Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.ui/src')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/IncludeInfo.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java95
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java501
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StyledInclude.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.java63
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BlockFlowInfo.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BranchFlowInfo.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ConditionalFlowInfo.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/DoWhileFlowInfo.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java156
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowContext.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java231
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ForFlowInfo.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericConditionalFlowInfo.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericSequentialFlowInfo.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/IfFlowInfo.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InOutFlowAnalyzer.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java74
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/RangeBasedForFlowInfo.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ReturnFlowInfo.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/SwitchFlowInfo.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ThrowFlowInfo.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/TryFlowInfo.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/WhileFlowInfo.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/participants/ResourceModifications.java116
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java254
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextType.java306
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContext.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContextType.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContextType.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContext.java81
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContextType.java103
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CModelUtil.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Messages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Resources.java112
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/SimplePositionTracker.java81
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java281
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java157
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java75
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BusyCursorJobRunner.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java150
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java720
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java73
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICStatusConstants.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java61
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java2977
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java192
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java128
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceToCElementAdapterFactory.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexHandler.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java76
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java122
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AlignConstAction.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java150
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CollapseAllAction.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java197
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogHandler.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java87
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExpandAllAction.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FindWordAction.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenAllFilesHandler.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java136
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java179
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java77
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexHandler.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java81
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java103
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesHandler.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateUnresolvedIncludesHandler.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java103
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java128
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/IBuildConsoleStreamDecorator.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java90
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java94
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java349
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java116
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHProviderManager.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java55
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java1058
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java161
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java73
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java226
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java167
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java148
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java85
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java166
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java143
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/FormattingScopeDialog.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java85
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ResizableStatusDialog.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java109
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TableTextCellEditor.java503
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TextFieldNavigationHandler.java161
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java970
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java353
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java128
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryBasePage.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java345
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java2148
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java244
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialog.java192
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntryDialog.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsPropertyPage.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelectionDialog.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTabBlock.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescriptor.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java49
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialog.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.java150
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java224
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java324
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java1097
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java110
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlink.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java137
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementIncludeResolver.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSelectMarkerRulerAction.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java404
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSupport.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTemplatesPage.java98
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ContributedSemanticHighlighting.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java220
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronizer.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICAnnotation.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java60
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPostSaveListener.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java91
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java412
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndexUpdateRequestor.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InteractiveHeaderChooser.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java53
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvider.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionHistory.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionToDeclarationJob.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java224
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java287
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java261
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingWithOwnPreference.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java395
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SortLinesAction.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.java148
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.java102
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java129
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java59
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationModelEvent.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java153
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java111
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/AnonymousStructFilter.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ArchiveFilter.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java213
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ExecutableFilter.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterDescriptor.java143
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NamePatternFilter.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCElementFilter.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ObjectFilter.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/SharedFilter.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CFunctionSummary.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpBook.java84
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpEntry.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java94
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpTopic.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java59
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java138
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.java129
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java180
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBFile.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownAction.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java99
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.java203
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBNode.java272
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBRemoveFromView.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java1280
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java59
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAction.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexAction.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java49
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexNode.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexView.java159
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java146
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingEntryDialog.java86
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java113
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java151
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersPage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java144
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java194
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvider.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionProvider.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDecorator.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGroup.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionProvider.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java245
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java61
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java59
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java138
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java604
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java371
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java145
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java65
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java216
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java90
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java613
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java111
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStyleBlock.java73
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStylePreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java484
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ConfigurationBlockPropertyAndPreferencePage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java368
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java177
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionBlock.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionEditDialog.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java108
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionPreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeCategoriesBlock.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeGroupStyleBlock.java99
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeOrderBlock.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasBlock.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasPreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStyleBlock.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStylePreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java140
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java161
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java280
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java393
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesBlock.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesPreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java146
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java52
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java153
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePage.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityIntegerFieldEditor.java123
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePage.java240
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java182
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java442
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java114
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java71
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java87
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java109
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java212
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java153
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java94
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPage.java357
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java162
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java141
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java88
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModifyDialog.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java149
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileStore.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java59
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogTabPage.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersioner.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java227
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTabPage.java1236
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java313
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java749
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPage.java96
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java213
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java566
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java194
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview.java140
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java2099
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java585
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java58
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeParametersControl.java260
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ClassMemberInserter.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Container.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java250
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java52
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ParameterEditDialog.java112
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java58
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferences.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/VariableNameInformation.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/AbstractCElementRenameChange.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CCompositeChange.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CreateFileChange.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/DeleteFileChange.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/UndoCTextFileChange.java99
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java84
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilityComposite.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabeledTextField.java109
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelectionPanel.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantInfo.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java92
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantWizard.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPage.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExpressionExtractor.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java151
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionWizard.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/FunctionExtractor.java65
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtractableStatementFinder.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnStatementFinder.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarReplacerVisitor.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/StatementExtractor.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailName.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java86
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableWizard.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/InputPage.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorDescriptor.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorFactory.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FieldDescriptor.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java77
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java94
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodWizard.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodData.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodInputPage.java55
-rwxr-xr-xcore/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java111
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodWizard.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDefinitionInsertLocationFinder.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodToImplementConfig.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterHandler.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterInfo.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java69
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java178
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/GCCHeaderSubstitutionMaps.java616
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutionMap.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutor.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IElementSelector.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IHeaderChooser.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreationContext.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreator.java83
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeGroupStyle.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeMap.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java122
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeUtil.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/InclusionRequest.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/Messages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/SymbolExportMap.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java2615
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.java150
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVisitor.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java254
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java146
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java182
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java202
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java158
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java101
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java188
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java494
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java612
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoring.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java877
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java88
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringWizard.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileReferenceAdjuster.java84
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java459
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java203
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameModifications.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameParticipantHelper.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java127
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/SourceFolderRenameParticipant.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java563
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/reorg/RefactoringModifications.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRefactoringStrategy.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/InsertionPointFinder.java131
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSupportedException.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/RefactoringJob.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromClassToInHeaderStrategy.java52
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java58
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToClassStrategy.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java59
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNodeHelper.java113
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoring.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringContext.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringRunner.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStrategyFactory.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingActionDelegate.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Checks.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java68
-rwxr-xr-xcore/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerator.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/resources/ResourceExclusionContributor.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElement.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchLabelProvider.java63
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListContentProvider.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListLabelProvider.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java449
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java156
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchProviderManager.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java89
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeContentProvider.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeLabelProvider.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUnresolvedIncludesQuery.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewPage.java69
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CountLabelProvider.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LRUWorkingSets.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java67
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetAction.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesHandler.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java240
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java75
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java135
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java164
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java93
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java274
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java846
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBraceRule.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java151
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java237
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java74
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java122
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java136
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java137
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java647
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java644
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COperatorRule.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java65
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java90
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java158
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java67
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPresentationReconciler.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java88
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordIterator.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CombinedWordRule.java74
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java537
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java64
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICReconcilingListener.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineComparator.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/NumberRule.java184
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PartitionDamager.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharRule.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java89
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java118
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java120
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.java450
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java335
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHover.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpandHover.java67
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java334
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java59
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java150
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CExpandHover.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java84
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java299
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformationProvider.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.java135
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java407
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java196
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java375
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java209
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextInformation.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java157
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java313
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java244
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHandler.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java183
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java321
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java360
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/FunctionCompletionProposal.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java196
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java108
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuesser.java64
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/PositionBasedCompletionProposal.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java129
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java254
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java240
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java81
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProposal.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java86
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor.java98
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorrectionProposal.java95
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java103
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefactoringProposal.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrectionProposal.java105
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java91
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDictionary.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerConfiguration.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java52
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java140
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java754
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java85
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java98
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStrategy.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java160
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java107
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java69
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java270
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java68
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java957
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java103
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java113
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java60
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyAction.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java123
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java173
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.java85
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java225
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvider.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THNode.java61
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java1189
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java186
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java252
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java53
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java39
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java256
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/NameComposer.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.java102
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTableViewer.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.java531
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.java759
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.java88
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RowLayouter.java174
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java60
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StatusLineHandler.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java201
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java90
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java64
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Util.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ViewerPane.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvider.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider.java599
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressNode.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.java75
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java702
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java185
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java126
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java91
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.java60
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAST.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IncludeFolderDecorator.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java222
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java110
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java86
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPresenter.java103
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java101
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java118
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediator.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelProvider.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.java125
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.java298
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java83
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java95
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java314
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizard.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java122
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java53
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListDialogField.java269
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java111
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java115
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSelectionDialog.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java52
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java296
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java182
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java1905
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPrefs.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java546
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java794
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java128
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java119
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java88
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java147
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java517
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java96
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java170
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java49
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java77
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java90
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java525
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTemplateWizard.java148
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java125
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java125
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java258
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java126
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java163
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableLabelProvider.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableSelectionDialog.java84
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java646
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPage.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPageStrategy.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsProcessor.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.java81
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportWizard.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java121
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportWizard.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizard.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizardPage.java292
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImportExportException.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContribution.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfigsContribution.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContribution.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildJob.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsContribution.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribution.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.java198
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageContentProvider.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdater.java145
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfigurationElement.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfiguration.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationController.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationFactory.java63
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationController.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsController.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.java53
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java49
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationManager.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationsPage.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfiguration.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.java99
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUIImages.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java195
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java299
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementSorter.java101
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java168
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java107
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CodeGeneration.java207
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleListener.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleManager.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICDTConstants.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ILanguageUI.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IPropertyChangeParticipant.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/NamespacesGrouping.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java423
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/SharedImagesFactory.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java260
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java123
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeConfigAction.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java344
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java93
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java101
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java156
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java391
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java156
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenAction.java85
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java186
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java200
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java89
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java130
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java67
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/FastIndexerBlock.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionPage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IInputStatusValidator.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java611
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java58
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java85
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallHierarchyProvider.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/IExternalSearchProvider.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java126
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java245
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java238
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java576
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java106
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BuildVarListDialog.java77
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTHelpContextIds.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java98
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java54
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTUIListComparator.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java209
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java185
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java130
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java101
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java65
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider2.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java112
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java110
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PageLayout.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java158
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java75
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java340
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java114
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java254
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java74
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/Messages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributor.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java89
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java507
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java56
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionProposal.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IInvocationContext.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IProblemLocation.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickAssistProcessor.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickFixProcessor.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticHighlighter.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStore.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/SharedASTJob.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationContext.java76
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/IProposalFilter.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEditStrategy.java183
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java202
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java289
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCommentViewerConfiguration.java25
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanner.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionProposalComputer.java62
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickStrategy.java79
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDictionary.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java180
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java60
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTProjectWizard.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CNewWizard.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CWizardHandler.java186
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/EntryDescriptor.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ICPathContainerPage.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardItemsListListener.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardWithMemory.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCCProjectWizard.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java2796
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java265
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java913
1335 files changed, 60248 insertions, 59090 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java
index 13803c78fff..a234c44d82e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/IncludeInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/IncludeInfo.java
index c01bae97b80..d44b1d5fe3f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/IncludeInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/IncludeInfo.java
@@ -100,7 +100,7 @@ public class IncludeInfo implements Comparable<IncludeInfo> {
public int compareTo(IncludeInfo other) {
if (isSystem != other.isSystem)
return isSystem ? -1 : 1;
-
+
int length1 = name.length();
int length2 = other.name.length();
for (int i = 0; i < length1 && i < length2; i++) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java
index 2511c408203..be878e466b5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java
@@ -93,31 +93,31 @@ public class InclusionContext {
if (path == null) {
String directory = fCurrentDirectory == null ? null : fCurrentDirectory.toOSString();
String filePath = CPreprocessor.getAbsoluteInclusionPath(include.getName(), directory);
- if (filePath != null) {
- path = new Path(filePath);
- } else if (!include.isSystem() && !fIncludeSearchPath.isInhibitUseOfCurrentFileDirectory()) {
- // Check to see if we find a match in the current directory.
- filePath = ScannerUtility.createReconciledPath(directory, include.getName());
- if (fileExists(filePath)) {
- path = new Path(filePath);
- }
- }
+ if (filePath != null) {
+ path = new Path(filePath);
+ } else if (!include.isSystem() && !fIncludeSearchPath.isInhibitUseOfCurrentFileDirectory()) {
+ // Check to see if we find a match in the current directory.
+ filePath = ScannerUtility.createReconciledPath(directory, include.getName());
+ if (fileExists(filePath)) {
+ path = new Path(filePath);
+ }
+ }
- if (path == null) {
+ if (path == null) {
for (IncludeSearchPathElement pathElement : fIncludeSearchPath.getElements()) {
if (include.isSystem() && pathElement.isForQuoteIncludesOnly())
continue;
filePath = pathElement.getLocation(include.getName());
- if (fileExists(filePath)) {
- path = new Path(filePath);
- break;
- }
+ if (fileExists(filePath)) {
+ path = new Path(filePath);
+ break;
+ }
}
- }
- if (path == null)
- path = UNRESOLVED_INCLUDE;
- fIncludeResolutionCache.put(include, path);
- fInverseIncludeResolutionCache.put(path, include);
+ }
+ if (path == null)
+ path = UNRESOLVED_INCLUDE;
+ fIncludeResolutionCache.put(include, path);
+ fInverseIncludeResolutionCache.put(path, include);
}
return path == UNRESOLVED_INCLUDE ? null : path;
}
@@ -127,24 +127,24 @@ public class InclusionContext {
* the file is not on the include search path. Current directory is not considered to be a part
* of the include path by this method.
*/
- public IncludeInfo getIncludeForHeaderFile(IPath fullPath) {
- IncludeInfo include = fInverseIncludeResolutionCache.get(fullPath);
- if (include != null)
- return include;
- String headerLocation = fullPath.toOSString();
- String shortestInclude = null;
- boolean isSystem = false;
+ public IncludeInfo getIncludeForHeaderFile(IPath fullPath) {
+ IncludeInfo include = fInverseIncludeResolutionCache.get(fullPath);
+ if (include != null)
+ return include;
+ String headerLocation = fullPath.toOSString();
+ String shortestInclude = null;
+ boolean isSystem = false;
for (IncludeSearchPathElement pathElement : fIncludeSearchPath.getElements()) {
String includeDirective = pathElement.getIncludeDirective(headerLocation);
- if (includeDirective != null &&
- (shortestInclude == null || shortestInclude.length() > includeDirective.length())) {
+ if (includeDirective != null
+ && (shortestInclude == null || shortestInclude.length() > includeDirective.length())) {
shortestInclude = includeDirective;
isSystem = !pathElement.isForQuoteIncludesOnly();
}
}
if (shortestInclude == null) {
- if (fIncludeSearchPath.isInhibitUseOfCurrentFileDirectory() || fCurrentDirectory == null ||
- !fCurrentDirectory.isPrefixOf(fullPath)) {
+ if (fIncludeSearchPath.isInhibitUseOfCurrentFileDirectory() || fCurrentDirectory == null
+ || !fCurrentDirectory.isPrefixOf(fullPath)) {
return null;
}
shortestInclude = fullPath.setDevice(null).removeFirstSegments(fCurrentDirectory.segmentCount()).toString();
@@ -154,31 +154,31 @@ public class InclusionContext {
// if the header was included by #include_next.
fInverseIncludeResolutionCache.put(fullPath, include);
return include;
- }
+ }
/**
* Returns the include directive that resolves to the given header file, or {@code null} if
* the file is not on the include search path. Current directory is not considered to be a part
* of the include path by this method.
*/
- public IncludeInfo getIncludeForHeaderFile(IPath fullPath, boolean isSystem) {
- IncludeInfo include = fInverseIncludeResolutionCache.get(fullPath);
- if (include != null)
- return include;
- String headerLocation = fullPath.toOSString();
- String shortestInclude = null;
+ public IncludeInfo getIncludeForHeaderFile(IPath fullPath, boolean isSystem) {
+ IncludeInfo include = fInverseIncludeResolutionCache.get(fullPath);
+ if (include != null)
+ return include;
+ String headerLocation = fullPath.toOSString();
+ String shortestInclude = null;
for (IncludeSearchPathElement pathElement : fIncludeSearchPath.getElements()) {
if (isSystem && pathElement.isForQuoteIncludesOnly())
continue;
String includeDirective = pathElement.getIncludeDirective(headerLocation);
- if (includeDirective != null &&
- (shortestInclude == null || shortestInclude.length() > includeDirective.length())) {
+ if (includeDirective != null
+ && (shortestInclude == null || shortestInclude.length() > includeDirective.length())) {
shortestInclude = includeDirective;
}
}
if (shortestInclude == null) {
- if (fIncludeSearchPath.isInhibitUseOfCurrentFileDirectory() || fCurrentDirectory == null ||
- !fCurrentDirectory.isPrefixOf(fullPath)) {
+ if (fIncludeSearchPath.isInhibitUseOfCurrentFileDirectory() || fCurrentDirectory == null
+ || !fCurrentDirectory.isPrefixOf(fullPath)) {
return null;
}
shortestInclude = fullPath.setDevice(null).removeFirstSegments(fCurrentDirectory.segmentCount()).toString();
@@ -188,9 +188,9 @@ public class InclusionContext {
// if the header was included by #include_next.
fInverseIncludeResolutionCache.put(fullPath, include);
return include;
- }
+ }
- public IncludeGroupStyle getIncludeStyle(IPath headerPath) {
+ public IncludeGroupStyle getIncludeStyle(IPath headerPath) {
IncludeKind includeKind;
IncludeInfo includeInfo = getIncludeForHeaderFile(headerPath);
if (includeInfo != null && includeInfo.isSystem()) {
@@ -282,7 +282,7 @@ public class InclusionContext {
name = getRelativePath(header);
}
if (name == null) {
- name = header.toPortableString(); // Last resort.
+ name = header.toPortableString(); // Last resort.
}
}
return new IncludeInfo(name, style.isAngleBrackets());
@@ -315,9 +315,8 @@ public class InclusionContext {
public Pattern getKeepPragmaPattern() {
if (fKeepPragmaPattern == null) {
- String keepPattern = CCorePreferenceConstants.getPreference(
- CCorePreferenceConstants.INCLUDE_KEEP_PATTERN, fProject,
- CCorePreferenceConstants.DEFAULT_INCLUDE_KEEP_PATTERN);
+ String keepPattern = CCorePreferenceConstants.getPreference(CCorePreferenceConstants.INCLUDE_KEEP_PATTERN,
+ fProject, CCorePreferenceConstants.DEFAULT_INCLUDE_KEEP_PATTERN);
try {
fKeepPragmaPattern = Pattern.compile(keepPattern);
} catch (PatternSyntaxException e) {
@@ -331,7 +330,7 @@ public class InclusionContext {
* Sets the effective translation unit location that overrides the default value obtained by
* calling {@code getTranslationUnit().getLocation()}.
*
- * @param location the file system location to set
+ * @param location the file system location to set
*/
public void setTranslationUnitLocation(IPath location) {
this.fTuLocation = location;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
index 8de99ca8181..3bbbba6b5e4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
@@ -80,54 +80,49 @@ import org.eclipse.cdt.internal.ui.util.NameComposer;
import org.eclipse.cdt.internal.ui.viewsupport.ProjectTemplateStore;
public class StubUtility {
- private static final String[] EMPTY= {};
-
+ private static final String[] EMPTY = {};
+
private StubUtility() {
}
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getHeaderFileContent(ITranslationUnit, String, String, String)
- */
- public static String getHeaderFileContent(ITranslationUnit tu, String declarations,
- String fileComment, String includes, String namespaceBegin, String namespaceEnd,
- String namespaceName, String typeComment, String typeName,
- String lineDelimiter) throws CoreException {
- return getHeaderFileContent(getDefaultFileTemplate(tu), tu, declarations, fileComment,
- includes, namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName,
- lineDelimiter);
+ */
+ public static String getHeaderFileContent(ITranslationUnit tu, String declarations, String fileComment,
+ String includes, String namespaceBegin, String namespaceEnd, String namespaceName, String typeComment,
+ String typeName, String lineDelimiter) throws CoreException {
+ return getHeaderFileContent(getDefaultFileTemplate(tu), tu, declarations, fileComment, includes, namespaceBegin,
+ namespaceEnd, namespaceName, typeComment, typeName, lineDelimiter);
}
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getHeaderFileContent(Template, ITranslationUnit, String, String, String)
- */
- public static String getHeaderFileContent(Template template, ITranslationUnit tu,
- String declarations, String fileComment, String includes, String namespaceBegin,
- String namespaceEnd, String namespaceName, String typeComment, String typeName,
- String lineDelimiter) throws CoreException {
+ */
+ public static String getHeaderFileContent(Template template, ITranslationUnit tu, String declarations,
+ String fileComment, String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+ String typeComment, String typeName, String lineDelimiter) throws CoreException {
if (template == null) {
return null;
}
- ICProject project= tu.getCProject();
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+ ICProject project = tu.getCProject();
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setTranslationUnitVariables(tu);
- String includeGuardSymbol= generateIncludeGuardSymbol(tu.getResource(), project);
+ String includeGuardSymbol = generateIncludeGuardSymbol(tu.getResource(), project);
context.setVariable(CodeTemplateContextType.DECLARATIONS, declarations != null ? declarations : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment : ""); //$NON-NLS-1$
- context.setVariable(CodeTemplateContextType.INCLUDE_GUARD_SYMBOL, includeGuardSymbol != null ? includeGuardSymbol : ""); //$NON-NLS-1$
+ context.setVariable(CodeTemplateContextType.INCLUDE_GUARD_SYMBOL,
+ includeGuardSymbol != null ? includeGuardSymbol : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.INCLUDES, includes != null ? includes : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.NAMESPACE_BEGIN, namespaceBegin != null ? namespaceBegin : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.NAMESPACE_END, namespaceEnd != null ? namespaceEnd : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.NAMESPACE_NAME, namespaceName != null ? namespaceName : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.TYPE_COMMENT, typeComment != null ? typeComment : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.TYPENAME, typeName != null ? typeName : ""); //$NON-NLS-1$
- String[] fullLine= {
- CodeTemplateContextType.DECLARATIONS, CodeTemplateContextType.FILE_COMMENT,
- CodeTemplateContextType.INCLUDES,
- CodeTemplateContextType.NAMESPACE_BEGIN, CodeTemplateContextType.NAMESPACE_END,
- CodeTemplateContextType.TYPE_COMMENT
- };
+ String[] fullLine = { CodeTemplateContextType.DECLARATIONS, CodeTemplateContextType.FILE_COMMENT,
+ CodeTemplateContextType.INCLUDES, CodeTemplateContextType.NAMESPACE_BEGIN,
+ CodeTemplateContextType.NAMESPACE_END, CodeTemplateContextType.TYPE_COMMENT };
String text = evaluateTemplate(context, template, fullLine);
if (text != null && !text.endsWith(lineDelimiter))
@@ -138,29 +133,26 @@ public class StubUtility {
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getBodyFileContent(ITranslationUnit, String, String, String, String, String, String, String, String, String)
- */
- public static String getBodyFileContent(ITranslationUnit tu,
- String declarations, String fileComment, String includes, String namespaceBegin,
- String namespaceEnd, String namespaceName, String typeComment, String typeName,
- String lineDelimiter) throws CoreException {
- return getBodyFileContent(getDefaultFileTemplate(tu), tu, declarations, fileComment,
- includes, namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName,
- lineDelimiter);
+ */
+ public static String getBodyFileContent(ITranslationUnit tu, String declarations, String fileComment,
+ String includes, String namespaceBegin, String namespaceEnd, String namespaceName, String typeComment,
+ String typeName, String lineDelimiter) throws CoreException {
+ return getBodyFileContent(getDefaultFileTemplate(tu), tu, declarations, fileComment, includes, namespaceBegin,
+ namespaceEnd, namespaceName, typeComment, typeName, lineDelimiter);
}
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getBodyFileContent(Template, ITranslationUnit, String, String, String, String, String, String, String, String, String)
- */
- public static String getBodyFileContent(Template template, ITranslationUnit tu,
- String declarations, String fileComment, String includes, String namespaceBegin,
- String namespaceEnd, String namespaceName, String typeComment, String typeName,
- String lineDelimiter) throws CoreException {
+ */
+ public static String getBodyFileContent(Template template, ITranslationUnit tu, String declarations,
+ String fileComment, String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+ String typeComment, String typeName, String lineDelimiter) throws CoreException {
if (template == null) {
return null;
}
- ICProject project= tu.getCProject();
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+ ICProject project = tu.getCProject();
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setTranslationUnitVariables(tu);
context.setVariable(CodeTemplateContextType.DECLARATIONS, declarations != null ? declarations : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment : ""); //$NON-NLS-1$
@@ -170,12 +162,9 @@ public class StubUtility {
context.setVariable(CodeTemplateContextType.NAMESPACE_NAME, namespaceName != null ? namespaceName : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.TYPE_COMMENT, typeComment != null ? typeComment : ""); //$NON-NLS-1$
context.setVariable(CodeTemplateContextType.TYPENAME, typeName != null ? typeName : ""); //$NON-NLS-1$
- String[] fullLine= {
- CodeTemplateContextType.DECLARATIONS, CodeTemplateContextType.FILE_COMMENT,
- CodeTemplateContextType.INCLUDES,
- CodeTemplateContextType.NAMESPACE_BEGIN, CodeTemplateContextType.NAMESPACE_END,
- CodeTemplateContextType.TYPE_COMMENT
- };
+ String[] fullLine = { CodeTemplateContextType.DECLARATIONS, CodeTemplateContextType.FILE_COMMENT,
+ CodeTemplateContextType.INCLUDES, CodeTemplateContextType.NAMESPACE_BEGIN,
+ CodeTemplateContextType.NAMESPACE_END, CodeTemplateContextType.TYPE_COMMENT };
String text = evaluateTemplate(context, template, fullLine);
if (text != null && !text.endsWith(lineDelimiter))
text += lineDelimiter;
@@ -185,14 +174,12 @@ public class StubUtility {
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getTestFileContent(ITranslationUnit, String, String, String)
- */
- public static String getTestFileContent(ITranslationUnit tu, String declarations,
- String fileComment, String includes, String namespaceBegin, String namespaceEnd,
- String namespaceName, String typeName, String lineDelimiter)
- throws CoreException {
- return getBodyFileContent(getTestFileTemplate(tu), tu, declarations, fileComment,
- includes, namespaceBegin, namespaceEnd, namespaceName, null, typeName,
- lineDelimiter);
+ */
+ public static String getTestFileContent(ITranslationUnit tu, String declarations, String fileComment,
+ String includes, String namespaceBegin, String namespaceEnd, String namespaceName, String typeName,
+ String lineDelimiter) throws CoreException {
+ return getBodyFileContent(getTestFileTemplate(tu), tu, declarations, fileComment, includes, namespaceBegin,
+ namespaceEnd, namespaceName, null, typeName, lineDelimiter);
}
public static String getFileContent(Template template, IFile file, String lineDelimiter) throws CoreException {
@@ -203,17 +190,18 @@ public class StubUtility {
}
FileTemplateContext context;
if (cproject != null) {
- context= new CodeTemplateContext(template.getContextTypeId(), cproject, lineDelimiter);
+ context = new CodeTemplateContext(template.getContextTypeId(), cproject, lineDelimiter);
} else {
- context= new FileTemplateContext(template.getContextTypeId(), lineDelimiter);
+ context = new FileTemplateContext(template.getContextTypeId(), lineDelimiter);
}
- String fileComment= getFileComment(file, lineDelimiter);
+ String fileComment = getFileComment(file, lineDelimiter);
context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment : ""); //$NON-NLS-1$
- String includeGuardSymbol= generateIncludeGuardSymbol(file, cproject);
- context.setVariable(CodeTemplateContextType.INCLUDE_GUARD_SYMBOL, includeGuardSymbol != null ? includeGuardSymbol : ""); //$NON-NLS-1$
+ String includeGuardSymbol = generateIncludeGuardSymbol(file, cproject);
+ context.setVariable(CodeTemplateContextType.INCLUDE_GUARD_SYMBOL,
+ includeGuardSymbol != null ? includeGuardSymbol : ""); //$NON-NLS-1$
context.setResourceVariables(file);
- String[] fullLine= { CodeTemplateContextType.FILE_COMMENT };
-
+ String[] fullLine = { CodeTemplateContextType.FILE_COMMENT };
+
String text = evaluateTemplate(context, template, fullLine);
if (text != null) {
// Remove blank lines at the end.
@@ -228,7 +216,7 @@ public class StubUtility {
if (len < text.length()) {
text = text.substring(0, len);
} else if (!text.endsWith(lineDelimiter)) {
- text += lineDelimiter; // Add a line delimiter at the end.
+ text += lineDelimiter; // Add a line delimiter at the end.
}
}
return text;
@@ -237,18 +225,19 @@ public class StubUtility {
/*
* Don't use this method directly, use CodeGeneration.
*/
- public static String getClassBodyContent(ICProject project, String className,
- String classMemberDeclarations, String lineDelimiter) throws CoreException {
- Template template= getCodeTemplate(CodeTemplateContextType.CLASS_BODY_ID, project);
+ public static String getClassBodyContent(ICProject project, String className, String classMemberDeclarations,
+ String lineDelimiter) throws CoreException {
+ Template template = getCodeTemplate(CodeTemplateContextType.CLASS_BODY_ID, project);
if (template == null) {
return classMemberDeclarations;
}
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, className);
- context.setVariable(CodeTemplateContextType.DECLARATIONS, classMemberDeclarations != null ? classMemberDeclarations : ""); //$NON-NLS-1$
- String str= evaluateTemplate(context, template,
- new String[] { CodeTemplateContextType.DECLARATIONS });
- if (str == null && classMemberDeclarations != null && !Strings.containsOnlyWhitespaces(classMemberDeclarations)) {
+ context.setVariable(CodeTemplateContextType.DECLARATIONS,
+ classMemberDeclarations != null ? classMemberDeclarations : ""); //$NON-NLS-1$
+ String str = evaluateTemplate(context, template, new String[] { CodeTemplateContextType.DECLARATIONS });
+ if (str == null && classMemberDeclarations != null
+ && !Strings.containsOnlyWhitespaces(classMemberDeclarations)) {
return classMemberDeclarations;
}
return str;
@@ -257,25 +246,26 @@ public class StubUtility {
/*
* Don't use this method directly, use CodeGeneration.
*/
- public static String getMethodBodyContent(ICProject project, String typeName, String methodName, String bodyStatement, String lineDelimiter) throws CoreException {
- String templateId= CodeTemplateContextType.METHODSTUB_ID;
+ public static String getMethodBodyContent(ICProject project, String typeName, String methodName,
+ String bodyStatement, String lineDelimiter) throws CoreException {
+ String templateId = CodeTemplateContextType.METHODSTUB_ID;
return getMethodBodyContent(templateId, project, typeName, methodName, bodyStatement, lineDelimiter);
}
/*
* Don't use this method directly, use CodeGeneration.
*/
- public static String getMethodBodyContent(String templateId, ICProject project, String typeName,
- String methodName, String bodyStatement, String lineDelimiter) throws CoreException {
- Template template= getCodeTemplate(templateId, project);
+ public static String getMethodBodyContent(String templateId, ICProject project, String typeName, String methodName,
+ String bodyStatement, String lineDelimiter) throws CoreException {
+ Template template = getCodeTemplate(templateId, project);
if (template == null) {
return bodyStatement;
}
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
context.setVariable(CodeTemplateContextType.BODY_STATEMENT, bodyStatement != null ? bodyStatement : ""); //$NON-NLS-1$
- String str= evaluateTemplate(context, template, new String[] { CodeTemplateContextType.BODY_STATEMENT });
+ String str = evaluateTemplate(context, template, new String[] { CodeTemplateContextType.BODY_STATEMENT });
if (str == null && bodyStatement != null && !Strings.containsOnlyWhitespaces(bodyStatement)) {
return bodyStatement;
}
@@ -285,29 +275,31 @@ public class StubUtility {
/*
* Don't use this method directly, use CodeGeneration.
*/
- public static String getConstructorBodyContent(ICProject project, String typeName, String bodyStatement, String lineDelimiter) throws CoreException {
- String templateId= CodeTemplateContextType.CONSTRUCTORSTUB_ID;
+ public static String getConstructorBodyContent(ICProject project, String typeName, String bodyStatement,
+ String lineDelimiter) throws CoreException {
+ String templateId = CodeTemplateContextType.CONSTRUCTORSTUB_ID;
return getMethodBodyContent(templateId, project, typeName, typeName, bodyStatement, lineDelimiter);
}
/*
* Don't use this method directly, use CodeGeneration.
*/
- public static String getDestructorBodyContent(ICProject project, String typeName, String bodyStatement, String lineDelimiter) throws CoreException {
- String templateId= CodeTemplateContextType.DESTRUCTORSTUB_ID;
- return getMethodBodyContent(templateId, project, typeName, "~"+typeName, bodyStatement, lineDelimiter); //$NON-NLS-1$
+ public static String getDestructorBodyContent(ICProject project, String typeName, String bodyStatement,
+ String lineDelimiter) throws CoreException {
+ String templateId = CodeTemplateContextType.DESTRUCTORSTUB_ID;
+ return getMethodBodyContent(templateId, project, typeName, "~" + typeName, bodyStatement, lineDelimiter); //$NON-NLS-1$
}
/*
* Don't use this method directly, use CodeGeneration.
*/
- public static String getNamespaceBeginContent(ICProject project, String namespaceName,
- String lineDelimiter) throws CoreException {
- Template template= getCodeTemplate(CodeTemplateContextType.NAMESPACE_BEGIN_ID, project);
+ public static String getNamespaceBeginContent(ICProject project, String namespaceName, String lineDelimiter)
+ throws CoreException {
+ Template template = getCodeTemplate(CodeTemplateContextType.NAMESPACE_BEGIN_ID, project);
if (template == null) {
return null;
}
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setVariable(CodeTemplateContextType.NAMESPACE_NAME, namespaceName);
return evaluateTemplate(context, template, EMPTY);
}
@@ -315,13 +307,13 @@ public class StubUtility {
/*
* Don't use this method directly, use CodeGeneration.
*/
- public static String getNamespaceEndContent(ICProject project, String namespaceName,
- String lineDelimiter) throws CoreException {
- Template template= getCodeTemplate(CodeTemplateContextType.NAMESPACE_END_ID, project);
+ public static String getNamespaceEndContent(ICProject project, String namespaceName, String lineDelimiter)
+ throws CoreException {
+ Template template = getCodeTemplate(CodeTemplateContextType.NAMESPACE_END_ID, project);
if (template == null) {
return null;
}
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setVariable(CodeTemplateContextType.NAMESPACE_NAME, namespaceName);
return evaluateTemplate(context, template, EMPTY);
}
@@ -329,42 +321,43 @@ public class StubUtility {
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getFileComment(ITranslationUnit, String)
- */
+ */
public static String getFileComment(ITranslationUnit tu, String lineDelimiter) throws CoreException {
- Template template= getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, tu.getCProject());
+ Template template = getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, tu.getCProject());
if (template == null) {
return null;
}
-
- ICProject project= tu.getCProject();
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+
+ ICProject project = tu.getCProject();
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setTranslationUnitVariables(tu);
return evaluateTemplate(context, template);
- }
+ }
private static String getFileComment(IFile file, String lineDelimiter) throws CoreException {
- Template template= getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, file.getProject());
+ Template template = getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, file.getProject());
if (template == null) {
return null;
}
-
- FileTemplateContext context= new FileTemplateContext(template.getContextTypeId(), lineDelimiter);
+
+ FileTemplateContext context = new FileTemplateContext(template.getContextTypeId(), lineDelimiter);
context.setResourceVariables(file);
return evaluateTemplate(context, template);
- }
+ }
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getClassComment(ITranslationUnit, String, String)
- */
- public static String getClassComment(ITranslationUnit tu, String typeQualifiedName, String lineDelimiter) throws CoreException {
- Template template= getCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, tu.getCProject());
+ */
+ public static String getClassComment(ITranslationUnit tu, String typeQualifiedName, String lineDelimiter)
+ throws CoreException {
+ Template template = getCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, tu.getCProject());
if (template == null) {
return null;
}
-
- ICProject project= tu.getCProject();
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+
+ ICProject project = tu.getCProject();
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setTranslationUnitVariables(tu);
context.setVariable(CodeTemplateContextType.TYPENAME, typeQualifiedName);
return evaluateTemplate(context, template);
@@ -374,26 +367,30 @@ public class StubUtility {
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getMethodComment(ITranslationUnit, String, String, String[], String[], String, String)
*/
- public static String getMethodComment(ITranslationUnit tu, String typeName, String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig, String lineDelimiter) throws CoreException {
- String templateId= CodeTemplateContextType.METHODCOMMENT_ID;
- return getMethodComment(templateId, tu, typeName, methodName, paramNames, excTypeSig, retTypeSig, lineDelimiter);
+ public static String getMethodComment(ITranslationUnit tu, String typeName, String methodName, String[] paramNames,
+ String[] excTypeSig, String retTypeSig, String lineDelimiter) throws CoreException {
+ String templateId = CodeTemplateContextType.METHODCOMMENT_ID;
+ return getMethodComment(templateId, tu, typeName, methodName, paramNames, excTypeSig, retTypeSig,
+ lineDelimiter);
}
-
+
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getConstructorComment(ITranslationUnit, String, String[], String[], String)
*/
- public static String getConstructorComment(ITranslationUnit tu, String typeName, String[] paramNames, String[] excTypeSig, String lineDelimiter) throws CoreException {
- String templateId= CodeTemplateContextType.CONSTRUCTORCOMMENT_ID;
+ public static String getConstructorComment(ITranslationUnit tu, String typeName, String[] paramNames,
+ String[] excTypeSig, String lineDelimiter) throws CoreException {
+ String templateId = CodeTemplateContextType.CONSTRUCTORCOMMENT_ID;
return getMethodComment(templateId, tu, typeName, typeName, paramNames, excTypeSig, null, lineDelimiter);
}
-
+
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getDestructorComment(ITranslationUnit, String, String[], String)
*/
- public static String getDestructorComment(ITranslationUnit tu, String typeName, String[] excTypeSig, String lineDelimiter) throws CoreException {
- String templateId= CodeTemplateContextType.DESTRUCTORCOMMENT_ID;
+ public static String getDestructorComment(ITranslationUnit tu, String typeName, String[] excTypeSig,
+ String lineDelimiter) throws CoreException {
+ String templateId = CodeTemplateContextType.DESTRUCTORCOMMENT_ID;
return getMethodComment(templateId, tu, typeName, "~" + typeName, EMPTY, excTypeSig, null, lineDelimiter); //$NON-NLS-1$
}
@@ -401,23 +398,25 @@ public class StubUtility {
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.cdt.ui.CodeGeneration#getMethodComment(ITranslationUnit, String, String, String[], String[], String, String)
*/
- public static String getMethodComment(String templateId, ITranslationUnit tu, String typeName, String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig, String lineDelimiter) throws CoreException {
- Template template= getCodeTemplate(templateId, tu.getCProject());
+ public static String getMethodComment(String templateId, ITranslationUnit tu, String typeName, String methodName,
+ String[] paramNames, String[] excTypeSig, String retTypeSig, String lineDelimiter) throws CoreException {
+ Template template = getCodeTemplate(templateId, tu.getCProject());
if (template == null) {
return null;
}
- CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), tu.getCProject(), lineDelimiter);
+ CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), tu.getCProject(),
+ lineDelimiter);
context.setTranslationUnitVariables(tu);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
-
+
if (retTypeSig != null) {
context.setVariable(CodeTemplateContextType.RETURN_TYPE, retTypeSig);
}
context.setTranslationUnitVariables(tu);
TemplateBuffer buffer;
try {
- buffer= context.evaluate(template);
+ buffer = context.evaluate(template);
} catch (BadLocationException e) {
throw new CoreException(Status.CANCEL_STATUS);
} catch (TemplateException e) {
@@ -426,40 +425,41 @@ public class StubUtility {
if (buffer == null) {
return null;
}
-
+
// TODO doc comment tags
-
- String str= buffer.getString();
+
+ String str = buffer.getString();
if (Strings.containsOnlyWhitespaces(str)) {
return null;
}
return str;
}
-
+
// remove lines for empty variables, prefix multi-line variables
- private static String fixFullLineVariables(TemplateBuffer buffer, String[] variables) throws MalformedTreeException, BadLocationException {
- IDocument doc= new Document(buffer.getString());
- int nLines= doc.getNumberOfLines();
- MultiTextEdit edit= new MultiTextEdit();
- HashSet<Integer> removedLines= new HashSet<Integer>();
- for (int i= 0; i < variables.length; i++) {
- TemplateVariable position= findVariable(buffer, variables[i]);
+ private static String fixFullLineVariables(TemplateBuffer buffer, String[] variables)
+ throws MalformedTreeException, BadLocationException {
+ IDocument doc = new Document(buffer.getString());
+ int nLines = doc.getNumberOfLines();
+ MultiTextEdit edit = new MultiTextEdit();
+ HashSet<Integer> removedLines = new HashSet<Integer>();
+ for (int i = 0; i < variables.length; i++) {
+ TemplateVariable position = findVariable(buffer, variables[i]);
if (position == null) {
continue;
}
if (position.getLength() > 0) {
- int[] offsets= position.getOffsets();
- for (int j= 0; j < offsets.length; j++) {
+ int[] offsets = position.getOffsets();
+ for (int j = 0; j < offsets.length; j++) {
final int offset = offsets[j];
try {
- int startLine= doc.getLineOfOffset(offset);
- int startOffset= doc.getLineOffset(startLine);
- int endLine= doc.getLineOfOffset(offset + position.getLength());
- String prefix= doc.get(startOffset, offset - startOffset);
+ int startLine = doc.getLineOfOffset(offset);
+ int startOffset = doc.getLineOffset(startLine);
+ int endLine = doc.getLineOfOffset(offset + position.getLength());
+ String prefix = doc.get(startOffset, offset - startOffset);
if (prefix.length() > 0 && startLine < endLine) {
- for (int line= startLine + 1; line <= endLine; ++line) {
- int lineOffset= doc.getLineOffset(line);
+ for (int line = startLine + 1; line <= endLine; ++line) {
+ int lineOffset = doc.getLineOffset(line);
edit.addChild(new InsertEdit(lineOffset, prefix));
}
}
@@ -468,15 +468,16 @@ public class StubUtility {
}
}
} else {
- int[] offsets= position.getOffsets();
- for (int k= 0; k < offsets.length; k++) {
- int line= doc.getLineOfOffset(offsets[k]);
- IRegion lineInfo= doc.getLineInformation(line);
- int offset= lineInfo.getOffset();
- String str= doc.get(offset, lineInfo.getLength());
- if (Strings.containsOnlyWhitespaces(str) && nLines > line + 1 && removedLines.add(Integer.valueOf(line))) {
- int nextStart= doc.getLineOffset(line + 1);
- int length= nextStart - offset;
+ int[] offsets = position.getOffsets();
+ for (int k = 0; k < offsets.length; k++) {
+ int line = doc.getLineOfOffset(offsets[k]);
+ IRegion lineInfo = doc.getLineInformation(line);
+ int offset = lineInfo.getOffset();
+ String str = doc.get(offset, lineInfo.getLength());
+ if (Strings.containsOnlyWhitespaces(str) && nLines > line + 1
+ && removedLines.add(Integer.valueOf(line))) {
+ int nextStart = doc.getLineOffset(line + 1);
+ int length = nextStart - offset;
edit.addChild(new DeleteEdit(offset, length));
}
}
@@ -487,20 +488,20 @@ public class StubUtility {
}
private static TemplateVariable findVariable(TemplateBuffer buffer, String variable) {
- TemplateVariable[] positions= buffer.getVariables();
- for (int i= 0; i < positions.length; i++) {
- TemplateVariable curr= positions[i];
+ TemplateVariable[] positions = buffer.getVariables();
+ for (int i = 0; i < positions.length; i++) {
+ TemplateVariable curr = positions[i];
if (variable.equals(curr.getType())) {
return curr;
}
}
return null;
}
-
+
private static String evaluateTemplate(TemplateContext context, Template template) throws CoreException {
TemplateBuffer buffer;
try {
- buffer= context.evaluate(template);
+ buffer = context.evaluate(template);
} catch (BadLocationException e) {
throw new CoreException(Status.CANCEL_STATUS);
} catch (TemplateException e) {
@@ -508,20 +509,21 @@ public class StubUtility {
}
if (buffer == null)
return null;
- String str= buffer.getString();
+ String str = buffer.getString();
if (Strings.containsOnlyWhitespaces(str)) {
return null;
}
return str;
}
-
- private static String evaluateTemplate(TemplateContext context, Template template, String[] fullLineVariables) throws CoreException {
+
+ private static String evaluateTemplate(TemplateContext context, Template template, String[] fullLineVariables)
+ throws CoreException {
TemplateBuffer buffer;
try {
- buffer= context.evaluate(template);
+ buffer = context.evaluate(template);
if (buffer == null)
return null;
- String str= fixFullLineVariables(buffer, fullLineVariables);
+ String str = fixFullLineVariables(buffer, fullLineVariables);
if (Strings.containsOnlyWhitespaces(str)) {
return null;
}
@@ -535,7 +537,7 @@ public class StubUtility {
/**
* Returns the line delimiter which is used in the specified project.
- *
+ *
* @param project the C project, or <code>null</code>
* @return the used line delimiter
*/
@@ -544,44 +546,47 @@ public class StubUtility {
}
private static String getProjectLineDelimiter(ICProject cProject) {
- IProject project= null;
+ IProject project = null;
if (cProject != null)
- project= cProject.getProject();
-
- String lineDelimiter= getLineDelimiterPreference(project);
+ project = cProject.getProject();
+
+ String lineDelimiter = getLineDelimiterPreference(project);
if (lineDelimiter != null)
return lineDelimiter;
-
+
return System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
public static String getLineDelimiterPreference(IProject project) {
IScopeContext[] scopeContext;
if (project != null) {
// project preference
- scopeContext= new IScopeContext[] { new ProjectScope(project) };
- String lineDelimiter= Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
+ scopeContext = new IScopeContext[] { new ProjectScope(project) };
+ String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME,
+ Platform.PREF_LINE_SEPARATOR, null, scopeContext);
if (lineDelimiter != null)
return lineDelimiter;
}
// workspace preference
- scopeContext= new IScopeContext[] { InstanceScope.INSTANCE };
- String platformDefault= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, platformDefault, scopeContext);
+ scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
+ String platformDefault = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR,
+ platformDefault, scopeContext);
}
-
+
/**
* Examines a string and returns the first line delimiter found.
*/
public static String getLineDelimiterUsed(ICElement elem) throws CModelException {
- if (elem == null) return ""; //$NON-NLS-1$
-
- ITranslationUnit cu= (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
+ if (elem == null)
+ return ""; //$NON-NLS-1$
+
+ ITranslationUnit cu = (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
if (cu != null && cu.exists()) {
- IBuffer buf= cu.getBuffer();
- int length= buf.getLength();
- for (int i= 0; i < length; i++) {
- char ch= buf.getChar(i);
+ IBuffer buf = cu.getBuffer();
+ int length = buf.getLength();
+ for (int i = 0; i < length; i++) {
+ char ch = buf.getChar(i);
if (ch == SWT.CR) {
if (i + 1 < length) {
if (buf.getChar(i + 1) == SWT.LF) {
@@ -599,20 +604,20 @@ public class StubUtility {
/**
* Get the default task tag for the given project.
- *
+ *
* @param project
* @return the default task tag
*/
public static String getTodoTaskTag(ICProject project) {
- String markers= null;
+ String markers = null;
if (project == null) {
- markers= CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_TAGS);
+ markers = CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_TAGS);
} else {
- markers= project.getOption(CCorePreferenceConstants.TODO_TASK_TAGS, true);
+ markers = project.getOption(CCorePreferenceConstants.TODO_TASK_TAGS, true);
}
-
+
if (markers != null && markers.length() > 0) {
- int idx= markers.indexOf(',');
+ int idx = markers.indexOf(',');
if (idx == -1) {
return markers;
}
@@ -620,35 +625,35 @@ public class StubUtility {
}
return CCorePreferenceConstants.DEFAULT_TASK_TAG;
}
-
+
public static boolean doAddComments(ICProject project) {
- return PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, project, false);
+ return PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, project, false);
}
-
+
private static Template getDefaultFileTemplate(ITranslationUnit tu) {
- String templateId= null;
+ String templateId = null;
if (tu.isASMLanguage()) {
- templateId= CodeTemplateContextType.ASM_SOURCEFILE_ID;
+ templateId = CodeTemplateContextType.ASM_SOURCEFILE_ID;
} else if (tu.isCXXLanguage()) {
if (tu.isHeaderUnit()) {
- templateId= CodeTemplateContextType.CPP_HEADERFILE_ID;
+ templateId = CodeTemplateContextType.CPP_HEADERFILE_ID;
} else {
- templateId= CodeTemplateContextType.CPP_SOURCEFILE_ID;
+ templateId = CodeTemplateContextType.CPP_SOURCEFILE_ID;
}
} else if (tu.isCLanguage()) {
if (tu.isHeaderUnit()) {
- templateId= CodeTemplateContextType.C_HEADERFILE_ID;
+ templateId = CodeTemplateContextType.C_HEADERFILE_ID;
} else {
- templateId= CodeTemplateContextType.C_SOURCEFILE_ID;
+ templateId = CodeTemplateContextType.C_SOURCEFILE_ID;
}
}
return getCodeTemplate(templateId, tu.getCProject());
}
private static Template getTestFileTemplate(ITranslationUnit tu) {
- String templateId= null;
+ String templateId = null;
if (tu.isCXXLanguage() && !tu.isHeaderUnit()) {
- templateId= CodeTemplateContextType.CPP_TESTFILE_ID;
+ templateId = CodeTemplateContextType.CPP_TESTFILE_ID;
}
return getCodeTemplate(templateId, tu.getCProject());
}
@@ -660,7 +665,7 @@ public class StubUtility {
private static Template getCodeTemplate(String id, IProject project) {
if (project == null)
return CUIPlugin.getDefault().getCodeTemplateStore().findTemplateById(id);
- ProjectTemplateStore projectStore= new ProjectTemplateStore(project);
+ ProjectTemplateStore projectStore = new ProjectTemplateStore(project);
try {
projectStore.load();
} catch (IOException e) {
@@ -670,10 +675,9 @@ public class StubUtility {
}
public static String generateIncludeGuardSymbol(IResource file, ICProject cproject) {
- int scheme = PreferenceConstants.getPreference(
- PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME, cproject,
- PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME);
-
+ int scheme = PreferenceConstants.getPreference(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME,
+ cproject, PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME);
+
switch (scheme) {
case PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_PATH:
if (file == null)
@@ -683,7 +687,7 @@ public class StubUtility {
IPath basePath = root == null ? cproject.getPath() : root.getPath();
path = PathUtil.makeRelativePath(path, basePath);
return generateIncludeGuardSymbolFromFilePath(path.toString());
-
+
default:
CUIPlugin.log("Unknown preference value " + scheme + " for include guard scheme.", null); //$NON-NLS-1$ //$NON-NLS-2$
//$FALL-THROUGH$
@@ -693,9 +697,9 @@ public class StubUtility {
return generateIncludeGuardSymbolFromFilePath(file.getName());
case PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_UUID:
- return generateIncludeGuardSymbolFromUUID();
+ return generateIncludeGuardSymbolFromUUID();
}
- }
+ }
public static String generateIncludeGuardSymbolFromFilePath(String filename) {
// Convert to upper case and replace invalid characters with underscores,
@@ -705,7 +709,7 @@ public class StubUtility {
char ch = filename.charAt(i);
if (Character.isLetterOrDigit(ch)) {
buf.append(Character.toUpperCase(ch));
- } else if (buf.length() > 0){
+ } else if (buf.length() > 0) {
buf.append('_');
}
}
@@ -715,17 +719,17 @@ public class StubUtility {
private static String generateIncludeGuardSymbolFromUUID() {
String uuid = UUID.randomUUID().toString();
-
+
// 1) Make sure the guard always starts with a letter.
// 2) Convert to upper case and remove invalid characters
- //
+ //
// e.g. convert
// 067e6162-3b6f-4ae2-a171-2470b63dff00 to
// H067E6162-3b6F-4AE2-A171-2470B63DFF00
StringBuilder buf = new StringBuilder();
-
+
buf.append('H');
-
+
for (int i = 0; i < uuid.length(); ++i) {
char ch = uuid.charAt(i);
if (Character.isLetterOrDigit(ch)) {
@@ -740,7 +744,7 @@ public class StubUtility {
/**
* Get a set of file templates for the given content types.
- *
+ *
* @param contentTypes the list of content types
* @param project the project or <code>null</code>
* @return an array of templates
@@ -751,17 +755,17 @@ public class StubUtility {
}
TemplatePersistenceData[] templateDatas;
if (project == null) {
- templateDatas= CUIPlugin.getDefault().getCodeTemplateStore().getTemplateData(true);
+ templateDatas = CUIPlugin.getDefault().getCodeTemplateStore().getTemplateData(true);
} else {
- ProjectTemplateStore projectStore= new ProjectTemplateStore(project.getProject());
+ ProjectTemplateStore projectStore = new ProjectTemplateStore(project.getProject());
try {
projectStore.load();
} catch (IOException e) {
CUIPlugin.log(e);
}
- templateDatas= projectStore.getTemplateData();
+ templateDatas = projectStore.getTemplateData();
}
- List<Template> result= new ArrayList<Template>();
+ List<Template> result = new ArrayList<Template>();
for (int j = 0; j < contentTypes.length; j++) {
for (int i = 0; i < templateDatas.length; i++) {
Template template = templateDatas[i].getTemplate();
@@ -777,27 +781,27 @@ public class StubUtility {
/**
* Returns a suggested name for a getter that is guaranteed to be a valid identifier
* and not collide with a set of given names.
- *
+ *
* @param baseName the name used as an inspiration
* @param bool <code>true</code> if the getter is for a boolean field
* @param excluded the set of excluded names, can be {@code null}
* @param context the translation unit for which the code is intended, can be {@code null}
* @return the suggested name, or {@code null} if all possible names are taken
*/
- public static String suggestGetterName(String baseName, boolean bool, Set<String> excluded, ITranslationUnit context) {
+ public static String suggestGetterName(String baseName, boolean bool, Set<String> excluded,
+ ITranslationUnit context) {
IPreferencesService preferences = Platform.getPreferencesService();
- int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION,
- PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE, null);
- String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER, "", null); //$NON-NLS-1$
- String prefix = bool ?
- preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN, "is", null) : //$NON-NLS-1$
- preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_GETTER_PREFIX, "get", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_GETTER_SUFFIX, "", null); //$NON-NLS-1$
+ int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE, null);
+ String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER, "", null); //$NON-NLS-1$
+ String prefix = bool
+ ? preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN,
+ "is", null) //$NON-NLS-1$
+ : preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_GETTER_PREFIX, "get", null); //$NON-NLS-1$
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_GETTER_SUFFIX, "", //$NON-NLS-1$
+ null);
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
return adjustName(composer.compose(baseName), excluded, context);
}
@@ -805,7 +809,7 @@ public class StubUtility {
/**
* Returns a suggested name for a setter that is guaranteed to be a valid identifier
* and not collide with a set of given names.
- *
+ *
* @param baseName the name used as an inspiration
* @param excluded the set of excluded names, can be {@code null}
* @param context the translation unit for which the code is intended, can be {@code null}
@@ -818,10 +822,10 @@ public class StubUtility {
PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE, null);
String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
PreferenceConstants.NAME_STYLE_SETTER_WORD_DELIMITER, "", null); //$NON-NLS-1$
- String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_SETTER_PREFIX, "set", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_SETTER_SUFFIX, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_SETTER_PREFIX, "set", //$NON-NLS-1$
+ null);
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_SETTER_SUFFIX, "", //$NON-NLS-1$
+ null);
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
return adjustName(composer.compose(baseName), excluded, context);
}
@@ -829,7 +833,7 @@ public class StubUtility {
/**
* Returns a suggested name for a function parameter that is guaranteed to be a valid identifier
* and not collide with a set of given names.
- *
+ *
* @param baseName the name used as an inspiration
* @param excluded the set of excluded names, can be {@code null}
* @param context the translation unit for which the code is intended, can be {@code null}
@@ -842,10 +846,10 @@ public class StubUtility {
PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER, "", null); //$NON-NLS-1$
- String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX, "", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX, "", //$NON-NLS-1$
+ null);
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", //$NON-NLS-1$
+ null);
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
return adjustName(composer.compose(baseName), excluded, context);
}
@@ -853,7 +857,7 @@ public class StubUtility {
/**
* Returns a suggested name for a method that is guaranteed to be a valid identifier
* and not collide with a set of given names.
- *
+ *
* @param baseName the name used as an inspiration
* @param excluded the set of excluded names, can be {@code null}
* @param context the translation unit for which the code is intended, can be {@code null}
@@ -866,10 +870,10 @@ public class StubUtility {
PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
PreferenceConstants.NAME_STYLE_METHOD_WORD_DELIMITER, "", null); //$NON-NLS-1$
- String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_METHOD_PREFIX, "", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_METHOD_SUFFIX, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_METHOD_PREFIX, "", //$NON-NLS-1$
+ null);
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_METHOD_SUFFIX, "", //$NON-NLS-1$
+ null);
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
return adjustName(composer.compose(baseName), excluded, context);
}
@@ -877,11 +881,11 @@ public class StubUtility {
/**
* Checks is the given name is valid and, if not, tries to adjust it by adding a numeric suffix
* to it.
- *
+ *
* @param name the name to check and, possibly, adjust
* @param namesToAvoid the set of names to avoid
* @param context the translation unit, can be {@code null}
- * @return the adjusted name, or <code>null</code> if a valid name could not be generated.
+ * @return the adjusted name, or <code>null</code> if a valid name could not be generated.
*/
private static String adjustName(String name, Set<String> namesToAvoid, ITranslationUnit context) {
ILanguage language = null;
@@ -897,11 +901,11 @@ public class StubUtility {
/**
* Checks is the given name is valid and, if not, tries to adjust it by adding a numeric suffix
* to it.
- *
+ *
* @param name the name to check and, possibly, adjust
* @param namesToAvoid the set of names to avoid
* @param language the language of the translation unit, can be {@code null}
- * @return the adjusted name, or <code>null</code> if a valid name could not be generated.
+ * @return the adjusted name, or <code>null</code> if a valid name could not be generated.
*/
private static String adjustName(String name, Set<String> namesToAvoid, ILanguage language) {
if (language == null) {
@@ -917,8 +921,7 @@ public class StubUtility {
}
int numTries = namesToAvoid != null ? namesToAvoid.size() + 1 : 1;
for (int i = 1; i <= numTries; i++) {
- if ((namesToAvoid == null || !namesToAvoid.contains(name)) &&
- isValidIdentifier(name, language)) {
+ if ((namesToAvoid == null || !namesToAvoid.contains(name)) && isValidIdentifier(name, language)) {
return name;
}
name = originalName + i;
@@ -937,7 +940,7 @@ public class StubUtility {
* Returns the trimmed field name. Leading and trailing non-alphanumeric characters are trimmed.
* If the first word of the name consists of a single letter and the name contains more than
* one word, the first word is removed.
- *
+ *
* @param fieldName a field name to trim
* @return the trimmed field name
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StyledInclude.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StyledInclude.java
index 3d4b76228d8..4e52f1de0fb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StyledInclude.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StyledInclude.java
@@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeGroupStyle;
* Represents a new or an existing include statement together with the style associated with it.
*/
public class StyledInclude {
- private final IPath header; // null for existing unresolved includes
+ private final IPath header; // null for existing unresolved includes
private final IncludeInfo includeInfo; // never null
private final IncludeGroupStyle style;
private IASTPreprocessorIncludeStatement existingInclude;
@@ -72,7 +72,7 @@ public class StyledInclude {
@Override
public int hashCode() {
if (header != null)
- return header.hashCode(); // includeInfo is ignored if header is not null
+ return header.hashCode(); // includeInfo is ignored if header is not null
return includeInfo.hashCode();
}
@@ -86,7 +86,7 @@ public class StyledInclude {
return false;
StyledInclude other = (StyledInclude) obj;
if (header != null)
- return header.equals(other.header); // includeInfo is ignored if header is not null
+ return header.equals(other.header); // includeInfo is ignored if header is not null
if (other.header != null)
return false;
return includeInfo.equals(other.includeInfo);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java
index 5b47ff71204..191dd72f0b5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java
@@ -25,53 +25,62 @@ import org.eclipse.cdt.internal.corext.fix.LinkedProposalPositionGroup.PositionI
public class LinkedProposalModel {
private Map<String, LinkedProposalPositionGroup> fPositionGroups;
private LinkedProposalPositionGroup.PositionInformation fEndPosition;
-
+
public void addPositionGroup(LinkedProposalPositionGroup positionGroup) {
if (positionGroup == null) {
throw new IllegalArgumentException("positionGroup must not be null"); //$NON-NLS-1$
}
-
+
if (fPositionGroups == null) {
- fPositionGroups= new HashMap<String, LinkedProposalPositionGroup>();
+ fPositionGroups = new HashMap<String, LinkedProposalPositionGroup>();
}
fPositionGroups.put(positionGroup.getGroupId(), positionGroup);
}
-
+
public LinkedProposalPositionGroup getPositionGroup(String groupId, boolean createIfNotExisting) {
- LinkedProposalPositionGroup group= fPositionGroups != null ? (LinkedProposalPositionGroup) fPositionGroups.get(groupId) : null;
+ LinkedProposalPositionGroup group = fPositionGroups != null
+ ? (LinkedProposalPositionGroup) fPositionGroups.get(groupId)
+ : null;
if (createIfNotExisting && group == null) {
- group= new LinkedProposalPositionGroup(groupId);
+ group = new LinkedProposalPositionGroup(groupId);
addPositionGroup(group);
}
return group;
}
-
+
public Iterator<LinkedProposalPositionGroup> getPositionGroupIterator() {
if (fPositionGroups == null) {
return new Iterator<LinkedProposalPositionGroup>() {
@Override
- public boolean hasNext() {return false;}
+ public boolean hasNext() {
+ return false;
+ }
+
@Override
- public LinkedProposalPositionGroup next() {return null;}
+ public LinkedProposalPositionGroup next() {
+ return null;
+ }
+
@Override
- public void remove() {}
+ public void remove() {
+ }
};
}
return fPositionGroups.values().iterator();
}
-
+
/**
* Sets the end position of the linked mode to the end of the passed range.
* @param position The position that describes the end position of the linked mode.
*/
public void setEndPosition(PositionInformation position) {
- fEndPosition= position;
+ fEndPosition = position;
}
-
+
public void setEndPosition(ITrackedNodePosition position) {
setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, false));
}
-
+
public PositionInformation getEndPosition() {
return fEndPosition;
}
@@ -81,7 +90,7 @@ public class LinkedProposalModel {
}
public void clear() {
- fPositionGroups= null;
- fEndPosition= null;
+ fPositionGroups = null;
+ fEndPosition = null;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.java
index ddbd089565b..703d4935f28 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.java
@@ -26,7 +26,6 @@ import org.eclipse.text.edits.TextEdit;
import org.eclipse.cdt.core.dom.rewrite.ITrackedNodePosition;
-
public class LinkedProposalPositionGroup {
/**
* {@link LinkedProposalPositionGroup.PositionInformation} describes a position
@@ -36,99 +35,101 @@ public class LinkedProposalPositionGroup {
*/
public static abstract class PositionInformation {
public abstract int getOffset();
+
public abstract int getLength();
+
public abstract int getSequenceRank();
}
-
+
public static class Proposal {
-
+
private String fDisplayString;
private Image fImage;
private int fRelevance;
public Proposal(String displayString, Image image, int relevance) {
- fDisplayString= displayString;
- fImage= image;
- fRelevance= relevance;
+ fDisplayString = displayString;
+ fImage = image;
+ fRelevance = relevance;
}
-
+
public String getDisplayString() {
return fDisplayString;
}
-
+
public Image getImage() {
return fImage;
}
-
+
public int getRelevance() {
return fRelevance;
}
-
+
public void setImage(Image image) {
- fImage= image;
+ fImage = image;
}
-
+
public String getAdditionalProposalInfo() {
return null;
}
-
- public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException {
+
+ public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask,
+ LinkedModeModel model) throws CoreException {
return new ReplaceEdit(position.getOffset(), position.getLength(), fDisplayString);
}
- }
-
+ }
+
public static PositionInformation createPositionInformation(ITrackedNodePosition pos, boolean isFirst) {
return new TrackedNodePosition(pos, isFirst);
}
-
+
private static class TrackedNodePosition extends PositionInformation {
private final ITrackedNodePosition fPos;
private final boolean fIsFirst;
-
+
public TrackedNodePosition(ITrackedNodePosition pos, boolean isFirst) {
- fPos= pos;
- fIsFirst= isFirst;
+ fPos = pos;
+ fIsFirst = isFirst;
}
@Override
public int getOffset() {
return fPos.getStartPosition();
}
-
+
@Override
public int getLength() {
return fPos.getLength();
}
-
+
@Override
public int getSequenceRank() {
return fIsFirst ? 0 : 1;
}
}
-
+
private final String fGroupId;
private final List<PositionInformation> fPositions;
private final List<Proposal> fProposals;
-
public LinkedProposalPositionGroup(String groupID) {
- fGroupId= groupID;
- fPositions= new ArrayList<PositionInformation>();
- fProposals= new ArrayList<Proposal>();
+ fGroupId = groupID;
+ fPositions = new ArrayList<PositionInformation>();
+ fProposals = new ArrayList<Proposal>();
}
-
+
public void addPosition(PositionInformation position) {
fPositions.add(position);
}
-
+
public void addProposal(Proposal proposal) {
fProposals.add(proposal);
}
-
+
public void addPosition(ITrackedNodePosition position, boolean isFirst) {
addPosition(createPositionInformation(position, isFirst));
}
-
+
public void addProposal(String displayString, Image image, int relevance) {
addProposal(new Proposal(displayString, image, relevance));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BlockFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BlockFlowInfo.java
index 04f2c8426fb..3b848abf9d9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BlockFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BlockFlowInfo.java
@@ -19,5 +19,3 @@ class BlockFlowInfo extends GenericSequentialFlowInfo {
public BlockFlowInfo() {
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BranchFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BranchFlowInfo.java
index e839e6107dd..8af3398e546 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BranchFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/BranchFlowInfo.java
@@ -22,9 +22,7 @@ class BranchFlowInfo extends FlowInfo {
public BranchFlowInfo(IASTName label, FlowContext context) {
super(NO_RETURN);
- fBranches= new HashSet<String>(2);
+ fBranches = new HashSet<String>(2);
fBranches.add(makeString(label));
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ConditionalFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ConditionalFlowInfo.java
index b41f59963a4..b789da78cd3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ConditionalFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ConditionalFlowInfo.java
@@ -30,7 +30,7 @@ class ConditionalFlowInfo extends FlowInfo {
if (truePart == null && falsePart == null)
return;
- GenericConditionalFlowInfo cond= new GenericConditionalFlowInfo();
+ GenericConditionalFlowInfo cond = new GenericConditionalFlowInfo();
if (truePart != null)
cond.mergeAccessMode(truePart, context);
@@ -43,5 +43,3 @@ class ConditionalFlowInfo extends FlowInfo {
mergeAccessModeSequential(cond, context);
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/DoWhileFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/DoWhileFlowInfo.java
index 793a7f8f37d..a38b8136354 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/DoWhileFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/DoWhileFlowInfo.java
@@ -21,12 +21,12 @@ class DoWhileFlowInfo extends FlowInfo {
if (info == null)
return;
- fActionBranches= info.branches();
+ fActionBranches = info.branches();
assign(info);
if (fActionBranches && fReturnKind == VALUE_RETURN) {
- fReturnKind= PARTIAL_RETURN;
+ fReturnKind = PARTIAL_RETURN;
}
}
@@ -36,4 +36,3 @@ class DoWhileFlowInfo extends FlowInfo {
mergeAccessModeSequential(info, context);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
index dbcc68fd762..77e521de038 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
@@ -102,11 +102,11 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
static protected class SwitchData {
private boolean fHasDefaultCase;
- private final List<IRegion> fRanges= new ArrayList<IRegion>(4);
- private final List<FlowInfo> fInfos= new ArrayList<FlowInfo>(4);
+ private final List<IRegion> fRanges = new ArrayList<IRegion>(4);
+ private final List<FlowInfo> fInfos = new ArrayList<FlowInfo>(4);
public void setHasDefaultCase() {
- fHasDefaultCase= true;
+ fHasDefaultCase = true;
}
public boolean hasDefaultCase() {
@@ -136,7 +136,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
public FlowAnalyzer(FlowContext context) {
super(true);
- fFlowContext= context;
+ fFlowContext = context;
}
protected abstract boolean shouldCreateReturnFlowInfo(IASTReturnStatement node);
@@ -225,7 +225,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
protected FlowInfo assignFlowInfo(IASTNode target, IASTNode source) {
- FlowInfo result= getFlowInfo(source);
+ FlowInfo result = getFlowInfo(source);
setFlowInfo(target, result);
return result;
}
@@ -237,26 +237,26 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
//---- Helpers to process sequential flow infos -------------------------------------
protected GenericSequentialFlowInfo processSequential(IASTNode parent, IASTNode[] nodes) {
- GenericSequentialFlowInfo result= createSequential(parent);
+ GenericSequentialFlowInfo result = createSequential(parent);
process(result, nodes);
return result;
}
protected GenericSequentialFlowInfo processSequential(IASTNode parent, Iterable<IASTNode> nodes) {
- GenericSequentialFlowInfo result= createSequential(parent);
+ GenericSequentialFlowInfo result = createSequential(parent);
process(result, nodes);
return result;
}
protected GenericSequentialFlowInfo processSequential(IASTNode parent, IASTNode node) {
- GenericSequentialFlowInfo result= createSequential(parent);
+ GenericSequentialFlowInfo result = createSequential(parent);
if (node != null)
result.merge(getFlowInfo(node), fFlowContext);
return result;
}
protected GenericSequentialFlowInfo processSequential(IASTNode parent, IASTNode node1, IASTNode node2) {
- GenericSequentialFlowInfo result= createSequential(parent);
+ GenericSequentialFlowInfo result = createSequential(parent);
if (node1 != null)
result.merge(getFlowInfo(node1), fFlowContext);
if (node2 != null)
@@ -265,13 +265,13 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
protected GenericSequentialFlowInfo createSequential(IASTNode parent) {
- GenericSequentialFlowInfo result= createSequential();
+ GenericSequentialFlowInfo result = createSequential();
setFlowInfo(parent, result);
return result;
}
protected GenericSequentialFlowInfo createSequential(IASTNode[] nodes) {
- GenericSequentialFlowInfo result= createSequential();
+ GenericSequentialFlowInfo result = createSequential();
process(result, nodes);
return result;
}
@@ -357,60 +357,60 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
public int visit(IASTBreakStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTCaseStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTDefaultStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTCompoundStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTContinueStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTDeclarationStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTDoStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTExpressionStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTForStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTGotoStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTIfStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTLabelStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTNullStatement node) {
// Null statements aren't of any interest.
return PROCESS_SKIP;
}
-
+
public int visit(ICPPASTRangeBasedForStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(ICPPASTTryBlockStatement node) {
if (traverseNode(node)) {
fFlowContext.pushExceptions(node);
@@ -422,19 +422,19 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
return PROCESS_SKIP;
}
-
+
public int visit(ICPPASTCatchHandler node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTReturnStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTSwitchStatement node) {
return PROCESS_CONTINUE;
}
-
+
public int visit(IASTWhileStatement node) {
return PROCESS_CONTINUE;
}
@@ -442,7 +442,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
//---- Helper to process switch statement ----------------------------------------
protected SwitchData createSwitchData(IASTSwitchStatement node) {
- SwitchData result= new SwitchData();
+ SwitchData result = new SwitchData();
IASTStatement[] statements;
IASTStatement body = node.getBody();
if (body instanceof IASTCompoundStatement) {
@@ -453,9 +453,9 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
if (statements.length == 0)
return result;
- int start= -1;
- int end= -1;
- GenericSequentialFlowInfo info= null;
+ int start = -1;
+ int end = -1;
+ GenericSequentialFlowInfo info = null;
for (IASTStatement statement : statements) {
IASTFileLocation location = statement.getFileLocation();
@@ -464,24 +464,24 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
result.setHasDefaultCase();
}
if (info == null) {
- info= createSequential();
- start= location.getNodeOffset();
+ info = createSequential();
+ start = location.getNodeOffset();
} else {
if (info.isReturn() || info.isPartialReturn() || info.branches()) {
result.add(new Region(start, end - start + 1), info);
- info= createSequential();
- start= location.getNodeOffset();
+ info = createSequential();
+ start = location.getNodeOffset();
}
}
} else {
if (info == null) {
- info= createSequential();
- start= location.getNodeOffset();
+ info = createSequential();
+ start = location.getNodeOffset();
} else {
info.merge(getFlowInfo(statement), fFlowContext);
}
}
- end= location.getNodeOffset() + location.getNodeLength() - 1;
+ end = location.getNodeOffset() + location.getNodeLength() - 1;
}
result.add(new Region(start, end - start + 1), info);
return result;
@@ -551,7 +551,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(IASTCompoundStatement node) {
- BlockFlowInfo info= createBlock();
+ BlockFlowInfo info = createBlock();
setFlowInfo(node, info);
process(info, node.getStatements());
return PROCESS_SKIP;
@@ -568,7 +568,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(IASTDoStatement node) {
- DoWhileFlowInfo info= createDoWhile();
+ DoWhileFlowInfo info = createDoWhile();
setFlowInfo(node, info);
info.mergeAction(getFlowInfo(node.getBody()), fFlowContext);
info.mergeCondition(getFlowInfo(node.getCondition()), fFlowContext);
@@ -582,7 +582,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(IASTForStatement node) {
- ForFlowInfo forInfo= createFor();
+ ForFlowInfo forInfo = createFor();
setFlowInfo(node, forInfo);
forInfo.mergeInitializer(createSequential(node.getInitializerStatement()), fFlowContext);
forInfo.mergeCondition(getFlowInfo(node.getConditionExpression()), fFlowContext);
@@ -599,7 +599,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(IASTIfStatement node) {
- IfFlowInfo info= createIf();
+ IfFlowInfo info = createIf();
setFlowInfo(node, info);
info.mergeCondition(getFlowInfo(node.getConditionExpression()), fFlowContext);
info.merge(getFlowInfo(node.getThenClause()), getFlowInfo(node.getElseClause()), fFlowContext);
@@ -617,7 +617,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(ICPPASTRangeBasedForStatement node) {
- RangeBasedForFlowInfo forInfo= createRangeBasedFor();
+ RangeBasedForFlowInfo forInfo = createRangeBasedFor();
setFlowInfo(node, forInfo);
forInfo.mergeDeclaration(getFlowInfo(node.getDeclaration()), fFlowContext);
forInfo.mergeInitializerClause(getFlowInfo(node.getInitializerClause()), fFlowContext);
@@ -627,7 +627,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(ICPPASTTryBlockStatement node) {
- TryFlowInfo info= createTry();
+ TryFlowInfo info = createTry();
setFlowInfo(node, info);
info.mergeTry(getFlowInfo(node.getTryBody()), fFlowContext);
for (ICPPASTCatchHandler catchHandler : node.getCatchHandlers()) {
@@ -643,7 +643,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
public int leave(IASTReturnStatement node) {
if (shouldCreateReturnFlowInfo(node)) {
- ReturnFlowInfo info= createReturn(node);
+ ReturnFlowInfo info = createReturn(node);
setFlowInfo(node, info);
info.merge(getFlowInfo(node.getReturnArgument()), fFlowContext);
} else {
@@ -657,11 +657,11 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
protected int leave(IASTSwitchStatement node, SwitchData data) {
- SwitchFlowInfo switchFlowInfo= createSwitch();
+ SwitchFlowInfo switchFlowInfo = createSwitch();
setFlowInfo(node, switchFlowInfo);
switchFlowInfo.mergeTest(getFlowInfo(node.getControllerExpression()), fFlowContext);
- FlowInfo[] cases= data.getInfos();
- for (int i= 0; i < cases.length; i++) {
+ FlowInfo[] cases = data.getInfos();
+ for (int i = 0; i < cases.length; i++) {
switchFlowInfo.mergeCase(cases[i], fFlowContext);
}
switchFlowInfo.mergeDefault(data.hasDefaultCase(), fFlowContext);
@@ -670,12 +670,11 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(IASTWhileStatement node) {
- WhileFlowInfo info= createWhile();
+ WhileFlowInfo info = createWhile();
setFlowInfo(node, info);
info.mergeCondition(getFlowInfo(node.getCondition()), fFlowContext);
if (node instanceof ICPPASTWhileStatement) {
- info.mergeCondition(getFlowInfo(((ICPPASTWhileStatement) node).getConditionDeclaration()),
- fFlowContext);
+ info.mergeCondition(getFlowInfo(((ICPPASTWhileStatement) node).getConditionDeclaration()), fFlowContext);
}
info.mergeAction(getFlowInfo(node.getBody()), fFlowContext);
info.removeLabel(null);
@@ -728,11 +727,11 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(IASTConditionalExpression node) {
- ConditionalFlowInfo info= createConditional();
+ ConditionalFlowInfo info = createConditional();
setFlowInfo(node, info);
info.mergeCondition(getFlowInfo(node.getLogicalConditionExpression()), fFlowContext);
- info.merge(getFlowInfo(node.getPositiveResultExpression()),
- getFlowInfo(node.getNegativeResultExpression()), fFlowContext);
+ info.merge(getFlowInfo(node.getPositiveResultExpression()), getFlowInfo(node.getNegativeResultExpression()),
+ fFlowContext);
return PROCESS_SKIP;
}
@@ -754,7 +753,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(IASTFunctionDefinition node) {
- GenericSequentialFlowInfo info= processSequential(node, node.getDeclSpecifier());
+ GenericSequentialFlowInfo info = processSequential(node, node.getDeclSpecifier());
process(info, node.getDeclarator());
process(info, node.getBody());
if (node instanceof ICPPASTFunctionWithTryBlock) {
@@ -764,7 +763,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(IASTSimpleDeclaration node) {
- GenericSequentialFlowInfo info= processSequential(node, node.getDeclSpecifier());
+ GenericSequentialFlowInfo info = processSequential(node, node.getDeclSpecifier());
process(info, node.getDeclarators());
return PROCESS_SKIP;
}
@@ -773,7 +772,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
public int leave(IASTParameterDeclaration node) {
if (skipNode(node))
return PROCESS_SKIP;
- GenericSequentialFlowInfo info= processSequential(node, node.getDeclSpecifier());
+ GenericSequentialFlowInfo info = processSequential(node, node.getDeclSpecifier());
process(info, node.getDeclarator());
return PROCESS_SKIP;
}
@@ -785,7 +784,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
IASTNode nestedOrName = node.getNestedDeclarator();
if (nestedOrName == null)
nestedOrName = node.getName();
- GenericSequentialFlowInfo info= processSequential(node, nestedOrName);
+ GenericSequentialFlowInfo info = processSequential(node, nestedOrName);
if (node instanceof IASTArrayDeclarator)
process(info, ((IASTArrayDeclarator) node).getArrayModifiers());
IASTNode[] parameters = null;
@@ -825,19 +824,19 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
case IASTBinaryExpression.op_plusAssign:
case IASTBinaryExpression.op_shiftLeftAssign:
case IASTBinaryExpression.op_shiftRightAssign:
- FlowInfo lhs= getFlowInfo(node.getOperand1());
- FlowInfo rhs= getFlowInfo(node.getOperand2());
+ FlowInfo lhs = getFlowInfo(node.getOperand1());
+ FlowInfo rhs = getFlowInfo(node.getOperand2());
if (lhs instanceof LocalFlowInfo) {
- LocalFlowInfo llhs= (LocalFlowInfo) lhs;
+ LocalFlowInfo llhs = (LocalFlowInfo) lhs;
llhs.setWriteAccess(fFlowContext);
if (operator != IASTBinaryExpression.op_assign) {
- GenericSequentialFlowInfo tmp= createSequential();
+ GenericSequentialFlowInfo tmp = createSequential();
tmp.merge(new LocalFlowInfo(llhs, FlowInfo.READ, fFlowContext), fFlowContext);
tmp.merge(rhs, fFlowContext);
- rhs= tmp;
+ rhs = tmp;
}
}
- GenericSequentialFlowInfo info= createSequential(node);
+ GenericSequentialFlowInfo info = createSequential(node);
// First process right and side and then left hand side.
info.merge(rhs, fFlowContext);
info.merge(lhs, fFlowContext);
@@ -855,7 +854,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
// Leaf node.
return PROCESS_SKIP;
}
-
+
public int leave(IASTIdExpression node) {
assignFlowInfo(node, node.getName());
return PROCESS_SKIP;
@@ -878,24 +877,23 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
case IASTUnaryExpression.op_prefixDecr:
case IASTUnaryExpression.op_postFixIncr:
case IASTUnaryExpression.op_postFixDecr: {
- FlowInfo info= getFlowInfo(node.getOperand());
+ FlowInfo info = getFlowInfo(node.getOperand());
if (info instanceof LocalFlowInfo) {
// Normally this should be done in the parent node since the write access takes
// place later. But there seems to be no case where this influences the flow
// analysis. So it is kept here to simplify the code.
- GenericSequentialFlowInfo result= createSequential(node);
+ GenericSequentialFlowInfo result = createSequential(node);
result.merge(info, fFlowContext);
- result.merge(new LocalFlowInfo((LocalFlowInfo)info, FlowInfo.WRITE, fFlowContext),
- fFlowContext);
+ result.merge(new LocalFlowInfo((LocalFlowInfo) info, FlowInfo.WRITE, fFlowContext), fFlowContext);
} else {
setFlowInfo(node, info);
}
break;
}
case IASTUnaryExpression.op_throw: {
- ThrowFlowInfo info= createThrow();
+ ThrowFlowInfo info = createThrow();
setFlowInfo(node, info);
- IASTExpression expression= node.getOperand();
+ IASTExpression expression = node.getOperand();
info.merge(getFlowInfo(expression), fFlowContext);
break;
}
@@ -916,9 +914,9 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
public int leave(IASTName node) {
if (skipNode(node) || node.isDeclaration() || node instanceof ICPPASTQualifiedName)
return PROCESS_SKIP;
- IBinding binding= node.resolveBinding();
+ IBinding binding = node.resolveBinding();
if (binding instanceof IVariable) {
- IVariable variable= (IVariable) binding;
+ IVariable variable = (IVariable) binding;
if (!(variable instanceof IField)) {
int index = fFlowContext.getIndexFromLocal(variable);
if (index >= 0) {
@@ -955,7 +953,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
}
public int leave(ICPPASTNewExpression node) {
- GenericSequentialFlowInfo info= processSequential(node, node.getTypeId());
+ GenericSequentialFlowInfo info = processSequential(node, node.getTypeId());
process(info, node.getPlacementArguments());
process(info, node.getInitializer());
return PROCESS_SKIP;
@@ -1022,11 +1020,11 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
return PROCESS_SKIP;
}
- private void processFunctionCall(IASTFunctionCallExpression node,
- IASTExpression functionNameExpression, IASTInitializerClause[] arguments) {
+ private void processFunctionCall(IASTFunctionCallExpression node, IASTExpression functionNameExpression,
+ IASTInitializerClause[] arguments) {
if (skipNode(node))
return;
- FunctionCallFlowInfo info= createFunctionCallFlowInfo();
+ FunctionCallFlowInfo info = createFunctionCallFlowInfo();
setFlowInfo(node, info);
info.mergeReceiver(getFlowInfo(functionNameExpression), fFlowContext);
for (IASTInitializerClause arg : arguments) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowContext.java
index d48fec5f57b..6fc93947916 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowContext.java
@@ -46,19 +46,19 @@ public class FlowContext extends LocalVariableIndex {
public FlowContext(IASTFunctionDefinition functionDefinition) {
super(functionDefinition);
- fExceptionStack= new ArrayList<ICPPASTCatchHandler[]>(3);
+ fExceptionStack = new ArrayList<ICPPASTCatchHandler[]>(3);
}
public void setConsiderAccessMode(boolean b) {
- fConsiderAccessMode= b;
+ fConsiderAccessMode = b;
}
public void setComputeMode(ComputeMode mode) {
- fComputeMode= mode;
+ fComputeMode = mode;
}
void setLoopReentranceMode(boolean b) {
- fLoopReentranceMode= b;
+ fLoopReentranceMode = b;
}
int getArrayLength() {
@@ -99,7 +99,7 @@ public class FlowContext extends LocalVariableIndex {
int index = getIndexFromLocal(localVariable);
if (index >= 0) {
if (fLocals == null)
- fLocals= new IVariable[getNumLocalVariables()];
+ fLocals = new IVariable[getNumLocalVariables()];
fLocals[index] = localVariable;
}
}
@@ -121,7 +121,7 @@ public class FlowContext extends LocalVariableIndex {
for (ICPPASTCatchHandler catchHandler : catchHandlers) {
if (catchHandler.isCatchAll())
return true;
- IASTDeclaration caughtException= catchHandler.getDeclaration();
+ IASTDeclaration caughtException = catchHandler.getDeclaration();
if (caughtException instanceof IASTSimpleDeclaration) {
IASTDeclarator[] declarators = ((IASTSimpleDeclaration) caughtException).getDeclarators();
IType caughtType = CPPVisitor.createType(declarators[0]);
@@ -129,7 +129,7 @@ public class FlowContext extends LocalVariableIndex {
// 15.3
if (caughtType.isSameType(exceptionType))
return true;
- // TODO(sprigogin): Implement the rest of 15.3 matching logic.
+ // TODO(sprigogin): Implement the rest of 15.3 matching logic.
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java
index bcb83bf7c92..3d0b7da93c8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java
@@ -24,62 +24,67 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
public abstract class FlowInfo {
// Return statement handling.
- protected static final int NOT_POSSIBLE= 0;
- protected static final int UNDEFINED= 1;
- protected static final int NO_RETURN= 2;
- protected static final int PARTIAL_RETURN= 3;
- protected static final int VOID_RETURN= 4;
- protected static final int VALUE_RETURN= 5;
- protected static final int THROW= 6;
+ protected static final int NOT_POSSIBLE = 0;
+ protected static final int UNDEFINED = 1;
+ protected static final int NO_RETURN = 2;
+ protected static final int PARTIAL_RETURN = 3;
+ protected static final int VOID_RETURN = 4;
+ protected static final int VALUE_RETURN = 5;
+ protected static final int THROW = 6;
// Local access handling.
- public static final int UNUSED= 1 << 0;
- public static final int READ= 1 << 1;
- public static final int READ_POTENTIAL= 1 << 2;
- public static final int WRITE= 1 << 3;
- public static final int WRITE_POTENTIAL= 1 << 4;
- public static final int UNKNOWN= 1 << 5;
+ public static final int UNUSED = 1 << 0;
+ public static final int READ = 1 << 1;
+ public static final int READ_POTENTIAL = 1 << 2;
+ public static final int WRITE = 1 << 3;
+ public static final int WRITE_POTENTIAL = 1 << 4;
+ public static final int UNKNOWN = 1 << 5;
// Table to merge access modes for condition statements (e.g branch[x] || branch[y]).
- private static final int[][] ACCESS_MODE_CONDITIONAL_TABLE= {
- /* UNUSED READ READ_POTENTIAL WRITE WRITE_POTENTIAL UNKNOWN */
- /* UNUSED */ { UNUSED, READ_POTENTIAL, READ_POTENTIAL, WRITE_POTENTIAL, WRITE_POTENTIAL, UNKNOWN },
- /* READ */ { READ_POTENTIAL, READ, READ_POTENTIAL, UNKNOWN, UNKNOWN, UNKNOWN },
- /* READ_POTENTIAL */ { READ_POTENTIAL, READ_POTENTIAL, READ_POTENTIAL, UNKNOWN, UNKNOWN, UNKNOWN },
- /* WRITE */ { WRITE_POTENTIAL, UNKNOWN, UNKNOWN, WRITE, WRITE_POTENTIAL, UNKNOWN },
- /* WRITE_POTENTIAL */ { WRITE_POTENTIAL, UNKNOWN, UNKNOWN, WRITE_POTENTIAL, WRITE_POTENTIAL, UNKNOWN },
- /* UNKNOWN */ { UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN }
- };
+ private static final int[][] ACCESS_MODE_CONDITIONAL_TABLE = {
+ /* UNUSED READ READ_POTENTIAL WRITE WRITE_POTENTIAL UNKNOWN */
+ /* UNUSED */ { UNUSED, READ_POTENTIAL, READ_POTENTIAL, WRITE_POTENTIAL, WRITE_POTENTIAL, UNKNOWN },
+ /* READ */ { READ_POTENTIAL, READ, READ_POTENTIAL, UNKNOWN, UNKNOWN, UNKNOWN },
+ /* READ_POTENTIAL */ { READ_POTENTIAL, READ_POTENTIAL, READ_POTENTIAL, UNKNOWN, UNKNOWN, UNKNOWN },
+ /* WRITE */ { WRITE_POTENTIAL, UNKNOWN, UNKNOWN, WRITE, WRITE_POTENTIAL, UNKNOWN },
+ /* WRITE_POTENTIAL */ { WRITE_POTENTIAL, UNKNOWN, UNKNOWN, WRITE_POTENTIAL, WRITE_POTENTIAL, UNKNOWN },
+ /* UNKNOWN */ { UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN } };
// Table to change access mode if there is an open branch statement
- private static final int[] ACCESS_MODE_OPEN_BRANCH_TABLE= {
- /* UNUSED READ READ_POTENTIAL WRITE WRITE_POTENTIAL UNKNOWN */
- UNUSED, READ_POTENTIAL, READ_POTENTIAL, WRITE_POTENTIAL, WRITE_POTENTIAL, UNKNOWN
- };
+ private static final int[] ACCESS_MODE_OPEN_BRANCH_TABLE = {
+ /* UNUSED READ READ_POTENTIAL WRITE WRITE_POTENTIAL UNKNOWN */
+ UNUSED, READ_POTENTIAL, READ_POTENTIAL, WRITE_POTENTIAL, WRITE_POTENTIAL, UNKNOWN };
// Table to merge return modes for condition statements (y: fReturnKind, x: other.fReturnKind)
private static final int[][] RETURN_KIND_CONDITIONAL_TABLE = {
- /* NOT_POSSIBLE UNDEFINED NO_RETURN PARTIAL_RETURN VOID_RETURN VALUE_RETURN THROW */
- /* NOT_POSSIBLE */ { NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE },
- /* UNDEFINED */ { NOT_POSSIBLE, UNDEFINED, NO_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, THROW },
- /* NO_RETURN */ { NOT_POSSIBLE, NO_RETURN, NO_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, NO_RETURN },
- /* PARTIAL_RETURN */ { NOT_POSSIBLE, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN },
- /* VOID_RETURN */ { NOT_POSSIBLE, VOID_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, VOID_RETURN, NOT_POSSIBLE, VOID_RETURN },
- /* VALUE_RETURN */ { NOT_POSSIBLE, VALUE_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, NOT_POSSIBLE, VALUE_RETURN, VALUE_RETURN },
- /* THROW */ { NOT_POSSIBLE, THROW, NO_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, THROW }
- };
+ /* NOT_POSSIBLE UNDEFINED NO_RETURN PARTIAL_RETURN VOID_RETURN VALUE_RETURN THROW */
+ /* NOT_POSSIBLE */ { NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE,
+ NOT_POSSIBLE },
+ /* UNDEFINED */ { NOT_POSSIBLE, UNDEFINED, NO_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, THROW },
+ /* NO_RETURN */ { NOT_POSSIBLE, NO_RETURN, NO_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN,
+ NO_RETURN },
+ /* PARTIAL_RETURN */ { NOT_POSSIBLE, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN,
+ PARTIAL_RETURN, PARTIAL_RETURN },
+ /* VOID_RETURN */ { NOT_POSSIBLE, VOID_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, VOID_RETURN, NOT_POSSIBLE,
+ VOID_RETURN },
+ /* VALUE_RETURN */ { NOT_POSSIBLE, VALUE_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, NOT_POSSIBLE, VALUE_RETURN,
+ VALUE_RETURN },
+ /* THROW */ { NOT_POSSIBLE, THROW, NO_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, THROW } };
// Table to merge return modes for sequential statements (y: fReturnKind, x: other.fReturnKind)
private static final int[][] RETURN_KIND_SEQUENTIAL_TABLE = {
- /* NOT_POSSIBLE UNDEFINED NO_RETURN PARTIAL_RETURN VOID_RETURN VALUE_RETURN THROW */
- /* NOT_POSSIBLE */ { NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE },
- /* UNDEFINED */ { NOT_POSSIBLE, UNDEFINED, NO_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, THROW },
- /* NO_RETURN */ { NOT_POSSIBLE, NO_RETURN, NO_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, THROW },
- /* PARTIAL_RETURN */ { NOT_POSSIBLE, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, VALUE_RETURN },
- /* VOID_RETURN */ { NOT_POSSIBLE, VOID_RETURN, VOID_RETURN, PARTIAL_RETURN, VOID_RETURN, NOT_POSSIBLE, NOT_POSSIBLE },
- /* VALUE_RETURN */ { NOT_POSSIBLE, VALUE_RETURN, VALUE_RETURN, PARTIAL_RETURN, NOT_POSSIBLE, VALUE_RETURN, NOT_POSSIBLE },
- /* THROW */ { NOT_POSSIBLE, THROW, THROW, VALUE_RETURN, VOID_RETURN, VALUE_RETURN, THROW }
- };
+ /* NOT_POSSIBLE UNDEFINED NO_RETURN PARTIAL_RETURN VOID_RETURN VALUE_RETURN THROW */
+ /* NOT_POSSIBLE */ { NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE, NOT_POSSIBLE,
+ NOT_POSSIBLE },
+ /* UNDEFINED */ { NOT_POSSIBLE, UNDEFINED, NO_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, THROW },
+ /* NO_RETURN */ { NOT_POSSIBLE, NO_RETURN, NO_RETURN, PARTIAL_RETURN, VOID_RETURN, VALUE_RETURN, THROW },
+ /* PARTIAL_RETURN */ { NOT_POSSIBLE, PARTIAL_RETURN, PARTIAL_RETURN, PARTIAL_RETURN, VOID_RETURN,
+ VALUE_RETURN, VALUE_RETURN },
+ /* VOID_RETURN */ { NOT_POSSIBLE, VOID_RETURN, VOID_RETURN, PARTIAL_RETURN, VOID_RETURN, NOT_POSSIBLE,
+ NOT_POSSIBLE },
+ /* VALUE_RETURN */ { NOT_POSSIBLE, VALUE_RETURN, VALUE_RETURN, PARTIAL_RETURN, NOT_POSSIBLE, VALUE_RETURN,
+ NOT_POSSIBLE },
+ /* THROW */ { NOT_POSSIBLE, THROW, THROW, VALUE_RETURN, VOID_RETURN, VALUE_RETURN, THROW } };
protected static final String UNLABELED = "@unlabeled"; //$NON-NLS-1$
@@ -92,18 +97,18 @@ public abstract class FlowInfo {
}
protected FlowInfo(int returnKind) {
- fReturnKind= returnKind;
+ fReturnKind = returnKind;
}
//---- General Helpers ----------------------------------------------------------
protected void assignExecutionFlow(FlowInfo right) {
- fReturnKind= right.fReturnKind;
- fBranches= right.fBranches;
+ fReturnKind = right.fReturnKind;
+ fBranches = right.fBranches;
}
protected void assignAccessMode(FlowInfo right) {
- fAccessModes= right.fAccessModes;
+ fAccessModes = right.fAccessModes;
}
protected void assign(FlowInfo right) {
@@ -124,7 +129,7 @@ public abstract class FlowInfo {
//---- Return Kind ------------------------------------------------------------------
public void setNoReturn() {
- fReturnKind= NO_RETURN;
+ fReturnKind = NO_RETURN;
}
public boolean isUndefined() {
@@ -169,7 +174,7 @@ public abstract class FlowInfo {
if (fBranches != null) {
fBranches.remove(makeString(label));
if (fBranches.isEmpty())
- fBranches= null;
+ fBranches = null;
}
}
@@ -184,26 +189,26 @@ public abstract class FlowInfo {
//---- Execution flow -------------------------------------------------------------------
private void mergeExecutionFlowSequential(FlowInfo otherInfo) {
- int other= otherInfo.fReturnKind;
+ int other = otherInfo.fReturnKind;
if (branches() && other == VALUE_RETURN)
- other= PARTIAL_RETURN;
- fReturnKind= RETURN_KIND_SEQUENTIAL_TABLE[fReturnKind][other];
+ other = PARTIAL_RETURN;
+ fReturnKind = RETURN_KIND_SEQUENTIAL_TABLE[fReturnKind][other];
mergeBranches(otherInfo);
}
private void mergeExecutionFlowConditional(FlowInfo otherInfo) {
- fReturnKind= RETURN_KIND_CONDITIONAL_TABLE[fReturnKind][otherInfo.fReturnKind];
+ fReturnKind = RETURN_KIND_CONDITIONAL_TABLE[fReturnKind][otherInfo.fReturnKind];
mergeBranches(otherInfo);
}
private void mergeBranches(FlowInfo otherInfo) {
- fBranches= mergeSets(fBranches, otherInfo.fBranches);
+ fBranches = mergeSets(fBranches, otherInfo.fBranches);
}
private static <T> Set<T> mergeSets(Set<T> thisSet, Set<T> otherSet) {
if (otherSet != null) {
if (thisSet == null) {
- thisSet= otherSet;
+ thisSet = otherSet;
} else {
for (T element : otherSet) {
thisSet.add(element);
@@ -227,9 +232,9 @@ public abstract class FlowInfo {
public Set<IVariable> get(FlowContext context, int mode) {
if (fAccessModes == null)
return Collections.emptySet();
- Set<IVariable> result= new HashSet<IVariable>(fAccessModes.length);
- for (int i= 0; i < fAccessModes.length; i++) {
- int accessMode= fAccessModes[i];
+ Set<IVariable> result = new HashSet<IVariable>(fAccessModes.length);
+ for (int i = 0; i < fAccessModes.length; i++) {
+ int accessMode = fAccessModes[i];
if ((accessMode & mode) != 0)
result.add(context.getLocalFromIndex(i));
}
@@ -247,10 +252,10 @@ public abstract class FlowInfo {
* <code>False</code> otherwise
*/
public boolean hasAccessMode(FlowContext context, IVariable local, int mode) {
- boolean unusedMode= (mode & UNUSED) != 0;
+ boolean unusedMode = (mode & UNUSED) != 0;
if (fAccessModes == null && unusedMode)
return true;
- int index= context.getIndexFromLocal(local);
+ int index = context.getIndexFromLocal(local);
if (index == -1)
return unusedMode;
return (fAccessModes[index] & mode) != 0;
@@ -266,7 +271,7 @@ public abstract class FlowInfo {
public int getAccessMode(FlowContext context, IVariable local) {
if (fAccessModes == null)
return UNUSED;
- int index= context.getIndexFromLocal(local);
+ int index = context.getIndexFromLocal(local);
if (index == -1)
return UNUSED;
return fAccessModes[index];
@@ -277,31 +282,31 @@ public abstract class FlowInfo {
}
protected void clearAccessMode(IVariable binding, FlowContext context) {
- if (fAccessModes == null) // All are unused
+ if (fAccessModes == null) // All are unused
return;
int index = context.getIndexFromLocal(binding);
if (index >= 0)
- fAccessModes[index]= UNUSED;
+ fAccessModes[index] = UNUSED;
}
protected void mergeAccessModeSequential(FlowInfo otherInfo, FlowContext context) {
if (!context.considerAccessMode())
return;
- int[] others= otherInfo.fAccessModes;
- if (others == null) // others are all unused. So nothing to do
+ int[] others = otherInfo.fAccessModes;
+ if (others == null) // others are all unused. So nothing to do
return;
// Must not consider return kind since a return statement can't control execution flow
// inside a method. It always leaves the method.
if (branches()) {
- for (int i= 0; i < others.length; i++) {
- others[i]= ACCESS_MODE_OPEN_BRANCH_TABLE[getIndex(others[i])];
+ for (int i = 0; i < others.length; i++) {
+ others[i] = ACCESS_MODE_OPEN_BRANCH_TABLE[getIndex(others[i])];
}
}
- if (fAccessModes == null) { // all current variables are unused
- fAccessModes= others;
+ if (fAccessModes == null) { // all current variables are unused
+ fAccessModes = others;
return;
}
@@ -315,48 +320,48 @@ public abstract class FlowInfo {
}
private void handleComputeReturnValues(int[] others) {
- for (int i= 0; i < fAccessModes.length; i++) {
- int accessmode= fAccessModes[i];
- int othermode= others[i];
+ for (int i = 0; i < fAccessModes.length; i++) {
+ int accessmode = fAccessModes[i];
+ int othermode = others[i];
if (accessmode == WRITE)
continue;
if (accessmode == WRITE_POTENTIAL) {
if (othermode == WRITE)
- fAccessModes[i]= WRITE;
+ fAccessModes[i] = WRITE;
continue;
}
if (others[i] != UNUSED)
- fAccessModes[i]= othermode;
+ fAccessModes[i] = othermode;
}
}
private void handleComputeArguments(int[] others) {
- for (int i= 0; i < fAccessModes.length; i++) {
- int accessMode= fAccessModes[i];
- int otherMode= others[i];
+ for (int i = 0; i < fAccessModes.length; i++) {
+ int accessMode = fAccessModes[i];
+ int otherMode = others[i];
if (accessMode == UNUSED) {
- fAccessModes[i]= otherMode;
+ fAccessModes[i] = otherMode;
} else if (accessMode == WRITE_POTENTIAL && (otherMode == READ || otherMode == READ_POTENTIAL)) {
// Read always supersedes a potential write even if the read is potential as well
// (we have to consider the potential read as an argument then).
- fAccessModes[i]= otherMode;
+ fAccessModes[i] = otherMode;
} else if (accessMode == WRITE_POTENTIAL && otherMode == WRITE) {
- fAccessModes[i]= WRITE;
+ fAccessModes[i] = WRITE;
}
}
}
private void handleMergeValues(int[] others) {
- for (int i= 0; i < fAccessModes.length; i++) {
- fAccessModes[i]= ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][getIndex(others[i])];
+ for (int i = 0; i < fAccessModes.length; i++) {
+ fAccessModes[i] = ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][getIndex(others[i])];
}
}
protected void createAccessModeArray(FlowContext context) {
- fAccessModes= new int[context.getArrayLength()];
- for (int i= 0; i < fAccessModes.length; i++) {
- fAccessModes[i]= UNUSED;
+ fAccessModes = new int[context.getArrayLength()];
+ for (int i = 0; i < fAccessModes.length; i++) {
+ fAccessModes[i] = UNUSED;
}
}
@@ -364,24 +369,24 @@ public abstract class FlowInfo {
if (!context.considerAccessMode())
return;
- int[] others= otherInfo.fAccessModes;
+ int[] others = otherInfo.fAccessModes;
// first access
if (fAccessModes == null) {
if (others != null) {
- fAccessModes= others;
+ fAccessModes = others;
} else {
createAccessModeArray(context);
}
return;
} else {
if (others == null) {
- int index_unused= getIndex(UNUSED);
- for (int i= 0; i < fAccessModes.length; i++) {
- fAccessModes[i]= ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][index_unused];
+ int index_unused = getIndex(UNUSED);
+ for (int i = 0; i < fAccessModes.length; i++) {
+ fAccessModes[i] = ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][index_unused];
}
} else {
- for (int i= 0; i < fAccessModes.length; i++) {
- fAccessModes[i]= ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][getIndex(others[i])];
+ for (int i = 0; i < fAccessModes.length; i++) {
+ fAccessModes[i] = ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][getIndex(others[i])];
}
}
}
@@ -389,7 +394,7 @@ public abstract class FlowInfo {
protected void mergeEmptyCondition(FlowContext context) {
if (fReturnKind == VALUE_RETURN || fReturnKind == VOID_RETURN)
- fReturnKind= PARTIAL_RETURN;
+ fReturnKind = PARTIAL_RETURN;
if (!context.considerAccessMode())
return;
@@ -399,29 +404,27 @@ public abstract class FlowInfo {
return;
}
- int index_unused= getIndex(UNUSED);
- for (int i= 0; i < fAccessModes.length; i++) {
- fAccessModes[i]= ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][index_unused];
+ int index_unused = getIndex(UNUSED);
+ for (int i = 0; i < fAccessModes.length; i++) {
+ fAccessModes[i] = ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][index_unused];
}
}
private static int getIndex(int accessMode) {
- switch (accessMode) {
- case UNUSED:
- return 0;
- case READ:
- return 1;
- case READ_POTENTIAL:
- return 2;
- case WRITE:
- return 3;
- case WRITE_POTENTIAL:
- return 4;
- case UNKNOWN:
- return 5;
- }
- return -1;
+ switch (accessMode) {
+ case UNUSED:
+ return 0;
+ case READ:
+ return 1;
+ case READ_POTENTIAL:
+ return 2;
+ case WRITE:
+ return 3;
+ case WRITE_POTENTIAL:
+ return 4;
+ case UNKNOWN:
+ return 5;
+ }
+ return -1;
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ForFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ForFlowInfo.java
index 28c5b9dbd8b..f000c747970 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ForFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ForFlowInfo.java
@@ -45,4 +45,3 @@ class ForFlowInfo extends FlowInfo {
mergeSequential(info, context);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericConditionalFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericConditionalFlowInfo.java
index 677be44c6da..749be09cc4b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericConditionalFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericConditionalFlowInfo.java
@@ -34,5 +34,3 @@ class GenericConditionalFlowInfo extends FlowInfo {
mergeAccessModeConditional(info, context);
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericSequentialFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericSequentialFlowInfo.java
index 28401ff6154..1b2e24cb637 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericSequentialFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/GenericSequentialFlowInfo.java
@@ -32,5 +32,3 @@ class GenericSequentialFlowInfo extends FlowInfo {
mergeAccessModeSequential(info, context);
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/IfFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/IfFlowInfo.java
index e4a04c38677..182501e004c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/IfFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/IfFlowInfo.java
@@ -26,7 +26,7 @@ class IfFlowInfo extends FlowInfo {
if (thenPart == null && elsePart == null)
return;
- GenericConditionalFlowInfo cond= new GenericConditionalFlowInfo();
+ GenericConditionalFlowInfo cond = new GenericConditionalFlowInfo();
if (thenPart != null)
cond.merge(thenPart, context);
@@ -39,4 +39,3 @@ class IfFlowInfo extends FlowInfo {
mergeSequential(cond, context);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InOutFlowAnalyzer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InOutFlowAnalyzer.java
index 73c30dfcb90..abbf377ad12 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InOutFlowAnalyzer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InOutFlowAnalyzer.java
@@ -44,10 +44,10 @@ public class InOutFlowAnalyzer extends FlowAnalyzer {
}
public FlowInfo perform(IASTNode[] selectedNodes) {
- FlowContext context= getFlowContext();
- GenericSequentialFlowInfo result= createSequential();
- for (int i= 0; i < selectedNodes.length; i++) {
- IASTNode node= selectedNodes[i];
+ FlowContext context = getFlowContext();
+ GenericSequentialFlowInfo result = createSequential();
+ for (int i = 0; i < selectedNodes.length; i++) {
+ IASTNode node = selectedNodes[i];
node.accept(this);
result.merge(getFlowInfo(node), context);
}
@@ -97,7 +97,7 @@ public class InOutFlowAnalyzer extends FlowAnalyzer {
@Override
public int leave(IASTFunctionDefinition node) {
super.leave(node);
- FlowInfo info= accessFlowInfo(node);
+ FlowInfo info = accessFlowInfo(node);
IASTFunctionDeclarator declarator = node.getDeclarator();
if (declarator instanceof IASTStandardFunctionDeclarator) {
for (IASTParameterDeclaration param : ((IASTStandardFunctionDeclarator) declarator).getParameters()) {
@@ -138,9 +138,8 @@ public class InOutFlowAnalyzer extends FlowAnalyzer {
private void clearAccessMode(FlowInfo info, IASTDeclarator declarator) {
declarator = CPPVisitor.findInnermostDeclarator(declarator);
IASTName name = declarator.getName();
- IBinding binding= name.resolveBinding();
+ IBinding binding = name.resolveBinding();
if (binding instanceof IVariable && !(binding instanceof IField))
info.clearAccessMode((IVariable) binding, fFlowContext);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java
index 367f4cd27a2..71e387615b8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java
@@ -52,8 +52,8 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public LoopReentranceVisitor(FlowContext context, Selection selection, IASTNode loopNode) {
super(context);
- this.selection= selection;
- this.loopNode= loopNode;
+ this.selection = selection;
+ this.loopNode = loopNode;
}
@Override
@@ -84,7 +84,7 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public int leave(IASTDoStatement node) {
if (skipNode(node))
return PROCESS_SKIP;
- DoWhileFlowInfo info= createDoWhile();
+ DoWhileFlowInfo info = createDoWhile();
setFlowInfo(node, info);
info.mergeAction(getFlowInfo(node.getBody()), fFlowContext);
// No need to merge the condition. It was already considered by the InputFlowAnalyzer.
@@ -96,10 +96,10 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public int leave(ICPPASTRangeBasedForStatement node) {
if (skipNode(node))
return PROCESS_SKIP;
- FlowInfo paramInfo= getFlowInfo(node.getDeclaration());
- FlowInfo expressionInfo= getFlowInfo(node.getInitializerClause());
- FlowInfo actionInfo= getFlowInfo(node.getBody());
- RangeBasedForFlowInfo forInfo= createRangeBasedFor();
+ FlowInfo paramInfo = getFlowInfo(node.getDeclaration());
+ FlowInfo expressionInfo = getFlowInfo(node.getInitializerClause());
+ FlowInfo actionInfo = getFlowInfo(node.getBody());
+ RangeBasedForFlowInfo forInfo = createRangeBasedFor();
setFlowInfo(node, forInfo);
// If the for statement is the outermost loop then we only have to consider
// the action. The parameter and expression are only evaluated once.
@@ -120,11 +120,11 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public int leave(IASTForStatement node) {
if (skipNode(node))
return PROCESS_SKIP;
- FlowInfo initInfo= createSequential(node.getInitializerStatement());
- FlowInfo conditionInfo= getFlowInfo(node.getConditionExpression());
- FlowInfo incrementInfo= createSequential(node.getIterationExpression());
- FlowInfo actionInfo= getFlowInfo(node.getBody());
- ForFlowInfo forInfo= createFor();
+ FlowInfo initInfo = createSequential(node.getInitializerStatement());
+ FlowInfo conditionInfo = getFlowInfo(node.getConditionExpression());
+ FlowInfo incrementInfo = createSequential(node.getIterationExpression());
+ FlowInfo actionInfo = getFlowInfo(node.getBody());
+ ForFlowInfo forInfo = createFor();
setFlowInfo(node, forInfo);
// The for statement is the outermost loop. In this case we only have
// to consider the increment, condition and action.
@@ -139,7 +139,7 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
// the outer loop. Then we have to consider initializations, condition and action.
// For a conditional flow info that means:
// (initializations | increments) & condition & action.
- GenericConditionalFlowInfo initIncr= new GenericConditionalFlowInfo();
+ GenericConditionalFlowInfo initIncr = new GenericConditionalFlowInfo();
initIncr.merge(initInfo, fFlowContext);
initIncr.merge(incrementInfo, fFlowContext);
forInfo.mergeAccessModeSequential(initIncr, fFlowContext);
@@ -199,7 +199,7 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
}
if (lastGotoStatement == null)
return PROCESS_CONTINUE;
-
+
GotoLoopRegion newRegion = new GotoLoopRegion(labelStatement, lastGotoStatement);
boolean gaps = false;
for (int i = 0; i < gotoRegions.length; i++) {
@@ -245,14 +245,14 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public GotoReentranceVisitor(FlowContext context, Selection selection, GotoLoopRegion loopRegion) {
super(context);
- this.selection= selection;
+ this.selection = selection;
this.loopRegion = loopRegion;
}
@Override
protected boolean traverseNode(IASTNode node) {
- return !selection.covers(node) && !isBefore(node, loopRegion.firstLabelStatement) &&
- !isBefore(loopRegion.lastGotoStatement, node);
+ return !selection.covers(node) && !isBefore(node, loopRegion.firstLabelStatement)
+ && !isBefore(loopRegion.lastGotoStatement, node);
}
@Override
@@ -274,9 +274,9 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public InputFlowAnalyzer(FlowContext context, Selection selection, boolean doLoopReentrance) {
super(context);
- fSelection= selection;
+ fSelection = selection;
Assert.isNotNull(fSelection);
- fDoLoopReentrance= doLoopReentrance;
+ fDoLoopReentrance = doLoopReentrance;
}
public FlowInfo perform(IASTFunctionDefinition node) {
@@ -287,7 +287,7 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
GotoLoopRegion[] gotoRegions = gotoAnalyzer.getGotoRegions();
for (GotoLoopRegion loopRegion : gotoRegions) {
if (fSelection.coveredBy(loopRegion)) {
- GenericSequentialFlowInfo info= createSequential();
+ GenericSequentialFlowInfo info = createSequential();
info.merge(getFlowInfo(node), fFlowContext);
fGotoReentranceVisitor = new GotoReentranceVisitor(fFlowContext, fSelection, loopRegion);
FlowInfo gotoInfo = fGotoReentranceVisitor.process(node);
@@ -343,7 +343,7 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
private void createLoopReentranceVisitor(IASTNode node) {
if (fLoopReentranceVisitor == null && fDoLoopReentrance && fSelection.coveredBy(node)) {
- fLoopReentranceVisitor= new LoopReentranceVisitor(fFlowContext, fSelection, node);
+ fLoopReentranceVisitor = new LoopReentranceVisitor(fFlowContext, fSelection, node);
}
}
@@ -351,11 +351,11 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public int leave(IASTConditionalExpression node) {
if (skipNode(node))
return PROCESS_SKIP;
- IASTExpression thenPart= node.getPositiveResultExpression();
- IASTExpression elsePart= node.getNegativeResultExpression();
- if ((thenPart != null && fSelection.coveredBy(thenPart)) ||
- (elsePart != null && fSelection.coveredBy(elsePart))) {
- GenericSequentialFlowInfo info= createSequential();
+ IASTExpression thenPart = node.getPositiveResultExpression();
+ IASTExpression elsePart = node.getNegativeResultExpression();
+ if ((thenPart != null && fSelection.coveredBy(thenPart))
+ || (elsePart != null && fSelection.coveredBy(elsePart))) {
+ GenericSequentialFlowInfo info = createSequential();
setFlowInfo(node, info);
leaveConditional(info, node.getLogicalConditionExpression(), new IASTNode[] { thenPart, elsePart });
return PROCESS_SKIP;
@@ -374,11 +374,11 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public int leave(IASTIfStatement node) {
if (skipNode(node))
return PROCESS_SKIP;
- IASTStatement thenPart= node.getThenClause();
- IASTStatement elsePart= node.getElseClause();
- if ((thenPart != null && fSelection.coveredBy(thenPart)) ||
- (elsePart != null && fSelection.coveredBy(elsePart))) {
- GenericSequentialFlowInfo info= createSequential();
+ IASTStatement thenPart = node.getThenClause();
+ IASTStatement elsePart = node.getElseClause();
+ if ((thenPart != null && fSelection.coveredBy(thenPart))
+ || (elsePart != null && fSelection.coveredBy(elsePart))) {
+ GenericSequentialFlowInfo info = createSequential();
setFlowInfo(node, info);
leaveConditional(info, node.getConditionExpression(), new IASTNode[] { thenPart, elsePart });
return PROCESS_SKIP;
@@ -404,12 +404,12 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
public int leave(IASTSwitchStatement node) {
if (skipNode(node))
return PROCESS_SKIP;
- SwitchData data= createSwitchData(node);
- IRegion[] ranges= data.getRanges();
- for (int i= 0; i < ranges.length; i++) {
- IRegion range= ranges[i];
+ SwitchData data = createSwitchData(node);
+ IRegion[] ranges = data.getRanges();
+ for (int i = 0; i < ranges.length; i++) {
+ IRegion range = ranges[i];
if (fSelection.coveredBy(range)) {
- GenericSequentialFlowInfo info= createSequential();
+ GenericSequentialFlowInfo info = createSequential();
setFlowInfo(node, info);
info.merge(getFlowInfo(node.getControllerExpression()), fFlowContext);
info.merge(data.getInfo(i), fFlowContext);
@@ -442,7 +442,7 @@ public class InputFlowAnalyzer extends FlowAnalyzer {
return;
fLoopReentranceVisitor.process(node);
- GenericSequentialFlowInfo info= createSequential();
+ GenericSequentialFlowInfo info = createSequential();
info.merge(getFlowInfo(node), fFlowContext);
info.merge(fLoopReentranceVisitor.getFlowInfo(node), fFlowContext);
setFlowInfo(node, info);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java
index 6b3d86e43e8..1c8bbb4afac 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java
@@ -23,27 +23,26 @@ class LocalFlowInfo extends FlowInfo {
super(NO_RETURN);
if (variableIndex < 0)
throw new IllegalArgumentException("Invalid index for local variable \"" + binding.getName()); //$NON-NLS-1$
- fVariableIndex= variableIndex;
+ fVariableIndex = variableIndex;
if (context.considerAccessMode()) {
createAccessModeArray(context);
context.manageLocal(binding);
- fAccessModes[fVariableIndex]= localAccessMode;
+ fAccessModes[fVariableIndex] = localAccessMode;
}
}
public LocalFlowInfo(LocalFlowInfo info, int localAccessMode, FlowContext context) {
super(NO_RETURN);
- fVariableIndex= info.fVariableIndex;
+ fVariableIndex = info.fVariableIndex;
if (context.considerAccessMode()) {
createAccessModeArray(context);
- fAccessModes[fVariableIndex]= localAccessMode;
+ fAccessModes[fVariableIndex] = localAccessMode;
}
}
public void setWriteAccess(FlowContext context) {
if (context.considerAccessMode()) {
- fAccessModes[fVariableIndex]= FlowInfo.WRITE;
+ fAccessModes[fVariableIndex] = FlowInfo.WRITE;
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/RangeBasedForFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/RangeBasedForFlowInfo.java
index f469f7e6068..a5ef71d020d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/RangeBasedForFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/RangeBasedForFlowInfo.java
@@ -36,4 +36,3 @@ class RangeBasedForFlowInfo extends FlowInfo {
mergeSequential(info, context);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ReturnFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ReturnFlowInfo.java
index 8838e4e6902..4cbec5d3feb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ReturnFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ReturnFlowInfo.java
@@ -33,11 +33,9 @@ class ReturnFlowInfo extends FlowInfo {
}
private static int getReturnFlag(IASTReturnStatement node) {
- IASTExpression expression= node.getReturnValue();
+ IASTExpression expression = node.getReturnValue();
if (expression == null || SemanticUtil.isVoidType(expression.getExpressionType()))
return VOID_RETURN;
return VALUE_RETURN;
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java
index cf7a5d162c4..8e096a5d662 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java
@@ -22,16 +22,16 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
public class Selection {
/** Flag indicating that the AST node somehow intersects with the selection. */
- public static final int INTERSECTS= 0;
+ public static final int INTERSECTS = 0;
/** Flag that indicates that an AST node appears before the selected nodes. */
- public static final int BEFORE= 1;
+ public static final int BEFORE = 1;
/** Flag indicating that an AST node is covered by the selection. */
- public static final int SELECTED= 2;
+ public static final int SELECTED = 2;
/** Flag indicating that an AST nodes appears after the selected nodes. */
- public static final int AFTER= 3;
+ public static final int AFTER = 3;
private int fStart;
private int fLength;
@@ -49,10 +49,10 @@ public class Selection {
*/
public static Selection createFromStartLength(int start, int length) {
Assert.isTrue(start >= 0 && length >= 0);
- Selection result= new Selection();
- result.fStart= start;
- result.fLength= length;
- result.fEnd= start + length;
+ Selection result = new Selection();
+ result.fStart = start;
+ result.fLength = length;
+ result.fEnd = start + length;
return result;
}
@@ -65,10 +65,10 @@ public class Selection {
*/
public static Selection createFromStartEnd(int start, int end) {
Assert.isTrue(start >= 0 && end >= start);
- Selection result= new Selection();
- result.fStart= start;
- result.fLength= end - start;
- result.fEnd= result.fStart + result.fLength;
+ Selection result = new Selection();
+ result.fStart = start;
+ result.fLength = end - start;
+ result.fEnd = result.fStart + result.fLength;
return result;
}
@@ -99,8 +99,8 @@ public class Selection {
*/
public int getVisitSelectionMode(IASTNode node) {
IASTFileLocation location = node.getFileLocation();
- int nodeStart= location.getNodeOffset();
- int nodeEnd= nodeStart + location.getNodeLength();
+ int nodeStart = location.getNodeOffset();
+ int nodeEnd = nodeStart + location.getNodeLength();
if (nodeEnd <= fStart) {
return BEFORE;
} else if (covers(node)) {
@@ -113,8 +113,8 @@ public class Selection {
public int getLeaveSelectionMode(IASTNode node) {
IASTFileLocation location = node.getFileLocation();
- int nodeStart= location.getNodeOffset();
- int nodeEnd= nodeStart + location.getNodeLength();
+ int nodeStart = location.getNodeOffset();
+ int nodeEnd = nodeStart + location.getNodeLength();
if (nodeEnd <= fStart) {
return BEFORE;
} else if (covers(node)) {
@@ -133,35 +133,35 @@ public class Selection {
public boolean covers(IASTNode node) {
IASTFileLocation location = node.getFileLocation();
- int nodeStart= location.getNodeOffset();
+ int nodeStart = location.getNodeOffset();
return fStart <= nodeStart && nodeStart + location.getNodeLength() <= fEnd;
}
public boolean coveredBy(IASTNode node) {
IASTFileLocation location = node.getFileLocation();
- int nodeStart= location.getNodeOffset();
+ int nodeStart = location.getNodeOffset();
return nodeStart <= fStart && fEnd <= nodeStart + location.getNodeLength();
}
public boolean coveredBy(IRegion region) {
- int regionStart= region.getOffset();
+ int regionStart = region.getOffset();
return regionStart <= fStart && fEnd <= regionStart + region.getLength();
}
public boolean endsIn(IASTNode node) {
IASTFileLocation location = node.getFileLocation();
- int nodeStart= location.getNodeOffset();
+ int nodeStart = location.getNodeOffset();
return nodeStart < fEnd && fEnd < nodeStart + location.getNodeLength();
}
public boolean liesOutside(IASTNode node) {
IASTFileLocation location = node.getFileLocation();
- int nodeStart= location.getNodeOffset();
- return fEnd < nodeStart || nodeStart + location.getNodeLength() < fStart;
+ int nodeStart = location.getNodeOffset();
+ return fEnd < nodeStart || nodeStart + location.getNodeLength() < fStart;
}
@Override
public String toString() {
- return "<start == " + fStart + ", length == " + fLength + "/>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return "<start == " + fStart + ", length == " + fLength + "/>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/SwitchFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/SwitchFlowInfo.java
index 36d29880dda..f778de8ff9e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/SwitchFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/SwitchFlowInfo.java
@@ -19,7 +19,7 @@ class SwitchFlowInfo extends FlowInfo {
private boolean fHasNullCaseInfo;
public SwitchFlowInfo() {
- fCases= new GenericConditionalFlowInfo();
+ fCases = new GenericConditionalFlowInfo();
}
public void mergeTest(FlowInfo info, FlowContext context) {
@@ -30,7 +30,7 @@ class SwitchFlowInfo extends FlowInfo {
public void mergeCase(FlowInfo info, FlowContext context) {
if (info == null) {
- fHasNullCaseInfo= true;
+ fHasNullCaseInfo = true;
return;
}
fCases.mergeConditional(info, context);
@@ -42,4 +42,3 @@ class SwitchFlowInfo extends FlowInfo {
mergeSequential(fCases, context);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ThrowFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ThrowFlowInfo.java
index b11e5767314..64d80b73f7e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ThrowFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/ThrowFlowInfo.java
@@ -27,5 +27,3 @@ class ThrowFlowInfo extends FlowInfo {
assignAccessMode(info);
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/TryFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/TryFlowInfo.java
index bc302ce5a03..dd9c4819c70 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/TryFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/TryFlowInfo.java
@@ -41,4 +41,3 @@ class TryFlowInfo extends FlowInfo {
mergeSequential(info, context);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/WhileFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/WhileFlowInfo.java
index d67f8804e55..ce04208c948 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/WhileFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/WhileFlowInfo.java
@@ -32,4 +32,3 @@ class WhileFlowInfo extends FlowInfo {
mergeSequential(info, context);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/participants/ResourceModifications.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/participants/ResourceModifications.java
index 68244243472..19ed2ae8dae 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/participants/ResourceModifications.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/participants/ResourceModifications.java
@@ -64,7 +64,7 @@ public class ResourceModifications {
protected IResource fResource;
public DeltaDescription(IResource resource) {
- fResource= resource;
+ fResource = resource;
}
public abstract void buildDelta(IResourceChangeDescriptionFactory builder);
@@ -95,7 +95,7 @@ public class ResourceModifications {
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
- builder.change((IFile)fResource);
+ builder.change((IFile) fResource);
}
@Override
@@ -125,12 +125,12 @@ public class ResourceModifications {
public MoveDescription(IResource resource, IPath destination) {
super(resource);
- fDestination= destination;
+ fDestination = destination;
}
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
- IResource existing= ResourcesPlugin.getWorkspace().getRoot().findMember(fDestination);
+ IResource existing = ResourcesPlugin.getWorkspace().getRoot().findMember(fDestination);
if (existing != null && !existing.equals(fResource)) {
builder.delete(existing);
}
@@ -148,12 +148,12 @@ public class ResourceModifications {
public CopyDescription(IResource resource, IPath destination) {
super(resource);
- fDestination= destination;
+ fDestination = destination;
}
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
- IResource existing= ResourcesPlugin.getWorkspace().getRoot().findMember(fDestination);
+ IResource existing = ResourcesPlugin.getWorkspace().getRoot().findMember(fDestination);
if (existing != null && !existing.equals(fResource)) {
builder.delete(existing);
}
@@ -184,7 +184,7 @@ public class ResourceModifications {
*/
public void addCreate(IResource create) {
if (fCreate == null)
- fCreate= new ArrayList<>(2);
+ fCreate = new ArrayList<>(2);
fCreate.add(create);
if (fIgnoreCount == 0) {
internalAdd(new CreateDescription(create));
@@ -198,7 +198,7 @@ public class ResourceModifications {
*/
public void addDelete(IResource delete) {
if (fDelete == null)
- fDelete= new ArrayList<>(2);
+ fDelete = new ArrayList<>(2);
fDelete.add(delete);
if (fIgnoreCount == 0) {
internalAdd(new DeleteDescription(delete));
@@ -213,13 +213,13 @@ public class ResourceModifications {
*/
public void addMove(IResource move, MoveArguments arguments) {
if (fMove == null) {
- fMove= new ArrayList<>(2);
- fMoveArguments= new ArrayList<>(2);
+ fMove = new ArrayList<>(2);
+ fMoveArguments = new ArrayList<>(2);
}
fMove.add(move);
fMoveArguments.add(arguments);
if (fIgnoreCount == 0) {
- IPath destination= ((IResource)arguments.getDestination()).getFullPath().append(move.getName());
+ IPath destination = ((IResource) arguments.getDestination()).getFullPath().append(move.getName());
internalAdd(new MoveDescription(move, destination));
}
}
@@ -232,8 +232,8 @@ public class ResourceModifications {
*/
public void addCopy(IResource copy, CopyArguments arguments) {
if (fCopy == null) {
- fCopy= new ArrayList<>(2);
- fCopyArguments= new ArrayList<>(2);
+ fCopy = new ArrayList<>(2);
+ fCopyArguments = new ArrayList<>(2);
}
fCopy.add(copy);
fCopyArguments.add(arguments);
@@ -250,66 +250,61 @@ public class ResourceModifications {
Assert.isNotNull(rename);
Assert.isNotNull(arguments);
if (fRename == null) {
- fRename= new ArrayList<>(2);
- fRenameArguments= new ArrayList<>(2);
+ fRename = new ArrayList<>(2);
+ fRenameArguments = new ArrayList<>(2);
}
fRename.add(rename);
fRenameArguments.add(arguments);
if (fIgnoreCount == 0) {
- IPath newPath= rename.getFullPath().removeLastSegments(1).append(arguments.getNewName());
+ IPath newPath = rename.getFullPath().removeLastSegments(1).append(arguments.getNewName());
internalAdd(new MoveDescription(rename, newPath));
}
}
- public RefactoringParticipant[] getParticipants(RefactoringStatus status,
- RefactoringProcessor processor, String[] natures, SharableParticipants shared) {
- List<RefactoringParticipant> result= new ArrayList<>(5);
+ public RefactoringParticipant[] getParticipants(RefactoringStatus status, RefactoringProcessor processor,
+ String[] natures, SharableParticipants shared) {
+ List<RefactoringParticipant> result = new ArrayList<>(5);
if (fDelete != null) {
- DeleteArguments arguments= new DeleteArguments();
- for (Iterator<IResource> iter= fDelete.iterator(); iter.hasNext();) {
- DeleteParticipant[] deletes= ParticipantManager.loadDeleteParticipants(status,
- processor, iter.next(),
- arguments, natures, shared);
+ DeleteArguments arguments = new DeleteArguments();
+ for (Iterator<IResource> iter = fDelete.iterator(); iter.hasNext();) {
+ DeleteParticipant[] deletes = ParticipantManager.loadDeleteParticipants(status, processor, iter.next(),
+ arguments, natures, shared);
result.addAll(Arrays.asList(deletes));
}
}
if (fCreate != null) {
- CreateArguments arguments= new CreateArguments();
- for (Iterator<IResource> iter= fCreate.iterator(); iter.hasNext();) {
- CreateParticipant[] creates= ParticipantManager.loadCreateParticipants(status,
- processor, iter.next(),
- arguments, natures, shared);
+ CreateArguments arguments = new CreateArguments();
+ for (Iterator<IResource> iter = fCreate.iterator(); iter.hasNext();) {
+ CreateParticipant[] creates = ParticipantManager.loadCreateParticipants(status, processor, iter.next(),
+ arguments, natures, shared);
result.addAll(Arrays.asList(creates));
}
}
if (fMove != null) {
- for (int i= 0; i < fMove.size(); i++) {
- Object element= fMove.get(i);
- MoveArguments arguments= fMoveArguments.get(i);
- MoveParticipant[] moves= ParticipantManager.loadMoveParticipants(status,
- processor, element,
- arguments, natures, shared);
+ for (int i = 0; i < fMove.size(); i++) {
+ Object element = fMove.get(i);
+ MoveArguments arguments = fMoveArguments.get(i);
+ MoveParticipant[] moves = ParticipantManager.loadMoveParticipants(status, processor, element, arguments,
+ natures, shared);
result.addAll(Arrays.asList(moves));
}
}
if (fCopy != null) {
- for (int i= 0; i < fCopy.size(); i++) {
- Object element= fCopy.get(i);
- CopyArguments arguments= fCopyArguments.get(i);
- CopyParticipant[] copies= ParticipantManager.loadCopyParticipants(status,
- processor, element,
- arguments, natures, shared);
+ for (int i = 0; i < fCopy.size(); i++) {
+ Object element = fCopy.get(i);
+ CopyArguments arguments = fCopyArguments.get(i);
+ CopyParticipant[] copies = ParticipantManager.loadCopyParticipants(status, processor, element,
+ arguments, natures, shared);
result.addAll(Arrays.asList(copies));
}
}
if (fRename != null) {
- for (int i= 0; i < fRename.size(); i++) {
- Object resource= fRename.get(i);
- RenameArguments arguments= fRenameArguments.get(i);
- RenameParticipant[] renames= ParticipantManager.loadRenameParticipants(status,
- processor, resource,
- arguments, natures, shared);
+ for (int i = 0; i < fRename.size(); i++) {
+ Object resource = fRename.get(i);
+ RenameArguments arguments = fRenameArguments.get(i);
+ RenameParticipant[] renames = ParticipantManager.loadRenameParticipants(status, processor, resource,
+ arguments, natures, shared);
result.addAll(Arrays.asList(renames));
}
}
@@ -332,7 +327,7 @@ public class ResourceModifications {
public void addCopyDelta(IResource copy, CopyArguments arguments) {
if (fIgnoreCount == 0) {
- IPath destination= ((IResource) arguments.getDestination()).getFullPath().append(copy.getName());
+ IPath destination = ((IResource) arguments.getDestination()).getFullPath().append(copy.getName());
internalAdd(new CopyDescription(copy, destination));
}
}
@@ -347,9 +342,9 @@ public class ResourceModifications {
public boolean willExist(IResource resource) {
if (fDeltaDescriptions == null)
return false;
- IPath fullPath= resource.getFullPath();
- for (Iterator<DeltaDescription> iter= fDeltaDescriptions.iterator(); iter.hasNext();) {
- DeltaDescription delta= iter.next();
+ IPath fullPath = resource.getFullPath();
+ for (Iterator<DeltaDescription> iter = fDeltaDescriptions.iterator(); iter.hasNext();) {
+ DeltaDescription delta = iter.next();
if (fullPath.equals(delta.getDestinationPath()))
return true;
}
@@ -359,29 +354,32 @@ public class ResourceModifications {
public void buildDelta(IResourceChangeDescriptionFactory builder) {
if (fDeltaDescriptions == null)
return;
- for (Iterator<DeltaDescription> iter= fDeltaDescriptions.iterator(); iter.hasNext();) {
+ for (Iterator<DeltaDescription> iter = fDeltaDescriptions.iterator(); iter.hasNext();) {
iter.next().buildDelta(builder);
}
}
- public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource, RenameArguments args) {
- IPath newPath= resource.getFullPath().removeLastSegments(1).append(args.getNewName());
+ public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource,
+ RenameArguments args) {
+ IPath newPath = resource.getFullPath().removeLastSegments(1).append(args.getNewName());
new MoveDescription(resource, newPath).buildDelta(builder);
}
- public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource, MoveArguments args) {
- IPath destination= ((IResource)args.getDestination()).getFullPath().append(resource.getName());
+ public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource,
+ MoveArguments args) {
+ IPath destination = ((IResource) args.getDestination()).getFullPath().append(resource.getName());
new MoveDescription(resource, destination).buildDelta(builder);
}
- public static void buildCopyDelta(IResourceChangeDescriptionFactory builder, IResource resource, CopyArguments args) {
- IPath destination= ((IResource)args.getDestination()).getFullPath().append(resource.getName());
+ public static void buildCopyDelta(IResourceChangeDescriptionFactory builder, IResource resource,
+ CopyArguments args) {
+ IPath destination = ((IResource) args.getDestination()).getFullPath().append(resource.getName());
new CopyDescription(resource, destination).buildDelta(builder);
}
private void internalAdd(DeltaDescription description) {
if (fDeltaDescriptions == null)
- fDeltaDescriptions= new ArrayList<>();
+ fDeltaDescriptions = new ArrayList<>();
fDeltaDescriptions.add(description);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java
index f6b1876fbaa..00a15f43069 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java
@@ -37,28 +37,28 @@ import org.eclipse.cdt.ui.PreferenceConstants;
public class CContext extends TranslationUnitContext {
/**
* Creates a C/C++ code template context.
- *
+ *
* @param type the context type
* @param document the document
* @param completionOffset the completion position within the document
* @param completionLength the length of the context
* @param translationUnit the translation unit represented by the document
*/
- public CContext(TemplateContextType type, IDocument document, int completionOffset,
- int completionLength, ITranslationUnit translationUnit) {
+ public CContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength,
+ ITranslationUnit translationUnit) {
super(type, document, completionOffset, completionLength, translationUnit);
}
/**
* Creates a C/C++ code template context.
- *
+ *
* @param type the context type.
* @param document the document.
* @param completionPosition the completion position within the document
* @param translationUnit the translation unit (may be <code>null</code>).
*/
- public CContext(TemplateContextType type, IDocument document,
- Position completionPosition, ITranslationUnit translationUnit) {
+ public CContext(TemplateContextType type, IDocument document, Position completionPosition,
+ ITranslationUnit translationUnit) {
super(type, document, completionPosition, translationUnit);
}
@@ -68,10 +68,10 @@ public class CContext extends TranslationUnitContext {
return super.getStart();
try {
- IDocument document= getDocument();
+ IDocument document = getDocument();
- int start= getCompletionOffset();
- int end= getCompletionOffset() + getCompletionLength();
+ int start = getCompletionOffset();
+ int end = getCompletionOffset() + getCompletionLength();
while (start != 0 && isUnicodeIdentifierPartOrPoundSign(document.getChar(start - 1)))
start--;
@@ -80,11 +80,11 @@ public class CContext extends TranslationUnitContext {
start++;
if (start == end)
- start= getCompletionOffset();
+ start = getCompletionOffset();
- return start;
+ return start;
} catch (BadLocationException e) {
- return super.getStart();
+ return super.getStart();
}
}
@@ -94,37 +94,37 @@ public class CContext extends TranslationUnitContext {
return super.getEnd();
try {
- IDocument document= getDocument();
+ IDocument document = getDocument();
- int start= getCompletionOffset();
- int end= getCompletionOffset() + getCompletionLength();
+ int start = getCompletionOffset();
+ int end = getCompletionOffset() + getCompletionLength();
while (start != end && Character.isWhitespace(document.getChar(end - 1)))
end--;
- return end;
+ return end;
} catch (BadLocationException e) {
return super.getEnd();
- }
+ }
}
-
+
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
if (!canEvaluate(template))
return null;
- TemplateTranslator translator= new TemplateTranslator();
- TemplateBuffer buffer= translator.translate(template.getPattern());
+ TemplateTranslator translator = new TemplateTranslator();
+ TemplateBuffer buffer = translator.translate(template.getPattern());
getContextType().resolve(buffer, this);
- IPreferenceStore prefs= CUIPlugin.getDefault().getPreferenceStore();
- boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);
+ IPreferenceStore prefs = CUIPlugin.getDefault().getPreferenceStore();
+ boolean useCodeFormatter = prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);
- ICProject project= getCProject();
+ ICProject project = getCProject();
int indentationLevel = isReadOnly() ? 0 : getIndentationLevel();
- CFormatter formatter= new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()),
- indentationLevel, useCodeFormatter, project);
+ CFormatter formatter = new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), indentationLevel,
+ useCodeFormatter, project);
formatter.format(buffer, this);
return buffer;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java
index c0cfc56be57..5a587c1b57f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java
@@ -30,14 +30,14 @@ public class CContextType extends TranslationUnitContextType {
}
@Override
- public TranslationUnitContext createContext(IDocument document, int offset,
- int length, ITranslationUnit translationUnit) {
+ public TranslationUnitContext createContext(IDocument document, int offset, int length,
+ ITranslationUnit translationUnit) {
return new CContext(this, document, offset, length, translationUnit);
}
@Override
- public TranslationUnitContext createContext(IDocument document,
- Position position, ITranslationUnit translationUnit) {
+ public TranslationUnitContext createContext(IDocument document, Position position,
+ ITranslationUnit translationUnit) {
return new CContext(this, document, position, translationUnit);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java
index 0de2d9875a0..5d06993b606 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java
@@ -52,37 +52,36 @@ import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
import org.eclipse.cdt.internal.ui.editor.IndentUtil;
import org.eclipse.cdt.internal.ui.text.FastCPartitionScanner;
-
/**
* A template editor using the C/C++ formatter to format a template buffer.
*/
public class CFormatter {
- private static final String COMMENT_START= "/*-"; //$NON-NLS-1$
- private static final String COMMENT_END= "*/"; //$NON-NLS-1$
+ private static final String COMMENT_START = "/*-"; //$NON-NLS-1$
+ private static final String COMMENT_END = "*/"; //$NON-NLS-1$
/** The line delimiter to use if code formatter is not used. */
private final String fLineDelimiter;
/** The initial indent level */
private final int fInitialIndentLevel;
-
+
/** Flag indicating whether to use the code formatter or not. */
private boolean fUseCodeFormatter;
private final ICProject fProject;
/**
* Creates a CFormatter with the target line delimiter.
- *
+ *
* @param lineDelimiter the line delimiter to use
* @param initialIndentLevel the initial indentation level
* @param useCodeFormatter <code>true</code> if the core code formatter should be used
* @param project the C/C++ project from which to get the preferences, or <code>null</code> for workbench settings
*/
public CFormatter(String lineDelimiter, int initialIndentLevel, boolean useCodeFormatter, ICProject project) {
- fLineDelimiter= lineDelimiter;
- fUseCodeFormatter= useCodeFormatter;
- fInitialIndentLevel= initialIndentLevel;
- fProject= project;
+ fLineDelimiter = lineDelimiter;
+ fUseCodeFormatter = useCodeFormatter;
+ fInitialIndentLevel = initialIndentLevel;
+ fProject = project;
}
/**
@@ -93,14 +92,14 @@ public class CFormatter {
*/
public void format(TemplateBuffer buffer, TemplateContext context) throws BadLocationException {
try {
- VariableTracker tracker= new VariableTracker(buffer);
- IDocument document= tracker.getDocument();
-
+ VariableTracker tracker = new VariableTracker(buffer);
+ IDocument document = tracker.getDocument();
+
internalFormat(document, context, buffer);
convertLineDelimiters(document);
if (isReplacedAreaEmpty(context))
trimStart(document);
-
+
tracker.updateBuffer();
} catch (MalformedTreeException e) {
throw new BadLocationException();
@@ -110,10 +109,11 @@ public class CFormatter {
/**
* @param document
* @param context
- * @param buffer
+ * @param buffer
* @throws BadLocationException
*/
- private void internalFormat(IDocument document, TemplateContext context, TemplateBuffer buffer) throws BadLocationException {
+ private void internalFormat(IDocument document, TemplateContext context, TemplateBuffer buffer)
+ throws BadLocationException {
if (fUseCodeFormatter) {
// try to format and fall back to indenting
try {
@@ -128,10 +128,10 @@ public class CFormatter {
}
private void convertLineDelimiters(IDocument document) throws BadLocationException {
- int lines= document.getNumberOfLines();
- for (int line= 0; line < lines; line++) {
- IRegion region= document.getLineInformation(line);
- String lineDelimiter= document.getLineDelimiter(line);
+ int lines = document.getNumberOfLines();
+ for (int line = 0; line < lines; line++) {
+ IRegion region = document.getLineInformation(line);
+ String lineDelimiter = document.getLineDelimiter(line);
if (lineDelimiter != null)
document.replace(region.getOffset() + region.getLength(), lineDelimiter.length(), fLineDelimiter);
}
@@ -142,18 +142,18 @@ public class CFormatter {
}
private String trimAtOffset(int offset, IDocument document) throws BadLocationException {
- int i= offset;
+ int i = offset;
while ((i < document.getLength()) && Character.isWhitespace(document.getChar(i)))
i++;
-
- String trim= document.get(offset, i - offset);
+
+ String trim = document.get(offset, i - offset);
document.replace(offset, i - offset, ""); //$NON-NLS-1$
return trim;
}
private boolean isReplacedAreaEmpty(TemplateContext context) {
if (context instanceof DocumentTemplateContext) {
- DocumentTemplateContext dtc= (DocumentTemplateContext) context;
+ DocumentTemplateContext dtc = (DocumentTemplateContext) context;
if (dtc.getCompletionLength() == 0) {
return true;
}
@@ -172,14 +172,15 @@ public class CFormatter {
private void format(IDocument doc) throws BadLocationException {
Map<String, String> options;
if (fProject != null)
- options= fProject.getOptions(true);
+ options = fProject.getOptions(true);
else
- options= CCorePlugin.getOptions();
-
- TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_UNKNOWN, doc.get(), fInitialIndentLevel, fLineDelimiter, options);
+ options = CCorePlugin.getOptions();
+
+ TextEdit edit = CodeFormatterUtil.format(CodeFormatter.K_UNKNOWN, doc.get(), fInitialIndentLevel,
+ fLineDelimiter, options);
if (edit == null)
throw new BadLocationException(); // fall back to indenting
-
+
edit.apply(doc, TextEdit.UPDATE_REGIONS);
}
@@ -190,29 +191,29 @@ public class CFormatter {
/**
* Convert leading tabs to correct indentation and add initial indentation level.
- *
+ *
* @param document
- * @throws BadLocationException
+ * @throws BadLocationException
*/
private void adjustIndentation(IDocument document) throws BadLocationException {
- int lines= document.getNumberOfLines();
+ int lines = document.getNumberOfLines();
if (lines == 0)
return;
String option;
if (fProject == null)
- option= CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+ option = CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
else
- option= fProject.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
-
- boolean useSpaces= CCorePlugin.SPACE.equals(option);
- int indentWidth= CodeFormatterUtil.getIndentWidth(fProject);
- int tabWidth= CodeFormatterUtil.getTabWidth(fProject);
-
- for (int line= 0; line < lines; ++line) {
- IRegion lineRegion= document.getLineInformation(line);
- String indent= IndentUtil.getCurrentIndent(document, line, false);
- int tabs= 0;
+ option = fProject.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
+
+ boolean useSpaces = CCorePlugin.SPACE.equals(option);
+ int indentWidth = CodeFormatterUtil.getIndentWidth(fProject);
+ int tabWidth = CodeFormatterUtil.getTabWidth(fProject);
+
+ for (int line = 0; line < lines; ++line) {
+ IRegion lineRegion = document.getLineInformation(line);
+ String indent = IndentUtil.getCurrentIndent(document, line, false);
+ int tabs = 0;
for (int i = 0; i < indent.length(); i++) {
if (indent.charAt(i) == '\t') {
tabs++;
@@ -220,8 +221,9 @@ public class CFormatter {
break;
}
}
- int totalIndentWidth= (fInitialIndentLevel + tabs) * indentWidth + IndentUtil.computeVisualLength(indent.substring(tabs), tabWidth);
- String newIndent= IndentUtil.changePrefix("", totalIndentWidth, tabWidth, useSpaces); //$NON-NLS-1$
+ int totalIndentWidth = (fInitialIndentLevel + tabs) * indentWidth
+ + IndentUtil.computeVisualLength(indent.substring(tabs), tabWidth);
+ String newIndent = IndentUtil.changePrefix("", totalIndentWidth, tabWidth, useSpaces); //$NON-NLS-1$
document.replace(lineRegion.getOffset(), indent.length(), newIndent);
}
}
@@ -229,36 +231,37 @@ public class CFormatter {
/**
* Prefix each line of <code>line_selection</code> substitutions with
* the prefix of the first line.
- *
+ *
* @param document
* @param buffer
*/
private void prefixSelectionLines(IDocument document, TemplateBuffer buffer) {
- TemplateVariable[] variables= buffer.getVariables();
+ TemplateVariable[] variables = buffer.getVariables();
for (int i = 0; i < variables.length; i++) {
if (variables[i].getName().equals(GlobalTemplateVariables.LineSelection.NAME)) {
if (variables[i].getLength() > 0) {
- final int tabWidth= CodeFormatterUtil.getTabWidth(fProject);
- int delta= 0;
- int[] offsets= variables[i].getOffsets();
- for (int j= 0; j < offsets.length; j++) {
+ final int tabWidth = CodeFormatterUtil.getTabWidth(fProject);
+ int delta = 0;
+ int[] offsets = variables[i].getOffsets();
+ for (int j = 0; j < offsets.length; j++) {
final int offset = offsets[j] + delta;
try {
- int startLine= document.getLineOfOffset(offset);
- int startOffset= document.getLineOffset(startLine);
- int endLine= document.getLineOfOffset(offset+variables[i].getLength() - 1);
- String prefix= document.get(startOffset, offset - startOffset);
- String shift= trimAtOffset(offset, document);
+ int startLine = document.getLineOfOffset(offset);
+ int startOffset = document.getLineOffset(startLine);
+ int endLine = document.getLineOfOffset(offset + variables[i].getLength() - 1);
+ String prefix = document.get(startOffset, offset - startOffset);
+ String shift = trimAtOffset(offset, document);
delta -= shift.length();
if (startLine < endLine) {
- int shiftWidth= IndentUtil.computeVisualLength(shift, tabWidth);
- for (int line= startLine + 1; line <= endLine; ++line) {
- String currentIndent= IndentUtil.getCurrentIndent(document, line, false);
- int indentWidth= IndentUtil.computeVisualLength(currentIndent, tabWidth);
- int newIndentWidth= Math.max(0, indentWidth - shiftWidth);
+ int shiftWidth = IndentUtil.computeVisualLength(shift, tabWidth);
+ for (int line = startLine + 1; line <= endLine; ++line) {
+ String currentIndent = IndentUtil.getCurrentIndent(document, line, false);
+ int indentWidth = IndentUtil.computeVisualLength(currentIndent, tabWidth);
+ int newIndentWidth = Math.max(0, indentWidth - shiftWidth);
// replace current indent with prefix + spaces
- String newIndent= IndentUtil.changePrefix(prefix, prefix.length() + newIndentWidth, 1, true);
- int lineOffset= document.getLineOffset(line);
+ String newIndent = IndentUtil.changePrefix(prefix, prefix.length() + newIndentWidth,
+ 1, true);
+ int lineOffset = document.getLineOffset(line);
document.replace(lineOffset, currentIndent.length(), newIndent);
delta -= currentIndent.length();
delta += newIndent.length();
@@ -279,58 +282,53 @@ public class CFormatter {
* occur. Whitespace variables are also tracked.
*/
private static final class VariableTracker {
- private static final String CATEGORY= "__template_variables"; //$NON-NLS-1$
+ private static final String CATEGORY = "__template_variables"; //$NON-NLS-1$
private Document fDocument;
private final TemplateBuffer fBuffer;
private List<TypedPosition> fPositions;
-
+
/**
* Creates a new tracker.
- *
+ *
* @param buffer the buffer to track
* @throws MalformedTreeException
* @throws BadLocationException
*/
public VariableTracker(TemplateBuffer buffer) throws MalformedTreeException, BadLocationException {
Assert.isLegal(buffer != null);
- fBuffer= buffer;
- fDocument= new Document(fBuffer.getString());
+ fBuffer = buffer;
+ fDocument = new Document(fBuffer.getString());
installCStuff(fDocument);
fDocument.addPositionCategory(CATEGORY);
fDocument.addPositionUpdater(new ExclusivePositionUpdater(CATEGORY));
- fPositions= createRangeMarkers(fBuffer.getVariables(), fDocument);
+ fPositions = createRangeMarkers(fBuffer.getVariables(), fDocument);
}
-
+
/**
* Installs a C partitioner with <code>document</code>.
*
* @param document the document
*/
private static void installCStuff(Document document) {
- String[] types= new String[] {
- ICPartitions.C_MULTI_LINE_COMMENT,
- ICPartitions.C_SINGLE_LINE_COMMENT,
- ICPartitions.C_STRING,
- ICPartitions.C_CHARACTER,
- ICPartitions.C_PREPROCESSOR,
- IDocument.DEFAULT_CONTENT_TYPE
- };
- FastPartitioner partitioner= new FastPartitioner(new FastCPartitionScanner(), types);
+ String[] types = new String[] { ICPartitions.C_MULTI_LINE_COMMENT, ICPartitions.C_SINGLE_LINE_COMMENT,
+ ICPartitions.C_STRING, ICPartitions.C_CHARACTER, ICPartitions.C_PREPROCESSOR,
+ IDocument.DEFAULT_CONTENT_TYPE };
+ FastPartitioner partitioner = new FastPartitioner(new FastCPartitionScanner(), types);
partitioner.connect(document);
document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
}
-
+
/**
* Returns the document with the buffer contents. Whitespace variables are decorated with
* comments.
- *
+ *
* @return the buffer document
*/
public IDocument getDocument() {
checkState();
return fDocument;
}
-
+
private void checkState() {
if (fDocument == null)
throw new IllegalStateException();
@@ -338,108 +336,110 @@ public class CFormatter {
/**
* Restores any decorated regions and updates the buffer's variable offsets.
- *
+ *
* @return the buffer.
* @throws MalformedTreeException
* @throws BadLocationException
*/
public TemplateBuffer updateBuffer() throws MalformedTreeException, BadLocationException {
checkState();
- TemplateVariable[] variables= fBuffer.getVariables();
+ TemplateVariable[] variables = fBuffer.getVariables();
try {
removeRangeMarkers(fPositions, fDocument, variables);
} catch (BadPositionCategoryException x) {
Assert.isTrue(false);
}
fBuffer.setContent(fDocument.get(), variables);
- fDocument= null;
-
+ fDocument = null;
+
return fBuffer;
}
-
- private List<TypedPosition> createRangeMarkers(TemplateVariable[] variables, IDocument document) throws MalformedTreeException, BadLocationException {
- Map<ReplaceEdit, String> markerToOriginal= new HashMap<ReplaceEdit, String>();
-
- MultiTextEdit root= new MultiTextEdit(0, document.getLength());
- List<TextEdit> edits= new ArrayList<TextEdit>();
- boolean hasModifications= false;
- for (int i= 0; i != variables.length; i++) {
- final TemplateVariable variable= variables[i];
- int[] offsets= variable.getOffsets();
-
- String value= variable.getDefaultValue();
+
+ private List<TypedPosition> createRangeMarkers(TemplateVariable[] variables, IDocument document)
+ throws MalformedTreeException, BadLocationException {
+ Map<ReplaceEdit, String> markerToOriginal = new HashMap<ReplaceEdit, String>();
+
+ MultiTextEdit root = new MultiTextEdit(0, document.getLength());
+ List<TextEdit> edits = new ArrayList<TextEdit>();
+ boolean hasModifications = false;
+ for (int i = 0; i != variables.length; i++) {
+ final TemplateVariable variable = variables[i];
+ int[] offsets = variable.getOffsets();
+
+ String value = variable.getDefaultValue();
if (isWhitespaceVariable(value)) {
// replace whitespace positions with unformattable comments
- String placeholder= COMMENT_START + value + COMMENT_END;
- for (int j= 0; j != offsets.length; j++) {
- ReplaceEdit replace= new ReplaceEdit(offsets[j], value.length(), placeholder);
+ String placeholder = COMMENT_START + value + COMMENT_END;
+ for (int j = 0; j != offsets.length; j++) {
+ ReplaceEdit replace = new ReplaceEdit(offsets[j], value.length(), placeholder);
root.addChild(replace);
- hasModifications= true;
+ hasModifications = true;
markerToOriginal.put(replace, value);
edits.add(replace);
}
} else {
- for (int j= 0; j != offsets.length; j++) {
- RangeMarker marker= new RangeMarker(offsets[j], value.length());
+ for (int j = 0; j != offsets.length; j++) {
+ RangeMarker marker = new RangeMarker(offsets[j], value.length());
root.addChild(marker);
edits.add(marker);
}
}
}
-
+
if (hasModifications) {
// update the document and convert the replaces to markers
root.apply(document, TextEdit.UPDATE_REGIONS);
}
-
- List<TypedPosition> positions= new ArrayList<TypedPosition>();
- for (Iterator<TextEdit> it= edits.iterator(); it.hasNext();) {
- TextEdit edit= it.next();
+
+ List<TypedPosition> positions = new ArrayList<TypedPosition>();
+ for (Iterator<TextEdit> it = edits.iterator(); it.hasNext();) {
+ TextEdit edit = it.next();
try {
// abuse TypedPosition to piggy back the original contents of the position
- final TypedPosition pos= new TypedPosition(edit.getOffset(), edit.getLength(), markerToOriginal.get(edit));
+ final TypedPosition pos = new TypedPosition(edit.getOffset(), edit.getLength(),
+ markerToOriginal.get(edit));
document.addPosition(CATEGORY, pos);
positions.add(pos);
} catch (BadPositionCategoryException x) {
Assert.isTrue(false);
}
}
-
+
return positions;
}
-
+
private boolean isWhitespaceVariable(String value) {
- int length= value.length();
+ int length = value.length();
return length == 0 || value.trim().length() == 0;
}
-
- private void removeRangeMarkers(List<TypedPosition> positions, IDocument document, TemplateVariable[] variables) throws MalformedTreeException, BadLocationException, BadPositionCategoryException {
-
+
+ private void removeRangeMarkers(List<TypedPosition> positions, IDocument document, TemplateVariable[] variables)
+ throws MalformedTreeException, BadLocationException, BadPositionCategoryException {
+
// revert previous changes
- for (Iterator<TypedPosition> it= positions.iterator(); it.hasNext();) {
- TypedPosition position= it.next();
+ for (Iterator<TypedPosition> it = positions.iterator(); it.hasNext();) {
+ TypedPosition position = it.next();
// remove and re-add in order to not confuse ExclusivePositionUpdater
document.removePosition(CATEGORY, position);
- final String original= position.getType();
+ final String original = position.getType();
if (original != null) {
document.replace(position.getOffset(), position.getLength(), original);
position.setLength(original.length());
}
document.addPosition(position);
}
-
- Iterator<TypedPosition> it= positions.iterator();
- for (int i= 0; i != variables.length; i++) {
- TemplateVariable variable= variables[i];
- int[] offsets= new int[variable.getOffsets().length];
- for (int j= 0; j != offsets.length; j++)
- offsets[j]= it.next().getOffset();
+ Iterator<TypedPosition> it = positions.iterator();
+ for (int i = 0; i != variables.length; i++) {
+ TemplateVariable variable = variables[i];
+
+ int[] offsets = new int[variable.getOffsets().length];
+ for (int j = 0; j != offsets.length; j++)
+ offsets[j] = it.next().getOffset();
- variable.setOffsets(offsets);
+ variable.setOffsets(offsets);
}
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.java
index 44b212017c9..35fd835fcc8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.java
@@ -29,7 +29,7 @@ public class CodeTemplateContext extends FileTemplateContext {
public CodeTemplateContext(String contextTypeId, ICProject project, String lineDelimiter) {
super(contextTypeId, lineDelimiter);
- fProject= project;
+ fProject = project;
}
public ICProject getCProject() {
@@ -37,7 +37,7 @@ public class CodeTemplateContext extends FileTemplateContext {
}
public void setTranslationUnitVariables(ITranslationUnit tu) {
- IFile file= (IFile) tu.getResource();
+ IFile file = (IFile) tu.getResource();
if (file != null) {
super.setResourceVariables(file);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextType.java
index 36518f5de54..75034b9fc8e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextType.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextType.java
@@ -27,69 +27,74 @@ import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
public class CodeTemplateContextType extends FileTemplateContextType {
/* Context types */
- private static final String CONTEXTTYPE_PREFIX= "org.eclipse.cdt.ui.text.codetemplates."; //$NON-NLS-1$
+ private static final String CONTEXTTYPE_PREFIX = "org.eclipse.cdt.ui.text.codetemplates."; //$NON-NLS-1$
- public static final String CPPSOURCEFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_CXXSOURCE + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
- public static final String CPPHEADERFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_CXXHEADER + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
- public static final String CSOURCEFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_CSOURCE + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
- public static final String CHEADERFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_CHEADER + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
- public static final String ASMSOURCEFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_ASMSOURCE + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+ public static final String CPPSOURCEFILE_CONTEXTTYPE = CCorePlugin.CONTENT_TYPE_CXXSOURCE
+ + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+ public static final String CPPHEADERFILE_CONTEXTTYPE = CCorePlugin.CONTENT_TYPE_CXXHEADER
+ + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+ public static final String CSOURCEFILE_CONTEXTTYPE = CCorePlugin.CONTENT_TYPE_CSOURCE
+ + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+ public static final String CHEADERFILE_CONTEXTTYPE = CCorePlugin.CONTENT_TYPE_CHEADER
+ + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+ public static final String ASMSOURCEFILE_CONTEXTTYPE = CCorePlugin.CONTENT_TYPE_ASMSOURCE
+ + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
- public static final String NAMESPACE_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "namespace_context"; //$NON-NLS-1$
- public static final String CLASS_BODY_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "class_context"; //$NON-NLS-1$
- public static final String CONSTRUCTORBODY_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "constructorbody_context"; //$NON-NLS-1$
- public static final String DESTRUCTORBODY_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "destructorbody_context"; //$NON-NLS-1$
- public static final String METHODBODY_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "methodbody_context"; //$NON-NLS-1$
- public static final String FILECOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "filecomment_context"; //$NON-NLS-1$
- public static final String TYPECOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "typecomment_context"; //$NON-NLS-1$
- public static final String FIELDCOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "fieldcomment_context"; //$NON-NLS-1$
- public static final String METHODCOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "methodcomment_context"; //$NON-NLS-1$
- public static final String CONSTRUCTORCOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "constructorcomment_context"; //$NON-NLS-1$
- public static final String DESTRUCTORCOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "destructorcomment_context"; //$NON-NLS-1$
+ public static final String NAMESPACE_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "namespace_context"; //$NON-NLS-1$
+ public static final String CLASS_BODY_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "class_context"; //$NON-NLS-1$
+ public static final String CONSTRUCTORBODY_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "constructorbody_context"; //$NON-NLS-1$
+ public static final String DESTRUCTORBODY_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "destructorbody_context"; //$NON-NLS-1$
+ public static final String METHODBODY_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "methodbody_context"; //$NON-NLS-1$
+ public static final String FILECOMMENT_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "filecomment_context"; //$NON-NLS-1$
+ public static final String TYPECOMMENT_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "typecomment_context"; //$NON-NLS-1$
+ public static final String FIELDCOMMENT_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "fieldcomment_context"; //$NON-NLS-1$
+ public static final String METHODCOMMENT_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "methodcomment_context"; //$NON-NLS-1$
+ public static final String CONSTRUCTORCOMMENT_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "constructorcomment_context"; //$NON-NLS-1$
+ public static final String DESTRUCTORCOMMENT_CONTEXTTYPE = CONTEXTTYPE_PREFIX + "destructorcomment_context"; //$NON-NLS-1$
/* Templates */
- private static final String CODETEMPLATES_PREFIX= "org.eclipse.cdt.ui.text.codetemplates."; //$NON-NLS-1$
- public static final String COMMENT_SUFFIX= "comment"; //$NON-NLS-1$
-
- public static final String ASM_SOURCEFILE_ID= CODETEMPLATES_PREFIX + "asmsourcefile"; //$NON-NLS-1$
- public static final String CPP_SOURCEFILE_ID= CODETEMPLATES_PREFIX + "cppsourcefile"; //$NON-NLS-1$
- public static final String CPP_HEADERFILE_ID= CODETEMPLATES_PREFIX + "cppheaderfile"; //$NON-NLS-1$
- public static final String CPP_TESTFILE_ID= CODETEMPLATES_PREFIX + "cpptestfile"; //$NON-NLS-1$
- public static final String C_SOURCEFILE_ID= CODETEMPLATES_PREFIX + "csourcefile"; //$NON-NLS-1$
- public static final String C_HEADERFILE_ID= CODETEMPLATES_PREFIX + "cheaderfile"; //$NON-NLS-1$
- public static final String NAMESPACE_BEGIN_ID= CODETEMPLATES_PREFIX + "namespace_begin"; //$NON-NLS-1$
- public static final String NAMESPACE_END_ID= CODETEMPLATES_PREFIX + "namespace_end"; //$NON-NLS-1$
- public static final String CLASS_BODY_ID= CODETEMPLATES_PREFIX + "class_body"; //$NON-NLS-1$
- public static final String METHODSTUB_ID= CODETEMPLATES_PREFIX + "methodbody"; //$NON-NLS-1$
- public static final String CONSTRUCTORSTUB_ID= CODETEMPLATES_PREFIX + "constructorbody"; //$NON-NLS-1$
- public static final String DESTRUCTORSTUB_ID= CODETEMPLATES_PREFIX + "destructorbody"; //$NON-NLS-1$
- public static final String FILECOMMENT_ID= CODETEMPLATES_PREFIX + "file" + COMMENT_SUFFIX; //$NON-NLS-1$
- public static final String TYPECOMMENT_ID= CODETEMPLATES_PREFIX + "type" + COMMENT_SUFFIX; //$NON-NLS-1$
- public static final String FIELDCOMMENT_ID= CODETEMPLATES_PREFIX + "field" + COMMENT_SUFFIX; //$NON-NLS-1$
- public static final String METHODCOMMENT_ID= CODETEMPLATES_PREFIX + "method" + COMMENT_SUFFIX; //$NON-NLS-1$
- public static final String CONSTRUCTORCOMMENT_ID= CODETEMPLATES_PREFIX + "constructor" + COMMENT_SUFFIX; //$NON-NLS-1$
- public static final String DESTRUCTORCOMMENT_ID= CODETEMPLATES_PREFIX + "destructor" + COMMENT_SUFFIX; //$NON-NLS-1$
+ private static final String CODETEMPLATES_PREFIX = "org.eclipse.cdt.ui.text.codetemplates."; //$NON-NLS-1$
+ public static final String COMMENT_SUFFIX = "comment"; //$NON-NLS-1$
+
+ public static final String ASM_SOURCEFILE_ID = CODETEMPLATES_PREFIX + "asmsourcefile"; //$NON-NLS-1$
+ public static final String CPP_SOURCEFILE_ID = CODETEMPLATES_PREFIX + "cppsourcefile"; //$NON-NLS-1$
+ public static final String CPP_HEADERFILE_ID = CODETEMPLATES_PREFIX + "cppheaderfile"; //$NON-NLS-1$
+ public static final String CPP_TESTFILE_ID = CODETEMPLATES_PREFIX + "cpptestfile"; //$NON-NLS-1$
+ public static final String C_SOURCEFILE_ID = CODETEMPLATES_PREFIX + "csourcefile"; //$NON-NLS-1$
+ public static final String C_HEADERFILE_ID = CODETEMPLATES_PREFIX + "cheaderfile"; //$NON-NLS-1$
+ public static final String NAMESPACE_BEGIN_ID = CODETEMPLATES_PREFIX + "namespace_begin"; //$NON-NLS-1$
+ public static final String NAMESPACE_END_ID = CODETEMPLATES_PREFIX + "namespace_end"; //$NON-NLS-1$
+ public static final String CLASS_BODY_ID = CODETEMPLATES_PREFIX + "class_body"; //$NON-NLS-1$
+ public static final String METHODSTUB_ID = CODETEMPLATES_PREFIX + "methodbody"; //$NON-NLS-1$
+ public static final String CONSTRUCTORSTUB_ID = CODETEMPLATES_PREFIX + "constructorbody"; //$NON-NLS-1$
+ public static final String DESTRUCTORSTUB_ID = CODETEMPLATES_PREFIX + "destructorbody"; //$NON-NLS-1$
+ public static final String FILECOMMENT_ID = CODETEMPLATES_PREFIX + "file" + COMMENT_SUFFIX; //$NON-NLS-1$
+ public static final String TYPECOMMENT_ID = CODETEMPLATES_PREFIX + "type" + COMMENT_SUFFIX; //$NON-NLS-1$
+ public static final String FIELDCOMMENT_ID = CODETEMPLATES_PREFIX + "field" + COMMENT_SUFFIX; //$NON-NLS-1$
+ public static final String METHODCOMMENT_ID = CODETEMPLATES_PREFIX + "method" + COMMENT_SUFFIX; //$NON-NLS-1$
+ public static final String CONSTRUCTORCOMMENT_ID = CODETEMPLATES_PREFIX + "constructor" + COMMENT_SUFFIX; //$NON-NLS-1$
+ public static final String DESTRUCTORCOMMENT_ID = CODETEMPLATES_PREFIX + "destructor" + COMMENT_SUFFIX; //$NON-NLS-1$
/* Resolver types */
- public static final String ENCLOSING_METHOD= "enclosing_method"; //$NON-NLS-1$
- public static final String ENCLOSING_TYPE= "enclosing_type"; //$NON-NLS-1$
- public static final String BODY_STATEMENT= "body_statement"; //$NON-NLS-1$
- public static final String FIELD= "field"; //$NON-NLS-1$
- public static final String FIELD_TYPE= "field_type"; //$NON-NLS-1$
+ public static final String ENCLOSING_METHOD = "enclosing_method"; //$NON-NLS-1$
+ public static final String ENCLOSING_TYPE = "enclosing_type"; //$NON-NLS-1$
+ public static final String BODY_STATEMENT = "body_statement"; //$NON-NLS-1$
+ public static final String FIELD = "field"; //$NON-NLS-1$
+ public static final String FIELD_TYPE = "field_type"; //$NON-NLS-1$
- public static final String RETURN_TYPE= "return_type"; //$NON-NLS-1$
+ public static final String RETURN_TYPE = "return_type"; //$NON-NLS-1$
- public static final String TYPENAME= "type_name"; //$NON-NLS-1$
- public static final String NAMESPACE_NAME= "namespace_name"; //$NON-NLS-1$
- public static final String BASE_CLASSES= "base_classes"; //$NON-NLS-1$
- public static final String INCLUDE_GUARD_SYMBOL= "include_guard_symbol"; //$NON-NLS-1$
+ public static final String TYPENAME = "type_name"; //$NON-NLS-1$
+ public static final String NAMESPACE_NAME = "namespace_name"; //$NON-NLS-1$
+ public static final String BASE_CLASSES = "base_classes"; //$NON-NLS-1$
+ public static final String INCLUDE_GUARD_SYMBOL = "include_guard_symbol"; //$NON-NLS-1$
- public static final String DECLARATIONS= "declarations"; //$NON-NLS-1$
- public static final String TYPE_COMMENT= "typecomment"; //$NON-NLS-1$
- public static final String FILE_COMMENT= "filecomment"; //$NON-NLS-1$
- public static final String INCLUDES= "includes"; //$NON-NLS-1$
- public static final String NAMESPACE_BEGIN= "namespace_begin"; //$NON-NLS-1$
- public static final String NAMESPACE_END= "namespace_end"; //$NON-NLS-1$
+ public static final String DECLARATIONS = "declarations"; //$NON-NLS-1$
+ public static final String TYPE_COMMENT = "typecomment"; //$NON-NLS-1$
+ public static final String FILE_COMMENT = "filecomment"; //$NON-NLS-1$
+ public static final String INCLUDES = "includes"; //$NON-NLS-1$
+ public static final String NAMESPACE_BEGIN = "namespace_begin"; //$NON-NLS-1$
+ public static final String NAMESPACE_END = "namespace_end"; //$NON-NLS-1$
/**
* Resolver that resolves to the variable defined in the context.
@@ -105,7 +110,7 @@ public class CodeTemplateContextType extends FileTemplateContextType {
*/
protected static class Todo extends TemplateVariableResolver {
public Todo() {
- super("todo", TemplateMessages.CodeTemplateContextType_variable_description_todo); //$NON-NLS-1$
+ super("todo", TemplateMessages.CodeTemplateContextType_variable_description_todo); //$NON-NLS-1$
}
@Override
@@ -114,7 +119,7 @@ public class CodeTemplateContextType extends FileTemplateContextType {
if (context instanceof CodeTemplateContext) {
cProject = ((CodeTemplateContext) context).getCProject();
}
- String todoTaskTag= StubUtility.getTodoTaskTag(cProject);
+ String todoTaskTag = StubUtility.getTodoTaskTag(cProject);
if (todoTaskTag == null)
return "XXX"; //$NON-NLS-1$
@@ -131,86 +136,130 @@ public class CodeTemplateContextType extends FileTemplateContextType {
public CodeTemplateContextType(String contextTypeId, String contextName) {
super(contextTypeId, contextName);
- fIsComment= false;
+ fIsComment = false;
// global
addResolver(new Todo());
if (CPPSOURCEFILE_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration));
- addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
- addResolver(new CodeTemplateVariableResolver(INCLUDES, TemplateMessages.CodeTemplateContextType_variable_description_includes));
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN, TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin));
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_END, TemplateMessages.CodeTemplateContextType_variable_description_namespace_end));
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME, TemplateMessages.CodeTemplateContextType_variable_description_namespace_name));
- addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_typecomment));
- addResolver(new CodeTemplateVariableResolver(TYPENAME, TemplateMessages.CodeTemplateContextType_variable_description_class_name));
+ addResolver(new CodeTemplateVariableResolver(DECLARATIONS,
+ TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration));
+ addResolver(new CodeTemplateVariableResolver(FILE_COMMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
+ addResolver(new CodeTemplateVariableResolver(INCLUDES,
+ TemplateMessages.CodeTemplateContextType_variable_description_includes));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_END,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_end));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_name));
+ addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_typecomment));
+ addResolver(new CodeTemplateVariableResolver(TYPENAME,
+ TemplateMessages.CodeTemplateContextType_variable_description_class_name));
addTranslationUnitVariables();
} else if (CPPHEADERFILE_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration));
- addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
- addResolver(new CodeTemplateVariableResolver(INCLUDE_GUARD_SYMBOL, TemplateMessages.CodeTemplateContextType_variable_description_include_guard_symbol));
- addResolver(new CodeTemplateVariableResolver(INCLUDES, TemplateMessages.CodeTemplateContextType_variable_description_includes));
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN, TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin));
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_END, TemplateMessages.CodeTemplateContextType_variable_description_namespace_end));
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME, TemplateMessages.CodeTemplateContextType_variable_description_namespace_name));
- addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_typecomment));
- addResolver(new CodeTemplateVariableResolver(TYPENAME, TemplateMessages.CodeTemplateContextType_variable_description_class_name));
+ addResolver(new CodeTemplateVariableResolver(DECLARATIONS,
+ TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration));
+ addResolver(new CodeTemplateVariableResolver(FILE_COMMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
+ addResolver(new CodeTemplateVariableResolver(INCLUDE_GUARD_SYMBOL,
+ TemplateMessages.CodeTemplateContextType_variable_description_include_guard_symbol));
+ addResolver(new CodeTemplateVariableResolver(INCLUDES,
+ TemplateMessages.CodeTemplateContextType_variable_description_includes));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_END,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_end));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_name));
+ addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_typecomment));
+ addResolver(new CodeTemplateVariableResolver(TYPENAME,
+ TemplateMessages.CodeTemplateContextType_variable_description_class_name));
addTranslationUnitVariables();
} else if (CSOURCEFILE_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration));
- addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
- addResolver(new CodeTemplateVariableResolver(INCLUDES, TemplateMessages.CodeTemplateContextType_variable_description_includes));
+ addResolver(new CodeTemplateVariableResolver(DECLARATIONS,
+ TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration));
+ addResolver(new CodeTemplateVariableResolver(FILE_COMMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
+ addResolver(new CodeTemplateVariableResolver(INCLUDES,
+ TemplateMessages.CodeTemplateContextType_variable_description_includes));
addTranslationUnitVariables();
} else if (CHEADERFILE_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration));
- addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
- addResolver(new CodeTemplateVariableResolver(INCLUDE_GUARD_SYMBOL, TemplateMessages.CodeTemplateContextType_variable_description_include_guard_symbol));
- addResolver(new CodeTemplateVariableResolver(INCLUDES, TemplateMessages.CodeTemplateContextType_variable_description_includes));
+ addResolver(new CodeTemplateVariableResolver(DECLARATIONS,
+ TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration));
+ addResolver(new CodeTemplateVariableResolver(FILE_COMMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
+ addResolver(new CodeTemplateVariableResolver(INCLUDE_GUARD_SYMBOL,
+ TemplateMessages.CodeTemplateContextType_variable_description_include_guard_symbol));
+ addResolver(new CodeTemplateVariableResolver(INCLUDES,
+ TemplateMessages.CodeTemplateContextType_variable_description_includes));
addTranslationUnitVariables();
} else if (METHODBODY_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT, TemplateMessages.CodeTemplateContextType_variable_description_bodystatement));
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, TemplateMessages.CodeTemplateContextType_variable_description_enclosingmethod));
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
+ addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_bodystatement));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,
+ TemplateMessages.CodeTemplateContextType_variable_description_enclosingmethod));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
} else if (CONSTRUCTORBODY_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT, TemplateMessages.CodeTemplateContextType_variable_description_bodystatement));
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
+ addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_bodystatement));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
} else if (DESTRUCTORBODY_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT, TemplateMessages.CodeTemplateContextType_variable_description_bodystatement));
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
+ addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_bodystatement));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
} else if (CLASS_BODY_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_class_members));
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_class_name));
+ addResolver(new CodeTemplateVariableResolver(DECLARATIONS,
+ TemplateMessages.CodeTemplateContextType_variable_description_class_members));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_class_name));
} else if (NAMESPACE_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN, TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin));
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_END, TemplateMessages.CodeTemplateContextType_variable_description_namespace_end));
- addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME, TemplateMessages.CodeTemplateContextType_variable_description_namespace_name));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_END,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_end));
+ addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME,
+ TemplateMessages.CodeTemplateContextType_variable_description_namespace_name));
} else if (TYPECOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(TYPENAME, TemplateMessages.CodeTemplateContextType_variable_description_typename));
+ addResolver(new CodeTemplateVariableResolver(TYPENAME,
+ TemplateMessages.CodeTemplateContextType_variable_description_typename));
addTranslationUnitVariables();
- fIsComment= true;
+ fIsComment = true;
} else if (FILECOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
addTranslationUnitVariables();
- fIsComment= true;
+ fIsComment = true;
} else if (FIELDCOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(FIELD, TemplateMessages.CodeTemplateContextType_variable_description_fieldname));
- addResolver(new CodeTemplateVariableResolver(FIELD_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_fieldtype));
+ addResolver(new CodeTemplateVariableResolver(FIELD,
+ TemplateMessages.CodeTemplateContextType_variable_description_fieldname));
+ addResolver(new CodeTemplateVariableResolver(FIELD_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_fieldtype));
addTranslationUnitVariables();
- fIsComment= true;
+ fIsComment = true;
} else if (METHODCOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, TemplateMessages.CodeTemplateContextType_variable_description_enclosingmethod));
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
- addResolver(new CodeTemplateVariableResolver(RETURN_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_returntype));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,
+ TemplateMessages.CodeTemplateContextType_variable_description_enclosingmethod));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
+ addResolver(new CodeTemplateVariableResolver(RETURN_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_returntype));
addTranslationUnitVariables();
- fIsComment= true;
+ fIsComment = true;
} else if (CONSTRUCTORCOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
addTranslationUnitVariables();
- fIsComment= true;
+ fIsComment = true;
} else if (DESTRUCTORCOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
- addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
+ addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,
+ TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype));
addTranslationUnitVariables();
- fIsComment= true;
+ fIsComment = true;
} else {
addTranslationUnitVariables();
}
@@ -229,12 +278,19 @@ public class CodeTemplateContextType extends FileTemplateContextType {
}
public static void registerContextTypes(ContextTypeRegistry registry) {
- registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CPPSOURCEFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_cppsource_name));
- registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CPPHEADERFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_cppheader_name));
- registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CSOURCEFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_csource_name));
- registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CHEADERFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_cheader_name));
- FileTemplateContextType asmContextType= new FileTemplateContextType(CodeTemplateContextType.ASMSOURCEFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_asmsource_name);
- asmContextType.addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
+ registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CPPSOURCEFILE_CONTEXTTYPE,
+ TemplateMessages.CodeTemplateContextType_cppsource_name));
+ registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CPPHEADERFILE_CONTEXTTYPE,
+ TemplateMessages.CodeTemplateContextType_cppheader_name));
+ registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CSOURCEFILE_CONTEXTTYPE,
+ TemplateMessages.CodeTemplateContextType_csource_name));
+ registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CHEADERFILE_CONTEXTTYPE,
+ TemplateMessages.CodeTemplateContextType_cheader_name));
+ FileTemplateContextType asmContextType = new FileTemplateContextType(
+ CodeTemplateContextType.ASMSOURCEFILE_CONTEXTTYPE,
+ TemplateMessages.CodeTemplateContextType_asmsource_name);
+ asmContextType.addResolver(new CodeTemplateVariableResolver(FILE_COMMENT,
+ TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
registry.addContextType(asmContextType);
registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.NAMESPACE_CONTEXTTYPE));
@@ -256,23 +312,23 @@ public class CodeTemplateContextType extends FileTemplateContextType {
super.validate(pattern);
if (fIsComment) {
if (!isValidComment(pattern)) {
- throw new TemplateException(TemplateMessages.CodeTemplateContextType_validate_invalidcomment);
+ throw new TemplateException(TemplateMessages.CodeTemplateContextType_validate_invalidcomment);
}
}
}
private boolean isValidComment(String template) {
-// IScanner scanner= ToolFactory.createScanner(true, false, false, false);
-// scanner.setSource(template.toCharArray());
-// try {
-// int next= scanner.getNextToken();
-// while (TokenScanner.isComment(next)) {
-// next= scanner.getNextToken();
-// }
-// return next == ITerminalSymbols.TokenNameEOF;
-// } catch (InvalidInputException e) {
-// }
-// return false;
+ // IScanner scanner= ToolFactory.createScanner(true, false, false, false);
+ // scanner.setSource(template.toCharArray());
+ // try {
+ // int next= scanner.getNextToken();
+ // while (TokenScanner.isComment(next)) {
+ // next= scanner.getNextToken();
+ // }
+ // return next == ITerminalSymbols.TokenNameEOF;
+ // } catch (InvalidInputException e) {
+ // }
+ // return false;
return true;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContext.java
index f927b8ec3d5..fba60d18918 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContext.java
@@ -36,72 +36,71 @@ public class CommentContext extends TranslationUnitContext {
/**
* Creates a comment template context.
- *
+ *
* @param type the context type.
* @param document the document.
* @param completionOffset the completion offset within the document.
* @param completionLength the completion length within the document.
* @param translationUnit the translation unit (may be <code>null</code>).
*/
- public CommentContext(TemplateContextType type, IDocument document,
- int completionOffset, int completionLength, ITranslationUnit translationUnit) {
+ public CommentContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength,
+ ITranslationUnit translationUnit) {
super(type, document, completionOffset, completionLength, translationUnit);
}
/**
* Creates a comment template context.
- *
+ *
* @param type the context type.
* @param document the document.
* @param completionPosition the completion position within the document
* @param translationUnit the translation unit (may be <code>null</code>).
*/
- public CommentContext(TemplateContextType type, IDocument document,
- Position completionPosition, ITranslationUnit translationUnit) {
+ public CommentContext(TemplateContextType type, IDocument document, Position completionPosition,
+ ITranslationUnit translationUnit) {
super(type, document, completionPosition, translationUnit);
}
/*
* @see DocumentTemplateContext#getStart()
- */
+ */
@Override
public int getStart() {
if (fIsManaged && getCompletionLength() > 0)
return super.getStart();
-
+
try {
- IDocument document= getDocument();
+ IDocument document = getDocument();
if (getCompletionLength() == 0) {
- int start= getCompletionOffset();
-
+ int start = getCompletionOffset();
+
while ((start != 0) && !Character.isWhitespace(document.getChar(start - 1)))
start--;
-
+
if ((start != 0) && !Character.isWhitespace(document.getChar(start - 1)))
start--;
-
+
return start;
-
- }
- int start= getCompletionOffset();
- int end= getCompletionOffset() + getCompletionLength();
-
+ }
+
+ int start = getCompletionOffset();
+ int end = getCompletionOffset() + getCompletionLength();
+
while (start != 0 && !Character.isWhitespace(document.getChar(start - 1)))
start--;
-
+
while (start != end && Character.isWhitespace(document.getChar(start)))
start++;
-
+
if (start == end)
- start= getCompletionOffset();
-
- return start;
-
+ start = getCompletionOffset();
+
+ return start;
} catch (BadLocationException e) {
- return getCompletionOffset();
+ return getCompletionOffset();
}
}
@@ -110,23 +109,23 @@ public class CommentContext extends TranslationUnitContext {
*/
@Override
public int getEnd() {
- if (fIsManaged || getCompletionLength() == 0)
+ if (fIsManaged || getCompletionLength() == 0)
return super.getEnd();
- try {
- IDocument document= getDocument();
+ try {
+ IDocument document = getDocument();
+
+ int start = getCompletionOffset();
+ int end = getCompletionOffset() + getCompletionLength();
- int start= getCompletionOffset();
- int end= getCompletionOffset() + getCompletionLength();
-
while (start != end && Character.isWhitespace(document.getChar(end - 1)))
end--;
-
- return end;
+
+ return end;
} catch (BadLocationException e) {
return super.getEnd();
- }
+ }
}
/*
@@ -134,18 +133,19 @@ public class CommentContext extends TranslationUnitContext {
*/
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
- TemplateTranslator translator= new TemplateTranslator();
- TemplateBuffer buffer= translator.translate(template);
+ TemplateTranslator translator = new TemplateTranslator();
+ TemplateBuffer buffer = translator.translate(template);
getContextType().resolve(buffer, this);
-
+
// don't use code formatter for comment templates
- boolean useCodeFormatter= false;
+ boolean useCodeFormatter = false;
- ICProject project= getCProject();
- CFormatter formatter= new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), getIndentationLevel(), useCodeFormatter, project);
+ ICProject project = getCProject();
+ CFormatter formatter = new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()),
+ getIndentationLevel(), useCodeFormatter, project);
formatter.format(buffer, this);
-
+
return buffer;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContextType.java
index 149f9a7f115..a884d6ee034 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContextType.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContextType.java
@@ -26,7 +26,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
*/
public class CommentContextType extends TranslationUnitContextType {
- public static final String ID= "org.eclipse.cdt.ui.text.templates.comment"; //$NON-NLS-1$
+ public static final String ID = "org.eclipse.cdt.ui.text.templates.comment"; //$NON-NLS-1$
/**
* Creates a comment context type.
@@ -34,13 +34,13 @@ public class CommentContextType extends TranslationUnitContextType {
public CommentContextType() {
super();
}
-
+
/*
* @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, org.eclipse.cdt.core.model.ITranslationUnit)
*/
@Override
- public TranslationUnitContext createContext(IDocument document, int offset,
- int length, ITranslationUnit translationUnit) {
+ public TranslationUnitContext createContext(IDocument document, int offset, int length,
+ ITranslationUnit translationUnit) {
return new CommentContext(this, document, offset, length, translationUnit);
}
@@ -48,8 +48,8 @@ public class CommentContextType extends TranslationUnitContextType {
* @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position, org.eclipse.cdt.core.model.ITranslationUnit)
*/
@Override
- public TranslationUnitContext createContext(IDocument document,
- Position position, ITranslationUnit translationUnit) {
+ public TranslationUnitContext createContext(IDocument document, Position position,
+ ITranslationUnit translationUnit) {
return new CommentContext(this, document, position, translationUnit);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java
index 3cf0f18a3eb..81f56c73cd2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java
@@ -21,7 +21,7 @@ package org.eclipse.cdt.internal.corext.template.c;
public class DocCommentContextType extends CommentContextType {
@SuppressWarnings("hiding")
- public static final String ID= "org.eclipse.cdt.ui.text.templates.doccomment"; //$NON-NLS-1$
+ public static final String ID = "org.eclipse.cdt.ui.text.templates.doccomment"; //$NON-NLS-1$
public DocCommentContextType() {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java
index 93b76f30e4f..73f8514328b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java
@@ -33,7 +33,7 @@ final class ExclusivePositionUpdater implements IPositionUpdater {
* @param category the new category.
*/
public ExclusivePositionUpdater(String category) {
- fCategory= category;
+ fCategory = category;
}
/*
@@ -42,24 +42,24 @@ final class ExclusivePositionUpdater implements IPositionUpdater {
@Override
public void update(DocumentEvent event) {
- int eventOffset= event.getOffset();
- int eventOldLength= event.getLength();
- int eventNewLength= event.getText() == null ? 0 : event.getText().length();
- int deltaLength= eventNewLength - eventOldLength;
+ int eventOffset = event.getOffset();
+ int eventOldLength = event.getLength();
+ int eventNewLength = event.getText() == null ? 0 : event.getText().length();
+ int deltaLength = eventNewLength - eventOldLength;
try {
- Position[] positions= event.getDocument().getPositions(fCategory);
+ Position[] positions = event.getDocument().getPositions(fCategory);
- for (int i= 0; i != positions.length; i++) {
+ for (int i = 0; i != positions.length; i++) {
- Position position= positions[i];
+ Position position = positions[i];
if (position.isDeleted())
continue;
- int offset= position.getOffset();
- int length= position.getLength();
- int end= offset + length;
+ int offset = position.getOffset();
+ int length = position.getLength();
+ int end = offset + length;
if (offset >= eventOffset + eventOldLength)
// position comes
@@ -73,13 +73,13 @@ final class ExclusivePositionUpdater implements IPositionUpdater {
position.setLength(length + deltaLength);
} else if (offset < eventOffset) {
// event extends over end of position - adjust length
- int newEnd= eventOffset;
+ int newEnd = eventOffset;
position.setLength(newEnd - offset);
} else if (end > eventOffset + eventOldLength) {
// event extends from before position into it - adjust offset
// and length
// offset becomes end of event, length adjusted accordingly
- int newOffset= eventOffset + eventNewLength;
+ int newOffset = eventOffset + eventNewLength;
position.setOffset(newOffset);
position.setLength(end - newOffset + deltaLength);
} else {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.java
index 2447230ebcf..e2a3bb56e21 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.java
@@ -43,7 +43,7 @@ public class FileTemplateContext extends TemplateContext {
public FileTemplateContext(String contextTypeId, String lineDelimiter) {
super(CUIPlugin.getDefault().getCodeTemplateContextRegistry().getContextType(contextTypeId));
- fLineDelimiter= lineDelimiter;
+ fLineDelimiter = lineDelimiter;
}
/*
@@ -52,9 +52,9 @@ public class FileTemplateContext extends TemplateContext {
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
// test that all variables are defined
- Iterator<?> iterator= getContextType().resolvers();
+ Iterator<?> iterator = getContextType().resolvers();
while (iterator.hasNext()) {
- TemplateVariableResolver var= (TemplateVariableResolver) iterator.next();
+ TemplateVariableResolver var = (TemplateVariableResolver) iterator.next();
if (var.getClass() == FileTemplateContextType.FileTemplateVariableResolver.class) {
Assert.isNotNull(getVariable(var.getType()), "Variable " + var.getType() + " not defined"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -62,31 +62,31 @@ public class FileTemplateContext extends TemplateContext {
if (!canEvaluate(template))
return null;
-
- String pattern= changeLineDelimiter(template.getPattern(), fLineDelimiter);
-
- TemplateTranslator translator= new TemplateTranslator();
- TemplateBuffer buffer= translator.translate(pattern);
+
+ String pattern = changeLineDelimiter(template.getPattern(), fLineDelimiter);
+
+ TemplateTranslator translator = new TemplateTranslator();
+ TemplateBuffer buffer = translator.translate(pattern);
getContextType().resolve(buffer, this);
return buffer;
}
-
+
private static String changeLineDelimiter(String code, String lineDelim) {
try {
- ILineTracker tracker= new DefaultLineTracker();
+ ILineTracker tracker = new DefaultLineTracker();
tracker.set(code);
- int nLines= tracker.getNumberOfLines();
+ int nLines = tracker.getNumberOfLines();
if (nLines == 1) {
return code;
}
-
- StringBuilder buf= new StringBuilder();
- for (int i= 0; i < nLines; i++) {
+
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < nLines; i++) {
if (i != 0) {
buf.append(lineDelim);
}
IRegion region = tracker.getLineInformation(i);
- String line= code.substring(region.getOffset(), region.getOffset() + region.getLength());
+ String line = code.substring(region.getOffset(), region.getOffset() + region.getLength());
buf.append(line);
}
return buf.toString();
@@ -94,7 +94,7 @@ public class FileTemplateContext extends TemplateContext {
// can not happen
return code;
}
- }
+ }
/*
* @see org.eclipse.jface.text.templates.TemplateContext#canEvaluate(org.eclipse.jface.text.templates.Template)
@@ -103,11 +103,11 @@ public class FileTemplateContext extends TemplateContext {
public boolean canEvaluate(Template template) {
return true;
}
-
+
public void setResourceVariables(IFile file) {
setVariable(FileTemplateContextType.FILENAME, file.getName());
setVariable(FileTemplateContextType.FILEBASE, new Path(file.getName()).removeFileExtension().lastSegment());
- IPath location= file.getLocation();
+ IPath location = file.getLocation();
setVariable(FileTemplateContextType.FILELOCATION, location != null ? location.toOSString() : ""); //$NON-NLS-1$
setVariable(FileTemplateContextType.FILEPATH, file.getFullPath().toString());
setVariable(FileTemplateContextType.PROJECTNAME, file.getProject().getName());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContextType.java
index 5a035a9959a..e635be1a7f5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContextType.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContextType.java
@@ -42,17 +42,17 @@ import org.eclipse.cdt.internal.corext.util.Messages;
* @since 5.0
*/
public class FileTemplateContextType extends TemplateContextType {
- public static final String CONTEXTTYPE_SUFFIX= ".contenttype_context"; //$NON-NLS-1$
+ public static final String CONTEXTTYPE_SUFFIX = ".contenttype_context"; //$NON-NLS-1$
- public static final String CONTENTTYPE_TEXT= "org.eclipse.core.runtime.text"; //$NON-NLS-1$
- public static final String TEXTFILE_CONTEXTTYPE= CONTENTTYPE_TEXT + CONTEXTTYPE_SUFFIX;
+ public static final String CONTENTTYPE_TEXT = "org.eclipse.core.runtime.text"; //$NON-NLS-1$
+ public static final String TEXTFILE_CONTEXTTYPE = CONTENTTYPE_TEXT + CONTEXTTYPE_SUFFIX;
/* resolver types */
- public static final String FILENAME= "file_name"; //$NON-NLS-1$
- public static final String FILEBASE= "file_base"; //$NON-NLS-1$
- public static final String FILELOCATION= "file_loc"; //$NON-NLS-1$
- public static final String FILEPATH= "file_path"; //$NON-NLS-1$
- public static final String PROJECTNAME= "project_name"; //$NON-NLS-1$
+ public static final String FILENAME = "file_name"; //$NON-NLS-1$
+ public static final String FILEBASE = "file_base"; //$NON-NLS-1$
+ public static final String FILELOCATION = "file_loc"; //$NON-NLS-1$
+ public static final String FILEPATH = "file_path"; //$NON-NLS-1$
+ public static final String PROJECTNAME = "project_name"; //$NON-NLS-1$
/**
* Resolver that resolves to the variable defined in the context.
@@ -61,10 +61,10 @@ public class FileTemplateContextType extends TemplateContextType {
public FileTemplateVariableResolver(String type, String description) {
super(type, description);
}
-
+
@Override
protected String resolve(TemplateContext context) {
- String value= context.getVariable(getType());
+ String value = context.getVariable(getType());
return value != null ? value : ""; //$NON-NLS-1$
}
}
@@ -78,21 +78,21 @@ public class FileTemplateContextType extends TemplateContextType {
public DateVariableResolver() {
super("date", TemplateMessages.FileTemplateContextType_variable_description_date); //$NON-NLS-1$
}
-
+
/*
* @see org.eclipse.jface.text.templates.TemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateVariable, org.eclipse.jface.text.templates.TemplateContext)
*/
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
- fFormat= null;
- TemplateVariableType type= variable.getVariableType();
- List<?> params= type.getParams();
+ fFormat = null;
+ TemplateVariableType type = variable.getVariableType();
+ List<?> params = type.getParams();
if (params.size() == 1) {
- fFormat= params.get(0).toString();
+ fFormat = params.get(0).toString();
}
super.resolve(variable, context);
}
-
+
/*
* @see org.eclipse.jface.text.templates.SimpleTemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateContext)
*/
@@ -100,9 +100,9 @@ public class FileTemplateContextType extends TemplateContextType {
protected String resolve(TemplateContext context) {
DateFormat f;
if (fFormat == null) {
- f= DateFormat.getDateInstance();
+ f = DateFormat.getDateInstance();
} else {
- f= new SimpleDateFormat(fFormat);
+ f = new SimpleDateFormat(fFormat);
}
return f.format(new java.util.Date());
}
@@ -124,25 +124,25 @@ public class FileTemplateContextType extends TemplateContextType {
*/
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
- fVariableName= variable.getName();
- TemplateVariableType type= variable.getVariableType();
- List<?> params= type.getParams();
- fArguments= params.toArray(new String[params.size()]);
+ fVariableName = variable.getName();
+ TemplateVariableType type = variable.getVariableType();
+ List<?> params = type.getParams();
+ fArguments = params.toArray(new String[params.size()]);
super.resolve(variable, context);
}
-
+
/*
* @see org.eclipse.jface.text.templates.SimpleTemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateContext)
*/
@Override
protected String resolve(TemplateContext context) {
- StringBuilder expr= new StringBuilder("${"); //$NON-NLS-1$
+ StringBuilder expr = new StringBuilder("${"); //$NON-NLS-1$
expr.append(fVariableName);
for (int i = 0; i < fArguments.length; i++) {
expr.append(':').append(fArguments[i]);
}
expr.append('}');
- IStringVariableManager mgr= VariablesPlugin.getDefault().getStringVariableManager();
+ IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
try {
return mgr.performStringSubstitution(expr.toString(), false);
} catch (CoreException exc) {
@@ -165,43 +165,50 @@ public class FileTemplateContextType extends TemplateContextType {
addResolver(new GlobalTemplateVariables.Time());
addResolver(new GlobalTemplateVariables.User());
-// addResolver(new CoreVariableResolver("eclipse")); //$NON-NLS-1$
-
+ // addResolver(new CoreVariableResolver("eclipse")); //$NON-NLS-1$
+
addResourceVariables();
}
-
+
protected void addResourceVariables() {
- addResolver(new FileTemplateVariableResolver(FILENAME, TemplateMessages.FileTemplateContextType_variable_description_filename));
- addResolver(new FileTemplateVariableResolver(FILEBASE, TemplateMessages.FileTemplateContextType_variable_description_filebase));
- addResolver(new FileTemplateVariableResolver(FILELOCATION, TemplateMessages.FileTemplateContextType_variable_description_fileloc));
- addResolver(new FileTemplateVariableResolver(FILEPATH, TemplateMessages.FileTemplateContextType_variable_description_filepath));
- addResolver(new FileTemplateVariableResolver(PROJECTNAME, TemplateMessages.FileTemplateContextType_variable_description_projectname));
+ addResolver(new FileTemplateVariableResolver(FILENAME,
+ TemplateMessages.FileTemplateContextType_variable_description_filename));
+ addResolver(new FileTemplateVariableResolver(FILEBASE,
+ TemplateMessages.FileTemplateContextType_variable_description_filebase));
+ addResolver(new FileTemplateVariableResolver(FILELOCATION,
+ TemplateMessages.FileTemplateContextType_variable_description_fileloc));
+ addResolver(new FileTemplateVariableResolver(FILEPATH,
+ TemplateMessages.FileTemplateContextType_variable_description_filepath));
+ addResolver(new FileTemplateVariableResolver(PROJECTNAME,
+ TemplateMessages.FileTemplateContextType_variable_description_projectname));
}
@Override
protected TemplateVariableResolver getResolver(String type) {
// compatibility with editor template variables
if ("file".equals(type)) { //$NON-NLS-1$
- type= FILENAME;
+ type = FILENAME;
} else if ("project".equals(type) || "enclosing_project".equals(type)) { //$NON-NLS-1$ //$NON-NLS-2$
- type= PROJECTNAME;
+ type = PROJECTNAME;
}
return super.getResolver(type);
}
@Override
protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
- ArrayList<String> required= new ArrayList<String>(5);
- for (int i= 0; i < variables.length; i++) {
- String type= variables[i].getType();
+ ArrayList<String> required = new ArrayList<String>(5);
+ for (int i = 0; i < variables.length; i++) {
+ String type = variables[i].getType();
if (getResolver(type) == null) {
- throw new TemplateException(Messages.format(TemplateMessages.FileTemplateContextType_validate_unknownvariable, type));
+ throw new TemplateException(
+ Messages.format(TemplateMessages.FileTemplateContextType_validate_unknownvariable, type));
}
required.remove(type);
}
if (!required.isEmpty()) {
- String missing= required.get(0);
- throw new TemplateException(Messages.format(TemplateMessages.FileTemplateContextType_validate_missingvariable, missing));
+ String missing = required.get(0);
+ throw new TemplateException(
+ Messages.format(TemplateMessages.FileTemplateContextType_validate_missingvariable, missing));
}
super.validateVariables(variables);
}
@@ -211,21 +218,22 @@ public class FileTemplateContextType extends TemplateContextType {
*/
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
- String type= variable.getType();
- TemplateVariableResolver resolver= getResolver(type);
+ String type = variable.getType();
+ TemplateVariableResolver resolver = getResolver(type);
if (resolver == null) {
- resolver= new FileTemplateVariableResolver(type, ""); //$NON-NLS-1$
+ resolver = new FileTemplateVariableResolver(type, ""); //$NON-NLS-1$
}
resolver.resolve(variable, context);
}
public static void registerContextTypes(ContextTypeRegistry registry) {
- IContentTypeManager contentTypeMgr= Platform.getContentTypeManager();
- IContentType[] contentTypes= contentTypeMgr.getAllContentTypes();
+ IContentTypeManager contentTypeMgr = Platform.getContentTypeManager();
+ IContentType[] contentTypes = contentTypeMgr.getAllContentTypes();
for (int i = 0; i < contentTypes.length; i++) {
IContentType contentType = contentTypes[i];
- if (isTextContentType(contentType) && contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC).length > 0) {
- final String contextTypeId= contextTypeIdForContentType(contentType);
+ if (isTextContentType(contentType)
+ && contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC).length > 0) {
+ final String contextTypeId = contextTypeIdForContentType(contentType);
if (registry.getContextType(contextTypeId) == null) {
registry.addContextType(new FileTemplateContextType(contextTypeId, contentType.getName()));
}
@@ -253,7 +261,7 @@ public class FileTemplateContextType extends TemplateContextType {
if (contentType == null) {
return false;
}
- String id= contentType.getId();
+ String id = contentType.getId();
if (id.equals(CONTENTTYPE_TEXT)) {
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java
index 2669175c514..398740b1506 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java
@@ -26,7 +26,7 @@ public final class TemplateMessages extends NLS {
public static String CContextType_variable_description_enclosing_method_arguments;
public static String CContextType_variable_description_return_type;
public static String CContextType_variable_description_todo;
-
+
public static String CodeTemplateContextType_variable_description_todo;
public static String CodeTemplateContextType_variable_description_typedeclaration;
public static String CodeTemplateContextType_variable_description_class_members;
@@ -52,7 +52,7 @@ public final class TemplateMessages extends NLS {
public static String CodeTemplateContextType_cppsource_name;
public static String CodeTemplateContextType_cppheader_name;
public static String CodeTemplateContextType_asmsource_name;
-
+
public static String FileTemplateContextType__variable_description_eclipse;
public static String FileTemplateContextType_validate_unknownvariable;
public static String FileTemplateContextType_validate_missingvariable;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContext.java
index 9742fbf4296..7bca9dee004 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContext.java
@@ -46,7 +46,7 @@ public abstract class TranslationUnitContext extends DocumentTemplateContext {
/**
* Creates a translation unit context.
- *
+ *
* @param type the context type
* @param document the document
* @param completionOffset the completion position within the document
@@ -56,25 +56,25 @@ public abstract class TranslationUnitContext extends DocumentTemplateContext {
protected TranslationUnitContext(TemplateContextType type, IDocument document, int completionOffset,
int completionLength, ITranslationUnit translationUnit) {
super(type, document, completionOffset, completionLength);
- fTranslationUnit= translationUnit;
- fIsManaged= false;
+ fTranslationUnit = translationUnit;
+ fIsManaged = false;
}
-
+
/**
* Creates a translation unit context.
- *
+ *
* @param type the context type
* @param document the document
* @param completionPosition the completion position within the document
* @param translationUnit the translation unit represented by the document
*/
- protected TranslationUnitContext(TemplateContextType type, IDocument document,
- Position completionPosition, ITranslationUnit translationUnit) {
+ protected TranslationUnitContext(TemplateContextType type, IDocument document, Position completionPosition,
+ ITranslationUnit translationUnit) {
super(type, document, completionPosition);
- fTranslationUnit= translationUnit;
- fIsManaged= true;
+ fTranslationUnit = translationUnit;
+ fIsManaged = true;
}
-
+
/*
* @see org.eclipse.jface.text.templates.DocumentTemplateContext#canEvaluate(org.eclipse.jface.text.templates.Template)
*/
@@ -82,36 +82,32 @@ public abstract class TranslationUnitContext extends DocumentTemplateContext {
public boolean canEvaluate(Template template) {
if (fForceEvaluation)
return true;
-
- String key= getKey();
- return template.matches(key, getContextType().getId())
- && key.length() != 0 && template.getName().startsWith(key);
- }
-
+ String key = getKey();
+ return template.matches(key, getContextType().getId()) && key.length() != 0
+ && template.getName().startsWith(key);
+ }
/*
* @see org.eclipse.cdt.internal.corext.template.DocumentTemplateContext#getKey()
*/
@Override
public String getKey() {
- if (getCompletionLength() == 0)
+ if (getCompletionLength() == 0)
return super.getKey();
try {
- IDocument document= getDocument();
+ IDocument document = getDocument();
- int start= getStart();
- int end= getCompletionOffset();
- return start <= end
- ? document.get(start, end - start)
- : ""; //$NON-NLS-1$
+ int start = getStart();
+ int end = getCompletionOffset();
+ return start <= end ? document.get(start, end - start) : ""; //$NON-NLS-1$
} catch (BadLocationException e) {
- return super.getKey();
+ return super.getKey();
}
}
-
+
/**
* Returns the translation unit if one is associated with this context, <code>null</code> otherwise.
*/
@@ -128,10 +124,10 @@ public abstract class TranslationUnitContext extends DocumentTemplateContext {
return null;
try {
- ICElement element= fTranslationUnit.getElementAtOffset(getStart());
+ ICElement element = fTranslationUnit.getElementAtOffset(getStart());
while (element != null && element.getElementType() != elementType)
- element= element.getParent();
-
+ element = element.getParent();
+
return element;
} catch (CModelException e) {
@@ -141,40 +137,39 @@ public abstract class TranslationUnitContext extends DocumentTemplateContext {
/**
* Sets whether evaluation is forced or not.
- *
+ *
* @param evaluate <code>true</code> in order to force evaluation,
* <code>false</code> otherwise
*/
public void setForceEvaluation(boolean evaluate) {
- fForceEvaluation= evaluate;
+ fForceEvaluation = evaluate;
}
-
+
/**
* Get the associated <code>ICProject</code>.
* @return the associated <code>ICProject</code> or <code>null</code>
*/
protected ICProject getCProject() {
- ITranslationUnit translationUnit= getTranslationUnit();
- ICProject project= translationUnit == null ? null : translationUnit.getCProject();
+ ITranslationUnit translationUnit = getTranslationUnit();
+ ICProject project = translationUnit == null ? null : translationUnit.getCProject();
return project;
- }
+ }
/**
* Get the indentation level at the position of code completion.
* @return the indentation level at the position of code completion
*/
protected int getIndentationLevel() {
- int start= getStart();
- IDocument document= getDocument();
+ int start = getStart();
+ IDocument document = getDocument();
try {
- IRegion region= document.getLineInformationOfOffset(start);
- String lineContent= document.get(region.getOffset(), region.getLength());
- ICProject project= getCProject();
- return Strings.computeIndentUnits(lineContent, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
+ IRegion region = document.getLineInformationOfOffset(start);
+ String lineContent = document.get(region.getOffset(), region.getLength());
+ ICProject project = getCProject();
+ return Strings.computeIndentUnits(lineContent, CodeFormatterUtil.getTabWidth(project),
+ CodeFormatterUtil.getIndentWidth(project));
} catch (BadLocationException e) {
return 0;
}
- }
+ }
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContextType.java
index b481c79d11b..7dcd913ca82 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContextType.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContextType.java
@@ -31,21 +31,21 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
-
/**
* A context type for translation units.
*/
public abstract class TranslationUnitContextType extends TemplateContextType {
protected static class ReturnType extends TemplateVariableResolver {
- public ReturnType() {
- super("return_type", TemplateMessages.CContextType_variable_description_return_type); //$NON-NLS-1$
- }
- @Override
+ public ReturnType() {
+ super("return_type", TemplateMessages.CContextType_variable_description_return_type); //$NON-NLS-1$
+ }
+
+ @Override
public String resolve(TemplateContext context) {
- ICElement element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
+ ICElement element = ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
if (element == null) {
- element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
+ element = ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
}
if (element == null) {
return null;
@@ -60,53 +60,58 @@ public abstract class TranslationUnitContextType extends TemplateContextType {
protected static class File extends TemplateVariableResolver {
public File() {
- super("file", TemplateMessages.CContextType_variable_description_file); //$NON-NLS-1$
+ super("file", TemplateMessages.CContextType_variable_description_file); //$NON-NLS-1$
}
+
@Override
public String resolve(TemplateContext context) {
- ITranslationUnit unit= ((TranslationUnitContext) context).getTranslationUnit();
+ ITranslationUnit unit = ((TranslationUnitContext) context).getTranslationUnit();
return (unit == null) ? null : unit.getElementName();
}
}
protected static class FileBase extends TemplateVariableResolver {
public FileBase() {
- super("file_base", TemplateMessages.CContextType_variable_description_file_base); //$NON-NLS-1$
+ super("file_base", TemplateMessages.CContextType_variable_description_file_base); //$NON-NLS-1$
}
+
@Override
public String resolve(TemplateContext context) {
- ITranslationUnit unit= ((TranslationUnitContext) context).getTranslationUnit();
+ ITranslationUnit unit = ((TranslationUnitContext) context).getTranslationUnit();
return (unit == null) ? null : new Path(unit.getElementName()).removeFileExtension().lastSegment();
}
}
protected static class EnclosingCElement extends TemplateVariableResolver {
protected final int fElementType;
-
+
public EnclosingCElement(String name, String description, int elementType) {
super(name, description);
- fElementType= elementType;
+ fElementType = elementType;
}
+
@Override
public String resolve(TemplateContext context) {
- ICElement element= ((TranslationUnitContext) context).findEnclosingElement(fElementType);
+ ICElement element = ((TranslationUnitContext) context).findEnclosingElement(fElementType);
return (element == null) ? null : element.getElementName();
}
}
-
+
protected static class Method extends TemplateVariableResolver {
public Method() {
- super("enclosing_method", TemplateMessages.CContextType_variable_description_enclosing_method); //$NON-NLS-1$
+ super("enclosing_method", TemplateMessages.CContextType_variable_description_enclosing_method); //$NON-NLS-1$
}
+
@Override
public String resolve(TemplateContext context) {
- ICElement element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
+ ICElement element = ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
if (element == null) {
- element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION_DECLARATION);
+ element = ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION_DECLARATION);
if (element == null) {
- element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
+ element = ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
if (element == null) {
- element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD_DECLARATION);
+ element = ((TranslationUnitContext) context)
+ .findEnclosingElement(ICElement.C_METHOD_DECLARATION);
}
}
}
@@ -120,42 +125,46 @@ public abstract class TranslationUnitContextType extends TemplateContextType {
protected static class Project extends TemplateVariableResolver {
public Project() {
- super("enclosing_project", TemplateMessages.CContextType_variable_description_enclosing_project); //$NON-NLS-1$
+ super("enclosing_project", TemplateMessages.CContextType_variable_description_enclosing_project); //$NON-NLS-1$
}
+
@Override
public String resolve(TemplateContext context) {
- ITranslationUnit unit= ((TranslationUnitContext) context).getTranslationUnit();
+ ITranslationUnit unit = ((TranslationUnitContext) context).getTranslationUnit();
return (unit == null) ? null : unit.getCProject().getElementName();
}
- }
+ }
protected static class Arguments extends TemplateVariableResolver {
public Arguments() {
- super("enclosing_method_arguments", TemplateMessages.CContextType_variable_description_enclosing_method_arguments); //$NON-NLS-1$
+ super("enclosing_method_arguments", //$NON-NLS-1$
+ TemplateMessages.CContextType_variable_description_enclosing_method_arguments);
}
+
@Override
public String resolve(TemplateContext context) {
- ICElement element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
+ ICElement element = ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
if (element == null) {
- element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION_DECLARATION);
+ element = ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION_DECLARATION);
if (element == null) {
- element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
+ element = ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
if (element == null) {
- element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD_DECLARATION);
+ element = ((TranslationUnitContext) context)
+ .findEnclosingElement(ICElement.C_METHOD_DECLARATION);
}
}
}
if (element instanceof IFunctionDeclaration) {
- String[] arguments= ((IFunctionDeclaration)element).getParameterTypes();
- StringBuilder buffer= new StringBuilder();
-
- for (int i= 0; i < arguments.length; i++) {
+ String[] arguments = ((IFunctionDeclaration) element).getParameterTypes();
+ StringBuilder buffer = new StringBuilder();
+
+ for (int i = 0; i < arguments.length; i++) {
if (i > 0)
buffer.append(", "); //$NON-NLS-1$
- buffer.append(arguments[i]);
+ buffer.append(arguments[i]);
}
-
+
return buffer.toString();
}
return null;
@@ -165,29 +174,30 @@ public abstract class TranslationUnitContextType extends TemplateContextType {
protected static class Todo extends TemplateVariableResolver {
public Todo() {
- super("todo", TemplateMessages.CContextType_variable_description_todo); //$NON-NLS-1$
+ super("todo", TemplateMessages.CContextType_variable_description_todo); //$NON-NLS-1$
}
+
@Override
protected String resolve(TemplateContext context) {
- TranslationUnitContext cContext= (TranslationUnitContext) context;
- ITranslationUnit tUnit= cContext.getTranslationUnit();
+ TranslationUnitContext cContext = (TranslationUnitContext) context;
+ ITranslationUnit tUnit = cContext.getTranslationUnit();
if (tUnit == null)
return "XXX"; //$NON-NLS-1$
-
- ICProject cProject= tUnit.getCProject();
- String todoTaskTag= StubUtility.getTodoTaskTag(cProject);
+
+ ICProject cProject = tUnit.getCProject();
+ String todoTaskTag = StubUtility.getTodoTaskTag(cProject);
if (todoTaskTag == null)
return "XXX"; //$NON-NLS-1$
return todoTaskTag;
}
- }
+ }
/*
* @see TemplateContextType#TemplateContextType()
*/
public TranslationUnitContextType() {
- super();
+ super();
// global
addResolver(new GlobalTemplateVariables.Cursor());
addResolver(new GlobalTemplateVariables.WordSelection());
@@ -197,7 +207,7 @@ public abstract class TranslationUnitContextType extends TemplateContextType {
addResolver(new GlobalTemplateVariables.Year());
addResolver(new GlobalTemplateVariables.Time());
addResolver(new GlobalTemplateVariables.User());
-
+
// translation unit
addResolver(new File());
addResolver(new FileBase());
@@ -208,6 +218,9 @@ public abstract class TranslationUnitContextType extends TemplateContextType {
addResolver(new Todo());
}
- public abstract TranslationUnitContext createContext(IDocument document, int offset, int length, ITranslationUnit translationUnit);
- public abstract TranslationUnitContext createContext(IDocument document, Position position, ITranslationUnit translationUnit);
+ public abstract TranslationUnitContext createContext(IDocument document, int offset, int length,
+ ITranslationUnit translationUnit);
+
+ public abstract TranslationUnitContext createContext(IDocument document, Position position,
+ ITranslationUnit translationUnit);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CModelUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CModelUtil.java
index 6b225dbbf6c..60b6e71acd6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CModelUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CModelUtil.java
@@ -36,7 +36,7 @@ public class CModelUtil {
*/
public static ITranslationUnit toWorkingCopy(ITranslationUnit unit) {
if (!unit.isWorkingCopy()) {
- ITranslationUnit workingCopy= EditorUtility.getWorkingCopy(unit);
+ ITranslationUnit workingCopy = EditorUtility.getWorkingCopy(unit);
if (workingCopy != null) {
return workingCopy;
}
@@ -59,7 +59,7 @@ public class CModelUtil {
ICElement root = element;
while (root != null) {
if (root instanceof ISourceRoot)
- return (ISourceRoot)root;
+ return (ISourceRoot) root;
ICElement parent = root.getAncestor(ICElement.C_CCONTAINER);
if (parent == root)
return null;
@@ -79,9 +79,9 @@ public class CModelUtil {
while (curr != null && !(curr instanceof ISourceRoot)) {
curr = curr.getParent();
}
- folder = (ISourceRoot)curr;
+ folder = (ISourceRoot) curr;
if (folder == null) {
- ICProject cproject = element.getCProject();
+ ICProject cproject = element.getCProject();
folder = cproject.findSourceRoot(cproject.getProject());
}
}
@@ -95,10 +95,10 @@ public class CModelUtil {
* doesn't have an underlying resource.
*/
public static boolean isReferenced(ISourceRoot root) {
- IResource resource= root.getResource();
+ IResource resource = root.getResource();
if (resource != null) {
- IProject project= resource.getProject();
- IProject container= root.getCProject().getProject();
+ IProject project = resource.getProject();
+ IProject container = root.getCProject().getProject();
return !container.equals(project);
}
return false;
@@ -112,18 +112,18 @@ public class CModelUtil {
if (elem instanceof ITranslationUnit) {
return (ITranslationUnit) elem;
}
- elem= elem.getParent();
+ elem = elem.getParent();
}
return null;
}
/*
- * Don't log not-exists exceptions
+ * Don't log not-exists exceptions
*/
public static boolean isExceptionToBeLogged(CoreException exception) {
if (!(exception instanceof CModelException))
return true;
- CModelException ce= (CModelException)exception;
+ CModelException ce = (CModelException) exception;
ICModelStatus status = ce.getCModelStatus();
if (status == null || !status.doesNotExist())
return true;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
index e070975c31c..86521e02c79 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
@@ -35,7 +35,7 @@ public class CodeFormatterUtil {
* @return the indent string
*/
public static String createIndentString(int indentationUnits, ICProject project) {
- Map<String, String> options= project != null ? project.getOptions(true) : CCorePlugin.getOptions();
+ Map<String, String> options = project != null ? project.getOptions(true) : CCorePlugin.getOptions();
return ToolFactory.createDefaultCodeFormatter(options).createIndentationString(indentationUnits);
}
@@ -56,9 +56,9 @@ public class CodeFormatterUtil {
*/
String key;
if (CCorePlugin.SPACE.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR))) {
- key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+ key = DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
} else {
- key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
+ key = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
}
return getCoreOption(project, key, 4);
@@ -73,10 +73,11 @@ public class CodeFormatterUtil {
*/
public static int getIndentWidth(ICProject project) {
String key;
- if (DefaultCodeFormatterConstants.MIXED.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR))) {
- key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+ if (DefaultCodeFormatterConstants.MIXED
+ .equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR))) {
+ key = DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
} else {
- key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
+ key = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
}
return getCoreOption(project, key, 4);
@@ -122,7 +123,7 @@ public class CodeFormatterUtil {
String lineSeparator, Map<String, ?> options) {
if (offset < 0 || length < 0 || offset + length > source.length()) {
throw new IllegalArgumentException("offset or length outside of string. offset: " + //$NON-NLS-1$
- offset + ", length: " + length + ", string size: " + source.length()); //$NON-NLS-1$//$NON-NLS-2$
+ offset + ", length: " + length + ", string size: " + source.length()); //$NON-NLS-1$//$NON-NLS-2$
}
CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
return formatter.format(kind, source, offset, length, indentationLevel, lineSeparator);
@@ -130,27 +131,27 @@ public class CodeFormatterUtil {
public static TextEdit format(int kind, String source, int indentationLevel, String lineSeparator,
Map<String, ?> options) {
- String prefix= ""; //$NON-NLS-1$
- String suffix= ""; //$NON-NLS-1$
+ String prefix = ""; //$NON-NLS-1$
+ String suffix = ""; //$NON-NLS-1$
switch (kind) {
case CodeFormatter.K_EXPRESSION:
- prefix= "int __dummy__="; //$NON-NLS-1$
- suffix= ";"; //$NON-NLS-1$
+ prefix = "int __dummy__="; //$NON-NLS-1$
+ suffix = ";"; //$NON-NLS-1$
break;
case CodeFormatter.K_STATEMENTS:
- prefix= "void __dummy__() {"; //$NON-NLS-1$
- suffix= "}"; //$NON-NLS-1$
+ prefix = "void __dummy__() {"; //$NON-NLS-1$
+ suffix = "}"; //$NON-NLS-1$
--indentationLevel;
break;
}
- String tuSource= prefix + source + suffix;
+ String tuSource = prefix + source + suffix;
return format(tuSource, prefix.length(), source.length(), indentationLevel, lineSeparator, options);
}
- private static TextEdit format(String source, int offset, int length, int indentationLevel,
- String lineSeparator, Map<String, ?> options) {
- TextEdit edit= format(CodeFormatter.K_TRANSLATION_UNIT, source, offset, length,
- indentationLevel, lineSeparator, options);
+ private static TextEdit format(String source, int offset, int length, int indentationLevel, String lineSeparator,
+ Map<String, ?> options) {
+ TextEdit edit = format(CodeFormatter.K_TRANSLATION_UNIT, source, offset, length, indentationLevel,
+ lineSeparator, options);
if (edit != null && offset > 0) {
edit.moveTree(-offset);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Messages.java
index c8ecb8d8b2a..0b9703cc630 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Messages.java
@@ -17,7 +17,7 @@ import com.ibm.icu.text.MessageFormat;
/**
* Helper class to format message strings.
- *
+ *
* @since 3.1
*/
public class Messages {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Resources.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Resources.java
index 61c8c1a02c4..c88b797fad9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Resources.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Resources.java
@@ -41,143 +41,135 @@ public class Resources {
/**
* Checks if the given resource is in sync with the underlying file system.
- *
+ *
* @param resource the resource to be checked
* @return IStatus status describing the check's result. If <code>status.
* isOK()</code> returns <code>true</code> then the resource is in sync
*/
public static IStatus checkInSync(IResource resource) {
- return checkInSync(new IResource[] {resource});
+ return checkInSync(new IResource[] { resource });
}
-
+
/**
* Checks if the given resources are in sync with the underlying file
* system.
- *
+ *
* @param resources the resources to be checked
* @return IStatus status describing the check's result. If <code>status.
* isOK() </code> returns <code>true</code> then the resources are in sync
*/
public static IStatus checkInSync(IResource[] resources) {
- IStatus result= null;
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ IStatus result = null;
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
- result= addOutOfSync(result, resource);
- }
+ result = addOutOfSync(result, resource);
+ }
}
if (result != null)
return result;
- return new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+ return new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
}
/**
* Makes the given resource committable. Committable means that it is
* writeable and that its content hasn't changed by calling
* <code>validateEdit</code> for the given resource on <tt>IWorkspace</tt>.
- *
+ *
* @param resource the resource to be checked
- * @param context the context passed to <code>validateEdit</code>
+ * @param context the context passed to <code>validateEdit</code>
* @return status describing the method's result. If <code>status.isOK()</code> returns <code>true</code> then the resources are committable.
- *
+ *
* @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
*/
public static IStatus makeCommittable(IResource resource, Object context) {
return makeCommittable(new IResource[] { resource }, context);
}
-
+
/**
* Makes the given resources committable. Committable means that all
* resources are writeable and that the content of the resources hasn't
* changed by calling <code>validateEdit</code> for a given file on
* <tt>IWorkspace</tt>.
- *
+ *
* @param resources the resources to be checked
- * @param context the context passed to <code>validateEdit</code>
+ * @param context the context passed to <code>validateEdit</code>
* @return IStatus status describing the method's result. If <code>status.
* isOK()</code> returns <code>true</code> then the add resources are
* committable
- *
+ *
* @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
*/
public static IStatus makeCommittable(IResource[] resources, Object context) {
- List<IResource> readOnlyFiles= new ArrayList<IResource>();
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ List<IResource> readOnlyFiles = new ArrayList<IResource>();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
if (resource.getType() == IResource.FILE) {
ResourceAttributes attributes = resource.getResourceAttributes();
- if (attributes != null && attributes.isReadOnly()) {
+ if (attributes != null && attributes.isReadOnly()) {
readOnlyFiles.add(resource);
}
}
}
if (readOnlyFiles.size() == 0)
return new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
-
- Map<IFile, Long> oldTimeStamps= createModificationStampMap(readOnlyFiles);
- IStatus status= ResourcesPlugin.getWorkspace().validateEdit(
- readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
+
+ Map<IFile, Long> oldTimeStamps = createModificationStampMap(readOnlyFiles);
+ IStatus status = ResourcesPlugin.getWorkspace()
+ .validateEdit(readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
if (!status.isOK())
return status;
-
- IStatus modified= null;
- Map<IFile, Long> newTimeStamps= createModificationStampMap(readOnlyFiles);
- for (Iterator<IFile> iter= oldTimeStamps.keySet().iterator(); iter.hasNext();) {
- IFile file= iter.next();
+
+ IStatus modified = null;
+ Map<IFile, Long> newTimeStamps = createModificationStampMap(readOnlyFiles);
+ for (Iterator<IFile> iter = oldTimeStamps.keySet().iterator(); iter.hasNext();) {
+ IFile file = iter.next();
if (!oldTimeStamps.get(file).equals(newTimeStamps.get(file)))
- modified= addModified(modified, file);
+ modified = addModified(modified, file);
}
- if (modified != null)
+ if (modified != null)
return modified;
return new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
}
- private static Map<IFile, Long> createModificationStampMap(List<IResource> files){
- Map<IFile, Long> map= new HashMap<IFile, Long>();
- for (Iterator<IResource> iter= files.iterator(); iter.hasNext(); ) {
- IFile file= (IFile)iter.next();
+ private static Map<IFile, Long> createModificationStampMap(List<IResource> files) {
+ Map<IFile, Long> map = new HashMap<IFile, Long>();
+ for (Iterator<IResource> iter = files.iterator(); iter.hasNext();) {
+ IFile file = (IFile) iter.next();
map.put(file, Long.valueOf(file.getModificationStamp()));
}
return map;
}
-
+
private static IStatus addModified(IStatus status, IFile file) {
- IStatus entry= CUIStatus.createError(
- ICStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
- NLS.bind(CorextMessages.Resources_fileModified, file.getFullPath().toString()),
- null);
+ IStatus entry = CUIStatus.createError(ICStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
+ NLS.bind(CorextMessages.Resources_fileModified, file.getFullPath().toString()), null);
if (status == null) {
return entry;
} else if (status.isMultiStatus()) {
- ((MultiStatus)status).add(entry);
+ ((MultiStatus) status).add(entry);
return status;
} else {
- MultiStatus result= new MultiStatus(CUIPlugin.getPluginId(),
- ICStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
- CorextMessages.Resources_modifiedResources, null);
+ MultiStatus result = new MultiStatus(CUIPlugin.getPluginId(),
+ ICStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT, CorextMessages.Resources_modifiedResources, null);
result.add(status);
result.add(entry);
return result;
}
- }
+ }
private static IStatus addOutOfSync(IStatus status, IResource resource) {
- IStatus entry= new Status(
- IStatus.ERROR,
- ResourcesPlugin.getPlugin().getBundle().getSymbolicName(),
- IResourceStatus.OUT_OF_SYNC_LOCAL,
- NLS.bind(CorextMessages.Resources_outOfSync, resource.getFullPath().toString()),
- null);
+ IStatus entry = new Status(IStatus.ERROR, ResourcesPlugin.getPlugin().getBundle().getSymbolicName(),
+ IResourceStatus.OUT_OF_SYNC_LOCAL,
+ NLS.bind(CorextMessages.Resources_outOfSync, resource.getFullPath().toString()), null);
if (status == null) {
return entry;
} else if (status.isMultiStatus()) {
- ((MultiStatus)status).add(entry);
+ ((MultiStatus) status).add(entry);
return status;
} else {
- MultiStatus result= new MultiStatus(
- ResourcesPlugin.getPlugin().getBundle().getSymbolicName(),
- IResourceStatus.OUT_OF_SYNC_LOCAL,
- CorextMessages.Resources_outOfSyncResources, null);
+ MultiStatus result = new MultiStatus(ResourcesPlugin.getPlugin().getBundle().getSymbolicName(),
+ IResourceStatus.OUT_OF_SYNC_LOCAL, CorextMessages.Resources_outOfSyncResources, null);
result.add(status);
result.add(entry);
return result;
@@ -185,9 +177,9 @@ public class Resources {
}
public static String[] getLocationOSStrings(IResource[] resources) {
- List<String> result= new ArrayList<String>(resources.length);
- for (int i= 0; i < resources.length; i++) {
- IPath location= resources[i].getLocation();
+ List<String> result = new ArrayList<String>(resources.length);
+ for (int i = 0; i < resources.length; i++) {
+ IPath location = resources[i].getLocation();
if (location != null)
result.add(location.toOSString());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/SimplePositionTracker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/SimplePositionTracker.java
index ec4cddce003..775075672e6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/SimplePositionTracker.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/SimplePositionTracker.java
@@ -25,8 +25,7 @@ import org.eclipse.cdt.internal.core.PositionTracker;
*
* @since 4.0
*/
-public class SimplePositionTracker extends PositionTracker implements
- IPositionUpdater {
+public class SimplePositionTracker extends PositionTracker implements IPositionUpdater {
private IDocument fDocument;
@@ -35,47 +34,47 @@ public class SimplePositionTracker extends PositionTracker implements
*/
@Override
public void update(DocumentEvent event) {
- String text = event.getText();
- int insertLen = text != null ? text.length() : 0;
- update(event.getOffset(), event.getLength(), insertLen);
- }
+ String text = event.getText();
+ int insertLen = text != null ? text.length() : 0;
+ update(event.getOffset(), event.getLength(), insertLen);
+ }
- private void update(int offset, int deleteLen, int insertLen) {
- if (insertLen > deleteLen) {
- insert(offset + deleteLen, insertLen - deleteLen);
- } else if (insertLen < deleteLen) {
- delete(offset+insertLen, deleteLen - insertLen);
- }
- }
+ private void update(int offset, int deleteLen, int insertLen) {
+ if (insertLen > deleteLen) {
+ insert(offset + deleteLen, insertLen - deleteLen);
+ } else if (insertLen < deleteLen) {
+ delete(offset + insertLen, deleteLen - insertLen);
+ }
+ }
- /**
- * Start tracking on the given document.
- *
- * @param doc
- */
- public synchronized void startTracking(IDocument doc) {
- stopTracking();
- fDocument= doc;
- if (fDocument != null) {
- fDocument.addPositionUpdater(this);
- }
- }
+ /**
+ * Start tracking on the given document.
+ *
+ * @param doc
+ */
+ public synchronized void startTracking(IDocument doc) {
+ stopTracking();
+ fDocument = doc;
+ if (fDocument != null) {
+ fDocument.addPositionUpdater(this);
+ }
+ }
+
+ /**
+ * Stop tracking.
+ */
+ public synchronized void stopTracking() {
+ if (fDocument != null) {
+ fDocument.removePositionUpdater(this);
+ fDocument = null;
+ }
+ }
- /**
- * Stop tracking.
- */
- public synchronized void stopTracking() {
- if (fDocument != null) {
- fDocument.removePositionUpdater(this);
- fDocument= null;
- }
- }
-
- /**
- * Destroy the tracker.
- */
- public void dispose() {
- stopTracking();
- }
+ /**
+ * Destroy the tracker.
+ */
+ public void dispose() {
+ stopTracking();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java
index 202bae2d995..f44a3d92627 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java
@@ -32,8 +32,9 @@ import org.eclipse.cdt.core.model.ICProject;
*/
public class Strings {
- private Strings() {}
-
+ private Strings() {
+ }
+
/**
* Tells whether we have to use the {@link TextProcessor}
* <p>
@@ -42,18 +43,18 @@ public class Strings {
*/
public static final boolean USE_TEXT_PROCESSOR;
static {
- String testString= "args : String[]"; //$NON-NLS-1$
- USE_TEXT_PROCESSOR= testString != TextProcessor.process(testString);
+ String testString = "args : String[]"; //$NON-NLS-1$
+ USE_TEXT_PROCESSOR = testString != TextProcessor.process(testString);
}
- private static final String C_ELEMENT_DELIMITERS= TextProcessor.getDefaultDelimiters() + "<>(),?{} "; //$NON-NLS-1$
+ private static final String C_ELEMENT_DELIMITERS = TextProcessor.getDefaultDelimiters() + "<>(),?{} "; //$NON-NLS-1$
public static boolean startsWithIgnoreCase(CharSequence text, CharSequence prefix) {
- int textLength= text.length();
- int prefixLength= prefix.length();
+ int textLength = text.length();
+ int prefixLength = prefix.length();
if (textLength < prefixLength)
return false;
- for (int i= prefixLength - 1; i >= 0; i--) {
+ for (int i = prefixLength - 1; i >= 0; i--) {
if (Character.toLowerCase(prefix.charAt(i)) != Character.toLowerCase(text.charAt(i)))
return false;
}
@@ -72,22 +73,22 @@ public class Strings {
}
public static String removeNewLine(String message) {
- StringBuilder result= new StringBuilder();
- int current= 0;
- int index= message.indexOf('\n', 0);
+ StringBuilder result = new StringBuilder();
+ int current = 0;
+ int index = message.indexOf('\n', 0);
while (index != -1) {
result.append(message.substring(current, index));
if (current < index && index != 0)
result.append(' ');
- current= index + 1;
- index= message.indexOf('\n', current);
+ current = index + 1;
+ index = message.indexOf('\n', current);
}
result.append(message.substring(current));
return result.toString();
}
/**
- * Converts the given string into an array of lines. The lines
+ * Converts the given string into an array of lines. The lines
* don't contain any line delimiter characters.
*
* @return the string converted into an array of strings. Returns <code>
@@ -95,14 +96,14 @@ public class Strings {
*/
public static String[] convertIntoLines(String input) {
try {
- ILineTracker tracker= new DefaultLineTracker();
+ ILineTracker tracker = new DefaultLineTracker();
tracker.set(input);
- int size= tracker.getNumberOfLines();
- String result[]= new String[size];
- for (int i= 0; i < size; i++) {
- IRegion region= tracker.getLineInformation(i);
- int offset= region.getOffset();
- result[i]= input.substring(offset, offset + region.getLength());
+ int size = tracker.getNumberOfLines();
+ String result[] = new String[size];
+ for (int i = 0; i < size; i++) {
+ IRegion region = tracker.getLineInformation(i);
+ int offset = region.getOffset();
+ result[i] = input.substring(offset, offset + region.getLength());
}
return result;
} catch (BadLocationException e) {
@@ -114,33 +115,33 @@ public class Strings {
* Returns <code>true</code> if the given string only consists of
* white spaces according to C. If the string is empty, <code>true
* </code> is returned.
- *
+ *
* @return <code>true</code> if the string only consists of white
* spaces; otherwise <code>false</code> is returned
- *
+ *
* @see java.lang.Character#isWhitespace(char)
*/
public static boolean containsOnlyWhitespaces(String s) {
- int size= s.length();
- for (int i= 0; i < size; i++) {
+ int size = s.length();
+ for (int i = 0; i < size; i++) {
if (!Character.isWhitespace(s.charAt(i)))
return false;
}
return true;
}
-
+
/**
* Removes leading tabs and spaces from the given string. If the string
- * doesn't contain any leading tabs or spaces then the string itself is
+ * doesn't contain any leading tabs or spaces then the string itself is
* returned.
*/
public static String trimLeadingTabsAndSpaces(String line) {
- int size= line.length();
- int start= size;
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
+ int size = line.length();
+ int start = size;
+ for (int i = 0; i < size; i++) {
+ char c = line.charAt(i);
if (!IndentManipulation.isIndentChar(c)) {
- start= i;
+ start = i;
break;
}
}
@@ -151,14 +152,14 @@ public class Strings {
else
return line.substring(start);
}
-
+
public static String trimTrailingTabsAndSpaces(String line) {
- int size= line.length();
- int end= size;
- for (int i= size - 1; i >= 0; i--) {
- char c= line.charAt(i);
+ int size = line.length();
+ int end = size;
+ for (int i = size - 1; i >= 0; i--) {
+ char c = line.charAt(i);
if (IndentManipulation.isIndentChar(c)) {
- end= i;
+ end = i;
} else {
break;
}
@@ -170,24 +171,25 @@ public class Strings {
else
return line.substring(0, end);
}
-
+
/**
* Returns the indent of the given string in indentation units. Odd spaces
* are not counted.
- *
+ *
* @param line the text line
* @param project the project from which to get the formatter
* preferences, or <code>null</code> for global preferences
* @since 5.0
*/
public static int computeIndentUnits(String line, ICProject project) {
- return IndentManipulation.measureIndentUnits(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
+ return IndentManipulation.measureIndentUnits(line, CodeFormatterUtil.getTabWidth(project),
+ CodeFormatterUtil.getIndentWidth(project));
}
-
+
/**
* Returns the indent of the given string in indentation units. Odd spaces
* are not counted.
- *
+ *
* @param line the text line
* @param tabWidth the width of the '\t' character in space equivalents
* @param indentWidth the width of one indentation unit in space equivalents
@@ -196,12 +198,12 @@ public class Strings {
public static int computeIndentUnits(String line, int tabWidth, int indentWidth) {
return IndentManipulation.measureIndentUnits(line, tabWidth, indentWidth);
}
-
+
/**
* Computes the visual length of the indentation of a
* <code>CharSequence</code>, counting a tab character as the size until
* the next tab stop and every other whitespace character as one.
- *
+ *
* @param line the string to measure the indent of
* @param tabSize the visual size of a tab in space equivalents
* @return the visual length of the indentation of <code>line</code>
@@ -212,29 +214,30 @@ public class Strings {
}
/**
- * Removes the given number of indents from the line. Asserts that the given line
+ * Removes the given number of indents from the line. Asserts that the given line
* has the requested number of indents. If <code>indentsToRemove <= 0</code>
* the line is returned.
- *
+ *
* @param project the project from which to get the formatter
* preferences, or <code>null</code> for global preferences
* @since 5.0
*/
public static String trimIndent(String line, int indentsToRemove, ICProject project) {
- return IndentManipulation.trimIndent(line, indentsToRemove, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
+ return IndentManipulation.trimIndent(line, indentsToRemove, CodeFormatterUtil.getTabWidth(project),
+ CodeFormatterUtil.getIndentWidth(project));
}
-
+
/**
- * Removes the given number of indents from the line. Asserts that the given line
+ * Removes the given number of indents from the line. Asserts that the given line
* has the requested number of indents. If <code>indentsToRemove <= 0</code>
* the line is returned.
- *
+ *
* @since 5.0
*/
public static String trimIndent(String line, int indentsToRemove, int tabWidth, int indentWidth) {
return IndentManipulation.trimIndent(line, indentsToRemove, tabWidth, indentWidth);
}
-
+
/**
* Removes the common number of indents from all lines. If a line
* only consists out of white space it is ignored.
@@ -246,29 +249,31 @@ public class Strings {
public static void trimIndentation(String[] lines, ICProject project) {
trimIndentation(lines, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), true);
}
+
/**
* Removes the common number of indents from all lines. If a line
* only consists out of white space it is ignored.
- *
+ *
* @since 5.0
*/
public static void trimIndentation(String[] lines, int tabWidth, int indentWidth) {
trimIndentation(lines, tabWidth, indentWidth, true);
}
-
+
/**
* Removes the common number of indents from all lines. If a line
* only consists out of white space it is ignored. If <code>
* considerFirstLine</code> is false the first line will be ignored.
- *
+ *
* @param project the project from which to get the formatter
* preferences, or <code>null</code> for global preferences
* @since 5.0
*/
public static void trimIndentation(String[] lines, ICProject project, boolean considerFirstLine) {
- trimIndentation(lines, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), considerFirstLine);
+ trimIndentation(lines, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project),
+ considerFirstLine);
}
-
+
/**
* Removes the common number of indents from all lines. If a line
* only consists out of white space it is ignored. If <code>
@@ -276,42 +281,42 @@ public class Strings {
* @since 5.0
*/
public static void trimIndentation(String[] lines, int tabWidth, int indentWidth, boolean considerFirstLine) {
- String[] toDo= new String[lines.length];
+ String[] toDo = new String[lines.length];
// find indentation common to all lines
- int minIndent= Integer.MAX_VALUE; // very large
- for (int i= considerFirstLine ? 0 : 1; i < lines.length; i++) {
- String line= lines[i];
+ int minIndent = Integer.MAX_VALUE; // very large
+ for (int i = considerFirstLine ? 0 : 1; i < lines.length; i++) {
+ String line = lines[i];
if (containsOnlyWhitespaces(line))
continue;
- toDo[i]= line;
- int indent= computeIndentUnits(line, tabWidth, indentWidth);
+ toDo[i] = line;
+ int indent = computeIndentUnits(line, tabWidth, indentWidth);
if (indent < minIndent) {
- minIndent= indent;
+ minIndent = indent;
}
}
-
+
if (minIndent > 0) {
// remove this indent from all lines
- for (int i= considerFirstLine ? 0 : 1; i < toDo.length; i++) {
- String s= toDo[i];
+ for (int i = considerFirstLine ? 0 : 1; i < toDo.length; i++) {
+ String s = toDo[i];
if (s != null)
- lines[i]= trimIndent(s, minIndent, tabWidth, indentWidth);
+ lines[i] = trimIndent(s, minIndent, tabWidth, indentWidth);
else {
- String line= lines[i];
- int indent= computeIndentUnits(line, tabWidth, indentWidth);
+ String line = lines[i];
+ int indent = computeIndentUnits(line, tabWidth, indentWidth);
if (indent > minIndent)
- lines[i]= trimIndent(line, minIndent, tabWidth, indentWidth);
+ lines[i] = trimIndent(line, minIndent, tabWidth, indentWidth);
else
- lines[i]= trimLeadingTabsAndSpaces(line);
+ lines[i] = trimLeadingTabsAndSpaces(line);
}
}
}
}
-
+
/**
* Returns that part of the indentation of <code>line</code> that makes up
* a multiple of indentation units.
- *
+ *
* @param line the line to scan
* @param project the project from which to get the formatter
* preferences, or <code>null</code> for global preferences
@@ -319,13 +324,14 @@ public class Strings {
* @since 5.0
*/
public static String getIndentString(String line, ICProject project) {
- return IndentManipulation.extractIndentString(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
+ return IndentManipulation.extractIndentString(line, CodeFormatterUtil.getTabWidth(project),
+ CodeFormatterUtil.getIndentWidth(project));
}
-
+
/**
* Returns that part of the indentation of <code>line</code> that makes up
* a multiple of indentation units.
- *
+ *
* @param line the line to scan
* @param tabWidth the size of one tab in space equivalents
* @param indentWidth the size of the indent in space equivalents
@@ -335,93 +341,97 @@ public class Strings {
public static String getIndentString(String line, int tabWidth, int indentWidth) {
return IndentManipulation.extractIndentString(line, tabWidth, indentWidth);
}
-
+
public static String[] removeTrailingEmptyLines(String[] sourceLines) {
- int lastNonEmpty= findLastNonEmptyLineIndex(sourceLines);
- String[] result= new String[lastNonEmpty + 1];
- for (int i= 0; i < result.length; i++) {
- result[i]= sourceLines[i];
+ int lastNonEmpty = findLastNonEmptyLineIndex(sourceLines);
+ String[] result = new String[lastNonEmpty + 1];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = sourceLines[i];
}
return result;
}
private static int findLastNonEmptyLineIndex(String[] sourceLines) {
- for (int i= sourceLines.length - 1; i >= 0; i--) {
- if (! sourceLines[i].trim().isEmpty())
+ for (int i = sourceLines.length - 1; i >= 0; i--) {
+ if (!sourceLines[i].trim().isEmpty())
return i;
}
return -1;
}
-
+
/**
* Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added.
* The first line of the code will not be changed. (It is considered to have no indent as it might start in
* the middle of a line)
- *
+ *
* @param project the project from which to get the formatter
* preferences, or <code>null</code> for global preferences
* @since 5.0
*/
- public static String changeIndent(String code, int codeIndentLevel, ICProject project, String newIndent, String lineDelim) {
- return IndentManipulation.changeIndent(code, codeIndentLevel, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), newIndent, lineDelim);
+ public static String changeIndent(String code, int codeIndentLevel, ICProject project, String newIndent,
+ String lineDelim) {
+ return IndentManipulation.changeIndent(code, codeIndentLevel, CodeFormatterUtil.getTabWidth(project),
+ CodeFormatterUtil.getIndentWidth(project), newIndent, lineDelim);
}
-
+
/**
* Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added.
* The first line of the code will not be changed. (It is considered to have no indent as it might start in
* the middle of a line)
* @since 5.0
*/
- public static String changeIndent(String code, int codeIndentLevel, int tabWidth, int indentWidth, String newIndent, String lineDelim) {
+ public static String changeIndent(String code, int codeIndentLevel, int tabWidth, int indentWidth, String newIndent,
+ String lineDelim) {
return IndentManipulation.changeIndent(code, codeIndentLevel, tabWidth, indentWidth, newIndent, lineDelim);
}
-
+
public static String trimIndentation(String source, ICProject project, boolean considerFirstLine) {
- return trimIndentation(source, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), considerFirstLine);
+ return trimIndentation(source, CodeFormatterUtil.getTabWidth(project),
+ CodeFormatterUtil.getIndentWidth(project), considerFirstLine);
}
-
+
public static String trimIndentation(String source, int tabWidth, int indentWidth, boolean considerFirstLine) {
try {
- ILineTracker tracker= new DefaultLineTracker();
+ ILineTracker tracker = new DefaultLineTracker();
tracker.set(source);
- int size= tracker.getNumberOfLines();
+ int size = tracker.getNumberOfLines();
if (size == 1)
return source;
- String lines[]= new String[size];
- for (int i= 0; i < size; i++) {
- IRegion region= tracker.getLineInformation(i);
- int offset= region.getOffset();
- lines[i]= source.substring(offset, offset + region.getLength());
+ String lines[] = new String[size];
+ for (int i = 0; i < size; i++) {
+ IRegion region = tracker.getLineInformation(i);
+ int offset = region.getOffset();
+ lines[i] = source.substring(offset, offset + region.getLength());
}
Strings.trimIndentation(lines, tabWidth, indentWidth, considerFirstLine);
- StringBuilder result= new StringBuilder();
- int last= size - 1;
- for (int i= 0; i < size; i++) {
+ StringBuilder result = new StringBuilder();
+ int last = size - 1;
+ for (int i = 0; i < size; i++) {
result.append(lines[i]);
if (i < last)
result.append(tracker.getLineDelimiter(i));
}
return result.toString();
} catch (BadLocationException e) {
- Assert.isTrue(false,"Can not happend"); //$NON-NLS-1$
+ Assert.isTrue(false, "Can not happend"); //$NON-NLS-1$
return null;
}
}
-
+
/**
* Concatenate the given strings into one strings using the passed line delimiter as a
* delimiter. No delimiter is added to the last line.
*/
public static String concatenate(String[] lines, String delimiter) {
- StringBuilder buffer= new StringBuilder();
- for (int i= 0; i < lines.length; i++) {
+ StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < lines.length; i++) {
if (i > 0)
buffer.append(delimiter);
buffer.append(lines[i]);
}
return buffer.toString();
}
-
+
public static boolean equals(String s, char[] c) {
if (s.length() != c.length)
return false;
@@ -432,14 +442,14 @@ public class Strings {
}
return true;
}
-
+
public static String removeTrailingCharacters(String text, char toRemove) {
- int size= text.length();
- int end= size;
- for (int i= size - 1; i >= 0; i--) {
- char c= text.charAt(i);
+ int size = text.length();
+ int end = size;
+ for (int i = size - 1; i >= 0; i--) {
+ char c = text.charAt(i);
if (c == toRemove) {
- end= i;
+ end = i;
} else {
break;
}
@@ -481,24 +491,23 @@ public class Strings {
return LegacyActionTools.removeMnemonics(string);
}
-
/**
* Adds special marks so that that the given styled string is readable in a BiDi environment.
- *
+ *
* @param styledString the styled string
* @return the processed styled string
*/
public static StyledString markLTR(StyledString styledString) {
-
+
/*
* NOTE: For performance reasons we do not call markLTR(styledString, null)
*/
-
+
if (!USE_TEXT_PROCESSOR)
return styledString;
- String inputString= styledString.getString();
- String string= TextProcessor.process(inputString);
+ String inputString = styledString.getString();
+ String string = TextProcessor.process(inputString);
if (string != inputString)
insertMarks(styledString, inputString, string);
return styledString;
@@ -506,7 +515,7 @@ public class Strings {
/**
* Adds special marks so that that the given styled string is readable in a BiDi environment.
- *
+ *
* @param styledString the styled string
* @param delimiters the additional delimiters
* @return the processed styled string
@@ -515,8 +524,8 @@ public class Strings {
if (!USE_TEXT_PROCESSOR)
return styledString;
- String inputString= styledString.getString();
- String string= TextProcessor.process(inputString, delimiters);
+ String inputString = styledString.getString();
+ String string = TextProcessor.process(inputString, delimiters);
if (string != inputString)
insertMarks(styledString, inputString, string);
return styledString;
@@ -524,7 +533,7 @@ public class Strings {
/**
* Adds special marks so that that the given string is readable in a BiDi environment.
- *
+ *
* @param string the string
* @return the processed styled string
* @since 5.3
@@ -538,7 +547,7 @@ public class Strings {
/**
* Adds special marks so that that the given string is readable in a BiDi environment.
- *
+ *
* @param string the string
* @param delimiters the delimiters
* @return the processed styled string
@@ -554,7 +563,7 @@ public class Strings {
/**
* Adds special marks so that that the given C element label is readable in a BiDi
* environment.
- *
+ *
* @param string the string
* @return the processed styled string
* @since 5.3
@@ -569,7 +578,7 @@ public class Strings {
/**
* Adds special marks so that that the given styled C element label is readable in a BiDi
* environment.
- *
+ *
* @param styledString the styled string
* @return the processed styled string
* @since 5.3
@@ -578,8 +587,8 @@ public class Strings {
if (!USE_TEXT_PROCESSOR)
return styledString;
- String inputString= styledString.getString();
- String string= TextProcessor.process(inputString, C_ELEMENT_DELIMITERS);
+ String inputString = styledString.getString();
+ String string = TextProcessor.process(inputString, C_ELEMENT_DELIMITERS);
if (string != inputString)
insertMarks(styledString, inputString, string);
return styledString;
@@ -587,23 +596,23 @@ public class Strings {
/**
* Inserts the marks into the given styled string.
- *
+ *
* @param styledString the styled string
* @param originalString the original string
* @param processedString the processed string
* @since 5.3
*/
private static void insertMarks(StyledString styledString, String originalString, String processedString) {
- int originalLength= originalString.length();
- int processedStringLength= processedString.length();
- char orig= originalLength > 0 ? originalString.charAt(0) : '\0';
- for (int o= 0, p= 0; p < processedStringLength; p++) {
- char processed= processedString.charAt(p);
+ int originalLength = originalString.length();
+ int processedStringLength = processedString.length();
+ char orig = originalLength > 0 ? originalString.charAt(0) : '\0';
+ for (int o = 0, p = 0; p < processedStringLength; p++) {
+ char processed = processedString.charAt(p);
if (o < originalLength) {
if (orig == processed) {
o++;
if (o < originalLength)
- orig= originalString.charAt(o);
+ orig = originalString.charAt(o);
continue;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
index df0f8b0b61d..86db9540e59 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
@@ -78,22 +78,22 @@ C model (<code>ICModel</code>)<br>
*/
public class BaseCElementContentProvider implements ITreeContentProvider {
- protected static final Object[] NO_CHILDREN= new Object[0];
+ protected static final Object[] NO_CHILDREN = new Object[0];
- protected boolean fProvideMembers= false;
- protected boolean fProvideWorkingCopy= false;
- protected boolean fIncludesGrouping= false;
- protected boolean fNamespacesGrouping= false;
- protected boolean fMemberGrouping= false;
- protected boolean fMacroGrouping= false;
+ protected boolean fProvideMembers = false;
+ protected boolean fProvideWorkingCopy = false;
+ protected boolean fIncludesGrouping = false;
+ protected boolean fNamespacesGrouping = false;
+ protected boolean fMemberGrouping = false;
+ protected boolean fMacroGrouping = false;
public BaseCElementContentProvider() {
this(false, false);
}
public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
- fProvideMembers= provideMembers;
- fProvideWorkingCopy= provideWorkingCopy;
+ fProvideMembers = provideMembers;
+ fProvideWorkingCopy = provideWorkingCopy;
}
/**
@@ -109,7 +109,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
* for a TU's children.
*/
public void setProvideMembers(boolean b) {
- fProvideMembers= b;
+ fProvideMembers = b;
}
/**
@@ -117,7 +117,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
* a working copy of a compilation unit
*/
public void setProvideWorkingCopy(boolean b) {
- fProvideWorkingCopy= b;
+ fProvideWorkingCopy = b;
}
/**
@@ -132,7 +132,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
* Can elements be group.
*/
public boolean areIncludesGroup() {
- return fIncludesGrouping;
+ return fIncludesGrouping;
}
/**
@@ -140,14 +140,14 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
* @param b
*/
public void setIncludesGrouping(boolean b) {
- fIncludesGrouping = b;
+ fIncludesGrouping = b;
}
/**
* Can elements be group.
*/
public boolean areNamespacesGroup() {
- return fNamespacesGrouping;
+ return fNamespacesGrouping;
}
/**
@@ -155,7 +155,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
* @param b
*/
public void setNamespacesGrouping(boolean b) {
- fNamespacesGrouping = b;
+ fNamespacesGrouping = b;
}
/**
@@ -220,19 +220,19 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
try {
if (element instanceof ICModel) {
- return getCProjects((ICModel)element);
- } else if (element instanceof ICProject ) {
- return getSourceRoots((ICProject)element);
+ return getCProjects((ICModel) element);
+ } else if (element instanceof ICProject) {
+ return getSourceRoots((ICProject) element);
} else if (element instanceof ICContainer) {
- return getCResources((ICContainer)element);
+ return getCResources((ICContainer) element);
} else if (element instanceof ITranslationUnit) {
// if we want to get the children of a translation unit
if (fProvideMembers) {
// if we want to use the working copy of it
- ITranslationUnit tu = (ITranslationUnit)element;
- if (fProvideWorkingCopy){
+ ITranslationUnit tu = (ITranslationUnit) element;
+ if (fProvideWorkingCopy) {
// if it is not already a working copy
- if (!(element instanceof IWorkingCopy)){
+ if (!(element instanceof IWorkingCopy)) {
// if it has a valid working copy
IWorkingCopy copy = CDTUITools.getWorkingCopyManager().findSharedWorkingCopy(tu);
if (copy != null) {
@@ -243,21 +243,21 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
return getTranslationUnitChildren(tu);
}
} else if (element instanceof IBinary) {
- return ((IBinary)element).getChildren();
+ return ((IBinary) element).getChildren();
} else if (element instanceof IArchive) {
- return ((IArchive)element).getChildren();
+ return ((IArchive) element).getChildren();
} else if (element instanceof IBinaryModule) {
- return ((IBinaryModule)element).getChildren();
+ return ((IBinaryModule) element).getChildren();
} else if (element instanceof INamespace) {
return getNamespaceChildren((INamespace) element);
- } else if (element instanceof ISourceReference && element instanceof IParent) {
- return ((IParent)element).getChildren();
+ } else if (element instanceof ISourceReference && element instanceof IParent) {
+ return ((IParent) element).getChildren();
} else if (element instanceof IProject) {
- return getResources((IProject)element);
+ return getResources((IProject) element);
} else if (element instanceof IFolder) {
- return getResources((IFolder)element);
+ return getResources((IFolder) element);
} else if (element instanceof CElementGrouping) {
- return ((CElementGrouping)element).getChildren(element);
+ return ((CElementGrouping) element).getChildren(element);
}
} catch (CModelException e) {
//CUIPlugin.log(e);
@@ -286,7 +286,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
if (element instanceof ICProject) {
- ICProject cp= (ICProject)element;
+ ICProject cp = (ICProject) element;
if (!cp.getProject().isOpen()) {
return false;
}
@@ -294,11 +294,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
if (element instanceof ICContainer) {
- ICContainer container= (ICContainer)element;
- IResource resource= container.getResource();
+ ICContainer container = (ICContainer) element;
+ IResource resource = container.getResource();
if (resource instanceof IContainer) {
try {
- return ((IContainer)resource).members().length > 0;
+ return ((IContainer) resource).members().length > 0;
} catch (CoreException exc) {
return false;
}
@@ -307,7 +307,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
if (element instanceof IParent) {
// when we have C children return true, else we fetch all the children
- if (((IParent)element).hasChildren()) {
+ if (((IParent) element).hasChildren()) {
return true;
}
}
@@ -316,7 +316,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
return true;
}
- Object[] children= getChildren(element);
+ Object[] children = getChildren(element);
return (children != null) && children.length > 0;
}
@@ -333,9 +333,9 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
public Object internalGetParent(Object element) {
if (element instanceof IResource) {
- IResource parent= ((IResource)element).getParent();
+ IResource parent = ((IResource) element).getParent();
if (parent != null && parent.isAccessible()) {
- ICElement cParent= CoreModel.getDefault().create(parent);
+ ICElement cParent = CoreModel.getDefault().create(parent);
if (cParent != null && cParent.exists()) {
return cParent;
}
@@ -349,48 +349,49 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
if (parent instanceof IProject) {
return ((ICElement) element).getCProject();
}
- }
- else
- parent = ((ICElement)element).getParent();
+ } else
+ parent = ((ICElement) element).getParent();
// translate working copy parent to original TU,
// because working copies are never returned by getChildren
// this is necessary for proper show-in-target support
if (parent instanceof IWorkingCopy) {
- parent= ((IWorkingCopy)parent).getOriginalElement();
+ parent = ((IWorkingCopy) parent).getOriginalElement();
}
} else if (element instanceof IWorkbenchAdapter) {
- parent = ((IWorkbenchAdapter)element).getParent(element);
+ parent = ((IWorkbenchAdapter) element).getParent(element);
}
// if the parent is the default ISourceRoot == ICProject return the project
if (parent instanceof ISourceRoot) {
- if (isProjectSourceRoot((ISourceRoot)parent)) {
- parent = ((ISourceRoot)parent).getCProject();
+ if (isProjectSourceRoot((ISourceRoot) parent)) {
+ parent = ((ISourceRoot) parent).getCProject();
}
} else if (parent instanceof IBinaryContainer || parent instanceof IArchiveContainer) {
// If the virtual container is the parent we must find the legitimate parent.
if (element instanceof ICElement) {
- IResource res = ((ICElement)element).getResource();
+ IResource res = ((ICElement) element).getResource();
if (res != null) {
parent = internalGetParent(res);
}
}
}
if (parent instanceof INamespace && fNamespacesGrouping) {
- final INamespace namespace = (INamespace)parent;
- final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace, fMemberGrouping);
+ final INamespace namespace = (INamespace) parent;
+ final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace,
+ fMemberGrouping);
if (grouping.getNamespaces().length > 2) {
parent = grouping;
}
}
if (parent instanceof IMember && fMemberGrouping) {
- final IMember member = (IMember)parent;
+ final IMember member = (IMember) parent;
final String ns = getElementNamespace(member);
if (ns != null) {
Object parentParent = member.getParent();
if (parentParent instanceof INamespace && fNamespacesGrouping) {
- final INamespace namespace = (INamespace)parent;
- final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace);
+ final INamespace namespace = (INamespace) parent;
+ final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(),
+ namespace);
if (grouping.getNamespaces().length > 2) {
parentParent = grouping;
}
@@ -400,10 +401,10 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
// if we are doing grouping for the includes return the grouping container.
if (element instanceof IInclude && fIncludesGrouping) {
- parent = new IncludesGrouping(((IInclude)element).getTranslationUnit());
+ parent = new IncludesGrouping(((IInclude) element).getTranslationUnit());
}
if (element instanceof IMacro && fMacroGrouping) {
- parent = new MacrosGrouping(((IMacro)element).getTranslationUnit());
+ parent = new MacrosGrouping(((IMacro) element).getTranslationUnit());
}
return parent;
}
@@ -425,20 +426,19 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
if (!cproject.getProject().isOpen())
return NO_CHILDREN;
- List<ICElement> list= new ArrayList<ICElement>();
+ List<ICElement> list = new ArrayList<ICElement>();
ICElement[] children = cproject.getChildren();
for (ICElement child : children) {
if (child instanceof ISourceRoot && child.getResource().getType() == IResource.PROJECT) {
// Was a source root at the project, get the children of this element
- ICElement[] c2 = ((ISourceRoot)child).getChildren();
+ ICElement[] c2 = ((ISourceRoot) child).getChildren();
for (int k = 0; k < c2.length; ++k)
list.add(c2[k]);
} else if (CCorePlugin.showSourceRootsAtTopOfProject()) {
list.add(child);
- } else if (child instanceof ISourceRoot &&
- child.getResource().getParent().equals(cproject.getProject())) {
+ } else if (child instanceof ISourceRoot && child.getResource().getParent().equals(cproject.getProject())) {
list.add(child);
- }
+ }
}
Object[] objects = list.toArray();
@@ -464,7 +464,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
}
if (hasInclude) {
- list.add (0, new IncludesGrouping(unit));
+ list.add(0, new IncludesGrouping(unit));
}
children = list.toArray();
}
@@ -474,7 +474,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
List<Object> list = new ArrayList<Object>(children.length);
for (int i = 0; i < children.length; ++i) {
if (children[i] instanceof INamespace) {
- INamespace n1 = (INamespace)children[i];
+ INamespace n1 = (INamespace) children[i];
NamespacesGrouping namespacesGrouping = nsmap.get(n1.getElementName());
if (namespacesGrouping == null) {
namespacesGrouping = new NamespacesGrouping(unit, n1, fMemberGrouping);
@@ -497,7 +497,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
Map<String, MembersGrouping> map = new HashMap<String, MembersGrouping>();
for (int i = 0; i < children.length; ++i) {
if (children[i] instanceof IMember) {
- final ICElement member = (ICElement)children[i];
+ final ICElement member = (ICElement) children[i];
String namespace = getElementNamespace(member);
MembersGrouping memberGrouping = map.get(namespace);
if (memberGrouping == null) {
@@ -526,14 +526,13 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
if (hasMacros) {
//Check if include gouping is there. If so, put macros after
- if(!list.isEmpty()){
- if(list.get(0) instanceof IncludesGrouping)
- list.add (1, new MacrosGrouping(unit));
+ if (!list.isEmpty()) {
+ if (list.get(0) instanceof IncludesGrouping)
+ list.add(1, new MacrosGrouping(unit));
else
- list.add (0, new MacrosGrouping(unit));
- }
- else
- list.add (0, new MacrosGrouping(unit));
+ list.add(0, new MacrosGrouping(unit));
+ } else
+ list.add(0, new MacrosGrouping(unit));
}
children = list.toArray();
}
@@ -548,7 +547,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
Map<String, MembersGrouping> map = new HashMap<String, MembersGrouping>();
for (int i = 0; i < children.length; ++i) {
if (children[i] instanceof IMember) {
- final ICElement member = (ICElement)children[i];
+ final ICElement member = (ICElement) children[i];
String namespace = getElementNamespace(member);
MembersGrouping memberGrouping = map.get(namespace);
if (memberGrouping == null) {
@@ -591,7 +590,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
Object[] result = children;
if (missingElements.size() > 0) {
- result = concatenate(result, missingElements.toArray());
+ result = concatenate(result, missingElements.toArray());
}
if (objects != null && objects.length > 0) {
@@ -670,7 +669,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
List<Object> nonCResources = new ArrayList<Object>(objects.length);
for (Object object : objects) {
- Object o= object;
+ Object o = object;
// A folder can also be a source root in the following case
// Project
// + src <- source folder
@@ -679,7 +678,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
// Included is a member of excluded, but since it is rendered as a source
// folder we have to exclude it as a normal child.
if (o instanceof IFolder) {
- IFolder folder = (IFolder)o;
+ IFolder folder = (IFolder) o;
ISourceRoot root = null;
for (int j = 0; j < roots.length; j++) {
if (roots[j].getPath().equals(folder.getFullPath())) {
@@ -690,11 +689,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
// it is a sourceRoot skip it.
if (root != null) {
if (CCorePlugin.showSourceRootsAtTopOfProject())
- continue;
+ continue;
else
o = root;
}
- } else if (o instanceof IFile){
+ } else if (o instanceof IFile) {
boolean found = false;
for (ICElement binarie : binaries) {
IResource res = binarie.getResource();
@@ -723,7 +722,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
* Note: This method is for internal use only. Clients should not call this method.
*/
protected boolean isProjectSourceRoot(ISourceRoot root) {
- IResource resource= root.getResource();
+ IResource resource = root.getResource();
return (resource instanceof IProject);
}
@@ -732,10 +731,10 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
return false;
}
if (element instanceof IResource) {
- return ((IResource)element).exists();
+ return ((IResource) element).exists();
}
if (element instanceof ICElement) {
- return ((ICElement)element).exists();
+ return ((ICElement) element).exists();
}
return true;
}
@@ -750,7 +749,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
ArrayList<IBinary> list = new ArrayList<IBinary>(celements.length);
for (ICElement celement : celements) {
if (celement instanceof IBinary) {
- IBinary bin = (IBinary)celement;
+ IBinary bin = (IBinary) celement;
list.add(bin);
}
}
@@ -769,7 +768,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
ArrayList<IArchive> list = new ArrayList<IArchive>(celements.length);
for (ICElement celement : celements) {
if (celement instanceof IArchive) {
- IArchive ar = (IArchive)celement;
+ IArchive ar = (IArchive) celement;
list.add(ar);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java
index 042a8451719..dea40c529ac 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java
@@ -25,81 +25,84 @@ import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.ui.CUIPlugin;
public class BinaryPropertySource extends FilePropertySource {
-
- private final static String ELF_CPU= "CElementProperties.elf_cpu"; //$NON-NLS-1$
- private final static String ELF_TEXT= "CElementProperties.elf_text"; //$NON-NLS-1$
- private final static String ELF_DATA= "CElementProperties.elf_data"; //$NON-NLS-1$
- private final static String ELF_BSS= "CElementProperties.elf_bss"; //$NON-NLS-1$
- private final static String ELF_TYPE= "CElementProperties.elf_type"; //$NON-NLS-1$
- private final static String ELF_HAS_DEBUG= "CElementProperties.elf_has_debug"; //$NON-NLS-1$
- private final static String ELF_SONAME= "CElementProperties.elf_soname"; //$NON-NLS-1$
- private final static String ELF_NEEDED= "CElementProperties.elf_needed"; //$NON-NLS-1$
-
+
+ private final static String ELF_CPU = "CElementProperties.elf_cpu"; //$NON-NLS-1$
+ private final static String ELF_TEXT = "CElementProperties.elf_text"; //$NON-NLS-1$
+ private final static String ELF_DATA = "CElementProperties.elf_data"; //$NON-NLS-1$
+ private final static String ELF_BSS = "CElementProperties.elf_bss"; //$NON-NLS-1$
+ private final static String ELF_TYPE = "CElementProperties.elf_type"; //$NON-NLS-1$
+ private final static String ELF_HAS_DEBUG = "CElementProperties.elf_has_debug"; //$NON-NLS-1$
+ private final static String ELF_SONAME = "CElementProperties.elf_soname"; //$NON-NLS-1$
+ private final static String ELF_NEEDED = "CElementProperties.elf_needed"; //$NON-NLS-1$
+
private IBinary binary;
-
+
// Property Descriptors
static private IPropertyDescriptor[] fgPropertyDescriptors;
-
+
/**
* Get a PropertyDescriptor that defines the binary properties of an Elf
* @return the PropertyDescriptor
*/
private static IPropertyDescriptor[] getInitialPropertyDescriptor() {
// cpu name
- String cpuName= CUIPlugin.getResourceString(ELF_CPU);
- PropertyDescriptor cpuDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_CPU, cpuName);
+ String cpuName = CUIPlugin.getResourceString(ELF_CPU);
+ PropertyDescriptor cpuDescriptor = new PropertyDescriptor(ICElementPropertyConstants.P_ELF_CPU, cpuName);
cpuDescriptor.setAlwaysIncompatible(true);
cpuDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
// elf text
String textName = CUIPlugin.getResourceString(ELF_TEXT);
- PropertyDescriptor textDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_TEXT, textName);
+ PropertyDescriptor textDescriptor = new PropertyDescriptor(ICElementPropertyConstants.P_ELF_TEXT, textName);
textDescriptor.setAlwaysIncompatible(true);
textDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
-
+
// elf data
String dataName = CUIPlugin.getResourceString(ELF_DATA);
- PropertyDescriptor dataDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_DATA, dataName);
+ PropertyDescriptor dataDescriptor = new PropertyDescriptor(ICElementPropertyConstants.P_ELF_DATA, dataName);
dataDescriptor.setAlwaysIncompatible(true);
dataDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
-
+
// elf bss
String bssName = CUIPlugin.getResourceString(ELF_BSS);
- PropertyDescriptor bssDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_BSS, bssName);
+ PropertyDescriptor bssDescriptor = new PropertyDescriptor(ICElementPropertyConstants.P_ELF_BSS, bssName);
bssDescriptor.setAlwaysIncompatible(true);
bssDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
-
+
// elf type
String typeName = CUIPlugin.getResourceString(ELF_TYPE);
- PropertyDescriptor typeDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_TYPE, typeName);
+ PropertyDescriptor typeDescriptor = new PropertyDescriptor(ICElementPropertyConstants.P_ELF_TYPE, typeName);
typeDescriptor.setAlwaysIncompatible(true);
typeDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
-
+
// elf needed
String neededName = CUIPlugin.getResourceString(ELF_NEEDED);
- PropertyDescriptor neededDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_NEEDED, neededName);
+ PropertyDescriptor neededDescriptor = new PropertyDescriptor(ICElementPropertyConstants.P_ELF_NEEDED,
+ neededName);
neededDescriptor.setAlwaysIncompatible(true);
neededDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
-
+
// elf soname
String sonameName = CUIPlugin.getResourceString(ELF_SONAME);
- PropertyDescriptor sonameDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_SONAME, sonameName);
+ PropertyDescriptor sonameDescriptor = new PropertyDescriptor(ICElementPropertyConstants.P_ELF_SONAME,
+ sonameName);
sonameDescriptor.setAlwaysIncompatible(true);
sonameDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
-
+
// elf debug
String debugName = CUIPlugin.getResourceString(ELF_HAS_DEBUG);
- PropertyDescriptor debugDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_HAS_DEBUG, debugName);
+ PropertyDescriptor debugDescriptor = new PropertyDescriptor(ICElementPropertyConstants.P_ELF_HAS_DEBUG,
+ debugName);
debugDescriptor.setAlwaysIncompatible(true);
debugDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
-
- return new IPropertyDescriptor[] { cpuDescriptor, textDescriptor, dataDescriptor,
- bssDescriptor, typeDescriptor, sonameDescriptor, debugDescriptor, neededDescriptor };
+
+ return new IPropertyDescriptor[] { cpuDescriptor, textDescriptor, dataDescriptor, bssDescriptor, typeDescriptor,
+ sonameDescriptor, debugDescriptor, neededDescriptor };
}
-
+
public BinaryPropertySource(IBinary bin) {
- super((IFile)bin.getResource());
- binary= bin;
+ super((IFile) bin.getResource());
+ binary = bin;
}
/**
@@ -115,12 +118,12 @@ public class BinaryPropertySource extends FilePropertySource {
/**
* @see IPropertySource#getPropertyValue
- */
+ */
@Override
public Object getPropertyValue(Object name) {
if (element != null) {
Object returnValue = super.getPropertyValue(name);
- if(returnValue != null) {
+ if (returnValue != null) {
return returnValue;
}
}
@@ -137,7 +140,7 @@ public class BinaryPropertySource extends FilePropertySource {
} else if (name.equals(ICElementPropertyConstants.P_ELF_SONAME)) {
return binary.getSoname();
} else if (name.equals(ICElementPropertyConstants.P_ELF_HAS_DEBUG)) {
- if (binary.hasDebug()) {
+ if (binary.hasDebug()) {
return "true";//$NON-NLS-1$
}
return "false";//$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BusyCursorJobRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BusyCursorJobRunner.java
index 9b81f053146..96fb9016207 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BusyCursorJobRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BusyCursorJobRunner.java
@@ -144,5 +144,6 @@ public final class BusyCursorJobRunner {
}
}
- private BusyCursorJobRunner() {}
+ private BusyCursorJobRunner() {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
index ccb5e291f37..80670e4d1f6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
@@ -35,14 +35,8 @@ import org.eclipse.cdt.core.model.ICElement;
*/
public class CElementAdapterFactory implements IAdapterFactory {
- private static Class<?>[] PROPERTIES= new Class[] {
- IPropertySource.class,
- IResource.class,
- IWorkbenchAdapter.class,
- IPersistableElement.class,
- IDeferredWorkbenchAdapter.class,
- IActionFilter.class
- };
+ private static Class<?>[] PROPERTIES = new Class[] { IPropertySource.class, IResource.class,
+ IWorkbenchAdapter.class, IPersistableElement.class, IDeferredWorkbenchAdapter.class, IActionFilter.class };
private static CWorkbenchAdapter fgCWorkbenchAdapter;
private static CActionFilter fgCActionFilter;
@@ -66,7 +60,7 @@ public class CElementAdapterFactory implements IAdapterFactory {
if (IPropertySource.class.equals(key)) {
return getPropertySource(celem);
} else if (IResource.class.isAssignableFrom(key)) {
- IResource resource= getResource(celem);
+ IResource resource = getResource(celem);
if (resource != null && key.isAssignableFrom(resource.getClass())) {
return resource;
}
@@ -84,12 +78,12 @@ public class CElementAdapterFactory implements IAdapterFactory {
private IPropertySource getPropertySource(ICElement celement) {
if (celement instanceof IBinary) {
- return new BinaryPropertySource((IBinary)celement);
+ return new BinaryPropertySource((IBinary) celement);
}
IResource res = celement.getResource();
if (res != null) {
if (res instanceof IFile) {
- return new FilePropertySource((IFile)res);
+ return new FilePropertySource((IFile) res);
}
return new ResourcePropertySource(res);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java
index 00cba394faf..a96e351d7ba 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java
@@ -24,7 +24,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
public class CElementPropertySource implements IPropertySource {
- private final static String LABEL= "CElementProperties.name"; //$NON-NLS-1$
+ private final static String LABEL = "CElementProperties.name"; //$NON-NLS-1$
private ICElement fCElement;
@@ -33,15 +33,15 @@ public class CElementPropertySource implements IPropertySource {
static {
// resource name
- String displayName= CUIPlugin.getResourceString(LABEL);
- PropertyDescriptor descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName);
+ String displayName = CUIPlugin.getResourceString(LABEL);
+ PropertyDescriptor descriptor = new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName);
descriptor.setAlwaysIncompatible(true);
- fgPropertyDescriptors= new IPropertyDescriptor[] { descriptor };
+ fgPropertyDescriptors = new IPropertyDescriptor[] { descriptor };
}
public CElementPropertySource(ICElement elem) {
- fCElement= elem;
+ fCElement = elem;
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java
index 1b31cd89bfc..8b41bd5c808 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java
@@ -7,14 +7,13 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
* Markus Schorn (Wind River Systems)
**********************************************************************/
package org.eclipse.cdt.internal.ui;
-
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
@@ -44,7 +43,7 @@ import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
- * This class is used to manage external plugins that contribute
+ * This class is used to manage external plugins that contribute
* C/C++ help information through the CHelpProvider extension point
*/
@@ -54,7 +53,7 @@ public class CHelpProviderManager {
//private static Map fProjectHelpSettings = null;
private static CHelpSettings fDefaultHelpSettings = null;
-
+
private static File fSettingsFile = null;
static private CHelpProviderManager fInstance = null;
@@ -63,91 +62,91 @@ public class CHelpProviderManager {
private CHelpProviderManager() {
}
-
- private static File getSettingsFile(){
- if(fSettingsFile == null){
+
+ private static File getSettingsFile() {
+ if (fSettingsFile == null) {
fSettingsFile = CUIPlugin.getDefault().getStateLocation().append(C_HELP_SETTINGS_FILE_NAME).toFile();
}
return fSettingsFile;
}
-
-// private static Map getSettingsMap(){
-// if(fProjectHelpSettings == null)
-// fProjectHelpSettings = new HashMap();
-// return fProjectHelpSettings;
-// }
-
- private static CHelpSettings getDefaultHelpSettings(){
- if(fDefaultHelpSettings == null){
+
+ // private static Map getSettingsMap(){
+ // if(fProjectHelpSettings == null)
+ // fProjectHelpSettings = new HashMap();
+ // return fProjectHelpSettings;
+ // }
+
+ private static CHelpSettings getDefaultHelpSettings() {
+ if (fDefaultHelpSettings == null) {
fDefaultHelpSettings = new CHelpSettings(null);
}
return fDefaultHelpSettings;
}
- private static CHelpSettings getPersistedHelpSettings(IProject project){
-/* uncomment to use Map
- Map settingsMap = getSettingsMap();
- CHelpSettings settings = (CHelpSettings)settingsMap.get(project.getName());
- if(settings == null){
- settings = createHelpSettings(project);
- settingsMap.put(project.getName(),settings);
- }
- return settings;
-*/
+ private static CHelpSettings getPersistedHelpSettings(IProject project) {
+ /* uncomment to use Map
+ Map settingsMap = getSettingsMap();
+ CHelpSettings settings = (CHelpSettings)settingsMap.get(project.getName());
+ if(settings == null){
+ settings = createHelpSettings(project);
+ settingsMap.put(project.getName(),settings);
+ }
+ return settings;
+ */
return createHelpSettings(project);
}
-
- private static CHelpSettings createHelpSettings(IProject project){
-// String projectName = project.getName();
+
+ private static CHelpSettings createHelpSettings(IProject project) {
+ // String projectName = project.getName();
File file = getSettingsFile();
CHelpSettings settings = null;
Element rootElement = null;
- if(file.isFile()){
- try{
+ if (file.isFile()) {
+ try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(file);
NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT);
-
+
if (nodes.getLength() > 0)
- rootElement = (Element)nodes.item(0);
-
- }catch(ParserConfigurationException e){
- }catch(SAXException e){
- }catch(IOException e){
+ rootElement = (Element) nodes.item(0);
+
+ } catch (ParserConfigurationException e) {
+ } catch (SAXException e) {
+ } catch (IOException e) {
}
}
- settings = new CHelpSettings(project,rootElement);
+ settings = new CHelpSettings(project, rootElement);
return settings;
}
-
- private static CHelpSettings getHelpSettings(IProject project){
- if(project == null)
+
+ private static CHelpSettings getHelpSettings(IProject project) {
+ if (project == null)
return getDefaultHelpSettings();
CHelpSettings settings = null;
- if(fCurrentProject != null && fCurrentSettings != null && project == fCurrentProject)
+ if (fCurrentProject != null && fCurrentSettings != null && project == fCurrentProject)
settings = fCurrentSettings;
- else{
+ else {
fCurrentProject = project;
fCurrentSettings = getPersistedHelpSettings(project);
settings = fCurrentSettings;
}
return settings;
}
-
- private static CHelpSettings getHelpSettings(ICHelpInvocationContext context){
+
+ private static CHelpSettings getHelpSettings(ICHelpInvocationContext context) {
IProject project = getProjectFromContext(context);
-
+
return getHelpSettings(project);
}
-
- private static IProject getProjectFromContext(ICHelpInvocationContext context){
+
+ private static IProject getProjectFromContext(ICHelpInvocationContext context) {
IProject project = context.getProject();
- if(project == null){
+ if (project == null) {
ITranslationUnit unit = context.getTranslationUnit();
- if(unit != null)
+ if (unit != null)
project = unit.getCProject().getProject();
}
return project;
@@ -162,57 +161,56 @@ public class CHelpProviderManager {
public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, String name) {
CHelpSettings settings = getHelpSettings(context);
-
- return settings.getFunctionInfo(context,name);
+
+ return settings.getFunctionInfo(context, name);
}
public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag) {
CHelpSettings settings = getHelpSettings(context);
-
- return settings.getMatchingFunctions(context,frag);
+
+ return settings.getMatchingFunctions(context, frag);
}
- public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
+ public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name) {
CHelpSettings settings = getHelpSettings(context);
-
- return settings.getHelpResources(context,name);
+
+ return settings.getHelpResources(context, name);
}
-
- public CHelpBookDescriptor[] getCHelpBookDescriptors(ICHelpInvocationContext context){
+
+ public CHelpBookDescriptor[] getCHelpBookDescriptors(ICHelpInvocationContext context) {
return getHelpSettings(context).getCHelpBookDescriptors();
}
-
- public void serialize(ICHelpInvocationContext context){
+
+ public void serialize(ICHelpInvocationContext context) {
CHelpSettings settings = getHelpSettings(context);
File file = getSettingsFile();
- try{
+ try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc;
Element rootElement = null;
- if(file.exists()){
+ if (file.exists()) {
doc = builder.parse(file);
NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT);
-
+
if (nodes.getLength() > 0)
- rootElement = (Element)nodes.item(0);
- }
- else{
+ rootElement = (Element) nodes.item(0);
+ } else {
doc = builder.newDocument();
}
- if(rootElement == null){
+ if (rootElement == null) {
rootElement = doc.createElement(ELEMENT_ROOT);
doc.appendChild(rootElement);
}
- settings.serialize(doc,rootElement);
+ settings.serialize(doc, rootElement);
FileWriter writer = new FileWriter(file);
- Transformer transformer=TransformerFactory.newInstance().newTransformer();
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
@@ -222,11 +220,11 @@ public class CHelpProviderManager {
transformer.transform(source, result);
writer.close();
- }catch(ParserConfigurationException e){
- }catch(SAXException e){
- }catch(TransformerConfigurationException e){
- }catch(TransformerException e){
- }catch(IOException e){
+ } catch (ParserConfigurationException e) {
+ } catch (SAXException e) {
+ } catch (TransformerConfigurationException e) {
+ } catch (TransformerException e) {
+ } catch (IOException e) {
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java
index 9ef0014a02b..34e241fc25c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java
@@ -39,21 +39,21 @@ public class CPerspectiveFactory implements IPerspectiveFactory {
*/
@Override
public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
+ String editorArea = layout.getEditorArea();
- IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
+ IFolderLayout folder1 = layout.createFolder("topLeft", IPageLayout.LEFT, (float) 0.25, editorArea); //$NON-NLS-1$
folder1.addView(ProjectExplorer.VIEW_ID);
folder1.addPlaceholder(CUIPlugin.CVIEW_ID);
folder1.addPlaceholder(IPageLayout.ID_RES_NAV);
folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS);
- IFolderLayout folder2= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$
+ IFolderLayout folder2 = layout.createFolder("bottom", IPageLayout.BOTTOM, (float) 0.75, editorArea); //$NON-NLS-1$
folder2.addView(IPageLayout.ID_PROBLEM_VIEW);
folder2.addView(IPageLayout.ID_TASK_LIST);
folder2.addView(IConsoleConstants.ID_CONSOLE_VIEW);
folder2.addView(IPageLayout.ID_PROP_SHEET);
- IFolderLayout folder3= layout.createFolder("topRight", IPageLayout.RIGHT,(float)0.75, editorArea); //$NON-NLS-1$
+ IFolderLayout folder3 = layout.createFolder("topRight", IPageLayout.RIGHT, (float) 0.75, editorArea); //$NON-NLS-1$
folder3.addView(IPageLayout.ID_OUTLINE);
layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
index 3251d807164..61afe15f6ee 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
@@ -7,13 +7,13 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
* Markus Schorn (Wind River Systems)
* Anton Leherbauer (Wind River Systems)
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
* Dmitry Kozlov (CodeSourcery)
* Tomasz Wesolowski
* Andrew Gvozdev (Quoin Inc.) - moved usage involving registry to CDTSharedImages
@@ -43,237 +43,308 @@ import org.eclipse.cdt.ui.CUIPlugin;
* use public API class {@link CDTSharedImages} for that.
*/
public class CPluginImages {
- public static final IPath ICONS_PATH= new Path("$nl$/icons"); //$NON-NLS-1$
+ public static final IPath ICONS_PATH = new Path("$nl$/icons"); //$NON-NLS-1$
/** Converter from CPluginImages key to CDTSharedImages key */
private static Map<String, String> fPathMap = new HashMap<String, String>();
- private static final String NAME_PREFIX= CUIPlugin.PLUGIN_ID + '.';
- private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
-
- private static final String ICONS= "icons/"; //$NON-NLS-1$
- public static final String T_OBJ= "obj16/"; //$NON-NLS-1$
- public static final String T_WIZBAN= "wizban/"; //$NON-NLS-1$
- public static final String T_LCL= "lcl16/"; //$NON-NLS-1$
- public static final String T_DLCL= "dlcl16/"; //$NON-NLS-1$
- public static final String T_ELCL= "elcl16/"; //$NON-NLS-1$
- public static final String T_TOOL= "tool16/"; //$NON-NLS-1$
- public static final String T_VIEW= "view16/"; //$NON-NLS-1$
- public static final String T_OVR= "ovr16/"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_VARIABLE= NAME_PREFIX + "variable_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_LOCAL_VARIABLE= NAME_PREFIX + "variable_local_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CLASS_ALT= NAME_PREFIX + "classfo_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_NAMESPACE= NAME_PREFIX + "namespace_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_USING= NAME_PREFIX + "using_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_STRUCT= NAME_PREFIX + "struct_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_STRUCT_ALT= NAME_PREFIX + "structfo_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_UNION= NAME_PREFIX + "union_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_UNION_ALT= NAME_PREFIX + "unionfo_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TYPEDEF= NAME_PREFIX + "typedef_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TYPEDEF_ALT= NAME_PREFIX + "typedeffo_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ENUMERATION= NAME_PREFIX + "enum_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ENUMERATION_ALT= NAME_PREFIX + "enumfo_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_UNKNOWN_TYPE= NAME_PREFIX + "unknown_type_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ENUMERATOR= NAME_PREFIX + "enumerator_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_FUNCTION= NAME_PREFIX + "function_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PUBLIC_METHOD= NAME_PREFIX + "method_public_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PROTECTED_METHOD= NAME_PREFIX + "method_protected_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_PRIVATE_METHOD= NAME_PREFIX + "method_private_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PUBLIC_FIELD= NAME_PREFIX + "field_public_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PROTECTED_FIELD= NAME_PREFIX + "field_protected_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PRIVATE_FIELD= NAME_PREFIX + "field_private_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_KEYWORD= NAME_PREFIX + "keyword_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_DECLARATION= NAME_PREFIX + "cdeclaration_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_VAR_DECLARATION= NAME_PREFIX + "var_declaration_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INCLUDE= NAME_PREFIX + "include_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_MACRO= NAME_PREFIX + "define_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_LABEL= NAME_PREFIX + "label_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TUNIT= NAME_PREFIX + "c_file_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TUNIT_HEADER= NAME_PREFIX + "h_file_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TUNIT_ASM= NAME_PREFIX + "s_file_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TUNIT_RESOURCE= NAME_PREFIX + "c_resource_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TUNIT_RESOURCE_H= NAME_PREFIX + "ch_resource_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_TUNIT_RESOURCE_A= NAME_PREFIX + "asm_resource_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SOURCE_ROOT= NAME_PREFIX + "sroot_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SOURCE2_ROOT= NAME_PREFIX + "sroot2_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_FOLDER= NAME_PREFIX + "fldr_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CFOLDER= NAME_PREFIX + "cfolder_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CONFIG = NAME_PREFIX + "config.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ARCHIVE= NAME_PREFIX + "ar_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_BINARY= NAME_PREFIX + "bin_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SHLIB= NAME_PREFIX + "shlib_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CEXEC= NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CEXEC_DEBUG= NAME_PREFIX + "exec_dbg_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CORE= NAME_PREFIX + "core_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CONTAINER= NAME_PREFIX + "container_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ARCHIVES_CONTAINER= NAME_PREFIX + "archives_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_BINARIES_CONTAINER= NAME_PREFIX + "binaries_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_OUTPUT_FOLDER= NAME_PREFIX + "output_folder_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "lib_obj.gif"; //$NON-NLS-1$
+ private static final String NAME_PREFIX = CUIPlugin.PLUGIN_ID + '.';
+ private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
+
+ private static final String ICONS = "icons/"; //$NON-NLS-1$
+ public static final String T_OBJ = "obj16/"; //$NON-NLS-1$
+ public static final String T_WIZBAN = "wizban/"; //$NON-NLS-1$
+ public static final String T_LCL = "lcl16/"; //$NON-NLS-1$
+ public static final String T_DLCL = "dlcl16/"; //$NON-NLS-1$
+ public static final String T_ELCL = "elcl16/"; //$NON-NLS-1$
+ public static final String T_TOOL = "tool16/"; //$NON-NLS-1$
+ public static final String T_VIEW = "view16/"; //$NON-NLS-1$
+ public static final String T_OVR = "ovr16/"; //$NON-NLS-1$
+
+ public static final String IMG_OBJS_TEMPLATE = NAME_PREFIX + "template_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_VARIABLE = NAME_PREFIX + "variable_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_LOCAL_VARIABLE = NAME_PREFIX + "variable_local_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CLASS = NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CLASS_ALT = NAME_PREFIX + "classfo_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_NAMESPACE = NAME_PREFIX + "namespace_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_USING = NAME_PREFIX + "using_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_STRUCT = NAME_PREFIX + "struct_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_STRUCT_ALT = NAME_PREFIX + "structfo_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_UNION = NAME_PREFIX + "union_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_UNION_ALT = NAME_PREFIX + "unionfo_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TYPEDEF = NAME_PREFIX + "typedef_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TYPEDEF_ALT = NAME_PREFIX + "typedeffo_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ENUMERATION = NAME_PREFIX + "enum_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ENUMERATION_ALT = NAME_PREFIX + "enumfo_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_UNKNOWN_TYPE = NAME_PREFIX + "unknown_type_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ENUMERATOR = NAME_PREFIX + "enumerator_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_FUNCTION = NAME_PREFIX + "function_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_PUBLIC_METHOD = NAME_PREFIX + "method_public_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_PROTECTED_METHOD = NAME_PREFIX + "method_protected_obj.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJS_PRIVATE_METHOD = NAME_PREFIX + "method_private_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_PUBLIC_FIELD = NAME_PREFIX + "field_public_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_PROTECTED_FIELD = NAME_PREFIX + "field_protected_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_PRIVATE_FIELD = NAME_PREFIX + "field_private_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_KEYWORD = NAME_PREFIX + "keyword_obj.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJS_DECLARATION = NAME_PREFIX + "cdeclaration_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_VAR_DECLARATION = NAME_PREFIX + "var_declaration_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_INCLUDE = NAME_PREFIX + "include_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_MACRO = NAME_PREFIX + "define_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_LABEL = NAME_PREFIX + "label_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TUNIT = NAME_PREFIX + "c_file_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TUNIT_HEADER = NAME_PREFIX + "h_file_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TUNIT_ASM = NAME_PREFIX + "s_file_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TUNIT_RESOURCE = NAME_PREFIX + "c_resource_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TUNIT_RESOURCE_H = NAME_PREFIX + "ch_resource_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TUNIT_RESOURCE_A = NAME_PREFIX + "asm_resource_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_SOURCE_ROOT = NAME_PREFIX + "sroot_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_SOURCE2_ROOT = NAME_PREFIX + "sroot2_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_FOLDER = NAME_PREFIX + "fldr_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CFOLDER = NAME_PREFIX + "cfolder_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CONFIG = NAME_PREFIX + "config.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ARCHIVE = NAME_PREFIX + "ar_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_BINARY = NAME_PREFIX + "bin_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_SHLIB = NAME_PREFIX + "shlib_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CEXEC = NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CEXEC_DEBUG = NAME_PREFIX + "exec_dbg_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CORE = NAME_PREFIX + "core_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CONTAINER = NAME_PREFIX + "container_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ARCHIVES_CONTAINER = NAME_PREFIX + "archives_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_BINARIES_CONTAINER = NAME_PREFIX + "binaries_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_OUTPUT_FOLDER = NAME_PREFIX + "output_folder_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_LIBRARY = NAME_PREFIX + "lib_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INCLUDES_CONTAINER = NAME_PREFIX + "includes_container.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INCLUDES_FOLDER = NAME_PREFIX + "hfolder_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_QUOTE_INCLUDES_FOLDER = NAME_PREFIX + "hfolder_quote_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INCLUDES_FOLDER_SYSTEM = NAME_PREFIX + "fldr_sys_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INCLUDES_FOLDER_WORKSPACE = NAME_PREFIX + "wsp_includefolder.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ORDER= NAME_PREFIX + "cp_order_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_EXCLUDSION_FILTER_ATTRIB= NAME_PREFIX + "exclusion_filter_attrib.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ORDER = NAME_PREFIX + "cp_order_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_EXCLUDSION_FILTER_ATTRIB = NAME_PREFIX + "exclusion_filter_attrib.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SOURCE_ATTACH_ATTRIB = NAME_PREFIX + "source_attach_attrib.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_ARCHIVE_WSRC= NAME_PREFIX + "ar_src_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ARCHIVE_WSRC = NAME_PREFIX + "ar_src_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_IMPORT_SETTINGS = NAME_PREFIX + "import_settings_wiz.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_EXPORT_SETTINGS = NAME_PREFIX + "export_settings_wiz.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_PROJECT=NAME_PREFIX + "prj_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_PROJECT = NAME_PREFIX + "prj_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_INCCONT= NAME_PREFIX + "incc_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_INCCONT = NAME_PREFIX + "incc_obj.gif"; //$NON-NLS-1$
// Breakpoint images
public static final String IMG_OBJS_BREAKPOINT = NAME_PREFIX + "breakpoint.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "breakpoint_disabled.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_ACTIVE = NAME_PREFIX + "breakpoint_active.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_FIXABLE_PROBLEM= NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_FIXABLE_PROBLEM = NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_FIXABLE_ERROR = NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
// build console
public static final String IMG_VIEW_BUILD = NAME_PREFIX + "buildconsole.gif"; //$NON-NLS-1$
- public static final String IMG_SAVE_CONSOLE = NAME_PREFIX + "save_console.gif"; //$NON-NLS-1$
+ public static final String IMG_SAVE_CONSOLE = NAME_PREFIX + "save_console.gif"; //$NON-NLS-1$
// unknown type
public static final String IMG_OBJS_UNKNOWN = NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
-
+
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_BUILD_CONSOLE = createManaged(T_VIEW, IMG_VIEW_BUILD);
+ @Deprecated
+ public static final ImageDescriptor DESC_BUILD_CONSOLE = createManaged(T_VIEW, IMG_VIEW_BUILD);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_VARIABLE= createManaged(T_OBJ, IMG_OBJS_VARIABLE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_VARIABLE = createManaged(T_OBJ, IMG_OBJS_VARIABLE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= createManaged(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE = createManaged(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CLASS= createManaged(T_OBJ, IMG_OBJS_CLASS);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CLASS = createManaged(T_OBJ, IMG_OBJS_CLASS);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_NAMESPACE= createManaged(T_OBJ, IMG_OBJS_NAMESPACE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_NAMESPACE = createManaged(T_OBJ, IMG_OBJS_NAMESPACE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_USING = createManaged(T_OBJ, IMG_OBJS_USING);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_USING = createManaged(T_OBJ, IMG_OBJS_USING);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_STRUCT= createManaged(T_OBJ, IMG_OBJS_STRUCT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_STRUCT = createManaged(T_OBJ, IMG_OBJS_STRUCT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_UNION= createManaged(T_OBJ, IMG_OBJS_UNION);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_UNION = createManaged(T_OBJ, IMG_OBJS_UNION);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TYPEDEF= createManaged(T_OBJ, IMG_OBJS_TYPEDEF);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TYPEDEF = createManaged(T_OBJ, IMG_OBJS_TYPEDEF);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_ENUMERATION= createManaged(T_OBJ, IMG_OBJS_ENUMERATION);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_ENUMERATION = createManaged(T_OBJ, IMG_OBJS_ENUMERATION);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_UNKNOWN_TYPE= createManaged(T_OBJ, IMG_OBJS_UNKNOWN_TYPE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_UNKNOWN_TYPE = createManaged(T_OBJ, IMG_OBJS_UNKNOWN_TYPE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_ENUMERATOR= createManaged(T_OBJ, IMG_OBJS_ENUMERATOR);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_ENUMERATOR = createManaged(T_OBJ, IMG_OBJS_ENUMERATOR);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_FUNCTION= createManaged(T_OBJ, IMG_OBJS_FUNCTION);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_FUNCTION = createManaged(T_OBJ, IMG_OBJS_FUNCTION);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_PUBLIC_METHOD= createManaged(T_OBJ, IMG_OBJS_PUBLIC_METHOD);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_PUBLIC_METHOD = createManaged(T_OBJ, IMG_OBJS_PUBLIC_METHOD);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_PROTECTED_METHOD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_METHOD);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_PROTECTED_METHOD = createManaged(T_OBJ, IMG_OBJS_PROTECTED_METHOD);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_PRIVATE_METHOD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_METHOD);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_PRIVATE_METHOD = createManaged(T_OBJ, IMG_OBJS_PRIVATE_METHOD);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_PUBLIC_FIELD= createManaged(T_OBJ, IMG_OBJS_PUBLIC_FIELD);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_PUBLIC_FIELD = createManaged(T_OBJ, IMG_OBJS_PUBLIC_FIELD);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_PROTECTED_FIELD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_FIELD);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_PROTECTED_FIELD = createManaged(T_OBJ, IMG_OBJS_PROTECTED_FIELD);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_PRIVATE_FIELD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_FIELD);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_PRIVATE_FIELD = createManaged(T_OBJ, IMG_OBJS_PRIVATE_FIELD);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_KEYWORD= createManaged(T_OBJ, IMG_OBJS_KEYWORD);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_KEYWORD = createManaged(T_OBJ, IMG_OBJS_KEYWORD);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CLASS_ALT= createManaged(T_OBJ, IMG_OBJS_CLASS_ALT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CLASS_ALT = createManaged(T_OBJ, IMG_OBJS_CLASS_ALT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_STRUCT_ALT= createManaged(T_OBJ, IMG_OBJS_STRUCT_ALT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_STRUCT_ALT = createManaged(T_OBJ, IMG_OBJS_STRUCT_ALT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_UNION_ALT= createManaged(T_OBJ, IMG_OBJS_UNION_ALT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_UNION_ALT = createManaged(T_OBJ, IMG_OBJS_UNION_ALT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TYPEDEF_ALT= createManaged(T_OBJ, IMG_OBJS_TYPEDEF_ALT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TYPEDEF_ALT = createManaged(T_OBJ, IMG_OBJS_TYPEDEF_ALT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_ENUMERATION_ALT= createManaged(T_OBJ, IMG_OBJS_ENUMERATION_ALT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_ENUMERATION_ALT = createManaged(T_OBJ, IMG_OBJS_ENUMERATION_ALT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_DECLARARION= createManaged(T_OBJ, IMG_OBJS_DECLARATION);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_DECLARARION = createManaged(T_OBJ, IMG_OBJS_DECLARATION);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_VAR_DECLARARION= createManaged(T_OBJ, IMG_OBJS_VAR_DECLARATION);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_VAR_DECLARARION = createManaged(T_OBJ, IMG_OBJS_VAR_DECLARATION);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDE= createManaged(T_OBJ, IMG_OBJS_INCLUDE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_INCLUDE = createManaged(T_OBJ, IMG_OBJS_INCLUDE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_MACRO= createManaged(T_OBJ, IMG_OBJS_MACRO);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_MACRO = createManaged(T_OBJ, IMG_OBJS_MACRO);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_LABEL= createManaged(T_OBJ, IMG_OBJS_LABEL);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_LABEL = createManaged(T_OBJ, IMG_OBJS_LABEL);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT= createManaged(T_OBJ, IMG_OBJS_TUNIT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TUNIT = createManaged(T_OBJ, IMG_OBJS_TUNIT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_HEADER= createManaged(T_OBJ, IMG_OBJS_TUNIT_HEADER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TUNIT_HEADER = createManaged(T_OBJ, IMG_OBJS_TUNIT_HEADER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_ASM= createManaged(T_OBJ, IMG_OBJS_TUNIT_ASM);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TUNIT_ASM = createManaged(T_OBJ, IMG_OBJS_TUNIT_ASM);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE = createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_H= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_H);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_H = createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_H);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_A= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_A);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_A = createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_A);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SOURCE_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE_ROOT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SOURCE_ROOT = createManaged(T_OBJ, IMG_OBJS_SOURCE_ROOT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SOURCE2_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE2_ROOT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SOURCE2_ROOT = createManaged(T_OBJ, IMG_OBJS_SOURCE2_ROOT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_FOLDER= createManaged(T_OBJ, IMG_OBJS_FOLDER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_FOLDER = createManaged(T_OBJ, IMG_OBJS_FOLDER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CFOLDER= createManaged(T_OBJ, IMG_OBJS_CFOLDER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CFOLDER = createManaged(T_OBJ, IMG_OBJS_CFOLDER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CONFIG = createManaged(T_OBJ, IMG_OBJS_CONFIG);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CONFIG = createManaged(T_OBJ, IMG_OBJS_CONFIG);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_ARCHIVE= createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_ARCHIVE = createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_ARCHIVE_WSRC= createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_ARCHIVE_WSRC = createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_BINARY= createManaged(T_OBJ, IMG_OBJS_BINARY);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_BINARY = createManaged(T_OBJ, IMG_OBJS_BINARY);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SHLIB= createManaged(T_OBJ, IMG_OBJS_SHLIB);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SHLIB = createManaged(T_OBJ, IMG_OBJS_SHLIB);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CEXEC= createManaged(T_OBJ, IMG_OBJS_CEXEC);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CEXEC = createManaged(T_OBJ, IMG_OBJS_CEXEC);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CEXEC_DEBUG= createManaged(T_OBJ, IMG_OBJS_CEXEC_DEBUG);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CEXEC_DEBUG = createManaged(T_OBJ, IMG_OBJS_CEXEC_DEBUG);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CORE= createManaged(T_OBJ, IMG_OBJS_CORE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CORE = createManaged(T_OBJ, IMG_OBJS_CORE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CONTAINER= createManaged(T_OBJ, IMG_OBJS_CONTAINER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CONTAINER = createManaged(T_OBJ, IMG_OBJS_CONTAINER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_ARCHIVES_CONTAINER= createManaged(T_OBJ, IMG_OBJS_ARCHIVES_CONTAINER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_ARCHIVES_CONTAINER = createManaged(T_OBJ,
+ IMG_OBJS_ARCHIVES_CONTAINER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_BINARIES_CONTAINER= createManaged(T_OBJ, IMG_OBJS_BINARIES_CONTAINER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_BINARIES_CONTAINER = createManaged(T_OBJ,
+ IMG_OBJS_BINARIES_CONTAINER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER= createManaged(T_OBJ, IMG_OBJS_OUTPUT_FOLDER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER = createManaged(T_OBJ, IMG_OBJS_OUTPUT_FOLDER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_LIBRARY= createManaged(T_OBJ, IMG_OBJS_LIBRARY);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_LIBRARY = createManaged(T_OBJ, IMG_OBJS_LIBRARY);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDES_CONTAINER= createManaged(T_OBJ, IMG_OBJS_INCLUDES_CONTAINER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_INCLUDES_CONTAINER = createManaged(T_OBJ,
+ IMG_OBJS_INCLUDES_CONTAINER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER= createManaged(T_OBJ, IMG_OBJS_INCLUDES_FOLDER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER = createManaged(T_OBJ, IMG_OBJS_INCLUDES_FOLDER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_QUOTE_INCLUDES_FOLDER= createManaged(T_OBJ, IMG_OBJS_QUOTE_INCLUDES_FOLDER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_QUOTE_INCLUDES_FOLDER = createManaged(T_OBJ,
+ IMG_OBJS_QUOTE_INCLUDES_FOLDER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER_SYSTEM = createManaged(T_OBJ, IMG_OBJS_INCLUDES_FOLDER_SYSTEM);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER_SYSTEM = createManaged(T_OBJ,
+ IMG_OBJS_INCLUDES_FOLDER_SYSTEM);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER_WORKSPACE= createManaged(T_OBJ, IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER_WORKSPACE = createManaged(T_OBJ,
+ IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_ORDER= createManaged(T_OBJ, IMG_OBJS_ORDER);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_ORDER = createManaged(T_OBJ, IMG_OBJS_ORDER);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB = createManaged(T_OBJ, IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB = createManaged(T_OBJ,
+ IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= createManaged(T_OBJ, IMG_OBJS_SOURCE_ATTACH_ATTRIB);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB = createManaged(T_OBJ,
+ IMG_OBJS_SOURCE_ATTACH_ATTRIB);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_IMPORT_SETTINGS = createManaged(T_OBJ, IMG_OBJS_IMPORT_SETTINGS);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_IMPORT_SETTINGS = createManaged(T_OBJ, IMG_OBJS_IMPORT_SETTINGS);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_EXPORT_SETTINGS = createManaged(T_OBJ, IMG_OBJS_EXPORT_SETTINGS);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_EXPORT_SETTINGS = createManaged(T_OBJ, IMG_OBJS_EXPORT_SETTINGS);
public static final ImageDescriptor DESC_OVR_PATH_INHERIT = createUnManaged(T_OVR, "path_inherit_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_OVERRIDES = createUnManaged(T_OBJ, "over_co.gif"); //$NON-NLS-1$
@@ -281,189 +352,224 @@ public class CPluginImages {
public static final ImageDescriptor DESC_OBJS_SHADOWS = createUnManaged(T_OBJ, "shad_co.gif"); //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM= createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM = createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR= createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR = createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_INCCONT= createManaged(T_OBJ, IMG_OBJS_INCCONT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_INCCONT = createManaged(T_OBJ, IMG_OBJS_INCCONT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_UNKNOWN = createManaged(T_OBJ, IMG_OBJS_UNKNOWN);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_UNKNOWN = createManaged(T_OBJ, IMG_OBJS_UNKNOWN);
// Breakpoint image descriptors
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_BREAKPOINT = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT );
- /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED );
- /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ACTIVE = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_ACTIVE );
-
- public static final String IMG_MENU_SHIFT_RIGHT= NAME_PREFIX + "shift_r_edit.gif"; //$NON-NLS-1$
- public static final String IMG_MENU_SHIFT_LEFT= NAME_PREFIX + "shift_l_edit.gif"; //$NON-NLS-1$
- public static final String IMG_MENU_OPEN_INCLUDE= NAME_PREFIX + "open_include.gif"; //$NON-NLS-1$
- public static final String IMG_MENU_GROUP_INCLUDE= NAME_PREFIX + "group_include.gif"; //$NON-NLS-1$
- public static final String IMG_MENU_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$
- public static final String IMG_MENU_CODE_ASSIST= NAME_PREFIX + "metharg_obj.gif"; //$NON-NLS-1$
- public static final String IMG_MENU_COLLAPSE_ALL= NAME_PREFIX + "collapseall.png"; //$NON-NLS-1$
- public static final String IMG_MENU_EXPAND_ALL= NAME_PREFIX + "expandall.png"; //$NON-NLS-1$
- public static final String IMG_CLEAR_CONSOLE= NAME_PREFIX + "clear_co.gif"; //$NON-NLS-1$
- public static final String IMG_SCROLL_LOCK= NAME_PREFIX + "lock_co.gif"; //$NON-NLS-1$
- public static final String IMG_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$
- public static final String IMG_TOOL_GOTO_PREV_ERROR= NAME_PREFIX + "prev_error_nav.gif"; //$NON-NLS-1$
- public static final String IMG_TOOL_GOTO_NEXT_ERROR= NAME_PREFIX + "next_error_nav.gif"; //$NON-NLS-1$
- public static final String IMG_EDIT_PROPERTIES= NAME_PREFIX + "prop_edt.gif"; //$NON-NLS-1$
-
- public static final String IMG_ACTION_HIDE_FIELDS= NAME_PREFIX + "fields_co.gif"; //$NON-NLS-1$
- public static final String IMG_ACTION_SHOW_PUBLIC= NAME_PREFIX + "public_co.gif"; //$NON-NLS-1$
- public static final String IMG_ACTION_HIDE_STATIC= NAME_PREFIX + "static_co.gif"; //$NON-NLS-1$
-
- public static final String IMG_ACTION_SHOW_REF_BY = NAME_PREFIX + "ch_callers.gif"; //$NON-NLS-1$
- public static final String IMG_ACTION_SHOW_RELATES_TO = NAME_PREFIX + "ch_callees.gif"; //$NON-NLS-1$
- public static final String IMG_ACTION_HIDE_INACTIVE = NAME_PREFIX + "filterInactive.gif"; //$NON-NLS-1$
- public static final String IMG_ACTION_HIDE_SYSTEM = NAME_PREFIX + "filterSystem.gif"; //$NON-NLS-1$
- public static final String IMG_ACTION_HIDE_MACROS = NAME_PREFIX + "filterDefines.gif"; //$NON-NLS-1$
- public static final String IMG_SHOW_NEXT= NAME_PREFIX + "search_next.gif"; //$NON-NLS-1$
- public static final String IMG_SHOW_PREV= NAME_PREFIX + "search_prev.gif"; //$NON-NLS-1$
-
- public static final String IMG_REFRESH= NAME_PREFIX + "refresh_nav.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_CANCEL= NAME_PREFIX + "progress_stop.gif"; //$NON-NLS-1$
-
- // view orientation
- public static final String IMG_LCL_HORIZONTAL_ORIENTATION= NAME_PREFIX + "th_horizontal.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_VERTICAL_ORIENTATION= NAME_PREFIX + "th_vertical.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_AUTOMATIC_ORIENTATION= NAME_PREFIX + "th_automatic.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SINGLE_ORIENTATION= NAME_PREFIX + "th_single.gif"; //$NON-NLS-1$
-
- // hierarchy kind
- public static final String IMG_LCL_TYPE_HIERARCHY= NAME_PREFIX + "hierarchy_co.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SUB_TYPE_HIERARCHY= NAME_PREFIX + "sub_co.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SUPER_TYPE_HIERARCHY= NAME_PREFIX + "super_co.gif"; //$NON-NLS-1$
- public static final String IMG_LCL_SHOW_INHERITED_MEMBERS= NAME_PREFIX + "inher_co.gif"; //$NON-NLS-1$
-
- public static final String IMG_FILESYSTEM= NAME_PREFIX + "filesyst.gif"; //$NON-NLS-1$
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_BREAKPOINT = createManaged(T_OBJ, IMG_OBJS_BREAKPOINT);
+ /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged(T_OBJ,
+ IMG_OBJS_BREAKPOINT_DISABLED);
+ /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ACTIVE = createManaged(T_OBJ, IMG_OBJS_BREAKPOINT_ACTIVE);
+
+ public static final String IMG_MENU_SHIFT_RIGHT = NAME_PREFIX + "shift_r_edit.gif"; //$NON-NLS-1$
+ public static final String IMG_MENU_SHIFT_LEFT = NAME_PREFIX + "shift_l_edit.gif"; //$NON-NLS-1$
+ public static final String IMG_MENU_OPEN_INCLUDE = NAME_PREFIX + "open_include.gif"; //$NON-NLS-1$
+ public static final String IMG_MENU_GROUP_INCLUDE = NAME_PREFIX + "group_include.gif"; //$NON-NLS-1$
+ public static final String IMG_MENU_SEGMENT_EDIT = NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$
+ public static final String IMG_MENU_CODE_ASSIST = NAME_PREFIX + "metharg_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_MENU_COLLAPSE_ALL = NAME_PREFIX + "collapseall.png"; //$NON-NLS-1$
+ public static final String IMG_MENU_EXPAND_ALL = NAME_PREFIX + "expandall.png"; //$NON-NLS-1$
+ public static final String IMG_CLEAR_CONSOLE = NAME_PREFIX + "clear_co.gif"; //$NON-NLS-1$
+ public static final String IMG_SCROLL_LOCK = NAME_PREFIX + "lock_co.gif"; //$NON-NLS-1$
+ public static final String IMG_ALPHA_SORTING = NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$
+ public static final String IMG_TOOL_GOTO_PREV_ERROR = NAME_PREFIX + "prev_error_nav.gif"; //$NON-NLS-1$
+ public static final String IMG_TOOL_GOTO_NEXT_ERROR = NAME_PREFIX + "next_error_nav.gif"; //$NON-NLS-1$
+ public static final String IMG_EDIT_PROPERTIES = NAME_PREFIX + "prop_edt.gif"; //$NON-NLS-1$
+
+ public static final String IMG_ACTION_HIDE_FIELDS = NAME_PREFIX + "fields_co.gif"; //$NON-NLS-1$
+ public static final String IMG_ACTION_SHOW_PUBLIC = NAME_PREFIX + "public_co.gif"; //$NON-NLS-1$
+ public static final String IMG_ACTION_HIDE_STATIC = NAME_PREFIX + "static_co.gif"; //$NON-NLS-1$
+
+ public static final String IMG_ACTION_SHOW_REF_BY = NAME_PREFIX + "ch_callers.gif"; //$NON-NLS-1$
+ public static final String IMG_ACTION_SHOW_RELATES_TO = NAME_PREFIX + "ch_callees.gif"; //$NON-NLS-1$
+ public static final String IMG_ACTION_HIDE_INACTIVE = NAME_PREFIX + "filterInactive.gif"; //$NON-NLS-1$
+ public static final String IMG_ACTION_HIDE_SYSTEM = NAME_PREFIX + "filterSystem.gif"; //$NON-NLS-1$
+ public static final String IMG_ACTION_HIDE_MACROS = NAME_PREFIX + "filterDefines.gif"; //$NON-NLS-1$
+ public static final String IMG_SHOW_NEXT = NAME_PREFIX + "search_next.gif"; //$NON-NLS-1$
+ public static final String IMG_SHOW_PREV = NAME_PREFIX + "search_prev.gif"; //$NON-NLS-1$
+
+ public static final String IMG_REFRESH = NAME_PREFIX + "refresh_nav.gif"; //$NON-NLS-1$
+ public static final String IMG_LCL_CANCEL = NAME_PREFIX + "progress_stop.gif"; //$NON-NLS-1$
+
+ // view orientation
+ public static final String IMG_LCL_HORIZONTAL_ORIENTATION = NAME_PREFIX + "th_horizontal.gif"; //$NON-NLS-1$
+ public static final String IMG_LCL_VERTICAL_ORIENTATION = NAME_PREFIX + "th_vertical.gif"; //$NON-NLS-1$
+ public static final String IMG_LCL_AUTOMATIC_ORIENTATION = NAME_PREFIX + "th_automatic.gif"; //$NON-NLS-1$
+ public static final String IMG_LCL_SINGLE_ORIENTATION = NAME_PREFIX + "th_single.gif"; //$NON-NLS-1$
+
+ // hierarchy kind
+ public static final String IMG_LCL_TYPE_HIERARCHY = NAME_PREFIX + "hierarchy_co.gif"; //$NON-NLS-1$
+ public static final String IMG_LCL_SUB_TYPE_HIERARCHY = NAME_PREFIX + "sub_co.gif"; //$NON-NLS-1$
+ public static final String IMG_LCL_SUPER_TYPE_HIERARCHY = NAME_PREFIX + "super_co.gif"; //$NON-NLS-1$
+ public static final String IMG_LCL_SHOW_INHERITED_MEMBERS = NAME_PREFIX + "inher_co.gif"; //$NON-NLS-1$
+
+ public static final String IMG_FILESYSTEM = NAME_PREFIX + "filesyst.gif"; //$NON-NLS-1$
public static final String IMG_WORKSPACE = NAME_PREFIX + "workspace.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_FILESYSTEM = createManaged(T_OBJ, IMG_FILESYSTEM);
- /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_WORKSPACE = createManaged(T_OBJ, IMG_WORKSPACE);
- /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
-
- public static final ImageDescriptor DESC_OVR_STATIC= createUnManaged(T_OVR, "static_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_CONSTANT= createUnManaged(T_OVR, "c_ovr.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_VOLATILE= createUnManaged(T_OVR, "volatile_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_TEMPLATE= createUnManaged(T_OVR, "template_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_RELATESTO= createUnManaged(T_OVR, "relatesto_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_RELATESTOMULTIPLE= createUnManaged(T_OVR, "relatestoMultiple_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_REFERENCEDBY= createUnManaged(T_OVR, "referencedby_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_REC_RELATESTO= createUnManaged(T_OVR, "rec_relatesto_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_REC_REFERENCEDBY= createUnManaged(T_OVR, "rec_referencedby_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_SYSTEM_INCLUDE= createUnManaged(T_OVR, "systeminclude_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_DEFINES= createUnManaged(T_OVR, "defines_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_INACTIVE= createUnManaged(T_OVR, "inactive_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_READ_ACCESS= createUnManaged(T_OVR, "read.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_READ_WRITE_ACCESS= createUnManaged(T_OVR, "readwrite.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_WRITE_ACCESS= createUnManaged(T_OVR, "write.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_EXTERNAL_FILE= createUnManaged(T_OVR, "external_file.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_SETTING= createUnManaged(T_OVR, "setting_nav.gif"); //$NON-NLS-1$
-
- public static final ImageDescriptor DESC_OVR_WARNING= createUnManaged(T_OVR, "warning_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OVR_ERROR= createUnManaged(T_OVR, "error_co.gif"); //$NON-NLS-1$
-
-
- public static final ImageDescriptor DESC_WIZABAN_NEW_PROJ= createUnManaged(T_WIZBAN, "newcprj_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= createUnManaged(T_WIZBAN, "newclass_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZABAN_C_APP= createUnManaged(T_WIZBAN, "c_app_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEW_FILE= createUnManaged(T_WIZBAN, "newfile_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEW_HEADERFILE= createUnManaged(T_WIZBAN, "newhfile_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEW_SOURCEFILE= createUnManaged(T_WIZBAN, "newcfile_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR= createUnManaged(T_WIZBAN, "newsrcfldr_wiz.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_EXPORTINDEX= createUnManaged(T_WIZBAN, "exportzip_wiz.png"); //$NON-NLS-1$
+ @Deprecated
+ public static final ImageDescriptor DESC_FILESYSTEM = createManaged(T_OBJ, IMG_FILESYSTEM);
+ /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+ @Deprecated
+ public static final ImageDescriptor DESC_WORKSPACE = createManaged(T_OBJ, IMG_WORKSPACE);
+ /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_TEMPLATE = createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
+
+ public static final ImageDescriptor DESC_OVR_STATIC = createUnManaged(T_OVR, "static_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_CONSTANT = createUnManaged(T_OVR, "c_ovr.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_VOLATILE = createUnManaged(T_OVR, "volatile_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_TEMPLATE = createUnManaged(T_OVR, "template_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_RELATESTO = createUnManaged(T_OVR, "relatesto_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_RELATESTOMULTIPLE = createUnManaged(T_OVR, "relatestoMultiple_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_REFERENCEDBY = createUnManaged(T_OVR, "referencedby_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_REC_RELATESTO = createUnManaged(T_OVR, "rec_relatesto_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_REC_REFERENCEDBY = createUnManaged(T_OVR, "rec_referencedby_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_SYSTEM_INCLUDE = createUnManaged(T_OVR, "systeminclude_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_DEFINES = createUnManaged(T_OVR, "defines_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_INACTIVE = createUnManaged(T_OVR, "inactive_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_READ_ACCESS = createUnManaged(T_OVR, "read.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_READ_WRITE_ACCESS = createUnManaged(T_OVR, "readwrite.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_WRITE_ACCESS = createUnManaged(T_OVR, "write.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_EXTERNAL_FILE = createUnManaged(T_OVR, "external_file.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_SETTING = createUnManaged(T_OVR, "setting_nav.gif"); //$NON-NLS-1$
+
+ public static final ImageDescriptor DESC_OVR_WARNING = createUnManaged(T_OVR, "warning_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_ERROR = createUnManaged(T_OVR, "error_co.gif"); //$NON-NLS-1$
+
+ public static final ImageDescriptor DESC_WIZABAN_NEW_PROJ = createUnManaged(T_WIZBAN, "newcprj_wiz.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_NEWCLASS = createUnManaged(T_WIZBAN, "newclass_wiz.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZABAN_C_APP = createUnManaged(T_WIZBAN, "c_app_wiz.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_NEW_FILE = createUnManaged(T_WIZBAN, "newfile_wiz.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_NEW_HEADERFILE = createUnManaged(T_WIZBAN, "newhfile_wiz.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_NEW_SOURCEFILE = createUnManaged(T_WIZBAN, "newcfile_wiz.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR = createUnManaged(T_WIZBAN, "newsrcfldr_wiz.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_EXPORTINDEX = createUnManaged(T_WIZBAN, "exportzip_wiz.png"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_ADD_LIBRARY = createUnManaged(T_WIZBAN, "addpath_wiz.gif"); //$NON-NLS-1$
// For the build image
- public static final String IMG_OBJS_BUILD= NAME_PREFIX + "build_menu.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_BUILD = NAME_PREFIX + "build_menu.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_BUILD_MENU = createManaged(T_OBJ, IMG_OBJS_BUILD);
+ @Deprecated
+ public static final ImageDescriptor DESC_BUILD_MENU = createManaged(T_OBJ, IMG_OBJS_BUILD);
//for search
- public static final String IMG_OBJS_SEARCH_REF = NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_SEARCH_REF = NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_DECL = NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_LINE = NAME_PREFIX + "searchm_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_CSEARCH = NAME_PREFIX + "csearch_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_SEARCHFOLDER = NAME_PREFIX + "fldr_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_SEARCHPROJECT = NAME_PREFIX + "cprojects.gif"; //$NON-NLS-1$
-
+ public static final String IMG_OBJS_CSEARCH = NAME_PREFIX + "csearch_obj.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJS_SEARCHFOLDER = NAME_PREFIX + "fldr_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_SEARCHPROJECT = NAME_PREFIX + "cprojects.gif"; //$NON-NLS-1$
+
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCH_DECL = createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SEARCH_DECL = createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCH_REF = createManaged(T_OBJ, IMG_OBJS_SEARCH_REF);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SEARCH_REF = createManaged(T_OBJ, IMG_OBJS_SEARCH_REF);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCH_LINE = createManaged(T_OBJ, IMG_OBJS_SEARCH_LINE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SEARCH_LINE = createManaged(T_OBJ, IMG_OBJS_SEARCH_LINE);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_CSEARCH = createManaged(T_OBJ, IMG_OBJS_CSEARCH);
-
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_CSEARCH = createManaged(T_OBJ, IMG_OBJS_CSEARCH);
+
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCHHIERPROJECT = createManaged(T_OBJ,IMG_OBJS_SEARCHPROJECT);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SEARCHHIERPROJECT = createManaged(T_OBJ, IMG_OBJS_SEARCHPROJECT);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCHHIERFODLER = createManaged(T_OBJ,IMG_OBJS_SEARCHFOLDER);
-
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_SEARCHHIERFODLER = createManaged(T_OBJ, IMG_OBJS_SEARCHFOLDER);
+
// refactoring
- public static final String IMG_OBJS_REFACTORING_FATAL= NAME_PREFIX + "fatalerror_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_REFACTORING_ERROR= NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_REFACTORING_WARNING= NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_REFACTORING_INFO= NAME_PREFIX + "info_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_REFACTORING_FATAL = NAME_PREFIX + "fatalerror_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_REFACTORING_ERROR = NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_REFACTORING_WARNING = NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_REFACTORING_INFO = NAME_PREFIX + "info_obj.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_REFACTORING_FATAL= createManaged( T_OBJ, IMG_OBJS_REFACTORING_FATAL);
+ @Deprecated
+ public static final ImageDescriptor DESC_REFACTORING_FATAL = createManaged(T_OBJ, IMG_OBJS_REFACTORING_FATAL);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_REFACTORING_ERROR= createManaged( T_OBJ, IMG_OBJS_REFACTORING_ERROR);
+ @Deprecated
+ public static final ImageDescriptor DESC_REFACTORING_ERROR = createManaged(T_OBJ, IMG_OBJS_REFACTORING_ERROR);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_REFACTORING_WARNING= createManaged( T_OBJ, IMG_OBJS_REFACTORING_WARNING);
+ @Deprecated
+ public static final ImageDescriptor DESC_REFACTORING_WARNING = createManaged(T_OBJ, IMG_OBJS_REFACTORING_WARNING);
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_REFACTORING_INFO= createManaged ( T_OBJ, IMG_OBJS_REFACTORING_INFO);
-
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TU= createUnManaged(T_WIZBAN, "refactor_tu_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD= createUnManaged(T_WIZBAN, "refactor_field_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD= createUnManaged(T_WIZBAN, "refactor_method_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TYPE= createUnManaged(T_WIZBAN, "refactor_type_wiz.png"); //$NON-NLS-1$
+ @Deprecated
+ public static final ImageDescriptor DESC_REFACTORING_INFO = createManaged(T_OBJ, IMG_OBJS_REFACTORING_INFO);
+
+ public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TU = createUnManaged(T_WIZBAN, "refactor_tu_wiz.png"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD = createUnManaged(T_WIZBAN,
+ "refactor_field_wiz.png"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD = createUnManaged(T_WIZBAN,
+ "refactor_method_wiz.png"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TYPE = createUnManaged(T_WIZBAN, "refactor_type_wiz.png"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_DEFAULT_CHANGE= createUnManaged(T_OBJ, "change.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_COMPOSITE_CHANGE= createUnManaged(T_OBJ, "composite_change.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_CU_CHANGE= createUnManaged(T_OBJ, "cu_change.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_FILE_CHANGE= createUnManaged(T_OBJ, "file_change.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_TEXT_EDIT= createUnManaged(T_OBJ, "text_edit.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OBJS_DEFAULT_CHANGE = createUnManaged(T_OBJ, "change.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OBJS_COMPOSITE_CHANGE = createUnManaged(T_OBJ, "composite_change.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OBJS_CU_CHANGE = createUnManaged(T_OBJ, "cu_change.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OBJS_FILE_CHANGE = createUnManaged(T_OBJ, "file_change.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OBJS_TEXT_EDIT = createUnManaged(T_OBJ, "text_edit.gif"); //$NON-NLS-1$
public static final String IMG_PREFERRED = NAME_PREFIX + "tc_preferred.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_PREFERRED = createManaged(T_OBJ, IMG_PREFERRED);
+ @Deprecated
+ public static final ImageDescriptor DESC_PREFERRED = createManaged(T_OBJ, IMG_PREFERRED);
public static final String IMG_EMPTY = NAME_PREFIX + "tc_empty.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_EMPTY = createManaged(T_OBJ, IMG_EMPTY);
+ @Deprecated
+ public static final ImageDescriptor DESC_EMPTY = createManaged(T_OBJ, IMG_EMPTY);
- public static final ImageDescriptor DESC_DLCL_CONFIGURE_ANNOTATIONS= createUnManaged(T_DLCL, "configure_annotations.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_CONFIGURE_ANNOTATIONS= createUnManaged(T_ELCL, "configure_annotations.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DLCL_VIEW_MENU= createUnManaged(T_DLCL, "view_menu.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ELCL_VIEW_MENU= createUnManaged(T_ELCL, "view_menu.gif"); //$NON-NLS-1$
-
- public static final String IMG_OBJS_QUICK_ASSIST= NAME_PREFIX + "quickassist_obj.gif"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_DLCL_CONFIGURE_ANNOTATIONS = createUnManaged(T_DLCL,
+ "configure_annotations.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_ELCL_CONFIGURE_ANNOTATIONS = createUnManaged(T_ELCL,
+ "configure_annotations.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_DLCL_VIEW_MENU = createUnManaged(T_DLCL, "view_menu.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_ELCL_VIEW_MENU = createUnManaged(T_ELCL, "view_menu.gif"); //$NON-NLS-1$
+
+ public static final String IMG_OBJS_QUICK_ASSIST = NAME_PREFIX + "quickassist_obj.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_QUICK_ASSIST = createManaged(T_OBJ, IMG_OBJS_QUICK_ASSIST);
- public static final String IMG_CORRECTION_ADD= NAME_PREFIX + "correction_add.gif"; //$NON-NLS-1$
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_QUICK_ASSIST = createManaged(T_OBJ, IMG_OBJS_QUICK_ASSIST);
+ public static final String IMG_CORRECTION_ADD = NAME_PREFIX + "correction_add.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_CORRECTION_ADD = createManaged(T_OBJ, IMG_CORRECTION_ADD);
- public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
+ @Deprecated
+ public static final ImageDescriptor DESC_CORRECTION_ADD = createManaged(T_OBJ, IMG_CORRECTION_ADD);
+ public static final String IMG_CORRECTION_CHANGE = NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_CORRECTION_CHANGE = createManaged(T_OBJ, IMG_CORRECTION_CHANGE);
- public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$
+ @Deprecated
+ public static final ImageDescriptor DESC_CORRECTION_CHANGE = createManaged(T_OBJ, IMG_CORRECTION_CHANGE);
+ public static final String IMG_CORRECTION_RENAME = NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_CORRECTION_RENAME = createManaged(T_OBJ, IMG_CORRECTION_RENAME);
- public static final String IMG_CORRECTION_LINKED_RENAME= NAME_PREFIX + "correction_linked_rename.gif"; //$NON-NLS-1$
+ @Deprecated
+ public static final ImageDescriptor DESC_CORRECTION_RENAME = createManaged(T_OBJ, IMG_CORRECTION_RENAME);
+ public static final String IMG_CORRECTION_LINKED_RENAME = NAME_PREFIX + "correction_linked_rename.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_CORRECTION_LINKED_RENAME = createManaged(T_OBJ, IMG_CORRECTION_LINKED_RENAME);
+ @Deprecated
+ public static final ImageDescriptor DESC_CORRECTION_LINKED_RENAME = createManaged(T_OBJ,
+ IMG_CORRECTION_LINKED_RENAME);
- public static final String IMG_OBJS_NLS_NEVER_TRANSLATE= NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_NLS_NEVER_TRANSLATE = NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$
/** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
- @Deprecated public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE = createManaged(T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE);
+ @Deprecated
+ public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE = createManaged(T_OBJ,
+ IMG_OBJS_NLS_NEVER_TRANSLATE);
public static final ImageDescriptor DESC_ELCL_NAVIGATE_BACKWARD = createUnManaged(T_ELCL, "backward_nav.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_ELCL_NAVIGATE_FORWARD = createUnManaged(T_ELCL, "forward_nav.gif"); //$NON-NLS-1$
@@ -471,17 +577,19 @@ public class CPluginImages {
// incorrectly defined descriptors
/** @deprecated as of CDT 8.0. */
- @Deprecated public static final ImageDescriptor IMG_SAVE_CONSOLE_DESC = null;
+ @Deprecated
+ public static final ImageDescriptor IMG_SAVE_CONSOLE_DESC = null;
/** @deprecated as of CDT 8.0. */
- @Deprecated public static final ImageDescriptor DESC_OVR_FOCUS = null;
+ @Deprecated
+ public static final ImageDescriptor DESC_OVR_FOCUS = null;
/** @deprecated as of CDT 8.0. */
- @Deprecated public static final ImageDescriptor DESC_TOOL_NEWCLASS = null;
+ @Deprecated
+ public static final ImageDescriptor DESC_TOOL_NEWCLASS = null;
-
/**
* Creates an image descriptor which is managed by internal registry in CDTSharedImages.
* {@code name} is assumed to start with "org.eclipse.cdt.ui."
- *
+ *
* @deprecated as of CDT 8.0 with deprecation of {@link #get(String)}.
*/
@Deprecated
@@ -495,14 +603,14 @@ public class CPluginImages {
}
return ImageDescriptor.getMissingImageDescriptor();
}
-
+
/**
* Get an image from internal image registry. The image is managed by the registry and
* must not be disposed by the caller.
- *
+ *
* @param key - one of {@code CPluginImages.IMG_} constants.
* @return the image corresponding the given key.
- *
+ *
* @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImage(String)}.
*/
@Deprecated
@@ -510,7 +618,7 @@ public class CPluginImages {
String pathKey = fPathMap.get(key);
return CDTSharedImages.getImage(pathKey);
}
-
+
/**
* Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
* contain variables like $NL$.
@@ -519,10 +627,10 @@ public class CPluginImages {
* or <code>null</code>.
*/
private static ImageDescriptor create(String prefix, String name, boolean useMissingImageDescriptor) {
- IPath path= ICONS_PATH.append(prefix).append(name);
+ IPath path = ICONS_PATH.append(prefix).append(name);
return createImageDescriptor(CUIPlugin.getDefault().getBundle(), path, useMissingImageDescriptor);
}
-
+
/**
* Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
* contain variables like $NL$.
@@ -536,7 +644,7 @@ public class CPluginImages {
}
return ImageDescriptor.getMissingImageDescriptor();
}
-
+
/**
* Creates an image descriptor for the given path in a bundle. The path can contain variables
* like $NL$.
@@ -545,11 +653,11 @@ public class CPluginImages {
* Added for 3.1.1.
*/
public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor) {
- URL url= FileLocator.find(bundle, path, null);
+ URL url = FileLocator.find(bundle, path, null);
if (url != null) {
return ImageDescriptor.createFromURL(url);
}
-
+
Exception e = new Exception(NLS.bind(CUIMessages.CPluginImages_MissingImage, path, bundle.getSymbolicName()));
CUIPlugin.log(e.getMessage(), e);
@@ -562,18 +670,18 @@ public class CPluginImages {
/**
* Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
* are retrieved from the *tool16 folders.
- *
+ *
* @param action the action
* @param iconName the icon name
*/
public static void setToolImageDescriptors(IAction action, String iconName) {
setImageDescriptors(action, T_TOOL, iconName);
}
-
+
/**
* Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
* are retrieved from the *lcl16 folders.
- *
+ *
* @param action the action
* @param iconName the icon name
*/
@@ -583,12 +691,12 @@ public class CPluginImages {
/**
* Sets all available image descriptors for the given action.
- */
+ */
public static void setImageDescriptors(IAction action, String type, String relPath) {
- if (relPath.startsWith(NAME_PREFIX))
- relPath= relPath.substring(NAME_PREFIX_LENGTH);
+ if (relPath.startsWith(NAME_PREFIX))
+ relPath = relPath.substring(NAME_PREFIX_LENGTH);
action.setDisabledImageDescriptor(createUnManaged(("d" + type), relPath)); //$NON-NLS-1$
-// action.setHoverImageDescriptor(create("c" + type, relPath)); //$NON-NLS-1$
+ // action.setHoverImageDescriptor(create("c" + type, relPath)); //$NON-NLS-1$
action.setImageDescriptor(createUnManaged(("e" + type), relPath)); //$NON-NLS-1$
// We are still not sure about this, let see TF results first.
@@ -597,7 +705,7 @@ public class CPluginImages {
//ImageDescriptor desc = getImageRegistry().getDescriptor(relPath);
//if(desc == null) {
// desc = createManaged(T + "c" + type, relPath);
- //}
+ //}
//action.setImageDescriptor(desc);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java
index b64b32dabda..146f3ff07ab 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java
@@ -32,7 +32,7 @@ public class CProjectAdapterFactory implements IAdapterFactory {
@SuppressWarnings("unchecked")
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (IProject.class.equals(adapterType)) {
- return (T) ((ICProject)adaptableObject).getProject();
+ return (T) ((ICProject) adaptableObject).getProject();
}
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java
index 7f66d2f55d8..1d86dad4599 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java
@@ -15,25 +15,24 @@
package org.eclipse.cdt.internal.ui;
/**
- * Defines status codes relevant to the C UI plug-in. When a
+ * Defines status codes relevant to the C UI plug-in. When a
* Core exception is thrown, it contain a status object describing
* the cause of the exception. The status objects originating from the
* C UI plug-in use the codes defined in this interface.
*/
public class CStatusConstants {
-
+
// Prevent instantiation
private CStatusConstants() {
}
/** Status code describing an internal error */
- public static final int INTERNAL_ERROR= 1;
-
+ public static final int INTERNAL_ERROR = 1;
+
/**
* Status constant indicating that an exception occured on
* storing or loading templates.
*/
public static final int TEMPLATE_IO_EXCEPTION = 2;
-
-}
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java
index 9b8a1d7a4af..40297310b0b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java
@@ -23,7 +23,7 @@ import org.eclipse.core.runtime.IStatus;
*/
public class CUIException extends CoreException {
-
+
/**
* Comment for <code>serialVersionUID</code>
*/
@@ -31,5 +31,5 @@ public class CUIException extends CoreException {
public CUIException(IStatus status) {
super(status);
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java
index 5b693293296..94fddb2b54f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java
@@ -26,15 +26,15 @@ public class CUIStatus extends Status {
public CUIStatus(int code, String message, Throwable throwable) {
super(IStatus.ERROR, CUIPlugin.getPluginId(), code, message, throwable);
}
-
+
private CUIStatus(int severity, int code, String message, Throwable throwable) {
super(severity, CUIPlugin.getPluginId(), code, message, throwable);
}
-
+
public static IStatus createError(int code, Throwable throwable) {
- String message= throwable.getMessage();
+ String message = throwable.getMessage();
if (message == null) {
- message= throwable.getClass().getName();
+ message = throwable.getClass().getName();
}
return new CUIStatus(IStatus.ERROR, code, message, throwable);
}
@@ -42,7 +42,7 @@ public class CUIStatus extends Status {
public static IStatus createError(int code, String message, Throwable throwable) {
return new CUIStatus(IStatus.ERROR, code, message, throwable);
}
-
+
public static IStatus createWarning(int code, String message, Throwable throwable) {
return new CUIStatus(IStatus.WARNING, code, message, throwable);
}
@@ -50,7 +50,5 @@ public class CUIStatus extends Status {
public static IStatus createInfo(int code, String message, Throwable throwable) {
return new CUIStatus(IStatus.INFO, code, message, throwable);
}
-
-}
-
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
index 1e408991499..43bc0f8c78c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
@@ -64,9 +64,8 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter {
@Override
public ImageDescriptor getImageDescriptor(Object element) {
if (element instanceof ICElement) {
- return fImageProvider.getCImageDescriptor(
- (ICElement) element,
- CElementImageProvider.OVERLAY_ICONS | CElementImageProvider.SMALL_ICONS);
+ return fImageProvider.getCImageDescriptor((ICElement) element,
+ CElementImageProvider.OVERLAY_ICONS | CElementImageProvider.SMALL_ICONS);
}
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java
index 14a784a6dd3..9303c60c628 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java
@@ -44,7 +44,7 @@ public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDef
return;
}
collector.add(children, monitor);
- collector.done();
+ collector.done();
}
/*
@@ -64,6 +64,6 @@ public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDef
*/
@Override
public ISchedulingRule getRule(final Object object) {
- return fCElement.getResource();
+ return fCElement.getResource();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
index d1bfdaafbd1..6afd5bcea5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
@@ -19,35 +19,36 @@ import java.io.InputStream;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+
/**
* Input stream which reads from a document
*/
public class DocumentInputStream extends InputStream {
-
+
private IDocument fDocument;
private int fCurrPos;
-
+
public DocumentInputStream(IDocument document) {
- fDocument= document;
- fCurrPos= 0;
+ fDocument = document;
+ fCurrPos = 0;
}
-
+
public IDocument getDocument() {
return fDocument;
}
-
+
/**
* {@inheritDoc}
*/
- @Override
+ @Override
public int read() throws IOException {
- try {
- if (fCurrPos < fDocument.getLength()) {
- return fDocument.getChar(fCurrPos++);
- }
- } catch (BadLocationException e) {
- }
- return -1;
+ try {
+ if (fCurrPos < fDocument.getLength()) {
+ return fDocument.getChar(fCurrPos++);
+ }
+ } catch (BadLocationException e) {
+ }
+ return -1;
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java
index b9e962f5cc8..aaaa0de2594 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java
@@ -19,46 +19,46 @@ package org.eclipse.cdt.internal.ui;
*/
public interface ICElementPropertyConstants {
- /**
+ /**
* The <code>ICElement</code> property key for elf cpu.
*/
- public static final String P_ELF_CPU = "elf_cpu"; //$NON-NLS-1$
+ public static final String P_ELF_CPU = "elf_cpu"; //$NON-NLS-1$
- /**
+ /**
* The <code>ICElement</code> property key for elf text.
*/
- public static final String P_ELF_TEXT = "text"; //$NON-NLS-1$
+ public static final String P_ELF_TEXT = "text"; //$NON-NLS-1$
- /**
+ /**
* The <code>ICElement</code> property key for elf data.
*/
- public static final String P_ELF_DATA = "data"; //$NON-NLS-1$
+ public static final String P_ELF_DATA = "data"; //$NON-NLS-1$
- /**
+ /**
* The <code>ICElement</code> property key for elf bss.
*/
- public static final String P_ELF_BSS = "bss"; //$NON-NLS-1$
+ public static final String P_ELF_BSS = "bss"; //$NON-NLS-1$
- /**
+ /**
* The <code>ICElement</code> property key for elf bss.
*/
- public static final String P_ELF_HAS_DEBUG = "debug"; //$NON-NLS-1$
+ public static final String P_ELF_HAS_DEBUG = "debug"; //$NON-NLS-1$
- /**
+ /**
* The <code>ICElement</code> property key for elf soname.
*/
- public static final String P_ELF_SONAME = "soname"; //$NON-NLS-1$
+ public static final String P_ELF_SONAME = "soname"; //$NON-NLS-1$
- /**
+ /**
* The <code>ICElement</code> property key for elf type.
*/
- public static final String P_ELF_TYPE = "type"; //$NON-NLS-1$
+ public static final String P_ELF_TYPE = "type"; //$NON-NLS-1$
- /**
+ /**
* The <code>ICElement</code> property key for elf type.
*/
- public static final String P_ELF_NEEDED = "needed"; //$NON-NLS-1$
+ public static final String P_ELF_NEEDED = "needed"; //$NON-NLS-1$
- public static final String P_BINARY_FILE_CATEGORY = CUIMessages.ICElementPropertyConstants_catagory;
+ public static final String P_BINARY_FILE_CATEGORY = CUIMessages.ICElementPropertyConstants_catagory;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
index 3f4d776e1fb..f5014ea764f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
@@ -41,16 +41,16 @@ public interface ICHelpContextIds {
// Actions
public static final String ADD_INCLUDE_ON_SELECTION_ACTION = PREFIX + "add_includes_on_selection_action_context"; //$NON-NLS-1$;
public static final String ORGANIZE_INCLUDES_ACTION = PREFIX + "organize_includes_action"; //$NON-NLS-1$;
- public static final String FILTER_PUBLIC_ACTION= PREFIX + "filter_public_action"; //$NON-NLS-1$
- public static final String FILTER_FIELDS_ACTION= PREFIX + "filter_fields_action"; //$NON-NLS-1$
- public static final String FILTER_STATIC_ACTION= PREFIX + "filter_static_action"; //$NON-NLS-1$
- public static final String FILTER_LOCALTYPES_ACTION= PREFIX + "filter_localtypes_action"; //$NON-NLS-1$
+ public static final String FILTER_PUBLIC_ACTION = PREFIX + "filter_public_action"; //$NON-NLS-1$
+ public static final String FILTER_FIELDS_ACTION = PREFIX + "filter_fields_action"; //$NON-NLS-1$
+ public static final String FILTER_STATIC_ACTION = PREFIX + "filter_static_action"; //$NON-NLS-1$
+ public static final String FILTER_LOCALTYPES_ACTION = PREFIX + "filter_localtypes_action"; //$NON-NLS-1$
- public static final String GOTO_NEXT_ERROR_ACTION= PREFIX + "goto_next_error_action"; //$NON-NLS-1$
- public static final String GOTO_PREVIOUS_ERROR_ACTION= PREFIX + "goto_previous_error_action"; //$NON-NLS-1$
- public static final String TOGGLE_MARK_OCCURRENCES_ACTION= PREFIX + "toggle_mark_occurrences_action_context"; //$NON-NLS-1$
- public static final String FORMAT_ALL= PREFIX + "format_all_action"; //$NON-NLS-1$
- public static final String GOTO_MATCHING_BRACKET_ACTION= PREFIX + "goto_matching_bracket_action"; //$NON-NLS-1$
+ public static final String GOTO_NEXT_ERROR_ACTION = PREFIX + "goto_next_error_action"; //$NON-NLS-1$
+ public static final String GOTO_PREVIOUS_ERROR_ACTION = PREFIX + "goto_previous_error_action"; //$NON-NLS-1$
+ public static final String TOGGLE_MARK_OCCURRENCES_ACTION = PREFIX + "toggle_mark_occurrences_action_context"; //$NON-NLS-1$
+ public static final String FORMAT_ALL = PREFIX + "format_all_action"; //$NON-NLS-1$
+ public static final String GOTO_MATCHING_BRACKET_ACTION = PREFIX + "goto_matching_bracket_action"; //$NON-NLS-1$
// Preference/property pages
public static final String C_PREF_PAGE = PREFIX + "c_pref"; //$NON-NLS-1$
@@ -84,17 +84,18 @@ public interface ICHelpContextIds {
public static final String PROJECT_PATHS_OUTPUT = PREFIX + "std_prop_output"; //$NON-NLS-1$
public static final String PROJECT_PATHS_PROJECTS = PREFIX + "std_prop_projects"; //$NON-NLS-1$
public static final String PROJECT_PATHS_LIBRARIES = PREFIX + "std_prop_libraries"; //$NON-NLS-1$
- public static final String PROJECT_PATHS_CONTAINERS = PREFIX + "std_prop_containers"; //$NON-NLS-1$
- public static final String PROJECT_REFERENCES = PREFIX + "std_prop_references"; //$NON-NLS-1$
- public static final String PROJECT_INCLUDE_PATHS_SYMBOLS = PREFIX + "std_prop_include"; //$NON-NLS-1$
+ public static final String PROJECT_PATHS_CONTAINERS = PREFIX + "std_prop_containers"; //$NON-NLS-1$
+ public static final String PROJECT_REFERENCES = PREFIX + "std_prop_references"; //$NON-NLS-1$
+ public static final String PROJECT_INCLUDE_PATHS_SYMBOLS = PREFIX + "std_prop_include"; //$NON-NLS-1$
public static final String APPEARANCE_PREFERENCE_PAGE = PREFIX + "appearance_preference_page_context"; //$NON-NLS-1$
- public static final String SPELLING_CONFIGURATION_BLOCK= PREFIX + "spelling_configuration_block_context"; //$NON-NLS-1$
+ public static final String SPELLING_CONFIGURATION_BLOCK = PREFIX + "spelling_configuration_block_context"; //$NON-NLS-1$
public static final String CODE_STYLE_PREFERENCE_PAGE = PREFIX + "code_style_preference_context"; //$NON-NLS-1$
public static final String CODE_TEMPLATES_PREFERENCE_PAGE = PREFIX + "code_templates_preference_context"; //$NON-NLS-1$
public static final String ORGANIZE_INCLUDES_PREFERENCE_PAGE = PREFIX + "organize_includes_preference_context"; //$NON-NLS-1$
public static final String HEADER_SUBSTITUTION_PREFERENCE_PAGE = PREFIX + "header_substitution_preference_context"; //$NON-NLS-1$
- public static final String HEADER_SUBSTITUTION_MAP_EDIT_DIALOG = PREFIX + "header_substitution_map_edit_dialog_context"; //$NON-NLS-1$
+ public static final String HEADER_SUBSTITUTION_MAP_EDIT_DIALOG = PREFIX
+ + "header_substitution_map_edit_dialog_context"; //$NON-NLS-1$
public static final String HEADER_SUBSTITUTION_EDIT_DIALOG = PREFIX + "header_substitution_edit_dialog_context"; //$NON-NLS-1$
public static final String INCLUDE_PRAGMAS_PREFERENCE_PAGE = PREFIX + "include_pragmas_preference_context"; //$NON-NLS-1$
public static final String INCLUDE_STYLE_PREFERENCE_PAGE = PREFIX + "include_style_preference_context"; //$NON-NLS-1$
@@ -115,63 +116,61 @@ public interface ICHelpContextIds {
public static final String COPY_ACTION = PREFIX + "copy_action_context"; //$NON-NLS-1$
// Custom Filters
- public static final String CUSTOM_FILTERS_DIALOG= PREFIX + "open_custom_filters_dialog_context"; //$NON-NLS-1$
-
+ public static final String CUSTOM_FILTERS_DIALOG = PREFIX + "open_custom_filters_dialog_context"; //$NON-NLS-1$
public static final String PASTE_ACTION = PREFIX + "paste_action_context"; //$NON_NLS-1$ //$NON-NLS-1$
public static final String MOVE_ACTION = PREFIX + "move_action_context"; //$NON-NLS-1$
public static final String RENAME_ACTION = PREFIX + "rename_action_context"; //$NON-NLS-1$
-
- public static final String REFACTORING_PREFERENCE_PAGE= PREFIX + "refactoring_preference_page_context"; //$NON-NLS-1$
- public static final String REFACTORING_ERROR_WIZARD_PAGE= PREFIX + "refactoring_error_wizard_page_context"; //$NON-NLS-1$
- public static final String REFACTORING_PREVIEW_WIZARD_PAGE= PREFIX + "refactoring_preview_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_PARAMS_WIZARD_PAGE= PREFIX + "rename_params_wizard_page"; //$NON-NLS-1$
- public static final String RENAME_METHOD_WIZARD_PAGE= PREFIX + "rename_method_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_TYPE_WIZARD_PAGE= PREFIX + "rename_type_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_FIELD_WIZARD_PAGE= PREFIX + "rename_field_wizard_page_context"; //$NON-NLS-1$
- public static final String RENAME_RESOURCE_WIZARD_PAGE= PREFIX + "rename_resource_wizard_page_context"; //$NON-NLS-1$
- public static final String EXTRACT_FUNCTION_WIZARD_PAGE= PREFIX + "extract_function_wizard_page_context"; //$NON-NLS-1$
+ public static final String REFACTORING_PREFERENCE_PAGE = PREFIX + "refactoring_preference_page_context"; //$NON-NLS-1$
+ public static final String REFACTORING_ERROR_WIZARD_PAGE = PREFIX + "refactoring_error_wizard_page_context"; //$NON-NLS-1$
+ public static final String REFACTORING_PREVIEW_WIZARD_PAGE = PREFIX + "refactoring_preview_wizard_page_context"; //$NON-NLS-1$
+ public static final String RENAME_PARAMS_WIZARD_PAGE = PREFIX + "rename_params_wizard_page"; //$NON-NLS-1$
+ public static final String RENAME_METHOD_WIZARD_PAGE = PREFIX + "rename_method_wizard_page_context"; //$NON-NLS-1$
+ public static final String RENAME_TYPE_WIZARD_PAGE = PREFIX + "rename_type_wizard_page_context"; //$NON-NLS-1$
+ public static final String RENAME_FIELD_WIZARD_PAGE = PREFIX + "rename_field_wizard_page_context"; //$NON-NLS-1$
+ public static final String RENAME_RESOURCE_WIZARD_PAGE = PREFIX + "rename_resource_wizard_page_context"; //$NON-NLS-1$
+ public static final String EXTRACT_FUNCTION_WIZARD_PAGE = PREFIX + "extract_function_wizard_page_context"; //$NON-NLS-1$
// Dialogs
public static final String EDIT_TEMPLATE_DIALOG = PREFIX + "edit_template_dialog_context"; //$NON-NLS-1$
public static final String OPEN_ELEMENT_DIALOG = PREFIX + "open_element_dialog_context"; //$NON-NLS-1$
// view parts
- public static final String TYPE_HIERARCHY_VIEW= PREFIX + "type_hierarchy_view_context"; //$NON-NLS-1$
- public static final String CALL_HIERARCHY_VIEW= PREFIX + "call_hierarchy_view_context"; //$NON-NLS-1$
- public static final String INCLUDE_BROWSER_VIEW= PREFIX + "include_browser_view_context"; //$NON-NLS-1$
+ public static final String TYPE_HIERARCHY_VIEW = PREFIX + "type_hierarchy_view_context"; //$NON-NLS-1$
+ public static final String CALL_HIERARCHY_VIEW = PREFIX + "call_hierarchy_view_context"; //$NON-NLS-1$
+ public static final String INCLUDE_BROWSER_VIEW = PREFIX + "include_browser_view_context"; //$NON-NLS-1$
public static final String OPEN_ACTION = PREFIX + "open_action"; //$NON-NLS-1$
public static final String OPEN_PROJECT_ACTION = PREFIX + "open_project_action"; //$NON-NLS-1$
public static final String OPEN_TYPE_ACTION = PREFIX + "open_type_action"; //$NON-NLS-1$
public static final String OPEN_TYPE_IN_HIERARCHY_ACTION = PREFIX + "open_type_in_hierarchy_action"; //$NON-NLS-1$
- public static final String OPEN_TYPE_HIERARCHY_ACTION = PREFIX + "open_type_hierarchy_action"; //$NON-NLS-1$
+ public static final String OPEN_TYPE_HIERARCHY_ACTION = PREFIX + "open_type_hierarchy_action"; //$NON-NLS-1$
public static final String SELECT_ALL_ACTION = PREFIX + "select_all_action"; //$NON-NLS-1$
public static final String LINK_EDITOR_ACTION = PREFIX + "link_editor_action"; //$NON-NLS-1$
public static final String TYPEHIERARCHY_HISTORY_ACTION = PREFIX + "typehierarchy_history_action"; //$NON-NLS-1$
public static final String HISTORY_ACTION = PREFIX + "history_action"; //$NON-NLS-1$
public static final String HISTORY_LIST_ACTION = PREFIX + "history_list_action"; //$NON-NLS-1$
- public static final String TOGGLE_ORIENTATION_ACTION = PREFIX + "toggle_orientations_action"; //$NON-NLS-1$
+ public static final String TOGGLE_ORIENTATION_ACTION = PREFIX + "toggle_orientations_action"; //$NON-NLS-1$
public static final String FOCUS_ON_TYPE_ACTION = PREFIX + "focus_on_type_action"; //$NON-NLS-1$
public static final String FOCUS_ON_SELECTION_ACTION = PREFIX + "focus_on_selection_action"; //$NON-NLS-1$
- public static final String HISTORY_LIST_DIALOG = PREFIX + "history_list_dialog_context"; //$NON-NLS-1$
+ public static final String HISTORY_LIST_DIALOG = PREFIX + "history_list_dialog_context"; //$NON-NLS-1$
public static final String SHOW_INHERITED_ACTION = PREFIX + "show_inherited_action"; //$NON-NLS-1$
public static final String SHOW_SUPERTYPES = PREFIX + "show_supertypes_action"; //$NON-NLS-1$
public static final String SHOW_SUBTYPES = PREFIX + "show_subtypes_action"; //$NON-NLS-1$
public static final String SHOW_HIERARCHY = PREFIX + "show_hierarchy_action"; //$NON-NLS-1$
- public static final String SORT_BY_DEFINING_TYPE_ACTION = PREFIX + "sort_by_defining_type_action"; //$NON-NLS-1$
- public static final String SHOW_QUALIFIED_NAMES_ACTION = PREFIX + "show_qualified_names_action"; //$NON-NLS-1$
+ public static final String SORT_BY_DEFINING_TYPE_ACTION = PREFIX + "sort_by_defining_type_action"; //$NON-NLS-1$
+ public static final String SHOW_QUALIFIED_NAMES_ACTION = PREFIX + "show_qualified_names_action"; //$NON-NLS-1$
public static final String ENABLE_METHODFILTER_ACTION = PREFIX + "enable_methodfilter_action"; //$NON-NLS-1$
-
+
public static final String LEXICAL_SORTING_BROWSING_ACTION = PREFIX + "lexical_sorting_browsing_action"; //$NON-NLS-1$
-
- public static final String PROJECT_INDEXER_PROPERTIES = PREFIX + "std_prop_indexer"; //$NON-NLS-1$
+
+ public static final String PROJECT_INDEXER_PROPERTIES = PREFIX + "std_prop_indexer"; //$NON-NLS-1$
public static final String CEDITOR_VIEW = PREFIX + "editor_view"; //$NON-NLS-1$
public static final String COUTLINE_VIEW = PREFIX + "outline_view"; //$NON-NLS-1$
public static final String CPROJECT_VIEW = PREFIX + "projects_view"; //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICStatusConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICStatusConstants.java
index 2f1f4d4be61..85785e55f54 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICStatusConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICStatusConstants.java
@@ -7,14 +7,14 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui;
/**
- * Defines status codes relevant to the CDT UI plug-in. When a
+ * Defines status codes relevant to the CDT UI plug-in. When a
* Core exception is thrown, it contain a status object describing
* the cause of the exception. The status objects originating from the
* CDT UI plug-in use the codes defined in this interface.
@@ -23,9 +23,9 @@ public interface ICStatusConstants {
// C UI status constants start at 10000 to make sure that we don't
// collide with resource and c model constants.
-
- public static final int INTERNAL_ERROR= 10001;
-
+
+ public static final int INTERNAL_ERROR = 10001;
+
/**
* Status constant indicating that an exception occurred on
* storing or loading templates.
@@ -36,13 +36,13 @@ public interface ICStatusConstants {
* Status constant indicating that an validateEdit call has changed the
* content of a file on disk.
*/
- public static final int VALIDATE_EDIT_CHANGED_CONTENT= 10003;
-
+ public static final int VALIDATE_EDIT_CHANGED_CONTENT = 10003;
+
/**
* Status constant indicating that a <tt>ChangeAbortException</tt> has been
* caught.
- */
- public static final int CHANGE_ABORTED= 10004;
+ */
+ public static final int CHANGE_ABORTED = 10004;
/**
* Status constant indicating that an exception occurred while
@@ -53,8 +53,8 @@ public interface ICStatusConstants {
/**
* Status constant indication that a problem occurred while calculating
* the changed region during a save.
- *
+ *
* @since 5.1
*/
- public static final int EDITOR_CHANGED_REGION_CALCULATION= 10006;
+ public static final int EDITOR_CHANGED_REGION_CALCULATION = 10006;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java
index 8f94b1adcb3..930219d4ad0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java
@@ -21,116 +21,122 @@ import org.eclipse.cdt.ui.PreferenceConstants;
* extension contributed by this plug-in.
*/
public interface ICThemeConstants {
- String ID_PREFIX= CUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+ String ID_PREFIX = CUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
/**
* A theme constant that holds the background color used in the code assist selection dialog.
*/
- public final String CODEASSIST_PROPOSALS_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
+ public final String CODEASSIST_PROPOSALS_BACKGROUND = ID_PREFIX
+ + PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
/**
* A theme constant that holds the foreground color used in the code assist selection dialog.
*/
- public final String CODEASSIST_PROPOSALS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
+ public final String CODEASSIST_PROPOSALS_FOREGROUND = ID_PREFIX
+ + PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
/**
* A theme constant that holds the background color used for parameter hints.
*/
- public final String CODEASSIST_PARAMETERS_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
+ public final String CODEASSIST_PARAMETERS_BACKGROUND = ID_PREFIX
+ + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
/**
* A theme constant that holds the foreground color used for parameter hints.
*/
- public final String CODEASSIST_PARAMETERS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
+ public final String CODEASSIST_PARAMETERS_FOREGROUND = ID_PREFIX
+ + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
/**
* A theme constant that holds the foreground color used for multi-line comments.
*/
- public final String EDITOR_MULTI_LINE_COMMENT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR;
+ public final String EDITOR_MULTI_LINE_COMMENT_COLOR = ID_PREFIX
+ + PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR;
/**
* A theme constant that holds the foreground color used for single-line comments.
*/
- public final String EDITOR_SINGLE_LINE_COMMENT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR;
+ public final String EDITOR_SINGLE_LINE_COMMENT_COLOR = ID_PREFIX
+ + PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR;
/**
* A theme constant that holds the foreground color used for C/C++ keywords.
*/
- public final String EDITOR_C_KEYWORD_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_KEYWORD_COLOR;
+ public final String EDITOR_C_KEYWORD_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_C_KEYWORD_COLOR;
/**
* A theme constant that holds the foreground color used for preprocessor directives.
*/
- public final String EDITOR_PP_DIRECTIVE_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR;
+ public final String EDITOR_PP_DIRECTIVE_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR;
/**
* A theme constant that holds the foreground color used for preprocessor headers (includes).
*/
- public final String EDITOR_PP_HEADER_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_PP_HEADER_COLOR;
+ public final String EDITOR_PP_HEADER_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_PP_HEADER_COLOR;
/**
* A theme constant that holds the foreground color used for preprocessor text.
*/
- public final String EDITOR_PP_DEFAULT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_PP_DEFAULT_COLOR;
+ public final String EDITOR_PP_DEFAULT_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_PP_DEFAULT_COLOR;
/**
* A theme constant that holds the foreground color used for C/C++ built-in types.
*/
- public final String EDITOR_C_BUILTIN_TYPE_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR;
+ public final String EDITOR_C_BUILTIN_TYPE_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR;
/**
* A theme constant that holds the foreground color used for string constants.
*/
- public final String EDITOR_C_STRING_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_STRING_COLOR;
+ public final String EDITOR_C_STRING_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_C_STRING_COLOR;
/**
* A theme constant that holds the foreground color used for operators.
*/
- public final String EDITOR_C_OPERATOR_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_OPERATOR_COLOR;
+ public final String EDITOR_C_OPERATOR_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_C_OPERATOR_COLOR;
/**
* A theme constant that holds the foreground color used for numbers.
*/
- public final String EDITOR_C_NUMBER_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_NUMBER_COLOR;
+ public final String EDITOR_C_NUMBER_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_C_NUMBER_COLOR;
/**
* A theme constant that holds the foreground color used for braces.
*/
- public final String EDITOR_C_BRACES_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_BRACES_COLOR;
+ public final String EDITOR_C_BRACES_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_C_BRACES_COLOR;
/**
* A theme constant that holds the foreground color used for C/C++ code.
*/
- public final String EDITOR_C_DEFAULT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_DEFAULT_COLOR;
+ public final String EDITOR_C_DEFAULT_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_C_DEFAULT_COLOR;
/**
* A theme constant that holds the foreground color used for assembly labels.
*/
- public final String EDITOR_ASM_LABEL_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_ASM_LABEL_COLOR;
+ public final String EDITOR_ASM_LABEL_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_ASM_LABEL_COLOR;
/**
* A theme constant that holds the foreground color used for assembly directives.
*/
- public final String EDITOR_ASM_DIRECTIVE_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR;
+ public final String EDITOR_ASM_DIRECTIVE_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR;
/**
* A theme constant that holds the foreground color used for task tags.
*/
- public final String EDITOR_TASK_TAG_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_TASK_TAG_COLOR;
+ public final String EDITOR_TASK_TAG_COLOR = ID_PREFIX + PreferenceConstants.EDITOR_TASK_TAG_COLOR;
/**
* A theme constant that holds the foreground color used for doxygen multi-line comments.
*/
- public final String DOXYGEN_MULTI_LINE_COLOR= PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR;
+ public final String DOXYGEN_MULTI_LINE_COLOR = PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR;
/**
* A theme constant that holds the foreground color used for doxygen single line comments.
*/
- public final String DOXYGEN_SINGLE_LINE_COLOR= PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR;
-
+ public final String DOXYGEN_SINGLE_LINE_COLOR = PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR;
+
/**
* A theme constant that holds the foreground color used for doxygen tags.
*/
- public final String DOXYGEN_TAG_COLOR= PreferenceConstants.DOXYGEN_TAG_COLOR;
-
+ public final String DOXYGEN_TAG_COLOR = PreferenceConstants.DOXYGEN_TAG_COLOR;
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java
index 94d6283c505..494a752acbe 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java
@@ -30,26 +30,26 @@ public interface IContextMenuConstants {
/**
* Type hierarchy view part: pop-up menu target ID for supertype hierarchy viewer
* (value <code>"org.eclipse.cdt.ui.TypeHierarchy.supertypes"</code>).
- *
+ *
* @since 2.0
*/
- public static final String TARGET_ID_SUPERTYPES_VIEW= CUIPlugin.ID_TYPE_HIERARCHY + ".supertypes"; //$NON-NLS-1$
+ public static final String TARGET_ID_SUPERTYPES_VIEW = CUIPlugin.ID_TYPE_HIERARCHY + ".supertypes"; //$NON-NLS-1$
/**
* Type hierarchy view part: Pop-up menu target ID for the subtype hierarchy viewer
* (value <code>"org.eclipse.cdt.ui.TypeHierarchy.subtypes"</code>).
- *
+ *
* @since 2.0
*/
- public static final String TARGET_ID_SUBTYPES_VIEW= CUIPlugin.ID_TYPE_HIERARCHY + ".subtypes"; //$NON-NLS-1$
+ public static final String TARGET_ID_SUBTYPES_VIEW = CUIPlugin.ID_TYPE_HIERARCHY + ".subtypes"; //$NON-NLS-1$
/**
* Type hierarchy view part: pop-up menu target ID for the member viewer
* (value <code>"org.eclipse.cdt.ui.TypeHierarchy.members"</code>).
- *
+ *
* @since 2.0
*/
- public static final String TARGET_ID_MEMBERS_VIEW= CUIPlugin.ID_TYPE_HIERARCHY + ".members"; //$NON-NLS-1$
+ public static final String TARGET_ID_MEMBERS_VIEW = CUIPlugin.ID_TYPE_HIERARCHY + ".members"; //$NON-NLS-1$
/**
* Pop-up menu: name of group for goto actions (value <code>"group.goto"</code>).
@@ -61,7 +61,7 @@ public interface IContextMenuConstants {
* </ul>
* </p>
*/
- public static final String GROUP_GOTO= ICommonMenuConstants.GROUP_GOTO;
+ public static final String GROUP_GOTO = ICommonMenuConstants.GROUP_GOTO;
/**
* Pop-up menu: name of group for open actions (value <code>"group.open"</code>).
* <p>
@@ -72,8 +72,8 @@ public interface IContextMenuConstants {
* </ul>
* </p>
*/
- public static final String GROUP_OPEN= ICommonMenuConstants.GROUP_OPEN;
-
+ public static final String GROUP_OPEN = ICommonMenuConstants.GROUP_OPEN;
+
/**
* Pop-up menu: name of group for show actions (value <code>"group.show"</code>).
* <p>
@@ -84,8 +84,8 @@ public interface IContextMenuConstants {
* </ul>
* </p>
*/
- public static final String GROUP_SHOW= ICommonMenuConstants.GROUP_SHOW;
-
+ public static final String GROUP_SHOW = ICommonMenuConstants.GROUP_SHOW;
+
/**
* Pop-up menu: name of group for new actions (value <code>"group.new"</code>).
* <p>
@@ -96,47 +96,46 @@ public interface IContextMenuConstants {
* </ul>
* </p>
*/
- public static final String GROUP_NEW= ICommonMenuConstants.GROUP_NEW;
+ public static final String GROUP_NEW = ICommonMenuConstants.GROUP_NEW;
/**
* Pop-up menu: name of group for build actions (value <code>"group.build"</code>).
*/
- public static final String GROUP_BUILD= ICommonMenuConstants.GROUP_BUILD;
-
+ public static final String GROUP_BUILD = ICommonMenuConstants.GROUP_BUILD;
+
/**
* Pop-up menu: name of group for reorganize actions (value <code>"group.reorganize"</code>).
- */
- public static final String GROUP_REORGANIZE= ICommonMenuConstants.GROUP_REORGANIZE;
-
+ */
+ public static final String GROUP_REORGANIZE = ICommonMenuConstants.GROUP_REORGANIZE;
+
/**
* Pop-up menu: name of group for code generation or refactoring actions (
* value <code>"group.generate"</code>).
- */
- public static final String GROUP_GENERATE= ICommonMenuConstants.GROUP_GENERATE;
+ */
+ public static final String GROUP_GENERATE = ICommonMenuConstants.GROUP_GENERATE;
/**
* Pop-up menu: name of group for search actions (value <code>"group.search"</code>).
- */
- public static final String GROUP_SEARCH= ICommonMenuConstants.GROUP_SEARCH;
-
+ */
+ public static final String GROUP_SEARCH = ICommonMenuConstants.GROUP_SEARCH;
+
/**
* Pop-up menu: name of group for additional actions (value <code>"group.additions"</code>).
- */
- public static final String GROUP_ADDITIONS= ICommonMenuConstants.GROUP_ADDITIONS;
+ */
+ public static final String GROUP_ADDITIONS = ICommonMenuConstants.GROUP_ADDITIONS;
/**
* Pop-up menu: name of group for viewer setup actions (value <code>"group.viewerSetup"</code>).
- */
- public static final String GROUP_VIEWER_SETUP= ICommonMenuConstants.GROUP_VIEWER_SETUP;
+ */
+ public static final String GROUP_VIEWER_SETUP = ICommonMenuConstants.GROUP_VIEWER_SETUP;
/**
* Pop-up menu: name of group for properties actions (value <code>"group.properties"</code>).
- */
- public static final String GROUP_PROPERTIES= ICommonMenuConstants.GROUP_PROPERTIES;
+ */
+ public static final String GROUP_PROPERTIES = ICommonMenuConstants.GROUP_PROPERTIES;
/**
* Pop-up menu: name of group for debug actions (value <code>"group.debug"</code>).
- */
- public static final String GROUP_DEBUG= "group.debug"; //$NON-NLS-1$
+ */
+ public static final String GROUP_DEBUG = "group.debug"; //$NON-NLS-1$
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java
index 3d868a64caa..25a0d12492d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java
@@ -66,1440 +66,1565 @@ import org.eclipse.swt.widgets.Widget;
*/
public final class ImageCombo extends Composite {
- Text text;
- Table table;
- int visibleItemCount = 5;
- Shell popup;
- Button arrow;
- boolean hasFocus;
- Listener listener, filter;
- Color foreground, background;
- Font font;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#READ_ONLY
- * @see SWT#FLAT
- * @see Widget#getStyle()
- */
-public ImageCombo (Composite parent, int style) {
- super (parent, style = checkStyle (style));
-
- int textStyle = SWT.SINGLE;
- if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY;
- if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT;
- text = new Text (this, SWT.NONE);
- int arrowStyle = SWT.ARROW | SWT.DOWN;
- if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
- arrow = new Button (this, arrowStyle);
-
- listener = new Listener () {
- @Override
- public void handleEvent (Event event) {
- if (popup == event.widget) {
- popupEvent (event);
- return;
- }
- if (text == event.widget) {
- textEvent (event);
- return;
- }
- if (table == event.widget) {
- listEvent (event);
- return;
- }
- if (arrow == event.widget) {
- arrowEvent (event);
- return;
- }
- if (ImageCombo.this == event.widget) {
- comboEvent (event);
- return;
- }
- if (getShell () == event.widget) {
- handleFocus (SWT.FocusOut);
- }
- }
- };
- filter = new Listener() {
- @Override
- public void handleEvent(Event event) {
- Shell shell = ((Control)event.widget).getShell ();
- if (shell == ImageCombo.this.getShell ()) {
- handleFocus (SWT.FocusOut);
- }
- }
- };
-
- int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
- for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
-
- int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn};
- for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
-
- int [] arrowEvents = {SWT.Selection, SWT.FocusIn};
- for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
-
- createPopup( -1);
- initAccessible();
-}
-static int checkStyle (int style) {
- int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- return style & mask;
-}
-/**
- * Adds the argument to the end of the receiver's list.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #add(String,int)
- */
-public void add (String string, Image image) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TableItem newItem = new TableItem(this.table,SWT.NONE);
- newItem.setText(string);
- if (image != null) newItem.setImage(image);
-}
-/**
- * Adds the argument to the receiver's list at the given
- * zero-relative index.
- * <p>
- * Note: To add an item at the end of the list, use the
- * result of calling <code>getItemCount()</code> as the
- * index or use <code>add(String)</code>.
- * </p>
- *
- * @param string the new item
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #add(String)
- */
-public void add (String string,Image image, int index) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TableItem newItem = new TableItem(this.table,SWT.NONE,index);
- if (image != null) newItem.setImage(image);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is modified, by sending
- * it one of the messages defined in the <code>ModifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #removeModifyListener
- */
-public void addModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Modify, typedListener);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the combo's list selection changes.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-void arrowEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- handleFocus (SWT.FocusIn);
- break;
- }
- case SWT.Selection: {
- dropDown (!isDropped ());
- break;
- }
- }
-}
-/**
- * Sets the selection in the receiver's text field to an empty
- * selection starting just before the first character. If the
- * text field is editable, this has the effect of placing the
- * i-beam at the start of the text.
- * <p>
- * Note: To clear the selected items in the receiver's list,
- * use <code>deselectAll()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #deselectAll
- */
-public void clearSelection () {
- checkWidget ();
- text.clearSelection ();
- table.deselectAll ();
-}
-void comboEvent (Event event) {
- switch (event.type) {
- case SWT.Dispose:
- if (popup != null && !popup.isDisposed ()) {
- table.removeListener (SWT.Dispose, listener);
- popup.dispose ();
- }
- Shell shell = getShell ();
- shell.removeListener (SWT.Deactivate, listener);
- Display display = getDisplay ();
- display.removeFilter (SWT.FocusIn, filter);
- popup = null;
- text = null;
- table = null;
- arrow = null;
- break;
- case SWT.Move:
- dropDown (false);
- break;
- case SWT.Resize:
- internalLayout (false);
- break;
- }
-}
+ Text text;
+ Table table;
+ int visibleItemCount = 5;
+ Shell popup;
+ Button arrow;
+ boolean hasFocus;
+ Listener listener, filter;
+ Color foreground, background;
+ Font font;
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- int width = 0, height = 0;
- String[] items = getStringsFromTable();
- int textWidth = 0;
- GC gc = new GC (text);
- int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$
- for (int i = 0; i < items.length; i++) {
- textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth);
- }
- gc.dispose();
- Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
- Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
- Point listSize = table.computeSize (wHint, SWT.DEFAULT, changed);
- int borderWidth = getBorderWidth ();
-
- height = Math.max (hHint, Math.max (textSize.y, arrowSize.y) + 2*borderWidth);
- width = Math.max (wHint, Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x));
- return new Point (width, height);
-}
-void createPopup(int selectionIndex) {
- // create shell and list
- popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP);
- int style = getStyle ();
- int listStyle = SWT.SINGLE | SWT.V_SCROLL;
- if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
- if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
- // create a table instead of a list.
- table = new Table (popup, listStyle);
- if (font != null) table.setFont (font);
- if (foreground != null) table.setForeground (foreground);
- if (background != null) table.setBackground (background);
-
- int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
- for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
- int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose};
- for (int i=0; i<listEvents.length; i++) table.addListener (listEvents [i], listener);
-
- if (selectionIndex != -1) table.setSelection (selectionIndex);
-}
-/**
- * Deselects the item at the given zero-relative index in the receiver's
- * list. If the item at the index was already deselected, it remains
- * deselected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void deselect (int index) {
- checkWidget ();
- table.deselect (index);
-}
-/**
- * Deselects all selected items in the receiver's list.
- * <p>
- * Note: To clear the selection in the receiver's text field,
- * use <code>clearSelection()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #clearSelection
- */
-public void deselectAll () {
- checkWidget ();
- table.deselectAll ();
-}
-void dropDown (boolean drop) {
- if (drop == isDropped ()) return;
- if (!drop) {
- popup.setVisible (false);
- if (!isDisposed ()&& arrow.isFocusControl()) {
- text.setFocus();
- }
- return;
- }
-
- if (getShell() != popup.getParent ()) {
- TableItem[] items = table.getItems ();
- int selectionIndex = table.getSelectionIndex ();
- table.removeListener (SWT.Dispose, listener);
- popup.dispose();
- popup = null;
- table = null;
- createPopup (selectionIndex);
- }
-
- Point size = getSize ();
- int itemCount = table.getItemCount ();
- itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount);
- int itemHeight = table.getItemHeight () * itemCount;
- Point listSize = table.computeSize (SWT.DEFAULT, itemHeight, false);
- table.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
-
- int index = table.getSelectionIndex ();
- if (index != -1) table.setTopIndex (index);
- Display display = getDisplay ();
- Rectangle listRect = table.getBounds ();
- Rectangle parentRect = display.map (getParent (), null, getBounds ());
- Point comboSize = getSize ();
- Rectangle displayRect = getMonitor ().getClientArea ();
- int width = Math.max (comboSize.x, listRect.width + 2);
- int height = listRect.height + 2;
- int x = parentRect.x;
- int y = parentRect.y + comboSize.y;
- if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height;
- popup.setBounds (x, y, width, height);
- popup.setVisible (true);
- table.setFocus ();
-}
-/*
- * Return the Label immediately preceding the receiver in the z-order,
- * or null if none.
- */
-Label getAssociatedLabel () {
- Control[] siblings = getParent ().getChildren ();
- for (int i = 0; i < siblings.length; i++) {
- if (siblings [i] == ImageCombo.this) {
- if (i > 0 && siblings [i-1] instanceof Label) {
- return (Label) siblings [i-1];
- }
- }
- }
- return null;
-}
-@Override
-public Control [] getChildren () {
- checkWidget();
- return new Control [0];
-}
-/**
- * Gets the editable state.
- *
- * @return whether or not the reciever is editable
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public boolean getEditable () {
- checkWidget ();
- return text.getEditable();
-}
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver's list. Throws an exception if the index is out
- * of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem getItem (int index) {
- checkWidget();
- return this.table.getItem (index);
-}
-/**
- * Returns the number of items contained in the receiver's list.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- checkWidget ();
- return table.getItemCount ();
-}
-/**
- * Returns the height of the area which would be used to
- * display <em>one</em> of the items in the receiver's list.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemHeight () {
- checkWidget ();
- return table.getItemHeight ();
-}
-/**
- * Returns an array of <code>String</code>s which are the items
- * in the receiver's list.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem [] getItems () {
- checkWidget ();
- return table.getItems ();
-}
-char getMnemonic (String string) {
- int index = 0;
- int length = string.length ();
- do {
- while ((index < length) && (string.charAt (index) != '&')) index++;
- if (++index >= length) return '\0';
- if (string.charAt (index) != '&') return string.charAt (index);
- index++;
- } while (index < length);
- return '\0';
-}
+ /**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#READ_ONLY
+ * @see SWT#FLAT
+ * @see Widget#getStyle()
+ */
+ public ImageCombo(Composite parent, int style) {
+ super(parent, style = checkStyle(style));
-String [] getStringsFromTable()
-{
- String[] items = new String[this.table.getItems().length];
- for (int i = 0, n = items.length; i < n; i++) {
- items[i]=this.table.getItem(i).getText();
- }
- return items;
-}
-/**
- * Returns a <code>Point</code> whose x coordinate is the start
- * of the selection in the receiver's text field, and whose y
- * coordinate is the end of the selection. The returned values
- * are zero-relative. An "empty" selection as indicated by
- * the the x and y coordinates having the same value.
- *
- * @return a point representing the selection start and end
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getSelection () {
- checkWidget ();
- return text.getSelection ();
-}
-/**
- * Returns the zero-relative index of the item which is currently
- * selected in the receiver's list, or -1 if no item is selected.
- *
- * @return the index of the selected item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionIndex () {
- checkWidget ();
- return table.getSelectionIndex ();
-}
-@Override
-public int getStyle () {
- int style = super.getStyle ();
- style &= ~SWT.READ_ONLY;
- if (!text.getEditable()) style |= SWT.READ_ONLY;
- return style;
-}
-/**
- * Returns a string containing a copy of the contents of the
- * receiver's text field.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget ();
- return text.getText ();
-}
-/**
- * Returns the height of the receivers's text field.
- *
- * @return the text height
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTextHeight () {
- checkWidget ();
- return text.getLineHeight ();
-}
-/**
- * Returns the maximum number of characters that the receiver's
- * text field is capable of holding. If this has not been changed
- * by <code>setTextLimit()</code>, it will be the constant
- * <code>Combo.LIMIT</code>.
- *
- * @return the text limit
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTextLimit () {
- checkWidget ();
- return text.getTextLimit ();
-}
-/**
- * Gets the number of items that are visible in the drop
- * down portion of the receiver's list.
- *
- * @return the number of items that are visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public int getVisibleItemCount () {
- checkWidget ();
- return visibleItemCount;
-}
-void handleFocus (int type) {
- if (isDisposed ()) return;
- switch (type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- if (getEditable ()) text.selectAll ();
- hasFocus = true;
- Shell shell = getShell ();
- shell.removeListener (SWT.Deactivate, listener);
- shell.addListener (SWT.Deactivate, listener);
- Display display = getDisplay ();
- display.removeFilter (SWT.FocusIn, filter);
- display.addFilter (SWT.FocusIn, filter);
- Event e = new Event ();
- notifyListeners (SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- if (!hasFocus) return;
- Control focusControl = getDisplay ().getFocusControl ();
- if (focusControl == arrow || focusControl == table || focusControl == text) return;
- hasFocus = false;
- Shell shell = getShell ();
- shell.removeListener(SWT.Deactivate, listener);
- Display display = getDisplay ();
- display.removeFilter (SWT.FocusIn, filter);
- Event e = new Event ();
- notifyListeners (SWT.FocusOut, e);
- break;
- }
- }
-}
-/**
- * Searches the receiver's list starting at the first item
- * (index 0) until an item is found that is equal to the
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (String string) {
- checkWidget ();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return Arrays.asList(getStringsFromTable()).indexOf (string);
-}
+ int textStyle = SWT.SINGLE;
+ if ((style & SWT.READ_ONLY) != 0)
+ textStyle |= SWT.READ_ONLY;
+ if ((style & SWT.FLAT) != 0)
+ textStyle |= SWT.FLAT;
+ text = new Text(this, SWT.NONE);
+ int arrowStyle = SWT.ARROW | SWT.DOWN;
+ if ((style & SWT.FLAT) != 0)
+ arrowStyle |= SWT.FLAT;
+ arrow = new Button(this, arrowStyle);
+ listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (popup == event.widget) {
+ popupEvent(event);
+ return;
+ }
+ if (text == event.widget) {
+ textEvent(event);
+ return;
+ }
+ if (table == event.widget) {
+ listEvent(event);
+ return;
+ }
+ if (arrow == event.widget) {
+ arrowEvent(event);
+ return;
+ }
+ if (ImageCombo.this == event.widget) {
+ comboEvent(event);
+ return;
+ }
+ if (getShell() == event.widget) {
+ handleFocus(SWT.FocusOut);
+ }
+ }
+ };
+ filter = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ Shell shell = ((Control) event.widget).getShell();
+ if (shell == ImageCombo.this.getShell()) {
+ handleFocus(SWT.FocusOut);
+ }
+ }
+ };
-void initAccessible() {
- AccessibleAdapter accessibleAdapter = new AccessibleAdapter () {
- @Override
- public void getName (AccessibleEvent e) {
- String name = null;
- Label label = getAssociatedLabel ();
- if (label != null) {
- name = stripMnemonic (label.getText());
- }
- e.result = name;
- }
- @Override
- public void getKeyboardShortcut(AccessibleEvent e) {
- String shortcut = null;
- Label label = getAssociatedLabel ();
- if (label != null) {
- String text = label.getText ();
- if (text != null) {
- char mnemonic = getMnemonic (text);
- if (mnemonic != '\0') {
- shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
- }
- }
- }
- e.result = shortcut;
- }
- @Override
- public void getHelp (AccessibleEvent e) {
- e.result = getToolTipText ();
- }
- };
- getAccessible ().addAccessibleListener (accessibleAdapter);
- text.getAccessible ().addAccessibleListener (accessibleAdapter);
- table.getAccessible ().addAccessibleListener (accessibleAdapter);
-
- arrow.getAccessible ().addAccessibleListener (new AccessibleAdapter() {
- @Override
- public void getName (AccessibleEvent e) {
- e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- @Override
- public void getKeyboardShortcut (AccessibleEvent e) {
- e.result = "Alt+Down Arrow"; //$NON-NLS-1$
- }
- @Override
- public void getHelp (AccessibleEvent e) {
- e.result = getToolTipText ();
- }
- });
-
- getAccessible().addAccessibleTextListener (new AccessibleTextAdapter() {
- @Override
- public void getCaretOffset (AccessibleTextEvent e) {
- e.offset = text.getCaretPosition ();
- }
- });
-
- getAccessible().addAccessibleControlListener (new AccessibleControlAdapter() {
- @Override
- public void getChildAtPoint (AccessibleControlEvent e) {
- Point testPoint = toControl (e.x, e.y);
- if (getBounds ().contains (testPoint)) {
- e.childID = ACC.CHILDID_SELF;
- }
- }
-
- @Override
- public void getLocation (AccessibleControlEvent e) {
- Rectangle location = getBounds ();
- Point pt = toDisplay (location.x, location.y);
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
-
- @Override
- public void getChildCount (AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- @Override
- public void getRole (AccessibleControlEvent e) {
- e.detail = ACC.ROLE_COMBOBOX;
- }
-
- @Override
- public void getState (AccessibleControlEvent e) {
- e.detail = ACC.STATE_NORMAL;
- }
-
- @Override
- public void getValue (AccessibleControlEvent e) {
- e.result = getText ();
- }
- });
-
- text.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter () {
- @Override
- public void getRole (AccessibleControlEvent e) {
- e.detail = text.getEditable () ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
- }
- });
-
- arrow.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter() {
- @Override
- public void getDefaultAction (AccessibleControlEvent e) {
- e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
-}
-boolean isDropped () {
- return popup.getVisible ();
-}
-@Override
-public boolean isFocusControl () {
- checkWidget();
- if (text.isFocusControl () || arrow.isFocusControl () || table.isFocusControl () || popup.isFocusControl ()) {
- return true;
- }
- return super.isFocusControl ();
-}
-void internalLayout (boolean changed) {
- if (isDropped ()) dropDown (false);
- Rectangle rect = getClientArea ();
- int width = rect.width;
- int height = rect.height;
- Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed);
- text.setBounds (0, 0, width - arrowSize.x, height);
- arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
-}
-void listEvent (Event event) {
- switch (event.type) {
- case SWT.Dispose:
- if (getShell () != popup.getParent ()) {
- TableItem[] items = table.getItems ();
- int selectionIndex = table.getSelectionIndex ();
- popup = null;
- table = null;
- createPopup (selectionIndex);
- }
- break;
- case SWT.FocusIn: {
- handleFocus (SWT.FocusIn);
- break;
- }
- case SWT.MouseUp: {
- if (event.button != 1) return;
- dropDown (false);
- break;
- }
- case SWT.Selection: {
- int index = table.getSelectionIndex ();
- if (index == -1) return;
- text.setText (table.getItem (index).getText());
- text.selectAll ();
- table.setSelection (index);
- Event e = new Event ();
- e.time = event.time;
- e.stateMask = event.stateMask;
- e.doit = event.doit;
- notifyListeners (SWT.Selection, e);
- event.doit = e.doit;
- break;
- }
- case SWT.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- event.doit = false;
- break;
- }
- Event e = new Event ();
- e.time = event.time;
- e.detail = event.detail;
- e.doit = event.doit;
- e.character = event.character;
- e.keyCode = event.keyCode;
- notifyListeners (SWT.Traverse, e);
- event.doit = e.doit;
- event.detail = e.detail;
- break;
- }
- case SWT.KeyUp: {
- Event e = new Event ();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.KeyUp, e);
- break;
- }
- case SWT.KeyDown: {
- if (event.character == SWT.ESC) {
- // Escape key cancels popup list
- dropDown (false);
- }
- if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) {
- dropDown (false);
- }
- if (event.character == SWT.CR) {
- // Enter causes default selection
- dropDown (false);
- Event e = new Event ();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.DefaultSelection, e);
- }
- // At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed ()) break;
- Event e = new Event();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.KeyDown, e);
- break;
-
- }
- }
-}
+ int[] comboEvents = { SWT.Dispose, SWT.Move, SWT.Resize };
+ for (int i = 0; i < comboEvents.length; i++)
+ this.addListener(comboEvents[i], listener);
-void popupEvent(Event event) {
- switch (event.type) {
- case SWT.Paint:
- // draw black rectangle around list
- Rectangle listRect = table.getBounds();
- Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
- event.gc.setForeground(black);
- event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1);
- break;
- case SWT.Close:
- event.doit = false;
- dropDown (false);
- break;
- case SWT.Deactivate:
- dropDown (false);
- break;
- }
-}
-@Override
-public void redraw () {
- super.redraw();
- text.redraw();
- arrow.redraw();
- if (popup.isVisible()) table.redraw();
-}
-@Override
-public void redraw (int x, int y, int width, int height, boolean all) {
- super.redraw(x, y, width, height, true);
-}
+ int[] textEvents = { SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse,
+ SWT.FocusIn };
+ for (int i = 0; i < textEvents.length; i++)
+ text.addListener(textEvents[i], listener);
-/**
- * Removes the item from the receiver's list at the given
- * zero-relative index.
- *
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (int index) {
- checkWidget();
- table.remove (index);
-}
-/**
- * Removes the items from the receiver's list which are
- * between the given zero-relative start and end
- * indices (inclusive).
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (int start, int end) {
- checkWidget();
- table.remove (start, end);
-}
-/**
- * Searches the receiver's list starting at the first item
- * until an item is found that is equal to the argument,
- * and removes that item from the list.
- *
- * @param string the item to remove
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int index = -1;
- for (int i = 0, n = table.getItemCount(); i < n; i++) {
- if (table.getItem(i).getText().equals(string)) {
- index = i;
- break;
- }
- }
- remove(index);
-}
-/**
- * Removes all of the items from the receiver's list and clear the
- * contents of receiver's text field.
- * <p>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void removeAll () {
- checkWidget();
- text.setText (""); //$NON-NLS-1$
- table.removeAll ();
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's text is modified.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #addModifyListener
- */
-public void removeModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener(SWT.Modify, listener);
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's selection changes.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener(SWT.Selection, listener);
- removeListener(SWT.DefaultSelection,listener);
-}
-/**
- * Selects the item at the given zero-relative index in the receiver's
- * list. If the item at the index was already selected, it remains
- * selected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void select (int index) {
- checkWidget();
- if (index == -1) {
- table.deselectAll ();
- text.setText (""); //$NON-NLS-1$
- return;
- }
- if (0 <= index && index < table.getItemCount()) {
- if (index != getSelectionIndex()) {
- text.setText (table.getItem (index).getText());
- text.selectAll ();
- table.select (index);
- table.showSelection ();
- }
- }
-}
-@Override
-public void setBackground (Color color) {
- super.setBackground(color);
- background = color;
- if (text != null) text.setBackground(color);
- if (table != null) table.setBackground(color);
- if (arrow != null) arrow.setBackground(color);
-}
-/**
- * Sets the editable state.
- *
- * @param editable the new editable state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public void setEditable (boolean editable) {
- checkWidget ();
- text.setEditable(editable);
-}
-@Override
-public void setEnabled (boolean enabled) {
- super.setEnabled(enabled);
- if (popup != null) popup.setVisible (false);
- if (text != null) text.setEnabled(enabled);
- if (arrow != null) arrow.setEnabled(enabled);
-}
-@Override
-public boolean setFocus () {
- checkWidget();
- return text.setFocus ();
-}
-@Override
-public void setFont (Font font) {
- super.setFont (font);
- this.font = font;
- text.setFont (font);
- table.setFont (font);
- internalLayout (true);
-}
-@Override
-public void setForeground (Color color) {
- super.setForeground(color);
- foreground = color;
- if (text != null) text.setForeground(color);
- if (table != null) table.setForeground(color);
- if (arrow != null) arrow.setForeground(color);
-}
-/**
- * Sets the text of the item in the receiver's list at the given
- * zero-relative index to the string argument. This is equivalent
- * to <code>remove</code>'ing the old item at the index, and then
- * <code>add</code>'ing the new item at that index.
- *
- * @param index the index for the item
- * @param string the new text for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setItem (int index, String string, Image image) {
- checkWidget();
- remove(index);
- add(string,image,index);
-}
-/**
- * Sets the receiver's list to be the given array of items.
- *
- * @param items the array of items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setItems (String [] items) {
- checkWidget ();
- this.table.removeAll();
- for (int i = 0, n = items.length; i < n; i++) {
- add(items[i],null);
- }
- if (!text.getEditable ()) text.setText (""); //$NON-NLS-1$
-}
+ int[] arrowEvents = { SWT.Selection, SWT.FocusIn };
+ for (int i = 0; i < arrowEvents.length; i++)
+ arrow.addListener(arrowEvents[i], listener);
-/**
- * Sets the layout which is associated with the receiver to be
- * the argument which may be null.
- * <p>
- * Note : No Layout can be set on this Control because it already
- * manages the size and position of its children.
- * </p>
- *
- * @param layout the receiver's new layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-@Override
-public void setLayout (Layout layout) {
- checkWidget ();
- return;
-}
-/**
- * Sets the selection in the receiver's text field to the
- * range specified by the argument whose x coordinate is the
- * start of the selection and whose y coordinate is the end
- * of the selection.
- *
- * @param selection a point representing the new selection start and end
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (Point selection) {
- checkWidget();
- if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- text.setSelection (selection.x, selection.y);
-}
+ createPopup(-1);
+ initAccessible();
+ }
-/**
- * Sets the contents of the receiver's text field to the
- * given string.
- * <p>
- * Note: The text field in a <code>Combo</code> is typically
- * only capable of displaying a single line of text. Thus,
- * setting the text to a string containing line breaks or
- * other special characters will probably cause it to
- * display incorrectly.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int index = -1;
- for (int i = 0, n = table.getItemCount(); i < n; i++) {
- if (table.getItem(i).getText().equals(string)) {
- index = i;
- break;
- }
- }
- if (index == -1) {
- table.deselectAll ();
- text.setText (string);
- return;
- }
- text.setText (string);
- text.selectAll ();
- table.setSelection (index);
- table.showSelection ();
-}
-/**
- * Sets the maximum number of characters that the receiver's
- * text field is capable of holding to be the argument.
- *
- * @param limit new text limit
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTextLimit (int limit) {
- checkWidget();
- text.setTextLimit (limit);
-}
+ static int checkStyle(int style) {
+ int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+ return style & mask;
+ }
-@Override
-public void setToolTipText (String string) {
- checkWidget();
- super.setToolTipText(string);
- arrow.setToolTipText (string);
- text.setToolTipText (string);
-}
+ /**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+ public void add(String string, Image image) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TableItem newItem = new TableItem(this.table, SWT.NONE);
+ newItem.setText(string);
+ if (image != null)
+ newItem.setImage(image);
+ }
-@Override
-public void setVisible (boolean visible) {
- super.setVisible(visible);
- if (!visible) popup.setVisible(false);
-}
-/**
- * Sets the number of items that are visible in the drop
- * down portion of the receiver's list.
- *
- * @param count the new number of items to be visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public void setVisibleItemCount (int count) {
- checkWidget ();
- if (count < 0) return;
- visibleItemCount = count;
-}
-String stripMnemonic (String string) {
- int index = 0;
- int length = string.length ();
- do {
- while ((index < length) && (string.charAt (index) != '&')) index++;
- if (++index >= length) return string;
- if (string.charAt (index) != '&') {
- return string.substring(0, index-1) + string.substring(index, length);
- }
- index++;
- } while (index < length);
- return string;
-}
-void textEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- handleFocus (SWT.FocusIn);
- break;
- }
- case SWT.KeyDown: {
- if (event.character == SWT.CR) {
- dropDown (false);
- Event e = new Event ();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.DefaultSelection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed ()) break;
-
- if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
- event.doit = false;
- if ((event.stateMask & SWT.ALT) != 0) {
- boolean dropped = isDropped ();
- text.selectAll ();
- if (!dropped) setFocus ();
- dropDown (!dropped);
- break;
- }
-
- int oldIndex = getSelectionIndex ();
- if (event.keyCode == SWT.ARROW_UP) {
- select (Math.max (oldIndex - 1, 0));
- } else {
- select (Math.min (oldIndex + 1, getItemCount () - 1));
- }
- if (oldIndex != getSelectionIndex ()) {
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.Selection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed ()) break;
- }
-
- // Further work : Need to add support for incremental search in
- // pop up list as characters typed in text widget
-
- Event e = new Event ();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.KeyDown, e);
- break;
- }
- case SWT.KeyUp: {
- Event e = new Event ();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.KeyUp, e);
- break;
- }
- case SWT.Modify: {
- table.deselectAll ();
- Event e = new Event ();
- e.time = event.time;
- notifyListeners (SWT.Modify, e);
- break;
- }
- case SWT.MouseDown: {
- if (event.button != 1) return;
- if (text.getEditable ()) return;
- boolean dropped = isDropped ();
- text.selectAll ();
- if (!dropped) setFocus ();
- dropDown (!dropped);
- break;
- }
- case SWT.MouseUp: {
- if (event.button != 1) return;
- if (text.getEditable ()) return;
- text.selectAll ();
- break;
- }
- case SWT.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- // The enter causes default selection and
- // the arrow keys are used to manipulate the list contents so
- // do not use them for traversal.
- event.doit = false;
- break;
- }
-
- Event e = new Event ();
- e.time = event.time;
- e.detail = event.detail;
- e.doit = event.doit;
- e.character = event.character;
- e.keyCode = event.keyCode;
- notifyListeners (SWT.Traverse, e);
- event.doit = e.doit;
- event.detail = e.detail;
- break;
- }
- }
-}
+ /**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+ public void add(String string, Image image, int index) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TableItem newItem = new TableItem(this.table, SWT.NONE, index);
+ if (image != null)
+ newItem.setImage(image);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+ public void addModifyListener(ModifyListener listener) {
+ checkWidget();
+ if (listener == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Modify, typedListener);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the combo's list selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+ public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+ }
+
+ void arrowEvent(Event event) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ handleFocus(SWT.FocusIn);
+ break;
+ }
+ case SWT.Selection: {
+ dropDown(!isDropped());
+ break;
+ }
+ }
+ }
+
+ /**
+ * Sets the selection in the receiver's text field to an empty
+ * selection starting just before the first character. If the
+ * text field is editable, this has the effect of placing the
+ * i-beam at the start of the text.
+ * <p>
+ * Note: To clear the selected items in the receiver's list,
+ * use <code>deselectAll()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #deselectAll
+ */
+ public void clearSelection() {
+ checkWidget();
+ text.clearSelection();
+ table.deselectAll();
+ }
+
+ void comboEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ if (popup != null && !popup.isDisposed()) {
+ table.removeListener(SWT.Dispose, listener);
+ popup.dispose();
+ }
+ Shell shell = getShell();
+ shell.removeListener(SWT.Deactivate, listener);
+ Display display = getDisplay();
+ display.removeFilter(SWT.FocusIn, filter);
+ popup = null;
+ text = null;
+ table = null;
+ arrow = null;
+ break;
+ case SWT.Move:
+ dropDown(false);
+ break;
+ case SWT.Resize:
+ internalLayout(false);
+ break;
+ }
+ }
+
+ @Override
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ checkWidget();
+ int width = 0, height = 0;
+ String[] items = getStringsFromTable();
+ int textWidth = 0;
+ GC gc = new GC(text);
+ int spacer = gc.stringExtent(" ").x; //$NON-NLS-1$
+ for (int i = 0; i < items.length; i++) {
+ textWidth = Math.max(gc.stringExtent(items[i]).x, textWidth);
+ }
+ gc.dispose();
+ Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point listSize = table.computeSize(wHint, SWT.DEFAULT, changed);
+ int borderWidth = getBorderWidth();
+
+ height = Math.max(hHint, Math.max(textSize.y, arrowSize.y) + 2 * borderWidth);
+ width = Math.max(wHint, Math.max(textWidth + 2 * spacer + arrowSize.x + 2 * borderWidth, listSize.x));
+ return new Point(width, height);
+ }
+
+ void createPopup(int selectionIndex) {
+ // create shell and list
+ popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
+ int style = getStyle();
+ int listStyle = SWT.SINGLE | SWT.V_SCROLL;
+ if ((style & SWT.FLAT) != 0)
+ listStyle |= SWT.FLAT;
+ if ((style & SWT.RIGHT_TO_LEFT) != 0)
+ listStyle |= SWT.RIGHT_TO_LEFT;
+ if ((style & SWT.LEFT_TO_RIGHT) != 0)
+ listStyle |= SWT.LEFT_TO_RIGHT;
+ // create a table instead of a list.
+ table = new Table(popup, listStyle);
+ if (font != null)
+ table.setFont(font);
+ if (foreground != null)
+ table.setForeground(foreground);
+ if (background != null)
+ table.setBackground(background);
+
+ int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
+ for (int i = 0; i < popupEvents.length; i++)
+ popup.addListener(popupEvents[i], listener);
+ int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn,
+ SWT.Dispose };
+ for (int i = 0; i < listEvents.length; i++)
+ table.addListener(listEvents[i], listener);
+
+ if (selectionIndex != -1)
+ table.setSelection(selectionIndex);
+ }
+
+ /**
+ * Deselects the item at the given zero-relative index in the receiver's
+ * list. If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void deselect(int index) {
+ checkWidget();
+ table.deselect(index);
+ }
+
+ /**
+ * Deselects all selected items in the receiver's list.
+ * <p>
+ * Note: To clear the selection in the receiver's text field,
+ * use <code>clearSelection()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #clearSelection
+ */
+ public void deselectAll() {
+ checkWidget();
+ table.deselectAll();
+ }
+
+ void dropDown(boolean drop) {
+ if (drop == isDropped())
+ return;
+ if (!drop) {
+ popup.setVisible(false);
+ if (!isDisposed() && arrow.isFocusControl()) {
+ text.setFocus();
+ }
+ return;
+ }
+
+ if (getShell() != popup.getParent()) {
+ TableItem[] items = table.getItems();
+ int selectionIndex = table.getSelectionIndex();
+ table.removeListener(SWT.Dispose, listener);
+ popup.dispose();
+ popup = null;
+ table = null;
+ createPopup(selectionIndex);
+ }
+
+ Point size = getSize();
+ int itemCount = table.getItemCount();
+ itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount);
+ int itemHeight = table.getItemHeight() * itemCount;
+ Point listSize = table.computeSize(SWT.DEFAULT, itemHeight, false);
+ table.setBounds(1, 1, Math.max(size.x - 2, listSize.x), listSize.y);
+
+ int index = table.getSelectionIndex();
+ if (index != -1)
+ table.setTopIndex(index);
+ Display display = getDisplay();
+ Rectangle listRect = table.getBounds();
+ Rectangle parentRect = display.map(getParent(), null, getBounds());
+ Point comboSize = getSize();
+ Rectangle displayRect = getMonitor().getClientArea();
+ int width = Math.max(comboSize.x, listRect.width + 2);
+ int height = listRect.height + 2;
+ int x = parentRect.x;
+ int y = parentRect.y + comboSize.y;
+ if (y + height > displayRect.y + displayRect.height)
+ y = parentRect.y - height;
+ popup.setBounds(x, y, width, height);
+ popup.setVisible(true);
+ table.setFocus();
+ }
+
+ /*
+ * Return the Label immediately preceding the receiver in the z-order,
+ * or null if none.
+ */
+ Label getAssociatedLabel() {
+ Control[] siblings = getParent().getChildren();
+ for (int i = 0; i < siblings.length; i++) {
+ if (siblings[i] == ImageCombo.this) {
+ if (i > 0 && siblings[i - 1] instanceof Label) {
+ return (Label) siblings[i - 1];
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Control[] getChildren() {
+ checkWidget();
+ return new Control[0];
+ }
+
+ /**
+ * Gets the editable state.
+ *
+ * @return whether or not the reciever is editable
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+ public boolean getEditable() {
+ checkWidget();
+ return text.getEditable();
+ }
+
+ /**
+ * Returns the item at the given, zero-relative index in the
+ * receiver's list. Throws an exception if the index is out
+ * of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public TableItem getItem(int index) {
+ checkWidget();
+ return this.table.getItem(index);
+ }
+
+ /**
+ * Returns the number of items contained in the receiver's list.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getItemCount() {
+ checkWidget();
+ return table.getItemCount();
+ }
+
+ /**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's list.
+ *
+ * @return the height of one item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getItemHeight() {
+ checkWidget();
+ return table.getItemHeight();
+ }
+
+ /**
+ * Returns an array of <code>String</code>s which are the items
+ * in the receiver's list.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public TableItem[] getItems() {
+ checkWidget();
+ return table.getItems();
+ }
+
+ char getMnemonic(String string) {
+ int index = 0;
+ int length = string.length();
+ do {
+ while ((index < length) && (string.charAt(index) != '&'))
+ index++;
+ if (++index >= length)
+ return '\0';
+ if (string.charAt(index) != '&')
+ return string.charAt(index);
+ index++;
+ } while (index < length);
+ return '\0';
+ }
+
+ String[] getStringsFromTable() {
+ String[] items = new String[this.table.getItems().length];
+ for (int i = 0, n = items.length; i < n; i++) {
+ items[i] = this.table.getItem(i).getText();
+ }
+ return items;
+ }
+
+ /**
+ * Returns a <code>Point</code> whose x coordinate is the start
+ * of the selection in the receiver's text field, and whose y
+ * coordinate is the end of the selection. The returned values
+ * are zero-relative. An "empty" selection as indicated by
+ * the the x and y coordinates having the same value.
+ *
+ * @return a point representing the selection start and end
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public Point getSelection() {
+ checkWidget();
+ return text.getSelection();
+ }
+
+ /**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver's list, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getSelectionIndex() {
+ checkWidget();
+ return table.getSelectionIndex();
+ }
+
+ @Override
+ public int getStyle() {
+ int style = super.getStyle();
+ style &= ~SWT.READ_ONLY;
+ if (!text.getEditable())
+ style |= SWT.READ_ONLY;
+ return style;
+ }
+
+ /**
+ * Returns a string containing a copy of the contents of the
+ * receiver's text field.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public String getText() {
+ checkWidget();
+ return text.getText();
+ }
+
+ /**
+ * Returns the height of the receivers's text field.
+ *
+ * @return the text height
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getTextHeight() {
+ checkWidget();
+ return text.getLineHeight();
+ }
+
+ /**
+ * Returns the maximum number of characters that the receiver's
+ * text field is capable of holding. If this has not been changed
+ * by <code>setTextLimit()</code>, it will be the constant
+ * <code>Combo.LIMIT</code>.
+ *
+ * @return the text limit
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getTextLimit() {
+ checkWidget();
+ return text.getTextLimit();
+ }
+
+ /**
+ * Gets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ *
+ * @return the number of items that are visible
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+ public int getVisibleItemCount() {
+ checkWidget();
+ return visibleItemCount;
+ }
+
+ void handleFocus(int type) {
+ if (isDisposed())
+ return;
+ switch (type) {
+ case SWT.FocusIn: {
+ if (hasFocus)
+ return;
+ if (getEditable())
+ text.selectAll();
+ hasFocus = true;
+ Shell shell = getShell();
+ shell.removeListener(SWT.Deactivate, listener);
+ shell.addListener(SWT.Deactivate, listener);
+ Display display = getDisplay();
+ display.removeFilter(SWT.FocusIn, filter);
+ display.addFilter(SWT.FocusIn, filter);
+ Event e = new Event();
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+ case SWT.FocusOut: {
+ if (!hasFocus)
+ return;
+ Control focusControl = getDisplay().getFocusControl();
+ if (focusControl == arrow || focusControl == table || focusControl == text)
+ return;
+ hasFocus = false;
+ Shell shell = getShell();
+ shell.removeListener(SWT.Deactivate, listener);
+ Display display = getDisplay();
+ display.removeFilter(SWT.FocusIn, filter);
+ Event e = new Event();
+ notifyListeners(SWT.FocusOut, e);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int indexOf(String string) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return Arrays.asList(getStringsFromTable()).indexOf(string);
+ }
+
+ void initAccessible() {
+ AccessibleAdapter accessibleAdapter = new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ String name = null;
+ Label label = getAssociatedLabel();
+ if (label != null) {
+ name = stripMnemonic(label.getText());
+ }
+ e.result = name;
+ }
+
+ @Override
+ public void getKeyboardShortcut(AccessibleEvent e) {
+ String shortcut = null;
+ Label label = getAssociatedLabel();
+ if (label != null) {
+ String text = label.getText();
+ if (text != null) {
+ char mnemonic = getMnemonic(text);
+ if (mnemonic != '\0') {
+ shortcut = "Alt+" + mnemonic; //$NON-NLS-1$
+ }
+ }
+ }
+ e.result = shortcut;
+ }
+
+ @Override
+ public void getHelp(AccessibleEvent e) {
+ e.result = getToolTipText();
+ }
+ };
+ getAccessible().addAccessibleListener(accessibleAdapter);
+ text.getAccessible().addAccessibleListener(accessibleAdapter);
+ table.getAccessible().addAccessibleListener(accessibleAdapter);
+
+ arrow.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public void getKeyboardShortcut(AccessibleEvent e) {
+ e.result = "Alt+Down Arrow"; //$NON-NLS-1$
+ }
+
+ @Override
+ public void getHelp(AccessibleEvent e) {
+ e.result = getToolTipText();
+ }
+ });
+
+ getAccessible().addAccessibleTextListener(new AccessibleTextAdapter() {
+ @Override
+ public void getCaretOffset(AccessibleTextEvent e) {
+ e.offset = text.getCaretPosition();
+ }
+ });
+
+ getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
+ @Override
+ public void getChildAtPoint(AccessibleControlEvent e) {
+ Point testPoint = toControl(e.x, e.y);
+ if (getBounds().contains(testPoint)) {
+ e.childID = ACC.CHILDID_SELF;
+ }
+ }
+
+ @Override
+ public void getLocation(AccessibleControlEvent e) {
+ Rectangle location = getBounds();
+ Point pt = toDisplay(location.x, location.y);
+ e.x = pt.x;
+ e.y = pt.y;
+ e.width = location.width;
+ e.height = location.height;
+ }
+
+ @Override
+ public void getChildCount(AccessibleControlEvent e) {
+ e.detail = 0;
+ }
+
+ @Override
+ public void getRole(AccessibleControlEvent e) {
+ e.detail = ACC.ROLE_COMBOBOX;
+ }
+
+ @Override
+ public void getState(AccessibleControlEvent e) {
+ e.detail = ACC.STATE_NORMAL;
+ }
+
+ @Override
+ public void getValue(AccessibleControlEvent e) {
+ e.result = getText();
+ }
+ });
+
+ text.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
+ @Override
+ public void getRole(AccessibleControlEvent e) {
+ e.detail = text.getEditable() ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
+ }
+ });
+
+ arrow.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
+ @Override
+ public void getDefaultAction(AccessibleControlEvent e) {
+ e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ }
+
+ boolean isDropped() {
+ return popup.getVisible();
+ }
+
+ @Override
+ public boolean isFocusControl() {
+ checkWidget();
+ if (text.isFocusControl() || arrow.isFocusControl() || table.isFocusControl() || popup.isFocusControl()) {
+ return true;
+ }
+ return super.isFocusControl();
+ }
+
+ void internalLayout(boolean changed) {
+ if (isDropped())
+ dropDown(false);
+ Rectangle rect = getClientArea();
+ int width = rect.width;
+ int height = rect.height;
+ Point arrowSize = arrow.computeSize(SWT.DEFAULT, height, changed);
+ text.setBounds(0, 0, width - arrowSize.x, height);
+ arrow.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
+ }
+
+ void listEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ if (getShell() != popup.getParent()) {
+ TableItem[] items = table.getItems();
+ int selectionIndex = table.getSelectionIndex();
+ popup = null;
+ table = null;
+ createPopup(selectionIndex);
+ }
+ break;
+ case SWT.FocusIn: {
+ handleFocus(SWT.FocusIn);
+ break;
+ }
+ case SWT.MouseUp: {
+ if (event.button != 1)
+ return;
+ dropDown(false);
+ break;
+ }
+ case SWT.Selection: {
+ int index = table.getSelectionIndex();
+ if (index == -1)
+ return;
+ text.setText(table.getItem(index).getText());
+ text.selectAll();
+ table.setSelection(index);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ e.doit = event.doit;
+ notifyListeners(SWT.Selection, e);
+ event.doit = e.doit;
+ break;
+ }
+ case SWT.Traverse: {
+ switch (event.detail) {
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_ESCAPE:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_NEXT:
+ event.doit = false;
+ break;
+ }
+ Event e = new Event();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ notifyListeners(SWT.Traverse, e);
+ event.doit = e.doit;
+ event.detail = e.detail;
+ break;
+ }
+ case SWT.KeyUp: {
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyUp, e);
+ break;
+ }
+ case SWT.KeyDown: {
+ if (event.character == SWT.ESC) {
+ // Escape key cancels popup list
+ dropDown(false);
+ }
+ if ((event.stateMask & SWT.ALT) != 0
+ && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) {
+ dropDown(false);
+ }
+ if (event.character == SWT.CR) {
+ // Enter causes default selection
+ dropDown(false);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.DefaultSelection, e);
+ }
+ // At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed())
+ break;
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyDown, e);
+ break;
+
+ }
+ }
+ }
+
+ void popupEvent(Event event) {
+ switch (event.type) {
+ case SWT.Paint:
+ // draw black rectangle around list
+ Rectangle listRect = table.getBounds();
+ Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+ event.gc.setForeground(black);
+ event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1);
+ break;
+ case SWT.Close:
+ event.doit = false;
+ dropDown(false);
+ break;
+ case SWT.Deactivate:
+ dropDown(false);
+ break;
+ }
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+ text.redraw();
+ arrow.redraw();
+ if (popup.isVisible())
+ table.redraw();
+ }
+
+ @Override
+ public void redraw(int x, int y, int width, int height, boolean all) {
+ super.redraw(x, y, width, height, true);
+ }
+
+ /**
+ * Removes the item from the receiver's list at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void remove(int index) {
+ checkWidget();
+ table.remove(index);
+ }
+
+ /**
+ * Removes the items from the receiver's list which are
+ * between the given zero-relative start and end
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void remove(int start, int end) {
+ checkWidget();
+ table.remove(start, end);
+ }
+
+ /**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument,
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void remove(String string) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int index = -1;
+ for (int i = 0, n = table.getItemCount(); i < n; i++) {
+ if (table.getItem(i).getText().equals(string)) {
+ index = i;
+ break;
+ }
+ }
+ remove(index);
+ }
+
+ /**
+ * Removes all of the items from the receiver's list and clear the
+ * contents of receiver's text field.
+ * <p>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void removeAll() {
+ checkWidget();
+ text.setText(""); //$NON-NLS-1$
+ table.removeAll();
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+ public void removeModifyListener(ModifyListener listener) {
+ checkWidget();
+ if (listener == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ removeListener(SWT.Modify, listener);
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+ public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+ }
+
+ /**
+ * Selects the item at the given zero-relative index in the receiver's
+ * list. If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void select(int index) {
+ checkWidget();
+ if (index == -1) {
+ table.deselectAll();
+ text.setText(""); //$NON-NLS-1$
+ return;
+ }
+ if (0 <= index && index < table.getItemCount()) {
+ if (index != getSelectionIndex()) {
+ text.setText(table.getItem(index).getText());
+ text.selectAll();
+ table.select(index);
+ table.showSelection();
+ }
+ }
+ }
+
+ @Override
+ public void setBackground(Color color) {
+ super.setBackground(color);
+ background = color;
+ if (text != null)
+ text.setBackground(color);
+ if (table != null)
+ table.setBackground(color);
+ if (arrow != null)
+ arrow.setBackground(color);
+ }
+
+ /**
+ * Sets the editable state.
+ *
+ * @param editable the new editable state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+ public void setEditable(boolean editable) {
+ checkWidget();
+ text.setEditable(editable);
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ if (popup != null)
+ popup.setVisible(false);
+ if (text != null)
+ text.setEnabled(enabled);
+ if (arrow != null)
+ arrow.setEnabled(enabled);
+ }
+
+ @Override
+ public boolean setFocus() {
+ checkWidget();
+ return text.setFocus();
+ }
+
+ @Override
+ public void setFont(Font font) {
+ super.setFont(font);
+ this.font = font;
+ text.setFont(font);
+ table.setFont(font);
+ internalLayout(true);
+ }
+
+ @Override
+ public void setForeground(Color color) {
+ super.setForeground(color);
+ foreground = color;
+ if (text != null)
+ text.setForeground(color);
+ if (table != null)
+ table.setForeground(color);
+ if (arrow != null)
+ arrow.setForeground(color);
+ }
+
+ /**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument. This is equivalent
+ * to <code>remove</code>'ing the old item at the index, and then
+ * <code>add</code>'ing the new item at that index.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setItem(int index, String string, Image image) {
+ checkWidget();
+ remove(index);
+ add(string, image, index);
+ }
+
+ /**
+ * Sets the receiver's list to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setItems(String[] items) {
+ checkWidget();
+ this.table.removeAll();
+ for (int i = 0, n = items.length; i < n; i++) {
+ add(items[i], null);
+ }
+ if (!text.getEditable())
+ text.setText(""); //$NON-NLS-1$
+ }
+
+ /**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note : No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ @Override
+ public void setLayout(Layout layout) {
+ checkWidget();
+ return;
+ }
+
+ /**
+ * Sets the selection in the receiver's text field to the
+ * range specified by the argument whose x coordinate is the
+ * start of the selection and whose y coordinate is the end
+ * of the selection.
+ *
+ * @param selection a point representing the new selection start and end
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setSelection(Point selection) {
+ checkWidget();
+ if (selection == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ text.setSelection(selection.x, selection.y);
+ }
+
+ /**
+ * Sets the contents of the receiver's text field to the
+ * given string.
+ * <p>
+ * Note: The text field in a <code>Combo</code> is typically
+ * only capable of displaying a single line of text. Thus,
+ * setting the text to a string containing line breaks or
+ * other special characters will probably cause it to
+ * display incorrectly.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setText(String string) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int index = -1;
+ for (int i = 0, n = table.getItemCount(); i < n; i++) {
+ if (table.getItem(i).getText().equals(string)) {
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) {
+ table.deselectAll();
+ text.setText(string);
+ return;
+ }
+ text.setText(string);
+ text.selectAll();
+ table.setSelection(index);
+ table.showSelection();
+ }
+
+ /**
+ * Sets the maximum number of characters that the receiver's
+ * text field is capable of holding to be the argument.
+ *
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setTextLimit(int limit) {
+ checkWidget();
+ text.setTextLimit(limit);
+ }
+
+ @Override
+ public void setToolTipText(String string) {
+ checkWidget();
+ super.setToolTipText(string);
+ arrow.setToolTipText(string);
+ text.setToolTipText(string);
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (!visible)
+ popup.setVisible(false);
+ }
+
+ /**
+ * Sets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ *
+ * @param count the new number of items to be visible
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+ public void setVisibleItemCount(int count) {
+ checkWidget();
+ if (count < 0)
+ return;
+ visibleItemCount = count;
+ }
+
+ String stripMnemonic(String string) {
+ int index = 0;
+ int length = string.length();
+ do {
+ while ((index < length) && (string.charAt(index) != '&'))
+ index++;
+ if (++index >= length)
+ return string;
+ if (string.charAt(index) != '&') {
+ return string.substring(0, index - 1) + string.substring(index, length);
+ }
+ index++;
+ } while (index < length);
+ return string;
+ }
+
+ void textEvent(Event event) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ handleFocus(SWT.FocusIn);
+ break;
+ }
+ case SWT.KeyDown: {
+ if (event.character == SWT.CR) {
+ dropDown(false);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.DefaultSelection, e);
+ }
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed())
+ break;
+
+ if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
+ event.doit = false;
+ if ((event.stateMask & SWT.ALT) != 0) {
+ boolean dropped = isDropped();
+ text.selectAll();
+ if (!dropped)
+ setFocus();
+ dropDown(!dropped);
+ break;
+ }
+
+ int oldIndex = getSelectionIndex();
+ if (event.keyCode == SWT.ARROW_UP) {
+ select(Math.max(oldIndex - 1, 0));
+ } else {
+ select(Math.min(oldIndex + 1, getItemCount() - 1));
+ }
+ if (oldIndex != getSelectionIndex()) {
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.Selection, e);
+ }
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed())
+ break;
+ }
+
+ // Further work : Need to add support for incremental search in
+ // pop up list as characters typed in text widget
+
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyDown, e);
+ break;
+ }
+ case SWT.KeyUp: {
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyUp, e);
+ break;
+ }
+ case SWT.Modify: {
+ table.deselectAll();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.Modify, e);
+ break;
+ }
+ case SWT.MouseDown: {
+ if (event.button != 1)
+ return;
+ if (text.getEditable())
+ return;
+ boolean dropped = isDropped();
+ text.selectAll();
+ if (!dropped)
+ setFocus();
+ dropDown(!dropped);
+ break;
+ }
+ case SWT.MouseUp: {
+ if (event.button != 1)
+ return;
+ if (text.getEditable())
+ return;
+ text.selectAll();
+ break;
+ }
+ case SWT.Traverse: {
+ switch (event.detail) {
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_NEXT:
+ // The enter causes default selection and
+ // the arrow keys are used to manipulate the list contents so
+ // do not use them for traversal.
+ event.doit = false;
+ break;
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ notifyListeners(SWT.Traverse, e);
+ event.doit = e.doit;
+ event.detail = e.detail;
+ break;
+ }
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java
index ab88eac6bfc..a07e16e491c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java
@@ -49,34 +49,34 @@ import org.eclipse.swt.graphics.Rectangle;
public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
/** The default position type for untyped positions */
- private static final String DEFAULT_TYPE= "__default__"; //$NON-NLS-1$
+ private static final String DEFAULT_TYPE = "__default__"; //$NON-NLS-1$
/** The position type for the cursor line position */
- private static final String CURSOR_LINE_TYPE= "__cursor_line__"; //$NON-NLS-1$
+ private static final String CURSOR_LINE_TYPE = "__cursor_line__"; //$NON-NLS-1$
/** Manager for position changes */
private IPaintPositionManager fPositionManager;
/** Indicates whether this painter is active */
- private boolean fIsActive= false;
+ private boolean fIsActive = false;
/** The text viewer this painter is associated with */
private ITextViewer fTextViewer;
/** The viewer's widget */
private StyledText fTextWidget;
/** Text positions (cursor line position is always at index 0 */
- private List<Position> fPositions= new ArrayList<Position>();
+ private List<Position> fPositions = new ArrayList<Position>();
/** Cached text positions */
- private List<Position> fLastPositions= new ArrayList<Position>();
+ private List<Position> fLastPositions = new ArrayList<Position>();
/** Temporary changed positions */
- private List<Position> fChangedPositions= new ArrayList<Position>();
+ private List<Position> fChangedPositions = new ArrayList<Position>();
/** Cursor line position */
- private Position fCursorLine= new TypedPosition(0, 0, CURSOR_LINE_TYPE);
+ private Position fCursorLine = new TypedPosition(0, 0, CURSOR_LINE_TYPE);
/** Saved cursor line position */
- private Position fLastCursorLine= new Position(0, 0);
+ private Position fLastCursorLine = new Position(0, 0);
/** Enablement of the cursor line highlighting */
private boolean fCursorLineEnabled;
/** Whether cursor line highlighting is active */
private boolean fCursorLineActive;
/** Map of position type to color */
- private Map<String, Color> fColorMap= new HashMap<String, Color>();
+ private Map<String, Color> fColorMap = new HashMap<String, Color>();
/**
* Creates a new painter for the given text viewer.
@@ -84,8 +84,8 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
public LineBackgroundPainter(ITextViewer textViewer) {
super();
- fTextViewer= textViewer;
- fTextWidget= textViewer.getTextWidget();
+ fTextViewer = textViewer;
+ fTextWidget = textViewer.getTextWidget();
fPositions.add(fCursorLine);
fLastPositions.add(fLastCursorLine);
}
@@ -124,8 +124,8 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
* @param enable
*/
public void enableCursorLine(boolean enable) {
- fCursorLineEnabled= enable;
- fCursorLineActive= enable;
+ fCursorLineEnabled = enable;
+ fCursorLineActive = enable;
if (fCursorLineActive) {
updateCursorLine();
}
@@ -138,7 +138,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
* @param positions a list of <code>Position</code>s
*/
public void setHighlightPositions(List<Position> positions) {
- boolean isActive= fIsActive;
+ boolean isActive = fIsActive;
deactivate(isActive);
fPositions.clear();
fPositions.add(fCursorLine);
@@ -155,7 +155,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
* @param positions a list of <code>Position</code>s
*/
public void addHighlightPositions(List<Position> positions) {
- boolean isActive= fIsActive;
+ boolean isActive = fIsActive;
deactivate(isActive);
fPositions.addAll(positions);
if (isActive) {
@@ -169,7 +169,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
* @param positions a list of <code>Position</code>s
*/
public void removeHighlightPositions(List<Position> positions) {
- boolean isActive= fIsActive;
+ boolean isActive = fIsActive;
deactivate(isActive);
fPositions.removeAll(positions);
if (isActive) {
@@ -184,7 +184,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
* @param addPositions a list of <code>Position</code>s to add
*/
public void replaceHighlightPositions(List<Position> removePositions, List<Position> addPositions) {
- boolean isActive= fIsActive;
+ boolean isActive = fIsActive;
deactivate(isActive);
fPositions.removeAll(removePositions);
fPositions.addAll(addPositions);
@@ -197,7 +197,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
* Trigger redraw of managed positions.
*/
public void redraw() {
- if(fIsActive) {
+ if (fIsActive) {
fTextWidget.redraw();
}
}
@@ -210,9 +210,9 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
if (fPositionManager == null) {
return;
}
- int sz= fPositions.size();
- for (int i= 0; i < sz; ++i) {
- Position position= positions.get(i);
+ int sz = fPositions.size();
+ for (int i = 0; i < sz; ++i) {
+ Position position = positions.get(i);
fPositionManager.managePosition(position);
}
}
@@ -225,9 +225,9 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
if (fPositionManager == null) {
return;
}
- int sz= fPositions.size();
- for (int i= 0; i < sz; ++i) {
- Position position= positions.get(i);
+ int sz = fPositions.size();
+ for (int i = 0; i < sz; ++i) {
+ Position position = positions.get(i);
fPositionManager.unmanagePosition(position);
}
}
@@ -238,15 +238,15 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
@Override
public void dispose() {
// no deactivate!
- fIsActive= false;
- fTextViewer= null;
- fTextWidget= null;
- fCursorLine= null;
- fLastCursorLine= null;
- fPositions= null;
- fLastPositions= null;
- fChangedPositions= null;
- fColorMap= null;
+ fIsActive = false;
+ fTextViewer = null;
+ fTextWidget = null;
+ fCursorLine = null;
+ fLastCursorLine = null;
+ fPositions = null;
+ fLastPositions = null;
+ fChangedPositions = null;
+ fColorMap = null;
}
/**
@@ -262,7 +262,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
@Override
public void paint(int reason) {
- IDocument document= fTextViewer.getDocument();
+ IDocument document = fTextViewer.getDocument();
if (document == null) {
deactivate(false);
return;
@@ -271,27 +271,27 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
if (fCursorLineEnabled) {
// check selection
- StyledText textWidget= fTextViewer.getTextWidget();
- Point selection= textWidget.getSelection();
- int startLine= textWidget.getLineAtOffset(selection.x);
- int endLine= textWidget.getLineAtOffset(selection.y);
+ StyledText textWidget = fTextViewer.getTextWidget();
+ Point selection = textWidget.getSelection();
+ int startLine = textWidget.getLineAtOffset(selection.x);
+ int endLine = textWidget.getLineAtOffset(selection.y);
if (startLine != endLine) {
redrawPositions(Collections.singletonList(fLastCursorLine));
- fCursorLineActive= false;
+ fCursorLineActive = false;
} else {
- fCursorLineActive= true;
+ fCursorLineActive = true;
}
if (fCursorLineActive) {
// redraw in case of text changes prior to update of current cursor line
if (!fLastCursorLine.equals(fCursorLine)) {
redrawPositions(Collections.singletonList(fLastCursorLine));
- fLastCursorLine.offset= fCursorLine.offset;
- fLastCursorLine.length= fCursorLine.length;
+ fLastCursorLine.offset = fCursorLine.offset;
+ fLastCursorLine.length = fCursorLine.length;
}
updateCursorLine();
}
}
- List<Position> changedPositions= getChangedPositions();
+ List<Position> changedPositions = getChangedPositions();
if (changedPositions != null) {
redrawPositions(changedPositions);
updatePositions();
@@ -305,7 +305,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
private void activate(boolean redraw) {
if (!fIsActive) {
- fIsActive= true;
+ fIsActive = true;
fTextWidget.addLineBackgroundListener(this);
if (redraw) {
if (fCursorLineActive) {
@@ -322,23 +322,23 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
* Copy positions from the current position list to the last position list.
*/
private void updatePositions() {
- int sz= fPositions.size();
- for (int i= 0; i < sz; ++i) {
- Position position= fPositions.get(i);
+ int sz = fPositions.size();
+ for (int i = 0; i < sz; ++i) {
+ Position position = fPositions.get(i);
Position copy;
if (i == fLastPositions.size()) {
- copy= new Position(position.offset, position.length);
- copy.isDeleted= position.isDeleted;
+ copy = new Position(position.offset, position.length);
+ copy.isDeleted = position.isDeleted;
fLastPositions.add(copy);
} else {
- copy= fLastPositions.get(i);
- copy.offset= position.offset;
- copy.length= position.length;
- copy.isDeleted= position.isDeleted;
+ copy = fLastPositions.get(i);
+ copy.offset = position.offset;
+ copy.length = position.length;
+ copy.isDeleted = position.isDeleted;
}
- position.isDeleted= false;
+ position.isDeleted = false;
}
- int diff= fLastPositions.size() - sz;
+ int diff = fLastPositions.size() - sz;
while (diff > 0) {
--diff;
fLastPositions.remove(sz + diff);
@@ -353,13 +353,13 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
if (fLastPositions.size() != fPositions.size()) {
return fLastPositions;
}
- List<Position> changedPositions= null;
- for (int i= 0, sz= fPositions.size(); i < sz; ++i) {
- Position previous= fLastPositions.get(i);
- Position current= fPositions.get(i);
+ List<Position> changedPositions = null;
+ for (int i = 0, sz = fPositions.size(); i < sz; ++i) {
+ Position previous = fLastPositions.get(i);
+ Position current = fPositions.get(i);
if (!previous.equals(current)) {
if (changedPositions == null) {
- changedPositions= fChangedPositions;
+ changedPositions = fChangedPositions;
changedPositions.clear();
}
changedPositions.add(previous);
@@ -376,14 +376,14 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
private void redrawPositions(List<Position> positions) {
// TextViewer.getTopIndexStartOffset is buggy
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=174419
-// final int minOffset= fTextViewer.getTopIndexStartOffset();
- final int minOffset= getTopIndexStartOffset();
- final int maxOffset= fTextViewer.getBottomIndexEndOffset()+3;
- Rectangle clientArea= fTextWidget.getClientArea();
- int width= clientArea.width + fTextWidget.getHorizontalPixel();
- int lineHeight= fTextWidget.getLineHeight();
- for (int i= 0, sz= positions.size(); i < sz; ++i) {
- Position position= positions.get(i);
+ // final int minOffset= fTextViewer.getTopIndexStartOffset();
+ final int minOffset = getTopIndexStartOffset();
+ final int maxOffset = fTextViewer.getBottomIndexEndOffset() + 3;
+ Rectangle clientArea = fTextWidget.getClientArea();
+ int width = clientArea.width + fTextWidget.getHorizontalPixel();
+ int lineHeight = fTextWidget.getLineHeight();
+ for (int i = 0, sz = positions.size(); i < sz; ++i) {
+ Position position = positions.get(i);
// if the position that is about to be drawn was deleted then we can't
if (position.isDeleted()) {
continue;
@@ -392,21 +392,21 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
if (!position.overlapsWith(minOffset, maxOffset - minOffset + 1)) {
continue;
}
- int widgetOffset= getWidgetOffset(position.offset);
+ int widgetOffset = getWidgetOffset(position.offset);
if (widgetOffset < 0 || widgetOffset > fTextWidget.getCharCount()) {
continue;
}
// TLETODO [performance] SyledText.getLocationAtOffset() is very expensive
- Point upperLeft= fTextWidget.getLocationAtOffset(widgetOffset);
- int upperY= Math.max(Math.min(upperLeft.y, clientArea.height), 0);
+ Point upperLeft = fTextWidget.getLocationAtOffset(widgetOffset);
+ int upperY = Math.max(Math.min(upperLeft.y, clientArea.height), 0);
int height;
if (position.length == 0) {
- height= lineHeight;
+ height = lineHeight;
} else {
- int widgetEndOffset= Math.min(widgetOffset + position.length, fTextWidget.getCharCount());
- Point lowerRight= fTextWidget.getLocationAtOffset(widgetEndOffset);
- int lowerY= Math.min(lowerRight.y + lineHeight, clientArea.height);
- height= lowerY - upperY;
+ int widgetEndOffset = Math.min(widgetOffset + position.length, fTextWidget.getCharCount());
+ Point lowerRight = fTextWidget.getLocationAtOffset(widgetEndOffset);
+ int lowerY = Math.min(lowerRight.y + lineHeight, clientArea.height);
+ height = lowerY - upperY;
}
if (height > 0) {
fTextWidget.redraw(0, upperY, width, height, false);
@@ -421,9 +421,9 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
private int getTopIndexStartOffset() {
if (fTextWidget != null) {
- int top= fTextWidget.getTopIndex();
+ int top = fTextWidget.getTopIndex();
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=183653
- top= fTextWidget.getOffsetAtLine(Math.min(fTextWidget.getLineCount() - 1, top));
+ top = fTextWidget.getOffsetAtLine(Math.min(fTextWidget.getLineCount() - 1, top));
if (top >= 0) {
return getDocumentOffset(top);
}
@@ -437,7 +437,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
@Override
public void deactivate(boolean redraw) {
if (fIsActive) {
- fIsActive= false;
+ fIsActive = false;
fTextWidget.removeLineBackgroundListener(this);
if (redraw) {
redrawPositions(fLastPositions);
@@ -451,7 +451,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
@Override
public void setPositionManager(IPaintPositionManager manager) {
- fPositionManager= manager;
+ fPositionManager = manager;
}
/**
@@ -461,11 +461,11 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
private int getWidgetOffset(int documentOffset) {
if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)fTextViewer;
+ ITextViewerExtension5 extension = (ITextViewerExtension5) fTextViewer;
return extension.modelOffset2WidgetOffset(documentOffset);
}
- IRegion visible= fTextViewer.getVisibleRegion();
- int widgetOffset= documentOffset - visible.getOffset();
+ IRegion visible = fTextViewer.getVisibleRegion();
+ int widgetOffset = documentOffset - visible.getOffset();
if (widgetOffset > visible.getLength()) {
return -1;
}
@@ -479,10 +479,10 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
private int getDocumentOffset(int widgetOffset) {
if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)fTextViewer;
+ ITextViewerExtension5 extension = (ITextViewerExtension5) fTextViewer;
return extension.widgetOffset2ModelOffset(widgetOffset);
}
- IRegion visible= fTextViewer.getVisibleRegion();
+ IRegion visible = fTextViewer.getVisibleRegion();
if (widgetOffset > visible.getLength()) {
return -1;
}
@@ -495,11 +495,11 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
@Override
public void lineGetBackground(LineBackgroundEvent event) {
if (fTextWidget != null) {
- Position match= findIncludingPosition(getDocumentOffset(event.lineOffset));
+ Position match = findIncludingPosition(getDocumentOffset(event.lineOffset));
if (match != null) {
- Color color= getColorForPosition(match);
+ Color color = getColorForPosition(match);
if (color != null) {
- event.lineBackground= color;
+ event.lineBackground = color;
}
}
}
@@ -517,7 +517,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
}
} else {
if (position instanceof TypedPosition) {
- String type= ((TypedPosition)position).getType();
+ String type = ((TypedPosition) position).getType();
return fColorMap.get(type);
}
return fColorMap.get(DEFAULT_TYPE);
@@ -532,8 +532,8 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
private Position findIncludingPosition(int offset) {
// TLETODO [performance] Use binary search?
- for (int i= fCursorLineActive ? 0 : 1, sz= fPositions.size(); i < sz; ++i) {
- Position position= fPositions.get(i);
+ for (int i = fCursorLineActive ? 0 : 1, sz = fPositions.size(); i < sz; ++i) {
+ Position position = fPositions.get(i);
if (position.offset == offset || position.includes(offset)) {
return position;
}
@@ -546,13 +546,13 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
*/
private void updateCursorLine() {
try {
- IDocument document= fTextViewer.getDocument();
+ IDocument document = fTextViewer.getDocument();
if (document != null) {
- int lineNumber= document.getLineOfOffset(getDocumentOffset(fTextWidget.getCaretOffset()));
+ int lineNumber = document.getLineOfOffset(getDocumentOffset(fTextWidget.getCaretOffset()));
- fCursorLine.isDeleted= false;
- fCursorLine.offset= document.getLineOffset(lineNumber);
- fCursorLine.length= 0;
+ fCursorLine.isDeleted = false;
+ fCursorLine.offset = document.getLineOffset(lineNumber);
+ fCursorLine.length = 0;
}
} catch (BadLocationException e) {
// gracefully ignored
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java
index e1e1b860069..87c6cec2ff9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java
@@ -21,7 +21,7 @@ import org.eclipse.cdt.ui.CElementGrouping;
/**
* Grouping for macro definitions.
- *
+ *
* @since 5.2
*/
public class MacrosGrouping extends CElementGrouping {
@@ -61,7 +61,7 @@ public class MacrosGrouping extends CElementGrouping {
return true;
}
if (obj instanceof MacrosGrouping) {
- return tu.equals(((MacrosGrouping)obj).tu) ;
+ return tu.equals(((MacrosGrouping) obj).tu);
}
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java
index f4d83f785b9..d67b8f22a48 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java
@@ -36,8 +36,8 @@ public class MembersGrouping extends CElementGrouping {
public MembersGrouping(Object parent, String namespace) {
super(CElementGrouping.CLASS_GROUPING);
assert parent instanceof ICElement || parent instanceof NamespacesGrouping;
- fParent= parent;
- fNamespace= namespace;
+ fParent = parent;
+ fNamespace = namespace;
}
@Override
@@ -50,7 +50,7 @@ public class MembersGrouping extends CElementGrouping {
List<ICElement> nsMembers = new ArrayList<ICElement>();
if (fParent instanceof IParent) {
try {
- nsMembers.addAll(getNamespaceChildren(((IParent)fParent).getChildren()));
+ nsMembers.addAll(getNamespaceChildren(((IParent) fParent).getChildren()));
} catch (CModelException exc) {
}
} else if (fParent instanceof NamespacesGrouping) {
@@ -99,7 +99,7 @@ public class MembersGrouping extends CElementGrouping {
return true;
}
if (obj instanceof MembersGrouping) {
- final MembersGrouping other= (MembersGrouping)obj;
+ final MembersGrouping other = (MembersGrouping) obj;
return fParent.equals(other.fParent) && fNamespace.equals(other.fNamespace);
}
return false;
@@ -109,7 +109,7 @@ public class MembersGrouping extends CElementGrouping {
public int hashCode() {
return fParent.hashCode() * 17 + fNamespace.hashCode();
}
-
+
@Override
public String toString() {
return fNamespace;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
index 35e56d7b55d..c58eaef6c5d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
@@ -41,67 +41,67 @@ import org.eclipse.cdt.core.model.ICElement;
*/
public class PersistableCElementFactory implements IElementFactory, IPersistableElement {
- // These persistence constants are stored in XML. Do not
- // change them.
- private static final String TAG_PATH = "path";//$NON-NLS-1$
- private static final String TAG_TYPE = "type";//$NON-NLS-1$
+ // These persistence constants are stored in XML. Do not
+ // change them.
+ private static final String TAG_PATH = "path";//$NON-NLS-1$
+ private static final String TAG_TYPE = "type";//$NON-NLS-1$
- private static final String FACTORY_ID = "org.eclipse.cdt.ui.PersistableCElementFactory";//$NON-NLS-1$
+ private static final String FACTORY_ID = "org.eclipse.cdt.ui.PersistableCElementFactory";//$NON-NLS-1$
- // IPersistable data.
- private ICElement fCElement;
+ // IPersistable data.
+ private ICElement fCElement;
- /**
- * Create a PersistableCElementFactory. This constructor is typically used
- * for our IElementFactory side.
- */
- public PersistableCElementFactory() {
- }
+ /**
+ * Create a PersistableCElementFactory. This constructor is typically used
+ * for our IElementFactory side.
+ */
+ public PersistableCElementFactory() {
+ }
- /**
- * Create a PersistableCElementFactory. This constructor is typically used
- * for our IPersistableElement side.
- */
- public PersistableCElementFactory(ICElement input) {
- fCElement = input;
- }
+ /**
+ * Create a PersistableCElementFactory. This constructor is typically used
+ * for our IPersistableElement side.
+ */
+ public PersistableCElementFactory(ICElement input) {
+ fCElement = input;
+ }
- /**
- * @see IElementFactory
- */
- @Override
+ /**
+ * @see IElementFactory
+ */
+ @Override
public IAdaptable createElement(IMemento memento) {
- // Get the file name.
- String fileName = memento.getString(TAG_PATH);
- if (fileName == null) {
+ // Get the file name.
+ String fileName = memento.getString(TAG_PATH);
+ if (fileName == null) {
return null;
}
- IPath elementPath= new Path(fileName);
- fCElement = CoreModel.getDefault().create(elementPath);
- if (fCElement != null && fCElement.getResource() != null) {
- IResource resource= fCElement.getResource();
- if (!resource.isAccessible()) {
- return resource;
- }
- }
- if (fCElement != null) {
- return fCElement;
- }
+ IPath elementPath = new Path(fileName);
+ fCElement = CoreModel.getDefault().create(elementPath);
+ if (fCElement != null && fCElement.getResource() != null) {
+ IResource resource = fCElement.getResource();
+ if (!resource.isAccessible()) {
+ return resource;
+ }
+ }
+ if (fCElement != null) {
+ return fCElement;
+ }
- final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- Integer elementType= memento.getInteger(TAG_TYPE);
+ final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ Integer elementType = memento.getInteger(TAG_TYPE);
if (elementType == null) {
if (elementPath.segmentCount() == 1) {
return root.getProject(fileName);
}
- IFolder folder= root.getFolder(elementPath);
- File osFile= folder.getLocation().toFile();
- if (osFile.isDirectory()) {
- return folder;
- }
- return root.getFile(elementPath);
- }
+ IFolder folder = root.getFolder(elementPath);
+ File osFile = folder.getLocation().toFile();
+ if (osFile.isDirectory()) {
+ return folder;
+ }
+ return root.getFile(elementPath);
+ }
switch (elementType.intValue()) {
case IResource.ROOT:
return root;
@@ -112,25 +112,25 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable
case IResource.FILE:
return root.getFile(elementPath);
}
- return null;
- }
+ return null;
+ }
- /**
- * @see IPersistableElement
- */
- @Override
+ /**
+ * @see IPersistableElement
+ */
+ @Override
public String getFactoryId() {
- return FACTORY_ID;
- }
+ return FACTORY_ID;
+ }
- /**
- * @see IPersistableElement
- */
- @Override
+ /**
+ * @see IPersistableElement
+ */
+ @Override
public void saveState(IMemento memento) {
- if (fCElement.getResource() != null) {
- memento.putString(TAG_PATH, fCElement.getResource().getFullPath().toString());
- memento.putInteger(TAG_TYPE, fCElement.getResource().getType());
- }
- }
+ if (fCElement.getResource() != null) {
+ memento.putString(TAG_PATH, fCElement.getResource().getFullPath().toString());
+ memento.putInteger(TAG_TYPE, fCElement.getResource().getType());
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java
index 7c6acc357f4..3281bb0fa2e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java
@@ -26,12 +26,10 @@ import org.eclipse.cdt.core.model.ICElement;
public class ResourceAdapterFactory implements IAdapterFactory {
- private static Class<?>[] PROPERTIES= new Class[] {
- ICElement.class
- };
+ private static Class<?>[] PROPERTIES = new Class[] { ICElement.class };
//private static CElementFactory celementFactory= new CElementFactory();
- private static CoreModel celementFactory= CoreModel.getDefault();
+ private static CoreModel celementFactory = CoreModel.getDefault();
/**
* @see IAdapterFactory#getAdapterList
@@ -46,17 +44,17 @@ public class ResourceAdapterFactory implements IAdapterFactory {
public <T> T getAdapter(Object element, Class<T> key) {
if (ICElement.class.equals(key)) {
//try {
- if (element instanceof IFile) {
- return (T) celementFactory.create((IFile)element);
- } else if (element instanceof IFolder) {
- return (T) celementFactory.create((IFolder)element);
- } else if (element instanceof IProject) {
- return (T) celementFactory.create((IProject)element);
- } else if (element instanceof IWorkspaceRoot) {
- return (T) CoreModel.create((IWorkspaceRoot)element);
- } else if (element instanceof IResource) {
- return (T) celementFactory.create((IResource)element);
- }
+ if (element instanceof IFile) {
+ return (T) celementFactory.create((IFile) element);
+ } else if (element instanceof IFolder) {
+ return (T) celementFactory.create((IFolder) element);
+ } else if (element instanceof IProject) {
+ return (T) celementFactory.create((IProject) element);
+ } else if (element instanceof IWorkspaceRoot) {
+ return (T) CoreModel.create((IWorkspaceRoot) element);
+ } else if (element instanceof IResource) {
+ return (T) celementFactory.create((IResource) element);
+ }
//} catch (CoreException e) {
// CUIPlugin.getDefault().getLog().log(e.getStatus());
//}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceToCElementAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceToCElementAdapterFactory.java
index f9f97b091a0..7a875cb5d9e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceToCElementAdapterFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceToCElementAdapterFactory.java
@@ -17,7 +17,6 @@ import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.cdt.core.model.CoreModelUtil;
import org.eclipse.cdt.core.model.ITranslationUnit;
-
/**
* An adapter factory that adapts resources to CElements. This was introduced in
* the context of non-extensible content providers (Package Explorer) which
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java
index 8664562791d..e9842099914 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java
@@ -21,11 +21,11 @@ import org.eclipse.ui.PlatformUI;
/**
* This is an action template for actions that toggle whether
* it links its selection to the active editor.
- *
+ *
* @since 3.0
*/
public abstract class AbstractToggleLinkingAction extends Action {
-
+
/**
* Constructs a new action.
*/
@@ -33,7 +33,7 @@ public abstract class AbstractToggleLinkingAction extends Action {
super(ActionMessages.ToggleLinkingAction_label);
setDescription(ActionMessages.ToggleLinkingAction_description);
setToolTipText(ActionMessages.ToggleLinkingAction_tooltip);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "synced.gif"); //$NON-NLS-1$
+ CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "synced.gif"); //$NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.LINK_EDITOR_ACTION);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java
index fb65c29702b..ef6179ffe2a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java
@@ -70,21 +70,21 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate
public void selectionChanged(IAction action, ISelection selection) {
fSelection = selection;
}
-
+
public boolean isEnabledFor(ISelection selection) {
selectionChanged(null, selection);
ICElement[] elements = getSelectedCElements();
return elements.length > 0;
}
-
+
protected ICElement[] getSelectedCElements() {
- ArrayList<ICElement> tuSelection= new ArrayList<ICElement>();
+ ArrayList<ICElement> tuSelection = new ArrayList<ICElement>();
if (fSelection instanceof IStructuredSelection) {
IStructuredSelection resources = SelectionConverter.convertSelectionToResources(fSelection);
- for (Iterator<?> i= resources.iterator(); i.hasNext();) {
- Object o= i.next();
+ for (Iterator<?> i = resources.iterator(); i.hasNext();) {
+ Object o = i.next();
if (o instanceof IResource) {
- ICElement celement= CCorePlugin.getDefault().getCoreModel().create((IResource) o);
+ ICElement celement = CCorePlugin.getDefault().getCoreModel().create((IResource) o);
if (celement != null) {
tuSelection.add(celement);
}
@@ -93,7 +93,7 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate
} else if (fSelection == null || fSelection instanceof ITextSelection) {
IProject project = EditorUtility.getProjectForActiveEditor();
if (project != null) {
- ICProject cproject= CCorePlugin.getDefault().getCoreModel().create(project);
+ ICProject cproject = CCorePlugin.getDefault().getCoreModel().create(project);
if (cproject != null) {
tuSelection.add(cproject);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexHandler.java
index af22d3dde88..3ee28358856 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexHandler.java
@@ -26,9 +26,9 @@ import org.eclipse.cdt.internal.ui.util.SelectionUtil;
* Abstract handler for {@link org.eclipse.cdt.internal.ui.actions.AbstractUpdateIndexAction}
*/
public abstract class AbstractUpdateIndexHandler extends AbstractHandler {
-
+
abstract protected AbstractUpdateIndexAction getAction();
-
+
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
@@ -44,7 +44,7 @@ public abstract class AbstractUpdateIndexHandler extends AbstractHandler {
*/
@Override
public void setEnabled(Object evaluationContext) {
- ISelection selection = SelectionUtil.getActiveSelection();
- setBaseEnabled(getAction().isEnabledFor(selection));
+ ISelection selection = SelectionUtil.getActiveSelection();
+ setBaseEnabled(getAction().isEnabledFor(selection));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
index 47adfd73d78..276f39a1df0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Rational Software - initial implementation
* Sergey Prigogin (Google)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java
index 6bbb5936d51..7627308fa7d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java
@@ -34,59 +34,57 @@ import org.eclipse.cdt.internal.ui.viewsupport.BasicElementLabels;
* http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
*/
public class ActionUtil {
-
- private ActionUtil(){
+
+ private ActionUtil() {
}
//bug 31998 we will have to disable renaming of linked packages (and cus)
public static boolean mustDisableCModelAction(Shell shell, Object element) {
- return false;
-// if (!(element instanceof IPackageFragment) && !(element instanceof IPackageFragmentRoot))
-// return false;
-//
-// IResource resource= ResourceUtil.getResource(element);
-// if ((resource == null) || (! (resource instanceof IFolder)) || (! resource.isLinked()))
-// return false;
-//
-// MessageDialog.openInformation(shell, ActionMessages.ActionUtil.not_possible"), ActionMessages.ActionUtil.no_linked")); //$NON-NLS-1$ //$NON-NLS-2$
-// return true;
+ return false;
+ // if (!(element instanceof IPackageFragment) && !(element instanceof IPackageFragmentRoot))
+ // return false;
+ //
+ // IResource resource= ResourceUtil.getResource(element);
+ // if ((resource == null) || (! (resource instanceof IFolder)) || (! resource.isLinked()))
+ // return false;
+ //
+ // MessageDialog.openInformation(shell, ActionMessages.ActionUtil.not_possible"), ActionMessages.ActionUtil.no_linked")); //$NON-NLS-1$ //$NON-NLS-2$
+ // return true;
}
-
+
public static boolean isProcessable(CEditor editor) {
if (editor == null)
return true;
Shell shell = editor.getSite().getShell();
- ICElement input= SelectionConverter.getInput(editor);
+ ICElement input = SelectionConverter.getInput(editor);
// if a C/C++ editor doesn't have an input of type C element
// then it is for sure not on the build path
if (input == null) {
- MessageDialog.openInformation(shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
+ MessageDialog.openInformation(shell, ActionMessages.ActionUtil_notOnBuildPath_title,
ActionMessages.ActionUtil_notOnBuildPath_message);
return false;
}
return isProcessable(shell, input);
}
-
+
public static boolean isProcessable(Shell shell, Object element) {
if (!(element instanceof ICElement))
return true;
-
+
if (isOnBuildPath((ICElement) element))
return true;
- MessageDialog.openInformation(shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
+ MessageDialog.openInformation(shell, ActionMessages.ActionUtil_notOnBuildPath_title,
ActionMessages.ActionUtil_notOnBuildPath_message);
return false;
}
- public static boolean isOnBuildPath(ICElement element) {
- //fix for bug http://dev.eclipse.org/bugs/show_bug.cgi?id=20051
- if (element.getElementType() == ICElement.C_PROJECT)
- return true;
-// ICProject project= element.getCProject();
-// if (!project.isOnSourceRoot(element.getResource()))
-// return false;
+ public static boolean isOnBuildPath(ICElement element) {
+ //fix for bug http://dev.eclipse.org/bugs/show_bug.cgi?id=20051
+ if (element.getElementType() == ICElement.C_PROJECT)
+ return true;
+ // ICProject project= element.getCProject();
+ // if (!project.isOnSourceRoot(element.getResource()))
+ // return false;
return true;
}
@@ -105,7 +103,7 @@ public class ActionUtil {
*/
public static boolean isEditable(CEditor editor, Shell shell, ICElement element) {
if (editor != null) {
- ICElement input= SelectionConverter.getInput(editor);
+ ICElement input = SelectionConverter.getInput(editor);
if (input != null && input.equals(element.getAncestor(ICElement.C_UNIT)))
return isEditable(editor);
else
@@ -120,29 +118,26 @@ public class ActionUtil {
return editor.validateEditorInputState();
}
-
+
public static boolean isEditable(Shell shell, ICElement element) {
if (!isProcessable(shell, element))
return false;
- ICElement cu= element.getAncestor(ICElement.C_UNIT);
+ ICElement cu = element.getAncestor(ICElement.C_UNIT);
if (cu != null) {
- IResource resource= cu.getResource();
+ IResource resource = cu.getResource();
if (resource != null && resource.isDerived()) {
// see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#validateEditorInputState()
- final String warnKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED;
- IPreferenceStore store= EditorsUI.getPreferenceStore();
+ final String warnKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED;
+ IPreferenceStore store = EditorsUI.getPreferenceStore();
if (!store.getBoolean(warnKey))
return true;
- MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
- shell,
+ MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(shell,
ActionMessages.ActionUtil_warning_derived_title,
- Messages.format(ActionMessages.ActionUtil_warning_derived_message, BasicElementLabels.getPathLabel(resource.getFullPath(), false)),
- ActionMessages.ActionUtil_warning_derived_dontShowAgain,
- false,
- null,
- null);
+ Messages.format(ActionMessages.ActionUtil_warning_derived_message,
+ BasicElementLabels.getPathLabel(resource.getFullPath(), false)),
+ ActionMessages.ActionUtil_warning_derived_dontShowAgain, false, null, null);
EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState());
return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
@@ -151,4 +146,3 @@ public class ActionUtil {
return true;
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java
index 506b9446209..a4fdf5de1cf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java
@@ -34,39 +34,39 @@ import org.eclipse.cdt.ui.text.ICPartitions;
/**
* Action that encloses the editor's current selection with C block comment terminators
* (<code>&#47;&#42;</code> and <code>&#42;&#47;</code>).
- *
+ *
* @since 3.0
*/
public class AddBlockCommentAction extends BlockCommentAction {
/**
* Creates a new instance.
- *
+ *
* @param bundle the resource bundle
* @param prefix a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or
+ * (described in <code>ResourceAction</code> constructor), or
* <code>null</code> if none
* @param editor the text editor
*/
public AddBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
super(bundle, prefix, editor);
}
-
+
@Override
- protected void runInternal(ITextSelection selection,
- IDocumentExtension3 docExtension, Edit.EditFactory factory)
+ protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory)
throws BadLocationException, BadPartitioningException {
-
- if ( !(docExtension instanceof IDocument) ) return;
-
- List<Edit> edits= new LinkedList<Edit>();
- ITypedRegion firstPartition = docExtension.getPartition(ICPartitions.C_PARTITIONING,
- selection.getOffset(), false);
+ if (!(docExtension instanceof IDocument))
+ return;
+
+ List<Edit> edits = new LinkedList<Edit>();
+
+ ITypedRegion firstPartition = docExtension.getPartition(ICPartitions.C_PARTITIONING, selection.getOffset(),
+ false);
ITypedRegion lastPartition = docExtension.getPartition(ICPartitions.C_PARTITIONING,
selection.getOffset() + selection.getLength() - 1, false);
-
+
int commentAreaStart = selection.getOffset();
- int commentAreaEnd = selection.getOffset()+selection.getLength();
+ int commentAreaEnd = selection.getOffset() + selection.getLength();
// Include special partitions fully in the comment area
if (isSpecialPartition(firstPartition.getType())) {
commentAreaStart = firstPartition.getOffset();
@@ -74,20 +74,19 @@ public class AddBlockCommentAction extends BlockCommentAction {
if (isSpecialPartition(lastPartition.getType())) {
commentAreaEnd = lastPartition.getOffset() + lastPartition.getLength();
}
- Region estimatedCommentArea = new Region(commentAreaStart,commentAreaEnd-commentAreaStart);
+ Region estimatedCommentArea = new Region(commentAreaStart, commentAreaEnd - commentAreaStart);
-
- Region commentArea = handleEnclosingPartitions(estimatedCommentArea, lastPartition,
- (IDocument)docExtension, factory, edits);
+ Region commentArea = handleEnclosingPartitions(estimatedCommentArea, lastPartition, (IDocument) docExtension,
+ factory, edits);
handleInteriorPartition(commentArea, firstPartition, docExtension, factory, edits);
-
+
executeEdits(edits);
}
/**
* Add enclosing comment tags for the whole area to be commented
- *
+ *
* @param commentArea initial comment area which can be adjusted
* @param lastPartition last partition
* @param doc document
@@ -96,56 +95,57 @@ public class AddBlockCommentAction extends BlockCommentAction {
* @return new possibly adjusted comment area
* @throws BadLocationException
*/
- private Region handleEnclosingPartitions(Region commentArea,
- ITypedRegion lastPartition, IDocument doc, Edit.EditFactory factory,
- List<Edit> edits) throws BadLocationException {
-
+ private Region handleEnclosingPartitions(Region commentArea, ITypedRegion lastPartition, IDocument doc,
+ Edit.EditFactory factory, List<Edit> edits) throws BadLocationException {
+
int commentAreaStart = commentArea.getOffset();
int commentAreaEnd = commentArea.getOffset() + commentArea.getLength();
-
+
String commentStartTag = getCommentStart(); // "/*"
- String commentEndTag = getCommentEnd(); // "*/"
-
+ String commentEndTag = getCommentEnd(); // "*/"
+
String startLineEOL = doc.getLineDelimiter(doc.getLineOfOffset(commentAreaStart));
- if (startLineEOL==null) startLineEOL=""; //$NON-NLS-1$
- String endLineEOL = doc.getLineDelimiter(doc.getLineOfOffset(commentAreaEnd-1));
- if (endLineEOL==null) endLineEOL=""; //$NON-NLS-1$
-
- boolean isLeftEol = commentAreaStart<startLineEOL.length()
- || doc.get(commentAreaStart-startLineEOL.length(),startLineEOL.length()).equals(startLineEOL);
- boolean isRightEol = doc.get(commentAreaEnd-endLineEOL.length(),endLineEOL.length()).equals(endLineEOL);
-
+ if (startLineEOL == null)
+ startLineEOL = ""; //$NON-NLS-1$
+ String endLineEOL = doc.getLineDelimiter(doc.getLineOfOffset(commentAreaEnd - 1));
+ if (endLineEOL == null)
+ endLineEOL = ""; //$NON-NLS-1$
+
+ boolean isLeftEol = commentAreaStart < startLineEOL.length()
+ || doc.get(commentAreaStart - startLineEOL.length(), startLineEOL.length()).equals(startLineEOL);
+ boolean isRightEol = doc.get(commentAreaEnd - endLineEOL.length(), endLineEOL.length()).equals(endLineEOL);
+
if (isLeftEol && isRightEol) {
// Block of full lines found
- int areaStartLine = doc.getLineOfOffset(commentAreaStart+startLineEOL.length());
- int areaEndLine = doc.getLineOfOffset(commentAreaEnd-endLineEOL.length());
- if (areaStartLine!=areaEndLine) {
+ int areaStartLine = doc.getLineOfOffset(commentAreaStart + startLineEOL.length());
+ int areaEndLine = doc.getLineOfOffset(commentAreaEnd - endLineEOL.length());
+ if (areaStartLine != areaEndLine) {
// If multiple full lines arrange inserting comment tags on their own lines
- commentStartTag = getCommentStart()+startLineEOL;
- commentEndTag = getCommentEnd()+endLineEOL;
+ commentStartTag = getCommentStart() + startLineEOL;
+ commentEndTag = getCommentEnd() + endLineEOL;
} else {
// If one full line insert end comment tag on the same line (before the EOL)
- commentAreaEnd = commentAreaEnd-endLineEOL.length();
+ commentAreaEnd = commentAreaEnd - endLineEOL.length();
}
} else {
if (lastPartition.getType() == ICPartitions.C_SINGLE_LINE_COMMENT
|| lastPartition.getType() == ICPartitions.C_SINGLE_LINE_DOC_COMMENT) {
// C++ comments "//" partition ends with EOL, insert end comment tag before it
// on the same line, so we get something like /*// text*/
- commentAreaEnd = commentAreaEnd-endLineEOL.length();
+ commentAreaEnd = commentAreaEnd - endLineEOL.length();
}
}
-
+
edits.add(factory.createEdit(commentAreaStart, 0, commentStartTag));
edits.add(factory.createEdit(commentAreaEnd, 0, commentEndTag));
-
- return new Region(commentAreaStart,commentAreaEnd-commentAreaStart);
+
+ return new Region(commentAreaStart, commentAreaEnd - commentAreaStart);
}
/**
* Make all inside partitions join in one comment, in particular remove
* all enclosing comment tokens of the inside partitions.
- *
+ *
* @param commentArea comment area region
* @param partition first partition
* @param docExtension document
@@ -154,39 +154,38 @@ public class AddBlockCommentAction extends BlockCommentAction {
* @throws BadLocationException
* @throws BadPartitioningException
*/
- private void handleInteriorPartition(IRegion commentArea,
- ITypedRegion partition, IDocumentExtension3 docExtension,
- Edit.EditFactory factory, List<Edit> edits)
- throws BadLocationException, BadPartitioningException {
-
+ private void handleInteriorPartition(IRegion commentArea, ITypedRegion partition, IDocumentExtension3 docExtension,
+ Edit.EditFactory factory, List<Edit> edits) throws BadLocationException, BadPartitioningException {
+
int commentAreaEnd = commentArea.getOffset() + commentArea.getLength();
int prevPartitionEnd = -1;
- int partitionEnd = partition.getOffset()+partition.getLength();
-
+ int partitionEnd = partition.getOffset() + partition.getLength();
+
final int startCommentTokenLength = getCommentStart().length();
final int endCommentTokenLength = getCommentEnd().length();
-
- while (partitionEnd<=commentAreaEnd) {
+
+ while (partitionEnd <= commentAreaEnd) {
if (partition.getType() == ICPartitions.C_MULTI_LINE_COMMENT
- || partition.getType() == ICPartitions.C_MULTI_LINE_DOC_COMMENT) {
+ || partition.getType() == ICPartitions.C_MULTI_LINE_DOC_COMMENT) {
// already in a comment - remove start/end tokens
edits.add(factory.createEdit(partition.getOffset(), startCommentTokenLength, "")); //$NON-NLS-1$
- edits.add(factory.createEdit(partitionEnd - endCommentTokenLength, endCommentTokenLength, "")); //$NON-NLS-1$
+ edits.add(factory.createEdit(partitionEnd - endCommentTokenLength, endCommentTokenLength, "")); //$NON-NLS-1$
}
// advance to next partition
prevPartitionEnd = partitionEnd;
- partition= docExtension.getPartition(ICPartitions.C_PARTITIONING, partitionEnd, false);
+ partition = docExtension.getPartition(ICPartitions.C_PARTITIONING, partitionEnd, false);
partitionEnd = partition.getOffset() + partition.getLength();
-
+
// break the loop if we get stuck and no advance was made
- if (partitionEnd<=prevPartitionEnd) break;
+ if (partitionEnd <= prevPartitionEnd)
+ break;
}
}
/**
* Returns whether <code>partType</code> is special, i.e. a <code>String</code>,
* <code>Character</code>, or <code>Comment</code> partition.
- *
+ *
* @param partType the partition type to check
* @return <code>true</code> if <code>partType</code> is special, <code>false</code> otherwise
*/
@@ -199,5 +198,4 @@ public class AddBlockCommentAction extends BlockCommentAction {
return selection != null && !selection.isEmpty() && selection.getLength() > 0;
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AlignConstAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AlignConstAction.java
index 707e87a752d..dcf41ce8bf4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AlignConstAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AlignConstAction.java
@@ -73,7 +73,7 @@ public class AlignConstAction extends TextEditorAction {
String candidate = signature.substring(0, Keywords.CONST.length() + 1);
return !IdentifierHelper.checkIdentifierName(candidate).isCorrect();
}
-
+
private boolean endsWithConst(String signature) {
if (!signature.endsWith(Keywords.CONST)) {
return false;
@@ -91,14 +91,12 @@ public class AlignConstAction extends TextEditorAction {
boolean expectConstRight = CCorePreferenceConstants.getPreference(
CCorePreferenceConstants.PLACE_CONST_RIGHT_OF_TYPE, cProject,
CCorePreferenceConstants.DEFAULT_PLACE_CONST_RIGHT_OF_TYPE);
- MisalignedConstFinderVisitor misalignedConstVisitor = new MisalignedConstFinderVisitor(
- expectConstRight);
+ MisalignedConstFinderVisitor misalignedConstVisitor = new MisalignedConstFinderVisitor(expectConstRight);
rootNode.accept(misalignedConstVisitor);
return misalignedConstVisitor.getDeclSpecifiersWithMisaligedConst();
}
- public static void rewriteMisalignedConstSpecifiers(IASTNode node, IProgressMonitor monitor)
- throws CoreException {
+ public static void rewriteMisalignedConstSpecifiers(IASTNode node, IProgressMonitor monitor) throws CoreException {
ICProject cProject = node.getTranslationUnit().getOriginatingTranslationUnit().getCProject();
List<IASTDeclSpecifier> misalignedSpecifiers = findMisalignedConsts(node, cProject);
if (!misalignedSpecifiers.isEmpty()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java
index 42e4387a01e..5be84387159 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java
@@ -40,7 +40,7 @@ import org.eclipse.ui.texteditor.TextEditorAction;
/**
* Common block comment code.
- *
+ *
* @since 3.0
*/
public abstract class BlockCommentAction extends TextEditorAction {
@@ -55,15 +55,15 @@ public abstract class BlockCommentAction extends TextEditorAction {
}
/**
- * An edit is a kind of <code>DocumentEvent</code>, in this case an edit instruction, that is
- * affiliated with a <code>Position</code> on a document. The offset of the document event is
- * not stored statically, but taken from the affiliated <code>Position</code>, which gets
+ * An edit is a kind of <code>DocumentEvent</code>, in this case an edit instruction, that is
+ * affiliated with a <code>Position</code> on a document. The offset of the document event is
+ * not stored statically, but taken from the affiliated <code>Position</code>, which gets
* updated when other edits occur.
*/
static class Edit extends DocumentEvent {
-
+
/**
- * Factory for edits which manages the creation, installation and destruction of
+ * Factory for edits which manages the creation, installation and destruction of
* position categories, position updaters etc. on a certain document. Once a factory has
* been obtained, <code>Edit</code> objects can be obtained from it which will be linked to
* the document by positions of one position category.
@@ -71,44 +71,44 @@ public abstract class BlockCommentAction extends TextEditorAction {
* used any more, so the positions can be discarded.</p>
*/
public static class EditFactory {
-
+
/** The position category basename for this edits. */
- private static final String CATEGORY= "__positionalEditPositionCategory"; //$NON-NLS-1$
-
+ private static final String CATEGORY = "__positionalEditPositionCategory"; //$NON-NLS-1$
+
/** The count of factories. */
- private static int fgCount= 0;
-
+ private static int fgCount = 0;
+
/** This factory's category. */
private final String fCategory;
private IDocument fDocument;
private IPositionUpdater fUpdater;
-
+
/**
* Creates a new <code>EditFactory</code> with an unambiguous position category name.
* @param document the document that is being edited.
*/
public EditFactory(IDocument document) {
- fCategory= CATEGORY + fgCount++;
- fDocument= document;
+ fCategory = CATEGORY + fgCount++;
+ fDocument = document;
}
-
+
/**
* Creates a new edition on the document of this factory.
- *
+ *
* @param offset the offset of the edition at the point when is created.
* @param length the length of the edition (not updated via the position update mechanism)
* @param text the text to be replaced on the document
* @return an <code>Edit</code> reflecting the edition on the document
*/
public Edit createEdit(int offset, int length, String text) throws BadLocationException {
-
+
if (!fDocument.containsPositionCategory(fCategory)) {
fDocument.addPositionCategory(fCategory);
- fUpdater= new DefaultPositionUpdater(fCategory);
+ fUpdater = new DefaultPositionUpdater(fCategory);
fDocument.addPositionUpdater(fUpdater);
}
-
- Position position= new Position(offset);
+
+ Position position = new Position(offset);
try {
fDocument.addPosition(fCategory, position);
} catch (BadPositionCategoryException e) {
@@ -116,9 +116,9 @@ public abstract class BlockCommentAction extends TextEditorAction {
}
return new Edit(fDocument, length, text, position);
}
-
+
/**
- * Releases the position category on the document and uninstalls the position updater.
+ * Releases the position category on the document and uninstalls the position updater.
* <code>Edit</code>s managed by this factory are not updated after this call.
*/
public void release() {
@@ -129,18 +129,18 @@ public abstract class BlockCommentAction extends TextEditorAction {
} catch (BadPositionCategoryException e) {
Assert.isTrue(false);
}
- fDocument= null;
- fUpdater= null;
+ fDocument = null;
+ fUpdater = null;
}
}
}
-
+
/** The position in the document where this edit be executed. */
private Position fPosition;
-
+
/**
* Creates a new edition on <code>document</code>, taking its offset from <code>position</code>.
- *
+ *
* @param document the document being edited
* @param length the length of the edition
* @param text the replacement text of the edition
@@ -148,9 +148,9 @@ public abstract class BlockCommentAction extends TextEditorAction {
*/
protected Edit(IDocument document, int length, String text, Position position) {
super(document, 0, length, text);
- fPosition= position;
+ fPosition = position;
}
-
+
/*
* @see org.eclipse.jface.text.DocumentEvent#getOffset()
*/
@@ -158,68 +158,68 @@ public abstract class BlockCommentAction extends TextEditorAction {
public int getOffset() {
return fPosition.getOffset();
}
-
+
/**
* Executes the edition on document. The offset is taken from the position.
- *
+ *
* @throws BadLocationException if the execution of the document fails.
*/
public void perform() throws BadLocationException {
getDocument().replace(getOffset(), getLength(), getText());
}
-
+
}
@Override
public void run() {
if (!isEnabled())
return;
-
- ITextEditor editor= getTextEditor();
+
+ ITextEditor editor = getTextEditor();
if (editor == null || !ensureEditable(editor))
return;
-
- ITextSelection selection= getCurrentSelection();
+
+ ITextSelection selection = getCurrentSelection();
if (!isValidSelection(selection))
return;
-
+
if (!validateEditorInputState())
return;
-
- IDocumentProvider docProvider= editor.getDocumentProvider();
- IEditorInput input= editor.getEditorInput();
+
+ IDocumentProvider docProvider = editor.getDocumentProvider();
+ IEditorInput input = editor.getEditorInput();
if (docProvider == null || input == null)
return;
-
- IDocument document= docProvider.getDocument(input);
+
+ IDocument document = docProvider.getDocument(input);
if (document == null)
return;
-
+
IDocumentExtension3 docExtension;
if (document instanceof IDocumentExtension3)
- docExtension= (IDocumentExtension3) document;
+ docExtension = (IDocumentExtension3) document;
else
return;
-
- IRewriteTarget target= editor.getAdapter(IRewriteTarget.class);
+
+ IRewriteTarget target = editor.getAdapter(IRewriteTarget.class);
if (target != null) {
target.beginCompoundChange();
}
-
- Edit.EditFactory factory= new Edit.EditFactory(document);
-
+
+ Edit.EditFactory factory = new Edit.EditFactory(document);
+
try {
runInternal(selection, docExtension, factory);
-
+
} catch (BadLocationException e) {
- // can happen on concurrent modification, deletion etc. of the document
+ // can happen on concurrent modification, deletion etc. of the document
// -> don't complain, just bail out
} catch (BadPartitioningException e) {
// should not happen
- Assert.isTrue(false, "bad partitioning"); //$NON-NLS-1$
+ Assert.isTrue(false, "bad partitioning"); //$NON-NLS-1$
} finally {
factory.release();
-
+
if (target != null) {
target.endCompoundChange();
}
@@ -228,33 +228,33 @@ public abstract class BlockCommentAction extends TextEditorAction {
/**
* Calls <code>perform</code> on all <code>Edit</code>s in <code>edits</code>.
- *
+ *
* @param edits a list of <code>Edit</code>s
* @throws BadLocationException if an <code>Edit</code> threw such an exception.
*/
protected void executeEdits(List<Edit> edits) throws BadLocationException {
- for (Iterator<Edit> it= edits.iterator(); it.hasNext();) {
- Edit edit= it.next();
+ for (Iterator<Edit> it = edits.iterator(); it.hasNext();) {
+ Edit edit = it.next();
edit.perform();
}
}
/**
* Ensures that the editor is modifyable. If the editor is an instance of
- * <code>ITextEditorExtension2</code>, its <code>validateEditorInputState</code> method
+ * <code>ITextEditorExtension2</code>, its <code>validateEditorInputState</code> method
* is called, otherwise, the result of <code>isEditable</code> is returned.
- *
+ *
* @param editor the editor to be checked
* @return <code>true</code> if the editor is editable, <code>false</code> otherwise
*/
protected boolean ensureEditable(ITextEditor editor) {
Assert.isNotNull(editor);
-
+
if (editor instanceof ITextEditorExtension2) {
- ITextEditorExtension2 ext= (ITextEditorExtension2) editor;
+ ITextEditorExtension2 ext = (ITextEditorExtension2) editor;
return ext.validateEditorInputState();
}
-
+
return editor.isEditable();
}
@@ -264,7 +264,7 @@ public abstract class BlockCommentAction extends TextEditorAction {
@Override
public void update() {
super.update();
-
+
if (isEnabled()) {
if (!canModifyEditor() || !isValidSelection(getCurrentSelection()))
setEnabled(false);
@@ -272,18 +272,18 @@ public abstract class BlockCommentAction extends TextEditorAction {
}
/**
- * Returns the editor's selection, or <code>null</code> if no selection can be obtained or the
+ * Returns the editor's selection, or <code>null</code> if no selection can be obtained or the
* editor is <code>null</code>.
- *
+ *
* @return the selection of the action's editor, or <code>null</code>
*/
protected ITextSelection getCurrentSelection() {
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (editor != null) {
- ISelectionProvider provider= editor.getSelectionProvider();
+ ISelectionProvider provider = editor.getSelectionProvider();
if (provider != null) {
- ISelection selection= provider.getSelection();
- if (selection instanceof ITextSelection)
+ ISelection selection = provider.getSelection();
+ if (selection instanceof ITextSelection)
return (ITextSelection) selection;
}
}
@@ -292,18 +292,19 @@ public abstract class BlockCommentAction extends TextEditorAction {
/**
* Runs the real command once all the editor, document, and selection checks have succeeded.
- *
+ *
* @param selection the current selection we are being called for
* @param docExtension the document extension where we get the partitioning from
- * @param factory the edit factory we can use to create <code>Edit</code>s
+ * @param factory the edit factory we can use to create <code>Edit</code>s
* @throws BadLocationException if an edition fails
* @throws BadPartitioningException if a partitioning call fails
*/
- protected abstract void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException;
+ protected abstract void runInternal(ITextSelection selection, IDocumentExtension3 docExtension,
+ Edit.EditFactory factory) throws BadLocationException, BadPartitioningException;
/**
* Checks whether <code>selection</code> is valid.
- *
+ *
* @param selection the selection to check
* @return <code>true</code> if the selection is valid, <code>false</code> otherwise
*/
@@ -311,7 +312,7 @@ public abstract class BlockCommentAction extends TextEditorAction {
/**
* Returns the text to be inserted at the selection start.
- *
+ *
* @return the text to be inserted at the selection start
*/
protected String getCommentStart() {
@@ -321,7 +322,7 @@ public abstract class BlockCommentAction extends TextEditorAction {
/**
* Returns the text to be inserted at the selection end.
- *
+ *
* @return the text to be inserted at the selection end
*/
protected String getCommentEnd() {
@@ -329,5 +330,4 @@ public abstract class BlockCommentAction extends TextEditorAction {
return "*/"; //$NON-NLS-1$
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java
index 65350a24691..a39fd3d7b53 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java
@@ -45,7 +45,7 @@ public abstract class CDTQuickMenuCreator extends QuickMenuCreator {
* @param editor a Java editor, or <code>null</code> if none
*/
public CDTQuickMenuCreator(CEditor editor) {
- fEditor= editor;
+ fEditor = editor;
}
@Override
@@ -56,20 +56,20 @@ public abstract class CDTQuickMenuCreator extends QuickMenuCreator {
}
private Point computeWordStart() {
- ITextSelection selection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
- IRegion textRegion= CWordFinder.findWord(fEditor.getViewer().getDocument(), selection.getOffset());
+ ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
+ IRegion textRegion = CWordFinder.findWord(fEditor.getViewer().getDocument(), selection.getOffset());
if (textRegion == null)
return null;
- IRegion widgetRegion= modelRange2WidgetRange(textRegion);
+ IRegion widgetRegion = modelRange2WidgetRange(textRegion);
if (widgetRegion == null)
return null;
- int start= widgetRegion.getOffset();
+ int start = widgetRegion.getOffset();
- StyledText styledText= fEditor.getViewer().getTextWidget();
- Point result= styledText.getLocationAtOffset(start);
- result.y+= styledText.getLineHeight(start);
+ StyledText styledText = fEditor.getViewer().getTextWidget();
+ Point result = styledText.getLocationAtOffset(start);
+ result.y += styledText.getLineHeight(start);
if (!styledText.getClientArea().contains(result))
return null;
@@ -77,17 +77,17 @@ public abstract class CDTQuickMenuCreator extends QuickMenuCreator {
}
private IRegion modelRange2WidgetRange(IRegion region) {
- ISourceViewer viewer= fEditor.getViewer();
+ ISourceViewer viewer = fEditor.getViewer();
if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)viewer;
+ ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
return extension.modelRange2WidgetRange(region);
}
- IRegion visibleRegion= viewer.getVisibleRegion();
- int start= region.getOffset() - visibleRegion.getOffset();
- int end= start + region.getLength();
+ IRegion visibleRegion = viewer.getVisibleRegion();
+ int start = region.getOffset() - visibleRegion.getOffset();
+ int end = start + region.getLength();
if (end > visibleRegion.getLength())
- end= visibleRegion.getLength();
+ end = visibleRegion.getLength();
return new Region(start, end - start);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CollapseAllAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CollapseAllAction.java
index b39096a3e68..5a3285b074b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CollapseAllAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CollapseAllAction.java
@@ -24,20 +24,20 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* Collapse all nodes.
*/
public class CollapseAllAction extends Action {
-
+
private final TreeViewer fViewer;
-
+
public CollapseAllAction(TreeViewer viewer) {
- super(ActionMessages.CollapseAllAction_label);
- setDescription(ActionMessages.CollapseAllAction_description);
- setToolTipText(ActionMessages.CollapseAllAction_tooltip);
+ super(ActionMessages.CollapseAllAction_label);
+ setDescription(ActionMessages.CollapseAllAction_description);
+ setToolTipText(ActionMessages.CollapseAllAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_COLLAPSE_ALL);
fViewer = viewer;
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COLLAPSE_ALL_ACTION);
}
-
+
@Override
- public void run() {
+ public void run() {
try {
fViewer.getControl().setRedraw(false);
fViewer.collapseAll();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java
index 77d27bcd187..b91be4e06d9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java
@@ -23,10 +23,10 @@ import org.eclipse.ui.actions.ActionGroup;
public class CompositeActionGroup extends ActionGroup {
private ActionGroup[] fGroups;
-
+
public CompositeActionGroup() {
}
-
+
public CompositeActionGroup(ActionGroup[] groups) {
setGroups(groups);
}
@@ -34,32 +34,32 @@ public class CompositeActionGroup extends ActionGroup {
protected void setGroups(ActionGroup[] groups) {
Assert.isTrue(fGroups == null);
Assert.isNotNull(groups);
- fGroups= groups;
+ fGroups = groups;
}
-
+
public ActionGroup get(int index) {
if (fGroups == null)
return null;
return fGroups[index];
}
-
+
public void addGroup(ActionGroup group) {
if (fGroups == null) {
- fGroups= new ActionGroup[] { group };
+ fGroups = new ActionGroup[] { group };
} else {
- ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
+ ActionGroup[] newGroups = new ActionGroup[fGroups.length + 1];
System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
- newGroups[fGroups.length]= group;
- fGroups= newGroups;
+ newGroups[fGroups.length] = group;
+ fGroups = newGroups;
}
}
-
+
@Override
public void dispose() {
super.dispose();
if (fGroups == null)
return;
- for (int i= 0; i < fGroups.length; i++) {
+ for (int i = 0; i < fGroups.length; i++) {
fGroups[i].dispose();
}
}
@@ -69,7 +69,7 @@ public class CompositeActionGroup extends ActionGroup {
super.fillActionBars(actionBars);
if (fGroups == null)
return;
- for (int i= 0; i < fGroups.length; i++) {
+ for (int i = 0; i < fGroups.length; i++) {
fGroups[i].fillActionBars(actionBars);
}
}
@@ -79,7 +79,7 @@ public class CompositeActionGroup extends ActionGroup {
super.fillContextMenu(menu);
if (fGroups == null)
return;
- for (int i= 0; i < fGroups.length; i++) {
+ for (int i = 0; i < fGroups.length; i++) {
fGroups[i].fillContextMenu(menu);
}
}
@@ -89,7 +89,7 @@ public class CompositeActionGroup extends ActionGroup {
super.setContext(context);
if (fGroups == null)
return;
- for (int i= 0; i < fGroups.length; i++) {
+ for (int i = 0; i < fGroups.length; i++) {
fGroups[i].setContext(context);
}
}
@@ -99,7 +99,7 @@ public class CompositeActionGroup extends ActionGroup {
super.updateActionBars();
if (fGroups == null)
return;
- for (int i= 0; i < fGroups.length; i++) {
+ for (int i = 0; i < fGroups.length; i++) {
fGroups[i].updateActionBars();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java
index b964c86c28c..831d3fe2468 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java
@@ -40,24 +40,24 @@ import org.eclipse.cdt.internal.ui.util.SelectionUtil;
* Copies contents of a TreeViewer to the clipboard.
*/
public class CopyTreeAction extends Action {
- private static final char INDENTATION= '\t';
+ private static final char INDENTATION = '\t';
private ViewPart fView;
private TreeViewer fViewer;
public CopyTreeAction(String label, ViewPart view, TreeViewer viewer) {
super(label);
- fView= view;
- fViewer= viewer;
+ fView = view;
+ fViewer = viewer;
}
public boolean canActionBeAdded() {
- Object element= SelectionUtil.getSingleElement(getSelection());
+ Object element = SelectionUtil.getSingleElement(getSelection());
return element != null;
}
private ISelection getSelection() {
- ISelectionProvider provider= fView.getSite().getSelectionProvider();
+ ISelectionProvider provider = fView.getSite().getSelectionProvider();
if (provider != null) {
return provider.getSelection();
@@ -71,20 +71,19 @@ public class CopyTreeAction extends Action {
*/
@Override
public void run() {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
addChildren(fViewer.getTree().getSelection()[0], 0, buf);
- TextTransfer plainTextTransfer= TextTransfer.getInstance();
- Clipboard clipboard= new Clipboard(fView.getSite().getShell().getDisplay());
+ TextTransfer plainTextTransfer = TextTransfer.getInstance();
+ Clipboard clipboard = new Clipboard(fView.getSite().getShell().getDisplay());
try {
- clipboard.setContents(
- new String[] { convertLineTerminators(buf.toString()) },
+ clipboard.setContents(new String[] { convertLineTerminators(buf.toString()) },
new Transfer[] { plainTextTransfer });
} catch (SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
throw e;
- if (MessageDialog.openQuestion(fView.getViewSite().getShell(),
- ActionMessages.CopyTreeAction_problem, ActionMessages.CopyTreeAction_clipboard_busy)) {
+ if (MessageDialog.openQuestion(fView.getViewSite().getShell(), ActionMessages.CopyTreeAction_problem,
+ ActionMessages.CopyTreeAction_clipboard_busy)) {
run();
}
} finally {
@@ -94,13 +93,13 @@ public class CopyTreeAction extends Action {
/**
* Adds the specified {@link TreeItem}'s text to the StringBuilder.
- *
+ *
* @param item the tree item
* @param indent the indent size
* @param buf the string buffer
*/
private void addChildren(TreeItem item, int indent, StringBuilder buf) {
- for (int i= 0; i < indent; i++) {
+ for (int i = 0; i < indent; i++) {
buf.append(INDENTATION);
}
@@ -108,7 +107,7 @@ public class CopyTreeAction extends Action {
buf.append('\n');
if (item.getExpanded()) {
- TreeItem[] items= item.getItems();
+ TreeItem[] items = item.getItems();
for (TreeItem item2 : items) {
addChildren(item2, indent + 1, buf);
}
@@ -116,15 +115,15 @@ public class CopyTreeAction extends Action {
}
static String convertLineTerminators(String in) {
- StringWriter stringWriter= new StringWriter();
- PrintWriter printWriter= new PrintWriter(stringWriter);
- StringReader stringReader= new StringReader(in);
- BufferedReader bufferedReader= new BufferedReader(stringReader);
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter);
+ StringReader stringReader = new StringReader(in);
+ BufferedReader bufferedReader = new BufferedReader(stringReader);
try {
- String line= bufferedReader.readLine();
+ String line = bufferedReader.readLine();
while (line != null) {
printWriter.print(line);
- line= bufferedReader.readLine();
+ line = bufferedReader.readLine();
if (line != null && line.length() != 0)
printWriter.println();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
index 226b9c0e7bc..7939e729ad1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
@@ -102,13 +102,13 @@ public class CreateParserLogAction implements IObjectActionDelegate {
private static final String INDENT = " ";
private static final class MyVisitor extends ASTVisitor {
- List<IASTProblem> fProblems= new ArrayList<IASTProblem>();
- List<IProblemBinding> fProblemBindings= new ArrayList<IProblemBinding>();
- List<Exception> fExceptions= new ArrayList<Exception>();
+ List<IASTProblem> fProblems = new ArrayList<IASTProblem>();
+ List<IProblemBinding> fProblemBindings = new ArrayList<IProblemBinding>();
+ List<Exception> fExceptions = new ArrayList<Exception>();
MyVisitor() {
- shouldVisitProblems= true;
- shouldVisitNames= true;
+ shouldVisitProblems = true;
+ shouldVisitNames = true;
}
@Override
@@ -123,7 +123,7 @@ public class CreateParserLogAction implements IObjectActionDelegate {
return PROCESS_CONTINUE;
}
try {
- IBinding binding= name.resolveBinding();
+ IBinding binding = name.resolveBinding();
if (binding instanceof IProblemBinding) {
fProblemBindings.add((IProblemBinding) binding);
}
@@ -134,7 +134,7 @@ public class CreateParserLogAction implements IObjectActionDelegate {
}
}
- private static final Comparator<String> COMP_INSENSITIVE= new Comparator<String> () {
+ private static final Comparator<String> COMP_INSENSITIVE = new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.toUpperCase().compareTo(o2.toUpperCase());
@@ -148,12 +148,12 @@ public class CreateParserLogAction implements IObjectActionDelegate {
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fSite= targetPart.getSite();
+ fSite = targetPart.getSite();
}
@Override
public void run(IAction action) {
- if(!(fSelection instanceof IStructuredSelection) && !(fSelection instanceof ITextSelection)) {
+ if (!(fSelection instanceof IStructuredSelection) && !(fSelection instanceof ITextSelection)) {
return;
}
@@ -167,57 +167,56 @@ public class CreateParserLogAction implements IObjectActionDelegate {
workingCopies.add((IWorkingCopy) inputElement);
}
}
-
+
ArrayList<ITranslationUnit> tuSelection = getSelectedTranslationUnits();
- for(int i = 0; i < tuSelection.size(); i++) {
- if(!(tuSelection.get(i) instanceof IWorkingCopy)) {
+ for (int i = 0; i < tuSelection.size(); i++) {
+ if (!(tuSelection.get(i) instanceof IWorkingCopy)) {
tuSelection.set(i, convertToWorkingCopy(tuSelection.get(i), workingCopies));
}
}
- ITranslationUnit[] tuArray= tuSelection.toArray(new ITranslationUnit[tuSelection.size()]);
+ ITranslationUnit[] tuArray = tuSelection.toArray(new ITranslationUnit[tuSelection.size()]);
if (tuArray.length == 0) {
return;
}
- FileDialog dlg= new FileDialog(fSite.getShell(), SWT.SAVE);
+ FileDialog dlg = new FileDialog(fSite.getShell(), SWT.SAVE);
String title = ActionMessages.CreateParserLogAction_title;
dlg.setText(title);
- dlg.setFilterExtensions(new String[]{"*.log"});
- String path= null;
- while(path == null) {
- path= dlg.open();
+ dlg.setFilterExtensions(new String[] { "*.log" });
+ String path = null;
+ while (path == null) {
+ path = dlg.open();
if (path == null)
return;
- File file= new File(path);
+ File file = new File(path);
if (file.exists()) {
if (!file.canWrite()) {
- final String msg= NLS.bind(ActionMessages.CreateParserLogAction_readOnlyFile, path);
+ final String msg = NLS.bind(ActionMessages.CreateParserLogAction_readOnlyFile, path);
MessageDialog.openError(fSite.getShell(), title, msg);
- path= null;
- }
- else {
+ path = null;
+ } else {
final String msg = NLS.bind(ActionMessages.CreateParserLogAction_existingFile, path);
if (!MessageDialog.openQuestion(fSite.getShell(), title, msg)) {
- path= null;
+ path = null;
}
}
}
}
try {
- PrintStream out= new PrintStream(path);
+ PrintStream out = new PrintStream(path);
try {
- boolean needsep= false;
+ boolean needsep = false;
for (ITranslationUnit tu : tuArray) {
if (needsep) {
- out.println(); out.println();
+ out.println();
+ out.println();
}
createLog(out, tu, new NullProgressMonitor());
- needsep= true;
+ needsep = true;
}
- }
- finally {
+ } finally {
out.close();
}
try {
@@ -227,12 +226,12 @@ public class CreateParserLogAction implements IObjectActionDelegate {
} catch (IOException e) {
MessageDialog.openError(fSite.getShell(), title, e.getMessage());
}
-
+
}
private ITranslationUnit convertToWorkingCopy(ITranslationUnit tu, List<IWorkingCopy> workingCopies) {
for (IWorkingCopy wc : workingCopies) {
- if (tu.equals(wc.getOriginalElement()))
+ if (tu.equals(wc.getOriginalElement()))
return wc;
}
return tu;
@@ -257,32 +256,33 @@ public class CreateParserLogAction implements IObjectActionDelegate {
protected IStatus createLog(PrintStream out, ITranslationUnit tu, ILanguage lang, IASTTranslationUnit ast) {
IStatus status = Status.OK_STATUS;
final ICProject cproject = tu.getCProject();
- final String projectName= cproject == null ? null : cproject.getElementName();
+ final String projectName = cproject == null ? null : cproject.getElementName();
final IIndex index = ast.getIndex();
ITranslationUnit configureWith = tu;
- int ctxLinkage= 0;
- ISignificantMacros ctxSigMacros= null;
+ int ctxLinkage = 0;
+ ISignificantMacros ctxSigMacros = null;
if (tu instanceof TranslationUnit) {
- TranslationUnit itu= (TranslationUnit) tu;
- IIndexFile[] ctxToHeader = itu.getContextToHeader(index, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
+ TranslationUnit itu = (TranslationUnit) tu;
+ IIndexFile[] ctxToHeader = itu.getContextToHeader(index,
+ ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
if (ctxToHeader != null) {
try {
final IIndexFile ctxFile = ctxToHeader[0];
- ctxLinkage= ctxToHeader[0].getLinkageID();
- ctxSigMacros= ctxFile.getSignificantMacros();
+ ctxLinkage = ctxToHeader[0].getLinkageID();
+ ctxSigMacros = ctxFile.getSignificantMacros();
configureWith = CoreModelUtil.findTranslationUnitForLocation(ctxFile.getLocation(), cproject);
} catch (CoreException e) {
}
if (configureWith == null) {
- configureWith= tu;
- ctxToHeader= null;
+ configureWith = tu;
+ ctxToHeader = null;
}
}
}
- final ExtendedScannerInfo scfg= new ExtendedScannerInfo(configureWith.getScannerInfo(true));
- final MyVisitor visitor= new MyVisitor();
+ final ExtendedScannerInfo scfg = new ExtendedScannerInfo(configureWith.getScannerInfo(true));
+ final MyVisitor visitor = new MyVisitor();
ast.accept(visitor);
out.println("Project: " + projectName);
@@ -298,16 +298,15 @@ public class CreateParserLogAction implements IObjectActionDelegate {
}
try {
- IIndexFile[] versions= index.getFiles(IndexLocationFactory.getIFL(tu));
+ IIndexFile[] versions = index.getFiles(IndexLocationFactory.getIFL(tu));
out.println("Versions in Index: " + versions.length);
for (IIndexFile f : versions) {
- int[] count= countNames(f);
- out.println(INDENT + getLinkageName(f.getLinkageID()) + ": "
- + f.getSignificantMacros() + "; " + count[0] + " macros, "
- + count[1] + " includes, " + count[2] + " names;");
+ int[] count = countNames(f);
+ out.println(INDENT + getLinkageName(f.getLinkageID()) + ": " + f.getSignificantMacros() + "; "
+ + count[0] + " macros, " + count[1] + " includes, " + count[2] + " names;");
}
} catch (CoreException e) {
- status= e.getStatus();
+ status = e.getStatus();
}
out.println();
@@ -316,15 +315,17 @@ public class CreateParserLogAction implements IObjectActionDelegate {
output(out, "Preincluded files (option -include):", scfg.getIncludeFiles());
output(out, "Preincluded macro files (option -imacros):", scfg.getMacroFiles());
- HashSet<String> reported= new HashSet<String>();
+ HashSet<String> reported = new HashSet<String>();
output(out, "Macro definitions (option -D):", scfg.getDefinedSymbols(), reported);
- output(out, "Macro definitions (from language + headers in index):", ast.getBuiltinMacroDefinitions(), reported);
+ output(out, "Macro definitions (from language + headers in index):", ast.getBuiltinMacroDefinitions(),
+ reported);
output(out, "Macro definitions (from files actually parsed):", ast.getMacroDefinitions(), reported);
try {
- outputUnresolvedIncludes(cproject, ast.getIndex(), out, ast.getIncludeDirectives(), ast.getLinkage().getLinkageID());
+ outputUnresolvedIncludes(cproject, ast.getIndex(), out, ast.getIncludeDirectives(),
+ ast.getLinkage().getLinkageID());
} catch (CoreException e) {
- status= e.getStatus();
+ status = e.getStatus();
}
output(out, "Scanner problems:", ast.getPreprocessorProblems());
output(out, "Parser problems:", visitor.fProblems.toArray(new IASTProblem[0]));
@@ -335,47 +336,52 @@ public class CreateParserLogAction implements IObjectActionDelegate {
}
private int[] countNames(IIndexFile f) {
- int[] result= {0,0,0};
+ int[] result = { 0, 0, 0 };
try {
- result[0]= f.getMacros().length;
- result[1]= f.getIncludes().length;
- result[2]= f.findNames(0, Integer.MAX_VALUE).length;
+ result[0] = f.getMacros().length;
+ result[1] = f.getIncludes().length;
+ result[2] = f.findNames(0, Integer.MAX_VALUE).length;
} catch (CoreException e) {
}
return result;
}
private String getLinkageName(int linkageID) {
- switch(linkageID) {
- case ILinkage.NO_LINKAGE_ID: return ILinkage.NO_LINKAGE_NAME;
- case ILinkage.C_LINKAGE_ID: return ILinkage.C_LINKAGE_NAME;
- case ILinkage.CPP_LINKAGE_ID: return ILinkage.CPP_LINKAGE_NAME;
- case ILinkage.FORTRAN_LINKAGE_ID: return ILinkage.FORTRAN_LINKAGE_NAME;
- case ILinkage.OBJC_LINKAGE_ID: return ILinkage.OBJC_LINKAGE_NAME;
+ switch (linkageID) {
+ case ILinkage.NO_LINKAGE_ID:
+ return ILinkage.NO_LINKAGE_NAME;
+ case ILinkage.C_LINKAGE_ID:
+ return ILinkage.C_LINKAGE_NAME;
+ case ILinkage.CPP_LINKAGE_ID:
+ return ILinkage.CPP_LINKAGE_NAME;
+ case ILinkage.FORTRAN_LINKAGE_ID:
+ return ILinkage.FORTRAN_LINKAGE_NAME;
+ case ILinkage.OBJC_LINKAGE_ID:
+ return ILinkage.OBJC_LINKAGE_NAME;
}
return String.valueOf(linkageID);
}
private String getBuildConfig(ICProject cproject) {
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
- ICProjectDescription prefs= prjDescMgr.getProjectDescription(cproject.getProject(), false);
- if (prefs != null) {
- ICConfigurationDescription cfg= prefs.getDefaultSettingConfiguration();
- if (cfg != null)
- return cfg.getName();
- }
- return "unknown";
+ ICProjectDescriptionManager prjDescMgr = CCorePlugin.getDefault().getProjectDescriptionManager();
+ ICProjectDescription prefs = prjDescMgr.getProjectDescription(cproject.getProject(), false);
+ if (prefs != null) {
+ ICConfigurationDescription cfg = prefs.getDefaultSettingConfiguration();
+ if (cfg != null)
+ return cfg.getName();
+ }
+ return "unknown";
}
private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out,
IASTPreprocessorIncludeStatement[] includeDirectives, int linkageID) throws CoreException {
- fWroteUnresolvedTitle= false;
- ASTFilePathResolver resolver= new ProjectIndexerInputAdapter(prj);
- HashSet<IIndexFile> handled= new HashSet<IIndexFile>();
+ fWroteUnresolvedTitle = false;
+ ASTFilePathResolver resolver = new ProjectIndexerInputAdapter(prj);
+ HashSet<IIndexFile> handled = new HashSet<IIndexFile>();
for (IASTPreprocessorIncludeStatement include : includeDirectives) {
if (include.isResolved()) {
IIndexFileLocation ifl = resolver.resolveASTPath(include.getPath());
- IIndexFile ifile= index.getFile(linkageID, ifl, include.getSignificantMacros());
+ IIndexFile ifile = index.getFile(linkageID, ifl, include.getSignificantMacros());
outputUnresolvedIncludes(index, out, ifl, ifile, handled);
}
}
@@ -383,8 +389,8 @@ public class CreateParserLogAction implements IObjectActionDelegate {
out.println();
}
- private void outputUnresolvedIncludes(IIndex index, PrintStream out,
- IIndexFileLocation ifl, IIndexFile ifile, Set<IIndexFile> handled) throws CoreException {
+ private void outputUnresolvedIncludes(IIndex index, PrintStream out, IIndexFileLocation ifl, IIndexFile ifile,
+ Set<IIndexFile> handled) throws CoreException {
if (ifile == null) {
writeUnresolvedTitle(out);
out.println(INDENT + ifl.getURI() + " is not indexed");
@@ -397,8 +403,8 @@ public class CreateParserLogAction implements IObjectActionDelegate {
outputUnresolvedIncludes(index, out, inc.getIncludesLocation(), next, handled);
} else {
writeUnresolvedTitle(out);
- out.println(INDENT + "Unresolved inclusion: " + inc.getFullName() + " in file " +
- inc.getIncludedByLocation().getURI());
+ out.println(INDENT + "Unresolved inclusion: " + inc.getFullName() + " in file "
+ + inc.getIncludedByLocation().getURI());
}
}
}
@@ -407,7 +413,7 @@ public class CreateParserLogAction implements IObjectActionDelegate {
public void writeUnresolvedTitle(PrintStream out) {
if (!fWroteUnresolvedTitle) {
- fWroteUnresolvedTitle= true;
+ fWroteUnresolvedTitle = true;
out.println("Unresolved includes (from headers in index):");
}
}
@@ -426,7 +432,7 @@ public class CreateParserLogAction implements IObjectActionDelegate {
if (!definedSymbols.isEmpty()) {
out.println(label);
- SortedMap<String, String> sorted= new TreeMap<String, String>(COMP_INSENSITIVE);
+ SortedMap<String, String> sorted = new TreeMap<String, String>(COMP_INSENSITIVE);
sorted.putAll(definedSymbols);
for (Entry<String, String> entry : sorted.entrySet()) {
final String macro = entry.getKey() + '=' + entry.getValue();
@@ -438,10 +444,11 @@ public class CreateParserLogAction implements IObjectActionDelegate {
}
}
- private void output(PrintStream out, String label, IASTPreprocessorMacroDefinition[] defs, HashSet<String> reported) {
+ private void output(PrintStream out, String label, IASTPreprocessorMacroDefinition[] defs,
+ HashSet<String> reported) {
if (defs.length > 0) {
out.println(label);
- SortedSet<String> macros= new TreeSet<String>(COMP_INSENSITIVE);
+ SortedSet<String> macros = new TreeSet<String>(COMP_INSENSITIVE);
for (IASTPreprocessorMacroDefinition def : defs) {
macros.add(def.toString());
}
@@ -469,7 +476,7 @@ public class CreateParserLogAction implements IObjectActionDelegate {
if (list.length > 0) {
out.println(label);
for (IProblemBinding problem : list) {
- String file= problem.getFileName();
+ String file = problem.getFileName();
int line = problem.getLineNumber();
out.println(INDENT + problem.getMessage() + " in file " + file + ':' + line);
}
@@ -491,10 +498,10 @@ public class CreateParserLogAction implements IObjectActionDelegate {
public void selectionChanged(IAction action, ISelection selection) {
fSelection = selection;
}
-
+
public IWorkingCopy getTranslationUnitForSelectedEditorInput() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if(window != null) {
+ if (window != null) {
IWorkbenchPart workbenchPart = window.getPartService().getActivePart();
if (workbenchPart instanceof IEditorPart) {
IEditorPart editorPart = (IEditorPart) workbenchPart;
@@ -512,21 +519,21 @@ public class CreateParserLogAction implements IObjectActionDelegate {
ArrayList<ITranslationUnit> tus = getSelectedTranslationUnits();
return tus.size() > 0;
}
-
+
private ArrayList<ITranslationUnit> getSelectedTranslationUnits() {
- ArrayList<ITranslationUnit> tuSelection= new ArrayList<ITranslationUnit>();
- if(fSelection instanceof IStructuredSelection) {
- IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
- Iterator<?> i= cElements.iterator();
+ ArrayList<ITranslationUnit> tuSelection = new ArrayList<ITranslationUnit>();
+ if (fSelection instanceof IStructuredSelection) {
+ IStructuredSelection cElements = SelectionConverter.convertSelectionToCElements(fSelection);
+ Iterator<?> i = cElements.iterator();
while (i.hasNext()) {
- Object o= i.next();
+ Object o = i.next();
if (o instanceof ITranslationUnit) {
- tuSelection.add((ITranslationUnit)o);
+ tuSelection.add((ITranslationUnit) o);
}
}
- } else if(fSelection == null || fSelection instanceof ITextSelection) {
+ } else if (fSelection == null || fSelection instanceof ITextSelection) {
IWorkingCopy tu = getTranslationUnitForSelectedEditorInput();
- if(tu != null) {
+ if (tu != null) {
tuSelection.add(tu);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogHandler.java
index beb47fe04e6..3abf5e3d82b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogHandler.java
@@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.ui.util.SelectionUtil;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class CreateParserLogHandler extends AbstractHandler {
-
+
private final CreateParserLogAction createParserLogAction = new CreateParserLogAction();
@Override
@@ -41,13 +41,13 @@ public class CreateParserLogHandler extends AbstractHandler {
createParserLogAction.run(null);
return null;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
*/
@Override
public void setEnabled(Object evaluationContext) {
- ISelection selection = SelectionUtil.getActiveSelection();
- setBaseEnabled(createParserLogAction.isEnabledFor(selection));
+ ISelection selection = SelectionUtil.getActiveSelection();
+ setBaseEnabled(createParserLogAction.isEnabledFor(selection));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java
index 6b724b5f9a9..84a1c101e14 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java
@@ -13,6 +13,7 @@
* Nokia - converted from action to handler
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -52,8 +53,6 @@ import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.newui.AbstractPage;
-
-
/**
* Handler for command that deletes resource description. (If resource description is missing
* one from parent is normally used)
@@ -61,7 +60,7 @@ import org.eclipse.cdt.ui.newui.AbstractPage;
public class DeleteResConfigsHandler extends AbstractHandler {
protected ArrayList<IResource> objects;
- private ArrayList<ResCfgData> outData;
+ private ArrayList<ResCfgData> outData;
@Override
public void setEnabled(Object context) {
@@ -71,10 +70,10 @@ public class DeleteResConfigsHandler extends AbstractHandler {
protected ISelection getSelection(Object context) {
Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME);
- if (s instanceof ISelection) {
- return (ISelection) s;
- }
- return null;
+ if (s instanceof ISelection) {
+ return (ISelection) s;
+ }
+ return null;
}
public void setEnabledFromSelection(ISelection selection) {
@@ -84,25 +83,25 @@ public class DeleteResConfigsHandler extends AbstractHandler {
// case for context menu
Object[] obs = null;
if (selection instanceof IStructuredSelection) {
- obs = ((IStructuredSelection)selection).toArray();
- }
- else if (selection instanceof ITextSelection) {
+ obs = ((IStructuredSelection) selection).toArray();
+ } else if (selection instanceof ITextSelection) {
IFile file = getFileFromActiveEditor();
if (file != null)
obs = Collections.singletonList(file).toArray();
}
if (obs != null && obs.length > 0) {
- for (int i=0; i<obs.length; i++) {
+ for (int i = 0; i < obs.length; i++) {
IResource res = null;
// only folders and files may be affected by this action
if (obs[i] instanceof ICContainer || obs[i] instanceof ITranslationUnit)
- res = ((ICElement)obs[i]).getResource();
+ res = ((ICElement) obs[i]).getResource();
// project's configuration cannot be deleted
else if (obs[i] instanceof IResource && !(obs[i] instanceof IProject))
- res = (IResource)obs[i];
+ res = (IResource) obs[i];
if (res != null) {
IProject p = res.getProject();
- if (!p.isOpen()) continue;
+ if (!p.isOpen())
+ continue;
if (!CoreModel.getDefault().isNewStyleProject(p))
continue;
@@ -110,13 +109,16 @@ public class DeleteResConfigsHandler extends AbstractHandler {
IPath path = res.getProjectRelativePath();
// getting description in read-only mode
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
- if (prjd == null) continue;
+ if (prjd == null)
+ continue;
ICConfigurationDescription[] cfgds = prjd.getConfigurations();
- if (cfgds == null || cfgds.length == 0) continue;
+ if (cfgds == null || cfgds.length == 0)
+ continue;
for (ICConfigurationDescription cfgd : cfgds) {
ICResourceDescription rd = cfgd.getResourceDescription(path, true);
if (rd != null) {
- if (objects == null) objects = new ArrayList<IResource>();
+ if (objects == null)
+ objects = new ArrayList<IResource>();
objects.add(res);
break; // stop configurations scanning
}
@@ -151,21 +153,20 @@ public class DeleteResConfigsHandler extends AbstractHandler {
}
private void openDialog() {
- if (objects == null || objects.size() == 0) return;
+ if (objects == null || objects.size() == 0)
+ return;
// create list of configurations to delete
- ListSelectionDialog dialog = new ListSelectionDialog(
- CUIPlugin.getActiveWorkbenchShell(),
- objects,
- createSelectionDialogContentProvider(),
- new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0);
+ ListSelectionDialog dialog = new ListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), objects,
+ createSelectionDialogContentProvider(), new LabelProvider() {
+ }, ActionMessages.DeleteResConfigsAction_0);
dialog.setTitle(ActionMessages.DeleteResConfigsAction_1);
if (dialog.open() == Window.OK) {
Object[] selected = dialog.getResult();
if (selected != null && selected.length > 0) {
for (Object element : selected) {
- ((ResCfgData)element).delete();
- AbstractPage.updateViews(((ResCfgData)element).res);
+ ((ResCfgData) element).delete();
+ AbstractPage.updateViews(((ResCfgData) element).res);
}
}
}
@@ -178,9 +179,12 @@ public class DeleteResConfigsHandler extends AbstractHandler {
ICConfigurationDescription cfgd;
ICResourceDescription rdesc;
- public ResCfgData(IResource res2, ICProjectDescription prjd2,
- ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) {
- res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2;
+ public ResCfgData(IResource res2, ICProjectDescription prjd2, ICConfigurationDescription cfgd2,
+ ICResourceDescription rdesc2) {
+ res = res2;
+ prjd = prjd2;
+ cfgd = cfgd2;
+ rdesc = rdesc2;
}
// performs deletion
@@ -188,15 +192,16 @@ public class DeleteResConfigsHandler extends AbstractHandler {
try {
cfgd.removeResourceDescription(rdesc);
CoreModel.getDefault().setProjectDescription(res.getProject(), prjd);
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
}
+
@Override
public String toString() {
- return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$
+ return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$
}
}
-
private IStructuredContentProvider createSelectionDialogContentProvider() {
outData = null;
@@ -204,10 +209,11 @@ public class DeleteResConfigsHandler extends AbstractHandler {
@Override
public Object[] getElements(Object inputElement) {
- if (outData != null) return outData.toArray();
+ if (outData != null)
+ return outData.toArray();
outData = new ArrayList<ResCfgData>();
- List<?> ls = (List<?>)inputElement;
+ List<?> ls = (List<?>) inputElement;
Iterator<?> it = ls.iterator();
IProject proj = null;
ICProjectDescription prjd = null;
@@ -215,7 +221,7 @@ public class DeleteResConfigsHandler extends AbstractHandler {
// creating list of all res descs for all objects
while (it.hasNext()) {
- IResource res = (IResource)it.next();
+ IResource res = (IResource) it.next();
IPath path = res.getProjectRelativePath();
if (res.getProject() != proj) {
proj = res.getProject();
@@ -232,10 +238,14 @@ public class DeleteResConfigsHandler extends AbstractHandler {
}
return outData.toArray();
}
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
};
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java
index 25adf4a942f..c13fc9b3ca9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java
@@ -59,7 +59,6 @@ import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.cdt.internal.ui.newui.Messages;
-
/**
* Handler for command that excludes resources from build.
*/
@@ -76,10 +75,10 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
protected ISelection getSelection(Object context) {
Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME);
- if (s instanceof ISelection) {
- return (ISelection) s;
- }
- return null;
+ if (s instanceof ISelection) {
+ return (ISelection) s;
+ }
+ return null;
}
public void setEnabledFromSelection(ISelection selection) {
@@ -91,18 +90,17 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
// case for context menu
Object[] obs = null;
if (selection instanceof IStructuredSelection) {
- obs = ((IStructuredSelection)selection).toArray();
- }
- else if (selection instanceof ITextSelection) {
+ obs = ((IStructuredSelection) selection).toArray();
+ } else if (selection instanceof ITextSelection) {
IFile file = getFileFromActiveEditor();
if (file != null)
obs = Collections.singletonList(file).toArray();
}
if (obs != null && obs.length > 0) {
- for (int i=0; i<obs.length && cfgsOK; i++) {
+ for (int i = 0; i < obs.length && cfgsOK; i++) {
// if project selected, don't do anything
if ((obs[i] instanceof IProject) || (obs[i] instanceof ICProject)) {
- cfgsOK=false;
+ cfgsOK = false;
break;
}
IResource res = null;
@@ -115,13 +113,15 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
}
if (res != null) {
ICConfigurationDescription[] cfgds = getCfgsRead(res);
- if (cfgds == null || cfgds.length == 0) continue;
+ if (cfgds == null || cfgds.length == 0)
+ continue;
- if (objects == null) objects = new ArrayList<IResource>();
+ if (objects == null)
+ objects = new ArrayList<IResource>();
objects.add(res);
if (cfgNames == null) {
cfgNames = new ArrayList<String>(cfgds.length);
- for (int j=0; j<cfgds.length; j++) {
+ for (int j = 0; j < cfgds.length; j++) {
if (!canExclude(res, cfgds[j])) {
cfgNames = null;
cfgsOK = false;
@@ -133,9 +133,8 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
if (cfgNames.size() != cfgds.length) {
cfgsOK = false;
} else {
- for (int j=0; j<cfgds.length; j++) {
- if (! canExclude(res, cfgds[j]) ||
- ! cfgNames.contains(cfgds[j].getName())) {
+ for (int j = 0; j < cfgds.length; j++) {
+ if (!canExclude(res, cfgds[j]) || !cfgNames.contains(cfgds[j].getName())) {
cfgsOK = false;
break;
}
@@ -174,7 +173,8 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
private void setExclude(IResource res, ICConfigurationDescription cfg, boolean exclude) {
try {
- ICSourceEntry[] newEntries = CDataUtil.setExcluded(res.getFullPath(), (res instanceof IFolder), exclude, cfg.getSourceEntries());
+ ICSourceEntry[] newEntries = CDataUtil.setExcluded(res.getFullPath(), (res instanceof IFolder), exclude,
+ cfg.getSourceEntries());
cfg.setSourceEntries(newEntries);
} catch (CoreException e) {
CUIPlugin.log(e);
@@ -189,25 +189,26 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
private ICConfigurationDescription[] getCfgsRead(IResource res) {
IProject p = res.getProject();
- if (!p.isOpen()) return null;
- if (!CoreModel.getDefault().isNewStyleProject(p)) return null;
+ if (!p.isOpen())
+ return null;
+ if (!CoreModel.getDefault().isNewStyleProject(p))
+ return null;
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
- if (prjd == null) return null;
+ if (prjd == null)
+ return null;
ICConfigurationDescription[] cfgs = prjd.getConfigurations();
Arrays.sort(cfgs, CDTListComparator.getInstance());
return cfgs;
}
private void openDialog() {
- if (objects == null || objects.size() == 0) return;
+ if (objects == null || objects.size() == 0)
+ return;
// create list of configurations to delete
- ListSelectionDialog dialog = new ListSelectionDialog(
- CUIPlugin.getActiveWorkbenchShell(),
- cfgNames,
- createSelectionDialogContentProvider(),
- new LabelProvider() {},
- ActionMessages.ExcludeFromBuildAction_0);
+ ListSelectionDialog dialog = new ListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), cfgNames,
+ createSelectionDialogContentProvider(), new LabelProvider() {
+ }, ActionMessages.ExcludeFromBuildAction_0);
dialog.setTitle(ActionMessages.ExcludeFromBuildAction_1);
boolean[] status = new boolean[cfgNames.size()];
@@ -216,14 +217,16 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
IResource res = it.next();
ICConfigurationDescription[] cfgds = getCfgsRead(res);
IPath p = res.getFullPath();
- for (int i=0; i<cfgds.length; i++) {
+ for (int i = 0; i < cfgds.length; i++) {
boolean b = CDataUtil.isExcluded(p, cfgds[i].getSourceEntries());
- if (b) status[i] = true;
+ if (b)
+ status[i] = true;
}
}
ArrayList<String> lst = new ArrayList<String>();
- for (int i=0; i<status.length; i++)
- if (status[i]) lst.add(cfgNames.get(i));
+ for (int i = 0; i < status.length; i++)
+ if (status[i])
+ lst.add(cfgNames.get(i));
if (lst.size() > 0)
dialog.setInitialElementSelections(lst);
@@ -233,14 +236,16 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
while (it2.hasNext()) {
IResource res = it2.next();
IProject p = res.getProject();
- if (!p.isOpen()) continue;
+ if (!p.isOpen())
+ continue;
// get writable description
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, true);
- if (prjd == null) continue;
+ if (prjd == null)
+ continue;
ICConfigurationDescription[] cfgds = prjd.getConfigurations();
- for (int i=0; i<cfgds.length; i++) {
+ for (int i = 0; i < cfgds.length; i++) {
boolean exclude = false;
- for (int j=0; j<selected.length; j++) {
+ for (int j = 0; j < selected.length; j++) {
if (cfgds[i].getName().equals(selected[j])) {
exclude = true;
break;
@@ -261,11 +266,17 @@ public class ExcludeFromBuildHandler extends AbstractHandler {
private IStructuredContentProvider createSelectionDialogContentProvider() {
return new IStructuredContentProvider() {
@Override
- public Object[] getElements(Object inputElement) { return cfgNames.toArray(); }
+ public Object[] getElements(Object inputElement) {
+ return cfgNames.toArray();
+ }
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
};
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExpandAllAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExpandAllAction.java
index a11ad8d865c..a6502d60f49 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExpandAllAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExpandAllAction.java
@@ -24,20 +24,20 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* Expand all nodes.
*/
public class ExpandAllAction extends Action {
-
+
private final TreeViewer fViewer;
-
+
public ExpandAllAction(TreeViewer viewer) {
- super(ActionMessages.ExpandAllAction_label);
- setDescription(ActionMessages.ExpandAllAction_description);
- setToolTipText(ActionMessages.ExpandAllAction_tooltip);
+ super(ActionMessages.ExpandAllAction_label);
+ setDescription(ActionMessages.ExpandAllAction_description);
+ setToolTipText(ActionMessages.ExpandAllAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_EXPAND_ALL);
fViewer = viewer;
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.EXPAND_ALL_ACTION);
}
-
+
@Override
- public void run() {
+ public void run() {
try {
fViewer.getControl().setRedraw(false);
fViewer.expandAll();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FindWordAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FindWordAction.java
index 61d99040dee..7af02b8306f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FindWordAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FindWordAction.java
@@ -35,15 +35,15 @@ import org.eclipse.cdt.internal.ui.text.CWordFinder;
*/
public class FindWordAction extends TextEditorAction {
- public static final String FIND_WORD = "FindWord"; //$NON-NLS-1$
+ public static final String FIND_WORD = "FindWord"; //$NON-NLS-1$
- private ITextViewer fViewer;
- private FindNextAction fFindNext;
+ private ITextViewer fViewer;
+ private FindNextAction fFindNext;
/**
* Creates new action.
*/
- public FindWordAction(ResourceBundle bundle, String prefix, ITextEditor editor, ITextViewer viewer) {
+ public FindWordAction(ResourceBundle bundle, String prefix, ITextEditor editor, ITextViewer viewer) {
super(bundle, prefix, editor);
fViewer = viewer;
fFindNext = new FindNextAction(bundle, prefix, editor, true);
@@ -56,7 +56,7 @@ public class FindWordAction extends TextEditorAction {
@Override
public void run() {
ITextEditor editor = getTextEditor();
- if (editor == null )
+ if (editor == null)
return;
ISelectionProvider selectionProvider = editor.getSelectionProvider();
@@ -75,7 +75,7 @@ public class FindWordAction extends TextEditorAction {
IDocument document = docProvider.getDocument(input);
if (document == null)
return;
-
+
IResource resource = (input).getAdapter(IResource.class);
if (resource == null || !(resource instanceof IFile))
return;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java
index b02bda4dc91..da687c9de3c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java
@@ -30,7 +30,6 @@ import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.cdt.internal.ui.editor.CEditor;
-
/**
* Groups the CDT folding actions.
*
@@ -70,8 +69,6 @@ public class FoldingActionGroup extends ActionGroup {
private TextOperationAction fCollapseAll;
private PreferenceAction fRestoreDefaults;
-
-
/**
* Creates a new projection action group for <code>editor</code>. If the
* supplied viewer is not an instance of <code>ProjectionViewer</code>, the
@@ -82,23 +79,24 @@ public class FoldingActionGroup extends ActionGroup {
*/
public FoldingActionGroup(final ITextEditor editor, ITextViewer viewer) {
if (!(viewer instanceof ProjectionViewer)) {
- fToggle= null;
- fExpand= null;
- fCollapse= null;
- fExpandAll= null;
- fCollapseAll= null;
- fRestoreDefaults= null;
- fProjectionListener= null;
+ fToggle = null;
+ fExpand = null;
+ fCollapse = null;
+ fExpandAll = null;
+ fCollapseAll = null;
+ fRestoreDefaults = null;
+ fProjectionListener = null;
return;
}
- fViewer= (ProjectionViewer) viewer;
+ fViewer = (ProjectionViewer) viewer;
- fProjectionListener= new IProjectionListener() {
+ fProjectionListener = new IProjectionListener() {
@Override
public void projectionEnabled() {
update();
}
+
@Override
public void projectionDisabled() {
update();
@@ -107,31 +105,36 @@ public class FoldingActionGroup extends ActionGroup {
fViewer.addProjectionListener(fProjectionListener);
- fToggle= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE, true); //$NON-NLS-1$
+ fToggle = new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor, //$NON-NLS-1$
+ ProjectionViewer.TOGGLE, true);
fToggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE);
editor.setAction("FoldingToggle", fToggle); //$NON-NLS-1$
- fExpandAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.ExpandAll.", editor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$
+ fExpandAll = new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.ExpandAll.", editor, //$NON-NLS-1$
+ ProjectionViewer.EXPAND_ALL, true);
fExpandAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL);
editor.setAction("FoldingExpandAll", fExpandAll); //$NON-NLS-1$
- fCollapseAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.CollapseAll.", editor, ProjectionViewer.COLLAPSE_ALL, true); //$NON-NLS-1$
+ fCollapseAll = new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.CollapseAll.", editor, //$NON-NLS-1$
+ ProjectionViewer.COLLAPSE_ALL, true);
fCollapseAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE_ALL);
editor.setAction("FoldingCollapseAll", fCollapseAll); //$NON-NLS-1$
- fExpand= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Expand.", editor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$
+ fExpand = new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Expand.", editor, //$NON-NLS-1$
+ ProjectionViewer.EXPAND, true);
fExpand.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND);
editor.setAction("FoldingExpand", fExpand); //$NON-NLS-1$
- fCollapse= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Collapse.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$
+ fCollapse = new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Collapse.", editor, //$NON-NLS-1$
+ ProjectionViewer.COLLAPSE, true);
fCollapse.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE);
editor.setAction("FoldingCollapse", fCollapse); //$NON-NLS-1$
- fRestoreDefaults= new FoldingAction(FoldingMessages.getResourceBundle(), "Projection.Restore.") { //$NON-NLS-1$
+ fRestoreDefaults = new FoldingAction(FoldingMessages.getResourceBundle(), "Projection.Restore.") { //$NON-NLS-1$
@Override
public void run() {
if (editor instanceof CEditor) {
- CEditor cEditor= (CEditor) editor;
+ CEditor cEditor = (CEditor) editor;
cEditor.resetProjection();
}
}
@@ -159,7 +162,7 @@ public class FoldingActionGroup extends ActionGroup {
public void dispose() {
if (isEnabled()) {
fViewer.removeProjectionListener(fProjectionListener);
- fViewer= null;
+ fViewer = null;
}
super.dispose();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java
index 2df5cfff6b6..eedb6d0d0a9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java
@@ -22,21 +22,21 @@ import java.util.ResourceBundle;
*/
public class FoldingMessages {
- private static final String BUNDLE_NAME= "org.eclipse.cdt.internal.ui.actions.FoldingMessages"; //$NON-NLS-1$
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.actions.FoldingMessages"; //$NON-NLS-1$
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
private FoldingMessages() {
// no instance
}
/**
- * Returns the resource string associated with the given key in the resource bundle. If there isn't
+ * Returns the resource string associated with the given key in the resource bundle. If there isn't
* any value under the given key, the key is returned.
*
* @param key the resource key
* @return the string
- */
+ */
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
@@ -44,40 +44,40 @@ public class FoldingMessages {
return '!' + key + '!';
}
}
-
+
/**
* Returns the resource bundle managed by the receiver.
- *
+ *
* @return the resource bundle
* @since 3.0
*/
public static ResourceBundle getResourceBundle() {
return RESOURCE_BUNDLE;
}
-
+
/**
- * Returns the formatted resource string associated with the given key in the resource bundle.
- * <code>MessageFormat</code> is used to format the message. If there isn't any value
+ * Returns the formatted resource string associated with the given key in the resource bundle.
+ * <code>MessageFormat</code> is used to format the message. If there isn't any value
* under the given key, the key is returned.
*
* @param key the resource key
* @param arg the message argument
* @return the string
- */
+ */
public static String getFormattedString(String key, Object arg) {
return getFormattedString(key, new Object[] { arg });
}
-
+
/**
- * Returns the formatted resource string associated with the given key in the resource bundle.
- * <code>MessageFormat</code> is used to format the message. If there isn't any value
+ * Returns the formatted resource string associated with the given key in the resource bundle.
+ * <code>MessageFormat</code> is used to format the message. If there isn't any value
* under the given key, the key is returned.
*
* @param key the resource key
* @param args the message arguments
* @return the string
- */
+ */
public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
+ return MessageFormat.format(getString(key), args);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenAllFilesHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenAllFilesHandler.java
index fbc50250e58..c88201053dd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenAllFilesHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenAllFilesHandler.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
-
/**
* Handler for {@link org.eclipse.cdt.internal.ui.actions.FreshenIndexAction}
*
@@ -23,7 +22,7 @@ package org.eclipse.cdt.internal.ui.actions;
public class FreshenAllFilesHandler extends AbstractUpdateIndexHandler {
private final FreshenIndexAction freshenIndexAction = new FreshenIndexAction();
-
+
@Override
public AbstractUpdateIndexAction getAction() {
return freshenIndexAction;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java
index afc4c89049e..2c71f96d585 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
import org.eclipse.cdt.core.index.IIndexManager;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java
index 2152f096086..6e919fb7283 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java
@@ -40,84 +40,84 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
*/
public class GoToNextPreviousMemberAction extends TextEditorAction {
- public static final String NEXT_MEMBER = "GotoNextMember"; //$NON-NLS-1$
+ public static final String NEXT_MEMBER = "GotoNextMember"; //$NON-NLS-1$
public static final String PREVIOUS_MEMBER = "GotoPrevMember"; //$NON-NLS-1$
-
+
/** Determines should action take user to the next member or to the previous one. */
- private boolean fGotoNext;
-
- /**
- * Creates new action.
- * @param bundle Resource bundle.
- * @param prefix Prefix.
- * @param editor Editor.
- * @param gotoNext Is it go to next or previous action.
- */
- public GoToNextPreviousMemberAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean gotoNext) {
- super(bundle, prefix, editor);
-
- fGotoNext = gotoNext;
- }
-
- /**
- * Creates new action.
- * @param bundle Resource bundle.
- * @param prefix Prefix.
- * @param editor Editor.
- * @param style UI style.
- * @param gotoNext Is it go to next or previous action.
- */
- public GoToNextPreviousMemberAction(ResourceBundle bundle, String prefix, ITextEditor editor, int style, boolean gotoNext) {
- super(bundle, prefix, editor, style);
-
- fGotoNext = gotoNext;
- }
-
- /*
+ private boolean fGotoNext;
+
+ /**
+ * Creates new action.
+ * @param bundle Resource bundle.
+ * @param prefix Prefix.
+ * @param editor Editor.
+ * @param gotoNext Is it go to next or previous action.
+ */
+ public GoToNextPreviousMemberAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean gotoNext) {
+ super(bundle, prefix, editor);
+
+ fGotoNext = gotoNext;
+ }
+
+ /**
+ * Creates new action.
+ * @param bundle Resource bundle.
+ * @param prefix Prefix.
+ * @param editor Editor.
+ * @param style UI style.
+ * @param gotoNext Is it go to next or previous action.
+ */
+ public GoToNextPreviousMemberAction(ResourceBundle bundle, String prefix, ITextEditor editor, int style,
+ boolean gotoNext) {
+ super(bundle, prefix, editor, style);
+
+ fGotoNext = gotoNext;
+ }
+
+ /*
* @see org.eclipse.ui.texteditor.TextEditorAction#update()
*/
@Override
public void update() {
- final ITextEditor editor = getTextEditor();
- setEnabled(editor instanceof CEditor && ((CEditor)editor).getInputCElement() != null);
+ final ITextEditor editor = getTextEditor();
+ setEnabled(editor instanceof CEditor && ((CEditor) editor).getInputCElement() != null);
}
/**
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
public void run() {
- final CEditor editor = (CEditor) getTextEditor();
- final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
- final IEditorInput editorInput = editor.getEditorInput();
- final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
- if (workingCopy == null) {
- return;
- }
- try {
- ISourceReference next= fGotoNext ?
- getNextElement(workingCopy, selection.getOffset()) :
- getPrevElement(workingCopy, selection.getOffset());
- if (next != null) {
- editor.selectAndReveal(next.getSourceRange().getIdStartPos(), 0);
- }
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- }
+ final CEditor editor = (CEditor) getTextEditor();
+ final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
+ final IEditorInput editorInput = editor.getEditorInput();
+ final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+ if (workingCopy == null) {
+ return;
+ }
+ try {
+ ISourceReference next = fGotoNext ? getNextElement(workingCopy, selection.getOffset())
+ : getPrevElement(workingCopy, selection.getOffset());
+ if (next != null) {
+ editor.selectAndReveal(next.getSourceRange().getIdStartPos(), 0);
+ }
+ } catch (CModelException e) {
+ CUIPlugin.log(e);
+ }
+ }
private ISourceReference getNextElement(IParent parent, int offset) throws CModelException {
- ICElement[] children= parent.getChildren();
+ ICElement[] children = parent.getChildren();
for (int i = 0; i < children.length; i++) {
ICElement element = children[i];
if (element instanceof ISourceReference) {
- final ISourceReference candidate1= (ISourceReference) element;
- final ISourceRange range= candidate1.getSourceRange();
- final int idpos1= range.getIdStartPos();
+ final ISourceReference candidate1 = (ISourceReference) element;
+ final ISourceRange range = candidate1.getSourceRange();
+ final int idpos1 = range.getIdStartPos();
if (element instanceof IParent && range.getStartPos() + range.getLength() > offset) {
- ISourceReference candidate2= getNextElement((IParent) element, offset);
+ ISourceReference candidate2 = getNextElement((IParent) element, offset);
if (candidate2 != null) {
- final int idpos2= candidate2.getSourceRange().getIdStartPos();
+ final int idpos2 = candidate2.getSourceRange().getIdStartPos();
if (idpos1 <= offset || idpos1 > idpos2) {
return candidate2;
}
@@ -132,17 +132,17 @@ public class GoToNextPreviousMemberAction extends TextEditorAction {
}
private ISourceReference getPrevElement(IParent parent, int offset) throws CModelException {
- ICElement[] children= parent.getChildren();
- for (int i= children.length-1; i >= 0; i--) {
+ ICElement[] children = parent.getChildren();
+ for (int i = children.length - 1; i >= 0; i--) {
ICElement element = children[i];
if (element instanceof ISourceReference) {
- final ISourceReference candidate1= (ISourceReference) element;
- final ISourceRange range= candidate1.getSourceRange();
- final int idpos1= range.getIdStartPos();
+ final ISourceReference candidate1 = (ISourceReference) element;
+ final ISourceRange range = candidate1.getSourceRange();
+ final int idpos1 = range.getIdStartPos();
if (element instanceof IParent && range.getStartPos() < offset) {
- ISourceReference candidate2= getPrevElement((IParent) element, offset);
+ ISourceReference candidate2 = getPrevElement((IParent) element, offset);
if (candidate2 != null) {
- final int idpos2= candidate2.getSourceRange().getIdStartPos();
+ final int idpos2 = candidate2.getSourceRange().getIdStartPos();
if (idpos1 >= offset || idpos1 < idpos2) {
return candidate2;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java
index d5b32790086..98496e96d6b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java
@@ -35,9 +35,9 @@ import org.eclipse.ui.texteditor.TextEditorAction;
*/
public class GotoNextBookmarkAction extends TextEditorAction {
- public static final String NEXT_BOOKMARK = "GotoNextBookmark"; //$NON-NLS-1$
+ public static final String NEXT_BOOKMARK = "GotoNextBookmark"; //$NON-NLS-1$
- /**
+ /**
* Private class to handle comparison of markers using their line numbers.
*/
private class CompareMarker implements Comparator<IMarker> {
@@ -45,8 +45,10 @@ public class GotoNextBookmarkAction extends TextEditorAction {
public int compare(IMarker m1, IMarker m2) {
int l1 = MarkerUtilities.getLineNumber(m1);
int l2 = MarkerUtilities.getLineNumber(m2);
- if (l1 > l2) return 1;
- if (l1 < l2) return -1;
+ if (l1 > l2)
+ return 1;
+ if (l1 < l2)
+ return -1;
return 0;
}
}
@@ -65,7 +67,7 @@ public class GotoNextBookmarkAction extends TextEditorAction {
@Override
public void run() {
ITextEditor editor = getTextEditor();
- if (editor == null )
+ if (editor == null)
return;
ISelectionProvider provider = editor.getSelectionProvider();
@@ -76,7 +78,7 @@ public class GotoNextBookmarkAction extends TextEditorAction {
if (selection == null || selection.isEmpty())
return;
- IEditorInput input= editor.getEditorInput();
+ IEditorInput input = editor.getEditorInput();
if (input == null)
return;
@@ -110,8 +112,7 @@ public class GotoNextBookmarkAction extends TextEditorAction {
break;
}
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
e.printStackTrace();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java
index 1ee7346ae32..d9c659f9255 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java
@@ -54,7 +54,6 @@ import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
import org.eclipse.cdt.internal.ui.text.CIndenter;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
-
/**
* Indents a line or range of lines in a C document to its correct position. No complete
* AST must be present, the indentation is computed using heuristics. The algorithm used is fast for
@@ -84,7 +83,7 @@ public class IndentAction extends TextEditorAction {
*/
public IndentAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean isTabAction) {
super(bundle, prefix, editor);
- fIsTabAction= isTabAction;
+ fIsTabAction = isTabAction;
}
@Override
@@ -93,21 +92,21 @@ public class IndentAction extends TextEditorAction {
if (!isEnabled() || !validateEditorInputState())
return;
- ITextSelection selection= getSelection();
- final IDocument document= getDocument();
+ ITextSelection selection = getSelection();
+ final IDocument document = getDocument();
if (document != null) {
- final int offset= selection.getOffset();
- final int length= selection.getLength();
- final Position end= new Position(offset + length);
+ final int offset = selection.getOffset();
+ final int length = selection.getLength();
+ final Position end = new Position(offset + length);
final int firstLine, nLines;
- fCaretOffset= -1;
+ fCaretOffset = -1;
try {
- firstLine= document.getLineOfOffset(offset);
+ firstLine = document.getLineOfOffset(offset);
// check for marginal (zero-length) lines
- int minusOne= length == 0 ? 0 : 1;
- nLines= document.getLineOfOffset(offset + length - minusOne) - firstLine + 1;
+ int minusOne = length == 0 ? 0 : 1;
+ nLines = document.getLineOfOffset(offset + length - minusOne) - firstLine + 1;
document.addPosition(end);
} catch (BadLocationException e) {
// will only happen on concurrent modification
@@ -115,19 +114,19 @@ public class IndentAction extends TextEditorAction {
return;
}
- Runnable runnable= new Runnable() {
+ Runnable runnable = new Runnable() {
@Override
public void run() {
- IRewriteTarget target= getTextEditor().getAdapter(IRewriteTarget.class);
+ IRewriteTarget target = getTextEditor().getAdapter(IRewriteTarget.class);
if (target != null)
target.beginCompoundChange();
try {
- CHeuristicScanner scanner= new CHeuristicScanner(document);
- CIndenter indenter= new CIndenter(document, scanner, getCProject());
- final boolean multiLine= nLines > 1;
- boolean hasChanged= false;
- for (int i= 0; i < nLines; i++) {
+ CHeuristicScanner scanner = new CHeuristicScanner(document);
+ CIndenter indenter = new CIndenter(document, scanner, getCProject());
+ final boolean multiLine = nLines > 1;
+ boolean hasChanged = false;
+ for (int i = 0; i < nLines; i++) {
hasChanged |= indentLine(document, firstLine + i, offset, indenter, scanner, multiLine);
}
@@ -135,11 +134,11 @@ public class IndentAction extends TextEditorAction {
// keep selection when indenting multiple
int newOffset, newLength;
if (!fIsTabAction && multiLine) {
- newOffset= offset;
- newLength= end.getOffset() - offset;
+ newOffset = offset;
+ newLength = end.getOffset() - offset;
} else {
- newOffset= fCaretOffset;
- newLength= 0;
+ newOffset = fCaretOffset;
+ newLength = 0;
}
// always reset the selection if anything was replaced
@@ -149,7 +148,8 @@ public class IndentAction extends TextEditorAction {
} catch (BadLocationException e) {
// will only happen on concurrent modification
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK,
+ "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$
} finally {
document.removePosition(end);
if (target != null)
@@ -159,7 +159,7 @@ public class IndentAction extends TextEditorAction {
};
if (nLines > 50) {
- Display display= getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay();
+ Display display = getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay();
BusyIndicator.showWhile(display, runnable);
} else {
runnable.run();
@@ -176,9 +176,9 @@ public class IndentAction extends TextEditorAction {
private void selectAndReveal(int newOffset, int newLength) {
Assert.isTrue(newOffset >= 0);
Assert.isTrue(newLength >= 0);
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (editor instanceof CEditor) {
- ISourceViewer viewer= ((CEditor)editor).getViewer();
+ ISourceViewer viewer = ((CEditor) editor).getViewer();
if (viewer != null)
viewer.setSelectedRange(newOffset, newLength);
} else {
@@ -200,21 +200,24 @@ public class IndentAction extends TextEditorAction {
* @return <code>true</code> if <code>document</code> was modified, <code>false</code> otherwise
* @throws BadLocationException if the document got changed concurrently
*/
- private boolean indentLine(IDocument document, int line, int caret, CIndenter indenter, CHeuristicScanner scanner, boolean multiLine) throws BadLocationException {
- IRegion currentLine= document.getLineInformation(line);
- int offset= currentLine.getOffset();
- int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
+ private boolean indentLine(IDocument document, int line, int caret, CIndenter indenter, CHeuristicScanner scanner,
+ boolean multiLine) throws BadLocationException {
+ IRegion currentLine = document.getLineInformation(line);
+ int offset = currentLine.getOffset();
+ int wsStart = offset; // where we start searching for non-WS; after the "//" in single line comments
- String indent= null;
+ String indent = null;
if (offset < document.getLength()) {
- ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
- ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
- String type= partition.getType();
+ ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
+ ITypedRegion startingPartition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset,
+ false);
+ String type = partition.getType();
if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT) || type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
- indent= computeCommentIndent(document, line, scanner, startingPartition);
+ indent = computeCommentIndent(document, line, scanner, startingPartition);
} else if (startingPartition.getType().equals(ICPartitions.C_PREPROCESSOR)) {
- indent= computePreprocessorIndent(document, line, startingPartition);
- } else if (startingPartition.getType().equals(ICPartitions.C_STRING) && offset > startingPartition.getOffset()) {
+ indent = computePreprocessorIndent(document, line, startingPartition);
+ } else if (startingPartition.getType().equals(ICPartitions.C_STRING)
+ && offset > startingPartition.getOffset()) {
// Don't indent inside (raw-)string, but if the indent action was triggered by a Tab key,
// insert a '\t' character or spaces at the caret position.
if (!fIsTabAction)
@@ -234,27 +237,28 @@ public class IndentAction extends TextEditorAction {
text = buf.toString();
}
document.replace(caret, 0, text);
- fCaretOffset= caret + text.length();
+ fCaretOffset = caret + text.length();
return true;
- } else if (!fIsTabAction && startingPartition.getOffset() == offset && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
+ } else if (!fIsTabAction && startingPartition.getOffset() == offset
+ && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
// line comment starting at position 0 -> indent inside
if (indentInsideLineComments()) {
- int max= document.getLength() - offset;
- int slashes= 2;
+ int max = document.getLength() - offset;
+ int slashes = 2;
while (slashes < max - 1 && document.get(offset + slashes, 2).equals("//")) //$NON-NLS-1$
- slashes+= 2;
+ slashes += 2;
- wsStart= offset + slashes;
+ wsStart = offset + slashes;
- StringBuilder computed= indenter.computeIndentation(offset);
+ StringBuilder computed = indenter.computeIndentation(offset);
if (computed == null)
- computed= new StringBuilder(0);
- int tabSize= getTabSize();
+ computed = new StringBuilder(0);
+ int tabSize = getTabSize();
while (slashes > 0 && computed.length() > 0) {
- char c= computed.charAt(0);
+ char c = computed.charAt(0);
if (c == '\t') {
if (slashes > tabSize)
- slashes-= tabSize;
+ slashes -= tabSize;
else
break;
} else if (c == ' ') {
@@ -266,51 +270,51 @@ public class IndentAction extends TextEditorAction {
computed.deleteCharAt(0);
}
- indent= document.get(offset, wsStart - offset) + computed;
+ indent = document.get(offset, wsStart - offset) + computed;
}
}
}
// standard C code indentation
if (indent == null) {
- StringBuilder computed= indenter.computeIndentation(offset);
+ StringBuilder computed = indenter.computeIndentation(offset);
if (computed != null)
- indent= computed.toString();
+ indent = computed.toString();
else
- indent= ""; //$NON-NLS-1$
+ indent = ""; //$NON-NLS-1$
}
// change document:
// get current white space
- int lineLength= currentLine.getLength();
- int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
+ int lineLength = currentLine.getLength();
+ int end = scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
if (end == CHeuristicScanner.NOT_FOUND) {
// an empty line
- end= offset + lineLength;
+ end = offset + lineLength;
if (multiLine && !indentEmptyLines())
- indent= ""; //$NON-NLS-1$
+ indent = ""; //$NON-NLS-1$
}
- int length= end - offset;
- String currentIndent= document.get(offset, length);
+ int length = end - offset;
+ String currentIndent = document.get(offset, length);
// if we are right before the text start / line end, and already after the insertion point
// then just shift to the right
if (fIsTabAction && caret == end && whiteSpaceLength(currentIndent) >= whiteSpaceLength(indent)) {
- int indentWidth= whiteSpaceLength(currentIndent) + getIndentSize();
+ int indentWidth = whiteSpaceLength(currentIndent) + getIndentSize();
if (useTabsAndSpaces()) {
currentIndent = trimSpacesRight(currentIndent);
}
- String replacement= IndentUtil.changePrefix(currentIndent, indentWidth, getTabSize(), useSpaces());
+ String replacement = IndentUtil.changePrefix(currentIndent, indentWidth, getTabSize(), useSpaces());
document.replace(offset, length, replacement);
- fCaretOffset= offset + replacement.length();
+ fCaretOffset = offset + replacement.length();
return true;
}
// set the caret offset so it can be used when setting the selection
if (caret >= offset && caret <= end)
- fCaretOffset= offset + indent.length();
+ fCaretOffset = offset + indent.length();
else
- fCaretOffset= -1;
+ fCaretOffset = -1;
// only change the document if it is a real change
if (!indent.equals(currentIndent)) {
@@ -331,7 +335,7 @@ public class IndentAction extends TextEditorAction {
while (i >= 0 && indent.charAt(i) == ' ') {
--i;
}
- return indent.substring(0, i+1);
+ return indent.substring(0, i + 1);
}
/**
@@ -344,7 +348,8 @@ public class IndentAction extends TextEditorAction {
* @return the indent, or <code>null</code> if not computable
* @throws BadLocationException
*/
- private String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
+ private String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition)
+ throws BadLocationException {
return IndentUtil.computeCommentIndent(document, line, scanner, partition);
}
@@ -357,7 +362,8 @@ public class IndentAction extends TextEditorAction {
* @return the indent, or <code>null</code> if not computable
* @throws BadLocationException
*/
- private String computePreprocessorIndent(IDocument document, int line, ITypedRegion partition) throws BadLocationException {
+ private String computePreprocessorIndent(IDocument document, int line, ITypedRegion partition)
+ throws BadLocationException {
return IndentUtil.computePreprocessorIndent(document, line, partition);
}
@@ -391,7 +397,8 @@ public class IndentAction extends TextEditorAction {
* @return <code>true</code> if tabs and spaces should be used
*/
private boolean useTabsAndSpaces() {
- return DefaultCodeFormatterConstants.MIXED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
+ return DefaultCodeFormatterConstants.MIXED
+ .equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
}
/**
@@ -420,7 +427,8 @@ public class IndentAction extends TextEditorAction {
* @return <code>true</code> if empty lines should be indented, <code>false</code> otherwise
*/
private boolean indentEmptyLines() {
- return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES));
+ return DefaultCodeFormatterConstants.TRUE
+ .equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES));
}
/**
@@ -429,7 +437,8 @@ public class IndentAction extends TextEditorAction {
* @return <code>true</code> if line comments at column 0 should be indented inside, <code>false</code> otherwise.
*/
private boolean indentInsideLineComments() {
- return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS));
+ return DefaultCodeFormatterConstants.TRUE
+ .equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS));
}
/**
@@ -439,7 +448,7 @@ public class IndentAction extends TextEditorAction {
* @return the value of the preference
*/
private String getCoreFormatterOption(String key) {
- ICProject project= getCProject();
+ ICProject project = getCProject();
if (project == null)
return CCorePlugin.getOption(key);
return project.getOption(key, true);
@@ -469,7 +478,7 @@ public class IndentAction extends TextEditorAction {
* <code>null</code> if it cannot be found
*/
private ICProject getCProject() {
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (editor == null)
return null;
@@ -482,7 +491,7 @@ public class IndentAction extends TextEditorAction {
* @return the editor's selection provider or <code>null</code>
*/
private ISelectionProvider getSelectionProvider() {
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (editor != null) {
return editor.getSelectionProvider();
}
@@ -511,27 +520,27 @@ public class IndentAction extends TextEditorAction {
* @return <code>true</code> if the selection is valid for an indent operation
*/
private boolean isValidSelection() {
- ITextSelection selection= getSelection();
+ ITextSelection selection = getSelection();
if (selection.isEmpty())
return false;
- int offset= selection.getOffset();
- int length= selection.getLength();
+ int offset = selection.getOffset();
+ int length = selection.getLength();
- IDocument document= getDocument();
+ IDocument document = getDocument();
if (document == null)
return false;
try {
- IRegion firstLine= document.getLineInformationOfOffset(offset);
- int lineOffset= firstLine.getOffset();
+ IRegion firstLine = document.getLineInformationOfOffset(offset);
+ int lineOffset = firstLine.getOffset();
// 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) {
return document.get(lineOffset, offset - lineOffset).trim().length() == 0;
}
-// return lineOffset + firstLine.getLength() < offset + length;
+ // return lineOffset + firstLine.getLength() < offset + length;
return false; // only enable for empty selections for now
} catch (BadLocationException e) {
}
@@ -545,7 +554,7 @@ public class IndentAction extends TextEditorAction {
* @return <code>true</code> if smart mode is on, <code>false</code> otherwise
*/
private boolean isSmartMode() {
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (editor instanceof ITextEditorExtension3)
return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT;
@@ -560,10 +569,10 @@ public class IndentAction extends TextEditorAction {
* @return the current document or <code>null</code>
*/
private IDocument getDocument() {
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (editor != null) {
- IDocumentProvider provider= editor.getDocumentProvider();
- IEditorInput input= editor.getEditorInput();
+ IDocumentProvider provider = editor.getDocumentProvider();
+ IEditorInput input = editor.getEditorInput();
if (provider != null && input != null)
return provider.getDocument(input);
@@ -578,9 +587,9 @@ public class IndentAction extends TextEditorAction {
* @return the current selection, never <code>null</code>
*/
private ITextSelection getSelection() {
- ISelectionProvider provider= getSelectionProvider();
+ ISelectionProvider provider = getSelectionProvider();
if (provider != null) {
- ISelection selection= provider.getSelection();
+ ISelection selection = provider.getSelection();
if (selection instanceof ITextSelection)
return (ITextSelection) selection;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java
index 0a15e1984e5..3082149131e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java
@@ -39,43 +39,44 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
public class OpenActionUtil {
-
- private static final String DIALOG_SETTINGS_SECTION_NAME = CUIPlugin.PLUGIN_ID + ".OPEN_ACTION_SELECTION_DIALOG_SECTION"; //$NON-NLS-1$
+
+ private static final String DIALOG_SETTINGS_SECTION_NAME = CUIPlugin.PLUGIN_ID
+ + ".OPEN_ACTION_SELECTION_DIALOG_SECTION"; //$NON-NLS-1$
private OpenActionUtil() {
// no instance.
}
-
+
/**
* Opens the editor on the given element and subsequently selects it.
*/
public static void open(Object element) throws CModelException, PartInitException {
open(element, true);
}
-
+
/**
* Opens the editor on the given element and subsequently selects it.
*/
public static void open(Object element, boolean activate) throws CModelException, PartInitException {
- IEditorPart part= EditorUtility.openInEditor(element, activate);
+ IEditorPart part = EditorUtility.openInEditor(element, activate);
if (element instanceof ICElement)
- EditorUtility.revealInEditor(part, (ICElement)element);
+ EditorUtility.revealInEditor(part, (ICElement) element);
}
-
+
/**
* Filters out source references from the given code resolve results.
- * A utility method that can be called by subclassers.
+ * A utility method that can be called by subclassers.
*/
public static List<ISourceReference> filterResolveResults(ICElement[] codeResolveResults) {
- int nResults= codeResolveResults.length;
- List<ISourceReference> refs= new ArrayList<ISourceReference>(nResults);
- for (int i= 0; i < nResults; i++) {
+ int nResults = codeResolveResults.length;
+ List<ISourceReference> refs = new ArrayList<ISourceReference>(nResults);
+ for (int i = 0; i < nResults; i++) {
if (codeResolveResults[i] instanceof ISourceReference)
refs.add((ISourceReference) codeResolveResults[i]);
}
return refs;
}
-
+
/**
* Shows a dialog for resolving an ambiguous C element.
* Utility method that can be called by subclasses.
@@ -91,29 +92,32 @@ public class OpenActionUtil {
* @param shell parent shell for showing the dialog
* @param title title of the dialog
* @param message message to be shown in the dialog
- * @param textFlags text flags to change the label provider
- * @param imageFlags image flags to change the label provider
+ * @param textFlags text flags to change the label provider
+ * @param imageFlags image flags to change the label provider
* @return the selected element or <code>null</code>
* @since 4.0
*/
- public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message, long textFlags, int imageFlags) {
- int nResults= elements.length;
-
+ public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message,
+ long textFlags, int imageFlags) {
+ int nResults = elements.length;
+
if (nResults == 0)
return null;
-
+
if (nResults == 1)
return elements[0];
-
+
ILabelProvider labelProvider;
if (textFlags == 0 && imageFlags == 0) {
- labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT | CElementLabelProvider.SHOW_QUALIFIED);
+ labelProvider = new CElementLabelProvider(
+ CElementLabelProvider.SHOW_DEFAULT | CElementLabelProvider.SHOW_QUALIFIED);
} else {
- labelProvider= new CUILabelProvider(textFlags, imageFlags);
+ labelProvider = new CUILabelProvider(textFlags, imageFlags);
}
-
+
// TODO: Use CDT's ElementListSelectionDialog as in selectPath().
- org.eclipse.ui.dialogs.ElementListSelectionDialog dialog= new org.eclipse.ui.dialogs.ElementListSelectionDialog(shell, labelProvider) {
+ org.eclipse.ui.dialogs.ElementListSelectionDialog dialog = new org.eclipse.ui.dialogs.ElementListSelectionDialog(
+ shell, labelProvider) {
@Override
protected IDialogSettings getDialogBoundsSettings() {
IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
@@ -127,21 +131,21 @@ public class OpenActionUtil {
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setElements(elements);
-
+
if (dialog.open() == Window.OK) {
- Object[] selection= dialog.getResult();
+ Object[] selection = dialog.getResult();
if (selection != null && selection.length > 0) {
- nResults= selection.length;
- for (int i= 0; i < nResults; i++) {
- Object current= selection[i];
+ nResults = selection.length;
+ for (int i = 0; i < nResults; i++) {
+ Object current = selection[i];
if (current instanceof ICElement)
return (ICElement) current;
}
}
- }
+ }
return null;
}
-
+
/**
* Shows a dialog for resolving an ambiguous path.
* @param paths an array of ambiguous paths
@@ -150,22 +154,23 @@ public class OpenActionUtil {
* @return the selected path or <code>null</code>
*/
public static IPath selectPath(List<IPath> paths, String title, String message) {
- ILabelProvider renderer= new LabelProvider() {
+ ILabelProvider renderer = new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IPath) {
- IPath file= (IPath)element;
- return file.lastSegment() + " - " + file.toString(); //$NON-NLS-1$
+ IPath file = (IPath) element;
+ return file.lastSegment() + " - " + file.toString(); //$NON-NLS-1$
}
return super.getText(element);
}
};
-
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), renderer, false, false);
+
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(),
+ renderer, false, false);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setElements(paths);
-
+
if (dialog.open() == Window.OK) {
return (IPath) dialog.getSelectedElement();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexHandler.java
index 80451d0c708..1e5934d7d0d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexHandler.java
@@ -21,7 +21,7 @@ package org.eclipse.cdt.internal.ui.actions;
*/
public class RebuildIndexHandler extends AbstractUpdateIndexHandler {
private final RebuildIndexAction rebuildIndexAction = new RebuildIndexAction();
-
+
@Override
public AbstractUpdateIndexAction getAction() {
return rebuildIndexAction;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java
index 31c031ab6e2..4ea687f7818 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java
@@ -31,32 +31,34 @@ import org.eclipse.cdt.ui.text.ICPartitions;
/**
* Action that removes the enclosing comment marks from a C block comment.
- *
+ *
* @since 3.0
*/
public class RemoveBlockCommentAction extends BlockCommentAction {
/**
* Creates a new instance.
- *
+ *
* @param bundle the resource bundle
* @param prefix a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or
+ * (described in <code>ResourceAction</code> constructor), or
* <code>null</code> if none
* @param editor the text editor
*/
public RemoveBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
super(bundle, prefix, editor);
}
-
+
@Override
- protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadPartitioningException, BadLocationException {
- if ( !(docExtension instanceof IDocument) ) return;
+ protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory)
+ throws BadPartitioningException, BadLocationException {
+ if (!(docExtension instanceof IDocument))
+ return;
+
+ List<Edit> edits = new LinkedList<Edit>();
- List<Edit> edits= new LinkedList<Edit>();
-
int partitionStart = -1;
- int partitionEnd = selection.getOffset();
+ int partitionEnd = selection.getOffset();
do {
ITypedRegion partition = docExtension.getPartition(ICPartitions.C_PARTITIONING, partitionEnd, false);
@@ -65,20 +67,19 @@ public class RemoveBlockCommentAction extends BlockCommentAction {
break;
}
partitionStart = partition.getOffset();
- partitionEnd = partitionStart + partition.getLength();
+ partitionEnd = partitionStart + partition.getLength();
if (partition.getType() == ICPartitions.C_MULTI_LINE_COMMENT
|| partition.getType() == ICPartitions.C_MULTI_LINE_DOC_COMMENT) {
- uncommentPartition((IDocument)docExtension, factory, edits, partitionStart, partitionEnd);
+ uncommentPartition((IDocument) docExtension, factory, edits, partitionStart, partitionEnd);
}
- } while (partitionEnd < selection.getOffset()+selection.getLength());
+ } while (partitionEnd < selection.getOffset() + selection.getLength());
executeEdits(edits);
}
- private void uncommentPartition(IDocument doc, Edit.EditFactory factory,
- List<Edit> edits, int partitionStart, int partitionEnd)
- throws BadLocationException {
-
+ private void uncommentPartition(IDocument doc, Edit.EditFactory factory, List<Edit> edits, int partitionStart,
+ int partitionEnd) throws BadLocationException {
+
int startCommentTokenLength = getCommentStart().length();
int endCommentTokenLength = getCommentEnd().length();
@@ -90,8 +91,8 @@ public class RemoveBlockCommentAction extends BlockCommentAction {
// start comment tag '/*'
if (lineContent.equals(getCommentStart())) {
String eol = doc.getLineDelimiter(doc.getLineOfOffset(partitionStart));
- if (eol!=null) {
- startCommentTokenLength = startCommentTokenLength+eol.length();
+ if (eol != null) {
+ startCommentTokenLength = startCommentTokenLength + eol.length();
}
}
}
@@ -103,7 +104,7 @@ public class RemoveBlockCommentAction extends BlockCommentAction {
// end comment tag '*/'
if (lineContent.equals(getCommentEnd())) {
String eol = doc.getLineDelimiter(doc.getLineOfOffset(partitionEnd));
- if (eol!=null) {
+ if (eol != null) {
endCommentTokenLength = endCommentTokenLength + eol.length();
}
}
@@ -118,5 +119,4 @@ public class RemoveBlockCommentAction extends BlockCommentAction {
return selection != null && !selection.isEmpty() && selection.getLength() > 0;
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java
index c465bf8dae3..e05ca2cf28f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java
@@ -37,7 +37,7 @@ public class SelectAllAction extends Action {
setToolTipText(ActionMessages.SelectAllAction_tooltip);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.SELECT_ALL_ACTION);
Assert.isNotNull(viewer);
- fViewer= viewer;
+ fViewer = viewer;
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
index bddec4dc8c3..e8239596c40 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
@@ -57,12 +57,12 @@ public class SelectionConverter {
*/
public static IStructuredSelection getStructuredSelection(IWorkbenchPart part) throws CModelException {
if (part instanceof CEditor)
- return new StructuredSelection(codeResolve((CEditor)part));
- ISelectionProvider provider= part.getSite().getSelectionProvider();
+ return new StructuredSelection(codeResolve((CEditor) part));
+ ISelectionProvider provider = part.getSite().getSelectionProvider();
if (provider != null) {
- ISelection selection= provider.getSelection();
+ ISelection selection = provider.getSelection();
if (selection instanceof IStructuredSelection)
- return (IStructuredSelection)selection;
+ return (IStructuredSelection) selection;
}
return StructuredSelection.EMPTY;
}
@@ -74,7 +74,7 @@ public class SelectionConverter {
* @param s The structured selection
* @return The converted selection
*/
- public static IStructuredSelection convertSelectionToCElements(ISelection s) {
+ public static IStructuredSelection convertSelectionToCElements(ISelection s) {
return convertSelectionToCElements(s, false);
}
@@ -84,8 +84,7 @@ public class SelectionConverter {
* @param keepNonCElements Whether to keep objects in selection if they cannot be converted
* @return The converted selection
*/
- public static IStructuredSelection convertSelectionToCElements(ISelection s,
- boolean keepNonCElements) {
+ public static IStructuredSelection convertSelectionToCElements(ISelection s, boolean keepNonCElements) {
List<Object> converted = new ArrayList<Object>();
if (s instanceof IStructuredSelection) {
Object[] elements = ((IStructuredSelection) s).toArray();
@@ -222,7 +221,8 @@ public class SelectionConverter {
}
public static ICElement getInput(ITextEditor editor) {
- if (editor == null) return null;
+ if (editor == null)
+ return null;
IEditorInput input = editor.getEditorInput();
IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(input);
@@ -246,7 +246,7 @@ public class SelectionConverter {
}
public static ICElement[] codeResolve(CEditor editor) throws CModelException {
- return codeResolve(getInput(editor), (ITextSelection)editor.getSelectionProvider().getSelection());
+ return codeResolve(getInput(editor), (ITextSelection) editor.getSelectionProvider().getSelection());
}
public static ICElement[] codeResolve(ICElement input, ITextSelection selection) throws CModelException {
@@ -259,28 +259,28 @@ public class SelectionConverter {
}
}
}
- ICElement[] elems = tunit.getElementsAtOffset(selection.getOffset());
- if (elems != null) {
- for (int i = 0; i < elems.length; ++i) {
- ICElement elem = elems[i];
- if (elem instanceof ISourceReference) {
- String text = selection.getText();
- if (text.equals(elem.getElementName())) {
- return new ICElement[] { elem };
- }
- }
- }
- for (int i = 0; i < elems.length; ++i) {
- ICElement elem = elems[i];
- if (elem instanceof ISourceReference) {
- ISourceRange range = ((ISourceReference)elem).getSourceRange();
- if (range.getStartPos() == selection.getOffset()) {
- return new ICElement[] { elem };
- }
- }
- }
- }
- }
+ ICElement[] elems = tunit.getElementsAtOffset(selection.getOffset());
+ if (elems != null) {
+ for (int i = 0; i < elems.length; ++i) {
+ ICElement elem = elems[i];
+ if (elem instanceof ISourceReference) {
+ String text = selection.getText();
+ if (text.equals(elem.getElementName())) {
+ return new ICElement[] { elem };
+ }
+ }
+ }
+ for (int i = 0; i < elems.length; ++i) {
+ ICElement elem = elems[i];
+ if (elem instanceof ISourceReference) {
+ ISourceRange range = ((ISourceReference) elem).getSourceRange();
+ if (range.getStartPos() == selection.getOffset()) {
+ return new ICElement[] { elem };
+ }
+ }
+ }
+ }
+ }
return ICElement.EMPTY_ARRAY;
}
@@ -289,13 +289,14 @@ public class SelectionConverter {
* asking the user if code resolve returned more than one result. If the selection
* doesn't cover a Java element <code>null</code> is returned.
*/
- public static ICElement codeResolve(CEditor editor, Shell shell, String title, String message) throws CModelException {
- ICElement[] elements= codeResolve(editor);
+ public static ICElement codeResolve(CEditor editor, Shell shell, String title, String message)
+ throws CModelException {
+ ICElement[] elements = codeResolve(editor);
if (elements == null || elements.length == 0)
return null;
- ICElement candidate= elements[0];
+ ICElement candidate = elements[0];
if (elements.length > 1) {
- candidate= OpenActionUtil.selectCElement(elements, shell, title, message);
+ candidate = OpenActionUtil.selectCElement(elements, shell, title, message);
}
return candidate;
}
@@ -306,11 +307,11 @@ public class SelectionConverter {
* length is greater than 0 the method returns the editor's input element.
*/
public static ICElement[] codeResolveOrInput(CEditor editor) throws CModelException {
- ICElement input= getInput(editor);
- ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection();
- ICElement[] result= codeResolve(input, selection);
+ ICElement input = getInput(editor);
+ ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
+ ICElement[] result = codeResolve(input, selection);
if (result.length == 0) {
- result= new ICElement[] {input};
+ result = new ICElement[] { input };
}
return result;
}
@@ -318,7 +319,7 @@ public class SelectionConverter {
public static ICElement[] codeResolveOrInputHandled(CEditor editor, Shell shell, String title) {
try {
return codeResolveOrInput(editor);
- } catch(CModelException e) {
+ } catch (CModelException e) {
ExceptionHandler.handle(e, shell, title, ActionMessages.SelectionConverter_codeResolve_failed);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java
index 2f960034186..7103c5551b2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java
@@ -28,8 +28,7 @@ public class StructureSelectHistoryAction extends StructureSelectionAction {
public static final String PREFIX = "StructureSelectHistory."; //$NON-NLS-1$
- public StructureSelectHistoryAction(ResourceBundle bundle, ITextEditor editor,
- SelectionHistory history) {
+ public StructureSelectHistoryAction(ResourceBundle bundle, ITextEditor editor, SelectionHistory history) {
super(bundle, PREFIX, editor, history);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java
index 659266107e7..5459a3bffda 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java
@@ -37,11 +37,11 @@ public class StructureSelectNextAction extends StructureSelectionAction {
public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
ISourceRange newSourceRange = expandToNext(ast, current);
if (newSourceRange == null) {
- newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current);
+ newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current);
}
if (newSourceRange != null) {
history.remember(current);
- }
+ }
return newSourceRange;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java
index e5298a9e4a2..bd31f07ab74 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java
@@ -37,11 +37,11 @@ public class StructureSelectPreviousAction extends StructureSelectionAction {
public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
ISourceRange newSourceRange = expandToPrevious(ast, current);
if (newSourceRange == null) {
- newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current);
+ newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current);
}
if (newSourceRange != null) {
history.remember(current);
- }
+ }
return newSourceRange;
}
@@ -72,7 +72,8 @@ public class StructureSelectPreviousAction extends StructureSelectionAction {
if (firstSelectedChildIndex > 0) {
IASTNode prevNode = children[firstSelectedChildIndex - 1];
int endingOffset = current.getStartPos() + current.getLength();
- return new SourceRange(prevNode.getFileLocation().getNodeOffset(), endingOffset - prevNode.getFileLocation().getNodeOffset());
+ return new SourceRange(prevNode.getFileLocation().getNodeOffset(),
+ endingOffset - prevNode.getFileLocation().getNodeOffset());
}
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java
index cfe3d1f28e8..bdfdd85922e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java
@@ -42,7 +42,8 @@ public abstract class StructureSelectionAction extends TextEditorAction {
protected final SelectionHistory history;
- protected StructureSelectionAction(ResourceBundle bundle, String prefix, ITextEditor editor, SelectionHistory history) {
+ protected StructureSelectionAction(ResourceBundle bundle, String prefix, ITextEditor editor,
+ SelectionHistory history) {
super(bundle, prefix, editor);
this.history = history;
}
@@ -71,7 +72,7 @@ public abstract class StructureSelectionAction extends TextEditorAction {
public static final String NEXT = "StructureSelectNext"; //$NON-NLS-1$
public static final String PREVIOUS = "StructureSelectPrevious"; //$NON-NLS-1$
public static final String HISTORY = "StructureSelectHistory"; //$NON-NLS-1$
-
+
@Override
public void run() {
IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
@@ -81,26 +82,27 @@ public abstract class StructureSelectionAction extends TextEditorAction {
final CEditor cEditor = (CEditor) editorPart;
ITranslationUnit tu = (ITranslationUnit) CDTUITools.getEditorInputCElement(cEditor.getEditorInput());
-
+
ITextSelection selection;
try {
selection = (ITextSelection) cEditor.getSelectionProvider().getSelection();
} catch (ClassCastException e) {
return;
}
-
+
final int offset = selection.getOffset();
final int length = selection.getLength();
-
- ExpandSelectionJob expandSelectionJob = new ExpandSelectionJob("expand selection", tu, cEditor, new SourceRange(offset, length)); //$NON-NLS-1$
-
+
+ ExpandSelectionJob expandSelectionJob = new ExpandSelectionJob("expand selection", tu, cEditor, //$NON-NLS-1$
+ new SourceRange(offset, length));
+
expandSelectionJob.schedule();
try {
expandSelectionJob.join();
} catch (InterruptedException e) {
return;
}
-
+
if (expandSelectionJob.newSourceRange != null) {
history.ignoreSelectionChanges();
cEditor.setSelection(expandSelectionJob.newSourceRange, true);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java
index 73652f68380..4f247cca77c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java
@@ -31,8 +31,8 @@ public class SurroundWithActionGroup extends ActionGroup {
private final String fGroup;
public SurroundWithActionGroup(CEditor editor, String group) {
- fEditor= editor;
- fGroup= group;
+ fEditor = editor;
+ fGroup = group;
}
/**
@@ -41,24 +41,26 @@ public class SurroundWithActionGroup extends ActionGroup {
*/
@Override
public void fillContextMenu(IMenuManager menu) {
- ISelectionProvider selectionProvider= fEditor.getSelectionProvider();
+ ISelectionProvider selectionProvider = fEditor.getSelectionProvider();
if (selectionProvider == null)
return;
- ISelection selection= selectionProvider.getSelection();
+ ISelection selection = selectionProvider.getSelection();
if (!(selection instanceof ITextSelection))
return;
- ITextSelection textSelection= (ITextSelection)selection;
+ ITextSelection textSelection = (ITextSelection) selection;
if (textSelection.getLength() == 0)
return;
- String menuText= ActionMessages.SurroundWithTemplateMenuAction_SubMenuName;
+ String menuText = ActionMessages.SurroundWithTemplateMenuAction_SubMenuName;
- MenuManager subMenu = new MenuManager(menuText, SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
+ MenuManager subMenu = new MenuManager(menuText,
+ SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
subMenu.setActionDefinitionId(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
menu.appendToGroup(fGroup, subMenu);
- subMenu.add(new Action() {});
+ subMenu.add(new Action() {
+ });
subMenu.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java
index 5ff49043c70..461dce5a464 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java
@@ -59,13 +59,13 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistInvocationCo
import org.eclipse.cdt.internal.ui.text.contentassist.TemplateCompletionProposalComputer;
public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownDelegate2 {
- public static final String SURROUND_WITH_QUICK_MENU_ACTION_ID= "org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"; //$NON-NLS-1$
+ public static final String SURROUND_WITH_QUICK_MENU_ACTION_ID = "org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"; //$NON-NLS-1$
- private static final String C_TEMPLATE_PREFERENCE_PAGE_ID= "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
+ private static final String C_TEMPLATE_PREFERENCE_PAGE_ID = "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
- private static final String TEMPLATE_GROUP= "templateGroup"; //$NON-NLS-1$
+ private static final String TEMPLATE_GROUP = "templateGroup"; //$NON-NLS-1$
- private static final String CONFIG_GROUP= "configGroup"; //$NON-NLS-1$
+ private static final String CONFIG_GROUP = "configGroup"; //$NON-NLS-1$
private static class ConfigureTemplatesAction extends Action {
public ConfigureTemplatesAction() {
@@ -74,7 +74,8 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
@Override
public void run() {
- PreferencesUtil.createPreferenceDialogOn(getShell(), C_TEMPLATE_PREFERENCE_PAGE_ID, new String[] {C_TEMPLATE_PREFERENCE_PAGE_ID}, null).open();
+ PreferencesUtil.createPreferenceDialogOn(getShell(), C_TEMPLATE_PREFERENCE_PAGE_ID,
+ new String[] { C_TEMPLATE_PREFERENCE_PAGE_ID }, null).open();
}
private Shell getShell() {
@@ -82,7 +83,8 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
}
}
- private static Action NONE_APPLICABLE_ACTION= new Action(ActionMessages.SurroundWithTemplateMenuAction_NoneApplicable) {
+ private static Action NONE_APPLICABLE_ACTION = new Action(
+ ActionMessages.SurroundWithTemplateMenuAction_NoneApplicable) {
@Override
public void run() {
//Do nothing
@@ -96,7 +98,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
private Menu fMenu;
private IPartService fPartService;
- private IPartListener fPartListener= new IPartListener() {
+ private IPartListener fPartListener = new IPartListener() {
@Override
public void partActivated(IWorkbenchPart part) {
}
@@ -124,8 +126,8 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
return;
}
MenuItem[] items = fMenu.getItems();
- for (int i= 0; i < items.length; i++) {
- MenuItem menuItem= items[i];
+ for (int i = 0; i < items.length; i++) {
+ MenuItem menuItem = items[i];
if (!menuItem.isDisposed()) {
menuItem.dispose();
}
@@ -149,12 +151,12 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
}
public static void fillMenu(IMenuManager menu, CEditor editor) {
- IAction[] actions= getTemplateActions(editor);
+ IAction[] actions = getTemplateActions(editor);
if (actions == null || actions.length == 0) {
menu.add(NONE_APPLICABLE_ACTION);
} else {
menu.add(new Separator(TEMPLATE_GROUP));
- for (int i= 0; i < actions.length; i++) {
+ for (int i = 0; i < actions.length; i++) {
menu.add(actions[i]);
}
}
@@ -167,7 +169,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
public void dispose() {
if (fPartService != null) {
fPartService.removePartListener(fPartListener);
- fPartService= null;
+ fPartService = null;
}
setMenu(null);
}
@@ -176,13 +178,13 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
public void init(IWorkbenchWindow window) {
if (fPartService != null) {
fPartService.removePartListener(fPartListener);
- fPartService= null;
+ fPartService = null;
}
if (window != null) {
- IPartService partService= window.getPartService();
+ IPartService partService = window.getPartService();
if (partService != null) {
- fPartService= partService;
+ fPartService = partService;
partService.addPartListener(fPartListener);
}
}
@@ -190,11 +192,11 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
@Override
public void run(IAction action) {
- IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart();
+ IWorkbenchPart activePart = CUIPlugin.getActivePage().getActivePart();
if (!(activePart instanceof CEditor))
return;
- final CEditor editor= (CEditor) activePart;
+ final CEditor editor = (CEditor) activePart;
new QuickMenuCreator() {
@Override
@@ -214,30 +216,30 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
* @param menu the menu to fill entries into it
*/
protected void fillMenu(Menu menu) {
- IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart();
+ IWorkbenchPart activePart = CUIPlugin.getActivePage().getActivePart();
if (!(activePart instanceof CEditor)) {
- ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
+ ActionContributionItem item = new ActionContributionItem(NONE_APPLICABLE_ACTION);
item.fill(menu, -1);
return;
}
- CEditor editor= (CEditor) activePart;
- IAction[] actions= getTemplateActions(editor);
+ CEditor editor = (CEditor) activePart;
+ IAction[] actions = getTemplateActions(editor);
if (actions == null || actions.length <= 0) {
- ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
+ ActionContributionItem item = new ActionContributionItem(NONE_APPLICABLE_ACTION);
item.fill(menu, -1);
} else {
- for (int i= 0; i < actions.length; i++) {
- ActionContributionItem item= new ActionContributionItem(actions[i]);
+ for (int i = 0; i < actions.length; i++) {
+ ActionContributionItem item = new ActionContributionItem(actions[i]);
item.fill(menu, -1);
}
}
- Separator configGroup= new Separator(CONFIG_GROUP);
+ Separator configGroup = new Separator(CONFIG_GROUP);
configGroup.fill(menu, -1);
- ActionContributionItem configAction= new ActionContributionItem(new ConfigureTemplatesAction());
+ ActionContributionItem configAction = new ActionContributionItem(new ConfigureTemplatesAction());
configAction.fill(menu, -1);
}
@@ -247,7 +249,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
public void menuShown(MenuEvent e) {
Menu m = (Menu) e.widget;
MenuItem[] items = m.getItems();
- for (int i= 0; i < items.length; i++) {
+ for (int i = 0; i < items.length; i++) {
items[i].dispose();
}
fillMenu(m);
@@ -263,22 +265,23 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
}
private static IAction[] getTemplateActions(CEditor editor) {
- ITextSelection textSelection= getTextSelection(editor);
+ ITextSelection textSelection = getTextSelection(editor);
if (textSelection == null || textSelection.isEmpty())
return null;
- ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+ ITranslationUnit tu = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
if (tu == null)
return null;
TemplateCompletionProposalComputer templateComputer = new TemplateCompletionProposalComputer();
- CContentAssistInvocationContext context = new CContentAssistInvocationContext(editor.getViewer(), textSelection.getOffset(), editor, true, false);
+ CContentAssistInvocationContext context = new CContentAssistInvocationContext(editor.getViewer(),
+ textSelection.getOffset(), editor, true, false);
try {
- List<ICompletionProposal> proposals= templateComputer.computeCompletionProposals(context, null);
+ List<ICompletionProposal> proposals = templateComputer.computeCompletionProposals(context, null);
if (proposals == null || proposals.isEmpty())
return null;
-
+
return getActionsFromProposals(proposals, context.getInvocationOffset(), editor.getViewer());
} finally {
context.dispose();
@@ -286,28 +289,28 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
}
private static ITextSelection getTextSelection(CEditor editor) {
- ISelectionProvider selectionProvider= editor.getSelectionProvider();
+ ISelectionProvider selectionProvider = editor.getSelectionProvider();
if (selectionProvider == null)
return null;
- ISelection selection= selectionProvider.getSelection();
+ ISelection selection = selectionProvider.getSelection();
if (!(selection instanceof ITextSelection))
return null;
- return (ITextSelection)selection;
+ return (ITextSelection) selection;
}
- private static IAction[] getActionsFromProposals(List<ICompletionProposal> proposals,
- final int offset, final ITextViewer viewer) {
- List<Action> result= new ArrayList<>();
+ private static IAction[] getActionsFromProposals(List<ICompletionProposal> proposals, final int offset,
+ final ITextViewer viewer) {
+ List<Action> result = new ArrayList<>();
int j = 1;
for (final ICompletionProposal proposal : proposals) {
- StringBuilder actionName= new StringBuilder();
+ StringBuilder actionName = new StringBuilder();
if (j < 10) {
actionName.append('&').append(j).append(' ');
}
actionName.append(proposal.getDisplayString());
- Action action= new Action(actionName.toString()) {
+ Action action = new Action(actionName.toString()) {
@Override
public void run() {
applyProposal(proposal, viewer, (char) 0, 0, offset);
@@ -323,13 +326,13 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
return result.toArray(new IAction[result.size()]);
}
- private static void applyProposal(ICompletionProposal proposal, ITextViewer viewer, char trigger,
- int stateMask, final int offset) {
+ private static void applyProposal(ICompletionProposal proposal, ITextViewer viewer, char trigger, int stateMask,
+ final int offset) {
Assert.isTrue(proposal instanceof ICompletionProposalExtension2);
- IRewriteTarget target= null;
- IEditingSupportRegistry registry= null;
- IEditingSupport helper= new IEditingSupport() {
+ IRewriteTarget target = null;
+ IEditingSupportRegistry registry = null;
+ IEditingSupport helper = new IEditingSupport() {
@Override
public boolean isOriginator(DocumentEvent event, IRegion focus) {
return focus.getOffset() <= offset && focus.getOffset() + focus.getLength() >= offset;
@@ -342,24 +345,24 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
};
try {
- IDocument document= viewer.getDocument();
+ IDocument document = viewer.getDocument();
if (viewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) viewer;
- target= extension.getRewriteTarget();
+ ITextViewerExtension extension = (ITextViewerExtension) viewer;
+ target = extension.getRewriteTarget();
}
if (target != null)
target.beginCompoundChange();
if (viewer instanceof IEditingSupportRegistry) {
- registry= (IEditingSupportRegistry) viewer;
+ registry = (IEditingSupportRegistry) viewer;
registry.register(helper);
}
((ICompletionProposalExtension2) proposal).apply(viewer, trigger, stateMask, offset);
- Point selection= proposal.getSelection(document);
+ Point selection = proposal.getSelection(document);
if (selection != null) {
viewer.setSelectedRange(selection.x, selection.y);
viewer.revealRange(selection.x, selection.y);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java
index f75a5a0b89a..97c6d7c0a41 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
import org.eclipse.cdt.core.index.IIndexManager;
@@ -19,10 +19,8 @@ import org.eclipse.cdt.core.index.IIndexManager;
public class UpdateIndexWithModifiedFilesAction extends AbstractUpdateIndexAction {
@Override
protected int getUpdateOptions() {
- return IIndexManager.UPDATE_CHECK_TIMESTAMPS |
- IIndexManager.UPDATE_CHECK_CONFIGURATION |
- IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT |
- IIndexManager.UPDATE_CHECK_CONTENTS_HASH |
- IIndexManager.UPDATE_UNRESOLVED_INCLUDES;
+ return IIndexManager.UPDATE_CHECK_TIMESTAMPS | IIndexManager.UPDATE_CHECK_CONFIGURATION
+ | IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT | IIndexManager.UPDATE_CHECK_CONTENTS_HASH
+ | IIndexManager.UPDATE_UNRESOLVED_INCLUDES;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesHandler.java
index aa1c17d8513..a3067042f99 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesHandler.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
-
/**
* Handler for {@link org.eclipse.cdt.internal.ui.actions.UpdateIndexWithModifiedFilesAction}
*
@@ -23,7 +22,7 @@ package org.eclipse.cdt.internal.ui.actions;
public class UpdateIndexWithModifiedFilesHandler extends AbstractUpdateIndexHandler {
private final UpdateIndexWithModifiedFilesAction updateAction = new UpdateIndexWithModifiedFilesAction();
-
+
@Override
public AbstractUpdateIndexAction getAction() {
return updateAction;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateUnresolvedIncludesHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateUnresolvedIncludesHandler.java
index 6a8670efcca..27df0a6a8b4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateUnresolvedIncludesHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateUnresolvedIncludesHandler.java
@@ -21,7 +21,7 @@ package org.eclipse.cdt.internal.ui.actions;
*/
public class UpdateUnresolvedIncludesHandler extends AbstractUpdateIndexHandler {
private final UpdateUnresolvedIncludesAction updateAction = new UpdateUnresolvedIncludesAction();
-
+
@Override
public AbstractUpdateIndexAction getAction() {
return updateAction;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java
index c39b2171565..3264a3c06a2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java
@@ -52,8 +52,8 @@ 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.
*/
public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
+ fWorkspaceRunnable = runnable;
+ fRule = rule;
}
/**
@@ -66,9 +66,9 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
* thread
*/
public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule, boolean transfer) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
- fTransfer= transfer;
+ fWorkspaceRunnable = runnable;
+ fRule = rule;
+ fTransfer = transfer;
}
public ISchedulingRule getSchedulingRule() {
@@ -96,7 +96,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
}
public void runAsUserJob(String name, final Object jobFamiliy) {
- Job buildJob = new Job(name){
+ Job buildJob = new Job(name) {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@@ -105,7 +105,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
try {
WorkbenchRunnableAdapter.this.run(monitor);
} catch (InvocationTargetException e) {
- Throwable cause= e.getCause();
+ Throwable cause = e.getCause();
if (cause instanceof CoreException) {
return ((CoreException) cause).getStatus();
}
@@ -117,6 +117,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
}
return Status.OK_STATUS;
}
+
@Override
public boolean belongsTo(Object family) {
return jobFamiliy == family;
@@ -129,4 +130,3 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
// TODO: should block until user pressed 'to background'
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java
index c67a7eee040..19155f9a216 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java
@@ -64,12 +64,12 @@ public class BuildPreferencePage extends PreferencePage implements IWorkbenchPre
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
- Composite container= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(10);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = 0;
+ layout.verticalSpacing = convertVerticalDLUsToPixels(10);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
container.setLayout(layout);
// Build either default configuration or all.
@@ -113,7 +113,7 @@ public class BuildPreferencePage extends PreferencePage implements IWorkbenchPre
}
private void addNote(Group parent, String noteMessage) {
- Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), parent,
+ Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), parent,
PreferencesMessages.CPluginPreferencePage_note, noteMessage);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.verticalIndent = GROUP_VINDENT;
@@ -128,7 +128,7 @@ public class BuildPreferencePage extends PreferencePage implements IWorkbenchPre
// this is temporary fix for problem that 3 line note does not displayed properly within the group
Label messageLabel = (Label) children[1];
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint=500;
+ gd.widthHint = 500;
messageLabel.setLayoutData(gd);
}
return messageComposite;
@@ -166,13 +166,13 @@ public class BuildPreferencePage extends PreferencePage implements IWorkbenchPre
return true;
}
- @Override
+ @Override
protected void performDefaults() {
ACBuilder.setAllConfigBuild(false);
ACBuilder.setBuildConfigResourceChanges(false);
buildActive.setSelection(true);
buildAll.setSelection(false);
buildOnlyOnRefChange.setSelection(false);
- super.performDefaults();
- }
+ super.performDefaults();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java
index c1658b89cc4..89e1264822c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java
@@ -64,8 +64,8 @@ public class NewToolChainWizardSelectionPage extends WizardPage {
String iconFile = element.getAttribute("icon"); //$NON-NLS-1$
if (iconFile != null) {
- ImageDescriptor desc = CUIPlugin
- .imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconFile);
+ ImageDescriptor desc = CUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(),
+ iconFile);
if (desc != null) {
item.setImage(desc.createImage());
}
@@ -109,8 +109,7 @@ public class NewToolChainWizardSelectionPage extends WizardPage {
if (descImage == null) {
return null;
}
- return AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(),
- descImage);
+ return AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), descImage);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java
index 6ea8cebdbfc..3fe645a9543 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java
@@ -44,7 +44,7 @@ public class BuildConsole extends AbstractConsole {
/**
* Property constant indicating the color of a stream has changed.
*/
- public static final String P_STREAM_COLOR = CUIPlugin.PLUGIN_ID + ".CONSOLE_P_STREAM_COLOR"; //$NON-NLS-1$
+ public static final String P_STREAM_COLOR = CUIPlugin.PLUGIN_ID + ".CONSOLE_P_STREAM_COLOR"; //$NON-NLS-1$
/** The page containing this build console */
private BuildConsolePage fBuildConsolePage;
@@ -81,7 +81,7 @@ public class BuildConsole extends AbstractConsole {
*/
public BuildConsole(IBuildConsoleManager manager, String name, String contextId, URL iconUrl) {
super(name, CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_BUILD_CONSOLE));
- if (iconUrl!=null) {
+ if (iconUrl != null) {
CDTSharedImages.register(iconUrl);
this.setImageDescriptor(CDTSharedImages.getImageDescriptor(iconUrl.toString()));
}
@@ -126,7 +126,7 @@ public class BuildConsole extends AbstractConsole {
if (background == null) {
return;
}
- } else if (fBackground.equals(background)){
+ } else if (fBackground.equals(background)) {
return;
}
Color old = fBackground;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java
index f65ba3403d2..0aada30fe4d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java
@@ -19,7 +19,7 @@ import org.eclipse.jface.text.Document;
public class BuildConsoleDocument extends Document {
public BuildConsoleDocument() {
- setTextStore(new ConsoleOutputTextStore(2500));
+ setTextStore(new ConsoleOutputTextStore(2500));
setLineTracker(new DefaultLineTracker());
completeInitialization();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java
index 796d135bbb7..fb00b87b86e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java
@@ -27,7 +27,7 @@ public class BuildConsoleFactory implements IConsoleFactory {
public void openConsole() {
IBuildConsoleManager manager = CUIPlugin.getDefault().getConsoleManager();
if (manager instanceof BuildConsoleManager) {
- ((BuildConsoleManager)manager).showConsole(true);
+ ((BuildConsoleManager) manager).showConsole(true);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java
index c4b2bbe12cd..52661ce9a3f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java
@@ -130,8 +130,9 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
*/
protected void startConsoleActivity(IProject project) {
if (!listeners.isEmpty()) {
- for (IBuildConsoleListener listener: listeners) {
- ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project, IBuildConsoleEvent.CONSOLE_START);
+ for (IBuildConsoleListener listener : listeners) {
+ ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project,
+ IBuildConsoleEvent.CONSOLE_START);
listener.consoleChange(event);
}
}
@@ -165,9 +166,9 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
}
if (consoleView instanceof IConsoleView) {
if (BuildConsole.getCurrentPage() == null)
- ((IConsoleView)consoleView).display(fConsole);
+ ((IConsoleView) consoleView).display(fConsole);
else
- ((IConsoleView)consoleView).display(BuildConsole.getCurrentPage().getConsole());
+ ((IConsoleView) consoleView).display(BuildConsole.getCurrentPage().getConsole());
}
}
}
@@ -176,7 +177,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
boolean shouldBringToTop(IViewPart consoleView) {
boolean bringToTop = false;
if (consoleView instanceof IConsoleView) {
- IConsoleView cView = (IConsoleView)consoleView;
+ IConsoleView cView = (IConsoleView) consoleView;
return !cView.isPinned() && BuildConsolePreferencePage.isConsoleOnTop();
}
return bringToTop;
@@ -192,13 +193,15 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
public void resourceChanged(IResourceChangeEvent event) {
IResource resource = event.getResource();
if (resource != null && resource.getType() == IResource.PROJECT) {
- if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
+ if (event.getType() == IResourceChangeEvent.PRE_DELETE
+ || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
IDocumentPartitioner partioner = fConsoleMap.remove(resource);
if (partioner != null) {
partioner.disconnect();
if (!listeners.isEmpty()) {
for (IBuildConsoleListener listener : listeners) {
- ConsoleEvent consoleEvent = new ConsoleEvent(this, (IProject)resource, IBuildConsoleEvent.CONSOLE_CLOSE);
+ ConsoleEvent consoleEvent = new ConsoleEvent(this, (IProject) resource,
+ IBuildConsoleEvent.CONSOLE_CLOSE);
listener.consoleChange(consoleEvent);
}
}
@@ -221,7 +224,8 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
problemInfoBackgroundColor.dispose();
problemHighlightedColor.dispose();
}
- ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new org.eclipse.ui.console.IConsole[]{fConsole});
+ ConsolePlugin.getDefault().getConsoleManager()
+ .removeConsoles(new org.eclipse.ui.console.IConsole[] { fConsole });
CUIPlugin.getWorkspace().removeResourceChangeListener(this);
CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
}
@@ -286,23 +290,32 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
public void run() {
// add console to the Console view
fConsole = createBuildConsole(fName, fContextMenuId, iconUrl);
- ConsolePlugin.getDefault().getConsoleManager().addConsoles(new org.eclipse.ui.console.IConsole[]{fConsole});
+ ConsolePlugin.getDefault().getConsoleManager()
+ .addConsoles(new org.eclipse.ui.console.IConsole[] { fConsole });
infoStream.setConsole(fConsole);
- infoColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
+ infoColor = createColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
infoStream.setColor(infoColor);
outputStream.setConsole(fConsole);
- outputColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
+ outputColor = createColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
outputStream.setColor(outputColor);
errorStream.setConsole(fConsole);
- errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
+ errorColor = createColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
errorStream.setColor(errorColor);
- backgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
+ backgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
fConsole.setBackground(backgroundColor);
- problemHighlightedColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
- problemErrorBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
- problemWarningBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
- problemInfoBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
+ problemHighlightedColor = createColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
+ problemErrorBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
+ problemWarningBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
+ problemInfoBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
}
});
CUIPlugin.getWorkspace().addResourceChangeListener(this);
@@ -319,42 +332,50 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
String property = event.getProperty();
// colors
if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR)) {
- Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
+ Color newColor = createColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
infoStream.setColor(newColor);
infoColor.dispose();
infoColor = newColor;
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR)) {
- Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
+ Color newColor = createColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
outputStream.setColor(newColor);
outputColor.dispose();
outputColor = newColor;
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR)) {
- Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
+ Color newColor = createColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
errorStream.setColor(newColor);
errorColor.dispose();
errorColor = newColor;
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR)) {
- Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
+ Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
fConsole.setBackground(newColor);
backgroundColor.dispose();
backgroundColor = newColor;
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR)) {
- Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
+ Color newColor = createColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
problemHighlightedColor.dispose();
problemHighlightedColor = newColor;
redrawTextViewer();
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR)) {
- Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
+ Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
problemErrorBackgroundColor.dispose();
problemErrorBackgroundColor = newColor;
redrawTextViewer();
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR)) {
- Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
+ Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
problemWarningBackgroundColor.dispose();
problemWarningBackgroundColor = newColor;
redrawTextViewer();
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR)) {
- Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
+ Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(),
+ BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
problemInfoBackgroundColor.dispose();
problemInfoBackgroundColor = newColor;
redrawTextViewer();
@@ -363,9 +384,11 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
private void redrawTextViewer() {
final BuildConsolePage p = BuildConsole.getCurrentPage();
- if ( p == null ) return;
+ if (p == null)
+ return;
final BuildConsoleViewer v = p.getViewer();
- if ( v == null ) return;
+ if (v == null)
+ return;
Display display = Display.getDefault();
display.asyncExec(new Runnable() {
@Override
@@ -377,12 +400,12 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
public IBuildConsoleStreamDecorator getStreamDecorator(int type) throws CoreException {
switch (type) {
- case BUILD_STREAM_TYPE_ERROR :
- return errorStream;
- case BUILD_STREAM_TYPE_INFO :
- return infoStream;
- case BUILD_STREAM_TYPE_OUTPUT :
- return outputStream;
+ case BUILD_STREAM_TYPE_ERROR:
+ return errorStream;
+ case BUILD_STREAM_TYPE_INFO:
+ return infoStream;
+ case BUILD_STREAM_TYPE_OUTPUT:
+ return outputStream;
}
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, "No Such Console", null)); //$NON-NLS-1$
}
@@ -426,7 +449,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
*/
@Override
public IConsole getProjectConsole(IProject project) {
- if (project==null || !project.isAccessible())
+ if (project == null || !project.isAccessible())
return null;
fLastProject = project;
@@ -487,7 +510,8 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
* @param project to get default log location for, can't be {@code null}.
*/
public String getDefaultConsoleLogLocation(IProject project) {
- IPath defaultLogLocation = CUIPlugin.getDefault().getStateLocation().append(project.getName() + PROJECT_LOG_EXT);
+ IPath defaultLogLocation = CUIPlugin.getDefault().getStateLocation()
+ .append(project.getName() + PROJECT_LOG_EXT);
return defaultLogLocation.toOSString();
}
@@ -500,7 +524,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
public URI getLogURI(IProject project) {
Assert.isNotNull(project);
- if (fContextMenuId!=DEFAULT_CONTEXT_MENU_ID)
+ if (fContextMenuId != DEFAULT_CONTEXT_MENU_ID)
return null;
URI logURI = null;
@@ -510,11 +534,12 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
if (keepLog) {
String strLocation;
strLocation = prefs.get(KEY_LOG_LOCATION, getDefaultConsoleLogLocation(project));
- if (strLocation.trim().length()>0) {
+ if (strLocation.trim().length() > 0) {
logURI = URIUtil.toURI(strLocation);
}
- if (logURI==null) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,"Can't determine URI for location=["+strLocation+"]"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (logURI == null) {
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+ "Can't determine URI for location=[" + strLocation + "]"); //$NON-NLS-1$ //$NON-NLS-2$
CUIPlugin.log(status);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
index 424d08e99ab..58030ef05b6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
@@ -98,12 +98,7 @@ import org.eclipse.cdt.ui.IBuildConsoleManager;
import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
public class BuildConsolePage extends Page
- implements
- ISelectionListener,
- IPropertyChangeListener,
- IBuildConsoleListener,
- ITextListener,
- IAdaptable {
+ implements ISelectionListener, IPropertyChangeListener, IBuildConsoleListener, ITextListener, IAdaptable {
static final int POSITION_NEXT = -1;
static final int POSITION_PREV = -2;
@@ -144,8 +139,7 @@ public class BuildConsolePage extends Page
* @param console
* @param contextId
*/
- public BuildConsolePage(IConsoleView view, BuildConsole console,
- String contextId) {
+ public BuildConsolePage(IConsoleView view, BuildConsole console, String contextId) {
fConsole = console;
fConsoleView = view;
fContextMenuId = contextId;
@@ -173,7 +167,7 @@ public class BuildConsolePage extends Page
IConsole console = consoleManager.getProjectConsole(project);
getViewer().setDocument(document);
if (console instanceof BuildConsolePartitioner) {
- BuildConsolePartitioner par = (BuildConsolePartitioner)console;
+ BuildConsolePartitioner par = (BuildConsolePartitioner) console;
// Show the error, but don't show it in the editor if we are viewing the global console.
// Prevents showing errors in the editor for projects other than the current project.
showError(par, fShowErrorAction.isChecked() && !(getConsole() instanceof GlobalBuildConsole));
@@ -184,7 +178,8 @@ public class BuildConsolePage extends Page
@Override
public void consoleChange(final IBuildConsoleEvent event) {
- if (event.getType() == IBuildConsoleEvent.CONSOLE_START || event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE) {
+ if (event.getType() == IBuildConsoleEvent.CONSOLE_START
+ || event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE) {
Control control = getControl();
if (control != null && !control.isDisposed()) {
Display display = control.getDisplay();
@@ -198,7 +193,8 @@ public class BuildConsolePage extends Page
@Override
public void run() {
if (isAvailable()) {
- if (event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE && getProject() != event.getProject()) {
+ if (event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE
+ && getProject() != event.getProject()) {
return;
}
setProject(event.getProject());
@@ -246,7 +242,8 @@ public class BuildConsolePage extends Page
JFaceResources.getFontRegistry().addListener(this);
setFont(JFaceResources.getFont(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT));
- setTabs(CUIPlugin.getDefault().getPreferenceStore().getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
+ setTabs(CUIPlugin.getDefault().getPreferenceStore()
+ .getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
getConsole().addPropertyChangeListener(this);
CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
@@ -284,7 +281,7 @@ public class BuildConsolePage extends Page
final String property = event.getProperty();
if (BuildConsole.P_STREAM_COLOR.equals(property) && source instanceof IBuildConsoleStreamDecorator) {
- IBuildConsoleStreamDecorator stream = (IBuildConsoleStreamDecorator)source;
+ IBuildConsoleStreamDecorator stream = (IBuildConsoleStreamDecorator) source;
if (stream.getConsole().equals(getConsole()) && getControl() != null) {
Display display = getControl().getDisplay();
display.asyncExec(new Runnable() {
@@ -298,7 +295,8 @@ public class BuildConsolePage extends Page
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT)) {
setFont(JFaceResources.getFont(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT));
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH)) {
- setTabs(CUIPlugin.getDefault().getPreferenceStore().getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
+ setTabs(CUIPlugin.getDefault().getPreferenceStore()
+ .getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
} else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) {
fViewer.getTextWidget().setBackground(fConsole.getBackground());
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_WRAP_LINES)
@@ -324,17 +322,18 @@ public class BuildConsolePage extends Page
// each action
IActionBars actionBars = getSite().getActionBars();
TextViewerAction action = new TextViewerAction(getViewer(), ITextOperationTarget.COPY);
- action.configureAction(ConsoleMessages.BuildConsolePage__Copy_Ctrl_C_6,
- ConsoleMessages.BuildConsolePage_Copy_7, ConsoleMessages.BuildConsolePage_Copy_7);
- action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- action.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
- ISharedImages.IMG_TOOL_COPY_DISABLED));
- action.setHoverImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ action.configureAction(ConsoleMessages.BuildConsolePage__Copy_Ctrl_C_6, ConsoleMessages.BuildConsolePage_Copy_7,
+ ConsoleMessages.BuildConsolePage_Copy_7);
+ action.setImageDescriptor(
+ PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ action.setDisabledImageDescriptor(
+ PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
+ action.setHoverImageDescriptor(
+ PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
setGlobalAction(actionBars, ActionFactory.COPY.getId(), action);
action = new TextViewerAction(getViewer(), ITextOperationTarget.SELECT_ALL);
action.configureAction(ConsoleMessages.BuildConsolePage_Select__All_Ctrl_A_12,
- ConsoleMessages.BuildConsolePage_Select_All,
- ConsoleMessages.BuildConsolePage_Select_All);
+ ConsoleMessages.BuildConsolePage_Select_All, ConsoleMessages.BuildConsolePage_Select_All);
setGlobalAction(actionBars, ActionFactory.SELECT_ALL.getId(), action);
//XXX Still using "old" resource access
ResourceBundle bundle = ResourceBundle.getBundle(ConsoleMessages.BUNDLE_NAME);
@@ -357,7 +356,7 @@ public class BuildConsolePage extends Page
protected void updateAction(String actionId) {
IAction action = fGlobalActions.get(actionId);
if (action instanceof IUpdate) {
- ((IUpdate)action).update();
+ ((IUpdate) action).update();
}
}
@@ -412,16 +411,16 @@ public class BuildConsolePage extends Page
protected void setInitialSelection() {
// Use the selection, if any
- IWorkbenchPage page= getSite().getPage();
- ISelection selection= null;
+ IWorkbenchPage page = getSite().getPage();
+ ISelection selection = null;
if (page != null)
- selection= page.getSelection();
+ selection = page.getSelection();
if (convertSelectionToProject(selection) == null) {
if (selection instanceof ITextSelection) {
- Object part= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
+ Object part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
if (part instanceof IEditorPart) {
- if (setSelectionFromEditor((IEditorPart)part) == true)
+ if (setSelectionFromEditor((IEditorPart) part) == true)
return;
}
}
@@ -435,14 +434,14 @@ public class BuildConsolePage extends Page
boolean setSelectionFromEditor(IEditorPart part) {
if (part == null)
return false;
- IWorkbenchPartSite site= part.getSite();
+ IWorkbenchPartSite site = part.getSite();
if (site == null)
return false;
- ISelectionProvider provider= site.getSelectionProvider();
- if (provider != null ) {
- IEditorInput ei= part.getEditorInput();
+ ISelectionProvider provider = site.getSelectionProvider();
+ if (provider != null) {
+ IEditorInput ei = part.getEditorInput();
if (ei instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)ei).getFile();
+ IFile file = ((IFileEditorInput) ei).getFile();
selectionChanged(part, new StructuredSelection(file));
return true;
}
@@ -463,16 +462,16 @@ public class BuildConsolePage extends Page
IProject convertSelectionToProject(ISelection selection) {
IProject project = null;
- if (selection == null || ! (selection instanceof IStructuredSelection)) {
+ if (selection == null || !(selection instanceof IStructuredSelection)) {
return project;
}
- IStructuredSelection ssel = (IStructuredSelection)selection;
+ IStructuredSelection ssel = (IStructuredSelection) selection;
Object element = ssel.getFirstElement();
if (element instanceof IAdaptable) {
- IAdaptable input = (IAdaptable)element;
+ IAdaptable input = (IAdaptable) element;
IResource resource = null;
if (input instanceof IResource) {
- resource = (IResource)input;
+ resource = (IResource) input;
} else {
resource = input.getAdapter(IResource.class);
}
@@ -549,12 +548,12 @@ public class BuildConsolePage extends Page
if (Widget.class.equals(required)) {
return (T) getViewer().getTextWidget();
}
-// if (IShowInSource.class.equals(required)) {
-// return this;
-// }
-// if (IShowInTargetList.class.equals(required)) {
-// return this;
-// }
+ // if (IShowInSource.class.equals(required)) {
+ // return this;
+ // }
+ // if (IShowInTargetList.class.equals(required)) {
+ // return this;
+ // }
return null;
}
@@ -566,7 +565,7 @@ public class BuildConsolePage extends Page
@Override
public void textChanged(TextEvent event) {
// update the find replace action if the document length is > 0
- IUpdate findReplace = (IUpdate)fGlobalActions.get(ActionFactory.FIND.getId());
+ IUpdate findReplace = (IUpdate) fGlobalActions.get(ActionFactory.FIND.getId());
if (findReplace != null) {
findReplace.update();
}
@@ -586,21 +585,22 @@ public class BuildConsolePage extends Page
*/
void moveToError(int position) {
IConsole console = getCurrentConsole();
- if (console == null) return;
+ if (console == null)
+ return;
if (console instanceof BuildConsolePartitioner) {
- BuildConsolePartitioner par = (BuildConsolePartitioner)console;
+ BuildConsolePartitioner par = (BuildConsolePartitioner) console;
BuildConsolePartition oldPartition = par.fDocumentMarkerManager.getCurrentPartition();
// Move to specified line in the model (BuildConsolePartitioner)
- if ( position == POSITION_NEXT ) {
+ if (position == POSITION_NEXT) {
par.fDocumentMarkerManager.moveToNextError();
- } else if ( position == POSITION_PREV ) {
+ } else if (position == POSITION_PREV) {
par.fDocumentMarkerManager.moveToPreviousError();
- } else if ( position == POSITION_FIST ) {
+ } else if (position == POSITION_FIST) {
par.fDocumentMarkerManager.moveToFirstError();
- } else if ( position >= 0 ) {
- if ( ! par.fDocumentMarkerManager.moveToErrorByOffset(position) ) {
+ } else if (position >= 0) {
+ if (!par.fDocumentMarkerManager.moveToErrorByOffset(position)) {
// we haven't moved, because offset points to non-error partition
return;
}
@@ -608,7 +608,7 @@ public class BuildConsolePage extends Page
if (oldPartition != null) {
getViewer().deselectPartition(par, oldPartition);
}
- showError(par, position > 0 || fShowErrorAction.isChecked() );
+ showError(par, position > 0 || fShowErrorAction.isChecked());
}
}
@@ -618,12 +618,13 @@ public class BuildConsolePage extends Page
public void showError(BuildConsolePartitioner par, boolean openInEditor) {
// Highlight current error
BuildConsolePartition p = par.fDocumentMarkerManager.getCurrentPartition();
- if ( p == null ) return;
+ if (p == null)
+ return;
getViewer().selectPartition(par, p);
// Show error in editor if necessary
// (always show when absolute positioning, otherwise depends
// on fShowErrorAction state)
- if ( openInEditor ) {
+ if (openInEditor) {
openErrorInEditor(par.fDocumentMarkerManager.getCurrentErrorMarker());
}
}
@@ -634,10 +635,12 @@ public class BuildConsolePage extends Page
public static void openErrorInEditor(ProblemMarkerInfo marker) {
IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
- if ( marker == null || marker.file == null || window == null ) return;
+ if (marker == null || marker.file == null || window == null)
+ return;
IWorkbenchPage page = window.getActivePage();
- if (page == null) return;
+ if (page == null)
+ return;
IEditorPart editor = page.getActiveEditor();
if (editor != null) {
@@ -648,14 +651,15 @@ public class BuildConsolePage extends Page
}
}
- if ( marker.file instanceof IFile ) {
+ if (marker.file instanceof IFile) {
try {
// Find IMarker corresponding to ProblemMarkerInfo
- IMarker mrkrs[] = marker.file.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE);
- for (IMarker m: mrkrs) {
- if ( marker.lineNumber == ((Integer)m.getAttribute(IMarker.LINE_NUMBER)).intValue() &&
- marker.description.equals(m.getAttribute(IMarker.MESSAGE)) &&
- marker.severity == ((Integer)m.getAttribute(IMarker.SEVERITY)).intValue() ) {
+ IMarker mrkrs[] = marker.file.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true,
+ IResource.DEPTH_ONE);
+ for (IMarker m : mrkrs) {
+ if (marker.lineNumber == ((Integer) m.getAttribute(IMarker.LINE_NUMBER)).intValue()
+ && marker.description.equals(m.getAttribute(IMarker.MESSAGE))
+ && marker.severity == ((Integer) m.getAttribute(IMarker.SEVERITY)).intValue()) {
IDE.openEditor(page, m, OpenStrategy.activateOnOpen());
return;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java
index ae8fc78036b..1ac9b87462f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java
@@ -31,7 +31,7 @@ public class BuildConsolePageParticipant implements IConsolePageParticipant {
@Override
public void init(IPageBookViewPage page, IConsole console) {
- this.console = (BuildConsole)console;
+ this.console = (BuildConsole) console;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java
index 5ebc7eea419..84b91073c2c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java
@@ -66,7 +66,7 @@ public class BuildConsolePartitioner
/**
* Active list of partitions, must only be accessed form UI thread which
* provides implicit lock.
- *
+ *
* The partitions are required to be sorted, and the partitions must not have
* any gaps. (The Offset + Length of partition N must equals the Offset of
* partition N + 1.)
@@ -499,20 +499,17 @@ public class BuildConsolePartitioner
@Override
public ConsoleOutputStream getOutputStream() throws CoreException {
- return new BuildOutputStream(this,
- fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_OUTPUT));
+ return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_OUTPUT));
}
@Override
public ConsoleOutputStream getInfoStream() throws CoreException {
- return new BuildOutputStream(this,
- fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_INFO));
+ return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_INFO));
}
@Override
public ConsoleOutputStream getErrorStream() throws CoreException {
- return new BuildOutputStream(this,
- fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_ERROR));
+ return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_ERROR));
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java
index 7eca7d2cbdb..d6f9fa6ea88 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java
@@ -58,7 +58,7 @@ public class BuildConsolePartitionerEditData {
* All the streams that have been written to since the last update.
*/
List<IBuildConsoleStreamDecorator> getStreamsNeedingNotifcation();
-
+
/**
* True if partitions with problem markers have been added since the last
* update.
@@ -104,14 +104,13 @@ public class BuildConsolePartitionerEditData {
* Set of streams that have been updated since the last UI update.
*/
private Set<IBuildConsoleStreamDecorator> fEditStreams = new HashSet<>();
-
+
/**
* True if partitions with problem markers have been added since the last UI
* update.
*/
private boolean fEditProblemsAdded = false;
-
public BuildConsolePartitionerEditData(int maxLines) {
fMaxLines = maxLines;
}
@@ -138,7 +137,7 @@ public class BuildConsolePartitionerEditData {
}
/**
- *
+ *
* Adds the new text to the document.
*
* @param text
@@ -148,7 +147,7 @@ public class BuildConsolePartitionerEditData {
* @param marker
* the marker associated with this line of console output, can be
* <code>null</code>
- *
+ *
*/
public void append(String text, IBuildConsoleStreamDecorator stream, ProblemMarkerInfo marker) {
int newlines = (int) text.chars().filter(ch -> ch == '\n').count();
@@ -170,8 +169,8 @@ public class BuildConsolePartitionerEditData {
fEditProblemsAdded = true;
}
if (fEditPartitions.isEmpty()) {
- fEditPartitions.add(new BuildConsolePartition(stream, fEditStringBuilder.length(),
- text.length(), partitionType, marker, newlines));
+ fEditPartitions.add(new BuildConsolePartition(stream, fEditStringBuilder.length(), text.length(),
+ partitionType, marker, newlines));
} else {
int index = fEditPartitions.size() - 1;
BuildConsolePartition last = fEditPartitions.get(index);
@@ -184,8 +183,7 @@ public class BuildConsolePartitionerEditData {
* number of lines of the whole document, this significantly
* simplifies the logic of checkOverflow.
*/
- canBeCombined = canBeCombined
- && (fMaxLines <= 0 || (last.getNewlines() + newlines < fMaxLines));
+ canBeCombined = canBeCombined && (fMaxLines <= 0 || (last.getNewlines() + newlines < fMaxLines));
/*
* Don't permit different partition types to be combined
*/
@@ -200,9 +198,8 @@ public class BuildConsolePartitionerEditData {
int combinedOffset = last.getOffset();
int combinedLength = last.getLength() + text.length();
int combinedNewlines = last.getNewlines() + newlines;
- BuildConsolePartition partition2 = new BuildConsolePartition(last.getStream(),
- combinedOffset, combinedLength, BuildConsolePartition.CONSOLE_PARTITION_TYPE,
- null, combinedNewlines);
+ BuildConsolePartition partition2 = new BuildConsolePartition(last.getStream(), combinedOffset,
+ combinedLength, BuildConsolePartition.CONSOLE_PARTITION_TYPE, null, combinedNewlines);
fEditPartitions.set(index, partition2);
} else {
// different kinds - add a new parition
@@ -312,7 +309,7 @@ public class BuildConsolePartitionerEditData {
* Obtain the next snapshot of data. This update must be processed by the
* UI. i.e. don't call this method unless you are going to handle the update
* now.
- *
+ *
* @return see {@link UpdateUIData} for details on individual values
* returned.
*/
@@ -362,7 +359,7 @@ public class BuildConsolePartitionerEditData {
public long getOffset() {
return newOffset;
}
-
+
@Override
public boolean hasProblemsAdded() {
return problemsAdded;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java
index dd7de4d40f6..17f66c0c379 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java
@@ -24,7 +24,7 @@ public class BuildConsoleStreamDecorator implements IBuildConsoleStreamDecorator
/**
* Constructs a new stream connected to the given console.
- *
+ *
*/
public BuildConsoleStreamDecorator() {
}
@@ -35,7 +35,7 @@ public class BuildConsoleStreamDecorator implements IBuildConsoleStreamDecorator
/**
* Sets the color of this message stream
- *
+ *
* @param color
* color of this message stream, possibly <code>null</code>
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java
index 66d900d9237..7b145962b56 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java
@@ -38,16 +38,14 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.cdt.ui.CUIPlugin;
public class BuildConsoleViewer extends TextViewer
- implements LineStyleListener,
- LineBackgroundListener,
- MouseTrackListener,
- MouseListener {
+ implements LineStyleListener, LineBackgroundListener, MouseTrackListener, MouseListener {
protected InternalDocumentListener fInternalDocumentListener = new InternalDocumentListener();
/**
* Whether the console scrolls as output is appended.
*/
private boolean fAutoScroll = true;
+
/**
* Internal document listener.
*/
@@ -55,6 +53,7 @@ public class BuildConsoleViewer extends TextViewer
@Override
public void documentAboutToBeChanged(DocumentEvent e) {
}
+
@Override
public void documentChanged(DocumentEvent e) {
revealEndOfDocument();
@@ -158,26 +157,30 @@ public class BuildConsoleViewer extends TextViewer
@Override
public void lineGetStyle(LineStyleEvent event) {
IDocument document = getDocument();
- if (document == null) return;
+ if (document == null)
+ return;
BuildConsolePartitioner partitioner = (BuildConsolePartitioner) document.getDocumentPartitioner();
- if (partitioner == null) return;
+ if (partitioner == null)
+ return;
BuildConsolePartition p = partitioner.fDocumentMarkerManager.getCurrentPartition();
- Color problemHighlightedColor = partitioner.fManager.getProblemHighlightedColor();
+ Color problemHighlightedColor = partitioner.fManager.getProblemHighlightedColor();
// Note, computePartitioning actually doesn't change anything in partitioning,
// but only computes number of affected regions.
- List<BuildConsolePartition> regions = partitioner.computePartitioningAsList(event.lineOffset, event.lineText.length());
+ List<BuildConsolePartition> regions = partitioner.computePartitioningAsList(event.lineOffset,
+ event.lineText.length());
StyleRange[] styles = new StyleRange[regions.size()];
for (int i = 0; i < regions.size(); i++) {
BuildConsolePartition partition = regions.get(i);
- if (partition.getStream()== null) return;
+ if (partition.getStream() == null)
+ return;
Color colorFG = partition.getStream().getColor();
Color colorBG = null;
// Highlight current partition
- if ( partition == p ) {
+ if (partition == p) {
colorFG = problemHighlightedColor;
}
StyleRange styleRange = new StyleRange(partition.getOffset(), partition.getLength(), colorFG, colorBG);
@@ -199,22 +202,22 @@ public class BuildConsoleViewer extends TextViewer
if (st != null) {
try {
int start = partitioner.getDocument().getLineOfOffset(p.getOffset());
- int end = partitioner.getDocument().getLineOfOffset(p.getOffset()+p.getLength()-1);
-
- if ( fAutoScroll ) {
+ int end = partitioner.getDocument().getLineOfOffset(p.getOffset() + p.getLength() - 1);
+
+ if (fAutoScroll) {
// Check if area around this line is visible, scroll if needed
int top = getTopIndex();
int bottom = getBottomIndex();
- if ( start < top + 1 ) {
+ if (start < top + 1) {
setTopIndex(start - 1 > 0 ? start - 1 : 0);
- } else if ( end > bottom -1 ) {
+ } else if (end > bottom - 1) {
setTopIndex(top + start - bottom + 1);
}
}
-
+
// Select line
st.redrawRange(p.getOffset(), p.getLength(), false);
-
+
} catch (BadLocationException e) {
CUIPlugin.log(e);
}
@@ -266,19 +269,21 @@ public class BuildConsoleViewer extends TextViewer
@Override
public void lineGetBackground(LineBackgroundEvent event) {
IDocument document = getDocument();
- if (document == null) return;
+ if (document == null)
+ return;
BuildConsolePartitioner partitioner = (BuildConsolePartitioner) document.getDocumentPartitioner();
- if (partitioner == null) return;
+ if (partitioner == null)
+ return;
BuildConsolePartition partition = (BuildConsolePartition) partitioner.getPartition(event.lineOffset);
// Set background for error partitions
- if (partition!=null) {
+ if (partition != null) {
String type = partition.getType();
- if (type==BuildConsolePartition.ERROR_PARTITION_TYPE) {
+ if (type == BuildConsolePartition.ERROR_PARTITION_TYPE) {
event.lineBackground = partitioner.fManager.getProblemBackgroundColor();
- } else if (type==BuildConsolePartition.WARNING_PARTITION_TYPE) {
+ } else if (type == BuildConsolePartition.WARNING_PARTITION_TYPE) {
event.lineBackground = partitioner.fManager.getWarningBackgroundColor();
- } else if (type==BuildConsolePartition.INFO_PARTITION_TYPE) {
+ } else if (type == BuildConsolePartition.INFO_PARTITION_TYPE) {
event.lineBackground = partitioner.fManager.getInfoBackgroundColor();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java
index a9eecdbb5d8..5c21a53a21c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java
@@ -32,8 +32,7 @@ public class BuildOutputStream extends ConsoleOutputStream implements IErrorMark
final IBuildConsoleStreamDecorator fStream;
private BuildConsolePartitioner fPartitioner;
- public BuildOutputStream(BuildConsolePartitioner partitioner,
- IBuildConsoleStreamDecorator stream) {
+ public BuildOutputStream(BuildConsolePartitioner partitioner, IBuildConsoleStreamDecorator stream) {
fPartitioner = partitioner;
if (fPartitioner.getProject() == null)
// Note: The global console log stream should have been
@@ -68,5 +67,5 @@ public class BuildOutputStream extends ConsoleOutputStream implements IErrorMark
public synchronized void write(String msg) throws IOException {
fPartitioner.appendToDocument(msg, fStream, null);
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java
index 3c0c7e4efc7..ae087f04fd6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java
@@ -40,7 +40,7 @@ public class CBuildConsole implements ICConsole {
@Override
public void init(String contextId, String name, URL iconUrl) {
- if (contextId==null)
+ if (contextId == null)
fConsoleManager = CUIPlugin.getDefault().getConsoleManager();
else
fConsoleManager = CUIPlugin.getDefault().getConsoleManager(name, contextId, iconUrl); // careful with order of arguments
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java
index f445d6b6ef3..2e024f9e8a8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java
@@ -58,8 +58,8 @@ public class CopyBuildLogAction extends Action {
Shell shell = Display.getCurrent().getActiveShell();
if (console instanceof BuildConsolePartitioner) {
- URI srcURI = ((BuildConsolePartitioner)console).getLogURI();
- if (srcURI==null) {
+ URI srcURI = ((BuildConsolePartitioner) console).getLogURI();
+ if (srcURI == null) {
MessageDialog.openWarning(shell, ConsoleMessages.CopyLog_UnavailableLog,
ConsoleMessages.CopyLog_BuildNotLogged);
return;
@@ -71,14 +71,14 @@ public class CopyBuildLogAction extends Action {
} catch (CoreException e) {
CUIPlugin.log(e);
MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
- ConsoleMessages.CopyLog_UnableToAccess+srcURI);
+ ConsoleMessages.CopyLog_UnableToAccess + srcURI);
return;
}
if (!srcStore.fetchInfo().exists()) {
MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
ConsoleMessages.CopyLog_LogFileIsNotAvailable);
- return;
+ return;
}
// open file dialog
@@ -86,11 +86,11 @@ public class CopyBuildLogAction extends Action {
dialog.setText(ConsoleMessages.CopyLog_ChooseDestination);
String destLocation = dialog.open();
- if (destLocation!=null) {
+ if (destLocation != null) {
URI destURI = URIUtil.toURI(destLocation);
- if (destURI==null) {
+ if (destURI == null) {
MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
- ConsoleMessages.CopyLog_InvalidDestination+destLocation);
+ ConsoleMessages.CopyLog_InvalidDestination + destLocation);
return;
}
try {
@@ -99,7 +99,7 @@ public class CopyBuildLogAction extends Action {
} catch (CoreException e) {
CUIPlugin.log(e);
MessageDialog.openError(shell, ConsoleMessages.CopyLog_ErrorCopyingFile,
- ConsoleMessages.CopyLog_ErrorWhileCopyingLog+e.getLocalizedMessage());
+ ConsoleMessages.CopyLog_ErrorWhileCopyingLog + e.getLocalizedMessage());
} finally {
ResourcesUtil.refreshWorkspaceFiles(destURI);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java
index 9471b906e93..7911b42073a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java
@@ -19,30 +19,31 @@ import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.cdt.core.ProblemMarkerInfo;
/**
- * Manages current position of highlighted error in BuildConsole
+ * Manages current position of highlighted error in BuildConsole
*/
class DocumentMarkerManager {
-
- BuildConsoleDocument fDocument;
+
+ BuildConsoleDocument fDocument;
BuildConsolePartitioner fPartitioner;
-
+
int highlightedPartitionIndex = -1;
-
+
DocumentMarkerManager(BuildConsoleDocument document, BuildConsolePartitioner partitioner) {
fDocument = document;
fPartitioner = partitioner;
}
/** Increment index */
- void moveToNextError() {
- if ( fPartitioner.fPartitions.size() == 0 ) return;
- if ( highlightedPartitionIndex == -1 ) {
+ void moveToNextError() {
+ if (fPartitioner.fPartitions.size() == 0)
+ return;
+ if (highlightedPartitionIndex == -1) {
moveToFirstError();
return;
}
- int i = highlightedPartitionIndex + 1;
+ int i = highlightedPartitionIndex + 1;
do {
- if ( i == fPartitioner.fPartitions.size() ) {
+ if (i == fPartitioner.fPartitions.size()) {
i = 0;
}
String type = fPartitioner.fPartitions.get(i).getType();
@@ -52,20 +53,21 @@ class DocumentMarkerManager {
} else {
i++;
}
- } while ( highlightedPartitionIndex != i);
+ } while (highlightedPartitionIndex != i);
}
-
+
/** Decrement index */
- void moveToPreviousError() {
- if ( fPartitioner.fPartitions.size() == 0 ) return;
- if ( highlightedPartitionIndex == -1 ) {
+ void moveToPreviousError() {
+ if (fPartitioner.fPartitions.size() == 0)
+ return;
+ if (highlightedPartitionIndex == -1) {
moveToFirstError();
return;
}
-
- int i = highlightedPartitionIndex - 1;
+
+ int i = highlightedPartitionIndex - 1;
do {
- if ( i == -1 ) {
+ if (i == -1) {
i = fPartitioner.fPartitions.size() - 1;
}
String type = fPartitioner.fPartitions.get(i).getType();
@@ -75,15 +77,15 @@ class DocumentMarkerManager {
} else {
i--;
}
- } while ( highlightedPartitionIndex != i);
+ } while (highlightedPartitionIndex != i);
}
-
+
void moveToFirstError() {
- for (int i=0; i<fPartitioner.fPartitions.size(); i++) {
+ for (int i = 0; i < fPartitioner.fPartitions.size(); i++) {
String type = fPartitioner.fPartitions.get(i).getType();
if (BuildConsolePartition.isProblemPartitionType(type)) {
highlightedPartitionIndex = i;
- return;
+ return;
}
}
highlightedPartitionIndex = -1;
@@ -103,7 +105,7 @@ class DocumentMarkerManager {
/** Get marker for current error */
ProblemMarkerInfo getCurrentErrorMarker() {
BuildConsolePartition p = getCurrentPartition();
- if ( p != null ) {
+ if (p != null) {
return p.getMarker();
} else {
return null;
@@ -112,15 +114,14 @@ class DocumentMarkerManager {
/** Get partition for current error */
BuildConsolePartition getCurrentPartition() {
- if ( 0 <= highlightedPartitionIndex &&
- highlightedPartitionIndex < fPartitioner.fPartitions.size() ) {
+ if (0 <= highlightedPartitionIndex && highlightedPartitionIndex < fPartitioner.fPartitions.size()) {
BuildConsolePartition p = fPartitioner.fPartitions.get(highlightedPartitionIndex);
return p;
}
return null;
- }
-
+ }
+
void clear() {
- highlightedPartitionIndex = -1;
+ highlightedPartitionIndex = -1;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java
index 552099a335a..c057165ef19 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java
@@ -9,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Jeff Johnston (Red Hat Inc.), Andrew Gvozdev - initial implementation
+ * Jeff Johnston (Red Hat Inc.), Andrew Gvozdev - initial implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.buildconsole;
@@ -46,7 +46,7 @@ public class GlobalBuildConsoleManager extends BuildConsoleManager {
/** Singleton instance */
private static GlobalBuildConsoleManager INSTANCE = null;
private static BuildConsolePartitioner fGlobalConsolePartitioner = null;
-
+
/**
* Default constructor is private. The only instance will be created on
* access of static methods and assigned to {@link #INSTANCE}.
@@ -60,22 +60,21 @@ public class GlobalBuildConsoleManager extends BuildConsoleManager {
* @return get instance creating one if necessary.
*/
private static GlobalBuildConsoleManager getInstance() {
- if (INSTANCE==null)
+ if (INSTANCE == null)
INSTANCE = new GlobalBuildConsoleManager();
return INSTANCE;
}
-
+
/**
* @return get global console partitioner creating one if necessary.
*/
private static BuildConsolePartitioner getConsolePartitioner() {
- if (fGlobalConsolePartitioner==null) {
+ if (fGlobalConsolePartitioner == null) {
fGlobalConsolePartitioner = new BuildConsolePartitioner(getInstance());
}
return fGlobalConsolePartitioner;
}
-
-
+
/**
* Start the console. This will call {@link #startup(String, String, URL)}
* to add the global console to the Console view.
@@ -84,16 +83,16 @@ public class GlobalBuildConsoleManager extends BuildConsoleManager {
// instantiate the INSTANCE
getInstance();
}
-
+
/**
* Stop the console and deallocate resources allocated during {@link #startup()}
*/
public static void stop() {
// avoid initializing INSTANCE needlessly during shutdown
- if (INSTANCE!=null)
+ if (INSTANCE != null)
INSTANCE.shutdown();
}
-
+
@Override
protected BuildConsole createBuildConsole(String name, String contextId, final URL iconUrl) {
return new GlobalBuildConsole(this, name, contextId, iconUrl);
@@ -180,11 +179,12 @@ public class GlobalBuildConsoleManager extends BuildConsoleManager {
boolean keepLog = prefs.getBoolean(KEY_KEEP_LOG, CONSOLE_KEEP_LOG_DEFAULT);
if (keepLog) {
String strLocation = prefs.get(KEY_LOG_LOCATION, getDefaultConsoleLogLocation());
- if (strLocation.trim().length()>0) {
+ if (strLocation.trim().length() > 0) {
logURI = URIUtil.toURI(strLocation);
}
- if (logURI==null) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,"Can't determine URI for location=["+strLocation+"]"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (logURI == null) {
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+ "Can't determine URI for location=[" + strLocation + "]"); //$NON-NLS-1$ //$NON-NLS-2$
CUIPlugin.log(status);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/IBuildConsoleStreamDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/IBuildConsoleStreamDecorator.java
index 34016f56983..f635a8a81c9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/IBuildConsoleStreamDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/IBuildConsoleStreamDecorator.java
@@ -21,14 +21,14 @@ public interface IBuildConsoleStreamDecorator {
/**
* Returns the color of this message stream, or <code>null</code> if
* default.
- *
+ *
* @return the color of this message stream, or <code>null</code>
*/
Color getColor();
/**
* Returns the console this stream is connected to.
- *
+ *
* @return the console this stream is connected to
*/
IConsole getConsole();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java
index 9b0f96295ec..69584fc1339 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java
@@ -33,7 +33,7 @@ class MultiBuildConsoleAdapter implements IConsole {
private final IConsole fProjectConsole;
private final IConsole fGlobalConsole;
- private static class BuildOutputStreamAdapter extends ConsoleOutputStream implements IErrorMarkeredOutputStream {
+ private static class BuildOutputStreamAdapter extends ConsoleOutputStream implements IErrorMarkeredOutputStream {
private final BuildOutputStream one;
private final BuildOutputStream two;
@@ -53,18 +53,18 @@ class MultiBuildConsoleAdapter implements IConsole {
two.write(c);
}
- @Override
+ @Override
public synchronized void write(byte[] b, int off, int len) throws IOException {
one.write(b, off, len);
two.write(b, off, len);
- }
-
- @Override
- public synchronized void write(String msg) throws IOException {
- one.write(msg);
- two.write(msg);
- }
-
+ }
+
+ @Override
+ public synchronized void write(String msg) throws IOException {
+ one.write(msg);
+ two.write(msg);
+ }
+
@Override
public void write(String s, ProblemMarkerInfo marker) throws IOException {
one.write(s, marker);
@@ -76,7 +76,7 @@ class MultiBuildConsoleAdapter implements IConsole {
one.flush();
two.flush();
}
-
+
@Override
public void close() throws IOException {
one.flush();
@@ -99,17 +99,20 @@ class MultiBuildConsoleAdapter implements IConsole {
@Override
public ConsoleOutputStream getOutputStream() throws CoreException {
- return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getOutputStream(), (BuildOutputStream)fGlobalConsole.getOutputStream());
+ return new BuildOutputStreamAdapter((BuildOutputStream) fProjectConsole.getOutputStream(),
+ (BuildOutputStream) fGlobalConsole.getOutputStream());
}
@Override
public ConsoleOutputStream getInfoStream() throws CoreException {
- return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getInfoStream(), (BuildOutputStream)fGlobalConsole.getInfoStream());
+ return new BuildOutputStreamAdapter((BuildOutputStream) fProjectConsole.getInfoStream(),
+ (BuildOutputStream) fGlobalConsole.getInfoStream());
}
@Override
public ConsoleOutputStream getErrorStream() throws CoreException {
- return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getErrorStream(), (BuildOutputStream)fGlobalConsole.getErrorStream());
+ return new BuildOutputStreamAdapter((BuildOutputStream) fProjectConsole.getErrorStream(),
+ (BuildOutputStream) fGlobalConsole.getErrorStream());
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java
index 8b84db19260..74d5e65dd00 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java
@@ -26,10 +26,10 @@ public class NextErrorAction extends Action {
private BuildConsolePage fConsolePage;
public NextErrorAction(BuildConsolePage page) {
- super(ConsoleMessages.NextErrorAction_Tooltip);
+ super(ConsoleMessages.NextErrorAction_Tooltip);
fConsolePage = page;
setEnabled(true);
- setToolTipText(ConsoleMessages.NextErrorAction_Tooltip);
+ setToolTipText(ConsoleMessages.NextErrorAction_Tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java
index afe85de44e1..973242b4ac9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java
@@ -27,10 +27,10 @@ public class PreviousErrorAction extends Action {
private BuildConsolePage fConsolePage;
public PreviousErrorAction(BuildConsolePage page) {
- super(ConsoleMessages.PreviousErrorAction_Tooltip);
+ super(ConsoleMessages.PreviousErrorAction_Tooltip);
fConsolePage = page;
setEnabled(true);
- setToolTipText(ConsoleMessages.PreviousErrorAction_Tooltip);
+ setToolTipText(ConsoleMessages.PreviousErrorAction_Tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java
index cf4410e073a..66b15a14886 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java
@@ -25,9 +25,9 @@ public class ScrollLockAction extends Action {
private BuildConsoleViewer fConsoleViewer;
public ScrollLockAction(BuildConsoleViewer viewer) {
- super(ConsoleMessages.ScrollLockAction_Scroll_Lock_1);
+ super(ConsoleMessages.ScrollLockAction_Scroll_Lock_1);
fConsoleViewer = viewer;
- setToolTipText(ConsoleMessages.ScrollLockAction_Scroll_Lock_1);
+ setToolTipText(ConsoleMessages.ScrollLockAction_Scroll_Lock_1);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SCROLL_LOCK);
setChecked(false);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java
index b5261197fe0..264fc099c3f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java
@@ -29,13 +29,13 @@ import org.eclipse.cdt.ui.IBuildConsoleManager;
public class ShowErrorAction extends Action {
private BuildConsolePage fConsolePage;
-
+
public ShowErrorAction(BuildConsolePage page) {
- super(ConsoleMessages.ShowErrorAction_Tooltip);
+ super(ConsoleMessages.ShowErrorAction_Tooltip);
fConsolePage = page;
setChecked(true);
- setToolTipText(ConsoleMessages.ShowErrorAction_Tooltip);
- ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
+ setToolTipText(ConsoleMessages.ShowErrorAction_Tooltip);
+ ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED_DISABLED));
}
@@ -51,10 +51,10 @@ public class ShowErrorAction extends Action {
IProject project = fConsolePage.getProject();
IConsole console = consoleManager.getProjectConsole(project);
if (console instanceof BuildConsolePartitioner) {
- BuildConsolePartitioner par = (BuildConsolePartitioner)console;
+ BuildConsolePartitioner par = (BuildConsolePartitioner) console;
fConsolePage.showError(par, true);
}
}
- }
-
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java
index 99b2e5173d4..86dbacec26d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java
@@ -28,15 +28,15 @@ public class WrapLinesAction extends Action {
/**
* Constructor.
- *
+ *
* @param viewer - console viewer.
*/
public WrapLinesAction(BuildConsoleViewer viewer) {
- super(ConsoleMessages.WrapLinesAction_WrapLines);
+ super(ConsoleMessages.WrapLinesAction_WrapLines);
fConsoleViewer = viewer;
propertyChange();
setToolTipText(ConsoleMessages.WrapLinesAction_WrapLines);
- setImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_WRAP_LINE));
+ setImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_WRAP_LINE));
}
public void propertyChange() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java
index 2619252a415..2aca12762ea 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.ArrayList;
@@ -24,15 +24,15 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
public class CElementSet {
- private Set<ICElement> fSet= new LinkedHashSet<ICElement>();
+ private Set<ICElement> fSet = new LinkedHashSet<ICElement>();
private int fHashCode;
-
- CElementSet( ICElement[] elements) {
+
+ CElementSet(ICElement[] elements) {
fSet.addAll(Arrays.asList(elements));
- fHashCode= 0;
- for (int i = 0; i < elements.length; i++) {
- fHashCode = 31*fHashCode + elements[i].hashCode();
- }
+ fHashCode = 0;
+ for (int i = 0; i < elements.length; i++) {
+ fHashCode = 31 * fHashCode + elements[i].hashCode();
+ }
}
@Override
@@ -63,8 +63,8 @@ public class CElementSet {
if (fSet.size() != other.fSet.size()) {
return false;
}
- for (Iterator<ICElement> iter = fSet.iterator(); iter.hasNext(); ) {
- if (!other.fSet.contains(iter.next())) {
+ for (Iterator<ICElement> iter = fSet.iterator(); iter.hasNext();) {
+ if (!other.fSet.contains(iter.next())) {
return false;
}
}
@@ -77,8 +77,8 @@ public class CElementSet {
}
public ICElement[] getElements(WorkingSetFilterUI filter) {
- ArrayList<ICElement> result= new ArrayList<ICElement>(fSet.size());
- for (Iterator<ICElement> iter = fSet.iterator(); iter.hasNext(); ) {
+ ArrayList<ICElement> result = new ArrayList<ICElement>(fSet.size());
+ for (Iterator<ICElement> iter = fSet.iterator(); iter.hasNext();) {
ICElement element = iter.next();
if (filter == null || filter.isPartOfWorkingSet(element)) {
result.add(element);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
index 255d7aa7cb8..53bef61d515 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
@@ -60,7 +60,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
*/
public CHContentProvider(CHViewPart view, Display disp) {
super(disp);
- fView= view;
+ fView = view;
}
@Override
@@ -107,7 +107,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
}
if (parentElement instanceof ICHENode) {
- return asyncComputeRoot(((ICHENode)parentElement).getRepresentedDeclaration());
+ return asyncComputeRoot(((ICHENode) parentElement).getRepresentedDeclaration());
}
if (parentElement instanceof ICElement) {
@@ -130,14 +130,14 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
private Object[] asyncComputeRoot(final ICElement input) throws CoreException, InterruptedException {
- IIndex index= CCorePlugin.getIndexManager().getIndex(input.getCProject(), CallHierarchyUI.INDEX_SEARCH_OPTION);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(input.getCProject(), CallHierarchyUI.INDEX_SEARCH_OPTION);
index.acquireReadLock();
try {
- ICElement element= input;
- if (CHQueries.isExternal(element)) {
- ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
- return new Object[] { new CHNode(null, tu, 0, element, -1) };
- }
+ ICElement element = input;
+ if (CHQueries.isExternal(element)) {
+ ITranslationUnit tu = CModelUtil.getTranslationUnit(element);
+ return new Object[] { new CHNode(null, tu, 0, element, -1) };
+ }
if (!IndexUI.isIndexed(index, input)) {
getDisplay().asyncExec(new Runnable() {
@@ -147,8 +147,8 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
});
} else {
- element= IndexUI.attemptConvertionToHandle(index, input);
- final ICElement finalElement= element;
+ element = IndexUI.attemptConvertionToHandle(index, input);
+ final ICElement finalElement = element;
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
@@ -156,15 +156,16 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
});
}
- ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
+ ITranslationUnit tu = CModelUtil.getTranslationUnit(element);
if (!fComputeReferencedBy && element instanceof IMethod) {
- IIndexName methodName= IndexUI.elementToName(index, element);
+ IIndexName methodName = IndexUI.elementToName(index, element);
if (methodName != null) {
- IBinding methodBinding= index.findBinding(methodName);
+ IBinding methodBinding = index.findBinding(methodName);
if (methodBinding instanceof ICPPMethod) {
- ICElement[] defs= CHQueries.findOverriders(index, (ICPPMethod) methodBinding);
+ ICElement[] defs = CHQueries.findOverriders(index, (ICPPMethod) methodBinding);
if (defs != null && defs.length > 0) {
- return new Object[] { new CHMultiDefNode(null, tu, 0, defs, methodBinding.getLinkage().getLinkageID()) };
+ return new Object[] {
+ new CHMultiDefNode(null, tu, 0, defs, methodBinding.getLinkage().getLinkageID()) };
}
}
}
@@ -176,8 +177,9 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
private Object[] asyncronouslyComputeReferencedBy(CHNode parent) throws CoreException, InterruptedException {
- ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY);
+ ICProject[] scope = CoreModel.getDefault().getCModel().getCProjects();
+ IIndex index = CCorePlugin.getIndexManager().getIndex(scope,
+ IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY);
index.acquireReadLock();
try {
return CHQueries.findCalledBy(this, parent, index, NPM);
@@ -187,8 +189,9 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
private Object[] asyncronouslyComputeRefersTo(CHNode parent) throws CoreException, InterruptedException {
- ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY);
+ ICProject[] scope = CoreModel.getDefault().getCModel().getCProjects();
+ IIndex index = CCorePlugin.getIndexManager().getIndex(scope,
+ IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY);
index.acquireReadLock();
try {
return CHQueries.findCalls(this, parent, index, NPM);
@@ -206,17 +209,17 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
public void setWorkingSetFilter(WorkingSetFilterUI filterUI) {
- fFilter= filterUI;
+ fFilter = filterUI;
recompute();
}
CHNode[] createNodes(CHNode node, CalledByResult result) throws CoreException {
- ArrayList<CHNode> nodes= new ArrayList<CHNode>();
- ICElement[] elements= result.getElements();
+ ArrayList<CHNode> nodes = new ArrayList<CHNode>();
+ ICElement[] elements = result.getElements();
for (ICElement element : elements) {
if (element != null) {
if (fFilter == null || fFilter.isPartOfWorkingSet(element)) {
- IIndexName[] refs= result.getReferences(element);
+ IIndexName[] refs = result.getReferences(element);
if (refs != null && refs.length > 0) {
CHNode newNode = createRefbyNode(node, element, refs);
nodes.add(newNode);
@@ -228,18 +231,18 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
private CHNode createRefbyNode(CHNode parent, ICElement element, IIndexName[] refs) throws CoreException {
- ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
+ ITranslationUnit tu = CModelUtil.getTranslationUnit(element);
final IIndexFile file = refs[0].getFile();
- CHNode node= new CHNode(parent, tu, file.getTimestamp(), element, file.getLinkageID());
+ CHNode node = new CHNode(parent, tu, file.getTimestamp(), element, file.getLinkageID());
if (element instanceof IVariable || element instanceof IEnumerator) {
node.setInitializer(true);
}
- boolean readAccess= false;
- boolean writeAccess= false;
+ boolean readAccess = false;
+ boolean writeAccess = false;
for (IIndexName reference : refs) {
node.addReference(new CHReferenceInfo(reference.getNodeOffset(), reference.getNodeLength()));
- readAccess= (readAccess || reference.isReadAccess());
- writeAccess= (writeAccess || reference.isWriteAccess());
+ readAccess = (readAccess || reference.isReadAccess());
+ writeAccess = (writeAccess || reference.isWriteAccess());
}
node.setRWAccess(readAccess, writeAccess);
node.sortReferencesByOffset();
@@ -247,14 +250,14 @@ public class CHContentProvider extends AsyncTreeContentProvider {
}
CHNode[] createNodes(CHNode node, CallsToResult callsTo) throws CoreException {
- ITranslationUnit tu= CModelUtil.getTranslationUnit(node.getRepresentedDeclaration());
- ArrayList<CHNode> result= new ArrayList<CHNode>();
- CElementSet[] elementSets= callsTo.getElementSets();
+ ITranslationUnit tu = CModelUtil.getTranslationUnit(node.getRepresentedDeclaration());
+ ArrayList<CHNode> result = new ArrayList<CHNode>();
+ CElementSet[] elementSets = callsTo.getElementSets();
for (CElementSet elementSet : elementSets) {
CElementSet set = elementSet;
if (!set.isEmpty()) {
- IIndexName[] refs= callsTo.getReferences(set);
- ICElement[] elements= set.getElements(fFilter);
+ IIndexName[] refs = callsTo.getReferences(set);
+ ICElement[] elements = set.getElements(fFilter);
if (elements.length > 0) {
CHNode childNode = createReftoNode(node, tu, elements, refs);
result.add(childNode);
@@ -264,26 +267,27 @@ public class CHContentProvider extends AsyncTreeContentProvider {
return result.toArray(new CHNode[result.size()]);
}
- private CHNode createReftoNode(CHNode parent, ITranslationUnit tu, ICElement[] elements, IIndexName[] references) throws CoreException {
+ private CHNode createReftoNode(CHNode parent, ITranslationUnit tu, ICElement[] elements, IIndexName[] references)
+ throws CoreException {
assert elements.length > 0;
final IIndexFile file = references[0].getFile();
- final long timestamp= file.getTimestamp();
- final int linkageID= file.getLinkageID();
+ final long timestamp = file.getTimestamp();
+ final int linkageID = file.getLinkageID();
CHNode node;
if (elements.length == 1) {
- node= new CHNode(parent, tu, timestamp, elements[0], linkageID);
+ node = new CHNode(parent, tu, timestamp, elements[0], linkageID);
} else {
- node= new CHMultiDefNode(parent, tu, timestamp, elements, linkageID);
+ node = new CHMultiDefNode(parent, tu, timestamp, elements, linkageID);
}
- boolean readAccess= false;
- boolean writeAccess= false;
+ boolean readAccess = false;
+ boolean writeAccess = false;
for (IIndexName reference : references) {
node.addReference(new CHReferenceInfo(reference.getNodeOffset(), reference.getNodeLength()));
- readAccess= (readAccess || reference.isReadAccess());
- writeAccess= (writeAccess || reference.isWriteAccess());
+ readAccess = (readAccess || reference.isReadAccess());
+ writeAccess = (writeAccess || reference.isWriteAccess());
}
node.sortReferencesByOffset();
node.setRWAccess(readAccess, writeAccess);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java
index d0b9f3633d0..f3446877c4e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.Iterator;
@@ -27,35 +27,35 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.cdt.core.model.ICElement;
public class CHDropTargetListener implements DropTargetListener {
- private CHViewPart fCallHierarchy;
+ private CHViewPart fCallHierarchy;
private ICElement fInput;
- private boolean fEnabled= true;
+ private boolean fEnabled = true;
- public CHDropTargetListener(CHViewPart view) {
- fCallHierarchy= view;
- }
-
- public void setEnabled(boolean val) {
- fEnabled= val;
- }
-
- @Override
+ public CHDropTargetListener(CHViewPart view) {
+ fCallHierarchy = view;
+ }
+
+ public void setEnabled(boolean val) {
+ fEnabled = val;
+ }
+
+ @Override
public void dragEnter(DropTargetEvent event) {
- fInput= null;
- checkOperation(event);
- if (event.detail != DND.DROP_NONE) {
+ fInput = null;
+ checkOperation(event);
+ if (event.detail != DND.DROP_NONE) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
- fInput= checkLocalSelection();
+ fInput = checkLocalSelection();
if (!CallHierarchyUI.isRelevantForCallHierarchy(fInput)) {
- event.detail= DND.DROP_NONE;
- fInput= null;
+ event.detail = DND.DROP_NONE;
+ fInput = null;
}
- }
- }
- }
+ }
+ }
+ }
private ICElement checkLocalSelection() {
- ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
+ ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
if (sel instanceof IStructuredSelection) {
for (Iterator<?> iter = ((IStructuredSelection) sel).iterator(); iter.hasNext();) {
Object element = iter.next();
@@ -63,7 +63,7 @@ public class CHDropTargetListener implements DropTargetListener {
return (ICElement) element;
}
if (element instanceof IAdaptable) {
- ICElement adapter= ((IAdaptable) element).getAdapter(ICElement.class);
+ ICElement adapter = ((IAdaptable) element).getAdapter(ICElement.class);
if (adapter != null) {
return adapter;
}
@@ -73,37 +73,37 @@ public class CHDropTargetListener implements DropTargetListener {
return null;
}
- @Override
+ @Override
public void dragLeave(DropTargetEvent event) {
- }
+ }
- @Override
+ @Override
public void dragOperationChanged(DropTargetEvent event) {
- checkOperation(event);
- }
+ checkOperation(event);
+ }
- @Override
+ @Override
public void dragOver(DropTargetEvent event) {
- }
+ }
- @Override
+ @Override
public void drop(DropTargetEvent event) {
- if (fInput == null) {
- Display.getCurrent().beep();
- } else {
- fCallHierarchy.setInput(fInput);
- }
- }
+ if (fInput == null) {
+ Display.getCurrent().beep();
+ } else {
+ fCallHierarchy.setInput(fInput);
+ }
+ }
- @Override
+ @Override
public void dropAccept(DropTargetEvent event) {
- }
-
- private void checkOperation(DropTargetEvent event) {
- if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
- event.detail= DND.DROP_COPY;
- } else {
- event.detail= DND.DROP_NONE;
- }
- }
+ }
+
+ private void checkOperation(DropTargetEvent event) {
+ if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
+ event.detail = DND.DROP_COPY;
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java
index 36c332792c5..9a72c9ee2a2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java
@@ -33,18 +33,18 @@ import org.eclipse.cdt.ui.ICHEContentProvider;
public class CHEProviderSettings {
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CCallHierarchy"; //$NON-NLS-1$
- private static final String ELEMENT_NAME_CONTENT = "CallHierarchyContentProvider"; //$NON-NLS-1$
- private static final String ELEMENT_NAME_LABEL = "CallHierarchyLabelProvider"; //$NON-NLS-1$
- private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$
+ private static final String ELEMENT_NAME_CONTENT = "CallHierarchyContentProvider"; //$NON-NLS-1$
+ private static final String ELEMENT_NAME_LABEL = "CallHierarchyLabelProvider"; //$NON-NLS-1$
+ private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$
- IOpenListener[] openListeners =null;
+ IOpenListener[] openListeners = null;
static ICHEContentProvider[] chContentProviders = null;
static IStyledLabelProvider[] chLabelProviders = null;
private static void loadExtensions() {
- List<ICHEContentProvider> chCProviders = new ArrayList<ICHEContentProvider>();
- List<IStyledLabelProvider> chLProviders = new ArrayList<IStyledLabelProvider>();
+ List<ICHEContentProvider> chCProviders = new ArrayList<ICHEContentProvider>();
+ List<IStyledLabelProvider> chLProviders = new ArrayList<IStyledLabelProvider>();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
if (extensionPoint != null) {
@@ -82,17 +82,15 @@ public class CHEProviderSettings {
chContentProviders = chCProviders.toArray(new ICHEContentProvider[chCProviders.size()]);
}
-
-
public static IStyledLabelProvider[] getCCallHierarchyLabelProviders() {
- if ( chLabelProviders == null) {
+ if (chLabelProviders == null) {
loadExtensions();
}
return chLabelProviders;
}
public static ICHEContentProvider[] getCCallHierarchyContentProviders() {
- if ( chContentProviders == null) {
+ if (chContentProviders == null) {
loadExtensions();
}
return chContentProviders;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java
index 3be45bb48cf..4df91219c46 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java
@@ -26,28 +26,25 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
* Action used for the include browser forward / backward buttons
*/
public class CHHistoryAction extends Action {
- final static long LABEL_OPTIONS=
- CElementLabels.M_PARAMETER_TYPES |
- CElementLabels.ALL_FULLY_QUALIFIED |
- CElementLabels.TEMPLATE_ARGUMENTS |
- CElementLabels.MF_POST_FILE_QUALIFIED;
+ final static long LABEL_OPTIONS = CElementLabels.M_PARAMETER_TYPES | CElementLabels.ALL_FULLY_QUALIFIED
+ | CElementLabels.TEMPLATE_ARGUMENTS | CElementLabels.MF_POST_FILE_QUALIFIED;
private CHViewPart fViewPart;
private ICElement fElement;
public CHHistoryAction(CHViewPart viewPart, ICElement element) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- fViewPart= viewPart;
- fElement= element;
-
- String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS);
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+ fViewPart = viewPart;
+ fElement = element;
+
+ String elementName = CElementLabels.getElementLabel(element, LABEL_OPTIONS);
setText(elementName);
setImageDescriptor(getImageDescriptor(element));
}
private ImageDescriptor getImageDescriptor(ICElement elem) {
- CElementImageProvider imageProvider= new CElementImageProvider();
- ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
+ CElementImageProvider imageProvider = new CElementImageProvider();
+ ImageDescriptor desc = imageProvider.getBaseImageDescriptor(elem, 0);
imageProvider.dispose();
return desc;
}
@@ -55,5 +52,5 @@ public class CHHistoryAction extends Action {
@Override
public void run() {
fViewPart.setInput(fElement);
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java
index f2f3b37f4e5..6f786e1a093 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java
@@ -27,15 +27,16 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.CPluginImages;
public class CHHistoryDropDownAction extends Action implements IMenuCreator {
-
+
public static class ClearHistoryAction extends Action {
-
+
private CHViewPart fView;
+
public ClearHistoryAction(CHViewPart view) {
super(CHMessages.CHHistoryDropDownAction_ClearHistory_label);
- fView= view;
+ fView = view;
}
-
+
@Override
public void run() {
CallHierarchyUI.clearHistory();
@@ -43,15 +44,15 @@ public class CHHistoryDropDownAction extends Action implements IMenuCreator {
}
}
- public static final int RESULTS_IN_DROP_DOWN= 10;
+ public static final int RESULTS_IN_DROP_DOWN = 10;
private CHViewPart fHierarchyView;
private Menu fMenu;
-
+
public CHHistoryDropDownAction(CHViewPart view) {
- fHierarchyView= view;
- fMenu= null;
- setToolTipText(CHMessages.CHHistoryDropDownAction_ShowHistoryList_tooltip);
+ fHierarchyView = view;
+ fMenu = null;
+ setToolTipText(CHMessages.CHHistoryDropDownAction_ShowHistoryList_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
setMenuCreator(this);
}
@@ -61,7 +62,7 @@ public class CHHistoryDropDownAction extends Action implements IMenuCreator {
// action is reused, can be called several times.
if (fMenu != null) {
fMenu.dispose();
- fMenu= null;
+ fMenu = null;
}
}
@@ -75,33 +76,31 @@ public class CHHistoryDropDownAction extends Action implements IMenuCreator {
if (fMenu != null) {
fMenu.dispose();
}
- fMenu= new Menu(parent);
- ICElement[] elements= CallHierarchyUI.getHistoryEntries();
+ fMenu = new Menu(parent);
+ ICElement[] elements = CallHierarchyUI.getHistoryEntries();
addEntries(fMenu, elements);
new MenuItem(fMenu, SWT.SEPARATOR);
addActionToMenu(fMenu, new CHHistoryListAction(fHierarchyView));
addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
return fMenu;
}
-
+
private boolean addEntries(Menu menu, ICElement[] elements) {
- boolean checked= false;
-
- int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
- for (int i= 0; i < min; i++) {
- CHHistoryAction action= new CHHistoryAction(fHierarchyView, elements[i]);
+ boolean checked = false;
+
+ int min = Math.min(elements.length, RESULTS_IN_DROP_DOWN);
+ for (int i = 0; i < min; i++) {
+ CHHistoryAction action = new CHHistoryAction(fHierarchyView, elements[i]);
action.setChecked(elements[i].equals(fHierarchyView.getInput()));
- checked= checked || action.isChecked();
+ checked = checked || action.isChecked();
addActionToMenu(menu, action);
}
-
-
+
return checked;
}
-
protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
+ ActionContributionItem item = new ActionContributionItem(action);
item.fill(parent, -1);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java
index 7cdb372d00a..18bc20e93d6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java
@@ -41,68 +41,68 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class CHHistoryListAction extends Action {
-
+
private class HistoryListDialog extends StatusDialog {
private ListDialogField<ICElement> fHistoryList;
private IStatus fHistoryStatus;
private ICElement fResult;
-
+
private HistoryListDialog(Shell shell, ICElement[] historyEntries) {
super(shell);
- setHelpAvailable(false);
- setTitle(CHMessages.CHHistoryListAction_HistoryDialog_title);
- String[] buttonLabels= new String[] {
- CHMessages.CHHistoryListAction_Remove_label,
- };
-
- IListAdapter<ICElement> adapter= new IListAdapter<ICElement>() {
+ setHelpAvailable(false);
+ setTitle(CHMessages.CHHistoryListAction_HistoryDialog_title);
+ String[] buttonLabels = new String[] { CHMessages.CHHistoryListAction_Remove_label, };
+
+ IListAdapter<ICElement> adapter = new IListAdapter<ICElement>() {
@Override
public void customButtonPressed(ListDialogField<ICElement> field, int index) {
doCustomButtonPressed();
}
+
@Override
public void selectionChanged(ListDialogField<ICElement> field) {
doSelectionChanged();
}
-
+
@Override
public void doubleClicked(ListDialogField<ICElement> field) {
doDoubleClicked();
- }
+ }
};
-
- ILabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
-
- fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
- fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label);
+
+ ILabelProvider labelProvider = new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS,
+ CElementImageProvider.OVERLAY_ICONS);
+
+ fHistoryList = new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
+ fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label);
fHistoryList.setElements(Arrays.asList(historyEntries));
-
+
ISelection sel;
if (historyEntries.length > 0) {
- sel= new StructuredSelection(historyEntries[0]);
+ sel = new StructuredSelection(historyEntries[0]);
} else {
- sel= new StructuredSelection();
+ sel = new StructuredSelection();
}
-
+
fHistoryList.selectElements(sel);
}
-
+
@Override
protected Control createDialogArea(Composite parent) {
initializeDialogUnits(parent);
-
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
+
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Composite inner = new Composite(composite, SWT.NONE);
inner.setFont(parent.getFont());
-
+
inner.setLayoutData(new GridData(GridData.FILL_BOTH));
LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null), true);
- applyDialogFont(composite);
+ applyDialogFont(composite);
return composite;
}
@@ -112,7 +112,7 @@ public class CHHistoryListAction extends Action {
private void doCustomButtonPressed() {
fHistoryList.removeElements(fHistoryList.getSelectedElements());
}
-
+
private void doDoubleClicked() {
if (fHistoryStatus.isOK()) {
okPressed();
@@ -120,32 +120,32 @@ public class CHHistoryListAction extends Action {
}
private void doSelectionChanged() {
- StatusInfo status= new StatusInfo();
- List<ICElement> selected= fHistoryList.getSelectedElements();
+ StatusInfo status = new StatusInfo();
+ List<ICElement> selected = fHistoryList.getSelectedElements();
if (selected.size() != 1) {
status.setError(""); //$NON-NLS-1$
- fResult= null;
+ fResult = null;
} else {
- fResult= selected.get(0);
+ fResult = selected.get(0);
}
- fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
- fHistoryStatus= status;
- updateStatus(status);
+ fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
+ fHistoryStatus = status;
+ updateStatus(status);
}
-
+
public ICElement getResult() {
return fResult;
}
-
+
public ICElement[] getRemaining() {
- List<ICElement> elems= fHistoryList.getElements();
+ List<ICElement> elems = fHistoryList.getElements();
return elems.toArray(new ICElement[elems.size()]);
- }
-
+ }
+
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
}
@Override
@@ -154,22 +154,21 @@ public class CHHistoryListAction extends Action {
super.create();
}
}
-
+
private CHViewPart fView;
-
+
public CHHistoryListAction(CHViewPart view) {
- fView= view;
- setText(CHMessages.CHHistoryListAction_OpenHistory_label);
+ fView = view;
+ setText(CHMessages.CHHistoryListAction_OpenHistory_label);
}
-
+
@Override
public void run() {
- ICElement[] historyEntries= CallHierarchyUI.getHistoryEntries();
- HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
+ ICElement[] historyEntries = CallHierarchyUI.getHistoryEntries();
+ HistoryListDialog dialog = new HistoryListDialog(fView.getSite().getShell(), historyEntries);
if (dialog.open() == Window.OK) {
CallHierarchyUI.setHistoryEntries(dialog.getRemaining());
fView.setInput(dialog.getResult());
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
index 561739b1106..7e90ad7c99c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
@@ -40,216 +40,219 @@ import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
public class CHLabelProvider extends AppearanceAwareLabelProvider {
private final static long LABEL_OPTIONS_SIMPLE = CElementLabels.ALL_FULLY_QUALIFIED
- | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.TEMPLATE_ARGUMENTS;
- private final static long LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED;
+ | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE
+ | CElementLabels.TEMPLATE_ARGUMENTS;
+ private final static long LABEL_OPTIONS_SHOW_FILES = LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED;
- private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, CElementImageProvider.OVERLAY_ICONS);
- private CHContentProvider fContentProvider;
- private HashMap<String, Image> fCachedImages= new HashMap<String, Image>();
+ private CUILabelProvider fCLabelProvider = new CUILabelProvider(LABEL_OPTIONS_SIMPLE,
+ CElementImageProvider.OVERLAY_ICONS);
+ private CHContentProvider fContentProvider;
+ private HashMap<String, Image> fCachedImages = new HashMap<String, Image>();
private Color fColorInactive;
private IStyledLabelProvider[] fProviders;
private CHViewPart fView;
- public CHLabelProvider(CHViewPart view, Display display, CHContentProvider cp) {
- fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
- fContentProvider= cp;
- fView = view;
- }
+ public CHLabelProvider(CHViewPart view, Display display, CHContentProvider cp) {
+ fColorInactive = display.getSystemColor(SWT.COLOR_DARK_GRAY);
+ fContentProvider = cp;
+ fView = view;
+ }
- @Override
+ @Override
public Image getImage(Object element) {
- if (fProviders == null ) {
+ if (fProviders == null) {
fProviders = fView.getLabelProviders();
}
- if ( fProviders != null ) {
+ if (fProviders != null) {
for (IStyledLabelProvider provider : fProviders) {
Image img = provider.getImage(element);
if (img != null)
return img;
}
}
- if (element instanceof CHNode) {
- CHNode node= (CHNode) element;
- Image image= null;
- if (node.isInitializer()) {
- ImageDescriptor desc= CElementImageProvider.getFunctionImageDescriptor();
- image= CUIPlugin.getImageDescriptorRegistry().get(desc);
- } else {
- ICElement decl= node.getOneRepresentedDeclaration();
- if (decl != null) {
- image= fCLabelProvider.getImage(decl);
- }
- }
- if (image != null) {
- return decorateImage(image, node);
- }
- }
- return super.getImage(element);
- }
-
- @Override
+ if (element instanceof CHNode) {
+ CHNode node = (CHNode) element;
+ Image image = null;
+ if (node.isInitializer()) {
+ ImageDescriptor desc = CElementImageProvider.getFunctionImageDescriptor();
+ image = CUIPlugin.getImageDescriptorRegistry().get(desc);
+ } else {
+ ICElement decl = node.getOneRepresentedDeclaration();
+ if (decl != null) {
+ image = fCLabelProvider.getImage(decl);
+ }
+ }
+ if (image != null) {
+ return decorateImage(image, node);
+ }
+ }
+ return super.getImage(element);
+ }
+
+ @Override
public String getText(Object element) {
- if (element instanceof CHNode) {
- CHNode node= (CHNode) element;
- ICElement decl= node.getOneRepresentedDeclaration();
- if (decl != null) {
- String label;
- if (node.isMultiDef()) {
- long options= fCLabelProvider.getTextFlags();
- fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
- label= fCLabelProvider.getText(decl);
- fCLabelProvider.setTextFlags(options);
- } else {
- label= fCLabelProvider.getText(decl);
- if (node.isInitializer()) {
- label= addInitializerDecoration(label);
- }
- }
- int refCount= node.getReferenceCount();
- if (refCount > 1) {
- label += NLS.bind(" ({0} {1})", Integer.valueOf(refCount), CHMessages.CHLabelProvider_matches); //$NON-NLS-1$
- }
- return decorateText(label, element);
- }
- }
- return super.getText(element);
- }
-
- @Override
+ if (element instanceof CHNode) {
+ CHNode node = (CHNode) element;
+ ICElement decl = node.getOneRepresentedDeclaration();
+ if (decl != null) {
+ String label;
+ if (node.isMultiDef()) {
+ long options = fCLabelProvider.getTextFlags();
+ fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
+ label = fCLabelProvider.getText(decl);
+ fCLabelProvider.setTextFlags(options);
+ } else {
+ label = fCLabelProvider.getText(decl);
+ if (node.isInitializer()) {
+ label = addInitializerDecoration(label);
+ }
+ }
+ int refCount = node.getReferenceCount();
+ if (refCount > 1) {
+ label += NLS.bind(" ({0} {1})", Integer.valueOf(refCount), CHMessages.CHLabelProvider_matches); //$NON-NLS-1$
+ }
+ return decorateText(label, element);
+ }
+ }
+ return super.getText(element);
+ }
+
+ @Override
public StyledString getStyledText(Object element) {
- if (fProviders == null ) {
- fProviders = fView.getLabelProviders();
- }
- if (fProviders != null) {
- for (IStyledLabelProvider provider : fProviders) {
- StyledString styledString = provider.getStyledText(element);
- if (styledString != null)
- return styledString;
- }
- }
- if (element instanceof CHNode) {
- CHNode node= (CHNode) element;
- ICElement decl= node.getOneRepresentedDeclaration();
- if (decl != null) {
- StyledString label;
- if (node.isMultiDef()) {
- long options= fCLabelProvider.getTextFlags();
- fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
- label= fCLabelProvider.getStyledText(decl);
- fCLabelProvider.setTextFlags(options);
- } else {
- label= fCLabelProvider.getStyledText(decl);
- if (node.isInitializer()) {
- label= addInitializerDecoration(label);
- }
- }
- int refCount= node.getReferenceCount();
- if (refCount > 1) {
- final int offset= label.length();
- label.append(NLS.bind(" ({0} {1})", Integer.valueOf(refCount), CHMessages.CHLabelProvider_matches)); //$NON-NLS-1$
- label.setStyle(offset, label.length() - offset, StyledString.COUNTER_STYLER);
-
- }
- String decorated= decorateText(label.getString(), element);
- if (decorated != null) {
- return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, label);
- }
- return label;
- }
- }
- return fCLabelProvider.getStyledText(element);
+ if (fProviders == null) {
+ fProviders = fView.getLabelProviders();
+ }
+ if (fProviders != null) {
+ for (IStyledLabelProvider provider : fProviders) {
+ StyledString styledString = provider.getStyledText(element);
+ if (styledString != null)
+ return styledString;
+ }
+ }
+ if (element instanceof CHNode) {
+ CHNode node = (CHNode) element;
+ ICElement decl = node.getOneRepresentedDeclaration();
+ if (decl != null) {
+ StyledString label;
+ if (node.isMultiDef()) {
+ long options = fCLabelProvider.getTextFlags();
+ fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
+ label = fCLabelProvider.getStyledText(decl);
+ fCLabelProvider.setTextFlags(options);
+ } else {
+ label = fCLabelProvider.getStyledText(decl);
+ if (node.isInitializer()) {
+ label = addInitializerDecoration(label);
+ }
+ }
+ int refCount = node.getReferenceCount();
+ if (refCount > 1) {
+ final int offset = label.length();
+ label.append(NLS.bind(" ({0} {1})", Integer.valueOf(refCount), CHMessages.CHLabelProvider_matches)); //$NON-NLS-1$
+ label.setStyle(offset, label.length() - offset, StyledString.COUNTER_STYLER);
+
+ }
+ String decorated = decorateText(label.getString(), element);
+ if (decorated != null) {
+ return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER,
+ label);
+ }
+ return label;
+ }
+ }
+ return fCLabelProvider.getStyledText(element);
}
- private String addInitializerDecoration(String label) {
- int i= 0;
- char[] content= label.toCharArray();
- for (i = 0; i < content.length; i++) {
+ private String addInitializerDecoration(String label) {
+ int i = 0;
+ char[] content = label.toCharArray();
+ for (i = 0; i < content.length; i++) {
char c = content[i];
if (c == '-' || Character.isWhitespace(c)) {
break;
}
}
- StringBuilder buf= new StringBuilder(label.length() + 10);
- buf.append("{init "); //$NON-NLS-1$
- buf.append(content, 0, i);
- buf.append("}()"); //$NON-NLS-1$
- buf.append(content, i, content.length-i);
+ StringBuilder buf = new StringBuilder(label.length() + 10);
+ buf.append("{init "); //$NON-NLS-1$
+ buf.append(content, 0, i);
+ buf.append("}()"); //$NON-NLS-1$
+ buf.append(content, i, content.length - i);
- return buf.toString();
+ return buf.toString();
}
- private StyledString addInitializerDecoration(StyledString label) {
- int i= 0;
- char[] content= label.toString().toCharArray();
- for (i = 0; i < content.length; i++) {
+ private StyledString addInitializerDecoration(StyledString label) {
+ int i = 0;
+ char[] content = label.toString().toCharArray();
+ for (i = 0; i < content.length; i++) {
char c = content[i];
if (c == '-' || Character.isWhitespace(c)) {
break;
}
}
- StyledString label2= new StyledString();
- label2.append("{init "); //$NON-NLS-1$
- i += label2.length();
- label2.append(label);
- label2.insert('}', i++);
- label2.insert('(', i++);
- label2.insert(')', i++);
- label2.setStyle(0, i, null);
- return label2;
+ StyledString label2 = new StyledString();
+ label2.append("{init "); //$NON-NLS-1$
+ i += label2.length();
+ label2.append(label);
+ label2.insert('}', i++);
+ label2.insert('(', i++);
+ label2.insert(')', i++);
+ label2.setStyle(0, i, null);
+ return label2;
}
@Override
public void dispose() {
- fCLabelProvider.dispose();
- for (Image image : fCachedImages.values()) {
- image.dispose();
- }
- fCachedImages.clear();
- super.dispose();
- }
-
- private Image decorateImage(Image image, CHNode node) {
- int flags= 0;
- if (node.isRecursive()) {
- flags |= CElementImageDescriptor.RECURSIVE_RELATION;
- } else if (fContentProvider.hasChildren(node)) {
- if (fContentProvider.getComputeReferencedBy()) {
- flags |= CElementImageDescriptor.REFERENCED_BY;
- } else {
- if (node.isMultiDef()) {
- flags |= CElementImageDescriptor.RELATES_TO_MULTIPLE;
- } else {
- flags |= CElementImageDescriptor.RELATES_TO;
- }
- }
- }
- if (node.isReadAccess()) {
- flags |= CElementImageDescriptor.READ_ACCESS;
- }
- if (node.isWriteAccess()) {
- flags |= CElementImageDescriptor.WRITE_ACCESS;
- }
-
- String key= image.toString()+String.valueOf(flags);
- Image result= fCachedImages.get(key);
- if (result == null) {
- ImageDescriptor desc= new CElementImageDescriptor(
- new ImageImageDescriptor(image), flags, new Point(20,16));
- result= desc.createImage();
- fCachedImages.put(key, result);
- }
- return result;
- }
-
- @Override
+ fCLabelProvider.dispose();
+ for (Image image : fCachedImages.values()) {
+ image.dispose();
+ }
+ fCachedImages.clear();
+ super.dispose();
+ }
+
+ private Image decorateImage(Image image, CHNode node) {
+ int flags = 0;
+ if (node.isRecursive()) {
+ flags |= CElementImageDescriptor.RECURSIVE_RELATION;
+ } else if (fContentProvider.hasChildren(node)) {
+ if (fContentProvider.getComputeReferencedBy()) {
+ flags |= CElementImageDescriptor.REFERENCED_BY;
+ } else {
+ if (node.isMultiDef()) {
+ flags |= CElementImageDescriptor.RELATES_TO_MULTIPLE;
+ } else {
+ flags |= CElementImageDescriptor.RELATES_TO;
+ }
+ }
+ }
+ if (node.isReadAccess()) {
+ flags |= CElementImageDescriptor.READ_ACCESS;
+ }
+ if (node.isWriteAccess()) {
+ flags |= CElementImageDescriptor.WRITE_ACCESS;
+ }
+
+ String key = image.toString() + String.valueOf(flags);
+ Image result = fCachedImages.get(key);
+ if (result == null) {
+ ImageDescriptor desc = new CElementImageDescriptor(new ImageImageDescriptor(image), flags,
+ new Point(20, 16));
+ result = desc.createImage();
+ fCachedImages.put(key, result);
+ }
+ return result;
+ }
+
+ @Override
public Color getForeground(Object element) {
- if (element instanceof CHMultiDefNode) {
- return fColorInactive;
- }
- return null;
- }
+ if (element instanceof CHMultiDefNode) {
+ return fColorInactive;
+ }
+ return null;
+ }
- public void setShowFiles(boolean show) {
+ public void setShowFiles(boolean show) {
fCLabelProvider.setTextFlags(show ? LABEL_OPTIONS_SHOW_FILES : LABEL_OPTIONS_SIMPLE);
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java
index 5eb82ee02f7..ea98f23bc48 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import org.eclipse.cdt.core.model.ICElement;
@@ -21,26 +21,26 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
*/
public class CHMultiDefChildNode extends CHNode {
- public CHMultiDefChildNode(CHMultiDefNode parent, ITranslationUnit fileOfReferences,
- long timestamp, ICElement decl, int linkageID) {
- super(parent, fileOfReferences, timestamp, decl, linkageID);
- }
-
+ public CHMultiDefChildNode(CHMultiDefNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl,
+ int linkageID) {
+ super(parent, fileOfReferences, timestamp, decl, linkageID);
+ }
+
@Override
public int getReferenceCount() {
return getParent().getReferenceCount();
}
-
+
@Override
public CHReferenceInfo getReference(int idx) {
return getParent().getReference(idx);
}
-
+
@Override
public int getFirstReferenceOffset() {
return getParent().getFirstReferenceOffset();
}
-
+
@Override
public void addReference(CHReferenceInfo info) {
assert false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
index 9282b6c1c83..454e8b46e71 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.Objects;
@@ -21,20 +21,19 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
public class CHMultiDefNode extends CHNode {
private CHNode[] fChildren;
- public CHMultiDefNode(CHNode parent, ITranslationUnit tu, long timestamp, ICElement[] elements,
- int linkageID) {
+ public CHMultiDefNode(CHNode parent, ITranslationUnit tu, long timestamp, ICElement[] elements, int linkageID) {
super(parent, tu, timestamp, null, linkageID);
if (elements.length == 0) {
throw new IllegalArgumentException();
}
fHashCode += elements[0].hashCode();
- fChildren= new CHNode[elements.length];
+ fChildren = new CHNode[elements.length];
for (int i = 0; i < elements.length; i++) {
ICElement element = elements[i];
- fChildren[i]= new CHMultiDefChildNode(this, tu, timestamp, element, linkageID);
+ fChildren[i] = new CHMultiDefChildNode(this, tu, timestamp, element, linkageID);
}
}
-
+
public CHNode[] getChildNodes() {
return fChildren;
}
@@ -49,7 +48,6 @@ public class CHMultiDefNode extends CHNode {
return fChildren[0].isVariableOrEnumerator();
}
-
@Override
public ICElement getOneRepresentedDeclaration() {
return fChildren[0].getRepresentedDeclaration();
@@ -59,13 +57,13 @@ public class CHMultiDefNode extends CHNode {
public boolean isMultiDef() {
return true;
}
-
- @Override
+
+ @Override
public boolean equals(Object o) {
- if (!super.equals(o) || !(o instanceof CHMultiDefNode))
- return false;
+ if (!super.equals(o) || !(o instanceof CHMultiDefNode))
+ return false;
- final CHMultiDefNode rhs = (CHMultiDefNode) o;
+ final CHMultiDefNode rhs = (CHMultiDefNode) o;
return Objects.equals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration());
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
index 5edc83d2923..6825bf38d49 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
@@ -33,48 +33,47 @@ public class CHNode implements IAdaptable {
private CHNode fParent;
private ICElement fRepresentedDecl;
private ITranslationUnit fFileOfReferences;
- private List<CHReferenceInfo> fReferences;
+ private List<CHReferenceInfo> fReferences;
- protected int fHashCode;
- private long fTimestamp;
- private boolean fIsRecursive;
+ protected int fHashCode;
+ private long fTimestamp;
+ private boolean fIsRecursive;
private boolean fIsInitializer;
private boolean fIsReadAccess;
private boolean fIsWriteAccess;
private final int fLinkageID;
- /**
- * Creates a new node for the include browser
- */
- public CHNode(CHNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl,
- int linkageID) {
- fParent= parent;
- fFileOfReferences= fileOfReferences;
- fReferences= Collections.emptyList();
- fRepresentedDecl= decl;
- fIsRecursive= computeIsRecursive(fParent, decl);
- fHashCode= computeHashCode();
- fTimestamp= timestamp;
- fLinkageID= linkageID;
- }
+ /**
+ * Creates a new node for the include browser
+ */
+ public CHNode(CHNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl, int linkageID) {
+ fParent = parent;
+ fFileOfReferences = fileOfReferences;
+ fReferences = Collections.emptyList();
+ fRepresentedDecl = decl;
+ fIsRecursive = computeIsRecursive(fParent, decl);
+ fHashCode = computeHashCode();
+ fTimestamp = timestamp;
+ fLinkageID = linkageID;
+ }
private int computeHashCode() {
- int hashCode= 1;
- if (fParent != null) {
- hashCode= fParent.hashCode() * 31;
- }
- if (fRepresentedDecl != null) {
- hashCode+= fRepresentedDecl.hashCode();
- }
- return hashCode;
- }
-
- @Override
+ int hashCode = 1;
+ if (fParent != null) {
+ hashCode = fParent.hashCode() * 31;
+ }
+ if (fRepresentedDecl != null) {
+ hashCode += fRepresentedDecl.hashCode();
+ }
+ return hashCode;
+ }
+
+ @Override
public int hashCode() {
- return fHashCode;
- }
+ return fHashCode;
+ }
- @Override
+ @Override
public boolean equals(Object o) {
if (!(o instanceof CHNode)) {
return false;
@@ -86,32 +85,32 @@ public class CHNode implements IAdaptable {
}
return Objects.equals(fRepresentedDecl, rhs.fRepresentedDecl);
- }
-
- private boolean computeIsRecursive(CHNode parent, ICElement decl) {
- if (parent == null || decl == null) {
- return false;
- }
- if (decl.equals(parent.fRepresentedDecl)) {
- return true;
- }
- return computeIsRecursive(parent.fParent, decl);
- }
+ }
+
+ private boolean computeIsRecursive(CHNode parent, ICElement decl) {
+ if (parent == null || decl == null) {
+ return false;
+ }
+ if (decl.equals(parent.fRepresentedDecl)) {
+ return true;
+ }
+ return computeIsRecursive(parent.fParent, decl);
+ }
/**
- * Returns the parent node or <code>null</code> for the root node.
- */
- public CHNode getParent() {
- return fParent;
- }
+ * Returns the parent node or <code>null</code> for the root node.
+ */
+ public CHNode getParent() {
+ return fParent;
+ }
- public int getLinkageID() {
- return fLinkageID;
- }
+ public int getLinkageID() {
+ return fLinkageID;
+ }
public boolean isRecursive() {
- return fIsRecursive;
- }
+ return fIsRecursive;
+ }
public int getReferenceCount() {
return fReferences.size();
@@ -134,8 +133,7 @@ public class CHNode implements IAdaptable {
}
public boolean isVariableOrEnumerator() {
- return fRepresentedDecl instanceof IVariableDeclaration ||
- fRepresentedDecl instanceof IEnumerator;
+ return fRepresentedDecl instanceof IVariableDeclaration || fRepresentedDecl instanceof IEnumerator;
}
public int getFirstReferenceOffset() {
@@ -145,10 +143,10 @@ public class CHNode implements IAdaptable {
public void addReference(CHReferenceInfo info) {
switch (fReferences.size()) {
case 0:
- fReferences= Collections.singletonList(info);
+ fReferences = Collections.singletonList(info);
return;
case 1:
- fReferences= new ArrayList<CHReferenceInfo>(fReferences);
+ fReferences = new ArrayList<CHReferenceInfo>(fReferences);
break;
}
fReferences.add(info);
@@ -190,8 +188,8 @@ public class CHNode implements IAdaptable {
}
public void setRWAccess(boolean readAccess, boolean writeAccess) {
- fIsReadAccess= readAccess;
- fIsWriteAccess= writeAccess;
+ fIsReadAccess = readAccess;
+ fIsWriteAccess = writeAccess;
}
public boolean isReadAccess() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java
index 6a652cb5c8a..3a2c94034b3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Marc-Andre Laperle - Adapted to CDT from JDT
@@ -24,14 +24,14 @@ public class CHPinAction extends Action {
/**
* Constructs a 'Pin Call Hierarchy view' action.
- *
+ *
* @param view the Call Hierarchy view
*/
public CHPinAction(CHViewPart view) {
super(CHMessages.CHPinAction_label, IAction.AS_CHECK_BOX);
setToolTipText(CHMessages.CHPinAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "pin_view.gif"); //$NON-NLS-1$
- fView= view;
+ fView = view;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHProviderManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHProviderManager.java
index d24080e01e1..1b3ac467425 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHProviderManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHProviderManager.java
@@ -39,7 +39,8 @@ public class CHProviderManager {
public static CHProviderManager INSTANCE = new CHProviderManager();
- private CHProviderManager() {}
+ private CHProviderManager() {
+ }
public List<ICallHierarchyProvider> getCallHierarchyProviders() {
if (callHierarchyProviders == null) {
@@ -50,14 +51,14 @@ public class CHProviderManager {
try {
for (IConfigurationElement element : extension.getConfigurationElements()) {
if (ELEMENT_PROVIDER.equals(element.getName())) {
- Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
- if (provider instanceof ICallHierarchyProvider) {
- callHierarchyProviders.add((ICallHierarchyProvider) provider);
- } else {
- CUIPlugin.logError(NLS.bind(CHMessages.CHProviderManager_InvalidCallHierarchyProvider,
- extension.getContributor().getName()));
- }
- }
+ Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
+ if (provider instanceof ICallHierarchyProvider) {
+ callHierarchyProviders.add((ICallHierarchyProvider) provider);
+ } else {
+ CUIPlugin.logError(NLS.bind(CHMessages.CHProviderManager_InvalidCallHierarchyProvider,
+ extension.getContributor().getName()));
+ }
+ }
}
} catch (CoreException e) {
CUIPlugin.log(e);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
index fc44ee38f77..45f4727faa4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
@@ -45,22 +45,23 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
* @since 4.0
*/
public class CHQueries {
- private static final CHNode[] EMPTY_NODES= {};
+ private static final CHNode[] EMPTY_NODES = {};
- private CHQueries() {}
+ private CHQueries() {
+ }
/**
* Searches for functions and methods that call a given element.
*/
public static CHNode[] findCalledBy(CHContentProvider cp, CHNode node, IIndex index, IProgressMonitor pm)
throws CoreException {
- CalledByResult result= new CalledByResult();
- ICElement callee= node.getRepresentedDeclaration();
+ CalledByResult result = new CalledByResult();
+ ICElement callee = node.getRepresentedDeclaration();
if (!(callee instanceof ISourceReference)) {
return EMPTY_NODES;
}
- boolean done= false;
- int linkageID= node.getLinkageID();
+ boolean done = false;
+ int linkageID = node.getLinkageID();
if (linkageID == -1) {
final ITranslationUnit tu = ((ISourceReference) callee).getTranslationUnit();
if (tu == null)
@@ -71,7 +72,7 @@ public class CHQueries {
// Bug 260262: in a header file we need to consider C and C++.
findCalledBy(callee, ILinkage.C_LINKAGE_ID, index, result);
findCalledBy(callee, ILinkage.CPP_LINKAGE_ID, index, result);
- done= true;
+ done = true;
}
}
if (!done) {
@@ -97,11 +98,11 @@ public class CHQueries {
private static void findCalledBy(ICElement callee, int linkageID, IIndex index, CalledByResult result)
throws CoreException {
final ICProject project = callee.getCProject();
- IIndexBinding calleeBinding= IndexUI.elementToBinding(index, callee, linkageID);
+ IIndexBinding calleeBinding = IndexUI.elementToBinding(index, callee, linkageID);
if (calleeBinding != null) {
findCalledBy1(index, calleeBinding, true, project, result);
if (calleeBinding instanceof ICPPMethod) {
- IBinding[] overriddenBindings= ClassTypeHelper.findOverridden((ICPPMethod) calleeBinding);
+ IBinding[] overriddenBindings = ClassTypeHelper.findOverridden((ICPPMethod) calleeBinding);
for (IBinding overriddenBinding : overriddenBindings) {
findCalledBy1(index, overriddenBinding, false, project, result);
}
@@ -109,8 +110,8 @@ public class CHQueries {
}
}
- private static void findCalledBy1(IIndex index, IBinding callee, boolean includeOrdinaryCalls,
- ICProject project, CalledByResult result) throws CoreException {
+ private static void findCalledBy1(IIndex index, IBinding callee, boolean includeOrdinaryCalls, ICProject project,
+ CalledByResult result) throws CoreException {
findCalledBy2(index, callee, includeOrdinaryCalls, project, result);
List<? extends IBinding> specializations = IndexUI.findSpecializations(index, callee);
for (IBinding spec : specializations) {
@@ -118,14 +119,14 @@ public class CHQueries {
}
}
- private static void findCalledBy2(IIndex index, IBinding callee, boolean includeOrdinaryCalls,
- ICProject project, CalledByResult result) throws CoreException {
- IIndexName[] names= index.findNames(callee, IIndex.FIND_REFERENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ private static void findCalledBy2(IIndex index, IBinding callee, boolean includeOrdinaryCalls, ICProject project,
+ CalledByResult result) throws CoreException {
+ IIndexName[] names = index.findNames(callee, IIndex.FIND_REFERENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
for (IIndexName rname : names) {
if (includeOrdinaryCalls || rname.couldBePolymorphicMethodCall()) {
- IIndexName caller= rname.getEnclosingDefinition();
+ IIndexName caller = rname.getEnclosingDefinition();
if (caller != null) {
- ICElement elem= IndexUI.getCElementForName(project, index, caller);
+ ICElement elem = IndexUI.getCElementForName(project, index, caller);
if (elem != null) {
result.add(elem, rname);
}
@@ -139,26 +140,26 @@ public class CHQueries {
*/
public static CHNode[] findCalls(CHContentProvider cp, CHNode node, IIndex index, IProgressMonitor pm)
throws CoreException {
- ICElement caller= node.getRepresentedDeclaration();
- CallsToResult result= new CallsToResult();
- IIndexName callerName= IndexUI.elementToName(index, caller);
+ ICElement caller = node.getRepresentedDeclaration();
+ CallsToResult result = new CallsToResult();
+ IIndexName callerName = IndexUI.elementToName(index, caller);
if (callerName != null) {
- IIndexName[] refs= callerName.getEnclosedNames();
+ IIndexName[] refs = callerName.getEnclosedNames();
for (IIndexName name : refs) {
- IBinding binding= index.findBinding(name);
+ IBinding binding = index.findBinding(name);
if (CallHierarchyUI.isRelevantForCallHierarchy(binding)) {
while (true) {
- ICElement[] defs= null;
+ ICElement[] defs = null;
if (binding instanceof ICPPMethod && name.couldBePolymorphicMethodCall()) {
defs = findOverriders(index, (ICPPMethod) binding);
}
if (defs == null) {
- defs= IndexUI.findRepresentative(index, binding);
+ defs = IndexUI.findRepresentative(index, binding);
}
if (defs != null && defs.length > 0) {
result.add(defs, name);
} else if (binding instanceof ICPPSpecialization) {
- binding= ((ICPPSpecialization) binding).getSpecializedBinding();
+ binding = ((ICPPSpecialization) binding).getSpecializedBinding();
if (binding != null)
continue;
}
@@ -177,10 +178,10 @@ public class CHQueries {
* Searches for overriders of method and converts them to ICElement, returns null,
* if there are none.
*/
- static ICElement[] findOverriders(IIndex index, ICPPMethod binding) throws CoreException {
- IBinding[] virtualOverriders= ClassTypeHelper.findOverriders(index, binding);
+ static ICElement[] findOverriders(IIndex index, ICPPMethod binding) throws CoreException {
+ IBinding[] virtualOverriders = ClassTypeHelper.findOverriders(index, binding);
if (virtualOverriders.length > 0) {
- ArrayList<ICElementHandle> list= new ArrayList<ICElementHandle>();
+ ArrayList<ICElementHandle> list = new ArrayList<ICElementHandle>();
list.addAll(Arrays.asList(IndexUI.findRepresentative(index, binding)));
for (IBinding overrider : virtualOverriders) {
list.addAll(Arrays.asList(IndexUI.findRepresentative(index, overrider)));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java
index 70d8a17100c..b1f22241918 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.Comparator;
@@ -27,8 +27,8 @@ public class CHReferenceInfo {
private int fLength;
public CHReferenceInfo(int offset, int length) {
- fOffset= offset;
- fLength= length;
+ fOffset = offset;
+ fLength = length;
}
public int getOffset() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java
index bc22eedb7d7..e46eaff7688 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java
@@ -27,12 +27,12 @@ public class CHRemoveFromView extends Action {
/**
* Constructs a Remove From View action.
- *
+ *
* @param view the Call Hierarchy view
*/
public CHRemoveFromView(CHViewPart view) {
super(CHMessages.CHViewPart_RemoveFromView_label);
- fView= view;
+ fView = view;
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE));
setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
index 8db5848db0b..04cc882454a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
@@ -104,40 +104,40 @@ import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
* The view part for the include browser.
*/
public class CHViewPart extends ViewPart {
- private static final String TRUE = String.valueOf(true);
- private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
- private static final String KEY_FILTER_VARIABLES = "variableFilter"; //$NON-NLS-1$
- private static final String KEY_SHOW_FILES= "showFilesInLabels"; //$NON-NLS-1$
-
- private IMemento fMemento;
- private boolean fShowsMessage;
- private CHNode fNavigationNode;
- private int fNavigationDetail;
-
- // widgets
- private PageBook fPagebook;
- private Composite fViewerPage;
- private Label fInfoText;
-
- // treeviewer
- private CHContentProvider fContentProvider;
- private CHLabelProvider fLabelProvider;
- private ExtendedTreeViewer fTreeViewer;
-
- // filters, sorter
- private ViewerFilter fVariableFilter;
- private ViewerComparator fSorterAlphaNumeric;
- private ViewerComparator fSorterReferencePosition;
+ private static final String TRUE = String.valueOf(true);
+ private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
+ private static final String KEY_FILTER_VARIABLES = "variableFilter"; //$NON-NLS-1$
+ private static final String KEY_SHOW_FILES = "showFilesInLabels"; //$NON-NLS-1$
+
+ private IMemento fMemento;
+ private boolean fShowsMessage;
+ private CHNode fNavigationNode;
+ private int fNavigationDetail;
+
+ // widgets
+ private PageBook fPagebook;
+ private Composite fViewerPage;
+ private Label fInfoText;
+
+ // treeviewer
+ private CHContentProvider fContentProvider;
+ private CHLabelProvider fLabelProvider;
+ private ExtendedTreeViewer fTreeViewer;
+
+ // filters, sorter
+ private ViewerFilter fVariableFilter;
+ private ViewerComparator fSorterAlphaNumeric;
+ private ViewerComparator fSorterReferencePosition;
private WorkingSetFilterUI fWorkingSetFilterUI;
- // actions
- private Action fReferencedByAction;
- private Action fMakesReferenceToAction;
- private Action fFilterVariablesAction;
- private Action fShowFilesInLabelsAction;
- private Action fNextAction;
- private Action fPreviousAction;
- private Action fRefreshAction;
+ // actions
+ private Action fReferencedByAction;
+ private Action fMakesReferenceToAction;
+ private Action fFilterVariablesAction;
+ private Action fShowFilesInLabelsAction;
+ private Action fNextAction;
+ private Action fPreviousAction;
+ private Action fRefreshAction;
private Action fHistoryAction;
private Action fShowReference;
private Action fOpenElement;
@@ -158,41 +158,41 @@ public class CHViewPart extends ViewPart {
private ICHEContentProvider[] fProviders;
private IStyledLabelProvider[] fLabelProviders;
- @Override
+ @Override
public void setFocus() {
- fPagebook.setFocus();
- }
-
- public void setMessage(String msg) {
- fInfoText.setText(msg);
- fPagebook.showPage(fInfoText);
- fShowsMessage= true;
- updateDescription();
- updateActionEnablement();
- }
-
- public void setInput(ICElement input) {
- if (input == null) {
- setMessage(CHMessages.CHViewPart_emptyPageMessage);
- fTreeViewer.setInput(null);
- return;
- }
- fShowsMessage= false;
- boolean allowsRefTo= allowsRefTo(input);
- fTreeViewer.setInput(null);
- if (!allowsRefTo && !fContentProvider.getComputeReferencedBy()) {
- fContentProvider.setComputeReferencedBy(true);
- fReferencedByAction.setChecked(true);
- fMakesReferenceToAction.setChecked(false);
- updateSorter();
- }
- fMakesReferenceToAction.setEnabled(allowsRefTo);
- fTreeViewer.setInput(input);
- fPagebook.showPage(fViewerPage);
- updateDescription();
- CallHierarchyUI.updateHistory(input);
- updateActionEnablement();
- }
+ fPagebook.setFocus();
+ }
+
+ public void setMessage(String msg) {
+ fInfoText.setText(msg);
+ fPagebook.showPage(fInfoText);
+ fShowsMessage = true;
+ updateDescription();
+ updateActionEnablement();
+ }
+
+ public void setInput(ICElement input) {
+ if (input == null) {
+ setMessage(CHMessages.CHViewPart_emptyPageMessage);
+ fTreeViewer.setInput(null);
+ return;
+ }
+ fShowsMessage = false;
+ boolean allowsRefTo = allowsRefTo(input);
+ fTreeViewer.setInput(null);
+ if (!allowsRefTo && !fContentProvider.getComputeReferencedBy()) {
+ fContentProvider.setComputeReferencedBy(true);
+ fReferencedByAction.setChecked(true);
+ fMakesReferenceToAction.setChecked(false);
+ updateSorter();
+ }
+ fMakesReferenceToAction.setEnabled(allowsRefTo);
+ fTreeViewer.setInput(input);
+ fPagebook.showPage(fViewerPage);
+ updateDescription();
+ CallHierarchyUI.updateHistory(input);
+ updateActionEnablement();
+ }
public void reportNotIndexed(ICElement input) {
if (input != null && getInput() == input) {
@@ -217,15 +217,15 @@ public class CHViewPart extends ViewPart {
@Override
public void createPartControl(Composite parent) {
- fPagebook = new PageBook(parent, SWT.NULL);
- createInfoPage();
- createViewerPage();
+ fPagebook = new PageBook(parent, SWT.NULL);
+ createInfoPage();
+ createViewerPage();
- getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, fTreeViewer));
+ getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, fTreeViewer));
- initDragAndDrop();
- createActions();
- createContextMenu();
+ initDragAndDrop();
+ createActions();
+ createContextMenu();
bindingService = PlatformUI.getWorkbench().getService(IBindingService.class);
if (bindingService != null) {
@@ -233,9 +233,11 @@ public class CHViewPart extends ViewPart {
@Override
public void bindingManagerChanged(BindingManagerEvent event) {
if (event.isActiveBindingsChanged()) {
- String keyBinding = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_DELETE);
+ String keyBinding = bindingService
+ .getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_DELETE);
if (keyBinding != null) {
- fRemoveFromViewAction.setText(CHMessages.CHViewPart_RemoveFromView_label + '\t'+ keyBinding);
+ fRemoveFromViewAction
+ .setText(CHMessages.CHViewPart_RemoveFromView_label + '\t' + keyBinding);
}
}
}
@@ -243,21 +245,21 @@ public class CHViewPart extends ViewPart {
bindingService.addBindingManagerListener(bindingManagerListener);
}
- setMessage(CHMessages.CHViewPart_emptyPageMessage);
+ setMessage(CHMessages.CHViewPart_emptyPageMessage);
- initializeActionStates();
+ initializeActionStates();
- IContextService ctxService = getSite().getService(IContextService.class);
- if (ctxService != null) {
- fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
- }
+ IContextService ctxService = getSite().getService(IContextService.class);
+ if (ctxService != null) {
+ fContextActivation = ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+ }
PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.CALL_HIERARCHY_VIEW);
addPartListener();
}
private void addPartListener() {
- fPartListener= new IPartListener2() {
+ fPartListener = new IPartListener2() {
@Override
public void partActivated(IWorkbenchPartReference partRef) {
if (isThisView(partRef))
@@ -265,7 +267,8 @@ public class CHViewPart extends ViewPart {
}
@Override
- public void partBroughtToTop(IWorkbenchPartReference partRef) { }
+ public void partBroughtToTop(IWorkbenchPartReference partRef) {
+ }
@Override
public void partClosed(IWorkbenchPartReference partRef) {
@@ -275,15 +278,24 @@ public class CHViewPart extends ViewPart {
}
@Override
- public void partDeactivated(IWorkbenchPartReference partRef) {}
+ public void partDeactivated(IWorkbenchPartReference partRef) {
+ }
+
@Override
- public void partOpened(IWorkbenchPartReference partRef) {}
+ public void partOpened(IWorkbenchPartReference partRef) {
+ }
+
@Override
- public void partHidden(IWorkbenchPartReference partRef) {}
+ public void partHidden(IWorkbenchPartReference partRef) {
+ }
+
@Override
- public void partVisible(IWorkbenchPartReference partRef) {}
+ public void partVisible(IWorkbenchPartReference partRef) {
+ }
+
@Override
- public void partInputChanged(IWorkbenchPartReference partRef) {}
+ public void partInputChanged(IWorkbenchPartReference partRef) {
+ }
};
getViewSite().getPage().addPartListener(fPartListener);
}
@@ -304,456 +316,458 @@ public class CHViewPart extends ViewPart {
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.dispose();
- fOpenViewActionGroup= null;
+ fOpenViewActionGroup = null;
}
if (fSelectionSearchGroup != null) {
fSelectionSearchGroup.dispose();
- fSelectionSearchGroup= null;
+ fSelectionSearchGroup = null;
}
if (fRefactoringActionGroup != null) {
fRefactoringActionGroup.dispose();
- fRefactoringActionGroup= null;
+ fRefactoringActionGroup = null;
}
if (fWorkingSetFilterUI != null) {
fWorkingSetFilterUI.dispose();
- fWorkingSetFilterUI= null;
+ fWorkingSetFilterUI = null;
}
if (fPartListener != null) {
getViewSite().getPage().removePartListener(fPartListener);
- fPartListener= null;
+ fPartListener = null;
}
super.dispose();
}
- private void initializeActionStates() {
- boolean referencedBy= true;
- boolean filterVariables= false;
- boolean showFiles= false;
-
- if (fMemento != null) {
- filterVariables= TRUE.equals(fMemento.getString(KEY_FILTER_VARIABLES));
- showFiles= TRUE.equals(fMemento.getString(KEY_SHOW_FILES));
- }
-
- fLabelProvider.setShowFiles(showFiles);
- fShowFilesInLabelsAction.setChecked(showFiles);
-
- fReferencedByAction.setChecked(referencedBy);
- fMakesReferenceToAction.setChecked(!referencedBy);
- fContentProvider.setComputeReferencedBy(referencedBy);
-
- fFilterVariablesAction.setChecked(filterVariables);
- fFilterVariablesAction.run();
- updateSorter();
- }
-
- @Override
+ private void initializeActionStates() {
+ boolean referencedBy = true;
+ boolean filterVariables = false;
+ boolean showFiles = false;
+
+ if (fMemento != null) {
+ filterVariables = TRUE.equals(fMemento.getString(KEY_FILTER_VARIABLES));
+ showFiles = TRUE.equals(fMemento.getString(KEY_SHOW_FILES));
+ }
+
+ fLabelProvider.setShowFiles(showFiles);
+ fShowFilesInLabelsAction.setChecked(showFiles);
+
+ fReferencedByAction.setChecked(referencedBy);
+ fMakesReferenceToAction.setChecked(!referencedBy);
+ fContentProvider.setComputeReferencedBy(referencedBy);
+
+ fFilterVariablesAction.setChecked(filterVariables);
+ fFilterVariablesAction.run();
+ updateSorter();
+ }
+
+ @Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
- fMemento= memento;
- super.init(site, memento);
- }
+ fMemento = memento;
+ super.init(site, memento);
+ }
/**
* Tells whether the given part reference references this view.
- *
+ *
* @param partRef the workbench part reference
* @return <code>true</code> if the given part reference references this view
*/
private boolean isThisView(IWorkbenchPartReference partRef) {
if (!CUIPlugin.ID_CALL_HIERARCHY.equals(partRef.getId()))
return false;
- String partRefSecondaryId = ((IViewReference)partRef).getSecondaryId();
+ String partRefSecondaryId = ((IViewReference) partRef).getSecondaryId();
String thisSecondaryId = getViewSite().getSecondaryId();
- return thisSecondaryId == null && partRefSecondaryId == null || thisSecondaryId != null && thisSecondaryId.equals(partRefSecondaryId);
+ return thisSecondaryId == null && partRefSecondaryId == null
+ || thisSecondaryId != null && thisSecondaryId.equals(partRefSecondaryId);
}
- @Override
+ @Override
public void saveState(IMemento memento) {
- if (fWorkingSetFilterUI != null) {
- fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
- }
- memento.putString(KEY_FILTER_VARIABLES, String.valueOf(fFilterVariablesAction.isChecked()));
- memento.putString(KEY_SHOW_FILES, String.valueOf(fShowFilesInLabelsAction.isChecked()));
- super.saveState(memento);
- }
-
- private void createContextMenu() {
- MenuManager manager = new MenuManager();
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
- @Override
+ if (fWorkingSetFilterUI != null) {
+ fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
+ }
+ memento.putString(KEY_FILTER_VARIABLES, String.valueOf(fFilterVariablesAction.isChecked()));
+ memento.putString(KEY_SHOW_FILES, String.valueOf(fShowFilesInLabelsAction.isChecked()));
+ super.saveState(memento);
+ }
+
+ private void createContextMenu() {
+ MenuManager manager = new MenuManager();
+ manager.setRemoveAllWhenShown(true);
+ manager.addMenuListener(new IMenuListener() {
+ @Override
public void menuAboutToShow(IMenuManager m) {
- onContextMenuAboutToShow(m);
- }
- });
- Menu menu = manager.createContextMenu(fTreeViewer.getControl());
- fTreeViewer.getControl().setMenu(menu);
- IWorkbenchPartSite site = getSite();
- site.registerContextMenu(CUIPlugin.ID_CALL_HIERARCHY, manager, fTreeViewer);
- }
-
- private void createViewerPage() {
- Display display= getSite().getShell().getDisplay();
- fViewerPage = new Composite(fPagebook, SWT.NULL);
- fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
- fViewerPage.setSize(100, 100);
- fViewerPage.setLayout(new FillLayout());
-
- fProviders = CHEProviderSettings.getCCallHierarchyContentProviders();
- fLabelProviders = CHEProviderSettings.getCCallHierarchyLabelProviders();
-
- fContentProvider= new CHContentProvider(this, display);
- fLabelProvider = new CHLabelProvider(this, display, fContentProvider);
- fTreeViewer= new ExtendedTreeViewer(fViewerPage);
- fTreeViewer.setContentProvider(fContentProvider);
- fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fLabelProvider));
- fTreeViewer.setAutoExpandLevel(2);
- fTreeViewer.addOpenListener(new IOpenListener() {
+ onContextMenuAboutToShow(m);
+ }
+ });
+ Menu menu = manager.createContextMenu(fTreeViewer.getControl());
+ fTreeViewer.getControl().setMenu(menu);
+ IWorkbenchPartSite site = getSite();
+ site.registerContextMenu(CUIPlugin.ID_CALL_HIERARCHY, manager, fTreeViewer);
+ }
+
+ private void createViewerPage() {
+ Display display = getSite().getShell().getDisplay();
+ fViewerPage = new Composite(fPagebook, SWT.NULL);
+ fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fViewerPage.setSize(100, 100);
+ fViewerPage.setLayout(new FillLayout());
+
+ fProviders = CHEProviderSettings.getCCallHierarchyContentProviders();
+ fLabelProviders = CHEProviderSettings.getCCallHierarchyLabelProviders();
+
+ fContentProvider = new CHContentProvider(this, display);
+ fLabelProvider = new CHLabelProvider(this, display, fContentProvider);
+ fTreeViewer = new ExtendedTreeViewer(fViewerPage);
+ fTreeViewer.setContentProvider(fContentProvider);
+ fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fLabelProvider));
+ fTreeViewer.setAutoExpandLevel(2);
+ fTreeViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
- onShowSelectedReference(event.getSelection());
- }
- });
- if (fProviders !=null) {
+ onShowSelectedReference(event.getSelection());
+ }
+ });
+ if (fProviders != null) {
for (ICHEContentProvider provider : fProviders) {
fTreeViewer.addOpenListener(provider.getCCallHierarchyOpenListener());
}
- }
- }
+ }
+ }
private void createInfoPage() {
fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
- }
-
- private void initDragAndDrop() {
- CHDropTargetListener dropListener= new CHDropTargetListener(this);
- Transfer[] localSelectionTransfer= new Transfer[] {
- LocalSelectionTransfer.getTransfer()
- };
- DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
- dropTarget.setTransfer(localSelectionTransfer);
- dropTarget.addDropListener(dropListener);
- }
-
- private void createActions() {
- // Action groups
- fOpenViewActionGroup= new OpenViewActionGroup(this);
- fOpenViewActionGroup.setSuppressCallHierarchy(true);
- fOpenViewActionGroup.setSuppressProperties(true);
- fOpenViewActionGroup.setEnableIncludeBrowser(true);
- fSelectionSearchGroup= new SelectionSearchGroup(getSite());
- fRefactoringActionGroup= new CRefactoringActionGroup(this);
-
- fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
- @Override
+ }
+
+ private void initDragAndDrop() {
+ CHDropTargetListener dropListener = new CHDropTargetListener(this);
+ Transfer[] localSelectionTransfer = new Transfer[] { LocalSelectionTransfer.getTransfer() };
+ DropTarget dropTarget = new DropTarget(fPagebook,
+ DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
+ dropTarget.setTransfer(localSelectionTransfer);
+ dropTarget.addDropListener(dropListener);
+ }
+
+ private void createActions() {
+ // Action groups
+ fOpenViewActionGroup = new OpenViewActionGroup(this);
+ fOpenViewActionGroup.setSuppressCallHierarchy(true);
+ fOpenViewActionGroup.setSuppressProperties(true);
+ fOpenViewActionGroup.setEnableIncludeBrowser(true);
+ fSelectionSearchGroup = new SelectionSearchGroup(getSite());
+ fRefactoringActionGroup = new CRefactoringActionGroup(this);
+
+ fWorkingSetFilterUI = new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
+ @Override
protected void onWorkingSetChange() {
- updateWorkingSetFilter(this);
- }
- @Override
+ updateWorkingSetFilter(this);
+ }
+
+ @Override
protected void onWorkingSetNameChange() {
- updateDescription();
- }
- };
-
- fReferencedByAction=
- new Action(CHMessages.CHViewPart_ShowCallers_label, IAction.AS_RADIO_BUTTON) {
- @Override
- public void run() {
- if (isChecked()) {
- onSetShowReferencedBy(true);
- }
- }
- };
- fReferencedByAction.setToolTipText(CHMessages.CHViewPart_ShowCallers_tooltip);
- CPluginImages.setImageDescriptors(fReferencedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);
-
- fMakesReferenceToAction=
- new Action(CHMessages.CHViewPart_ShowCallees_label, IAction.AS_RADIO_BUTTON) {
- @Override
- public void run() {
- if (isChecked()) {
- onSetShowReferencedBy(false);
- }
- }
- };
- fMakesReferenceToAction.setToolTipText(CHMessages.CHViewPart_ShowCallees_tooltip);
- CPluginImages.setImageDescriptors(fMakesReferenceToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
-
- fVariableFilter= new ViewerFilter() {
- @Override
+ updateDescription();
+ }
+ };
+
+ fReferencedByAction = new Action(CHMessages.CHViewPart_ShowCallers_label, IAction.AS_RADIO_BUTTON) {
+ @Override
+ public void run() {
+ if (isChecked()) {
+ onSetShowReferencedBy(true);
+ }
+ }
+ };
+ fReferencedByAction.setToolTipText(CHMessages.CHViewPart_ShowCallers_tooltip);
+ CPluginImages.setImageDescriptors(fReferencedByAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_SHOW_REF_BY);
+
+ fMakesReferenceToAction = new Action(CHMessages.CHViewPart_ShowCallees_label, IAction.AS_RADIO_BUTTON) {
+ @Override
+ public void run() {
+ if (isChecked()) {
+ onSetShowReferencedBy(false);
+ }
+ }
+ };
+ fMakesReferenceToAction.setToolTipText(CHMessages.CHViewPart_ShowCallees_tooltip);
+ CPluginImages.setImageDescriptors(fMakesReferenceToAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
+
+ fVariableFilter = new ViewerFilter() {
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof CHNode) {
- CHNode node= (CHNode) element;
- return !node.isVariableOrEnumerator();
- }
- return true;
- }
- };
- fFilterVariablesAction= new Action(CHMessages.CHViewPart_FilterVariables_label, IAction.AS_CHECK_BOX) {
- @Override
+ if (element instanceof CHNode) {
+ CHNode node = (CHNode) element;
+ return !node.isVariableOrEnumerator();
+ }
+ return true;
+ }
+ };
+ fFilterVariablesAction = new Action(CHMessages.CHViewPart_FilterVariables_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- if (isChecked()) {
- fTreeViewer.addFilter(fVariableFilter);
- } else {
- fTreeViewer.removeFilter(fVariableFilter);
- }
- }
- };
- fFilterVariablesAction.setToolTipText(CHMessages.CHViewPart_FilterVariables_tooltip);
- CPluginImages.setImageDescriptors(fFilterVariablesAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
-
- fSorterAlphaNumeric= new ViewerComparator();
- fSorterReferencePosition= new ViewerComparator() {
- @Override
+ if (isChecked()) {
+ fTreeViewer.addFilter(fVariableFilter);
+ } else {
+ fTreeViewer.removeFilter(fVariableFilter);
+ }
+ }
+ };
+ fFilterVariablesAction.setToolTipText(CHMessages.CHViewPart_FilterVariables_tooltip);
+ CPluginImages.setImageDescriptors(fFilterVariablesAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_HIDE_FIELDS);
+
+ fSorterAlphaNumeric = new ViewerComparator();
+ fSorterReferencePosition = new ViewerComparator() {
+ @Override
public int category(Object element) {
- if (element instanceof CHNode) {
- return 0;
- }
- return 1;
- }
+ if (element instanceof CHNode) {
+ return 0;
+ }
+ return 1;
+ }
- @Override
+ @Override
public int compare(Viewer viewer, Object e1, Object e2) {
- if (!(e1 instanceof CHNode)) {
- if (!(e2 instanceof CHNode)) {
- return 0;
- }
- return -1;
- }
- if (!(e2 instanceof CHNode)) {
- return 1;
- }
- CHNode n1= (CHNode) e1;
- CHNode n2= (CHNode) e2;
- int offset1= n1.getFirstReferenceOffset();
- int offset2= n2.getFirstReferenceOffset();
- return Integer.compare(offset1, offset2);
- }
- };
-
- fShowReference= new Action(CHMessages.CHViewPart_ShowReference_label) {
- @Override
+ if (!(e1 instanceof CHNode)) {
+ if (!(e2 instanceof CHNode)) {
+ return 0;
+ }
+ return -1;
+ }
+ if (!(e2 instanceof CHNode)) {
+ return 1;
+ }
+ CHNode n1 = (CHNode) e1;
+ CHNode n2 = (CHNode) e2;
+ int offset1 = n1.getFirstReferenceOffset();
+ int offset2 = n2.getFirstReferenceOffset();
+ return Integer.compare(offset1, offset2);
+ }
+ };
+
+ fShowReference = new Action(CHMessages.CHViewPart_ShowReference_label) {
+ @Override
public void run() {
- onShowSelectedReference(fTreeViewer.getSelection());
- }
- };
- fShowReference.setToolTipText(CHMessages.CHViewPart_ShowReference_tooltip);
- fOpenElement= new Action(CHMessages.CHViewPart_Open_label) {
- @Override
+ onShowSelectedReference(fTreeViewer.getSelection());
+ }
+ };
+ fShowReference.setToolTipText(CHMessages.CHViewPart_ShowReference_tooltip);
+ fOpenElement = new Action(CHMessages.CHViewPart_Open_label) {
+ @Override
public void run() {
- onOpenElement(fTreeViewer.getSelection());
- }
- };
- fOpenElement.setToolTipText(CHMessages.CHViewPart_Open_tooltip);
- fOpenElement.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
-
- fShowFilesInLabelsAction= new Action(CHMessages.CHViewPart_ShowFiles_label, IAction.AS_CHECK_BOX) {
- @Override
+ onOpenElement(fTreeViewer.getSelection());
+ }
+ };
+ fOpenElement.setToolTipText(CHMessages.CHViewPart_Open_tooltip);
+ fOpenElement.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
+
+ fShowFilesInLabelsAction = new Action(CHMessages.CHViewPart_ShowFiles_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- onShowFilesInLabels(isChecked());
- }
- };
- fShowFilesInLabelsAction.setToolTipText(CHMessages.CHViewPart_ShowFiles_tooltip);
- fNextAction = new Action(CHMessages.CHViewPart_NextReference_label) {
- @Override
+ onShowFilesInLabels(isChecked());
+ }
+ };
+ fShowFilesInLabelsAction.setToolTipText(CHMessages.CHViewPart_ShowFiles_tooltip);
+ fNextAction = new Action(CHMessages.CHViewPart_NextReference_label) {
+ @Override
public void run() {
- onNextOrPrevious(true);
- }
- };
- fNextAction.setToolTipText(CHMessages.CHViewPart_NextReference_tooltip);
- CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
-
- fPreviousAction = new Action(CHMessages.CHViewPart_PreviousReference_label) {
- @Override
+ onNextOrPrevious(true);
+ }
+ };
+ fNextAction.setToolTipText(CHMessages.CHViewPart_NextReference_tooltip);
+ CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
+
+ fPreviousAction = new Action(CHMessages.CHViewPart_PreviousReference_label) {
+ @Override
public void run() {
- onNextOrPrevious(false);
- }
- };
- fPreviousAction.setToolTipText(CHMessages.CHViewPart_PreviousReference_tooltip);
- CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
-
- fRefreshAction = new Action(CHMessages.CHViewPart_Refresh_label) {
- @Override
+ onNextOrPrevious(false);
+ }
+ };
+ fPreviousAction.setToolTipText(CHMessages.CHViewPart_PreviousReference_tooltip);
+ CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
+
+ fRefreshAction = new Action(CHMessages.CHViewPart_Refresh_label) {
+ @Override
public void run() {
- onRefresh();
- }
- };
- fRefreshAction.setToolTipText(CHMessages.CHViewPart_Refresh_tooltip);
- CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
-
- fHistoryAction = new CHHistoryDropDownAction(this);
-
- fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer);
- fPinViewAction= new CHPinAction(this);
- fRemoveFromViewAction= new CHRemoveFromView(this);
-
- // setup action bar
- // global action hooks
- IActionBars actionBars = getViewSite().getActionBars();
- fRefactoringActionGroup.fillActionBars(actionBars);
- fOpenViewActionGroup.fillActionBars(actionBars);
- fSelectionSearchGroup.fillActionBars(actionBars);
-
- actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenElement);
- actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
- actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
- actionBars.updateActionBars();
-
- TextActionHandler textActionHandler = new TextActionHandler(actionBars);
- textActionHandler.setDeleteAction(fRemoveFromViewAction);
-
- // local toolbar
- IToolBarManager tm = actionBars.getToolBarManager();
- tm.add(fNextAction);
- tm.add(fPreviousAction);
- tm.add(new Separator());
- tm.add(fFilterVariablesAction);
- tm.add(new Separator());
- tm.add(fReferencedByAction);
- tm.add(fMakesReferenceToAction);
+ onRefresh();
+ }
+ };
+ fRefreshAction.setToolTipText(CHMessages.CHViewPart_Refresh_tooltip);
+ CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
+
+ fHistoryAction = new CHHistoryDropDownAction(this);
+
+ fCopyAction = new CopyCallHierarchyAction(this, fTreeViewer);
+ fPinViewAction = new CHPinAction(this);
+ fRemoveFromViewAction = new CHRemoveFromView(this);
+
+ // setup action bar
+ // global action hooks
+ IActionBars actionBars = getViewSite().getActionBars();
+ fRefactoringActionGroup.fillActionBars(actionBars);
+ fOpenViewActionGroup.fillActionBars(actionBars);
+ fSelectionSearchGroup.fillActionBars(actionBars);
+
+ actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenElement);
+ actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
+ actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
+ actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
+ actionBars.updateActionBars();
+
+ TextActionHandler textActionHandler = new TextActionHandler(actionBars);
+ textActionHandler.setDeleteAction(fRemoveFromViewAction);
+
+ // local toolbar
+ IToolBarManager tm = actionBars.getToolBarManager();
+ tm.add(fNextAction);
+ tm.add(fPreviousAction);
+ tm.add(new Separator());
+ tm.add(fFilterVariablesAction);
+ tm.add(new Separator());
+ tm.add(fReferencedByAction);
+ tm.add(fMakesReferenceToAction);
tm.add(fHistoryAction);
- tm.add(fRefreshAction);
- tm.add(fPinViewAction);
-
- // local menu
- IMenuManager mm = actionBars.getMenuManager();
-
- fWorkingSetFilterUI.fillActionBars(actionBars);
- mm.add(fReferencedByAction);
- mm.add(fMakesReferenceToAction);
- mm.add(new Separator());
- mm.add(fShowFilesInLabelsAction);
- mm.add(new Separator());
- mm.add(fFilterVariablesAction);
- }
-
- private void setNextNode(boolean forward) {
- TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), CHNode.class);
- TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
- if (selectedItem == null) {
- fNavigationNode= null;
- return;
- }
-
- if (selectedItem.getData().equals(fNavigationNode)) {
- if (forward && fNavigationDetail < getReferenceCount(fNavigationNode)-1) {
- fNavigationDetail++;
- } else if (!forward && fNavigationDetail > 0) {
- fNavigationDetail--;
- } else {
- selectedItem= navigator.getNextSibbling(selectedItem, forward);
- fNavigationNode= selectedItem == null ? null : (CHNode) selectedItem.getData();
- initNavigationDetail(forward);
- }
- } else {
- fNavigationNode= (CHNode) selectedItem.getData();
- initNavigationDetail(forward);
- }
- }
+ tm.add(fRefreshAction);
+ tm.add(fPinViewAction);
+
+ // local menu
+ IMenuManager mm = actionBars.getMenuManager();
+
+ fWorkingSetFilterUI.fillActionBars(actionBars);
+ mm.add(fReferencedByAction);
+ mm.add(fMakesReferenceToAction);
+ mm.add(new Separator());
+ mm.add(fShowFilesInLabelsAction);
+ mm.add(new Separator());
+ mm.add(fFilterVariablesAction);
+ }
+
+ private void setNextNode(boolean forward) {
+ TreeNavigator navigator = new TreeNavigator(fTreeViewer.getTree(), CHNode.class);
+ TreeItem selectedItem = navigator.getSelectedItemOrFirstOnLevel(1, forward);
+ if (selectedItem == null) {
+ fNavigationNode = null;
+ return;
+ }
+
+ if (selectedItem.getData().equals(fNavigationNode)) {
+ if (forward && fNavigationDetail < getReferenceCount(fNavigationNode) - 1) {
+ fNavigationDetail++;
+ } else if (!forward && fNavigationDetail > 0) {
+ fNavigationDetail--;
+ } else {
+ selectedItem = navigator.getNextSibbling(selectedItem, forward);
+ fNavigationNode = selectedItem == null ? null : (CHNode) selectedItem.getData();
+ initNavigationDetail(forward);
+ }
+ } else {
+ fNavigationNode = (CHNode) selectedItem.getData();
+ initNavigationDetail(forward);
+ }
+ }
private void initNavigationDetail(boolean forward) {
if (!forward && fNavigationNode != null) {
- fNavigationDetail= Math.max(0, getReferenceCount(fNavigationNode) -1);
+ fNavigationDetail = Math.max(0, getReferenceCount(fNavigationNode) - 1);
} else {
- fNavigationDetail= 0;
+ fNavigationDetail = 0;
}
}
protected void onShowSelectedReference(ISelection selection) {
- CHNode node= selectionToNode(selection);
+ CHNode node = selectionToNode(selection);
if (node != null && node == fNavigationNode && node.getReferenceCount() > 0) {
- fNavigationDetail= (fNavigationDetail + 1) % node.getReferenceCount();
+ fNavigationDetail = (fNavigationDetail + 1) % node.getReferenceCount();
} else {
- fNavigationDetail= 0;
+ fNavigationDetail = 0;
}
- fNavigationNode= node;
- showReference();
+ fNavigationNode = node;
+ showReference();
}
protected void onOpenElement(ISelection selection) {
- CHNode node= selectionToNode(selection);
- openElement(node);
+ CHNode node = selectionToNode(selection);
+ openElement(node);
}
private void openElement(CHNode node) {
if (node != null && !node.isMultiDef()) {
- ICElement elem= node.getRepresentedDeclaration();
- if (elem != null) {
- IWorkbenchPage page= getSite().getPage();
- try {
+ ICElement elem = node.getRepresentedDeclaration();
+ if (elem != null) {
+ IWorkbenchPage page = getSite().getPage();
+ try {
EditorOpener.open(page, elem);
} catch (CModelException e) {
CUIPlugin.log(e);
}
- }
- }
- }
-
- protected void onNextOrPrevious(boolean forward) {
- setNextNode(forward);
- if (fNavigationNode != null) {
- StructuredSelection sel= new StructuredSelection(fNavigationNode);
- fTreeViewer.setSelection(sel);
- showReference();
- }
- }
-
- protected void onRefresh() {
- fContentProvider.recompute();
- }
-
- protected void onShowFilesInLabels(boolean show) {
- fLabelProvider.setShowFiles(show);
- fTreeViewer.refresh();
- }
-
- private void updateSorter() {
- if (fReferencedByAction.isChecked()) {
- fTreeViewer.setComparator(fSorterAlphaNumeric);
- } else {
- fTreeViewer.setComparator(fSorterReferencePosition);
- }
- }
-
- private void updateDescription() {
- String message= ""; //$NON-NLS-1$
- if (!fShowsMessage) {
- ICElement elem= getInput();
- if (elem != null) {
- String format, scope, label;
-
- // label
- label= CElementLabels.getElementLabel(elem, CHHistoryAction.LABEL_OPTIONS);
-
- // scope
- IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet();
- if (workingSet == null) {
- scope= CHMessages.CHViewPart_WorkspaceScope;
- } else {
- scope= workingSet.getLabel();
- }
-
- // format
- if (fReferencedByAction.isChecked()) {
- format= CHMessages.CHViewPart_Title_callers;
- } else {
- format= CHMessages.CHViewPart_Title_callees;
- }
-
- // message
- message= Messages.format(format, label, scope);
- }
- }
-
- // Escape '&' characters in the message, otherwise SWT interprets them
- // as mnemonics. '&' characters can appear in the label of a CElement
- // if the CElement represents a function with arguments of C++
- // reference type.
- message = TextUtil.escape(message, '&');
-
- setContentDescription(message);
- }
+ }
+ }
+ }
+
+ protected void onNextOrPrevious(boolean forward) {
+ setNextNode(forward);
+ if (fNavigationNode != null) {
+ StructuredSelection sel = new StructuredSelection(fNavigationNode);
+ fTreeViewer.setSelection(sel);
+ showReference();
+ }
+ }
+
+ protected void onRefresh() {
+ fContentProvider.recompute();
+ }
+
+ protected void onShowFilesInLabels(boolean show) {
+ fLabelProvider.setShowFiles(show);
+ fTreeViewer.refresh();
+ }
+
+ private void updateSorter() {
+ if (fReferencedByAction.isChecked()) {
+ fTreeViewer.setComparator(fSorterAlphaNumeric);
+ } else {
+ fTreeViewer.setComparator(fSorterReferencePosition);
+ }
+ }
+
+ private void updateDescription() {
+ String message = ""; //$NON-NLS-1$
+ if (!fShowsMessage) {
+ ICElement elem = getInput();
+ if (elem != null) {
+ String format, scope, label;
+
+ // label
+ label = CElementLabels.getElementLabel(elem, CHHistoryAction.LABEL_OPTIONS);
+
+ // scope
+ IWorkingSet workingSet = fWorkingSetFilterUI.getWorkingSet();
+ if (workingSet == null) {
+ scope = CHMessages.CHViewPart_WorkspaceScope;
+ } else {
+ scope = workingSet.getLabel();
+ }
+
+ // format
+ if (fReferencedByAction.isChecked()) {
+ format = CHMessages.CHViewPart_Title_callers;
+ } else {
+ format = CHMessages.CHViewPart_Title_callees;
+ }
+
+ // message
+ message = Messages.format(format, label, scope);
+ }
+ }
+
+ // Escape '&' characters in the message, otherwise SWT interprets them
+ // as mnemonics. '&' characters can appear in the label of a CElement
+ // if the CElement represents a function with arguments of C++
+ // reference type.
+ message = TextUtil.escape(message, '&');
+
+ setContentDescription(message);
+ }
private void updateActionEnablement() {
fHistoryAction.setEnabled(CallHierarchyUI.getHistoryEntries().length > 0);
@@ -762,25 +776,25 @@ public class CHViewPart extends ViewPart {
fRefreshAction.setEnabled(!fShowsMessage);
}
- private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
- fContentProvider.setWorkingSetFilter(filterUI);
- }
+ private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
+ fContentProvider.setWorkingSetFilter(filterUI);
+ }
- public void onSetShowReferencedBy(boolean showReferencedBy) {
- if (showReferencedBy != fContentProvider.getComputeReferencedBy()) {
- Object input= fTreeViewer.getInput();
- fTreeViewer.setInput(null);
- fContentProvider.setComputeReferencedBy(showReferencedBy);
- updateSorter();
- fTreeViewer.setInput(input);
- updateDescription();
- }
- }
+ public void onSetShowReferencedBy(boolean showReferencedBy) {
+ if (showReferencedBy != fContentProvider.getComputeReferencedBy()) {
+ Object input = fTreeViewer.getInput();
+ fTreeViewer.setInput(null);
+ fContentProvider.setComputeReferencedBy(showReferencedBy);
+ updateSorter();
+ fTreeViewer.setInput(input);
+ updateDescription();
+ }
+ }
protected void onContextMenuAboutToShow(IMenuManager menu) {
CUIPlugin.createStandardGroups(menu);
-
- CHNode node= selectionToNode(fTreeViewer.getSelection());
+
+ CHNode node = selectionToNode(fTreeViewer.getSelection());
if (node != null) {
if (getReferenceCount(node) > 0) {
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fShowReference);
@@ -789,10 +803,10 @@ public class CHViewPart extends ViewPart {
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenElement);
}
if (node.getParent() != null) {
- final ICElement element= node.getRepresentedDeclaration();
+ final ICElement element = node.getRepresentedDeclaration();
if (element != null) {
- String label= Messages.format(CHMessages.CHViewPart_FocusOn_label,
- CElementLabels.getTextLabel(element, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES));
+ String label = Messages.format(CHMessages.CHViewPart_FocusOn_label, CElementLabels.getTextLabel(
+ element, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES));
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) {
@Override
public void run() {
@@ -802,10 +816,10 @@ public class CHViewPart extends ViewPart {
}
}
}
-
+
// Action groups
ISelection selection = getSite().getSelectionProvider().getSelection();
- if (OpenViewActionGroup.canActionBeAdded(selection)){
+ if (OpenViewActionGroup.canActionBeAdded(selection)) {
fOpenViewActionGroup.fillContextMenu(menu);
}
@@ -816,38 +830,38 @@ public class CHViewPart extends ViewPart {
menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fRemoveFromViewAction);
}
- if (SelectionSearchGroup.canActionBeAdded(selection)){
+ if (SelectionSearchGroup.canActionBeAdded(selection)) {
fSelectionSearchGroup.fillContextMenu(menu);
}
fRefactoringActionGroup.fillContextMenu(menu);
}
- private void showReference() {
- if (fNavigationNode != null) {
- ITranslationUnit file= fNavigationNode.getFileOfReferences();
- if (file != null) {
- IWorkbenchPage page= getSite().getPage();
- if (fNavigationNode.getReferenceCount() > 0) {
- long timestamp= fNavigationNode.getTimestamp();
- if (fNavigationDetail < 0) {
- fNavigationDetail= 0;
- } else if (fNavigationDetail >= fNavigationNode.getReferenceCount()-1) {
- fNavigationDetail= fNavigationNode.getReferenceCount()-1;
- }
-
- CHReferenceInfo ref= fNavigationNode.getReference(fNavigationDetail);
- Region region= new Region(ref.getOffset(), ref.getLength());
- EditorOpener.open(page, file, region, timestamp);
- } else {
- try {
- EditorOpener.open(page, fNavigationNode.getRepresentedDeclaration());
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- }
- }
- }
- }
+ private void showReference() {
+ if (fNavigationNode != null) {
+ ITranslationUnit file = fNavigationNode.getFileOfReferences();
+ if (file != null) {
+ IWorkbenchPage page = getSite().getPage();
+ if (fNavigationNode.getReferenceCount() > 0) {
+ long timestamp = fNavigationNode.getTimestamp();
+ if (fNavigationDetail < 0) {
+ fNavigationDetail = 0;
+ } else if (fNavigationDetail >= fNavigationNode.getReferenceCount() - 1) {
+ fNavigationDetail = fNavigationNode.getReferenceCount() - 1;
+ }
+
+ CHReferenceInfo ref = fNavigationNode.getReference(fNavigationDetail);
+ Region region = new Region(ref.getOffset(), ref.getLength());
+ EditorOpener.open(page, file, region, timestamp);
+ } else {
+ try {
+ EditorOpener.open(page, fNavigationNode.getRepresentedDeclaration());
+ } catch (CModelException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ }
+ }
+ }
private int getReferenceCount(CHNode node) {
if (node != null) {
@@ -856,15 +870,15 @@ public class CHViewPart extends ViewPart {
return parent.getReferenceCount();
}
return node.getReferenceCount();
- }
+ }
return 0;
}
private CHNode selectionToNode(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) selection;
- for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
- Object cand= iter.next();
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ for (Iterator<?> iter = ss.iterator(); iter.hasNext();) {
+ Object cand = iter.next();
if (cand instanceof CHNode) {
return (CHNode) cand;
}
@@ -878,11 +892,11 @@ public class CHViewPart extends ViewPart {
}
public ICElement getInput() {
- Object input= fTreeViewer.getInput();
- if (input instanceof ICElement) {
- return (ICElement) input;
- }
- return null;
+ Object input = fTreeViewer.getInput();
+ if (input instanceof ICElement) {
+ return (ICElement) input;
+ }
+ return null;
}
public TreeViewer getTreeViewer() {
@@ -897,16 +911,16 @@ public class CHViewPart extends ViewPart {
/**
* Marks the view as pinned.
- *
+ *
* @param pinned if <code>true</code> the view is marked as pinned
*/
void setPinned(boolean pinned) {
- fIsPinned= pinned;
+ fIsPinned = pinned;
}
/**
* Indicates whether the Call Hierarchy view is pinned.
- *
+ *
* @return <code>true</code> if the view is pinned, <code>false</code> otherwise
*/
boolean isPinned() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java
index 5bea54166a6..af189256e2a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java
@@ -71,44 +71,45 @@ public class CallHierarchyUI {
/**
* List of the Call Hierarchy views in LRU order, where the most recently used view is at index 0.
*/
- private static List<CHViewPart> fLRUCallHierarchyViews= new ArrayList<CHViewPart>();
+ private static List<CHViewPart> fLRUCallHierarchyViews = new ArrayList<CHViewPart>();
private static int fViewCount;
private static final int MAX_HISTORY_SIZE = 10;
- private static List<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
+ private static List<ICElement> fHistoryEntries = new ArrayList<ICElement>(MAX_HISTORY_SIZE);
public static void setIsJUnitTest(boolean val) {
- sIsJUnitTest= val;
+ sIsJUnitTest = val;
}
public static void open(final IWorkbenchWindow window, final ICElement input) {
- if (input != null) {
- final Display display= Display.getCurrent();
+ if (input != null) {
+ final Display display = Display.getCurrent();
- Job job= new Job(CHMessages.CallHierarchyUI_label) {
- @Override
+ Job job = new Job(CHMessages.CallHierarchyUI_label) {
+ @Override
protected IStatus run(IProgressMonitor monitor) {
- final ICElement[] elems= findDefinitions(input);
+ final ICElement[] elems = findDefinitions(input);
if (elems != null && elems.length > 0) {
display.asyncExec(new Runnable() {
@Override
public void run() {
internalOpen(window, elems);
- }});
+ }
+ });
}
return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
- }
- }
-
- private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement input) {
- IWorkbenchPage page= window.getActivePage();
- try {
- CHViewPart viewPart = findLRUCallHierarchyViewPart(page); //find the first view which is not pinned
- String secondaryId = null;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ }
+ }
+
+ private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement input) {
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ CHViewPart viewPart = findLRUCallHierarchyViewPart(page); //find the first view which is not pinned
+ String secondaryId = null;
if (viewPart == null) {
if (page.findViewReference(CUIPlugin.ID_CALL_HIERARCHY) != null) { //all the current views are pinned, open a new instance
secondaryId = String.valueOf(++fViewCount);
@@ -117,16 +118,17 @@ public class CallHierarchyUI {
secondaryId = viewPart.getViewSite().getSecondaryId();
}
- viewPart = (CHViewPart) page.showView(CUIPlugin.ID_CALL_HIERARCHY, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
+ viewPart = (CHViewPart) page.showView(CUIPlugin.ID_CALL_HIERARCHY, secondaryId,
+ IWorkbenchPage.VIEW_ACTIVATE);
viewPart.setInput(input);
- return viewPart;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, window.getShell(), CHMessages.OpenCallHierarchyAction_label, null);
- }
- return null;
- }
-
- private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement[] input) {
+ return viewPart;
+ } catch (CoreException e) {
+ ExceptionHandler.handle(e, window.getShell(), CHMessages.OpenCallHierarchyAction_label, null);
+ }
+ return null;
+ }
+
+ private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement[] input) {
ICElement elem = null;
switch (input.length) {
case 0:
@@ -138,8 +140,8 @@ public class CallHierarchyUI {
if (sIsJUnitTest) {
throw new RuntimeException("ambiguous input"); //$NON-NLS-1$
}
- elem = OpenActionUtil.selectCElement(input, window.getShell(),
- CHMessages.CallHierarchyUI_label, CHMessages.CallHierarchyUI_selectMessage,
+ elem = OpenActionUtil.selectCElement(input, window.getShell(), CHMessages.CallHierarchyUI_label,
+ CHMessages.CallHierarchyUI_selectMessage,
CElementLabels.ALL_DEFAULT | CElementLabels.MF_POST_FILE_QUALIFIED, 0);
break;
}
@@ -149,26 +151,28 @@ public class CallHierarchyUI {
return null;
}
- public static void open(final ITextEditor editor, final ITextSelection sel) {
+ public static void open(final ITextEditor editor, final ITextSelection sel) {
if (editor != null) {
- ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+ ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager()
+ .getWorkingCopy(editor.getEditorInput());
if (inputCElement != null) {
- final ICProject project= inputCElement.getCProject();
+ final ICProject project = inputCElement.getCProject();
final IEditorInput editorInput = editor.getEditorInput();
- final Display display= Display.getCurrent();
+ final Display display = Display.getCurrent();
- Job job= new Job(CHMessages.CallHierarchyUI_label) {
+ Job job = new Job(CHMessages.CallHierarchyUI_label) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
StatusLineHandler.clearStatusLine(editor.getSite());
- final ICElement[] elems= findDefinitions(project, editorInput, sel);
+ final ICElement[] elems = findDefinitions(project, editorInput, sel);
if (elems.length > 0) {
display.asyncExec(new Runnable() {
@Override
public void run() {
internalOpen(editor.getSite().getWorkbenchWindow(), elems);
- }});
+ }
+ });
} else {
StatusLineHandler.showStatusLineMessage(editor.getSite(),
CHMessages.CallHierarchyUI_openFailureMessage);
@@ -178,34 +182,36 @@ public class CallHierarchyUI {
return e.getStatus();
}
}
+
@Override
public boolean belongsTo(Object family) {
- return family == CallHierarchyUI.class;
+ return family == CallHierarchyUI.class;
}
};
job.setUser(true);
job.schedule();
}
}
- }
+ }
private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel)
throws CoreException {
try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
index.acquireReadLock();
try {
- IASTName name= IndexUI.getSelectedName(editorInput, sel);
+ IASTName name = IndexUI.getSelectedName(editorInput, sel);
if (name != null) {
- IBinding binding= name.resolveBinding();
+ IBinding binding = name.resolveBinding();
if (!CallHierarchyUI.isRelevantForCallHierarchy(binding)) {
- for (IASTNode parent= name; parent != null; parent= parent.getParent()) {
+ for (IASTNode parent = name; parent != null; parent = parent.getParent()) {
if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
- ICPPASTFunctionCallExpression fcall= (ICPPASTFunctionCallExpression) parent.getParent();
+ ICPPASTFunctionCallExpression fcall = (ICPPASTFunctionCallExpression) parent
+ .getParent();
if (fcall != null) {
IASTImplicitName[] implicit = fcall.getImplicitNames();
if (implicit.length > 0)
- binding= implicit[0].resolveBinding();
+ binding = implicit[0].resolveBinding();
}
break;
}
@@ -213,26 +219,26 @@ public class CallHierarchyUI {
}
if (CallHierarchyUI.isRelevantForCallHierarchy(binding)) {
if (name.isDefinition()) {
- ICElement elem= IndexUI.getCElementForName(project, index, name);
+ ICElement elem = IndexUI.getCElementForName(project, index, name);
if (elem != null) {
return new ICElement[] { elem };
}
return NO_ELEMENTS;
}
- ICElement[] elems= IndexUI.findAllDefinitions(index, binding);
+ ICElement[] elems = IndexUI.findAllDefinitions(index, binding);
if (elems.length != 0)
return elems;
if (name.isDeclaration()) {
- ICElementHandle elem= IndexUI.getCElementForName(project, index, name);
+ ICElementHandle elem = IndexUI.getCElementForName(project, index, name);
if (elem != null) {
return new ICElement[] { elem };
}
return NO_ELEMENTS;
}
- ICElementHandle elem= IndexUI.findAnyDeclaration(index, project, binding);
+ ICElementHandle elem = IndexUI.findAnyDeclaration(index, project, binding);
if (elem != null) {
return new ICElement[] { elem };
}
@@ -254,46 +260,46 @@ public class CallHierarchyUI {
return NO_ELEMENTS;
}
- private static ICElement[] findSpecializationDeclaration(IBinding binding, ICProject project,
- IIndex index) throws CoreException {
+ private static ICElement[] findSpecializationDeclaration(IBinding binding, ICProject project, IIndex index)
+ throws CoreException {
while (binding instanceof ICPPSpecialization) {
- IBinding original= ((ICPPSpecialization) binding).getSpecializedBinding();
- ICElementHandle[] elems= IndexUI.findAllDefinitions(index, original);
+ IBinding original = ((ICPPSpecialization) binding).getSpecializedBinding();
+ ICElementHandle[] elems = IndexUI.findAllDefinitions(index, original);
if (elems.length == 0) {
- ICElementHandle elem= IndexUI.findAnyDeclaration(index, project, original);
+ ICElementHandle elem = IndexUI.findAnyDeclaration(index, project, original);
if (elem != null) {
- elems= new ICElementHandle[] { elem };
+ elems = new ICElementHandle[] { elem };
}
}
if (elems.length > 0) {
return elems;
}
- binding= original;
+ binding = original;
}
return NO_ELEMENTS;
}
public static ICElement[] findDefinitions(ICElement input) {
try {
- final ITranslationUnit tu= CModelUtil.getTranslationUnit(input);
+ final ITranslationUnit tu = CModelUtil.getTranslationUnit(input);
if (tu != null) {
- final ICProject project= tu.getCProject();
+ final ICProject project = tu.getCProject();
final IIndex index = CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
index.acquireReadLock();
try {
if (needToFindDefinition(input)) {
- IBinding binding= IndexUI.elementToBinding(index, input);
+ IBinding binding = IndexUI.elementToBinding(index, input);
if (binding != null) {
- ICElement[] result= IndexUI.findAllDefinitions(index, binding);
+ ICElement[] result = IndexUI.findAllDefinitions(index, binding);
if (result.length > 0) {
return result;
}
}
}
- IIndexName name= IndexUI.elementToName(index, input);
+ IIndexName name = IndexUI.elementToName(index, input);
if (name != null) {
- ICElementHandle handle= IndexUI.getCElementForName(tu, index, name);
+ ICElementHandle handle = IndexUI.getCElementForName(tu, index, name);
return new ICElement[] { handle };
}
} finally {
@@ -320,9 +326,7 @@ public class CallHierarchyUI {
}
public static boolean isRelevantForCallHierarchy(IBinding binding) {
- if (binding instanceof ICExternalBinding ||
- binding instanceof IEnumerator ||
- binding instanceof IFunction)
+ if (binding instanceof ICExternalBinding || binding instanceof IEnumerator || binding instanceof IFunction)
return true;
if (binding instanceof IVariable) {
@@ -360,7 +364,6 @@ public class CallHierarchyUI {
return false;
}
-
/**
* Adds the activated view part to the head of the list.
*
@@ -397,21 +400,21 @@ public class CallHierarchyUI {
* @return the Call Hierarchy view part to open or <code>null</code> if none found
*/
private static CHViewPart findLRUCallHierarchyViewPart(IWorkbenchPage page) {
- boolean viewFoundInPage= false;
+ boolean viewFoundInPage = false;
for (CHViewPart view : fLRUCallHierarchyViews) {
if (page.equals(view.getSite().getPage())) {
if (!view.isPinned()) {
return view;
}
- viewFoundInPage= true;
+ viewFoundInPage = true;
}
}
if (!viewFoundInPage) {
// Find unresolved views
- IViewReference[] viewReferences= page.getViewReferences();
+ IViewReference[] viewReferences = page.getViewReferences();
for (IViewReference curr : viewReferences) {
if (CUIPlugin.ID_CALL_HIERARCHY.equals(curr.getId()) && page.equals(curr.getPage())) {
- CHViewPart view= (CHViewPart)curr.getView(true);
+ CHViewPart view = (CHViewPart) curr.getView(true);
if (view != null && !view.isPinned()) {
return view;
}
@@ -431,12 +434,12 @@ public class CallHierarchyUI {
}
static public void updateHistory(ICElement input) {
- if (input != null) {
- fHistoryEntries.remove(input);
- fHistoryEntries.add(0, input);
- if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
- fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
- }
- }
+ if (input != null) {
+ fHistoryEntries.remove(input);
+ fHistoryEntries.add(0, input);
+ if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
+ fHistoryEntries.remove(MAX_HISTORY_SIZE - 1);
+ }
+ }
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java
index 00570cf0739..f47e1006897 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java
@@ -24,7 +24,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.extensions.ICalledByResult;
public class CalledByResult implements ICalledByResult {
- private Map<ICElement, List<IIndexName>> fElementToReferences= new HashMap<>();
+ private Map<ICElement, List<IIndexName>> fElementToReferences = new HashMap<>();
public ICElement[] getElements() {
Set<ICElement> elements = fElementToReferences.keySet();
@@ -32,15 +32,15 @@ public class CalledByResult implements ICalledByResult {
}
public IIndexName[] getReferences(ICElement calledElement) {
- List<IIndexName> references= fElementToReferences.get(calledElement);
+ List<IIndexName> references = fElementToReferences.get(calledElement);
return references.toArray(new IIndexName[references.size()]);
}
@Override
public void add(ICElement elem, IIndexName ref) {
- List<IIndexName> list= fElementToReferences.get(elem);
+ List<IIndexName> list = fElementToReferences.get(elem);
if (list == null) {
- list= new ArrayList<>();
+ list = new ArrayList<>();
fElementToReferences.put(elem, list);
}
list.add(ref);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java
index 5ebb8881269..b644675d1fc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java
@@ -24,7 +24,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.extensions.ICallToResult;
public class CallsToResult implements ICallToResult {
- private Map<CElementSet, List<IIndexName>> fElementSetsToReferences= new HashMap<>();
+ private Map<CElementSet, List<IIndexName>> fElementSetsToReferences = new HashMap<>();
public CElementSet[] getElementSets() {
Set<CElementSet> elementSets = fElementSetsToReferences.keySet();
@@ -32,16 +32,16 @@ public class CallsToResult implements ICallToResult {
}
public IIndexName[] getReferences(CElementSet elementSet) {
- List<IIndexName> references= fElementSetsToReferences.get(elementSet);
+ List<IIndexName> references = fElementSetsToReferences.get(elementSet);
return references.toArray(new IIndexName[references.size()]);
}
@Override
public void add(ICElement[] elems, IIndexName ref) {
- CElementSet key= new CElementSet(elems);
- List<IIndexName> list= fElementSetsToReferences.get(key);
+ CElementSet key = new CElementSet(elems);
+ List<IIndexName> list = fElementSetsToReferences.get(key);
if (list == null) {
- list= new ArrayList<>();
+ list = new ArrayList<>();
fElementSetsToReferences.put(key, list);
}
list.add(ref);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
index 811d2a212ca..2e803cc863b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import org.eclipse.core.runtime.IAdaptable;
@@ -35,23 +35,24 @@ public class OpenCallHierarchyAction extends SelectionDispatchAction {
setText(CHMessages.OpenCallHierarchyAction_label);
setToolTipText(CHMessages.OpenCallHierarchyAction_tooltip);
}
-
+
public OpenCallHierarchyAction(ITextEditor editor) {
this(editor.getSite());
- fEditor= editor;
- setEnabled(fEditor != null && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
+ fEditor = editor;
+ setEnabled(fEditor != null
+ && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
}
@Override
public void run(ITextSelection sel) {
CallHierarchyUI.open(fEditor, sel);
}
-
+
@Override
public void run(IStructuredSelection selection) {
if (!selection.isEmpty()) {
- Object selectedObject= selection.getFirstElement();
- ICElement elem= getAdapter(selectedObject, ICElement.class);
+ Object selectedObject = selection.getFirstElement();
+ ICElement elem = getAdapter(selectedObject, ICElement.class);
if (elem != null) {
CallHierarchyUI.open(getSite().getWorkbenchWindow(), elem);
}
@@ -61,16 +62,16 @@ public class OpenCallHierarchyAction extends SelectionDispatchAction {
@Override
public void selectionChanged(ITextSelection sel) {
}
-
+
@Override
public void selectionChanged(IStructuredSelection selection) {
if (selection.isEmpty()) {
setEnabled(false);
return;
}
-
- Object selectedObject= selection.getFirstElement();
- ICElement elem= getAdapter(selectedObject, ICElement.class);
+
+ Object selectedObject = selection.getFirstElement();
+ ICElement elem = getAdapter(selectedObject, ICElement.class);
if (elem != null) {
setEnabled(isValidElement(elem));
} else {
@@ -97,7 +98,7 @@ public class OpenCallHierarchyAction extends SelectionDispatchAction {
return (T) object;
}
if (object instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) object;
+ IAdaptable adaptable = (IAdaptable) object;
return adaptable.getAdapter(desiredClass);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java
index 23e7f75b6e4..cbcbebb8a9f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import org.eclipse.jface.action.IAction;
@@ -33,10 +33,10 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionDelegate {
- private static final int[] VISIBLE_TYPES = {
- ICElement.C_FUNCTION, ICElement.C_METHOD, ICElement.C_VARIABLE, ICElement.C_ENUMERATOR,
- ICElement.C_FUNCTION_DECLARATION, ICElement.C_METHOD_DECLARATION, ICElement.C_VARIABLE_DECLARATION };
-
+ private static final int[] VISIBLE_TYPES = { ICElement.C_FUNCTION, ICElement.C_METHOD, ICElement.C_VARIABLE,
+ ICElement.C_ENUMERATOR, ICElement.C_FUNCTION_DECLARATION, ICElement.C_METHOD_DECLARATION,
+ ICElement.C_VARIABLE_DECLARATION };
+
private IWorkbenchWindow fWorkbenchWindow;
public OpenElementInCallHierarchyAction() {
@@ -49,15 +49,15 @@ public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionD
int result = dialog.open();
if (result != IDialogConstants.OK_ID)
return;
-
+
ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
if (info == null)
return;
-
- ICElement[] elements= null;
+
+ ICElement[] elements = null;
ITypeReference location = info.getResolvedReference();
if (location != null) {
- elements= location.getCElements();
+ elements = location.getCElements();
}
if (elements == null || elements.length == 0) {
String title = CHMessages.OpenElementInCallHierarchyAction_errorDlgTitle;
@@ -68,7 +68,7 @@ public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionD
CallHierarchyUI.open(fWorkbenchWindow, elements[0]);
}
}
-
+
private void configureDialog(ElementSelectionDialog dialog) {
dialog.setDialogSettings(getClass().getName());
dialog.setVisibleTypes(VISIBLE_TYPES);
@@ -77,13 +77,13 @@ public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionD
dialog.setMessage(CHMessages.OpenElementInCallHierarchyAction_message);
if (fWorkbenchWindow != null) {
- IWorkbenchPage page= fWorkbenchWindow.getActivePage();
+ IWorkbenchPage page = fWorkbenchWindow.getActivePage();
if (page != null) {
- IWorkbenchPart part= page.getActivePart();
+ IWorkbenchPart part = page.getActivePart();
if (part instanceof ITextEditor) {
- ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection();
+ ISelection sel = ((ITextEditor) part).getSelectionProvider().getSelection();
if (sel instanceof ITextSelection) {
- String txt= ((ITextSelection) sel).getText();
+ String txt = ((ITextSelection) sel).getText();
if (txt.length() > 0 && txt.length() < 80) {
dialog.setFilter(txt, true);
}
@@ -99,14 +99,14 @@ public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionD
@Override
public void dispose() {
- fWorkbenchWindow= null;
+ fWorkbenchWindow = null;
}
-
+
@Override
public void init(IWorkbenchWindow window) {
- fWorkbenchWindow= window;
+ fWorkbenchWindow = window;
}
-
+
@Override
public void selectionChanged(IAction action, ISelection selection) {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java
index 75b8689cae3..26c618cd508 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java
@@ -25,20 +25,20 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
* @since 4.0
*/
class ReferenceVisitor extends ASTVisitor {
- private ArrayList<IASTName> fReferences= new ArrayList<IASTName>();
+ private ArrayList<IASTName> fReferences = new ArrayList<IASTName>();
private int fOffset;
private int fEndOffset;
private String fFileName;
-
+
ReferenceVisitor(String fileName, int offset, int length) {
- shouldVisitNames= true;
- shouldVisitDeclarations= true;
-
- fFileName= fileName;
- fOffset= offset;
- fEndOffset= offset + length;
+ shouldVisitNames = true;
+ shouldVisitDeclarations = true;
+
+ fFileName = fileName;
+ fOffset = offset;
+ fEndOffset = offset + length;
}
-
+
public IASTName[] getReferences() {
return fReferences.toArray(new IASTName[fReferences.size()]);
}
@@ -46,12 +46,12 @@ class ReferenceVisitor extends ASTVisitor {
@Override
public int visit(IASTName name) {
if (name.isReference()) {
- IASTFileLocation loc= name.getFileLocation();
+ IASTFileLocation loc = name.getFileLocation();
if (!loc.getFileName().equals(fFileName)) {
return PROCESS_SKIP;
}
- int offset= loc.getNodeOffset();
- if (fOffset <= offset && offset+loc.getNodeLength() <= fEndOffset) {
+ int offset = loc.getNodeOffset();
+ if (fOffset <= offset && offset + loc.getNodeLength() <= fEndOffset) {
fReferences.add(name);
}
}
@@ -60,12 +60,12 @@ class ReferenceVisitor extends ASTVisitor {
@Override
public int visit(IASTDeclaration declaration) {
- IASTFileLocation loc= declaration.getFileLocation();
+ IASTFileLocation loc = declaration.getFileLocation();
if (loc != null) {
if (!loc.getFileName().equals(fFileName)) {
return PROCESS_SKIP;
}
- int offset= loc.getNodeOffset();
+ int offset = loc.getNodeOffset();
if (offset + loc.getNodeLength() <= fOffset || fEndOffset <= offset) {
return PROCESS_SKIP;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java
index 5c3ffd34469..b6cf81e7a42 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java
@@ -34,7 +34,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICColorConstants;
import org.eclipse.cdt.ui.text.ICPartitions;
-
/**
* Abstract implementation of a merge viewer.
*/
@@ -59,7 +58,7 @@ abstract class AbstractMergeViewer extends TextMergeViewer {
/**
* Create a new merge viewer.
- *
+ *
* @param parent
* @param style
* @param configuration
@@ -69,11 +68,11 @@ abstract class AbstractMergeViewer extends TextMergeViewer {
IPreferenceStore store = getPreferenceStore();
- fUseSystemColors= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
- if (! fUseSystemColors) {
- RGB bg= createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+ fUseSystemColors = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+ if (!fUseSystemColors) {
+ RGB bg = createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
setBackgroundColor(bg);
- RGB fg= createColor(store, ICColorConstants.C_DEFAULT);
+ RGB fg = createColor(store, ICColorConstants.C_DEFAULT);
setForegroundColor(fg);
}
@@ -81,8 +80,8 @@ abstract class AbstractMergeViewer extends TextMergeViewer {
protected IPreferenceStore getPreferenceStore() {
if (fPreferenceStore == null) {
- fPreferenceStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
- fPreferenceChangeListener= new IPropertyChangeListener() {
+ fPreferenceStore = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ fPreferenceChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
handlePropertyChange(event);
@@ -97,38 +96,39 @@ abstract class AbstractMergeViewer extends TextMergeViewer {
protected void handleDispose(DisposeEvent event) {
if (fPreferenceChangeListener != null) {
fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener);
- fPreferenceChangeListener= null;
+ fPreferenceChangeListener = null;
}
super.handleDispose(event);
}
protected void handlePropertyChange(PropertyChangeEvent event) {
-
- String key= event.getProperty();
-
+
+ String key = event.getProperty();
+
if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) {
-
+
if (!fUseSystemColors) {
- RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+ RGB bg = createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
setBackgroundColor(bg);
}
-
+
} else if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
-
- fUseSystemColors= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+
+ fUseSystemColors = fPreferenceStore
+ .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
if (fUseSystemColors) {
setBackgroundColor(null);
setForegroundColor(null);
} else {
- RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+ RGB bg = createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
setBackgroundColor(bg);
- RGB fg= createColor(fPreferenceStore, ICColorConstants.C_DEFAULT);
+ RGB fg = createColor(fPreferenceStore, ICColorConstants.C_DEFAULT);
setForegroundColor(fg);
}
} else if (key.equals(ICColorConstants.C_DEFAULT)) {
-
+
if (!fUseSystemColors) {
- RGB fg= createColor(fPreferenceStore, ICColorConstants.C_DEFAULT);
+ RGB fg = createColor(fPreferenceStore, ICColorConstants.C_DEFAULT);
setForegroundColor(fg);
}
}
@@ -142,7 +142,7 @@ abstract class AbstractMergeViewer extends TextMergeViewer {
@Override
protected void configureTextViewer(TextViewer textViewer) {
if (textViewer instanceof SourceViewer) {
- ((SourceViewer)textViewer).configure(getSourceViewerConfiguration());
+ ((SourceViewer) textViewer).configure(getSourceViewerConfiguration());
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java
index 85e4b5a7447..00caeb25eaf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java
@@ -22,7 +22,7 @@ import org.eclipse.swt.widgets.Composite;
/**
* Creates a merge viewer for assembly code.
*/
-public class AsmContentViewerCreator implements IViewerCreator {
+public class AsmContentViewerCreator implements IViewerCreator {
/*
* @see org.eclipse.compare.IViewerCreator#createViewer(org.eclipse.swt.widgets.Composite, org.eclipse.compare.CompareConfiguration)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java
index ccd938e4d5f..796c8103f4d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java
@@ -31,13 +31,13 @@ import org.eclipse.cdt.ui.text.IColorManager;
*/
public class AsmMergeViewer extends AbstractMergeViewer {
- private static final String TITLE= "AsmMergeViewer.title"; //$NON-NLS-1$
+ private static final String TITLE = "AsmMergeViewer.title"; //$NON-NLS-1$
AsmSourceViewerConfiguration fSourceViewerConfiguration;
/**
* Create a new assembly merge viewer.
- *
+ *
* @param parent
* @param style
* @param configuration
@@ -49,9 +49,10 @@ public class AsmMergeViewer extends AbstractMergeViewer {
@Override
protected SourceViewerConfiguration getSourceViewerConfiguration() {
if (fSourceViewerConfiguration == null) {
- IPreferenceStore store= getPreferenceStore();
+ IPreferenceStore store = getPreferenceStore();
final IColorManager colorManager = CDTUITools.getColorManager();
- fSourceViewerConfiguration= new AsmSourceViewerConfiguration(colorManager, store, null, ICPartitions.C_PARTITIONING);
+ fSourceViewerConfiguration = new AsmSourceViewerConfiguration(colorManager, store, null,
+ ICPartitions.C_PARTITIONING);
}
return fSourceViewerConfiguration;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java
index df786bde54d..c69466d8944 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java
@@ -17,19 +17,16 @@ package org.eclipse.cdt.internal.ui.compare;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
-
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.IViewerCreator;
-
import org.eclipse.jface.viewers.Viewer;
-
/**
* Required when creating a CMergeViewer from the plugin.xml file.
*/
public class CContentViewerCreator implements IViewerCreator {
-
+
@Override
public Viewer createViewer(Composite parent, CompareConfiguration mp) {
return new CMergeViewer(parent, SWT.NULL, mp);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java
index 734adc6340a..fe19f4e1105 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -34,11 +34,11 @@ import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
* A merge viewer for C/C++ code.
*/
public class CMergeViewer extends AbstractMergeViewer {
-
- private static final String TITLE= "CMergeViewer.title"; //$NON-NLS-1$
+
+ private static final String TITLE = "CMergeViewer.title"; //$NON-NLS-1$
CSourceViewerConfiguration fSourceViewerConfiguration;
-
+
public CMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
super(parent, styles, mp);
}
@@ -46,9 +46,10 @@ public class CMergeViewer extends AbstractMergeViewer {
@Override
protected SourceViewerConfiguration getSourceViewerConfiguration() {
if (fSourceViewerConfiguration == null) {
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
IPreferenceStore store = getPreferenceStore();
- fSourceViewerConfiguration = new CSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING);
+ fSourceViewerConfiguration = new CSourceViewerConfiguration(tools.getColorManager(), store, null,
+ ICPartitions.C_PARTITIONING);
}
return fSourceViewerConfiguration;
}
@@ -56,7 +57,7 @@ public class CMergeViewer extends AbstractMergeViewer {
@Override
protected IDocumentPartitioner getDocumentPartitioner() {
// use workspace default for highlighting doc comments in compare viewer
- IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
+ IDocCommentOwner owner = DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java
index 22d692bc869..9cd150ed66e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java
@@ -24,7 +24,7 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.graphics.Image;
/**
- *
+ *
*/
class CNode extends DocumentRangeNode implements ITypedElement {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
index b62c97a01ed..38117dd5405 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
@@ -76,7 +76,7 @@ public class CStructureCreator extends StructureCreator {
@Override
public String getContents(Object node, boolean ignoreWhitespace) {
if (node instanceof IDocumentRange) {
- IDocumentRange documentRange= (IDocumentRange)node;
+ IDocumentRange documentRange = (IDocumentRange) node;
final Position range = documentRange.getRange();
try {
return documentRange.getDocument().get(range.getOffset(), range.getLength());
@@ -97,28 +97,27 @@ public class CStructureCreator extends StructureCreator {
* @see org.eclipse.compare.structuremergeviewer.StructureCreator#createStructureComparator(java.lang.Object, org.eclipse.jface.text.IDocument, org.eclipse.compare.ISharedDocumentAdapter, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- protected IStructureComparator createStructureComparator(Object element,
- IDocument document, ISharedDocumentAdapter sharedDocumentAdapter,
- IProgressMonitor monitor) throws CoreException {
+ protected IStructureComparator createStructureComparator(Object element, IDocument document,
+ ISharedDocumentAdapter sharedDocumentAdapter, IProgressMonitor monitor) throws CoreException {
- DocumentRangeNode root= new StructureRootNode(document, element, this, sharedDocumentAdapter);
+ DocumentRangeNode root = new StructureRootNode(document, element, this, sharedDocumentAdapter);
// don't follow inclusions
IncludeFileContentProvider contentProvider = IncludeFileContentProvider.getEmptyFilesProvider();
-
+
// empty scanner info
- IScannerInfo scanInfo= new ScannerInfo();
-
+ IScannerInfo scanInfo = new ScannerInfo();
+
// determine the language
- boolean isSource[]= {false};
- ILanguage language= determineLanguage(element, isSource);
-
+ boolean isSource[] = { false };
+ ILanguage language = determineLanguage(element, isSource);
+
FileContent content = FileContent.create("<text>", isSource[0], document.get().toCharArray()); //$NON-NLS-1$
-
+
try {
- IASTTranslationUnit ast = language.getASTTranslationUnit(content, scanInfo, contentProvider, null,
- 0, ParserUtil.getParserLogService());
- CStructureCreatorVisitor structureCreator= new CStructureCreatorVisitor(root);
+ IASTTranslationUnit ast = language.getASTTranslationUnit(content, scanInfo, contentProvider, null, 0,
+ ParserUtil.getParserLogService());
+ CStructureCreatorVisitor structureCreator = new CStructureCreatorVisitor(root);
// build structure
ast.accept(structureCreator);
} catch (CoreException exc) {
@@ -130,20 +129,20 @@ public class CStructureCreator extends StructureCreator {
/**
* Try to determine the <code>ILanguage</code> for the given input element.
- *
+ *
* @param element
* @return a language instance
*/
private ILanguage determineLanguage(Object element, boolean[] isSource) {
- ILanguage language= null;
+ ILanguage language = null;
if (element instanceof ResourceNode) {
- IResource resource= ((ResourceNode)element).getResource();
+ IResource resource = ((ResourceNode) element).getResource();
if (resource.getType() == IResource.FILE) {
- ITranslationUnit tUnit= (ITranslationUnit)CoreModel.getDefault().create(resource);
+ ITranslationUnit tUnit = (ITranslationUnit) CoreModel.getDefault().create(resource);
if (tUnit != null) {
try {
- language= tUnit.getLanguage();
- isSource[0]= tUnit.isSourceUnit();
+ language = tUnit.getLanguage();
+ isSource[0] = tUnit.isSourceUnit();
} catch (CoreException exc) {
// silently ignored
}
@@ -151,7 +150,7 @@ public class CStructureCreator extends StructureCreator {
}
}
if (language == null) {
- language= GPPLanguage.getDefault();
+ language = GPPLanguage.getDefault();
}
return language;
}
@@ -160,26 +159,26 @@ public class CStructureCreator extends StructureCreator {
protected String getDocumentPartitioning() {
return ICPartitions.C_PARTITIONING;
}
-
+
@Override
protected IDocumentPartitioner getDocumentPartitioner() {
// use workspace default for highlighting doc comments in compare viewer
- IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
+ IDocCommentOwner owner = DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
}
-
+
private static String readString(IStreamContentAccessor sa) throws CoreException {
- InputStream is= sa.getContents();
+ InputStream is = sa.getContents();
if (is != null) {
- String encoding= null;
+ String encoding = null;
if (sa instanceof IEncodedStreamContentAccessor) {
try {
- encoding= ((IEncodedStreamContentAccessor) sa).getCharset();
+ encoding = ((IEncodedStreamContentAccessor) sa).getCharset();
} catch (Exception e) {
}
}
if (encoding == null)
- encoding= ResourcesPlugin.getEncoding();
+ encoding = ResourcesPlugin.getEncoding();
return readString(is, encoding);
}
return null;
@@ -188,18 +187,18 @@ public class CStructureCreator extends StructureCreator {
private static String readString(InputStream is, String encoding) {
if (is == null)
return null;
- BufferedReader reader= null;
+ BufferedReader reader = null;
try {
- StringBuilder buffer= new StringBuilder();
- char[] part= new char[2048];
- int read= 0;
- reader= new BufferedReader(new InputStreamReader(is, encoding));
+ StringBuilder buffer = new StringBuilder();
+ char[] part = new char[2048];
+ int read = 0;
+ reader = new BufferedReader(new InputStreamReader(is, encoding));
- while ((read= reader.read(part)) != -1)
+ while ((read = reader.read(part)) != -1)
buffer.append(part, 0, read);
-
+
return buffer.toString();
-
+
} catch (IOException ex) {
// NeedWork
} finally {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java
index 83b7af58292..133a77eb59f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java
@@ -63,16 +63,16 @@ import org.eclipse.cdt.internal.ui.CUIMessages;
*/
class CStructureCreatorVisitor extends ASTVisitor {
- private static final String TRANSLATION_UNIT_NAME = CUIMessages.CStructureCreatorVisitor_translationUnitName;
- private static final String ANONYMOUS_NAME= CoreModelMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$
-
+ private static final String TRANSLATION_UNIT_NAME = CUIMessages.CStructureCreatorVisitor_translationUnitName;
+ private static final String ANONYMOUS_NAME = CoreModelMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$
+
private Stack<DocumentRangeNode> fStack = new Stack<DocumentRangeNode>();
private IDocument fDocument;
private String fTranslationUnitFileName;
/**
* Create visitor adding nodes to given root.
- *
+ *
* @param root
*/
public CStructureCreatorVisitor(DocumentRangeNode root) {
@@ -80,10 +80,10 @@ class CStructureCreatorVisitor extends ASTVisitor {
fStack.clear();
fStack.push(root);
// visitor options
- shouldVisitTranslationUnit= true;
- shouldVisitDeclarations= true;
- shouldVisitEnumerators=true;
- shouldVisitNamespaces=true;
+ shouldVisitTranslationUnit = true;
+ shouldVisitDeclarations = true;
+ shouldVisitEnumerators = true;
+ shouldVisitNamespaces = true;
}
/*
@@ -91,37 +91,39 @@ class CStructureCreatorVisitor extends ASTVisitor {
*/
@Override
public int visit(IASTTranslationUnit tu) {
- fTranslationUnitFileName= tu.getFilePath();
+ fTranslationUnitFileName = tu.getFilePath();
push(ICElement.C_UNIT, TRANSLATION_UNIT_NAME, 0);
- // TODO fix ordering of includes and macros
+ // TODO fix ordering of includes and macros
// includes
- final IASTPreprocessorIncludeStatement[] includeDirectives= tu.getIncludeDirectives();
- for (int i= 0; i < includeDirectives.length; i++) {
- IASTPreprocessorIncludeStatement includeDirective= includeDirectives[i];
+ final IASTPreprocessorIncludeStatement[] includeDirectives = tu.getIncludeDirectives();
+ for (int i = 0; i < includeDirectives.length; i++) {
+ IASTPreprocessorIncludeStatement includeDirective = includeDirectives[i];
if (isLocalToFile(includeDirective)) {
- push(ICElement.C_INCLUDE, new String(includeDirective.getName().toCharArray()), getStartOffset(includeDirective));
+ push(ICElement.C_INCLUDE, new String(includeDirective.getName().toCharArray()),
+ getStartOffset(includeDirective));
pop(getEndOffset(includeDirective));
}
}
// macros
- final IASTPreprocessorMacroDefinition[] macroDefinitions= tu.getMacroDefinitions();
- for (int i= 0; i < macroDefinitions.length; i++) {
- IASTPreprocessorMacroDefinition macroDefinition= macroDefinitions[i];
+ final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
+ for (int i = 0; i < macroDefinitions.length; i++) {
+ IASTPreprocessorMacroDefinition macroDefinition = macroDefinitions[i];
if (isLocalToFile(macroDefinition)) {
- push(ICElement.C_MACRO, new String(macroDefinition.getName().toCharArray()), getStartOffset(macroDefinition));
+ push(ICElement.C_MACRO, new String(macroDefinition.getName().toCharArray()),
+ getStartOffset(macroDefinition));
pop(getEndOffset(macroDefinition));
}
}
-
+
return super.visit(tu);
}
/**
- * Test whether given AST node is local to the source file
+ * Test whether given AST node is local to the source file
* and not part of an inclusion.
- *
+ *
* @param node
* @return <code>true</code> if the node is part of the source file.
*/
@@ -131,46 +133,46 @@ class CStructureCreatorVisitor extends ASTVisitor {
/**
* Compute the start offset of given AST node.
- *
+ *
* @param node
* @return
*/
private int getStartOffset(IASTNode node) {
- IASTFileLocation fileLocation= getMinFileLocation(node.getNodeLocations());
+ IASTFileLocation fileLocation = getMinFileLocation(node.getNodeLocations());
if (fileLocation != null) {
return fileLocation.getNodeOffset();
}
- DocumentRangeNode container= getCurrentContainer();
- Object[] children= container.getChildren();
+ DocumentRangeNode container = getCurrentContainer();
+ Object[] children = container.getChildren();
if (children != null && children.length > 0) {
- Position prevRange= ((DocumentRangeNode)children[children.length - 1]).getRange();
+ Position prevRange = ((DocumentRangeNode) children[children.length - 1]).getRange();
return prevRange.getOffset() + prevRange.getLength();
}
// fallback: use container range start
- Position containerRange= container.getRange();
+ Position containerRange = container.getRange();
return containerRange.getOffset();
}
/**
* Compute the end offset of give AST node.
- *
+ *
* @param node
* @return
*/
private int getEndOffset(IASTNode node) {
- IASTFileLocation fileLocation= getMaxFileLocation(node.getNodeLocations());
+ IASTFileLocation fileLocation = getMaxFileLocation(node.getNodeLocations());
if (fileLocation != null) {
return fileLocation.getNodeOffset() + fileLocation.getNodeLength();
}
// fallback: use container range end
- DocumentRangeNode container= getCurrentContainer();
- Position containerRange= container.getRange();
+ DocumentRangeNode container = getCurrentContainer();
+ Position containerRange = container.getRange();
return containerRange.getOffset() + containerRange.getLength();
}
-/*
- * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
- */
+ /*
+ * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
+ */
@Override
public int leave(IASTTranslationUnit tu) {
super.leave(tu);
@@ -178,42 +180,42 @@ class CStructureCreatorVisitor extends ASTVisitor {
pop(fDocument.getLength());
return PROCESS_SKIP;
}
-
+
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
*/
@Override
public int visit(IASTDeclaration node) {
- boolean isTemplateDecl= isTemplateDecl(node);
- final int startOffset= isTemplateDecl ? getStartOffset(node.getParent()) : getStartOffset(node);
- final int endOffset= getEndOffset(node);
+ boolean isTemplateDecl = isTemplateDecl(node);
+ final int startOffset = isTemplateDecl ? getStartOffset(node.getParent()) : getStartOffset(node);
+ final int endOffset = getEndOffset(node);
if (node instanceof IASTFunctionDefinition) {
- IASTFunctionDefinition functionDef= (IASTFunctionDefinition)node;
+ IASTFunctionDefinition functionDef = (IASTFunctionDefinition) node;
final int nodeType;
if (inClassBody()) {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD : ICElement.C_METHOD;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_METHOD : ICElement.C_METHOD;
} else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION : ICElement.C_FUNCTION;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION : ICElement.C_FUNCTION;
}
push(nodeType, getDeclaratorName(functionDef.getDeclarator()), startOffset);
pop(endOffset);
return PROCESS_SKIP;
} else if (node instanceof IASTSimpleDeclaration) {
- IASTSimpleDeclaration simpleDecl= (IASTSimpleDeclaration)node;
- IASTDeclSpecifier declSpec= simpleDecl.getDeclSpecifier();
+ IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) node;
+ IASTDeclSpecifier declSpec = simpleDecl.getDeclSpecifier();
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
- ICPPASTCompositeTypeSpecifier compositeTypeSpec= (ICPPASTCompositeTypeSpecifier)declSpec;
- final String nodeName= getTypeName(compositeTypeSpec);
+ ICPPASTCompositeTypeSpecifier compositeTypeSpec = (ICPPASTCompositeTypeSpecifier) declSpec;
+ final String nodeName = getTypeName(compositeTypeSpec);
final int nodeType;
switch (compositeTypeSpec.getKey()) {
case IASTCompositeTypeSpecifier.k_struct:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
break;
case IASTCompositeTypeSpecifier.k_union:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
break;
case ICPPASTCompositeTypeSpecifier.k_class:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
break;
default:
assert false : "Unexpected composite type specifier"; //$NON-NLS-1$
@@ -221,14 +223,14 @@ class CStructureCreatorVisitor extends ASTVisitor {
}
push(nodeType, nodeName, startOffset);
} else if (declSpec instanceof IASTEnumerationSpecifier) {
- IASTEnumerationSpecifier enumSpecifier= (IASTEnumerationSpecifier)declSpec;
+ IASTEnumerationSpecifier enumSpecifier = (IASTEnumerationSpecifier) declSpec;
push(ICElement.C_ENUMERATION, getEnumerationName(enumSpecifier), startOffset);
} else {
- IASTDeclarator[] declarators= simpleDecl.getDeclarators();
+ IASTDeclarator[] declarators = simpleDecl.getDeclarators();
for (int i = 0; i < declarators.length; i++) {
- IASTDeclarator declarator= declarators[i];
- int declStartOffset= declarators.length == 1 ? startOffset : getStartOffset(declarator);
- int declEndOffset= declarators.length == 1 ? endOffset : getEndOffset(declarator);
+ IASTDeclarator declarator = declarators[i];
+ int declStartOffset = declarators.length == 1 ? startOffset : getStartOffset(declarator);
+ int declEndOffset = declarators.length == 1 ? endOffset : getEndOffset(declarator);
final String nodeName = getDeclaratorName(declarator);
if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
push(ICElement.C_TYPEDEF, nodeName, declStartOffset);
@@ -236,21 +238,23 @@ class CStructureCreatorVisitor extends ASTVisitor {
} else if (declarator instanceof IASTFunctionDeclarator && !hasNestedPointerOperators(declarator)) {
final int nodeType;
if (inClassBody()) {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD_DECLARATION : ICElement.C_METHOD_DECLARATION;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_METHOD_DECLARATION
+ : ICElement.C_METHOD_DECLARATION;
} else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION_DECLARATION : ICElement.C_FUNCTION_DECLARATION;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION_DECLARATION
+ : ICElement.C_FUNCTION_DECLARATION;
}
push(nodeType, nodeName, declStartOffset);
pop(declEndOffset);
} else if (declarator != null) {
final int nodeType;
if (inClassBody()) {
- nodeType= ICElement.C_FIELD;
+ nodeType = ICElement.C_FIELD;
} else {
if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) {
- nodeType= ICElement.C_VARIABLE_DECLARATION;
+ nodeType = ICElement.C_VARIABLE_DECLARATION;
} else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_VARIABLE : ICElement.C_VARIABLE;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_VARIABLE : ICElement.C_VARIABLE;
}
}
push(nodeType, nodeName, declStartOffset);
@@ -267,11 +271,11 @@ class CStructureCreatorVisitor extends ASTVisitor {
} else if (node instanceof ICPPASTNamespaceAlias) {
// ignored
} else if (node instanceof ICPPASTUsingDeclaration) {
- ICPPASTUsingDeclaration usingDecl= (ICPPASTUsingDeclaration)node;
+ ICPPASTUsingDeclaration usingDecl = (ICPPASTUsingDeclaration) node;
push(ICElement.C_USING, ASTStringUtil.getQualifiedName(usingDecl.getName()), startOffset);
pop(endOffset);
} else if (node instanceof ICPPASTUsingDirective) {
- ICPPASTUsingDirective usingDirective= (ICPPASTUsingDirective)node;
+ ICPPASTUsingDirective usingDirective = (ICPPASTUsingDirective) node;
push(ICElement.C_USING, ASTStringUtil.getQualifiedName(usingDirective.getQualifiedName()), startOffset);
pop(endOffset);
} else if (node instanceof ICPPASTLinkageSpecification) {
@@ -306,41 +310,41 @@ class CStructureCreatorVisitor extends ASTVisitor {
pop(getEndOffset(enumerator));
return super.visit(enumerator);
}
-
+
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
*/
@Override
public int leave(IASTDeclaration node) {
super.leave(node);
- boolean isTemplateDecl= isTemplateDecl(node);
- final int endOffset= isTemplateDecl ? getEndOffset(node.getParent()) : getEndOffset(node);
+ boolean isTemplateDecl = isTemplateDecl(node);
+ final int endOffset = isTemplateDecl ? getEndOffset(node.getParent()) : getEndOffset(node);
if (node instanceof IASTFunctionDefinition) {
final int nodeType;
if (inClassBody()) {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD : ICElement.C_METHOD;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_METHOD : ICElement.C_METHOD;
} else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION : ICElement.C_FUNCTION;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION : ICElement.C_FUNCTION;
}
assert getCurrentContainer().getTypeCode() == nodeType;
pop(endOffset);
} else if (node instanceof IASTSimpleDeclaration) {
- IASTSimpleDeclaration simpleDecl= (IASTSimpleDeclaration)node;
- IASTDeclSpecifier declSpec= simpleDecl.getDeclSpecifier();
- boolean isCompositeType= false;
+ IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) node;
+ IASTDeclSpecifier declSpec = simpleDecl.getDeclSpecifier();
+ boolean isCompositeType = false;
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
- isCompositeType= true;
- ICPPASTCompositeTypeSpecifier compositeTypeSpec= (ICPPASTCompositeTypeSpecifier)declSpec;
+ isCompositeType = true;
+ ICPPASTCompositeTypeSpecifier compositeTypeSpec = (ICPPASTCompositeTypeSpecifier) declSpec;
final int nodeType;
switch (compositeTypeSpec.getKey()) {
case IASTCompositeTypeSpecifier.k_struct:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
break;
case IASTCompositeTypeSpecifier.k_union:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
break;
case ICPPASTCompositeTypeSpecifier.k_class:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
break;
default:
assert false : "Unexpected composite type specifier"; //$NON-NLS-1$
@@ -349,38 +353,40 @@ class CStructureCreatorVisitor extends ASTVisitor {
assert getCurrentContainer().getTypeCode() == nodeType;
pop(isTemplateDecl ? endOffset : getEndOffset(declSpec));
} else if (declSpec instanceof IASTEnumerationSpecifier) {
- isCompositeType= true;
+ isCompositeType = true;
assert getCurrentContainer().getTypeCode() == ICElement.C_ENUMERATION;
pop(getEndOffset(declSpec));
}
if (isCompositeType) {
- IASTDeclarator[] declarators= simpleDecl.getDeclarators();
- for (int i= 0; i < declarators.length; i++) {
- IASTDeclarator declarator= declarators[i];
- final String nodeName= getDeclaratorName(declarator);
- final int declStartOffset= getStartOffset(declarator);
- final int declEndOffset= getEndOffset(declarator);
+ IASTDeclarator[] declarators = simpleDecl.getDeclarators();
+ for (int i = 0; i < declarators.length; i++) {
+ IASTDeclarator declarator = declarators[i];
+ final String nodeName = getDeclaratorName(declarator);
+ final int declStartOffset = getStartOffset(declarator);
+ final int declEndOffset = getEndOffset(declarator);
if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
push(ICElement.C_TYPEDEF, nodeName, declStartOffset);
pop(declEndOffset);
} else if (declarator instanceof IASTFunctionDeclarator && !hasNestedPointerOperators(declarator)) {
final int nodeType;
if (inClassBody()) {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD_DECLARATION : ICElement.C_METHOD_DECLARATION;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_METHOD_DECLARATION
+ : ICElement.C_METHOD_DECLARATION;
} else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION_DECLARATION : ICElement.C_FUNCTION_DECLARATION;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION_DECLARATION
+ : ICElement.C_FUNCTION_DECLARATION;
}
push(nodeType, nodeName, declStartOffset);
pop(declEndOffset);
} else if (declarator != null) {
final int nodeType;
if (inClassBody()) {
- nodeType= ICElement.C_FIELD;
+ nodeType = ICElement.C_FIELD;
} else {
if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) {
- nodeType= ICElement.C_VARIABLE_DECLARATION;
+ nodeType = ICElement.C_VARIABLE_DECLARATION;
} else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_VARIABLE : ICElement.C_VARIABLE;
+ nodeType = isTemplateDecl ? ICElement.C_TEMPLATE_VARIABLE : ICElement.C_VARIABLE;
}
}
push(nodeType, nodeName, declStartOffset);
@@ -413,7 +419,7 @@ class CStructureCreatorVisitor extends ASTVisitor {
}
return PROCESS_CONTINUE;
}
-
+
/*
* @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#leave(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
*/
@@ -433,7 +439,7 @@ class CStructureCreatorVisitor extends ASTVisitor {
*/
private void push(int type, String name, int declarationStart) {
if (name.length() == 0) {
- name= ANONYMOUS_NAME;
+ name = ANONYMOUS_NAME;
}
fStack.push(new CNode(getCurrentContainer(), type, name, declarationStart, 0));
}
@@ -443,30 +449,26 @@ class CStructureCreatorVisitor extends ASTVisitor {
* and pops it off the stack.
*/
private void pop(int declarationEnd) {
- DocumentRangeNode current= getCurrentContainer();
+ DocumentRangeNode current = getCurrentContainer();
current.setAppendPosition(declarationEnd);
current.setLength(declarationEnd - current.getRange().getOffset());
fStack.pop();
}
-
/**
* @return <code>true</code> if the current container is class-like.
*/
private boolean inClassBody() {
- int typeCode= getCurrentContainer().getTypeCode();
- return typeCode == ICElement.C_CLASS
- || typeCode == ICElement.C_TEMPLATE_CLASS
- || typeCode == ICElement.C_STRUCT
- || typeCode == ICElement.C_TEMPLATE_STRUCT
- || typeCode == ICElement.C_UNION
+ int typeCode = getCurrentContainer().getTypeCode();
+ return typeCode == ICElement.C_CLASS || typeCode == ICElement.C_TEMPLATE_CLASS || typeCode == ICElement.C_STRUCT
+ || typeCode == ICElement.C_TEMPLATE_STRUCT || typeCode == ICElement.C_UNION
|| typeCode == ICElement.C_TEMPLATE_UNION;
}
/**
* Test whether the given declaration is a templated declaration.
- *
- * @param node
+ *
+ * @param node
* @return <code>true</code> if the declaration is templated.
*/
private boolean isTemplateDecl(IASTDeclaration node) {
@@ -474,47 +476,47 @@ class CStructureCreatorVisitor extends ASTVisitor {
}
private boolean hasNestedPointerOperators(IASTDeclarator declarator) {
- declarator= declarator.getNestedDeclarator();
+ declarator = declarator.getNestedDeclarator();
while (declarator != null) {
if (declarator.getPointerOperators().length > 0) {
return true;
}
- declarator= declarator.getNestedDeclarator();
+ declarator = declarator.getNestedDeclarator();
}
return false;
}
private String getEnumerationName(IASTEnumerationSpecifier enumSpecifier) {
- String nodeName= ASTStringUtil.getQualifiedName(enumSpecifier.getName());
+ String nodeName = ASTStringUtil.getQualifiedName(enumSpecifier.getName());
if (nodeName.length() == 0) {
- nodeName= ANONYMOUS_NAME;
+ nodeName = ANONYMOUS_NAME;
}
return nodeName;
}
private String getTypeName(IASTCompositeTypeSpecifier compositeTypeSpec) {
- String nodeName= ASTStringUtil.getQualifiedName(compositeTypeSpec.getName());
+ String nodeName = ASTStringUtil.getQualifiedName(compositeTypeSpec.getName());
if (nodeName.length() == 0) {
- nodeName= ANONYMOUS_NAME;
+ nodeName = ANONYMOUS_NAME;
}
return nodeName;
}
private String getDeclaratorName(IASTDeclarator node) {
- node= getInnermostDeclarator(node);
- IASTName name= node.getName();
- String nodeName= ASTStringUtil.getQualifiedName(name);
+ node = getInnermostDeclarator(node);
+ IASTName name = node.getName();
+ String nodeName = ASTStringUtil.getQualifiedName(name);
if (nodeName.length() == 0) {
- nodeName= ANONYMOUS_NAME;
+ nodeName = ANONYMOUS_NAME;
}
return nodeName;
}
private IASTDeclarator getInnermostDeclarator(IASTDeclarator node) {
- IASTDeclarator nested= node.getNestedDeclarator();
+ IASTDeclarator nested = node.getNestedDeclarator();
while (nested != null) {
- node= nested;
- nested= node.getNestedDeclarator();
+ node = nested;
+ nested = node.getNestedDeclarator();
}
return node;
}
@@ -523,7 +525,7 @@ class CStructureCreatorVisitor extends ASTVisitor {
if (locations == null || locations.length == 0) {
return null;
}
- final IASTNodeLocation nodeLocation= locations[locations.length-1];
+ final IASTNodeLocation nodeLocation = locations[locations.length - 1];
return nodeLocation.asFileLocation();
}
@@ -531,7 +533,7 @@ class CStructureCreatorVisitor extends ASTVisitor {
if (locations == null || locations.length == 0) {
return null;
}
- final IASTNodeLocation nodeLocation= locations[0];
+ final IASTNodeLocation nodeLocation = locations[0];
return nodeLocation.asFileLocation();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java
index eafc856f353..ed6ec636e2e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java
@@ -60,88 +60,88 @@ public class BuildGroup extends CViewActionGroup {
* before build.
*/
public static class CDTBuildAction extends BuildAction {
- public CDTBuildAction(IShellProvider shell, int kind) {
- super(shell, kind);
- }
-
- @Override
- protected boolean updateSelection(IStructuredSelection s) {
- // Call the super since it needs to clear out some settings
- super.updateSelection(s);
- // Always build CDT projects
- return true;
- }
-
- @Override
- public void run() {
- // Ensure we correctly save files in all referenced projects before build
- Set<IProject> prjs = new HashSet<IProject>();
- for (IResource resource : getSelectedResources()) {
- IProject project = resource.getProject();
- if (project != null) {
- prjs.add(project);
- try {
- prjs.addAll(Arrays.asList(project.getReferencedProjects()));
- } catch (CoreException e) {
- // Project not accessible or not open
- }
- }
- }
- saveEditors(prjs);
+ public CDTBuildAction(IShellProvider shell, int kind) {
+ super(shell, kind);
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection s) {
+ // Call the super since it needs to clear out some settings
+ super.updateSelection(s);
+ // Always build CDT projects
+ return true;
+ }
+
+ @Override
+ public void run() {
+ // Ensure we correctly save files in all referenced projects before build
+ Set<IProject> prjs = new HashSet<IProject>();
+ for (IResource resource : getSelectedResources()) {
+ IProject project = resource.getProject();
+ if (project != null) {
+ prjs.add(project);
+ try {
+ prjs.addAll(Arrays.asList(project.getReferencedProjects()));
+ } catch (CoreException e) {
+ // Project not accessible or not open
+ }
+ }
+ }
+ saveEditors(prjs);
// Clear the build console, and open a stream
CUIPlugin.getDefault().startGlobalConsole();
- // Now delegate to the parent
- super.run();
- }
+ // Now delegate to the parent
+ super.run();
+ }
- /**
- * Taken from inaccessible o.e.ui.ide.BuildUtilities.java
- *
- * Causes all editors to save any modified resources in the provided collection
- * of projects depending on the user's preference.
- * @param projects The projects in which to save editors, or <code>null</code>
- * to save editors in all projects.
- */
- private static void saveEditors(Collection<IProject> projects) {
- if (!BuildAction.isSaveAllSet()) {
- return;
- }
- IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
- for (IWorkbenchWindow window : windows) {
- IWorkbenchPage[] pages = window.getPages();
- for (IWorkbenchPage page : pages) {
- if (projects == null) {
- page.saveAllEditors(false);
- } else {
- IEditorPart[] editors = page.getDirtyEditors();
- for (IEditorPart editor : editors) {
- IFile inputFile = ResourceUtil.getFile(editor.getEditorInput());
- if (inputFile != null) {
- if (projects.contains(inputFile.getProject())) {
- page.saveEditor(editor, false);
- }
- }
- }
- }
- }
- }
- }
+ /**
+ * Taken from inaccessible o.e.ui.ide.BuildUtilities.java
+ *
+ * Causes all editors to save any modified resources in the provided collection
+ * of projects depending on the user's preference.
+ * @param projects The projects in which to save editors, or <code>null</code>
+ * to save editors in all projects.
+ */
+ private static void saveEditors(Collection<IProject> projects) {
+ if (!BuildAction.isSaveAllSet()) {
+ return;
+ }
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (IWorkbenchWindow window : windows) {
+ IWorkbenchPage[] pages = window.getPages();
+ for (IWorkbenchPage page : pages) {
+ if (projects == null) {
+ page.saveAllEditors(false);
+ } else {
+ IEditorPart[] editors = page.getDirtyEditors();
+ for (IEditorPart editor : editors) {
+ IFile inputFile = ResourceUtil.getFile(editor.getEditorInput());
+ if (inputFile != null) {
+ if (projects.contains(inputFile.getProject())) {
+ page.saveEditor(editor, false);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
private static class RebuildAction extends CDTBuildAction {
- public RebuildAction(IShellProvider shell) {
- super(shell, IncrementalProjectBuilder.FULL_BUILD);
- }
- @Override
- protected void invokeOperation(IResource resource, IProgressMonitor monitor)
- throws CoreException {
- // these are both async. NOT what I want.
- ((IProject) resource).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
- ((IProject) resource).build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ public RebuildAction(IShellProvider shell) {
+ super(shell, IncrementalProjectBuilder.FULL_BUILD);
+ }
+
+ @Override
+ protected void invokeOperation(IResource resource, IProgressMonitor monitor) throws CoreException {
+ // these are both async. NOT what I want.
+ ((IProject) resource).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
+ ((IProject) resource).build(IncrementalProjectBuilder.FULL_BUILD, monitor);
- }
+ }
}
private BuildAction buildAction;
@@ -170,7 +170,7 @@ public class BuildGroup extends CViewActionGroup {
* <p>
* No disabled action should be on the context menu.
* </p>
- *
+ *
* @param menu
* context menu to add actions to
*/
@@ -193,7 +193,7 @@ public class BuildGroup extends CViewActionGroup {
if (next instanceof IProject) {
project = (IProject) next;
} else if (next instanceof IAdaptable) {
- IResource res = ((IAdaptable)next).getAdapter(IResource.class);
+ IResource res = ((IAdaptable) next).getAdapter(IResource.class);
if (res instanceof IProject) {
project = (IProject) res;
}
@@ -217,8 +217,8 @@ public class BuildGroup extends CViewActionGroup {
if (!selection.isEmpty() && isProjectSelection && hasBuilder) {
buildAction.selectionChanged(selection);
menu.add(buildAction);
-// rebuildAction.selectionChanged(selection);
-// menu.add(rebuildAction);
+ // rebuildAction.selectionChanged(selection);
+ // menu.add(rebuildAction);
cleanAction.selectionChanged(selection);
menu.add(cleanAction);
}
@@ -234,14 +234,15 @@ public class BuildGroup extends CViewActionGroup {
/**
* Returns whether there are builders configured on the given project.
- *
+ *
* @return <code>true</code> if it has builders, <code>false</code> if
* not, or if this could not be determined
*/
boolean hasBuilder(IProject project) {
try {
ICommand[] commands = project.getDescription().getBuildSpec();
- if (commands.length > 0) return true;
+ if (commands.length > 0)
+ return true;
} catch (CoreException e) {
// Cannot determine if project has builders. Project is closed
// or does not exist. Fall through to return false.
@@ -254,13 +255,13 @@ public class BuildGroup extends CViewActionGroup {
final IWorkbenchPartSite site = getCView().getSite();
buildAction = new CDTBuildAction(site, IncrementalProjectBuilder.INCREMENTAL_BUILD);
- buildAction.setText(CViewMessages.BuildAction_label);
+ buildAction.setText(CViewMessages.BuildAction_label);
cleanAction = new CDTBuildAction(site, IncrementalProjectBuilder.CLEAN_BUILD);
- cleanAction.setText(CViewMessages.CleanAction_label);
-
+ cleanAction.setText(CViewMessages.CleanAction_label);
+
rebuildAction = new RebuildAction(site);
- rebuildAction.setText(CViewMessages.RebuildAction_label);
+ rebuildAction.setText(CViewMessages.RebuildAction_label);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
index f55e9d65fcb..71fd53581c2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
@@ -16,7 +16,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.cview;
-
import java.util.ArrayList;
import org.eclipse.core.resources.IFile;
@@ -122,11 +121,12 @@ import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
/**
- *
+ *
* CView
- *
+ *
*/
-public class CView extends ViewPart implements ISetSelectionTarget, IPropertyChangeListener, IShowInTarget, IShowInTargetList {
+public class CView extends ViewPart
+ implements ISetSelectionTarget, IPropertyChangeListener, IShowInTarget, IShowInTargetList {
ProblemTreeViewer viewer;
IMemento memento;
@@ -194,9 +194,11 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
}
if (IWorkingSetManager.CHANGE_WORKING_SET_REMOVE.equals(property) && oldValue == filterWorkingSet) {
setWorkingSet(null);
- } else if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property) && newValue == filterWorkingSet) {
+ } else if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property)
+ && newValue == filterWorkingSet) {
updateTitle();
- } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property) && newValue == filterWorkingSet) {
+ } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)
+ && newValue == filterWorkingSet) {
getViewer().refresh();
}
}
@@ -218,7 +220,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Reveal and select the passed element selection in self's visual
* component
- *
+ *
* @see ISetSelectionTarget#selectReveal(ISelection)
*/
@Override
@@ -268,7 +270,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Handles a key release in the viewer. Does nothing by default.
- *
+ *
*/
protected void handleKeyReleased(KeyEvent event) {
if (getActionGroup() != null) {
@@ -303,7 +305,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Returns the action group.
- *
+ *
* @return the action group
*/
protected CViewActionGroup getActionGroup() {
@@ -312,7 +314,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Sets the action group.
- *
+ *
* @param actionGroup
* the action group
*/
@@ -363,7 +365,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Adds the filters to the viewer.
- *
+ *
* @param viewer
* the viewer
*/
@@ -390,34 +392,22 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
}
private void initDrag() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- Transfer[] transfers= new Transfer[] {
- LocalSelectionTransfer.getTransfer(),
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance(),
- };
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(viewer),
- new ResourceTransferDragAdapter(viewer),
- new FileTransferDragAdapter(viewer)
- };
+ int ops = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer(), ResourceTransfer.getInstance(),
+ FileTransfer.getInstance(), };
+ TransferDragSourceListener[] dragListeners = new TransferDragSourceListener[] {
+ new SelectionTransferDragAdapter(viewer), new ResourceTransferDragAdapter(viewer),
+ new FileTransferDragAdapter(viewer) };
viewer.addDragSupport(ops, transfers, new CDTViewerDragAdapter(viewer, dragListeners));
}
private void initDrop() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT;
- Transfer[] transfers= new Transfer[] {
- LocalSelectionTransfer.getTransfer(),
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance(),
- PluginTransfer.getInstance()
- };
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new SelectionTransferDropAdapter(viewer),
- new ResourceTransferDropAdapter(viewer),
- new FileTransferDropAdapter(viewer),
- new PluginTransferDropAdapter(viewer),
- };
+ int ops = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT;
+ Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer(), ResourceTransfer.getInstance(),
+ FileTransfer.getInstance(), PluginTransfer.getInstance() };
+ TransferDropTargetListener[] dropListeners = new TransferDropTargetListener[] {
+ new SelectionTransferDropAdapter(viewer), new ResourceTransferDropAdapter(viewer),
+ new FileTransferDropAdapter(viewer), new PluginTransferDropAdapter(viewer), };
viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
}
@@ -574,26 +564,28 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
initFilterFromPreferences();
}
-
if (memento != null) {
restoreState(memento);
}
memento = null;
- IContextService ctxService = getSite().getService(IContextService.class);
- if (ctxService != null) {
- fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
- }
- }
-
+ IContextService ctxService = getSite().getService(IContextService.class);
+ if (ctxService != null) {
+ fContextActivation = ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+ }
+ }
+
protected ProblemTreeViewer createViewer(Composite parent) {
return new RemoteTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
}
protected IContentProvider createContentProvider() {
- boolean showCUChildren = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
- boolean groupIncludes = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
- boolean groupMacros = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
+ boolean showCUChildren = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
+ boolean groupIncludes = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
+ boolean groupMacros = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
CViewContentProvider provider = new CViewContentProvider(viewer, getSite(), showCUChildren, true);
provider.setIncludesGrouping(groupIncludes);
provider.setMacroGrouping(groupMacros);
@@ -601,7 +593,8 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
}
protected CUILabelProvider createLabelProvider() {
- return new CViewLabelProvider(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS);
+ return new CViewLabelProvider(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
+ AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS);
}
/*
@@ -611,9 +604,9 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
public void dispose() {
if (fContextActivation != null) {
IContextService ctxService = getSite().getService(IContextService.class);
- if (ctxService != null) {
- ctxService.deactivateContext(fContextActivation);
- }
+ if (ctxService != null) {
+ ctxService.deactivateContext(fContextActivation);
+ }
}
getSite().getPage().removePartListener(partListener);
@@ -667,7 +660,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Returns the working set filter for this view.
- *
+ *
* @return the working set
*/
public IWorkingSet getWorkingSet() {
@@ -704,7 +697,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Called when the context menu is about to open. Delegates to the action
* group using the viewer's selection as the action context.
- *
+ *
* @since 2.0
*/
protected void fillContextMenu(IMenuManager menu) {
@@ -733,7 +726,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Returns the message to show in the status line.
- *
+ *
* @param selection
* the current selection
* @return the status line message
@@ -752,12 +745,12 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
if (celement instanceof IBinaryContainer) {
ICProject cproj = celement.getCProject();
if (cproj != null) {
- return cproj.getPath() + CViewMessages.CView_binaries;
+ return cproj.getPath() + CViewMessages.CView_binaries;
}
} else if (celement instanceof IArchiveContainer) {
ICProject cproj = celement.getCProject();
if (cproj != null) {
- return cproj.getPath() + CViewMessages.CView_archives;
+ return cproj.getPath() + CViewMessages.CView_archives;
}
} else if (celement instanceof IBinaryModule) {
IBinary bin = ((IBinaryModule) celement).getBinary();
@@ -768,22 +761,21 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
}
return celement.getElementName();
} else if (o instanceof IWorkbenchAdapter) {
- IWorkbenchAdapter wAdapter = (IWorkbenchAdapter)o;
+ IWorkbenchAdapter wAdapter = (IWorkbenchAdapter) o;
return wAdapter.getLabel(o);
} else {
return "ItemSelected"; //$NON-NLS-1$
}
}
if (selection.size() > 1) {
- return NLS.bind(CViewMessages.CView_statusLine,
- new String[] { Integer.toString(selection.size())});
+ return NLS.bind(CViewMessages.CView_statusLine, new String[] { Integer.toString(selection.size()) });
}
return "";//$NON-NLS-1$
}
/**
* Updates the action bar actions.
- *
+ *
* @param selection
* the current selection
*/
@@ -811,7 +803,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Updates the message shown in the status line.
- *
+ *
* @param selection
* the current selection
*/
@@ -844,13 +836,15 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (viewer == null) return;
+ if (viewer == null)
+ return;
boolean refreshViewer = false;
String property = event.getProperty();
if (property.equals(PreferenceConstants.PREF_SHOW_CU_CHILDREN)) {
- boolean showCUChildren = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
+ boolean showCUChildren = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
IContentProvider provider = viewer.getContentProvider();
if (provider instanceof CElementContentProvider) {
((CElementContentProvider) provider).setProvideMembers(showCUChildren);
@@ -860,17 +854,19 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
CViewActionGroup group = getActionGroup();
if (group instanceof MainActionGroup) {
boolean enable = isLinkingEnabled();
- ((MainActionGroup)group).toggleLinkingAction.setChecked(enable);
+ ((MainActionGroup) group).toggleLinkingAction.setChecked(enable);
}
} else if (property.equals(PreferenceConstants.CVIEW_GROUP_INCLUDES)) {
- boolean groupIncludes = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
+ boolean groupIncludes = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
IContentProvider provider = viewer.getContentProvider();
if (provider instanceof CElementContentProvider) {
((CElementContentProvider) provider).setIncludesGrouping(groupIncludes);
}
refreshViewer = true;
} else if (property.equals(PreferenceConstants.CVIEW_GROUP_MACROS)) {
- boolean groupMacros = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
+ boolean groupMacros = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
IContentProvider provider = viewer.getContentProvider();
if (provider instanceof CElementContentProvider) {
((CElementContentProvider) provider).setMacroGrouping(groupMacros);
@@ -886,7 +882,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/**
* Returns whether the navigator selection automatically tracks the active
* editor.
- *
+ *
* @return <code>true</code> if linking is enabled, <code>false</code>
* if not
*/
@@ -935,7 +931,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/*
* (non-Javadoc)
- *
+ *
* @see IViewPartInputProvider#getViewPartInput()
*/
public Object getViewPartInput() {
@@ -946,9 +942,9 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
}
void restoreState(IMemento memento) {
-
+
CoreModel factory = CoreModel.getDefault();
-
+
getActionGroup().restoreFilterAndSorterState(memento);
IMemento childMem = memento.getChild(TAG_EXPANDED);
@@ -1025,8 +1021,8 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
for (Object expandedElement : expandedElements) {
Object o = expandedElement;
// Do not save expanded binary files are libraries.
- if (o instanceof IParent
- && !(o instanceof IArchiveContainer || o instanceof IBinaryContainer || o instanceof IBinary || o instanceof IArchive)) {
+ if (o instanceof IParent && !(o instanceof IArchiveContainer || o instanceof IBinaryContainer
+ || o instanceof IBinary || o instanceof IArchive)) {
IMemento elementMem = expandedMem.createChild(TAG_ELEMENT);
ICElement e = (ICElement) o;
IResource res = e.getResource();
@@ -1074,12 +1070,12 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
*/
@Override
public boolean show(ShowInContext context) {
- ISelection selection= context.getSelection();
+ ISelection selection = context.getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
selectReveal(selection);
return true;
@@ -1094,7 +1090,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
}
return false;
}
-
+
/**
* Returns the <code>IShowInSource</code> for this view.
*/
@@ -1107,8 +1103,8 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
};
}
- @Override
+ @Override
public String[] getShowInTargetIds() {
- return new String[]{IPageLayout.ID_RES_NAV};
- }
+ return new String[] { IPageLayout.ID_RES_NAV };
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java
index 8658e9471c5..e310a51dc9f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java
@@ -24,7 +24,7 @@ import org.eclipse.ui.actions.SelectionProviderAction;
* Superclass of all actions provided by the cview.
*/
public abstract class CViewAction extends SelectionProviderAction {
-
+
private CView cview;
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java
index 6c483d22a38..e4d78f61010 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java
@@ -30,13 +30,13 @@ import org.eclipse.ui.views.navigator.WorkspaceActionGroup;
/**
* This is the action group for all the view actions.
* It delegates to several subgroups for most of the actions.
- *
+ *
* @see GotoActionGroup
* @see OpenFileGroup
* @see RefactorActionGroup
* @see SortAndFilterActionGroup
* @see WorkspaceActionGroup
- *
+ *
*/
public abstract class CViewActionGroup extends ActionGroup {
@@ -44,17 +44,17 @@ public abstract class CViewActionGroup extends ActionGroup {
* The resource navigator.
*/
protected CView cview;
-
+
/**
* Constructs a new navigator action group and creates its actions.
- *
+ *
* @param cview the CView
*/
public CViewActionGroup(CView cview) {
this.cview = cview;
makeActions();
}
-
+
/**
* Returns the image descriptor with the given relative path.
*/
@@ -68,7 +68,7 @@ public abstract class CViewActionGroup extends ActionGroup {
// should not happen
return ImageDescriptor.getMissingImageDescriptor();
}
- }
+ }
/**
* Returns the resource navigator.
@@ -76,11 +76,11 @@ public abstract class CViewActionGroup extends ActionGroup {
public CView getCView() {
return cview;
}
-
+
/**
- * Handles a key pressed event by invoking the appropriate action.
+ * Handles a key pressed event by invoking the appropriate action.
* Does nothing by default.
- */
+ */
public void handleKeyPressed(KeyEvent event) {
}
@@ -95,7 +95,7 @@ public abstract class CViewActionGroup extends ActionGroup {
* Makes the actions contained in this action group.
*/
protected abstract void makeActions();
-
+
/**
* Called when the context menu is about to open.
* Override to add your own context dependent menu contributions.
@@ -115,7 +115,7 @@ public abstract class CViewActionGroup extends ActionGroup {
/**
* Runs the default action in the group.
* Does nothing by default.
- *
+ *
* @param selection the current selection
*/
public void runDefaultAction(IStructuredSelection selection) {
@@ -123,7 +123,7 @@ public abstract class CViewActionGroup extends ActionGroup {
public void restoreFilterAndSorterState(IMemento memento) {
}
-
+
public void saveFilterAndSorterState(IMemento memento) {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
index 492c6a2ff45..edc2d563db5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
@@ -59,16 +59,17 @@ public class CViewContentProvider extends CElementContentProvider {
* @param provideMembers
* @param provideWorkingCopy
*/
- public CViewContentProvider(TreeViewer viewer, IWorkbenchPartSite site, boolean provideMembers, boolean provideWorkingCopy) {
+ public CViewContentProvider(TreeViewer viewer, IWorkbenchPartSite site, boolean provideMembers,
+ boolean provideWorkingCopy) {
super(provideMembers, provideWorkingCopy);
fManager = createContentManager(viewer, site);
}
protected RemoteTreeContentManager createContentManager(TreeViewer viewer, IWorkbenchPartSite site) {
if (site == null) {
- return new RemoteTreeContentManager(this, (RemoteTreeViewer)viewer, null);
+ return new RemoteTreeContentManager(this, (RemoteTreeViewer) viewer, null);
}
- return new RemoteTreeContentManager(this, (RemoteTreeViewer)viewer, site);
+ return new RemoteTreeContentManager(this, (RemoteTreeViewer) viewer, site);
}
/* (non-Javadoc)
@@ -95,13 +96,13 @@ public class CViewContentProvider extends CElementContentProvider {
Object[] extras = null;
try {
if (element instanceof ICProject) {
- extras = getProjectChildren((ICProject)element);
+ extras = getProjectChildren((ICProject) element);
} else if (element instanceof IBinaryContainer) {
- extras = getExecutables((IBinaryContainer)element);
+ extras = getExecutables((IBinaryContainer) element);
} else if (element instanceof IArchiveContainer) {
- extras = getArchives((IArchiveContainer)element);
+ extras = getArchives((IArchiveContainer) element);
} else if (element instanceof IIncludeReference) {
- extras = getIncludeReferenceChildren((IIncludeReference)element);
+ extras = getIncludeReferenceChildren((IIncludeReference) element);
}
/*
* Do not to this for now, since ILibraryReference is an Archive.
@@ -134,11 +135,11 @@ public class CViewContentProvider extends CElementContentProvider {
Object[] extras = null;
IArchiveContainer archive = cproject.getArchiveContainer();
if (getArchives(archive).length > 0) {
- extras = new Object[] {archive};
+ extras = new Object[] { archive };
}
IBinaryContainer bin = cproject.getBinaryContainer();
if (getExecutables(bin).length > 0) {
- Object[] o = new Object[] {bin};
+ Object[] o = new Object[] { bin };
if (extras != null && extras.length > 0) {
extras = concatenate(extras, o);
} else {
@@ -148,7 +149,7 @@ public class CViewContentProvider extends CElementContentProvider {
LibraryRefContainer libRefCont = new LibraryRefContainer(cproject);
Object[] libRefs = libRefCont.getChildren(cproject);
if (libRefs != null && libRefs.length > 0) {
- Object[] o = new Object[] {libRefCont};
+ Object[] o = new Object[] { libRefCont };
if (extras != null && extras.length > 0) {
extras = concatenate(extras, o);
} else {
@@ -159,7 +160,7 @@ public class CViewContentProvider extends CElementContentProvider {
IncludeRefContainer incRefCont = new IncludeRefContainer(cproject);
Object[] incRefs = incRefCont.getChildren(cproject);
if (incRefs != null && incRefs.length > 0) {
- Object[] o = new Object[] {incRefCont};
+ Object[] o = new Object[] { incRefCont };
if (extras != null && extras.length > 0) {
extras = concatenate(extras, o);
} else {
@@ -174,7 +175,7 @@ public class CViewContentProvider extends CElementContentProvider {
ArrayList<IBinary> list = new ArrayList<IBinary>(celements.length);
for (int i = 0; i < celements.length; i++) {
if (celements[i] instanceof IBinary) {
- IBinary bin = (IBinary)celements[i];
+ IBinary bin = (IBinary) celements[i];
if (bin.showInBinaryContainer()) {
list.add(bin);
}
@@ -195,18 +196,19 @@ public class CViewContentProvider extends CElementContentProvider {
// to the container and containers refere to the project
Object parent = super.internalGetParent(element);
if (element instanceof IncludeReferenceProxy) {
- parent = ((IncludeReferenceProxy)element).getIncludeRefContainer();
+ parent = ((IncludeReferenceProxy) element).getIncludeRefContainer();
} else if (element instanceof IncludeRefContainer) {
- parent = ((IncludeRefContainer)element).getCProject();
+ parent = ((IncludeRefContainer) element).getCProject();
} else if (element instanceof ILibraryReference) {
if (parent instanceof ICProject) {
- parent = new LibraryRefContainer((ICProject)parent);
+ parent = new LibraryRefContainer((ICProject) parent);
}
} else if (element instanceof LibraryRefContainer) {
- parent = ((LibraryRefContainer)element).getCProject();
+ parent = ((LibraryRefContainer) element).getCProject();
}
return parent;
}
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
@@ -221,7 +223,7 @@ public class CViewContentProvider extends CElementContentProvider {
}
if (element instanceof IBinaryContainer) {
try {
- IBinaryContainer cont = (IBinaryContainer)element;
+ IBinaryContainer cont = (IBinaryContainer) element;
IBinary[] bins = getBinaries(cont);
return (bins != null) && bins.length > 0;
} catch (CModelException e) {
@@ -229,15 +231,16 @@ public class CViewContentProvider extends CElementContentProvider {
}
} else if (element instanceof IArchiveContainer) {
try {
- IArchiveContainer cont = (IArchiveContainer)element;
+ IArchiveContainer cont = (IArchiveContainer) element;
IArchive[] ars = getArchives(cont);
return (ars != null) && ars.length > 0;
} catch (CModelException e) {
return false;
}
} else if (element instanceof IncludeReferenceProxy) {
- IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
- IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath());
+ IIncludeReference reference = ((IncludeReferenceProxy) element).getReference();
+ IContainer container = ResourcesPlugin.getWorkspace().getRoot()
+ .getContainerForLocation(reference.getPath());
if (container != null) {
// do not allow to navigate to workspace containers inside "Includes" node
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java
index 29a6b398414..2c8fc3a8106 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -23,16 +23,16 @@ public class CViewElementComparer implements IElementComparer {
@Override
public boolean equals(Object o1, Object o2) {
- if (o1 == o2) // this handles also the case that both are null
+ if (o1 == o2) // this handles also the case that both are null
return true;
- if (o1 == null)
- return false; // o2 != null if we reach this point
+ if (o1 == null)
+ return false; // o2 != null if we reach this point
if (o1.equals(o2))
return true;
// Assume they are CElements
- ICElement c1= (o1 instanceof ICElement) ? (ICElement)o1 : null;
- ICElement c2= (o2 instanceof ICElement) ? (ICElement)o2 : null;
+ ICElement c1 = (o1 instanceof ICElement) ? (ICElement) o1 : null;
+ ICElement c2 = (o2 instanceof ICElement) ? (ICElement) o2 : null;
if (c1 == null || c2 == null)
return false;
@@ -42,20 +42,20 @@ public class CViewElementComparer implements IElementComparer {
// Below is for children of TranslationUnits but we have to make sure
// we handle the case that the child comes from the a workingCopy in that
// case it should be equal as the original element.
- ITranslationUnit u1 = (ITranslationUnit)c1.getAncestor(ICElement.C_UNIT);
- ITranslationUnit u2 = (ITranslationUnit)c2.getAncestor(ICElement.C_UNIT);
+ ITranslationUnit u1 = (ITranslationUnit) c1.getAncestor(ICElement.C_UNIT);
+ ITranslationUnit u2 = (ITranslationUnit) c2.getAncestor(ICElement.C_UNIT);
if (u1 == null || u2 == null) {
return false;
}
-
+
if (u1.isWorkingCopy() && u2.isWorkingCopy() || !u1.isWorkingCopy() && !u2.isWorkingCopy()) {
return false;
}
// From here on either c1 or c2 is a working copy.
if (u1.isWorkingCopy()) {
- c1= ((IWorkingCopy)u1).getOriginal(c1);
+ c1 = ((IWorkingCopy) u1).getOriginal(c1);
} else if (u2.isWorkingCopy()) {
- c2= ((IWorkingCopy)u2).getOriginal(c2);
+ c2 = ((IWorkingCopy) u2).getOriginal(c2);
}
if (c1 == null || c2 == null)
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java
index 5d97bc9898c..dbafc4dacad 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java
@@ -18,25 +18,26 @@ import org.eclipse.ui.views.framelist.TreeFrame;
import org.eclipse.ui.views.framelist.TreeViewerFrameSource;
public class CViewFrameSource extends TreeViewerFrameSource {
- private CView cview;
+ private CView cview;
- @Override
- protected TreeFrame createFrame(Object input) {
- TreeFrame frame = super.createFrame(input);
- frame.setToolTipText(cview.getToolTipText(input));
- return frame;
- }
- /**
- * Also updates the title of the packages explorer
- */
- @Override
- protected void frameChanged(TreeFrame frame) {
- super.frameChanged(frame);
- cview.updateTitle();
- }
- public CViewFrameSource(CView cview) {
- super(cview.getViewer());
- this.cview = cview;
- }
-}
+ @Override
+ protected TreeFrame createFrame(Object input) {
+ TreeFrame frame = super.createFrame(input);
+ frame.setToolTipText(cview.getToolTipText(input));
+ return frame;
+ }
+
+ /**
+ * Also updates the title of the packages explorer
+ */
+ @Override
+ protected void frameChanged(TreeFrame frame) {
+ super.frameChanged(frame);
+ cview.updateTitle();
+ }
+ public CViewFrameSource(CView cview) {
+ super(cview.getViewer());
+ this.cview = cview;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java
index ed3ad46dec9..770ef1adab1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java
@@ -49,12 +49,13 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
@Override
public String getText(Object element) {
if (element instanceof IncludeReferenceProxy) {
- final IIncludeReference ref = ((IncludeReferenceProxy)element).getReference();
+ final IIncludeReference ref = ((IncludeReferenceProxy) element).getReference();
final IPath uriPathLocation = ref.getPath().makeAbsolute();
- final IContainer[] containers= ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(uriPathLocation));
+ final IContainer[] containers = ResourcesPlugin.getWorkspace().getRoot()
+ .findContainersForLocationURI(URIUtil.toURI(uriPathLocation));
if (containers.length > 0) {
// bug 192707, prefer the project the reference belongs to.
- final ICProject prj= ref.getCProject();
+ final ICProject prj = ref.getCProject();
if (prj != null) {
for (int i = 0; i < containers.length; i++) {
final IContainer container = containers[i];
@@ -70,11 +71,11 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
return decorateText(p.toString(), element);
}
} else if (element instanceof IIncludeReference) {
- IIncludeReference ref = (IIncludeReference)element;
+ IIncludeReference ref = (IIncludeReference) element;
Object parent = ref.getParent();
if (parent instanceof IIncludeReference) {
IPath p = ref.getPath();
- IPath parentLocation = ((IIncludeReference)parent).getPath();
+ IPath parentLocation = ((IIncludeReference) parent).getPath();
if (parentLocation.isPrefixOf(p)) {
p = p.setDevice(null);
p = p.removeFirstSegments(parentLocation.segmentCount());
@@ -82,11 +83,11 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
return decorateText(p.toString(), element);
}
} else if (element instanceof ITranslationUnit) {
- ITranslationUnit unit = (ITranslationUnit)element;
+ ITranslationUnit unit = (ITranslationUnit) element;
Object parent = unit.getParent();
if (parent instanceof IIncludeReference) {
IPath p = unit.getPath();
- IPath parentLocation = ((IIncludeReference)parent).getPath();
+ IPath parentLocation = ((IIncludeReference) parent).getPath();
if (parentLocation.isPrefixOf(p)) {
p = p.setDevice(null);
p = p.removeFirstSegments(parentLocation.segmentCount());
@@ -106,14 +107,16 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
public Image getImage(Object element) {
String imageKey = null;
if (element instanceof IncludeReferenceProxy) {
- IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
+ IIncludeReference reference = ((IncludeReferenceProxy) element).getReference();
IPath path = reference.getPath();
ICProject cproject = reference.getCProject();
IProject project = (cproject != null) ? cproject.getProject() : null;
- for (IContainer containerInclude : ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(path.makeAbsolute()))) {
+ for (IContainer containerInclude : ResourcesPlugin.getWorkspace().getRoot()
+ .findContainersForLocationURI(URIUtil.toURI(path.makeAbsolute()))) {
IProject projectInclude = containerInclude.getProject();
boolean isProjectRelative = projectInclude != null && projectInclude.equals(project);
- imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative);
+ imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH,
+ ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative);
if (isProjectRelative) {
break;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java
index 91d0a9f0a53..c35d027ebf3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java
@@ -36,56 +36,57 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The ResourceNavigatorMoveAction is a resource move that aso updates the navigator
* to show the result of the move.
* It also delegates to MoveProjectAction as needed.
- *
+ *
* @since 2.0
*/
public class CViewMoveAction extends MoveResourceAction {
private StructuredViewer viewer;
private MoveProjectAction moveProjectAction;
-
-/**
- * Create a ResourceNavigatorMoveAction and use the supplied viewer to update the UI.
- * @param shellProvider provider for the shell
- * @param structureViewer StructuredViewer
- */
-public CViewMoveAction(IShellProvider shellProvider, StructuredViewer structureViewer) {
- super(shellProvider);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.MOVE_ACTION);
- this.viewer = structureViewer;
- this.moveProjectAction = new MoveProjectAction(shellProvider);
-}
-/* (non-Javadoc)
- * Method declared on IAction.
- */
-@Override
-public void run() {
- if (moveProjectAction.isEnabled()) {
- moveProjectAction.run();
- return;
+
+ /**
+ * Create a ResourceNavigatorMoveAction and use the supplied viewer to update the UI.
+ * @param shellProvider provider for the shell
+ * @param structureViewer StructuredViewer
+ */
+ public CViewMoveAction(IShellProvider shellProvider, StructuredViewer structureViewer) {
+ super(shellProvider);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.MOVE_ACTION);
+ this.viewer = structureViewer;
+ this.moveProjectAction = new MoveProjectAction(shellProvider);
}
-
- super.run();
- List<?> destinations = getDestinations();
- if (destinations != null && destinations.isEmpty() == false) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- List<IResource> resources = new ArrayList<IResource>();
- Iterator<?> iterator = destinations.iterator();
-
- while (iterator.hasNext()) {
- IResource newResource = root.findMember((IPath) iterator.next());
- if (newResource != null)
- resources.add(newResource);
+
+ /* (non-Javadoc)
+ * Method declared on IAction.
+ */
+ @Override
+ public void run() {
+ if (moveProjectAction.isEnabled()) {
+ moveProjectAction.run();
+ return;
}
-
- this.viewer.setSelection(new StructuredSelection(resources), true);
- }
-}
+ super.run();
+ List<?> destinations = getDestinations();
+ if (destinations != null && destinations.isEmpty() == false) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ List<IResource> resources = new ArrayList<IResource>();
+ Iterator<?> iterator = destinations.iterator();
-@Override
-protected boolean updateSelection(IStructuredSelection selection) {
- moveProjectAction.selectionChanged(selection);
- return super.updateSelection(selection) || moveProjectAction.isEnabled();
-}
+ while (iterator.hasNext()) {
+ IResource newResource = root.findMember((IPath) iterator.next());
+ if (newResource != null)
+ resources.add(newResource);
+ }
+
+ this.viewer.setSelection(new StructuredSelection(resources), true);
+ }
+
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ moveProjectAction.selectionChanged(selection);
+ return super.updateSelection(selection) || moveProjectAction.isEnabled();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java
index 89187ac5d36..fc56e4b6153 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java
@@ -28,7 +28,6 @@ import org.eclipse.ui.actions.RenameResourceAction;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-
/**
* The ResourceNavigatorRenameAction is the rename action used by the
* ResourceNavigator that also allows updating after rename.
@@ -36,6 +35,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
*/
public class CViewRenameAction extends RenameResourceAction {
private TreeViewer viewer;
+
/**
* Create a ResourceNavigatorRenameAction and use the tree of the supplied viewer
* for editing.
@@ -46,11 +46,10 @@ public class CViewRenameAction extends RenameResourceAction {
@Deprecated
public CViewRenameAction(Shell shell, TreeViewer treeViewer) {
super(shell, treeViewer.getTree());
- PlatformUI.getWorkbench().getHelpSystem().setHelp(
- this,
- ICHelpContextIds.RENAME_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.RENAME_ACTION);
this.viewer = treeViewer;
}
+
/**
* Create a ResourceNavigatorRenameAction and use the tree of the supplied viewer
* for editing.
@@ -59,9 +58,7 @@ public class CViewRenameAction extends RenameResourceAction {
*/
public CViewRenameAction(IShellProvider shellProvider, TreeViewer treeViewer) {
super(shellProvider, treeViewer.getTree());
- PlatformUI.getWorkbench().getHelpSystem().setHelp(
- this,
- ICHelpContextIds.RENAME_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.RENAME_ACTION);
this.viewer = treeViewer;
}
@@ -78,6 +75,7 @@ public class CViewRenameAction extends RenameResourceAction {
this.viewer.setSelection(new StructuredSelection(newResource), true);
}
}
+
/**
* Handle the key release
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java
index 74dc7c6af8f..697f2794b60 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java
@@ -41,7 +41,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
- *
+ *
* @since 2.0
*/
public class CopyAction extends SelectionListenerAction {
@@ -73,32 +73,34 @@ public class CopyAction extends SelectionListenerAction {
* @param clipboard a platform clipboard
*/
public CopyAction(Shell shell, Clipboard clipboard) {
- super(CViewMessages.CopyAction_title);
+ super(CViewMessages.CopyAction_title);
Assert.isNotNull(shell);
Assert.isNotNull(clipboard);
this.shell = shell;
this.clipboard = clipboard;
- setToolTipText(CViewMessages.CopyAction_toolTip);
+ setToolTipText(CViewMessages.CopyAction_toolTip);
setId(CopyAction.ID);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COPY_ACTION);
}
+
/**
* Creates a new action.
*
* @param shell the shell for any dialogs
* @param clipboard a platform clipboard
* @param pasteAction a paste action
- *
+ *
* @since 2.0
*/
public CopyAction(Shell shell, Clipboard clipboard, PasteAction pasteAction) {
this(shell, clipboard);
this.pasteAction = pasteAction;
}
+
/**
- * The <code>CopyAction</code> implementation of this method defined
- * on <code>IAction</code> copies the selected resources to the
+ * The <code>CopyAction</code> implementation of this method defined
+ * on <code>IAction</code> copies the selected resources to the
* clipboard.
*/
@Override
@@ -134,9 +136,10 @@ public class CopyAction extends SelectionListenerAction {
if (pasteAction != null && pasteAction.getStructuredSelection() != null)
pasteAction.selectionChanged(pasteAction.getStructuredSelection());
}
+
/**
* Set the clipboard contents. Prompt to retry if clipboard is busy.
- *
+ *
* @param resources the resources to copy to the clipboard
* @param fileNames file names of the resources to copy to the clipboard
* @param names string representation of all names
@@ -145,24 +148,24 @@ public class CopyAction extends SelectionListenerAction {
try {
// set the clipboard contents
if (fileNames.length > 0) {
- clipboard.setContents(
- new Object[] { resources, fileNames, names },
- new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance()});
+ clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] {
+ ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
} else {
- clipboard.setContents(
- new Object[] { resources, names },
- new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance()});
+ clipboard.setContents(new Object[] { resources, names },
+ new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
}
} catch (SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
throw e;
- if (MessageDialog.openQuestion(shell, CViewMessages.CopyToClipboardProblemDialog_title, CViewMessages.CopyToClipboardProblemDialog_message))
+ if (MessageDialog.openQuestion(shell, CViewMessages.CopyToClipboardProblemDialog_title,
+ CViewMessages.CopyToClipboardProblemDialog_message))
setClipboard(resources, fileNames, names);
}
}
+
/**
* The <code>CopyAction</code> implementation of this
- * <code>SelectionListenerAction</code> method enables this action if
+ * <code>SelectionListenerAction</code> method enables this action if
* one or more resources of compatible types are selected.
*/
@Override
@@ -186,7 +189,7 @@ public class CopyAction extends SelectionListenerAction {
if (projSelected && fileFoldersSelected)
return false;
- // must have a common parent
+ // must have a common parent
IContainer firstParent = ((IResource) selectedResources.get(0)).getParent();
if (firstParent == null)
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java
index dfd2fa9e2cd..19da1e832bf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.cview;
-
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.Action;
@@ -23,16 +22,16 @@ public class DefaultAction extends Action {
Shell shell;
- DefaultAction (Shell shell, String s) {
- super (s);
+ DefaultAction(Shell shell, String s) {
+ super(s);
this.shell = shell;
}
@Override
public void run() {
MessageBox errorMsg = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
- errorMsg.setText(CViewMessages.DefaultAction_WIP);
- errorMsg.setMessage (CViewMessages.DefaultAction_workInProgress);
+ errorMsg.setText(CViewMessages.DefaultAction_WIP);
+ errorMsg.setMessage(CViewMessages.DefaultAction_workInProgress);
errorMsg.open();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java
index ba5e49dc370..daf1d39c1e9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java
@@ -47,7 +47,7 @@ public class GotoActionGroup extends CViewActionGroup {
@Override
public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
+ IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
if (selection.size() == 1) {
if (SelectionConverter.allResourcesAreOfType(selection, IResource.FOLDER)) {
@@ -98,11 +98,11 @@ public class GotoActionGroup extends CViewActionGroup {
// This should never happen because resource navigator sets
// context immediately after this group is created.
if (context != null) {
- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
if (selection.size() == 1) {
Object object = selection.getFirstElement();
if (object instanceof IAdaptable) {
- IResource resource = ((IAdaptable)object).getAdapter(IResource.class);
+ IResource resource = ((IAdaptable) object).getAdapter(IResource.class);
if (resource instanceof IProject) {
enable = ((IProject) resource).isOpen();
} else if (resource instanceof IFolder) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java
index c49c24f716c..85ac40ab451 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java
@@ -14,7 +14,6 @@
package org.eclipse.cdt.internal.ui.cview;
-
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;
@@ -32,7 +31,7 @@ public class IncludeRefContainer extends CElementGrouping {
ICProject fCProject;
/**
- *
+ *
*/
public IncludeRefContainer(ICProject cproject) {
super(INCLUDE_REF_CONTAINER);
@@ -81,7 +80,7 @@ public class IncludeRefContainer extends CElementGrouping {
*/
@Override
public String getLabel(Object o) {
- return CViewMessages.IncludeRefContainer_Includes;
+ return CViewMessages.IncludeRefContainer_Includes;
}
/* (non-Javadoc)
@@ -102,7 +101,7 @@ public class IncludeRefContainer extends CElementGrouping {
@Override
public boolean equals(Object obj) {
if (obj instanceof IncludeRefContainer) {
- IncludeRefContainer other = (IncludeRefContainer)obj;
+ IncludeRefContainer other = (IncludeRefContainer) obj;
return fCProject.equals(other.getCProject());
}
return super.equals(obj);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java
index 6c76839627a..8f18cde5506 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java
@@ -31,7 +31,7 @@ public class IncludeReferenceProxy extends CElementGrouping {
IncludeRefContainer includeRefContainer;
IIncludeReference reference;
-
+
public IncludeReferenceProxy(IncludeRefContainer parent, IIncludeReference reference) {
super(0);
this.reference = reference;
@@ -97,7 +97,7 @@ public class IncludeReferenceProxy extends CElementGrouping {
public int hashCode() {
return reference.hashCode();
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java
index 87c00ebd130..c0c50a0be19 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java
@@ -36,7 +36,7 @@ public class LibraryRefContainer extends CElementGrouping {
private ICProject fCProject;
/**
- *
+ *
*/
public LibraryRefContainer(ICProject cproject) {
super(LIBRARY_REF_CONTAINER);
@@ -89,7 +89,7 @@ public class LibraryRefContainer extends CElementGrouping {
*/
@Override
public String getLabel(Object o) {
- return CViewMessages.LibraryRefContainer_Libraries;
+ return CViewMessages.LibraryRefContainer_Libraries;
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
index 545c20d8863..f33ba40e223 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
@@ -73,21 +73,20 @@ public class MainActionGroup extends CViewActionGroup {
CollapseAllAction collapseAllAction;
ToggleLinkingAction toggleLinkingAction;
-
BuildGroup buildGroup;
OpenFileGroup openFileGroup;
GotoActionGroup gotoGroup;
RefactorActionGroup refactorGroup;
OpenProjectGroup openProjectGroup;
WorkingSetFilterActionGroup workingSetGroup;
- CustomFiltersActionGroup fCustomFiltersActionGroup;
+ CustomFiltersActionGroup fCustomFiltersActionGroup;
SelectionSearchGroup selectionSearchGroup;
- OpenViewActionGroup openViewActionGroup;
+ OpenViewActionGroup openViewActionGroup;
CRefactoringActionGroup crefactoringActionGroup;
-
- private NewWizardMenu newWizardMenu;
+
+ private NewWizardMenu newWizardMenu;
public MainActionGroup(CView cview) {
super(cview);
@@ -129,7 +128,7 @@ public class MainActionGroup extends CViewActionGroup {
buildGroup = new BuildGroup(getCView());
refactorGroup = new RefactorActionGroup(getCView());
- newWizardMenu = new NewWizardMenu(getCView().getSite().getWorkbenchWindow());
+ newWizardMenu = new NewWizardMenu(getCView().getSite().getWorkbenchWindow());
openIncludeAction = new OpenIncludeAction(viewer);
@@ -140,10 +139,10 @@ public class MainActionGroup extends CViewActionGroup {
@Override
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
-
+
if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {
Object newValue = event.getNewValue();
-
+
if (newValue instanceof IWorkingSet) {
getCView().setWorkingSet((IWorkingSet) newValue);
} else if (newValue == null) {
@@ -154,7 +153,7 @@ public class MainActionGroup extends CViewActionGroup {
};
workingSetGroup = new WorkingSetFilterActionGroup(shell, workingSetUpdater);
workingSetGroup.setWorkingSet(getCView().getWorkingSet());
- fCustomFiltersActionGroup= new CustomFiltersActionGroup(getCView(), getCView().getViewer());
+ fCustomFiltersActionGroup = new CustomFiltersActionGroup(getCView(), getCView().getViewer());
addBookmarkAction = new AddBookmarkAction(shellProvider, true);
addTaskAction = new AddTaskAction(shellProvider);
@@ -165,13 +164,13 @@ public class MainActionGroup extends CViewActionGroup {
collapseAllAction = new CollapseAllAction(getCView().getViewer());
- toggleLinkingAction = new ToggleLinkingAction(getCView());
+ toggleLinkingAction = new ToggleLinkingAction(getCView());
toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$
-// toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
+ // toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
- openViewActionGroup= new OpenViewActionGroup(getCView());
- crefactoringActionGroup= new CRefactoringActionGroup(getCView());
+ openViewActionGroup = new OpenViewActionGroup(getCView());
+ crefactoringActionGroup = new CRefactoringActionGroup(getCView());
}
/**
@@ -234,10 +233,11 @@ public class MainActionGroup extends CViewActionGroup {
menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS + "-end")); //$NON-NLS-1$
menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
-
+
openViewActionGroup.fillContextMenu(menu);
crefactoringActionGroup.fillContextMenu(menu);
}
+
/**
* Extends the superclass implementation to set the context in the
* subgroups.
@@ -257,9 +257,9 @@ public class MainActionGroup extends CViewActionGroup {
}
void addNewMenu(IMenuManager menu, IStructuredSelection selection) {
- MenuManager newMenu = new MenuManager(CViewMessages.NewWizardsActionGroup_new);
- menu.add(newMenu);
- newMenu.add(newWizardMenu);
+ MenuManager newMenu = new MenuManager(CViewMessages.NewWizardsActionGroup_new);
+ menu.add(newMenu);
+ newMenu.add(newWizardMenu);
}
void addBookMarkMenu(IMenuManager menu, IStructuredSelection selection) {
@@ -281,11 +281,11 @@ public class MainActionGroup extends CViewActionGroup {
return;
}
- if (SelectionSearchGroup.canActionBeAdded(selection)){
+ if (SelectionSearchGroup.canActionBeAdded(selection)) {
selectionSearchGroup.fillContextMenu(menu);
}
}
-
+
@Override
public void runDefaultAction(IStructuredSelection selection) {
openFileGroup.runDefaultAction(selection);
@@ -338,7 +338,7 @@ public class MainActionGroup extends CViewActionGroup {
openViewActionGroup.fillActionBars(actionBars);
crefactoringActionGroup.fillActionBars(actionBars);
-
+
IToolBarManager toolBar = actionBars.getToolBarManager();
toolBar.add(new Separator());
toolBar.add(collapseAllAction);
@@ -357,7 +357,7 @@ public class MainActionGroup extends CViewActionGroup {
//fWorkingSetFilterActionGroup.restoreState(memento);
fCustomFiltersActionGroup.restoreState(memento);
}
-
+
@Override
public void saveFilterAndSorterState(IMemento memento) {
//fWorkingSetFilterActionGroup.saveState(memento);
@@ -365,7 +365,7 @@ public class MainActionGroup extends CViewActionGroup {
}
public CustomFiltersActionGroup getCustomFilterActionGroup() {
- return fCustomFiltersActionGroup;
+ return fCustomFiltersActionGroup;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java
index ac33b230ae6..40be5537331 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java
@@ -56,11 +56,12 @@ public class OpenFileGroup extends CViewActionGroup {
@Override
public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
+ IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
- boolean anyResourceSelected = !selection.isEmpty()
- && SelectionConverter.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE);
- boolean onlyFilesSelected = !selection.isEmpty() && SelectionConverter.allResourcesAreOfType(selection, IResource.FILE);
+ boolean anyResourceSelected = !selection.isEmpty() && SelectionConverter.allResourcesAreOfType(selection,
+ IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+ boolean onlyFilesSelected = !selection.isEmpty()
+ && SelectionConverter.allResourcesAreOfType(selection, IResource.FILE);
if (onlyFilesSelected) {
openFileAction.selectionChanged(selection);
@@ -75,7 +76,7 @@ public class OpenFileGroup extends CViewActionGroup {
/**
* Adds the OpenWith submenu to the context menu.
- *
+ *
* @param menu
* the context menu
* @param selection
@@ -91,14 +92,14 @@ public class OpenFileGroup extends CViewActionGroup {
return;
}
- MenuManager submenu = new MenuManager(CViewMessages.OpenWithMenu_label);
+ MenuManager submenu = new MenuManager(CViewMessages.OpenWithMenu_label);
submenu.add(new OpenWithMenu(getCView().getSite().getPage(), (IFile) element));
menu.add(submenu);
}
/**
* Adds the Open in New Window action to the context menu.
- *
+ *
* @param menu
* the context menu
* @param selection
@@ -121,18 +122,19 @@ public class OpenFileGroup extends CViewActionGroup {
menu.add(new OpenInNewWindowAction(getCView().getSite().getWorkbenchWindow(), (IContainer) element));
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+ */
+ @Override
public void fillActionBars(IActionBars actionBars) {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
- */
- @Override
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+ */
+ @Override
public void updateActionBars() {
- }
+ }
/**
* Runs the default action (open file).
@@ -155,14 +157,13 @@ public class OpenFileGroup extends CViewActionGroup {
} catch (Exception e) {
}
} else if (obj instanceof IAdaptable) {
- IResource element = ((IAdaptable)obj).getAdapter(IResource.class);
+ IResource element = ((IAdaptable) obj).getAdapter(IResource.class);
if (element instanceof IFile) {
openFileAction.selectionChanged(selection);
openFileAction.run();
- }
- else if(element instanceof IProject){
+ } else if (element instanceof IProject) {
try {
- ((IProject)element).open(null);
+ ((IProject) element).open(null);
} catch (CoreException e) {
CUIPlugin.log(e);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java
index e7c8dec1404..e461ea7308a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java
@@ -69,7 +69,7 @@ public class OpenProjectGroup extends CViewActionGroup {
* <p>
* No disabled action should be on the context menu.
* </p>
- *
+ *
* @param menu
* context menu to add actions to
*/
@@ -90,7 +90,7 @@ public class OpenProjectGroup extends CViewActionGroup {
} else if (next instanceof IAdaptable) {
IResource res = ((IAdaptable) next).getAdapter(IResource.class);
if (res instanceof IProject) {
- project = (IProject)res;
+ project = (IProject) res;
}
}
@@ -136,7 +136,7 @@ public class OpenProjectGroup extends CViewActionGroup {
@Override
protected void makeActions() {
- final IWorkbenchPartSite site= getCView().getSite();
+ final IWorkbenchPartSite site = getCView().getSite();
IWorkspace workspace = CUIPlugin.getWorkspace();
openProjectAction = new OpenResourceAction(site);
@@ -146,7 +146,7 @@ public class OpenProjectGroup extends CViewActionGroup {
refreshAction = new RefreshAction(site);
refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$
refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));//$NON-NLS-1$
-// refreshAction.setHoverImageDescriptor(getImageDescriptor("clcl16/refresh_nav.gif"));//$NON-NLS-1$
+ // refreshAction.setHoverImageDescriptor(getImageDescriptor("clcl16/refresh_nav.gif"));//$NON-NLS-1$
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
index 4cef933aeee..51ebeed9317 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
@@ -38,7 +38,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
- *
+ *
* @since 2.0
*/
/*package*/
@@ -65,19 +65,20 @@ public class PasteAction extends SelectionListenerAction {
* @param shell the shell for any dialogs
*/
public PasteAction(Shell shell, Clipboard clipboard) {
- super(CViewMessages.PasteAction_title);
+ super(CViewMessages.PasteAction_title);
Assert.isNotNull(shell);
Assert.isNotNull(clipboard);
this.shell = shell;
this.clipboard = clipboard;
- setToolTipText(CViewMessages.PasteAction_toolTip);
+ setToolTipText(CViewMessages.PasteAction_toolTip);
setId(PasteAction.ID);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.PASTE_ACTION);
}
+
/**
* Returns the actual target of the paste action. Returns null
* if no valid target is selected.
- *
+ *
* @return the actual target of the paste action
*/
private IResource getTarget() {
@@ -95,11 +96,12 @@ public class PasteAction extends SelectionListenerAction {
}
return null;
}
+
/**
* Returns whether any of the given resources are linked resources.
- *
+ *
* @param resources resource to check for linked type. may be null
- * @return true=one or more resources are linked. false=none of the
+ * @return true=one or more resources are linked. false=none of the
* resources are linked
*/
private boolean isLinked(IResource[] resources) {
@@ -112,6 +114,7 @@ public class PasteAction extends SelectionListenerAction {
}
return false;
}
+
/**
* Implementation of method defined on <code>IAction</code>.
*/
@@ -150,6 +153,7 @@ public class PasteAction extends SelectionListenerAction {
operation.copyFiles(fileData, container);
}
}
+
/**
* Returns the container to hold the pasted resources.
*/
@@ -159,9 +163,10 @@ public class PasteAction extends SelectionListenerAction {
return ((IFile) selection.get(0)).getParent();
return (IContainer) selection.get(0);
}
+
/**
* The <code>PasteAction</code> implementation of this
- * <code>SelectionListenerAction</code> method enables this action if
+ * <code>SelectionListenerAction</code> method enables this action if
* a resource compatible with what is on the clipboard is selected.
*/
@Override
@@ -175,11 +180,11 @@ public class PasteAction extends SelectionListenerAction {
public void run() {
// clipboard must have resources or files
ResourceTransfer resTransfer = ResourceTransfer.getInstance();
- clipboardData[0] = (IResource[])clipboard.getContents(resTransfer);
+ clipboardData[0] = (IResource[]) clipboard.getContents(resTransfer);
}
});
IResource[] resourceData = clipboardData[0];
- if (resourceData != null && resourceData.length > 0 && resourceData[0].getType() == IResource.PROJECT) {
+ if (resourceData != null && resourceData.length > 0 && resourceData[0].getType() == IResource.PROJECT) {
for (int i = 0; i < resourceData.length; i++) {
// make sure all resource data are open projects
// can paste open projects regardless of selection
@@ -194,8 +199,8 @@ public class PasteAction extends SelectionListenerAction {
if (getSelectedNonResources().size() > 0)
return false;
- // targetResource is null if no valid target is selected or
- // selection is empty
+ // targetResource is null if no valid target is selected or
+ // selection is empty
IResource targetResource = getTarget();
if (targetResource == null)
return false;
@@ -204,7 +209,7 @@ public class PasteAction extends SelectionListenerAction {
// open project) or multiple file selection with the same parent
List<?> selectedResources = getSelectedResources();
if (selectedResources.size() > 1) {
- // if more than one resource is selected the selection has
+ // if more than one resource is selected the selection has
// to be all files with the same parent
for (int i = 0; i < selectedResources.size(); i++) {
IResource resource = (IResource) selectedResources.get(i);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java
index e078097b052..89aa3ded53a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java
@@ -35,7 +35,7 @@ import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
/**
* This is the action group for refactor actions,
* including global action handlers for copy, paste and delete.
- *
+ *
*/
public class RefactorActionGroup extends CViewActionGroup {
@@ -47,7 +47,7 @@ public class RefactorActionGroup extends CViewActionGroup {
private CViewRenameAction renameAction;
private CViewMoveAction moveAction;
private TextActionHandler textActionHandler;
-
+
public RefactorActionGroup(CView cview) {
super(cview);
}
@@ -66,8 +66,8 @@ public class RefactorActionGroup extends CViewActionGroup {
IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
- boolean anyResourceSelected = !selection.isEmpty()
- && SelectionConverter.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+ boolean anyResourceSelected = !selection.isEmpty() && SelectionConverter.allResourcesAreOfType(selection,
+ IResource.PROJECT | IResource.FOLDER | IResource.FILE);
copyAction.selectionChanged(selection);
menu.add(copyAction);
@@ -91,14 +91,14 @@ public class RefactorActionGroup extends CViewActionGroup {
textActionHandler.setPasteAction(pasteAction);
textActionHandler.setDeleteAction(deleteAction);
renameAction.setTextActionHandler(textActionHandler);
-
+
actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction);
actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
}
/**
- * Handles a key pressed event by invoking the appropriate action.
- */
+ * Handles a key pressed event by invoking the appropriate action.
+ */
@Override
public void handleKeyPressed(KeyEvent event) {
if (event.character == SWT.DEL && event.stateMask == 0) {
@@ -112,7 +112,7 @@ public class RefactorActionGroup extends CViewActionGroup {
renameAction.run();
}
// Swallow the event.
- event.doit = false;
+ event.doit = false;
}
}
@@ -122,7 +122,7 @@ public class RefactorActionGroup extends CViewActionGroup {
final IWorkbenchPartSite site = getCView().getSite();
Shell shell = site.getShell();
clipboard = new Clipboard(shell.getDisplay());
-
+
pasteAction = new PasteAction(shell, clipboard);
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
@@ -133,13 +133,13 @@ public class RefactorActionGroup extends CViewActionGroup {
copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
copyAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
-
+
moveAction = new CViewMoveAction(site, treeViewer);
renameAction = new CViewRenameAction(site, treeViewer);
-
+
deleteAction = new DeleteResourceAction(site);
deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
- deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
deleteAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java
index 6d8e24fe7a6..73986e9958b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java
@@ -26,19 +26,19 @@ import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
public class SelectionTransferDragAdapter extends BasicSelectionTransferDragAdapter {
-
+
public SelectionTransferDragAdapter(ISelectionProvider provider) {
super(provider);
}
-
+
@Override
protected boolean isDragable(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- for (Iterator<?> iter= ((IStructuredSelection)selection).iterator(); iter.hasNext();) {
- Object element= iter.next();
+ for (Iterator<?> iter = ((IStructuredSelection) selection).iterator(); iter.hasNext();) {
+ Object element = iter.next();
if (element instanceof ICElement) {
if (!(element instanceof ISourceReference)) {
- return false;
+ return false;
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java
index f3099d3a93b..01b868f686f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java
@@ -49,22 +49,22 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement
private ICElement[] fMoveData;
private ICElement[] fCopyData;
- private static final long DROP_TIME_DIFF_TRESHOLD= 150;
+ private static final long DROP_TIME_DIFF_TRESHOLD = 150;
public SelectionTransferDropAdapter(StructuredViewer viewer) {
super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
}
//---- TransferDropTargetListener interface ---------------------------------------
-
+
@Override
public Transfer getTransfer() {
return LocalSelectionTransfer.getTransfer();
}
-
+
@Override
public boolean isEnabled(DropTargetEvent event) {
- Object target= event.item != null ? event.item.getData() : null;
+ Object target = event.item != null ? event.item.getData() : null;
if (target == null) {
return false;
}
@@ -72,117 +72,121 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement
}
//---- Actual DND -----------------------------------------------------------------
-
+
@Override
public void dragEnter(DropTargetEvent event) {
clear();
super.dragEnter(event);
}
-
+
@Override
public void dragLeave(DropTargetEvent event) {
clear();
super.dragLeave(event);
}
-
+
private void clear() {
fElements = null;
fMoveData = null;
fCopyData = null;
}
-
+
@Override
public void validateDrop(Object target, DropTargetEvent event, int operation) {
- event.detail= DND.DROP_NONE;
-
- if (tooFast(event)) {
+ event.detail = DND.DROP_NONE;
+
+ if (tooFast(event)) {
return;
}
-
+
initializeSelection();
-
+
try {
- switch(operation) {
- case DND.DROP_DEFAULT:
- event.detail= handleValidateDefault(target, event);
- break;
- case DND.DROP_COPY:
- event.detail= handleValidateCopy(target, event);
- break;
- case DND.DROP_MOVE:
- event.detail= handleValidateMove(target, event);
- break;
- case DND.DROP_LINK:
- event.detail= handleValidateLink(target, event);
- break;
+ switch (operation) {
+ case DND.DROP_DEFAULT:
+ event.detail = handleValidateDefault(target, event);
+ break;
+ case DND.DROP_COPY:
+ event.detail = handleValidateCopy(target, event);
+ break;
+ case DND.DROP_MOVE:
+ event.detail = handleValidateMove(target, event);
+ break;
+ case DND.DROP_LINK:
+ event.detail = handleValidateLink(target, event);
+ break;
}
- } catch (CModelException e){
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message);
- event.detail= DND.DROP_NONE;
- }
+ } catch (CModelException e) {
+ ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title,
+ CViewMessages.SelectionTransferDropAdapter_error_message);
+ event.detail = DND.DROP_NONE;
+ }
}
- protected void initializeSelection(){
+ protected void initializeSelection() {
if (fElements != null) {
return;
}
- ISelection s= LocalSelectionTransfer.getTransfer().getSelection();
+ ISelection s = LocalSelectionTransfer.getTransfer().getSelection();
if (!(s instanceof IStructuredSelection)) {
return;
}
- fElements = ((IStructuredSelection)s).toList();
+ fElements = ((IStructuredSelection) s).toList();
}
-
+
private boolean tooFast(DropTargetEvent event) {
- return Math.abs(LocalSelectionTransfer.getTransfer().getSelectionSetTime() - (event.time & 0xFFFFFFFFL)) < DROP_TIME_DIFF_TRESHOLD;
- }
+ return Math.abs(LocalSelectionTransfer.getTransfer().getSelectionSetTime()
+ - (event.time & 0xFFFFFFFFL)) < DROP_TIME_DIFF_TRESHOLD;
+ }
@Override
public void drop(Object target, DropTargetEvent event) {
try {
- switch(event.detail) {
- case DND.DROP_MOVE:
- handleDropMove(target, event);
- break;
- case DND.DROP_COPY:
- handleDropCopy(target, event);
- break;
- case DND.DROP_LINK:
- handleDropLink(target, event);
- break;
+ switch (event.detail) {
+ case DND.DROP_MOVE:
+ handleDropMove(target, event);
+ break;
+ case DND.DROP_COPY:
+ handleDropCopy(target, event);
+ break;
+ case DND.DROP_LINK:
+ handleDropLink(target, event);
+ break;
}
- } catch (CModelException e){
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message);
- } catch(InvocationTargetException e) {
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_exception);
+ } catch (CModelException e) {
+ ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title,
+ CViewMessages.SelectionTransferDropAdapter_error_message);
+ } catch (InvocationTargetException e) {
+ ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title,
+ CViewMessages.SelectionTransferDropAdapter_error_exception);
} catch (InterruptedException e) {
//ok
} finally {
// The drag source listener must not perform any operation
// since this drop adapter did the remove of the source even
// if we moved something.
- event.detail= DND.DROP_NONE;
+ event.detail = DND.DROP_NONE;
}
}
-
+
private int handleValidateDefault(Object target, DropTargetEvent event) throws CModelException {
if (target == null) {
return DND.DROP_NONE;
- }
- return handleValidateMove(target, event);
+ }
+ return handleValidateMove(target, event);
}
-
+
private int handleValidateMove(Object target, DropTargetEvent event) throws CModelException {
if (target == null || fElements.contains(target)) {
return DND.DROP_NONE;
}
if (fMoveData == null) {
- ICElement[] cElements= getCElements(fElements);
+ ICElement[] cElements = getCElements(fElements);
if (cElements != null && cElements.length > 0) {
fMoveData = cElements;
}
}
-
+
if (!canMoveElements()) {
return DND.DROP_NONE;
}
@@ -192,7 +196,7 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement
}
return DND.DROP_NONE;
}
-
+
private boolean canMoveElements() {
if (fMoveData != null) {
return hasCommonParent(fMoveData);
@@ -209,7 +213,7 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement
if (p != null) {
return false;
}
- } else if (!parent.equals(p)){
+ } else if (!parent.equals(p)) {
return false;
}
}
@@ -223,12 +227,13 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement
private int handleValidateLink(Object target, DropTargetEvent event) {
return DND.DROP_NONE;
}
-
- private void handleDropMove(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
- final ICElement[] cElements= getCElements(fElements);
-
+
+ private void handleDropMove(final Object target, DropTargetEvent event)
+ throws CModelException, InvocationTargetException, InterruptedException {
+ final ICElement[] cElements = getCElements(fElements);
+
if (target instanceof ICElement) {
- ICElement cTarget = (ICElement)target;
+ ICElement cTarget = (ICElement) target;
ICElement parent = cTarget;
boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
if (!isTargetTranslationUnit) {
@@ -260,39 +265,40 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement
}
}
- private int handleValidateCopy(Object target, DropTargetEvent event) throws CModelException{
+ private int handleValidateCopy(Object target, DropTargetEvent event) throws CModelException {
if (target == null) {
return DND.DROP_NONE;
}
if (fCopyData == null) {
- ICElement[] cElements= getCElements(fElements);
+ ICElement[] cElements = getCElements(fElements);
if (cElements != null && cElements.length > 0) {
- fCopyData= cElements;
+ fCopyData = cElements;
}
}
-
+
if (!canCopyElements())
- return DND.DROP_NONE;
+ return DND.DROP_NONE;
if (target instanceof ISourceReference) {
return DND.DROP_COPY;
}
- return DND.DROP_NONE;
+ return DND.DROP_NONE;
}
-
+
private boolean canCopyElements() {
if (fCopyData != null) {
return hasCommonParent(fCopyData);
}
return false;
- }
-
- private void handleDropCopy(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
- final ICElement[] cElements= getCElements(fElements);
+ }
+
+ private void handleDropCopy(final Object target, DropTargetEvent event)
+ throws CModelException, InvocationTargetException, InterruptedException {
+ final ICElement[] cElements = getCElements(fElements);
if (target instanceof ICElement) {
- ICElement cTarget = (ICElement)target;
+ ICElement cTarget = (ICElement) target;
ICElement parent = cTarget;
boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
if (!isTargetTranslationUnit) {
@@ -329,14 +335,14 @@ public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implement
}
public void run(IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException {
- IRunnableContext context= new ProgressMonitorDialog(getShell());
+ IRunnableContext context = new ProgressMonitorDialog(getShell());
context.run(true, true, runnable);
}
public static ICElement[] getCElements(List<?> elements) {
- List<ICElement> resources= new ArrayList<ICElement>(elements.size());
- for (Iterator<?> iter= elements.iterator(); iter.hasNext();) {
- Object element= iter.next();
+ List<ICElement> resources = new ArrayList<ICElement>(elements.size());
+ for (Iterator<?> iter = elements.iterator(); iter.hasNext();) {
+ Object element = iter.next();
if (element instanceof ITranslationUnit) {
continue;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java
index 98de9ac3f91..921fa25cd1e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java
@@ -19,13 +19,13 @@ import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
/**
* This action toggles whether this navigator links its selection to the active
* editor.
- *
+ *
* @since 2.0
*/
public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- CView fCView;
-
+
+ CView fCView;
+
/**
* Constructs a new action.
*/
@@ -39,7 +39,7 @@ public class ToggleLinkingAction extends AbstractToggleLinkingAction {
*/
@Override
public void run() {
- fCView.setLinkingEnabled(isChecked());
+ fCView.setLinkingEnabled(isChecked());
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java
index c2724734855..8d2fb34393c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java
@@ -34,27 +34,28 @@ import org.eclipse.swt.widgets.Shell;
* A class to select one or more elements out of an indexed property
*/
public abstract class AbstractElementListSelectionDialog extends SelectionStatusDialog {
-
+
private ILabelProvider fRenderer;
private boolean fIgnoreCase;
private boolean fIsMultipleSelection;
-
+
private SelectionList fSelectionList;
private Label fMessage;
- private ISelectionValidator fValidator;
-
+ private ISelectionValidator fValidator;
+
private String fMessageText;
private String fEmptyListMessage;
private String fNothingSelectedMessage;
-
+
private StatusInfo fCurrStatus;
-
+
/*
* @private
*/
protected void access$superOpen() {
super.open();
}
+
/*
* @private
* @see Dialog#cancelPressed
@@ -64,60 +65,65 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus
setResult(null);
super.cancelPressed();
}
+
protected Point computeInitialSize() {
return new Point(convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(18));
}
+
/*
* @private
* @see Window#createDialogArea(Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
- Composite contents= (Composite)super.createDialogArea(parent);
-
- fMessage= createMessage(contents);
-
- int flags= fIsMultipleSelection ? SWT.MULTI : SWT.SINGLE;
- fSelectionList= new SelectionList(contents, flags | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
- fRenderer, fIgnoreCase);
-
+ Composite contents = (Composite) super.createDialogArea(parent);
+
+ fMessage = createMessage(contents);
+
+ int flags = fIsMultipleSelection ? SWT.MULTI : SWT.SINGLE;
+ fSelectionList = new SelectionList(contents, flags | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, fRenderer,
+ fIgnoreCase);
+
fSelectionList.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
handleDoubleClick();
}
+
@Override
public void widgetSelected(SelectionEvent e) {
verifyCurrentSelection();
}
});
- GridData spec= new GridData();
- Point initialSize= computeInitialSize();
- spec.widthHint= initialSize.x;
- spec.heightHint= initialSize.y;
- spec.grabExcessVerticalSpace= true;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.FILL;
+ GridData spec = new GridData();
+ Point initialSize = computeInitialSize();
+ spec.widthHint = initialSize.x;
+ spec.heightHint = initialSize.y;
+ spec.grabExcessVerticalSpace = true;
+ spec.grabExcessHorizontalSpace = true;
+ spec.horizontalAlignment = GridData.FILL;
+ spec.verticalAlignment = GridData.FILL;
fSelectionList.setLayoutData(spec);
-
+
return contents;
}
+
/**
* Creates the message text widget and sets layout data.
*/
protected Label createMessage(Composite parent) {
- Label text= new Label(parent, SWT.NULL);
+ Label text = new Label(parent, SWT.NULL);
text.setText(fMessageText);
- GridData spec= new GridData();
- spec.grabExcessVerticalSpace= false;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.BEGINNING;
+ GridData spec = new GridData();
+ spec.grabExcessVerticalSpace = false;
+ spec.grabExcessHorizontalSpace = true;
+ spec.horizontalAlignment = GridData.FILL;
+ spec.verticalAlignment = GridData.BEGINNING;
text.setLayoutData(spec);
return text;
}
+
/*
* @private
* @see Window#create(Shell)
@@ -125,27 +131,30 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus
@Override
public void create() {
super.create();
- if (isEmptyList()) {
- fMessage.setEnabled(false);
- fSelectionList.setEnabled(false);
- } else {
- verifyCurrentSelection();
+ if (isEmptyList()) {
+ fMessage.setEnabled(false);
+ fSelectionList.setEnabled(false);
+ } else {
+ verifyCurrentSelection();
fSelectionList.selectFilterText();
fSelectionList.setFocus();
- }
+ }
}
+
/**
* Returns the currently used filter text.
*/
protected String getFilter() {
return fSelectionList.getFilter();
}
+
/**
* Returns the selection indices.
*/
protected int[] getSelectionIndices() {
return fSelectionList.getSelectionIndices();
}
+
/**
* Returns the widget selection. Returns empty list when the widget is not
* usable.
@@ -153,13 +162,15 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus
protected List<?> getWidgetSelection() {
if (fSelectionList == null || fSelectionList.isDisposed())
return Collections.emptyList();
- return fSelectionList.getSelection();
+ return fSelectionList.getSelection();
}
+
/**
* An element as been selected in the list by double clicking on it.
* Emulate a OK button pressed to close the dialog.
- */
+ */
protected abstract void handleDoubleClick();
+
/**
* Checks whether the list of elements is empty or not.
*/
@@ -168,37 +179,42 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus
return true;
return fSelectionList.isEmptyList();
}
+
/**
* Constructs a list selection dialog.
* @param renderer The label renderer used
* @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
+ * @param multipleSelection Allow multiple selection
*/
- protected AbstractElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
+ protected AbstractElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer,
+ boolean ignoreCase, boolean multipleSelection) {
super(parent);
setTitle(title);
setImage(image);
- fRenderer= renderer;
- fIgnoreCase= ignoreCase;
- fIsMultipleSelection= multipleSelection;
-
- fMessageText= ""; //$NON-NLS-1$
-
- fCurrStatus= new StatusInfo();
-
- fValidator= null;
- fEmptyListMessage= ""; //$NON-NLS-1$
- fNothingSelectedMessage= ""; //$NON-NLS-1$
+ fRenderer = renderer;
+ fIgnoreCase = ignoreCase;
+ fIsMultipleSelection = multipleSelection;
+
+ fMessageText = ""; //$NON-NLS-1$
+
+ fCurrStatus = new StatusInfo();
+
+ fValidator = null;
+ fEmptyListMessage = ""; //$NON-NLS-1$
+ fNothingSelectedMessage = ""; //$NON-NLS-1$
}
+
/**
* Constructs a list selection dialog.
* @param renderer The label renderer used
* @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
+ * @param multipleSelection Allow multiple selection
*/
- protected AbstractElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
+ protected AbstractElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase,
+ boolean multipleSelection) {
this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$
}
+
/*
* @private
*/
@@ -210,8 +226,9 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus
access$superOpen();
}
});
- return getReturnCode() ;
+ return getReturnCode();
}
+
/**
* Refilters the current list according to the filter entered into the
* text edit field.
@@ -219,33 +236,38 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus
protected void refilter() {
fSelectionList.filter(true);
}
+
/**
* If a empty-list message is set, a error message is shown
* Must be set before widget creation
*/
public void setEmptyListMessage(String message) {
- fEmptyListMessage= message;
+ fEmptyListMessage = message;
}
+
/**
* Sets the filter text to the given value.
*/
protected void setFilter(String text, boolean refilter) {
fSelectionList.setFilter(text, refilter);
}
+
/**
* Sets the message to be shown above the match text field.
* Must be set before widget creation
*/
@Override
public void setMessage(String message) {
- fMessageText= message;
+ fMessageText = message;
}
+
/**
* If the selection is empty, this message is shown
*/
public void setNothingSelectedMessage(String message) {
- fNothingSelectedMessage= message;
+ fNothingSelectedMessage = message;
}
+
/**
* Selects the elements in the list determined by the given
* selection indices.
@@ -253,6 +275,7 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus
protected void setSelection(int[] selection) {
fSelectionList.setSelection(selection);
}
+
/**
* Initializes the selection list widget with the given list of
* elements.
@@ -260,20 +283,22 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus
protected void setSelectionListElements(List<?> elements, boolean refilter) {
fSelectionList.setElements(elements, refilter);
}
+
/**
* A validator can be set to check if the current selection
* is valid
*/
public void setValidator(ISelectionValidator validator) {
- fValidator= validator;
+ fValidator = validator;
}
+
/**
* Verifies the current selection and updates the status line
* accordingly.
*/
protected boolean verifyCurrentSelection() {
- List<?> sel= getWidgetSelection();
- int length= sel.size();
+ List<?> sel = getWidgetSelection();
+ int length = sel.size();
if (length > 0) {
if (fValidator != null) {
fValidator.isValid(sel.toArray(), fCurrStatus);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java
index 234f75c3bca..8da42e65326 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java
@@ -28,9 +28,9 @@ import org.eclipse.swt.widgets.Shell;
* A class to select one or more elements out of an indexed property
*/
public class ElementListSelectionDialog extends AbstractElementListSelectionDialog {
-
+
private List<?> fElements;
-
+
/*
* @private
*/
@@ -38,73 +38,85 @@ public class ElementListSelectionDialog extends AbstractElementListSelectionDial
protected void computeResult() {
setResult(getWidgetSelection());
}
+
/*
* @private
- */
+ */
@Override
protected Control createDialogArea(Composite parent) {
- Control result= super.createDialogArea(parent);
-
+ Control result = super.createDialogArea(parent);
+
setSelectionListElements(fElements, false);
- //a little trick to make the window come up faster
- String initialFilter= null;
- if (getPrimaryInitialSelection() instanceof String)
- initialFilter= (String)getPrimaryInitialSelection();
- if (initialFilter != null)
- setFilter(initialFilter, true);
- else
- refilter();
-
+ //a little trick to make the window come up faster
+ String initialFilter = null;
+ if (getPrimaryInitialSelection() instanceof String)
+ initialFilter = (String) getPrimaryInitialSelection();
+ if (initialFilter != null)
+ setFilter(initialFilter, true);
+ else
+ refilter();
+
return result;
}
+
public Object getSelectedElement() {
return getPrimaryResult();
}
+
public Object[] getSelectedElements() {
return getResult();
}
+
/*
* @private
- */
+ */
@Override
protected void handleDoubleClick() {
if (verifyCurrentSelection()) {
buttonPressed(IDialogConstants.OK_ID);
}
}
+
/**
* Constructs a list selection dialog.
* @param renderer The label renderer used
* @param ignoreCase Decides if the match string ignores lower/upper case
- * @param multipleSelection Allow multiple selection
+ * @param multipleSelection Allow multiple selection
*/
- public ElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- super (parent, title, image, renderer, ignoreCase, multipleSelection);
+ public ElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer,
+ boolean ignoreCase, boolean multipleSelection) {
+ super(parent, title, image, renderer, ignoreCase, multipleSelection);
}
+
/**
* Constructs a list selection dialog.
* @param renderer The label renderer used
* @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
+ * @param multipleSelection Allow multiple selection
*/
- public ElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
+ public ElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase,
+ boolean multipleSelection) {
this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$
}
+
public int open(Object[] elements) {
return open(Arrays.asList(elements));
}
+
public int open(Object[] elements, String initialSelection) {
return open(Arrays.asList(elements), initialSelection);
}
+
/**
* Open the dialog.
* @param elements The elements to show in the list
* @return Returns OK or CANCEL
- */
+ */
public int open(List<?> elements) {
setElements(elements);
return open();
}
+
/**
* Open the dialog.
* @param elements The elements to show in the list
@@ -116,10 +128,11 @@ public class ElementListSelectionDialog extends AbstractElementListSelectionDial
setInitialSelection(initialSelection);
return open();
}
+
/**
* Sets the elements presented by this dialog.
*/
public void setElements(List<?> elements) {
- fElements= elements;
+ fElements = elements;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/FormattingScopeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/FormattingScopeDialog.java
index bba4b7c53ab..cb45d77aa40 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/FormattingScopeDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/FormattingScopeDialog.java
@@ -51,13 +51,10 @@ public class FormattingScopeDialog extends StatusDialog {
createLabel(composite, Messages.FormattingScopeDialog_message);
int indent = converter.convertHorizontalDLUsToPixels(8);
- fScopeFileRadio =
- createRadioButton(composite, Messages.FormattingScopeDialog_format_file, indent);
- fScopeStatementRadio =
- createRadioButton(composite, Messages.FormattingScopeDialog_format_statement, indent);
+ fScopeFileRadio = createRadioButton(composite, Messages.FormattingScopeDialog_format_file, indent);
+ fScopeStatementRadio = createRadioButton(composite, Messages.FormattingScopeDialog_format_statement, indent);
createLabel(composite, ""); // Separator //$NON-NLS-1$
- fDoNotAskAgainCheckBox =
- createCheckBox(composite, Messages.FormattingScopeDialog_do_not_ask_again);
+ fDoNotAskAgainCheckBox = createCheckBox(composite, Messages.FormattingScopeDialog_do_not_ask_again);
String scope = preferenceStore.getString(PreferenceConstants.FORMATTING_SCOPE_FOR_EMPTY_SELECTION);
if (PreferenceConstants.FORMATTING_SCOPE_DOCUMENT.equals(scope)) {
@@ -65,14 +62,14 @@ public class FormattingScopeDialog extends StatusDialog {
} else {
fScopeStatementRadio.setSelection(true);
}
- applyDialogFont(composite);
+ applyDialogFont(composite);
return composite;
}
@Override
protected void okPressed() {
- String scope = fScopeFileRadio.getSelection() ?
- PreferenceConstants.FORMATTING_SCOPE_DOCUMENT : PreferenceConstants.FORMATTING_SCOPE_STATEMENT;
+ String scope = fScopeFileRadio.getSelection() ? PreferenceConstants.FORMATTING_SCOPE_DOCUMENT
+ : PreferenceConstants.FORMATTING_SCOPE_STATEMENT;
preferenceStore.setValue(PreferenceConstants.FORMATTING_SCOPE_FOR_EMPTY_SELECTION, scope);
if (fDoNotAskAgainCheckBox.getSelection()) {
preferenceStore.setValue(PreferenceConstants.FORMATTING_CONFIRM_SCOPE_FOR_EMPTY_SELECTION, false);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java
index 41efd1e83ee..8fd0fa998f7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java
@@ -17,7 +17,7 @@ package org.eclipse.cdt.internal.ui.dialogs;
import org.eclipse.core.runtime.IStatus;
public interface IStatusChangeListener {
-
+
/**
* Called to announce that the given status has changed.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java
index 6f6cabdb758..cb668c9951e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java
@@ -23,8 +23,8 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
/**
- * A message line. It distinguishes between "normal" messages and errors.
- * Setting an error message hides a currently displayed message until
+ * A message line. It distinguishes between "normal" messages and errors.
+ * Setting an error message hides a currently displayed message until
* <code>clearErrorMessage</code> is called.
*/
public class MessageLine extends CLabel {
@@ -35,7 +35,7 @@ public class MessageLine extends CLabel {
private RGB fErrorRGB;
protected Color fErrorColor;
- private static RGB fgErrorRGB= new RGB(200, 0, 0);
+ private static RGB fgErrorRGB = new RGB(200, 0, 0);
/**
* Clears the currently displayed error message and redisplays
@@ -44,12 +44,14 @@ public class MessageLine extends CLabel {
public void clearErrorMessage() {
setErrorMessage(null);
}
+
/**
* Clears the currently displayed message.
*/
public void clearMessage() {
setMessage(null);
}
+
/**
* Get the currently displayed error text.
* @return The error message. If no error message is displayed <code>null</code> is returned.
@@ -57,6 +59,7 @@ public class MessageLine extends CLabel {
public String getErrorMessage() {
return fErrorText;
}
+
/**
* Get the currently displayed message.
* @return The message. If no message is displayed <code>null<code> is returned.
@@ -64,24 +67,27 @@ public class MessageLine extends CLabel {
public String getMessage() {
return fMessageText;
}
+
/**
* Creates a new message line as a child of the parent and with the given SWT style bits.
* Error message will be shown with in the given RGB color.
*/
public MessageLine(Composite parent, int style, RGB errorRGB) {
super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= errorRGB;
+ fDefaultColor = getForeground();
+ fErrorRGB = errorRGB;
}
+
/**
* Creates a new message line as a child of the parent and with the given SWT style bits.
* Error message will be shown with in the RGB color 200,0,0.
*/
public MessageLine(Composite parent, int style) {
super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= fgErrorRGB;
+ fDefaultColor = getForeground();
+ fErrorRGB = fgErrorRGB;
}
+
/**
* Creates a new message line as a child of the given parent.
* Error message will be shown with in the RGB color 200,0,0.
@@ -89,25 +95,27 @@ public class MessageLine extends CLabel {
public MessageLine(Composite parent) {
this(parent, SWT.LEFT);
}
+
/**
* Sets the default error color used by all message lines.
- * Note: a call to this method only affects newly created MessageLines not existing ones.
+ * Note: a call to this method only affects newly created MessageLines not existing ones.
*/
public static void setErrorColor(RGB color) {
- fgErrorRGB= color;
+ fgErrorRGB = color;
}
+
/**
* Display the given error message. A currently displayed message
* is saved and will be redisplayed when the error message is cleared.
*/
public void setErrorMessage(String message) {
- fErrorText= message;
+ fErrorText = message;
if (message == null) {
setMessage(fMessageText);
} else {
if (fErrorColor == null) {
- fErrorColor= new Color(getDisplay(), fErrorRGB);
+ fErrorColor = new Color(getDisplay(), fErrorRGB);
addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
@@ -119,14 +127,15 @@ public class MessageLine extends CLabel {
setText(message);
}
}
+
/**
* Set the message text. If the message line currently displays an error,
* the message is stored and will be shown after a call to clearErrorMessage
*/
public void setMessage(String message) {
- fMessageText= message;
+ fMessageText = message;
if (message == null)
- message= ""; //$NON-NLS-1$
+ message = ""; //$NON-NLS-1$
if (fErrorText == null) {
setForeground(fDefaultColor);
setText(message);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java
index e05311f2f4f..5dc29c8ca06 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -35,15 +35,15 @@ import org.eclipse.cdt.internal.ui.CUIMessages;
/**
* This is a <code>MessageDialog</code> which allows the user
* to choose that the dialog isn't shown again the next time.
- */
+ */
public class OptionalMessageDialog extends MessageDialog {
// Dialog store id constants
- private static final String STORE_ID= "OptionalMessageDialog.hide."; //$NON-NLS-1$
+ private static final String STORE_ID = "OptionalMessageDialog.hide."; //$NON-NLS-1$
private static final String KEY_DETAIL = ".detail"; //$NON-NLS-1$
- public static final int NOT_SHOWN= IDialogConstants.CLIENT_ID + 1;
- public static final int NO_DETAIL= -1;
-
+ public static final int NOT_SHOWN = IDialogConstants.CLIENT_ID + 1;
+ public static final int NO_DETAIL = -1;
+
private Button fHideDialogCheckBox;
private String fId;
private String fHideMessage;
@@ -52,97 +52,100 @@ public class OptionalMessageDialog extends MessageDialog {
* Opens the dialog but only if the user hasn't chosen to hide it.
* Returns <code>NOT_SHOWN</code> if the dialog was not shown.
*/
- public static int open(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
+ public static int open(String id, Shell parent, String title, Image titleImage, String message, int dialogType,
+ String[] buttonLabels, int defaultButtonIndex) {
if (!isDialogEnabled(id))
return OptionalMessageDialog.NOT_SHOWN;
-
- MessageDialog dialog= new OptionalMessageDialog(id, parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex);
+
+ MessageDialog dialog = new OptionalMessageDialog(id, parent, title, titleImage, message, dialogType,
+ buttonLabels, defaultButtonIndex);
return dialog.open();
}
- protected OptionalMessageDialog(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
+ protected OptionalMessageDialog(String id, Shell parent, String title, Image titleImage, String message,
+ int dialogType, String[] buttonLabels, int defaultButtonIndex) {
super(parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex);
- fId= id;
- switch(dialogType) {
+ fId = id;
+ switch (dialogType) {
case QUESTION:
- case QUESTION_WITH_CANCEL:
- fHideMessage= CUIMessages.OptionalMessageDialog_rememberDecision;
- break;
- default:
- fHideMessage= CUIMessages.OptionalMessageDialog_dontShowAgain;
+ case QUESTION_WITH_CANCEL:
+ fHideMessage = CUIMessages.OptionalMessageDialog_rememberDecision;
+ break;
+ default:
+ fHideMessage = CUIMessages.OptionalMessageDialog_dontShowAgain;
}
}
@Override
protected Control createCustomArea(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fHideDialogCheckBox= new Button(composite, SWT.CHECK | SWT.LEFT);
+
+ fHideDialogCheckBox = new Button(composite, SWT.CHECK | SWT.LEFT);
fHideDialogCheckBox.setText(fHideMessage);
fHideDialogCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- setDialogEnabled(fId, !((Button)e.widget).getSelection());
+ setDialogEnabled(fId, !((Button) e.widget).getSelection());
}
});
applyDialogFont(fHideDialogCheckBox);
return fHideDialogCheckBox;
}
-
+
//--------------- Configuration handling --------------
-
+
/**
* Returns this dialog
- *
+ *
* @return the settings to be used
*/
private static IDialogSettings getDialogSettings() {
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
- settings= settings.getSection(STORE_ID);
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
+ settings = settings.getSection(STORE_ID);
if (settings == null)
- settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID);
+ settings = CUIPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID);
return settings;
}
-
+
/**
* Answers whether the optional dialog is enabled and should be shown.
*/
public static boolean isDialogEnabled(String key) {
- IDialogSettings settings= getDialogSettings();
+ IDialogSettings settings = getDialogSettings();
return !settings.getBoolean(key);
}
-
+
/**
* Sets a detail for the dialog.
*/
public static void setDialogDetail(String key, int detail) {
- IDialogSettings settings= getDialogSettings();
- settings.put(key+KEY_DETAIL, detail);
+ IDialogSettings settings = getDialogSettings();
+ settings.put(key + KEY_DETAIL, detail);
}
/**
* Returns the detail for this dialog, or NO_DETAIL, if none.
*/
public static int getDialogDetail(String key) {
- IDialogSettings settings= getDialogSettings();
+ IDialogSettings settings = getDialogSettings();
try {
- return settings.getInt(key+KEY_DETAIL);
+ return settings.getInt(key + KEY_DETAIL);
} catch (NumberFormatException e) {
return NO_DETAIL;
}
}
-
+
/**
* Sets whether the optional dialog is enabled and should be shown.
*/
public static void setDialogEnabled(String key, boolean isEnabled) {
- IDialogSettings settings= getDialogSettings();
+ IDialogSettings settings = getDialogSettings();
settings.put(key, !isEnabled);
}
@@ -150,7 +153,7 @@ public class OptionalMessageDialog extends MessageDialog {
* Clears all remembered information about hidden dialogs
*/
public static void clearAllRememberedStates() {
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
settings.addNewSection(STORE_ID);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ResizableStatusDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ResizableStatusDialog.java
index 123f49198df..e3a0e300e92 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ResizableStatusDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ResizableStatusDialog.java
@@ -31,22 +31,22 @@ public abstract class ResizableStatusDialog extends StatusDialog {
@Override
protected Point getInitialSize() {
- Point defaultSize= getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- Point restoredSize= super.getInitialSize();
+ Point defaultSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ Point restoredSize = super.getInitialSize();
if (restoredSize.x < defaultSize.x)
- restoredSize.x= defaultSize.x;
+ restoredSize.x = defaultSize.x;
if (restoredSize.y < defaultSize.y)
- restoredSize.y= defaultSize.y;
+ restoredSize.y = defaultSize.y;
return restoredSize;
}
@Override
protected IDialogSettings getDialogBoundsSettings() {
- String sectionName= getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
- IDialogSettings section= settings.getSection(sectionName);
+ String sectionName = getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(sectionName);
if (section == null)
- section= settings.addNewSection(sectionName);
+ section = settings.addNewSection(sectionName);
return section;
}
@@ -55,4 +55,3 @@ public abstract class ResizableStatusDialog extends StatusDialog {
return true;
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java
index 2c4b78a63f8..1154a110f61 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java
@@ -48,24 +48,25 @@ public class SelectionList extends Composite {
private Object[] fElements;
protected ILabelProvider fRenderer;
private boolean fIgnoreCase;
-
+
// Implementation details
private String[] fRenderedStrings;
- private int[] fFilteredElements;
+ private int[] fFilteredElements;
private String fRememberedMatchText;
// SWT widgets
private Table fList;
private Text fText;
-
+
/**
* Adds a selection change listener to this widget.
*/
public void addSelectionListener(SelectionListener listener) {
fList.addSelectionListener(listener);
}
+
private void createList(int style) {
- fList= new Table(this, style);
+ fList = new Table(this, style);
fList.setLayoutData(new GridData(GridData.FILL_BOTH));
fList.addDisposeListener(new DisposeListener() {
@Override
@@ -74,15 +75,16 @@ public class SelectionList extends Composite {
}
});
}
+
private void createText() {
- fText= new Text(this, SWT.BORDER);
- GridData spec= new GridData();
- spec.grabExcessVerticalSpace= false;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.BEGINNING;
+ fText = new Text(this, SWT.BORDER);
+ GridData spec = new GridData();
+ spec.grabExcessVerticalSpace = false;
+ spec.grabExcessHorizontalSpace = true;
+ spec.horizontalAlignment = GridData.FILL;
+ spec.verticalAlignment = GridData.BEGINNING;
fText.setLayoutData(spec);
- Listener l= new Listener() {
+ Listener l = new Listener() {
@Override
public void handleEvent(Event evt) {
filter(false);
@@ -90,38 +92,42 @@ public class SelectionList extends Composite {
};
fText.addListener(SWT.Modify, l);
}
+
/**
* Filters the list of elements according to the pattern entered
* into the text entry field.
*/
public void filter(boolean forceUpdate) {
- int k= 0;
- String text= fText.getText();
+ int k = 0;
+ String text = fText.getText();
if (!forceUpdate && text.equals(fRememberedMatchText))
return;
- fRememberedMatchText= text;
- StringMatcher matcher= new StringMatcher(text+"*", fIgnoreCase, false); //$NON-NLS-1$
- for (int i= 0; i < fElements.length; i++) {
+ fRememberedMatchText = text;
+ StringMatcher matcher = new StringMatcher(text + "*", fIgnoreCase, false); //$NON-NLS-1$
+ for (int i = 0; i < fElements.length; i++) {
if (matcher.match(fRenderedStrings[i])) {
- fFilteredElements[k]= i;
+ fFilteredElements[k] = i;
k++;
}
}
- fFilteredElements[k]= -1;
+ fFilteredElements[k] = -1;
updateListWidget(fFilteredElements, k);
}
+
/**
* Returns the currently used filter text.
*/
public String getFilter() {
return fText.getText();
}
+
/**
* Returns the selection indices.
*/
public int[] getSelectionIndices() {
return fList.getSelectionIndices();
}
+
/**
* Returns a list of selected elements. Note that the type of the elements
* returned in the list are the same as the ones passed to the selection list
@@ -130,68 +136,76 @@ public class SelectionList extends Composite {
public List<?> getSelection() {
if (fList == null || fList.isDisposed() || fList.getSelectionCount() == 0)
return Collections.emptyList();
- int[] listSelection= fList.getSelectionIndices();
- List<Object> selected= new ArrayList<Object>(listSelection.length);
- for (int i= 0; i < listSelection.length; i++) {
+ int[] listSelection = fList.getSelectionIndices();
+ List<Object> selected = new ArrayList<Object>(listSelection.length);
+ for (int i = 0; i < listSelection.length; i++) {
selected.add(fElements[fFilteredElements[listSelection[i]]]);
}
return selected;
}
+
/**
* Returns <code>true</code> when the list of elements is empty.
*/
public boolean isEmptyList() {
return fElements == null || fElements.length == 0;
}
+
/**
* Creates new instance of the widget.
*/
public SelectionList(Composite parent, int style, ILabelProvider renderer, boolean ignoreCase) {
super(parent, SWT.NONE);
- fRenderer= renderer;
- fIgnoreCase= ignoreCase;
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0; layout.marginWidth= 0;
+ fRenderer = renderer;
+ fIgnoreCase = ignoreCase;
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
//XXX: 1G9V58A: ITPUI:WIN2000 - Dialog.convert* methods should be static
setLayout(layout);
createText();
createList(style);
}
+
/**
* Removes a selection change listener to this widget.
*/
public void removeSelectionListener(SelectionListener listener) {
fList.removeSelectionListener(listener);
}
+
private String[] renderStrings() {
- String[] strings= new String[fElements.length];
- for (int i= 0; i < strings.length; i++) {
- strings[i]= fRenderer.getText(fElements[i]);
+ String[] strings = new String[fElements.length];
+ for (int i = 0; i < strings.length; i++) {
+ strings[i] = fRenderer.getText(fElements[i]);
}
TwoArrayQuickSort.sort(strings, fElements, fIgnoreCase);
return strings;
}
+
/**
* Select the pattern text.
*/
public void selectFilterText() {
fText.selectAll();
}
+
/**
* Sets the list of elements presented in the widget.
*/
public void setElements(List<?> elements, boolean refilter) {
// We copy the list since we sort it.
if (elements == null)
- fElements= new Object[0];
- else
- fElements= elements.toArray();
- fFilteredElements= new int[fElements.length+1];
- fRenderedStrings= renderStrings();
+ fElements = new Object[0];
+ else
+ fElements = elements.toArray();
+ fFilteredElements = new int[fElements.length + 1];
+ fRenderedStrings = renderStrings();
if (refilter)
- filter(true);
+ filter(true);
}
- /*
+
+ /*
* Non Java-doc
*/
@Override
@@ -200,6 +214,7 @@ public class SelectionList extends Composite {
fText.setEnabled(enable);
fList.setEnabled(enable);
}
+
/**
* Sets the filter pattern. Current only prefix filter pattern are supported.
*/
@@ -208,6 +223,7 @@ public class SelectionList extends Composite {
if (refilter)
filter(true);
}
+
/*
* Non Java-doc
*/
@@ -215,6 +231,7 @@ public class SelectionList extends Composite {
public boolean setFocus() {
return fText.setFocus();
}
+
/*
* Non Java-doc
*/
@@ -224,6 +241,7 @@ public class SelectionList extends Composite {
fText.setFont(font);
fList.setFont(font);
}
+
/**
* Selects the elements in the list determined by the given
* selection indices.
@@ -231,34 +249,35 @@ public class SelectionList extends Composite {
protected void setSelection(int[] selection) {
fList.setSelection(selection);
}
+
private void updateListWidget(int[] indices, int size) {
if (fList == null || fList.isDisposed())
return;
fList.setRedraw(false);
- int itemCount= fList.getItemCount();
+ int itemCount = fList.getItemCount();
if (size < itemCount) {
- fList.remove(0, itemCount-size-1);
+ fList.remove(0, itemCount - size - 1);
}
- TableItem[] items= fList.getItems();
- for (int i= 0; i < size; i++) {
- TableItem ti= null;
+ TableItem[] items = fList.getItems();
+ for (int i = 0; i < size; i++) {
+ TableItem ti = null;
if (i < itemCount) {
- ti= items[i];
+ ti = items[i];
} else {
- ti= new TableItem(fList, i);
+ ti = new TableItem(fList, i);
}
ti.setText(fRenderedStrings[indices[i]]);
- Image img= fRenderer.getImage(fElements[indices[i]]);
+ Image img = fRenderer.getImage(fElements[indices[i]]);
if (img != null)
ti.setImage(img);
}
if (fList.getItemCount() > 0) {
fList.setSelection(0);
}
-
+
fList.setRedraw(true);
- Event event= new Event();
+ Event event = new Event();
fList.notifyListeners(SWT.Selection, event);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
index f0c4b5d0d85..3d7dc5a845f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
@@ -33,14 +33,14 @@ import org.eclipse.ui.dialogs.SelectionDialog;
* The status message must be passed over as StatusInfo object and can be
* an error, warning or ok. The OK button is enabled / disabled depending
* on the status.
- */
+ */
public abstract class SelectionStatusDialog extends SelectionDialog {
private MessageLine fStatusLine;
private IStatus fLastStatus;
private Image fImage;
private boolean fInitialSelectionSet;
private boolean fStatusLineAboveButtons;
-
+
public SelectionStatusDialog(Shell parent) {
super(parent);
}
@@ -59,18 +59,19 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
@Override
protected Control createButtonBar(Composite parent) {
- Composite composite= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
if (fStatusLineAboveButtons) {
- layout.verticalSpacing= 0;
+ layout.verticalSpacing = 0;
} else {
- layout.numColumns= 2;
+ layout.numColumns = 2;
}
- layout.marginHeight= 0; layout.marginWidth= 0;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fStatusLine= new MessageLine(composite);
+
+ fStatusLine = new MessageLine(composite);
fStatusLine.setAlignment(SWT.LEFT);
fStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fStatusLine.setMessage(""); //$NON-NLS-1$
@@ -88,16 +89,16 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
}
/**
- * Returns the first element of the initial selection or {@code null}
+ * Returns the first element of the initial selection or {@code null}
* if there isn't any initial selection.
*
* @return the first element of the initial selection.
*/
protected Object getPrimaryInitialSelection() {
- List<?> result= getInitialElementSelections();
+ List<?> result = getInitialElementSelections();
if (result == null || result.size() == 0)
return null;
- return result.get(0);
+ return result.get(0);
}
/**
@@ -108,10 +109,10 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
* returned.
*/
public Object getPrimaryResult() {
- Object[] result= getResult();
+ Object[] result = getResult();
if (result == null || result.length == 0)
return null;
- return result[0];
+ return result[0];
}
@Override
@@ -126,14 +127,14 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
* @param image the dialog's image
*/
public void setImage(Image image) {
- fImage= image;
+ fImage = image;
}
protected void setInitialSelection(int position, Object element) {
@SuppressWarnings("unchecked")
- List<Object> l= getInitialElementSelections();
+ List<Object> l = getInitialElementSelections();
l.set(position, element);
- fInitialSelectionSet= true;
+ fInitialSelectionSet = true;
}
/**
@@ -154,15 +155,15 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
@Override
public void setInitialSelections(Object[] selectedElements) {
super.setInitialSelections(selectedElements);
- fInitialSelectionSet= true;
+ fInitialSelectionSet = true;
}
/**
* Sets a result element at the given position.
*/
protected void setResult(int position, Object element) {
- Object[] result= getResult();
- result[position]= element;
+ Object[] result = getResult();
+ result[position] = element;
setResult(Arrays.asList(result));
}
@@ -174,7 +175,7 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
* {@code false} to the right
*/
public void setStatusLineAboveButtons(boolean aboveButtons) {
- fStatusLineAboveButtons= aboveButtons;
+ fStatusLineAboveButtons = aboveButtons;
}
/**
@@ -182,7 +183,7 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
* may override this method to update additional buttons.
*/
protected void updateButtonsEnableState(IStatus status) {
- Button okButton= getOkButton();
+ Button okButton = getOkButton();
if (okButton != null && !okButton.isDisposed())
okButton.setEnabled(!status.matches(IStatus.ERROR));
}
@@ -192,10 +193,10 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
* this method before the dialog has been opened.
*/
protected void updateStatus(IStatus status) {
- fLastStatus= status;
+ fLastStatus = status;
if (fStatusLine != null && !fStatusLine.isDisposed()) {
- updateButtonsEnableState(status);
- StatusTool.applyToStatusLine(fStatusLine, status);
+ updateButtonsEnableState(status);
+ StatusTool.applyToStatusLine(fStatusLine, status);
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java
index 458ca84947a..2ca2701275b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java
@@ -24,8 +24,8 @@ import org.eclipse.cdt.ui.CUIPlugin;
* a message describes the problem
*/
public class StatusInfo implements IStatus {
-
- public static final IStatus OK_STATUS= new StatusInfo();
+
+ public static final IStatus OK_STATUS = new StatusInfo();
private String fStatusMessage;
private int fSeverity;
@@ -42,11 +42,11 @@ public class StatusInfo implements IStatus {
* @param severity The status severity: ERROR, WARNING, INFO and OK.
* @param message The message of the status. Applies only for ERROR,
* WARNING and INFO.
- */
+ */
public StatusInfo(int severity, String message) {
- fStatusMessage= message;
- fSeverity= severity;
- }
+ fStatusMessage = message;
+ fSeverity = severity;
+ }
/**
* @see IStatus#getChildren()
@@ -55,6 +55,7 @@ public class StatusInfo implements IStatus {
public IStatus[] getChildren() {
return new IStatus[0];
}
+
/**
* @see IStatus#getCode()
*/
@@ -62,6 +63,7 @@ public class StatusInfo implements IStatus {
public int getCode() {
return fSeverity;
}
+
/**
* @see IStatus#getException()
*/
@@ -69,6 +71,7 @@ public class StatusInfo implements IStatus {
public Throwable getException() {
return null;
}
+
/**
* @see IStatus#getMessage
*/
@@ -76,6 +79,7 @@ public class StatusInfo implements IStatus {
public String getMessage() {
return fStatusMessage;
}
+
/**
* @see IStatus#getPlugin()
*/
@@ -83,6 +87,7 @@ public class StatusInfo implements IStatus {
public String getPlugin() {
return CUIPlugin.PLUGIN_ID;
}
+
/**
* @see IStatus#getSeverity()
*/
@@ -90,12 +95,15 @@ public class StatusInfo implements IStatus {
public int getSeverity() {
return fSeverity;
}
+
public boolean isError() {
return fSeverity == IStatus.ERROR;
}
+
public boolean isInfo() {
return fSeverity == IStatus.INFO;
}
+
/**
* @see IStatus#isMultiStatus()
*/
@@ -103,13 +111,16 @@ public class StatusInfo implements IStatus {
public boolean isMultiStatus() {
return false;
}
+
@Override
public boolean isOK() {
return fSeverity == IStatus.OK;
}
+
public boolean isWarning() {
return fSeverity == IStatus.WARNING;
}
+
/**
* @see IStatus#matches(int)
*/
@@ -117,25 +128,29 @@ public class StatusInfo implements IStatus {
public boolean matches(int severityMask) {
return (fSeverity & severityMask) != 0;
}
+
public void setError(String errorMessage) {
- fStatusMessage= errorMessage;
- fSeverity= IStatus.ERROR;
+ fStatusMessage = errorMessage;
+ fSeverity = IStatus.ERROR;
}
+
public void setInfo(String infoMessage) {
- fStatusMessage= infoMessage;
- fSeverity= IStatus.INFO;
+ fStatusMessage = infoMessage;
+ fSeverity = IStatus.INFO;
}
+
public void setOK() {
- fStatusMessage= null;
- fSeverity= IStatus.OK;
+ fStatusMessage = null;
+ fSeverity = IStatus.OK;
}
+
public void setWarning(String warningMessage) {
- fStatusMessage= warningMessage;
- fSeverity= IStatus.WARNING;
+ fStatusMessage = warningMessage;
+ fSeverity = IStatus.WARNING;
}
/**
- * Returns a string representation of the status, suitable
+ * Returns a string representation of the status, suitable
* for debugging purposes only.
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java
index 7ac0e078829..9732bcc9b29 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java
@@ -22,7 +22,7 @@ public class StatusTool {
* Applies the status to the status line of a dialog page
*/
public static void applyToStatusLine(MessageLine messageLine, IStatus status) {
- String[] messages= getErrorMessages(status);
+ String[] messages = getErrorMessages(status);
messageLine.setErrorMessage(messages[0]);
messageLine.setMessage(messages[1]);
}
@@ -31,7 +31,7 @@ public class StatusTool {
* Applies the status to the status line of a dialog page
*/
public static void applyToStatusLine(DialogPage page, IStatus status) {
- String[] messages= getErrorMessages(status);
+ String[] messages = getErrorMessages(status);
page.setErrorMessage(messages[0]);
page.setMessage(messages[1]);
}
@@ -40,7 +40,7 @@ public class StatusTool {
* Returns error-message / warning-message for a status
*/
public static String[] getErrorMessages(IStatus status) {
- String message= status.getMessage();
+ String message = status.getMessage();
if (status.matches(IStatus.ERROR) && !"".equals(message)) { //$NON-NLS-1$
return new String[] { message, null };
} else if (status.matches(IStatus.WARNING | IStatus.INFO)) {
@@ -68,14 +68,14 @@ public class StatusTool {
* than ok.
*/
public static IStatus getMostSevere(IStatus[] status) {
- IStatus max= null;
- for (int i= 0; i < status.length; i++) {
- IStatus curr= status[i];
+ IStatus max = null;
+ for (int i = 0; i < status.length; i++) {
+ IStatus curr = status[i];
if (curr.matches(IStatus.ERROR)) {
return curr;
}
if (max == null || curr.getSeverity() > max.getSeverity()) {
- max= curr;
+ max = curr;
}
}
return max;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
index f99547ab0f7..4f2782ac379 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
@@ -40,24 +40,24 @@ public class StatusUtil {
* than ok.
*/
public static IStatus getMostSevere(IStatus[] status) {
- IStatus max= null;
- for (int i= 0; i < status.length; i++) {
- IStatus curr= status[i];
+ IStatus max = null;
+ for (int i = 0; i < status.length; i++) {
+ IStatus curr = status[i];
if (curr.matches(IStatus.ERROR)) {
return curr;
}
if (max == null || curr.getSeverity() > max.getSeverity()) {
- max= curr;
+ max = curr;
}
}
return max;
}
-
+
/**
* Applies the status to the status line of a dialog page.
*/
public static void applyToStatusLine(DialogPage page, IStatus status) {
- String message= status.getMessage();
+ String message = status.getMessage();
switch (status.getSeverity()) {
case IStatus.OK:
page.setMessage(message, IMessageProvider.NONE);
@@ -66,18 +66,18 @@ public class StatusUtil {
case IStatus.WARNING:
page.setMessage(message, IMessageProvider.WARNING);
page.setErrorMessage(null);
- break;
+ break;
case IStatus.INFO:
page.setMessage(message, IMessageProvider.INFORMATION);
page.setErrorMessage(null);
- break;
+ break;
default:
if (message.length() == 0) {
- message= null;
+ message = null;
}
page.setMessage(null);
page.setErrorMessage(message);
- break;
+ break;
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TableTextCellEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TableTextCellEditor.java
index c724d7e91da..00a020c0313 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TableTextCellEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TableTextCellEditor.java
@@ -66,20 +66,20 @@ public class TableTextCellEditor extends CellEditor {
SubjectControlContentAssistant fContentAssistant;
private IActivationListener fActivationListener;
- protected Text text;
+ protected Text text;
- private boolean isSelection;
- private boolean isDeleteable;
- private boolean isSelectable;
+ private boolean isSelection;
+ private boolean isDeleteable;
+ private boolean isSelectable;
- private static final int defaultStyle = SWT.SINGLE;
+ private static final int defaultStyle = SWT.SINGLE;
private ModifyListener fModifyListener;
public TableTextCellEditor(TableViewer tableViewer, int column) {
super(tableViewer.getTable(), defaultStyle);
- fTableViewer= tableViewer;
- fColumn= column;
- fProperty= (String) tableViewer.getColumnProperties()[column];
+ fTableViewer = tableViewer;
+ fColumn = column;
+ fProperty = (String) tableViewer.getColumnProperties()[column];
}
@Override
@@ -87,12 +87,11 @@ public class TableTextCellEditor extends CellEditor {
super.activate();
if (fActivationListener != null)
fActivationListener.activate();
- fOriginalValue= text.getText();
+ fOriginalValue = text.getText();
}
private void fireModifyEvent(Object newValue) {
- fTableViewer.getCellModifier().modify(
- ((IStructuredSelection) fTableViewer.getSelection()).getFirstElement(),
+ fTableViewer.getCellModifier().modify(((IStructuredSelection) fTableViewer.getSelection()).getFirstElement(),
fProperty, newValue);
}
@@ -106,75 +105,75 @@ public class TableTextCellEditor extends CellEditor {
}
public void setContentAssistant(SubjectControlContentAssistant assistant) {
- fContentAssistant= assistant;
+ fContentAssistant = assistant;
}
public void setActivationListener(IActivationListener listener) {
- fActivationListener= listener;
+ fActivationListener = listener;
}
public Text getText() {
return text;
}
- protected void checkDeleteable() {
- boolean oldIsDeleteable = isDeleteable;
- isDeleteable = isDeleteEnabled();
- if (oldIsDeleteable != isDeleteable) {
- fireEnablementChanged(DELETE);
- }
- }
-
- protected void checkSelectable() {
- boolean oldIsSelectable = isSelectable;
- isSelectable = isSelectAllEnabled();
- if (oldIsSelectable != isSelectable) {
- fireEnablementChanged(SELECT_ALL);
- }
- }
-
- protected void checkSelection() {
- boolean oldIsSelection = isSelection;
- isSelection = text.getSelectionCount() > 0;
- if (oldIsSelection != isSelection) {
- fireEnablementChanged(COPY);
- fireEnablementChanged(CUT);
- }
- }
+ protected void checkDeleteable() {
+ boolean oldIsDeleteable = isDeleteable;
+ isDeleteable = isDeleteEnabled();
+ if (oldIsDeleteable != isDeleteable) {
+ fireEnablementChanged(DELETE);
+ }
+ }
+
+ protected void checkSelectable() {
+ boolean oldIsSelectable = isSelectable;
+ isSelectable = isSelectAllEnabled();
+ if (oldIsSelectable != isSelectable) {
+ fireEnablementChanged(SELECT_ALL);
+ }
+ }
+
+ protected void checkSelection() {
+ boolean oldIsSelection = isSelection;
+ isSelection = text.getSelectionCount() > 0;
+ if (oldIsSelection != isSelection) {
+ fireEnablementChanged(COPY);
+ fireEnablementChanged(CUT);
+ }
+ }
private ModifyListener getModifyListener() {
- if (fModifyListener == null) {
- fModifyListener = new ModifyListener() {
- @Override
+ if (fModifyListener == null) {
+ fModifyListener = new ModifyListener() {
+ @Override
public void modifyText(ModifyEvent e) {
- editOccured(e);
- }
- };
- }
- return fModifyListener;
+ editOccured(e);
+ }
+ };
+ }
+ return fModifyListener;
}
- /* (non-Javadoc)
- * Method declared on CellEditor.
- */
- @Override
+ /* (non-Javadoc)
+ * Method declared on CellEditor.
+ */
+ @Override
protected Control createControl(Composite parent) {
- text= new Text(parent, getStyle());
- text.addSelectionListener(new SelectionAdapter() {
- @Override
+ text = new Text(parent, getStyle());
+ text.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {
- handleDefaultSelection(e);
- }
- });
+ handleDefaultSelection(e);
+ }
+ });
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
// support switching rows while editing:
if (e.stateMask == SWT.MOD1 || e.stateMask == SWT.MOD2) {
if (e.keyCode == SWT.ARROW_UP || e.keyCode == SWT.ARROW_DOWN) {
- // allow starting multi-selection even if in edit mode
+ // allow starting multi-selection even if in edit mode
deactivate();
- e.doit= false;
+ e.doit = false;
return;
}
}
@@ -184,23 +183,23 @@ public class TableTextCellEditor extends CellEditor {
switch (e.keyCode) {
case SWT.ARROW_DOWN:
- e.doit= false;
- int nextRow= fTableViewer.getTable().getSelectionIndex() + 1;
+ e.doit = false;
+ int nextRow = fTableViewer.getTable().getSelectionIndex() + 1;
if (nextRow >= fTableViewer.getTable().getItemCount())
break;
editRow(nextRow);
break;
case SWT.ARROW_UP:
- e.doit= false;
- int prevRow= fTableViewer.getTable().getSelectionIndex() - 1;
+ e.doit = false;
+ int prevRow = fTableViewer.getTable().getSelectionIndex() - 1;
if (prevRow < 0)
break;
editRow(prevRow);
break;
case SWT.F2:
- e.doit= false;
+ e.doit = false;
deactivate();
break;
}
@@ -208,245 +207,243 @@ public class TableTextCellEditor extends CellEditor {
private void editRow(int row) {
fTableViewer.getTable().setSelection(row);
- IStructuredSelection newSelection= (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection newSelection = (IStructuredSelection) fTableViewer.getSelection();
if (newSelection.size() == 1)
fTableViewer.editElement(newSelection.getFirstElement(), fColumn);
}
});
- text.addKeyListener(new KeyAdapter() {
- // hook key pressed - see PR 14201
- @Override
+ text.addKeyListener(new KeyAdapter() {
+ // hook key pressed - see PR 14201
+ @Override
public void keyPressed(KeyEvent e) {
- keyReleaseOccured(e);
-
- // as a result of processing the above call, clients may have
- // disposed this cell editor
- if ((getControl() == null) || getControl().isDisposed())
- return;
- checkSelection(); // see explaination below
- checkDeleteable();
- checkSelectable();
- }
- });
- text.addTraverseListener(new TraverseListener() {
- @Override
+ keyReleaseOccured(e);
+
+ // as a result of processing the above call, clients may have
+ // disposed this cell editor
+ if ((getControl() == null) || getControl().isDisposed())
+ return;
+ checkSelection(); // see explaination below
+ checkDeleteable();
+ checkSelectable();
+ }
+ });
+ text.addTraverseListener(new TraverseListener() {
+ @Override
public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_ESCAPE
- || e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- }
- }
- });
- // We really want a selection listener but it is not supported so we
- // use a key listener and a mouse listener to know when selection changes
- // may have occurred
- text.addMouseListener(new MouseAdapter() {
- @Override
+ if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
+ e.doit = false;
+ }
+ }
+ });
+ // We really want a selection listener but it is not supported so we
+ // use a key listener and a mouse listener to know when selection changes
+ // may have occurred
+ text.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseUp(MouseEvent e) {
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- });
- text.addFocusListener(new FocusAdapter() {
- @Override
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
+ });
+ text.addFocusListener(new FocusAdapter() {
+ @Override
public void focusLost(FocusEvent e) {
- e.display.asyncExec(new Runnable() {
+ e.display.asyncExec(new Runnable() {
@Override
public void run() {
// without the asyncExec, focus has not had a chance to go to the content assist proposals
TableTextCellEditor.this.focusLost();
}
});
- }
- });
- text.setFont(parent.getFont());
- text.setBackground(parent.getBackground());
- text.setText("");//$NON-NLS-1$
- text.addModifyListener(getModifyListener());
+ }
+ });
+ text.setFont(parent.getFont());
+ text.setBackground(parent.getBackground());
+ text.setText("");//$NON-NLS-1$
+ text.addModifyListener(getModifyListener());
return text;
- }
+ }
- @Override
+ @Override
protected void fireCancelEditor() {
/* bug 58540: change signature refactoring interaction: validate as you type [refactoring] */
- text.setText(fOriginalValue);
+ text.setText(fOriginalValue);
super.fireApplyEditorValue();
- }
-
- /**
- * The <code>TextCellEditor</code> implementation of
- * this <code>CellEditor</code> framework method returns
- * the text string.
- *
- * @return the text string
- */
- @Override
+ }
+
+ /**
+ * The <code>TextCellEditor</code> implementation of
+ * this <code>CellEditor</code> framework method returns
+ * the text string.
+ *
+ * @return the text string
+ */
+ @Override
protected Object doGetValue() {
- return text.getText();
- }
+ return text.getText();
+ }
- @Override
+ @Override
protected void doSetFocus() {
- if (text != null) {
- text.selectAll();
- text.setFocus();
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- }
-
- /**
- * The <code>TextCellEditor2</code> implementation of
- * this <code>CellEditor</code> framework method accepts
- * a text string (type <code>String</code>).
- *
- * @param value a text string (type <code>String</code>)
- */
- @Override
+ if (text != null) {
+ text.selectAll();
+ text.setFocus();
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
+ }
+
+ /**
+ * The <code>TextCellEditor2</code> implementation of
+ * this <code>CellEditor</code> framework method accepts
+ * a text string (type <code>String</code>).
+ *
+ * @param value a text string (type <code>String</code>)
+ */
+ @Override
protected void doSetValue(Object value) {
- Assert.isTrue(text != null && (value instanceof String));
- text.removeModifyListener(getModifyListener());
- text.setText((String) value);
- text.addModifyListener(getModifyListener());
- }
-
- /**
- * Processes a modify event that occurred in this text cell editor.
- * This framework method performs validation and sets the error message
- * accordingly, and then reports a change via <code>fireEditorValueChanged</code>.
- * Subclasses should call this method at appropriate times. Subclasses
- * may extend or reimplement.
- *
- * @param e the SWT modify event
- */
- protected void editOccured(ModifyEvent e) {
- String value = text.getText();
- boolean oldValidState = isValueValid();
- boolean newValidState = isCorrect(value);
- if (!newValidState) {
- // Try to insert the current value into the error message.
- setErrorMessage(NLS.bind(getErrorMessage(), value));
- }
- valueChanged(oldValidState, newValidState);
+ Assert.isTrue(text != null && (value instanceof String));
+ text.removeModifyListener(getModifyListener());
+ text.setText((String) value);
+ text.addModifyListener(getModifyListener());
+ }
+
+ /**
+ * Processes a modify event that occurred in this text cell editor.
+ * This framework method performs validation and sets the error message
+ * accordingly, and then reports a change via <code>fireEditorValueChanged</code>.
+ * Subclasses should call this method at appropriate times. Subclasses
+ * may extend or reimplement.
+ *
+ * @param e the SWT modify event
+ */
+ protected void editOccured(ModifyEvent e) {
+ String value = text.getText();
+ boolean oldValidState = isValueValid();
+ boolean newValidState = isCorrect(value);
+ if (!newValidState) {
+ // Try to insert the current value into the error message.
+ setErrorMessage(NLS.bind(getErrorMessage(), value));
+ }
+ valueChanged(oldValidState, newValidState);
fireModifyEvent(text.getText()); // update model on-the-fly
- }
+ }
- @Override
+ @Override
public LayoutData getLayoutData() {
- return new LayoutData();
- }
+ return new LayoutData();
+ }
- protected void handleDefaultSelection(SelectionEvent event) {
- // same with enter-key handling code in keyReleaseOccured(e);
- fireApplyEditorValue();
- deactivate();
- }
+ protected void handleDefaultSelection(SelectionEvent event) {
+ // same with enter-key handling code in keyReleaseOccured(e);
+ fireApplyEditorValue();
+ deactivate();
+ }
- @Override
+ @Override
public boolean isCopyEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return text.getSelectionCount() > 0;
- }
+ if (text == null || text.isDisposed())
+ return false;
+ return text.getSelectionCount() > 0;
+ }
- @Override
+ @Override
public boolean isCutEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return text.getSelectionCount() > 0;
- }
+ if (text == null || text.isDisposed())
+ return false;
+ return text.getSelectionCount() > 0;
+ }
- @Override
+ @Override
public boolean isDeleteEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return text.getSelectionCount() > 0
- || text.getCaretPosition() < text.getCharCount();
- }
+ if (text == null || text.isDisposed())
+ return false;
+ return text.getSelectionCount() > 0 || text.getCaretPosition() < text.getCharCount();
+ }
- @Override
+ @Override
public boolean isPasteEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return true;
- }
+ if (text == null || text.isDisposed())
+ return false;
+ return true;
+ }
- @Override
+ @Override
public boolean isSelectAllEnabled() {
- if (text == null || text.isDisposed())
- return false;
- return text.getCharCount() > 0;
- }
+ if (text == null || text.isDisposed())
+ return false;
+ return text.getCharCount() > 0;
+ }
- @Override
+ @Override
protected void keyReleaseOccured(KeyEvent keyEvent) {
- if (keyEvent.character == '\r') { // Return key
- // Enter is handled in handleDefaultSelection.
- // Do not apply the editor value in response to an Enter key event
- // since this can be received from the IME when the intent is -not-
- // to apply the value.
- // See bug 39074 [CellEditors] [DBCS] canna input mode fires bogus event from Text Control
- //
- // An exception is made for Ctrl+Enter for multi-line texts, since
- // a default selection event is not sent in this case.
- if (text != null && !text.isDisposed() && (text.getStyle() & SWT.MULTI) != 0) {
- if ((keyEvent.stateMask & SWT.CTRL) != 0) {
- super.keyReleaseOccured(keyEvent);
- }
- }
- return;
- }
- super.keyReleaseOccured(keyEvent);
- }
-
- @Override
+ if (keyEvent.character == '\r') { // Return key
+ // Enter is handled in handleDefaultSelection.
+ // Do not apply the editor value in response to an Enter key event
+ // since this can be received from the IME when the intent is -not-
+ // to apply the value.
+ // See bug 39074 [CellEditors] [DBCS] canna input mode fires bogus event from Text Control
+ //
+ // An exception is made for Ctrl+Enter for multi-line texts, since
+ // a default selection event is not sent in this case.
+ if (text != null && !text.isDisposed() && (text.getStyle() & SWT.MULTI) != 0) {
+ if ((keyEvent.stateMask & SWT.CTRL) != 0) {
+ super.keyReleaseOccured(keyEvent);
+ }
+ }
+ return;
+ }
+ super.keyReleaseOccured(keyEvent);
+ }
+
+ @Override
public void performCopy() {
- text.copy();
- }
+ text.copy();
+ }
- @Override
+ @Override
public void performCut() {
- text.cut();
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
+ text.cut();
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
- @Override
+ @Override
public void performDelete() {
- if (text.getSelectionCount() > 0) {
- // remove the contents of the current selection
- text.insert(""); //$NON-NLS-1$
- } else {
- // remove the next character
- int pos = text.getCaretPosition();
- if (pos < text.getCharCount()) {
- text.setSelection(pos, pos + 1);
- text.insert(""); //$NON-NLS-1$
- }
- }
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
-
- @Override
+ if (text.getSelectionCount() > 0) {
+ // remove the contents of the current selection
+ text.insert(""); //$NON-NLS-1$
+ } else {
+ // remove the next character
+ int pos = text.getCaretPosition();
+ if (pos < text.getCharCount()) {
+ text.setSelection(pos, pos + 1);
+ text.insert(""); //$NON-NLS-1$
+ }
+ }
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
+
+ @Override
public void performPaste() {
- text.paste();
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
+ text.paste();
+ checkSelection();
+ checkDeleteable();
+ checkSelectable();
+ }
- @Override
+ @Override
public void performSelectAll() {
- text.selectAll();
- checkSelection();
- checkDeleteable();
- }
+ text.selectAll();
+ checkSelection();
+ checkDeleteable();
+ }
@Override
protected boolean dependsOnExternalFocusListener() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TextFieldNavigationHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TextFieldNavigationHandler.java
index 37970d0dee9..8bf4a72d1ae 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TextFieldNavigationHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TextFieldNavigationHandler.java
@@ -79,17 +79,17 @@ public class TextFieldNavigationHandler {
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;
+ 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;
}
}
@@ -108,19 +108,18 @@ 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".equals(SWT.getPlatform()) //$NON-NLS-1$
// on carbon, getCaretPosition() always returns getSelection().x
|| Util.isMac();
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) {
@@ -176,7 +175,7 @@ public class TextFieldNavigationHandler {
private final StyledText fStyledText;
public StyledTextNavigable(StyledText styledText) {
- fStyledText= styledText;
+ fStyledText = styledText;
}
@Override
@@ -214,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) {
@@ -256,7 +255,7 @@ public class TextFieldNavigationHandler {
public int getCaretPosition() {
selectionChanged();
return fCaretPosition;
-// return fCombo.getCaretPosition(); // not available: bug 103630
+ // return fCombo.getCaretPosition(); // not available: bug 103630
}
@Override
@@ -266,17 +265,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 CWordIterator fIterator;
private final Navigable fNavigable;
private KeyAdapter fKeyListener;
private FocusHandler(Navigable navigable) {
- fIterator= new CWordIterator();
- fNavigable= navigable;
+ fIterator = new CWordIterator();
+ fNavigable = navigable;
- Control control= navigable.getControl();
+ Control control = navigable.getControl();
control.addFocusListener(this);
if (control.isFocusControl())
activate();
@@ -304,17 +303,17 @@ 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 final boolean IS_WORKAROUND= (fNavigable instanceof ComboNavigable)
+ fKeyListener = new KeyAdapter() {
+ private final boolean IS_WORKAROUND = (fNavigable instanceof ComboNavigable)
|| (fNavigable instanceof TextNavigable && TextNavigable.BUG_106024_TEXT_SELECTION);
private List<Submission> fSubmissions;
@@ -322,38 +321,39 @@ public class TextFieldNavigationHandler {
public void keyPressed(KeyEvent e) {
if (IS_WORKAROUND) {
if (e.keyCode == SWT.ARROW_LEFT && e.stateMask == SWT.MOD2) {
- int caretPosition= fNavigable.getCaretPosition();
+ 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);
else
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();
+ 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);
else
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));
+ KeySequence keySequence = KeySequence
+ .getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
for (Submission submission : getSubmissions()) {
- TriggerSequence[] triggerSequences= submission.getTriggerSequences();
- for (int i= 0; i < triggerSequences.length; i++) {
+ 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;
+ e.doit = false;
submission.execute();
return;
}
@@ -365,23 +365,25 @@ public class TextFieldNavigationHandler {
if (fSubmissions != null)
return fSubmissions;
- fSubmissions= new ArrayList<Submission>();
+ fSubmissions = new ArrayList<Submission>();
- ICommandService commandService= PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- IBindingService bindingService= PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
+ IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
if (commandService == null || bindingService == null)
return fSubmissions;
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=184502 ,
// similar to CodeAssistAdvancedConfigurationBlock.getKeyboardShortcut(..):
- BindingManager localBindingManager= new BindingManager(new ContextManager(), new CommandManager());
- final Scheme[] definedSchemes= bindingService.getDefinedSchemes();
+ BindingManager localBindingManager = new BindingManager(new ContextManager(),
+ new CommandManager());
+ final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
if (definedSchemes != null) {
try {
for (int i = 0; i < definedSchemes.length; i++) {
- Scheme scheme= definedSchemes[i];
- Scheme localSchemeCopy= localBindingManager.getScheme(scheme.getId());
- localSchemeCopy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
+ Scheme scheme = definedSchemes[i];
+ Scheme localSchemeCopy = localBindingManager.getScheme(scheme.getId());
+ localSchemeCopy.define(scheme.getName(), scheme.getDescription(),
+ scheme.getParentId());
}
} catch (final NotDefinedException e) {
CUIPlugin.log(e);
@@ -392,21 +394,22 @@ public class TextFieldNavigationHandler {
localBindingManager.setBindings(bindingService.getBindings());
try {
- Scheme activeScheme= bindingService.getActiveScheme();
+ Scheme activeScheme = bindingService.getActiveScheme();
if (activeScheme != null)
localBindingManager.setActiveScheme(activeScheme);
} catch (NotDefinedException e) {
CUIPlugin.log(e);
}
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.SELECT_WORD_NEXT)) {
+ fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService,
+ 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);
else
@@ -415,14 +418,15 @@ public class TextFieldNavigationHandler {
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS)) {
+ fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService,
+ 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);
else
@@ -431,42 +435,45 @@ public class TextFieldNavigationHandler {
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.WORD_NEXT)) {
+ fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService,
+ 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(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.WORD_PREVIOUS)) {
+ fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService,
+ 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(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.DELETE_NEXT_WORD)) {
+ fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService,
+ 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;
@@ -475,20 +482,21 @@ public class TextFieldNavigationHandler {
fNavigable.setSelection(start, start);
}
});
- fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService, ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD)) {
+ fSubmissions.add(new Submission(getKeyBindings(localBindingManager, commandService,
+ 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;
@@ -501,9 +509,10 @@ public class TextFieldNavigationHandler {
return fSubmissions;
}
- private TriggerSequence[] getKeyBindings(BindingManager localBindingManager, ICommandService commandService, String commandID) {
- Command command= commandService.getCommand(commandID);
- ParameterizedCommand pCmd= new ParameterizedCommand(command, null);
+ private TriggerSequence[] getKeyBindings(BindingManager localBindingManager,
+ ICommandService commandService, String commandID) {
+ Command command = commandService.getCommand(commandID);
+ ParameterizedCommand pCmd = new ParameterizedCommand(command, null);
return localBindingManager.getActiveBindingsDisregardingContextFor(pCmd);
}
@@ -517,7 +526,7 @@ public class TextFieldNavigationHandler {
private TriggerSequence[] fTriggerSequences;
public Submission(TriggerSequence[] triggerSequences) {
- fTriggerSequences= triggerSequences;
+ fTriggerSequences = triggerSequences;
}
public TriggerSequence[] getTriggerSequences() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java
index 2adcf48b52a..d66cd085c02 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java
@@ -19,7 +19,6 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-
/**
* Implementation of a <code>ISelectionValidator</code> to validate the
* type of an element.
@@ -27,13 +26,13 @@ import org.eclipse.ui.dialogs.ISelectionStatusValidator;
*/
public class TypedElementSelectionValidator implements ISelectionStatusValidator {
- private IStatus fgErrorStatus= new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
- private IStatus fgOKStatus= new StatusInfo();
+ private IStatus fgErrorStatus = new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
+ private IStatus fgOKStatus = new StatusInfo();
private Class<?>[] fAcceptedTypes;
private boolean fAllowMultipleSelection;
private Collection<?> fRejectedElements;
-
+
/**
* @param acceptedTypes The types accepted by the validator
* @param allowMultipleSelection If set to <code>true</code>, the validator
@@ -42,20 +41,21 @@ public class TypedElementSelectionValidator implements ISelectionStatusValidator
public TypedElementSelectionValidator(Class<?>[] acceptedTypes, boolean allowMultipleSelection) {
this(acceptedTypes, allowMultipleSelection, null);
}
-
+
/**
* @param acceptedTypes The types accepted by the validator
* @param allowMultipleSelection If set to <code>true</code>, the validator
* allows multiple selection.
* @param rejectedElements A list of elements that are not accepted
*/
- public TypedElementSelectionValidator(Class<?>[] acceptedTypes, boolean allowMultipleSelection, Collection<Object> rejectedElements) {
+ public TypedElementSelectionValidator(Class<?>[] acceptedTypes, boolean allowMultipleSelection,
+ Collection<Object> rejectedElements) {
Assert.isNotNull(acceptedTypes);
- fAcceptedTypes= acceptedTypes;
- fAllowMultipleSelection= allowMultipleSelection;
- fRejectedElements= rejectedElements;
- }
-
+ fAcceptedTypes = acceptedTypes;
+ fAllowMultipleSelection = allowMultipleSelection;
+ fRejectedElements = rejectedElements;
+ }
+
/*
* @see org.eclipse.ui.dialogs.ISelectionValidator#isValid(java.lang.Object)
*/
@@ -65,32 +65,32 @@ public class TypedElementSelectionValidator implements ISelectionStatusValidator
return fgOKStatus;
}
return fgErrorStatus;
- }
+ }
private boolean isOfAcceptedType(Object o) {
- for (int i= 0; i < fAcceptedTypes.length; i++) {
+ for (int i = 0; i < fAcceptedTypes.length; i++) {
if (fAcceptedTypes[i].isInstance(o)) {
return true;
}
}
return false;
}
-
+
private boolean isRejectedElement(Object elem) {
return (fRejectedElements != null) && fRejectedElements.contains(elem);
}
-
+
private boolean isValid(Object[] selection) {
if (selection.length == 0) {
return false;
}
-
+
if (!fAllowMultipleSelection && selection.length != 1) {
return false;
}
-
- for (int i= 0; i < selection.length; i++) {
- Object o= selection[i];
+
+ for (int i = 0; i < selection.length; i++) {
+ Object o = selection[i];
if (!isOfAcceptedType(o) || isRejectedElement(o)) {
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java
index 85befd5d76f..8f7e957ac47 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java
@@ -39,12 +39,12 @@ public class TypedViewerFilter extends ViewerFilter {
* @param acceptedTypes Accepted elements must be of this types
* @param rejectedElements Element equals to the rejected elements are
* filtered out
- */
+ */
public TypedViewerFilter(Class<?>[] acceptedTypes, Object[] rejectedElements) {
Assert.isNotNull(acceptedTypes);
- fAcceptedTypes= acceptedTypes;
- fRejectedElements= rejectedElements;
- }
+ fAcceptedTypes = acceptedTypes;
+ fRejectedElements = rejectedElements;
+ }
/**
* @see ViewerFilter#select
@@ -52,13 +52,13 @@ public class TypedViewerFilter extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (fRejectedElements != null) {
- for (int i= 0; i < fRejectedElements.length; i++) {
+ for (int i = 0; i < fRejectedElements.length; i++) {
if (element.equals(fRejectedElements[i])) {
return false;
}
}
}
- for (int i= 0; i < fAcceptedTypes.length; i++) {
+ for (int i = 0; i < fAcceptedTypes.length; i++) {
if (fAcceptedTypes[i].isInstance(element)) {
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
index 63a58e70e1c..6f57f042db8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
@@ -51,7 +51,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
private StatusInfo fBuildPathStatus;
private ICElement fCurrCElement;
-
+
private String fUserSettingsTimeStamp;
private long fFileTimeStamp;
@@ -78,16 +78,16 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
* @return Returns the current class path (raw). Note that the entries
* returned must not be valid.
*/
- public IPathEntry[] getRawCPath() throws CModelException{
+ public IPathEntry[] getRawCPath() throws CModelException {
List<CPElement> elements = getCPaths();
IPathEntry[] entries = getCProject().getRawPathEntries();
List<IPathEntry> cpath = new ArrayList<IPathEntry>(elements.size() + entries.length);
- int[] applyTypes = getAppliedFilteredTypes();
+ int[] applyTypes = getAppliedFilteredTypes();
// create and set the paths
for (int i = 0; i < elements.size(); i++) {
- CPElement entry = (elements.get(i));
+ CPElement entry = (elements.get(i));
for (int applyType : applyTypes) {
if (entry.getEntryKind() == applyType) {
cpath.add(entry.getPathEntry());
@@ -110,7 +110,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
cpath.add(entrie);
}
}
-
+
return cpath.toArray(new IPathEntry[cpath.size()]);
}
@@ -118,7 +118,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
* Initializes the paths for the given project. Multiple calls to init are
* allowed, but all existing settings will be cleared and replace by the
* given or default paths.
- *
+ *
* @param element
* The C/C++ project to configure. Does not have to exist.
* @param cpathEntries
@@ -135,7 +135,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
cpathEntries = getCProject().getRawPathEntries();
} catch (CModelException e) {
}
-
+
}
if (cpathEntries != null) {
newCPath = getFilteredElements(cpathEntries, getFilteredTypes());
@@ -146,7 +146,8 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
}
abstract protected int[] getFilteredTypes(); // path type which block would like access to
- abstract protected int[] getAppliedFilteredTypes(); // path type which block modifies
+
+ abstract protected int[] getAppliedFilteredTypes(); // path type which block modifies
abstract protected void initialize(ICElement element, List<CPElement> cPaths);
@@ -175,7 +176,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
private String getEncodedSettings() {
StringBuilder buf = new StringBuilder();
-
+
List<CPElement> elements = getCPaths();
int nElements = elements.size();
buf.append('[').append(nElements).append(']');
@@ -228,7 +229,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
}
private IStatus findMostSevereStatus() {
- return StatusUtil.getMostSevere(new IStatus[] { fCPathStatus, fBuildPathStatus});
+ return StatusUtil.getMostSevere(new IStatus[] { fCPathStatus, fBuildPathStatus });
}
protected StatusInfo getPathStatus() {
@@ -252,7 +253,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#updateContainer()
*/
@Override
@@ -298,20 +299,20 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
return fCurrPage;
}
- protected void internalConfigureCProject(List<CPElement> cPathEntries, IProgressMonitor monitor) throws CoreException,
- InterruptedException {
+ protected void internalConfigureCProject(List<CPElement> cPathEntries, IProgressMonitor monitor)
+ throws CoreException, InterruptedException {
// 10 monitor steps to go
monitor.worked(2);
-
+
IPathEntry[] entries = getCProject().getRawPathEntries();
-
+
List<IPathEntry> cpath = new ArrayList<IPathEntry>(cPathEntries.size() + entries.length);
- int[] applyTypes = getAppliedFilteredTypes();
+ int[] applyTypes = getAppliedFilteredTypes();
// create and set the paths
for (int i = 0; i < cPathEntries.size(); i++) {
- CPElement entry = (cPathEntries.get(i));
+ CPElement entry = (cPathEntries.get(i));
for (int applyType : applyTypes) {
if (entry.getEntryKind() == applyType) {
IResource res = entry.getResource();
@@ -350,7 +351,7 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
if (monitor == null) {
monitor = new NullProgressMonitor();
}
- monitor.setTaskName(CPathEntryMessages.CPathsBlock_operationdesc_c);
+ monitor.setTaskName(CPathEntryMessages.CPathsBlock_operationdesc_c);
monitor.beginTask("", 10); //$NON-NLS-1$
try {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java
index 14f55596090..7a63c337f3d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java
@@ -30,33 +30,33 @@ import org.eclipse.jface.viewers.ViewerFilter;
* Viewer filter for archive selection dialogs.
* Archives are files with file extension "a", "dll", "so.
* The filter is not case sensitive.
- *
+ *
* @deprecated as of CDT 4.0. This class was used for property pages
* for 3.X style projects.
*/
@Deprecated
public class ArchiveFileFilter extends ViewerFilter {
- private static final String[] fgArchiveExtensions= { "a", "so", "dll" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] fgArchiveExtensions = { "a", "so", "dll" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private List<IFile> fExcludes;
private boolean fRecursive;
-
+
/**
* @param excludedFiles Excluded files will not pass the filter.
- * <code>null</code> is allowed if no files should be excluded.
+ * <code>null</code> is allowed if no files should be excluded.
* @param recusive Folders are only shown if, searched recursivly, contain
* an archive
*/
public ArchiveFileFilter(IFile[] excludedFiles, boolean recusive) {
if (excludedFiles != null) {
- fExcludes= Arrays.asList(excludedFiles);
+ fExcludes = Arrays.asList(excludedFiles);
} else {
- fExcludes= null;
+ fExcludes = null;
}
- fRecursive= recusive;
+ fRecursive = recusive;
}
-
+
/*
* @see ViewerFilter#select
*/
@@ -66,14 +66,14 @@ public class ArchiveFileFilter extends ViewerFilter {
if (fExcludes != null && fExcludes.contains(element)) {
return false;
}
- return isArchivePath(((IFile)element).getFullPath());
+ return isArchivePath(((IFile) element).getFullPath());
} else if (element instanceof IContainer) { // IProject, IFolder
if (!fRecursive) {
return true;
}
try {
- IResource[] resources= ((IContainer)element).members();
- for (int i= 0; i < resources.length; i++) {
+ IResource[] resources = ((IContainer) element).members();
+ for (int i = 0; i < resources.length; i++) {
// recursive! Only show containers that contain an archive
if (select(viewer, parent, resources[i])) {
return true;
@@ -81,26 +81,26 @@ public class ArchiveFileFilter extends ViewerFilter {
}
} catch (CoreException e) {
CUIPlugin.log(e.getStatus());
- }
+ }
}
return false;
}
-
+
public static boolean isArchivePath(IPath path) {
- String ext= path.getFileExtension();
+ String ext = path.getFileExtension();
if (ext != null && ext.length() != 0) {
return isArchiveFileExtension(ext);
}
return false;
}
-
+
public static boolean isArchiveFileExtension(String ext) {
- for (int i= 0; i < fgArchiveExtensions.length; i++) {
+ for (int i = 0; i < fgArchiveExtensions.length; i++) {
if (ext.equalsIgnoreCase(fgArchiveExtensions[i])) {
return true;
}
}
return false;
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java
index b00b62fbbea..dacbff457cd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java
@@ -53,8 +53,8 @@ public class CPElement {
public static final String BASE = "base-path"; //$NON-NLS-1$
public static final String PARENT = "parent"; //$NON-NLS-1$
public static final String PARENT_CONTAINER = "parent-container"; //$NON-NLS-1$
- public static final String INCLUDE_FILE = "includefile"; //$NON-NLS-1$
- public static final String MACROS_FILE = "macrosfile"; //$NON-NLS-1$
+ public static final String INCLUDE_FILE = "includefile"; //$NON-NLS-1$
+ public static final String MACROS_FILE = "macrosfile"; //$NON-NLS-1$
private final int fEntryKind;
private final IPath fPath;
@@ -66,18 +66,18 @@ public class CPElement {
private IPathEntry fCachedEntry;
private CPElement Inherited; // used when the path is duplicated on a child
- // resource but is inherited from a parent
- // resource these are not real path entries
+ // resource but is inherited from a parent
+ // resource these are not real path entries
private IStatus fStatus;
-
+
// create a inherited element and apply to path/resource
public CPElement(CPElement element, IPath path, IResource res) {
this(element.getCProject(), element.getEntryKind(), path, res);
setExported(element.isExported());
fChildren.clear();
- for(int i = 0; i < element.fChildren.size(); i++) {
- CPElementAttribute attrib = (CPElementAttribute)element.fChildren.get(i);
+ for (int i = 0; i < element.fChildren.size(); i++) {
+ CPElementAttribute attrib = (CPElementAttribute) element.fChildren.get(i);
fChildren.add(new CPElementAttribute(this, attrib.getKey(), attrib.getValue()));
}
Inherited = element;
@@ -93,76 +93,74 @@ public class CPElement {
fCachedEntry = null;
switch (entryKind) {
- case IPathEntry.CDT_OUTPUT:
- createAttributeElement(EXCLUSION, new Path[0]);
- break;
- case IPathEntry.CDT_SOURCE:
- createAttributeElement(EXCLUSION, new Path[0]);
- break;
- case IPathEntry.CDT_LIBRARY:
- createAttributeElement(LIBRARY, new Path("")); //$NON-NLS-1$
- createAttributeElement(SOURCEATTACHMENT, null);
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_INCLUDE:
- createAttributeElement(INCLUDE, new Path("")); //$NON-NLS-1$
- createAttributeElement(EXCLUSION, new Path[0]);
- createAttributeElement(SYSTEM_INCLUDE, Boolean.valueOf(true));
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- createAttributeElement(INCLUDE_FILE, new Path("")); //$NON-NLS-1$
- createAttributeElement(EXCLUSION, new Path[0]);
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_MACRO:
- createAttributeElement(MACRO_NAME, ""); //$NON-NLS-1$
- createAttributeElement(MACRO_VALUE, ""); //$NON-NLS-1$
- createAttributeElement(EXCLUSION, new Path[0]);
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_MACRO_FILE:
- createAttributeElement(MACROS_FILE, new Path("")); //$NON-NLS-1$
- createAttributeElement(EXCLUSION, new Path[0]);
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_CONTAINER:
- try {
- IPathEntryContainer container = CoreModel.getPathEntryContainer(fPath, fCProject);
- if (container != null) {
- IPathEntry[] entries = null;
- if (container instanceof IPathEntryContainerExtension &&
- res instanceof IFile) {
- IPathEntryContainerExtension extContainer = (IPathEntryContainerExtension) container;
- entries = extContainer.getPathEntries(res.getFullPath(),
- IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO |
- IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE);
- } else {
- entries = container.getPathEntries();
- }
- for (IPathEntry entrie : entries) {
- CPElement curr = createFromExisting(entrie, fCProject);
- curr.createAttributeElement(PARENT_CONTAINER, this);
- CPElementGroup group = new CPElementGroup(this, curr.getEntryKind());
- int indx = fChildren.indexOf(group);
- if (indx == -1) {
- fChildren.add(group);
- } else {
- group = (CPElementGroup)fChildren.get(indx);
- }
- group.addChild(curr);
+ case IPathEntry.CDT_OUTPUT:
+ createAttributeElement(EXCLUSION, new Path[0]);
+ break;
+ case IPathEntry.CDT_SOURCE:
+ createAttributeElement(EXCLUSION, new Path[0]);
+ break;
+ case IPathEntry.CDT_LIBRARY:
+ createAttributeElement(LIBRARY, new Path("")); //$NON-NLS-1$
+ createAttributeElement(SOURCEATTACHMENT, null);
+ createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+ createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+ break;
+ case IPathEntry.CDT_INCLUDE:
+ createAttributeElement(INCLUDE, new Path("")); //$NON-NLS-1$
+ createAttributeElement(EXCLUSION, new Path[0]);
+ createAttributeElement(SYSTEM_INCLUDE, Boolean.valueOf(true));
+ createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+ createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+ break;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ createAttributeElement(INCLUDE_FILE, new Path("")); //$NON-NLS-1$
+ createAttributeElement(EXCLUSION, new Path[0]);
+ createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+ createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+ break;
+ case IPathEntry.CDT_MACRO:
+ createAttributeElement(MACRO_NAME, ""); //$NON-NLS-1$
+ createAttributeElement(MACRO_VALUE, ""); //$NON-NLS-1$
+ createAttributeElement(EXCLUSION, new Path[0]);
+ createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+ createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+ break;
+ case IPathEntry.CDT_MACRO_FILE:
+ createAttributeElement(MACROS_FILE, new Path("")); //$NON-NLS-1$
+ createAttributeElement(EXCLUSION, new Path[0]);
+ createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+ createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+ break;
+ case IPathEntry.CDT_CONTAINER:
+ try {
+ IPathEntryContainer container = CoreModel.getPathEntryContainer(fPath, fCProject);
+ if (container != null) {
+ IPathEntry[] entries = null;
+ if (container instanceof IPathEntryContainerExtension && res instanceof IFile) {
+ IPathEntryContainerExtension extContainer = (IPathEntryContainerExtension) container;
+ entries = extContainer.getPathEntries(res.getFullPath(), IPathEntry.CDT_INCLUDE
+ | IPathEntry.CDT_MACRO | IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE);
+ } else {
+ entries = container.getPathEntries();
+ }
+ for (IPathEntry entrie : entries) {
+ CPElement curr = createFromExisting(entrie, fCProject);
+ curr.createAttributeElement(PARENT_CONTAINER, this);
+ CPElementGroup group = new CPElementGroup(this, curr.getEntryKind());
+ int indx = fChildren.indexOf(group);
+ if (indx == -1) {
+ fChildren.add(group);
+ } else {
+ group = (CPElementGroup) fChildren.get(indx);
}
+ group.addChild(curr);
}
- } catch (CModelException e) {
}
- break;
- default:
- break;
+ } catch (CModelException e) {
+ }
+ break;
+ default:
+ break;
}
}
@@ -177,49 +175,47 @@ public class CPElement {
}
private IPathEntry newPathEntry() {
- IPath[] exclusionPattern = (IPath[])getAttribute(EXCLUSION);
- IPath base = (IPath)getAttribute(BASE);
- IPath baseRef = (IPath)getAttribute(BASE_REF);
+ IPath[] exclusionPattern = (IPath[]) getAttribute(EXCLUSION);
+ IPath base = (IPath) getAttribute(BASE);
+ IPath baseRef = (IPath) getAttribute(BASE_REF);
switch (fEntryKind) {
- case IPathEntry.CDT_OUTPUT:
- return CoreModel.newOutputEntry(fPath, exclusionPattern);
- case IPathEntry.CDT_SOURCE:
- return CoreModel.newSourceEntry(fPath, exclusionPattern);
- case IPathEntry.CDT_LIBRARY:
- IPath libraryPath = (IPath)getAttribute(LIBRARY);
- IPath attach = (IPath)getAttribute(SOURCEATTACHMENT);
- if (!baseRef.isEmpty()) {
- return CoreModel.newLibraryRefEntry(fPath, baseRef, libraryPath);
- }
- return CoreModel.newLibraryEntry(fPath, base, libraryPath, attach, null, null, isExported());
- case IPathEntry.CDT_PROJECT:
- return CoreModel.newProjectEntry(fPath, isExported());
- case IPathEntry.CDT_CONTAINER:
- return CoreModel.newContainerEntry(fPath, isExported());
- case IPathEntry.CDT_INCLUDE:
- IPath include = (IPath)getAttribute(INCLUDE);
- if (!baseRef.isEmpty()) {
- return CoreModel.newIncludeRefEntry(fPath, baseRef, include);
- }
- return CoreModel.newIncludeEntry(fPath, base, include, ((Boolean)getAttribute(SYSTEM_INCLUDE)).booleanValue(),
- exclusionPattern, isExported());
- case IPathEntry.CDT_INCLUDE_FILE:
- IPath includeFile = (IPath)getAttribute(INCLUDE_FILE);
- return CoreModel.newIncludeFileEntry(fPath, baseRef, base, includeFile,
- exclusionPattern, isExported());
- case IPathEntry.CDT_MACRO:
- String macroName = (String)getAttribute(MACRO_NAME);
- String macroValue = (String)getAttribute(MACRO_VALUE);
- if (!baseRef.isEmpty()) {
- return CoreModel.newMacroRefEntry(fPath, baseRef, macroName);
- }
- return CoreModel.newMacroEntry(fPath, macroName, macroValue, exclusionPattern, isExported());
- case IPathEntry.CDT_MACRO_FILE:
- IPath macrosFile = (IPath)getAttribute(MACROS_FILE);
- return CoreModel.newMacroFileEntry(fPath, baseRef, base, macrosFile,
- exclusionPattern, isExported());
- default:
- return null;
+ case IPathEntry.CDT_OUTPUT:
+ return CoreModel.newOutputEntry(fPath, exclusionPattern);
+ case IPathEntry.CDT_SOURCE:
+ return CoreModel.newSourceEntry(fPath, exclusionPattern);
+ case IPathEntry.CDT_LIBRARY:
+ IPath libraryPath = (IPath) getAttribute(LIBRARY);
+ IPath attach = (IPath) getAttribute(SOURCEATTACHMENT);
+ if (!baseRef.isEmpty()) {
+ return CoreModel.newLibraryRefEntry(fPath, baseRef, libraryPath);
+ }
+ return CoreModel.newLibraryEntry(fPath, base, libraryPath, attach, null, null, isExported());
+ case IPathEntry.CDT_PROJECT:
+ return CoreModel.newProjectEntry(fPath, isExported());
+ case IPathEntry.CDT_CONTAINER:
+ return CoreModel.newContainerEntry(fPath, isExported());
+ case IPathEntry.CDT_INCLUDE:
+ IPath include = (IPath) getAttribute(INCLUDE);
+ if (!baseRef.isEmpty()) {
+ return CoreModel.newIncludeRefEntry(fPath, baseRef, include);
+ }
+ return CoreModel.newIncludeEntry(fPath, base, include,
+ ((Boolean) getAttribute(SYSTEM_INCLUDE)).booleanValue(), exclusionPattern, isExported());
+ case IPathEntry.CDT_INCLUDE_FILE:
+ IPath includeFile = (IPath) getAttribute(INCLUDE_FILE);
+ return CoreModel.newIncludeFileEntry(fPath, baseRef, base, includeFile, exclusionPattern, isExported());
+ case IPathEntry.CDT_MACRO:
+ String macroName = (String) getAttribute(MACRO_NAME);
+ String macroValue = (String) getAttribute(MACRO_VALUE);
+ if (!baseRef.isEmpty()) {
+ return CoreModel.newMacroRefEntry(fPath, baseRef, macroName);
+ }
+ return CoreModel.newMacroEntry(fPath, macroName, macroValue, exclusionPattern, isExported());
+ case IPathEntry.CDT_MACRO_FILE:
+ IPath macrosFile = (IPath) getAttribute(MACROS_FILE);
+ return CoreModel.newMacroFileEntry(fPath, baseRef, base, macrosFile, exclusionPattern, isExported());
+ default:
+ return null;
}
}
@@ -246,66 +242,66 @@ public class CPElement {
appendEncodePath(fPath, buf).append(';');
buf.append(Boolean.valueOf(fIsExported)).append(';');
switch (fEntryKind) {
- case IPathEntry.CDT_OUTPUT:
- case IPathEntry.CDT_SOURCE:
+ case IPathEntry.CDT_OUTPUT:
+ case IPathEntry.CDT_SOURCE:
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_MACRO_FILE:
+ IPath[] exclusion = (IPath[]) getAttribute(EXCLUSION);
+ buf.append('[').append(exclusion.length).append(']');
+ for (IPath element : exclusion) {
+ appendEncodePath(element, buf);
+ }
+ switch (fEntryKind) {
case IPathEntry.CDT_INCLUDE:
- case IPathEntry.CDT_INCLUDE_FILE:
+ IPath baseRef = (IPath) getAttribute(BASE_REF);
+ appendEncodePath(baseRef, buf);
+ IPath base = (IPath) getAttribute(BASE);
+ appendEncodePath(base, buf);
+ IPath include = (IPath) getAttribute(INCLUDE);
+ appendEncodePath(include, buf);
+ break;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ baseRef = (IPath) getAttribute(BASE_REF);
+ appendEncodePath(baseRef, buf);
+ base = (IPath) getAttribute(BASE);
+ appendEncodePath(base, buf);
+ IPath includeFile = (IPath) getAttribute(INCLUDE_FILE);
+ appendEncodePath(includeFile, buf);
+ break;
case IPathEntry.CDT_MACRO:
- case IPathEntry.CDT_MACRO_FILE:
- IPath[] exclusion = (IPath[])getAttribute(EXCLUSION);
- buf.append('[').append(exclusion.length).append(']');
- for (IPath element : exclusion) {
- appendEncodePath(element, buf);
- }
- switch (fEntryKind) {
- case IPathEntry.CDT_INCLUDE:
- IPath baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- IPath base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- IPath include = (IPath)getAttribute(INCLUDE);
- appendEncodePath(include, buf);
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- IPath includeFile = (IPath)getAttribute(INCLUDE_FILE);
- appendEncodePath(includeFile, buf);
- break;
- case IPathEntry.CDT_MACRO:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- String symbol = (String)getAttribute(MACRO_NAME);
- buf.append(symbol).append(';');
- break;
- case IPathEntry.CDT_MACRO_FILE:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- IPath macrosFile = (IPath)getAttribute(MACROS_FILE);
- appendEncodePath(macrosFile, buf);
- break;
- default:
- break;
- }
+ baseRef = (IPath) getAttribute(BASE_REF);
+ appendEncodePath(baseRef, buf);
+ base = (IPath) getAttribute(BASE);
+ appendEncodePath(base, buf);
+ String symbol = (String) getAttribute(MACRO_NAME);
+ buf.append(symbol).append(';');
break;
- case IPathEntry.CDT_LIBRARY:
- IPath baseRef = (IPath)getAttribute(BASE_REF);
+ case IPathEntry.CDT_MACRO_FILE:
+ baseRef = (IPath) getAttribute(BASE_REF);
appendEncodePath(baseRef, buf);
- IPath base = (IPath)getAttribute(BASE);
+ base = (IPath) getAttribute(BASE);
appendEncodePath(base, buf);
- IPath sourceAttach = (IPath)getAttribute(SOURCEATTACHMENT);
- appendEncodePath(sourceAttach, buf);
- IPath library = (IPath)getAttribute(LIBRARY);
- appendEncodePath(library, buf);
+ IPath macrosFile = (IPath) getAttribute(MACROS_FILE);
+ appendEncodePath(macrosFile, buf);
break;
default:
break;
+ }
+ break;
+ case IPathEntry.CDT_LIBRARY:
+ IPath baseRef = (IPath) getAttribute(BASE_REF);
+ appendEncodePath(baseRef, buf);
+ IPath base = (IPath) getAttribute(BASE);
+ appendEncodePath(base, buf);
+ IPath sourceAttach = (IPath) getAttribute(SOURCEATTACHMENT);
+ appendEncodePath(sourceAttach, buf);
+ IPath library = (IPath) getAttribute(LIBRARY);
+ appendEncodePath(library, buf);
+ break;
+ default:
+ break;
}
buf.setLength(buf.length() - 1);
return buf;
@@ -326,66 +322,66 @@ public class CPElement {
appendEncodedPath(fPath, buf).append(';');
buf.append(Boolean.valueOf(fIsExported)).append(';');
switch (fEntryKind) {
- case IPathEntry.CDT_OUTPUT:
- case IPathEntry.CDT_SOURCE:
+ case IPathEntry.CDT_OUTPUT:
+ case IPathEntry.CDT_SOURCE:
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_MACRO_FILE:
+ IPath[] exclusion = (IPath[]) getAttribute(EXCLUSION);
+ buf.append('[').append(exclusion.length).append(']');
+ for (IPath element : exclusion) {
+ appendEncodedPath(element, buf);
+ }
+ switch (fEntryKind) {
case IPathEntry.CDT_INCLUDE:
- case IPathEntry.CDT_INCLUDE_FILE:
+ IPath baseRef = (IPath) getAttribute(BASE_REF);
+ appendEncodedPath(baseRef, buf);
+ IPath base = (IPath) getAttribute(BASE);
+ appendEncodedPath(base, buf);
+ IPath include = (IPath) getAttribute(INCLUDE);
+ appendEncodedPath(include, buf);
+ break;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ baseRef = (IPath) getAttribute(BASE_REF);
+ appendEncodedPath(baseRef, buf);
+ base = (IPath) getAttribute(BASE);
+ appendEncodedPath(base, buf);
+ IPath includeFile = (IPath) getAttribute(INCLUDE_FILE);
+ appendEncodedPath(includeFile, buf);
+ break;
case IPathEntry.CDT_MACRO:
- case IPathEntry.CDT_MACRO_FILE:
- IPath[] exclusion = (IPath[])getAttribute(EXCLUSION);
- buf.append('[').append(exclusion.length).append(']');
- for (IPath element : exclusion) {
- appendEncodedPath(element, buf);
- }
- switch (fEntryKind) {
- case IPathEntry.CDT_INCLUDE:
- IPath baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodedPath(baseRef, buf);
- IPath base = (IPath)getAttribute(BASE);
- appendEncodedPath(base, buf);
- IPath include = (IPath)getAttribute(INCLUDE);
- appendEncodedPath(include, buf);
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodedPath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodedPath(base, buf);
- IPath includeFile = (IPath)getAttribute(INCLUDE_FILE);
- appendEncodedPath(includeFile, buf);
- break;
- case IPathEntry.CDT_MACRO:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodedPath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodedPath(base, buf);
- String symbol = (String)getAttribute(MACRO_NAME);
- buf.append(symbol).append(';');
- break;
- case IPathEntry.CDT_MACRO_FILE:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodedPath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodedPath(base, buf);
- IPath macrosFile = (IPath)getAttribute(MACROS_FILE);
- appendEncodedPath(macrosFile, buf);
- break;
- default:
- break;
- }
+ baseRef = (IPath) getAttribute(BASE_REF);
+ appendEncodedPath(baseRef, buf);
+ base = (IPath) getAttribute(BASE);
+ appendEncodedPath(base, buf);
+ String symbol = (String) getAttribute(MACRO_NAME);
+ buf.append(symbol).append(';');
break;
- case IPathEntry.CDT_LIBRARY:
- IPath baseRef = (IPath)getAttribute(BASE_REF);
+ case IPathEntry.CDT_MACRO_FILE:
+ baseRef = (IPath) getAttribute(BASE_REF);
appendEncodedPath(baseRef, buf);
- IPath base = (IPath)getAttribute(BASE);
+ base = (IPath) getAttribute(BASE);
appendEncodedPath(base, buf);
- IPath sourceAttach = (IPath)getAttribute(SOURCEATTACHMENT);
- appendEncodedPath(sourceAttach, buf);
- IPath library = (IPath)getAttribute(LIBRARY);
- appendEncodedPath(library, buf);
+ IPath macrosFile = (IPath) getAttribute(MACROS_FILE);
+ appendEncodedPath(macrosFile, buf);
break;
default:
break;
+ }
+ break;
+ case IPathEntry.CDT_LIBRARY:
+ IPath baseRef = (IPath) getAttribute(BASE_REF);
+ appendEncodedPath(baseRef, buf);
+ IPath base = (IPath) getAttribute(BASE);
+ appendEncodedPath(base, buf);
+ IPath sourceAttach = (IPath) getAttribute(SOURCEATTACHMENT);
+ appendEncodedPath(sourceAttach, buf);
+ IPath library = (IPath) getAttribute(LIBRARY);
+ appendEncodedPath(library, buf);
+ break;
+ default:
+ break;
}
buf.setLength(buf.length() - 1);
return buf;
@@ -393,7 +389,7 @@ public class CPElement {
/**
* Gets the path entry path.
- *
+ *
* @see IPathEntry#getPath()
*/
public IPath getPath() {
@@ -402,7 +398,7 @@ public class CPElement {
/**
* Gets the classpath entry kind.
- *
+ *
* @see IPathEntry#getEntryKind()
*/
public int getEntryKind() {
@@ -420,7 +416,7 @@ public class CPElement {
public CPElement getParentContainer() {
CPElementAttribute attribute = findAttributeElement(PARENT_CONTAINER);
if (attribute != null) {
- return (CPElement)attribute.getValue();
+ return (CPElement) attribute.getValue();
}
return null;
}
@@ -439,7 +435,7 @@ public class CPElement {
public CPElementGroup getParent() {
CPElementAttribute attribute = findAttributeElement(PARENT);
if (attribute != null) {
- return (CPElementGroup)attribute.getValue();
+ return (CPElementGroup) attribute.getValue();
}
return null;
}
@@ -458,7 +454,7 @@ public class CPElement {
for (int i = 0; i < fChildren.size(); i++) {
Object curr = fChildren.get(i);
if (curr instanceof CPElementAttribute) {
- CPElementAttribute elem = (CPElementAttribute)curr;
+ CPElementAttribute elem = (CPElementAttribute) curr;
if (key.equals(elem.getKey())) {
return elem;
}
@@ -481,33 +477,33 @@ public class CPElement {
public Object[] getChildren() {
switch (fEntryKind) {
- case IPathEntry.CDT_OUTPUT:
- case IPathEntry.CDT_SOURCE:
- case IPathEntry.CDT_INCLUDE:
- case IPathEntry.CDT_INCLUDE_FILE:
- case IPathEntry.CDT_MACRO:
- case IPathEntry.CDT_MACRO_FILE:
- if (getInherited() == null && getParentContainer() == null) {
- return new Object[]{findAttributeElement(EXCLUSION)};
- }
- break;
- // case IPathEntry.CDT_LIBRARY:
- // return new Object[] { findAttributeElement(SOURCEATTACHMENT) };
-
- case IPathEntry.CDT_CONTAINER: {
- List<Object> list = new ArrayList<Object>();
- for (int i = 0; i < fChildren.size(); i++) {
- Object curr = fChildren.get(i);
- if (curr instanceof CPElementGroup) {
- list.add(curr);
- }
+ case IPathEntry.CDT_OUTPUT:
+ case IPathEntry.CDT_SOURCE:
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_MACRO_FILE:
+ if (getInherited() == null && getParentContainer() == null) {
+ return new Object[] { findAttributeElement(EXCLUSION) };
+ }
+ break;
+ // case IPathEntry.CDT_LIBRARY:
+ // return new Object[] { findAttributeElement(SOURCEATTACHMENT) };
+
+ case IPathEntry.CDT_CONTAINER: {
+ List<Object> list = new ArrayList<Object>();
+ for (int i = 0; i < fChildren.size(); i++) {
+ Object curr = fChildren.get(i);
+ if (curr instanceof CPElementGroup) {
+ list.add(curr);
}
- return list.toArray();
}
+ return list.toArray();
+ }
}
return new Object[0];
}
-
+
private void attributeChanged(String key) {
fCachedEntry = null;
fStatus = null;
@@ -519,31 +515,31 @@ public class CPElement {
@Override
public boolean equals(Object other) {
if (other != null && other.getClass().equals(getClass())) {
- CPElement elem = (CPElement)other;
+ CPElement elem = (CPElement) other;
if (elem.fEntryKind != fEntryKind || !elem.fPath.equals(fPath)) {
return false;
}
switch (fEntryKind) {
- case IPathEntry.CDT_LIBRARY:
- return (getAttribute(LIBRARY).equals(elem.getAttribute(LIBRARY))
- && getAttribute(BASE).equals(elem.getAttribute(BASE)) && getAttribute(BASE_REF).equals(
- elem.getAttribute(BASE_REF)));
- case IPathEntry.CDT_INCLUDE:
- return (getAttribute(INCLUDE).equals(elem.getAttribute(INCLUDE))
- && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
- elem.getAttribute(BASE)));
- case IPathEntry.CDT_INCLUDE_FILE:
- return (getAttribute(INCLUDE_FILE).equals(elem.getAttribute(INCLUDE_FILE))
- && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
- elem.getAttribute(BASE)));
- case IPathEntry.CDT_MACRO:
- return (getAttribute(MACRO_NAME).equals(elem.getAttribute(MACRO_NAME))
- && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
- elem.getAttribute(BASE)));
- case IPathEntry.CDT_MACRO_FILE:
- return (getAttribute(MACROS_FILE).equals(elem.getAttribute(MACROS_FILE))
- && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
- elem.getAttribute(BASE)));
+ case IPathEntry.CDT_LIBRARY:
+ return (getAttribute(LIBRARY).equals(elem.getAttribute(LIBRARY))
+ && getAttribute(BASE).equals(elem.getAttribute(BASE))
+ && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)));
+ case IPathEntry.CDT_INCLUDE:
+ return (getAttribute(INCLUDE).equals(elem.getAttribute(INCLUDE))
+ && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF))
+ && getAttribute(BASE).equals(elem.getAttribute(BASE)));
+ case IPathEntry.CDT_INCLUDE_FILE:
+ return (getAttribute(INCLUDE_FILE).equals(elem.getAttribute(INCLUDE_FILE))
+ && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF))
+ && getAttribute(BASE).equals(elem.getAttribute(BASE)));
+ case IPathEntry.CDT_MACRO:
+ return (getAttribute(MACRO_NAME).equals(elem.getAttribute(MACRO_NAME))
+ && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF))
+ && getAttribute(BASE).equals(elem.getAttribute(BASE)));
+ case IPathEntry.CDT_MACRO_FILE:
+ return (getAttribute(MACROS_FILE).equals(elem.getAttribute(MACROS_FILE))
+ && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF))
+ && getAttribute(BASE).equals(elem.getAttribute(BASE)));
}
return true;
}
@@ -558,38 +554,38 @@ public class CPElement {
final int HASH_FACTOR = 89;
int hashCode = fPath.hashCode() + fEntryKind;
switch (fEntryKind) {
- case IPathEntry.CDT_LIBRARY:
- hashCode = hashCode * HASH_FACTOR + getAttribute(LIBRARY).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- break;
- case IPathEntry.CDT_INCLUDE:
- hashCode = hashCode * HASH_FACTOR + getAttribute(INCLUDE).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- hashCode = hashCode * HASH_FACTOR + getAttribute(INCLUDE_FILE).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- break;
- case IPathEntry.CDT_MACRO:
- hashCode = hashCode * HASH_FACTOR + getAttribute(MACRO_NAME).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- break;
- case IPathEntry.CDT_MACRO_FILE:
- hashCode = hashCode * HASH_FACTOR + getAttribute(MACROS_FILE).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- break;
+ case IPathEntry.CDT_LIBRARY:
+ hashCode = hashCode * HASH_FACTOR + getAttribute(LIBRARY).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+ break;
+ case IPathEntry.CDT_INCLUDE:
+ hashCode = hashCode * HASH_FACTOR + getAttribute(INCLUDE).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+ break;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ hashCode = hashCode * HASH_FACTOR + getAttribute(INCLUDE_FILE).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+ break;
+ case IPathEntry.CDT_MACRO:
+ hashCode = hashCode * HASH_FACTOR + getAttribute(MACRO_NAME).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+ break;
+ case IPathEntry.CDT_MACRO_FILE:
+ hashCode = hashCode * HASH_FACTOR + getAttribute(MACROS_FILE).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+ hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+ break;
}
return hashCode;
}
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#toString()
*/
@Override
@@ -599,7 +595,7 @@ public class CPElement {
/**
* Returns if a entry is missing.
- *
+ *
* @return Returns a boolean
*/
public IStatus getStatus() {
@@ -613,111 +609,126 @@ public class CPElement {
IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
IPathEntry entry = getPathEntry();
switch (getEntryKind()) {
- case IPathEntry.CDT_CONTAINER:
- try {
- if ((CoreModel.getPathEntryContainer(fPath, fCProject) == null)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
- CPathEntryMessages.CPElement_status_pathContainerMissing, null);
- }
- } catch (CModelException e) {
+ case IPathEntry.CDT_CONTAINER:
+ try {
+ if ((CoreModel.getPathEntryContainer(fPath, fCProject) == null)) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_pathContainerMissing, null);
}
- break;
- case IPathEntry.CDT_LIBRARY:
- if (!((ILibraryEntry)entry).getFullLibraryPath().toFile().exists()) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_libraryPathNotFound, null);
+ } catch (CModelException e) {
+ }
+ break;
+ case IPathEntry.CDT_LIBRARY:
+ if (!((ILibraryEntry) entry).getFullLibraryPath().toFile().exists()) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_libraryPathNotFound, null);
+ }
+ break;
+ case IPathEntry.CDT_SOURCE:
+ path = fPath.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- break;
- case IPathEntry.CDT_SOURCE:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_sourcePathMissing, null);
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_sourcePathMissing, null);
+ }
+ break;
+ case IPathEntry.CDT_OUTPUT:
+ path = fPath.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- break;
- case IPathEntry.CDT_OUTPUT:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_outputPathMissing, null);
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_outputPathMissing, null);
+ }
+ break;
+ case IPathEntry.CDT_INCLUDE:
+ path = fPath.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- break;
- case IPathEntry.CDT_INCLUDE:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
+ }
+ if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT
+ && fCProject != null) {
+ if (!fCProject.isOnSourceRoot(res)) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_notOnSourcePath, null);
}
- if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
- if (!fCProject.isOnSourceRoot(res)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null);
- }
+ }
+ if (!((IIncludeEntry) entry).getFullIncludePath().toFile().exists()) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_includePathNotFound, null);
+ }
+ break;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ path = fPath.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- if (!((IIncludeEntry) entry).getFullIncludePath().toFile().exists()) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_includePathNotFound, null);
+ }
+ if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT
+ && fCProject != null) {
+ if (!fCProject.isOnSourceRoot(res)) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_notOnSourcePath, null);
}
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
- if (!fCProject.isOnSourceRoot(res)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null);
- }
- }
- if (!((IIncludeFileEntry)entry).getFullIncludeFilePath().toFile().exists()) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_includeFilePathNotFound, null);
- }
- break;
- case IPathEntry.CDT_MACRO:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
+ }
+ if (!((IIncludeFileEntry) entry).getFullIncludeFilePath().toFile().exists()) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_includeFilePathNotFound, null);
+ }
+ break;
+ case IPathEntry.CDT_MACRO:
+ path = fPath.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
- if (!fCProject.isOnSourceRoot(res)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null);
- }
+ }
+ if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT
+ && fCProject != null) {
+ if (!fCProject.isOnSourceRoot(res)) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_notOnSourcePath, null);
+ }
+ }
+ break;
+ case IPathEntry.CDT_MACRO_FILE:
+ path = fPath.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- break;
- case IPathEntry.CDT_MACRO_FILE:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
- if (!fCProject.isOnSourceRoot(res)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null);
- }
- }
- if (!((IMacroFileEntry)entry).getFullMacroFilePath().toFile().exists()) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_macrosFilePathNotFound, null);
- }
- break;
- case IPathEntry.CDT_PROJECT:
- res = root.findMember(fPath);
- if (res == null) {
- fStatus = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_missingProjectPath, null);
+ }
+ if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT
+ && fCProject != null) {
+ if (!fCProject.isOnSourceRoot(res)) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_notOnSourcePath, null);
}
- break;
+ }
+ if (!((IMacroFileEntry) entry).getFullMacroFilePath().toFile().exists()) {
+ fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_macrosFilePathNotFound, null);
+ }
+ break;
+ case IPathEntry.CDT_PROJECT:
+ res = root.findMember(fPath);
+ if (res == null) {
+ fStatus = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1,
+ CPathEntryMessages.CPElement_status_missingProjectPath, null);
+ }
+ break;
}
}
return fStatus;
@@ -725,7 +736,7 @@ public class CPElement {
/**
* Returns if a entry is exported (only applies to libraries)
- *
+ *
* @return Returns a boolean
*/
public boolean isExported() {
@@ -749,7 +760,7 @@ public class CPElement {
/**
* Gets the project.
- *
+ *
* @return Returns a ICProject
*/
public ICProject getCProject() {
@@ -762,11 +773,11 @@ public class CPElement {
IPath sourceAttachment = null;
IPath[] exclusion = null;
IPath include = null;
- IPath includeFile = null;
+ IPath includeFile = null;
IPath library = null;
String macroName = null;
String macroValue = null;
- IPath macrosFile = null;
+ IPath macrosFile = null;
boolean sysInclude = false;
IPath baseRef = null;
IPath base = null;
@@ -775,102 +786,103 @@ public class CPElement {
IResource res = null;
switch (curr.getEntryKind()) {
- case IPathEntry.CDT_CONTAINER:
- res = (element instanceof ICProject) ? null : element.getResource();
- break;
- case IPathEntry.CDT_LIBRARY:
- library = ((ILibraryEntry)curr).getLibraryPath();
- sourceAttachment = ((ILibraryEntry)curr).getSourceAttachmentPath();
- base = ((ILibraryEntry)curr).getBasePath();
- baseRef = ((ILibraryEntry)curr).getBaseReference();
- break;
- case IPathEntry.CDT_SOURCE:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
+ case IPathEntry.CDT_CONTAINER:
+ res = (element instanceof ICProject) ? null : element.getResource();
+ break;
+ case IPathEntry.CDT_LIBRARY:
+ library = ((ILibraryEntry) curr).getLibraryPath();
+ sourceAttachment = ((ILibraryEntry) curr).getSourceAttachmentPath();
+ base = ((ILibraryEntry) curr).getBasePath();
+ baseRef = ((ILibraryEntry) curr).getBaseReference();
+ break;
+ case IPathEntry.CDT_SOURCE:
+ path = path.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- exclusion = ((ISourceEntry)curr).getExclusionPatterns();
- break;
- case IPathEntry.CDT_OUTPUT:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
+ }
+ exclusion = ((ISourceEntry) curr).getExclusionPatterns();
+ break;
+ case IPathEntry.CDT_OUTPUT:
+ path = path.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- exclusion = ((IOutputEntry)curr).getExclusionPatterns();
- break;
- case IPathEntry.CDT_INCLUDE:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
+ }
+ exclusion = ((IOutputEntry) curr).getExclusionPatterns();
+ break;
+ case IPathEntry.CDT_INCLUDE:
+ path = path.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- exclusion = ((IIncludeEntry)curr).getExclusionPatterns();
- sysInclude = ((IIncludeEntry)curr).isSystemInclude();
- baseRef = ((IIncludeEntry)curr).getBaseReference();
- base = ((IIncludeEntry)curr).getBasePath();
- include = ((IIncludeEntry)curr).getIncludePath();
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- exclusion = ((IIncludeFileEntry)curr).getExclusionPatterns();
- includeFile = ((IIncludeFileEntry)curr).getIncludeFilePath();
- baseRef = ((IIncludeFileEntry)curr).getBaseReference();
- base = ((IIncludeFileEntry)curr).getBasePath();
- break;
- case IPathEntry.CDT_MACRO:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
+ }
+ exclusion = ((IIncludeEntry) curr).getExclusionPatterns();
+ sysInclude = ((IIncludeEntry) curr).isSystemInclude();
+ baseRef = ((IIncludeEntry) curr).getBaseReference();
+ base = ((IIncludeEntry) curr).getBasePath();
+ include = ((IIncludeEntry) curr).getIncludePath();
+ break;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ path = path.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
}
- exclusion = ((IMacroEntry)curr).getExclusionPatterns();
- macroName = ((IMacroEntry)curr).getMacroName();
- macroValue = ((IMacroEntry)curr).getMacroValue();
- baseRef = ((IMacroEntry)curr).getBaseReference();
- base = ((IMacroEntry)curr).getBasePath();
- break;
- case IPathEntry.CDT_MACRO_FILE:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- exclusion = ((IMacroFileEntry)curr).getExclusionPatterns();
- macrosFile = ((IMacroFileEntry)curr).getMacroFilePath();
- baseRef = ((IMacroFileEntry)curr).getBaseReference();
- base = ((IMacroFileEntry)curr).getBasePath();
- break;
- case IPathEntry.CDT_PROJECT:
- res = root.findMember(path);
- break;
+ }
+ exclusion = ((IIncludeFileEntry) curr).getExclusionPatterns();
+ includeFile = ((IIncludeFileEntry) curr).getIncludeFilePath();
+ baseRef = ((IIncludeFileEntry) curr).getBaseReference();
+ base = ((IIncludeFileEntry) curr).getBasePath();
+ break;
+ case IPathEntry.CDT_MACRO:
+ path = path.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
+ }
+ }
+ exclusion = ((IMacroEntry) curr).getExclusionPatterns();
+ macroName = ((IMacroEntry) curr).getMacroName();
+ macroValue = ((IMacroEntry) curr).getMacroValue();
+ baseRef = ((IMacroEntry) curr).getBaseReference();
+ base = ((IMacroEntry) curr).getBasePath();
+ break;
+ case IPathEntry.CDT_MACRO_FILE:
+ path = path.removeTrailingSeparator();
+ res = root.findMember(path);
+ if (res == null) {
+ if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+ res = root.getFolder(path);
+ }
+ }
+ exclusion = ((IMacroFileEntry) curr).getExclusionPatterns();
+ macrosFile = ((IMacroFileEntry) curr).getMacroFilePath();
+ baseRef = ((IMacroFileEntry) curr).getBaseReference();
+ base = ((IMacroFileEntry) curr).getBasePath();
+ break;
+ case IPathEntry.CDT_PROJECT:
+ res = root.findMember(path);
+ break;
}
- CPElement elem = new CPElement((element == null) ? null : element.getCProject(), curr.getEntryKind(), path, res);
+ CPElement elem = new CPElement((element == null) ? null : element.getCProject(), curr.getEntryKind(), path,
+ res);
elem.setAttribute(SOURCEATTACHMENT, sourceAttachment);
elem.setAttribute(EXCLUSION, exclusion);
elem.setAttribute(INCLUDE, include);
- elem.setAttribute(INCLUDE_FILE, includeFile);
+ elem.setAttribute(INCLUDE_FILE, includeFile);
elem.setAttribute(LIBRARY, library);
elem.setAttribute(MACRO_NAME, macroName);
elem.setAttribute(MACRO_VALUE, macroValue);
- elem.setAttribute(MACROS_FILE, macrosFile);
+ elem.setAttribute(MACROS_FILE, macrosFile);
elem.setAttribute(SYSTEM_INCLUDE, Boolean.valueOf(sysInclude));
elem.setAttribute(BASE_REF, baseRef);
elem.setAttribute(BASE, base);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java
index 9ac507070e3..2e16c317a2d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java
@@ -31,7 +31,7 @@ public class CPElementAttribute {
/**
* Returns the key.
- *
+ *
* @return String
*/
public String getKey() {
@@ -40,7 +40,7 @@ public class CPElementAttribute {
/**
* Returns the value.
- *
+ *
* @return Object
*/
public Object getValue() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java
index ec9fd093716..4877f63136f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java
@@ -56,16 +56,17 @@ public class CPElementFilter extends ViewerFilter {
public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof CPElement) {
for (int i = 0; i < fKind.length; i++) {
- if ( ((CPElement)element).getEntryKind() == fKind[i]) {
+ if (((CPElement) element).getEntryKind() == fKind[i]) {
if (fExcludes == null || !fExcludes.contains(element)) {
if (fExportedOnly == true) {
- if ( !fShowInherited ) {
- return ((CPElement)element).getInherited() == null && ((CPElement)element).isExported();
+ if (!fShowInherited) {
+ return ((CPElement) element).getInherited() == null
+ && ((CPElement) element).isExported();
}
- return ((CPElement)element).isExported();
+ return ((CPElement) element).isExported();
}
- if ( !fShowInherited ) {
- return ((CPElement)element).getInherited() == null;
+ if (!fShowInherited) {
+ return ((CPElement) element).getInherited() == null;
}
return true;
}
@@ -73,10 +74,10 @@ public class CPElementFilter extends ViewerFilter {
}
} else if (element instanceof IPathEntry) {
for (int i = 0; i < fKind.length; i++) {
- if ( ((IPathEntry)element).getEntryKind() == fKind[i]) {
+ if (((IPathEntry) element).getEntryKind() == fKind[i]) {
if (fExcludes == null || !fExcludes.contains(element)) {
if (fExportedOnly == true) {
- return ((IPathEntry)element).isExported();
+ return ((IPathEntry) element).isExported();
}
return true;
}
@@ -84,7 +85,7 @@ public class CPElementFilter extends ViewerFilter {
}
} else if (element instanceof CPElementGroup) {
for (int i = 0; i < fKind.length; i++) {
- if ( ((CPElementGroup)element).getEntryKind() == fKind[i]) {
+ if (((CPElementGroup) element).getEntryKind() == fKind[i]) {
return true;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java
index c0ff43a8c24..1ceca40f13e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java
@@ -66,8 +66,9 @@ public class CPElementGroup {
return true;
}
if (arg0 instanceof CPElementGroup) {
- CPElementGroup other = (CPElementGroup)arg0;
- return (kind == other.kind && ( (parent == null && other.parent == null) || parent.equals(other.parent)) && ( (resource == null && other.resource == null) || resource.equals(other.resource)));
+ CPElementGroup other = (CPElementGroup) arg0;
+ return (kind == other.kind && ((parent == null && other.parent == null) || parent.equals(other.parent))
+ && ((resource == null && other.resource == null) || resource.equals(other.resource)));
}
return false;
}
@@ -83,13 +84,13 @@ public class CPElementGroup {
List<CPElement> children = getChildrenList(element.getEntryKind(), false);
return children != null ? children.indexOf(element) : -1;
}
-
+
public void addChild(CPElement element, int insertIndex) {
List<CPElement> children = getChildrenList(element.getEntryKind(), true);
children.add(insertIndex, element);
element.setParent(this);
}
-
+
public void addChild(CPElement element) {
List<CPElement> children = getChildrenList(element.getEntryKind(), true);
int indx = children.indexOf(element);
@@ -124,7 +125,8 @@ public class CPElementGroup {
public void setChildren(CPElement[] elements) {
if (elements.length > 0) {
if (childrenListMap != null) {
- childrenListMap.put(Integer.valueOf(elements[0].getEntryKind()), new ArrayList<CPElement>(Arrays.asList(elements)));
+ childrenListMap.put(Integer.valueOf(elements[0].getEntryKind()),
+ new ArrayList<CPElement>(Arrays.asList(elements)));
} else {
childrenList = new ArrayList<CPElement>(Arrays.asList(elements));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java
index ac7e1d58121..47ec66bd0a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java
@@ -44,7 +44,7 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
private String fNewLabel, fCreateLabel;
private ImageDescriptor fIncludeIcon, fMacroIcon, fLibWSrcIcon, fLibIcon;
- private ImageDescriptor fQuoteIncludeIcon, fIncludeFileIcon, fMacrosFileIcon;
+ private ImageDescriptor fQuoteIncludeIcon, fIncludeFileIcon, fMacrosFileIcon;
private ImageDescriptor fFolderImage, fOutputImage, fProjectImage, fContainerImage;
private boolean bShowExported;
private boolean bShowParentInfo;
@@ -55,17 +55,17 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
}
public CPElementLabelProvider(boolean showExported, boolean showParentInfo) {
- fNewLabel = CPathEntryMessages.CPElementLabelProvider_new;
- fCreateLabel = CPathEntryMessages.CPElementLabelProvider_willbecreated;
+ fNewLabel = CPathEntryMessages.CPElementLabelProvider_new;
+ fCreateLabel = CPathEntryMessages.CPElementLabelProvider_willbecreated;
fRegistry = CUIPlugin.getImageDescriptorRegistry();
fLibIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
fLibWSrcIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
fIncludeIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
- fQuoteIncludeIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_QUOTE_INCLUDES_FOLDER);
- fIncludeFileIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+ fQuoteIncludeIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_QUOTE_INCLUDES_FOLDER);
+ fIncludeFileIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
fMacroIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
- fMacrosFileIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+ fMacrosFileIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
fFolderImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ROOT);
fOutputImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
fContainerImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY);
@@ -83,64 +83,64 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
@Override
public void dispose() {
inDirect.dispose();
- inDirect= null;
+ inDirect = null;
super.dispose();
}
-
+
@Override
public String getText(Object element) {
if (element instanceof CPElement) {
- return getCPElementText((CPElement)element);
+ return getCPElementText((CPElement) element);
} else if (element instanceof CPElementAttribute) {
- return getCPElementAttributeText((CPElementAttribute)element);
+ return getCPElementAttributeText((CPElementAttribute) element);
} else if (element instanceof IPathEntry) {
- return getCPElementText(CPElement.createFromExisting((IPathEntry)element, null));
+ return getCPElementText(CPElement.createFromExisting((IPathEntry) element, null));
} else if (element instanceof CPElementGroup) {
- return (getCPContainerGroupText((CPElementGroup)element));
+ return (getCPContainerGroupText((CPElementGroup) element));
}
return super.getText(element);
}
private String getCPContainerGroupText(CPElementGroup group) {
switch (group.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- return CPathEntryMessages.CPElementLabelProvider_Includes;
- case IPathEntry.CDT_INCLUDE_FILE :
- return CPathEntryMessages.CPElementLabelProvider_IncludeFiles;
- case IPathEntry.CDT_MACRO :
- return CPathEntryMessages.CPElementLabelProvider_PreprocessorSymbols;
- case IPathEntry.CDT_MACRO_FILE :
- return CPathEntryMessages.CPElementLabelProvider_MacrosFiles;
- case IPathEntry.CDT_LIBRARY :
- return CPathEntryMessages.CPElementLabelProvider_Libraries;
- case -1 :
- if (group.getResource().getType() == IResource.PROJECT) {
- return group.getResource().getName();
- }
- StringBuilder label = new StringBuilder(group.getResource().getProjectRelativePath().toString());
- if (!group.getResource().exists()) {
- label.append(fCreateLabel);
- }
- return label.toString();
+ case IPathEntry.CDT_INCLUDE:
+ return CPathEntryMessages.CPElementLabelProvider_Includes;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ return CPathEntryMessages.CPElementLabelProvider_IncludeFiles;
+ case IPathEntry.CDT_MACRO:
+ return CPathEntryMessages.CPElementLabelProvider_PreprocessorSymbols;
+ case IPathEntry.CDT_MACRO_FILE:
+ return CPathEntryMessages.CPElementLabelProvider_MacrosFiles;
+ case IPathEntry.CDT_LIBRARY:
+ return CPathEntryMessages.CPElementLabelProvider_Libraries;
+ case -1:
+ if (group.getResource().getType() == IResource.PROJECT) {
+ return group.getResource().getName();
+ }
+ StringBuilder label = new StringBuilder(group.getResource().getProjectRelativePath().toString());
+ if (!group.getResource().exists()) {
+ label.append(fCreateLabel);
+ }
+ return label.toString();
}
return ""; //$NON-NLS-1$
}
public String getCPElementAttributeText(CPElementAttribute attrib) {
- String notAvailable = CPathEntryMessages.CPElementLabelProvider_none;
+ String notAvailable = CPathEntryMessages.CPElementLabelProvider_none;
StringBuilder buf = new StringBuilder();
String key = attrib.getKey();
if (key.equals(CPElement.SOURCEATTACHMENT)) {
- buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_label);
- IPath path = (IPath)attrib.getValue();
+ buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_label);
+ IPath path = (IPath) attrib.getValue();
if (path != null && !path.isEmpty()) {
buf.append(getPathString(path, path.getDevice() != null));
} else {
buf.append(notAvailable);
}
} else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) {
- buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_root_label);
- IPath path = (IPath)attrib.getValue();
+ buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_root_label);
+ IPath path = (IPath) attrib.getValue();
if (path != null && !path.isEmpty()) {
buf.append(path.toString());
} else {
@@ -148,12 +148,12 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
}
}
if (key.equals(CPElement.EXCLUSION)) {
- buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_label);
- IPath[] patterns = (IPath[])attrib.getValue();
+ buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_label);
+ IPath[] patterns = (IPath[]) attrib.getValue();
if (patterns != null && patterns.length > 0) {
for (int i = 0; i < patterns.length; i++) {
if (i > 0) {
- buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_separator);
+ buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_separator);
}
buf.append(patterns[i].toString());
}
@@ -167,80 +167,82 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
public String getCPElementText(CPElement cpentry) {
IPath path = cpentry.getPath();
switch (cpentry.getEntryKind()) {
- case IPathEntry.CDT_LIBRARY : {
- IPath libPath = (IPath)cpentry.getAttribute(CPElement.LIBRARY);
- StringBuilder str = new StringBuilder();
- addBaseString(libPath, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_PROJECT :
- return path.lastSegment();
- case IPathEntry.CDT_INCLUDE : {
- IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
- StringBuilder str = new StringBuilder();
- addBaseString(incPath, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_INCLUDE_FILE : {
- IPath incFilePath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE_FILE));
- StringBuilder str = new StringBuilder();
- addBaseString(incFilePath, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_MACRO : {
- StringBuilder str = new StringBuilder((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
- + (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
- addBaseString(null, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_MACRO_FILE : {
- IPath macroFilePath = ((IPath)cpentry.getAttribute(CPElement.MACROS_FILE));
- StringBuilder str = new StringBuilder();
- addBaseString(macroFilePath, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_CONTAINER : {
- StringBuilder str = new StringBuilder(path.toString());
- try {
- IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
- if (container != null) {
- str.setLength(0);
- str.append(container.getDescription());
- }
- } catch (CModelException e) {
+ case IPathEntry.CDT_LIBRARY: {
+ IPath libPath = (IPath) cpentry.getAttribute(CPElement.LIBRARY);
+ StringBuilder str = new StringBuilder();
+ addBaseString(libPath, cpentry, str);
+ addExport(cpentry, str);
+ addParentInfo(cpentry, str);
+ return str.toString();
+ }
+ case IPathEntry.CDT_PROJECT:
+ return path.lastSegment();
+ case IPathEntry.CDT_INCLUDE: {
+ IPath incPath = ((IPath) cpentry.getAttribute(CPElement.INCLUDE));
+ StringBuilder str = new StringBuilder();
+ addBaseString(incPath, cpentry, str);
+ addExport(cpentry, str);
+ addParentInfo(cpentry, str);
+ return str.toString();
+ }
+ case IPathEntry.CDT_INCLUDE_FILE: {
+ IPath incFilePath = ((IPath) cpentry.getAttribute(CPElement.INCLUDE_FILE));
+ StringBuilder str = new StringBuilder();
+ addBaseString(incFilePath, cpentry, str);
+ addExport(cpentry, str);
+ addParentInfo(cpentry, str);
+ return str.toString();
+ }
+ case IPathEntry.CDT_MACRO: {
+ StringBuilder str = new StringBuilder((String) cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
+ + (String) cpentry.getAttribute(CPElement.MACRO_VALUE));
+ addBaseString(null, cpentry, str);
+ addExport(cpentry, str);
+ addParentInfo(cpentry, str);
+ return str.toString();
+ }
+ case IPathEntry.CDT_MACRO_FILE: {
+ IPath macroFilePath = ((IPath) cpentry.getAttribute(CPElement.MACROS_FILE));
+ StringBuilder str = new StringBuilder();
+ addBaseString(macroFilePath, cpentry, str);
+ addExport(cpentry, str);
+ addParentInfo(cpentry, str);
+ return str.toString();
+ }
+ case IPathEntry.CDT_CONTAINER: {
+ StringBuilder str = new StringBuilder(path.toString());
+ try {
+ IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(),
+ cpentry.getCProject());
+ if (container != null) {
+ str.setLength(0);
+ str.append(container.getDescription());
}
- addExport(cpentry, str);
- return str.toString();
+ } catch (CModelException e) {
}
- case IPathEntry.CDT_SOURCE :
- case IPathEntry.CDT_OUTPUT : {
- StringBuilder buf = new StringBuilder(path.makeRelative().toString());
- IResource resource = cpentry.getResource();
- if (resource != null && !resource.exists()) {
- buf.append(' ');
- if (cpentry.getStatus().getSeverity() != IStatus.OK) { // only valid error for src/output would missing path...
- buf.append(fCreateLabel);
- } else {
- buf.append(fNewLabel);
- }
+ addExport(cpentry, str);
+ return str.toString();
+ }
+ case IPathEntry.CDT_SOURCE:
+ case IPathEntry.CDT_OUTPUT: {
+ StringBuilder buf = new StringBuilder(path.makeRelative().toString());
+ IResource resource = cpentry.getResource();
+ if (resource != null && !resource.exists()) {
+ buf.append(' ');
+ if (cpentry.getStatus().getSeverity() != IStatus.OK) { // only valid error for src/output would missing path...
+ buf.append(fCreateLabel);
+ } else {
+ buf.append(fNewLabel);
}
- return buf.toString();
}
- default :
- // pass
+ return buf.toString();
}
- return CPathEntryMessages.CPElementLabelProvider_unknown_element_label;
+ default:
+ // pass
+ }
+ return CPathEntryMessages.CPElementLabelProvider_unknown_element_label;
}
+
/**
* @param cpentry
* @param str
@@ -251,7 +253,8 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
if (parent != null) {
str.append(" ["); //$NON-NLS-1$
try {
- IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
+ IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(),
+ cpentry.getCProject());
if (container != null) {
str.append(container.getDescription());
}
@@ -266,12 +269,12 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
private void addExport(CPElement cpentry, StringBuilder str) {
if (bShowExported && cpentry.isExported()) {
str.append(' ');
- str.append(CPathEntryMessages.CPElementLabelProvider_export_label);
+ str.append(CPathEntryMessages.CPElementLabelProvider_export_label);
}
}
private void addBaseString(IPath endPath, CPElement cpentry, StringBuilder str) {
- IPath baseRef = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
+ IPath baseRef = (IPath) cpentry.getAttribute(CPElement.BASE_REF);
if (!baseRef.isEmpty()) {
if (baseRef.isAbsolute()) {
// str.append("From project ");
@@ -297,7 +300,7 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
str.append(')');
}
} else {
- IPath path = (IPath)cpentry.getAttribute(CPElement.BASE);
+ IPath path = (IPath) cpentry.getAttribute(CPElement.BASE);
if (!path.isEmpty()) {
if (endPath != null) {
path = path.append(endPath);
@@ -326,38 +329,38 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
private ImageDescriptor getCPElementBaseImage(CPElement cpentry) {
switch (cpentry.getEntryKind()) {
- case IPathEntry.CDT_OUTPUT :
- if (cpentry.getPath().segmentCount() == 1) {
- return fProjectImage;
- }
- return fOutputImage;
- case IPathEntry.CDT_SOURCE :
- if (cpentry.getPath().segmentCount() == 1) {
- return fProjectImage;
- }
- return fFolderImage;
- case IPathEntry.CDT_LIBRARY :
- IPath path = (IPath)cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
- if (path == null || path.isEmpty()) {
- return fLibIcon;
- }
- return fLibWSrcIcon;
- case IPathEntry.CDT_PROJECT :
+ case IPathEntry.CDT_OUTPUT:
+ if (cpentry.getPath().segmentCount() == 1) {
+ return fProjectImage;
+ }
+ return fOutputImage;
+ case IPathEntry.CDT_SOURCE:
+ if (cpentry.getPath().segmentCount() == 1) {
return fProjectImage;
- case IPathEntry.CDT_CONTAINER :
- return fContainerImage;
- case IPathEntry.CDT_INCLUDE :
- if (((Boolean)cpentry.getAttribute(CPElement.SYSTEM_INCLUDE)).booleanValue())
- return fIncludeIcon;
- return fQuoteIncludeIcon;
- case IPathEntry.CDT_INCLUDE_FILE :
- return fIncludeFileIcon;
- case IPathEntry.CDT_MACRO :
- return fMacroIcon;
- case IPathEntry.CDT_MACRO_FILE :
- return fMacrosFileIcon;
- default :
- return null;
+ }
+ return fFolderImage;
+ case IPathEntry.CDT_LIBRARY:
+ IPath path = (IPath) cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
+ if (path == null || path.isEmpty()) {
+ return fLibIcon;
+ }
+ return fLibWSrcIcon;
+ case IPathEntry.CDT_PROJECT:
+ return fProjectImage;
+ case IPathEntry.CDT_CONTAINER:
+ return fContainerImage;
+ case IPathEntry.CDT_INCLUDE:
+ if (((Boolean) cpentry.getAttribute(CPElement.SYSTEM_INCLUDE)).booleanValue())
+ return fIncludeIcon;
+ return fQuoteIncludeIcon;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ return fIncludeFileIcon;
+ case IPathEntry.CDT_MACRO:
+ return fMacroIcon;
+ case IPathEntry.CDT_MACRO_FILE:
+ return fMacrosFileIcon;
+ default:
+ return null;
}
}
@@ -366,50 +369,54 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
@Override
public Image getImage(Object element) {
if (element instanceof CPElement) {
- CPElement cpentry = (CPElement)element;
+ CPElement cpentry = (CPElement) element;
ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry);
if (imageDescriptor != null) {
switch (cpentry.getStatus().getSeverity()) {
- case IStatus.WARNING :
- imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
- break;
- case IStatus.ERROR :
- imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.ERROR, SMALL_SIZE);
- break;
+ case IStatus.WARNING:
+ imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING,
+ SMALL_SIZE);
+ break;
+ case IStatus.ERROR:
+ imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.ERROR,
+ SMALL_SIZE);
+ break;
}
if (cpentry.getInherited() != null) {
- imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE);
+ imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.PATH_INHERIT,
+ SMALL_SIZE);
}
return fRegistry.get(imageDescriptor);
}
} else if (element instanceof CPElementAttribute) {
- String key = ((CPElementAttribute)element).getKey();
+ String key = ((CPElementAttribute) element).getKey();
if (key.equals(CPElement.SOURCEATTACHMENT)) {
return fRegistry.get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ATTACH_ATTRIB));
} else if (key.equals(CPElement.EXCLUSION)) {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB);
}
} else if (element instanceof IPathEntry) {
- return getImage(CPElement.createFromExisting((IPathEntry)element, null));
+ return getImage(CPElement.createFromExisting((IPathEntry) element, null));
} else if (element instanceof CPElementGroup) {
- switch ( ((CPElementGroup)element).getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
- case IPathEntry.CDT_MACRO :
- return fRegistry.get(fMacroIcon);
- case IPathEntry.CDT_INCLUDE_FILE :
- case IPathEntry.CDT_MACRO_FILE :
- return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDE);
- case IPathEntry.CDT_LIBRARY :
- return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY);
- case -1 :
- IResource res = ((CPElementGroup)element).getResource();
- IWorkbenchAdapter adapter = res.getAdapter(IWorkbenchAdapter.class);
- ImageDescriptor imageDescriptor = adapter.getImageDescriptor(res);
- if (!res.exists()) {
- imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
- }
- return fRegistry.get(imageDescriptor);
+ switch (((CPElementGroup) element).getEntryKind()) {
+ case IPathEntry.CDT_INCLUDE:
+ return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
+ case IPathEntry.CDT_MACRO:
+ return fRegistry.get(fMacroIcon);
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO_FILE:
+ return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDE);
+ case IPathEntry.CDT_LIBRARY:
+ return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY);
+ case -1:
+ IResource res = ((CPElementGroup) element).getResource();
+ IWorkbenchAdapter adapter = res.getAdapter(IWorkbenchAdapter.class);
+ ImageDescriptor imageDescriptor = adapter.getImageDescriptor(res);
+ if (!res.exists()) {
+ imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING,
+ SMALL_SIZE);
+ }
+ return fRegistry.get(imageDescriptor);
}
}
return null;
@@ -417,13 +424,13 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
@Override
public Color getForeground(Object element) {
if (element instanceof CPElement) {
- if ( ((CPElement)element).getInherited() != null) {
+ if (((CPElement) element).getInherited() != null) {
return inDirect;
}
}
@@ -432,7 +439,7 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java
index f4fd2f61e67..2b7493ffc16 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java
@@ -41,30 +41,30 @@ public class CPElementSorter extends ViewerSorter {
@Override
public int category(Object obj) {
if (obj instanceof CPElement) {
- switch ( ((CPElement)obj).getEntryKind()) {
- case IPathEntry.CDT_LIBRARY :
- return LIBRARY;
- case IPathEntry.CDT_PROJECT :
- return PROJECT;
- case IPathEntry.CDT_SOURCE :
- return SOURCE;
- case IPathEntry.CDT_CONTAINER :
- return CONTAINER;
+ switch (((CPElement) obj).getEntryKind()) {
+ case IPathEntry.CDT_LIBRARY:
+ return LIBRARY;
+ case IPathEntry.CDT_PROJECT:
+ return PROJECT;
+ case IPathEntry.CDT_SOURCE:
+ return SOURCE;
+ case IPathEntry.CDT_CONTAINER:
+ return CONTAINER;
}
} else if (obj instanceof CPElementGroup) {
- switch ( ((CPElementGroup)obj).getEntryKind()) {
- case IPathEntry.CDT_LIBRARY :
- return LIBRARY;
- case IPathEntry.CDT_PROJECT :
+ switch (((CPElementGroup) obj).getEntryKind()) {
+ case IPathEntry.CDT_LIBRARY:
+ return LIBRARY;
+ case IPathEntry.CDT_PROJECT:
+ return PROJECT;
+ case IPathEntry.CDT_SOURCE:
+ return SOURCE;
+ case IPathEntry.CDT_CONTAINER:
+ return CONTAINER;
+ case -1:
+ if (((CPElementGroup) obj).getResource() instanceof IProject) {
return PROJECT;
- case IPathEntry.CDT_SOURCE :
- return SOURCE;
- case IPathEntry.CDT_CONTAINER :
- return CONTAINER;
- case -1 :
- if ( ((CPElementGroup)obj).getResource() instanceof IProject) {
- return PROJECT;
- }
+ }
}
}
return OTHER;
@@ -78,7 +78,7 @@ public class CPElementSorter extends ViewerSorter {
List<CPElement> syms = new ArrayList<CPElement>(elements.length);
for (Object element : elements) {
if (element instanceof CPElement) {
- CPElement cpelement = (CPElement)element;
+ CPElement cpelement = (CPElement) element;
if (cpelement.getEntryKind() == IPathEntry.CDT_INCLUDE) {
includes.add(cpelement);
} else if (cpelement.getEntryKind() == IPathEntry.CDT_MACRO) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java
index 1a4203c28ad..d120a664d8d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java
@@ -23,13 +23,13 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
public class CPListImageDescriptor extends CompositeImageDescriptor {
/** Flag to render the waring adornment */
- public final static int WARNING= 0x1;
+ public final static int WARNING = 0x1;
/** Flag to render the inherited adornment */
- public final static int ERROR= 0x2;
+ public final static int ERROR = 0x2;
/** Flag to render the inherited adornment */
- public final static int PATH_INHERIT= 0x4;
+ public final static int PATH_INHERIT = 0x4;
private ImageDescriptor fBaseImage;
private int flags;
@@ -91,23 +91,23 @@ public class CPListImageDescriptor extends CompositeImageDescriptor {
* Add any overlays to the image as specified in the flags.
*/
protected void drawOverlays() {
- Point size= getSize();
+ Point size = getSize();
ImageData data = null;
- int x= getSize().x;
+ int x = getSize().x;
if ((flags & PATH_INHERIT) == PATH_INHERIT) {
data = CPluginImages.DESC_OVR_PATH_INHERIT.getImageData(100);
drawImage(data, x, 0);
}
- x= 0;
+ x = 0;
if ((flags & ERROR) != 0) {
data = CPluginImages.DESC_OVR_ERROR.getImageData(100);
drawImage(data, x, size.y - data.height);
- x+= data.width;
+ x += data.width;
}
if ((flags & WARNING) != 0) {
data = CPluginImages.DESC_OVR_WARNING.getImageData(100);
drawImage(data, x, size.y - data.height);
- x+= data.width;
+ x += data.width;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
index ab274ef999b..5558ad786e5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
@@ -37,7 +37,8 @@ public abstract class CPathBasePage extends AbstractCOptionPage {
super(title, image);
}
- protected void fixNestingConflicts(List<CPElement> newEntries, List<CPElement> existingList, Set<CPElement> modifiedSourceEntries) {
+ protected void fixNestingConflicts(List<CPElement> newEntries, List<CPElement> existingList,
+ Set<CPElement> modifiedSourceEntries) {
ArrayList<CPElement> existing = new ArrayList<CPElement>(existingList);
for (int i = 0; i < newEntries.size(); i++) {
CPElement curr = newEntries.get(i);
@@ -56,7 +57,8 @@ public abstract class CPathBasePage extends AbstractCOptionPage {
if (currPath.isPrefixOf(entryPath) && !currPath.equals(entryPath)) {
IPath[] exclusionFilters = (IPath[]) curr.getAttribute(CPElement.EXCLUSION);
if (!CoreModelUtil.isExcludedPath(entryPath.removeFirstSegments(1), exclusionFilters)) {
- IPath pathToExclude = entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator();
+ IPath pathToExclude = entryPath.removeFirstSegments(currPath.segmentCount())
+ .addTrailingSeparator();
IPath[] newExclusionFilters = new IPath[exclusionFilters.length + 1];
System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length);
newExclusionFilters[exclusionFilters.length] = pathToExclude;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java
index 6d9767eb0c7..d8b13c29052 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java
@@ -45,14 +45,14 @@ public class CPathContainerDefaultPage extends NewElementWizardPage implements I
*/
public CPathContainerDefaultPage() {
super("CPathContainerDefaultPage"); //$NON-NLS-1$
- setTitle(CPathEntryMessages.CPathContainerDefaultPage_title);
- setDescription(CPathEntryMessages.CPathContainerDefaultPage_description);
+ setTitle(CPathEntryMessages.CPathContainerDefaultPage_title);
+ setDescription(CPathEntryMessages.CPathContainerDefaultPage_description);
setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
-
- fUsedPaths= new ArrayList<IPath>();
-
- fEntryField= new StringDialogField();
- fEntryField.setLabelText(CPathEntryMessages.CPathContainerDefaultPage_path_label);
+
+ fUsedPaths = new ArrayList<IPath>();
+
+ fEntryField = new StringDialogField();
+ fEntryField.setLabelText(CPathEntryMessages.CPathContainerDefaultPage_path_label);
fEntryField.setDialogFieldListener(new IDialogFieldListener() {
@Override
public void dialogFieldChanged(DialogField field) {
@@ -63,18 +63,18 @@ public class CPathContainerDefaultPage extends NewElementWizardPage implements I
}
protected void validatePath() {
- StatusInfo status= new StatusInfo();
- String str= fEntryField.getText();
+ StatusInfo status = new StatusInfo();
+ String str = fEntryField.getText();
if (str.length() == 0) {
- status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_enterpath);
+ status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_enterpath);
} else if (!Path.ROOT.isValidPath(str)) {
- status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_invalidpath);
+ status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_invalidpath);
} else {
- IPath path= new Path(str);
+ IPath path = new Path(str);
if (path.segmentCount() == 0) {
- status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_needssegment);
+ status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_needssegment);
} else if (fUsedPaths.contains(path)) {
- status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_alreadyexists);
+ status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_alreadyexists);
}
}
updateStatus(status);
@@ -85,19 +85,19 @@ public class CPathContainerDefaultPage extends NewElementWizardPage implements I
*/
@Override
public void createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
composite.setLayout(layout);
-
+
fEntryField.doFillIntoGrid(composite, 2);
LayoutUtil.setHorizontalGrabbing(fEntryField.getTextControl(null), true);
-
+
fEntryField.setFocus();
-
+
setControl(composite);
Dialog.applyDialogFont(composite);
-// WorkbenchHelp.setHelp(composite, IJavaHelpContextIds.CLASSPATH_CONTAINER_DEFAULT_PAGE);
+ // WorkbenchHelp.setHelp(composite, IJavaHelpContextIds.CLASSPATH_CONTAINER_DEFAULT_PAGE);
}
/* (non-Javadoc)
@@ -107,27 +107,27 @@ public class CPathContainerDefaultPage extends NewElementWizardPage implements I
public boolean finish() {
return true;
}
-
+
/* (non-Javadoc)
* @see IClasspathContainerPage#getSelection()
*/
@Override
public IContainerEntry[] getNewContainers() {
- return new IContainerEntry[] {CoreModel.newContainerEntry(new Path(fEntryField.getText()))};
+ return new IContainerEntry[] { CoreModel.newContainerEntry(new Path(fEntryField.getText())) };
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension#initialize(org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathEntry)
*/
@Override
public void initialize(ICProject project, IPathEntry[] currentEntries) {
- for (int i= 0; i < currentEntries.length; i++) {
- IPathEntry curr= currentEntries[i];
+ for (int i = 0; i < currentEntries.length; i++) {
+ IPathEntry curr = currentEntries[i];
if (curr.getEntryKind() == IPathEntry.CDT_CONTAINER) {
fUsedPaths.add(curr.getPath());
}
}
- }
+ }
/* (non-Javadoc)
* @see IClasspathContainerPage#setSelection(IClasspathEntry)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java
index 581f4f020a0..571fa93766e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java
@@ -43,7 +43,6 @@ import org.eclipse.cdt.internal.ui.util.CoreUtility;
public class CPathContainerDescriptor implements IContainerDescriptor {
-
/**
* Adapter class to adapter deprecated ICPathContainerPage to new IPathEntryContainerPage
* @author Dave
@@ -58,8 +57,8 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
return null;
}
-
private final org.eclipse.cdt.ui.wizards.ICPathContainerPage fPage;
+
protected PathEntryContainerPageAdapter(org.eclipse.cdt.ui.wizards.ICPathContainerPage page) {
fPage = page;
}
@@ -269,6 +268,7 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
}
}
+
private IConfigurationElement fConfigElement;
private static final String ATT_EXTENSION = "PathContainerPage"; //$NON-NLS-1$
@@ -276,7 +276,7 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
private static final String ATT_ID = "id"; //$NON-NLS-1$
private static final String ATT_NAME = "name"; //$NON-NLS-1$
private static final String ATT_ICON = "icon"; //$NON-NLS-1$
- private static final String ATT_PAGE_CLASS = "class"; //$NON-NLS-1$
+ private static final String ATT_PAGE_CLASS = "class"; //$NON-NLS-1$
private Image pageImage;
@@ -289,8 +289,9 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
String pageClassName = configElement.getAttribute(ATT_PAGE_CLASS);
if (name == null) {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Invalid extension (missing name): " + id, //$NON-NLS-1$
- null));
+ throw new CoreException(
+ new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Invalid extension (missing name): " + id, //$NON-NLS-1$
+ null));
}
if (pageClassName == null) {
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
@@ -303,8 +304,8 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
Object elem = CoreUtility.createExtension(fConfigElement, ATT_PAGE_CLASS);
if (elem instanceof IPathEntryContainerPage) {
return (IPathEntryContainerPage) elem;
- }
- IPathEntryContainerPage result= PathEntryContainerPageAdapter.createAdapter(elem);
+ }
+ IPathEntryContainerPage result = PathEntryContainerPageAdapter.createAdapter(elem);
if (result != null) {
return result;
}
@@ -367,7 +368,8 @@ public class CPathContainerDescriptor implements IContainerDescriptor {
public static IContainerDescriptor[] getDescriptors() {
ArrayList<IContainerDescriptor> containers = new ArrayList<IContainerDescriptor>();
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION);
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ ATT_EXTENSION);
if (extensionPoint != null) {
IContainerDescriptor defaultPage = null;
String defaultPageName = CPathContainerDefaultPage.class.getName();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
index 72b1a54c069..6f2af8f5c76 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
@@ -44,7 +44,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
/**
* Path Containers tab for C/C++ Project Paths page for 3.X projects.
- *
+ *
* @deprecated as of CDT 4.0. This tab was used to set preferences/properties
* for 3.X style projects.
*/
@@ -62,23 +62,18 @@ public class CPathContainerEntryPage extends CPathBasePage {
private final int IDX_EXPORT = 5;
public CPathContainerEntryPage(ListDialogField<CPElement> cPathList) {
- super(CPathEntryMessages.ContainerEntryPage_title);
+ super(CPathEntryMessages.ContainerEntryPage_title);
fCPathList = cPathList;
- String[] buttonLabels = new String[]{
- CPathEntryMessages.ContainerEntryPage_add_button,
- /* */null,
- CPathEntryMessages.ContainerEntryPage_edit_button,
- CPathEntryMessages.ContainerEntryPage_remove_button,
- null,
- CPathEntryMessages.ContainerEntryPage_export_button
- };
+ String[] buttonLabels = new String[] { CPathEntryMessages.ContainerEntryPage_add_button, /* */null,
+ CPathEntryMessages.ContainerEntryPage_edit_button, CPathEntryMessages.ContainerEntryPage_remove_button,
+ null, CPathEntryMessages.ContainerEntryPage_export_button };
ContainersAdapter adapter = new ContainersAdapter();
fContainersList = new TreeListDialogField<CPElement>(adapter, buttonLabels, new CPElementLabelProvider());
fContainersList.setDialogFieldListener(adapter);
- fContainersList.setLabelText(CPathEntryMessages.ContainerEntryPage_libraries_label);
+ fContainersList.setLabelText(CPathEntryMessages.ContainerEntryPage_libraries_label);
fContainersList.enableButton(IDX_REMOVE, false);
fContainersList.enableButton(IDX_EDIT, false);
@@ -116,7 +111,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
Composite composite = new Composite(parent, SWT.NONE);
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fContainersList}, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fContainersList }, true);
LayoutUtil.setHorizontalGrabbing(fContainersList.getTreeControl(null), true);
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
@@ -127,15 +122,16 @@ public class CPathContainerEntryPage extends CPathBasePage {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getChildren().length != 0;
+ return ((CPElementGroup) element).getChildren().length != 0;
}
return true;
}
});
setControl(composite);
-
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_CONTAINERS);
+
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite,
+ ICHelpContextIds.PROJECT_PATHS_CONTAINERS);
}
private class ContainersAdapter implements IDialogFieldListener, ITreeListAdapter<CPElement> {
@@ -166,9 +162,9 @@ public class CPathContainerEntryPage extends CPathBasePage {
@Override
public Object[] getChildren(TreeListDialogField<CPElement> field, Object element) {
if (element instanceof CPElement) {
- return ((CPElement)element).getChildren();
+ return ((CPElement) element).getChildren();
} else if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getChildren();
+ return ((CPElementGroup) element).getChildren();
}
return EMPTY_ARR;
}
@@ -176,9 +172,9 @@ public class CPathContainerEntryPage extends CPathBasePage {
@Override
public Object getParent(TreeListDialogField<CPElement> field, Object element) {
if (element instanceof CPElementAttribute) {
- return ((CPElementAttribute)element).getParent();
+ return ((CPElementAttribute) element).getParent();
} else if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getParent();
+ return ((CPElementGroup) element).getParent();
}
return null;
}
@@ -188,7 +184,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
if (element instanceof CPElementGroup) {
return true;
} else if (element instanceof CPElement) {
- return ((CPElement)element).getChildren().length != 0;
+ return ((CPElement) element).getChildren().length != 0;
}
return false;
@@ -205,22 +201,22 @@ public class CPathContainerEntryPage extends CPathBasePage {
void containerPageCustomButtonPressed(DialogField field, int index) {
CPElement[] containers = null;
switch (index) {
- case IDX_ADD :
- /* add container */
- containers = openContainerSelectionDialog(null);
- break;
- case IDX_EDIT :
- /* edit */
- editEntry();
- return;
- case IDX_REMOVE :
- /* remove */
- removeEntry();
- return;
- case IDX_EXPORT :
- /* export */
- exportEntry();
- return;
+ case IDX_ADD:
+ /* add container */
+ containers = openContainerSelectionDialog(null);
+ break;
+ case IDX_EDIT:
+ /* edit */
+ editEntry();
+ return;
+ case IDX_REMOVE:
+ /* remove */
+ removeEntry();
+ return;
+ case IDX_EXPORT:
+ /* export */
+ exportEntry();
+ return;
}
if (containers != null) {
int nElementsChosen = containers.length;
@@ -269,7 +265,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
for (int i = 0; i < selElements.size(); i++) {
Object elem = selElements.get(i);
if (elem instanceof CPElement) {
- CPElement curr = (CPElement)elem;
+ CPElement curr = (CPElement) elem;
if (curr.getParentContainer() != null) {
return false;
}
@@ -292,7 +288,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
for (int i = 0; i < selElements.size(); i++) {
Object elem = selElements.get(i);
if (elem instanceof CPElement) {
- CPElement curr = (CPElement)elem;
+ CPElement curr = (CPElement) elem;
if (curr.getParentContainer() != null) {
return false;
}
@@ -311,7 +307,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
for (int i = 0; i < selElements.size(); i++) {
Object elem = selElements.get(i);
if (elem instanceof CPElement) {
- ((CPElement)elem).setExported(! ((CPElement)elem).isExported()); // toggle export
+ ((CPElement) elem).setExported(!((CPElement) elem).isExported()); // toggle export
}
}
fContainersList.refresh();
@@ -327,32 +323,32 @@ public class CPathContainerEntryPage extends CPathBasePage {
}
Object elem = selElements.get(0);
if (fContainersList.getIndexOfElement(elem) != -1) {
- editElementEntry((CPElement)elem);
+ editElementEntry((CPElement) elem);
} else if (elem instanceof CPElementAttribute) {
- editAttributeEntry((CPElementAttribute)elem);
+ editAttributeEntry((CPElementAttribute) elem);
}
}
private void editAttributeEntry(CPElementAttribute elem) {
-// String key = elem.getKey();
-// if (key.equals(CPElement.SOURCEATTACHMENT)) {
-// CPElement selElement = elem.getParent();
-//
-// IPath containerPath = null;
-// boolean applyChanges = false;
-// Object parentContainer = selElement.getParentContainer();
-// if (parentContainer instanceof CPElement) {
-// containerPath = ((CPElement)parentContainer).getPath();
-// applyChanges = true;
-// }
-// SourceAttachmentDialog dialog = new SourceAttachmentDialog(getShell(), (ILibraryEntry)selElement.getPathEntry(), containerPath,
-// fCurrCProject, applyChanges);
-// if (dialog.open() == Window.OK) {
-// selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
-// fContainersList.refresh();
-// fCPathList.refresh(); // images
-// }
-// }
+ // String key = elem.getKey();
+ // if (key.equals(CPElement.SOURCEATTACHMENT)) {
+ // CPElement selElement = elem.getParent();
+ //
+ // IPath containerPath = null;
+ // boolean applyChanges = false;
+ // Object parentContainer = selElement.getParentContainer();
+ // if (parentContainer instanceof CPElement) {
+ // containerPath = ((CPElement)parentContainer).getPath();
+ // applyChanges = true;
+ // }
+ // SourceAttachmentDialog dialog = new SourceAttachmentDialog(getShell(), (ILibraryEntry)selElement.getPathEntry(), containerPath,
+ // fCurrCProject, applyChanges);
+ // if (dialog.open() == Window.OK) {
+ // selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
+ // fContainersList.refresh();
+ // fCPathList.refresh(); // images
+ // }
+ // }
}
private void editElementEntry(CPElement elem) {
@@ -380,8 +376,8 @@ public class CPathContainerEntryPage extends CPathBasePage {
}
Object elem = selElements.get(0);
if (elem instanceof CPElement) {
- CPElement curr = (CPElement)elem;
- return ! (curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
+ CPElement curr = (CPElement) elem;
+ return !(curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
}
if (elem instanceof CPElementAttribute) {
return true;
@@ -425,10 +421,10 @@ public class CPathContainerEntryPage extends CPathBasePage {
IContainerEntry elem = null;
String title;
if (existing == null) {
- title = CPathEntryMessages.ContainerEntryPage_ContainerDialog_new_title;
+ title = CPathEntryMessages.ContainerEntryPage_ContainerDialog_new_title;
} else {
- title = CPathEntryMessages.ContainerEntryPage_ContainerDialog_edit_title;
- elem = (IContainerEntry)existing.getPathEntry();
+ title = CPathEntryMessages.ContainerEntryPage_ContainerDialog_edit_title;
+ elem = (IContainerEntry) existing.getPathEntry();
}
CPathContainerWizard wizard = new CPathContainerWizard(elem, fCurrCProject, getRawClasspath());
wizard.setWindowTitle(title);
@@ -456,7 +452,7 @@ public class CPathContainerEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java
index 9d9fe3fa6dd..049482349a1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java
@@ -38,16 +38,15 @@ import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
public class CPathContainerSelectionPage extends WizardPage {
- private static final String DIALOGSTORE_SECTION= "CPathContainerSelectionPage"; //$NON-NLS-1$
- private static final String DIALOGSTORE_CONTAINER_IDX= "index"; //$NON-NLS-1$
-
+ private static final String DIALOGSTORE_SECTION = "CPathContainerSelectionPage"; //$NON-NLS-1$
+ private static final String DIALOGSTORE_CONTAINER_IDX = "index"; //$NON-NLS-1$
private static class CPathContainerLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
return ((IContainerDescriptor) element).getName();
}
-
+
@Override
public Image getImage(Object element) {
return ((IContainerDescriptor) element).getImage();
@@ -55,10 +54,10 @@ public class CPathContainerSelectionPage extends WizardPage {
}
private static class CPathContainerSorter extends ViewerSorter {
-
+
@Override
public int category(Object element) {
- if ( element instanceof ProjectContainerDescriptor) {
+ if (element instanceof ProjectContainerDescriptor) {
return 0;
}
return 1;
@@ -75,16 +74,16 @@ public class CPathContainerSelectionPage extends WizardPage {
*/
protected CPathContainerSelectionPage(IContainerDescriptor[] containerPages) {
super("CPathContainerWizardPage"); //$NON-NLS-1$
- setTitle(CPathEntryMessages.CPathContainerSelectionPage_title);
- setDescription(CPathEntryMessages.CPathContainerSelectionPage_description);
+ setTitle(CPathEntryMessages.CPathContainerSelectionPage_title);
+ setDescription(CPathEntryMessages.CPathContainerSelectionPage_description);
setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
- fContainers= containerPages;
+ fContainers = containerPages;
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
- fDialogSettings= settings.getSection(DIALOGSTORE_SECTION);
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
+ fDialogSettings = settings.getSection(DIALOGSTORE_SECTION);
if (fDialogSettings == null) {
- fDialogSettings= settings.addNewSection(DIALOGSTORE_SECTION);
+ fDialogSettings = settings.addNewSection(DIALOGSTORE_SECTION);
fDialogSettings.put(DIALOGSTORE_CONTAINER_IDX, 0);
}
validatePage();
@@ -95,7 +94,7 @@ public class CPathContainerSelectionPage extends WizardPage {
*/
@Override
public void createControl(Composite parent) {
- fListViewer= new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
+ fListViewer = new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
fListViewer.setLabelProvider(new CPathContainerLabelProvider());
fListViewer.setContentProvider(new ListContentProvider());
fListViewer.setSorter(new CPathContainerSorter());
@@ -111,11 +110,11 @@ public class CPathContainerSelectionPage extends WizardPage {
public void doubleClick(DoubleClickEvent event) {
doDoubleClick();
}
- });
-
- int selectionIndex= fDialogSettings.getInt(DIALOGSTORE_CONTAINER_IDX);
+ });
+
+ int selectionIndex = fDialogSettings.getInt(DIALOGSTORE_CONTAINER_IDX);
if (selectionIndex >= fContainers.length) {
- selectionIndex= 0;
+ selectionIndex = 0;
}
fListViewer.getTable().select(selectionIndex);
validatePage();
@@ -130,24 +129,23 @@ public class CPathContainerSelectionPage extends WizardPage {
setPageComplete(getSelected() != null);
}
-
public IContainerDescriptor getSelected() {
if (fListViewer != null) {
- ISelection selection= fListViewer.getSelection();
+ ISelection selection = fListViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
- if (ss.size() == 1)
+ if (ss.size() == 1)
return (IContainerDescriptor) ss.getFirstElement();
}
}
return null;
}
-
+
protected void doDoubleClick() {
if (canFlipToNextPage()) {
getContainer().showPage(getNextPage());
}
- }
+ }
/* (non-Javadoc)
* @see IWizardPage#canFlipToNextPage()
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.java
index c097aff7c25..24ed0484d79 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.java
@@ -91,7 +91,7 @@ public class CPathContainerWizard extends Wizard {
/*
* (non-Javadoc)
- *
+ *
* @see IWizard#performFinish()
*/
@Override
@@ -99,7 +99,7 @@ public class CPathContainerWizard extends Wizard {
if (fContainerPage != null) {
if (fContainerPage.finish()) {
if (fContainerPage instanceof ProjectContainerPage) {
- fProjectEntry = ((ProjectContainerPage)fContainerPage).getProjectEntry();
+ fProjectEntry = ((ProjectContainerPage) fContainerPage).getProjectEntry();
} else {
fContainerEntries = fContainerPage.getNewContainers();
}
@@ -114,7 +114,7 @@ public class CPathContainerWizard extends Wizard {
/*
* (non-Javadoc)
- *
+ *
* @see IWizard#addPages()
*/
@Override
@@ -129,8 +129,7 @@ public class CPathContainerWizard extends Wizard {
if (fFilterType != null) {
allContainers.add(0, new ProjectContainerDescriptor(fFilterType));
}
- fSelectionWizardPage = new CPathContainerSelectionPage(
- allContainers.toArray(new IContainerDescriptor[0]));
+ fSelectionWizardPage = new CPathContainerSelectionPage(allContainers.toArray(new IContainerDescriptor[0]));
addPage(fSelectionWizardPage);
// add as dummy, will not be shown
@@ -171,7 +170,7 @@ public class CPathContainerWizard extends Wizard {
/*
* (non-Javadoc)
- *
+ *
* @see IWizard#getNextPage(IWizardPage)
*/
@Override
@@ -186,7 +185,7 @@ public class CPathContainerWizard extends Wizard {
&& fContainerPage.getNewContainers()[0] != null) {
IPathEntry entry;
if (fContainerPage instanceof ProjectContainerPage) {
- entry = ((ProjectContainerPage)fContainerPage).getProjectEntry();
+ entry = ((ProjectContainerPage) fContainerPage).getProjectEntry();
} else {
entry = fContainerPage.getNewContainers()[0];
}
@@ -198,8 +197,8 @@ public class CPathContainerWizard extends Wizard {
}
private void handlePageCreationFailed(CoreException e) {
- String title = CPathEntryMessages.CPathContainerWizard_pagecreationerror_title;
- String message = CPathEntryMessages.CPathContainerWizard_pagecreationerror_message;
+ String title = CPathEntryMessages.CPathContainerWizard_pagecreationerror_title;
+ String message = CPathEntryMessages.CPathContainerWizard_pagecreationerror_message;
ExceptionHandler.handle(e, getShell(), title, message);
}
@@ -214,7 +213,7 @@ public class CPathContainerWizard extends Wizard {
/*
* (non-Javadoc)
- *
+ *
* @see IWizard#canFinish()
*/
@Override
@@ -237,7 +236,8 @@ public class CPathContainerWizard extends Wizard {
public static int openWizard(Shell shell, CPathContainerWizard wizard) {
WizardDialog dialog = new WizardDialog(shell, wizard);
PixelConverter converter = new PixelConverter(shell);
- dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
+ dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70),
+ converter.convertHeightInCharsToPixels(20));
dialog.create();
return dialog.open();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.java
index 159a0c1fc7e..d0d970f1c9b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.java
@@ -50,13 +50,13 @@ public class CPathFilterPage extends WizardPage {
private List<IPathEntry> fPaths;
private List<?> fExclusions;
private ViewerFilter filter;
-
+
protected ICElement fCElement;
protected CPathFilterPage(ICElement cElement, int[] filterType) {
super("CPathFilterPage"); //$NON-NLS-1$
- setTitle(CPathEntryMessages.CPathFilterPage_title);
- setDescription(CPathEntryMessages.CPathFilterPage_description);
+ setTitle(CPathEntryMessages.CPathFilterPage_title);
+ setDescription(CPathEntryMessages.CPathFilterPage_description);
setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
fFilterType = filterType;
fCElement = cElement;
@@ -70,7 +70,7 @@ public class CPathFilterPage extends WizardPage {
layout.numColumns = 2;
container.setLayout(layout);
Label label = new Label(container, SWT.NULL);
- label.setText(CPathEntryMessages.CPathFilterPage_label);
+ label.setText(CPathEntryMessages.CPathFilterPage_label);
GridData gd = new GridData();
gd.horizontalSpan = 2;
label.setLayoutData(gd);
@@ -113,7 +113,8 @@ public class CPathFilterPage extends WizardPage {
}
} else if (fParentEntry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
try {
- IPathEntryContainer container = CoreModel.getPathEntryContainer(fParentEntry.getPath(), fCElement.getCProject());
+ IPathEntryContainer container = CoreModel.getPathEntryContainer(fParentEntry.getPath(),
+ fCElement.getCProject());
if (container != null) {
fPaths = Arrays.asList(container.getPathEntries());
}
@@ -123,7 +124,6 @@ public class CPathFilterPage extends WizardPage {
createExlusions(fParentEntry.getEntryKind() == IPathEntry.CDT_PROJECT);
}
-
private void createExlusions(boolean showExported) {
fExclusions = new ArrayList<Object>();
if (filter != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.java
index f4fe80c3179..6893dc0d7bf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.java
@@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import org.eclipse.jface.wizard.Wizard;
-
/**
* @deprecated as of CDT 4.0. This class does not seem to be used,
* probably remnant of 3.X style projects or earlier.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryBasePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryBasePage.java
index e770f736038..e40be2184bc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryBasePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryBasePage.java
@@ -24,14 +24,15 @@ import org.eclipse.cdt.core.model.ICElement;
*/
public abstract class CPathIncludeSymbolEntryBasePage extends CPathBasePage {
- public CPathIncludeSymbolEntryBasePage(String title) {
- super(title);
- }
+ public CPathIncludeSymbolEntryBasePage(String title) {
+ super(title);
+ }
- public CPathIncludeSymbolEntryBasePage(String title, ImageDescriptor image) {
- super(title, image);
- }
+ public CPathIncludeSymbolEntryBasePage(String title, ImageDescriptor image) {
+ super(title, image);
+ }
- public abstract void init(ICElement cElement, List<CPElement> cPaths);
- public abstract List<CPElement> getCPaths();
+ public abstract void init(ICElement cElement, List<CPElement> cPaths);
+
+ public abstract List<CPElement> getCPaths();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java
index 427e9a2f7fd..e0e6a5b3da7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java
@@ -92,24 +92,16 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
private final int IDX_UP = 14;
private final int IDX_DOWN = 15;
- private static final String[] buttonLabel = new String[]{
-
- CPathEntryMessages.IncludeSymbolEntryPage_addFolderFile,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_addUserSymbol,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_addExternalInclude,
- CPathEntryMessages.IncludeSymbolEntryPage_addFromWorkspace,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_addContributed,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_edit,
- CPathEntryMessages.IncludeSymbolEntryPage_remove,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_export,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_up,
- CPathEntryMessages.IncludeSymbolEntryPage_down};
+ private static final String[] buttonLabel = new String[] {
+
+ CPathEntryMessages.IncludeSymbolEntryPage_addFolderFile, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_addUserSymbol, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_addExternalInclude,
+ CPathEntryMessages.IncludeSymbolEntryPage_addFromWorkspace, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_addContributed, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_edit, CPathEntryMessages.IncludeSymbolEntryPage_remove, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_export, null, CPathEntryMessages.IncludeSymbolEntryPage_up,
+ CPathEntryMessages.IncludeSymbolEntryPage_down };
private CPElementGroup fTopGroup;
private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter<CPElementGroup> {
@@ -139,9 +131,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
@Override
public Object[] getChildren(TreeListDialogField<CPElementGroup> field, Object element) {
if (element instanceof CPElement) {
- return ((CPElement)element).getChildren();
+ return ((CPElement) element).getChildren();
} else if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getChildren();
+ return ((CPElementGroup) element).getChildren();
}
return EMPTY_ARR;
}
@@ -149,9 +141,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
@Override
public Object getParent(TreeListDialogField<CPElementGroup> field, Object element) {
if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getParent();
+ return ((CPElementGroup) element).getParent();
} else if (element instanceof CPElement) {
- return ((CPElement)element).getParent();
+ return ((CPElement) element).getParent();
}
return null;
}
@@ -162,7 +154,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
return true;
}
if (element instanceof CPElement) {
- return ((CPElement)element).getChildren().length > 0;
+ return ((CPElement) element).getChildren().length > 0;
}
return false;
}
@@ -177,17 +169,18 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
public CPathIncludeSymbolEntryPage(IStatusChangeListener context) {
- super(CPathEntryMessages.IncludeSymbolEntryPage_title);
+ super(CPathEntryMessages.IncludeSymbolEntryPage_title);
fContext = context;
IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
- fIncludeSymPathsList = new TreeListDialogField<CPElementGroup>(adapter, buttonLabel, new CPElementLabelProvider(true, false)) {
+ fIncludeSymPathsList = new TreeListDialogField<CPElementGroup>(adapter, buttonLabel,
+ new CPElementLabelProvider(true, false)) {
@Override
protected int getTreeStyle() {
return super.getTreeStyle() & ~SWT.MULTI;
}
};
- fIncludeSymPathsList.setLabelText(CPathEntryMessages.IncludeSymbolEntryPage_label);
+ fIncludeSymPathsList.setLabelText(CPathEntryMessages.IncludeSymbolEntryPage_label);
fIncludeSymPathsList.enableButton(IDX_REMOVE, false);
fIncludeSymPathsList.enableButton(IDX_EDIT, false);
fIncludeSymPathsList.enableButton(IDX_ADD_CONTRIBUTED, true);
@@ -200,11 +193,11 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
fIncludeSymPathsList.setTreeExpansionLevel(2);
fShowInheritedPaths = new SelectionButtonDialogField(SWT.CHECK);
fShowInheritedPaths.setSelection(true);
- fShowInheritedPaths.setLabelText(CPathEntryMessages.IncludeSymbolsEntryPage_show_inherited_check);
+ fShowInheritedPaths.setLabelText(CPathEntryMessages.IncludeSymbolsEntryPage_show_inherited_check);
fShowInheritedPaths.setDialogFieldListener(adapter);
- fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER}, false,
- true);
+ fFilter = new CPElementFilter(
+ new int[] { -1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER }, false, true);
}
@Override
@@ -214,14 +207,15 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fIncludeSymPathsList, fShowInheritedPaths }, true);
LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null), true);
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
setControl(composite);
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INCLUDE_PATHS_SYMBOLS);
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite,
+ ICHelpContextIds.PROJECT_INCLUDE_PATHS_SYMBOLS);
}
@Override
@@ -256,9 +250,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
if (nErrorEntries == 1 && entryError != null) {
status = entryError.getStatus();
} else {
- status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, NLS.bind(
- CPathEntryMessages.CPElement_status_multiplePathErrors,
- String.valueOf(nErrorEntries)), null);
+ status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ NLS.bind(CPathEntryMessages.CPElement_status_multiplePathErrors, String.valueOf(nErrorEntries)),
+ null);
}
}
fContext.statusChanged(status);
@@ -271,9 +265,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
CPElement element = null;
if (selected.get(0) instanceof CPElement) {
- element = (CPElement)selected.get(0);
+ element = (CPElement) selected.get(0);
} else if (selected.get(0) instanceof CPElementAttribute) {
- element = ((CPElementAttribute)selected.get(0)).getParent();
+ element = ((CPElementAttribute) selected.get(0)).getParent();
}
if (element != null && element.getStatus().getSeverity() != IStatus.OK) {
fContext.statusChanged(element.getStatus());
@@ -282,45 +276,45 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
return;
}
}
-
+
private List<CPElementGroup> createGroups(ICElement element, List<?> cPaths) {
// create resource groups
List<CPElementGroup> resourceGroups = new ArrayList<CPElementGroup>(5);
fTopGroup = new CPElementGroup(element.getResource());
resourceGroups.add(fTopGroup);
- // add containers first so that they appear at top of list
+ // add containers first so that they appear at top of list
for (int i = 0; i < cPaths.size(); i++) {
- CPElement cpelement = (CPElement)cPaths.get(i);
+ CPElement cpelement = (CPElement) cPaths.get(i);
switch (cpelement.getEntryKind()) {
- case IPathEntry.CDT_CONTAINER :
- fTopGroup.addChild(cpelement);
- break;
+ case IPathEntry.CDT_CONTAINER:
+ fTopGroup.addChild(cpelement);
+ break;
}
}
for (int i = 0; i < cPaths.size(); i++) {
- CPElement cpelement = (CPElement)cPaths.get(i);
+ CPElement cpelement = (CPElement) cPaths.get(i);
switch (cpelement.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- case IPathEntry.CDT_MACRO :
- CPElementGroup resGroup = new CPElementGroup(cpelement.getResource());
- int ndx = resourceGroups.indexOf(resGroup);
- if (ndx == -1) {
- resourceGroups.add(resGroup);
- } else {
- resGroup = resourceGroups.get(ndx);
- }
- resGroup.addChild(cpelement);
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_MACRO:
+ CPElementGroup resGroup = new CPElementGroup(cpelement.getResource());
+ int ndx = resourceGroups.indexOf(resGroup);
+ if (ndx == -1) {
+ resourceGroups.add(resGroup);
+ } else {
+ resGroup = resourceGroups.get(ndx);
+ }
+ resGroup.addChild(cpelement);
}
}
// place each path in its appropriate inherited group (or not if
// excluded)
for (int i = 0; i < cPaths.size(); i++) {
- CPElement cpelement = (CPElement)cPaths.get(i);
+ CPElement cpelement = (CPElement) cPaths.get(i);
switch (cpelement.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- case IPathEntry.CDT_MACRO :
- addPathToResourceGroups(cpelement, null, resourceGroups);
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_MACRO:
+ addPathToResourceGroups(cpelement, null, resourceGroups);
}
}
return resourceGroups;
@@ -328,7 +322,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
private void addPathToResourceGroup(CPElement element, CPElementGroup parent, CPElementGroup group) {
IPath resPath = element.getPath();
- IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
+ IPath[] exclusions = (IPath[]) element.getAttribute(CPElement.EXCLUSION);
if ((group != parent || !group.getResource().equals(element.getResource()))
&& resPath.isPrefixOf(group.getPath())
&& (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
@@ -368,7 +362,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
private void updatePathOnResourceGroups(CPElement element, List<CPElementGroup> groups) {
CPElementGroup parent = element.getParent();
IPath resPath = element.getPath();
- IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
+ IPath[] exclusions = (IPath[]) element.getAttribute(CPElement.EXCLUSION);
for (int i = 0; i < groups.size(); i++) {
CPElementGroup group = groups.get(i);
if (group != parent) {
@@ -377,8 +371,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
for (CPElement element2 : elements) {
if (element2.getInherited() == element) {
found = true;
- if (!CoreModelUtil.isExcludedPath(group.getResource().getFullPath().removeFirstSegments(
- resPath.segmentCount()), exclusions)) {
+ if (!CoreModelUtil.isExcludedPath(
+ group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()),
+ exclusions)) {
group.replaceChild(element2, new CPElement(element, group.getPath(), group.getResource()));
} else {
group.removeChild(element2);
@@ -399,7 +394,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
resGroup.removeChild(element);
if (Inherited != null) { // applied exclusion to orig.
IPath exclude = element.getPath().removeFirstSegments(Inherited.getPath().segmentCount());
- IPath[] exclusions = (IPath[])Inherited.getAttribute(CPElement.EXCLUSION);
+ IPath[] exclusions = (IPath[]) Inherited.getAttribute(CPElement.EXCLUSION);
IPath[] newExlusions = new IPath[exclusions.length + 1];
System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
newExlusions[exclusions.length] = exclude;
@@ -434,14 +429,15 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
Object elem = selected.get(0);
if (elem instanceof CPElement) {
- CPElement element = (CPElement)elem;
+ CPElement element = (CPElement) elem;
if (element.getParentContainer() == null) {
- return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
+ return element.getEntryKind() == IPathEntry.CDT_INCLUDE
+ || element.getEntryKind() == IPathEntry.CDT_MACRO;
}
} else if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib = (CPElementAttribute)elem;
+ CPElementAttribute attrib = (CPElementAttribute) elem;
if (attrib.getKey().equals(CPElement.EXCLUSION)) {
- if (((IPath[])attrib.getValue()).length > 0) {
+ if (((IPath[]) attrib.getValue()).length > 0) {
return true;
}
}
@@ -453,7 +449,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
List<?> selected = getSelection();
Object elem = selected.get(0);
if (elem instanceof CPElement) {
- CPElement element = (CPElement)elem;
+ CPElement element = (CPElement) elem;
CPElementGroup parent = element.getParent();
if (removePathFromResourceGroups(element, fIncludeSymPathsList.getElements()) == null) {
updatePathOnResourceGroups(element.getInherited(), fIncludeSymPathsList.getElements());
@@ -461,7 +457,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
fIncludeSymPathsList.refresh();
fIncludeSymPathsList.selectElements(new StructuredSelection(parent));
} else if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib = (CPElementAttribute)elem;
+ CPElementAttribute attrib = (CPElementAttribute) elem;
String key = attrib.getKey();
Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
attrib.getParent().setAttribute(key, value);
@@ -477,13 +473,14 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
Object elem = selected.get(0);
if (elem instanceof CPElement) {
- CPElement element = (CPElement)selected.get(0);
+ CPElement element = (CPElement) selected.get(0);
if (element.getParentContainer() == null && element.getInherited() == null) {
- IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
+ IPath path = (IPath) element.getAttribute(CPElement.BASE_REF);
if (path != null && !path.equals(Path.EMPTY)) {
return false;
}
- return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO
+ return element.getEntryKind() == IPathEntry.CDT_INCLUDE
+ || element.getEntryKind() == IPathEntry.CDT_MACRO
|| element.getEntryKind() == IPathEntry.CDT_CONTAINER;
}
}
@@ -501,20 +498,20 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
Object element = selElements.get(0);
if (element instanceof CPElement) {
- editElementEntry((CPElement)element);
+ editElementEntry((CPElement) element);
} else if (element instanceof CPElementAttribute) {
- editAttributeEntry((CPElementAttribute)element);
+ editAttributeEntry((CPElementAttribute) element);
}
}
private void editElementEntry(CPElement element) {
- IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
+ IPath path = (IPath) element.getAttribute(CPElement.BASE_REF);
if (path != null && !path.equals(Path.EMPTY)) {
return;
} else if (element.getEntryKind() == IPathEntry.CDT_MACRO) {
addSymbol(element);
} else if (element.getEntryKind() == IPathEntry.CDT_INCLUDE) {
- path = (IPath)element.getAttribute(CPElement.BASE);
+ path = (IPath) element.getAttribute(CPElement.BASE);
if (path != null && !path.equals(Path.EMPTY)) {
CPElement[] includes = openWorkspacePathEntryDialog(null);
if (includes != null && includes.length > 0) {
@@ -552,7 +549,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
private void exportEntry() {
- CPElement element = (CPElement)getSelection().get(0);
+ CPElement element = (CPElement) getSelection().get(0);
element.setExported(!element.isExported()); // toggle
fIncludeSymPathsList.refresh(element);
}
@@ -563,12 +560,13 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
Object elem = selected.get(0);
if (elem instanceof CPElement) {
- CPElement element = (CPElement)selected.get(0);
+ CPElement element = (CPElement) selected.get(0);
if (element.getParentContainer() == null && element.getInherited() == null) {
- IPath base_ref = (IPath)element.getAttribute(CPElement.BASE_REF);
+ IPath base_ref = (IPath) element.getAttribute(CPElement.BASE_REF);
if (base_ref != null && !base_ref.equals(Path.EMPTY))
return false;
- return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
+ return element.getEntryKind() == IPathEntry.CDT_INCLUDE
+ || element.getEntryKind() == IPathEntry.CDT_MACRO;
}
}
return false;
@@ -580,9 +578,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
for (int i = 0; i < selected.size(); i++) {
Object element = selected.get(i);
- if (! (element instanceof CPElement))
+ if (!(element instanceof CPElement))
return false;
- CPElement elem = (CPElement)element;
+ CPElement elem = (CPElement) element;
if (elem.getEntryKind() != IPathEntry.CDT_INCLUDE && elem.getEntryKind() != IPathEntry.CDT_MACRO) {
return false;
}
@@ -597,7 +595,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
if (!canMove(selected)) {
return false;
}
- CPElement first = (CPElement)selected.get(0);
+ CPElement first = (CPElement) selected.get(0);
CPElementGroup parent = first.getParent();
CPElement children[] = parent.getChildren(first.getEntryKind());
int indx = Arrays.asList(children).indexOf(first);
@@ -611,7 +609,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
if (!canMove(selected)) {
return false;
}
- CPElement last = (CPElement)selected.get(selected.size() - 1);
+ CPElement last = (CPElement) selected.get(selected.size() - 1);
CPElementGroup parent = last.getParent();
CPElement children[] = parent.getChildren(last.getEntryKind());
int indx = Arrays.asList(children).indexOf(last);
@@ -651,7 +649,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
/**
- *
+ *
*/
private boolean moveDown(CPElement element) {
boolean rc = false;
@@ -684,10 +682,10 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
if (!selected.isEmpty()) {
Object item = selected.get(0);
if (item instanceof CPElement) {
- item = ((CPElement)item).getParent();
+ item = ((CPElement) item).getParent();
}
if (item instanceof CPElementGroup) {
- return (CPElementGroup)item;
+ return (CPElementGroup) item;
}
}
return fTopGroup;
@@ -699,8 +697,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
if (fFilter != null) {
fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
}
- fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
- false, showInherited);
+ fFilter = new CPElementFilter(
+ new int[] { -1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER }, false,
+ showInherited);
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
fIncludeSymPathsList.refresh();
}
@@ -723,45 +722,45 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
protected void ListCustomButtonPressed(TreeListDialogField<?> field, int index) {
switch (index) {
- case IDX_ADD_FOLDER_FILE :
- addNewPathResource();
- break;
- case IDX_ADD_SYMBOL :
- addSymbol(null);
- break;
- case IDX_ADD_EXT_INCLUDE :
- addInclude(null);
- break;
- case IDX_ADD_WS_INCLUDE :
- addFromWorkspace();
- break;
- case IDX_ADD_CONTRIBUTED :
- addContributed();
- break;
- case IDX_EDIT :
- if (canEdit(field.getSelectedElements())) {
- editEntry();
- }
- break;
- case IDX_REMOVE :
- if (canRemove(field.getSelectedElements())) {
- removeEntry();
- }
- break;
- case IDX_DOWN :
- if (canMoveDown(field.getSelectedElements())) {
- moveDown((CPElement)field.getSelectedElements().get(0));
- }
- break;
- case IDX_UP :
- if (canMoveUp(field.getSelectedElements())) {
- moveUp((CPElement)field.getSelectedElements().get(0));
- }
- break;
- case IDX_EXPORT :
- if (canExport(field.getSelectedElements())) {
- exportEntry();
- }
+ case IDX_ADD_FOLDER_FILE:
+ addNewPathResource();
+ break;
+ case IDX_ADD_SYMBOL:
+ addSymbol(null);
+ break;
+ case IDX_ADD_EXT_INCLUDE:
+ addInclude(null);
+ break;
+ case IDX_ADD_WS_INCLUDE:
+ addFromWorkspace();
+ break;
+ case IDX_ADD_CONTRIBUTED:
+ addContributed();
+ break;
+ case IDX_EDIT:
+ if (canEdit(field.getSelectedElements())) {
+ editEntry();
+ }
+ break;
+ case IDX_REMOVE:
+ if (canRemove(field.getSelectedElements())) {
+ removeEntry();
+ }
+ break;
+ case IDX_DOWN:
+ if (canMoveDown(field.getSelectedElements())) {
+ moveDown((CPElement) field.getSelectedElements().get(0));
+ }
+ break;
+ case IDX_UP:
+ if (canMoveUp(field.getSelectedElements())) {
+ moveUp((CPElement) field.getSelectedElements().get(0));
+ }
+ break;
+ case IDX_EXPORT:
+ if (canExport(field.getSelectedElements())) {
+ exportEntry();
+ }
}
}
@@ -794,12 +793,12 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
protected void addNewPathResource() {
- Class<?>[] acceptedClasses = new Class[]{ICProject.class, ICContainer.class, ITranslationUnit.class};
+ Class<?>[] acceptedClasses = new Class[] { ICProject.class, ICContainer.class, ITranslationUnit.class };
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
- String title = CPathEntryMessages.IncludeSymbolEntryPage_newResource_title;
- String message = CPathEntryMessages.IncludeSymbolEntryPage_newResource_description;
+ String title = CPathEntryMessages.IncludeSymbolEntryPage_newResource_title;
+ String message = CPathEntryMessages.IncludeSymbolEntryPage_newResource_description;
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
new CElementContentProvider());
@@ -814,9 +813,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
Object[] elements = dialog.getResult();
IResource resource;
if (elements[0] instanceof IResource) {
- resource = (IResource)elements[0];
+ resource = (IResource) elements[0];
} else {
- resource = ((ICElement)elements[0]).getResource();
+ resource = ((ICElement) elements[0]).getResource();
}
CPElementGroup newGroup = new CPElementGroup(resource);
if (!fIncludeSymPathsList.getElements().contains(newGroup)) {
@@ -828,9 +827,9 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
for (CPElement cpelement : cpelements) {
if (cpelement.getInherited() == null) {
switch (cpelement.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- case IPathEntry.CDT_MACRO :
- addPathToResourceGroup(cpelement, null, newGroup);
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_MACRO:
+ addPathToResourceGroup(cpelement, null, newGroup);
}
}
}
@@ -847,17 +846,16 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
// Popup an entry dialog
InputDialog dialog;
if (existing == null) {
- dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_title,
- CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_message, "", //$NON-NLS-1$
+ dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_title,
+ CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_message, "", //$NON-NLS-1$
null);
} else {
StringBuilder initialValue = new StringBuilder();
- initialValue.append((String)existing.getAttribute(CPElement.MACRO_NAME));
+ initialValue.append((String) existing.getAttribute(CPElement.MACRO_NAME));
initialValue.append('=');
- initialValue.append((String)existing.getAttribute(CPElement.MACRO_VALUE));
- dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_title,
- CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_message, initialValue.toString(),
- null);
+ initialValue.append((String) existing.getAttribute(CPElement.MACRO_VALUE));
+ dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_title,
+ CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_message, initialValue.toString(), null);
}
String symbol = null;
@@ -865,8 +863,8 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
symbol = dialog.getValue();
if (symbol != null && symbol.length() > 0) {
CPElementGroup group = getSelectedGroup();
- CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
- group.getResource());
+ CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO,
+ group.getResource().getFullPath(), group.getResource());
String name, value = ""; //$NON-NLS-1$
int index = symbol.indexOf("="); //$NON-NLS-1$
if (index != -1) {
@@ -897,14 +895,12 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
protected void addInclude(CPElement existing) {
InputDialog dialog;
if (existing == null) {
- dialog = new SelectPathInputDialog(getShell(),
- CPathEntryMessages.IncludeSymbolEntryPage_addExternal_title,
- CPathEntryMessages.IncludeSymbolEntryPage_addExternal_message, null, null);
+ dialog = new SelectPathInputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_addExternal_title,
+ CPathEntryMessages.IncludeSymbolEntryPage_addExternal_message, null, null);
} else {
- dialog = new SelectPathInputDialog(
- getShell(),
- CPathEntryMessages.IncludeSymbolEntryPage_editExternal_title,
- CPathEntryMessages.IncludeSymbolEntryPage_editExternal_message, ((IPath)existing.getAttribute(CPElement.INCLUDE)).toOSString(), null);
+ dialog = new SelectPathInputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_editExternal_title,
+ CPathEntryMessages.IncludeSymbolEntryPage_editExternal_message,
+ ((IPath) existing.getAttribute(CPElement.INCLUDE)).toOSString(), null);
}
String newItem = null;
if (dialog.open() == Window.OK) {
@@ -912,8 +908,8 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
if (newItem != null && !newItem.isEmpty()) {
if (existing == null) {
CPElementGroup group = getSelectedGroup();
- CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
- group.getResource());
+ CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE,
+ group.getResource().getFullPath(), group.getResource());
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
if (!group.contains(newPath)) {
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
@@ -967,15 +963,17 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
}
protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
- Class<?>[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
- TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
+ Class<?>[] acceptedClasses = new Class[] { ICProject.class, IProject.class, IContainer.class,
+ ICContainer.class };
+ TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses,
+ existing == null);
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
String title = (existing == null) ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_title
- : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title;
+ : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title;
String message = (existing == null)
? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_description
- : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description;
+ : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description;
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
new CElementContentProvider());
@@ -997,11 +995,11 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
IProject project;
IPath includePath;
if (elements[i] instanceof IResource) {
- project = ((IResource)elements[i]).getProject();
- includePath = ((IResource)elements[i]).getProjectRelativePath();
+ project = ((IResource) elements[i]).getProject();
+ includePath = ((IResource) elements[i]).getProjectRelativePath();
} else {
- project = ((ICElement)elements[i]).getCProject().getProject();
- includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
+ project = ((ICElement) elements[i]).getCProject().getProject();
+ includePath = ((ICElement) elements[i]).getResource().getProjectRelativePath();
}
CPElementGroup group = getSelectedGroup();
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
@@ -1018,13 +1016,13 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
IContainerEntry elem = null;
String title;
if (existing == null) {
- title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_new_title;
+ title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_new_title;
} else {
- title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_edit_title;
- elem = (IContainerEntry)existing.getPathEntry();
+ title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_edit_title;
+ elem = (IContainerEntry) existing.getPathEntry();
}
- CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(), new int[]{
- IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO});
+ CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(),
+ new int[] { IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO });
wizard.setWindowTitle(title);
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
IPathEntry parent = wizard.getEntriesParent();
@@ -1037,18 +1035,18 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
if (elements[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
group.getResource());
- res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry)elements[i]).getIncludePath());
+ res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry) elements[i]).getIncludePath());
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
} else if (elements[i].getEntryKind() == IPathEntry.CDT_MACRO) {
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
group.getResource());
- res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
+ res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry) elements[i]).getMacroName());
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
}
}
return res;
}
- return new CPElement[]{CPElement.createFromExisting(parent, fCurrCProject)};
+ return new CPElement[] { CPElement.createFromExisting(parent, fCurrCProject) };
}
return null;
}
@@ -1063,15 +1061,14 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
- Button browse = createButton(parent, 3,
- CPathEntryMessages.IncludeSymbolEntryPage_addExternal_button_browse,
+ Button browse = createButton(parent, 3, CPathEntryMessages.IncludeSymbolEntryPage_addExternal_button_browse,
false);
browse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
- dialog.setText(CPathEntryMessages.IncludeSymbolEntryPage_browseForFolder);
+ dialog.setText(CPathEntryMessages.IncludeSymbolEntryPage_browseForFolder);
String currentName = getText().getText();
if (currentName != null && currentName.trim().length() != 0) {
dialog.setFilterPath(currentName);
@@ -1088,7 +1085,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#getSelection()
*/
@Override
@@ -1098,7 +1095,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#setSelection(java.util.List)
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java
index 63931b7edbb..1cf26dc7bc7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java
@@ -77,1120 +77,1114 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
*/
public class CPathIncludeSymbolEntryPerFilePage extends CPathIncludeSymbolEntryBasePage {
- private TreeListDialogField<CPElementGroup> fIncludeSymPathsList;
- private SelectionButtonDialogField fShowInheritedPaths;
- private ICElement fCurrCElement;
- private ICProject fCurrCProject;
- private CPElementFilter fFilter;
- private IStatusChangeListener fContext;
- private int fTreeExpansionLevel = 2;
-
- private final int IDX_ADD_FOLDER_FILE = 0;
- private final int IDX_ADD_SYMBOL = 2;
- private final int IDX_ADD_EXT_INCLUDE = 4;
- private final int IDX_ADD_WS_INCLUDE = 5;
- private final int IDX_ADD_CONTRIBUTED = 7;
- private final int IDX_EDIT = 9;
- private final int IDX_REMOVE = 10;
- private final int IDX_EXPORT = 12;
- private final int IDX_UP = 14;
- private final int IDX_DOWN = 15;
-
- private static final String[] buttonLabel = new String[]{
-
- CPathEntryMessages.IncludeSymbolEntryPage_addFolderFile,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_addUserSymbol,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_addExternalInclude,
- CPathEntryMessages.IncludeSymbolEntryPage_addFromWorkspace,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_addContributed,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_edit,
- CPathEntryMessages.IncludeSymbolEntryPage_remove,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_export,
- null,
- CPathEntryMessages.IncludeSymbolEntryPage_up,
- CPathEntryMessages.IncludeSymbolEntryPage_down};
- private CPElementGroup fTopGroup;
-
- /**
- * Per file specific CPElementFilter
- *
- * @author vhirsl
- */
- private class CPElementPerFileFilter extends CPElementFilter {
-
- public CPElementPerFileFilter(int[] kind, boolean exportedOnly, boolean showInherited) {
- super(kind, exportedOnly, showInherited);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPElementFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
+ private TreeListDialogField<CPElementGroup> fIncludeSymPathsList;
+ private SelectionButtonDialogField fShowInheritedPaths;
+ private ICElement fCurrCElement;
+ private ICProject fCurrCProject;
+ private CPElementFilter fFilter;
+ private IStatusChangeListener fContext;
+ private int fTreeExpansionLevel = 2;
+
+ private final int IDX_ADD_FOLDER_FILE = 0;
+ private final int IDX_ADD_SYMBOL = 2;
+ private final int IDX_ADD_EXT_INCLUDE = 4;
+ private final int IDX_ADD_WS_INCLUDE = 5;
+ private final int IDX_ADD_CONTRIBUTED = 7;
+ private final int IDX_EDIT = 9;
+ private final int IDX_REMOVE = 10;
+ private final int IDX_EXPORT = 12;
+ private final int IDX_UP = 14;
+ private final int IDX_DOWN = 15;
+
+ private static final String[] buttonLabel = new String[] {
+
+ CPathEntryMessages.IncludeSymbolEntryPage_addFolderFile, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_addUserSymbol, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_addExternalInclude,
+ CPathEntryMessages.IncludeSymbolEntryPage_addFromWorkspace, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_addContributed, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_edit, CPathEntryMessages.IncludeSymbolEntryPage_remove, null,
+ CPathEntryMessages.IncludeSymbolEntryPage_export, null, CPathEntryMessages.IncludeSymbolEntryPage_up,
+ CPathEntryMessages.IncludeSymbolEntryPage_down };
+ private CPElementGroup fTopGroup;
+
+ /**
+ * Per file specific CPElementFilter
+ *
+ * @author vhirsl
+ */
+ private class CPElementPerFileFilter extends CPElementFilter {
+
+ public CPElementPerFileFilter(int[] kind, boolean exportedOnly, boolean showInherited) {
+ super(kind, exportedOnly, showInherited);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPElementFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
public boolean select(Viewer viewer, Object parent, Object element) {
- IResource res = null;
- if (element instanceof CPElement) {
- CPElement cpElem = (CPElement) element;
- res = cpElem.getResource();
- } else if (element instanceof CPElementGroup) {
- CPElementGroup cpElemGroup = (CPElementGroup) element;
- res = cpElemGroup.getResource();
- }
- if (res != null && !res.equals(fCurrCElement.getResource())) {
- IPath currResPath = fCurrCElement.getResource().getFullPath();
- IPath resPath = res.getFullPath();
- boolean found = false;
- for (int i = currResPath.segmentCount() - 1; i >= 0; --i) {
- if (resPath.equals(currResPath.uptoSegment(i))) {
- found = true;
- break;
- }
- }
- if (found == false)
- return false;
- }
- return super.select(viewer, parent, element);
- }
-
- }
-
- private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter<CPElementGroup> {
-
- private final Object[] EMPTY_ARR = new Object[0];
-
- // -------- IListAdapter --------
- @Override
+ IResource res = null;
+ if (element instanceof CPElement) {
+ CPElement cpElem = (CPElement) element;
+ res = cpElem.getResource();
+ } else if (element instanceof CPElementGroup) {
+ CPElementGroup cpElemGroup = (CPElementGroup) element;
+ res = cpElemGroup.getResource();
+ }
+ if (res != null && !res.equals(fCurrCElement.getResource())) {
+ IPath currResPath = fCurrCElement.getResource().getFullPath();
+ IPath resPath = res.getFullPath();
+ boolean found = false;
+ for (int i = currResPath.segmentCount() - 1; i >= 0; --i) {
+ if (resPath.equals(currResPath.uptoSegment(i))) {
+ found = true;
+ break;
+ }
+ }
+ if (found == false)
+ return false;
+ }
+ return super.select(viewer, parent, element);
+ }
+
+ }
+
+ private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter<CPElementGroup> {
+
+ private final Object[] EMPTY_ARR = new Object[0];
+
+ // -------- IListAdapter --------
+ @Override
public void customButtonPressed(TreeListDialogField<CPElementGroup> field, int index) {
- listCustomButtonPressed(field, index);
- }
+ listCustomButtonPressed(field, index);
+ }
- @Override
+ @Override
public void selectionChanged(TreeListDialogField<CPElementGroup> field) {
- listPageSelectionChanged(field);
- }
+ listPageSelectionChanged(field);
+ }
- @Override
+ @Override
public void doubleClicked(TreeListDialogField<CPElementGroup> field) {
- listPageDoubleClicked(field);
- }
+ listPageDoubleClicked(field);
+ }
- @Override
+ @Override
public void keyPressed(TreeListDialogField<CPElementGroup> field, KeyEvent event) {
- listPageKeyPressed(field, event);
- }
+ listPageKeyPressed(field, event);
+ }
- @Override
+ @Override
public Object[] getChildren(TreeListDialogField<CPElementGroup> field, Object element) {
- if (element instanceof CPElement) {
- return ((CPElement)element).getChildren();
- } else if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getChildren();
- }
- return EMPTY_ARR;
- }
-
- @Override
+ if (element instanceof CPElement) {
+ return ((CPElement) element).getChildren();
+ } else if (element instanceof CPElementGroup) {
+ return ((CPElementGroup) element).getChildren();
+ }
+ return EMPTY_ARR;
+ }
+
+ @Override
public Object getParent(TreeListDialogField<CPElementGroup> field, Object element) {
- if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getParent();
- } else if (element instanceof CPElement) {
- return ((CPElement)element).getParent();
- }
- return null;
- }
-
- @Override
+ if (element instanceof CPElementGroup) {
+ return ((CPElementGroup) element).getParent();
+ } else if (element instanceof CPElement) {
+ return ((CPElement) element).getParent();
+ }
+ return null;
+ }
+
+ @Override
public boolean hasChildren(TreeListDialogField<CPElementGroup> field, Object element) {
- if (element instanceof CPElementGroup) {
- return true;
- }
- if (element instanceof CPElement) {
- return ((CPElement)element).getChildren().length > 0;
- }
- return false;
- }
-
- // ---------- IDialogFieldListener --------
-
- @Override
+ if (element instanceof CPElementGroup) {
+ return true;
+ }
+ if (element instanceof CPElement) {
+ return ((CPElement) element).getChildren().length > 0;
+ }
+ return false;
+ }
+
+ // ---------- IDialogFieldListener --------
+
+ @Override
public void dialogFieldChanged(DialogField field) {
- listPageDialogFieldChanged(field);
- }
+ listPageDialogFieldChanged(field);
+ }
- }
+ }
- public CPathIncludeSymbolEntryPerFilePage(IStatusChangeListener context) {
- super(CPathEntryMessages.IncludeSymbolEntryPage_title);
- fContext = context;
- IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
- fIncludeSymPathsList = new TreeListDialogField<CPElementGroup>(adapter, buttonLabel, new CPElementLabelProvider(true, false)) {
+ public CPathIncludeSymbolEntryPerFilePage(IStatusChangeListener context) {
+ super(CPathEntryMessages.IncludeSymbolEntryPage_title);
+ fContext = context;
+ IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
+ fIncludeSymPathsList = new TreeListDialogField<CPElementGroup>(adapter, buttonLabel,
+ new CPElementLabelProvider(true, false)) {
- @Override
+ @Override
protected int getTreeStyle() {
- return super.getTreeStyle() & ~SWT.MULTI;
- }
- };
- fIncludeSymPathsList.setLabelText(CPathEntryMessages.IncludeSymbolEntryPage_label);
- fIncludeSymPathsList.enableButton(IDX_ADD_FOLDER_FILE, false);
- fIncludeSymPathsList.enableButton(IDX_REMOVE, false);
- fIncludeSymPathsList.enableButton(IDX_EDIT, false);
- fIncludeSymPathsList.enableButton(IDX_ADD_CONTRIBUTED, true);
- fIncludeSymPathsList.enableButton(IDX_ADD_EXT_INCLUDE, true);
- fIncludeSymPathsList.enableButton(IDX_ADD_WS_INCLUDE, true);
- fIncludeSymPathsList.enableButton(IDX_ADD_SYMBOL, true);
- fIncludeSymPathsList.enableButton(IDX_EXPORT, false);
- fIncludeSymPathsList.enableButton(IDX_UP, false);
- fIncludeSymPathsList.enableButton(IDX_DOWN, false);
- fIncludeSymPathsList.setTreeExpansionLevel(fTreeExpansionLevel);
- fShowInheritedPaths = new SelectionButtonDialogField(SWT.CHECK);
- fShowInheritedPaths.setSelection(true);
- fShowInheritedPaths.setLabelText(CPathEntryMessages.IncludeSymbolsEntryPage_show_inherited_check);
- fShowInheritedPaths.setDialogFieldListener(adapter);
-
- fFilter = new CPElementPerFileFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_INCLUDE_FILE,
- IPathEntry.CDT_MACRO, IPathEntry.CDT_MACRO_FILE, IPathEntry.CDT_CONTAINER},
- false, true);
- }
-
- @Override
+ return super.getTreeStyle() & ~SWT.MULTI;
+ }
+ };
+ fIncludeSymPathsList.setLabelText(CPathEntryMessages.IncludeSymbolEntryPage_label);
+ fIncludeSymPathsList.enableButton(IDX_ADD_FOLDER_FILE, false);
+ fIncludeSymPathsList.enableButton(IDX_REMOVE, false);
+ fIncludeSymPathsList.enableButton(IDX_EDIT, false);
+ fIncludeSymPathsList.enableButton(IDX_ADD_CONTRIBUTED, true);
+ fIncludeSymPathsList.enableButton(IDX_ADD_EXT_INCLUDE, true);
+ fIncludeSymPathsList.enableButton(IDX_ADD_WS_INCLUDE, true);
+ fIncludeSymPathsList.enableButton(IDX_ADD_SYMBOL, true);
+ fIncludeSymPathsList.enableButton(IDX_EXPORT, false);
+ fIncludeSymPathsList.enableButton(IDX_UP, false);
+ fIncludeSymPathsList.enableButton(IDX_DOWN, false);
+ fIncludeSymPathsList.setTreeExpansionLevel(fTreeExpansionLevel);
+ fShowInheritedPaths = new SelectionButtonDialogField(SWT.CHECK);
+ fShowInheritedPaths.setSelection(true);
+ fShowInheritedPaths.setLabelText(CPathEntryMessages.IncludeSymbolsEntryPage_show_inherited_check);
+ fShowInheritedPaths.setDialogFieldListener(adapter);
+
+ fFilter = new CPElementPerFileFilter(new int[] { -1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_INCLUDE_FILE,
+ IPathEntry.CDT_MACRO, IPathEntry.CDT_MACRO_FILE, IPathEntry.CDT_CONTAINER }, false, true);
+ }
+
+ @Override
public void createControl(Composite parent) {
- PixelConverter converter = new PixelConverter(parent);
+ PixelConverter converter = new PixelConverter(parent);
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
- LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null), true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fIncludeSymPathsList, fShowInheritedPaths }, true);
+ LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null), true);
- int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
- fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
- setControl(composite);
- fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INCLUDE_PATHS_SYMBOLS);
- }
+ int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+ fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
+ setControl(composite);
+ fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite,
+ ICHelpContextIds.PROJECT_INCLUDE_PATHS_SYMBOLS);
+ }
- @Override
+ @Override
public Image getImage() {
- return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
- }
+ return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
+ }
- @Override
+ @Override
public void init(ICElement cElement, List<CPElement> cPaths) {
- fCurrCElement = cElement;
- fCurrCProject = cElement.getCProject();
- List<CPElementGroup> elements = createGroups(cElement, cPaths);
- fIncludeSymPathsList.setElements(elements);
- updateStatus();
- }
-
- private void updateStatus() {
- CPElement entryError = null;
- int nErrorEntries = 0;
- IStatus status = Status.OK_STATUS;
- List<CPElement> elements = getCPaths();
- for (int i = elements.size() - 1; i >= 0; i--) {
- CPElement currElement = elements.get(i);
- if (currElement.getStatus().getSeverity() != IStatus.OK) {
- nErrorEntries++;
- if (entryError == null) {
- entryError = currElement;
- }
- }
- }
-
- if (nErrorEntries > 0) {
- if (nErrorEntries == 1 && entryError != null) {
- status = entryError.getStatus();
- } else {
- status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, NLS.bind(
- CPathEntryMessages.CPElement_status_multiplePathErrors,
- String.valueOf(nErrorEntries)), null);
- }
- }
- fContext.statusChanged(status);
- }
-
- private void updateStatus(List<?> selected) {
- if (selected.size() != 1) {
- updateStatus();
- return;
- }
- CPElement element = null;
- if (selected.get(0) instanceof CPElement) {
- element = (CPElement)selected.get(0);
- } else if (selected.get(0) instanceof CPElementAttribute) {
- element = ((CPElementAttribute)selected.get(0)).getParent();
- }
- if (element != null && element.getStatus().getSeverity() != IStatus.OK) {
- fContext.statusChanged(element.getStatus());
- } else {
- updateStatus();
- return;
- }
- }
-
- private List<CPElementGroup> createGroups(ICElement element, List<CPElement> cPaths) {
- // create resource groups
- List<CPElementGroup> resourceGroups = new ArrayList<CPElementGroup>(5);
- fTopGroup = new CPElementGroup(element.getResource());
- resourceGroups.add(fTopGroup);
- // add containers first so that they appear at top of list
- for (int i = 0; i < cPaths.size(); i++) {
- CPElement cpelement = cPaths.get(i);
- switch (cpelement.getEntryKind()) {
- case IPathEntry.CDT_CONTAINER :
- fTopGroup.addChild(cpelement);
- break;
- }
- }
- for (int i = 0; i < cPaths.size(); i++) {
- CPElement cpelement = cPaths.get(i);
- switch (cpelement.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- case IPathEntry.CDT_INCLUDE_FILE :
- case IPathEntry.CDT_MACRO :
- case IPathEntry.CDT_MACRO_FILE :
- CPElementGroup resGroup = new CPElementGroup(cpelement.getResource());
- int ndx = resourceGroups.indexOf(resGroup);
- if (ndx == -1) {
- resourceGroups.add(resGroup);
- } else {
- resGroup = resourceGroups.get(ndx);
- }
- resGroup.addChild(cpelement);
- }
- }
-
- // place each path in its appropriate inherited group (or not if
- // excluded)
- for (int i = 0; i < cPaths.size(); i++) {
- CPElement cpelement = cPaths.get(i);
- switch (cpelement.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- case IPathEntry.CDT_INCLUDE_FILE :
- case IPathEntry.CDT_MACRO :
- case IPathEntry.CDT_MACRO_FILE :
- addPathToResourceGroups(cpelement, null, resourceGroups);
- }
- }
- return resourceGroups;
- }
-
- private void addPathToResourceGroup(CPElement element, CPElementGroup parent, CPElementGroup group) {
- IPath resPath = element.getPath();
- IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
- if ( (group != parent || !group.getResource().equals(element.getResource()))
- && resPath.isPrefixOf(group.getPath())
- && (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
- group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
- if (parent != null) { // try to insert at proper place in group...
- int insertHere = -1;
- int ndx = parent.indexof(element);
- if (ndx != -1) {
- CPElement[] children = parent.getChildren(element.getEntryKind());
- for (int i = ndx; i < children.length; i++) {
- insertHere = group.indexof(new CPElement(children[i], group.getPath(), group.getResource()));
- if (insertHere != -1) {
- group.addChild(new CPElement(element, group.getPath(), group.getResource()), insertHere);
- break;
- }
- }
- }
- if (insertHere == -1) {
- group.addChild(new CPElement(element, group.getPath(), group.getResource()));
- }
- } else {
- group.addChild(new CPElement(element, group.getPath(), group.getResource()));
- }
- }
- }
-
- private void addPathToResourceGroups(CPElement element, CPElementGroup parent, List<CPElementGroup> groups) {
- if (parent != null) {
- parent.addChild(element);
- }
- for (int i = 0; i < groups.size(); i++) {
- CPElementGroup group = groups.get(i);
- addPathToResourceGroup(element, parent, group);
- }
- }
-
- private void updatePathOnResourceGroups(CPElement element, List<CPElementGroup> groups) {
- CPElementGroup parent = element.getParent();
- IPath resPath = element.getPath();
- IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
- for (int i = 0; i < groups.size(); i++) {
- CPElementGroup group = groups.get(i);
- if (group != parent) {
- boolean found = false;
- CPElement[] elements = group.getChildren(element.getEntryKind());
- for (CPElement element2 : elements) {
- if (element2.getInherited() == element) {
- found = true;
- if (!CoreModelUtil.isExcludedPath(group.getResource().getFullPath().removeFirstSegments(
- resPath.segmentCount()), exclusions)) {
- group.replaceChild(element2, new CPElement(element, group.getPath(), group.getResource()));
- } else {
- group.removeChild(element2);
- }
- break;
- }
- }
- if (!found) {
- addPathToResourceGroup(element, parent, group);
- }
- }
- }
- }
-
- private CPElement removePathFromResourceGroups(CPElement element, List<CPElementGroup> groups) {
- CPElement Inherited = element.getInherited();
- CPElementGroup resGroup = element.getParent();
- resGroup.removeChild(element);
- if (Inherited != null) { // applied exclusion to orig.
- IPath exclude = element.getPath().removeFirstSegments(Inherited.getPath().segmentCount());
- IPath[] exclusions = (IPath[])Inherited.getAttribute(CPElement.EXCLUSION);
- IPath[] newExlusions = new IPath[exclusions.length + 1];
- System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
- newExlusions[exclusions.length] = exclude;
- Inherited.setAttribute(CPElement.EXCLUSION, newExlusions);
- return null;
- }
- // remove all inherited
- for (int i = 0; i < groups.size(); i++) {
- CPElementGroup group = groups.get(i);
- CPElement elements[] = group.getChildren(element.getEntryKind());
- for (CPElement element2 : elements) {
- if (element2.getInherited() == element) {
- group.removeChild(element2);
- break;
- }
- }
- }
- return element;
- }
-
- private boolean canAddPath(List<?> selected) {
- CPElementGroup group = getSelectedGroup();
- if (group != null) {
- return group.getEntryKind() == -1; // resource group
- }
- return false;
- }
-
- private boolean canRemove(List<?> selected) {
- if (selected.size() != 1) {
- return false;
- }
- Object elem = selected.get(0);
- if (elem instanceof CPElement) {
- CPElement element = (CPElement)elem;
- if (element.getParentContainer() == null) {
- return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
- }
- } else if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib = (CPElementAttribute)elem;
- if (attrib.getKey().equals(CPElement.EXCLUSION)) {
- if ( ((IPath[])attrib.getValue()).length > 0) {
- return true;
- }
- }
- }
- return false;
- }
-
- private void removeEntry() {
- List<?> selected = getSelection();
- Object elem = selected.get(0);
- if (elem instanceof CPElement) {
- CPElement element = (CPElement)elem;
- CPElementGroup parent = element.getParent();
- if (removePathFromResourceGroups(element, fIncludeSymPathsList.getElements()) == null) {
- updatePathOnResourceGroups( element.getInherited(), fIncludeSymPathsList.getElements());
- }
- fIncludeSymPathsList.refresh();
- fIncludeSymPathsList.selectElements(new StructuredSelection(parent));
- } else if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib = (CPElementAttribute)elem;
- String key = attrib.getKey();
- Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
- attrib.getParent().setAttribute(key, value);
- updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
- fIncludeSymPathsList.refresh();
- }
- updateStatus();
- }
-
- private boolean canEdit(List<?> selected) {
- if (selected.size() != 1) {
- return false;
- }
- Object elem = selected.get(0);
- if (elem instanceof CPElement) {
- CPElement element = (CPElement)selected.get(0);
- if (element.getParentContainer() == null && element.getInherited() == null) {
- IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
- if (path != null && !path.equals(Path.EMPTY)) {
- return false;
- }
- return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO
- || element.getEntryKind() == IPathEntry.CDT_CONTAINER;
- }
- }
- if (elem instanceof CPElementAttribute) {
- return true;
- }
- return false;
- }
-
- private void editEntry() {
- List<?> selElements = fIncludeSymPathsList.getSelectedElements();
- if (selElements.size() != 1) {
- return;
- }
- Object element = selElements.get(0);
-
- if (element instanceof CPElement) {
- editElementEntry((CPElement)element);
- } else if (element instanceof CPElementAttribute) {
- editAttributeEntry((CPElementAttribute)element);
- }
- }
-
- private void editElementEntry(CPElement element) {
- IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
- if (path != null && !path.equals(Path.EMPTY)) {
- return;
- } else if (element.getEntryKind() == IPathEntry.CDT_MACRO) {
- addSymbol(element);
- } else if (element.getEntryKind() == IPathEntry.CDT_INCLUDE) {
- path = (IPath)element.getAttribute(CPElement.BASE);
- if (path != null && !path.equals(Path.EMPTY)) {
- CPElement[] includes = openWorkspacePathEntryDialog(null);
- if (includes != null && includes.length > 0) {
- includes[0].setExported(element.isExported());
-
- }
- } else {
- addInclude(element);
- }
- } else if (element.getEntryKind() == IPathEntry.CDT_CONTAINER) {
- CPElement[] res = null;
-
- res = openContainerSelectionDialog(element);
- if (res != null && res.length > 0) {
- CPElement curr = res[0];
- curr.setExported(element.isExported());
- fTopGroup.replaceChild(element, curr);
- fIncludeSymPathsList.refresh();
- }
- }
- }
-
- private void editAttributeEntry(CPElementAttribute elem) {
- String key = elem.getKey();
- if (key.equals(CPElement.EXCLUSION)) {
- CPElement selElement = elem.getParent();
- ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
- if (dialog.open() == Window.OK) {
- selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
- updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
- fIncludeSymPathsList.refresh();
- updateStatus();
- }
- }
- }
-
- private void exportEntry() {
- CPElement element = (CPElement)getSelection().get(0);
- element.setExported(!element.isExported()); // toggle
- fIncludeSymPathsList.refresh(element);
- }
-
- private boolean canExport(List<?> selected) {
- if (selected.size() != 1) {
- return false;
- }
- Object elem = selected.get(0);
- if (elem instanceof CPElement) {
- CPElement element = (CPElement)selected.get(0);
- if (element.getParentContainer() == null && element.getInherited() == null) {
- IPath base_ref = (IPath)element.getAttribute(CPElement.BASE_REF);
- if (base_ref != null && !base_ref.equals(Path.EMPTY))
- return false;
- return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
- }
- }
- return false;
- }
-
- private boolean canMove(List<?> selected) {
- if (selected.size() == 0) {
- return false;
- }
- for (int i = 0; i < selected.size(); i++) {
- Object element = selected.get(i);
- if (! (element instanceof CPElement))
- return false;
- CPElement elem = (CPElement)element;
- if (elem.getEntryKind() != IPathEntry.CDT_INCLUDE && elem.getEntryKind() != IPathEntry.CDT_MACRO) {
- return false;
- }
- if (elem.getParentContainer() != null || elem.getInherited() != null) {
- return false;
- }
- }
- return true;
- }
-
- private boolean canMoveUp(List<?> selected) {
- if (!canMove(selected)) {
- return false;
- }
- CPElement first = (CPElement)selected.get(0);
- CPElementGroup parent = first.getParent();
- CPElement children[] = parent.getChildren(first.getEntryKind());
- int indx = Arrays.asList(children).indexOf(first);
- if (indx <= 0) {
- return false;
- }
- return true;
- }
-
- private boolean canMoveDown(List<?> selected) {
- if (!canMove(selected)) {
- return false;
- }
- CPElement last = (CPElement)selected.get(selected.size() - 1);
- CPElementGroup parent = last.getParent();
- CPElement children[] = parent.getChildren(last.getEntryKind());
- int indx = Arrays.asList(children).indexOf(last);
- if (indx >= children.length - 1 || children[indx + 1].getInherited() != null) {
- return false;
- }
- return true;
- }
-
- private boolean moveUp(CPElement element) {
- boolean rc = false;
- int kind = element.getEntryKind();
- for (CPElementGroup group : fIncludeSymPathsList.getElements()) {
- CPElement[] children = group.getChildren(kind);
- for (int k = 0; k < children.length; ++k) {
- CPElement child = children[k];
- if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
- if (child.getInherited() != null && k > 0 && children[k - 1].getInherited() == null) {
- break;
- }
- int prevIndex = k - 1;
- if (prevIndex >= 0) {
- // swap the two
- children[k] = children[prevIndex];
- children[prevIndex] = child;
- rc = true;
- break;
- }
- }
- }
- group.setChildren(children);
- }
- fIncludeSymPathsList.refresh();
- fIncludeSymPathsList.selectElements(new StructuredSelection(element));
- fIncludeSymPathsList.setFocus();
- return rc;
- }
-
- /**
- *
- */
- private boolean moveDown(CPElement element) {
- boolean rc = false;
- int kind = element.getEntryKind();
- for (CPElementGroup group : fIncludeSymPathsList.getElements()) {
- CPElement[] children = group.getChildren(kind);
- for (int k = children.length - 1; k >= 0; --k) {
- CPElement child = children[k];
- if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
- int prevIndex = k + 1;
- if (prevIndex < children.length) {
- // swap the two
- children[k] = children[prevIndex];
- children[prevIndex] = child;
- rc = true;
- break;
- }
- }
- }
- group.setChildren(children);
- }
- fIncludeSymPathsList.refresh();
- fIncludeSymPathsList.selectElements(new StructuredSelection(element));
- fIncludeSymPathsList.setFocus();
- return rc;
- }
-
- private CPElementGroup getSelectedGroup() {
- List<?> selected = fIncludeSymPathsList.getSelectedElements();
- if (!selected.isEmpty()) {
- Object item = selected.get(0);
- if (item instanceof CPElement) {
- item = ((CPElement)item).getParent();
- }
- if (item instanceof CPElementGroup) {
- return (CPElementGroup)item;
- }
- }
- return fTopGroup;
- }
-
- protected void listPageDialogFieldChanged(DialogField field) {
- boolean showInherited = fShowInheritedPaths.isSelected();
- if (field == fShowInheritedPaths) {
- if (fFilter != null) {
- fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
- }
- fFilter = new CPElementPerFileFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_INCLUDE_FILE,
- IPathEntry.CDT_MACRO, IPathEntry.CDT_MACRO_FILE, IPathEntry.CDT_CONTAINER},
- false, showInherited);
- fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
- fIncludeSymPathsList.setTreeExpansionLevel(fTreeExpansionLevel);
- fIncludeSymPathsList.refresh();
- }
- updateStatus();
- }
-
- protected void listPageSelectionChanged(TreeListDialogField<CPElementGroup> field) {
- List<?> selected = field.getSelectedElements();
- field.enableButton(IDX_REMOVE, canRemove(selected));
- field.enableButton(IDX_EDIT, canEdit(selected));
- field.enableButton(IDX_ADD_CONTRIBUTED, canAddPath(selected));
- field.enableButton(IDX_ADD_EXT_INCLUDE, canAddPath(selected));
- field.enableButton(IDX_ADD_WS_INCLUDE, canAddPath(selected));
- field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
- field.enableButton(IDX_EXPORT, canExport(selected));
- field.enableButton(IDX_DOWN, canMoveDown(selected));
- field.enableButton(IDX_UP, canMoveUp(selected));
- updateStatus(selected);
- }
-
- protected void listCustomButtonPressed(TreeListDialogField<CPElementGroup> field, int index) {
- switch (index) {
- case IDX_ADD_FOLDER_FILE :
- addNewPathResource();
- break;
- case IDX_ADD_SYMBOL :
- addSymbol(null);
- break;
- case IDX_ADD_EXT_INCLUDE :
- addInclude(null);
- break;
- case IDX_ADD_WS_INCLUDE :
- addFromWorkspace();
- break;
- case IDX_ADD_CONTRIBUTED :
- addContributed();
- break;
- case IDX_EDIT :
- if (canEdit(field.getSelectedElements())) {
- editEntry();
- }
- break;
- case IDX_REMOVE :
- if (canRemove(field.getSelectedElements())) {
- removeEntry();
- }
- break;
- case IDX_DOWN :
- if (canMoveDown(field.getSelectedElements())) {
- moveDown((CPElement)field.getSelectedElements().get(0));
- }
- break;
- case IDX_UP :
- if (canMoveUp(field.getSelectedElements())) {
- moveUp((CPElement)field.getSelectedElements().get(0));
- }
- break;
- case IDX_EXPORT :
- if (canExport(field.getSelectedElements())) {
- exportEntry();
- }
-
- }
- }
-
- protected void listPageDoubleClicked(TreeListDialogField<CPElementGroup> field) {
- if (canEdit(fIncludeSymPathsList.getSelectedElements())) {
- editEntry();
- }
- }
-
- protected void listPageKeyPressed(TreeListDialogField<CPElementGroup> field, KeyEvent event) {
- if (field == fIncludeSymPathsList) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- List<?> selection = field.getSelectedElements();
- if (canEdit(selection)) {
- removeEntry();
- }
- }
- }
- }
-
- protected IPathEntry[] getRawPathEntries() {
- List<CPElement> paths = getCPaths();
- IPathEntry[] currEntries = new IPathEntry[paths.size()];
- for (int i = 0; i < currEntries.length; i++) {
- CPElement curr = paths.get(i);
- currEntries[i] = curr.getPathEntry();
- }
- return currEntries;
- }
-
- protected void addNewPathResource() {
- Class<?>[] acceptedClasses = new Class[]{ICProject.class, ICContainer.class, ITranslationUnit.class};
- TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
- ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
-
- String title = CPathEntryMessages.IncludeSymbolEntryPage_newResource_title;
- String message = CPathEntryMessages.IncludeSymbolEntryPage_newResource_description;
-
- ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
- new CElementContentProvider());
- dialog.setValidator(validator);
- dialog.setTitle(title);
- dialog.setMessage(message);
- dialog.addFilter(filter);
- dialog.setInput(fCurrCProject);
- dialog.setInitialSelection(fCurrCProject);
-
- if (dialog.open() == Window.OK) {
- Object[] elements = dialog.getResult();
- IResource resource;
- if (elements[0] instanceof IResource) {
- resource = (IResource)elements[0];
- } else {
- resource = ((ICElement)elements[0]).getResource();
- }
- CPElementGroup newGroup = new CPElementGroup(resource);
- if (!fIncludeSymPathsList.getElements().contains(newGroup)) {
- List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
- for (int i = 0; i < groups.size(); i++) {
- CPElementGroup group = groups.get(i);
- if (group.getPath().isPrefixOf(newGroup.getPath())) {
- CPElement[] cpelements = group.getChildren();
- for (CPElement cpelement : cpelements) {
- if (cpelement.getInherited() == null) {
- switch (cpelement.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- case IPathEntry.CDT_INCLUDE_FILE :
- case IPathEntry.CDT_MACRO :
- case IPathEntry.CDT_MACRO_FILE :
- addPathToResourceGroup(cpelement, null, newGroup);
- }
- }
- }
- }
- }
- fIncludeSymPathsList.addElement(newGroup);
- }
- fIncludeSymPathsList.selectElements(new StructuredSelection(newGroup));
- fIncludeSymPathsList.expandElement(newGroup, 1);
- }
- }
-
- protected void addSymbol(CPElement existing) {
- // Popup an entry dialog
- InputDialog dialog;
- if (existing == null) {
- dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_title,
- CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_message, "", //$NON-NLS-1$
- null);
- } else {
- StringBuilder initialValue = new StringBuilder();
- initialValue.append((String)existing.getAttribute(CPElement.MACRO_NAME));
- initialValue.append('=');
- initialValue.append((String)existing.getAttribute(CPElement.MACRO_VALUE));
- dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_title,
- CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_message, initialValue.toString(),
- null);
- }
-
- String symbol = null;
- if (dialog.open() == Window.OK) {
- symbol = dialog.getValue();
- if (symbol != null && symbol.length() > 0) {
- CPElementGroup group = getSelectedGroup();
- CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
- group.getResource());
- String name, value = ""; //$NON-NLS-1$
- int index = symbol.indexOf("="); //$NON-NLS-1$
- if (index != -1) {
- name = symbol.substring(0, index).trim();
- value = symbol.substring(index + 1).trim();
- } else {
- name = symbol.trim();
- }
- if (existing != null) {
- existing.setAttribute(CPElement.MACRO_NAME, name);
- existing.setAttribute(CPElement.MACRO_VALUE, value);
- updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
- fIncludeSymPathsList.refresh();
- } else {
- newPath.setAttribute(CPElement.MACRO_NAME, name);
- newPath.setAttribute(CPElement.MACRO_VALUE, value);
- if (!group.contains(newPath)) {
- addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
- fIncludeSymPathsList.refresh();
- fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
- }
- updateStatus();
- }
- }
- }
- }
-
- protected void addInclude(CPElement existing) {
- InputDialog dialog;
- if (existing == null) {
- dialog = new SelectPathInputDialog(getShell(),
- CPathEntryMessages.IncludeSymbolEntryPage_addExternal_title,
- CPathEntryMessages.IncludeSymbolEntryPage_addExternal_message, null, null);
- } else {
- dialog = new SelectPathInputDialog(
- getShell(),
- CPathEntryMessages.IncludeSymbolEntryPage_editExternal_title,
- CPathEntryMessages.IncludeSymbolEntryPage_editExternal_message, ((IPath)existing.getAttribute(CPElement.INCLUDE)).toOSString(), null);
- }
- String newItem = null;
- if (dialog.open() == Window.OK) {
- newItem = dialog.getValue();
- if (newItem != null && !newItem.isEmpty()) {
- if (existing == null) {
- CPElementGroup group = getSelectedGroup();
- CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
- group.getResource());
- newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
- if (!group.contains(newPath)) {
- addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
- fIncludeSymPathsList.refresh();
- fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
- }
- } else {
- existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
- updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
- fIncludeSymPathsList.refresh();
- }
- updateStatus();
- }
- }
- }
-
- protected void addFromWorkspace() {
- CPElement[] includes = openWorkspacePathEntryDialog(null);
- if (includes != null && includes.length > 0) {
- int nElementsChosen = includes.length;
- CPElementGroup group = getSelectedGroup();
- for (int i = 0; i < nElementsChosen; i++) {
- CPElement curr = includes[i];
- if (!group.contains(curr)) {
- addPathToResourceGroups(curr, group, fIncludeSymPathsList.getElements());
- fIncludeSymPathsList.refresh();
- fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
- updateStatus();
- }
- }
- }
-
- }
-
- protected void addContributed() {
- CPElement[] includes = openContainerSelectionDialog(null);
- if (includes != null && includes.length > 0) {
- int nElementsChosen = includes.length;
- // remove duplicates
- CPElementGroup group = getSelectedGroup();
- for (int i = 0; i < nElementsChosen; i++) {
- CPElement curr = includes[i];
- if (!group.contains(curr)) {
- addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
- fIncludeSymPathsList.refresh();
- fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
- updateStatus();
- }
- }
- }
- }
-
- protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
- Class<?>[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
- TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
- ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
-
- String title = (existing == null) ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_title
- : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title;
- String message = (existing == null)
- ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_description
- : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description;
-
- ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
- new CElementContentProvider());
- dialog.setValidator(validator);
- dialog.setTitle(title);
- dialog.setMessage(message);
- dialog.addFilter(filter);
- dialog.setInput(CoreModel.getDefault().getCModel());
- if (existing == null) {
- dialog.setInitialSelection(fCurrCProject);
- } else {
- dialog.setInitialSelection(existing.getCProject());
- }
-
- if (dialog.open() == Window.OK) {
- Object[] elements = dialog.getResult();
- CPElement[] res = new CPElement[elements.length];
- for (int i = 0; i < res.length; i++) {
- IProject project;
- IPath includePath;
- if (elements[i] instanceof IResource) {
- project = ((IResource)elements[i]).getProject();
- includePath = ((IResource)elements[i]).getProjectRelativePath();
- } else {
- project = ((ICElement)elements[i]).getCProject().getProject();
- includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
- }
- CPElementGroup group = getSelectedGroup();
- res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
- group.getResource());
- res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
- res[i].setAttribute(CPElement.INCLUDE, includePath);
- }
- return res;
- }
- return null;
- }
-
- protected CPElement[] openContainerSelectionDialog(CPElement existing) {
- IContainerEntry elem = null;
- String title;
- if (existing == null) {
- title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_new_title;
- } else {
- title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_edit_title;
- elem = (IContainerEntry)existing.getPathEntry();
- }
- CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(), new int[]{
- IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO});
- wizard.setWindowTitle(title);
- if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
- IPathEntry parent = wizard.getEntriesParent();
- IPathEntry[] elements = wizard.getEntries();
-
- if (elements != null) {
- CPElement[] res = new CPElement[elements.length];
- CPElementGroup group = getSelectedGroup();
- for (int i = 0; i < res.length; i++) {
- if (elements[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
- res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
- group.getResource());
- res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry)elements[i]).getIncludePath());
- res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
- } else if (elements[i].getEntryKind() == IPathEntry.CDT_MACRO) {
- res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
- group.getResource());
- res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
- res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
- }
- }
- return res;
- }
- return new CPElement[]{CPElement.createFromExisting(parent, fCurrCProject)};
- }
- return null;
- }
-
- private class SelectPathInputDialog extends InputDialog {
-
- public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
- IInputValidator validator) {
- super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
- }
-
- @Override
+ fCurrCElement = cElement;
+ fCurrCProject = cElement.getCProject();
+ List<CPElementGroup> elements = createGroups(cElement, cPaths);
+ fIncludeSymPathsList.setElements(elements);
+ updateStatus();
+ }
+
+ private void updateStatus() {
+ CPElement entryError = null;
+ int nErrorEntries = 0;
+ IStatus status = Status.OK_STATUS;
+ List<CPElement> elements = getCPaths();
+ for (int i = elements.size() - 1; i >= 0; i--) {
+ CPElement currElement = elements.get(i);
+ if (currElement.getStatus().getSeverity() != IStatus.OK) {
+ nErrorEntries++;
+ if (entryError == null) {
+ entryError = currElement;
+ }
+ }
+ }
+
+ if (nErrorEntries > 0) {
+ if (nErrorEntries == 1 && entryError != null) {
+ status = entryError.getStatus();
+ } else {
+ status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+ NLS.bind(CPathEntryMessages.CPElement_status_multiplePathErrors, String.valueOf(nErrorEntries)),
+ null);
+ }
+ }
+ fContext.statusChanged(status);
+ }
+
+ private void updateStatus(List<?> selected) {
+ if (selected.size() != 1) {
+ updateStatus();
+ return;
+ }
+ CPElement element = null;
+ if (selected.get(0) instanceof CPElement) {
+ element = (CPElement) selected.get(0);
+ } else if (selected.get(0) instanceof CPElementAttribute) {
+ element = ((CPElementAttribute) selected.get(0)).getParent();
+ }
+ if (element != null && element.getStatus().getSeverity() != IStatus.OK) {
+ fContext.statusChanged(element.getStatus());
+ } else {
+ updateStatus();
+ return;
+ }
+ }
+
+ private List<CPElementGroup> createGroups(ICElement element, List<CPElement> cPaths) {
+ // create resource groups
+ List<CPElementGroup> resourceGroups = new ArrayList<CPElementGroup>(5);
+ fTopGroup = new CPElementGroup(element.getResource());
+ resourceGroups.add(fTopGroup);
+ // add containers first so that they appear at top of list
+ for (int i = 0; i < cPaths.size(); i++) {
+ CPElement cpelement = cPaths.get(i);
+ switch (cpelement.getEntryKind()) {
+ case IPathEntry.CDT_CONTAINER:
+ fTopGroup.addChild(cpelement);
+ break;
+ }
+ }
+ for (int i = 0; i < cPaths.size(); i++) {
+ CPElement cpelement = cPaths.get(i);
+ switch (cpelement.getEntryKind()) {
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_MACRO_FILE:
+ CPElementGroup resGroup = new CPElementGroup(cpelement.getResource());
+ int ndx = resourceGroups.indexOf(resGroup);
+ if (ndx == -1) {
+ resourceGroups.add(resGroup);
+ } else {
+ resGroup = resourceGroups.get(ndx);
+ }
+ resGroup.addChild(cpelement);
+ }
+ }
+
+ // place each path in its appropriate inherited group (or not if
+ // excluded)
+ for (int i = 0; i < cPaths.size(); i++) {
+ CPElement cpelement = cPaths.get(i);
+ switch (cpelement.getEntryKind()) {
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_MACRO_FILE:
+ addPathToResourceGroups(cpelement, null, resourceGroups);
+ }
+ }
+ return resourceGroups;
+ }
+
+ private void addPathToResourceGroup(CPElement element, CPElementGroup parent, CPElementGroup group) {
+ IPath resPath = element.getPath();
+ IPath[] exclusions = (IPath[]) element.getAttribute(CPElement.EXCLUSION);
+ if ((group != parent || !group.getResource().equals(element.getResource()))
+ && resPath.isPrefixOf(group.getPath())
+ && (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
+ group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
+ if (parent != null) { // try to insert at proper place in group...
+ int insertHere = -1;
+ int ndx = parent.indexof(element);
+ if (ndx != -1) {
+ CPElement[] children = parent.getChildren(element.getEntryKind());
+ for (int i = ndx; i < children.length; i++) {
+ insertHere = group.indexof(new CPElement(children[i], group.getPath(), group.getResource()));
+ if (insertHere != -1) {
+ group.addChild(new CPElement(element, group.getPath(), group.getResource()), insertHere);
+ break;
+ }
+ }
+ }
+ if (insertHere == -1) {
+ group.addChild(new CPElement(element, group.getPath(), group.getResource()));
+ }
+ } else {
+ group.addChild(new CPElement(element, group.getPath(), group.getResource()));
+ }
+ }
+ }
+
+ private void addPathToResourceGroups(CPElement element, CPElementGroup parent, List<CPElementGroup> groups) {
+ if (parent != null) {
+ parent.addChild(element);
+ }
+ for (int i = 0; i < groups.size(); i++) {
+ CPElementGroup group = groups.get(i);
+ addPathToResourceGroup(element, parent, group);
+ }
+ }
+
+ private void updatePathOnResourceGroups(CPElement element, List<CPElementGroup> groups) {
+ CPElementGroup parent = element.getParent();
+ IPath resPath = element.getPath();
+ IPath[] exclusions = (IPath[]) element.getAttribute(CPElement.EXCLUSION);
+ for (int i = 0; i < groups.size(); i++) {
+ CPElementGroup group = groups.get(i);
+ if (group != parent) {
+ boolean found = false;
+ CPElement[] elements = group.getChildren(element.getEntryKind());
+ for (CPElement element2 : elements) {
+ if (element2.getInherited() == element) {
+ found = true;
+ if (!CoreModelUtil.isExcludedPath(
+ group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()),
+ exclusions)) {
+ group.replaceChild(element2, new CPElement(element, group.getPath(), group.getResource()));
+ } else {
+ group.removeChild(element2);
+ }
+ break;
+ }
+ }
+ if (!found) {
+ addPathToResourceGroup(element, parent, group);
+ }
+ }
+ }
+ }
+
+ private CPElement removePathFromResourceGroups(CPElement element, List<CPElementGroup> groups) {
+ CPElement Inherited = element.getInherited();
+ CPElementGroup resGroup = element.getParent();
+ resGroup.removeChild(element);
+ if (Inherited != null) { // applied exclusion to orig.
+ IPath exclude = element.getPath().removeFirstSegments(Inherited.getPath().segmentCount());
+ IPath[] exclusions = (IPath[]) Inherited.getAttribute(CPElement.EXCLUSION);
+ IPath[] newExlusions = new IPath[exclusions.length + 1];
+ System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
+ newExlusions[exclusions.length] = exclude;
+ Inherited.setAttribute(CPElement.EXCLUSION, newExlusions);
+ return null;
+ }
+ // remove all inherited
+ for (int i = 0; i < groups.size(); i++) {
+ CPElementGroup group = groups.get(i);
+ CPElement elements[] = group.getChildren(element.getEntryKind());
+ for (CPElement element2 : elements) {
+ if (element2.getInherited() == element) {
+ group.removeChild(element2);
+ break;
+ }
+ }
+ }
+ return element;
+ }
+
+ private boolean canAddPath(List<?> selected) {
+ CPElementGroup group = getSelectedGroup();
+ if (group != null) {
+ return group.getEntryKind() == -1; // resource group
+ }
+ return false;
+ }
+
+ private boolean canRemove(List<?> selected) {
+ if (selected.size() != 1) {
+ return false;
+ }
+ Object elem = selected.get(0);
+ if (elem instanceof CPElement) {
+ CPElement element = (CPElement) elem;
+ if (element.getParentContainer() == null) {
+ return element.getEntryKind() == IPathEntry.CDT_INCLUDE
+ || element.getEntryKind() == IPathEntry.CDT_MACRO;
+ }
+ } else if (elem instanceof CPElementAttribute) {
+ CPElementAttribute attrib = (CPElementAttribute) elem;
+ if (attrib.getKey().equals(CPElement.EXCLUSION)) {
+ if (((IPath[]) attrib.getValue()).length > 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private void removeEntry() {
+ List<?> selected = getSelection();
+ Object elem = selected.get(0);
+ if (elem instanceof CPElement) {
+ CPElement element = (CPElement) elem;
+ CPElementGroup parent = element.getParent();
+ if (removePathFromResourceGroups(element, fIncludeSymPathsList.getElements()) == null) {
+ updatePathOnResourceGroups(element.getInherited(), fIncludeSymPathsList.getElements());
+ }
+ fIncludeSymPathsList.refresh();
+ fIncludeSymPathsList.selectElements(new StructuredSelection(parent));
+ } else if (elem instanceof CPElementAttribute) {
+ CPElementAttribute attrib = (CPElementAttribute) elem;
+ String key = attrib.getKey();
+ Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
+ attrib.getParent().setAttribute(key, value);
+ updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
+ fIncludeSymPathsList.refresh();
+ }
+ updateStatus();
+ }
+
+ private boolean canEdit(List<?> selected) {
+ if (selected.size() != 1) {
+ return false;
+ }
+ Object elem = selected.get(0);
+ if (elem instanceof CPElement) {
+ CPElement element = (CPElement) selected.get(0);
+ if (element.getParentContainer() == null && element.getInherited() == null) {
+ IPath path = (IPath) element.getAttribute(CPElement.BASE_REF);
+ if (path != null && !path.equals(Path.EMPTY)) {
+ return false;
+ }
+ return element.getEntryKind() == IPathEntry.CDT_INCLUDE
+ || element.getEntryKind() == IPathEntry.CDT_MACRO
+ || element.getEntryKind() == IPathEntry.CDT_CONTAINER;
+ }
+ }
+ if (elem instanceof CPElementAttribute) {
+ return true;
+ }
+ return false;
+ }
+
+ private void editEntry() {
+ List<?> selElements = fIncludeSymPathsList.getSelectedElements();
+ if (selElements.size() != 1) {
+ return;
+ }
+ Object element = selElements.get(0);
+
+ if (element instanceof CPElement) {
+ editElementEntry((CPElement) element);
+ } else if (element instanceof CPElementAttribute) {
+ editAttributeEntry((CPElementAttribute) element);
+ }
+ }
+
+ private void editElementEntry(CPElement element) {
+ IPath path = (IPath) element.getAttribute(CPElement.BASE_REF);
+ if (path != null && !path.equals(Path.EMPTY)) {
+ return;
+ } else if (element.getEntryKind() == IPathEntry.CDT_MACRO) {
+ addSymbol(element);
+ } else if (element.getEntryKind() == IPathEntry.CDT_INCLUDE) {
+ path = (IPath) element.getAttribute(CPElement.BASE);
+ if (path != null && !path.equals(Path.EMPTY)) {
+ CPElement[] includes = openWorkspacePathEntryDialog(null);
+ if (includes != null && includes.length > 0) {
+ includes[0].setExported(element.isExported());
+
+ }
+ } else {
+ addInclude(element);
+ }
+ } else if (element.getEntryKind() == IPathEntry.CDT_CONTAINER) {
+ CPElement[] res = null;
+
+ res = openContainerSelectionDialog(element);
+ if (res != null && res.length > 0) {
+ CPElement curr = res[0];
+ curr.setExported(element.isExported());
+ fTopGroup.replaceChild(element, curr);
+ fIncludeSymPathsList.refresh();
+ }
+ }
+ }
+
+ private void editAttributeEntry(CPElementAttribute elem) {
+ String key = elem.getKey();
+ if (key.equals(CPElement.EXCLUSION)) {
+ CPElement selElement = elem.getParent();
+ ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
+ if (dialog.open() == Window.OK) {
+ selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
+ updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
+ fIncludeSymPathsList.refresh();
+ updateStatus();
+ }
+ }
+ }
+
+ private void exportEntry() {
+ CPElement element = (CPElement) getSelection().get(0);
+ element.setExported(!element.isExported()); // toggle
+ fIncludeSymPathsList.refresh(element);
+ }
+
+ private boolean canExport(List<?> selected) {
+ if (selected.size() != 1) {
+ return false;
+ }
+ Object elem = selected.get(0);
+ if (elem instanceof CPElement) {
+ CPElement element = (CPElement) selected.get(0);
+ if (element.getParentContainer() == null && element.getInherited() == null) {
+ IPath base_ref = (IPath) element.getAttribute(CPElement.BASE_REF);
+ if (base_ref != null && !base_ref.equals(Path.EMPTY))
+ return false;
+ return element.getEntryKind() == IPathEntry.CDT_INCLUDE
+ || element.getEntryKind() == IPathEntry.CDT_MACRO;
+ }
+ }
+ return false;
+ }
+
+ private boolean canMove(List<?> selected) {
+ if (selected.size() == 0) {
+ return false;
+ }
+ for (int i = 0; i < selected.size(); i++) {
+ Object element = selected.get(i);
+ if (!(element instanceof CPElement))
+ return false;
+ CPElement elem = (CPElement) element;
+ if (elem.getEntryKind() != IPathEntry.CDT_INCLUDE && elem.getEntryKind() != IPathEntry.CDT_MACRO) {
+ return false;
+ }
+ if (elem.getParentContainer() != null || elem.getInherited() != null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean canMoveUp(List<?> selected) {
+ if (!canMove(selected)) {
+ return false;
+ }
+ CPElement first = (CPElement) selected.get(0);
+ CPElementGroup parent = first.getParent();
+ CPElement children[] = parent.getChildren(first.getEntryKind());
+ int indx = Arrays.asList(children).indexOf(first);
+ if (indx <= 0) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean canMoveDown(List<?> selected) {
+ if (!canMove(selected)) {
+ return false;
+ }
+ CPElement last = (CPElement) selected.get(selected.size() - 1);
+ CPElementGroup parent = last.getParent();
+ CPElement children[] = parent.getChildren(last.getEntryKind());
+ int indx = Arrays.asList(children).indexOf(last);
+ if (indx >= children.length - 1 || children[indx + 1].getInherited() != null) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean moveUp(CPElement element) {
+ boolean rc = false;
+ int kind = element.getEntryKind();
+ for (CPElementGroup group : fIncludeSymPathsList.getElements()) {
+ CPElement[] children = group.getChildren(kind);
+ for (int k = 0; k < children.length; ++k) {
+ CPElement child = children[k];
+ if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
+ if (child.getInherited() != null && k > 0 && children[k - 1].getInherited() == null) {
+ break;
+ }
+ int prevIndex = k - 1;
+ if (prevIndex >= 0) {
+ // swap the two
+ children[k] = children[prevIndex];
+ children[prevIndex] = child;
+ rc = true;
+ break;
+ }
+ }
+ }
+ group.setChildren(children);
+ }
+ fIncludeSymPathsList.refresh();
+ fIncludeSymPathsList.selectElements(new StructuredSelection(element));
+ fIncludeSymPathsList.setFocus();
+ return rc;
+ }
+
+ /**
+ *
+ */
+ private boolean moveDown(CPElement element) {
+ boolean rc = false;
+ int kind = element.getEntryKind();
+ for (CPElementGroup group : fIncludeSymPathsList.getElements()) {
+ CPElement[] children = group.getChildren(kind);
+ for (int k = children.length - 1; k >= 0; --k) {
+ CPElement child = children[k];
+ if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
+ int prevIndex = k + 1;
+ if (prevIndex < children.length) {
+ // swap the two
+ children[k] = children[prevIndex];
+ children[prevIndex] = child;
+ rc = true;
+ break;
+ }
+ }
+ }
+ group.setChildren(children);
+ }
+ fIncludeSymPathsList.refresh();
+ fIncludeSymPathsList.selectElements(new StructuredSelection(element));
+ fIncludeSymPathsList.setFocus();
+ return rc;
+ }
+
+ private CPElementGroup getSelectedGroup() {
+ List<?> selected = fIncludeSymPathsList.getSelectedElements();
+ if (!selected.isEmpty()) {
+ Object item = selected.get(0);
+ if (item instanceof CPElement) {
+ item = ((CPElement) item).getParent();
+ }
+ if (item instanceof CPElementGroup) {
+ return (CPElementGroup) item;
+ }
+ }
+ return fTopGroup;
+ }
+
+ protected void listPageDialogFieldChanged(DialogField field) {
+ boolean showInherited = fShowInheritedPaths.isSelected();
+ if (field == fShowInheritedPaths) {
+ if (fFilter != null) {
+ fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
+ }
+ fFilter = new CPElementPerFileFilter(new int[] { -1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_INCLUDE_FILE,
+ IPathEntry.CDT_MACRO, IPathEntry.CDT_MACRO_FILE, IPathEntry.CDT_CONTAINER }, false, showInherited);
+ fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
+ fIncludeSymPathsList.setTreeExpansionLevel(fTreeExpansionLevel);
+ fIncludeSymPathsList.refresh();
+ }
+ updateStatus();
+ }
+
+ protected void listPageSelectionChanged(TreeListDialogField<CPElementGroup> field) {
+ List<?> selected = field.getSelectedElements();
+ field.enableButton(IDX_REMOVE, canRemove(selected));
+ field.enableButton(IDX_EDIT, canEdit(selected));
+ field.enableButton(IDX_ADD_CONTRIBUTED, canAddPath(selected));
+ field.enableButton(IDX_ADD_EXT_INCLUDE, canAddPath(selected));
+ field.enableButton(IDX_ADD_WS_INCLUDE, canAddPath(selected));
+ field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
+ field.enableButton(IDX_EXPORT, canExport(selected));
+ field.enableButton(IDX_DOWN, canMoveDown(selected));
+ field.enableButton(IDX_UP, canMoveUp(selected));
+ updateStatus(selected);
+ }
+
+ protected void listCustomButtonPressed(TreeListDialogField<CPElementGroup> field, int index) {
+ switch (index) {
+ case IDX_ADD_FOLDER_FILE:
+ addNewPathResource();
+ break;
+ case IDX_ADD_SYMBOL:
+ addSymbol(null);
+ break;
+ case IDX_ADD_EXT_INCLUDE:
+ addInclude(null);
+ break;
+ case IDX_ADD_WS_INCLUDE:
+ addFromWorkspace();
+ break;
+ case IDX_ADD_CONTRIBUTED:
+ addContributed();
+ break;
+ case IDX_EDIT:
+ if (canEdit(field.getSelectedElements())) {
+ editEntry();
+ }
+ break;
+ case IDX_REMOVE:
+ if (canRemove(field.getSelectedElements())) {
+ removeEntry();
+ }
+ break;
+ case IDX_DOWN:
+ if (canMoveDown(field.getSelectedElements())) {
+ moveDown((CPElement) field.getSelectedElements().get(0));
+ }
+ break;
+ case IDX_UP:
+ if (canMoveUp(field.getSelectedElements())) {
+ moveUp((CPElement) field.getSelectedElements().get(0));
+ }
+ break;
+ case IDX_EXPORT:
+ if (canExport(field.getSelectedElements())) {
+ exportEntry();
+ }
+
+ }
+ }
+
+ protected void listPageDoubleClicked(TreeListDialogField<CPElementGroup> field) {
+ if (canEdit(fIncludeSymPathsList.getSelectedElements())) {
+ editEntry();
+ }
+ }
+
+ protected void listPageKeyPressed(TreeListDialogField<CPElementGroup> field, KeyEvent event) {
+ if (field == fIncludeSymPathsList) {
+ if (event.character == SWT.DEL && event.stateMask == 0) {
+ List<?> selection = field.getSelectedElements();
+ if (canEdit(selection)) {
+ removeEntry();
+ }
+ }
+ }
+ }
+
+ protected IPathEntry[] getRawPathEntries() {
+ List<CPElement> paths = getCPaths();
+ IPathEntry[] currEntries = new IPathEntry[paths.size()];
+ for (int i = 0; i < currEntries.length; i++) {
+ CPElement curr = paths.get(i);
+ currEntries[i] = curr.getPathEntry();
+ }
+ return currEntries;
+ }
+
+ protected void addNewPathResource() {
+ Class<?>[] acceptedClasses = new Class[] { ICProject.class, ICContainer.class, ITranslationUnit.class };
+ TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+ String title = CPathEntryMessages.IncludeSymbolEntryPage_newResource_title;
+ String message = CPathEntryMessages.IncludeSymbolEntryPage_newResource_description;
+
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
+ new CElementContentProvider());
+ dialog.setValidator(validator);
+ dialog.setTitle(title);
+ dialog.setMessage(message);
+ dialog.addFilter(filter);
+ dialog.setInput(fCurrCProject);
+ dialog.setInitialSelection(fCurrCProject);
+
+ if (dialog.open() == Window.OK) {
+ Object[] elements = dialog.getResult();
+ IResource resource;
+ if (elements[0] instanceof IResource) {
+ resource = (IResource) elements[0];
+ } else {
+ resource = ((ICElement) elements[0]).getResource();
+ }
+ CPElementGroup newGroup = new CPElementGroup(resource);
+ if (!fIncludeSymPathsList.getElements().contains(newGroup)) {
+ List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
+ for (int i = 0; i < groups.size(); i++) {
+ CPElementGroup group = groups.get(i);
+ if (group.getPath().isPrefixOf(newGroup.getPath())) {
+ CPElement[] cpelements = group.getChildren();
+ for (CPElement cpelement : cpelements) {
+ if (cpelement.getInherited() == null) {
+ switch (cpelement.getEntryKind()) {
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_MACRO_FILE:
+ addPathToResourceGroup(cpelement, null, newGroup);
+ }
+ }
+ }
+ }
+ }
+ fIncludeSymPathsList.addElement(newGroup);
+ }
+ fIncludeSymPathsList.selectElements(new StructuredSelection(newGroup));
+ fIncludeSymPathsList.expandElement(newGroup, 1);
+ }
+ }
+
+ protected void addSymbol(CPElement existing) {
+ // Popup an entry dialog
+ InputDialog dialog;
+ if (existing == null) {
+ dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_title,
+ CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_message, "", //$NON-NLS-1$
+ null);
+ } else {
+ StringBuilder initialValue = new StringBuilder();
+ initialValue.append((String) existing.getAttribute(CPElement.MACRO_NAME));
+ initialValue.append('=');
+ initialValue.append((String) existing.getAttribute(CPElement.MACRO_VALUE));
+ dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_title,
+ CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_message, initialValue.toString(), null);
+ }
+
+ String symbol = null;
+ if (dialog.open() == Window.OK) {
+ symbol = dialog.getValue();
+ if (symbol != null && symbol.length() > 0) {
+ CPElementGroup group = getSelectedGroup();
+ CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO,
+ group.getResource().getFullPath(), group.getResource());
+ String name, value = ""; //$NON-NLS-1$
+ int index = symbol.indexOf("="); //$NON-NLS-1$
+ if (index != -1) {
+ name = symbol.substring(0, index).trim();
+ value = symbol.substring(index + 1).trim();
+ } else {
+ name = symbol.trim();
+ }
+ if (existing != null) {
+ existing.setAttribute(CPElement.MACRO_NAME, name);
+ existing.setAttribute(CPElement.MACRO_VALUE, value);
+ updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
+ fIncludeSymPathsList.refresh();
+ } else {
+ newPath.setAttribute(CPElement.MACRO_NAME, name);
+ newPath.setAttribute(CPElement.MACRO_VALUE, value);
+ if (!group.contains(newPath)) {
+ addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
+ fIncludeSymPathsList.refresh();
+ fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
+ }
+ updateStatus();
+ }
+ }
+ }
+ }
+
+ protected void addInclude(CPElement existing) {
+ InputDialog dialog;
+ if (existing == null) {
+ dialog = new SelectPathInputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_addExternal_title,
+ CPathEntryMessages.IncludeSymbolEntryPage_addExternal_message, null, null);
+ } else {
+ dialog = new SelectPathInputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_editExternal_title,
+ CPathEntryMessages.IncludeSymbolEntryPage_editExternal_message,
+ ((IPath) existing.getAttribute(CPElement.INCLUDE)).toOSString(), null);
+ }
+ String newItem = null;
+ if (dialog.open() == Window.OK) {
+ newItem = dialog.getValue();
+ if (newItem != null && !newItem.isEmpty()) {
+ if (existing == null) {
+ CPElementGroup group = getSelectedGroup();
+ CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE,
+ group.getResource().getFullPath(), group.getResource());
+ newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
+ if (!group.contains(newPath)) {
+ addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
+ fIncludeSymPathsList.refresh();
+ fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
+ }
+ } else {
+ existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
+ updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
+ fIncludeSymPathsList.refresh();
+ }
+ updateStatus();
+ }
+ }
+ }
+
+ protected void addFromWorkspace() {
+ CPElement[] includes = openWorkspacePathEntryDialog(null);
+ if (includes != null && includes.length > 0) {
+ int nElementsChosen = includes.length;
+ CPElementGroup group = getSelectedGroup();
+ for (int i = 0; i < nElementsChosen; i++) {
+ CPElement curr = includes[i];
+ if (!group.contains(curr)) {
+ addPathToResourceGroups(curr, group, fIncludeSymPathsList.getElements());
+ fIncludeSymPathsList.refresh();
+ fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
+ updateStatus();
+ }
+ }
+ }
+
+ }
+
+ protected void addContributed() {
+ CPElement[] includes = openContainerSelectionDialog(null);
+ if (includes != null && includes.length > 0) {
+ int nElementsChosen = includes.length;
+ // remove duplicates
+ CPElementGroup group = getSelectedGroup();
+ for (int i = 0; i < nElementsChosen; i++) {
+ CPElement curr = includes[i];
+ if (!group.contains(curr)) {
+ addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
+ fIncludeSymPathsList.refresh();
+ fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
+ updateStatus();
+ }
+ }
+ }
+ }
+
+ protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
+ Class<?>[] acceptedClasses = new Class[] { ICProject.class, IProject.class, IContainer.class,
+ ICContainer.class };
+ TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses,
+ existing == null);
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+ String title = (existing == null) ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_title
+ : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title;
+ String message = (existing == null)
+ ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_description
+ : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description;
+
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
+ new CElementContentProvider());
+ dialog.setValidator(validator);
+ dialog.setTitle(title);
+ dialog.setMessage(message);
+ dialog.addFilter(filter);
+ dialog.setInput(CoreModel.getDefault().getCModel());
+ if (existing == null) {
+ dialog.setInitialSelection(fCurrCProject);
+ } else {
+ dialog.setInitialSelection(existing.getCProject());
+ }
+
+ if (dialog.open() == Window.OK) {
+ Object[] elements = dialog.getResult();
+ CPElement[] res = new CPElement[elements.length];
+ for (int i = 0; i < res.length; i++) {
+ IProject project;
+ IPath includePath;
+ if (elements[i] instanceof IResource) {
+ project = ((IResource) elements[i]).getProject();
+ includePath = ((IResource) elements[i]).getProjectRelativePath();
+ } else {
+ project = ((ICElement) elements[i]).getCProject().getProject();
+ includePath = ((ICElement) elements[i]).getResource().getProjectRelativePath();
+ }
+ CPElementGroup group = getSelectedGroup();
+ res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
+ group.getResource());
+ res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
+ res[i].setAttribute(CPElement.INCLUDE, includePath);
+ }
+ return res;
+ }
+ return null;
+ }
+
+ protected CPElement[] openContainerSelectionDialog(CPElement existing) {
+ IContainerEntry elem = null;
+ String title;
+ if (existing == null) {
+ title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_new_title;
+ } else {
+ title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_edit_title;
+ elem = (IContainerEntry) existing.getPathEntry();
+ }
+ CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(),
+ new int[] { IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO });
+ wizard.setWindowTitle(title);
+ if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
+ IPathEntry parent = wizard.getEntriesParent();
+ IPathEntry[] elements = wizard.getEntries();
+
+ if (elements != null) {
+ CPElement[] res = new CPElement[elements.length];
+ CPElementGroup group = getSelectedGroup();
+ for (int i = 0; i < res.length; i++) {
+ if (elements[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
+ res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
+ group.getResource());
+ res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry) elements[i]).getIncludePath());
+ res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
+ } else if (elements[i].getEntryKind() == IPathEntry.CDT_MACRO) {
+ res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
+ group.getResource());
+ res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry) elements[i]).getMacroName());
+ res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
+ }
+ }
+ return res;
+ }
+ return new CPElement[] { CPElement.createFromExisting(parent, fCurrCProject) };
+ }
+ return null;
+ }
+
+ private class SelectPathInputDialog extends InputDialog {
+
+ public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
+ IInputValidator validator) {
+ super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
+ }
+
+ @Override
protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- Button browse = createButton(parent, 3,
- CPathEntryMessages.IncludeSymbolEntryPage_addExternal_button_browse,
- false);
- browse.addSelectionListener(new SelectionAdapter() {
+ super.createButtonsForButtonBar(parent);
+ Button browse = createButton(parent, 3, CPathEntryMessages.IncludeSymbolEntryPage_addExternal_button_browse,
+ false);
+ browse.addSelectionListener(new SelectionAdapter() {
- @Override
+ @Override
public void widgetSelected(SelectionEvent ev) {
- DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
- dialog.setText(CPathEntryMessages.IncludeSymbolEntryPage_browseForFolder);
- String currentName = getText().getText();
- if (currentName != null && currentName.trim().length() != 0) {
- dialog.setFilterPath(currentName);
- }
- String dirname = dialog.open();
- if (dirname != null) {
- getText().setText(dirname);
- }
- }
- });
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#getSelection()
- */
- @Override
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
+ dialog.setText(CPathEntryMessages.IncludeSymbolEntryPage_browseForFolder);
+ String currentName = getText().getText();
+ if (currentName != null && currentName.trim().length() != 0) {
+ dialog.setFilterPath(currentName);
+ }
+ String dirname = dialog.open();
+ if (dirname != null) {
+ getText().setText(dirname);
+ }
+ }
+ });
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#getSelection()
+ */
+ @Override
public List<?> getSelection() {
- return fIncludeSymPathsList.getSelectedElements();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#setSelection(java.util.List)
- */
- @Override
+ return fIncludeSymPathsList.getSelectedElements();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#setSelection(java.util.List)
+ */
+ @Override
public void setSelection(List<?> selElements) {
- fIncludeSymPathsList.selectElements(new StructuredSelection(selElements));
- }
+ fIncludeSymPathsList.selectElements(new StructuredSelection(selElements));
+ }
- @Override
+ @Override
public boolean isEntryKind(int kind) {
- return kind == IPathEntry.CDT_INCLUDE || kind == IPathEntry.CDT_MACRO;
- }
+ return kind == IPathEntry.CDT_INCLUDE || kind == IPathEntry.CDT_MACRO;
+ }
- @Override
+ @Override
public void performApply(IProgressMonitor monitor) throws CoreException {
- }
+ }
- @Override
+ @Override
public void performDefaults() {
- }
+ }
- @Override
+ @Override
public List<CPElement> getCPaths() {
- List<CPElement> cPaths = new ArrayList<CPElement>();
- List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
- for (int i = 0; i < groups.size(); i++) {
- CPElementGroup group = groups.get(i);
- CPElement[] elements = group.getChildren();
- for (CPElement element : elements) {
- if (element.getInherited() == null) {
- cPaths.add(element);
- }
- }
- }
- return cPaths;
- }
+ List<CPElement> cPaths = new ArrayList<CPElement>();
+ List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
+ for (int i = 0; i < groups.size(); i++) {
+ CPElementGroup group = groups.get(i);
+ CPElement[] elements = group.getChildren();
+ for (CPElement element : elements) {
+ if (element.getInherited() == null) {
+ cPaths.add(element);
+ }
+ }
+ }
+ return cPaths;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java
index 5a9c0b47c3a..6d5a03da100 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java
@@ -60,7 +60,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
/**
* Libraries tab for C/C++ Project Paths page for 3.X projects.
- *
+ *
* @deprecated as of CDT 4.0. This tab was used to set preferences/properties
* for 3.X style projects.
*/
@@ -81,28 +81,24 @@ public class CPathLibraryEntryPage extends CPathBasePage {
private final int IDX_EXPORT = 7;
public CPathLibraryEntryPage(ListDialogField<CPElement> cPathList) {
- super(CPathEntryMessages.LibrariesEntryPage_title);
- setDescription(CPathEntryMessages.LibrariesEntryPage_description);
+ super(CPathEntryMessages.LibrariesEntryPage_title);
+ setDescription(CPathEntryMessages.LibrariesEntryPage_description);
fWorkspaceRoot = CUIPlugin.getWorkspace().getRoot();
fCPathList = cPathList;
LibrariesAdapter adapter = new LibrariesAdapter();
- String[] buttonLabels= new String[] {
- CPathEntryMessages.LibrariesEntryPage_libraries_addextlib_button,
- CPathEntryMessages.LibrariesEntryPage_libraries_addworkspacelib_button,
- CPathEntryMessages.LibrariesEntryPage_libraries_addcontriblib_button,
- /* */ null,
- CPathEntryMessages.LibrariesEntryPage_libraries_edit_button,
- CPathEntryMessages.LibrariesEntryPage_libraries_remove_button,
- null,
- CPathEntryMessages.LibrariesEntryPage_libraries_export_button
- };
+ String[] buttonLabels = new String[] { CPathEntryMessages.LibrariesEntryPage_libraries_addextlib_button,
+ CPathEntryMessages.LibrariesEntryPage_libraries_addworkspacelib_button,
+ CPathEntryMessages.LibrariesEntryPage_libraries_addcontriblib_button, /* */ null,
+ CPathEntryMessages.LibrariesEntryPage_libraries_edit_button,
+ CPathEntryMessages.LibrariesEntryPage_libraries_remove_button, null,
+ CPathEntryMessages.LibrariesEntryPage_libraries_export_button };
fLibrariesList = new TreeListDialogField<CPElement>(adapter, buttonLabels, new CPElementLabelProvider());
fLibrariesList.setDialogFieldListener(adapter);
- fLibrariesList.setLabelText(CPathEntryMessages.LibrariesEntryPage_libraries_label);
+ fLibrariesList.setLabelText(CPathEntryMessages.LibrariesEntryPage_libraries_label);
fLibrariesList.setViewerComparator(new CPElementSorter());
fLibrariesList.enableButton(IDX_EDIT, false);
@@ -125,7 +121,7 @@ public class CPathLibraryEntryPage extends CPathBasePage {
private void updateLibrariesList() {
List<CPElement> cpelements = filterList(fCPathList.getElements());
fLibrariesList.setElements(cpelements);
- }
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#getSelection()
@@ -173,7 +169,7 @@ public class CPathLibraryEntryPage extends CPathBasePage {
PixelConverter converter = new PixelConverter(parent);
Composite composite = new Composite(parent, SWT.NONE);
- LayoutUtil.doDefaultLayout(composite, new DialogField[] {fLibrariesList}, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fLibrariesList }, true);
LayoutUtil.setHorizontalGrabbing(fLibrariesList.getTreeControl(null), true);
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
@@ -182,29 +178,30 @@ public class CPathLibraryEntryPage extends CPathBasePage {
fLibrariesList.getTreeViewer().setSorter(new CPElementSorter());
setControl(composite);
-
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_LIBRARIES);
+
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite,
+ ICHelpContextIds.PROJECT_PATHS_LIBRARIES);
}
private class LibrariesAdapter implements IDialogFieldListener, ITreeListAdapter<CPElement> {
- private final Object[] EMPTY_ARR= new Object[0];
-
+ private final Object[] EMPTY_ARR = new Object[0];
+
// -------- IListAdapter --------
@Override
public void customButtonPressed(TreeListDialogField<CPElement> field, int index) {
libraryPageCustomButtonPressed(field, index);
}
-
+
@Override
public void selectionChanged(TreeListDialogField<CPElement> field) {
libraryPageSelectionChanged(field);
}
-
+
@Override
public void doubleClicked(TreeListDialogField<CPElement> field) {
libraryPageDoubleClicked(field);
}
-
+
@Override
public void keyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
libraryPageKeyPressed(field, event);
@@ -228,28 +225,28 @@ public class CPathLibraryEntryPage extends CPathBasePage {
@Override
public boolean hasChildren(TreeListDialogField<CPElement> field, Object element) {
-// return (element instanceof CPElement);
+ // return (element instanceof CPElement);
return false;
- }
-
+ }
+
// ---------- IDialogFieldListener --------
-
+
@Override
public void dialogFieldChanged(DialogField field) {
}
}
protected void libraryPageCustomButtonPressed(DialogField field, int index) {
- CPElement[] libentries= null;
+ CPElement[] libentries = null;
switch (index) {
case IDX_ADD_LIB: /* add jar */
- libentries= openLibFileDialog(null);
+ libentries = openLibFileDialog(null);
break;
case IDX_ADD_LIBEXT: /* add external jar */
- libentries= openExtLibFileDialog(null);
+ libentries = openExtLibFileDialog(null);
break;
case IDX_ADD_CONTRIBUTED: /* add variable */
- libentries= openContainerSelectionDialog(null);
+ libentries = openContainerSelectionDialog(null);
break;
case IDX_EDIT: /* edit */
editEntry();
@@ -257,20 +254,20 @@ public class CPathLibraryEntryPage extends CPathBasePage {
case IDX_REMOVE: /* remove */
removeEntry();
return;
- case IDX_EXPORT :
+ case IDX_EXPORT:
/* export */
exportEntry();
- return;
+ return;
}
-
+
if (libentries != null) {
- int nElementsChosen= libentries.length;
+ int nElementsChosen = libentries.length;
// remove duplicates
- List<CPElement> cplist= fLibrariesList.getElements();
- List<CPElement> elementsToAdd= new ArrayList<CPElement>(nElementsChosen);
-
- for (int i= 0; i < nElementsChosen; i++) {
- CPElement curr= libentries[i];
+ List<CPElement> cplist = fLibrariesList.getElements();
+ List<CPElement> elementsToAdd = new ArrayList<CPElement>(nElementsChosen);
+
+ for (int i = 0; i < nElementsChosen; i++) {
+ CPElement curr = libentries[i];
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
elementsToAdd.add(curr);
//curr.setAttribute(CPElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
@@ -292,11 +289,11 @@ public class CPathLibraryEntryPage extends CPathBasePage {
for (int i = 0; i < selElements.size(); i++) {
Object elem = selElements.get(i);
if (elem instanceof CPElement) {
- CPElement curr = (CPElement)elem;
+ CPElement curr = (CPElement) elem;
if (curr.getParentContainer() != null) {
return false;
}
- IPath base_ref = (IPath)curr.getAttribute(CPElement.BASE_REF);
+ IPath base_ref = (IPath) curr.getAttribute(CPElement.BASE_REF);
if (base_ref != null && !base_ref.equals(Path.EMPTY))
return false;
@@ -312,13 +309,13 @@ public class CPathLibraryEntryPage extends CPathBasePage {
}
Object elem = selElements.get(0);
if (fLibrariesList.getIndexOfElement(elem) != -1) {
- ((CPElement)elem).setExported(!((CPElement)elem).isExported()); // toggle export
+ ((CPElement) elem).setExported(!((CPElement) elem).isExported()); // toggle export
fLibrariesList.refresh(elem);
}
}
-
+
protected void libraryPageDoubleClicked(TreeListDialogField<CPElement> field) {
- List<?> selection= fLibrariesList.getSelectedElements();
+ List<?> selection = fLibrariesList.getSelectedElements();
if (canEdit(selection)) {
editEntry();
}
@@ -327,22 +324,22 @@ public class CPathLibraryEntryPage extends CPathBasePage {
protected void libraryPageKeyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
if (field == fLibrariesList) {
if (event.character == SWT.DEL && event.stateMask == 0) {
- List<?> selection= field.getSelectedElements();
+ List<?> selection = field.getSelectedElements();
if (canRemove(selection)) {
removeEntry();
}
}
- }
- }
+ }
+ }
private void removeEntry() {
- List<?> selElements= fLibrariesList.getSelectedElements();
- for (int i= selElements.size() - 1; i >= 0 ; i--) {
- Object elem= selElements.get(i);
+ List<?> selElements = fLibrariesList.getSelectedElements();
+ for (int i = selElements.size() - 1; i >= 0; i--) {
+ Object elem = selElements.get(i);
if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib= (CPElementAttribute) elem;
+ CPElementAttribute attrib = (CPElementAttribute) elem;
attrib.getParent().setAttribute(attrib.getKey(), null);
- selElements.remove(i);
+ selElements.remove(i);
}
}
if (selElements.isEmpty()) {
@@ -358,44 +355,44 @@ public class CPathLibraryEntryPage extends CPathBasePage {
if (selElements.size() == 0) {
return false;
}
- for (int i= 0; i < selElements.size(); i++) {
- Object elem= selElements.get(i);
+ for (int i = 0; i < selElements.size(); i++) {
+ Object elem = selElements.get(i);
if (elem instanceof CPElementAttribute) {
- if (((CPElementAttribute)elem).getValue() == null) {
+ if (((CPElementAttribute) elem).getValue() == null) {
return false;
}
} else if (elem instanceof CPElement) {
- CPElement curr= (CPElement) elem;
+ CPElement curr = (CPElement) elem;
if (curr.getParentContainer() != null) {
return false;
}
}
}
return true;
- }
+ }
/**
* Method editEntry.
*/
private void editEntry() {
- List<?> selElements= fLibrariesList.getSelectedElements();
+ List<?> selElements = fLibrariesList.getSelectedElements();
if (selElements.size() != 1) {
return;
}
- Object elem= selElements.get(0);
+ Object elem = selElements.get(0);
if (fLibrariesList.getIndexOfElement(elem) != -1) {
editElementEntry((CPElement) elem);
} else if (elem instanceof CPElementAttribute) {
editAttributeEntry((CPElementAttribute) elem);
}
}
-
+
private void editAttributeEntry(CPElementAttribute elem) {
- String key= elem.getKey();
+ String key = elem.getKey();
if (key.equals(CPElement.SOURCEATTACHMENT)) {
- CPElement selElement= elem.getParent();
- ILibraryEntry libEntry = (ILibraryEntry)selElement.getPathEntry();
- SourceAttachmentDialog dialog= new SourceAttachmentDialog(getShell(), libEntry, fCurrCProject, true);
+ CPElement selElement = elem.getParent();
+ ILibraryEntry libEntry = (ILibraryEntry) selElement.getPathEntry();
+ SourceAttachmentDialog dialog = new SourceAttachmentDialog(getShell(), libEntry, fCurrCProject, true);
if (dialog.open() == Window.OK) {
selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
fLibrariesList.refresh();
@@ -405,38 +402,38 @@ public class CPathLibraryEntryPage extends CPathBasePage {
}
private void editElementEntry(CPElement elem) {
- CPElement[] res= null;
+ CPElement[] res = null;
switch (elem.getEntryKind()) {
- case IPathEntry.CDT_LIBRARY:
- IPath p = (IPath)elem.getAttribute(CPElement.LIBRARY);
- if (p.isAbsolute()) {
- res= openExtLibFileDialog(elem);
- } else {
- res= openLibFileDialog(elem);
- }
+ case IPathEntry.CDT_LIBRARY:
+ IPath p = (IPath) elem.getAttribute(CPElement.LIBRARY);
+ if (p.isAbsolute()) {
+ res = openExtLibFileDialog(elem);
+ } else {
+ res = openLibFileDialog(elem);
+ }
break;
}
if (res != null && res.length > 0) {
- CPElement curr= res[0];
+ CPElement curr = res[0];
curr.setExported(elem.isExported());
fLibrariesList.replaceElement(elem, curr);
- }
+ }
}
protected void libraryPageSelectionChanged(DialogField field) {
- List<?> selElements= fLibrariesList.getSelectedElements();
+ List<?> selElements = fLibrariesList.getSelectedElements();
fLibrariesList.enableButton(IDX_EDIT, canEdit(selElements));
fLibrariesList.enableButton(IDX_REMOVE, canRemove(selElements));
fLibrariesList.enableButton(IDX_EXPORT, canExport(selElements));
}
private IFile[] getUsedLibFiles(CPElement existing) {
- List<IResource> res= new ArrayList<IResource>();
- List<CPElement> cplist= fLibrariesList.getElements();
- for (int i= 0; i < cplist.size(); i++) {
- CPElement elem= cplist.get(i);
+ List<IResource> res = new ArrayList<IResource>();
+ List<CPElement> cplist = fLibrariesList.getElements();
+ for (int i = 0; i < cplist.size(); i++) {
+ CPElement elem = cplist.get(i);
if (elem.getEntryKind() == IPathEntry.CDT_LIBRARY && (elem != existing)) {
- IResource resource= elem.getResource();
+ IResource resource = elem.getResource();
if (resource instanceof IFile) {
res.add(resource);
}
@@ -452,46 +449,49 @@ public class CPathLibraryEntryPage extends CPathBasePage {
}
private CPElement[] openExtLibFileDialog(CPElement existing) {
- String title= CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_title;
-
- FileDialog dialog= new FileDialog(getShell(), existing == null ? SWT.MULTI : SWT.SINGLE);
+ String title = CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_title;
+
+ FileDialog dialog = new FileDialog(getShell(), existing == null ? SWT.MULTI : SWT.SINGLE);
dialog.setText(title);
- dialog.setFilterExtensions(new String[] {"*.a;*.so;*.dll;*.lib"}); //$NON-NLS-1$
+ dialog.setFilterExtensions(new String[] { "*.a;*.so;*.dll;*.lib" }); //$NON-NLS-1$
//dialog.setFilterPath(lastUsedPath);
if (existing != null) {
dialog.setFileName(existing.getPath().lastSegment());
}
-
- String res= dialog.open();
+
+ String res = dialog.open();
if (res == null) {
return null;
}
- String[] fileNames= dialog.getFileNames();
- int nChosen= fileNames.length;
-
- IPath filterPath= new Path(dialog.getFilterPath());
- CPElement[] elems= new CPElement[nChosen];
- for (int i= 0; i < nChosen; i++) {
- IPath path= filterPath.append(fileNames[i]).makeAbsolute();
- elems[i]= newCPLibraryElement(path);
+ String[] fileNames = dialog.getFileNames();
+ int nChosen = fileNames.length;
+
+ IPath filterPath = new Path(dialog.getFilterPath());
+ CPElement[] elems = new CPElement[nChosen];
+ for (int i = 0; i < nChosen; i++) {
+ IPath path = filterPath.append(fileNames[i]).makeAbsolute();
+ elems[i] = newCPLibraryElement(path);
}
//fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, filterPath.toOSString());
-
- return elems;
+
+ return elems;
}
private CPElement[] openLibFileDialog(CPElement existing) {
- Class<?>[] acceptedClasses= new Class[] { IFile.class };
- TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, existing == null);
- ViewerFilter filter= new ArchiveFileFilter(getUsedLibFiles(existing), true);
-
- ILabelProvider lp= new WorkbenchLabelProvider();
- ITreeContentProvider cp= new WorkbenchContentProvider();
-
- String title= (existing == null) ? CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_title : CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_edit_title;
- String message= (existing == null) ? CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_description : CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_edit_description;
-
- ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
+ Class<?>[] acceptedClasses = new Class[] { IFile.class };
+ TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses,
+ existing == null);
+ ViewerFilter filter = new ArchiveFileFilter(getUsedLibFiles(existing), true);
+
+ ILabelProvider lp = new WorkbenchLabelProvider();
+ ITreeContentProvider cp = new WorkbenchContentProvider();
+
+ String title = (existing == null) ? CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_title
+ : CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_edit_title;
+ String message = (existing == null) ? CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_description
+ : CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_edit_description;
+
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setValidator(validator);
dialog.setTitle(title);
dialog.setMessage(message);
@@ -499,17 +499,17 @@ public class CPathLibraryEntryPage extends CPathBasePage {
dialog.setInput(fWorkspaceRoot);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (existing == null) {
- dialog.setInitialSelection(fCurrCProject.getProject());
+ dialog.setInitialSelection(fCurrCProject.getProject());
} else {
dialog.setInitialSelection(existing.getResource());
}
-
+
if (dialog.open() == Window.OK) {
- Object[] elements= dialog.getResult();
- CPElement[] res= new CPElement[elements.length];
- for (int i= 0; i < res.length; i++) {
- IPath path= ((IResource)elements[i]).getLocation();
- res[i]= newCPLibraryElement(path);
+ Object[] elements = dialog.getResult();
+ CPElement[] res = new CPElement[elements.length];
+ for (int i = 0; i < res.length; i++) {
+ IPath path = ((IResource) elements[i]).getLocation();
+ res[i] = newCPLibraryElement(path);
}
return res;
}
@@ -529,13 +529,13 @@ public class CPathLibraryEntryPage extends CPathBasePage {
IContainerEntry elem = null;
String title;
if (existing == null) {
- title = CPathEntryMessages.LibrariesEntryPage_ContainerDialog_new_title;
+ title = CPathEntryMessages.LibrariesEntryPage_ContainerDialog_new_title;
} else {
- title = CPathEntryMessages.LibrariesEntryPage_ContainerDialog_edit_title;
- elem = (IContainerEntry)existing.getPathEntry();
+ title = CPathEntryMessages.LibrariesEntryPage_ContainerDialog_edit_title;
+ elem = (IContainerEntry) existing.getPathEntry();
}
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(),
- new int[] {IPathEntry.CDT_LIBRARY});
+ new int[] { IPathEntry.CDT_LIBRARY });
wizard.setWindowTitle(title);
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
IPathEntry parent = wizard.getEntriesParent();
@@ -545,7 +545,7 @@ public class CPathLibraryEntryPage extends CPathBasePage {
CPElement[] res = new CPElement[elements.length];
for (int i = 0; i < res.length; i++) {
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_LIBRARY, fProjPath, null);
- res[i].setAttribute(CPElement.LIBRARY, ((ILibraryEntry)elements[i]).getLibraryPath());
+ res[i].setAttribute(CPElement.LIBRARY, ((ILibraryEntry) elements[i]).getLibraryPath());
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
}
return res;
@@ -558,9 +558,9 @@ public class CPathLibraryEntryPage extends CPathBasePage {
if (selElements.size() != 1) {
return false;
}
- Object elem= selElements.get(0);
+ Object elem = selElements.get(0);
if (elem instanceof CPElement) {
- CPElement curr= (CPElement) elem;
+ CPElement curr = (CPElement) elem;
return !(curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
}
if (elem instanceof CPElementAttribute) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.java
index 8e9d9380364..8590c851a2b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.java
@@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
/**
* Export tab for C/C++ Project Paths page for 3.X projects.
- *
+ *
* @deprecated as of CDT 4.0. This tab was used to set preferences/properties
* for 3.X style projects.
*/
@@ -39,16 +39,16 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class CPathOrderExportPage extends CPathBasePage {
private ListDialogField<?> fCPathList;
-
+
public CPathOrderExportPage(ListDialogField<?> cPathList) {
- super(CPathEntryMessages.OrderExportsPage_title);
- setDescription(CPathEntryMessages.OrderExportsPage_description);
+ super(CPathEntryMessages.OrderExportsPage_title);
+ setDescription(CPathEntryMessages.OrderExportsPage_description);
fCPathList = cPathList;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
@@ -58,7 +58,7 @@ public class CPathOrderExportPage extends CPathBasePage {
Composite composite = new Composite(parent, SWT.NONE);
setControl(composite);
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fCPathList}, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fCPathList }, true);
LayoutUtil.setHorizontalGrabbing(fCPathList.getListControl(null), true);
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
@@ -69,6 +69,7 @@ public class CPathOrderExportPage extends CPathBasePage {
public Image getImage() {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_ORDER);
}
+
/*
* @see BuildPathBasePage#getSelection
*/
@@ -87,7 +88,7 @@ public class CPathOrderExportPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
*/
@Override
@@ -97,7 +98,7 @@ public class CPathOrderExportPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
@@ -107,7 +108,7 @@ public class CPathOrderExportPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performDefaults()
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
index 6af1ba348dc..9272c4e2437 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
@@ -62,7 +62,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
/**
* Output tab for C/C++ Project Paths page for 3.X projects.
- *
+ *
* @deprecated as of CDT 4.0. This tab was used to set preferences/properties
* for 3.X style projects.
*/
@@ -82,8 +82,8 @@ public class CPathOutputEntryPage extends CPathBasePage {
private final int IDX_REMOVE = 3;
public CPathOutputEntryPage(ListDialogField<CPElement> cPathList) {
- super(CPathEntryMessages.OutputPathEntryPage_title);
- setDescription(CPathEntryMessages.OutputPathEntryPage_description);
+ super(CPathEntryMessages.OutputPathEntryPage_title);
+ setDescription(CPathEntryMessages.OutputPathEntryPage_description);
fWorkspaceRoot = CUIPlugin.getWorkspace().getRoot();
fCPathList = cPathList;
@@ -92,15 +92,13 @@ public class CPathOutputEntryPage extends CPathBasePage {
String[] buttonLabels;
- buttonLabels = new String[]{
- CPathEntryMessages.OutputPathEntryPage_folders_add_button,
- /* 1 */null, CPathEntryMessages.OutputPathEntryPage_folders_edit_button,
- CPathEntryMessages.OutputPathEntryPage_folders_remove_button
- };
+ buttonLabels = new String[] { CPathEntryMessages.OutputPathEntryPage_folders_add_button, /* 1 */null,
+ CPathEntryMessages.OutputPathEntryPage_folders_edit_button,
+ CPathEntryMessages.OutputPathEntryPage_folders_remove_button };
fOutputList = new TreeListDialogField<CPElement>(adapter, buttonLabels, new CPElementLabelProvider());
fOutputList.setDialogFieldListener(adapter);
- fOutputList.setLabelText(CPathEntryMessages.OutputPathEntryPage_folders_label);
+ fOutputList.setLabelText(CPathEntryMessages.OutputPathEntryPage_folders_label);
fOutputList.setViewerComparator(new CPElementSorter());
fOutputList.enableButton(IDX_EDIT, false);
@@ -126,7 +124,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
for (int i = 0; i < folders.size(); i++) {
CPElement cpe = folders.get(i);
- IPath[] patterns = (IPath[])cpe.getAttribute(CPElement.EXCLUSION);
+ IPath[] patterns = (IPath[]) cpe.getAttribute(CPElement.EXCLUSION);
if (patterns.length > 0) {
fOutputList.expandElement(cpe, 3);
}
@@ -138,7 +136,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
PixelConverter converter = new PixelConverter(parent);
Composite composite = new Composite(parent, SWT.NONE);
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fOutputList}, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fOutputList }, true);
LayoutUtil.setHorizontalGrabbing(fOutputList.getTreeControl(null), true);
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
@@ -148,13 +146,13 @@ public class CPathOutputEntryPage extends CPathBasePage {
List<CPElement> elements = fOutputList.getElements();
for (int i = 0; i < elements.size(); i++) {
CPElement elem = elements.get(i);
- IPath[] patterns = (IPath[])elem.getAttribute(CPElement.EXCLUSION);
+ IPath[] patterns = (IPath[]) elem.getAttribute(CPElement.EXCLUSION);
if (patterns.length > 0) {
fOutputList.expandElement(elem, 3);
}
}
setControl(composite);
-
+
CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_OUTPUT);
}
@@ -186,7 +184,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
@Override
public Object[] getChildren(TreeListDialogField<CPElement> field, Object element) {
if (element instanceof CPElement) {
- return ((CPElement)element).getChildren();
+ return ((CPElement) element).getChildren();
}
return EMPTY_ARR;
}
@@ -194,7 +192,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
@Override
public Object getParent(TreeListDialogField<CPElement> field, Object element) {
if (element instanceof CPElementAttribute) {
- return ((CPElementAttribute)element).getParent();
+ return ((CPElementAttribute) element).getParent();
}
return null;
}
@@ -302,9 +300,9 @@ public class CPathOutputEntryPage extends CPathBasePage {
}
Object elem = selElements.get(0);
if (fOutputList.getIndexOfElement(elem) != -1) {
- editElementEntry((CPElement)elem);
+ editElementEntry((CPElement) elem);
} else if (elem instanceof CPElementAttribute) {
- editAttributeEntry((CPElementAttribute)elem);
+ editAttributeEntry((CPElementAttribute) elem);
}
}
@@ -342,7 +340,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
for (int i = selElements.size() - 1; i >= 0; i--) {
Object elem = selElements.get(i);
if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib = (CPElementAttribute)elem;
+ CPElementAttribute attrib = (CPElementAttribute) elem;
String key = attrib.getKey();
Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
attrib.getParent().setAttribute(key, value);
@@ -364,16 +362,16 @@ public class CPathOutputEntryPage extends CPathBasePage {
for (int i = 0; i < selElements.size(); i++) {
Object elem = selElements.get(i);
if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib = (CPElementAttribute)elem;
+ CPElementAttribute attrib = (CPElementAttribute) elem;
if (attrib.getKey().equals(CPElement.EXCLUSION)) {
- if ( ((IPath[])attrib.getValue()).length == 0) {
+ if (((IPath[]) attrib.getValue()).length == 0) {
return false;
}
} else if (attrib.getValue() == null) {
return false;
}
} else if (elem instanceof CPElement) {
- CPElement curr = (CPElement)elem;
+ CPElement curr = (CPElement) elem;
if (curr.getParentContainer() != null) {
return false;
}
@@ -442,16 +440,17 @@ public class CPathOutputEntryPage extends CPathBasePage {
if (includeLinked) {
NewFolderDialog dialog = new NewFolderDialog(getShell(), fCurrCProject.getProject());
if (dialog.open() == Window.OK) {
- IResource createdFolder = (IResource)dialog.getResult()[0];
+ IResource createdFolder = (IResource) dialog.getResult()[0];
return newCPOutputElement(createdFolder);
}
return null;
}
String title = (existing == null) ? CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_new_title
- : CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_edit_title;
+ : CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_edit_title;
IProject proj = fCurrCProject.getProject();
- NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj, getExistingContainers(existing), existing);
- dialog.setMessage(NLS.bind(CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_description,
+ NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj,
+ getExistingContainers(existing), existing);
+ dialog.setMessage(NLS.bind(CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_description,
fProjPath.toString()));
if (dialog.open() == Window.OK) {
IResource folder = dialog.getSourceFolder();
@@ -463,15 +462,15 @@ public class CPathOutputEntryPage extends CPathBasePage {
private void askForAddingExclusionPatternsDialog(List<CPElement> newEntries, Set<CPElement> modifiedEntries) {
fixNestingConflicts(newEntries, fOutputList.getElements(), modifiedEntries);
if (!modifiedEntries.isEmpty()) {
- String title = CPathEntryMessages.OutputPathEntryPage_exclusion_added_title;
- String message = CPathEntryMessages.OutputPathEntryPage_exclusion_added_message;
+ String title = CPathEntryMessages.OutputPathEntryPage_exclusion_added_title;
+ String message = CPathEntryMessages.OutputPathEntryPage_exclusion_added_message;
MessageDialog.openInformation(getShell(), title, message);
}
}
private CPElement[] openOutputContainerDialog(CPElement existing) {
- Class<?>[] acceptedClasses = new Class[]{IProject.class, IFolder.class};
+ Class<?>[] acceptedClasses = new Class[] { IProject.class, IFolder.class };
List<IContainer> existingContainers = getExistingContainers(null);
IProject[] allProjects = fWorkspaceRoot.getProjects();
@@ -488,12 +487,11 @@ public class CPathOutputEntryPage extends CPathBasePage {
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new BaseWorkbenchContentProvider();
- String title = (existing == null)
- ? CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_new_title
- : CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_edit_title;
+ String title = (existing == null) ? CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_new_title
+ : CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_edit_title;
String message = (existing == null)
? CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_new_description
- : CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_edit_description;
+ : CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_edit_description;
MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(getShell(), lp, cp);
dialog.setExisting(existingContainers.toArray());
@@ -510,7 +508,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
Object[] elements = dialog.getResult();
CPElement[] res = new CPElement[elements.length];
for (int i = 0; i < res.length; i++) {
- IResource elem = (IResource)elements[i];
+ IResource elem = (IResource) elements[i];
res[i] = newCPOutputElement(elem);
}
return res;
@@ -556,7 +554,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
*/
@Override
@@ -566,7 +564,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
@@ -575,7 +573,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java
index 6153d455c6d..b3df166b070 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java
@@ -43,7 +43,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
/**
* Projects tab for C/C++ Project Paths page for 3.X projects.
- *
+ *
* @deprecated as of CDT 4.0. This tab was used for property pages
* for 3.X style projects.
*/
@@ -55,16 +55,16 @@ public class CPathProjectsEntryPage extends CPathBasePage {
private ListDialogField<CPElement> fCPathList;
public CPathProjectsEntryPage(ListDialogField<CPElement> cPathList) {
- super(CPathEntryMessages.ProjectsEntryPage_title);
- setDescription(CPathEntryMessages.ProjectsEntryPage_description);
+ super(CPathEntryMessages.ProjectsEntryPage_title);
+ setDescription(CPathEntryMessages.ProjectsEntryPage_description);
ProjectsListListener listener = new ProjectsListListener();
- String[] buttonLabels = new String[] { CPathEntryMessages.ProjectsEntryPage_projects_checkall_button,
- CPathEntryMessages.ProjectsEntryWorkbookPage_projects_uncheckall_button};
+ String[] buttonLabels = new String[] { CPathEntryMessages.ProjectsEntryPage_projects_checkall_button,
+ CPathEntryMessages.ProjectsEntryWorkbookPage_projects_uncheckall_button };
fProjectsList = new CheckedListDialogField<CPElement>(null, buttonLabels, new CPElementLabelProvider());
fProjectsList.setDialogFieldListener(listener);
- fProjectsList.setLabelText(CPathEntryMessages.ProjectsEntryPage_projects_label);
+ fProjectsList.setLabelText(CPathEntryMessages.ProjectsEntryPage_projects_label);
fProjectsList.setCheckAllButtonIndex(0);
fProjectsList.setUncheckAllButtonIndex(1);
@@ -79,7 +79,7 @@ public class CPathProjectsEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
@@ -88,7 +88,7 @@ public class CPathProjectsEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
*/
@Override
@@ -97,7 +97,7 @@ public class CPathProjectsEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
@@ -108,13 +108,14 @@ public class CPathProjectsEntryPage extends CPathBasePage {
setControl(composite);
- LayoutUtil.doDefaultLayout(composite, new DialogField[] { fProjectsList}, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fProjectsList }, true);
LayoutUtil.setHorizontalGrabbing(fProjectsList.getListControl(null), true);
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
fProjectsList.setButtonsMinWidth(buttonBarWidth);
-
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_PROJECTS);
+
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite,
+ ICHelpContextIds.PROJECT_PATHS_PROJECTS);
}
private class ProjectsListListener implements IDialogFieldListener {
@@ -141,11 +142,11 @@ public class CPathProjectsEntryPage extends CPathBasePage {
final List<CPElement> checkedProjects = new ArrayList<CPElement>();
try {
ICProject[] cprojects = cmodel.getCProjects();
-
+
// a vector remembering all projects that dont have to be added anymore
List<IResource> existingProjects = new ArrayList<IResource>(cprojects.length);
existingProjects.add(currCProject.getProject());
-
+
// add the projects-cpentries that are already on the C Path
List<CPElement> cpelements = fCPathList.getElements();
for (int i = cpelements.size() - 1; i >= 0; i--) {
@@ -156,7 +157,7 @@ public class CPathProjectsEntryPage extends CPathBasePage {
checkedProjects.add(cpelem);
}
}
-
+
for (ICProject cproject : cprojects) {
IProject proj = cproject.getProject();
if (!existingProjects.contains(proj)) {
@@ -212,7 +213,7 @@ public class CPathProjectsEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.java
index ffc082ec02a..919956a78e4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.java
@@ -44,14 +44,14 @@ import org.eclipse.ui.dialogs.PropertyPage;
/**
* C/C++ Project Paths page for 3.X projects.
- *
+ *
* @deprecated as of CDT 4.0. This property page was used to set properties
* "C/C++ Make Project" for 3.X style projects.
* This page lives dormant as of writing (CDT 7.0) but may get activated for
* {@code org.eclipse.cdt.make.core.makeNature} project (3.X style).
*/
@Deprecated
-public class CPathPropertyPage extends PropertyPage implements IStatusChangeListener{
+public class CPathPropertyPage extends PropertyPage implements IStatusChangeListener {
private static final String PAGE_SETTINGS = "CPathsPropertyPage"; //$NON-NLS-1$
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
@@ -101,7 +101,7 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
*/
private Control createWithoutCProject(Composite parent) {
Label label = new Label(parent, SWT.LEFT);
- label.setText(CPathEntryMessages.CPathsPropertyPage_no_C_project_message);
+ label.setText(CPathEntryMessages.CPathsPropertyPage_no_C_project_message);
fCPathsBlock = null;
setValid(true);
@@ -113,7 +113,7 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
*/
private Control createForClosedProject(Composite parent) {
Label label = new Label(parent, SWT.LEFT);
- label.setText(CPathEntryMessages.CPathsPropertyPage_closed_project_message);
+ label.setText(CPathEntryMessages.CPathsPropertyPage_closed_project_message);
fCPathsBlock = null;
setValid(true);
@@ -125,12 +125,11 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
if (fCPathsBlock != null) {
if (!visible) {
if (fCPathsBlock.hasChangesInDialog()) {
- String title = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_title;
- String message = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_message;
- String[] buttonLabels = new String[]{
- CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_save,
- CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_discard,
- };
+ String title = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_title;
+ String message = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_message;
+ String[] buttonLabels = new String[] {
+ CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_save,
+ CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_discard, };
MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
buttonLabels, 0);
int res = dialog.open();
@@ -154,7 +153,7 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
if (adaptable != null) {
ICElement elem = adaptable.getAdapter(ICElement.class);
if (elem instanceof ICProject) {
- return ((ICProject)elem).getProject();
+ return ((ICProject) elem).getProject();
}
}
return null;
@@ -193,8 +192,8 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
try {
new ProgressMonitorDialog(shell).run(true, true, op);
} catch (InvocationTargetException e) {
- String title = CPathEntryMessages.CPathsPropertyPage_error_title;
- String message = CPathEntryMessages.CPathsPropertyPage_error_message;
+ String title = CPathEntryMessages.CPathsPropertyPage_error_title;
+ String message = CPathEntryMessages.CPathsPropertyPage_error_message;
ExceptionHandler.handle(e, shell, title, message);
return false;
} catch (InterruptedException e) {
@@ -207,7 +206,7 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
/*
* (non-Javadoc)
- *
+ *
* @see IStatusChangeListener#statusChanged
*/
@Override
@@ -218,7 +217,7 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.preference.IPreferencePage#performCancel()
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
index fa388945df2..72b7a3e9d24 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
@@ -61,7 +61,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
/**
* Source tab for C/C++ Project Paths page for 3.X projects.
- *
+ *
* @deprecated as of CDT 4.0. This tab was used for property pages
* for 3.X style projects.
*/
@@ -81,8 +81,8 @@ public class CPathSourceEntryPage extends CPathBasePage {
private final int IDX_REMOVE = 3;
public CPathSourceEntryPage(ListDialogField<CPElement> classPathList) {
- super(CPathEntryMessages.SourcePathEntryPage_title);
- setDescription(CPathEntryMessages.SourcePathEntryPage_description);
+ super(CPathEntryMessages.SourcePathEntryPage_title);
+ setDescription(CPathEntryMessages.SourcePathEntryPage_description);
fWorkspaceRoot = CUIPlugin.getWorkspace().getRoot();
fCPathList = classPathList;
@@ -91,15 +91,13 @@ public class CPathSourceEntryPage extends CPathBasePage {
String[] buttonLabels;
- buttonLabels = new String[]{
- CPathEntryMessages.SourcePathEntryPage_folders_add_button,
- /* 1 */null, CPathEntryMessages.SourcePathEntryPath_folders_edit_button,
- CPathEntryMessages.SourcePathEntryPage_folders_remove_button
- };
+ buttonLabels = new String[] { CPathEntryMessages.SourcePathEntryPage_folders_add_button, /* 1 */null,
+ CPathEntryMessages.SourcePathEntryPath_folders_edit_button,
+ CPathEntryMessages.SourcePathEntryPage_folders_remove_button };
fFoldersList = new TreeListDialogField<CPElement>(adapter, buttonLabels, new CPElementLabelProvider());
fFoldersList.setDialogFieldListener(adapter);
- fFoldersList.setLabelText(CPathEntryMessages.SourcePathEntryPage_folders_label);
+ fFoldersList.setLabelText(CPathEntryMessages.SourcePathEntryPage_folders_label);
fFoldersList.setViewerComparator(new CPElementSorter());
fFoldersList.enableButton(IDX_EDIT, false);
@@ -124,7 +122,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
for (int i = 0; i < folders.size(); i++) {
CPElement cpe = folders.get(i);
- IPath[] patterns = (IPath[])cpe.getAttribute(CPElement.EXCLUSION);
+ IPath[] patterns = (IPath[]) cpe.getAttribute(CPElement.EXCLUSION);
if (patterns.length > 0) {
fFoldersList.expandElement(cpe, 3);
}
@@ -136,7 +134,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
PixelConverter converter = new PixelConverter(parent);
Composite composite = new Composite(parent, SWT.NONE);
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fFoldersList}, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fFoldersList }, true);
LayoutUtil.setHorizontalGrabbing(fFoldersList.getTreeControl(null), true);
int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
@@ -146,14 +144,14 @@ public class CPathSourceEntryPage extends CPathBasePage {
List<CPElement> elements = fFoldersList.getElements();
for (int i = 0; i < elements.size(); i++) {
CPElement elem = elements.get(i);
- IPath[] patterns = (IPath[])elem.getAttribute(CPElement.EXCLUSION);
+ IPath[] patterns = (IPath[]) elem.getAttribute(CPElement.EXCLUSION);
if (patterns.length > 0) {
fFoldersList.expandElement(elem, 3);
}
}
setControl(composite);
-
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_SOURCE);
+
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_SOURCE);
}
private class SourceContainerAdapter implements ITreeListAdapter<CPElement>, IDialogFieldListener {
@@ -184,7 +182,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
@Override
public Object[] getChildren(TreeListDialogField<CPElement> field, Object element) {
if (element instanceof CPElement) {
- return ((CPElement)element).getChildren();
+ return ((CPElement) element).getChildren();
}
return EMPTY_ARR;
}
@@ -192,7 +190,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
@Override
public Object getParent(TreeListDialogField<CPElement> field, Object element) {
if (element instanceof CPElementAttribute) {
- return ((CPElementAttribute)element).getParent();
+ return ((CPElementAttribute) element).getParent();
}
return null;
}
@@ -278,9 +276,9 @@ public class CPathSourceEntryPage extends CPathBasePage {
}
Object elem = selElements.get(0);
if (fFoldersList.getIndexOfElement(elem) != -1) {
- editElementEntry((CPElement)elem);
+ editElementEntry((CPElement) elem);
} else if (elem instanceof CPElementAttribute) {
- editAttributeEntry((CPElementAttribute)elem);
+ editAttributeEntry((CPElementAttribute) elem);
}
}
@@ -318,7 +316,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
for (int i = selElements.size() - 1; i >= 0; i--) {
Object elem = selElements.get(i);
if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib = (CPElementAttribute)elem;
+ CPElementAttribute attrib = (CPElementAttribute) elem;
String key = attrib.getKey();
Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
attrib.getParent().setAttribute(key, value);
@@ -340,16 +338,16 @@ public class CPathSourceEntryPage extends CPathBasePage {
for (int i = 0; i < selElements.size(); i++) {
Object elem = selElements.get(i);
if (elem instanceof CPElementAttribute) {
- CPElementAttribute attrib = (CPElementAttribute)elem;
+ CPElementAttribute attrib = (CPElementAttribute) elem;
if (attrib.getKey().equals(CPElement.EXCLUSION)) {
- if ( ((IPath[])attrib.getValue()).length == 0) {
+ if (((IPath[]) attrib.getValue()).length == 0) {
return false;
}
} else if (attrib.getValue() == null) {
return false;
}
} else if (elem instanceof CPElement) {
- CPElement curr = (CPElement)elem;
+ CPElement curr = (CPElement) elem;
if (curr.getParentContainer() != null) {
return false;
}
@@ -418,17 +416,18 @@ public class CPathSourceEntryPage extends CPathBasePage {
if (includeLinked) {
NewFolderDialog dialog = new NewFolderDialog(getShell(), fCurrCProject.getProject());
if (dialog.open() == Window.OK) {
- IResource createdFolder = (IResource)dialog.getResult()[0];
+ IResource createdFolder = (IResource) dialog.getResult()[0];
return newCPSourceElement(createdFolder);
}
return null;
}
String title = (existing == null) ? CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_new_title
- : CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_edit_title;
+ : CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_edit_title;
IProject proj = fCurrCProject.getProject();
- NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj, getExistingContainers(existing), existing);
- dialog.setMessage(NLS.bind(CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_description,
+ NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj,
+ getExistingContainers(existing), existing);
+ dialog.setMessage(NLS.bind(CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_description,
fProjPath.toString()));
if (dialog.open() == Window.OK) {
IResource folder = dialog.getSourceFolder();
@@ -440,15 +439,15 @@ public class CPathSourceEntryPage extends CPathBasePage {
private void askForAddingExclusionPatternsDialog(List<CPElement> newEntries, Set<CPElement> modifiedEntries) {
fixNestingConflicts(newEntries, fFoldersList.getElements(), modifiedEntries);
if (!modifiedEntries.isEmpty()) {
- String title = CPathEntryMessages.SourcePathEntryPage_exclusion_added_title;
- String message = CPathEntryMessages.SourcePathEntryPage_exclusion_added_message;
+ String title = CPathEntryMessages.SourcePathEntryPage_exclusion_added_title;
+ String message = CPathEntryMessages.SourcePathEntryPage_exclusion_added_message;
MessageDialog.openInformation(getShell(), title, message);
}
}
private CPElement[] openSourceContainerDialog(CPElement existing) {
- Class<?>[] acceptedClasses = new Class[]{IProject.class, IFolder.class};
+ Class<?>[] acceptedClasses = new Class[] { IProject.class, IFolder.class };
List<IContainer> existingContainers = getExistingContainers(null);
IProject[] allProjects = fWorkspaceRoot.getProjects();
@@ -465,12 +464,11 @@ public class CPathSourceEntryPage extends CPathBasePage {
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new BaseWorkbenchContentProvider();
- String title = (existing == null)
- ? CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_new_title
- : CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_edit_title;
+ String title = (existing == null) ? CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_new_title
+ : CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_edit_title;
String message = (existing == null)
? CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_new_description
- : CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_edit_description;
+ : CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_edit_description;
MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(getShell(), lp, cp);
dialog.setExisting(existingContainers.toArray());
@@ -487,7 +485,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
Object[] elements = dialog.getResult();
CPElement[] res = new CPElement[elements.length];
for (int i = 0; i < res.length; i++) {
- IResource elem = (IResource)elements[i];
+ IResource elem = (IResource) elements[i];
res[i] = newCPSourceElement(elem);
}
return res;
@@ -533,7 +531,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
*/
@Override
@@ -543,7 +541,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
@@ -552,7 +550,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performDefaults()
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java
index 1ac11f8656f..7753664c844 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java
@@ -31,14 +31,15 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
/**
* Block for C/C++ Project Paths page for 3.X projects.
- *
+ *
* @deprecated as of CDT 4.0. This option block was for property pages
* for 3.X style projects.
*/
@Deprecated
public class CPathTabBlock extends AbstractPathOptionBlock {
-
- private final int[] pathTypes = {IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT, IPathEntry.CDT_LIBRARY,IPathEntry.CDT_CONTAINER};
+
+ private final int[] pathTypes = { IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT,
+ IPathEntry.CDT_LIBRARY, IPathEntry.CDT_CONTAINER };
private ListDialogField<CPElement> fCPathList;
@@ -67,9 +68,9 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
public CPathTabBlock(IStatusChangeListener context, int pageToShow) {
super(context, pageToShow);
- String[] buttonLabels = new String[]{ CPathEntryMessages.CPathsBlock_path_up_button,
- CPathEntryMessages.CPathsBlock_path_down_button,
- /* 2 */null, CPathEntryMessages.CPathsBlock_path_checkall_button,
+ String[] buttonLabels = new String[] { CPathEntryMessages.CPathsBlock_path_up_button,
+ CPathEntryMessages.CPathsBlock_path_down_button, /* 2 */null,
+ CPathEntryMessages.CPathsBlock_path_checkall_button,
CPathEntryMessages.CPathsBlock_path_uncheckall_button
};
@@ -100,7 +101,7 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
@@ -143,6 +144,7 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
protected int[] getAppliedFilteredTypes() {
return pathTypes;
}
+
/**
* Validates the build path.
*/
@@ -171,7 +173,7 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
if (nErrorEntries == 1 && entryError != null) {
getPathStatus().setWarning(entryError.getStatus().getMessage());
} else {
- getPathStatus().setWarning(NLS.bind(CPathEntryMessages.CPElement_status_multiplePathErrors,
+ getPathStatus().setWarning(NLS.bind(CPathEntryMessages.CPElement_status_multiplePathErrors,
String.valueOf(nErrorEntries)));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialog.java
index 00d50a69e26..b116951ee80 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialog.java
@@ -56,12 +56,12 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class ExclusionPatternDialog extends StatusDialog {
-
+
private static class ExclusionPatternLabelProvider extends LabelProvider {
-
+
@Override
public Image getImage(Object element) {
- ImageDescriptorRegistry registry= CUIPlugin.getImageDescriptorRegistry();
+ ImageDescriptorRegistry registry = CUIPlugin.getImageDescriptorRegistry();
return registry.get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB));
}
@@ -71,53 +71,49 @@ public class ExclusionPatternDialog extends StatusDialog {
}
}
-
-
+
private ListDialogField<String> fExclusionPatternList;
private CPElement fCurrElement;
private IProject fCurrProject;
-
+
private IContainer fCurrSourceFolder;
-
- private static final int IDX_ADD= 0;
- private static final int IDX_ADD_MULTIPLE= 1;
- private static final int IDX_EDIT= 2;
- private static final int IDX_REMOVE= 4;
-
-
+
+ private static final int IDX_ADD = 0;
+ private static final int IDX_ADD_MULTIPLE = 1;
+ private static final int IDX_EDIT = 2;
+ private static final int IDX_REMOVE = 4;
+
public ExclusionPatternDialog(Shell parent, CPElement entryToEdit) {
super(parent);
- fCurrElement= entryToEdit;
- setTitle(CPathEntryMessages.ExclusionPatternDialog_title);
-
- String label= NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label, entryToEdit.getPath().makeRelative().toString());
-
- String[] buttonLabels= new String[] {
- CPathEntryMessages.ExclusionPatternDialog_pattern_add,
- CPathEntryMessages.ExclusionPatternDialog_pattern_add_multiple,
- CPathEntryMessages.ExclusionPatternDialog_pattern_edit,
- null,
- CPathEntryMessages.ExclusionPatternDialog_pattern_remove
- };
-
- ExclusionPatternAdapter adapter= new ExclusionPatternAdapter();
-
- fExclusionPatternList= new ListDialogField<String>(adapter, buttonLabels, new ExclusionPatternLabelProvider());
+ fCurrElement = entryToEdit;
+ setTitle(CPathEntryMessages.ExclusionPatternDialog_title);
+
+ String label = NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label,
+ entryToEdit.getPath().makeRelative().toString());
+
+ String[] buttonLabels = new String[] { CPathEntryMessages.ExclusionPatternDialog_pattern_add,
+ CPathEntryMessages.ExclusionPatternDialog_pattern_add_multiple,
+ CPathEntryMessages.ExclusionPatternDialog_pattern_edit, null,
+ CPathEntryMessages.ExclusionPatternDialog_pattern_remove };
+
+ ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
+
+ fExclusionPatternList = new ListDialogField<String>(adapter, buttonLabels, new ExclusionPatternLabelProvider());
fExclusionPatternList.setDialogFieldListener(adapter);
fExclusionPatternList.setLabelText(label);
fExclusionPatternList.setRemoveButtonIndex(IDX_REMOVE);
fExclusionPatternList.enableButton(IDX_EDIT, false);
-
- fCurrProject= entryToEdit.getCProject().getProject();
- IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot();
- IResource res= root.findMember(entryToEdit.getPath());
+
+ fCurrProject = entryToEdit.getCProject().getProject();
+ IWorkspaceRoot root = fCurrProject.getWorkspace().getRoot();
+ IResource res = root.findMember(entryToEdit.getPath());
if (res instanceof IContainer) {
- fCurrSourceFolder= (IContainer) res;
- }
-
- IPath[] pattern= (IPath[]) entryToEdit.getAttribute(CPElement.EXCLUSION);
-
- ArrayList<String> elements= new ArrayList<String>(pattern.length);
+ fCurrSourceFolder = (IContainer) res;
+ }
+
+ IPath[] pattern = (IPath[]) entryToEdit.getAttribute(CPElement.EXCLUSION);
+
+ ArrayList<String> elements = new ArrayList<String>(pattern.length);
for (IPath element : pattern) {
elements.add(element.toString());
}
@@ -127,26 +123,25 @@ public class ExclusionPatternDialog extends StatusDialog {
setHelpAvailable(false);
}
-
-
+
@Override
protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite)super.createDialogArea(parent);
+ Composite composite = (Composite) super.createDialogArea(parent);
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
+ Composite inner = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
inner.setLayout(layout);
-
+
fExclusionPatternList.doFillIntoGrid(inner, 3);
LayoutUtil.setHorizontalSpan(fExclusionPatternList.getLabelControl(null), 2);
-
- applyDialogFont(composite);
+
+ applyDialogFont(composite);
return composite;
}
-
+
protected void doCustomButtonPressed(ListDialogField<String> field, int index) {
if (index == IDX_ADD) {
addEntry();
@@ -156,44 +151,42 @@ public class ExclusionPatternDialog extends StatusDialog {
addMultipleEntries();
}
}
-
+
protected void doDoubleClicked(ListDialogField<String> field) {
editEntry();
}
-
+
protected void doSelectionChanged(ListDialogField<String> field) {
- List<String> selected= field.getSelectedElements();
+ List<String> selected = field.getSelectedElements();
fExclusionPatternList.enableButton(IDX_EDIT, canEdit(selected));
}
-
+
private boolean canEdit(List<String> selected) {
return selected.size() == 1;
}
-
+
private void editEntry() {
-
- List<String> selElements= fExclusionPatternList.getSelectedElements();
+
+ List<String> selElements = fExclusionPatternList.getSelectedElements();
if (selElements.size() != 1) {
return;
}
- List<String> existing= fExclusionPatternList.getElements();
- String entry= selElements.get(0);
- ExclusionPatternEntryDialog dialog= new ExclusionPatternEntryDialog(getShell(), entry, existing, fCurrElement);
+ List<String> existing = fExclusionPatternList.getElements();
+ String entry = selElements.get(0);
+ ExclusionPatternEntryDialog dialog = new ExclusionPatternEntryDialog(getShell(), entry, existing, fCurrElement);
if (dialog.open() == Window.OK) {
fExclusionPatternList.replaceElement(entry, dialog.getExclusionPattern());
}
}
-
+
private void addEntry() {
- List<String> existing= fExclusionPatternList.getElements();
- ExclusionPatternEntryDialog dialog= new ExclusionPatternEntryDialog(getShell(), null, existing, fCurrElement);
+ List<String> existing = fExclusionPatternList.getElements();
+ ExclusionPatternEntryDialog dialog = new ExclusionPatternEntryDialog(getShell(), null, existing, fCurrElement);
if (dialog.open() == Window.OK) {
fExclusionPatternList.addElement(dialog.getExclusionPattern());
}
- }
-
-
-
+ }
+
// -------- ExclusionPatternAdapter --------
private class ExclusionPatternAdapter implements IListAdapter<String>, IDialogFieldListener {
@@ -215,69 +208,68 @@ public class ExclusionPatternDialog extends StatusDialog {
@Override
public void dialogFieldChanged(DialogField field) {
}
-
+
}
-
+
protected void doStatusLineUpdate() {
- }
-
+ }
+
protected void checkIfPatternValid() {
}
-
-
+
public IPath[] getExclusionPattern() {
- IPath[] res= new IPath[fExclusionPatternList.getSize()];
- for (int i= 0; i < res.length; i++) {
- String entry= fExclusionPatternList.getElement(i);
- res[i]= new Path(entry);
+ IPath[] res = new IPath[fExclusionPatternList.getSize()];
+ for (int i = 0; i < res.length; i++) {
+ String entry = fExclusionPatternList.getElement(i);
+ res[i] = new Path(entry);
}
return res;
}
-
+
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
-// WorkbenchHelp.setHelp(newShell, ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
+ // WorkbenchHelp.setHelp(newShell, ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
}
-
+
private void addMultipleEntries() {
- Class<?>[] acceptedClasses= new Class<?>[] { IFolder.class, IFile.class };
- ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
- ViewerFilter filter= new TypedViewerFilter(acceptedClasses);
+ Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class };
+ ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, true);
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
- ILabelProvider lp= new WorkbenchLabelProvider();
- ITreeContentProvider cp= new WorkbenchContentProvider();
-
- IResource initialElement= null;
+ ILabelProvider lp = new WorkbenchLabelProvider();
+ ITreeContentProvider cp = new WorkbenchContentProvider();
- ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
- dialog.setTitle(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_title);
+ IResource initialElement = null;
+
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
+ dialog.setTitle(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_title);
dialog.setValidator(validator);
- dialog.setMessage(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_description);
+ dialog.setMessage(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_description);
dialog.addFilter(filter);
dialog.setInput(fCurrSourceFolder);
dialog.setInitialSelection(initialElement);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
- Object[] objects= dialog.getResult();
- int existingSegments= fCurrSourceFolder.getFullPath().segmentCount();
-
+ Object[] objects = dialog.getResult();
+ int existingSegments = fCurrSourceFolder.getFullPath().segmentCount();
+
for (Object object : objects) {
- IResource curr= (IResource) object;
- IPath path= curr.getFullPath().removeFirstSegments(existingSegments).makeRelative();
+ IResource curr = (IResource) object;
+ IPath path = curr.getFullPath().removeFirstSegments(existingSegments).makeRelative();
String res;
if (curr instanceof IContainer) {
- res= path.addTrailingSeparator().toString();
+ res = path.addTrailingSeparator().toString();
} else {
- res= path.toString();
+ res = path.toString();
}
fExclusionPatternList.addElement(res);
}
}
- }
-
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntryDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntryDialog.java
index 68591c5e579..b12b90e02cf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntryDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntryDialog.java
@@ -59,13 +59,14 @@ public class ExclusionPatternEntryDialog extends StatusDialog {
private String fExclusionPattern;
private List<String> fExistingPatterns;
- public ExclusionPatternEntryDialog(Shell parent, String patternToEdit, List<String> existingPatterns, CPElement entryToEdit) {
+ public ExclusionPatternEntryDialog(Shell parent, String patternToEdit, List<String> existingPatterns,
+ CPElement entryToEdit) {
super(parent);
fExistingPatterns = existingPatterns;
if (patternToEdit == null) {
- setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_add_title);
+ setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_add_title);
} else {
- setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_edit_title);
+ setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_edit_title);
fExistingPatterns.remove(patternToEdit);
}
@@ -77,13 +78,13 @@ public class ExclusionPatternEntryDialog extends StatusDialog {
fExclusionPatternStatus = new StatusInfo();
- String label = NLS.bind(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_label,
+ String label = NLS.bind(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_label,
entryToEdit.getPath().makeRelative().toString());
ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
fExclusionPatternDialog = new StringButtonDialogField(adapter);
fExclusionPatternDialog.setLabelText(label);
- fExclusionPatternDialog.setButtonLabel(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_button);
+ fExclusionPatternDialog.setButtonLabel(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_button);
fExclusionPatternDialog.setDialogFieldListener(adapter);
fExclusionPatternDialog.enableButton(fCurrSourceFolder != null);
@@ -110,7 +111,7 @@ public class ExclusionPatternEntryDialog extends StatusDialog {
inner.setLayout(layout);
Label description = new Label(inner, SWT.WRAP);
- description.setText(CPathEntryMessages.ExclusionPatternEntryDialog_description);
+ description.setText(CPathEntryMessages.ExclusionPatternEntryDialog_description);
GridData gd = new GridData();
gd.horizontalSpan = 2;
gd.widthHint = convertWidthInCharsToPixels(80);
@@ -161,16 +162,16 @@ public class ExclusionPatternEntryDialog extends StatusDialog {
protected void checkIfPatternValid() {
String pattern = fExclusionPatternDialog.getText().trim();
if (pattern.length() == 0) {
- fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_empty);
+ fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_empty);
return;
}
IPath path = new Path(pattern);
if (path.isAbsolute() || path.getDevice() != null) {
- fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_notrelative);
+ fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_notrelative);
return;
}
if (fExistingPatterns.contains(pattern)) {
- fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_exists);
+ fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_exists);
return;
}
@@ -195,7 +196,7 @@ public class ExclusionPatternEntryDialog extends StatusDialog {
// ---------- util method ------------
private IPath chooseExclusionPattern() {
- Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class};
+ Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class };
ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
@@ -219,9 +220,9 @@ public class ExclusionPatternEntryDialog extends StatusDialog {
}
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
- dialog.setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_title);
+ dialog.setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_title);
dialog.setValidator(validator);
- dialog.setMessage(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_description);
+ dialog.setMessage(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_description);
dialog.addFilter(filter);
dialog.setInput(fCurrSourceFolder);
dialog.setInitialSelection(initialElement);
@@ -229,7 +230,8 @@ public class ExclusionPatternEntryDialog extends StatusDialog {
if (dialog.open() == Window.OK) {
IResource res = (IResource) dialog.getFirstResult();
- IPath path = res.getFullPath().removeFirstSegments(fCurrSourceFolder.getFullPath().segmentCount()).makeRelative();
+ IPath path = res.getFullPath().removeFirstSegments(fCurrSourceFolder.getFullPath().segmentCount())
+ .makeRelative();
if (res instanceof IContainer) {
return path.addTrailingSeparator();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog.java
index 038ed147e90..9aaf7670e34 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog.java
@@ -37,7 +37,6 @@ import org.eclipse.ui.views.navigator.ResourceComparator;
import org.eclipse.cdt.internal.ui.util.SWTUtil;
-
/**
* @deprecated as of CDT 4.0. This class was used for property pages
* for 3.X style projects.
@@ -58,12 +57,12 @@ public class FolderSelectionDialog extends ElementTreeSelectionDialog implements
*/
@Override
protected Control createDialogArea(Composite parent) {
- Composite result= (Composite)super.createDialogArea(parent);
-
+ Composite result = (Composite) super.createDialogArea(parent);
+
getTreeViewer().addSelectionChangedListener(this);
-
+
Button button = new Button(result, SWT.PUSH);
- button.setText(CPathEntryMessages.FolderSelectionDialog_button);
+ button.setText(CPathEntryMessages.FolderSelectionDialog_button);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
@@ -73,35 +72,35 @@ public class FolderSelectionDialog extends ElementTreeSelectionDialog implements
button.setFont(parent.getFont());
button.setLayoutData(new GridData());
SWTUtil.setButtonDimensionHint(button);
- fNewFolderButton= button;
-
- applyDialogFont(result);
+ fNewFolderButton = button;
+
+ applyDialogFont(result);
return result;
}
private void updateNewFolderButtonState() {
- IStructuredSelection selection= (IStructuredSelection) getTreeViewer().getSelection();
- fSelectedContainer= null;
+ IStructuredSelection selection = (IStructuredSelection) getTreeViewer().getSelection();
+ fSelectedContainer = null;
if (selection.size() == 1) {
- Object first= selection.getFirstElement();
+ Object first = selection.getFirstElement();
if (first instanceof IContainer) {
- fSelectedContainer= (IContainer) first;
+ fSelectedContainer = (IContainer) first;
}
}
fNewFolderButton.setEnabled(fSelectedContainer != null);
- }
-
+ }
+
protected void newFolderButtonPressed() {
- NewFolderDialog dialog= new NewFolderDialog(getShell(), fSelectedContainer);
+ NewFolderDialog dialog = new NewFolderDialog(getShell(), fSelectedContainer);
if (dialog.open() == Window.OK) {
- TreeViewer treeViewer= getTreeViewer();
+ TreeViewer treeViewer = getTreeViewer();
treeViewer.refresh(fSelectedContainer);
- Object createdFolder= dialog.getResult()[0];
+ Object createdFolder = dialog.getResult()[0];
treeViewer.reveal(createdFolder);
treeViewer.setSelection(new StructuredSelection(createdFolder));
}
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.java
index fae557b2b44..99bf0eeecbc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.java
@@ -21,7 +21,10 @@ import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
public interface IContainerDescriptor {
public IPathEntryContainerPage createPage() throws CoreException;
+
public String getName();
+
public Image getImage();
+
public boolean canEdit(IPathEntry entry);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsPropertyPage.java
index c4ab660caed..98e43da4df3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsPropertyPage.java
@@ -50,7 +50,8 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
/**
* @noreference This class is not intended to be referenced by clients.
*/
-public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatusChangeListener, IPathEntryStoreListener {
+public class IncludesSymbolsPropertyPage extends PropertyPage
+ implements IStatusChangeListener, IPathEntryStoreListener {
private static final String PAGE_SETTINGS = "IncludeSysmbolsPropertyPage"; //$NON-NLS-1$
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
@@ -102,7 +103,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
*/
private Control createWithoutCProject(Composite parent) {
Label label = new Label(parent, SWT.LEFT);
- label.setText(CPathEntryMessages.CPathsPropertyPage_no_C_project_message);
+ label.setText(CPathEntryMessages.CPathsPropertyPage_no_C_project_message);
fIncludesSymbolsBlock = null;
setValid(true);
@@ -114,7 +115,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
*/
private Control createForClosedProject(Composite parent) {
Label label = new Label(parent, SWT.LEFT);
- label.setText(CPathEntryMessages.CPathsPropertyPage_closed_project_message);
+ label.setText(CPathEntryMessages.CPathsPropertyPage_closed_project_message);
fIncludesSymbolsBlock = null;
setValid(true);
@@ -123,7 +124,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.dialogs.IDialogPage#dispose()
*/
@Override
@@ -132,18 +133,17 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
fStore.removePathEntryStoreListener(this);
}
}
-
+
@Override
public void setVisible(boolean visible) {
if (fIncludesSymbolsBlock != null) {
if (!visible) {
if (fIncludesSymbolsBlock.hasChangesInDialog()) {
- String title = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_title;
- String message = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_message;
- String[] buttonLabels = new String[]{
- CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_save,
- CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_discard,
- };
+ String title = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_title;
+ String message = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_message;
+ String[] buttonLabels = new String[] {
+ CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_save,
+ CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_discard, };
MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
buttonLabels, 0);
int res = dialog.open();
@@ -213,8 +213,8 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
try {
new ProgressMonitorDialog(shell).run(true, true, op);
} catch (InvocationTargetException e) {
- String title = CPathEntryMessages.CPathsPropertyPage_error_title;
- String message = CPathEntryMessages.CPathsPropertyPage_error_message;
+ String title = CPathEntryMessages.CPathsPropertyPage_error_title;
+ String message = CPathEntryMessages.CPathsPropertyPage_error_message;
ExceptionHandler.handle(e, shell, title, message);
return false;
} catch (InterruptedException e) {
@@ -227,7 +227,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
/*
* (non-Javadoc)
- *
+ *
* @see IStatusChangeListener#statusChanged
*/
@Override
@@ -238,7 +238,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.preference.IPreferencePage#performCancel()
*/
@Override
@@ -251,7 +251,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent)
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelectionDialog.java
index e0263a19889..c89e3e41db9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelectionDialog.java
@@ -68,7 +68,8 @@ public class MultipleFolderSelectionDialog extends SelectionStatusDialog impleme
Set<Object> fExisting;
private Object fFocusElement;
- public MultipleFolderSelectionDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
+ public MultipleFolderSelectionDialog(Shell parent, ILabelProvider labelProvider,
+ ITreeContentProvider contentProvider) {
super(parent);
fLabelProvider = labelProvider;
fContentProvider = contentProvider;
@@ -93,7 +94,7 @@ public class MultipleFolderSelectionDialog extends SelectionStatusDialog impleme
/**
* Sets the tree input.
- *
+ *
* @param input
* the tree input.
*/
@@ -103,7 +104,7 @@ public class MultipleFolderSelectionDialog extends SelectionStatusDialog impleme
/**
* Adds a filter to the tree viewer.
- *
+ *
* @param filter
* a filter.
*/
@@ -183,7 +184,7 @@ public class MultipleFolderSelectionDialog extends SelectionStatusDialog impleme
/**
* Creates the tree viewer.
- *
+ *
* @param parent
* the parent composite
* @return the tree viewer
@@ -213,7 +214,7 @@ public class MultipleFolderSelectionDialog extends SelectionStatusDialog impleme
}
/**
- *
+ *
*/
protected void updateOKStatus() {
computeResult();
@@ -226,7 +227,7 @@ public class MultipleFolderSelectionDialog extends SelectionStatusDialog impleme
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
@@ -245,7 +246,7 @@ public class MultipleFolderSelectionDialog extends SelectionStatusDialog impleme
treeWidget.setFont(composite.getFont());
Button button = new Button(composite, SWT.PUSH);
- button.setText(CPathEntryMessages.MultipleFolderSelectionDialog_button);
+ button.setText(CPathEntryMessages.MultipleFolderSelectionDialog_button);
button.addSelectionListener(new SelectionAdapter() {
@Override
@@ -315,7 +316,7 @@ public class MultipleFolderSelectionDialog extends SelectionStatusDialog impleme
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTabBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTabBlock.java
index 2c686d7f110..e7712ae153f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTabBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTabBlock.java
@@ -75,56 +75,55 @@ public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock implemen
protected List<CPElement> getCPaths() {
if (fIncludeSymbols != null) {
return fIncludeSymbols.getCPaths();
- }
+ }
return fCPaths;
}
@Override
protected int[] getFilteredTypes() {
- return new int[] {IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER};
+ return new int[] { IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER };
}
@Override
protected int[] getAppliedFilteredTypes() {
- return new int[] {IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO};
+ return new int[] { IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO };
}
-
+
@Override
protected void initialize(ICElement element, List<CPElement> cPaths) {
fCPaths = cPaths;
if (element instanceof ICProject) {
- fIncludeSymbols = new CPathIncludeSymbolEntryPage(this);
- }
- else {
- fIncludeSymbols = new CPathIncludeSymbolEntryPerFilePage(this);
- }
- if (fIncludeSymbols != null) {
+ fIncludeSymbols = new CPathIncludeSymbolEntryPage(this);
+ } else {
+ fIncludeSymbols = new CPathIncludeSymbolEntryPerFilePage(this);
+ }
+ if (fIncludeSymbols != null) {
fIncludeSymbols.init(element, cPaths);
}
doStatusLineUpdate();
initializeTimeStamps();
}
-
+
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
*/
@Override
public void statusChanged(IStatus status) {
switch (status.getSeverity()) {
- case IStatus.ERROR :
- getPathStatus().setError(status.getMessage());
- break;
- case IStatus.INFO :
- getPathStatus().setInfo(status.getMessage());
- break;
- case IStatus.WARNING :
- getPathStatus().setWarning(status.getMessage());
- break;
- default:
- getPathStatus().setOK();
+ case IStatus.ERROR:
+ getPathStatus().setError(status.getMessage());
+ break;
+ case IStatus.INFO:
+ getPathStatus().setInfo(status.getMessage());
+ break;
+ case IStatus.WARNING:
+ getPathStatus().setWarning(status.getMessage());
+ break;
+ default:
+ getPathStatus().setOK();
}
updateBuildPathStatus();
doStatusLineUpdate();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog.java
index 516c27c9a1b..e5bb587caa0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog.java
@@ -53,7 +53,8 @@ public class NewSourceFolderDialog extends StatusDialog {
private List<IContainer> fExistingFolders;
private IProject fCurrProject;
- public NewSourceFolderDialog(Shell parent, String title, IProject project, List<IContainer> existingFolders, CPElement entryToEdit) {
+ public NewSourceFolderDialog(Shell parent, String title, IProject project, List<IContainer> existingFolders,
+ CPElement entryToEdit) {
super(parent);
setTitle(title);
@@ -62,16 +63,16 @@ public class NewSourceFolderDialog extends StatusDialog {
SourceContainerAdapter adapter = new SourceContainerAdapter();
fUseProjectButton = new SelectionButtonDialogField(SWT.RADIO);
- fUseProjectButton.setLabelText(CPathEntryMessages.NewSourceFolderDialog_useproject_button);
+ fUseProjectButton.setLabelText(CPathEntryMessages.NewSourceFolderDialog_useproject_button);
fUseProjectButton.setDialogFieldListener(adapter);
fUseFolderButton = new SelectionButtonDialogField(SWT.RADIO);
- fUseFolderButton.setLabelText(CPathEntryMessages.NewSourceFolderDialog_usefolder_button);
+ fUseFolderButton.setLabelText(CPathEntryMessages.NewSourceFolderDialog_usefolder_button);
fUseFolderButton.setDialogFieldListener(adapter);
fContainerDialogField = new StringDialogField();
fContainerDialogField.setDialogFieldListener(adapter);
- fContainerDialogField.setLabelText(CPathEntryMessages.NewSourceFolderDialog_sourcefolder_label);
+ fContainerDialogField.setLabelText(CPathEntryMessages.NewSourceFolderDialog_sourcefolder_label);
fUseFolderButton.attachDialogField(fContainerDialogField);
@@ -154,7 +155,7 @@ public class NewSourceFolderDialog extends StatusDialog {
if (fUseFolderButton.isSelected()) {
String pathStr = fContainerDialogField.getText();
if (pathStr.length() == 0) {
- fContainerFieldStatus.setError(CPathEntryMessages.NewSourceFolderDialog_error_enterpath);
+ fContainerFieldStatus.setError(CPathEntryMessages.NewSourceFolderDialog_error_enterpath);
return;
}
IPath path = fCurrProject.getFullPath().append(pathStr);
@@ -162,7 +163,7 @@ public class NewSourceFolderDialog extends StatusDialog {
IStatus pathValidation = workspace.validatePath(path.toString(), IResource.FOLDER);
if (!pathValidation.isOK()) {
- fContainerFieldStatus.setError(NLS.bind(CPathEntryMessages.NewSourceFolderDialog_error_invalidpath,
+ fContainerFieldStatus.setError(NLS.bind(CPathEntryMessages.NewSourceFolderDialog_error_invalidpath,
pathValidation.getMessage()));
return;
}
@@ -171,7 +172,7 @@ public class NewSourceFolderDialog extends StatusDialog {
folder = fCurrProject;
}
if (isExisting(folder)) {
- fContainerFieldStatus.setError(CPathEntryMessages.NewSourceFolderDialog_error_pathexists);
+ fContainerFieldStatus.setError(CPathEntryMessages.NewSourceFolderDialog_error_pathexists);
return;
}
fContainerFieldStatus.setOK();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescriptor.java
index ef344abb5bb..eabfae4ff9f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescriptor.java
@@ -23,7 +23,7 @@ import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
public class ProjectContainerDescriptor implements IContainerDescriptor {
private int[] fFilterType;
-
+
public ProjectContainerDescriptor(int[] filterType) {
fFilterType = filterType;
}
@@ -35,9 +35,9 @@ public class ProjectContainerDescriptor implements IContainerDescriptor {
@Override
public String getName() {
- return CPathEntryMessages.ProjectContainer_label;
+ return CPathEntryMessages.ProjectContainer_label;
}
-
+
@Override
public Image getImage() {
return CUIPlugin.getDefault().getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT);
@@ -49,5 +49,4 @@ public class ProjectContainerDescriptor implements IContainerDescriptor {
return false;
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.java
index 97b1b45c40f..8679b6ec63e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.java
@@ -52,8 +52,8 @@ public class ProjectContainerPage extends WizardPage implements IPathEntryContai
protected ProjectContainerPage(int[] filterType) {
super("projectContainerPage"); //$NON-NLS-1$
- setTitle(CPathEntryMessages.ProjectContainerPage_title);
- setDescription(CPathEntryMessages.ProjectContainerPage_description);
+ setTitle(CPathEntryMessages.ProjectContainerPage_title);
+ setDescription(CPathEntryMessages.ProjectContainerPage_description);
setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
fFilterType = filterType;
validatePage();
@@ -73,7 +73,7 @@ public class ProjectContainerPage extends WizardPage implements IPathEntryContai
public IContainerEntry[] getNewContainers() {
return new IContainerEntry[0];
}
-
+
IProjectEntry getProjectEntry() {
if (viewer != null) {
ISelection selection = viewer.getSelection();
@@ -87,13 +87,13 @@ public class ProjectContainerPage extends WizardPage implements IPathEntryContai
}
return null;
}
-
+
void setProjectEntry(IProjectEntry entry) {
if (entry != null) {
viewer.setSelection(new StructuredSelection(entry));
}
}
-
+
@Override
public void setSelection(IContainerEntry containerEntry) {
}
@@ -106,7 +106,7 @@ public class ProjectContainerPage extends WizardPage implements IPathEntryContai
layout.numColumns = 2;
container.setLayout(layout);
Label label = new Label(container, SWT.NULL);
- label.setText(CPathEntryMessages.ProjectContainerPage_label);
+ label.setText(CPathEntryMessages.ProjectContainerPage_label);
GridData gd = new GridData();
gd.horizontalSpan = 2;
label.setLayoutData(gd);
@@ -145,7 +145,8 @@ public class ProjectContainerPage extends WizardPage implements IPathEntryContai
ICProject[] cProjects = CoreModel.getDefault().getCModel().getCProjects();
for (int i = 0; i < cProjects.length; i++) {
boolean added = false;
- if (!cProjects[i].equals(fCProject) && !current.contains(CoreModel.newProjectEntry(cProjects[i].getPath()))) {
+ if (!cProjects[i].equals(fCProject)
+ && !current.contains(CoreModel.newProjectEntry(cProjects[i].getPath()))) {
IPathEntry[] projEntries = cProjects[i].getRawPathEntries();
for (IPathEntry projEntrie : projEntries) {
for (int element : fFilterType) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java
index 478464ce567..90ab6904cc8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java
@@ -72,7 +72,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
/**
* UI to set the source attachment archive and root. Same implementation for both setting attachments for libraries from variable
* entries and for normal (internal or external) jar.
- *
+ *
* @deprecated as of CDT 4.0. This class was used for property pages
* for 3.X style projects.
*/
@@ -110,7 +110,7 @@ public class SourceAttachmentBlock {
* @param project
* Project to which the entry belongs. Can be <code>null</code> if <code>getRunnable</code> is not run and the
* entry does not belong to a container.
- *
+ *
*/
public SourceAttachmentBlock(IStatusChangeListener context, ILibraryEntry entry, ICProject project) {
Assert.isNotNull(entry);
@@ -127,16 +127,16 @@ public class SourceAttachmentBlock {
fFileNameField = new StringButtonDialogField(adapter);
fFileNameField.setDialogFieldListener(adapter);
- fFileNameField.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_label);
- fFileNameField.setButtonLabel(CPathEntryMessages.SourceAttachmentBlock_filename_externalfile_button);
+ fFileNameField.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_label);
+ fFileNameField.setButtonLabel(CPathEntryMessages.SourceAttachmentBlock_filename_externalfile_button);
fWorkspaceButton = new SelectionButtonDialogField(SWT.PUSH);
fWorkspaceButton.setDialogFieldListener(adapter);
- fWorkspaceButton.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_internal_button);
+ fWorkspaceButton.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_internal_button);
fExternalFolderButton = new SelectionButtonDialogField(SWT.PUSH);
fExternalFolderButton.setDialogFieldListener(adapter);
- fExternalFolderButton.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_externalfolder_button);
+ fExternalFolderButton.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_externalfolder_button);
// set the old settings
setDefaults();
@@ -197,8 +197,8 @@ public class SourceAttachmentBlock {
Label message = new Label(composite, SWT.LEFT);
message.setLayoutData(gd);
- message.setText(NLS.bind(
- CPathEntryMessages.SourceAttachmentBlock_message, fEntry.getLibraryPath().lastSegment()));
+ message.setText(
+ NLS.bind(CPathEntryMessages.SourceAttachmentBlock_message, fEntry.getLibraryPath().lastSegment()));
fWorkspaceButton.doFillIntoGrid(composite, 1);
@@ -272,7 +272,7 @@ public class SourceAttachmentBlock {
fFullPathResolvedLabel.setText(getResolvedLabelString(fFileNameField.getText(), true));
}
- IStatus status = StatusUtil.getMostSevere(new IStatus[]{fNameStatus});
+ IStatus status = StatusUtil.getMostSevere(new IStatus[] { fNameStatus });
fContext.statusChanged(status);
}
@@ -307,7 +307,7 @@ public class SourceAttachmentBlock {
return status;
}
if (!Path.EMPTY.isValidPath(fileName)) {
- status.setError(CPathEntryMessages.SourceAttachmentBlock_filename_error_notvalid);
+ status.setError(CPathEntryMessages.SourceAttachmentBlock_filename_error_notvalid);
return status;
}
IPath filePath = new Path(fileName);
@@ -317,8 +317,8 @@ public class SourceAttachmentBlock {
file = res.getLocation().toFile();
}
if (!file.exists()) {
- String message = NLS.bind(
- CPathEntryMessages.SourceAttachmentBlock_filename_error_filenotexists, filePath.toString());
+ String message = NLS.bind(CPathEntryMessages.SourceAttachmentBlock_filename_error_filenotexists,
+ filePath.toString());
status.setError(message);
return status;
}
@@ -339,8 +339,8 @@ public class SourceAttachmentBlock {
}
FileDialog dialog = new FileDialog(getShell());
- dialog.setText(CPathEntryMessages.SourceAttachmentBlock_extjardialog_text);
- dialog.setFilterExtensions(new String[]{"*.jar;*.zip"}); //$NON-NLS-1$
+ dialog.setText(CPathEntryMessages.SourceAttachmentBlock_extjardialog_text);
+ dialog.setFilterExtensions(new String[] { "*.jar;*.zip" }); //$NON-NLS-1$
dialog.setFilterPath(currPath.toOSString());
String res = dialog.open();
if (res != null) {
@@ -359,7 +359,7 @@ public class SourceAttachmentBlock {
}
DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setText(CPathEntryMessages.SourceAttachmentBlock_extfolderdialog_text);
+ dialog.setText(CPathEntryMessages.SourceAttachmentBlock_extfolderdialog_text);
dialog.setFilterPath(currPath.toOSString());
String res = dialog.open();
if (res != null) {
@@ -374,7 +374,7 @@ public class SourceAttachmentBlock {
private IPath chooseInternalJarFile() {
String initSelection = fFileNameField.getText();
- Class<?>[] acceptedClasses = new Class<?>[]{IFolder.class, IFile.class};
+ Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class };
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
ViewerFilter filter = new ArchiveFileFilter(null, false);
@@ -394,12 +394,12 @@ public class SourceAttachmentBlock {
dialog.setAllowMultiple(false);
dialog.setValidator(validator);
dialog.addFilter(filter);
- dialog.setTitle(CPathEntryMessages.SourceAttachmentBlock_intjardialog_title);
- dialog.setMessage(CPathEntryMessages.SourceAttachmentBlock_intjardialog_message);
+ dialog.setTitle(CPathEntryMessages.SourceAttachmentBlock_intjardialog_title);
+ dialog.setMessage(CPathEntryMessages.SourceAttachmentBlock_intjardialog_message);
dialog.setInput(fWorkspaceRoot);
dialog.setInitialSelection(initSel);
if (dialog.open() == Window.OK) {
- IResource res = (IResource)dialog.getFirstResult();
+ IResource res = (IResource) dialog.getFirstResult();
return res.getFullPath();
}
return null;
@@ -441,12 +441,13 @@ public class SourceAttachmentBlock {
boolean isExported = fEntry.isExported();
ILibraryEntry newEntry;
newEntry = CoreModel.newLibraryEntry(fEntry.getPath(), fEntry.getBasePath(), fEntry.getLibraryPath(),
- getSourceAttachmentPath(), getSourceAttachmentRootPath(), getSourceAttachmentPrefixMapping(), isExported);
+ getSourceAttachmentPath(), getSourceAttachmentRootPath(), getSourceAttachmentPrefixMapping(),
+ isExported);
updateProjectPathEntry(shell, fProject, newEntry, monitor);
}
- private void updateProjectPathEntry(Shell shell, ICProject cproject, ILibraryEntry newEntry, IProgressMonitor monitor)
- throws CModelException {
+ private void updateProjectPathEntry(Shell shell, ICProject cproject, ILibraryEntry newEntry,
+ IProgressMonitor monitor) throws CModelException {
IPathEntry[] oldClasspath = cproject.getRawPathEntries();
int nEntries = oldClasspath.length;
ArrayList<IPathEntry> newEntries = new ArrayList<IPathEntry>(nEntries + 1);
@@ -480,8 +481,8 @@ public class SourceAttachmentBlock {
@Override
public void run() {
- String title = CPathEntryMessages.SourceAttachmentBlock_putoncpdialog_title;
- String message = CPathEntryMessages.SourceAttachmentBlock_putoncpdialog_message;
+ String title = CPathEntryMessages.SourceAttachmentBlock_putoncpdialog_title;
+ String message = CPathEntryMessages.SourceAttachmentBlock_putoncpdialog_message;
result[0] = MessageDialog.openQuestion(CUIPlugin.getActiveWorkbenchShell(), title, message);
}
});
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialog.java
index 39c50b04795..f70df6e18a7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialog.java
@@ -42,7 +42,7 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
*/
@Deprecated
public class SourceAttachmentDialog extends StatusDialog {
-
+
private SourceAttachmentBlock fSourceAttachmentBlock;
private boolean fApplyChanges;
@@ -50,7 +50,7 @@ public class SourceAttachmentDialog extends StatusDialog {
* Creates an instance of the SourceAttachmentDialog. After
* <code>open</code>, the edited paths can be access with
* <code>getSourceAttachmentPath</code> and
- * <code>getSourceAttachmentRootPath</code>.
+ * <code>getSourceAttachmentRootPath</code>.
* @param parent Parent shell for the dialog
* @param entry The entry to edit
* @param project Project to which the entry belongs. Can be
@@ -63,20 +63,20 @@ public class SourceAttachmentDialog extends StatusDialog {
*/
public SourceAttachmentDialog(Shell parent, ILibraryEntry entry, ICProject project, boolean applyChanges) {
super(parent);
- fApplyChanges= applyChanges;
+ fApplyChanges = applyChanges;
- IStatusChangeListener listener= new IStatusChangeListener() {
+ IStatusChangeListener listener = new IStatusChangeListener() {
@Override
public void statusChanged(IStatus status) {
updateStatus(status);
}
- };
- fSourceAttachmentBlock= new SourceAttachmentBlock(listener, entry, project);
-
- setTitle(CPathEntryMessages.SourceAttachmentDialog_title);
+ };
+ fSourceAttachmentBlock = new SourceAttachmentBlock(listener, entry, project);
+
+ setTitle(CPathEntryMessages.SourceAttachmentDialog_title);
setHelpAvailable(false);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/
@@ -84,29 +84,28 @@ public class SourceAttachmentDialog extends StatusDialog {
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
//WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.SOURCE_ATTACHMENT_DIALOG);
- }
-
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Control inner= createSourceAttachmentControls(composite);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
- applyDialogFont(composite);
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Control inner = createSourceAttachmentControls(composite);
+ inner.setLayoutData(new GridData(GridData.FILL_BOTH));
+ applyDialogFont(composite);
return composite;
}
/**
* Creates the controls for the source attachment configuration.
- */
+ */
protected Control createSourceAttachmentControls(Composite composite) {
return fSourceAttachmentBlock.createControl(composite);
}
-
-
+
/**
* Returns the configured source attachment path.
*/
@@ -118,11 +117,11 @@ public class SourceAttachmentDialog extends StatusDialog {
* Returns the configured source attachment path root. Sonce 2.1 source
* attachment roots are autodetected. The value returned is therefore always
* null.
- */
+ */
public IPath getSourceAttachmentRootPath() {
return fSourceAttachmentBlock.getSourceAttachmentRootPath();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@@ -131,24 +130,24 @@ public class SourceAttachmentDialog extends StatusDialog {
super.okPressed();
if (fApplyChanges) {
try {
- IRunnableWithProgress runnable= getRunnable();
- new ProgressMonitorDialog(getShell()).run(true, true, runnable);
-
+ IRunnableWithProgress runnable = getRunnable();
+ new ProgressMonitorDialog(getShell()).run(true, true, runnable);
+
} catch (InvocationTargetException e) {
- String title= CPathEntryMessages.SourceAttachmentDialog_error_title;
- String message= CPathEntryMessages.SourceAttachmentDialog_error_message;
+ String title = CPathEntryMessages.SourceAttachmentDialog_error_title;
+ String message = CPathEntryMessages.SourceAttachmentDialog_error_message;
ExceptionHandler.handle(e, getShell(), title, message);
-
+
} catch (InterruptedException e) {
// cancelled
}
}
}
-
+
/**
* Creates the runnable that configures the project with the new source
* attachements.
- */
+ */
protected IRunnableWithProgress getRunnable() {
return fSourceAttachmentBlock.getRunnable(getShell());
}
@@ -163,8 +162,9 @@ public class SourceAttachmentDialog extends StatusDialog {
* @param libPath The path of the bibrary to be found
* @return IClasspathEntry A classpath entry from the container of
* <code>null</code> if the container can not be modified.
- */
- public static IPathEntry getPathEntryToEdit(ICProject jproject, IPath containerPath, IPath libPath) throws CModelException {
+ */
+ public static IPathEntry getPathEntryToEdit(ICProject jproject, IPath containerPath, IPath libPath)
+ throws CModelException {
//IPathEntryContainer container= CoreModel.getPathEntryContainer(containerPath, jproject);
//PathEntryContainerInitializer initializer= CoreModel.getPathEntryContainerInitializer(containerPath.segment(0));
//if (container != null && initializer != null && initializer.canUpdateClasspathContainer(containerPath, jproject)) {
@@ -178,8 +178,6 @@ public class SourceAttachmentDialog extends StatusDialog {
// }
//}
return null; // attachment not possible
- }
-
-
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
index bea8c326f88..28ba0aad58e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
@@ -25,12 +25,12 @@ import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.Transfer;
public class BasicSelectionTransferDragAdapter extends DragSourceAdapter implements TransferDragSourceListener {
-
+
private ISelectionProvider fProvider;
-
+
public BasicSelectionTransferDragAdapter(ISelectionProvider provider) {
Assert.isNotNull(provider);
- fProvider= provider;
+ fProvider = provider;
}
/**
@@ -40,51 +40,49 @@ public class BasicSelectionTransferDragAdapter extends DragSourceAdapter impleme
public Transfer getTransfer() {
return LocalSelectionTransfer.getTransfer();
}
-
+
/* non Java-doc
* @see org.eclipse.swt.dnd.DragSourceListener#dragStart
*/
@Override
public void dragStart(DragSourceEvent event) {
- ISelection selection= fProvider.getSelection();
+ ISelection selection = fProvider.getSelection();
LocalSelectionTransfer.getTransfer().setSelection(selection);
LocalSelectionTransfer.getTransfer().setSelectionSetTime(event.time & 0xFFFFFFFFL);
- event.doit= isDragable(selection);
+ event.doit = isDragable(selection);
}
-
+
/**
* Checks if the elements contained in the given selection can
* be dragged.
* <p>
* Subclasses may override.
- *
+ *
* @param selection containing the elements to be dragged
*/
protected boolean isDragable(ISelection selection) {
return true;
}
-
/* non Java-doc
* @see org.eclipse.swt.dnd.DragSourceListener#dragSetData
- */
+ */
@Override
public void dragSetData(DragSourceEvent event) {
// For consistency set the data to the selection even though
// the selection is provided by the LocalSelectionTransfer
// to the drop target adapter.
- event.data= LocalSelectionTransfer.getTransfer().getSelection();
+ event.data = LocalSelectionTransfer.getTransfer().getSelection();
}
-
/* non Java-doc
* @see org.eclipse.swt.dnd.DragSourceListener#dragFinished
- */
+ */
@Override
public void dragFinished(DragSourceEvent event) {
// Make sure we don't have to do any remaining work
Assert.isTrue(event.detail != DND.DROP_MOVE);
LocalSelectionTransfer.getTransfer().setSelection(null);
LocalSelectionTransfer.getTransfer().setSelectionSetTime(0);
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.java
index 1ece0dc1c11..03e688af1b9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.java
@@ -29,15 +29,15 @@ public class CDTViewerDragAdapter extends DelegatingDragAdapter {
public CDTViewerDragAdapter(StructuredViewer viewer, TransferDragSourceListener[] listeners) {
super(listeners);
Assert.isNotNull(viewer);
- fViewer= viewer;
+ fViewer = viewer;
}
-
+
@Override
public void dragStart(DragSourceEvent event) {
- IStructuredSelection selection= (IStructuredSelection)fViewer.getSelection();
+ IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
if (selection.isEmpty()) {
- event.doit= false;
- return;
+ event.doit = false;
+ return;
}
super.dragStart(event);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.java
index ecb70479cac..696b24646e7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.java
@@ -34,43 +34,43 @@ import org.eclipse.swt.widgets.TreeItem;
public class CDTViewerDropAdapter implements DropTargetListener {
/**
- * Constant describing the position of the mouse cursor relative
+ * Constant describing the position of the mouse cursor relative
* to the target object. This means the mouse is not positioned
* over or near any valid target.
*/
- public static final int LOCATION_NONE= DND.FEEDBACK_NONE;
-
+ public static final int LOCATION_NONE = DND.FEEDBACK_NONE;
+
/**
- * Constant describing the position of the mouse cursor relative
+ * Constant describing the position of the mouse cursor relative
* to the target object. This means the mouse is positioned
* directly on the target.
*/
- public static final int LOCATION_ON= DND.FEEDBACK_SELECT;
-
+ public static final int LOCATION_ON = DND.FEEDBACK_SELECT;
+
/**
- * Constant describing the position of the mouse cursor relative
+ * Constant describing the position of the mouse cursor relative
* to the target object. This means the mouse is positioned
* slightly before the target.
*/
- public static final int LOCATION_BEFORE= DND.FEEDBACK_INSERT_BEFORE;
-
+ public static final int LOCATION_BEFORE = DND.FEEDBACK_INSERT_BEFORE;
+
/**
- * Constant describing the position of the mouse cursor relative
+ * Constant describing the position of the mouse cursor relative
* to the target object. This means the mouse is positioned
* slightly after the target.
*/
- public static final int LOCATION_AFTER= DND.FEEDBACK_INSERT_AFTER;
-
+ public static final int LOCATION_AFTER = DND.FEEDBACK_INSERT_AFTER;
+
/**
* The threshold used to determine if the mouse is before or after
* an item.
*/
- private static final int LOCATION_EPSILON= 5;
-
+ private static final int LOCATION_EPSILON = 5;
+
/**
* Style to enable location feedback.
*/
- public static final int INSERTION_FEEDBACK= 1 << 1;
+ public static final int INSERTION_FEEDBACK = 1 << 1;
private StructuredViewer fViewer;
private int fFeedback;
@@ -82,58 +82,58 @@ public class CDTViewerDropAdapter implements DropTargetListener {
public CDTViewerDropAdapter(StructuredViewer viewer, int feedback) {
Assert.isNotNull(viewer);
- fViewer= viewer;
- fFeedback= feedback;
- fLastOperation= -1;
+ fViewer = viewer;
+ fFeedback = feedback;
+ fLastOperation = -1;
}
/**
* Controls whether the drop adapter shows insertion feedback or not.
- *
+ *
* @param showInsertionFeedback <code>true</code> if the drop adapter is supposed
* to show insertion feedback. Otherwise <code>false</code>
*/
public void showInsertionFeedback(boolean showInsertionFeedback) {
- fShowInsertionFeedback= showInsertionFeedback;
+ fShowInsertionFeedback = showInsertionFeedback;
}
-
+
/**
* Returns the viewer this adapter is working on.
*/
protected StructuredViewer getViewer() {
return fViewer;
- }
-
+ }
+
//---- Hooks to override -----------------------------------------------------
-
+
/**
* The actual drop has occurred. Calls <code>drop(Object target, DropTargetEvent event)
* </code>.
* @see DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
- */
+ */
@Override
public void drop(DropTargetEvent event) {
drop(fTarget, event);
}
-
+
/**
* The actual drop has occurred.
* @param target the drop target in form of a domain element.
* @param event the drop traget event
- */
+ */
public void drop(Object target, DropTargetEvent event) {
}
-
+
/**
* Checks if the drop is valid. The method calls <code>validateDrop
- * (Object target, DropTargetEvent event). Implementors can alter the
- * <code>currentDataType</code> field and the <code>detail</code> field
+ * (Object target, DropTargetEvent event). Implementors can alter the
+ * <code>currentDataType</code> field and the <code>detail</code> field
* to give feedback about drop acceptence.
*/
public void validateDrop(DropTargetEvent event) {
validateDrop(fTarget, event, fRequestedOperation);
}
-
+
/**
* Checks if the drop on the current target is valid. The method
* can alter the <code>currentDataType</code> field and the <code>
@@ -144,52 +144,52 @@ public class CDTViewerDropAdapter implements DropTargetListener {
*/
public void validateDrop(Object target, DropTargetEvent event, int operation) {
}
-
+
@Override
public void dragEnter(DropTargetEvent event) {
dragOperationChanged(event);
}
-
+
@Override
public void dragLeave(DropTargetEvent event) {
- fTarget= null;
- fLocation= LOCATION_NONE;
+ fTarget = null;
+ fLocation = LOCATION_NONE;
}
-
+
@Override
public void dragOperationChanged(DropTargetEvent event) {
- fRequestedOperation= event.detail;
- fTarget= computeTarget(event);
- fLocation= computeLocation(event);
+ fRequestedOperation = event.detail;
+ fTarget = computeTarget(event);
+ fLocation = computeLocation(event);
validateDrop(event);
- fLastOperation= event.detail;
+ fLastOperation = event.detail;
computeFeedback(event);
}
-
+
@Override
public void dragOver(DropTargetEvent event) {
- Object oldTarget= fTarget;
- fTarget= computeTarget(event);
-
+ Object oldTarget = fTarget;
+ fTarget = computeTarget(event);
+
//set the location feedback
- int oldLocation= fLocation;
- fLocation= computeLocation(event);
+ int oldLocation = fLocation;
+ fLocation = computeLocation(event);
if (oldLocation != fLocation || oldTarget != fTarget || fLastOperation != event.detail) {
validateDrop(event);
- fLastOperation= event.detail;
+ fLastOperation = event.detail;
} else {
- event.detail= fLastOperation;
+ event.detail = fLastOperation;
}
computeFeedback(event);
}
-
+
@Override
public void dropAccept(DropTargetEvent event) {
- fTarget= computeTarget(event);
+ fTarget = computeTarget(event);
validateDrop(event);
- fLastOperation= event.detail;
+ fLastOperation = event.detail;
}
-
+
/**
* Returns the data held by <code>event.item</code>. Inside a viewer
* this corresponds to the items data model element.
@@ -197,20 +197,20 @@ public class CDTViewerDropAdapter implements DropTargetListener {
protected Object computeTarget(DropTargetEvent event) {
return event.item == null ? null : event.item.getData();
}
-
+
/**
* Returns the position of the given coordinates relative to the given target.
- * The position is determined to be before, after, or on the item, based on
- * some threshold value. The return value is one of the LOCATION_* constants
+ * The position is determined to be before, after, or on the item, based on
+ * some threshold value. The return value is one of the LOCATION_* constants
* defined in this class.
*/
final protected int computeLocation(DropTargetEvent event) {
if (!(event.item instanceof Item))
return LOCATION_NONE;
-
- Item item= (Item) event.item;
- Point coordinates= fViewer.getControl().toControl(new Point(event.x, event.y));
- Rectangle bounds= getBounds(item);
+
+ Item item = (Item) event.item;
+ Point coordinates = fViewer.getControl().toControl(new Point(event.x, event.y));
+ Rectangle bounds = getBounds(item);
if (bounds == null) {
return LOCATION_NONE;
}
@@ -224,16 +224,16 @@ public class CDTViewerDropAdapter implements DropTargetListener {
}
/**
- * Returns the bounds of the given item, or <code>null</code> if it is not a
+ * Returns the bounds of the given item, or <code>null</code> if it is not a
* valid type of item.
*/
private Rectangle getBounds(Item item) {
if (item instanceof TreeItem)
return ((TreeItem) item).getBounds();
-
+
if (item instanceof TableItem)
return ((TableItem) item).getBounds(0);
-
+
return null;
}
@@ -243,35 +243,35 @@ public class CDTViewerDropAdapter implements DropTargetListener {
*/
protected void computeFeedback(DropTargetEvent event) {
if (!fShowInsertionFeedback && fLocation != LOCATION_NONE) {
- event.feedback= DND.FEEDBACK_SELECT;
+ event.feedback = DND.FEEDBACK_SELECT;
} else {
- event.feedback= fLocation;
+ event.feedback = fLocation;
}
- event.feedback|= fFeedback;
+ event.feedback |= fFeedback;
}
-
+
/**
* Sets the drop operation to </code>DROP_NODE<code>.
*/
protected void clearDropOperation(DropTargetEvent event) {
- event.detail= DND.DROP_NONE;
+ event.detail = DND.DROP_NONE;
}
-
+
/**
* Returns the requested drop operation.
*/
protected int getRequestedOperation() {
return fRequestedOperation;
- }
-
+ }
+
protected void setDefaultFeedback(int feedback) {
- fFeedback= feedback;
+ fFeedback = feedback;
}
-
- //---- helper methods to test DnD
-
+
+ //---- helper methods to test DnD
+
public void internalTestSetLocation(int location) {
- fLocation= location;
+ fLocation = location;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java
index 6df4dd27c62..5f386b4879e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java
@@ -32,43 +32,43 @@ public class DelegatingDragAdapter implements DragSourceListener {
private TransferDragSourceListener[] fPossibleListeners;
private List<TransferDragSourceListener> fActiveListeners;
private TransferDragSourceListener fFinishListener;
-
+
public DelegatingDragAdapter(TransferDragSourceListener[] listeners) {
setPossibleListeners(listeners);
}
-
+
protected void setPossibleListeners(TransferDragSourceListener[] listeners) {
Assert.isNotNull(listeners);
Assert.isTrue(fActiveListeners == null, "Can only set possible listeners before drag operation has started"); //$NON-NLS-1$
- fPossibleListeners= listeners;
+ fPossibleListeners = listeners;
}
-
+
/* non Java-doc
* @see DragSourceListener
*/
@Override
public void dragStart(DragSourceEvent event) {
- fFinishListener= null;
- boolean saveDoit= event.doit;
- Object saveData= event.data;
- boolean doIt= false;
- List<Transfer> transfers= new ArrayList<Transfer>(fPossibleListeners.length);
- fActiveListeners= new ArrayList<TransferDragSourceListener>(fPossibleListeners.length);
-
+ fFinishListener = null;
+ boolean saveDoit = event.doit;
+ Object saveData = event.data;
+ boolean doIt = false;
+ List<Transfer> transfers = new ArrayList<Transfer>(fPossibleListeners.length);
+ fActiveListeners = new ArrayList<TransferDragSourceListener>(fPossibleListeners.length);
+
for (TransferDragSourceListener listener : fPossibleListeners) {
- event.doit= saveDoit;
+ event.doit = saveDoit;
listener.dragStart(event);
if (event.doit) {
transfers.add(listener.getTransfer());
fActiveListeners.add(listener);
}
- doIt= doIt || event.doit;
+ doIt = doIt || event.doit;
}
if (doIt) {
- ((DragSource)event.widget).setTransfer(transfers.toArray(new Transfer[transfers.size()]));
+ ((DragSource) event.widget).setTransfer(transfers.toArray(new Transfer[transfers.size()]));
}
- event.data= saveData;
- event.doit= doIt;
+ event.data = saveData;
+ event.doit = doIt;
}
/* non Java-doc
@@ -76,42 +76,42 @@ public class DelegatingDragAdapter implements DragSourceListener {
*/
@Override
public void dragSetData(DragSourceEvent event) {
- fFinishListener= getListener(event.dataType);
+ fFinishListener = getListener(event.dataType);
if (fFinishListener != null) {
fFinishListener.dragSetData(event);
}
}
-
+
/* non Java-doc
* @see DragSourceListener
*/
@Override
public void dragFinished(DragSourceEvent event) {
- try{
+ try {
if (fFinishListener != null) {
fFinishListener.dragFinished(event);
} else {
// If the user presses Escape then we get a dragFinished without
// getting a dragSetData before.
- fFinishListener= getListener(event.dataType);
+ fFinishListener = getListener(event.dataType);
if (fFinishListener != null) {
fFinishListener.dragFinished(event);
}
}
- } finally{
- fFinishListener= null;
- fActiveListeners= null;
- }
+ } finally {
+ fFinishListener = null;
+ fActiveListeners = null;
+ }
}
-
+
private TransferDragSourceListener getListener(TransferData type) {
if (type == null)
return null;
-
+
for (TransferDragSourceListener listener : fActiveListeners) {
if (listener.getTransfer().isSupportedType(type))
return listener;
}
return null;
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.java
index e2380f5a749..5c819078459 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.java
@@ -33,32 +33,32 @@ public class DelegatingDropAdapter implements DropTargetListener {
/**
* Creates a new delegating drop adapter.
- *
+ *
* @param listeners an array of potential listeners
*/
public DelegatingDropAdapter(TransferDropTargetListener[] listeners) {
Assert.isNotNull(listeners);
- fListeners= listeners;
+ fListeners = listeners;
}
/**
* The cursor has entered the drop target boundaries. The current listener
* is updated, and <code>#dragEnter()</code> is forwarded to the current
* listener.
- *
+ *
* @param event the drop target event
* @see DropTargetListener#dragEnter(DropTargetEvent)
*/
@Override
public void dragEnter(DropTargetEvent event) {
- fOriginalDropType= event.detail;
+ fOriginalDropType = event.detail;
updateCurrentListener(event);
}
/**
* The cursor has left the drop target boundaries. The event is forwarded to
* the current listener.
- *
+ *
* @param event the drop target event
* @see DropTargetListener#dragLeave(DropTargetEvent)
*/
@@ -71,16 +71,16 @@ public class DelegatingDropAdapter implements DropTargetListener {
* The operation being performed has changed (usually due to the user
* changing a drag modifier key while dragging). Updates the current
* listener and forwards this event to that listener.
- *
+ *
* @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.
@@ -99,15 +99,15 @@ public class DelegatingDropAdapter implements DropTargetListener {
* and forwards this event to that listener. 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
* @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
@@ -125,7 +125,7 @@ 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
* @see DropTargetListener#drop(DropTargetEvent)
*/
@@ -145,7 +145,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
/**
* Forwards this event to the current listener if there is one.
- *
+ *
* @param event the drop target event
* @see DropTargetListener#dropAccept(DropTargetEvent)
*/
@@ -163,7 +163,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
/**
* Returns the listener which currently handles drop events.
- *
+ *
* @return the <code>TransferDropTargetListener</code> which currently
* handles drop events.
*/
@@ -175,7 +175,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
* Returns the transfer data type supported by the given listener. Returns
* <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.
@@ -183,7 +183,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
* <code>null</code>.
*/
private TransferData getSupportedTransferType(TransferData[] dataTypes, TransferDropTargetListener listener) {
- for (int i= 0; i < dataTypes.length; i++) {
+ for (int i = 0; i < dataTypes.length; i++) {
if (listener.getTransfer().isSupportedType(dataTypes[i])) {
return dataTypes[i];
}
@@ -194,13 +194,13 @@ public class DelegatingDropAdapter implements DropTargetListener {
/**
* Returns the combined set of <code>Transfer</code> types of all
* <code>TransferDropTargetListeners</code>.
- *
+ *
* @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;
}
@@ -208,7 +208,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
/**
* Sets the current listener to <code>listener</code>. Sends the given
* <code>DropTargetEvent</code> if the current listener changes.
- *
+ *
* @return <code>true</code> if the new listener is different than the
* previous <code>false</code> otherwise
*/
@@ -223,7 +223,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
}
});
}
- fCurrentListener= listener;
+ fCurrentListener = listener;
if (fCurrentListener != null) {
SafeRunner.run(new SafeRunnable() {
@Override
@@ -243,37 +243,37 @@ public class DelegatingDropAdapter implements DropTargetListener {
* 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
*/
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
+ // 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;
}
- event.currentDataType= originalDataType;
+ event.currentDataType = originalDataType;
}
}
setCurrentListener(null, event);
- event.detail= DND.DROP_NONE;
+ event.detail = DND.DROP_NONE;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java
index 19f49e58ad3..33f4e76c818 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java
@@ -77,7 +77,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
public void dragFinished(DragSourceEvent event) {
if (event.doit) {
if (event.detail == DND.DROP_MOVE) {
- // Never delete resources when dragging outside Eclipse.
+ // Never delete resources when dragging outside Eclipse.
// See: http://bugs.eclipse.org/bugs/show_bug.cgi?id=30543
} else if (event.detail == DND.DROP_NONE || event.detail == DND.DROP_TARGET_MOVE) {
runOperation(new RefreshOperation(getResources()), true, false);
@@ -102,14 +102,13 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
try {
- monitor.beginTask(CUIMessages.FileTransferDragAdapter_refreshing, roots.size());
- MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, CUIMessages.FileTransferDragAdapter_problem, null);
+ monitor.beginTask(CUIMessages.FileTransferDragAdapter_refreshing, roots.size());
+ MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK,
+ CUIMessages.FileTransferDragAdapter_problem, null);
for (IResource resource : roots) {
try {
- resource.refreshLocal(
- IResource.DEPTH_ONE,
- new SubProgressMonitor(monitor, 1));
+ resource.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(monitor, 1));
} catch (CoreException e) {
status.add(e.getStatus());
}
@@ -154,28 +153,25 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
if (!resources.isEmpty()) {
int count = resources.size();
List<String> locations = new ArrayList<String>(count);
-
+
for (IResource resource : resources) {
IPath location = resource.getLocation();
-
+
if (location != null) {
locations.add(location.toOSString());
}
}
-
+
String[] result = new String[locations.size()];
-
+
locations.toArray(result);
-
+
return result;
}
return null;
}
- private static void runOperation(
- IRunnableWithProgress operation,
- boolean fork,
- boolean cancelable) {
+ private static void runOperation(IRunnableWithProgress operation, boolean fork, boolean cancelable) {
try {
IWorkbench workbench = CUIPlugin.getDefault().getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
@@ -185,8 +181,8 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
} catch (InterruptedException e) {
// Do nothing. Operation has been canceled by user.
} catch (InvocationTargetException e) {
- String message = CUIMessages.FileTransferDragAdapter_problem;
- String title = CUIMessages.FileTransferDragAdapter_problemTitle;
+ String message = CUIMessages.FileTransferDragAdapter_problem;
+ String title = CUIMessages.FileTransferDragAdapter_problemTitle;
ExceptionHandler.handle(e, title, message);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.java
index c84ae74d7f5..d992a620356 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.java
@@ -38,15 +38,15 @@ public class FileTransferDropAdapter extends CDTViewerDropAdapter implements Tra
}
//---- TransferDropTargetListener interface ---------------------------------------
-
+
@Override
public Transfer getTransfer() {
return FileTransfer.getInstance();
}
-
+
@Override
public boolean isEnabled(DropTargetEvent event) {
- Object target= event.item != null ? event.item.getData() : null;
+ Object target = event.item != null ? event.item.getData() : null;
if (target == null) {
return false;
}
@@ -54,23 +54,23 @@ public class FileTransferDropAdapter extends CDTViewerDropAdapter implements Tra
}
//---- Actual DND -----------------------------------------------------------------
-
+
@Override
public void validateDrop(Object target, DropTargetEvent event, int operation) {
- event.detail= DND.DROP_NONE;
+ event.detail = DND.DROP_NONE;
boolean isContainer = false;
if (target instanceof IContainer) {
isContainer = true;
} else if (target instanceof IAdaptable) {
- target = ((IAdaptable)target).getAdapter(IResource.class);
+ target = ((IAdaptable) target).getAdapter(IResource.class);
isContainer = target instanceof IContainer;
}
if (isContainer) {
- IContainer container= (IContainer)target;
+ IContainer container = (IContainer) target;
if (container.isAccessible()) {
ResourceAttributes attributes = container.getResourceAttributes();
if (attributes != null && !attributes.isReadOnly()) {
- event.detail= DND.DROP_COPY;
+ event.detail = DND.DROP_COPY;
}
}
}
@@ -78,19 +78,19 @@ public class FileTransferDropAdapter extends CDTViewerDropAdapter implements Tra
@Override
public void drop(Object dropTarget, final DropTargetEvent event) {
- int operation= event.detail;
-
- event.detail= DND.DROP_NONE;
- final Object data= event.data;
+ int operation = event.detail;
+
+ event.detail = DND.DROP_NONE;
+ final Object data = event.data;
if (data == null || !(data instanceof String[]) || operation != DND.DROP_COPY)
return;
-
- final IContainer target= getActualTarget(dropTarget);
+
+ final IContainer target = getActualTarget(dropTarget);
if (target == null)
return;
-
- // Run the import operation asynchronously.
- // Otherwise the drag source (e.g., Windows Explorer) will be blocked
+
+ // Run the import operation asynchronously.
+ // Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 35796.
Display.getCurrent().asyncExec(new Runnable() {
@Override
@@ -98,20 +98,20 @@ public class FileTransferDropAdapter extends CDTViewerDropAdapter implements Tra
getShell().forceActive();
new CopyFilesAndFoldersOperation(getShell()).copyFiles((String[]) data, target);
// Import always performs a copy.
- event.detail= DND.DROP_COPY;
+ event.detail = DND.DROP_COPY;
}
});
}
-
+
private IContainer getActualTarget(Object dropTarget) {
if (dropTarget instanceof IContainer) {
- return (IContainer)dropTarget;
+ return (IContainer) dropTarget;
} else if (dropTarget instanceof ICElement) {
- return getActualTarget(((ICElement)dropTarget).getResource());
+ return getActualTarget(((ICElement) dropTarget).getResource());
}
return null;
}
-
+
Shell getShell() {
return getViewer().getControl().getShell();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.java
index 7779fe5e50a..3ba98ff6862 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.java
@@ -26,18 +26,17 @@ import org.eclipse.cdt.core.model.ICElement;
/**
* PluginTransferDropAdapter
* Enable DND to support PluginTransfer type.
- * The actual DND operation is a call back to the
+ * The actual DND operation is a call back to the
* org.eclipse.ui.dropActions delegate.
*
*/
-public class PluginTransferDropAdapter extends PluginDropAdapter implements
- TransferDropTargetListener {
+public class PluginTransferDropAdapter extends PluginDropAdapter implements TransferDropTargetListener {
- public PluginTransferDropAdapter (StructuredViewer viewer) {
+ public PluginTransferDropAdapter(StructuredViewer viewer) {
super(viewer);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener#getTransfer()
*/
@@ -46,13 +45,12 @@ public class PluginTransferDropAdapter extends PluginDropAdapter implements
return PluginTransfer.getInstance();
}
-
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener#isEnabled(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public boolean isEnabled(DropTargetEvent event) {
- Object target= event.item != null ? event.item.getData() : null;
+ Object target = event.item != null ? event.item.getData() : null;
if (target == null) {
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java
index 56a6d5a9ece..b75b0a843c8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java
@@ -38,7 +38,7 @@ import org.eclipse.cdt.internal.ui.CUIMessages;
/**
* A drag adapter that transfers the current selection as </code>
- * IResource</code>. Only those elements in the selection are part
+ * IResource</code>. Only those elements in the selection are part
* of the transfer which can be converted into an <code>IResource
* </code>.
*/
@@ -83,8 +83,8 @@ public class ResourceTransferDragAdapter implements TransferDragSourceListener {
DragSource dragSource = (DragSource) event.widget;
Control control = dragSource.getControl();
Shell shell = control.getShell();
- String title = CUIMessages.Drag_move_problem_title;
- String message = CUIMessages.Drag_move_problem_message;
+ String title = CUIMessages.Drag_move_problem_title;
+ String message = CUIMessages.Drag_move_problem_message;
ReadOnlyStateChecker checker = new ReadOnlyStateChecker(shell, title, message);
@@ -114,7 +114,7 @@ public class ResourceTransferDragAdapter implements TransferDragSourceListener {
Object element = iterator.next();
IResource resource = null;
if (element instanceof IResource) {
- resource = (IResource)element;
+ resource = (IResource) element;
} else if (element instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) element;
resource = adaptable.getAdapter(IResource.class);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java
index 798836626e5..95d0d22fe46 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java
@@ -61,7 +61,7 @@ public class ResourceTransferDropAdapter extends CDTViewerDropAdapter implements
*/
@Override
public boolean isEnabled(DropTargetEvent event) {
- Object target= event.item != null ? event.item.getData() : null;
+ Object target = event.item != null ? event.item.getData() : null;
if (target == null) {
return false;
}
@@ -95,26 +95,24 @@ public class ResourceTransferDropAdapter extends CDTViewerDropAdapter implements
@Override
public void drop(Object dropTarget, final DropTargetEvent event) {
- int op= event.detail;
-
- event.detail= DND.DROP_NONE;
- final Object data= event.data;
+ int op = event.detail;
+
+ event.detail = DND.DROP_NONE;
+ final Object data = event.data;
if (data == null || !(data instanceof IResource[]))
return;
-
- final IContainer target= getDestination(dropTarget);
+
+ final IContainer target = getDestination(dropTarget);
if (target == null) {
return;
}
- IResource[] sources = (IResource[])data;
+ IResource[] sources = (IResource[]) data;
if (op == DND.DROP_COPY) {
CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
operation.copyResources(sources, target);
- } else {
- ReadOnlyStateChecker checker = new ReadOnlyStateChecker(
- getShell(),
- "Move Resource Action", //$NON-NLS-1$
- "Move Resource Action");//$NON-NLS-1$
+ } else {
+ ReadOnlyStateChecker checker = new ReadOnlyStateChecker(getShell(), "Move Resource Action", //$NON-NLS-1$
+ "Move Resource Action");//$NON-NLS-1$
sources = checker.checkReadOnlyResources(sources);
MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell());
operation.copyResources(sources, target);
@@ -123,31 +121,29 @@ public class ResourceTransferDropAdapter extends CDTViewerDropAdapter implements
private IContainer getDestination(Object dropTarget) {
if (dropTarget instanceof IContainer) {
- return (IContainer)dropTarget;
+ return (IContainer) dropTarget;
} else if (dropTarget instanceof ICElement) {
- return getDestination(((ICElement)dropTarget).getResource());
+ return getDestination(((ICElement) dropTarget).getResource());
}
return null;
}
/**
* Returns the resource selection from the LocalSelectionTransfer.
- *
+ *
* @return the resource selection from the LocalSelectionTransfer
*/
private IResource[] getSelectedResources() {
ArrayList<IResource> selectedResources = new ArrayList<IResource>();
-
- ISelection selection = LocalSelectionTransfer.getTransfer()
- .getSelection();
+
+ ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) selection;
for (Iterator<?> i = ssel.iterator(); i.hasNext();) {
Object o = i.next();
if (o instanceof IResource) {
selectedResources.add((IResource) o);
- }
- else if (o instanceof IAdaptable) {
+ } else if (o instanceof IAdaptable) {
IAdaptable a = (IAdaptable) o;
IResource r = a.getAdapter(IResource.class);
if (r != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.java
index c1ec6c1476b..f61712fb035 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.java
@@ -33,13 +33,13 @@ import org.eclipse.ui.texteditor.ITextEditorExtension;
/**
* Drag source adapter for text selections in ITextViewers.
- *
+ *
* @since 4.0
*/
public class TextViewerDragAdapter extends DragSourceAdapter {
/** The position category to be used to indicate a drag source selection */
- public final static String DRAG_SELECTION_CATEGORY= "dragSelectionCategory"; //$NON-NLS-1$
+ public final static String DRAG_SELECTION_CATEGORY = "dragSelectionCategory"; //$NON-NLS-1$
/** The position updater for the drag selection position */
private IPositionUpdater fPositionUpdater;
/** The drag selection position */
@@ -49,7 +49,7 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
/** The editor of the viewer (may be null) */
private ITextEditorExtension fEditor;
/** Flag whether this drag source listener allows to drag */
- private boolean fIsEnabled= true;
+ private boolean fIsEnabled = true;
/**
* Create a new TextViewerDragAdapter.
@@ -64,8 +64,8 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
* @param viewer the text viewer
*/
public TextViewerDragAdapter(ITextViewer viewer, ITextEditorExtension editor) {
- fViewer= viewer;
- fEditor= editor;
+ fViewer = viewer;
+ fEditor = editor;
}
/*
@@ -73,7 +73,7 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
*/
@Override
public void dragFinished(DragSourceEvent event) {
- IDocument doc= fViewer.getDocument();
+ IDocument doc = fViewer.getDocument();
try {
doc.removePositionCategory(DRAG_SELECTION_CATEGORY);
doc.removePositionUpdater(fPositionUpdater);
@@ -88,7 +88,7 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
}
}
if (fViewer instanceof ITextViewerExtension) {
- ((ITextViewerExtension)fViewer).getRewriteTarget().endCompoundChange();
+ ((ITextViewerExtension) fViewer).getRewriteTarget().endCompoundChange();
}
}
@@ -97,12 +97,12 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
*/
@Override
public void dragSetData(DragSourceEvent event) {
- IDocument doc= fViewer.getDocument();
+ IDocument doc = fViewer.getDocument();
try {
- event.data= doc.get(fSelectionPosition.offset, fSelectionPosition.length);
+ event.data = doc.get(fSelectionPosition.offset, fSelectionPosition.length);
} catch (BadLocationException e) {
- event.detail= DND.DROP_NONE;
- event.doit= false;
+ event.detail = DND.DROP_NONE;
+ event.doit = false;
}
}
@@ -112,27 +112,27 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
@Override
public void dragStart(DragSourceEvent event) {
if (!fIsEnabled) {
- event.doit= false;
+ event.doit = false;
return;
}
// convert screen coordinates to widget offest
- int offset= getOffsetAtLocation(event.x, event.y, false);
+ int offset = getOffsetAtLocation(event.x, event.y, false);
// convert further to a document offset
- offset= getDocumentOffset(offset);
- Point selection= fViewer.getSelectedRange();
- if (selection != null && offset >= selection.x && offset < selection.x+selection.y) {
- fSelectionPosition= new Position(selection.x, selection.y);
+ offset = getDocumentOffset(offset);
+ Point selection = fViewer.getSelectedRange();
+ if (selection != null && offset >= selection.x && offset < selection.x + selection.y) {
+ fSelectionPosition = new Position(selection.x, selection.y);
if (fViewer instanceof ITextViewerExtension) {
- ((ITextViewerExtension)fViewer).getRewriteTarget().beginCompoundChange();
+ ((ITextViewerExtension) fViewer).getRewriteTarget().beginCompoundChange();
}
- IDocument doc= fViewer.getDocument();
+ IDocument doc = fViewer.getDocument();
try {
// add the drag selection position
// the position is used to delete the selection on a DROP_MOVE
// and it can be used by the drop target to determine if it should
// allow the drop (e.g. if drop location overlaps selection)
doc.addPositionCategory(DRAG_SELECTION_CATEGORY);
- fPositionUpdater= new DefaultPositionUpdater(DRAG_SELECTION_CATEGORY);
+ fPositionUpdater = new DefaultPositionUpdater(DRAG_SELECTION_CATEGORY);
doc.addPositionUpdater(fPositionUpdater);
doc.addPosition(DRAG_SELECTION_CATEGORY, fSelectionPosition);
} catch (BadLocationException e) {
@@ -140,21 +140,21 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
} catch (BadPositionCategoryException e) {
// cannot happen
}
- event.doit= true;
+ event.doit = true;
// this has no effect?
event.detail = DND.DROP_COPY;
if (isDocumentEditable()) {
event.detail |= DND.DROP_MOVE;
}
} else {
- event.doit= false;
+ event.doit = false;
event.detail = DND.DROP_NONE;
}
}
/**
* Convert mouse screen coordinates to a <code>StyledText</code> offset.
- *
+ *
* @param x
* screen X-coordinate
* @param y
@@ -163,25 +163,25 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
* if <code>true</code>, coordinates are expected to be
* absolute screen coordinates
* @return text offset
- *
+ *
* @see StyledText#getOffsetAtLocation()
*/
private int getOffsetAtLocation(int x, int y, boolean absolute) {
- StyledText textWidget= fViewer.getTextWidget();
- StyledTextContent content= textWidget.getContent();
+ StyledText textWidget = fViewer.getTextWidget();
+ StyledTextContent content = textWidget.getContent();
Point location;
if (absolute) {
- location= textWidget.toControl(x, y);
+ location = textWidget.toControl(x, y);
} else {
- location= new Point(x ,y);
+ location = new Point(x, y);
}
- int line= (textWidget.getTopPixel() + location.y) / textWidget.getLineHeight();
+ int line = (textWidget.getTopPixel() + location.y) / textWidget.getLineHeight();
if (line >= content.getLineCount()) {
return content.getCharCount();
}
- int lineOffset= content.getOffsetAtLine(line);
- String lineText= content.getLine(line);
- Point endOfLine= textWidget.getLocationAtOffset(lineOffset + lineText.length());
+ int lineOffset = content.getOffsetAtLine(line);
+ String lineText = content.getLine(line);
+ Point endOfLine = textWidget.getLocationAtOffset(lineOffset + lineText.length());
if (location.x >= endOfLine.x) {
return lineOffset + lineText.length();
}
@@ -200,10 +200,10 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
*/
private int getDocumentOffset(int widgetOffset) {
if (fViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)fViewer;
+ ITextViewerExtension5 extension = (ITextViewerExtension5) fViewer;
return extension.widgetOffset2ModelOffset(widgetOffset);
}
- IRegion visible= fViewer.getVisibleRegion();
+ IRegion visible = fViewer.getVisibleRegion();
if (widgetOffset > visible.getLength()) {
return -1;
}
@@ -225,7 +225,7 @@ public class TextViewerDragAdapter extends DragSourceAdapter {
* @param enabled
*/
public void setEnabled(boolean enabled) {
- fIsEnabled= enabled;
+ fIsEnabled = enabled;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.java
index 052f0fb94f0..d79c76ca566 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.java
@@ -27,13 +27,13 @@ public interface TransferDropTargetListener extends DropTargetListener {
* Returns the transfer used by this drop target.
*/
public Transfer getTransfer();
-
+
/**
* Returns whether the listener is able to handle the given
* drop traget event.
- *
+ *
* @param event the drop target event
- *
+ *
* @return <code>true</code> if the listener can handle the event;
* otherwise <code>false</code>
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java
index 6ec9b7f828f..e6e7ccb508a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java
@@ -57,7 +57,7 @@ public final class ASTProvider {
String fName;
private WAIT_FLAG(String name) {
- fName= name;
+ fName = name;
}
@Override
@@ -74,7 +74,7 @@ public final class ASTProvider {
* If not yet cached and if the translation unit is open, an AST will be created by
* this AST provider.
*/
- public static final WAIT_FLAG WAIT_IF_OPEN= new WAIT_FLAG("wait if open"); //$NON-NLS-1$
+ public static final WAIT_FLAG WAIT_IF_OPEN = new WAIT_FLAG("wait if open"); //$NON-NLS-1$
/**
* Wait flag indicating that a client requesting an AST
@@ -83,7 +83,7 @@ public final class ASTProvider {
* <p>
* No AST will be created by the AST provider.
*/
- public static final WAIT_FLAG WAIT_ACTIVE_ONLY= new WAIT_FLAG("wait active only"); //$NON-NLS-1$
+ public static final WAIT_FLAG WAIT_ACTIVE_ONLY = new WAIT_FLAG("wait active only"); //$NON-NLS-1$
/**
* Wait flag indicating that a client requesting an AST
@@ -91,12 +91,12 @@ public final class ASTProvider {
* <p>
* No AST will be created by the AST provider.
*/
- public static final WAIT_FLAG WAIT_NO= new WAIT_FLAG("don't wait"); //$NON-NLS-1$
+ public static final WAIT_FLAG WAIT_NO = new WAIT_FLAG("don't wait"); //$NON-NLS-1$
/** Full parse mode (no PDOM) */
- public static int PARSE_MODE_FULL= 0;
+ public static int PARSE_MODE_FULL = 0;
/** Fast parse mode (use PDOM) */
- public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
+ public static int PARSE_MODE_FAST = ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
/**
* Internal activation listener.
@@ -149,7 +149,7 @@ public final class ASTProvider {
@Override
public void windowActivated(IWorkbenchWindow window) {
- IWorkbenchPartReference ref= window.getPartService().getActivePartReference();
+ IWorkbenchPartReference ref = window.getPartService().getActivePartReference();
if (isCEditor(ref) && !isActiveEditor(ref))
activeEditorChanged(ref.getPart(true));
}
@@ -160,7 +160,8 @@ public final class ASTProvider {
@Override
public void windowClosed(IWorkbenchWindow window) {
- if (fActiveEditor != null && fActiveEditor.getSite() != null && window == fActiveEditor.getSite().getWorkbenchWindow()) {
+ if (fActiveEditor != null && fActiveEditor.getSite() != null
+ && window == fActiveEditor.getSite().getWorkbenchWindow()) {
activeEditorChanged(null);
}
window.getPartService().removePartListener(this);
@@ -183,7 +184,7 @@ public final class ASTProvider {
if (ref == null)
return false;
- String id= ref.getId();
+ String id = ref.getId();
if (CUIPlugin.EDITOR_ID.equals(id))
return true;
@@ -198,7 +199,7 @@ public final class ASTProvider {
}
}
- private final ASTCache fCache= new ASTCache();
+ private final ASTCache fCache = new ASTCache();
private ActivationListener fActivationListener;
private IWorkbenchPart fActiveEditor;
private long fTimeStamp;
@@ -226,12 +227,12 @@ public final class ASTProvider {
void install() {
if (PlatformUI.isWorkbenchRunning()) {
// Create and register activation listener
- fActivationListener= new ActivationListener();
+ fActivationListener = new ActivationListener();
PlatformUI.getWorkbench().addWindowListener(fActivationListener);
// Ensure existing windows get connected
- IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
- for (int i= 0, length= windows.length; i < length; i++) {
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i = 0, length = windows.length; i < length; i++) {
windows[i].getPartService().addPartListener(fActivationListener);
}
}
@@ -246,8 +247,8 @@ public final class ASTProvider {
}
synchronized (this) {
- fActiveEditor= editor;
- fTimeStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
+ fActiveEditor = editor;
+ fTimeStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
fCache.setActiveElement(tu);
}
@@ -270,24 +271,24 @@ public final class ASTProvider {
}
private boolean updateModificationStamp() {
- long timeStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
- ITextEditor textEditor= null;
+ long timeStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
+ ITextEditor textEditor = null;
synchronized (this) {
if (fActiveEditor instanceof ITextEditor) {
- textEditor= (ITextEditor) fActiveEditor;
- timeStamp= fTimeStamp;
+ textEditor = (ITextEditor) fActiveEditor;
+ timeStamp = fTimeStamp;
}
}
if (textEditor != null) {
- IEditorInput editorInput= textEditor.getEditorInput();
- IDocument document= textEditor.getDocumentProvider().getDocument(editorInput);
+ IEditorInput editorInput = textEditor.getEditorInput();
+ IDocument document = textEditor.getDocumentProvider().getDocument(editorInput);
if (document instanceof IDocumentExtension4) {
- IDocumentExtension4 docExt= (IDocumentExtension4) document;
- long newTimeStamp= docExt.getModificationStamp();
+ IDocumentExtension4 docExt = (IDocumentExtension4) document;
+ long newTimeStamp = docExt.getModificationStamp();
if (newTimeStamp != timeStamp) {
synchronized (this) {
if (fActiveEditor == textEditor && fTimeStamp == timeStamp) {
- fTimeStamp= newTimeStamp;
+ fTimeStamp = newTimeStamp;
return true;
}
}
@@ -304,7 +305,7 @@ public final class ASTProvider {
if (fActivationListener != null) {
// Dispose activation listener
PlatformUI.getWorkbench().removeWindowListener(fActivationListener);
- fActivationListener= null;
+ fActivationListener = null;
}
fCache.setActiveElement(null);
}
@@ -355,8 +356,8 @@ public final class ASTProvider {
* @param monitor a progress monitor, may be {@code null}.
* @return the shared AST, or {@code null} if the shared AST is not available.
*/
- public final IASTTranslationUnit acquireSharedAST(ITranslationUnit tu, IIndex index,
- WAIT_FLAG waitFlag, IProgressMonitor monitor) {
+ public final IASTTranslationUnit acquireSharedAST(ITranslationUnit tu, IIndex index, WAIT_FLAG waitFlag,
+ IProgressMonitor monitor) {
if (!prepareForUsingCache(tu, waitFlag))
return null;
return fCache.acquireSharedAST(tu, index, waitFlag != WAIT_NO, monitor);
@@ -388,7 +389,7 @@ public final class ASTProvider {
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=342506 explains
// benign nature of the race conditions in the code below.
- final boolean isActive= fCache.isActiveElement(tu);
+ final boolean isActive = fCache.isActiveElement(tu);
if (waitFlag == WAIT_ACTIVE_ONLY && !isActive) {
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java
index 15dcc60be0f..12adce81f9e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java
@@ -111,7 +111,8 @@ public abstract class AbstractCModelOutlinePage extends Page
public COutlineLabelProvider(long textFlags, int imageFlags) {
super(textFlags, imageFlags);
PreferenceConstants.getPreferenceStore().addPropertyChangeListener(this);
- fSimpleName= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS);
+ fSimpleName = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS);
}
@Override
@@ -119,7 +120,7 @@ public abstract class AbstractCModelOutlinePage extends Page
PreferenceConstants.getPreferenceStore().removePropertyChangeListener(this);
super.dispose();
}
-
+
@Override
protected long evaluateTextFlags(Object element) {
if (fSimpleName) {
@@ -127,15 +128,16 @@ public abstract class AbstractCModelOutlinePage extends Page
}
return super.evaluateTextFlags(element);
}
-
+
@Override
public void propertyChange(PropertyChangeEvent event) {
if (PreferenceConstants.OUTLINE_GROUP_MEMBERS.equals(event.getProperty())) {
final Object newValue = event.getNewValue();
if (newValue instanceof Boolean) {
- fSimpleName= ((Boolean) newValue).booleanValue();
+ fSimpleName = ((Boolean) newValue).booleanValue();
} else {
- fSimpleName= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS);
+ fSimpleName = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS);
}
}
}
@@ -155,7 +157,7 @@ public abstract class AbstractCModelOutlinePage extends Page
@Override
protected void internalExpandToLevel(Widget node, int level) {
if (node instanceof Item) {
- Item i= (Item) node;
+ Item i = (Item) node;
final Object data = i.getData();
// Don't expand include grouping by default.
if (data instanceof IncludesGrouping) {
@@ -167,15 +169,15 @@ public abstract class AbstractCModelOutlinePage extends Page
}
super.internalExpandToLevel(node, level);
}
-
+
private boolean shouldExpandElement(ICElement cElement) {
- final ICElement parent= cElement.getParent();
+ final ICElement parent = cElement.getParent();
if (parent == null) {
return false;
}
// Expand classes and namespaces.
- final int elementType= cElement.getElementType();
- final int parentType= parent.getElementType();
+ final int elementType = cElement.getElementType();
+ final int parentType = parent.getElementType();
switch (elementType) {
case ICElement.C_CLASS:
case ICElement.C_TEMPLATE_CLASS:
@@ -196,7 +198,7 @@ public abstract class AbstractCModelOutlinePage extends Page
setToolTipText(ActionMessages.IncludesGroupingAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_GROUP_INCLUDE);
- boolean enabled= isIncludesGroupingEnabled();
+ boolean enabled = isIncludesGroupingEnabled();
setChecked(enabled);
fOutLinePage = outlinePage;
}
@@ -213,7 +215,7 @@ public abstract class AbstractCModelOutlinePage extends Page
/**
* This action toggles macro grouping.
- *
+ *
* @since 5.2
*/
protected static class MacroGroupingAction extends Action {
@@ -225,9 +227,8 @@ public abstract class AbstractCModelOutlinePage extends Page
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_MACROS);
this.setImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO));
this.setDisabledImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO));
-
- boolean enabled= isMacroGroupingEnabled();
+ boolean enabled = isMacroGroupingEnabled();
setChecked(enabled);
}
@@ -240,11 +241,11 @@ public abstract class AbstractCModelOutlinePage extends Page
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS);
}
}
-
+
/**
* This action toggles whether this C Outline page links
* its selection to the active editor.
- *
+ *
* @since 3.0
*/
public class ToggleLinkingAction extends AbstractToggleLinkingAction {
@@ -263,16 +264,15 @@ public abstract class AbstractCModelOutlinePage extends Page
synchronizeSelectionWithEditor();
}
}
-
- private static final long TEXT_FLAGS =
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE |
- CElementLabels.M_APP_RETURNTYPE;
+
+ private static final long TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS
+ | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE;
private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS;
protected ITextEditor fEditor;
protected ITranslationUnit fInput;
private ProblemTreeViewer fTreeViewer;
- private ListenerList<ISelectionChangedListener> fSelectionChangedListeners =
- new ListenerList<>(ListenerList.IDENTITY);
+ private ListenerList<ISelectionChangedListener> fSelectionChangedListeners = new ListenerList<>(
+ ListenerList.IDENTITY);
protected TogglePresentationAction fTogglePresentation;
protected String fContextMenuId;
private Menu fMenu;
@@ -300,14 +300,14 @@ public abstract class AbstractCModelOutlinePage extends Page
*/
public AbstractCModelOutlinePage(String contextMenuId, ITextEditor editor) {
super();
- fEditor= editor;
- fInput= null;
- fContextMenuId= contextMenuId;
+ fEditor = editor;
+ fInput = null;
+ fContextMenuId = contextMenuId;
- fTogglePresentation= new TogglePresentationAction();
+ fTogglePresentation = new TogglePresentationAction();
fTogglePresentation.setEditor(editor);
-
- fOpenIncludeAction= new OpenIncludeAction(this);
+
+ fOpenIncludeAction = new OpenIncludeAction(this);
}
@Override
@@ -353,16 +353,16 @@ public abstract class AbstractCModelOutlinePage extends Page
return new IShowInTarget() {
@Override
public boolean show(ShowInContext context) {
- ISelection sel= context.getSelection();
+ ISelection sel = context.getSelection();
if (sel instanceof ITextSelection) {
- ITextSelection tsel= (ITextSelection) sel;
- int offset= tsel.getOffset();
- ICElement element= null;
+ ITextSelection tsel = (ITextSelection) sel;
+ int offset = tsel.getOffset();
+ ICElement element = null;
if (fEditor instanceof CEditor) {
- element= ((CEditor) fEditor).getElementAt(offset, false);
+ element = ((CEditor) fEditor).getElementAt(offset, false);
} else if (fInput != null) {
try {
- element= fInput.getElementAtOffset(offset);
+ element = fInput.getElementAtOffset(offset);
} catch (CModelException e) {
CUIPlugin.log(e);
}
@@ -394,22 +394,22 @@ public abstract class AbstractCModelOutlinePage extends Page
public void synchronizeSelectionWithEditor() {
if (fInput == null || fEditor == null || fTreeViewer == null)
return;
-
+
ITextSelection editorSelection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
if (editorSelection == null)
return;
-
+
int offset = editorSelection.getOffset();
-
- ICElement editorElement= null;
+
+ ICElement editorElement = null;
try {
- if (fInput.isStructureKnown() && fInput.isConsistent()) {
- editorElement = fInput.getElementAtOffset(offset);
- }
+ if (fInput.isStructureKnown() && fInput.isConsistent()) {
+ editorElement = fInput.getElementAtOffset(offset);
+ }
} catch (CModelException e) {
return;
}
-
+
if (editorElement != null) {
IStructuredSelection selection = new StructuredSelection(editorElement);
fTreeViewer.setSelection(selection, true);
@@ -421,32 +421,32 @@ public abstract class AbstractCModelOutlinePage extends Page
*/
protected void contextMenuAboutToShow(IMenuManager menu) {
CUIPlugin.createStandardGroups(menu);
-
- ISelection selection= getSelection();
- if (fOpenViewActionGroup != null && OpenViewActionGroup.canActionBeAdded(selection)){
+
+ ISelection selection = getSelection();
+ if (fOpenViewActionGroup != null && OpenViewActionGroup.canActionBeAdded(selection)) {
fOpenViewActionGroup.fillContextMenu(menu);
}
-
+
if (OpenIncludeAction.canActionBeAdded(selection)) {
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenIncludeAction);
}
-
- if (fSelectionSearchGroup != null && SelectionSearchGroup.canActionBeAdded(selection)){
+
+ if (fSelectionSearchGroup != null && SelectionSearchGroup.canActionBeAdded(selection)) {
fSelectionSearchGroup.fillContextMenu(menu);
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
-
+
if (fSourceActionGroup != null) {
fSourceActionGroup.fillContextMenu(menu);
}
-
+
if (fRefactoringActionGroup != null) {
fRefactoringActionGroup.fillContextMenu(menu);
}
}
protected CContentOutlinerProvider createContentProvider(TreeViewer viewer) {
- IWorkbenchPart part= getSite().getPage().getActivePart();
+ IWorkbenchPart part = getSite().getPage().getActivePart();
if (part == null) {
return new CContentOutlinerProvider(viewer);
}
@@ -466,13 +466,13 @@ public abstract class AbstractCModelOutlinePage extends Page
private CUILabelProvider createLabelProvider() {
return new COutlineLabelProvider(TEXT_FLAGS, IMAGE_FLAGS);
}
-
+
@Override
public void createControl(Composite parent) {
fTreeViewer = createTreeViewer(parent);
initDragAndDrop();
-
- MenuManager manager= new MenuManager(fContextMenuId);
+
+ MenuManager manager = new MenuManager(fContextMenuId);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
@Override
@@ -480,10 +480,10 @@ public abstract class AbstractCModelOutlinePage extends Page
contextMenuAboutToShow(manager);
}
});
- Control control= fTreeViewer.getControl();
- fMenu= manager.createContextMenu(control);
+ Control control = fTreeViewer.getControl();
+ fMenu = manager.createContextMenu(control);
control.setMenu(fMenu);
-
+
fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
@@ -493,29 +493,29 @@ public abstract class AbstractCModelOutlinePage extends Page
}
});
// register global actions
- IPageSite site= getSite();
+ IPageSite site = getSite();
site.registerContextMenu(fContextMenuId, manager, fTreeViewer);
site.setSelectionProvider(fTreeViewer);
-
- IActionBars bars= site.getActionBars();
+
+ IActionBars bars = site.getActionBars();
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY,
fTogglePresentation);
-
+
fSelectionSearchGroup = createSearchActionGroup();
fOpenViewActionGroup = createOpenViewActionGroup();
fSourceActionGroup = createSourceActionGroup();
- fRefactoringActionGroup= createRefactoringActionGroup();
+ fRefactoringActionGroup = createRefactoringActionGroup();
// Custom filter group
- fCustomFiltersActionGroup= createCustomFiltersActionGroup();
-
+ fCustomFiltersActionGroup = createCustomFiltersActionGroup();
+
// Do this before setting input but after the initializations of the fields filtering
registerActionBars(bars);
bars.updateActionBars();
-
+
fTreeViewer.setInput(fInput);
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
-
- IHandlerService handlerService= site.getService(IHandlerService.class);
+
+ IHandlerService handlerService = site.getService(IHandlerService.class);
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
}
@@ -523,68 +523,68 @@ public abstract class AbstractCModelOutlinePage extends Page
public void dispose() {
if (fTreeViewer != null) {
fTreeViewer.removeSelectionChangedListener(this);
- fTreeViewer= null;
+ fTreeViewer = null;
}
-
+
if (fTogglePresentation != null) {
fTogglePresentation.setEditor(null);
- fTogglePresentation= null;
+ fTogglePresentation = null;
}
-
+
if (fMemberFilterActionGroup != null) {
fMemberFilterActionGroup.dispose();
- fMemberFilterActionGroup= null;
+ fMemberFilterActionGroup = null;
}
-
+
if (fOpenViewActionGroup != null) {
- fOpenViewActionGroup.dispose();
- fOpenViewActionGroup= null;
+ fOpenViewActionGroup.dispose();
+ fOpenViewActionGroup = null;
}
-
+
if (fRefactoringActionGroup != null) {
fRefactoringActionGroup.dispose();
- fRefactoringActionGroup= null;
+ fRefactoringActionGroup = null;
}
-
+
if (fSelectionSearchGroup != null) {
fSelectionSearchGroup.dispose();
- fSelectionSearchGroup= null;
+ fSelectionSearchGroup = null;
}
-
+
if (fCustomFiltersActionGroup != null) {
fCustomFiltersActionGroup.dispose();
- fCustomFiltersActionGroup= null;
+ fCustomFiltersActionGroup = null;
}
-
+
if (fSelectionChangedListeners != null) {
fSelectionChangedListeners.clear();
// don't set the listeners to null, the outline page may be reused.
}
-
+
if (fMenu != null && !fMenu.isDisposed()) {
fMenu.dispose();
- fMenu= null;
+ fMenu = null;
}
-
- fInput= null;
-
+
+ fInput = null;
+
super.dispose();
}
/**
* Register actions to the action bars.
- *
+ *
* @param actionBars
*/
protected void registerActionBars(IActionBars actionBars) {
- IToolBarManager toolBarManager= actionBars.getToolBarManager();
-
+ IToolBarManager toolBarManager = actionBars.getToolBarManager();
+
fCollapseAllAction = new CollapseAllAction(fTreeViewer);
toolBarManager.add(fCollapseAllAction);
- LexicalSortingAction action= new LexicalSortingAction(getTreeViewer());
+ LexicalSortingAction action = new LexicalSortingAction(getTreeViewer());
toolBarManager.add(action);
-
- fMemberFilterActionGroup= createMemberFilterActionGroup();
+
+ fMemberFilterActionGroup = createMemberFilterActionGroup();
if (fMemberFilterActionGroup != null) {
fMemberFilterActionGroup.fillActionBars(actionBars);
}
@@ -600,12 +600,12 @@ public abstract class AbstractCModelOutlinePage extends Page
if (fSelectionSearchGroup != null) {
fSelectionSearchGroup.fillActionBars(actionBars);
}
- IMenuManager menu= actionBars.getMenuManager();
+ IMenuManager menu = actionBars.getMenuManager();
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
-
- fToggleLinkingAction= new ToggleLinkingAction();
+
+ fToggleLinkingAction = new ToggleLinkingAction();
menu.add(fToggleLinkingAction);
-
+
menu.add(new Separator("group.layout")); //$NON-NLS-1$
menu.add(new IncludeGroupingAction(this));
menu.add(new MacroGroupingAction(this));
@@ -636,7 +636,7 @@ public abstract class AbstractCModelOutlinePage extends Page
// default: no refactoring actions
return null;
}
-
+
/**
* @return an ActionGroup contributing source actions or
* {@code null} if source actions are not supported
@@ -677,7 +677,7 @@ public abstract class AbstractCModelOutlinePage extends Page
protected void fireSelectionChanged(ISelection selection) {
// Create an event.
SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
-
+
// Fire the event.
Object[] listeners = fSelectionChangedListeners.getListeners();
for (int i = 0; i < listeners.length; ++i) {
@@ -687,7 +687,7 @@ public abstract class AbstractCModelOutlinePage extends Page
fRefactoringActionGroup.setContext(new ActionContext(selection));
fRefactoringActionGroup.updateActionBars();
}
-
+
if (fSourceActionGroup != null) {
fSourceActionGroup.setContext(new ActionContext(selection));
fSourceActionGroup.updateActionBars();
@@ -737,12 +737,12 @@ public abstract class AbstractCModelOutlinePage extends Page
@Override
public void setSelection(ISelection selection) {
- if (fTreeViewer != null)
+ if (fTreeViewer != null)
fTreeViewer.setSelection(selection);
}
/**
- * Set the current input to the content provider.
+ * Set the current input to the content provider.
* @param unit
*/
public void setInput(ITranslationUnit unit) {
@@ -753,21 +753,17 @@ public abstract class AbstractCModelOutlinePage extends Page
}
private void initDragAndDrop() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- Transfer[] transfers= new Transfer[] {
- LocalSelectionTransfer.getTransfer()
- };
-
+ int ops = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
+
// Drop adapter.
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new SelectionTransferDropAdapter(fTreeViewer)
- };
+ TransferDropTargetListener[] dropListeners = new TransferDropTargetListener[] {
+ new SelectionTransferDropAdapter(fTreeViewer) };
fTreeViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new DelegatingDropAdapter(dropListeners));
-
+
// Drag adapter.
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(fTreeViewer)
- };
+ TransferDragSourceListener[] dragListeners = new TransferDragSourceListener[] {
+ new SelectionTransferDragAdapter(fTreeViewer) };
fTreeViewer.addDragSupport(ops, transfers, new CDTViewerDragAdapter(fTreeViewer, dragListeners));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java
index 9c22ab5908c..40cef9d6b36 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java
@@ -65,7 +65,8 @@ public class AddIncludeAction extends TextEditorAction {
*/
public AddIncludeAction(ITextEditor editor) {
super(CEditorMessages.getBundleForConstructedKeys(), "AddInclude.", editor); //$NON-NLS-1$
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.ADD_INCLUDE_ON_SELECTION_ACTION);
+ CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this,
+ ICHelpContextIds.ADD_INCLUDE_ON_SELECTION_ACTION);
final Shell shell = editor.getEditorSite().getShell();
fAmbiguityResolver = new IElementSelector() {
@SuppressWarnings("unchecked")
@@ -75,11 +76,10 @@ public class AddIncludeAction extends TextEditorAction {
runInUIThread(new Runnable() {
@Override
public void run() {
- ElementListSelectionDialog dialog=
- new ElementListSelectionDialog(shell, new LabelProvider());
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());
dialog.setElements(elements.toArray());
- dialog.setTitle(CEditorMessages.AddInclude_label);
- dialog.setMessage(CEditorMessages.AddInclude_description);
+ dialog.setTitle(CEditorMessages.AddInclude_label);
+ dialog.setMessage(CEditorMessages.AddInclude_description);
if (dialog.open() == Window.OK)
result[0] = dialog.getFirstResult();
}
@@ -96,7 +96,7 @@ public class AddIncludeAction extends TextEditorAction {
if (tu == null) {
return;
}
- final ISelection selection= getTextEditor().getSelectionProvider().getSelection();
+ final ISelection selection = getTextEditor().getSelectionProvider().getSelection();
if (selection.isEmpty() || !(selection instanceof ITextSelection)) {
return;
}
@@ -112,7 +112,7 @@ public class AddIncludeAction extends TextEditorAction {
@Override
public IStatus run(IProgressMonitor monitor) {
try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(tu.getCProject(),
+ IIndex index = CCorePlugin.getIndexManager().getIndex(tu.getCProject(),
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT);
try {
index.acquireReadLock();
@@ -141,7 +141,7 @@ public class AddIncludeAction extends TextEditorAction {
// Apply text edits.
IEditorInput editorInput = editor.getEditorInput();
IDocument document = editor.getDocumentProvider().getDocument(editorInput);
- IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
+ IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
manager.beginCompoundChange();
try {
edit.apply(document);
@@ -151,8 +151,7 @@ public class AddIncludeAction extends TextEditorAction {
manager.endCompoundChange();
}
} else if (status.matches(IStatus.ERROR)) {
- ErrorDialog.openError(editor.getEditorSite().getShell(),
- CEditorMessages.AddInclude_error_title,
+ ErrorDialog.openError(editor.getEditorSite().getShell(), CEditorMessages.AddInclude_error_title,
CEditorMessages.AddInclude_insertion_failed, status);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.java
index d38331d86b4..41f1b832037 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.java
@@ -28,38 +28,38 @@ public class CAnnotationIterator implements Iterator<Annotation> {
private Iterator<Annotation> fIterator;
private Annotation fNext;
private boolean fReturnAllAnnotations;
-
+
/**
* Returns a new CAnnotationIterator.
* @param parent the parent iterator to iterate over annotations
* @param returnAllAnnotations whether to return all annotations or just problem annotations
*/
public CAnnotationIterator(Iterator<Annotation> parent, boolean returnAllAnnotations) {
- fReturnAllAnnotations= returnAllAnnotations;
- fIterator= parent;
+ fReturnAllAnnotations = returnAllAnnotations;
+ fIterator = parent;
skip();
}
private void skip() {
while (fIterator.hasNext()) {
- Annotation next= fIterator.next();
-
+ Annotation next = fIterator.next();
+
if (next.isMarkedDeleted())
continue;
if (fReturnAllAnnotations || next instanceof ICAnnotation || isProblemMarkerAnnotation(next)) {
- fNext= next;
+ fNext = next;
return;
}
}
- fNext= null;
+ fNext = null;
}
private static boolean isProblemMarkerAnnotation(Annotation annotation) {
if (!(annotation instanceof MarkerAnnotation))
return false;
try {
- return(((MarkerAnnotation)annotation).getMarker().isSubtypeOf(IMarker.PROBLEM));
+ return (((MarkerAnnotation) annotation).getMarker().isSubtypeOf(IMarker.PROBLEM));
} catch (CoreException e) {
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
index c0d9fa40e78..43c8e077802 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -43,12 +43,11 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
-
/**
* Outline page for C/C++ translation units.
*/
public class CContentOutlinePage extends AbstractCModelOutlinePage {
-
+
private Composite fParent;
private StackLayout fStackLayout;
private Composite fOutlinePage;
@@ -64,7 +63,7 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
* @returns the CEditor corresponding to this CContentOutlinePage.
*/
public CEditor getEditor() {
- return (CEditor)fEditor;
+ return (CEditor) fEditor;
}
@Override
@@ -85,13 +84,14 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
}
private Control createStatusPage(Composite parent) {
- final Link link= new Link(parent, SWT.NONE);
+ final Link link = new Link(parent, SWT.NONE);
link.setText(CEditorMessages.Scalability_outlineDisabled);
link.setToolTipText(CEditorMessages.Scalability_linkToolTip);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(link.getShell(), "org.eclipse.cdt.ui.preferences.CScalabilityPreferences", null, null).open(); //$NON-NLS-1$
+ PreferencesUtil.createPreferenceDialogOn(link.getShell(),
+ "org.eclipse.cdt.ui.preferences.CScalabilityPreferences", null, null).open(); //$NON-NLS-1$
}
});
return link;
@@ -99,8 +99,8 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
@Override
public void setInput(ITranslationUnit unit) {
- final CEditor editor= getEditor();
- if (editor.isEnableScalablilityMode()
+ final CEditor editor = getEditor();
+ if (editor.isEnableScalablilityMode()
&& PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_RECONCILER)) {
fScalabilityMode = true;
super.setInput(null);
@@ -135,7 +135,7 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
@Override
protected ActionGroup createOpenViewActionGroup() {
- OpenViewActionGroup ovag= new OpenViewActionGroup(this, getEditor());
+ OpenViewActionGroup ovag = new OpenViewActionGroup(this, getEditor());
ovag.setEnableIncludeBrowser(true);
return ovag;
}
@@ -144,7 +144,6 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
protected ActionGroup createRefactoringActionGroup() {
return new CRefactoringActionGroup(this);
}
-
@Override
protected ActionGroup createSourceActionGroup() {
@@ -160,10 +159,10 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
protected ActionGroup createMemberFilterActionGroup() {
return new MemberFilterActionGroup(getTreeViewer(), "COutlineViewer"); //$NON-NLS-1$
}
-
+
/**
* This action toggles namespace grouping
- *
+ *
* @since 5.2
*/
protected static class NamespaceGroupingAction extends Action {
@@ -175,7 +174,7 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
this.setImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE));
this.setDisabledImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE));
- boolean enabled= isNamspacesGroupingEnabled();
+ boolean enabled = isNamspacesGroupingEnabled();
setChecked(enabled);
}
@@ -184,17 +183,18 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
*/
@Override
public void run() {
- PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_NAMESPACES, isChecked());
+ PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_NAMESPACES,
+ isChecked());
}
- public boolean isNamspacesGroupingEnabled () {
+ public boolean isNamspacesGroupingEnabled() {
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES);
}
}
-
+
/**
* This action toggles member definition grouping
- *
+ *
* @since 5.2
*/
protected static class MemberGroupingAction extends Action {
@@ -205,7 +205,7 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
setToolTipText(ActionMessages.MemberGroupingAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC);
- boolean enabled= isMemberGroupingEnabled();
+ boolean enabled = isMemberGroupingEnabled();
setChecked(enabled);
}
@@ -217,19 +217,19 @@ public class CContentOutlinePage extends AbstractCModelOutlinePage {
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_MEMBERS, isChecked());
}
- public boolean isMemberGroupingEnabled () {
+ public boolean isMemberGroupingEnabled() {
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS);
}
}
-
+
@Override
protected void registerActionBars(IActionBars actionBars) {
super.registerActionBars(actionBars);
- IMenuManager menu= actionBars.getMenuManager();
+ IMenuManager menu = actionBars.getMenuManager();
// appendToGroup does not work reliably (bug 326748)
-// menu.appendToGroup("group.layout", new MemberGroupingAction(this)); //$NON-NLS-1$
-// menu.appendToGroup("group.layout", new NamespaceGroupingAction(this)); //$NON-NLS-1$
+ // menu.appendToGroup("group.layout", new MemberGroupingAction(this)); //$NON-NLS-1$
+ // menu.appendToGroup("group.layout", new NamespaceGroupingAction(this)); //$NON-NLS-1$
// add actions directly instead
menu.add(new MemberGroupingAction(this));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java
index 46e79627de2..81f5a690e2d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java
@@ -69,7 +69,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
/**
* Creates new content provider for dialog.
- *
+ *
* @param viewer
* Tree viewer.
*/
@@ -93,13 +93,13 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
public void run() {
if (!treeViewer.getControl().isDisposed()) {
if (fInitialDeltaPending) {
- fInitialDeltaPending= false;
+ fInitialDeltaPending = false;
treeViewer.setInput(root);
} else {
// setting the selection here causes a secondary editor to scroll
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=191358
- // final ISelection sel = treeViewer.getSelection();
- // treeViewer.setSelection(updateSelection(sel));
+ // final ISelection sel = treeViewer.getSelection();
+ // treeViewer.setSelection(updateSelection(sel));
treeViewer.refresh();
}
}
@@ -111,22 +111,25 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
/**
* Called after CEditor contents is changed.
* Existing elements can change their offset and length.
- *
+ *
* @param sdata delta information
*/
public void contentShift(CShiftData sdata) {
try {
ICElement[] el = root.getChildren();
- for (int i=0; i< el.length; i++) {
- if (!(el[i] instanceof SourceManipulation)) continue;
+ for (int i = 0; i < el.length; i++) {
+ if (!(el[i] instanceof SourceManipulation))
+ continue;
SourceManipulation sm = (SourceManipulation) el[i];
ISourceRange src = sm.getSourceRange();
int endOffset = src.getStartPos() + src.getLength();
-
+
// code BELOW this element changed - do nothing !
- if (sdata.getOffset() > endOffset) { continue; }
-
+ if (sdata.getOffset() > endOffset) {
+ continue;
+ }
+
if (sdata.getOffset() < src.getStartPos()) {
// code ABOVE this element changed - modify offset
sm.setIdPos(src.getIdStartPos() + sdata.getSize(), src.getIdLength());
@@ -138,9 +141,10 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
sm.setLines(src.getStartLine(), src.getEndLine() + sdata.getLines());
}
}
- } catch (CModelException e) {}
+ } catch (CModelException e) {
+ }
}
-
+
/**
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
@@ -167,19 +171,19 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
if (isTU) {
root = (ITranslationUnit) newInput;
if (fListener == null) {
- fListener= new ElementChangedListener();
+ fListener = new ElementChangedListener();
CoreModel.getDefault().addElementChangedListener(fListener);
- fPropertyListener= new PropertyListener();
+ fPropertyListener = new PropertyListener();
PreferenceConstants.getPreferenceStore().addPropertyChangeListener(fPropertyListener);
}
} else {
if (fListener != null) {
CoreModel.getDefault().removeElementChangedListener(fListener);
PreferenceConstants.getPreferenceStore().removePropertyChangeListener(fPropertyListener);
- fListener= null;
- fPropertyListener= null;
+ fListener = null;
+ fPropertyListener = null;
}
- root= null;
+ root = null;
}
}
@@ -191,10 +195,10 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
Object[] children = null;
// Use the deferred manager for the first time (when parsing)
if (element instanceof ITranslationUnit) {
- ITranslationUnit unit= (ITranslationUnit)element;
+ ITranslationUnit unit = (ITranslationUnit) element;
if (!unit.isOpen()) {
- fInitialDeltaPending= true;
- children= new Object[] { new PendingUpdateAdapter() };
+ fInitialDeltaPending = true;
+ children = new Object[] { new PendingUpdateAdapter() };
}
}
if (children == null) {
@@ -213,7 +217,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
/**
* Updates current selection.
- *
+ *
* @param sel
* Selection to update.
* @return Updated selection.
@@ -225,7 +229,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
while (iter.hasNext()) {
final Object o = iter.next();
if (o instanceof ICElement) {
- newSelection.add((ICElement)o);
+ newSelection.add((ICElement) o);
}
}
}
@@ -234,7 +238,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
/**
* The element change listener of the C outline viewer.
- *
+ *
* @see IElementChangedListener
*/
class ElementChangedListener implements IElementChangedListener {
@@ -252,10 +256,10 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
@Override
public void elementChanged(final ElementChangedEvent e) {
if (e.getType() == ElementChangedEvent.POST_SHIFT && e.getDelta() instanceof CShiftData) {
- contentShift((CShiftData)(e.getDelta()));
+ contentShift((CShiftData) (e.getDelta()));
return;
}
-
+
final ICElementDelta delta = findElement(root, e.getDelta());
if (delta != null) {
contentUpdated();
@@ -264,7 +268,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
/**
* Determines is structural change.
- *
+ *
* @param cuDelta
* Delta to check.
* @return <b>true</b> if structural change.
@@ -278,7 +282,8 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
if ((flags & ICElementDelta.F_CHILDREN) != 0) {
ret = true;
} else {
- ret = (flags & (ICElementDelta.F_CONTENT | ICElementDelta.F_FINE_GRAINED)) == ICElementDelta.F_CONTENT;
+ ret = (flags
+ & (ICElementDelta.F_CONTENT | ICElementDelta.F_FINE_GRAINED)) == ICElementDelta.F_CONTENT;
}
}
return ret;
@@ -286,15 +291,14 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
/**
* Searches for element.
- *
+ *
* @param unit
* Unit to search in.
* @param delta
* Delta.
* @return Found element.
*/
- protected ICElementDelta findElement(ICElement unit,
- ICElementDelta delta) {
+ protected ICElementDelta findElement(ICElement unit, ICElementDelta delta) {
if (delta == null || unit == null) {
return null;
}
@@ -329,9 +333,9 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
}
/**
- *
+ *
* Property change listener.
- *
+ *
* @author P.Tomaszewski
*/
class PropertyListener implements IPropertyChangeListener {
@@ -369,7 +373,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
contentUpdated();
}
}
- }else if (prop.equals(PreferenceConstants.OUTLINE_GROUP_MACROS)) {
+ } else if (prop.equals(PreferenceConstants.OUTLINE_GROUP_MACROS)) {
Object newValue = event.getNewValue();
if (newValue instanceof Boolean) {
boolean value = ((Boolean) newValue).booleanValue();
@@ -379,7 +383,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
}
}
}
-
+
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
index f23b99180ce..a466c7b923f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
@@ -112,7 +112,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
* Annotation representing an {@code IProblem}.
*/
public static class ProblemAnnotation extends Annotation implements ICAnnotation {
- private static final String INDEXER_ANNOTATION_TYPE= "org.eclipse.cdt.ui.indexmarker"; //$NON-NLS-1$
+ private static final String INDEXER_ANNOTATION_TYPE = "org.eclipse.cdt.ui.indexmarker"; //$NON-NLS-1$
private final ITranslationUnit fTranslationUnit;
private final int fId;
@@ -122,17 +122,16 @@ public class CDocumentProvider extends TextFileDocumentProvider {
private List<ICAnnotation> fOverlaids;
public ProblemAnnotation(IProblem problem, ITranslationUnit tu) {
- fTranslationUnit= tu;
+ fTranslationUnit = tu;
setText(problem.getMessage());
- fId= problem.getID();
- fIsProblem= problem.isError() || problem.isWarning();
- fArguments= isProblem() ? problem.getArguments() : null;
- setType(problem instanceof CoreSpellingProblem ?
- SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE);
+ fId = problem.getID();
+ fIsProblem = problem.isError() || problem.isWarning();
+ fArguments = isProblem() ? problem.getArguments() : null;
+ setType(problem instanceof CoreSpellingProblem ? SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE);
if (problem instanceof IPersistableProblem) {
- fMarkerType= ((IPersistableProblem) problem).getMarkerType();
+ fMarkerType = ((IPersistableProblem) problem).getMarkerType();
} else {
- fMarkerType= null;
+ fMarkerType = null;
}
}
@@ -164,7 +163,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
public void addOverlaid(ICAnnotation annotation) {
if (fOverlaids == null)
- fOverlaids= new ArrayList<>(1);
+ fOverlaids = new ArrayList<>(1);
fOverlaids.add(annotation);
}
@@ -173,7 +172,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
if (fOverlaids != null) {
fOverlaids.remove(annotation);
if (fOverlaids.size() == 0)
- fOverlaids= null;
+ fOverlaids = null;
}
}
@@ -207,7 +206,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
Object fValue;
}
- private List<Entry> fList= new ArrayList<>(2);
+ private List<Entry> fList = new ArrayList<>(2);
private int fAnchor;
public ReverseMap() {
@@ -217,20 +216,20 @@ public class CDocumentProvider extends TextFileDocumentProvider {
Entry entry;
// behind anchor
- int length= fList.size();
- for (int i= fAnchor; i < length; i++) {
- entry= fList.get(i);
+ int length = fList.size();
+ for (int i = fAnchor; i < length; i++) {
+ entry = fList.get(i);
if (entry.fPosition.equals(position)) {
- fAnchor= i;
+ fAnchor = i;
return entry.fValue;
}
}
// before anchor
- for (int i= 0; i < fAnchor; i++) {
- entry= fList.get(i);
+ for (int i = 0; i < fAnchor; i++) {
+ entry = fList.get(i);
if (entry.fPosition.equals(position)) {
- fAnchor= i;
+ fAnchor = i;
return entry.fValue;
}
}
@@ -240,37 +239,37 @@ public class CDocumentProvider extends TextFileDocumentProvider {
private int getIndex(Position position) {
Entry entry;
- int length= fList.size();
- for (int i= 0; i < length; i++) {
- entry= fList.get(i);
+ int length = fList.size();
+ for (int i = 0; i < length; i++) {
+ entry = fList.get(i);
if (entry.fPosition.equals(position))
return i;
}
return -1;
}
- public void put(Position position, Object value) {
- int index= getIndex(position);
+ public void put(Position position, Object value) {
+ int index = getIndex(position);
if (index == -1) {
- Entry entry= new Entry();
- entry.fPosition= position;
- entry.fValue= value;
+ Entry entry = new Entry();
+ entry.fPosition = position;
+ entry.fValue = value;
fList.add(entry);
} else {
- Entry entry= fList.get(index);
- entry.fValue= value;
+ Entry entry = fList.get(index);
+ entry.fValue = value;
}
}
public void remove(Position position) {
- int index= getIndex(position);
+ int index = getIndex(position);
if (index > -1)
fList.remove(index);
}
public void clear() {
fList.clear();
- fAnchor= 0;
+ fAnchor = 0;
}
}
@@ -319,7 +318,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
List<IProblem> fReportedProblems;
}
- private final ThreadLocal<ProblemRequestorState> fProblemRequestorState= new ThreadLocal<>();
+ private final ThreadLocal<ProblemRequestorState> fProblemRequestorState = new ThreadLocal<>();
private int fStateCount;
private ITranslationUnit fTranslationUnit;
@@ -327,21 +326,21 @@ public class CDocumentProvider extends TextFileDocumentProvider {
private IProgressMonitor fProgressMonitor;
private boolean fIsActive;
- private final ReverseMap fReverseMap= new ReverseMap();
+ private final ReverseMap fReverseMap = new ReverseMap();
private List<CMarkerAnnotation> fPreviouslyOverlaid;
- private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<>();
+ private List<CMarkerAnnotation> fCurrentlyOverlaid = new ArrayList<>();
public TranslationUnitAnnotationModel(IResource resource) {
super(resource);
}
- public void setTranslationUnit(ITranslationUnit unit) {
- fTranslationUnit= unit;
+ public void setTranslationUnit(ITranslationUnit unit) {
+ fTranslationUnit = unit;
}
@Override
protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
- String markerType= MarkerUtilities.getMarkerType(marker);
+ String markerType = MarkerUtilities.getMarkerType(marker);
if (markerType != null && markerType.startsWith(CMarkerAnnotation.C_MARKER_TYPE_PREFIX)) {
return new CMarkerAnnotation(marker);
}
@@ -350,23 +349,23 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
protected Position createPositionFromMarker(IMarker marker) {
- int start= MarkerUtilities.getCharStart(marker);
- int end= MarkerUtilities.getCharEnd(marker);
+ int start = MarkerUtilities.getCharStart(marker);
+ int end = MarkerUtilities.getCharEnd(marker);
if (start > end) {
- end= start + end;
- start= end - start;
- end= end - start;
+ end = start + end;
+ start = end - start;
+ end = end - start;
}
if (start == -1 && end == -1) {
// marker line number is 1-based
- int line= MarkerUtilities.getLineNumber(marker);
+ int line = MarkerUtilities.getLineNumber(marker);
if (line > 0 && fDocument != null) {
try {
- IRegion lineRegion= fDocument.getLineInformation(line - 1);
- start= lineRegion.getOffset();
- end= start + lineRegion.getLength();
+ IRegion lineRegion = fDocument.getLineInformation(line - 1);
+ start = lineRegion.getOffset();
+ end = start + lineRegion.getLength();
if (marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)) {
// strip leading whitespace
while (start < end && Character.isWhitespace(fDocument.getChar(start))) {
@@ -391,11 +390,11 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
protected Position createPositionFromProblem(IProblem problem) {
- int start= problem.getSourceStart();
+ int start = problem.getSourceStart();
if (start < 0)
return null;
- int length= problem.getSourceEnd() - problem.getSourceStart() + 1;
+ int length = problem.getSourceEnd() - problem.getSourceStart() + 1;
if (length < 0)
return null;
return new Position(start, length);
@@ -403,14 +402,14 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
public void beginReporting() {
- ProblemRequestorState state= fProblemRequestorState.get();
+ ProblemRequestorState state = fProblemRequestorState.get();
if (state == null)
internalBeginReporting(false);
}
@Override
public void beginReportingSequence() {
- ProblemRequestorState state= fProblemRequestorState.get();
+ ProblemRequestorState state = fProblemRequestorState.get();
if (state == null)
internalBeginReporting(true);
}
@@ -423,9 +422,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/
private void internalBeginReporting(boolean insideReportingSequence) {
if (fTranslationUnit != null) {
- ProblemRequestorState state= new ProblemRequestorState();
- state.fInsideReportingSequence= insideReportingSequence;
- state.fReportedProblems= new ArrayList<>();
+ ProblemRequestorState state = new ProblemRequestorState();
+ state.fInsideReportingSequence = insideReportingSequence;
+ state.fReportedProblems = new ArrayList<>();
synchronized (getLockObject()) {
fProblemRequestorState.set(state);
++fStateCount;
@@ -436,7 +435,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
public void acceptProblem(IProblem problem) {
if (isActive()) {
- ProblemRequestorState state= fProblemRequestorState.get();
+ ProblemRequestorState state = fProblemRequestorState.get();
if (state != null && isReliable(problem)) {
state.fReportedProblems.add(problem);
}
@@ -455,23 +454,23 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
public void endReporting() {
- ProblemRequestorState state= fProblemRequestorState.get();
+ ProblemRequestorState state = fProblemRequestorState.get();
if (state != null && !state.fInsideReportingSequence)
internalEndReporting(state);
}
@Override
public void endReportingSequence() {
- ProblemRequestorState state= fProblemRequestorState.get();
+ ProblemRequestorState state = fProblemRequestorState.get();
if (state != null && state.fInsideReportingSequence)
internalEndReporting(state);
}
private void internalEndReporting(ProblemRequestorState state) {
- int stateCount= 0;
+ int stateCount = 0;
synchronized (getLockObject()) {
--fStateCount;
- stateCount= fStateCount;
+ stateCount = fStateCount;
fProblemRequestorState.set(null);
}
@@ -486,16 +485,16 @@ public class CDocumentProvider extends TextFileDocumentProvider {
if (fProgressMonitor != null && fProgressMonitor.isCanceled())
return;
- boolean temporaryProblemsChanged= false;
+ boolean temporaryProblemsChanged = false;
synchronized (getLockObject()) {
- boolean isCanceled= false;
+ boolean isCanceled = false;
- fPreviouslyOverlaid= fCurrentlyOverlaid;
- fCurrentlyOverlaid= new ArrayList<>();
+ fPreviouslyOverlaid = fCurrentlyOverlaid;
+ fCurrentlyOverlaid = new ArrayList<>();
if (fGeneratedAnnotations.size() > 0) {
- temporaryProblemsChanged= true;
+ temporaryProblemsChanged = true;
removeAnnotations(fGeneratedAnnotations, false, true);
fGeneratedAnnotations.clear();
}
@@ -503,19 +502,19 @@ public class CDocumentProvider extends TextFileDocumentProvider {
if (reportedProblems != null) {
for (IProblem problem : reportedProblems) {
if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
- isCanceled= true;
+ isCanceled = true;
break;
}
- Position position= createPositionFromProblem(problem);
+ Position position = createPositionFromProblem(problem);
if (position != null) {
try {
- ProblemAnnotation annotation= new ProblemAnnotation(problem, fTranslationUnit);
+ ProblemAnnotation annotation = new ProblemAnnotation(problem, fTranslationUnit);
overlayMarkers(position, annotation);
addAnnotation(annotation, position, false);
fGeneratedAnnotations.add(annotation);
- temporaryProblemsChanged= true;
+ temporaryProblemsChanged = true;
} catch (BadLocationException x) {
// Ignore invalid position
}
@@ -524,7 +523,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
removeMarkerOverlays(isCanceled);
- fPreviouslyOverlaid= null;
+ fPreviouslyOverlaid = null;
}
if (temporaryProblemsChanged)
@@ -535,9 +534,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
if (isCanceled) {
fCurrentlyOverlaid.addAll(fPreviouslyOverlaid);
} else if (fPreviouslyOverlaid != null) {
- Iterator<CMarkerAnnotation> e= fPreviouslyOverlaid.iterator();
+ Iterator<CMarkerAnnotation> e = fPreviouslyOverlaid.iterator();
while (e.hasNext()) {
- CMarkerAnnotation annotation= e.next();
+ CMarkerAnnotation annotation = e.next();
annotation.setOverlay(null);
}
}
@@ -549,9 +548,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/
private void setOverlay(Object value, ProblemAnnotation problemAnnotation) {
if (value instanceof CMarkerAnnotation) {
- CMarkerAnnotation annotation= (CMarkerAnnotation) value;
- if (annotation.isProblem()
- && (!annotation.isQuickFixableStateSet() || !annotation.isQuickFixable())) {
+ CMarkerAnnotation annotation = (CMarkerAnnotation) value;
+ if (annotation.isProblem() && (!annotation.isQuickFixableStateSet() || !annotation.isQuickFixable())) {
annotation.setOverlay(problemAnnotation);
fPreviouslyOverlaid.remove(annotation);
fCurrentlyOverlaid.add(annotation);
@@ -560,9 +558,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) {
- Object value= getAnnotations(position);
+ Object value = getAnnotations(position);
if (value instanceof List<?>) {
- List<?> list= (List<?>) value;
+ List<?> list = (List<?>) value;
for (Object element : list) {
setOverlay(element, problemAnnotation);
}
@@ -575,7 +573,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
* Tells this annotation model to collect temporary problems from now on.
*/
private void startCollectingProblems() {
- fGeneratedAnnotations= new ArrayList<>();
+ fGeneratedAnnotations = new ArrayList<>();
}
/**
@@ -584,7 +582,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
private void stopCollectingProblems() {
if (fGeneratedAnnotations != null)
removeAnnotations(fGeneratedAnnotations, true, true);
- fGeneratedAnnotations= null;
+ fGeneratedAnnotations = null;
}
@Override
@@ -594,13 +592,13 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
+ fProgressMonitor = monitor;
}
@Override
public void setIsActive(boolean isActive) {
if (fIsActive != isActive) {
- fIsActive= isActive;
+ fIsActive = isActive;
if (fIsActive)
startCollectingProblems();
else
@@ -616,18 +614,19 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
@SuppressWarnings({ "unchecked" })
- protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
+ protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged)
+ throws BadLocationException {
super.addAnnotation(annotation, position, fireModelChanged);
synchronized (getLockObject()) {
- Object cached= fReverseMap.get(position);
+ Object cached = fReverseMap.get(position);
if (cached == null) {
fReverseMap.put(position, annotation);
} else if (cached instanceof List) {
- List<Annotation> list= (List<Annotation>) cached;
+ List<Annotation> list = (List<Annotation>) cached;
list.add(annotation);
} else if (cached instanceof Annotation) {
- List<Object> list= new ArrayList<>(2);
+ List<Object> list = new ArrayList<>(2);
list.add(cached);
list.add(annotation);
fReverseMap.put(position, list);
@@ -645,11 +644,11 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
- Position position= getPosition(annotation);
+ Position position = getPosition(annotation);
synchronized (getLockObject()) {
- Object cached= fReverseMap.get(position);
+ Object cached = fReverseMap.get(position);
if (cached instanceof List<?>) {
- List<?> list= (List<?>) cached;
+ List<?> list = (List<?>) cached;
list.remove(annotation);
if (list.size() == 1) {
fReverseMap.put(position, list.get(0));
@@ -663,16 +662,17 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
}
- protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
+ protected static class GlobalAnnotationModelListener
+ implements IAnnotationModelListener, IAnnotationModelListenerExtension {
private ListenerList<IAnnotationModelListener> fListenerList;
public GlobalAnnotationModelListener() {
- fListenerList= new ListenerList<IAnnotationModelListener>(ListenerList.IDENTITY);
+ fListenerList = new ListenerList<IAnnotationModelListener>(ListenerList.IDENTITY);
}
@Override
public void modelChanged(IAnnotationModel model) {
- Object[] listeners= fListenerList.getListeners();
+ Object[] listeners = fListenerList.getListeners();
for (Object listener : listeners) {
((IAnnotationModelListener) listener).modelChanged(model);
}
@@ -680,7 +680,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
public void modelChanged(AnnotationModelEvent event) {
- Object[] listeners= fListenerList.getListeners();
+ Object[] listeners = fListenerList.getListeners();
for (Object curr : listeners) {
if (curr instanceof IAnnotationModelListenerExtension) {
((IAnnotationModelListenerExtension) curr).modelChanged(event);
@@ -698,7 +698,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
/** Preference key for temporary problems */
- private static final String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS;
+ private static final String HANDLE_TEMPORARY_PROBLEMS = PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS;
/** Internal property changed listener */
private IPropertyChangeListener fPropertyListener;
@@ -707,11 +707,12 @@ public class CDocumentProvider extends TextFileDocumentProvider {
public CDocumentProvider() {
super();
- IDocumentProvider parentProvider= new ExternalSearchDocumentProvider();
- parentProvider= new ForwardingDocumentProvider(ICPartitions.C_PARTITIONING, new CDocumentSetupParticipant(), parentProvider);
+ IDocumentProvider parentProvider = new ExternalSearchDocumentProvider();
+ parentProvider = new ForwardingDocumentProvider(ICPartitions.C_PARTITIONING, new CDocumentSetupParticipant(),
+ parentProvider);
setParentDocumentProvider(parentProvider);
- fGlobalAnnotationModelListener= new GlobalAnnotationModelListener();
- fPropertyListener= new IPropertyChangeListener() {
+ fGlobalAnnotationModelListener = new GlobalAnnotationModelListener();
+ fPropertyListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (HANDLE_TEMPORARY_PROBLEMS.equals(event.getProperty()))
@@ -724,9 +725,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
public void connect(Object element) throws CoreException {
super.connect(element);
- IDocument document= getDocument(element);
+ IDocument document = getDocument(element);
if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension= (IDocumentExtension3) document;
+ IDocumentExtension3 extension = (IDocumentExtension3) document;
if (extension.getDocumentPartitioner(ICPartitions.C_PARTITIONING) == null)
new CDocumentSetupParticipant().setup(document);
}
@@ -744,9 +745,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
if (element == null) {
// Not in a source folder?
- ICProject cproject= CoreModel.getDefault().create(file.getProject());
+ ICProject cproject = CoreModel.getDefault().create(file.getProject());
if (cproject != null) {
- String contentTypeId= CoreModel.getRegistedContentTypeId(file.getProject(), file.getName());
+ String contentTypeId = CoreModel.getRegistedContentTypeId(file.getProject(), file.getName());
if (contentTypeId != null) {
return new TranslationUnit(cproject, file, contentTypeId);
}
@@ -775,15 +776,15 @@ public class CDocumentProvider extends TextFileDocumentProvider {
ITranslationUnitEditorInput input = (ITranslationUnitEditorInput) element;
original = input.getTranslationUnit();
} else if (element instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) element;
- ILocationProvider locationProvider= adaptable.getAdapter(ILocationProvider.class);
+ IAdaptable adaptable = (IAdaptable) element;
+ ILocationProvider locationProvider = adaptable.getAdapter(ILocationProvider.class);
if (locationProvider instanceof ILocationProviderExtension) {
- URI uri= ((ILocationProviderExtension) locationProvider).getURI(element);
- original= createTranslationUnit(uri);
+ URI uri = ((ILocationProviderExtension) locationProvider).getURI(element);
+ original = createTranslationUnit(uri);
}
if (original == null && locationProvider != null) {
- IPath location= locationProvider.getPath(element);
- original= createTranslationUnit(location);
+ IPath location = locationProvider.getPath(element);
+ original = createTranslationUnit(location);
}
}
@@ -797,21 +798,23 @@ public class CDocumentProvider extends TextFileDocumentProvider {
TranslationUnitInfo tuInfo = (TranslationUnitInfo) info;
setUpSynchronization(tuInfo);
- IProblemRequestor requestor= tuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) tuInfo.fModel : null;
- tuInfo.fCopy = CDTUITools.getWorkingCopyManager().getSharedWorkingCopy(original, requestor, getProgressMonitor());
+ IProblemRequestor requestor = tuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) tuInfo.fModel
+ : null;
+ tuInfo.fCopy = CDTUITools.getWorkingCopyManager().getSharedWorkingCopy(original, requestor,
+ getProgressMonitor());
if (tuInfo.fModel instanceof TranslationUnitAnnotationModel) {
- TranslationUnitAnnotationModel model= (TranslationUnitAnnotationModel) tuInfo.fModel;
+ TranslationUnitAnnotationModel model = (TranslationUnitAnnotationModel) tuInfo.fModel;
model.setTranslationUnit(tuInfo.fCopy);
} else {
IPath location = original.getLocation();
if (location != null) {
IResource markerResource = CUIPlugin.getWorkspace().getRoot();
IAnnotationModel originalModel = tuInfo.fModel;
- ExternalSearchAnnotationModel externalSearchModel =
- new ExternalSearchAnnotationModel(markerResource, location, IResource.DEPTH_ONE);
- tuInfo.fModel= externalSearchModel;
- IAnnotationModel fileBufferModel= tuInfo.fTextFileBuffer.getAnnotationModel();
+ ExternalSearchAnnotationModel externalSearchModel = new ExternalSearchAnnotationModel(markerResource,
+ location, IResource.DEPTH_ONE);
+ tuInfo.fModel = externalSearchModel;
+ IAnnotationModel fileBufferModel = tuInfo.fTextFileBuffer.getAnnotationModel();
if (fileBufferModel != null) {
externalSearchModel.addAnnotationModel("fileBufferModel", fileBufferModel); //$NON-NLS-1$
}
@@ -823,7 +826,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
if (tuInfo.fModel != null)
tuInfo.fModel.addAnnotationModelListener(fGlobalAnnotationModelListener);
if (requestor instanceof IProblemRequestorExtension) {
- IProblemRequestorExtension extension= (IProblemRequestorExtension) requestor;
+ IProblemRequestorExtension extension = (IProblemRequestorExtension) requestor;
extension.setIsActive(isHandlingTemporaryProblems());
}
return tuInfo;
@@ -838,7 +841,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
if (location == null) {
return null;
}
- IEditorInput input= EditorUtility.getEditorInputForLocation(location, null);
+ IEditorInput input = EditorUtility.getEditorInputForLocation(location, null);
if (input instanceof ITranslationUnitEditorInput) {
return ((ITranslationUnitEditorInput) input).getTranslationUnit();
}
@@ -854,7 +857,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
if (uri == null) {
return null;
}
- IEditorInput input= EditorUtility.getEditorInputForLocation(uri, null);
+ IEditorInput input = EditorUtility.getEditorInputForLocation(uri, null);
if (input instanceof ITranslationUnitEditorInput) {
return ((ITranslationUnitEditorInput) input).getTranslationUnit();
}
@@ -877,8 +880,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
SubMonitor progress = SubMonitor.convert(monitor, 100);
try {
- IDocument document= info.fTextFileBuffer.getDocument();
- IResource resource= info.fCopy.getResource();
+ IDocument document = info.fTextFileBuffer.getDocument();
+ IResource resource = info.fCopy.getResource();
if (resource instanceof IFile && !resource.exists()) {
// The underlying resource has been deleted, just recreate the file, ignore the rest
@@ -887,7 +890,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
try {
- CoreException saveActionException= null;
+ CoreException saveActionException = null;
try {
performSaveActions(info.fCopy, info.fTextFileBuffer, progress.split(20));
} catch (CoreException e) {
@@ -916,7 +919,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document,
final boolean overwrite) throws CoreException {
- final FileInfo info= getFileInfo(element);
+ final FileInfo info = getFileInfo(element);
if (info instanceof TranslationUnitInfo) {
return new DocumentProviderOperation() {
@Override
@@ -927,7 +930,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
@Override
public ISchedulingRule getSchedulingRule() {
if (info.fElement instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput) info.fElement).getFile();
+ IFile file = ((IFileEditorInput) info.fElement).getFile();
return computeSchedulingRule(file);
}
return null;
@@ -942,8 +945,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
TextEdit rootEdit = null;
ICProject cProject = tu.getCProject();
- Map<String, Object> options = new HashMap<String, Object>(cProject.getOptions(true));
- options.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu);
+ Map<String, Object> options = new HashMap<String, Object>(cProject.getOptions(true));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu);
CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
String code = document.get();
TextEdit[] formatEdits = formatter.format(CodeFormatter.K_TRANSLATION_UNIT, code, changedRegions,
@@ -968,11 +971,13 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/
private void performSaveActions(ITranslationUnit tu, ITextFileBuffer buffer, IProgressMonitor monitor)
throws CoreException {
- if (shouldRemoveTrailingWhitespace() || shouldAddNewlineAtEof() || shouldFormatCode() || shouldAlignAllConst()) {
+ if (shouldRemoveTrailingWhitespace() || shouldAddNewlineAtEof() || shouldFormatCode()
+ || shouldAlignAllConst()) {
SubMonitor progress = SubMonitor.convert(monitor, 3);
- IDocumentUndoManager undoManager= null;
- IRegion[] changedRegions= needsChangedRegions() ?
- EditorUtility.calculateChangedLineRegions(buffer, progress.split(1)) : null;
+ IDocumentUndoManager undoManager = null;
+ IRegion[] changedRegions = needsChangedRegions()
+ ? EditorUtility.calculateChangedLineRegions(buffer, progress.split(1))
+ : null;
IDocument document = buffer.getDocument();
try {
if (shouldFormatCode() && tu != null) {
@@ -982,7 +987,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
TextEdit edit = formatCode(tu, document, changedRegions, progress.split(1));
if (edit != null) {
- undoManager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
+ undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
undoManager.beginCompoundChange();
edit.apply(document);
}
@@ -991,7 +996,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
TextEdit edit = createTrailingWhitespaceEdit(document, changedRegions);
if (edit != null) {
if (undoManager == null) {
- undoManager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
+ undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
undoManager.beginCompoundChange();
}
edit.apply(document);
@@ -1002,9 +1007,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
} catch (MalformedTreeException | BadLocationException e) {
- String message= e.getMessage();
+ String message = e.getMessage();
if (message == null)
- message= e.getClass().getSimpleName();
+ message = e.getClass().getSimpleName();
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, message, e));
} finally {
if (undoManager != null)
@@ -1018,28 +1023,25 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
private static boolean isLimitedFormatCode() {
- return PreferenceConstants.getPreferenceStore().getBoolean(
- PreferenceConstants.FORMAT_SOURCE_CODE_LIMIT_TO_EDITED_LINES);
+ return PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.FORMAT_SOURCE_CODE_LIMIT_TO_EDITED_LINES);
}
private static boolean shouldAddNewlineAtEof() {
- return PreferenceConstants.getPreferenceStore().getBoolean(
- PreferenceConstants.ENSURE_NEWLINE_AT_EOF);
+ return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.ENSURE_NEWLINE_AT_EOF);
}
private static boolean shouldRemoveTrailingWhitespace() {
- return PreferenceConstants.getPreferenceStore().getBoolean(
- PreferenceConstants.REMOVE_TRAILING_WHITESPACE);
+ return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.REMOVE_TRAILING_WHITESPACE);
}
private static boolean isLimitedRemoveTrailingWhitespace() {
- return PreferenceConstants.getPreferenceStore().getBoolean(
- PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES);
+ return PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES);
}
private static boolean shouldAlignAllConst() {
- return PreferenceConstants.getPreferenceStore().getBoolean(
- PreferenceConstants.ALIGN_ALL_CONST);
+ return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.ALIGN_ALL_CONST);
}
private static boolean needsChangedRegions() {
@@ -1080,9 +1082,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
charPos++;
if (charPos < lineEnd) {
// check partition - don't remove whitespace inside strings
- ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, charPos, false);
+ ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING,
+ charPos, false);
if (!ICPartitions.C_STRING.equals(partition.getType())) {
- lastWhitespaceEdit= new DeleteEdit(charPos, lineEnd - charPos);
+ lastWhitespaceEdit = new DeleteEdit(charPos, lineEnd - charPos);
if (rootEdit == null) {
rootEdit = new MultiTextEdit();
}
@@ -1098,10 +1101,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
IRegion lastLineRegion = document.getLineInformationOfOffset(endOffset);
// Insert newline at the end of the document if the last line is not empty and
// will not become empty after removal of trailing whitespace.
- if (lastLineRegion.getLength() != 0 &&
- (lastWhitespaceEdit == null ||
- lastWhitespaceEdit.getOffset() != lastLineRegion.getOffset() ||
- lastWhitespaceEdit.getLength() != lastLineRegion.getLength())) {
+ if (lastLineRegion.getLength() != 0
+ && (lastWhitespaceEdit == null || lastWhitespaceEdit.getOffset() != lastLineRegion.getOffset()
+ || lastWhitespaceEdit.getLength() != lastLineRegion.getLength())) {
TextEdit edit = new InsertEdit(endOffset, TextUtilities.getDefaultLineDelimiter(document));
if (rootEdit == null) {
rootEdit = edit;
@@ -1116,21 +1118,21 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return rootEdit;
}
-// private static boolean isWhitespaceRegion(IDocument document, IRegion region) throws BadLocationException {
-// int end = region.getOffset() + region.getLength();
-// for (int i = region.getOffset(); i < end; i++) {
-// if (!Character.isWhitespace(document.getChar(i))) {
-// return false;
-// }
-// }
-// return true;
-// }
+ // private static boolean isWhitespaceRegion(IDocument document, IRegion region) throws BadLocationException {
+ // int end = region.getOffset() + region.getLength();
+ // for (int i = region.getOffset(); i < end; i++) {
+ // if (!Character.isWhitespace(document.getChar(i))) {
+ // return false;
+ // }
+ // }
+ // return true;
+ // }
/**
* Returns the preference whether handling temporary problems is enabled.
*/
protected boolean isHandlingTemporaryProblems() {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS);
}
@@ -1138,11 +1140,11 @@ public class CDocumentProvider extends TextFileDocumentProvider {
* Switches the state of problem acceptance according to the value in the preference store.
*/
protected void enableHandlingTemporaryProblems() {
- boolean enable= isHandlingTemporaryProblems();
- for (Iterator<?> iter= getFileInfosIterator(); iter.hasNext();) {
- FileInfo info= (FileInfo) iter.next();
+ boolean enable = isHandlingTemporaryProblems();
+ for (Iterator<?> iter = getFileInfosIterator(); iter.hasNext();) {
+ FileInfo info = (FileInfo) iter.next();
if (info.fModel instanceof IProblemRequestorExtension) {
- IProblemRequestorExtension extension= (IProblemRequestorExtension) info.fModel;
+ IProblemRequestorExtension extension = (IProblemRequestorExtension) info.fModel;
extension.setIsActive(enable);
}
}
@@ -1166,7 +1168,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
public void shutdown() {
-// CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyListener);
+ // CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyListener);
Iterator<?> e = getConnectedElementsIterator();
while (e.hasNext())
disconnect(e.next());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java
index e2781f183ea..9a84019639c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java
@@ -25,17 +25,16 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.text.CTextTools;
-
/**
* CDocumentSetupParticipant
*/
public class CDocumentSetupParticipant implements IDocumentSetupParticipant, IDocumentSetupParticipantExtension {
/**
- *
+ *
*/
public CDocumentSetupParticipant() {
}
-
+
/*
* @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
*/
@@ -43,13 +42,13 @@ public class CDocumentSetupParticipant implements IDocumentSetupParticipant, IDo
public void setup(IDocument document) {
setup(document, null, null);
}
-
+
/*
* @see org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension#setup(org.eclipse.jface.text.IDocument, org.eclipse.core.runtime.IPath, org.eclipse.core.filebuffers.LocationKind)
*/
@Override
public void setup(IDocument document, IPath location, LocationKind locationKind) {
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
tools.setupCDocument(document, location, locationKind);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
index e73b5e15136..2c528e49372 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
@@ -254,14 +254,14 @@ import org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager;
/**
* C/C++ source editor.
*/
-public class CEditor extends TextEditor implements ICEditor, ISelectionChangedListener, ICReconcilingListener,
- ICModelBasedEditor {
+public class CEditor extends TextEditor
+ implements ICEditor, ISelectionChangedListener, ICReconcilingListener, ICModelBasedEditor {
/** Marker used for synchronization from Problems View to the editor on double-click. */
private IMarker fSyncProblemsViewMarker;
/**
* A slightly modified implementation of IGotomarker compared to AbstractDecoratedTextEditor.
- *
+ *
* @since 5.0
*/
private final class GotoMarkerAdapter implements IGotoMarker {
@@ -273,22 +273,22 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (getSourceViewer() == null)
return;
- int start= MarkerUtilities.getCharStart(marker);
- int end= MarkerUtilities.getCharEnd(marker);
-
- boolean selectLine= start < 0 || end < 0;
+ int start = MarkerUtilities.getCharStart(marker);
+ int end = MarkerUtilities.getCharEnd(marker);
+
+ boolean selectLine = start < 0 || end < 0;
// Look up the current range of the marker when the document has been edited.
- IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+ IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
if (model instanceof AbstractMarkerAnnotationModel) {
- AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
- Position pos= markerModel.getMarkerPosition(marker);
+ AbstractMarkerAnnotationModel markerModel = (AbstractMarkerAnnotationModel) model;
+ Position pos = markerModel.getMarkerPosition(marker);
if (pos != null && !pos.isDeleted()) {
// Use position instead of marker values
- start= pos.getOffset();
- end= pos.getOffset() + pos.getLength();
+ start = pos.getOffset();
+ end = pos.getOffset() + pos.getLength();
// Use position as is
- selectLine= false;
+ selectLine = false;
}
if (pos != null && pos.isDeleted()) {
@@ -297,29 +297,29 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
}
- IDocument document= getDocumentProvider().getDocument(getEditorInput());
+ IDocument document = getDocumentProvider().getDocument(getEditorInput());
if (selectLine) {
int line;
try {
if (start >= 0) {
- IRegion lineInfo= document.getLineInformationOfOffset(start);
- start= lineInfo.getOffset();
- end= start + lineInfo.getLength();
+ IRegion lineInfo = document.getLineInformationOfOffset(start);
+ start = lineInfo.getOffset();
+ end = start + lineInfo.getLength();
} else {
- line= MarkerUtilities.getLineNumber(marker);
+ line = MarkerUtilities.getLineNumber(marker);
// Marker line numbers are 1-based
- -- line;
- IRegion lineInfo= document.getLineInformation(line);
- start= lineInfo.getOffset();
- end= start + lineInfo.getLength();
+ --line;
+ IRegion lineInfo = document.getLineInformation(line);
+ start = lineInfo.getOffset();
+ end = start + lineInfo.getLength();
}
} catch (BadLocationException e) {
return;
}
}
- int length= document.getLength();
+ int length = document.getLength();
if (end - 1 < length && start < length) {
fSyncProblemsViewMarker = marker;
selectAndReveal(start, end - start);
@@ -330,7 +330,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
class AdaptedSourceViewer extends CSourceViewer {
public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
- boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
+ boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store);
}
@@ -345,18 +345,18 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
return;
switch (operation) {
- case CONTENTASSIST_PROPOSALS:
- String msg= fContentAssistant.showPossibleCompletions();
- setStatusLineErrorMessage(msg);
- return;
- case QUICK_ASSIST:
- /*
- * TODO: We can get rid of this once the SourceViewer has a way to update
- * the status line https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787
- */
- msg= fQuickAssistAssistant.showPossibleQuickAssists();
- setStatusLineErrorMessage(msg);
- return;
+ case CONTENTASSIST_PROPOSALS:
+ String msg = fContentAssistant.showPossibleCompletions();
+ setStatusLineErrorMessage(msg);
+ return;
+ case QUICK_ASSIST:
+ /*
+ * TODO: We can get rid of this once the SourceViewer has a way to update
+ * the status line https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787
+ */
+ msg = fQuickAssistAssistant.showPossibleQuickAssists();
+ setStatusLineErrorMessage(msg);
+ return;
}
super.doOperation(operation);
@@ -392,28 +392,28 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private IFormattingContext createFormattingContext(int selectionOffset, int selectionLength,
boolean formattingScopeForEmptySelectionSupported) {
- IFormattingContext context= new FormattingContext();
+ IFormattingContext context = new FormattingContext();
Map<String, Object> preferences;
- ICElement inputCElement= getInputCElement();
- ICProject cProject= inputCElement != null ? inputCElement.getCProject() : null;
+ ICElement inputCElement = getInputCElement();
+ ICProject cProject = inputCElement != null ? inputCElement.getCProject() : null;
if (cProject == null) {
- preferences= new HashMap<String, Object>(CCorePlugin.getOptions());
+ preferences = new HashMap<String, Object>(CCorePlugin.getOptions());
} else {
- preferences= new HashMap<String, Object>(cProject.getOptions(true));
+ preferences = new HashMap<String, Object>(cProject.getOptions(true));
}
if (inputCElement instanceof ITranslationUnit) {
- ITranslationUnit tu= (ITranslationUnit) inputCElement;
+ ITranslationUnit tu = (ITranslationUnit) inputCElement;
ILanguage language;
try {
- language= tu.getLanguage();
+ language = tu.getLanguage();
} catch (CoreException e) {
// Use fallback CPP
- language= GPPLanguage.getDefault();
+ language = GPPLanguage.getDefault();
}
preferences.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu);
- preferences.put(DefaultCodeFormatterConstants.FORMATTER_LANGUAGE, language);
+ preferences.put(DefaultCodeFormatterConstants.FORMATTER_LANGUAGE, language);
preferences.put(DefaultCodeFormatterConstants.FORMATTER_CURRENT_FILE, tu.getResource());
boolean formatWholeDocument = false;
if (formattingScopeForEmptySelectionSupported && selectionLength == 0) {
@@ -445,7 +445,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (cProject == null) {
// custom formatter specified?
- String customFormatterId= getPreferenceStore().getString(CCorePreferenceConstants.CODE_FORMATTER);
+ String customFormatterId = getPreferenceStore().getString(CCorePreferenceConstants.CODE_FORMATTER);
if (customFormatterId != null) {
preferences.put(CCorePreferenceConstants.CODE_FORMATTER, customFormatterId);
}
@@ -571,7 +571,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
// position comes
// after change - shift
position.setOffset(offset + deltaLength);
- } else if (end <= eventOffset) {
+ } else if (end <= eventOffset) {
// position comes way before change -
// leave alone
} else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
@@ -598,14 +598,14 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
}
-// /**
-// * Returns the position category.
-// *
-// * @return the position category
-// */
-// public String getCategory() {
-// return fCategory;
-// }
+ // /**
+ // * Returns the position category.
+ // *
+ // * @return the position category
+ // */
+ // public String getCategory() {
+ // return fCategory;
+ // }
}
public static class BracketInserter implements VerifyKeyListener, ILinkedModeListener {
@@ -647,8 +647,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private boolean isAngularIntroducer(String identifier) {
return identifier.length() > 0 && (Character.isUpperCase(identifier.charAt(0))
- || angularIntroducers.contains(identifier)
- || identifier.endsWith("_ptr") //$NON-NLS-1$
+ || angularIntroducers.contains(identifier) || identifier.endsWith("_ptr") //$NON-NLS-1$
|| identifier.endsWith("_cast")); //$NON-NLS-1$
}
@@ -658,21 +657,21 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (!event.doit)
return;
-// Need to check that it is Generic Editor or CEditor before checking "Smart Insert" mode
-// because Generic Editor doesn't have a "Smart Insert" mode.
- if(!isGenericEditor)
+ // Need to check that it is Generic Editor or CEditor before checking "Smart Insert" mode
+ // because Generic Editor doesn't have a "Smart Insert" mode.
+ if (!isGenericEditor)
if (fEditor.getInsertMode() != SMART_INSERT)
- return;
- switch (event.character) {
- case '(':
- case '<':
- case '[':
- case '{':
- case '\'':
- case '\"':
- break;
- default:
return;
+ switch (event.character) {
+ case '(':
+ case '<':
+ case '[':
+ case '{':
+ case '\'':
+ case '\"':
+ break;
+ default:
+ return;
}
IDocument document = sourceViewer.getDocument();
@@ -687,69 +686,64 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
return;
}
- ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
+ ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset,
+ true);
if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
&& !ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
return;
}
- CHeuristicScanner scanner = new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, partition.getType());
+ CHeuristicScanner scanner = new CHeuristicScanner(document, ICPartitions.C_PARTITIONING,
+ partition.getType());
int nextToken = scanner.nextToken(offset + length, endLine.getOffset() + endLine.getLength());
- String next = nextToken == Symbols.TokenEOF ? null : document.get(offset, scanner.getPosition() - offset).trim();
+ String next = nextToken == Symbols.TokenEOF ? null
+ : document.get(offset, scanner.getPosition() - offset).trim();
int prevToken = scanner.previousToken(offset - 1, startLine.getOffset());
int prevTokenOffset = scanner.getPosition() + 1;
- String previous = prevToken == Symbols.TokenEOF ? null : document.get(prevTokenOffset, offset - prevTokenOffset).trim();
+ String previous = prevToken == Symbols.TokenEOF ? null
+ : document.get(prevTokenOffset, offset - prevTokenOffset).trim();
switch (event.character) {
- case '(':
- if (!fCloseBrackets
- || nextToken == Symbols.TokenLPAREN
- || nextToken == Symbols.TokenIDENT
- || next != null && next.length() > 1) {
- return;
- }
- break;
-
- case '<':
- if (!(fCloseAngularBrackets && fCloseBrackets)
- || nextToken == Symbols.TokenLESSTHAN
- || prevToken != Symbols.TokenIDENT
- || !isAngularIntroducer(previous)) {
- return;
- }
- break;
+ case '(':
+ if (!fCloseBrackets || nextToken == Symbols.TokenLPAREN || nextToken == Symbols.TokenIDENT
+ || next != null && next.length() > 1) {
+ return;
+ }
+ break;
- case '[':
- if (!fCloseBrackets
- || nextToken == Symbols.TokenIDENT
- || next != null && next.length() > 1) {
- return;
- }
- break;
+ case '<':
+ if (!(fCloseAngularBrackets && fCloseBrackets) || nextToken == Symbols.TokenLESSTHAN
+ || prevToken != Symbols.TokenIDENT || !isAngularIntroducer(previous)) {
+ return;
+ }
+ break;
- case '{':
- // An opening brace inside parentheses probably starts an initializer list -
- // close it.
- if (!fCloseBraces
- || nextToken == Symbols.TokenIDENT
- || next != null && next.length() > 1
- || !isInsideParentheses(scanner, offset - 1)) {
- return;
- }
- break;
+ case '[':
+ if (!fCloseBrackets || nextToken == Symbols.TokenIDENT || next != null && next.length() > 1) {
+ return;
+ }
+ break;
- case '\'':
- case '"':
- if (!fCloseStrings
- || nextToken == Symbols.TokenIDENT
- || next != null && (next.length() > 1 || next.charAt(0) == event.character)
- || isInsideStringInPreprocessorDirective(partition, document, offset)) {
- return;
- }
- break;
+ case '{':
+ // An opening brace inside parentheses probably starts an initializer list -
+ // close it.
+ if (!fCloseBraces || nextToken == Symbols.TokenIDENT || next != null && next.length() > 1
+ || !isInsideParentheses(scanner, offset - 1)) {
+ return;
+ }
+ break;
- default:
+ case '\'':
+ case '"':
+ if (!fCloseStrings || nextToken == Symbols.TokenIDENT
+ || next != null && (next.length() > 1 || next.charAt(0) == event.character)
+ || isInsideStringInPreprocessorDirective(partition, document, offset)) {
return;
+ }
+ break;
+
+ default:
+ return;
}
if (!fEditor.validateEditorInputState())
@@ -786,7 +780,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
level.fUI = new EditorLinkedModeUI(model, sourceViewer);
level.fUI.setSimpleMode(true);
- level.fUI.setExitPolicy(new ExitPolicy(closingCharacter, getEscapeCharacter(closingCharacter), fBracketLevelStack, sourceViewer));
+ level.fUI.setExitPolicy(new ExitPolicy(closingCharacter, getEscapeCharacter(closingCharacter),
+ fBracketLevelStack, sourceViewer));
level.fUI.setExitPosition(sourceViewer, offset + 2, 0, Integer.MAX_VALUE);
level.fUI.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
level.fUI.enter();
@@ -818,7 +813,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
return false;
}
- private boolean isInsideStringInPreprocessorDirective(ITypedRegion partition, IDocument document, int offset) throws BadLocationException {
+ private boolean isInsideStringInPreprocessorDirective(ITypedRegion partition, IDocument document, int offset)
+ throws BadLocationException {
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType()) && offset < document.getLength()) {
// Use temporary document to test whether offset is inside non-default partition.
String directive = document.get(partition.getOffset(), offset - partition.getOffset() + 1);
@@ -826,7 +822,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (hashIdx >= 0) {
IDocument tmp = new Document(directive.substring(hashIdx + 1));
new CDocumentSetupParticipant().setup(tmp);
- String type = TextUtilities.getContentType(tmp, ICPartitions.C_PARTITIONING, offset - (partition.getOffset() + hashIdx + 1), true);
+ String type = TextUtilities.getContentType(tmp, ICPartitions.C_PARTITIONING,
+ offset - (partition.getOffset() + hashIdx + 1), true);
if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
return true;
}
@@ -853,9 +850,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
&& !level.fSecondPosition.isDeleted
&& level.fSecondPosition.offset == level.fFirstPosition.offset) {
try {
- document.replace(level.fSecondPosition.offset,
- level.fSecondPosition.length,
- null);
+ document.replace(level.fSecondPosition.offset, level.fSecondPosition.length, null);
} catch (BadLocationException e) {
CUIPlugin.log(e);
}
@@ -931,7 +926,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
int next = findNextPosition(position);
try {
- if (isBlockSelectionModeEnabled() && document.getLineOfOffset(next) != document.getLineOfOffset(position)) {
+ if (isBlockSelectionModeEnabled()
+ && document.getLineOfOffset(next) != document.getLineOfOffset(position)) {
super.run(); // may navigate into virtual white space
} else if (next != BreakIterator.DONE) {
setCaretPosition(next);
@@ -1006,11 +1002,11 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
return;
final ISourceViewer viewer = getSourceViewer();
- StyledText text= viewer.getTextWidget();
- Point widgetSelection= text.getSelection();
+ StyledText text = viewer.getTextWidget();
+ Point widgetSelection = text.getSelection();
if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
- final int caret= text.getCaretOffset();
- final int offset= modelOffset2WidgetOffset(viewer, position);
+ final int caret = text.getCaretOffset();
+ final int offset = modelOffset2WidgetOffset(viewer, position);
if (caret == widgetSelection.x)
text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
@@ -1018,14 +1014,14 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
text.invokeAction(ST.DELETE_NEXT);
} else {
- Point selection= viewer.getSelectedRange();
+ Point selection = viewer.getSelectedRange();
final int caret, length;
if (selection.y != 0) {
- caret= selection.x;
- length= selection.y;
+ caret = selection.x;
+ length = selection.y;
} else {
- caret= widgetOffset2ModelOffset(viewer, text.getCaretOffset());
- length= position - caret;
+ caret = widgetOffset2ModelOffset(viewer, text.getCaretOffset());
+ length = position - caret;
}
try {
@@ -1114,7 +1110,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
int previous = findPreviousPosition(position);
try {
- if (isBlockSelectionModeEnabled() && document.getLineOfOffset(previous) != document.getLineOfOffset(position)) {
+ if (isBlockSelectionModeEnabled()
+ && document.getLineOfOffset(previous) != document.getLineOfOffset(position)) {
super.run(); // may navigate into virtual white space
} else if (previous != BreakIterator.DONE) {
setCaretPosition(previous);
@@ -1191,11 +1188,11 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
final int length;
final ISourceViewer viewer = getSourceViewer();
- StyledText text= viewer.getTextWidget();
- Point widgetSelection= text.getSelection();
+ StyledText text = viewer.getTextWidget();
+ Point widgetSelection = text.getSelection();
if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
- final int caret= text.getCaretOffset();
- final int offset= modelOffset2WidgetOffset(viewer, position);
+ final int caret = text.getCaretOffset();
+ final int offset = modelOffset2WidgetOffset(viewer, position);
if (caret == widgetSelection.x)
text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
@@ -1203,12 +1200,12 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
text.invokeAction(ST.DELETE_PREVIOUS);
} else {
- Point selection= viewer.getSelectedRange();
+ Point selection = viewer.getSelectedRange();
if (selection.y != 0) {
- position= selection.x;
- length= selection.y;
+ position = selection.x;
+ length = selection.y;
} else {
- length= widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
+ length = widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
}
try {
@@ -1271,17 +1268,17 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
/**
* Time when last error message got set.
- *
+ *
* @since 5.3
*/
private long fErrorMessageTime;
/**
* Timeout for the error message.
- *
+ *
* @since 5.3
*/
- private static final long ERROR_MESSAGE_TIMEOUT= 1000;
+ private static final long ERROR_MESSAGE_TIMEOUT = 1000;
/** The outline page */
protected CContentOutlinePage fOutlinePage;
@@ -1294,15 +1291,15 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
/** Generate action group filling the "Source" submenu */
private GenerateActionGroup fGenerateActionGroup;
-
+
/** Generate action group filling the "Surround with" submenu */
private SurroundWithActionGroup fSurroundWithActionGroup;
/** Pairs of brackets, used to match. */
- protected static final char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
+ protected static final char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
/** Matches the brackets. */
- protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
+ protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
/** The bracket inserter. */
private final BracketInserter fBracketInserter = new BracketInserter(this, false);
@@ -1329,8 +1326,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
/** Preference key for automatically closing curly braces */
private static final String CLOSE_BRACES = PreferenceConstants.EDITOR_CLOSE_BRACES;
- /** Preference key for compiler task tags */
- private static final String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS;
+ /** Preference key for compiler task tags */
+ private static final String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS;
/**
* This editor's projection support
@@ -1350,8 +1347,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* AST reconciling listeners.
* @since 4.0
*/
- private final ListenerList<ICReconcilingListener> fReconcilingListeners=
- new ListenerList<ICReconcilingListener>(ListenerList.IDENTITY);
+ private final ListenerList<ICReconcilingListener> fReconcilingListeners = new ListenerList<ICReconcilingListener>(
+ ListenerList.IDENTITY);
/**
* Semantic highlighting manager
@@ -1420,7 +1417,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
- ISourceViewer sourceViewer= getSourceViewer();
+ ISourceViewer sourceViewer = getSourceViewer();
if (!(sourceViewer instanceof ISourceViewerExtension2)) {
setPreferenceStore(createCombinedPreferenceStore(input));
internalDoSetInput(input);
@@ -1448,14 +1445,15 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
private void internalDoSetInput(IEditorInput input) throws CoreException {
- ISourceViewer sourceViewer= getSourceViewer();
- CSourceViewer cSourceViewer= null;
+ ISourceViewer sourceViewer = getSourceViewer();
+ CSourceViewer cSourceViewer = null;
if (sourceViewer instanceof CSourceViewer) {
- cSourceViewer= (CSourceViewer) sourceViewer;
+ cSourceViewer = (CSourceViewer) sourceViewer;
}
- IPreferenceStore store= getPreferenceStore();
- if (cSourceViewer != null && isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
+ IPreferenceStore store = getPreferenceStore();
+ if (cSourceViewer != null && isFoldingEnabled()
+ && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
cSourceViewer.prepareDelayedProjection();
super.doSetInput(input);
@@ -1468,7 +1466,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (fCEditorErrorTickUpdater != null) {
fCEditorErrorTickUpdater.updateEditorImage(getInputCElement());
}
- ICElement element= getInputCElement();
+ ICElement element = getInputCElement();
if (element instanceof ITranslationUnit) {
ITranslationUnit tu = (ITranslationUnit) element;
fIndexUpdateRequestor.updateIndexInclusion(tu);
@@ -1486,21 +1484,19 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (fEnableScalablilityMode && !wasEnabled) {
// Alert users that scalability mode should be turned on
if (getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_ALERT)) {
- MessageDialogWithToggle dialog = new MessageDialogWithToggle(
- getSite().getShell(),
- CEditorMessages.Scalability_info,
- null,
- CEditorMessages.Scalability_message,
+ MessageDialogWithToggle dialog = new MessageDialogWithToggle(getSite().getShell(),
+ CEditorMessages.Scalability_info, null, CEditorMessages.Scalability_message,
MessageDialog.INFORMATION,
- new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0,
- CEditorMessages.Scalability_reappear,
- false) {
+ new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0,
+ CEditorMessages.Scalability_reappear, false) {
{
setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS | SWT.ON_TOP | getDefaultOrientation());
}
+
@Override
protected void buttonPressed(int buttonId) {
- PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT, !getToggleState());
+ PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT,
+ !getToggleState());
super.buttonPressed(buttonId);
if (buttonId == IDialogConstants.YES_ID) {
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getSite().getShell(),
@@ -1518,23 +1514,25 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
protected void setPreferenceStore(IPreferenceStore store) {
super.setPreferenceStore(store);
- SourceViewerConfiguration sourceViewerConfiguration= getSourceViewerConfiguration();
+ SourceViewerConfiguration sourceViewerConfiguration = getSourceViewerConfiguration();
if (!(sourceViewerConfiguration instanceof CSourceViewerConfiguration)) {
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
- setSourceViewerConfiguration(new CSourceViewerScalableConfiguration(textTools.getColorManager(), store, this, ICPartitions.C_PARTITIONING));
+ CTextTools textTools = CUIPlugin.getDefault().getTextTools();
+ setSourceViewerConfiguration(new CSourceViewerScalableConfiguration(textTools.getColorManager(), store,
+ this, ICPartitions.C_PARTITIONING));
}
if (getSourceViewer() instanceof CSourceViewer)
((CSourceViewer) getSourceViewer()).setPreferenceStore(store);
- fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
- fMarkOverloadedOperatorOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES);
- fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
+ fMarkOccurrenceAnnotations = store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
+ fMarkOverloadedOperatorOccurrences = store
+ .getBoolean(PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES);
+ fStickyOccurrenceAnnotations = store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
}
/**
* Update the title image.
- * @param image Title image.
+ * @param image Title image.
*/
public void updatedTitleImage(Image image) {
setTitleImage(image);
@@ -1546,7 +1544,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @return the working copy wrapped by this editors input.
* @since 3.0
*/
- public IWorkingCopy getInputCElement () {
+ public IWorkingCopy getInputCElement() {
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
}
@@ -1556,16 +1554,16 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
/**
- * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
+ * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
*/
- @Override
+ @Override
public boolean isSaveAsAllowed() {
return true;
}
/**
* Returns the outline page of the C/C++ editor.
- * @return Outline page.
+ * @return Outline page.
*/
public CContentOutlinePage getOutlinePage() {
if (fOutlinePage == null) {
@@ -1586,15 +1584,16 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
@SuppressWarnings("deprecation")
public String[] getShowInTargetIds() {
- return new String[] { IPageLayout.ID_PROJECT_EXPLORER, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV };
+ return new String[] { IPageLayout.ID_PROJECT_EXPLORER, IPageLayout.ID_OUTLINE,
+ IPageLayout.ID_RES_NAV };
}
};
} else if (adapterClass.isAssignableFrom(IShowInSource.class)) {
- ICElement ce= getElementAt(getSourceViewer().getSelectedRange().x, false);
+ ICElement ce = getElementAt(getSourceViewer().getSelectedRange().x, false);
if (ce instanceof ITranslationUnit) {
ce = null;
}
- final ISelection selection= ce != null ? new StructuredSelection(ce) : null;
+ final ISelection selection = ce != null ? new StructuredSelection(ce) : null;
return (T) new IShowInSource() {
@Override
public ShowInContext getShowInContext() {
@@ -1620,7 +1619,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
return (T) this;
return super.getAdapter(adapterClass);
}
-
+
/**
* Handles a property change event describing a change
* of the editor's preference store and updates the preference
@@ -1649,10 +1648,10 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
final AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
if (asv != null) {
- boolean newBooleanValue= false;
- Object newValue= event.getNewValue();
+ boolean newBooleanValue = false;
+ Object newValue = event.getNewValue();
if (newValue != null)
- newBooleanValue= Boolean.valueOf(newValue.toString()).booleanValue();
+ newBooleanValue = Boolean.valueOf(newValue.toString()).booleanValue();
if (CLOSE_BRACKETS.equals(property)) {
fBracketInserter.setCloseBracketsEnabled(newBooleanValue);
@@ -1694,7 +1693,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
sourceViewer.invalidateTextPresentation();
return;
}
-
+
if (affectsOverrideIndicatorAnnotations(event)) {
if (isShowingOverrideIndicators()) {
if (fOverrideIndicatorManager == null)
@@ -1711,7 +1710,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
fProjectionModelUpdater.uninstall();
}
// either freshly enabled or provider changed
- fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+ fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry()
+ .getCurrentFoldingProvider();
if (fProjectionModelUpdater != null) {
fProjectionModelUpdater.install(this, asv);
}
@@ -1721,8 +1721,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)
|| DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE.equals(property)
|| DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR.equals(property)) {
- StyledText textWidget= asv.getTextWidget();
- int tabWidth= getSourceViewerConfiguration().getTabWidth(asv);
+ StyledText textWidget = asv.getTextWidget();
+ int tabWidth = getSourceViewerConfiguration().getTabWidth(asv);
if (textWidget.getTabs() != tabWidth)
textWidget.setTabs(tabWidth);
uninstallTabsToSpacesConverter();
@@ -1736,7 +1736,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (PreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
if (newBooleanValue != fMarkOccurrenceAnnotations) {
- fMarkOccurrenceAnnotations= newBooleanValue;
+ fMarkOccurrenceAnnotations = newBooleanValue;
if (!fMarkOccurrenceAnnotations)
uninstallOccurrencesFinder();
else
@@ -1745,16 +1745,16 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
return;
}
if (PreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) {
- fStickyOccurrenceAnnotations= newBooleanValue;
+ fStickyOccurrenceAnnotations = newBooleanValue;
return;
}
if (PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES.equals(property)) {
- fMarkOverloadedOperatorOccurrences= newBooleanValue;
+ fMarkOverloadedOperatorOccurrences = newBooleanValue;
return;
}
- if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)
- || (isEnableScalablilityMode() && PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT.equals(property))) {
+ if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event) || (isEnableScalablilityMode()
+ && PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT.equals(property))) {
if (isSemanticHighlightingEnabled()) {
installSemanticHighlighting();
fSemanticManager.refresh();
@@ -1763,22 +1763,23 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
return;
}
-
+
// For Scalability
if (isEnableScalablilityMode()) {
- if (PreferenceConstants.SCALABILITY_RECONCILER.equals(property) ||
- PreferenceConstants.SCALABILITY_SYNTAX_COLOR.equals(property)) {
+ if (PreferenceConstants.SCALABILITY_RECONCILER.equals(property)
+ || PreferenceConstants.SCALABILITY_SYNTAX_COLOR.equals(property)) {
BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
@Override
public void run() {
setOutlinePageInput(fOutlinePage, getEditorInput());
asv.unconfigure();
asv.configure(getSourceViewerConfiguration());
- }});
+ }
+ });
return;
}
}
-
+
IContentAssistant c = asv.getContentAssistant();
if (c instanceof ContentAssistant) {
ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
@@ -1798,26 +1799,27 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* Updates the hovering behavior depending on the preferences.
*/
private void updateHoverBehavior() {
- SourceViewerConfiguration configuration= getSourceViewerConfiguration();
- String[] types= configuration.getConfiguredContentTypes(getSourceViewer());
+ SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+ String[] types = configuration.getConfiguredContentTypes(getSourceViewer());
for (String t : types) {
- ISourceViewer sourceViewer= getSourceViewer();
+ ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension2) {
// Remove existing hovers
((ITextViewerExtension2) sourceViewer).removeTextHovers(t);
- int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
+ int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
if (stateMasks != null) {
for (int stateMask : stateMasks) {
- ITextHover textHover= configuration.getTextHover(sourceViewer, t, stateMask);
+ ITextHover textHover = configuration.getTextHover(sourceViewer, t, stateMask);
((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask);
}
} else {
- ITextHover textHover= configuration.getTextHover(sourceViewer, t);
- ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
+ ITextHover textHover = configuration.getTextHover(sourceViewer, t);
+ ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t,
+ ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
}
} else {
sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t);
@@ -1833,7 +1835,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
protected void selectionChanged() {
if (getSelectionProvider() == null)
return;
- ISourceReference element= computeHighlightRangeSourceReference();
+ ISourceReference element = computeHighlightRangeSourceReference();
updateStatusLine();
synchronizeOutlinePage();
setSelection(element, false);
@@ -1848,24 +1850,24 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @since 4.0
*/
protected ISourceReference computeHighlightRangeSourceReference() {
- ISourceViewer sourceViewer= getSourceViewer();
+ ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null)
return null;
- StyledText styledText= sourceViewer.getTextWidget();
+ StyledText styledText = sourceViewer.getTextWidget();
if (styledText == null)
return null;
- int caret= 0;
+ int caret = 0;
if (sourceViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) sourceViewer;
- caret= extension.widgetOffset2ModelOffset(styledText.getSelection().x);
+ ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
+ caret = extension.widgetOffset2ModelOffset(styledText.getSelection().x);
} else {
- int offset= sourceViewer.getVisibleRegion().getOffset();
- caret= offset + styledText.getSelection().x;
+ int offset = sourceViewer.getVisibleRegion().getOffset();
+ caret = offset + styledText.getSelection().x;
}
- ICElement element= getElementAt(caret, false);
+ ICElement element = getElementAt(caret, false);
if (!(element instanceof ISourceReference))
return null;
@@ -1884,7 +1886,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @return the most narrow element which includes the given offset
*/
protected ICElement getElementAt(int offset, boolean reconcile) {
- IWorkingCopy unit= getInputCElement();
+ IWorkingCopy unit = getInputCElement();
if (unit != null) {
try {
@@ -1934,18 +1936,18 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
setSelection(range, !isActivePart());
}
} catch (CModelException e) {
- // Selection change not applied.
+ // Selection change not applied.
}
}
}
}
/**
- * Sets selection for C element.
- *
- * @param element Element to select.
+ * Sets selection for C element.
+ *
+ * @param element Element to select.
*/
- public void setSelection(ICElement element) {
+ public void setSelection(ICElement element) {
if (element instanceof ISourceReference && !(element instanceof ITranslationUnit)) {
ISourceReference reference = (ISourceReference) element;
// set hightlight range
@@ -1953,15 +1955,15 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
}
- /**
- * Sets selection for source reference.
- *
- * @param element Source reference to set.
- * @param moveCursor Should cursor be moved.
- */
- public void setSelection(ISourceReference element, boolean moveCursor) {
+ /**
+ * Sets selection for source reference.
+ *
+ * @param element Source reference to set.
+ * @param moveCursor Should cursor be moved.
+ */
+ public void setSelection(ISourceReference element, boolean moveCursor) {
if (element != null) {
- StyledText textWidget = null;
+ StyledText textWidget = null;
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer != null)
@@ -1973,7 +1975,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
try {
setSelection(element.getSourceRange(), moveCursor);
} catch (CModelException e) {
- // Selection not applied.
+ // Selection not applied.
}
}
}
@@ -1989,9 +1991,9 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (getSelectionProvider() == null)
return;
- ISelection selection= getSelectionProvider().getSelection();
+ ISelection selection = getSelectionProvider().getSelection();
if (selection instanceof ITextSelection) {
- ITextSelection textSelection= (ITextSelection) selection;
+ ITextSelection textSelection = (ITextSelection) selection;
// PR 39995: [navigation] Forward history cleared after going back in navigation history:
// mark only in navigation history if the cursor is being moved (which it isn't if
// this is called from a PostSelectionEvent that should only update the magnet)
@@ -2000,13 +2002,13 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
if (element != null) {
- StyledText textWidget= null;
-
- ISourceViewer sourceViewer= getSourceViewer();
+ StyledText textWidget = null;
+
+ ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null)
return;
-
- textWidget= sourceViewer.getTextWidget();
+
+ textWidget = sourceViewer.getTextWidget();
if (textWidget == null)
return;
@@ -2014,26 +2016,29 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
IRegion alternateRegion = null;
int start = element.getStartPos();
int length = element.getLength();
-
+
// Sanity check sometimes the parser may throw wrong numbers.
if (start < 0 || length < 0) {
start = 0;
length = 0;
}
-
+
// 0 length and start and non-zero start line says we know
// the line for some reason, but not the offset.
if (length == 0 && start == 0 && element.getStartLine() > 0) {
// We have the information in term of lines, we can work it out.
// Binary elements return the first executable statement so we have to subtract -1
- start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
+ start = getDocumentProvider().getDocument(getEditorInput())
+ .getLineOffset(element.getStartLine() - 1);
if (element.getEndLine() > 0) {
- length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
+ length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine())
+ - start;
} else {
length = start;
}
// create an alternate region for the keyword highlight.
- alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
+ alternateRegion = getDocumentProvider().getDocument(getEditorInput())
+ .getLineInformation(element.getStartLine() - 1);
if (start == length || length < 0) {
if (alternateRegion != null) {
start = alternateRegion.getOffset();
@@ -2042,7 +2047,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
}
setHighlightRange(start, length, moveCursor);
-
+
if (moveCursor) {
start = element.getIdStartPos();
length = element.getIdLength();
@@ -2051,7 +2056,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
length = alternateRegion.getLength();
}
if (start > -1 && length > 0) {
- try {
+ try {
textWidget.setRedraw(false);
sourceViewer.revealRange(start, length);
sourceViewer.setSelectedRange(start, length);
@@ -2063,7 +2068,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
}
} catch (IllegalArgumentException | BadLocationException e) {
- // No information to the user
+ // No information to the user
}
} else if (moveCursor) {
resetHighlightRange();
@@ -2072,10 +2077,10 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
/**
- * Checks is the editor active part.
- * @return {@code true} if editor is the active part of the workbench.
+ * Checks is the editor active part.
+ * @return {@code true} if editor is the active part of the workbench.
*/
- private boolean isActivePart() {
+ private boolean isActivePart() {
IWorkbenchWindow window = getSite().getWorkbenchWindow();
IPartService service = window.getPartService();
return (this == service.getActivePart());
@@ -2083,15 +2088,15 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
protected void installTabsToSpacesConverter() {
- ISourceViewer sourceViewer= getSourceViewer();
- SourceViewerConfiguration config= getSourceViewerConfiguration();
+ ISourceViewer sourceViewer = getSourceViewer();
+ SourceViewerConfiguration config = getSourceViewerConfiguration();
if (config != null && sourceViewer instanceof ITextViewerExtension7) {
- int tabWidth= config.getTabWidth(sourceViewer);
- TabsToSpacesConverter tabToSpacesConverter= new TabsToSpacesConverter();
+ int tabWidth = config.getTabWidth(sourceViewer);
+ TabsToSpacesConverter tabToSpacesConverter = new TabsToSpacesConverter();
tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
- IDocumentProvider provider= getDocumentProvider();
+ IDocumentProvider provider = getDocumentProvider();
if (provider instanceof CDocumentProvider) {
- CDocumentProvider cProvider= (CDocumentProvider) provider;
+ CDocumentProvider cProvider = (CDocumentProvider) provider;
tabToSpacesConverter.setLineTracker(cProvider.createLineTracker(getEditorInput()));
} else {
tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
@@ -2102,13 +2107,13 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
private void updateIndentationMode() {
- ISourceViewer sourceViewer= getSourceViewer();
+ ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer instanceof CSourceViewer) {
- CSourceViewer cSourceVieer= (CSourceViewer) sourceViewer;
- ICElement element= getInputCElement();
- ICProject project= element == null ? null : element.getCProject();
- final int indentWidth= CodeFormatterUtil.getIndentWidth(project);
- final boolean useSpaces= isTabsToSpacesConversionEnabled();
+ CSourceViewer cSourceVieer = (CSourceViewer) sourceViewer;
+ ICElement element = getInputCElement();
+ ICProject project = element == null ? null : element.getCProject();
+ final int indentWidth = CodeFormatterUtil.getIndentWidth(project);
+ final boolean useSpaces = isTabsToSpacesConversionEnabled();
cSourceVieer.configureIndentation(indentWidth, useSpaces);
}
super.updateIndentPrefixes();
@@ -2116,13 +2121,13 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
protected boolean isTabsToSpacesConversionEnabled() {
- ICElement element= getInputCElement();
- ICProject project= element == null ? null : element.getCProject();
+ ICElement element = getInputCElement();
+ ICProject project = element == null ? null : element.getCProject();
String option;
if (project == null)
- option= CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+ option = CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
else
- option= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
+ option = project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
return CCorePlugin.SPACE.equals(option);
}
@@ -2132,13 +2137,13 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
fProjectionModelUpdater = null;
}
}
-
- /**
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
- @Override
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPart#dispose()
+ */
+ @Override
public void dispose() {
- fIndexUpdateRequestor.updateIndexInclusion(null);
+ fIndexUpdateRequestor.updateIndexInclusion(null);
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension)
@@ -2152,18 +2157,18 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
// Cancel possible running computation
- fMarkOccurrenceAnnotations= false;
+ fMarkOccurrenceAnnotations = false;
uninstallOccurrencesFinder();
uninstallOverrideIndicator();
- uninstallSemanticHighlighting();
+ uninstallSemanticHighlighting();
if (fCEditorErrorTickUpdater != null) {
fCEditorErrorTickUpdater.dispose();
fCEditorErrorTickUpdater = null;
}
- if (fBracketMatcher != null) {
+ if (fBracketMatcher != null) {
fBracketMatcher.dispose();
fBracketMatcher = null;
}
@@ -2195,19 +2200,19 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (fGenerateActionGroup != null) {
fGenerateActionGroup.dispose();
- fGenerateActionGroup= null;
+ fGenerateActionGroup = null;
}
-
+
if (fSurroundWithActionGroup != null) {
fSurroundWithActionGroup.dispose();
- fSurroundWithActionGroup= null;
+ fSurroundWithActionGroup = null;
}
-
- if (fEditorSelectionChangedListener != null) {
+
+ if (fEditorSelectionChangedListener != null) {
fEditorSelectionChangedListener.uninstall(getSelectionProvider());
fEditorSelectionChangedListener = null;
}
-
+
if (fSelectionHistory != null) {
fSelectionHistory.dispose();
fSelectionHistory = null;
@@ -2220,7 +2225,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
String oldLanguage = ""; //$NON-NLS-1$
IFile originalFile = getEditorInputFile(originalElement);
-
+
if (originalFile != null) {
// If the project of the original input cannot be accessed, the project is being
// renamed - accept the move. See http://bugs.eclipse.org/434852
@@ -2256,7 +2261,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
return null;
}
-
+
@Override
protected void createActions() {
super.createActions();
@@ -2264,10 +2269,10 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
fFoldingGroup = new FoldingActionGroup(this, getSourceViewer());
// Default text editing menu items
- IAction action= new GotoMatchingBracketAction(this);
+ IAction action = new GotoMatchingBracketAction(this);
action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
-
+
final ResourceBundle bundle = ConstructedCEditorMessages.getResourceBundle();
action = new GotoNextBookmarkAction(bundle, "GotoNextBookmark.", this); //$NON-NLS-1$
action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_BOOKMARK);
@@ -2285,14 +2290,14 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
configureToggleCommentAction();
- action = new AddBlockCommentAction(bundle, "AddBlockComment.", this); //$NON-NLS-1$
+ action = new AddBlockCommentAction(bundle, "AddBlockComment.", this); //$NON-NLS-1$
action.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
setAction("AddBlockComment", action); //$NON-NLS-1$
markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$
//WorkbenchHelp.setHelp(action, ICHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
- action = new RemoveBlockCommentAction(bundle, "RemoveBlockComment.", this); //$NON-NLS-1$
+ action = new RemoveBlockCommentAction(bundle, "RemoveBlockComment.", this); //$NON-NLS-1$
action.setActionDefinitionId(ICEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
setAction("RemoveBlockComment", action); //$NON-NLS-1$
markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
@@ -2304,7 +2309,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
setAction("Indent", action); //$NON-NLS-1$
markAsStateDependentAction("Indent", true); //$NON-NLS-1$
markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(action, ICHelpContextIds.INDENT_ACTION);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(action, ICHelpContextIds.INDENT_ACTION);
action = new AlignConstAction(bundle, "AlignConst.", this); //$NON-NLS-1$
action.setActionDefinitionId(ICEditorActionDefinitionIds.ALIGN_CONST);
@@ -2337,66 +2342,66 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
setAction("ContentAssistProposal", action); //$NON-NLS-1$
markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
- action= new TextOperationAction(bundle, "ContentAssistContextInformation.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
+ action = new TextOperationAction(bundle, "ContentAssistContextInformation.", this, //$NON-NLS-1$
+ ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
setAction("ContentAssistContextInformation", action); //$NON-NLS-1$
markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$
- action = new TextOperationAction(bundle, "OpenOutline.", this, CSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_OUTLINE);
- setAction("OpenOutline", action); //$NON-NLS-1$*/
-
- action = new TextOperationAction(bundle, "OpenHierarchy.", this, CSourceViewer.SHOW_HIERARCHY, true); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_QUICK_TYPE_HIERARCHY);
- setAction("OpenHierarchy", action); //$NON-NLS-1$*/
-
- action = new GoToNextPreviousMemberAction(bundle, "GotoNextMember.", this, true); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
- setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action);
-
- action = new GoToNextPreviousMemberAction(bundle, "GotoPreviousMember.", this, false); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
- setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action);
-
- action= new ToggleSourceAndHeaderAction(bundle, "ToggleSourceHeader.", this); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_SOURCE_HEADER);
- setAction("ToggleSourceHeader", action); //$NON-NLS-1$
-
- action = new TextOperationAction(bundle, "OpenMacroExplorer.", this, CSourceViewer.SHOW_MACRO_EXPLORER, true); //$NON-NLS-1$
- action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_QUICK_MACRO_EXPLORER);
- setAction("OpenMacroExplorer", action); //$NON-NLS-1$*/
-
- fSelectionHistory = new SelectionHistory(this);
-
- action = new StructureSelectEnclosingAction(bundle, this, fSelectionHistory);
- action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_ENCLOSING);
- setAction(StructureSelectionAction.ENCLOSING, action);
-
- action = new StructureSelectNextAction(bundle, this, fSelectionHistory);
- action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_NEXT);
- setAction(StructureSelectionAction.NEXT, action);
-
- action = new StructureSelectPreviousAction(bundle, this, fSelectionHistory);
- action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_PREVIOUS);
- setAction(StructureSelectionAction.PREVIOUS, action);
-
- action = new StructureSelectHistoryAction(bundle, this, fSelectionHistory);
- action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_LAST);
- setAction(StructureSelectionAction.HISTORY, action);
-
+ action = new TextOperationAction(bundle, "OpenOutline.", this, CSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_OUTLINE);
+ setAction("OpenOutline", action); //$NON-NLS-1$*/
+
+ action = new TextOperationAction(bundle, "OpenHierarchy.", this, CSourceViewer.SHOW_HIERARCHY, true); //$NON-NLS-1$
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_QUICK_TYPE_HIERARCHY);
+ setAction("OpenHierarchy", action); //$NON-NLS-1$*/
+
+ action = new GoToNextPreviousMemberAction(bundle, "GotoNextMember.", this, true); //$NON-NLS-1$
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
+ setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action);
+
+ action = new GoToNextPreviousMemberAction(bundle, "GotoPreviousMember.", this, false); //$NON-NLS-1$
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
+ setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action);
+
+ action = new ToggleSourceAndHeaderAction(bundle, "ToggleSourceHeader.", this); //$NON-NLS-1$
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_SOURCE_HEADER);
+ setAction("ToggleSourceHeader", action); //$NON-NLS-1$
+
+ action = new TextOperationAction(bundle, "OpenMacroExplorer.", this, CSourceViewer.SHOW_MACRO_EXPLORER, true); //$NON-NLS-1$
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_QUICK_MACRO_EXPLORER);
+ setAction("OpenMacroExplorer", action); //$NON-NLS-1$*/
+
+ fSelectionHistory = new SelectionHistory(this);
+
+ action = new StructureSelectEnclosingAction(bundle, this, fSelectionHistory);
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_ENCLOSING);
+ setAction(StructureSelectionAction.ENCLOSING, action);
+
+ action = new StructureSelectNextAction(bundle, this, fSelectionHistory);
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_NEXT);
+ setAction(StructureSelectionAction.NEXT, action);
+
+ action = new StructureSelectPreviousAction(bundle, this, fSelectionHistory);
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_PREVIOUS);
+ setAction(StructureSelectionAction.PREVIOUS, action);
+
+ action = new StructureSelectHistoryAction(bundle, this, fSelectionHistory);
+ action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_LAST);
+ setAction(StructureSelectionAction.HISTORY, action);
+
// add annotation actions for roll-over expand hover
- action= new CSelectMarkerRulerAction(bundle, "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
+ action = new CSelectMarkerRulerAction(bundle, "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
setAction("AnnotationAction", action); //$NON-NLS-1$
-
-
- // Assorted action groupings
+
+ // Assorted action groupings
fSelectionSearchGroup = createSelectionSearchGroup();
- fTextSearchGroup= new TextSearchGroup(this);
- fRefactoringActionGroup= new CRefactoringActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
- fOpenInViewGroup= createOpenViewActionGroup();
- fGenerateActionGroup= new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+ fTextSearchGroup = new TextSearchGroup(this);
+ fRefactoringActionGroup = new CRefactoringActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+ fOpenInViewGroup = createOpenViewActionGroup();
+ fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
fSurroundWithActionGroup = new SurroundWithActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
-
+
action = getAction(ITextEditorActionConstants.SHIFT_RIGHT);
if (action != null) {
action.setId(ITextEditorActionConstants.SHIFT_RIGHT);
@@ -2412,7 +2417,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
protected ActionGroup createSelectionSearchGroup() {
return new SelectionSearchGroup(this);
}
-
+
protected ActionGroup createOpenViewActionGroup() {
return new OpenViewActionGroup(this);
}
@@ -2423,7 +2428,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
menu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
// separator for debug related actions (similar to ruler context menu)
menu.add(new Separator(IContextMenuConstants.GROUP_DEBUG));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_DEBUG+".end")); //$NON-NLS-1$
+ menu.add(new GroupMarker(IContextMenuConstants.GROUP_DEBUG + ".end")); //$NON-NLS-1$
super.editorContextMenuAboutToShow(menu);
@@ -2433,10 +2438,10 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW));
- final boolean hasCElement= getInputCElement() != null;
+ final boolean hasCElement = getInputCElement() != null;
if (hasCElement) {
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDeclarations"); //$NON-NLS-1$
- addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDefinition"); //$NON-NLS-1$
+ addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDefinition"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenTypeHierarchy"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenCallHierarchy"); //$NON-NLS-1$
@@ -2446,7 +2451,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
addAction(menu, IContextMenuConstants.GROUP_OPEN, "ToggleSourceHeader"); //$NON-NLS-1$
}
- ActionContext context= new ActionContext(getSelectionProvider().getSelection());
+ ActionContext context = new ActionContext(getSelectionProvider().getSelection());
fGenerateActionGroup.setContext(context);
fGenerateActionGroup.fillContextMenu(menu);
fGenerateActionGroup.setContext(null);
@@ -2454,7 +2459,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
fSurroundWithActionGroup.setContext(context);
fSurroundWithActionGroup.fillContextMenu(menu);
fSurroundWithActionGroup.setContext(null);
-
+
if (hasCElement) {
fSelectionSearchGroup.fillContextMenu(menu);
}
@@ -2469,21 +2474,21 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
protected void rulerContextMenuAboutToShow(IMenuManager menu) {
super.rulerContextMenuAboutToShow(menu);
- IMenuManager foldingMenu= new MenuManager(CEditorMessages.CEditor_menu_folding, "projection"); //$NON-NLS-1$
+ IMenuManager foldingMenu = new MenuManager(CEditorMessages.CEditor_menu_folding, "projection"); //$NON-NLS-1$
menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, foldingMenu);
- IAction action= getAction("FoldingToggle"); //$NON-NLS-1$
+ IAction action = getAction("FoldingToggle"); //$NON-NLS-1$
foldingMenu.add(action);
- action= getAction("FoldingExpandAll"); //$NON-NLS-1$
+ action = getAction("FoldingExpandAll"); //$NON-NLS-1$
foldingMenu.add(action);
- action= getAction("FoldingCollapseAll"); //$NON-NLS-1$
+ action = getAction("FoldingCollapseAll"); //$NON-NLS-1$
foldingMenu.add(action);
- action= getAction("FoldingRestore"); //$NON-NLS-1$
+ action = getAction("FoldingRestore"); //$NON-NLS-1$
foldingMenu.add(action);
}
/**
- * Sets an input for the outline page.
+ * Sets an input for the outline page.
* @param page Page to set the input.
* @param input Input to set.
*/
@@ -2505,7 +2510,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
/**
- * Determines if folding is enabled.
+ * Determines if folding is enabled.
* @return {@code true} if folding is enabled, {@code false} otherwise.
*/
protected boolean isFoldingEnabled() {
@@ -2536,8 +2541,9 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
}
helpSystem.displayHelp(ICHelpContextIds.CEDITOR_VIEW);
- }});
-
+ }
+ });
+
fEditorSelectionChangedListener = new EditorSelectionChangedListener();
fEditorSelectionChangedListener.install(getSelectionProvider());
@@ -2564,14 +2570,15 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (isMarkingOccurrences())
installOccurrencesFinder(false);
- if(isShowingOverrideIndicators())
+ if (isShowingOverrideIndicators())
installOverrideIndicator(false);
}
@Override
protected SourceViewerDecorationSupport getSourceViewerDecorationSupport(ISourceViewer viewer) {
if (fSourceViewerDecorationSupport == null) {
- fSourceViewerDecorationSupport= new CSourceViewerDecorationSupport(this, viewer, getOverviewRuler(), getAnnotationAccess(), getSharedColors());
+ fSourceViewerDecorationSupport = new CSourceViewerDecorationSupport(this, viewer, getOverviewRuler(),
+ getAnnotationAccess(), getSharedColors());
configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
}
return fSourceViewerDecorationSupport;
@@ -2583,13 +2590,13 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
// Enhance the stock source viewer decorator with a bracket matcher
support.setCharacterPairMatcher(fBracketMatcher);
support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
- ((CSourceViewerDecorationSupport) support).setInactiveCodePainterPreferenceKeys(INACTIVE_CODE_ENABLE, INACTIVE_CODE_COLOR);
+ ((CSourceViewerDecorationSupport) support).setInactiveCodePainterPreferenceKeys(INACTIVE_CODE_ENABLE,
+ INACTIVE_CODE_COLOR);
// The base class will have already called setMarginPainterPreferenceKeys. We override it
// here with more specific values for the C/C++ editor. Note that this needs to go after
// the call to super since the last invocation wins.
- support.setMarginPainterPreferenceKeys(
- AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
+ support.setMarginPainterPreferenceKeys(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR,
DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
}
@@ -2603,7 +2610,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
*/
private Object getLockObject(IAnnotationModel annotationModel) {
if (annotationModel instanceof ISynchronizable) {
- Object lock= ((ISynchronizable) annotationModel).getLockObject();
+ Object lock = ((ISynchronizable) annotationModel).getLockObject();
if (lock != null)
return lock;
}
@@ -2623,7 +2630,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
int selectionLength = Math.abs(selection.getLength());
if (selectionLength > 1) {
- setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_invalidSelection);
+ setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_invalidSelection);
sourceViewer.getTextWidget().getDisplay().beep();
return;
}
@@ -2635,7 +2642,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
IRegion region = fBracketMatcher.match(document, sourceCaretOffset);
if (region == null) {
- setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_noMatchingBracket);
+ setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_noMatchingBracket);
sourceViewer.getTextWidget().getDisplay().beep();
return;
}
@@ -2648,7 +2655,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
int anchor = fBracketMatcher.getAnchor();
// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
- int targetOffset = (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length;
+ int targetOffset = (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1 : offset + length;
boolean visible = false;
if (sourceViewer instanceof ITextViewerExtension5) {
@@ -2657,11 +2664,12 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
} else {
IRegion visibleRegion = sourceViewer.getVisibleRegion();
// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
- visible = (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
+ visible = (targetOffset >= visibleRegion.getOffset()
+ && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
}
if (!visible) {
- setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);
+ setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);
sourceViewer.getTextWidget().getDisplay().beep();
return;
}
@@ -2697,24 +2705,24 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @return the found annotation or {@code null}
*/
private Annotation getAnnotation(int offset, int length, IMarker marker) {
- IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+ IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
if (model == null)
return null;
-
+
Iterator<Annotation> parent;
if (model instanceof IAnnotationModelExtension2) {
- parent= ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true);
+ parent = ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true);
} else {
- parent= model.getAnnotationIterator();
+ parent = model.getAnnotationIterator();
}
- Iterator<Annotation> e= new CAnnotationIterator(parent, false);
+ Iterator<Annotation> e = new CAnnotationIterator(parent, false);
Annotation annotation = null;
while (e.hasNext()) {
Annotation a = e.next();
if (!isNavigationTarget(a))
continue;
-
+
Position p = model.getPosition(a);
if (p != null && p.overlapsWith(offset, length)) {
if (annotation == null) {
@@ -2730,7 +2738,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
}
}
-
+
return annotation;
}
@@ -2805,20 +2813,21 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- IPreferenceStore store= getPreferenceStore();
- ISourceViewer sourceViewer =
- new AdaptedSourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles, store);
+ IPreferenceStore store = getPreferenceStore();
+ ISourceViewer sourceViewer = new AdaptedSourceViewer(parent, ruler, getOverviewRuler(),
+ isOverviewRulerVisible(), styles, store);
- CSourceViewer cSourceViewer= null;
+ CSourceViewer cSourceViewer = null;
if (sourceViewer instanceof CSourceViewer) {
- cSourceViewer= (CSourceViewer) sourceViewer;
+ cSourceViewer = (CSourceViewer) sourceViewer;
}
/*
* This is a performance optimization to reduce the computation of
* the text presentation triggered by {@link #setVisibleDocument(IDocument)}
*/
- if (cSourceViewer != null && isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
+ if (cSourceViewer != null && isFoldingEnabled()
+ && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
cSourceViewer.prepareDelayedProjection();
ProjectionViewer projectionViewer = (ProjectionViewer) sourceViewer;
@@ -2835,7 +2844,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
});
fProjectionSupport.install();
- fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+ fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry()
+ .getCurrentFoldingProvider();
if (fProjectionModelUpdater != null)
fProjectionModelUpdater.install(this, projectionViewer);
@@ -2854,7 +2864,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* Holds the current occurrence annotations.
* @since 5.0
*/
- private Annotation[] fOccurrenceAnnotations= null;
+ private Annotation[] fOccurrenceAnnotations = null;
/**
* Tells whether all occurrences of the element at the
* current caret location are automatically marked in
@@ -2887,7 +2897,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* occurrence marking took place.
* @since 5.0
*/
- private long fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
+ private long fMarkOccurrenceModificationStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
/**
* The region of the word under the caret used to when
* computing the current occurrence markings.
@@ -2910,7 +2920,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
protected void initializeKeyBindingScopes() {
- setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.cEditorScope" }); //$NON-NLS-1$
+ setKeyBindingScopes(new String[] { "org.eclipse.cdt.ui.cEditorScope" }); //$NON-NLS-1$
}
@Override
@@ -2957,19 +2967,19 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
}
- /**
- * Sets the given message as error message to this editor's status line.
- *
- * @param message message to be set
- */
- @Override
+ /**
+ * Sets the given message as error message to this editor's status line.
+ *
+ * @param message message to be set
+ */
+ @Override
public void setStatusLineErrorMessage(String message) {
- long now= System.currentTimeMillis();
+ long now = System.currentTimeMillis();
if (message != null || now - fErrorMessageTime > ERROR_MESSAGE_TIMEOUT) {
super.setStatusLineErrorMessage(message);
- fErrorMessageTime= message != null ? now : 0;
+ fErrorMessageTime = message != null ? now : 0;
}
- }
+ }
/**
* Sets the given message as message to this editor's status line.
@@ -3029,48 +3039,48 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private static char getEscapeCharacter(char character) {
switch (character) {
- case '"':
- case '\'':
- return '\\';
- default:
- return 0;
+ case '"':
+ case '\'':
+ return '\\';
+ default:
+ return 0;
}
}
private static char getPeerCharacter(char character) {
switch (character) {
- case '(':
- return ')';
+ case '(':
+ return ')';
- case ')':
- return '(';
+ case ')':
+ return '(';
- case '<':
- return '>';
+ case '<':
+ return '>';
- case '>':
- return '<';
+ case '>':
+ return '<';
- case '[':
- return ']';
+ case '[':
+ return ']';
- case ']':
- return '[';
+ case ']':
+ return '[';
- case '{':
- return '}';
+ case '{':
+ return '}';
- case '}':
- return '{';
+ case '}':
+ return '{';
- case '"':
- return character;
+ case '"':
+ return character;
- case '\'':
- return character;
+ case '\'':
+ return character;
- default:
- throw new IllegalArgumentException();
+ default:
+ throw new IllegalArgumentException();
}
}
@@ -3099,23 +3109,23 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
@Override
public void aboutToBeReconciled() {
- fIsReconciling= true;
+ fIsReconciling = true;
// Notify AST provider
CUIPlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputCElement());
// Notify listeners
Object[] listeners = fReconcilingListeners.getListeners();
- for (int i = 0, length= listeners.length; i < length; ++i) {
+ for (int i = 0, length = listeners.length; i < length; ++i) {
((ICReconcilingListener) listeners[i]).aboutToBeReconciled();
}
}
@Override
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
- fIsReconciling= false;
+ fIsReconciling = false;
- CUIPlugin cuiPlugin= CUIPlugin.getDefault();
+ CUIPlugin cuiPlugin = CUIPlugin.getDefault();
if (cuiPlugin == null)
return;
@@ -3124,7 +3134,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
// Notify listeners
Object[] listeners = fReconcilingListeners.getListeners();
- for (int i = 0, length= listeners.length; i < length; ++i) {
+ for (int i = 0, length = listeners.length; i < length; ++i) {
((ICReconcilingListener) listeners[i]).reconciled(ast, force, progressMonitor);
}
}
@@ -3157,7 +3167,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @since 4.0
*/
protected boolean isSemanticHighlightingEnabled() {
- return SemanticHighlightings.isEnabled(getPreferenceStore()) && !(isEnableScalablilityMode() && getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT));
+ return SemanticHighlightings.isEnabled(getPreferenceStore()) && !(isEnableScalablilityMode()
+ && getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT));
}
/**
@@ -3167,8 +3178,9 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
*/
private void installSemanticHighlighting() {
if (fSemanticManager == null) {
- fSemanticManager= new SemanticHighlightingManager();
- fSemanticManager.install(this, (CSourceViewer) getSourceViewer(), CUIPlugin.getDefault().getTextTools().getColorManager(), getPreferenceStore());
+ fSemanticManager = new SemanticHighlightingManager();
+ fSemanticManager.install(this, (CSourceViewer) getSourceViewer(),
+ CUIPlugin.getDefault().getTextTools().getColorManager(), getPreferenceStore());
}
}
@@ -3180,7 +3192,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private void uninstallSemanticHighlighting() {
if (fSemanticManager != null) {
fSemanticManager.uninstall();
- fSemanticManager= null;
+ fSemanticManager = null;
}
}
@@ -3226,24 +3238,25 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private boolean fCanceled;
private final OccurrenceLocation[] fLocations;
- public OccurrencesAnnotationUpdaterJob(IDocument document, OccurrenceLocation[] locations, ISelection selection, ISelectionValidator validator) {
- super(CEditorMessages.CEditor_markOccurrences_job_name);
- fDocument= document;
- fSelection= selection;
- fLocations= locations;
- fPostSelectionValidator= validator;
+ public OccurrencesAnnotationUpdaterJob(IDocument document, OccurrenceLocation[] locations, ISelection selection,
+ ISelectionValidator validator) {
+ super(CEditorMessages.CEditor_markOccurrences_job_name);
+ fDocument = document;
+ fSelection = selection;
+ fLocations = locations;
+ fPostSelectionValidator = validator;
}
// cannot use cancel() because it is declared final
void doCancel() {
- fCanceled= true;
+ fCanceled = true;
cancel();
}
private boolean isCanceled(IProgressMonitor progressMonitor) {
- return fCanceled || progressMonitor.isCanceled()
- || fPostSelectionValidator != null && !(fPostSelectionValidator.isValid(fSelection) || fForcedMarkOccurrencesSelection == fSelection)
- || LinkedModeModel.hasInstalledModel(fDocument);
+ return fCanceled || progressMonitor.isCanceled() || fPostSelectionValidator != null
+ && !(fPostSelectionValidator.isValid(fSelection) || fForcedMarkOccurrencesSelection == fSelection)
+ || LinkedModeModel.hasInstalledModel(fDocument);
}
@Override
@@ -3251,34 +3264,36 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (isCanceled(progressMonitor))
return Status.CANCEL_STATUS;
- ITextViewer textViewer= getViewer();
+ ITextViewer textViewer = getViewer();
if (textViewer == null)
return Status.CANCEL_STATUS;
- IDocument document= textViewer.getDocument();
+ IDocument document = textViewer.getDocument();
if (document == null)
return Status.CANCEL_STATUS;
- IDocumentProvider documentProvider= getDocumentProvider();
+ IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider == null)
return Status.CANCEL_STATUS;
- IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
+ IAnnotationModel annotationModel = documentProvider.getAnnotationModel(getEditorInput());
if (annotationModel == null)
return Status.CANCEL_STATUS;
// Add occurrence annotations
- int length= fLocations.length;
- Map<Annotation, Position> annotationMap= new HashMap<>(length);
- for (int i= 0; i < length; i++) {
+ int length = fLocations.length;
+ Map<Annotation, Position> annotationMap = new HashMap<>(length);
+ for (int i = 0; i < length; i++) {
if (isCanceled(progressMonitor))
return Status.CANCEL_STATUS;
- OccurrenceLocation location= fLocations[i];
- Position position= new Position(location.getOffset(), location.getLength());
+ OccurrenceLocation location = fLocations[i];
+ Position position = new Position(location.getOffset(), location.getLength());
- String description= location.getDescription();
- String annotationType= (location.getFlags() == IOccurrencesFinder.F_WRITE_OCCURRENCE) ? "org.eclipse.cdt.ui.occurrences.write" : "org.eclipse.cdt.ui.occurrences"; //$NON-NLS-1$ //$NON-NLS-2$
+ String description = location.getDescription();
+ String annotationType = (location.getFlags() == IOccurrencesFinder.F_WRITE_OCCURRENCE)
+ ? "org.eclipse.cdt.ui.occurrences.write" //$NON-NLS-1$
+ : "org.eclipse.cdt.ui.occurrences"; //$NON-NLS-1$
annotationMap.put(new Annotation(annotationType, false, description), position);
}
@@ -3288,16 +3303,17 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
synchronized (getLockObject(annotationModel)) {
if (annotationModel instanceof IAnnotationModelExtension) {
- ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
+ ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations,
+ annotationMap);
} else {
removeOccurrenceAnnotations();
- Iterator<Map.Entry<Annotation, Position>> iter= annotationMap.entrySet().iterator();
+ Iterator<Map.Entry<Annotation, Position>> iter = annotationMap.entrySet().iterator();
while (iter.hasNext()) {
- Map.Entry<Annotation, Position> mapEntry= iter.next();
+ Map.Entry<Annotation, Position> mapEntry = iter.next();
annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue());
}
}
- fOccurrenceAnnotations= annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
+ fOccurrenceAnnotations = annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
}
return Status.OK_STATUS;
@@ -3312,29 +3328,29 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
class OccurrencesFinderJobCanceler implements IDocumentListener, ITextInputListener {
public void install() {
- ISourceViewer sourceViewer= getSourceViewer();
+ ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null)
return;
- StyledText text= sourceViewer.getTextWidget();
+ StyledText text = sourceViewer.getTextWidget();
if (text == null || text.isDisposed())
return;
sourceViewer.addTextInputListener(this);
- IDocument document= sourceViewer.getDocument();
+ IDocument document = sourceViewer.getDocument();
if (document != null)
document.addDocumentListener(this);
}
public void uninstall() {
- ISourceViewer sourceViewer= getSourceViewer();
+ ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer != null)
sourceViewer.removeTextInputListener(this);
- IDocumentProvider documentProvider= getDocumentProvider();
+ IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider != null) {
- IDocument document= documentProvider.getDocument(getEditorInput());
+ IDocument document = documentProvider.getDocument(getEditorInput());
if (document != null)
document.removeDocumentListener(this);
}
@@ -3384,36 +3400,37 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (astRoot == null || selection == null)
return;
- IDocument document= getSourceViewer().getDocument();
+ IDocument document = getSourceViewer().getDocument();
if (document == null)
return;
- ISelectionValidator validator= null;
+ ISelectionValidator validator = null;
if (fForcedMarkOccurrencesSelection != selection && getSelectionProvider() instanceof ISelectionValidator) {
- validator= (ISelectionValidator) getSelectionProvider();
+ validator = (ISelectionValidator) getSelectionProvider();
if (!validator.isValid(selection)) {
return;
}
}
- boolean hasChanged= false;
+ boolean hasChanged = false;
if (document instanceof IDocumentExtension4) {
- int offset= selection.getOffset();
- long currentModificationStamp= ((IDocumentExtension4) document).getModificationStamp();
- IRegion markOccurrenceTargetRegion= fMarkOccurrenceTargetRegion;
- hasChanged= currentModificationStamp != fMarkOccurrenceModificationStamp;
+ int offset = selection.getOffset();
+ long currentModificationStamp = ((IDocumentExtension4) document).getModificationStamp();
+ IRegion markOccurrenceTargetRegion = fMarkOccurrenceTargetRegion;
+ hasChanged = currentModificationStamp != fMarkOccurrenceModificationStamp;
if (markOccurrenceTargetRegion != null && !hasChanged) {
- if (markOccurrenceTargetRegion.getOffset() <= offset && offset <= markOccurrenceTargetRegion.getOffset() + markOccurrenceTargetRegion.getLength())
+ if (markOccurrenceTargetRegion.getOffset() <= offset
+ && offset <= markOccurrenceTargetRegion.getOffset() + markOccurrenceTargetRegion.getLength())
return;
}
- fMarkOccurrenceTargetRegion= CWordFinder.findWord(document, offset);
- fMarkOccurrenceModificationStamp= currentModificationStamp;
+ fMarkOccurrenceTargetRegion = CWordFinder.findWord(document, offset);
+ fMarkOccurrenceModificationStamp = currentModificationStamp;
}
- OccurrenceLocation[] locations= null;
+ OccurrenceLocation[] locations = null;
- IASTNodeSelector selector= astRoot.getNodeSelector(null);
- IASTName name= selector.findEnclosingName(selection.getOffset(), selection.getLength());
+ IASTNodeSelector selector = astRoot.getNodeSelector(null);
+ IASTName name = selector.findEnclosingName(selection.getOffset(), selection.getLength());
if (name == null)
name = selector.findEnclosingImplicitName(selection.getOffset(), selection.getLength());
@@ -3422,14 +3439,14 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
if (name != null) {
- IBinding binding= name.resolveBinding();
+ IBinding binding = name.resolveBinding();
if (binding != null) {
- OccurrencesFinder occurrencesFinder= new OccurrencesFinder();
+ OccurrencesFinder occurrencesFinder = new OccurrencesFinder();
if (occurrencesFinder.initialize(astRoot, name) == null) {
- if (!fMarkOverloadedOperatorOccurrences) {
- occurrencesFinder.setOptions(OccurrencesFinder.OPTION_EXCLUDE_IMPLICIT_REFERENCES);
- }
- locations= occurrencesFinder.getOccurrences();
+ if (!fMarkOverloadedOperatorOccurrences) {
+ occurrencesFinder.setOptions(OccurrencesFinder.OPTION_EXCLUDE_IMPLICIT_REFERENCES);
+ }
+ locations = occurrencesFinder.getOccurrences();
}
}
}
@@ -3442,7 +3459,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
return;
}
- fOccurrencesAnnotationUpdaterJob= new OccurrencesAnnotationUpdaterJob(document, locations, selection, validator);
+ fOccurrencesAnnotationUpdaterJob = new OccurrencesAnnotationUpdaterJob(document, locations, selection,
+ validator);
// we are already in a background job
//fOccurrencesFinderJob.setPriority(Job.DECORATE);
//fOccurrencesFinderJob.setSystem(true);
@@ -3451,9 +3469,9 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
protected void installOccurrencesFinder(boolean forceUpdate) {
- fMarkOccurrenceAnnotations= true;
+ fMarkOccurrenceAnnotations = true;
- fPostSelectionListenerWithAST= new ISelectionListenerWithAST() {
+ fPostSelectionListenerWithAST = new ISelectionListenerWithAST() {
@Override
public void selectionChanged(IEditorPart part, ITextSelection selection, IASTTranslationUnit astRoot) {
updateOccurrenceAnnotations(selection, astRoot);
@@ -3463,58 +3481,59 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
if (forceUpdate && getSelectionProvider() != null) {
ICElement inputCElement = getInputCElement();
if (inputCElement instanceof ITranslationUnit) {
- fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection();
- ASTProvider.getASTProvider().runOnAST(inputCElement, ASTProvider.WAIT_NO, getProgressMonitor(), new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
- updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, ast);
- return Status.OK_STATUS;
- }
- });
+ fForcedMarkOccurrencesSelection = getSelectionProvider().getSelection();
+ ASTProvider.getASTProvider().runOnAST(inputCElement, ASTProvider.WAIT_NO, getProgressMonitor(),
+ new ASTRunnable() {
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+ updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, ast);
+ return Status.OK_STATUS;
+ }
+ });
}
}
if (fOccurrencesFinderJobCanceler == null) {
- fOccurrencesFinderJobCanceler= new OccurrencesFinderJobCanceler();
+ fOccurrencesFinderJobCanceler = new OccurrencesFinderJobCanceler();
fOccurrencesFinderJobCanceler.install();
}
}
protected void uninstallOccurrencesFinder() {
- fMarkOccurrenceAnnotations= false;
+ fMarkOccurrenceAnnotations = false;
if (fOccurrencesAnnotationUpdaterJob != null) {
fOccurrencesAnnotationUpdaterJob.cancel();
- fOccurrencesAnnotationUpdaterJob= null;
+ fOccurrencesAnnotationUpdaterJob = null;
}
if (fOccurrencesFinderJobCanceler != null) {
fOccurrencesFinderJobCanceler.uninstall();
- fOccurrencesFinderJobCanceler= null;
+ fOccurrencesFinderJobCanceler = null;
}
if (fPostSelectionListenerWithAST != null) {
SelectionListenerWithASTManager.getDefault().removeListener(this, fPostSelectionListenerWithAST);
- fPostSelectionListenerWithAST= null;
+ fPostSelectionListenerWithAST = null;
}
removeOccurrenceAnnotations();
}
protected boolean isMarkingOccurrences() {
- IPreferenceStore store= getPreferenceStore();
+ IPreferenceStore store = getPreferenceStore();
return store != null && store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
}
void removeOccurrenceAnnotations() {
- fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
- fMarkOccurrenceTargetRegion= null;
+ fMarkOccurrenceModificationStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
+ fMarkOccurrenceTargetRegion = null;
- IDocumentProvider documentProvider= getDocumentProvider();
+ IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider == null)
return;
- IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
+ IAnnotationModel annotationModel = documentProvider.getAnnotationModel(getEditorInput());
if (annotationModel == null || fOccurrenceAnnotations == null)
return;
@@ -3525,7 +3544,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
for (Annotation occurrenceAnnotation : fOccurrenceAnnotations)
annotationModel.removeAnnotation(occurrenceAnnotation);
}
- fOccurrenceAnnotations= null;
+ fOccurrenceAnnotations = null;
}
}
@@ -3536,9 +3555,9 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @return the preference store for this editor
*/
private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) {
- List<IPreferenceStore> stores= new ArrayList<>(3);
+ List<IPreferenceStore> stores = new ArrayList<>(3);
- ICProject project= EditorUtility.getCProject(input);
+ ICProject project = EditorUtility.getCProject(input);
if (project != null) {
stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), CCorePlugin.PLUGIN_ID));
}
@@ -3558,7 +3577,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
public boolean isParserBasedContentAssistDisabled() {
return getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
}
-
+
/**
* @return {@code true} if Content Assist auto activation is disabled.
*
@@ -3567,7 +3586,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
public boolean isContentAssistAutoActivartionDisabled() {
return getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION);
}
-
+
/**
* @return {@code true} if the number of lines in the file exceed
* the line number for scalability mode in the preference.
@@ -3588,15 +3607,15 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
public boolean shouldProcessLocalParsingCompletions() {
return true;
}
-
+
protected void uninstallOverrideIndicator() {
if (fOverrideIndicatorManager != null) {
fOverrideIndicatorManager.removeAnnotations();
removeReconcileListener(fOverrideIndicatorManager);
- fOverrideIndicatorManager= null;
+ fOverrideIndicatorManager = null;
}
}
-
+
/**
* Determines whether the preference change encoded by the given event
* changes the override indication.
@@ -3606,17 +3625,18 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @since 5.3
*/
protected boolean affectsOverrideIndicatorAnnotations(PropertyChangeEvent event) {
- String key= event.getProperty();
- AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
+ String key = event.getProperty();
+ AnnotationPreference preference = getAnnotationPreferenceLookup()
+ .getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
if (key == null || preference == null)
return false;
return key.equals(preference.getHighlightPreferenceKey())
- || key.equals(preference.getVerticalRulerPreferenceKey())
- || key.equals(preference.getOverviewRulerPreferenceKey())
- || key.equals(preference.getTextPreferenceKey());
+ || key.equals(preference.getVerticalRulerPreferenceKey())
+ || key.equals(preference.getOverviewRulerPreferenceKey())
+ || key.equals(preference.getTextPreferenceKey());
}
-
+
/**
* Returns the boolean preference for the given key.
*
@@ -3628,7 +3648,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private boolean getBoolean(IPreferenceStore store, String key) {
return key != null && store.getBoolean(key);
}
-
+
/**
* Tells whether override indicators are shown.
*
@@ -3636,37 +3656,40 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @since 5.3
*/
protected boolean isShowingOverrideIndicators() {
- AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
- IPreferenceStore store= getPreferenceStore();
+ AnnotationPreference preference = getAnnotationPreferenceLookup()
+ .getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
+ IPreferenceStore store = getPreferenceStore();
return getBoolean(store, preference.getHighlightPreferenceKey())
- || getBoolean(store, preference.getVerticalRulerPreferenceKey())
- || getBoolean(store, preference.getOverviewRulerPreferenceKey())
- || getBoolean(store, preference.getTextPreferenceKey());
+ || getBoolean(store, preference.getVerticalRulerPreferenceKey())
+ || getBoolean(store, preference.getOverviewRulerPreferenceKey())
+ || getBoolean(store, preference.getTextPreferenceKey());
}
-
+
protected void installOverrideIndicator(boolean provideAST) {
uninstallOverrideIndicator();
- IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+ IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
if (model == null)
return;
- fOverrideIndicatorManager= new OverrideIndicatorManager(model, null);
-
+ fOverrideIndicatorManager = new OverrideIndicatorManager(model, null);
+
addReconcileListener(fOverrideIndicatorManager);
ICElement inputCElement = getInputCElement();
if (provideAST && inputCElement instanceof ITranslationUnit) {
- ASTProvider.getASTProvider().runOnAST(inputCElement, ASTProvider.WAIT_ACTIVE_ONLY, getProgressMonitor(), new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
- if (ast != null)
- fOverrideIndicatorManager.reconciled(ast, true, getProgressMonitor());
- return Status.OK_STATUS;
- }});
+ ASTProvider.getASTProvider().runOnAST(inputCElement, ASTProvider.WAIT_ACTIVE_ONLY, getProgressMonitor(),
+ new ASTRunnable() {
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+ if (ast != null)
+ fOverrideIndicatorManager.reconciled(ast, true, getProgressMonitor());
+ return Status.OK_STATUS;
+ }
+ });
}
}
-
+
@Override
protected void editorSaved() {
super.editorSaved();
@@ -3680,14 +3703,14 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
}
}
-
+
/**
* @since 5.4
*/
public void addPostSaveListener(IPostSaveListener listener) {
fPostSaveListeners.add(listener);
}
-
+
/**
* @since 5.4
*/
@@ -3701,7 +3724,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
return super.createAnnotationRulerColumn(ruler);
}
- AnnotationRulerColumn column= new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess());
+ AnnotationRulerColumn column = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess());
column.setHover(new CExpandHover(ruler, getAnnotationAccess(), new IDoubleClickListener() {
@Override
@@ -3711,13 +3734,13 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
}
private void triggerAction(String actionID) {
- IAction action= getAction(actionID);
+ IAction action = getAction(actionID);
if (action != null) {
if (action instanceof IUpdate)
((IUpdate) action).update();
// hack to propagate line change
if (action instanceof ISelectionListener) {
- ((ISelectionListener)action).selectionChanged(null, null);
+ ((ISelectionListener) action).selectionChanged(null, null);
}
if (action.isEnabled()) {
action.run();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
index fe05ffc4378..a17e9ba6d27 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
@@ -64,12 +64,12 @@ public class CEditorActionContributor extends TextEditorActionContributor {
private RetargetTextEditorAction fExpandSelectionToNext;
private RetargetTextEditorAction fExpandSelectionToPrevious;
private RetargetTextEditorAction fExpandSelectionToHistory;
-
+
public CEditorActionContributor() {
super();
-
+
ResourceBundle bundle = ConstructedCEditorMessages.getResourceBundle();
-
+
fContentAssist = new RetargetTextEditorAction(bundle, "ContentAssistProposal."); //$NON-NLS-1$
fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
@@ -77,45 +77,45 @@ public class CEditorActionContributor extends TextEditorActionContributor {
fContextInformation.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
// actions that are "contributed" to editors, they are considered belonging to the active editor
- fTogglePresentation= new TogglePresentationAction();
+ fTogglePresentation = new TogglePresentationAction();
- fToggleMarkOccurrencesAction= new ToggleMarkOccurrencesAction();
+ fToggleMarkOccurrencesAction = new ToggleMarkOccurrencesAction();
- fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
- fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
+ fPreviousAnnotation = new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
+ fNextAnnotation = new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
- fGotoMatchingBracket= new RetargetTextEditorAction(bundle, "GotoMatchingBracket."); //$NON-NLS-1$
+ fGotoMatchingBracket = new RetargetTextEditorAction(bundle, "GotoMatchingBracket."); //$NON-NLS-1$
fGotoMatchingBracket.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
fGotoNextBookmark = new RetargetTextEditorAction(bundle, "GotoNextBookmark."); //$NON-NLS-1$
fGotoNextBookmark.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_BOOKMARK);
- fGotoNextMemberAction= new RetargetTextEditorAction(bundle, "GotoNextMember."); //$NON-NLS-1$
+ fGotoNextMemberAction = new RetargetTextEditorAction(bundle, "GotoNextMember."); //$NON-NLS-1$
fGotoNextMemberAction.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
- fGotoPreviousMemberAction= new RetargetTextEditorAction(bundle, "GotoPreviousMember."); //$NON-NLS-1$
+ fGotoPreviousMemberAction = new RetargetTextEditorAction(bundle, "GotoPreviousMember."); //$NON-NLS-1$
fGotoPreviousMemberAction.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
- fToggleInsertModeAction= new RetargetTextEditorAction(bundle, "ToggleInsertMode.", IAction.AS_CHECK_BOX); //$NON-NLS-1$
+ fToggleInsertModeAction = new RetargetTextEditorAction(bundle, "ToggleInsertMode.", IAction.AS_CHECK_BOX); //$NON-NLS-1$
fToggleInsertModeAction.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
- fShowOutline= new RetargetTextEditorAction(bundle, "OpenOutline."); //$NON-NLS-1$
+ fShowOutline = new RetargetTextEditorAction(bundle, "OpenOutline."); //$NON-NLS-1$
fShowOutline.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_OUTLINE);
- fToggleSourceHeader= new RetargetTextEditorAction(bundle, "ToggleSourceHeader."); //$NON-NLS-1$
+ fToggleSourceHeader = new RetargetTextEditorAction(bundle, "ToggleSourceHeader."); //$NON-NLS-1$
fToggleSourceHeader.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_SOURCE_HEADER);
fFindWord = new RetargetTextEditorAction(bundle, "FindWord."); //$NON-NLS-1$
fFindWord.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_WORD);
-
+
fExpandSelectionToEnclosing = new RetargetTextEditorAction(bundle, StructureSelectEnclosingAction.PREFIX);
fExpandSelectionToEnclosing.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_ENCLOSING);
- fExpandSelectionToNext= new RetargetTextEditorAction(bundle, StructureSelectNextAction.PREFIX);
+ fExpandSelectionToNext = new RetargetTextEditorAction(bundle, StructureSelectNextAction.PREFIX);
fExpandSelectionToNext.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_NEXT);
- fExpandSelectionToPrevious= new RetargetTextEditorAction(bundle, StructureSelectPreviousAction.PREFIX);
+ fExpandSelectionToPrevious = new RetargetTextEditorAction(bundle, StructureSelectPreviousAction.PREFIX);
fExpandSelectionToPrevious.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_PREVIOUS);
- fExpandSelectionToHistory= new RetargetTextEditorAction(bundle, StructureSelectHistoryAction.PREFIX);
+ fExpandSelectionToHistory = new RetargetTextEditorAction(bundle, StructureSelectHistoryAction.PREFIX);
fExpandSelectionToHistory.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_LAST);
- }
+ }
/*
* @see org.eclipse.ui.texteditor.BasicTextEditorActionContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
@@ -123,25 +123,26 @@ public class CEditorActionContributor extends TextEditorActionContributor {
@Override
public void contributeToMenu(IMenuManager menu) {
super.contributeToMenu(menu);
-
- IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
+
+ IMenuManager editMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+ if (editMenu != null) {
editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, fContentAssist);
editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, fContextInformation);
editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fFindWord);
-// editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftRight);
-// editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftLeft);
-// editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fFormatter);
-// editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
-// editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fAddInclude);
-// editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
+ // editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftRight);
+ // editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftLeft);
+ // editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fFormatter);
+ // editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
+ // editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fAddInclude);
+ // editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
editMenu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleInsertModeAction);
-
+
{
- MenuManager structureSelection = new MenuManager(CEditorMessages.CEditorActionContributor_ExpandSelectionMenu_label,"expandSelection"); //$NON-NLS-1$
+ MenuManager structureSelection = new MenuManager(
+ CEditorMessages.CEditorActionContributor_ExpandSelectionMenu_label, "expandSelection"); //$NON-NLS-1$
editMenu.insertAfter(ITextEditorActionConstants.SELECT_ALL, structureSelection);
structureSelection.add(fExpandSelectionToEnclosing);
structureSelection.add(fExpandSelectionToNext);
@@ -149,16 +150,16 @@ public class CEditorActionContributor extends TextEditorActionContributor {
structureSelection.add(fExpandSelectionToHistory);
}
}
-
- IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
+
+ IMenuManager navigateMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
if (navigateMenu != null) {
navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fToggleSourceHeader);
navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fShowOutline);
- IMenuManager gotoMenu= navigateMenu.findMenuUsingPath(IWorkbenchActionConstants.GO_TO);
+ IMenuManager gotoMenu = navigateMenu.findMenuUsingPath(IWorkbenchActionConstants.GO_TO);
if (gotoMenu != null) {
- gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
+ gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
gotoMenu.appendToGroup("additions2", fGotoPreviousMemberAction); //$NON-NLS-1$
gotoMenu.appendToGroup("additions2", fGotoNextMemberAction); //$NON-NLS-1$
gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
@@ -166,7 +167,7 @@ public class CEditorActionContributor extends TextEditorActionContributor {
}
}
}
-
+
/**
* @see org.eclipse.ui.part.EditorActionBarContributor#init(IActionBars)
*/
@@ -174,12 +175,13 @@ public class CEditorActionContributor extends TextEditorActionContributor {
public void init(IActionBars bars) {
super.init(bars);
- // register actions that have a dynamic editor.
+ // register actions that have a dynamic editor.
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextAnnotation);
bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousAnnotation);
- bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
+ bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY,
+ fTogglePresentation);
bars.setGlobalActionHandler(ICEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES, fToggleMarkOccurrencesAction);
}
@@ -189,11 +191,11 @@ public class CEditorActionContributor extends TextEditorActionContributor {
@Override
public void setActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
-
- ITextEditor textEditor= null;
+
+ ITextEditor textEditor = null;
if (part instanceof ITextEditor)
- textEditor= (ITextEditor) part;
-
+ textEditor = (ITextEditor) part;
+
fTogglePresentation.setEditor(textEditor);
fToggleMarkOccurrencesAction.setEditor(textEditor);
fPreviousAnnotation.setEditor(textEditor);
@@ -211,14 +213,14 @@ public class CEditorActionContributor extends TextEditorActionContributor {
fToggleSourceHeader.setAction(getAction(textEditor, "ToggleSourceHeader")); //$NON-NLS-1$
fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE));
fFindWord.setAction(getAction(textEditor, FindWordAction.FIND_WORD));
-
+
fExpandSelectionToEnclosing.setAction(getAction(textEditor, StructureSelectionAction.ENCLOSING));
fExpandSelectionToNext.setAction(getAction(textEditor, StructureSelectionAction.NEXT));
fExpandSelectionToPrevious.setAction(getAction(textEditor, StructureSelectionAction.PREVIOUS));
fExpandSelectionToHistory.setAction(getAction(textEditor, StructureSelectionAction.HISTORY));
// Source menu.
- IActionBars bars= getActionBars();
+ IActionBars bars = getActionBars();
bars.setGlobalActionHandler(CdtActionConstants.SHIFT_RIGHT, getAction(textEditor, "ShiftRight")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.SHIFT_LEFT, getAction(textEditor, "ShiftLeft")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$
@@ -226,29 +228,35 @@ public class CEditorActionContributor extends TextEditorActionContributor {
bars.setGlobalActionHandler(CdtActionConstants.TOGGLE_COMMENT, getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
- bars.setGlobalActionHandler(CdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
+ bars.setGlobalActionHandler(CdtActionConstants.REMOVE_BLOCK_COMMENT,
+ getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.INDENT, getAction(textEditor, "Indent")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.ALIGN_CONST, getAction(textEditor, "AlignConst")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.ADD_INCLUDE, getAction(textEditor, "AddInclude")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.ORGANIZE_INCLUDES, getAction(textEditor, "OrganizeIncludes")); //$NON-NLS-1$
bars.setGlobalActionHandler(CdtActionConstants.SORT_LINES, getAction(textEditor, "SortLines")); //$NON-NLS-1$
- IAction action= getAction(textEditor, ITextEditorActionConstants.REFRESH);
+ IAction action = getAction(textEditor, ITextEditorActionConstants.REFRESH);
bars.setGlobalActionHandler(ITextEditorActionConstants.REFRESH, action);
- bars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
- bars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
+ bars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(),
+ getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
+ bars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(),
+ getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
- bars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), getAction(textEditor, IDEActionFactory.OPEN_PROJECT.getId()));
- bars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), getAction(textEditor, IDEActionFactory.CLOSE_PROJECT.getId()));
- bars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), getAction(textEditor, IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId()));
+ bars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(),
+ getAction(textEditor, IDEActionFactory.OPEN_PROJECT.getId()));
+ bars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(),
+ getAction(textEditor, IDEActionFactory.CLOSE_PROJECT.getId()));
+ bars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(),
+ getAction(textEditor, IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId()));
if (part instanceof CEditor) {
- CEditor cEditor= (CEditor) part;
+ CEditor cEditor = (CEditor) part;
cEditor.fillActionBars(bars);
}
}
-
+
@Override
public void dispose() {
setActiveEditor(null);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
index 376e7b22085..b726314ea93 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
-
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.graphics.Image;
@@ -46,11 +45,12 @@ public class CEditorErrorTickUpdater implements IProblemChangedListener {
CEditorImageProvider() {
super(0, CElementImageProvider.SMALL_ICONS);
}
+
@Override
protected int evaluateImageFlags(Object element) {
- int flags= getImageFlags();
+ int flags = getImageFlags();
if (element instanceof ITranslationUnit) {
- ITranslationUnit tUnit= (ITranslationUnit) element;
+ ITranslationUnit tUnit = (ITranslationUnit) element;
if (tUnit.getResource() == null) {
flags |= CElementImageProvider.OVERLAY_EXTERNAL;
}
@@ -64,13 +64,12 @@ public class CEditorErrorTickUpdater implements IProblemChangedListener {
public CEditorErrorTickUpdater(CEditor editor) {
Assert.isNotNull(editor);
- fCEditor= editor;
- fLabelProvider= new CEditorImageProvider();
+ fCEditor = editor;
+ fLabelProvider = new CEditorImageProvider();
fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
CUIPlugin.getDefault().getProblemMarkerManager().addListener(this);
}
-
/* (non-Javadoc)
* @see IProblemChangedListener#problemsChanged(IResource[], boolean)
*/
@@ -79,15 +78,15 @@ public class CEditorErrorTickUpdater implements IProblemChangedListener {
if (!isMarkerChange) {
return;
}
- IEditorInput input= fCEditor.getEditorInput();
+ IEditorInput input = fCEditor.getEditorInput();
if (input != null) { // might run async, tests needed
- ICElement celement= fCEditor.getInputCElement();
+ ICElement celement = fCEditor.getInputCElement();
if (celement != null) {
- IResource resource= celement.getResource();
+ IResource resource = celement.getResource();
if (resource == null) {
return;
}
- for (int i = 0; i < resourcesChanged.length; i++){
+ for (int i = 0; i < resourcesChanged.length; i++) {
if (resource.equals(resourcesChanged[i])) {
updateEditorImage(celement);
return;
@@ -96,20 +95,20 @@ public class CEditorErrorTickUpdater implements IProblemChangedListener {
}
}
}
-
+
public void updateEditorImage(ICElement celement) {
- Image titleImage= fCEditor.getTitleImage();
+ Image titleImage = fCEditor.getTitleImage();
if (titleImage == null) {
return;
}
- Image newImage= fLabelProvider.getImage(celement);
+ Image newImage = fLabelProvider.getImage(celement);
if (titleImage != newImage) {
postImageChange(newImage);
}
}
-
+
private void postImageChange(final Image newImage) {
- Shell shell= fCEditor.getEditorSite().getShell();
+ Shell shell = fCEditor.getEditorSite().getShell();
if (shell != null && !shell.isDisposed()) {
shell.getDisplay().syncExec(new Runnable() {
@Override
@@ -119,7 +118,7 @@ public class CEditorErrorTickUpdater implements IProblemChangedListener {
});
}
}
-
+
public void dispose() {
fLabelProvider.dispose();
CUIPlugin.getDefault().getProblemMarkerManager().removeListener(this);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
index 81d4af27b64..9acec2140ea 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
@@ -21,9 +21,8 @@ import java.util.ResourceBundle;
import org.eclipse.osgi.util.NLS;
public final class CEditorMessages extends NLS {
- private static final String BUNDLE_FOR_CONSTRUCTED_KEYS=
- "org.eclipse.cdt.internal.ui.editor.ConstructedCEditorMessages"; //$NON-NLS-1$
- private static ResourceBundle fgBundleForConstructedKeys= ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS);
+ private static final String BUNDLE_FOR_CONSTRUCTED_KEYS = "org.eclipse.cdt.internal.ui.editor.ConstructedCEditorMessages"; //$NON-NLS-1$
+ private static ResourceBundle fgBundleForConstructedKeys = ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS);
/**
* Returns the message bundle which contains constructed keys.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlink.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlink.java
index fa14d7411c1..01d4b1c26e1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlink.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlink.java
@@ -19,10 +19,9 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
-
/**
* C element hyperlink.
- *
+ *
* @since 3.0
*/
public class CElementHyperlink implements IHyperlink {
@@ -30,18 +29,17 @@ public class CElementHyperlink implements IHyperlink {
private final IRegion fRegion;
private final IAction fOpenAction;
-
/**
* Creates a new C element hyperlink.
*/
public CElementHyperlink(IRegion region, IAction openAction) {
Assert.isNotNull(openAction);
Assert.isNotNull(region);
-
- fRegion= region;
- fOpenAction= openAction;
+
+ fRegion = region;
+ fOpenAction = openAction;
}
-
+
@Override
public IRegion getHyperlinkRegion() {
return fRegion;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
index 1eea572fd58..60b7be813e3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
@@ -59,17 +59,19 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
}
@Override
- public IHyperlink[] detectHyperlinks(final ITextViewer textViewer, final IRegion region, boolean canShowMultipleHyperlinks) {
- ITextEditor textEditor= getAdapter(ITextEditor.class);
+ public IHyperlink[] detectHyperlinks(final ITextViewer textViewer, final IRegion region,
+ boolean canShowMultipleHyperlinks) {
+ ITextEditor textEditor = getAdapter(ITextEditor.class);
if (region == null || !(textEditor instanceof ICModelBasedEditor))
return null;
- final IAction openAction= textEditor.getAction("OpenDeclarations"); //$NON-NLS-1$
+ final IAction openAction = textEditor.getAction("OpenDeclarations"); //$NON-NLS-1$
if (openAction == null)
return null;
IDocument document = textViewer.getDocument();
- final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(textEditor.getEditorInput());
+ final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager()
+ .getWorkingCopy(textEditor.getEditorInput());
if (workingCopy == null) {
return null;
}
@@ -77,67 +79,69 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
final IRegion[] hyperlinkRegion = { null };
// Do not wait for AST if it's not available yet. Waiting for AST would block the UI thread
// for the duration of the parsing.
- IStatus status= ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_NO, null, new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
- if (ast == null)
- return Status.CANCEL_STATUS;
-
- IASTNode linkASTNode = getLinkASTNode(document, ast, region);
-
- IASTNodeLocation linkLocation = null;
- if (linkASTNode != null) {
- if (linkASTNode instanceof IASTName) {
- IASTName astName = (IASTName) linkASTNode;
- IASTImageLocation imageLocation = astName.getImageLocation();
- if (imageLocation != null) {
- linkLocation = imageLocation;
+ IStatus status = ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_NO, null,
+ new ASTRunnable() {
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+ if (ast == null)
+ return Status.CANCEL_STATUS;
+
+ IASTNode linkASTNode = getLinkASTNode(document, ast, region);
+
+ IASTNodeLocation linkLocation = null;
+ if (linkASTNode != null) {
+ if (linkASTNode instanceof IASTName) {
+ IASTName astName = (IASTName) linkASTNode;
+ IASTImageLocation imageLocation = astName.getImageLocation();
+ if (imageLocation != null) {
+ linkLocation = imageLocation;
+ }
+ }
+ if (linkLocation == null) {
+ linkLocation = linkASTNode.getFileLocation();
+ }
}
- }
- if (linkLocation == null) {
- linkLocation = linkASTNode.getFileLocation();
- }
- }
-
- if (linkLocation == null) {
- // Consider a fallback way of finding the hyperlink
- // (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=333050).
- return Status.CANCEL_STATUS;
- }
- hyperlinkRegion[0] = new Region(linkLocation.getNodeOffset(), linkLocation.getNodeLength());
- return Status.OK_STATUS;
- }
- });
+ if (linkLocation == null) {
+ // Consider a fallback way of finding the hyperlink
+ // (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=333050).
+ return Status.CANCEL_STATUS;
+ }
+
+ hyperlinkRegion[0] = new Region(linkLocation.getNodeOffset(), linkLocation.getNodeLength());
+ return Status.OK_STATUS;
+ }
+ });
if (status == Status.CANCEL_STATUS) {
// AST was not available yet or didn't help us to find the hyperlink, try to compute
- // the hyperlink without it.
+ // the hyperlink without it.
try {
// Check partition type.
- String partitionType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, region.getOffset(), false);
+ String partitionType = TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING,
+ region.getOffset(), false);
if (IDocument.DEFAULT_CONTENT_TYPE.equals(partitionType)) {
// Regular code.
hyperlinkRegion[0] = getIdentifier(document, region.getOffset(), workingCopy.getLanguage());
} else if (ICPartitions.C_PREPROCESSOR.equals(partitionType)) {
// Preprocessor directive.
- Scanner scanner= new Scanner();
+ Scanner scanner = new Scanner();
scanner.setSplitPreprocessor(true);
- scanner.setSource(document.get().toCharArray());
- scanner.setCurrentPosition(findPreprocessorDirectiveStart(document, region.getOffset()));
- Token token = scanner.nextToken();
- if (token != null && token.getType() == Token.tPREPROCESSOR_INCLUDE) {
- int endPos = token.getOffset() + token.getLength();
- // Trim trailing whitespace.
- while (Character.isWhitespace(document.getChar(--endPos))) {
- }
- endPos++;
- if (region.getOffset() <= endPos) {
- hyperlinkRegion[0] = new Region(token.getOffset(), endPos - token.getOffset());
- }
- } else {
+ scanner.setSource(document.get().toCharArray());
+ scanner.setCurrentPosition(findPreprocessorDirectiveStart(document, region.getOffset()));
+ Token token = scanner.nextToken();
+ if (token != null && token.getType() == Token.tPREPROCESSOR_INCLUDE) {
+ int endPos = token.getOffset() + token.getLength();
+ // Trim trailing whitespace.
+ while (Character.isWhitespace(document.getChar(--endPos))) {
+ }
+ endPos++;
+ if (region.getOffset() <= endPos) {
+ hyperlinkRegion[0] = new Region(token.getOffset(), endPos - token.getOffset());
+ }
+ } else {
hyperlinkRegion[0] = getIdentifier(document, region.getOffset(), workingCopy.getLanguage());
- }
+ }
}
} catch (BadLocationException e) {
// Ignore to return null.
@@ -151,10 +155,10 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
}
private static IASTNode getLinkASTNode(IDocument document, IASTTranslationUnit ast, IRegion region) {
- final int offset= region.getOffset();
- final int length= Math.max(1, region.getLength());
-
- final IASTNodeSelector nodeSelector= ast.getNodeSelector(null);
+ final int offset = region.getOffset();
+ final int length = Math.max(1, region.getLength());
+
+ final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
if (isOverAutoOrDecltype(document, offset)) {
IASTNode node = nodeSelector.findEnclosingNode(offset, length);
IASTTypeId enclosingTypeId = ASTQueries.findAncestorWithType(node, IASTTypeId.class);
@@ -162,8 +166,8 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
return enclosingTypeId;
}
}
-
- IASTName selectedName= nodeSelector.findEnclosingName(offset, length);
+
+ IASTName selectedName = nodeSelector.findEnclosingName(offset, length);
if (selectedName != null) { // found a name
// Prefer include statement over the include name
if (selectedName.getParent() instanceof IASTPreprocessorIncludeStatement) {
@@ -171,13 +175,13 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
} else {
return selectedName;
}
- } else {
+ } else {
final IASTNode implicit = nodeSelector.findEnclosingImplicitName(offset, length);
if (implicit != null) {
return implicit;
} else {
// Search for include statement
- final IASTNode cand= nodeSelector.findEnclosingNode(offset, length);
+ final IASTNode cand = nodeSelector.findEnclosingNode(offset, length);
if (cand instanceof IASTPreprocessorIncludeStatement) {
return cand;
}
@@ -185,7 +189,7 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
}
return null;
}
-
+
private static boolean isOverAutoOrDecltype(IDocument document, int offset) {
try {
IRegion wordRegion = CWordFinder.findWord(document, offset);
@@ -198,13 +202,14 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
}
return false;
}
-
+
/**
* Returns the identifier at the given offset, or {@code null} if the there is no identifier
* at the offset.
*/
- private static IRegion getIdentifier(IDocument document, int offset, ILanguage language) throws BadLocationException {
- IRegion wordRegion= CWordFinder.findWord(document, offset);
+ private static IRegion getIdentifier(IDocument document, int offset, ILanguage language)
+ throws BadLocationException {
+ IRegion wordRegion = CWordFinder.findWord(document, offset);
if (wordRegion != null && wordRegion.getLength() > 0) {
String word = document.get(wordRegion.getOffset(), wordRegion.getLength());
if (!Character.isDigit(word.charAt(0))) {
@@ -217,7 +222,7 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
}
private static boolean isLanguageKeyword(ILanguage lang, String word) {
- ICLanguageKeywords keywords= lang.getAdapter(ICLanguageKeywords.class);
+ ICLanguageKeywords keywords = lang.getAdapter(ICLanguageKeywords.class);
if (keywords != null) {
for (String keyword : keywords.getKeywords()) {
if (keyword.equals(word))
@@ -228,8 +233,8 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
return true;
}
for (String keyword : keywords.getPreprocessorKeywords()) {
- if (keyword.charAt(0) == '#' && keyword.length() == word.length() + 1 &&
- keyword.regionMatches(1, word, 0, word.length())) {
+ if (keyword.charAt(0) == '#' && keyword.length() == word.length() + 1
+ && keyword.regionMatches(1, word, 0, word.length())) {
return true;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementIncludeResolver.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementIncludeResolver.java
index 8fddd051d74..647e1db19c4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementIncludeResolver.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementIncludeResolver.java
@@ -48,7 +48,7 @@ public class CElementIncludeResolver {
public static List<IPath> resolveInclude(IInclude include) throws CoreException {
IResource res = include.getUnderlyingResource();
ArrayList<IPath> filesFound = new ArrayList<IPath>(4);
- String fullFileName= include.getFullFileName();
+ String fullFileName = include.getFullFileName();
if (fullFileName != null) {
IPath fullPath = new Path(fullFileName);
if (fullPath.isAbsolute() && fullPath.toFile().exists()) {
@@ -64,7 +64,7 @@ public class CElementIncludeResolver {
IProject proj = res.getProject();
String includeName = include.getElementName();
// Search in the scannerInfo information
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(proj);
+ IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(proj);
if (provider != null) {
IScannerInfo info = provider.getScannerInformation(res);
// XXXX this should fall back to project by itself
@@ -73,14 +73,14 @@ public class CElementIncludeResolver {
}
if (info != null) {
IExtendedScannerInfo scanInfo = new ExtendedScannerInfo(info);
-
+
boolean isSystemInclude = include.isStandard();
-
+
if (!isSystemInclude) {
// search in current directory
- IPath location= include.getTranslationUnit().getLocation();
+ IPath location = include.getTranslationUnit().getLocation();
if (location != null) {
- String currentDir= location.removeLastSegments(1).toOSString();
+ String currentDir = location.removeLastSegments(1).toOSString();
findFile(new String[] { currentDir }, includeName, filesFound);
}
if (filesFound.isEmpty()) {
@@ -96,7 +96,7 @@ public class CElementIncludeResolver {
findFile(includePaths, includeName, filesFound);
}
}
-
+
if (filesFound.isEmpty()) {
// Fall back and search the project
findFile(proj, new Path(includeName), filesFound);
@@ -106,10 +106,9 @@ public class CElementIncludeResolver {
return filesFound;
}
- private static void findFile(String[] includePaths, String name, ArrayList<IPath> list)
- throws CoreException {
+ private static void findFile(String[] includePaths, String name, ArrayList<IPath> list) throws CoreException {
// in case it is an absolute path
- IPath includeFile= new Path(name);
+ IPath includeFile = new Path(name);
if (includeFile.isAbsolute()) {
includeFile = PathUtil.getCanonicalPathWindows(includeFile);
if (includeFile.toFile().exists()) {
@@ -128,7 +127,7 @@ public class CElementIncludeResolver {
list.add(p);
}
}
- }
+ }
}
}
@@ -139,7 +138,8 @@ public class CElementIncludeResolver {
* @param list
* @throws CoreException
*/
- private static void findFile(IContainer parent, final IPath name, final ArrayList<IPath> list) throws CoreException {
+ private static void findFile(IContainer parent, final IPath name, final ArrayList<IPath> list)
+ throws CoreException {
parent.accept(new IResourceProxyVisitor() {
@Override
@@ -150,9 +150,9 @@ public class CElementIncludeResolver {
int numSegToRemove = rPath.segmentCount() - name.segmentCount();
IPath sPath = rPath.removeFirstSegments(numSegToRemove);
sPath = sPath.setDevice(name.getDevice());
- if (Platform.getOS().equals(Platform.OS_WIN32) ?
- sPath.toOSString().equalsIgnoreCase(name.toOSString()) :
- sPath.equals(name)) {
+ if (Platform.getOS().equals(Platform.OS_WIN32)
+ ? sPath.toOSString().equalsIgnoreCase(name.toOSString())
+ : sPath.equals(name)) {
list.add(rPath);
}
return false;
@@ -167,7 +167,7 @@ public class CElementIncludeResolver {
* Returns the path as is, if it points to a workspace resource. If the path
* does not point to a workspace resource, but there are linked workspace
* resources pointing to it, returns the paths of these resources.
- * Otherwise, returns the path as is.
+ * Otherwise, returns the path as is.
*/
private static IPath[] resolveIncludeLink(IPath path) {
if (!isInProject(path)) {
@@ -175,19 +175,19 @@ public class CElementIncludeResolver {
if (files.length > 0) {
IPath[] paths = new IPath[files.length];
for (int i = 0; i < files.length; i++) {
- paths[i] = files[i].getFullPath();
+ paths[i] = files[i].getFullPath();
}
return paths;
}
}
-
+
return new IPath[] { path };
}
-
+
private static boolean isInProject(IPath path) {
- return getWorkspaceRoot().getFileForLocation(path) != null;
+ return getWorkspaceRoot().getFileForLocation(path) != null;
}
-
+
private static IWorkspaceRoot getWorkspaceRoot() {
return ResourcesPlugin.getWorkspace().getRoot();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java
index 7b60ad02968..4ee9641bde2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java
@@ -26,14 +26,13 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.model.ITranslationUnit;
+public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnotation, ICAnnotation {
-public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnotation, ICAnnotation {
-
- public static final String C_MARKER_TYPE_PREFIX= "org.eclipse.cdt"; //$NON-NLS-1$
- public static final String ERROR_ANNOTATION_TYPE= "org.eclipse.cdt.ui.error"; //$NON-NLS-1$
- public static final String WARNING_ANNOTATION_TYPE= "org.eclipse.cdt.ui.warning"; //$NON-NLS-1$
- public static final String INFO_ANNOTATION_TYPE= "org.eclipse.cdt.ui.info"; //$NON-NLS-1$
- public static final String TASK_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$
+ public static final String C_MARKER_TYPE_PREFIX = "org.eclipse.cdt"; //$NON-NLS-1$
+ public static final String ERROR_ANNOTATION_TYPE = "org.eclipse.cdt.ui.error"; //$NON-NLS-1$
+ public static final String WARNING_ANNOTATION_TYPE = "org.eclipse.cdt.ui.warning"; //$NON-NLS-1$
+ public static final String INFO_ANNOTATION_TYPE = "org.eclipse.cdt.ui.info"; //$NON-NLS-1$
+ public static final String TASK_ANNOTATION_TYPE = "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$
private boolean fIsProblemMarker;
@@ -41,7 +40,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
public CMarkerAnnotation(IMarker marker) {
super(marker);
- fIsProblemMarker = MarkerUtilities.isMarkerType(getMarker(), IMarker.PROBLEM);
+ fIsProblemMarker = MarkerUtilities.isMarkerType(getMarker(), IMarker.PROBLEM);
}
/**
@@ -60,7 +59,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
@Override
public boolean isError() {
if (fIsProblemMarker) {
- int markerSeverity= getMarker().getAttribute(IMarker.SEVERITY, -1);
+ int markerSeverity = getMarker().getAttribute(IMarker.SEVERITY, -1);
return (markerSeverity == IMarker.SEVERITY_ERROR);
}
return false;
@@ -72,12 +71,12 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
@Override
public boolean isWarning() {
if (fIsProblemMarker) {
- int markerSeverity= getMarker().getAttribute(IMarker.SEVERITY, -1);
+ int markerSeverity = getMarker().getAttribute(IMarker.SEVERITY, -1);
return (markerSeverity == IMarker.SEVERITY_WARNING);
}
return false;
}
-
+
/**
* @see IProblemAnnotation#isTemporaryProblem()
*/
@@ -85,13 +84,13 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
public boolean isTemporaryProblem() {
return false;
}
-
+
/**
* @see IProblemAnnotation#getArguments()
*/
@Override
public String[] getArguments() {
- String [] s = {"problem", "here"}; //$NON-NLS-1$ //$NON-NLS-2$
+ String[] s = { "problem", "here" }; //$NON-NLS-1$ //$NON-NLS-2$
//if (fIsProblemMarker)
// return Util.getProblemArgumentsFromMarker(getMarker().getAttribute(CCorePlugin.C_PROBLEMMARKER));
return s;
@@ -107,7 +106,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
return getMarker().getAttribute(ICModelMarker.C_MODEL_PROBLEM_MARKER, -1);
return 0;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.editor.IProblemAnnotation#isProblem()
*/
@@ -115,20 +114,20 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
public boolean isProblem() {
return fIsProblemMarker;
}
-
+
/**
* Overlays this annotation with the given cAnnotation.
- *
+ *
* @param cAnnotation annotation that is overlaid by this annotation
*/
public void setOverlay(ICAnnotation cAnnotation) {
if (fOverlay != null)
fOverlay.removeOverlaid(this);
-
- fOverlay= cAnnotation;
+
+ fOverlay = cAnnotation;
if (!isMarkedDeleted())
markDeleted(fOverlay != null);
-
+
if (fOverlay != null)
fOverlay.addOverlaid(this);
}
@@ -140,7 +139,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
public boolean hasOverlay() {
return fOverlay != null;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.editor.ICAnnotation#getOverlay()
*/
@@ -148,7 +147,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
public ICAnnotation getOverlay() {
return fOverlay;
}
-
+
/*
* @see ICAnnotation#addOverlaid(ICAnnotation)
*/
@@ -164,7 +163,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
public void removeOverlaid(ICAnnotation annotation) {
// not supported
}
-
+
/*
* @see ICAnnotation#getOverlaidIterator()
*/
@@ -179,19 +178,19 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
*/
@Override
public ITranslationUnit getTranslationUnit() {
- ICElement element= CoreModel.getDefault().create(getMarker().getResource());
+ ICElement element = CoreModel.getDefault().create(getMarker().getResource());
if (element instanceof ITranslationUnit) {
- return (ITranslationUnit)element;
+ return (ITranslationUnit) element;
}
return null;
}
@Override
public String getMarkerType() {
- IMarker marker= getMarker();
+ IMarker marker = getMarker();
if (marker == null || !marker.exists())
return null;
-
+
return MarkerUtilities.getMarkerType(getMarker());
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSelectMarkerRulerAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSelectMarkerRulerAction.java
index 22f6d5bf80f..a7b477462ad 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSelectMarkerRulerAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSelectMarkerRulerAction.java
@@ -55,24 +55,24 @@ public class CSelectMarkerRulerAction extends SelectAnnotationRulerAction {
*/
@Override
public void annotationDefaultSelected(VerticalRulerEvent event) {
- Annotation annotation= event.getSelectedAnnotation();
- IAnnotationModel model= getAnnotationModel();
+ Annotation annotation = event.getSelectedAnnotation();
+ IAnnotationModel model = getAnnotationModel();
if (isOverrideIndicator(annotation)) {
- ((OverrideIndicatorManager.OverrideIndicator)annotation).open();
+ ((OverrideIndicatorManager.OverrideIndicator) annotation).open();
return;
}
if (isBreakpoint(annotation))
triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK, event.getEvent());
- Position position= model.getPosition(annotation);
+ Position position = model.getPosition(annotation);
if (position == null)
return;
if (isQuickFixTarget(annotation)) {
- ITextOperationTarget operation= getTextEditor().getAdapter(ITextOperationTarget.class);
- final int opCode= ISourceViewer.QUICK_ASSIST;
+ ITextOperationTarget operation = getTextEditor().getAdapter(ITextOperationTarget.class);
+ final int opCode = ISourceViewer.QUICK_ASSIST;
if (operation != null && operation.canDoOperation(opCode)) {
getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
operation.doOperation(opCode);
@@ -96,12 +96,13 @@ public class CSelectMarkerRulerAction extends SelectAnnotationRulerAction {
/**
* Checks whether the given annotation is a breakpoint annotation.
- *
+ *
* @param annotation the annotation
* @return <code>true</code> if the annotation is a breakpoint annotation
*/
private boolean isBreakpoint(Annotation annotation) {
- return annotation.getType().equals("org.eclipse.cdt.debug.core.breakpoint") || annotation.getType().equals(CExpandHover.NO_BREAKPOINT_ANNOTATION); //$NON-NLS-1$
+ return annotation.getType().equals("org.eclipse.cdt.debug.core.breakpoint") //$NON-NLS-1$
+ || annotation.getType().equals(CExpandHover.NO_BREAKPOINT_ANNOTATION);
}
private boolean isQuickFixTarget(Annotation a) {
@@ -109,20 +110,20 @@ public class CSelectMarkerRulerAction extends SelectAnnotationRulerAction {
}
private void triggerAction(String actionID, Event event) {
- IAction action= getTextEditor().getAction(actionID);
+ IAction action = getTextEditor().getAction(actionID);
if (action != null) {
if (action instanceof IUpdate)
((IUpdate) action).update();
// hack to propagate line change
if (action instanceof ISelectionListener) {
- ((ISelectionListener)action).selectionChanged(null, null);
+ ((ISelectionListener) action).selectionChanged(null, null);
}
if (action.isEnabled()) {
if (event == null) {
action.run();
} else {
- event.type= SWT.MouseDoubleClick;
- event.count= 2;
+ event.type = SWT.MouseDoubleClick;
+ event.count = 2;
action.runWithEvent(event);
}
}
@@ -130,4 +131,3 @@ public class CSelectMarkerRulerAction extends SelectAnnotationRulerAction {
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
index 1c8504bede0..920b0bf9a8e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
@@ -63,19 +63,19 @@ import org.eclipse.cdt.internal.ui.text.CTextTools;
* Source viewer for C/C++ et al.
*/
public class CSourceViewer extends ProjectionViewer implements IPropertyChangeListener {
- /** Show outline operation id. */
- public static final int SHOW_OUTLINE= 101;
- /** Show type hierarchy operation id. */
- public static final int SHOW_HIERARCHY= 102;
- /** Show macro explorer operation id. */
- public static final int SHOW_MACRO_EXPLORER= 103;
-
- /** Presents outline. */
- private IInformationPresenter fOutlinePresenter;
- /** Presents type hierarchy. */
- private IInformationPresenter fHierarchyPresenter;
- /** Presents macro explorer. */
- private IInformationPresenter fMacroExplorationPresenter;
+ /** Show outline operation id. */
+ public static final int SHOW_OUTLINE = 101;
+ /** Show type hierarchy operation id. */
+ public static final int SHOW_HIERARCHY = 102;
+ /** Show macro explorer operation id. */
+ public static final int SHOW_MACRO_EXPLORER = 103;
+
+ /** Presents outline. */
+ private IInformationPresenter fOutlinePresenter;
+ /** Presents type hierarchy. */
+ private IInformationPresenter fHierarchyPresenter;
+ /** Presents macro explorer. */
+ private IInformationPresenter fMacroExplorationPresenter;
/**
* This viewer's foreground color.
@@ -124,74 +124,74 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
* Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=195808
*/
private boolean fWasProjectionMode;
-
+
/**
* The configured indent width.
*/
- private int fIndentWidth= 4;
+ private int fIndentWidth = 4;
/**
* Flag indicating whether to use spaces exclusively for indentation.
*/
private boolean fUseSpaces;
/**
- * Creates new source viewer.
- * @param parent
+ * Creates new source viewer.
+ * @param parent
* @param ruler
* @param overviewRuler
* @param isOverviewRulerShowing
* @param styles
* @param store
*/
- public CSourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler,
- boolean isOverviewRulerShowing, int styles, IPreferenceStore store) {
+ public CSourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler,
+ boolean isOverviewRulerShowing, int styles, IPreferenceStore store) {
super(parent, ruler, overviewRuler, isOverviewRulerShowing, styles);
- setPreferenceStore(store);
+ setPreferenceStore(store);
}
-
+
public IContentAssistant getContentAssistant() {
return fContentAssistant;
}
-
+
/*
* @see ISourceViewer#configure(SourceViewerConfiguration)
*/
@Override
public void configure(SourceViewerConfiguration configuration) {
// Prevent access to colors disposed in unconfigure().
- StyledText textWidget= getTextWidget();
+ StyledText textWidget = getTextWidget();
if (textWidget != null && !textWidget.isDisposed()) {
- Color foregroundColor= textWidget.getForeground();
+ Color foregroundColor = textWidget.getForeground();
if (foregroundColor != null && foregroundColor.isDisposed())
textWidget.setForeground(null);
- Color backgroundColor= textWidget.getBackground();
+ Color backgroundColor = textWidget.getBackground();
if (backgroundColor != null && backgroundColor.isDisposed())
textWidget.setBackground(null);
}
if (configuration instanceof CSourceViewerConfiguration) {
- CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
+ CSourceViewerConfiguration cConfiguration = (CSourceViewerConfiguration) configuration;
cConfiguration.resetScanners();
}
-
+
super.configure(configuration);
if (configuration instanceof CSourceViewerConfiguration) {
- CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
- fOutlinePresenter= cConfiguration.getOutlinePresenter(this);
+ CSourceViewerConfiguration cConfiguration = (CSourceViewerConfiguration) configuration;
+ fOutlinePresenter = cConfiguration.getOutlinePresenter(this);
if (fOutlinePresenter != null)
fOutlinePresenter.install(this);
- fHierarchyPresenter= cConfiguration.getHierarchyPresenter(this);
- if (fHierarchyPresenter != null)
+ fHierarchyPresenter = cConfiguration.getHierarchyPresenter(this);
+ if (fHierarchyPresenter != null)
fHierarchyPresenter.install(this);
- fMacroExplorationPresenter= cConfiguration.getMacroExplorationPresenter(this);
+ fMacroExplorationPresenter = cConfiguration.getMacroExplorationPresenter(this);
if (fMacroExplorationPresenter != null) {
fMacroExplorationPresenter.install(this);
}
- String[] defaultIndentPrefixes= fIndentChars.get(IDocument.DEFAULT_CONTENT_TYPE);
+ String[] defaultIndentPrefixes = fIndentChars.get(IDocument.DEFAULT_CONTENT_TYPE);
if (defaultIndentPrefixes != null && defaultIndentPrefixes.length > 0) {
- final int indentWidth= cConfiguration.getIndentWidth(this);
- final boolean useSpaces= cConfiguration.useSpacesOnly(this);
+ final int indentWidth = cConfiguration.getIndentWidth(this);
+ final boolean useSpaces = cConfiguration.useSpacesOnly(this);
configureIndentation(indentWidth, useSpaces);
}
}
@@ -199,136 +199,145 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
fPreferenceStore.addPropertyChangeListener(this);
initializeViewerColors();
// init flag here in case we start in segmented mode
- fWasProjectionMode= fPreferenceStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
+ fWasProjectionMode = fPreferenceStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
}
- fIsConfigured= true;
+ fIsConfigured = true;
}
protected void initializeViewerColors() {
if (fPreferenceStore != null) {
- StyledText styledText= getTextWidget();
+ StyledText styledText = getTextWidget();
// ----------- foreground color --------------------
- Color color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
+ Color color = fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
+ styledText.getDisplay());
styledText.setForeground(color);
if (fForegroundColor != null)
fForegroundColor.dispose();
- fForegroundColor= color;
+ fForegroundColor = color;
// ---------- background color ----------------------
- color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
+ color = fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null
+ : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
+ styledText.getDisplay());
styledText.setBackground(color);
if (fBackgroundColor != null)
fBackgroundColor.dispose();
- fBackgroundColor= color;
+ fBackgroundColor = color;
// ----------- selection foreground color --------------------
- color= fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR)
- ? null
- : createColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, styledText.getDisplay());
+ color = fPreferenceStore.getBoolean(
+ AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR)
+ ? null
+ : createColor(fPreferenceStore,
+ AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR,
+ styledText.getDisplay());
styledText.setSelectionForeground(color);
if (fSelectionForegroundColor != null)
fSelectionForegroundColor.dispose();
- fSelectionForegroundColor= color;
+ fSelectionForegroundColor = color;
// ---------- selection background color ----------------------
- color= fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR)
- ? null
- : createColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, styledText.getDisplay());
+ color = fPreferenceStore.getBoolean(
+ AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR)
+ ? null
+ : createColor(fPreferenceStore,
+ AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR,
+ styledText.getDisplay());
styledText.setSelectionBackground(color);
if (fSelectionBackgroundColor != null)
fSelectionBackgroundColor.dispose();
- fSelectionBackgroundColor= color;
+ fSelectionBackgroundColor = color;
+ }
+ }
+
+ /**
+ * Creates a color from the information stored in the given preference store.
+ * Returns <code>null</code> if there is no such information available.
+ *
+ * @param store the store to read from
+ * @param key the key used for the lookup in the preference store
+ * @param display the display used create the color
+ * @return the created color according to the specification in the preference store
+ */
+ private Color createColor(IPreferenceStore store, String key, Display display) {
+ RGB rgb = null;
+
+ if (store.contains(key)) {
+ if (store.isDefault(key)) {
+ rgb = PreferenceConverter.getDefaultColor(store, key);
+ } else {
+ rgb = PreferenceConverter.getColor(store, key);
+ }
+
+ if (rgb != null)
+ return new Color(display, rgb);
}
- }
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns <code>null</code> if there is no such information available.
- *
- * @param store the store to read from
- * @param key the key used for the lookup in the preference store
- * @param display the display used create the color
- * @return the created color according to the specification in the preference store
- */
- private Color createColor(IPreferenceStore store, String key, Display display) {
- RGB rgb= null;
-
- if (store.contains(key)) {
- if (store.isDefault(key)) {
- rgb= PreferenceConverter.getDefaultColor(store, key);
- } else {
- rgb= PreferenceConverter.getColor(store, key);
- }
-
- if (rgb != null)
- return new Color(display, rgb);
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#unconfigure()
- */
- @Override
+
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.SourceViewer#unconfigure()
+ */
+ @Override
public void unconfigure() {
- if (fOutlinePresenter != null) {
- fOutlinePresenter.uninstall();
- fOutlinePresenter= null;
- }
- if (fHierarchyPresenter != null) {
- fHierarchyPresenter.uninstall();
- fHierarchyPresenter= null;
- }
- if (fMacroExplorationPresenter != null) {
- fMacroExplorationPresenter.uninstall();
- fMacroExplorationPresenter= null;
- }
+ if (fOutlinePresenter != null) {
+ fOutlinePresenter.uninstall();
+ fOutlinePresenter = null;
+ }
+ if (fHierarchyPresenter != null) {
+ fHierarchyPresenter.uninstall();
+ fHierarchyPresenter = null;
+ }
+ if (fMacroExplorationPresenter != null) {
+ fMacroExplorationPresenter.uninstall();
+ fMacroExplorationPresenter = null;
+ }
if (fForegroundColor != null) {
fForegroundColor.dispose();
- fForegroundColor= null;
+ fForegroundColor = null;
}
if (fBackgroundColor != null) {
fBackgroundColor.dispose();
- fBackgroundColor= null;
+ fBackgroundColor = null;
}
if (fPreferenceStore != null)
fPreferenceStore.removePropertyChangeListener(this);
- super.unconfigure();
+ super.unconfigure();
- fIsConfigured= false;
- }
+ fIsConfigured = false;
+ }
/*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
@Override
public void propertyChange(PropertyChangeEvent event) {
- String property= event.getProperty();
+ String property = event.getProperty();
if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
|| AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
|| AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
|| AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
|| AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR.equals(property)
- || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR.equals(property)
+ || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR
+ .equals(property)
|| AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR.equals(property)
- || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR.equals(property)) {
+ || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR
+ .equals(property)) {
initializeViewerColors();
}
}
@@ -344,7 +353,7 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
if (fIsConfigured && fPreferenceStore != null)
fPreferenceStore.removePropertyChangeListener(this);
- fPreferenceStore= store;
+ fPreferenceStore = store;
if (fIsConfigured && fPreferenceStore != null) {
fPreferenceStore.addPropertyChangeListener(this);
@@ -360,52 +369,52 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
// Use LEFT_TO_RIGHT unless otherwise specified.
if ((styles & SWT.RIGHT_TO_LEFT) == 0 && (styles & SWT.LEFT_TO_RIGHT) == 0)
styles |= SWT.LEFT_TO_RIGHT;
-
+
super.createControl(parent, styles);
}
/*
- * @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int)
+ * @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int)
*/
- @Override
+ @Override
public void doOperation(int operation) {
if (getTextWidget() == null) {
return;
}
switch (operation) {
- case SHOW_OUTLINE:
- fOutlinePresenter.showInformation();
- return;
- case SHOW_HIERARCHY:
- fHierarchyPresenter.showInformation();
- return;
- case SHOW_MACRO_EXPLORER:
- fMacroExplorationPresenter.showInformation();
+ case SHOW_OUTLINE:
+ fOutlinePresenter.showInformation();
+ return;
+ case SHOW_HIERARCHY:
+ fHierarchyPresenter.showInformation();
+ return;
+ case SHOW_MACRO_EXPLORER:
+ fMacroExplorationPresenter.showInformation();
}
super.doOperation(operation);
}
- /*
- * @see org.eclipse.jface.text.source.projection.ProjectionViewer#canDoOperation(int)
- */
- @Override
+ /*
+ * @see org.eclipse.jface.text.source.projection.ProjectionViewer#canDoOperation(int)
+ */
+ @Override
public boolean canDoOperation(int operation) {
switch (operation) {
- case SHOW_OUTLINE:
- return fOutlinePresenter != null;
- case SHOW_HIERARCHY:
- return fHierarchyPresenter != null;
- case SHOW_MACRO_EXPLORER:
- return fMacroExplorationPresenter != null;
+ case SHOW_OUTLINE:
+ return fOutlinePresenter != null;
+ case SHOW_HIERARCHY:
+ return fHierarchyPresenter != null;
+ case SHOW_MACRO_EXPLORER:
+ return fMacroExplorationPresenter != null;
}
- return super.canDoOperation(operation);
- }
+ return super.canDoOperation(operation);
+ }
/**
* Prepend given listener to the list of presentation listeners
- *
+ *
* @param listener The listener to be added.
- *
+ *
* @see TextViewer#addTextPresentationListener(ITextPresentationListener)
* @since 4.0
*/
@@ -413,10 +422,10 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
Assert.isNotNull(listener);
// using list from base class
- List<ITextPresentationListener> textPresentationListeners= fTextPresentationListeners;
-
- if (textPresentationListeners == null)
- fTextPresentationListeners= textPresentationListeners= new ArrayList<ITextPresentationListener>();
+ List<ITextPresentationListener> textPresentationListeners = fTextPresentationListeners;
+
+ if (textPresentationListeners == null)
+ fTextPresentationListeners = textPresentationListeners = new ArrayList<ITextPresentationListener>();
textPresentationListeners.remove(listener);
textPresentationListeners.add(0, listener);
@@ -429,15 +438,15 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
* This is a performance optimization to reduce the computation of
* the text presentation triggered by <code>setVisibleDocument(IDocument)</code>.
* </p>
- *
+ *
* @see #setVisibleDocument(IDocument)
* @since 4.0
*/
void prepareDelayedProjection() {
Assert.isTrue(!fIsSetVisibleDocumentDelayed);
- fIsSetVisibleDocumentDelayed= true;
+ fIsSetVisibleDocumentDelayed = true;
}
-
+
/**
* {@inheritDoc}
* <p>
@@ -449,15 +458,15 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
@Override
protected void setVisibleDocument(IDocument document) {
if (fIsSetVisibleDocumentDelayed) {
- fIsSetVisibleDocumentDelayed= false;
- IDocument previous= getVisibleDocument();
+ fIsSetVisibleDocumentDelayed = false;
+ IDocument previous = getVisibleDocument();
enableProjection(); // will set the visible document if anything is folded
- IDocument current= getVisibleDocument();
+ IDocument current = getVisibleDocument();
// if the visible document was not replaced, continue as usual
if (current != null && current != previous)
return;
}
-
+
super.setVisibleDocument(document);
}
@@ -471,11 +480,11 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
*/
@Override
protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
- IRegion region= modelRange2WidgetRange(new Region(range.start, range.length));
+ IRegion region = modelRange2WidgetRange(new Region(range.start, range.length));
if (region != null) {
// don't clone the style range, but simply reuse it.
- range.start= region.getOffset();
- range.length= region.getLength();
+ range.start = region.getOffset();
+ range.length = region.getLength();
return range;
}
return null;
@@ -488,11 +497,11 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
public void setVisibleRegion(int start, int length) {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=195808
if (!fWasProjectionMode && isProjectionMode()) {
- fWasProjectionMode= true;
+ fWasProjectionMode = true;
}
super.setVisibleRegion(start, length);
}
-
+
/*
* @see org.eclipse.jface.text.source.projection.ProjectionViewer#resetVisibleRegion()
*/
@@ -501,20 +510,20 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
super.resetVisibleRegion();
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=195808
if (fWasProjectionMode) {
- fWasProjectionMode= false;
+ fWasProjectionMode = false;
enableProjection();
}
}
/**
* Configure the indentation mode for this viewer.
- *
+ *
* @param indentWidth the indentation width
* @param useSpaces if <code>true</code>, only spaces are used for indentation
*/
public void configureIndentation(int indentWidth, boolean useSpaces) {
- fIndentWidth= indentWidth;
- fUseSpaces= useSpaces;
+ fIndentWidth = indentWidth;
+ fUseSpaces = useSpaces;
}
/*
@@ -532,7 +541,7 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
/**
* Increase/decrease indentation of current selection.
- *
+ *
* @param increase if <code>true</code>, indent is increased by one unit
* @param shiftWidth width in spaces of one indent unit
* @param useSpaces if <code>true</code>, only spaces are used for indentation
@@ -541,33 +550,33 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
if (fUndoManager != null) {
fUndoManager.beginCompoundChange();
}
- IDocument d= getDocument();
- DocumentRewriteSession rewriteSession= null;
+ IDocument d = getDocument();
+ DocumentRewriteSession rewriteSession = null;
try {
if (d instanceof IDocumentExtension4) {
- IDocumentExtension4 extension= (IDocumentExtension4) d;
- rewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
+ IDocumentExtension4 extension = (IDocumentExtension4) d;
+ rewriteSession = extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
}
- Point selection= getSelectedRange();
+ Point selection = getSelectedRange();
// perform the adjustment
- int tabWidth= getTextWidget().getTabs();
- int startLine= d.getLineOfOffset(selection.x);
- int endLine= selection.y == 0 ? startLine : d.getLineOfOffset(selection.x + selection.y - 1);
- for (int line= startLine; line <= endLine; ++line) {
- IRegion lineRegion= d.getLineInformation(line);
- String indent= IndentUtil.getCurrentIndent(d, line, false);
- int indentWidth= IndentUtil.computeVisualLength(indent, tabWidth);
- int newIndentWidth= Math.max(0, indentWidth + (increase ? shiftWidth : -shiftWidth));
- String newIndent= IndentUtil.changePrefix(indent.trim(), newIndentWidth, tabWidth, useSpaces);
- int commonLen= getCommonPrefixLength(indent, newIndent);
+ int tabWidth = getTextWidget().getTabs();
+ int startLine = d.getLineOfOffset(selection.x);
+ int endLine = selection.y == 0 ? startLine : d.getLineOfOffset(selection.x + selection.y - 1);
+ for (int line = startLine; line <= endLine; ++line) {
+ IRegion lineRegion = d.getLineInformation(line);
+ String indent = IndentUtil.getCurrentIndent(d, line, false);
+ int indentWidth = IndentUtil.computeVisualLength(indent, tabWidth);
+ int newIndentWidth = Math.max(0, indentWidth + (increase ? shiftWidth : -shiftWidth));
+ String newIndent = IndentUtil.changePrefix(indent.trim(), newIndentWidth, tabWidth, useSpaces);
+ int commonLen = getCommonPrefixLength(indent, newIndent);
if (commonLen < Math.max(indent.length(), newIndent.length())) {
if (commonLen > 0) {
- indent= indent.substring(commonLen);
- newIndent= newIndent.substring(commonLen);
+ indent = indent.substring(commonLen);
+ newIndent = newIndent.substring(commonLen);
}
- final int offset= lineRegion.getOffset() + commonLen;
+ final int offset = lineRegion.getOffset() + commonLen;
if (!increase && newIndent.length() > indent.length() && indent.length() > 0) {
d.replace(offset, indent.length(), ""); //$NON-NLS-1$
d.replace(offset, 0, newIndent);
@@ -580,7 +589,7 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
// ignored
} finally {
if (rewriteSession != null) {
- ((IDocumentExtension4)d).stopRewriteSession(rewriteSession);
+ ((IDocumentExtension4) d).stopRewriteSession(rewriteSession);
}
if (fUndoManager != null) {
fUndoManager.endCompoundChange();
@@ -588,17 +597,17 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
}
}
- /**
- * Compute the length of the common prefix of two strings.
- *
+ /**
+ * Compute the length of the common prefix of two strings.
+ *
* @param s1
* @param s2
* @return the length of the common prefix
*/
private static int getCommonPrefixLength(String s1, String s2) {
- final int l1= s1.length();
- final int l2= s2.length();
- int i= 0;
+ final int l1 = s1.length();
+ final int l2 = s2.length();
+ int i = 0;
while (i < l1 && i < l2 && s1.charAt(i) == s2.charAt(i)) {
++i;
}
@@ -606,40 +615,39 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
}
/*
- * work around for memory leak in TextViewer$WidgetCommand
- */
- @Override
+ * work around for memory leak in TextViewer$WidgetCommand
+ */
+ @Override
protected void updateTextListeners(WidgetCommand cmd) {
- super.updateTextListeners(cmd);
- cmd.preservedText= null;
- cmd.event= null;
- cmd.text= null;
- }
+ super.updateTextListeners(cmd);
+ cmd.preservedText = null;
+ cmd.event = null;
+ cmd.text = null;
+ }
/**
* Sets the viewer's background color to the given control's background color.
* The background color is <em>only</em> set if it's visibly distinct from the
* default Java source text color.
- *
+ *
* @param control the control with the default background color
*/
public void adaptBackgroundColor(Control control) {
// Workaround for dark editor background color, see https://bugs.eclipse.org/330680
- Color defaultColor= control.getBackground();
- float[] defaultBgHSB= defaultColor.getRGB().getHSB();
-
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
- IColorManager manager= textTools.getColorManager();
- Color cDefaultColor= manager.getColor(ICColorConstants.C_DEFAULT);
- RGB cDefaultRGB= cDefaultColor != null ?
- cDefaultColor.getRGB() : new RGB(255, 255, 255);
- float[] cDefaultHSB= cDefaultRGB.getHSB();
-
+ Color defaultColor = control.getBackground();
+ float[] defaultBgHSB = defaultColor.getRGB().getHSB();
+
+ CTextTools textTools = CUIPlugin.getDefault().getTextTools();
+ IColorManager manager = textTools.getColorManager();
+ Color cDefaultColor = manager.getColor(ICColorConstants.C_DEFAULT);
+ RGB cDefaultRGB = cDefaultColor != null ? cDefaultColor.getRGB() : new RGB(255, 255, 255);
+ float[] cDefaultHSB = cDefaultRGB.getHSB();
+
if (Math.abs(defaultBgHSB[2] - cDefaultHSB[2]) >= 0.5f) {
getTextWidget().setBackground(defaultColor);
if (fBackgroundColor != null) {
fBackgroundColor.dispose();
- fBackgroundColor= null;
+ fBackgroundColor = null;
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSupport.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSupport.java
index ec6abb8d0d5..c64fb4a4dbb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSupport.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSupport.java
@@ -32,9 +32,9 @@ import org.eclipse.cdt.internal.ui.LineBackgroundPainter;
* <ul>
* <li>inactive code painter</li>
* </ul>
- *
+ *
* @author anton.leherbauer@windriver.com
- *
+ *
* @since 4.0
*/
public class CSourceViewerDecorationSupport extends SourceViewerDecorationSupport {
@@ -65,18 +65,14 @@ public class CSourceViewerDecorationSupport extends SourceViewerDecorationSuppor
/**
* Inherited constructor.
- *
+ *
* @param sourceViewer
* @param overviewRuler
* @param annotationAccess
* @param sharedTextColors
*/
- CSourceViewerDecorationSupport(
- CEditor editor,
- ISourceViewer sourceViewer,
- IOverviewRuler overviewRuler,
- IAnnotationAccess annotationAccess,
- ISharedTextColors sharedTextColors) {
+ CSourceViewerDecorationSupport(CEditor editor, ISourceViewer sourceViewer, IOverviewRuler overviewRuler,
+ IAnnotationAccess annotationAccess, ISharedTextColors sharedTextColors) {
super(sourceViewer, overviewRuler, annotationAccess, sharedTextColors);
fEditor = editor;
// we have to save our own references, because super class members are all private
@@ -189,7 +185,7 @@ public class CSourceViewerDecorationSupport extends SourceViewerDecorationSuppor
/**
* Returns the shared color for the given key.
- *
+ *
* @param key the color key string
* @return the shared color for the given key
*/
@@ -203,7 +199,7 @@ public class CSourceViewerDecorationSupport extends SourceViewerDecorationSuppor
/**
* Returns the shared color for the given RGB.
- *
+ *
* @param rgb the rgb
* @return the shared color for the given rgb
*/
@@ -245,7 +241,7 @@ public class CSourceViewerDecorationSupport extends SourceViewerDecorationSuppor
fLineBackgroundPainter.setBackgroundColor(INACTIVE_CODE_KEY, getColor(fInactiveCodeColorKey));
fLineBackgroundPainter.setCursorLineColor(getColor(fCLPColorKey));
fLineBackgroundPainter.enableCursorLine(isCLPActive());
- ((ITextViewerExtension2)fViewer).addPainter(fLineBackgroundPainter);
+ ((ITextViewerExtension2) fViewer).addPainter(fLineBackgroundPainter);
}
}
}
@@ -257,10 +253,10 @@ public class CSourceViewerDecorationSupport extends SourceViewerDecorationSuppor
if (fLineBackgroundPainter != null) {
if (fInactiveCodeHighlighting != null) {
fInactiveCodeHighlighting.uninstall();
- fInactiveCodeHighlighting= null;
+ fInactiveCodeHighlighting = null;
}
if (fViewer instanceof ITextViewerExtension2) {
- ((ITextViewerExtension2)fViewer).removePainter(fLineBackgroundPainter);
+ ((ITextViewerExtension2) fViewer).removePainter(fLineBackgroundPainter);
}
fLineBackgroundPainter.deactivate(true);
fLineBackgroundPainter.dispose();
@@ -270,13 +266,13 @@ public class CSourceViewerDecorationSupport extends SourceViewerDecorationSuppor
/**
* Show inactive code positions.
- *
+ *
* @param refresh trigger a refresh of the positions
*/
private void showInactiveCodePositions(boolean refresh) {
installLineBackgroundPainter();
if (fLineBackgroundPainter != null) {
- fInactiveCodeHighlighting= new InactiveCodeHighlighting(INACTIVE_CODE_KEY);
+ fInactiveCodeHighlighting = new InactiveCodeHighlighting(INACTIVE_CODE_KEY);
fInactiveCodeHighlighting.install(fEditor, fLineBackgroundPainter);
if (refresh) {
fInactiveCodeHighlighting.refresh();
@@ -291,7 +287,7 @@ public class CSourceViewerDecorationSupport extends SourceViewerDecorationSuppor
if (fLineBackgroundPainter != null) {
if (fInactiveCodeHighlighting != null) {
fInactiveCodeHighlighting.uninstall();
- fInactiveCodeHighlighting= null;
+ fInactiveCodeHighlighting = null;
}
if (!isCLPActive()) {
uninstallLineBackgroundPainter();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java
index b4139783836..b4ee96a42d1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java
@@ -27,9 +27,9 @@ import org.eclipse.ui.editors.text.StorageDocumentProvider;
* CStorageDocumentProvider
*/
public class CStorageDocumentProvider extends StorageDocumentProvider {
-
+
/**
- *
+ *
*/
public CStorageDocumentProvider() {
super();
@@ -49,7 +49,7 @@ public class CStorageDocumentProvider extends StorageDocumentProvider {
@Override
protected void setupDocument(Object element, IDocument document) {
if (document != null) {
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
tools.setupCDocument(document);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTemplatesPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTemplatesPage.java
index 5f96abe22e1..0f0911f7641 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTemplatesPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTemplatesPage.java
@@ -64,23 +64,24 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
*/
public class CTemplatesPage extends AbstractTemplatesPage {
- private static final String PREFERENCE_PAGE_ID= "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
- private static final TemplateStore TEMPLATE_STORE= CUIPlugin.getDefault().getTemplateStore();
- private static final IPreferenceStore PREFERENCE_STORE= CUIPlugin.getDefault().getPreferenceStore();
- private static final ContextTypeRegistry TEMPLATE_CONTEXT_REGISTRY= CUIPlugin.getDefault().getTemplateContextRegistry();
+ private static final String PREFERENCE_PAGE_ID = "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
+ private static final TemplateStore TEMPLATE_STORE = CUIPlugin.getDefault().getTemplateStore();
+ private static final IPreferenceStore PREFERENCE_STORE = CUIPlugin.getDefault().getPreferenceStore();
+ private static final ContextTypeRegistry TEMPLATE_CONTEXT_REGISTRY = CUIPlugin.getDefault()
+ .getTemplateContextRegistry();
private TemplateVariableProcessor fTemplateProcessor;
private CEditor fCEditor;
/**
* Create a new AbstractTemplatesPage for the CEditor
- *
+ *
* @param cEditor the C editor
*/
public CTemplatesPage(CEditor cEditor) {
super(cEditor, cEditor.getViewer());
- fCEditor= cEditor;
- fTemplateProcessor= new TemplateVariableProcessor();
+ fCEditor = cEditor;
+ fTemplateProcessor = new TemplateVariableProcessor();
}
/*
@@ -91,8 +92,8 @@ public class CTemplatesPage extends AbstractTemplatesPage {
if (!fCEditor.validateEditorInputState())
return;
- ISourceViewer contextViewer= fCEditor.getViewer();
- ITextSelection textSelection= (ITextSelection) contextViewer.getSelectionProvider().getSelection();
+ ISourceViewer contextViewer = fCEditor.getViewer();
+ ITextSelection textSelection = (ITextSelection) contextViewer.getSelectionProvider().getSelection();
if (!isValidTemplate(document, template, textSelection.getOffset(), textSelection.getLength()))
return;
beginCompoundChange(contextViewer);
@@ -105,15 +106,16 @@ public class CTemplatesPage extends AbstractTemplatesPage {
*/
String savedText;
try {
- savedText= document.get(textSelection.getOffset(), textSelection.getLength());
+ savedText = document.get(textSelection.getOffset(), textSelection.getLength());
if (savedText.length() == 0) {
- String prefix= getIdentifierPart(document, template, textSelection.getOffset(), textSelection.getLength());
+ String prefix = getIdentifierPart(document, template, textSelection.getOffset(),
+ textSelection.getLength());
if (prefix.length() > 0 && !template.getName().startsWith(prefix.toString())) {
return;
}
if (prefix.length() > 0) {
contextViewer.setSelectedRange(textSelection.getOffset() - prefix.length(), prefix.length());
- textSelection= (ITextSelection) contextViewer.getSelectionProvider().getSelection();
+ textSelection = (ITextSelection) contextViewer.getSelectionProvider().getSelection();
}
}
document.replace(textSelection.getOffset(), textSelection.getLength(), template.getName().substring(0, 1));
@@ -121,13 +123,13 @@ public class CTemplatesPage extends AbstractTemplatesPage {
endCompoundChange(contextViewer);
return;
}
- Position position= new Position(textSelection.getOffset() + 1, 0);
- Region region= new Region(textSelection.getOffset() + 1, 0);
+ Position position = new Position(textSelection.getOffset() + 1, 0);
+ Region region = new Region(textSelection.getOffset() + 1, 0);
contextViewer.getSelectionProvider().setSelection(new TextSelection(textSelection.getOffset(), 1));
- ITranslationUnit compilationUnit= (ITranslationUnit) EditorUtility.getEditorInputCElement(fCEditor);
+ ITranslationUnit compilationUnit = (ITranslationUnit) EditorUtility.getEditorInputCElement(fCEditor);
- TemplateContextType type= getContextTypeRegistry().getContextType(template.getContextTypeId());
- DocumentTemplateContext context= ((CContextType) type).createContext(document, position, compilationUnit);
+ TemplateContextType type = getContextTypeRegistry().getContextType(template.getContextTypeId());
+ DocumentTemplateContext context = ((CContextType) type).createContext(document, position, compilationUnit);
context.setVariable("selection", savedText); //$NON-NLS-1$
if (context.getKey().length() == 0) {
try {
@@ -137,7 +139,7 @@ public class CTemplatesPage extends AbstractTemplatesPage {
return;
}
}
- TemplateProposal proposal= new TemplateProposal(template, context, region, null);
+ TemplateProposal proposal = new TemplateProposal(template, context, region, null);
fCEditor.getSite().getPage().activate(fCEditor);
proposal.apply(fCEditor.getViewer(), ' ', 0, region.getOffset());
endCompoundChange(contextViewer);
@@ -172,10 +174,10 @@ public class CTemplatesPage extends AbstractTemplatesPage {
*/
@Override
protected boolean isValidTemplate(IDocument document, Template template, int offset, int length) {
- String[] contextIds= getContextTypeIds(document, offset);
- for (int i= 0; i < contextIds.length; i++) {
+ String[] contextIds = getContextTypeIds(document, offset);
+ for (int i = 0; i < contextIds.length; i++) {
if (contextIds[i].equals(template.getContextTypeId())) {
- DocumentTemplateContext context= getContext(document, template, offset, length);
+ DocumentTemplateContext context = getContext(document, template, offset, length);
return context.canEvaluate(template) || isTemplateAllowed(context, template);
}
}
@@ -187,22 +189,23 @@ public class CTemplatesPage extends AbstractTemplatesPage {
*/
@Override
protected SourceViewer createPatternViewer(Composite parent) {
- IDocument document= new Document();
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
+ IDocument document = new Document();
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
tools.setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- CSourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);
- SimpleCSourceViewerConfiguration configuration= new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false);
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ CSourceViewer viewer = new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);
+ SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration(tools.getColorManager(),
+ store, null, ICPartitions.C_PARTITIONING, false);
viewer.configure(configuration);
viewer.setEditable(false);
viewer.setDocument(document);
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+ Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new CSourcePreviewerUpdater(viewer, configuration, store);
- Control control= viewer.getControl();
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+ Control control = viewer.getControl();
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
control.setLayoutData(data);
viewer.setEditable(false);
@@ -222,7 +225,8 @@ public class CTemplatesPage extends AbstractTemplatesPage {
*/
@Override
protected Template editTemplate(Template template, boolean edit, boolean isNameModifiable) {
- EditTemplateDialog dialog= new EditTemplateDialog(getSite().getShell(), template, edit, isNameModifiable, false, getContextTypeRegistry());
+ EditTemplateDialog dialog = new EditTemplateDialog(getSite().getShell(), template, edit, isNameModifiable,
+ false, getContextTypeRegistry());
if (dialog.open() == Window.OK)
return dialog.getTemplate();
return null;
@@ -235,17 +239,17 @@ public class CTemplatesPage extends AbstractTemplatesPage {
protected void updatePatternViewer(Template template) {
if (template == null) {
getPatternViewer().getDocument().set(""); //$NON-NLS-1$
- return ;
+ return;
}
- String contextId= template.getContextTypeId();
- TemplateContextType type= getContextTypeRegistry().getContextType(contextId);
+ String contextId = template.getContextTypeId();
+ TemplateContextType type = getContextTypeRegistry().getContextType(contextId);
fTemplateProcessor.setContextType(type);
- IDocument doc= getPatternViewer().getDocument();
+ IDocument doc = getPatternViewer().getDocument();
- String start= ""; //$NON-NLS-1$
+ String start = ""; //$NON-NLS-1$
doc.set(start + template.getPattern());
- int startLen= start.length();
+ int startLen = start.length();
getPatternViewer().setDocument(doc, startLen, doc.getLength() - startLen);
}
@@ -259,7 +263,7 @@ public class CTemplatesPage extends AbstractTemplatesPage {
/**
* Undomanager - end compound change
- *
+ *
* @param viewer the viewer
*/
private void endCompoundChange(ISourceViewer viewer) {
@@ -269,7 +273,7 @@ public class CTemplatesPage extends AbstractTemplatesPage {
/**
* Undomanager - begin a compound change
- *
+ *
* @param viewer the viewer
*/
private void beginCompoundChange(ISourceViewer viewer) {
@@ -280,7 +284,7 @@ public class CTemplatesPage extends AbstractTemplatesPage {
/**
* Check whether the template is allowed even though the context can't evaluate it. This is
* needed because the Dropping of a template is more lenient than ctl-space invoked code assist.
- *
+ *
* @param context the template context
* @param template the template
* @return true if the template is allowed
@@ -288,7 +292,8 @@ public class CTemplatesPage extends AbstractTemplatesPage {
private boolean isTemplateAllowed(DocumentTemplateContext context, Template template) {
int offset;
try {
- return ((offset= context.getCompletionOffset()) > 0 && !isTemplateNamePart(context.getDocument().getChar(offset - 1)));
+ return ((offset = context.getCompletionOffset()) > 0
+ && !isTemplateNamePart(context.getDocument().getChar(offset - 1)));
} catch (BadLocationException e) {
}
return false;
@@ -296,7 +301,7 @@ public class CTemplatesPage extends AbstractTemplatesPage {
/**
* Checks whether the character is a valid character in C template names
- *
+ *
* @param ch the character
* @return <code>true</code> if the character is part of a template name
*/
@@ -306,7 +311,7 @@ public class CTemplatesPage extends AbstractTemplatesPage {
/**
* Get context
- *
+ *
* @param document the document
* @param template the template
* @param offset the offset
@@ -314,8 +319,9 @@ public class CTemplatesPage extends AbstractTemplatesPage {
* @return the context
*/
private DocumentTemplateContext getContext(IDocument document, Template template, final int offset, int length) {
- DocumentTemplateContext context= new CContext(getContextTypeRegistry().getContextType(template.getContextTypeId()), document, new Position(offset, length), (ITranslationUnit) EditorUtility.getEditorInputCElement(
- fCEditor));
+ DocumentTemplateContext context = new CContext(
+ getContextTypeRegistry().getContextType(template.getContextTypeId()), document,
+ new Position(offset, length), (ITranslationUnit) EditorUtility.getEditorInputCElement(fCEditor));
return context;
}
@@ -324,7 +330,7 @@ public class CTemplatesPage extends AbstractTemplatesPage {
* <p>
* FIXME: should trigger code assist to get the context.
* </p>
- *
+ *
* @param document the document
* @param offset the offset
* @return an array of valid context id
@@ -336,7 +342,7 @@ public class CTemplatesPage extends AbstractTemplatesPage {
/**
* Get the C identifier terminated at the given offset
- *
+ *
* @param document the document
* @param template the template
* @param offset the offset
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.java
index 0092adc4c58..4146f22dad0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.java
@@ -18,7 +18,7 @@ import java.util.ResourceBundle;
import com.ibm.icu.text.MessageFormat;
-public class ConstructedCEditorMessages {
+public class ConstructedCEditorMessages {
private static final String RESOURCE_BUNDLE = "org.eclipse.cdt.internal.ui.editor.ConstructedCEditorMessages"; //$NON-NLS-1$
private static ResourceBundle fgResourceBundle;
@@ -36,11 +36,11 @@ public class ConstructedCEditorMessages {
public static ResourceBundle getResourceBundle() {
return fgResourceBundle;
}
-
- public static String getString( String key ) {
+
+ public static String getString(String key) {
try {
- return fgResourceBundle.getString( key );
- } catch(MissingResourceException e) {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
} catch (NullPointerException e) {
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
@@ -49,17 +49,15 @@ public class ConstructedCEditorMessages {
/**
* Gets a string from the resource bundle and formats it with arguments
- */
+ */
public static String getFormattedString(String key, Object[] args) {
return MessageFormat.format(getString(key), args);
}
-
+
/**
* Gets a string from the resource bundle and formats it with arguments
- */
+ */
public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg } );
- }
+ return MessageFormat.format(getString(key), new Object[] { arg });
+ }
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ContributedSemanticHighlighting.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ContributedSemanticHighlighting.java
index 50c41c3f4cd..b25c8b50dbb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ContributedSemanticHighlighting.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ContributedSemanticHighlighting.java
@@ -137,8 +137,8 @@ public class ContributedSemanticHighlighting extends SemanticHighlightingWithOwn
try {
return StringConverter.asRGB(val);
} catch (DataFormatException e) {
- CUIPlugin
- .log("Error in " + Attr_DefaultTextColor + " attribute of " + extensionId + ' ' + val + " is not a RGB value", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ CUIPlugin.log("Error in " + Attr_DefaultTextColor + " attribute of " + extensionId + ' ' + val //$NON-NLS-1$//$NON-NLS-2$
+ + " is not a RGB value", e); //$NON-NLS-1$
}
// black by default
@@ -223,7 +223,7 @@ public class ContributedSemanticHighlighting extends SemanticHighlightingWithOwn
evalContext.addVariable(Var_projectNature, Arrays.asList(natures));
ILanguage language = tu.getLanguage();
- if( language != null )
+ if (language != null)
evalContext.addVariable(Var_languageId, language.getId());
return enablementExpression.evaluate(evalContext) == EvaluationResult.TRUE;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.java
index 2ff0f397422..97c431309d9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.java
@@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory;
*/
public class CustomBufferFactory implements IBufferFactory {
/**
- *
+ *
*/
public CustomBufferFactory() {
super();
@@ -46,17 +46,17 @@ public class CustomBufferFactory implements IBufferFactory {
public IBuffer createBuffer(IOpenable owner) {
if (owner instanceof IWorkingCopy) {
- IWorkingCopy unit= (IWorkingCopy) owner;
- ITranslationUnit original= unit.getOriginalElement();
- IResource resource= original.getResource();
+ IWorkingCopy unit = (IWorkingCopy) owner;
+ ITranslationUnit original = unit.getOriginalElement();
+ IResource resource = original.getResource();
if (resource instanceof IFile) {
- IFile fFile = (IFile)resource;
- DocumentAdapter adapter= new DocumentAdapter(owner, fFile);
+ IFile fFile = (IFile) resource;
+ DocumentAdapter adapter = new DocumentAdapter(owner, fFile);
return adapter;
}
// URI
- URI locationUri= original.getLocationURI();
+ URI locationUri = original.getLocationURI();
if (locationUri != null) {
try {
return new DocumentAdapter(owner, locationUri);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.java
index 664e67fac2c..4fb0b72b30c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.java
@@ -67,7 +67,7 @@ public class DefaultBinaryFileEditor extends AbstractTextEditor implements IReso
/**
* Create an editor input from the given binary.
- *
+ *
* @param binary
*/
public BinaryFileEditorInput(IBinary binary) {
@@ -89,8 +89,7 @@ public class DefaultBinaryFileEditor extends AbstractTextEditor implements IReso
public ImageDescriptor getImageDescriptor() {
IFile file = (IFile) fBinary.getResource();
IContentType contentType = IDE.getContentType(file);
- return PlatformUI.getWorkbench().getEditorRegistry()
- .getImageDescriptor(file.getName(), contentType);
+ return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(file.getName(), contentType);
}
/*
@@ -123,11 +122,9 @@ public class DefaultBinaryFileEditor extends AbstractTextEditor implements IReso
@Override
public IStorage getStorage() throws CoreException {
if (fStorage == null) {
- IBinaryParser.IBinaryObject object = fBinary
- .getAdapter(IBinaryParser.IBinaryObject.class);
+ IBinaryParser.IBinaryObject object = fBinary.getAdapter(IBinaryParser.IBinaryObject.class);
if (object != null) {
- IGnuToolFactory factory = object.getBinaryParser().getAdapter(
- IGnuToolFactory.class);
+ IGnuToolFactory factory = object.getBinaryParser().getAdapter(IGnuToolFactory.class);
if (factory != null) {
Objdump objdump = factory.getObjdump(object.getPath());
if (objdump != null) {
@@ -141,8 +138,8 @@ public class DefaultBinaryFileEditor extends AbstractTextEditor implements IReso
// add a message for user
String text = CEditorMessages.DefaultBinaryFileEditor_TruncateMessage;
String message = "\n\n--- " + text + " ---\n" + objdump.toString(); //$NON-NLS-1$ //$NON-NLS-2$
- System.arraycopy(message.getBytes(), 0, output,
- limitBytes - message.length(), message.length());
+ System.arraycopy(message.getBytes(), 0, output, limitBytes - message.length(),
+ message.length());
}
fStorage = new FileStorage(new ByteArrayInputStream(output), object.getPath());
} catch (IOException exc) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java
index da88bfbe810..33e0f218da3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
-
import java.net.URI;
import java.util.ArrayList;
import java.util.HashSet;
@@ -53,13 +52,12 @@ import org.eclipse.cdt.core.model.IBufferChangedListener;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.ui.CUIPlugin;
-
/**
* Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
* same algorithm as the text widget to determine the buffer's line delimiter.
* All text inserted into the buffer is converted to this line delimiter.
* This class is <code>public</code> for test purposes only.
- *
+ *
* This class is similar to the JDT DocumentAdapter class.
*/
public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
@@ -68,106 +66,115 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
* Internal implementation of a NULL instanceof IBuffer.
*/
static private class NullBuffer implements IBuffer {
-
+
@Override
- public void addBufferChangedListener(IBufferChangedListener listener) {}
-
+ public void addBufferChangedListener(IBufferChangedListener listener) {
+ }
+
@Override
- public void append(char[] text) {}
-
+ public void append(char[] text) {
+ }
+
@Override
- public void append(String text) {}
-
+ public void append(String text) {
+ }
+
@Override
- public void close() {}
-
+ public void close() {
+ }
+
@Override
public char getChar(int position) {
return 0;
}
-
+
@Override
public char[] getCharacters() {
return null;
}
-
+
@Override
public String getContents() {
return null;
}
-
+
@Override
public int getLength() {
return 0;
}
-
+
@Override
public IOpenable getOwner() {
return null;
}
-
+
@Override
public String getText(int offset, int length) {
return null;
}
-
+
@Override
public IResource getUnderlyingResource() {
return null;
}
-
+
@Override
public boolean hasUnsavedChanges() {
return false;
}
-
+
@Override
public boolean isClosed() {
return false;
}
-
+
@Override
public boolean isReadOnly() {
return true;
}
-
+
@Override
- public void removeBufferChangedListener(IBufferChangedListener listener) {}
-
+ public void removeBufferChangedListener(IBufferChangedListener listener) {
+ }
+
@Override
- public void replace(int position, int length, char[] text) {}
-
+ public void replace(int position, int length, char[] text) {
+ }
+
@Override
- public void replace(int position, int length, String text) {}
-
+ public void replace(int position, int length, String text) {
+ }
+
@Override
- public void save(IProgressMonitor progress, boolean force) throws CModelException {}
-
+ public void save(IProgressMonitor progress, boolean force) throws CModelException {
+ }
+
@Override
- public void setContents(char[] contents) {}
-
+ public void setContents(char[] contents) {
+ }
+
@Override
- public void setContents(String contents) {}
+ public void setContents(String contents) {
+ }
}
-
-
+
/** NULL implementing <code>IBuffer</code> */
- public final static IBuffer NULL= new NullBuffer();
+ public final static IBuffer NULL = new NullBuffer();
/**
* Executes a document set content call in the ui thread.
*/
protected class DocumentSetCommand implements Runnable {
-
+
private String fContents;
-
+
@Override
public void run() {
fDocument.set(fContents);
}
-
+
public void set(String contents) {
- fContents= contents;
+ fContents = contents;
Display.getDefault().syncExec(this);
}
}
@@ -176,11 +183,11 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
* Executes a document replace call in the ui thread.
*/
protected class DocumentReplaceCommand implements Runnable {
-
+
private int fOffset;
private int fLength;
private String fText;
-
+
@Override
public void run() {
try {
@@ -189,28 +196,28 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
// ignore
}
}
-
+
public void replace(int offset, int length, String text) {
- fOffset= offset;
- fLength= length;
- fText= text;
+ fOffset = offset;
+ fLength = length;
+ fText = text;
Display.getDefault().syncExec(this);
}
}
- private static final boolean DEBUG_LINE_DELIMITERS= true;
+ private static final boolean DEBUG_LINE_DELIMITERS = true;
private IOpenable fOwner;
private IFile fFile;
private ITextFileBuffer fTextFileBuffer;
IDocument fDocument;
- private DocumentSetCommand fSetCmd= new DocumentSetCommand();
- private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
+ private DocumentSetCommand fSetCmd = new DocumentSetCommand();
+ private DocumentReplaceCommand fReplaceCmd = new DocumentReplaceCommand();
private Set<String> fLegalLineDelimiters;
- private List<IBufferChangedListener> fBufferListeners= new ArrayList<IBufferChangedListener>(3);
+ private List<IBufferChangedListener> fBufferListeners = new ArrayList<IBufferChangedListener>(3);
private IStatus fStatus;
final private IPath fLocation;
@@ -218,52 +225,51 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
private IFileStore fFileStore;
-
public DocumentAdapter(IOpenable owner, IFile file) {
- fOwner= owner;
- fFile= file;
- fLocation= file.getFullPath();
- fLocationKind= LocationKind.IFILE;
+ fOwner = owner;
+ fFile = file;
+ fLocation = file.getFullPath();
+ fLocationKind = LocationKind.IFILE;
initialize();
}
public DocumentAdapter(IOpenable owner, IPath location) {
- fOwner= owner;
- fLocation= location;
- fLocationKind= LocationKind.NORMALIZE;
-
+ fOwner = owner;
+ fLocation = location;
+ fLocationKind = LocationKind.NORMALIZE;
+
initialize();
}
public DocumentAdapter(IOpenable owner, URI locationUri) throws CoreException {
- fOwner= owner;
- fFileStore= EFS.getStore(locationUri);
+ fOwner = owner;
+ fFileStore = EFS.getStore(locationUri);
- fLocation= null;
- fLocationKind= null;
+ fLocation = null;
+ fLocationKind = null;
initialize();
}
private void initialize() {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
try {
if (fLocation != null) {
manager.connect(fLocation, fLocationKind, new NullProgressMonitor());
- fTextFileBuffer= manager.getTextFileBuffer(fLocation, fLocationKind);
+ fTextFileBuffer = manager.getTextFileBuffer(fLocation, fLocationKind);
} else {
manager.connectFileStore(fFileStore, new NullProgressMonitor());
- fTextFileBuffer= manager.getFileStoreTextFileBuffer(fFileStore);
+ fTextFileBuffer = manager.getFileStoreTextFileBuffer(fFileStore);
}
- fDocument= fTextFileBuffer.getDocument();
+ fDocument = fTextFileBuffer.getDocument();
} catch (CoreException x) {
- fStatus= x.getStatus();
+ fStatus = x.getStatus();
if (fLocation != null) {
- fDocument= manager.createEmptyDocument(fLocation, fLocationKind);
+ fDocument = manager.createEmptyDocument(fLocation, fLocationKind);
}
if (fDocument instanceof ISynchronizable) {
- ((ISynchronizable)fDocument).setLockObject(new Object());
+ ((ISynchronizable) fDocument).setLockObject(new Object());
}
}
fDocument.addPrenotifiedDocumentListener(this);
@@ -279,10 +285,10 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
return fTextFileBuffer.getStatus();
return null;
}
-
+
/**
* Returns the adapted document.
- *
+ *
* @return the adapted document
*/
public IDocument getDocument() {
@@ -298,7 +304,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
if (!fBufferListeners.contains(listener))
fBufferListeners.add(listener);
}
-
+
/*
* @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
*/
@@ -307,7 +313,6 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
Assert.isNotNull(listener);
fBufferListeners.remove(listener);
}
-
/**
* @see org.eclipse.cdt.core.model.IBuffer#append(char[])
@@ -328,22 +333,21 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
fReplaceCmd.replace(fDocument.getLength(), 0, text);
}
-
/**
* @see org.eclipse.cdt.core.model.IBuffer#close()
*/
@Override
public void close() {
-
+
if (isClosed())
return;
-
- IDocument d= fDocument;
- fDocument= null;
+
+ IDocument d = fDocument;
+ fDocument = null;
d.removePrenotifiedDocumentListener(this);
-
+
if (fTextFileBuffer != null) {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
try {
if (fLocation != null) {
manager.disconnect(fLocation, fLocationKind, new NullProgressMonitor());
@@ -353,9 +357,9 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
} catch (CoreException x) {
// ignore
}
- fTextFileBuffer= null;
+ fTextFileBuffer = null;
}
-
+
fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
fBufferListeners.clear();
}
@@ -377,7 +381,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
*/
@Override
public char[] getCharacters() {
- String content= getContents();
+ String content = getContents();
return content == null ? null : content.toCharArray();
}
@@ -446,7 +450,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
*/
@Override
public boolean isReadOnly() {
- IResource resource= getUnderlyingResource();
+ IResource resource = getUnderlyingResource();
if (resource != null) {
ResourceAttributes attributes = resource.getResourceAttributes();
if (attributes != null) {
@@ -501,23 +505,23 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
*/
@Override
public void setContents(String contents) {
- int oldLength= fDocument.getLength();
-
+ int oldLength = fDocument.getLength();
+
if (contents == null) {
-
+
if (oldLength != 0)
fSetCmd.set(""); //$NON-NLS-1$
-
+
} else {
// set only if different
if (DEBUG_LINE_DELIMITERS) {
validateLineDelimiters(contents);
}
-
- int newLength= contents.length();
+
+ int newLength = contents.length();
if (oldLength != newLength || !contents.equals(fDocument.get()))
fSetCmd.set(contents);
-
+
}
}
@@ -525,11 +529,11 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
if (fLegalLineDelimiters == null) {
// collect all line delimiters in the document
- HashSet<String> existingDelimiters= new HashSet<String>();
+ HashSet<String> existingDelimiters = new HashSet<String>();
- for (int i= fDocument.getNumberOfLines() - 1; i >= 0; i-- ) {
+ for (int i = fDocument.getNumberOfLines() - 1; i >= 0; i--) {
try {
- String curr= fDocument.getLineDelimiter(i);
+ String curr = fDocument.getLineDelimiter(i);
if (curr != null) {
existingDelimiters.add(curr);
}
@@ -540,23 +544,23 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
if (existingDelimiters.isEmpty()) {
return; // first insertion of a line delimiter: no test
}
- fLegalLineDelimiters= existingDelimiters;
-
+ fLegalLineDelimiters = existingDelimiters;
+
}
-
- DefaultLineTracker tracker= new DefaultLineTracker();
+
+ DefaultLineTracker tracker = new DefaultLineTracker();
tracker.set(contents);
-
- int lines= tracker.getNumberOfLines();
+
+ int lines = tracker.getNumberOfLines();
if (lines <= 1)
return;
-
- for (int i= 0; i < lines; i++) {
+
+ for (int i = 0; i < lines; i++) {
try {
- String curr= tracker.getLineDelimiter(i);
+ String curr = tracker.getLineDelimiter(i);
if (curr != null && !fLegalLineDelimiters.contains(curr)) {
- StringBuilder buf= new StringBuilder("New line delimiter added to new code: "); //$NON-NLS-1$
- for (int k= 0; k < curr.length(); k++) {
+ StringBuilder buf = new StringBuilder("New line delimiter added to new code: "); //$NON-NLS-1$
+ for (int k = 0; k < curr.length(); k++) {
buf.append(String.valueOf((int) curr.charAt(k)));
}
CUIPlugin.log(new Exception(buf.toString()));
@@ -582,10 +586,10 @@ public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
public void documentChanged(DocumentEvent event) {
fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText()));
}
-
+
private void fireBufferChanged(BufferChangedEvent event) {
if (fBufferListeners != null && fBufferListeners.size() > 0) {
- Iterator<IBufferChangedListener> e= new ArrayList<IBufferChangedListener>(fBufferListeners).iterator();
+ Iterator<IBufferChangedListener> e = new ArrayList<IBufferChangedListener>(fBufferListeners).iterator();
while (e.hasNext())
e.next().bufferChanged(event);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.java
index 571f51080fa..ee2d0c9ead5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.java
@@ -57,10 +57,11 @@ class EclipsePreferencesAdapter implements IPreferenceStore {
}
/** Listeners on on this adapter */
- private ListenerList<IPropertyChangeListener> fListeners= new ListenerList<IPropertyChangeListener>(ListenerList.IDENTITY);
+ private ListenerList<IPropertyChangeListener> fListeners = new ListenerList<IPropertyChangeListener>(
+ ListenerList.IDENTITY);
/** Listener on the node */
- private IEclipsePreferences.IPreferenceChangeListener fListener= new PreferenceChangeListener();
+ private IEclipsePreferences.IPreferenceChangeListener fListener = new PreferenceChangeListener();
/** wrapped node */
private final IScopeContext fContext;
@@ -73,8 +74,8 @@ class EclipsePreferencesAdapter implements IPreferenceStore {
* @param qualifier the qualifier
*/
public EclipsePreferencesAdapter(IScopeContext context, String qualifier) {
- fContext= context;
- fQualifier= qualifier;
+ fContext = context;
+ fQualifier = qualifier;
}
private IEclipsePreferences getNode() {
@@ -115,9 +116,9 @@ class EclipsePreferencesAdapter implements IPreferenceStore {
*/
@Override
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
- PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue);
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++)
+ PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
+ Object[] listeners = fListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++)
((IPropertyChangeListener) listeners[i]).propertyChange(event);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronizer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronizer.java
index 55ef69ea165..fe116ee667d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronizer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronizer.java
@@ -35,8 +35,8 @@ public class EditorHighlightingSynchronizer implements ILinkedModeListener {
*/
public EditorHighlightingSynchronizer(CEditor editor) {
Assert.isLegal(editor != null);
- fEditor= editor;
- fWasOccurrencesOn= fEditor.isMarkingOccurrences();
+ fEditor = editor;
+ fWasOccurrencesOn = fEditor.isMarkingOccurrences();
if (fWasOccurrencesOn && !isEditorDisposed())
fEditor.uninstallOccurrencesFinder();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java
index f8ab08aa5dc..cf183d66384 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java
@@ -28,7 +28,7 @@ public class ExternalSearchAnnotationModel extends ResourceMarkerAnnotationModel
private final IPath fLocation;
private final int fDepth;
private final String fLocationAttribute;
-
+
public ExternalSearchAnnotationModel(IResource markerResource, IPath location) {
this(markerResource, location, IResource.DEPTH_ZERO, ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
}
@@ -37,12 +37,11 @@ public class ExternalSearchAnnotationModel extends ResourceMarkerAnnotationModel
this(markerResource, location, depth, ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
}
- ExternalSearchAnnotationModel(IResource markerResource, IPath location, int depth,
- String locationAttribute) {
+ ExternalSearchAnnotationModel(IResource markerResource, IPath location, int depth, String locationAttribute) {
super(markerResource);
- fLocation= location;
- fDepth= depth;
- fLocationAttribute= locationAttribute;
+ fLocation = location;
+ fDepth = depth;
+ fLocationAttribute = locationAttribute;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java
index 7c96e12f80f..2fe2161e665 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java
@@ -36,7 +36,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
-
+
public ExternalSearchDocumentProvider() {
super(new CStorageDocumentProvider());
}
@@ -46,13 +46,13 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
*/
@Override
protected FileInfo createFileInfo(Object element) throws CoreException {
- final FileInfo info= super.createFileInfo(element);
+ final FileInfo info = super.createFileInfo(element);
if (info != null) {
IAnnotationModel originalModel = info.fModel;
IAnnotationModel externalSearchModel = createAnnotationModel(element);
if (externalSearchModel != null) {
- info.fModel= externalSearchModel;
- IAnnotationModel fileBufferModel= info.fTextFileBuffer.getAnnotationModel();
+ info.fModel = externalSearchModel;
+ IAnnotationModel fileBufferModel = info.fTextFileBuffer.getAnnotationModel();
if (fileBufferModel != null) {
((AnnotationModel) externalSearchModel).addAnnotationModel("fileBufferModel", fileBufferModel); //$NON-NLS-1$
}
@@ -67,13 +67,12 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
return info;
}
-
protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
if (element instanceof ExternalEditorInput) {
- return createExternalSearchAnnotationModel((ExternalEditorInput)element);
+ return createExternalSearchAnnotationModel((ExternalEditorInput) element);
}
if (element instanceof IStorageEditorInput) {
- IStorage storage= ((IStorageEditorInput)element).getStorage();
+ IStorage storage = ((IStorageEditorInput) element).getStorage();
if (storage.getFullPath() != null) {
return createExternalSearchAnnotationModel(storage.getFullPath(), null);
}
@@ -85,7 +84,7 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
}
}
if (element instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) element;
+ IAdaptable adaptable = (IAdaptable) element;
ILocationProvider provider = adaptable.getAdapter(ILocationProvider.class);
if (provider != null) {
IPath location = provider.getPath(element);
@@ -107,7 +106,7 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
/**
* Create an annotation model for the given {@link ExternalEditorInput}.
- *
+ *
* @param externalInput
* @return a new annotation model for the external editor input
*/
@@ -118,21 +117,21 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
}
return null;
}
-
+
/**
* Create an annotation model for the given file and associated resource marker.
- *
+ *
* @param location the local file system location
* @param markerResource the resource to retrieve markers from, may be <code>null</code>
* @return a new annotation model for the file
*/
private IAnnotationModel createExternalSearchAnnotationModel(IPath location, IResource markerResource) {
- AnnotationModel model= null;
- if (markerResource != null){
+ AnnotationModel model = null;
+ if (markerResource != null) {
model = new ExternalSearchAnnotationModel(markerResource, location);
} else {
// no marker resource available - search workspace root and all project resources (depth one)
- markerResource= CUIPlugin.getWorkspace().getRoot();
+ markerResource = CUIPlugin.getWorkspace().getRoot();
model = new ExternalSearchAnnotationModel(markerResource, location, IResource.DEPTH_ONE);
}
return model;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java
index d58588bb8f2..095eee0cda5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java
@@ -19,34 +19,32 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
-
-
public class GotoAnnotationAction extends TextEditorAction {
-
+
private boolean fForward;
-
+
public GotoAnnotationAction(String prefix, boolean forward) {
super(ConstructedCEditorMessages.getResourceBundle(), prefix, null);
- fForward= forward;
+ fForward = forward;
if (forward)
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.GOTO_NEXT_ERROR_ACTION);
else
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.GOTO_PREVIOUS_ERROR_ACTION);
}
-
+
@Override
public void run() {
- CEditor e= (CEditor) getTextEditor();
+ CEditor e = (CEditor) getTextEditor();
e.gotoAnnotation(fForward);
}
-
+
@Override
public void setEditor(ITextEditor editor) {
- if (editor instanceof CEditor)
+ if (editor instanceof CEditor)
super.setEditor(editor);
update();
}
-
+
@Override
public void update() {
setEnabled(getTextEditor() instanceof CEditor);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.java
index fbf710a6216..e9f21045f5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.java
@@ -21,21 +21,20 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-
public class GotoMatchingBracketAction extends Action {
- public final static String GOTO_MATCHING_BRACKET= "GotoMatchingBracket"; //$NON-NLS-1$
-
+ public final static String GOTO_MATCHING_BRACKET = "GotoMatchingBracket"; //$NON-NLS-1$
+
private final CEditor fEditor;
-
+
public GotoMatchingBracketAction(CEditor editor) {
- super(CEditorMessages.GotoMatchingBracket_label);
+ super(CEditorMessages.GotoMatchingBracket_label);
Assert.isNotNull(editor);
- fEditor= editor;
+ fEditor = editor;
setEnabled(true);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.GOTO_MATCHING_BRACKET_ACTION);
}
-
+
@Override
public void run() {
fEditor.gotoMatchingBracket();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICAnnotation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICAnnotation.java
index 4c8dd84f233..4df518803a7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICAnnotation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICAnnotation.java
@@ -23,94 +23,94 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
*
* Interface of annotations representing markers
* and problems.
- *
+ *
* @see org.eclipse.core.resources.IMarker
* @see org.eclipse.cdt.core.parser.IProblem
*/
public interface ICAnnotation {
-
+
/**
* @see org.eclipse.jface.text.source.Annotation#getType()
*/
String getType();
-
+
/**
* @see org.eclipse.jface.text.source.Annotation#isPersistent()
*/
boolean isPersistent();
-
+
/**
* @see org.eclipse.jface.text.source.Annotation#isMarkedDeleted()
*/
boolean isMarkedDeleted();
-
+
/**
- * @see org.eclipse.jface.text.source.Annotation#getText()
+ * @see org.eclipse.jface.text.source.Annotation#getText()
*/
String getText();
-
+
/**
* Returns whether this annotation is overlaid.
- *
+ *
* @return <code>true</code> if overlaid
*/
boolean hasOverlay();
-
+
/**
* Returns the overlay of this annotation.
- *
+ *
* @return the annotation's overlay
*/
ICAnnotation getOverlay();
-
+
/**
* Returns an iterator for iterating over the
- * annotation which are overlaid by this annotation.
- *
+ * annotation which are overlaid by this annotation.
+ *
* @return an iterator over the overlaid annotations
*/
Iterator<ICAnnotation> getOverlaidIterator();
-
+
/**
* Adds the given annotation to the list of
* annotations which are overlaid by this annotations.
- *
+ *
* @param annotation the problem annotation
*/
void addOverlaid(ICAnnotation annotation);
-
+
/**
* Removes the given annotation from the list of
* annotations which are overlaid by this annotation.
- *
+ *
* @param annotation the problem annotation
*/
void removeOverlaid(ICAnnotation annotation);
-
+
/**
* Tells whether this annotation is a problem
* annotation.
- *
+ *
* @return <code>true</code> if it is a problem annotation
*/
boolean isProblem();
-
+
/**
* Returns the compilation unit corresponding to the document on which the annotation is set
* or <code>null</code> if no corresponding co0mpilationunit exists.
*/
ITranslationUnit getTranslationUnit();
-
+
String[] getArguments();
-
+
int getId();
/**
* Returns the marker type associated to this problem or <code>null<code> if no marker type
* can be evaluated. See also {@link org.eclipse.cdt.ui.text.IProblemLocation#getMarkerType()}.
- *
+ *
* @return the type of the marker which would be associated to the problem or
- * <code>null<code> if no marker type can be evaluated.
+ * <code>null<code> if no marker type can be evaluated.
*/
String getMarkerType();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
index ca81b512e4f..7a46b6df4ec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
@@ -34,28 +34,28 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.comment"</code>).
* @since 4.0.0
*/
- public static final String TOGGLE_COMMENT= "org.eclipse.cdt.ui.edit.text.c.toggle.comment"; //$NON-NLS-1$
+ public static final String TOGGLE_COMMENT = "org.eclipse.cdt.ui.edit.text.c.toggle.comment"; //$NON-NLS-1$
/**
* Action definition ID of the source -> add block comment action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.add.block.comment"</code>).
* @since 3.0
*/
- public static final String ADD_BLOCK_COMMENT= "org.eclipse.cdt.ui.edit.text.c.add.block.comment"; //$NON-NLS-1$
+ public static final String ADD_BLOCK_COMMENT = "org.eclipse.cdt.ui.edit.text.c.add.block.comment"; //$NON-NLS-1$
/**
* Action definition ID of the source -> remove block comment action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.remove.block.comment"</code>).
* @since 3.0
*/
- public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.cdt.ui.edit.text.c.remove.block.comment"; //$NON-NLS-1$
+ public static final String REMOVE_BLOCK_COMMENT = "org.eclipse.cdt.ui.edit.text.c.remove.block.comment"; //$NON-NLS-1$
/**
* Action definition ID of the source -> join lines action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.join.lines"</code>).
* @since 3.0.2
*/
- public static final String JOIN_LINES= "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$
+ public static final String JOIN_LINES = "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$
/**
* Action definition ID of the source -> indent action
@@ -79,43 +79,43 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* Action definition ID of the source -> add include action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.add.include"</code>).
*/
- public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.edit.text.c.add.include"; //$NON-NLS-1$
+ public static final String ADD_INCLUDE = "org.eclipse.cdt.ui.edit.text.c.add.include"; //$NON-NLS-1$
/**
* Action definition ID of the source -> organize includes action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.organize.includes"</code>).
*/
- public static final String ORGANIZE_INCLUDES= "org.eclipse.cdt.ui.edit.text.c.organize.includes"; //$NON-NLS-1$
+ public static final String ORGANIZE_INCLUDES = "org.eclipse.cdt.ui.edit.text.c.organize.includes"; //$NON-NLS-1$
/**
* Action definition ID of the open declaration action
* (value <code>"org.eclipse.cdt.ui.edit.opendecl"</code>).
*/
- public static final String OPEN_DECL= "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$
+ public static final String OPEN_DECL = "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$
/**
* Action definition ID of the show in C/C++ Projects View action
* (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>).
*/
- public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
+ public static final String OPEN_CVIEW = "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
/**
* Action definition ID of the refactor -> rename element action
* (value <code>"org.eclipse.cdt.ui.edit.text.rename.element"</code>).
*/
- public static final String RENAME_ELEMENT= "org.eclipse.cdt.ui.edit.text.rename.element"; //$NON-NLS-1$
+ public static final String RENAME_ELEMENT = "org.eclipse.cdt.ui.edit.text.rename.element"; //$NON-NLS-1$
/**
* Action definition ID of the refactor -> extract constant action
* (value <code>"org.eclipse.cdt.ui.refactor.extract.constant"</code>).
*/
- public static final String EXTRACT_CONSTANT= "org.eclipse.cdt.ui.refactor.extract.constant"; //$NON-NLS-1$
+ public static final String EXTRACT_CONSTANT = "org.eclipse.cdt.ui.refactor.extract.constant"; //$NON-NLS-1$
/**
* Action definition ID of the refactor -> extract local variable action
* (value <code>"org.eclipse.cdt.ui.refactor.extract.local.variable"</code>).
*/
- public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.cdt.ui.refactor.extract.local.variable"; //$NON-NLS-1$
+ public static final String EXTRACT_LOCAL_VARIABLE = "org.eclipse.cdt.ui.refactor.extract.local.variable"; //$NON-NLS-1$
/**
* Action definition ID of the refactor -> extract function action (value
@@ -133,103 +133,103 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* Action definition ID of the refactor -> hide method action
* (value <code>"org.eclipse.cdt.ui.refactor.hide.method"</code>).
*/
- public static final String HIDE_METHOD= "org.eclipse.cdt.ui.refactor.hide.method"; //$NON-NLS-1$
+ public static final String HIDE_METHOD = "org.eclipse.cdt.ui.refactor.hide.method"; //$NON-NLS-1$
/**
* Action definition ID of the refactor -> implement method action
* (value <code>"org.eclipse.cdt.ui.refactor.implement.method"</code>).
*/
- public static final String IMPLEMENT_METHOD= "org.eclipse.cdt.ui.refactor.implement.method"; //$NON-NLS-1$
+ public static final String IMPLEMENT_METHOD = "org.eclipse.cdt.ui.refactor.implement.method"; //$NON-NLS-1$
/**
* Action definition ID of the refactor -> generate getters and setters
* (value <code>"org.eclipse.cdt.ui.refactor.getters.and.setters"</code>).
*/
- public static final String GETTERS_AND_SETTERS= "org.eclipse.cdt.ui.refactor.getters.and.setters"; //$NON-NLS-1$
+ public static final String GETTERS_AND_SETTERS = "org.eclipse.cdt.ui.refactor.getters.and.setters"; //$NON-NLS-1$
/**
* Action definition ID of the refactor -> undo action
* (value <code>"org.eclipse.cdt.ui.edit.text.undo.action"</code>).
*/
- public static final String UNDO_ACTION= "org.eclipse.cdt.ui.edit.text.undo.action"; //$NON-NLS-1$
+ public static final String UNDO_ACTION = "org.eclipse.cdt.ui.edit.text.undo.action"; //$NON-NLS-1$
/**
* Action definition ID of the refactor -> redo action
* (value <code>"org.eclipse.cdt.ui.edit.text.redo.action"</code>).
*/
- public static final String REDO_ACTION= "org.eclipse.cdt.ui.edit.text.redo.action"; //$NON-NLS-1$
+ public static final String REDO_ACTION = "org.eclipse.cdt.ui.edit.text.redo.action"; //$NON-NLS-1$
/**
* Action definition ID of the find references in workspace action
* (value <code>"org.eclipse.cdt.ui.search.findrefs"</code>).
*/
- public static final String FIND_REFS= "org.eclipse.cdt.ui.search.findrefs"; //$NON-NLS-1$
+ public static final String FIND_REFS = "org.eclipse.cdt.ui.search.findrefs"; //$NON-NLS-1$
/**
* Action definition ID of the find references in project action
* (value <code>"org.eclipse.cdt.ui.search.findrefs.project"</code>).
*/
- public static final String FIND_REFS_PROJECT= "org.eclipse.cdt.ui.search.findrefs.project"; //$NON-NLS-1$
+ public static final String FIND_REFS_PROJECT = "org.eclipse.cdt.ui.search.findrefs.project"; //$NON-NLS-1$
/**
* Action definition ID of the find references in working set action
* (value <code>"org.eclipse.cdt.ui.search.findrefs.workingset"</code>).
*/
- public static final String FIND_REFS_WORKING_SET= "org.eclipse.cdt.ui.search.findrefs.workingset"; //$NON-NLS-1$
+ public static final String FIND_REFS_WORKING_SET = "org.eclipse.cdt.ui.search.findrefs.workingset"; //$NON-NLS-1$
/**
* Action definition ID of the find declarations in workspace action
* (value <code>"org.eclipse.cdt.ui.search.finddecl"</code>).
*/
- public static final String FIND_DECL= "org.eclipse.cdt.ui.search.finddecl"; //$NON-NLS-1$
+ public static final String FIND_DECL = "org.eclipse.cdt.ui.search.finddecl"; //$NON-NLS-1$
/**
* Action definition ID of the find declarations in project action
* (value <code>"org.eclipse.cdt.ui.search.finddecl.project"</code>).
*/
- public static final String FIND_DECL_PROJECT= "org.eclipse.cdt.ui.search.finddecl.project"; //$NON-NLS-1$
+ public static final String FIND_DECL_PROJECT = "org.eclipse.cdt.ui.search.finddecl.project"; //$NON-NLS-1$
/**
* Action definition ID of the find declarations in working set action
* (value <code>"org.eclipse.cdt.ui.search.finddecl.workingset"</code>).
*/
- public static final String FIND_DECL_WORKING_SET= "org.eclipse.cdt.ui.search.finddecl.workingset"; //$NON-NLS-1$
+ public static final String FIND_DECL_WORKING_SET = "org.eclipse.cdt.ui.search.finddecl.workingset"; //$NON-NLS-1$
/**
* Action definition ID of the navigate -> open type hierarchy action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.open.type.hierarchy"</code>).
*/
- public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.cdt.ui.edit.open.type.hierarchy"; //$NON-NLS-1$
+ public static final String OPEN_TYPE_HIERARCHY = "org.eclipse.cdt.ui.edit.open.type.hierarchy"; //$NON-NLS-1$
/**
* Action definition ID of the navigate -> open type hierarchy action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.open.quick.type.hierarchy"</code>).
*/
- public static final String OPEN_QUICK_TYPE_HIERARCHY= "org.eclipse.cdt.ui.edit.open.quick.type.hierarchy"; //$NON-NLS-1$
+ public static final String OPEN_QUICK_TYPE_HIERARCHY = "org.eclipse.cdt.ui.edit.open.quick.type.hierarchy"; //$NON-NLS-1$
/**
* Action definition ID of the navigate -> open action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.open.editor"</code>).
*/
- public static final String OPEN_EDITOR= "org.eclipse.cdt.ui.edit.text.c.open.editor"; //$NON-NLS-1$
+ public static final String OPEN_EDITOR = "org.eclipse.cdt.ui.edit.text.c.open.editor"; //$NON-NLS-1$
/**
* Action definition ID of the open quick outline.
* (value <code>"org.eclipse.cdt.ui.edit.open.outline"</code>).
*/
- public static final String OPEN_OUTLINE= "org.eclipse.cdt.ui.edit.open.outline"; //$NON-NLS-1$
+ public static final String OPEN_OUTLINE = "org.eclipse.cdt.ui.edit.open.outline"; //$NON-NLS-1$
/**
* Action definition ID for opening the call hierarchy.
* (value <code>"org.eclipse.cdt.ui.edit.open.call.hierarchy"</code>).
*/
- public static final String OPEN_CALL_HIERARCHY= "org.eclipse.cdt.ui.edit.open.call.hierarchy"; //$NON-NLS-1$
+ public static final String OPEN_CALL_HIERARCHY = "org.eclipse.cdt.ui.edit.open.call.hierarchy"; //$NON-NLS-1$
/**
* Action definition ID for opening the include browser.
* (value <code>"org.eclipse.cdt.ui.edit.open.include.browser"</code>).
*/
- public static final String OPEN_INCLUDE_BROWSER= "org.eclipse.cdt.ui.edit.open.include.browser"; //$NON-NLS-1$
+ public static final String OPEN_INCLUDE_BROWSER = "org.eclipse.cdt.ui.edit.open.include.browser"; //$NON-NLS-1$
/**
* Action definition ID for go to next c member.
@@ -249,7 +249,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
*
* @since 3.0
*/
- public static final String GOTO_MATCHING_BRACKET= "org.eclipse.cdt.ui.edit.text.c.goto.matching.bracket"; //$NON-NLS-1$
+ public static final String GOTO_MATCHING_BRACKET = "org.eclipse.cdt.ui.edit.text.c.goto.matching.bracket"; //$NON-NLS-1$
/**
* Action definition ID for goto next bookmark action
@@ -276,7 +276,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value: <code>"org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"</code>).
* @since 5.0
*/
- public static final String TOGGLE_MARK_OCCURRENCES= "org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"; //$NON-NLS-1$
+ public static final String TOGGLE_MARK_OCCURRENCES = "org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"; //$NON-NLS-1$
/**
* Action definition ID of the open macro explorer quick view action
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPostSaveListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPostSaveListener.java
index 37b0bf912d0..2beae0e4bb1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPostSaveListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IPostSaveListener.java
@@ -20,17 +20,17 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
/**
* Listener that is informed when a translation unit is saved.
* <p>
- * The difference between this interface and JDT's {@code IPostSaveListener} is that CDT does not
+ * The difference between this interface and JDT's {@code IPostSaveListener} is that CDT does not
* allow post-save listeners to make changes to the saved file.
* </p>
- *
+ *
* @since 5.4
*/
public interface IPostSaveListener {
/**
* Informs this post-save listener that the given translation unit has been saved. The listener
* should <strong>not</strong> modify the given translation unit.
- *
+ *
* @param translationUnit the translation unit which was saved
* @param monitor the progress monitor for reporting progress
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java
index 26d6072b732..b5198d506f2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java
@@ -18,20 +18,18 @@ package org.eclipse.cdt.internal.ui.editor;
* Interface of annotations representing problems.
*/
public interface IProblemAnnotation {
-
+
String getMessage();
-
+
int getId();
-
+
String[] getArguments();
-
+
boolean isTemporaryProblem();
-
+
boolean isWarning();
-
+
boolean isError();
-
+
boolean isProblem();
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java
index 3159d1a244e..518f6b38ff5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java
@@ -54,7 +54,7 @@ import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
/**
* Paints code lines disabled by preprocessor directives (#ifdef etc.)
* with a configurable background color (default light gray).
- *
+ *
* @see LineBackgroundPainter
* @since 4.0
*/
@@ -68,12 +68,12 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
public HighlightPosition(int offset, int length, String type) {
super(offset, length, type);
}
+
public HighlightPosition(IRegion region, String type) {
super(region.getOffset(), region.getLength(), type);
}
}
-
/** The line background painter */
private LineBackgroundPainter fLineBackgroundPainter;
/** The key for inactive code positions in the background painter */
@@ -87,7 +87,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
/** The editor this is installed on */
private CEditor fEditor;
/** The list of currently highlighted positions */
- private List<Position> fInactiveCodePositions= Collections.emptyList();
+ private List<Position> fInactiveCodePositions = Collections.emptyList();
private IDocument fDocument;
/**
@@ -95,7 +95,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
* @param highlightKey
*/
public InactiveCodeHighlighting(String highlightKey) {
- fHighlightKey= highlightKey;
+ fHighlightKey = highlightKey;
}
/**
@@ -104,19 +104,20 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
private void scheduleJob() {
synchronized (fJobLock) {
if (fUpdateJob == null) {
- fUpdateJob = new Job(CEditorMessages.InactiveCodeHighlighting_job) {
+ fUpdateJob = new Job(CEditorMessages.InactiveCodeHighlighting_job) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
IStatus result = Status.OK_STATUS;
if (fTranslationUnit != null) {
- final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
- result= astProvider.runOnAST(fTranslationUnit, ASTProvider.WAIT_IF_OPEN, monitor, new ASTCache.ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
- reconciled(ast, true, monitor);
- return Status.OK_STATUS;
- }
- });
+ final ASTProvider astProvider = CUIPlugin.getDefault().getASTProvider();
+ result = astProvider.runOnAST(fTranslationUnit, ASTProvider.WAIT_IF_OPEN, monitor,
+ new ASTCache.ASTRunnable() {
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+ reconciled(ast, true, monitor);
+ return Status.OK_STATUS;
+ }
+ });
}
if (monitor.isCanceled()) {
result = Status.CANCEL_STATUS;
@@ -134,22 +135,22 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
/**
* Install this highlighting on the given editor and line background painter.
- *
+ *
* @param editor
* @param lineBackgroundPainter
*/
public void install(CEditor editor, LineBackgroundPainter lineBackgroundPainter) {
assert fEditor == null;
assert editor != null && lineBackgroundPainter != null;
- fEditor= editor;
- fLineBackgroundPainter= lineBackgroundPainter;
- ICElement cElement= fEditor.getInputCElement();
+ fEditor = editor;
+ fLineBackgroundPainter = lineBackgroundPainter;
+ ICElement cElement = fEditor.getInputCElement();
if (cElement instanceof ITranslationUnit) {
- fTranslationUnit = (ITranslationUnit)cElement;
+ fTranslationUnit = (ITranslationUnit) cElement;
} else {
fTranslationUnit = null;
}
- fDocument= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+ fDocument = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
fEditor.getViewer().addTextInputListener(this);
fEditor.addReconcileListener(this);
}
@@ -165,17 +166,17 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
}
if (fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
- fInactiveCodePositions= Collections.emptyList();
- fLineBackgroundPainter= null;
+ fInactiveCodePositions = Collections.emptyList();
+ fLineBackgroundPainter = null;
}
if (fEditor != null) {
fEditor.removeReconcileListener(this);
if (fEditor.getViewer() != null) {
fEditor.getViewer().removeTextInputListener(this);
}
- fEditor= null;
- fTranslationUnit= null;
- fDocument= null;
+ fEditor = null;
+ fTranslationUnit = null;
+ fDocument = null;
}
}
@@ -201,13 +202,13 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
if (progressMonitor != null && progressMonitor.isCanceled()) {
return;
}
- final List<Position> newInactiveCodePositions= collectInactiveCodePositions(ast);
+ final List<Position> newInactiveCodePositions = collectInactiveCodePositions(ast);
Runnable updater = new Runnable() {
@Override
public void run() {
if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
fLineBackgroundPainter.replaceHighlightPositions(fInactiveCodePositions, newInactiveCodePositions);
- fInactiveCodePositions= newInactiveCodePositions;
+ fInactiveCodePositions = newInactiveCodePositions;
}
}
};
@@ -217,9 +218,9 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
}
/**
- * Collect source positions of preprocessor-hidden branches
+ * Collect source positions of preprocessor-hidden branches
* in the given translation unit.
- *
+ *
* @param translationUnit the {@link IASTTranslationUnit}, may be <code>null</code>
* @return a {@link List} of {@link IRegion}s
*/
@@ -239,13 +240,13 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
IASTPreprocessorStatement[] preprocStmts = translationUnit.getAllPreprocessorStatements();
for (IASTPreprocessorStatement statement : preprocStmts) {
- IASTFileLocation floc= statement.getFileLocation();
+ IASTFileLocation floc = statement.getFileLocation();
if (floc == null || !fileName.equals(floc.getFileName())) {
// preprocessor directive is from a different file
continue;
}
if (statement instanceof IASTPreprocessorIfStatement) {
- IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement)statement;
+ IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement) statement;
inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
if (!ifStmt.taken()) {
if (!inInactiveCode) {
@@ -254,7 +255,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
}
}
} else if (statement instanceof IASTPreprocessorIfdefStatement) {
- IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement)statement;
+ IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement) statement;
inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
if (!ifdefStmt.taken()) {
if (!inInactiveCode) {
@@ -263,7 +264,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
}
}
} else if (statement instanceof IASTPreprocessorIfndefStatement) {
- IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement)statement;
+ IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement) statement;
inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
if (!ifndefStmt.taken()) {
if (!inInactiveCode) {
@@ -272,7 +273,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
}
}
} else if (statement instanceof IASTPreprocessorElseStatement) {
- IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement)statement;
+ IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement) statement;
if (!elseStmt.taken() && !inInactiveCode) {
inactiveCodeStart = floc.getNodeOffset();
inInactiveCode = true;
@@ -282,7 +283,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
inInactiveCode = false;
}
} else if (statement instanceof IASTPreprocessorElifStatement) {
- IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement)statement;
+ IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement) statement;
if (!elifStmt.taken() && !inInactiveCode) {
inactiveCodeStart = floc.getNodeOffset();
inInactiveCode = true;
@@ -299,8 +300,8 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, true, fHighlightKey));
}
inInactiveCode = wasInInactiveCode;
+ } catch (EmptyStackException e) {
}
- catch( EmptyStackException e) {}
}
}
if (inInactiveCode) {
@@ -314,8 +315,8 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
/**
* Create a highlight position aligned to start at a line offset. The region's start is
* decreased to the line offset, and the end offset decreased to the line start if
- * <code>inclusive</code> is <code>false</code>.
- *
+ * <code>inclusive</code> is <code>false</code>.
+ *
* @param startOffset the start offset of the region to align
* @param endOffset the (exclusive) end offset of the region to align
* @param inclusive whether the last line should be included or not
@@ -323,14 +324,14 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
* @return a position aligned for background highlighting
*/
private HighlightPosition createHighlightPosition(int startOffset, int endOffset, boolean inclusive, String key) {
- final IDocument document= fDocument;
+ final IDocument document = fDocument;
try {
if (document != null) {
- int start= document.getLineOfOffset(startOffset);
- int end= document.getLineOfOffset(endOffset);
- startOffset= document.getLineOffset(start);
+ int start = document.getLineOfOffset(startOffset);
+ int end = document.getLineOfOffset(endOffset);
+ startOffset = document.getLineOffset(start);
if (!inclusive) {
- endOffset= document.getLineOffset(end);
+ endOffset = document.getLineOffset(end);
}
}
} catch (BadLocationException x) {
@@ -338,7 +339,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
}
return new HighlightPosition(startOffset, endOffset - startOffset, key);
}
-
+
/*
* @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
*/
@@ -346,7 +347,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
- fInactiveCodePositions= Collections.emptyList();
+ fInactiveCodePositions = Collections.emptyList();
}
}
@@ -355,7 +356,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
*/
@Override
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- fDocument= newInput;
+ fDocument = newInput;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java
index 708d5652dc2..da7acae18a8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java
@@ -33,13 +33,12 @@ import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
import org.eclipse.cdt.internal.ui.text.CIndenter;
-
/**
* Utility that indents a number of lines in a document.
*/
public final class IndentUtil {
-
- private static final String SLASHES= "//"; //$NON-NLS-1$
+
+ private static final String SLASHES = "//"; //$NON-NLS-1$
/**
* The result of an indentation operation. The result may be passed to
@@ -50,11 +49,13 @@ public final class IndentUtil {
*/
public static final class IndentResult {
private IndentResult(boolean[] commentLines) {
- commentLinesAtColumnZero= commentLines;
+ commentLinesAtColumnZero = commentLines;
}
+
private boolean[] commentLinesAtColumnZero;
private boolean hasChanged;
- private int leftmostLine= -1;
+ private int leftmostLine = -1;
+
/**
* Returns <code>true</code> if the indentation operation changed the
* document, <code>false</code> if not.
@@ -64,7 +65,7 @@ public final class IndentUtil {
return hasChanged;
}
}
-
+
private IndentUtil() {
// do not instantiate
}
@@ -73,7 +74,7 @@ public final class IndentUtil {
* Indents the line range specified by <code>lines</code> in
* <code>document</code>. The passed C project may be
* <code>null</code>, it is used solely to obtain formatter preferences.
- *
+ *
* @param document the document to be changed
* @param lines the line range to be indented
* @param project the C project to get the formatter preferences from, or
@@ -86,24 +87,26 @@ public final class IndentUtil {
* @throws BadLocationException if <code>lines</code> is not a valid line
* range on <code>document</code>
*/
- public static IndentResult indentLines(IDocument document, ILineRange lines, ICProject project, IndentResult result) throws BadLocationException {
- int numberOfLines= lines.getNumberOfLines();
-
+ public static IndentResult indentLines(IDocument document, ILineRange lines, ICProject project, IndentResult result)
+ throws BadLocationException {
+ int numberOfLines = lines.getNumberOfLines();
+
if (numberOfLines < 1)
return new IndentResult(null);
-
- result= reuseOrCreateToken(result, numberOfLines);
-
- CHeuristicScanner scanner= new CHeuristicScanner(document);
- CIndenter indenter= new CIndenter(document, scanner, project);
- boolean changed= false;
- int tabSize= CodeFormatterUtil.getTabWidth(project);
- boolean indentInsideLineComments= indentInsideLineComments(project);
- for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++) {
- changed |= indentLine(document, line, indenter, scanner, result.commentLinesAtColumnZero, i++, tabSize, indentInsideLineComments);
+
+ result = reuseOrCreateToken(result, numberOfLines);
+
+ CHeuristicScanner scanner = new CHeuristicScanner(document);
+ CIndenter indenter = new CIndenter(document, scanner, project);
+ boolean changed = false;
+ int tabSize = CodeFormatterUtil.getTabWidth(project);
+ boolean indentInsideLineComments = indentInsideLineComments(project);
+ for (int line = lines.getStartLine(), last = line + numberOfLines, i = 0; line < last; line++) {
+ changed |= indentLine(document, line, indenter, scanner, result.commentLinesAtColumnZero, i++, tabSize,
+ indentInsideLineComments);
}
- result.hasChanged= changed;
-
+ result.hasChanged = changed;
+
return result;
}
@@ -116,27 +119,28 @@ public final class IndentUtil {
* range on <code>document</code>
*/
public static void indentLines(IDocument document, LineRange lines, String indent) throws BadLocationException {
- int numberOfLines= lines.getNumberOfLines();
- for (int line= lines.getStartLine(), last= line + numberOfLines; line < last; line++) {
- int offset= document.getLineOffset(line);
+ int numberOfLines = lines.getNumberOfLines();
+ for (int line = lines.getStartLine(), last = line + numberOfLines; line < last; line++) {
+ int offset = document.getLineOffset(line);
document.replace(offset, 0, indent);
}
}
-
+
/**
* Returns <code>true</code> if line comments at column 0 should be indented inside, <code>false</code> otherwise.
- *
+ *
* @param project the project to get project specific options from
* @return <code>true</code> if line comments at column 0 should be indented inside, <code>false</code> otherwise.
*/
public static boolean indentInsideLineComments(ICProject project) {
- return DefaultCodeFormatterConstants.TRUE.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS));
+ return DefaultCodeFormatterConstants.TRUE
+ .equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS));
}
/**
* Returns the possibly <code>project</code>-specific core preference
* defined under <code>key</code>.
- *
+ *
* @param project the project to get the preference from, or
* <code>null</code> to get the global preference
* @param key the key of the preference
@@ -155,7 +159,7 @@ public final class IndentUtil {
* lines are adjusted accordingly. The passed C project may be
* <code>null</code>, it is used solely to obtain formatter
* preferences.
- *
+ *
* @param document the document to be changed
* @param lines the line range to be shifted
* @param project the C project to get the formatter preferences
@@ -170,47 +174,51 @@ public final class IndentUtil {
* @throws BadLocationException if <code>lines</code> is not a
* valid line range on <code>document</code>
*/
- public static IndentResult shiftLines(IDocument document, ILineRange lines, ICProject project, IndentResult result) throws BadLocationException {
- int numberOfLines= lines.getNumberOfLines();
-
+ public static IndentResult shiftLines(IDocument document, ILineRange lines, ICProject project, IndentResult result)
+ throws BadLocationException {
+ int numberOfLines = lines.getNumberOfLines();
+
if (numberOfLines < 1)
return new IndentResult(null);
-
- result= reuseOrCreateToken(result, numberOfLines);
- result.hasChanged= false;
-
- CHeuristicScanner scanner= new CHeuristicScanner(document);
- CIndenter indenter= new CIndenter(document, scanner, project);
-
- boolean indentInsideLineComments= indentInsideLineComments(project);
- String current= getCurrentIndent(document, lines.getStartLine(), indentInsideLineComments);
- StringBuilder correct= new StringBuilder(computeIndent(document, lines.getStartLine(), indenter, scanner));
-
- int tabSize= CodeFormatterUtil.getTabWidth(project);
- StringBuilder addition= new StringBuilder();
- int difference= subtractIndent(correct, current, addition, tabSize);
-
+
+ result = reuseOrCreateToken(result, numberOfLines);
+ result.hasChanged = false;
+
+ CHeuristicScanner scanner = new CHeuristicScanner(document);
+ CIndenter indenter = new CIndenter(document, scanner, project);
+
+ boolean indentInsideLineComments = indentInsideLineComments(project);
+ String current = getCurrentIndent(document, lines.getStartLine(), indentInsideLineComments);
+ StringBuilder correct = new StringBuilder(computeIndent(document, lines.getStartLine(), indenter, scanner));
+
+ int tabSize = CodeFormatterUtil.getTabWidth(project);
+ StringBuilder addition = new StringBuilder();
+ int difference = subtractIndent(correct, current, addition, tabSize);
+
if (difference == 0)
return result;
-
+
if (result.leftmostLine == -1)
- result.leftmostLine= getLeftMostLine(document, lines, tabSize, indentInsideLineComments);
-
- int maxReduction= computeVisualLength(getCurrentIndent(document, result.leftmostLine + lines.getStartLine(), indentInsideLineComments), tabSize);
-
+ result.leftmostLine = getLeftMostLine(document, lines, tabSize, indentInsideLineComments);
+
+ int maxReduction = computeVisualLength(
+ getCurrentIndent(document, result.leftmostLine + lines.getStartLine(), indentInsideLineComments),
+ tabSize);
+
if (difference > 0) {
- for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++)
+ for (int line = lines.getStartLine(), last = line + numberOfLines, i = 0; line < last; line++)
addIndent(document, line, addition, result.commentLinesAtColumnZero, i++, indentInsideLineComments);
} else {
- int reduction= Math.min(-difference, maxReduction);
- for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++)
- cutIndent(document, line, reduction, tabSize, result.commentLinesAtColumnZero, i++, indentInsideLineComments);
+ int reduction = Math.min(-difference, maxReduction);
+ for (int line = lines.getStartLine(), last = line + numberOfLines, i = 0; line < last; line++)
+ cutIndent(document, line, reduction, tabSize, result.commentLinesAtColumnZero, i++,
+ indentInsideLineComments);
}
-
- result.hasChanged= true;
-
+
+ result.hasChanged = true;
+
return result;
-
+
}
/**
@@ -225,10 +233,11 @@ public final class IndentUtil {
* @param indentInsideLineComments option whether to indent inside line comments starting at column 0
* @throws BadLocationException on concurrent document modification
*/
- private static void addIndent(IDocument document, int line, CharSequence indent, boolean[] commentlines, int relative, boolean indentInsideLineComments) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- int insert= region.getOffset();
- int endOffset= region.getOffset() + region.getLength();
+ private static void addIndent(IDocument document, int line, CharSequence indent, boolean[] commentlines,
+ int relative, boolean indentInsideLineComments) throws BadLocationException {
+ IRegion region = document.getLineInformation(line);
+ int insert = region.getOffset();
+ int endOffset = region.getOffset() + region.getLength();
if (indentInsideLineComments) {
// go behind line comments
@@ -253,7 +262,8 @@ public final class IndentUtil {
* @return number of characters deleted
* @throws BadLocationException
*/
- public static int cutIndent(IDocument document, int line, int shiftWidth, int tabWidth) throws BadLocationException {
+ public static int cutIndent(IDocument document, int line, int shiftWidth, int tabWidth)
+ throws BadLocationException {
return cutIndent(document, line, shiftWidth, tabWidth, new boolean[1], 0, false);
}
@@ -271,20 +281,21 @@ public final class IndentUtil {
* @return number of characters deleted
* @throws BadLocationException on concurrent document modification
*/
- private static int cutIndent(IDocument document, int line, int toDelete, int tabSize, boolean[] commentLines, int relative, boolean indentInsideLineComments) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- int from= region.getOffset();
- int endOffset= region.getOffset() + region.getLength();
+ private static int cutIndent(IDocument document, int line, int toDelete, int tabSize, boolean[] commentLines,
+ int relative, boolean indentInsideLineComments) throws BadLocationException {
+ IRegion region = document.getLineInformation(line);
+ int from = region.getOffset();
+ int endOffset = region.getOffset() + region.getLength();
if (indentInsideLineComments) {
// go behind line comments
while (from < endOffset - 2 && document.get(from, 2).equals(SLASHES))
from += 2;
}
-
- int to= from;
+
+ int to = from;
while (toDelete > 0 && to < endOffset) {
- char ch= document.getChar(to);
+ char ch = document.getChar(to);
if (!Character.isWhitespace(ch))
break;
toDelete -= computeVisualLength(ch, tabSize);
@@ -293,9 +304,9 @@ public final class IndentUtil {
else
break;
}
-
+
if (endOffset > to + 1 && document.get(to, 2).equals(SLASHES))
- commentLines[relative]= true;
+ commentLines[relative] = true;
document.replace(from, to - from, ""); //$NON-NLS-1$
return to - from;
@@ -311,22 +322,22 @@ public final class IndentUtil {
* @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
* @return the difference in lenght of <code>correct</code> and <code>current</code>
*/
- private static int subtractIndent(CharSequence correct, CharSequence current, StringBuilder difference, int tabSize) {
- int c1= computeVisualLength(correct, tabSize);
- int c2= computeVisualLength(current, tabSize);
- int diff= c1 - c2;
+ private static int subtractIndent(CharSequence correct, CharSequence current, StringBuilder difference,
+ int tabSize) {
+ int c1 = computeVisualLength(correct, tabSize);
+ int c2 = computeVisualLength(current, tabSize);
+ int diff = c1 - c2;
if (diff <= 0)
return diff;
difference.setLength(0);
- int len= 0, i= 0;
+ int len = 0, i = 0;
while (len < diff) {
- char c= correct.charAt(i++);
+ char c = correct.charAt(i++);
difference.append(c);
len += computeVisualLength(c, tabSize);
}
-
return diff;
}
@@ -344,10 +355,10 @@ public final class IndentUtil {
* @return the visual length of <code>seq</code>
*/
public static int computeVisualLength(CharSequence seq, int tablen) {
- int size= 0;
+ int size = 0;
- for (int i= 0; i < seq.length(); i++) {
- char ch= seq.charAt(i);
+ for (int i = 0; i < seq.length(); i++) {
+ char ch = seq.charAt(i);
if (ch == '\t') {
if (tablen != 0)
size += tablen - size % tablen;
@@ -370,20 +381,21 @@ public final class IndentUtil {
* @return the indentation of <code>line</code> in <code>document</code>
* @throws BadLocationException if the document is changed concurrently
*/
- public static String getCurrentIndent(IDocument document, int line, boolean indentInsideLineComments) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- int from= region.getOffset();
- int endOffset= region.getOffset() + region.getLength();
+ public static String getCurrentIndent(IDocument document, int line, boolean indentInsideLineComments)
+ throws BadLocationException {
+ IRegion region = document.getLineInformation(line);
+ int from = region.getOffset();
+ int endOffset = region.getOffset() + region.getLength();
- int to= from;
+ int to = from;
if (indentInsideLineComments) {
// go behind line comments
while (to < endOffset - 2 && document.get(to, 2).equals(SLASHES))
to += 2;
}
-
+
while (to < endOffset) {
- char ch= document.getChar(to);
+ char ch = document.getChar(to);
if (!Character.isWhitespace(ch))
break;
to++;
@@ -391,17 +403,19 @@ public final class IndentUtil {
return document.get(from, to - from);
}
-
- private static int getLeftMostLine(IDocument document, ILineRange lines, int tabSize, boolean indentInsideLineComments) throws BadLocationException {
- int numberOfLines= lines.getNumberOfLines();
- int first= lines.getStartLine();
- int minLine= -1;
- int minIndent= Integer.MAX_VALUE;
- for (int line= 0; line < numberOfLines; line++) {
- int length= computeVisualLength(getCurrentIndent(document, line + first, indentInsideLineComments), tabSize);
+
+ private static int getLeftMostLine(IDocument document, ILineRange lines, int tabSize,
+ boolean indentInsideLineComments) throws BadLocationException {
+ int numberOfLines = lines.getNumberOfLines();
+ int first = lines.getStartLine();
+ int minLine = -1;
+ int minIndent = Integer.MAX_VALUE;
+ for (int line = 0; line < numberOfLines; line++) {
+ int length = computeVisualLength(getCurrentIndent(document, line + first, indentInsideLineComments),
+ tabSize);
if (length < minIndent && document.getLineLength(line + first) > 0) {
- minIndent= length;
- minLine= line;
+ minIndent = length;
+ minLine = line;
}
}
return minLine;
@@ -409,21 +423,22 @@ public final class IndentUtil {
private static IndentResult reuseOrCreateToken(IndentResult token, int numberOfLines) {
if (token == null)
- token= new IndentResult(new boolean[numberOfLines]);
+ token = new IndentResult(new boolean[numberOfLines]);
else if (token.commentLinesAtColumnZero == null)
- token.commentLinesAtColumnZero= new boolean[numberOfLines];
+ token.commentLinesAtColumnZero = new boolean[numberOfLines];
else if (token.commentLinesAtColumnZero.length != numberOfLines) {
- boolean[] commentBooleans= new boolean[numberOfLines];
- System.arraycopy(token.commentLinesAtColumnZero, 0, commentBooleans, 0, Math.min(numberOfLines, token.commentLinesAtColumnZero.length));
- token.commentLinesAtColumnZero= commentBooleans;
+ boolean[] commentBooleans = new boolean[numberOfLines];
+ System.arraycopy(token.commentLinesAtColumnZero, 0, commentBooleans, 0,
+ Math.min(numberOfLines, token.commentLinesAtColumnZero.length));
+ token.commentLinesAtColumnZero = commentBooleans;
}
return token;
}
-
+
/**
* Indents a single line using the heuristic scanner. Multiline comments are
* indented as specified by the <code>CCommentAutoIndentStrategy</code>.
- *
+ *
* @param document the document
* @param line the line to be indented
* @param indenter the C indenter
@@ -436,67 +451,69 @@ public final class IndentUtil {
* <code>false</code> if not
* @throws BadLocationException if the document got changed concurrently
*/
- private static boolean indentLine(IDocument document, int line, CIndenter indenter,
- CHeuristicScanner scanner, boolean[] commentLines, int lineIndex, int tabSize,
- boolean indentInsideLineComments) throws BadLocationException {
- IRegion currentLine= document.getLineInformation(line);
- final int offset= currentLine.getOffset();
- int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
-
- String indent= null;
+ private static boolean indentLine(IDocument document, int line, CIndenter indenter, CHeuristicScanner scanner,
+ boolean[] commentLines, int lineIndex, int tabSize, boolean indentInsideLineComments)
+ throws BadLocationException {
+ IRegion currentLine = document.getLineInformation(line);
+ final int offset = currentLine.getOffset();
+ int wsStart = offset; // where we start searching for non-WS; after the "//" in single line comments
+
+ String indent = null;
if (offset < document.getLength()) {
- ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
- ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
- String type= partition.getType();
+ ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
+ ITypedRegion startingPartition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset,
+ false);
+ String type = partition.getType();
if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT) || type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
- indent= computeCommentIndent(document, line, scanner, startingPartition);
+ indent = computeCommentIndent(document, line, scanner, startingPartition);
} else if (startingPartition.getType().equals(ICPartitions.C_PREPROCESSOR)) {
- indent= computePreprocessorIndent(document, line, startingPartition);
- } else if (!commentLines[lineIndex] && startingPartition.getOffset() == offset && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
+ indent = computePreprocessorIndent(document, line, startingPartition);
+ } else if (!commentLines[lineIndex] && startingPartition.getOffset() == offset
+ && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
return false;
}
}
-
+
// standard C code indentation
if (indent == null) {
- StringBuilder computed= indenter.computeIndentation(offset);
+ StringBuilder computed = indenter.computeIndentation(offset);
if (computed != null)
- indent= computed.toString();
+ indent = computed.toString();
else
- indent= ""; //$NON-NLS-1$
+ indent = ""; //$NON-NLS-1$
}
-
+
// change document:
// get current white space
- int lineLength= currentLine.getLength();
- int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
+ int lineLength = currentLine.getLength();
+ int end = scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
if (end == CHeuristicScanner.NOT_FOUND)
- end= offset + lineLength;
- int length= end - offset;
- String currentIndent= document.get(offset, length);
-
+ end = offset + lineLength;
+ int length = end - offset;
+ String currentIndent = document.get(offset, length);
+
// memorize the fact that a line is a single line comment (but not at column 0) and should be treated like code
// as opposed to commented out code, which should keep its slashes at column 0
// if 'indentInsideLineComments' is false, all comment lines are indented with the code
if (length > 0 || !indentInsideLineComments) {
- ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, end, false);
+ ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, end, false);
if (partition.getOffset() == end && ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType())) {
- commentLines[lineIndex]= true;
+ commentLines[lineIndex] = true;
}
}
-
+
// only change the document if it is a real change
if (!indent.equals(currentIndent)) {
document.replace(offset, length, indent);
return true;
}
-
+
return false;
}
/**
* Computes and returns the indentation for a source line.
- *
+ *
* @param document the document
* @param line the line in document
* @param indenter the C indenter
@@ -504,36 +521,38 @@ public final class IndentUtil {
* @return the indent, never <code>null</code>
* @throws BadLocationException
*/
- public static String computeIndent(IDocument document, int line, CIndenter indenter, CHeuristicScanner scanner) throws BadLocationException {
- IRegion currentLine= document.getLineInformation(line);
- final int offset= currentLine.getOffset();
-
- String indent= null;
+ public static String computeIndent(IDocument document, int line, CIndenter indenter, CHeuristicScanner scanner)
+ throws BadLocationException {
+ IRegion currentLine = document.getLineInformation(line);
+ final int offset = currentLine.getOffset();
+
+ String indent = null;
if (offset < document.getLength()) {
- ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
- ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
- String type= partition.getType();
+ ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
+ ITypedRegion startingPartition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset,
+ false);
+ String type = partition.getType();
if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT) || type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
- indent= computeCommentIndent(document, line, scanner, startingPartition);
+ indent = computeCommentIndent(document, line, scanner, startingPartition);
} else if (startingPartition.getType().equals(ICPartitions.C_PREPROCESSOR)) {
- indent= computePreprocessorIndent(document, line, startingPartition);
+ indent = computePreprocessorIndent(document, line, startingPartition);
}
}
-
+
// standard C code indentation
if (indent == null) {
- StringBuilder computed= indenter.computeIndentation(offset);
+ StringBuilder computed = indenter.computeIndentation(offset);
if (computed != null)
- indent= computed.toString();
+ indent = computed.toString();
else
- indent= ""; //$NON-NLS-1$
+ indent = ""; //$NON-NLS-1$
}
return indent;
}
-
+
/**
* Computes and returns the indentation for a block comment line.
- *
+ *
* @param document the document
* @param line the line in document
* @param scanner the scanner
@@ -541,54 +560,55 @@ public final class IndentUtil {
* @return the indent, or <code>null</code> if not computable
* @throws BadLocationException
*/
- public static String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
+ public static String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner,
+ ITypedRegion partition) throws BadLocationException {
if (line == 0) // impossible - the first line is never inside a comment
return null;
-
+
// don't make any assumptions if the line does not start with \s*\* - it might be
// commented out code, for which we don't want to change the indent
- final IRegion lineInfo= document.getLineInformation(line);
- final int lineStart= lineInfo.getOffset();
- final int lineLength= lineInfo.getLength();
- final int lineEnd= lineStart + lineLength;
- int nonWS= scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
+ final IRegion lineInfo = document.getLineInformation(line);
+ final int lineStart = lineInfo.getOffset();
+ final int lineLength = lineInfo.getLength();
+ final int lineEnd = lineStart + lineLength;
+ int nonWS = scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
if (nonWS == CHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
if (nonWS == CHeuristicScanner.NOT_FOUND)
return document.get(lineStart, lineLength);
return document.get(lineStart, nonWS - lineStart);
}
-
+
// take the indent from the previous line and reuse
- IRegion previousLine= document.getLineInformation(line - 1);
- int previousLineStart= previousLine.getOffset();
- int previousLineLength= previousLine.getLength();
- int previousLineEnd= previousLineStart + previousLineLength;
-
- StringBuilder buf= new StringBuilder();
- int previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
+ IRegion previousLine = document.getLineInformation(line - 1);
+ int previousLineStart = previousLine.getOffset();
+ int previousLineLength = previousLine.getLength();
+ int previousLineEnd = previousLineStart + previousLineLength;
+
+ StringBuilder buf = new StringBuilder();
+ int previousLineNonWS = scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
if (previousLineNonWS == CHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
// align with the comment start if the previous line is not an asterix line
- previousLine= document.getLineInformationOfOffset(partition.getOffset());
- previousLineStart= previousLine.getOffset();
- previousLineLength= previousLine.getLength();
- previousLineEnd= previousLineStart + previousLineLength;
- previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
+ previousLine = document.getLineInformationOfOffset(partition.getOffset());
+ previousLineStart = previousLine.getOffset();
+ previousLineLength = previousLine.getLength();
+ previousLineEnd = previousLineStart + previousLineLength;
+ previousLineNonWS = scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
if (previousLineNonWS == CHeuristicScanner.NOT_FOUND)
- previousLineNonWS= previousLineEnd;
-
+ previousLineNonWS = previousLineEnd;
+
// add the initial space
// TODO this may be controlled by a formatter preference in the future
buf.append(' ');
}
-
- String indentation= document.get(previousLineStart, previousLineNonWS - previousLineStart);
+
+ String indentation = document.get(previousLineStart, previousLineNonWS - previousLineStart);
buf.insert(0, indentation);
return buf.toString();
}
/**
* Computes and returns the indentation for a preprocessor line.
- *
+ *
* @param document the document
* @param line the line in document
* @param partition the comment partition
@@ -597,28 +617,29 @@ public final class IndentUtil {
*/
public static String computePreprocessorIndent(IDocument document, int line, ITypedRegion partition)
throws BadLocationException {
- int ppFirstLine= document.getLineOfOffset(partition.getOffset());
+ int ppFirstLine = document.getLineOfOffset(partition.getOffset());
if (line == ppFirstLine) {
return ""; //$NON-NLS-1$
}
- CHeuristicScanner ppScanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, partition.getType());
- CIndenter ppIndenter= new CIndenter(document, ppScanner);
+ CHeuristicScanner ppScanner = new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, partition.getType());
+ CIndenter ppIndenter = new CIndenter(document, ppScanner);
if (line == ppFirstLine + 1) {
- return ppIndenter.createReusingIndent(new StringBuilder(), ppIndenter.getContinuationLineIndent(), 0).toString();
+ return ppIndenter.createReusingIndent(new StringBuilder(), ppIndenter.getContinuationLineIndent(), 0)
+ .toString();
}
- StringBuilder computed= ppIndenter.computeIndentation(document.getLineOffset(line), false);
+ StringBuilder computed = ppIndenter.computeIndentation(document.getLineOffset(line), false);
if (computed != null) {
return computed.toString();
}
// take the indent from the previous line and reuse
- IRegion previousLine= document.getLineInformation(line - 1);
- int previousLineStart= previousLine.getOffset();
- int previousLineLength= previousLine.getLength();
- int previousLineEnd= previousLineStart + previousLineLength;
-
- int previousLineNonWS= ppScanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
- String previousIndent= document.get(previousLineStart, previousLineNonWS - previousLineStart);
- computed= new StringBuilder(previousIndent);
+ IRegion previousLine = document.getLineInformation(line - 1);
+ int previousLineStart = previousLine.getOffset();
+ int previousLineLength = previousLine.getLength();
+ int previousLineEnd = previousLineStart + previousLineLength;
+
+ int previousLineNonWS = ppScanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
+ String previousIndent = document.get(previousLineStart, previousLineNonWS - previousLineStart);
+ computed = new StringBuilder(previousIndent);
return computed.toString();
}
@@ -648,10 +669,11 @@ public final class IndentUtil {
* @param startColumn the column where to start measurement
* @return StringBuilder
*/
- private static StringBuilder appendIndent(StringBuilder buffer, int width, int tabWidth, boolean useSpaces, int startColumn) {
+ private static StringBuilder appendIndent(StringBuilder buffer, int width, int tabWidth, boolean useSpaces,
+ int startColumn) {
assert tabWidth > 0;
int tabStop = startColumn - startColumn % tabWidth;
- int tabs = useSpaces ? 0 : (width-tabStop) / tabWidth;
+ int tabs = useSpaces ? 0 : (width - tabStop) / tabWidth;
for (int i = 0; i < tabs; ++i) {
buffer.append('\t');
tabStop += tabWidth;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndexUpdateRequestor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndexUpdateRequestor.java
index 26fdac40ace..7d92171a2e8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndexUpdateRequestor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndexUpdateRequestor.java
@@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.cdt.internal.corext.util.CModelUtil;
/**
- * A controller for on-demand indexing of files opened in C/C++ editors.
+ * A controller for on-demand indexing of files opened in C/C++ editors.
*/
public class IndexUpdateRequestor implements IPreferenceChangeListener {
private static class IndexUpdateRequestorJob extends Job {
@@ -77,7 +77,7 @@ public class IndexUpdateRequestor implements IPreferenceChangeListener {
IProject newProject;
synchronized (this) {
oldProject = fTu == null ? null : fTu.getCProject().getProject();
- newProject = tu == null ? null : tu.getCProject().getProject();
+ newProject = tu == null ? null : tu.getCProject().getProject();
fTu = tu;
}
@@ -92,7 +92,8 @@ public class IndexUpdateRequestor implements IPreferenceChangeListener {
if (tu != null) {
IProject project = tu.getCProject().getProject();
- if (!String.valueOf(true).equals(IndexerPreferences.get(project, IndexerPreferences.KEY_INDEX_ON_OPEN, null))) {
+ if (!String.valueOf(true)
+ .equals(IndexerPreferences.get(project, IndexerPreferences.KEY_INDEX_ON_OPEN, null))) {
tu = null;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InteractiveHeaderChooser.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InteractiveHeaderChooser.java
index 58fef2f1141..902026106c5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InteractiveHeaderChooser.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InteractiveHeaderChooser.java
@@ -50,7 +50,7 @@ public class InteractiveHeaderChooser implements IHeaderChooser {
if (headers.size() == 1)
return headers.iterator().next();
- Set<IPath> cacheKey = new HashSet<IPath>(headers);
+ Set<IPath> cacheKey = new HashSet<IPath>(headers);
// Check the decision cache. If the cache doesn't help, ask the user.
// Query the cache.
if (userChoiceCache.containsKey(cacheKey)) {
@@ -64,8 +64,7 @@ public class InteractiveHeaderChooser implements IHeaderChooser {
@Override
public void run() {
if (!shell.isDisposed()) {
- ElementListSelectionDialog dialog =
- new ElementListSelectionDialog(shell, new LabelProvider());
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());
dialog.setElements(elemArray);
dialog.setTitle(title);
dialog.setMessage(NLS.bind(CEditorMessages.OrganizeIncludes_choose_header, bindingName));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java
index b8dd90635a4..6827350d8e6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java
@@ -24,11 +24,10 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.CPluginImages;
-
public class LexicalSortingAction extends Action {
-
- private static final String ACTION_NAME= "LexicalSortingAction"; //$NON-NLS-1$
-
+
+ private static final String ACTION_NAME = "LexicalSortingAction"; //$NON-NLS-1$
+
private final ViewerComparator fSorter;
private final TreeViewer fTreeViewer;
private final String fStoreKey;
@@ -39,35 +38,35 @@ public class LexicalSortingAction extends Action {
public LexicalSortingAction(TreeViewer treeViewer, String storeKeySuffix) {
super(CUIPlugin.getResourceString(ACTION_NAME + ".label")); //$NON-NLS-1$
-
+
setDescription(CUIPlugin.getResourceString(ACTION_NAME + ".description")); //$NON-NLS-1$
setToolTipText(CUIPlugin.getResourceString(ACTION_NAME + ".tooltip")); //$NON-NLS-1$
-
+
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ALPHA_SORTING);
-
- fTreeViewer= treeViewer;
- fSorter= new CElementSorter();
- fStoreKey= ACTION_NAME + storeKeySuffix;
- boolean checked= CUIPlugin.getDefault().getDialogSettings().getBoolean(fStoreKey);
+ fTreeViewer = treeViewer;
+ fSorter = new CElementSorter();
+ fStoreKey = ACTION_NAME + storeKeySuffix;
+
+ boolean checked = CUIPlugin.getDefault().getDialogSettings().getBoolean(fStoreKey);
valueChanged(checked, false);
}
-
+
@Override
public void run() {
valueChanged(isChecked(), true);
}
-
+
private void valueChanged(boolean on, boolean store) {
setChecked(on);
fTreeViewer.setComparator(on ? fSorter : null);
-
- String key= ACTION_NAME + ".tooltip" + (on ? ".on" : ".off"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ String key = ACTION_NAME + ".tooltip" + (on ? ".on" : ".off"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
setToolTipText(CUIPlugin.getResourceString(key));
-
+
if (store) {
CUIPlugin.getDefault().getDialogSettings().put(fStoreKey, on);
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
index 36816c386ac..d9ceffbb736 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -37,45 +37,44 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
-
public class OpenIncludeAction extends Action {
- private static final String PREFIX= "OpenIncludeAction."; //$NON-NLS-1$
-
- private static final String DIALOG_TITLE= PREFIX + "dialog.title"; //$NON-NLS-1$
- private static final String DIALOG_MESSAGE= PREFIX + "dialog.message"; //$NON-NLS-1$
-
+ private static final String PREFIX = "OpenIncludeAction."; //$NON-NLS-1$
+
+ private static final String DIALOG_TITLE = PREFIX + "dialog.title"; //$NON-NLS-1$
+ private static final String DIALOG_MESSAGE = PREFIX + "dialog.message"; //$NON-NLS-1$
+
private ISelectionProvider fSelectionProvider;
public OpenIncludeAction(ISelectionProvider provider) {
super(CUIPlugin.getResourceString(PREFIX + "label")); //$NON-NLS-1$
setDescription(CUIPlugin.getResourceString(PREFIX + "description")); //$NON-NLS-1$
setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip")); //$NON-NLS-1$
-
+
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
-
- fSelectionProvider= provider;
+
+ fSelectionProvider = provider;
}
-
+
@Override
public void run() {
- IInclude include= getIncludeStatement(fSelectionProvider.getSelection());
+ IInclude include = getIncludeStatement(fSelectionProvider.getSelection());
if (include == null) {
return;
}
try {
List<IPath> filesFound = CElementIncludeResolver.resolveInclude(include);
- int nElementsFound= filesFound.size();
+ int nElementsFound = filesFound.size();
if (nElementsFound == 0) {
noElementsFound();
return;
}
-
+
IPath fileToOpen;
if (nElementsFound == 1) {
- fileToOpen= filesFound.get(0);
+ fileToOpen = filesFound.get(0);
} else {
- fileToOpen= chooseFile(filesFound);
+ fileToOpen = chooseFile(filesFound);
}
if (fileToOpen != null) {
EditorUtility.openInEditor(fileToOpen, include);
@@ -84,40 +83,40 @@ public class OpenIncludeAction extends Action {
CUIPlugin.log(e.getStatus());
}
}
-
+
private static void noElementsFound() {
MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
errorMsg.setText(CUIPlugin.getResourceString("OpenIncludeAction.error")); //$NON-NLS-1$
- errorMsg.setMessage (CUIPlugin.getResourceString("OpenIncludeAction.error.description")); //$NON-NLS-1$
+ errorMsg.setMessage(CUIPlugin.getResourceString("OpenIncludeAction.error.description")); //$NON-NLS-1$
errorMsg.open();
}
-
+
private static IPath chooseFile(List<IPath> filesFound) {
- return OpenActionUtil.selectPath(filesFound, CUIPlugin.getResourceString(DIALOG_TITLE),
+ return OpenActionUtil.selectPath(filesFound, CUIPlugin.getResourceString(DIALOG_TITLE),
CUIPlugin.getResourceString(DIALOG_MESSAGE));
}
-
+
private static IInclude getIncludeStatement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
- List<?> list= ((IStructuredSelection)sel).toList();
+ List<?> list = ((IStructuredSelection) sel).toList();
if (list.size() == 1) {
- Object element= list.get(0);
+ Object element = list.get(0);
if (element instanceof IInclude) {
- return (IInclude)element;
+ return (IInclude) element;
}
}
}
return null;
}
-
+
public static boolean canActionBeAdded(ISelection selection) {
ICElement include = getIncludeStatement(selection);
if (include != null) {
IResource res = include.getUnderlyingResource();
if (res != null) {
- return true;
+ return true;
}
}
return false;
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java
index 84f12bcea20..a335a00b4c0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java
@@ -69,8 +69,8 @@ public class OrganizeIncludesAction extends TextEditorAction {
return;
}
- final IHeaderChooser headerChooser = new InteractiveHeaderChooser(
- CEditorMessages.OrganizeIncludes_label, editor.getSite().getShell());
+ final IHeaderChooser headerChooser = new InteractiveHeaderChooser(CEditorMessages.OrganizeIncludes_label,
+ editor.getSite().getShell());
final MultiTextEdit[] holder = new MultiTextEdit[1];
// We can't use SharedASTJob because IncludeOrganizer needs to disable promiscuous
// binding resolution, and you can't mix promiscuous and non-promiscuous binding
@@ -79,14 +79,14 @@ public class OrganizeIncludesAction extends TextEditorAction {
@Override
public IStatus run(IProgressMonitor monitor) {
try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(tu.getCProject(),
+ IIndex index = CCorePlugin.getIndexManager().getIndex(tu.getCProject(),
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT);
try {
index.acquireReadLock();
IASTTranslationUnit ast = tu.getAST(index, ASTCache.PARSE_MODE);
if (ast == null) {
- return CUIPlugin.createErrorStatus(
- NLS.bind(CEditorMessages.OrganizeIncludes_ast_not_available, tu.getPath().toOSString()));
+ return CUIPlugin.createErrorStatus(NLS.bind(
+ CEditorMessages.OrganizeIncludes_ast_not_available, tu.getPath().toOSString()));
}
IncludeOrganizer organizer = new IncludeOrganizer(tu, index, headerChooser);
holder[0] = organizer.organizeIncludes(ast);
@@ -108,7 +108,7 @@ public class OrganizeIncludesAction extends TextEditorAction {
// Apply the text edit.
IEditorInput editorInput = editor.getEditorInput();
IDocument document = editor.getDocumentProvider().getDocument(editorInput);
- IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
+ IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
manager.beginCompoundChange();
try {
edit.apply(document);
@@ -120,8 +120,7 @@ public class OrganizeIncludesAction extends TextEditorAction {
manager.endCompoundChange();
}
} else if (status.matches(IStatus.ERROR)) {
- ErrorDialog.openError(editor.getEditorSite().getShell(),
- CEditorMessages.OrganizeIncludes_error_title,
+ ErrorDialog.openError(editor.getEditorSite().getShell(), CEditorMessages.OrganizeIncludes_error_title,
CEditorMessages.OrganizeIncludes_insertion_failed, status);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvider.java
index bc50b4acea7..bb060d4180b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvider.java
@@ -62,12 +62,13 @@ public class OverrideIndicatorImageProvider implements IAnnotationImageProvider
assert false;
return null;
}
-
+
private boolean isImageProviderFor(Annotation annotation) {
- return annotation != null && OverrideIndicatorManager.OverrideIndicator.ANNOTATION_TYPE_ID.equals(annotation.getType());
+ return annotation != null
+ && OverrideIndicatorManager.OverrideIndicator.ANNOTATION_TYPE_ID.equals(annotation.getType());
}
-
+
private int getAnnotationType(Annotation annotation) {
- return ((OverrideIndicatorManager.OverrideIndicator)annotation).getIndicationType();
+ return ((OverrideIndicatorManager.OverrideIndicator) annotation).getIndicationType();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java
index 1d8fbcb2a0d..e0940ea7389 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java
@@ -54,7 +54,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
public class OverrideIndicatorManager implements ICReconcilingListener {
public static final String ANNOTATION_TYPE = "org.eclipse.cdt.ui.overrideIndicator"; //$NON-NLS-1$
- private final HashMap<ICPPClassType, ICPPMethod[]> methodsCache = new HashMap<>();
+ private final HashMap<ICPPClassType, ICPPMethod[]> methodsCache = new HashMap<>();
public static final int ANNOTATION_IMPLEMENTS = 0;
public static final int ANNOTATION_OVERRIDES = 1;
@@ -85,11 +85,11 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
private final IAnnotationModel fAnnotationModel;
private Annotation[] fOverrideAnnotations;
-
+
private final Object fAnnotationModelLockObject;
private int annotationKind;
private String annotationMessage;
-
+
public OverrideIndicatorManager(IAnnotationModel annotationModel, IASTTranslationUnit ast) {
fAnnotationModel = annotationModel;
fAnnotationModelLockObject = getLockObject(fAnnotationModel);
@@ -110,14 +110,14 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
}
return annotationModel;
}
-
+
protected void updateAnnotations(IASTTranslationUnit ast, IProgressMonitor progressMonitor) {
if (ast == null || progressMonitor.isCanceled())
return;
-
+
final IIndex index = ast.getIndex();
- final Map<Annotation, Position> annotationMap= new HashMap<Annotation, Position>(50);
-
+ final Map<Annotation, Position> annotationMap = new HashMap<Annotation, Position>(50);
+
class MethodFinder extends ASTVisitor {
{
shouldVisitDeclarators = true;
@@ -139,18 +139,22 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
ICPPMethod overriddenMethod = testForOverride(method);
if (overriddenMethod != null) {
try {
- ICElementHandle baseDeclaration = IndexUI.findAnyDeclaration(index, null, overriddenMethod);
+ ICElementHandle baseDeclaration = IndexUI.findAnyDeclaration(index, null,
+ overriddenMethod);
if (baseDeclaration == null) {
- ICElementHandle[] allDefinitions = IndexUI.findAllDefinitions(index, overriddenMethod);
+ ICElementHandle[] allDefinitions = IndexUI.findAllDefinitions(index,
+ overriddenMethod);
if (allDefinitions.length > 0) {
baseDeclaration = allDefinitions[0];
}
}
-
- OverrideIndicator indicator = new OverrideIndicator(annotationKind, annotationMessage, baseDeclaration);
-
+
+ OverrideIndicator indicator = new OverrideIndicator(annotationKind,
+ annotationMessage, baseDeclaration);
+
IASTFileLocation fileLocation = declarator.getFileLocation();
- Position position = new Position(fileLocation.getNodeOffset(), fileLocation.getNodeLength());
+ Position position = new Position(fileLocation.getNodeOffset(),
+ fileLocation.getNodeLength());
annotationMap.put(indicator, position);
} catch (CoreException e) {
}
@@ -164,54 +168,54 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
return PROCESS_CONTINUE;
}
}
-
+
try {
ast.accept(new MethodFinder());
} finally {
methodsCache.clear();
}
-
+
if (progressMonitor.isCanceled())
return;
synchronized (fAnnotationModelLockObject) {
if (fAnnotationModel instanceof IAnnotationModelExtension) {
- ((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, annotationMap);
+ ((IAnnotationModelExtension) fAnnotationModel).replaceAnnotations(fOverrideAnnotations, annotationMap);
} else {
removeAnnotations();
for (Map.Entry<Annotation, Position> entry : annotationMap.entrySet()) {
fAnnotationModel.addAnnotation(entry.getKey(), entry.getValue());
}
}
- fOverrideAnnotations= annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
+ fOverrideAnnotations = annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
}
}
-
+
private ICPPMethod testForOverride(ICPPMethod method) throws DOMException {
if (method.isDestructor() || method.isPureVirtual()) {
return null;
}
-
+
ICPPBase[] bases = method.getClassOwner().getBases();
if (bases.length == 0) {
return null;
}
-
+
ICPPClassType owningClass = method.getClassOwner();
ICPPMethod overriddenMethod = getOverriddenMethodInBaseClass(owningClass, method);
-
+
if (overriddenMethod != null) {
StringBuilder sb = new StringBuilder();
if (annotationKind == ANNOTATION_IMPLEMENTS) {
sb.append(CEditorMessages.OverrideIndicatorManager_implements);
- } else if (annotationKind == ANNOTATION_OVERRIDES){
+ } else if (annotationKind == ANNOTATION_OVERRIDES) {
sb.append(CEditorMessages.OverrideIndicatorManager_overrides);
} else if (annotationKind == ANNOTATION_SHADOWS) {
sb.append(CEditorMessages.OverrideIndicatorManager_shadows);
}
sb.append(' ');
sb.append(ASTStringUtil.join(overriddenMethod.getQualifiedName(), "::")); //$NON-NLS-1$
-
+
if (bases.length > 1) {
boolean foundInDirectlyDerivedBaseClass = false;
ICPPClassType matchedMethodOwner = overriddenMethod.getClassOwner();
@@ -239,14 +243,15 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
}
}
}
-
+
annotationMessage = sb.toString();
return overriddenMethod;
}
return null;
}
- private ICPPMethod getOverriddenMethodInBaseClass(ICPPClassType aClass, ICPPMethod testedMethod) throws DOMException {
+ private ICPPMethod getOverriddenMethodInBaseClass(ICPPClassType aClass, ICPPMethod testedMethod)
+ throws DOMException {
final String testedMethodName = testedMethod.getName();
ICPPMethod[] allInheritedMethods;
@@ -254,10 +259,9 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
allInheritedMethods = methodsCache.get(aClass);
} else {
ICPPMethod[] inheritedMethods = null;
- ICPPClassType[] bases= ClassTypeHelper.getAllBases(aClass);
+ ICPPClassType[] bases = ClassTypeHelper.getAllBases(aClass);
for (ICPPClassType base : bases) {
- inheritedMethods = ArrayUtil.addAll(ICPPMethod.class, inheritedMethods,
- base.getDeclaredMethods());
+ inheritedMethods = ArrayUtil.addAll(ICPPMethod.class, inheritedMethods, base.getDeclaredMethods());
}
allInheritedMethods = ArrayUtil.trim(ICPPMethod.class, inheritedMethods);
methodsCache.put(aClass, allInheritedMethods);
@@ -303,12 +307,12 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
synchronized (fAnnotationModelLockObject) {
if (fAnnotationModel instanceof IAnnotationModelExtension) {
- ((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, null);
+ ((IAnnotationModelExtension) fAnnotationModel).replaceAnnotations(fOverrideAnnotations, null);
} else {
- for (int i= 0, length= fOverrideAnnotations.length; i < length; i++)
+ for (int i = 0, length = fOverrideAnnotations.length; i < length; i++)
fAnnotationModel.removeAnnotation(fOverrideAnnotations[i]);
}
- fOverrideAnnotations= null;
+ fOverrideAnnotations = null;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java
index a6527e6f300..ceddb749d98 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java
@@ -18,31 +18,30 @@ import java.util.Iterator;
import org.eclipse.jface.text.source.IAnnotationModel;
-
/**
* Filters problems based on their types.
*/
public class ProblemAnnotationIterator implements Iterator<IProblemAnnotation> {
-
+
private Iterator<?> fIterator;
private IProblemAnnotation fNext;
-
+
public ProblemAnnotationIterator(IAnnotationModel model) {
- fIterator= model.getAnnotationIterator();
+ fIterator = model.getAnnotationIterator();
skip();
}
-
+
private void skip() {
while (fIterator.hasNext()) {
- Object next= fIterator.next();
+ Object next = fIterator.next();
if (next instanceof IProblemAnnotation) {
- fNext= (IProblemAnnotation) next;
+ fNext = (IProblemAnnotation) next;
return;
}
}
- fNext= null;
+ fNext = null;
}
-
+
/*
* @see Iterator#hasNext()
*/
@@ -71,5 +70,3 @@ public class ProblemAnnotationIterator implements Iterator<IProblemAnnotation> {
throw new UnsupportedOperationException();
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionHistory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionHistory.java
index 7d59cb86d2f..dac662377a5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionHistory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionHistory.java
@@ -31,9 +31,9 @@ public class SelectionHistory {
public SelectionHistory(CEditor editor) {
Assert.isNotNull(editor);
- fEditor= editor;
- fHistory= new Stack<ISourceRange>();
- fSelectionListener= new ISelectionChangedListener() {
+ fEditor = editor;
+ fHistory = new Stack<ISourceRange>();
+ fSelectionListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (fSelectionChangeListenerCounter == 0)
@@ -54,7 +54,7 @@ public class SelectionHistory {
public ISourceRange getLast() {
if (isEmpty())
return null;
- ISourceRange result= fHistory.pop();
+ ISourceRange result = fHistory.pop();
return result;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionToDeclarationJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionToDeclarationJob.java
index 0d87e586513..0375d31fd17 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionToDeclarationJob.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionToDeclarationJob.java
@@ -78,7 +78,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
* Based on class OpenDeclarationsJob
* @author Alvaro Sanchez-Leon
* @since 5.6
- */
+ */
public class SelectionToDeclarationJob extends Job implements ASTRunnable {
private enum NameKind {
REFERENCE, DECLARATION, USING_DECL, DEFINITION
@@ -91,12 +91,13 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
public SelectionToDeclarationJob(ITextEditor editor, ITextSelection textSelection) throws CoreException {
super(CEditorMessages.OpenDeclarations_dialog_title);
-
+
if (!(editor instanceof CEditor)) {
- IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, ICStatusConstants.INTERNAL_ERROR, "Action not supportted outside the context of the C Editor", null); //$NON-NLS-1$
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, ICStatusConstants.INTERNAL_ERROR,
+ "Action not supportted outside the context of the C Editor", null); //$NON-NLS-1$
throw new CoreException(status);
}
-
+
fTranslationUnit = ((CEditor) editor).getInputCElement();
fTextSelection = textSelection;
}
@@ -115,8 +116,8 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
if (fIndex != null)
return Status.CANCEL_STATUS;
- fIndex = CCorePlugin.getIndexManager()
- .getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
+ fIndex = CCorePlugin.getIndexManager().getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES
+ | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
try {
fIndex.acquireReadLock();
@@ -148,7 +149,8 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
IASTName sourceName = nodeSelector.findEnclosingName(selectionStart, selectionLength);
if (sourceName == null) {
- IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, CEditorMessages.StepIntoSelection_unable_to_resolve_name);
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+ CEditorMessages.StepIntoSelection_unable_to_resolve_name);
throw new CoreException(status);
}
@@ -174,7 +176,8 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
IName[] names = findDeclNames(ast, kind, binding);
for (final IName name : names) {
if (name != null) {
- if (name instanceof IIndexName && filename.equals(((IIndexName) name).getFileLocation().getFileName())) {
+ if (name instanceof IIndexName
+ && filename.equals(((IIndexName) name).getFileLocation().getFileName())) {
// Exclude index names from the current file.
} else if (areOverlappingNames(name, sourceName)) {
// Exclude the current location.
@@ -235,7 +238,8 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
return declNames;
}
- private IName[] findNames(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding) throws CoreException {
+ private IName[] findNames(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding)
+ throws CoreException {
IName[] declNames;
if (kind == NameKind.DEFINITION) {
declNames = findDeclarations(index, ast, binding);
@@ -253,7 +257,8 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
return declNames;
}
- private IName[] findDefinitions(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding) throws CoreException {
+ private IName[] findDefinitions(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding)
+ throws CoreException {
List<IASTName> declNames = new ArrayList<IASTName>();
declNames.addAll(Arrays.asList(ast.getDefinitionsInAST(binding)));
for (Iterator<IASTName> i = declNames.iterator(); i.hasNext();) {
@@ -314,7 +319,8 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
/**
* Returns definitions of bindings referenced by implicit name at the given location.
*/
- private IName[] findImplicitTargets(IASTTranslationUnit ast, IASTNodeSelector nodeSelector, int offset, int length) throws CoreException {
+ private IName[] findImplicitTargets(IASTTranslationUnit ast, IASTNodeSelector nodeSelector, int offset, int length)
+ throws CoreException {
IName[] definitions = IName.EMPTY_ARRAY;
IASTName firstName = nodeSelector.findEnclosingImplicitName(offset, length);
if (firstName != null) {
@@ -366,7 +372,8 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
if (loc1 == null || loc2 == null)
return false;
return loc1.getFileName().equals(loc2.getFileName())
- && max(loc1.getNodeOffset(), loc2.getNodeOffset()) < min(loc1.getNodeOffset() + loc1.getNodeLength(), loc2.getNodeOffset() + loc2.getNodeLength());
+ && max(loc1.getNodeOffset(), loc2.getNodeOffset()) < min(loc1.getNodeOffset() + loc1.getNodeLength(),
+ loc2.getNodeOffset() + loc2.getNodeLength());
}
private static boolean isInSameFunction(IASTName refName, IName funcDeclName) {
@@ -399,7 +406,8 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
return (IASTDeclaration) node;
}
- private void filterToFunctions(ICProject project, IIndex index, IName[] declNames, List<IFunctionDeclaration> functionElements) {
+ private void filterToFunctions(ICProject project, IIndex index, IName[] declNames,
+ List<IFunctionDeclaration> functionElements) {
for (IName declName : declNames) {
try {
ICElement elem = getCElementForName(project, index, declName);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java
index c681bc3214a..4cbfd9a4aed 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java
@@ -28,7 +28,7 @@ public abstract class SemanticHighlighting {
* @return the preference key, will be augmented by a prefix and a suffix for each preference
*/
public abstract String getPreferenceKey();
-
+
/**
* @return <code>true</code> if the highlighting is enabled by default
*/
@@ -41,7 +41,7 @@ public abstract class SemanticHighlighting {
public boolean requiresImplicitNames() {
return false;
}
-
+
/**
* Indicates that the highlighting needs to visit expressions.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java
index 957c09b389a..d88a32ed38b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
@@ -60,7 +60,7 @@ import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration;
/**
* Semantic highlighting manager.
* Cloned from JDT.
- *
+ *
* @since 4.0
*/
public class SemanticHighlightingManager implements IPropertyChangeListener {
@@ -94,7 +94,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
* @param textAttribute The background to set.
*/
public void setTextAttribute(TextAttribute textAttribute) {
- fTextAttribute= textAttribute;
+ fTextAttribute = textAttribute;
}
/**
@@ -108,7 +108,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
* @param isEnabled the new enabled state
*/
public void setEnabled(boolean isEnabled) {
- fIsEnabled= isEnabled;
+ fIsEnabled = isEnabled;
}
}
@@ -132,24 +132,25 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
*/
public HighlightedPosition(int offset, int length, HighlightingStyle highlighting, Object lock) {
super(offset, length);
- fStyle= highlighting;
- fLock= lock;
+ fStyle = highlighting;
+ fLock = lock;
}
/**
* @return Returns a corresponding style range.
*/
public StyleRange createStyleRange() {
- int len= 0;
+ int len = 0;
if (fStyle.isEnabled())
- len= getLength();
+ len = getLength();
- TextAttribute textAttribute= fStyle.getTextAttribute();
- int style= textAttribute.getStyle();
- int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
- StyleRange styleRange= new StyleRange(getOffset(), len, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle);
- styleRange.strikeout= (style & TextAttribute.STRIKETHROUGH) != 0;
- styleRange.underline= (style & TextAttribute.UNDERLINE) != 0;
+ TextAttribute textAttribute = fStyle.getTextAttribute();
+ int style = textAttribute.getStyle();
+ int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
+ StyleRange styleRange = new StyleRange(getOffset(), len, textAttribute.getForeground(),
+ textAttribute.getBackground(), fontStyle);
+ styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
+ styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
return styleRange;
}
@@ -240,7 +241,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
*/
public HighlightedRange(int offset, int length, String key) {
super(offset, length);
- fKey= key;
+ fKey = key;
}
/**
@@ -255,7 +256,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
*/
@Override
public boolean equals(Object o) {
- return super.equals(o) && o instanceof HighlightedRange && fKey.equals(((HighlightedRange)o).getKey());
+ return super.equals(o) && o instanceof HighlightedRange && fKey.equals(((HighlightedRange) o).getKey());
}
/*
@@ -301,17 +302,19 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
* @param colorManager The color manager
* @param preferenceStore The preference store
*/
- public void install(CEditor editor, CSourceViewer sourceViewer, IColorManager colorManager, IPreferenceStore preferenceStore) {
- fEditor= editor;
- fSourceViewer= sourceViewer;
- fColorManager= colorManager;
- fPreferenceStore= preferenceStore;
+ public void install(CEditor editor, CSourceViewer sourceViewer, IColorManager colorManager,
+ IPreferenceStore preferenceStore) {
+ fEditor = editor;
+ fSourceViewer = sourceViewer;
+ fColorManager = colorManager;
+ fPreferenceStore = preferenceStore;
if (fEditor != null) {
- fConfiguration= new CSourceViewerScalableConfiguration(colorManager, preferenceStore, editor, ICPartitions.C_PARTITIONING);
- fPresentationReconciler= (CPresentationReconciler) fConfiguration.getPresentationReconciler(sourceViewer);
+ fConfiguration = new CSourceViewerScalableConfiguration(colorManager, preferenceStore, editor,
+ ICPartitions.C_PARTITIONING);
+ fPresentationReconciler = (CPresentationReconciler) fConfiguration.getPresentationReconciler(sourceViewer);
} else {
- fConfiguration= null;
- fPresentationReconciler= null;
+ fConfiguration = null;
+ fPresentationReconciler = null;
}
fPreferenceStore.addPropertyChangeListener(this);
@@ -323,7 +326,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
/**
* Installs the semantic highlighting on the given source viewer infrastructure.
* No reconciliation will be performed.
- *
+ *
* This is used for highlighting the code in the previewer window in the preferences.
*
* @param sourceViewer the source viewer
@@ -331,8 +334,8 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
* @param preferenceStore the preference store
* @param previewerLibraryDecls library declarations required for the previewer code to be valid
*/
- public void install(CSourceViewer sourceViewer, IColorManager colorManager,
- IPreferenceStore preferenceStore, String previewerLibraryDecls) {
+ public void install(CSourceViewer sourceViewer, IColorManager colorManager, IPreferenceStore preferenceStore,
+ String previewerLibraryDecls) {
fPreviewerLibraryDecls = previewerLibraryDecls;
install(null, sourceViewer, colorManager, preferenceStore);
}
@@ -343,11 +346,11 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
private void enable() {
initializeHighlightings();
- fPresenter= new SemanticHighlightingPresenter();
+ fPresenter = new SemanticHighlightingPresenter();
fPresenter.install(fSourceViewer, fPresentationReconciler);
if (fEditor != null) {
- fReconciler= new SemanticHighlightingReconciler();
+ fReconciler = new SemanticHighlightingReconciler();
fReconciler.install(fEditor, fSourceViewer, fPresenter, fSemanticHighlightings, fHighlightings);
} else {
fPresenter.updatePresentation(null, computePreviewerPositions(), new HighlightedPosition[0]);
@@ -361,10 +364,10 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
// Before parsing and coloring the preview code, prepend library declarations
// required to make it valid.
CharArray previewCode = new CharArray(fPreviewerLibraryDecls + fSourceViewer.getDocument().get());
-
+
// Parse the preview code.
ILanguage language = GPPLanguage.getDefault();
- FileContent content = new InternalFileContent("<previewer>", previewCode); //$NON-NLS-1$
+ FileContent content = new InternalFileContent("<previewer>", previewCode); //$NON-NLS-1$
IScannerInfo scanInfo = new ScannerInfo();
IncludeFileContentProvider fileCreator = IncludeFileContentProvider.getEmptyFilesProvider();
IParserLogService log = ParserUtil.getParserLogService();
@@ -375,7 +378,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
CUIPlugin.log(e);
return new HighlightedPosition[] {};
}
-
+
// Correct highlighting of external SDK references requires an index-based AST.
// Since we don't have an index-based AST here, we swap out the external SDK
// highlighting with a custom one that recognizes certain hardcoded functions
@@ -388,13 +391,13 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
highlightings.add(highlighting);
}
}
-
+
// Compute the highlighted positions for the preview code.
PreviewerPositionCollector collector = new PreviewerPositionCollector(
highlightings.toArray(new SemanticHighlighting[highlightings.size()]), fHighlightings);
tu.accept(collector);
List<HighlightedPosition> positions = collector.getPositions();
-
+
// Since the code that was parsed and colored included library declarations as
// a prefix, the offsets in the highlighted positions reflect offsets in the
// library declarations + preview code. Since what we're actually showing is
@@ -408,21 +411,21 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
adjustedPositions.add(position);
}
}
-
+
return adjustedPositions.toArray(new HighlightedPosition[adjustedPositions.size()]);
}
-
- // A custom version of the highlighting for external SDK functions, for use
+
+ // A custom version of the highlighting for external SDK functions, for use
// by the previewer. Just highlights names that match a hardcoded list of
// SDK functions that appear in the previewer code.
private static class PreviewerExternalSDKHighlighting extends SemanticHighlightingWithOwnPreference {
static private final Set<String> fHarcodedSDKFunctions;
static {
fHarcodedSDKFunctions = new HashSet<String>();
- fHarcodedSDKFunctions.add("fprintf"); //$NON-NLS-1$
+ fHarcodedSDKFunctions.add("fprintf"); //$NON-NLS-1$
// add others as necessary
}
-
+
@Override
public boolean consumes(ISemanticToken token) {
IASTNode node = token.getNode();
@@ -438,25 +441,28 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
public RGB getDefaultDefaultTextColor() {
return null;
}
+
@Override
public String getDisplayName() {
return null;
}
+
@Override
public String getPreferenceKey() {
return null;
}
+
@Override
public boolean isEnabledByDefault() {
return false;
}
}
-
+
// Simple implementation of AbstractPositionCollector for the previewer.
private class PreviewerPositionCollector extends AbstractPositionCollector {
private List<HighlightedPosition> fPositions = new ArrayList<>();
-
- public PreviewerPositionCollector(SemanticHighlighting[] highlightings,
+
+ public PreviewerPositionCollector(SemanticHighlighting[] highlightings,
HighlightingStyle[] highlightingStyles) {
super(highlightings, highlightingStyles);
}
@@ -465,7 +471,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
protected void addPosition(int offset, int length, HighlightingStyle highlightingStyle) {
fPositions.add(fPresenter.createHighlightedPosition(offset, length, highlightingStyle));
}
-
+
public List<HighlightedPosition> getPositions() {
return fPositions;
}
@@ -479,14 +485,14 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
if (fPreferenceStore != null) {
fPreferenceStore.removePropertyChangeListener(this);
- fPreferenceStore= null;
+ fPreferenceStore = null;
}
- fEditor= null;
- fSourceViewer= null;
- fColorManager= null;
- fConfiguration= null;
- fPresentationReconciler= null;
+ fEditor = null;
+ fSourceViewer = null;
+ fColorManager = null;
+ fConfiguration = null;
+ fPresentationReconciler = null;
}
/**
@@ -495,12 +501,12 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
private void disable() {
if (fReconciler != null) {
fReconciler.uninstall();
- fReconciler= null;
+ fReconciler = null;
}
if (fPresenter != null) {
fPresenter.uninstall();
- fPresenter= null;
+ fPresenter = null;
}
if (fSemanticHighlightings != null)
@@ -518,32 +524,36 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
* Initializes semantic highlightings.
*/
protected void initializeHighlightings() {
- fSemanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
- fHighlightings= new HighlightingStyle[fSemanticHighlightings.length];
+ fSemanticHighlightings = SemanticHighlightings.getSemanticHighlightings();
+ fHighlightings = new HighlightingStyle[fSemanticHighlightings.length];
- for (int i= 0, n= fSemanticHighlightings.length; i < n; i++) {
- SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i];
- String colorKey= SemanticHighlightings.getColorPreferenceKey(semanticHighlighting);
+ for (int i = 0, n = fSemanticHighlightings.length; i < n; i++) {
+ SemanticHighlighting semanticHighlighting = fSemanticHighlightings[i];
+ String colorKey = SemanticHighlightings.getColorPreferenceKey(semanticHighlighting);
addColor(colorKey);
- String boldKey= SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting);
- int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
+ String boldKey = SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting);
+ int style = fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
- String italicKey= SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting);
+ String italicKey = SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting);
if (fPreferenceStore.getBoolean(italicKey))
style |= SWT.ITALIC;
- String strikethroughKey= SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting);
+ String strikethroughKey = SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting);
if (fPreferenceStore.getBoolean(strikethroughKey))
style |= TextAttribute.STRIKETHROUGH;
- String underlineKey= SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting);
+ String underlineKey = SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting);
if (fPreferenceStore.getBoolean(underlineKey))
style |= TextAttribute.UNDERLINE;
- boolean isEnabled= fPreferenceStore.getBoolean(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting));
+ boolean isEnabled = fPreferenceStore
+ .getBoolean(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting));
- fHighlightings[i]= new HighlightingStyle(new TextAttribute(fColorManager.getColor(PreferenceConverter.getColor(fPreferenceStore, colorKey)), null, style), isEnabled);
+ fHighlightings[i] = new HighlightingStyle(
+ new TextAttribute(fColorManager.getColor(PreferenceConverter.getColor(fPreferenceStore, colorKey)),
+ null, style),
+ isEnabled);
}
}
@@ -551,11 +561,11 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
* Disposes the semantic highlightings.
*/
protected void disposeHighlightings() {
- for (int i= 0, n= fSemanticHighlightings.length; i < n; i++)
+ for (int i = 0, n = fSemanticHighlightings.length; i < n; i++)
removeColor(SemanticHighlightings.getColorPreferenceKey(fSemanticHighlightings[i]));
- fSemanticHighlightings= null;
- fHighlightings= null;
+ fSemanticHighlightings = null;
+ fHighlightings = null;
}
@Override
@@ -585,122 +595,124 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
if (!isEnabled())
return false;
-
- boolean refreshNeeded= false;
- for (int i= 0, n= fSemanticHighlightings.length; i < n; i++) {
- SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i];
+ boolean refreshNeeded = false;
+
+ for (int i = 0, n = fSemanticHighlightings.length; i < n; i++) {
+ SemanticHighlighting semanticHighlighting = fSemanticHighlightings[i];
- String colorKey= SemanticHighlightings.getColorPreferenceKey(semanticHighlighting);
+ String colorKey = SemanticHighlightings.getColorPreferenceKey(semanticHighlighting);
if (colorKey.equals(event.getProperty())) {
adaptToTextForegroundChange(fHighlightings[i], event);
fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
+ refreshNeeded = true;
continue;
}
- String boldKey= SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting);
+ String boldKey = SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting);
if (boldKey.equals(event.getProperty())) {
adaptToTextStyleChange(fHighlightings[i], event, SWT.BOLD);
fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
+ refreshNeeded = true;
continue;
}
- String italicKey= SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting);
+ String italicKey = SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting);
if (italicKey.equals(event.getProperty())) {
adaptToTextStyleChange(fHighlightings[i], event, SWT.ITALIC);
fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
+ refreshNeeded = true;
continue;
}
- String strikethroughKey= SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting);
+ String strikethroughKey = SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting);
if (strikethroughKey.equals(event.getProperty())) {
adaptToTextStyleChange(fHighlightings[i], event, TextAttribute.STRIKETHROUGH);
fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
+ refreshNeeded = true;
continue;
}
- String underlineKey= SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting);
+ String underlineKey = SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting);
if (underlineKey.equals(event.getProperty())) {
adaptToTextStyleChange(fHighlightings[i], event, TextAttribute.UNDERLINE);
fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
+ refreshNeeded = true;
continue;
}
- String enabledKey= SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting);
+ String enabledKey = SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting);
if (enabledKey.equals(event.getProperty())) {
adaptToEnablementChange(fHighlightings[i], event);
fPresenter.highlightingStyleChanged(fHighlightings[i]);
- refreshNeeded= true;
+ refreshNeeded = true;
continue;
}
}
-
+
if (refreshNeeded && fReconciler != null)
fReconciler.refresh();
-
+
return refreshNeeded;
}
protected void adaptToEnablementChange(HighlightingStyle highlighting, PropertyChangeEvent event) {
- Object value= event.getNewValue();
+ Object value = event.getNewValue();
boolean eventValue;
if (value instanceof Boolean)
- eventValue= ((Boolean) value).booleanValue();
+ eventValue = ((Boolean) value).booleanValue();
else if (IPreferenceStore.TRUE.equals(value))
- eventValue= true;
+ eventValue = true;
else
- eventValue= false;
+ eventValue = false;
highlighting.setEnabled(eventValue);
}
protected void adaptToTextForegroundChange(HighlightingStyle highlighting, PropertyChangeEvent event) {
- RGB rgb= null;
+ RGB rgb = null;
- Object value= event.getNewValue();
+ Object value = event.getNewValue();
if (value instanceof RGB)
- rgb= (RGB) value;
+ rgb = (RGB) value;
else if (value instanceof String)
- rgb= StringConverter.asRGB((String) value);
+ rgb = StringConverter.asRGB((String) value);
if (rgb != null) {
- String property= event.getProperty();
- Color color= fColorManager.getColor(property);
+ String property = event.getProperty();
+ Color color = fColorManager.getColor(property);
if ((color == null || !rgb.equals(color.getRGB()))) {
fColorManager.unbindColor(property);
fColorManager.bindColor(property, rgb);
- color= fColorManager.getColor(property);
+ color = fColorManager.getColor(property);
}
- TextAttribute oldAttr= highlighting.getTextAttribute();
+ TextAttribute oldAttr = highlighting.getTextAttribute();
highlighting.setTextAttribute(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
}
}
- protected void adaptToTextStyleChange(HighlightingStyle highlighting, PropertyChangeEvent event, int styleAttribute) {
- boolean eventValue= false;
- Object value= event.getNewValue();
+ protected void adaptToTextStyleChange(HighlightingStyle highlighting, PropertyChangeEvent event,
+ int styleAttribute) {
+ boolean eventValue = false;
+ Object value = event.getNewValue();
if (value instanceof Boolean)
- eventValue= ((Boolean) value).booleanValue();
+ eventValue = ((Boolean) value).booleanValue();
else if (IPreferenceStore.TRUE.equals(value))
- eventValue= true;
+ eventValue = true;
- TextAttribute oldAttr= highlighting.getTextAttribute();
- boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute;
+ TextAttribute oldAttr = highlighting.getTextAttribute();
+ boolean activeValue = (oldAttr.getStyle() & styleAttribute) == styleAttribute;
if (activeValue != eventValue)
- highlighting.setTextAttribute(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
+ highlighting.setTextAttribute(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(),
+ eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
}
private void addColor(String colorKey) {
if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) {
- RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey);
+ RGB rgb = PreferenceConverter.getColor(fPreferenceStore, colorKey);
fColorManager.unbindColor(colorKey);
fColorManager.bindColor(colorKey, rgb);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java
index 0d86209ad64..4a6c9094570 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java
@@ -42,7 +42,7 @@ import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
/**
* Semantic highlighting presenter - UI thread implementation.
* Cloned from JDT.
- *
+ *
* @since 4.0
*/
public class SemanticHighlightingPresenter implements ITextPresentationListener, ITextInputListener, IDocumentListener {
@@ -59,29 +59,29 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param category the new category.
*/
public HighlightingPositionUpdater(String category) {
- fCategory= category;
+ fCategory = category;
}
@Override
public void update(DocumentEvent event) {
- int eventOffset= event.getOffset();
- int eventOldLength= event.getLength();
- int eventEnd= eventOffset + eventOldLength;
+ int eventOffset = event.getOffset();
+ int eventOldLength = event.getLength();
+ int eventEnd = eventOffset + eventOldLength;
try {
- Position[] positions= event.getDocument().getPositions(fCategory);
+ Position[] positions = event.getDocument().getPositions(fCategory);
- for (int i= 0; i != positions.length; i++) {
- HighlightedPosition position= (HighlightedPosition) positions[i];
+ for (int i = 0; i != positions.length; i++) {
+ HighlightedPosition position = (HighlightedPosition) positions[i];
// Also update deleted positions because they get deleted by the background
// thread and removed/invalidated only in the UI runnable.
-// if (position.isDeleted())
-// continue;
+ // if (position.isDeleted())
+ // continue;
- int offset= position.getOffset();
- int length= position.getLength();
- int end= offset + length;
+ int offset = position.getOffset();
+ int length = position.getLength();
+ int end = offset + length;
if (offset > eventEnd) {
updateWithPrecedingEvent(position, event);
@@ -109,9 +109,9 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param event The event
*/
private void updateWithPrecedingEvent(HighlightedPosition position, DocumentEvent event) {
- String newText= event.getText();
- int eventNewLength= newText != null ? newText.length() : 0;
- int deltaLength= eventNewLength - event.getLength();
+ String newText = event.getText();
+ int eventNewLength = newText != null ? newText.length() : 0;
+ int deltaLength = eventNewLength - event.getLength();
position.setOffset(position.getOffset() + deltaLength);
}
@@ -132,31 +132,31 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param event The event
*/
private void updateWithIncludedEvent(HighlightedPosition position, DocumentEvent event) {
- int eventOffset= event.getOffset();
- String newText= event.getText();
+ int eventOffset = event.getOffset();
+ String newText = event.getText();
if (newText == null)
- newText= ""; //$NON-NLS-1$
- int eventNewLength= newText.length();
+ newText = ""; //$NON-NLS-1$
+ int eventNewLength = newText.length();
- int deltaLength= eventNewLength - event.getLength();
+ int deltaLength = eventNewLength - event.getLength();
- int offset= position.getOffset();
- int length= position.getLength();
- int end= offset + length;
+ int offset = position.getOffset();
+ int length = position.getLength();
+ int end = offset + length;
- int includedLength= 0;
+ int includedLength = 0;
while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
includedLength++;
if (includedLength == eventNewLength) {
position.setLength(length + deltaLength);
} else {
- int newLeftLength= eventOffset - offset + includedLength;
+ int newLeftLength = eventOffset - offset + includedLength;
- int excludedLength= eventNewLength;
+ int excludedLength = eventNewLength;
while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1)))
excludedLength--;
- int newRightOffset= eventOffset + excludedLength;
- int newRightLength= end + deltaLength - newRightOffset;
+ int newRightOffset = eventOffset + excludedLength;
+ int newRightLength = end + deltaLength - newRightOffset;
if (newRightLength == 0) {
position.setLength(newLeftLength);
@@ -179,12 +179,12 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param event The event
*/
private void updateWithOverEndEvent(HighlightedPosition position, DocumentEvent event) {
- String newText= event.getText();
+ String newText = event.getText();
if (newText == null)
- newText= ""; //$NON-NLS-1$
- int eventNewLength= newText.length();
+ newText = ""; //$NON-NLS-1$
+ int eventNewLength = newText.length();
- int includedLength= 0;
+ int includedLength = 0;
while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
includedLength++;
position.setLength(event.getOffset() - position.getOffset() + includedLength);
@@ -198,19 +198,19 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param event The event
*/
private void updateWithOverStartEvent(HighlightedPosition position, DocumentEvent event) {
- int eventOffset= event.getOffset();
- int eventEnd= eventOffset + event.getLength();
+ int eventOffset = event.getOffset();
+ int eventEnd = eventOffset + event.getLength();
- String newText= event.getText();
+ String newText = event.getText();
if (newText == null)
- newText= ""; //$NON-NLS-1$
- int eventNewLength= newText.length();
+ newText = ""; //$NON-NLS-1$
+ int eventNewLength = newText.length();
- int excludedLength= eventNewLength;
+ int excludedLength = eventNewLength;
while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1)))
excludedLength--;
- int deleted= eventEnd - position.getOffset();
- int inserted= eventNewLength - excludedLength;
+ int deleted = eventEnd - position.getOffset();
+ int inserted = eventNewLength - excludedLength;
position.update(eventOffset + excludedLength, position.getLength() - deleted + inserted);
}
@@ -227,7 +227,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/** Position updater */
- private IPositionUpdater fPositionUpdater= new HighlightingPositionUpdater(getPositionCategory());
+ private IPositionUpdater fPositionUpdater = new HighlightingPositionUpdater(getPositionCategory());
/** The source viewer this semantic highlighting reconciler is installed on */
private CSourceViewer fSourceViewer;
@@ -235,12 +235,12 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
private CPresentationReconciler fPresentationReconciler;
/** UI's current highlighted positions - can contain <code>null</code> elements */
- private List<HighlightedPosition> fPositions= new ArrayList<HighlightedPosition>();
+ private List<HighlightedPosition> fPositions = new ArrayList<HighlightedPosition>();
/** UI position lock */
- private Object fPositionLock= new Object();
+ private Object fPositionLock = new Object();
/** <code>true</code> iff the current reconcile is canceled. */
- private boolean fIsCanceled= false;
+ private boolean fIsCanceled = false;
/**
* Creates and returns a new highlighted position with the given offset, length and highlighting.
@@ -257,7 +257,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
// TODO: reuse deleted positions
return new HighlightedPosition(offset, length, style, fPositionUpdater);
}
-
+
/**
* Adds all current positions to the given list.
* <p>
@@ -282,37 +282,39 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param removedPositions the removed positions
* @return the text presentation or <code>null</code>, if reconciliation should be canceled
*/
- public TextPresentation createPresentation(List<? extends Position> addedPositions, List<? extends Position> removedPositions) {
- CSourceViewer sourceViewer= fSourceViewer;
- CPresentationReconciler presentationReconciler= fPresentationReconciler;
+ public TextPresentation createPresentation(List<? extends Position> addedPositions,
+ List<? extends Position> removedPositions) {
+ CSourceViewer sourceViewer = fSourceViewer;
+ CPresentationReconciler presentationReconciler = fPresentationReconciler;
if (sourceViewer == null || presentationReconciler == null)
return null;
if (isCanceled())
return null;
- IDocument document= sourceViewer.getDocument();
+ IDocument document = sourceViewer.getDocument();
if (document == null)
return null;
- int minStart= Integer.MAX_VALUE;
- int maxEnd= Integer.MIN_VALUE;
- for (int i= 0, n= removedPositions.size(); i < n; i++) {
- Position position= removedPositions.get(i);
- int offset= position.getOffset();
- minStart= Math.min(minStart, offset);
- maxEnd= Math.max(maxEnd, offset + position.getLength());
+ int minStart = Integer.MAX_VALUE;
+ int maxEnd = Integer.MIN_VALUE;
+ for (int i = 0, n = removedPositions.size(); i < n; i++) {
+ Position position = removedPositions.get(i);
+ int offset = position.getOffset();
+ minStart = Math.min(minStart, offset);
+ maxEnd = Math.max(maxEnd, offset + position.getLength());
}
- for (int i= 0, n= addedPositions.size(); i < n; i++) {
- Position position= addedPositions.get(i);
- int offset= position.getOffset();
- minStart= Math.min(minStart, offset);
- maxEnd= Math.max(maxEnd, offset + position.getLength());
+ for (int i = 0, n = addedPositions.size(); i < n; i++) {
+ Position position = addedPositions.get(i);
+ int offset = position.getOffset();
+ minStart = Math.min(minStart, offset);
+ maxEnd = Math.max(maxEnd, offset + position.getLength());
}
if (minStart < maxEnd)
try {
- return presentationReconciler.createRepairDescription(new Region(minStart, maxEnd - minStart), document);
+ return presentationReconciler.createRepairDescription(new Region(minStart, maxEnd - minStart),
+ document);
} catch (RuntimeException e) {
// Assume concurrent modification from UI thread
}
@@ -330,18 +332,20 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param removedPositions the removed positions
* @return the runnable or <code>null</code>, if reconciliation should be canceled
*/
- public Runnable createUpdateRunnable(final TextPresentation textPresentation, List<HighlightedPosition> addedPositions, List<HighlightedPosition> removedPositions) {
+ public Runnable createUpdateRunnable(final TextPresentation textPresentation,
+ List<HighlightedPosition> addedPositions, List<HighlightedPosition> removedPositions) {
if (fSourceViewer == null || textPresentation == null)
return null;
// TODO: do clustering of positions and post multiple fast runnables
- final HighlightedPosition[] added= addedPositions.toArray(new HighlightedPosition[addedPositions.size()]);
- final HighlightedPosition[] removed= removedPositions.toArray(new HighlightedPosition[removedPositions.size()]);
+ final HighlightedPosition[] added = addedPositions.toArray(new HighlightedPosition[addedPositions.size()]);
+ final HighlightedPosition[] removed = removedPositions
+ .toArray(new HighlightedPosition[removedPositions.size()]);
if (isCanceled())
return null;
- Runnable runnable= new Runnable() {
+ Runnable runnable = new Runnable() {
@Override
public void run() {
updatePresentation(textPresentation, added, removed);
@@ -362,32 +366,33 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param addedPositions the added positions
* @param removedPositions the removed positions
*/
- public void updatePresentation(TextPresentation textPresentation, HighlightedPosition[] addedPositions, HighlightedPosition[] removedPositions) {
+ public void updatePresentation(TextPresentation textPresentation, HighlightedPosition[] addedPositions,
+ HighlightedPosition[] removedPositions) {
if (fSourceViewer == null)
return;
-// checkOrdering("added positions: ", Arrays.asList(addedPositions)); //$NON-NLS-1$
-// checkOrdering("removed positions: ", Arrays.asList(removedPositions)); //$NON-NLS-1$
-// checkOrdering("old positions: ", fPositions); //$NON-NLS-1$
+ // checkOrdering("added positions: ", Arrays.asList(addedPositions)); //$NON-NLS-1$
+ // checkOrdering("removed positions: ", Arrays.asList(removedPositions)); //$NON-NLS-1$
+ // checkOrdering("old positions: ", fPositions); //$NON-NLS-1$
// TODO: double-check consistency with document.getPositions(...)
// TODO: reuse removed positions
if (isCanceled())
return;
- IDocument document= fSourceViewer.getDocument();
+ IDocument document = fSourceViewer.getDocument();
if (document == null)
return;
- String positionCategory= getPositionCategory();
+ String positionCategory = getPositionCategory();
- List<HighlightedPosition> removedPositionsList= Arrays.asList(removedPositions);
+ List<HighlightedPosition> removedPositionsList = Arrays.asList(removedPositions);
try {
synchronized (fPositionLock) {
- List<HighlightedPosition> oldPositions= fPositions;
- int newSize= Math.max(fPositions.size() + addedPositions.length - removedPositions.length, 10);
-
+ List<HighlightedPosition> oldPositions = fPositions;
+ int newSize = Math.max(fPositions.size() + addedPositions.length - removedPositions.length, 10);
+
/*
* The following loop is a kind of merge sort: it merges two List<Position>, each
* sorted by position.offset, into one new list. The first of the two is the
@@ -395,48 +400,48 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* removed on the fly. The second of two is the list of added positions. The result
* is stored in newPositions.
*/
- List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(newSize);
- HighlightedPosition position= null;
- HighlightedPosition addedPosition= null;
- for (int i= 0, j= 0, n= oldPositions.size(), m= addedPositions.length;
- i < n || position != null || j < m || addedPosition != null;) {
+ List<HighlightedPosition> newPositions = new ArrayList<HighlightedPosition>(newSize);
+ HighlightedPosition position = null;
+ HighlightedPosition addedPosition = null;
+ for (int i = 0, j = 0, n = oldPositions.size(), m = addedPositions.length; i < n || position != null
+ || j < m || addedPosition != null;) {
// loop variant: i + j < old(i + j)
-
+
// a) find the next non-deleted Position from the old list
while (position == null && i < n) {
- position= oldPositions.get(i++);
+ position = oldPositions.get(i++);
if (position.isDeleted() || contain(removedPositionsList, position)) {
document.removePosition(positionCategory, position);
- position= null;
+ position = null;
}
}
-
+
// b) find the next Position from the added list
if (addedPosition == null && j < m) {
- addedPosition= addedPositions[j++];
+ addedPosition = addedPositions[j++];
document.addPosition(positionCategory, addedPosition);
}
-
+
// c) merge: add the next of position/addedPosition with the lower offset
if (position != null) {
if (addedPosition != null)
if (position.getOffset() <= addedPosition.getOffset()) {
newPositions.add(position);
- position= null;
+ position = null;
} else {
newPositions.add(addedPosition);
- addedPosition= null;
+ addedPosition = null;
}
else {
newPositions.add(position);
- position= null;
+ position = null;
}
} else if (addedPosition != null) {
newPositions.add(addedPosition);
- addedPosition= null;
+ addedPosition = null;
}
}
- fPositions= newPositions;
+ fPositions = newPositions;
}
} catch (BadPositionCategoryException e) {
// Should not happen
@@ -445,7 +450,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
// Should not happen
CUIPlugin.log(e);
}
-// checkOrdering("new positions: ", fPositions); //$NON-NLS-1$
+ // checkOrdering("new positions: ", fPositions); //$NON-NLS-1$
if (textPresentation != null)
fSourceViewer.changeTextPresentation(textPresentation, false);
@@ -453,14 +458,14 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
fSourceViewer.invalidateTextPresentation();
}
-// private void checkOrdering(String s, List positions) {
-// Position previous= null;
-// for (int i= 0, n= positions.size(); i < n; i++) {
-// Position current= (Position) positions.get(i);
-// if (previous != null && previous.getOffset() + previous.getLength() > current.getOffset())
-// return;
-// }
-// }
+ // private void checkOrdering(String s, List positions) {
+ // Position previous= null;
+ // for (int i= 0, n= positions.size(); i < n; i++) {
+ // Position current= (Position) positions.get(i);
+ // if (previous != null && previous.getOffset() + previous.getLength() > current.getOffset())
+ // return;
+ // }
+ // }
/**
* Returns <code>true</code> iff the positions contain the position.
@@ -479,10 +484,10 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @return the index
*/
private int indexOf(List<? extends Position> positions, Position position) {
- int index= computeIndexAtOffset(positions, position.getOffset());
- int size= positions.size();
+ int index = computeIndexAtOffset(positions, position.getOffset());
+ int size = positions.size();
while (index < size) {
- if (positions.get(index) == position)
+ if (positions.get(index) == position)
return index;
index++;
}
@@ -495,7 +500,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param position The position for insertion
*/
private void insertPosition(HighlightedPosition position) {
- int i= computeIndexAfterOffset(fPositions, position.getOffset());
+ int i = computeIndexAfterOffset(fPositions, position.getOffset());
fPositions.add(i, position);
}
@@ -507,15 +512,15 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @return the index of the last position with an offset greater than the given offset
*/
private int computeIndexAfterOffset(List<? extends Position> positions, int offset) {
- int i= -1;
- int j= positions.size();
+ int i = -1;
+ int j = positions.size();
while (j - i > 1) {
- int k= (i + j) >> 1;
- Position position= positions.get(k);
+ int k = (i + j) >> 1;
+ Position position = positions.get(k);
if (position.getOffset() > offset)
- j= k;
+ j = k;
else
- i= k;
+ i = k;
}
return j;
}
@@ -528,37 +533,37 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @return the index of the last position with an offset equal or greater than the given offset
*/
private int computeIndexAtOffset(List<? extends Position> positions, int offset) {
- int i= -1;
- int j= positions.size();
+ int i = -1;
+ int j = positions.size();
while (j - i > 1) {
- int k= (i + j) >> 1;
- Position position= positions.get(k);
+ int k = (i + j) >> 1;
+ Position position = positions.get(k);
if (position.getOffset() >= offset)
- j= k;
+ j = k;
else
- i= k;
+ i = k;
}
return j;
}
@Override
public void applyTextPresentation(TextPresentation textPresentation) {
- IRegion region= textPresentation.getExtent();
- int i= computeIndexAtOffset(fPositions, region.getOffset());
- int n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
+ IRegion region = textPresentation.getExtent();
+ int i = computeIndexAtOffset(fPositions, region.getOffset());
+ int n = computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
if (n - i > 2) {
- List<StyleRange> ranges= new ArrayList<StyleRange>(n - i);
+ List<StyleRange> ranges = new ArrayList<StyleRange>(n - i);
for (; i < n; i++) {
- HighlightedPosition position= fPositions.get(i);
+ HighlightedPosition position = fPositions.get(i);
if (!position.isDeleted())
ranges.add(position.createStyleRange());
}
- StyleRange[] array= new StyleRange[ranges.size()];
- array= ranges.toArray(array);
+ StyleRange[] array = new StyleRange[ranges.size()];
+ array = ranges.toArray(array);
textPresentation.replaceStyleRanges(array);
} else {
for (; i < n; i++) {
- HighlightedPosition position= fPositions.get(i);
+ HighlightedPosition position = fPositions.get(i);
if (!position.isDeleted())
textPresentation.replaceStyleRange(position.createStyleRange());
}
@@ -593,7 +598,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* </p>
*/
public boolean isCanceled() {
- IDocument document= fSourceViewer != null ? fSourceViewer.getDocument() : null;
+ IDocument document = fSourceViewer != null ? fSourceViewer.getDocument() : null;
if (document == null)
return fIsCanceled;
@@ -608,14 +613,14 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param isCanceled <code>true</code> iff the current reconcile is canceled
*/
public void setCanceled(boolean isCanceled) {
- IDocument document= fSourceViewer != null ? fSourceViewer.getDocument() : null;
+ IDocument document = fSourceViewer != null ? fSourceViewer.getDocument() : null;
if (document == null) {
- fIsCanceled= isCanceled;
+ fIsCanceled = isCanceled;
return;
}
synchronized (getLockObject(document)) {
- fIsCanceled= isCanceled;
+ fIsCanceled = isCanceled;
}
}
@@ -625,7 +630,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
*/
private Object getLockObject(IDocument document) {
if (document instanceof ISynchronizable) {
- Object lock= ((ISynchronizable)document).getLockObject();
+ Object lock = ((ISynchronizable) document).getLockObject();
if (lock != null)
return lock;
}
@@ -642,8 +647,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* should not be called
*/
public void install(CSourceViewer sourceViewer, CPresentationReconciler backgroundPresentationReconciler) {
- fSourceViewer= sourceViewer;
- fPresentationReconciler= backgroundPresentationReconciler;
+ fSourceViewer = sourceViewer;
+ fPresentationReconciler = backgroundPresentationReconciler;
fSourceViewer.prependTextPresentationListener(this);
fSourceViewer.addTextInputListener(this);
@@ -663,7 +668,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
resetState();
fSourceViewer.removeTextInputListener(this);
- fSourceViewer= null;
+ fSourceViewer = null;
}
}
@@ -673,8 +678,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param highlighting The highlighting
*/
public void highlightingStyleChanged(HighlightingStyle highlighting) {
- for (int i= 0, n= fPositions.size(); i < n; i++) {
- HighlightedPosition position= fPositions.get(i);
+ for (int i = 0, n = fPositions.size(); i < n; i++) {
+ HighlightedPosition position = fPositions.get(i);
if (position.getHighlighting() == highlighting)
fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
}
@@ -687,8 +692,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
if (fPositions.size() > 1000) {
fSourceViewer.invalidateTextPresentation();
} else {
- for (int i= 0, n= fPositions.size(); i < n; i++) {
- Position position= fPositions.get(i);
+ for (int i = 0, n = fPositions.size(); i < n; i++) {
+ Position position = fPositions.get(i);
fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
}
}
@@ -703,15 +708,15 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param highlighting
*/
private void addPositionFromUI(int offset, int length, HighlightingStyle highlighting) {
- HighlightedPosition position= createHighlightedPosition(offset, length, highlighting);
+ HighlightedPosition position = createHighlightedPosition(offset, length, highlighting);
synchronized (fPositionLock) {
insertPosition(position);
}
- IDocument document= fSourceViewer.getDocument();
+ IDocument document = fSourceViewer.getDocument();
if (document == null)
return;
- String positionCategory= getPositionCategory();
+ String positionCategory = getPositionCategory();
try {
document.addPosition(positionCategory, position);
} catch (BadLocationException e) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java
index f3ae09eef30..11f8258f1ed 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java
@@ -63,11 +63,11 @@ import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
/**
* Semantic highlighting reconciler - Background thread implementation.
* Cloned from JDT.
- *
+ *
* @since 4.0
*/
public class SemanticHighlightingReconciler implements ICReconcilingListener {
-
+
/**
* Collects positions from the AST.
* This abstract version exists so it can be reused by the previewer widget.
@@ -76,34 +76,33 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
public static abstract class AbstractPositionCollector extends ASTVisitor {
private SemanticHighlighting[] fHighlightings;
private HighlightingStyle[] fHighlightingStyles;
-
+
/** The semantic token */
- private SemanticToken fToken= new SemanticToken();
-
+ private SemanticToken fToken = new SemanticToken();
+
private class PositionCollectorRequirements {
public boolean visitImplicitNames = false;
public boolean visitExpressions = false;
}
-
- public AbstractPositionCollector(SemanticHighlighting[] highlightings,
- HighlightingStyle[] highlightingStyles) {
+
+ public AbstractPositionCollector(SemanticHighlighting[] highlightings, HighlightingStyle[] highlightingStyles) {
fHighlightings = highlightings;
fHighlightingStyles = highlightingStyles;
-
+
PositionCollectorRequirements requirements = getRequirements();
-
- shouldVisitTranslationUnit= true;
- shouldVisitNames= true;
- shouldVisitDeclarations= true;
- shouldVisitExpressions= requirements.visitExpressions;
- shouldVisitStatements= true;
- shouldVisitDeclarators= true;
- shouldVisitNamespaces= true;
- shouldVisitVirtSpecifiers= true;
+
+ shouldVisitTranslationUnit = true;
+ shouldVisitNames = true;
+ shouldVisitDeclarations = true;
+ shouldVisitExpressions = requirements.visitExpressions;
+ shouldVisitStatements = true;
+ shouldVisitDeclarators = true;
+ shouldVisitNamespaces = true;
+ shouldVisitVirtSpecifiers = true;
shouldVisitImplicitNames = requirements.visitImplicitNames;
shouldVisitImplicitNameAlternates = requirements.visitImplicitNames;
}
-
+
private PositionCollectorRequirements getRequirements() {
PositionCollectorRequirements result = new PositionCollectorRequirements();
for (int i = 0; i < fHighlightings.length; i++) {
@@ -123,7 +122,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
@Override
public int visit(IASTTranslationUnit tu) {
// Visit macro definitions.
- IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
+ IASTPreprocessorMacroDefinition[] macroDefs = tu.getMacroDefinitions();
for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
if (macroDef.isPartOfTranslationUnitFile()) {
visitNode(macroDef.getName());
@@ -131,12 +130,12 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
// Visit macro expansions.
- IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions();
+ IASTPreprocessorMacroExpansion[] macroExps = tu.getMacroExpansions();
for (IASTPreprocessorMacroExpansion macroExp : macroExps) {
if (macroExp.isPartOfTranslationUnitFile()) {
- IASTName macroRef= macroExp.getMacroReference();
+ IASTName macroRef = macroExp.getMacroReference();
visitNode(macroRef);
- IASTName[] nestedMacroRefs= macroExp.getNestedMacroReferences();
+ IASTName[] nestedMacroRefs = macroExp.getNestedMacroReferences();
for (IASTName nestedMacroRef : nestedMacroRefs) {
visitNode(nestedMacroRef);
}
@@ -157,18 +156,18 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
@Override
public int leave(IASTDeclaration declaration) {
-// if (!shouldVisitCatchHandlers && declaration instanceof IASTFunctionDefinition) {
-// shouldVisitCatchHandlers= true;
-// IASTFunctionDefinition functionDef= (IASTFunctionDefinition) declaration;
-// ICPPASTFunctionTryBlockDeclarator declarator= (ICPPASTFunctionTryBlockDeclarator) functionDef.getDeclarator();
-// ICPPASTCatchHandler[] catchHandlers= declarator.getCatchHandlers();
-// for (ICPPASTCatchHandler catchHandler : catchHandlers) {
-// catchHandler.accept(this);
-// }
-// }
+ // if (!shouldVisitCatchHandlers && declaration instanceof IASTFunctionDefinition) {
+ // shouldVisitCatchHandlers= true;
+ // IASTFunctionDefinition functionDef= (IASTFunctionDefinition) declaration;
+ // ICPPASTFunctionTryBlockDeclarator declarator= (ICPPASTFunctionTryBlockDeclarator) functionDef.getDeclarator();
+ // ICPPASTCatchHandler[] catchHandlers= declarator.getCatchHandlers();
+ // for (ICPPASTCatchHandler catchHandler : catchHandlers) {
+ // catchHandler.accept(this);
+ // }
+ // }
return PROCESS_CONTINUE;
}
-
+
@Override
public int visit(ICPPASTNamespaceDefinition namespace) {
if (!namespace.isPartOfTranslationUnitFile()) {
@@ -179,17 +178,17 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
@Override
public int visit(IASTDeclarator declarator) {
-// if (declarator instanceof ICPPASTFunctionTryBlockDeclarator) {
-// shouldVisitCatchHandlers= false;
-// }
+ // if (declarator instanceof ICPPASTFunctionTryBlockDeclarator) {
+ // shouldVisitCatchHandlers= false;
+ // }
return PROCESS_CONTINUE;
}
@Override
public int visit(IASTStatement statement) {
-// if (!shouldVisitCatchHandlers && statement instanceof ICPPASTCatchHandler) {
-// return PROCESS_SKIP;
-// }
+ // if (!shouldVisitCatchHandlers && statement instanceof ICPPASTCatchHandler) {
+ // return PROCESS_SKIP;
+ // }
return PROCESS_CONTINUE;
}
@@ -200,19 +199,19 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
return PROCESS_CONTINUE;
}
-
+
@Override
public int visit(ICPPASTVirtSpecifier virtSpecifier) {
visitNode(virtSpecifier);
return PROCESS_CONTINUE;
}
-
+
@Override
public int visit(ICPPASTClassVirtSpecifier classVirtSpecifier) {
visitNode(classVirtSpecifier);
return PROCESS_CONTINUE;
}
-
+
@Override
public int visit(IASTExpression expression) {
if (visitNode(expression)) {
@@ -220,14 +219,14 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
return PROCESS_CONTINUE;
}
-
+
private boolean visitNode(IASTNode node) {
try {
CPPSemantics.pushLookupPoint(node);
- boolean consumed= false;
+ boolean consumed = false;
fToken.update(node);
- for (int i= 0, n= fHighlightings.length; i < n; ++i) {
- SemanticHighlighting semanticHighlighting= fHighlightings[i];
+ for (int i = 0, n = fHighlightings.length; i < n; ++i) {
+ SemanticHighlighting semanticHighlighting = fHighlightings[i];
// If the semantic highlighting doesn't color expressions, don't bother
// passing it one to begin with.
if (node instanceof IASTExpression && !semanticHighlighting.requiresExpressions()) {
@@ -238,7 +237,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
if (location != null) {
highlightLocation(location, fHighlightingStyles[i]);
}
- consumed= true;
+ consumed = true;
break;
}
}
@@ -251,7 +250,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
/**
* Gets the location to highlight for a given node.
- *
+ *
* @param node the node
*/
private IASTNodeLocation getLocationToHighlight(IASTNode node) {
@@ -269,12 +268,12 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
} else {
// Fallback in case no image location available.
// Only use the fallback for nodes that are not preprocessor nodes,
- // because in the case of nested macro expansions, a preprocessor node
+ // because in the case of nested macro expansions, a preprocessor node
// can have a node location that is not representative of its actual
// image; such nodes should have an image location (accessed via
// getImageLocation(), above) where appropriate.
if (!(node instanceof ASTPreprocessorName)) {
- IASTNodeLocation[] nodeLocations= node.getNodeLocations();
+ IASTNodeLocation[] nodeLocations = node.getNodeLocations();
if (nodeLocations.length == 1) {
IASTNodeLocation nodeLocation = nodeLocations[0];
if (!(nodeLocation instanceof IASTMacroExpansionLocation)) {
@@ -285,16 +284,16 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
return null;
}
-
+
/**
* Highlights the given node location with the given highlighting.
- *
+ *
* @param nodeLocation the node location to highlight
* @param highlightingStyle the highlighting style to apply
*/
private void highlightLocation(IASTNodeLocation nodeLocation, HighlightingStyle highlightingStyle) {
- int offset= nodeLocation.getNodeOffset();
- int length= nodeLocation.getNodeLength();
+ int offset = nodeLocation.getNodeOffset();
+ int length = nodeLocation.getNodeLength();
if (offset > -1 && length > 0) {
addPosition(offset, length, highlightingStyle);
}
@@ -302,29 +301,29 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
/**
* Adds a position with the given range and highlighting iff it does not exist already.
- *
+ *
* @param offset The range offset
* @param length The range length
* @param highlightingStyle The highlighting style
*/
protected abstract void addPosition(int offset, int length, HighlightingStyle highlightingStyle);
}
-
+
private class PositionCollector extends AbstractPositionCollector {
public PositionCollector() {
super(fJobSemanticHighlightings, fJobHighlightings);
}
@Override
- protected void addPosition(int offset, int length, HighlightingStyle highlightingStyle) {
- boolean isExisting= false;
+ protected void addPosition(int offset, int length, HighlightingStyle highlightingStyle) {
+ boolean isExisting = false;
// TODO: use binary search
- for (int i= 0, n= fRemovedPositions.size(); i < n; i++) {
- HighlightedPosition position= fRemovedPositions.get(i);
+ for (int i = 0, n = fRemovedPositions.size(); i < n; i++) {
+ HighlightedPosition position = fRemovedPositions.get(i);
if (position == null)
continue;
if (position.isEqual(offset, length, highlightingStyle)) {
- isExisting= true;
+ isExisting = true;
fRemovedPositions.set(i, null);
fNOfRemovedPositions--;
break;
@@ -332,7 +331,8 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
if (!isExisting) {
- HighlightedPosition position= fJobPresenter.createHighlightedPosition(offset, length, highlightingStyle);
+ HighlightedPosition position = fJobPresenter.createHighlightedPosition(offset, length,
+ highlightingStyle);
fAddedPositions.add(position);
}
}
@@ -348,23 +348,23 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
private HighlightingStyle[] fHighlightings;
/** Background job's added highlighted positions */
- protected List<HighlightedPosition> fAddedPositions= new ArrayList<HighlightedPosition>();
+ protected List<HighlightedPosition> fAddedPositions = new ArrayList<HighlightedPosition>();
/** Background job's removed highlighted positions */
- protected List<HighlightedPosition> fRemovedPositions= new ArrayList<HighlightedPosition>();
+ protected List<HighlightedPosition> fRemovedPositions = new ArrayList<HighlightedPosition>();
/** Number of removed positions */
protected int fNOfRemovedPositions;
/** Background job */
private Job fJob;
/** Background job lock */
- private final Object fJobLock= new Object();
+ private final Object fJobLock = new Object();
/** Reconcile operation lock. */
- private final Object fReconcileLock= new Object();
+ private final Object fReconcileLock = new Object();
/**
* <code>true</code> if any thread is executing
* <code>reconcile</code>, <code>false</code> otherwise.
*/
- private boolean fIsReconciling= false;
+ private boolean fIsReconciling = false;
/**
* The semantic highlighting presenter - cache for background thread, only valid during
@@ -393,42 +393,42 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
synchronized (fReconcileLock) {
if (fIsReconciling)
return;
- fIsReconciling= true;
+ fIsReconciling = true;
}
- fJobPresenter= fPresenter;
- fJobSemanticHighlightings= fSemanticHighlightings;
- fJobHighlightings= fHighlightings;
-
+ fJobPresenter = fPresenter;
+ fJobSemanticHighlightings = fSemanticHighlightings;
+ fJobHighlightings = fHighlightings;
+
try {
if (fJobPresenter == null || fJobSemanticHighlightings == null || fJobHighlightings == null)
return;
-
+
fJobPresenter.setCanceled(progressMonitor != null && progressMonitor.isCanceled());
-
+
if (ast == null || fJobPresenter.isCanceled())
return;
-
- PositionCollector collector= new PositionCollector();
+
+ PositionCollector collector = new PositionCollector();
startReconcilingPositions();
-
+
if (!fJobPresenter.isCanceled())
reconcilePositions(ast, collector);
-
- TextPresentation textPresentation= null;
+
+ TextPresentation textPresentation = null;
if (!fJobPresenter.isCanceled())
- textPresentation= fJobPresenter.createPresentation(fAddedPositions, fRemovedPositions);
-
+ textPresentation = fJobPresenter.createPresentation(fAddedPositions, fRemovedPositions);
+
if (!fJobPresenter.isCanceled())
updatePresentation(textPresentation, fAddedPositions, fRemovedPositions);
-
+
stopReconcilingPositions();
} finally {
- fJobPresenter= null;
- fJobSemanticHighlightings= null;
- fJobHighlightings= null;
+ fJobPresenter = null;
+ fJobSemanticHighlightings = null;
+ fJobHighlightings = null;
synchronized (fReconcileLock) {
- fIsReconciling= false;
+ fIsReconciling = false;
}
}
}
@@ -438,7 +438,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
*/
protected void startReconcilingPositions() {
fJobPresenter.addAllPositions(fRemovedPositions);
- fNOfRemovedPositions= fRemovedPositions.size();
+ fNOfRemovedPositions = fRemovedPositions.size();
}
/**
@@ -454,14 +454,14 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
} finally {
CPPSemantics.popLookupPoint();
}
- List<HighlightedPosition> oldPositions= fRemovedPositions;
- List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(fNOfRemovedPositions);
- for (int i= 0, n= oldPositions.size(); i < n; i ++) {
- HighlightedPosition current= oldPositions.get(i);
+ List<HighlightedPosition> oldPositions = fRemovedPositions;
+ List<HighlightedPosition> newPositions = new ArrayList<HighlightedPosition>(fNOfRemovedPositions);
+ for (int i = 0, n = oldPositions.size(); i < n; i++) {
+ HighlightedPosition current = oldPositions.get(i);
if (current != null)
newPositions.add(current);
}
- fRemovedPositions= newPositions;
+ fRemovedPositions = newPositions;
// Positions need to be sorted by ascending offset
Collections.sort(fAddedPositions, new Comparator<Position>() {
@Override
@@ -478,24 +478,25 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
* @param addedPositions the added positions
* @param removedPositions the removed positions
*/
- protected void updatePresentation(TextPresentation textPresentation, List<HighlightedPosition> addedPositions, List<HighlightedPosition> removedPositions) {
- Runnable runnable= fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
+ protected void updatePresentation(TextPresentation textPresentation, List<HighlightedPosition> addedPositions,
+ List<HighlightedPosition> removedPositions) {
+ Runnable runnable = fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
if (runnable == null)
return;
- CEditor editor= fEditor;
+ CEditor editor = fEditor;
if (editor == null)
return;
- IWorkbenchPartSite site= editor.getSite();
+ IWorkbenchPartSite site = editor.getSite();
if (site == null)
return;
- Shell shell= site.getShell();
+ Shell shell = site.getShell();
if (shell == null || shell.isDisposed())
return;
- Display display= shell.getDisplay();
+ Display display = shell.getDisplay();
if (display == null || display.isDisposed())
return;
@@ -507,7 +508,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
*/
protected void stopReconcilingPositions() {
fRemovedPositions.clear();
- fNOfRemovedPositions= 0;
+ fNOfRemovedPositions = 0;
fAddedPositions.clear();
}
@@ -519,12 +520,13 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
* @param semanticHighlightings the semantic highlightings
* @param highlightings the highlightings
*/
- public void install(CEditor editor, ISourceViewer sourceViewer, SemanticHighlightingPresenter presenter, SemanticHighlighting[] semanticHighlightings, HighlightingStyle[] highlightings) {
- fPresenter= presenter;
- fSemanticHighlightings= semanticHighlightings;
- fHighlightings= highlightings;
+ public void install(CEditor editor, ISourceViewer sourceViewer, SemanticHighlightingPresenter presenter,
+ SemanticHighlighting[] semanticHighlightings, HighlightingStyle[] highlightings) {
+ fPresenter = presenter;
+ fSemanticHighlightings = semanticHighlightings;
+ fHighlightings = highlightings;
- fEditor= editor;
+ fEditor = editor;
if (fEditor != null) {
fEditor.addReconcileListener(this);
@@ -540,29 +542,29 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
if (fEditor != null) {
fEditor.removeReconcileListener(this);
- fEditor= null;
+ fEditor = null;
}
- fSemanticHighlightings= null;
- fHighlightings= null;
- fPresenter= null;
+ fSemanticHighlightings = null;
+ fHighlightings = null;
+ fPresenter = null;
}
/**
* Schedules a background job for retrieving the AST and reconciling the Semantic Highlighting model.
*/
private void scheduleJob() {
- final ICElement element= fEditor.getInputCElement();
+ final ICElement element = fEditor.getInputCElement();
synchronized (fJobLock) {
- final Job oldJob= fJob;
+ final Job oldJob = fJob;
if (fJob != null) {
fJob.cancel();
- fJob= null;
+ fJob = null;
}
-
+
if (element != null) {
- fJob= new Job(CEditorMessages.SemanticHighlighting_job) {
+ fJob = new Job(CEditorMessages.SemanticHighlighting_job) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
if (oldJob != null) {
@@ -575,25 +577,26 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
-
- final Job me= this;
- ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
- IStatus status= astProvider.runOnAST(element, ASTProvider.WAIT_IF_OPEN, monitor, new ASTCache.ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
- reconciled(ast, true, monitor);
- synchronized (fJobLock) {
- // allow the job to be gc'ed
- if (fJob == me)
- fJob= null;
- }
- return Status.OK_STATUS;
- }
- });
+
+ final Job me = this;
+ ASTProvider astProvider = CUIPlugin.getDefault().getASTProvider();
+ IStatus status = astProvider.runOnAST(element, ASTProvider.WAIT_IF_OPEN, monitor,
+ new ASTCache.ASTRunnable() {
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+ reconciled(ast, true, monitor);
+ synchronized (fJobLock) {
+ // allow the job to be gc'ed
+ if (fJob == me)
+ fJob = null;
+ }
+ return Status.OK_STATUS;
+ }
+ });
return status;
}
};
-// fJob.setSystem(true);
+ // fJob.setSystem(true);
fJob.setPriority(Job.SHORT);
fJob.schedule();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingWithOwnPreference.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingWithOwnPreference.java
index 2eed6550390..64025eb33f3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingWithOwnPreference.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingWithOwnPreference.java
@@ -20,9 +20,9 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.ui.CUIPlugin;
/**
- * A semantic highlighting which has its own preferences for specifying
+ * A semantic highlighting which has its own preferences for specifying
* its color and style.
- *
+ *
* Semantic highlightings not deriving from this class are associated
* with a syntactic highlighting, and use the color and style of that
* syntactic highlighting.
@@ -75,9 +75,8 @@ public abstract class SemanticHighlightingWithOwnPreference extends SemanticHigh
*/
public abstract String getDisplayName();
-
private String getThemeColorKey() {
- return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$
+ return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$
}
/**
@@ -92,8 +91,8 @@ public abstract class SemanticHighlightingWithOwnPreference extends SemanticHigh
if (!PlatformUI.isWorkbenchRunning())
return defaultRGB;
- ColorRegistry registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
- RGB rgb= registry.getRGB(key);
+ ColorRegistry registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
+ RGB rgb = registry.getRGB(key);
if (rgb != null)
return rgb;
return defaultRGB;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java
index 52aca13373c..5ea9a50d12f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java
@@ -113,135 +113,136 @@ public class SemanticHighlightings {
/**
* A named preference part that controls the highlighting of static fields.
*/
- public static final String STATIC_FIELD= "staticField"; //$NON-NLS-1$
+ public static final String STATIC_FIELD = "staticField"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of fields.
*/
- public static final String FIELD= "field"; //$NON-NLS-1$
+ public static final String FIELD = "field"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of method declarations.
*/
- public static final String METHOD_DECLARATION= "methodDeclaration"; //$NON-NLS-1$
+ public static final String METHOD_DECLARATION = "methodDeclaration"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of static method invocations.
*/
- public static final String STATIC_METHOD_INVOCATION= "staticMethod"; //$NON-NLS-1$
+ public static final String STATIC_METHOD_INVOCATION = "staticMethod"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of function declarations.
*/
- public static final String FUNCTION_DECLARATION= "functionDeclaration"; //$NON-NLS-1$
+ public static final String FUNCTION_DECLARATION = "functionDeclaration"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of functions.
*/
- public static final String FUNCTION= "function"; //$NON-NLS-1$
+ public static final String FUNCTION = "function"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of local variables.
*/
- public static final String LOCAL_VARIABLE_DECLARATION= "localVariableDeclaration"; //$NON-NLS-1$
+ public static final String LOCAL_VARIABLE_DECLARATION = "localVariableDeclaration"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of local variable references.
*/
- public static final String LOCAL_VARIABLE= "localVariable"; //$NON-NLS-1$
+ public static final String LOCAL_VARIABLE = "localVariable"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of global variables.
*/
- public static final String GLOBAL_VARIABLE= "globalVariable"; //$NON-NLS-1$
+ public static final String GLOBAL_VARIABLE = "globalVariable"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of parameter variables.
*/
- public static final String PARAMETER_VARIABLE= "parameterVariable"; //$NON-NLS-1$
+ public static final String PARAMETER_VARIABLE = "parameterVariable"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of template parameters.
*/
- public static final String TEMPLATE_PARAMETER= "templateParameter"; //$NON-NLS-1$
+ public static final String TEMPLATE_PARAMETER = "templateParameter"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of methods.
*/
- public static final String METHOD= "method"; //$NON-NLS-1$
+ public static final String METHOD = "method"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of classes.
*/
- public static final String CLASS= "class"; //$NON-NLS-1$
+ public static final String CLASS = "class"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of enums.
*/
- public static final String ENUM= "enum"; //$NON-NLS-1$
+ public static final String ENUM = "enum"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of enum classes.
*/
- public static final String ENUM_CLASS= "enumClass"; //$NON-NLS-1$
+ public static final String ENUM_CLASS = "enumClass"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of macro references.
*/
- public static final String MACRO_REFERENCE= "macroSubstitution"; //$NON-NLS-1$
+ public static final String MACRO_REFERENCE = "macroSubstitution"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of macro definitions.
*/
- public static final String MACRO_DEFINITION= "macroDefinition"; //$NON-NLS-1$
+ public static final String MACRO_DEFINITION = "macroDefinition"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of typedefs.
*/
- public static final String TYPEDEF= "typedef"; //$NON-NLS-1$
+ public static final String TYPEDEF = "typedef"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of namespaces.
*/
- public static final String NAMESPACE= "namespace"; //$NON-NLS-1$
+ public static final String NAMESPACE = "namespace"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of labels.
*/
- public static final String LABEL= "label"; //$NON-NLS-1$
+ public static final String LABEL = "label"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of enumerators.
*/
- public static final String ENUMERATOR= "enumerator"; //$NON-NLS-1$
+ public static final String ENUMERATOR = "enumerator"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of problems.
*/
- public static final String PROBLEM= "problem"; //$NON-NLS-1$
+ public static final String PROBLEM = "problem"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of external SDK.
*/
- public static final String EXTERNAL_SDK= "externalSDK"; //$NON-NLS-1$
+ public static final String EXTERNAL_SDK = "externalSDK"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting of operators that have been overloaded.
*/
- public static final String OVERLOADED_OPERATOR= "overloadedOperator"; //$NON-NLS-1$
-
+ public static final String OVERLOADED_OPERATOR = "overloadedOperator"; //$NON-NLS-1$
+
/**
* A named preference part that controls the highlighting of variables passed by non-const reference.
*/
- public static final String VARIABLE_PASSED_BY_NONCONST_REF= "variablePassedByNonconstRef"; //$NON-NLS-1$
+ public static final String VARIABLE_PASSED_BY_NONCONST_REF = "variablePassedByNonconstRef"; //$NON-NLS-1$
/**
* A named preference part that controls the highlighting UDL suffixes.
*/
- public static final String UDL_SUFFIX = "udlSuffix"; //$NON-NLS-1$
+ public static final String UDL_SUFFIX = "udlSuffix"; //$NON-NLS-1$
/** Init debugging mode */
- private static final boolean DEBUG= Boolean.parseBoolean(Platform.getDebugOption("org.eclipse.cdt.ui/debug/SemanticHighlighting")); //$NON-NLS-1$
+ private static final boolean DEBUG = Boolean
+ .parseBoolean(Platform.getDebugOption("org.eclipse.cdt.ui/debug/SemanticHighlighting")); //$NON-NLS-1$
/**
* Semantic highlightings
@@ -284,9 +285,9 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name instanceof ICPPASTQualifiedName && name.isReference()) {
return false;
}
@@ -294,9 +295,9 @@ public class SemanticHighlightings {
// Variable template instance - do not color the entire template-id.
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof IField && !(binding instanceof IProblemBinding)) {
- return ((IField)binding).isStatic();
+ return ((IField) binding).isStatic();
}
}
return false;
@@ -339,9 +340,9 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name instanceof ICPPASTQualifiedName && name.isReference()) {
return false;
}
@@ -349,7 +350,7 @@ public class SemanticHighlightings {
// Variable template instance - do not color the entire template-id.
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof IField) {
if (binding instanceof ICPPUnknownBinding) {
if (heuristicallyResolve((ICPPUnknownBinding) binding) instanceof IEnumerator) {
@@ -399,26 +400,26 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTImplicitName)
return false;
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (!name.isReference()) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICPPMethod) {
return true;
} else if (binding instanceof IProblemBinding) {
// try to be derive from AST
- node= name.getParent();
+ node = name.getParent();
while (node instanceof IASTName) {
- node= node.getParent();
+ node = node.getParent();
}
if (node instanceof ICPPASTFunctionDeclarator) {
if (name instanceof ICPPASTQualifiedName) {
- ICPPASTQualifiedName qName= (ICPPASTQualifiedName) name;
- ICPPASTNameSpecifier[] qualifier= qName.getQualifier();
+ ICPPASTQualifiedName qName = (ICPPASTQualifiedName) name;
+ ICPPASTNameSpecifier[] qualifier = qName.getQualifier();
if (qualifier.length > 0) {
if (qualifier[qualifier.length - 1].resolveBinding() instanceof ICPPClassType) {
return true;
@@ -426,7 +427,7 @@ public class SemanticHighlightings {
}
} else {
while (node != token.getRoot() && !(node.getParent() instanceof IASTDeclSpecifier)) {
- node= node.getParent();
+ node = node.getParent();
}
if (node instanceof ICPPASTCompositeTypeSpecifier) {
return true;
@@ -476,16 +477,16 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name instanceof ICPPASTQualifiedName) {
return false;
}
if (!name.isReference()) {
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICPPMethod && !(binding instanceof IProblemBinding)) {
return ((ICPPMethod) binding).isStatic();
}
@@ -530,16 +531,16 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTImplicitName)
return false;
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
- boolean qualified = name instanceof ICPPASTQualifiedName;
+ IASTName name = (IASTName) node;
+ boolean qualified = name instanceof ICPPASTQualifiedName;
if (qualified && name.isReference()) {
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICPPMethod) {
return true;
} else if (binding instanceof ICPPDeferredFunction) {
@@ -557,7 +558,7 @@ public class SemanticHighlightings {
}
return false;
}
-
+
private boolean isInheritingConstructorDeclaration(IBinding binding) {
if (!(binding instanceof ICPPUsingDeclaration)) {
return false;
@@ -630,18 +631,18 @@ public class SemanticHighlightings {
return true;
}
// The template-name in a template-id is never a declaration, it's a reference
- // to the template. However, if the template-id itself is a declaration, we want
+ // to the template. However, if the template-id itself is a declaration, we want
// to color the template-name part of it as a declaration.
- if (name.getParent() instanceof ICPPASTTemplateId &&
- name.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME) {
+ if (name.getParent() instanceof ICPPASTTemplateId
+ && name.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME) {
return ((IASTName) name.getParent()).isDeclaration();
}
return false;
}
-
+
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTImplicitName)
return false;
@@ -650,9 +651,9 @@ public class SemanticHighlightings {
if (node instanceof ICPPASTTemplateId) {
return false;
}
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (isDeclaration(name)) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
return true;
} else if (binding instanceof IProblemBinding) {
@@ -660,13 +661,13 @@ public class SemanticHighlightings {
if (name instanceof ICPPASTQualifiedName) {
return false;
}
- node= name.getParent();
+ node = name.getParent();
while (node instanceof IASTName) {
- node= node.getParent();
+ node = node.getParent();
}
if (node instanceof IASTFunctionDeclarator) {
while (node != token.getRoot() && !(node.getParent() instanceof IASTDeclSpecifier)) {
- node= node.getParent();
+ node = node.getParent();
}
if (node instanceof ICPPASTCompositeTypeSpecifier) {
return false;
@@ -716,11 +717,11 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTImplicitName)
return false;
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name instanceof ICPPASTQualifiedName && name.isReference()) {
return false;
}
@@ -728,7 +729,7 @@ public class SemanticHighlightings {
if (name instanceof ICPPASTTemplateId) {
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
return true;
}
@@ -773,14 +774,12 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name.isDeclaration()) {
- IBinding binding= token.getBinding();
- if (binding instanceof IVariable
- && !(binding instanceof IField)
- && !(binding instanceof IParameter)
+ IBinding binding = token.getBinding();
+ if (binding instanceof IVariable && !(binding instanceof IField) && !(binding instanceof IParameter)
&& !(binding instanceof IProblemBinding)) {
if (LocalVariableHighlighting.isLocalVariable((IVariable) binding)) {
return true;
@@ -828,14 +827,12 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name.isReference()) {
- IBinding binding= token.getBinding();
- if (binding instanceof IVariable
- && !(binding instanceof IField)
- && !(binding instanceof IParameter)
+ IBinding binding = token.getBinding();
+ if (binding instanceof IVariable && !(binding instanceof IField) && !(binding instanceof IParameter)
&& !(binding instanceof IProblemBinding)) {
if (isLocalVariable((IVariable) binding)) {
return true;
@@ -846,31 +843,30 @@ public class SemanticHighlightings {
return false;
}
- public static boolean isLocalVariable(IVariable variable) {
- // A variable marked 'extern' declares a global
- // variable even if the declaration is local.
- if (variable.isExtern()) {
- return false;
- }
- try {
- IScope scope= variable.getScope();
- while (scope != null) {
- if (scope instanceof ICPPFunctionScope ||
- scope instanceof ICPPBlockScope ||
- scope instanceof ICFunctionScope) {
- return true;
- }
- try {
- scope= scope.getParent();
- } catch (DOMException e) {
- scope= null;
- }
- }
- } catch (DOMException exc) {
- CUIPlugin.log(exc);
- }
- return false;
- }
+ public static boolean isLocalVariable(IVariable variable) {
+ // A variable marked 'extern' declares a global
+ // variable even if the declaration is local.
+ if (variable.isExtern()) {
+ return false;
+ }
+ try {
+ IScope scope = variable.getScope();
+ while (scope != null) {
+ if (scope instanceof ICPPFunctionScope || scope instanceof ICPPBlockScope
+ || scope instanceof ICFunctionScope) {
+ return true;
+ }
+ try {
+ scope = scope.getParent();
+ } catch (DOMException e) {
+ scope = null;
+ }
+ }
+ } catch (DOMException exc) {
+ CUIPlugin.log(exc);
+ }
+ return false;
+ }
}
/**
@@ -909,9 +905,9 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name instanceof ICPPASTQualifiedName) {
return false;
}
@@ -919,10 +915,8 @@ public class SemanticHighlightings {
// Variable template instance - do not color the entire template-id.
return false;
}
- IBinding binding= token.getBinding();
- if (binding instanceof IVariable
- && !(binding instanceof IField)
- && !(binding instanceof IParameter)
+ IBinding binding = token.getBinding();
+ if (binding instanceof IVariable && !(binding instanceof IField) && !(binding instanceof IParameter)
&& !(binding instanceof ICPPTemplateNonTypeParameter)
&& !(binding instanceof IProblemBinding)) {
if (!LocalVariableHighlighting.isLocalVariable((IVariable) binding)) {
@@ -970,7 +964,7 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof IParameter) {
return true;
}
@@ -1014,9 +1008,9 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICPPTemplateParameter) {
return true;
}
@@ -1061,17 +1055,17 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof ICPPASTQualifiedName || node instanceof ICPPASTTemplateId) {
return false;
}
if (node instanceof IASTImplicitName && node.getParent() instanceof ICPPASTUsingDeclaration) {
- // For names in an inheriting constructor declaration, we want to use the method
- // highlighting (since it's a constructor), not the class highlighting.
+ // For names in an inheriting constructor declaration, we want to use the method
+ // highlighting (since it's a constructor), not the class highlighting.
return false;
}
if (node instanceof IASTName) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICompositeType && !(binding instanceof ICPPTemplateParameter)) {
if (binding instanceof ICPPUnknownBinding) {
if (heuristicallyResolve((ICPPUnknownBinding) binding) instanceof IEnumeration) {
@@ -1121,14 +1115,14 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
if (node instanceof ICPPASTQualifiedName) {
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICPPUnknownBinding) {
- binding= heuristicallyResolve((ICPPUnknownBinding) binding);
+ binding = heuristicallyResolve((ICPPUnknownBinding) binding);
}
if (binding instanceof IEnumeration) {
if (binding instanceof ICPPEnumeration) {
@@ -1177,14 +1171,14 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
if (node instanceof ICPPASTQualifiedName) {
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICPPUnknownBinding) {
- binding= heuristicallyResolve((ICPPUnknownBinding) binding);
+ binding = heuristicallyResolve((ICPPUnknownBinding) binding);
}
if (binding instanceof ICPPEnumeration) {
return ((ICPPEnumeration) binding).isScoped();
@@ -1230,9 +1224,9 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof IMacroBinding) {
- IASTName name= (IASTName)token.getNode();
+ IASTName name = (IASTName) token.getNode();
if (name.isReference()) {
return true;
}
@@ -1277,9 +1271,9 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof IMacroBinding) {
- IASTName name= (IASTName)token.getNode();
+ IASTName name = (IASTName) token.getNode();
if (!name.isReference()) {
return true;
}
@@ -1324,13 +1318,13 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name instanceof ICPPASTQualifiedName) {
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
// Names that resolve to alias template instances are template-ids
// with the template-name naming the alias template. We don't want
// to color the entire template-id, but rather want to color its
@@ -1387,7 +1381,7 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICPPNamespace) {
return true;
}
@@ -1431,7 +1425,7 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ILabel) {
return true;
}
@@ -1475,15 +1469,15 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name instanceof ICPPASTQualifiedName) {
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof ICPPUnknownBinding) {
- binding= heuristicallyResolve((ICPPUnknownBinding) binding);
+ binding = heuristicallyResolve((ICPPUnknownBinding) binding);
}
if (binding instanceof IEnumerator) {
return true;
@@ -1534,7 +1528,7 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node == null) {
return false;
}
@@ -1550,11 +1544,11 @@ public class SemanticHighlightings {
// which resolve, to get a non-Problem highlighting.
return false;
}
- IBinding binding= token.getBinding();
+ IBinding binding = token.getBinding();
if (binding instanceof IProblemBinding) {
IProblemBinding problemBinding = (IProblemBinding) binding;
if (SemanticQueries.isUnknownBuiltin(problemBinding, node)) {
- return false; // Ignore an unknown built-in.
+ return false; // Ignore an unknown built-in.
}
return true;
}
@@ -1603,9 +1597,9 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
- IASTNode node= token.getNode();
+ IASTNode node = token.getNode();
if (node instanceof IASTName) {
- IASTName name= (IASTName) node;
+ IASTName name = (IASTName) node;
if (name instanceof ICPPASTQualifiedName) {
return false;
}
@@ -1613,8 +1607,8 @@ public class SemanticHighlightings {
return false;
}
if (name.isReference()) {
- IBinding binding= token.getBinding();
- IIndex index= token.getRoot().getIndex();
+ IBinding binding = token.getBinding();
+ IIndex index = token.getRoot().getIndex();
return isExternalSDKReference(binding, index);
}
}
@@ -1628,13 +1622,13 @@ public class SemanticHighlightings {
if (((IIndexBinding) binding).isFileLocal()) {
return false;
}
- }
- else if (!(binding instanceof ICExternalBinding)) {
+ } else if (!(binding instanceof ICExternalBinding)) {
return false;
}
- IIndexName[] decls= index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ IIndexName[] decls = index.findNames(binding,
+ IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
for (IIndexName decl : decls) {
- IIndexFile indexFile= decl.getFile();
+ IIndexFile indexFile = decl.getFile();
if (indexFile != null && indexFile.getLocation().getFullPath() != null) {
return false;
}
@@ -1706,8 +1700,7 @@ public class SemanticHighlightings {
if (binding instanceof ICPPUnknownBinding)
return false;
char[] chars = name.toCharArray();
- if (chars[0] == '~' || OverloadableOperator.isNew(chars)
- || OverloadableOperator.isDelete(chars)) {
+ if (chars[0] == '~' || OverloadableOperator.isNew(chars) || OverloadableOperator.isDelete(chars)) {
return false;
}
return true;
@@ -1716,24 +1709,23 @@ public class SemanticHighlightings {
return false;
}
}
-
+
/**
* Semantic highlighting for variables passed by non-const reference.
- *
+ *
* The purpose of having a highlighting for this is that there's an important
- * semantic difference between passing a variable by non-const reference
+ * semantic difference between passing a variable by non-const reference
* (where the called function can modify the original variable) and passing
* a variable by const reference or value (where it cannot), but syntactically
* these two forms of passing look the same at the call site.
*/
- private static final class VariablePassedByNonconstRefHighlighting
- extends SemanticHighlightingWithOwnPreference {
+ private static final class VariablePassedByNonconstRefHighlighting extends SemanticHighlightingWithOwnPreference {
@Override
public String getPreferenceKey() {
return VARIABLE_PASSED_BY_NONCONST_REF;
}
-
+
@Override
public boolean requiresExpressions() {
return true;
@@ -1743,7 +1735,7 @@ public class SemanticHighlightings {
public RGB getDefaultDefaultTextColor() {
return new RGB(200, 100, 150); // dark pink
}
-
+
@Override
public boolean isBoldByDefault() {
return true;
@@ -1762,30 +1754,30 @@ public class SemanticHighlightings {
@Override
public boolean consumes(ISemanticToken token) {
IASTNode node = token.getNode();
-
+
// This highlighting only applies to function arguments.
// We also filter out C expressions at this stage, since references only exist in C++
// (and then we can cast to C++ AST node types without further checks below).
- boolean isFunctionArgument = (node instanceof ICPPASTExpression) &&
- (node.getParent() instanceof IASTFunctionCallExpression) &&
- (node.getPropertyInParent() == IASTFunctionCallExpression.ARGUMENT);
+ boolean isFunctionArgument = (node instanceof ICPPASTExpression)
+ && (node.getParent() instanceof IASTFunctionCallExpression)
+ && (node.getPropertyInParent() == IASTFunctionCallExpression.ARGUMENT);
if (!isFunctionArgument) {
return false;
}
-
+
// If the argument expression is not an lvalue, we don't care if the function
- // modifies it.
+ // modifies it.
IASTExpression expression = (IASTExpression) node;
if (expression.getValueCategory() != ValueCategory.LVALUE) {
return false;
}
-
+
// Resolve the type of the function being called.
// Note that, in the case of a call to a template function or a set of overloaded functions,
- // the function name expression will be an id-expression, and
- // CPPASTIdExpression.getEvaluation() will perform template instantiation and overload
+ // the function name expression will be an id-expression, and
+ // CPPASTIdExpression.getEvaluation() will perform template instantiation and overload
// resolution, and we'll get the instantiated function type.
- // Note that we don't use CPPASTIdExpression.getExpressionType() because it typically turns
+ // Note that we don't use CPPASTIdExpression.getExpressionType() because it typically turns
// a potentially-useful FunctionSetType into the useless CPPDeferredFunction.FUNCTION_TYPE.
IASTFunctionCallExpression functionCall = ((IASTFunctionCallExpression) node.getParent());
ICPPASTExpression functionName = (ICPPASTExpression) functionCall.getFunctionNameExpression();
@@ -1807,7 +1799,7 @@ public class SemanticHighlightings {
if (!(functionType instanceof ICPPFunctionType)) {
return false;
}
-
+
// Find the parameter type matching the argument.
IType[] parameterTypes = ((ICPPFunctionType) functionType).getParameterTypes();
int argIndex = -1;
@@ -1822,7 +1814,7 @@ public class SemanticHighlightings {
return false;
}
IType parameterType = parameterTypes[argIndex];
-
+
// Consume the node if the parameter type is a non-const reference.
// In the case of an reference to an array type, it is the element type
// which must be non-const.
@@ -1834,7 +1826,7 @@ public class SemanticHighlightings {
}
boolean isConstRef = false;
if (referredType instanceof IQualifierType) {
- isConstRef = ((IQualifierType) referredType).isConst();
+ isConstRef = ((IQualifierType) referredType).isConst();
} else if (referredType instanceof IPointerType) {
isConstRef = ((IPointerType) referredType).isConst();
}
@@ -1843,10 +1835,10 @@ public class SemanticHighlightings {
return false;
}
}
-
+
/**
* Semantic highlighting for context-sensitive keywords.
- *
+ *
* This does not get its own color and style; rather, it uses
* the color and style of the 'Keyword' syntactic highlighting.
*/
@@ -1855,7 +1847,7 @@ public class SemanticHighlightings {
public String getPreferenceKey() {
return ICColorConstants.C_KEYWORD;
}
-
+
@Override
public boolean isEnabledByDefault() {
return true;
@@ -1920,7 +1912,7 @@ public class SemanticHighlightings {
}
return binding;
}
-
+
// Note on the get___PreferenceKey() functions below:
// - For semantic highlightings deriving from SemanticHighlightingWithOwnPreference,
// these functions return keys for accessing the highlighting's own preferences.
@@ -1935,7 +1927,7 @@ public class SemanticHighlightings {
// From a user's perspective, semantic highlightings not deriving from
// SemanticHighlightingWithOwnPreference are still always enabled because there is no
// way to disable them in the UI.
-
+
/**
* A named preference that controls the given semantic highlighting's color.
*
@@ -1944,7 +1936,8 @@ public class SemanticHighlightings {
*/
public static String getColorPreferenceKey(SemanticHighlighting semanticHighlighting) {
if (semanticHighlighting instanceof SemanticHighlightingWithOwnPreference) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX;
+ return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey()
+ + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX;
} else {
return semanticHighlighting.getPreferenceKey();
}
@@ -1958,7 +1951,8 @@ public class SemanticHighlightings {
*/
public static String getBoldPreferenceKey(SemanticHighlighting semanticHighlighting) {
if (semanticHighlighting instanceof SemanticHighlightingWithOwnPreference) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX;
+ return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey()
+ + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX;
} else {
return semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_BOLD_SUFFIX;
}
@@ -1972,7 +1966,8 @@ public class SemanticHighlightings {
*/
public static String getItalicPreferenceKey(SemanticHighlighting semanticHighlighting) {
if (semanticHighlighting instanceof SemanticHighlightingWithOwnPreference) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
+ return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey()
+ + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
} else {
return semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_ITALIC_SUFFIX;
}
@@ -1985,8 +1980,9 @@ public class SemanticHighlightings {
* @return the strikethrough preference key
*/
public static String getStrikethroughPreferenceKey(SemanticHighlighting semanticHighlighting) {
- if (semanticHighlighting instanceof SemanticHighlightingWithOwnPreference) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX;
+ if (semanticHighlighting instanceof SemanticHighlightingWithOwnPreference) {
+ return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey()
+ + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX;
} else {
return semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
}
@@ -2000,7 +1996,8 @@ public class SemanticHighlightings {
*/
public static String getUnderlinePreferenceKey(SemanticHighlighting semanticHighlighting) {
if (semanticHighlighting instanceof SemanticHighlightingWithOwnPreference) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX;
+ return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey()
+ + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX;
} else {
return semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
}
@@ -2013,7 +2010,8 @@ public class SemanticHighlightings {
* @return the enabled preference key
*/
public static String getEnabledPreferenceKey(SemanticHighlighting semanticHighlighting) {
- return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
+ return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey()
+ + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
}
private static class Key implements Comparable<Key> {
@@ -2096,11 +2094,10 @@ public class SemanticHighlightings {
loadBuiltInSemanticHighlightings(highlightings);
// load the extensions
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- CUIPlugin.getPluginId(), ExtensionPoint);
+ IConfigurationElement[] elements = Platform.getExtensionRegistry()
+ .getConfigurationElementsFor(CUIPlugin.getPluginId(), ExtensionPoint);
for (IConfigurationElement element : elements) {
- ContributedSemanticHighlighting contributedHighlighting = new ContributedSemanticHighlighting(
- element);
+ ContributedSemanticHighlighting contributedHighlighting = new ContributedSemanticHighlighting(element);
Key key = new Key(contributedHighlighting.getPriority(), contributedHighlighting.getId());
highlightings.put(key, contributedHighlighting);
@@ -2130,16 +2127,22 @@ public class SemanticHighlightings {
public static void initDefaults(IPreferenceStore store) {
store.setDefault(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, true);
- SemanticHighlighting[] semanticHighlightings= getSemanticHighlightings();
+ SemanticHighlighting[] semanticHighlightings = getSemanticHighlightings();
for (SemanticHighlighting semanticHighlighting : semanticHighlightings) {
- store.setDefault(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting), DEBUG || semanticHighlighting.isEnabledByDefault());
+ store.setDefault(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting),
+ DEBUG || semanticHighlighting.isEnabledByDefault());
if (semanticHighlighting instanceof SemanticHighlightingWithOwnPreference) {
SemanticHighlightingWithOwnPreference highlighting = (SemanticHighlightingWithOwnPreference) semanticHighlighting;
- PreferenceConverter.setDefault(store, SemanticHighlightings.getColorPreferenceKey(highlighting), highlighting.getDefaultTextColor());
- store.setDefault(SemanticHighlightings.getBoldPreferenceKey(highlighting), highlighting.isBoldByDefault());
- store.setDefault(SemanticHighlightings.getItalicPreferenceKey(highlighting), highlighting.isItalicByDefault());
- store.setDefault(SemanticHighlightings.getStrikethroughPreferenceKey(highlighting), highlighting.isStrikethroughByDefault());
- store.setDefault(SemanticHighlightings.getUnderlinePreferenceKey(highlighting), DEBUG || highlighting.isUnderlineByDefault());
+ PreferenceConverter.setDefault(store, SemanticHighlightings.getColorPreferenceKey(highlighting),
+ highlighting.getDefaultTextColor());
+ store.setDefault(SemanticHighlightings.getBoldPreferenceKey(highlighting),
+ highlighting.isBoldByDefault());
+ store.setDefault(SemanticHighlightings.getItalicPreferenceKey(highlighting),
+ highlighting.isItalicByDefault());
+ store.setDefault(SemanticHighlightings.getStrikethroughPreferenceKey(highlighting),
+ highlighting.isStrikethroughByDefault());
+ store.setDefault(SemanticHighlightings.getUnderlinePreferenceKey(highlighting),
+ DEBUG || highlighting.isUnderlineByDefault());
}
}
}
@@ -2157,11 +2160,11 @@ public class SemanticHighlightings {
if (event.getProperty().equals(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)) {
return true;
}
- String relevantKey= null;
- SemanticHighlighting[] highlightings= getSemanticHighlightings();
+ String relevantKey = null;
+ SemanticHighlighting[] highlightings = getSemanticHighlightings();
for (SemanticHighlighting highlighting : highlightings) {
if (event.getProperty().equals(getEnabledPreferenceKey(highlighting))) {
- relevantKey= event.getProperty();
+ relevantKey = event.getProperty();
break;
}
}
@@ -2169,7 +2172,7 @@ public class SemanticHighlightings {
return false;
for (SemanticHighlighting highlighting : highlightings) {
- String key= getEnabledPreferenceKey(highlighting);
+ String key = getEnabledPreferenceKey(highlighting);
if (key.equals(relevantKey))
continue;
if (store.getBoolean(key))
@@ -2191,9 +2194,9 @@ public class SemanticHighlightings {
if (!store.getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)) {
return false;
}
- SemanticHighlighting[] highlightings= getSemanticHighlightings();
+ SemanticHighlighting[] highlightings = getSemanticHighlightings();
for (SemanticHighlighting highlighting : highlightings) {
- String enabledKey= getEnabledPreferenceKey(highlighting);
+ String enabledKey = getEnabledPreferenceKey(highlighting);
if (store.getBoolean(enabledKey)) {
return true;
}
@@ -2204,7 +2207,7 @@ public class SemanticHighlightings {
/**
* Returns whether the given highlighting is the highlighting for external SDK functions.
- * For the previewer widget in the preferences, this is swapped out with a different implementation.
+ * For the previewer widget in the preferences, this is swapped out with a different implementation.
*/
public static boolean isExternalSDKHighlighting(SemanticHighlighting highlighting) {
return highlighting instanceof ExternalSDKHighlighting;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java
index f6315d1f0fb..5b4cbfb272a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java
@@ -45,9 +45,9 @@ public final class SemanticToken implements ISemanticToken {
@Override
public IBinding getBinding() {
if (!fIsBindingResolved) {
- fIsBindingResolved= true;
+ fIsBindingResolved = true;
if (fNode instanceof IASTName)
- fBinding= ((IASTName) fNode).resolveBinding();
+ fBinding = ((IASTName) fNode).resolveBinding();
}
return fBinding;
@@ -67,9 +67,9 @@ public final class SemanticToken implements ISemanticToken {
@Override
public IASTTranslationUnit getRoot() {
if (!fIsRootResolved) {
- fIsRootResolved= true;
+ fIsRootResolved = true;
if (fNode != null) {
- fRoot= fNode.getTranslationUnit();
+ fRoot = fNode.getTranslationUnit();
}
}
return fRoot;
@@ -85,7 +85,7 @@ public final class SemanticToken implements ISemanticToken {
*/
void update(IASTNode node) {
clear();
- fNode= node;
+ fNode = node;
}
/**
@@ -95,10 +95,10 @@ public final class SemanticToken implements ISemanticToken {
* </p>
*/
void clear() {
- fNode= null;
- fBinding= null;
- fIsBindingResolved= false;
- fRoot= null;
- fIsRootResolved= false;
+ fNode = null;
+ fBinding = null;
+ fIsBindingResolved = false;
+ fRoot = null;
+ fIsRootResolved = false;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SortLinesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SortLinesAction.java
index f82fae303d0..878e58a47ec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SortLinesAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SortLinesAction.java
@@ -60,7 +60,7 @@ public final class SortLinesAction extends TextEditorAction {
*/
@Override
public void run() {
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (editor == null)
return;
@@ -68,17 +68,16 @@ public final class SortLinesAction extends TextEditorAction {
if (!(selection instanceof ITextSelection))
return;
- ITextSelection textSelection= (ITextSelection) selection;
+ ITextSelection textSelection = (ITextSelection) selection;
if (textSelection.getStartLine() < 0 || textSelection.getEndLine() < 0)
return;
IEditorInput editorInput = editor.getEditorInput();
ICProject cProject = EditorUtility.getCProject(editorInput);
- IDocument document= editor.getDocumentProvider().getDocument(editorInput);
+ IDocument document = editor.getDocumentProvider().getDocument(editorInput);
try {
- IRegion block= getTextBlockFromSelection(textSelection, document);
- SortElement[] elements = createSortElements(block, document,
- CodeFormatterUtil.getTabWidth(cProject));
+ IRegion block = getTextBlockFromSelection(textSelection, document);
+ SortElement[] elements = createSortElements(block, document, CodeFormatterUtil.getTabWidth(cProject));
if (elements.length <= 1)
return;
@@ -97,7 +96,7 @@ public final class SortLinesAction extends TextEditorAction {
return;
ReplaceEdit edit = new ReplaceEdit(block.getOffset(), block.getLength(), replacement);
- IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
+ IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
manager.beginCompoundChange();
edit.apply(document);
editor.getSelectionProvider().setSelection(new TextSelection(block.getOffset(), buf.length()));
@@ -117,29 +116,29 @@ public final class SortLinesAction extends TextEditorAction {
*/
private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document) {
try {
- IRegion firstLine= document.getLineInformationOfOffset(selection.getOffset());
+ IRegion firstLine = document.getLineInformationOfOffset(selection.getOffset());
int selectionEnd = selection.getOffset() + selection.getLength();
- IRegion lastLine= document.getLineInformationOfOffset(selectionEnd);
+ IRegion lastLine = document.getLineInformationOfOffset(selectionEnd);
int length = lastLine.getOffset() - firstLine.getOffset();
if (selectionEnd > lastLine.getOffset()) {
- // Last line is included with the line delimiter.
+ // Last line is included with the line delimiter.
length += document.getLineLength(document.getLineOfOffset(selectionEnd));
}
return new Region(firstLine.getOffset(), length);
} catch (BadLocationException e) {
- CUIPlugin.log(e); // Should not happen
+ CUIPlugin.log(e); // Should not happen
}
return null;
}
private SortElement[] createSortElements(IRegion block, IDocument document, int tabWidth)
throws BadLocationException {
- ITypedRegion[] regions= TextUtilities.computePartitioning(document, ICPartitions.C_PARTITIONING,
+ ITypedRegion[] regions = TextUtilities.computePartitioning(document, ICPartitions.C_PARTITIONING,
block.getOffset(), block.getLength(), false);
int numLines = document.getNumberOfLines(block.getOffset(), block.getLength());
if (endOf(block) <= document.getLineInformationOfOffset(endOf(block)).getOffset()) {
- numLines--; // Last line is excluded
+ numLines--; // Last line is excluded
}
LineInfo[] lineDescriptors = new LineInfo[numLines];
int numNonCommentLines = 0;
@@ -154,10 +153,10 @@ public final class SortLinesAction extends TextEditorAction {
i++;
for (; i < regions.length && regions[i].getOffset() < lineInfo.getTrimmedEndOffset(); i++) {
ITypedRegion region = regions[i];
- if (region.getType() != ICPartitions.C_MULTI_LINE_COMMENT &&
- region.getType() != ICPartitions.C_MULTI_LINE_DOC_COMMENT &&
- region.getType() != ICPartitions.C_SINGLE_LINE_COMMENT &&
- region.getType() != ICPartitions.C_SINGLE_LINE_DOC_COMMENT) {
+ if (region.getType() != ICPartitions.C_MULTI_LINE_COMMENT
+ && region.getType() != ICPartitions.C_MULTI_LINE_DOC_COMMENT
+ && region.getType() != ICPartitions.C_SINGLE_LINE_COMMENT
+ && region.getType() != ICPartitions.C_SINGLE_LINE_DOC_COMMENT) {
lineInfo.nonComment = true;
break;
}
@@ -174,10 +173,10 @@ public final class SortLinesAction extends TextEditorAction {
for (int j = 0; j < lineDescriptors.length; j++) {
LineInfo lineInfo = lineDescriptors[j];
if (lineInfo.nonComment) {
- int endOffset = k < numNonCommentLines - 1 ?
- lineInfo.getEndOffset() : block.getOffset() + block.getLength();
- elements[k++] = new SortElement(new Region(offset, endOffset - offset), lineInfo,
- document, tabWidth);
+ int endOffset = k < numNonCommentLines - 1 ? lineInfo.getEndOffset()
+ : block.getOffset() + block.getLength();
+ elements[k++] = new SortElement(new Region(offset, endOffset - offset), lineInfo, document,
+ tabWidth);
offset = lineInfo.getEndOffset();
}
}
@@ -220,14 +219,15 @@ public final class SortLinesAction extends TextEditorAction {
if (editor != null) {
ISelection selection = editor.getSelectionProvider().getSelection();
if (selection instanceof ITextSelection) {
- ITextSelection textSelection= (ITextSelection) selection;
+ ITextSelection textSelection = (ITextSelection) selection;
int startLine = textSelection.getStartLine();
int endLine = textSelection.getEndLine();
if (startLine >= 0 && endLine > startLine) {
if (endLine == startLine + 1) {
- IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
try {
- if (textSelection.getOffset() + textSelection.getLength() > document.getLineOffset(endLine)) {
+ if (textSelection.getOffset() + textSelection.getLength() > document
+ .getLineOffset(endLine)) {
enabled = true;
}
} catch (BadLocationException e) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.java
index 183624e07f9..1feaa4ebf84 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.java
@@ -63,14 +63,14 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContext;
* and vice versa.
*/
public final class SourceHeaderPartnerFinder {
-
+
private static class Counter {
public int fCount;
}
-
+
private SourceHeaderPartnerFinder() {
}
-
+
/**
* Compute the partner file for a translation unit.
* The partner file is the corresponding source or header file
@@ -80,7 +80,7 @@ public final class SourceHeaderPartnerFinder {
*/
private static class PartnerFileComputer implements ASTRunnable {
PartnerFileVisitor fVisitor = null;
-
+
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
if (ast != null && ast.getIndex() != null) {
@@ -94,19 +94,19 @@ public final class SourceHeaderPartnerFinder {
if (fVisitor != null) {
return fVisitor.getPartnerFileLocation();
}
-
+
return null;
}
}
-
+
private static class PartnerFileVisitor extends ASTVisitor {
- /**
- * When this many times the same partner file is hit,
+ /**
+ * When this many times the same partner file is hit,
* we are confident enough to take it.
*/
private static final int CONFIDENCE_LIMIT = 15;
- /**
- * When this many times no match was found in the index,
+ /**
+ * When this many times no match was found in the index,
* we suspect that we won't get a good partner.
*/
private static final int SUSPECT_LIMIT = 15;
@@ -120,24 +120,24 @@ public final class SourceHeaderPartnerFinder {
private int fSuspect;
/** The current favorite partner file */
private IPath fFavoriteLocation;
-
+
{
- shouldVisitDeclarators= true;
+ shouldVisitDeclarators = true;
shouldVisitTranslationUnit = true;
}
public PartnerFileVisitor() {
- fMap= new HashMap<IPath, Counter>();
+ fMap = new HashMap<IPath, Counter>();
}
@Override
public int visit(IASTTranslationUnit tu) {
- fIndex= tu.getIndex();
+ fIndex = tu.getIndex();
if (fIndex == null) {
- return PROCESS_ABORT;
+ return PROCESS_ABORT;
}
-
- fFilePath= Path.fromOSString(tu.getFilePath());
+
+ fFilePath = Path.fromOSString(tu.getFilePath());
return super.visit(tu);
}
@@ -151,32 +151,32 @@ public final class SourceHeaderPartnerFinder {
@Override
public int visit(IASTDeclarator declarator) {
if (declarator instanceof IASTFunctionDeclarator) {
- IASTName name= declarator.getName();
+ IASTName name = declarator.getName();
if (name != null && declarator.getNestedDeclarator() == null) {
- IBinding binding= name.resolveBinding();
+ IBinding binding = name.resolveBinding();
if (binding != null && !(binding instanceof IProblemBinding)) {
- boolean isDefinition= name.isDefinition();
+ boolean isDefinition = name.isDefinition();
final IIndexName[] partnerNames;
try {
if (isDefinition) {
- partnerNames= fIndex.findNames(binding,
+ partnerNames = fIndex.findNames(binding,
IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
} else {
- partnerNames= fIndex.findNames(binding,
+ partnerNames = fIndex.findNames(binding,
IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
}
if (partnerNames.length == 0) {
++fSuspect;
if (fSuspect == SUSPECT_LIMIT) {
- fFavoriteLocation= null;
+ fFavoriteLocation = null;
return PROCESS_ABORT;
}
}
- for (int i= 0; i < partnerNames.length; i++) {
- IIndexName partnerName= partnerNames[i];
- IASTFileLocation partnerLocation= partnerName.getFileLocation();
+ for (int i = 0; i < partnerNames.length; i++) {
+ IIndexName partnerName = partnerNames[i];
+ IASTFileLocation partnerLocation = partnerName.getFileLocation();
if (partnerLocation != null) {
- IPath partnerFileLocation= Path.fromOSString(partnerLocation.getFileName());
+ IPath partnerFileLocation = Path.fromOSString(partnerLocation.getFileName());
if (!fFilePath.equals(partnerFileLocation)) {
addPotentialPartnerFileLocation(partnerFileLocation);
if (fConfidence == CONFIDENCE_LIMIT) {
@@ -195,29 +195,29 @@ public final class SourceHeaderPartnerFinder {
}
private void addPotentialPartnerFileLocation(IPath partnerFileLocation) {
- Counter counter= fMap.get(partnerFileLocation);
+ Counter counter = fMap.get(partnerFileLocation);
if (counter == null) {
- counter= new Counter();
+ counter = new Counter();
fMap.put(partnerFileLocation, counter);
}
++counter.fCount;
if (counter.fCount > fConfidence) {
- fConfidence= counter.fCount;
- fFavoriteLocation= partnerFileLocation;
+ fConfidence = counter.fCount;
+ fFavoriteLocation = partnerFileLocation;
}
}
}
-
+
/**
* Finds a file in the given resource container for the given basename.
- *
+ *
* @param container
* @param basename
* @return a matching {@link IFile} or <code>null</code>, if no matching file was found
*/
private static IFile findInContainer(IContainer container, final String basename) {
- final IFile[] result= { null };
- IResourceProxyVisitor visitor= new IResourceProxyVisitor() {
+ final IFile[] result = { null };
+ IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
if (!proxy.isAccessible()) {
@@ -236,7 +236,8 @@ public final class SourceHeaderPartnerFinder {
return false;
}
return true;
- }};
+ }
+ };
try {
container.accept(visitor, 0);
} catch (CoreException e) {
@@ -244,74 +245,66 @@ public final class SourceHeaderPartnerFinder {
}
return result[0];
}
-
+
private static IContentType[] getPartnerContentTypes(String contentTypeId) {
- IContentTypeManager mgr= Platform.getContentTypeManager();
+ IContentTypeManager mgr = Platform.getContentTypeManager();
if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CHEADER)) {
- return new IContentType[] {
- mgr.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE),
- mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE)
- };
+ return new IContentType[] { mgr.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE),
+ mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE) };
}
if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CSOURCE)) {
- return new IContentType[] {
- mgr.getContentType(CCorePlugin.CONTENT_TYPE_CHEADER),
- mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER)
- };
+ return new IContentType[] { mgr.getContentType(CCorePlugin.CONTENT_TYPE_CHEADER),
+ mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER) };
}
if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER)) {
- return new IContentType[] {
- mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE),
- mgr.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE)
- };
+ return new IContentType[] { mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE),
+ mgr.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE) };
}
if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CXXSOURCE)) {
- return new IContentType[] {
- mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER),
- mgr.getContentType(CCorePlugin.CONTENT_TYPE_CHEADER)
- };
+ return new IContentType[] { mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER),
+ mgr.getContentType(CCorePlugin.CONTENT_TYPE_CHEADER) };
}
return new IContentType[0];
}
-
+
/**
* Finds a partner translation unit based on filename/extension matching.
- *
+ *
* @param a partner translation unit or <code>null</code>
*/
private static ITranslationUnit getPartnerFileFromFilename(ITranslationUnit tu) {
- IPath sourceFileLocation= tu.getLocation();
+ IPath sourceFileLocation = tu.getLocation();
if (sourceFileLocation == null) {
return null;
}
- IPath partnerBasePath= sourceFileLocation.removeFileExtension();
- IContentType[] contentTypes= getPartnerContentTypes(tu.getContentTypeId());
- HashSet<String> extensionsTried= new HashSet<>();
+ IPath partnerBasePath = sourceFileLocation.removeFileExtension();
+ IContentType[] contentTypes = getPartnerContentTypes(tu.getContentTypeId());
+ HashSet<String> extensionsTried = new HashSet<>();
for (IContentType contentType : contentTypes) {
String[] partnerExtensions = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
for (String ext : partnerExtensions) {
if (extensionsTried.add(ext)) {
- String partnerFileBasename= partnerBasePath.addFileExtension(ext).lastSegment();
-
- IFile partnerFile= null;
+ String partnerFileBasename = partnerBasePath.addFileExtension(ext).lastSegment();
+
+ IFile partnerFile = null;
IResource resource = tu.getResource();
IContainer container = resource != null ? resource.getParent() : null;
while (container != null && partnerFile == null && !(container instanceof IWorkspaceRoot)) {
- partnerFile= findInContainer(container, partnerFileBasename);
+ partnerFile = findInContainer(container, partnerFileBasename);
container = container.getParent();
}
if (partnerFile != null) {
- ITranslationUnit partnerUnit= (ITranslationUnit) CoreModel.getDefault().create(partnerFile);
+ ITranslationUnit partnerUnit = (ITranslationUnit) CoreModel.getDefault().create(partnerFile);
if (partnerUnit != null) {
return partnerUnit;
}
}
// External translation unit - try in same directory
if (resource == null) {
- IPath partnerFileLoation= partnerBasePath.removeLastSegments(1).append(partnerFileBasename);
- ITranslationUnit partnerUnit= CoreModel.getDefault().createTranslationUnitFrom(
- tu.getCProject(), partnerFileLoation);
+ IPath partnerFileLoation = partnerBasePath.removeLastSegments(1).append(partnerFileBasename);
+ ITranslationUnit partnerUnit = CoreModel.getDefault()
+ .createTranslationUnitFrom(tu.getCProject(), partnerFileLoation);
if (partnerUnit != null) {
return partnerUnit;
}
@@ -323,25 +316,25 @@ public final class SourceHeaderPartnerFinder {
}
public static ITranslationUnit getPartnerTranslationUnit(ITranslationUnit tu) {
- ITranslationUnit partnerUnit= getPartnerFileFromFilename(tu);
+ ITranslationUnit partnerUnit = getPartnerFileFromFilename(tu);
if (partnerUnit == null) {
// Search partner file based on definition/declaration association
- IProgressMonitor monitor= new NullProgressMonitor();
- PartnerFileComputer computer= new PartnerFileComputer();
+ IProgressMonitor monitor = new NullProgressMonitor();
+ PartnerFileComputer computer = new PartnerFileComputer();
ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_ACTIVE_ONLY, monitor, computer);
partnerUnit = createTranslationUnit(computer.getPartnerFileLocation(), tu.getCProject());
}
return partnerUnit;
}
-
+
public static ITranslationUnit getPartnerTranslationUnit(ITranslationUnit tu,
CRefactoringContext refactoringContext) throws CoreException {
- ITranslationUnit partnerUnit= getPartnerFileFromFilename(tu);
+ ITranslationUnit partnerUnit = getPartnerFileFromFilename(tu);
if (partnerUnit == null) {
// Search partner file based on definition/declaration association
- IProgressMonitor monitor= new NullProgressMonitor();
+ IProgressMonitor monitor = new NullProgressMonitor();
IASTTranslationUnit ast = refactoringContext.getAST(tu, monitor);
PartnerFileVisitor visitor = new PartnerFileVisitor();
ast.accept(visitor);
@@ -349,14 +342,13 @@ public final class SourceHeaderPartnerFinder {
}
return partnerUnit;
}
-
+
private static ITranslationUnit createTranslationUnit(IPath partnerFileLoation, ICProject project) {
ITranslationUnit partnerUnit = null;
if (partnerFileLoation != null) {
- partnerUnit= (ITranslationUnit) CoreModel.getDefault().create(partnerFileLoation);
+ partnerUnit = (ITranslationUnit) CoreModel.getDefault().create(partnerFileLoation);
if (partnerUnit == null) {
- partnerUnit= CoreModel.getDefault().createTranslationUnitFrom(project,
- partnerFileLoation);
+ partnerUnit = CoreModel.getDefault().createTranslationUnitFrom(project, partnerFileLoation);
}
}
return partnerUnit;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.java
index 61a4ca0e422..c37d45dbce5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException;
@@ -36,7 +35,7 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputer
/**
* Action to run content assist on a specific proposal category.
- *
+ *
* @since 4.0
*/
final class SpecificContentAssistAction extends Action implements IUpdate {
@@ -47,19 +46,20 @@ final class SpecificContentAssistAction extends Action implements IUpdate {
/**
* The content assist executor.
*/
- private final SpecificContentAssistExecutor fExecutor= new SpecificContentAssistExecutor(CompletionProposalComputerRegistry.getDefault());
+ private final SpecificContentAssistExecutor fExecutor = new SpecificContentAssistExecutor(
+ CompletionProposalComputerRegistry.getDefault());
/**
* The editor.
*/
private CEditor fEditor;
-
+
/**
* Creates a new action for a certain proposal category.
- *
+ *
* @param category
*/
public SpecificContentAssistAction(CompletionProposalCategory category) {
- fCategory= category;
+ fCategory = category;
setText(category.getName());
setImageDescriptor(category.getImageDescriptor());
setActionDefinitionId("org.eclipse.cdt.ui.specific_content_assist.command"); //$NON-NLS-1$
@@ -70,12 +70,12 @@ final class SpecificContentAssistAction extends Action implements IUpdate {
*/
@Override
public void run() {
- ITextEditor editor= getActiveEditor();
+ ITextEditor editor = getActiveEditor();
if (editor == null)
return;
-
+
fExecutor.invokeContentAssist(editor, fCategory.getId());
-
+
return;
}
@@ -85,72 +85,72 @@ final class SpecificContentAssistAction extends Action implements IUpdate {
/**
* Sets the active editor part.
- *
+ *
* @param part the editor, possibly <code>null</code>
*/
public void setActiveEditor(IEditorPart part) {
CEditor editor;
if (part instanceof CEditor)
- editor= (CEditor) part;
+ editor = (CEditor) part;
else
- editor= null;
- fEditor= editor;
+ editor = null;
+ fEditor = editor;
setEnabled(computeEnablement(fEditor));
}
-
+
private boolean computeEnablement(ITextEditor editor) {
if (editor == null)
return false;
- ITextOperationTarget target= editor.getAdapter(ITextOperationTarget.class);
- boolean hasContentAssist= target != null && target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+ ITextOperationTarget target = editor.getAdapter(ITextOperationTarget.class);
+ boolean hasContentAssist = target != null && target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
if (!hasContentAssist)
return false;
-
- ISelection selection= editor.getSelectionProvider().getSelection();
+
+ ISelection selection = editor.getSelectionProvider().getSelection();
return isValidSelection(selection);
}
- /**
+ /**
* Computes the partition type at the selection start and checks whether the proposal category
* has any computers for this partition.
- *
+ *
* @param selection the selection
* @return <code>true</code> if there are any computers for the selection
*/
- private boolean isValidSelection(ISelection selection) {
- if (!(selection instanceof ITextSelection))
- return false;
- int offset= ((ITextSelection) selection).getOffset();
-
- IDocument document= getDocument();
- if (document == null)
- return false;
-
- String contentType;
- try {
- contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, true);
- } catch (BadLocationException x) {
- return false;
- }
-
- return fCategory.hasComputers(contentType);
- }
-
+ private boolean isValidSelection(ISelection selection) {
+ if (!(selection instanceof ITextSelection))
+ return false;
+ int offset = ((ITextSelection) selection).getOffset();
+
+ IDocument document = getDocument();
+ if (document == null)
+ return false;
+
+ String contentType;
+ try {
+ contentType = TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, true);
+ } catch (BadLocationException x) {
+ return false;
+ }
+
+ return fCategory.hasComputers(contentType);
+ }
+
private IDocument getDocument() {
Assert.isTrue(fEditor != null);
- IDocumentProvider provider= fEditor.getDocumentProvider();
- if (provider == null)
- return null;
-
- IDocument document= provider.getDocument(fEditor.getEditorInput());
- return document;
- }
+ IDocumentProvider provider = fEditor.getDocumentProvider();
+ if (provider == null)
+ return null;
+
+ IDocument document = provider.getDocument(fEditor.getEditorInput());
+ return document;
+ }
/*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- @Override
+ * @see org.eclipse.ui.texteditor.IUpdate#update()
+ */
+ @Override
public void update() {
- setEnabled(computeEnablement(fEditor));
- }
+ setEnabled(computeEnablement(fEditor));
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor.java
index 860518979a3..124e1c9c4c2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor.java
@@ -25,10 +25,9 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalCategory;
import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerRegistry;
-
/**
* A content assist executor can invoke content assist for a specific proposal category on an editor.
- *
+ *
* @since 4.0
*/
public final class SpecificContentAssistExecutor {
@@ -37,42 +36,42 @@ public final class SpecificContentAssistExecutor {
/**
* Creates a new executor.
- *
+ *
* @param registry the computer registry to use for the enablement of proposal categories
*/
public SpecificContentAssistExecutor(CompletionProposalComputerRegistry registry) {
Assert.isNotNull(registry);
- fRegistry= registry;
+ fRegistry = registry;
}
/**
* Invokes content assist on <code>editor</code>, showing only proposals computed by the
* <code>CompletionProposalCategory</code> with the given <code>categoryId</code>.
- *
+ *
* @param editor the editor to invoke code assist on
* @param categoryId the id of the proposal category to show proposals for
*/
public void invokeContentAssist(final ITextEditor editor, String categoryId) {
- Collection<CompletionProposalCategory> categories= fRegistry.getProposalCategories();
- boolean[] inclusionState= new boolean[categories.size()];
- boolean[] separateState= new boolean[categories.size()];
- int i= 0;
- for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) {
- CompletionProposalCategory cat= it.next();
- inclusionState[i]= cat.isIncluded();
+ Collection<CompletionProposalCategory> categories = fRegistry.getProposalCategories();
+ boolean[] inclusionState = new boolean[categories.size()];
+ boolean[] separateState = new boolean[categories.size()];
+ int i = 0;
+ for (Iterator<CompletionProposalCategory> it = categories.iterator(); it.hasNext(); i++) {
+ CompletionProposalCategory cat = it.next();
+ inclusionState[i] = cat.isIncluded();
cat.setIncluded(cat.getId().equals(categoryId));
- separateState[i]= cat.isSeparateCommand();
+ separateState[i] = cat.isSeparateCommand();
cat.setSeparateCommand(false);
}
-
+
try {
- ITextOperationTarget target= editor.getAdapter(ITextOperationTarget.class);
+ ITextOperationTarget target = editor.getAdapter(ITextOperationTarget.class);
if (target != null && target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS))
target.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
} finally {
- i= 0;
- for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) {
- CompletionProposalCategory cat= it.next();
+ i = 0;
+ for (Iterator<CompletionProposalCategory> it = categories.iterator(); it.hasNext(); i++) {
+ CompletionProposalCategory cat = it.next();
cat.setIncluded(inclusionState[i]);
cat.setSeparateCommand(separateState[i]);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java
index 6f7ca4d2d2a..734c65bb502 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java
@@ -77,7 +77,7 @@ public final class ToggleCommentAction extends TextEditorAction {
if (fOperationTarget == null || fDocumentPartitioning == null || fPrefixesMap == null)
return;
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (editor == null)
return;
@@ -86,11 +86,11 @@ public final class ToggleCommentAction extends TextEditorAction {
final int operationCode;
if (isSelectionCommented(editor.getSelectionProvider().getSelection()))
- operationCode= ITextOperationTarget.STRIP_PREFIX;
+ operationCode = ITextOperationTarget.STRIP_PREFIX;
else
- operationCode= ITextOperationTarget.PREFIX;
+ operationCode = ITextOperationTarget.PREFIX;
- Shell shell= editor.getSite().getShell();
+ Shell shell = editor.getSite().getShell();
if (!fOperationTarget.canDoOperation(operationCode)) {
if (shell != null) {
MessageDialog.openError(shell, CEditorMessages.ToggleComment_error_title,
@@ -99,9 +99,9 @@ public final class ToggleCommentAction extends TextEditorAction {
return;
}
- Display display= null;
+ Display display = null;
if (shell != null && !shell.isDisposed())
- display= shell.getDisplay();
+ display = shell.getDisplay();
BusyIndicator.showWhile(display, new Runnable() {
@Override
@@ -121,34 +121,34 @@ public final class ToggleCommentAction extends TextEditorAction {
if (!(selection instanceof ITextSelection))
return false;
- ITextSelection textSelection= (ITextSelection) selection;
+ ITextSelection textSelection = (ITextSelection) selection;
if (textSelection.getStartLine() < 0 || textSelection.getEndLine() < 0)
return false;
- IDocument document= getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
+ IDocument document = getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
try {
- IRegion block= getTextBlockFromSelection(textSelection, document);
- ITypedRegion[] regions= TextUtilities.computePartitioning(document, fDocumentPartitioning,
+ IRegion block = getTextBlockFromSelection(textSelection, document);
+ ITypedRegion[] regions = TextUtilities.computePartitioning(document, fDocumentPartitioning,
block.getOffset(), block.getLength(), false);
- int[] lines= new int[regions.length * 2]; // [startline, endline, startline, endline, ...]
+ int[] lines = new int[regions.length * 2]; // [startline, endline, startline, endline, ...]
// For each partition in the text selection, figure out the startline and endline.
// Count the number of lines that are selected.
- for (int i = 0, j = 0; i < regions.length; i++, j+= 2) {
+ for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
// Start line of region
- lines[j]= getFirstCompleteLineOfRegion(regions[i], document);
+ lines[j] = getFirstCompleteLineOfRegion(regions[i], document);
// End line of region
- int length= regions[i].getLength();
- int offset= regions[i].getOffset() + length;
+ int length = regions[i].getLength();
+ int offset = regions[i].getOffset() + length;
if (length > 0)
offset--;
// If there is no startline for this region (startline = -1),
// then there is no endline,
// otherwise, get the line number of the endline and store it in the array.
- lines[j + 1]= (lines[j] == -1 ? -1 : document.getLineOfOffset(offset));
+ lines[j + 1] = (lines[j] == -1 ? -1 : document.getLineOfOffset(offset));
// We could count the number of lines that are selected in this region
// lineCount += lines[j + 1] - lines[j] + 1;
@@ -158,12 +158,12 @@ public final class ToggleCommentAction extends TextEditorAction {
}
// Perform the check
- boolean hasComment= false;
+ boolean hasComment = false;
for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
- String[] prefixes= fPrefixesMap.get(regions[i].getType());
+ String[] prefixes = fPrefixesMap.get(regions[i].getType());
if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0) {
if (isBlockCommented(lines[j], lines[j + 1], prefixes, document)) {
- hasComment= true;
+ hasComment = true;
} else if (!isBlockEmpty(lines[j], lines[j + 1], document)) {
return false;
}
@@ -171,7 +171,7 @@ public final class ToggleCommentAction extends TextEditorAction {
}
return hasComment;
} catch (BadLocationException e) {
- CUIPlugin.log(e); // Should not happen
+ CUIPlugin.log(e); // Should not happen
}
return false;
@@ -182,20 +182,21 @@ public final class ToggleCommentAction extends TextEditorAction {
* the beginning of a line) completely containing the current selection.
*
* Note, the implementation has to match {@link TextViewer}.getTextBlockFromSelection().
- *
+ *
* @param selection The selection to use
* @param document The document
* @return the region describing the text block comprising the given selection
* @throws BadLocationException
*/
- private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document) throws BadLocationException {
- int start= document.getLineOffset(selection.getStartLine());
+ private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document)
+ throws BadLocationException {
+ int start = document.getLineOffset(selection.getStartLine());
int end;
- int endLine= selection.getEndLine();
- if (document.getNumberOfLines() > endLine+1) {
- end= document.getLineOffset(endLine+1);
+ int endLine = selection.getEndLine();
+ if (document.getNumberOfLines() > endLine + 1) {
+ end = document.getLineOffset(endLine + 1);
} else {
- end= document.getLength();
+ end = document.getLength();
}
return new Region(start, end - start);
}
@@ -209,16 +210,16 @@ public final class ToggleCommentAction extends TextEditorAction {
*/
private int getFirstCompleteLineOfRegion(IRegion region, IDocument document) {
try {
- int startLine= document.getLineOfOffset(region.getOffset());
+ int startLine = document.getLineOfOffset(region.getOffset());
- int offset= document.getLineOffset(startLine);
+ int offset = document.getLineOffset(startLine);
if (offset >= region.getOffset())
return startLine;
- offset= document.getLineOffset(startLine + 1);
+ offset = document.getLineOffset(startLine + 1);
return (offset > region.getOffset() + region.getLength() ? -1 : startLine + 1);
} catch (BadLocationException e) {
- CUIPlugin.log(e); // Should not happen
+ CUIPlugin.log(e); // Should not happen
}
return -1;
@@ -240,23 +241,23 @@ public final class ToggleCommentAction extends TextEditorAction {
try {
// Check for occurrences of prefixes in the given lines
boolean hasComment = false;
- for (int i= startLine; i <= endLine; i++) {
- IRegion line= document.getLineInformation(i);
- String text= document.get(line.getOffset(), line.getLength());
+ for (int i = startLine; i <= endLine; i++) {
+ IRegion line = document.getLineInformation(i);
+ String text = document.get(line.getOffset(), line.getLength());
boolean isEmptyLine = text.trim().length() == 0;
- if(isEmptyLine) {
+ if (isEmptyLine) {
continue;
}
-
- int[] found= TextUtilities.indexOf(prefixes, text, 0);
+
+ int[] found = TextUtilities.indexOf(prefixes, text, 0);
if (found[0] == -1) {
// Found a line which is not commented
return false;
}
- String s= document.get(line.getOffset(), found[0]);
- s= s.trim();
+ String s = document.get(line.getOffset(), found[0]);
+ s = s.trim();
if (s.length() != 0) {
// Found a line which is not commented
return false;
@@ -265,7 +266,7 @@ public final class ToggleCommentAction extends TextEditorAction {
}
return hasComment;
} catch (BadLocationException e) {
- CUIPlugin.log(e); // Should not happen
+ CUIPlugin.log(e); // Should not happen
}
return false;
@@ -282,20 +283,20 @@ public final class ToggleCommentAction extends TextEditorAction {
*/
private boolean isBlockEmpty(int startLine, int endLine, IDocument document) {
try {
- for (int i= startLine; i <= endLine; i++) {
- IRegion line= document.getLineInformation(i);
- String text= document.get(line.getOffset(), line.getLength());
-
+ for (int i = startLine; i <= endLine; i++) {
+ IRegion line = document.getLineInformation(i);
+ String text = document.get(line.getOffset(), line.getLength());
+
boolean isEmptyLine = text.trim().length() == 0;
- if(!isEmptyLine) {
+ if (!isEmptyLine) {
return false;
}
}
return true;
} catch (BadLocationException e) {
- CUIPlugin.log(e); // Should not happen
+ CUIPlugin.log(e); // Should not happen
}
-
+
return false;
}
@@ -314,12 +315,12 @@ public final class ToggleCommentAction extends TextEditorAction {
return;
}
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
if (fOperationTarget == null && editor != null)
- fOperationTarget= editor.getAdapter(ITextOperationTarget.class);
+ fOperationTarget = editor.getAdapter(ITextOperationTarget.class);
- boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(ITextOperationTarget.PREFIX) &&
- fOperationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
+ boolean isEnabled = (fOperationTarget != null && fOperationTarget.canDoOperation(ITextOperationTarget.PREFIX)
+ && fOperationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
setEnabled(isEnabled);
}
@@ -329,7 +330,7 @@ public final class ToggleCommentAction extends TextEditorAction {
@Override
public void setEditor(ITextEditor editor) {
super.setEditor(editor);
- fOperationTarget= null;
+ fOperationTarget = null;
}
/**
@@ -338,35 +339,35 @@ public final class ToggleCommentAction extends TextEditorAction {
* @param configuration
*/
public void configure(ISourceViewer sourceViewer, SourceViewerConfiguration configuration) {
- fPrefixesMap= null;
+ fPrefixesMap = null;
- String[] types= configuration.getConfiguredContentTypes(sourceViewer);
- Map<String, String[]> prefixesMap= new HashMap<String, String[]>(types.length);
+ String[] types = configuration.getConfiguredContentTypes(sourceViewer);
+ Map<String, String[]> prefixesMap = new HashMap<String, String[]>(types.length);
for (String type : types) {
- String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type);
+ String[] prefixes = configuration.getDefaultPrefixes(sourceViewer, type);
if (prefixes != null && prefixes.length > 0) {
- int emptyPrefixes= 0;
+ int emptyPrefixes = 0;
for (String prefixe : prefixes) {
if (prefixe.length() == 0)
emptyPrefixes++;
}
if (emptyPrefixes > 0) {
- String[] nonemptyPrefixes= new String[prefixes.length - emptyPrefixes];
- for (int j= 0, k= 0; j < prefixes.length; j++) {
- String prefix= prefixes[j];
+ String[] nonemptyPrefixes = new String[prefixes.length - emptyPrefixes];
+ for (int j = 0, k = 0; j < prefixes.length; j++) {
+ String prefix = prefixes[j];
if (prefix.length() != 0) {
- nonemptyPrefixes[k]= prefix;
+ nonemptyPrefixes[k] = prefix;
k++;
}
}
- prefixes= nonemptyPrefixes;
+ prefixes = nonemptyPrefixes;
}
prefixesMap.put(type, prefixes);
}
}
- fDocumentPartitioning= configuration.getConfiguredDocumentPartitioning(sourceViewer);
- fPrefixesMap= prefixesMap;
+ fDocumentPartitioning = configuration.getConfiguredDocumentPartitioning(sourceViewer);
+ fPrefixesMap = prefixesMap;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.java
index 1d5763e08fe..7845e35bd9c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.java
@@ -42,7 +42,8 @@ public class ToggleMarkOccurrencesAction extends TextEditorAction implements IPr
* Constructs and updates the action.
*/
public ToggleMarkOccurrencesAction() {
- super(ConstructedCEditorMessages.getResourceBundle(), "ToggleMarkOccurrencesAction.", null, IAction.AS_CHECK_BOX); //$NON-NLS-1$
+ super(ConstructedCEditorMessages.getResourceBundle(), "ToggleMarkOccurrencesAction.", null, //$NON-NLS-1$
+ IAction.AS_CHECK_BOX);
CPluginImages.setToolImageDescriptors(this, "mark_occurrences.gif"); //$NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TOGGLE_MARK_OCCURRENCES_ACTION);
update();
@@ -55,11 +56,11 @@ public class ToggleMarkOccurrencesAction extends TextEditorAction implements IPr
@Override
public void update() {
- ITextEditor editor= getTextEditor();
+ ITextEditor editor = getTextEditor();
- boolean checked= false;
+ boolean checked = false;
if (editor instanceof CEditor)
- checked= ((CEditor)editor).isMarkingOccurrences();
+ checked = ((CEditor) editor).isMarkingOccurrences();
setChecked(checked);
setEnabled(editor != null);
@@ -71,12 +72,12 @@ public class ToggleMarkOccurrencesAction extends TextEditorAction implements IPr
if (editor != null) {
if (fStore == null) {
- fStore= CUIPlugin.getDefault().getPreferenceStore();
+ fStore = CUIPlugin.getDefault().getPreferenceStore();
fStore.addPropertyChangeListener(this);
}
} else if (fStore != null) {
fStore.removePropertyChangeListener(this);
- fStore= null;
+ fStore = null;
}
update();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java
index b447616938b..f23f095a228 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java
@@ -13,8 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
-
-
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -29,14 +27,13 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.TextEditorAction;
-
/**
* A toolbar action which toggles the presentation model of the
* connected text editor. The editor shows either the highlight range
* only or always the whole document.
*/
public class TogglePresentationAction extends TextEditorAction implements IPropertyChangeListener {
-
+
private IPreferenceStore fStore;
/**
@@ -46,83 +43,83 @@ public class TogglePresentationAction extends TextEditorAction implements IPrope
super(ConstructedCEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SEGMENT_EDIT);
setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TOGGLE_PRESENTATION_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TOGGLE_PRESENTATION_ACTION);
update();
}
-
+
/*
* @see IAction#actionPerformed
*/
@Override
public void run() {
-
- ITextEditor editor= getTextEditor();
+
+ ITextEditor editor = getTextEditor();
if (editor == null)
return;
-
- IRegion remembered= editor.getHighlightRange();
+
+ IRegion remembered = editor.getHighlightRange();
editor.resetHighlightRange();
-
- boolean showAll= !editor.showsHighlightRangeOnly();
+
+ boolean showAll = !editor.showsHighlightRangeOnly();
setChecked(showAll);
-
+
editor.showHighlightRangeOnly(showAll);
if (remembered != null)
editor.setHighlightRange(remembered.getOffset(), remembered.getLength(), true);
-
+
fStore.removePropertyChangeListener(this);
fStore.setValue(PreferenceConstants.EDITOR_SHOW_SEGMENTS, showAll);
fStore.addPropertyChangeListener(this);
}
-
+
/*
* @see TextEditorAction#update
*/
@Override
public void update() {
- ITextEditor editor= getTextEditor();
- boolean checked= (editor != null && editor.showsHighlightRangeOnly());
+ ITextEditor editor = getTextEditor();
+ boolean checked = (editor != null && editor.showsHighlightRangeOnly());
setChecked(checked);
setEnabled(editor != null);
}
-
+
/*
* @see TextEditorAction#setEditor(ITextEditor)
*/
@Override
public void setEditor(ITextEditor editor) {
-
+
super.setEditor(editor);
-
+
if (editor != null) {
-
+
if (fStore == null) {
- fStore= CUIPlugin.getDefault().getPreferenceStore();
+ fStore = CUIPlugin.getDefault().getPreferenceStore();
fStore.addPropertyChangeListener(this);
}
synchronizeWithPreference(editor);
-
+
} else if (fStore != null) {
fStore.removePropertyChangeListener(this);
- fStore= null;
+ fStore = null;
}
-
+
update();
}
-
+
/**
* Synchronizes the appearance of the editor with what the preference store tells him.
*/
private void synchronizeWithPreference(ITextEditor editor) {
-
+
if (editor == null)
return;
-
- boolean showSegments= fStore.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS);
+
+ boolean showSegments = fStore.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS);
setChecked(showSegments);
-
+
if (editor.showsHighlightRangeOnly() != showSegments) {
- IRegion remembered= editor.getHighlightRange();
+ IRegion remembered = editor.getHighlightRange();
editor.resetHighlightRange();
editor.showHighlightRangeOnly(showSegments);
if (remembered != null)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.java
index f48add63089..4bbdd5c430a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.java
@@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
/**
* Editor action to toggle between source and header files.
- *
+ *
* @since 4.0
*/
public class ToggleSourceAndHeaderAction extends TextEditorAction {
@@ -41,7 +41,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
/**
* Create a toggle source/header action for the given editor.
- *
+ *
* @param bundle the resource bundle to take the label, tooltip and description from.
* @param prefix the prefix to be prepended to the resource bundle keys
* @param editor the text editor this action is associated with
@@ -53,14 +53,14 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
@Override
public void run() {
- IWorkingCopy currentUnit= getWorkingCopy();
+ IWorkingCopy currentUnit = getWorkingCopy();
if (currentUnit == null) {
return;
}
- ITranslationUnit partnerUnit= computePartnerFile(currentUnit);
+ ITranslationUnit partnerUnit = computePartnerFile(currentUnit);
if (partnerUnit != null) {
- fgLastSourceUnit= currentUnit.getOriginalElement();
- fgLastPartnerUnit= partnerUnit;
+ fgLastSourceUnit = currentUnit.getOriginalElement();
+ fgLastPartnerUnit = partnerUnit;
try {
EditorUtility.openInEditor(partnerUnit);
} catch (PartInitException exc) {
@@ -76,8 +76,8 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
if (editor == null) {
return null;
}
- IEditorInput input= editor.getEditorInput();
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
+ IEditorInput input = editor.getEditorInput();
+ IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(input);
}
@@ -88,7 +88,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
/**
* Compute the corresponding translation unit for the given unit.
- *
+ *
* @param tUnit the current source/header translation unit
* @return the partner translation unit
*/
@@ -97,9 +97,9 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
if (fgLastPartnerUnit != null) {
final ITranslationUnit originalUnit;
if (tUnit instanceof IWorkingCopy) {
- originalUnit= ((IWorkingCopy)tUnit).getOriginalElement();
+ originalUnit = ((IWorkingCopy) tUnit).getOriginalElement();
} else {
- originalUnit= tUnit;
+ originalUnit = tUnit;
}
if (originalUnit.getTranslationUnit().equals(fgLastPartnerUnit)) {
if (fgLastSourceUnit.exists()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationModelEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationModelEvent.java
index 9ffa898e7a9..1c6a9045196 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationModelEvent.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationModelEvent.java
@@ -26,47 +26,46 @@ import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.ui.texteditor.MarkerAnnotation;
-
/**
*
* TranslationUnitAnnotationModelEvent
*
* Event sent out by changes of the compilation unit annotation model.
*/
-public class TranslationUnitAnnotationModelEvent extends AnnotationModelEvent {
-
+public class TranslationUnitAnnotationModelEvent extends AnnotationModelEvent {
+
private boolean fIncludesProblemMarkerAnnotations;
private IResource fUnderlyingResource;
-
+
/**
* Constructor for CompilationUnitAnnotationModelEvent.
* @param model
- * @param underlyingResource The annotation model's underlying resource
+ * @param underlyingResource The annotation model's underlying resource
*/
public TranslationUnitAnnotationModelEvent(IAnnotationModel model, IResource underlyingResource) {
super(model);
- fUnderlyingResource= underlyingResource;
- fIncludesProblemMarkerAnnotations= false;
+ fUnderlyingResource = underlyingResource;
+ fIncludesProblemMarkerAnnotations = false;
}
-
+
private void testIfProblemMarker(Annotation annotation) {
if (fIncludesProblemMarkerAnnotations) {
return;
}
if (annotation instanceof CMarkerAnnotation) {
- fIncludesProblemMarkerAnnotations= ((CMarkerAnnotation) annotation).isProblem();
+ fIncludesProblemMarkerAnnotations = ((CMarkerAnnotation) annotation).isProblem();
} else if (annotation instanceof MarkerAnnotation) {
try {
- IMarker marker= ((MarkerAnnotation) annotation).getMarker();
+ IMarker marker = ((MarkerAnnotation) annotation).getMarker();
if (!marker.exists() || marker.isSubtypeOf(IMarker.PROBLEM)) {
- fIncludesProblemMarkerAnnotations= true;
+ fIncludesProblemMarkerAnnotations = true;
}
} catch (CoreException e) {
CUIPlugin.log(e);
}
- }
+ }
}
-
+
/*
* @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationAdded(org.eclipse.jface.text.source.Annotation)
*/
@@ -76,7 +75,6 @@ public class TranslationUnitAnnotationModelEvent extends AnnotationModelEvent {
testIfProblemMarker(annotation);
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationRemoved(org.eclipse.jface.text.source.Annotation, org.eclipse.jface.text.Position)
*/
@@ -94,7 +92,7 @@ public class TranslationUnitAnnotationModelEvent extends AnnotationModelEvent {
super.annotationRemoved(annotation);
testIfProblemMarker(annotation);
}
-
+
/*
* @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationChanged(org.eclipse.jface.text.source.Annotation)
*/
@@ -103,16 +101,16 @@ public class TranslationUnitAnnotationModelEvent extends AnnotationModelEvent {
testIfProblemMarker(annotation);
super.annotationChanged(annotation);
}
-
+
/**
* Returns whether the change included problem marker annotations.
- *
+ *
* @return <code>true</code> if the change included marker annotations
*/
public boolean includesProblemMarkerAnnotationChanges() {
return fIncludesProblemMarkerAnnotations;
}
-
+
/**
* Returns the annotation model's underlying resource
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
index f90a1f01054..860e03ce181 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
@@ -44,67 +44,67 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
/**
* Creates a new working copy manager that co-operates with the given
* compilation unit document provider.
- *
+ *
* @param provider the provider
*/
public WorkingCopyManager(CDocumentProvider provider) {
Assert.isNotNull(provider);
- fDocumentProvider= provider;
+ fDocumentProvider = provider;
}
@Override
public void connect(IEditorInput input) throws CoreException {
fDocumentProvider.connect(input);
}
-
+
@Override
public void disconnect(IEditorInput input) {
fDocumentProvider.disconnect(input);
}
-
+
@Override
public void shutdown() {
if (!fIsShuttingDown) {
- fIsShuttingDown= true;
+ fIsShuttingDown = true;
try {
if (fMap != null) {
fMap.clear();
- fMap= null;
+ fMap = null;
}
fDocumentProvider.shutdown();
} finally {
- fIsShuttingDown= false;
+ fIsShuttingDown = false;
}
}
}
@Override
public IWorkingCopy getWorkingCopy(IEditorInput input) {
- IWorkingCopy unit= fMap == null ? null : fMap.get(input);
+ IWorkingCopy unit = fMap == null ? null : fMap.get(input);
return unit != null ? unit : fDocumentProvider.getWorkingCopy(input);
}
-
+
@Override
public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) {
if (fDocumentProvider.getDocument(input) != null) {
if (fMap == null)
- fMap= new HashMap<>();
+ fMap = new HashMap<>();
fMap.put(input, workingCopy);
}
}
-
+
@Override
public void removeWorkingCopy(IEditorInput input) {
fMap.remove(input);
if (fMap.isEmpty())
- fMap= null;
+ fMap = null;
}
- public IBufferFactory getBufferFactory() {
+ public IBufferFactory getBufferFactory() {
if (fBufferFactory == null) {
synchronized (this) {
if (fBufferFactory == null)
- fBufferFactory= new CustomBufferFactory();
+ fBufferFactory = new CustomBufferFactory();
}
}
return fBufferFactory;
@@ -123,6 +123,7 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
@Override
public IWorkingCopy getSharedWorkingCopy(ITranslationUnit original, IProblemRequestor requestor,
IProgressMonitor progressMonitor) throws CModelException {
- return CModelManager.getDefault().getSharedWorkingCopy(getBufferFactory(), original, requestor, progressMonitor);
+ return CModelManager.getDefault().getSharedWorkingCopy(getBufferFactory(), original, requestor,
+ progressMonitor);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java
index 2d3b7279ff5..c1f49f9000c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java
@@ -29,19 +29,20 @@ public class ASMEditorActionContributor extends TextEditorActionContributor {
* Default constructor is mandatory (executable extension).
*/
public ASMEditorActionContributor() {
- fTogglePresentation= new TogglePresentationAction();
+ fTogglePresentation = new TogglePresentationAction();
fTogglePresentation.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
}
-
+
/*
* @see org.eclipse.ui.editors.text.TextEditorActionContributor#init(org.eclipse.ui.IActionBars)
*/
@Override
public void init(IActionBars bars) {
super.init(bars);
- bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
+ bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY,
+ fTogglePresentation);
}
-
+
/*
* @see org.eclipse.ui.editors.text.TextEditorActionContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
*/
@@ -50,19 +51,19 @@ public class ASMEditorActionContributor extends TextEditorActionContributor {
super.setActiveEditor(part);
internalSetActiveEditor(part);
}
-
+
private void internalSetActiveEditor(IEditorPart part) {
- ITextEditor textEditor= null;
+ ITextEditor textEditor = null;
if (part instanceof ITextEditor)
- textEditor= (ITextEditor) part;
-
+ textEditor = (ITextEditor) part;
+
fTogglePresentation.setEditor(textEditor);
-
+
if (part instanceof AsmTextEditor) {
((AsmTextEditor) part).fillActionBars(getActionBars());
}
}
-
+
/*
* @see org.eclipse.ui.editors.text.TextEditorActionContributor#dispose()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java
index 69775ad1601..3d80ed03839 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -32,63 +32,57 @@ import org.eclipse.cdt.ui.text.ITokenStoreFactory;
import org.eclipse.cdt.internal.ui.text.CWhitespaceRule;
-
/*
* An assembly code scanner.
*/
public final class AsmCodeScanner extends AbstractCScanner {
-
- private static String[] fgTokenProperties= {
- ICColorConstants.ASM_DIRECTIVE,
- ICColorConstants.ASM_LABEL,
- ICColorConstants.C_KEYWORD,
- ICColorConstants.C_SINGLE_LINE_COMMENT,
- ICColorConstants.C_DEFAULT
- };
+
+ private static String[] fgTokenProperties = { ICColorConstants.ASM_DIRECTIVE, ICColorConstants.ASM_LABEL,
+ ICColorConstants.C_KEYWORD, ICColorConstants.C_SINGLE_LINE_COMMENT, ICColorConstants.C_DEFAULT };
private IAsmLanguage fAsmLanguage;
-
+
/**
* Creates an assembly code scanner.
*/
public AsmCodeScanner(ITokenStoreFactory factory, IAsmLanguage asmLanguage) {
super(factory.createTokenStore(fgTokenProperties));
- fAsmLanguage= asmLanguage;
+ fAsmLanguage = asmLanguage;
setRules(createRules());
}
protected List<IRule> createRules() {
IToken token;
- List<IRule> rules= new ArrayList<IRule>();
+ List<IRule> rules = new ArrayList<IRule>();
// Add rule(s) for single line comments
- token= getToken(ICColorConstants.C_SINGLE_LINE_COMMENT);
- char[] lineCommentChars= fAsmLanguage.getLineCommentCharacters();
- for (int i= 0; i < lineCommentChars.length; i++) {
- rules.add(new EndOfLineRule(new String(new char [] {lineCommentChars[i]}), token));
+ token = getToken(ICColorConstants.C_SINGLE_LINE_COMMENT);
+ char[] lineCommentChars = fAsmLanguage.getLineCommentCharacters();
+ for (int i = 0; i < lineCommentChars.length; i++) {
+ rules.add(new EndOfLineRule(new String(new char[] { lineCommentChars[i] }), token));
}
- final IToken other= getToken(ICColorConstants.C_DEFAULT);
+ final IToken other = getToken(ICColorConstants.C_DEFAULT);
// Add generic whitespace rule.
rules.add(new CWhitespaceRule(other));
// Add rule for labels
- token= getToken(ICColorConstants.ASM_LABEL);
- IRule labelRule= new AsmLabelRule(new AsmWordDetector(false), token, other);
+ token = getToken(ICColorConstants.ASM_LABEL);
+ IRule labelRule = new AsmLabelRule(new AsmWordDetector(false), token, other);
rules.add(labelRule);
-
+
// Add word rule for keywords
- token= getToken(ICColorConstants.ASM_DIRECTIVE);
- String[] keywords= fAsmLanguage.getDirectiveKeywords();
- WordRule wordRule= new WordRule(new AsmWordDetector('.'), other);
- for (int i=0; i<keywords.length; i++)
+ token = getToken(ICColorConstants.ASM_DIRECTIVE);
+ String[] keywords = fAsmLanguage.getDirectiveKeywords();
+ WordRule wordRule = new WordRule(new AsmWordDetector('.'), other);
+ for (int i = 0; i < keywords.length; i++)
wordRule.addWord(keywords[i], token);
rules.add(wordRule);
// TODO use extra color?
- token= getToken(ICColorConstants.C_KEYWORD);
- WordPatternRule regPattern= new WordPatternRule(new AsmWordDetector('%', (char)0), "%", null, token); //$NON-NLS-1$
+ token = getToken(ICColorConstants.C_KEYWORD);
+ WordPatternRule regPattern = new WordPatternRule(new AsmWordDetector('%', (char) 0), "%", null, token); //$NON-NLS-1$
rules.add(regPattern);
setDefaultReturnToken(other);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.java
index a3696831de2..32ebaa80fa0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.java
@@ -38,7 +38,7 @@ public class AsmContentOutlinePage extends AbstractCModelOutlinePage {
@Override
protected OpenViewActionGroup createOpenViewActionGroup() {
- OpenViewActionGroup ovag= new OpenViewActionGroup(this);
+ OpenViewActionGroup ovag = new OpenViewActionGroup(this);
ovag.setEnableIncludeBrowser(false);
ovag.setSuppressCallHierarchy(true);
ovag.setSuppressTypeHierarchy(true);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java
index 342549f5763..ae102e42647 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java
@@ -33,15 +33,15 @@ public class AsmDocumentSetupParticipant implements IDocumentSetupParticipant, I
*/
public AsmDocumentSetupParticipant() {
}
-
+
/*
* @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
*/
@Override
public void setup(IDocument document) {
- IDocumentPartitioner partitioner= CDTUITools.createAsmDocumentPartitioner();
+ IDocumentPartitioner partitioner = CDTUITools.createAsmDocumentPartitioner();
if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
+ IDocumentExtension3 extension3 = (IDocumentExtension3) document;
extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
} else {
document.setDocumentPartitioner(partitioner);
@@ -53,7 +53,8 @@ public class AsmDocumentSetupParticipant implements IDocumentSetupParticipant, I
* @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
*/
@Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ throws CoreException {
// prepared for partitioner configuration
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.java
index 394398f283c..946f2a460c1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.java
@@ -43,9 +43,9 @@ final class AsmLabelRule implements IRule {
Assert.isNotNull(labelToken);
Assert.isNotNull(defaultToken);
- fDetector= detector;
- fLabelToken= labelToken;
- fDefaultToken= defaultToken;
+ fDetector = detector;
+ fLabelToken = labelToken;
+ fDefaultToken = defaultToken;
}
/*
@@ -53,14 +53,14 @@ final class AsmLabelRule implements IRule {
*/
@Override
public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
+ int c = scanner.read();
if (fDetector.isWordStart((char) c)) {
- int count= 1;
+ int count = 1;
do {
- c= scanner.read();
+ c = scanner.read();
++count;
} while (fDetector.isWordPart((char) c));
- if(c == ':') {
+ if (c == ':') {
return fLabelToken;
}
if (fDefaultToken.isUndefined()) {
@@ -70,7 +70,7 @@ final class AsmLabelRule implements IRule {
}
return fDefaultToken;
}
-
+
scanner.unread();
return Token.UNDEFINED;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java
index a7107b35fc7..14561e63752 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java
@@ -39,13 +39,9 @@ import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
public class AsmPreprocessorScanner extends AbstractCScanner {
/** Properties for tokens. */
- private static final String[] fgTokenProperties= {
- ICColorConstants.C_SINGLE_LINE_COMMENT,
- ICColorConstants.PP_DIRECTIVE,
- ICColorConstants.C_STRING,
- ICColorConstants.PP_HEADER,
- ICColorConstants.PP_DEFAULT,
- };
+ private static final String[] fgTokenProperties = { ICColorConstants.C_SINGLE_LINE_COMMENT,
+ ICColorConstants.PP_DIRECTIVE, ICColorConstants.C_STRING, ICColorConstants.PP_HEADER,
+ ICColorConstants.PP_DEFAULT, };
private IAsmLanguage fAsmLanguage;
@@ -57,7 +53,7 @@ public class AsmPreprocessorScanner extends AbstractCScanner {
public AsmPreprocessorScanner(ITokenStoreFactory factory, IAsmLanguage asmLanguage) {
super(factory.createTokenStore(fgTokenProperties));
Assert.isNotNull(asmLanguage);
- fAsmLanguage= asmLanguage;
+ fAsmLanguage = asmLanguage;
setRules(createRules());
}
@@ -65,18 +61,19 @@ public class AsmPreprocessorScanner extends AbstractCScanner {
* Creates rules used in this RulesBasedScanner
*/
protected List<IRule> createRules() {
- List<IRule> rules= new ArrayList<IRule>();
- IToken defaultToken= getToken(ICColorConstants.PP_DEFAULT);
+ List<IRule> rules = new ArrayList<IRule>();
+ IToken defaultToken = getToken(ICColorConstants.PP_DEFAULT);
IToken token;
// Add generic white space rule.
rules.add(new CWhitespaceRule(defaultToken));
- token= getToken(ICColorConstants.PP_DIRECTIVE);
- PreprocessorRule preprocessorRule= new PreprocessorRule(new CWordDetector(), defaultToken, getToken(ICColorConstants.C_SINGLE_LINE_COMMENT));
- String[] ppKeywords= fAsmLanguage.getPreprocessorKeywords();
- for (int i= 0; i < ppKeywords.length; i++) {
- String ppKeyword= ppKeywords[i];
+ token = getToken(ICColorConstants.PP_DIRECTIVE);
+ PreprocessorRule preprocessorRule = new PreprocessorRule(new CWordDetector(), defaultToken,
+ getToken(ICColorConstants.C_SINGLE_LINE_COMMENT));
+ String[] ppKeywords = fAsmLanguage.getPreprocessorKeywords();
+ for (int i = 0; i < ppKeywords.length; i++) {
+ String ppKeyword = ppKeywords[i];
if (ppKeyword.length() > 1) {
preprocessorRule.addWord(ppKeyword, token);
}
@@ -90,7 +87,7 @@ public class AsmPreprocessorScanner extends AbstractCScanner {
rules.add(headerRule);
token = getToken(ICColorConstants.C_SINGLE_LINE_COMMENT);
- IRule lineCommentRule= new EndOfLineRule("#", token); //$NON-NLS-1$
+ IRule lineCommentRule = new EndOfLineRule("#", token); //$NON-NLS-1$
rules.add(lineCommentRule);
// token = getToken(ICColorConstants.C_MULTI_LINE_COMMENT);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.java
index 5d29462c539..18967e2dc3d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.java
@@ -39,7 +39,7 @@ public class AsmReconcilingStrategy implements IReconcilingStrategy, IReconcilin
private ITextEditor fEditor;
public AsmReconcilingStrategy(ITextEditor editor) {
- fEditor= editor;
+ fEditor = editor;
}
private IProgressMonitor fProgressMonitor;
@@ -73,7 +73,7 @@ public class AsmReconcilingStrategy implements IReconcilingStrategy, IReconcilin
*/
@Override
public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
+ fProgressMonitor = monitor;
}
/*
@@ -86,7 +86,7 @@ public class AsmReconcilingStrategy implements IReconcilingStrategy, IReconcilin
private void reconcile(final boolean initialReconcile) {
IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager();
- IWorkingCopy workingCopy= fManager.getWorkingCopy(fEditor.getEditorInput());
+ IWorkingCopy workingCopy = fManager.getWorkingCopy(fEditor.getEditorInput());
if (workingCopy == null) {
return;
}
@@ -98,9 +98,10 @@ public class AsmReconcilingStrategy implements IReconcilingStrategy, IReconcilin
} catch (OperationCanceledException oce) {
// document was modified while parsing
} catch (CModelException e) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e); //$NON-NLS-1$
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
+ "Error in CDT UI during reconcile", e); //$NON-NLS-1$
CUIPlugin.log(status);
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java
index 34e4db2e683..f233c6f462b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -15,7 +15,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor.asm;
-
import java.util.Iterator;
import org.eclipse.jface.action.GroupMarker;
@@ -72,11 +71,10 @@ import org.eclipse.cdt.internal.ui.editor.AbstractCModelOutlinePage;
import org.eclipse.cdt.internal.ui.editor.CAnnotationIterator;
import org.eclipse.cdt.internal.ui.editor.ICAnnotation;
-
/**
* Assembly text editor.
*/
-public class AsmTextEditor extends TextEditor implements ISelectionChangedListener, ICModelBasedEditor {
+public class AsmTextEditor extends TextEditor implements ISelectionChangedListener, ICModelBasedEditor {
/**
* Updates the outline page selection and this editor's range indicator.
@@ -90,7 +88,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
AsmTextEditor.this.selectionChanged();
}
}
-
+
private AbstractCModelOutlinePage fOutlinePage;
private EditorSelectionChangedListener fEditorSelectionChangedListener;
@@ -103,19 +101,20 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
public AsmTextEditor() {
super();
}
-
+
/**
* Initializes this editor.
*/
@Override
protected void initializeEditor() {
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
// FIXME: Should this editor have a different preference store ?
// For now we are sharing with the CEditor and any changes in the
// setting of the CEditor will be reflected in this editor.
setPreferenceStore(store);
final IColorManager colorManager = CDTUITools.getColorManager();
- setSourceViewerConfiguration(new AsmSourceViewerConfiguration(colorManager, store, this, ICPartitions.C_PARTITIONING));
+ setSourceViewerConfiguration(
+ new AsmSourceViewerConfiguration(colorManager, store, this, ICPartitions.C_PARTITIONING));
setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
setEditorContextMenuId("#ASMEditorContext"); //$NON-NLS-1$
setRulerContextMenuId("#ASMEditorRulerContext"); //$NON-NLS-1$
@@ -151,7 +150,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
public void createPartControl(Composite parent) {
super.createPartControl(parent);
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICHelpContextIds.ASMEDITOR_VIEW);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICHelpContextIds.ASMEDITOR_VIEW);
fEditorSelectionChangedListener = new EditorSelectionChangedListener();
fEditorSelectionChangedListener.install(getSelectionProvider());
@@ -166,7 +165,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
fOutlinePage.dispose();
fOutlinePage = null;
}
- if (fEditorSelectionChangedListener != null) {
+ if (fEditorSelectionChangedListener != null) {
fEditorSelectionChangedListener.uninstall(getSelectionProvider());
fEditorSelectionChangedListener = null;
}
@@ -185,7 +184,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
protected boolean affectsTextPresentation(PropertyChangeEvent event) {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
if (configuration instanceof AsmSourceViewerConfiguration) {
- return ((AsmSourceViewerConfiguration)configuration).affectsTextPresentation(event);
+ return ((AsmSourceViewerConfiguration) configuration).affectsTextPresentation(event);
}
return false;
}
@@ -197,7 +196,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
if (configuration instanceof AsmSourceViewerConfiguration) {
- ((AsmSourceViewerConfiguration)configuration).handlePropertyChangeEvent(event);
+ ((AsmSourceViewerConfiguration) configuration).handlePropertyChangeEvent(event);
}
super.handlePreferenceStoreChanged(event);
}
@@ -211,7 +210,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
menu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
// separator for debug related actions (similar to ruler context menu)
menu.add(new Separator(IContextMenuConstants.GROUP_DEBUG));
- menu.add(new GroupMarker(IContextMenuConstants.GROUP_DEBUG+".end")); //$NON-NLS-1$
+ menu.add(new GroupMarker(IContextMenuConstants.GROUP_DEBUG + ".end")); //$NON-NLS-1$
// The base implementation creates GROUP_OPEN, so actions added
// to GROUP_OPEN need to come after this.
@@ -226,7 +225,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
/**
* Gets the outline page for this editor.
- * @return Outline page.
+ * @return Outline page.
*/
public AbstractCModelOutlinePage getOutlinePage() {
if (fOutlinePage == null) {
@@ -238,7 +237,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
}
/**
- * Sets an input for the outline page.
+ * Sets an input for the outline page.
* @param page Page to set the input.
* @param input Input to set.
*/
@@ -255,7 +254,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
protected void selectionChanged() {
if (getSelectionProvider() == null)
return;
- ISourceReference element= computeHighlightRangeSourceReference();
+ ISourceReference element = computeHighlightRangeSourceReference();
updateStatusLine();
synchronizeOutlinePage();
setSelection(element, false);
@@ -266,13 +265,13 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
* position in the editor.
*/
protected void synchronizeOutlinePage() {
- if(fOutlinePage != null && fOutlinePage.isLinkingEnabled()) {
+ if (fOutlinePage != null && fOutlinePage.isLinkingEnabled()) {
fOutlinePage.removeSelectionChangedListener(this);
fOutlinePage.synchronizeSelectionWithEditor();
fOutlinePage.addSelectionChangedListener(this);
}
- }
-
+ }
+
protected void updateStatusLine() {
ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection();
Annotation annotation = getAnnotation(selection.getOffset(), selection.getLength());
@@ -287,36 +286,36 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
/**
* Returns the annotation overlapping with the given range or <code>null</code>.
- *
+ *
* @param offset the region offset
* @param length the region length
* @return the found annotation or <code>null</code>
*/
private Annotation getAnnotation(int offset, int length) {
- IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+ IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
if (model == null)
return null;
-
+
@SuppressWarnings("rawtypes")
Iterator parent;
if (model instanceof IAnnotationModelExtension2) {
- parent= ((IAnnotationModelExtension2)model).getAnnotationIterator(offset, length, true, true);
+ parent = ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true);
} else {
- parent= model.getAnnotationIterator();
+ parent = model.getAnnotationIterator();
}
@SuppressWarnings("unchecked")
- Iterator<Annotation> e= new CAnnotationIterator(parent, false);
+ Iterator<Annotation> e = new CAnnotationIterator(parent, false);
while (e.hasNext()) {
Annotation a = e.next();
if (!isNavigationTarget(a))
continue;
-
+
Position p = model.getPosition(a);
if (p != null && p.overlapsWith(offset, length))
return a;
}
-
+
return null;
}
@@ -331,7 +330,6 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
}
return null;
}
-
/**
* Computes and returns the source reference that includes the caret and
@@ -341,26 +339,26 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
* @return the computed source reference
*/
protected ISourceReference computeHighlightRangeSourceReference() {
- ISourceViewer sourceViewer= getSourceViewer();
+ ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null)
return null;
- StyledText styledText= sourceViewer.getTextWidget();
+ StyledText styledText = sourceViewer.getTextWidget();
if (styledText == null)
return null;
- int caret= 0;
+ int caret = 0;
if (sourceViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)sourceViewer;
- caret= extension.widgetOffset2ModelOffset(styledText.getSelection().x);
+ ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
+ caret = extension.widgetOffset2ModelOffset(styledText.getSelection().x);
} else {
- int offset= sourceViewer.getVisibleRegion().getOffset();
- caret= offset + styledText.getSelection().x;
+ int offset = sourceViewer.getVisibleRegion().getOffset();
+ caret = offset + styledText.getSelection().x;
}
- ICElement element= getElementAt(caret, false);
+ ICElement element = getElementAt(caret, false);
- if ( !(element instanceof ISourceReference))
+ if (!(element instanceof ISourceReference))
return null;
return (ISourceReference) element;
@@ -377,7 +375,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
* @return the most narrow element which includes the given offset
*/
protected ICElement getElementAt(int offset, boolean reconcile) {
- ITranslationUnit unit= getInputCElement();
+ ITranslationUnit unit = getInputCElement();
if (unit != null) {
try {
@@ -403,7 +401,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
*
* @return the C element wrapped by this editors input.
*/
- public IWorkingCopy getInputCElement () {
+ public IWorkingCopy getInputCElement() {
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
}
@@ -424,27 +422,27 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
setSelection(range, !isActivePart());
}
} catch (CModelException e) {
- // Selection change not applied.
+ // Selection change not applied.
}
}
}
}
/**
- * Checks is the editor active part.
- * @return <code>true</code> if editor is the active part of the workbench.
+ * Checks is the editor active part.
+ * @return <code>true</code> if editor is the active part of the workbench.
*/
- private boolean isActivePart() {
+ private boolean isActivePart() {
IWorkbenchWindow window = getSite().getWorkbenchWindow();
IPartService service = window.getPartService();
return (this == service.getActivePart());
}
/**
- * Sets selection for C element.
- * @param element Element to select.
+ * Sets selection for C element.
+ * @param element Element to select.
*/
- public void setSelection(ICElement element) {
+ public void setSelection(ICElement element) {
if (element instanceof ISourceReference && !(element instanceof ITranslationUnit)) {
ISourceReference reference = (ISourceReference) element;
// set hightlight range
@@ -452,26 +450,26 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
}
}
- /**
- * Sets selection for source reference.
- * @param element Source reference to set.
- * @param moveCursor Should cursor be moved.
- */
- public void setSelection(ISourceReference element, boolean moveCursor) {
+ /**
+ * Sets selection for source reference.
+ * @param element Source reference to set.
+ * @param moveCursor Should cursor be moved.
+ */
+ public void setSelection(ISourceReference element, boolean moveCursor) {
if (element != null) {
- StyledText textWidget = null;
-
+ StyledText textWidget = null;
+
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer != null)
textWidget = sourceViewer.getTextWidget();
-
+
if (textWidget == null)
return;
try {
setSelection(element.getSourceRange(), moveCursor);
} catch (CModelException e) {
- // Selection not applied.
+ // Selection not applied.
}
}
}
@@ -487,9 +485,9 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
if (getSelectionProvider() == null)
return;
- ISelection selection= getSelectionProvider().getSelection();
+ ISelection selection = getSelectionProvider().getSelection();
if (selection instanceof ITextSelection) {
- ITextSelection textSelection= (ITextSelection) selection;
+ ITextSelection textSelection = (ITextSelection) selection;
// PR 39995: [navigation] Forward history cleared after going back in navigation history:
// mark only in navigation history if the cursor is being moved (which it isn't if
// this is called from a PostSelectionEvent that should only update the magnet)
@@ -498,14 +496,14 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
}
if (element != null) {
-
- StyledText textWidget= null;
-
- ISourceViewer sourceViewer= getSourceViewer();
+
+ StyledText textWidget = null;
+
+ ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null)
return;
-
- textWidget= sourceViewer.getTextWidget();
+
+ textWidget = sourceViewer.getTextWidget();
if (textWidget == null)
return;
@@ -513,26 +511,29 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
IRegion alternateRegion = null;
int start = element.getStartPos();
int length = element.getLength();
-
+
// Sanity check sometimes the parser may throw wrong numbers.
if (start < 0 || length < 0) {
start = 0;
length = 0;
}
-
+
// 0 length and start and non-zero start line says we know
// the line for some reason, but not the offset.
if (length == 0 && start == 0 && element.getStartLine() > 0) {
// We have the information in term of lines, we can work it out.
// Binary elements return the first executable statement so we have to subtract -1
- start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
+ start = getDocumentProvider().getDocument(getEditorInput())
+ .getLineOffset(element.getStartLine() - 1);
if (element.getEndLine() > 0) {
- length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
+ length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine())
+ - start;
} else {
length = start;
}
// create an alternate region for the keyword highlight.
- alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
+ alternateRegion = getDocumentProvider().getDocument(getEditorInput())
+ .getLineInformation(element.getStartLine() - 1);
if (start == length || length < 0) {
if (alternateRegion != null) {
start = alternateRegion.getOffset();
@@ -541,7 +542,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
}
}
setHighlightRange(start, length, moveCursor);
-
+
if (moveCursor) {
start = element.getIdStartPos();
length = element.getIdLength();
@@ -550,7 +551,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
length = alternateRegion.getLength();
}
if (start > -1 && length > 0) {
- try {
+ try {
textWidget.setRedraw(false);
sourceViewer.revealRange(start, length);
sourceViewer.setSelectedRange(start, length);
@@ -562,9 +563,9 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
}
} catch (IllegalArgumentException x) {
- // No information to the user
+ // No information to the user
} catch (BadLocationException e) {
- // No information to the user
+ // No information to the user
}
} else if (moveCursor) {
resetHighlightRange();
@@ -579,13 +580,13 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
@Override
protected void initializeKeyBindingScopes() {
- setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.asmEditorScope" }); //$NON-NLS-1$
+ setKeyBindingScopes(new String[] { "org.eclipse.cdt.ui.asmEditorScope" }); //$NON-NLS-1$
}
-
+
@Override
protected void createActions() {
super.createActions();
-
+
fOpenInViewGroup = new OpenViewActionGroup(this);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java
index 983551272c3..613e99914a8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -36,23 +36,22 @@ import org.eclipse.cdt.internal.ui.text.TokenStore;
import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner;
import org.eclipse.cdt.internal.ui.text.util.CColorManager;
-
/**
* This type shares all scanners and the color manager between
* its clients.
- *
+ *
* @deprecated No longer used within CDT.
*/
@Deprecated
public class AsmTextTools {
-
- private class PreferenceListener implements IPropertyChangeListener {
- @Override
+
+ private class PreferenceListener implements IPropertyChangeListener {
+ @Override
public void propertyChange(PropertyChangeEvent event) {
- adaptToPreferenceChange(event);
- }
- }
-
+ adaptToPreferenceChange(event);
+ }
+ }
+
/** The color manager -- use the same as for C code */
private CColorManager fColorManager;
/** The Asm source code scanner */
@@ -65,83 +64,83 @@ public class AsmTextTools {
private SingleTokenCScanner fStringScanner;
/** The ASM preprocessor scanner */
private AsmPreprocessorScanner fPreprocessorScanner;
-
+
/** The preference store */
private IPreferenceStore fPreferenceStore;
/** The preference change listener */
- private PreferenceListener fPreferenceListener= new PreferenceListener();
-
-
- /**
- * Creates a new Asm text tools collection and eagerly creates
- * and initializes all members of this collection.
- */
- public AsmTextTools(IPreferenceStore store) {
- fPreferenceStore = store != null ? store : CUIPlugin.getDefault().getCombinedPreferenceStore();
- fColorManager= new CColorManager();
-
- ITokenStoreFactory factory= new ITokenStoreFactory() {
+ private PreferenceListener fPreferenceListener = new PreferenceListener();
+
+ /**
+ * Creates a new Asm text tools collection and eagerly creates
+ * and initializes all members of this collection.
+ */
+ public AsmTextTools(IPreferenceStore store) {
+ fPreferenceStore = store != null ? store : CUIPlugin.getDefault().getCombinedPreferenceStore();
+ fColorManager = new CColorManager();
+
+ ITokenStoreFactory factory = new ITokenStoreFactory() {
@Override
public ITokenStore createTokenStore(String[] propertyColorNames) {
return new TokenStore(fColorManager, fPreferenceStore, propertyColorNames);
}
};
- fCodeScanner= new AsmCodeScanner(factory, AssemblyLanguage.getDefault());
- fPreprocessorScanner= new AsmPreprocessorScanner(factory, AssemblyLanguage.getDefault());
- fMultilineCommentScanner= new CCommentScanner(factory, ICColorConstants.C_MULTI_LINE_COMMENT);
- fSinglelineCommentScanner= new CCommentScanner(factory, ICColorConstants.C_SINGLE_LINE_COMMENT);
- fStringScanner= new SingleTokenCScanner(factory, ICColorConstants.C_STRING);
+ fCodeScanner = new AsmCodeScanner(factory, AssemblyLanguage.getDefault());
+ fPreprocessorScanner = new AsmPreprocessorScanner(factory, AssemblyLanguage.getDefault());
+ fMultilineCommentScanner = new CCommentScanner(factory, ICColorConstants.C_MULTI_LINE_COMMENT);
+ fSinglelineCommentScanner = new CCommentScanner(factory, ICColorConstants.C_SINGLE_LINE_COMMENT);
+ fStringScanner = new SingleTokenCScanner(factory, ICColorConstants.C_STRING);
// listener must be registered after initializing scanners
- fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
- }
-
+ fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
+ }
+
/**
- * Creates a new Asm text tools collection and eagerly creates
+ * Creates a new Asm text tools collection and eagerly creates
* and initializes all members of this collection.
*/
public AsmTextTools() {
- this((IPreferenceStore)null);
+ this((IPreferenceStore) null);
}
+
/**
* Disposes all members of this tools collection.
*/
public void dispose() {
-
- fCodeScanner= null;
-
- fMultilineCommentScanner= null;
- fSinglelineCommentScanner= null;
- fStringScanner= null;
-
+
+ fCodeScanner = null;
+
+ fMultilineCommentScanner = null;
+ fSinglelineCommentScanner = null;
+ fStringScanner = null;
+
if (fColorManager != null) {
fColorManager.dispose();
- fColorManager= null;
+ fColorManager = null;
}
-
+
if (fPreferenceStore != null) {
fPreferenceStore.removePropertyChangeListener(fPreferenceListener);
- fPreferenceStore= null;
-
- fPreferenceListener= null;
+ fPreferenceStore = null;
+
+ fPreferenceListener = null;
}
}
-
+
/**
* Gets the color manager.
*/
public CColorManager getColorManager() {
return fColorManager;
}
-
+
/**
* Gets the code scanner used.
*/
public RuleBasedScanner getCodeScanner() {
return fCodeScanner;
}
-
+
/**
* Returns a scanner which is configured to scan multiline comments.
*
@@ -159,7 +158,7 @@ public class AsmTextTools {
public RuleBasedScanner getSinglelineCommentScanner() {
return fSinglelineCommentScanner;
}
-
+
/**
* Returns a scanner which is configured to scan strings.
*
@@ -181,22 +180,20 @@ public class AsmTextTools {
/**
* Determines whether the preference change encoded by the given event
* changes the behavior of one its contained components.
- *
+ *
* @param event the event to be investigated
* @return <code>true</code> if event causes a behavioral change
*/
public boolean affectsBehavior(PropertyChangeEvent event) {
- return fCodeScanner.affectsBehavior(event) ||
- fMultilineCommentScanner.affectsBehavior(event) ||
- fSinglelineCommentScanner.affectsBehavior(event) ||
- fStringScanner.affectsBehavior(event) ||
- fPreprocessorScanner.affectsBehavior(event);
+ return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event)
+ || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event)
+ || fPreprocessorScanner.affectsBehavior(event);
}
-
+
/**
* Adapts the behavior of the contained components to the change
* encoded in the given event.
- *
+ *
* @param event the event to whch to adapt
*/
protected void adaptToPreferenceChange(PropertyChangeEvent event) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java
index b01ad78d5ee..6800fb1569e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java
@@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.ui.editor.asm;
import org.eclipse.jface.text.rules.IWordDetector;
-
/**
* A C aware word detector.
*/
@@ -27,32 +26,34 @@ public class AsmWordDetector implements IWordDetector {
public AsmWordDetector() {
}
-
+
public AsmWordDetector(boolean strict) {
fStrictStart = strict;
}
-
+
public AsmWordDetector(char extra) {
fExtra = extra;
}
-
+
public AsmWordDetector(char prefix, char extra) {
fPrefix = prefix;
fExtra = extra;
}
+
/*
* @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
*/
@Override
public boolean isWordStart(char c) {
- if(fPrefix != 0) {
+ if (fPrefix != 0) {
return (fPrefix == c);
}
- if(fStrictStart) {
+ if (fStrictStart) {
return (Character.isJavaIdentifierStart(c) || (c == fExtra));
}
return (Character.isJavaIdentifierPart(c) || (c == fExtra));
}
+
/*
* @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java
index 9b5b51dcc15..f77c1a4c209 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java
@@ -36,7 +36,7 @@ public class ResourcePropertyTester extends PropertyTester {
ICommand[] buildSpec = description.getBuildSpec();
for (ICommand builder : buildSpec) {
if (builder.getBuilderName().equals(expectedValue))
- return true;
+ return true;
}
} catch (CoreException e) {
// Ignore to return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/AnonymousStructFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/AnonymousStructFilter.java
index 8d76667b19a..0d779cc5e21 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/AnonymousStructFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/AnonymousStructFilter.java
@@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.model.Structure;
/**
* Filters out anonymous structs and enums.
*/
-public class AnonymousStructFilter extends ViewerFilter {
+public class AnonymousStructFilter extends ViewerFilter {
/**
* Returns the result of this filter, when applied to the
* given inputs.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ArchiveFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ArchiveFilter.java
index e1973e2d025..21a66450f72 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ArchiveFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ArchiveFilter.java
@@ -19,21 +19,19 @@ import org.eclipse.cdt.core.model.IArchiveContainer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
-
/**
* The ArchiveFilter is a filter used to determine whether
* a C Archive is shown
*/
public class ArchiveFilter extends ViewerFilter {
-
+
/* (non-Javadoc)
* Method declared on ViewerFilter.
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IArchive) {
- if (! (parentElement instanceof IArchiveContainer)) {
+ if (!(parentElement instanceof IArchiveContainer)) {
return false;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.java
index 92b265900d4..1a7f4c1a90f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.java
@@ -25,7 +25,7 @@ import org.eclipse.cdt.core.model.ICElement;
public class ClosedProjectFilter extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof ICElement)
+ if (element instanceof ICElement)
return ((ICElement) element).getCProject().getProject().isOpen();
if (element instanceof IResource)
return ((IResource) element).getProject().isOpen();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java
index 4dffbca4c1c..70a464ef5cf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java
@@ -57,7 +57,7 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
public class CustomFiltersDialog extends SelectionDialog {
- private static final String SEPARATOR= ","; //$NON-NLS-1$
+ private static final String SEPARATOR = ","; //$NON-NLS-1$
private String fViewId;
private boolean fEnablePatterns;
@@ -72,17 +72,12 @@ public class CustomFiltersDialog extends SelectionDialog {
Stack<FilterDescriptor> fFilterDescriptorChangeHistory;
-
/**
* Creates a dialog to customize Java element filters.
*
* @param shell the parent shell
*/
- public CustomFiltersDialog(
- Shell shell,
- String viewId,
- boolean enablePatterns,
- String[] patterns,
+ public CustomFiltersDialog(Shell shell, String viewId, boolean enablePatterns, String[] patterns,
String[] enabledFilterIds) {
super(shell);
@@ -90,59 +85,59 @@ public class CustomFiltersDialog extends SelectionDialog {
Assert.isNotNull(patterns);
Assert.isNotNull(enabledFilterIds);
- fViewId= viewId;
- fPatterns= patterns;
- fEnablePatterns= enablePatterns;
- fEnabledFilterIds= enabledFilterIds;
+ fViewId = viewId;
+ fPatterns = patterns;
+ fEnablePatterns = enablePatterns;
+ fEnabledFilterIds = enabledFilterIds;
- fBuiltInFilters= FilterDescriptor.getFilterDescriptors(fViewId);
- fFilterDescriptorChangeHistory= new Stack<FilterDescriptor>();
+ fBuiltInFilters = FilterDescriptor.getFilterDescriptors(fViewId);
+ fFilterDescriptorChangeHistory = new Stack<FilterDescriptor>();
setShellStyle(getShellStyle() | SWT.RESIZE);
}
@Override
protected void configureShell(Shell shell) {
- setTitle(FilterMessages.CustomFiltersDialog_title);
- setMessage(FilterMessages.CustomFiltersDialog_filterList_label);
+ setTitle(FilterMessages.CustomFiltersDialog_title);
+ setMessage(FilterMessages.CustomFiltersDialog_filterList_label);
super.configureShell(shell);
PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, ICHelpContextIds.CUSTOM_FILTERS_DIALOG);
}
/**
* Overrides method in Dialog
- *
+ *
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
- */
+ */
@Override
protected Control createDialogArea(Composite parent) {
initializeDialogUnits(parent);
// create a composite with standard margins and spacing
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setFont(parent.getFont());
- Composite group= composite;
-
+ Composite group = composite;
+
// Checkbox
- fEnableUserDefinedPatterns= new Button(group, SWT.CHECK);
- fEnableUserDefinedPatterns.setText(FilterMessages.CustomFiltersDialog_enableUserDefinedPattern);
-
+ fEnableUserDefinedPatterns = new Button(group, SWT.CHECK);
+ fEnableUserDefinedPatterns.setText(FilterMessages.CustomFiltersDialog_enableUserDefinedPattern);
+
// Pattern field
- fUserDefinedPatterns= new Text(group, SWT.SINGLE | SWT.BORDER);
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- data.widthHint= convertWidthInCharsToPixels(59);
+ fUserDefinedPatterns = new Text(group, SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ data.widthHint = convertWidthInCharsToPixels(59);
fUserDefinedPatterns.setLayoutData(data);
- String patterns= convertToString(fPatterns, SEPARATOR);
+ String patterns = convertToString(fPatterns, SEPARATOR);
fUserDefinedPatterns.setText(patterns);
// Info text
- final Label info= new Label(group, SWT.LEFT);
- info.setText(FilterMessages.CustomFiltersDialog_patternInfo);
+ final Label info = new Label(group, SWT.LEFT);
+ info.setText(FilterMessages.CustomFiltersDialog_patternInfo);
// Enabling / disabling of pattern group
fEnableUserDefinedPatterns.setSelection(fEnablePatterns);
@@ -151,7 +146,7 @@ public class CustomFiltersDialog extends SelectionDialog {
fEnableUserDefinedPatterns.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- boolean state= fEnableUserDefinedPatterns.getSelection();
+ boolean state = fEnableUserDefinedPatterns.getSelection();
fUserDefinedPatterns.setEnabled(state);
info.setEnabled(fEnableUserDefinedPatterns.getSelection());
if (state)
@@ -162,21 +157,21 @@ public class CustomFiltersDialog extends SelectionDialog {
// Filters provided by extension point
if (fBuiltInFilters.length > 0)
createCheckBoxList(group);
-
- applyDialogFont(parent);
+
+ applyDialogFont(parent);
return parent;
}
private void createCheckBoxList(Composite parent) {
// Filler
new Label(parent, SWT.NONE);
-
- Label info= new Label(parent, SWT.LEFT);
- info.setText(FilterMessages.CustomFiltersDialog_filterList_label);
-
- fCheckBoxList= CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
- GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= fCheckBoxList.getTable().getItemHeight() * 10;
+
+ Label info = new Label(parent, SWT.LEFT);
+ info.setText(FilterMessages.CustomFiltersDialog_filterList_label);
+
+ fCheckBoxList = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = fCheckBoxList.getTable().getItemHeight() * 10;
fCheckBoxList.getTable().setLayoutData(data);
fCheckBoxList.setLabelProvider(createLabelPrivder());
@@ -184,11 +179,11 @@ public class CustomFiltersDialog extends SelectionDialog {
fCheckBoxList.setInput(fBuiltInFilters);
setInitialSelections(getEnabledFilterDescriptors());
-
- List<?> initialSelection= getInitialElementSelections();
+
+ List<?> initialSelection = getInitialElementSelections();
if (initialSelection != null && !initialSelection.isEmpty())
checkInitialSelections();
-
+
fCheckBoxList.getTable().getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
@@ -198,20 +193,21 @@ public class CustomFiltersDialog extends SelectionDialog {
fCheckBoxList.getTable().setToolTipText(FilterMessages.CustomFiltersDialog_filterList_label);
// Description
- info= new Label(parent, SWT.LEFT);
- info.setText(FilterMessages.CustomFiltersDialog_description_label);
- final Text description= new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.VERTICAL);
+ info = new Label(parent, SWT.LEFT);
+ info.setText(FilterMessages.CustomFiltersDialog_description_label);
+ final Text description = new Text(parent,
+ SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.VERTICAL);
data = new GridData(GridData.FILL_HORIZONTAL);
- data.heightHint= convertHeightInCharsToPixels(3);
+ data.heightHint = convertHeightInCharsToPixels(3);
description.setLayoutData(data);
fCheckBoxList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection= event.getSelection();
+ ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
- Object selectedElement= ((IStructuredSelection)selection).getFirstElement();
+ Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
if (selectedElement instanceof FilterDescriptor)
- description.setText(((FilterDescriptor)selectedElement).getDescription());
+ description.setText(((FilterDescriptor) selectedElement).getDescription());
}
}
});
@@ -221,33 +217,34 @@ public class CustomFiltersDialog extends SelectionDialog {
*/
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
- Object element= event.getElement();
+ Object element = event.getElement();
if (element instanceof FilterDescriptor) {
// renew if already touched
if (fFilterDescriptorChangeHistory.contains(element)) {
fFilterDescriptorChangeHistory.remove(element);
}
- fFilterDescriptorChangeHistory.push((FilterDescriptor)element);
+ fFilterDescriptorChangeHistory.push((FilterDescriptor) element);
}
- }});
+ }
+ });
addSelectionButtons(parent);
}
private void addSelectionButtons(Composite composite) {
- Composite buttonComposite= new Composite(composite, SWT.RIGHT);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
+ Composite buttonComposite = new Composite(composite, SWT.RIGHT);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
buttonComposite.setLayout(layout);
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
- data.grabExcessHorizontalSpace= true;
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
+ data.grabExcessHorizontalSpace = true;
composite.setData(data);
// Select All button
- String label= FilterMessages.CustomFiltersDialog_SelectAllButton_label;
- Button selectButton= createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, label, false);
+ String label = FilterMessages.CustomFiltersDialog_SelectAllButton_label;
+ Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, label, false);
SWTUtil.setButtonDimensionHint(selectButton);
- SelectionListener listener= new SelectionAdapter() {
+ SelectionListener listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fCheckBoxList.setAllChecked(true);
@@ -260,10 +257,10 @@ public class CustomFiltersDialog extends SelectionDialog {
selectButton.addSelectionListener(listener);
// Deselect All button
- label= FilterMessages.CustomFiltersDialog_DeselectAllButton_label;
- Button deselectButton= createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, label, false);
+ label = FilterMessages.CustomFiltersDialog_DeselectAllButton_label;
+ Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, label, false);
SWTUtil.setButtonDimensionHint(deselectButton);
- listener= new SelectionAdapter() {
+ listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fCheckBoxList.setAllChecked(false);
@@ -276,16 +273,16 @@ public class CustomFiltersDialog extends SelectionDialog {
}
private void checkInitialSelections() {
- Iterator<?> itemsToCheck= getInitialElementSelections().iterator();
+ Iterator<?> itemsToCheck = getInitialElementSelections().iterator();
while (itemsToCheck.hasNext())
- fCheckBoxList.setChecked(itemsToCheck.next(),true);
+ fCheckBoxList.setChecked(itemsToCheck.next(), true);
}
@Override
protected void okPressed() {
if (fBuiltInFilters != null) {
- ArrayList<FilterDescriptor> result= new ArrayList<FilterDescriptor>();
- for (int i= 0; i < fBuiltInFilters.length; ++i) {
+ ArrayList<FilterDescriptor> result = new ArrayList<FilterDescriptor>();
+ for (int i = 0; i < fBuiltInFilters.length; ++i) {
if (fCheckBoxList.getChecked(fBuiltInFilters[i]))
result.add(fBuiltInFilters[i]);
}
@@ -293,39 +290,38 @@ public class CustomFiltersDialog extends SelectionDialog {
}
super.okPressed();
}
-
+
private ILabelProvider createLabelPrivder() {
- return
- new LabelProvider() {
- @Override
- public Image getImage(Object element) {
- return null;
- }
- @Override
- public String getText(Object element) {
- if (element instanceof FilterDescriptor)
- return ((FilterDescriptor)element).getName();
- return null;
- }
- };
+ return new LabelProvider() {
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof FilterDescriptor)
+ return ((FilterDescriptor) element).getName();
+ return null;
+ }
+ };
}
// ---------- result handling ----------
-
+
@SuppressWarnings("rawtypes")
@Override
protected void setResult(List newResult) {
super.setResult(newResult);
if (fUserDefinedPatterns.getText().length() > 0) {
- fEnablePatterns= fEnableUserDefinedPatterns.getSelection();
- fPatterns= convertFromString(fUserDefinedPatterns.getText(), SEPARATOR);
+ fEnablePatterns = fEnableUserDefinedPatterns.getSelection();
+ fPatterns = convertFromString(fUserDefinedPatterns.getText(), SEPARATOR);
} else {
- fEnablePatterns= false;
- fPatterns= new String[0];
- }
+ fEnablePatterns = false;
+ fPatterns = new String[0];
+ }
}
-
/**
* @return the patterns which have been entered by the user
*/
@@ -337,10 +333,10 @@ public class CustomFiltersDialog extends SelectionDialog {
* @return the ids of the enabled built-in filters
*/
public String[] getEnabledFilterIds() {
- Object[] result= getResult();
- Set<String> enabledIds= new HashSet<String>(result.length);
+ Object[] result = getResult();
+ Set<String> enabledIds = new HashSet<String>(result.length);
for (Object element : result)
- enabledIds.add(((FilterDescriptor)element).getId());
+ enabledIds.add(((FilterDescriptor) element).getId());
return enabledIds.toArray(new String[enabledIds.size()]);
}
@@ -350,7 +346,7 @@ public class CustomFiltersDialog extends SelectionDialog {
public boolean areUserDefinedPatternsEnabled() {
return fEnablePatterns;
}
-
+
/**
* @return a stack with the filter descriptor check history
* @since 3.0
@@ -360,34 +356,33 @@ public class CustomFiltersDialog extends SelectionDialog {
}
private FilterDescriptor[] getEnabledFilterDescriptors() {
- FilterDescriptor[] filterDescs= fBuiltInFilters;
- List<FilterDescriptor> result= new ArrayList<FilterDescriptor>(filterDescs.length);
- List<String> enabledFilterIds= Arrays.asList(fEnabledFilterIds);
+ FilterDescriptor[] filterDescs = fBuiltInFilters;
+ List<FilterDescriptor> result = new ArrayList<FilterDescriptor>(filterDescs.length);
+ List<String> enabledFilterIds = Arrays.asList(fEnabledFilterIds);
for (FilterDescriptor filterDesc : filterDescs) {
- String id= filterDesc.getId();
+ String id = filterDesc.getId();
if (enabledFilterIds.contains(id))
result.add(filterDesc);
}
return result.toArray(new FilterDescriptor[result.size()]);
}
-
public static String[] convertFromString(String patterns, String separator) {
- StringTokenizer tokenizer= new StringTokenizer(patterns, separator);
- String[] result= new String[tokenizer.countTokens()];
- for (int i= 0; i < result.length; i++)
- result[i]= tokenizer.nextToken().trim();
+ StringTokenizer tokenizer = new StringTokenizer(patterns, separator);
+ String[] result = new String[tokenizer.countTokens()];
+ for (int i = 0; i < result.length; i++)
+ result[i] = tokenizer.nextToken().trim();
return result;
}
public static String convertToString(String[] patterns, String separator) {
- int length= patterns.length;
- StringBuilder strBuf= new StringBuilder();
+ int length = patterns.length;
+ StringBuilder strBuf = new StringBuilder();
if (length > 0)
strBuf.append(patterns[0]);
else
return ""; //$NON-NLS-1$
- int i= 1;
+ int i = 1;
while (i < length) {
strBuf.append(separator);
strBuf.append(" "); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ExecutableFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ExecutableFilter.java
index 8268989449f..e958fb7167a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ExecutableFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ExecutableFilter.java
@@ -19,22 +19,20 @@ import org.eclipse.cdt.core.model.IBinaryContainer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
-
/**
* The ExecutableFilter is a filter used to determine whether
* an executable is shown
*/
public class ExecutableFilter extends ViewerFilter {
-
+
/* (non-Javadoc)
* Method declared on ViewerFilter.
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IBinary) {
- IBinary bin = (IBinary)element;
- if (! (parentElement instanceof IBinaryContainer)) {
+ IBinary bin = (IBinary) element;
+ if (!(parentElement instanceof IBinaryContainer)) {
if (bin.isExecutable()) {
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterDescriptor.java
index df91524799f..e4e364383d9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterDescriptor.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -31,43 +31,40 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.ui.CUIPlugin;
-
/**
* Represents a custom filter which is provided by the
* "org.eclipse.jdt.ui.javaElementFilters" extension point.
- *
+ *
* since 2.0
*/
public class FilterDescriptor implements Comparable<FilterDescriptor> {
- private static String PATTERN_FILTER_ID_PREFIX= "_patternFilterId_"; //$NON-NLS-1$
+ private static String PATTERN_FILTER_ID_PREFIX = "_patternFilterId_"; //$NON-NLS-1$
+ private static final String EXTENSION_POINT_NAME = "CElementFilters"; //$NON-NLS-1$
- private static final String EXTENSION_POINT_NAME= "CElementFilters"; //$NON-NLS-1$
+ private static final String FILTER_TAG = "filter"; //$NON-NLS-1$
- private static final String FILTER_TAG= "filter"; //$NON-NLS-1$
-
- private static final String PATTERN_ATTRIBUTE= "pattern"; //$NON-NLS-1$
- private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
+ private static final String PATTERN_ATTRIBUTE = "pattern"; //$NON-NLS-1$
+ private static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
/**
* @deprecated as of 3.0 use {@link FilterDescriptor#TARGET_ID_ATTRIBUTE}
*/
@Deprecated
- private static final String VIEW_ID_ATTRIBUTE= "viewId"; //$NON-NLS-1$
- private static final String TARGET_ID_ATTRIBUTE= "targetId"; //$NON-NLS-1$
- private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
- private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
- private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$
- private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
+ private static final String VIEW_ID_ATTRIBUTE = "viewId"; //$NON-NLS-1$
+ private static final String TARGET_ID_ATTRIBUTE = "targetId"; //$NON-NLS-1$
+ private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+ private static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
+ private static final String ENABLED_ATTRIBUTE = "enabled"; //$NON-NLS-1$
+ private static final String DESCRIPTION_ATTRIBUTE = "description"; //$NON-NLS-1$
/**
* @deprecated use "enabled" instead
*/
@Deprecated
- private static final String SELECTED_ATTRIBUTE= "selected"; //$NON-NLS-1$
+ private static final String SELECTED_ATTRIBUTE = "selected"; //$NON-NLS-1$
private static FilterDescriptor[] fgFilterDescriptors;
-
IConfigurationElement fElement;
/**
@@ -75,36 +72,41 @@ public class FilterDescriptor implements Comparable<FilterDescriptor> {
*/
public static FilterDescriptor[] getFilterDescriptors() {
if (fgFilterDescriptors == null) {
- IExtensionRegistry registory= Platform.getExtensionRegistry();
- IConfigurationElement[] elements= registory.getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, EXTENSION_POINT_NAME);
- fgFilterDescriptors= createFilterDescriptors(elements);
- }
+ IExtensionRegistry registory = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registory.getConfigurationElementsFor(CUIPlugin.PLUGIN_ID,
+ EXTENSION_POINT_NAME);
+ fgFilterDescriptors = createFilterDescriptors(elements);
+ }
return fgFilterDescriptors;
- }
+ }
+
/**
* Returns all Java element filters which
* are contributed to the given view.
*/
public static FilterDescriptor[] getFilterDescriptors(String targetId) {
- FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors();
- List<FilterDescriptor> result= new ArrayList<FilterDescriptor>(filterDescs.length);
- for (int i= 0; i < filterDescs.length; i++) {
- String tid= filterDescs[i].getTargetId();
+ FilterDescriptor[] filterDescs = FilterDescriptor.getFilterDescriptors();
+ List<FilterDescriptor> result = new ArrayList<FilterDescriptor>(filterDescs.length);
+ for (int i = 0; i < filterDescs.length; i++) {
+ String tid = filterDescs[i].getTargetId();
if (tid == null || tid.equals(targetId))
result.add(filterDescs[i]);
}
return result.toArray(new FilterDescriptor[result.size()]);
}
-
+
/**
* Creates a new filter descriptor for the given configuration element.
*/
FilterDescriptor(IConfigurationElement element) {
- fElement= element;
+ fElement = element;
// it is either a pattern filter or a custom filter
- Assert.isTrue(isPatternFilter() ^ isCustomFilter(), "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not specify a correct filter"); //$NON-NLS-1$
- Assert.isNotNull(getId(), "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not provide a valid ID"); //$NON-NLS-1$
- Assert.isNotNull(getName(), "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not provide a valid name"); //$NON-NLS-1$
+ Assert.isTrue(isPatternFilter() ^ isCustomFilter(),
+ "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not specify a correct filter"); //$NON-NLS-1$
+ Assert.isNotNull(getId(),
+ "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not provide a valid ID"); //$NON-NLS-1$
+ Assert.isNotNull(getName(),
+ "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not provide a valid name"); //$NON-NLS-1$
}
/**
@@ -114,25 +116,25 @@ public class FilterDescriptor implements Comparable<FilterDescriptor> {
public ViewerFilter createViewerFilter() {
if (!isCustomFilter())
return null;
-
- final ViewerFilter[] result= new ViewerFilter[1];
- String message= NLS.bind(FilterMessages.FilterDescriptor_filterCreationError_message, getId());
- ISafeRunnable code= new SafeRunnable(message) {
+
+ final ViewerFilter[] result = new ViewerFilter[1];
+ String message = NLS.bind(FilterMessages.FilterDescriptor_filterCreationError_message, getId());
+ ISafeRunnable code = new SafeRunnable(message) {
/*
* @see org.eclipse.core.runtime.ISafeRunnable#run()
*/
@Override
public void run() throws Exception {
- result[0]= (ViewerFilter)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ result[0] = (ViewerFilter) fElement.createExecutableExtension(CLASS_ATTRIBUTE);
}
-
+
};
SafeRunnable.run(code);
return result[0];
}
-
+
//---- XML Attribute accessors ---------------------------------------------
-
+
/**
* Returns the filter's id.
* <p>
@@ -143,14 +145,14 @@ public class FilterDescriptor implements Comparable<FilterDescriptor> {
*/
public String getId() {
if (isPatternFilter()) {
- String targetId= getTargetId();
+ String targetId = getTargetId();
if (targetId == null)
return PATTERN_FILTER_ID_PREFIX + getPattern();
return targetId + PATTERN_FILTER_ID_PREFIX + getPattern();
}
return fElement.getAttribute(ID_ATTRIBUTE);
}
-
+
/**
* Returns the filter's name.
* <p>
@@ -159,15 +161,15 @@ public class FilterDescriptor implements Comparable<FilterDescriptor> {
* </p>
*/
public String getName() {
- String name= fElement.getAttribute(NAME_ATTRIBUTE);
+ String name = fElement.getAttribute(NAME_ATTRIBUTE);
if (name == null && isPatternFilter())
- name= getPattern();
+ name = getPattern();
return name;
}
/**
* Returns the filter's pattern.
- *
+ *
* @return the pattern string or <code>null</code> if it's not a pattern filter
*/
public String getPattern() {
@@ -176,30 +178,30 @@ public class FilterDescriptor implements Comparable<FilterDescriptor> {
/**
* Returns the filter's viewId.
- *
+ *
* @return the view ID or <code>null</code> if the filter is for all views
* @since 3.0
*/
public String getTargetId() {
- String tid= fElement.getAttribute(TARGET_ID_ATTRIBUTE);
-
+ String tid = fElement.getAttribute(TARGET_ID_ATTRIBUTE);
+
if (tid != null)
return tid;
-
+
// Backwards compatibility code
return fElement.getAttribute(VIEW_ID_ATTRIBUTE);
-
+
}
/**
* Returns the filter's description.
- *
+ *
* @return the description or <code>null</code> if no description is provided
*/
public String getDescription() {
- String description= fElement.getAttribute(DESCRIPTION_ATTRIBUTE);
+ String description = fElement.getAttribute(DESCRIPTION_ATTRIBUTE);
if (description == null)
- description= ""; //$NON-NLS-1$
+ description = ""; //$NON-NLS-1$
return description;
}
@@ -220,44 +222,45 @@ public class FilterDescriptor implements Comparable<FilterDescriptor> {
/**
* Returns <code>true</code> if the filter
* is initially enabled.
- *
+ *
* This attribute is optional and defaults to <code>true</code>.
*/
public boolean isEnabled() {
- String strVal= fElement.getAttribute(ENABLED_ATTRIBUTE);
+ String strVal = fElement.getAttribute(ENABLED_ATTRIBUTE);
if (strVal == null)
// backward compatibility
- strVal= fElement.getAttribute(SELECTED_ATTRIBUTE);
+ strVal = fElement.getAttribute(SELECTED_ATTRIBUTE);
return strVal == null || Boolean.valueOf(strVal).booleanValue();
}
- /*
- * Implements a method from IComparable
- */
+ /*
+ * Implements a method from IComparable
+ */
@Override
public int compareTo(FilterDescriptor o) {
return Collator.getInstance().compare(getName(), (o).getName());
}
//---- initialization ---------------------------------------------------
-
+
/**
* Creates the filter descriptors.
*/
private static FilterDescriptor[] createFilterDescriptors(IConfigurationElement[] elements) {
- List<FilterDescriptor> result= new ArrayList<FilterDescriptor>(5);
- Set<String> descIds= new HashSet<String>(5);
- for (int i= 0; i < elements.length; i++) {
- final IConfigurationElement element= elements[i];
+ List<FilterDescriptor> result = new ArrayList<FilterDescriptor>(5);
+ Set<String> descIds = new HashSet<String>(5);
+ for (int i = 0; i < elements.length; i++) {
+ final IConfigurationElement element = elements[i];
if (FILTER_TAG.equals(element.getName())) {
- final FilterDescriptor[] desc= new FilterDescriptor[1];
- SafeRunnable.run(new SafeRunnable(FilterMessages.FilterDescriptor_filterDescriptionCreationError_message) {
- @Override
- public void run() throws Exception {
- desc[0]= new FilterDescriptor(element);
- }
- });
+ final FilterDescriptor[] desc = new FilterDescriptor[1];
+ SafeRunnable
+ .run(new SafeRunnable(FilterMessages.FilterDescriptor_filterDescriptionCreationError_message) {
+ @Override
+ public void run() throws Exception {
+ desc[0] = new FilterDescriptor(element);
+ }
+ });
if (desc[0] != null && !descIds.contains(desc[0].getId())) {
result.add(desc[0]);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.java
index 636f6ae465f..61e9f431889 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Eclipse CDT Project and others
+ * Copyright (c) 2010 Eclipse CDT Project and others
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -29,15 +29,15 @@ public class ForwardDeclarationFilter extends ViewerFilter {
*/
@Override
public boolean select(Viewer viewer, Object parent, Object element) {
- if (!(element instanceof ICElement))
+ if (!(element instanceof ICElement))
return true;
-
- final ICElement celem= (ICElement) element;
- ICElement tu= celem;
+
+ final ICElement celem = (ICElement) element;
+ ICElement tu = celem;
while (tu != null && !(tu instanceof ITranslationUnit)) {
- tu= tu.getParent();
+ tu = tu.getParent();
}
-
+
// Don't filter forward declarations in header file
if (tu instanceof ITranslationUnit && ((ITranslationUnit) tu).isHeaderUnit())
return true;
@@ -45,18 +45,18 @@ public class ForwardDeclarationFilter extends ViewerFilter {
switch (celem.getElementType()) {
case ICElement.C_FUNCTION_DECLARATION:
case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
-
+
case ICElement.C_STRUCT_DECLARATION:
case ICElement.C_UNION_DECLARATION:
case ICElement.C_CLASS_DECLARATION:
case ICElement.C_TEMPLATE_CLASS_DECLARATION:
case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
case ICElement.C_TEMPLATE_UNION_DECLARATION:
-
+
case ICElement.C_VARIABLE_DECLARATION:
return false;
}
-
+
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NamePatternFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NamePatternFilter.java
index d884b30a9e7..7b335835475 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NamePatternFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NamePatternFilter.java
@@ -29,49 +29,48 @@ import org.eclipse.jface.viewers.ViewerFilter;
* ? => any character
* * => any string
* </p>
- *
+ *
* @since 2.0
*/
public class NamePatternFilter extends ViewerFilter {
private String[] fPatterns;
private StringMatcher[] fMatchers;
-
+
/**
* Return the currently configured StringMatchers.
*/
private StringMatcher[] getMatchers() {
return fMatchers;
}
-
+
/**
* Gets the patterns for the receiver.
*/
public String[] getPatterns() {
return fPatterns;
}
-
-
+
/* (non-Javadoc)
* Method declared on ViewerFilter.
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- String matchName= null;
+ String matchName = null;
if (element instanceof ICElement) {
- matchName= ((ICElement) element).getElementName();
+ matchName = ((ICElement) element).getElementName();
} else if (element instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) element;
- ICElement javaElement= adaptable.getAdapter(ICElement.class);
+ IAdaptable adaptable = (IAdaptable) element;
+ ICElement javaElement = adaptable.getAdapter(ICElement.class);
if (javaElement != null)
- matchName= javaElement.getElementName();
+ matchName = javaElement.getElementName();
else {
- IResource resource= adaptable.getAdapter(IResource.class);
+ IResource resource = adaptable.getAdapter(IResource.class);
if (resource != null)
- matchName= resource.getName();
+ matchName = resource.getName();
}
}
if (matchName != null) {
- StringMatcher[] testMatchers= getMatchers();
+ StringMatcher[] testMatchers = getMatchers();
for (int i = 0; i < testMatchers.length; i++) {
if (testMatchers[i].match(matchName))
return false;
@@ -80,7 +79,7 @@ public class NamePatternFilter extends ViewerFilter {
}
return true;
}
-
+
/**
* Sets the patterns to filter out for the receiver.
* <p>
@@ -94,7 +93,7 @@ public class NamePatternFilter extends ViewerFilter {
fMatchers = new StringMatcher[newPatterns.length];
for (int i = 0; i < newPatterns.length; i++) {
//Reset the matchers to prevent constructor overhead
- fMatchers[i]= new StringMatcher(newPatterns[i], true, false);
+ fMatchers[i] = new StringMatcher(newPatterns[i], true, false);
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCElementFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCElementFilter.java
index f84ebc7393c..211c82a7b15 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCElementFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCElementFilter.java
@@ -23,13 +23,11 @@ import org.eclipse.core.resources.IStorage;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
-
/**
* Filters out all non-C elements.
*/
-public class NonCElementFilter extends ViewerFilter {
-
+public class NonCElementFilter extends ViewerFilter {
+
/**
* Returns the result of this filter, when applied to the
* given inputs.
@@ -42,20 +40,20 @@ public class NonCElementFilter extends ViewerFilter {
return true;
if (element instanceof IProject) {
- IProject project = (IProject)element;
+ IProject project = (IProject) element;
if (!project.isOpen() || CoreModel.hasCNature(project)) {
return true;
}
return false;
} else if (element instanceof IResource) {
- IProject project= ((IResource)element).getProject();
+ IProject project = ((IResource) element).getProject();
return project == null || !project.isOpen();
}
// Exclude all IStorage elements which are neither C elements nor resources
if (element instanceof IStorage)
return false;
-
+
return true;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.java
index 1fd33ebc9e3..096d47d8c02 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.filters;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
@@ -22,7 +21,6 @@ import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
-
/**
* Filters (open) non-C projects.
*/
@@ -36,7 +34,7 @@ public class NonCProjectsFilter extends ViewerFilter {
if (element instanceof ICProject) {
return true;
} else if (element instanceof IProject) {
- IProject project = (IProject)element;
+ IProject project = (IProject) element;
if (!project.isOpen()) {
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ObjectFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ObjectFilter.java
index e6983bfee07..f6c9df70995 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ObjectFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ObjectFilter.java
@@ -19,22 +19,20 @@ import org.eclipse.cdt.core.model.IBinaryContainer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
-
/**
* The ObjectFilter is a filter used to determine whether
* a Object is shown
*/
public class ObjectFilter extends ViewerFilter {
-
+
/* (non-Javadoc)
* Method declared on ViewerFilter.
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IBinary) {
- IBinary bin = (IBinary)element;
- if (! (parentElement instanceof IBinaryContainer)) {
+ IBinary bin = (IBinary) element;
+ if (!(parentElement instanceof IBinaryContainer)) {
if (bin.isObject()) {
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/SharedFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/SharedFilter.java
index 62619b13909..2d688b4d278 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/SharedFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/SharedFilter.java
@@ -19,22 +19,20 @@ import org.eclipse.cdt.core.model.IBinaryContainer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
-
/**
* The SharedFilter is a filter used to determine whether
* a Shared object is shown
*/
public class SharedFilter extends ViewerFilter {
-
+
/* (non-Javadoc)
* Method declared on ViewerFilter.
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IBinary) {
- IBinary bin = (IBinary)element;
- if (! (parentElement instanceof IBinaryContainer)) {
+ IBinary bin = (IBinary) element;
+ if (!(parentElement instanceof IBinaryContainer)) {
if (bin.isSharedLib()) {
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CFunctionSummary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CFunctionSummary.java
index 9eb9d6d14f4..a01606fbee8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CFunctionSummary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CFunctionSummary.java
@@ -34,94 +34,102 @@ public class CFunctionSummary implements IFunctionSummary {
private static final String SP = " "; //$NON-NLS-1$
private static final String LB = "("; //$NON-NLS-1$
private static final String RB = ")"; //$NON-NLS-1$
-
+
private String name = null;
private String desc = null;
private IRequiredInclude[] incs = null;
IFunctionPrototypeSummary fps = null;
-
+
public CFunctionSummary(Element e, String defName) {
name = defName; // if there's no "name" tag, keyword used instead
String args = null;
String type = null;
NodeList list = e.getChildNodes();
ArrayList<IRequiredInclude> incList = new ArrayList<IRequiredInclude>();
- for(int j = 0; j < list.getLength(); j++){
+ for (int j = 0; j < list.getLength(); j++) {
Node node = list.item(j);
- if(node.getNodeType() != Node.ELEMENT_NODE)
+ if (node.getNodeType() != Node.ELEMENT_NODE)
continue;
String s = node.getNodeName().trim();
String t = node.getFirstChild().getNodeValue().trim();
- if(NODE_NAME.equals(s)){
+ if (NODE_NAME.equals(s)) {
name = t;
- } else if(NODE_DESC.equals(s)){
+ } else if (NODE_DESC.equals(s)) {
desc = t;
- } else if(NODE_ARGS.equals(s)){
+ } else if (NODE_ARGS.equals(s)) {
args = t;
- } else if(NODE_TYPE.equals(s)){
+ } else if (NODE_TYPE.equals(s)) {
type = t;
- } else if(NODE_INCL.equals(s)){
+ } else if (NODE_INCL.equals(s)) {
boolean std = true;
- if (((Element)node).hasAttribute(ATTR_STD)) {
- String st = ((Element)node).getAttribute(ATTR_STD);
- std = (st == null || st.equalsIgnoreCase("true") //$NON-NLS-1$
- || st.equalsIgnoreCase("yes")); //$NON-NLS-1$
+ if (((Element) node).hasAttribute(ATTR_STD)) {
+ String st = ((Element) node).getAttribute(ATTR_STD);
+ std = (st == null || st.equalsIgnoreCase("true") //$NON-NLS-1$
+ || st.equalsIgnoreCase("yes")); //$NON-NLS-1$
}
incList.add(new RequiredInclude(t, std));
}
}
- if (incList.size() > 0)
+ if (incList.size() > 0)
incs = incList.toArray(new IRequiredInclude[incList.size()]);
- fps = new FunctionPrototypeSummary(type + SP + name + LB + args + RB);
+ fps = new FunctionPrototypeSummary(type + SP + name + LB + args + RB);
}
-
+
@Override
public String getDescription() {
return desc;
}
+
@Override
- public IRequiredInclude[] getIncludes() {
- return incs;
+ public IRequiredInclude[] getIncludes() {
+ return incs;
}
+
@Override
public String getName() {
return name;
}
+
@Override
public String getNamespace() {
return null;
}
+
@Override
public IFunctionPrototypeSummary getPrototype() {
return fps;
}
-
+
/**
- * This class implements IRequiredInclude interface
+ * This class implements IRequiredInclude interface
*/
private class RequiredInclude implements IRequiredInclude {
private String iname;
private boolean std;
-
+
private RequiredInclude(String s, boolean b) {
iname = s;
std = b;
}
+
@Override
public String getIncludeName() {
return iname;
}
+
@Override
public boolean isStandard() {
return std;
}
+
@Override
public String toString() {
- if (std)
- return "#include <" + iname + ">"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (std)
+ return "#include <" + iname + ">"; //$NON-NLS-1$ //$NON-NLS-2$
return "#include \"" + iname + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
}
+
@Override
public String toString() {
return "<functionSummary> : " + getPrototype().getPrototypeString(false); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpBook.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpBook.java
index ce612fa6b3a..31a2276a7bf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpBook.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpBook.java
@@ -31,17 +31,17 @@ import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
public class CHelpBook implements ICHelpBook {
private static final String ATTR_TITLE = "title"; //$NON-NLS-1$
- private static final String ATTR_BTYPE = "type"; //$NON-NLS-1$
+ private static final String ATTR_BTYPE = "type"; //$NON-NLS-1$
private static final String NODE_ENTRY = "entry"; //$NON-NLS-1$
- private static final String TYPE_C = "HELP_TYPE_C"; //$NON-NLS-1$
+ private static final String TYPE_C = "HELP_TYPE_C"; //$NON-NLS-1$
private static final String TYPE_CPP = "HELP_TYPE_CPP"; //$NON-NLS-1$
private static final String TYPE_ASM = "HELP_TYPE_ASM"; //$NON-NLS-1$
- private static final int DEFAULT_VAL = ICHelpBook.HELP_TYPE_C;
+ private static final int DEFAULT_VAL = ICHelpBook.HELP_TYPE_C;
private int type;
private String title;
- private TreeMap<String, CHelpEntry> entries;
-
+ private TreeMap<String, CHelpEntry> entries;
+
public CHelpBook(Element e) {
entries = new TreeMap<String, CHelpEntry>();
@@ -51,8 +51,7 @@ public class CHelpBook implements ICHelpBook {
String s = e.getAttribute(ATTR_BTYPE);
try {
type = Integer.parseInt(s);
- if (type < DEFAULT_VAL ||
- type > ICHelpBook.HELP_TYPE_ASM)
+ if (type < DEFAULT_VAL || type > ICHelpBook.HELP_TYPE_ASM)
type = DEFAULT_VAL;
} catch (NumberFormatException ee) {
if (TYPE_C.equalsIgnoreCase(s))
@@ -66,50 +65,47 @@ public class CHelpBook implements ICHelpBook {
}
}
NodeList list = e.getChildNodes();
- for(int i = 0; i < list.getLength(); i++){
+ for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
- if(node.getNodeType() != Node.ELEMENT_NODE) continue;
- if(NODE_ENTRY.equals(node.getNodeName())) {
- CHelpEntry he = new CHelpEntry((Element)node);
- if (he.isValid())
+ if (node.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+ if (NODE_ENTRY.equals(node.getNodeName())) {
+ CHelpEntry he = new CHelpEntry((Element) node);
+ if (he.isValid())
entries.put(he.getKeyword(), he);
}
}
}
-
+
@Override
public int getCHelpType() {
return type;
}
-
+
@Override
public String getTitle() {
return title;
}
-
- public IFunctionSummary getFunctionInfo(
- ICHelpInvocationContext context,
- String name) {
-
+
+ public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, String name) {
+
if (entries.containsKey(name)) {
CHelpEntry he = entries.get(name);
IFunctionSummary[] fs = he.getFunctionSummary();
if (fs != null && fs.length > 0)
- return fs[0];
+ return fs[0];
}
return null;
}
-
+
/**
* Temporary implementation with slow search
* @param context
* @param prefix
* @return matching functions
*/
- public List<IFunctionSummary> getMatchingFunctions(
- ICHelpInvocationContext context,
- String prefix) {
-
+ public List<IFunctionSummary> getMatchingFunctions(ICHelpInvocationContext context, String prefix) {
+
Collection<CHelpEntry> col = null;
if (prefix == null || prefix.trim().length() == 0) {
// return whole data
@@ -119,22 +115,20 @@ public class CHelpBook implements ICHelpBook {
byte[] bs = pr1.getBytes();
int i = bs.length - 1;
while (i >= 0) {
- byte b = bs[i];
- if (++b > bs[i]) { // no overflow
- bs[i] = b;
- break;
- }
- i--;
+ byte b = bs[i];
+ if (++b > bs[i]) { // no overflow
+ bs[i] = b;
+ break;
+ }
+ i--;
}
- SortedMap<String, CHelpEntry> sm = (i>-1) ?
- entries.subMap(pr1, new String(bs)) :
- entries.tailMap(pr1);
- col = sm.values();
+ SortedMap<String, CHelpEntry> sm = (i > -1) ? entries.subMap(pr1, new String(bs)) : entries.tailMap(pr1);
+ col = sm.values();
}
-
+
if (col.size() > 0) {
ArrayList<IFunctionSummary> out = new ArrayList<IFunctionSummary>(col.size());
- for (CHelpEntry he: col)
+ for (CHelpEntry he : col)
for (IFunctionSummary fs : he.getFunctionSummary())
out.add(fs);
return out;
@@ -142,28 +136,30 @@ public class CHelpBook implements ICHelpBook {
return null;
}
- public ICHelpResourceDescriptor getHelpResources(
- ICHelpInvocationContext context, String name) {
+ public ICHelpResourceDescriptor getHelpResources(ICHelpInvocationContext context, String name) {
if (entries.containsKey(name)) {
CHelpEntry he = entries.get(name);
IHelpResource[] hr = he.getHelpResource();
if (hr != null && hr.length > 0)
- return new HRDescriptor(this, hr);
+ return new HRDescriptor(this, hr);
}
return null;
}
-
+
private class HRDescriptor implements ICHelpResourceDescriptor {
private ICHelpBook book;
private IHelpResource[] res;
+
HRDescriptor(ICHelpBook _book, IHelpResource[] _res) {
book = _book;
- res = _res;
+ res = _res;
}
+
@Override
public ICHelpBook getCHelpBook() {
return book;
}
+
@Override
public IHelpResource[] getHelpResources() {
return res;
@@ -172,7 +168,7 @@ public class CHelpBook implements ICHelpBook {
@Override
public String toString() {
- return "<helpBook title=\"" +title +"\" type=\"" + type + "\">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return "<helpBook title=\"" + title + "\" type=\"" + type + "\">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpEntry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpEntry.java
index 49a82123282..4484e828a39 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpEntry.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpEntry.java
@@ -31,47 +31,51 @@ public class CHelpEntry {
private boolean isValid = true;
private CHelpTopic[] hts = null;
private CFunctionSummary[] fss = null;
-
+
public CHelpEntry(Element e) {
keyword = e.getAttribute(ATTR_KEYWD).trim();
ArrayList<CFunctionSummary> obs1 = new ArrayList<CFunctionSummary>();
ArrayList<CHelpTopic> obs2 = new ArrayList<CHelpTopic>();
NodeList list = e.getChildNodes();
- for(int i = 0; i < list.getLength(); i++){
+ for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
if (node.getNodeType() != Node.ELEMENT_NODE)
continue;
- if (NODE_FSUMM.equals(node.getNodeName())){
- obs1.add(new CFunctionSummary((Element)node, keyword));
+ if (NODE_FSUMM.equals(node.getNodeName())) {
+ obs1.add(new CFunctionSummary((Element) node, keyword));
} else if (NODE_TOPIC.equals(node.getNodeName())) {
- obs2.add(new CHelpTopic((Element)node, keyword));
+ obs2.add(new CHelpTopic((Element) node, keyword));
}
}
fss = obs1.toArray(new CFunctionSummary[obs1.size()]);
hts = obs2.toArray(new CHelpTopic[obs2.size()]);
-
+
if (fss.length == 0 && hts.length == 0)
isValid = false; // nothing to display
}
/**
* Returns true if help entry is correct
- * Returns false if entry is empty or when
- * subsequent processing failed somehow.
+ * Returns false if entry is empty or when
+ * subsequent processing failed somehow.
* @return entry state
*/
public boolean isValid() {
return isValid;
}
+
public String getKeyword() {
return keyword;
}
+
public IFunctionSummary[] getFunctionSummary() {
return fss;
}
+
public IHelpResource[] getHelpResource() {
return hts;
}
+
@Override
public String toString() {
return "<entry keyword=\"" + keyword + "\">"; //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java
index 7835337640a..22f0c25db92 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java
@@ -48,15 +48,15 @@ import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
public class CHelpProvider implements ICHelpProvider {
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.HelpInfo"; //$NON-NLS-1$
- private static final String ELEMENT_NAME = "helpInfo"; //$NON-NLS-1$
- private static final String ATTRIB_FILE = "file"; //$NON-NLS-1$
+ private static final String ELEMENT_NAME = "helpInfo"; //$NON-NLS-1$
+ private static final String ATTRIB_FILE = "file"; //$NON-NLS-1$
private static final String NODE_HEAD = "documentation"; //$NON-NLS-1$
private static final String NODE_BOOK = "helpBook"; //$NON-NLS-1$
private boolean Done = false;
-
+
ICHelpBook[] hbs = null;
-
+
@Override
public ICHelpBook[] getCHelpBooks() {
waitForDone();
@@ -64,13 +64,10 @@ public class CHelpProvider implements ICHelpProvider {
}
@Override
- public IFunctionSummary getFunctionInfo(
- ICHelpInvocationContext context,
- ICHelpBook[] helpBooks,
- String name) {
- for (int i=0; i<helpBooks.length; i++) {
+ public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
+ for (int i = 0; i < helpBooks.length; i++) {
if (helpBooks[i] instanceof CHelpBook) {
- IFunctionSummary fs = ((CHelpBook)helpBooks[i]).getFunctionInfo(context, name);
+ IFunctionSummary fs = ((CHelpBook) helpBooks[i]).getFunctionInfo(context, name);
if (fs != null) // if null, try with another book
return fs;
}
@@ -79,14 +76,13 @@ public class CHelpProvider implements ICHelpProvider {
}
@Override
- public ICHelpResourceDescriptor[] getHelpResources(
- ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
+ public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, ICHelpBook[] helpBooks,
+ String name) {
ArrayList<ICHelpResourceDescriptor> lst = new ArrayList<ICHelpResourceDescriptor>();
for (ICHelpBook h : helpBooks) {
if (h instanceof CHelpBook) {
- ICHelpResourceDescriptor hrd =
- ((CHelpBook)h).getHelpResources(context, name);
+ ICHelpResourceDescriptor hrd = ((CHelpBook) h).getHelpResources(context, name);
if (hrd != null)
lst.add(hrd);
}
@@ -97,13 +93,12 @@ public class CHelpProvider implements ICHelpProvider {
}
@Override
- public IFunctionSummary[] getMatchingFunctions(
- ICHelpInvocationContext context, ICHelpBook[] helpBooks,
+ public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, ICHelpBook[] helpBooks,
String prefix) {
ArrayList<IFunctionSummary> lst = new ArrayList<IFunctionSummary>();
- for (int i=0; i<helpBooks.length; i++) {
+ for (int i = 0; i < helpBooks.length; i++) {
if (helpBooks[i] instanceof CHelpBook) {
- List<IFunctionSummary> fs = ((CHelpBook)helpBooks[i]).getMatchingFunctions(context, prefix);
+ List<IFunctionSummary> fs = ((CHelpBook) helpBooks[i]).getMatchingFunctions(context, prefix);
if (fs != null) // if null, try with another book
lst.addAll(fs);
}
@@ -115,32 +110,32 @@ public class CHelpProvider implements ICHelpProvider {
@Override
public void initialize() {
-// (new Thread() {
-// public void run() {
- loadExtensions();
-// }
-// }).run();
+ // (new Thread() {
+ // public void run() {
+ loadExtensions();
+ // }
+ // }).run();
}
private void waitForDone() {
if (hbs != null)
return;
try {
- while (! Done ) Thread.sleep(10);
- } catch (InterruptedException e) {}
+ while (!Done)
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ }
}
-
- private void loadExtensions()
- {
+
+ private void loadExtensions() {
try {
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
- .getExtensionPoint(EXTENSION_POINT_ID);
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
if (extensionPoint != null) {
IExtension[] extensions = extensionPoint.getExtensions();
if (extensions != null) {
ArrayList<ICHelpBook> chbl = new ArrayList<ICHelpBook>();
- for (IExtension ex: extensions) {
- String pluginId = ex.getNamespaceIdentifier();
+ for (IExtension ex : extensions) {
+ String pluginId = ex.getNamespaceIdentifier();
for (IConfigurationElement el : ex.getConfigurationElements()) {
if (el.getName().equals(ELEMENT_NAME)) {
loadFile(el, chbl, pluginId);
@@ -156,20 +151,26 @@ public class CHelpProvider implements ICHelpProvider {
Done = true;
}
}
-
+
private void loadFile(IConfigurationElement el, ArrayList<ICHelpBook> chbl, String pluginId) {
String fname = el.getAttribute(ATTRIB_FILE);
- if (fname == null || fname.trim().length() == 0) return;
+ if (fname == null || fname.trim().length() == 0)
+ return;
URL x = FileLocator.find(Platform.getBundle(pluginId), new Path(fname), null);
- if (x == null) return;
- try { x = FileLocator.toFileURL(x);
- } catch (IOException e) { return; }
+ if (x == null)
+ return;
+ try {
+ x = FileLocator.toFileURL(x);
+ } catch (IOException e) {
+ return;
+ }
fname = x.getPath();
- if (fname == null || fname.trim().length() == 0) return;
+ if (fname == null || fname.trim().length() == 0)
+ return;
- // format is not supported for now
+ // format is not supported for now
// String format = el.getAttribute(ATTRIB_FORMAT);
-
+
Document doc = null;
try {
InputStream stream = new FileInputStream(fname);
@@ -178,13 +179,14 @@ public class CHelpProvider implements ICHelpProvider {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = builder.parse(src);
Element e = doc.getDocumentElement();
- if(NODE_HEAD.equals(e.getNodeName())){
+ if (NODE_HEAD.equals(e.getNodeName())) {
NodeList list = e.getChildNodes();
- for(int j = 0; j < list.getLength(); j++){
+ for (int j = 0; j < list.getLength(); j++) {
Node node = list.item(j);
- if(node.getNodeType() != Node.ELEMENT_NODE) continue;
- if(NODE_BOOK.equals(node.getNodeName())){
- chbl.add(new CHelpBook((Element)node));
+ if (node.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+ if (NODE_BOOK.equals(node.getNodeName())) {
+ chbl.add(new CHelpBook((Element) node));
}
}
}
@@ -192,5 +194,5 @@ public class CHelpProvider implements ICHelpProvider {
} catch (SAXException e) {
} catch (IOException e) {
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpTopic.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpTopic.java
index 0935bc98c0e..642dc62beb4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpTopic.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpTopic.java
@@ -18,25 +18,28 @@ import org.w3c.dom.Element;
public class CHelpTopic implements IHelpResource {
private static final String ATTR_TITLE = "title"; //$NON-NLS-1$
- private static final String ATTR_HREF = "href"; //$NON-NLS-1$
+ private static final String ATTR_HREF = "href"; //$NON-NLS-1$
private String href = null;
private String title = null;
-
+
public CHelpTopic(Element e, String defTitle) {
- href = e.getAttribute(ATTR_HREF).trim();
- title = e.getAttribute(ATTR_TITLE).trim();
+ href = e.getAttribute(ATTR_HREF).trim();
+ title = e.getAttribute(ATTR_TITLE).trim();
if (title == null || title.length() == 0)
title = defTitle;
}
+
@Override
public String getHref() {
return href;
}
+
@Override
public String getLabel() {
return title;
}
+
@Override
public String toString() {
return "<topic href=\"" + href + "\" title=\"" + title + "\">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java
index 15f2ce2857e..7599af9643f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import java.util.ArrayList;
@@ -36,7 +36,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
-/**
+/**
* This is the content provider for the include browser.
*/
public class IBContentProvider extends AsyncTreeContentProvider {
@@ -79,16 +79,17 @@ public class IBContentProvider extends AsyncTreeContentProvider {
protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
if (parentElement instanceof IBNode) {
IBNode node = (IBNode) parentElement;
- IIndexFileLocation ifl= node.getRepresentedIFL();
- ICProject project= node.getCProject();
+ IIndexFileLocation ifl = node.getRepresentedIFL();
+ ICProject project = node.getCProject();
if (ifl == null) {
return NO_CHILDREN;
}
-
+
IIndex index;
try {
- ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
+ ICProject[] scope = CoreModel.getDefault().getCModel().getCProjects();
+ index = CCorePlugin.getIndexManager().getIndex(scope,
+ IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
index.acquireReadLock();
} catch (CoreException e) {
CUIPlugin.log(e);
@@ -96,35 +97,33 @@ public class IBContentProvider extends AsyncTreeContentProvider {
} catch (InterruptedException e) {
return NO_CHILDREN;
}
-
+
try {
- IBFile directiveFile= null;
- IBFile targetFile= null;
+ IBFile directiveFile = null;
+ IBFile targetFile = null;
IIndexInclude[] includes;
if (fComputeIncludedBy) {
- includes= findIncludedBy(index, ifl, NPM);
+ includes = findIncludedBy(index, ifl, NPM);
} else {
- includes= findIncludesTo(index, ifl, NPM);
- directiveFile= node.getRepresentedFile();
+ includes = findIncludesTo(index, ifl, NPM);
+ directiveFile = node.getRepresentedFile();
}
if (includes.length > 0) {
- Set<IBNode> result= new LinkedHashSet<IBNode>(includes.length);
+ Set<IBNode> result = new LinkedHashSet<IBNode>(includes.length);
for (IIndexInclude include : includes) {
try {
if (fComputeIncludedBy) {
- directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation());
+ directiveFile = targetFile = new IBFile(project, include.getIncludedByLocation());
} else {
- IIndexFileLocation includesPath= include.getIncludesLocation();
+ IIndexFileLocation includesPath = include.getIncludesLocation();
if (includesPath == null) {
- targetFile= new IBFile(include.getFullName());
+ targetFile = new IBFile(include.getFullName());
} else {
- targetFile= new IBFile(project, includesPath);
+ targetFile = new IBFile(project, includesPath);
}
}
- IBNode newnode= new IBNode(node, targetFile, directiveFile,
- include.getNameOffset(),
- include.getNameLength(),
- include.getIncludedBy().getTimestamp());
+ IBNode newnode = new IBNode(node, targetFile, directiveFile, include.getNameOffset(),
+ include.getNameLength(), include.getIncludedBy().getTimestamp());
newnode.setIsActiveCode(include.isActive());
newnode.setIsSystemInclude(include.isSystemInclude());
if (!result.contains(newnode) || newnode.isActiveCode())
@@ -154,13 +153,13 @@ public class IBContentProvider extends AsyncTreeContentProvider {
private IIndexInclude[] findIncludedBy(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
try {
if (ifl != null) {
- IIndexFile[] files= index.getFiles(ifl);
+ IIndexFile[] files = index.getFiles(ifl);
if (files.length == 1) {
return index.findIncludedBy(files[0]);
}
if (files.length > 0) {
- ArrayList<IIndexInclude> list= new ArrayList<IIndexInclude>();
- HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
+ ArrayList<IIndexInclude> list = new ArrayList<IIndexInclude>();
+ HashSet<IIndexFileLocation> handled = new HashSet<IIndexFileLocation>();
for (IIndexFile file : files) {
final IIndexInclude[] includes = index.findIncludedBy(file);
for (IIndexInclude indexInclude : includes) {
@@ -174,20 +173,20 @@ public class IBContentProvider extends AsyncTreeContentProvider {
}
} catch (CoreException e) {
CUIPlugin.log(e);
- }
+ }
return IIndexInclude.EMPTY_INCLUDES_ARRAY;
}
public IIndexInclude[] findIncludesTo(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
try {
if (ifl != null) {
- IIndexFile[] files= index.getFiles(ifl);
+ IIndexFile[] files = index.getFiles(ifl);
if (files.length == 1) {
return index.findIncludes(files[0]);
}
if (files.length > 0) {
- ArrayList<IIndexInclude> list= new ArrayList<IIndexInclude>();
- HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
+ ArrayList<IIndexInclude> list = new ArrayList<IIndexInclude>();
+ HashSet<IIndexFileLocation> handled = new HashSet<IIndexFileLocation>();
for (IIndexFile file : files) {
final IIndexInclude[] includes = index.findIncludes(file);
for (IIndexInclude indexInclude : includes) {
@@ -201,7 +200,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
}
} catch (CoreException e) {
CUIPlugin.log(e);
- }
+ }
return IIndexInclude.EMPTY_INCLUDES_ARRAY;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java
index 54eb8c952ea..5a6b43c271c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java
@@ -31,81 +31,81 @@ import org.eclipse.cdt.ui.CUIPlugin;
public class IBConversions {
- public static IBNode selectionToNode(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection ssel= (IStructuredSelection) sel;
- for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
- Object o= iter.next();
- if (o instanceof IBNode) {
- IBNode node = (IBNode) o;
- return node;
- }
- }
- }
- return null;
- }
+ public static IBNode selectionToNode(ISelection sel) {
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) sel;
+ for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
+ Object o = iter.next();
+ if (o instanceof IBNode) {
+ IBNode node = (IBNode) o;
+ return node;
+ }
+ }
+ }
+ return null;
+ }
- public static ITranslationUnit selectionToTU(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection ssel= (IStructuredSelection) sel;
- for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
- ITranslationUnit tu= objectToTU(iter.next());
- if (tu != null) {
- return tu;
- }
- }
- }
- return null;
- }
+ public static ITranslationUnit selectionToTU(ISelection sel) {
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) sel;
+ for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
+ ITranslationUnit tu = objectToTU(iter.next());
+ if (tu != null) {
+ return tu;
+ }
+ }
+ }
+ return null;
+ }
- public static ISelection nodeSelectionToRepresentedTUSelection(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection ssel= (IStructuredSelection) sel;
- ArrayList<ITranslationUnit> tus= new ArrayList<ITranslationUnit>();
- for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
- Object obj= iter.next();
- if (obj instanceof IBNode) {
- ITranslationUnit tu= ((IBNode) obj).getRepresentedTranslationUnit();
- if (tu != null) {
- tus.add(tu);
- }
- }
- }
- return new StructuredSelection(tus);
- }
- return StructuredSelection.EMPTY;
- }
+ public static ISelection nodeSelectionToRepresentedTUSelection(ISelection sel) {
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) sel;
+ ArrayList<ITranslationUnit> tus = new ArrayList<ITranslationUnit>();
+ for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
+ Object obj = iter.next();
+ if (obj instanceof IBNode) {
+ ITranslationUnit tu = ((IBNode) obj).getRepresentedTranslationUnit();
+ if (tu != null) {
+ tus.add(tu);
+ }
+ }
+ }
+ return new StructuredSelection(tus);
+ }
+ return StructuredSelection.EMPTY;
+ }
- public static ITranslationUnit objectToTU(Object object) {
- if (object instanceof ITranslationUnit) {
- return (ITranslationUnit) object;
- }
- if (object instanceof IFile) {
- return CoreModelUtil.findTranslationUnit((IFile) object);
- }
- if (object instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) object;
- ITranslationUnit result= adaptable.getAdapter(ITranslationUnit.class);
- if (result != null) {
- return result;
- }
- IFile file= adaptable.getAdapter(IFile.class);
- if (file != null) {
- return CoreModelUtil.findTranslationUnit(file);
- }
+ public static ITranslationUnit objectToTU(Object object) {
+ if (object instanceof ITranslationUnit) {
+ return (ITranslationUnit) object;
+ }
+ if (object instanceof IFile) {
+ return CoreModelUtil.findTranslationUnit((IFile) object);
+ }
+ if (object instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) object;
+ ITranslationUnit result = adaptable.getAdapter(ITranslationUnit.class);
+ if (result != null) {
+ return result;
+ }
+ IFile file = adaptable.getAdapter(IFile.class);
+ if (file != null) {
+ return CoreModelUtil.findTranslationUnit(file);
+ }
- ILocationProvider locProvider= adaptable.getAdapter(ILocationProvider.class);
- if (locProvider != null) {
- IPath path= locProvider.getPath(locProvider);
- if (path != null) {
- try {
+ ILocationProvider locProvider = adaptable.getAdapter(ILocationProvider.class);
+ if (locProvider != null) {
+ IPath path = locProvider.getPath(locProvider);
+ if (path != null) {
+ try {
return CoreModelUtil.findTranslationUnitForLocation(path, null);
} catch (CModelException e) {
CUIPlugin.log(e);
}
- }
- }
- }
- return null;
- }
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.java
index a91e374ae2f..38a7c648c02 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import java.util.ArrayList;
@@ -30,78 +30,77 @@ import org.eclipse.cdt.core.index.IndexLocationFactory;
public class IBDragSourceListener implements DragSourceListener {
- private TreeViewer fTreeViewer;
- private ArrayList<IBNode> fSelectedNodes= new ArrayList<IBNode>();
+ private TreeViewer fTreeViewer;
+ private ArrayList<IBNode> fSelectedNodes = new ArrayList<IBNode>();
private IBDropTargetListener fDropTargetListener;
- public IBDragSourceListener(TreeViewer viewer) {
- fTreeViewer= viewer;
- }
+ public IBDragSourceListener(TreeViewer viewer) {
+ fTreeViewer = viewer;
+ }
- @Override
+ @Override
public void dragStart(DragSourceEvent event) {
- if (fDropTargetListener != null) {
- fDropTargetListener.setEnabled(false);
- }
- fSelectedNodes.clear();
- if (event.doit) {
- IStructuredSelection sel= (IStructuredSelection) fTreeViewer.getSelection();
- for (Iterator<?> iter = sel.iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (element instanceof IBNode) {
- fSelectedNodes.add((IBNode) element);
- }
- }
- event.doit= !fSelectedNodes.isEmpty();
- }
- }
+ if (fDropTargetListener != null) {
+ fDropTargetListener.setEnabled(false);
+ }
+ fSelectedNodes.clear();
+ if (event.doit) {
+ IStructuredSelection sel = (IStructuredSelection) fTreeViewer.getSelection();
+ for (Iterator<?> iter = sel.iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof IBNode) {
+ fSelectedNodes.add((IBNode) element);
+ }
+ }
+ event.doit = !fSelectedNodes.isEmpty();
+ }
+ }
- public void setDependentDropTargetListener(IBDropTargetListener dl) {
- fDropTargetListener= dl;
- }
-
- @Override
+ public void setDependentDropTargetListener(IBDropTargetListener dl) {
+ fDropTargetListener = dl;
+ }
+
+ @Override
public void dragSetData(DragSourceEvent event) {
- if (ResourceTransfer.getInstance().isSupportedType(event.dataType)) {
- event.data= getResources();
- }
- else if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
- event.data= getFiles();
- }
- }
+ if (ResourceTransfer.getInstance().isSupportedType(event.dataType)) {
+ event.data = getResources();
+ } else if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
+ event.data = getFiles();
+ }
+ }
- private String[] getFiles() {
- ArrayList<String> files= new ArrayList<String>(fSelectedNodes.size());
- for (Iterator<IBNode> iter = fSelectedNodes.iterator(); iter.hasNext();) {
- IBNode node = iter.next();
- IIndexFileLocation ifl= (IIndexFileLocation) node.getAdapter(IIndexFileLocation.class);
- if (ifl != null) {
- IPath location= IndexLocationFactory.getAbsolutePath(ifl);
- if (location != null) {
- files.add(location.toOSString());
- }
- }
- }
- return files.toArray(new String[files.size()]);
- }
+ private String[] getFiles() {
+ ArrayList<String> files = new ArrayList<String>(fSelectedNodes.size());
+ for (Iterator<IBNode> iter = fSelectedNodes.iterator(); iter.hasNext();) {
+ IBNode node = iter.next();
+ IIndexFileLocation ifl = (IIndexFileLocation) node.getAdapter(IIndexFileLocation.class);
+ if (ifl != null) {
+ IPath location = IndexLocationFactory.getAbsolutePath(ifl);
+ if (location != null) {
+ files.add(location.toOSString());
+ }
+ }
+ }
+ return files.toArray(new String[files.size()]);
+ }
- private IFile[] getResources() {
- ArrayList<IFile> files= new ArrayList<IFile>(fSelectedNodes.size());
- for (Iterator<IBNode> iter = fSelectedNodes.iterator(); iter.hasNext();) {
- IBNode node = iter.next();
- IFile file= (IFile) node.getAdapter(IFile.class);
- if (file != null) {
- files.add(file);
- }
- }
- return files.toArray(new IFile[files.size()]);
- }
+ private IFile[] getResources() {
+ ArrayList<IFile> files = new ArrayList<IFile>(fSelectedNodes.size());
+ for (Iterator<IBNode> iter = fSelectedNodes.iterator(); iter.hasNext();) {
+ IBNode node = iter.next();
+ IFile file = (IFile) node.getAdapter(IFile.class);
+ if (file != null) {
+ files.add(file);
+ }
+ }
+ return files.toArray(new IFile[files.size()]);
+ }
- @Override
+ @Override
public void dragFinished(DragSourceEvent event) {
- if (fDropTargetListener != null) {
- fDropTargetListener.setEnabled(true);
- }
- fSelectedNodes.clear();
- }
+ if (fDropTargetListener != null) {
+ fDropTargetListener.setEnabled(true);
+ }
+ fSelectedNodes.clear();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java
index 533912f21b0..65e10da432a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
@@ -37,39 +37,38 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
public class IBDropTargetListener implements DropTargetListener {
-
- private IBViewPart fIncludeBrowser;
+
+ private IBViewPart fIncludeBrowser;
private ITranslationUnit fTranslationUnit;
- private boolean fEnabled= true;
-
- public IBDropTargetListener(IBViewPart view) {
- fIncludeBrowser= view;
- }
-
- public void setEnabled(boolean val) {
- fEnabled= val;
- }
-
- @Override
+ private boolean fEnabled = true;
+
+ public IBDropTargetListener(IBViewPart view) {
+ fIncludeBrowser = view;
+ }
+
+ public void setEnabled(boolean val) {
+ fEnabled = val;
+ }
+
+ @Override
public void dragEnter(DropTargetEvent event) {
- fTranslationUnit= null;
- checkOperation(event);
- if (event.detail != DND.DROP_NONE) {
+ fTranslationUnit = null;
+ checkOperation(event);
+ if (event.detail != DND.DROP_NONE) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
- fTranslationUnit= checkLocalSelection();
+ fTranslationUnit = checkLocalSelection();
if (fTranslationUnit == null) {
- TransferData alternateDataType = checkForAlternateDataType(event.dataTypes,
- new Transfer[] {ResourceTransfer.getInstance(), FileTransfer.getInstance()});
+ TransferData alternateDataType = checkForAlternateDataType(event.dataTypes,
+ new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance() });
if (alternateDataType == null) {
- event.detail= DND.DROP_NONE;
- }
- else {
- event.currentDataType= alternateDataType;
+ event.detail = DND.DROP_NONE;
+ } else {
+ event.currentDataType = alternateDataType;
}
}
- }
- }
- }
+ }
+ }
+ }
private TransferData checkForAlternateDataType(TransferData[] dataTypes, Transfer[] transfers) {
for (int i = 0; i < dataTypes.length; i++) {
@@ -85,9 +84,9 @@ public class IBDropTargetListener implements DropTargetListener {
}
private ITranslationUnit checkLocalSelection() {
- ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
+ ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
if (sel instanceof IStructuredSelection) {
- for (Iterator<?> iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
+ for (Iterator<?> iter = ((IStructuredSelection) sel).iterator(); iter.hasNext();) {
Object element = iter.next();
if (element instanceof ITranslationUnit) {
return (ITranslationUnit) element;
@@ -97,74 +96,73 @@ public class IBDropTargetListener implements DropTargetListener {
return null;
}
- @Override
+ @Override
public void dragLeave(DropTargetEvent event) {
- }
+ }
- @Override
+ @Override
public void dragOperationChanged(DropTargetEvent event) {
- checkOperation(event);
- }
+ checkOperation(event);
+ }
- @Override
+ @Override
public void dragOver(DropTargetEvent event) {
- }
+ }
- @Override
+ @Override
public void drop(DropTargetEvent event) {
- if (fTranslationUnit == null) {
- fTranslationUnit= findFirstTranslationUnit(event.data);
- }
- if (fTranslationUnit == null) {
- fIncludeBrowser.setMessage(IBMessages.IBViewPart_falseInputMessage);
- Display.getCurrent().beep();
- }
- else {
- fIncludeBrowser.setInput(fTranslationUnit);
- }
- }
-
- private ITranslationUnit findFirstTranslationUnit(Object o) {
- if (o instanceof String[]) {
- String[] filePaths= (String[]) o;
- for (int i = 0; i < filePaths.length; i++) {
- String filePath = filePaths[i];
- ITranslationUnit tu= findTranslationUnit(ResourceLookup.findFilesForLocation(Path.fromOSString(filePath)));
- if (tu != null) {
- return tu;
- }
- }
- return null;
- }
- if (o instanceof IResource[]) {
- return findTranslationUnit((IResource[]) o);
- }
- return null;
- }
-
- private ITranslationUnit findTranslationUnit(IResource[] files) {
- for (int i = 0; i < files.length; i++) {
- IResource resource = files[i];
- if (resource.getType() == IResource.FILE) {
- ITranslationUnit tu= CoreModelUtil.findTranslationUnit((IFile) resource);
- if (tu != null) {
- return tu;
- }
- }
- }
- return null;
- }
-
- @Override
+ if (fTranslationUnit == null) {
+ fTranslationUnit = findFirstTranslationUnit(event.data);
+ }
+ if (fTranslationUnit == null) {
+ fIncludeBrowser.setMessage(IBMessages.IBViewPart_falseInputMessage);
+ Display.getCurrent().beep();
+ } else {
+ fIncludeBrowser.setInput(fTranslationUnit);
+ }
+ }
+
+ private ITranslationUnit findFirstTranslationUnit(Object o) {
+ if (o instanceof String[]) {
+ String[] filePaths = (String[]) o;
+ for (int i = 0; i < filePaths.length; i++) {
+ String filePath = filePaths[i];
+ ITranslationUnit tu = findTranslationUnit(
+ ResourceLookup.findFilesForLocation(Path.fromOSString(filePath)));
+ if (tu != null) {
+ return tu;
+ }
+ }
+ return null;
+ }
+ if (o instanceof IResource[]) {
+ return findTranslationUnit((IResource[]) o);
+ }
+ return null;
+ }
+
+ private ITranslationUnit findTranslationUnit(IResource[] files) {
+ for (int i = 0; i < files.length; i++) {
+ IResource resource = files[i];
+ if (resource.getType() == IResource.FILE) {
+ ITranslationUnit tu = CoreModelUtil.findTranslationUnit((IFile) resource);
+ if (tu != null) {
+ return tu;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
public void dropAccept(DropTargetEvent event) {
- }
-
- private void checkOperation(DropTargetEvent event) {
- if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
- event.detail= DND.DROP_COPY;
- }
- else {
- event.detail= DND.DROP_NONE;
- }
- }
+ }
+
+ private void checkOperation(DropTargetEvent event) {
+ if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
+ event.detail = DND.DROP_COPY;
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBFile.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBFile.java
index de8e6f21a7f..2dc10e45e9a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBFile.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBFile.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* IBM Corporation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
@@ -32,29 +32,29 @@ public class IBFile {
final public ITranslationUnit fTU;
final public IIndexFileLocation fLocation;
final public String fName;
-
+
public IBFile(ITranslationUnit tu) {
- fTU= tu;
- fLocation= IndexLocationFactory.getIFL(tu);
- fName= tu.getElementName();
+ fTU = tu;
+ fLocation = IndexLocationFactory.getIFL(tu);
+ fName = tu.getElementName();
}
-
+
public IBFile(ICProject preferredProject, IIndexFileLocation location) throws CModelException {
- fLocation= location;
+ fLocation = location;
ITranslationUnit TU = CoreModelUtil.findTranslationUnitForLocation(location, preferredProject);
if (TU == null) //for EFS file that might not be on this filesystem
TU = CoreModelUtil.findTranslationUnitForLocation(location.getURI(), preferredProject);
fTU = TU;
- String name= fLocation.getURI().getPath();
- fName= name.substring(name.lastIndexOf('/')+1);
+ String name = fLocation.getURI().getPath();
+ fName = name.substring(name.lastIndexOf('/') + 1);
}
public IBFile(String name) {
- fName= name;
- fLocation= null;
- fTU= null;
+ fName = name;
+ fLocation = null;
+ fTU = null;
}
-
+
public IIndexFileLocation getLocation() {
return fLocation;
}
@@ -63,17 +63,14 @@ public class IBFile {
public boolean equals(Object obj) {
if (obj instanceof IBFile) {
IBFile file = (IBFile) obj;
- return (Objects.equals(fLocation, file.fLocation) &&
- Objects.equals(fTU, file.fTU));
+ return (Objects.equals(fLocation, file.fLocation) && Objects.equals(fTU, file.fTU));
}
return super.equals(obj);
}
@Override
public int hashCode() {
- return Objects.hashCode(fLocation)
- + 31* (Objects.hashCode(fTU)
- + 31* Objects.hashCode(fName));
+ return Objects.hashCode(fLocation) + 31 * (Objects.hashCode(fTU) + 31 * Objects.hashCode(fName));
}
public ITranslationUnit getTranslationUnit() {
@@ -82,9 +79,9 @@ public class IBFile {
public IFile getResource() {
if (fLocation != null) {
- String fullPath= fLocation.getFullPath();
+ String fullPath = fLocation.getFullPath();
if (fullPath != null) {
- IResource file= ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath);
+ IResource file = ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath);
if (file instanceof IFile) {
return (IFile) file;
}
@@ -92,7 +89,7 @@ public class IBFile {
}
return null;
}
-
+
public String getName() {
return fName;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java
index 6bf04122d38..8f84d7603f4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java
@@ -22,7 +22,6 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-
/**
* Action used for the include browser forward / backward buttons
*/
@@ -30,24 +29,24 @@ public class IBHistoryAction extends Action {
private IBViewPart fViewPart;
private ITranslationUnit fElement;
-
+
public IBHistoryAction(IBViewPart viewPart, ITranslationUnit element) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- fViewPart= viewPart;
- fElement= element;
-
- String elementName= CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED);
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+ fViewPart = viewPart;
+ fElement = element;
+
+ String elementName = CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED);
setText(elementName);
setImageDescriptor(getImageDescriptor(element));
}
-
+
private ImageDescriptor getImageDescriptor(ITranslationUnit elem) {
- CElementImageProvider imageProvider= new CElementImageProvider();
- ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
+ CElementImageProvider imageProvider = new CElementImageProvider();
+ ImageDescriptor desc = imageProvider.getBaseImageDescriptor(elem, 0);
imageProvider.dispose();
return desc;
}
-
+
/*
* @see Action#run()
*/
@@ -55,5 +54,5 @@ public class IBHistoryAction extends Action {
public void run() {
fViewPart.setInput(fElement);
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownAction.java
index 2faca13a0e1..600d89ed695 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownAction.java
@@ -27,16 +27,16 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.CPluginImages;
public class IBHistoryDropDownAction extends Action implements IMenuCreator {
-
+
public static class ClearHistoryAction extends Action {
private IBViewPart fView;
-
+
public ClearHistoryAction(IBViewPart view) {
super(IBMessages.IBHistoryDropDownAction_ClearHistory_label);
- fView= view;
+ fView = view;
}
-
+
@Override
public void run() {
fView.setHistoryEntries(new ITranslationUnit[0]);
@@ -44,15 +44,15 @@ public class IBHistoryDropDownAction extends Action implements IMenuCreator {
}
}
- public static final int RESULTS_IN_DROP_DOWN= 10;
+ public static final int RESULTS_IN_DROP_DOWN = 10;
private IBViewPart fHierarchyView;
private Menu fMenu;
-
+
public IBHistoryDropDownAction(IBViewPart view) {
- fHierarchyView= view;
- fMenu= null;
- setToolTipText(IBMessages.IBHistoryDropDownAction_tooltip);
+ fHierarchyView = view;
+ fMenu = null;
+ setToolTipText(IBMessages.IBHistoryDropDownAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
setMenuCreator(this);
}
@@ -62,7 +62,7 @@ public class IBHistoryDropDownAction extends Action implements IMenuCreator {
// action is reused, can be called several times.
if (fMenu != null) {
fMenu.dispose();
- fMenu= null;
+ fMenu = null;
}
}
@@ -76,33 +76,31 @@ public class IBHistoryDropDownAction extends Action implements IMenuCreator {
if (fMenu != null) {
fMenu.dispose();
}
- fMenu= new Menu(parent);
- ITranslationUnit[] elements= fHierarchyView.getHistoryEntries();
+ fMenu = new Menu(parent);
+ ITranslationUnit[] elements = fHierarchyView.getHistoryEntries();
addEntries(fMenu, elements);
new MenuItem(fMenu, SWT.SEPARATOR);
addActionToMenu(fMenu, new IBHistoryListAction(fHierarchyView));
addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
return fMenu;
}
-
+
private boolean addEntries(Menu menu, ITranslationUnit[] elements) {
- boolean checked= false;
-
- int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
- for (int i= 0; i < min; i++) {
- IBHistoryAction action= new IBHistoryAction(fHierarchyView, elements[i]);
+ boolean checked = false;
+
+ int min = Math.min(elements.length, RESULTS_IN_DROP_DOWN);
+ for (int i = 0; i < min; i++) {
+ IBHistoryAction action = new IBHistoryAction(fHierarchyView, elements[i]);
action.setChecked(elements[i].equals(fHierarchyView.getInput()));
- checked= checked || action.isChecked();
+ checked = checked || action.isChecked();
addActionToMenu(menu, action);
}
-
-
+
return checked;
}
-
protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
+ ActionContributionItem item = new ActionContributionItem(action);
item.fill(parent, -1);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java
index e3512f7046b..8c566e896d7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java
@@ -42,71 +42,71 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class IBHistoryListAction extends Action {
-
+
private class HistoryListDialog extends StatusDialog {
private ListDialogField<ITranslationUnit> fHistoryList;
private IStatus fHistoryStatus;
private ITranslationUnit fResult;
-
+
private HistoryListDialog(Shell shell, ITranslationUnit[] elements) {
super(shell);
- setHelpAvailable(false);
- setTitle(IBMessages.IBHistoryListAction_HistoryDialog_title);
- String[] buttonLabels= new String[] {
- IBMessages.IBHistoryListAction_Remove_label,
- };
-
- IListAdapter<ITranslationUnit> adapter= new IListAdapter<ITranslationUnit>() {
+ setHelpAvailable(false);
+ setTitle(IBMessages.IBHistoryListAction_HistoryDialog_title);
+ String[] buttonLabels = new String[] { IBMessages.IBHistoryListAction_Remove_label, };
+
+ IListAdapter<ITranslationUnit> adapter = new IListAdapter<ITranslationUnit>() {
@Override
public void customButtonPressed(ListDialogField<ITranslationUnit> field, int index) {
doCustomButtonPressed();
}
+
@Override
public void selectionChanged(ListDialogField<ITranslationUnit> field) {
doSelectionChanged();
}
-
+
@Override
public void doubleClicked(ListDialogField<ITranslationUnit> field) {
doDoubleClicked();
- }
+ }
};
-
- ILabelProvider labelProvider= new CUILabelProvider(CElementLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS);
-
- fHistoryList= new ListDialogField<ITranslationUnit>(adapter, buttonLabels, labelProvider);
- fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label);
+
+ ILabelProvider labelProvider = new CUILabelProvider(CElementLabels.APPEND_ROOT_PATH,
+ CElementImageProvider.OVERLAY_ICONS);
+
+ fHistoryList = new ListDialogField<ITranslationUnit>(adapter, buttonLabels, labelProvider);
+ fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label);
fHistoryList.setElements(Arrays.asList(elements));
-
+
ISelection sel;
if (elements.length > 0) {
- sel= new StructuredSelection(elements[0]);
+ sel = new StructuredSelection(elements[0]);
} else {
- sel= new StructuredSelection();
+ sel = new StructuredSelection();
}
-
+
fHistoryList.selectElements(sel);
}
-
+
/*
* @see Dialog#createDialogArea(Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
initializeDialogUnits(parent);
-
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
+
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Composite inner = new Composite(composite, SWT.NONE);
inner.setFont(parent.getFont());
-
+
inner.setLayoutData(new GridData(GridData.FILL_BOTH));
LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null), true);
- applyDialogFont(composite);
+ applyDialogFont(composite);
return composite;
}
@@ -116,43 +116,43 @@ public class IBHistoryListAction extends Action {
private void doCustomButtonPressed() {
fHistoryList.removeElements(fHistoryList.getSelectedElements());
}
-
+
private void doDoubleClicked() {
if (fHistoryStatus.isOK()) {
okPressed();
}
}
-
+
private void doSelectionChanged() {
- StatusInfo status= new StatusInfo();
- List<ITranslationUnit> selected= fHistoryList.getSelectedElements();
+ StatusInfo status = new StatusInfo();
+ List<ITranslationUnit> selected = fHistoryList.getSelectedElements();
if (selected.size() != 1) {
status.setError(""); //$NON-NLS-1$
- fResult= null;
+ fResult = null;
} else {
- fResult= selected.get(0);
+ fResult = selected.get(0);
}
- fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
- fHistoryStatus= status;
- updateStatus(status);
+ fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
+ fHistoryStatus = status;
+ updateStatus(status);
}
-
+
public ITranslationUnit getResult() {
return fResult;
}
-
+
public ITranslationUnit[] getRemaining() {
- List<ITranslationUnit> elems= fHistoryList.getElements();
+ List<ITranslationUnit> elems = fHistoryList.getElements();
return elems.toArray(new ITranslationUnit[elems.size()]);
- }
-
+ }
+
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
}
/* (non-Javadoc)
@@ -164,25 +164,24 @@ public class IBHistoryListAction extends Action {
super.create();
}
}
-
+
private IBViewPart fView;
-
+
public IBHistoryListAction(IBViewPart view) {
- fView= view;
- setText(IBMessages.IBHistoryListAction_label);
+ fView = view;
+ setText(IBMessages.IBHistoryListAction_label);
}
-
+
/*
* @see IAction#run()
*/
@Override
public void run() {
- ITranslationUnit[] historyEntries= fView.getHistoryEntries();
- HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
+ ITranslationUnit[] historyEntries = fView.getHistoryEntries();
+ HistoryListDialog dialog = new HistoryListDialog(fView.getSite().getShell(), historyEntries);
if (dialog.open() == Window.OK) {
fView.setHistoryEntries(dialog.getRemaining());
fView.setInput(dialog.getResult());
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.java
index 6f42e6963b4..f8645da6f1a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import java.util.HashMap;
@@ -34,111 +34,110 @@ import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
public class IBLabelProvider extends LabelProvider implements IColorProvider {
- private CElementLabelProvider fCLabelProvider= new CElementLabelProvider();
- private Color fColorInactive;
- private IBContentProvider fContentProvider;
- private HashMap<String, Image> fCachedImages= new HashMap<String, Image>();
- private boolean fShowFolders;
-
- public IBLabelProvider(Display display, IBContentProvider cp) {
- fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
- fContentProvider= cp;
- }
-
- @Override
+ private CElementLabelProvider fCLabelProvider = new CElementLabelProvider();
+ private Color fColorInactive;
+ private IBContentProvider fContentProvider;
+ private HashMap<String, Image> fCachedImages = new HashMap<String, Image>();
+ private boolean fShowFolders;
+
+ public IBLabelProvider(Display display, IBContentProvider cp) {
+ fColorInactive = display.getSystemColor(SWT.COLOR_DARK_GRAY);
+ fContentProvider = cp;
+ }
+
+ @Override
public Image getImage(Object element) {
- if (element instanceof IBNode) {
- IBNode node= (IBNode) element;
- ITranslationUnit tu= node.getRepresentedTranslationUnit();
- Image image= tu != null ? fCLabelProvider.getImage(tu) : CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
- return decorateImage(image, node);
- }
- return super.getImage(element);
- }
-
- @Override
+ if (element instanceof IBNode) {
+ IBNode node = (IBNode) element;
+ ITranslationUnit tu = node.getRepresentedTranslationUnit();
+ Image image = tu != null ? fCLabelProvider.getImage(tu)
+ : CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+ return decorateImage(image, node);
+ }
+ return super.getImage(element);
+ }
+
+ @Override
public String getText(Object element) {
- if (element instanceof IBNode) {
- IBNode node= (IBNode) element;
- IPath path= node.getRepresentedPath();
- if (path != null) {
- if (fShowFolders) {
- return path.lastSegment() + " (" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return path.lastSegment();
- }
- return node.getDirectiveName();
- }
- return super.getText(element);
- }
-
- @Override
+ if (element instanceof IBNode) {
+ IBNode node = (IBNode) element;
+ IPath path = node.getRepresentedPath();
+ if (path != null) {
+ if (fShowFolders) {
+ return path.lastSegment() + " (" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return path.lastSegment();
+ }
+ return node.getDirectiveName();
+ }
+ return super.getText(element);
+ }
+
+ @Override
public void dispose() {
- fCLabelProvider.dispose();
- for (Iterator<Image> iter = fCachedImages.values().iterator(); iter.hasNext();) {
- Image image = iter.next();
- image.dispose();
- }
- fCachedImages.clear();
- super.dispose();
- }
-
- private Image decorateImage(Image image, IBNode node) {
- int flags= 0;
- if (node.isSystemInclude()) {
- flags |= CElementImageDescriptor.SYSTEM_INCLUDE;
- }
- if (!node.isActiveCode()) {
- flags |= CElementImageDescriptor.INACTIVE;
- }
-
- if (node.isRecursive()) {
- flags |= CElementImageDescriptor.RECURSIVE_RELATION;
- }
- else if (fContentProvider.hasChildren(node)) {
- if (fContentProvider.getComputeIncludedBy()) {
- flags |= CElementImageDescriptor.REFERENCED_BY;
- }
- else {
- flags |= CElementImageDescriptor.RELATES_TO;
- }
- }
-
- if (node.isActiveCode() && node.getRepresentedIFL() == null) {
- flags |= CElementImageDescriptor.WARNING;
- }
-
- if (flags == 0) {
- return image;
- }
- String key= image.toString()+String.valueOf(flags);
- Image result= fCachedImages.get(key);
- if (result == null) {
- ImageDescriptor desc= new CElementImageDescriptor(
- new ImageImageDescriptor(image), flags, new Point(20,16));
- result= desc.createImage();
- fCachedImages.put(key, result);
- }
- return result;
- }
-
- @Override
+ fCLabelProvider.dispose();
+ for (Iterator<Image> iter = fCachedImages.values().iterator(); iter.hasNext();) {
+ Image image = iter.next();
+ image.dispose();
+ }
+ fCachedImages.clear();
+ super.dispose();
+ }
+
+ private Image decorateImage(Image image, IBNode node) {
+ int flags = 0;
+ if (node.isSystemInclude()) {
+ flags |= CElementImageDescriptor.SYSTEM_INCLUDE;
+ }
+ if (!node.isActiveCode()) {
+ flags |= CElementImageDescriptor.INACTIVE;
+ }
+
+ if (node.isRecursive()) {
+ flags |= CElementImageDescriptor.RECURSIVE_RELATION;
+ } else if (fContentProvider.hasChildren(node)) {
+ if (fContentProvider.getComputeIncludedBy()) {
+ flags |= CElementImageDescriptor.REFERENCED_BY;
+ } else {
+ flags |= CElementImageDescriptor.RELATES_TO;
+ }
+ }
+
+ if (node.isActiveCode() && node.getRepresentedIFL() == null) {
+ flags |= CElementImageDescriptor.WARNING;
+ }
+
+ if (flags == 0) {
+ return image;
+ }
+ String key = image.toString() + String.valueOf(flags);
+ Image result = fCachedImages.get(key);
+ if (result == null) {
+ ImageDescriptor desc = new CElementImageDescriptor(new ImageImageDescriptor(image), flags,
+ new Point(20, 16));
+ result = desc.createImage();
+ fCachedImages.put(key, result);
+ }
+ return result;
+ }
+
+ @Override
public Color getBackground(Object element) {
- return null;
- }
+ return null;
+ }
- @Override
+ @Override
public Color getForeground(Object element) {
- if (element instanceof IBNode) {
- IBNode node= (IBNode) element;
- if (!node.isActiveCode()) {
- return fColorInactive;
- }
- }
- return null;
- }
-
- public void setShowFolders(boolean show) {
- fShowFolders= show;
- }
+ if (element instanceof IBNode) {
+ IBNode node = (IBNode) element;
+ if (!node.isActiveCode()) {
+ return fColorInactive;
+ }
+ }
+ return null;
+ }
+
+ public void setShowFolders(boolean show) {
+ fShowFolders = show;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBNode.java
index 6d901edcfee..ad1bcf582e7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBNode.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import java.util.Objects;
@@ -29,50 +29,50 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
*/
public class IBNode implements IAdaptable {
private IBNode fParent;
- private IBFile fRepresentedFile;
-
- // navigation info
- private IBFile fDirectiveFile;
- private int fDirectiveCharacterOffset;
- private int fDirectiveLength;
- private int fHashCode;
-
- private boolean fIsSystemInclude= false;
- private boolean fIsActive= true;
- private boolean fIsRecursive;
- private long fTimestamp;
-
- /**
- * Creates a new node for the include browser
- */
- public IBNode(IBNode parent, IBFile represents, IBFile fileOfDirective,
- int charOffset, int length, long timestamp) {
- assert represents != null;
- fParent= parent;
- fRepresentedFile= represents;
- fDirectiveFile= fileOfDirective;
- fDirectiveCharacterOffset= charOffset;
- fDirectiveLength= length;
- fIsRecursive= computeIsRecursive(fParent, represents.getLocation());
- fHashCode= computeHashCode();
- fTimestamp= timestamp;
- }
-
- private int computeHashCode() {
- int hashCode= 0;
- if (fParent != null) {
- hashCode= fParent.hashCode() * 31;
- }
- hashCode+= fRepresentedFile.hashCode();
- return hashCode;
- }
-
- @Override
+ private IBFile fRepresentedFile;
+
+ // navigation info
+ private IBFile fDirectiveFile;
+ private int fDirectiveCharacterOffset;
+ private int fDirectiveLength;
+ private int fHashCode;
+
+ private boolean fIsSystemInclude = false;
+ private boolean fIsActive = true;
+ private boolean fIsRecursive;
+ private long fTimestamp;
+
+ /**
+ * Creates a new node for the include browser
+ */
+ public IBNode(IBNode parent, IBFile represents, IBFile fileOfDirective, int charOffset, int length,
+ long timestamp) {
+ assert represents != null;
+ fParent = parent;
+ fRepresentedFile = represents;
+ fDirectiveFile = fileOfDirective;
+ fDirectiveCharacterOffset = charOffset;
+ fDirectiveLength = length;
+ fIsRecursive = computeIsRecursive(fParent, represents.getLocation());
+ fHashCode = computeHashCode();
+ fTimestamp = timestamp;
+ }
+
+ private int computeHashCode() {
+ int hashCode = 0;
+ if (fParent != null) {
+ hashCode = fParent.hashCode() * 31;
+ }
+ hashCode += fRepresentedFile.hashCode();
+ return hashCode;
+ }
+
+ @Override
public int hashCode() {
- return fHashCode;
- }
-
- @Override
+ return fHashCode;
+ }
+
+ @Override
public boolean equals(Object o) {
if (!(o instanceof IBNode)) {
return false;
@@ -83,99 +83,99 @@ public class IBNode implements IAdaptable {
return false;
}
- return Objects.equals(fRepresentedFile, rhs.fRepresentedFile);
+ return Objects.equals(fRepresentedFile, rhs.fRepresentedFile);
+ }
+
+ private boolean computeIsRecursive(IBNode parent, IIndexFileLocation ifl) {
+ if (parent == null || ifl == null) {
+ return false;
+ }
+ if (ifl.equals(parent.getRepresentedFile().getLocation())) {
+ return true;
+ }
+ return computeIsRecursive(parent.fParent, ifl);
+ }
+
+ /**
+ * Returns the parent node or <code>null</code> for the root node.
+ */
+ public IBNode getParent() {
+ return fParent;
+ }
+
+ /**
+ * Returns the translation unit that requests the inclusion
+ */
+ public IBFile getRepresentedFile() {
+ return fRepresentedFile;
}
-
- private boolean computeIsRecursive(IBNode parent, IIndexFileLocation ifl) {
- if (parent == null || ifl == null) {
- return false;
- }
- if (ifl.equals(parent.getRepresentedFile().getLocation())) {
- return true;
- }
- return computeIsRecursive(parent.fParent, ifl);
- }
/**
- * Returns the parent node or <code>null</code> for the root node.
- */
- public IBNode getParent() {
- return fParent;
- }
-
- /**
- * Returns the translation unit that requests the inclusion
- */
- public IBFile getRepresentedFile() {
- return fRepresentedFile;
- }
-
- /**
- * Returns whether this is a system include (angle-brackets).
- */
- public boolean isSystemInclude() {
- return fIsSystemInclude;
- }
-
- /**
- * Defines whether this is a system include (angle-brackets).
- */
- public void setIsSystemInclude(boolean isSystemInclude) {
- fIsSystemInclude= isSystemInclude;
- }
-
- /**
- * Returns whether this inclusion is actually performed with the current set
- * of macro definitions. This is true unless the include directive appears within
- * a conditional compilation construct (#ifdef/#endif).
- */
- public boolean isActiveCode() {
- return fIsActive;
- }
-
- /**
- * Defines whether the inclusion appears in active code.
- */
- public void setIsActiveCode(boolean isActiveCode) {
- fIsActive= isActiveCode;
- }
-
- public boolean isRecursive() {
- return fIsRecursive;
- }
-
- public int getDirectiveCharacterOffset() {
- return fDirectiveCharacterOffset;
- }
-
- public int getDirectiveLength() {
- return fDirectiveLength;
- }
-
- public IBFile getDirectiveFile() {
- return fDirectiveFile;
- }
-
- public String getDirectiveName() {
- return fRepresentedFile.getName();
- }
-
- @Override
+ * Returns whether this is a system include (angle-brackets).
+ */
+ public boolean isSystemInclude() {
+ return fIsSystemInclude;
+ }
+
+ /**
+ * Defines whether this is a system include (angle-brackets).
+ */
+ public void setIsSystemInclude(boolean isSystemInclude) {
+ fIsSystemInclude = isSystemInclude;
+ }
+
+ /**
+ * Returns whether this inclusion is actually performed with the current set
+ * of macro definitions. This is true unless the include directive appears within
+ * a conditional compilation construct (#ifdef/#endif).
+ */
+ public boolean isActiveCode() {
+ return fIsActive;
+ }
+
+ /**
+ * Defines whether the inclusion appears in active code.
+ */
+ public void setIsActiveCode(boolean isActiveCode) {
+ fIsActive = isActiveCode;
+ }
+
+ public boolean isRecursive() {
+ return fIsRecursive;
+ }
+
+ public int getDirectiveCharacterOffset() {
+ return fDirectiveCharacterOffset;
+ }
+
+ public int getDirectiveLength() {
+ return fDirectiveLength;
+ }
+
+ public IBFile getDirectiveFile() {
+ return fDirectiveFile;
+ }
+
+ public String getDirectiveName() {
+ return fRepresentedFile.getName();
+ }
+
+ @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Class adapter) {
- if (fRepresentedFile != null) {
- if (adapter.isAssignableFrom(ITranslationUnit.class)) {
- return fRepresentedFile.getTranslationUnit();
- }
- if (adapter.isAssignableFrom(IFile.class)) {
- return fRepresentedFile.getResource();
- }
- if (adapter.isAssignableFrom(IIndexFileLocation.class)) {
- return fRepresentedFile.getLocation();
- }
- }
- return null;
- }
+ if (fRepresentedFile != null) {
+ if (adapter.isAssignableFrom(ITranslationUnit.class)) {
+ return fRepresentedFile.getTranslationUnit();
+ }
+ if (adapter.isAssignableFrom(IFile.class)) {
+ return fRepresentedFile.getResource();
+ }
+ if (adapter.isAssignableFrom(IIndexFileLocation.class)) {
+ return fRepresentedFile.getLocation();
+ }
+ }
+ return null;
+ }
public ITranslationUnit getRepresentedTranslationUnit() {
return fRepresentedFile == null ? null : fRepresentedFile.getTranslationUnit();
@@ -185,13 +185,13 @@ public class IBNode implements IAdaptable {
if (fRepresentedFile == null) {
return null;
}
- IIndexFileLocation ifl= fRepresentedFile.getLocation();
+ IIndexFileLocation ifl = fRepresentedFile.getLocation();
if (ifl != null) {
return IndexLocationFactory.getPath(ifl);
}
return null;
}
-
+
public IIndexFileLocation getRepresentedIFL() {
return fRepresentedFile == null ? null : fRepresentedFile.getLocation();
}
@@ -201,11 +201,11 @@ public class IBNode implements IAdaptable {
}
public ICProject getCProject() {
- ITranslationUnit tu= getRepresentedTranslationUnit();
+ ITranslationUnit tu = getRepresentedTranslationUnit();
if (tu != null) {
return tu.getCProject();
}
- IBNode parent= getParent();
+ IBNode parent = getParent();
if (parent != null) {
return parent.getCProject();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBRemoveFromView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBRemoveFromView.java
index c73e65d2fc4..21934ff4a63 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBRemoveFromView.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBRemoveFromView.java
@@ -27,12 +27,12 @@ public class IBRemoveFromView extends Action {
/**
* Constructs a Remove From View action.
- *
+ *
* @param view the Include Browser view
*/
public IBRemoveFromView(IBViewPart view) {
super(IBMessages.IBViewPart_RemoveFromView_label);
- fView= view;
+ fView = view;
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE));
setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.java
index 4a7c713198e..aa4dd516bd2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
@@ -31,18 +31,17 @@ public class IBSetInputJob extends Job {
private Display fDisplay;
private IBViewPart fViewPart;
-
public IBSetInputJob(IBViewPart viewPart, Display disp) {
super(IBMessages.IBViewPart_waitingOnIndexerMessage);
setSystem(true);
- fViewPart= viewPart;
- fDisplay= disp;
+ fViewPart = viewPart;
+ fDisplay = disp;
}
-
+
@Override
protected IStatus run(IProgressMonitor monitor) {
- if (CCorePlugin.getIndexManager().joinIndexer(IIndexManager.FOREVER, monitor)) {
- try {
+ if (CCorePlugin.getIndexManager().joinIndexer(IIndexManager.FOREVER, monitor)) {
+ try {
fDisplay.asyncExec(new Runnable() {
@Override
public void run() {
@@ -53,10 +52,10 @@ public class IBSetInputJob extends Job {
// display may be disposed
}
}
- return Status.OK_STATUS;
+ return Status.OK_STATUS;
}
public void setInput(ITranslationUnit input) {
- fInput= input;
+ fInput = input;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java
index 2d6d86f4027..e8f064d14c8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java
@@ -11,9 +11,9 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Ed Swartz (Nokia)
- * Martin Oberhuber (Wind River) - bug 398195: consider external API in IB
+ * Martin Oberhuber (Wind River) - bug 398195: consider external API in IB
* Marc-Andre Laperle (Ericsson)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import java.util.ArrayList;
@@ -121,46 +121,46 @@ import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
*/
public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget, IShowInTargetList {
private static final int MAX_HISTORY_SIZE = 10;
- private static final String TRUE = "true"; //$NON-NLS-1$
- private static final String FALSE = "false"; //$NON-NLS-1$
- private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
- private static final String KEY_FILTER_SYSTEM = "systemFilter"; //$NON-NLS-1$
- private static final String KEY_FILTER_INACTIVE = "inactiveFilter"; //$NON-NLS-1$
- private static final String KEY_INPUT_PATH= "inputPath"; //$NON-NLS-1$
+ private static final String TRUE = "true"; //$NON-NLS-1$
+ private static final String FALSE = "false"; //$NON-NLS-1$
+ private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
+ private static final String KEY_FILTER_SYSTEM = "systemFilter"; //$NON-NLS-1$
+ private static final String KEY_FILTER_INACTIVE = "inactiveFilter"; //$NON-NLS-1$
+ private static final String KEY_INPUT_PATH = "inputPath"; //$NON-NLS-1$
private static final String KEY_INCLUDED_BY = "includedBy"; //$NON-NLS-1$
private static final String KEY_SHOW_FOLDERS = "showFolders"; //$NON-NLS-1$
-
- private IMemento fMemento;
- private boolean fShowsMessage;
- private IBNode fLastNavigationNode;
- private ArrayList<ITranslationUnit> fHistoryEntries= new ArrayList<ITranslationUnit>(MAX_HISTORY_SIZE);
-
- // widgets
- private PageBook fPagebook;
- private Composite fViewerPage;
- private Label fInfoText;
-
- // treeviewer
- private IBContentProvider fContentProvider;
- private IBLabelProvider fLabelProvider;
- private ExtendedTreeViewer fTreeViewer;
-
- // filters, sorter
- private IBWorkingSetFilter fWorkingSetFilter;
- private ViewerFilter fInactiveFilter;
- private ViewerFilter fSystemFilter;
- private ViewerComparator fSorterAlphaNumeric;
- private ViewerComparator fSorterReferencePosition;
-
- // actions
- private Action fIncludedByAction;
- private Action fIncludesToAction;
- private Action fFilterInactiveAction;
- private Action fFilterSystemAction;
- private Action fShowFolderInLabelsAction;
- private Action fNextAction;
- private Action fPreviousAction;
- private Action fRefreshAction;
+
+ private IMemento fMemento;
+ private boolean fShowsMessage;
+ private IBNode fLastNavigationNode;
+ private ArrayList<ITranslationUnit> fHistoryEntries = new ArrayList<ITranslationUnit>(MAX_HISTORY_SIZE);
+
+ // widgets
+ private PageBook fPagebook;
+ private Composite fViewerPage;
+ private Label fInfoText;
+
+ // treeviewer
+ private IBContentProvider fContentProvider;
+ private IBLabelProvider fLabelProvider;
+ private ExtendedTreeViewer fTreeViewer;
+
+ // filters, sorter
+ private IBWorkingSetFilter fWorkingSetFilter;
+ private ViewerFilter fInactiveFilter;
+ private ViewerFilter fSystemFilter;
+ private ViewerComparator fSorterAlphaNumeric;
+ private ViewerComparator fSorterReferencePosition;
+
+ // actions
+ private Action fIncludedByAction;
+ private Action fIncludesToAction;
+ private Action fFilterInactiveAction;
+ private Action fFilterSystemAction;
+ private Action fShowFolderInLabelsAction;
+ private Action fNextAction;
+ private Action fPreviousAction;
+ private Action fRefreshAction;
private Action fHistoryAction;
private Action fRemoveFromViewAction;
private CopyTreeAction fCopyAction;
@@ -171,75 +171,76 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
private IBindingService bindingService;
private IBindingManagerListener bindingManagerListener;
- @Override
+ @Override
public void setFocus() {
- fPagebook.setFocus();
- }
-
- public void setMessage(String msg) {
- fInfoText.setText(msg);
- fPagebook.showPage(fInfoText);
- fShowsMessage= true;
- updateActionEnablement();
- updateDescription();
- }
-
- public void setInput(ITranslationUnit input) {
- if (fPagebook.isDisposed()) {
- return;
- }
- if (input instanceof IWorkingCopy) {
- input= ((IWorkingCopy) input).getOriginalElement();
- }
- fSetInputJob.cancel();
- if (input == null) {
- setMessage(IBMessages.IBViewPart_instructionMessage);
- fTreeViewer.setInput(null);
- return;
- }
-
- if (CCorePlugin.getIndexManager().isIndexerIdle()) {
- setInputIndexerIdle(input);
- } else {
- setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
- fSetInputJob.setInput(input);
- fSetInputJob.schedule();
- }
- }
+ fPagebook.setFocus();
+ }
+
+ public void setMessage(String msg) {
+ fInfoText.setText(msg);
+ fPagebook.showPage(fInfoText);
+ fShowsMessage = true;
+ updateActionEnablement();
+ updateDescription();
+ }
+
+ public void setInput(ITranslationUnit input) {
+ if (fPagebook.isDisposed()) {
+ return;
+ }
+ if (input instanceof IWorkingCopy) {
+ input = ((IWorkingCopy) input).getOriginalElement();
+ }
+ fSetInputJob.cancel();
+ if (input == null) {
+ setMessage(IBMessages.IBViewPart_instructionMessage);
+ fTreeViewer.setInput(null);
+ return;
+ }
+
+ if (CCorePlugin.getIndexManager().isIndexerIdle()) {
+ setInputIndexerIdle(input);
+ } else {
+ setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
+ fSetInputJob.setInput(input);
+ fSetInputJob.schedule();
+ }
+ }
private void setInputIndexerIdle(final ITranslationUnit input) {
- fShowsMessage= false;
- boolean isHeader= input.isHeaderUnit();
-
- fTreeViewer.setInput(null);
- if (!isHeader) {
- fContentProvider.setComputeIncludedBy(isHeader);
- fIncludedByAction.setChecked(isHeader);
- fIncludesToAction.setChecked(!isHeader);
- fIncludedByAction.setEnabled(false);
- updateSorter();
- } else {
- fIncludedByAction.setEnabled(true);
- }
- fTreeViewer.setInput(input);
- fPagebook.showPage(fViewerPage);
- updateHistory(input);
-
- updateActionEnablement();
- updateDescription();
- final Display display= Display.getCurrent();
- Job job= new Job(IBMessages.IBViewPart_jobCheckInput) {
+ fShowsMessage = false;
+ boolean isHeader = input.isHeaderUnit();
+
+ fTreeViewer.setInput(null);
+ if (!isHeader) {
+ fContentProvider.setComputeIncludedBy(isHeader);
+ fIncludedByAction.setChecked(isHeader);
+ fIncludesToAction.setChecked(!isHeader);
+ fIncludedByAction.setEnabled(false);
+ updateSorter();
+ } else {
+ fIncludedByAction.setEnabled(true);
+ }
+ fTreeViewer.setInput(input);
+ fPagebook.showPage(fViewerPage);
+ updateHistory(input);
+
+ updateActionEnablement();
+ updateDescription();
+ final Display display = Display.getCurrent();
+ Job job = new Job(IBMessages.IBViewPart_jobCheckInput) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- final ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(projects,
+ final ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
+ IIndex index = CCorePlugin.getIndexManager().getIndex(projects,
IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
index.acquireReadLock();
try {
if (!IndexUI.isIndexed(index, input)) {
// Bug 306879: Try to find an alternative translation unit for the file by the location.
- final ITranslationUnit alt= CoreModelUtil.findTranslationUnitForLocation(input.getLocation(), input.getCProject());
+ final ITranslationUnit alt = CoreModelUtil
+ .findTranslationUnitForLocation(input.getLocation(), input.getCProject());
if (alt != null && IndexUI.isIndexed(index, alt)) {
display.asyncExec(new Runnable() {
@Override
@@ -271,11 +272,11 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return Status.CANCEL_STATUS;
- }
+ }
}
- };
- job.setSystem(true);
- job.schedule();
+ };
+ job.setSystem(true);
+ job.schedule();
}
private void updateActionEnablement() {
@@ -287,15 +288,15 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
@Override
public void createPartControl(Composite parent) {
- fSetInputJob= new IBSetInputJob(this, Display.getCurrent());
-
- fPagebook = new PageBook(parent, SWT.NULL);
- createInfoPage();
- createViewerPage();
-
- initDragAndDrop();
- createActions();
- createContextMenu();
+ fSetInputJob = new IBSetInputJob(this, Display.getCurrent());
+
+ fPagebook = new PageBook(parent, SWT.NULL);
+ createInfoPage();
+ createViewerPage();
+
+ initDragAndDrop();
+ createActions();
+ createContextMenu();
bindingService = PlatformUI.getWorkbench().getService(IBindingService.class);
if (bindingService != null) {
@@ -303,9 +304,11 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
@Override
public void bindingManagerChanged(BindingManagerEvent event) {
if (event.isActiveBindingsChanged()) {
- String keyBinding = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_DELETE);
+ String keyBinding = bindingService
+ .getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_DELETE);
if (keyBinding != null) {
- fRemoveFromViewAction.setText(IBMessages.IBViewPart_RemoveFromView_label + '\t'+ keyBinding);
+ fRemoveFromViewAction
+ .setText(IBMessages.IBViewPart_RemoveFromView_label + '\t' + keyBinding);
}
}
}
@@ -313,21 +316,21 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
bindingService.addBindingManagerListener(bindingManagerListener);
}
- getSite().setSelectionProvider(fTreeViewer);
- setMessage(IBMessages.IBViewPart_instructionMessage);
-
- initializeActionStates();
- restoreInput();
- fMemento= null;
+ getSite().setSelectionProvider(fTreeViewer);
+ setMessage(IBMessages.IBViewPart_instructionMessage);
- IContextService ctxService = getSite().getService(IContextService.class);
- if (ctxService != null) {
- fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
- }
+ initializeActionStates();
+ restoreInput();
+ fMemento = null;
+
+ IContextService ctxService = getSite().getService(IContextService.class);
+ if (ctxService != null) {
+ fContextActivation = ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+ }
PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.INCLUDE_BROWSER_VIEW);
}
-
+
@Override
public void dispose() {
putDialogSettings();
@@ -347,480 +350,480 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
fWorkingSetFilterUI.dispose();
}
}
-
- private void initializeActionStates() {
- IDialogSettings ds= getDialogSettings();
-
- boolean includedBy= !FALSE.equals(ds.get(KEY_INCLUDED_BY));
- fIncludedByAction.setChecked(includedBy);
- fIncludesToAction.setChecked(!includedBy);
- fContentProvider.setComputeIncludedBy(includedBy);
-
- fFilterInactiveAction.setChecked(TRUE.equals(ds.get(KEY_FILTER_INACTIVE)));
- fFilterInactiveAction.run();
- fFilterSystemAction.setChecked(TRUE.equals(ds.get(KEY_FILTER_SYSTEM)));
- fFilterSystemAction.run();
- fShowFolderInLabelsAction.setChecked(TRUE.equals((ds.get(KEY_SHOW_FOLDERS))));
- fShowFolderInLabelsAction.run();
- updateSorter();
- }
-
- private void restoreInput() {
- if (fMemento != null) {
- String pathStr= fMemento.getString(KEY_INPUT_PATH);
- if (pathStr != null) {
- IPath path= Path.fromPortableString(pathStr);
- if (path.segmentCount() > 1) {
- String name= path.segment(0);
- ICProject project= CoreModel.getDefault().getCModel().getCProject(name);
- if (project != null) {
- ICElement celement;
- try {
- celement = project.findElement(path);
- if (celement instanceof ITranslationUnit) {
- setInput((ITranslationUnit) celement);
- }
- } catch (CModelException e) {
- // ignore
- }
- }
- }
- }
- }
- }
-
- @Override
+
+ private void initializeActionStates() {
+ IDialogSettings ds = getDialogSettings();
+
+ boolean includedBy = !FALSE.equals(ds.get(KEY_INCLUDED_BY));
+ fIncludedByAction.setChecked(includedBy);
+ fIncludesToAction.setChecked(!includedBy);
+ fContentProvider.setComputeIncludedBy(includedBy);
+
+ fFilterInactiveAction.setChecked(TRUE.equals(ds.get(KEY_FILTER_INACTIVE)));
+ fFilterInactiveAction.run();
+ fFilterSystemAction.setChecked(TRUE.equals(ds.get(KEY_FILTER_SYSTEM)));
+ fFilterSystemAction.run();
+ fShowFolderInLabelsAction.setChecked(TRUE.equals((ds.get(KEY_SHOW_FOLDERS))));
+ fShowFolderInLabelsAction.run();
+ updateSorter();
+ }
+
+ private void restoreInput() {
+ if (fMemento != null) {
+ String pathStr = fMemento.getString(KEY_INPUT_PATH);
+ if (pathStr != null) {
+ IPath path = Path.fromPortableString(pathStr);
+ if (path.segmentCount() > 1) {
+ String name = path.segment(0);
+ ICProject project = CoreModel.getDefault().getCModel().getCProject(name);
+ if (project != null) {
+ ICElement celement;
+ try {
+ celement = project.findElement(path);
+ if (celement instanceof ITranslationUnit) {
+ setInput((ITranslationUnit) celement);
+ }
+ } catch (CModelException e) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
- fMemento= memento;
- super.init(site, memento);
- }
+ fMemento = memento;
+ super.init(site, memento);
+ }
- @Override
+ @Override
public void saveState(IMemento memento) {
- putDialogSettings();
- if (memento != null) {
- if (fWorkingSetFilter != null) {
- fWorkingSetFilter.getUI().saveState(memento, KEY_WORKING_SET_FILTER);
- }
- ITranslationUnit input= getInput();
- if (input != null) {
- IPath path= input.getPath();
- if (path != null) {
- memento.putString(KEY_INPUT_PATH, path.toPortableString());
- }
- }
- }
- super.saveState(memento);
- }
-
- private void putDialogSettings() {
- IDialogSettings ds= getDialogSettings();
- ds.put(KEY_FILTER_INACTIVE, String.valueOf(fFilterInactiveAction.isChecked()));
- ds.put(KEY_FILTER_SYSTEM, String.valueOf(fFilterSystemAction.isChecked()));
- ds.put(KEY_INCLUDED_BY, String.valueOf(fIncludedByAction.isChecked()));
- ds.put(KEY_SHOW_FOLDERS, String.valueOf(fShowFolderInLabelsAction.isChecked()));
- }
+ putDialogSettings();
+ if (memento != null) {
+ if (fWorkingSetFilter != null) {
+ fWorkingSetFilter.getUI().saveState(memento, KEY_WORKING_SET_FILTER);
+ }
+ ITranslationUnit input = getInput();
+ if (input != null) {
+ IPath path = input.getPath();
+ if (path != null) {
+ memento.putString(KEY_INPUT_PATH, path.toPortableString());
+ }
+ }
+ }
+ super.saveState(memento);
+ }
+
+ private void putDialogSettings() {
+ IDialogSettings ds = getDialogSettings();
+ ds.put(KEY_FILTER_INACTIVE, String.valueOf(fFilterInactiveAction.isChecked()));
+ ds.put(KEY_FILTER_SYSTEM, String.valueOf(fFilterSystemAction.isChecked()));
+ ds.put(KEY_INCLUDED_BY, String.valueOf(fIncludedByAction.isChecked()));
+ ds.put(KEY_SHOW_FOLDERS, String.valueOf(fShowFolderInLabelsAction.isChecked()));
+ }
private IDialogSettings getDialogSettings() {
- IDialogSettings ds= CUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings ds = CUIPlugin.getDefault().getDialogSettings();
final String name = IBViewPart.class.getName();
- IDialogSettings result= ds.getSection(name);
+ IDialogSettings result = ds.getSection(name);
if (result == null) {
- result= ds.addNewSection(name);
+ result = ds.addNewSection(name);
}
return result;
}
private void createContextMenu() {
- MenuManager manager = new MenuManager();
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
- @Override
+ MenuManager manager = new MenuManager();
+ manager.setRemoveAllWhenShown(true);
+ manager.addMenuListener(new IMenuListener() {
+ @Override
public void menuAboutToShow(IMenuManager m) {
- onContextMenuAboutToShow(m);
- }
- });
- Menu menu = manager.createContextMenu(fTreeViewer.getControl());
- fTreeViewer.getControl().setMenu(menu);
- IWorkbenchPartSite site = getSite();
- site.registerContextMenu(CUIPlugin.ID_INCLUDE_BROWSER, manager, fTreeViewer);
- }
-
- private void createViewerPage() {
- Display display= getSite().getShell().getDisplay();
- fViewerPage = new Composite(fPagebook, SWT.NULL);
- fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
- fViewerPage.setSize(100, 100);
- fViewerPage.setLayout(new FillLayout());
-
- fContentProvider= new IBContentProvider(display);
- fLabelProvider= new IBLabelProvider(display, fContentProvider);
- fTreeViewer= new ExtendedTreeViewer(fViewerPage);
- fTreeViewer.setUseHashlookup(true);
- fTreeViewer.setContentProvider(fContentProvider);
- fTreeViewer.setLabelProvider(fLabelProvider);
- fTreeViewer.setAutoExpandLevel(2);
- fTreeViewer.addOpenListener(new IOpenListener() {
- @Override
+ onContextMenuAboutToShow(m);
+ }
+ });
+ Menu menu = manager.createContextMenu(fTreeViewer.getControl());
+ fTreeViewer.getControl().setMenu(menu);
+ IWorkbenchPartSite site = getSite();
+ site.registerContextMenu(CUIPlugin.ID_INCLUDE_BROWSER, manager, fTreeViewer);
+ }
+
+ private void createViewerPage() {
+ Display display = getSite().getShell().getDisplay();
+ fViewerPage = new Composite(fPagebook, SWT.NULL);
+ fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fViewerPage.setSize(100, 100);
+ fViewerPage.setLayout(new FillLayout());
+
+ fContentProvider = new IBContentProvider(display);
+ fLabelProvider = new IBLabelProvider(display, fContentProvider);
+ fTreeViewer = new ExtendedTreeViewer(fViewerPage);
+ fTreeViewer.setUseHashlookup(true);
+ fTreeViewer.setContentProvider(fContentProvider);
+ fTreeViewer.setLabelProvider(fLabelProvider);
+ fTreeViewer.setAutoExpandLevel(2);
+ fTreeViewer.addOpenListener(new IOpenListener() {
+ @Override
public void open(OpenEvent event) {
- onShowInclude(event.getSelection());
- }
- });
- }
-
- private void createInfoPage() {
- fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
- }
-
- private void initDragAndDrop() {
- IBDropTargetListener dropListener= new IBDropTargetListener(this);
- Transfer[] dropTransfers= new Transfer[] {
- LocalSelectionTransfer.getTransfer(),
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance()};
- DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
- dropTarget.setTransfer(dropTransfers);
- dropTarget.addDropListener(dropListener);
-
- Transfer[] dragTransfers= new Transfer[] {
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance()};
- IBDragSourceListener dragListener= new IBDragSourceListener(fTreeViewer);
- dragListener.setDependentDropTargetListener(dropListener);
- fTreeViewer.addDragSupport(DND.DROP_COPY, dragTransfers, dragListener);
- }
-
- private void createActions() {
- fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
- @Override
+ onShowInclude(event.getSelection());
+ }
+ });
+ }
+
+ private void createInfoPage() {
+ fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
+ }
+
+ private void initDragAndDrop() {
+ IBDropTargetListener dropListener = new IBDropTargetListener(this);
+ Transfer[] dropTransfers = new Transfer[] { LocalSelectionTransfer.getTransfer(),
+ ResourceTransfer.getInstance(), FileTransfer.getInstance() };
+ DropTarget dropTarget = new DropTarget(fPagebook,
+ DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
+ dropTarget.setTransfer(dropTransfers);
+ dropTarget.addDropListener(dropListener);
+
+ Transfer[] dragTransfers = new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance() };
+ IBDragSourceListener dragListener = new IBDragSourceListener(fTreeViewer);
+ dragListener.setDependentDropTargetListener(dropListener);
+ fTreeViewer.addDragSupport(DND.DROP_COPY, dragTransfers, dragListener);
+ }
+
+ private void createActions() {
+ fWorkingSetFilterUI = new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
+ @Override
protected void onWorkingSetChange() {
- updateWorkingSetFilter(this);
- }
- @Override
+ updateWorkingSetFilter(this);
+ }
+
+ @Override
protected void onWorkingSetNameChange() {
- updateDescription();
- }
- };
-
- fIncludedByAction=
- new Action(IBMessages.IBViewPart_showIncludedBy_label, IAction.AS_RADIO_BUTTON) {
- @Override
- public void run() {
- if (isChecked()) {
- onSetDirection(true);
- }
- }
- };
- fIncludedByAction.setToolTipText(IBMessages.IBViewPart_showIncludedBy_tooltip);
- CPluginImages.setImageDescriptors(fIncludedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);
-
- fIncludesToAction=
- new Action(IBMessages.IBViewPart_showIncludesTo_label, IAction.AS_RADIO_BUTTON) {
- @Override
- public void run() {
- if (isChecked()) {
- onSetDirection(false);
- }
- }
- };
- fIncludesToAction.setToolTipText(IBMessages.IBViewPart_showIncludesTo_tooltip);
- CPluginImages.setImageDescriptors(fIncludesToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
-
- fInactiveFilter= new ViewerFilter() {
- @Override
+ updateDescription();
+ }
+ };
+
+ fIncludedByAction = new Action(IBMessages.IBViewPart_showIncludedBy_label, IAction.AS_RADIO_BUTTON) {
+ @Override
+ public void run() {
+ if (isChecked()) {
+ onSetDirection(true);
+ }
+ }
+ };
+ fIncludedByAction.setToolTipText(IBMessages.IBViewPart_showIncludedBy_tooltip);
+ CPluginImages.setImageDescriptors(fIncludedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);
+
+ fIncludesToAction = new Action(IBMessages.IBViewPart_showIncludesTo_label, IAction.AS_RADIO_BUTTON) {
+ @Override
+ public void run() {
+ if (isChecked()) {
+ onSetDirection(false);
+ }
+ }
+ };
+ fIncludesToAction.setToolTipText(IBMessages.IBViewPart_showIncludesTo_tooltip);
+ CPluginImages.setImageDescriptors(fIncludesToAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
+
+ fInactiveFilter = new ViewerFilter() {
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IBNode) {
- IBNode node= (IBNode) element;
- return node.isActiveCode();
- }
- return true;
- }
- };
- fFilterInactiveAction= new Action(IBMessages.IBViewPart_hideInactive_label, IAction.AS_CHECK_BOX) {
- @Override
+ if (element instanceof IBNode) {
+ IBNode node = (IBNode) element;
+ return node.isActiveCode();
+ }
+ return true;
+ }
+ };
+ fFilterInactiveAction = new Action(IBMessages.IBViewPart_hideInactive_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- if (isChecked()) {
- fTreeViewer.addFilter(fInactiveFilter);
- } else {
- fTreeViewer.removeFilter(fInactiveFilter);
- }
- }
- };
- fFilterInactiveAction.setToolTipText(IBMessages.IBViewPart_hideInactive_tooltip);
- CPluginImages.setImageDescriptors(fFilterInactiveAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE);
-
- fSystemFilter= new ViewerFilter() {
- @Override
+ if (isChecked()) {
+ fTreeViewer.addFilter(fInactiveFilter);
+ } else {
+ fTreeViewer.removeFilter(fInactiveFilter);
+ }
+ }
+ };
+ fFilterInactiveAction.setToolTipText(IBMessages.IBViewPart_hideInactive_tooltip);
+ CPluginImages.setImageDescriptors(fFilterInactiveAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_HIDE_INACTIVE);
+
+ fSystemFilter = new ViewerFilter() {
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IBNode) {
- IBNode node= (IBNode) element;
- return !node.isSystemInclude();
- }
- return true;
- }
- };
- fFilterSystemAction= new Action(IBMessages.IBViewPart_hideSystem_label, IAction.AS_CHECK_BOX) {
- @Override
+ if (element instanceof IBNode) {
+ IBNode node = (IBNode) element;
+ return !node.isSystemInclude();
+ }
+ return true;
+ }
+ };
+ fFilterSystemAction = new Action(IBMessages.IBViewPart_hideSystem_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- if (isChecked()) {
- fTreeViewer.addFilter(fSystemFilter);
- } else {
- fTreeViewer.removeFilter(fSystemFilter);
- }
- }
- };
- fFilterSystemAction.setToolTipText(IBMessages.IBViewPart_hideSystem_tooltip);
- CPluginImages.setImageDescriptors(fFilterSystemAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_SYSTEM);
-
- fSorterAlphaNumeric= new ViewerComparator();
- fSorterReferencePosition= new ViewerComparator() {
- @Override
+ if (isChecked()) {
+ fTreeViewer.addFilter(fSystemFilter);
+ } else {
+ fTreeViewer.removeFilter(fSystemFilter);
+ }
+ }
+ };
+ fFilterSystemAction.setToolTipText(IBMessages.IBViewPart_hideSystem_tooltip);
+ CPluginImages.setImageDescriptors(fFilterSystemAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_HIDE_SYSTEM);
+
+ fSorterAlphaNumeric = new ViewerComparator();
+ fSorterReferencePosition = new ViewerComparator() {
+ @Override
public int category(Object element) {
- if (element instanceof IBNode) {
- return 0;
- }
- return 1;
- }
- @Override
+ if (element instanceof IBNode) {
+ return 0;
+ }
+ return 1;
+ }
+
+ @Override
public int compare(Viewer viewer, Object e1, Object e2) {
- if (!(e1 instanceof IBNode)) {
- if (!(e2 instanceof IBNode)) {
- return 0;
- }
- return -1;
- }
- if (!(e2 instanceof IBNode)) {
- return 1;
- }
- IBNode n1= (IBNode) e1;
- IBNode n2= (IBNode) e2;
- return n1.getDirectiveCharacterOffset() - n2.getDirectiveCharacterOffset();
- }
- };
-
- fShowFolderInLabelsAction= new Action(IBMessages.IBViewPart_showFolders_label, IAction.AS_CHECK_BOX) {
- @Override
+ if (!(e1 instanceof IBNode)) {
+ if (!(e2 instanceof IBNode)) {
+ return 0;
+ }
+ return -1;
+ }
+ if (!(e2 instanceof IBNode)) {
+ return 1;
+ }
+ IBNode n1 = (IBNode) e1;
+ IBNode n2 = (IBNode) e2;
+ return n1.getDirectiveCharacterOffset() - n2.getDirectiveCharacterOffset();
+ }
+ };
+
+ fShowFolderInLabelsAction = new Action(IBMessages.IBViewPart_showFolders_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- onShowFolderInLabels(isChecked());
- }
- };
- fShowFolderInLabelsAction.setToolTipText(IBMessages.IBViewPart_showFolders_tooltip);
- fNextAction = new Action(IBMessages.IBViewPart_nextMatch_label) {
- @Override
+ onShowFolderInLabels(isChecked());
+ }
+ };
+ fShowFolderInLabelsAction.setToolTipText(IBMessages.IBViewPart_showFolders_tooltip);
+ fNextAction = new Action(IBMessages.IBViewPart_nextMatch_label) {
+ @Override
public void run() {
- onNextOrPrevious(true);
- }
- };
- fNextAction.setToolTipText(IBMessages.IBViewPart_nextMatch_tooltip);
- CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
-
- fPreviousAction = new Action(IBMessages.IBViewPart_previousMatch_label) {
- @Override
+ onNextOrPrevious(true);
+ }
+ };
+ fNextAction.setToolTipText(IBMessages.IBViewPart_nextMatch_tooltip);
+ CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
+
+ fPreviousAction = new Action(IBMessages.IBViewPart_previousMatch_label) {
+ @Override
public void run() {
- onNextOrPrevious(false);
- }
- };
- fPreviousAction.setToolTipText(IBMessages.IBViewPart_previousMatch_tooltip);
- CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
-
- fRefreshAction = new Action(IBMessages.IBViewPart_refresh_label) {
- @Override
+ onNextOrPrevious(false);
+ }
+ };
+ fPreviousAction.setToolTipText(IBMessages.IBViewPart_previousMatch_tooltip);
+ CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
+
+ fRefreshAction = new Action(IBMessages.IBViewPart_refresh_label) {
+ @Override
public void run() {
- onRefresh();
- }
- };
- fRefreshAction.setToolTipText(IBMessages.IBViewPart_refresh_tooltip);
- CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
-
- fHistoryAction= new IBHistoryDropDownAction(this);
- ExpandAllAction expandAll = new ExpandAllAction(getTreeViewer());
- CollapseAllAction collapseAll = new CollapseAllAction(getTreeViewer());
-
- fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer);
- fRemoveFromViewAction= new IBRemoveFromView(this);
-
- // setup action bar
- // global action hooks
- IActionBars actionBars = getViewSite().getActionBars();
- actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
- actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
- actionBars.updateActionBars();
-
- TextActionHandler textActionHandler = new TextActionHandler(actionBars);
- textActionHandler.setDeleteAction(fRemoveFromViewAction);
-
- // local toolbar
- IToolBarManager tm = actionBars.getToolBarManager();
- tm.add(fNextAction);
- tm.add(fPreviousAction);
- tm.add(new Separator());
- tm.add(expandAll);
- tm.add(collapseAll);
- tm.add(new Separator());
- tm.add(fFilterSystemAction);
- tm.add(fFilterInactiveAction);
- tm.add(new Separator());
- tm.add(fIncludedByAction);
- tm.add(fIncludesToAction);
- tm.add(fHistoryAction);
- tm.add(fRefreshAction);
-
- // local menu
- IMenuManager mm = actionBars.getMenuManager();
-
- fWorkingSetFilterUI.fillActionBars(actionBars);
- mm.add(fIncludedByAction);
- mm.add(fIncludesToAction);
- mm.add(new Separator());
- mm.add(fShowFolderInLabelsAction);
- mm.add(new Separator());
- mm.add(fFilterSystemAction);
- mm.add(fFilterInactiveAction);
- }
-
- private IBNode getNextNode(boolean forward) {
- TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), IBNode.class);
- TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
- if (selectedItem == null) {
- return null;
- }
-
- if (selectedItem.getData().equals(fLastNavigationNode)) {
- selectedItem= navigator.getNextSibbling(selectedItem, forward);
- }
-
- return selectedItem == null ? null : (IBNode) selectedItem.getData();
- }
-
- protected void onNextOrPrevious(boolean forward) {
- IBNode nextItem= getNextNode(forward);
- if (nextItem != null) {
- StructuredSelection sel= new StructuredSelection(nextItem);
- fTreeViewer.setSelection(sel);
- onShowInclude(sel);
- }
- }
-
- protected void onRefresh() {
- fContentProvider.recompute();
- }
-
- protected void onShowFolderInLabels(boolean show) {
- fLabelProvider.setShowFolders(show);
- fTreeViewer.refresh();
- }
-
- private void updateHistory(ITranslationUnit input) {
- if (input != null) {
- fHistoryEntries.remove(input);
- fHistoryEntries.add(0, input);
- if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
- fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
- }
- }
- }
-
- private void updateSorter() {
- if (fIncludedByAction.isChecked()) {
- fTreeViewer.setComparator(fSorterAlphaNumeric);
- } else {
- fTreeViewer.setComparator(fSorterReferencePosition);
- }
- }
-
- private void updateDescription() {
- String message= ""; //$NON-NLS-1$
- if (!fShowsMessage) {
- ITranslationUnit tu= getInput();
- if (tu != null) {
- IPath path= tu.getPath();
- if (path != null) {
- String format, file, scope;
-
- file= path.lastSegment() + "(" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$//$NON-NLS-2$
- if (fWorkingSetFilter == null) {
- scope= IBMessages.IBViewPart_workspaceScope;
- } else {
- scope= fWorkingSetFilter.getLabel();
- }
-
- if (fIncludedByAction.isChecked()) {
- format= IBMessages.IBViewPart_IncludedByContentDescription;
- } else {
- format= IBMessages.IBViewPart_IncludesToContentDescription;
- }
- message= Messages.format(format, file, scope);
- }
- }
- }
- setContentDescription(message);
- }
-
- private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
- if (filterUI.getWorkingSet() == null) {
- if (fWorkingSetFilter != null) {
- fTreeViewer.removeFilter(fWorkingSetFilter);
- fWorkingSetFilter= null;
- }
- } else {
- if (fWorkingSetFilter != null) {
- fTreeViewer.refresh();
- } else {
- fWorkingSetFilter= new IBWorkingSetFilter(filterUI);
- fTreeViewer.addFilter(fWorkingSetFilter);
- }
- }
- }
-
- public void onSetDirection(boolean includedBy) {
- if (includedBy != fContentProvider.getComputeIncludedBy()) {
- Object input= fTreeViewer.getInput();
- fTreeViewer.setInput(null);
- fContentProvider.setComputeIncludedBy(includedBy);
- updateSorter();
- fTreeViewer.setInput(input);
- updateDescription();
- }
- }
-
- protected void onContextMenuAboutToShow(IMenuManager m) {
- final IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
- final IBNode node= IBConversions.selectionToNode(selection);
-
- if (node != null) {
- final IWorkbenchPage page = getSite().getPage();
-
- // open include
- if (node.getParent() != null && node.getDirectiveFile() != null) {
- m.add(new Action(IBMessages.IBViewPart_showInclude_label) {
- @Override
+ onRefresh();
+ }
+ };
+ fRefreshAction.setToolTipText(IBMessages.IBViewPart_refresh_tooltip);
+ CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
+
+ fHistoryAction = new IBHistoryDropDownAction(this);
+ ExpandAllAction expandAll = new ExpandAllAction(getTreeViewer());
+ CollapseAllAction collapseAll = new CollapseAllAction(getTreeViewer());
+
+ fCopyAction = new CopyCallHierarchyAction(this, fTreeViewer);
+ fRemoveFromViewAction = new IBRemoveFromView(this);
+
+ // setup action bar
+ // global action hooks
+ IActionBars actionBars = getViewSite().getActionBars();
+ actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
+ actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
+ actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
+ actionBars.updateActionBars();
+
+ TextActionHandler textActionHandler = new TextActionHandler(actionBars);
+ textActionHandler.setDeleteAction(fRemoveFromViewAction);
+
+ // local toolbar
+ IToolBarManager tm = actionBars.getToolBarManager();
+ tm.add(fNextAction);
+ tm.add(fPreviousAction);
+ tm.add(new Separator());
+ tm.add(expandAll);
+ tm.add(collapseAll);
+ tm.add(new Separator());
+ tm.add(fFilterSystemAction);
+ tm.add(fFilterInactiveAction);
+ tm.add(new Separator());
+ tm.add(fIncludedByAction);
+ tm.add(fIncludesToAction);
+ tm.add(fHistoryAction);
+ tm.add(fRefreshAction);
+
+ // local menu
+ IMenuManager mm = actionBars.getMenuManager();
+
+ fWorkingSetFilterUI.fillActionBars(actionBars);
+ mm.add(fIncludedByAction);
+ mm.add(fIncludesToAction);
+ mm.add(new Separator());
+ mm.add(fShowFolderInLabelsAction);
+ mm.add(new Separator());
+ mm.add(fFilterSystemAction);
+ mm.add(fFilterInactiveAction);
+ }
+
+ private IBNode getNextNode(boolean forward) {
+ TreeNavigator navigator = new TreeNavigator(fTreeViewer.getTree(), IBNode.class);
+ TreeItem selectedItem = navigator.getSelectedItemOrFirstOnLevel(1, forward);
+ if (selectedItem == null) {
+ return null;
+ }
+
+ if (selectedItem.getData().equals(fLastNavigationNode)) {
+ selectedItem = navigator.getNextSibbling(selectedItem, forward);
+ }
+
+ return selectedItem == null ? null : (IBNode) selectedItem.getData();
+ }
+
+ protected void onNextOrPrevious(boolean forward) {
+ IBNode nextItem = getNextNode(forward);
+ if (nextItem != null) {
+ StructuredSelection sel = new StructuredSelection(nextItem);
+ fTreeViewer.setSelection(sel);
+ onShowInclude(sel);
+ }
+ }
+
+ protected void onRefresh() {
+ fContentProvider.recompute();
+ }
+
+ protected void onShowFolderInLabels(boolean show) {
+ fLabelProvider.setShowFolders(show);
+ fTreeViewer.refresh();
+ }
+
+ private void updateHistory(ITranslationUnit input) {
+ if (input != null) {
+ fHistoryEntries.remove(input);
+ fHistoryEntries.add(0, input);
+ if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
+ fHistoryEntries.remove(MAX_HISTORY_SIZE - 1);
+ }
+ }
+ }
+
+ private void updateSorter() {
+ if (fIncludedByAction.isChecked()) {
+ fTreeViewer.setComparator(fSorterAlphaNumeric);
+ } else {
+ fTreeViewer.setComparator(fSorterReferencePosition);
+ }
+ }
+
+ private void updateDescription() {
+ String message = ""; //$NON-NLS-1$
+ if (!fShowsMessage) {
+ ITranslationUnit tu = getInput();
+ if (tu != null) {
+ IPath path = tu.getPath();
+ if (path != null) {
+ String format, file, scope;
+
+ file = path.lastSegment() + "(" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$//$NON-NLS-2$
+ if (fWorkingSetFilter == null) {
+ scope = IBMessages.IBViewPart_workspaceScope;
+ } else {
+ scope = fWorkingSetFilter.getLabel();
+ }
+
+ if (fIncludedByAction.isChecked()) {
+ format = IBMessages.IBViewPart_IncludedByContentDescription;
+ } else {
+ format = IBMessages.IBViewPart_IncludesToContentDescription;
+ }
+ message = Messages.format(format, file, scope);
+ }
+ }
+ }
+ setContentDescription(message);
+ }
+
+ private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
+ if (filterUI.getWorkingSet() == null) {
+ if (fWorkingSetFilter != null) {
+ fTreeViewer.removeFilter(fWorkingSetFilter);
+ fWorkingSetFilter = null;
+ }
+ } else {
+ if (fWorkingSetFilter != null) {
+ fTreeViewer.refresh();
+ } else {
+ fWorkingSetFilter = new IBWorkingSetFilter(filterUI);
+ fTreeViewer.addFilter(fWorkingSetFilter);
+ }
+ }
+ }
+
+ public void onSetDirection(boolean includedBy) {
+ if (includedBy != fContentProvider.getComputeIncludedBy()) {
+ Object input = fTreeViewer.getInput();
+ fTreeViewer.setInput(null);
+ fContentProvider.setComputeIncludedBy(includedBy);
+ updateSorter();
+ fTreeViewer.setInput(input);
+ updateDescription();
+ }
+ }
+
+ protected void onContextMenuAboutToShow(IMenuManager m) {
+ final IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
+ final IBNode node = IBConversions.selectionToNode(selection);
+
+ if (node != null) {
+ final IWorkbenchPage page = getSite().getPage();
+
+ // open include
+ if (node.getParent() != null && node.getDirectiveFile() != null) {
+ m.add(new Action(IBMessages.IBViewPart_showInclude_label) {
+ @Override
public void run() {
- onShowInclude(selection);
- }
- });
- }
-
- final ITranslationUnit tu= node.getRepresentedTranslationUnit();
- if (tu != null) {
- // open
- OpenCElementAction ofa= new OpenCElementAction(page);
- ofa.selectionChanged(selection);
- m.add(ofa);
-
- // show in
- IMenuManager submenu= new MenuManager(IBMessages.IBViewPart_ShowInMenu_label);
- submenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getSite().getWorkbenchWindow()));
- m.add(submenu);
- if (node.getParent() != null) {
- m.add(new Action(Messages.format(IBMessages.IBViewPart_FocusOn_label, tu.getPath().lastSegment())) {
- @Override
+ onShowInclude(selection);
+ }
+ });
+ }
+
+ final ITranslationUnit tu = node.getRepresentedTranslationUnit();
+ if (tu != null) {
+ // open
+ OpenCElementAction ofa = new OpenCElementAction(page);
+ ofa.selectionChanged(selection);
+ m.add(ofa);
+
+ // show in
+ IMenuManager submenu = new MenuManager(IBMessages.IBViewPart_ShowInMenu_label);
+ submenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getSite().getWorkbenchWindow()));
+ m.add(submenu);
+ if (node.getParent() != null) {
+ m.add(new Action(Messages.format(IBMessages.IBViewPart_FocusOn_label, tu.getPath().lastSegment())) {
+ @Override
public void run() {
- setInput(tu);
- }
- });
- }
- }
+ setInput(tu);
+ }
+ });
+ }
+ }
m.add(new Separator(IContextMenuConstants.GROUP_EDIT));
if (fCopyAction.canActionBeAdded()) {
@@ -828,76 +831,73 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
}
m.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fRemoveFromViewAction);
- }
- m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
- }
-
- protected void onShowInclude(ISelection selection) {
- IBNode node= IBConversions.selectionToNode(selection);
- if (node != null) {
- fLastNavigationNode= node;
-
- IWorkbenchPage page= getSite().getPage();
- IBFile ibf= node.getDirectiveFile();
- if (ibf != null) {
- IRegion region= new Region(node.getDirectiveCharacterOffset(), node.getDirectiveLength());
- long timestamp= node.getTimestamp();
-
- IFile f= ibf.getResource();
- if (f != null) {
- EditorOpener.open(page, f, region, timestamp);
- } else {
- IIndexFileLocation ifl = ibf.getLocation();
- if (ifl != null) {
- IPath location= IndexLocationFactory.getAbsolutePath(ifl);
- if (location != null) {
- EditorOpener.openExternalFile(page, location, region, timestamp);
- }
- }
- }
- } else {
- ITranslationUnit tu= IBConversions.selectionToTU(selection);
- if (tu != null) {
- IResource r= tu.getResource();
- if (r != null) {
- OpenFileAction ofa= new OpenFileAction(page);
- ofa.selectionChanged((IStructuredSelection) selection);
- ofa.run();
- }
- }
- }
- }
- }
-
- @Override
+ }
+ m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
+ }
+
+ protected void onShowInclude(ISelection selection) {
+ IBNode node = IBConversions.selectionToNode(selection);
+ if (node != null) {
+ fLastNavigationNode = node;
+
+ IWorkbenchPage page = getSite().getPage();
+ IBFile ibf = node.getDirectiveFile();
+ if (ibf != null) {
+ IRegion region = new Region(node.getDirectiveCharacterOffset(), node.getDirectiveLength());
+ long timestamp = node.getTimestamp();
+
+ IFile f = ibf.getResource();
+ if (f != null) {
+ EditorOpener.open(page, f, region, timestamp);
+ } else {
+ IIndexFileLocation ifl = ibf.getLocation();
+ if (ifl != null) {
+ IPath location = IndexLocationFactory.getAbsolutePath(ifl);
+ if (location != null) {
+ EditorOpener.openExternalFile(page, location, region, timestamp);
+ }
+ }
+ }
+ } else {
+ ITranslationUnit tu = IBConversions.selectionToTU(selection);
+ if (tu != null) {
+ IResource r = tu.getResource();
+ if (r != null) {
+ OpenFileAction ofa = new OpenFileAction(page);
+ ofa.selectionChanged((IStructuredSelection) selection);
+ ofa.run();
+ }
+ }
+ }
+ }
+ }
+
+ @Override
public ShowInContext getShowInContext() {
- return new ShowInContext(null, IBConversions.nodeSelectionToRepresentedTUSelection(fTreeViewer.getSelection()));
- }
+ return new ShowInContext(null, IBConversions.nodeSelectionToRepresentedTUSelection(fTreeViewer.getSelection()));
+ }
- @Override
+ @Override
public boolean show(ShowInContext context) {
- ITranslationUnit tu= IBConversions.selectionToTU(context.getSelection());
- if (tu == null) {
- tu= IBConversions.objectToTU(context.getInput());
- if (tu == null) {
- setMessage(IBMessages.IBViewPart_falseInputMessage);
- return false;
- }
- }
-
- setInput(tu);
- return true;
- }
-
- @Override
+ ITranslationUnit tu = IBConversions.selectionToTU(context.getSelection());
+ if (tu == null) {
+ tu = IBConversions.objectToTU(context.getInput());
+ if (tu == null) {
+ setMessage(IBMessages.IBViewPart_falseInputMessage);
+ return false;
+ }
+ }
+
+ setInput(tu);
+ return true;
+ }
+
+ @Override
public String[] getShowInTargetIds() {
- return new String[] {
- ProjectExplorer.VIEW_ID,
- IPageLayout.ID_PROJECT_EXPLORER
- };
- }
+ return new String[] { ProjectExplorer.VIEW_ID, IPageLayout.ID_PROJECT_EXPLORER };
+ }
- // access for tests
+ // access for tests
public TreeViewer getTreeViewer() {
return fTreeViewer;
}
@@ -918,10 +918,10 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
}
public ITranslationUnit getInput() {
- Object input= fTreeViewer.getInput();
- if (input instanceof ITranslationUnit) {
- return (ITranslationUnit) input;
- }
- return null;
+ Object input = fTreeViewer.getInput();
+ if (input instanceof ITranslationUnit) {
+ return (ITranslationUnit) input;
+ }
+ return null;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.java
index b340aeca16e..7bcbdb0f35e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
@@ -22,32 +22,32 @@ import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
public class IBWorkingSetFilter extends ViewerFilter {
- private WorkingSetFilterUI fWorkingSetFilter;
-
- public IBWorkingSetFilter(WorkingSetFilterUI wsFilter) {
- fWorkingSetFilter= wsFilter;
- }
-
- @Override
+ private WorkingSetFilterUI fWorkingSetFilter;
+
+ public IBWorkingSetFilter(WorkingSetFilterUI wsFilter) {
+ fWorkingSetFilter = wsFilter;
+ }
+
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (parentElement instanceof IBNode && element instanceof IBNode) {
- IBNode node= (IBNode) element;
- if (!fWorkingSetFilter.isPartOfWorkingSet(node.getRepresentedTranslationUnit())) {
- return false;
- }
- }
- return true;
- }
-
- public WorkingSetFilterUI getUI() {
- return fWorkingSetFilter;
- }
-
- public String getLabel() {
- IWorkingSet ws= fWorkingSetFilter.getWorkingSet();
- if (ws != null) {
- return ws.getLabel();
- }
- return IBMessages.IBViewPart_workspaceScope;
- }
+ if (parentElement instanceof IBNode && element instanceof IBNode) {
+ IBNode node = (IBNode) element;
+ if (!fWorkingSetFilter.isPartOfWorkingSet(node.getRepresentedTranslationUnit())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public WorkingSetFilterUI getUI() {
+ return fWorkingSetFilter;
+ }
+
+ public String getLabel() {
+ IWorkingSet ws = fWorkingSetFilter.getWorkingSet();
+ if (ws != null) {
+ return ws.getLabel();
+ }
+ return IBMessages.IBViewPart_workspaceScope;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java
index 17f9fb589b7..affbe75d1a7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Martin Oberhuber (Wind River) - bug 398195: consider external API in IB
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
@@ -40,48 +40,51 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
public class IncludeBrowserUI {
public static void open(final IWorkbenchWindow window, final ICElement input) {
- try {
- ITranslationUnit tu= convertToTranslationUnit(input);
- if (tu != null) {
- IWorkbenchPage page= window.getActivePage();
- IBViewPart result= (IBViewPart) page.showView(CUIPlugin.ID_INCLUDE_BROWSER);
- result.setInput(tu);
- }
- } catch (CoreException e) {
- ExceptionHandler.handle(e, window.getShell(), IBMessages.OpenIncludeBrowserAction_label, null);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
+ try {
+ ITranslationUnit tu = convertToTranslationUnit(input);
+ if (tu != null) {
+ IWorkbenchPage page = window.getActivePage();
+ IBViewPart result = (IBViewPart) page.showView(CUIPlugin.ID_INCLUDE_BROWSER);
+ result.setInput(tu);
+ }
+ } catch (CoreException e) {
+ ExceptionHandler.handle(e, window.getShell(), IBMessages.OpenIncludeBrowserAction_label, null);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
}
- }
+ }
public static void open(final ITextEditor editor, final ITextSelection sel) {
if (editor != null) {
- ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+ ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager()
+ .getWorkingCopy(editor.getEditorInput());
open(editor.getSite().getWorkbenchWindow(), inputCElement);
}
- }
+ }
- private static ITranslationUnit convertToTranslationUnit(ICElement input) throws CoreException, InterruptedException {
- ITranslationUnit result= null;
- if (input instanceof IInclude) {
- result= findTargetTranslationUnit((IInclude) input);
- }
- if (result == null && input instanceof ISourceReference) {
- result= ((ISourceReference) input).getTranslationUnit();
- }
+ private static ITranslationUnit convertToTranslationUnit(ICElement input)
+ throws CoreException, InterruptedException {
+ ITranslationUnit result = null;
+ if (input instanceof IInclude) {
+ result = findTargetTranslationUnit((IInclude) input);
+ }
+ if (result == null && input instanceof ISourceReference) {
+ result = ((ISourceReference) input).getTranslationUnit();
+ }
return result;
}
- private static ITranslationUnit findTargetTranslationUnit(IInclude input) throws CoreException, InterruptedException {
- ICProject project= input.getCProject();
+ private static ITranslationUnit findTargetTranslationUnit(IInclude input)
+ throws CoreException, InterruptedException {
+ ICProject project = input.getCProject();
if (project != null) {
- IIndex index= CCorePlugin.getIndexManager().getIndex(project,
+ IIndex index = CCorePlugin.getIndexManager().getIndex(project,
IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
index.acquireReadLock();
try {
- IIndexInclude include= IndexUI.elementToInclude(index, input);
+ IIndexInclude include = IndexUI.elementToInclude(index, input);
if (include != null) {
- IIndexFileLocation loc= include.getIncludesLocation();
+ IIndexFileLocation loc = include.getIncludesLocation();
if (loc != null) {
return CoreModelUtil.findTranslationUnitForLocation(loc, project);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAction.java
index 3c10142f144..6d3371fb948 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAction.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
@@ -25,7 +25,6 @@ import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
-
public class OpenIncludeBrowserAction extends SelectionDispatchAction {
private ITextEditor fEditor;
@@ -35,23 +34,24 @@ public class OpenIncludeBrowserAction extends SelectionDispatchAction {
setText(IBMessages.OpenIncludeBrowserAction_label);
setToolTipText(IBMessages.OpenIncludeBrowserAction_tooltip);
}
-
+
public OpenIncludeBrowserAction(ITextEditor editor) {
this(editor.getSite());
- fEditor= editor;
- setEnabled(fEditor != null && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
+ fEditor = editor;
+ setEnabled(fEditor != null
+ && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
}
@Override
public void run(ITextSelection sel) {
IncludeBrowserUI.open(fEditor, sel);
}
-
+
@Override
public void run(IStructuredSelection selection) {
if (!selection.isEmpty()) {
- Object selectedObject= selection.getFirstElement();
- ICElement elem= getAdapter(selectedObject, ICElement.class);
+ Object selectedObject = selection.getFirstElement();
+ ICElement elem = getAdapter(selectedObject, ICElement.class);
if (elem != null) {
IncludeBrowserUI.open(getSite().getWorkbenchWindow(), elem);
}
@@ -61,20 +61,19 @@ public class OpenIncludeBrowserAction extends SelectionDispatchAction {
@Override
public void selectionChanged(ITextSelection sel) {
}
-
+
@Override
public void selectionChanged(IStructuredSelection selection) {
if (selection.isEmpty()) {
setEnabled(false);
return;
}
-
- Object selectedObject= selection.getFirstElement();
- ICElement elem= getAdapter(selectedObject, ICElement.class);
+
+ Object selectedObject = selection.getFirstElement();
+ ICElement elem = getAdapter(selectedObject, ICElement.class);
if (elem != null) {
setEnabled(isValidElement(elem));
- }
- else {
+ } else {
setEnabled(false);
}
}
@@ -92,7 +91,7 @@ public class OpenIncludeBrowserAction extends SelectionDispatchAction {
return (T) object;
}
if (object instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) object;
+ IAdaptable adaptable = (IAdaptable) object;
return adaptable.getAdapter(desiredClass);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java
index ce7f3ba06e5..386a5db602e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java
@@ -50,7 +50,7 @@ public class CountNodeAction extends IndexAction {
ISelection selection = viewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return false;
- Object[] objs = ((IStructuredSelection)selection).toArray();
+ Object[] objs = ((IStructuredSelection) selection).toArray();
for (int i = 0; i < objs.length; ++i)
if (objs[i] instanceof ICProject)
return true;
@@ -73,13 +73,13 @@ public class CountNodeAction extends IndexAction {
if (!(selection instanceof IStructuredSelection))
return;
- Object[] objs = ((IStructuredSelection)selection).toArray();
+ Object[] objs = ((IStructuredSelection) selection).toArray();
for (int i = 0; i < objs.length; ++i) {
if (!(objs[i] instanceof ICProject))
continue;
- ICProject project = (ICProject)objs[i];
- IPDOM ipdom= CCoreInternals.getPDOMManager().getPDOM(project);
+ ICProject project = (ICProject) objs[i];
+ IPDOM ipdom = CCoreInternals.getPDOMManager().getPDOM(project);
if (!(ipdom instanceof PDOM)) {
continue;
}
@@ -110,25 +110,19 @@ public class CountNodeAction extends IndexAction {
});
pdom.accept(new IPDOMVisitor() {
@Override
- public boolean visit(IPDOMNode node)
- throws CoreException {
+ public boolean visit(IPDOMNode node) throws CoreException {
++count[SYMBOLS];
if (node instanceof PDOMBinding) {
PDOMBinding binding = (PDOMBinding) node;
- for (PDOMName name = binding
- .getFirstReference(); name != null; name = name
+ for (PDOMName name = binding.getFirstReference(); name != null; name = name
.getNextInBinding())
++count[REFS];
- for (IPDOMIterator<PDOMName> i = binding.getExternalReferences();
- i.hasNext();
- i.next())
+ for (IPDOMIterator<PDOMName> i = binding.getExternalReferences(); i.hasNext(); i.next())
++count[REFS];
- for (PDOMName name = binding
- .getFirstDeclaration(); name != null; name = name
+ for (PDOMName name = binding.getFirstDeclaration(); name != null; name = name
.getNextInBinding())
++count[DECLS];
- for (PDOMName name = binding
- .getFirstDefinition(); name != null; name = name
+ for (PDOMName name = binding.getFirstDefinition(); name != null; name = name
.getNextInBinding())
++count[DEFS];
}
@@ -150,17 +144,10 @@ public class CountNodeAction extends IndexAction {
return;
}
- MessageDialog.openInformation(null,
- CUIPlugin.getResourceString("IndexView.CountSymbols.title"), //$NON-NLS-1$
+ MessageDialog.openInformation(null, CUIPlugin.getResourceString("IndexView.CountSymbols.title"), //$NON-NLS-1$
CUIPlugin.getFormattedString("IndexView.CountSymbols.message", //$NON-NLS-1$
- new String[] {
- String.valueOf(count[0]),
- String.valueOf(count[1]),
- String.valueOf(count[2]),
- String.valueOf(count[3]),
- String.valueOf(count[4]),
- String.valueOf(count[5])
- }));
+ new String[] { String.valueOf(count[0]), String.valueOf(count[1]), String.valueOf(count[2]),
+ String.valueOf(count[3]), String.valueOf(count[4]), String.valueOf(count[5]) }));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.java
index 9e2581ffbb9..21df2342a9c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.java
@@ -22,7 +22,6 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
-
/**
* @author David Daoust
*
@@ -31,9 +30,9 @@ public class DiscardExternalDefsAction extends IndexAction {
public DiscardExternalDefsAction(TreeViewer viewer, IndexView view) {
super(view, viewer, CUIPlugin.getResourceString("IndexView.ToggleExternals.name"), IAction.AS_CHECK_BOX); //$NON-NLS-1$
setToolTipText(CUIPlugin.getResourceString("IndexView.ToggleExternals.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "public_co.gif"); //$NON-NLS-1$
+ CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "public_co.gif"); //$NON-NLS-1$
}
-
+
@Override
public void run() {
ISelection selection = viewer.getSelection();
@@ -41,7 +40,7 @@ public class DiscardExternalDefsAction extends IndexAction {
return;
indexView.toggleExternalDefs();
}
-
+
@Override
public boolean valid() {
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java
index a5cc7e7adbd..02609cdf4c8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java
@@ -35,31 +35,29 @@ public class FindDeclarationsAction extends IndexAction {
public FindDeclarationsAction(IndexView view, TreeViewer viewer) {
super(view, viewer, CUIPlugin.getResourceString("IndexView.findDeclarations.name")); //$NON-NLS-1$
}
-
+
private IndexNode getBindingNode() {
ISelection selection = viewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return null;
- Object[] objs = ((IStructuredSelection)selection).toArray();
+ Object[] objs = ((IStructuredSelection) selection).toArray();
if (objs.length == 1 && objs[0] instanceof IndexNode) {
- IndexNode node= (IndexNode) objs[0];
+ IndexNode node = (IndexNode) objs[0];
if (node.fObject instanceof IIndexBinding) {
return node;
}
}
return null;
}
-
+
@Override
public void run() {
IndexNode binding = getBindingNode();
if (binding != null) {
- ICProject cproject= binding.getProject();
+ ICProject cproject = binding.getProject();
if (cproject != null) {
- IndexViewSearchQuery query = new IndexViewSearchQuery(
- null,
- cproject, indexView.getLastWriteAccess(cproject),
- (IIndexBinding) binding.fObject, binding.fText,
+ IndexViewSearchQuery query = new IndexViewSearchQuery(null, cproject,
+ indexView.getLastWriteAccess(cproject), (IIndexBinding) binding.fObject, binding.fText,
CSearchQuery.FIND_DECLARATIONS | CSearchQuery.FIND_DEFINITIONS);
NewSearchUI.activateSearchResultView();
@@ -67,7 +65,7 @@ public class FindDeclarationsAction extends IndexAction {
}
}
}
-
+
@Override
public boolean valid() {
return getBindingNode() != null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java
index d26102e86d3..3452423e38d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java
@@ -39,26 +39,24 @@ public class FindReferencesAction extends IndexAction {
ISelection selection = viewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return null;
- Object[] objs = ((IStructuredSelection)selection).toArray();
+ Object[] objs = ((IStructuredSelection) selection).toArray();
if (objs.length == 1 && objs[0] instanceof IndexNode) {
- IndexNode node= (IndexNode) objs[0];
+ IndexNode node = (IndexNode) objs[0];
if (node.fObject instanceof IIndexBinding) {
return node;
}
}
return null;
}
-
+
@Override
public void run() {
IndexNode binding = getBindingNode();
if (binding != null) {
- ICProject cproject= binding.getProject();
+ ICProject cproject = binding.getProject();
if (cproject != null) {
- IndexViewSearchQuery query = new IndexViewSearchQuery(
- null,
- cproject, indexView.getLastWriteAccess(cproject),
- (IIndexBinding) binding.fObject, binding.fText,
+ IndexViewSearchQuery query = new IndexViewSearchQuery(null, cproject,
+ indexView.getLastWriteAccess(cproject), (IIndexBinding) binding.fObject, binding.fText,
CSearchQuery.FIND_REFERENCES);
NewSearchUI.activateSearchResultView();
@@ -66,7 +64,7 @@ public class FindReferencesAction extends IndexAction {
}
}
}
-
+
@Override
public boolean valid() {
return getBindingNode() != null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexAction.java
index cd1793eb447..d154fd1982d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexAction.java
@@ -21,7 +21,7 @@ import org.eclipse.jface.viewers.TreeViewer;
/**
* @author Doug Schaefer
- *
+ *
* Root class for Index View Actions. Add an check to make sure the
* action is valid with the current context.
*/
@@ -29,28 +29,28 @@ public abstract class IndexAction extends Action {
final protected IndexView indexView;
final protected TreeViewer viewer;
-
+
protected IndexAction(IndexView view, TreeViewer viewer) {
super();
- this.indexView= view;
+ this.indexView = view;
this.viewer = viewer;
}
protected IndexAction(IndexView view, TreeViewer viewer, String text) {
super(text);
- this.indexView= view;
+ this.indexView = view;
this.viewer = viewer;
}
protected IndexAction(IndexView view, TreeViewer viewer, String text, ImageDescriptor image) {
super(text, image);
- this.indexView= view;
+ this.indexView = view;
this.viewer = viewer;
}
protected IndexAction(IndexView view, TreeViewer viewer, String text, int style) {
super(text, style);
- this.indexView= view;
+ this.indexView = view;
this.viewer = viewer;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java
index 6f13db30867..c0da10f5cee 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java
@@ -53,7 +53,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
/**
* Common label provider for index based viewers.
- *
+ *
* @author Doug Schaefer
*/
public class IndexLabelProvider extends LabelProvider {
@@ -64,34 +64,33 @@ public class IndexLabelProvider extends LabelProvider {
}
return super.getText(element);
}
-
+
@Override
public Image getImage(Object element) {
if (element instanceof IndexNode) {
return ((IndexNode) element).fImage;
}
- ImageDescriptor desc= null;
+ ImageDescriptor desc = null;
if (element instanceof ICProject)
desc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SEARCHPROJECT);
else if (element instanceof ICContainer)
desc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SEARCHFOLDER);
else if (element instanceof ITranslationUnit) {
ITranslationUnit tu = (ITranslationUnit) element;
- desc = tu.isHeaderUnit()
- ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER)
- : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
+ desc = tu.isHeaderUnit() ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER)
+ : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
}
-
+
if (desc != null)
return CUIPlugin.getImageDescriptorRegistry().get(desc);
-
+
return super.getImage(element);
}
public static String getText(IPDOMNode element) {
if (element instanceof PDOMNamedNode) {
try {
- String result = ((PDOMNamedNode)element).getDBName().getString();
+ String result = ((PDOMNamedNode) element).getDBName().getString();
if (element instanceof ICPPTemplateInstance) {
StringBuilder buffer = null;
@@ -114,7 +113,8 @@ public class IndexLabelProvider extends LabelProvider {
StringBuilder buffer = new StringBuilder("Part: "); //$NON-NLS-1$
buffer.append(result);
buffer.append('<');
- ICPPTemplateArgument[] types = ((ICPPClassTemplatePartialSpecialization) element).getTemplateArguments();
+ ICPPTemplateArgument[] types = ((ICPPClassTemplatePartialSpecialization) element)
+ .getTemplateArguments();
for (int i = 0; i < types.length; i++) {
if (i > 0)
buffer.append(',');
@@ -124,46 +124,46 @@ public class IndexLabelProvider extends LabelProvider {
result = buffer.toString();
} else if (element instanceof ICPPSpecialization) {
ICPPSpecialization spec = (ICPPSpecialization) element;
-
+
StringBuilder buffer = null;
buffer = new StringBuilder("Spec: "); //$NON-NLS-1$
buffer.append(result);
-
+
if (!(spec instanceof ICPPTemplateDefinition)
&& spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
buffer.append('<');
buffer.append(((ICPPSpecialization) element).getTemplateParameterMap().toString());
buffer.append('>');
}
-
+
result = buffer.toString();
}
-
+
/*
* aftodo - Ideally here we'd call ASTTypeUtil.getType but
* we don't currently store return types
*/
- if(element instanceof IFunction) {
- result += " "+ASTTypeUtil.getParameterTypeString(((IFunction) element).getType()); //$NON-NLS-1$
+ if (element instanceof IFunction) {
+ result += " " + ASTTypeUtil.getParameterTypeString(((IFunction) element).getType()); //$NON-NLS-1$
}
-
+
return result;
} catch (CoreException e) {
return e.getMessage();
}
- }
+ }
return ""; //$NON-NLS-1$
}
-
+
public static Image getImage(IPDOMNode element) {
ImageDescriptor desc = null;
-
+
if (element instanceof IVariable)
desc = CElementImageProvider.getVariableImageDescriptor();
else if (element instanceof IFunction)
desc = CElementImageProvider.getFunctionImageDescriptor();
else if (element instanceof ICPPClassType) {
- switch (((ICPPClassType)element).getKey()) {
+ switch (((ICPPClassType) element).getKey()) {
case ICPPClassType.k_class:
desc = CElementImageProvider.getClassImageDescriptor();
break;
@@ -174,8 +174,7 @@ public class IndexLabelProvider extends LabelProvider {
desc = CElementImageProvider.getUnionImageDescriptor();
break;
}
- }
- else if (element instanceof ICompositeType)
+ } else if (element instanceof ICompositeType)
desc = CElementImageProvider.getStructImageDescriptor();
else if (element instanceof ICPPNamespace)
desc = CElementImageProvider.getNamespaceImageDescriptor();
@@ -185,7 +184,7 @@ public class IndexLabelProvider extends LabelProvider {
desc = CElementImageProvider.getEnumeratorImageDescriptor();
else if (element instanceof ITypedef)
desc = CElementImageProvider.getTypedefImageDescriptor();
-
+
if (desc != null)
return CUIPlugin.getImageDescriptorRegistry().get(desc);
else if (element instanceof PDOMLinkage)
@@ -193,5 +192,5 @@ public class IndexLabelProvider extends LabelProvider {
return null;
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexNode.java
index 02912db8f31..3ea2a8d51b6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexNode.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.indexview;
@@ -25,8 +25,8 @@ class IndexNode {
String fText;
Image fImage;
boolean fHasDeclarationInProject;
- int fBindingKind= 0;
-
+ int fBindingKind = 0;
+
public ICProject getProject() {
if (fParent instanceof IndexNode) {
return ((IndexNode) fParent).getProject();
@@ -71,5 +71,5 @@ class IndexNode {
return false;
return true;
}
-
+
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexView.java
index 79944a482cc..48a6c0ec067 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexView.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexView.java
@@ -81,27 +81,26 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
private IndexAction findReferencesAction;
Filter filter = new Filter();
public boolean isLinking = false;
- private volatile boolean fUpdateRequested= false;
- private Map<String, Long> fTimestampPerProject= new HashMap<String, Long>();
+ private volatile boolean fUpdateRequested = false;
+ private Map<String, Long> fTimestampPerProject = new HashMap<String, Long>();
private IndexContentProvider contentProvider;
-
public void toggleExternalDefs() {
- filter.showExternalDefs = ! filter.showExternalDefs;
+ filter.showExternalDefs = !filter.showExternalDefs;
if (!filter.showExternalDefs) {
viewer.addFilter(filter);
} else {
viewer.removeFilter(filter);
}
}
-
+
public void toggleLinking() {
- isLinking = ! isLinking;
+ isLinking = !isLinking;
if (isLinking) {
openDefinitionAction.run();
}
}
-
+
/**
* Handles selection changed in viewer. Updates global actions. Links to
* editor (if option enabled)
@@ -111,30 +110,32 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
openDefinitionAction.run();
}
}
-
+
private static class Filter extends ViewerFilter {
public boolean showExternalDefs = false;
+
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IndexNode) {
- IndexNode node= (IndexNode)element;
+ IndexNode node = (IndexNode) element;
return node.fHasDeclarationInProject;
}
return true;
}
+
public static boolean hasDeclarationInProject(IPDOMNode element) {
if (element instanceof PDOMBinding) {
try {
- PDOMBinding binding = (PDOMBinding)element;
- final PDOM pdom= binding.getPDOM();
- IIndexName[] names= pdom.findNames(binding, IIndex.FIND_DECLARATIONS);
+ PDOMBinding binding = (PDOMBinding) element;
+ final PDOM pdom = binding.getPDOM();
+ IIndexName[] names = pdom.findNames(binding, IIndex.FIND_DECLARATIONS);
for (int i = 0; i < names.length; i++) {
IIndexName name = names[i];
if (name.getFile().getLocation().getFullPath() != null) {
return true;
}
}
- names= pdom.findNames(binding, IIndex.FIND_DEFINITIONS);
+ names = pdom.findNames(binding, IIndex.FIND_DEFINITIONS);
for (int i = 0; i < names.length; i++) {
IIndexName name = names[i];
if (name.getFile().getLocation().getFullPath() != null) {
@@ -144,37 +145,40 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
} catch (CoreException e) {
CUIPlugin.log(e);
}
- }
- else if (element instanceof PDOMLinkage) {
+ } else if (element instanceof PDOMLinkage) {
return true;
}
return false;
}
}
-
+
private static class Children implements IPDOMVisitor {
private ArrayList<IPDOMNode> fNodes;
+
public Children() {
- fNodes= new ArrayList<IPDOMNode>();
+ fNodes = new ArrayList<IPDOMNode>();
}
+
@Override
public boolean visit(IPDOMNode node) throws CoreException {
fNodes.add(node);
return false;
}
+
@Override
public void leave(IPDOMNode node) throws CoreException {
}
+
public IPDOMNode[] getNodes() {
return fNodes.toArray(new IPDOMNode[fNodes.size()]);
}
}
-
+
private class IndexContentProvider extends AsyncTreeContentProvider {
public IndexContentProvider(Display disp) {
super(disp);
}
-
+
@Override
public Object getParent(Object element) {
if (element instanceof IndexNode) {
@@ -196,11 +200,10 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
CUIPlugin.log(e);
return new Object[0];
}
- }
- else if (parentElement instanceof IndexNode) {
- final IndexNode node= (IndexNode) parentElement;
+ } else if (parentElement instanceof IndexNode) {
+ final IndexNode node = (IndexNode) parentElement;
if (node.fObject instanceof PDOMBinding) {
- final PDOMBinding binding= (PDOMBinding) node.fObject;
+ final PDOMBinding binding = (PDOMBinding) node.fObject;
if (!binding.mayHaveChildren()) {
return new Object[0];
}
@@ -210,30 +213,27 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
return null;
}
-
@Override
protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
try {
if (parentElement instanceof ICProject) {
- ICProject cproject= (ICProject)parentElement;
+ ICProject cproject = (ICProject) parentElement;
if (!cproject.getProject().isOpen()) {
return new Object[0];
}
return computeChildren(cproject);
- }
- else if (parentElement instanceof IndexNode) {
- IndexNode node= (IndexNode) parentElement;
- ICProject cproject= node.getProject();
+ } else if (parentElement instanceof IndexNode) {
+ IndexNode node = (IndexNode) parentElement;
+ ICProject cproject = node.getProject();
if (cproject != null && cproject.getProject().isOpen()) {
- Long ts= fTimestampPerProject.get(cproject.getElementName());
- IPDOM pdom= CCoreInternals.getPDOMManager().getPDOM(cproject);
+ Long ts = fTimestampPerProject.get(cproject.getElementName());
+ IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM(cproject);
pdom.acquireReadLock();
try {
if (ts == null || ts.longValue() == pdom.getLastWriteAccess()) {
return computeChildren(parentElement, node.fObject);
}
- }
- finally {
+ } finally {
pdom.releaseReadLock();
}
}
@@ -251,14 +251,13 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
pdom.acquireReadLock();
try {
fTimestampPerProject.put(cproject.getElementName(), Long.valueOf(pdom.getLastWriteAccess()));
- IPDOMNode[] linkages= pdom.getLinkageImpls();
+ IPDOMNode[] linkages = pdom.getLinkageImpls();
if (linkages.length == 1) {
// Skip linkages in hierarchy if there is only one
return computeChildren(cproject, linkages[0]);
}
return wrap(cproject, linkages);
- }
- finally {
+ } finally {
pdom.releaseReadLock();
}
}
@@ -273,68 +272,68 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
if (nodes.length == 0) {
return nodes;
}
- IndexNode[] result= new IndexNode[nodes.length];
+ IndexNode[] result = new IndexNode[nodes.length];
for (int i = 0; i < result.length; i++) {
- final IndexNode indexNode = result[i]= new IndexNode();
- final IPDOMNode node= nodes[i];
- indexNode.fParent= parent;
- indexNode.fObject= node;
- indexNode.fText= IndexLabelProvider.getText(node);
- indexNode.fImage= IndexLabelProvider.getImage(node);
- indexNode.fHasDeclarationInProject= Filter.hasDeclarationInProject(node);
+ final IndexNode indexNode = result[i] = new IndexNode();
+ final IPDOMNode node = nodes[i];
+ indexNode.fParent = parent;
+ indexNode.fObject = node;
+ indexNode.fText = IndexLabelProvider.getText(node);
+ indexNode.fImage = IndexLabelProvider.getImage(node);
+ indexNode.fHasDeclarationInProject = Filter.hasDeclarationInProject(node);
if (node instanceof PDOMNode) {
- indexNode.fBindingKind= ((PDOMNode) node).getNodeType();
+ indexNode.fBindingKind = ((PDOMNode) node).getNodeType();
}
}
return result;
}
}
-
+
@Override
public void createPartControl(Composite parent) {
viewer = new ExtendedTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- contentProvider= new IndexContentProvider(getSite().getShell().getDisplay());
+ contentProvider = new IndexContentProvider(getSite().getShell().getDisplay());
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(new IndexLabelProvider());
viewer.setUseHashlookup(true);
-
+
ICModel model = CoreModel.getDefault().getCModel();
viewer.setInput(model);
viewer.addFilter(filter);
try {
ICProject[] projects = model.getCProjects();
for (int i = 0; i < projects.length; ++i) {
- IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM(projects[i]);
+ IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM(projects[i]);
pdom.addListener(this);
}
} catch (CoreException e) {
CUIPlugin.log(e);
}
CoreModel.getDefault().addElementChangedListener(this);
-
+
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
-
+
// Menu
- MenuManager menuMgr = new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- private void hideMenuItems(IMenuManager manager) {
- }
+ MenuManager menuMgr = new MenuManager();
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ private void hideMenuItems(IMenuManager manager) {
+ }
- @Override
+ @Override
public void menuAboutToShow(IMenuManager manager) {
- IndexView.this.fillContextMenu(manager);
- hideMenuItems(manager);
- }
- });
- Menu menu = menuMgr.createContextMenu(viewer.getControl());
- viewer.getControl().setMenu(menu);
- getSite().registerContextMenu(menuMgr, viewer);
-
- getSite().setSelectionProvider(viewer);
+ IndexView.this.fillContextMenu(manager);
+ hideMenuItems(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+
+ getSite().setSelectionProvider(viewer);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
@@ -342,7 +341,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
}
});
}
-
+
@Override
public void dispose() {
super.dispose();
@@ -350,7 +349,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
try {
ICProject[] projects = model.getCProjects();
for (int i = 0; i < projects.length; ++i) {
- IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM(projects[i]);
+ IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM(projects[i]);
pdom.removeListener(this);
}
} catch (CoreException e) {
@@ -358,7 +357,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
}
CoreModel.getDefault().removeElementChangedListener(this);
}
-
+
private void makeActions() {
countSymbolsAction = new CountNodeAction(this, viewer);
discardExternalDefsAction = new DiscardExternalDefsAction(viewer, this);
@@ -381,7 +380,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(menuMgr, viewer);
}
-
+
private void fillContextMenu(IMenuManager manager) {
if (countSymbolsAction.valid())
manager.add(countSymbolsAction);
@@ -395,7 +394,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
manager.add(findReferencesAction);
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
-
+
private void hookDoubleClickAction() {
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
@@ -410,13 +409,13 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
//fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
}
-
+
private void fillLocalToolBar(IToolBarManager manager) {
-// drillDownAdapter.addNavigationActions(manager);
+ // drillDownAdapter.addNavigationActions(manager);
manager.add(toggleLinkingAction);
manager.add(discardExternalDefsAction);
}
-
+
@Override
public void setFocus() {
viewer.getControl().setFocus();
@@ -429,11 +428,11 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
private void requestUpdate() {
if (!fUpdateRequested) {
- fUpdateRequested= true;
+ fUpdateRequested = true;
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- fUpdateRequested= false;
+ fUpdateRequested = false;
if (!viewer.getControl().isDisposed()) {
contentProvider.recompute();
}
@@ -441,7 +440,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
});
}
}
-
+
@Override
public void elementChanged(ElementChangedEvent event) {
// Only respond to post change events
@@ -451,7 +450,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
// TODO we'll get fancier when we do a virtual tree.
processDelta(event.getDelta());
}
-
+
private void processDelta(ICElementDelta delta) {
int type = delta.getElement().getElementType();
switch (type) {
@@ -465,7 +464,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
switch (delta.getKind()) {
case ICElementDelta.ADDED:
try {
- IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM((ICProject)delta.getElement());
+ IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM((ICProject) delta.getElement());
pdom.addListener(this);
handleChange(null, null);
} catch (CoreException e) {
@@ -479,7 +478,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
}
public long getLastWriteAccess(ICProject cproject) {
- Long result= fTimestampPerProject.get(cproject.getElementName());
+ Long result = fTimestampPerProject.get(cproject.getElementName());
return result == null ? -1 : result.longValue();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java
index 92190dbfd32..1fc399b4815 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java
@@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.ui.search.CSearchQuery;
/**
* @author Doug Schaefer
- *
+ *
* This is the search query to be used for searching the PDOM.
*/
public class IndexViewSearchQuery extends CSearchQuery {
@@ -41,16 +41,16 @@ public class IndexViewSearchQuery extends CSearchQuery {
private long fLastWrite;
private String fName;
private ICProject fProject;
-
- public IndexViewSearchQuery(ICElement[] scope, ICProject project, long pdomLastWrite,
- IIndexBinding binding, String name, int flags) {
+
+ public IndexViewSearchQuery(ICElement[] scope, ICProject project, long pdomLastWrite, IIndexBinding binding,
+ String name, int flags) {
super(scope, flags);
- fProject= project;
+ fProject = project;
fBinding = binding;
- fLastWrite= pdomLastWrite;
- fName= name;
+ fLastWrite = pdomLastWrite;
+ fName = name;
}
-
+
@Override
public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
try {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java
index 6005ef6665d..cc4b261b28d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java
@@ -50,14 +50,14 @@ public class OpenDefinitionAction extends IndexAction {
public OpenDefinitionAction(IndexView view, TreeViewer viewer) {
super(view, viewer, CUIPlugin.getResourceString("IndexView.openDefinition.name"));//$NON-NLS-1$
}
-
+
private IndexNode getBindingNode() {
ISelection selection = viewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return null;
- Object[] objs = ((IStructuredSelection)selection).toArray();
+ Object[] objs = ((IStructuredSelection) selection).toArray();
if (objs.length == 1 && objs[0] instanceof IndexNode) {
- IndexNode node= (IndexNode) objs[0];
+ IndexNode node = (IndexNode) objs[0];
if (node.fObject instanceof IIndexBinding) {
return node;
}
@@ -67,40 +67,40 @@ public class OpenDefinitionAction extends IndexAction {
@Override
public void run() {
- IndexNode bindingNode= getBindingNode();
+ IndexNode bindingNode = getBindingNode();
if (bindingNode == null) {
return;
}
try {
- ICProject cproject= bindingNode.getProject();
+ ICProject cproject = bindingNode.getProject();
if (cproject != null) {
- IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
if (!openDefinition(cproject, bindingNode, index)) {
- index= CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects(), IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
+ index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects(),
+ IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
openDefinition(cproject, bindingNode, index);
}
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
CUIPlugin.log(e);
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
}
}
- private boolean openDefinition(ICProject cproject, IndexNode bindingNode, IIndex index)
+ private boolean openDefinition(ICProject cproject, IndexNode bindingNode, IIndex index)
throws InterruptedException, CoreException, CModelException, PartInitException {
index.acquireReadLock();
try {
- if (indexView.getLastWriteAccess(cproject) != CCoreInternals.getPDOMManager().getPDOM(cproject).getLastWriteAccess()) {
+ if (indexView.getLastWriteAccess(cproject) != CCoreInternals.getPDOMManager().getPDOM(cproject)
+ .getLastWriteAccess()) {
return true;
}
- IIndexName[] defs= index.findDefinitions((IIndexBinding) bindingNode.fObject);
+ IIndexName[] defs = index.findDefinitions((IIndexBinding) bindingNode.fObject);
if (defs.length > 0) {
showInEditor(defs[0]);
return true;
}
- defs= index.findDeclarations((IIndexBinding) bindingNode.fObject);
+ defs = index.findDeclarations((IIndexBinding) bindingNode.fObject);
if (defs.length > 0) {
showInEditor(defs[0]);
return true;
@@ -113,10 +113,10 @@ public class OpenDefinitionAction extends IndexAction {
private void showInEditor(IIndexName name) throws CModelException, PartInitException, CoreException {
IPath path = IndexLocationFactory.getPath(name.getFile().getLocation());
- if(path!=null) {
+ if (path != null) {
IEditorPart editor = EditorUtility.openInEditor(path, null);
if (editor != null && editor instanceof ITextEditor) {
- ITextEditor textEditor = (ITextEditor)editor;
+ ITextEditor textEditor = (ITextEditor) editor;
int nodeOffset = name.getNodeOffset();
int nodeLength = name.getNodeLength();
try {
@@ -125,7 +125,7 @@ public class OpenDefinitionAction extends IndexAction {
IDocument document = textEditor.getDocumentProvider().getDocument(editor.getEditorInput());
nodeOffset = document.getLineOffset(nodeOffset);
nodeLength = document.getLineLength(nodeOffset);
- }
+ }
textEditor.selectAndReveal(nodeOffset, nodeLength);
} catch (BadLocationException e) {
CUIPlugin.log(e);
@@ -133,7 +133,7 @@ public class OpenDefinitionAction extends IndexAction {
}
}
}
-
+
@Override
public boolean valid() {
return getBindingNode() != null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.java
index c24c481faaf..6d1a8c10455 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.java
@@ -19,12 +19,12 @@ import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
/**
* This action toggles whether this navigator links its selection to the active
* editor.
- *
+ *
*/
public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- IndexView fCView;
-
+
+ IndexView fCView;
+
/**
* Constructs a new action.
*/
@@ -38,7 +38,7 @@ public class ToggleLinkingAction extends AbstractToggleLinkingAction {
*/
@Override
public void run() {
- fCView.toggleLinking();
+ fCView.toggleLinking();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java
index faded12b221..16a04489d7f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -72,19 +72,16 @@ public abstract class ContentTypeMappingDialog extends Dialog {
@Override
protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
- true);
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
protected String[] getLanguages() {
- ILanguage[] languages = LanguageManager.getInstance()
- .getRegisteredLanguages();
+ ILanguage[] languages = LanguageManager.getInstance().getRegisteredLanguages();
String[] descriptions = new String[languages.length];
-
+
for (int i = 0; i < descriptions.length; i++) {
descriptions[i] = languages[i].getName();
fLanguageNamesToIDsMap.put(descriptions[i], languages[i].getId());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
index 00be6ecf6ca..6ff3df9088c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
@@ -63,48 +63,48 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
private static final int MINIMUM_COLUMN_WIDTH = 150;
private static final int LANGUAGE_COLUMN = 1;
private static final int CONFIGURATION_COLUMN = 0;
-
+
private static final int LANGUAGE_ID = 0;
private static final int LANGUAGE_NAME = 1;
-
+
private static final String ALL_CONFIGURATIONS = ""; //$NON-NLS-1$
-
+
private IContentType fContentType;
private Composite fContents;
private Table fTable;
private ILanguage[] fLanguages;
private Map<String, ILanguage> fLanguageIds;
private boolean fHasChanges;
-
+
public FileLanguageMappingPropertyPage() {
super();
fLanguages = LanguageManager.getInstance().getRegisteredLanguages();
fLanguageIds = LanguageVerifier.computeAvailableLanguages();
}
-
+
@Override
protected Control createContents(Composite parent) {
IFile file = getFile();
IProject project = file.getProject();
fContentType = CContentTypes.getContentType(project, file.getName());
-
+
fContents = new Composite(parent, SWT.NONE);
fContents.setLayout(new GridLayout(2, false));
Label contentTypeLabel = new Label(fContents, SWT.NONE);
contentTypeLabel.setText(PreferencesMessages.FileLanguagesPropertyPage_contentTypeLabel);
contentTypeLabel.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, false, false));
-
+
Label contentTypeDescriptionLabel = new Label(fContents, SWT.NONE);
contentTypeDescriptionLabel.setText(fContentType.getName());
contentTypeDescriptionLabel.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
-
+
try {
createMappingTable(fContents, file);
} catch (CoreException e) {
CUIPlugin.log(e);
}
-
+
Link link = new Link(fContents, SWT.NONE);
link.setText(PreferencesMessages.FileLanguagesPropertyPage_description);
link.addListener(SWT.Selection, new LanguageMappingLinkListener(parent.getShell(), project) {
@@ -117,9 +117,9 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
}
}
});
-
+
link.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false, 2, 1));
-
+
fContents.pack();
return fContents;
}
@@ -149,12 +149,12 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
layout.setColumnData(contentTypeColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
layout.setColumnData(languageColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
tableParent.setLayout(layout);
-
+
final TableEditor editor = new TableEditor(fTable);
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setColumn(LANGUAGE_COLUMN);
-
+
final IProject project = file.getProject();
fTable.addListener(SWT.Selection, new Listener() {
@@ -164,7 +164,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
if (oldEditor != null) {
oldEditor.dispose();
}
-
+
TableItem item = (TableItem) event.item;
if (item == null) {
return;
@@ -173,7 +173,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
LanguageTableData data = (LanguageTableData) item.getData();
CCombo newEditor = new CCombo(fTable, SWT.READ_ONLY);
populateLanguages(project, file, data.configuration, data.languageId, newEditor);
-
+
newEditor.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
@@ -182,12 +182,12 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
if (index != -1) {
TableItem item = editor.getItem();
item.setText(LANGUAGE_COLUMN, combo.getText());
-
+
String selectedLanguage = ((String[]) combo.getData())[index];
LanguageTableData data = (LanguageTableData) item.getData();
data.languageId = selectedLanguage;
fHasChanges = true;
-
+
try {
refreshMappings();
} catch (CoreException e) {
@@ -196,12 +196,12 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
}
}
});
-
+
newEditor.setFocus();
editor.setEditor(newEditor, item, LANGUAGE_COLUMN);
}
});
-
+
populateLanguageTable(fTable);
refreshMappings();
}
@@ -211,58 +211,60 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
IProject project = file.getProject();
ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription[] configurations = description.getConfigurations();
-
+
TableItem defaultItem = new TableItem(table, SWT.NONE);
defaultItem.setText(CONFIGURATION_COLUMN, PreferencesMessages.FileLanguagesPropertyPage_defaultMapping);
-
+
ProjectLanguageConfiguration config = LanguageManager.getInstance().getLanguageConfiguration(project);
-
+
Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(config, description, fLanguageIds);
if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
String affectedLanguages = LanguageVerifier.computeAffectedLanguages(missingLanguages);
- messageBox.setMessage(Messages.format(PreferencesMessages.FileLanguagesPropertyPage_missingLanguage, affectedLanguages));
+ messageBox.setMessage(
+ Messages.format(PreferencesMessages.FileLanguagesPropertyPage_missingLanguage, affectedLanguages));
messageBox.open();
}
-
+
String defaultLanguageId = config.getLanguageForFile(null, file);
- LanguageTableData defaultData = new LanguageTableData(null, defaultLanguageId );
+ LanguageTableData defaultData = new LanguageTableData(null, defaultLanguageId);
defaultItem.setData(defaultData);
-
+
for (int i = 0; i < configurations.length; i++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(CONFIGURATION_COLUMN, configurations[i].getName());
String languageId = config.getLanguageForFile(configurations[i], file);
-
+
if (languageId != null) {
ILanguage language = fLanguageIds.get(languageId);
- String languageName = language.getName();
+ String languageName = language.getName();
item.setText(LANGUAGE_COLUMN, languageName);
}
-
+
LanguageTableData data = new LanguageTableData(configurations[i], languageId);
item.setData(data);
}
}
- private void populateLanguages(IProject project, IFile file, ICConfigurationDescription configuration, String selectedLanguage, CCombo combo) {
+ private void populateLanguages(IProject project, IFile file, ICConfigurationDescription configuration,
+ String selectedLanguage, CCombo combo) {
try {
String[][] languageInfo = getLanguages(project, file, configuration);
combo.setItems(languageInfo[LANGUAGE_NAME]);
combo.setData(languageInfo[LANGUAGE_ID]);
-
+
findSelection(configuration, selectedLanguage, combo);
fContents.layout();
} catch (CoreException e) {
CUIPlugin.log(e);
}
}
-
+
private void refreshMappings() throws CoreException {
IFile file = getFile();
IProject project = file.getProject();
-
+
LanguageManager manager = LanguageManager.getInstance();
TableItem[] items = fTable.getItems();
for (int i = 0; i < items.length; i++) {
@@ -278,38 +280,39 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
}
}
- private void findSelection(ICConfigurationDescription configuration, String languageId, CCombo combo) throws CoreException {
-// if (languageId == null) {
-// TableItem[] items = fTable.getItems();
-// for (int i = 0; i < items.length; i++) {
-// LanguageTableData data = (LanguageTableData) items[i].getData();
-// if (configuration == null && data.configuration == null) {
-// languageId = data.languageId;
-// break;
-// } else if (configuration != null && data.configuration != null) {
-// languageId = data.languageId;
-// break;
-// }
-// }
-// }
-
+ private void findSelection(ICConfigurationDescription configuration, String languageId, CCombo combo)
+ throws CoreException {
+ // if (languageId == null) {
+ // TableItem[] items = fTable.getItems();
+ // for (int i = 0; i < items.length; i++) {
+ // LanguageTableData data = (LanguageTableData) items[i].getData();
+ // if (configuration == null && data.configuration == null) {
+ // languageId = data.languageId;
+ // break;
+ // } else if (configuration != null && data.configuration != null) {
+ // languageId = data.languageId;
+ // break;
+ // }
+ // }
+ // }
+
if (languageId == null) {
// No mapping was defined so we'll choose the default.
combo.select(0);
return;
}
-
+
LanguageManager manager = LanguageManager.getInstance();
ILanguage language = manager.getLanguage(languageId);
String name = language.getName();
-
+
for (int i = 1; i < combo.getItemCount(); i++) {
if (name.equals(combo.getItem(i))) {
combo.select(i);
return;
}
}
-
+
// Couldn't find the mapping so we'll choose the default.
combo.select(0);
}
@@ -320,12 +323,12 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
if (!fHasChanges) {
return true;
}
-
+
IFile file = getFile();
IProject project = file.getProject();
LanguageManager manager = LanguageManager.getInstance();
ProjectLanguageConfiguration config = manager.getLanguageConfiguration(project);
-
+
Map<String, String> mappings = new TreeMap<String, String>();
TableItem[] items = fTable.getItems();
for (int i = 0; i < items.length; i++) {
@@ -351,7 +354,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
return false;
}
}
-
+
private IFile getFile() {
return getElement().getAdapter(IFile.class);
}
@@ -360,11 +363,12 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
protected void performDefaults() {
super.performDefaults();
}
-
- private String computeInheritedFrom(ICConfigurationDescription configuration, LanguageMapping mapping) throws CoreException {
+
+ private String computeInheritedFrom(ICConfigurationDescription configuration, LanguageMapping mapping)
+ throws CoreException {
String inheritedFrom;
ILanguage language;
-
+
LanguageTableData data = (LanguageTableData) fTable.getItem(0).getData();
if (configuration != null && data.languageId != null) {
inheritedFrom = PreferencesMessages.FileLanguagesPropertyPage_inheritedFromFile;
@@ -387,10 +391,12 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
}
return Messages.format(inheritedFrom, language.getName());
}
-
- private LanguageMapping computeInheritedMapping(IProject project, IFile file, ICConfigurationDescription configuration) throws CoreException {
- LanguageMapping mappings[] = LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, fContentType.getId(), true);
-
+
+ private LanguageMapping computeInheritedMapping(IProject project, IFile file,
+ ICConfigurationDescription configuration) throws CoreException {
+ LanguageMapping mappings[] = LanguageMappingResolver.computeLanguage(project,
+ file.getProjectRelativePath().toPortableString(), configuration, fContentType.getId(), true);
+
// Skip over the file mapping because we want to know what mapping the file
// mapping overrides.
for (int i = 0; i < mappings.length; i++) {
@@ -398,15 +404,16 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
return mappings[i];
}
}
-
+
return null;
}
-
- private String[][] getLanguages(IProject project, IFile file, ICConfigurationDescription configuration) throws CoreException {
+
+ private String[][] getLanguages(IProject project, IFile file, ICConfigurationDescription configuration)
+ throws CoreException {
String[][] descriptions = new String[2][fLanguages.length + 1];
-
+
LanguageMapping inheritedMapping = computeInheritedMapping(project, file, configuration);
-
+
int index = 0;
descriptions[LANGUAGE_ID][index] = null;
descriptions[LANGUAGE_NAME][index] = computeInheritedFrom(configuration, inheritedMapping);
@@ -419,15 +426,14 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
}
return descriptions;
}
-
+
private static class LanguageTableData {
ICConfigurationDescription configuration;
String languageId;
-
+
LanguageTableData(ICConfigurationDescription configuration, String languageId) {
this.configuration = configuration;
this.languageId = languageId;
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener.java
index 3402329aef2..413f79c8df9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener.java
@@ -23,10 +23,10 @@ public class LanguageMappingLinkListener implements Listener {
private static final String WORKSPACE_PREFERENCE_PAGE = "org.eclipse.cdt.ui.preferences.LanguageMappings"; //$NON-NLS-1$
private static final String PROJECT_PROPERTY_PAGE = "org.eclipse.cdt.ui.projectLanguageMappings"; //$NON-NLS-1$
-
+
private static final String WORKSPACE_LINK = "workspace"; //$NON-NLS-1$
private static final String PROJECT_LINK = "project"; //$NON-NLS-1$
-
+
private Shell fShell;
private IAdaptable fElement;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java
index cedfc195ae5..2f6bd14625f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java
@@ -37,22 +37,22 @@ public abstract class LanguageMappingWidget {
protected static final int MINIMUM_COLUMN_WIDTH = 150;
protected Composite fContents;
protected boolean fIsReadOnly;
-
+
protected Table fTable;
protected HashMap<String, String> fContentTypeNamesToIDsMap;
protected Set<IContentType> fAffectedContentTypes;
protected Font fOverriddenFont;
protected LanguageMappingWidget fChild;
protected IAdaptable fElement;
-
+
protected Set<String> fOverriddenContentTypes;
-
+
private boolean fIsChanged;
-
+
public LanguageMappingWidget() {
fOverriddenFont = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
fOverriddenContentTypes = Collections.emptySet();
-
+
// keep a mapping of all registered content types and their names
fContentTypeNamesToIDsMap = new HashMap<String, String>();
String[] contentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds();
@@ -75,15 +75,15 @@ public abstract class LanguageMappingWidget {
public IAdaptable getElement() {
return fElement;
}
-
+
public void setElement(IAdaptable element) {
fElement = element;
}
-
+
public void setOverriddenContentTypes(Set<String> contentTypes) {
fOverriddenContentTypes = contentTypes;
}
-
+
public IContentType[] getAffectedContentTypes() {
return fAffectedContentTypes.toArray(new IContentType[fAffectedContentTypes.size()]);
}
@@ -91,11 +91,11 @@ public abstract class LanguageMappingWidget {
public void setReadOnly(boolean isReadOnly) {
fIsReadOnly = isReadOnly;
}
-
+
public void setChild(LanguageMappingWidget child) {
fChild = child;
}
-
+
public boolean isChanged() {
return fIsChanged;
}
@@ -103,7 +103,7 @@ public abstract class LanguageMappingWidget {
public void setChanged(boolean changed) {
fIsChanged = changed;
}
-
+
protected void createHeader(Composite parent, String description) {
Link link = new Link(fContents, SWT.NONE);
link.setText(description);
@@ -120,7 +120,8 @@ public abstract class LanguageMappingWidget {
gridData.horizontalSpan = 2;
link.setLayoutData(gridData);
}
-
+
public abstract Composite createContents(Composite parent, String description);
+
public abstract void refreshMappings();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java
index 96079f2b1e5..ca70ec47840 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java
@@ -34,7 +34,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
* Analyzes and repairs language mapping configurations.
*/
public class LanguageVerifier {
-
+
public static Map<String, ILanguage> computeAvailableLanguages() {
ILanguage[] registeredLanguages = LanguageManager.getInstance().getRegisteredLanguages();
Map<String, ILanguage> languages = new TreeMap<String, ILanguage>();
@@ -43,7 +43,7 @@ public class LanguageVerifier {
}
return languages;
}
-
+
public static String computeAffectedLanguages(Set<String> missingLanguages) {
Iterator<String> languages = missingLanguages.iterator();
StringBuilder buffer = new StringBuilder();
@@ -54,11 +54,13 @@ public class LanguageVerifier {
return buffer.toString();
}
- public static Set<String> removeMissingLanguages(ProjectLanguageConfiguration config, ICProjectDescription description, Map<String, ILanguage> availableLanguages) {
+ public static Set<String> removeMissingLanguages(ProjectLanguageConfiguration config,
+ ICProjectDescription description, Map<String, ILanguage> availableLanguages) {
Set<String> missingLanguages = new TreeSet<String>();
-
+
// Check file mappings
- Iterator<Entry<String, Map<String, String>>> fileConfigurationMappings = config.getFileMappings().entrySet().iterator();
+ Iterator<Entry<String, Map<String, String>>> fileConfigurationMappings = config.getFileMappings().entrySet()
+ .iterator();
while (fileConfigurationMappings.hasNext()) {
Entry<String, Map<String, String>> entry = fileConfigurationMappings.next();
String path = entry.getKey();
@@ -75,9 +77,10 @@ public class LanguageVerifier {
}
}
}
-
+
// Check content type mappings
- Iterator<Entry<String, Map<String, String>>> configurationContentTypeMappings = config.getContentTypeMappings().entrySet().iterator();
+ Iterator<Entry<String, Map<String, String>>> configurationContentTypeMappings = config.getContentTypeMappings()
+ .entrySet().iterator();
while (configurationContentTypeMappings.hasNext()) {
Entry<String, Map<String, String>> entry = configurationContentTypeMappings.next();
String configurationId = entry.getKey();
@@ -94,13 +97,14 @@ public class LanguageVerifier {
}
}
}
-
+
return missingLanguages;
}
- public static Set<String> removeMissingLanguages(WorkspaceLanguageConfiguration config, Map<String, ILanguage> availableLanguages) {
+ public static Set<String> removeMissingLanguages(WorkspaceLanguageConfiguration config,
+ Map<String, ILanguage> availableLanguages) {
Set<String> missingLanguages = new TreeSet<String>();
-
+
// Check content type mappings
Iterator<Entry<String, String>> contentTypeMappings = config.getWorkspaceMappings().entrySet().iterator();
List<String> removals = new ArrayList<String>();
@@ -109,10 +113,10 @@ public class LanguageVerifier {
String languageId = entry.getValue();
if (!availableLanguages.containsKey(languageId)) {
missingLanguages.add(languageId);
- removals.add(entry.getKey());
+ removals.add(entry.getKey());
}
}
-
+
for (String removal : removals) {
config.removeWorkspaceMapping(removal);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java
index 53b6821bcd0..a20529e616b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
@@ -38,7 +38,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
-
+
private Combo fConfiguration;
private ICConfigurationDescription[] fConfigurations;
private String[] fContentTypesIDs;
@@ -47,13 +47,13 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
public ProjectContentTypeMappingDialog(Shell parentShell, ICConfigurationDescription[] configurations) {
super(parentShell);
fConfigurations = configurations;
-
+
fContentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds();
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
for (int i = 0; i < fContentTypesIDs.length; i++) {
String name = contentTypeManager.getContentType(fContentTypesIDs[i]).getName();
-
+
// keep track of what ID this name corresponds to so that when
// we setup the mapping
// later based upon user selection, we'll know what ID to use
@@ -89,11 +89,11 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
getButton(IDialogConstants.OK_ID).setEnabled(false);
return;
}
-
- // Shift index by one because of "All configurations" entry.
+
+ // Shift index by one because of "All configurations" entry.
int configurationIndex = index - 1;
ICConfigurationDescription configuration = fConfigurations[configurationIndex];
-
+
fSelectedConfigurationName = configuration.getName();
fSelectedConfigurationID = configuration.getId();
configureContentTypes(fContentType, configuration);
@@ -102,13 +102,13 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
}
});
fConfiguration.select(0);
-
+
Label contentTypeLabel = new Label(area, SWT.TRAIL);
contentTypeLabel.setText(PreferencesMessages.ContentTypeMappingsDialog_contentType);
fContentType = new Combo(area, SWT.DROP_DOWN | SWT.READ_ONLY);
fContentType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
+
fContentType.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
@@ -136,16 +136,16 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
return area;
}
-
+
private void configureContentTypes(Combo combo, ICConfigurationDescription configuration) {
combo.removeAll();
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
List<String> names = new LinkedList<String>();
-
+
for (int i = 0; i < fContentTypesIDs.length; i++) {
String contentTypeId = fContentTypesIDs[i];
String name = contentTypeManager.getContentType(contentTypeId).getName();
-
+
if (configuration != null) {
String key = ProjectLanguageMappingWidget.createFilterKey(configuration.getId(), contentTypeId);
if (!fFilteredContentTypes.contains(key)) {
@@ -155,16 +155,17 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
names.add(name);
}
}
-
+
Collections.sort(names);
- for(String name : names) {
+ for (String name : names) {
combo.add(name);
}
}
@Override
protected boolean isValidSelection() {
- return fContentType.getSelectionIndex() != -1 && fLanguage.getSelectionIndex() != -1 && fConfiguration.getSelectionIndex() != -1;
+ return fContentType.getSelectionIndex() != -1 && fLanguage.getSelectionIndex() != -1
+ && fConfiguration.getSelectionIndex() != -1;
}
public void setContentTypeFilter(Set<String> contentTypeFilter) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java
index db17005594b..55620483d22 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
@@ -50,14 +50,14 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
private WorkspaceLanguageMappingWidget fInheritedMappingWidget;
private ProjectLanguageConfiguration fMappings;
private ILanguageMappingChangeListener fInheritedMappingsChangeListener;
-
+
public ProjectLanguageMappingPropertyPage() {
super();
fMappingWidget = new ProjectLanguageMappingWidget();
-
+
fInheritedMappingWidget = new WorkspaceLanguageMappingWidget();
fInheritedMappingWidget.setReadOnly(true);
-
+
fMappingWidget.setChild(fInheritedMappingWidget);
}
@@ -67,19 +67,20 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
@Override
protected Control createContents(Composite parent) {
fMappingWidget.setElement(getProject());
-
+
Composite contents = new Composite(parent, SWT.NONE);
contents.setLayout(new GridLayout(1, false));
-
+
fetchMappings(getProject());
- Composite contentTypeMappings = fMappingWidget.createContents(contents, PreferencesMessages.ProjectLanguagesPropertyPage_description);
+ Composite contentTypeMappings = fMappingWidget.createContents(contents,
+ PreferencesMessages.ProjectLanguagesPropertyPage_description);
contentTypeMappings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
+
Group group = new Group(contents, SWT.SHADOW_IN);
group.setText(PreferencesMessages.ProjectLanguagesPropertyPage_inheritedWorkspaceMappingsGroup);
group.setLayout(new FillLayout());
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
+
fetchWorkspaceMappings();
fInheritedMappingWidget.createContents(group, null);
fInheritedMappingsChangeListener = new ILanguageMappingChangeListener() {
@@ -97,8 +98,7 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
}
});
}
- }
- else if (event.getType() == ILanguageMappingChangeEvent.TYPE_PROJECT) {
+ } else if (event.getType() == ILanguageMappingChangeEvent.TYPE_PROJECT) {
if (ProjectLanguageMappingPropertyPage.this.isControlCreated()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
@@ -114,7 +114,7 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
}
};
LanguageManager.getInstance().registerLanguageChangeListener(fInheritedMappingsChangeListener);
-
+
return contents;
}
@@ -122,15 +122,17 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
try {
LanguageManager manager = LanguageManager.getInstance();
fMappings = manager.getLanguageConfiguration(project);
-
+
ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project);
Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
- Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, description, availableLanguages);
+ Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, description,
+ availableLanguages);
if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
String affectedLanguages = LanguageVerifier.computeAffectedLanguages(missingLanguages);
- messageBox.setMessage(Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_missingLanguage, affectedLanguages));
+ messageBox.setMessage(Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_missingLanguage,
+ affectedLanguages));
messageBox.open();
}
@@ -139,19 +141,21 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
CUIPlugin.log(e);
}
}
-
+
private void fetchWorkspaceMappings() {
try {
LanguageManager manager = LanguageManager.getInstance();
WorkspaceLanguageConfiguration workspaceMappings = manager.getWorkspaceLanguageConfiguration();
Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
- Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(workspaceMappings, availableLanguages);
+ Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(workspaceMappings,
+ availableLanguages);
if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
String affectedLanguages = LanguageVerifier.computeAffectedLanguages(missingLanguages);
- messageBox.setMessage(Messages.format(PreferencesMessages.WorkspaceLanguagesPreferencePage_missingLanguage, affectedLanguages));
+ messageBox.setMessage(Messages.format(
+ PreferencesMessages.WorkspaceLanguagesPreferencePage_missingLanguage, affectedLanguages));
messageBox.open();
}
@@ -174,7 +178,7 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
if (!fMappingWidget.isChanged()) {
return true;
}
-
+
fMappings.setContentTypeMappings(fMappingWidget.getContentTypeMappings());
IContentType[] affectedContentTypes = fMappingWidget.getAffectedContentTypes();
LanguageManager.getInstance().storeLanguageMappingConfiguration(getProject(), affectedContentTypes);
@@ -185,7 +189,7 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
return false;
}
}
-
+
@Override
public void dispose() {
super.dispose();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java
index 3f5cf1c78bc..8e09c0869ce 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java
@@ -59,7 +59,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
private static final int CONTENT_TYPE_COLUMN = 1;
private static final int LANGUAGE_COLUMN = 2;
-
+
private Map<String, Map<String, String>> fConfigurationContentTypeMappings;
public void setMappings(Map<String, Map<String, String>> contentTypeMappings) {
@@ -95,7 +95,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
TableColumn configurationColumn = new TableColumn(fTable, SWT.LEAD);
configurationColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_configurationColumn);
-
+
TableColumn contentTypeColumn = new TableColumn(fTable, SWT.LEAD);
contentTypeColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_contentTypeColumn);
@@ -121,8 +121,9 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
IProject project = getElement().getAdapter(IProject.class);
ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false);
ICConfigurationDescription[] configurations = description.getConfigurations();
- ProjectContentTypeMappingDialog dialog = new ProjectContentTypeMappingDialog(fContents.getShell(), configurations);
-
+ ProjectContentTypeMappingDialog dialog = new ProjectContentTypeMappingDialog(fContents.getShell(),
+ configurations);
+
dialog.setContentTypeFilter(createContentTypeFilter(fConfigurationContentTypeMappings));
dialog.setBlockOnOpen(true);
@@ -140,7 +141,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
}
contentTypeMappings.put(contentType, language);
setChanged(true);
-
+
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
refreshMappings();
@@ -167,7 +168,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
} else {
configurationId = data.configuration.getId();
}
-
+
Map<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId);
if (contentTypeMappings != null) {
contentTypeMappings.remove(contentType);
@@ -176,7 +177,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
}
-
+
if (selection.length > 0) {
setChanged(true);
}
@@ -204,13 +205,13 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
}
return filter;
}
-
+
@Override
public void refreshMappings() {
if (fTable == null) {
return;
}
-
+
fTable.removeAll();
Iterator<Entry<String, Map<String, String>>> mappings = fConfigurationContentTypeMappings.entrySet().iterator();
@@ -226,24 +227,25 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
while (contentTypeMappings.hasNext()) {
Entry<String, String> entry = contentTypeMappings.next();
TableItem item = new TableItem(fTable, SWT.NONE);
-
+
String contentType = entry.getKey();
String contentTypeName = contentTypeManager.getContentType(contentType).getName();
String languageId = entry.getValue();
String languageName = LanguageManager.getInstance().getLanguage(languageId).getName();
-
+
ICConfigurationDescription configuration = description.getConfigurationById(configurationId);
-
+
item.setData(new LanguageTableData(configuration, contentType, languageId));
-
+
if (configuration == null) {
item.setText(CONFIGURATION_COLUMN, PreferencesMessages.ContentTypeMappingsDialog_allConfigurations);
} else {
item.setText(CONFIGURATION_COLUMN, configuration.getName());
}
-
+
if (fOverriddenContentTypes.contains(contentType)) {
- item.setText(CONTENT_TYPE_COLUMN, Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType, contentTypeName));
+ item.setText(CONTENT_TYPE_COLUMN, Messages.format(
+ PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType, contentTypeName));
item.setFont(fOverriddenFont);
} else {
item.setText(CONTENT_TYPE_COLUMN, contentTypeName);
@@ -251,15 +253,17 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
item.setText(LANGUAGE_COLUMN, languageName);
}
}
-
+
if (fChild != null) {
- Set<String> overrides = new HashSet<String>(createWorkspaceContentTypeFilter(fConfigurationContentTypeMappings));
+ Set<String> overrides = new HashSet<String>(
+ createWorkspaceContentTypeFilter(fConfigurationContentTypeMappings));
fChild.setOverriddenContentTypes(overrides);
fChild.refreshMappings();
}
}
-
- private Set<String> createWorkspaceContentTypeFilter(Map<String, Map<String, String>> configurationContentTypeMappings) {
+
+ private Set<String> createWorkspaceContentTypeFilter(
+ Map<String, Map<String, String>> configurationContentTypeMappings) {
Map<String, String> contentTypeMappings = configurationContentTypeMappings.get(ALL_CONFIGURATIONS);
if (contentTypeMappings == null) {
return Collections.emptySet();
@@ -270,11 +274,11 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
static String createFilterKey(String configurationId, String contentTypeId) {
return configurationId + CONTENT_TYPE_KEY_DELIMITER + contentTypeId;
}
-
+
private static class LanguageTableData {
ICConfigurationDescription configuration;
String contentTypeId;
-
+
LanguageTableData(ICConfigurationDescription configuration, String contentTypeId, String languageId) {
this.configuration = configuration;
this.contentTypeId = contentTypeId;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java
index 1a1350ec0b0..02c35aaea60 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java
@@ -79,20 +79,17 @@ public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog
return area;
}
-
+
private void configureContentTypes(Combo combo) {
combo.removeAll();
- String[] contentTypesIDs = LanguageManager.getInstance()
- .getRegisteredContentTypeIds();
+ String[] contentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds();
- IContentTypeManager contentTypeManager = Platform
- .getContentTypeManager();
+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
for (int i = 0; i < contentTypesIDs.length; i++) {
if (!fFilteredContentTypes.contains(contentTypesIDs[i])) {
- String name = contentTypeManager.getContentType(
- contentTypesIDs[i]).getName();
+ String name = contentTypeManager.getContentType(contentTypesIDs[i]).getName();
combo.add(name);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java
index 6d2a92b6786..353d0667cb3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java
@@ -46,15 +46,16 @@ public class WorkspaceLanguageMappingPreferencePage extends PreferencePage imple
WorkspaceLanguageConfiguration fMappings;
WorkspaceLanguageMappingWidget fMappingWidget;
-
+
public WorkspaceLanguageMappingPreferencePage() {
fMappingWidget = new WorkspaceLanguageMappingWidget();
}
-
+
@Override
public void createControl(Composite parent) {
super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.LANGUAGE_MAPPING_PREFERENCE_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
+ ICHelpContextIds.LANGUAGE_MAPPING_PREFERENCE_PAGE);
}
@Override
@@ -66,34 +67,35 @@ public class WorkspaceLanguageMappingPreferencePage extends PreferencePage imple
}
return fMappingWidget.createContents(parent, PreferencesMessages.WorkspaceLanguagesPreferencePage_description);
}
-
+
private void fetchMappings() throws CoreException {
fMappings = LanguageManager.getInstance().getWorkspaceLanguageConfiguration();
-
+
Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, availableLanguages);
if (missingLanguages.size() > 0) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
String affectedLanguages = LanguageVerifier.computeAffectedLanguages(missingLanguages);
- messageBox.setMessage(Messages.format(PreferencesMessages.WorkspaceLanguagesPreferencePage_missingLanguage, affectedLanguages));
+ messageBox.setMessage(Messages.format(PreferencesMessages.WorkspaceLanguagesPreferencePage_missingLanguage,
+ affectedLanguages));
messageBox.open();
}
-
+
fMappingWidget.setMappings(fMappings.getWorkspaceMappings());
}
@Override
public void init(IWorkbench workbench) {
}
-
+
@Override
public boolean performOk() {
try {
if (!fMappingWidget.isChanged()) {
return true;
}
-
+
IContentType[] affectedContentTypes = fMappingWidget.getAffectedContentTypes();
LanguageManager manager = LanguageManager.getInstance();
WorkspaceLanguageConfiguration config = manager.getWorkspaceLanguageConfiguration();
@@ -106,7 +108,7 @@ public class WorkspaceLanguageMappingPreferencePage extends PreferencePage imple
return false;
}
}
-
+
@Override
protected void performDefaults() {
super.performDefaults();
@@ -115,7 +117,7 @@ public class WorkspaceLanguageMappingPreferencePage extends PreferencePage imple
node.remove(CCorePreferenceConstants.WORKSPACE_LANGUAGE_MAPPINGS);
try {
// remove workspace mappings
- Map<String,String> currentMappings= fMappings.getWorkspaceMappings();
+ Map<String, String> currentMappings = fMappings.getWorkspaceMappings();
Set<String> keys = currentMappings.keySet();
String[] contentTypeIds = keys.toArray(new String[keys.size()]);
for (String contentTypeId : contentTypeIds) {
@@ -124,9 +126,9 @@ public class WorkspaceLanguageMappingPreferencePage extends PreferencePage imple
// add default mappings
LanguageMappingStore store = new LanguageMappingStore();
WorkspaceLanguageConfiguration defaultConfig = store.decodeWorkspaceMappings();
- Map<String,String> defaultMappings= defaultConfig.getWorkspaceMappings();
+ Map<String, String> defaultMappings = defaultConfig.getWorkspaceMappings();
for (String contentTypeId : defaultMappings.keySet()) {
- String language= defaultMappings.get(contentTypeId);
+ String language = defaultMappings.get(contentTypeId);
fMappings.addWorkspaceMapping(contentTypeId, language);
}
fetchMappings();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java
index a0487239cae..dfaf20eaae8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java
@@ -46,12 +46,12 @@ import org.eclipse.cdt.internal.ui.util.Messages;
public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
private Map<String, String> fContentTypeMappings;
-
+
public WorkspaceLanguageMappingWidget() {
super();
fContentTypeMappings = new TreeMap<String, String>();
}
-
+
@Override
public Composite createContents(Composite parent, String description) {
fContents = new Composite(parent, SWT.NONE);
@@ -74,7 +74,6 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
}
});
fTable.setToolTipText(PreferencesMessages.WorkspaceLanguagesPreferencePage_mappingTableTitle);
-
TableColumn contentTypeColumn = new TableColumn(fTable, SWT.LEAD);
contentTypeColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_contentTypeColumn);
@@ -91,17 +90,18 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
Composite buttons = new Composite(fContents, SWT.NONE);
buttons.setLayout(new GridLayout());
buttons.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
-
+
Button addButton = new Button(buttons, SWT.PUSH);
addButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
addButton.setText(PreferencesMessages.ProjectLanguagesPropertyPage_addMappingButton);
addButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
- WorkspaceContentTypeMappingDialog dialog = new WorkspaceContentTypeMappingDialog(fContents.getShell());
+ WorkspaceContentTypeMappingDialog dialog = new WorkspaceContentTypeMappingDialog(
+ fContents.getShell());
dialog.setContentTypeFilter(fContentTypeMappings.keySet());
dialog.setBlockOnOpen(true);
-
+
if (dialog.open() == Window.OK) {
String contentType = dialog.getContentTypeID();
String language = dialog.getLanguageID();
@@ -113,29 +113,29 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
}
}
});
-
+
Button removeButton = new Button(buttons, SWT.PUSH);
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
removeButton.setText(PreferencesMessages.ProjectLanguagesPropertyPage_removeMappingButton);
removeButton.addListener(SWT.Selection, new Listener() {
-
+
@Override
public void handleEvent(Event event) {
TableItem[] selection = fTable.getSelection();
-
+
for (int i = 0; i < selection.length; i++) {
String contentType = fContentTypeNamesToIDsMap.get(selection[i].getText(0));
-
+
fContentTypeMappings.remove(contentType);
-
+
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
}
-
+
if (selection.length > 0) {
setChanged(true);
}
-
+
refreshMappings();
}
});
@@ -150,7 +150,7 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
if (fTable == null) {
return;
}
-
+
fTable.removeAll();
Iterator<Entry<String, String>> mappings = fContentTypeMappings.entrySet().iterator();
@@ -166,14 +166,15 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
String languageName = LanguageManager.getInstance().getLanguage(entry.getValue()).getName();
if (fOverriddenContentTypes.contains(contentType)) {
- item.setText(0, Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType, contentTypeName));
+ item.setText(0, Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType,
+ contentTypeName));
item.setFont(fOverriddenFont);
} else {
item.setText(0, contentTypeName);
}
item.setText(1, languageName);
}
-
+
if (fChild != null) {
Set<String> overrides = new HashSet<String>(fContentTypeMappings.keySet());
overrides.addAll(fOverriddenContentTypes);
@@ -181,7 +182,7 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
fChild.refreshMappings();
}
}
-
+
public void setMappings(Map<String, String> mappings) {
fContentTypeMappings = new TreeMap<String, String>(mappings);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingEntryDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingEntryDialog.java
index 8341a1a0b01..2680df4bc3f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingEntryDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingEntryDialog.java
@@ -79,41 +79,29 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private static final int COMBO_INDEX_LIBRARY_DIR = 4;
private static final int COMBO_INDEX_LIBRARY_FILE = 5;
- final private String[] comboKindItems = {
- Messages.LanguageSettingEntryDialog_IncludeDirectory,
- Messages.LanguageSettingEntryDialog_PreporocessorMacro,
- Messages.LanguageSettingEntryDialog_IncludeFile,
- Messages.LanguageSettingEntryDialog_PreprocessorMacroFile,
- Messages.LanguageSettingEntryDialog_LibraryPath,
- Messages.LanguageSettingEntryDialog_Library,
- };
- final private Image[] comboKindImages = {
- CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER),
+ final private String[] comboKindItems = { Messages.LanguageSettingEntryDialog_IncludeDirectory,
+ Messages.LanguageSettingEntryDialog_PreporocessorMacro, Messages.LanguageSettingEntryDialog_IncludeFile,
+ Messages.LanguageSettingEntryDialog_PreprocessorMacroFile, Messages.LanguageSettingEntryDialog_LibraryPath,
+ Messages.LanguageSettingEntryDialog_Library, };
+ final private Image[] comboKindImages = { CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TUNIT_HEADER),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACROS_FILE),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY_FOLDER),
- CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY),
- };
+ CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY), };
private static final int COMBO_PATH_INDEX_PROJECT = 0;
private static final int COMBO_PATH_INDEX_WORKSPACE = 1;
private static final int COMBO_PATH_INDEX_FILESYSTEM = 2;
- final private String[] pathCategories = {
- Messages.LanguageSettingEntryDialog_ProjectPath,
- Messages.LanguageSettingEntryDialog_WorkspacePath,
- Messages.LanguageSettingEntryDialog_Filesystem,
- };
- final private Image[] pathCategoryImages = {
- CDTSharedImages.getImage(CDTSharedImages.IMG_ETOOL_PROJECT),
+ final private String[] pathCategories = { Messages.LanguageSettingEntryDialog_ProjectPath,
+ Messages.LanguageSettingEntryDialog_WorkspacePath, Messages.LanguageSettingEntryDialog_Filesystem, };
+ final private Image[] pathCategoryImages = { CDTSharedImages.getImage(CDTSharedImages.IMG_ETOOL_PROJECT),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE),
- CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM),
- };
+ CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM), };
private ICLanguageSettingEntry[] entries;
-
public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, int kind) {
super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription;
@@ -127,7 +115,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
* This constructor is intended to be used with {@code clearValue=true} for "Add" dialogs
* where provided entry is used as a template.
*/
- public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, ICLanguageSettingEntry entry, boolean clearValue) {
+ public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription,
+ ICLanguageSettingEntry entry, boolean clearValue) {
super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject();
@@ -139,12 +128,13 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
/**
* This constructor is used for "Edit" dialogs to edit provided entry
*/
- public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, ICLanguageSettingEntry entry) {
+ public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription,
+ ICLanguageSettingEntry entry) {
this(parent, cfgDescription, entry, false);
}
private int comboIndexToKind(int index) {
- int kind=0;
+ int kind = 0;
switch (index) {
case COMBO_INDEX_INCLUDE_DIR:
kind = ICSettingEntry.INCLUDE_PATH;
@@ -169,7 +159,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
}
private int kindToComboIndex(int kind) {
- int index= 0;
+ int index = 0;
switch (kind) {
case ICSettingEntry.INCLUDE_PATH:
index = COMBO_INDEX_INCLUDE_DIR;
@@ -199,7 +189,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
GridData gd;
// Composite for the dialog area
- compositeArea = new Composite (parent, SWT.NONE);
+ compositeArea = new Composite(parent, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = SWT.TOP;
gd.horizontalSpan = 7;
@@ -207,7 +197,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
compositeArea.setLayout(new GridLayout(7, false));
// Icon for kind
- iconComboKind = new Label (compositeArea, SWT.NONE);
+ iconComboKind = new Label(compositeArea, SWT.NONE);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.RIGHT;
@@ -229,6 +219,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
updateImages();
setButtons();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@@ -237,7 +228,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
comboKind.setEnabled(clearValue);
// Icon for path category
- final Label comboPathCategoryIcon = new Label (compositeArea, SWT.NONE);
+ final Label comboPathCategoryIcon = new Label(compositeArea, SWT.NONE);
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END);
gd.verticalAlignment = SWT.TOP;
gd.widthHint = 15;
@@ -273,6 +264,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
updateImages();
setButtons();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@@ -303,7 +295,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
@Override
public void modifyText(ModifyEvent e) {
setButtons();
- }});
+ }
+ });
inputName.setFocus();
inputName.setSelection(0, inputName.getText().length());
@@ -353,7 +346,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
}
// Checkboxes
- Composite compCheckboxes = new Composite (parent, SWT.NONE);
+ Composite compCheckboxes = new Composite(parent, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = SWT.TOP;
gd.horizontalSpan = 4;
@@ -372,6 +365,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
updateImages();
setButtons();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@@ -390,6 +384,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
updateImages();
setButtons();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@@ -399,7 +394,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Framework folder"
checkBoxFramework = new Button(compCheckboxes, SWT.CHECK);
checkBoxFramework.setText(Messages.LanguageSettingEntryDialog_FrameworkFolder);
- checkBoxFramework.setSelection(initialEntry != null && (initialEntry.getFlags() & ICSettingEntry.FRAMEWORKS_MAC) != 0);
+ checkBoxFramework
+ .setSelection(initialEntry != null && (initialEntry.getFlags() & ICSettingEntry.FRAMEWORKS_MAC) != 0);
gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxFramework.setLayoutData(gd);
checkBoxFramework.addSelectionListener(new SelectionListener() {
@@ -408,6 +404,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
updateImages();
setButtons();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@@ -415,14 +412,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
});
// Buttons
- Composite compButtons = new Composite (parent, SWT.FILL);
+ Composite compButtons = new Composite(parent, SWT.FILL);
gd = new GridData(SWT.RIGHT, SWT.BOTTOM, false, false);
gd.horizontalSpan = 4;
gd.grabExcessVerticalSpace = true;
compButtons.setLayoutData(gd);
compButtons.setLayout(new GridLayout(4, false));
- // Placeholder
+ // Placeholder
Label placeholder = new Label(compButtons, 0);
placeholder.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
@@ -430,7 +427,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
buttonOk = new Button(compButtons, SWT.PUSH);
buttonOk.setText(IDialogConstants.OK_LABEL);
gd = new GridData();
- gd.widthHint = buttonVars.computeSize(SWT.DEFAULT,SWT.NONE).x;
+ gd.widthHint = buttonVars.computeSize(SWT.DEFAULT, SWT.NONE).x;
buttonOk.setLayoutData(gd);
buttonOk.addSelectionListener(new SelectionAdapter() {
@Override
@@ -507,8 +504,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
if (path.isEmpty()) {
buttonOk.setEnabled(false);
} else {
- buttonOk.setEnabled((isProjectSelected && !path.startsWith(SLASH)) ||
- (isWorkspaceSelected && path.startsWith(SLASH)) || isFilesystemSelected);
+ buttonOk.setEnabled((isProjectSelected && !path.startsWith(SLASH))
+ || (isWorkspaceSelected && path.startsWith(SLASH)) || isFilesystemSelected);
}
buttonVars.setEnabled(isFilesystemSelected);
@@ -525,13 +522,16 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
result = true;
String name = text1;
- int flagBuiltIn = checkBoxBuiltIn.isVisible() && checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
+ int flagBuiltIn = checkBoxBuiltIn.isVisible() && checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN
+ : 0;
int flags = flagBuiltIn;
int kind = comboKind.getSelectionIndex();
if (kind != COMBO_INDEX_MACRO) {
int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
- int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
+ int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection()
+ ? ICSettingEntry.FRAMEWORKS_MAC
+ : 0;
int indexPathKind = comboPathCategory.getSelectionIndex();
boolean isProjectPath = indexPathKind == COMBO_PATH_INDEX_PROJECT;
@@ -571,7 +571,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
result = false;
}
- entries = new ICLanguageSettingEntry[] {entry};
+ entries = new ICLanguageSettingEntry[] { entry };
shell.dispose();
} else if (e.widget.equals(buttonCancel)) {
shell.dispose();
@@ -620,7 +620,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
if (str != null) {
str = strip_wsp(str);
- if (comboPathCategory.getSelectionIndex() == COMBO_PATH_INDEX_PROJECT && str.startsWith(SLASH + project.getName() + SLASH)) {
+ if (comboPathCategory.getSelectionIndex() == COMBO_PATH_INDEX_PROJECT
+ && str.startsWith(SLASH + project.getName() + SLASH)) {
str = str.substring(project.getName().length() + 2);
}
inputName.setText(str);
@@ -645,7 +646,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
int flagBuiltin = checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
int flagSystem = checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
int flagFramework = checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
- boolean isWorkspacePath = indexPathKind == COMBO_PATH_INDEX_PROJECT || indexPathKind == COMBO_PATH_INDEX_WORKSPACE;
+ boolean isWorkspacePath = indexPathKind == COMBO_PATH_INDEX_PROJECT
+ || indexPathKind == COMBO_PATH_INDEX_WORKSPACE;
int flagWorkspace = isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED : 0;
int flags = flagBuiltin | flagWorkspace | flagSystem | flagFramework;
Image image = LanguageSettingsImages.getImage(kind, flags, indexPathKind == COMBO_PATH_INDEX_PROJECT);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
index dbc908333f2..b30cd8c8e3e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
@@ -138,7 +138,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (entriesParent != null) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_PARENT;
}
- } else if (provider instanceof ILanguageSettingsBroadcastingProvider && (page.isForFile() || page.isForFolder())) {
+ } else if (provider instanceof ILanguageSettingsBroadcastingProvider
+ && (page.isForFile() || page.isForFolder())) {
// Assuming that the default entries for a resource are always null.
// Using that for performance reasons. See note in performDefaults().
List<ICLanguageSettingEntry> entriesParent = provider.getSettingEntries(null, null, currentLanguageId);
@@ -199,7 +200,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return (Object[]) parentElement;
if (parentElement instanceof ILanguageSettingsProvider) {
- ILanguageSettingsProvider lsProvider = (ILanguageSettingsProvider)parentElement;
+ ILanguageSettingsProvider lsProvider = (ILanguageSettingsProvider) parentElement;
List<ICLanguageSettingEntry> entriesList = getSettingEntriesUpResourceTree(lsProvider);
if (entriesList == null) {
return null;
@@ -230,7 +231,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
@Override
public boolean hasChildren(Object element) {
Object[] children = getChildren(element);
- return children!=null && children.length>0;
+ return children != null && children.length > 0;
}
@Override
@@ -247,7 +248,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
* Shortcut for getting the current resource for the property page.
*/
private IResource getResource() {
- return (IResource)page.getElement();
+ return (IResource) page.getElement();
}
/**
@@ -274,7 +275,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
}
if (itemData instanceof ILanguageSettingsProvider) {
- provider = (ILanguageSettingsProvider)itemData;
+ provider = (ILanguageSettingsProvider) itemData;
}
}
@@ -292,7 +293,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
TreeItem item = items[0];
Object itemData = item.getData();
if (itemData instanceof ICLanguageSettingEntry) {
- entry = (ICLanguageSettingEntry)itemData;
+ entry = (ICLanguageSettingEntry) itemData;
}
}
@@ -308,7 +309,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private List<ICLanguageSettingEntry> getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
IResource rc = getResource();
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, cfgDescription, rc, currentLanguageId);
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider,
+ cfgDescription, rc, currentLanguageId);
return entries;
}
@@ -331,7 +333,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
String cfgId = cfgDescription.getId();
- List<ILanguageSettingsProvider> initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
initialProvidersMap.put(cfgId, initialProviders);
}
}
@@ -417,7 +420,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
- if (buttonIsEnabled(BUTTON_EDIT) && treeEntries.getSelection().length>0)
+ if (buttonIsEnabled(BUTTON_EDIT) && treeEntries.getSelection().length > 0)
buttonPressed(BUTTON_EDIT);
}
});
@@ -428,7 +431,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
* Create sash form.
*/
private void createSashForm() {
- sashFormEntries = new SashForm(usercomp,SWT.HORIZONTAL);
+ sashFormEntries = new SashForm(usercomp, SWT.HORIZONTAL);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
@@ -467,7 +470,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
usercomp.setLayout(new GridLayout());
GridData gd = (GridData) usercomp.getLayoutData();
// Discourage settings entry table from trying to show all its items at once, see bug 264330
- gd.heightHint =1;
+ gd.heightHint = 1;
if (page instanceof LanguageSettingsProvidersPage) {
masterPropertyPage = (LanguageSettingsProvidersPage) page;
@@ -589,7 +592,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
* Displays warning message - if any - for selected language settings entry.
*/
private void updateStatusLine() {
- IStatus status=null;
+ IStatus status = null;
if (masterPropertyPage.isLanguageSettingsProvidersEnabled()) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
status = LanguageSettingsImages.getStatus(getSelectedEntry(), cfgDescription);
@@ -599,12 +602,14 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
boolean isAllowedEditing = provider instanceof ILanguageSettingsEditableProvider
&& LanguageSettingsProviderAssociationManager.isAllowedToEditEntries(provider);
if (provider != null && !isAllowedEditing) {
- status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsEntriesTab_Entries_Not_Editable);
+ status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID,
+ Messages.LanguageSettingsEntriesTab_Entries_Not_Editable);
}
}
if (status == null || status == Status.OK_STATUS) {
if (treeLanguages.getItemCount() <= 0) {
- status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsEntriesTab_Cannot_Determine_Languages);
+ status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+ Messages.LanguageSettingsEntriesTab_Cannot_Determine_Languages);
}
}
fStatusLine.setErrorStatus(status);
@@ -669,7 +674,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
for (TreeItem providerItem : providerItems) {
Object providerItemData = providerItem.getData();
if (providerItemData instanceof ILanguageSettingsProvider) {
- ILanguageSettingsProvider provider = (ILanguageSettingsProvider)providerItemData;
+ ILanguageSettingsProvider provider = (ILanguageSettingsProvider) providerItemData;
if (provider.getId().equals(id)) {
return providerItem;
}
@@ -686,12 +691,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
for (TreeItem providerItem : providerItems) {
Object providerItemData = providerItem.getData();
if (providerItemData instanceof ILanguageSettingsProvider) {
- ILanguageSettingsProvider provider = (ILanguageSettingsProvider)providerItemData;
+ ILanguageSettingsProvider provider = (ILanguageSettingsProvider) providerItemData;
if (provider.getId().equals(providerId)) {
TreeItem[] entryItems = providerItem.getItems();
for (TreeItem entryItem : entryItems) {
Object entryItemData = entryItem.getData();
- if (entryItemData==entry)
+ if (entryItemData == entry)
return entryItem;
}
}
@@ -729,7 +734,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
List<ICLanguageSettingEntry> entries = getEntriesShownToUser(provider);
ICLanguageSettingEntry selectedEntry = getSelectedEntry();
int pos = getExactIndex(entries, selectedEntry);
- entries.add(pos+1, entry);
+ entries.add(pos + 1, entry);
saveEntries(provider, entries);
updateTreeForEntries(providerId, entry);
@@ -745,13 +750,15 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
IResource rc = getResource();
if (entries != null && rc != null) {
IContainer parent = rc instanceof IProject ? null : rc.getParent();
- List<ICLanguageSettingEntry> parentEntries = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, cfgDescription, parent, currentLanguageId);
+ List<ICLanguageSettingEntry> parentEntries = LanguageSettingsManager
+ .getSettingEntriesUpResourceTree(provider, cfgDescription, parent, currentLanguageId);
if (entries.equals(parentEntries)) {
// to use parent entries instead
entries = null;
}
}
- ((ILanguageSettingsEditableProvider)provider).setSettingEntries(cfgDescription, rc, currentLanguageId, entries);
+ ((ILanguageSettingsEditableProvider) provider).setSettingEntries(cfgDescription, rc, currentLanguageId,
+ entries);
}
}
@@ -777,11 +784,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (selectedProvider instanceof ILanguageSettingsEditableProvider) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
ICLanguageSettingEntry selectedEntry = getSelectedEntry();
- LanguageSettingEntryDialog addDialog = new LanguageSettingEntryDialog(usercomp.getShell(), cfgDescription, selectedEntry, true);
+ LanguageSettingEntryDialog addDialog = new LanguageSettingEntryDialog(usercomp.getShell(), cfgDescription,
+ selectedEntry, true);
if (addDialog.open()) {
ICLanguageSettingEntry settingEntry = addDialog.getEntries()[0];
if (settingEntry != null) {
- selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
+ selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider);
addEntry(selectedProvider, settingEntry);
}
}
@@ -796,7 +804,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId());
if (initialProviders.contains(provider)) {
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders());
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders());
int pos = providers.indexOf(provider);
if (pos >= 0) {
try {
@@ -804,10 +813,10 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
providers.set(pos, provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
} catch (CloneNotSupportedException e) {
- CUIPlugin.log("Internal Error: cannot clone provider "+provider.getId(), e); //$NON-NLS-1$
+ CUIPlugin.log("Internal Error: cannot clone provider " + provider.getId(), e); //$NON-NLS-1$
}
} else {
- CUIPlugin.log("Internal Error: cannot find provider "+provider.getId(), new Exception()); //$NON-NLS-1$
+ CUIPlugin.log("Internal Error: cannot find provider " + provider.getId(), new Exception()); //$NON-NLS-1$
}
}
return provider;
@@ -819,11 +828,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private void performEdit(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider && selectedEntry != null) {
ICConfigurationDescription cfgDecsription = getConfigurationDescription();
- LanguageSettingEntryDialog editDialog = new LanguageSettingEntryDialog(usercomp.getShell(), cfgDecsription, selectedEntry);
+ LanguageSettingEntryDialog editDialog = new LanguageSettingEntryDialog(usercomp.getShell(), cfgDecsription,
+ selectedEntry);
if (editDialog.open()) {
ICLanguageSettingEntry newEntry = editDialog.getEntries()[0];
if (newEntry != null) {
- selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
+ selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider);
replaceEntry(selectedProvider, selectedEntry, newEntry);
}
}
@@ -855,7 +865,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
/**
* Replace provider's entry and update UI.
*/
- private void replaceEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry oldEntry, ICLanguageSettingEntry newEntry) {
+ private void replaceEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry oldEntry,
+ ICLanguageSettingEntry newEntry) {
if (provider != null && oldEntry != null && newEntry != null) {
String providerId = provider.getId();
@@ -885,7 +896,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
*/
private void performDelete(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider) {
- selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
+ selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider);
if (selectedEntry != null) {
deleteEntry(selectedProvider, selectedEntry);
} else {
@@ -907,7 +918,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
ICLanguageSettingEntry newEntry = CDataUtil.createEntry(entry, flags);
if (newEntry != null) {
- provider = getWorkingCopy((ILanguageSettingsEditableProvider)provider);
+ provider = getWorkingCopy((ILanguageSettingsEditableProvider) provider);
replaceEntry(provider, entry, newEntry);
}
}
@@ -920,8 +931,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (provider instanceof ILanguageSettingsEditableProvider) {
List<ICLanguageSettingEntry> entries = getEntriesShownToUser(provider);
if (entries.size() > 0) {
- provider = getWorkingCopy((ILanguageSettingsEditableProvider)provider);
- for (int i = 0; i < entries.size() ; i++) {
+ provider = getWorkingCopy((ILanguageSettingsEditableProvider) provider);
+ for (int i = 0; i < entries.size(); i++) {
ICLanguageSettingEntry entry = entries.get(i);
int flags = entry.getFlags();
if (isExport) {
@@ -961,7 +972,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
List<ICLanguageSettingEntry> entries = getEntriesShownToUser(provider);
int pos = getExactIndex(entries, entry);
- int newPos = up ? pos-1 : pos+1;
+ int newPos = up ? pos - 1 : pos + 1;
Collections.swap(entries, pos, newPos);
saveEntries(provider, entries);
@@ -974,7 +985,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
*/
private void performMoveUp(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) {
- selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
+ selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider);
moveEntry(selectedProvider, selectedEntry, true);
}
}
@@ -984,7 +995,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
*/
private void performMoveDown(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) {
- selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
+ selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider);
moveEntry(selectedProvider, selectedEntry, false);
}
}
@@ -997,12 +1008,13 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
IResource rc = getResource();
ICConfigurationDescription cfgDescription = getConfigurationDescription();
if (rc != null && cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> cfgProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> cfgProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
for (ILanguageSettingsProvider cfgProvider : cfgProviders) {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(cfgProvider);
if (rawProvider instanceof LanguageSettingsBaseProvider) {
// filter out providers incapable of providing entries for this language
- List<String> languageIds = ((LanguageSettingsBaseProvider)rawProvider).getLanguageScope();
+ List<String> languageIds = ((LanguageSettingsBaseProvider) rawProvider).getLanguageScope();
if (languageIds != null && !languageIds.contains(currentLanguageId)) {
continue;
}
@@ -1015,7 +1027,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
/**
* Re-reads and refreshes the entries tree.
- *
+ *
* @param selectedProviderId - provider of the entry to select after update.
* If the entry is {@code null} the provider itself will be selected.
* @param selectedEntry - entry to select in the tree after update.
@@ -1070,14 +1082,15 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
// if no languages are defined keep null language as "Unspecified language"
languageIds.add(null);
}
-
+
// Use a TreeMap to sort the languages by name.
// For each name we keep a list of ids in case of name overlap.
Map<String, List<String>> map = new TreeMap<String, List<String>>();
for (String langId : languageIds) {
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
- String langName = language != null ? language.getName() : Messages.LanguageSettingsEntriesTab_UnspecifiedLanguage;
+ String langName = language != null ? language.getName()
+ : Messages.LanguageSettingsEntriesTab_UnspecifiedLanguage;
if (langName == null || langName.length() == 0)
continue;
List<String> langIds = map.get(langName);
@@ -1087,7 +1100,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
langIds.add(langId);
}
-
+
for (String langName : map.keySet()) {
List<String> langIds = map.get(langName);
for (String langId : langIds) {
@@ -1177,19 +1190,22 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
boolean changed = false;
IResource rc = getResource();
- List<ILanguageSettingsProvider> oldProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
- List<ILanguageSettingsProvider> newProviders = new ArrayList<ILanguageSettingsProvider>(oldProviders.size());
+ List<ILanguageSettingsProvider> oldProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> newProviders = new ArrayList<ILanguageSettingsProvider>(
+ oldProviders.size());
// clear entries for a given resource for all languages where applicable
- providers: for (ILanguageSettingsProvider provider : oldProviders) {
+ providers: for (ILanguageSettingsProvider provider : oldProviders) {
ILanguageSettingsEditableProvider providerCopy = null;
if (provider instanceof ILanguageSettingsEditableProvider) {
for (TreeItem langItems : treeLanguages.getItems()) {
- String langId = (String)langItems.getData();
+ String langId = (String) langItems.getData();
if (provider.getSettingEntries(cfgDescription, rc, langId) != null) {
if (providerCopy == null) {
// copy providers to be able to "Cancel" in UI
- providerCopy = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) provider, true);
+ providerCopy = LanguageSettingsManager
+ .getProviderCopy((ILanguageSettingsEditableProvider) provider, true);
if (providerCopy == null) {
continue providers;
}
@@ -1218,7 +1234,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
ICConfigurationDescription sd = srcRcDescription.getConfiguration();
ICConfigurationDescription dd = destRcDescription.getConfiguration();
if (sd instanceof ILanguageSettingsProvidersKeeper && dd instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> newProviders = ((ILanguageSettingsProvidersKeeper) sd).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> newProviders = ((ILanguageSettingsProvidersKeeper) sd)
+ .getLanguageSettingProviders();
((ILanguageSettingsProvidersKeeper) dd).setLanguageSettingProviders(newProviders);
}
}
@@ -1250,7 +1267,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
IResource rc = getResource();
if (rc instanceof IFile) {
try {
- ILanguage language = LanguageManager.getInstance().getLanguageForFile((IFile)rc, null);
+ ILanguage language = LanguageManager.getInstance().getLanguageForFile((IFile) rc, null);
return language != null;
} catch (CoreException e) {
// who cares, not even logging
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java
index da4f4078b13..4ebad2c04c1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java
@@ -39,11 +39,12 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
*/
public class LanguageSettingsImages {
// evaluates to "/${ProjName)/"
- private static final String PROJ_NAME_PREFIX = '/' + CdtVariableResolver.createVariableReference(CdtVariableResolver.VAR_PROJ_NAME) + '/';
+ private static final String PROJ_NAME_PREFIX = '/'
+ + CdtVariableResolver.createVariableReference(CdtVariableResolver.VAR_PROJ_NAME) + '/';
/**
* Check if the language settings entry should be presented as "project-relative" in UI.
- *
+ *
* @param entry - language settings entry to check.
* @return {@code true} if the entry should be displayed as "project-relative", {@code false} otherwise.
*/
@@ -57,7 +58,7 @@ public class LanguageSettingsImages {
/**
* Convert path used by {@link ICLanguageSettingEntry} to label representing project-relative portion.
- *
+ *
* @param path - path to convert to label in project-relative format.
* @return label to be used to display the path in UI.
*/
@@ -70,7 +71,7 @@ public class LanguageSettingsImages {
/**
* Convert label for project-relative path back to path representation carried by {@link ICLanguageSettingEntry}.
- *
+ *
* @param label - label in project-relative format.
* @return path to be used by {@link ICLanguageSettingEntry}.
*/
@@ -114,9 +115,10 @@ public class LanguageSettingsImages {
String[] overlayKeys = new String[5];
if ((flags & ICSettingEntry.UNDEFINED) != 0) {
- image = CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
+ image = CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE,
+ IDecoration.BOTTOM_LEFT);
} else {
- String overlayKeyStatus=null;
+ String overlayKeyStatus = null;
IStatus status = getStatus(entry, cfgDescription);
switch (status.getSeverity()) {
case IStatus.ERROR:
@@ -130,11 +132,11 @@ public class LanguageSettingsImages {
break;
}
if (overlayKeyStatus != null) {
- overlayKeys[IDecoration.BOTTOM_LEFT]=overlayKeyStatus;
+ overlayKeys[IDecoration.BOTTOM_LEFT] = overlayKeyStatus;
}
if ((flags & ICSettingEntry.EXPORTED) != 0) {
- overlayKeys[IDecoration.BOTTOM_RIGHT]=CDTSharedImages.IMG_OVR_EXPORTED;
+ overlayKeys[IDecoration.BOTTOM_RIGHT] = CDTSharedImages.IMG_OVR_EXPORTED;
}
image = CDTSharedImages.getImageOverlaid(imageKey, overlayKeys);
@@ -200,7 +202,7 @@ public class LanguageSettingsImages {
if (isWorkspacePath) {
IPath path = new Path(entry.getValue());
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
- exists = (rc !=null) && rc.isAccessible();
+ exists = (rc != null) && rc.isAccessible();
} else if (UNCPathConverter.isUNC(entry.getName())) {
return true;
} else {
@@ -221,23 +223,27 @@ public class LanguageSettingsImages {
public static IStatus getStatus(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
if (entry instanceof ACPathEntry) {
if (!entry.isResolved()) {
- ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] {entry}, cfgDescription);
+ ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] { entry },
+ cfgDescription);
if (entries != null && entries.length > 0) {
entry = entries[0];
}
}
- ACPathEntry acEntry = (ACPathEntry)entry;
+ ACPathEntry acEntry = (ACPathEntry) entry;
String acEntryName = acEntry.getName();
IPath path = new Path(acEntryName);
if (!path.isAbsolute()) {
- return new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_UsingRelativePathsNotRecommended);
+ return new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID,
+ Messages.LanguageSettingsImages_UsingRelativePathsNotRecommended);
}
if (!isLocationOk(acEntry)) {
if (acEntry.isFile()) {
- return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FileDoesNotExist);
+ return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ Messages.LanguageSettingsImages_FileDoesNotExist);
} else {
- return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FolderDoesNotExist);
+ return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ Messages.LanguageSettingsImages_FolderDoesNotExist);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java
index 3d76efdf5e1..65cd580fc59 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java
@@ -72,7 +72,8 @@ public class LanguageSettingsProviderAssociationManager {
isLoaded = true;
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
+ IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
@@ -127,7 +128,8 @@ public class LanguageSettingsProviderAssociationManager {
try {
String iconName = config.getAttribute(ATTR_ICON);
if (iconName != null) {
- URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
+ URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName())
+ .getEntry("/"); //$NON-NLS-1$
url = new URL(pluginInstallUrl, iconName);
if (loadedIcons.contains(url)) {
return url;
@@ -164,7 +166,8 @@ public class LanguageSettingsProviderAssociationManager {
if (fRegirestedIds.contains(providerId)) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
+ IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
@@ -184,7 +187,8 @@ public class LanguageSettingsProviderAssociationManager {
}
}
} catch (Exception e) {
- CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$
+ CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " //$NON-NLS-1$
+ + ext.getUniqueIdentifier(), e);
}
}
}
@@ -200,7 +204,8 @@ public class LanguageSettingsProviderAssociationManager {
if (fRegisteredClasses.contains(providerClassName)) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
+ IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
@@ -212,7 +217,7 @@ public class LanguageSettingsProviderAssociationManager {
String className = cfgEl.getAttribute(ATTR_CLASS);
if (providerClassName.equals(className)) {
String pageClass = cfgEl.getAttribute(ATTR_PAGE);
- if (pageClass!=null && pageClass.trim().length()>0) {
+ if (pageClass != null && pageClass.trim().length() > 0) {
ICOptionPage page = (ICOptionPage) cfgEl.createExecutableExtension(ATTR_PAGE);
return page;
}
@@ -220,7 +225,8 @@ public class LanguageSettingsProviderAssociationManager {
}
}
} catch (Exception e) {
- CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$
+ CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " //$NON-NLS-1$
+ + ext.getUniqueIdentifier(), e);
}
}
}
@@ -282,7 +288,7 @@ public class LanguageSettingsProviderAssociationManager {
}
Class<? extends ILanguageSettingsProvider> clazz = provider.getClass();
- outer: for (Class<?> c = clazz ;c != null; c = c.getSuperclass()) {
+ outer: for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
optionsPage = createOptionsPageByClass(c);
if (optionsPage != null) {
break;
@@ -324,7 +330,7 @@ public class LanguageSettingsProviderAssociationManager {
return Boolean.parseBoolean(properties.get(attr));
}
- for (Class<?> c = provider.getClass();c != null; c = c.getSuperclass()) {
+ for (Class<?> c = provider.getClass(); c != null; c = c.getSuperclass()) {
String className = c.getCanonicalName();
properties = fAssociationsByClass.get(className);
if (properties != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java
index 22e2f5c24d0..3d3911760a0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java
@@ -133,13 +133,15 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING;
}
} else if (page.isForPrefs()) {
- if (isWorkingCopy(provider) && !provider.equals(LanguageSettingsManager.getRawProvider(LanguageSettingsManager.getWorkspaceProvider(provider.getId())))) {
+ if (isWorkingCopy(provider) && !provider.equals(LanguageSettingsManager
+ .getRawProvider(LanguageSettingsManager.getWorkspaceProvider(provider.getId())))) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_EDITED;
} else if (!LanguageSettingsManager.getExtensionProviderIds().contains(provider.getId())) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_USER;
} else {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
- if (rawProvider instanceof ILanguageSettingsEditableProvider && !LanguageSettingsManager.isEqualExtensionProvider(rawProvider, false)) {
+ if (rawProvider instanceof ILanguageSettingsEditableProvider
+ && !LanguageSettingsManager.isEqualExtensionProvider(rawProvider, false)) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING;
}
}
@@ -198,12 +200,12 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
private boolean isWorkingCopy(ILanguageSettingsProvider provider) {
boolean isWorkingCopy = false;
if (page.isForPrefs()) {
- isWorkingCopy = ! LanguageSettingsManager.isWorkspaceProvider(provider);
+ isWorkingCopy = !LanguageSettingsManager.isWorkspaceProvider(provider);
} else {
if (!LanguageSettingsManager.isWorkspaceProvider(provider)) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
List<ILanguageSettingsProvider> initialProviders = initialProvidersByCfg.get(cfgDescription.getId());
- isWorkingCopy = initialProviders != null && ! initialProviders.contains(provider);
+ isWorkingCopy = initialProviders != null && !initialProviders.contains(provider);
}
}
@@ -228,7 +230,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
}
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
- ILanguageSettingsEditableProvider newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider)rawProvider, true);
+ ILanguageSettingsEditableProvider newProvider = LanguageSettingsManager
+ .getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, true);
if (newProvider != null) {
replaceSelectedProvider(newProvider);
// Warning: Do not initializeOptionsPage() here as the method can be called from an existing page
@@ -255,8 +258,10 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
String id = provider.getId();
ICConfigurationDescription cfgDescription = getConfigurationDescription();
- String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getDefaultLanguageSettingsProvidersIds();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
// check for the provider mismatch in configuration list vs. default list from the tool-chain
if (defaultIds != null && (Arrays.asList(defaultIds).contains(id) != providers.contains(provider))) {
@@ -274,7 +279,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
}
// check if configuration provider equals to the default one from extension point
- if (!LanguageSettingsManager.isWorkspaceProvider(provider) && !LanguageSettingsManager.isEqualExtensionProvider(provider, false)) {
+ if (!LanguageSettingsManager.isWorkspaceProvider(provider)
+ && !LanguageSettingsManager.isEqualExtensionProvider(provider, false)) {
return true;
}
@@ -297,7 +303,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
}
// check if "shared" flag matches that of initial provider
- if (providers.contains(provider) && LanguageSettingsManager.isWorkspaceProvider(initialProvider) != LanguageSettingsManager.isWorkspaceProvider(provider)) {
+ if (providers.contains(provider) && LanguageSettingsManager
+ .isWorkspaceProvider(initialProvider) != LanguageSettingsManager.isWorkspaceProvider(provider)) {
return true;
}
@@ -316,9 +323,10 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
*/
private boolean isPresentedAsShared(ILanguageSettingsProvider provider) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
- return LanguageSettingsManager.isWorkspaceProvider(provider) &&
- ( providers.contains(provider) || LanguageSettingsManager.isPreferShared(provider.getId()) );
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
+ return LanguageSettingsManager.isWorkspaceProvider(provider)
+ && (providers.contains(provider) || LanguageSettingsManager.isPreferShared(provider.getId()));
}
/**
@@ -344,7 +352,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
int pos = tableProviders.getSelectionIndex();
if (pos >= 0 && pos < tableProviders.getItemCount()) {
- provider = (ILanguageSettingsProvider)tableProvidersViewer.getElementAt(pos);
+ provider = (ILanguageSettingsProvider) tableProvidersViewer.getElementAt(pos);
}
return provider;
}
@@ -366,7 +374,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private List<ILanguageSettingsProvider> getCheckedProviders() {
- return (List)Arrays.asList(tableProvidersViewer.getCheckedElements());
+ return (List) Arrays.asList(tableProvidersViewer.getCheckedElements());
}
/**
@@ -404,7 +412,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
String cfgId = cfgDescription.getId();
- List<ILanguageSettingsProvider> initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
initialProvidersByCfg.put(cfgId, initialProviders);
}
}
@@ -440,12 +449,15 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
ILanguageSettingsProvider newProvider = null;
if (event.getChecked()) {
- if (LanguageSettingsManager.isWorkspaceProvider(checkedProvider) && !LanguageSettingsManager.isPreferShared(id)) {
+ if (LanguageSettingsManager.isWorkspaceProvider(checkedProvider)
+ && !LanguageSettingsManager.isPreferShared(id)) {
newProvider = getInitialProvider(id);
- if(newProvider == null) {
- ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(checkedProvider);
+ if (newProvider == null) {
+ ILanguageSettingsProvider rawProvider = LanguageSettingsManager
+ .getRawProvider(checkedProvider);
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
- newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false);
+ newProvider = LanguageSettingsManager
+ .getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false);
}
}
}
@@ -485,7 +497,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
} else {
// Toggle to configuration-owned provider
newProvider = getInitialProvider(id);
- if(newProvider == null || LanguageSettingsManager.isWorkspaceProvider(newProvider)) {
+ if (newProvider == null || LanguageSettingsManager.isWorkspaceProvider(newProvider)) {
try {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
@@ -523,8 +535,9 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
// globality changed
provider = toggleGlobalProvider(provider, isGlobal);
}
- projectStorageCheckBox.setSelection(provider instanceof LanguageSettingsSerializableProvider
- && LanguageSettingsManager.isStoringEntriesInProjectArea((LanguageSettingsSerializableProvider) provider));
+ projectStorageCheckBox.setSelection(
+ provider instanceof LanguageSettingsSerializableProvider && LanguageSettingsManager
+ .isStoringEntriesInProjectArea((LanguageSettingsSerializableProvider) provider));
}
@Override
@@ -546,12 +559,14 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
public void widgetSelected(SelectionEvent e) {
boolean inProjectArea = projectStorageCheckBox.getSelection();
ILanguageSettingsProvider newProvider = getWorkingCopy(getSelectedProvider().getId());
- LanguageSettingsManager.setStoringEntriesInProjectArea((LanguageSettingsSerializableProvider) newProvider, inProjectArea);
+ LanguageSettingsManager.setStoringEntriesInProjectArea(
+ (LanguageSettingsSerializableProvider) newProvider, inProjectArea);
replaceSelectedProvider(newProvider);
createOptionsPage(newProvider);
displaySelectedOptionPage();
updateButtons();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@@ -565,7 +580,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
private void createLinkToPreferences(final Composite parent, int span) {
linkToWorkspacePreferences = new Link(parent, SWT.NONE);
String href = NLS.bind("<a href=\"workspace\">{0}</a>", Messages.LanguageSettingsProviderTab_WorkspaceSettings); //$NON-NLS-1$
- linkToWorkspacePreferences.setText(NLS.bind(Messages.LanguageSettingsProviderTab_OptionsCanBeChangedInPreferencesDiscoveryTab, href));
+ linkToWorkspacePreferences.setText(
+ NLS.bind(Messages.LanguageSettingsProviderTab_OptionsCanBeChangedInPreferencesDiscoveryTab, href));
GridData gd = new GridData();
gd.horizontalSpan = span;
linkToWorkspacePreferences.setLayoutData(gd);
@@ -574,7 +590,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
@Override
public void handleEvent(Event event) {
// Use event.text to tell which link was used
- PreferencesUtil.createPreferenceDialogOn(parent.getShell(), WORKSPACE_PREFERENCE_PAGE, null, null).open();
+ PreferencesUtil.createPreferenceDialogOn(parent.getShell(), WORKSPACE_PREFERENCE_PAGE, null, null)
+ .open();
}
});
}
@@ -607,6 +624,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
public void controlResized(ControlEvent e) {
compositeOptionsPage.setBounds(compositeOptionsPage.getParent().getClientArea());
}
+
@Override
public void controlMoved(ControlEvent e) {
}
@@ -706,7 +724,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
} else {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(selectedProvider);
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
- ILanguageSettingsEditableProvider newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false);
+ ILanguageSettingsEditableProvider newProvider = LanguageSettingsManager
+ .getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false);
if (newProvider != null) {
replaceSelectedProvider(newProvider);
createOptionsPage(newProvider);
@@ -727,20 +746,23 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
if (page.isForPrefs()) {
newProvider = LanguageSettingsManager.getExtensionProviderCopy(id, true);
if (newProvider == null) {
- Status status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR, Messages.GeneralMessages_InternalError_ReportLogToCdtTeam,
- new Exception("Internal Error getting copy of provider id="+id)); //$NON-NLS-1$
+ Status status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR,
+ Messages.GeneralMessages_InternalError_ReportLogToCdtTeam,
+ new Exception("Internal Error getting copy of provider id=" + id)); //$NON-NLS-1$
fStatusLine.setErrorStatus(status);
CUIPlugin.log(status);
}
} else {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
- String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
+ String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getDefaultLanguageSettingsProvidersIds();
boolean isDefault = Arrays.asList(defaultIds).contains(id);
if (isDefault && !LanguageSettingsManager.isPreferShared(id)) {
newProvider = LanguageSettingsManager.getExtensionProviderCopy(id, true);
if (newProvider == null) {
- Status status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR, Messages.GeneralMessages_InternalError_ReportLogToCdtTeam,
- new Exception("Internal Error getting copy of provider id="+id)); //$NON-NLS-1$
+ Status status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR,
+ Messages.GeneralMessages_InternalError_ReportLogToCdtTeam,
+ new Exception("Internal Error getting copy of provider id=" + id)); //$NON-NLS-1$
fStatusLine.setErrorStatus(status);
CUIPlugin.log(status);
}
@@ -776,7 +798,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
private void performMoveUp(ILanguageSettingsProvider selectedProvider) {
int pos = presentedProviders.indexOf(selectedProvider);
if (pos > 0) {
- moveProvider(pos, pos-1);
+ moveProvider(pos, pos - 1);
}
}
@@ -787,7 +809,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
int pos = presentedProviders.indexOf(selectedProvider);
int last = presentedProviders.size() - 1;
if (pos >= 0 && pos < last) {
- moveProvider(pos, pos+1);
+ moveProvider(pos, pos + 1);
}
}
@@ -831,19 +853,21 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
boolean isRangeOk = (pos >= 0 && pos <= last);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
- boolean isAllowedClearing = rawProvider instanceof ILanguageSettingsEditableProvider && rawProvider instanceof LanguageSettingsSerializableProvider
+ boolean isAllowedClearing = rawProvider instanceof ILanguageSettingsEditableProvider
+ && rawProvider instanceof LanguageSettingsSerializableProvider
&& LanguageSettingsProviderAssociationManager.isAllowedToClear(rawProvider);
- boolean canClear = isAllowedClearing && (canForWorkspace || (canForProject && !LanguageSettingsManager.isWorkspaceProvider(provider)));
+ boolean canClear = isAllowedClearing
+ && (canForWorkspace || (canForProject && !LanguageSettingsManager.isWorkspaceProvider(provider)));
if (rawProvider instanceof LanguageSettingsSerializableProvider) {
- canClear = canClear && !((LanguageSettingsSerializableProvider)rawProvider).isEmpty();
+ canClear = canClear && !((LanguageSettingsSerializableProvider) rawProvider).isEmpty();
}
boolean canResetForProject = canForProject && isReconfiguredForProject(provider);
- boolean canResetForWorkspace = canForWorkspace &&
- (rawProvider instanceof ILanguageSettingsEditableProvider
+ boolean canResetForWorkspace = canForWorkspace
+ && (rawProvider instanceof ILanguageSettingsEditableProvider
&& !LanguageSettingsManager.isEqualExtensionProvider(rawProvider, false))
- && ( LanguageSettingsManager.getExtensionProviderIds().contains(rawProvider.getId()) );
+ && (LanguageSettingsManager.getExtensionProviderIds().contains(rawProvider.getId()));
boolean canReset = canResetForProject || canResetForWorkspace;
boolean canMoveUp = canForProject && isRangeOk && pos != 0;
@@ -891,12 +915,13 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
List<ILanguageSettingsProvider> providers;
ICConfigurationDescription cfgDescription = getConfigurationDescription();
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- providers = new ArrayList<ILanguageSettingsProvider>(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders());
+ providers = new ArrayList<ILanguageSettingsProvider>(
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders());
for (ILanguageSettingsProvider provider : providers) {
idsList.add(provider.getId());
}
} else {
- providers = new ArrayList<ILanguageSettingsProvider>();
+ providers = new ArrayList<ILanguageSettingsProvider>();
}
List<ILanguageSettingsProvider> allAvailableProvidersSet = LanguageSettingsManager.getWorkspaceProviders();
@@ -914,11 +939,11 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
presentedProviders = providers;
ILanguageSettingsProvider selectedProvider = getSelectedProvider();
- String selectedId = selectedProvider!=null ? selectedProvider.getId() : null;
+ String selectedId = selectedProvider != null ? selectedProvider.getId() : null;
tableProvidersViewer.setInput(presentedProviders);
- if (selectedId!=null) {
- for (int i=0; i<presentedProviders.size(); i++) {
+ if (selectedId != null) {
+ for (int i = 0; i < presentedProviders.size(); i++) {
if (selectedId.equals(presentedProviders.get(i).getId())) {
tableProviders.setSelection(i);
break;
@@ -939,7 +964,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
}
if (optionsPage instanceof AbstractLanguageSettingProviderOptionPage) {
- ((AbstractLanguageSettingProviderOptionPage)optionsPage).init(this, provider.getId());
+ ((AbstractLanguageSettingProviderOptionPage) optionsPage).init(this, provider.getId());
}
}
@@ -983,7 +1008,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
currentOptionsPage = optionsPageMap.get(id);
- if (!page.isForPrefs() ) {
+ if (!page.isForPrefs()) {
boolean isChecked = tableProvidersViewer.getChecked(provider);
boolean isShared = isPresentedAsShared(provider);
boolean isRawProviderEditable = rawProvider instanceof ILanguageSettingsEditableProvider;
@@ -994,8 +1019,9 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
projectStorageCheckBox.setVisible(rawProvider instanceof LanguageSettingsSerializableProvider);
projectStorageCheckBox.setEnabled(isChecked && !isShared);
- projectStorageCheckBox.setSelection(provider instanceof LanguageSettingsSerializableProvider
- && LanguageSettingsManager.isStoringEntriesInProjectArea((LanguageSettingsSerializableProvider) provider));
+ projectStorageCheckBox
+ .setSelection(provider instanceof LanguageSettingsSerializableProvider && LanguageSettingsManager
+ .isStoringEntriesInProjectArea((LanguageSettingsSerializableProvider) provider));
linkToWorkspacePreferences.setVisible(isShared && currentOptionsPage != null);
linkToWorkspacePreferences.setEnabled(isChecked);
@@ -1028,7 +1054,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> cfgProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> cfgProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
tableProvidersViewer.setCheckedElements(cfgProviders.toArray(new ILanguageSettingsProvider[0]));
}
@@ -1069,13 +1096,14 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
String cfgId = cfgDescription.getId();
if (!initialProvidersByCfg.containsKey(cfgId)) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
initialProvidersByCfg.put(cfgId, initialProviders);
}
}
}
- if (rcDes!=null) {
+ if (rcDes != null) {
if (page.isMultiCfg()) {
setAllVisible(false, null);
return;
@@ -1107,14 +1135,19 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
if (page.isForProject()) {
// set project LSP enablement to that of workspace
- masterPropertyPage.setLanguageSettingsProvidersEnabled(ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null));
+ masterPropertyPage.setLanguageSettingsProvidersEnabled(
+ ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null));
ICConfigurationDescription cfgDescription = getConfigurationDescription();
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> cfgProviders = new ArrayList<ILanguageSettingsProvider>(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders());
- String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
- List<ILanguageSettingsProvider> newProviders = LanguageSettingsManager.createLanguageSettingsProviders(defaultIds);
+ List<ILanguageSettingsProvider> cfgProviders = new ArrayList<ILanguageSettingsProvider>(
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders());
+ String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getDefaultLanguageSettingsProvidersIds();
+ List<ILanguageSettingsProvider> newProviders = LanguageSettingsManager
+ .createLanguageSettingsProviders(defaultIds);
if (!cfgProviders.equals(newProviders)) {
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(newProviders);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .setLanguageSettingProviders(newProviders);
}
}
@@ -1124,7 +1157,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(id);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
if (!LanguageSettingsManager.isEqualExtensionProvider(rawProvider, true)) {
- ILanguageSettingsProvider extProvider = LanguageSettingsManager.getExtensionProviderCopy(id, true);
+ ILanguageSettingsProvider extProvider = LanguageSettingsManager.getExtensionProviderCopy(id,
+ true);
if (extProvider != null) {
provider = extProvider;
}
@@ -1151,7 +1185,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
ICConfigurationDescription sd = srcRcDescription.getConfiguration();
ICConfigurationDescription dd = destRcDescription.getConfiguration();
if (sd instanceof ILanguageSettingsProvidersKeeper && dd instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> newProviders = ((ILanguageSettingsProvidersKeeper) sd).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> newProviders = ((ILanguageSettingsProvidersKeeper) sd)
+ .getLanguageSettingProviders();
((ILanguageSettingsProvidersKeeper) dd).setLanguageSettingProviders(newProviders);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java
index cfd3f5b3632..a28113a5581 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java
@@ -77,7 +77,7 @@ public class LanguageSettingsProvidersLabelProvider extends LabelProvider {
@Override
public Image getImage(Object element) {
if (element instanceof ILanguageSettingsProvider) {
- ILanguageSettingsProvider provider = (ILanguageSettingsProvider)element;
+ ILanguageSettingsProvider provider = (ILanguageSettingsProvider) element;
String imageKey = getBaseKey(provider);
String[] overlayKeys = getOverlayKeys(provider);
return CDTSharedImages.getImageOverlaid(imageKey, overlayKeys);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersPage.java
index e6090b17832..baa56976d7f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersPage.java
@@ -62,7 +62,8 @@ public class LanguageSettingsProvidersPage extends AbstractPage {
if (prj != null) {
if (!prj.equals(project)) {
project = prj;
- isLanguageSettingsProvidersEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project);
+ isLanguageSettingsProvidersEnabled = ScannerDiscoveryLegacySupport
+ .isLanguageSettingsProvidersFunctionalityEnabled(project);
}
return isLanguageSettingsProvidersEnabled;
}
@@ -81,7 +82,7 @@ public class LanguageSettingsProvidersPage extends AbstractPage {
public void setLanguageSettingsProvidersEnabled(boolean enable) {
isLanguageSettingsProvidersEnabled = enable;
project = getProject();
- forEach(ICPropertyTab.UPDATE,getResDesc());
+ forEach(ICPropertyTab.UPDATE, getResDesc());
}
/**
@@ -90,7 +91,8 @@ public class LanguageSettingsProvidersPage extends AbstractPage {
* @noreference This method is temporary and not intended to be referenced by clients.
*/
public void applyLanguageSettingsProvidersEnabled() {
- ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(getProject(), isLanguageSettingsProvidersEnabled);
+ ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(getProject(),
+ isLanguageSettingsProvidersEnabled);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java
index 83b01550857..35ca10559c4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java
@@ -27,11 +27,11 @@ import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionGroup;
/**
- * A basic abstract action group implementation similar to
+ * A basic abstract action group implementation similar to
* {@link org.eclipse.cdt.internal.ui.cview.CViewActionGroup}, avoiding
* the explicit dependency on {@link org.eclipse.cdt.internal.ui.cview.CView} to
* allow reuse in the Common Navigator.
- *
+ *
* @see org.eclipse.cdt.internal.ui.cview.CViewActionGroup
*/
public abstract class AbstractCNavigatorActionGroup extends ActionGroup {
@@ -43,7 +43,7 @@ public abstract class AbstractCNavigatorActionGroup extends ActionGroup {
/**
* Create a new action group associated with given view part.
- *
+ *
* @param viewPart
* the view part this action group is associated with, may not be
* <code>null</code>.
@@ -56,7 +56,7 @@ public abstract class AbstractCNavigatorActionGroup extends ActionGroup {
/**
* Provide access to the view part this action group has been registered with.
- *
+ *
* @return the view part
*/
protected IViewPart getViewPart() {
@@ -77,7 +77,7 @@ public abstract class AbstractCNavigatorActionGroup extends ActionGroup {
* Makes the actions contained in this action group.
*/
protected abstract void makeActions();
-
+
/*
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java
index 77942ebf86e..e3ff84f8d5d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java
@@ -51,8 +51,8 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
private BuildAction fCleanAction;
// Menu tags for the build
- final String BUILD_GROUP_MARKER= "buildGroup"; //$NON-NLS-1$
- final String BUILD_GROUP_MARKER_END= "end-buildGroup"; //$NON-NLS-1$
+ final String BUILD_GROUP_MARKER = "buildGroup"; //$NON-NLS-1$
+ final String BUILD_GROUP_MARKER_END = "end-buildGroup"; //$NON-NLS-1$
/**
* Create action group associated with given view part.
@@ -84,39 +84,39 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
*/
@Override
public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection selection= (IStructuredSelection) getContext().getSelection();
- boolean isProjectSelection= true;
- boolean hasOpenProjects= false;
- boolean hasClosedProjects= false;
- boolean hasBuilder= true; // false if any project is closed or does
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+ boolean isProjectSelection = true;
+ boolean hasOpenProjects = false;
+ boolean hasClosedProjects = false;
+ boolean hasBuilder = true; // false if any project is closed or does
// not have builder
- Iterator<?> resources= selection.iterator();
+ Iterator<?> resources = selection.iterator();
while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
- Object next= resources.next();
- IProject project= null;
+ Object next = resources.next();
+ IProject project = null;
if (next instanceof IProject) {
- project= (IProject) next;
+ project = (IProject) next;
} else if (next instanceof IAdaptable) {
- IResource res= ((IAdaptable)next).getAdapter(IResource.class);
+ IResource res = ((IAdaptable) next).getAdapter(IResource.class);
if (res instanceof IProject) {
- project= (IProject) res;
+ project = (IProject) res;
}
}
if (project == null) {
- isProjectSelection= false;
+ isProjectSelection = false;
continue;
}
if (project.isOpen()) {
- hasOpenProjects= true;
+ hasOpenProjects = true;
if (hasBuilder && !hasBuilder(project)) {
- hasBuilder= false;
+ hasBuilder = false;
}
} else {
- hasClosedProjects= true;
- hasBuilder= false;
+ hasClosedProjects = true;
+ hasBuilder = false;
}
}
@@ -127,8 +127,8 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
if (oldBuild != null) {
menu.insertAfter(BuildAction.ID_BUILD, fCleanAction);
// Replace ResourceMgmtActionProvier's build action with our own
- if (oldBuild instanceof ActionContributionItem &&
- ((ActionContributionItem)oldBuild).getAction() instanceof BuildAction) {
+ if (oldBuild instanceof ActionContributionItem
+ && ((ActionContributionItem) oldBuild).getAction() instanceof BuildAction) {
menu.remove(oldBuild);
menu.insertBefore(fCleanAction.getId(), fBuildAction);
}
@@ -150,8 +150,9 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
*/
boolean hasBuilder(IProject project) {
try {
- ICommand[] commands= project.getDescription().getBuildSpec();
- if (commands.length > 0) return true;
+ ICommand[] commands = project.getDescription().getBuildSpec();
+ if (commands.length > 0)
+ return true;
} catch (CoreException e) {
// Cannot determine if project has builders. Project is closed
// or does not exist. Fall through to return false.
@@ -161,8 +162,9 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
@Override
protected void makeActions() {
- fBuildAction = new BuildGroup.CDTBuildAction(getViewPart().getSite(), IncrementalProjectBuilder.INCREMENTAL_BUILD);
- fCleanAction= new BuildGroup.CDTBuildAction(getViewPart().getSite(), IncrementalProjectBuilder.CLEAN_BUILD);
+ fBuildAction = new BuildGroup.CDTBuildAction(getViewPart().getSite(),
+ IncrementalProjectBuilder.INCREMENTAL_BUILD);
+ fCleanAction = new BuildGroup.CDTBuildAction(getViewPart().getSite(), IncrementalProjectBuilder.CLEAN_BUILD);
fCleanAction.setText(CViewMessages.CleanAction_label);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java
index 0784b1cdfcf..a16d7096bb9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java
@@ -24,7 +24,7 @@ import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
/**
* A Common Navigator action provider providing the contributions
* from the build action group.
- *
+ *
* @see CNavigatorBuildActionGroup
*/
public class CNavigatorBuildActionProvider extends CommonActionProvider {
@@ -36,15 +36,15 @@ public class CNavigatorBuildActionProvider extends CommonActionProvider {
*/
@Override
public void init(ICommonActionExtensionSite site) {
- ICommonViewerWorkbenchSite workbenchSite= null;
+ ICommonViewerWorkbenchSite workbenchSite = null;
if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
- workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
+ workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite();
}
if (workbenchSite != null) {
if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
- IViewPart viewPart= (IViewPart) workbenchSite.getPart();
+ IViewPart viewPart = (IViewPart) workbenchSite.getPart();
- fBuildGroup= new CNavigatorBuildActionGroup(viewPart);
+ fBuildGroup = new CNavigatorBuildActionGroup(viewPart);
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java
index 71bb7e1b153..abb7c15a7d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java
@@ -70,28 +70,28 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
*/
@Override
public void init(ICommonContentExtensionSite commonContentExtensionSite) {
- IMemento memento= commonContentExtensionSite.getMemento();
+ IMemento memento = commonContentExtensionSite.getMemento();
restoreState(memento);
- fPropertyChangeListener= new IPropertyChangeListener() {
+ fPropertyChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
- boolean refreshViewer= false;
- String property= event.getProperty();
- Object newValue= event.getNewValue();
-
+ boolean refreshViewer = false;
+ String property = event.getProperty();
+ Object newValue = event.getNewValue();
+
if (property.equals(PreferenceConstants.PREF_SHOW_CU_CHILDREN)) {
- boolean showCUChildren= newValue instanceof Boolean ? ((Boolean)newValue).booleanValue() : false;
+ boolean showCUChildren = newValue instanceof Boolean ? ((Boolean) newValue).booleanValue() : false;
setProvideMembers(showCUChildren);
- refreshViewer= true;
+ refreshViewer = true;
} else if (property.equals(PreferenceConstants.CVIEW_GROUP_INCLUDES)) {
- boolean groupIncludes= newValue instanceof Boolean ? ((Boolean)newValue).booleanValue() : false;
+ boolean groupIncludes = newValue instanceof Boolean ? ((Boolean) newValue).booleanValue() : false;
setIncludesGrouping(groupIncludes);
- refreshViewer= true;
+ refreshViewer = true;
} else if (property.equals(PreferenceConstants.CVIEW_GROUP_MACROS)) {
- boolean groupMacros = newValue instanceof Boolean ? ((Boolean)newValue).booleanValue() : false;
+ boolean groupMacros = newValue instanceof Boolean ? ((Boolean) newValue).booleanValue() : false;
setMacroGrouping(groupMacros);
- refreshViewer= true;
+ refreshViewer = true;
}
if (refreshViewer && getViewer() != null) {
@@ -100,7 +100,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
}
};
CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
-
+
// Note that this listener listens to CCorePlugin preferences
fPreferenceChangeListener = new IPreferenceChangeListener() {
@Override
@@ -118,7 +118,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).addPreferenceChangeListener(fPreferenceChangeListener);
// TLETODO [CN] use extension state model for view options persistence
-// fStateModel.addPropertyChangeListener(listener);
+ // fStateModel.addPropertyChangeListener(listener);
}
/*
@@ -127,10 +127,10 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
@Override
public void dispose() {
InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).removePreferenceChangeListener(fPreferenceChangeListener);
-
+
CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
// TLETODO [CN] use extension state model for view options persistence
-// fStateModel.removePropertyChangeListener(fPropertyChangeListener);
+ // fStateModel.removePropertyChangeListener(fPropertyChangeListener);
super.dispose();
}
@@ -139,20 +139,20 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
*/
@Override
public void restoreState(IMemento memento) {
- IPreferenceStore store= PreferenceConstants.getPreferenceStore();
- boolean showCUChildren= store.getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
- boolean groupIncludes= store.getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
- boolean groupMacros= store.getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
+ IPreferenceStore store = PreferenceConstants.getPreferenceStore();
+ boolean showCUChildren = store.getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
+ boolean groupIncludes = store.getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
+ boolean groupMacros = store.getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
if (memento != null) {
// options controlled by preference only
-// String mementoValue= memento.getString(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
-// if (mementoValue != null) {
-// showCUChildren= Boolean.valueOf(mementoValue).booleanValue();
-// }
-// mementoValue= memento.getString(PreferenceConstants.CVIEW_GROUP_INCLUDES);
-// if (mementoValue != null) {
-// groupIncludes= Boolean.valueOf(mementoValue).booleanValue();
-// }
+ // String mementoValue= memento.getString(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
+ // if (mementoValue != null) {
+ // showCUChildren= Boolean.valueOf(mementoValue).booleanValue();
+ // }
+ // mementoValue= memento.getString(PreferenceConstants.CVIEW_GROUP_INCLUDES);
+ // if (mementoValue != null) {
+ // groupIncludes= Boolean.valueOf(mementoValue).booleanValue();
+ // }
}
setProvideMembers(showCUChildren);
setIncludesGrouping(groupIncludes);
@@ -177,7 +177,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- fRealInput= newInput;
+ fRealInput = newInput;
super.inputChanged(viewer, oldInput, findInputElement(newInput));
}
@@ -193,11 +193,11 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
*/
@Override
public Object getParent(Object element) {
- Object parent= super.getParent(element);
+ Object parent = super.getParent(element);
if (parent instanceof ICModel) {
return getViewerInput() != null ? fRealInput : parent;
} else if (parent instanceof ICProject)
- return ((ICProject)parent).getProject();
+ return ((ICProject) parent).getProject();
return parent;
}
@@ -223,9 +223,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
@Override
public Object[] getElements(Object parent) {
if (parent instanceof IWorkspaceRoot) {
- return ((IWorkspaceRoot)parent).getProjects();
+ return ((IWorkspaceRoot) parent).getProjects();
} else if (parent instanceof IProject) {
- return super.getChildren(CoreModel.getDefault().create((IProject)parent));
+ return super.getChildren(CoreModel.getDefault().create((IProject) parent));
}
return super.getElements(parent);
}
@@ -237,12 +237,12 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
public Object[] getChildren(Object element) {
Object children[];
if (element instanceof IWorkspaceRoot) {
- return ((IWorkspaceRoot)element).getProjects();
+ return ((IWorkspaceRoot) element).getProjects();
} else if (element instanceof IProject) {
CModel cModel = CModelManager.getDefault().getCModel();
- ICProject prj = cModel.findCProject((IProject)element);
- if(prj == null) {
- prj = CoreModel.getDefault().create((IProject)element);
+ ICProject prj = cModel.findCProject((IProject) element);
+ if (prj == null) {
+ prj = CoreModel.getDefault().create((IProject) element);
}
return super.getChildren(prj);
} else {
@@ -257,12 +257,12 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
@Override
public boolean hasChildren(Object element) {
if (element instanceof IProject) {
- IProject project= (IProject) element;
+ IProject project = (IProject) element;
return project.isAccessible();
}
return super.hasChildren(element);
}
-
+
/*
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set)
*/
@@ -285,25 +285,25 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
}
private void customizeCElements(Object[] cChildren, Set<Object> proposedChildren) {
- List<Object> elementList= Arrays.asList(cChildren);
+ List<Object> elementList = Arrays.asList(cChildren);
for (Object element : proposedChildren) {
- IResource resource= null;
+ IResource resource = null;
if (element instanceof IResource) {
- resource= (IResource)element;
+ resource = (IResource) element;
} else if (element instanceof IAdaptable) {
- resource= ((IAdaptable)element).getAdapter(IResource.class);
+ resource = ((IAdaptable) element).getAdapter(IResource.class);
}
if (resource != null) {
- int i= elementList.indexOf(resource);
+ int i = elementList.indexOf(resource);
if (i >= 0) {
- cChildren[i]= null;
+ cChildren[i] = null;
}
}
}
for (Object element : cChildren) {
if (element instanceof ICElement) {
- ICElement cElement= (ICElement)element;
- IResource resource= cElement.getResource();
+ ICElement cElement = (ICElement) element;
+ IResource resource = cElement.getResource();
if (resource != null) {
proposedChildren.remove(resource);
}
@@ -330,11 +330,11 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
Object parent = addModification.getParent();
if (parent instanceof ICProject) {
if (fRealInput instanceof IWorkspaceRoot) {
- addModification.setParent(((ICProject)parent).getProject());
+ addModification.setParent(((ICProject) parent).getProject());
}
} else if (parent instanceof IProject || parent instanceof IFolder) {
// ignore adds to C projects (we are issuing a refresh)
- IProject project= ((IResource) parent).getProject();
+ IProject project = ((IResource) parent).getProject();
if (CoreModel.hasCNature(project)) {
addModification.getChildren().clear();
return addModification;
@@ -342,9 +342,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
} else if (parent instanceof IWorkspaceRoot) {
// ignore adds of C projects (we are issuing a refresh)
for (Iterator<?> iterator = addModification.getChildren().iterator(); iterator.hasNext();) {
- Object child= iterator.next();
+ Object child = iterator.next();
if (child instanceof IProject) {
- if (CoreModel.hasCNature((IProject)child)) {
+ if (CoreModel.hasCNature((IProject) child)) {
iterator.remove();
}
}
@@ -387,23 +387,22 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
/**
* Converts the shape modification to use ICElements.
- *
+ *
* @param modification
* the shape modification to convert
* @return <code>true</code> if the shape modification set was modified
*/
- private boolean convertToCElements(
- PipelinedShapeModification modification) {
- Object parent= modification.getParent();
+ private boolean convertToCElements(PipelinedShapeModification modification) {
+ Object parent = modification.getParent();
// don't convert projects
if (parent instanceof IContainer) {
- IContainer container= (IContainer)parent;
- IProject project= container.getProject();
+ IContainer container = (IContainer) parent;
+ IProject project = container.getProject();
if (project != null && CoreModel.hasCNature(project)) {
- ICElement element= CoreModel.getDefault().create(container);
+ ICElement element = CoreModel.getDefault().create(container);
if (element != null) {
// don't convert the root
- if( !(element instanceof ICModel) && !(element instanceof ICProject) ) {
+ if (!(element instanceof ICModel) && !(element instanceof ICProject)) {
modification.setParent(element);
}
@SuppressWarnings("unchecked")
@@ -417,22 +416,22 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
/**
* Converts the given set to ICElements.
- *
+ *
* @param currentChildren
* The set of current children that would be contributed or
* refreshed in the viewer.
* @return <code>true</code> if the input set was modified
*/
private boolean convertToCElements(Set<Object> currentChildren) {
- LinkedHashSet<ICElement> convertedChildren= new LinkedHashSet<ICElement>();
+ LinkedHashSet<ICElement> convertedChildren = new LinkedHashSet<ICElement>();
ICElement newChild;
- for (Iterator<Object> iter= currentChildren.iterator(); iter.hasNext();) {
- Object child= iter.next();
+ for (Iterator<Object> iter = currentChildren.iterator(); iter.hasNext();) {
+ Object child = iter.next();
// do not convert IProject
if (child instanceof IFile || child instanceof IFolder) {
- IResource resource= (IResource)child;
+ IResource resource = (IResource) child;
if (resource.isAccessible() && CoreModel.hasCNature(resource.getProject())) {
- if ((newChild= CoreModel.getDefault().create(resource)) != null) {
+ if ((newChild = CoreModel.getDefault().create(resource)) != null) {
iter.remove();
convertedChildren.add(newChild);
}
@@ -450,17 +449,18 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
protected void postContainerRefresh(final IParent container, final ICProject cproject) {
postRefreshable(new RefreshContainer(container, cproject.getProject()));
}
+
@Override
protected void postRefresh(final Object element) {
if (element instanceof ICModel) {
// don't refresh workspace root
-// super.postRefresh(fRealInput);
+ // super.postRefresh(fRealInput);
} else if (element instanceof ICProject) {
- super.postRefresh(((ICProject)element).getProject());
+ super.postRefresh(((ICProject) element).getProject());
} else if (element instanceof ICElement) {
super.postRefresh(element);
} else if (element instanceof IResource) {
- IProject project= ((IResource)element).getProject();
+ IProject project = ((IResource) element).getProject();
if (CoreModel.hasCNature(project)) {
super.postRefresh(element);
}
@@ -473,16 +473,16 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
if (element instanceof ICElement) {
super.postAdd(fRealInput, element);
} else if (element instanceof IProject) {
- if (CoreModel.hasCNature((IProject)element)) {
+ if (CoreModel.hasCNature((IProject) element)) {
super.postAdd(fRealInput, element);
}
}
} else if (parent instanceof ICProject) {
- super.postAdd(((ICProject)parent).getProject(), element);
+ super.postAdd(((ICProject) parent).getProject(), element);
} else if (parent instanceof ICElement) {
super.postAdd(parent, element);
} else if (element instanceof IResource) {
- IProject project= ((IResource)element).getProject();
+ IProject project = ((IResource) element).getProject();
if (CoreModel.hasCNature(project)) {
super.postAdd(parent, element);
}
@@ -499,7 +499,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
if (element instanceof ICModel) {
super.postProjectStateChanged(fRealInput);
} else if (element instanceof ICProject) {
- super.postProjectStateChanged(((ICProject)element).getProject());
+ super.postProjectStateChanged(((ICProject) element).getProject());
} else {
super.postProjectStateChanged(element);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java
index 15f35d9028a..e2b84cfaa07 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java
@@ -30,18 +30,16 @@ import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
/**
- * A Common Navigator drag assistant supporting <code>LocalSelectionTransfer</code> of
- * <code>ICElement</code>s being also <code>ISourceReference</code>s and
+ * A Common Navigator drag assistant supporting <code>LocalSelectionTransfer</code> of
+ * <code>ICElement</code>s being also <code>ISourceReference</code>s and
* <code>FileTransfer</code> for external translation units.
- *
+ *
* @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter
*/
public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
- private static final Transfer[] TRANSFERS = new Transfer[] {
- LocalSelectionTransfer.getTransfer(),
- FileTransfer.getInstance()
- };
+ private static final Transfer[] TRANSFERS = new Transfer[] { LocalSelectionTransfer.getTransfer(),
+ FileTransfer.getInstance() };
/*
* @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#getSupportedTransferTypes()
@@ -58,9 +56,9 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
public boolean setDragData(DragSourceEvent event, IStructuredSelection selection) {
if (selection != null) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
- boolean applicable= false;
- for (Iterator<?> iter= (selection).iterator(); iter.hasNext();) {
- Object element= iter.next();
+ boolean applicable = false;
+ for (Iterator<?> iter = (selection).iterator(); iter.hasNext();) {
+ Object element = iter.next();
if (element instanceof ICElement) {
if (element instanceof ITranslationUnit) {
continue;
@@ -68,7 +66,7 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
if (!(element instanceof ISourceReference)) {
return false;
}
- applicable= true;
+ applicable = true;
}
}
if (applicable) {
@@ -76,12 +74,12 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
return true;
}
} else if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
- List<String> files= new ArrayList<String>();
- for (Iterator<?> iter= (selection).iterator(); iter.hasNext();) {
- Object element= iter.next();
+ List<String> files = new ArrayList<String>();
+ for (Iterator<?> iter = (selection).iterator(); iter.hasNext();) {
+ Object element = iter.next();
if (element instanceof ITranslationUnit) {
- ITranslationUnit tu= (ITranslationUnit) element;
- IPath location= tu.getLocation();
+ ITranslationUnit tu = (ITranslationUnit) element;
+ IPath location = tu.getLocation();
if (location != null) {
files.add(location.toOSString());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java
index eb401aea26f..179ee7c4018 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java
@@ -61,7 +61,7 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
/**
* A Common Navigator drop adapter assistant handling dropping of <code>ICElement</code>s.
- *
+ *
* @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter
*/
public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
@@ -73,8 +73,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
*/
@Override
public boolean isSupportedType(TransferData transferType) {
- return super.isSupportedType(transferType)
- || ResourceTransfer.getInstance().isSupportedType(transferType)
+ return super.isSupportedType(transferType) || ResourceTransfer.getInstance().isSupportedType(transferType)
|| FileTransfer.getInstance().isSupportedType(transferType);
}
@@ -82,31 +81,26 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
*/
@Override
- public IStatus handleDrop(CommonDropAdapter dropAdapter,
- DropTargetEvent event, Object target) {
+ public IStatus handleDrop(CommonDropAdapter dropAdapter, DropTargetEvent event, Object target) {
try {
// drop in folder
- if (target instanceof ICContainer ||
- target instanceof ICProject ||
- target instanceof IContainer ||
- (dropAdapter.getCurrentOperation() == DND.DROP_COPY && (
- target instanceof IFile ||
- target instanceof ITranslationUnit))) {
-
- final Object data= event.data;
+ if (target instanceof ICContainer || target instanceof ICProject || target instanceof IContainer
+ || (dropAdapter.getCurrentOperation() == DND.DROP_COPY
+ && (target instanceof IFile || target instanceof ITranslationUnit))) {
+
+ final Object data = event.data;
if (data == null) {
return Status.CANCEL_STATUS;
}
- final IContainer destination= getDestination(target);
+ final IContainer destination = getDestination(target);
if (destination == null) {
return Status.CANCEL_STATUS;
}
IResource[] resources = null;
TransferData currentTransfer = dropAdapter.getCurrentTransfer();
final int dropOperation = dropAdapter.getCurrentOperation();
- if (LocalSelectionTransfer.getTransfer().isSupportedType(
- currentTransfer)) {
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(currentTransfer)) {
resources = getSelectedResources();
if (target instanceof ITranslationUnit) {
if (handleDropCopy(target, event).isOK()) {
@@ -114,48 +108,47 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
return Status.OK_STATUS;
}
}
- } else if (ResourceTransfer.getInstance().isSupportedType(
- currentTransfer)) {
+ } else if (ResourceTransfer.getInstance().isSupportedType(currentTransfer)) {
resources = (IResource[]) event.data;
}
if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
final String[] names = (String[]) data;
- // Run the import operation asynchronously.
- // Otherwise the drag source (e.g., Windows Explorer) will be blocked
+ // Run the import operation asynchronously.
+ // Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 35796.
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
getShell().forceActive();
- CopyFilesAndFoldersOperation op= new CopyFilesAndFoldersOperation(getShell());
+ CopyFilesAndFoldersOperation op = new CopyFilesAndFoldersOperation(getShell());
op.copyOrLinkFiles(names, destination, dropOperation);
}
});
} else if (event.detail == DND.DROP_COPY || event.detail == DND.DROP_LINK) {
return performResourceCopy(dropAdapter, getShell(), resources);
} else {
- ReadOnlyStateChecker checker = new ReadOnlyStateChecker(
- getShell(),
- "Move Resource Action", //$NON-NLS-1$
- "Move Resource Action");//$NON-NLS-1$
+ ReadOnlyStateChecker checker = new ReadOnlyStateChecker(getShell(), "Move Resource Action", //$NON-NLS-1$
+ "Move Resource Action");//$NON-NLS-1$
resources = checker.checkReadOnlyResources(resources);
MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell());
operation.copyResources(resources, destination);
}
return Status.OK_STATUS;
}
-
- switch(event.detail) {
- case DND.DROP_MOVE:
- return handleDropMove(target, event);
- case DND.DROP_COPY:
- return handleDropCopy(target, event);
+
+ switch (event.detail) {
+ case DND.DROP_MOVE:
+ return handleDropMove(target, event);
+ case DND.DROP_COPY:
+ return handleDropCopy(target, event);
}
- } catch (CModelException e){
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message);
+ } catch (CModelException e) {
+ ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title,
+ CViewMessages.SelectionTransferDropAdapter_error_message);
return e.getStatus();
- } catch(InvocationTargetException e) {
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_exception);
+ } catch (InvocationTargetException e) {
+ ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title,
+ CViewMessages.SelectionTransferDropAdapter_error_exception);
return Status.CANCEL_STATUS;
} catch (InterruptedException e) {
//ok
@@ -163,7 +156,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
// The drag source listener must not perform any operation
// since this drop adapter did the remove of the source even
// if we moved something.
- event.detail= DND.DROP_NONE;
+ event.detail = DND.DROP_NONE;
}
return Status.CANCEL_STATUS;
}
@@ -172,22 +165,17 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
*/
@Override
- public IStatus validateDrop(Object target, int operation,
- TransferData transferType) {
+ public IStatus validateDrop(Object target, int operation, TransferData transferType) {
// drop in folder
- if (target instanceof ICContainer ||
- target instanceof ICProject ||
- target instanceof IContainer ||
- (operation == DND.DROP_COPY && (
- target instanceof IFile ||
- target instanceof ITranslationUnit))) {
- IContainer destination= getDestination(target);
+ if (target instanceof ICContainer || target instanceof ICProject || target instanceof IContainer
+ || (operation == DND.DROP_COPY && (target instanceof IFile || target instanceof ITranslationUnit))) {
+ IContainer destination = getDestination(target);
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
- IResource[] selectedResources= getSelectedResources();
+ IResource[] selectedResources = getSelectedResources();
if (selectedResources.length > 0) {
for (IResource res : selectedResources) {
- if(res instanceof IProject) {
+ if (res instanceof IProject) {
// drop of projects not supported on other IResources
// "Path for project must have only one segment."
return Status.CANCEL_STATUS;
@@ -213,10 +201,8 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
// Fixes bug 29778
sourceNames = new String[0];
}
- CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(
- getShell());
- if (null != copyOperation.validateImportDestination(destination,
- sourceNames)) {
+ CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(getShell());
+ if (null != copyOperation.validateImportDestination(destination, sourceNames)) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
@@ -225,33 +211,34 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
try {
- switch(operation) {
- case DND.DROP_DEFAULT:
- return handleValidateMove(target);
- case DND.DROP_COPY:
- return handleValidateCopy(target);
- case DND.DROP_MOVE:
- return handleValidateMove(target);
+ switch (operation) {
+ case DND.DROP_DEFAULT:
+ return handleValidateMove(target);
+ case DND.DROP_COPY:
+ return handleValidateCopy(target);
+ case DND.DROP_MOVE:
+ return handleValidateMove(target);
}
- } catch (CModelException e){
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message);
+ } catch (CModelException e) {
+ ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title,
+ CViewMessages.SelectionTransferDropAdapter_error_message);
}
}
return Status.CANCEL_STATUS;
}
- private IStatus handleValidateCopy(Object target) throws CModelException{
+ private IStatus handleValidateCopy(Object target) throws CModelException {
if (target != null) {
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
- ICElement[] cElements= getCElements(selection);
-
+ ICElement[] cElements = getCElements(selection);
+
if (cElements == null || cElements.length == 0) {
- return Status.CANCEL_STATUS;
+ return Status.CANCEL_STATUS;
}
if (!canCopyElements(cElements))
- return Status.CANCEL_STATUS;
-
+ return Status.CANCEL_STATUS;
+
if (target instanceof ISourceReference) {
for (ICElement cElement : cElements) {
if (cElement.getElementType() <= ICElement.C_UNIT) {
@@ -260,7 +247,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
}
return Status.OK_STATUS;
}
-
+
}
return Status.CANCEL_STATUS;
}
@@ -269,16 +256,16 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
if (target != null) {
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
- ICElement[] cElements= getCElements(selection);
+ ICElement[] cElements = getCElements(selection);
if (cElements == null || cElements.length == 0) {
- return Status.CANCEL_STATUS;
+ return Status.CANCEL_STATUS;
}
if (Arrays.asList(cElements).contains(target)) {
- return Status.CANCEL_STATUS;
+ return Status.CANCEL_STATUS;
}
if (!canMoveElements(cElements)) {
- return Status.CANCEL_STATUS;
+ return Status.CANCEL_STATUS;
}
if (target instanceof ISourceReference) {
for (ICElement cElement : cElements) {
@@ -288,7 +275,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
}
return Status.OK_STATUS;
}
-
+
}
return Status.CANCEL_STATUS;
}
@@ -297,13 +284,12 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
* Performs a resource copy.
* Cloned from ResourceDropAdapterAssistant to support linked resources (bug 319405).
*/
- private IStatus performResourceCopy(CommonDropAdapter dropAdapter,
- Shell shell, IResource[] sources) {
+ private IStatus performResourceCopy(CommonDropAdapter dropAdapter, Shell shell, IResource[] sources) {
IContainer target = getDestination(dropAdapter.getCurrentTarget());
if (target == null) {
return Status.CANCEL_STATUS;
}
-
+
boolean shouldLinkAutomatically = false;
if (target.isVirtual()) {
shouldLinkAutomatically = true;
@@ -335,7 +321,8 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
// if all sources are either links or groups, copy then normally,
// don't show the dialog
if (!allSourceAreLinksOrVirtualFolders) {
- ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
+ ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources,
+ target);
dialog.setResource(target);
if (dialog.open() == Window.OK) {
if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
@@ -354,12 +341,13 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
return Status.OK_STATUS;
}
- private IStatus handleDropCopy(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
+ private IStatus handleDropCopy(final Object target, DropTargetEvent event)
+ throws CModelException, InvocationTargetException, InterruptedException {
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
- final ICElement[] cElements= getCElements(selection);
+ final ICElement[] cElements = getCElements(selection);
if (target instanceof ICElement && cElements.length > 0) {
- ICElement cTarget = (ICElement)target;
+ ICElement cTarget = (ICElement) target;
ICElement parent = cTarget;
boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
if (!isTargetTranslationUnit) {
@@ -393,12 +381,13 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
return Status.CANCEL_STATUS;
}
- private IStatus handleDropMove(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
+ private IStatus handleDropMove(final Object target, DropTargetEvent event)
+ throws CModelException, InvocationTargetException, InterruptedException {
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
- final ICElement[] cElements= getCElements(selection);
-
+ final ICElement[] cElements = getCElements(selection);
+
if (target instanceof ICElement) {
- ICElement cTarget = (ICElement)target;
+ ICElement cTarget = (ICElement) target;
ICElement parent = cTarget;
boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
if (!isTargetTranslationUnit) {
@@ -433,7 +422,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
}
public void run(IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException {
- IRunnableContext context= new ProgressMonitorDialog(getShell());
+ IRunnableContext context = new ProgressMonitorDialog(getShell());
context.run(true, true, runnable);
}
@@ -441,8 +430,8 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
if (!(selection instanceof IStructuredSelection)) {
return null;
}
- List<?> elements = ((IStructuredSelection)selection).toList();
- List<Object> resources= new ArrayList<Object>(elements.size());
+ List<?> elements = ((IStructuredSelection) selection).toList();
+ List<Object> resources = new ArrayList<Object>(elements.size());
for (Object element : elements) {
if (element instanceof ITranslationUnit) {
continue;
@@ -458,25 +447,24 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
return hasCommonParent(cElements);
}
return false;
- }
-
+ }
+
private static boolean canMoveElements(ICElement[] cElements) {
if (cElements != null) {
return hasCommonParent(cElements);
}
return false;
- }
-
+ }
+
private static boolean hasCommonParent(ICElement[] elements) {
if (elements.length > 1) {
ICElement parent = elements[0];
for (int i = 0; i < elements.length; ++i) {
ICElement p = elements[i].getParent();
if (parent == null) {
- if (p!= null)
+ if (p != null)
return false;
- }
- else if (!parent.equals(p))
+ } else if (!parent.equals(p))
return false;
}
}
@@ -485,33 +473,32 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
private IContainer getDestination(Object dropTarget) {
if (dropTarget instanceof IContainer) {
- return (IContainer)dropTarget;
+ return (IContainer) dropTarget;
} else if (dropTarget instanceof ICElement) {
- return getDestination(((ICElement)dropTarget).getResource());
+ return getDestination(((ICElement) dropTarget).getResource());
} else if (dropTarget instanceof IFile) {
- return ((IFile)dropTarget).getParent();
+ return ((IFile) dropTarget).getParent();
}
return null;
}
/**
* Returns the resource selection from the LocalSelectionTransfer.
- *
+ *
* @return the resource selection from the LocalSelectionTransfer
*/
private IResource[] getSelectedResources() {
- ISelection selection = LocalSelectionTransfer.getTransfer()
- .getSelection();
+ ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (selection instanceof IStructuredSelection) {
- return getSelectedResources((IStructuredSelection)selection);
- }
+ return getSelectedResources((IStructuredSelection) selection);
+ }
return NO_RESOURCES;
}
/**
* Returns the resource selection from the LocalSelectionTransfer.
- *
+ *
* @return the resource selection from the LocalSelectionTransfer
*/
private IResource[] getSelectedResources(IStructuredSelection selection) {
@@ -529,8 +516,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
}
}
}
- return selectedResources
- .toArray(new IResource[selectedResources.size()]);
+ return selectedResources.toArray(new IResource[selectedResources.size()]);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java
index ff29f07c284..5b81d2844ba 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java
@@ -46,7 +46,7 @@ public class CNavigatorEditActionGroup extends ActionGroup {
private DeleteResourceAction deleteAction;
- private PasteAction pasteAction;
+ private PasteAction pasteAction;
private TextActionHandler textActionHandler;
@@ -56,7 +56,7 @@ public class CNavigatorEditActionGroup extends ActionGroup {
* @param aShell
*/
public CNavigatorEditActionGroup(Shell aShell) {
- shell = aShell;
+ shell = aShell;
makeActions();
}
@@ -73,9 +73,8 @@ public class CNavigatorEditActionGroup extends ActionGroup {
public void fillContextMenu(IMenuManager menu) {
IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
- boolean anyResourceSelected = !selection.isEmpty()
- && ResourceSelectionUtil.allResourcesAreOfType(selection,
- IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+ boolean anyResourceSelected = !selection.isEmpty() && ResourceSelectionUtil.allResourcesAreOfType(selection,
+ IResource.PROJECT | IResource.FOLDER | IResource.FILE);
copyAction.selectionChanged(selection);
menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, copyAction);
@@ -101,14 +100,14 @@ public class CNavigatorEditActionGroup extends ActionGroup {
//renameAction.setTextActionHandler(textActionHandler);
updateActionBars();
-// textActionHandler.updateActionBars();
+ // textActionHandler.updateActionBars();
actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
}
protected void makeActions() {
- final SameShellProvider shellProvider= new SameShellProvider(shell);
+ final SameShellProvider shellProvider = new SameShellProvider(shell);
clipboard = new Clipboard(shell.getDisplay());
pasteAction = new PasteAction(shell, clipboard);
@@ -121,10 +120,9 @@ public class CNavigatorEditActionGroup extends ActionGroup {
copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
-
+
deleteAction = new DeleteResourceAction(shellProvider);
- deleteAction.setDisabledImageDescriptor(
- images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
}
@@ -135,6 +133,6 @@ public class CNavigatorEditActionGroup extends ActionGroup {
copyAction.selectionChanged(selection);
pasteAction.selectionChanged(selection);
- deleteAction.selectionChanged(selection);
+ deleteAction.selectionChanged(selection);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvider.java
index 8f409555b61..a12c7ef5c6b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvider.java
@@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
* Common Navigator action provider for clipboard actions.
*/
public class CNavigatorEditActionProvider extends CommonActionProvider {
-
+
private CNavigatorEditActionGroup fEditGroup;
private GenerateActionGroup fGenerateGroup;
@@ -41,16 +41,16 @@ public class CNavigatorEditActionProvider extends CommonActionProvider {
@Override
public void init(ICommonActionExtensionSite anActionSite) {
super.init(anActionSite);
-
+
fEditGroup = new CNavigatorEditActionGroup(anActionSite.getViewSite().getShell());
- ICommonViewerWorkbenchSite workbenchSite= null;
+ ICommonViewerWorkbenchSite workbenchSite = null;
if (anActionSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
- workbenchSite= (ICommonViewerWorkbenchSite) anActionSite.getViewSite();
+ workbenchSite = (ICommonViewerWorkbenchSite) anActionSite.getViewSite();
}
if (workbenchSite != null) {
if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
- IViewPart viewPart= (IViewPart) workbenchSite.getPart();
+ IViewPart viewPart = (IViewPart) workbenchSite.getPart();
fGenerateGroup = new GenerateActionGroup(viewPart);
}
@@ -72,7 +72,7 @@ public class CNavigatorEditActionProvider extends CommonActionProvider {
* @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
*/
@Override
- public void fillActionBars(IActionBars actionBars) {
+ public void fillActionBars(IActionBars actionBars) {
fEditGroup.fillActionBars(actionBars);
if (fGenerateGroup != null) {
fGenerateGroup.fillActionBars(actionBars);
@@ -83,7 +83,7 @@ public class CNavigatorEditActionProvider extends CommonActionProvider {
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
- public void fillContextMenu(IMenuManager menu) {
+ public void fillContextMenu(IMenuManager menu) {
fEditGroup.fillContextMenu(menu);
if (fGenerateGroup != null) {
fGenerateGroup.fillContextMenu(menu);
@@ -94,7 +94,7 @@ public class CNavigatorEditActionProvider extends CommonActionProvider {
* @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
*/
@Override
- public void setContext(ActionContext context) {
+ public void setContext(ActionContext context) {
if (context != null) {
// convert non-IResource to IResources on the fly
ISelection selection = SelectionConverter.convertSelectionToResources(context.getSelection());
@@ -111,7 +111,7 @@ public class CNavigatorEditActionProvider extends CommonActionProvider {
* @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
*/
@Override
- public void updateActionBars() {
+ public void updateActionBars() {
fEditGroup.updateActionBars();
if (fGenerateGroup != null) {
fGenerateGroup.updateActionBars();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java
index 2e5d5fba862..32984bcd056 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java
@@ -34,7 +34,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
/**
* A label provider suitable for the Common Navigator providing also
* status message text for the current selected item.
- *
+ *
* @see org.eclipse.cdt.internal.ui.cview.CView#createLabelProvider
* @see org.eclipse.cdt.internal.ui.cview.CView#getStatusLineMessage
*/
@@ -45,8 +45,7 @@ public class CNavigatorLabelProvider extends CViewLabelProvider implements IComm
*/
public CNavigatorLabelProvider() {
super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
- AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
- | CElementImageProvider.SMALL_ICONS);
+ AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS);
addLabelDecorator(new CNavigatorProblemsLabelDecorator());
}
@@ -90,12 +89,12 @@ public class CNavigatorLabelProvider extends CViewLabelProvider implements IComm
if (celement instanceof IBinaryContainer) {
ICProject cproj = celement.getCProject();
if (cproj != null) {
- return cproj.getPath() + CViewMessages.CView_binaries;
+ return cproj.getPath() + CViewMessages.CView_binaries;
}
} else if (celement instanceof IArchiveContainer) {
ICProject cproj = celement.getCProject();
if (cproj != null) {
- return cproj.getPath() + CViewMessages.CView_archives;
+ return cproj.getPath() + CViewMessages.CView_archives;
}
} else if (celement instanceof IBinaryModule) {
IBinary bin = ((IBinaryModule) celement).getBinary();
@@ -106,7 +105,7 @@ public class CNavigatorLabelProvider extends CViewLabelProvider implements IComm
}
return celement.getElementName();
} else if (element instanceof IWorkbenchAdapter) {
- IWorkbenchAdapter wAdapter = (IWorkbenchAdapter)element;
+ IWorkbenchAdapter wAdapter = (IWorkbenchAdapter) element;
return wAdapter.getLabel(element);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.java
index ad3493e0606..b450f9639a0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.java
@@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
/**
* Provide support for linking view selection with active editor.
- *
+ *
* @since 4.0
*/
public class CNavigatorLinkHelper implements ILinkHelper {
@@ -45,8 +45,8 @@ public class CNavigatorLinkHelper implements ILinkHelper {
public void activateEditor(IWorkbenchPage page, IStructuredSelection selection) {
if (selection == null || selection.isEmpty())
return;
- Object element= selection.getFirstElement();
- IEditorPart part= EditorUtility.isOpenInEditor(element);
+ Object element = selection.getFirstElement();
+ IEditorPart part = EditorUtility.isOpenInEditor(element);
if (part != null) {
page.bringToTop(part);
if (element instanceof ICElement && !(element instanceof ITranslationUnit)) {
@@ -61,23 +61,23 @@ public class CNavigatorLinkHelper implements ILinkHelper {
*/
@Override
public IStructuredSelection findSelection(IEditorInput input) {
- IWorkingCopyManager mgr= CUIPlugin.getDefault().getWorkingCopyManager();
- Object element= mgr.getWorkingCopy(input);
+ IWorkingCopyManager mgr = CUIPlugin.getDefault().getWorkingCopyManager();
+ Object element = mgr.getWorkingCopy(input);
if (element == null) {
IFile file = ResourceUtil.getFile(input);
if (file != null && CoreModel.hasCNature(file.getProject())) {
- element= CoreModel.getDefault().create(file);
+ element = CoreModel.getDefault().create(file);
}
} else {
- ITranslationUnit tUnit= ((IWorkingCopy) element).getOriginalElement();
- IFile file= (IFile) tUnit.getResource();
+ ITranslationUnit tUnit = ((IWorkingCopy) element).getOriginalElement();
+ IFile file = (IFile) tUnit.getResource();
if (file != null) {
- element= CoreModel.getDefault().create(file);
+ element = CoreModel.getDefault().create(file);
if (element == null) {
- element= file;
+ element = file;
}
} else {
- element= tUnit;
+ element = tUnit;
}
}
return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java
index af138d83259..a0a747f7d9a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java
@@ -26,7 +26,7 @@ import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
/**
* A Common Navigator action provider providing the contributions
* from the open editor action group.
- *
+ *
* @see CNavigatorOpenEditorActionGroup
*/
public class CNavigatorOpenActionProvider extends CommonActionProvider {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java
index 6c9ca98dc94..cf41d129b4a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java
@@ -34,7 +34,6 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
import org.eclipse.cdt.internal.ui.cview.CViewMessages;
-
/**
* This is basically a clone of {@link org.eclipse.cdt.internal.ui.cview.OpenFileGroup},
* but without explicit dependency on CView. This opens it up for use in the
@@ -44,7 +43,7 @@ import org.eclipse.cdt.internal.ui.cview.CViewMessages;
* for all applicable editors if one or more files are selected.
* For all container selections, an "Open In New Window" action is contributed.
* </p>
- *
+ *
* @see org.eclipse.cdt.internal.ui.cview.OpenFileGroup
* @see org.eclipse.ui.actions.OpenFileAction
* @see org.eclipse.ui.actions.OpenWithMenu
@@ -57,7 +56,7 @@ public class CNavigatorOpenEditorActionGroup extends AbstractCNavigatorActionGro
/**
* Create an action group for the given view part.
- *
+ *
* @param viewPart
*/
public CNavigatorOpenEditorActionGroup(IViewPart viewPart) {
@@ -66,13 +65,13 @@ public class CNavigatorOpenEditorActionGroup extends AbstractCNavigatorActionGro
@Override
protected void makeActions() {
- fOpenFileAction= new OpenCElementAction(getViewPart().getSite().getPage());
+ fOpenFileAction = new OpenCElementAction(getViewPart().getSite().getPage());
}
@Override
public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection celements= (IStructuredSelection) getContext().getSelection();
- IStructuredSelection selection= SelectionConverter.convertSelectionToResources(celements);
+ IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
+ IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
fOpenFileAction.selectionChanged(celements);
if (fOpenFileAction.isEnabled()) {
@@ -85,7 +84,7 @@ public class CNavigatorOpenEditorActionGroup extends AbstractCNavigatorActionGro
/**
* Adds the OpenWith submenu to the context menu.
- *
+ *
* @param menu
* the context menu
* @param selection
@@ -96,19 +95,19 @@ public class CNavigatorOpenEditorActionGroup extends AbstractCNavigatorActionGro
if (selection.size() != 1) {
return;
}
- Object element= selection.getFirstElement();
+ Object element = selection.getFirstElement();
if (!(element instanceof IFile)) {
return;
}
- MenuManager submenu= new MenuManager(CViewMessages.OpenWithMenu_label, ICommonMenuConstants.GROUP_OPEN_WITH);
+ MenuManager submenu = new MenuManager(CViewMessages.OpenWithMenu_label, ICommonMenuConstants.GROUP_OPEN_WITH);
submenu.add(new OpenWithMenu(getViewPart().getSite().getPage(), (IFile) element));
menu.insertAfter(ICommonMenuConstants.GROUP_OPEN_WITH, submenu);
}
/**
* Adds the Open in New Window action to the context menu.
- *
+ *
* @param menu
* the context menu
* @param selection
@@ -120,9 +119,9 @@ public class CNavigatorOpenEditorActionGroup extends AbstractCNavigatorActionGro
if (selection.size() != 1) {
return;
}
- Object element= selection.getFirstElement();
+ Object element = selection.getFirstElement();
if (element instanceof ICElement) {
- element= ((ICElement)element).getResource();
+ element = ((ICElement) element).getResource();
}
if (!(element instanceof IContainer)) {
return;
@@ -131,27 +130,28 @@ public class CNavigatorOpenEditorActionGroup extends AbstractCNavigatorActionGro
return;
}
- menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, new OpenInNewWindowAction(getViewPart().getSite().getWorkbenchWindow(), (IContainer) element));
+ menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN,
+ new OpenInNewWindowAction(getViewPart().getSite().getWorkbenchWindow(), (IContainer) element));
}
- /*
- * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
- */
- @Override
+ /*
+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+ */
+ @Override
public void fillActionBars(IActionBars actionBars) {
- }
+ }
- /*
- * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
- */
- @Override
+ /*
+ * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+ */
+ @Override
public void updateActionBars() {
- IStructuredSelection celements= (IStructuredSelection) getContext().getSelection();
+ IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
fOpenFileAction.selectionChanged(celements);
- }
+ }
/**
- * Returns the open action managed by this action group.
+ * Returns the open action managed by this action group.
*
* @return the open action
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionProvider.java
index 6df2cc90a52..e0c8a578b3c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.navigator;
@@ -28,19 +28,19 @@ import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
public class CNavigatorOpenViewActionProvider extends CommonActionProvider {
private OpenViewActionGroup fOpenViewActionGroup;
-
+
/*
* @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
*/
@Override
public void init(ICommonActionExtensionSite site) {
- ICommonViewerWorkbenchSite workbenchSite= null;
+ ICommonViewerWorkbenchSite workbenchSite = null;
if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
- workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
+ workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite();
}
if (workbenchSite != null) {
if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
- fOpenViewActionGroup= new OpenViewActionGroup(workbenchSite.getPart());
+ fOpenViewActionGroup = new OpenViewActionGroup(workbenchSite.getPart());
// properties action is already provided by resource extensions
fOpenViewActionGroup.setSuppressProperties(true);
}
@@ -76,7 +76,7 @@ public class CNavigatorOpenViewActionProvider extends CommonActionProvider {
public void fillContextMenu(IMenuManager menu) {
if (fOpenViewActionGroup != null) {
ISelection selection = getContext().getSelection();
- if (OpenViewActionGroup.canActionBeAdded(selection)){
+ if (OpenViewActionGroup.canActionBeAdded(selection)) {
fOpenViewActionGroup.fillContextMenu(menu);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDecorator.java
index be530544cd7..a8b06b63d4f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDecorator.java
@@ -36,12 +36,11 @@ public class CNavigatorProblemsLabelDecorator extends ProblemsLabelDecorator {
* @see org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator#fireProblemsChanged(org.eclipse.core.resources.IResource[], boolean)
*/
@Override
- protected void fireProblemsChanged(IResource[] changedResources,
- boolean isMarkerChange) {
+ protected void fireProblemsChanged(IResource[] changedResources, boolean isMarkerChange) {
// performance: if the number of changed resources is large, it is faster
// to trigger a viewer refresh by setting changedResources to null
if (changedResources != null && changedResources.length > 500) {
- changedResources= null;
+ changedResources = null;
}
super.fireProblemsChanged(changedResources, isMarkerChange);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGroup.java
index 63705dab580..9d142334598 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGroup.java
@@ -30,7 +30,7 @@ import org.eclipse.ui.navigator.ICommonMenuConstants;
/**
* This is the action group for refactor actions move and rename.
- *
+ *
* A clone of org.eclipse.ui.internal.navigator.resources.actions.RefactorActionGroup.
*/
public class CNavigatorRefactorActionGroup extends ActionGroup {
@@ -44,7 +44,7 @@ public class CNavigatorRefactorActionGroup extends ActionGroup {
private Tree tree;
/**
- *
+ *
* @param aShell
* @param aTree
*/
@@ -57,9 +57,8 @@ public class CNavigatorRefactorActionGroup extends ActionGroup {
@Override
public void fillContextMenu(IMenuManager menu) {
IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
- boolean anyResourceSelected = !selection.isEmpty()
- && ResourceSelectionUtil.allResourcesAreOfType(selection,
- IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+ boolean anyResourceSelected = !selection.isEmpty() && ResourceSelectionUtil.allResourcesAreOfType(selection,
+ IResource.PROJECT | IResource.FOLDER | IResource.FILE);
if (anyResourceSelected) {
moveAction.selectionChanged(selection);
@@ -73,7 +72,7 @@ public class CNavigatorRefactorActionGroup extends ActionGroup {
public void fillActionBars(IActionBars actionBars) {
updateActionBars();
-// textActionHandler.updateActionBars();
+ // textActionHandler.updateActionBars();
actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction);
actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
}
@@ -81,7 +80,7 @@ public class CNavigatorRefactorActionGroup extends ActionGroup {
protected void makeActions() {
moveAction = new MoveResourceAction(shellProvider);
moveAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_MOVE);
-
+
renameAction = new CNavigatorRenameResourceAction(shellProvider, tree);
renameAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_RENAME);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionProvider.java
index 0e0ffe07daf..3b95184d7e9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionProvider.java
@@ -46,16 +46,17 @@ public class CNavigatorRefactorActionProvider extends CommonActionProvider {
@Override
public void init(ICommonActionExtensionSite actionSite) {
super.init(actionSite);
- ICommonViewerWorkbenchSite workbenchSite= null;
+ ICommonViewerWorkbenchSite workbenchSite = null;
if (actionSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
workbenchSite = (ICommonViewerWorkbenchSite) actionSite.getViewSite();
}
if (workbenchSite != null) {
- final IWorkbenchPartSite partSite= workbenchSite.getSite();
- resourceRefactorGroup= new CNavigatorRefactorActionGroup(partSite, (Tree)actionSite.getStructuredViewer().getControl());
- IUndoContext workspaceContext= ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class);
+ final IWorkbenchPartSite partSite = workbenchSite.getSite();
+ resourceRefactorGroup = new CNavigatorRefactorActionGroup(partSite,
+ (Tree) actionSite.getStructuredViewer().getControl());
+ IUndoContext workspaceContext = ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class);
undoRedoGroup = new UndoRedoActionGroup(partSite, workspaceContext, true);
- cElementRefactorGroup= new CRefactoringActionGroup(workbenchSite.getPart());
+ cElementRefactorGroup = new CRefactoringActionGroup(workbenchSite.getPart());
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java
index e4c8346d18e..fac9c306326 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java
@@ -25,25 +25,25 @@ import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
/**
* Common Navigator action provider for the C-search sub menus.
- *
+ *
* @see org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup
*/
public class CNavigatorSearchActionProvider extends CommonActionProvider {
private SelectionSearchGroup fSearchGroup;
-
+
/*
* @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
*/
@Override
public void init(ICommonActionExtensionSite site) {
- ICommonViewerWorkbenchSite workbenchSite= null;
+ ICommonViewerWorkbenchSite workbenchSite = null;
if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
- workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
+ workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite();
}
if (workbenchSite != null) {
if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
- fSearchGroup= new SelectionSearchGroup(workbenchSite.getSite());
+ fSearchGroup = new SelectionSearchGroup(workbenchSite.getSite());
}
}
}
@@ -77,7 +77,7 @@ public class CNavigatorSearchActionProvider extends CommonActionProvider {
public void fillContextMenu(IMenuManager menu) {
if (fSearchGroup != null) {
ISelection selection = getContext().getSelection();
- if (SelectionSearchGroup.canActionBeAdded(selection)){
+ if (SelectionSearchGroup.canActionBeAdded(selection)) {
fSearchGroup.fillContextMenu(menu);
}
}
@@ -103,5 +103,5 @@ public class CNavigatorSearchActionProvider extends CommonActionProvider {
fSearchGroup.updateActionBars();
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java
index d20ce9c10ca..7c8a9a0d7df 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java
@@ -37,6 +37,7 @@ import org.eclipse.ui.actions.OpenFileAction;
public class OpenCElementAction extends OpenFileAction {
private ICElement fOpenElement;
+
/**
* @param page
*/
@@ -52,7 +53,7 @@ public class OpenCElementAction extends OpenFileAction {
if (fOpenElement != null) {
IEditorPart part;
try {
- part= EditorUtility.openInEditor(fOpenElement);
+ part = EditorUtility.openInEditor(fOpenElement);
if (fOpenElement instanceof ISourceReference && !(fOpenElement instanceof ITranslationUnit)) {
EditorUtility.revealInEditor(part, fOpenElement);
}
@@ -72,11 +73,10 @@ public class OpenCElementAction extends OpenFileAction {
fOpenElement = null;
if (selection.size() == 1) {
Object element = selection.getFirstElement();
- if (!(element instanceof ICElement) && element instanceof IAdaptable) {
+ if (!(element instanceof ICElement) && element instanceof IAdaptable) {
element = ((IAdaptable) element).getAdapter(ICElement.class);
}
- if (element instanceof ICElement
- && (element instanceof ISourceReference || element instanceof IBinary)) {
+ if (element instanceof ICElement && (element instanceof ISourceReference || element instanceof IBinary)) {
fOpenElement = (ICElement) element;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java
index 6de062e0b28..96a29dbd605 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java
@@ -29,17 +29,17 @@ import org.eclipse.swt.widgets.Composite;
*/
public class StatusMessageLine {
private CLabel fLabel;
-
+
/**
* Constructor.
- *
+ *
* @param parent - parent element.
* @param style - the style of the control. Refer to {@link CLabel#CLabel(Composite, int)}.
* @param span - how many columns it should span.
*/
public StatusMessageLine(Composite parent, int style, int span) {
fLabel = new CLabel(parent, style);
- if (span!=1) {
+ if (span != 1) {
GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);
gd.horizontalSpan = span;
fLabel.setLayoutData(gd);
@@ -65,7 +65,7 @@ public class StatusMessageLine {
/**
* Assign {@link IStatus} object to the message line. The status should provide
* severity for the icon and message to display.
- *
+ *
* @param status - status object for the message line.
*/
public void setErrorStatus(IStatus status) {
@@ -78,7 +78,7 @@ public class StatusMessageLine {
return;
}
}
- fLabel.setText(""); //$NON-NLS-1$
+ fLabel.setText(""); //$NON-NLS-1$
fLabel.setImage(null);
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java
index 207b85e9000..d456cf8e6d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java
@@ -51,47 +51,47 @@ import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
/**
* Abstract implementation of a generic {@link IPreferenceConfigurationBlock}.
- *
+ *
* @since 4.0
*/
abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlock {
/**
* Use as follows:
- *
+ *
* <pre>
* SectionManager manager= new SectionManager();
* Composite composite= manager.createSectionComposite(parent);
- *
+ *
* Composite xSection= manager.createSection("section X"));
* xSection.setLayout(new FillLayout());
* new Button(xSection, SWT.PUSH); // add controls to section..
- *
+ *
* [...]
- *
+ *
* return composite; // return main composite
* </pre>
*/
protected final class SectionManager {
/** The preference setting for keeping no section open. */
- private static final String __NONE= "__none"; //$NON-NLS-1$
- private final Set<ExpandableComposite> fSections= new HashSet<ExpandableComposite>();
- private boolean fIsBeingManaged= false;
- private final ExpansionAdapter fListener= new ExpansionAdapter() {
+ private static final String __NONE = "__none"; //$NON-NLS-1$
+ private final Set<ExpandableComposite> fSections = new HashSet<ExpandableComposite>();
+ private boolean fIsBeingManaged = false;
+ private final ExpansionAdapter fListener = new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
- ExpandableComposite source= (ExpandableComposite) e.getSource();
+ ExpandableComposite source = (ExpandableComposite) e.getSource();
updateSectionStyle(source);
if (fIsBeingManaged)
return;
if (e.getState()) {
try {
- fIsBeingManaged= true;
+ fIsBeingManaged = true;
for (ExpandableComposite composite : fSections) {
if (composite != source)
composite.setExpanded(false);
}
} finally {
- fIsBeingManaged= false;
+ fIsBeingManaged = false;
}
if (fLastOpenKey != null && fDialogSettingsStore != null)
fDialogSettingsStore.setValue(fLastOpenKey, source.getText());
@@ -99,10 +99,10 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
if (!fIsBeingManaged && fLastOpenKey != null && fDialogSettingsStore != null)
fDialogSettingsStore.setValue(fLastOpenKey, __NONE);
}
- ExpandableComposite exComp= getParentExpandableComposite(source);
+ ExpandableComposite exComp = getParentExpandableComposite(source);
if (exComp != null)
exComp.layout(true, true);
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(source);
+ ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(source);
if (parentScrolledComposite != null) {
parentScrolledComposite.reflow(true);
}
@@ -120,13 +120,15 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
public SectionManager() {
this(null, null);
}
+
/**
* Creates a new section manager.
*/
public SectionManager(IPreferenceStore dialogSettingsStore, String lastOpenKey) {
- fDialogSettingsStore= dialogSettingsStore;
- fLastOpenKey= lastOpenKey;
+ fDialogSettingsStore = dialogSettingsStore;
+ fLastOpenKey = lastOpenKey;
}
+
private void manage(ExpandableComposite section) {
if (section == null)
throw new NullPointerException();
@@ -134,7 +136,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
section.addExpansionListener(fListener);
makeScrollableCompositeAware(section);
}
-
+
/**
* Creates a new composite that can contain a set of expandable
* sections. A <code>ScrolledPageComposite</code> is created and a new
@@ -147,45 +149,46 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
* The receiver keeps a reference to the inner body composite, so that
* new sections can be added via <code>createSection</code>.
* </p>
- *
+ *
* @param parent the parent composite
* @return the newly created composite
*/
public Composite createSectionComposite(Composite parent) {
Assert.isTrue(fBody == null);
- boolean isNested= isNestedInScrolledComposite(parent);
+ boolean isNested = isNestedInScrolledComposite(parent);
Composite composite;
if (isNested) {
- composite= new Composite(parent, SWT.NONE);
- fBody= composite;
+ composite = new Composite(parent, SWT.NONE);
+ fBody = composite;
} else {
- composite= new ScrolledPageContent(parent);
- fBody= ((ScrolledPageContent) composite).getBody();
+ composite = new ScrolledPageContent(parent);
+ fBody = ((ScrolledPageContent) composite).getBody();
}
-
+
fBody.setLayout(new GridLayout());
-
+
return composite;
}
-
+
/**
* Creates an expandable section within the parent created previously by
- * calling <code>createSectionComposite</code>. Controls can be added
+ * calling <code>createSectionComposite</code>. Controls can be added
* directly to the returned composite, which has no layout initially.
- *
+ *
* @param label the display name of the section
* @return a composite within the expandable section
*/
public Composite createSection(String label) {
Assert.isNotNull(fBody);
- final ExpandableComposite excomposite= new ExpandableComposite(fBody, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
+ final ExpandableComposite excomposite = new ExpandableComposite(fBody, SWT.NONE,
+ ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
if (fFirstChild == null)
- fFirstChild= excomposite;
+ fFirstChild = excomposite;
excomposite.setText(label);
- String last= null;
+ String last = null;
if (fLastOpenKey != null && fDialogSettingsStore != null)
- last= fDialogSettingsStore.getString(fLastOpenKey);
-
+ last = fDialogSettingsStore.getString(fLastOpenKey);
+
if (fFirstChild == excomposite && !__NONE.equals(last) || label.equals(last)) {
excomposite.setExpanded(true);
if (fFirstChild != excomposite)
@@ -194,79 +197,78 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
excomposite.setExpanded(false);
}
excomposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
-
+
updateSectionStyle(excomposite);
manage(excomposite);
-
- Composite contents= new Composite(excomposite, SWT.NONE);
+
+ Composite contents = new Composite(excomposite, SWT.NONE);
excomposite.setClient(contents);
-
+
return contents;
}
}
- protected static final int INDENT= 20;
+ protected static final int INDENT = 20;
private final OverlayPreferenceStore fStore;
-
- private final Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
- private final SelectionListener fCheckBoxListener= new SelectionListener() {
+
+ private final Map<Object, String> fCheckBoxes = new HashMap<Object, String>();
+ private final SelectionListener fCheckBoxListener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
@Override
public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
+ Button button = (Button) e.widget;
fStore.setValue(fCheckBoxes.get(button), button.getSelection());
}
};
-
-
- private final Map<Object, String> fTextFields= new HashMap<Object, String>();
- private final ModifyListener fTextFieldListener= new ModifyListener() {
+
+ private final Map<Object, String> fTextFields = new HashMap<Object, String>();
+ private final ModifyListener fTextFieldListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
- Text text= (Text) e.widget;
+ Text text = (Text) e.widget;
fStore.setValue(fTextFields.get(text), text.getText());
}
};
- private final ArrayList<Text> fNumberFields= new ArrayList<Text>();
- private final ModifyListener fNumberFieldListener= new ModifyListener() {
+ private final ArrayList<Text> fNumberFields = new ArrayList<Text>();
+ private final ModifyListener fNumberFieldListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
numberFieldChanged((Text) e.widget);
}
};
-
+
/**
* List of master/slave listeners when there's a dependency.
- *
+ *
* @see #createDependency(Button, Control)
* @since 3.0
*/
- private final ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
-
+ private final ArrayList<Object> fMasterSlaveListeners = new ArrayList<Object>();
+
private StatusInfo fStatus;
private final PreferencePage fMainPage;
public AbstractConfigurationBlock(OverlayPreferenceStore store) {
Assert.isNotNull(store);
- fStore= store;
- fMainPage= null;
+ fStore = store;
+ fMainPage = null;
}
-
+
public AbstractConfigurationBlock(OverlayPreferenceStore store, PreferencePage mainPreferencePage) {
Assert.isNotNull(store);
Assert.isNotNull(mainPreferencePage);
- fStore= store;
- fMainPage= mainPreferencePage;
+ fStore = store;
+ fMainPage = mainPreferencePage;
}
protected final ScrolledPageContent getParentScrolledComposite(Control control) {
- Control parent= control.getParent();
+ Control parent = control.getParent();
while (!(parent instanceof ScrolledPageContent) && parent != null) {
- parent= parent.getParent();
+ parent = parent.getParent();
}
if (parent instanceof ScrolledPageContent) {
return (ScrolledPageContent) parent;
@@ -275,9 +277,9 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
}
private final ExpandableComposite getParentExpandableComposite(Control control) {
- Control parent= control.getParent();
+ Control parent = control.getParent();
while (!(parent instanceof ExpandableComposite) && parent != null) {
- parent= parent.getParent();
+ parent = parent.getParent();
}
if (parent instanceof ExpandableComposite) {
return (ExpandableComposite) parent;
@@ -288,31 +290,31 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
protected void updateSectionStyle(ExpandableComposite excomposite) {
excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
}
-
+
private void makeScrollableCompositeAware(Control control) {
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
+ ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(control);
if (parentScrolledComposite != null) {
parentScrolledComposite.adaptChild(control);
}
}
-
+
private boolean isNestedInScrolledComposite(Composite parent) {
return getParentScrolledComposite(parent) != null;
}
-
- protected Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox= new Button(parent, SWT.CHECK);
+
+ protected Button addCheckBox(Composite parent, String label, String key, int indentation) {
+ Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setText(label);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
+
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = indentation;
+ gd.horizontalSpan = 2;
checkBox.setLayoutData(gd);
checkBox.addSelectionListener(fCheckBoxListener);
makeScrollableCompositeAware(checkBox);
fCheckBoxes.put(checkBox, key);
-
+
return checkBox;
}
@@ -321,7 +323,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
* - first element is of type <code>Label</code>
* - second element is of type <code>Text</code>
* Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
- *
+ *
* @param composite the parent composite
* @param label the text field's label
* @param key the preference key
@@ -330,19 +332,19 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
* @param isNumber <code>true</code> iff this text field is used to e4dit a number
* @return the controls added
*/
- protected Control[] addLabelledTextField(Composite composite, String label, String key,
- int textLimit, int indentation, boolean isNumber) {
- PixelConverter pixelConverter= new PixelConverter(composite);
-
- Label labelControl= new Label(composite, SWT.NONE);
+ protected Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit,
+ int indentation, boolean isNumber) {
+ PixelConverter pixelConverter = new PixelConverter(composite);
+
+ Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(label);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = indentation;
labelControl.setLayoutData(gd);
-
- Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.widthHint= pixelConverter.convertWidthInCharsToPixels(textLimit + 1);
+
+ Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.widthHint = pixelConverter.convertWidthInCharsToPixels(textLimit + 1);
textControl.setLayoutData(gd);
textControl.setTextLimit(textLimit);
fTextFields.put(textControl, key);
@@ -352,28 +354,29 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
} else {
textControl.addModifyListener(fTextFieldListener);
}
-
- return new Control[]{labelControl, textControl};
+
+ return new Control[] { labelControl, textControl };
}
protected void createDependency(final Button master, final Control slave) {
- createDependency(master, new Control[] {slave});
+ createDependency(master, new Control[] { slave });
}
-
+
protected void createDependency(final Button master, final Control[] slaves) {
Assert.isTrue(slaves.length > 0);
indent(slaves[0]);
- SelectionListener listener= new SelectionListener() {
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- boolean state= master.getSelection();
+ boolean state = master.getSelection();
for (Control slave : slaves) {
slave.setEnabled(state);
}
}
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
};
master.addSelectionListener(listener);
fMasterSlaveListeners.add(listener);
@@ -389,28 +392,28 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
}
private void initializeFields() {
- Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+ Iterator<Object> iter = fCheckBoxes.keySet().iterator();
while (iter.hasNext()) {
- Button b= (Button) iter.next();
- String key= fCheckBoxes.get(b);
+ Button b = (Button) iter.next();
+ String key = fCheckBoxes.get(b);
b.setSelection(fStore.getBoolean(key));
}
-
- iter= fTextFields.keySet().iterator();
+
+ iter = fTextFields.keySet().iterator();
while (iter.hasNext()) {
- Text t= (Text) iter.next();
- String key= fTextFields.get(t);
+ Text t = (Text) iter.next();
+ String key = fTextFields.get(t);
t.setText(fStore.getString(key));
}
-
- // Update slaves
- iter= fMasterSlaveListeners.iterator();
- while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
- listener.widgetSelected(null);
- }
-
- updateStatus(new StatusInfo());
+
+ // Update slaves
+ iter = fMasterSlaveListeners.iterator();
+ while (iter.hasNext()) {
+ SelectionListener listener = (SelectionListener) iter.next();
+ listener.widgetSelected(null);
+ }
+
+ updateStatus(new StatusInfo());
}
@Override
@@ -424,33 +427,33 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
IStatus getStatus() {
if (fStatus == null)
- fStatus= new StatusInfo();
+ fStatus = new StatusInfo();
return fStatus;
}
@Override
public void dispose() {
}
-
+
private void numberFieldChanged(Text textControl) {
- String number= textControl.getText();
- IStatus status= validatePositiveNumber(number);
+ String number = textControl.getText();
+ IStatus status = validatePositiveNumber(number);
if (!status.matches(IStatus.ERROR))
fStore.setValue(fTextFields.get(textControl), number);
updateStatus(status);
}
-
+
private IStatus validatePositiveNumber(String number) {
- StatusInfo status= new StatusInfo();
+ StatusInfo status = new StatusInfo();
if (number.length() == 0) {
- status.setError(PreferencesMessages.CEditorPreferencePage_empty_input);
+ status.setError(PreferencesMessages.CEditorPreferencePage_empty_input);
} else {
try {
- int value= Integer.parseInt(number);
+ int value = Integer.parseInt(number);
if (value < 0)
- status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number));
+ status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number));
} catch (NumberFormatException e) {
- status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number));
+ status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number));
}
}
return status;
@@ -462,7 +465,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
fMainPage.setValid(status.isOK());
StatusUtil.applyToStatusLine(fMainPage, status);
}
-
+
protected final OverlayPreferenceStore getPreferenceStore() {
return fStore;
}
@@ -471,9 +474,9 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
if (manager != null) {
return manager.createSection(label);
}
- Group group= new Group(parent, SWT.SHADOW_NONE);
+ Group group = new Group(parent, SWT.SHADOW_NONE);
group.setText(label);
- GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false);
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
group.setLayoutData(data);
return group;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java
index 954cf4504e2..d4404d4da2d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java
@@ -28,15 +28,14 @@ import org.eclipse.ui.PlatformUI;
/**
* Abstract preference page which is used to wrap a
* {@link org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock}.
- *
+ *
* @since 4.0
*/
-public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
-
+public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage
+ implements IWorkbenchPreferencePage {
+
private IPreferenceConfigurationBlock fConfigurationBlock;
private OverlayPreferenceStore fOverlayStore;
-
/**
* Creates a new preference page.
@@ -44,18 +43,22 @@ public abstract class AbstractConfigurationBlockPreferencePage extends Preferenc
public AbstractConfigurationBlockPreferencePage() {
setDescription();
setPreferenceStore();
- fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {});
- fConfigurationBlock= createConfigurationBlock(fOverlayStore);
+ fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {});
+ fConfigurationBlock = createConfigurationBlock(fOverlayStore);
}
-
- protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore);
+
+ protected abstract IPreferenceConfigurationBlock createConfigurationBlock(
+ OverlayPreferenceStore overlayPreferenceStore);
+
protected abstract String getHelpId();
+
protected abstract void setDescription();
+
protected abstract void setPreferenceStore();
-
+
/*
* @see IWorkbenchPreferencePage#init()
- */
+ */
@Override
public void init(IWorkbench workbench) {
}
@@ -68,66 +71,66 @@ public abstract class AbstractConfigurationBlockPreferencePage extends Preferenc
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId());
}
-
+
/*
* @see PreferencePage#createContents(Composite)
*/
@Override
protected Control createContents(Composite parent) {
-
+
fOverlayStore.load();
fOverlayStore.start();
-
- Control content= fConfigurationBlock.createControl(parent);
-
+
+ Control content = fConfigurationBlock.createControl(parent);
+
initialize();
-
+
Dialog.applyDialogFont(content);
return content;
}
-
+
private void initialize() {
fConfigurationBlock.initialize();
}
-
- /*
+
+ /*
* @see PreferencePage#performOk()
*/
@Override
public boolean performOk() {
-
+
fConfigurationBlock.performOk();
fOverlayStore.propagate();
-
+
return true;
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
@Override
public void performDefaults() {
-
+
fOverlayStore.loadDefaults();
fConfigurationBlock.performDefaults();
super.performDefaults();
}
-
+
/*
* @see DialogPage#dispose()
*/
@Override
public void dispose() {
-
+
fConfigurationBlock.dispose();
-
+
if (fOverlayStore != null) {
fOverlayStore.stop();
- fOverlayStore= null;
+ fOverlayStore = null;
}
-
+
super.dispose();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferencePage.java
index 6bc1abdc27d..7c7e66b1f84 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferencePage.java
@@ -28,7 +28,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* A preference that on preference from the UI plugin, as well the CDT core.
- *
+ *
* Currently only supporting boolean preferences.
*/
public abstract class AbstractMixedPreferencePage extends AbstractPreferencePage {
@@ -69,7 +69,7 @@ public abstract class AbstractMixedPreferencePage extends AbstractPreferencePage
}
protected abstract OverlayPreferenceStore.OverlayKey[] createCorePrefsOverlayStoreKeys();
-
+
@Override
protected void initializeFields() {
super.initializeFields();
@@ -81,13 +81,13 @@ public abstract class AbstractMixedPreferencePage extends AbstractPreferencePage
b.setSelection(corePrefsOverlayStore.getBoolean(key));
}
}
-
+
@Override
public boolean performOk() {
corePrefsOverlayStore.propagate();
return super.performOk();
}
-
+
@Override
protected void performDefaults() {
corePrefsOverlayStore.loadDefaults();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java
index 97698f52803..1b08791b24a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java
@@ -74,7 +74,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
fOverlayStore.setValue(fTextFields.get(text), text.getText());
}
};
-
+
protected Map<Object, String> fComboBoxes = new HashMap<>();
private ModifyListener fComboBoxListener = new ModifyListener() {
@Override
@@ -84,12 +84,13 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
fOverlayStore.setValue(fComboBoxes.get(combo), state);
}
};
-
+
protected Map<Object, String> fCheckBoxes = new HashMap<>();
private SelectionListener fCheckBoxListener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
+
@Override
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.widget;
@@ -115,6 +116,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
+
@Override
public void widgetSelected(SelectionEvent e) {
ColorSelector editor = (ColorSelector) e.widget.getData();
@@ -127,9 +129,8 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
protected Button addRadioButton(Composite parent, String label, String key, int indentation) {
return addRadioButton(parent, label, key, null, indentation);
}
-
- protected Button addRadioButton(Composite parent, String label, String key, String value,
- int indentation) {
+
+ protected Button addRadioButton(Composite parent, String label, String key, String value, int indentation) {
Button radioButton = new Button(parent, SWT.RADIO);
radioButton.setText(label);
if (value != null)
@@ -147,7 +148,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
return radioButton;
}
-
+
protected Button addCheckBox(Composite parent, String label, String key, int indentation) {
Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setText(label);
@@ -175,8 +176,8 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
return group;
}
- protected Control addTextField(Composite composite, String label, String key, int textLimit,
- int indentation, boolean isNumber) {
+ protected Control addTextField(Composite composite, String label, String key, int textLimit, int indentation,
+ boolean isNumber) {
Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(label);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
@@ -199,15 +200,14 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
return textControl;
}
- protected void addComboBox(Composite composite, String label, String key, int textLimit,
- int indentation) {
+ protected void addComboBox(Composite composite, String label, String key, int textLimit, int indentation) {
Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(label);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = indentation;
labelControl.setLayoutData(gd);
- Combo comboControl = new Combo(composite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); // TODO: When will the combo be disposed?
+ Combo comboControl = new Combo(composite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); // TODO: When will the combo be disposed?
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
if (textLimit != NO_TEXT_LIMIT) {
gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
@@ -215,30 +215,31 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
}
comboControl.setLayoutData(gd);
fComboBoxes.put(comboControl, key);
- comboControl.addModifyListener(fComboBoxListener); // TODO: When will the listener be removed?
+ comboControl.addModifyListener(fComboBoxListener); // TODO: When will the listener be removed?
}
protected void addFiller(Composite composite) {
- PixelConverter pixelConverter= new PixelConverter(composite);
- Label filler= new Label(composite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+ PixelConverter pixelConverter = new PixelConverter(composite);
+ Label filler = new Label(composite, SWT.LEFT);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2;
filler.setLayoutData(gd);
}
protected void createDependency(final Button master, String masterKey, final Control slave) {
indent(slave);
- boolean masterState= fOverlayStore.getBoolean(masterKey);
+ boolean masterState = fOverlayStore.getBoolean(masterKey);
slave.setEnabled(masterState);
- SelectionListener listener= new SelectionListener() {
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
slave.setEnabled(master.getSelection());
}
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
};
master.addSelectionListener(listener);
fMasters.add(master);
@@ -255,14 +256,14 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
private IStatus validatePositiveNumber(String number) {
StatusInfo status = new StatusInfo();
if (number.length() == 0) {
- status.setError(PreferencesMessages.CEditorPreferencePage_empty_input);
+ status.setError(PreferencesMessages.CEditorPreferencePage_empty_input);
} else {
try {
int value = Integer.parseInt(number);
if (value < 0)
- status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number));
+ status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number));
} catch (NumberFormatException e) {
- status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number));
+ status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number));
}
}
return status;
@@ -282,9 +283,9 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
}
protected void indent(Control control) {
- GridData gridData= new GridData();
- gridData.horizontalIndent= 20;
- control.setLayoutData(gridData);
+ GridData gridData = new GridData();
+ gridData.horizontalIndent = 20;
+ control.setLayoutData(gridData);
}
protected Control addColorButton(Composite parent, String label, String key, int indentation) {
@@ -321,13 +322,13 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
}
public AbstractPreferencePage() {
- super();
+ super();
setPreferenceStore(PreferenceConstants.getPreferenceStore());
fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), createOverlayStoreKeys());
}
protected abstract OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys();
-
+
protected void initializeFields() {
Iterator<Object> e = fColorButtons.keySet().iterator();
while (e.hasNext()) {
@@ -364,7 +365,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
// Interpret the state string as a Combo state description
ProposalFilterPreferencesUtil.restoreComboFromString(c, state);
}
-
+
// Notify listeners for control dependencies.
Iterator<Button> buttonIter = fMasters.iterator();
while (buttonIter.hasNext()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java
index 710bf333db9..b5bf0807334 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java
@@ -59,64 +59,67 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben
private SelectionButtonDialogField fShowSourceRootsAtTopOfProject;
private SelectionButtonDialogField fCViewSortOrderOfExcludedFiles;
-
public AppearancePreferencePage() {
setPreferenceStore(PreferenceConstants.getPreferenceStore());
- setDescription(PreferencesMessages.AppearancePreferencePage_description);
-
- IDialogFieldListener listener= new IDialogFieldListener() {
+ setDescription(PreferencesMessages.AppearancePreferencePage_description);
+
+ IDialogFieldListener listener = new IDialogFieldListener() {
@Override
public void dialogFieldChanged(DialogField field) {
doDialogFieldChanged(field);
}
};
- fShowTUChildren= new SelectionButtonDialogField(SWT.CHECK);
+ fShowTUChildren = new SelectionButtonDialogField(SWT.CHECK);
fShowTUChildren.setDialogFieldListener(listener);
- fShowTUChildren.setLabelText(PreferencesMessages.AppearancePreferencePage_showTUChildren_label);
+ fShowTUChildren.setLabelText(PreferencesMessages.AppearancePreferencePage_showTUChildren_label);
- fOutlineGroupIncludes= new SelectionButtonDialogField(SWT.CHECK);
+ fOutlineGroupIncludes = new SelectionButtonDialogField(SWT.CHECK);
fOutlineGroupIncludes.setDialogFieldListener(listener);
- fOutlineGroupIncludes.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupIncludes_label);
+ fOutlineGroupIncludes.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupIncludes_label);
- fOutlineGroupNamespaces= new SelectionButtonDialogField(SWT.CHECK);
+ fOutlineGroupNamespaces = new SelectionButtonDialogField(SWT.CHECK);
fOutlineGroupNamespaces.setDialogFieldListener(listener);
- fOutlineGroupNamespaces.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupNamespaces_label);
+ fOutlineGroupNamespaces.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupNamespaces_label);
- fOutlineGroupMembers= new SelectionButtonDialogField(SWT.CHECK);
+ fOutlineGroupMembers = new SelectionButtonDialogField(SWT.CHECK);
fOutlineGroupMembers.setDialogFieldListener(listener);
- fOutlineGroupMembers.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupMethods_label);
+ fOutlineGroupMembers.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupMethods_label);
- fCViewGroupIncludes= new SelectionButtonDialogField(SWT.CHECK);
+ fCViewGroupIncludes = new SelectionButtonDialogField(SWT.CHECK);
fCViewGroupIncludes.setDialogFieldListener(listener);
- fCViewGroupIncludes.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewGroupIncludes_label);
-
- fCViewSeparateHeaderAndSource= new SelectionButtonDialogField(SWT.CHECK);
+ fCViewGroupIncludes.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewGroupIncludes_label);
+
+ fCViewSeparateHeaderAndSource = new SelectionButtonDialogField(SWT.CHECK);
fCViewSeparateHeaderAndSource.setDialogFieldListener(listener);
- fCViewSeparateHeaderAndSource.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewSeparateHeaderAndSource_label);
+ fCViewSeparateHeaderAndSource
+ .setLabelText(PreferencesMessages.AppearancePreferencePage_cviewSeparateHeaderAndSource_label);
- fShowSourceRootsAtTopOfProject= new SelectionButtonDialogField(SWT.CHECK);
+ fShowSourceRootsAtTopOfProject = new SelectionButtonDialogField(SWT.CHECK);
fShowSourceRootsAtTopOfProject.setDialogFieldListener(listener);
- fShowSourceRootsAtTopOfProject.setLabelText(PreferencesMessages.AppearancePreferencePage_showSourceRootsAtTopOfProject_label);
-
- fOutlineGroupMacros= new SelectionButtonDialogField(SWT.CHECK);
+ fShowSourceRootsAtTopOfProject
+ .setLabelText(PreferencesMessages.AppearancePreferencePage_showSourceRootsAtTopOfProject_label);
+
+ fOutlineGroupMacros = new SelectionButtonDialogField(SWT.CHECK);
fOutlineGroupMacros.setDialogFieldListener(listener);
fOutlineGroupMacros.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupMacros_label);
-
- fCViewGroupMacros= new SelectionButtonDialogField(SWT.CHECK);
+
+ fCViewGroupMacros = new SelectionButtonDialogField(SWT.CHECK);
fCViewGroupMacros.setDialogFieldListener(listener);
fCViewGroupMacros.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewGroupMacros_label);
-
- fCViewSortOrderOfExcludedFiles= new SelectionButtonDialogField(SWT.CHECK);
+
+ fCViewSortOrderOfExcludedFiles = new SelectionButtonDialogField(SWT.CHECK);
fCViewSortOrderOfExcludedFiles.setDialogFieldListener(listener);
- fCViewSortOrderOfExcludedFiles.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewKeepSortOrderOfExcludedFiles_label);
+ fCViewSortOrderOfExcludedFiles
+ .setLabelText(PreferencesMessages.AppearancePreferencePage_cviewKeepSortOrderOfExcludedFiles_label);
}
private void initFields() {
- IPreferenceStore prefs= getPreferenceStore();
+ IPreferenceStore prefs = getPreferenceStore();
fShowTUChildren.setSelection(prefs.getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN));
fCViewGroupIncludes.setSelection(prefs.getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES));
- fCViewSeparateHeaderAndSource.setSelection(prefs.getBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE));
+ fCViewSeparateHeaderAndSource
+ .setSelection(prefs.getBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE));
fCViewGroupMacros.setSelection(prefs.getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS));
fOutlineGroupIncludes.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES));
fOutlineGroupNamespaces.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES));
@@ -126,7 +129,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben
fShowSourceRootsAtTopOfProject.setSelection(showSourceRootsAtTopOfProject);
fCViewSortOrderOfExcludedFiles.setSelection(prefs.getBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES));
}
-
+
/*
* @see PreferencePage#createControl(Composite)
*/
@@ -134,7 +137,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben
public void createControl(Composite parent) {
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.APPEARANCE_PREFERENCE_PAGE);
- }
+ }
/*
* @see PreferencePage#createContents(Composite)
@@ -142,15 +145,15 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben
@Override
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
- int nColumns= 1;
-
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.numColumns= nColumns;
+ int nColumns = 1;
+
+ Composite result = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = 0;
+ layout.numColumns = nColumns;
result.setLayout(layout);
-
+
fShowTUChildren.doFillIntoGrid(result, nColumns);
fCViewGroupIncludes.doFillIntoGrid(result, nColumns);
fOutlineGroupIncludes.doFillIntoGrid(result, nColumns);
@@ -160,56 +163,56 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben
fOutlineGroupMacros.doFillIntoGrid(result, nColumns);
new Separator().doFillIntoGrid(result, nColumns);
-
+
fCViewSeparateHeaderAndSource.doFillIntoGrid(result, nColumns);
fCViewSortOrderOfExcludedFiles.doFillIntoGrid(result, nColumns);
-
- String noteTitle= PreferencesMessages.AppearancePreferencePage_note;
- String noteMessage= PreferencesMessages.AppearancePreferencePage_preferenceOnlyForNewViews;
- Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
+
+ String noteTitle = PreferencesMessages.AppearancePreferencePage_note;
+ String noteMessage = PreferencesMessages.AppearancePreferencePage_preferenceOnlyForNewViews;
+ Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
noteControl.setLayoutData(gd);
-
-
+
new Separator().doFillIntoGrid(result, nColumns);
fShowSourceRootsAtTopOfProject.doFillIntoGrid(result, nColumns);
-
+
initFields();
-
+
Dialog.applyDialogFont(result);
return result;
}
-
- void doDialogFieldChanged(DialogField field) {
+
+ void doDialogFieldChanged(DialogField field) {
updateStatus(getValidationStatus());
}
-
- private IStatus getValidationStatus(){
+
+ private IStatus getValidationStatus() {
return new StatusInfo();
}
-
+
private void updateStatus(IStatus status) {
setValid(!status.matches(IStatus.ERROR));
StatusUtil.applyToStatusLine(this, status);
- }
-
+ }
+
/*
* @see IWorkbenchPreferencePage#init(IWorkbench)
*/
@Override
public void init(IWorkbench workbench) {
}
-
+
/*
* @see IPreferencePage#performOk()
*/
@Override
public boolean performOk() {
- IPreferenceStore prefs= getPreferenceStore();
+ IPreferenceStore prefs = getPreferenceStore();
prefs.setValue(PreferenceConstants.PREF_SHOW_CU_CHILDREN, fShowTUChildren.isSelected());
prefs.setValue(PreferenceConstants.CVIEW_GROUP_INCLUDES, fCViewGroupIncludes.isSelected());
- prefs.setValue(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE, fCViewSeparateHeaderAndSource.isSelected());
+ prefs.setValue(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE,
+ fCViewSeparateHeaderAndSource.isSelected());
prefs.setValue(PreferenceConstants.CVIEW_GROUP_MACROS, fCViewGroupMacros.isSelected());
prefs.setValue(PreferenceConstants.OUTLINE_GROUP_INCLUDES, fOutlineGroupIncludes.isSelected());
prefs.setValue(PreferenceConstants.OUTLINE_GROUP_NAMESPACES, fOutlineGroupNamespaces.isSelected());
@@ -219,8 +222,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben
try {
InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).flush();
IEclipsePreferences corePluginNode = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID);
- corePluginNode.putBoolean(
- CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT,
+ corePluginNode.putBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT,
fShowSourceRootsAtTopOfProject.isSelected());
corePluginNode.flush();
} catch (BackingStoreException exc) {
@@ -228,25 +230,27 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben
}
return super.performOk();
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
@Override
protected void performDefaults() {
- IPreferenceStore prefs= getPreferenceStore();
+ IPreferenceStore prefs = getPreferenceStore();
fShowTUChildren.setSelection(prefs.getDefaultBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN));
fCViewGroupIncludes.setSelection(prefs.getDefaultBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES));
- fCViewSeparateHeaderAndSource.setSelection(prefs.getDefaultBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE));
+ fCViewSeparateHeaderAndSource
+ .setSelection(prefs.getDefaultBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE));
fCViewGroupMacros.setSelection(prefs.getDefaultBoolean(PreferenceConstants.CVIEW_GROUP_MACROS));
fOutlineGroupIncludes.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES));
fOutlineGroupNamespaces.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES));
fOutlineGroupMembers.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS));
fOutlineGroupMacros.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS));
- boolean showSourceRootsPref = DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).getBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true);
+ boolean showSourceRootsPref = DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID)
+ .getBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true);
fShowSourceRootsAtTopOfProject.setSelection(showSourceRootsPref);
- fCViewSortOrderOfExcludedFiles.setSelection(prefs.getDefaultBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES));
+ fCViewSortOrderOfExcludedFiles
+ .setSelection(prefs.getDefaultBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES));
super.performDefaults();
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
index d4a26b5a79a..22ecffafcc3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
@@ -81,7 +81,6 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
private IntegerFieldEditor buildCount;
private IntegerFieldEditor wrapLinesMax;
-
public BuildConsolePreferencePage() {
super(GRID);
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
@@ -113,28 +112,32 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
buildCount = new IntegerFieldEditor(PREF_BUILDCONSOLE_LINES,
CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.label"), parent); //$NON-NLS-1$
- buildCount.getLabelControl(parent).setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.tooltip")); //$NON-NLS-1$
- buildCount.getTextControl(parent).setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.tooltip")); //$NON-NLS-1$
+ buildCount.getLabelControl(parent)
+ .setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.tooltip")); //$NON-NLS-1$
+ buildCount.getTextControl(parent)
+ .setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.tooltip")); //$NON-NLS-1$
buildCount.setErrorMessage(CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.errorMessage")); //$NON-NLS-1$
buildCount.setValidRange(10, Integer.MAX_VALUE);
addField(buildCount);
IntegerFieldEditor updateDelay = new IntegerFieldEditor(PREF_BUILDCONSOLE_UPDATE_DELAY_MS,
CUIPlugin.getResourceString("ConsolePreferencePage.consoleUpdateDelay.label"), parent); //$NON-NLS-1$
- updateDelay.getLabelControl(parent).setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleUpdateDelay.tooltip")); //$NON-NLS-1$
- updateDelay.getTextControl(parent).setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleUpdateDelay.tooltip")); //$NON-NLS-1$
- updateDelay.setErrorMessage(CUIPlugin.getResourceString("ConsolePreferencePage.consoleUpdateDelay.errorMessage")); //$NON-NLS-1$
+ updateDelay.getLabelControl(parent)
+ .setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleUpdateDelay.tooltip")); //$NON-NLS-1$
+ updateDelay.getTextControl(parent)
+ .setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleUpdateDelay.tooltip")); //$NON-NLS-1$
+ updateDelay
+ .setErrorMessage(CUIPlugin.getResourceString("ConsolePreferencePage.consoleUpdateDelay.errorMessage")); //$NON-NLS-1$
updateDelay.setValidRange(0, Integer.MAX_VALUE);
addField(updateDelay);
wrapLinesMax = new IntegerFieldEditor(PREF_BUILDCONSOLE_WRAP_LINES_MAX,
CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.label"), parent); //$NON-NLS-1$
- wrapLinesMax.getLabelControl(parent).setToolTipText(
- CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.tooltip")); //$NON-NLS-1$
- wrapLinesMax.getTextControl(parent).setToolTipText(
- CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.tooltip")); //$NON-NLS-1$
- wrapLinesMax.setErrorMessage(
- CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.errorMessage")); //$NON-NLS-1$
+ wrapLinesMax.getLabelControl(parent)
+ .setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.tooltip")); //$NON-NLS-1$
+ wrapLinesMax.getTextControl(parent)
+ .setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.tooltip")); //$NON-NLS-1$
+ wrapLinesMax.setErrorMessage(CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.errorMessage")); //$NON-NLS-1$
wrapLinesMax.setValidRange(0, Integer.MAX_VALUE);
addField(wrapLinesMax);
@@ -186,7 +189,7 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
setWrapLinesEnablement();
super.propertyChange(event);
}
-
+
private Label createLabel(Composite parent, String text) {
Label label = new Label(parent, SWT.LEFT);
label.setText(text);
@@ -196,6 +199,7 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
label.setLayoutData(data);
return label;
}
+
/**
* Creates a new color field editor.
*/
@@ -241,7 +245,7 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
public static int buildConsoleLines() {
return CUIPlugin.getDefault().getPreferenceStore().getInt(PREF_BUILDCONSOLE_LINES);
}
-
+
public static int buildConsoleUpdateDelayMs() {
return CUIPlugin.getDefault().getPreferenceStore().getInt(PREF_BUILDCONSOLE_UPDATE_DELAY_MS);
}
@@ -251,37 +255,39 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
}
public static void initDefaults(IPreferenceStore prefs, boolean unconditionally) {
- if(unconditionally || !prefs.contains(PREF_CLEAR_CONSOLE))
+ if (unconditionally || !prefs.contains(PREF_CLEAR_CONSOLE))
prefs.setDefault(PREF_CLEAR_CONSOLE, true);
- if(unconditionally || !prefs.contains(PREF_AUTO_OPEN_CONSOLE))
+ if (unconditionally || !prefs.contains(PREF_AUTO_OPEN_CONSOLE))
prefs.setDefault(PREF_AUTO_OPEN_CONSOLE, true);
- if(unconditionally || !prefs.contains(PREF_CONSOLE_ON_TOP))
+ if (unconditionally || !prefs.contains(PREF_CONSOLE_ON_TOP))
prefs.setDefault(PREF_CONSOLE_ON_TOP, true);
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_WRAP_LINES))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_WRAP_LINES))
prefs.setDefault(PREF_BUILDCONSOLE_WRAP_LINES, false);
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_LINES))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_LINES))
prefs.setDefault(PREF_BUILDCONSOLE_LINES, 500);
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_WRAP_LINES_MAX))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_WRAP_LINES_MAX))
prefs.setDefault(PREF_BUILDCONSOLE_WRAP_LINES_MAX, 5000);
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_UPDATE_DELAY_MS))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_UPDATE_DELAY_MS))
prefs.setDefault(PREF_BUILDCONSOLE_UPDATE_DELAY_MS, DEFAULT_BUILDCONSOLE_UPDATE_DELAY_MS);
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_TAB_WIDTH))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_TAB_WIDTH))
prefs.setDefault(PREF_BUILDCONSOLE_TAB_WIDTH, 4);
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_OUTPUT_COLOR))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_OUTPUT_COLOR))
PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_OUTPUT_COLOR, new RGB(0, 0, 0));
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_INFO_COLOR))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_INFO_COLOR))
PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_INFO_COLOR, new RGB(0, 0, 255));
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_ERROR_COLOR))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_ERROR_COLOR))
PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_ERROR_COLOR, new RGB(255, 0, 0));
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_BACKGROUND_COLOR))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_BACKGROUND_COLOR))
PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_BACKGROUND_COLOR, new RGB(255, 255, 255));
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR))
PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR, new RGB(254, 231, 224));
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR))
- PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR, new RGB(254, 243, 218));
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR))
- PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR, new RGB(244, 247, 254));
- if(unconditionally || !prefs.contains(PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR))
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR))
+ PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR,
+ new RGB(254, 243, 218));
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR))
+ PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR,
+ new RGB(244, 247, 254));
+ if (unconditionally || !prefs.contains(PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR))
PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR, new RGB(255, 0, 0));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.java
index 34c806f798f..3ee41c0645c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.java
@@ -54,8 +54,8 @@ public class BuildLogPreferencePage extends PropertyPage implements ICOptionCont
@Override
protected Control createContents(Composite parent) {
IProject project = getProject();
- isProjectLevel= project != null;
- if(isProjectLevel) {
+ isProjectLevel = project != null;
+ if (isProjectLevel) {
BuildConsoleManager consoleManager = getConsoleManager();
Preferences prefs = consoleManager.getBuildLogPreferences(project);
@@ -65,9 +65,11 @@ public class BuildLogPreferencePage extends PropertyPage implements ICOptionCont
ControlFactory.createEmptySpace(contents, 3);
// [v] Enable Logging
- enableLoggingCheckbox = ControlFactory.createCheckBox(contents, PreferencesMessages.BuildLogPreferencePage_EnableLogging);
+ enableLoggingCheckbox = ControlFactory.createCheckBox(contents,
+ PreferencesMessages.BuildLogPreferencePage_EnableLogging);
((GridData) enableLoggingCheckbox.getLayoutData()).horizontalSpan = 2;
- boolean keepLog = prefs.getBoolean(BuildConsoleManager.KEY_KEEP_LOG, BuildConsoleManager.CONSOLE_KEEP_LOG_DEFAULT);
+ boolean keepLog = prefs.getBoolean(BuildConsoleManager.KEY_KEEP_LOG,
+ BuildConsoleManager.CONSOLE_KEEP_LOG_DEFAULT);
enableLoggingCheckbox.setSelection(keepLog);
enableLoggingCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
@@ -79,18 +81,21 @@ public class BuildLogPreferencePage extends PropertyPage implements ICOptionCont
ControlFactory.createEmptySpace(contents, 3);
// Log file location: [....................]
- logLocationLabel = ControlFactory.createLabel(contents, PreferencesMessages.BuildLogPreferencePage_LogLocation);
+ logLocationLabel = ControlFactory.createLabel(contents,
+ PreferencesMessages.BuildLogPreferencePage_LogLocation);
((GridData) logLocationLabel.getLayoutData()).grabExcessHorizontalSpace = false;
logLocationText = ControlFactory.createTextField(contents, SWT.SINGLE | SWT.BORDER);
- String logLocation = prefs.get(BuildConsoleManager.KEY_LOG_LOCATION, consoleManager.getDefaultConsoleLogLocation(project));
+ String logLocation = prefs.get(BuildConsoleManager.KEY_LOG_LOCATION,
+ consoleManager.getDefaultConsoleLogLocation(project));
logLocationText.setText(logLocation);
logLocationText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
}
});
- ((GridData)logLocationText.getLayoutData()).widthHint = new PixelConverter(parent).convertWidthInCharsToPixels(40);
+ ((GridData) logLocationText.getLayoutData()).widthHint = new PixelConverter(parent)
+ .convertWidthInCharsToPixels(40);
// [Browse...]
browseButton = ControlFactory.createPushButton(contents, PreferencesMessages.BuildLogPreferencePage_Browse);
@@ -118,7 +123,7 @@ public class BuildLogPreferencePage extends PropertyPage implements ICOptionCont
@Override
protected void performDefaults() {
- if(isProjectLevel) {
+ if (isProjectLevel) {
IProject project = getProject();
BuildConsoleManager consoleManager = getConsoleManager();
Preferences prefs = consoleManager.getBuildLogPreferences(project);
@@ -129,8 +134,10 @@ public class BuildLogPreferencePage extends PropertyPage implements ICOptionCont
} catch (BackingStoreException e) {
CUIPlugin.log(e);
}
- logLocationText.setText(prefs.get(BuildConsoleManager.KEY_LOG_LOCATION, consoleManager.getDefaultConsoleLogLocation(project)));
- enableLoggingCheckbox.setSelection(prefs.getBoolean(BuildConsoleManager.KEY_KEEP_LOG, BuildConsoleManager.CONSOLE_KEEP_LOG_DEFAULT));
+ logLocationText.setText(prefs.get(BuildConsoleManager.KEY_LOG_LOCATION,
+ consoleManager.getDefaultConsoleLogLocation(project)));
+ enableLoggingCheckbox.setSelection(
+ prefs.getBoolean(BuildConsoleManager.KEY_KEEP_LOG, BuildConsoleManager.CONSOLE_KEEP_LOG_DEFAULT));
updateEnablements();
}
super.performDefaults();
@@ -138,7 +145,7 @@ public class BuildLogPreferencePage extends PropertyPage implements ICOptionCont
@Override
public boolean performOk() {
- if(isProjectLevel) {
+ if (isProjectLevel) {
BuildConsoleManager consoleManager = getConsoleManager();
Preferences prefs = consoleManager.getBuildLogPreferences(getProject());
prefs.put(BuildConsoleManager.KEY_LOG_LOCATION, logLocationText.getText());
@@ -153,19 +160,19 @@ public class BuildLogPreferencePage extends PropertyPage implements ICOptionCont
}
@Override
- public IProject getProject(){
- IProject project= null;
+ public IProject getProject() {
+ IProject project = null;
IAdaptable elem = getElement();
if (elem instanceof IProject) {
- project= (IProject) elem;
+ project = (IProject) elem;
} else if (elem != null) {
- project= elem.getAdapter(IProject.class);
+ project = elem.getAdapter(IProject.class);
}
return project;
}
private BuildConsoleManager getConsoleManager() {
- return (BuildConsoleManager)CUIPlugin.getDefault().getConsoleManager();
+ return (BuildConsoleManager) CUIPlugin.getDefault().getConsoleManager();
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java
index cd9e5a3f5bb..e336d167057 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java
@@ -82,7 +82,7 @@ import org.eclipse.cdt.internal.ui.text.util.CColorManager;
/**
* Configures C/C++ Editor code coloring preferences.
- *
+ *
* @since 4.0
*/
class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
@@ -102,7 +102,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
private String fStrikethroughKey;
/** Underline preference key */
private String fUnderlineKey;
-
+
/**
* Initialize the item with the given values.
* @param displayName the display name
@@ -112,50 +112,51 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
* @param strikethroughKey the strikethrough preference key
* @param underlineKey the underline preference key
*/
- public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
- fDisplayName= displayName;
- fColorKey= colorKey;
- fBoldKey= boldKey;
- fItalicKey= italicKey;
- fStrikethroughKey= strikethroughKey;
- fUnderlineKey= underlineKey;
+ public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey,
+ String strikethroughKey, String underlineKey) {
+ fDisplayName = displayName;
+ fColorKey = colorKey;
+ fBoldKey = boldKey;
+ fItalicKey = italicKey;
+ fStrikethroughKey = strikethroughKey;
+ fUnderlineKey = underlineKey;
}
-
+
/**
* @return the bold preference key
*/
public String getBoldKey() {
return fBoldKey;
}
-
+
/**
* @return the bold preference key
*/
public String getItalicKey() {
return fItalicKey;
}
-
+
/**
* @return the strikethrough preference key
*/
public String getStrikethroughKey() {
return fStrikethroughKey;
}
-
+
/**
* @return the underline preference key
*/
public String getUnderlineKey() {
return fUnderlineKey;
}
-
+
/**
* @return the color preference key
*/
public String getColorKey() {
return fColorKey;
}
-
+
/**
* @return the display name
*/
@@ -163,11 +164,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
return fDisplayName;
}
}
-
+
private static class SemanticHighlightingColorListItem extends HighlightingColorListItem {
/** Enablement preference key */
private final String fEnableKey;
-
+
/**
* Initialize the item with the given values.
* @param displayName the display name
@@ -178,12 +179,12 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
* @param underlineKey the underlineKey preference key
* @param enableKey the enable preference key
*/
- public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey,
- String italicKey, String strikethroughKey, String underlineKey, String enableKey) {
+ public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey,
+ String strikethroughKey, String underlineKey, String enableKey) {
super(displayName, colorKey, boldKey, italicKey, strikethroughKey, underlineKey);
- fEnableKey= enableKey;
+ fEnableKey = enableKey;
}
-
+
/**
* @return the enablement preference key
*/
@@ -200,7 +201,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
public String getText(Object element) {
if (element instanceof String)
return (String) element;
- return ((HighlightingColorListItem)element).getDisplayName();
+ return ((HighlightingColorListItem) element).getDisplayName();
}
@Override
@@ -225,13 +226,14 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
private class ColorListContentProvider implements ITreeContentProvider {
@Override
public Object[] getElements(Object inputElement) {
- return new String[] {fCodeCategory, fAssemblyCategory, fCommentsCategory, fPreprocessorCategory, fDoxygenCategory};
+ return new String[] { fCodeCategory, fAssemblyCategory, fCommentsCategory, fPreprocessorCategory,
+ fDoxygenCategory };
}
-
+
@Override
public void dispose() {
}
-
+
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@@ -239,7 +241,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof String) {
- String entry= (String) parentElement;
+ String entry = (String) parentElement;
if (fCodeCategory.equals(entry))
return fListModel.subList(11, fListModel.size()).toArray();
if (fAssemblyCategory.equals(entry))
@@ -258,7 +260,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
public Object getParent(Object element) {
if (element instanceof String)
return null;
- int index= fListModel.indexOf(element);
+ int index = fListModel.indexOf(element);
if (index >= 11)
return fCodeCategory;
if (index >= 8)
@@ -279,51 +281,67 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
/**
* Preference key suffix for bold preferences.
*/
- private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX;
+ private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
/**
* Preference key suffix for italic preferences.
*/
- private static final String ITALIC= PreferenceConstants.EDITOR_ITALIC_SUFFIX;
+ private static final String ITALIC = PreferenceConstants.EDITOR_ITALIC_SUFFIX;
/**
* Preference key suffix for strikethrough preferences.
*/
- private static final String STRIKETHROUGH= PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
+ private static final String STRIKETHROUGH = PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
/**
* Preference key suffix for underline preferences.
*/
- private static final String UNDERLINE= PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
-
+ private static final String UNDERLINE = PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
+
/**
* The keys of the overlay store.
*/
- private final String[][] fSyntaxColorListModel= new String[][] {
- { PreferencesMessages.CEditorColoringConfigurationBlock_MultiLine, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_singleLine, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_cCommentTaskTags, PreferenceConstants.EDITOR_TASK_TAG_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_ppDirectives, PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_ppOthers, PreferenceConstants.EDITOR_PP_DEFAULT_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_ppHeaders, PreferenceConstants.EDITOR_PP_HEADER_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_asmLabels, PreferenceConstants.EDITOR_ASM_LABEL_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_asmDirectives, PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenTagRecognized, PreferenceConstants.DOXYGEN_TAG_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenSingleLineComment, PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenMultiLineComment, PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_keywords, PreferenceConstants.EDITOR_C_KEYWORD_COLOR },
-// { PreferencesMessages.CEditorColoringConfigurationBlock_returnKeyword, PreferenceConstants.EDITOR_C_KEYWORD_RETURN_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_builtInTypes, PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_operators, PreferenceConstants.EDITOR_C_OPERATOR_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_strings, PreferenceConstants.EDITOR_C_STRING_COLOR },
+ private final String[][] fSyntaxColorListModel = new String[][] {
+ { PreferencesMessages.CEditorColoringConfigurationBlock_MultiLine,
+ PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_singleLine,
+ PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_cCommentTaskTags,
+ PreferenceConstants.EDITOR_TASK_TAG_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_ppDirectives,
+ PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_ppOthers,
+ PreferenceConstants.EDITOR_PP_DEFAULT_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_ppHeaders,
+ PreferenceConstants.EDITOR_PP_HEADER_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_asmLabels,
+ PreferenceConstants.EDITOR_ASM_LABEL_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_asmDirectives,
+ PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenTagRecognized,
+ PreferenceConstants.DOXYGEN_TAG_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenSingleLineComment,
+ PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenMultiLineComment,
+ PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_keywords,
+ PreferenceConstants.EDITOR_C_KEYWORD_COLOR },
+ // { PreferencesMessages.CEditorColoringConfigurationBlock_returnKeyword, PreferenceConstants.EDITOR_C_KEYWORD_RETURN_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_builtInTypes,
+ PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_operators,
+ PreferenceConstants.EDITOR_C_OPERATOR_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_strings,
+ PreferenceConstants.EDITOR_C_STRING_COLOR },
{ PreferencesMessages.CEditorColoringConfigurationBlock_braces, PreferenceConstants.EDITOR_C_BRACES_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_numbers, PreferenceConstants.EDITOR_C_NUMBER_COLOR },
- { PreferencesMessages.CEditorColoringConfigurationBlock_others, PreferenceConstants.EDITOR_C_DEFAULT_COLOR },
- };
-
- private final String fCodeCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_code;
- private final String fCommentsCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_comments;
- private final String fPreprocessorCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_preprocessor;
- private final String fAssemblyCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_assembly;
- private final String fDoxygenCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_doxygen;
-
+ { PreferencesMessages.CEditorColoringConfigurationBlock_numbers,
+ PreferenceConstants.EDITOR_C_NUMBER_COLOR },
+ { PreferencesMessages.CEditorColoringConfigurationBlock_others,
+ PreferenceConstants.EDITOR_C_DEFAULT_COLOR }, };
+
+ private final String fCodeCategory = PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_code;
+ private final String fCommentsCategory = PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_comments;
+ private final String fPreprocessorCategory = PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_preprocessor;
+ private final String fAssemblyCategory = PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_assembly;
+ private final String fDoxygenCategory = PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_doxygen;
+
private ColorSelector fSyntaxForegroundColorEditor;
private Label fColorEditorLabel;
private Button fEnableSemanticHighlightingCheckbox;
@@ -344,7 +362,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
/**
* Highlighting color list
*/
- private final java.util.List<HighlightingColorListItem> fListModel= new ArrayList<HighlightingColorListItem>();
+ private final java.util.List<HighlightingColorListItem> fListModel = new ArrayList<HighlightingColorListItem>();
/**
* Highlighting color list viewer
*/
@@ -373,63 +391,59 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
public CEditorColoringConfigurationBlock(OverlayPreferenceStore store) {
super(store);
-
- fColorManager= new CColorManager(false);
-
+
+ fColorManager = new CColorManager(false);
+
for (String[] element : fSyntaxColorListModel)
- fListModel.add(new HighlightingColorListItem (
- element[0],
- element[1],
- element[1] + BOLD,
- element[1] + ITALIC,
- element[1] + STRIKETHROUGH,
- element[1] + UNDERLINE));
-
- SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
+ fListModel.add(new HighlightingColorListItem(element[0], element[1], element[1] + BOLD, element[1] + ITALIC,
+ element[1] + STRIKETHROUGH, element[1] + UNDERLINE));
+
+ SemanticHighlighting[] semanticHighlightings = SemanticHighlightings.getSemanticHighlightings();
for (SemanticHighlighting semanticHighlighting : semanticHighlightings) {
if (semanticHighlighting instanceof SemanticHighlightingWithOwnPreference) {
- SemanticHighlightingWithOwnPreference highlighting = (SemanticHighlightingWithOwnPreference) semanticHighlighting;
- fListModel.add(
- new SemanticHighlightingColorListItem(
- highlighting.getDisplayName(),
- SemanticHighlightings.getColorPreferenceKey(highlighting),
- SemanticHighlightings.getBoldPreferenceKey(highlighting),
- SemanticHighlightings.getItalicPreferenceKey(highlighting),
- SemanticHighlightings.getStrikethroughPreferenceKey(highlighting),
- SemanticHighlightings.getUnderlinePreferenceKey(highlighting),
- SemanticHighlightings.getEnabledPreferenceKey(highlighting)
- ));
+ SemanticHighlightingWithOwnPreference highlighting = (SemanticHighlightingWithOwnPreference) semanticHighlighting;
+ fListModel.add(new SemanticHighlightingColorListItem(highlighting.getDisplayName(),
+ SemanticHighlightings.getColorPreferenceKey(highlighting),
+ SemanticHighlightings.getBoldPreferenceKey(highlighting),
+ SemanticHighlightings.getItalicPreferenceKey(highlighting),
+ SemanticHighlightings.getStrikethroughPreferenceKey(highlighting),
+ SemanticHighlightings.getUnderlinePreferenceKey(highlighting),
+ SemanticHighlightings.getEnabledPreferenceKey(highlighting)));
}
}
-
+
store.addKeys(createOverlayStoreKeys());
}
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
- List<OverlayPreferenceStore.OverlayKey> overlayKeys= new ArrayList<OverlayPreferenceStore.OverlayKey>();
+ List<OverlayPreferenceStore.OverlayKey> overlayKeys = new ArrayList<OverlayPreferenceStore.OverlayKey>();
+
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED));
-
- for (int i= 0, n= fListModel.size(); i < n; i++) {
- HighlightingColorListItem item= fListModel.get(i);
+ for (int i = 0, n = fListModel.size(); i < n; i++) {
+ HighlightingColorListItem item = fListModel.get(i);
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, item.getColorKey()));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getBoldKey()));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getItalicKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getStrikethroughKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getUnderlineKey()));
-
+ overlayKeys.add(
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getStrikethroughKey()));
+ overlayKeys
+ .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getUnderlineKey()));
+
if (item instanceof SemanticHighlightingColorListItem)
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ((SemanticHighlightingColorListItem) item).getEnableKey()));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ((SemanticHighlightingColorListItem) item).getEnableKey()));
}
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+
+ OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
}
/**
* Creates page for hover preferences.
- *
+ *
* @param parent the parent composite
* @return the control for the preference page
*/
@@ -438,55 +452,55 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
initializeDialogUnits(parent);
return createSyntaxPage(parent);
}
-
+
/**
- * Returns the number of pixels corresponding to the width of the given
- * number of characters.
- * <p>
- * This method may only be called after <code>initializeDialogUnits</code>
- * has been called.
- * </p>
- * <p>
- * Clients may call this framework method, but should not override it.
- * </p>
- *
- * @param chars
- * the number of characters
- * @return the number of pixels
- */
- private int convertWidthInCharsToPixels(int chars) {
- // test for failure to initialize for backward compatibility
- if (fFontMetrics == null)
- return 0;
- return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
- }
+ * Returns the number of pixels corresponding to the width of the given
+ * number of characters.
+ * <p>
+ * This method may only be called after <code>initializeDialogUnits</code>
+ * has been called.
+ * </p>
+ * <p>
+ * Clients may call this framework method, but should not override it.
+ * </p>
+ *
+ * @param chars
+ * the number of characters
+ * @return the number of pixels
+ */
+ private int convertWidthInCharsToPixels(int chars) {
+ // test for failure to initialize for backward compatibility
+ if (fFontMetrics == null)
+ return 0;
+ return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
+ }
/**
- * Returns the number of pixels corresponding to the height of the given
- * number of characters.
- * <p>
- * This method may only be called after <code>initializeDialogUnits</code>
- * has been called.
- * </p>
- * <p>
- * Clients may call this framework method, but should not override it.
- * </p>
- *
- * @param chars
- * the number of characters
- * @return the number of pixels
- */
- private int convertHeightInCharsToPixels(int chars) {
- // test for failure to initialize for backward compatibility
- if (fFontMetrics == null)
- return 0;
- return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
- }
-
+ * Returns the number of pixels corresponding to the height of the given
+ * number of characters.
+ * <p>
+ * This method may only be called after <code>initializeDialogUnits</code>
+ * has been called.
+ * </p>
+ * <p>
+ * Clients may call this framework method, but should not override it.
+ * </p>
+ *
+ * @param chars
+ * the number of characters
+ * @return the number of pixels
+ */
+ private int convertHeightInCharsToPixels(int chars) {
+ // test for failure to initialize for backward compatibility
+ if (fFontMetrics == null)
+ return 0;
+ return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
+ }
+
@Override
public void initialize() {
super.initialize();
-
+
fListViewer.setInput(fListModel);
fListViewer.setSelection(new StructuredSelection(fCodeCategory));
}
@@ -494,7 +508,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
@Override
public void performDefaults() {
super.performDefaults();
-
+
fListViewer.refresh();
handleSyntaxColorListSelection();
@@ -517,7 +531,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
}
private void handleSyntaxColorListSelection() {
- HighlightingColorListItem item= getHighlightingColorListItem();
+ HighlightingColorListItem item = getHighlightingColorListItem();
if (item == null) {
fEnableCheckbox.setEnabled(false);
fSyntaxForegroundColorEditor.getButton().setEnabled(false);
@@ -528,16 +542,18 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
fUnderlineCheckBox.setEnabled(false);
return;
}
- RGB rgb= PreferenceConverter.getColor(getPreferenceStore(), item.getColorKey());
+ RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), item.getColorKey());
fSyntaxForegroundColorEditor.setColorValue(rgb);
fBoldCheckBox.setSelection(getPreferenceStore().getBoolean(item.getBoldKey()));
fItalicCheckBox.setSelection(getPreferenceStore().getBoolean(item.getItalicKey()));
fStrikethroughCheckBox.setSelection(getPreferenceStore().getBoolean(item.getStrikethroughKey()));
fUnderlineCheckBox.setSelection(getPreferenceStore().getBoolean(item.getUnderlineKey()));
if (item instanceof SemanticHighlightingColorListItem) {
- boolean semanticHighlightingEnabled= getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED);
+ boolean semanticHighlightingEnabled = getPreferenceStore()
+ .getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED);
fEnableCheckbox.setEnabled(semanticHighlightingEnabled);
- boolean enable= semanticHighlightingEnabled && getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey());
+ boolean enable = semanticHighlightingEnabled
+ && getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey());
fEnableCheckbox.setSelection(enable);
fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
fColorEditorLabel.setEnabled(enable);
@@ -556,15 +572,15 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
fEnableCheckbox.setSelection(true);
}
}
-
+
private Control createSyntaxPage(final Composite parent) {
- Composite colorComposite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ Composite colorComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
colorComposite.setLayout(layout);
- Link link= new Link(colorComposite, SWT.NONE);
+ Link link = new Link(colorComposite, SWT.NONE);
link.setText(PreferencesMessages.CEditorColoringConfigurationBlock_link);
link.addSelectionListener(new SelectionAdapter() {
@Override
@@ -574,34 +590,34 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
});
// TODO replace by link-specific tooltips when
// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
-// link.setToolTipText(PreferencesMessages.CEditorColoringConfigurationBlock_link_tooltip);
-
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gridData.widthHint= 150; // only expand further if anyone else requires it
- gridData.horizontalSpan= 2;
+ // link.setToolTipText(PreferencesMessages.CEditorColoringConfigurationBlock_link_tooltip);
+
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ gridData.widthHint = 150; // only expand further if anyone else requires it
+ gridData.horizontalSpan = 2;
link.setLayoutData(gridData);
addFiller(colorComposite, 1);
- fEnableSemanticHighlightingCheckbox= addCheckBox(colorComposite,
+ fEnableSemanticHighlightingCheckbox = addCheckBox(colorComposite,
PreferencesMessages.CEditorColoringConfigurationBlock_enable_semantic_highlighting,
PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, 0);
-
+
Label label;
- label= new Label(colorComposite, SWT.LEFT);
+ label = new Label(colorComposite, SWT.LEFT);
label.setText(PreferencesMessages.CEditorColoringConfigurationBlock_coloring_element);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite editorComposite= new Composite(colorComposite, SWT.NONE);
- layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+
+ Composite editorComposite = new Composite(colorComposite, SWT.NONE);
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
editorComposite.setLayout(layout);
- GridData gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
editorComposite.setLayoutData(gd);
-
- fListViewer= new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
+
+ fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
fListViewer.setLabelProvider(new ColorListLabelProvider());
fListViewer.setContentProvider(new ColorListContentProvider());
fListViewer.setComparator(new ViewerComparator(Collator.getInstance()) {
@@ -621,122 +637,126 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
return 0;
}
});
- gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true);
- gd.heightHint= convertHeightInCharsToPixels(9);
- int maxWidth= 0;
+ gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true);
+ gd.heightHint = convertHeightInCharsToPixels(9);
+ int maxWidth = 0;
for (HighlightingColorListItem item : fListModel) {
- maxWidth= Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
+ maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
}
- ScrollBar vBar= ((Scrollable) fListViewer.getControl()).getVerticalBar();
+ ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
if (vBar != null)
maxWidth += vBar.getSize().x * 3; // scrollbars and tree indentation guess
- gd.widthHint= maxWidth;
-
+ gd.widthHint = maxWidth;
+
fListViewer.getControl().setLayoutData(gd);
-
- Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
- layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
+
+ Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
stylesComposite.setLayout(layout);
stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fEnableCheckbox= new Button(stylesComposite, SWT.CHECK);
+
+ fEnableCheckbox = new Button(stylesComposite, SWT.CHECK);
fEnableCheckbox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_enable);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment = GridData.BEGINNING;
+ gd.horizontalSpan = 2;
fEnableCheckbox.setLayoutData(gd);
-
- fColorEditorLabel= new Label(stylesComposite, SWT.LEFT);
+
+ fColorEditorLabel = new Label(stylesComposite, SWT.LEFT);
fColorEditorLabel.setText(PreferencesMessages.CEditorColoringConfigurationBlock_color);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = 20;
fColorEditorLabel.setLayoutData(gd);
-
- fSyntaxForegroundColorEditor= new ColorSelector(stylesComposite);
- Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton();
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+
+ fSyntaxForegroundColorEditor = new ColorSelector(stylesComposite);
+ Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
foregroundColorButton.setLayoutData(gd);
-
- fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
+
+ fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
fBoldCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_bold);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = 20;
+ gd.horizontalSpan = 2;
fBoldCheckBox.setLayoutData(gd);
-
- fItalicCheckBox= new Button(stylesComposite, SWT.CHECK);
+
+ fItalicCheckBox = new Button(stylesComposite, SWT.CHECK);
fItalicCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_italic);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = 20;
+ gd.horizontalSpan = 2;
fItalicCheckBox.setLayoutData(gd);
-
- fStrikethroughCheckBox= new Button(stylesComposite, SWT.CHECK);
+
+ fStrikethroughCheckBox = new Button(stylesComposite, SWT.CHECK);
fStrikethroughCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_strikethrough);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = 20;
+ gd.horizontalSpan = 2;
fStrikethroughCheckBox.setLayoutData(gd);
-
- fUnderlineCheckBox= new Button(stylesComposite, SWT.CHECK);
+
+ fUnderlineCheckBox = new Button(stylesComposite, SWT.CHECK);
fUnderlineCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_underline);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 20;
- gd.horizontalSpan= 2;
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = 20;
+ gd.horizontalSpan = 2;
fUnderlineCheckBox.setLayoutData(gd);
-
- label= new Label(colorComposite, SWT.LEFT);
+
+ label = new Label(colorComposite, SWT.LEFT);
label.setText(PreferencesMessages.CEditorColoringConfigurationBlock_preview);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Control previewer= createPreviewer(colorComposite);
- gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(20);
- gd.heightHint= convertHeightInCharsToPixels(5);
+
+ Control previewer = createPreviewer(colorComposite);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = convertWidthInCharsToPixels(20);
+ gd.heightHint = convertHeightInCharsToPixels(5);
previewer.setLayoutData(gd);
-
+
fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleSyntaxColorListSelection();
}
});
-
+
foregroundColorButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
- PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue());
+ HighlightingColorListItem item = getHighlightingColorListItem();
+ PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(),
+ fSyntaxForegroundColorEditor.getColorValue());
}
});
-
+
fBoldCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
+ HighlightingColorListItem item = getHighlightingColorListItem();
getPreferenceStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection());
}
});
-
+
fItalicCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
+ HighlightingColorListItem item = getHighlightingColorListItem();
getPreferenceStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection());
}
});
@@ -745,35 +765,38 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
+ HighlightingColorListItem item = getHighlightingColorListItem();
getPreferenceStore().setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection());
}
});
-
+
fUnderlineCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
+ HighlightingColorListItem item = getHighlightingColorListItem();
getPreferenceStore().setValue(item.getUnderlineKey(), fUnderlineCheckBox.getSelection());
}
});
-
+
fEnableCheckbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- HighlightingColorListItem item= getHighlightingColorListItem();
+ HighlightingColorListItem item = getHighlightingColorListItem();
if (item instanceof SemanticHighlightingColorListItem) {
- boolean enable= fEnableCheckbox.getSelection();
+ boolean enable = fEnableCheckbox.getSelection();
getPreferenceStore().setValue(((SemanticHighlightingColorListItem) item).getEnableKey(), enable);
fEnableCheckbox.setSelection(enable);
fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
@@ -787,16 +810,17 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
}
}
});
-
+
fEnableSemanticHighlightingCheckbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
+
@Override
public void widgetSelected(SelectionEvent e) {
fListViewer.refresh(true);
- HighlightingColorListItem item= getHighlightingColorListItem();
+ HighlightingColorListItem item = getHighlightingColorListItem();
if (item instanceof SemanticHighlightingColorListItem) {
handleSyntaxColorListSelection();
uninstallSemanticHighlighting();
@@ -804,61 +828,62 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
}
}
});
-
+
colorComposite.layout(false);
-
+
return colorComposite;
}
-
+
private void addFiller(Composite composite, int horizontalSpan) {
- PixelConverter pixelConverter= new PixelConverter(composite);
- Label filler= new Label(composite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= horizontalSpan;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+ PixelConverter pixelConverter = new PixelConverter(composite);
+ Label filler = new Label(composite, SWT.LEFT);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = horizontalSpan;
+ gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2;
filler.setLayoutData(gd);
}
private Control createPreviewer(Composite parent) {
- IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
+ IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
// Task tags can have their own coloring, and to demonstrate this, the preview code
- // contains a "TODO" task tag. In order for the comment scanner to recognize this
+ // contains a "TODO" task tag. In order for the comment scanner to recognize this
// as a task tag and apply the coloring, "TODO" needs to be present under the
// TODO_TASK_TAGS preference key. Normally this is contained in the core preference
// store, but since the user can override the set of task tags, we provide a custom
// preference store that always has "TODO" under that key.
- IPreferenceStore taskTagPreferenceStore= new PreferenceStore();
- taskTagPreferenceStore.setValue(CCorePreferenceConstants.TODO_TASK_TAGS, "TODO"); //$NON-NLS-1$
- IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(),
- taskTagPreferenceStore, generalTextStore });
+ IPreferenceStore taskTagPreferenceStore = new PreferenceStore();
+ taskTagPreferenceStore.setValue(CCorePreferenceConstants.TODO_TASK_TAGS, "TODO"); //$NON-NLS-1$
+ IPreferenceStore store = new ChainedPreferenceStore(
+ new IPreferenceStore[] { getPreferenceStore(), taskTagPreferenceStore, generalTextStore });
fPreviewViewer = new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
- SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration(fColorManager, store, null, ICPartitions.C_PARTITIONING, false);
+ SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration(fColorManager, store,
+ null, ICPartitions.C_PARTITIONING, false);
fPreviewViewer.configure(configuration);
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+ Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
fPreviewViewer.getTextWidget().setFont(font);
CSourcePreviewerUpdater.registerPreviewer(fPreviewViewer, configuration, store);
fPreviewViewer.setEditable(false);
-
- String libraryDecls= loadPreviewContentFromFile("ColorSettingPreviewLibraryDecls.txt"); //$NON-NLS-1$
- fPreviewerLibraryDecls= libraryDecls;
- String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
- IDocument document= new Document(content);
+
+ String libraryDecls = loadPreviewContentFromFile("ColorSettingPreviewLibraryDecls.txt"); //$NON-NLS-1$
+ fPreviewerLibraryDecls = libraryDecls;
+ String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
+ IDocument document = new Document(content);
CUIPlugin.getDefault().getTextTools().setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
fPreviewViewer.setDocument(document);
-
+
installSemanticHighlighting();
-
+
return fPreviewViewer.getControl();
}
private String loadPreviewContentFromFile(String filename) {
String line;
- String separator= System.getProperty("line.separator"); //$NON-NLS-1$
- StringBuilder buffer= new StringBuilder(512);
- BufferedReader reader= null;
+ String separator = System.getProperty("line.separator"); //$NON-NLS-1$
+ StringBuilder buffer = new StringBuilder(512);
+ BufferedReader reader = null;
try {
- reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
- while ((line= reader.readLine()) != null) {
+ reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
+ while ((line = reader.readLine()) != null) {
buffer.append(line);
buffer.append(separator);
}
@@ -866,7 +891,10 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
CUIPlugin.log(io);
} finally {
if (reader != null) {
- try { reader.close(); } catch (IOException e) {}
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
}
}
return buffer.toString();
@@ -877,7 +905,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
*/
private void installSemanticHighlighting() {
if (fSemanticHighlightingManager == null) {
- fSemanticHighlightingManager= new SemanticHighlightingManager();
+ fSemanticHighlightingManager = new SemanticHighlightingManager();
fSemanticHighlightingManager.install(fPreviewViewer, fColorManager, getPreferenceStore(),
fPreviewerLibraryDecls);
}
@@ -889,39 +917,39 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
private void uninstallSemanticHighlighting() {
if (fSemanticHighlightingManager != null) {
fSemanticHighlightingManager.uninstall();
- fSemanticHighlightingManager= null;
+ fSemanticHighlightingManager = null;
}
}
/**
* Returns the current highlighting color list item.
- *
+ *
* @return the current highlighting color list item
*/
private HighlightingColorListItem getHighlightingColorListItem() {
- IStructuredSelection selection= (IStructuredSelection) fListViewer.getSelection();
- Object element= selection.getFirstElement();
+ IStructuredSelection selection = (IStructuredSelection) fListViewer.getSelection();
+ Object element = selection.getFirstElement();
if (element instanceof String)
return null;
return (HighlightingColorListItem) element;
}
-
+
/**
- * Initializes the computation of horizontal and vertical dialog units based
- * on the size of current font.
- * <p>
- * This method must be called before any of the dialog unit based conversion
- * methods are called.
- * </p>
- *
- * @param testControl
- * a control from which to obtain the current font
- */
- private void initializeDialogUnits(Control testControl) {
- // Compute and store a font metric
- GC gc = new GC(testControl);
- gc.setFont(JFaceResources.getDialogFont());
- fFontMetrics = gc.getFontMetrics();
- gc.dispose();
- }
+ * Initializes the computation of horizontal and vertical dialog units based
+ * on the size of current font.
+ * <p>
+ * This method must be called before any of the dialog unit based conversion
+ * methods are called.
+ * </p>
+ *
+ * @param testControl
+ * a control from which to obtain the current font
+ */
+ private void initializeDialogUnits(Control testControl) {
+ // Compute and store a font metric
+ GC gc = new GC(testControl);
+ gc.setFont(JFaceResources.getDialogFont());
+ fFontMetrics = gc.getFontMetrics();
+ gc.dispose();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java
index e76147598ef..a8eda814ca4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java
@@ -26,7 +26,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* <p>
* Note: Must be public since it is referenced from plugin.xml
* </p>
- *
+ *
* @since 4.0
*/
public class CEditorColoringPreferencePage extends AbstractConfigurationBlockPreferencePage {
@@ -37,15 +37,15 @@ public class CEditorColoringPreferencePage extends AbstractConfigurationBlockPre
@Override
protected void setDescription() {
- String description= PreferencesMessages.CEditorPreferencePage_colors;
+ String description = PreferencesMessages.CEditorPreferencePage_colors;
setDescription(description);
}
-
+
@Override
protected Label createDescriptionLabel(Composite parent) {
return null;
}
-
+
@Override
protected void setPreferenceStore() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java
index 16ecfba128b..7563add6a90 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java
@@ -72,55 +72,54 @@ import org.eclipse.cdt.internal.ui.util.TableLayoutComposite;
* Configures C/C++ Editor hover preferences.
*/
public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationBlock {
- static final String DELIMITER= PreferencesMessages.CEditorHoverConfigurationBlock_delimiter;
+ static final String DELIMITER = PreferencesMessages.CEditorHoverConfigurationBlock_delimiter;
- private static final int ENABLED_PROP= 0;
- private static final int MODIFIER_PROP= 1;
+ private static final int ENABLED_PROP = 0;
+ private static final int MODIFIER_PROP = 1;
// Data structure to hold the values which are edited by the user
private static class HoverConfig {
-
+
String fModifierString;
boolean fIsEnabled;
int fStateMask;
private HoverConfig(String modifier, int stateMask, boolean enabled) {
- fModifierString= modifier;
- fIsEnabled= enabled;
- fStateMask= stateMask;
+ fModifierString = modifier;
+ fIsEnabled = enabled;
+ fStateMask = stateMask;
}
}
-
-
+
private class CEditorTextHoverDescriptorLabelProvider implements ITableLabelProvider {
@Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
-
+
@Override
public String getColumnText(Object element, int columnIndex) {
switch (columnIndex) {
case ENABLED_PROP:
- return ((CEditorTextHoverDescriptor)element).getLabel();
+ return ((CEditorTextHoverDescriptor) element).getLabel();
case MODIFIER_PROP:
- TableItem item= (TableItem)fHoverTableViewer.testFindItem(element);
- int index= fHoverTable.indexOf(item);
+ TableItem item = (TableItem) fHoverTableViewer.testFindItem(element);
+ int index = fHoverTable.indexOf(item);
return fHoverConfigs[index].fModifierString;
default:
break;
}
-
+
return null;
}
@Override
public void addListener(ILabelProviderListener listener) {
}
-
+
@Override
public void dispose() {
}
@@ -134,26 +133,24 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
public void removeListener(ILabelProviderListener listener) {
}
}
-
-
+
private class CEditorTextHoverDescriptorContentProvider implements IStructuredContentProvider {
-
+
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Do nothing since the viewer listens to resource deltas
}
-
+
@Override
public void dispose() {
}
-
+
@Override
public Object[] getElements(Object element) {
- return (Object[])element;
+ return (Object[]) element;
}
}
-
OverlayPreferenceStore fStore;
HoverConfig[] fHoverConfigs;
Text fModifierEditor;
@@ -162,42 +159,45 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
private TableColumn fNameColumn;
private TableColumn fModifierColumn;
private Text fDescription;
- private Map<Button, String> fCheckBoxes= new HashMap<>();
- private SelectionListener fCheckBoxListener= new SelectionListener() {
+ private Map<Button, String> fCheckBoxes = new HashMap<>();
+ private SelectionListener fCheckBoxListener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
+ Button button = (Button) e.widget;
fStore.setValue(fCheckBoxes.get(button), button.getSelection());
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
+ Button button = (Button) e.widget;
fStore.setValue(fCheckBoxes.get(button), button.getSelection());
}
};
-
+
private PreferencePage fMainPreferencePage;
private StatusInfo fStatus;
-
+
public CEditorHoverConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) {
Assert.isNotNull(mainPreferencePage);
Assert.isNotNull(store);
- fMainPreferencePage= mainPreferencePage;
- fStore= store;
+ fMainPreferencePage = mainPreferencePage;
+ fStore = store;
fStore.addKeys(createOverlayStoreKeys());
}
-
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+
+ ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
+
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
+
+ OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
}
@@ -211,42 +211,42 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
@Override
public Control createControl(Composite parent) {
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ ScrolledPageContent scrolled = new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
-
- Composite hoverComposite= new Composite(scrolled, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+ Composite hoverComposite = new Composite(scrolled, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
hoverComposite.setLayout(layout);
hoverComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- String rollOverLabel= PreferencesMessages.CEditorHoverConfigurationBlock_annotationRollover;
+
+ String rollOverLabel = PreferencesMessages.CEditorHoverConfigurationBlock_annotationRollover;
addCheckBox(hoverComposite, rollOverLabel, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER, 0);
//addFiller(hoverComposite);
- Label label= new Label(hoverComposite, SWT.NONE);
- label.setText(PreferencesMessages.CEditorHoverConfigurationBlock_hoverPreferences);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
+ Label label = new Label(hoverComposite, SWT.NONE);
+ label.setText(PreferencesMessages.CEditorHoverConfigurationBlock_hoverPreferences);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment = GridData.BEGINNING;
+ gd.horizontalSpan = 2;
label.setLayoutData(gd);
- TableLayoutComposite layouter= new TableLayoutComposite(hoverComposite, SWT.NONE);
+ TableLayoutComposite layouter = new TableLayoutComposite(hoverComposite, SWT.NONE);
addColumnLayoutData(layouter);
// Hover table
- fHoverTable= new Table(layouter, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
+ fHoverTable = new Table(layouter,
+ SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
fHoverTable.setHeaderVisible(true);
fHoverTable.setLinesVisible(true);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint= SWTUtil.getTableHeightHint(fHoverTable, 10);
- gd.horizontalSpan= 2;
- gd.widthHint= new PixelConverter(parent).convertWidthInCharsToPixels(30);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = SWTUtil.getTableHeightHint(fHoverTable, 10);
+ gd.horizontalSpan = 2;
+ gd.widthHint = new PixelConverter(parent).convertWidthInCharsToPixels(30);
layouter.setLayoutData(gd);
fHoverTable.addSelectionListener(new SelectionListener() {
@@ -254,43 +254,44 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
public void widgetSelected(SelectionEvent e) {
handleHoverListSelection();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
- TableLayout tableLayout= new TableLayout();
+ TableLayout tableLayout = new TableLayout();
fHoverTable.setLayout(tableLayout);
- fNameColumn= new TableColumn(fHoverTable, SWT.NONE);
- fNameColumn.setText(PreferencesMessages.CEditorHoverConfigurationBlock_nameColumnTitle);
+ fNameColumn = new TableColumn(fHoverTable, SWT.NONE);
+ fNameColumn.setText(PreferencesMessages.CEditorHoverConfigurationBlock_nameColumnTitle);
fNameColumn.setResizable(true);
- fModifierColumn= new TableColumn(fHoverTable, SWT.NONE);
- fModifierColumn.setText(PreferencesMessages.CEditorHoverConfigurationBlock_modifierColumnTitle);
+ fModifierColumn = new TableColumn(fHoverTable, SWT.NONE);
+ fModifierColumn.setText(PreferencesMessages.CEditorHoverConfigurationBlock_modifierColumnTitle);
fModifierColumn.setResizable(true);
- fHoverTableViewer= new CheckboxTableViewer(fHoverTable);
+ fHoverTableViewer = new CheckboxTableViewer(fHoverTable);
fHoverTableViewer.setUseHashlookup(true);
fHoverTableViewer.setContentProvider(new CEditorTextHoverDescriptorContentProvider());
fHoverTableViewer.setLabelProvider(new CEditorTextHoverDescriptorLabelProvider());
-
- ((CheckboxTableViewer)fHoverTableViewer).addCheckStateListener(new ICheckStateListener() {
+
+ ((CheckboxTableViewer) fHoverTableViewer).addCheckStateListener(new ICheckStateListener() {
/*
* @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
- String id= ((CEditorTextHoverDescriptor)event.getElement()).getId();
+ String id = ((CEditorTextHoverDescriptor) event.getElement()).getId();
if (id == null)
return;
- CEditorTextHoverDescriptor[] descriptors= getContributedHovers();
+ CEditorTextHoverDescriptor[] descriptors = getContributedHovers();
HoverConfig hoverConfig = null;
- int i= 0, length= fHoverConfigs.length;
+ int i = 0, length = fHoverConfigs.length;
while (i < length) {
if (id.equals(descriptors[i].getId())) {
hoverConfig = fHoverConfigs[i];
- hoverConfig.fIsEnabled= event.getChecked();
+ hoverConfig.fIsEnabled = event.getChecked();
fModifierEditor.setEnabled(event.getChecked());
break;
}
@@ -299,48 +300,56 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
updateStatus(hoverConfig);
}
});
-
+
// Text field for modifier string
- label= new Label(hoverComposite, SWT.LEFT);
- label.setText(PreferencesMessages.CEditorHoverConfigurationBlock_keyModifier);
- fModifierEditor= new Text(hoverComposite, SWT.BORDER);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ label = new Label(hoverComposite, SWT.LEFT);
+ label.setText(PreferencesMessages.CEditorHoverConfigurationBlock_keyModifier);
+ fModifierEditor = new Text(hoverComposite, SWT.BORDER);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
fModifierEditor.setLayoutData(gd);
fModifierEditor.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
+
@Override
public void keyPressed(KeyEvent e) {
- isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
+ isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
-
+
@Override
public void keyReleased(KeyEvent e) {
if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) {
- String text= fModifierEditor.getText();
- Point selection= fModifierEditor.getSelection();
- int i= selection.x - 1;
+ String text = fModifierEditor.getText();
+ Point selection = fModifierEditor.getSelection();
+ int i = selection.x - 1;
while (i > -1 && Character.isWhitespace(text.charAt(i))) {
i--;
}
- boolean needsPrefixDelimiter= i > -1 && !String.valueOf(text.charAt(i)).equals(DELIMITER);
+ boolean needsPrefixDelimiter = i > -1 && !String.valueOf(text.charAt(i)).equals(DELIMITER);
- i= selection.y;
+ i = selection.y;
while (i < text.length() && Character.isWhitespace(text.charAt(i))) {
i++;
}
- boolean needsPostfixDelimiter= i < text.length() && !String.valueOf(text.charAt(i)).equals(DELIMITER);
+ boolean needsPostfixDelimiter = i < text.length()
+ && !String.valueOf(text.charAt(i)).equals(DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
- insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter, new String[] {Action.findModifierString(e.stateMask)});
+ insertString = NLS.bind(
+ PreferencesMessages.CEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter,
+ new String[] { Action.findModifierString(e.stateMask) });
else if (needsPrefixDelimiter)
- insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertDelimiterAndModifier, new String[] {Action.findModifierString(e.stateMask)});
+ insertString = NLS.bind(
+ PreferencesMessages.CEditorHoverConfigurationBlock_insertDelimiterAndModifier,
+ new String[] { Action.findModifierString(e.stateMask) });
else if (needsPostfixDelimiter)
- insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertModifierAndDelimiter, new String[] {Action.findModifierString(e.stateMask)});
+ insertString = NLS.bind(
+ PreferencesMessages.CEditorHoverConfigurationBlock_insertModifierAndDelimiter,
+ new String[] { Action.findModifierString(e.stateMask) });
else
- insertString= Action.findModifierString(e.stateMask);
+ insertString = Action.findModifierString(e.stateMask);
if (insertString != null)
fModifierEditor.insert(insertString);
@@ -356,27 +365,27 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
});
// Description
- Label descriptionLabel= new Label(hoverComposite, SWT.LEFT);
- descriptionLabel.setText(PreferencesMessages.CEditorHoverConfigurationBlock_description);
- gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- gd.horizontalSpan= 2;
+ Label descriptionLabel = new Label(hoverComposite, SWT.LEFT);
+ descriptionLabel.setText(PreferencesMessages.CEditorHoverConfigurationBlock_description);
+ gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+ gd.horizontalSpan = 2;
descriptionLabel.setLayoutData(gd);
- fDescription= new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
- gd= new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan= 2;
+ fDescription = new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
fDescription.setLayoutData(gd);
initialize();
scrolled.setContent(hoverComposite);
- final Point size= hoverComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ final Point size = hoverComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrolled.setMinSize(size.x, size.y);
Dialog.applyDialogFont(scrolled);
-
+
return scrolled;
}
-
+
private void addColumnLayoutData(TableLayoutComposite layouter) {
layouter.addColumnData(new ColumnWeightData(40, true));
layouter.addColumnData(new ColumnWeightData(60, true));
@@ -391,28 +400,29 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
*/
@Override
public void initialize() {
- CEditorTextHoverDescriptor[] hoverDescs= getContributedHovers();
- fHoverConfigs= new HoverConfig[hoverDescs.length];
- for (int i= 0; i < hoverDescs.length; i++)
- fHoverConfigs[i]= new HoverConfig(hoverDescs[i].getModifierString(), hoverDescs[i].getStateMask(), hoverDescs[i].isEnabled());
+ CEditorTextHoverDescriptor[] hoverDescs = getContributedHovers();
+ fHoverConfigs = new HoverConfig[hoverDescs.length];
+ for (int i = 0; i < hoverDescs.length; i++)
+ fHoverConfigs[i] = new HoverConfig(hoverDescs[i].getModifierString(), hoverDescs[i].getStateMask(),
+ hoverDescs[i].isEnabled());
fHoverTableViewer.setInput(hoverDescs);
-
+
initializeFields();
}
void initializeFields() {
fModifierEditor.setEnabled(false);
- Iterator<Button> e= fCheckBoxes.keySet().iterator();
+ Iterator<Button> e = fCheckBoxes.keySet().iterator();
while (e.hasNext()) {
- Button b= e.next();
- String key= fCheckBoxes.get(b);
+ Button b = e.next();
+ String key = fCheckBoxes.get(b);
b.setSelection(fStore.getBoolean(key));
}
- CEditorTextHoverDescriptor[] hoverDescs= getContributedHovers();
- for (int i= 0; i < hoverDescs.length; i++)
+ CEditorTextHoverDescriptor[] hoverDescs = getContributedHovers();
+ for (int i = 0; i < hoverDescs.length; i++)
fHoverTable.getItem(i).setChecked(hoverDescs[i].isEnabled());
fHoverTableViewer.refresh();
}
@@ -422,19 +432,19 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
*/
@Override
public void performOk() {
- StringBuilder buf= new StringBuilder();
- StringBuilder maskBuf= new StringBuilder();
- for (int i= 0; i < fHoverConfigs.length; i++) {
+ StringBuilder buf = new StringBuilder();
+ StringBuilder maskBuf = new StringBuilder();
+ for (int i = 0; i < fHoverConfigs.length; i++) {
buf.append(getContributedHovers()[i].getId());
buf.append(CEditorTextHoverDescriptor.VALUE_SEPARATOR);
if (!fHoverConfigs[i].fIsEnabled)
buf.append(CEditorTextHoverDescriptor.DISABLED_TAG);
- String modifier= fHoverConfigs[i].fModifierString;
+ String modifier = fHoverConfigs[i].fModifierString;
if (modifier == null || modifier.length() == 0)
- modifier= CEditorTextHoverDescriptor.NO_MODIFIER;
+ modifier = CEditorTextHoverDescriptor.NO_MODIFIER;
buf.append(modifier);
buf.append(CEditorTextHoverDescriptor.VALUE_SEPARATOR);
-
+
maskBuf.append(getContributedHovers()[i].getId());
maskBuf.append(CEditorTextHoverDescriptor.VALUE_SEPARATOR);
maskBuf.append(fHoverConfigs[i].fStateMask);
@@ -442,7 +452,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
}
fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, buf.toString());
fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, maskBuf.toString());
-
+
CUIPlugin.getDefault().resetCEditorTextHoverDescriptors();
}
@@ -457,112 +467,123 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
}
private void restoreFromPreferences() {
- String compiledTextHoverModifiers= fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
-
- StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
- HashMap<String, String> idToModifier= new HashMap<String, String>(tokenizer.countTokens() / 2);
+ String compiledTextHoverModifiers = fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
+
+ StringTokenizer tokenizer = new StringTokenizer(compiledTextHoverModifiers,
+ CEditorTextHoverDescriptor.VALUE_SEPARATOR);
+ HashMap<String, String> idToModifier = new HashMap<String, String>(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
- String id= tokenizer.nextToken();
+ String id = tokenizer.nextToken();
if (tokenizer.hasMoreTokens())
idToModifier.put(id, tokenizer.nextToken());
}
- String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
+ String compiledTextHoverModifierMasks = CUIPlugin.getDefault().getPreferenceStore()
+ .getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
- tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
- HashMap<String, String> idToModifierMask= new HashMap<String, String>(tokenizer.countTokens() / 2);
+ tokenizer = new StringTokenizer(compiledTextHoverModifierMasks, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
+ HashMap<String, String> idToModifierMask = new HashMap<String, String>(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
- String id= tokenizer.nextToken();
+ String id = tokenizer.nextToken();
if (tokenizer.hasMoreTokens())
idToModifierMask.put(id, tokenizer.nextToken());
}
- for (int i= 0; i < fHoverConfigs.length; i++) {
- String modifierString= idToModifier.get(getContributedHovers()[i].getId());
- boolean enabled= true;
+ for (int i = 0; i < fHoverConfigs.length; i++) {
+ String modifierString = idToModifier.get(getContributedHovers()[i].getId());
+ boolean enabled = true;
if (modifierString == null)
- modifierString= CEditorTextHoverDescriptor.DISABLED_TAG;
-
+ modifierString = CEditorTextHoverDescriptor.DISABLED_TAG;
+
if (modifierString.startsWith(CEditorTextHoverDescriptor.DISABLED_TAG)) {
- enabled= false;
- modifierString= modifierString.substring(1);
+ enabled = false;
+ modifierString = modifierString.substring(1);
}
if (modifierString.equals(CEditorTextHoverDescriptor.NO_MODIFIER))
- modifierString= ""; //$NON-NLS-1$
+ modifierString = ""; //$NON-NLS-1$
- fHoverConfigs[i].fModifierString= modifierString;
- fHoverConfigs[i].fIsEnabled= enabled;
- fHoverConfigs[i].fStateMask= CEditorTextHoverDescriptor.computeStateMask(modifierString);
+ fHoverConfigs[i].fModifierString = modifierString;
+ fHoverConfigs[i].fIsEnabled = enabled;
+ fHoverConfigs[i].fStateMask = CEditorTextHoverDescriptor.computeStateMask(modifierString);
if (fHoverConfigs[i].fStateMask == -1) {
try {
- fHoverConfigs[i].fStateMask= Integer.parseInt(idToModifierMask.get(getContributedHovers()[i].getId()));
+ fHoverConfigs[i].fStateMask = Integer
+ .parseInt(idToModifierMask.get(getContributedHovers()[i].getId()));
} catch (NumberFormatException ex) {
- fHoverConfigs[i].fStateMask= -1;
+ fHoverConfigs[i].fStateMask = -1;
}
}
}
}
void handleModifierModified() {
- int i= fHoverTable.getSelectionIndex();
- String modifiers= fModifierEditor.getText();
- fHoverConfigs[i].fModifierString= modifiers;
- fHoverConfigs[i].fStateMask= CEditorTextHoverDescriptor.computeStateMask(modifiers);
+ int i = fHoverTable.getSelectionIndex();
+ String modifiers = fModifierEditor.getText();
+ fHoverConfigs[i].fModifierString = modifiers;
+ fHoverConfigs[i].fStateMask = CEditorTextHoverDescriptor.computeStateMask(modifiers);
if (fHoverConfigs[i].fIsEnabled && fHoverConfigs[i].fStateMask == -1)
- fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValid, fHoverConfigs[i].fModifierString));
+ fStatus = new StatusInfo(IStatus.ERROR,
+ NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValid,
+ fHoverConfigs[i].fModifierString));
else
- fStatus= new StatusInfo();
-
+ fStatus = new StatusInfo();
+
// update table
fHoverTableViewer.refresh(getContributedHovers()[i]);
-
+
updateStatus(fHoverConfigs[i]);
}
- void handleHoverListSelection() {
- int i= fHoverTable.getSelectionIndex();
-
+ void handleHoverListSelection() {
+ int i = fHoverTable.getSelectionIndex();
+
if (i < 0) {
if (fHoverTable.getSelectionCount() == 0)
fModifierEditor.setEnabled(false);
return;
}
-
- boolean enabled= fHoverConfigs[i].fIsEnabled;
+
+ boolean enabled = fHoverConfigs[i].fIsEnabled;
fModifierEditor.setEnabled(enabled);
fModifierEditor.setText(fHoverConfigs[i].fModifierString);
- String description= getContributedHovers()[i].getDescription();
+ String description = getContributedHovers()[i].getDescription();
if (description == null)
- description= ""; //$NON-NLS-1$
+ description = ""; //$NON-NLS-1$
fDescription.setText(description);
}
IStatus getStatus() {
if (fStatus == null)
- fStatus= new StatusInfo();
+ fStatus = new StatusInfo();
return fStatus;
}
void updateStatus(HoverConfig hoverConfig) {
if (hoverConfig != null && hoverConfig.fIsEnabled && hoverConfig.fStateMask == -1)
- fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValid, hoverConfig.fModifierString));
+ fStatus = new StatusInfo(IStatus.ERROR,
+ NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValid,
+ hoverConfig.fModifierString));
else
- fStatus= new StatusInfo();
+ fStatus = new StatusInfo();
- int i= 0;
- HashMap<Integer, String> stateMasks= new HashMap<Integer, String>(fHoverConfigs.length);
+ int i = 0;
+ HashMap<Integer, String> stateMasks = new HashMap<Integer, String>(fHoverConfigs.length);
while (fStatus.isOK() && i < fHoverConfigs.length) {
if (fHoverConfigs[i].fIsEnabled) {
- String label= getContributedHovers()[i].getLabel();
- Integer stateMask= fHoverConfigs[i].fStateMask;
+ String label = getContributedHovers()[i].getLabel();
+ Integer stateMask = fHoverConfigs[i].fStateMask;
if (fHoverConfigs[i].fStateMask == -1)
- fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValidForHover, new String[] {fHoverConfigs[i].fModifierString, label}));
+ fStatus = new StatusInfo(IStatus.ERROR,
+ NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValidForHover,
+ new String[] { fHoverConfigs[i].fModifierString, label }));
else if (stateMasks.containsKey(stateMask))
- fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, stateMasks.get(stateMask)}));
+ fStatus = new StatusInfo(IStatus.ERROR,
+ NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier,
+ new String[] { label, stateMasks.get(stateMask) }));
else
stateMasks.put(stateMask, label);
}
@@ -574,12 +595,12 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
}
private Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox= new Button(parent, SWT.CHECK);
+ Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setText(label);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = indentation;
+ gd.horizontalSpan = 2;
checkBox.setLayoutData(gd);
checkBox.addSelectionListener(fCheckBoxListener);
@@ -587,16 +608,16 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
return checkBox;
}
-
-// private void addFiller(Composite composite) {
-// PixelConverter pixelConverter= new PixelConverter(composite);
-// Label filler= new Label(composite, SWT.LEFT );
-// GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-// gd.horizontalSpan= 2;
-// gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
-// filler.setLayoutData(gd);
-// }
-
+
+ // private void addFiller(Composite composite) {
+ // PixelConverter pixelConverter= new PixelConverter(composite);
+ // Label filler= new Label(composite, SWT.LEFT );
+ // GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ // gd.horizontalSpan= 2;
+ // gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+ // filler.setLayoutData(gd);
+ // }
+
/*
* @see DialogPage#dispose()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java
index 25e0f49a4e2..392c21e08cb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
-
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -26,7 +25,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The page for setting the editor hover options.
*/
public final class CEditorHoverPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
+
/*
* @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
*/
@@ -40,10 +39,10 @@ public final class CEditorHoverPreferencePage extends AbstractConfigurationBlock
*/
@Override
protected void setDescription() {
- String description= PreferencesMessages.CEditorPreferencePage_hover_title;
+ String description = PreferencesMessages.CEditorPreferencePage_hover_title;
setDescription(description);
}
-
+
/*
* @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
*/
@@ -51,8 +50,7 @@ public final class CEditorHoverPreferencePage extends AbstractConfigurationBlock
protected void setPreferenceStore() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
}
-
-
+
@Override
protected Label createDescriptionLabel(Composite parent) {
return null; // no description for new look.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
index b6c20613611..ff7405296e6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -67,14 +67,21 @@ import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
*/
public class CEditorPreferencePage extends AbstractPreferencePage {
protected final String[][] fAppearanceColorListModel = new String[][] {
- {PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null },
- {PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCodeColor, CEditor.INACTIVE_CODE_COLOR, null },
- {PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor, ContentAssistPreference.PROPOSALS_BACKGROUND, null },
- {PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor, ContentAssistPreference.PROPOSALS_FOREGROUND, null },
- {PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor, ContentAssistPreference.PARAMETERS_BACKGROUND, null },
- {PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterForegroundColor, ContentAssistPreference.PARAMETERS_FOREGROUND, null },
- {PreferencesMessages.CEditorPreferencePage_sourceHoverBackgroundColor, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT},
- };
+ { PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor,
+ CEditor.MATCHING_BRACKETS_COLOR, null },
+ { PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCodeColor, CEditor.INACTIVE_CODE_COLOR,
+ null },
+ { PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor,
+ ContentAssistPreference.PROPOSALS_BACKGROUND, null },
+ { PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor,
+ ContentAssistPreference.PROPOSALS_FOREGROUND, null },
+ { PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor,
+ ContentAssistPreference.PARAMETERS_BACKGROUND, null },
+ { PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterForegroundColor,
+ ContentAssistPreference.PARAMETERS_FOREGROUND, null },
+ { PreferencesMessages.CEditorPreferencePage_sourceHoverBackgroundColor,
+ PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR,
+ PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT }, };
private List fAppearanceColorList;
private ColorSelector fAppearanceColorEditor;
@@ -82,34 +89,47 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
private DocCommentOwnerComposite fDocCommentOwnerComposite;
// TODO(sprigogin): Remove once compatibility with Platform 4.4 is no longer required.
private final boolean formattingScopeForEmptySelectionSupported;
-
+
public CEditorPreferencePage() {
super();
Bundle jfaceText = Platform.getBundle("org.eclipse.jface.text"); //$NON-NLS-1$
- formattingScopeForEmptySelectionSupported =
- jfaceText.getVersion().compareTo(new Version(3, 10, 0)) >= 0;
+ formattingScopeForEmptySelectionSupported = jfaceText.getVersion().compareTo(new Version(3, 10, 0)) >= 0;
}
@Override
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
ArrayList<OverlayKey> overlayKeys = new ArrayList<>();
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SUB_WORD_NAVIGATION));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.MATCHING_BRACKETS_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.INACTIVE_CODE_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.INACTIVE_CODE_ENABLE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, FORMATTING_SCOPE_FOR_EMPTY_SELECTION));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, FORMATTING_CONFIRM_SCOPE_FOR_EMPTY_SELECTION));
-
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+ overlayKeys.add(
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SUB_WORD_NAVIGATION));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS));
+ overlayKeys.add(
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.MATCHING_BRACKETS_COLOR));
+ overlayKeys
+ .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS));
+ overlayKeys
+ .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.INACTIVE_CODE_COLOR));
+ overlayKeys.add(
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.INACTIVE_CODE_ENABLE));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.PROPOSALS_BACKGROUND));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.PROPOSALS_FOREGROUND));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.PARAMETERS_BACKGROUND));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.PARAMETERS_FOREGROUND));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ FORMATTING_SCOPE_FOR_EMPTY_SELECTION));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ FORMATTING_CONFIRM_SCOPE_FOR_EMPTY_SELECTION));
+
+ OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
}
@@ -144,18 +164,19 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
}
private Control createBehaviorBlock(Composite parent) {
- Composite behaviorComposite= ControlFactory.createGroup(parent, PreferencesMessages.CEditorPreferencePage_GeneralAppearanceGroupTitle, 1);
-
+ Composite behaviorComposite = ControlFactory.createGroup(parent,
+ PreferencesMessages.CEditorPreferencePage_GeneralAppearanceGroupTitle, 1);
+
GridLayout layout = new GridLayout();
layout.numColumns = 2;
behaviorComposite.setLayout(layout);
int indent = convertHorizontalDLUsToPixels(8);
- String label= PreferencesMessages.CEditorPreferencePage_behaviorPage_subWordNavigation;
+ String label = PreferencesMessages.CEditorPreferencePage_behaviorPage_subWordNavigation;
addCheckBox(behaviorComposite, label, CEditor.SUB_WORD_NAVIGATION, 0);
- label = PreferencesMessages.CEditorPreferencePage_behaviourPage_EnableEditorProblemAnnotation;
+ label = PreferencesMessages.CEditorPreferencePage_behaviourPage_EnableEditorProblemAnnotation;
addCheckBox(behaviorComposite, label, PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS, 0);
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBrackets;
@@ -172,11 +193,13 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
l.setLayoutData(gd);
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_formatFile;
- addRadioButton(behaviorComposite, label, FORMATTING_SCOPE_FOR_EMPTY_SELECTION, FORMATTING_SCOPE_DOCUMENT, indent);
-
+ addRadioButton(behaviorComposite, label, FORMATTING_SCOPE_FOR_EMPTY_SELECTION, FORMATTING_SCOPE_DOCUMENT,
+ indent);
+
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_formatStatement;
- addRadioButton(behaviorComposite, label, FORMATTING_SCOPE_FOR_EMPTY_SELECTION, FORMATTING_SCOPE_STATEMENT, indent);
-
+ addRadioButton(behaviorComposite, label, FORMATTING_SCOPE_FOR_EMPTY_SELECTION, FORMATTING_SCOPE_STATEMENT,
+ indent);
+
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_confirmFormattingScope;
addCheckBox(behaviorComposite, label, FORMATTING_CONFIRM_SCOPE_FOR_EMPTY_SELECTION, indent);
}
@@ -228,24 +251,24 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
gd.horizontalAlignment = GridData.BEGINNING;
foregroundColorButton.setLayoutData(gd);
- SelectionListener colorDefaultSelectionListener= new SelectionAdapter() {
+ SelectionListener colorDefaultSelectionListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- boolean systemDefault= fAppearanceColorDefault.getSelection();
+ boolean systemDefault = fAppearanceColorDefault.getSelection();
fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
- int i= fAppearanceColorList.getSelectionIndex();
- String key= fAppearanceColorListModel[i][2];
+ int i = fAppearanceColorList.getSelectionIndex();
+ String key = fAppearanceColorListModel[i][2];
if (key != null)
fOverlayStore.setValue(key, systemDefault);
}
};
- fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK);
+ fAppearanceColorDefault = new Button(stylesComposite, SWT.CHECK);
fAppearanceColorDefault.setText(PreferencesMessages.CEditorPreferencePage_colorPage_systemDefault);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment = GridData.BEGINNING;
+ gd.horizontalSpan = 2;
fAppearanceColorDefault.setLayoutData(gd);
fAppearanceColorDefault.setVisible(false);
fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener);
@@ -282,7 +305,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
fAppearanceColorDefault.setVisible(false);
fAppearanceColorEditor.getButton().setEnabled(true);
} else {
- boolean systemDefault= fOverlayStore.getBoolean(systemDefaultKey);
+ boolean systemDefault = fOverlayStore.getBoolean(systemDefaultKey);
fAppearanceColorDefault.setSelection(systemDefault);
fAppearanceColorDefault.setVisible(true);
fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
@@ -293,7 +316,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
String text = PreferencesMessages.CEditorPreferencePage_link;
Link link = new Link(parent, SWT.NONE);
link.setText(text);
- link.addListener (SWT.Selection, new Listener() {
+ link.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
String u = event.text;
@@ -304,8 +327,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
link.setToolTipText(PreferencesMessages.CEditorPreferencePage_link_tooltip);
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gridData.widthHint= 150; // only expand further if anyone else requires it
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ gridData.widthHint = 150; // only expand further if anyone else requires it
link.setLayoutData(gridData);
return link;
}
@@ -315,7 +338,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
fOverlayStore.load();
fOverlayStore.start();
- Composite contents= ControlFactory.createComposite(parent, 1);
+ Composite contents = ControlFactory.createComposite(parent, 1);
contents.setLayoutData(new GridData(GridData.FILL_BOTH));
createHeader(contents);
@@ -324,13 +347,13 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
createBehaviorBlock(contents);
ControlFactory.createEmptySpace(contents, 2);
-
- String dsc= PreferencesMessages.CEditorPreferencePage_SelectDocToolDescription;
- String msg= PreferencesMessages.CEditorPreferencePage_WorkspaceDefaultLabel;
- IDocCommentOwner workspaceOwner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
- fDocCommentOwnerComposite= new DocCommentOwnerComposite(contents, workspaceOwner, dsc, msg);
+
+ String dsc = PreferencesMessages.CEditorPreferencePage_SelectDocToolDescription;
+ String msg = PreferencesMessages.CEditorPreferencePage_WorkspaceDefaultLabel;
+ IDocCommentOwner workspaceOwner = DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
+ fDocCommentOwnerComposite = new DocCommentOwnerComposite(contents, workspaceOwner, dsc, msg);
fDocCommentOwnerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
-
+
initialize();
return contents;
@@ -354,7 +377,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
@Override
public boolean performOk() {
- DocCommentOwnerManager.getInstance().setWorkspaceCommentOwner(fDocCommentOwnerComposite.getSelectedDocCommentOwner());
+ DocCommentOwnerManager.getInstance()
+ .setWorkspaceCommentOwner(fDocCommentOwnerComposite.getSelectedDocCommentOwner());
return super.performOk();
}
@@ -363,11 +387,12 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
*/
private void initializeDefaultColors() {
if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
- Display display= fAppearanceColorList.getDisplay();
- RGB rgb= SourceViewerInformationControl.getVisibleBackgroundColor(display);
+ Display display = fAppearanceColorList.getDisplay();
+ RGB rgb = SourceViewerInformationControl.getVisibleBackgroundColor(display);
if (rgb == null)
- rgb= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
- PreferenceConverter.setValue(getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb);
+ rgb = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
+ PreferenceConverter.setValue(getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR,
+ rgb);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.java
index 9bdb1e620b6..b67e151f8fd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.java
@@ -73,7 +73,6 @@ public class CFileTypeAssociation {
return true;
}
-
/**
* @return Returns the fSettings.
*/
@@ -94,7 +93,7 @@ public class CFileTypeAssociation {
return "*." + pattern; //$NON-NLS-1$
}
return pattern;
-
+
}
public boolean isFileSpec() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java
index 833c65395dc..3b550013c70 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java
@@ -36,21 +36,21 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.cdt.core.model.CoreModel;
public class CFileTypeDialog extends Dialog {
-
+
public CFileTypeDialog(Shell parentShell) {
super(parentShell);
}
- private Text fTextPattern;
- private Combo fComboType;
+ private Text fTextPattern;
+ private Combo fComboType;
- private String fPattern;
+ private String fPattern;
private IContentType fType;
-
+
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- newShell.setText(PreferencesMessages.CFileTypeDialog_title);
+ newShell.setText(PreferencesMessages.CFileTypeDialog_title);
}
@Override
@@ -67,15 +67,15 @@ public class CFileTypeDialog extends Dialog {
((GridLayout) composite.getLayout()).numColumns = 2;
// Pattern row
-
+
Label pattern = new Label(composite, SWT.NONE);
-
- pattern.setText(PreferencesMessages.CFileTypeDialog_patternLabel);
+
+ pattern.setText(PreferencesMessages.CFileTypeDialog_patternLabel);
fTextPattern = new Text(composite, SWT.BORDER | SWT.SINGLE);
-
+
fTextPattern.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
if (null != fPattern) {
fTextPattern.setText(fPattern);
}
@@ -86,19 +86,19 @@ public class CFileTypeDialog extends Dialog {
getOkayButton().setEnabled(getPatternFromControl().length() > 0);
}
});
-
+
// Type row
-
+
Label type = new Label(composite, SWT.NONE);
-
- type.setText(PreferencesMessages.CFileTypeDialog_typeLabel);
-
+
+ type.setText(PreferencesMessages.CFileTypeDialog_typeLabel);
+
fComboType = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.SINGLE);
fComboType.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
populateTypesCombo();
-
+
return composite;
}
@@ -109,14 +109,14 @@ public class CFileTypeDialog extends Dialog {
public String getPattern() {
return fPattern;
}
-
+
public IContentType getContentType() {
return fType;
}
private void populateTypesCombo() {
IContentTypeManager manager = Platform.getContentTypeManager();
- String[] ids = CoreModel.getRegistedContentTypeIds();
+ String[] ids = CoreModel.getRegistedContentTypeIds();
ArrayList<IContentType> list = new ArrayList<IContentType>(ids.length);
for (String id : ids) {
IContentType ctype = manager.getContentType(id);
@@ -127,12 +127,12 @@ public class CFileTypeDialog extends Dialog {
IContentType[] ctypes = new IContentType[list.size()];
list.toArray(ctypes);
- int index = -1;
+ int index = -1;
for (IContentType ctype : ctypes) {
fComboType.add(ctype.getName());
}
-
+
fComboType.setData(ctypes);
if (null != fType) {
@@ -145,18 +145,18 @@ public class CFileTypeDialog extends Dialog {
Button getOkayButton() {
return getButton(IDialogConstants.OK_ID);
}
-
+
String getPatternFromControl() {
return fTextPattern.getText().trim();
}
-
+
private IContentType getTypeFromControl() {
- IContentType type = null;
- int index = fComboType.getSelectionIndex();
-
+ IContentType type = null;
+ int index = fComboType.getSelectionIndex();
+
if (-1 != index) {
- String name = fComboType.getItem(index);
- IContentType[] types = (IContentType[]) fComboType.getData();
+ String name = fComboType.getItem(index);
+ IContentType[] types = (IContentType[]) fComboType.getData();
for (IContentType type2 : types) {
if (name.equals(type2.getName())) {
type = type2;
@@ -165,14 +165,13 @@ public class CFileTypeDialog extends Dialog {
}
return type;
}
-
+
@Override
protected void okPressed() {
- fPattern = getPatternFromControl();
- fType = getTypeFromControl();
-
+ fPattern = getPatternFromControl();
+ fType = getTypeFromControl();
+
super.okPressed();
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java
index abf49dae516..5c1bc35ad28 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java
@@ -61,19 +61,19 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
* for displaying/editing CDT file type associations
*/
public class CFileTypesPreferenceBlock {
- private static final int COL_PATTERN = 0;
- private static final int COL_DESCRIPTION = 1;
- private static final int COL_STATUS = 2;
-
- private ArrayList<CFileTypeAssociation> fAddAssoc;
- private ArrayList<CFileTypeAssociation> fRemoveAssoc;
- private boolean fDirty = false;
- private IProject fInput;
+ private static final int COL_PATTERN = 0;
+ private static final int COL_DESCRIPTION = 1;
+ private static final int COL_STATUS = 2;
+
+ private ArrayList<CFileTypeAssociation> fAddAssoc;
+ private ArrayList<CFileTypeAssociation> fRemoveAssoc;
+ private boolean fDirty = false;
+ private IProject fInput;
private IContentType[] fContentTypes;
- private TableViewer fAssocViewer;
- private Button fBtnNew;
- private Button fBtnRemove;
+ private TableViewer fAssocViewer;
+ private Button fBtnNew;
+ private Button fBtnRemove;
private class AssocSorter extends ViewerSorter {
@Override
@@ -88,10 +88,10 @@ public class CFileTypesPreferenceBlock {
return 30;
}
}
-
+
private class AssocContentProvider implements IStructuredContentProvider {
CFileTypeAssociation[] assocs;
-
+
@Override
public Object[] getElements(Object inputElement) {
return assocs;
@@ -104,15 +104,15 @@ public class CFileTypesPreferenceBlock {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof CFileTypeAssociation[]) {
+ if (newInput instanceof CFileTypeAssociation[]) {
assocs = (CFileTypeAssociation[]) newInput;
}
}
}
-
+
private class AssocLabelProvider implements ILabelProvider, ITableLabelProvider {
private ListenerList<ILabelProviderListener> listeners = new ListenerList<>();
-
+
@Override
public Image getColumnImage(Object element, int columnIndex) {
if (element instanceof CFileTypeAssociation) {
@@ -128,19 +128,19 @@ public class CFileTypesPreferenceBlock {
if (element instanceof CFileTypeAssociation) {
CFileTypeAssociation assoc = (CFileTypeAssociation) element;
switch (columnIndex) {
- case COL_PATTERN:
- return assoc.getPattern();
-
- case COL_DESCRIPTION:
- return assoc.getDescription();
-
- case COL_STATUS:
- if (assoc.isUserDefined()) {
- return PreferencesMessages.CFileTypesPreferencePage_userDefined;
- } else if (assoc.isPredefined()) {
- return PreferencesMessages.CFileTypesPreferencePage_preDefined;
- }
- return ""; //$NON-NLS-1$
+ case COL_PATTERN:
+ return assoc.getPattern();
+
+ case COL_DESCRIPTION:
+ return assoc.getDescription();
+
+ case COL_STATUS:
+ if (assoc.isUserDefined()) {
+ return PreferencesMessages.CFileTypesPreferencePage_userDefined;
+ } else if (assoc.isPredefined()) {
+ return PreferencesMessages.CFileTypesPreferencePage_preDefined;
+ }
+ return ""; //$NON-NLS-1$
}
}
return element.toString();
@@ -190,102 +190,102 @@ public class CFileTypesPreferenceBlock {
}
public Control createControl(Composite parent) {
- Composite control = new Composite(parent, SWT.NONE);
- GridLayout controlLayout = new GridLayout(2, false);
+ Composite control = new Composite(parent, SWT.NONE);
+ GridLayout controlLayout = new GridLayout(2, false);
controlLayout.marginHeight = 0;
- controlLayout.marginWidth = 0;
+ controlLayout.marginWidth = 0;
control.setLayout(controlLayout);
control.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
-
+
// Create the table viewer for file associations
-
- Composite tablePane = new Composite(control, SWT.NONE);
- GridLayout tablePaneLayout = new GridLayout();
- GridData gridData = new GridData(GridData.FILL_BOTH);
-
+
+ Composite tablePane = new Composite(control, SWT.NONE);
+ GridLayout tablePaneLayout = new GridLayout();
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+
tablePaneLayout.marginHeight = 0;
- tablePaneLayout.marginWidth = 0;
-
+ tablePaneLayout.marginWidth = 0;
+
tablePane.setLayout(tablePaneLayout);
tablePane.setLayoutData(gridData);
Table table = new Table(tablePane, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
-
- TableLayout tblLayout = new TableLayout();
- TableColumn col = null;
-
+
+ TableLayout tblLayout = new TableLayout();
+ TableColumn col = null;
+
gridData = new GridData(GridData.FILL_BOTH);
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.heightHint = SWTUtil.getTableHeightHint(table, 15);
gridData.widthHint = new PixelConverter(parent).convertWidthInCharsToPixels(60);
-
+
tblLayout.addColumnData(new ColumnWeightData(20));
tblLayout.addColumnData(new ColumnWeightData(60));
tblLayout.addColumnData(new ColumnWeightData(20));
-
+
table.setLayout(tblLayout);
table.setLayoutData(gridData);
table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
+ table.setLinesVisible(true);
+
col = new TableColumn(table, SWT.LEFT);
- col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitlePattern);
-
+ col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitlePattern);
+
col = new TableColumn(table, SWT.LEFT);
- col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitleDescription);
-
+ col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitleDescription);
+
col = new TableColumn(table, SWT.LEFT);
- col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitleStatus);
+ col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitleStatus);
// Create the button pane
- Composite buttonPane = new Composite(control, SWT.NONE);
- GridLayout buttonPaneLayout = new GridLayout();
-
+ Composite buttonPane = new Composite(control, SWT.NONE);
+ GridLayout buttonPaneLayout = new GridLayout();
+
buttonPaneLayout.marginHeight = 0;
- buttonPaneLayout.marginWidth = 0;
-
+ buttonPaneLayout.marginWidth = 0;
+
buttonPane.setLayout(buttonPaneLayout);
buttonPane.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
// New button
-
- fBtnNew = new Button(buttonPane, SWT.PUSH);
- fBtnNew.setText(PreferencesMessages.CFileTypesPreferenceBlock_New___);
-
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnNew);
+
+ fBtnNew = new Button(buttonPane, SWT.PUSH);
+ fBtnNew.setText(PreferencesMessages.CFileTypesPreferenceBlock_New___);
+
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnNew);
fBtnNew.setLayoutData(gridData);
-
+
fBtnNew.addListener(SWT.Selection, e -> handleAdd());
// Remove button
-
- fBtnRemove = new Button(buttonPane, SWT.PUSH);
- fBtnRemove.setText(PreferencesMessages.CFileTypesPreferenceBlock_Remove);
-
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnRemove);
+
+ fBtnRemove = new Button(buttonPane, SWT.PUSH);
+ fBtnRemove.setText(PreferencesMessages.CFileTypesPreferenceBlock_Remove);
+
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnRemove);
fBtnRemove.setLayoutData(gridData);
-
+
fBtnRemove.addListener(SWT.Selection, e -> handleRemove());
// Hook up the viewer
-
+
fAssocViewer = new TableViewer(table);
-
+
fAssocViewer.setSorter(new AssocSorter());
fAssocViewer.setContentProvider(new AssocContentProvider());
fAssocViewer.setLabelProvider(new AssocLabelProvider());
fAssocViewer.setInput(getCFileTypeAssociations());
fAssocViewer.addSelectionChangedListener(event -> handleSelectionChanged());
-
+
handleSelectionChanged();
-
+
return control;
}
@@ -295,7 +295,7 @@ public class CFileTypesPreferenceBlock {
fBtnRemove.setEnabled(enabled);
setDirty(enabled);
}
-
+
public void setInput(IProject input) {
fAddAssoc.clear();
fRemoveAssoc.clear();
@@ -309,25 +309,25 @@ public class CFileTypesPreferenceBlock {
private void setDirty(boolean dirty) {
fDirty = dirty;
}
-
+
public boolean performOk() {
boolean changed = fDirty;
-
+
if (fDirty) {
CFileTypeAssociation[] add = fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]);
CFileTypeAssociation[] rem = fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]);
-
+
changed = add.length > 0 || rem.length > 0;
adjustAssociations(add, rem);
-
+
fAddAssoc.clear();
fRemoveAssoc.clear();
setDirty(false);
- }
+ }
return changed;
}
-
+
private CFileTypeAssociation[] getCFileTypeAssociations() {
ArrayList<CFileTypeAssociation> list = new ArrayList<CFileTypeAssociation>();
if (fInput == null) {
@@ -358,7 +358,7 @@ public class CFileTypesPreferenceBlock {
int type = IContentType.FILE_NAME_SPEC;
if (assoc.isExtSpec()) {
type = IContentType.FILE_EXTENSION_SPEC;
- }
+ }
addAssociation(context, contentType, spec, type);
}
}
@@ -409,24 +409,31 @@ public class CFileTypesPreferenceBlock {
private void fillWithUserDefinedCFileTypeAssociations(ArrayList<CFileTypeAssociation> list) {
IContentType[] ctypes = getRegistedContentTypes();
- fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
- fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list);
+ fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC,
+ list);
+ fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC,
+ list);
}
private void fillWithPredefinedCFileTypeAssociations(ArrayList<CFileTypeAssociation> list) {
IContentType[] ctypes = getRegistedContentTypes();
- fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
- fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_NAME_SPEC, list);
+ fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_EXTENSION_SPEC,
+ list);
+ fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_NAME_SPEC,
+ list);
}
private void fillWithProjectCFileTypeAssociations(ArrayList<CFileTypeAssociation> list, IProject project) {
IContentType[] ctypes = getRegistedContentTypes();
IScopeContext context = new ProjectScope(project);
- fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
- fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list);
+ fillWithCFileTypeAssociations(ctypes, context,
+ IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
+ fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC,
+ list);
}
- private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type, ArrayList<CFileTypeAssociation> list) {
+ private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type,
+ ArrayList<CFileTypeAssociation> list) {
for (IContentType ctype : ctypes) {
try {
IContentTypeSettings setting = ctype.getSettings(context);
@@ -470,7 +477,7 @@ public class CFileTypesPreferenceBlock {
CFileTypeAssociation assoc = null;
CFileTypeDialog dlg = new CFileTypeDialog(fBtnNew.getParent().getShell());
-
+
if (Window.OK == dlg.open()) {
assoc = createAssociation(dlg.getPattern(), dlg.getContentType());
if (handleAdd(assoc)) {
@@ -479,13 +486,13 @@ public class CFileTypesPreferenceBlock {
}
}
}
-
+
private boolean handleAdd(CFileTypeAssociation assoc) {
// assoc is marked to be added.
if (containsIgnoreCaseOfSpec(fAddAssoc, assoc)) {
reportDuplicateAssociation(assoc);
return false;
- }
+ }
// assoc exists, but is marked to be removed.
if (containsIgnoreCaseOfSpec(fRemoveAssoc, assoc)) {
if (!fRemoveAssoc.remove(assoc)) {
@@ -497,29 +504,28 @@ public class CFileTypesPreferenceBlock {
// analyze current settings
IContentTypeSettings settings;
if (fInput == null) {
- settings= assoc.getContentType();
+ settings = assoc.getContentType();
} else {
try {
- settings= assoc.getContentType().getSettings(new ProjectScope(fInput));
+ settings = assoc.getContentType().getSettings(new ProjectScope(fInput));
} catch (CoreException e) {
ErrorDialog.openError(fBtnNew.getParent().getShell(),
- PreferencesMessages.CFileTypesPreferenceBlock_addAssociationError_title,
- null, e.getStatus());
+ PreferencesMessages.CFileTypesPreferenceBlock_addAssociationError_title, null, e.getStatus());
return false;
}
}
- String newSpec= assoc.getSpec();
- String[] specs= settings.getFileSpecs(assoc.getFileSpecType());
+ String newSpec = assoc.getSpec();
+ String[] specs = settings.getFileSpecs(assoc.getFileSpecType());
for (String spec : specs) {
if (spec.equalsIgnoreCase(newSpec)) {
reportDuplicateAssociation(assoc);
return false;
- }
+ }
}
fAddAssoc.add(assoc);
return true;
- }
-
+ }
+
private boolean containsIgnoreCaseOfSpec(Collection<CFileTypeAssociation> collection, CFileTypeAssociation assoc) {
for (CFileTypeAssociation existing : collection) {
if (assoc.equalsIgnoreCaseOfSpec(existing)) {
@@ -531,8 +537,8 @@ public class CFileTypesPreferenceBlock {
private void reportDuplicateAssociation(CFileTypeAssociation assoc) {
MessageDialog.openError(fBtnNew.getParent().getShell(),
- PreferencesMessages.CFileTypesPreferenceBlock_addAssociationError_title,
- Messages.format(PreferencesMessages.CFileTypesPreferenceBlock_addAssociationErrorMessage,
+ PreferencesMessages.CFileTypesPreferenceBlock_addAssociationError_title,
+ Messages.format(PreferencesMessages.CFileTypesPreferenceBlock_addAssociationErrorMessage,
assoc.getPattern(), assoc.getContentType().getName()));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java
index 7ca12d3345c..b31796f2e03 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java
@@ -33,7 +33,7 @@ public class CFileTypesPreferencePage extends PreferencePage implements IWorkben
private CFileTypesPreferenceBlock fPrefsBlock;
public CFileTypesPreferencePage() {
- setDescription(PreferencesMessages.CFileTypesPreferencePage_description);
+ setDescription(PreferencesMessages.CFileTypesPreferencePage_description);
noDefaultAndApplyButton();
}
@@ -49,10 +49,10 @@ public class CFileTypesPreferencePage extends PreferencePage implements IWorkben
fPrefsBlock = new CFileTypesPreferenceBlock(null);
- PlatformUI.getWorkbench().getHelpSystem().setHelp( topPane, ICHelpContextIds.FILE_TYPES_PREF_PAGE );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(topPane, ICHelpContextIds.FILE_TYPES_PREF_PAGE);
return fPrefsBlock.createControl(topPane);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
@@ -75,7 +75,7 @@ public class CFileTypesPreferencePage extends PreferencePage implements IWorkben
public boolean performOk() {
if (fPrefsBlock.performOk()) {
}
-
+
return super.performOk();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java
index 26237b8ca59..6e666f31d84 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
-
import java.util.ArrayList;
import org.eclipse.core.resources.IProject;
@@ -62,7 +61,8 @@ public class CFileTypesPropertyPage extends PropertyPage {
super(input);
}
- private IContentTypeManager.ContentTypeChangeEvent newContentTypeChangeEvent(IContentType source, IScopeContext context) {
+ private IContentTypeManager.ContentTypeChangeEvent newContentTypeChangeEvent(IContentType source,
+ IScopeContext context) {
return new IContentTypeManager.ContentTypeChangeEvent(source, context);
}
@@ -99,18 +99,18 @@ public class CFileTypesPropertyPage extends PropertyPage {
// accumulate the events
list.add(newContentTypeChangeEvent(contentType, context));
}
-
+
}
protected Button fUseWorkspace;
protected Button fUseProject;
protected FixCFileTypesPreferenceBlock fPrefsBlock;
-
- public CFileTypesPropertyPage(){
+
+ public CFileTypesPropertyPage() {
super();
noDefaultAndApplyButton();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@@ -122,14 +122,14 @@ public class CFileTypesPropertyPage extends PropertyPage {
topPane.setLayoutData(new GridData(GridData.FILL_BOTH));
// Workspace radio buttons
-
+
Composite radioPane = new Composite(topPane, SWT.NONE);
radioPane.setLayout(new GridLayout());
radioPane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
fUseWorkspace = new Button(radioPane, SWT.RADIO);
- fUseWorkspace.setText(PreferencesMessages.CFileTypesPropertyPage_useWorkspaceSettings);
+ fUseWorkspace.setText(PreferencesMessages.CFileTypesPropertyPage_useWorkspaceSettings);
fUseWorkspace.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
@@ -140,11 +140,11 @@ public class CFileTypesPropertyPage extends PropertyPage {
}
});
- final IProject project = getProject();
+ final IProject project = getProject();
boolean custom = CCorePlugin.usesProjectSpecificContentTypes(project);
fUseProject = new Button(radioPane, SWT.RADIO);
- fUseProject.setText(PreferencesMessages.CFileTypesPropertyPage_useProjectSettings);
+ fUseProject.setText(PreferencesMessages.CFileTypesPropertyPage_useProjectSettings);
fUseProject.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
@@ -154,7 +154,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
}
}
});
-
+
Composite blockPane = new Composite(topPane, SWT.NONE);
blockPane.setLayout(new GridLayout());
@@ -167,15 +167,15 @@ public class CFileTypesPropertyPage extends PropertyPage {
}
fPrefsBlock.createControl(blockPane);
-
+
fUseWorkspace.setSelection(!custom);
fUseProject.setSelection(custom);
fPrefsBlock.setEnabled(custom);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp( topPane, ICHelpContextIds.FILE_TYPES_STD_PAGE );
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(topPane, ICHelpContextIds.FILE_TYPES_STD_PAGE);
return topPane;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
@@ -193,7 +193,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
*/
@Override
public boolean performOk() {
- boolean useProjectContentTypes= fUseProject.getSelection();
+ boolean useProjectContentTypes = fUseProject.getSelection();
IProject project = getProject();
if (CCorePlugin.usesProjectSpecificContentTypes(project) != useProjectContentTypes) {
CCorePlugin.setUseProjectSpecificContentTypes(project, useProjectContentTypes);
@@ -204,23 +204,23 @@ public class CFileTypesPropertyPage extends PropertyPage {
}
return super.performOk();
}
-
- private IProject getProject(){
- Object element = getElement();
- IProject project = null;
-
+
+ private IProject getProject() {
+ Object element = getElement();
+ IProject project = null;
+
if (element instanceof IProject) {
project = (IProject) element;
} else if (element instanceof IAdaptable) {
- project= ((IAdaptable)element).getAdapter(IProject.class);
+ project = ((IAdaptable) element).getAdapter(IProject.class);
}
return project;
}
public IContentType[] getRegistedContentTypes() {
- String [] ids = CoreModel.getRegistedContentTypeIds();
+ String[] ids = CoreModel.getRegistedContentTypeIds();
IContentTypeManager manager = Platform.getContentTypeManager();
- IContentType [] ctypes = new IContentType[ids.length];
+ IContentType[] ctypes = new IContentType[ids.length];
for (int i = 0; i < ids.length; i++) {
ctypes[i] = manager.getContentType(ids[i]);
}
@@ -240,7 +240,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
try {
IContentTypeSettings projectSettings = ctype.getSettings(projectScope);
String[] projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
- if (projectSpecs!= null && projectSpecs.length > 0) {
+ if (projectSpecs != null && projectSpecs.length > 0) {
list.add(ctype);
} else {
projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_NAME_SPEC);
@@ -255,10 +255,11 @@ public class CFileTypesPropertyPage extends PropertyPage {
// fire the events
if (list.size() > 0) {
- IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[list.size()];
+ IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[list
+ .size()];
for (int i = 0; i < list.size(); ++i) {
IContentType source = list.get(i);
- events[i] = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope);
+ events[i] = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope);
}
CModelManager.getDefault().contentTypeChanged(events);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java
index 4f986ea2365..3ac5144a838 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java
@@ -52,8 +52,8 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
* The page for general C/C++ preferences.
*/
public class CPluginPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
- public static final String C_BASE_PREF_PAGE_ID= "org.eclipse.cdt.ui.preferences.CPluginPreferencePage"; //$NON-NLS-1$
-
+ public static final String C_BASE_PREF_PAGE_ID = "org.eclipse.cdt.ui.preferences.CPluginPreferencePage"; //$NON-NLS-1$
+
private static final int GROUP_VINDENT = 5;
private ArrayList<Button> fCheckBoxes;
@@ -62,50 +62,48 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
setDescription(PreferencesMessages.CPluginPreferencePage_description);
- fCheckBoxes= new ArrayList<Button>();
+ fCheckBoxes = new ArrayList<Button>();
}
-
+
@Override
public void createControl(Composite parent) {
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_PREF_PAGE);
- }
+ }
@Override
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
- Composite container= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(10);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = 0;
+ layout.verticalSpacing = convertVerticalDLUsToPixels(10);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
container.setLayout(layout);
Group outlineViewGroup = addGroup(container, PreferencesMessages.CPluginPreferencePage_outline_view);
addCheckBox(outlineViewGroup, PreferencesMessages.CPluginPreferencePage_structuralParseMode_label,
PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
-
+
addNote(outlineViewGroup, PreferencesMessages.CPluginPreferencePage_performanceHint);
// Refactoring.
Group refactoringGroup = addGroup(container, PreferencesMessages.CPluginPreferencePage_refactoring_title);
- addCheckBox(refactoringGroup,
- PreferencesMessages.CPluginPreferencePage_refactoring_auto_save,
+ addCheckBox(refactoringGroup, PreferencesMessages.CPluginPreferencePage_refactoring_auto_save,
PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS);
- addCheckBox(refactoringGroup,
- PreferencesMessages.CPluginPreferencePage_refactoring_lightweight,
+ addCheckBox(refactoringGroup, PreferencesMessages.CPluginPreferencePage_refactoring_lightweight,
PreferenceConstants.REFACTOR_LIGHTWEIGHT);
-
- Group dontAskGroup= addGroup(container, PreferencesMessages.CPluginPreferencePage_cdtDialogs_group, 2);
- Label label= new Label(dontAskGroup, SWT.WRAP);
+
+ Group dontAskGroup = addGroup(container, PreferencesMessages.CPluginPreferencePage_cdtDialogs_group, 2);
+ Label label = new Label(dontAskGroup, SWT.WRAP);
label.setText(PreferencesMessages.CPluginPreferencePage_clearDoNotShowAgainSettings_label);
- GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false);
- data.widthHint= convertVerticalDLUsToPixels(50);
+ GridData data = new GridData(GridData.FILL, GridData.CENTER, true, false);
+ data.widthHint = convertVerticalDLUsToPixels(50);
label.setLayoutData(data);
- Button clearButton= new Button(dontAskGroup, SWT.PUSH);
+ Button clearButton = new Button(dontAskGroup, SWT.PUSH);
clearButton.setText(PreferencesMessages.CPluginPreferencePage_clear_button);
clearButton.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
clearButton.addSelectionListener(new SelectionListener() {
@@ -113,6 +111,7 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
public void widgetSelected(SelectionEvent e) {
OptionalMessageDialog.clearAllRememberedStates();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
OptionalMessageDialog.clearAllRememberedStates();
@@ -124,7 +123,7 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
}
private void addNote(Group parent, String noteMessage) {
- Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), parent,
+ Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), parent,
PreferencesMessages.CPluginPreferencePage_note, noteMessage);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.verticalIndent = GROUP_VINDENT;
@@ -139,12 +138,12 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
// this is temporary fix for problem that 3 line note does not displayed properly within the group
Label messageLabel = (Label) children[1];
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint=500;
+ gd.widthHint = 500;
messageLabel.setLayoutData(gd);
}
return messageComposite;
}
-
+
private Group addGroup(Composite parent, String label) {
return addGroup(parent, label, 1);
}
@@ -158,7 +157,7 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
}
private Button addCheckBox(Composite parent, String label, String key) {
- Button button= new Button(parent, SWT.CHECK);
+ Button button = new Button(parent, SWT.CHECK);
button.setText(label);
button.setData(key);
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
@@ -170,11 +169,11 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
}
protected void addFiller(Composite composite) {
- PixelConverter pixelConverter= new PixelConverter(composite);
- Label filler= new Label(composite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 1;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+ PixelConverter pixelConverter = new PixelConverter(composite);
+ Label filler = new Label(composite, SWT.LEFT);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 1;
+ gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2;
filler.setLayoutData(gd);
}
@@ -187,7 +186,8 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
}
public static boolean useStructuralParseMode() {
- return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
+ return CUIPlugin.getDefault().getPreferenceStore()
+ .getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
}
/**
@@ -196,7 +196,7 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
@Override
public void init(IWorkbench workbench) {
}
-
+
/**
* Initializes the default values of this page in the preference bundle.
*/
@@ -204,7 +204,7 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, false);
prefs.setDefault(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE, false);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
@@ -212,10 +212,10 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
public boolean performOk() {
if (!super.performOk())
return false;
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= fCheckBoxes.get(i);
- String key= (String) button.getData();
+ IPreferenceStore store = getPreferenceStore();
+ for (int i = 0; i < fCheckBoxes.size(); i++) {
+ Button button = fCheckBoxes.get(i);
+ String key = (String) button.getData();
store.setValue(key, button.getSelection());
}
// tell the Core Plugin about this preference
@@ -223,14 +223,14 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
return true;
}
- @Override
+ @Override
protected void performDefaults() {
- super.performDefaults();
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= fCheckBoxes.get(i);
- String key= (String) button.getData();
+ super.performDefaults();
+ IPreferenceStore store = getPreferenceStore();
+ for (int i = 0; i < fCheckBoxes.size(); i++) {
+ Button button = fCheckBoxes.get(i);
+ String key = (String) button.getData();
button.setSelection(store.getDefaultBoolean(key));
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java
index 837f9982766..c91454a33ff 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java
@@ -27,17 +27,17 @@ import org.eclipse.swt.graphics.Font;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
-
public class CSourcePreviewerUpdater {
/**
* Handles editor font changes for source preview viewers.
- *
+ *
* @param viewer
* @param configuration
* @param store
*/
- public CSourcePreviewerUpdater(SourceViewer viewer, CSourceViewerConfiguration configuration, IPreferenceStore store) {
+ public CSourcePreviewerUpdater(SourceViewer viewer, CSourceViewerConfiguration configuration,
+ IPreferenceStore store) {
registerPreviewer(viewer, configuration, store);
}
@@ -48,23 +48,24 @@ public class CSourcePreviewerUpdater {
* @param configuration the configuration
* @param preferenceStore the preference store
*/
- static public void registerPreviewer(final SourceViewer viewer, final CSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) {
+ static public void registerPreviewer(final SourceViewer viewer, final CSourceViewerConfiguration configuration,
+ final IPreferenceStore preferenceStore) {
Assert.isNotNull(viewer);
Assert.isNotNull(configuration);
Assert.isNotNull(preferenceStore);
- final IPropertyChangeListener fontChangeListener= new IPropertyChangeListener() {
+ final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() {
/*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+ Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
}
}
};
- final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
+ final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
/*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java
index 16bd8e6af3d..8196d123ec1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java
@@ -55,23 +55,25 @@ public class CTemplatePreferencePage extends TemplatePreferencePage {
*/
protected class CEditTemplateDialog extends EditTemplateDialog {
- public CEditTemplateDialog(Shell shell, Template template,
- boolean edit, boolean isNameModifiable,
+ public CEditTemplateDialog(Shell shell, Template template, boolean edit, boolean isNameModifiable,
ContextTypeRegistry contextTypeRegistry) {
super(shell, template, edit, isNameModifiable, contextTypeRegistry);
}
+
/*
* @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage.EditTemplateDialog#createViewer(org.eclipse.swt.widgets.Composite)
*/
@Override
protected SourceViewer createViewer(Composite parent) {
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- CSourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- CSourceViewerConfiguration configuration= new CSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning()) {
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ CSourceViewer viewer = new CSourceViewer(parent, null, null, false,
+ SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(tools.getColorManager(), store,
+ null, tools.getDocumentPartitioning()) {
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
- ContentAssistant assistant= new ContentAssistant();
+ ContentAssistant assistant = new ContentAssistant();
assistant.enableAutoActivation(true);
assistant.enableAutoInsert(true);
assistant.setContentAssistProcessor(getTemplateProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
@@ -86,11 +88,12 @@ public class CTemplatePreferencePage extends TemplatePreferencePage {
viewer.configure(configuration);
viewer.setEditable(true);
viewer.setDocument(document);
-
- Font font= JFaceResources.getFontRegistry().get(PreferenceConstants.EDITOR_TEXT_FONT);
+
+ Font font = JFaceResources.getFontRegistry().get(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
-
- CSourcePreviewerUpdater.registerPreviewer(viewer, configuration, CUIPlugin.getDefault().getCombinedPreferenceStore());
+
+ CSourcePreviewerUpdater.registerPreviewer(viewer, configuration,
+ CUIPlugin.getDefault().getCombinedPreferenceStore());
return viewer;
}
}
@@ -100,7 +103,7 @@ public class CTemplatePreferencePage extends TemplatePreferencePage {
setTemplateStore(CUIPlugin.getDefault().getTemplateStore());
setContextTypeRegistry(CUIPlugin.getDefault().getTemplateContextRegistry());
}
-
+
/*
* @see PreferencePage#createControl(Composite)
*/
@@ -123,7 +126,8 @@ public class CTemplatePreferencePage extends TemplatePreferencePage {
*/
@Override
protected Template editTemplate(Template template, boolean edit, boolean isNameModifiable) {
- CEditTemplateDialog dialog= new CEditTemplateDialog(getShell(), template, edit, isNameModifiable, getContextTypeRegistry());
+ CEditTemplateDialog dialog = new CEditTemplateDialog(getShell(), template, edit, isNameModifiable,
+ getContextTypeRegistry());
if (dialog.open() == Window.OK) {
return dialog.getTemplate();
}
@@ -135,31 +139,35 @@ public class CTemplatePreferencePage extends TemplatePreferencePage {
*/
@Override
protected SourceViewer createViewer(Composite parent) {
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- CSourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning());
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ CSourceViewer viewer = new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
+ store);
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(tools.getColorManager(), store, null,
+ tools.getDocumentPartitioning());
IDocument document = new Document();
tools.setupCDocument(document);
viewer.configure(configuration);
viewer.setEditable(false);
viewer.setDocument(document);
-
- Font font= JFaceResources.getFontRegistry().get(PreferenceConstants.EDITOR_TEXT_FONT);
+
+ Font font = JFaceResources.getFontRegistry().get(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
-
- Control control= viewer.getControl();
- GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= convertHeightInCharsToPixels(5);
+
+ Control control = viewer.getControl();
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = convertHeightInCharsToPixels(5);
control.setLayoutData(data);
-
- control.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+
+ control.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
- e.result = PreferencesMessages.TemplatePreferencePage_Viewer_preview;
- }});
-
- CSourcePreviewerUpdater.registerPreviewer(viewer, configuration, CUIPlugin.getDefault().getCombinedPreferenceStore());
+ e.result = PreferencesMessages.TemplatePreferencePage_Viewer_preview;
+ }
+ });
+
+ CSourcePreviewerUpdater.registerPreviewer(viewer, configuration,
+ CUIPlugin.getDefault().getCombinedPreferenceStore());
return viewer;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java
index 12775df910a..276c3a2116b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java
@@ -76,23 +76,18 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputer
import org.eclipse.cdt.internal.ui.util.Messages;
import org.eclipse.cdt.internal.ui.util.SWTUtil;
-
/**
- *
+ *
* @since 3.2
*/
final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlock {
-
- private static final Key PREF_EXCLUDED_CATEGORIES= getCDTUIKey(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
- private static final Key PREF_CATEGORY_ORDER= getCDTUIKey(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
- private static final Key PREF_PROPOSAL_TIMEOUT= getCDTUIKey(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT);
-
+
+ private static final Key PREF_EXCLUDED_CATEGORIES = getCDTUIKey(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
+ private static final Key PREF_CATEGORY_ORDER = getCDTUIKey(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
+ private static final Key PREF_PROPOSAL_TIMEOUT = getCDTUIKey(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT);
+
private static Key[] getAllKeys() {
- return new Key[] {
- PREF_EXCLUDED_CATEGORIES,
- PREF_CATEGORY_ORDER,
- PREF_PROPOSAL_TIMEOUT
- };
+ return new Key[] { PREF_EXCLUDED_CATEGORIES, PREF_CATEGORY_ORDER, PREF_PROPOSAL_TIMEOUT };
}
private final class DefaultTableLabelProvider extends LabelProvider implements ITableLabelProvider {
@@ -113,27 +108,27 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
@Override
public String getColumnText(Object element, int columnIndex) {
switch (columnIndex) {
- case 0:
- return ((ModelElement) element).getName();
- case 1:
- return ((ModelElement) element).getKeybindingAsString();
- default:
- Assert.isTrue(false);
- return null;
- }
- }
-
+ case 0:
+ return ((ModelElement) element).getName();
+ case 1:
+ return ((ModelElement) element).getKeybindingAsString();
+ default:
+ Assert.isTrue(false);
+ return null;
+ }
+ }
+
/*
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(Object element) {
- return getColumnText(element, 0); // needed to make the sorter work
+ return getColumnText(element, 0); // needed to make the sorter work
}
}
private final class SeparateTableLabelProvider extends LabelProvider implements ITableLabelProvider {
-
+
/*
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
@@ -143,210 +138,221 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
return ((ModelElement) element).getImage();
return null;
}
-
+
/*
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
switch (columnIndex) {
- case 0:
- return ((ModelElement) element).getName();
- default:
- Assert.isTrue(false);
+ case 0:
+ return ((ModelElement) element).getName();
+ default:
+ Assert.isTrue(false);
return null;
}
}
}
- private final Comparator<ModelElement> fCategoryComparator= new Comparator<ModelElement>() {
+ private final Comparator<ModelElement> fCategoryComparator = new Comparator<ModelElement>() {
@Override
public int compare(ModelElement o1, ModelElement o2) {
return o1.getRank() - o2.getRank();
}
};
-
+
private final class PreferenceModel {
- private static final int LIMIT= 0xffff;
- private static final String COLON= ":"; //$NON-NLS-1$
- private static final String SEPARATOR= "\0"; //$NON-NLS-1$
+ private static final int LIMIT = 0xffff;
+ private static final String COLON = ":"; //$NON-NLS-1$
+ private static final String SEPARATOR = "\0"; //$NON-NLS-1$
private final List<ModelElement> fElements;
/**
* The read-only list of elements.
*/
final List<ModelElement> elements;
-
+
public PreferenceModel(CompletionProposalComputerRegistry registry) {
- List<CompletionProposalCategory> categories= registry.getProposalCategories();
- fElements= new ArrayList<ModelElement>();
+ List<CompletionProposalCategory> categories = registry.getProposalCategories();
+ fElements = new ArrayList<ModelElement>();
for (CompletionProposalCategory category : categories) {
if (category.hasComputers()) {
fElements.add(new ModelElement(category, this));
}
}
Collections.sort(fElements, fCategoryComparator);
- elements= Collections.unmodifiableList(fElements);
+ elements = Collections.unmodifiableList(fElements);
}
-
- public void moveUp(ModelElement category) {
- int index= fElements.indexOf(category);
+
+ public void moveUp(ModelElement category) {
+ int index = fElements.indexOf(category);
if (index > 0) {
- ModelElement item= fElements.remove(index);
+ ModelElement item = fElements.remove(index);
fElements.add(index - 1, item);
writeOrderPreference(null, false);
}
- }
+ }
- public void moveDown(ModelElement category) {
- int index= fElements.indexOf(category);
+ public void moveDown(ModelElement category) {
+ int index = fElements.indexOf(category);
if (index < fElements.size() - 1) {
- ModelElement item= fElements.remove(index);
+ ModelElement item = fElements.remove(index);
fElements.add(index + 1, item);
writeOrderPreference(null, false);
}
- }
-
- private void writeInclusionPreference(ModelElement changed, boolean isInDefaultCategory) {
- StringBuilder buf= new StringBuilder();
- for (Object element : fElements) {
- ModelElement item= (ModelElement) element;
- boolean included= changed == item ? isInDefaultCategory : item.isInDefaultCategory();
- if (!included)
- buf.append(item.getId()).append(SEPARATOR);
- }
-
- String newValue= buf.toString();
- String oldValue= setValue(PREF_EXCLUDED_CATEGORIES, newValue);
- validateSettings(PREF_EXCLUDED_CATEGORIES, oldValue, newValue);
- }
-
- private void writeOrderPreference(ModelElement changed, boolean isSeparate) {
- StringBuilder buf= new StringBuilder();
- int i= 0;
- for (Iterator<ModelElement> it= fElements.iterator(); it.hasNext(); i++) {
- ModelElement item= it.next();
- boolean separate= changed == item ? isSeparate : item.isSeparateCommand();
- int rank= separate ? i : i + LIMIT;
- buf.append(item.getId()).append(COLON).append(rank).append(SEPARATOR);
- }
-
- String newValue= buf.toString();
- String oldValue= setValue(PREF_CATEGORY_ORDER, newValue);
- validateSettings(PREF_CATEGORY_ORDER, oldValue, newValue);
- }
-
-
- private boolean readInclusionPreference(CompletionProposalCategory cat) {
- String[] ids= getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR);
- for (String id : ids) {
- if (id.equals(cat.getId()))
- return false;
- }
- return true;
- }
-
- private int readOrderPreference(CompletionProposalCategory cat) {
- String[] sortOrderIds= getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR);
- for (String sortOrderId : sortOrderIds) {
- String[] idAndRank= getTokens(sortOrderId, COLON);
- if (idAndRank[0].equals(cat.getId()))
- return Integer.parseInt(idAndRank[1]);
- }
- return LIMIT + 1;
- }
-
- public void update() {
+ }
+
+ private void writeInclusionPreference(ModelElement changed, boolean isInDefaultCategory) {
+ StringBuilder buf = new StringBuilder();
+ for (Object element : fElements) {
+ ModelElement item = (ModelElement) element;
+ boolean included = changed == item ? isInDefaultCategory : item.isInDefaultCategory();
+ if (!included)
+ buf.append(item.getId()).append(SEPARATOR);
+ }
+
+ String newValue = buf.toString();
+ String oldValue = setValue(PREF_EXCLUDED_CATEGORIES, newValue);
+ validateSettings(PREF_EXCLUDED_CATEGORIES, oldValue, newValue);
+ }
+
+ private void writeOrderPreference(ModelElement changed, boolean isSeparate) {
+ StringBuilder buf = new StringBuilder();
+ int i = 0;
+ for (Iterator<ModelElement> it = fElements.iterator(); it.hasNext(); i++) {
+ ModelElement item = it.next();
+ boolean separate = changed == item ? isSeparate : item.isSeparateCommand();
+ int rank = separate ? i : i + LIMIT;
+ buf.append(item.getId()).append(COLON).append(rank).append(SEPARATOR);
+ }
+
+ String newValue = buf.toString();
+ String oldValue = setValue(PREF_CATEGORY_ORDER, newValue);
+ validateSettings(PREF_CATEGORY_ORDER, oldValue, newValue);
+ }
+
+ private boolean readInclusionPreference(CompletionProposalCategory cat) {
+ String[] ids = getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR);
+ for (String id : ids) {
+ if (id.equals(cat.getId()))
+ return false;
+ }
+ return true;
+ }
+
+ private int readOrderPreference(CompletionProposalCategory cat) {
+ String[] sortOrderIds = getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR);
+ for (String sortOrderId : sortOrderIds) {
+ String[] idAndRank = getTokens(sortOrderId, COLON);
+ if (idAndRank[0].equals(cat.getId()))
+ return Integer.parseInt(idAndRank[1]);
+ }
+ return LIMIT + 1;
+ }
+
+ public void update() {
Collections.sort(fElements, fCategoryComparator);
- }
+ }
}
-
+
private final class ModelElement {
private final CompletionProposalCategory fCategory;
private final Command fCommand;
private final IParameter fParam;
private final PreferenceModel fPreferenceModel;
-
+
ModelElement(CompletionProposalCategory category, PreferenceModel model) {
- fCategory= category;
- ICommandService commandSvc= PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- fCommand= commandSvc.getCommand("org.eclipse.cdt.ui.specific_content_assist.command"); //$NON-NLS-1$
+ fCategory = category;
+ ICommandService commandSvc = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
+ fCommand = commandSvc.getCommand("org.eclipse.cdt.ui.specific_content_assist.command"); //$NON-NLS-1$
IParameter type;
try {
- type= fCommand.getParameters()[0];
+ type = fCommand.getParameters()[0];
} catch (NotDefinedException x) {
Assert.isTrue(false);
- type= null;
+ type = null;
}
- fParam= type;
- fPreferenceModel= model;
+ fParam = type;
+ fPreferenceModel = model;
}
+
Image getImage() {
return CodeAssistAdvancedConfigurationBlock.this.getImage(fCategory.getImageDescriptor());
}
+
String getName() {
return fCategory.getDisplayName();
}
+
String getKeybindingAsString() {
- final Parameterization[] params= { new Parameterization(fParam, fCategory.getId()) };
- final ParameterizedCommand pCmd= new ParameterizedCommand(fCommand, params);
- String key= getKeyboardShortcut(pCmd);
+ final Parameterization[] params = { new Parameterization(fParam, fCategory.getId()) };
+ final ParameterizedCommand pCmd = new ParameterizedCommand(fCommand, params);
+ String key = getKeyboardShortcut(pCmd);
return key;
}
+
boolean isInDefaultCategory() {
return fPreferenceModel.readInclusionPreference(fCategory);
}
+
void setInDefaultCategory(boolean included) {
if (included != isInDefaultCategory())
fPreferenceModel.writeInclusionPreference(this, included);
}
+
String getId() {
return fCategory.getId();
}
+
int getRank() {
- int rank= getInternalRank();
+ int rank = getInternalRank();
if (rank > PreferenceModel.LIMIT)
return rank - PreferenceModel.LIMIT;
return rank;
}
+
void moveUp() {
fPreferenceModel.moveUp(this);
}
+
void moveDown() {
fPreferenceModel.moveDown(this);
}
+
private int getInternalRank() {
return fPreferenceModel.readOrderPreference(fCategory);
}
+
boolean isSeparateCommand() {
return getInternalRank() < PreferenceModel.LIMIT;
}
-
+
void setSeparateCommand(boolean separate) {
if (separate != isSeparateCommand())
fPreferenceModel.writeOrderPreference(this, separate);
}
-
+
void update() {
fCategory.setIncluded(isInDefaultCategory());
- int rank= getInternalRank();
+ int rank = getInternalRank();
fCategory.setSortOrder(rank);
fCategory.setSeparateCommand(rank < PreferenceModel.LIMIT);
}
}
-
+
/** element type: {@link ModelElement}. */
private final PreferenceModel fModel;
- private final Map<ImageDescriptor, Image> fImages= new HashMap<ImageDescriptor, Image>();
+ private final Map<ImageDescriptor, Image> fImages = new HashMap<ImageDescriptor, Image>();
private CheckboxTableViewer fDefaultViewer;
private CheckboxTableViewer fSeparateViewer;
private Button fUpButton;
private Button fDownButton;
-
- CodeAssistAdvancedConfigurationBlock(IStatusChangeListener statusListener, IWorkbenchPreferenceContainer container) {
+
+ CodeAssistAdvancedConfigurationBlock(IStatusChangeListener statusListener,
+ IWorkbenchPreferenceContainer container) {
super(statusListener, null, getAllKeys(), container);
- fModel= new PreferenceModel(CompletionProposalComputerRegistry.getDefault());
+ fModel = new PreferenceModel(CompletionProposalComputerRegistry.getDefault());
}
/*
@@ -354,131 +360,138 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
*/
@Override
protected Control createContents(Composite parent) {
-
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
-
+
+ ScrolledPageContent scrolled = new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
-
- Composite composite= new Composite(scrolled, SWT.NONE);
- int columns= 2;
- GridLayout layout= new GridLayout(columns, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+
+ Composite composite = new Composite(scrolled, SWT.NONE);
+ int columns = 2;
+ GridLayout layout = new GridLayout(columns, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
composite.setLayout(layout);
-
+
createDefaultLabel(composite, columns);
createDefaultViewer(composite, columns);
createKeysLink(composite, columns);
-
+
createFiller(composite, columns);
-
+
createSeparateLabel(composite, columns);
- createSeparateSection(composite);
-
- createFiller(composite, columns);
+ createSeparateSection(composite);
+
+ createFiller(composite, columns);
createTimeoutField(composite, columns);
-
+
updateControls();
if (fModel.elements.size() > 0) {
fDefaultViewer.getTable().select(0);
fSeparateViewer.getTable().select(0);
handleTableSelection();
}
-
+
scrolled.setContent(composite);
scrolled.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
return scrolled;
}
-
+
private void createTimeoutField(Composite composite, int columns) {
- Composite timeoutComposite= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout(3, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+ Composite timeoutComposite = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
timeoutComposite.setLayout(layout);
- GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false, columns, 1);
+ GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false, columns, 1);
timeoutComposite.setLayoutData(gd);
- PixelConverter pixelConverter= new PixelConverter(composite);
+ PixelConverter pixelConverter = new PixelConverter(composite);
String label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalTimeout;
- Text textField = addTextField(timeoutComposite, label, PREF_PROPOSAL_TIMEOUT, 0, pixelConverter.convertWidthInCharsToPixels(7));
+ Text textField = addTextField(timeoutComposite, label, PREF_PROPOSAL_TIMEOUT, 0,
+ pixelConverter.convertWidthInCharsToPixels(7));
String toolTip = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalTimeoutToolTip;
textField.setToolTipText(toolTip);
}
private void createDefaultLabel(Composite composite, int h_span) {
- final ICommandService commandSvc= PlatformUI.getWorkbench().getAdapter(ICommandService.class);
- final Command command= commandSvc.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- ParameterizedCommand pCmd= new ParameterizedCommand(command, null);
- String key= getKeyboardShortcut(pCmd);
+ final ICommandService commandSvc = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
+ final Command command = commandSvc.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ ParameterizedCommand pCmd = new ParameterizedCommand(command, null);
+ String key = getKeyboardShortcut(pCmd);
if (key == null)
- key= PreferencesMessages.CodeAssistAdvancedConfigurationBlock_no_shortcut;
-
- PixelConverter pixelConverter= new PixelConverter(composite);
- int width= pixelConverter.convertWidthInCharsToPixels(40);
-
- Label label= new Label(composite, SWT.NONE | SWT.WRAP);
- label.setText(Messages.format(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_page_description, new Object[] { key }));
- GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
- gd.widthHint= width;
+ key = PreferencesMessages.CodeAssistAdvancedConfigurationBlock_no_shortcut;
+
+ PixelConverter pixelConverter = new PixelConverter(composite);
+ int width = pixelConverter.convertWidthInCharsToPixels(40);
+
+ Label label = new Label(composite, SWT.NONE | SWT.WRAP);
+ label.setText(Messages.format(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_page_description,
+ new Object[] { key }));
+ GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
+ gd.widthHint = width;
label.setLayoutData(gd);
-
+
createFiller(composite, h_span);
- label= new Label(composite, SWT.NONE | SWT.WRAP);
+ label = new Label(composite, SWT.NONE | SWT.WRAP);
label.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_description);
- gd= new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
- gd.widthHint= width;
+ gd = new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
+ gd.widthHint = width;
label.setLayoutData(gd);
- }
+ }
private void createDefaultViewer(Composite composite, int h_span) {
- fDefaultViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
- Table table= fDefaultViewer.getTable();
+ fDefaultViewer = CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
+ Table table = fDefaultViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(false);
table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, h_span, 1));
-
- TableColumn nameColumn= new TableColumn(table, SWT.NONE);
- nameColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_category_column_title);
+
+ TableColumn nameColumn = new TableColumn(table, SWT.NONE);
+ nameColumn
+ .setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_category_column_title);
nameColumn.setResizable(false);
- TableColumn keyColumn= new TableColumn(table, SWT.NONE);
- keyColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title);
+ TableColumn keyColumn = new TableColumn(table, SWT.NONE);
+ keyColumn.setText(
+ PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title);
keyColumn.setResizable(true);
-
+
fDefaultViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
- boolean checked= event.getChecked();
- ModelElement element= (ModelElement) event.getElement();
+ boolean checked = event.getChecked();
+ ModelElement element = (ModelElement) event.getElement();
element.setInDefaultCategory(checked);
}
});
-
+
fDefaultViewer.setContentProvider(ArrayContentProvider.getInstance());
-
- DefaultTableLabelProvider labelProvider= new DefaultTableLabelProvider();
+
+ DefaultTableLabelProvider labelProvider = new DefaultTableLabelProvider();
fDefaultViewer.setLabelProvider(labelProvider);
fDefaultViewer.setInput(fModel.elements);
fDefaultViewer.setComparator(new ViewerComparator()); // sort alphabetically
-
- final int ICON_AND_CHECKBOX_WITH= 50;
- final int HEADER_MARGIN= 20;
- int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
- int minKeyWidth= computeWidth(table, keyColumn.getText()) + HEADER_MARGIN;
- for (int i= 0; i < fModel.elements.size(); i++) {
- minNameWidth= Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
- minKeyWidth= Math.max(minKeyWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 1)));
- }
-
+
+ final int ICON_AND_CHECKBOX_WITH = 50;
+ final int HEADER_MARGIN = 20;
+ int minNameWidth = computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
+ int minKeyWidth = computeWidth(table, keyColumn.getText()) + HEADER_MARGIN;
+ for (int i = 0; i < fModel.elements.size(); i++) {
+ minNameWidth = Math.max(minNameWidth,
+ computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0))
+ + ICON_AND_CHECKBOX_WITH);
+ minKeyWidth = Math.max(minKeyWidth,
+ computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 1)));
+ }
+
nameColumn.setWidth(minNameWidth);
keyColumn.setWidth(minKeyWidth);
}
-
+
private void createKeysLink(Composite composite, int h_span) {
- Link link= new Link(composite, SWT.NONE | SWT.WRAP);
+ Link link = new Link(composite, SWT.NONE | SWT.WRAP);
link.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_key_binding_hint);
link.addSelectionListener(new SelectionAdapter() {
@Override
@@ -486,128 +499,131 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
PreferencesUtil.createPreferenceDialogOn(getShell(), e.text, null, null);
}
});
-
- PixelConverter pixelConverter= new PixelConverter(composite);
- int width= pixelConverter.convertWidthInCharsToPixels(40);
+
+ PixelConverter pixelConverter = new PixelConverter(composite);
+ int width = pixelConverter.convertWidthInCharsToPixels(40);
// limit the size of the Link as it would take all it can get
- GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
- gd.widthHint= width;
+ GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
+ gd.widthHint = width;
link.setLayoutData(gd);
- }
+ }
private void createFiller(Composite composite, int h_span) {
- Label filler= new Label(composite, SWT.NONE);
+ Label filler = new Label(composite, SWT.NONE);
filler.setVisible(false);
filler.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, h_span, 1));
- }
+ }
private void createSeparateLabel(Composite composite, int h_span) {
- PixelConverter pixelConverter= new PixelConverter(composite);
- int width= pixelConverter.convertWidthInCharsToPixels(40);
-
- Label label= new Label(composite, SWT.NONE | SWT.WRAP);
+ PixelConverter pixelConverter = new PixelConverter(composite);
+ int width = pixelConverter.convertWidthInCharsToPixels(40);
+
+ Label label = new Label(composite, SWT.NONE | SWT.WRAP);
label.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_description);
- GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
- gd.widthHint= width;
+ GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
+ gd.widthHint = width;
label.setLayoutData(gd);
}
-
+
private void createSeparateSection(Composite composite) {
createSeparateViewer(composite);
createButtonList(composite);
}
private void createSeparateViewer(Composite composite) {
- fSeparateViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
- Table table= fSeparateViewer.getTable();
+ fSeparateViewer = CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
+ Table table = fSeparateViewer.getTable();
table.setHeaderVisible(false);
table.setLinesVisible(false);
table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1));
-
- TableColumn nameColumn= new TableColumn(table, SWT.NONE);
- nameColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title);
+
+ TableColumn nameColumn = new TableColumn(table, SWT.NONE);
+ nameColumn
+ .setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title);
nameColumn.setResizable(false);
-
+
fSeparateViewer.setContentProvider(ArrayContentProvider.getInstance());
-
- ITableLabelProvider labelProvider= new SeparateTableLabelProvider();
+
+ ITableLabelProvider labelProvider = new SeparateTableLabelProvider();
fSeparateViewer.setLabelProvider(labelProvider);
fSeparateViewer.setInput(fModel.elements);
-
- final int ICON_AND_CHECKBOX_WITH= 50;
- final int HEADER_MARGIN= 20;
- int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
- for (int i= 0; i < fModel.elements.size(); i++) {
- minNameWidth= Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
- }
-
+
+ final int ICON_AND_CHECKBOX_WITH = 50;
+ final int HEADER_MARGIN = 20;
+ int minNameWidth = computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
+ for (int i = 0; i < fModel.elements.size(); i++) {
+ minNameWidth = Math.max(minNameWidth,
+ computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0))
+ + ICON_AND_CHECKBOX_WITH);
+ }
+
nameColumn.setWidth(minNameWidth);
-
+
fSeparateViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
- boolean checked= event.getChecked();
- ModelElement element= (ModelElement) event.getElement();
+ boolean checked = event.getChecked();
+ ModelElement element = (ModelElement) event.getElement();
element.setSeparateCommand(checked);
}
});
-
+
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleTableSelection();
}
});
-
+
}
-
+
private void createButtonList(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
-
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
composite.setLayout(layout);
-
- fUpButton= new Button(composite, SWT.PUSH | SWT.CENTER);
- fUpButton.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_Up);
- fUpButton.addSelectionListener(new SelectionAdapter() {
- @Override
+
+ fUpButton = new Button(composite, SWT.PUSH | SWT.CENTER);
+ fUpButton.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_Up);
+ fUpButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- int index= getSelectionIndex();
- if (index != -1) {
- (fModel.elements.get(index)).moveUp();
- fSeparateViewer.refresh();
- handleTableSelection();
- }
- }
- });
- fUpButton.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(fUpButton);
-
- fDownButton= new Button(composite, SWT.PUSH | SWT.CENTER);
- fDownButton.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_Down);
- fDownButton.addSelectionListener(new SelectionAdapter() {
- @Override
+ int index = getSelectionIndex();
+ if (index != -1) {
+ (fModel.elements.get(index)).moveUp();
+ fSeparateViewer.refresh();
+ handleTableSelection();
+ }
+ }
+ });
+ fUpButton.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(fUpButton);
+
+ fDownButton = new Button(composite, SWT.PUSH | SWT.CENTER);
+ fDownButton.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_Down);
+ fDownButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- int index= getSelectionIndex();
- if (index != -1) {
- (fModel.elements.get(index)).moveDown();
- fSeparateViewer.refresh();
- handleTableSelection();
- }
- }
- });
- fDownButton.setLayoutData(new GridData());
- SWTUtil.setButtonDimensionHint(fDownButton);
+ int index = getSelectionIndex();
+ if (index != -1) {
+ (fModel.elements.get(index)).moveDown();
+ fSeparateViewer.refresh();
+ handleTableSelection();
+ }
+ }
+ });
+ fDownButton.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(fDownButton);
}
private void handleTableSelection() {
- ModelElement item= getSelectedItem();
+ ModelElement item = getSelectedItem();
if (item != null) {
- int index= getSelectionIndex();
+ int index = getSelectionIndex();
fUpButton.setEnabled(index > 0);
fDownButton.setEnabled(index < fModel.elements.size() - 1);
} else {
@@ -615,15 +631,15 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
fDownButton.setEnabled(false);
}
}
-
+
private ModelElement getSelectedItem() {
return (ModelElement) ((IStructuredSelection) fSeparateViewer.getSelection()).getFirstElement();
}
-
+
private int getSelectionIndex() {
return fSeparateViewer.getTable().getSelectionIndex();
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
*/
@@ -637,14 +653,14 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
fSeparateViewer.refresh();
handleTableSelection();
}
-
+
private void updateCheckedState() {
- final int size= fModel.elements.size();
- List<ModelElement> defaultChecked= new ArrayList<ModelElement>(size);
- List<ModelElement> separateChecked= new ArrayList<ModelElement>(size);
+ final int size = fModel.elements.size();
+ List<ModelElement> defaultChecked = new ArrayList<ModelElement>(size);
+ List<ModelElement> separateChecked = new ArrayList<ModelElement>(size);
for (Object element2 : fModel.elements) {
- ModelElement element= (ModelElement) element2;
+ ModelElement element = (ModelElement) element2;
if (element.isInDefaultCategory())
defaultChecked.add(element);
if (element.isSeparateCommand())
@@ -661,10 +677,10 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
@Override
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
for (Object element : fModel.elements) {
- ModelElement item= (ModelElement) element;
+ ModelElement item = (ModelElement) element;
item.update();
}
-
+
return super.processChanges(container);
}
@@ -676,20 +692,19 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
if (changedKey == null) {
String newVal = getStoredValue(PREF_PROPOSAL_TIMEOUT);
validateSettings(PREF_PROPOSAL_TIMEOUT, null, newVal);
- }
- else if (changedKey.equals(PREF_PROPOSAL_TIMEOUT)) {
+ } else if (changedKey.equals(PREF_PROPOSAL_TIMEOUT)) {
StatusInfo statusInfo = new StatusInfo();
String errMsg = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalTimeoutErrMsg;
statusInfo.setError(errMsg);
if (newValue != null) {
- try {
- long parseLong = Long.parseLong(newValue);
- if (parseLong >= 0l) {
- statusInfo.setOK();
- }
- } catch (final NumberFormatException e) {
- // do nothing
- }
+ try {
+ long parseLong = Long.parseLong(newValue);
+ if (parseLong >= 0l) {
+ statusInfo.setOK();
+ }
+ } catch (final NumberFormatException e) {
+ // do nothing
+ }
}
fContext.statusChanged(statusInfo);
}
@@ -702,7 +717,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
// no builds triggered by our settings
return null;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#dispose()
*/
@@ -711,14 +726,14 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
for (Image image : fImages.values()) {
image.dispose();
}
-
+
super.dispose();
}
private int computeWidth(Control control, String name) {
if (name == null)
return 0;
- GC gc= new GC(control);
+ GC gc = new GC(control);
try {
gc.setFont(JFaceResources.getDialogFont());
return gc.stringExtent(name).x + 10;
@@ -729,14 +744,14 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
private static BindingManager fgLocalBindingManager;
static {
- fgLocalBindingManager= new BindingManager(new ContextManager(), new CommandManager());
- final IBindingService bindingService= PlatformUI.getWorkbench().getService(IBindingService.class);
- final Scheme[] definedSchemes= bindingService.getDefinedSchemes();
+ fgLocalBindingManager = new BindingManager(new ContextManager(), new CommandManager());
+ final IBindingService bindingService = PlatformUI.getWorkbench().getService(IBindingService.class);
+ final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
if (definedSchemes != null) {
try {
for (int i = 0; i < definedSchemes.length; i++) {
- final Scheme scheme= definedSchemes[i];
- final Scheme copy= fgLocalBindingManager.getScheme(scheme.getId());
+ final Scheme scheme = definedSchemes[i];
+ final Scheme copy = fgLocalBindingManager.getScheme(scheme.getId());
copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
}
} catch (final NotDefinedException e) {
@@ -748,32 +763,32 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
}
private static String getKeyboardShortcut(ParameterizedCommand command) {
- IBindingService bindingService= PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
fgLocalBindingManager.setBindings(bindingService.getBindings());
try {
- Scheme activeScheme= bindingService.getActiveScheme();
+ Scheme activeScheme = bindingService.getActiveScheme();
if (activeScheme != null)
fgLocalBindingManager.setActiveScheme(activeScheme);
} catch (NotDefinedException e) {
CUIPlugin.log(e);
}
-
- TriggerSequence[] bindings= fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command);
+
+ TriggerSequence[] bindings = fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command);
if (bindings.length > 0)
return bindings[0].format();
return null;
}
-
+
private Image getImage(ImageDescriptor imgDesc) {
if (imgDesc == null)
return null;
-
- Image img= fImages.get(imgDesc);
+
+ Image img = fImages.get(imgDesc);
if (img == null) {
- img= imgDesc.createImage(false);
+ img = imgDesc.createImage(false);
fImages.put(imgDesc, img);
}
return img;
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java
index ef21b3db7f5..d265e95fab9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java
@@ -24,15 +24,15 @@ import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-public final class CodeAssistAdvancedPreferencePage extends PropertyAndPreferencePage {
+public final class CodeAssistAdvancedPreferencePage extends PropertyAndPreferencePage {
private CodeAssistAdvancedConfigurationBlock fConfigurationBlock;
@Override
public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= new CodeAssistAdvancedConfigurationBlock(getNewStatusChangedListener(), container);
-
+ IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
+ fConfigurationBlock = new CodeAssistAdvancedConfigurationBlock(getNewStatusChangedListener(), container);
+
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_EDITOR_PREF_PAGE);
}
@@ -57,7 +57,7 @@ public final class CodeAssistAdvancedPreferencePage extends PropertyAndPreferenc
// no project settings supported
return null;
}
-
+
/*
* @see org.eclipse.jface.dialogs.DialogPage#dispose()
*/
@@ -68,7 +68,7 @@ public final class CodeAssistAdvancedPreferencePage extends PropertyAndPreferenc
}
super.dispose();
}
-
+
/*
* @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
*/
@@ -87,10 +87,10 @@ public final class CodeAssistAdvancedPreferencePage extends PropertyAndPreferenc
public boolean performOk() {
if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
return false;
- }
+ }
return super.performOk();
}
-
+
/*
* @see org.eclipse.jface.preference.IPreferencePage#performApply()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java
index 5be7f3a27a0..39b3bf901e8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java
@@ -49,31 +49,46 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
ArrayList<OverlayKey> overlayKeys = new ArrayList<>();
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PREFIX_COMPLETION));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.GUESS_ARGUMENTS));
-// overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.TIMEOUT_DELAY));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_ARGUMENTS));
-// overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES));
-// overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_SEARCH_SCOPE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FILTER));
-
- return overlayKeys.toArray(new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]);
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
+ ContentAssistPreference.AUTOACTIVATION_DELAY));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.AUTOINSERT));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.PREFIX_COMPLETION));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.GUESS_ARGUMENTS));
+ // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.TIMEOUT_DELAY));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_ARGUMENTS));
+ // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.ORDER_PROPOSALS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES));
+ // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ ContentAssistPreference.PROJECT_SEARCH_SCOPE));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ ContentAssistPreference.PROPOSALS_FILTER));
+
+ return overlayKeys.toArray(new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]);
}
-
+
@Override
public void createControl(Composite parent) {
- super.createControl(parent);
+ super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
ICHelpContextIds.C_EDITOR_CONTENT_ASSIST_PREF_PAGE);
}
@@ -82,7 +97,7 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
protected Control createContents(Composite parent) {
fOverlayStore.load();
fOverlayStore.start();
-
+
Composite contentAssistComposite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
@@ -92,60 +107,60 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// search scope (no longer supported)
// The following three radio buttons are grouped together
-// label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupTitle;
-// Group searchGroup = addGroupBox(contentAssistComposite, label, 2);
-//
-// label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption;
-// addRadioButton(searchGroup, label, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, 0);
-//
-// label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption;
-// addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_SEARCH_SCOPE, 0);
-
+ // label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupTitle;
+ // Group searchGroup = addGroupBox(contentAssistComposite, label, 2);
+ //
+ // label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption;
+ // addRadioButton(searchGroup, label, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, 0);
+ //
+ // label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption;
+ // addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_SEARCH_SCOPE, 0);
+
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertionGroupTitle;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertionGroupTitle;
Group insertionGroup = addGroupBox(contentAssistComposite, label, 2);
-
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically;
+
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically;
addCheckBox(insertionGroup, label, ContentAssistPreference.AUTOINSERT, 0);
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically;
addCheckBox(insertionGroup, label, ContentAssistPreference.PREFIX_COMPLETION, 0);
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_guessArguments;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_guessArguments;
addCheckBox(insertionGroup, label, ContentAssistPreference.GUESS_ARGUMENTS, 0);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// sorting and filtering
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_sortingSection_title;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_sortingSection_title;
Group sortingGroup = addGroupBox(contentAssistComposite, label, 2);
- label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder;
addCheckBox(sortingGroup, label, ContentAssistPreference.ORDER_PROPOSALS, 0);
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_proposalFilterSelect ;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_proposalFilterSelect;
addComboBox(sortingGroup, label, ContentAssistPreference.PROPOSALS_FILTER, NO_TEXT_LIMIT, 0);
- label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_showCamelCaseMatches;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_showCamelCaseMatches;
addCheckBox(sortingGroup, label, ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES, 0);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// The following items are grouped for Auto Activation
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle;
Group enableGroup = addGroupBox(contentAssistComposite, label, 2);
-
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot;
+
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot;
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, 0);
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow;
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, 0);
-
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
+
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0);
label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow;
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW, 0);
- label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationDelay;
+ label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationDelay;
addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 4, true);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java
index 26d24c2adbf..e7b72c23b0b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java
@@ -32,30 +32,30 @@ import org.eclipse.cdt.internal.ui.preferences.formatter.CodeFormatterConfigurat
* The page to configure the code formatter options.
*/
public class CodeFormatterPreferencePage extends PropertyAndPreferencePage {
- public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.CodeFormatterPreferencePage"; //$NON-NLS-1$
-
+ public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.CodeFormatterPreferencePage"; //$NON-NLS-1$
+
private CodeFormatterConfigurationBlock fConfigurationBlock;
public CodeFormatterPreferencePage() {
- setDescription(PreferencesMessages.CodeFormatterPreferencePage_description);
-
+ setDescription(PreferencesMessages.CodeFormatterPreferencePage_description);
+
// Only used when page is shown programmatically.
- setTitle(PreferencesMessages.CodeFormatterPreferencePage_title);
+ setTitle(PreferencesMessages.CodeFormatterPreferencePage_title);
}
@Override
public void createControl(Composite parent) {
- IPreferencePageContainer container= getContainer();
+ IPreferencePageContainer container = getContainer();
IWorkingCopyManager workingCopyManager;
if (container instanceof IWorkbenchPreferenceContainer) {
- workingCopyManager= ((IWorkbenchPreferenceContainer) container).getWorkingCopyManager();
+ workingCopyManager = ((IWorkbenchPreferenceContainer) container).getWorkingCopyManager();
} else {
- workingCopyManager= new WorkingCopyManager(); // non shared
+ workingCopyManager = new WorkingCopyManager(); // non shared
}
- PreferencesAccess access= PreferencesAccess.getWorkingCopyPreferences(workingCopyManager);
- fConfigurationBlock= new CodeFormatterConfigurationBlock(getProject(), access);
-
+ PreferencesAccess access = PreferencesAccess.getWorkingCopyPreferences(workingCopyManager);
+ fConfigurationBlock = new CodeFormatterConfigurationBlock(getProject(), access);
+
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
}
@@ -64,12 +64,12 @@ public class CodeFormatterPreferencePage extends PropertyAndPreferencePage {
protected Control createPreferenceContent(Composite composite) {
return fConfigurationBlock.createContents(composite);
}
-
+
@Override
protected boolean hasProjectSpecificOptions(IProject project) {
return fConfigurationBlock.hasProjectSpecificOptions(project);
}
-
+
@Override
protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
super.enableProjectSpecificSettings(useProjectSpecificSettings);
@@ -77,17 +77,17 @@ public class CodeFormatterPreferencePage extends PropertyAndPreferencePage {
fConfigurationBlock.enableProjectSpecificSettings(useProjectSpecificSettings);
}
}
-
+
@Override
protected String getPreferencePageId() {
return PREF_ID;
}
-
+
@Override
protected String getPropertyPageId() {
return PROP_ID;
}
-
+
@Override
public void dispose() {
if (fConfigurationBlock != null) {
@@ -95,7 +95,7 @@ public class CodeFormatterPreferencePage extends PropertyAndPreferencePage {
}
super.dispose();
}
-
+
@Override
protected void performDefaults() {
if (fConfigurationBlock != null) {
@@ -108,18 +108,18 @@ public class CodeFormatterPreferencePage extends PropertyAndPreferencePage {
public boolean performOk() {
if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
return false;
- }
+ }
return super.performOk();
}
-
+
@Override
public void performApply() {
if (fConfigurationBlock != null) {
fConfigurationBlock.performApply();
- }
+ }
super.performApply();
}
-
+
@Override
public void setElement(IAdaptable element) {
super.setElement(element);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStyleBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStyleBlock.java
index b9c5b30b6f7..f747c5c6e7d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStyleBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStyleBlock.java
@@ -31,60 +31,55 @@ import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
* Configures elements of C/C++ code style affecting refactoring.
*/
class CodeStyleBlock extends OptionsConfigurationBlock {
- private static final Key CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER =
- getCDTUIKey(PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER);
- private static final Key FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT =
- getCDTUIKey(PreferenceConstants.FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT);
- private static final Key FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER =
- getCDTUIKey(PreferenceConstants.FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER);
- private static final Key PLACE_CONST_RIGHT_OF_TYPE =
- getKey(CCorePlugin.PLUGIN_ID, CCorePreferenceConstants.PLACE_CONST_RIGHT_OF_TYPE);
+ private static final Key CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER = getCDTUIKey(
+ PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER);
+ private static final Key FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT = getCDTUIKey(
+ PreferenceConstants.FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT);
+ private static final Key FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER = getCDTUIKey(
+ PreferenceConstants.FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER);
+ private static final Key PLACE_CONST_RIGHT_OF_TYPE = getKey(CCorePlugin.PLUGIN_ID,
+ CCorePreferenceConstants.PLACE_CONST_RIGHT_OF_TYPE);
private static Key[] getAllKeys() {
- return new Key[] {
- CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER,
- FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT,
- FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER,
- PLACE_CONST_RIGHT_OF_TYPE,
- };
+ return new Key[] { CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER, FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT,
+ FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER, PLACE_CONST_RIGHT_OF_TYPE, };
}
- public CodeStyleBlock(IStatusChangeListener context, IProject project,
- IWorkbenchPreferenceContainer container) {
+ public CodeStyleBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
super(context, project, getAllKeys(), container);
}
-
+
@Override
public Control createContents(Composite parent) {
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ ScrolledPageContent scrolled = new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
-
- Composite control= new Composite(scrolled, SWT.NONE);
- GridLayout layout= new GridLayout();
+
+ Composite control = new Composite(scrolled, SWT.NONE);
+ GridLayout layout = new GridLayout();
control.setLayout(layout);
- Composite composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_class_member_order);
+ Composite composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_class_member_order);
fillClassMemberOrderSection(composite);
-
- composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_function_parameter_order);
+
+ composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_function_parameter_order);
fillFunctionParameterOrderSection(composite);
- composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_function_output_parameter_style);
+ composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_function_output_parameter_style);
fillFunctionOutputParameterStyleSection(composite);
-
+
composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_const_keyword_placement);
fillConstPlacementsSections(composite);
scrolled.setContent(control);
- final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ final Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrolled.setMinSize(size.x, size.y);
return scrolled;
}
private void fillClassMemberOrderSection(Composite composite) {
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
composite.setLayout(layout);
addRadioButton(composite, PreferencesMessages.CodeStyleBlock_public_private,
@@ -94,8 +89,8 @@ class CodeStyleBlock extends OptionsConfigurationBlock {
}
private void fillFunctionParameterOrderSection(Composite composite) {
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
composite.setLayout(layout);
addRadioButton(composite, PreferencesMessages.CodeStyleBlock_input_output,
@@ -105,8 +100,8 @@ class CodeStyleBlock extends OptionsConfigurationBlock {
}
private void fillFunctionOutputParameterStyleSection(Composite composite) {
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
composite.setLayout(layout);
addRadioButton(composite, PreferencesMessages.CodeStyleBlock_pass_by_reference,
@@ -116,14 +111,14 @@ class CodeStyleBlock extends OptionsConfigurationBlock {
}
private void fillConstPlacementsSections(Composite composite) {
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
composite.setLayout(layout);
- addRadioButton(composite, PreferencesMessages.CodeStyleBlock_const_left,
- PLACE_CONST_RIGHT_OF_TYPE, FALSE_TRUE, 0);
- addRadioButton(composite, PreferencesMessages.CodeStyleBlock_const_right,
- PLACE_CONST_RIGHT_OF_TYPE, TRUE_FALSE, 0);
+ addRadioButton(composite, PreferencesMessages.CodeStyleBlock_const_left, PLACE_CONST_RIGHT_OF_TYPE, FALSE_TRUE,
+ 0);
+ addRadioButton(composite, PreferencesMessages.CodeStyleBlock_const_right, PLACE_CONST_RIGHT_OF_TYPE, TRUE_FALSE,
+ 0);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStylePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStylePreferencePage.java
index 4c0cdd1125e..0480779198a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStylePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeStylePreferencePage.java
@@ -23,13 +23,13 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The page for setting various code style preferences.
*/
public class CodeStylePreferencePage extends ConfigurationBlockPropertyAndPreferencePage {
- public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.CodeStylePreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.CodeStylePreferencePage"; //$NON-NLS-1$
+ public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.CodeStylePreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.CodeStylePreferencePage"; //$NON-NLS-1$
public CodeStylePreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
// Only used when the page is shown programmatically.
- setTitle(PreferencesMessages.CodeStylePreferencePage_title);
+ setTitle(PreferencesMessages.CodeStylePreferencePage_title);
}
@Override
@@ -51,6 +51,6 @@ public class CodeStylePreferencePage extends ConfigurationBlockPropertyAndPrefer
protected String getPropertyPageId() {
return null;
// TODO(sprigogin): Project specific settings
-// return PROP_ID;
+ // return PROP_ID;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java
index 3dcb340664b..83418b54884 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java
@@ -84,30 +84,30 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
/**
*/
public class CodeTemplateBlock extends OptionsConfigurationBlock {
-
+
private class CodeTemplateAdapter extends ViewerComparator
implements ITreeListAdapter<Object>, IDialogFieldListener {
- private final Object[] NO_CHILDREN= new Object[0];
+ private final Object[] NO_CHILDREN = new Object[0];
@Override
public void customButtonPressed(TreeListDialogField<Object> field, int index) {
doButtonPressed(index, field.getSelectedElements());
}
-
+
@Override
public void selectionChanged(TreeListDialogField<Object> field) {
- List<Object> selected= field.getSelectedElements();
+ List<Object> selected = field.getSelectedElements();
field.enableButton(IDX_ADD, canAdd(selected));
field.enableButton(IDX_EDIT, canEdit(selected));
field.enableButton(IDX_REMOVE, canRemove(selected));
field.enableButton(IDX_EXPORT, !selected.isEmpty());
-
+
updateSourceViewerInput(selected);
}
@Override
public void doubleClicked(TreeListDialogField<Object> field) {
- List<Object> selected= field.getSelectedElements();
+ List<Object> selected = field.getSelectedElements();
if (canEdit(selected)) {
doButtonPressed(IDX_EDIT, selected);
}
@@ -128,7 +128,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
@Override
public Object getParent(TreeListDialogField<Object> field, Object element) {
if (element instanceof TemplatePersistenceData) {
- TemplatePersistenceData data= (TemplatePersistenceData) element;
+ TemplatePersistenceData data = (TemplatePersistenceData) element;
if (data.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
return COMMENT_NODE;
}
@@ -144,7 +144,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
@Override
public boolean hasChildren(TreeListDialogField<Object> field, Object element) {
- return (element == COMMENT_NODE || element == CODE_NODE || element == FILE_NODE || element instanceof TemplateContextType);
+ return (element == COMMENT_NODE || element == CODE_NODE || element == FILE_NODE
+ || element instanceof TemplateContextType);
}
@Override
@@ -157,7 +158,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
@Override
public void keyPressed(TreeListDialogField<Object> field, KeyEvent event) {
}
-
+
/*
* @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
*/
@@ -170,8 +171,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
} else if (element == FILE_NODE) {
return 3;
} else if (element instanceof TemplateContextType) {
- TemplateContextType type= (TemplateContextType) element;
- String id= type.getId();
+ TemplateContextType type = (TemplateContextType) element;
+ String id = type.getId();
if (CodeTemplateContextType.CPPSOURCEFILE_CONTEXTTYPE.equals(id)) {
return 1;
} else if (CodeTemplateContextType.CPPHEADERFILE_CONTEXTTYPE.equals(id)) {
@@ -187,10 +188,10 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
return 1000;
}
-
- TemplatePersistenceData data= (TemplatePersistenceData) element;
- String id= data.getId();
-
+
+ TemplatePersistenceData data = (TemplatePersistenceData) element;
+ String id = data.getId();
+
if (CodeTemplateContextType.ASMSOURCEFILE_CONTEXTTYPE.equals(id)) {
return 105;
} else if (CodeTemplateContextType.NAMESPACE_BEGIN_ID.equals(id)) {
@@ -228,35 +229,35 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
*/
@Override
public Image getImage(Object element) {
-// if (element == COMMENT_NODE || element == CODE_NODE || element == FILE_NODE) {
-// return null;
-// }
-// if (element instanceof TemplateContextType) {
-// String id= ((TemplateContextType)element).getId();
-// if (FileTemplateContextType.isFileTemplateContextType(id)) {
-// IContentType contentType= FileTemplateContextType.getContentTypeFromConextType(id);
-// if (contentType != null) {
-// String dummyFileName;
-// String[] fileSpecs= contentType.getFileSpecs(IContentType.FILE_NAME_SPEC);
-// if (fileSpecs.length > 0) {
-// dummyFileName= fileSpecs[0];
-// } else {
-// String[] extSpecs= contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
-// if (extSpecs.length > 0) {
-// dummyFileName= "dummy" + extSpecs[0]; //$NON-NLS-1$
-// } else {
-// dummyFileName= "dummy"; //$NON-NLS-1$
-// }
-// }
-// IEditorRegistry editorRegistry= PlatformUI.getWorkbench().getEditorRegistry();
-// IEditorDescriptor[] editorDesc= editorRegistry.getEditors(dummyFileName, contentType);
-// if (editorDesc.length > 0) {
-// ImageDescriptor desc= editorDesc[0].getImageDescriptor();
-// return CUIPlugin.getImageDescriptorRegistry().get(desc);
-// }
-// }
-// }
-// }
+ // if (element == COMMENT_NODE || element == CODE_NODE || element == FILE_NODE) {
+ // return null;
+ // }
+ // if (element instanceof TemplateContextType) {
+ // String id= ((TemplateContextType)element).getId();
+ // if (FileTemplateContextType.isFileTemplateContextType(id)) {
+ // IContentType contentType= FileTemplateContextType.getContentTypeFromConextType(id);
+ // if (contentType != null) {
+ // String dummyFileName;
+ // String[] fileSpecs= contentType.getFileSpecs(IContentType.FILE_NAME_SPEC);
+ // if (fileSpecs.length > 0) {
+ // dummyFileName= fileSpecs[0];
+ // } else {
+ // String[] extSpecs= contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+ // if (extSpecs.length > 0) {
+ // dummyFileName= "dummy" + extSpecs[0]; //$NON-NLS-1$
+ // } else {
+ // dummyFileName= "dummy"; //$NON-NLS-1$
+ // }
+ // }
+ // IEditorRegistry editorRegistry= PlatformUI.getWorkbench().getEditorRegistry();
+ // IEditorDescriptor[] editorDesc= editorRegistry.getEditors(dummyFileName, contentType);
+ // if (editorDesc.length > 0) {
+ // ImageDescriptor desc= editorDesc[0].getImageDescriptor();
+ // return CUIPlugin.getImageDescriptorRegistry().get(desc);
+ // }
+ // }
+ // }
+ // }
return null;
}
@@ -271,8 +272,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
if (element instanceof TemplateContextType) {
return ((TemplateContextType) element).getName();
}
- TemplatePersistenceData data= (TemplatePersistenceData) element;
- String id= data.getId();
+ TemplatePersistenceData data = (TemplatePersistenceData) element;
+ String id = data.getId();
if (FileTemplateContextType.isFileTemplateContextType(data.getTemplate().getContextTypeId())) {
return data.getTemplate().getName();
} else if (CodeTemplateContextType.NAMESPACE_BEGIN_ID.equals(id)) {
@@ -302,62 +303,57 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
return data.getTemplate().getName();
}
- }
-
- private static final Key PREF_GENERATE_COMMENTS= getCDTUIKey(PreferenceConstants.CODEGEN_ADD_COMMENTS);
-
+ }
+
+ private static final Key PREF_GENERATE_COMMENTS = getCDTUIKey(PreferenceConstants.CODEGEN_ADD_COMMENTS);
+
private static Key[] getAllKeys() {
- return new Key[] {
- PREF_GENERATE_COMMENTS
- };
- }
-
- private final static int IDX_ADD= 0;
- private final static int IDX_EDIT= 1;
- private final static int IDX_REMOVE= 2;
- private final static int IDX_IMPORT= 3;
- private final static int IDX_EXPORT= 4;
- private final static int IDX_EXPORTALL= 5;
-
- protected final static Object COMMENT_NODE= PreferencesMessages.CodeTemplateBlock_templates_comment_node;
- protected final static Object CODE_NODE= PreferencesMessages.CodeTemplateBlock_templates_code_node;
- protected final static Object FILE_NODE= PreferencesMessages.CodeTemplateBlock_templates_file_node;
+ return new Key[] { PREF_GENERATE_COMMENTS };
+ }
+
+ private final static int IDX_ADD = 0;
+ private final static int IDX_EDIT = 1;
+ private final static int IDX_REMOVE = 2;
+ private final static int IDX_IMPORT = 3;
+ private final static int IDX_EXPORT = 4;
+ private final static int IDX_EXPORTALL = 5;
+
+ protected final static Object COMMENT_NODE = PreferencesMessages.CodeTemplateBlock_templates_comment_node;
+ protected final static Object CODE_NODE = PreferencesMessages.CodeTemplateBlock_templates_code_node;
+ protected final static Object FILE_NODE = PreferencesMessages.CodeTemplateBlock_templates_file_node;
private TreeListDialogField<Object> fCodeTemplateTree;
private SelectionButtonDialogField fGenerateComments;
-
+
protected ProjectTemplateStore fTemplateStore;
-
+
private PixelConverter fPixelConverter;
private SourceViewer fPatternViewer;
private TemplateVariableProcessor fTemplateProcessor;
private ContextTypeRegistry fFileTemplateContextTypes;
-
- public CodeTemplateBlock(IStatusChangeListener context, IProject project,
- IWorkbenchPreferenceContainer container) {
+
+ public CodeTemplateBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
super(context, project, getAllKeys(), container);
-
- fTemplateStore= new ProjectTemplateStore(project);
+
+ fTemplateStore = new ProjectTemplateStore(project);
try {
fTemplateStore.load();
} catch (IOException e) {
CUIPlugin.log(e);
}
-
- fTemplateProcessor= new TemplateVariableProcessor();
-
- CodeTemplateAdapter adapter= new CodeTemplateAdapter();
-
- String[] buttonLabels= new String[] {
- PreferencesMessages.CodeTemplateBlock_templates_new_button,
- PreferencesMessages.CodeTemplateBlock_templates_edit_button,
- PreferencesMessages.CodeTemplateBlock_templates_remove_button,
- PreferencesMessages.CodeTemplateBlock_templates_import_button,
- PreferencesMessages.CodeTemplateBlock_templates_export_button,
- PreferencesMessages.CodeTemplateBlock_templates_exportall_button
- };
- fCodeTemplateTree= new TreeListDialogField<Object>(adapter, buttonLabels, new CodeTemplateLabelProvider());
+
+ fTemplateProcessor = new TemplateVariableProcessor();
+
+ CodeTemplateAdapter adapter = new CodeTemplateAdapter();
+
+ String[] buttonLabels = new String[] { PreferencesMessages.CodeTemplateBlock_templates_new_button,
+ PreferencesMessages.CodeTemplateBlock_templates_edit_button,
+ PreferencesMessages.CodeTemplateBlock_templates_remove_button,
+ PreferencesMessages.CodeTemplateBlock_templates_import_button,
+ PreferencesMessages.CodeTemplateBlock_templates_export_button,
+ PreferencesMessages.CodeTemplateBlock_templates_exportall_button };
+ fCodeTemplateTree = new TreeListDialogField<Object>(adapter, buttonLabels, new CodeTemplateLabelProvider());
fCodeTemplateTree.setDialogFieldListener(adapter);
fCodeTemplateTree.setLabelText(PreferencesMessages.CodeTemplateBlock_templates_label);
fCodeTemplateTree.setViewerComparator(adapter);
@@ -366,17 +362,17 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
fCodeTemplateTree.enableButton(IDX_ADD, false);
fCodeTemplateTree.enableButton(IDX_EDIT, false);
fCodeTemplateTree.enableButton(IDX_REMOVE, false);
-
+
fCodeTemplateTree.addElement(COMMENT_NODE);
fCodeTemplateTree.addElement(CODE_NODE);
fCodeTemplateTree.addElement(FILE_NODE);
- fCodeTemplateTree.selectFirstElement();
-
- fGenerateComments= new SelectionButtonDialogField(SWT.CHECK | SWT.WRAP);
+ fCodeTemplateTree.selectFirstElement();
+
+ fGenerateComments = new SelectionButtonDialogField(SWT.CHECK | SWT.WRAP);
fGenerateComments.setDialogFieldListener(adapter);
- fGenerateComments.setLabelText(PreferencesMessages.CodeTemplateBlock_createcomment_label);
-
+ fGenerateComments.setLabelText(PreferencesMessages.CodeTemplateBlock_createcomment_label);
+
updateControls();
}
@@ -388,39 +384,39 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
public boolean hasProjectSpecificOptions(IProject project) {
if (super.hasProjectSpecificOptions(project))
return true;
-
+
if (project != null) {
return ProjectTemplateStore.hasProjectSpecificTempates(project);
}
return false;
- }
-
+ }
+
@Override
protected Control createContents(Composite parent) {
- fPixelConverter= new PixelConverter(parent);
+ fPixelConverter = new PixelConverter(parent);
setShell(parent.getShell());
-
- Composite composite= new Composite(parent, SWT.NONE);
+
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setFont(parent.getFont());
-
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
+
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
composite.setLayout(layout);
-
+
fCodeTemplateTree.doFillIntoGrid(composite, 3);
LayoutUtil.setHorizontalSpan(fCodeTemplateTree.getLabelControl(null), 2);
LayoutUtil.setHorizontalGrabbing(fCodeTemplateTree.getTreeControl(null), true);
-
- fPatternViewer= createViewer(composite, 2);
-
+
+ fPatternViewer = createViewer(composite, 2);
+
fGenerateComments.doFillIntoGrid(composite, 2);
-
+
return composite;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
*/
@@ -428,68 +424,73 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
protected void updateControls() {
fGenerateComments.setSelection(getBooleanValue(PREF_GENERATE_COMMENTS));
}
-
+
private SourceViewer createViewer(Composite parent, int nColumns) {
- Label label= new Label(parent, SWT.NONE);
- label.setText(PreferencesMessages.CodeTemplateBlock_preview);
- GridData data= new GridData();
- data.horizontalSpan= nColumns;
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(PreferencesMessages.CodeTemplateBlock_preview);
+ GridData data = new GridData();
+ data.horizontalSpan = nColumns;
label.setLayoutData(data);
-
- IDocument document= new Document();
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
+
+ IDocument document = new Document();
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
tools.setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- SourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
- CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ SourceViewer viewer = new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
+ store);
+ CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration(
+ tools.getColorManager(), store, null, fTemplateProcessor);
viewer.configure(configuration);
viewer.setEditable(false);
viewer.setDocument(document);
-
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+
+ Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new CSourcePreviewerUpdater(viewer, configuration, store);
-
- Control control= viewer.getControl();
- data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- data.horizontalSpan= nColumns;
- data.heightHint= fPixelConverter.convertHeightInCharsToPixels(5);
+
+ Control control = viewer.getControl();
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+ data.horizontalSpan = nColumns;
+ data.heightHint = fPixelConverter.convertHeightInCharsToPixels(5);
control.setLayoutData(data);
-
+
return viewer;
}
private void reconfigurePatternViewer() {
if (fPatternViewer == null)
return;
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration(
+ tools.getColorManager(), store, null, fTemplateProcessor);
fPatternViewer.unconfigure();
fPatternViewer.configure(configuration);
fPatternViewer.invalidateTextPresentation();
}
protected TemplatePersistenceData[] getCodeTemplatesOfCategory(boolean isComment) {
- ArrayList<TemplatePersistenceData> res= new ArrayList<TemplatePersistenceData>();
- TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
+ ArrayList<TemplatePersistenceData> res = new ArrayList<TemplatePersistenceData>();
+ TemplatePersistenceData[] templates = fTemplateStore.getTemplateData();
for (TemplatePersistenceData curr : templates) {
- boolean isUserAdded= curr.getId() == null;
- boolean isFileTemplate= FileTemplateContextType.isFileTemplateContextType(curr.getTemplate().getContextTypeId());
- if (!isUserAdded && !isFileTemplate && isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
+ boolean isUserAdded = curr.getId() == null;
+ boolean isFileTemplate = FileTemplateContextType
+ .isFileTemplateContextType(curr.getTemplate().getContextTypeId());
+ if (!isUserAdded && !isFileTemplate
+ && isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
res.add(curr);
}
}
return res.toArray(new TemplatePersistenceData[res.size()]);
}
-
+
private TemplatePersistenceData[] getTemplatesOfContextType(TemplateContextType contextType) {
return getTemplatesOfContextType(contextType.getId());
}
protected TemplatePersistenceData[] getTemplatesOfContextType(String contextTypeId) {
- ArrayList<TemplatePersistenceData> res= new ArrayList<TemplatePersistenceData>();
- TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
+ ArrayList<TemplatePersistenceData> res = new ArrayList<TemplatePersistenceData>();
+ TemplatePersistenceData[] templates = fTemplateStore.getTemplateData();
for (TemplatePersistenceData curr : templates) {
if (contextTypeId.equals(curr.getTemplate().getContextTypeId())) {
res.add(curr);
@@ -500,11 +501,11 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
protected ContextTypeRegistry getFileTemplateContextRegistry() {
if (fFileTemplateContextTypes == null) {
- fFileTemplateContextTypes= new ContextTypeRegistry();
- Iterator<?> contextTypesIter= CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes();
- while(contextTypesIter.hasNext()) {
- TemplateContextType contextType= (TemplateContextType)contextTypesIter.next();
- final String contextTypeId= contextType.getId();
+ fFileTemplateContextTypes = new ContextTypeRegistry();
+ Iterator<?> contextTypesIter = CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes();
+ while (contextTypesIter.hasNext()) {
+ TemplateContextType contextType = (TemplateContextType) contextTypesIter.next();
+ final String contextTypeId = contextType.getId();
// add if at least one template registered
if (FileTemplateContextType.isFileTemplateContextType(contextTypeId)) {
fFileTemplateContextTypes.addContextType(contextType);
@@ -513,12 +514,12 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
return fFileTemplateContextTypes;
}
-
+
protected TemplateContextType[] getFileTemplateContextTypes() {
- Iterator<?> iter= getFileTemplateContextRegistry().contextTypes();
- ArrayList<TemplateContextType> result= new ArrayList<TemplateContextType>();
+ Iterator<?> iter = getFileTemplateContextRegistry().contextTypes();
+ ArrayList<TemplateContextType> result = new ArrayList<TemplateContextType>();
while (iter.hasNext()) {
- TemplateContextType contextType= (TemplateContextType)iter.next();
+ TemplateContextType contextType = (TemplateContextType) iter.next();
if (getTemplatesOfContextType(contextType).length > 0) {
result.add(contextType);
}
@@ -528,7 +529,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
protected static boolean canAdd(List<Object> selected) {
if (selected.size() == 1) {
- Object element= selected.get(0);
+ Object element = selected.get(0);
if (element instanceof TemplateContextType || element == FILE_NODE) {
return true;
}
@@ -540,34 +541,35 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
}
return false;
- }
-
+ }
+
protected static boolean canEdit(List<Object> selected) {
return selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData);
- }
-
+ }
+
protected static boolean canRemove(List<Object> selected) {
if (selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData)) {
- TemplatePersistenceData data= (TemplatePersistenceData)selected.get(0);
+ TemplatePersistenceData data = (TemplatePersistenceData) selected.get(0);
return data.isUserAdded();
}
return false;
}
-
+
protected void updateSourceViewerInput(List<Object> selection) {
if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) {
return;
}
if (selection.size() == 1 && selection.get(0) instanceof TemplatePersistenceData) {
- TemplatePersistenceData data= (TemplatePersistenceData) selection.get(0);
- Template template= data.getTemplate();
- TemplateContextType type= CUIPlugin.getDefault().getCodeTemplateContextRegistry().getContextType(template.getContextTypeId());
+ TemplatePersistenceData data = (TemplatePersistenceData) selection.get(0);
+ Template template = data.getTemplate();
+ TemplateContextType type = CUIPlugin.getDefault().getCodeTemplateContextRegistry()
+ .getContextType(template.getContextTypeId());
fTemplateProcessor.setContextType(type);
reconfigurePatternViewer();
fPatternViewer.getDocument().set(template.getPattern());
} else {
fPatternViewer.getDocument().set(""); //$NON-NLS-1$
- }
+ }
}
protected void doButtonPressed(int buttonIndex, List<Object> selected) {
@@ -576,26 +578,26 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
edit((TemplatePersistenceData) selected.get(0), false);
break;
case IDX_ADD: {
- Object element= selected.get(0);
- Template orig= null;
+ Object element = selected.get(0);
+ Template orig = null;
String contextTypeId;
if (element instanceof TemplatePersistenceData) {
- orig= ((TemplatePersistenceData)element).getTemplate();
- contextTypeId= orig.getContextTypeId();
+ orig = ((TemplatePersistenceData) element).getTemplate();
+ contextTypeId = orig.getContextTypeId();
} else if (element instanceof TemplateContextType) {
- TemplateContextType type= (TemplateContextType)selected.get(0);
- contextTypeId= type.getId();
+ TemplateContextType type = (TemplateContextType) selected.get(0);
+ contextTypeId = type.getId();
} else {
// default: text file
- contextTypeId= FileTemplateContextType.TEXTFILE_CONTEXTTYPE;
+ contextTypeId = FileTemplateContextType.TEXTFILE_CONTEXTTYPE;
}
Template newTemplate;
if (orig != null) {
- newTemplate= new Template("", "", contextTypeId, orig.getPattern(), false); //$NON-NLS-1$//$NON-NLS-2$
+ newTemplate = new Template("", "", contextTypeId, orig.getPattern(), false); //$NON-NLS-1$//$NON-NLS-2$
} else {
- newTemplate= new Template("", "", contextTypeId, "", false); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ newTemplate = new Template("", "", contextTypeId, "", false); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
}
- TemplatePersistenceData newData= new TemplatePersistenceData(newTemplate, true);
+ TemplatePersistenceData newData = new TemplatePersistenceData(newTemplate, true);
edit(newData, true);
break;
}
@@ -613,7 +615,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
break;
}
}
-
+
private void remove(TemplatePersistenceData data) {
if (data.isUserAdded()) {
fTemplateStore.delete(data);
@@ -622,15 +624,16 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
private void edit(TemplatePersistenceData data, boolean isNew) {
- Template newTemplate= new Template(data.getTemplate());
- boolean isFileTemplate= FileTemplateContextType.isFileTemplateContextType(newTemplate.getContextTypeId());
+ Template newTemplate = new Template(data.getTemplate());
+ boolean isFileTemplate = FileTemplateContextType.isFileTemplateContextType(newTemplate.getContextTypeId());
ContextTypeRegistry contextTypeRegistry;
if (isFileTemplate) {
- contextTypeRegistry= getFileTemplateContextRegistry();
+ contextTypeRegistry = getFileTemplateContextRegistry();
} else {
- contextTypeRegistry= CUIPlugin.getDefault().getCodeTemplateContextRegistry();
+ contextTypeRegistry = CUIPlugin.getDefault().getCodeTemplateContextRegistry();
}
- EditTemplateDialog dialog= new EditTemplateDialog(getShell(), newTemplate, !isNew, data.isUserAdded(), isFileTemplate, contextTypeRegistry);
+ EditTemplateDialog dialog = new EditTemplateDialog(getShell(), newTemplate, !isNew, data.isUserAdded(),
+ isFileTemplate, contextTypeRegistry);
if (dialog.open() == Window.OK) {
// changed
data.setTemplate(dialog.getTemplate());
@@ -646,23 +649,23 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
fCodeTemplateTree.selectElements(new StructuredSelection(data));
}
}
-
+
private void import_() {
- FileDialog dialog= new FileDialog(getShell());
- dialog.setText(PreferencesMessages.CodeTemplateBlock_import_title);
- dialog.setFilterExtensions(new String[] {PreferencesMessages.CodeTemplateBlock_import_extension});
- String path= dialog.open();
-
+ FileDialog dialog = new FileDialog(getShell());
+ dialog.setText(PreferencesMessages.CodeTemplateBlock_import_title);
+ dialog.setFilterExtensions(new String[] { PreferencesMessages.CodeTemplateBlock_import_extension });
+ String path = dialog.open();
+
if (path == null)
return;
-
+
try {
- TemplateReaderWriter reader= new TemplateReaderWriter();
- File file= new File(path);
+ TemplateReaderWriter reader = new TemplateReaderWriter();
+ File file = new File(path);
if (file.exists()) {
- InputStream input= new BufferedInputStream(new FileInputStream(file));
+ InputStream input = new BufferedInputStream(new FileInputStream(file));
try {
- TemplatePersistenceData[] datas= reader.read(input, null);
+ TemplatePersistenceData[] datas = reader.read(input, null);
for (TemplatePersistenceData data : datas) {
updateTemplate(data);
}
@@ -682,14 +685,14 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
openReadErrorDialog(e);
}
}
-
+
private void updateTemplate(TemplatePersistenceData data) {
- String dataId= data.getId();
- TemplatePersistenceData[] datas= fTemplateStore.getTemplateData();
+ String dataId = data.getId();
+ TemplatePersistenceData[] datas = fTemplateStore.getTemplateData();
if (dataId != null) {
// predefined
for (TemplatePersistenceData data2 : datas) {
- String id= data2.getId();
+ String id = data2.getId();
if (id != null && id.equals(dataId)) {
data2.setTemplate(data.getTemplate());
return;
@@ -697,12 +700,13 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
} else {
// user added
- String dataName= data.getTemplate().getName();
+ String dataName = data.getTemplate().getName();
for (TemplatePersistenceData data2 : datas) {
if (data2.getId() == null) {
- String name= data2.getTemplate().getName();
- String contextTypeId= data2.getTemplate().getContextTypeId();
- if (name != null && name.equals(dataName) && contextTypeId.equals(data.getTemplate().getContextTypeId())) {
+ String name = data2.getTemplate().getName();
+ String contextTypeId = data2.getTemplate().getContextTypeId();
+ if (name != null && name.equals(dataName)
+ && contextTypeId.equals(data.getTemplate().getContextTypeId())) {
data2.setTemplate(data.getTemplate());
return;
}
@@ -712,65 +716,68 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
fTemplateStore.addTemplateData(data);
}
}
-
+
private void exportAll() {
- export(fTemplateStore.getTemplateData());
+ export(fTemplateStore.getTemplateData());
}
-
+
private void export(List<Object> selected) {
- Set<Object> datas= new HashSet<Object>();
- for (int i= 0; i < selected.size(); i++) {
- Object curr= selected.get(i);
+ Set<Object> datas = new HashSet<Object>();
+ for (int i = 0; i < selected.size(); i++) {
+ Object curr = selected.get(i);
if (curr instanceof TemplatePersistenceData) {
datas.add(curr);
} else if (curr instanceof TemplateContextType) {
- TemplatePersistenceData[] cat= getTemplatesOfContextType((TemplateContextType)curr);
+ TemplatePersistenceData[] cat = getTemplatesOfContextType((TemplateContextType) curr);
datas.addAll(Arrays.asList(cat));
} else if (curr == FILE_NODE) {
- TemplateContextType[] types= getFileTemplateContextTypes();
+ TemplateContextType[] types = getFileTemplateContextTypes();
for (TemplateContextType contextType : types) {
- TemplatePersistenceData[] cat= getTemplatesOfContextType(contextType);
+ TemplatePersistenceData[] cat = getTemplatesOfContextType(contextType);
datas.addAll(Arrays.asList(cat));
}
} else if (curr == COMMENT_NODE || curr == CODE_NODE) {
- TemplatePersistenceData[] cat= getCodeTemplatesOfCategory(curr == COMMENT_NODE);
+ TemplatePersistenceData[] cat = getCodeTemplatesOfCategory(curr == COMMENT_NODE);
datas.addAll(Arrays.asList(cat));
}
}
export(datas.toArray(new TemplatePersistenceData[datas.size()]));
}
-
+
private void export(TemplatePersistenceData[] templates) {
- FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
- dialog.setText(Messages.format(PreferencesMessages.CodeTemplateBlock_export_title, String.valueOf(templates.length)));
- dialog.setFilterExtensions(new String[] {PreferencesMessages.CodeTemplateBlock_export_extension});
- dialog.setFileName(PreferencesMessages.CodeTemplateBlock_export_filename);
- String path= dialog.open();
+ FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
+ dialog.setText(
+ Messages.format(PreferencesMessages.CodeTemplateBlock_export_title, String.valueOf(templates.length)));
+ dialog.setFilterExtensions(new String[] { PreferencesMessages.CodeTemplateBlock_export_extension });
+ dialog.setFileName(PreferencesMessages.CodeTemplateBlock_export_filename);
+ String path = dialog.open();
if (path == null)
return;
-
- File file= new File(path);
+
+ File file = new File(path);
if (file.isHidden()) {
- String title= PreferencesMessages.CodeTemplateBlock_export_error_title;
- String message= Messages.format(PreferencesMessages.CodeTemplateBlock_export_error_hidden, file.getAbsolutePath());
+ String title = PreferencesMessages.CodeTemplateBlock_export_error_title;
+ String message = Messages.format(PreferencesMessages.CodeTemplateBlock_export_error_hidden,
+ file.getAbsolutePath());
MessageDialog.openError(getShell(), title, message);
return;
}
-
+
if (file.exists() && !file.canWrite()) {
- String title= PreferencesMessages.CodeTemplateBlock_export_error_title;
- String message= Messages.format(PreferencesMessages.CodeTemplateBlock_export_error_canNotWrite, file.getAbsolutePath());
+ String title = PreferencesMessages.CodeTemplateBlock_export_error_title;
+ String message = Messages.format(PreferencesMessages.CodeTemplateBlock_export_error_canNotWrite,
+ file.getAbsolutePath());
MessageDialog.openError(getShell(), title, message);
return;
}
if (!file.exists() || confirmOverwrite(file)) {
- OutputStream output= null;
+ OutputStream output = null;
try {
- output= new BufferedOutputStream(new FileOutputStream(file));
- TemplateReaderWriter writer= new TemplateReaderWriter();
+ output = new BufferedOutputStream(new FileOutputStream(file));
+ TemplateReaderWriter writer = new TemplateReaderWriter();
writer.save(templates, output);
output.close();
} catch (IOException e) {
@@ -778,7 +785,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
try {
output.close();
} catch (IOException e2) {
- // ignore
+ // ignore
}
}
openWriteErrorDialog();
@@ -787,28 +794,27 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
private boolean confirmOverwrite(File file) {
- return MessageDialog.openQuestion(getShell(),
- PreferencesMessages.CodeTemplateBlock_export_exists_title,
- Messages.format(PreferencesMessages.CodeTemplateBlock_export_exists_message, file.getAbsolutePath()));
+ return MessageDialog.openQuestion(getShell(), PreferencesMessages.CodeTemplateBlock_export_exists_title,
+ Messages.format(PreferencesMessages.CodeTemplateBlock_export_exists_message, file.getAbsolutePath()));
}
@Override
public void performDefaults() {
super.performDefaults();
fTemplateStore.restoreDefaults();
-
+
// refresh
fCodeTemplateTree.refresh();
updateSourceViewerInput(fCodeTemplateTree.getSelectedElements());
}
-
+
public boolean performOk(boolean enabled) {
- boolean res= super.performOk();
+ boolean res = super.performOk();
if (!res)
return false;
-
+
if (fProject != null) {
- TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData();
+ TemplatePersistenceData[] templateData = fTemplateStore.getTemplateData();
for (TemplatePersistenceData element : templateData) {
fTemplateStore.setProjectSpecific(element.getId(), enabled);
}
@@ -821,7 +827,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
return true;
}
-
+
public void performCancel() {
try {
fTemplateStore.revertChanges();
@@ -829,21 +835,21 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
openReadErrorDialog(e);
}
}
-
+
private void openReadErrorDialog(Exception e) {
- String title= PreferencesMessages.CodeTemplateBlock_error_read_title;
-
- String message= e.getLocalizedMessage();
+ String title = PreferencesMessages.CodeTemplateBlock_error_read_title;
+
+ String message = e.getLocalizedMessage();
if (message != null)
- message= Messages.format(PreferencesMessages.CodeTemplateBlock_error_parse_message, message);
+ message = Messages.format(PreferencesMessages.CodeTemplateBlock_error_parse_message, message);
else
- message= PreferencesMessages.CodeTemplateBlock_error_read_message;
+ message = PreferencesMessages.CodeTemplateBlock_error_read_message;
MessageDialog.openError(getShell(), title, message);
}
-
+
private void openWriteErrorDialog() {
- String title= PreferencesMessages.CodeTemplateBlock_error_write_title;
- String message= PreferencesMessages.CodeTemplateBlock_error_write_message;
+ String title = PreferencesMessages.CodeTemplateBlock_error_write_title;
+ String message = PreferencesMessages.CodeTemplateBlock_error_write_message;
MessageDialog.openError(getShell(), title, message);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java
index 3f1c133b171..3b4b8c75478 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -33,17 +33,17 @@ import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
* The page to configure the code templates.
*/
public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
- public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.CodeTemplatePreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.CodeTemplatePreferencePage"; //$NON-NLS-1$
-
- public static final String DATA_SELECT_TEMPLATE= "CodeTemplatePreferencePage.select_template"; //$NON-NLS-1$
-
+ public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.CodeTemplatePreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.CodeTemplatePreferencePage"; //$NON-NLS-1$
+
+ public static final String DATA_SELECT_TEMPLATE = "CodeTemplatePreferencePage.select_template"; //$NON-NLS-1$
+
private CodeTemplateBlock fCodeTemplateConfigurationBlock;
public CodeTemplatePreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
// Only used when page is shown programmatically
- setTitle(PreferencesMessages.CodeTemplatesPreferencePage_title);
+ setTitle(PreferencesMessages.CodeTemplatesPreferencePage_title);
}
/*
@@ -51,14 +51,13 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
*/
@Override
public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fCodeTemplateConfigurationBlock= new CodeTemplateBlock(getNewStatusChangedListener(),
- getProject(), container);
-
+ IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
+ fCodeTemplateConfigurationBlock = new CodeTemplateBlock(getNewStatusChangedListener(), getProject(), container);
+
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
ICHelpContextIds.CODE_TEMPLATES_PREFERENCE_PAGE);
- }
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
@@ -67,7 +66,7 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
protected Control createPreferenceContent(Composite composite) {
return fCodeTemplateConfigurationBlock.createContents(composite);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
*/
@@ -78,7 +77,7 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
fCodeTemplateConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
}
}
-
+
/*
* @see IPreferencePage#performOk()
*/
@@ -89,7 +88,7 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
}
return true;
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
@@ -100,7 +99,7 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
fCodeTemplateConfigurationBlock.performDefaults();
}
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.DialogPage#dispose()
*/
@@ -111,13 +110,13 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
}
super.dispose();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
*/
public void statusChanged(IStatus status) {
setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
+ StatusUtil.applyToStatusLine(this, status);
}
/* (non-Javadoc)
@@ -146,7 +145,7 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
protected String getPreferencePageId() {
return PREF_ID;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
*/
@@ -154,7 +153,7 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
protected String getPropertyPageId() {
return null;
// TODO project specific settings
-// return PROP_ID;
+ // return PROP_ID;
}
/*
@@ -163,10 +162,10 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
@Override
public void applyData(Object data) {
if (data instanceof Map<?, ?>) {
- Object id= ((Map<?, ?>) data).get(DATA_SELECT_TEMPLATE);
+ Object id = ((Map<?, ?>) data).get(DATA_SELECT_TEMPLATE);
if (id instanceof String) {
- final TemplatePersistenceData[] templates=
- fCodeTemplateConfigurationBlock.fTemplateStore.getTemplateData();
+ final TemplatePersistenceData[] templates = fCodeTemplateConfigurationBlock.fTemplateStore
+ .getTemplateData();
for (TemplatePersistenceData template : templates) {
if (id.equals(template.getId()) || id.equals(template.getTemplate().getName())) {
fCodeTemplateConfigurationBlock.postSetSelection(template);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java
index 65faa125b27..dbfd2355ef5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -45,7 +45,6 @@ import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
import org.eclipse.cdt.internal.ui.text.template.TemplateVariableProcessor;
-
public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerConfiguration {
private static class TemplateVariableTextHover implements ITextHover {
@@ -56,7 +55,7 @@ public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerCo
* @param processor the template variable processor
*/
public TemplateVariableTextHover(TemplateVariableProcessor processor) {
- fProcessor= processor;
+ fProcessor = processor;
}
/* (non-Javadoc)
@@ -65,21 +64,21 @@ public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerCo
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion subject) {
try {
- IDocument doc= textViewer.getDocument();
- int offset= subject.getOffset();
- if (offset >= 2 && "${".equals(doc.get(offset-2, 2))) { //$NON-NLS-1$
- String varName= doc.get(offset, subject.getLength());
- TemplateContextType contextType= fProcessor.getContextType();
+ IDocument doc = textViewer.getDocument();
+ int offset = subject.getOffset();
+ if (offset >= 2 && "${".equals(doc.get(offset - 2, 2))) { //$NON-NLS-1$
+ String varName = doc.get(offset, subject.getLength());
+ TemplateContextType contextType = fProcessor.getContextType();
if (contextType != null) {
- Iterator<?> iter= contextType.resolvers();
+ Iterator<?> iter = contextType.resolvers();
while (iter.hasNext()) {
- TemplateVariableResolver var= (TemplateVariableResolver) iter.next();
+ TemplateVariableResolver var = (TemplateVariableResolver) iter.next();
if (varName.equals(var.getType())) {
return var.getDescription();
}
}
}
- }
+ }
} catch (BadLocationException e) {
}
return null;
@@ -93,30 +92,30 @@ public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerCo
if (textViewer != null) {
return CWordFinder.findWord(textViewer.getDocument(), offset);
}
- return null;
+ return null;
}
-
- }
-
+
+ }
+
private final TemplateVariableProcessor fProcessor;
- public CodeTemplateSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore store, ITextEditor editor, TemplateVariableProcessor processor) {
+ public CodeTemplateSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore store, ITextEditor editor,
+ TemplateVariableProcessor processor) {
super(colorManager, store, editor, ICPartitions.C_PARTITIONING, false);
- fProcessor= processor;
+ fProcessor = processor;
}
-
+
/*
* @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
*/
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
-
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- ContentAssistant assistant= new ContentAssistant();
+ ContentAssistant assistant = new ContentAssistant();
assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
- // Register the same processor for strings and single line comments to get code completion at the start of those partitions.
+ // Register the same processor for strings and single line comments to get code completion at the start of those partitions.
assistant.setContentAssistProcessor(fProcessor, ICPartitions.C_STRING);
assistant.setContentAssistProcessor(fProcessor, ICPartitions.C_CHARACTER);
assistant.setContentAssistProcessor(fProcessor, ICPartitions.C_SINGLE_LINE_COMMENT);
@@ -135,7 +134,7 @@ public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerCo
});
return assistant;
- }
+ }
/*
* @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
@@ -149,7 +148,7 @@ public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerCo
* @see org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
*/
@Override
- public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceViewer) {
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
if (fProcessor.getContextType() instanceof CodeTemplateContextType) {
return super.getPresentationReconciler(sourceViewer);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ConfigurationBlockPropertyAndPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ConfigurationBlockPropertyAndPreferencePage.java
index b1f0c70669b..2182d9aee5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ConfigurationBlockPropertyAndPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ConfigurationBlockPropertyAndPreferencePage.java
@@ -35,8 +35,8 @@ public abstract class ConfigurationBlockPropertyAndPreferencePage extends Proper
@Override
public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- fConfigurationBlock= createConfigurationBlock(container);
+ IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
+ fConfigurationBlock = createConfigurationBlock(container);
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java
index 82572ab54b3..4bae9c40a0e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java
@@ -102,25 +102,25 @@ import org.eclipse.cdt.internal.ui.text.template.TemplateVariableProcessor;
public class EditTemplateDialog extends StatusDialog {
private static class TextViewerAction extends Action implements IUpdate {
- private int fOperationCode= -1;
+ private int fOperationCode = -1;
private final ITextOperationTarget fOperationTarget;
-
+
/**
* Creates a new action.
- *
+ *
* @param viewer the viewer
* @param operationCode the opcode
*/
public TextViewerAction(ITextViewer viewer, int operationCode) {
- fOperationCode= operationCode;
- fOperationTarget= viewer.getTextOperationTarget();
+ fOperationCode = operationCode;
+ fOperationTarget = viewer.getTextOperationTarget();
update();
}
-
+
/**
* Updates the enabled state of the action.
* Fires a property change if the enabled state changes.
- *
+ *
* @see Action#firePropertyChange(String, Object, Object)
*/
@Override
@@ -129,15 +129,16 @@ public class EditTemplateDialog extends StatusDialog {
if (fOperationCode == ITextOperationTarget.REDO)
return;
- boolean wasEnabled= isEnabled();
- boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
+ boolean wasEnabled = isEnabled();
+ boolean isEnabled = (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
setEnabled(isEnabled);
-
+
if (wasEnabled != isEnabled) {
- firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE);
+ firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE,
+ isEnabled ? Boolean.TRUE : Boolean.FALSE);
}
}
-
+
/**
* @see Action#run()
*/
@@ -150,7 +151,7 @@ public class EditTemplateDialog extends StatusDialog {
}
private Template fTemplate;
-
+
private Text fNameText;
private Text fDescriptionText;
private Combo fContextCombo;
@@ -161,18 +162,18 @@ public class EditTemplateDialog extends StatusDialog {
private boolean fIsContextTypeModifiable;
private StatusInfo fValidationStatus;
- private boolean fSuppressError= true; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=4354
- private final Map<String, TextViewerAction> fGlobalActions= new HashMap<String, TextViewerAction>(10);
+ private boolean fSuppressError = true; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=4354
+ private final Map<String, TextViewerAction> fGlobalActions = new HashMap<String, TextViewerAction>(10);
private final List<String> fSelectionActions = new ArrayList<String>(3);
private String[][] fContextTypes;
-
+
private ContextTypeRegistry fContextTypeRegistry;
-
- private final TemplateVariableProcessor fTemplateProcessor= new TemplateVariableProcessor();
+
+ private final TemplateVariableProcessor fTemplateProcessor = new TemplateVariableProcessor();
/**
* Creates a new dialog.
- *
+ *
* @param parent the shell parent of the dialog
* @param template the template to edit
* @param edit whether this is a new template or an existing being edited
@@ -180,41 +181,42 @@ public class EditTemplateDialog extends StatusDialog {
* @param isContextTypeModifiable whether the context type of the template may be modified
* @param registry the context type registry to use
*/
- public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, boolean isContextTypeModifiable, ContextTypeRegistry registry) {
+ public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable,
+ boolean isContextTypeModifiable, ContextTypeRegistry registry) {
super(parent);
-
- String title= edit
- ? PreferencesMessages.EditTemplateDialog_title_edit
- : PreferencesMessages.EditTemplateDialog_title_new;
+
+ String title = edit ? PreferencesMessages.EditTemplateDialog_title_edit
+ : PreferencesMessages.EditTemplateDialog_title_new;
setTitle(title);
- fTemplate= template;
- fIsNameModifiable= isNameModifiable;
- fIsContextTypeModifiable= isContextTypeModifiable;
-
-// String delim= new Document().getLegalLineDelimiters()[0];
-
- List<String[]> contexts= new ArrayList<String[]>();
- for (Iterator<?> it= registry.contextTypes(); it.hasNext();) {
- TemplateContextType type= (TemplateContextType) it.next();
+ fTemplate = template;
+ fIsNameModifiable = isNameModifiable;
+ fIsContextTypeModifiable = isContextTypeModifiable;
+
+ // String delim= new Document().getLegalLineDelimiters()[0];
+
+ List<String[]> contexts = new ArrayList<String[]>();
+ for (Iterator<?> it = registry.contextTypes(); it.hasNext();) {
+ TemplateContextType type = (TemplateContextType) it.next();
// TODO cppdoc? doxygen?
-// if (type.getId().equals("javadoc")) //$NON-NLS-1$
-// contexts.add(new String[] { type.getId(), type.getName(), "/**" + delim }); //$NON-NLS-1$
-// else
- contexts.add(0, new String[] { type.getId(), type.getName(), "" }); //$NON-NLS-1$
+ // if (type.getId().equals("javadoc")) //$NON-NLS-1$
+ // contexts.add(new String[] { type.getId(), type.getName(), "/**" + delim }); //$NON-NLS-1$
+ // else
+ contexts.add(0, new String[] { type.getId(), type.getName(), "" }); //$NON-NLS-1$
}
Collections.sort(contexts, new Comparator<String[]>() {
@Override
public int compare(String[] s1, String[] s2) {
return s1[1].compareTo(s2[1]);
- }});
- fContextTypes= contexts.toArray(new String[contexts.size()][]);
-
- fValidationStatus= new StatusInfo();
-
- fContextTypeRegistry= registry;
-
- TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
+ }
+ });
+ fContextTypes = contexts.toArray(new String[contexts.size()][]);
+
+ fValidationStatus = new StatusInfo();
+
+ fContextTypeRegistry = registry;
+
+ TemplateContextType type = fContextTypeRegistry.getContextType(template.getContextTypeId());
fTemplateProcessor.setContextType(type);
}
@@ -222,93 +224,93 @@ public class EditTemplateDialog extends StatusDialog {
protected boolean isResizable() {
return true;
}
-
+
@Override
public void create() {
super.create();
updateStatusAndButtons();
getButton(IDialogConstants.OK_ID).setEnabled(getStatus().isOK());
}
-
+
@Override
protected Control createDialogArea(Composite ancestor) {
- Composite parent= new Composite(ancestor, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
+ Composite parent = new Composite(ancestor, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
parent.setLayout(layout);
parent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ModifyListener listener= new ModifyListener() {
+
+ ModifyListener listener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
doTextWidgetChanged(e.widget);
}
};
-
+
if (fIsNameModifiable) {
createLabel(parent, PreferencesMessages.EditTemplateDialog_name);
-
- Composite composite= new Composite(parent, SWT.NONE);
+
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- layout= new GridLayout();
- layout.numColumns= fIsContextTypeModifiable ? 3 : 1;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+ layout = new GridLayout();
+ layout.numColumns = fIsContextTypeModifiable ? 3 : 1;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
composite.setLayout(layout);
-
- fNameText= createText(composite);
+
+ fNameText = createText(composite);
fNameText.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
-
+
@Override
public void focusLost(FocusEvent e) {
if (fSuppressError) {
- fSuppressError= false;
+ fSuppressError = false;
updateStatusAndButtons();
}
}
});
-
+
if (fIsContextTypeModifiable) {
createLabel(composite, PreferencesMessages.EditTemplateDialog_contextType);
- fContextCombo= new Combo(composite, SWT.READ_ONLY);
+ fContextCombo = new Combo(composite, SWT.READ_ONLY);
fContextCombo.setVisibleItemCount(10);
for (String[] contextType : fContextTypes) {
fContextCombo.add(contextType[1]);
}
-
+
fContextCombo.addModifyListener(listener);
-
-// fAutoInsertCheckbox= createCheckbox(composite, PreferencesMessages.EditTemplateDialog_autoinsert);
-// fAutoInsertCheckbox.setSelection(fTemplate.isAutoInsertable());
+
+ // fAutoInsertCheckbox= createCheckbox(composite, PreferencesMessages.EditTemplateDialog_autoinsert);
+ // fAutoInsertCheckbox.setSelection(fTemplate.isAutoInsertable());
}
}
-
+
createLabel(parent, PreferencesMessages.EditTemplateDialog_description);
-
- int descFlags= fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
- fDescriptionText= new Text(parent, descFlags );
+
+ int descFlags = fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
+ fDescriptionText = new Text(parent, descFlags);
fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
fDescriptionText.addModifyListener(listener);
- Label patternLabel= createLabel(parent, PreferencesMessages.EditTemplateDialog_pattern);
+ Label patternLabel = createLabel(parent, PreferencesMessages.EditTemplateDialog_pattern);
patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- fPatternEditor= createEditor(parent);
-
- Label filler= new Label(parent, SWT.NONE);
+ fPatternEditor = createEditor(parent);
+
+ Label filler = new Label(parent, SWT.NONE);
filler.setLayoutData(new GridData());
-
- Composite composite= new Composite(parent, SWT.NONE);
- layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData());
-
- fInsertVariableButton= new Button(composite, SWT.NONE);
+
+ fInsertVariableButton = new Button(composite, SWT.NONE);
fInsertVariableButton.setLayoutData(getButtonGridData());
fInsertVariableButton.setText(PreferencesMessages.EditTemplateDialog_insert_variable);
fInsertVariableButton.addSelectionListener(new SelectionListener() {
@@ -319,7 +321,8 @@ public class EditTemplateDialog extends StatusDialog {
}
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
});
fDescriptionText.setText(fTemplate.getDescription());
@@ -337,17 +340,17 @@ public class EditTemplateDialog extends StatusDialog {
applyDialogFont(parent);
return composite;
}
-
+
protected void doTextWidgetChanged(Widget w) {
if (w == fNameText) {
- fSuppressError= false;
+ fSuppressError = false;
updateStatusAndButtons();
} else if (w == fContextCombo) {
- String contextId= getContextId();
+ String contextId = getContextId();
fTemplateProcessor.setContextType(fContextTypeRegistry.getContextType(contextId));
reconfigurePatternEditor();
- IDocument document= fPatternEditor.getDocument();
- String prefix= getPrefix();
+ IDocument document = fPatternEditor.getDocument();
+ String prefix = getPrefix();
document.set(prefix + getPattern());
fPatternEditor.setVisibleRegion(prefix.length(), document.getLength() - prefix.length());
updateStatusAndButtons();
@@ -355,24 +358,24 @@ public class EditTemplateDialog extends StatusDialog {
// nothing
}
}
-
+
private String getContextId() {
if (fContextCombo != null && !fContextCombo.isDisposed()) {
- String name= fContextCombo.getText();
+ String name = fContextCombo.getText();
for (String[] contextType : fContextTypes) {
if (name.equals(contextType[1])) {
return contextType[0];
}
}
}
-
+
return fTemplate.getContextTypeId();
}
protected void doSourceChanged(IDocument document) {
- String text= document.get();
+ String text = document.get();
fValidationStatus.setOK();
- TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId());
+ TemplateContextType contextType = fContextTypeRegistry.getContextType(getContextId());
if (contextType != null) {
try {
contextType.validate(text);
@@ -386,67 +389,69 @@ public class EditTemplateDialog extends StatusDialog {
}
private static GridData getButtonGridData() {
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
return data;
}
private static Label createLabel(Composite parent, String name) {
- Label label= new Label(parent, SWT.NULL);
+ Label label = new Label(parent, SWT.NULL);
label.setText(name);
label.setLayoutData(new GridData());
return label;
}
-// private static Button createCheckbox(Composite parent, String name) {
-// Button button= new Button(parent, SWT.CHECK);
-// button.setText(name);
-// button.setLayoutData(new GridData());
-//
-// return button;
-// }
-
+ // private static Button createCheckbox(Composite parent, String name) {
+ // Button button= new Button(parent, SWT.CHECK);
+ // button.setText(name);
+ // button.setLayoutData(new GridData());
+ //
+ // return button;
+ // }
+
private Text createText(Composite parent) {
- Text text= new Text(parent, SWT.BORDER);
- final GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(20);
+ Text text = new Text(parent, SWT.BORDER);
+ final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = convertWidthInCharsToPixels(20);
text.setLayoutData(gd);
return text;
}
private SourceViewer createEditor(Composite parent) {
- String prefix= getPrefix();
- IDocument document= new Document(prefix + fTemplate.getPattern());
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
+ String prefix = getPrefix();
+ IDocument document = new Document(prefix + fTemplate.getPattern());
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
tools.setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- SourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
- CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ SourceViewer viewer = new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
+ store);
+ CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration(
+ tools.getColorManager(), store, null, fTemplateProcessor);
viewer.configure(configuration);
viewer.setEditable(true);
viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length());
-
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+
+ Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new CSourcePreviewerUpdater(viewer, configuration, store);
-
- int nLines= document.getNumberOfLines();
+
+ int nLines = document.getNumberOfLines();
if (nLines < 5) {
- nLines= 5;
+ nLines = 5;
} else if (nLines > 12) {
- nLines= 12;
+ nLines = 12;
}
- Control control= viewer.getControl();
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= convertWidthInCharsToPixels(80);
- data.heightHint= convertHeightInCharsToPixels(nLines);
+ Control control = viewer.getControl();
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = convertWidthInCharsToPixels(80);
+ data.heightHint = convertHeightInCharsToPixels(nLines);
control.setLayoutData(data);
-
+
viewer.addTextListener(new ITextListener() {
@Override
public void textChanged(TextEvent event) {
- if (event .getDocumentEvent() != null)
+ if (event.getDocumentEvent() != null)
doSourceChanged(event.getDocumentEvent().getDocument());
}
});
@@ -464,71 +469,75 @@ public class EditTemplateDialog extends StatusDialog {
private void reconfigurePatternEditor() {
if (fPatternEditor == null)
return;
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration(
+ tools.getColorManager(), store, null, fTemplateProcessor);
fPatternEditor.unconfigure();
fPatternEditor.configure(configuration);
fPatternEditor.invalidateTextPresentation();
}
-
+
private String getPrefix() {
- String id= getContextId();
- int idx= getIndex(id);
+ String id = getContextId();
+ int idx = getIndex(id);
if (idx != -1)
return fContextTypes[idx][2];
return ""; //$NON-NLS-1$
}
private void initializeActions() {
- final ArrayList<IHandlerActivation> handlerActivations= new ArrayList<IHandlerActivation>(3);
- final IHandlerService handlerService= PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
+ final ArrayList<IHandlerActivation> handlerActivations = new ArrayList<IHandlerActivation>(3);
+ final IHandlerService handlerService = PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
getShell().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
handlerService.deactivateHandlers(handlerActivations);
}
});
-
- Expression expression= new ActiveShellExpression(fPatternEditor.getControl().getShell());
- TextViewerAction action= new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO);
+ Expression expression = new ActiveShellExpression(fPatternEditor.getControl().getShell());
+
+ TextViewerAction action = new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO);
action.setText(PreferencesMessages.EditTemplateDialog_undo);
fGlobalActions.put(ITextEditorActionConstants.UNDO, action);
- handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_UNDO, new ActionHandler(action), expression));
+ handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_UNDO,
+ new ActionHandler(action), expression));
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.REDO);
+ action = new TextViewerAction(fPatternEditor, ITextOperationTarget.REDO);
action.setText(PreferencesMessages.EditTemplateDialog_redo);
fGlobalActions.put(ITextEditorActionConstants.REDO, action);
- handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_REDO, new ActionHandler(action), expression));
+ handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_REDO,
+ new ActionHandler(action), expression));
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.CUT);
+ action = new TextViewerAction(fPatternEditor, ITextOperationTarget.CUT);
action.setText(PreferencesMessages.EditTemplateDialog_cut);
fGlobalActions.put(ITextEditorActionConstants.CUT, action);
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.COPY);
+ action = new TextViewerAction(fPatternEditor, ITextOperationTarget.COPY);
action.setText(PreferencesMessages.EditTemplateDialog_copy);
fGlobalActions.put(ITextEditorActionConstants.COPY, action);
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.PASTE);
+ action = new TextViewerAction(fPatternEditor, ITextOperationTarget.PASTE);
action.setText(PreferencesMessages.EditTemplateDialog_paste);
fGlobalActions.put(ITextEditorActionConstants.PASTE, action);
- action= new TextViewerAction(fPatternEditor, ITextOperationTarget.SELECT_ALL);
+ action = new TextViewerAction(fPatternEditor, ITextOperationTarget.SELECT_ALL);
action.setText(PreferencesMessages.EditTemplateDialog_select_all);
fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action);
- action= new TextViewerAction(fPatternEditor, ISourceViewer.CONTENTASSIST_PROPOSALS);
+ action = new TextViewerAction(fPatternEditor, ISourceViewer.CONTENTASSIST_PROPOSALS);
action.setText(PreferencesMessages.EditTemplateDialog_content_assist);
fGlobalActions.put("ContentAssistProposal", action); //$NON-NLS-1$
- handlerActivations.add(handlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new ActionHandler(action), expression));
+ handlerActivations.add(handlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS,
+ new ActionHandler(action), expression));
fSelectionActions.add(ITextEditorActionConstants.CUT);
fSelectionActions.add(ITextEditorActionConstants.COPY);
fSelectionActions.add(ITextEditorActionConstants.PASTE);
-
+
// create context menu
- MenuManager manager= new MenuManager(null, null);
+ MenuManager manager = new MenuManager(null, null);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
@Override
@@ -537,8 +546,8 @@ public class EditTemplateDialog extends StatusDialog {
}
});
- StyledText text= fPatternEditor.getTextWidget();
- Menu menu= manager.createContextMenu(text);
+ StyledText text = fPatternEditor.getTextWidget();
+ Menu menu = manager.createContextMenu(text);
text.setMenu(menu);
}
@@ -546,25 +555,26 @@ public class EditTemplateDialog extends StatusDialog {
menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO));
menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, fGlobalActions.get(ITextEditorActionConstants.UNDO));
menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, fGlobalActions.get(ITextEditorActionConstants.REDO));
-
+
menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.CUT));
menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.COPY));
menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.PASTE));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL));
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT,
+ fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL));
menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
menu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$
}
protected void updateSelectionDependentActions() {
- Iterator<String> iterator= fSelectionActions.iterator();
+ Iterator<String> iterator = fSelectionActions.iterator();
while (iterator.hasNext())
updateAction(iterator.next());
}
protected void updateAction(String actionId) {
- IAction action= fGlobalActions.get(actionId);
+ IAction action = fGlobalActions.get(actionId);
if (action instanceof IUpdate)
((IUpdate) action).update();
}
@@ -572,31 +582,31 @@ public class EditTemplateDialog extends StatusDialog {
private int getIndex(String contextid) {
if (contextid == null)
return -1;
-
- for (int i= 0; i < fContextTypes.length; i++) {
+
+ for (int i = 0; i < fContextTypes.length; i++) {
if (contextid.equals(fContextTypes[i][0])) {
return i;
}
}
return -1;
}
-
+
@Override
protected void okPressed() {
- String name= fNameText == null ? fTemplate.getName() : fNameText.getText();
- boolean isAutoInsertable= fAutoInsertCheckbox != null && fAutoInsertCheckbox.getSelection();
- fTemplate= new Template(name, fDescriptionText.getText(), getContextId(), getPattern(), isAutoInsertable);
+ String name = fNameText == null ? fTemplate.getName() : fNameText.getText();
+ boolean isAutoInsertable = fAutoInsertCheckbox != null && fAutoInsertCheckbox.getSelection();
+ fTemplate = new Template(name, fDescriptionText.getText(), getContextId(), getPattern(), isAutoInsertable);
super.okPressed();
}
-
+
private void updateStatusAndButtons() {
- StatusInfo status= fValidationStatus;
- boolean isEmpty= fNameText != null && fNameText.getText().length() == 0;
+ StatusInfo status = fValidationStatus;
+ boolean isEmpty = fNameText != null && fNameText.getText().length() == 0;
if (!fSuppressError && isEmpty) {
- status= new StatusInfo();
+ status = new StatusInfo();
status.setError(PreferencesMessages.EditTemplateDialog_error_noname);
} else if (fNameText != null && !isValidTemplateName(fNameText.getText())) {
- status= new StatusInfo();
+ status = new StatusInfo();
status.setError(PreferencesMessages.EditTemplateDialog_error_invalidName);
}
updateStatus(status);
@@ -605,7 +615,7 @@ public class EditTemplateDialog extends StatusDialog {
/**
* Checks whether the given string is a valid
* template name.
- *
+ *
* @param name the string to test
* @return <code>true</code> if the name is valid
*/
@@ -624,40 +634,40 @@ public class EditTemplateDialog extends StatusDialog {
/**
* Returns the created template.
- *
+ *
* @return the created template
*/
public Template getTemplate() {
return fTemplate;
}
-
+
private String getPattern() {
- IDocument doc= fPatternEditor.getDocument();
- IRegion visible= fPatternEditor.getVisibleRegion();
+ IDocument doc = fPatternEditor.getDocument();
+ IRegion visible = fPatternEditor.getVisibleRegion();
try {
return doc.get(visible.getOffset(), doc.getLength() - visible.getOffset());
} catch (BadLocationException e) {
return ""; //$NON-NLS-1$
}
}
-
+
@Override
protected Point getInitialSize() {
- Point defaultSize= getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- Point restoredSize= super.getInitialSize();
+ Point defaultSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ Point restoredSize = super.getInitialSize();
if (defaultSize.x > restoredSize.x) {
- restoredSize.x= defaultSize.x;
+ restoredSize.x = defaultSize.x;
}
return restoredSize;
}
@Override
protected IDialogSettings getDialogBoundsSettings() {
- String sectionName= getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
- IDialogSettings section= settings.getSection(sectionName);
+ String sectionName = getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(sectionName);
if (section == null)
- section= settings.addNewSection(sectionName);
+ section = settings.addNewSection(sectionName);
return section;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java
index b1ac0ab1c84..e451dd85b8d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java
@@ -54,26 +54,26 @@ import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistr
/**
* Configures C Editor folding preferences.
- *
+ *
* @since 3.0
*/
class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
-
+
private static class ErrorPreferences implements ICFoldingPreferenceBlock {
private final String fMessage;
-
+
protected ErrorPreferences(String message) {
- fMessage= message;
+ fMessage = message;
}
-
+
@Override
public Control createControl(Composite composite) {
- Composite inner= new Composite(composite, SWT.NONE);
+ Composite inner = new Composite(composite, SWT.NONE);
inner.setLayout(new FillLayout(SWT.VERTICAL));
- Label label= new Label(inner, SWT.CENTER);
+ Label label = new Label(inner, SWT.CENTER);
label.setText(fMessage);
-
+
return inner;
}
@@ -96,7 +96,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
/** The overlay preference store. */
protected final OverlayPreferenceStore fStore;
-
+
/* The controls */
private Combo fProviderCombo;
protected Button fFoldingCheckbox;
@@ -106,36 +106,37 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
private final Map<String, ICFoldingPreferenceBlock> fProviderPreferences;
private final Map<String, Control> fProviderControls;
private StackLayout fStackLayout;
-
public FoldingConfigurationBlock(OverlayPreferenceStore store) {
Assert.isNotNull(store);
- fStore= store;
+ fStore = store;
fStore.addKeys(createOverlayStoreKeys());
- fProviderDescriptors= createListModel();
- fProviderPreferences= new HashMap<String, ICFoldingPreferenceBlock>();
- fProviderControls= new HashMap<String, Control>();
+ fProviderDescriptors = createListModel();
+ fProviderPreferences = new HashMap<String, ICFoldingPreferenceBlock>();
+ fProviderControls = new HashMap<String, Control>();
}
private Map<String, CFoldingStructureProviderDescriptor> createListModel() {
- CFoldingStructureProviderRegistry reg= CUIPlugin.getDefault().getFoldingStructureProviderRegistry();
+ CFoldingStructureProviderRegistry reg = CUIPlugin.getDefault().getFoldingStructureProviderRegistry();
reg.reloadExtensions();
- CFoldingStructureProviderDescriptor[] descs= reg.getFoldingProviderDescriptors();
- Map<String, CFoldingStructureProviderDescriptor> map= new HashMap<String, CFoldingStructureProviderDescriptor>();
- for (int i= 0; i < descs.length; i++) {
+ CFoldingStructureProviderDescriptor[] descs = reg.getFoldingProviderDescriptors();
+ Map<String, CFoldingStructureProviderDescriptor> map = new HashMap<String, CFoldingStructureProviderDescriptor>();
+ for (int i = 0; i < descs.length; i++) {
map.put(descs[i].getId(), descs[i]);
}
return map;
}
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_ENABLED));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOLDING_PROVIDER));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+ ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
+
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_ENABLED));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+ PreferenceConstants.EDITOR_FOLDING_PROVIDER));
+
+ OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
}
@@ -143,26 +144,25 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public Control createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NULL);
+ Composite composite = new Composite(parent, SWT.NULL);
// assume parent page uses griddata
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL);
composite.setLayoutData(gd);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- PixelConverter pc= new PixelConverter(composite);
- layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ PixelConverter pc = new PixelConverter(composite);
+ layout.verticalSpacing = pc.convertHeightInCharsToPixels(1) / 2;
composite.setLayout(layout);
-
-
+
/* check box for new editors */
- fFoldingCheckbox= new Button(composite, SWT.CHECK);
- fFoldingCheckbox.setText(PreferencesMessages.FoldingConfigurationBlock_enable);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+ fFoldingCheckbox = new Button(composite, SWT.CHECK);
+ fFoldingCheckbox.setText(PreferencesMessages.FoldingConfigurationBlock_enable);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
fFoldingCheckbox.setLayoutData(gd);
fFoldingCheckbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- boolean enabled= fFoldingCheckbox.getSelection();
+ boolean enabled = fFoldingCheckbox.getSelection();
fStore.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, enabled);
updateCheckboxDependencies();
}
@@ -171,33 +171,33 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
public void widgetDefaultSelected(SelectionEvent e) {
}
});
-
- Label label= new Label(composite, SWT.CENTER);
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+
+ Label label = new Label(composite, SWT.CENTER);
+ gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
label.setLayoutData(gd);
/* list */
- Composite comboComp= new Composite(composite, SWT.NONE);
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- GridLayout gridLayout= new GridLayout(2, false);
- gridLayout.marginWidth= 0;
+ Composite comboComp = new Composite(composite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ GridLayout gridLayout = new GridLayout(2, false);
+ gridLayout.marginWidth = 0;
comboComp.setLayout(gridLayout);
-
- Label comboLabel= new Label(comboComp, SWT.CENTER);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
+
+ Label comboLabel = new Label(comboComp, SWT.CENTER);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
comboLabel.setLayoutData(gd);
- comboLabel.setText(PreferencesMessages.FoldingConfigurationBlock_combo_caption);
-
- label= new Label(composite, SWT.CENTER);
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ comboLabel.setText(PreferencesMessages.FoldingConfigurationBlock_combo_caption);
+
+ label = new Label(composite, SWT.CENTER);
+ gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
label.setLayoutData(gd);
- fProviderCombo= new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
+ fProviderCombo = new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
fProviderCombo.setLayoutData(gd);
/* list viewer */
- fProviderViewer= new ComboViewer(fProviderCombo);
+ fProviderViewer = new ComboViewer(fProviderCombo);
fProviderViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void dispose() {
@@ -217,7 +217,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
public Image getImage(Object element) {
return null;
}
-
+
@Override
public String getText(Object element) {
return ((CFoldingStructureProviderDescriptor) element).getName();
@@ -226,31 +226,32 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
fProviderViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel= (IStructuredSelection) event.getSelection();
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (!sel.isEmpty()) {
- fStore.setValue(PreferenceConstants.EDITOR_FOLDING_PROVIDER, ((CFoldingStructureProviderDescriptor) sel.getFirstElement()).getId());
+ fStore.setValue(PreferenceConstants.EDITOR_FOLDING_PROVIDER,
+ ((CFoldingStructureProviderDescriptor) sel.getFirstElement()).getId());
updateListDependencies();
}
}
});
fProviderViewer.setInput(fProviderDescriptors);
fProviderViewer.refresh();
-
- Composite groupComp= new Composite(composite, SWT.NONE);
- gd= new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan= 2;
+
+ Composite groupComp = new Composite(composite, SWT.NONE);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
groupComp.setLayoutData(gd);
- gridLayout= new GridLayout(1, false);
- gridLayout.marginWidth= 0;
+ gridLayout = new GridLayout(1, false);
+ gridLayout.marginWidth = 0;
groupComp.setLayout(gridLayout);
-
+
/* contributed provider preferences. */
- fGroup= new Composite(groupComp, SWT.NONE);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+ fGroup = new Composite(groupComp, SWT.NONE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
fGroup.setLayoutData(gd);
- fStackLayout= new StackLayout();
+ fStackLayout = new StackLayout();
fGroup.setLayout(fStackLayout);
-
+
return composite;
}
@@ -258,43 +259,43 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
}
void updateListDependencies() {
- String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
- CFoldingStructureProviderDescriptor desc= fProviderDescriptors.get(id);
+ String id = fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
+ CFoldingStructureProviderDescriptor desc = fProviderDescriptors.get(id);
ICFoldingPreferenceBlock prefs;
-
+
if (desc == null) {
// safety in case there is no such descriptor
- String message= PreferencesMessages.FoldingConfigurationBlock_error_not_exist;
+ String message = PreferencesMessages.FoldingConfigurationBlock_error_not_exist;
CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null));
- prefs= new ErrorPreferences(message);
+ prefs = new ErrorPreferences(message);
} else {
- prefs= fProviderPreferences.get(id);
+ prefs = fProviderPreferences.get(id);
if (prefs == null) {
try {
- prefs= desc.createPreferences();
+ prefs = desc.createPreferences();
fProviderPreferences.put(id, prefs);
} catch (CoreException e) {
CUIPlugin.log(e);
- prefs= new ErrorPreferences(e.getLocalizedMessage());
+ prefs = new ErrorPreferences(e.getLocalizedMessage());
}
}
}
-
- Control control= fProviderControls.get(id);
+
+ Control control = fProviderControls.get(id);
if (control == null) {
- control= prefs.createControl(fGroup);
+ control = prefs.createControl(fGroup);
if (control == null) {
- String message= PreferencesMessages.FoldingConfigurationBlock_info_no_preferences;
- control= new ErrorPreferences(message).createControl(fGroup);
+ String message = PreferencesMessages.FoldingConfigurationBlock_info_no_preferences;
+ control = new ErrorPreferences(message).createControl(fGroup);
} else {
fProviderControls.put(id, control);
}
}
- fStackLayout.topControl= control;
+ fStackLayout.topControl = control;
control.pack();
fGroup.layout();
fGroup.getParent().layout();
-
+
prefs.initialize();
}
@@ -309,7 +310,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
prefs.performOk();
}
}
-
+
@Override
public void performDefaults() {
restoreFromPreferences();
@@ -317,7 +318,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
prefs.performDefaults();
}
}
-
+
@Override
public void dispose() {
for (ICFoldingPreferenceBlock prefs : fProviderPreferences.values()) {
@@ -326,12 +327,12 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
}
private void restoreFromPreferences() {
- boolean enabled= fStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
+ boolean enabled = fStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
fFoldingCheckbox.setSelection(enabled);
updateCheckboxDependencies();
-
- String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
- Object provider= fProviderDescriptors.get(id);
+
+ String id = fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
+ Object provider = fProviderDescriptors.get(id);
if (provider != null) {
fProviderViewer.setSelection(new StructuredSelection(provider), true);
updateListDependencies();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java
index 7246fc3621d..522bb1ebf0f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
-
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -26,7 +25,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The page for setting the editor folding options.
*/
public final class FoldingPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
+
/*
* @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
*/
@@ -40,10 +39,10 @@ public final class FoldingPreferencePage extends AbstractConfigurationBlockPrefe
*/
@Override
protected void setDescription() {
- String description= PreferencesMessages.FoldingPreferencePage_folding_title;
+ String description = PreferencesMessages.FoldingPreferencePage_folding_title;
setDescription(description);
}
-
+
/*
* @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
*/
@@ -51,8 +50,7 @@ public final class FoldingPreferencePage extends AbstractConfigurationBlockPrefe
protected void setPreferenceStore() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
}
-
-
+
@Override
protected Label createDescriptionLabel(Composite parent) {
return null; // no description for new look.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionBlock.java
index b4d5d587cac..c8902e6af5e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionBlock.java
@@ -50,9 +50,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class HeaderSubstitutionBlock extends OptionsConfigurationBlock {
static final Key KEY_HEADER_SUBSTITUTION = getCDTUIKey(PreferenceConstants.INCLUDES_HEADER_SUBSTITUTION);
- private static Key[] ALL_KEYS = {
- KEY_HEADER_SUBSTITUTION
- };
+ private static Key[] ALL_KEYS = { KEY_HEADER_SUBSTITUTION };
private class HeaderMapLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider {
@@ -80,9 +78,8 @@ public class HeaderSubstitutionBlock extends OptionsConfigurationBlock {
if (columnIndex == 0) {
return map.getName();
}
- return map.isCppOnly() ?
- PreferencesMessages.HeaderSubstitutionBlock_cpp_only :
- PreferencesMessages.HeaderSubstitutionBlock_c_and_cpp;
+ return map.isCppOnly() ? PreferencesMessages.HeaderSubstitutionBlock_cpp_only
+ : PreferencesMessages.HeaderSubstitutionBlock_c_and_cpp;
}
@Override
@@ -105,13 +102,11 @@ public class HeaderSubstitutionBlock extends OptionsConfigurationBlock {
super(context, project, ALL_KEYS, container);
ListAdapter adapter = new ListAdapter();
- String[] buttons = new String[] {
- PreferencesMessages.HeaderSubstitutionBlock_add_button,
- PreferencesMessages.HeaderSubstitutionBlock_edit_button,
- PreferencesMessages.HeaderSubstitutionBlock_remove_button,
- PreferencesMessages.HeaderSubstitutionBlock_up_button,
- PreferencesMessages.HeaderSubstitutionBlock_down_button,
- };
+ String[] buttons = new String[] { PreferencesMessages.HeaderSubstitutionBlock_add_button,
+ PreferencesMessages.HeaderSubstitutionBlock_edit_button,
+ PreferencesMessages.HeaderSubstitutionBlock_remove_button,
+ PreferencesMessages.HeaderSubstitutionBlock_up_button,
+ PreferencesMessages.HeaderSubstitutionBlock_down_button, };
fHeaderMapsList = new ListDialogField<HeaderSubstitutionMap>(adapter, buttons, new HeaderMapLabelProvider());
fHeaderMapsList.setLabelText(PreferencesMessages.HeaderSubstitutionBlock_header_substitution_maps);
fHeaderMapsList.setDialogFieldListener(adapter);
@@ -119,15 +114,10 @@ public class HeaderSubstitutionBlock extends OptionsConfigurationBlock {
fHeaderMapsList.setUpButtonIndex(IDX_UP);
fHeaderMapsList.setDownButtonIndex(IDX_DOWN);
- String[] columnsHeaders = new String[] {
- PreferencesMessages.HeaderSubstitutionBlock_name_column_title,
- PreferencesMessages.HeaderSubstitutionBlock_languages_column_title,
- };
+ String[] columnsHeaders = new String[] { PreferencesMessages.HeaderSubstitutionBlock_name_column_title,
+ PreferencesMessages.HeaderSubstitutionBlock_languages_column_title, };
- ColumnLayoutData[] columnData = new ColumnLayoutData[] {
- new ColumnWeightData(5),
- new ColumnWeightData(2),
- };
+ ColumnLayoutData[] columnData = new ColumnLayoutData[] { new ColumnWeightData(5), new ColumnWeightData(2), };
fHeaderMapsList.setTableColumns(new ListDialogField.ColumnsDescription(columnData, columnsHeaders, true));
loadHeaderMaps();
@@ -237,8 +227,8 @@ public class HeaderSubstitutionBlock extends OptionsConfigurationBlock {
edited = field.getSelectedElements().get(0);
}
if (index == IDX_ADD || index == IDX_EDIT) {
- HeaderSubstitutionMapEditDialog dialog =
- new HeaderSubstitutionMapEditDialog(getShell(), edited, field.getElements());
+ HeaderSubstitutionMapEditDialog dialog = new HeaderSubstitutionMapEditDialog(getShell(), edited,
+ field.getElements());
if (dialog.open() == Window.OK) {
if (edited != null) {
field.replaceElement(edited, dialog.getResult());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionEditDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionEditDialog.java
index 96611316b3a..2d0d6ae5a77 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionEditDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionEditDialog.java
@@ -57,7 +57,8 @@ public class HeaderSubstitutionEditDialog extends ResizableStatusDialog {
fTargetField.setLabelText(PreferencesMessages.HeaderSubstitutionEditDialog_target);
fTargetField.setDialogFieldListener(listener);
fRequiredSubstitutionCheckBox = new SelectionButtonDialogField(SWT.CHECK);
- fRequiredSubstitutionCheckBox.setLabelText(PreferencesMessages.HeaderSubstitutionEditDialog_required_substitution);
+ fRequiredSubstitutionCheckBox
+ .setLabelText(PreferencesMessages.HeaderSubstitutionEditDialog_required_substitution);
if (rule != null) {
fSourceField.setText(rule.getSource());
@@ -99,9 +100,9 @@ public class HeaderSubstitutionEditDialog extends ResizableStatusDialog {
fTargetField.doFillIntoGrid(inner, 2);
fRequiredSubstitutionCheckBox.doFillIntoGrid(composite, 2);
- applyDialogFont(composite);
+ applyDialogFont(composite);
- validate();
+ validate();
return composite;
}
@@ -119,7 +120,8 @@ public class HeaderSubstitutionEditDialog extends ResizableStatusDialog {
} else if (!isValidHeader(target)) {
status = new StatusInfo(IStatus.WARNING, PreferencesMessages.HeaderSubstitutionEditDialog_invalid_target);
} else if (target.equals(source)) {
- status = new StatusInfo(IStatus.WARNING, PreferencesMessages.HeaderSubstitutionEditDialog_error_replacement_by_itself);
+ status = new StatusInfo(IStatus.WARNING,
+ PreferencesMessages.HeaderSubstitutionEditDialog_error_replacement_by_itself);
}
updateStatus(status);
}
@@ -133,7 +135,7 @@ public class HeaderSubstitutionEditDialog extends ResizableStatusDialog {
private boolean isValidHeader(String header) {
if (header.isEmpty())
return false;
- if (header.startsWith("<") != header.endsWith(">")) //$NON-NLS-1$//$NON-NLS-2$
+ if (header.startsWith("<") != header.endsWith(">")) //$NON-NLS-1$//$NON-NLS-2$
return false;
if (header.startsWith("<") && header.length() < 3) //$NON-NLS-1$
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java
index 03ad305d56b..30307b8b355 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java
@@ -82,8 +82,7 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
private static final String TAG_HEADER_SUBSTITUTION_MAP = "header_substitution_map"; //$NON-NLS-1$
private static final Collator COLLATOR = Collator.getInstance();
- private static final Comparator<HeaderSubstitutionRule> SOURCE_COMPARATOR =
- new Comparator<HeaderSubstitutionRule>() {
+ private static final Comparator<HeaderSubstitutionRule> SOURCE_COMPARATOR = new Comparator<HeaderSubstitutionRule>() {
@Override
public int compare(HeaderSubstitutionRule r1, HeaderSubstitutionRule r2) {
return COLLATOR.compare(r1.getSource(), r2.getSource());
@@ -127,11 +126,10 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
if (!isOkToUse(fTableControl))
return false;
- int[] indc= fTable.getTable().getSelectionIndices();
- for (int i= 0; i < indc.length; i++) {
+ int[] indc = fTable.getTable().getSelectionIndices();
+ for (int i = 0; i < indc.length; i++) {
int index = indc[i];
- if (index == 0 ||
- SOURCE_COMPARATOR.compare(fElements.get(index), fElements.get(index - 1)) != 0) {
+ if (index == 0 || SOURCE_COMPARATOR.compare(fElements.get(index), fElements.get(index - 1)) != 0) {
return false;
}
}
@@ -143,12 +141,11 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
if (!isOkToUse(fTableControl))
return false;
- int k= fElements.size() - 1;
- int[] indc= fTable.getTable().getSelectionIndices();
- for (int i= 0; i < indc.length; i++) {
+ int k = fElements.size() - 1;
+ int[] indc = fTable.getTable().getSelectionIndices();
+ for (int i = 0; i < indc.length; i++) {
int index = indc[i];
- if (index == k ||
- SOURCE_COMPARATOR.compare(fElements.get(index), fElements.get(index + 1)) != 0) {
+ if (index == k || SOURCE_COMPARATOR.compare(fElements.get(index), fElements.get(index + 1)) != 0) {
return false;
}
}
@@ -263,39 +260,33 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
fNameField.setLabelText(PreferencesMessages.HeaderSubstitutionMapEditDialog_name);
fNameField.setDialogFieldListener(adapter);
- String[] items = new String[] {
- PreferencesMessages.HeaderSubstitutionMapEditDialog_c_and_cpp,
- PreferencesMessages.HeaderSubstitutionMapEditDialog_cpp_only,
- };
+ String[] items = new String[] { PreferencesMessages.HeaderSubstitutionMapEditDialog_c_and_cpp,
+ PreferencesMessages.HeaderSubstitutionMapEditDialog_cpp_only, };
fAppliesToField = new ComboDialogField(SWT.READ_ONLY);
fAppliesToField.setLabelText(PreferencesMessages.HeaderSubstitutionMapEditDialog_applies_to);
fAppliesToField.setItems(items);
- String[] buttons = new String[] {
- PreferencesMessages.HeaderSubstitutionMapEditDialog_add_button,
+ String[] buttons = new String[] { PreferencesMessages.HeaderSubstitutionMapEditDialog_add_button,
PreferencesMessages.HeaderSubstitutionMapEditDialog_edit_button,
- PreferencesMessages.HeaderSubstitutionMapEditDialog_remove_button,
- };
+ PreferencesMessages.HeaderSubstitutionMapEditDialog_remove_button, };
fUnconditionalSubstitutionsField = new HeaderSubstitutionListField(adapter, buttons);
- fUnconditionalSubstitutionsField.setLabelText(PreferencesMessages.HeaderSubstitutionMapEditDialog_required_substitution);
+ fUnconditionalSubstitutionsField
+ .setLabelText(PreferencesMessages.HeaderSubstitutionMapEditDialog_required_substitution);
fUnconditionalSubstitutionsField.setDialogFieldListener(adapter);
- final String[] columnsHeaders = new String[] {
- PreferencesMessages.HeaderSubstitutionMapEditDialog_header,
- PreferencesMessages.HeaderSubstitutionMapEditDialog_replacement,
- };
+ final String[] columnsHeaders = new String[] { PreferencesMessages.HeaderSubstitutionMapEditDialog_header,
+ PreferencesMessages.HeaderSubstitutionMapEditDialog_replacement, };
fUnconditionalSubstitutionsField.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
- buttons = new String[] {
- PreferencesMessages.HeaderSubstitutionMapEditDialog_add_button2,
+ buttons = new String[] { PreferencesMessages.HeaderSubstitutionMapEditDialog_add_button2,
PreferencesMessages.HeaderSubstitutionMapEditDialog_edit_button2,
PreferencesMessages.HeaderSubstitutionMapEditDialog_remove_button2,
PreferencesMessages.HeaderSubstitutionMapEditDialog_up_button,
- PreferencesMessages.HeaderSubstitutionMapEditDialog_down_button,
- };
+ PreferencesMessages.HeaderSubstitutionMapEditDialog_down_button, };
fOptionalSubstitutionsField = new HeaderSubstitutionListField(adapter, buttons);
- fOptionalSubstitutionsField.setLabelText(PreferencesMessages.HeaderSubstitutionMapEditDialog_optional_substitution);
+ fOptionalSubstitutionsField
+ .setLabelText(PreferencesMessages.HeaderSubstitutionMapEditDialog_optional_substitution);
fOptionalSubstitutionsField.setDialogFieldListener(adapter);
fOptionalSubstitutionsField.enableButton(IDX_EDIT, false);
@@ -313,7 +304,8 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
fAppliesToField.selectItem(map != null && map.isCppOnly() ? 1 : 0);
if (map != null) {
- List<HeaderSubstitutionRule> substitutionRules = getSubstitutionRules(map.getUnconditionalSubstitutionMap());
+ List<HeaderSubstitutionRule> substitutionRules = getSubstitutionRules(
+ map.getUnconditionalSubstitutionMap());
fUnconditionalSubstitutionsField.setElements(substitutionRules);
substitutionRules = getSubstitutionRules(map.getOptionalSubstitutionMap());
fOptionalSubstitutionsField.setElements(substitutionRules);
@@ -321,7 +313,7 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
}
private String createUniqueName() {
- for (int i = 1; ; i++) {
+ for (int i = 1;; i++) {
String name = NLS.bind(PreferencesMessages.HeaderSubstitutionMapEditDialog_default_map_name, i);
if (!fExistingNames.contains(name))
return name;
@@ -334,8 +326,8 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
String source = stripQuotes(entry.getKey().toString());
for (IncludeInfo target : entry.getValue()) {
boolean unconditional = map.isUnconditionalSubstitution();
- HeaderSubstitutionRule rule =
- new HeaderSubstitutionRule(source, stripQuotes(target.toString()), unconditional);
+ HeaderSubstitutionRule rule = new HeaderSubstitutionRule(source, stripQuotes(target.toString()),
+ unconditional);
result.add(rule);
}
@@ -408,26 +400,26 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
Separator separator = new Separator(SWT.NONE);
separator.doFillIntoGrid(inner, 4, conv.convertHeightInCharsToPixels(1));
- int minHeight = convertHeightInCharsToPixels(12);
+ int minHeight = convertHeightInCharsToPixels(12);
fUnconditionalSubstitutionsField.doFillIntoGrid(inner, 4);
LayoutUtil.setHeightHint(fUnconditionalSubstitutionsField.getListControl(null), minHeight);
fOptionalSubstitutionsField.doFillIntoGrid(inner, 4);
- LayoutUtil.setHeightHint(fOptionalSubstitutionsField.getListControl(null), minHeight);
+ LayoutUtil.setHeightHint(fOptionalSubstitutionsField.getListControl(null), minHeight);
- applyDialogFont(composite);
+ applyDialogFont(composite);
return composite;
}
private void importFromFile() {
- FileDialog dialog= new FileDialog(getShell(), SWT.OPEN);
+ FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText(PreferencesMessages.HeaderSubstitutionMapEditDialog_import_title);
// TODO(sprigogin): Add import from .imp files
// (see http://code.google.com/p/include-what-you-use/wiki/IWYUMappings)
- dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$
- String path= dialog.open();
+ dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$
+ String path = dialog.open();
if (path == null)
return;
@@ -446,17 +438,16 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
}
}
} catch (IOException e) {
- String title= PreferencesMessages.HeaderSubstitutionMapEditDialog_import_title;
- String message= e.getLocalizedMessage();
+ String title = PreferencesMessages.HeaderSubstitutionMapEditDialog_import_title;
+ String message = e.getLocalizedMessage();
if (message != null) {
- message= NLS.bind(PreferencesMessages.HeaderSubstitutionMapEditDialog_error_parse_message, message);
+ message = NLS.bind(PreferencesMessages.HeaderSubstitutionMapEditDialog_error_parse_message, message);
} else {
- message= NLS.bind(PreferencesMessages.HeaderSubstitutionMapEditDialog_error_read_message, path);
+ message = NLS.bind(PreferencesMessages.HeaderSubstitutionMapEditDialog_error_read_message, path);
}
MessageDialog.openError(getShell(), title, message);
} catch (CoreException e) {
- MessageDialog.openError(getShell(),
- PreferencesMessages.HeaderSubstitutionMapEditDialog_import_title,
+ MessageDialog.openError(getShell(), PreferencesMessages.HeaderSubstitutionMapEditDialog_import_title,
e.getLocalizedMessage());
}
@@ -466,12 +457,12 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
private void exportToFile() {
HeaderSubstitutionMap map = getResult();
- FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
+ FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
dialog.setText(PreferencesMessages.HeaderSubstitutionMapEditDialog_export_title);
- dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$
+ dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$
dialog.setFileName(map.getName() + ".xml"); //$NON-NLS-1$
dialog.setOverwrite(true);
- String path= dialog.open();
+ String path = dialog.open();
if (path == null)
return;
@@ -492,12 +483,10 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
}
}
} catch (IOException e) {
- MessageDialog.openError(getShell(),
- PreferencesMessages.HeaderSubstitutionMapEditDialog_export_title,
+ MessageDialog.openError(getShell(), PreferencesMessages.HeaderSubstitutionMapEditDialog_export_title,
PreferencesMessages.HeaderSubstitutionMapEditDialog_error_write_message);
} catch (CoreException e) {
- MessageDialog.openError(getShell(),
- PreferencesMessages.HeaderSubstitutionMapEditDialog_export_title,
+ MessageDialog.openError(getShell(), PreferencesMessages.HeaderSubstitutionMapEditDialog_export_title,
e.getLocalizedMessage());
}
}
@@ -505,7 +494,8 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ICHelpContextIds.HEADER_SUBSTITUTION_MAP_EDIT_DIALOG);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell,
+ ICHelpContextIds.HEADER_SUBSTITUTION_MAP_EDIT_DIALOG);
}
private void onButtonPressed(ListDialogField<HeaderSubstitutionRule> field, int buttonId) {
@@ -524,8 +514,9 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
break;
HeaderSubstitutionRule newRule = dialog.getResult();
- ListDialogField<HeaderSubstitutionRule> newField = newRule.isUnconditionalSubstitution() ?
- fUnconditionalSubstitutionsField : fOptionalSubstitutionsField;
+ ListDialogField<HeaderSubstitutionRule> newField = newRule.isUnconditionalSubstitution()
+ ? fUnconditionalSubstitutionsField
+ : fOptionalSubstitutionsField;
if (buttonId == IDX_ADD) {
newField.addElement(newRule);
} else {
@@ -572,9 +563,10 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog {
if (name.isEmpty()) {
status = new StatusInfo(IStatus.WARNING, PreferencesMessages.HeaderSubstitutionMapEditDialog_enter_name);
} else if (fExistingNames.contains(name)) {
- status = new StatusInfo(IStatus.WARNING, PreferencesMessages.HeaderSubstitutionMapEditDialog_duplicate_name);
- } else if (fUnconditionalSubstitutionsField.getElements().isEmpty() &&
- fOptionalSubstitutionsField.getElements().isEmpty()) {
+ status = new StatusInfo(IStatus.WARNING,
+ PreferencesMessages.HeaderSubstitutionMapEditDialog_duplicate_name);
+ } else if (fUnconditionalSubstitutionsField.getElements().isEmpty()
+ && fOptionalSubstitutionsField.getElements().isEmpty()) {
status = new StatusInfo(IStatus.WARNING, PreferencesMessages.HeaderSubstitutionMapEditDialog_map_is_empty);
}
updateStatus(status);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionPreferencePage.java
index 80a06d73ac8..c11ea9d1ca0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionPreferencePage.java
@@ -23,13 +23,13 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The preference page for configuring header file substitution rules.
*/
public class HeaderSubstitutionPreferencePage extends ConfigurationBlockPropertyAndPreferencePage {
- public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.HeaderSubstitutionPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.HeaderSubstitutionPreferencePage"; //$NON-NLS-1$
+ public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.HeaderSubstitutionPreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.HeaderSubstitutionPreferencePage"; //$NON-NLS-1$
public HeaderSubstitutionPreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
// Only used when the page is shown programmatically.
- setTitle(PreferencesMessages.HeaderSubstitutionPreferencePage_title);
+ setTitle(PreferencesMessages.HeaderSubstitutionPreferencePage_title);
}
@Override
@@ -51,6 +51,6 @@ public class HeaderSubstitutionPreferencePage extends ConfigurationBlockProperty
protected String getPropertyPageId() {
return null;
// TODO(sprigogin): Project specific settings
-// return PROP_ID;
+ // return PROP_ID;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java
index be4034f3ab3..d80fe3117d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java
@@ -18,7 +18,6 @@ package org.eclipse.cdt.internal.ui.preferences;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-
/**
* Interface for preference configuration blocks which can either be
* wrapped by a {@link org.eclipse.cdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage}
@@ -26,39 +25,39 @@ import org.eclipse.swt.widgets.Control;
* <p>
* Clients may implement this interface.
* </p>
- *
+ *
* @since 3.0
*/
public interface IPreferenceConfigurationBlock {
-
+
/**
* Creates the preference control.
- *
+ *
* @param parent the parent composite to which to add the preferences control
- * @return the control that was added to <code>parent</code>
+ * @return the control that was added to <code>parent</code>
*/
Control createControl(Composite parent);
-
+
/**
- * Called after creating the control. Implementations should load the
+ * Called after creating the control. Implementations should load the
* preferences values and update the controls accordingly.
*/
void initialize();
-
+
/**
* Called when the <code>OK</code> button is pressed on the preference
* page. Implementations should commit the configured preference settings
* into their form of preference storage.
*/
void performOk();
-
+
/**
* Called when the <code>Defaults</code> button is pressed on the
* preference page. Implementation should reset any preference settings to
* their default values and adjust the controls accordingly.
*/
void performDefaults();
-
+
/**
* Called when the preference page is being disposed. Implementations should
* free any resources they are holding on to.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeCategoriesBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeCategoriesBlock.java
index 9a8a5475ca2..efe8fbce532 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeCategoriesBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeCategoriesBlock.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -89,11 +88,11 @@ public class IncludeCategoriesBlock extends OptionsConfigurationBlock {
@Override
protected Control createContents(Composite parent) {
- pixelConverter = new PixelConverter(parent);
+ pixelConverter = new PixelConverter(parent);
setShell(parent.getShell());
- Composite composite = new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setFont(parent.getFont());
GridLayout layout = new GridLayout();
@@ -131,7 +130,7 @@ public class IncludeCategoriesBlock extends OptionsConfigurationBlock {
}
private void createCategoryEditors(Composite parent) {
- Composite editorArea = new Composite(parent, SWT.NONE);
+ Composite editorArea = new Composite(parent, SWT.NONE);
editorArea.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
editorArea.setFont(parent.getFont());
editorAreaStack = new StackLayout();
@@ -176,12 +175,12 @@ public class IncludeCategoriesBlock extends OptionsConfigurationBlock {
fContext.statusChanged(new StatusInfo());
}
- /**
- * Represents a category of settings.
- */
+ /**
+ * Represents a category of settings.
+ */
private final static class Category {
public final Category parent;
- public final int index; // Index in the siblings list
+ public final int index; // Index in the siblings list
private final List<Category> children;
private final IncludeKind includeKind;
private Control editorArea;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeGroupStyleBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeGroupStyleBlock.java
index f0e3e6bcbbe..e18c82d2da4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeGroupStyleBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeGroupStyleBlock.java
@@ -63,7 +63,7 @@ public class IncludeGroupStyleBlock extends OptionsConfigurationBlock {
@Override
protected Control createContents(Composite parent) {
- pixelConverter = new PixelConverter(parent);
+ pixelConverter = new PixelConverter(parent);
setShell(parent.getShell());
@@ -76,7 +76,7 @@ public class IncludeGroupStyleBlock extends OptionsConfigurationBlock {
composite.setLayout(layout);
composite.setFont(parent.getFont());
- Group group = ControlFactory.createGroup(composite, description, 1);
+ Group group = ControlFactory.createGroup(composite, description, 1);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite envelope = new Composite(group, SWT.NONE);
@@ -87,54 +87,53 @@ public class IncludeGroupStyleBlock extends OptionsConfigurationBlock {
addCheckBox(envelope, PreferencesMessages.IncludeGroupStyleBlock_keep_includes_together, 0,
new BooleanDataSource() {
- @Override
- public boolean get() {
- return style.isKeepTogether();
- }
-
- @Override
- public void set(boolean value) {
- style.setKeepTogether(value);
- }
- });
+ @Override
+ public boolean get() {
+ return style.isKeepTogether();
+ }
+
+ @Override
+ public void set(boolean value) {
+ style.setKeepTogether(value);
+ }
+ });
checkBoxBlankLine = addCheckBox(envelope, PreferencesMessages.IncludeGroupStyleBlock_blank_line_before,
- pixelConverter.convertHorizontalDLUsToPixels(10),
- new BooleanDataSource() {
- @Override
- public boolean get() {
- return style.isBlankLineBefore();
- }
-
- @Override
- public void set(boolean value) {
- style.setBlankLineBefore(value);
- }
- });
+ pixelConverter.convertHorizontalDLUsToPixels(10), new BooleanDataSource() {
+ @Override
+ public boolean get() {
+ return style.isBlankLineBefore();
+ }
+
+ @Override
+ public void set(boolean value) {
+ style.setBlankLineBefore(value);
+ }
+ });
if (!style.getIncludeKind().hasChildren()) {
addCheckBox(envelope, PreferencesMessages.IncludeGroupStyleBlock_use_relative_path, 0,
new BooleanDataSource() {
- @Override
- public boolean get() {
- return style.isRelativePath();
- }
-
- @Override
- public void set(boolean value) {
- style.setRelativePath(value);
- }
- });
+ @Override
+ public boolean get() {
+ return style.isRelativePath();
+ }
+
+ @Override
+ public void set(boolean value) {
+ style.setRelativePath(value);
+ }
+ });
addCheckBox(envelope, PreferencesMessages.IncludeGroupStyleBlock_use_angle_brackets, 0,
new BooleanDataSource() {
- @Override
- public boolean get() {
- return style.isAngleBrackets();
- }
-
- @Override
- public void set(boolean value) {
- style.setAngleBrackets(value);
- }
- });
+ @Override
+ public boolean get() {
+ return style.isAngleBrackets();
+ }
+
+ @Override
+ public void set(boolean value) {
+ style.setAngleBrackets(value);
+ }
+ });
}
updateControls();
@@ -143,11 +142,11 @@ public class IncludeGroupStyleBlock extends OptionsConfigurationBlock {
}
private Button addCheckBox(Composite parent, String label, int indent, BooleanDataSource dataSource) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 3;
- gd.horizontalIndent= indent;
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
+ gd.horizontalIndent = indent;
- Button checkBox= new Button(parent, SWT.CHECK);
+ Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setFont(JFaceResources.getDialogFont());
checkBox.setText(label);
checkBox.setData(dataSource);
@@ -166,7 +165,7 @@ public class IncludeGroupStyleBlock extends OptionsConfigurationBlock {
@Override
protected void updateControls() {
super.updateControls();
- for (int i= checkBoxes.size() - 1; i >= 0; i--) {
+ for (int i = checkBoxes.size() - 1; i >= 0; i--) {
updateCheckBox(checkBoxes.get(i));
}
}
@@ -198,11 +197,13 @@ public class IncludeGroupStyleBlock extends OptionsConfigurationBlock {
private interface BooleanDataSource {
boolean get();
+
void set(boolean value);
}
private interface StringDataSource {
String get();
+
void set(String value);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeOrderBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeOrderBlock.java
index b039c0c3a32..47bf82036f3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeOrderBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeOrderBlock.java
@@ -44,29 +44,27 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class IncludeOrderBlock extends OptionsConfigurationBlock {
private static final int IDX_UP = 0;
private static final int IDX_DOWN = 1;
- private static final String[] UP_DOWN_LABELS = {
- PreferencesMessages.IncludeOrderBlock_up,
- PreferencesMessages.IncludeOrderBlock_down
- };
+ private static final String[] UP_DOWN_LABELS = { PreferencesMessages.IncludeOrderBlock_up,
+ PreferencesMessages.IncludeOrderBlock_down };
private final List<IncludeGroupStyle> styles;
private Map<IncludeKind, IncludeGroupStyle> stylesByKind;
private GroupListField includeGroupList;
private PixelConverter pixelConverter;
- public IncludeOrderBlock(IStatusChangeListener context, IProject project,
- IWorkbenchPreferenceContainer container, List<IncludeGroupStyle> styles) {
+ public IncludeOrderBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container,
+ List<IncludeGroupStyle> styles) {
super(context, project, new Key[0], container);
this.styles = styles;
}
@Override
protected Control createContents(Composite parent) {
- pixelConverter = new PixelConverter(parent);
+ pixelConverter = new PixelConverter(parent);
setShell(parent.getShell());
- Composite composite = new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setFont(parent.getFont());
GridLayout layout = new GridLayout(2, false);
@@ -103,8 +101,8 @@ public class IncludeOrderBlock extends OptionsConfigurationBlock {
for (IncludeGroupStyle style : orderedStyles) {
style.setOrder(order++);
IncludeKind includeKind = style.getIncludeKind();
- if (style.isKeepTogether() &&
- (!includeKind.hasChildren() || hasUngroupedChildren(includeKind, stylesByKind))) {
+ if (style.isKeepTogether()
+ && (!includeKind.hasChildren() || hasUngroupedChildren(includeKind, stylesByKind))) {
groupedStyles.add(style);
}
}
@@ -113,7 +111,8 @@ public class IncludeOrderBlock extends OptionsConfigurationBlock {
IncludeGroupStyle style = groupedStyles.get(i);
IncludeKind groupingKind = getGroupingParentKind(style);
if (groupingKind != null) {
- while (++i < groupedStyles.size() && getGroupingParentKind(groupedStyles.get(i)) == groupingKind) {}
+ while (++i < groupedStyles.size() && getGroupingParentKind(groupedStyles.get(i)) == groupingKind) {
+ }
for (int j = i + 1; j < groupedStyles.size(); j++) {
if (getGroupingParentKind(groupedStyles.get(j)) == groupingKind) {
groupedStyles.add(i++, groupedStyles.remove(j));
@@ -165,8 +164,8 @@ public class IncludeOrderBlock extends OptionsConfigurationBlock {
// "Other" include kind is special since it effectively includes all other ungrouped includes.
if (includeKind == IncludeKind.OTHER) {
for (IncludeKind kind : stylesByKind.keySet()) {
- if (kind != IncludeKind.OTHER && kind.hasChildren() && !stylesByKind.get(kind).isKeepTogether() &&
- hasUngroupedChildren(kind, stylesByKind)) {
+ if (kind != IncludeKind.OTHER && kind.hasChildren() && !stylesByKind.get(kind).isKeepTogether()
+ && hasUngroupedChildren(kind, stylesByKind)) {
return true;
}
}
@@ -268,7 +267,7 @@ public class IncludeOrderBlock extends OptionsConfigurationBlock {
}
private List<IncludeGroupStyle> moveUp(List<IncludeGroupStyle> elements, boolean[] selected) {
- int nElements= elements.size();
+ int nElements = elements.size();
List<IncludeGroupStyle> res = new ArrayList<IncludeGroupStyle>(nElements);
List<IncludeGroupStyle> floating = new ArrayList<IncludeGroupStyle>();
for (int i = 0; i < nElements; i++) {
@@ -317,9 +316,10 @@ public class IncludeOrderBlock extends OptionsConfigurationBlock {
for (int i = 1; i < selected.length; i++) {
int j = i - 1;
if (selected[i] && !selected[j] && areKeptTogether(elements.get(i), elements.get(j))) {
- while (++i < selected.length && selected[i]) {}
+ while (++i < selected.length && selected[i]) {
+ }
if (!areKeptTogether(elements.get(i - 1), elements.get(j)))
- return false; // Cannot break a group.
+ return false; // Cannot break a group.
}
}
return true;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasBlock.java
index 1303473658d..6770049fc23 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasBlock.java
@@ -45,18 +45,15 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
*/
public class IncludePragmasBlock extends OptionsConfigurationBlock {
private static final Key KEY_EXPORT_PATTERN = getCDTCoreKey(CCorePreferenceConstants.INCLUDE_EXPORT_PATTERN);
- private static final Key KEY_BEGIN_EXPORTS_PATTERN = getCDTCoreKey(CCorePreferenceConstants.INCLUDE_BEGIN_EXPORTS_PATTERN);
- private static final Key KEY_END_EXPORTS_PATTERN = getCDTCoreKey(CCorePreferenceConstants.INCLUDE_END_EXPORTS_PATTERN);
+ private static final Key KEY_BEGIN_EXPORTS_PATTERN = getCDTCoreKey(
+ CCorePreferenceConstants.INCLUDE_BEGIN_EXPORTS_PATTERN);
+ private static final Key KEY_END_EXPORTS_PATTERN = getCDTCoreKey(
+ CCorePreferenceConstants.INCLUDE_END_EXPORTS_PATTERN);
private static final Key KEY_PRIVATE_PATTERN = getCDTCoreKey(CCorePreferenceConstants.INCLUDE_PRIVATE_PATTERN);
private static final Key KEY_KEEP_PATTERN = getCDTCoreKey(CCorePreferenceConstants.INCLUDE_KEEP_PATTERN);
- private static Key[] ALL_KEYS = {
- KEY_EXPORT_PATTERN,
- KEY_BEGIN_EXPORTS_PATTERN,
- KEY_END_EXPORTS_PATTERN,
- KEY_PRIVATE_PATTERN,
- KEY_KEEP_PATTERN,
- };
+ private static Key[] ALL_KEYS = { KEY_EXPORT_PATTERN, KEY_BEGIN_EXPORTS_PATTERN, KEY_END_EXPORTS_PATTERN,
+ KEY_PRIVATE_PATTERN, KEY_KEEP_PATTERN, };
private PixelConverter pixelConverter;
public IncludePragmasBlock(IStatusChangeListener context, IProject project,
@@ -69,7 +66,7 @@ public class IncludePragmasBlock extends OptionsConfigurationBlock {
setShell(parent.getShell());
pixelConverter = new PixelConverter(parent);
- Composite composite = new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setFont(parent.getFont());
GridLayout layout = new GridLayout(3, false);
layout.marginHeight = 0;
@@ -79,8 +76,8 @@ public class IncludePragmasBlock extends OptionsConfigurationBlock {
Control control = createHeader(composite);
LayoutUtil.setHorizontalSpan(control, 3);
- control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_export_pattern,
- KEY_EXPORT_PATTERN, 0, pixelConverter.convertWidthInCharsToPixels(40));
+ control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_export_pattern, KEY_EXPORT_PATTERN, 0,
+ pixelConverter.convertWidthInCharsToPixels(40));
LayoutUtil.setHorizontalGrabbing(control, true);
control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_begin_exports_pattern,
KEY_BEGIN_EXPORTS_PATTERN, 0, pixelConverter.convertWidthInCharsToPixels(40));
@@ -88,11 +85,11 @@ public class IncludePragmasBlock extends OptionsConfigurationBlock {
control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_end_exports_pattern,
KEY_END_EXPORTS_PATTERN, 0, pixelConverter.convertWidthInCharsToPixels(40));
LayoutUtil.setHorizontalGrabbing(control, true);
- control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_private_pattern,
- KEY_PRIVATE_PATTERN, 0, pixelConverter.convertWidthInCharsToPixels(40));
+ control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_private_pattern, KEY_PRIVATE_PATTERN,
+ 0, pixelConverter.convertWidthInCharsToPixels(40));
LayoutUtil.setHorizontalGrabbing(control, true);
- control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_keep_pattern,
- KEY_KEEP_PATTERN, 0, pixelConverter.convertWidthInCharsToPixels(40));
+ control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_keep_pattern, KEY_KEEP_PATTERN, 0,
+ pixelConverter.convertWidthInCharsToPixels(40));
LayoutUtil.setHorizontalGrabbing(control, true);
updateControls();
@@ -111,8 +108,8 @@ public class IncludePragmasBlock extends OptionsConfigurationBlock {
public void run() {
try {
URL url = new URL(event.text);
- IWorkbenchBrowserSupport browserSupport= PlatformUI.getWorkbench().getBrowserSupport();
- IWebBrowser browser= browserSupport.getExternalBrowser();
+ IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
+ IWebBrowser browser = browserSupport.getExternalBrowser();
browser.openURL(url);
} catch (PartInitException e) {
// TODO(sprigogin): Should we show an error dialog?
@@ -128,9 +125,9 @@ public class IncludePragmasBlock extends OptionsConfigurationBlock {
// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 is fixed
link.setToolTipText(PreferencesMessages.IncludePragmasBlock_link_tooltip);
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
// Only expand further if anyone else requires it
- gridData.widthHint= pixelConverter.convertWidthInCharsToPixels(40);
+ gridData.widthHint = pixelConverter.convertWidthInCharsToPixels(40);
link.setLayoutData(gridData);
return link;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasPreferencePage.java
index 93a5d232069..7139f21b625 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasPreferencePage.java
@@ -24,13 +24,13 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* @see "https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md"
*/
public class IncludePragmasPreferencePage extends ConfigurationBlockPropertyAndPreferencePage {
- public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.IncludePragmasPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.IncludePragmasPreferencePage"; //$NON-NLS-1$
+ public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.IncludePragmasPreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.IncludePragmasPreferencePage"; //$NON-NLS-1$
public IncludePragmasPreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
// Only used when the page is shown programmatically.
- setTitle(PreferencesMessages.IncludePragmasPreferencePage_title);
+ setTitle(PreferencesMessages.IncludePragmasPreferencePage_title);
}
@Override
@@ -52,6 +52,6 @@ public class IncludePragmasPreferencePage extends ConfigurationBlockPropertyAndP
protected String getPropertyPageId() {
return null;
// TODO(sprigogin): Project specific settings
-// return PROP_ID;
+ // return PROP_ID;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStyleBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStyleBlock.java
index 98a802df39f..e9c9bda9b2c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStyleBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStyleBlock.java
@@ -37,8 +37,10 @@ public class IncludeStyleBlock extends TabConfigurationBlock {
static final Key KEY_STYLE_SAME_FOLDER = getCDTUIKey(PreferenceConstants.INCLUDE_STYLE_SAME_FOLDER);
static final Key KEY_STYLE_SUBFOLDER = getCDTUIKey(PreferenceConstants.INCLUDE_STYLE_SUBFOLDER);
static final Key KEY_STYLE_SYSTEM = getCDTUIKey(PreferenceConstants.INCLUDE_STYLE_SYSTEM);
- static final Key KEY_STYLE_SYSTEM_WITH_EXTENSION = getCDTUIKey(PreferenceConstants.INCLUDE_STYLE_SYSTEM_WITH_EXTENSION);
- static final Key KEY_STYLE_SYSTEM_WITHOUT_EXTENSION = getCDTUIKey(PreferenceConstants.INCLUDE_STYLE_SYSTEM_WITHOUT_EXTENSION);
+ static final Key KEY_STYLE_SYSTEM_WITH_EXTENSION = getCDTUIKey(
+ PreferenceConstants.INCLUDE_STYLE_SYSTEM_WITH_EXTENSION);
+ static final Key KEY_STYLE_SYSTEM_WITHOUT_EXTENSION = getCDTUIKey(
+ PreferenceConstants.INCLUDE_STYLE_SYSTEM_WITHOUT_EXTENSION);
static final Key KEY_STYLE_OTHER = getCDTUIKey(PreferenceConstants.INCLUDE_STYLE_OTHER);
static final Key KEY_STYLE_SAME_PROJECT = getCDTUIKey(PreferenceConstants.INCLUDE_STYLE_SAME_PROJECT);
static final Key KEY_STYLE_OTHER_PROJECT = getCDTUIKey(PreferenceConstants.INCLUDE_STYLE_OTHER_PROJECT);
@@ -47,28 +49,25 @@ public class IncludeStyleBlock extends TabConfigurationBlock {
static final Map<IncludeKind, Key> KEY_MAP = createKeyMap();
static final Key[] STYLE_KEYS = KEY_MAP.values().toArray(new Key[KEY_MAP.size()]);
-
- private static final String[] TAB_LABELS = {
- PreferencesMessages.IncludeStyleBlock_categories_tab,
- PreferencesMessages.IncludeStyleBlock_order_tab,
- };
-
+
+ private static final String[] TAB_LABELS = { PreferencesMessages.IncludeStyleBlock_categories_tab,
+ PreferencesMessages.IncludeStyleBlock_order_tab, };
+
private final List<IncludeGroupStyle> styles;
- public IncludeStyleBlock(IStatusChangeListener context, IProject project,
- IWorkbenchPreferenceContainer container) {
+ public IncludeStyleBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
this(context, project, container, new ArrayList<IncludeGroupStyle>());
}
-
- private IncludeStyleBlock(IStatusChangeListener context, IProject project,
- IWorkbenchPreferenceContainer container, List<IncludeGroupStyle> styles) {
+
+ private IncludeStyleBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container,
+ List<IncludeGroupStyle> styles) {
super(context, project, createTabs(context, project, container, styles), TAB_LABELS, container);
this.styles = styles;
settingsUpdated();
}
- private static OptionsConfigurationBlock[] createTabs(IStatusChangeListener context,
- IProject project, IWorkbenchPreferenceContainer container, List<IncludeGroupStyle> styles) {
+ private static OptionsConfigurationBlock[] createTabs(IStatusChangeListener context, IProject project,
+ IWorkbenchPreferenceContainer container, List<IncludeGroupStyle> styles) {
IncludeCategoriesBlock includeCategoriesBlock = new IncludeCategoriesBlock(context, project, container, styles);
IncludeOrderBlock includeOrderBlock = new IncludeOrderBlock(context, project, container, styles);
return new OptionsConfigurationBlock[] { includeCategoriesBlock, includeOrderBlock };
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStylePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStylePreferencePage.java
index ca51112bd39..5f3f2a3ec94 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStylePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludeStylePreferencePage.java
@@ -23,13 +23,13 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The preference page for configuring styles of include statements.
*/
public class IncludeStylePreferencePage extends ConfigurationBlockPropertyAndPreferencePage {
- public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.IncludeStylePreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.IncludeStylePreferencePage"; //$NON-NLS-1$
+ public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.IncludeStylePreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.IncludeStylePreferencePage"; //$NON-NLS-1$
public IncludeStylePreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
// Only used when the page is shown programmatically.
- setTitle(PreferencesMessages.IncludeStylePreferencePage_title);
+ setTitle(PreferencesMessages.IncludeStylePreferencePage_title);
}
@Override
@@ -51,6 +51,6 @@ public class IncludeStylePreferencePage extends ConfigurationBlockPropertyAndPre
protected String getPropertyPageId() {
return null;
// TODO(sprigogin): Project specific settings
-// return PROP_ID;
+ // return PROP_ID;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java
index bb122235cdd..c321deba782 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java
@@ -36,22 +36,21 @@ import org.eclipse.cdt.ui.dialogs.IndexerBlock;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-public class IndexerPreferencePage extends PreferencePage implements
- IWorkbenchPreferencePage, ICOptionContainer {
+public class IndexerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ICOptionContainer {
// bug 217860, allow to hide build configuration
private static final String SHOW_BUILD_SPECIFIC_CONFIG = "show.build.specific.indexer.config"; //$NON-NLS-1$
private final IndexerBlock fOptionBlock;
private final CacheSizeBlock fCacheBlock;
private final IndexerStrategyBlock fStrategyBlock;
-
- public IndexerPreferencePage(){
+
+ public IndexerPreferencePage() {
fOptionBlock = new IndexerBlock();
fOptionBlock.setContainer(this);
- fStrategyBlock= new IndexerStrategyBlock(this);
- fCacheBlock= new CacheSizeBlock(this);
+ fStrategyBlock = new IndexerStrategyBlock(this);
+ fCacheBlock = new CacheSizeBlock(this);
}
-
+
@Override
public void createControl(Composite parent) {
super.createControl(parent);
@@ -62,14 +61,14 @@ public class IndexerPreferencePage extends PreferencePage implements
protected Control createContents(Composite parent) {
GridLayout gl;
Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(gl= new GridLayout());
+ composite.setLayout(gl = new GridLayout());
composite.setLayoutData(new GridData());
- gl.verticalSpacing= 0;
-
+ gl.verticalSpacing = 0;
+
fOptionBlock.createControl(composite);
fStrategyBlock.createControl(composite);
fCacheBlock.createControl(composite);
-
+
return composite;
}
@@ -82,16 +81,13 @@ public class IndexerPreferencePage extends PreferencePage implements
if (!fOptionBlock.isValid()) {
setErrorMessage(fOptionBlock.getErrorMessage());
setValid(false);
- }
- else if (!fStrategyBlock.isValid()) {
+ } else if (!fStrategyBlock.isValid()) {
setErrorMessage(fStrategyBlock.getErrorMessage());
setValid(false);
- }
- else if (!fCacheBlock.isValid()) {
+ } else if (!fCacheBlock.isValid()) {
setErrorMessage(fCacheBlock.getErrorMessage());
setValid(false);
- }
- else {
+ } else {
setErrorMessage(null);
setValid(true);
}
@@ -114,7 +110,8 @@ public class IndexerPreferencePage extends PreferencePage implements
fOptionBlock.performApply(new NullProgressMonitor());
fStrategyBlock.performApply(new NullProgressMonitor());
fCacheBlock.performApply(new NullProgressMonitor());
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
return true;
}
@@ -131,9 +128,9 @@ public class IndexerPreferencePage extends PreferencePage implements
* @since 5.0
*/
public static boolean showBuildConfiguration() {
- IWorkbenchActivitySupport activitySupport= PlatformUI.getWorkbench().getActivitySupport();
- IIdentifier identifier= activitySupport.getActivityManager().getIdentifier(
- CUIPlugin.getPluginId() + '/' + SHOW_BUILD_SPECIFIC_CONFIG);
+ IWorkbenchActivitySupport activitySupport = PlatformUI.getWorkbench().getActivitySupport();
+ IIdentifier identifier = activitySupport.getActivityManager()
+ .getIdentifier(CUIPlugin.getPluginId() + '/' + SHOW_BUILD_SPECIFIC_CONFIG);
return identifier.isEnabled();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java
index 28542eeaf61..40d492ad011 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
import org.eclipse.core.runtime.CoreException;
@@ -40,110 +40,114 @@ import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
* various parsing related caches.
*/
public class IndexerStrategyBlock extends AbstractCOptionPage {
- private Button fAutoUpdateButton;
+ private Button fAutoUpdateButton;
private Button fImmediateUpdateButton;
private Button fUseActiveBuildButton;
private Button fUseFixedBuildConfig;
public IndexerStrategyBlock(ICOptionContainer container) {
- setContainer(container);
- }
+ setContainer(container);
+ }
- @Override
+ @Override
public void createControl(Composite parent) {
- GridData gd;
- GridLayout gl;
- Composite composite = ControlFactory.createComposite(parent, 1);
- gl= (GridLayout)composite.getLayout();
- gl.marginWidth= 0;
- gl.verticalSpacing= gl.marginHeight*2;
-
- gd= (GridData) composite.getLayoutData();
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalAlignment= GridData.FILL;
+ GridData gd;
+ GridLayout gl;
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ gl = (GridLayout) composite.getLayout();
+ gl.marginWidth = 0;
+ gl.verticalSpacing = gl.marginHeight * 2;
+
+ gd = (GridData) composite.getLayoutData();
+ gd.grabExcessHorizontalSpace = false;
+ gd.horizontalAlignment = GridData.FILL;
setControl(composite);
-
- SelectionListener updateEnablement= new SelectionAdapter() {
+
+ SelectionListener updateEnablement = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateEnablement();
}
};
- Group group= ControlFactory.createGroup(composite, PreferencesMessages.IndexerStrategyBlock_strategyGroup, 1);
- gd= (GridData) group.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
- gd.horizontalAlignment= GridData.FILL;
- fAutoUpdateButton= ControlFactory.createCheckBox(group, PreferencesMessages.IndexerStrategyBlock_autoUpdate);
- fImmediateUpdateButton= ControlFactory.createCheckBox(group, PreferencesMessages.IndexerStrategyBlock_immediateUpdate);
+ Group group = ControlFactory.createGroup(composite, PreferencesMessages.IndexerStrategyBlock_strategyGroup, 1);
+ gd = (GridData) group.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+ fAutoUpdateButton = ControlFactory.createCheckBox(group, PreferencesMessages.IndexerStrategyBlock_autoUpdate);
+ fImmediateUpdateButton = ControlFactory.createCheckBox(group,
+ PreferencesMessages.IndexerStrategyBlock_immediateUpdate);
fAutoUpdateButton.addSelectionListener(updateEnablement);
-
+
if (IndexerPreferencePage.showBuildConfiguration()) {
- group= ControlFactory.createGroup(composite, PreferencesMessages.IndexerStrategyBlock_buildConfigGroup, 1);
- gd= (GridData) group.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
- gd.horizontalAlignment= GridData.FILL;
- fUseActiveBuildButton= ControlFactory.createRadioButton(group, PreferencesMessages.IndexerStrategyBlock_activeBuildConfig, null, null);
- fUseFixedBuildConfig= ControlFactory.createRadioButton(group, PreferencesMessages.IndexerStrategyBlock_specificBuildConfig, null, null);
- }
+ group = ControlFactory.createGroup(composite, PreferencesMessages.IndexerStrategyBlock_buildConfigGroup, 1);
+ gd = (GridData) group.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+ fUseActiveBuildButton = ControlFactory.createRadioButton(group,
+ PreferencesMessages.IndexerStrategyBlock_activeBuildConfig, null, null);
+ fUseFixedBuildConfig = ControlFactory.createRadioButton(group,
+ PreferencesMessages.IndexerStrategyBlock_specificBuildConfig, null, null);
+ }
initializeValues();
- }
+ }
- protected void updateEnablement() {
- fImmediateUpdateButton.setEnabled(fAutoUpdateButton.getSelection());
+ protected void updateEnablement() {
+ fImmediateUpdateButton.setEnabled(fAutoUpdateButton.getSelection());
}
private void initializeValues() {
- int updatePolicy= IndexerPreferences.getUpdatePolicy(null);
- initUpdatePolicy(updatePolicy);
-
- if (fUseActiveBuildButton != null) {
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
- ICProjectDescriptionWorkspacePreferences prefs= prjDescMgr.getProjectDescriptionWorkspacePreferences(false);
- boolean useActive= prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE;
- fUseActiveBuildButton.setSelection(useActive);
- fUseFixedBuildConfig.setSelection(!useActive);
- }
- updateEnablement();
+ int updatePolicy = IndexerPreferences.getUpdatePolicy(null);
+ initUpdatePolicy(updatePolicy);
+
+ if (fUseActiveBuildButton != null) {
+ ICProjectDescriptionManager prjDescMgr = CCorePlugin.getDefault().getProjectDescriptionManager();
+ ICProjectDescriptionWorkspacePreferences prefs = prjDescMgr
+ .getProjectDescriptionWorkspacePreferences(false);
+ boolean useActive = prefs
+ .getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE;
+ fUseActiveBuildButton.setSelection(useActive);
+ fUseFixedBuildConfig.setSelection(!useActive);
+ }
+ updateEnablement();
}
private void initUpdatePolicy(int updatePolicy) {
fAutoUpdateButton.setSelection(updatePolicy != IndexerPreferences.UPDATE_POLICY_MANUAL);
- fImmediateUpdateButton.setSelection(updatePolicy == IndexerPreferences.UPDATE_POLICY_IMMEDIATE);
+ fImmediateUpdateButton.setSelection(updatePolicy == IndexerPreferences.UPDATE_POLICY_IMMEDIATE);
}
@Override
public void performApply(IProgressMonitor monitor) throws CoreException {
int updatePolicy;
if (!fAutoUpdateButton.getSelection()) {
- updatePolicy= IndexerPreferences.UPDATE_POLICY_MANUAL;
+ updatePolicy = IndexerPreferences.UPDATE_POLICY_MANUAL;
} else if (fImmediateUpdateButton.getSelection()) {
- updatePolicy= IndexerPreferences.UPDATE_POLICY_IMMEDIATE;
+ updatePolicy = IndexerPreferences.UPDATE_POLICY_IMMEDIATE;
} else {
- updatePolicy= IndexerPreferences.UPDATE_POLICY_LAZY;
- }
+ updatePolicy = IndexerPreferences.UPDATE_POLICY_LAZY;
+ }
IndexerPreferences.setUpdatePolicy(null, updatePolicy);
- if (fUseActiveBuildButton != null) {
- boolean useActive= fUseActiveBuildButton.getSelection();
- int relation= useActive ?
- ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE :
- ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT;
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
- ICProjectDescriptionWorkspacePreferences prefs= prjDescMgr.getProjectDescriptionWorkspacePreferences(true);
- prefs.setConfigurationRelations(relation);
- prjDescMgr.setProjectDescriptionWorkspacePreferences(prefs, false, new NullProgressMonitor());
- }
+ if (fUseActiveBuildButton != null) {
+ boolean useActive = fUseActiveBuildButton.getSelection();
+ int relation = useActive ? ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE
+ : ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT;
+ ICProjectDescriptionManager prjDescMgr = CCorePlugin.getDefault().getProjectDescriptionManager();
+ ICProjectDescriptionWorkspacePreferences prefs = prjDescMgr.getProjectDescriptionWorkspacePreferences(true);
+ prefs.setConfigurationRelations(relation);
+ prjDescMgr.setProjectDescriptionWorkspacePreferences(prefs, false, new NullProgressMonitor());
+ }
}
- @Override
+ @Override
public void performDefaults() {
- initUpdatePolicy(IndexerPreferences.getDefaultUpdatePolicy());
- if (fUseActiveBuildButton != null) {
- fUseActiveBuildButton.setSelection(false);
- fUseFixedBuildConfig.setSelection(true);
- }
- updateEnablement();
- }
+ initUpdatePolicy(IndexerPreferences.getDefaultUpdatePolicy());
+ if (fUseActiveBuildButton != null) {
+ fUseActiveBuildButton.setSelection(false);
+ fUseFixedBuildConfig.setSelection(true);
+ }
+ updateEnablement();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java
index 73e8d8b1030..ce6f4a03b42 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -42,149 +42,154 @@ import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey
/**
* Configures C/C++ Editor mark occurrences preferences.
- *
+ *
* @since 5.0
*/
class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock {
private final OverlayPreferenceStore fStore;
-
- private final Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
- private final SelectionListener fCheckBoxListener= new SelectionListener() {
+
+ private final Map<Object, String> fCheckBoxes = new HashMap<Object, String>();
+ private final SelectionListener fCheckBoxListener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
@Override
public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
+ Button button = (Button) e.widget;
fStore.setValue(fCheckBoxes.get(button), button.getSelection());
}
};
-
+
/**
* List of master/slave listeners when there's a dependency.
- *
+ *
* @see #createDependency(Button, String, Control)
*/
- private final ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
-
+ private final ArrayList<Object> fMasterSlaveListeners = new ArrayList<Object>();
+
private StatusInfo fStatus;
public MarkOccurrencesConfigurationBlock(OverlayPreferenceStore store) {
Assert.isNotNull(store);
- fStore= store;
-
+ fStore = store;
+
fStore.addKeys(createOverlayStoreKeys());
}
-
+
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-
- ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+
+ ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
+
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_MARK_OCCURRENCES));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
+
+ OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
- }
+ }
/**
* Creates page for mark occurrences preferences.
- *
+ *
* @param parent the parent composite
* @return the control for the preference page
*/
@Override
public Control createControl(final Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
composite.setLayout(layout);
-
- Link link= new Link(composite, SWT.NONE);
+
+ Link link = new Link(composite, SWT.NONE);
link.setText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
+ PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
}
});
// TODO replace by link-specific tooltips when
// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
- link.setToolTipText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link_tooltip);
-
+ link.setToolTipText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link_tooltip);
+
addFiller(composite);
-
+
String label;
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markOccurrences;
- Button master= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0);
-
+
+ label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markOccurrences;
+ Button master = addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0);
+
addFiller(composite);
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markOverloadOccurrences;
- Button slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, 0);
+
+ label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markOverloadOccurrences;
+ Button slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES,
+ 0);
createDependency(master, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, slave);
addFiller(composite);
-
- label= PreferencesMessages.MarkOccurrencesConfigurationBlock_stickyOccurrences;
- slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0);
+
+ label = PreferencesMessages.MarkOccurrencesConfigurationBlock_stickyOccurrences;
+ slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0);
createDependency(master, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, slave);
return composite;
}
-
+
private void addFiller(Composite composite) {
- PixelConverter pixelConverter= new PixelConverter(composite);
-
- Label filler= new Label(composite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+ PixelConverter pixelConverter = new PixelConverter(composite);
+
+ Label filler = new Label(composite, SWT.LEFT);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2;
filler.setLayoutData(gd);
}
- private Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox= new Button(parent, SWT.CHECK);
+ private Button addCheckBox(Composite parent, String label, String key, int indentation) {
+ Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setText(label);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
+
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = indentation;
+ gd.horizontalSpan = 2;
checkBox.setLayoutData(gd);
checkBox.addSelectionListener(fCheckBoxListener);
-
+
fCheckBoxes.put(checkBox, key);
-
+
return checkBox;
}
private void createDependency(final Button master, String masterKey, final Control slave) {
indent(slave);
- boolean masterState= fStore.getBoolean(masterKey);
+ boolean masterState = fStore.getBoolean(masterKey);
slave.setEnabled(masterState);
- SelectionListener listener= new SelectionListener() {
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
slave.setEnabled(master.getSelection());
}
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
};
master.addSelectionListener(listener);
fMasterSlaveListeners.add(listener);
}
private static void indent(Control control) {
- GridData gridData= new GridData();
- gridData.horizontalIndent= 10;
- control.setLayoutData(gridData);
+ GridData gridData = new GridData();
+ gridData.horizontalIndent = 10;
+ control.setLayoutData(gridData);
}
@Override
@@ -193,21 +198,21 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock
}
void initializeFields() {
-
- Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+
+ Iterator<Object> iter = fCheckBoxes.keySet().iterator();
while (iter.hasNext()) {
- Button b= (Button) iter.next();
- String key= fCheckBoxes.get(b);
+ Button b = (Button) iter.next();
+ String key = fCheckBoxes.get(b);
b.setSelection(fStore.getBoolean(key));
}
-
- // Update slaves
- iter= fMasterSlaveListeners.iterator();
- while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
- listener.widgetSelected(null);
- }
-
+
+ // Update slaves
+ iter = fMasterSlaveListeners.iterator();
+ while (iter.hasNext()) {
+ SelectionListener listener = (SelectionListener) iter.next();
+ listener.widgetSelected(null);
+ }
+
}
@Override
@@ -226,7 +231,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock
IStatus getStatus() {
if (fStatus == null)
- fStatus= new StatusInfo();
+ fStatus = new StatusInfo();
return fStatus;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java
index d22b11cbc2e..fb16e27aedd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java
@@ -15,7 +15,6 @@
package org.eclipse.cdt.internal.ui.preferences;
-
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -27,7 +26,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The page for setting the editor options.
*/
public final class MarkOccurrencesPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
+
/*
* @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
*/
@@ -41,10 +40,10 @@ public final class MarkOccurrencesPreferencePage extends AbstractConfigurationBl
*/
@Override
protected void setDescription() {
- String description= PreferencesMessages.MarkOccurrencesConfigurationBlock_title;
+ String description = PreferencesMessages.MarkOccurrencesConfigurationBlock_title;
setDescription(description);
}
-
+
/*
* @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
*/
@@ -52,8 +51,7 @@ public final class MarkOccurrencesPreferencePage extends AbstractConfigurationBl
protected void setPreferenceStore() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
}
-
-
+
@Override
protected Label createDescriptionLabel(Composite parent) {
return null; // no description for new look.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java
index 409af6065a0..f2939f9e8b0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java
@@ -63,195 +63,153 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_UPPER_CASE),
String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CASE),
String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE),
- String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE),
- };
+ String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE), };
private final String[] CAPITALIZATION_LABELS = {
String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_original),
String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_upper_case),
String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_lower_case),
String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_camel_case),
- String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_lower_camel_case),
- };
+ String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_lower_camel_case), };
- private static final Key KEY_CONSTANT_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_CONSTANT_CAPITALIZATION);
- private static final Key KEY_CONSTANT_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_CONSTANT_WORD_DELIMITER);
+ private static final Key KEY_CONSTANT_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_CONSTANT_CAPITALIZATION);
+ private static final Key KEY_CONSTANT_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_CONSTANT_WORD_DELIMITER);
private static final Key KEY_CONSTANT_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CONSTANT_PREFIX);
private static final Key KEY_CONSTANT_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CONSTANT_SUFFIX);
- private static final Key KEY_VARIABLE_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION);
- private static final Key KEY_VARIABLE_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER);
+ private static final Key KEY_VARIABLE_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION);
+ private static final Key KEY_VARIABLE_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER);
private static final Key KEY_VARIABLE_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX);
private static final Key KEY_VARIABLE_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX);
- private static final Key KEY_FIELD_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_FIELD_CAPITALIZATION);
- private static final Key KEY_FIELD_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_FIELD_WORD_DELIMITER);
+ private static final Key KEY_FIELD_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_FIELD_CAPITALIZATION);
+ private static final Key KEY_FIELD_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_FIELD_WORD_DELIMITER);
private static final Key KEY_FIELD_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_FIELD_PREFIX);
private static final Key KEY_FIELD_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_FIELD_SUFFIX);
- private static final Key KEY_METHOD_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_METHOD_CAPITALIZATION);
- private static final Key KEY_METHOD_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_METHOD_WORD_DELIMITER);
+ private static final Key KEY_METHOD_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_METHOD_CAPITALIZATION);
+ private static final Key KEY_METHOD_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_METHOD_WORD_DELIMITER);
private static final Key KEY_METHOD_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_METHOD_PREFIX);
private static final Key KEY_METHOD_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_METHOD_SUFFIX);
- private static final Key KEY_GETTER_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION);
- private static final Key KEY_GETTER_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER);
+ private static final Key KEY_GETTER_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION);
+ private static final Key KEY_GETTER_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER);
private static final Key KEY_GETTER_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_PREFIX);
- private static final Key KEY_GETTER_PREFIX_FOR_BOOLEAN = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN);
+ private static final Key KEY_GETTER_PREFIX_FOR_BOOLEAN = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN);
private static final Key KEY_GETTER_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_SUFFIX);
- private static final Key KEY_SETTER_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_SETTER_CAPITALIZATION);
- private static final Key KEY_SETTER_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_SETTER_WORD_DELIMITER);
+ private static final Key KEY_SETTER_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_SETTER_CAPITALIZATION);
+ private static final Key KEY_SETTER_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_SETTER_WORD_DELIMITER);
private static final Key KEY_SETTER_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_SETTER_PREFIX);
private static final Key KEY_SETTER_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_SETTER_SUFFIX);
- private static final Key KEY_CPP_SOURCE_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION);
- private static final Key KEY_CPP_SOURCE_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER);
+ private static final Key KEY_CPP_SOURCE_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION);
+ private static final Key KEY_CPP_SOURCE_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER);
private static final Key KEY_CPP_SOURCE_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_SOURCE_PREFIX);
private static final Key KEY_CPP_SOURCE_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_SOURCE_SUFFIX);
- private static final Key KEY_CPP_HEADER_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION);
- private static final Key KEY_CPP_HEADER_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER);
+ private static final Key KEY_CPP_HEADER_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION);
+ private static final Key KEY_CPP_HEADER_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER);
private static final Key KEY_CPP_HEADER_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX);
private static final Key KEY_CPP_HEADER_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_HEADER_SUFFIX);
- private static final Key KEY_CPP_TEST_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_TEST_CAPITALIZATION);
- private static final Key KEY_CPP_TEST_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_TEST_WORD_DELIMITER);
+ private static final Key KEY_CPP_TEST_CAPITALIZATION = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_CPP_TEST_CAPITALIZATION);
+ private static final Key KEY_CPP_TEST_WORD_DELIMITER = getCDTUIKey(
+ PreferenceConstants.NAME_STYLE_CPP_TEST_WORD_DELIMITER);
private static final Key KEY_CPP_TEST_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_TEST_PREFIX);
private static final Key KEY_CPP_TEST_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_TEST_SUFFIX);
- private static final Key KEY_INCLUDE_GUARD_SCHEME = getCDTUIKey(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME);
+ private static final Key KEY_INCLUDE_GUARD_SCHEME = getCDTUIKey(
+ PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME);
private static final IdentifierValidator IDENTIFIER_VALIDATOR = new IdentifierValidator();
private static final FilenameValidator FILENAME_VALIDATOR = new FilenameValidator();
private static Key[] getAllKeys() {
- return new Key[] {
- KEY_CONSTANT_CAPITALIZATION,
- KEY_CONSTANT_WORD_DELIMITER,
- KEY_CONSTANT_PREFIX,
- KEY_CONSTANT_SUFFIX,
- KEY_VARIABLE_CAPITALIZATION,
- KEY_VARIABLE_WORD_DELIMITER,
- KEY_VARIABLE_PREFIX,
- KEY_VARIABLE_SUFFIX,
- KEY_FIELD_CAPITALIZATION,
- KEY_FIELD_WORD_DELIMITER,
- KEY_FIELD_PREFIX,
- KEY_FIELD_SUFFIX,
- KEY_METHOD_CAPITALIZATION,
- KEY_METHOD_WORD_DELIMITER,
- KEY_METHOD_PREFIX,
- KEY_METHOD_SUFFIX,
- KEY_GETTER_CAPITALIZATION,
- KEY_GETTER_WORD_DELIMITER,
- KEY_GETTER_PREFIX,
- KEY_GETTER_PREFIX_FOR_BOOLEAN,
- KEY_GETTER_SUFFIX,
- KEY_SETTER_CAPITALIZATION,
- KEY_SETTER_WORD_DELIMITER,
- KEY_SETTER_PREFIX,
- KEY_SETTER_SUFFIX,
- KEY_CPP_SOURCE_CAPITALIZATION,
- KEY_CPP_SOURCE_WORD_DELIMITER,
- KEY_CPP_SOURCE_PREFIX,
- KEY_CPP_SOURCE_SUFFIX,
- KEY_CPP_HEADER_CAPITALIZATION,
- KEY_CPP_HEADER_WORD_DELIMITER,
- KEY_CPP_HEADER_PREFIX,
- KEY_CPP_HEADER_SUFFIX,
- KEY_CPP_TEST_CAPITALIZATION,
- KEY_CPP_TEST_WORD_DELIMITER,
- KEY_CPP_TEST_PREFIX,
- KEY_CPP_TEST_SUFFIX,
- KEY_INCLUDE_GUARD_SCHEME,
- };
+ return new Key[] { KEY_CONSTANT_CAPITALIZATION, KEY_CONSTANT_WORD_DELIMITER, KEY_CONSTANT_PREFIX,
+ KEY_CONSTANT_SUFFIX, KEY_VARIABLE_CAPITALIZATION, KEY_VARIABLE_WORD_DELIMITER, KEY_VARIABLE_PREFIX,
+ KEY_VARIABLE_SUFFIX, KEY_FIELD_CAPITALIZATION, KEY_FIELD_WORD_DELIMITER, KEY_FIELD_PREFIX,
+ KEY_FIELD_SUFFIX, KEY_METHOD_CAPITALIZATION, KEY_METHOD_WORD_DELIMITER, KEY_METHOD_PREFIX,
+ KEY_METHOD_SUFFIX, KEY_GETTER_CAPITALIZATION, KEY_GETTER_WORD_DELIMITER, KEY_GETTER_PREFIX,
+ KEY_GETTER_PREFIX_FOR_BOOLEAN, KEY_GETTER_SUFFIX, KEY_SETTER_CAPITALIZATION, KEY_SETTER_WORD_DELIMITER,
+ KEY_SETTER_PREFIX, KEY_SETTER_SUFFIX, KEY_CPP_SOURCE_CAPITALIZATION, KEY_CPP_SOURCE_WORD_DELIMITER,
+ KEY_CPP_SOURCE_PREFIX, KEY_CPP_SOURCE_SUFFIX, KEY_CPP_HEADER_CAPITALIZATION,
+ KEY_CPP_HEADER_WORD_DELIMITER, KEY_CPP_HEADER_PREFIX, KEY_CPP_HEADER_SUFFIX,
+ KEY_CPP_TEST_CAPITALIZATION, KEY_CPP_TEST_WORD_DELIMITER, KEY_CPP_TEST_PREFIX, KEY_CPP_TEST_SUFFIX,
+ KEY_INCLUDE_GUARD_SCHEME, };
}
- private final Category[] rootCategories;
+ private final Category[] rootCategories;
private TreeListDialogField<Category> categoryTree;
private PixelConverter pixelConverter;
private StackLayout editorAreaStack;
private Category selectedCategory;
- public NameStyleBlock(IStatusChangeListener context, IProject project,
- IWorkbenchPreferenceContainer container) {
+ public NameStyleBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
super(context, project, getAllKeys(), container);
rootCategories = createCategories();
}
private Category[] createCategories() {
- Category codeCategory = new Category(PreferencesMessages.NameStyleBlock_code_node);
+ Category codeCategory = new Category(PreferencesMessages.NameStyleBlock_code_node);
new Category(PreferencesMessages.NameStyleBlock_constant_node,
- PreferencesMessages.NameStyleBlock_constant_node_description, EXAMPLE_CONSTANT_NAME,
- codeCategory)
- .setCapitalizationKey(KEY_CONSTANT_CAPITALIZATION)
- .setWordDelimiterKey(KEY_CONSTANT_WORD_DELIMITER)
- .setPrefixKey(KEY_CONSTANT_PREFIX)
- .setSuffixKey(KEY_CONSTANT_SUFFIX)
- .setNameValidator(IDENTIFIER_VALIDATOR);
+ PreferencesMessages.NameStyleBlock_constant_node_description, EXAMPLE_CONSTANT_NAME, codeCategory)
+ .setCapitalizationKey(KEY_CONSTANT_CAPITALIZATION)
+ .setWordDelimiterKey(KEY_CONSTANT_WORD_DELIMITER).setPrefixKey(KEY_CONSTANT_PREFIX)
+ .setSuffixKey(KEY_CONSTANT_SUFFIX).setNameValidator(IDENTIFIER_VALIDATOR);
new Category(PreferencesMessages.NameStyleBlock_variable_node,
- PreferencesMessages.NameStyleBlock_variable_node_description, EXAMPLE_VARIABLE_NAME,
- codeCategory)
- .setCapitalizationKey(KEY_VARIABLE_CAPITALIZATION)
- .setWordDelimiterKey(KEY_VARIABLE_WORD_DELIMITER)
- .setPrefixKey(KEY_VARIABLE_PREFIX)
- .setSuffixKey(KEY_VARIABLE_SUFFIX)
- .setNameValidator(IDENTIFIER_VALIDATOR);
+ PreferencesMessages.NameStyleBlock_variable_node_description, EXAMPLE_VARIABLE_NAME, codeCategory)
+ .setCapitalizationKey(KEY_VARIABLE_CAPITALIZATION)
+ .setWordDelimiterKey(KEY_VARIABLE_WORD_DELIMITER).setPrefixKey(KEY_VARIABLE_PREFIX)
+ .setSuffixKey(KEY_VARIABLE_SUFFIX).setNameValidator(IDENTIFIER_VALIDATOR);
Category fieldCategory = new Category(PreferencesMessages.NameStyleBlock_field_node,
- PreferencesMessages.NameStyleBlock_field_node_description, EXAMPLE_FIELD_NAME,
- codeCategory)
- .setCapitalizationKey(KEY_FIELD_CAPITALIZATION)
- .setWordDelimiterKey(KEY_FIELD_WORD_DELIMITER)
- .setPrefixKey(KEY_FIELD_PREFIX)
- .setSuffixKey(KEY_FIELD_SUFFIX)
- .setNameValidator(IDENTIFIER_VALIDATOR);
+ PreferencesMessages.NameStyleBlock_field_node_description, EXAMPLE_FIELD_NAME, codeCategory)
+ .setCapitalizationKey(KEY_FIELD_CAPITALIZATION).setWordDelimiterKey(KEY_FIELD_WORD_DELIMITER)
+ .setPrefixKey(KEY_FIELD_PREFIX).setSuffixKey(KEY_FIELD_SUFFIX)
+ .setNameValidator(IDENTIFIER_VALIDATOR);
new Category(PreferencesMessages.NameStyleBlock_method_node,
- PreferencesMessages.NameStyleBlock_method_node_description, EXAMPLE_METHOD_NAME,
- codeCategory)
- .setCapitalizationKey(KEY_METHOD_CAPITALIZATION)
- .setWordDelimiterKey(KEY_METHOD_WORD_DELIMITER)
- .setPrefixKey(KEY_METHOD_PREFIX)
- .setSuffixKey(KEY_METHOD_SUFFIX)
- .setNameValidator(IDENTIFIER_VALIDATOR);
+ PreferencesMessages.NameStyleBlock_method_node_description, EXAMPLE_METHOD_NAME, codeCategory)
+ .setCapitalizationKey(KEY_METHOD_CAPITALIZATION).setWordDelimiterKey(KEY_METHOD_WORD_DELIMITER)
+ .setPrefixKey(KEY_METHOD_PREFIX).setSuffixKey(KEY_METHOD_SUFFIX)
+ .setNameValidator(IDENTIFIER_VALIDATOR);
new Category(PreferencesMessages.NameStyleBlock_getter_node,
- PreferencesMessages.NameStyleBlock_getter_node_description, EXAMPLE_FIELD_NAME,
- codeCategory)
- .setCapitalizationKey(KEY_GETTER_CAPITALIZATION)
- .setWordDelimiterKey(KEY_GETTER_WORD_DELIMITER)
- .setPrefixKey(KEY_GETTER_PREFIX)
- .setAlternativePrefixKey(KEY_GETTER_PREFIX_FOR_BOOLEAN)
- .setSuffixKey(KEY_GETTER_SUFFIX)
- .setSeedNameGenerator(fieldCategory)
- .setNameValidator(IDENTIFIER_VALIDATOR)
- .setTrimFieldName(true);
+ PreferencesMessages.NameStyleBlock_getter_node_description, EXAMPLE_FIELD_NAME, codeCategory)
+ .setCapitalizationKey(KEY_GETTER_CAPITALIZATION).setWordDelimiterKey(KEY_GETTER_WORD_DELIMITER)
+ .setPrefixKey(KEY_GETTER_PREFIX).setAlternativePrefixKey(KEY_GETTER_PREFIX_FOR_BOOLEAN)
+ .setSuffixKey(KEY_GETTER_SUFFIX).setSeedNameGenerator(fieldCategory)
+ .setNameValidator(IDENTIFIER_VALIDATOR).setTrimFieldName(true);
new Category(PreferencesMessages.NameStyleBlock_setter_node,
- PreferencesMessages.NameStyleBlock_setter_node_description, EXAMPLE_FIELD_NAME,
- codeCategory)
- .setCapitalizationKey(KEY_SETTER_CAPITALIZATION)
- .setWordDelimiterKey(KEY_SETTER_WORD_DELIMITER)
- .setPrefixKey(KEY_SETTER_PREFIX)
- .setSuffixKey(KEY_SETTER_SUFFIX)
- .setSeedNameGenerator(fieldCategory)
- .setNameValidator(IDENTIFIER_VALIDATOR)
- .setTrimFieldName(true);
+ PreferencesMessages.NameStyleBlock_setter_node_description, EXAMPLE_FIELD_NAME, codeCategory)
+ .setCapitalizationKey(KEY_SETTER_CAPITALIZATION).setWordDelimiterKey(KEY_SETTER_WORD_DELIMITER)
+ .setPrefixKey(KEY_SETTER_PREFIX).setSuffixKey(KEY_SETTER_SUFFIX)
+ .setSeedNameGenerator(fieldCategory).setNameValidator(IDENTIFIER_VALIDATOR)
+ .setTrimFieldName(true);
new IncludeGuardCategory(codeCategory);
Category fileCategory = new Category(PreferencesMessages.NameStyleBlock_files_node);
new Category(PreferencesMessages.NameStyleBlock_cpp_header_node,
- PreferencesMessages.NameStyleBlock_cpp_header_node_description, EXAMPLE_CLASS_NAME,
- fileCategory)
- .setCapitalizationKey(KEY_CPP_HEADER_CAPITALIZATION)
- .setWordDelimiterKey(KEY_CPP_HEADER_WORD_DELIMITER)
- .setPrefixKey(KEY_CPP_HEADER_PREFIX)
- .setSuffixKey(KEY_CPP_HEADER_SUFFIX)
- .setNameValidator(FILENAME_VALIDATOR);
+ PreferencesMessages.NameStyleBlock_cpp_header_node_description, EXAMPLE_CLASS_NAME, fileCategory)
+ .setCapitalizationKey(KEY_CPP_HEADER_CAPITALIZATION)
+ .setWordDelimiterKey(KEY_CPP_HEADER_WORD_DELIMITER).setPrefixKey(KEY_CPP_HEADER_PREFIX)
+ .setSuffixKey(KEY_CPP_HEADER_SUFFIX).setNameValidator(FILENAME_VALIDATOR);
new Category(PreferencesMessages.NameStyleBlock_cpp_source_node,
- PreferencesMessages.NameStyleBlock_cpp_source_node_description, EXAMPLE_CLASS_NAME,
- fileCategory)
- .setCapitalizationKey(KEY_CPP_SOURCE_CAPITALIZATION)
- .setWordDelimiterKey(KEY_CPP_SOURCE_WORD_DELIMITER)
- .setPrefixKey(KEY_CPP_SOURCE_PREFIX)
- .setSuffixKey(KEY_CPP_SOURCE_SUFFIX)
- .setNameValidator(FILENAME_VALIDATOR);
+ PreferencesMessages.NameStyleBlock_cpp_source_node_description, EXAMPLE_CLASS_NAME, fileCategory)
+ .setCapitalizationKey(KEY_CPP_SOURCE_CAPITALIZATION)
+ .setWordDelimiterKey(KEY_CPP_SOURCE_WORD_DELIMITER).setPrefixKey(KEY_CPP_SOURCE_PREFIX)
+ .setSuffixKey(KEY_CPP_SOURCE_SUFFIX).setNameValidator(FILENAME_VALIDATOR);
new Category(PreferencesMessages.NameStyleBlock_cpp_test_node,
- PreferencesMessages.NameStyleBlock_cpp_test_node_description, EXAMPLE_CLASS_NAME,
- fileCategory)
- .setCapitalizationKey(KEY_CPP_TEST_CAPITALIZATION)
- .setWordDelimiterKey(KEY_CPP_TEST_WORD_DELIMITER)
- .setPrefixKey(KEY_CPP_TEST_PREFIX)
- .setSuffixKey(KEY_CPP_TEST_SUFFIX)
- .setNameValidator(FILENAME_VALIDATOR);
+ PreferencesMessages.NameStyleBlock_cpp_test_node_description, EXAMPLE_CLASS_NAME, fileCategory)
+ .setCapitalizationKey(KEY_CPP_TEST_CAPITALIZATION)
+ .setWordDelimiterKey(KEY_CPP_TEST_WORD_DELIMITER).setPrefixKey(KEY_CPP_TEST_PREFIX)
+ .setSuffixKey(KEY_CPP_TEST_SUFFIX).setNameValidator(FILENAME_VALIDATOR);
return new Category[] { codeCategory, fileCategory };
}
@@ -261,11 +219,11 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
@Override
protected Control createContents(Composite parent) {
- pixelConverter = new PixelConverter(parent);
+ pixelConverter = new PixelConverter(parent);
setShell(parent.getShell());
- Composite composite = new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setFont(parent.getFont());
GridLayout layout = new GridLayout();
@@ -308,7 +266,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
}
private void createCategoryEditorArea(Composite parent) {
- Composite editorArea = new Composite(parent, SWT.NONE);
+ Composite editorArea = new Composite(parent, SWT.NONE);
editorArea.setLayoutData(new GridData(GridData.FILL_BOTH));
editorArea.setFont(parent.getFont());
editorAreaStack = new StackLayout();
@@ -319,7 +277,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
}
private void createCategoryEditor(Composite parent, Category category) {
- Composite composite = new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = pixelConverter.convertHeightInCharsToPixels(1);
layout.marginWidth = 0;
@@ -327,7 +285,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
composite.setFont(parent.getFont());
if (category.isConcrete()) {
- Group group = ControlFactory.createGroup(composite, category.description, 1);
+ Group group = ControlFactory.createGroup(composite, category.description, 1);
Composite envelope = new Composite(group, SWT.NONE);
layout = new GridLayout(4, false);
@@ -339,21 +297,23 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
envelope.setLayoutData(new GridData(GridData.FILL_BOTH));
addRadioButton(envelope, PreferencesMessages.NameStyleBlock_file_path_relative_to_source_folder,
KEY_INCLUDE_GUARD_SCHEME,
- new String[] { String.valueOf(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_PATH), null },
+ new String[] {
+ String.valueOf(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_PATH),
+ null },
0);
- addRadioButton(envelope, PreferencesMessages.NameStyleBlock_file_name,
- KEY_INCLUDE_GUARD_SCHEME,
- new String[] { String.valueOf(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME), null },
+ addRadioButton(envelope, PreferencesMessages.NameStyleBlock_file_name, KEY_INCLUDE_GUARD_SCHEME,
+ new String[] {
+ String.valueOf(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME),
+ null },
0);
- addRadioButton(envelope, PreferencesMessages.NameStyleBlock_unique_identifier,
- KEY_INCLUDE_GUARD_SCHEME,
- new String[] { String.valueOf(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_UUID), null },
+ addRadioButton(envelope, PreferencesMessages.NameStyleBlock_unique_identifier, KEY_INCLUDE_GUARD_SCHEME,
+ new String[] { String.valueOf(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_UUID),
+ null },
0);
} else {
envelope.setLayoutData(new GridData(GridData.FILL_VERTICAL));
Control control = addComboBox(envelope, PreferencesMessages.NameStyleBlock_capitalization_label,
- category.getCapitalizationKey(), CAPITALIZATION_VALUES,
- CAPITALIZATION_LABELS, 0);
+ category.getCapitalizationKey(), CAPITALIZATION_VALUES, CAPITALIZATION_LABELS, 0);
LayoutUtil.setHorizontalSpan(getLabel(control), 1);
LayoutUtil.setHorizontalSpan(control, 3);
control = addTextField(envelope, PreferencesMessages.NameStyleBlock_word_delimiter_label,
@@ -430,8 +390,8 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
StatusInfo status = new StatusInfo();
if (selectedCategory != null && changedKey != null) {
NameValidator validator = selectedCategory.getNameValidator();
- if (changedKey.equals(selectedCategory.getPrefixKey()) ||
- changedKey.equals(selectedCategory.getAlternativePrefixKey())) {
+ if (changedKey.equals(selectedCategory.getPrefixKey())
+ || changedKey.equals(selectedCategory.getAlternativePrefixKey())) {
if (!validator.isValidStart(newValue)) {
status.setError(PreferencesMessages.NameStyleBlock_invalid_prefix);
}
@@ -449,14 +409,14 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
fContext.statusChanged(status);
}
- /**
- * Represents a category of settings.
- */
+ /**
+ * Represents a category of settings.
+ */
private static class Category {
public final String name;
public final String description;
public final Category parent;
- public final int index; // Index in the siblings list
+ public final int index; // Index in the siblings list
private final List<Category> children;
private Key capitalizationKey;
private Key wordDelimiterKey;
@@ -484,7 +444,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
* @param name Category name
*/
Category(String name) {
- this(name, null, null, null);
+ this(name, null, null, null);
}
private int addChild(Category category) {
@@ -592,8 +552,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
String prefix = settings.getValue(prefixKey);
String suffix = settings.getValue(suffixKey);
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
- String name = seedNameGenerator != null ?
- seedNameGenerator.composeExampleName(settings) : seedName;
+ String name = seedNameGenerator != null ? seedNameGenerator.composeExampleName(settings) : seedName;
if (trimFieldName) {
name = StubUtility.trimFieldName(name);
}
@@ -610,7 +569,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
super(PreferencesMessages.NameStyleBlock_include_guard_node,
PreferencesMessages.NameStyleBlock_include_guard_node_description, null, parent);
}
-
+
@Override
String composeExampleName(NameStyleBlock settings) {
int scheme = Integer.parseInt(settings.getValue(KEY_INCLUDE_GUARD_SCHEME));
@@ -650,6 +609,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
}
abstract boolean isValidStart(char ch);
+
abstract boolean isValidPart(char ch);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java
index a670690e0f5..eb79d8be30d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java
@@ -23,13 +23,13 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The preference page for configuring styles of names.
*/
public class NameStylePreferencePage extends ConfigurationBlockPropertyAndPreferencePage {
- public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.NameStylePreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.NameStylePreferencePage"; //$NON-NLS-1$
+ public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.NameStylePreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.NameStylePreferencePage"; //$NON-NLS-1$
public NameStylePreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
// Only used when the page is shown programmatically.
- setTitle(PreferencesMessages.NameStylePreferencePage_title);
+ setTitle(PreferencesMessages.NameStylePreferencePage_title);
}
@Override
@@ -51,6 +51,6 @@ public class NameStylePreferencePage extends ConfigurationBlockPropertyAndPrefer
protected String getPropertyPageId() {
return null;
// TODO(sprigogin): Project specific settings
-// return PROP_ID;
+ // return PROP_ID;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java
index 0f4ba9a2e40..fd7bb61ce87 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java
@@ -67,16 +67,16 @@ import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
* an options configuration page.
*/
public abstract class OptionsConfigurationBlock {
- protected static final String[] FALSE_TRUE = new String[] { "false", "true" }; //$NON-NLS-1$//$NON-NLS-2$
- protected static final String[] TRUE_FALSE = new String[] { "true", "false" }; //$NON-NLS-1$//$NON-NLS-2$
+ protected static final String[] FALSE_TRUE = new String[] { "false", "true" }; //$NON-NLS-1$//$NON-NLS-2$
+ protected static final String[] TRUE_FALSE = new String[] { "true", "false" }; //$NON-NLS-1$//$NON-NLS-2$
public static final class Key {
private final String fQualifier;
private final String fKey;
public Key(String qualifier, String key) {
- fQualifier= qualifier;
- fKey= key;
+ fQualifier = qualifier;
+ fKey = key;
}
public String getName() {
@@ -84,7 +84,7 @@ public abstract class OptionsConfigurationBlock {
}
private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
- IEclipsePreferences node= context.getNode(fQualifier);
+ IEclipsePreferences node = context.getNode(fQualifier);
if (manager != null) {
return manager.getWorkingCopy(node);
}
@@ -96,8 +96,8 @@ public abstract class OptionsConfigurationBlock {
}
public String getStoredValue(IScopeContext[] lookupOrder, boolean ignoreTopScope, IWorkingCopyManager manager) {
- for (int i= ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++) {
- String value= getStoredValue(lookupOrder[i], manager);
+ for (int i = ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++) {
+ String value = getStoredValue(lookupOrder[i], manager);
if (value != null) {
return value;
}
@@ -128,8 +128,8 @@ public abstract class OptionsConfigurationBlock {
private final String[] fValues;
public ControlData(Key key, String[] values) {
- fKey= key;
- fValues= values;
+ fKey = key;
+ fValues = values;
}
public Key getKey() {
@@ -137,7 +137,7 @@ public abstract class OptionsConfigurationBlock {
}
public String getValue(boolean selection) {
- int index= selection ? 0 : 1;
+ int index = selection ? 0 : 1;
return fValues[index];
}
@@ -147,7 +147,7 @@ public abstract class OptionsConfigurationBlock {
public int getSelection(String value) {
if (value != null) {
- for (int i= 0; i < fValues.length; i++) {
+ for (int i = 0; i < fValues.length; i++) {
if (value.equals(fValues[i])) {
return i;
}
@@ -157,9 +157,9 @@ public abstract class OptionsConfigurationBlock {
}
}
- private static final String REBUILD_COUNT_KEY= "preferences_build_requested"; //$NON-NLS-1$
+ private static final String REBUILD_COUNT_KEY = "preferences_build_requested"; //$NON-NLS-1$
- private static final String SETTINGS_EXPANDED= "expanded"; //$NON-NLS-1$
+ private static final String SETTINGS_EXPANDED = "expanded"; //$NON-NLS-1$
protected final ArrayList<Button> fCheckBoxes;
protected final ArrayList<Combo> fComboBoxes;
@@ -187,49 +187,43 @@ public abstract class OptionsConfigurationBlock {
public OptionsConfigurationBlock(IStatusChangeListener context, IProject project, Key[] allKeys,
IWorkbenchPreferenceContainer container) {
- fContext= context;
- fProject= project;
- fAllKeys= allKeys;
- fContainer= container;
+ fContext = context;
+ fProject = project;
+ fAllKeys = allKeys;
+ fContainer = container;
if (container == null) {
- fManager= new WorkingCopyManager();
+ fManager = new WorkingCopyManager();
} else {
- fManager= container.getWorkingCopyManager();
+ fManager = container.getWorkingCopyManager();
}
if (fProject != null) {
- fLookupOrder= new IScopeContext[] {
- new ProjectScope(fProject),
- InstanceScope.INSTANCE,
- DefaultScope.INSTANCE
- };
+ fLookupOrder = new IScopeContext[] { new ProjectScope(fProject), InstanceScope.INSTANCE,
+ DefaultScope.INSTANCE };
} else {
- fLookupOrder= new IScopeContext[] {
- InstanceScope.INSTANCE,
- DefaultScope.INSTANCE
- };
+ fLookupOrder = new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE };
}
checkIfOptionsComplete(allKeys);
if (fProject == null || hasProjectSpecificOptions(fProject)) {
- fDisabledProjectSettings= null;
+ fDisabledProjectSettings = null;
} else {
- fDisabledProjectSettings= new IdentityHashMap<Key, String>();
- for (int i= 0; i < allKeys.length; i++) {
- Key curr= allKeys[i];
+ fDisabledProjectSettings = new IdentityHashMap<Key, String>();
+ for (int i = 0; i < allKeys.length; i++) {
+ Key curr = allKeys[i];
fDisabledProjectSettings.put(curr, curr.getStoredValue(fLookupOrder, false, fManager));
}
}
settingsUpdated();
- fCheckBoxes= new ArrayList<Button>();
- fComboBoxes= new ArrayList<Combo>();
- fTextBoxes= new ArrayList<Text>(2);
- fLabels= new HashMap<Control, Label>();
- fExpandedComposites= new ArrayList<ExpandableComposite>();
+ fCheckBoxes = new ArrayList<Button>();
+ fComboBoxes = new ArrayList<Combo>();
+ fTextBoxes = new ArrayList<Text>(2);
+ fLabels = new HashMap<Control, Label>();
+ fExpandedComposites = new ArrayList<ExpandableComposite>();
- fRebuildCount= getRebuildCount();
+ fRebuildCount = getRebuildCount();
}
protected final IWorkbenchPreferenceContainer getPreferenceContainer() {
@@ -249,9 +243,9 @@ public abstract class OptionsConfigurationBlock {
}
private void checkIfOptionsComplete(Key[] allKeys) {
- for (int i= 0; i < allKeys.length; i++) {
+ for (int i = 0; i < allKeys.length; i++) {
if (allKeys[i].getStoredValue(fLookupOrder, false, fManager) == null) {
- CUIPlugin.logError("Preference option missing: " + allKeys[i] + " (" + this.getClass().getName() +')'); //$NON-NLS-1$//$NON-NLS-2$
+ CUIPlugin.logError("Preference option missing: " + allKeys[i] + " (" + this.getClass().getName() + ')'); //$NON-NLS-1$//$NON-NLS-2$
}
}
}
@@ -262,15 +256,16 @@ public abstract class OptionsConfigurationBlock {
private void incrementRebuildCount() {
fRebuildCount++;
- fManager.getWorkingCopy(DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID)).putInt(REBUILD_COUNT_KEY, fRebuildCount);
+ fManager.getWorkingCopy(DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID)).putInt(REBUILD_COUNT_KEY,
+ fRebuildCount);
}
protected void settingsUpdated() {
}
public void selectOption(String key, String qualifier) {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
+ for (int i = 0; i < fAllKeys.length; i++) {
+ Key curr = fAllKeys[i];
if (curr.getName().equals(key) && curr.getQualifier().equals(qualifier)) {
selectOption(curr);
}
@@ -278,13 +273,13 @@ public abstract class OptionsConfigurationBlock {
}
public void selectOption(Key key) {
- Control control= findControl(key);
+ Control control = findControl(key);
if (control != null) {
if (!fExpandedComposites.isEmpty()) {
- ExpandableComposite expandable= getParentExpandableComposite(control);
+ ExpandableComposite expandable = getParentExpandableComposite(control);
if (expandable != null) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite curr= fExpandedComposites.get(i);
+ for (int i = 0; i < fExpandedComposites.size(); i++) {
+ ExpandableComposite curr = fExpandedComposites.get(i);
curr.setExpanded(curr == expandable);
}
expandedStateChanged(expandable);
@@ -296,9 +291,9 @@ public abstract class OptionsConfigurationBlock {
public boolean hasProjectSpecificOptions(IProject project) {
if (project != null) {
- IScopeContext projectContext= new ProjectScope(project);
- Key[] allKeys= fAllKeys;
- for (int i= 0; i < allKeys.length; i++) {
+ IScopeContext projectContext = new ProjectScope(project);
+ Key[] allKeys = fAllKeys;
+ for (int i = 0; i < allKeys.length; i++) {
if (allKeys[i].getStoredValue(projectContext, fManager) != null) {
return true;
}
@@ -312,19 +307,19 @@ public abstract class OptionsConfigurationBlock {
}
protected void setShell(Shell shell) {
- fShell= shell;
+ fShell = shell;
}
protected abstract Control createContents(Composite parent);
protected Button addCheckBox(Composite parent, String label, Key key, String[] values, int indent) {
- ControlData data= new ControlData(key, values);
+ ControlData data = new ControlData(key, values);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 3;
- gd.horizontalIndent= indent;
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
+ gd.horizontalIndent = indent;
- Button checkBox= new Button(parent, SWT.CHECK);
+ Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setFont(JFaceResources.getDialogFont());
checkBox.setText(label);
checkBox.setData(data);
@@ -333,7 +328,7 @@ public abstract class OptionsConfigurationBlock {
makeScrollableCompositeAware(checkBox);
- String currValue= getValue(key);
+ String currValue = getValue(key);
checkBox.setSelection(data.getSelection(currValue) == 0);
fCheckBoxes.add(checkBox);
@@ -341,32 +336,32 @@ public abstract class OptionsConfigurationBlock {
return checkBox;
}
- protected Button addCheckBoxWithLink(Composite parent, String label, Key key, String[] values,
- int indent, int widthHint, SelectionListener listener) {
- ControlData data= new ControlData(key, values);
+ protected Button addCheckBoxWithLink(Composite parent, String label, Key key, String[] values, int indent,
+ int widthHint, SelectionListener listener) {
+ ControlData data = new ControlData(key, values);
- GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false);
- gd.horizontalSpan= 3;
- gd.horizontalIndent= indent;
+ GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false);
+ gd.horizontalSpan = 3;
+ gd.horizontalIndent = indent;
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
composite.setLayout(layout);
composite.setLayoutData(gd);
- Button checkBox= new Button(composite, SWT.CHECK);
+ Button checkBox = new Button(composite, SWT.CHECK);
checkBox.setFont(JFaceResources.getDialogFont());
checkBox.setData(data);
checkBox.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
checkBox.addSelectionListener(getSelectionListener());
- gd= new GridData(GridData.FILL, GridData.CENTER, true, false);
- gd.widthHint= widthHint;
+ gd = new GridData(GridData.FILL, GridData.CENTER, true, false);
+ gd.widthHint = widthHint;
- Link link= new Link(composite, SWT.NONE);
+ Link link = new Link(composite, SWT.NONE);
link.setText(label);
link.setLayoutData(gd);
if (listener != null) {
@@ -376,7 +371,7 @@ public abstract class OptionsConfigurationBlock {
makeScrollableCompositeAware(link);
makeScrollableCompositeAware(checkBox);
- String currValue= getValue(key);
+ String currValue = getValue(key);
checkBox.setSelection(data.getSelection(currValue) == 0);
fCheckBoxes.add(checkBox);
@@ -385,40 +380,40 @@ public abstract class OptionsConfigurationBlock {
}
protected Button addRadioButton(Composite parent, String label, Key key, String[] values, int indent) {
- ControlData data= new ControlData(key, values);
+ ControlData data = new ControlData(key, values);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 4;
-// gd.horizontalIndent= indent;
+ gd.horizontalSpan = 4;
+ // gd.horizontalIndent= indent;
- Button radioButton= new Button(parent, SWT.RADIO);
+ Button radioButton = new Button(parent, SWT.RADIO);
radioButton.setFont(JFaceResources.getDialogFont());
radioButton.setText(label);
radioButton.setData(data);
radioButton.setLayoutData(gd);
radioButton.addSelectionListener(getSelectionListener());
-// makeScrollableCompositeAware(radioButton);
+ // makeScrollableCompositeAware(radioButton);
- String currValue= getValue(key);
+ String currValue = getValue(key);
radioButton.setSelection(data.getSelection(currValue) == 0);
fCheckBoxes.add(radioButton);
return radioButton;
}
-
- protected Combo addComboBox(Composite parent, String label, Key key, String[] values,
- String[] valueLabels, int indent) {
- GridData gd= new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1);
- gd.horizontalIndent= indent;
- Label labelControl= new Label(parent, SWT.LEFT);
+ protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels,
+ int indent) {
+ GridData gd = new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1);
+ gd.horizontalIndent = indent;
+
+ Label labelControl = new Label(parent, SWT.LEFT);
labelControl.setFont(JFaceResources.getDialogFont());
labelControl.setText(label);
labelControl.setLayoutData(gd);
- Combo comboBox= newComboControl(parent, key, values, valueLabels);
+ Combo comboBox = newComboControl(parent, key, values, valueLabels);
comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
fLabels.put(comboBox, labelControl);
@@ -426,25 +421,25 @@ public abstract class OptionsConfigurationBlock {
return comboBox;
}
- protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values,
- String[] valueLabels, int indent) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indent;
- gd.horizontalSpan= 3;
+ protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels,
+ int indent) {
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = indent;
+ gd.horizontalSpan = 3;
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
composite.setLayout(layout);
composite.setLayoutData(gd);
- Combo comboBox= newComboControl(composite, key, values, valueLabels);
+ Combo comboBox = newComboControl(composite, key, values, valueLabels);
comboBox.setFont(JFaceResources.getDialogFont());
comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- Label labelControl= new Label(composite, SWT.LEFT | SWT.WRAP);
+ Label labelControl = new Label(composite, SWT.LEFT | SWT.WRAP);
labelControl.setText(label);
labelControl.setLayoutData(new GridData());
@@ -453,9 +448,9 @@ public abstract class OptionsConfigurationBlock {
}
protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels) {
- ControlData data= new ControlData(key, values);
+ ControlData data = new ControlData(key, values);
- Combo comboBox= new Combo(composite, SWT.READ_ONLY);
+ Combo comboBox = new Combo(composite, SWT.READ_ONLY);
comboBox.setItems(valueLabels);
comboBox.setData(data);
comboBox.addSelectionListener(getSelectionListener());
@@ -463,7 +458,7 @@ public abstract class OptionsConfigurationBlock {
makeScrollableCompositeAware(comboBox);
- String currValue= getValue(key);
+ String currValue = getValue(key);
comboBox.select(data.getSelection(currValue));
fComboBoxes.add(comboBox);
@@ -474,16 +469,15 @@ public abstract class OptionsConfigurationBlock {
return addTextField(parent, label, key, indent, widthHint, SWT.NONE);
}
- protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint,
- int extraStyle) {
- Label labelControl= new Label(parent, SWT.WRAP);
+ protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint, int extraStyle) {
+ Label labelControl = new Label(parent, SWT.WRAP);
labelControl.setText(label);
labelControl.setFont(JFaceResources.getDialogFont());
- GridData data= new GridData();
- data.horizontalIndent= indent;
+ GridData data = new GridData();
+ data.horizontalIndent = indent;
labelControl.setLayoutData(data);
- Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE | extraStyle);
+ Text textBox = new Text(parent, SWT.BORDER | SWT.SINGLE | extraStyle);
textBox.setData(key);
makeScrollableCompositeAware(textBox);
@@ -491,18 +485,18 @@ public abstract class OptionsConfigurationBlock {
fLabels.put(textBox, labelControl);
if (key != null) {
- String currValue= getValue(key);
+ String currValue = getValue(key);
if (currValue != null) {
textBox.setText(currValue);
}
textBox.addModifyListener(getTextModifyListener());
}
- data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
if (widthHint != 0) {
- data.widthHint= widthHint;
+ data.widthHint = widthHint;
}
- data.horizontalSpan= 2;
+ data.horizontalSpan = 2;
textBox.setLayoutData(data);
fTextBoxes.add(textBox);
@@ -510,17 +504,17 @@ public abstract class OptionsConfigurationBlock {
}
protected Composite addSubsection(Composite parent, String label) {
- Group group= new Group(parent, SWT.SHADOW_NONE);
+ Group group = new Group(parent, SWT.SHADOW_NONE);
group.setText(label);
- GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false);
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
group.setLayoutData(data);
return group;
}
protected ScrolledPageContent getParentScrolledComposite(Control control) {
- Control parent= control.getParent();
+ Control parent = control.getParent();
while (!(parent instanceof ScrolledPageContent) && parent != null) {
- parent= parent.getParent();
+ parent = parent.getParent();
}
if (parent instanceof ScrolledPageContent) {
return (ScrolledPageContent) parent;
@@ -529,9 +523,9 @@ public abstract class OptionsConfigurationBlock {
}
protected ExpandableComposite getParentExpandableComposite(Control control) {
- Control parent= control.getParent();
+ Control parent = control.getParent();
while (!(parent instanceof ExpandableComposite) && parent != null) {
- parent= parent.getParent();
+ parent = parent.getParent();
}
if (parent instanceof ExpandableComposite) {
return (ExpandableComposite) parent;
@@ -540,14 +534,14 @@ public abstract class OptionsConfigurationBlock {
}
protected void makeScrollableCompositeAware(Control control) {
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
+ ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(control);
if (parentScrolledComposite != null) {
parentScrolledComposite.adaptChild(control);
}
}
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
- ExpandableComposite excomposite= new ExpandableComposite(parent, SWT.NONE,
+ ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE,
ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
excomposite.setText(label);
excomposite.setExpanded(false);
@@ -565,15 +559,15 @@ public abstract class OptionsConfigurationBlock {
}
protected final void expandedStateChanged(ExpandableComposite expandable) {
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(expandable);
+ ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(expandable);
if (parentScrolledComposite != null) {
parentScrolledComposite.reflow(true);
}
}
protected void restoreSectionExpansionStates(IDialogSettings settings) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite excomposite= fExpandedComposites.get(i);
+ for (int i = 0; i < fExpandedComposites.size(); i++) {
+ ExpandableComposite excomposite = fExpandedComposites.get(i);
if (settings == null) {
excomposite.setExpanded(i == 0); // only expand the first node by default
} else {
@@ -583,17 +577,18 @@ public abstract class OptionsConfigurationBlock {
}
protected void storeSectionExpansionStates(IDialogSettings settings) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite curr= fExpandedComposites.get(i);
+ for (int i = 0; i < fExpandedComposites.size(); i++) {
+ ExpandableComposite curr = fExpandedComposites.get(i);
settings.put(SETTINGS_EXPANDED + String.valueOf(i), curr.isExpanded());
}
}
protected SelectionListener getSelectionListener() {
if (fSelectionListener == null) {
- fSelectionListener= new SelectionListener() {
+ fSelectionListener = new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
@Override
public void widgetSelected(SelectionEvent e) {
@@ -606,7 +601,7 @@ public abstract class OptionsConfigurationBlock {
protected ModifyListener getTextModifyListener() {
if (fTextModifyListener == null) {
- fTextModifyListener= new ModifyListener() {
+ fTextModifyListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
textChanged((Text) e.widget);
@@ -617,24 +612,24 @@ public abstract class OptionsConfigurationBlock {
}
protected void controlChanged(Widget widget) {
- ControlData data= (ControlData) widget.getData();
- String newValue= null;
+ ControlData data = (ControlData) widget.getData();
+ String newValue = null;
if (widget instanceof Button) {
- newValue= data.getValue(((Button) widget).getSelection());
+ newValue = data.getValue(((Button) widget).getSelection());
} else if (widget instanceof Combo) {
- newValue= data.getValue(((Combo) widget).getSelectionIndex());
+ newValue = data.getValue(((Combo) widget).getSelectionIndex());
} else {
return;
}
- String oldValue= setValue(data.getKey(), newValue);
+ String oldValue = setValue(data.getKey(), newValue);
validateSettings(data.getKey(), oldValue, newValue);
}
protected void textChanged(Text textControl) {
- Key key= (Key) textControl.getData();
+ Key key = (Key) textControl.getData();
if (key != null) {
- String newValue= textControl.getText();
- String oldValue= setValue(key, newValue);
+ String newValue = textControl.getText();
+ String oldValue = setValue(key, newValue);
validateSettings(key, oldValue, newValue);
}
}
@@ -650,7 +645,6 @@ public abstract class OptionsConfigurationBlock {
return key.getStoredValue(fLookupOrder, false, fManager);
}
-
protected boolean getBooleanValue(Key key) {
return Boolean.valueOf(getValue(key)).booleanValue();
}
@@ -659,7 +653,7 @@ public abstract class OptionsConfigurationBlock {
if (fDisabledProjectSettings != null) {
return fDisabledProjectSettings.put(key, value);
}
- String oldValue= getValue(key);
+ String oldValue = getValue(key);
key.setStoredValue(fLookupOrder[0], value, fManager);
return oldValue;
}
@@ -684,21 +678,21 @@ public abstract class OptionsConfigurationBlock {
protected abstract void validateSettings(Key changedKey, String oldValue, String newValue);
protected String[] getTokens(String text, String separator) {
- StringTokenizer tok= new StringTokenizer(text, separator);
- int nTokens= tok.countTokens();
- String[] res= new String[nTokens];
- for (int i= 0; i < res.length; i++) {
- res[i]= tok.nextToken().trim();
+ StringTokenizer tok = new StringTokenizer(text, separator);
+ int nTokens = tok.countTokens();
+ String[] res = new String[nTokens];
+ for (int i = 0; i < res.length; i++) {
+ res[i] = tok.nextToken().trim();
}
return res;
}
private boolean getChanges(IScopeContext currContext, List<Key> changedSettings) {
- boolean needsBuild= false;
- for (int i= 0; i < fAllKeys.length; i++) {
- Key key= fAllKeys[i];
- String oldVal= key.getStoredValue(currContext, null);
- String val= key.getStoredValue(currContext, fManager);
+ boolean needsBuild = false;
+ for (int i = 0; i < fAllKeys.length; i++) {
+ Key key = fAllKeys[i];
+ String oldVal = key.getStoredValue(currContext, null);
+ String val = key.getStoredValue(currContext, fManager);
if (val == null) {
if (oldVal != null) {
changedSettings.add(key);
@@ -713,22 +707,22 @@ public abstract class OptionsConfigurationBlock {
}
public void useProjectSpecificSettings(boolean enable) {
- boolean hasProjectSpecificOption= fDisabledProjectSettings == null;
+ boolean hasProjectSpecificOption = fDisabledProjectSettings == null;
if (enable != hasProjectSpecificOption && fProject != null) {
if (enable) {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String val= fDisabledProjectSettings.get(curr);
+ for (int i = 0; i < fAllKeys.length; i++) {
+ Key curr = fAllKeys[i];
+ String val = fDisabledProjectSettings.get(curr);
curr.setStoredValue(fLookupOrder[0], val, fManager);
}
- fDisabledProjectSettings= null;
+ fDisabledProjectSettings = null;
updateControls();
validateSettings(null, null, null);
} else {
- fDisabledProjectSettings= new IdentityHashMap<Key, String>();
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String oldSetting= curr.getStoredValue(fLookupOrder, false, fManager);
+ fDisabledProjectSettings = new IdentityHashMap<Key, String>();
+ for (int i = 0; i < fAllKeys.length; i++) {
+ Key curr = fAllKeys[i];
+ String oldSetting = curr.getStoredValue(fLookupOrder, false, fManager);
fDisabledProjectSettings.put(curr, oldSetting);
curr.setStoredValue(fLookupOrder[0], null, fManager); // clear project settings
}
@@ -749,29 +743,32 @@ public abstract class OptionsConfigurationBlock {
}
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
- IScopeContext currContext= fLookupOrder[0];
+ IScopeContext currContext = fLookupOrder[0];
- List<Key> changedOptions= new ArrayList<Key>();
- boolean needsBuild= getChanges(currContext, changedOptions);
+ List<Key> changedOptions = new ArrayList<Key>();
+ boolean needsBuild = getChanges(currContext, changedOptions);
if (changedOptions.isEmpty()) {
return true;
}
if (needsBuild) {
- int count= getRebuildCount();
+ int count = getRebuildCount();
if (count > fRebuildCount) {
- needsBuild= false; // build already requested
- fRebuildCount= count;
+ needsBuild = false; // build already requested
+ fRebuildCount = count;
}
}
- boolean doBuild= false;
+ boolean doBuild = false;
if (needsBuild) {
- String[] strings= getFullBuildDialogStrings(fProject == null);
+ String[] strings = getFullBuildDialogStrings(fProject == null);
if (strings != null) {
- MessageDialog dialog= new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
- int res= dialog.open();
+ MessageDialog dialog = new MessageDialog(
+ getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] {
+ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
+ 2);
+ int res = dialog.open();
if (res == 0) {
- doBuild= true;
+ doBuild = true;
} else if (res != 1) {
return false; // cancel pressed
}
@@ -782,7 +779,7 @@ public abstract class OptionsConfigurationBlock {
if (doBuild) { // post build
incrementRebuildCount();
// do a re-index?
-// container.registerUpdateJob(CoreUtility.getBuildJob(fProject));
+ // container.registerUpdateJob(CoreUtility.getBuildJob(fProject));
}
} else {
// apply changes right away
@@ -794,7 +791,7 @@ public abstract class OptionsConfigurationBlock {
}
if (doBuild) {
// do a re-index?
-// CoreUtility.getBuildJob(fProject).schedule();
+ // CoreUtility.getBuildJob(fProject).schedule();
}
}
@@ -808,9 +805,9 @@ public abstract class OptionsConfigurationBlock {
}
public void performDefaults() {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String defValue= curr.getStoredValue(fLookupOrder, true, fManager);
+ for (int i = 0; i < fAllKeys.length; i++) {
+ Key curr = fAllKeys[i];
+ String defValue = curr.getStoredValue(fLookupOrder, true, fManager);
setValue(curr, defValue);
}
@@ -823,9 +820,9 @@ public abstract class OptionsConfigurationBlock {
* @since 3.1
*/
public void performRevert() {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String origValue= curr.getStoredValue(fLookupOrder, false, null);
+ for (int i = 0; i < fAllKeys.length; i++) {
+ Key curr = fAllKeys[i];
+ String origValue = curr.getStoredValue(fLookupOrder, false, null);
setValue(curr, origValue);
}
@@ -839,35 +836,35 @@ public abstract class OptionsConfigurationBlock {
protected void updateControls() {
// update the UI
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
+ for (int i = fCheckBoxes.size() - 1; i >= 0; i--) {
updateCheckBox(fCheckBoxes.get(i));
}
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
+ for (int i = fComboBoxes.size() - 1; i >= 0; i--) {
updateCombo(fComboBoxes.get(i));
}
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
+ for (int i = fTextBoxes.size() - 1; i >= 0; i--) {
updateText(fTextBoxes.get(i));
}
}
protected void updateCombo(Combo curr) {
- ControlData data= (ControlData) curr.getData();
+ ControlData data = (ControlData) curr.getData();
- String currValue= getValue(data.getKey());
+ String currValue = getValue(data.getKey());
curr.select(data.getSelection(currValue));
}
protected void updateCheckBox(Button curr) {
- ControlData data= (ControlData) curr.getData();
+ ControlData data = (ControlData) curr.getData();
- String currValue= getValue(data.getKey());
+ String currValue = getValue(data.getKey());
curr.setSelection(data.getSelection(currValue) == 0);
}
protected void updateText(Text curr) {
- Key key= (Key) curr.getData();
+ Key key = (Key) curr.getData();
if (key != null) {
- String currValue= getValue(key);
+ String currValue = getValue(key);
if (currValue != null) {
curr.setText(currValue);
}
@@ -875,9 +872,9 @@ public abstract class OptionsConfigurationBlock {
}
protected Button getCheckBox(Key key) {
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
- Button curr= fCheckBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
+ for (int i = fCheckBoxes.size() - 1; i >= 0; i--) {
+ Button curr = fCheckBoxes.get(i);
+ ControlData data = (ControlData) curr.getData();
if (key.equals(data.getKey())) {
return curr;
}
@@ -886,9 +883,9 @@ public abstract class OptionsConfigurationBlock {
}
protected Combo getComboBox(Key key) {
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
- Combo curr= fComboBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
+ for (int i = fComboBoxes.size() - 1; i >= 0; i--) {
+ Combo curr = fComboBoxes.get(i);
+ ControlData data = (ControlData) curr.getData();
if (key.equals(data.getKey())) {
return curr;
}
@@ -897,9 +894,9 @@ public abstract class OptionsConfigurationBlock {
}
protected Text getTextControl(Key key) {
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
- Text curr= fTextBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
+ for (int i = fTextBoxes.size() - 1; i >= 0; i--) {
+ Text curr = fTextBoxes.get(i);
+ ControlData data = (ControlData) curr.getData();
if (key.equals(data.getKey())) {
return curr;
}
@@ -908,15 +905,15 @@ public abstract class OptionsConfigurationBlock {
}
protected Control findControl(Key key) {
- Combo comboBox= getComboBox(key);
+ Combo comboBox = getComboBox(key);
if (comboBox != null) {
return comboBox;
}
- Button checkBox= getCheckBox(key);
+ Button checkBox = getCheckBox(key);
if (checkBox != null) {
return checkBox;
}
- Text text= getTextControl(key);
+ Text text = getTextControl(key);
if (text != null) {
return text;
}
@@ -928,8 +925,8 @@ public abstract class OptionsConfigurationBlock {
}
protected void setComboEnabled(Key key, boolean enabled) {
- Combo combo= getComboBox(key);
- Label label= fLabels.get(combo);
+ Combo combo = getComboBox(key);
+ Label label = fLabels.get(combo);
combo.setEnabled(enabled);
label.setEnabled(enabled);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesBlock.java
index 0d4965880df..f3a50257d1a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesBlock.java
@@ -31,40 +31,32 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
* The preference block for configuring Organize Includes command.
*/
public class OrganizeIncludesBlock extends OptionsConfigurationBlock {
- private static final Key KEY_HEURISTIC_HEADER_SUBSTITUTION = getCDTUIKey(PreferenceConstants.INCLUDES_HEURISTIC_HEADER_SUBSTITUTION);
- private static final Key KEY_PARTNER_INDIRECT_INCLUSION = getCDTUIKey(PreferenceConstants.INCLUDES_ALLOW_PARTNER_INDIRECT_INCLUSION);
+ private static final Key KEY_HEURISTIC_HEADER_SUBSTITUTION = getCDTUIKey(
+ PreferenceConstants.INCLUDES_HEURISTIC_HEADER_SUBSTITUTION);
+ private static final Key KEY_PARTNER_INDIRECT_INCLUSION = getCDTUIKey(
+ PreferenceConstants.INCLUDES_ALLOW_PARTNER_INDIRECT_INCLUSION);
private static final Key KEY_INCLUDES_REORDERING = getCDTUIKey(PreferenceConstants.INCLUDES_ALLOW_REORDERING);
- private static final Key KEY_UNUSED_STATEMENTS_DISPOSITION = getCDTUIKey(PreferenceConstants.INCLUDES_UNUSED_STATEMENTS_DISPOSITION);
- private static final Key KEY_FORWARD_DECLARE_COMPOSITE_TYPES = getCDTUIKey(PreferenceConstants.FORWARD_DECLARE_COMPOSITE_TYPES);
+ private static final Key KEY_UNUSED_STATEMENTS_DISPOSITION = getCDTUIKey(
+ PreferenceConstants.INCLUDES_UNUSED_STATEMENTS_DISPOSITION);
+ private static final Key KEY_FORWARD_DECLARE_COMPOSITE_TYPES = getCDTUIKey(
+ PreferenceConstants.FORWARD_DECLARE_COMPOSITE_TYPES);
private static final Key KEY_FORWARD_DECLARE_ENUMS = getCDTUIKey(PreferenceConstants.FORWARD_DECLARE_ENUMS);
private static final Key KEY_FORWARD_DECLARE_FUNCTIONS = getCDTUIKey(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS);
- private static final Key KEY_FORWARD_DECLARE_EXTERNAL_VARIABLES = getCDTUIKey(PreferenceConstants.FORWARD_DECLARE_EXTERNAL_VARIABLES);
+ private static final Key KEY_FORWARD_DECLARE_EXTERNAL_VARIABLES = getCDTUIKey(
+ PreferenceConstants.FORWARD_DECLARE_EXTERNAL_VARIABLES);
private static final Key KEY_FORWARD_DECLARE_TEMPLATES = getCDTUIKey(PreferenceConstants.FORWARD_DECLARE_TEMPLATES);
- private static final Key KEY_FORWARD_DECLARE_NAMESPACE_ELEMENTS = getCDTUIKey(PreferenceConstants.FORWARD_DECLARE_NAMESPACE_ELEMENTS);
+ private static final Key KEY_FORWARD_DECLARE_NAMESPACE_ELEMENTS = getCDTUIKey(
+ PreferenceConstants.FORWARD_DECLARE_NAMESPACE_ELEMENTS);
- private static final String[] DISPOSITION_VALUES = {
- UnusedStatementDisposition.REMOVE.toString(),
- UnusedStatementDisposition.COMMENT_OUT.toString(),
- UnusedStatementDisposition.KEEP.toString(),
- };
- private static final String[] DISPOSITION_LABELS = {
- PreferencesMessages.OrganizeIncludesBlock_remove,
- PreferencesMessages.OrganizeIncludesBlock_comment_out,
- PreferencesMessages.OrganizeIncludesBlock_keep,
- };
+ private static final String[] DISPOSITION_VALUES = { UnusedStatementDisposition.REMOVE.toString(),
+ UnusedStatementDisposition.COMMENT_OUT.toString(), UnusedStatementDisposition.KEEP.toString(), };
+ private static final String[] DISPOSITION_LABELS = { PreferencesMessages.OrganizeIncludesBlock_remove,
+ PreferencesMessages.OrganizeIncludesBlock_comment_out, PreferencesMessages.OrganizeIncludesBlock_keep, };
- private static Key[] ALL_KEYS = {
- KEY_HEURISTIC_HEADER_SUBSTITUTION,
- KEY_PARTNER_INDIRECT_INCLUSION,
- KEY_INCLUDES_REORDERING,
- KEY_UNUSED_STATEMENTS_DISPOSITION,
- KEY_FORWARD_DECLARE_COMPOSITE_TYPES,
- KEY_FORWARD_DECLARE_ENUMS,
- KEY_FORWARD_DECLARE_FUNCTIONS,
- KEY_FORWARD_DECLARE_EXTERNAL_VARIABLES,
- KEY_FORWARD_DECLARE_TEMPLATES,
- KEY_FORWARD_DECLARE_NAMESPACE_ELEMENTS,
- };
+ private static Key[] ALL_KEYS = { KEY_HEURISTIC_HEADER_SUBSTITUTION, KEY_PARTNER_INDIRECT_INCLUSION,
+ KEY_INCLUDES_REORDERING, KEY_UNUSED_STATEMENTS_DISPOSITION, KEY_FORWARD_DECLARE_COMPOSITE_TYPES,
+ KEY_FORWARD_DECLARE_ENUMS, KEY_FORWARD_DECLARE_FUNCTIONS, KEY_FORWARD_DECLARE_EXTERNAL_VARIABLES,
+ KEY_FORWARD_DECLARE_TEMPLATES, KEY_FORWARD_DECLARE_NAMESPACE_ELEMENTS, };
public OrganizeIncludesBlock(IStatusChangeListener context, IProject project,
IWorkbenchPreferenceContainer container) {
@@ -75,7 +67,7 @@ public class OrganizeIncludesBlock extends OptionsConfigurationBlock {
protected Control createContents(Composite parent) {
setShell(parent.getShell());
- Composite composite = new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setFont(parent.getFont());
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesPreferencePage.java
index 87da326a9a9..7a121254731 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OrganizeIncludesPreferencePage.java
@@ -23,13 +23,13 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
* The preference page for configuring Organize Includes command.
*/
public class OrganizeIncludesPreferencePage extends ConfigurationBlockPropertyAndPreferencePage {
- public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.OrganizeIncludesPreferencePage"; //$NON-NLS-1$
- public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.OrganizeIncludesPreferencePage"; //$NON-NLS-1$
+ public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.OrganizeIncludesPreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.OrganizeIncludesPreferencePage"; //$NON-NLS-1$
public OrganizeIncludesPreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
// Only used when the page is shown programmatically.
- setTitle(PreferencesMessages.OrganizeIncludesPreferencePage_title);
+ setTitle(PreferencesMessages.OrganizeIncludesPreferencePage_title);
}
@Override
@@ -51,6 +51,6 @@ public class OrganizeIncludesPreferencePage extends ConfigurationBlockPropertyAn
protected String getPropertyPageId() {
return null;
// TODO(sprigogin): Project specific settings
-// return PROP_ID;
+ // return PROP_ID;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java
index f29215e3e2a..0a23ea2a762 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java
@@ -23,111 +23,112 @@ import org.eclipse.jface.util.PropertyChangeEvent;
/**
* An overlaying preference store.
*/
-public class OverlayPreferenceStore implements IPreferenceStore {
-
+public class OverlayPreferenceStore implements IPreferenceStore {
+
public static final class TypeDescriptor {
protected TypeDescriptor() {
}
}
-
- public static final TypeDescriptor BOOLEAN= new TypeDescriptor();
- public static final TypeDescriptor DOUBLE= new TypeDescriptor();
- public static final TypeDescriptor FLOAT= new TypeDescriptor();
- public static final TypeDescriptor INT= new TypeDescriptor();
- public static final TypeDescriptor LONG= new TypeDescriptor();
- public static final TypeDescriptor STRING= new TypeDescriptor();
-
+
+ public static final TypeDescriptor BOOLEAN = new TypeDescriptor();
+ public static final TypeDescriptor DOUBLE = new TypeDescriptor();
+ public static final TypeDescriptor FLOAT = new TypeDescriptor();
+ public static final TypeDescriptor INT = new TypeDescriptor();
+ public static final TypeDescriptor LONG = new TypeDescriptor();
+ public static final TypeDescriptor STRING = new TypeDescriptor();
+
public static class OverlayKey {
TypeDescriptor fDescriptor;
String fKey;
-
+
public OverlayKey(TypeDescriptor descriptor, String key) {
- fDescriptor= descriptor;
- fKey= key;
+ fDescriptor = descriptor;
+ fKey = key;
}
}
-
+
private class PropertyListener implements IPropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent event) {
- OverlayKey key= findOverlayKey(event.getProperty());
+ OverlayKey key = findOverlayKey(event.getProperty());
if (key != null)
- propagateProperty(fParent, key, fStore);
+ propagateProperty(fParent, key, fStore);
}
}
-
+
protected IPreferenceStore fParent;
protected IPreferenceStore fStore;
private OverlayKey[] fOverlayKeys;
private boolean fLoaded;
private PropertyListener fPropertyListener;
-
+
public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
- fParent= parent;
- fOverlayKeys= overlayKeys;
- fStore= new PreferenceStore();
+ fParent = parent;
+ fOverlayKeys = overlayKeys;
+ fStore = new PreferenceStore();
}
-
+
protected OverlayKey findOverlayKey(String key) {
- for (int i= 0; i < fOverlayKeys.length; i++) {
+ for (int i = 0; i < fOverlayKeys.length; i++) {
if (fOverlayKeys[i].fKey.equals(key))
return fOverlayKeys[i];
}
return null;
}
-
+
private boolean covers(String key) {
return (findOverlayKey(key) != null);
}
-
+
protected void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
if (orgin.isDefault(key.fKey)) {
if (!target.isDefault(key.fKey))
target.setToDefault(key.fKey);
return;
}
-
- TypeDescriptor d= key.fDescriptor;
+
+ TypeDescriptor d = key.fDescriptor;
if (BOOLEAN == d) {
- boolean originValue= orgin.getBoolean(key.fKey);
- boolean targetValue= target.getBoolean(key.fKey);
+ boolean originValue = orgin.getBoolean(key.fKey);
+ boolean targetValue = target.getBoolean(key.fKey);
if (targetValue != originValue)
target.setValue(key.fKey, originValue);
} else if (DOUBLE == d) {
- double originValue= orgin.getDouble(key.fKey);
- double targetValue= target.getDouble(key.fKey);
+ double originValue = orgin.getDouble(key.fKey);
+ double targetValue = target.getDouble(key.fKey);
if (targetValue != originValue)
target.setValue(key.fKey, originValue);
} else if (FLOAT == d) {
- float originValue= orgin.getFloat(key.fKey);
- float targetValue= target.getFloat(key.fKey);
+ float originValue = orgin.getFloat(key.fKey);
+ float targetValue = target.getFloat(key.fKey);
if (targetValue != originValue)
target.setValue(key.fKey, originValue);
} else if (INT == d) {
- int originValue= orgin.getInt(key.fKey);
- int targetValue= target.getInt(key.fKey);
+ int originValue = orgin.getInt(key.fKey);
+ int targetValue = target.getInt(key.fKey);
if (targetValue != originValue)
target.setValue(key.fKey, originValue);
} else if (LONG == d) {
- long originValue= orgin.getLong(key.fKey);
- long targetValue= target.getLong(key.fKey);
+ long originValue = orgin.getLong(key.fKey);
+ long targetValue = target.getLong(key.fKey);
if (targetValue != originValue)
target.setValue(key.fKey, originValue);
} else if (STRING == d) {
- String originValue= orgin.getString(key.fKey);
- String targetValue= target.getString(key.fKey);
+ String originValue = orgin.getString(key.fKey);
+ String targetValue = target.getString(key.fKey);
if (targetValue != null && originValue != null && !targetValue.equals(originValue))
target.setValue(key.fKey, originValue);
}
}
-
+
public void propagate() {
- for (int i= 0; i < fOverlayKeys.length; i++)
+ for (int i = 0; i < fOverlayKeys.length; i++)
propagateProperty(fStore, fOverlayKeys[i], fParent);
}
-
- private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) {
- TypeDescriptor d= key.fDescriptor;
+
+ private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target,
+ boolean forceInitialization) {
+ TypeDescriptor d = key.fDescriptor;
if (BOOLEAN == d) {
if (forceInitialization)
target.setValue(key.fKey, true);
@@ -160,43 +161,43 @@ public class OverlayPreferenceStore implements IPreferenceStore {
target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
}
}
-
+
public void load() {
- for (int i= 0; i < fOverlayKeys.length; i++)
+ for (int i = 0; i < fOverlayKeys.length; i++)
loadProperty(fParent, fOverlayKeys[i], fStore, true);
- fLoaded= true;
+ fLoaded = true;
}
-
+
public void loadDefaults() {
- for (int i= 0; i < fOverlayKeys.length; i++)
+ for (int i = 0; i < fOverlayKeys.length; i++)
setToDefault(fOverlayKeys[i].fKey);
}
-
+
public void start() {
if (fPropertyListener == null) {
- fPropertyListener= new PropertyListener();
+ fPropertyListener = new PropertyListener();
fParent.addPropertyChangeListener(fPropertyListener);
}
}
-
+
public void stop() {
- if (fPropertyListener != null) {
+ if (fPropertyListener != null) {
fParent.removePropertyChangeListener(fPropertyListener);
- fPropertyListener= null;
+ fPropertyListener = null;
}
}
-
+
@Override
public void addPropertyChangeListener(IPropertyChangeListener listener) {
fStore.addPropertyChangeListener(listener);
}
-
+
@Override
public void removePropertyChangeListener(IPropertyChangeListener listener) {
fStore.removePropertyChangeListener(listener);
}
-
+
@Override
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
fStore.firePropertyChangeEvent(name, oldValue, newValue);
@@ -206,7 +207,7 @@ public class OverlayPreferenceStore implements IPreferenceStore {
public boolean contains(String name) {
return fStore.contains(name);
}
-
+
@Override
public boolean getBoolean(String name) {
return fStore.getBoolean(name);
@@ -363,29 +364,28 @@ public class OverlayPreferenceStore implements IPreferenceStore {
/**
* The keys to add to the list of overlay keys.
* <p>
- * Note: This method must be called before {@link #load()} is called.
+ * Note: This method must be called before {@link #load()} is called.
* </p>
- *
+ *
* @param keys
* @since 3.0
*/
public void addKeys(OverlayKey[] keys) {
Assert.isTrue(!fLoaded);
Assert.isNotNull(keys);
-
- int overlayKeysLength= fOverlayKeys.length;
- OverlayKey[] result= new OverlayKey[keys.length + overlayKeysLength];
-
- for (int i= 0, length= overlayKeysLength; i < length; i++)
- result[i]= fOverlayKeys[i];
-
- for (int i= 0, length= keys.length; i < length; i++)
- result[overlayKeysLength + i]= keys[i];
-
- fOverlayKeys= result;
-
+
+ int overlayKeysLength = fOverlayKeys.length;
+ OverlayKey[] result = new OverlayKey[keys.length + overlayKeysLength];
+
+ for (int i = 0, length = overlayKeysLength; i < length; i++)
+ result[i] = fOverlayKeys[i];
+
+ for (int i = 0, length = keys.length; i < length; i++)
+ result[overlayKeysLength + i] = keys[i];
+
+ fOverlayKeys = result;
+
if (fLoaded)
load();
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java
index 3a06081c8b5..4bb394f0c2e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java
@@ -25,76 +25,76 @@ import org.eclipse.ui.preferences.IWorkingCopyManager;
import org.osgi.service.prefs.BackingStoreException;
/**
- *
+ *
*/
public class PreferencesAccess {
-
+
public static PreferencesAccess getOriginalPreferences() {
return new PreferencesAccess();
}
-
+
public static PreferencesAccess getWorkingCopyPreferences(IWorkingCopyManager workingCopyManager) {
return new WorkingCopyPreferencesAccess(workingCopyManager);
}
-
+
private PreferencesAccess() {
// can only extends in this file
}
-
+
public IScopeContext getDefaultScope() {
return DefaultScope.INSTANCE;
}
-
+
public IScopeContext getInstanceScope() {
return InstanceScope.INSTANCE;
}
-
+
public IScopeContext getProjectScope(IProject project) {
return new ProjectScope(project);
}
-
+
public void applyChanges() throws BackingStoreException {
}
-
+
private static class WorkingCopyPreferencesAccess extends PreferencesAccess {
private final IWorkingCopyManager fWorkingCopyManager;
private WorkingCopyPreferencesAccess(IWorkingCopyManager workingCopyManager) {
- fWorkingCopyManager= workingCopyManager;
+ fWorkingCopyManager = workingCopyManager;
}
-
+
private final IScopeContext getWorkingCopyScopeContext(IScopeContext original) {
return new WorkingCopyScopeContext(fWorkingCopyManager, original);
}
-
+
@Override
public IScopeContext getDefaultScope() {
return getWorkingCopyScopeContext(super.getDefaultScope());
}
-
+
@Override
public IScopeContext getInstanceScope() {
return getWorkingCopyScopeContext(super.getInstanceScope());
}
-
+
@Override
public IScopeContext getProjectScope(IProject project) {
return getWorkingCopyScopeContext(super.getProjectScope(project));
}
-
+
@Override
public void applyChanges() throws BackingStoreException {
fWorkingCopyManager.applyChanges();
}
}
-
+
private static class WorkingCopyScopeContext implements IScopeContext {
private final IWorkingCopyManager fWorkingCopyManager;
private final IScopeContext fOriginal;
public WorkingCopyScopeContext(IWorkingCopyManager workingCopyManager, IScopeContext original) {
- fWorkingCopyManager= workingCopyManager;
- fOriginal= original;
+ fWorkingCopyManager = workingCopyManager;
+ fOriginal = original;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
index bb58ab32806..fcb869f5075 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
@@ -39,9 +39,9 @@ public final class PreferencesMessages extends NLS {
public static String CEditorPreferencePage_colors;
public static String CEditorPreferencePage_invalid_input;
public static String CEditorPreferencePage_empty_input;
-// public static String CEditorPreferencePage_ContentAssistPage_searchGroupTitle;
-// public static String CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption;
-// public static String CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption;
+ // public static String CEditorPreferencePage_ContentAssistPage_searchGroupTitle;
+ // public static String CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption;
+ // public static String CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption;
public static String CEditorPreferencePage_ContentAssistPage_insertionGroupTitle;
public static String CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically;
public static String CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically;
@@ -105,7 +105,7 @@ public final class PreferencesMessages extends NLS {
public static String CEditorPreferencePage_behaviorPage_subWordNavigation;
public static String CEditorPreferencePage_behaviorPage_inactiveCode;
public static String CEditorPreferencePage_behaviorPage_formattingWithEmptySelection;
- public static String CEditorPreferencePage_behaviorPage_formatFile;
+ public static String CEditorPreferencePage_behaviorPage_formatFile;
public static String CEditorPreferencePage_behaviorPage_formatStatement;
public static String CEditorPreferencePage_behaviorPage_confirmFormattingScope;
public static String CEditorPreferencePage_behaviorPage_appearanceColorOptions;
@@ -387,7 +387,7 @@ public final class PreferencesMessages extends NLS {
public static String HeaderSubstitutionPreferencePage_title;
public static String HeaderSubstitutionBlock_header_substitution_maps;
- public static String HeaderSubstitutionBlock_c_and_cpp;
+ public static String HeaderSubstitutionBlock_c_and_cpp;
public static String HeaderSubstitutionBlock_cpp_only;
public static String HeaderSubstitutionBlock_add_button;
public static String HeaderSubstitutionBlock_edit_button;
@@ -407,7 +407,7 @@ public final class PreferencesMessages extends NLS {
public static String HeaderSubstitutionEditDialog_error_replacement_by_itself;
public static String HeaderSubstitutionEditDialog_invalid_source;
public static String HeaderSubstitutionEditDialog_invalid_target;
-
+
public static String HeaderSubstitutionMapEditDialog_new_title;
public static String HeaderSubstitutionMapEditDialog_edit_title;
public static String HeaderSubstitutionMapEditDialog_name;
@@ -426,7 +426,7 @@ public final class PreferencesMessages extends NLS {
public static String HeaderSubstitutionMapEditDialog_remove_button2;
public static String HeaderSubstitutionMapEditDialog_up_button;
public static String HeaderSubstitutionMapEditDialog_down_button;
- public static String HeaderSubstitutionMapEditDialog_c_and_cpp;
+ public static String HeaderSubstitutionMapEditDialog_c_and_cpp;
public static String HeaderSubstitutionMapEditDialog_cpp_only;
public static String HeaderSubstitutionMapEditDialog_import_title;
public static String HeaderSubstitutionMapEditDialog_export_title;
@@ -474,7 +474,7 @@ public final class PreferencesMessages extends NLS {
public static String IncludeOrderBlock_down;
public static String IncludeOrderBlock_order_of_includes;
public static String IncludePragmasPreferencePage_title;
- public static String IncludePragmasBlock_description;
+ public static String IncludePragmasBlock_description;
public static String IncludePragmasBlock_link_tooltip;
public static String IncludePragmasBlock_export_pattern;
public static String IncludePragmasBlock_begin_exports_pattern;
@@ -556,7 +556,7 @@ public final class PreferencesMessages extends NLS {
public static String EditTemplateDialog_paste;
public static String EditTemplateDialog_select_all;
public static String EditTemplateDialog_content_assist;
-// public static String EditTemplateDialog_autoinsert;
+ // public static String EditTemplateDialog_autoinsert;
public static String MarkOccurrencesConfigurationBlock_title;
public static String MarkOccurrencesConfigurationBlock_link;
@@ -564,7 +564,7 @@ public final class PreferencesMessages extends NLS {
public static String MarkOccurrencesConfigurationBlock_markOccurrences;
public static String MarkOccurrencesConfigurationBlock_markOverloadOccurrences;
public static String MarkOccurrencesConfigurationBlock_stickyOccurrences;
-
+
public static String ScalabilityPreferencePage_description;
public static String ScalabilityPreferencePage_detection_label;
public static String ScalabilityPreferencePage_detection_group_label;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java
index e347d598b1f..1d8334b2943 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java
@@ -54,27 +54,26 @@ public class ProjectSelectionDialog extends SelectionStatusDialog {
private Set<ICProject> fProjectsWithSpecifics;
// sizing constants
- private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250;
- private final static int SIZING_SELECTION_WIDGET_WIDTH= 300;
-
- private final static String DIALOG_SETTINGS_SHOW_ALL= "ProjectSelectionDialog.show_all"; //$NON-NLS-1$
+ private final static int SIZING_SELECTION_WIDGET_HEIGHT = 250;
+ private final static int SIZING_SELECTION_WIDGET_WIDTH = 300;
+
+ private final static String DIALOG_SETTINGS_SHOW_ALL = "ProjectSelectionDialog.show_all"; //$NON-NLS-1$
private ViewerFilter fFilter;
public ProjectSelectionDialog(Shell parentShell, Set<ICProject> projectsWithSpecifics) {
super(parentShell);
- setTitle(PreferencesMessages.ProjectSelectionDialog_title);
- setMessage(PreferencesMessages.ProjectSelectionDialog_desciption);
- fProjectsWithSpecifics= projectsWithSpecifics;
-
- fFilter= new ViewerFilter() {
+ setTitle(PreferencesMessages.ProjectSelectionDialog_title);
+ setMessage(PreferencesMessages.ProjectSelectionDialog_desciption);
+ fProjectsWithSpecifics = projectsWithSpecifics;
+
+ fFilter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return fProjectsWithSpecifics.contains(element);
}
};
}
-
/* (non-Javadoc)
* Method declared on Dialog.
@@ -82,14 +81,14 @@ public class ProjectSelectionDialog extends SelectionStatusDialog {
@Override
protected Control createDialogArea(Composite parent) {
// page group
- Composite composite= (Composite) super.createDialogArea(parent);
+ Composite composite = (Composite) super.createDialogArea(parent);
- Font font= parent.getFont();
+ Font font = parent.getFont();
composite.setFont(font);
createMessageArea(composite);
- fTableViewer= new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ fTableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
@@ -99,12 +98,12 @@ public class ProjectSelectionDialog extends SelectionStatusDialog {
fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
- okPressed();
+ okPressed();
}
});
- GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
- data.heightHint= SIZING_SELECTION_WIDGET_HEIGHT;
- data.widthHint= SIZING_SELECTION_WIDGET_WIDTH;
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+ data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
fTableViewer.getTable().setLayoutData(data);
fTableViewer.setLabelProvider(new CElementLabelProvider());
@@ -112,32 +111,33 @@ public class ProjectSelectionDialog extends SelectionStatusDialog {
fTableViewer.setComparator(new CElementSorter());
fTableViewer.getControl().setFont(font);
- Button checkbox= new Button(composite, SWT.CHECK);
- checkbox.setText(PreferencesMessages.ProjectSelectionDialog_filter);
+ Button checkbox = new Button(composite, SWT.CHECK);
+ checkbox.setText(PreferencesMessages.ProjectSelectionDialog_filter);
checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
checkbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateFilter(((Button) e.widget).getSelection());
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
updateFilter(((Button) e.widget).getSelection());
}
});
- IDialogSettings dialogSettings= CUIPlugin.getDefault().getDialogSettings();
- boolean doFilter= !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL) && !fProjectsWithSpecifics.isEmpty();
+ IDialogSettings dialogSettings = CUIPlugin.getDefault().getDialogSettings();
+ boolean doFilter = !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL) && !fProjectsWithSpecifics.isEmpty();
checkbox.setSelection(doFilter);
updateFilter(doFilter);
-
- ICModel input= CoreModel.getDefault().getCModel();
+
+ ICModel input = CoreModel.getDefault().getCModel();
fTableViewer.setInput(input);
-
+
doSelectionChanged(new Object[0]);
Dialog.applyDialogFont(composite);
return composite;
}
-
+
protected void updateFilter(boolean selected) {
if (selected) {
fTableViewer.addFilter(fFilter);
@@ -152,7 +152,7 @@ public class ProjectSelectionDialog extends SelectionStatusDialog {
updateStatus(new StatusInfo(IStatus.ERROR, "")); //$NON-NLS-1$
setSelectionResult(null);
} else {
- updateStatus(new StatusInfo());
+ updateStatus(new StatusInfo());
setSelectionResult(objects);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java
index 26a0cba0432..0b563d30a99 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -56,103 +56,108 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFie
/**
* Base for project property and preference pages
*/
-public abstract class PropertyAndPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
+public abstract class PropertyAndPreferencePage extends PreferencePage
+ implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
private Control fConfigurationBlockControl;
private ControlEnableState fBlockEnableState;
private Link fChangeWorkspaceSettings;
private SelectionButtonDialogField fUseProjectSettings;
private IStatus fBlockStatus;
private Composite fParentComposite;
-
+
private IProject fProject; // project or null
private Map<?, ?> fData; // page data
-
- public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
-
+
+ public static final String DATA_NO_LINK = "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
+
public PropertyAndPreferencePage() {
- fBlockStatus= new StatusInfo();
- fBlockEnableState= null;
- fProject= null;
- fData= null;
+ fBlockStatus = new StatusInfo();
+ fBlockEnableState = null;
+ fProject = null;
+ fData = null;
}
protected abstract Control createPreferenceContent(Composite composite);
+
protected abstract boolean hasProjectSpecificOptions(IProject project);
-
+
protected abstract String getPreferencePageId();
+
protected abstract String getPropertyPageId();
-
+
protected boolean supportsProjectSpecificOptions() {
return getPropertyPageId() != null;
}
-
+
protected boolean offerLink() {
return fData == null || !Boolean.TRUE.equals(fData.get(DATA_NO_LINK));
}
-
- @Override
+
+ @Override
protected Label createDescriptionLabel(Composite parent) {
- fParentComposite= parent;
+ fParentComposite = parent;
if (isProjectPreferencePage()) {
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setFont(parent.getFont());
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
composite.setLayout(layout);
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- IDialogFieldListener listener= new IDialogFieldListener() {
+
+ IDialogFieldListener listener = new IDialogFieldListener() {
@Override
public void dialogFieldChanged(DialogField field) {
- enableProjectSpecificSettings(((SelectionButtonDialogField)field).isSelected());
+ enableProjectSpecificSettings(((SelectionButtonDialogField) field).isSelected());
}
};
-
- fUseProjectSettings= new SelectionButtonDialogField(SWT.CHECK);
+
+ fUseProjectSettings = new SelectionButtonDialogField(SWT.CHECK);
fUseProjectSettings.setDialogFieldListener(listener);
fUseProjectSettings.setLabelText(PreferencesMessages.PropertyAndPreferencePage_useprojectsettings_label);
fUseProjectSettings.doFillIntoGrid(composite, 1);
LayoutUtil.setHorizontalGrabbing(fUseProjectSettings.getSelectionButton(null), true);
-
+
if (offerLink()) {
- fChangeWorkspaceSettings= createLink(composite, PreferencesMessages.PropertyAndPreferencePage_useworkspacesettings_change);
+ fChangeWorkspaceSettings = createLink(composite,
+ PreferencesMessages.PropertyAndPreferencePage_useworkspacesettings_change);
fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
} else {
LayoutUtil.setHorizontalSpan(fUseProjectSettings.getSelectionButton(null), 2);
}
-
- Label horizontalLine= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+
+ Label horizontalLine = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
horizontalLine.setFont(composite.getFont());
} else if (supportsProjectSpecificOptions() && offerLink()) {
- fChangeWorkspaceSettings= createLink(parent, PreferencesMessages.PropertyAndPreferencePage_showprojectspecificsettings_label);
+ fChangeWorkspaceSettings = createLink(parent,
+ PreferencesMessages.PropertyAndPreferencePage_showprojectspecificsettings_label);
fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
}
return super.createDescriptionLabel(parent);
- }
-
+ }
+
/*
* @see org.eclipse.jface.preference.IPreferencePage#createContents(Composite)
*/
@Override
protected Control createContents(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
composite.setLayout(layout);
composite.setFont(parent.getFont());
-
- GridData data= new GridData(GridData.FILL, GridData.FILL, true, true);
-
- fConfigurationBlockControl= createPreferenceContent(composite);
+
+ GridData data = new GridData(GridData.FILL, GridData.FILL, true, true);
+
+ fConfigurationBlockControl = createPreferenceContent(composite);
fConfigurationBlockControl.setLayoutData(data);
if (isProjectPreferencePage()) {
- boolean useProjectSettings= hasProjectSpecificOptions(getProject());
+ boolean useProjectSettings = hasProjectSpecificOptions(getProject());
enableProjectSpecificSettings(useProjectSettings);
}
@@ -161,9 +166,9 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
}
private Link createLink(Composite composite, String text) {
- Link link= new Link(composite, SWT.NONE);
+ Link link = new Link(composite, SWT.NONE);
link.setFont(composite.getFont());
- link.setText("<A>" + text + "</A>"); //$NON-NLS-1$//$NON-NLS-2$
+ link.setText("<A>" + text + "</A>"); //$NON-NLS-1$//$NON-NLS-2$
link.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -177,34 +182,34 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
});
return link;
}
-
+
protected boolean useProjectSettings() {
return isProjectPreferencePage() && fUseProjectSettings != null && fUseProjectSettings.isSelected();
}
-
+
protected boolean isProjectPreferencePage() {
return fProject != null;
}
-
+
protected IProject getProject() {
return fProject;
}
-
+
/**
* Handle link activation.
- *
+ *
* @param link the link
*/
final void doLinkActivated(Link link) {
- Map<String, Boolean> data= new HashMap<String, Boolean>();
+ Map<String, Boolean> data = new HashMap<String, Boolean>();
data.put(DATA_NO_LINK, Boolean.TRUE);
-
+
if (isProjectPreferencePage()) {
openWorkspacePreferences(data);
} else {
- HashSet<ICProject> projectsWithSpecifics= new HashSet<ICProject>();
+ HashSet<ICProject> projectsWithSpecifics = new HashSet<ICProject>();
try {
- ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
+ ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
for (ICProject curr : projects) {
if (hasProjectSpecificOptions(curr.getProject())) {
projectsWithSpecifics.add(curr);
@@ -213,48 +218,48 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
} catch (CModelException e) {
// ignore
}
- ProjectSelectionDialog dialog= new ProjectSelectionDialog(getShell(), projectsWithSpecifics);
+ ProjectSelectionDialog dialog = new ProjectSelectionDialog(getShell(), projectsWithSpecifics);
if (dialog.open() == Window.OK) {
- ICProject res= (ICProject) dialog.getFirstResult();
+ ICProject res = (ICProject) dialog.getFirstResult();
openProjectProperties(res.getProject(), data);
}
}
}
-
+
protected final void openWorkspacePreferences(Object data) {
- String id= getPreferencePageId();
+ String id = getPreferencePageId();
PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, data).open();
}
-
+
protected final void openProjectProperties(IProject project, Object data) {
- String id= getPropertyPageId();
+ String id = getPropertyPageId();
if (id != null) {
PreferencesUtil.createPropertyDialogOn(getShell(), project, id, new String[] { id }, data).open();
}
}
-
+
protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
fUseProjectSettings.setSelection(useProjectSpecificSettings);
enablePreferenceContent(useProjectSpecificSettings);
updateLinkVisibility();
doStatusChanged();
}
-
+
private void updateLinkVisibility() {
if (fChangeWorkspaceSettings == null || fChangeWorkspaceSettings.isDisposed()) {
return;
}
-
+
if (isProjectPreferencePage()) {
fChangeWorkspaceSettings.setEnabled(!useProjectSettings());
}
}
protected void setPreferenceContentStatus(IStatus status) {
- fBlockStatus= status;
+ fBlockStatus = status;
doStatusChanged();
}
-
+
/**
* Returns a new status change listener that calls {@link #setPreferenceContentStatus(IStatus)}
* when the status has changed
@@ -268,7 +273,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
}
};
}
-
+
protected IStatus getPreferenceContentStatus() {
return fBlockStatus;
}
@@ -280,20 +285,20 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
updateStatus(new StatusInfo());
}
}
-
+
protected void enablePreferenceContent(boolean enable) {
if (enable) {
if (fBlockEnableState != null) {
fBlockEnableState.restore();
- fBlockEnableState= null;
+ fBlockEnableState = null;
}
} else {
if (fBlockEnableState == null) {
- fBlockEnableState= ControlEnableState.disable(fConfigurationBlockControl);
+ fBlockEnableState = ControlEnableState.disable(fConfigurationBlockControl);
}
}
}
-
+
@Override
protected void performDefaults() {
if (useProjectSettings()) {
@@ -318,13 +323,13 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
@Override
public void setElement(IAdaptable element) {
- fProject= (IProject) element.getAdapter(IResource.class);
+ fProject = (IProject) element.getAdapter(IResource.class);
}
-
+
@Override
public void applyData(Object data) {
if (data instanceof Map<?, ?>) {
- fData= (Map<?, ?>) data;
+ fData = (Map<?, ?>) data;
}
if (fChangeWorkspaceSettings != null) {
if (!offerLink()) {
@@ -332,8 +337,8 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
fParentComposite.layout(true, true);
}
}
- }
-
+ }
+
protected Map<?, ?> getData() {
return fData;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java
index 34565e5ab6c..fdf260eadc6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java
@@ -47,8 +47,8 @@ public class ProposalFilterPreferencesUtil {
public static String[] getProposalFilterNames() {
ArrayList<String> names = new ArrayList<String>();
try {
- IExtensionPoint point = Platform.getExtensionRegistry()
- .getExtensionPoint(CUIPlugin.PLUGIN_ID, "ProposalFilter"); //$NON-NLS-1$
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ "ProposalFilter"); //$NON-NLS-1$
if (point != null) {
IExtension[] extensions = point.getExtensions();
for (IExtension extension : extensions) {
@@ -73,7 +73,7 @@ public class ProposalFilterPreferencesUtil {
}
/**
- * Look up all contributed completion proposal filters
+ * Look up all contributed completion proposal filters
* and return their names as a semicolon-separated list
* plus a leading entry for the selected index 0,
* plus a leading <default> entry. <br>
@@ -92,30 +92,27 @@ public class ProposalFilterPreferencesUtil {
}
/**
- * Return the configuration element which corresponds
+ * Return the configuration element which corresponds
* to the human-readable filter name
* @param filterName The human-readable filter name
* @return The configuration element, or null if there is none
*/
public static IConfigurationElement getElementForName(String filterName) {
IConfigurationElement element = null;
- IExtensionPoint point = Platform.getExtensionRegistry()
- .getExtensionPoint(CUIPlugin.PLUGIN_ID, "ProposalFilter"); //$NON-NLS-1$
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ "ProposalFilter"); //$NON-NLS-1$
if (point != null) {
try {
IExtension[] extensions = point.getExtensions();
if (extensions.length >= 1) {
for (IExtension extension : extensions) {
- IConfigurationElement[] elements = extension
- .getConfigurationElements();
+ IConfigurationElement[] elements = extension.getConfigurationElements();
for (int j = 0; j < elements.length; ++j) {
IConfigurationElement testElement = elements[j];
if ("ProposalFilter".equals(testElement.getName())) { //$NON-NLS-1$
- String testName = testElement
- .getAttribute("name"); //$NON-NLS-1$
- if ((null != testName)
- && (filterName.equals(testName))) {
+ String testName = testElement.getAttribute("name"); //$NON-NLS-1$
+ if ((null != testName) && (filterName.equals(testName))) {
element = testElement;
break;
}
@@ -137,7 +134,7 @@ public class ProposalFilterPreferencesUtil {
/**
* The state of a Combo consists of the list of entries
* and the index of the selected entry.
- * This method converts the state of the given Combo
+ * This method converts the state of the given Combo
* to a string representation for storage in a preference store. <br>
* The string contains a semicolon-separated list of entries.
* The first entry is the index of the selected entry.
@@ -175,8 +172,7 @@ public class ProposalFilterPreferencesUtil {
if (endFirstEntry > 0) { // First entry must contain at least one character
String selectedString = text.substring(0, endFirstEntry);
int selectedIndex = Integer.parseInt(selectedString);
- String[] entryList = text.substring(endFirstEntry + 1,
- text.length()).split(";"); //$NON-NLS-1$
+ String[] entryList = text.substring(endFirstEntry + 1, text.length()).split(";"); //$NON-NLS-1$
combo.setItems(entryList);
combo.select(selectedIndex);
}
@@ -194,22 +190,20 @@ public class ProposalFilterPreferencesUtil {
public String[] items;
}
- /**
+ /**
* Convenience method to extract the state of a Combo
* from the state string stored e.g. in a preference store
* @param comboPreference The state string
- * @return A ComboState instance.
+ * @return A ComboState instance.
*/
public static ComboState getComboState(String comboPreference) {
ComboState state = new ComboState();
try {
int endFirstEntry = comboPreference.indexOf(";"); //$NON-NLS-1$
if (endFirstEntry > 0) { // First entry must contain at least one character
- String selectedString = comboPreference.substring(0,
- endFirstEntry);
+ String selectedString = comboPreference.substring(0, endFirstEntry);
state.selectedIndex = Integer.parseInt(selectedString);
- state.items = comboPreference.substring(endFirstEntry + 1,
- comboPreference.length()).split(";"); //$NON-NLS-1$
+ state.items = comboPreference.substring(endFirstEntry + 1, comboPreference.length()).split(";"); //$NON-NLS-1$
}
} catch (NumberFormatException e) {
// If this fails we return an empty ComboState
@@ -226,10 +220,8 @@ public class ProposalFilterPreferencesUtil {
public static IConfigurationElement getPreferredFilterElement() {
IConfigurationElement preferredElement = null;
try {
- IPreferenceStore store = CUIPlugin.getDefault()
- .getPreferenceStore();
- String filterComboStateString = store
- .getString(ContentAssistPreference.PROPOSALS_FILTER);
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ String filterComboStateString = store.getString(ContentAssistPreference.PROPOSALS_FILTER);
ComboState state = getComboState(filterComboStateString);
preferredElement = getElementForName(state.items[state.selectedIndex]);
} catch (Exception e) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePage.java
index f13e8e8698b..38b23e24c53 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePage.java
@@ -52,20 +52,17 @@ public class SaveActionsPreferencePage extends AbstractPreferencePage {
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- FORMAT_SOURCE_CODE));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, FORMAT_SOURCE_CODE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
FORMAT_SOURCE_CODE_LIMIT_TO_EDITED_LINES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- REMOVE_TRAILING_WHITESPACE));
+ overlayKeys
+ .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, REMOVE_TRAILING_WHITESPACE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- ENSURE_NEWLINE_AT_EOF));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
- ALIGN_ALL_CONST));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ENSURE_NEWLINE_AT_EOF));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ALIGN_ALL_CONST));
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+ OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
}
@@ -73,8 +70,7 @@ public class SaveActionsPreferencePage extends AbstractPreferencePage {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
- ICHelpContextIds.SAVE_ACTIONS_PREFERENCE_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.SAVE_ACTIONS_PREFERENCE_PAGE);
}
/**
@@ -92,17 +88,15 @@ public class SaveActionsPreferencePage extends AbstractPreferencePage {
}
private Control createConfigurationBlock(Composite parent) {
- Composite composite= ControlFactory.createComposite(parent, 1);
+ Composite composite = ControlFactory.createComposite(parent, 1);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- Button checkboxFormat = addCheckBox(composite,
- PreferencesMessages.SaveActionsPreferencePage_formatSourceCode, FORMAT_SOURCE_CODE, 0);
+ Button checkboxFormat = addCheckBox(composite, PreferencesMessages.SaveActionsPreferencePage_formatSourceCode,
+ FORMAT_SOURCE_CODE, 0);
Composite group = createRadioContainer(composite);
- fRadioFormatAllLines = addRadioButton(group,
- PreferencesMessages.SaveActionsPreferencePage_formatAllLines,
- null, 0);
- fRadioFormatEditedLines = addRadioButton(group,
- PreferencesMessages.SaveActionsPreferencePage_formatEditedLines,
+ fRadioFormatAllLines = addRadioButton(group, PreferencesMessages.SaveActionsPreferencePage_formatAllLines, null,
+ 0);
+ fRadioFormatEditedLines = addRadioButton(group, PreferencesMessages.SaveActionsPreferencePage_formatEditedLines,
REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES, 0);
createDependency(checkboxFormat, FORMAT_SOURCE_CODE, fRadioFormatAllLines);
createDependency(checkboxFormat, FORMAT_SOURCE_CODE, fRadioFormatEditedLines);
@@ -110,29 +104,23 @@ public class SaveActionsPreferencePage extends AbstractPreferencePage {
ControlFactory.createEmptySpace(composite, 1);
Button checkboxTrailingWhitespace = addCheckBox(composite,
- PreferencesMessages.SaveActionsPreferencePage_removeTrailingWhitespace,
- REMOVE_TRAILING_WHITESPACE, 0);
+ PreferencesMessages.SaveActionsPreferencePage_removeTrailingWhitespace, REMOVE_TRAILING_WHITESPACE, 0);
group = createRadioContainer(composite);
fRadioTrailingWhitespaceAllLines = addRadioButton(group,
- PreferencesMessages.SaveActionsPreferencePage_inAllLines,
- null, 0);
+ PreferencesMessages.SaveActionsPreferencePage_inAllLines, null, 0);
fRadioTrailingWhitespaceEditedLines = addRadioButton(group,
PreferencesMessages.SaveActionsPreferencePage_inEditedLines,
REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES, 0);
- createDependency(checkboxTrailingWhitespace, REMOVE_TRAILING_WHITESPACE,
- fRadioTrailingWhitespaceAllLines);
- createDependency(checkboxTrailingWhitespace, REMOVE_TRAILING_WHITESPACE,
- fRadioTrailingWhitespaceEditedLines);
+ createDependency(checkboxTrailingWhitespace, REMOVE_TRAILING_WHITESPACE, fRadioTrailingWhitespaceAllLines);
+ createDependency(checkboxTrailingWhitespace, REMOVE_TRAILING_WHITESPACE, fRadioTrailingWhitespaceEditedLines);
ControlFactory.createEmptySpace(composite, 1);
- addCheckBox(composite, PreferencesMessages.SaveActionsPreferencePage_ensureNewline,
- ENSURE_NEWLINE_AT_EOF, 0);
+ addCheckBox(composite, PreferencesMessages.SaveActionsPreferencePage_ensureNewline, ENSURE_NEWLINE_AT_EOF, 0);
ControlFactory.createEmptySpace(composite, 1);
- addCheckBox(composite, PreferencesMessages.SaveActionsPreferencePage_alignConst,
- ALIGN_ALL_CONST, 0);
+ addCheckBox(composite, PreferencesMessages.SaveActionsPreferencePage_alignConst, ALIGN_ALL_CONST, 0);
return composite;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityIntegerFieldEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityIntegerFieldEditor.java
index 62047d636a6..23a7b553145 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityIntegerFieldEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityIntegerFieldEditor.java
@@ -39,7 +39,7 @@ public class ScalabilityIntegerFieldEditor extends IntegerFieldEditor {
public ScalabilityIntegerFieldEditor(String enableKey, String nameKey, String labelText, Composite parent) {
super(nameKey, labelText, parent);
- fEnableKey= enableKey;
+ fEnableKey = enableKey;
}
@Override
@@ -47,17 +47,18 @@ public class ScalabilityIntegerFieldEditor extends IntegerFieldEditor {
Text control = super.getTextControl(parent);
if (fDecoration == null) {
fDecoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP);
- FieldDecoration errorDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
+ FieldDecoration errorDecoration = FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
fDecoration.setImage(errorDecoration.getImage());
fDecoration.setDescriptionText(getErrorMessage());
// validate on focus gain
- control.addFocusListener(new FocusAdapter() {
- @Override
+ control.addFocusListener(new FocusAdapter() {
+ @Override
public void focusGained(FocusEvent e) {
- refreshValidState();
- }
- });
+ refreshValidState();
+ }
+ });
}
return control;
}
@@ -87,11 +88,11 @@ public class ScalabilityIntegerFieldEditor extends IntegerFieldEditor {
private Button getCheckboxControl(Composite parent) {
if (fCheckbox == null) {
- Composite inner= new Composite(parent, SWT.NULL);
- final GridLayout layout= new GridLayout(2, false);
+ Composite inner = new Composite(parent, SWT.NULL);
+ final GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
inner.setLayout(layout);
- fCheckbox= new Button(inner, SWT.CHECK);
+ fCheckbox = new Button(inner, SWT.CHECK);
fCheckbox.setFont(parent.getFont());
fCheckbox.setText(getLabelText());
// create and hide label from base class
@@ -101,9 +102,9 @@ public class ScalabilityIntegerFieldEditor extends IntegerFieldEditor {
fCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- boolean isSelected = fCheckbox.getSelection();
- valueChanged(fWasSelected, isSelected);
- fWasSelected = isSelected;
+ boolean isSelected = fCheckbox.getSelection();
+ valueChanged(fWasSelected, isSelected);
+ fWasSelected = isSelected;
}
});
} else {
@@ -114,7 +115,7 @@ public class ScalabilityIntegerFieldEditor extends IntegerFieldEditor {
@Override
public Label getLabelControl(Composite parent) {
- final Label label= getLabelControl();
+ final Label label = getLabelControl();
if (label == null) {
return super.getLabelControl(parent);
} else {
@@ -124,11 +125,11 @@ public class ScalabilityIntegerFieldEditor extends IntegerFieldEditor {
}
protected void valueChanged(boolean oldValue, boolean newValue) {
- if (oldValue != newValue) {
- valueChanged();
+ if (oldValue != newValue) {
+ valueChanged();
fireStateChanged(VALUE, oldValue, newValue);
- getTextControl().setEnabled(newValue);
- getLabelControl().setEnabled(newValue);
+ getTextControl().setEnabled(newValue);
+ getLabelControl().setEnabled(newValue);
}
}
@@ -144,55 +145,55 @@ public class ScalabilityIntegerFieldEditor extends IntegerFieldEditor {
@Override
protected void doLoad() {
super.doLoad();
- if (fCheckbox != null) {
- boolean value = getPreferenceStore().getBoolean(fEnableKey);
- fCheckbox.setSelection(value);
- fWasSelected = value;
- getTextControl().setEnabled(value);
- getLabelControl().setEnabled(value);
- }
+ if (fCheckbox != null) {
+ boolean value = getPreferenceStore().getBoolean(fEnableKey);
+ fCheckbox.setSelection(value);
+ fWasSelected = value;
+ getTextControl().setEnabled(value);
+ getLabelControl().setEnabled(value);
+ }
}
@Override
protected void doLoadDefault() {
super.doLoadDefault();
- if (fCheckbox != null) {
- boolean value = getPreferenceStore().getDefaultBoolean(fEnableKey);
- fCheckbox.setSelection(value);
- fWasSelected = value;
- getTextControl().setEnabled(value);
- getLabelControl().setEnabled(value);
- }
+ if (fCheckbox != null) {
+ boolean value = getPreferenceStore().getDefaultBoolean(fEnableKey);
+ fCheckbox.setSelection(value);
+ fWasSelected = value;
+ getTextControl().setEnabled(value);
+ getLabelControl().setEnabled(value);
+ }
}
- @Override
+ @Override
protected void doStore() {
- super.doStore();
- getPreferenceStore().setValue(fEnableKey, fCheckbox.getSelection());
- }
-
- /**
- * Returns this field editor's current boolean value.
- *
- * @return the value
- */
- public boolean getBooleanValue() {
- return fCheckbox.getSelection();
- }
-
- /**
- * Set the checkbox selection and enablement of the other controls as specified.
- */
- public void setBooleanValue(boolean value) {
- // The checkbox selection will normally be propagated to the label and text controls in the
- // checkbox selection listener. However, the callback is only invoked when the selection changes,
- // which means that an initial value of false will not be properly propagated. The state is
- // directly updated here.
- if (fCheckbox != null) {
- fWasSelected = value;
- getLabelControl().setEnabled(value);
- getTextControl().setEnabled(value);
- fCheckbox.setSelection(value);
- }
- }
+ super.doStore();
+ getPreferenceStore().setValue(fEnableKey, fCheckbox.getSelection());
+ }
+
+ /**
+ * Returns this field editor's current boolean value.
+ *
+ * @return the value
+ */
+ public boolean getBooleanValue() {
+ return fCheckbox.getSelection();
+ }
+
+ /**
+ * Set the checkbox selection and enablement of the other controls as specified.
+ */
+ public void setBooleanValue(boolean value) {
+ // The checkbox selection will normally be propagated to the label and text controls in the
+ // checkbox selection listener. However, the callback is only invoked when the selection changes,
+ // which means that an initial value of false will not be properly propagated. The state is
+ // directly updated here.
+ if (fCheckbox != null) {
+ fWasSelected = value;
+ getLabelControl().setEnabled(value);
+ getTextControl().setEnabled(value);
+ fCheckbox.setSelection(value);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePage.java
index cd7bf089b8d..9611fb89e06 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePage.java
@@ -52,18 +52,18 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator;
public class ScalabilityPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
+
// Files with this number of lines will trigger scalability mode
private IntegerFieldEditor fLinesToTrigger;
-
+
private Button fEnableAll;
-
+
private Button fReconciler;
-
+
private Button fSyntaxColor;
-
+
private Button fSemanticHighlighting;
-
+
private Button fContentAssist;
private Button fContentAssistAutoActivation;
@@ -72,52 +72,52 @@ public class ScalabilityPreferencePage extends PreferencePage implements IWorkbe
private ScalabilityIntegerFieldEditor fMaximumTokens;
- private final Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
+ private final Map<Object, String> fCheckBoxes = new HashMap<Object, String>();
/**
* List of master/slave listeners when there's a dependency.
- *
+ *
* @see #createDependency(Button, String, Control)
*/
- private final ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
-
+ private final ArrayList<Object> fMasterSlaveListeners = new ArrayList<Object>();
+
public ScalabilityPreferencePage() {
setPreferenceStore(PreferenceConstants.getPreferenceStore());
setDescription(PreferencesMessages.ScalabilityPreferencePage_description);
}
-
+
/**
* Creates a button with the given label and sets the default configuration data.
*/
- private Button createCheckButton( Composite parent, String label, String key ) {
- Button button = new Button( parent, SWT.CHECK | SWT.LEFT );
- button.setText( label );
+ private Button createCheckButton(Composite parent, String label, String key) {
+ Button button = new Button(parent, SWT.CHECK | SWT.LEFT);
+ button.setText(label);
// FieldEditor GridData
GridData data = new GridData();
- button.setLayoutData( data );
+ button.setLayoutData(data);
fCheckBoxes.put(button, key);
return button;
}
-
+
private void initFields() {
- IPreferenceStore prefs=getPreferenceStore();
+ IPreferenceStore prefs = getPreferenceStore();
- Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+ Iterator<Object> iter = fCheckBoxes.keySet().iterator();
while (iter.hasNext()) {
- Button b= (Button) iter.next();
- String key= fCheckBoxes.get(b);
+ Button b = (Button) iter.next();
+ String key = fCheckBoxes.get(b);
b.setSelection(prefs.getBoolean(key));
}
- // Update slaves
- iter= fMasterSlaveListeners.iterator();
- while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
- listener.widgetSelected(null);
- }
- fLinesToTrigger.setStringValue(Integer.toString(prefs.getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
- fMaximumTrivialExpressions.load();
- fMaximumTokens.load();
+ // Update slaves
+ iter = fMasterSlaveListeners.iterator();
+ while (iter.hasNext()) {
+ SelectionListener listener = (SelectionListener) iter.next();
+ listener.widgetSelected(null);
+ }
+ fLinesToTrigger.setStringValue(Integer.toString(prefs.getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
+ fMaximumTrivialExpressions.load();
+ fMaximumTokens.load();
}
/*
@@ -135,24 +135,24 @@ public class ScalabilityPreferencePage extends PreferencePage implements IWorkbe
@Override
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
- int nColumns= 1;
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.numColumns= nColumns;
+ int nColumns = 1;
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = 0;
+ layout.numColumns = nColumns;
composite.setLayout(layout);
-
+
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData( data );
-
+ composite.setLayoutData(data);
+
createDetectionSettings(composite);
new Separator().doFillIntoGrid(composite, nColumns);
-
+
createScalabilityModeSettings(composite);
new Separator().doFillIntoGrid(composite, nColumns);
@@ -161,11 +161,11 @@ public class ScalabilityPreferencePage extends PreferencePage implements IWorkbe
new Separator().doFillIntoGrid(composite, nColumns);
- String noteTitle= PreferencesMessages.ScalabilityPreferencePage_note;
- String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewEditors;
- Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
+ String noteTitle = PreferencesMessages.ScalabilityPreferencePage_note;
+ String noteMessage = PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewEditors;
+ Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
noteControl.setLayoutData(gd);
initFields();
@@ -185,69 +185,76 @@ public class ScalabilityPreferencePage extends PreferencePage implements IWorkbe
* the text label of the new composite
* @return the newly-created composite
*/
- private Composite createGroupComposite( Composite parent, int numColumns, String labelText ) {
- return ControlFactory.createGroup( parent, labelText, numColumns );
+ private Composite createGroupComposite(Composite parent, int numColumns, String labelText) {
+ return ControlFactory.createGroup(parent, labelText, numColumns);
}
/**
* Create the view setting preferences composite widget
*/
- private void createDetectionSettings( Composite parent ) {
- Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_detection_group_label );
- createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_detection_label,PreferenceConstants.SCALABILITY_ALERT);
+ private void createDetectionSettings(Composite parent) {
+ Composite group = createGroupComposite(parent, 1,
+ PreferencesMessages.ScalabilityPreferencePage_detection_group_label);
+ createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_detection_label,
+ PreferenceConstants.SCALABILITY_ALERT);
- Composite comp= new Composite(group, SWT.NONE);
+ Composite comp = new Composite(group, SWT.NONE);
fLinesToTrigger = createIntegerField(comp, PreferenceConstants.SCALABILITY_NUMBER_OF_LINES,
PreferencesMessages.ScalabilityPreferencePage_trigger_lines_label, 1, Integer.MAX_VALUE);
}
-
+
/**
* Create the view setting preferences composite widget
*/
- private void createScalabilityModeSettings( Composite parent ) {
- Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_group_label );
-
- fEnableAll = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_label, PreferenceConstants.SCALABILITY_ENABLE_ALL);
- fReconciler = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_reconciler_label, PreferenceConstants.SCALABILITY_RECONCILER);
+ private void createScalabilityModeSettings(Composite parent) {
+ Composite group = createGroupComposite(parent, 1,
+ PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_group_label);
+
+ fEnableAll = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_label,
+ PreferenceConstants.SCALABILITY_ENABLE_ALL);
+ fReconciler = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_reconciler_label,
+ PreferenceConstants.SCALABILITY_RECONCILER);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fReconciler, true);
-
- fSemanticHighlighting = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_semanticHighlighting_label, PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT);
+
+ fSemanticHighlighting = createCheckButton(group,
+ PreferencesMessages.ScalabilityPreferencePage_semanticHighlighting_label,
+ PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fSemanticHighlighting, true);
-
- fSyntaxColor = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_syntaxColor_label, PreferenceConstants.SCALABILITY_SYNTAX_COLOR);
+
+ fSyntaxColor = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_syntaxColor_label,
+ PreferenceConstants.SCALABILITY_SYNTAX_COLOR);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fSyntaxColor, true);
-
- fContentAssist = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_label, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
+
+ fContentAssist = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_label,
+ PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fContentAssist, true);
-
- fContentAssistAutoActivation = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_autoActivation, PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION);
- createDependency(fContentAssist, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST, fContentAssistAutoActivation, true);
+
+ fContentAssistAutoActivation = createCheckButton(group,
+ PreferencesMessages.ScalabilityPreferencePage_contentAssist_autoActivation,
+ PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION);
+ createDependency(fContentAssist, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST,
+ fContentAssistAutoActivation, true);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fContentAssistAutoActivation, false);
}
private void createParserSettings(Composite parent) {
- Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_parserSettings_group_label );
-
- fMaximumTrivialExpressions
- = createScalabilityIntegerField(
- group,
- CCorePreferenceConstants.SCALABILITY_SKIP_TRIVIAL_EXPRESSIONS,
- CCorePreferenceConstants.SCALABILITY_MAXIMUM_TRIVIAL_EXPRESSIONS,
- PreferencesMessages.ScalabilityPreferencePage_skipTrivialExpressions_label,
- 1, Integer.MAX_VALUE);
+ Composite group = createGroupComposite(parent, 1,
+ PreferencesMessages.ScalabilityPreferencePage_parserSettings_group_label);
+
+ fMaximumTrivialExpressions = createScalabilityIntegerField(group,
+ CCorePreferenceConstants.SCALABILITY_SKIP_TRIVIAL_EXPRESSIONS,
+ CCorePreferenceConstants.SCALABILITY_MAXIMUM_TRIVIAL_EXPRESSIONS,
+ PreferencesMessages.ScalabilityPreferencePage_skipTrivialExpressions_label, 1, Integer.MAX_VALUE);
fMaximumTrivialExpressions.setPreferenceStore(CUIPlugin.getDefault().getCorePreferenceStore());
- fMaximumTokens
- = createScalabilityIntegerField(
- group,
- CCorePreferenceConstants.SCALABILITY_LIMIT_TOKENS_PER_TU,
- CCorePreferenceConstants.SCALABILITY_MAXIMUM_TOKENS,
- PreferencesMessages.ScalabilityPreferencePage_maximumTokensPerTU_label,
- 1, 1000000000);
+ fMaximumTokens = createScalabilityIntegerField(group, CCorePreferenceConstants.SCALABILITY_LIMIT_TOKENS_PER_TU,
+ CCorePreferenceConstants.SCALABILITY_MAXIMUM_TOKENS,
+ PreferencesMessages.ScalabilityPreferencePage_maximumTokensPerTU_label, 1, 1000000000);
fMaximumTokens.setPreferenceStore(CUIPlugin.getDefault().getCorePreferenceStore());
}
- private IntegerFieldEditor createIntegerField(Composite parent, String name, String labelText, int rangeMinimum, int rangeMaximum) {
+ private IntegerFieldEditor createIntegerField(Composite parent, String name, String labelText, int rangeMinimum,
+ int rangeMaximum) {
final IntegerFieldEditor integerField = new IntegerFieldEditor(name, labelText, parent);
GridData data = (GridData) integerField.getTextControl(parent).getLayoutData();
@@ -269,7 +276,8 @@ public class ScalabilityPreferencePage extends PreferencePage implements IWorkbe
return integerField;
}
- private ScalabilityIntegerFieldEditor createScalabilityIntegerField(Composite parent, String enable, String name, String labelText, int rangeMinimum, int rangeMaximum) {
+ private ScalabilityIntegerFieldEditor createScalabilityIntegerField(Composite parent, String enable, String name,
+ String labelText, int rangeMinimum, int rangeMaximum) {
final ScalabilityIntegerFieldEditor field = new ScalabilityIntegerFieldEditor(enable, name, labelText, parent);
GridData data = (GridData) field.getTextControl(parent).getLayoutData();
@@ -292,55 +300,56 @@ public class ScalabilityPreferencePage extends PreferencePage implements IWorkbe
}
private static void indent(Control control, GridData masterLayoutData) {
- GridData gridData= new GridData();
- gridData.horizontalIndent= masterLayoutData.horizontalIndent + 20;
+ GridData gridData = new GridData();
+ gridData.horizontalIndent = masterLayoutData.horizontalIndent + 20;
control.setLayoutData(gridData);
}
-
+
private void createDependency(final Button master, String masterKey, final Control slave, boolean indent) {
if (indent) {
- indent(slave, (GridData)master.getLayoutData());
+ indent(slave, (GridData) master.getLayoutData());
}
- boolean masterState= getPreferenceStore().getBoolean(masterKey);
+ boolean masterState = getPreferenceStore().getBoolean(masterKey);
slave.setEnabled(!masterState);
-
+
if (masterState) {
- ((Button)slave).setSelection(masterState);
+ ((Button) slave).setSelection(masterState);
}
-
- SelectionListener listener= new SelectionListener() {
+
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
slave.setEnabled(!master.getSelection());
if (master.getSelection()) {
- ((Button)slave).setSelection(master.getSelection());
+ ((Button) slave).setSelection(master.getSelection());
}
}
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
};
master.addSelectionListener(listener);
fMasterSlaveListeners.add(listener);
}
-
+
/*
* @see IWorkbenchPreferencePage#init(IWorkbench)
*/
@Override
public void init(IWorkbench workbench) {
}
-
+
/*
* @see IPreferencePage#performOk()
*/
@Override
public boolean performOk() {
- IPreferenceStore prefs= getPreferenceStore();
- Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+ IPreferenceStore prefs = getPreferenceStore();
+ Iterator<Object> iter = fCheckBoxes.keySet().iterator();
while (iter.hasNext()) {
- Button b= (Button) iter.next();
- String key= fCheckBoxes.get(b);
+ Button b = (Button) iter.next();
+ String key = fCheckBoxes.get(b);
prefs.setValue(key, b.getSelection());
}
prefs.setValue(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, fLinesToTrigger.getIntValue());
@@ -348,29 +357,30 @@ public class ScalabilityPreferencePage extends PreferencePage implements IWorkbe
fMaximumTokens.store();
return super.performOk();
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
@Override
protected void performDefaults() {
- IPreferenceStore prefs= getPreferenceStore();
+ IPreferenceStore prefs = getPreferenceStore();
- Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+ Iterator<Object> iter = fCheckBoxes.keySet().iterator();
while (iter.hasNext()) {
- Button b= (Button) iter.next();
- String key= fCheckBoxes.get(b);
+ Button b = (Button) iter.next();
+ String key = fCheckBoxes.get(b);
b.setSelection(prefs.getDefaultBoolean(key));
}
- // Update slaves
- iter= fMasterSlaveListeners.iterator();
- while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
- listener.widgetSelected(null);
- }
- fLinesToTrigger.setStringValue(Integer.toString(prefs.getDefaultInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
- fMaximumTrivialExpressions.loadDefault();
- fMaximumTokens.loadDefault();
+ // Update slaves
+ iter = fMasterSlaveListeners.iterator();
+ while (iter.hasNext()) {
+ SelectionListener listener = (SelectionListener) iter.next();
+ listener.widgetSelected(null);
+ }
+ fLinesToTrigger
+ .setStringValue(Integer.toString(prefs.getDefaultInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
+ fMaximumTrivialExpressions.loadDefault();
+ fMaximumTokens.loadDefault();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java
index c600a38b988..fa78a7d1e05 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java
@@ -22,34 +22,33 @@ import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.SharedScrolledComposite;
-
public class ScrolledPageContent extends SharedScrolledComposite {
private FormToolkit fToolkit;
-
+
public ScrolledPageContent(Composite parent) {
this(parent, SWT.V_SCROLL | SWT.H_SCROLL);
}
-
+
public ScrolledPageContent(Composite parent, int style) {
super(parent, style);
-
+
setFont(parent.getFont());
-
- FormColors colors= new FormColors(parent.getDisplay());
+
+ FormColors colors = new FormColors(parent.getDisplay());
colors.setBackground(null);
colors.setForeground(null);
-
- fToolkit= new FormToolkit(colors);
-
+
+ fToolkit = new FormToolkit(colors);
+
setExpandHorizontal(true);
setExpandVertical(true);
-
- Composite body= new Composite(this, SWT.NONE);
+
+ Composite body = new Composite(this, SWT.NONE);
body.setFont(parent.getFont());
setContent(body);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.swt.widgets.Widget#dispose()
*/
@@ -58,11 +57,11 @@ public class ScrolledPageContent extends SharedScrolledComposite {
fToolkit.dispose();
super.dispose();
}
-
+
public void adaptChild(Control childControl) {
fToolkit.adapt(childControl, true, true);
}
-
+
public Composite getBody() {
return (Composite) getContent();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
index 858d571e491..a41c0074549 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
@@ -51,162 +51,172 @@ class SmartTypingConfigurationBlock extends AbstractConfigurationBlock {
super(store);
store.addKeys(createOverlayStoreKeys());
}
-
+
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
return new OverlayPreferenceStore.OverlayKey[] {
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_AUTO_INDENT),
-
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS),
-
-// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_SEMICOLON),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_TAB),
-// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_OPENING_BRACE),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_SMART_PASTE),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_AUTO_INDENT),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_CLOSE_STRINGS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_CLOSE_BRACKETS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_CLOSE_BRACES),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_WRAP_STRINGS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_ESCAPE_STRINGS),
+
+ // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_SEMICOLON),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_SMART_TAB),
+ // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_OPENING_BRACE),
};
- }
+ }
/**
* Creates page for mark occurrences preferences.
- *
+ *
* @param parent the parent composite
* @return the control for the preference page
*/
@Override
public Control createControl(Composite parent) {
- ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ ScrolledPageContent scrolled = new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
-
- Composite control= new Composite(scrolled, SWT.NONE);
- GridLayout layout= new GridLayout();
+
+ Composite control = new Composite(scrolled, SWT.NONE);
+ GridLayout layout = new GridLayout();
control.setLayout(layout);
Composite composite;
-
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoclose_title);
+
+ composite = createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoclose_title);
addAutoclosingSection(composite);
-
-// composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_automove_title);
-// addAutopositionSection(composite);
-
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_tabs_title);
+
+ // composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_automove_title);
+ // addAutopositionSection(composite);
+
+ composite = createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_tabs_title);
addTabSection(composite);
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_pasting_title);
+ composite = createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_pasting_title);
addPasteSection(composite);
-
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_strings_title);
+
+ composite = createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_strings_title);
addStringsSection(composite);
- composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoindent_title);
+ composite = createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoindent_title);
addAutoIndentSection(composite);
scrolled.setContent(control);
- final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ final Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrolled.setMinSize(size.x, size.y);
return scrolled;
}
private void addAutoIndentSection(Composite composite) {
- GridLayout layout= new GridLayout();
+ GridLayout layout = new GridLayout();
composite.setLayout(layout);
String label;
- label= PreferencesMessages.SmartTypingConfigurationBlock_autoindent_newlines;
+ label = PreferencesMessages.SmartTypingConfigurationBlock_autoindent_newlines;
addCheckBox(composite, label, PreferenceConstants.EDITOR_AUTO_INDENT, 0);
}
private void addStringsSection(Composite composite) {
- GridLayout layout= new GridLayout();
+ GridLayout layout = new GridLayout();
composite.setLayout(layout);
String label;
Button master, slave;
- label= PreferencesMessages.CEditorPreferencePage_wrapStrings;
- master= addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 0);
-
- label= PreferencesMessages.CEditorPreferencePage_escapeStrings;
- slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 0);
+ label = PreferencesMessages.CEditorPreferencePage_wrapStrings;
+ master = addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 0);
+
+ label = PreferencesMessages.CEditorPreferencePage_escapeStrings;
+ slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 0);
createDependency(master, slave);
}
private void addPasteSection(Composite composite) {
- GridLayout layout= new GridLayout();
+ GridLayout layout = new GridLayout();
composite.setLayout(layout);
String label;
- label= PreferencesMessages.CEditorPreferencePage_smartPaste;
+ label = PreferencesMessages.CEditorPreferencePage_smartPaste;
addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE, 0);
}
private void addTabSection(Composite composite) {
- GridLayout layout= new GridLayout();
+ GridLayout layout = new GridLayout();
composite.setLayout(layout);
String label;
- label= PreferencesMessages.CEditorPreferencePage_typing_smartTab;
+ label = PreferencesMessages.CEditorPreferencePage_typing_smartTab;
addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_TAB, 0);
-
+
createMessage(composite);
}
-// private void addAutopositionSection(Composite composite) {
-// GridLayout layout= new GridLayout();
-// composite.setLayout(layout);
-//
-// String label;
-//
-// label= PreferencesMessages.CEditorPreferencePage_typing_smartSemicolon;
-// addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_SEMICOLON, 0);
-//
-// label= PreferencesMessages.CEditorPreferencePage_typing_smartOpeningBrace;
-// addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_OPENING_BRACE, 0);
-// }
+ // private void addAutopositionSection(Composite composite) {
+ // GridLayout layout= new GridLayout();
+ // composite.setLayout(layout);
+ //
+ // String label;
+ //
+ // label= PreferencesMessages.CEditorPreferencePage_typing_smartSemicolon;
+ // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_SEMICOLON, 0);
+ //
+ // label= PreferencesMessages.CEditorPreferencePage_typing_smartOpeningBrace;
+ // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_OPENING_BRACE, 0);
+ // }
private void addAutoclosingSection(Composite composite) {
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
composite.setLayout(layout);
String label;
- label= PreferencesMessages.CEditorPreferencePage_closeStrings;
+ label = PreferencesMessages.CEditorPreferencePage_closeStrings;
addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 0);
- label= PreferencesMessages.CEditorPreferencePage_closeBrackets;
+ label = PreferencesMessages.CEditorPreferencePage_closeBrackets;
addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 0);
- label= PreferencesMessages.CEditorPreferencePage_closeAngularBrackets;
+ label = PreferencesMessages.CEditorPreferencePage_closeAngularBrackets;
addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS, 0);
- label= PreferencesMessages.CEditorPreferencePage_closeBraces;
+ label = PreferencesMessages.CEditorPreferencePage_closeBraces;
addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 0);
}
-
+
private void createMessage(final Composite composite) {
- // TODO create a link with an argument, so the formatter preference page can open the
+ // TODO create a link with an argument, so the formatter preference page can open the
// current profile automatically.
- String linkTooltip= PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tooltip;
+ String linkTooltip = PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tooltip;
String text;
- String indentMode= CUIPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+ String indentMode = CUIPlugin.getDefault().getCombinedPreferenceStore()
+ .getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
if (CCorePlugin.TAB.equals(indentMode)) {
- text= Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tab_text,
+ text = Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tab_text,
Integer.toString(getTabDisplaySize()));
} else {
- text= Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_others_text,
+ text = Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_others_text,
Integer.toString(getTabDisplaySize()), Integer.toString(getIndentSize()), getIndentMode());
}
-
- final Link link= new Link(composite, SWT.NONE);
+
+ final Link link = new Link(composite, SWT.NONE);
link.setText(text);
link.setToolTipText(linkTooltip);
- GridData gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gd.widthHint= 300; // don't get wider initially
+ GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ gd.widthHint = 300; // don't get wider initially
link.setLayoutData(gd);
link.addSelectionListener(new SelectionAdapter() {
@Override
@@ -215,20 +225,21 @@ class SmartTypingConfigurationBlock extends AbstractConfigurationBlock {
"org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage", null, null); //$NON-NLS-1$
}
});
-
- final IPreferenceStore combinedStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
- final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
- private boolean fHasRun= false;
+
+ final IPreferenceStore combinedStore = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
+ private boolean fHasRun = false;
+
@Override
public void propertyChange(PropertyChangeEvent event) {
if (fHasRun)
return;
if (composite.isDisposed())
return;
- String property= event.getProperty();
+ String property = event.getProperty();
if (DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR.equals(property)
|| DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)) {
- fHasRun= true;
+ fHasRun = true;
link.dispose();
createMessage(composite);
Dialog.applyDialogFont(composite);
@@ -247,14 +258,15 @@ class SmartTypingConfigurationBlock extends AbstractConfigurationBlock {
}
private String getIndentMode() {
- String indentMode= CUIPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
-
+ String indentMode = CUIPlugin.getDefault().getCombinedPreferenceStore()
+ .getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+
if (CCorePlugin.SPACE.equals(indentMode))
- return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_spaces;
-
+ return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_spaces;
+
if (CCorePlugin.TAB.equals(indentMode))
return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabs;
-
+
if (DefaultCodeFormatterConstants.MIXED.equals(indentMode))
return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
@@ -265,7 +277,7 @@ class SmartTypingConfigurationBlock extends AbstractConfigurationBlock {
private int getIndentSize() {
return CodeFormatterUtil.getIndentWidth(null);
}
-
+
private int getTabDisplaySize() {
return CodeFormatterUtil.getTabWidth(null);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java
index a8a8ed326df..40b3f91bc91 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java
@@ -32,20 +32,20 @@ public final class SmartTypingPreferencePage extends AbstractConfigurationBlockP
@Override
protected void setDescription() {
- String description= PreferencesMessages.CEditorPreferencePage_typing_tabTitle;
+ String description = PreferencesMessages.CEditorPreferencePage_typing_tabTitle;
setDescription(description);
}
-
+
@Override
protected void setPreferenceStore() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
}
-
+
@Override
protected Label createDescriptionLabel(Composite parent) {
return null; // no description for new look.
}
-
+
@Override
protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
return new SmartTypingConfigurationBlock(overlayPreferenceStore);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java
index a7109eecb46..c0eae011791 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java
@@ -70,32 +70,39 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
* Currently the spelling engine cannot return word proposals but
* only correction proposals and hence this is disabled.
*/
- private static final boolean SUPPORT_CONTENT_ASSIST_PROPOSALS= false;
-
+ private static final boolean SUPPORT_CONTENT_ASSIST_PROPOSALS = false;
+
/** Preference keys for the preferences in this block */
- private static final Key PREF_SPELLING_IGNORE_DIGITS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_DIGITS);
- private static final Key PREF_SPELLING_IGNORE_MIXED= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_MIXED);
- private static final Key PREF_SPELLING_IGNORE_SENTENCE= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_SENTENCE);
- private static final Key PREF_SPELLING_IGNORE_UPPER= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_UPPER);
- private static final Key PREF_SPELLING_IGNORE_STRING_LITERALS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_STRING_LITERALS);
- private static final Key PREF_SPELLING_IGNORE_SINGLE_LETTERS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_SINGLE_LETTERS);
- private static final Key PREF_SPELLING_IGNORE_NON_LETTERS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_NON_LETTERS);
- private static final Key PREF_SPELLING_IGNORE_URLS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_URLS);
- private static final Key PREF_SPELLING_LOCALE= getCDTUIKey(PreferenceConstants.SPELLING_LOCALE);
- private static final Key PREF_SPELLING_PROPOSAL_THRESHOLD= getCDTUIKey(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);
- private static final Key PREF_SPELLING_PROBLEMS_THRESHOLD= getCDTUIKey(PreferenceConstants.SPELLING_PROBLEMS_THRESHOLD);
- private static final Key PREF_SPELLING_USER_DICTIONARY= getCDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY);
- private static final Key PREF_SPELLING_USER_DICTIONARY_ENCODING= getCDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING);
- private static final Key PREF_SPELLING_ENABLE_CONTENTASSIST= getCDTUIKey(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST);
+ private static final Key PREF_SPELLING_IGNORE_DIGITS = getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_DIGITS);
+ private static final Key PREF_SPELLING_IGNORE_MIXED = getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_MIXED);
+ private static final Key PREF_SPELLING_IGNORE_SENTENCE = getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_SENTENCE);
+ private static final Key PREF_SPELLING_IGNORE_UPPER = getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_UPPER);
+ private static final Key PREF_SPELLING_IGNORE_STRING_LITERALS = getCDTUIKey(
+ PreferenceConstants.SPELLING_IGNORE_STRING_LITERALS);
+ private static final Key PREF_SPELLING_IGNORE_SINGLE_LETTERS = getCDTUIKey(
+ PreferenceConstants.SPELLING_IGNORE_SINGLE_LETTERS);
+ private static final Key PREF_SPELLING_IGNORE_NON_LETTERS = getCDTUIKey(
+ PreferenceConstants.SPELLING_IGNORE_NON_LETTERS);
+ private static final Key PREF_SPELLING_IGNORE_URLS = getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_URLS);
+ private static final Key PREF_SPELLING_LOCALE = getCDTUIKey(PreferenceConstants.SPELLING_LOCALE);
+ private static final Key PREF_SPELLING_PROPOSAL_THRESHOLD = getCDTUIKey(
+ PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);
+ private static final Key PREF_SPELLING_PROBLEMS_THRESHOLD = getCDTUIKey(
+ PreferenceConstants.SPELLING_PROBLEMS_THRESHOLD);
+ private static final Key PREF_SPELLING_USER_DICTIONARY = getCDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY);
+ private static final Key PREF_SPELLING_USER_DICTIONARY_ENCODING = getCDTUIKey(
+ PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING);
+ private static final Key PREF_SPELLING_ENABLE_CONTENTASSIST = getCDTUIKey(
+ PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST);
/**
* The value for no platform dictionary.
*/
- private static final String PREF_VALUE_NO_LOCALE= ""; //$NON-NLS-1$
+ private static final String PREF_VALUE_NO_LOCALE = ""; //$NON-NLS-1$
/**
* Creates a selection dependency between a master and a slave control.
- *
+ *
* @param master The master button that controls the state of the slave
* @param slave The slave control that is enabled only if the master is
* selected
@@ -117,54 +124,54 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
/**
* Returns the locale codes for the locale list.
- *
+ *
* @param locales
* The list of locales
* @return Array of locale codes for the list
*/
protected static String[] getDictionaryCodes(final Set<Locale> locales) {
- int index= 0;
+ int index = 0;
- final String[] codes= new String[locales.size() + 1];
+ final String[] codes = new String[locales.size() + 1];
for (Locale locale : locales) {
- codes[index++]= locale.toString();
+ codes[index++] = locale.toString();
}
- codes[index++]= PREF_VALUE_NO_LOCALE;
+ codes[index++] = PREF_VALUE_NO_LOCALE;
return codes;
}
/**
* Returns the display labels for the locale list.
- *
+ *
* @param locales The list of locales
* @return Array of display labels for the list
*/
protected static String[] getDictionaryLabels(final Set<Locale> locales) {
- int index= 0;
+ int index = 0;
- final String[] labels= new String[locales.size() + 1];
+ final String[] labels = new String[locales.size() + 1];
for (Locale locale : locales) {
- labels[index++]= locale.getDisplayName();
+ labels[index++] = locale.getDisplayName();
}
- labels[index++]= PreferencesMessages.SpellingPreferencePage_dictionary_none;
+ labels[index++] = PreferencesMessages.SpellingPreferencePage_dictionary_none;
return labels;
}
/**
* Validates that the file with the specified absolute path exists and can
* be opened.
- *
+ *
* @param path The path of the file to validate
* @return a status without error if the path is valid
*/
protected static IStatus validateAbsoluteFilePath(String path) {
- final StatusInfo status= new StatusInfo();
- IStringVariableManager variableManager= VariablesPlugin.getDefault().getStringVariableManager();
+ final StatusInfo status = new StatusInfo();
+ IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
try {
- path= variableManager.performStringSubstitution(path);
+ path = variableManager.performStringSubstitution(path);
if (path.length() > 0) {
-
- final File file= new File(path);
+
+ final File file = new File(path);
if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite()))
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite()))
@@ -178,121 +185,123 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
/**
* Validates that the specified locale is available.
- *
+ *
* @param localeString the locale to validate
* @return The status of the validation
*/
private static IStatus validateLocale(final String localeString) {
if (PREF_VALUE_NO_LOCALE.equals(localeString))
- return new StatusInfo();
+ return new StatusInfo();
+
+ Locale locale = SpellCheckEngine.convertToLocale(localeString);
- Locale locale= SpellCheckEngine.convertToLocale(localeString);
-
if (SpellCheckEngine.findClosestLocale(locale) != null)
return new StatusInfo();
-
+
return new StatusInfo(IStatus.ERROR, PreferencesMessages.SpellingPreferencePage_locale_error);
}
-
+
/**
* Validates that the specified number is positive.
- *
+ *
* @param number the number to validate
* @return The status of the validation
*/
protected static IStatus validatePositiveNumber(final String number) {
- final StatusInfo status= new StatusInfo();
+ final StatusInfo status = new StatusInfo();
if (number.length() == 0) {
- status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold);
+ status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold);
} else {
try {
- final int value= Integer.parseInt(number);
+ final int value = Integer.parseInt(number);
if (value < 0) {
- status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
+ status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
}
} catch (NumberFormatException exception) {
- status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
+ status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
}
}
return status;
}
/** The dictionary path field */
- private Text fDictionaryPath= null;
+ private Text fDictionaryPath = null;
/** The status for the workspace dictionary file */
- private IStatus fFileStatus= new StatusInfo();
+ private IStatus fFileStatus = new StatusInfo();
/** The status for the proposal threshold */
- private IStatus fThresholdStatus= new StatusInfo();
-
+ private IStatus fThresholdStatus = new StatusInfo();
+
/** The status for the encoding field editor */
- private IStatus fEncodingFieldEditorStatus= new StatusInfo();
-
+ private IStatus fEncodingFieldEditorStatus = new StatusInfo();
+
/** The encoding field editor. */
- private EncodingFieldEditor fEncodingEditor;
+ private EncodingFieldEditor fEncodingEditor;
/** The encoding field editor's parent. */
- private Composite fEncodingEditorParent;
+ private Composite fEncodingEditorParent;
/**
* All controls
*/
private Control[] fAllControls;
-
+
/**
* All previously enabled controls
*/
private Control[] fEnabledControls;
-
+
/**
* Creates a new spelling configuration block.
- *
+ *
* @param context the status change listener
* @param project the Java project
* @param container the preference container
*/
- public SpellingConfigurationBlock(final IStatusChangeListener context, final IProject project, IWorkbenchPreferenceContainer container) {
+ public SpellingConfigurationBlock(final IStatusChangeListener context, final IProject project,
+ IWorkbenchPreferenceContainer container) {
super(context, project, getAllKeys(), container);
- IStatus status= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
+ IStatus status = validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
if (status.getSeverity() != IStatus.OK)
setValue(PREF_SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$
- status= validateLocale(getValue(PREF_SPELLING_LOCALE));
+ status = validateLocale(getValue(PREF_SPELLING_LOCALE));
if (status.getSeverity() != IStatus.OK)
setValue(PREF_SPELLING_LOCALE, SpellCheckEngine.getDefaultLocale().toString());
}
@Override
- protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
- ControlData data= new ControlData(key, values);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indent;
-
- Label labelControl= new Label(parent, SWT.LEFT | SWT.WRAP);
+ protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels,
+ int indent) {
+ ControlData data = new ControlData(key, values);
+
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = indent;
+
+ Label labelControl = new Label(parent, SWT.LEFT | SWT.WRAP);
labelControl.setText(label);
labelControl.setLayoutData(gd);
-
- Combo comboBox= new Combo(parent, SWT.READ_ONLY);
+
+ Combo comboBox = new Combo(parent, SWT.READ_ONLY);
comboBox.setItems(valueLabels);
comboBox.setData(data);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
comboBox.setLayoutData(gd);
comboBox.addSelectionListener(getSelectionListener());
-
+
fLabels.put(comboBox, labelControl);
-
- String currValue= getValue(key);
-
- Locale locale= SpellCheckEngine.convertToLocale(currValue);
- locale= SpellCheckEngine.findClosestLocale(locale);
+
+ String currValue = getValue(key);
+
+ Locale locale = SpellCheckEngine.convertToLocale(currValue);
+ locale = SpellCheckEngine.findClosestLocale(locale);
if (locale != null)
- currValue= locale.toString();
-
+ currValue = locale.toString();
+
comboBox.select(data.getSelection(currValue));
-
+
fComboBoxes.add(comboBox);
return comboBox;
}
@@ -302,56 +311,56 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
*/
@Override
protected Control createContents(final Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
- List<Control> allControls= new ArrayList<Control>();
- final PixelConverter converter= new PixelConverter(parent);
+ List<Control> allControls = new ArrayList<Control>();
+ final PixelConverter converter = new PixelConverter(parent);
- final String[] trueFalse= new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE };
+ final String[] trueFalse = new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE };
- Group user= new Group(composite, SWT.NONE);
- user.setText(PreferencesMessages.SpellingPreferencePage_group_user);
- user.setLayout(new GridLayout());
+ Group user = new Group(composite, SWT.NONE);
+ user.setText(PreferencesMessages.SpellingPreferencePage_group_user);
+ user.setLayout(new GridLayout());
user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
allControls.add(user);
- String label= PreferencesMessages.SpellingPreferencePage_ignore_digits_label;
- Control slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_DIGITS, trueFalse, 0);
+ String label = PreferencesMessages.SpellingPreferencePage_ignore_digits_label;
+ Control slave = addCheckBox(user, label, PREF_SPELLING_IGNORE_DIGITS, trueFalse, 0);
allControls.add(slave);
- label= PreferencesMessages.SpellingPreferencePage_ignore_mixed_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_MIXED, trueFalse, 0);
+ label = PreferencesMessages.SpellingPreferencePage_ignore_mixed_label;
+ slave = addCheckBox(user, label, PREF_SPELLING_IGNORE_MIXED, trueFalse, 0);
allControls.add(slave);
- label= PreferencesMessages.SpellingPreferencePage_ignore_sentence_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SENTENCE, trueFalse, 0);
+ label = PreferencesMessages.SpellingPreferencePage_ignore_sentence_label;
+ slave = addCheckBox(user, label, PREF_SPELLING_IGNORE_SENTENCE, trueFalse, 0);
allControls.add(slave);
- label= PreferencesMessages.SpellingPreferencePage_ignore_upper_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_UPPER, trueFalse, 0);
+ label = PreferencesMessages.SpellingPreferencePage_ignore_upper_label;
+ slave = addCheckBox(user, label, PREF_SPELLING_IGNORE_UPPER, trueFalse, 0);
allControls.add(slave);
- label= PreferencesMessages.SpellingPreferencePage_ignore_url_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_URLS, trueFalse, 0);
+ label = PreferencesMessages.SpellingPreferencePage_ignore_url_label;
+ slave = addCheckBox(user, label, PREF_SPELLING_IGNORE_URLS, trueFalse, 0);
allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_non_letters_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_NON_LETTERS, trueFalse, 0);
+
+ label = PreferencesMessages.SpellingPreferencePage_ignore_non_letters_label;
+ slave = addCheckBox(user, label, PREF_SPELLING_IGNORE_NON_LETTERS, trueFalse, 0);
allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_single_letters_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SINGLE_LETTERS, trueFalse, 0);
+
+ label = PreferencesMessages.SpellingPreferencePage_ignore_single_letters_label;
+ slave = addCheckBox(user, label, PREF_SPELLING_IGNORE_SINGLE_LETTERS, trueFalse, 0);
allControls.add(slave);
-
- label= PreferencesMessages.SpellingPreferencePage_ignore_string_literals_label;
- slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_STRING_LITERALS, trueFalse, 0);
+
+ label = PreferencesMessages.SpellingPreferencePage_ignore_string_literals_label;
+ slave = addCheckBox(user, label, PREF_SPELLING_IGNORE_STRING_LITERALS, trueFalse, 0);
allControls.add(slave);
-
- final Set<Locale> locales= SpellCheckEngine.getLocalesWithInstalledDictionaries();
- boolean hasPlaformDictionaries= locales.size() > 0;
-
- final Group engine= new Group(composite, SWT.NONE);
+
+ final Set<Locale> locales = SpellCheckEngine.getLocalesWithInstalledDictionaries();
+ boolean hasPlaformDictionaries = locales.size() > 0;
+
+ final Group engine = new Group(composite, SWT.NONE);
if (hasPlaformDictionaries)
engine.setText(PreferencesMessages.SpellingPreferencePage_group_dictionaries);
else
@@ -361,29 +370,30 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
allControls.add(engine);
if (hasPlaformDictionaries) {
- label= PreferencesMessages.SpellingPreferencePage_dictionary_label;
- Combo combo= addComboBox(engine, label, PREF_SPELLING_LOCALE, getDictionaryCodes(locales), getDictionaryLabels(locales), 0);
+ label = PreferencesMessages.SpellingPreferencePage_dictionary_label;
+ Combo combo = addComboBox(engine, label, PREF_SPELLING_LOCALE, getDictionaryCodes(locales),
+ getDictionaryLabels(locales), 0);
combo.setEnabled(locales.size() > 0);
allControls.add(combo);
allControls.add(fLabels.get(combo));
-
+
new Label(engine, SWT.NONE); // placeholder
}
-
- label= PreferencesMessages.SpellingPreferencePage_workspace_dictionary_label;
- fDictionaryPath= addTextField(engine, label, PREF_SPELLING_USER_DICTIONARY, 0, 0);
- GridData gd= (GridData) fDictionaryPath.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
- gd.widthHint= converter.convertWidthInCharsToPixels(40);
+
+ label = PreferencesMessages.SpellingPreferencePage_workspace_dictionary_label;
+ fDictionaryPath = addTextField(engine, label, PREF_SPELLING_USER_DICTIONARY, 0, 0);
+ GridData gd = (GridData) fDictionaryPath.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.widthHint = converter.convertWidthInCharsToPixels(40);
allControls.add(fDictionaryPath);
allControls.add(fLabels.get(fDictionaryPath));
- Composite buttons=new Composite(engine, SWT.NONE);
- buttons.setLayout(new GridLayout(2,true));
+ Composite buttons = new Composite(engine, SWT.NONE);
+ buttons.setLayout(new GridLayout(2, true));
buttons.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
- Button button= new Button(buttons, SWT.PUSH);
- button.setText(PreferencesMessages.SpellingPreferencePage_browse_label);
+
+ Button button = new Button(buttons, SWT.PUSH);
+ button.setText(PreferencesMessages.SpellingPreferencePage_browse_label);
button.addSelectionListener(new SelectionAdapter() {
@Override
@@ -394,8 +404,8 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
SWTUtil.setButtonDimensionHint(button);
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
allControls.add(button);
-
- button=new Button(buttons, SWT.PUSH);
+
+ button = new Button(buttons, SWT.PUSH);
button.setText(PreferencesMessages.SpellingPreferencePage_variables);
button.addSelectionListener(new SelectionAdapter() {
@Override
@@ -406,114 +416,128 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
SWTUtil.setButtonDimensionHint(button);
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
allControls.add(button);
-
+
// Description for user dictionary
new Label(engine, SWT.NONE); // filler
- Label description= new Label(engine, SWT.NONE);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 3;
+ Label description = new Label(engine, SWT.NONE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
description.setLayoutData(gd);
description.setText(PreferencesMessages.SpellingPreferencePage_user_dictionary_description);
allControls.add(description);
-
+
createEncodingFieldEditor(engine, allControls);
- Group advanced= new Group(composite, SWT.NONE);
- advanced.setText(PreferencesMessages.SpellingPreferencePage_group_advanced);
+ Group advanced = new Group(composite, SWT.NONE);
+ advanced.setText(PreferencesMessages.SpellingPreferencePage_group_advanced);
advanced.setLayout(new GridLayout(3, false));
advanced.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
allControls.add(advanced);
- label= PreferencesMessages.SpellingPreferencePage_problems_threshold;
- int digits= 4;
- Text text= addTextField(advanced, label, PREF_SPELLING_PROBLEMS_THRESHOLD, 0, converter.convertWidthInCharsToPixels(digits+1));
+ label = PreferencesMessages.SpellingPreferencePage_problems_threshold;
+ int digits = 4;
+ Text text = addTextField(advanced, label, PREF_SPELLING_PROBLEMS_THRESHOLD, 0,
+ converter.convertWidthInCharsToPixels(digits + 1));
text.setTextLimit(digits);
allControls.add(text);
allControls.add(fLabels.get(text));
- label= PreferencesMessages.SpellingPreferencePage_proposals_threshold;
- digits= 3;
- text= addTextField(advanced, label, PREF_SPELLING_PROPOSAL_THRESHOLD, 0, converter.convertWidthInCharsToPixels(digits+1));
+ label = PreferencesMessages.SpellingPreferencePage_proposals_threshold;
+ digits = 3;
+ text = addTextField(advanced, label, PREF_SPELLING_PROPOSAL_THRESHOLD, 0,
+ converter.convertWidthInCharsToPixels(digits + 1));
text.setTextLimit(digits);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
allControls.add(text);
allControls.add(fLabels.get(text));
if (SUPPORT_CONTENT_ASSIST_PROPOSALS) {
- label= PreferencesMessages.SpellingPreferencePage_enable_contentassist_label;
- button= addCheckBox(advanced, label, PREF_SPELLING_ENABLE_CONTENTASSIST, trueFalse, 0);
+ label = PreferencesMessages.SpellingPreferencePage_enable_contentassist_label;
+ button = addCheckBox(advanced, label, PREF_SPELLING_ENABLE_CONTENTASSIST, trueFalse, 0);
allControls.add(button);
}
- fAllControls= allControls.toArray(new Control[allControls.size()]);
-
+ fAllControls = allControls.toArray(new Control[allControls.size()]);
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.SPELLING_CONFIGURATION_BLOCK);
return composite;
}
/**
* Creates the encoding field editor.
- *
+ *
* @param composite the parent composite
* @param allControls list with all controls
*/
private void createEncodingFieldEditor(Composite composite, List<Control> allControls) {
- Label filler= new Label(composite, SWT.NONE);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 4;
+ Label filler = new Label(composite, SWT.NONE);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 4;
filler.setLayoutData(gd);
-
- Label label= new Label(composite, SWT.NONE);
+
+ Label label = new Label(composite, SWT.NONE);
label.setText(PreferencesMessages.SpellingPreferencePage_encoding_label);
label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
allControls.add(label);
-
- fEncodingEditorParent= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout(2, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+
+ fEncodingEditorParent = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
fEncodingEditorParent.setLayout(layout);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 3;
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
fEncodingEditorParent.setLayoutData(gd);
-
- fEncodingEditor= new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, fEncodingEditorParent); //$NON-NLS-1$
-
- PreferenceStore store= new PreferenceStore();
- String defaultEncoding= ResourcesPlugin.getEncoding();
+
+ fEncodingEditor = new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, //$NON-NLS-1$
+ fEncodingEditorParent);
+
+ PreferenceStore store = new PreferenceStore();
+ String defaultEncoding = ResourcesPlugin.getEncoding();
store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), defaultEncoding);
- String encoding= getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING);
+ String encoding = getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING);
if (encoding != null && encoding.length() > 0)
store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding);
fEncodingEditor.setPreferenceStore(store);
- // Redirect status messages from the field editor to the status change listener
- DialogPage fakePage= new DialogPage() {
+ // Redirect status messages from the field editor to the status change listener
+ DialogPage fakePage = new DialogPage() {
@Override
public void createControl(Composite c) {
}
+
@Override
public void setErrorMessage(String newMessage) {
- StatusInfo status= new StatusInfo();
+ StatusInfo status = new StatusInfo();
if (newMessage != null)
status.setError(newMessage);
- fEncodingFieldEditorStatus= status;
- fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
+ fEncodingFieldEditorStatus = status;
+ fContext.statusChanged(StatusUtil
+ .getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
}
};
fEncodingEditor.setPage(fakePage);
-
+
fEncodingEditor.load();
-
+
if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
fEncodingEditor.loadDefault();
}
private static Key[] getAllKeys() {
if (SUPPORT_CONTENT_ASSIST_PROPOSALS)
- return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST, PREF_SPELLING_IGNORE_STRING_LITERALS };
- return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS };
+ return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING,
+ PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE,
+ PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS,
+ PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD,
+ PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST,
+ PREF_SPELLING_IGNORE_STRING_LITERALS };
+ return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING,
+ PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE,
+ PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS,
+ PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD,
+ PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS };
}
/*
@@ -522,7 +546,7 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
protected final String[] getFullBuildDialogStrings(final boolean workspace) {
return null;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#performOk()
*/
@@ -532,10 +556,11 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
if (fEncodingEditor.presentsDefaultValue())
setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
else
- setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName()));
+ setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING,
+ fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName()));
return super.performOk();
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#performApply()
*/
@@ -545,7 +570,8 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
if (fEncodingEditor.presentsDefaultValue())
setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
else
- setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName()));
+ setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING,
+ fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName()));
return super.performApply();
}
@@ -555,30 +581,31 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
@Override
public void performDefaults() {
super.performDefaults();
-
+
setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
-
- fEncodingEditor.getPreferenceStore().setValue(fEncodingEditor.getPreferenceName(), ResourcesPlugin.getEncoding());
+
+ fEncodingEditor.getPreferenceStore().setValue(fEncodingEditor.getPreferenceName(),
+ ResourcesPlugin.getEncoding());
fEncodingEditor.load();
-
+
fEncodingEditor.loadDefault();
}
protected void handleVariablesButtonSelected() {
- StringVariableSelectionDialog dialog= new StringVariableSelectionDialog(fDictionaryPath.getShell());
+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(fDictionaryPath.getShell());
if (dialog.open() == Window.OK)
fDictionaryPath.setText(fDictionaryPath.getText() + dialog.getVariableExpression());
}
-
+
/**
* Handles selections of the browse button.
*/
protected void handleBrowseButtonSelected() {
- final FileDialog dialog= new FileDialog(fDictionaryPath.getShell(), SWT.OPEN);
- dialog.setText(PreferencesMessages.SpellingPreferencePage_filedialog_title);
+ final FileDialog dialog = new FileDialog(fDictionaryPath.getShell(), SWT.OPEN);
+ dialog.setText(PreferencesMessages.SpellingPreferencePage_filedialog_title);
dialog.setFilterPath(fDictionaryPath.getText());
- final String path= dialog.open();
+ final String path = dialog.open();
if (path != null)
fDictionaryPath.setText(path);
}
@@ -589,57 +616,58 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
@Override
protected void validateSettings(final Key key, final String oldValue, final String newValue) {
if (key == null || PREF_SPELLING_PROPOSAL_THRESHOLD.equals(key))
- fThresholdStatus= validatePositiveNumber(getValue(PREF_SPELLING_PROPOSAL_THRESHOLD));
+ fThresholdStatus = validatePositiveNumber(getValue(PREF_SPELLING_PROPOSAL_THRESHOLD));
else
- fThresholdStatus= new StatusInfo();
-
+ fThresholdStatus = new StatusInfo();
+
if (key == null || PREF_SPELLING_PROBLEMS_THRESHOLD.equals(key)) {
- IStatus status= validatePositiveNumber(getValue(PREF_SPELLING_PROBLEMS_THRESHOLD));
- fThresholdStatus= StatusUtil.getMostSevere(new IStatus[] {fThresholdStatus, status});
+ IStatus status = validatePositiveNumber(getValue(PREF_SPELLING_PROBLEMS_THRESHOLD));
+ fThresholdStatus = StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, status });
}
if (key == null || PREF_SPELLING_USER_DICTIONARY.equals(key))
- fFileStatus= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
+ fFileStatus = validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
- fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
+ fContext.statusChanged(
+ StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateCheckBox(org.eclipse.swt.widgets.Button)
*/
@Override
protected void updateCheckBox(Button curr) {
super.updateCheckBox(curr);
- Event event= new Event();
- event.type= SWT.Selection;
- event.display= curr.getDisplay();
- event.widget= curr;
+ Event event = new Event();
+ event.type = SWT.Selection;
+ event.display = curr.getDisplay();
+ event.widget = curr;
curr.notifyListeners(SWT.Selection, event);
}
-
+
/**
* Sets the enabled state.
- *
+ *
* @param enabled the new state
*/
protected void setEnabled(boolean enabled) {
fEncodingEditor.setEnabled(enabled, fEncodingEditorParent);
-
+
if (enabled && fEnabledControls != null) {
- for (int i= fEnabledControls.length - 1; i >= 0; i--)
+ for (int i = fEnabledControls.length - 1; i >= 0; i--)
fEnabledControls[i].setEnabled(true);
- fEnabledControls= null;
+ fEnabledControls = null;
}
if (!enabled && fEnabledControls == null) {
- List<Control> enabledControls= new ArrayList<Control>();
- for (int i= fAllControls.length - 1; i >= 0; i--) {
- Control control= fAllControls[i];
+ List<Control> enabledControls = new ArrayList<Control>();
+ for (int i = fAllControls.length - 1; i >= 0; i--) {
+ Control control = fAllControls[i];
if (control.isEnabled()) {
enabledControls.add(control);
control.setEnabled(false);
}
}
- fEnabledControls= enabledControls.toArray(new Control[enabledControls.size()]);
+ fEnabledControls = enabledControls.toArray(new Control[enabledControls.size()]);
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.java
index f1a1af580fd..f2ebffb38dc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.java
@@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
* Spelling preference block
*/
public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
-
+
private class NullStatusChangeListener implements IStatusChangeListener {
/*
* @see org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
@@ -39,32 +39,33 @@ public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
private class StatusChangeListenerAdapter implements IStatusChangeListener {
private final IPreferenceStatusMonitor fMonitor;
-
+
private IStatus fStatus;
-
+
public StatusChangeListenerAdapter(IPreferenceStatusMonitor monitor) {
super();
- fMonitor= monitor;
+ fMonitor = monitor;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
*/
@Override
public void statusChanged(IStatus status) {
- fStatus= status;
+ fStatus = status;
fMonitor.statusChanged(status);
}
-
+
public IStatus getStatus() {
return fStatus;
}
}
- private final SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(new NullStatusChangeListener(), null, null);
-
+ private final SpellingConfigurationBlock fBlock = new SpellingConfigurationBlock(new NullStatusChangeListener(),
+ null, null);
+
private SpellingPreferenceBlock.StatusChangeListenerAdapter fStatusMonitor;
-
+
/*
* @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#createControl(org.eclipse.swt.widgets.Composite)
*/
@@ -78,8 +79,8 @@ public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
*/
@Override
public void initialize(IPreferenceStatusMonitor statusMonitor) {
- fStatusMonitor= new StatusChangeListenerAdapter(statusMonitor);
- fBlock.fContext= fStatusMonitor;
+ fStatusMonitor = new StatusChangeListenerAdapter(statusMonitor);
+ fBlock.fContext = fStatusMonitor;
}
/*
@@ -87,7 +88,8 @@ public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
*/
@Override
public boolean canPerformOk() {
- return fStatusMonitor == null || fStatusMonitor.getStatus() == null || !fStatusMonitor.getStatus().matches(IStatus.ERROR);
+ return fStatusMonitor == null || fStatusMonitor.getStatus() == null
+ || !fStatusMonitor.getStatus().matches(IStatus.ERROR);
}
/*
@@ -105,7 +107,7 @@ public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
public void performDefaults() {
fBlock.performDefaults();
}
-
+
/*
* @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performRevert()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java
index 548c3ea379c..6b2e80ae94c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java
@@ -44,9 +44,8 @@ public class TabConfigurationBlock extends OptionsConfigurationBlock {
private final String[] fTabLabels;
private IStatus fStatus = Status.OK_STATUS;
- public TabConfigurationBlock(IStatusChangeListener context, IProject project,
- OptionsConfigurationBlock[] tabs, String[] tabLabels,
- IWorkbenchPreferenceContainer container) {
+ public TabConfigurationBlock(IStatusChangeListener context, IProject project, OptionsConfigurationBlock[] tabs,
+ String[] tabLabels, IWorkbenchPreferenceContainer container) {
super(context, project, getAllKeys(tabs), container);
if (tabLabels.length != tabs.length) {
throw new IllegalArgumentException("Number of labels doesn't match the number of tabs"); //$NON-NLS-1$
@@ -77,7 +76,7 @@ public class TabConfigurationBlock extends OptionsConfigurationBlock {
@Override
protected Control createContents(Composite parent) {
- PixelConverter pixelConverter = new PixelConverter(parent);
+ PixelConverter pixelConverter = new PixelConverter(parent);
final TabFolder folder = new TabFolder(parent, SWT.NONE);
folder.setLayout(new TabFolderLayout());
folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
@@ -107,7 +106,7 @@ public class TabConfigurationBlock extends OptionsConfigurationBlock {
public void widgetDefaultSelected(SelectionEvent e) {
}
});
- return folder;
+ return folder;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
index 907f90f2d69..6a31c5c9b77 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
@@ -54,26 +54,26 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFie
public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
private static final Key PREF_TODO_TASK_TAGS = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_TAGS);
private static final Key PREF_TODO_TASK_PRIORITIES = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_PRIORITIES);
- private static final Key PREF_TODO_TASK_CASE_SENSITIVE = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE);
+ private static final Key PREF_TODO_TASK_CASE_SENSITIVE = getCDTCoreKey(
+ CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE);
- private static final Key[] ALL_KEYS = new Key[] {
- PREF_TODO_TASK_TAGS, PREF_TODO_TASK_PRIORITIES, PREF_TODO_TASK_CASE_SENSITIVE
- };
+ private static final Key[] ALL_KEYS = new Key[] { PREF_TODO_TASK_TAGS, PREF_TODO_TASK_PRIORITIES,
+ PREF_TODO_TASK_CASE_SENSITIVE };
private static final String TASK_PRIORITY_HIGH = CCorePreferenceConstants.TASK_PRIORITY_HIGH;
private static final String TASK_PRIORITY_NORMAL = CCorePreferenceConstants.TASK_PRIORITY_NORMAL;
private static final String TASK_PRIORITY_LOW = CCorePreferenceConstants.TASK_PRIORITY_LOW;
-
+
public static class TodoTask {
public String name;
public String priority;
}
-
+
private class TodoTaskLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider {
public TodoTaskLabelProvider() {
}
-
+
@Override
public Image getImage(Object element) {
return null;
@@ -83,7 +83,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
public String getText(Object element) {
return getColumnText(element, 0);
}
-
+
@Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
@@ -95,18 +95,18 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
if (columnIndex == 0) {
String name = task.name;
if (isDefaultTask(task)) {
- name = Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name);
+ name = Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name);
}
return name;
}
if (TASK_PRIORITY_HIGH.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
} else if (TASK_PRIORITY_NORMAL.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
} else if (TASK_PRIORITY_LOW.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
}
- return ""; //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
}
@Override
@@ -117,7 +117,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
return null;
}
}
-
+
private static class TodoTaskSorter extends ViewerComparator {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
@@ -129,39 +129,35 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
private static final int IDX_EDIT = 1;
private static final int IDX_REMOVE = 2;
private static final int IDX_DEFAULT = 4;
-
+
private IStatus fTaskTagsStatus;
private final ListDialogField<TodoTask> fTodoTasksList;
private final SelectionButtonDialogField fCaseSensitiveCheckBox;
-
- public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
+ public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project,
+ IWorkbenchPreferenceContainer container) {
super(context, project, ALL_KEYS, container);
-
+
TaskTagAdapter adapter = new TaskTagAdapter();
- String[] buttons = new String[] {
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button,
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button,
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button,
- null,
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button,
- };
+ String[] buttons = new String[] { PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button,
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button,
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button, null,
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button, };
fTodoTasksList = new ListDialogField<TodoTask>(adapter, buttons, new TodoTaskLabelProvider());
fTodoTasksList.setDialogFieldListener(adapter);
fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);
-
+
String[] columnsHeaders = new String[] {
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column,
- PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column,
- };
-
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column,
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column, };
+
fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
fTodoTasksList.setViewerComparator(new TodoTaskSorter());
-
+
fCaseSensitiveCheckBox = new SelectionButtonDialogField(SWT.CHECK);
- fCaseSensitiveCheckBox.setLabelText(PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label);
+ fCaseSensitiveCheckBox.setLabelText(PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label);
fCaseSensitiveCheckBox.setDialogFieldListener(adapter);
-
+
unpackTodoTasks();
if (fTodoTasksList.getSize() > 0) {
fTodoTasksList.selectFirstElement();
@@ -169,19 +165,19 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
fTodoTasksList.enableButton(IDX_EDIT, false);
fTodoTasksList.enableButton(IDX_DEFAULT, false);
}
-
- fTaskTagsStatus = new StatusInfo();
+
+ fTaskTagsStatus = new StatusInfo();
}
-
+
public void setEnabled(boolean isEnabled) {
fTodoTasksList.setEnabled(isEnabled);
fCaseSensitiveCheckBox.setEnabled(isEnabled);
}
-
+
final boolean isDefaultTask(TodoTask task) {
return fTodoTasksList.getIndexOfElement(task) == 0;
}
-
+
private void setToDefaultTask(TodoTask task) {
List<TodoTask> elements = fTodoTasksList.getElements();
elements.remove(task);
@@ -189,12 +185,12 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
fTodoTasksList.setElements(elements);
fTodoTasksList.enableButton(IDX_DEFAULT, false);
}
-
+
public class TaskTagAdapter implements IListAdapter<TodoTask>, IDialogFieldListener {
private boolean canEdit(List<TodoTask> selectedElements) {
return selectedElements.size() == 1;
}
-
+
private boolean canSetToDefault(List<TodoTask> selectedElements) {
return selectedElements.size() == 1 && !isDefaultTask(selectedElements.get(0));
}
@@ -210,7 +206,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
field.enableButton(IDX_EDIT, canEdit(selectedElements));
field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements));
}
-
+
@Override
public void doubleClicked(ListDialogField<TodoTask> field) {
if (canEdit(field.getSelectedElements())) {
@@ -221,9 +217,9 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
@Override
public void dialogFieldChanged(DialogField field) {
updateModel(field);
- }
+ }
}
-
+
@Override
protected Control createContents(Composite parent) {
setShell(parent.getShell());
@@ -231,25 +227,25 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
-
+
PixelConverter conv = new PixelConverter(parent);
-
+
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(layout);
composite.setFont(parent.getFont());
-
+
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = conv.convertWidthInCharsToPixels(50);
Control listControl = fTodoTasksList.getListControl(composite);
listControl.setLayoutData(data);
-
+
Control buttonsControl = fTodoTasksList.getButtonBox(composite);
buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
-
+
fCaseSensitiveCheckBox.doFillIntoGrid(composite, 2);
-
+
validateSettings(null, null, null);
-
+
return composite;
}
@@ -258,7 +254,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
if (!areSettingsEnabled()) {
return;
}
-
+
if (changedKey != null) {
if (PREF_TODO_TASK_TAGS.equals(changedKey)) {
fTaskTagsStatus = validateTaskTags();
@@ -267,15 +263,15 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
}
} else {
fTaskTagsStatus = validateTaskTags();
- }
+ }
IStatus status = fTaskTagsStatus; //StatusUtil.getMostSevere(new IStatus[] { fTaskTagsStatus });
fContext.statusChanged(status);
}
-
+
private IStatus validateTaskTags() {
return new StatusInfo();
}
-
+
private void updateModel(DialogField field) {
if (field == fTodoTasksList) {
StringBuilder tags = new StringBuilder();
@@ -298,14 +294,14 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
setValue(PREF_TODO_TASK_CASE_SENSITIVE, state);
}
}
-
+
@Override
protected void updateControls() {
unpackTodoTasks();
}
-
+
private void unpackTodoTasks() {
- String currTags = getValue(PREF_TODO_TASK_TAGS);
+ String currTags = getValue(PREF_TODO_TASK_TAGS);
String currPrios = getValue(PREF_TODO_TASK_PRIORITIES);
String[] tags = getTokens(currTags, ","); //$NON-NLS-1$
String[] prios = getTokens(currPrios, ","); //$NON-NLS-1$
@@ -317,11 +313,11 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
elements.add(task);
}
fTodoTasksList.setElements(elements);
-
+
boolean isCaseSensitive = getBooleanValue(PREF_TODO_TASK_CASE_SENSITIVE);
fCaseSensitiveCheckBox.setSelection(isCaseSensitive);
}
-
+
private void doTodoButtonPressed(int index) {
TodoTask edited = null;
if (index != IDX_ADD) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java
index 3f9246e2b04..1d78611eb13 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java
@@ -40,22 +40,22 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
* Dialog to enter a new task tag.
*/
public class TodoTaskInputDialog extends StatusDialog {
-
+
private class CompilerTodoTaskInputAdapter implements IDialogFieldListener {
@Override
public void dialogFieldChanged(DialogField field) {
doValidation();
- }
+ }
}
-
+
private final StringDialogField fNameDialogField;
private final ComboDialogField fPriorityDialogField;
-
+
private final List<String> fExistingNames;
-
+
public TodoTaskInputDialog(Shell parent, TodoTask task, List<TodoTask> existingEntries) {
super(parent);
-
+
fExistingNames = new ArrayList<String>(existingEntries.size());
for (int i = 0; i < existingEntries.size(); i++) {
TodoTask curr = existingEntries.get(i);
@@ -63,29 +63,27 @@ public class TodoTaskInputDialog extends StatusDialog {
fExistingNames.add(curr.name);
}
}
-
+
if (task == null) {
- setTitle(PreferencesMessages.TodoTaskInputDialog_new_title);
+ setTitle(PreferencesMessages.TodoTaskInputDialog_new_title);
} else {
- setTitle(PreferencesMessages.TodoTaskInputDialog_edit_title);
+ setTitle(PreferencesMessages.TodoTaskInputDialog_edit_title);
}
CompilerTodoTaskInputAdapter adapter = new CompilerTodoTaskInputAdapter();
fNameDialogField = new StringDialogField();
- fNameDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_name_label);
+ fNameDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_name_label);
fNameDialogField.setDialogFieldListener(adapter);
-
+
fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$
-
- String[] items = new String[] {
- PreferencesMessages.TodoTaskInputDialog_priority_high,
- PreferencesMessages.TodoTaskInputDialog_priority_normal,
- PreferencesMessages.TodoTaskInputDialog_priority_low
- };
-
+
+ String[] items = new String[] { PreferencesMessages.TodoTaskInputDialog_priority_high,
+ PreferencesMessages.TodoTaskInputDialog_priority_normal,
+ PreferencesMessages.TodoTaskInputDialog_priority_low };
+
fPriorityDialogField = new ComboDialogField(SWT.READ_ONLY);
- fPriorityDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_priority_label);
+ fPriorityDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_priority_label);
fPriorityDialogField.setItems(items);
if (task != null) {
if (CCorePreferenceConstants.TASK_PRIORITY_HIGH.equals(task.priority)) {
@@ -99,7 +97,7 @@ public class TodoTaskInputDialog extends StatusDialog {
fPriorityDialogField.selectItem(1);
}
}
-
+
public TodoTask getResult() {
TodoTask task = new TodoTask();
task.name = fNameDialogField.getText().trim();
@@ -112,49 +110,50 @@ public class TodoTaskInputDialog extends StatusDialog {
break;
default:
task.priority = CCorePreferenceConstants.TASK_PRIORITY_LOW;
- break;
+ break;
}
return task;
}
-
+
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
-
+
Composite inner = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
inner.setLayout(layout);
-
+
fNameDialogField.doFillIntoGrid(inner, 2);
fPriorityDialogField.doFillIntoGrid(inner, 2);
-
+
LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null), true);
LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), convertWidthInCharsToPixels(45));
-
+
fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
-
- applyDialogFont(composite);
-
+
+ applyDialogFont(composite);
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.TODO_TASK_INPUT_DIALOG);
-
+
return composite;
}
-
+
private void doValidation() {
StatusInfo status = new StatusInfo();
String newText = fNameDialogField.getText();
if (newText.isEmpty()) {
- status.setError(PreferencesMessages.TodoTaskInputDialog_error_enterName);
+ status.setError(PreferencesMessages.TodoTaskInputDialog_error_enterName);
} else {
if (newText.indexOf(',') != -1) {
- status.setError(PreferencesMessages.TodoTaskInputDialog_error_comma);
+ status.setError(PreferencesMessages.TodoTaskInputDialog_error_comma);
} else if (fExistingNames.contains(newText)) {
- status.setError(PreferencesMessages.TodoTaskInputDialog_error_entryExists);
- } else if (Character.isWhitespace(newText.charAt(0)) || Character.isWhitespace(newText.charAt(newText.length() - 1))) {
- status.setError(PreferencesMessages.TodoTaskInputDialog_error_noSpace);
+ status.setError(PreferencesMessages.TodoTaskInputDialog_error_entryExists);
+ } else if (Character.isWhitespace(newText.charAt(0))
+ || Character.isWhitespace(newText.charAt(newText.length() - 1))) {
+ status.setError(PreferencesMessages.TodoTaskInputDialog_error_noSpace);
}
}
updateStatus(status);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java
index 95467586973..441128ffa73 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java
@@ -35,17 +35,17 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.TodoTaskPreferencePage"; //$NON-NLS-1$
public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.TodoTaskPreferencePage"; //$NON-NLS-1$
-
+
private TodoTaskConfigurationBlock fConfigurationBlock;
public TodoTaskPreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
- setDescription(PreferencesMessages.TodoTaskPreferencePage_description);
-
+ setDescription(PreferencesMessages.TodoTaskPreferencePage_description);
+
// only used when page is shown programatically
- setTitle(PreferencesMessages.TodoTaskPreferencePage_title);
+ setTitle(PreferencesMessages.TodoTaskPreferencePage_title);
}
-
+
/*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@@ -53,9 +53,9 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
public void createControl(Composite parent) {
IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
fConfigurationBlock = new TodoTaskConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
-
+
super.createControl(parent);
-
+
if (isProjectPreferencePage()) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.TODO_TASK_PROPERTY_PAGE);
} else {
@@ -70,7 +70,7 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
protected Control createPreferenceContent(Composite composite) {
return fConfigurationBlock.createContents(composite);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
*/
@@ -78,8 +78,7 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
protected boolean hasProjectSpecificOptions(IProject project) {
return fConfigurationBlock.hasProjectSpecificOptions(project);
}
-
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
*/
@@ -87,14 +86,14 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
protected String getPreferencePageId() {
return PREF_ID;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
*/
@Override
protected String getPropertyPageId() {
- // TODO: Project specific settings are not supported yet.
-// return PROP_ID;
+ // TODO: Project specific settings are not supported yet.
+ // return PROP_ID;
return null;
}
@@ -107,8 +106,8 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
if (fConfigurationBlock != null) {
fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
}
- }
-
+ }
+
/*
* @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
*/
@@ -127,10 +126,10 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
public boolean performOk() {
if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
return false;
- }
+ }
return super.performOk();
}
-
+
/*
* @see org.eclipse.jface.preference.IPreferencePage#performApply()
*/
@@ -140,7 +139,7 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
fConfigurationBlock.performApply();
}
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.DialogPage#dispose()
*/
@@ -151,7 +150,7 @@ public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
}
super.dispose();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java
index 49e074db964..149ae06ce0c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java
@@ -41,31 +41,31 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor
private final List<Button> fCheckBoxes;
private final List<Button> fRadioButtons;
private final List<Text> fTextControls;
-
+
/**
* creates a new preference page.
*/
public WorkInProgressPreferencePage() {
setPreferenceStore(getPreferenceStore());
- fRadioButtons= new ArrayList<Button>();
- fCheckBoxes= new ArrayList<Button>();
- fTextControls= new ArrayList<Text>();
+ fRadioButtons = new ArrayList<Button>();
+ fCheckBoxes = new ArrayList<Button>();
+ fTextControls = new ArrayList<Text>();
}
- Button addCheckBox(Composite parent, String label, String key) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-
- Button button= new Button(parent, SWT.CHECK);
+ Button addCheckBox(Composite parent, String label, String key) {
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+
+ Button button = new Button(parent, SWT.CHECK);
button.setText(label);
button.setData(key);
button.setLayoutData(gd);
button.setSelection(getPreferenceStore().getBoolean(key));
-
+
fCheckBoxes.add(button);
return button;
}
-
+
/*
* @see PreferencePage#createControl(Composite)
*/
@@ -78,22 +78,21 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor
@Override
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
-
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(10);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+
+ Composite result = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = 0;
+ layout.verticalSpacing = convertVerticalDLUsToPixels(10);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
result.setLayout(layout);
// Add your controls here
-
+
applyDialogFont(result);
return result;
}
-
-
+
/*
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
@@ -102,9 +101,9 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor
}
protected void createSpacer(Composite composite, int columnSpan) {
- Label label= new Label(composite, SWT.NONE);
- GridData gd= new GridData();
- gd.horizontalSpan= columnSpan;
+ Label label = new Label(composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalSpan = columnSpan;
label.setLayoutData(gd);
}
@@ -121,23 +120,23 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor
*/
@Override
protected void performDefaults() {
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= fCheckBoxes.get(i);
- String key= (String) button.getData();
+ IPreferenceStore store = getPreferenceStore();
+ for (int i = 0; i < fCheckBoxes.size(); i++) {
+ Button button = fCheckBoxes.get(i);
+ String key = (String) button.getData();
button.setSelection(store.getDefaultBoolean(key));
}
- for (int i= 0; i < fRadioButtons.size(); i++) {
- Button button= fRadioButtons.get(i);
- String[] info= (String[]) button.getData();
+ for (int i = 0; i < fRadioButtons.size(); i++) {
+ Button button = fRadioButtons.get(i);
+ String[] info = (String[]) button.getData();
button.setSelection(info[1].equals(store.getDefaultString(info[0])));
}
- for (int i= 0; i < fTextControls.size(); i++) {
- Text text= fTextControls.get(i);
- String key= (String) text.getData();
+ for (int i = 0; i < fTextControls.size(); i++) {
+ Text text = fTextControls.get(i);
+ String key = (String) text.getData();
text.setText(store.getDefaultString(key));
}
-
+
super.performDefaults();
}
@@ -146,22 +145,22 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor
*/
@Override
public boolean performOk() {
- IPreferenceStore store= getPreferenceStore();
- for (int i= 0; i < fCheckBoxes.size(); i++) {
- Button button= fCheckBoxes.get(i);
- String key= (String) button.getData();
+ IPreferenceStore store = getPreferenceStore();
+ for (int i = 0; i < fCheckBoxes.size(); i++) {
+ Button button = fCheckBoxes.get(i);
+ String key = (String) button.getData();
store.setValue(key, button.getSelection());
}
- for (int i= 0; i < fRadioButtons.size(); i++) {
- Button button= fRadioButtons.get(i);
+ for (int i = 0; i < fRadioButtons.size(); i++) {
+ Button button = fRadioButtons.get(i);
if (button.getSelection()) {
- String[] info= (String[]) button.getData();
+ String[] info = (String[]) button.getData();
store.setValue(info[0], info[1]);
}
}
- for (int i= 0; i < fTextControls.size(); i++) {
- Text text= fTextControls.get(i);
- String key= (String) text.getData();
+ for (int i = 0; i < fTextControls.size(); i++) {
+ Text text = fTextControls.get(i);
+ String key = (String) text.getData();
store.setValue(key, text.getText());
}
return super.performOk();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java
index 8c35026719a..f627cd9ac75 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java
@@ -36,61 +36,62 @@ import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomPr
import org.eclipse.cdt.internal.ui.util.Messages;
/**
- * The dialog to rename an imported profile.
+ * The dialog to rename an imported profile.
*/
public class AlreadyExistsDialog extends StatusDialog {
private Composite fComposite;
protected Text fNameText;
private Button fRenameRadio, fOverwriteRadio;
-
- private final int NUM_COLUMNS= 2;
-
+
+ private final int NUM_COLUMNS = 2;
+
private final StatusInfo fOk;
private final StatusInfo fEmpty;
private final StatusInfo fDuplicate;
-
+
private final CustomProfile fProfile;
private final ProfileManager fProfileManager;
-
+
public AlreadyExistsDialog(Shell parentShell, CustomProfile profile, ProfileManager profileManager) {
super(parentShell);
- fProfile= profile;
- fProfileManager= profileManager;
- fOk= new StatusInfo();
- fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_already_exists);
- fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_name_empty);
+ fProfile = profile;
+ fProfileManager = profileManager;
+ fOk = new StatusInfo();
+ fDuplicate = new StatusInfo(IStatus.ERROR,
+ FormatterMessages.AlreadyExistsDialog_message_profile_already_exists);
+ fEmpty = new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_name_empty);
}
@Override
public void create() {
super.create();
- setTitle(FormatterMessages.AlreadyExistsDialog_dialog_title);
+ setTitle(FormatterMessages.AlreadyExistsDialog_dialog_title);
}
-
+
@Override
public Control createDialogArea(Composite parent) {
initializeComposite(parent);
-
- createLabel(Messages.format(FormatterMessages.AlreadyExistsDialog_dialog_label, fProfile.getName()));
- fRenameRadio= createRadioButton(FormatterMessages.AlreadyExistsDialog_rename_radio_button_desc);
- fNameText= createTextField();
+ createLabel(Messages.format(FormatterMessages.AlreadyExistsDialog_dialog_label, fProfile.getName()));
+
+ fRenameRadio = createRadioButton(FormatterMessages.AlreadyExistsDialog_rename_radio_button_desc);
+ fNameText = createTextField();
- fOverwriteRadio= createRadioButton(FormatterMessages.AlreadyExistsDialog_overwrite_radio_button_desc);
+ fOverwriteRadio = createRadioButton(FormatterMessages.AlreadyExistsDialog_overwrite_radio_button_desc);
fRenameRadio.setSelection(true);
-
+
fNameText.setText(fProfile.getName());
fNameText.setSelection(0, fProfile.getName().length());
fNameText.setFocus();
-
+
fNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
doValidation();
}
});
-
+
fRenameRadio.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -99,66 +100,68 @@ public class AlreadyExistsDialog extends StatusDialog {
fNameText.setSelection(0, fNameText.getText().length());
doValidation();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
-
+
fOverwriteRadio.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
fNameText.setEnabled(false);
doValidation();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
-
+
updateStatus(fDuplicate);
-
+
applyDialogFont(fComposite);
-
+
return fComposite;
}
-
+
private void initializeComposite(Composite parent) {
- fComposite= new Composite(parent, SWT.NULL);
-
- final GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.numColumns= NUM_COLUMNS;
-
+ fComposite = new Composite(parent, SWT.NULL);
+
+ final GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ layout.numColumns = NUM_COLUMNS;
+
fComposite.setLayout(layout);
}
-
+
private Label createLabel(String text) {
- final GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= NUM_COLUMNS;
- gd.widthHint= convertWidthInCharsToPixels(60);
- final Label label= new Label(fComposite, SWT.WRAP);
+ final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = NUM_COLUMNS;
+ gd.widthHint = convertWidthInCharsToPixels(60);
+ final Label label = new Label(fComposite, SWT.WRAP);
label.setText(text);
label.setLayoutData(gd);
return label;
}
-
+
private Button createRadioButton(String text) {
final GridData gd = new GridData();
gd.horizontalSpan = NUM_COLUMNS;
- gd.widthHint= convertWidthInCharsToPixels(60);
- final Button radio= new Button(fComposite, SWT.RADIO);
+ gd.widthHint = convertWidthInCharsToPixels(60);
+ final Button radio = new Button(fComposite, SWT.RADIO);
radio.setLayoutData(gd);
radio.setText(text);
return radio;
}
-
+
private Text createTextField() {
- final GridData gd = new GridData( GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= NUM_COLUMNS;
- final Text text= new Text(fComposite, SWT.SINGLE | SWT.BORDER);
+ final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = NUM_COLUMNS;
+ final Text text = new Text(fComposite, SWT.SINGLE | SWT.BORDER);
text.setLayoutData(gd);
return text;
}
@@ -172,24 +175,24 @@ public class AlreadyExistsDialog extends StatusDialog {
return;
}
- String name= fNameText.getText().trim();
-
+ String name = fNameText.getText().trim();
+
if (name.length() == 0) {
updateStatus(fEmpty);
return;
}
-
+
if (fProfileManager.containsName(name)) {
updateStatus(fDuplicate);
return;
}
-
+
updateStatus(fOk);
}
-
+
@Override
protected void okPressed() {
- if (!getStatus().isOK())
+ if (!getStatus().isOK())
return;
if (fRenameRadio.getSelection())
fProfile.rename(fNameText.getText().trim(), fProfileManager);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java
index 131a7a77dbc..e55e648ab44 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java
@@ -13,7 +13,7 @@
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences.formatter;
-
+
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
@@ -25,84 +25,73 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
public class BracesTabPage extends FormatterTabPage {
-
+
/**
* Some C++ source code used for preview.
*/
- private final static String PREVIEW=
- createPreviewHeader(FormatterMessages.BracesTabPage_preview_header) +
- "#include <math.h>\n\n" + //$NON-NLS-1$
- "int digits[]= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };" + //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "class Point {" + //$NON-NLS-1$
- "public:" + //$NON-NLS-1$
- "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$
- "double distance(const Point& other) const;" + //$NON-NLS-1$
- "int compareX(const Point& other) const;" + //$NON-NLS-1$
- "double x;" + //$NON-NLS-1$
- "double y;" + //$NON-NLS-1$
- "};" + //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
- "double dx = x - other.x;" + //$NON-NLS-1$
- "double dy = y - other.y;" + //$NON-NLS-1$
- "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "int Point::compareX(const Point& other) const {" + //$NON-NLS-1$
- "if(x < other.x) {" + //$NON-NLS-1$
- "return -1;" + //$NON-NLS-1$
- "} else if(x > other.x){" + //$NON-NLS-1$
- "return 1;" + //$NON-NLS-1$
- "} else {" + //$NON-NLS-1$
- "return 0;" + //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "namespace FOO {"+ //$NON-NLS-1$
- "int foo(int bar) const {" + //$NON-NLS-1$
- "switch(bar) {" + //$NON-NLS-1$
- "case 0:" + //$NON-NLS-1$
- "++bar;" + //$NON-NLS-1$
- "break;" + //$NON-NLS-1$
- "case 1:" + //$NON-NLS-1$
- "--bar;" + //$NON-NLS-1$
- "default: {" + //$NON-NLS-1$
- "bar += bar;" + //$NON-NLS-1$
- "break;" + //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "} // end namespace FOO"; //$NON-NLS-1$
+ private final static String PREVIEW = createPreviewHeader(FormatterMessages.BracesTabPage_preview_header)
+ + "#include <math.h>\n\n" + //$NON-NLS-1$
+ "int digits[]= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "class Point {" + //$NON-NLS-1$
+ "public:" + //$NON-NLS-1$
+ "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$
+ "double distance(const Point& other) const;" + //$NON-NLS-1$
+ "int compareX(const Point& other) const;" + //$NON-NLS-1$
+ "double x;" + //$NON-NLS-1$
+ "double y;" + //$NON-NLS-1$
+ "};" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
+ "double dx = x - other.x;" + //$NON-NLS-1$
+ "double dy = y - other.y;" + //$NON-NLS-1$
+ "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "int Point::compareX(const Point& other) const {" + //$NON-NLS-1$
+ "if(x < other.x) {" + //$NON-NLS-1$
+ "return -1;" + //$NON-NLS-1$
+ "} else if(x > other.x){" + //$NON-NLS-1$
+ "return 1;" + //$NON-NLS-1$
+ "} else {" + //$NON-NLS-1$
+ "return 0;" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "namespace FOO {" + //$NON-NLS-1$
+ "int foo(int bar) const {" + //$NON-NLS-1$
+ "switch(bar) {" + //$NON-NLS-1$
+ "case 0:" + //$NON-NLS-1$
+ "++bar;" + //$NON-NLS-1$
+ "break;" + //$NON-NLS-1$
+ "case 1:" + //$NON-NLS-1$
+ "--bar;" + //$NON-NLS-1$
+ "default: {" + //$NON-NLS-1$
+ "bar += bar;" + //$NON-NLS-1$
+ "break;" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "} // end namespace FOO"; //$NON-NLS-1$
private TranslationUnitPreview fPreview;
-
- private final String[] fBracePositions= {
- DefaultCodeFormatterConstants.END_OF_LINE,
- DefaultCodeFormatterConstants.NEXT_LINE,
- DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED
- };
-
- private final String[] fExtendedBracePositions= {
- DefaultCodeFormatterConstants.END_OF_LINE,
- DefaultCodeFormatterConstants.NEXT_LINE,
- DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED,
- DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP
- };
-
- private final String[] fBracePositionNames= {
- FormatterMessages.BracesTabPage_position_same_line,
- FormatterMessages.BracesTabPage_position_next_line,
- FormatterMessages.BracesTabPage_position_next_line_indented
- };
-
- private final String[] fExtendedBracePositionNames= {
- FormatterMessages.BracesTabPage_position_same_line,
- FormatterMessages.BracesTabPage_position_next_line,
- FormatterMessages.BracesTabPage_position_next_line_indented,
- FormatterMessages.BracesTabPage_position_next_line_on_wrap
- };
-
+
+ private final String[] fBracePositions = { DefaultCodeFormatterConstants.END_OF_LINE,
+ DefaultCodeFormatterConstants.NEXT_LINE, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED };
+
+ private final String[] fExtendedBracePositions = { DefaultCodeFormatterConstants.END_OF_LINE,
+ DefaultCodeFormatterConstants.NEXT_LINE, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED,
+ DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP };
+
+ private final String[] fBracePositionNames = { FormatterMessages.BracesTabPage_position_same_line,
+ FormatterMessages.BracesTabPage_position_next_line,
+ FormatterMessages.BracesTabPage_position_next_line_indented };
+
+ private final String[] fExtendedBracePositionNames = { FormatterMessages.BracesTabPage_position_same_line,
+ FormatterMessages.BracesTabPage_position_next_line,
+ FormatterMessages.BracesTabPage_position_next_line_indented,
+ FormatterMessages.BracesTabPage_position_next_line_on_wrap };
+
/**
* Create a new BracesTabPage.
* @param modifyDialog
@@ -111,23 +100,34 @@ public class BracesTabPage extends FormatterTabPage {
public BracesTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
super(modifyDialog, workingValues);
}
-
+
@Override
protected void doCreatePreferences(Composite composite, int numColumns) {
- final Group group= createGroup(numColumns, composite, FormatterMessages.BracesTabPage_group_brace_positions_title);
- createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_class_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION);
- createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_namespace_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_NAMESPACE_DECLARATION);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_constructor_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION);
- createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_function_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_enumconst_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT);
-// createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_annotation_type_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION);
- createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
- createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks_in_case, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE);
- createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_switch_case, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
-
- ComboPreference arrayInitOption= createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_initializer_list, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST);
- final CheckboxPreference arrayInitCheckBox= createIndentedCheckboxPref(group, numColumns, FormatterMessages.BracesTabPage_option_keep_empty_initializer_list_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_INITIALIZER_LIST_ON_ONE_LINE, FALSE_TRUE);
+ final Group group = createGroup(numColumns, composite,
+ FormatterMessages.BracesTabPage_group_brace_positions_title);
+ createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_class_declaration,
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION);
+ createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_namespace_declaration,
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_NAMESPACE_DECLARATION);
+ // createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_constructor_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION);
+ createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_function_declaration,
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
+ // createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION);
+ // createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_enumconst_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT);
+ // createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_annotation_type_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION);
+ createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks,
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
+ createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks_in_case,
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE);
+ createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_switch_case,
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
+
+ ComboPreference arrayInitOption = createBracesCombo(group, numColumns,
+ FormatterMessages.BracesTabPage_option_initializer_list,
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST);
+ final CheckboxPreference arrayInitCheckBox = createIndentedCheckboxPref(group, numColumns,
+ FormatterMessages.BracesTabPage_option_keep_empty_initializer_list_on_one_line,
+ DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_INITIALIZER_LIST_ON_ONE_LINE, FALSE_TRUE);
arrayInitOption.addObserver(new Observer() {
@Override
@@ -137,7 +137,7 @@ public class BracesTabPage extends FormatterTabPage {
});
updateOptionEnablement(arrayInitOption, arrayInitCheckBox);
}
-
+
/**
* @param arrayInitOption
* @param arrayInitCheckBox
@@ -148,32 +148,34 @@ public class BracesTabPage extends FormatterTabPage {
@Override
protected void initializePage() {
- fPreview.setPreviewText(PREVIEW);
+ fPreview.setPreviewText(PREVIEW);
}
-
+
@Override
protected CPreview doCreateCPreview(Composite parent) {
- fPreview= new TranslationUnitPreview(fWorkingValues, parent);
- return fPreview;
+ fPreview = new TranslationUnitPreview(fWorkingValues, parent);
+ return fPreview;
}
-
+
private ComboPreference createBracesCombo(Composite composite, int numColumns, String message, String key) {
return createComboPref(composite, numColumns, message, key, fBracePositions, fBracePositionNames);
}
-
+
private ComboPreference createExtendedBracesCombo(Composite composite, int numColumns, String message, String key) {
- return createComboPref(composite, numColumns, message, key, fExtendedBracePositions, fExtendedBracePositionNames);
+ return createComboPref(composite, numColumns, message, key, fExtendedBracePositions,
+ fExtendedBracePositionNames);
}
-
- private CheckboxPreference createIndentedCheckboxPref(Composite composite, int numColumns, String message, String key, String[] values) {
- CheckboxPreference pref= createCheckboxPref(composite, numColumns, message, key, values);
- GridData data= (GridData) pref.getControl().getLayoutData();
- data.horizontalIndent= fPixelConverter.convertWidthInCharsToPixels(1);
+
+ private CheckboxPreference createIndentedCheckboxPref(Composite composite, int numColumns, String message,
+ String key, String[] values) {
+ CheckboxPreference pref = createCheckboxPref(composite, numColumns, message, key, values);
+ GridData data = (GridData) pref.getControl().getLayoutData();
+ data.horizontalIndent = fPixelConverter.convertWidthInCharsToPixels(1);
return pref;
}
- @Override
+ @Override
protected void doUpdatePreview() {
- fPreview.update();
- }
+ fPreview.update();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java
index f691025618f..a756e4af00d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java
@@ -50,18 +50,18 @@ import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
/**
* Abstract previewer for C/C++ source code formatting.
- *
+ *
* @since 4.0
*/
public abstract class CPreview {
private final class CSourcePreviewerUpdater {
- final IPropertyChangeListener fontListener= new IPropertyChangeListener() {
- @Override
+ final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
+ @Override
public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
- final Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+ if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
+ final Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
fSourceViewer.getTextWidget().setFont(font);
if (fMarginPainter != null) {
fMarginPainter.initialize();
@@ -69,8 +69,8 @@ public abstract class CPreview {
}
}
};
-
- final IPropertyChangeListener propertyListener= new IPropertyChangeListener() {
+
+ final IPropertyChangeListener propertyListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (fViewerConfiguration.affectsTextPresentation(event)) {
@@ -79,11 +79,11 @@ public abstract class CPreview {
}
}
};
-
+
public CSourcePreviewerUpdater() {
- JFaceResources.getFontRegistry().addListener(fontListener);
- fPreferenceStore.addPropertyChangeListener(propertyListener);
-
+ JFaceResources.getFontRegistry().addListener(fontListener);
+ fPreferenceStore.addPropertyChangeListener(propertyListener);
+
fSourceViewer.getTextWidget().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
@@ -93,127 +93,130 @@ public abstract class CPreview {
});
}
}
-
+
protected final SimpleCSourceViewerConfiguration fViewerConfiguration;
protected final Document fPreviewDocument;
protected final SourceViewer fSourceViewer;
protected final IPreferenceStore fPreferenceStore;
-
+
protected final MarginPainter fMarginPainter;
-
+
protected Map<String, String> fWorkingValues;
- private int fTabSize= 0;
+ private int fTabSize = 0;
private WhitespaceCharacterPainter fWhitespaceCharacterPainter;
-
+
/**
* Create a new C preview
* @param workingValues
* @param parent
*/
public CPreview(Map<String, String> workingValues, Composite parent) {
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- fPreviewDocument= new Document();
- fWorkingValues= workingValues;
- tools.setupCDocumentPartitioner(fPreviewDocument, ICPartitions.C_PARTITIONING, null);
-
- PreferenceStore prioritizedSettings= new PreferenceStore();
-
- IPreferenceStore[] chain= { prioritizedSettings, CUIPlugin.getDefault().getCombinedPreferenceStore() };
- fPreferenceStore= new ChainedPreferenceStore(chain);
- fSourceViewer= new CSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore);
- fViewerConfiguration= new SimpleCSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, ICPartitions.C_PARTITIONING, true);
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ fPreviewDocument = new Document();
+ fWorkingValues = workingValues;
+ tools.setupCDocumentPartitioner(fPreviewDocument, ICPartitions.C_PARTITIONING, null);
+
+ PreferenceStore prioritizedSettings = new PreferenceStore();
+
+ IPreferenceStore[] chain = { prioritizedSettings, CUIPlugin.getDefault().getCombinedPreferenceStore() };
+ fPreferenceStore = new ChainedPreferenceStore(chain);
+ fSourceViewer = new CSourceViewer(parent, null, null, false,
+ SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore);
+ fViewerConfiguration = new SimpleCSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null,
+ ICPartitions.C_PARTITIONING, true);
fSourceViewer.configure(fViewerConfiguration);
fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
-
- fMarginPainter= new MarginPainter(fSourceViewer);
- final RGB rgb= PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
+
+ fMarginPainter = new MarginPainter(fSourceViewer);
+ final RGB rgb = PreferenceConverter.getColor(fPreferenceStore,
+ AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
fSourceViewer.addPainter(fMarginPainter);
-
+
new CSourcePreviewerUpdater();
fSourceViewer.setDocument(fPreviewDocument);
}
-
+
public Control getControl() {
- return fSourceViewer.getControl();
+ return fSourceViewer.getControl();
}
-
+
public void update() {
if (fWorkingValues == null) {
- fPreviewDocument.set(""); //$NON-NLS-1$
- return;
+ fPreviewDocument.set(""); //$NON-NLS-1$
+ return;
}
-
+
// update the print margin
- final String value= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
- final int lineWidth= getPositiveIntValue(value, 0);
+ final String value = fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
+ final int lineWidth = getPositiveIntValue(value, 0);
fMarginPainter.setMarginRulerColumn(lineWidth);
-
+
// update the tab size
- final int tabSize= getPositiveIntValue(fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0);
+ final int tabSize = getPositiveIntValue(fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE),
+ 0);
if (tabSize != fTabSize)
fSourceViewer.getTextWidget().setTabs(tabSize);
- fTabSize= tabSize;
-
- final StyledText widget= (StyledText) fSourceViewer.getControl();
- final int height= widget.getClientArea().height;
- final int top0= widget.getTopPixel();
-
- final int totalPixels0= getHeightOfAllLines(widget);
- final int topPixelRange0= totalPixels0 > height ? totalPixels0 - height : 0;
-
+ fTabSize = tabSize;
+
+ final StyledText widget = (StyledText) fSourceViewer.getControl();
+ final int height = widget.getClientArea().height;
+ final int top0 = widget.getTopPixel();
+
+ final int totalPixels0 = getHeightOfAllLines(widget);
+ final int topPixelRange0 = totalPixels0 > height ? totalPixels0 - height : 0;
+
widget.setRedraw(false);
doFormatPreview();
fSourceViewer.setSelection(null);
-
- final int totalPixels1= getHeightOfAllLines(widget);
- final int topPixelRange1= totalPixels1 > height ? totalPixels1 - height : 0;
- final int top1= topPixelRange0 > 0 ? (int) (topPixelRange1 * top0 / (double) topPixelRange0) : 0;
+ final int totalPixels1 = getHeightOfAllLines(widget);
+ final int topPixelRange1 = totalPixels1 > height ? totalPixels1 - height : 0;
+
+ final int top1 = topPixelRange0 > 0 ? (int) (topPixelRange1 * top0 / (double) topPixelRange0) : 0;
widget.setTopPixel(top1);
widget.setRedraw(true);
}
-
+
private int getHeightOfAllLines(StyledText styledText) {
- int height= 0;
- int lineCount= styledText.getLineCount();
- for (int i= 0; i < lineCount; i++)
- height= height + styledText.getLineHeight(styledText.getOffsetAtLine(i));
+ int height = 0;
+ int lineCount = styledText.getLineCount();
+ for (int i = 0; i < lineCount; i++)
+ height = height + styledText.getLineHeight(styledText.getOffsetAtLine(i));
return height;
}
-
+
protected abstract void doFormatPreview();
private static int getPositiveIntValue(String string, int defaultValue) {
- try {
- int i= Integer.parseInt(string);
- if (i >= 0) {
- return i;
- }
- } catch (NumberFormatException e) {
- }
- return defaultValue;
- }
-
+ try {
+ int i = Integer.parseInt(string);
+ if (i >= 0) {
+ return i;
+ }
+ } catch (NumberFormatException e) {
+ }
+ return defaultValue;
+ }
+
public Map<String, String> getWorkingValues() {
return fWorkingValues;
}
-
-
+
public void setWorkingValues(Map<String, String> workingValues) {
- fWorkingValues= workingValues;
+ fWorkingValues = workingValues;
}
public void showInvisibleCharacters(boolean enable) {
if (enable) {
if (fWhitespaceCharacterPainter == null) {
- fWhitespaceCharacterPainter= new WhitespaceCharacterPainter(fSourceViewer);
+ fWhitespaceCharacterPainter = new WhitespaceCharacterPainter(fSourceViewer);
fSourceViewer.addPainter(fWhitespaceCharacterPainter);
}
} else {
fSourceViewer.removePainter(fWhitespaceCharacterPainter);
- fWhitespaceCharacterPainter= null;
+ fWhitespaceCharacterPainter = null;
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java
index 1974572a124..8e4a615c73b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java
@@ -32,12 +32,12 @@ import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
/**
- * The code formatter preference page.
+ * The code formatter preference page.
*/
public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
- private static final String FORMATTER_DIALOG_PREFERENCE_KEY= "formatter_page"; //$NON-NLS-1$
+ private static final String FORMATTER_DIALOG_PREFERENCE_KEY = "formatter_page"; //$NON-NLS-1$
- private static final String DIALOGSTORE_LASTSAVELOADPATH= CUIPlugin.PLUGIN_ID + ".codeformatter.savepath"; //$NON-NLS-1$
+ private static final String DIALOGSTORE_LASTSAVELOADPATH = CUIPlugin.PLUGIN_ID + ".codeformatter.savepath"; //$NON-NLS-1$
private class PreviewController implements Observer {
@@ -47,48 +47,46 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
fCodeStylePreview.setWorkingValues(profileManager.getSelected().getSettings());
fCodeStylePreview.update();
}
-
+
@Override
public void update(Observable o, Object arg) {
if (o == fCustomCodeFormatterBlock) {
- fCodeStylePreview.setFormatterId((String)arg);
+ fCodeStylePreview.setFormatterId((String) arg);
fCodeStylePreview.update();
return;
}
- final int value= ((Integer) arg).intValue();
+ final int value = ((Integer) arg).intValue();
switch (value) {
case ProfileManager.PROFILE_CREATED_EVENT:
case ProfileManager.PROFILE_DELETED_EVENT:
case ProfileManager.SELECTION_CHANGED_EVENT:
case ProfileManager.SETTINGS_CHANGED_EVENT:
- fCodeStylePreview.setWorkingValues(((ProfileManager)o).getSelected().getSettings());
+ fCodeStylePreview.setWorkingValues(((ProfileManager) o).getSelected().getSettings());
fCodeStylePreview.update();
}
}
}
-
+
/**
* Some C++ source code used for preview.
*/
- private static final String PREVIEW=
- "/*\n* " + //$NON-NLS-1$
- FormatterMessages.CodingStyleConfigurationBlock_preview_title +
- "\n*/\n" + //$NON-NLS-1$
- "#include <math.h>\n\n" + //$NON-NLS-1$
- "class Point {" + //$NON-NLS-1$
- "public:" + //$NON-NLS-1$
- "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$
- "double distance(const Point& other) const;" + //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "double x;" + //$NON-NLS-1$
- "double y;" + //$NON-NLS-1$
- "};" + //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
- "double dx = x - other.x;" + //$NON-NLS-1$
- "double dy = y - other.y;" + //$NON-NLS-1$
- "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
- "}"; //$NON-NLS-1$
+ private static final String PREVIEW = "/*\n* " + //$NON-NLS-1$
+ FormatterMessages.CodingStyleConfigurationBlock_preview_title + "\n*/\n" + //$NON-NLS-1$
+ "#include <math.h>\n\n" + //$NON-NLS-1$
+ "class Point {" + //$NON-NLS-1$
+ "public:" + //$NON-NLS-1$
+ "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$
+ "double distance(const Point& other) const;" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "double x;" + //$NON-NLS-1$
+ "double y;" + //$NON-NLS-1$
+ "};" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
+ "double dx = x - other.x;" + //$NON-NLS-1$
+ "double dy = y - other.y;" + //$NON-NLS-1$
+ "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
+ "}"; //$NON-NLS-1$
/**
* The CPreview.
@@ -102,48 +100,52 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
*/
public CodeFormatterConfigurationBlock(IProject project, PreferencesAccess access) {
super(project, access, DIALOGSTORE_LASTSAVELOADPATH);
- fCustomCodeFormatterBlock= new CustomCodeFormatterBlock(project, access);
+ fCustomCodeFormatterBlock = new CustomCodeFormatterBlock(project, access);
}
@Override
protected IProfileVersioner createProfileVersioner() {
- return new ProfileVersioner();
- }
+ return new ProfileVersioner();
+ }
@Override
protected ProfileStore createProfileStore(IProfileVersioner versioner) {
- return new FormatterProfileStore(versioner);
- }
-
+ return new FormatterProfileStore(versioner);
+ }
+
@Override
- protected ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner) {
- return new FormatterProfileManager(profiles, context, access, profileVersioner);
- }
-
+ protected ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context,
+ PreferencesAccess access, IProfileVersioner profileVersioner) {
+ return new FormatterProfileManager(profiles, context, access, profileVersioner);
+ }
+
@Override
protected void configurePreview(Composite composite, int numColumns, ProfileManager profileManager) {
fCustomCodeFormatterBlock.createContents(composite);
createLabel(composite, FormatterMessages.CodingStyleConfigurationBlock_preview_label_text, numColumns);
- TranslationUnitPreview result= new TranslationUnitPreview(profileManager.getSelected().getSettings(), composite);
+ TranslationUnitPreview result = new TranslationUnitPreview(profileManager.getSelected().getSettings(),
+ composite);
result.setFormatterId(fCustomCodeFormatterBlock.getFormatterId());
- result.setPreviewText(PREVIEW);
- fCodeStylePreview= result;
+ result.setPreviewText(PREVIEW);
+ fCodeStylePreview = result;
final GridData gd = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = numColumns;
- gd.verticalSpan= 7;
+ gd.verticalSpan = 7;
gd.widthHint = 0;
gd.heightHint = 0;
fCodeStylePreview.getControl().setLayoutData(gd);
-
+
new PreviewController(profileManager);
}
- @Override
- protected ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile) {
- return new FormatterModifyDialog(shell, profile, profileManager, profileStore, newProfile, FORMATTER_DIALOG_PREFERENCE_KEY, DIALOGSTORE_LASTSAVELOADPATH);
- }
+ @Override
+ protected ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager,
+ ProfileStore profileStore, boolean newProfile) {
+ return new FormatterModifyDialog(shell, profile, profileManager, profileStore, newProfile,
+ FORMATTER_DIALOG_PREFERENCE_KEY, DIALOGSTORE_LASTSAVELOADPATH);
+ }
@Override
public void performApply() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPage.java
index 3c3ead513c2..d0b1c6c8ba9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPage.java
@@ -26,64 +26,63 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
*/
public class CommentsTabPage extends FormatterTabPage {
-// private static abstract class Controller implements Observer {
-// private final Collection<CheckboxPreference> fMasters;
-// private final Collection<Object> fSlaves;
-//
-// public Controller(Collection<CheckboxPreference> masters, Collection<Object> slaves) {
-// fMasters= masters;
-// fSlaves= slaves;
-// for (CheckboxPreference pref : fMasters) {
-// pref.addObserver(this);
-// }
-// }
-//
-// public void update(Observable o, Object arg) {
-// boolean enabled= areSlavesEnabled();
-//
-// for (Object slave : fSlaves) {
-// if (slave instanceof Preference) {
-// ((Preference) slave).setEnabled(enabled);
-// } else if (slave instanceof Control) {
-// ((Group) slave).setEnabled(enabled);
-// }
-// }
-// }
-//
-// public Collection<CheckboxPreference> getMasters() {
-// return fMasters;
-// }
-//
-// protected abstract boolean areSlavesEnabled();
-// }
-//
-// private final static class OrController extends Controller {
-// public OrController(Collection<CheckboxPreference> masters, Collection<Object> slaves) {
-// super(masters, slaves);
-// update(null, null);
-// }
-//
-// @Override
-// protected boolean areSlavesEnabled() {
-// for (CheckboxPreference pref : getMasters()) {
-// if (pref.getChecked())
-// return true;
-// }
-// return false;
-// }
-// }
-
- private final String PREVIEW=
- createPreviewHeader(FormatterMessages.CommentsTabPage_preview_header) +
- "int gVariable = 100; \t\t// line 1 of comment\n" + //$NON-NLS-1$
- // needs as many tabs as indent size, consider case when tab indent size is 1
- "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// line 2 of comment\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- "void lineComments() {\n" + //$NON-NLS-1$
- "\tprintf(\"%d\\n\", 1234); \t\t// Integer number\n" + //$NON-NLS-1$
- "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// More here\n" + //$NON-NLS-1$
- "\tprintf(\"%.5g\\n\", 12.34);\t\t// Floating point number\n" + //$NON-NLS-1$
- "}\n"; //$NON-NLS-1$
+ // private static abstract class Controller implements Observer {
+ // private final Collection<CheckboxPreference> fMasters;
+ // private final Collection<Object> fSlaves;
+ //
+ // public Controller(Collection<CheckboxPreference> masters, Collection<Object> slaves) {
+ // fMasters= masters;
+ // fSlaves= slaves;
+ // for (CheckboxPreference pref : fMasters) {
+ // pref.addObserver(this);
+ // }
+ // }
+ //
+ // public void update(Observable o, Object arg) {
+ // boolean enabled= areSlavesEnabled();
+ //
+ // for (Object slave : fSlaves) {
+ // if (slave instanceof Preference) {
+ // ((Preference) slave).setEnabled(enabled);
+ // } else if (slave instanceof Control) {
+ // ((Group) slave).setEnabled(enabled);
+ // }
+ // }
+ // }
+ //
+ // public Collection<CheckboxPreference> getMasters() {
+ // return fMasters;
+ // }
+ //
+ // protected abstract boolean areSlavesEnabled();
+ // }
+ //
+ // private final static class OrController extends Controller {
+ // public OrController(Collection<CheckboxPreference> masters, Collection<Object> slaves) {
+ // super(masters, slaves);
+ // update(null, null);
+ // }
+ //
+ // @Override
+ // protected boolean areSlavesEnabled() {
+ // for (CheckboxPreference pref : getMasters()) {
+ // if (pref.getChecked())
+ // return true;
+ // }
+ // return false;
+ // }
+ // }
+
+ private final String PREVIEW = createPreviewHeader(FormatterMessages.CommentsTabPage_preview_header)
+ + "int gVariable = 100; \t\t// line 1 of comment\n" + //$NON-NLS-1$
+ // needs as many tabs as indent size, consider case when tab indent size is 1
+ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// line 2 of comment\n" + //$NON-NLS-1$
+ "\n" + //$NON-NLS-1$
+ "void lineComments() {\n" + //$NON-NLS-1$
+ "\tprintf(\"%d\\n\", 1234); \t\t// Integer number\n" + //$NON-NLS-1$
+ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// More here\n" + //$NON-NLS-1$
+ "\tprintf(\"%.5g\\n\", 12.34);\t\t// Floating point number\n" + //$NON-NLS-1$
+ "}\n"; //$NON-NLS-1$
private TranslationUnitPreview fPreview;
@@ -93,114 +92,121 @@ public class CommentsTabPage extends FormatterTabPage {
@Override
protected void doCreatePreferences(Composite composite, int numColumns) {
-// final int indent= fPixelConverter.convertWidthInCharsToPixels(4);
+ // final int indent= fPixelConverter.convertWidthInCharsToPixels(4);
// Global group
-// final Group globalGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group1_title);
-// createPrefFalseTrue(globalGroup, numColumns, FormatterMessages.CommentsTabPage_do_not_join_lines, DefaultCodeFormatterConstants.FORMATTER_JOIN_LINES_IN_COMMENTS, true);
+ // final Group globalGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group1_title);
+ // createPrefFalseTrue(globalGroup, numColumns, FormatterMessages.CommentsTabPage_do_not_join_lines, DefaultCodeFormatterConstants.FORMATTER_JOIN_LINES_IN_COMMENTS, true);
// Line comment group
- final Group lineCommentGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group1_title);
-// final CheckboxPreference singleLineCommentsOnFirstColumn= createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_format_line_comments_on_first_column, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, false);
-// ((GridData) singleLineCommentsOnFirstColumn.getControl().getLayoutData()).horizontalIndent= indent;
- createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_preserve_white_space_before_line_comment, DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, false);
- createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_line_up_line_comment_in_blocks_on_first_column, DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_UP_LINE_COMMENT_IN_BLOCKS_ON_FIRST_COLUMN, false);
- createNumberPref(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_line_width, DefaultCodeFormatterConstants.FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT, 0, 9999);
-// final CheckboxPreference singleLineComments= createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_enable_line_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, false);
-// createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_never_indent_line_comments_on_first_column, DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, false);
+ final Group lineCommentGroup = createGroup(numColumns, composite,
+ FormatterMessages.CommentsTabPage_group1_title);
+ // final CheckboxPreference singleLineCommentsOnFirstColumn= createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_format_line_comments_on_first_column, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, false);
+ // ((GridData) singleLineCommentsOnFirstColumn.getControl().getLayoutData()).horizontalIndent= indent;
+ createPrefFalseTrue(lineCommentGroup, numColumns,
+ FormatterMessages.CommentsTabPage_preserve_white_space_before_line_comment,
+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT,
+ false);
+ createPrefFalseTrue(lineCommentGroup, numColumns,
+ FormatterMessages.CommentsTabPage_line_up_line_comment_in_blocks_on_first_column,
+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_UP_LINE_COMMENT_IN_BLOCKS_ON_FIRST_COLUMN, false);
+ createNumberPref(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_line_width,
+ DefaultCodeFormatterConstants.FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT, 0, 9999);
+ // final CheckboxPreference singleLineComments= createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_enable_line_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, false);
+ // createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_never_indent_line_comments_on_first_column, DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, false);
// Block comment settings
-// final Group blockSettingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group4_title);
-// final CheckboxPreference header= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_header, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, false);
-// GridData spacerData= new GridData(0, 0);
-// spacerData.horizontalSpan= numColumns;
-// final CheckboxPreference blockComment= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_enable_block_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, false);
-// final CheckboxPreference nlBoundariesBlock= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_lines_at_comment_boundaries, DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES, false);
-// final CheckboxPreference blankLinesBlock= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_remove_blank_block_comment_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, false);
+ // final Group blockSettingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group4_title);
+ // final CheckboxPreference header= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_header, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, false);
+ // GridData spacerData= new GridData(0, 0);
+ // spacerData.horizontalSpan= numColumns;
+ // final CheckboxPreference blockComment= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_enable_block_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, false);
+ // final CheckboxPreference nlBoundariesBlock= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_lines_at_comment_boundaries, DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES, false);
+ // final CheckboxPreference blankLinesBlock= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_remove_blank_block_comment_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, false);
// Doxygen comment formatting settings
-// final Group settingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group2_title);
-// final CheckboxPreference doxygen= createPrefFalseTrue(globalGroup, numColumns, FormatterMessages.commentsTabPage_enable_javadoc_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, false);
-// final CheckboxPreference html= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_html, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML, false);
-// final CheckboxPreference code= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_code_snippets, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, false);
-// final CheckboxPreference blankDoxygen= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_blank_line_before_doxygen_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS);
-// final CheckboxPreference indentDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_indent_doxygen_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS, false);
-// final CheckboxPreference indentDesc= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_indent_description_after_param, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION, false);
-// ((GridData) indentDesc.getControl().getLayoutData()).horizontalIndent= indent;
-// final CheckboxPreference nlParam= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_line_after_param_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER);
-// final CheckboxPreference nlBoundariesDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_lines_at_doxygen_boundaries, DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES, false);
-// final CheckboxPreference blankLinesDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_clear_blank_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, false);
+ // final Group settingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group2_title);
+ // final CheckboxPreference doxygen= createPrefFalseTrue(globalGroup, numColumns, FormatterMessages.commentsTabPage_enable_javadoc_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, false);
+ // final CheckboxPreference html= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_html, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML, false);
+ // final CheckboxPreference code= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_code_snippets, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, false);
+ // final CheckboxPreference blankDoxygen= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_blank_line_before_doxygen_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS);
+ // final CheckboxPreference indentDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_indent_doxygen_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS, false);
+ // final CheckboxPreference indentDesc= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_indent_description_after_param, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION, false);
+ // ((GridData) indentDesc.getControl().getLayoutData()).horizontalIndent= indent;
+ // final CheckboxPreference nlParam= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_line_after_param_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER);
+ // final CheckboxPreference nlBoundariesDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_lines_at_doxygen_boundaries, DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES, false);
+ // final CheckboxPreference blankLinesDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_clear_blank_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, false);
// Line width settings
-// final Group widthGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group3_title);
-// final NumberPreference lineWidth= createNumberPref(widthGroup, numColumns, FormatterMessages.CommentsTabPage_line_width, DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, 0, 9999);
-
-// ArrayList<CheckboxPreference> lineFirstColumnMasters= new ArrayList<CheckboxPreference>();
-// lineFirstColumnMasters.add(singleLineComments);
-//
-// ArrayList<Object> lineFirstColumnSlaves= new ArrayList<Object>();
-// lineFirstColumnSlaves.add(singleLineCommentsOnFirstColumn);
-//
-// new Controller(lineFirstColumnMasters, lineFirstColumnSlaves) {
-// @Override
-// protected boolean areSlavesEnabled() {
-// return singleLineComments.getChecked();
-// }
-// }.update(null, null);
-//
-// ArrayList<CheckboxPreference> doxygenMaster= new ArrayList<CheckboxPreference>();
-// doxygenMaster.add(doxygen);
-// doxygenMaster.add(header);
-//
-// ArrayList<Object> doxygenSlaves= new ArrayList<Object>();
-// doxygenSlaves.add(settingsGroup);
-// doxygenSlaves.add(html);
-// doxygenSlaves.add(code);
-// doxygenSlaves.add(blankDoxygen);
-// doxygenSlaves.add(indentDoxygen);
-// doxygenSlaves.add(nlParam);
-// doxygenSlaves.add(nlBoundariesDoxygen);
-// doxygenSlaves.add(blankLinesDoxygen);
-//
-// new OrController(doxygenMaster, doxygenSlaves);
-//
-// ArrayList<CheckboxPreference> indentMasters= new ArrayList<CheckboxPreference>();
-// indentMasters.add(doxygen);
-// indentMasters.add(header);
-// indentMasters.add(indentDoxygen);
-//
-// ArrayList<Object> indentSlaves= new ArrayList<Object>();
-// indentSlaves.add(indentDesc);
-//
-// new Controller(indentMasters, indentSlaves) {
-// @Override
-// protected boolean areSlavesEnabled() {
-// return (doxygen.getChecked() || header.getChecked()) && indentDoxygen.getChecked();
-// }
-// }.update(null, null);
-//
-// ArrayList<CheckboxPreference> blockMasters= new ArrayList<CheckboxPreference>();
-// blockMasters.add(blockComment);
-// blockMasters.add(header);
-//
-// ArrayList<Object> blockSlaves= new ArrayList<Object>();
-// blockSlaves.add(blockSettingsGroup);
-// blockSlaves.add(nlBoundariesBlock);
-// blockSlaves.add(blankLinesBlock);
-//
-// new OrController(blockMasters, blockSlaves);
-//
-// ArrayList<CheckboxPreference> lineWidthMasters= new ArrayList<CheckboxPreference>();
-// lineWidthMasters.add(doxygen);
-// lineWidthMasters.add(blockComment);
-// lineWidthMasters.add(singleLineComments);
-// lineWidthMasters.add(header);
-//
-// ArrayList<Object> lineWidthSlaves= new ArrayList<Object>();
-// lineWidthSlaves.add(widthGroup);
-// lineWidthSlaves.add(lineWidth);
-//
-// new OrController(lineWidthMasters, lineWidthSlaves);
+ // final Group widthGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group3_title);
+ // final NumberPreference lineWidth= createNumberPref(widthGroup, numColumns, FormatterMessages.CommentsTabPage_line_width, DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, 0, 9999);
+
+ // ArrayList<CheckboxPreference> lineFirstColumnMasters= new ArrayList<CheckboxPreference>();
+ // lineFirstColumnMasters.add(singleLineComments);
+ //
+ // ArrayList<Object> lineFirstColumnSlaves= new ArrayList<Object>();
+ // lineFirstColumnSlaves.add(singleLineCommentsOnFirstColumn);
+ //
+ // new Controller(lineFirstColumnMasters, lineFirstColumnSlaves) {
+ // @Override
+ // protected boolean areSlavesEnabled() {
+ // return singleLineComments.getChecked();
+ // }
+ // }.update(null, null);
+ //
+ // ArrayList<CheckboxPreference> doxygenMaster= new ArrayList<CheckboxPreference>();
+ // doxygenMaster.add(doxygen);
+ // doxygenMaster.add(header);
+ //
+ // ArrayList<Object> doxygenSlaves= new ArrayList<Object>();
+ // doxygenSlaves.add(settingsGroup);
+ // doxygenSlaves.add(html);
+ // doxygenSlaves.add(code);
+ // doxygenSlaves.add(blankDoxygen);
+ // doxygenSlaves.add(indentDoxygen);
+ // doxygenSlaves.add(nlParam);
+ // doxygenSlaves.add(nlBoundariesDoxygen);
+ // doxygenSlaves.add(blankLinesDoxygen);
+ //
+ // new OrController(doxygenMaster, doxygenSlaves);
+ //
+ // ArrayList<CheckboxPreference> indentMasters= new ArrayList<CheckboxPreference>();
+ // indentMasters.add(doxygen);
+ // indentMasters.add(header);
+ // indentMasters.add(indentDoxygen);
+ //
+ // ArrayList<Object> indentSlaves= new ArrayList<Object>();
+ // indentSlaves.add(indentDesc);
+ //
+ // new Controller(indentMasters, indentSlaves) {
+ // @Override
+ // protected boolean areSlavesEnabled() {
+ // return (doxygen.getChecked() || header.getChecked()) && indentDoxygen.getChecked();
+ // }
+ // }.update(null, null);
+ //
+ // ArrayList<CheckboxPreference> blockMasters= new ArrayList<CheckboxPreference>();
+ // blockMasters.add(blockComment);
+ // blockMasters.add(header);
+ //
+ // ArrayList<Object> blockSlaves= new ArrayList<Object>();
+ // blockSlaves.add(blockSettingsGroup);
+ // blockSlaves.add(nlBoundariesBlock);
+ // blockSlaves.add(blankLinesBlock);
+ //
+ // new OrController(blockMasters, blockSlaves);
+ //
+ // ArrayList<CheckboxPreference> lineWidthMasters= new ArrayList<CheckboxPreference>();
+ // lineWidthMasters.add(doxygen);
+ // lineWidthMasters.add(blockComment);
+ // lineWidthMasters.add(singleLineComments);
+ // lineWidthMasters.add(header);
+ //
+ // ArrayList<Object> lineWidthSlaves= new ArrayList<Object>();
+ // lineWidthSlaves.add(widthGroup);
+ // lineWidthSlaves.add(lineWidth);
+ //
+ // new OrController(lineWidthMasters, lineWidthSlaves);
}
@Override
@@ -208,31 +214,32 @@ public class CommentsTabPage extends FormatterTabPage {
fPreview.setPreviewText(PREVIEW);
}
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
protected CPreview doCreateCPreview(Composite parent) {
- fPreview= new TranslationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
- */
- @Override
+ fPreview = new TranslationUnitPreview(fWorkingValues, parent);
+ return fPreview;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
+ */
+ @Override
protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
+ super.doUpdatePreview();
+ fPreview.update();
+ }
- private CheckboxPreference createPrefFalseTrue(Composite composite, int numColumns, String text, String key, boolean invertPreference) {
+ private CheckboxPreference createPrefFalseTrue(Composite composite, int numColumns, String text, String key,
+ boolean invertPreference) {
if (invertPreference)
return createCheckboxPref(composite, numColumns, text, key, TRUE_FALSE);
return createCheckboxPref(composite, numColumns, text, key, FALSE_TRUE);
}
-// private CheckboxPreference createPrefInsert(Composite composite, int numColumns, String text, String key) {
-// return createCheckboxPref(composite, numColumns, text, key, DO_NOT_INSERT_INSERT);
-// }
+ // private CheckboxPreference createPrefInsert(Composite composite, int numColumns, String text, String key) {
+ // return createCheckboxPref(composite, numColumns, text, key, DO_NOT_INSERT_INSERT);
+ // }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java
index 998ab5fd5d9..2474217ea38 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java
@@ -26,103 +26,119 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
public class ControlStatementsTabPage extends FormatterTabPage {
-
- private final String PREVIEW=
- createPreviewHeader(FormatterMessages.ControlStatementsTabPage_preview_header) +
- "class Example {" + //$NON-NLS-1$
- " void bar() {" + //$NON-NLS-1$
- " do {} while (true);" + //$NON-NLS-1$
- " try {} catch (...) { }" + //$NON-NLS-1$
- " }" + //$NON-NLS-1$
- " void foo2() {" + //$NON-NLS-1$
- " if (true) { " + //$NON-NLS-1$
- " return;" + //$NON-NLS-1$
- " }" + //$NON-NLS-1$
- " if (true) {" + //$NON-NLS-1$
- " return;" + //$NON-NLS-1$
- " } else if (false) {" + //$NON-NLS-1$
- " return; " + //$NON-NLS-1$
- " } else {" + //$NON-NLS-1$
- " return;" + //$NON-NLS-1$
- " }" + //$NON-NLS-1$
- " }" + //$NON-NLS-1$
- " void foo(int state) {" + //$NON-NLS-1$
- " if (true) return;" + //$NON-NLS-1$
- " if (true) " + //$NON-NLS-1$
- " return;" + //$NON-NLS-1$
- " else if (false)" + //$NON-NLS-1$
- " return;" + //$NON-NLS-1$
- " else return;" + //$NON-NLS-1$
- " }" + //$NON-NLS-1$
- "};"; //$NON-NLS-1$
-
-
+
+ private final String PREVIEW = createPreviewHeader(FormatterMessages.ControlStatementsTabPage_preview_header)
+ + "class Example {" + //$NON-NLS-1$
+ " void bar() {" + //$NON-NLS-1$
+ " do {} while (true);" + //$NON-NLS-1$
+ " try {} catch (...) { }" + //$NON-NLS-1$
+ " }" + //$NON-NLS-1$
+ " void foo2() {" + //$NON-NLS-1$
+ " if (true) { " + //$NON-NLS-1$
+ " return;" + //$NON-NLS-1$
+ " }" + //$NON-NLS-1$
+ " if (true) {" + //$NON-NLS-1$
+ " return;" + //$NON-NLS-1$
+ " } else if (false) {" + //$NON-NLS-1$
+ " return; " + //$NON-NLS-1$
+ " } else {" + //$NON-NLS-1$
+ " return;" + //$NON-NLS-1$
+ " }" + //$NON-NLS-1$
+ " }" + //$NON-NLS-1$
+ " void foo(int state) {" + //$NON-NLS-1$
+ " if (true) return;" + //$NON-NLS-1$
+ " if (true) " + //$NON-NLS-1$
+ " return;" + //$NON-NLS-1$
+ " else if (false)" + //$NON-NLS-1$
+ " return;" + //$NON-NLS-1$
+ " else return;" + //$NON-NLS-1$
+ " }" + //$NON-NLS-1$
+ "};"; //$NON-NLS-1$
+
private TranslationUnitPreview fPreview;
-
+
protected CheckboxPreference fThenStatementPref, fSimpleIfPref;
-
public ControlStatementsTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
super(modifyDialog, workingValues);
}
@Override
protected void doCreatePreferences(Composite composite, int numColumns) {
-
- final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.ControlStatementsTabPage_general_group_title);
- createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_else_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, DO_NOT_INSERT_INSERT);
- createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, DO_NOT_INSERT_INSERT);
- createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, DO_NOT_INSERT_INSERT);
-
- final Group ifElseGroup= createGroup(numColumns, composite, FormatterMessages.ControlStatementsTabPage_if_else_group_title);
- fThenStatementPref= createOption(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_then_on_same_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE, FALSE_TRUE);
-
- Label l= new Label(ifElseGroup, SWT.NONE);
- GridData gd= new GridData();
- gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(4);
+
+ final Group generalGroup = createGroup(numColumns, composite,
+ FormatterMessages.ControlStatementsTabPage_general_group_title);
+ createOption(generalGroup, numColumns,
+ FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_else_statements,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT,
+ DO_NOT_INSERT_INSERT);
+ createOption(generalGroup, numColumns,
+ FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT,
+ DO_NOT_INSERT_INSERT);
+ createOption(generalGroup, numColumns,
+ FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT,
+ DO_NOT_INSERT_INSERT);
+
+ final Group ifElseGroup = createGroup(numColumns, composite,
+ FormatterMessages.ControlStatementsTabPage_if_else_group_title);
+ fThenStatementPref = createOption(ifElseGroup, numColumns,
+ FormatterMessages.ControlStatementsTabPage_if_else_group_keep_then_on_same_line,
+ DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE, FALSE_TRUE);
+
+ Label l = new Label(ifElseGroup, SWT.NONE);
+ GridData gd = new GridData();
+ gd.widthHint = fPixelConverter.convertWidthInCharsToPixels(4);
l.setLayoutData(gd);
-
- fSimpleIfPref= createOption(ifElseGroup, numColumns - 1, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE, FALSE_TRUE);
-
- fThenStatementPref.addObserver( new Observer() {
+
+ fSimpleIfPref = createOption(ifElseGroup, numColumns - 1,
+ FormatterMessages.ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line,
+ DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE, FALSE_TRUE);
+
+ fThenStatementPref.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
fSimpleIfPref.setEnabled(!fThenStatementPref.getChecked());
}
-
+
});
-
+
fSimpleIfPref.setEnabled(!fThenStatementPref.getChecked());
-
- createOption(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_else_on_same_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE, FALSE_TRUE);
- createCheckboxPref(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line, DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF, FALSE_TRUE);
-// createCheckboxPref(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE, FALSE_TRUE);
+
+ createOption(ifElseGroup, numColumns,
+ FormatterMessages.ControlStatementsTabPage_if_else_group_keep_else_on_same_line,
+ DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE, FALSE_TRUE);
+ createCheckboxPref(ifElseGroup, numColumns,
+ FormatterMessages.ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line,
+ DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF, FALSE_TRUE);
+ // createCheckboxPref(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE, FALSE_TRUE);
}
-
+
@Override
protected void initializePage() {
- fPreview.setPreviewText(PREVIEW);
+ fPreview.setPreviewText(PREVIEW);
}
- /*
- * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
- */
- @Override
+ /*
+ * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
protected CPreview doCreateCPreview(Composite parent) {
- fPreview= new TranslationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- /*
- * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
- */
- @Override
+ fPreview = new TranslationUnitPreview(fWorkingValues, parent);
+ return fPreview;
+ }
+
+ /*
+ * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
+ */
+ @Override
protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
+ super.doUpdatePreview();
+ fPreview.update();
+ }
- private CheckboxPreference createOption(Composite composite, int span, String name, String key, String [] values) {
+ private CheckboxPreference createOption(Composite composite, int span, String name, String key, String[] values) {
return createCheckboxPref(composite, span, name, key, values);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java
index 57054d64052..3ca30928c3e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java
@@ -45,135 +45,136 @@ import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomPr
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
/**
- * The dialog to create a new profile.
+ * The dialog to create a new profile.
*/
public class CreateProfileDialog extends StatusDialog {
-
- private static final String PREF_OPEN_EDIT_DIALOG= CUIPlugin.PLUGIN_ID + ".codeformatter.create_profile_dialog.open_edit"; //$NON-NLS-1$
-
+
+ private static final String PREF_OPEN_EDIT_DIALOG = CUIPlugin.PLUGIN_ID
+ + ".codeformatter.create_profile_dialog.open_edit"; //$NON-NLS-1$
+
private Text fNameText;
private Combo fProfileCombo;
private Button fEditCheckbox;
-
- private final static StatusInfo fOk= new StatusInfo();
- private final static StatusInfo fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_name_is_empty);
- private final static StatusInfo fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_with_this_name_already_exists);
+
+ private final static StatusInfo fOk = new StatusInfo();
+ private final static StatusInfo fEmpty = new StatusInfo(IStatus.ERROR,
+ FormatterMessages.CreateProfileDialog_status_message_profile_name_is_empty);
+ private final static StatusInfo fDuplicate = new StatusInfo(IStatus.ERROR,
+ FormatterMessages.CreateProfileDialog_status_message_profile_with_this_name_already_exists);
private final ProfileManager fProfileManager;
private final List<Profile> fSortedProfiles;
- private final String [] fSortedNames;
-
+ private final String[] fSortedNames;
+
private CustomProfile fCreatedProfile;
protected boolean fOpenEditDialog;
private final IProfileVersioner fProfileVersioner;
-
+
public CreateProfileDialog(Shell parentShell, ProfileManager profileManager, IProfileVersioner profileVersioner) {
super(parentShell);
- fProfileManager= profileManager;
- fProfileVersioner= profileVersioner;
- fSortedProfiles= fProfileManager.getSortedProfiles();
- fSortedNames= fProfileManager.getSortedDisplayNames();
+ fProfileManager = profileManager;
+ fProfileVersioner = profileVersioner;
+ fSortedProfiles = fProfileManager.getSortedProfiles();
+ fSortedNames = fProfileManager.getSortedDisplayNames();
setShellStyle(getShellStyle() | SWT.RESIZE);
}
-
-
+
@Override
public void create() {
super.create();
- setTitle(FormatterMessages.CreateProfileDialog_dialog_title);
+ setTitle(FormatterMessages.CreateProfileDialog_dialog_title);
}
-
+
@Override
public Control createDialogArea(Composite parent) {
-
- final int numColumns= 2;
-
+
+ final int numColumns = 2;
+
GridData gd;
-
- final GridLayout layout= new GridLayout(numColumns, false);
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
-
- final Composite composite= new Composite(parent, SWT.NONE);
+
+ final GridLayout layout = new GridLayout(numColumns, false);
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+
+ final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(layout);
-
+
// Create "Profile name:" label
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = numColumns;
- gd.widthHint= convertWidthInCharsToPixels(60);
+ gd.widthHint = convertWidthInCharsToPixels(60);
final Label nameLabel = new Label(composite, SWT.WRAP);
- nameLabel.setText(FormatterMessages.CreateProfileDialog_profile_name_label_text);
+ nameLabel.setText(FormatterMessages.CreateProfileDialog_profile_name_label_text);
nameLabel.setLayoutData(gd);
-
+
// Create text field to enter name
- gd = new GridData( GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= numColumns;
- fNameText= new Text(composite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = numColumns;
+ fNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
fNameText.setLayoutData(gd);
- fNameText.addModifyListener( new ModifyListener() {
+ fNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
doValidation();
}
});
-
+
// Create "Initialize settings ..." label
gd = new GridData();
gd.horizontalSpan = numColumns;
Label profileLabel = new Label(composite, SWT.WRAP);
- profileLabel.setText(FormatterMessages.CreateProfileDialog_base_profile_label_text);
+ profileLabel.setText(FormatterMessages.CreateProfileDialog_base_profile_label_text);
profileLabel.setLayoutData(gd);
-
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= numColumns;
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = numColumns;
fProfileCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
fProfileCombo.setLayoutData(gd);
-
-
+
// "Open the edit dialog now" checkbox
- gd= new GridData();
- gd.horizontalSpan= numColumns;
- fEditCheckbox= new Button(composite, SWT.CHECK);
- fEditCheckbox.setText(FormatterMessages.CreateProfileDialog_open_edit_dialog_checkbox_text);
+ gd = new GridData();
+ gd.horizontalSpan = numColumns;
+ fEditCheckbox = new Button(composite, SWT.CHECK);
+ fEditCheckbox.setText(FormatterMessages.CreateProfileDialog_open_edit_dialog_checkbox_text);
fEditCheckbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- fOpenEditDialog= ((Button)e.widget).getSelection();
+ fOpenEditDialog = ((Button) e.widget).getSelection();
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
-
- final IDialogSettings dialogSettings= CUIPlugin.getDefault().getDialogSettings();//.get(PREF_OPEN_EDIT_DIALOG);
+
+ final IDialogSettings dialogSettings = CUIPlugin.getDefault().getDialogSettings();//.get(PREF_OPEN_EDIT_DIALOG);
if (dialogSettings.get(PREF_OPEN_EDIT_DIALOG) != null) {
- fOpenEditDialog= dialogSettings.getBoolean(PREF_OPEN_EDIT_DIALOG);
+ fOpenEditDialog = dialogSettings.getBoolean(PREF_OPEN_EDIT_DIALOG);
} else {
- fOpenEditDialog= true;
+ fOpenEditDialog = true;
}
fEditCheckbox.setSelection(fOpenEditDialog);
-
+
fProfileCombo.setItems(fSortedNames);
fProfileCombo.setText(fProfileManager.getDefaultProfile().getName());
updateStatus(fEmpty);
-
+
applyDialogFont(composite);
-
+
fNameText.setFocus();
-
+
return composite;
}
-
/**
* Validate the current settings
*/
protected void doValidation() {
- final String name= fNameText.getText().trim();
-
+ final String name = fNameText.getText().trim();
+
if (fProfileManager.containsName(name)) {
updateStatus(fDuplicate);
return;
@@ -184,26 +185,28 @@ public class CreateProfileDialog extends StatusDialog {
}
updateStatus(fOk);
}
-
+
@Override
protected void okPressed() {
- if (!getStatus().isOK())
+ if (!getStatus().isOK())
return;
CUIPlugin.getDefault().getDialogSettings().put(PREF_OPEN_EDIT_DIALOG, fOpenEditDialog);
- final Map<String, String> baseSettings= new HashMap<String, String>((fSortedProfiles.get(fProfileCombo.getSelectionIndex())).getSettings());
- final String profileName= fNameText.getText();
-
- fCreatedProfile= new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());
+ final Map<String, String> baseSettings = new HashMap<String, String>(
+ (fSortedProfiles.get(fProfileCombo.getSelectionIndex())).getSettings());
+ final String profileName = fNameText.getText();
+
+ fCreatedProfile = new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(),
+ fProfileVersioner.getProfileKind());
fProfileManager.addProfile(fCreatedProfile);
super.okPressed();
}
-
+
public final CustomProfile getCreatedProfile() {
return fCreatedProfile;
}
-
+
public final boolean openEditDialog() {
return fOpenEditDialog;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java
index 711635e885d..44786b0afec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java
@@ -61,18 +61,18 @@ public class CustomCodeFormatterBlock extends Observable {
final IScopeContext scope;
final IEclipsePreferences defaults;
if (project != null) {
- scope= access.getProjectScope(project);
- defaults= access.getInstanceScope().getNode(CCorePlugin.PLUGIN_ID);
+ scope = access.getProjectScope(project);
+ defaults = access.getInstanceScope().getNode(CCorePlugin.PLUGIN_ID);
} else {
- scope= access.getInstanceScope();
- defaults= access.getDefaultScope().getNode(CCorePlugin.PLUGIN_ID);
+ scope = access.getInstanceScope();
+ defaults = access.getDefaultScope().getNode(CCorePlugin.PLUGIN_ID);
}
- fPrefs= scope.getNode(CCorePlugin.PLUGIN_ID);
- fDefaultFormatterId= defaults.get(CCorePreferenceConstants.CODE_FORMATTER, null);
+ fPrefs = scope.getNode(CCorePlugin.PLUGIN_ID);
+ fDefaultFormatterId = defaults.get(CCorePreferenceConstants.CODE_FORMATTER, null);
if (fDefaultFormatterId == null) {
// Backward compatibility: use UI prefs
- IEclipsePreferences instance= access.getInstanceScope().getNode(CUIPlugin.PLUGIN_ID);
- fDefaultFormatterId= instance.get(CCorePreferenceConstants.CODE_FORMATTER, null);
+ IEclipsePreferences instance = access.getInstanceScope().getNode(CUIPlugin.PLUGIN_ID);
+ fDefaultFormatterId = instance.get(CCorePreferenceConstants.CODE_FORMATTER, null);
if (fDefaultFormatterId != null) {
instance.remove(CCorePreferenceConstants.CODE_FORMATTER);
if (project != null) {
@@ -120,7 +120,7 @@ public class CustomCodeFormatterBlock extends Observable {
/**
* Returns the currently selected formatter id.
- *
+ *
* @return the selected formatter id or {@code null} if the default is selected.
*/
public String getFormatterId() {
@@ -134,7 +134,8 @@ public class CustomCodeFormatterBlock extends Observable {
if (idMap.size() == 1) {
return parent; // No selector is needed since there is only one formatter.
}
- Composite composite = ControlFactory.createGroup(parent, FormatterMessages.CustomCodeFormatterBlock_formatter_name, 1);
+ Composite composite = ControlFactory.createGroup(parent,
+ FormatterMessages.CustomCodeFormatterBlock_formatter_name, 1);
((GridData) composite.getLayoutData()).horizontalSpan = 5;
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
@@ -152,18 +153,18 @@ public class CustomCodeFormatterBlock extends Observable {
fFormatterCombo.add(item);
}
- final String noteTitle= FormatterMessages.CustomCodeFormatterBlock_formatter_note;
- final String noteMessage= FormatterMessages.CustomCodeFormatterBlock_contributed_formatter_warning;
+ final String noteTitle = FormatterMessages.CustomCodeFormatterBlock_formatter_note;
+ final String noteMessage = FormatterMessages.CustomCodeFormatterBlock_contributed_formatter_warning;
ControlFactory.createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
-
+
initDefault();
-
+
return composite;
}
private void handleFormatterChanged() {
setChanged();
- String formatterId= getFormatterId();
+ String formatterId = getFormatterId();
notifyObservers(formatterId);
}
@@ -171,7 +172,7 @@ public class CustomCodeFormatterBlock extends Observable {
if (fFormatterCombo == null) {
return;
}
- String formatterID= fPrefs.get(CCorePreferenceConstants.CODE_FORMATTER, fDefaultFormatterId);
+ String formatterID = fPrefs.get(CCorePreferenceConstants.CODE_FORMATTER, fDefaultFormatterId);
fFormatterCombo.setText(getFormatterById(formatterID));
}
@@ -192,16 +193,17 @@ public class CustomCodeFormatterBlock extends Observable {
private void initializeFormatters() {
idMap.clear();
idMap.put(DEFAULT, CCorePreferenceConstants.DEFAULT_CODE_FORMATTER);
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.FORMATTER_EXTPOINT_ID);
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
+ CCorePlugin.FORMATTER_EXTPOINT_ID);
if (point != null) {
IExtension[] exts = point.getExtensions();
for (IExtension ext : exts) {
- IConfigurationElement[] elements = ext.getConfigurationElements();
- for (int j = 0; j < elements.length; ++j) {
- String name = elements[j].getAttribute(ATTR_NAME);
- String id= elements[j].getAttribute(ATTR_ID);
- idMap.put(name, id);
- }
+ IConfigurationElement[] elements = ext.getConfigurationElements();
+ for (int j = 0; j < elements.length; ++j) {
+ String name = elements[j].getAttribute(ATTR_NAME);
+ String id = elements[j].getAttribute(ATTR_ID);
+ idMap.put(name, id);
+ }
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java
index acf7ce6942a..6deaa290f1b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java
@@ -108,12 +108,12 @@ final class FormatterMessages extends NLS {
public static String WhiteSpaceTabPage_after_closing_angle_bracket;
public static String WhiteSpaceTabPage_before_opening_angle_bracket;
public static String WhiteSpaceTabPage_before_closing_angle_bracket;
-// public static String WhiteSpaceTabPage_before_parenthesized_expressions;
+ // public static String WhiteSpaceTabPage_before_parenthesized_expressions;
public static String WhiteSpaceTabPage_insert_space;
public static String WhiteSpaceTabPage_sort_by_c_element;
public static String WhiteSpaceTabPage_sort_by_syntax_element;
-// public static String WhiteSpaceOptions_return;
-// public static String WhiteSpaceOptions_throw;
+ // public static String WhiteSpaceOptions_return;
+ // public static String WhiteSpaceOptions_throw;
public static String WhiteSpaceOptions_base_clause;
public static String WhiteSpaceOptions_before;
public static String WhiteSpaceOptions_after;
@@ -189,12 +189,12 @@ final class FormatterMessages extends NLS {
public static String WhiteSpaceOptions_after_semicolon;
public static String WhiteSpaceOptions_before_question_mark;
public static String WhiteSpaceOptions_after_question_mark;
-// public static String WhiteSpaceOptions_before_ellipsis;
-// public static String WhiteSpaceOptions_after_ellipsis;
-// public static String WhiteSpaceOptions_return_with_parenthesized_expression;
-// public static String WhiteSpaceOptions_throw_with_parenthesized_expression;
+ // public static String WhiteSpaceOptions_before_ellipsis;
+ // public static String WhiteSpaceOptions_after_ellipsis;
+ // public static String WhiteSpaceOptions_return_with_parenthesized_expression;
+ // public static String WhiteSpaceOptions_throw_with_parenthesized_expression;
public static String LineWrappingTabPage_base_clause;
-// public static String LineWrappingTabPage_compact_if_else;
+ // public static String LineWrappingTabPage_compact_if_else;
public static String LineWrappingTabPage_parameters;
public static String LineWrappingTabPage_arguments;
public static String LineWrappingTabPage_throws_clause;
@@ -213,11 +213,11 @@ final class FormatterMessages extends NLS {
public static String LineWrappingTabPage_function_decls;
public static String LineWrappingTabPage_function_calls;
public static String LineWrappingTabPage_expressions;
-// public static String LineWrappingTabPage_statements;
+ // public static String LineWrappingTabPage_statements;
public static String LineWrappingTabPage_do_not_join_lines;
-
+
public static String LineWrappingTabPage_base_clause_lowercase;
-// public static String LineWrappingTabPage_compact_if_else_lowercase;
+ // public static String LineWrappingTabPage_compact_if_else_lowercase;
public static String LineWrappingTabPage_parameters_lowercase;
public static String LineWrappingTabPage_arguments_lowercase;
public static String LineWrappingTabPage_throws_clause_lowercase;
@@ -236,7 +236,7 @@ final class FormatterMessages extends NLS {
public static String LineWrappingTabPage_function_decls_lowercase;
public static String LineWrappingTabPage_function_calls_lowercase;
public static String LineWrappingTabPage_expressions_lowercase;
-// public static String LineWrappingTabPage_statements_lowercase;
+ // public static String LineWrappingTabPage_statements_lowercase;
public static String LineWrappingTabPage_assignment_alignment_lowercase;
public static String LineWrappingTabPage_wrapping_policy_label_text;
@@ -267,22 +267,22 @@ final class FormatterMessages extends NLS {
public static String AlreadyExistsDialog_dialog_label;
public static String AlreadyExistsDialog_rename_radio_button_desc;
public static String AlreadyExistsDialog_overwrite_radio_button_desc;
-// public static String BlankLinesTabPage_preview_header;
-// public static String BlankLinesTabPage_compilation_unit_group_title;
-// public static String BlankLinesTabPage_compilation_unit_option_before_package;
-// public static String BlankLinesTabPage_compilation_unit_option_after_package;
-// public static String BlankLinesTabPage_compilation_unit_option_before_import;
-// public static String BlankLinesTabPage_compilation_unit_option_after_import;
-// public static String BlankLinesTabPage_compilation_unit_option_between_type_declarations;
-// public static String BlankLinesTabPage_class_group_title;
-// public static String BlankLinesTabPage_class_option_before_first_decl;
-// public static String BlankLinesTabPage_class_option_before_decls_of_same_kind;
-// public static String BlankLinesTabPage_class_option_before_member_class_decls;
-// public static String BlankLinesTabPage_class_option_before_field_decls;
-// public static String BlankLinesTabPage_class_option_before_method_decls;
-// public static String BlankLinesTabPage_class_option_at_beginning_of_method_body;
-// public static String BlankLinesTabPage_blank_lines_group_title;
-// public static String BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve;
+ // public static String BlankLinesTabPage_preview_header;
+ // public static String BlankLinesTabPage_compilation_unit_group_title;
+ // public static String BlankLinesTabPage_compilation_unit_option_before_package;
+ // public static String BlankLinesTabPage_compilation_unit_option_after_package;
+ // public static String BlankLinesTabPage_compilation_unit_option_before_import;
+ // public static String BlankLinesTabPage_compilation_unit_option_after_import;
+ // public static String BlankLinesTabPage_compilation_unit_option_between_type_declarations;
+ // public static String BlankLinesTabPage_class_group_title;
+ // public static String BlankLinesTabPage_class_option_before_first_decl;
+ // public static String BlankLinesTabPage_class_option_before_decls_of_same_kind;
+ // public static String BlankLinesTabPage_class_option_before_member_class_decls;
+ // public static String BlankLinesTabPage_class_option_before_field_decls;
+ // public static String BlankLinesTabPage_class_option_before_method_decls;
+ // public static String BlankLinesTabPage_class_option_at_beginning_of_method_body;
+ // public static String BlankLinesTabPage_blank_lines_group_title;
+ // public static String BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve;
public static String BracesTabPage_preview_header;
public static String BracesTabPage_position_same_line;
public static String BracesTabPage_position_next_line;
@@ -336,7 +336,7 @@ final class FormatterMessages extends NLS {
public static String ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line;
public static String ControlStatementsTabPage_if_else_group_keep_else_on_same_line;
public static String ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line;
-// public static String ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line;
+ // public static String ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line;
public static String CreateProfileDialog_status_message_profile_with_this_name_already_exists;
public static String CreateProfileDialog_status_message_profile_name_is_empty;
public static String CreateProfileDialog_dialog_title;
@@ -351,8 +351,8 @@ final class FormatterMessages extends NLS {
public static String IndentationTabPage_general_group_option_tab_policy_MIXED;
public static String IndentationTabPage_general_group_option_tab_size;
public static String IndentationTabPage_general_group_option_indent_size;
-// public static String IndentationTabPage_field_alignment_group_title;
-// public static String IndentationTabPage_field_alignment_group_align_fields_in_columns;
+ // public static String IndentationTabPage_field_alignment_group_title;
+ // public static String IndentationTabPage_field_alignment_group_align_fields_in_columns;
public static String IndentationTabPage_indent_group_title;
public static String IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body;
public static String IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers;
@@ -362,14 +362,14 @@ final class FormatterMessages extends NLS {
public static String IndentationTabPage_switch_group_option_indent_statements_within_case_body;
public static String IndentationTabPage_switch_group_option_indent_break_statements;
public static String IndentationTabPage_namespace_group_option_indent_declarations_within_namespace;
- public static String IndentationTabPage_indent_empty_lines;
+ public static String IndentationTabPage_indent_empty_lines;
public static String IndentationTabPage_use_tabs_only_for_leading_indentations;
public static String ModifyDialog_dialog_title;
public static String ModifyDialog_apply_button;
public static String ModifyDialog_tabpage_braces_title;
public static String ModifyDialog_tabpage_indentation_title;
public static String ModifyDialog_tabpage_whitespace_title;
-// public static String ModifyDialog_tabpage_blank_lines_title;
+ // public static String ModifyDialog_tabpage_blank_lines_title;
public static String ModifyDialog_tabpage_new_lines_title;
public static String ModifyDialog_tabpage_control_statements_title;
public static String ModifyDialog_tabpage_line_wrapping_title;
@@ -382,17 +382,17 @@ final class FormatterMessages extends NLS {
public static String NewLinesTabPage_preview_header;
public static String NewLinesTabPage_newlines_group_title;
public static String NewLinesTabPage_newlines_group_option_before_colon_in_constructor_initializer_list;
-// public static String NewLinesTabPage_newlines_group_option_empty_class_body;
-// public static String NewLinesTabPage_newlines_group_option_empty_method_body;
-// public static String NewLinesTabPage_newlines_group_option_empty_block;
-// public static String NewLinesTabPage_newlines_group_option_empty_end_of_file;
-// public static String NewLinesTabPage_empty_statement_group_title;
-// public static String NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line;
-// public static String NewLinesTabPage_arrayInitializer_group_title;
-// public static String NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer;
-// public static String NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer;
-// public static String NewLinesTabPage_annotations_group_title;
-// public static String NewLinesTabPage_annotations_group_option_after_annotation;
+ // public static String NewLinesTabPage_newlines_group_option_empty_class_body;
+ // public static String NewLinesTabPage_newlines_group_option_empty_method_body;
+ // public static String NewLinesTabPage_newlines_group_option_empty_block;
+ // public static String NewLinesTabPage_newlines_group_option_empty_end_of_file;
+ // public static String NewLinesTabPage_empty_statement_group_title;
+ // public static String NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line;
+ // public static String NewLinesTabPage_arrayInitializer_group_title;
+ // public static String NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer;
+ // public static String NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer;
+ // public static String NewLinesTabPage_annotations_group_title;
+ // public static String NewLinesTabPage_annotations_group_option_after_annotation;
public static String ProfileManager_kandr_profile_name;
public static String ProfileManager_allman_profile_name;
public static String ProfileManager_gnu_profile_name;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModifyDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
index 9c89a8e1f6d..ae0237496b1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
@@ -22,20 +22,22 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
public class FormatterModifyDialog extends ModifyDialog {
-
- public FormatterModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
+
+ public FormatterModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager,
+ ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
super(parentShell, profile, profileManager, profileStore, newProfile, dialogPreferencesKey, lastSavePathKey);
}
-
+
@Override
protected void addPages(Map<String, String> values) {
- addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values));
-// addTabPage(FormatterMessages.ModifyDialog_tabpage_blank_lines_title, new BlankLinesTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_new_lines_title, new NewLinesTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_control_statements_title, new ControlStatementsTabPage(this, values));
- addTabPage(FormatterMessages.ModifyDialog_tabpage_line_wrapping_title, new LineWrappingTabPage(this, values));
+ addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values));
+ addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values));
+ addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values));
+ // addTabPage(FormatterMessages.ModifyDialog_tabpage_blank_lines_title, new BlankLinesTabPage(this, values));
+ addTabPage(FormatterMessages.ModifyDialog_tabpage_new_lines_title, new NewLinesTabPage(this, values));
+ addTabPage(FormatterMessages.ModifyDialog_tabpage_control_statements_title,
+ new ControlStatementsTabPage(this, values));
+ addTabPage(FormatterMessages.ModifyDialog_tabpage_line_wrapping_title, new LineWrappingTabPage(this, values));
addTabPage(FormatterMessages.ModifyDialog_tabpage_comments_title, new CommentsTabPage(this, values));
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java
index 1272dbe096f..b7f993bbb5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java
@@ -34,85 +34,96 @@ import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
public class FormatterProfileManager extends ProfileManager {
private static final List<String> EMPTY_LIST = Collections.emptyList();
- public final static String KANDR_PROFILE= "org.eclipse.cdt.ui.default.kandr_profile"; //$NON-NLS-1$
- public final static String ALLMAN_PROFILE= "org.eclipse.cdt.ui.default.allman_profile"; //$NON-NLS-1$
- public final static String GNU_PROFILE= "org.eclipse.cdt.ui.default.gnu_profile"; //$NON-NLS-1$
- public final static String WHITESMITHS_PROFILE= "org.eclipse.cdt.ui.default.whitesmites_profile"; //$NON-NLS-1$
-
- public final static String DEFAULT_PROFILE= KANDR_PROFILE;
-
- private final static KeySet[] KEY_SETS= new KeySet[] {
- new KeySet(CCorePlugin.PLUGIN_ID, new ArrayList<String>(DefaultCodeFormatterConstants.getDefaultSettings().keySet())),
- new KeySet(CUIPlugin.PLUGIN_ID, EMPTY_LIST)
- };
-
- private final static String PROFILE_KEY= PreferenceConstants.FORMATTER_PROFILE;
- private final static String FORMATTER_SETTINGS_VERSION= "formatter_settings_version"; //$NON-NLS-1$
-
- public FormatterProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess preferencesAccess, IProfileVersioner profileVersioner) {
- super(addBuiltinProfiles(profiles, profileVersioner), context, preferencesAccess, profileVersioner, KEY_SETS, PROFILE_KEY, FORMATTER_SETTINGS_VERSION);
- }
-
+ public final static String KANDR_PROFILE = "org.eclipse.cdt.ui.default.kandr_profile"; //$NON-NLS-1$
+ public final static String ALLMAN_PROFILE = "org.eclipse.cdt.ui.default.allman_profile"; //$NON-NLS-1$
+ public final static String GNU_PROFILE = "org.eclipse.cdt.ui.default.gnu_profile"; //$NON-NLS-1$
+ public final static String WHITESMITHS_PROFILE = "org.eclipse.cdt.ui.default.whitesmites_profile"; //$NON-NLS-1$
+
+ public final static String DEFAULT_PROFILE = KANDR_PROFILE;
+
+ private final static KeySet[] KEY_SETS = new KeySet[] {
+ new KeySet(CCorePlugin.PLUGIN_ID,
+ new ArrayList<String>(DefaultCodeFormatterConstants.getDefaultSettings().keySet())),
+ new KeySet(CUIPlugin.PLUGIN_ID, EMPTY_LIST) };
+
+ private final static String PROFILE_KEY = PreferenceConstants.FORMATTER_PROFILE;
+ private final static String FORMATTER_SETTINGS_VERSION = "formatter_settings_version"; //$NON-NLS-1$
+
+ public FormatterProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess preferencesAccess,
+ IProfileVersioner profileVersioner) {
+ super(addBuiltinProfiles(profiles, profileVersioner), context, preferencesAccess, profileVersioner, KEY_SETS,
+ PROFILE_KEY, FORMATTER_SETTINGS_VERSION);
+ }
+
private static List<Profile> addBuiltinProfiles(List<Profile> profiles, IProfileVersioner profileVersioner) {
- final Profile kandrProfile= new BuiltInProfile(KANDR_PROFILE, FormatterMessages.ProfileManager_kandr_profile_name, getKandRSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
+ final Profile kandrProfile = new BuiltInProfile(KANDR_PROFILE,
+ FormatterMessages.ProfileManager_kandr_profile_name, getKandRSettings(), 2,
+ profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
profiles.add(kandrProfile);
- final Profile allmanProfile= new BuiltInProfile(ALLMAN_PROFILE, FormatterMessages.ProfileManager_allman_profile_name, getAllmanSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
+ final Profile allmanProfile = new BuiltInProfile(ALLMAN_PROFILE,
+ FormatterMessages.ProfileManager_allman_profile_name, getAllmanSettings(), 2,
+ profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
profiles.add(allmanProfile);
- final Profile gnuProfile= new BuiltInProfile(GNU_PROFILE, FormatterMessages.ProfileManager_gnu_profile_name, getGNUSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
+ final Profile gnuProfile = new BuiltInProfile(GNU_PROFILE, FormatterMessages.ProfileManager_gnu_profile_name,
+ getGNUSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
profiles.add(gnuProfile);
- final Profile whitesmithsProfile= new BuiltInProfile(WHITESMITHS_PROFILE, FormatterMessages.ProfileManager_whitesmiths_profile_name, getWhitesmithsSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
+ final Profile whitesmithsProfile = new BuiltInProfile(WHITESMITHS_PROFILE,
+ FormatterMessages.ProfileManager_whitesmiths_profile_name, getWhitesmithsSettings(), 2,
+ profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
profiles.add(whitesmithsProfile);
// Add the Profiles which are at default scope and hence are contributed by a product.
- try {
- List<Profile> defaultProfiles= new FormatterProfileStore(profileVersioner).readProfiles(DefaultScope.INSTANCE);
- if (defaultProfiles != null) {
- Map<String, Profile> profMap= new LinkedHashMap<String, Profile>();
- // Add the already loaded / created profiles to a map
- for (Profile p : profiles)
- profMap.put(p.getID(), p);
-
- // Default profiles override any colliding profiles already in the list
- for (Profile p : defaultProfiles)
- profMap.put(p.getID(), new BuiltInProfile(p.getName(), p.getName(), p.getSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()));
- profiles= new ArrayList<Profile>(profMap.values());
- }
- } catch (CoreException e) {
- CUIPlugin.log(e);
- }
+ try {
+ List<Profile> defaultProfiles = new FormatterProfileStore(profileVersioner)
+ .readProfiles(DefaultScope.INSTANCE);
+ if (defaultProfiles != null) {
+ Map<String, Profile> profMap = new LinkedHashMap<String, Profile>();
+ // Add the already loaded / created profiles to a map
+ for (Profile p : profiles)
+ profMap.put(p.getID(), p);
+
+ // Default profiles override any colliding profiles already in the list
+ for (Profile p : defaultProfiles)
+ profMap.put(p.getID(), new BuiltInProfile(p.getName(), p.getName(), p.getSettings(), 2,
+ profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()));
+ profiles = new ArrayList<Profile>(profMap.values());
+ }
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
return profiles;
}
-
- /**
+
+ /**
* @return Returns the default settings.
*/
public static Map<String, String> getDefaultSettings() {
return DefaultCodeFormatterConstants.getDefaultSettings();
}
- /**
+ /**
* @return Returns the K&R settings.
*/
public static Map<String, String> getKandRSettings() {
return DefaultCodeFormatterConstants.getKandRSettings();
}
- /**
+ /**
* @return Returns the ANSI settings.
*/
public static Map<String, String> getAllmanSettings() {
return DefaultCodeFormatterConstants.getAllmanSettings();
}
- /**
+ /**
* @return Returns the GNU settings.
*/
public static Map<String, String> getGNUSettings() {
return DefaultCodeFormatterConstants.getGNUSettings();
}
- /**
+ /**
* @return Returns the Whitesmiths settings.
*/
public static Map<String, String> getWhitesmithsSettings() {
@@ -120,36 +131,36 @@ public class FormatterProfileManager extends ProfileManager {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager#getSelectedProfileId(org.eclipse.core.runtime.preferences.IScopeContext)
- */
+ * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager#getSelectedProfileId(org.eclipse.core.runtime.preferences.IScopeContext)
+ */
@Override
- protected String getSelectedProfileId(IScopeContext instanceScope) {
- String profileId= instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
+ protected String getSelectedProfileId(IScopeContext instanceScope) {
+ String profileId = instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
if (profileId == null) {
// request from bug 129427
- profileId= DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
+ profileId = DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
// fix for bug 89739
-// if (DEFAULT_PROFILE.equals(profileId)) { // default default:
-// IEclipsePreferences node= instanceScope.getNode(CCorePlugin.PLUGIN_ID);
-// if (node != null) {
-// String tabSetting= node.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, null);
-// if (CCorePlugin.SPACE.equals(tabSetting)) {
-// profileId= TAB_WIDTH_8_PROFILE;
-// }
-// }
-// }
+ // if (DEFAULT_PROFILE.equals(profileId)) { // default default:
+ // IEclipsePreferences node= instanceScope.getNode(CCorePlugin.PLUGIN_ID);
+ // if (node != null) {
+ // String tabSetting= node.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, null);
+ // if (CCorePlugin.SPACE.equals(tabSetting)) {
+ // profileId= TAB_WIDTH_8_PROFILE;
+ // }
+ // }
+ // }
}
- return profileId;
- }
+ return profileId;
+ }
/* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager#getDefaultProfile()
- */
- @Override
+ * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager#getDefaultProfile()
+ */
+ @Override
public Profile getDefaultProfile() {
- Profile p = super.getDefaultProfile();
- if (p != null)
- return p;
- return getProfile(DEFAULT_PROFILE);
- }
+ Profile p = super.getDefaultProfile();
+ if (p != null)
+ return p;
+ return getProfile(DEFAULT_PROFILE);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileStore.java
index f5a9ea50fb6..61f4ea0e373 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileStore.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileStore.java
@@ -26,30 +26,29 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-
public class FormatterProfileStore extends ProfileStore {
/**
* Preference key where all profiles are stored
*/
- private static final String PREF_FORMATTER_PROFILES= "org.eclipse.cdt.ui.formatterprofiles"; //$NON-NLS-1$
- private static final String PREF_FORMATTER_PROFILES_OLD= "org.eclipse.jdt.ui.formatterprofiles"; //$NON-NLS-1$
-
+ private static final String PREF_FORMATTER_PROFILES = "org.eclipse.cdt.ui.formatterprofiles"; //$NON-NLS-1$
+ private static final String PREF_FORMATTER_PROFILES_OLD = "org.eclipse.jdt.ui.formatterprofiles"; //$NON-NLS-1$
+
public FormatterProfileStore(IProfileVersioner profileVersioner) {
super(PREF_FORMATTER_PROFILES, profileVersioner);
}
-
+
/**
* {@inheritDoc}
*/
@Override
public List<Profile> readProfiles(IScopeContext scope) throws CoreException {
- final IEclipsePreferences node= scope.getNode(CUIPlugin.PLUGIN_ID);
- final String profilesValue= node.get(PREF_FORMATTER_PROFILES_OLD, null);
+ final IEclipsePreferences node = scope.getNode(CUIPlugin.PLUGIN_ID);
+ final String profilesValue = node.get(PREF_FORMATTER_PROFILES_OLD, null);
if (profilesValue != null) {
// migrate to new preference key
final String versionKeyOld = PREF_FORMATTER_PROFILES_OLD + VERSION_KEY_SUFFIX;
- String version= node.get(versionKeyOld, null);
+ String version = node.get(versionKeyOld, null);
node.put(PREF_FORMATTER_PROFILES, profilesValue);
node.put(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, version);
node.remove(PREF_FORMATTER_PROFILES_OLD);
@@ -60,7 +59,7 @@ public class FormatterProfileStore extends ProfileStore {
return readProfilesFromString(profilesValue);
}
}
- return super.readProfiles(scope);
+ return super.readProfiles(scope);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java
index 51c448288e5..610ea3dcfd6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java
@@ -30,26 +30,27 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.ui.CUIPlugin;
public abstract class FormatterTabPage extends ModifyDialogTabPage {
- private final static String SHOW_INVISIBLE_PREFERENCE_KEY= CUIPlugin.PLUGIN_ID + ".formatter_page.show_invisible_characters"; //$NON-NLS-1$
-
- /**
- * Constant array for boolean true/false selection.
- *
- * @since 5.3
- */
- protected static String[] TRUE_FALSE= { DefaultCodeFormatterConstants.TRUE, DefaultCodeFormatterConstants.FALSE };
-
- /**
- * Constant array for boolean true/false selection.
- *
- * @since 5.3
- */
- protected static String[] FALSE_TRUE= { DefaultCodeFormatterConstants.FALSE, DefaultCodeFormatterConstants.TRUE };
+ private final static String SHOW_INVISIBLE_PREFERENCE_KEY = CUIPlugin.PLUGIN_ID
+ + ".formatter_page.show_invisible_characters"; //$NON-NLS-1$
+
+ /**
+ * Constant array for boolean true/false selection.
+ *
+ * @since 5.3
+ */
+ protected static String[] TRUE_FALSE = { DefaultCodeFormatterConstants.TRUE, DefaultCodeFormatterConstants.FALSE };
+
+ /**
+ * Constant array for boolean true/false selection.
+ *
+ * @since 5.3
+ */
+ protected static String[] FALSE_TRUE = { DefaultCodeFormatterConstants.FALSE, DefaultCodeFormatterConstants.TRUE };
/**
* Constant array for insert / not_insert.
*/
- protected static String[] DO_NOT_INSERT_INSERT= { CCorePlugin.DO_NOT_INSERT, CCorePlugin.INSERT };
+ protected static String[] DO_NOT_INSERT_INSERT = { CCorePlugin.DO_NOT_INSERT, CCorePlugin.INSERT };
private CPreview fPreview;
private final IDialogSettings fDialogSettings;
@@ -58,14 +59,14 @@ public abstract class FormatterTabPage extends ModifyDialogTabPage {
public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener,
Map<String, String> workingValues) {
super(modifyListener, workingValues);
- fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
+ fDialogSettings = CUIPlugin.getDefault().getDialogSettings();
}
@Override
protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
- createLabel(numColumns - 1, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);
-
- fShowInvisibleButton= new Button(composite, SWT.CHECK);
+ createLabel(numColumns - 1, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);
+
+ fShowInvisibleButton = new Button(composite, SWT.CHECK);
fShowInvisibleButton.setText(FormatterMessages.FormatterTabPage_ShowInvisibleCharacters_label);
fShowInvisibleButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
fShowInvisibleButton.addSelectionListener(new SelectionAdapter() {
@@ -77,26 +78,26 @@ public abstract class FormatterTabPage extends ModifyDialogTabPage {
}
});
fShowInvisibleButton.setSelection(isShowInvisible());
-
- fPreview= doCreateCPreview(composite);
+
+ fPreview = doCreateCPreview(composite);
fDefaultFocusManager.add(fPreview.getControl());
fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection());
-
- final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0);
- gd.widthHint= 0;
- gd.heightHint=0;
+
+ final GridData gd = createGridData(numColumns, GridData.FILL_BOTH, 0);
+ gd.widthHint = 0;
+ gd.heightHint = 0;
fPreview.getControl().setLayoutData(gd);
-
+
return composite;
}
private boolean isShowInvisible() {
return fDialogSettings.getBoolean(SHOW_INVISIBLE_PREFERENCE_KEY);
}
-
+
@Override
protected void doUpdatePreview() {
- boolean showInvisible= isShowInvisible();
+ boolean showInvisible = isShowInvisible();
fPreview.showInvisibleCharacters(showInvisible);
fShowInvisibleButton.setSelection(showInvisible);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogTabPage.java
index 0129a8afbdf..bf6de000426 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogTabPage.java
@@ -25,17 +25,17 @@ import org.eclipse.swt.widgets.Composite;
public interface IModifyDialogTabPage {
public interface IModificationListener {
-
+
void updateStatus(IStatus status);
-
+
void valuesModified();
-
+
}
/**
* A map containing key value pairs this tab page
* is must modify.
- *
+ *
* @param workingValues the values to work with
*/
public void setWorkingValues(Map<String, String> workingValues);
@@ -45,21 +45,21 @@ public interface IModifyDialogTabPage {
* a value in the map passed to {@link #setWorkingValues(Map)}
* changes. The listener can also be informed about status
* changes.
- *
+ *
* @param modifyListener the listener to inform
*/
public void setModifyListener(IModificationListener modifyListener);
/**
* Create the contents of this tab page.
- *
+ *
* @param parent the parent composite
* @return created content control
*/
public Composite createContents(Composite parent);
/**
- * This is called when the page becomes visible.
+ * This is called when the page becomes visible.
* Common tasks to do include:
* <ul><li>Updating the preview.</li>
* <li>Setting the focus</li>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersioner.java
index e69245e3cc6..51e0087c9d1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersioner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersioner.java
@@ -20,11 +20,11 @@ public interface IProfileVersioner {
public int getFirstVersion();
public int getCurrentVersion();
-
- public String getProfileKind();
+
+ public String getProfileKind();
/**
- * Update the <code>profile</code> to the
+ * Update the <code>profile</code> to the
* current version number
*/
public void update(CustomProfile profile);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java
index d93c62ffd27..58239d5d012 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java
@@ -28,60 +28,59 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
public class IndentationTabPage extends FormatterTabPage {
-
+
/**
* Some C++ source code used for preview.
*/
- private final static String PREVIEW=
- createPreviewHeader(FormatterMessages.IndentationTabPage_preview_header) +
- "#include <math.h>\n\n" + //$NON-NLS-1$
- "class Point {" + //$NON-NLS-1$
- "public:" + //$NON-NLS-1$
- "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "double distance(const Point& other) const;" + //$NON-NLS-1$
- "int compareX(const Point& other) const;" + //$NON-NLS-1$
- "double x;" + //$NON-NLS-1$
- "double y;" + //$NON-NLS-1$
- "};" + //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
- "double dx = x - other.x;" + //$NON-NLS-1$
- "double dy = y - other.y;" + //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "int Point::compareX(const Point& other) const {" + //$NON-NLS-1$
- "if(x < other.x) {" + //$NON-NLS-1$
- "return -1;" + //$NON-NLS-1$
- "} else if(x > other.x){" + //$NON-NLS-1$
- "return 1;" + //$NON-NLS-1$
- "} else {" + //$NON-NLS-1$
- "return 0;" + //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "\n\n" + //$NON-NLS-1$
- "namespace FOO {"+ //$NON-NLS-1$
- "int foo(int bar) const {" + //$NON-NLS-1$
- "switch(bar) {" + //$NON-NLS-1$
- "case 0:" + //$NON-NLS-1$
- "++bar;" + //$NON-NLS-1$
- "break;" + //$NON-NLS-1$
- "case 1:" + //$NON-NLS-1$
- "--bar;" + //$NON-NLS-1$
- "default: {" + //$NON-NLS-1$
- "bar += bar;" + //$NON-NLS-1$
- "break;" + //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "}"+ //$NON-NLS-1$
- "} // end namespace FOO"; //$NON-NLS-1$
+ private final static String PREVIEW = createPreviewHeader(FormatterMessages.IndentationTabPage_preview_header)
+ + "#include <math.h>\n\n" + //$NON-NLS-1$
+ "class Point {" + //$NON-NLS-1$
+ "public:" + //$NON-NLS-1$
+ "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "double distance(const Point& other) const;" + //$NON-NLS-1$
+ "int compareX(const Point& other) const;" + //$NON-NLS-1$
+ "double x;" + //$NON-NLS-1$
+ "double y;" + //$NON-NLS-1$
+ "};" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
+ "double dx = x - other.x;" + //$NON-NLS-1$
+ "double dy = y - other.y;" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "int Point::compareX(const Point& other) const {" + //$NON-NLS-1$
+ "if(x < other.x) {" + //$NON-NLS-1$
+ "return -1;" + //$NON-NLS-1$
+ "} else if(x > other.x){" + //$NON-NLS-1$
+ "return 1;" + //$NON-NLS-1$
+ "} else {" + //$NON-NLS-1$
+ "return 0;" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "\n\n" + //$NON-NLS-1$
+ "namespace FOO {" + //$NON-NLS-1$
+ "int foo(int bar) const {" + //$NON-NLS-1$
+ "switch(bar) {" + //$NON-NLS-1$
+ "case 0:" + //$NON-NLS-1$
+ "++bar;" + //$NON-NLS-1$
+ "break;" + //$NON-NLS-1$
+ "case 1:" + //$NON-NLS-1$
+ "--bar;" + //$NON-NLS-1$
+ "default: {" + //$NON-NLS-1$
+ "bar += bar;" + //$NON-NLS-1$
+ "break;" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "}" + //$NON-NLS-1$
+ "} // end namespace FOO"; //$NON-NLS-1$
private TranslationUnitPreview fPreview;
- private String fOldTabChar= null;
-
- public IndentationTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
+ private String fOldTabChar = null;
+
+ public IndentationTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
super(modifyDialog, workingValues);
}
@@ -91,20 +90,29 @@ public class IndentationTabPage extends FormatterTabPage {
@Override
protected void doCreatePreferences(Composite composite, int numColumns) {
- final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_general_group_title);
-
- final String[] tabPolicyValues= new String[] {CCorePlugin.SPACE, CCorePlugin.TAB, DefaultCodeFormatterConstants.MIXED};
- final String[] tabPolicyLabels= new String[] {
- FormatterMessages.IndentationTabPage_general_group_option_tab_policy_SPACE,
- FormatterMessages.IndentationTabPage_general_group_option_tab_policy_TAB,
- FormatterMessages.IndentationTabPage_general_group_option_tab_policy_MIXED
- };
- final ComboPreference tabPolicy= createComboPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_policy, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, tabPolicyValues, tabPolicyLabels);
- final CheckboxPreference onlyForLeading= createCheckboxPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_use_tabs_only_for_leading_indentations, DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, FALSE_TRUE);
- final NumberPreference indentSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_indent_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
- final NumberPreference tabSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
-
- String tabchar= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+ final Group generalGroup = createGroup(numColumns, composite,
+ FormatterMessages.IndentationTabPage_general_group_title);
+
+ final String[] tabPolicyValues = new String[] { CCorePlugin.SPACE, CCorePlugin.TAB,
+ DefaultCodeFormatterConstants.MIXED };
+ final String[] tabPolicyLabels = new String[] {
+ FormatterMessages.IndentationTabPage_general_group_option_tab_policy_SPACE,
+ FormatterMessages.IndentationTabPage_general_group_option_tab_policy_TAB,
+ FormatterMessages.IndentationTabPage_general_group_option_tab_policy_MIXED };
+ final ComboPreference tabPolicy = createComboPref(generalGroup, numColumns,
+ FormatterMessages.IndentationTabPage_general_group_option_tab_policy,
+ DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, tabPolicyValues, tabPolicyLabels);
+ final CheckboxPreference onlyForLeading = createCheckboxPref(generalGroup, numColumns,
+ FormatterMessages.IndentationTabPage_use_tabs_only_for_leading_indentations,
+ DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, FALSE_TRUE);
+ final NumberPreference indentSize = createNumberPref(generalGroup, numColumns,
+ FormatterMessages.IndentationTabPage_general_group_option_indent_size,
+ DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
+ final NumberPreference tabSize = createNumberPref(generalGroup, numColumns,
+ FormatterMessages.IndentationTabPage_general_group_option_tab_size,
+ DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
+
+ String tabchar = fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
updateTabPreferences(tabchar, tabSize, indentSize, onlyForLeading);
tabPolicy.addObserver(new Observer() {
@Override
@@ -118,60 +126,81 @@ public class IndentationTabPage extends FormatterTabPage {
indentSize.updateWidget();
}
});
-
-// final Group typeMemberGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_field_alignment_group_title);
-// createCheckboxPref(typeMemberGroup, numColumns, FormatterMessages.IndentationTabPage_field_alignment_group_align_fields_in_columns, DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, FALSE_TRUE);
-
- final Group classGroup = createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_indent_group_title);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_block, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, FALSE_TRUE);
+ // final Group typeMemberGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_field_alignment_group_title);
+ // createCheckboxPref(typeMemberGroup, numColumns, FormatterMessages.IndentationTabPage_field_alignment_group_align_fields_in_columns, DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_switch_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_case_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_break_statements, DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, FALSE_TRUE);
+ final Group classGroup = createGroup(numColumns, composite,
+ FormatterMessages.IndentationTabPage_indent_group_title);
+ createCheckboxPref(classGroup, numColumns,
+ FormatterMessages.IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, FALSE_TRUE);
+ createCheckboxPref(classGroup, numColumns,
+ FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER,
+ FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_namespace_group_option_indent_declarations_within_namespace, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_NAMESPACE_HEADER, FALSE_TRUE);
+ createCheckboxPref(classGroup, numColumns,
+ FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_body,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, FALSE_TRUE);
+ createCheckboxPref(classGroup, numColumns,
+ FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_block,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, FALSE_TRUE);
- createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_indent_empty_lines, DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, FALSE_TRUE);
+ createCheckboxPref(classGroup, numColumns,
+ FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_switch_body,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, FALSE_TRUE);
+ createCheckboxPref(classGroup, numColumns,
+ FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_case_body,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, FALSE_TRUE);
+ createCheckboxPref(classGroup, numColumns,
+ FormatterMessages.IndentationTabPage_switch_group_option_indent_break_statements,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, FALSE_TRUE);
+
+ createCheckboxPref(classGroup, numColumns,
+ FormatterMessages.IndentationTabPage_namespace_group_option_indent_declarations_within_namespace,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_NAMESPACE_HEADER,
+ FALSE_TRUE);
+
+ createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_indent_empty_lines,
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, FALSE_TRUE);
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#initializePage()
*/
@Override
public void initializePage() {
- fPreview.setPreviewText(PREVIEW);
+ fPreview.setPreviewText(PREVIEW);
}
- /*
- * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
- */
- @Override
+ /*
+ * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
protected CPreview doCreateCPreview(Composite parent) {
- fPreview= new TranslationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
- /*
- * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
- */
- @Override
+ fPreview = new TranslationUnitPreview(fWorkingValues, parent);
+ return fPreview;
+ }
+
+ /*
+ * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
+ */
+ @Override
protected void doUpdatePreview() {
- fPreview.update();
- }
+ fPreview.update();
+ }
- private void updateTabPreferences(String tabPolicy, NumberPreference tabPreference, NumberPreference indentPreference, CheckboxPreference onlyForLeading) {
+ private void updateTabPreferences(String tabPolicy, NumberPreference tabPreference,
+ NumberPreference indentPreference, CheckboxPreference onlyForLeading) {
/*
* If the tab-char is SPACE (or TAB), INDENTATION_SIZE
* preference is not used by the core formatter. We piggy back the
* visual tab length setting in that preference in that case. If the
* user selects MIXED, we use the previous TAB_SIZE preference as the
- * new INDENTATION_SIZE (as this is what it really is) and set the
+ * new INDENTATION_SIZE (as this is what it really is) and set the
* visual tab size to the value piggy backed in the INDENTATION_SIZE
- * preference. See also CodeFormatterUtil.
+ * preference. See also CodeFormatterUtil.
*/
if (DefaultCodeFormatterConstants.MIXED.equals(tabPolicy)) {
if (CCorePlugin.SPACE.equals(fOldTabChar) || CCorePlugin.TAB.equals(fOldTabChar))
@@ -200,12 +229,12 @@ public class IndentationTabPage extends FormatterTabPage {
} else {
Assert.isTrue(false);
}
- fOldTabChar= tabPolicy;
+ fOldTabChar = tabPolicy;
}
private void swapTabValues() {
- String tabSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
- String indentSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
+ String tabSize = fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
+ String indentSize = fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, indentSize);
fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, tabSize);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTabPage.java
index a8a579aa5a1..40c62a997d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTabPage.java
@@ -58,9 +58,9 @@ import org.eclipse.cdt.internal.corext.util.Messages;
* The line wrapping tab page.
*/
public class LineWrappingTabPage extends FormatterTabPage {
- /**
- * Represents a line wrapping category.
- */
+ /**
+ * Represents a line wrapping category.
+ */
private final static class Category {
public final String key;
public final String name;
@@ -72,514 +72,493 @@ public class LineWrappingTabPage extends FormatterTabPage {
public int index;
public Category(String key, String prologue, String previewText, String name, String description) {
- this.key= key;
- this.name= name;
+ this.key = key;
+ this.name = name;
this.prologue = prologue;
- this.previewText= previewText != null ? createPreviewHeader(name) + previewText : null;
+ this.previewText = previewText != null ? createPreviewHeader(name) + previewText : null;
this.description = description;
- children= new ArrayList<Category>();
+ children = new ArrayList<Category>();
}
-
+
public Category(String key, String previewText, String name, String description) {
this(key, null, previewText, name, description);
}
-
+
/**
* @param name Category name
*/
public Category(String name, String description) {
- this(null, null, name, description);
+ this(null, null, name, description);
}
-
+
@Override
public String toString() {
return name;
}
}
-
- private final static String PREF_CATEGORY_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.line_wrapping_tab_page.last_category_index"; //$NON-NLS-1$
-
+ private final static String PREF_CATEGORY_INDEX = CUIPlugin.PLUGIN_ID
+ + "formatter_page.line_wrapping_tab_page.last_category_index"; //$NON-NLS-1$
+
private final class CategoryListener implements ISelectionChangedListener, IDoubleClickListener {
private final List<Category> fCategoriesList;
- private int fIndex= 0;
-
+ private int fIndex = 0;
+
public CategoryListener(List<Category> categoriesTree) {
- fCategoriesList= new ArrayList<Category>();
+ fCategoriesList = new ArrayList<Category>();
flatten(fCategoriesList, categoriesTree);
}
-
+
private void flatten(List<Category> categoriesList, List<Category> categoriesTree) {
for (Category category2 : categoriesTree) {
- final Category category= category2;
- category.index= fIndex++;
+ final Category category = category2;
+ category.index = fIndex++;
categoriesList.add(category);
flatten(categoriesList, category.children);
- }
+ }
}
-// public void add(Category category) {
-// category.index= fIndex++;
-// fCategoriesList.add(category);
-// }
+ // public void add(Category category) {
+ // category.index= fIndex++;
+ // fCategoriesList.add(category);
+ // }
@Override
public void selectionChanged(SelectionChangedEvent event) {
- if (event != null)
- fSelection= (IStructuredSelection)event.getSelection();
-
- if (fSelection.size() == 0) {
- disableAll();
- return;
- }
-
- if (!fOptionsGroup.isEnabled())
- enableDefaultComponents(true);
-
- fSelectionState.refreshState(fSelection);
-
- final Category category= (Category) fSelection.getFirstElement();
+ if (event != null)
+ fSelection = (IStructuredSelection) event.getSelection();
+
+ if (fSelection.size() == 0) {
+ disableAll();
+ return;
+ }
+
+ if (!fOptionsGroup.isEnabled())
+ enableDefaultComponents(true);
+
+ fSelectionState.refreshState(fSelection);
+
+ final Category category = (Category) fSelection.getFirstElement();
fDialogSettings.put(PREF_CATEGORY_INDEX, category.index);
-
+
fOptionsGroup.setText(getGroupLabel(category));
}
-
+
private String getGroupLabel(Category category) {
- if (fSelection.size() == 1) {
- if (fSelectionState.getElements().size() == 1)
- return NLS.bind(FormatterMessages.LineWrappingTabPage_group, category.description);
- return NLS.bind(FormatterMessages.LineWrappingTabPage_multi_group, category.description,
- String.valueOf(fSelectionState.getElements().size()));
- }
+ if (fSelection.size() == 1) {
+ if (fSelectionState.getElements().size() == 1)
+ return NLS.bind(FormatterMessages.LineWrappingTabPage_group, category.description);
+ return NLS.bind(FormatterMessages.LineWrappingTabPage_multi_group, category.description,
+ String.valueOf(fSelectionState.getElements().size()));
+ }
return NLS.bind(FormatterMessages.LineWrappingTabPage_multiple_selections,
- String.valueOf(fSelectionState.getElements().size()));
+ String.valueOf(fSelectionState.getElements().size()));
}
-
- private void disableAll() {
- enableDefaultComponents(false);
- fIndentStyleCombo.setEnabled(false);
- fForceSplit.setEnabled(false);
- }
-
- private void enableDefaultComponents(boolean enabled) {
- fOptionsGroup.setEnabled(enabled);
- fWrappingStyleCombo.setEnabled(enabled);
- fWrappingStylePolicy.setEnabled(enabled);
- }
-
- public void restoreSelection() {
+
+ private void disableAll() {
+ enableDefaultComponents(false);
+ fIndentStyleCombo.setEnabled(false);
+ fForceSplit.setEnabled(false);
+ }
+
+ private void enableDefaultComponents(boolean enabled) {
+ fOptionsGroup.setEnabled(enabled);
+ fWrappingStyleCombo.setEnabled(enabled);
+ fWrappingStylePolicy.setEnabled(enabled);
+ }
+
+ public void restoreSelection() {
int index;
try {
- index= fDialogSettings.getInt(PREF_CATEGORY_INDEX);
+ index = fDialogSettings.getInt(PREF_CATEGORY_INDEX);
} catch (NumberFormatException e) {
- index= -1;
+ index = -1;
}
if (index < 0 || index > fCategoriesList.size() - 1) {
- index= 1; // In order to select a category with preview initially
+ index = 1; // In order to select a category with preview initially
}
- final Category category= fCategoriesList.get(index);
+ final Category category = fCategoriesList.get(index);
fCategoriesViewer.setSelection(new StructuredSelection(new Category[] { category }));
}
- @Override
+ @Override
public void doubleClick(DoubleClickEvent event) {
- final ISelection selection= event.getSelection();
- if (selection instanceof IStructuredSelection) {
- final Category node= (Category)((IStructuredSelection)selection).getFirstElement();
- fCategoriesViewer.setExpandedState(node, !fCategoriesViewer.getExpandedState(node));
- }
- }
+ final ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ final Category node = (Category) ((IStructuredSelection) selection).getFirstElement();
+ fCategoriesViewer.setExpandedState(node, !fCategoriesViewer.getExpandedState(node));
+ }
+ }
}
-
+
private class SelectionState {
- private List<Category> fElements= new ArrayList<Category>();
-
- public void refreshState(IStructuredSelection selection) {
- Map<Object, Integer> wrappingStyleMap= new HashMap<Object, Integer>();
- Map<Object, Integer> indentStyleMap= new HashMap<Object, Integer>();
- Map<Object, Integer> forceWrappingMap= new HashMap<Object, Integer>();
- fElements.clear();
- evaluateElements(selection.iterator());
- evaluateMaps(wrappingStyleMap, indentStyleMap, forceWrappingMap);
- evaluatePreviewText();
- refreshControls(wrappingStyleMap, indentStyleMap, forceWrappingMap);
- }
-
- public List<Category> getElements() {
- return fElements;
- }
-
- private void evaluateElements(Iterator<?> iterator) {
- Category category;
- String value;
- while (iterator.hasNext()) {
- Object next= iterator.next();
- if (next instanceof Category) {
- category= (Category) next;
- value= fWorkingValues.get(category.key);
- if (value != null) {
- if (!fElements.contains(category))
- fElements.add(category);
- } else {
- evaluateElements(category.children.iterator());
- }
- }
- }
- }
-
- private void evaluateMaps(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap,
- Map<Object, Integer> forceWrappingMap) {
- for (Category category : fElements) {
- insertIntoMap(wrappingStyleMap, indentStyleMap, forceWrappingMap, category);
- }
- }
-
+ private List<Category> fElements = new ArrayList<Category>();
+
+ public void refreshState(IStructuredSelection selection) {
+ Map<Object, Integer> wrappingStyleMap = new HashMap<Object, Integer>();
+ Map<Object, Integer> indentStyleMap = new HashMap<Object, Integer>();
+ Map<Object, Integer> forceWrappingMap = new HashMap<Object, Integer>();
+ fElements.clear();
+ evaluateElements(selection.iterator());
+ evaluateMaps(wrappingStyleMap, indentStyleMap, forceWrappingMap);
+ evaluatePreviewText();
+ refreshControls(wrappingStyleMap, indentStyleMap, forceWrappingMap);
+ }
+
+ public List<Category> getElements() {
+ return fElements;
+ }
+
+ private void evaluateElements(Iterator<?> iterator) {
+ Category category;
+ String value;
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Category) {
+ category = (Category) next;
+ value = fWorkingValues.get(category.key);
+ if (value != null) {
+ if (!fElements.contains(category))
+ fElements.add(category);
+ } else {
+ evaluateElements(category.children.iterator());
+ }
+ }
+ }
+ }
+
+ private void evaluateMaps(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap,
+ Map<Object, Integer> forceWrappingMap) {
+ for (Category category : fElements) {
+ insertIntoMap(wrappingStyleMap, indentStyleMap, forceWrappingMap, category);
+ }
+ }
+
private void evaluatePreviewText() {
StringBuilder previewText = new StringBuilder();
- for (Category category : fElements) {
- if (category.prologue != null) {
- previewText.append(category.prologue);
- previewText.append("\n\n"); //$NON-NLS-1$
- }
- }
- int offset = previewText.length();
- for (Category category : fElements) {
- previewText.append(category.previewText);
- previewText.append("\n\n"); //$NON-NLS-1$
- }
- setPreviewText(previewText.toString(), offset);
+ for (Category category : fElements) {
+ if (category.prologue != null) {
+ previewText.append(category.prologue);
+ previewText.append("\n\n"); //$NON-NLS-1$
+ }
+ }
+ int offset = previewText.length();
+ for (Category category : fElements) {
+ previewText.append(category.previewText);
+ previewText.append("\n\n"); //$NON-NLS-1$
+ }
+ setPreviewText(previewText.toString(), offset);
}
-
- private void insertIntoMap(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap,
- Map<Object, Integer> forceMap, Category category) {
- final String value= fWorkingValues.get(category.key);
- Integer wrappingStyle;
- Integer indentStyle;
- Boolean forceWrapping;
-
- try {
- wrappingStyle= Integer.valueOf(DefaultCodeFormatterConstants.getWrappingStyle(value));
- indentStyle= Integer.valueOf(DefaultCodeFormatterConstants.getIndentStyle(value));
- forceWrapping= Boolean.valueOf(DefaultCodeFormatterConstants.getForceWrapping(value));
- } catch (IllegalArgumentException e) {
- forceWrapping= Boolean.FALSE;
- indentStyle= Integer.valueOf(DefaultCodeFormatterConstants.INDENT_DEFAULT);
- wrappingStyle= Integer.valueOf(DefaultCodeFormatterConstants.WRAP_NO_SPLIT);
- }
-
- increaseMapEntry(wrappingMap, wrappingStyle);
- increaseMapEntry(indentMap, indentStyle);
- increaseMapEntry(forceMap, forceWrapping);
- }
-
- private void increaseMapEntry(Map<Object, Integer> map, Object type) {
- Integer count= map.get(type);
- if (count == null) // not in map yet -> count == 0
- map.put(type, Integer.valueOf(1));
- else
- map.put(type, Integer.valueOf(count.intValue() + 1));
- }
-
- private void refreshControls(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap,
- Map<Object, Integer> forceWrappingMap) {
- updateCombos(wrappingStyleMap, indentStyleMap);
- updateButton(forceWrappingMap);
- Integer wrappingStyleMax= getWrappingStyleMax(wrappingStyleMap);
- boolean isInhomogeneous= (fElements.size() != wrappingStyleMap.get(wrappingStyleMax).intValue());
+
+ private void insertIntoMap(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap,
+ Map<Object, Integer> forceMap, Category category) {
+ final String value = fWorkingValues.get(category.key);
+ Integer wrappingStyle;
+ Integer indentStyle;
+ Boolean forceWrapping;
+
+ try {
+ wrappingStyle = Integer.valueOf(DefaultCodeFormatterConstants.getWrappingStyle(value));
+ indentStyle = Integer.valueOf(DefaultCodeFormatterConstants.getIndentStyle(value));
+ forceWrapping = Boolean.valueOf(DefaultCodeFormatterConstants.getForceWrapping(value));
+ } catch (IllegalArgumentException e) {
+ forceWrapping = Boolean.FALSE;
+ indentStyle = Integer.valueOf(DefaultCodeFormatterConstants.INDENT_DEFAULT);
+ wrappingStyle = Integer.valueOf(DefaultCodeFormatterConstants.WRAP_NO_SPLIT);
+ }
+
+ increaseMapEntry(wrappingMap, wrappingStyle);
+ increaseMapEntry(indentMap, indentStyle);
+ increaseMapEntry(forceMap, forceWrapping);
+ }
+
+ private void increaseMapEntry(Map<Object, Integer> map, Object type) {
+ Integer count = map.get(type);
+ if (count == null) // not in map yet -> count == 0
+ map.put(type, Integer.valueOf(1));
+ else
+ map.put(type, Integer.valueOf(count.intValue() + 1));
+ }
+
+ private void refreshControls(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap,
+ Map<Object, Integer> forceWrappingMap) {
+ updateCombos(wrappingStyleMap, indentStyleMap);
+ updateButton(forceWrappingMap);
+ Integer wrappingStyleMax = getWrappingStyleMax(wrappingStyleMap);
+ boolean isInhomogeneous = (fElements.size() != wrappingStyleMap.get(wrappingStyleMax).intValue());
updateControlEnablement(isInhomogeneous, wrappingStyleMax.intValue());
- doUpdatePreview();
+ doUpdatePreview();
notifyValuesModified();
- }
-
- private Integer getWrappingStyleMax(Map<Object, Integer> wrappingStyleMap) {
- int maxCount= 0, maxStyle= 0;
- for (int i= 0; i < WRAPPING_NAMES.length; i++) {
- Integer count= wrappingStyleMap.get(Integer.valueOf(i));
- if (count == null)
- continue;
- if (count.intValue() > maxCount) {
- maxCount= count.intValue();
- maxStyle= i;
- }
- }
- return Integer.valueOf(maxStyle);
- }
-
- private void updateButton(Map<Object, Integer> forceWrappingMap) {
- Integer nrOfTrue= forceWrappingMap.get(Boolean.TRUE);
- Integer nrOfFalse= forceWrappingMap.get(Boolean.FALSE);
-
- if (nrOfTrue == null || nrOfFalse == null)
- fForceSplit.setSelection(nrOfTrue != null);
- else
- fForceSplit.setSelection(nrOfTrue.intValue() > nrOfFalse.intValue());
-
- int max= getMax(nrOfTrue, nrOfFalse);
- String label= FormatterMessages.LineWrappingTabPage_force_split_checkbox_multi_text;
- fForceSplit.setText(getLabelText(label, max, fElements.size()));
- }
-
- private String getLabelText(String label, int count, int nElements) {
- if (nElements == 1 || count == 0)
- return label;
- return Messages.format(FormatterMessages.LineWrappingTabPage_occurences,
- new String[] {label, String.valueOf(count), String.valueOf(nElements)});
- }
-
- private int getMax(Integer nrOfTrue, Integer nrOfFalse) {
- if (nrOfTrue == null)
- return nrOfFalse.intValue();
- if (nrOfFalse == null)
- return nrOfTrue.intValue();
- if (nrOfTrue.compareTo(nrOfFalse) >= 0)
- return nrOfTrue.intValue();
- return nrOfFalse.intValue();
- }
-
- private void updateCombos(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap) {
- updateCombo(fWrappingStyleCombo, wrappingStyleMap, WRAPPING_NAMES);
- updateCombo(fIndentStyleCombo, indentStyleMap, INDENT_NAMES);
- }
-
- private void updateCombo(Combo combo, Map<Object, Integer> map, final String[] items) {
- String[] newItems= new String[items.length];
- int maxCount= 0, maxStyle= 0;
-
- for(int i = 0; i < items.length; i++) {
- Integer count= map.get(Integer.valueOf(i));
- int val= (count == null) ? 0 : count.intValue();
- if (val > maxCount) {
- maxCount= val;
- maxStyle= i;
- }
- newItems[i]= getLabelText(items[i], val, fElements.size());
- }
- combo.setItems(newItems);
- combo.setText(newItems[maxStyle]);
- }
+ }
+
+ private Integer getWrappingStyleMax(Map<Object, Integer> wrappingStyleMap) {
+ int maxCount = 0, maxStyle = 0;
+ for (int i = 0; i < WRAPPING_NAMES.length; i++) {
+ Integer count = wrappingStyleMap.get(Integer.valueOf(i));
+ if (count == null)
+ continue;
+ if (count.intValue() > maxCount) {
+ maxCount = count.intValue();
+ maxStyle = i;
+ }
+ }
+ return Integer.valueOf(maxStyle);
+ }
+
+ private void updateButton(Map<Object, Integer> forceWrappingMap) {
+ Integer nrOfTrue = forceWrappingMap.get(Boolean.TRUE);
+ Integer nrOfFalse = forceWrappingMap.get(Boolean.FALSE);
+
+ if (nrOfTrue == null || nrOfFalse == null)
+ fForceSplit.setSelection(nrOfTrue != null);
+ else
+ fForceSplit.setSelection(nrOfTrue.intValue() > nrOfFalse.intValue());
+
+ int max = getMax(nrOfTrue, nrOfFalse);
+ String label = FormatterMessages.LineWrappingTabPage_force_split_checkbox_multi_text;
+ fForceSplit.setText(getLabelText(label, max, fElements.size()));
+ }
+
+ private String getLabelText(String label, int count, int nElements) {
+ if (nElements == 1 || count == 0)
+ return label;
+ return Messages.format(FormatterMessages.LineWrappingTabPage_occurences,
+ new String[] { label, String.valueOf(count), String.valueOf(nElements) });
+ }
+
+ private int getMax(Integer nrOfTrue, Integer nrOfFalse) {
+ if (nrOfTrue == null)
+ return nrOfFalse.intValue();
+ if (nrOfFalse == null)
+ return nrOfTrue.intValue();
+ if (nrOfTrue.compareTo(nrOfFalse) >= 0)
+ return nrOfTrue.intValue();
+ return nrOfFalse.intValue();
+ }
+
+ private void updateCombos(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap) {
+ updateCombo(fWrappingStyleCombo, wrappingStyleMap, WRAPPING_NAMES);
+ updateCombo(fIndentStyleCombo, indentStyleMap, INDENT_NAMES);
+ }
+
+ private void updateCombo(Combo combo, Map<Object, Integer> map, final String[] items) {
+ String[] newItems = new String[items.length];
+ int maxCount = 0, maxStyle = 0;
+
+ for (int i = 0; i < items.length; i++) {
+ Integer count = map.get(Integer.valueOf(i));
+ int val = (count == null) ? 0 : count.intValue();
+ if (val > maxCount) {
+ maxCount = val;
+ maxStyle = i;
+ }
+ newItems[i] = getLabelText(items[i], val, fElements.size());
+ }
+ combo.setItems(newItems);
+ combo.setText(newItems[maxStyle]);
+ }
}
-
- protected static final String[] INDENT_NAMES = {
- FormatterMessages.LineWrappingTabPage_indentation_default,
- FormatterMessages.LineWrappingTabPage_indentation_on_column,
- FormatterMessages.LineWrappingTabPage_indentation_by_one
- };
-
- protected static final String[] WRAPPING_NAMES = {
- FormatterMessages.LineWrappingTabPage_splitting_do_not_split,
- FormatterMessages.LineWrappingTabPage_splitting_wrap_when_necessary, // COMPACT_SPLIT
- FormatterMessages.LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary, // COMPACT_FIRST_BREAK_SPLIT
- FormatterMessages.LineWrappingTabPage_splitting_wrap_always, // ONE_PER_LINE_SPLIT
- FormatterMessages.LineWrappingTabPage_splitting_wrap_always_indent_all_but_first, // NEXT_SHIFTED_SPLIT
- FormatterMessages.LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary
- };
-
-// private final Category fCompactIfCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF,
-// "int foo(int argument) {" + //$NON-NLS-1$
-// " if (argument==0) return 0;" + //$NON-NLS-1$
-// " if (argument==1) return 42; else return 43;" + //$NON-NLS-1$
-// "}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_compact_if_else,
-// FormatterMessages.LineWrappingTabPage_compact_if_else_lowercase
-// );
-
- private final Category fTypeDeclarationBaseClauseCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION,
- "class Example : public FooClass, virtual protected BarClass {};", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_base_clause,
- FormatterMessages.LineWrappingTabPage_base_clause_lowercase
- );
-
-// private final Category fConstructorDeclarationsParametersCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION,
-// "class Example {Example(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { this();}" + //$NON-NLS-1$
-// "Example() {}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_parameters,
-// FormatterMessages.LineWrappingTabPage_parameters_lowercase
-// );
-
- private final Category fMethodDeclarationsParametersCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
- "class Example {void foo(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) {}};", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_parameters,
- FormatterMessages.LineWrappingTabPage_parameters_lowercase
- );
-
- private final Category fMessageSendArgumentsCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
- "class Other {static void bar(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9) {}};"+ //$NON-NLS-1$
- "void foo() {Other::bar(100, 200, 300, 400, 500, 600, 700, 800, 900);}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_arguments,
- FormatterMessages.LineWrappingTabPage_arguments_lowercase
- );
-
- private final Category fMethodThrowsClauseCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION,
- "class Example {" + //$NON-NLS-1$
- "int foo() throw(FirstException, SecondException, ThirdException) {" + //$NON-NLS-1$
- " return Other::doSomething();}};", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_throws_clause,
- FormatterMessages.LineWrappingTabPage_throws_clause_lowercase
- );
-
- private final Category fConstructorInitializerListCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONSTRUCTOR_INITIALIZER_LIST,
- "class Point {" + //$NON-NLS-1$
- "public:" + //$NON-NLS-1$
- "Point(double x, double y) : x(x), y(y) {" + //$NON-NLS-1$
- "}\n\n" + //$NON-NLS-1$
- "private:" + //$NON-NLS-1$
- "double x;" + //$NON-NLS-1$
- "double y;" + //$NON-NLS-1$
- "};", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_constructor_initializer_list,
- FormatterMessages.LineWrappingTabPage_constructor_initializer_list_lowercase
- );
-
-// private final Category fConstructorThrowsClauseCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION,
-// "class Example {" + //$NON-NLS-1$
-// "Example() throws FirstException, SecondException, ThirdException {" + //$NON-NLS-1$
-// " return Other.doSomething();}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_throws_clause
-// FormatterMessages.LineWrappingTabPage_throws_clause_lowercase
-// );
-
-// private final Category fAllocationExpressionArgumentsCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION,
-// "class Example {SomeClass foo() {return new SomeClass(100, 200, 300, 400, 500, 600, 700, 800, 900 );}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_object_allocation
-// FormatterMessages.LineWrappingTabPage_object_allocation_lowercase
-// );
-
- private final Category fInitializerListExpressionsCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST,
- "int array[]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_initializer_list,
- FormatterMessages.LineWrappingTabPage_initializer_list_lowercase
- );
-
-// private final Category fExplicitConstructorArgumentsCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL,
-// "class Example extends AnotherClass {Example() {super(100, 200, 300, 400, 500, 600, 700);}}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_explicit_constructor_invocations
-// FormatterMessages.LineWrappingTabPage_explicit_constructor_invocations_lowercase
-// );
-
- private final Category fConditionalExpressionCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION,
- "int compare(int argument, int argument2) {return argument > argument2 ? 100000 : 200000;}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_conditionals,
- FormatterMessages.LineWrappingTabPage_conditionals_lowercase
- );
-
- private final Category fBinaryExpressionCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION,
- "int foo() {" + //$NON-NLS-1$
- " int sum= 100 + 200 + 300 + 400 + 500 + 600 + 700 + 800;" + //$NON-NLS-1$
- " int product= 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10;" + //$NON-NLS-1$
- " bool val= true && false && true && false && true;" + //$NON-NLS-1$
- " return product / sum;" + //$NON-NLS-1$
- "}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_binary_exprs,
- FormatterMessages.LineWrappingTabPage_binary_exprs_lowercase
- );
-
- private final Category fMemberAccessExpressionCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MEMBER_ACCESS,
- "class TreeNode {" + //$NON-NLS-1$
- "public:" + //$NON-NLS-1$
- "TreeNode* getParent();" + //$NON-NLS-1$
- "TreeNode* getFirstChild();" + //$NON-NLS-1$
- "};\n\n" + //$NON-NLS-1$
- "TreeNode* firstUncle(TreeNode& node) {" + //$NON-NLS-1$
- "return node.getParent()->getParent()->getFirstChild();" + //$NON-NLS-1$
- "}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_member_access,
- FormatterMessages.LineWrappingTabPage_member_access_lowercase
- );
-
- private final Category fStreamOutputExpressionCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_OVERLOADED_LEFT_SHIFT_CHAIN,
- // Invisible code
- "namespace std {\n" + //$NON-NLS-1$
- "class ostream {\n" + //$NON-NLS-1$
- " ostream& operator<<(int);\n" + //$NON-NLS-1$
- " ostream& operator<<(char);\n" + //$NON-NLS-1$
- " ostream& operator<<(const char*);\n" + //$NON-NLS-1$
- "};\n" + //$NON-NLS-1$
- "int setfill(char);\n" + //$NON-NLS-1$
- "int setw(int);\n" + //$NON-NLS-1$
- "extern char endl;\n" + //$NON-NLS-1$
- "extern ostream cout;\n" + //$NON-NLS-1$
- "}", //$NON-NLS-1$
- // Visible code
- "#include <iostream>\n" + //$NON-NLS-1$
- "#include <iomanip>\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- "using namespace std;\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- "void PrintDate(int year, int month, int day) {" + //$NON-NLS-1$
- "cout << setfill('0') << setw(4) << year << '/' << setw(2) << month" + //$NON-NLS-1$
- " << '/' << setw(2) << day << endl;" + //$NON-NLS-1$
- "}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_stream_output,
- FormatterMessages.LineWrappingTabPage_stream_output_lowercase
- );
-
-// private final Category fEnumConstArgumentsCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT,
-// "enum Example {" + //$NON-NLS-1$
-// "GREEN(0, 255, 0), RED(255, 0, 0) }", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_enum_constant_arguments,
-// FormatterMessages.LineWrappingTabPage_enum_constant_arguments_lowercase
-// );
-
-// private final Category fEnumDeclInterfacesCategory= new Category(
-// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION,
-// "enum Example implements A, B, C {" + //$NON-NLS-1$
-// "}", //$NON-NLS-1$
-// FormatterMessages.LineWrappingTabPage_enum_superinterfaces,
-// FormatterMessages.LineWrappingTabPage_enum_superinterfaces_lowercase
-// );
-
- private final Category fEnumeratorsCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUMERATOR_LIST,
- "enum Example {" + //$NON-NLS-1$
- "CANCELLED, RUNNING, WAITING, FINISHED };", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_enumerator_list,
- FormatterMessages.LineWrappingTabPage_enumerator_list_lowercase
- );
-
- private final Category fAssignmentCategory= new Category(
- DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT,
- "static char* string = \"text text text text\";" + //$NON-NLS-1$
- "class Example {" + //$NON-NLS-1$
- "void foo() {" + //$NON-NLS-1$
- "for (int i = 0; i < 10; i++) {}" + //$NON-NLS-1$
- "const char* character_string;" + //$NON-NLS-1$
- "character_string = \"text text text text\";}}", //$NON-NLS-1$
- FormatterMessages.LineWrappingTabPage_assignment_alignment,
- FormatterMessages.LineWrappingTabPage_assignment_alignment_lowercase
- );
+
+ protected static final String[] INDENT_NAMES = { FormatterMessages.LineWrappingTabPage_indentation_default,
+ FormatterMessages.LineWrappingTabPage_indentation_on_column,
+ FormatterMessages.LineWrappingTabPage_indentation_by_one };
+
+ protected static final String[] WRAPPING_NAMES = { FormatterMessages.LineWrappingTabPage_splitting_do_not_split,
+ FormatterMessages.LineWrappingTabPage_splitting_wrap_when_necessary, // COMPACT_SPLIT
+ FormatterMessages.LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary, // COMPACT_FIRST_BREAK_SPLIT
+ FormatterMessages.LineWrappingTabPage_splitting_wrap_always, // ONE_PER_LINE_SPLIT
+ FormatterMessages.LineWrappingTabPage_splitting_wrap_always_indent_all_but_first, // NEXT_SHIFTED_SPLIT
+ FormatterMessages.LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary };
+
+ // private final Category fCompactIfCategory= new Category(
+ // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF,
+ // "int foo(int argument) {" + //$NON-NLS-1$
+ // " if (argument==0) return 0;" + //$NON-NLS-1$
+ // " if (argument==1) return 42; else return 43;" + //$NON-NLS-1$
+ // "}", //$NON-NLS-1$
+ // FormatterMessages.LineWrappingTabPage_compact_if_else,
+ // FormatterMessages.LineWrappingTabPage_compact_if_else_lowercase
+ // );
+
+ private final Category fTypeDeclarationBaseClauseCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION,
+ "class Example : public FooClass, virtual protected BarClass {};", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_base_clause,
+ FormatterMessages.LineWrappingTabPage_base_clause_lowercase);
+
+ // private final Category fConstructorDeclarationsParametersCategory= new Category(
+ // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION,
+ // "class Example {Example(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { this();}" + //$NON-NLS-1$
+ // "Example() {}}", //$NON-NLS-1$
+ // FormatterMessages.LineWrappingTabPage_parameters,
+ // FormatterMessages.LineWrappingTabPage_parameters_lowercase
+ // );
+
+ private final Category fMethodDeclarationsParametersCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
+ "class Example {void foo(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) {}};", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_parameters,
+ FormatterMessages.LineWrappingTabPage_parameters_lowercase);
+
+ private final Category fMessageSendArgumentsCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
+ "class Other {static void bar(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9) {}};" //$NON-NLS-1$
+ + "void foo() {Other::bar(100, 200, 300, 400, 500, 600, 700, 800, 900);}",
+ FormatterMessages.LineWrappingTabPage_arguments, FormatterMessages.LineWrappingTabPage_arguments_lowercase);
+
+ private final Category fMethodThrowsClauseCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION,
+ "class Example {" + //$NON-NLS-1$
+ "int foo() throw(FirstException, SecondException, ThirdException) {" + //$NON-NLS-1$
+ " return Other::doSomething();}};", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_throws_clause,
+ FormatterMessages.LineWrappingTabPage_throws_clause_lowercase);
+
+ private final Category fConstructorInitializerListCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONSTRUCTOR_INITIALIZER_LIST, "class Point {" + //$NON-NLS-1$
+ "public:" + //$NON-NLS-1$
+ "Point(double x, double y) : x(x), y(y) {" + //$NON-NLS-1$
+ "}\n\n" + //$NON-NLS-1$
+ "private:" + //$NON-NLS-1$
+ "double x;" + //$NON-NLS-1$
+ "double y;" + //$NON-NLS-1$
+ "};", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_constructor_initializer_list,
+ FormatterMessages.LineWrappingTabPage_constructor_initializer_list_lowercase);
+
+ // private final Category fConstructorThrowsClauseCategory= new Category(
+ // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION,
+ // "class Example {" + //$NON-NLS-1$
+ // "Example() throws FirstException, SecondException, ThirdException {" + //$NON-NLS-1$
+ // " return Other.doSomething();}}", //$NON-NLS-1$
+ // FormatterMessages.LineWrappingTabPage_throws_clause
+ // FormatterMessages.LineWrappingTabPage_throws_clause_lowercase
+ // );
+
+ // private final Category fAllocationExpressionArgumentsCategory= new Category(
+ // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION,
+ // "class Example {SomeClass foo() {return new SomeClass(100, 200, 300, 400, 500, 600, 700, 800, 900 );}}", //$NON-NLS-1$
+ // FormatterMessages.LineWrappingTabPage_object_allocation
+ // FormatterMessages.LineWrappingTabPage_object_allocation_lowercase
+ // );
+
+ private final Category fInitializerListExpressionsCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST,
+ "int array[]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_initializer_list,
+ FormatterMessages.LineWrappingTabPage_initializer_list_lowercase);
+
+ // private final Category fExplicitConstructorArgumentsCategory= new Category(
+ // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL,
+ // "class Example extends AnotherClass {Example() {super(100, 200, 300, 400, 500, 600, 700);}}", //$NON-NLS-1$
+ // FormatterMessages.LineWrappingTabPage_explicit_constructor_invocations
+ // FormatterMessages.LineWrappingTabPage_explicit_constructor_invocations_lowercase
+ // );
+
+ private final Category fConditionalExpressionCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION,
+ "int compare(int argument, int argument2) {return argument > argument2 ? 100000 : 200000;}", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_conditionals,
+ FormatterMessages.LineWrappingTabPage_conditionals_lowercase);
+
+ private final Category fBinaryExpressionCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, "int foo() {" + //$NON-NLS-1$
+ " int sum= 100 + 200 + 300 + 400 + 500 + 600 + 700 + 800;" + //$NON-NLS-1$
+ " int product= 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10;" + //$NON-NLS-1$
+ " bool val= true && false && true && false && true;" + //$NON-NLS-1$
+ " return product / sum;" + //$NON-NLS-1$
+ "}", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_binary_exprs,
+ FormatterMessages.LineWrappingTabPage_binary_exprs_lowercase);
+
+ private final Category fMemberAccessExpressionCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MEMBER_ACCESS, "class TreeNode {" + //$NON-NLS-1$
+ "public:" + //$NON-NLS-1$
+ "TreeNode* getParent();" + //$NON-NLS-1$
+ "TreeNode* getFirstChild();" + //$NON-NLS-1$
+ "};\n\n" + //$NON-NLS-1$
+ "TreeNode* firstUncle(TreeNode& node) {" + //$NON-NLS-1$
+ "return node.getParent()->getParent()->getFirstChild();" + //$NON-NLS-1$
+ "}", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_member_access,
+ FormatterMessages.LineWrappingTabPage_member_access_lowercase);
+
+ private final Category fStreamOutputExpressionCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_OVERLOADED_LEFT_SHIFT_CHAIN,
+ // Invisible code
+ "namespace std {\n" + //$NON-NLS-1$
+ "class ostream {\n" + //$NON-NLS-1$
+ " ostream& operator<<(int);\n" + //$NON-NLS-1$
+ " ostream& operator<<(char);\n" + //$NON-NLS-1$
+ " ostream& operator<<(const char*);\n" + //$NON-NLS-1$
+ "};\n" + //$NON-NLS-1$
+ "int setfill(char);\n" + //$NON-NLS-1$
+ "int setw(int);\n" + //$NON-NLS-1$
+ "extern char endl;\n" + //$NON-NLS-1$
+ "extern ostream cout;\n" + //$NON-NLS-1$
+ "}", //$NON-NLS-1$
+ // Visible code
+ "#include <iostream>\n" + //$NON-NLS-1$
+ "#include <iomanip>\n" + //$NON-NLS-1$
+ "\n" + //$NON-NLS-1$
+ "using namespace std;\n" + //$NON-NLS-1$
+ "\n" + //$NON-NLS-1$
+ "void PrintDate(int year, int month, int day) {" + //$NON-NLS-1$
+ "cout << setfill('0') << setw(4) << year << '/' << setw(2) << month" + //$NON-NLS-1$
+ " << '/' << setw(2) << day << endl;" + //$NON-NLS-1$
+ "}", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_stream_output,
+ FormatterMessages.LineWrappingTabPage_stream_output_lowercase);
+
+ // private final Category fEnumConstArgumentsCategory= new Category(
+ // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT,
+ // "enum Example {" + //$NON-NLS-1$
+ // "GREEN(0, 255, 0), RED(255, 0, 0) }", //$NON-NLS-1$
+ // FormatterMessages.LineWrappingTabPage_enum_constant_arguments,
+ // FormatterMessages.LineWrappingTabPage_enum_constant_arguments_lowercase
+ // );
+
+ // private final Category fEnumDeclInterfacesCategory= new Category(
+ // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION,
+ // "enum Example implements A, B, C {" + //$NON-NLS-1$
+ // "}", //$NON-NLS-1$
+ // FormatterMessages.LineWrappingTabPage_enum_superinterfaces,
+ // FormatterMessages.LineWrappingTabPage_enum_superinterfaces_lowercase
+ // );
+
+ private final Category fEnumeratorsCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUMERATOR_LIST, "enum Example {" + //$NON-NLS-1$
+ "CANCELLED, RUNNING, WAITING, FINISHED };", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_enumerator_list,
+ FormatterMessages.LineWrappingTabPage_enumerator_list_lowercase);
+
+ private final Category fAssignmentCategory = new Category(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT,
+ "static char* string = \"text text text text\";" + //$NON-NLS-1$
+ "class Example {" + //$NON-NLS-1$
+ "void foo() {" + //$NON-NLS-1$
+ "for (int i = 0; i < 10; i++) {}" + //$NON-NLS-1$
+ "const char* character_string;" + //$NON-NLS-1$
+ "character_string = \"text text text text\";}}", //$NON-NLS-1$
+ FormatterMessages.LineWrappingTabPage_assignment_alignment,
+ FormatterMessages.LineWrappingTabPage_assignment_alignment_lowercase);
/**
* The default preview line width.
*/
- private static int DEFAULT_PREVIEW_WINDOW_LINE_WIDTH= 40;
-
+ private static int DEFAULT_PREVIEW_WINDOW_LINE_WIDTH = 40;
+
/**
* The key to save the user's preview window width in the dialog settings.
*/
- private static final String PREF_PREVIEW_LINE_WIDTH=
- CUIPlugin.PLUGIN_ID + ".codeformatter.line_wrapping_tab_page.preview_line_width"; //$NON-NLS-1$
-
+ private static final String PREF_PREVIEW_LINE_WIDTH = CUIPlugin.PLUGIN_ID
+ + ".codeformatter.line_wrapping_tab_page.preview_line_width"; //$NON-NLS-1$
+
/**
* The dialog settings.
*/
- protected final IDialogSettings fDialogSettings;
-
+ protected final IDialogSettings fDialogSettings;
+
protected TreeViewer fCategoriesViewer;
protected Label fWrappingStylePolicy;
protected Combo fWrappingStyleCombo;
@@ -596,189 +575,207 @@ public class LineWrappingTabPage extends FormatterTabPage {
* @see TreeViewer
*/
private final List<Category> fCategories;
-
+
/**
* The category listener which makes the selection persistent.
*/
protected final CategoryListener fCategoryListener;
-
+
/**
- * The current selection of elements.
+ * The current selection of elements.
*/
protected IStructuredSelection fSelection;
-
+
/**
* An object containing the state for the UI.
*/
SelectionState fSelectionState;
-
+
/**
* A special options store wherein the preview line width is kept.
*/
- protected final Map<String,String> fPreviewPreferences;
-
+ protected final Map<String, String> fPreviewPreferences;
+
/**
* The key for the preview line width.
*/
- private final String LINE_SPLIT= DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT;
-
+ private final String LINE_SPLIT = DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT;
+
/**
* Create a new line wrapping tab page.
* @param modifyDialog
* @param workingValues
*/
- public LineWrappingTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
+ public LineWrappingTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
super(modifyDialog, workingValues);
- fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
-
- final String previewLineWidth= fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH);
-
- fPreviewPreferences= new HashMap<String, String>();
- fPreviewPreferences.put(LINE_SPLIT, previewLineWidth != null ?
- previewLineWidth : String.valueOf(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH));
-
- fCategories= createCategories();
- fCategoryListener= new CategoryListener(fCategories);
+ fDialogSettings = CUIPlugin.getDefault().getDialogSettings();
+
+ final String previewLineWidth = fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH);
+
+ fPreviewPreferences = new HashMap<String, String>();
+ fPreviewPreferences.put(LINE_SPLIT,
+ previewLineWidth != null ? previewLineWidth : String.valueOf(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH));
+
+ fCategories = createCategories();
+ fCategoryListener = new CategoryListener(fCategories);
}
-
+
/**
* @return Create the categories tree.
*/
protected List<Category> createCategories() {
- final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls,
- FormatterMessages.LineWrappingTabPage_class_decls_lowercase);
+ final Category classDeclarations = new Category(FormatterMessages.LineWrappingTabPage_class_decls,
+ FormatterMessages.LineWrappingTabPage_class_decls_lowercase);
classDeclarations.children.add(fTypeDeclarationBaseClauseCategory);
-
-// final Category constructorDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_constructor_decls);
-// constructorDeclarations.children.add(fConstructorDeclarationsParametersCategory);
-// constructorDeclarations.children.add(fConstructorThrowsClauseCategory);
-// constructorDeclarations.children.add(fConstructorInitializerListCategory);
-
- final Category methodDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_function_decls,
- FormatterMessages.LineWrappingTabPage_function_decls_lowercase);
+
+ // final Category constructorDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_constructor_decls);
+ // constructorDeclarations.children.add(fConstructorDeclarationsParametersCategory);
+ // constructorDeclarations.children.add(fConstructorThrowsClauseCategory);
+ // constructorDeclarations.children.add(fConstructorInitializerListCategory);
+
+ final Category methodDeclarations = new Category(null, null,
+ FormatterMessages.LineWrappingTabPage_function_decls,
+ FormatterMessages.LineWrappingTabPage_function_decls_lowercase);
methodDeclarations.children.add(fMethodDeclarationsParametersCategory);
methodDeclarations.children.add(fMethodThrowsClauseCategory);
methodDeclarations.children.add(fConstructorInitializerListCategory);
- final Category enumDeclarations= new Category(FormatterMessages.LineWrappingTabPage_enum_decls,
- FormatterMessages.LineWrappingTabPage_enum_decls_lowercase);
+ final Category enumDeclarations = new Category(FormatterMessages.LineWrappingTabPage_enum_decls,
+ FormatterMessages.LineWrappingTabPage_enum_decls_lowercase);
enumDeclarations.children.add(fEnumeratorsCategory);
-// enumDeclarations.children.add(fEnumDeclInterfacesCategory);
-// enumDeclarations.children.add(fEnumConstArgumentsCategory);
-
- final Category functionCalls= new Category(FormatterMessages.LineWrappingTabPage_function_calls,
- FormatterMessages.LineWrappingTabPage_function_calls_lowercase);
+ // enumDeclarations.children.add(fEnumDeclInterfacesCategory);
+ // enumDeclarations.children.add(fEnumConstArgumentsCategory);
+
+ final Category functionCalls = new Category(FormatterMessages.LineWrappingTabPage_function_calls,
+ FormatterMessages.LineWrappingTabPage_function_calls_lowercase);
functionCalls.children.add(fMessageSendArgumentsCategory);
-// functionCalls.children.add(fMessageSendSelectorCategory);
-// functionCalls.children.add(fExplicitConstructorArgumentsCategory);
-// functionCalls.children.add(fAllocationExpressionArgumentsCategory);
-// functionCalls.children.add(fQualifiedAllocationExpressionCategory);
-
- final Category expressions= new Category(FormatterMessages.LineWrappingTabPage_expressions,
- FormatterMessages.LineWrappingTabPage_expressions_lowercase);
+ // functionCalls.children.add(fMessageSendSelectorCategory);
+ // functionCalls.children.add(fExplicitConstructorArgumentsCategory);
+ // functionCalls.children.add(fAllocationExpressionArgumentsCategory);
+ // functionCalls.children.add(fQualifiedAllocationExpressionCategory);
+
+ final Category expressions = new Category(FormatterMessages.LineWrappingTabPage_expressions,
+ FormatterMessages.LineWrappingTabPage_expressions_lowercase);
expressions.children.add(fBinaryExpressionCategory);
expressions.children.add(fConditionalExpressionCategory);
expressions.children.add(fAssignmentCategory);
expressions.children.add(fInitializerListExpressionsCategory);
expressions.children.add(fStreamOutputExpressionCategory);
expressions.children.add(fMemberAccessExpressionCategory);
-
-// final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements);
-// statements.children.add(fCompactIfCategory);
-
- final List<Category> root= new ArrayList<Category>();
+
+ // final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements);
+ // statements.children.add(fCompactIfCategory);
+
+ final List<Category> root = new ArrayList<Category>();
root.add(classDeclarations);
-// root.add(constructorDeclarations);
+ // root.add(constructorDeclarations);
root.add(methodDeclarations);
root.add(enumDeclarations);
root.add(functionCalls);
root.add(expressions);
-// root.add(statements);
-
+ // root.add(statements);
+
return root;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreatePreferences(org.eclipse.swt.widgets.Composite, int)
*/
@Override
protected void doCreatePreferences(Composite composite, int numColumns) {
- final Group lineWidthGroup= createGroup(numColumns, composite, FormatterMessages.LineWrappingTabPage_width_indent);
-
- createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_max_line_width, DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, 0, 9999);
- createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_wrapped, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, 9999);
- createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_INITIALIZER_LIST, 0, 9999);
- createCheckboxPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_do_not_join_lines, DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, TRUE_FALSE);
-
- fCategoriesViewer= new TreeViewer(composite /*categoryGroup*/, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL );
+ final Group lineWidthGroup = createGroup(numColumns, composite,
+ FormatterMessages.LineWrappingTabPage_width_indent);
+
+ createNumberPref(lineWidthGroup, numColumns,
+ FormatterMessages.LineWrappingTabPage_width_indent_option_max_line_width,
+ DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, 0, 9999);
+ createNumberPref(lineWidthGroup, numColumns,
+ FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_wrapped,
+ DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, 9999);
+ createNumberPref(lineWidthGroup, numColumns,
+ FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array,
+ DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_INITIALIZER_LIST, 0, 9999);
+ createCheckboxPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_do_not_join_lines,
+ DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, TRUE_FALSE);
+
+ fCategoriesViewer = new TreeViewer(composite /*categoryGroup*/,
+ SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL);
fCategoriesViewer.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
return ((Collection<?>) inputElement).toArray();
}
+
@Override
public Object[] getChildren(Object parentElement) {
return ((Category) parentElement).children.toArray();
}
+
@Override
- public Object getParent(Object element) { return null; }
+ public Object getParent(Object element) {
+ return null;
+ }
+
@Override
public boolean hasChildren(Object element) {
return !((Category) element).children.isEmpty();
}
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
});
fCategoriesViewer.setLabelProvider(new LabelProvider());
fCategoriesViewer.setInput(fCategories);
-
+
fCategoriesViewer.setExpandedElements(fCategories.toArray());
- final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT);
+ final GridData gd = createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT);
fCategoriesViewer.getControl().setLayoutData(gd);
- fOptionsGroup = createGroup(numColumns, composite, ""); //$NON-NLS-1$
-
+ fOptionsGroup = createGroup(numColumns, composite, ""); //$NON-NLS-1$
+
// label "Select split style:"
- fWrappingStylePolicy= createLabel(numColumns, fOptionsGroup,
- FormatterMessages.LineWrappingTabPage_wrapping_policy_label_text);
-
+ fWrappingStylePolicy = createLabel(numColumns, fOptionsGroup,
+ FormatterMessages.LineWrappingTabPage_wrapping_policy_label_text);
+
// combo SplitStyleCombo
- fWrappingStyleCombo= new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
+ fWrappingStyleCombo = new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
fWrappingStyleCombo.setItems(WRAPPING_NAMES);
fWrappingStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
-
+
// checkbox "Force split"
- fForceSplit= new Button(fOptionsGroup, SWT.CHECK);
+ fForceSplit = new Button(fOptionsGroup, SWT.CHECK);
fForceSplit.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
- fForceSplit.setText(FormatterMessages.LineWrappingTabPage_force_split_checkbox_text);
-
+ fForceSplit.setText(FormatterMessages.LineWrappingTabPage_force_split_checkbox_text);
+
// label "Select indentation style:"
- fIndentStylePolicy= createLabel(numColumns, fOptionsGroup,
- FormatterMessages.LineWrappingTabPage_indentation_policy_label_text);
-
+ fIndentStylePolicy = createLabel(numColumns, fOptionsGroup,
+ FormatterMessages.LineWrappingTabPage_indentation_policy_label_text);
+
// combo IndentStyleCombo
- fIndentStyleCombo= new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
+ fIndentStyleCombo = new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
fIndentStyleCombo.setItems(INDENT_NAMES);
fIndentStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
// selection state object
- fSelectionState= new SelectionState();
+ fSelectionState = new SelectionState();
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreatePreviewPane(org.eclipse.swt.widgets.Composite, int)
*/
@Override
protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
super.doCreatePreviewPane(composite, numColumns);
-
- final NumberPreference previewLineWidth= new NumberPreference(composite, numColumns / 2,
- fPreviewPreferences, LINE_SPLIT, 0, 9999,
- FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_text);
+
+ final NumberPreference previewLineWidth = new NumberPreference(composite, numColumns / 2, fPreviewPreferences,
+ LINE_SPLIT, 0, 9999, FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_text);
fDefaultFocusManager.add(previewLineWidth);
previewLineWidth.addObserver(fUpdater);
previewLineWidth.addObserver(new Observer() {
@@ -788,20 +785,20 @@ public class LineWrappingTabPage extends FormatterTabPage {
}
});
Label label = new Label(composite, SWT.WRAP);
- label.setText(FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_unit_text);
-
+ label.setText(FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_unit_text);
+
return composite;
}
-
- /*
- * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
- */
- @Override
+
+ /*
+ * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
protected CPreview doCreateCPreview(Composite parent) {
- fPreview= new TranslationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
-
+ fPreview = new TranslationUnitPreview(fWorkingValues, parent);
+ return fPreview;
+ }
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#initializePage()
*/
@@ -809,132 +806,135 @@ public class LineWrappingTabPage extends FormatterTabPage {
protected void initializePage() {
fCategoriesViewer.addSelectionChangedListener(fCategoryListener);
fCategoriesViewer.addDoubleClickListener(fCategoryListener);
-
+
fForceSplit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
forceSplitChanged(fForceSplit.getSelection());
}
});
- fIndentStyleCombo.addSelectionListener( new SelectionAdapter() {
+ fIndentStyleCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- indentStyleChanged(((Combo)e.widget).getSelectionIndex());
+ indentStyleChanged(((Combo) e.widget).getSelectionIndex());
}
});
- fWrappingStyleCombo.addSelectionListener( new SelectionAdapter() {
+ fWrappingStyleCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- wrappingStyleChanged(((Combo)e.widget).getSelectionIndex());
+ wrappingStyleChanged(((Combo) e.widget).getSelectionIndex());
}
});
-
+
fCategoryListener.restoreSelection();
-
+
fDefaultFocusManager.add(fCategoriesViewer.getControl());
fDefaultFocusManager.add(fWrappingStyleCombo);
fDefaultFocusManager.add(fIndentStyleCombo);
fDefaultFocusManager.add(fForceSplit);
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
*/
@Override
protected void doUpdatePreview() {
- final String normalSetting= fWorkingValues.get(LINE_SPLIT);
+ final String normalSetting = fWorkingValues.get(LINE_SPLIT);
fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
fPreview.update();
fWorkingValues.put(LINE_SPLIT, normalSetting);
}
-
- void setPreviewText(String text) {
+
+ void setPreviewText(String text) {
setPreviewText(text, 0);
}
void setPreviewText(String text, int offset) {
- final String normalSetting= fWorkingValues.get(LINE_SPLIT);
+ final String normalSetting = fWorkingValues.get(LINE_SPLIT);
fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
fPreview.setPreviewText(text, offset);
fWorkingValues.put(LINE_SPLIT, normalSetting);
}
-
+
protected void forceSplitChanged(boolean forceSplit) {
- Iterator<Category> iterator= fSelectionState.fElements.iterator();
- String currentKey;
- while (iterator.hasNext()) {
- currentKey= (iterator.next()).key;
- try {
- changeForceSplit(currentKey, forceSplit);
- } catch (IllegalArgumentException e) {
- fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(forceSplit, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT));
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK,
- Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
- }
- }
- fSelectionState.refreshState(fSelection);
+ Iterator<Category> iterator = fSelectionState.fElements.iterator();
+ String currentKey;
+ while (iterator.hasNext()) {
+ currentKey = (iterator.next()).key;
+ try {
+ changeForceSplit(currentKey, forceSplit);
+ } catch (IllegalArgumentException e) {
+ fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(forceSplit,
+ DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT));
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK,
+ Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
+ }
+ }
+ fSelectionState.refreshState(fSelection);
}
-
- private void changeForceSplit(String currentKey, boolean forceSplit) throws IllegalArgumentException{
- String value= fWorkingValues.get(currentKey);
- value= DefaultCodeFormatterConstants.setForceWrapping(value, forceSplit);
+
+ private void changeForceSplit(String currentKey, boolean forceSplit) throws IllegalArgumentException {
+ String value = fWorkingValues.get(currentKey);
+ value = DefaultCodeFormatterConstants.setForceWrapping(value, forceSplit);
if (value == null)
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException();
fWorkingValues.put(currentKey, value);
}
-
+
protected void wrappingStyleChanged(int wrappingStyle) {
- Iterator<Category> iterator= fSelectionState.fElements.iterator();
- String currentKey;
- while (iterator.hasNext()) {
- currentKey= (iterator.next()).key;
- try {
- changeWrappingStyle(currentKey, wrappingStyle);
- } catch (IllegalArgumentException e) {
- fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, wrappingStyle, DefaultCodeFormatterConstants.INDENT_DEFAULT));
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK,
- Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
- }
- }
- fSelectionState.refreshState(fSelection);
+ Iterator<Category> iterator = fSelectionState.fElements.iterator();
+ String currentKey;
+ while (iterator.hasNext()) {
+ currentKey = (iterator.next()).key;
+ try {
+ changeWrappingStyle(currentKey, wrappingStyle);
+ } catch (IllegalArgumentException e) {
+ fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, wrappingStyle,
+ DefaultCodeFormatterConstants.INDENT_DEFAULT));
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK,
+ Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
+ }
+ }
+ fSelectionState.refreshState(fSelection);
}
-
+
private void changeWrappingStyle(String currentKey, int wrappingStyle) throws IllegalArgumentException {
- String value= fWorkingValues.get(currentKey);
- value= DefaultCodeFormatterConstants.setWrappingStyle(value, wrappingStyle);
+ String value = fWorkingValues.get(currentKey);
+ value = DefaultCodeFormatterConstants.setWrappingStyle(value, wrappingStyle);
if (value == null)
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException();
fWorkingValues.put(currentKey, value);
}
-
+
protected void indentStyleChanged(int indentStyle) {
- Iterator<Category> iterator= fSelectionState.fElements.iterator();
- String currentKey;
- while (iterator.hasNext()) {
- currentKey= iterator.next().key;
- try {
- changeIndentStyle(currentKey, indentStyle);
- } catch (IllegalArgumentException e) {
- fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle));
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
- Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
- }
- }
- fSelectionState.refreshState(fSelection);
+ Iterator<Category> iterator = fSelectionState.fElements.iterator();
+ String currentKey;
+ while (iterator.hasNext()) {
+ currentKey = iterator.next().key;
+ try {
+ changeIndentStyle(currentKey, indentStyle);
+ } catch (IllegalArgumentException e) {
+ fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false,
+ DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle));
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
+ Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
+ }
+ }
+ fSelectionState.refreshState(fSelection);
}
-
- private void changeIndentStyle(String currentKey, int indentStyle) throws IllegalArgumentException{
- String value= fWorkingValues.get(currentKey);
- value= DefaultCodeFormatterConstants.setIndentStyle(value, indentStyle);
+
+ private void changeIndentStyle(String currentKey, int indentStyle) throws IllegalArgumentException {
+ String value = fWorkingValues.get(currentKey);
+ value = DefaultCodeFormatterConstants.setIndentStyle(value, indentStyle);
if (value == null)
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException();
fWorkingValues.put(currentKey, value);
}
-
- protected void updateControlEnablement(boolean inhomogenous, int wrappingStyle) {
- boolean doSplit= wrappingStyle != DefaultCodeFormatterConstants.WRAP_NO_SPLIT;
- fIndentStylePolicy.setEnabled(true);
- fIndentStyleCombo.setEnabled(inhomogenous || doSplit);
- fForceSplit.setEnabled(inhomogenous || doSplit);
+
+ protected void updateControlEnablement(boolean inhomogenous, int wrappingStyle) {
+ boolean doSplit = wrappingStyle != DefaultCodeFormatterConstants.WRAP_NO_SPLIT;
+ fIndentStylePolicy.setEnabled(true);
+ fIndentStyleCombo.setEnabled(inhomogenous || doSplit);
+ fForceSplit.setEnabled(inhomogenous || doSplit);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java
index 502500e506a..98d78212d67 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java
@@ -60,24 +60,23 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
public abstract class ModifyDialog extends StatusDialog implements IModifyDialogTabPage.IModificationListener {
-
- /**
- * The keys to retrieve the preferred area from the dialog settings.
- */
- private static final String DS_KEY_PREFERRED_WIDTH= "modify_dialog.preferred_width"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_HEIGHT= "modify_dialog.preferred_height"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_X= "modify_dialog.preferred_x"; //$NON-NLS-1$
- private static final String DS_KEY_PREFERRED_Y= "modify_dialog.preferred_y"; //$NON-NLS-1$
-
-
- /**
- * The key to store the number (beginning at 0) of the tab page which had the
- * focus last time.
- */
- private static final String DS_KEY_LAST_FOCUS= "modify_dialog.last_focus"; //$NON-NLS-1$
-
- private static final int APPLAY_BUTTON_ID= IDialogConstants.CLIENT_ID;
- private static final int SAVE_BUTTON_ID= IDialogConstants.CLIENT_ID + 1;
+
+ /**
+ * The keys to retrieve the preferred area from the dialog settings.
+ */
+ private static final String DS_KEY_PREFERRED_WIDTH = "modify_dialog.preferred_width"; //$NON-NLS-1$
+ private static final String DS_KEY_PREFERRED_HEIGHT = "modify_dialog.preferred_height"; //$NON-NLS-1$
+ private static final String DS_KEY_PREFERRED_X = "modify_dialog.preferred_x"; //$NON-NLS-1$
+ private static final String DS_KEY_PREFERRED_Y = "modify_dialog.preferred_y"; //$NON-NLS-1$
+
+ /**
+ * The key to store the number (beginning at 0) of the tab page which had the
+ * focus last time.
+ */
+ private static final String DS_KEY_LAST_FOCUS = "modify_dialog.last_focus"; //$NON-NLS-1$
+
+ private static final int APPLAY_BUTTON_ID = IDialogConstants.CLIENT_ID;
+ private static final int SAVE_BUTTON_ID = IDialogConstants.CLIENT_ID + 1;
private final String fKeyPreferredWidth;
private final String fKeyPreferredHight;
@@ -97,28 +96,29 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
private Button fSaveButton;
private StringDialogField fProfileNameField;
- protected ModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
+ protected ModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore,
+ boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
super(parentShell);
-
- fProfileStore= profileStore;
- fLastSaveLoadPathKey= lastSavePathKey;
-
- fKeyPreferredWidth= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_WIDTH;
- fKeyPreferredHight= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_HEIGHT;
- fKeyPreferredX= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_X;
- fKeyPreferredY= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_Y;
- fKeyLastFocus= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_LAST_FOCUS;
-
- fProfileManager= profileManager;
- fNewProfile= newProfile;
- setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX );
-
- fProfile= profile;
+
+ fProfileStore = profileStore;
+ fLastSaveLoadPathKey = lastSavePathKey;
+
+ fKeyPreferredWidth = CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_WIDTH;
+ fKeyPreferredHight = CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_HEIGHT;
+ fKeyPreferredX = CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_X;
+ fKeyPreferredY = CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_Y;
+ fKeyLastFocus = CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_LAST_FOCUS;
+
+ fProfileManager = profileManager;
+ fNewProfile = newProfile;
+ setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
+
+ fProfile = profile;
setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, profile.getName()));
- fWorkingValues= new HashMap<String, String>(fProfile.getSettings());
+ fWorkingValues = new HashMap<String, String>(fProfile.getSettings());
setStatusLineAboveButtons(false);
- fTabPages= new ArrayList<IModifyDialogTabPage>();
- fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
+ fTabPages = new ArrayList<IModifyDialogTabPage>();
+ fDialogSettings = CUIPlugin.getDefault().getDialogSettings();
}
protected abstract void addPages(Map<String, String> values);
@@ -126,76 +126,81 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
@Override
public void create() {
super.create();
- int lastFocusNr= 0;
+ int lastFocusNr = 0;
try {
- lastFocusNr= fDialogSettings.getInt(fKeyLastFocus);
- if (lastFocusNr < 0) lastFocusNr= 0;
- if (lastFocusNr > fTabPages.size() - 1) lastFocusNr= fTabPages.size() - 1;
+ lastFocusNr = fDialogSettings.getInt(fKeyLastFocus);
+ if (lastFocusNr < 0)
+ lastFocusNr = 0;
+ if (lastFocusNr > fTabPages.size() - 1)
+ lastFocusNr = fTabPages.size() - 1;
} catch (NumberFormatException x) {
- lastFocusNr= 0;
+ lastFocusNr = 0;
}
-
+
if (!fNewProfile) {
fTabFolder.setSelection(lastFocusNr);
- ((IModifyDialogTabPage)fTabFolder.getSelection()[0].getData()).setInitialFocus();
+ ((IModifyDialogTabPage) fTabFolder.getSelection()[0].getData()).setInitialFocus();
}
}
-
+
@Override
protected Control createDialogArea(Composite parent) {
-
- final Composite composite= (Composite)super.createDialogArea(parent);
-
- Composite nameComposite= new Composite(composite, SWT.NONE);
+
+ final Composite composite = (Composite) super.createDialogArea(parent);
+
+ Composite nameComposite = new Composite(composite, SWT.NONE);
nameComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
nameComposite.setLayout(new GridLayout(3, false));
-
- fProfileNameField= new StringDialogField();
+
+ fProfileNameField = new StringDialogField();
fProfileNameField.setLabelText(FormatterMessages.ModifyDialog_ProfileName_Label);
fProfileNameField.setText(fProfile.getName());
- fProfileNameField.getLabelControl(nameComposite).setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+ fProfileNameField.getLabelControl(nameComposite)
+ .setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fProfileNameField.getTextControl(nameComposite).setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fProfileNameField.setDialogFieldListener(new IDialogFieldListener() {
@Override
public void dialogFieldChanged(DialogField field) {
doValidate();
- }
+ }
});
-
- fSaveButton= createButton(nameComposite, SAVE_BUTTON_ID, FormatterMessages.ModifyDialog_Export_Button, false);
-
+
+ fSaveButton = createButton(nameComposite, SAVE_BUTTON_ID, FormatterMessages.ModifyDialog_Export_Button, false);
+
fTabFolder = new TabFolder(composite, SWT.NONE);
fTabFolder.setFont(composite.getFont());
fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- addPages(fWorkingValues);
+ addPages(fWorkingValues);
applyDialogFont(composite);
-
+
fTabFolder.addSelectionListener(new SelectionListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
@Override
public void widgetSelected(SelectionEvent e) {
- final TabItem tabItem= (TabItem)e.item;
- final IModifyDialogTabPage page= (IModifyDialogTabPage)tabItem.getData();
+ final TabItem tabItem = (TabItem) e.item;
+ final IModifyDialogTabPage page = (IModifyDialogTabPage) tabItem.getData();
// page.fSashForm.setWeights();
fDialogSettings.put(fKeyLastFocus, fTabPages.indexOf(page));
page.makeVisible();
}
});
-
+
doValidate();
-
+
return composite;
}
-
+
@Override
public void updateStatus(IStatus status) {
if (status == null) {
doValidate();
} else {
- super.updateStatus(status);
+ super.updateStatus(status);
}
}
@@ -204,20 +209,20 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
*/
@Override
protected Point getInitialSize() {
- Point initialSize= super.getInitialSize();
+ Point initialSize = super.getInitialSize();
try {
- int lastWidth= fDialogSettings.getInt(fKeyPreferredWidth);
+ int lastWidth = fDialogSettings.getInt(fKeyPreferredWidth);
if (initialSize.x > lastWidth)
- lastWidth= initialSize.x;
- int lastHeight= fDialogSettings.getInt(fKeyPreferredHight);
+ lastWidth = initialSize.x;
+ int lastHeight = fDialogSettings.getInt(fKeyPreferredHight);
if (initialSize.y > lastHeight)
- lastHeight= initialSize.y;
+ lastHeight = initialSize.y;
return new Point(lastWidth, lastHeight);
} catch (NumberFormatException ex) {
}
return initialSize;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
*/
@@ -229,10 +234,10 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
return super.getInitialLocation(initialSize);
}
}
-
+
@Override
public boolean close() {
- final Rectangle shell= getShell().getBounds();
+ final Rectangle shell = getShell().getBounds();
fDialogSettings.put(fKeyPreferredWidth, shell.width);
fDialogSettings.put(fKeyPreferredHight, shell.height);
@@ -241,7 +246,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
return super.close();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@@ -250,8 +255,8 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
applyPressed();
super.okPressed();
}
-
- @Override
+
+ @Override
protected void buttonPressed(int buttonId) {
if (buttonId == APPLAY_BUTTON_ID) {
applyPressed();
@@ -261,70 +266,73 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
} else {
super.buttonPressed(buttonId);
}
- }
-
+ }
+
private void applyPressed() {
if (!fProfile.getName().equals(fProfileNameField.getText())) {
- fProfile= fProfile.rename(fProfileNameField.getText(), fProfileManager);
+ fProfile = fProfile.rename(fProfileNameField.getText(), fProfileManager);
}
fProfile.setSettings(new HashMap<String, String>(fWorkingValues));
fProfileManager.setSelected(fProfile);
doValidate();
}
-
+
private void saveButtonPressed() {
- Profile selected= new CustomProfile(fProfileNameField.getText(), new HashMap<String, String>(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind());
-
- final FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
- dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title);
- dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$
+ Profile selected = new CustomProfile(fProfileNameField.getText(), new HashMap<String, String>(fWorkingValues),
+ fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind());
- final String lastPath= CUIPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".savepath"); //$NON-NLS-1$
+ final FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
+ dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title);
+ dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$
+
+ final String lastPath = CUIPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".savepath"); //$NON-NLS-1$
if (lastPath != null) {
dialog.setFilterPath(lastPath);
}
- final String path= dialog.open();
- if (path == null)
+ final String path = dialog.open();
+ if (path == null)
return;
CUIPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".savepath", dialog.getFilterPath()); //$NON-NLS-1$
- final File file= new File(path);
- if (file.exists() && !MessageDialog.openQuestion(getShell(), FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_title, Messages.format(FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_message, path))) {
+ final File file = new File(path);
+ if (file.exists() && !MessageDialog.openQuestion(getShell(),
+ FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_title, Messages.format(
+ FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_message, path))) {
return;
}
- String encoding= ProfileStore.ENCODING;
- final IContentType type= Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$
+ String encoding = ProfileStore.ENCODING;
+ final IContentType type = Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$
if (type != null)
- encoding= type.getDefaultCharset();
- final Collection<Profile> profiles= new ArrayList<Profile>();
+ encoding = type.getDefaultCharset();
+ final Collection<Profile> profiles = new ArrayList<Profile>();
profiles.add(selected);
try {
fProfileStore.writeProfilesToFile(profiles, file, encoding);
} catch (CoreException e) {
- final String title= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_title;
- final String message= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message;
+ final String title = FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_title;
+ final String message = FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message;
ExceptionHandler.handle(e, getShell(), title, message);
}
}
-
- @Override
+
+ @Override
protected void createButtonsForButtonBar(Composite parent) {
- fApplyButton= createButton(parent, APPLAY_BUTTON_ID, FormatterMessages.ModifyDialog_apply_button, false);
+ fApplyButton = createButton(parent, APPLAY_BUTTON_ID, FormatterMessages.ModifyDialog_apply_button, false);
fApplyButton.setEnabled(false);
-
- GridLayout layout= (GridLayout) parent.getLayout();
+
+ GridLayout layout = (GridLayout) parent.getLayout();
layout.numColumns++;
- layout.makeColumnsEqualWidth= false;
- Label label= new Label(parent, SWT.NONE);
- GridData data= new GridData();
- data.widthHint= layout.horizontalSpacing;
+ layout.makeColumnsEqualWidth = false;
+ Label label = new Label(parent, SWT.NONE);
+ GridData data = new GridData();
+ data.widthHint = layout.horizontalSpacing;
label.setLayoutData(data);
super.createButtonsForButtonBar(parent);
}
protected final void addTabPage(String title, IModifyDialogTabPage tabPage) {
- final TabItem tabItem= new TabItem(fTabFolder, SWT.NONE);
+ final TabItem tabItem = new TabItem(fTabFolder, SWT.NONE);
applyDialogFont(tabItem.getControl());
tabItem.setText(title);
tabItem.setData(tabPage);
@@ -339,75 +347,80 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
@Override
protected void updateButtonsEnableState(IStatus status) {
- super.updateButtonsEnableState(status);
- if (fApplyButton != null && !fApplyButton.isDisposed()) {
- fApplyButton.setEnabled(hasChanges() && !status.matches(IStatus.ERROR));
+ super.updateButtonsEnableState(status);
+ if (fApplyButton != null && !fApplyButton.isDisposed()) {
+ fApplyButton.setEnabled(hasChanges() && !status.matches(IStatus.ERROR));
+ }
+ if (fSaveButton != null && !fSaveButton.isDisposed()) {
+ fSaveButton.setEnabled(!validateProfileName().matches(IStatus.ERROR));
}
- if (fSaveButton != null && !fSaveButton.isDisposed()) {
- fSaveButton.setEnabled(!validateProfileName().matches(IStatus.ERROR));
- }
}
-
- private void doValidate() {
- String name= fProfileNameField.getText().trim();
+
+ private void doValidate() {
+ String name = fProfileNameField.getText().trim();
if (name.equals(fProfile.getName()) && fProfile.hasEqualSettings(fWorkingValues, fWorkingValues.keySet())) {
updateStatus(StatusInfo.OK_STATUS);
return;
}
-
- IStatus status= validateProfileName();
- if (status.matches(IStatus.ERROR)) {
- updateStatus(status);
- return;
- }
-
+
+ IStatus status = validateProfileName();
+ if (status.matches(IStatus.ERROR)) {
+ updateStatus(status);
+ return;
+ }
+
if (!name.equals(fProfile.getName()) && fProfileManager.containsName(name)) {
- updateStatus(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_Duplicate_Status, null));
+ updateStatus(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
+ FormatterMessages.ModifyDialog_Duplicate_Status, null));
return;
}
-
+
if (fProfile.isBuiltInProfile() || fProfile.isSharedProfile()) {
- updateStatus(new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_NewCreated_Status, null));
+ updateStatus(new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, 0,
+ FormatterMessages.ModifyDialog_NewCreated_Status, null));
return;
}
- updateStatus(StatusInfo.OK_STATUS);
- }
-
- private IStatus validateProfileName() {
- final String name= fProfileNameField.getText().trim();
-
- if (fProfile.isBuiltInProfile()) {
- if (fProfile.getName().equals(name)) {
- return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_BuiltIn_Status, null);
- }
- }
-
- if (fProfile.isSharedProfile()) {
- if (fProfile.getName().equals(name)) {
- return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_Shared_Status, null);
+ updateStatus(StatusInfo.OK_STATUS);
+ }
+
+ private IStatus validateProfileName() {
+ final String name = fProfileNameField.getText().trim();
+
+ if (fProfile.isBuiltInProfile()) {
+ if (fProfile.getName().equals(name)) {
+ return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_BuiltIn_Status,
+ null);
+ }
+ }
+
+ if (fProfile.isSharedProfile()) {
+ if (fProfile.getName().equals(name)) {
+ return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_Shared_Status,
+ null);
}
- }
-
+ }
+
if (name.length() == 0) {
- return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_EmptyName_Status, null);
+ return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_EmptyName_Status,
+ null);
}
-
+
return StatusInfo.OK_STATUS;
- }
+ }
private boolean hasChanges() {
if (!fProfileNameField.getText().trim().equals(fProfile.getName()))
return true;
-
- Iterator<Map.Entry<String, String>> iter= fProfile.getSettings().entrySet().iterator();
- for (;iter.hasNext();) {
- Map.Entry<String, String> curr= iter.next();
+
+ Iterator<Map.Entry<String, String>> iter = fProfile.getSettings().entrySet().iterator();
+ for (; iter.hasNext();) {
+ Map.Entry<String, String> curr = iter.next();
if (!fWorkingValues.get(curr.getKey()).equals(curr.getValue())) {
return true;
}
}
return false;
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java
index c793f3dac41..77e23636401 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java
@@ -56,103 +56,104 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.util.Messages;
-
-public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
+public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
/**
* This is the default listener for any of the Preference
* classes. It is added by the respective factory methods and
- * updates the page's preview on each change.
+ * updates the page's preview on each change.
*/
- protected final Observer fUpdater= new Observer() {
+ protected final Observer fUpdater = new Observer() {
@Override
public void update(Observable o, Object arg) {
doUpdatePreview();
notifyValuesModified();
}
};
-
+
/**
* The base class of all Preference classes. A preference class provides a wrapper
* around one or more SWT widgets and handles the input of values for some key.
* On each change, the new value is written to the map and the listeners are notified.
*/
protected abstract class Preference extends Observable {
- private final Map<String, String> fPreferences;
- private boolean fEnabled;
- private String fKey;
-
- /**
- * Create a new Preference.
- * @param preferences The map where the value is written.
- * @param key The key for which a value is managed.
- */
- public Preference(Map<String, String> preferences, String key) {
- fPreferences= preferences;
- fEnabled= true;
- fKey= key;
- }
- /**
- * @return Gets the map of this Preference.
- */
- protected final Map<String, String> getPreferences() {
- return fPreferences;
- }
-
- /**
- * Set the enabled state of all SWT widgets of this preference.
- * @param enabled new value
- */
- public final void setEnabled(boolean enabled) {
- fEnabled= enabled;
- updateWidget();
- }
-
- /**
- * @return Gets the enabled state of all SWT widgets of this Preference.
- */
- public final boolean getEnabled() {
- return fEnabled;
- }
-
- /**
- * Set the key which is used to store the value.
- * @param key New value
- */
- public final void setKey(String key) {
- if (key == null || !fKey.equals(key)) {
- fKey= key;
- updateWidget();
- }
- }
- /**
- * @return Gets the currently used key which is used to store the value.
- */
- public final String getKey() {
- return fKey;
- }
-
- /**
- * Returns the main control of a preference, which is mainly used to
- * manage the focus. This may be <code>null</code> if the preference doesn't
- * have a control which is able to have the focus.
- * @return The main control
- */
- public abstract Control getControl();
-
- /**
- * To be implemented in subclasses. Update the SWT widgets when the state
- * of this object has changed (enabled, key, ...).
- */
- protected abstract void updateWidget();
+ private final Map<String, String> fPreferences;
+ private boolean fEnabled;
+ private String fKey;
+
+ /**
+ * Create a new Preference.
+ * @param preferences The map where the value is written.
+ * @param key The key for which a value is managed.
+ */
+ public Preference(Map<String, String> preferences, String key) {
+ fPreferences = preferences;
+ fEnabled = true;
+ fKey = key;
+ }
+
+ /**
+ * @return Gets the map of this Preference.
+ */
+ protected final Map<String, String> getPreferences() {
+ return fPreferences;
+ }
+
+ /**
+ * Set the enabled state of all SWT widgets of this preference.
+ * @param enabled new value
+ */
+ public final void setEnabled(boolean enabled) {
+ fEnabled = enabled;
+ updateWidget();
+ }
+
+ /**
+ * @return Gets the enabled state of all SWT widgets of this Preference.
+ */
+ public final boolean getEnabled() {
+ return fEnabled;
+ }
+
+ /**
+ * Set the key which is used to store the value.
+ * @param key New value
+ */
+ public final void setKey(String key) {
+ if (key == null || !fKey.equals(key)) {
+ fKey = key;
+ updateWidget();
+ }
+ }
+
+ /**
+ * @return Gets the currently used key which is used to store the value.
+ */
+ public final String getKey() {
+ return fKey;
+ }
+
+ /**
+ * Returns the main control of a preference, which is mainly used to
+ * manage the focus. This may be <code>null</code> if the preference doesn't
+ * have a control which is able to have the focus.
+ * @return The main control
+ */
+ public abstract Control getControl();
+
+ /**
+ * To be implemented in subclasses. Update the SWT widgets when the state
+ * of this object has changed (enabled, key, ...).
+ */
+ protected abstract void updateWidget();
}
-
+
/**
- * Wrapper around a checkbox and a label.
- */
+ * Wrapper around a checkbox and a label.
+ */
protected class ButtonPreference extends Preference {
private final String[] fValues;
private final Button fCheckbox;
-
+
/**
* Create a new CheckboxPreference.
* @param composite The composite on which the SWT widgets are added.
@@ -163,35 +164,35 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* @param text The label text for this Preference.
* @param style SWT style flag for the button
*/
- public ButtonPreference(Composite composite, int numColumns,
- Map<String, String> preferences, String key,
- String [] values, String text, int style) {
- super(preferences, key);
- if (values == null || text == null)
- throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_text_unassigned);
- fValues= values;
-
- fCheckbox= new Button(composite, style);
+ public ButtonPreference(Composite composite, int numColumns, Map<String, String> preferences, String key,
+ String[] values, String text, int style) {
+ super(preferences, key);
+ if (values == null || text == null)
+ throw new IllegalArgumentException(
+ FormatterMessages.ModifyDialogTabPage_error_msg_values_text_unassigned);
+ fValues = values;
+
+ fCheckbox = new Button(composite, style);
fCheckbox.setText(text);
fCheckbox.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
fCheckbox.setFont(composite.getFont());
-
+
updateWidget();
fCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- checkboxChecked(((Button)e.widget).getSelection());
+ checkboxChecked(((Button) e.widget).getSelection());
}
});
}
-
+
protected void checkboxChecked(boolean state) {
getPreferences().put(getKey(), state ? fValues[1] : fValues[0]);
setChanged();
notifyObservers();
}
-
+
@Override
protected void updateWidget() {
if (getKey() != null) {
@@ -202,43 +203,45 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
fCheckbox.setEnabled(false);
}
}
-
+
public boolean getChecked() {
return fValues[1].equals(getPreferences().get(getKey()));
}
-
+
public void setChecked(boolean checked) {
getPreferences().put(getKey(), checked ? fValues[1] : fValues[0]);
updateWidget();
- checkboxChecked(checked);
+ checkboxChecked(checked);
}
-
+
@Override
public Control getControl() {
return fCheckbox;
}
}
-
+
protected final class CheckboxPreference extends ButtonPreference {
- public CheckboxPreference(Composite composite, int numColumns, Map<String, String> preferences, String key, String[] values, String text) {
- super(composite, numColumns, preferences, key, values, text, SWT.CHECK);
- }
+ public CheckboxPreference(Composite composite, int numColumns, Map<String, String> preferences, String key,
+ String[] values, String text) {
+ super(composite, numColumns, preferences, key, values, text, SWT.CHECK);
+ }
}
-
+
protected final class RadioPreference extends ButtonPreference {
- public RadioPreference(Composite composite, int numColumns, Map<String, String> preferences, String key, String[] values, String text) {
- super(composite, numColumns, preferences, key, values, text, SWT.RADIO);
- }
+ public RadioPreference(Composite composite, int numColumns, Map<String, String> preferences, String key,
+ String[] values, String text) {
+ super(composite, numColumns, preferences, key, values, text, SWT.RADIO);
+ }
}
-
+
/**
* Wrapper around a Combo box.
*/
protected final class ComboPreference extends Preference {
- private final String [] fItems;
+ private final String[] fItems;
private final String[] fValues;
private final Combo fCombo;
-
+
/**
* Create a new ComboPreference.
* @param composite The composite on which the SWT widgets are added.
@@ -249,41 +252,43 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* @param text The label text for this Preference.
* @param items An array of n elements indicating the text to be written in the combo box.
*/
- public ComboPreference(Composite composite, int numColumns,
- Map<String, String> preferences, String key,
- String [] values, String text, String [] items) {
- super(preferences, key);
- if (values == null || items == null || text == null)
- throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_items_text_unassigned);
- fValues= values;
- fItems= items;
+ public ComboPreference(Composite composite, int numColumns, Map<String, String> preferences, String key,
+ String[] values, String text, String[] items) {
+ super(preferences, key);
+ if (values == null || items == null || text == null)
+ throw new IllegalArgumentException(
+ FormatterMessages.ModifyDialogTabPage_error_msg_values_items_text_unassigned);
+ fValues = values;
+ fItems = items;
createLabel(numColumns - 1, composite, text);
- fCombo= new Combo(composite, SWT.SINGLE | SWT.READ_ONLY);
+ fCombo = new Combo(composite, SWT.SINGLE | SWT.READ_ONLY);
fCombo.setFont(composite.getFont());
fCombo.setItems(items);
-
- int max= 0;
+
+ int max = 0;
for (String item : items)
- if (item.length() > max) max= item.length();
-
- fCombo.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, fCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x));
+ if (item.length() > max)
+ max = item.length();
+
+ fCombo.setLayoutData(
+ createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, fCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x));
updateWidget();
fCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- comboSelected(((Combo)e.widget).getSelectionIndex());
+ comboSelected(((Combo) e.widget).getSelectionIndex());
}
});
}
-
+
protected void comboSelected(int index) {
getPreferences().put(getKey(), fValues[index]);
setChanged();
notifyObservers(fValues[index]);
}
-
+
@Override
protected void updateWidget() {
if (getKey() != null) {
@@ -294,40 +299,39 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
fCombo.setEnabled(false);
}
}
-
+
public String getSelectedItem() {
- final String selected= getPreferences().get(getKey());
- for (int i= 0; i < fValues.length; i++) {
+ final String selected = getPreferences().get(getKey());
+ for (int i = 0; i < fValues.length; i++) {
if (fValues[i].equals(selected)) {
return fItems[i];
}
}
return ""; //$NON-NLS-1$
}
-
+
public boolean hasValue(String value) {
return value.equals(getPreferences().get(getKey()));
}
-
+
@Override
public Control getControl() {
return fCombo;
}
}
-
+
/**
* Wrapper around a textfied which requests an integer input of a given range.
*/
protected final class NumberPreference extends Preference {
-
+
private final int fMinValue, fMaxValue;
private final Label fNumberLabel;
private final Text fNumberText;
protected int fSelected;
- protected int fOldSelected;
-
-
+ protected int fOldSelected;
+
/**
* Create a new NumberPreference.
* @param composite The composite on which the SWT widgets are added.
@@ -338,34 +342,35 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* @param maxValue The maximum value which is valid input.
* @param text The label text for this Preference.
*/
- public NumberPreference(Composite composite, int numColumns,
- Map<String, String> preferences, String key,
- int minValue, int maxValue, String text) {
- super(preferences, key);
-
- fNumberLabel= createLabel(numColumns - 1, composite, text, GridData.FILL_HORIZONTAL);
- fNumberText= new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.RIGHT);
+ public NumberPreference(Composite composite, int numColumns, Map<String, String> preferences, String key,
+ int minValue, int maxValue, String text) {
+ super(preferences, key);
+
+ fNumberLabel = createLabel(numColumns - 1, composite, text, GridData.FILL_HORIZONTAL);
+ fNumberText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.RIGHT);
fNumberText.setFont(composite.getFont());
- final int length= Integer.toString(maxValue).length() + 3;
- fNumberText.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_END, fPixelConverter.convertWidthInCharsToPixels(length)));
-
- fMinValue= minValue;
- fMaxValue= maxValue;
-
+ final int length = Integer.toString(maxValue).length() + 3;
+ fNumberText.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_END,
+ fPixelConverter.convertWidthInCharsToPixels(length)));
+
+ fMinValue = minValue;
+ fMaxValue = maxValue;
+
updateWidget();
-
+
fNumberText.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
- NumberPreference.this.focusGained();
+ NumberPreference.this.focusGained();
}
- @Override
+
+ @Override
public void focusLost(FocusEvent e) {
- NumberPreference.this.focusLost();
+ NumberPreference.this.focusLost();
}
});
-
+
fNumberText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
@@ -373,147 +378,151 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
}
});
}
-
+
private IStatus createErrorStatus() {
- return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 0, Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_value, Integer.toString(fMinValue), Integer.toString(fMaxValue)), null);
+ return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 0,
+ Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_value,
+ Integer.toString(fMinValue), Integer.toString(fMaxValue)),
+ null);
}
protected void focusGained() {
- fOldSelected= fSelected;
- fNumberText.setSelection(0, fNumberText.getCharCount());
+ fOldSelected = fSelected;
+ fNumberText.setSelection(0, fNumberText.getCharCount());
}
-
+
protected void focusLost() {
- updateStatus(null);
- final String input= fNumberText.getText();
- if (!validInput(input))
- fSelected= fOldSelected;
- else
- fSelected= Integer.parseInt(input);
- if (fSelected != fOldSelected) {
- saveSelected();
- fNumberText.setText(Integer.toString(fSelected));
- }
- }
-
-
+ updateStatus(null);
+ final String input = fNumberText.getText();
+ if (!validInput(input))
+ fSelected = fOldSelected;
+ else
+ fSelected = Integer.parseInt(input);
+ if (fSelected != fOldSelected) {
+ saveSelected();
+ fNumberText.setText(Integer.toString(fSelected));
+ }
+ }
+
protected void fieldModified() {
- final String trimInput= fNumberText.getText().trim();
- final boolean valid= validInput(trimInput);
-
- updateStatus(valid ? null : createErrorStatus());
-
- if (valid) {
- final int number= Integer.parseInt(trimInput);
- if (fSelected != number) {
- fSelected= number;
- saveSelected();
- }
- }
- }
-
+ final String trimInput = fNumberText.getText().trim();
+ final boolean valid = validInput(trimInput);
+
+ updateStatus(valid ? null : createErrorStatus());
+
+ if (valid) {
+ final int number = Integer.parseInt(trimInput);
+ if (fSelected != number) {
+ fSelected = number;
+ saveSelected();
+ }
+ }
+ }
+
private boolean validInput(String trimInput) {
- int number;
-
- try {
- number= Integer.parseInt(trimInput);
- } catch (NumberFormatException x) {
- return false;
- }
-
- if (number < fMinValue) return false;
- if (number > fMaxValue) return false;
- return true;
- }
-
+ int number;
+
+ try {
+ number = Integer.parseInt(trimInput);
+ } catch (NumberFormatException x) {
+ return false;
+ }
+
+ if (number < fMinValue)
+ return false;
+ if (number > fMaxValue)
+ return false;
+ return true;
+ }
+
private void saveSelected() {
getPreferences().put(getKey(), Integer.toString(fSelected));
setChanged();
notifyObservers();
}
-
+
@Override
protected void updateWidget() {
- final boolean hasKey= getKey() != null;
+ final boolean hasKey = getKey() != null;
- fNumberLabel.setEnabled(hasKey && getEnabled());
+ fNumberLabel.setEnabled(hasKey && getEnabled());
fNumberText.setEnabled(hasKey && getEnabled());
if (hasKey) {
- String s= getPreferences().get(getKey());
- try {
- fSelected= Integer.parseInt(s);
- } catch (NumberFormatException e) {
- final String message= Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_key, getKey());
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, message, e));
- s= ""; //$NON-NLS-1$
- }
- fNumberText.setText(s);
+ String s = getPreferences().get(getKey());
+ try {
+ fSelected = Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ final String message = Messages
+ .format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_key, getKey());
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, message, e));
+ s = ""; //$NON-NLS-1$
+ }
+ fNumberText.setText(s);
} else {
- fNumberText.setText(""); //$NON-NLS-1$
+ fNumberText.setText(""); //$NON-NLS-1$
}
}
-
+
@Override
public Control getControl() {
return fNumberText;
}
}
-
/**
* This class provides the default way to preserve and re-establish the focus
* over multiple modify sessions. Each ModifyDialogTabPage has its own instance,
* and it should add all relevant controls upon creation, always in the same sequence.
* This established a mapping of controls to indexes, which allows to restore the focus
- * in a later session.
- * The index is saved in the dialog settings, and there is only one common preference for
+ * in a later session.
+ * The index is saved in the dialog settings, and there is only one common preference for
* all tab pages. It is always the currently active tab page which stores its focus
- * index.
+ * index.
*/
protected final static class DefaultFocusManager extends FocusAdapter {
-
- private final static String PREF_LAST_FOCUS_INDEX= "formatter_page.modify_dialog_tab_page.last_focus_index"; //$NON-NLS-1$
-
+
+ private final static String PREF_LAST_FOCUS_INDEX = "formatter_page.modify_dialog_tab_page.last_focus_index"; //$NON-NLS-1$
+
private final IDialogSettings fDialogSettings;
-
+
private final Map<Control, Integer> fItemMap;
private final List<Control> fItemList;
-
+
private int fIndex;
-
+
public DefaultFocusManager() {
- fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
- fItemMap= new HashMap<Control, Integer>();
- fItemList= new ArrayList<Control>();
- fIndex= 0;
+ fDialogSettings = CUIPlugin.getDefault().getDialogSettings();
+ fItemMap = new HashMap<Control, Integer>();
+ fItemList = new ArrayList<Control>();
+ fIndex = 0;
}
@Override
public void focusGained(FocusEvent e) {
fDialogSettings.put(PREF_LAST_FOCUS_INDEX, fItemMap.get(e.widget).intValue());
}
-
+
public void add(Control control) {
control.addFocusListener(this);
fItemList.add(fIndex, control);
fItemMap.put(control, Integer.valueOf(fIndex++));
}
-
+
public void add(Preference preference) {
- final Control control= preference.getControl();
- if (control != null)
+ final Control control = preference.getControl();
+ if (control != null)
add(control);
}
-
+
public boolean isUsed() {
return fIndex != 0;
}
-
+
public void restoreFocus() {
- int index= 0;
+ int index = 0;
try {
- index= fDialogSettings.getInt(PREF_LAST_FOCUS_INDEX);
+ index = fDialogSettings.getInt(PREF_LAST_FOCUS_INDEX);
// make sure the value is within the range
if ((index >= 0) && (index <= fItemList.size() - 1)) {
fItemList.get(index).setFocus();
@@ -522,34 +531,34 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
// this is the first time
}
}
-
+
public void resetFocus() {
fDialogSettings.put(PREF_LAST_FOCUS_INDEX, -1);
}
}
-
+
/**
* Layout used for the settings part. Makes sure to show scrollbars
* if necessary. The settings part needs to be layouted on resize.
*/
private static class PageLayout extends Layout {
-
+
private final ScrolledComposite fContainer;
private final int fMinimalWidth;
private final int fMinimalHight;
private PageLayout(ScrolledComposite container, int minimalWidth, int minimalHight) {
- fContainer= container;
- fMinimalWidth= minimalWidth;
- fMinimalHight= minimalHight;
+ fContainer = container;
+ fMinimalWidth = minimalWidth;
+ fMinimalHight = minimalHight;
}
-
+
@Override
public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
return new Point(wHint, hHint);
}
-
+
int x = fMinimalWidth;
int y = fMinimalHight;
Control[] children = composite.getChildren();
@@ -558,27 +567,27 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
x = Math.max(x, size.x);
y = Math.max(y, size.y);
}
-
- Rectangle area= fContainer.getClientArea();
+
+ Rectangle area = fContainer.getClientArea();
if (area.width > x) {
fContainer.setExpandHorizontal(true);
} else {
fContainer.setExpandHorizontal(false);
}
-
+
if (area.height > y) {
fContainer.setExpandVertical(true);
} else {
fContainer.setExpandVertical(false);
}
-
+
if (wHint != SWT.DEFAULT) {
x = wHint;
}
if (hHint != SWT.DEFAULT) {
y = hHint;
}
-
+
return new Point(x, y);
}
@@ -595,11 +604,11 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
/**
* The default focus manager. This widget knows all widgets which can have the focus
* and listens for focusGained events, on which it stores the index of the current
- * focus holder. When the dialog is restarted, <code>restoreFocus()</code> sets the
+ * focus holder. When the dialog is restarted, <code>restoreFocus()</code> sets the
* focus to the last control which had it.
- *
+ *
* The standard Preference object are managed by this focus manager if they are created
- * using the respective factory methods. Other SWT widgets can be added in subclasses
+ * using the respective factory methods. Other SWT widgets can be added in subclasses
* when they are created.
*/
protected final DefaultFocusManager fDefaultFocusManager;
@@ -608,50 +617,49 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* A pixel converter for layout calculations
*/
protected PixelConverter fPixelConverter;
-
-
+
/**
* The map where the current settings are stored.
*/
protected Map<String, String> fWorkingValues;
-
+
/**
* The modify dialog where we can display status messages.
*/
private IModifyDialogTabPage.IModificationListener fModifyListener;
-
/*
* Create a new <code>ModifyDialogTabPage</code>
*/
- public ModifyDialogTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map<String, String> workingValues) {
- fWorkingValues= workingValues;
- fModifyListener= modifyListener;
- fDefaultFocusManager= new DefaultFocusManager();
+ public ModifyDialogTabPage(IModifyDialogTabPage.IModificationListener modifyListener,
+ Map<String, String> workingValues) {
+ fWorkingValues = workingValues;
+ fModifyListener = modifyListener;
+ fDefaultFocusManager = new DefaultFocusManager();
}
-
+
public ModifyDialogTabPage() {
- fDefaultFocusManager= new DefaultFocusManager();
+ fDefaultFocusManager = new DefaultFocusManager();
}
-
+
/**
* {@inheritDoc}
*/
@Override
public void setWorkingValues(Map<String, String> workingValues) {
- fWorkingValues= workingValues;
+ fWorkingValues = workingValues;
}
-
+
/**
* {@inheritDoc}
*/
@Override
public void setModifyListener(IModifyDialogTabPage.IModificationListener modifyListener) {
- fModifyListener= modifyListener;
+ fModifyListener = modifyListener;
}
-
+
/**
- * Create the contents of this tab page. Subclasses cannot override this,
+ * Create the contents of this tab page. Subclasses cannot override this,
* instead they must implement <code>doCreatePreferences</code>. <code>doCreatePreview</code> may also
* be overridden as necessary.
* @param parent The parent composite
@@ -659,53 +667,54 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
*/
@Override
public final Composite createContents(Composite parent) {
- final int numColumns= 4;
-
+ final int numColumns = 4;
+
if (fPixelConverter == null) {
- fPixelConverter= new PixelConverter(parent);
+ fPixelConverter = new PixelConverter(parent);
}
-
+
final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
sashForm.setFont(parent.getFont());
-
+
Composite scrollContainer = new Composite(sashForm, SWT.NONE);
-
+
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
scrollContainer.setLayoutData(gridData);
-
- GridLayout layout= new GridLayout(2, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.horizontalSpacing= 0;
- layout.verticalSpacing= 0;
+
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
scrollContainer.setLayout(layout);
-
- ScrolledComposite scroll= new ScrolledComposite(scrollContainer, SWT.V_SCROLL | SWT.H_SCROLL);
- scroll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ ScrolledComposite scroll = new ScrolledComposite(scrollContainer, SWT.V_SCROLL | SWT.H_SCROLL);
+ scroll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
- final Composite settingsContainer= new Composite(scroll, SWT.NONE);
+ final Composite settingsContainer = new Composite(scroll, SWT.NONE);
settingsContainer.setFont(sashForm.getFont());
-
+
scroll.setContent(settingsContainer);
-
+
settingsContainer.setLayout(new PageLayout(scroll, 400, 400));
settingsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Composite settingsPane= new Composite(settingsContainer, SWT.NONE);
+
+ Composite settingsPane = new Composite(settingsContainer, SWT.NONE);
settingsPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- layout= new GridLayout(numColumns, false);
- layout.verticalSpacing= (int)(1.5 * fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING));
- layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+
+ layout = new GridLayout(numColumns, false);
+ layout.verticalSpacing = (int) (1.5
+ * fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING));
+ layout.horizontalSpacing = fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ layout.marginHeight = fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
settingsPane.setLayout(layout);
doCreatePreferences(settingsPane, numColumns);
-
- settingsContainer.setSize(settingsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
+
+ settingsContainer.setSize(settingsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
scroll.addControlListener(new ControlListener() {
@Override
@@ -714,73 +723,71 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
@Override
public void controlResized(ControlEvent e) {
- settingsContainer.setSize(settingsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ settingsContainer.setSize(settingsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});
-
+
Label sashHandle = new Label(scrollContainer, SWT.SEPARATOR | SWT.VERTICAL);
- gridData= new GridData(SWT.RIGHT, SWT.FILL, false, true);
+ gridData = new GridData(SWT.RIGHT, SWT.FILL, false, true);
sashHandle.setLayoutData(gridData);
- final Composite previewPane= new Composite(sashForm, SWT.NONE);
+ final Composite previewPane = new Composite(sashForm, SWT.NONE);
previewPane.setLayout(createGridLayout(numColumns, true));
previewPane.setFont(sashForm.getFont());
doCreatePreviewPane(previewPane, numColumns);
initializePage();
-
- sashForm.setWeights(new int [] {3, 3});
+
+ sashForm.setWeights(new int[] { 3, 3 });
return sashForm;
}
-
+
/**
- * This method is called after all controls have been allocated, including the preview.
+ * This method is called after all controls have been allocated, including the preview.
* It can be used to set the preview text and to create listeners.
*
*/
protected abstract void initializePage();
-
/**
- * Create the left side of the modify dialog. This is meant to be implemented by subclasses.
+ * Create the left side of the modify dialog. This is meant to be implemented by subclasses.
* @param composite Composite to create in
* @param numColumns Number of columns to use
*/
protected abstract void doCreatePreferences(Composite composite, int numColumns);
-
/**
* Create the right side of the modify dialog. By default, the preview is displayed there.
- * Subclasses can override this method in order to customize the right-hand side of the
+ * Subclasses can override this method in order to customize the right-hand side of the
* dialog.
* @param composite Composite to create in
* @param numColumns Number of columns to use
* @return Created composite
*/
protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
- createLabel(numColumns, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);
-
- final CPreview preview= doCreateCPreview(composite);
+ createLabel(numColumns, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);
+
+ final CPreview preview = doCreateCPreview(composite);
fDefaultFocusManager.add(preview.getControl());
-
- final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0);
- gd.widthHint= 0;
- gd.heightHint=0;
+
+ final GridData gd = createGridData(numColumns, GridData.FILL_BOTH, 0);
+ gd.widthHint = 0;
+ gd.heightHint = 0;
preview.getControl().setLayoutData(gd);
-
+
return composite;
}
/**
* To be implemented by subclasses. This method should return an instance of CPreview.
* Currently, the choice is between CompilationUnitPreview which contains a valid compilation
- * unit, or a SnippetPreview which formats several independent code snippets and displays them
+ * unit, or a SnippetPreview which formats several independent code snippets and displays them
* in the same window.
* @param parent Parent composite
* @return Created preview
*/
protected abstract CPreview doCreateCPreview(Composite parent);
-
+
/**
* {@inheritDoc}
*/
@@ -789,53 +796,53 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
fDefaultFocusManager.resetFocus();
doUpdatePreview();
}
-
+
/**
* Update the preview. To be implemented by subclasses.
*/
protected abstract void doUpdatePreview();
-
+
protected void notifyValuesModified() {
fModifyListener.valuesModified();
}
- /**
+
+ /**
* {@inheritDoc}
*/
- @Override
+ @Override
public void setInitialFocus() {
if (fDefaultFocusManager.isUsed()) {
fDefaultFocusManager.restoreFocus();
}
}
-
- /**
- * Set the status field on the dialog. This can be used by tab pages to report
- * inconsistent input. The OK button is disabled if the kind is IStatus.ERROR.
- * @param status Status describing the current page error state
- */
+ /**
+ * Set the status field on the dialog. This can be used by tab pages to report
+ * inconsistent input. The OK button is disabled if the kind is IStatus.ERROR.
+ * @param status Status describing the current page error state
+ */
protected void updateStatus(IStatus status) {
fModifyListener.updateStatus(status);
}
-
+
/*
* Factory methods to make GUI construction easier
*/
-
+
/*
* Create a GridLayout with the default margin and spacing settings, as
* well as the specified number of columns.
*/
protected GridLayout createGridLayout(int numColumns, boolean margins) {
- final GridLayout layout= new GridLayout(numColumns, false);
- layout.verticalSpacing= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ final GridLayout layout = new GridLayout(numColumns, false);
+ layout.verticalSpacing = fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing = fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
if (margins) {
- layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.marginHeight = fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
} else {
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
}
return layout;
}
@@ -844,102 +851,100 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* Convenience method to create a GridData.
*/
protected static GridData createGridData(int numColumns, int style, int widthHint) {
- final GridData gd= new GridData(style);
- gd.horizontalSpan= numColumns;
- gd.widthHint= widthHint;
- return gd;
+ final GridData gd = new GridData(style);
+ gd.horizontalSpan = numColumns;
+ gd.widthHint = widthHint;
+ return gd;
}
-
- /*
- * Convenience method to create a label.
+ /*
+ * Convenience method to create a label.
*/
protected static Label createLabel(int numColumns, Composite parent, String text) {
return createLabel(numColumns, parent, text, GridData.FILL_HORIZONTAL);
}
-
+
/*
* Convenience method to create a label
*/
protected static Label createLabel(int numColumns, Composite parent, String text, int gridDataStyle) {
- final Label label= new Label(parent, SWT.WRAP);
+ final Label label = new Label(parent, SWT.WRAP);
label.setFont(parent.getFont());
label.setText(text);
-
- PixelConverter pixelConverter= new PixelConverter(parent);
- label.setLayoutData(createGridData(numColumns, gridDataStyle, pixelConverter.convertHorizontalDLUsToPixels(150)));
+
+ PixelConverter pixelConverter = new PixelConverter(parent);
+ label.setLayoutData(
+ createGridData(numColumns, gridDataStyle, pixelConverter.convertHorizontalDLUsToPixels(150)));
return label;
}
/*
* Convenience method to create a group
*/
- protected Group createGroup(int numColumns, Composite parent, String text ) {
- final Group group= new Group(parent, SWT.NONE);
+ protected Group createGroup(int numColumns, Composite parent, String text) {
+ final Group group = new Group(parent, SWT.NONE);
group.setFont(parent.getFont());
group.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
-
- final GridLayout layout= new GridLayout(numColumns, false);
- layout.verticalSpacing= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+
+ final GridLayout layout = new GridLayout(numColumns, false);
+ layout.verticalSpacing = fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing = fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ layout.marginHeight = fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
//layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
//layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
-
+
group.setLayout(layout);//createGridLayout(numColumns, true));
group.setText(text);
return group;
}
-
+
/*
- * Convenience method to create a NumberPreference. The widget is registered as
+ * Convenience method to create a NumberPreference. The widget is registered as
* a potential focus holder, and the default updater is added.
*/
protected NumberPreference createNumberPref(Composite composite, int numColumns, String name, String key,
- int minValue, int maxValue) {
- final NumberPreference pref= new NumberPreference(composite, numColumns, fWorkingValues,
- key, minValue, maxValue, name);
+ int minValue, int maxValue) {
+ final NumberPreference pref = new NumberPreference(composite, numColumns, fWorkingValues, key, minValue,
+ maxValue, name);
fDefaultFocusManager.add(pref);
pref.addObserver(fUpdater);
return pref;
}
-
+
/*
- * Convenience method to create a ComboPreference. The widget is registered as
+ * Convenience method to create a ComboPreference. The widget is registered as
* a potential focus holder, and the default updater is added.
*/
- protected ComboPreference createComboPref(Composite composite, int numColumns, String name,
- String key, String [] values, String [] items) {
- final ComboPreference pref= new ComboPreference(composite, numColumns,
- fWorkingValues, key, values, name, items);
+ protected ComboPreference createComboPref(Composite composite, int numColumns, String name, String key,
+ String[] values, String[] items) {
+ final ComboPreference pref = new ComboPreference(composite, numColumns, fWorkingValues, key, values, name,
+ items);
fDefaultFocusManager.add(pref);
pref.addObserver(fUpdater);
return pref;
}
/*
- * Convenience method to create a CheckboxPreference. The widget is registered as
+ * Convenience method to create a CheckboxPreference. The widget is registered as
* a potential focus holder, and the default updater is added.
*/
protected CheckboxPreference createCheckboxPref(Composite composite, int numColumns, String name, String key,
- String [] values) {
- final CheckboxPreference pref= new CheckboxPreference(composite, numColumns,
- fWorkingValues, key, values, name);
+ String[] values) {
+ final CheckboxPreference pref = new CheckboxPreference(composite, numColumns, fWorkingValues, key, values,
+ name);
fDefaultFocusManager.add(pref);
pref.addObserver(fUpdater);
return pref;
}
-
+
protected RadioPreference createRadioPref(Composite composite, int numColumns, String name, String key,
- String [] values) {
- final RadioPreference pref= new RadioPreference(composite, numColumns,
- fWorkingValues, key, values, name);
+ String[] values) {
+ final RadioPreference pref = new RadioPreference(composite, numColumns, fWorkingValues, key, values, name);
fDefaultFocusManager.add(pref);
pref.addObserver(fUpdater);
return pref;
}
-
/*
* Create a nice javadoc comment for some string.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPage.java
index 2c49dba2d52..32378e1ec4a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPage.java
@@ -23,16 +23,15 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
public class NewLinesTabPage extends FormatterTabPage {
- private final String PREVIEW=
- createPreviewHeader(FormatterMessages.NewLinesTabPage_preview_header) +
- "class Point {" + //$NON-NLS-1$
- "public:" + //$NON-NLS-1$
- "Point(double x, double y) : x(x), y(y) {" + //$NON-NLS-1$
- "}\n\n" + //$NON-NLS-1$
- "private:" + //$NON-NLS-1$
- "double x;" + //$NON-NLS-1$
- "double y;" + //$NON-NLS-1$
- "};"; //$NON-NLS-1$
+ private final String PREVIEW = createPreviewHeader(FormatterMessages.NewLinesTabPage_preview_header)
+ + "class Point {" + //$NON-NLS-1$
+ "public:" + //$NON-NLS-1$
+ "Point(double x, double y) : x(x), y(y) {" + //$NON-NLS-1$
+ "}\n\n" + //$NON-NLS-1$
+ "private:" + //$NON-NLS-1$
+ "double x;" + //$NON-NLS-1$
+ "double y;" + //$NON-NLS-1$
+ "};"; //$NON-NLS-1$
protected CheckboxPreference fThenStatementPref;
protected CheckboxPreference fSimpleIfPref;
@@ -45,52 +44,57 @@ public class NewLinesTabPage extends FormatterTabPage {
@Override
protected void doCreatePreferences(Composite composite, int numColumns) {
- final Group newlinesGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_newlines_group_title);
- createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_before_colon_in_constructor_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_COLON_IN_CONSTRUCTOR_INITIALIZER_LIST, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_anonymous_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_method_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_LABEL, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_enum_constant, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_annotation_decl_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION, DO_NOT_INSERT_INSERT);
-// createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_end_of_file, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, DO_NOT_INSERT_INSERT);
-
-// final Group arrayInitializerGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_arrayInitializer_group_title);
-// createPref(arrayInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, DO_NOT_INSERT_INSERT);
-// createPref(arrayInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, DO_NOT_INSERT_INSERT);
-
-// final Group emptyStatementsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_empty_statement_group_title);
-// createPref(emptyStatementsGroup, numColumns, FormatterMessages.NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line, DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, FALSE_TRUE);
-
-// final Group annotationsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_annotations_group_title);
-// createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_packages, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DO_NOT_INSERT_INSERT);
-// createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_types, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DO_NOT_INSERT_INSERT);
-// createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_fields, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DO_NOT_INSERT_INSERT);
-// createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_methods, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DO_NOT_INSERT_INSERT);
-// createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_paramters, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, DO_NOT_INSERT_INSERT);
-// createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_local_variables, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, DO_NOT_INSERT_INSERT);
+ final Group newlinesGroup = createGroup(numColumns, composite,
+ FormatterMessages.NewLinesTabPage_newlines_group_title);
+ createPref(newlinesGroup, numColumns,
+ FormatterMessages.NewLinesTabPage_newlines_group_option_before_colon_in_constructor_initializer_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_COLON_IN_CONSTRUCTOR_INITIALIZER_LIST,
+ DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_anonymous_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION, DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_method_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY, DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK, DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_LABEL, DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION, DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_enum_constant, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT, DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_annotation_decl_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION, DO_NOT_INSERT_INSERT);
+ // createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_end_of_file, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, DO_NOT_INSERT_INSERT);
+
+ // final Group arrayInitializerGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_arrayInitializer_group_title);
+ // createPref(arrayInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, DO_NOT_INSERT_INSERT);
+ // createPref(arrayInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, DO_NOT_INSERT_INSERT);
+
+ // final Group emptyStatementsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_empty_statement_group_title);
+ // createPref(emptyStatementsGroup, numColumns, FormatterMessages.NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line, DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, FALSE_TRUE);
+
+ // final Group annotationsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_annotations_group_title);
+ // createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_packages, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DO_NOT_INSERT_INSERT);
+ // createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_types, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DO_NOT_INSERT_INSERT);
+ // createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_fields, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DO_NOT_INSERT_INSERT);
+ // createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_methods, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DO_NOT_INSERT_INSERT);
+ // createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_paramters, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, DO_NOT_INSERT_INSERT);
+ // createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_local_variables, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, DO_NOT_INSERT_INSERT);
}
@Override
protected void initializePage() {
- fPreview.setPreviewText(PREVIEW);
+ fPreview.setPreviewText(PREVIEW);
}
- @Override
+ @Override
protected CPreview doCreateCPreview(Composite parent) {
- fPreview= new TranslationUnitPreview(fWorkingValues, parent);
- return fPreview;
- }
+ fPreview = new TranslationUnitPreview(fWorkingValues, parent);
+ return fPreview;
+ }
- @Override
+ @Override
protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
+ super.doUpdatePreview();
+ fPreview.update();
+ }
- private CheckboxPreference createPref(Composite composite, int numColumns, String message, String key, String[] values) {
+ private CheckboxPreference createPref(Composite composite, int numColumns, String message, String key,
+ String[] values) {
return createCheckboxPref(composite, numColumns, message, key, values);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java
index 0cc8b40e5b1..bd7f082156c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java
@@ -66,26 +66,26 @@ public abstract class ProfileConfigurationBlock {
@Override
public void update(Observable o, Object arg) {
try {
- fPreferenceListenerEnabled= false;
- final int value= ((Integer)arg).intValue();
- switch (value) {
- case ProfileManager.PROFILE_DELETED_EVENT:
- case ProfileManager.PROFILE_RENAMED_EVENT:
- case ProfileManager.PROFILE_CREATED_EVENT:
- case ProfileManager.SETTINGS_CHANGED_EVENT:
- try {
- fProfileStore.writeProfiles(fProfileManager.getSortedProfiles(), fInstanceScope); // update profile store
- fProfileManager.commitChanges(fCurrContext);
- } catch (CoreException x) {
- CUIPlugin.log(x);
- }
- break;
- case ProfileManager.SELECTION_CHANGED_EVENT:
- fProfileManager.commitChanges(fCurrContext);
- break;
- }
+ fPreferenceListenerEnabled = false;
+ final int value = ((Integer) arg).intValue();
+ switch (value) {
+ case ProfileManager.PROFILE_DELETED_EVENT:
+ case ProfileManager.PROFILE_RENAMED_EVENT:
+ case ProfileManager.PROFILE_CREATED_EVENT:
+ case ProfileManager.SETTINGS_CHANGED_EVENT:
+ try {
+ fProfileStore.writeProfiles(fProfileManager.getSortedProfiles(), fInstanceScope); // update profile store
+ fProfileManager.commitChanges(fCurrContext);
+ } catch (CoreException x) {
+ CUIPlugin.log(x);
+ }
+ break;
+ case ProfileManager.SELECTION_CHANGED_EVENT:
+ fProfileManager.commitChanges(fCurrContext);
+ break;
+ }
} finally {
- fPreferenceListenerEnabled= true;
+ fPreferenceListenerEnabled = true;
}
}
}
@@ -95,7 +95,7 @@ public abstract class ProfileConfigurationBlock {
private final List<Profile> fSortedProfiles;
public ProfileComboController() {
- fSortedProfiles= fProfileManager.getSortedProfiles();
+ fSortedProfiles = fProfileManager.getSortedProfiles();
fProfileCombo.addSelectionListener(this);
fProfileManager.addObserver(this);
updateProfiles();
@@ -104,17 +104,19 @@ public abstract class ProfileConfigurationBlock {
@Override
public void widgetSelected(SelectionEvent e) {
- final int index= fProfileCombo.getSelectionIndex();
+ final int index = fProfileCombo.getSelectionIndex();
fProfileManager.setSelected(fSortedProfiles.get(index));
}
@Override
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
@Override
public void update(Observable o, Object arg) {
- if (arg == null) return;
- final int value= ((Integer)arg).intValue();
+ if (arg == null)
+ return;
+ final int value = ((Integer) arg).intValue();
switch (value) {
case ProfileManager.PROFILE_CREATED_EVENT:
case ProfileManager.PROFILE_DELETED_EVENT:
@@ -150,17 +152,17 @@ public abstract class ProfileConfigurationBlock {
@Override
public void update(Observable o, Object arg) {
- Profile selected= ((ProfileManager)o).getSelected();
- final boolean notBuiltIn= !selected.isBuiltInProfile();
+ Profile selected = ((ProfileManager) o).getSelected();
+ final boolean notBuiltIn = !selected.isBuiltInProfile();
fDeleteButton.setEnabled(notBuiltIn);
}
@Override
public void widgetSelected(SelectionEvent e) {
- final Button button= (Button)e.widget;
+ final Button button = (Button) e.widget;
if (button == fEditButton)
modifyButtonPressed();
- else if (button == fDeleteButton)
+ else if (button == fDeleteButton)
deleteButtonPressed();
else if (button == fNewButton)
newButtonPressed();
@@ -173,72 +175,78 @@ public abstract class ProfileConfigurationBlock {
}
private void modifyButtonPressed() {
- final StatusDialog modifyDialog= createModifyDialog(fComposite.getShell(), fProfileManager.getSelected(), fProfileManager, fProfileStore, false);
+ final StatusDialog modifyDialog = createModifyDialog(fComposite.getShell(), fProfileManager.getSelected(),
+ fProfileManager, fProfileStore, false);
modifyDialog.open();
}
private void deleteButtonPressed() {
- if (MessageDialog.openQuestion(
- fComposite.getShell(),
- FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_title,
- Messages.format(FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_question, fProfileManager.getSelected().getName()))) {
+ if (MessageDialog.openQuestion(fComposite.getShell(),
+ FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_title,
+ Messages.format(FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_question,
+ fProfileManager.getSelected().getName()))) {
fProfileManager.deleteSelected();
}
}
private void newButtonPressed() {
- final CreateProfileDialog p= new CreateProfileDialog(fComposite.getShell(), fProfileManager, fProfileVersioner);
- if (p.open() != Window.OK)
+ final CreateProfileDialog p = new CreateProfileDialog(fComposite.getShell(), fProfileManager,
+ fProfileVersioner);
+ if (p.open() != Window.OK)
return;
- if (!p.openEditDialog())
+ if (!p.openEditDialog())
return;
- final StatusDialog modifyDialog= createModifyDialog(fComposite.getShell(), p.getCreatedProfile(), fProfileManager, fProfileStore, true);
+ final StatusDialog modifyDialog = createModifyDialog(fComposite.getShell(), p.getCreatedProfile(),
+ fProfileManager, fProfileStore, true);
modifyDialog.open();
}
private void loadButtonPressed() {
- final FileDialog dialog= new FileDialog(fComposite.getShell(), SWT.OPEN);
- dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_load_profile_dialog_title);
- dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$
- final String lastPath= CUIPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".loadpath"); //$NON-NLS-1$
+ final FileDialog dialog = new FileDialog(fComposite.getShell(), SWT.OPEN);
+ dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_load_profile_dialog_title);
+ dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$
+ final String lastPath = CUIPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".loadpath"); //$NON-NLS-1$
if (lastPath != null) {
dialog.setFilterPath(lastPath);
}
- final String path= dialog.open();
- if (path == null)
+ final String path = dialog.open();
+ if (path == null)
return;
CUIPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".loadpath", dialog.getFilterPath()); //$NON-NLS-1$
- final File file= new File(path);
- Collection<Profile> profiles= null;
+ final File file = new File(path);
+ Collection<Profile> profiles = null;
try {
- profiles= fProfileStore.readProfilesFromFile(file);
+ profiles = fProfileStore.readProfilesFromFile(file);
} catch (CoreException e) {
- final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title;
- final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_message;
+ final String title = FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title;
+ final String message = FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_message;
ExceptionHandler.handle(e, fComposite.getShell(), title, message);
}
if (profiles == null || profiles.isEmpty())
return;
- final CustomProfile profile= (CustomProfile)profiles.iterator().next();
-
+ final CustomProfile profile = (CustomProfile) profiles.iterator().next();
+
if (!fProfileVersioner.getProfileKind().equals(profile.getKind())) {
- final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title;
- final String message= Messages.format(FormatterMessages.ProfileConfigurationBlock_load_profile_wrong_profile_message, new String[] {fProfileVersioner.getProfileKind(), profile.getKind()});
+ final String title = FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title;
+ final String message = Messages.format(
+ FormatterMessages.ProfileConfigurationBlock_load_profile_wrong_profile_message,
+ new String[] { fProfileVersioner.getProfileKind(), profile.getKind() });
MessageDialog.openError(fComposite.getShell(), title, message);
return;
}
if (profile.getVersion() > fProfileVersioner.getCurrentVersion()) {
- final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title;
- final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message;
+ final String title = FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title;
+ final String message = FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message;
MessageDialog.openWarning(fComposite.getShell(), title, message);
}
if (fProfileManager.containsName(profile.getName())) {
- final AlreadyExistsDialog aeDialog= new AlreadyExistsDialog(fComposite.getShell(), profile, fProfileManager);
- if (aeDialog.open() != Window.OK)
+ final AlreadyExistsDialog aeDialog = new AlreadyExistsDialog(fComposite.getShell(), profile,
+ fProfileManager);
+ if (aeDialog.open() != Window.OK)
return;
}
fProfileVersioner.update(profile);
@@ -255,7 +263,7 @@ public abstract class ProfileConfigurationBlock {
private Button fDeleteButton;
private Button fNewButton;
private Button fLoadButton;
-
+
private PixelConverter fPixConv;
/**
* The ProfileManager, the model of this page.
@@ -272,34 +280,34 @@ public abstract class ProfileConfigurationBlock {
public ProfileConfigurationBlock(IProject project, final PreferencesAccess access, String lastSaveLoadPathKey) {
- fPreferenceAccess= access;
- fLastSaveLoadPathKey= lastSaveLoadPathKey;
+ fPreferenceAccess = access;
+ fLastSaveLoadPathKey = lastSaveLoadPathKey;
- fProfileVersioner= createProfileVersioner();
- fProfileStore= createProfileStore(fProfileVersioner);
- fInstanceScope= access.getInstanceScope();
+ fProfileVersioner = createProfileVersioner();
+ fProfileStore = createProfileStore(fProfileVersioner);
+ fInstanceScope = access.getInstanceScope();
if (project != null) {
- fCurrContext= access.getProjectScope(project);
+ fCurrContext = access.getProjectScope(project);
} else {
- fCurrContext= fInstanceScope;
+ fCurrContext = fInstanceScope;
}
- List<Profile> profiles= null;
- try {
- profiles= fProfileStore.readProfiles(fInstanceScope);
- } catch (CoreException e) {
- CUIPlugin.log(e);
- }
-
- if (profiles == null)
- profiles= new ArrayList<Profile>();
+ List<Profile> profiles = null;
+ try {
+ profiles = fProfileStore.readProfiles(fInstanceScope);
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+
+ if (profiles == null)
+ profiles = new ArrayList<Profile>();
- fProfileManager= createProfileManager(profiles, fCurrContext, access, fProfileVersioner);
+ fProfileManager = createProfileManager(profiles, fCurrContext, access, fProfileVersioner);
new StoreUpdater();
-
- fPreferenceListenerEnabled= true;
- fPreferenceListener= new IPreferenceChangeListener() {
+
+ fPreferenceListenerEnabled = true;
+ fPreferenceListener = new IPreferenceChangeListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (fPreferenceListenerEnabled) {
@@ -312,26 +320,28 @@ public abstract class ProfileConfigurationBlock {
}
protected void preferenceChanged(PreferenceChangeEvent event) {
-
+
}
protected abstract IProfileVersioner createProfileVersioner();
-
+
protected abstract ProfileStore createProfileStore(IProfileVersioner versioner);
-
- protected abstract ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner);
-
- protected abstract ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile);
+
+ protected abstract ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context,
+ PreferencesAccess access, IProfileVersioner profileVersioner);
+
+ protected abstract ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager,
+ ProfileStore profileStore, boolean newProfile);
protected abstract void configurePreview(Composite composite, int numColumns, ProfileManager profileManager);
private static Button createButton(Composite composite, String text, final int style) {
- final Button button= new Button(composite, SWT.PUSH);
+ final Button button = new Button(composite, SWT.PUSH);
button.setFont(composite.getFont());
button.setText(text);
- final GridData gd= new GridData(style);
- gd.widthHint= SWTUtil.getButtonWidthHint(button);
+ final GridData gd = new GridData(style);
+ gd.widthHint = SWTUtil.getButtonWidthHint(button);
button.setLayoutData(gd);
return button;
}
@@ -348,12 +358,16 @@ public abstract class ProfileConfigurationBlock {
fPixConv = new PixelConverter(parent);
fComposite = createComposite(parent, numColumns);
- fProfileCombo= createProfileCombo(fComposite, 3, fPixConv.convertWidthInCharsToPixels(20));
- fEditButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_edit_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING);
- fDeleteButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_remove_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING);
+ fProfileCombo = createProfileCombo(fComposite, 3, fPixConv.convertWidthInCharsToPixels(20));
+ fEditButton = createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_edit_button_desc,
+ GridData.HORIZONTAL_ALIGN_BEGINNING);
+ fDeleteButton = createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_remove_button_desc,
+ GridData.HORIZONTAL_ALIGN_BEGINNING);
- fNewButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_new_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING);
- fLoadButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_load_button_desc, GridData.HORIZONTAL_ALIGN_END);
+ fNewButton = createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_new_button_desc,
+ GridData.HORIZONTAL_ALIGN_BEGINNING);
+ fLoadButton = createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_load_button_desc,
+ GridData.HORIZONTAL_ALIGN_END);
createLabel(fComposite, "", 3); //$NON-NLS-1$
configurePreview(fComposite, numColumns, fProfileManager);
@@ -367,9 +381,9 @@ public abstract class ProfileConfigurationBlock {
private static Combo createProfileCombo(Composite composite, int span, int widthHint) {
final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = span;
- gd.widthHint= widthHint;
+ gd.widthHint = widthHint;
- final Combo combo= new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY );
+ final Combo combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
combo.setFont(composite.getFont());
combo.setLayoutData(gd);
return combo;
@@ -378,13 +392,13 @@ public abstract class ProfileConfigurationBlock {
protected static Label createLabel(Composite composite, String text, int numColumns) {
final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = numColumns;
- gd.widthHint= 0;
+ gd.widthHint = 0;
final Label label = new Label(composite, SWT.WRAP);
label.setFont(composite.getFont());
label.setText(text);
label.setLayoutData(gd);
- return label;
+ return label;
}
private Composite createComposite(Composite parent, int numColumns) {
@@ -423,9 +437,9 @@ public abstract class ProfileConfigurationBlock {
}
public void performDefaults() {
- Profile profile= fProfileManager.getDefaultProfile();
+ Profile profile = fProfileManager.getDefaultProfile();
if (profile != null) {
- int defaultIndex= fProfileManager.getSortedProfiles().indexOf(profile);
+ int defaultIndex = fProfileManager.getSortedProfiles().indexOf(profile);
if (defaultIndex != -1) {
fProfileManager.setSelected(profile);
}
@@ -434,8 +448,9 @@ public abstract class ProfileConfigurationBlock {
public void dispose() {
if (fPreferenceListener != null) {
- fPreferenceAccess.getInstanceScope().getNode(CUIPlugin.PLUGIN_ID).removePreferenceChangeListener(fPreferenceListener);
- fPreferenceListener= null;
+ fPreferenceAccess.getInstanceScope().getNode(CUIPlugin.PLUGIN_ID)
+ .removePreferenceChangeListener(fPreferenceListener);
+ fPreferenceListener = null;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java
index 3cb9a0abdb0..646c717af06 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java
@@ -43,50 +43,52 @@ import org.eclipse.cdt.internal.ui.util.Messages;
*/
public abstract class ProfileManager extends Observable {
private static final Map<String, String> EMPTY_MAP = Collections.emptyMap();
-
- public static final class KeySet {
+
+ public static final class KeySet {
private final List<String> fKeys;
private final String fNodeName;
public KeySet(String nodeName, List<String> keys) {
- fNodeName= nodeName;
- fKeys= keys;
- }
-
- public String getNodeName() {
- return fNodeName;
- }
-
- public List<String> getKeys() {
- return fKeys;
- }
- }
-
- /**
- * A prefix which is prepended to every ID of a user-defined profile, in order
- * to differentiate it from a built-in profile.
- */
- private final static String ID_PREFIX= "_"; //$NON-NLS-1$
-
+ fNodeName = nodeName;
+ fKeys = keys;
+ }
+
+ public String getNodeName() {
+ return fNodeName;
+ }
+
+ public List<String> getKeys() {
+ return fKeys;
+ }
+ }
+
/**
- * Represents a profile with a unique ID, a name and a map
+ * A prefix which is prepended to every ID of a user-defined profile, in order
+ * to differentiate it from a built-in profile.
+ */
+ private final static String ID_PREFIX = "_"; //$NON-NLS-1$
+
+ /**
+ * Represents a profile with a unique ID, a name and a map
* containing the code formatter settings.
*/
public static abstract class Profile implements Comparable<Profile> {
public abstract String getName();
+
public abstract Profile rename(String name, ProfileManager manager);
-
- public abstract Map<String,String> getSettings();
- public abstract void setSettings(Map<String,String> settings);
-
+
+ public abstract Map<String, String> getSettings();
+
+ public abstract void setSettings(Map<String, String> settings);
+
public abstract int getVersion();
-
- public boolean hasEqualSettings(Map<String,String> otherMap, Collection<String> allKeys) {
- Map<String,String> settings= getSettings();
+
+ public boolean hasEqualSettings(Map<String, String> otherMap, Collection<String> allKeys) {
+ Map<String, String> settings = getSettings();
for (Object element : allKeys) {
- String key= (String) element;
- Object other= otherMap.get(key);
- Object curr= settings.get(key);
+ String key = (String) element;
+ Object other = otherMap.get(key);
+ Object curr = settings.get(key);
if (other == null) {
if (curr != null) {
return false;
@@ -97,72 +99,73 @@ public abstract class ProfileManager extends Observable {
}
return true;
}
-
+
public abstract boolean isProfileToSave();
-
+
public abstract String getID();
-
+
public boolean isSharedProfile() {
return false;
}
-
+
public boolean isBuiltInProfile() {
return false;
}
}
-
+
/**
- * Represents a built-in profile. The state of a built-in profile
+ * Represents a built-in profile. The state of a built-in profile
* cannot be changed after instantiation.
*/
public final static class BuiltInProfile extends Profile {
private final String fName;
private final String fID;
- private final Map<String,String> fSettings;
+ private final Map<String, String> fSettings;
private final int fOrder;
private final int fCurrentVersion;
private final String fProfileKind;
-
- protected BuiltInProfile(String ID, String name, Map<String,String> settings, int order, int currentVersion, String profileKind) {
- fName= TextProcessor.process(name);
- fID= ID;
- fSettings= settings;
- fOrder= order;
- fCurrentVersion= currentVersion;
- fProfileKind= profileKind;
- }
-
+
+ protected BuiltInProfile(String ID, String name, Map<String, String> settings, int order, int currentVersion,
+ String profileKind) {
+ fName = TextProcessor.process(name);
+ fID = ID;
+ fSettings = settings;
+ fOrder = order;
+ fCurrentVersion = currentVersion;
+ fProfileKind = profileKind;
+ }
+
@Override
- public String getName() {
- return fName;
+ public String getName() {
+ return fName;
}
-
+
@Override
public Profile rename(String name, ProfileManager manager) {
- final String trimmed= name.trim();
- CustomProfile newProfile= new CustomProfile(trimmed, fSettings, fCurrentVersion, fProfileKind);
- manager.addProfile(newProfile);
+ final String trimmed = name.trim();
+ CustomProfile newProfile = new CustomProfile(trimmed, fSettings, fCurrentVersion, fProfileKind);
+ manager.addProfile(newProfile);
return newProfile;
}
-
+
@Override
- public Map<String,String> getSettings() {
+ public Map<String, String> getSettings() {
return fSettings;
}
-
+
@Override
- public void setSettings(Map<String,String> settings) {
+ public void setSettings(Map<String, String> settings) {
}
-
+
@Override
- public String getID() {
- return fID;
+ public String getID() {
+ return fID;
}
-
+
@Override
public final int compareTo(Profile o) {
if (o instanceof BuiltInProfile) {
- return fOrder - ((BuiltInProfile)o).fOrder;
+ return fOrder - ((BuiltInProfile) o).fOrder;
}
return -1;
}
@@ -171,16 +174,16 @@ public abstract class ProfileManager extends Observable {
public boolean isProfileToSave() {
return false;
}
-
+
@Override
public boolean isBuiltInProfile() {
return true;
}
- @Override
+ @Override
public int getVersion() {
- return fCurrentVersion;
- }
+ return fCurrentVersion;
+ }
}
/**
@@ -188,60 +191,60 @@ public abstract class ProfileManager extends Observable {
*/
public static class CustomProfile extends Profile {
private String fName;
- private Map<String,String> fSettings;
+ private Map<String, String> fSettings;
protected ProfileManager fManager;
private int fVersion;
private final String fKind;
- public CustomProfile(String name, Map<String,String> settings, int version, String kind) {
- fName= name;
- fSettings= settings;
- fVersion= version;
- fKind= kind;
+ public CustomProfile(String name, Map<String, String> settings, int version, String kind) {
+ fName = name;
+ fSettings = settings;
+ fVersion = version;
+ fKind = kind;
}
-
+
@Override
public String getName() {
return fName;
}
-
+
@Override
public Profile rename(String name, ProfileManager manager) {
- final String trimmed= name.trim();
- if (trimmed.equals(getName()))
+ final String trimmed = name.trim();
+ if (trimmed.equals(getName()))
return this;
-
- String oldID= getID(); // remember old id before changing name
- fName= trimmed;
-
+
+ String oldID = getID(); // remember old id before changing name
+ fName = trimmed;
+
manager.profileRenamed(this, oldID);
return this;
}
@Override
- public Map<String,String> getSettings() {
+ public Map<String, String> getSettings() {
return fSettings;
}
-
+
@Override
- public void setSettings(Map<String,String> settings) {
+ public void setSettings(Map<String, String> settings) {
if (settings == null)
throw new IllegalArgumentException();
- fSettings= settings;
+ fSettings = settings;
if (fManager != null) {
fManager.profileChanged(this);
}
}
-
+
@Override
- public String getID() {
+ public String getID() {
return ID_PREFIX + fName;
}
-
+
public void setManager(ProfileManager profileManager) {
- fManager= profileManager;
+ fManager = profileManager;
}
-
+
public ProfileManager getManager() {
return fManager;
}
@@ -250,11 +253,11 @@ public abstract class ProfileManager extends Observable {
public int getVersion() {
return fVersion;
}
-
- public void setVersion(int version) {
- fVersion= version;
+
+ public void setVersion(int version) {
+ fVersion = version;
}
-
+
@Override
public int compareTo(Profile o) {
if (o instanceof SharedProfile) {
@@ -265,47 +268,47 @@ public abstract class ProfileManager extends Observable {
}
return 1;
}
-
+
@Override
public boolean isProfileToSave() {
return true;
}
- public String getKind() {
- return fKind;
- }
+ public String getKind() {
+ return fKind;
+ }
}
-
+
public final static class SharedProfile extends CustomProfile {
-
- public SharedProfile(String oldName, Map<String,String> options, int version, String profileKind) {
+
+ public SharedProfile(String oldName, Map<String, String> options, int version, String profileKind) {
super(oldName, options, version, profileKind);
}
-
+
@Override
public Profile rename(String name, ProfileManager manager) {
- CustomProfile profile= new CustomProfile(name.trim(), getSettings(), getVersion(), getKind());
+ CustomProfile profile = new CustomProfile(name.trim(), getSettings(), getVersion(), getKind());
manager.profileReplaced(this, profile);
return profile;
}
-
+
@Override
- public String getID() {
+ public String getID() {
return SHARED_PROFILE;
}
-
+
@Override
public final int compareTo(Profile o) {
return 1;
}
-
+
@Override
public boolean isProfileToSave() {
return false;
}
-
+
@Override
public boolean isSharedProfile() {
return true;
@@ -315,39 +318,39 @@ public abstract class ProfileManager extends Observable {
/**
* The possible events for observers listening to this class.
*/
- public final static int SELECTION_CHANGED_EVENT= 1;
- public final static int PROFILE_DELETED_EVENT= 2;
- public final static int PROFILE_RENAMED_EVENT= 3;
- public final static int PROFILE_CREATED_EVENT= 4;
- public final static int SETTINGS_CHANGED_EVENT= 5;
+ public final static int SELECTION_CHANGED_EVENT = 1;
+ public final static int PROFILE_DELETED_EVENT = 2;
+ public final static int PROFILE_RENAMED_EVENT = 3;
+ public final static int PROFILE_CREATED_EVENT = 4;
+ public final static int SETTINGS_CHANGED_EVENT = 5;
/**
* The key of the preference where the selected profile is stored.
*/
private final String fProfileKey;
-
+
/**
* The key of the preference where the version of the current settings is stored
*/
private final String fProfileVersionKey;
- public final static String SHARED_PROFILE= "org.eclipse.cdt.ui.default.shared"; //$NON-NLS-1$
-
+ public final static String SHARED_PROFILE = "org.eclipse.cdt.ui.default.shared"; //$NON-NLS-1$
+
/**
* A map containing the available profiles, using the IDs as keys.
*/
- private final Map<String,Profile> fProfiles;
-
+ private final Map<String, Profile> fProfiles;
+
/**
* The available profiles, sorted by name.
*/
private final List<Profile> fProfilesByName;
-
+
/**
- * The currently selected profile.
+ * The currently selected profile.
*/
private Profile fSelected;
-
+
/**
* The keys of the options to be saved with each profile
*/
@@ -355,72 +358,66 @@ public abstract class ProfileManager extends Observable {
private final PreferencesAccess fPreferencesAccess;
private final IProfileVersioner fProfileVersioner;
-
+
/**
* Create and initialize a new profile manager.
* @param profiles Initial custom profiles (List of type <code>CustomProfile</code>)
- * @param profileVersioner
+ * @param profileVersioner
*/
- public ProfileManager(
- List<Profile> profiles,
- IScopeContext context,
- PreferencesAccess preferencesAccess,
- IProfileVersioner profileVersioner,
- KeySet[] keySets,
- String profileKey,
- String profileVersionKey) {
- fPreferencesAccess= preferencesAccess;
- fProfileVersioner= profileVersioner;
- fKeySets= keySets;
- fProfileKey= profileKey;
- fProfileVersionKey= profileVersionKey;
-
- fProfiles= new HashMap<String, Profile>();
- fProfilesByName= new ArrayList<Profile>();
-
+ public ProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess preferencesAccess,
+ IProfileVersioner profileVersioner, KeySet[] keySets, String profileKey, String profileVersionKey) {
+ fPreferencesAccess = preferencesAccess;
+ fProfileVersioner = profileVersioner;
+ fKeySets = keySets;
+ fProfileKey = profileKey;
+ fProfileVersionKey = profileVersionKey;
+
+ fProfiles = new HashMap<String, Profile>();
+ fProfilesByName = new ArrayList<Profile>();
+
for (Object element : profiles) {
- final Profile profile= (Profile) element;
+ final Profile profile = (Profile) element;
if (profile instanceof CustomProfile) {
- ((CustomProfile)profile).setManager(this);
+ ((CustomProfile) profile).setManager(this);
}
fProfiles.put(profile.getID(), profile);
fProfilesByName.add(profile);
}
Collections.sort(fProfilesByName);
-
- String profileId= getSelectedProfileId(fPreferencesAccess.getInstanceScope());
-
- Profile profile= fProfiles.get(profileId);
+
+ String profileId = getSelectedProfileId(fPreferencesAccess.getInstanceScope());
+
+ Profile profile = fProfiles.get(profileId);
if (profile == null) {
- profile= getDefaultProfile();
+ profile = getDefaultProfile();
}
- fSelected= profile;
-
+ fSelected = profile;
+
if (context.getName() == ProjectScope.SCOPE && hasProjectSpecificSettings(context)) {
- Map<String, String> map= readFromPreferenceStore(context, profile);
+ Map<String, String> map = readFromPreferenceStore(context, profile);
if (map != null) {
-
- List<String> allKeys= new ArrayList<String>();
+
+ List<String> allKeys = new ArrayList<String>();
for (KeySet keySet : fKeySets) {
- allKeys.addAll(keySet.getKeys());
- }
- Collections.sort(allKeys);
-
- Profile matching= null;
-
- String projProfileId= context.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
+ allKeys.addAll(keySet.getKeys());
+ }
+ Collections.sort(allKeys);
+
+ Profile matching = null;
+
+ String projProfileId = context.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
if (projProfileId != null) {
- Profile curr= fProfiles.get(projProfileId);
+ Profile curr = fProfiles.get(projProfileId);
if (curr != null && (curr.isBuiltInProfile() || curr.hasEqualSettings(map, allKeys))) {
- matching= curr;
+ matching = curr;
}
} else {
// old version: look for similar
for (Object element : fProfilesByName) {
- Profile curr= (Profile) element;
+ Profile curr = (Profile) element;
if (curr.hasEqualSettings(map, allKeys)) {
- matching= curr;
+ matching = curr;
break;
}
}
@@ -428,35 +425,37 @@ public abstract class ProfileManager extends Observable {
if (matching == null) {
String name;
if (projProfileId != null && !fProfiles.containsKey(projProfileId)) {
- name= Messages.format(FormatterMessages.ProfileManager_unmanaged_profile_with_name, projProfileId.substring(ID_PREFIX.length()));
+ name = Messages.format(FormatterMessages.ProfileManager_unmanaged_profile_with_name,
+ projProfileId.substring(ID_PREFIX.length()));
} else {
- name= FormatterMessages.ProfileManager_unmanaged_profile;
+ name = FormatterMessages.ProfileManager_unmanaged_profile;
}
// current settings do not correspond to any profile -> create a 'team' profile
- SharedProfile shared= new SharedProfile(name, map, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());
+ SharedProfile shared = new SharedProfile(name, map, fProfileVersioner.getCurrentVersion(),
+ fProfileVersioner.getProfileKind());
shared.setManager(this);
fProfiles.put(shared.getID(), shared);
fProfilesByName.add(shared); // add last
- matching= shared;
+ matching = shared;
}
- fSelected= matching;
+ fSelected = matching;
}
}
}
-
+
protected String getSelectedProfileId(IScopeContext instanceScope) {
- String profileId= instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
+ String profileId = instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
if (profileId == null) {
// request from bug 129427
- profileId= DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
+ profileId = DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
}
- return profileId;
- }
+ return profileId;
+ }
/**
* Notify observers with a message. The message must be one of the following:
* @param message Message to send out
- *
+ *
* @see #SELECTION_CHANGED_EVENT
* @see #PROFILE_DELETED_EVENT
* @see #PROFILE_RENAMED_EVENT
@@ -467,21 +466,21 @@ public abstract class ProfileManager extends Observable {
setChanged();
notifyObservers(Integer.valueOf(message));
}
-
+
public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) {
for (KeySet keySet : keySets) {
- IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
- for (Object element : keySet.getKeys()) {
- final String key= (String)element;
- Object val= preferences.get(key, null);
- if (val != null) {
- return true;
- }
- }
- }
+ IEclipsePreferences preferences = context.getNode(keySet.getNodeName());
+ for (Object element : keySet.getKeys()) {
+ final String key = (String) element;
+ Object val = preferences.get(key, null);
+ if (val != null) {
+ return true;
+ }
+ }
+ }
return false;
}
-
+
public boolean hasProjectSpecificSettings(IScopeContext context) {
return hasProjectSpecificSettings(context, fKeySets);
}
@@ -491,51 +490,51 @@ public abstract class ProfileManager extends Observable {
* @param context The project context
*/
public Map<String, String> readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
- final Map<String, String> profileOptions= new HashMap<String, String>();
- IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
-
- int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
+ final Map<String, String> profileOptions = new HashMap<String, String>();
+ IEclipsePreferences uiPrefs = context.getNode(CUIPlugin.PLUGIN_ID);
+
+ int version = uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
if (version != fProfileVersioner.getCurrentVersion()) {
- Map<String, String> allOptions= new HashMap<String, String>();
+ Map<String, String> allOptions = new HashMap<String, String>();
for (KeySet keySet : fKeySets) {
- addAll(context.getNode(keySet.getNodeName()), allOptions);
- }
- CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
+ addAll(context.getNode(keySet.getNodeName()), allOptions);
+ }
+ CustomProfile profile = new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
fProfileVersioner.update(profile);
return profile.getSettings();
}
-
- boolean hasValues= false;
+
+ boolean hasValues = false;
for (KeySet keySet : fKeySets) {
- IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
- for (Object element : keySet.getKeys()) {
- final String key= (String) element;
- String val= preferences.get(key, null);
+ IEclipsePreferences preferences = context.getNode(keySet.getNodeName());
+ for (Object element : keySet.getKeys()) {
+ final String key = (String) element;
+ String val = preferences.get(key, null);
if (val != null) {
- hasValues= true;
+ hasValues = true;
} else {
- val= workspaceProfile.getSettings().get(key);
+ val = workspaceProfile.getSettings().get(key);
}
profileOptions.put(key, val);
}
- }
-
+ }
+
if (!hasValues) {
return null;
}
return profileOptions;
}
-
+
/**
* @param uiPrefs
* @param allOptions
*/
- private void addAll(IEclipsePreferences uiPrefs, Map<String,String> allOptions) {
+ private void addAll(IEclipsePreferences uiPrefs, Map<String, String> allOptions) {
try {
- String[] keys= uiPrefs.keys();
+ String[] keys = uiPrefs.keys();
for (String key : keys) {
- String val= uiPrefs.get(key, null);
+ String val = uiPrefs.get(key, null);
if (val != null) {
allOptions.put(key, val);
}
@@ -545,54 +544,55 @@ public abstract class ProfileManager extends Observable {
}
}
- private boolean updatePreferences(IEclipsePreferences prefs, List<String> keys, Map<String,String> profileOptions) {
- boolean hasChanges= false;
+ private boolean updatePreferences(IEclipsePreferences prefs, List<String> keys,
+ Map<String, String> profileOptions) {
+ boolean hasChanges = false;
for (Object element : keys) {
- final String key= (String) element;
- final String oldVal= prefs.get(key, null);
- final String val= profileOptions.get(key);
+ final String key = (String) element;
+ final String oldVal = prefs.get(key, null);
+ final String val = profileOptions.get(key);
if (val == null) {
if (oldVal != null) {
prefs.remove(key);
- hasChanges= true;
+ hasChanges = true;
}
} else if (!val.equals(oldVal)) {
prefs.put(key, val);
- hasChanges= true;
+ hasChanges = true;
}
}
return hasChanges;
}
-
+
/**
- * Update all formatter settings with the settings of the specified profile.
+ * Update all formatter settings with the settings of the specified profile.
* @param profile The profile to write to the preference store
*/
private void writeToPreferenceStore(Profile profile, IScopeContext context) {
- final Map<String,String> profileOptions= profile.getSettings();
-
+ final Map<String, String> profileOptions = profile.getSettings();
+
for (KeySet keySet : fKeySets) {
- updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), profileOptions);
- }
-
- final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
+ updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), profileOptions);
+ }
+
+ final IEclipsePreferences uiPrefs = context.getNode(CUIPlugin.PLUGIN_ID);
if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
}
-
+
if (context.getName() == InstanceScope.SCOPE) {
uiPrefs.put(fProfileKey, profile.getID());
} else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
uiPrefs.put(fProfileKey, profile.getID());
}
}
-
- /**
- * Get an immutable list as view on all profiles, sorted alphabetically. Unless the set
- * of profiles has been modified between the two calls, the sequence is guaranteed to
+
+ /**
+ * Get an immutable list as view on all profiles, sorted alphabetically. Unless the set
+ * of profiles has been modified between the two calls, the sequence is guaranteed to
* correspond to the one returned by <code>getSortedNames</code>.
* @return a list of elements of type <code>Profile</code>
- *
+ *
* @see #getSortedDisplayNames()
*/
public List<Profile> getSortedProfiles() {
@@ -600,31 +600,31 @@ public abstract class ProfileManager extends Observable {
}
/**
- * Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the set of
- * profiles has been modified between the two calls, the sequence is guaranteed to correspond to the one
+ * Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the set of
+ * profiles has been modified between the two calls, the sequence is guaranteed to correspond to the one
* returned by <code>getSortedProfiles</code>.
* @return All names, sorted alphabetically
- * @see #getSortedProfiles()
- */
+ * @see #getSortedProfiles()
+ */
public String[] getSortedDisplayNames() {
- final String[] sortedNames= new String[fProfilesByName.size()];
- int i= 0;
+ final String[] sortedNames = new String[fProfilesByName.size()];
+ int i = 0;
for (Object element : fProfilesByName) {
- Profile curr= (Profile) element;
- sortedNames[i++]= curr.getName();
+ Profile curr = (Profile) element;
+ sortedNames[i++] = curr.getName();
}
return sortedNames;
}
-
+
/**
* Get the profile for this profile id.
* @param ID The profile ID
- * @return The profile with the given ID or <code>null</code>
+ * @return The profile with the given ID or <code>null</code>
*/
public Profile getProfile(String ID) {
return fProfiles.get(ID);
}
-
+
/**
* Activate the selected profile, update all necessary options in
* preferences and save profiles to disk.
@@ -634,16 +634,16 @@ public abstract class ProfileManager extends Observable {
writeToPreferenceStore(fSelected, scopeContext);
}
}
-
+
public void clearAllSettings(IScopeContext context) {
for (KeySet keySet : fKeySets) {
- updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), EMPTY_MAP);
- }
-
- final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
+ updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), EMPTY_MAP);
+ }
+
+ final IEclipsePreferences uiPrefs = context.getNode(CUIPlugin.PLUGIN_ID);
uiPrefs.remove(fProfileKey);
}
-
+
/**
* Get the currently selected profile.
* @return The currently selected profile.
@@ -657,9 +657,9 @@ public abstract class ProfileManager extends Observable {
* @param profile The profile to select
*/
public void setSelected(Profile profile) {
- final Profile newSelected= fProfiles.get(profile.getID());
+ final Profile newSelected = fProfiles.get(profile.getID());
if (newSelected != null && !newSelected.equals(fSelected)) {
- fSelected= newSelected;
+ fSelected = newSelected;
notifyObservers(SELECTION_CHANGED_EVENT);
}
}
@@ -672,21 +672,21 @@ public abstract class ProfileManager extends Observable {
*/
public boolean containsName(String name) {
for (Object element : fProfilesByName) {
- Profile curr= (Profile) element;
+ Profile curr = (Profile) element;
if (name.equals(curr.getName())) {
return true;
}
}
return false;
}
-
+
/**
* Add a new custom profile to this profile manager.
* @param profile The profile to add
- */
+ */
public void addProfile(CustomProfile profile) {
profile.setManager(this);
- final CustomProfile oldProfile= (CustomProfile)fProfiles.get(profile.getID());
+ final CustomProfile oldProfile = (CustomProfile) fProfiles.get(profile.getID());
if (oldProfile != null) {
fProfiles.remove(oldProfile.getID());
fProfilesByName.remove(oldProfile);
@@ -695,42 +695,42 @@ public abstract class ProfileManager extends Observable {
fProfiles.put(profile.getID(), profile);
fProfilesByName.add(profile);
Collections.sort(fProfilesByName);
- fSelected= profile;
+ fSelected = profile;
notifyObservers(PROFILE_CREATED_EVENT);
}
-
+
/**
* Delete the currently selected profile from this profile manager. The next profile
* in the list is selected.
* @return true if the profile has been successfully removed, false otherwise.
*/
public boolean deleteSelected() {
- if (!(fSelected instanceof CustomProfile))
+ if (!(fSelected instanceof CustomProfile))
return false;
-
- return deleteProfile((CustomProfile)fSelected);
+
+ return deleteProfile((CustomProfile) fSelected);
}
public boolean deleteProfile(CustomProfile profile) {
- int index= fProfilesByName.indexOf(profile);
-
+ int index = fProfilesByName.indexOf(profile);
+
fProfiles.remove(profile.getID());
fProfilesByName.remove(profile);
-
+
profile.setManager(null);
-
+
if (index >= fProfilesByName.size())
index--;
- fSelected= fProfilesByName.get(index);
+ fSelected = fProfilesByName.get(index);
if (!profile.isSharedProfile()) {
updateProfilesWithName(profile.getID(), null, false);
}
-
+
notifyObservers(PROFILE_DELETED_EVENT);
return true;
- }
-
+ }
+
public void profileRenamed(CustomProfile profile, String oldID) {
fProfiles.remove(oldID);
fProfiles.put(profile.getID(), profile);
@@ -738,41 +738,41 @@ public abstract class ProfileManager extends Observable {
if (!profile.isSharedProfile()) {
updateProfilesWithName(oldID, profile, false);
}
-
+
Collections.sort(fProfilesByName);
notifyObservers(PROFILE_RENAMED_EVENT);
}
-
+
public void profileReplaced(CustomProfile oldProfile, CustomProfile newProfile) {
fProfiles.remove(oldProfile.getID());
fProfiles.put(newProfile.getID(), newProfile);
fProfilesByName.remove(oldProfile);
fProfilesByName.add(newProfile);
Collections.sort(fProfilesByName);
-
+
if (!oldProfile.isSharedProfile()) {
updateProfilesWithName(oldProfile.getID(), null, false);
}
-
+
setSelected(newProfile);
notifyObservers(PROFILE_CREATED_EVENT);
notifyObservers(SELECTION_CHANGED_EVENT);
}
-
+
public void profileChanged(CustomProfile profile) {
if (!profile.isSharedProfile()) {
updateProfilesWithName(profile.getID(), profile, true);
}
-
+
notifyObservers(SETTINGS_CHANGED_EVENT);
}
-
+
private void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
- IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
- IScopeContext projectScope= fPreferencesAccess.getProjectScope(project);
- IEclipsePreferences node= projectScope.getNode(CUIPlugin.PLUGIN_ID);
- String profileId= node.get(fProfileKey, null);
+ IScopeContext projectScope = fPreferencesAccess.getProjectScope(project);
+ IEclipsePreferences node = projectScope.getNode(CUIPlugin.PLUGIN_ID);
+ String profileId = node.get(fProfileKey, null);
if (oldName.equals(profileId)) {
if (newProfile == null) {
node.remove(fProfileKey);
@@ -785,9 +785,9 @@ public abstract class ProfileManager extends Observable {
}
}
}
-
- IScopeContext instanceScope= fPreferencesAccess.getInstanceScope();
- final IEclipsePreferences uiPrefs= instanceScope.getNode(CUIPlugin.PLUGIN_ID);
+
+ IScopeContext instanceScope = fPreferencesAccess.getInstanceScope();
+ final IEclipsePreferences uiPrefs = instanceScope.getNode(CUIPlugin.PLUGIN_ID);
if (newProfile != null && oldName.equals(uiPrefs.get(fProfileKey, null))) {
writeToPreferenceStore(newProfile, instanceScope);
}
@@ -796,11 +796,11 @@ public abstract class ProfileManager extends Observable {
/**
* @return Default scoped profile or null
*/
- public Profile getDefaultProfile() {
+ public Profile getDefaultProfile() {
return getProfile(fPreferencesAccess.getDefaultScope().getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, "")); //$NON-NLS-1$
- }
+ }
public IProfileVersioner getProfileVersioner() {
- return fProfileVersioner;
- }
+ return fProfileVersioner;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java
index d61eb134a81..f9ebe1e65ef 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java
@@ -61,65 +61,64 @@ import org.eclipse.cdt.internal.ui.CUIStatus;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
-
public class ProfileStore {
/** The default encoding to use */
- public static final String ENCODING= "UTF-8"; //$NON-NLS-1$
-
- protected static final String VERSION_KEY_SUFFIX= ".version"; //$NON-NLS-1$
-
+ public static final String ENCODING = "UTF-8"; //$NON-NLS-1$
+
+ protected static final String VERSION_KEY_SUFFIX = ".version"; //$NON-NLS-1$
+
/**
- * A SAX event handler to parse the xml format for profiles.
+ * A SAX event handler to parse the xml format for profiles.
*/
private final static class ProfileDefaultHandler extends DefaultHandler {
private List<Profile> fProfiles;
private int fVersion;
-
+
private String fName;
private Map<String, String> fSettings;
private String fKind;
@Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
if (qName.equals(XML_NODE_SETTING)) {
- final String key= attributes.getValue(XML_ATTRIBUTE_ID);
- final String value= attributes.getValue(XML_ATTRIBUTE_VALUE);
+ final String key = attributes.getValue(XML_ATTRIBUTE_ID);
+ final String value = attributes.getValue(XML_ATTRIBUTE_VALUE);
fSettings.put(key, value);
} else if (qName.equals(XML_NODE_PROFILE)) {
- fName= attributes.getValue(XML_ATTRIBUTE_NAME);
- fKind= attributes.getValue(XML_ATTRIBUTE_PROFILE_KIND);
+ fName = attributes.getValue(XML_ATTRIBUTE_NAME);
+ fKind = attributes.getValue(XML_ATTRIBUTE_PROFILE_KIND);
if (fKind == null) //Can only be an CodeFormatterProfile created pre 20061106
- fKind= ProfileVersioner.CODE_FORMATTER_PROFILE_KIND;
-
- fSettings= new HashMap<String, String>(200);
+ fKind = ProfileVersioner.CODE_FORMATTER_PROFILE_KIND;
- }
- else if (qName.equals(XML_NODE_ROOT)) {
+ fSettings = new HashMap<String, String>(200);
+
+ } else if (qName.equals(XML_NODE_ROOT)) {
- fProfiles= new ArrayList<Profile>();
+ fProfiles = new ArrayList<Profile>();
try {
- fVersion= Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
+ fVersion = Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
} catch (NumberFormatException ex) {
throw new SAXException(ex);
}
}
}
-
+
@Override
public void endElement(String uri, String localName, String qName) {
if (qName.equals(XML_NODE_PROFILE)) {
fProfiles.add(new CustomProfile(fName, fSettings, fVersion, fKind));
- fName= null;
- fSettings= null;
- fKind= null;
+ fName = null;
+ fSettings = null;
+ fKind = null;
}
}
-
+
public List<Profile> getProfiles() {
return fProfiles;
}
@@ -128,27 +127,26 @@ public class ProfileStore {
/**
* Identifiers for the XML file.
*/
- private final static String XML_NODE_ROOT= "profiles"; //$NON-NLS-1$
- private final static String XML_NODE_PROFILE= "profile"; //$NON-NLS-1$
- private final static String XML_NODE_SETTING= "setting"; //$NON-NLS-1$
-
- private final static String XML_ATTRIBUTE_VERSION= "version"; //$NON-NLS-1$
- private final static String XML_ATTRIBUTE_ID= "id"; //$NON-NLS-1$
- private final static String XML_ATTRIBUTE_NAME= "name"; //$NON-NLS-1$
- private final static String XML_ATTRIBUTE_PROFILE_KIND= "kind"; //$NON-NLS-1$
- private final static String XML_ATTRIBUTE_VALUE= "value"; //$NON-NLS-1$
-
+ private final static String XML_NODE_ROOT = "profiles"; //$NON-NLS-1$
+ private final static String XML_NODE_PROFILE = "profile"; //$NON-NLS-1$
+ private final static String XML_NODE_SETTING = "setting"; //$NON-NLS-1$
+
+ private final static String XML_ATTRIBUTE_VERSION = "version"; //$NON-NLS-1$
+ private final static String XML_ATTRIBUTE_ID = "id"; //$NON-NLS-1$
+ private final static String XML_ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
+ private final static String XML_ATTRIBUTE_PROFILE_KIND = "kind"; //$NON-NLS-1$
+ private final static String XML_ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
+
private final IProfileVersioner fProfileVersioner;
private final String fProfilesKey;
private final String fProfilesVersionKey;
-
-
+
public ProfileStore(String profilesKey, IProfileVersioner profileVersioner) {
- fProfilesKey= profilesKey;
- fProfileVersioner= profileVersioner;
- fProfilesVersionKey= profilesKey + VERSION_KEY_SUFFIX;
+ fProfilesKey = profilesKey;
+ fProfileVersioner = profileVersioner;
+ fProfilesVersionKey = profilesKey + VERSION_KEY_SUFFIX;
}
-
+
/**
* @return Returns the collection of profiles currently stored in the preference store or
* <code>null</code> if the loading failed. The elements are of type {@link ProfileManager.CustomProfile}
@@ -158,48 +156,54 @@ public class ProfileStore {
public List<Profile> readProfiles(IScopeContext scope) throws CoreException {
return readProfilesFromString(scope.getNode(CUIPlugin.PLUGIN_ID).get(fProfilesKey, null));
}
-
+
public void writeProfiles(Collection<Profile> profiles, IScopeContext instanceScope) throws CoreException {
- ByteArrayOutputStream stream= new ByteArrayOutputStream(2000);
+ ByteArrayOutputStream stream = new ByteArrayOutputStream(2000);
try {
writeProfilesToStream(profiles, stream, ENCODING, fProfileVersioner);
String val;
try {
- val= stream.toString(ENCODING);
+ val = stream.toString(ENCODING);
} catch (UnsupportedEncodingException e) {
- val= stream.toString();
+ val = stream.toString();
}
IEclipsePreferences uiPreferences = instanceScope.getNode(CUIPlugin.PLUGIN_ID);
uiPreferences.put(fProfilesKey, val);
uiPreferences.putInt(fProfilesVersionKey, fProfileVersioner.getCurrentVersion());
} finally {
- try { stream.close(); } catch (IOException e) { /* ignore */ }
+ try {
+ stream.close();
+ } catch (IOException e) {
+ /* ignore */ }
}
}
-
+
public List<Profile> readProfilesFromString(String profiles) throws CoreException {
- if (profiles != null && profiles.length() > 0) {
+ if (profiles != null && profiles.length() > 0) {
byte[] bytes;
try {
- bytes= profiles.getBytes(ENCODING);
+ bytes = profiles.getBytes(ENCODING);
} catch (UnsupportedEncodingException e) {
- bytes= profiles.getBytes();
+ bytes = profiles.getBytes();
}
- InputStream is= new ByteArrayInputStream(bytes);
+ InputStream is = new ByteArrayInputStream(bytes);
try {
- List<Profile> res= readProfilesFromStream(new InputSource(is));
+ List<Profile> res = readProfilesFromStream(new InputSource(is));
if (res != null) {
- for (int i= 0; i < res.size(); i++) {
+ for (int i = 0; i < res.size(); i++) {
fProfileVersioner.update((CustomProfile) res.get(i));
}
}
return res;
} finally {
- try { is.close(); } catch (IOException e) { /* ignore */ }
+ try {
+ is.close();
+ } catch (IOException e) {
+ /* ignore */ }
}
}
return null;
- }
+ }
/**
* Read the available profiles from the internal XML file and return them
@@ -210,17 +214,20 @@ public class ProfileStore {
*/
public List<Profile> readProfilesFromFile(File file) throws CoreException {
try {
- final FileInputStream reader= new FileInputStream(file);
+ final FileInputStream reader = new FileInputStream(file);
try {
return readProfilesFromStream(new InputSource(reader));
} finally {
- try { reader.close(); } catch (IOException e) { /* ignore */ }
+ try {
+ reader.close();
+ } catch (IOException e) {
+ /* ignore */ }
}
} catch (IOException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
+ throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
}
}
-
+
/**
* Load profiles from a XML stream and add them to a map or <code>null</code> if the source is not a profile store.
* @param inputSource The input stream
@@ -228,21 +235,21 @@ public class ProfileStore {
* @throws CoreException
*/
protected static List<Profile> readProfilesFromStream(InputSource inputSource) throws CoreException {
- final ProfileDefaultHandler handler= new ProfileDefaultHandler();
+ final ProfileDefaultHandler handler = new ProfileDefaultHandler();
try {
- final SAXParserFactory factory= SAXParserFactory.newInstance();
- final SAXParser parser= factory.newSAXParser();
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
+ final SAXParser parser = factory.newSAXParser();
parser.parse(inputSource, handler);
} catch (SAXException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
+ throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
} catch (IOException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
+ throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
} catch (ParserConfigurationException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
+ throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);
}
return handler.getProfiles();
}
-
+
/**
* Write the available profiles to the internal XML file.
* @param profiles List of <code>CustomProfile</code>
@@ -253,17 +260,20 @@ public class ProfileStore {
public void writeProfilesToFile(Collection<Profile> profiles, File file, String encoding) throws CoreException {
final OutputStream stream;
try {
- stream= new FileOutputStream(file);
+ stream = new FileOutputStream(file);
try {
writeProfilesToStream(profiles, stream, encoding, fProfileVersioner);
} finally {
- try { stream.close(); } catch (IOException e) { /* ignore */ }
+ try {
+ stream.close();
+ } catch (IOException e) {
+ /* ignore */ }
}
} catch (IOException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
+ throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
}
}
-
+
/**
* Save profiles to an XML stream
* @param profiles List of <code>CustomProfile</code>
@@ -271,54 +281,56 @@ public class ProfileStore {
* @param encoding the encoding to use
* @throws CoreException
*/
- private static void writeProfilesToStream(Collection<Profile> profiles, OutputStream stream, String encoding, IProfileVersioner profileVersioner) throws CoreException {
+ private static void writeProfilesToStream(Collection<Profile> profiles, OutputStream stream, String encoding,
+ IProfileVersioner profileVersioner) throws CoreException {
try {
- final DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
- final DocumentBuilder builder= factory.newDocumentBuilder();
- final Document document= builder.newDocument();
-
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ final Document document = builder.newDocument();
+
final Element rootElement = document.createElement(XML_NODE_ROOT);
rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profileVersioner.getCurrentVersion()));
document.appendChild(rootElement);
-
+
for (Object element : profiles) {
- final Profile profile= (Profile)element;
+ final Profile profile = (Profile) element;
if (profile.isProfileToSave()) {
- final Element profileElement= createProfileElement(profile, document, profileVersioner);
+ final Element profileElement = createProfileElement(profile, document, profileVersioner);
rootElement.appendChild(profileElement);
}
}
- Transformer transformer=TransformerFactory.newInstance().newTransformer();
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
transformer.transform(new DOMSource(document), new StreamResult(stream));
} catch (TransformerException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
+ throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
} catch (ParserConfigurationException e) {
- throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
+ throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);
}
}
-
+
/*
* Create a new profile element in the specified document. The profile is not added
- * to the document by this method.
+ * to the document by this method.
*/
- private static Element createProfileElement(Profile profile, Document document, IProfileVersioner profileVersioner) {
- final Element element= document.createElement(XML_NODE_PROFILE);
+ private static Element createProfileElement(Profile profile, Document document,
+ IProfileVersioner profileVersioner) {
+ final Element element = document.createElement(XML_NODE_PROFILE);
element.setAttribute(XML_ATTRIBUTE_NAME, profile.getName());
element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion()));
element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind());
-
- final Iterator<String> keyIter= profile.getSettings().keySet().iterator();
-
+
+ final Iterator<String> keyIter = profile.getSettings().keySet().iterator();
+
while (keyIter.hasNext()) {
- final String key= keyIter.next();
- final String value= profile.getSettings().get(key);
+ final String key = keyIter.next();
+ final String value = profile.getSettings().get(key);
if (value != null) {
- final Element setting= document.createElement(XML_NODE_SETTING);
+ final Element setting = document.createElement(XML_NODE_SETTING);
setting.setAttribute(XML_ATTRIBUTE_ID, key);
setting.setAttribute(XML_ATTRIBUTE_VALUE, value);
element.appendChild(setting);
@@ -328,7 +340,7 @@ public class ProfileStore {
}
return element;
}
-
+
/*
* Creates a UI exception for logging purposes
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java
index 591e78a7151..e620b2fb45b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java
@@ -19,76 +19,74 @@ import java.util.Map;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
-
public class ProfileVersioner implements IProfileVersioner {
-
- public static final String CODE_FORMATTER_PROFILE_KIND= "CodeFormatterProfile"; //$NON-NLS-1$
-
- public static final int VERSION_1= 1; // < 20061106 (pre CDT 4.0M3)
-
- public static final int CURRENT_VERSION= VERSION_1;
-
-
+
+ public static final String CODE_FORMATTER_PROFILE_KIND = "CodeFormatterProfile"; //$NON-NLS-1$
+
+ public static final int VERSION_1 = 1; // < 20061106 (pre CDT 4.0M3)
+
+ public static final int CURRENT_VERSION = VERSION_1;
+
@Override
public int getFirstVersion() {
- return VERSION_1;
- }
+ return VERSION_1;
+ }
@Override
public int getCurrentVersion() {
- return CURRENT_VERSION;
- }
-
+ return CURRENT_VERSION;
+ }
+
/**
- * {@inheritDoc}
- */
- @Override
+ * {@inheritDoc}
+ */
+ @Override
public String getProfileKind() {
- return CODE_FORMATTER_PROFILE_KIND;
- }
+ return CODE_FORMATTER_PROFILE_KIND;
+ }
@Override
public void update(CustomProfile profile) {
- final Map<String, String> oldSettings= profile.getSettings();
- Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
+ final Map<String, String> oldSettings = profile.getSettings();
+ Map<String, String> newSettings = updateAndComplete(oldSettings, profile.getVersion());
profile.setVersion(CURRENT_VERSION);
profile.setSettings(newSettings);
}
-
+
public static int getVersionStatus(CustomProfile profile) {
- final int version= profile.getVersion();
- if (version < CURRENT_VERSION)
+ final int version = profile.getVersion();
+ if (version < CURRENT_VERSION)
return -1;
else if (version > CURRENT_VERSION)
return 1;
- else
+ else
return 0;
}
-
+
public static void updateAndComplete(CustomProfile profile) {
- final Map<String, String> oldSettings= profile.getSettings();
- Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
+ final Map<String, String> oldSettings = profile.getSettings();
+ Map<String, String> newSettings = updateAndComplete(oldSettings, profile.getVersion());
profile.setVersion(CURRENT_VERSION);
profile.setSettings(newSettings);
}
-
+
public static Map<String, String> updateAndComplete(Map<String, String> oldSettings, int version) {
- final Map<String, String> newSettings= FormatterProfileManager.getDefaultSettings();
-
+ final Map<String, String> newSettings = FormatterProfileManager.getDefaultSettings();
+
switch (version) {
-
+
default:
- for (Object element : oldSettings.keySet()) {
- final String key= (String)element;
- if (!newSettings.containsKey(key))
- continue;
-
- final String value= oldSettings.get(key);
- if (value != null) {
- newSettings.put(key, value);
- }
+ for (Object element : oldSettings.keySet()) {
+ final String key = (String) element;
+ if (!newSettings.containsKey(key))
+ continue;
+
+ final String value = oldSettings.get(key);
+ if (value != null) {
+ newSettings.put(key, value);
}
+ }
}
return newSettings;
}
- }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview.java
index d0d5387f816..1234c462a31 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview.java
@@ -31,76 +31,74 @@ import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
import org.eclipse.cdt.internal.ui.ICStatusConstants;
public class SnippetPreview extends CPreview {
-
- public final static class PreviewSnippet {
- public String header;
- public final String source;
- public final int kind;
-
- public PreviewSnippet(int kind, String source) {
- this.kind= kind;
- this.source= source;
- }
- }
-
- private ArrayList<PreviewSnippet> fSnippets;
-
- public SnippetPreview(Map<String, String> workingValues, Composite parent) {
- super(workingValues, parent);
- fSnippets= new ArrayList<PreviewSnippet>();
- }
-
- @Override
+
+ public final static class PreviewSnippet {
+ public String header;
+ public final String source;
+ public final int kind;
+
+ public PreviewSnippet(int kind, String source) {
+ this.kind = kind;
+ this.source = source;
+ }
+ }
+
+ private ArrayList<PreviewSnippet> fSnippets;
+
+ public SnippetPreview(Map<String, String> workingValues, Composite parent) {
+ super(workingValues, parent);
+ fSnippets = new ArrayList<PreviewSnippet>();
+ }
+
+ @Override
protected void doFormatPreview() {
- if (fSnippets.isEmpty()) {
- fPreviewDocument.set(""); //$NON-NLS-1$
- return;
- }
-
- // This delimiter looks best for invisible characters
- final String delimiter= "\n"; //$NON-NLS-1$
-
- final StringBuilder buffer= new StringBuilder();
- for (PreviewSnippet snippet: fSnippets) {
- String formattedSource;
- try {
- TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter,
- fWorkingValues);
- if (edit == null) {
- formattedSource= snippet.source;
- } else {
- Document document= new Document(snippet.source);
- edit.apply(document, TextEdit.NONE);
- formattedSource= document.get();
- }
- } catch (Exception e) {
- final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
- ICStatusConstants.INTERNAL_ERROR,
- FormatterMessages.CPreview_formatter_exception, e);
- CUIPlugin.log(status);
- continue;
- }
- buffer.append(delimiter);
- buffer.append(formattedSource);
- buffer.append(delimiter);
- buffer.append(delimiter);
- }
- fPreviewDocument.set(buffer.toString());
- }
-
- public void add(PreviewSnippet snippet) {
- fSnippets.add(snippet);
- }
-
- public void remove(PreviewSnippet snippet) {
- fSnippets.remove(snippet);
- }
-
- public void addAll(Collection<PreviewSnippet> snippets) {
- fSnippets.addAll(snippets);
- }
-
- public void clear() {
- fSnippets.clear();
- }
+ if (fSnippets.isEmpty()) {
+ fPreviewDocument.set(""); //$NON-NLS-1$
+ return;
+ }
+
+ // This delimiter looks best for invisible characters
+ final String delimiter = "\n"; //$NON-NLS-1$
+
+ final StringBuilder buffer = new StringBuilder();
+ for (PreviewSnippet snippet : fSnippets) {
+ String formattedSource;
+ try {
+ TextEdit edit = CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter, fWorkingValues);
+ if (edit == null) {
+ formattedSource = snippet.source;
+ } else {
+ Document document = new Document(snippet.source);
+ edit.apply(document, TextEdit.NONE);
+ formattedSource = document.get();
+ }
+ } catch (Exception e) {
+ final IStatus status = new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
+ ICStatusConstants.INTERNAL_ERROR, FormatterMessages.CPreview_formatter_exception, e);
+ CUIPlugin.log(status);
+ continue;
+ }
+ buffer.append(delimiter);
+ buffer.append(formattedSource);
+ buffer.append(delimiter);
+ buffer.append(delimiter);
+ }
+ fPreviewDocument.set(buffer.toString());
+ }
+
+ public void add(PreviewSnippet snippet) {
+ fSnippets.add(snippet);
+ }
+
+ public void remove(PreviewSnippet snippet) {
+ fSnippets.remove(snippet);
+ }
+
+ public void addAll(Collection<PreviewSnippet> snippets) {
+ fSnippets.addAll(snippets);
+ }
+
+ public void clear() {
+ fSnippets.clear();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java
index 7631d576306..99d8c5e76ab 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java
@@ -34,36 +34,36 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.ICStatusConstants;
public class TranslationUnitPreview extends CPreview {
- private String fPreviewText;
- private int fPreviewTextOffset;
+ private String fPreviewText;
+ private int fPreviewTextOffset;
private String fFormatterId;
- /**
- * @param workingValues
- * @param parent
- */
- public TranslationUnitPreview(Map<String, String> workingValues, Composite parent) {
- super(workingValues, parent);
- }
+ /**
+ * @param workingValues
+ * @param parent
+ */
+ public TranslationUnitPreview(Map<String, String> workingValues, Composite parent) {
+ super(workingValues, parent);
+ }
- @Override
+ @Override
protected void doFormatPreview() {
- if (fPreviewText == null) {
- fPreviewDocument.set(""); //$NON-NLS-1$
- return;
- }
- fPreviewDocument.set(fPreviewText);
-
+ if (fPreviewText == null) {
+ fPreviewDocument.set(""); //$NON-NLS-1$
+ return;
+ }
+ fPreviewDocument.set(fPreviewText);
+
fSourceViewer.setVisibleRegion(fPreviewTextOffset, fPreviewText.length() - fPreviewTextOffset);
fSourceViewer.setRedraw(false);
final IFormattingContext context = new FormattingContext();
try {
- final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
+ final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
if (formatter instanceof IContentFormatterExtension) {
final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
- Map<String, String> prefs= fWorkingValues;
+ Map<String, String> prefs = fWorkingValues;
if (fFormatterId != null) {
- prefs= new HashMap<String, String>(fWorkingValues);
+ prefs = new HashMap<String, String>(fWorkingValues);
prefs.put(CCorePreferenceConstants.CODE_FORMATTER, fFormatterId);
}
context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, prefs);
@@ -73,29 +73,29 @@ public class TranslationUnitPreview extends CPreview {
formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength()));
}
} catch (Exception e) {
- final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR,
- FormatterMessages.CPreview_formatter_exception, e);
+ final IStatus status = new Status(IStatus.ERROR, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR,
+ FormatterMessages.CPreview_formatter_exception, e);
CUIPlugin.log(status);
} finally {
- context.dispose();
- fSourceViewer.setRedraw(true);
+ context.dispose();
+ fSourceViewer.setRedraw(true);
}
- }
-
- public void setPreviewText(String previewText) {
+ }
+
+ public void setPreviewText(String previewText) {
setPreviewText(previewText, 0);
}
public void setPreviewText(String previewText, int previewTextOffset) {
- fPreviewText= previewText;
- fPreviewTextOffset = previewTextOffset;
- update();
- }
+ fPreviewText = previewText;
+ fPreviewTextOffset = previewTextOffset;
+ update();
+ }
/**
* @param formatterId
*/
public void setFormatterId(String formatterId) {
- fFormatterId= formatterId;
+ fFormatterId = formatterId;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
index fda840d9825..420769dae83 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
@@ -26,964 +26,1259 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.internal.ui.preferences.formatter.SnippetPreview.PreviewSnippet;
-
/**
- * Manage code formatter white space options on a higher level.
+ * Manage code formatter white space options on a higher level.
*/
public final class WhiteSpaceOptions {
- /**
- * Represents a node in the options tree.
- */
+ /**
+ * Represents a node in the options tree.
+ */
public abstract static class Node {
-
- private final InnerNode fParent;
- private final String fName;
-
- public int index;
-
- protected final Map<String,String> fWorkingValues;
- protected final ArrayList<Node> fChildren;
-
- public Node(InnerNode parent, Map<String,String> workingValues, String message) {
- if (workingValues == null || message == null)
- throw new IllegalArgumentException();
- fParent= parent;
- fWorkingValues= workingValues;
- fName= message;
- fChildren= new ArrayList<Node>();
- if (fParent != null)
- fParent.add(this);
- }
-
- public abstract void setChecked(boolean checked);
-
- public boolean hasChildren() {
- return !fChildren.isEmpty();
- }
-
- public List<Node> getChildren() {
- return Collections.unmodifiableList(fChildren);
- }
-
- public InnerNode getParent() {
- return fParent;
- }
-
- @Override
+
+ private final InnerNode fParent;
+ private final String fName;
+
+ public int index;
+
+ protected final Map<String, String> fWorkingValues;
+ protected final ArrayList<Node> fChildren;
+
+ public Node(InnerNode parent, Map<String, String> workingValues, String message) {
+ if (workingValues == null || message == null)
+ throw new IllegalArgumentException();
+ fParent = parent;
+ fWorkingValues = workingValues;
+ fName = message;
+ fChildren = new ArrayList<Node>();
+ if (fParent != null)
+ fParent.add(this);
+ }
+
+ public abstract void setChecked(boolean checked);
+
+ public boolean hasChildren() {
+ return !fChildren.isEmpty();
+ }
+
+ public List<Node> getChildren() {
+ return Collections.unmodifiableList(fChildren);
+ }
+
+ public InnerNode getParent() {
+ return fParent;
+ }
+
+ @Override
public final String toString() {
- return fName;
- }
-
- public abstract List<PreviewSnippet> getSnippets();
-
- public abstract void getCheckedLeafs(List<OptionNode> list);
- }
-
+ return fName;
+ }
+
+ public abstract List<PreviewSnippet> getSnippets();
+
+ public abstract void getCheckedLeafs(List<OptionNode> list);
+ }
+
/**
* A node representing a group of options in the tree.
*/
public static class InnerNode extends Node {
-
- public InnerNode(InnerNode parent, Map<String,String> workingValues, String messageKey) {
- super(parent, workingValues, messageKey);
- }
- @Override
+ public InnerNode(InnerNode parent, Map<String, String> workingValues, String messageKey) {
+ super(parent, workingValues, messageKey);
+ }
+
+ @Override
public void setChecked(boolean checked) {
- for (Object element : fChildren)
- ((Node)element).setChecked(checked);
- }
+ for (Object element : fChildren)
+ ((Node) element).setChecked(checked);
+ }
- public void add(Node child) {
- fChildren.add(child);
- }
+ public void add(Node child) {
+ fChildren.add(child);
+ }
- @Override
+ @Override
public List<PreviewSnippet> getSnippets() {
- final ArrayList<PreviewSnippet> snippets= new ArrayList<PreviewSnippet>(fChildren.size());
- for (Object element : fChildren) {
- final List<PreviewSnippet> childSnippets= ((Node)element).getSnippets();
- for (PreviewSnippet snippet : childSnippets) {
- if (!snippets.contains(snippet))
- snippets.add(snippet);
- }
- }
- return snippets;
- }
-
- @Override
+ final ArrayList<PreviewSnippet> snippets = new ArrayList<PreviewSnippet>(fChildren.size());
+ for (Object element : fChildren) {
+ final List<PreviewSnippet> childSnippets = ((Node) element).getSnippets();
+ for (PreviewSnippet snippet : childSnippets) {
+ if (!snippets.contains(snippet))
+ snippets.add(snippet);
+ }
+ }
+ return snippets;
+ }
+
+ @Override
public void getCheckedLeafs(List<OptionNode> list) {
- for (Node element : fChildren) {
- element.getCheckedLeafs(list);
- }
- }
+ for (Node element : fChildren) {
+ element.getCheckedLeafs(list);
+ }
+ }
}
-
/**
* A node representing a concrete white space option in the tree.
*/
public static class OptionNode extends Node {
- private final String fKey;
- private final ArrayList<PreviewSnippet> fSnippets;
-
- public OptionNode(InnerNode parent, Map<String, String> workingValues, String messageKey, String key, PreviewSnippet snippet) {
- super(parent, workingValues, messageKey);
- fKey= key;
- fSnippets= new ArrayList<PreviewSnippet>(1);
- fSnippets.add(snippet);
- }
-
- @Override
+ private final String fKey;
+ private final ArrayList<PreviewSnippet> fSnippets;
+
+ public OptionNode(InnerNode parent, Map<String, String> workingValues, String messageKey, String key,
+ PreviewSnippet snippet) {
+ super(parent, workingValues, messageKey);
+ fKey = key;
+ fSnippets = new ArrayList<PreviewSnippet>(1);
+ fSnippets.add(snippet);
+ }
+
+ @Override
public void setChecked(boolean checked) {
- fWorkingValues.put(fKey, checked ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
- }
-
- public boolean getChecked() {
- return CCorePlugin.INSERT.equals(fWorkingValues.get(fKey));
- }
-
- @Override
+ fWorkingValues.put(fKey, checked ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
+ }
+
+ public boolean getChecked() {
+ return CCorePlugin.INSERT.equals(fWorkingValues.get(fKey));
+ }
+
+ @Override
public List<PreviewSnippet> getSnippets() {
- return fSnippets;
- }
-
- @Override
+ return fSnippets;
+ }
+
+ @Override
public void getCheckedLeafs(List<OptionNode> list) {
- if (getChecked())
- list.add(this);
- }
+ if (getChecked())
+ list.add(this);
+ }
}
-
-
-
+
/**
* Preview snippets.
*/
-
- private final PreviewSnippet FOR_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "for (int i= 0, j= argc; i < argc; i++, j--) {}" //$NON-NLS-1$
- );
-
- private final PreviewSnippet WHILE_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "while (condition) {} do {} while (condition);" //$NON-NLS-1$
- );
-
- private final PreviewSnippet CATCH_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "try { number= Math::parseInt(value); } catch (Math::Exception e) {}"); //$NON-NLS-1$
-
- private final PreviewSnippet IF_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "if (condition) { return foo; } else {return bar;}"); //$NON-NLS-1$
-
- private final PreviewSnippet SWITCH_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "switch (number) { case RED: return GREEN; case GREEN: return BLUE; case BLUE: return RED; default: return BLACK;}"); //$NON-NLS-1$
-
- private final PreviewSnippet METHOD_DECL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_CLASS_BODY_DECLARATIONS,
- "void foo() throw(E0, E1) {}" + //$NON-NLS-1$
- "void bar(int x, int y) throw() {}"); //$NON-NLS-1$
-
- private final PreviewSnippet INITIALIZER_LIST_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "int array[]= {1, 2, 3};"); //$NON-NLS-1$
-
- private final PreviewSnippet ARRAY_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "int array[]= {1, 2, 3};\n" + //$NON-NLS-1$
- "array [2] = 0;\n" + //$NON-NLS-1$
- "int * parray= new int[3];" + //$NON-NLS-1$
- "delete[] parray;"); //$NON-NLS-1$
-
- private final PreviewSnippet METHOD_CALL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "foo();\n" + //$NON-NLS-1$
- "bar(x, y);"); //$NON-NLS-1$
-
- private final PreviewSnippet LABEL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "label: for (int i= 0; i<argc; i++) goto label;"); //$NON-NLS-1$
-
- private final PreviewSnippet SEMICOLON_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "int a= 4; foo(); bar(x, y);"); //$NON-NLS-1$
-
- private final PreviewSnippet CONDITIONAL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_TRANSLATION_UNIT,
- "bool value= condition ? true : false;"); //$NON-NLS-1$
-
- private final PreviewSnippet CLASS_DECL_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_TRANSLATION_UNIT,
- "class MyClass : Base1, Base2 {};"); //$NON-NLS-1$
-
- private final PreviewSnippet OPERATOR_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "int a= -4 + -9; b= a++ / --number; c += 4; bool value= true && false;"); //$NON-NLS-1$
-
- private final PreviewSnippet CAST_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "char * s= ((char *)object);"); //$NON-NLS-1$
-
- private final PreviewSnippet EXPRESSION_LIST_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "a= 0, b= 1, c= 2, d= 3;"); //$NON-NLS-1$
-
- private final PreviewSnippet DECLARATOR_LIST_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "int a=0,b=1,c=2,d=3;"); //$NON-NLS-1$
-
- private final PreviewSnippet BLOCK_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "if (true) { return 1; } else { return 2; }"); //$NON-NLS-1$
-
- private final PreviewSnippet PAREN_EXPR_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_STATEMENTS,
- "result= (a *( b + c + d) * (e + f));"); //$NON-NLS-1$
-
- private final PreviewSnippet TEMPLATES_PREVIEW= new PreviewSnippet(
- CodeFormatter.K_TRANSLATION_UNIT,
- "template<typename T1,typename T2> class map {};\n" + //$NON-NLS-1$
- "map<int,int> m;" //$NON-NLS-1$
- );
-
+
+ private final PreviewSnippet FOR_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "for (int i= 0, j= argc; i < argc; i++, j--) {}" //$NON-NLS-1$
+ );
+
+ private final PreviewSnippet WHILE_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "while (condition) {} do {} while (condition);" //$NON-NLS-1$
+ );
+
+ private final PreviewSnippet CATCH_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "try { number= Math::parseInt(value); } catch (Math::Exception e) {}"); //$NON-NLS-1$
+
+ private final PreviewSnippet IF_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "if (condition) { return foo; } else {return bar;}"); //$NON-NLS-1$
+
+ private final PreviewSnippet SWITCH_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "switch (number) { case RED: return GREEN; case GREEN: return BLUE; case BLUE: return RED; default: return BLACK;}"); //$NON-NLS-1$
+
+ private final PreviewSnippet METHOD_DECL_PREVIEW = new PreviewSnippet(CodeFormatter.K_CLASS_BODY_DECLARATIONS,
+ "void foo() throw(E0, E1) {}" + //$NON-NLS-1$
+ "void bar(int x, int y) throw() {}"); //$NON-NLS-1$
+
+ private final PreviewSnippet INITIALIZER_LIST_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "int array[]= {1, 2, 3};"); //$NON-NLS-1$
+
+ private final PreviewSnippet ARRAY_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "int array[]= {1, 2, 3};\n" + //$NON-NLS-1$
+ "array [2] = 0;\n" + //$NON-NLS-1$
+ "int * parray= new int[3];" + //$NON-NLS-1$
+ "delete[] parray;"); //$NON-NLS-1$
+
+ private final PreviewSnippet METHOD_CALL_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS, "foo();\n" + //$NON-NLS-1$
+ "bar(x, y);"); //$NON-NLS-1$
+
+ private final PreviewSnippet LABEL_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "label: for (int i= 0; i<argc; i++) goto label;"); //$NON-NLS-1$
+
+ private final PreviewSnippet SEMICOLON_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "int a= 4; foo(); bar(x, y);"); //$NON-NLS-1$
+
+ private final PreviewSnippet CONDITIONAL_PREVIEW = new PreviewSnippet(CodeFormatter.K_TRANSLATION_UNIT,
+ "bool value= condition ? true : false;"); //$NON-NLS-1$
+
+ private final PreviewSnippet CLASS_DECL_PREVIEW = new PreviewSnippet(CodeFormatter.K_TRANSLATION_UNIT,
+ "class MyClass : Base1, Base2 {};"); //$NON-NLS-1$
+
+ private final PreviewSnippet OPERATOR_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "int a= -4 + -9; b= a++ / --number; c += 4; bool value= true && false;"); //$NON-NLS-1$
+
+ private final PreviewSnippet CAST_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "char * s= ((char *)object);"); //$NON-NLS-1$
+
+ private final PreviewSnippet EXPRESSION_LIST_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "a= 0, b= 1, c= 2, d= 3;"); //$NON-NLS-1$
+
+ private final PreviewSnippet DECLARATOR_LIST_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "int a=0,b=1,c=2,d=3;"); //$NON-NLS-1$
+
+ private final PreviewSnippet BLOCK_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "if (true) { return 1; } else { return 2; }"); //$NON-NLS-1$
+
+ private final PreviewSnippet PAREN_EXPR_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
+ "result= (a *( b + c + d) * (e + f));"); //$NON-NLS-1$
+
+ private final PreviewSnippet TEMPLATES_PREVIEW = new PreviewSnippet(CodeFormatter.K_TRANSLATION_UNIT,
+ "template<typename T1,typename T2> class map {};\n" + //$NON-NLS-1$
+ "map<int,int> m;" //$NON-NLS-1$
+ );
+
/**
* Create the tree, in this order: syntax element - position - abstract element
* @param workingValues
* @return returns roots (type <code>Node</code>)
*/
public List<InnerNode> createTreeBySyntaxElem(Map<String, String> workingValues) {
- final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
-
- InnerNode element;
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_paren);
- createBeforeOpenParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterOpenParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_paren);
- createBeforeClosingParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterCloseParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_brace);
- createBeforeOpenBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterOpenBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_brace);
- createBeforeClosingBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterCloseBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_bracket);
- createBeforeOpenBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterOpenBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_bracket);
- createBeforeClosingBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_operator);
- createBeforeOperatorTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterOperatorTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_comma);
- createBeforeCommaTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterCommaTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_colon);
- createBeforeColonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterColonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_semicolon);
- createBeforeSemicolonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterSemicolonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_question_mark);
- createBeforeQuestionTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
- createAfterQuestionTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_parens);
- createBetweenEmptyParenTree(workingValues, element);
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_braces);
- createBetweenEmptyBracesTree(workingValues, element);
- roots.add(element);
-
- element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_brackets);
- createBetweenEmptyBracketsTree(workingValues, element);
- roots.add(element);
-
- return roots;
- }
-
- /**
- * Create the tree, in this order: position - syntax element - abstract
- * element
- * @param workingValues
- * @return returns roots (type <code>Node</code>)
- */
- public List<InnerNode> createAltTree(Map<String, String> workingValues) {
-
- final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
-
- InnerNode parent;
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_paren);
- createBeforeOpenParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_paren);
- createAfterOpenParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_paren);
- createBeforeClosingParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_paren);
- createAfterCloseParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_parens);
- createBetweenEmptyParenTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_brace);
- createBeforeOpenBraceTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_brace);
- createAfterOpenBraceTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_brace);
- createBeforeClosingBraceTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_brace);
- createAfterCloseBraceTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_braces);
- createBetweenEmptyBracesTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_bracket);
- createBeforeOpenBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_bracket);
- createAfterOpenBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_bracket);
- createBeforeClosingBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_brackets);
- createBetweenEmptyBracketsTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_angle_bracket);
- createBeforeOpenAngleBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_angle_bracket);
- createAfterOpenAngleBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_angle_bracket);
- createBeforeClosingAngleBracketTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_angle_bracket);
- createAfterClosingAngleBracketTree(workingValues, parent);
-
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_operator);
- createBeforeOperatorTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_operator);
- createAfterOperatorTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_comma);
- createBeforeCommaTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_comma);
- createAfterCommaTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_colon);
- createAfterColonTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_colon);
- createBeforeColonTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon);
- createBeforeSemicolonTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_semicolon);
- createAfterSemicolonTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_question_mark);
- createBeforeQuestionTree(workingValues, parent);
-
- parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_question_mark);
- createAfterQuestionTree(workingValues, parent);
-
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_ellipsis);
-// createBeforeEllipsis(workingValues, parent);
-//
-// parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_ellipsis);
-// createAfterEllipsis(workingValues, parent);
-
- return roots;
+ final ArrayList<InnerNode> roots = new ArrayList<InnerNode>();
+
+ InnerNode element;
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_paren);
+ createBeforeOpenParenTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterOpenParenTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_paren);
+ createBeforeClosingParenTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterCloseParenTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_brace);
+ createBeforeOpenBraceTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterOpenBraceTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_brace);
+ createBeforeClosingBraceTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterCloseBraceTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_bracket);
+ createBeforeOpenBracketTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterOpenBracketTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_bracket);
+ createBeforeClosingBracketTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_operator);
+ createBeforeOperatorTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterOperatorTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_comma);
+ createBeforeCommaTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterCommaTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_colon);
+ createBeforeColonTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterColonTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_semicolon);
+ createBeforeSemicolonTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterSemicolonTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_question_mark);
+ createBeforeQuestionTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before));
+ createAfterQuestionTree(workingValues,
+ createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after));
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_parens);
+ createBetweenEmptyParenTree(workingValues, element);
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_braces);
+ createBetweenEmptyBracesTree(workingValues, element);
+ roots.add(element);
+
+ element = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_brackets);
+ createBetweenEmptyBracketsTree(workingValues, element);
+ roots.add(element);
+
+ return roots;
+ }
+
+ /**
+ * Create the tree, in this order: position - syntax element - abstract
+ * element
+ * @param workingValues
+ * @return returns roots (type <code>Node</code>)
+ */
+ public List<InnerNode> createAltTree(Map<String, String> workingValues) {
+
+ final ArrayList<InnerNode> roots = new ArrayList<InnerNode>();
+
+ InnerNode parent;
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_paren);
+ createBeforeOpenParenTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_paren);
+ createAfterOpenParenTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_paren);
+ createBeforeClosingParenTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_paren);
+ createAfterCloseParenTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_parens);
+ createBetweenEmptyParenTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_brace);
+ createBeforeOpenBraceTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_brace);
+ createAfterOpenBraceTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_brace);
+ createBeforeClosingBraceTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_brace);
+ createAfterCloseBraceTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_braces);
+ createBetweenEmptyBracesTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_bracket);
+ createBeforeOpenBracketTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_bracket);
+ createAfterOpenBracketTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_bracket);
+ createBeforeClosingBracketTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_brackets);
+ createBetweenEmptyBracketsTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues,
+ FormatterMessages.WhiteSpaceOptions_before_opening_angle_bracket);
+ createBeforeOpenAngleBracketTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues,
+ FormatterMessages.WhiteSpaceOptions_after_opening_angle_bracket);
+ createAfterOpenAngleBracketTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues,
+ FormatterMessages.WhiteSpaceOptions_before_closing_angle_bracket);
+ createBeforeClosingAngleBracketTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues,
+ FormatterMessages.WhiteSpaceOptions_after_closing_angle_bracket);
+ createAfterClosingAngleBracketTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_operator);
+ createBeforeOperatorTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_operator);
+ createAfterOperatorTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_comma);
+ createBeforeCommaTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_comma);
+ createAfterCommaTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_colon);
+ createAfterColonTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_colon);
+ createBeforeColonTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon);
+ createBeforeSemicolonTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_semicolon);
+ createAfterSemicolonTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_question_mark);
+ createBeforeQuestionTree(workingValues, parent);
+
+ parent = createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_question_mark);
+ createAfterQuestionTree(workingValues, parent);
+
+ // parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_ellipsis);
+ // createBeforeEllipsis(workingValues, parent);
+ //
+ // parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_ellipsis);
+ // createAfterEllipsis(workingValues, parent);
+
+ return roots;
}
private InnerNode createParentNode(List<InnerNode> roots, Map<String, String> workingValues, String text) {
- final InnerNode parent= new InnerNode(null, workingValues, text);
- roots.add(parent);
- return parent;
- }
-
- public ArrayList<InnerNode> createTreeByCElement(Map<String, String> workingValues) {
-
- final InnerNode declarations= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_declarations);
- createClassTree(workingValues, declarations);
- createDeclaratorListTree(workingValues, declarations);
-// createConstructorTree(workingValues, declarations);
- createMethodDeclTree(workingValues, declarations);
- createExceptionSpecificationTree(workingValues, declarations);
- createLabelTree(workingValues, declarations);
-
- final InnerNode statements= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_statements);
- createOption(statements, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW);
- createBlockTree(workingValues, statements);
- createIfStatementTree(workingValues, statements);
- createForStatementTree(workingValues, statements);
- createSwitchStatementTree(workingValues, statements);
- createDoWhileTree(workingValues, statements);
- createTryStatementTree(workingValues, statements);
-// createReturnTree(workingValues, statements);
-// createThrowTree(workingValues, statements);
-
- final InnerNode expressions= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_expressions);
- createFunctionCallTree(workingValues, expressions);
+ final InnerNode parent = new InnerNode(null, workingValues, text);
+ roots.add(parent);
+ return parent;
+ }
+
+ public ArrayList<InnerNode> createTreeByCElement(Map<String, String> workingValues) {
+
+ final InnerNode declarations = new InnerNode(null, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_declarations);
+ createClassTree(workingValues, declarations);
+ createDeclaratorListTree(workingValues, declarations);
+ // createConstructorTree(workingValues, declarations);
+ createMethodDeclTree(workingValues, declarations);
+ createExceptionSpecificationTree(workingValues, declarations);
+ createLabelTree(workingValues, declarations);
+
+ final InnerNode statements = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_statements);
+ createOption(statements, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW);
+ createBlockTree(workingValues, statements);
+ createIfStatementTree(workingValues, statements);
+ createForStatementTree(workingValues, statements);
+ createSwitchStatementTree(workingValues, statements);
+ createDoWhileTree(workingValues, statements);
+ createTryStatementTree(workingValues, statements);
+ // createReturnTree(workingValues, statements);
+ // createThrowTree(workingValues, statements);
+
+ final InnerNode expressions = new InnerNode(null, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_expressions);
+ createFunctionCallTree(workingValues, expressions);
createAssignmentTree(workingValues, expressions);
createInitializerListTree(workingValues, expressions);
createOperatorTree(workingValues, expressions);
createParenthesizedExpressionTree(workingValues, expressions);
createTypecastTree(workingValues, expressions);
createConditionalTree(workingValues, expressions);
- createExpressionListTree(workingValues, expressions);
-
- final InnerNode arrays= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_arrays);
+ createExpressionListTree(workingValues, expressions);
+
+ final InnerNode arrays = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_arrays);
createArrayTree(workingValues, arrays);
-
- final InnerNode templates= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_templates);
+
+ final InnerNode templates = new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_templates);
createTemplateArgumentTree(workingValues, templates);
createTemplateParameterTree(workingValues, templates);
-
- final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
+
+ final ArrayList<InnerNode> roots = new ArrayList<InnerNode>();
roots.add(declarations);
roots.add(statements);
roots.add(expressions);
roots.add(arrays);
roots.add(templates);
- return roots;
- }
-
+ return roots;
+ }
+
private void createBeforeQuestionTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- }
-
- private void createBeforeSemicolonTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW);
- }
-
- private void createBeforeColonTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
-
- final InnerNode switchStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch);
- createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_case, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW);
- createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_default, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW);
- }
-
- private void createBeforeCommaTree(Map<String, String> workingValues, final InnerNode parent) {
-
-// final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for);
-// createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW);
-// createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_incrementation, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
-
- final InnerNode invocation= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arguments);
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW);
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
-
- final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameters);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
-
- final InnerNode lists= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lists);
- createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_declarator_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW);
- createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_expression_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW);
- createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW);
- }
-
- private void createBeforeOperatorTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
- }
-
- private void createBeforeClosingBracketTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW);
- }
-
- private void createBeforeClosingAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- }
-
-
- private void createBeforeOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW);
- }
-
- private void createBeforeOpenAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- }
-
- private void createBeforeClosingBraceTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_INITIALIZER_LIST, CLASS_DECL_PREVIEW);
- }
-
- private void createBeforeOpenBraceTree(Map<String, String> workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_class_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW);
-
- final InnerNode functionDecl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_declaration); {
- createOption(functionDecl, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- }
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW);
- }
-
- private void createBeforeClosingParenTree(Map<String, String> workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW);
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
-
- final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_declaration);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW);
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- }
-
- private void createBeforeOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);
-
- final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_declaration);
- createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW);
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- }
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL,
+ CONDITIONAL_PREVIEW);
+ }
+
+ private void createBeforeSemicolonTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_statements,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW);
+ }
+
+ private void createBeforeColonTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
+
+ final InnerNode switchStatement = createChild(parent, workingValues,
+ FormatterMessages.WhiteSpaceOptions_switch);
+ createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_case,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW);
+ createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_default,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW);
+ }
+
+ private void createBeforeCommaTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ // final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for);
+ // createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW);
+ // createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_incrementation, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
+
+ final InnerNode invocation = createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arguments);
+ createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_function_call,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS,
+ METHOD_CALL_PREVIEW);
+ createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+
+ final InnerNode decl = createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameters);
+ createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS,
+ METHOD_DECL_PREVIEW);
+ createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+
+ final InnerNode lists = createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lists);
+ createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_declarator_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST,
+ DECLARATOR_LIST_PREVIEW);
+ createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_expression_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST,
+ EXPRESSION_LIST_PREVIEW);
+ createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS,
+ METHOD_DECL_PREVIEW);
+ }
+
+ private void createBeforeOperatorTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
+ }
+
+ private void createBeforeClosingBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW);
+ }
+
+ private void createBeforeClosingAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ }
+
+ private void createBeforeOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW);
+ }
+
+ private void createBeforeOpenAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ }
+
+ private void createBeforeClosingBraceTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_INITIALIZER_LIST,
+ CLASS_DECL_PREVIEW);
+ }
+
+ private void createBeforeOpenBraceTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_class_decl,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION,
+ CLASS_DECL_PREVIEW);
+
+ final InnerNode functionDecl = createChild(parent, workingValues,
+ FormatterMessages.WhiteSpaceOptions_function_declaration);
+ {
+ createOption(functionDecl, workingValues, FormatterMessages.WhiteSpaceOptions_function,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ }
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW);
+ }
+
+ private void createBeforeClosingParenTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW);
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
+
+ final InnerNode decl = createChild(parent, workingValues,
+ FormatterMessages.WhiteSpaceOptions_function_declaration);
+ createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION,
+ METHOD_DECL_PREVIEW);
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION,
+ METHOD_CALL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION,
+ PAREN_EXPR_PREVIEW);
+ }
+
+ private void createBeforeOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
+ // createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
+ // createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);
+
+ final InnerNode decls = createChild(parent, workingValues,
+ FormatterMessages.WhiteSpaceOptions_function_declaration);
+ createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_function,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION,
+ METHOD_DECL_PREVIEW);
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION,
+ METHOD_CALL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION,
+ PAREN_EXPR_PREVIEW);
+ }
private void createAfterQuestionTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- }
-
-// private void createBeforeEllipsis(Map workingValues, InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
-// }
-//
-// private void createAfterEllipsis(Map workingValues, InnerNode parent) {
-// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
-// }
-
- private void createAfterSemicolonTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW);
- }
-
- private void createAfterColonTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
- }
-
- private void createAfterCommaTree(Map<String, String> workingValues, final InnerNode parent) {
-
-// final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for); {
-// createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW);
-// createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_incrementation, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
-// }
- final InnerNode invocation= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arguments); {
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW);
- createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- }
- final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameters); {
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW);
- createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- }
- final InnerNode lists= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lists); {
- createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_declarator_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW);
- createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_expression_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW);
- createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- }
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW);
- }
-
- private void createAfterOperatorTree(Map<String, String> workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
- }
-
- private void createAfterOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW);
- }
-
- private void createAfterOpenAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- }
-
-
-
- private void createAfterOpenBraceTree(Map<String, String> workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- }
-
- private void createAfterCloseBraceTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
- }
-
- private void createAfterCloseParenTree(Map<String, String> workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
- }
-
- private void createAfterClosingAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- //createOption(parent, workingValues, "WhiteSpaceOptions.parameterized_type", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW); //$NON-NLS-1$
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- }
-
- private void createAfterOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
-
- final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_declaration); {
- createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW);
- }
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- }
-
- private void createBetweenEmptyParenTree(Map<String, String> workingValues, final InnerNode parent) {
-
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_EXCEPTION_SPECIFICATION, METHOD_CALL_PREVIEW);
- }
-
- private void createBetweenEmptyBracketsTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS, ARRAY_PREVIEW);
- }
-
- private void createBetweenEmptyBracesTree(Map<String, String> workingValues, final InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- }
-
- // syntax element tree
-
- private InnerNode createClassTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_classes);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_opening_brace_of_a_class, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_colon_of_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_after_colon_of_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_comma_base_types, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_BASE_TYPES, CLASS_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_after_comma_base_types, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_BASE_TYPES, CLASS_DECL_PREVIEW);
- return root;
- }
-
- private InnerNode createAssignmentTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_before_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_after_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
- return root;
- }
-
- private InnerNode createOperatorTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_operators);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_binary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_binary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_unary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_unary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_prefix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_prefix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_postfix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_postfix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
- return root;
- }
-
- private InnerNode createMethodDeclTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_functions);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW);
- return root;
- }
-
- private InnerNode createExceptionSpecificationTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_exception_specifications);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW);
- return root;
- }
-
- private InnerNode createDeclaratorListTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW);
- return root;
- }
-
- private InnerNode createExpressionListTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW);
- return root;
- }
-
- private InnerNode createInitializerListTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_initializer_list);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_braces, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
- return root;
- }
-
- private InnerNode createArrayTree(Map<String, String> workingValues, InnerNode parent) {
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW);
- createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_brackets, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS, ARRAY_PREVIEW);
- return parent;
- }
-
- private InnerNode createFunctionCallTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_calls);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_function_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_function_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW);
- return root;
- }
-
- private InnerNode createBlockTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_blocks);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
- return root;
- }
-
- private InnerNode createSwitchStatementTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_switch);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_case_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_default_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
- return root;
- }
-
- private InnerNode createDoWhileTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_do);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW);
-
- return root;
- }
-
- private InnerNode createTryStatementTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_try);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);
- return root;
- }
- private InnerNode createIfStatementTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_if);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW);
- return root;
- }
-
- private InnerNode createForStatementTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_for);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW);
-
- return root;
- }
-
-// private InnerNode createReturnTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_parenthesized_expressions, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
-// return root;
-// }
-
-// private InnerNode createThrowTree(Map workingValues, InnerNode parent) {
-// final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw);
-// createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_parenthesized_expressions, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);
-// return root;
-// }
-
- private InnerNode createLabelTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_labels);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
- return root;
- }
-
- private InnerNode createTemplateArgumentTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_template_arguments);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
- return root;
- }
-
- private InnerNode createTemplateParameterTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_template_parameters);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
- return root;
- }
-
- private InnerNode createConditionalTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_conditionals);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
- return root;
- }
-
-
- private InnerNode createTypecastTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_typecasts);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
- return root;
- }
-
-
- private InnerNode createParenthesizedExpressionTree(Map<String, String> workingValues, InnerNode parent) {
- final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_parenexpr);
-
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
- return root;
- }
-
-
-
- private static InnerNode createChild(InnerNode root, Map<String, String> workingValues, String message) {
- return new InnerNode(root, workingValues, message);
- }
-
- private static OptionNode createOption(InnerNode root, Map<String, String> workingValues, String message, String key, PreviewSnippet snippet) {
- return new OptionNode(root, workingValues, message, key, snippet);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL,
+ CONDITIONAL_PREVIEW);
+ }
+
+ // private void createBeforeEllipsis(Map workingValues, InnerNode parent) {
+ // createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
+ // }
+ //
+ // private void createAfterEllipsis(Map workingValues, InnerNode parent) {
+ // createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
+ // }
+
+ private void createAfterSemicolonTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW);
+ }
+
+ private void createAfterColonTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
+ }
+
+ private void createAfterCommaTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ // final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for); {
+ // createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW);
+ // createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_incrementation, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
+ // }
+ final InnerNode invocation = createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arguments);
+ {
+ createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_function,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS,
+ METHOD_CALL_PREVIEW);
+ createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ }
+ final InnerNode decl = createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameters);
+ {
+ createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS,
+ METHOD_DECL_PREVIEW);
+ createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ }
+ final InnerNode lists = createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lists);
+ {
+ createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_declarator_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST,
+ DECLARATOR_LIST_PREVIEW);
+ createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_expression_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST,
+ EXPRESSION_LIST_PREVIEW);
+ createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ }
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS,
+ METHOD_DECL_PREVIEW);
+ }
+
+ private void createAfterOperatorTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
+ }
+
+ private void createAfterOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW);
+ }
+
+ private void createAfterOpenAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ }
+
+ private void createAfterOpenBraceTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ }
+
+ private void createAfterCloseBraceTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
+ }
+
+ private void createAfterCloseParenTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
+ }
+
+ private void createAfterClosingAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ //createOption(parent, workingValues, "WhiteSpaceOptions.parameterized_type", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW); //$NON-NLS-1$
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ }
+
+ private void createAfterOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
+
+ final InnerNode decls = createChild(parent, workingValues,
+ FormatterMessages.WhiteSpaceOptions_function_declaration);
+ {
+ createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_function,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION,
+ METHOD_DECL_PREVIEW);
+ }
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION,
+ METHOD_CALL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION,
+ PAREN_EXPR_PREVIEW);
+ }
+
+ private void createBetweenEmptyParenTree(Map<String, String> workingValues, final InnerNode parent) {
+
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_decl,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION,
+ METHOD_CALL_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_EXCEPTION_SPECIFICATION,
+ METHOD_CALL_PREVIEW);
+ }
+
+ private void createBetweenEmptyBracketsTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS, ARRAY_PREVIEW);
+ }
+
+ private void createBetweenEmptyBracesTree(Map<String, String> workingValues, final InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ }
+
+ // syntax element tree
+
+ private InnerNode createClassTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_classes);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_opening_brace_of_a_class,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION,
+ CLASS_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_colon_of_base_clause,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_after_colon_of_base_clause,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_comma_base_types,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_BASE_TYPES, CLASS_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_after_comma_base_types,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_BASE_TYPES, CLASS_DECL_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createAssignmentTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_before_assignment_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_after_assignment_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createOperatorTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_operators);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_binary_operators,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_binary_operators,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_unary_operators,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_unary_operators,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_prefix_operators,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_prefix_operators,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_postfix_operators,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_postfix_operators,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createMethodDeclTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_functions);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION,
+ METHOD_DECL_PREVIEW);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS,
+ METHOD_DECL_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createExceptionSpecificationTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_exception_specifications);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_EXCEPTION_SPECIFICATION,
+ METHOD_DECL_PREVIEW);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS,
+ METHOD_DECL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS,
+ METHOD_DECL_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createDeclaratorListTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_declarator_list);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list_before_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST,
+ DECLARATOR_LIST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list_after_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST,
+ DECLARATOR_LIST_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createExpressionListTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_expression_list);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_before_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST,
+ EXPRESSION_LIST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_after_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST,
+ EXPRESSION_LIST_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createInitializerListTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_initializer_list);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_brace,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_brace,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_braces,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_INITIALIZER_LIST,
+ INITIALIZER_LIST_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createArrayTree(Map<String, String> workingValues, InnerNode parent) {
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_brackets,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS, ARRAY_PREVIEW);
+ return parent;
+ }
+
+ private InnerNode createFunctionCallTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_calls);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION,
+ METHOD_CALL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION,
+ METHOD_CALL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION,
+ METHOD_CALL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION,
+ METHOD_CALL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_function_args,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS,
+ METHOD_CALL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_function_args,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS,
+ METHOD_CALL_PREVIEW);
+ // createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW);
+ // createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createBlockTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_blocks);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_brace,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createSwitchStatementTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_switch);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_case_colon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_default_colon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createDoWhileTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_do);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW);
+
+ return root;
+ }
+
+ private InnerNode createTryStatementTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_try);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createIfStatementTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_if);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createForStatementTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_for);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);
+ // createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW);
+ // createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW);
+ // createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
+ // createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_semicolon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_semicolon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW);
+
+ return root;
+ }
+
+ // private InnerNode createReturnTree(Map workingValues, InnerNode parent) {
+ // final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return);
+ // createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_parenthesized_expressions, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
+ // return root;
+ // }
+
+ // private InnerNode createThrowTree(Map workingValues, InnerNode parent) {
+ // final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw);
+ // createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_parenthesized_expressions, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);
+ // return root;
+ // }
+
+ private InnerNode createLabelTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_labels);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createTemplateArgumentTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_template_arguments);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_angle_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS,
+ TEMPLATES_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createTemplateParameterTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_template_parameters);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_angle_bracket,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS,
+ TEMPLATES_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createConditionalTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_conditionals);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_question,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL,
+ CONDITIONAL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_question,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL,
+ CONDITIONAL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createTypecastTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_typecasts);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
+ return root;
+ }
+
+ private InnerNode createParenthesizedExpressionTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_parenexpr);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION,
+ PAREN_EXPR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION,
+ PAREN_EXPR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION,
+ PAREN_EXPR_PREVIEW);
+ return root;
+ }
+
+ private static InnerNode createChild(InnerNode root, Map<String, String> workingValues, String message) {
+ return new InnerNode(root, workingValues, message);
+ }
+
+ private static OptionNode createOption(InnerNode root, Map<String, String> workingValues, String message,
+ String key, PreviewSnippet snippet) {
+ return new OptionNode(root, workingValues, message, key, snippet);
}
public static void makeIndexForNodes(List<? extends Node> tree, List<Node> flatList) {
- for (Node node : tree) {
- node.index= flatList.size();
- flatList.add(node);
- makeIndexForNodes(node.getChildren(), flatList);
- }
- }
+ for (Node node : tree) {
+ node.index = flatList.size();
+ flatList.add(node);
+ makeIndexForNodes(node.getChildren(), flatList);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java
index 728a557b3a7..b97792c0b29 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java
@@ -52,108 +52,115 @@ import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.Inner
import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.Node;
import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.OptionNode;
-
public class WhiteSpaceTabPage extends FormatterTabPage {
-
-
- /**
- * Encapsulates a view of the options tree which is structured by
- * syntactical element.
- */
-
- private final class SyntaxComponent implements ISelectionChangedListener, ICheckStateListener, IDoubleClickListener {
-
- private final String PREF_NODE_KEY= CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.node"; //$NON-NLS-1$
-
- private final List<Node> fIndexedNodeList;
+
+ /**
+ * Encapsulates a view of the options tree which is structured by
+ * syntactical element.
+ */
+
+ private final class SyntaxComponent
+ implements ISelectionChangedListener, ICheckStateListener, IDoubleClickListener {
+
+ private final String PREF_NODE_KEY = CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.node"; //$NON-NLS-1$
+
+ private final List<Node> fIndexedNodeList;
private final List<? extends Node> fTree;
-
+
private ContainerCheckedTreeViewer fTreeViewer;
private Composite fComposite;
-
- private Node fLastSelected= null;
- public SyntaxComponent() {
- fIndexedNodeList= new ArrayList<Node>();
- fTree= new WhiteSpaceOptions().createAltTree(fWorkingValues);
+ private Node fLastSelected = null;
+
+ public SyntaxComponent() {
+ fIndexedNodeList = new ArrayList<Node>();
+ fTree = new WhiteSpaceOptions().createAltTree(fWorkingValues);
WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
}
-
+
public void createContents(final int numColumns, final Composite parent) {
- fComposite= new Composite(parent, SWT.NONE);
+ fComposite = new Composite(parent, SWT.NONE);
fComposite.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, SWT.DEFAULT));
fComposite.setLayout(createGridLayout(numColumns, false));
-
- createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space);
-
- fTreeViewer= new ContainerCheckedTreeViewer(fComposite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
+
+ createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space);
+
+ fTreeViewer = new ContainerCheckedTreeViewer(fComposite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
fTreeViewer.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- return ((Collection<?>)inputElement).toArray();
+ return ((Collection<?>) inputElement).toArray();
}
+
@Override
public Object[] getChildren(Object parentElement) {
- return ((Node)parentElement).getChildren().toArray();
+ return ((Node) parentElement).getChildren().toArray();
}
+
@Override
public Object getParent(Object element) {
- return ((Node)element).getParent();
+ return ((Node) element).getParent();
}
+
@Override
public boolean hasChildren(Object element) {
- return ((Node)element).hasChildren();
+ return ((Node) element).hasChildren();
}
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
});
fTreeViewer.setLabelProvider(new LabelProvider());
- fTreeViewer.getControl().setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, SWT.DEFAULT));
+ fTreeViewer.getControl().setLayoutData(
+ createGridData(numColumns, GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, SWT.DEFAULT));
fDefaultFocusManager.add(fTreeViewer.getControl());
- }
-
+ }
+
public void initialize() {
fTreeViewer.addCheckStateListener(this);
fTreeViewer.addSelectionChangedListener(this);
fTreeViewer.addDoubleClickListener(this);
- fTreeViewer.setInput(fTree);
- restoreSelection();
- refreshState();
+ fTreeViewer.setInput(fTree);
+ restoreSelection();
+ refreshState();
}
-
+
public void refreshState() {
- final ArrayList<OptionNode> checked= new ArrayList<OptionNode>(100);
- for (Node node : fTree)
+ final ArrayList<OptionNode> checked = new ArrayList<OptionNode>(100);
+ for (Node node : fTree)
(node).getCheckedLeafs(checked);
- fTreeViewer.setGrayedElements(new Object[0]);
- fTreeViewer.setCheckedElements(checked.toArray());
- fPreview.clear();
- if (fLastSelected != null) {
- fPreview.addAll(fLastSelected.getSnippets());
- }
- doUpdatePreview();
+ fTreeViewer.setGrayedElements(new Object[0]);
+ fTreeViewer.setCheckedElements(checked.toArray());
+ fPreview.clear();
+ if (fLastSelected != null) {
+ fPreview.addAll(fLastSelected.getSnippets());
+ }
+ doUpdatePreview();
}
@Override
public void selectionChanged(SelectionChangedEvent event) {
- final IStructuredSelection selection= (IStructuredSelection)event.getSelection();
- if (selection.isEmpty())
- return;
- final Node node= (Node)selection.getFirstElement();
- if (node == fLastSelected)
- return;
- fDialogSettings.put(PREF_NODE_KEY, node.index);
- fPreview.clear();
- fPreview.addAll(node.getSnippets());
- doUpdatePreview();
- fLastSelected= node;
+ final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ if (selection.isEmpty())
+ return;
+ final Node node = (Node) selection.getFirstElement();
+ if (node == fLastSelected)
+ return;
+ fDialogSettings.put(PREF_NODE_KEY, node.index);
+ fPreview.clear();
+ fPreview.addAll(node.getSnippets());
+ doUpdatePreview();
+ fLastSelected = node;
}
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
- final Node node= (Node)event.getElement();
+ final Node node = (Node) event.getElement();
node.setChecked(event.getChecked());
doUpdatePreview();
notifyValuesModified();
@@ -162,316 +169,316 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
public void restoreSelection() {
int index;
try {
- index= fDialogSettings.getInt(PREF_NODE_KEY);
+ index = fDialogSettings.getInt(PREF_NODE_KEY);
} catch (NumberFormatException ex) {
- index= -1;
+ index = -1;
}
if (index < 0 || index > fIndexedNodeList.size() - 1) {
- index= 0;
+ index = 0;
}
- final Node node= fIndexedNodeList.get(index);
+ final Node node = fIndexedNodeList.get(index);
if (node != null) {
- fTreeViewer.expandToLevel(node, 0);
- fTreeViewer.setSelection(new StructuredSelection(new Node [] {node}));
- fLastSelected= node;
+ fTreeViewer.expandToLevel(node, 0);
+ fTreeViewer.setSelection(new StructuredSelection(new Node[] { node }));
+ fLastSelected = node;
}
}
- @Override
+ @Override
public void doubleClick(DoubleClickEvent event) {
- final ISelection selection= event.getSelection();
- if (selection instanceof IStructuredSelection) {
- final Node node= (Node)((IStructuredSelection)selection).getFirstElement();
- fTreeViewer.setExpandedState(node, !fTreeViewer.getExpandedState(node));
- }
- }
-
- public Control getControl() {
- return fComposite;
- }
+ final ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ final Node node = (Node) ((IStructuredSelection) selection).getFirstElement();
+ fTreeViewer.setExpandedState(node, !fTreeViewer.getExpandedState(node));
+ }
+ }
+
+ public Control getControl() {
+ return fComposite;
+ }
}
-
-
-
+
private final class CElementComponent implements ISelectionChangedListener, ICheckStateListener {
-
- private final String PREF_INNER_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.c_view.inner"; //$NON-NLS-1$
- private final String PREF_OPTION_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.c_view.option"; //$NON-NLS-1$
-
- private final ArrayList<Node> fIndexedNodeList;
- private final ArrayList<InnerNode> fTree;
-
- private InnerNode fLastSelected;
-
- private TreeViewer fInnerViewer;
- private CheckboxTableViewer fOptionsViewer;
-
- private Composite fComposite;
-
- public CElementComponent() {
- fIndexedNodeList= new ArrayList<Node>();
- fTree= new WhiteSpaceOptions().createTreeByCElement(fWorkingValues);
+
+ private final String PREF_INNER_INDEX = CUIPlugin.PLUGIN_ID + "formatter_page.white_space.c_view.inner"; //$NON-NLS-1$
+ private final String PREF_OPTION_INDEX = CUIPlugin.PLUGIN_ID + "formatter_page.white_space.c_view.option"; //$NON-NLS-1$
+
+ private final ArrayList<Node> fIndexedNodeList;
+ private final ArrayList<InnerNode> fTree;
+
+ private InnerNode fLastSelected;
+
+ private TreeViewer fInnerViewer;
+ private CheckboxTableViewer fOptionsViewer;
+
+ private Composite fComposite;
+
+ public CElementComponent() {
+ fIndexedNodeList = new ArrayList<Node>();
+ fTree = new WhiteSpaceOptions().createTreeByCElement(fWorkingValues);
WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
- }
+ }
+
+ public void createContents(int numColumns, Composite parent) {
- public void createContents(int numColumns, Composite parent) {
-
- fComposite= new Composite(parent, SWT.NONE);
+ fComposite = new Composite(parent, SWT.NONE);
fComposite.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, SWT.DEFAULT));
fComposite.setLayout(createGridLayout(numColumns, false));
-
- createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space, GridData.HORIZONTAL_ALIGN_BEGINNING);
-
- final SashForm sashForm= new SashForm(fComposite, SWT.VERTICAL);
+
+ createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space,
+ GridData.HORIZONTAL_ALIGN_BEGINNING);
+
+ final SashForm sashForm = new SashForm(fComposite, SWT.VERTICAL);
sashForm.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
-
- fInnerViewer= new TreeViewer(sashForm, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
+
+ fInnerViewer = new TreeViewer(sashForm, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
fInnerViewer.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- return ((Collection<?>)inputElement).toArray();
+ return ((Collection<?>) inputElement).toArray();
}
+
@Override
public Object[] getChildren(Object parentElement) {
- final List<Node> children= ((Node)parentElement).getChildren();
- final ArrayList<Object> innerChildren= new ArrayList<Object>();
- for (Object o : children) {
- if (o instanceof InnerNode) innerChildren.add(o);
- }
- return innerChildren.toArray();
+ final List<Node> children = ((Node) parentElement).getChildren();
+ final ArrayList<Object> innerChildren = new ArrayList<Object>();
+ for (Object o : children) {
+ if (o instanceof InnerNode)
+ innerChildren.add(o);
+ }
+ return innerChildren.toArray();
}
+
@Override
public Object getParent(Object element) {
- if (element instanceof InnerNode)
- return ((InnerNode)element).getParent();
- return null;
+ if (element instanceof InnerNode)
+ return ((InnerNode) element).getParent();
+ return null;
}
+
@Override
public boolean hasChildren(Object element) {
- final List<?> children= ((Node)element).getChildren();
- for (Object child : children)
- if (child instanceof InnerNode) return true;
- return false;
+ final List<?> children = ((Node) element).getChildren();
+ for (Object child : children)
+ if (child instanceof InnerNode)
+ return true;
+ return false;
}
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
});
-
+
fInnerViewer.setLabelProvider(new LabelProvider());
-
- final GridData innerGd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
- innerGd.heightHint= fPixelConverter.convertHeightInCharsToPixels(3);
+
+ final GridData innerGd = createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL,
+ SWT.DEFAULT);
+ innerGd.heightHint = fPixelConverter.convertHeightInCharsToPixels(3);
fInnerViewer.getControl().setLayoutData(innerGd);
-
- fOptionsViewer= CheckboxTableViewer.newCheckList(sashForm, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL);
+
+ fOptionsViewer = CheckboxTableViewer.newCheckList(sashForm, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL);
fOptionsViewer.setContentProvider(ArrayContentProvider.getInstance());
fOptionsViewer.setLabelProvider(new LabelProvider());
-
- final GridData optionsGd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
- optionsGd.heightHint= fPixelConverter.convertHeightInCharsToPixels(3);
+
+ final GridData optionsGd = createGridData(numColumns,
+ GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
+ optionsGd.heightHint = fPixelConverter.convertHeightInCharsToPixels(3);
fOptionsViewer.getControl().setLayoutData(optionsGd);
-
+
fDefaultFocusManager.add(fInnerViewer.getControl());
- fDefaultFocusManager.add(fOptionsViewer.getControl());
-
+ fDefaultFocusManager.add(fOptionsViewer.getControl());
+
fInnerViewer.setInput(fTree);
}
-
- public void refreshState() {
- if (fLastSelected != null) {
- innerViewerChanged(fLastSelected);
- }
- }
-
- public void initialize() {
- fInnerViewer.addSelectionChangedListener(this);
- fOptionsViewer.addSelectionChangedListener(this);
- fOptionsViewer.addCheckStateListener(this);
- restoreSelections();
- refreshState();
- }
-
- private void restoreSelections() {
- Node node;
- final int innerIndex= getValidatedIndex(PREF_INNER_INDEX);
- node= fIndexedNodeList.get(innerIndex);
+
+ public void refreshState() {
+ if (fLastSelected != null) {
+ innerViewerChanged(fLastSelected);
+ }
+ }
+
+ public void initialize() {
+ fInnerViewer.addSelectionChangedListener(this);
+ fOptionsViewer.addSelectionChangedListener(this);
+ fOptionsViewer.addCheckStateListener(this);
+ restoreSelections();
+ refreshState();
+ }
+
+ private void restoreSelections() {
+ Node node;
+ final int innerIndex = getValidatedIndex(PREF_INNER_INDEX);
+ node = fIndexedNodeList.get(innerIndex);
if (node instanceof InnerNode) {
- fInnerViewer.expandToLevel(node, 0);
- fInnerViewer.setSelection(new StructuredSelection(new Object[] {node}));
- fLastSelected= (InnerNode)node;
+ fInnerViewer.expandToLevel(node, 0);
+ fInnerViewer.setSelection(new StructuredSelection(new Object[] { node }));
+ fLastSelected = (InnerNode) node;
}
-
- final int optionIndex= getValidatedIndex(PREF_OPTION_INDEX);
- node= fIndexedNodeList.get(optionIndex);
+
+ final int optionIndex = getValidatedIndex(PREF_OPTION_INDEX);
+ node = fIndexedNodeList.get(optionIndex);
if (node instanceof OptionNode) {
- fOptionsViewer.setSelection(new StructuredSelection(new Object[] {node}));
+ fOptionsViewer.setSelection(new StructuredSelection(new Object[] { node }));
}
- }
-
- private int getValidatedIndex(String key) {
+ }
+
+ private int getValidatedIndex(String key) {
int index;
try {
- index= fDialogSettings.getInt(key);
+ index = fDialogSettings.getInt(key);
} catch (NumberFormatException ex) {
- index= 0;
+ index = 0;
}
if (index < 0 || index > fIndexedNodeList.size() - 1) {
- index= 0;
+ index = 0;
}
return index;
- }
-
- public Control getControl() {
- return fComposite;
- }
+ }
- @Override
+ public Control getControl() {
+ return fComposite;
+ }
+
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
- final IStructuredSelection selection= (IStructuredSelection)event.getSelection();
-
- if (selection.isEmpty() || !(selection.getFirstElement() instanceof Node))
- return;
-
- final Node selected= (Node)selection.getFirstElement();
-
- if (selected == null || selected == fLastSelected)
- return;
-
-
- if (event.getSource() == fInnerViewer && selected instanceof InnerNode) {
- fLastSelected= (InnerNode)selected;
- fDialogSettings.put(PREF_INNER_INDEX, selected.index);
- innerViewerChanged((InnerNode)selected);
- }
- else if (event.getSource() == fOptionsViewer && selected instanceof OptionNode)
- fDialogSettings.put(PREF_OPTION_INDEX, selected.index);
- }
-
- private void innerViewerChanged(InnerNode selectedNode) {
-
- final List<Node> children= selectedNode.getChildren();
-
- final ArrayList<OptionNode> optionsChildren= new ArrayList<OptionNode>();
+ final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+
+ if (selection.isEmpty() || !(selection.getFirstElement() instanceof Node))
+ return;
+
+ final Node selected = (Node) selection.getFirstElement();
+
+ if (selected == null || selected == fLastSelected)
+ return;
+
+ if (event.getSource() == fInnerViewer && selected instanceof InnerNode) {
+ fLastSelected = (InnerNode) selected;
+ fDialogSettings.put(PREF_INNER_INDEX, selected.index);
+ innerViewerChanged((InnerNode) selected);
+ } else if (event.getSource() == fOptionsViewer && selected instanceof OptionNode)
+ fDialogSettings.put(PREF_OPTION_INDEX, selected.index);
+ }
+
+ private void innerViewerChanged(InnerNode selectedNode) {
+
+ final List<Node> children = selectedNode.getChildren();
+
+ final ArrayList<OptionNode> optionsChildren = new ArrayList<OptionNode>();
for (Object o : children) {
- if (o instanceof OptionNode) optionsChildren.add((OptionNode) o);
+ if (o instanceof OptionNode)
+ optionsChildren.add((OptionNode) o);
}
-
+
fOptionsViewer.setInput(optionsChildren.toArray());
-
+
for (OptionNode child : optionsChildren) {
fOptionsViewer.setChecked(child, child.getChecked());
}
-
+
fPreview.clear();
fPreview.addAll(selectedNode.getSnippets());
doUpdatePreview();
- }
-
- @Override
+ }
+
+ @Override
public void checkStateChanged(CheckStateChangedEvent event) {
- final OptionNode option= (OptionNode)event.getElement();
+ final OptionNode option = (OptionNode) event.getElement();
if (option != null)
- option.setChecked(event.getChecked());
+ option.setChecked(event.getChecked());
doUpdatePreview();
notifyValuesModified();
- }
+ }
}
-
-
/**
* This component switches between the two view and is responsible for delegating
* the appropriate update requests.
*/
private final class SwitchComponent extends SelectionAdapter {
- private final String PREF_VIEW_KEY= CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.view"; //$NON-NLS-1$
- private final String [] fItems= new String [] {
- FormatterMessages.WhiteSpaceTabPage_sort_by_c_element,
- FormatterMessages.WhiteSpaceTabPage_sort_by_syntax_element
- };
-
- private Combo fSwitchCombo;
- private PageBook fPageBook;
- private final SyntaxComponent fSyntaxComponent;
- private final CElementComponent fCElementComponent;
-
- public SwitchComponent() {
- fSyntaxComponent= new SyntaxComponent();
- fCElementComponent= new CElementComponent();
- }
-
- @Override
+ private final String PREF_VIEW_KEY = CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.view"; //$NON-NLS-1$
+ private final String[] fItems = new String[] { FormatterMessages.WhiteSpaceTabPage_sort_by_c_element,
+ FormatterMessages.WhiteSpaceTabPage_sort_by_syntax_element };
+
+ private Combo fSwitchCombo;
+ private PageBook fPageBook;
+ private final SyntaxComponent fSyntaxComponent;
+ private final CElementComponent fCElementComponent;
+
+ public SwitchComponent() {
+ fSyntaxComponent = new SyntaxComponent();
+ fCElementComponent = new CElementComponent();
+ }
+
+ @Override
public void widgetSelected(SelectionEvent e) {
- final int index= fSwitchCombo.getSelectionIndex();
- if (index == 0) {
- fDialogSettings.put(PREF_VIEW_KEY, false);
- fCElementComponent.refreshState();
- fPageBook.showPage(fCElementComponent.getControl());
- }
- else if (index == 1) {
- fDialogSettings.put(PREF_VIEW_KEY, true);
- fSyntaxComponent.refreshState();
- fPageBook.showPage(fSyntaxComponent.getControl());
- }
- }
-
- public void createContents(int numColumns, Composite parent) {
-
- fPageBook= new PageBook(parent, SWT.NONE);
- fPageBook.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
-
- fCElementComponent.createContents(numColumns, fPageBook);
- fSyntaxComponent.createContents(numColumns, fPageBook);
-
- fSwitchCombo= new Combo(parent, SWT.READ_ONLY);
- final GridData gd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_END, SWT.DEFAULT);
- fSwitchCombo.setLayoutData(gd);
- fSwitchCombo.setItems(fItems);
- }
-
- public void initialize() {
- fSwitchCombo.addSelectionListener(this);
- fCElementComponent.initialize();
- fSyntaxComponent.initialize();
- restoreSelection();
- }
-
- private void restoreSelection() {
- final boolean selectSyntax= fDialogSettings.getBoolean(PREF_VIEW_KEY);
- if (selectSyntax) {
- fSyntaxComponent.refreshState();
- fSwitchCombo.setText(fItems[1]);
- fPageBook.showPage(fSyntaxComponent.getControl());
+ final int index = fSwitchCombo.getSelectionIndex();
+ if (index == 0) {
+ fDialogSettings.put(PREF_VIEW_KEY, false);
+ fCElementComponent.refreshState();
+ fPageBook.showPage(fCElementComponent.getControl());
+ } else if (index == 1) {
+ fDialogSettings.put(PREF_VIEW_KEY, true);
+ fSyntaxComponent.refreshState();
+ fPageBook.showPage(fSyntaxComponent.getControl());
+ }
+ }
+
+ public void createContents(int numColumns, Composite parent) {
+
+ fPageBook = new PageBook(parent, SWT.NONE);
+ fPageBook.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
+
+ fCElementComponent.createContents(numColumns, fPageBook);
+ fSyntaxComponent.createContents(numColumns, fPageBook);
+
+ fSwitchCombo = new Combo(parent, SWT.READ_ONLY);
+ final GridData gd = createGridData(numColumns, GridData.HORIZONTAL_ALIGN_END, SWT.DEFAULT);
+ fSwitchCombo.setLayoutData(gd);
+ fSwitchCombo.setItems(fItems);
+ }
+
+ public void initialize() {
+ fSwitchCombo.addSelectionListener(this);
+ fCElementComponent.initialize();
+ fSyntaxComponent.initialize();
+ restoreSelection();
+ }
+
+ private void restoreSelection() {
+ final boolean selectSyntax = fDialogSettings.getBoolean(PREF_VIEW_KEY);
+ if (selectSyntax) {
+ fSyntaxComponent.refreshState();
+ fSwitchCombo.setText(fItems[1]);
+ fPageBook.showPage(fSyntaxComponent.getControl());
} else {
- fCElementComponent.refreshState();
- fSwitchCombo.setText(fItems[0]);
- fPageBook.showPage(fCElementComponent.getControl());
+ fCElementComponent.refreshState();
+ fSwitchCombo.setText(fItems[0]);
+ fPageBook.showPage(fCElementComponent.getControl());
}
- }
+ }
}
-
-
-
private final SwitchComponent fSwitchComponent;
- protected final IDialogSettings fDialogSettings;
+ protected final IDialogSettings fDialogSettings;
protected SnippetPreview fPreview;
-
/**
* Create a new white space dialog page.
* @param modifyDialog
* @param workingValues
*/
- public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
+ public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
super(modifyDialog, workingValues);
- fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
- fSwitchComponent= new SwitchComponent();
+ fDialogSettings = CUIPlugin.getDefault().getDialogSettings();
+ fSwitchComponent = new SwitchComponent();
}
@Override
@@ -481,18 +488,18 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
@Override
protected void initializePage() {
- fSwitchComponent.initialize();
+ fSwitchComponent.initialize();
}
-
- @Override
+
+ @Override
protected CPreview doCreateCPreview(Composite parent) {
- fPreview= new SnippetPreview(fWorkingValues, parent);
- return fPreview;
- }
+ fPreview = new SnippetPreview(fWorkingValues, parent);
+ return fPreview;
+ }
- @Override
+ @Override
protected void doUpdatePreview() {
- super.doUpdatePreview();
- fPreview.update();
- }
+ super.doUpdatePreview();
+ fPreview.update();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
index f6e72684ff1..d49b74be64b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -69,7 +69,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
* AST creation, condition checking, change generating, and selection handling.
*/
public abstract class CRefactoring extends Refactoring {
- protected String name = Messages.Refactoring_name;
+ protected String name = Messages.Refactoring_name;
protected final ICProject project;
protected final ITranslationUnit tu;
protected Region selectedRegion;
@@ -79,14 +79,14 @@ public abstract class CRefactoring extends Refactoring {
public CRefactoring(ICElement element, ISelection selection, ICProject project) {
this.project = project;
- this.initStatus= new RefactoringStatus();
+ this.initStatus = new RefactoringStatus();
if (!(element instanceof ISourceReference)) {
tu = null;
initStatus.addFatalError(Messages.Refactoring_SelectionNotValid);
return;
}
- ISourceReference sourceRef= (ISourceReference) element;
+ ISourceReference sourceRef = (ISourceReference) element;
tu = CModelUtil.toWorkingCopy(sourceRef.getTranslationUnit());
if (selection instanceof ITextSelection) {
@@ -112,19 +112,19 @@ public abstract class CRefactoring extends Refactoring {
SubMonitor progress = SubMonitor.convert(pm, Messages.CRefactoring_checking_final_conditions, 12);
try {
- CheckConditionsContext context= new CheckConditionsContext();
+ CheckConditionsContext context = new CheckConditionsContext();
context.add(new ValidateEditChecker(getValidationContext()));
ResourceChangeChecker resourceChecker = new ResourceChangeChecker();
IResourceChangeDescriptionFactory deltaFactory = resourceChecker.getDeltaFactory();
context.add(resourceChecker);
-
+
RefactoringStatus result = checkFinalConditions(progress.split(8), context);
if (result.hasFatalError())
return result;
-
+
modificationCollector = new ModificationCollector(deltaFactory);
collectModifications(progress.split(2), modificationCollector);
-
+
result.merge(context.check(progress.split(2)));
return result;
} finally {
@@ -144,7 +144,7 @@ public abstract class CRefactoring extends Refactoring {
if (isProgressMonitorCanceled(sm, initStatus)) {
return initStatus;
}
- sm.subTask(Messages.Refactoring_PM_LoadTU);
+ sm.subTask(Messages.Refactoring_PM_LoadTU);
IASTTranslationUnit ast = getAST(tu, sm);
if (ast == null) {
initStatus.addError(NLS.bind(Messages.Refactoring_ParsingError, tu.getPath()));
@@ -153,17 +153,17 @@ public abstract class CRefactoring extends Refactoring {
if (isProgressMonitorCanceled(sm, initStatus)) {
return initStatus;
}
- sm.subTask(Messages.Refactoring_PM_CheckTU);
+ sm.subTask(Messages.Refactoring_PM_CheckTU);
checkAST(ast);
sm.worked(2);
- sm.subTask(Messages.Refactoring_PM_InitRef);
+ sm.subTask(Messages.Refactoring_PM_InitRef);
sm.done();
return initStatus;
}
protected static boolean isProgressMonitorCanceled(IProgressMonitor sm, RefactoringStatus status) {
if (sm.isCanceled()) {
- status.addFatalError(Messages.Refactoring_CanceledByUser);
+ status.addFatalError(Messages.Refactoring_CanceledByUser);
return true;
}
return false;
@@ -204,7 +204,7 @@ public abstract class CRefactoring extends Refactoring {
protected boolean checkAST(IASTTranslationUnit ast) {
ProblemFinder problemFinder = new ProblemFinder(initStatus);
- ast.accept(problemFinder);
+ ast.accept(problemFinder);
return problemFinder.hasProblem();
}
@@ -218,9 +218,9 @@ public abstract class CRefactoring extends Refactoring {
@Override
public int visit(IASTName name) {
- if (name.isPartOfTranslationUnitFile() &&
- SelectionHelper.doesNodeOverlapWithRegion(name, selectedRegion) &&
- !(name instanceof ICPPASTQualifiedName)) {
+ if (name.isPartOfTranslationUnitFile()
+ && SelectionHelper.doesNodeOverlapWithRegion(name, selectedRegion)
+ && !(name instanceof ICPPASTQualifiedName)) {
names.add(name);
}
return super.visit(name);
@@ -232,7 +232,7 @@ public abstract class CRefactoring extends Refactoring {
private class ProblemFinder extends ASTVisitor {
private boolean problemFound = false;
private final RefactoringStatus status;
-
+
public ProblemFinder(RefactoringStatus status) {
this.status = status;
}
@@ -289,7 +289,7 @@ public abstract class CRefactoring extends Refactoring {
private void addWarningToState() {
if (!problemFound) {
- status.addWarning(Messages.Refactoring_CompileErrorInTU);
+ status.addWarning(Messages.Refactoring_CompileErrorInTU);
problemFound = true;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java
index 6ea47da60b9..229c4292150 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java
@@ -44,8 +44,7 @@ import org.eclipse.cdt.internal.ui.editor.ASTProvider;
*/
public class CRefactoringContext extends RefactoringContext {
private static final int PARSE_MODE = ITranslationUnit.AST_SKIP_ALL_HEADERS
- | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
- | ITranslationUnit.AST_PARSE_INACTIVE_CODE;
+ | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_PARSE_INACTIVE_CODE;
private final Map<ITranslationUnit, IASTTranslationUnit> fASTCache;
private IIndex fIndex;
@@ -75,46 +74,45 @@ public class CRefactoringContext extends RefactoringContext {
throws CoreException, OperationCanceledException {
if (isDisposed())
throw new IllegalStateException("CRefactoringContext is already disposed."); //$NON-NLS-1$
- getIndex(); // Make sure the index is locked.
+ getIndex(); // Make sure the index is locked.
if (pm != null && pm.isCanceled())
throw new OperationCanceledException();
- tu= CModelUtil.toWorkingCopy(tu);
- // Try to get a shared AST before creating our own.
- IASTTranslationUnit ast= fASTCache.get(tu);
- if (ast == null) {
- if (fSharedAST != null && tu.equals(fSharedAST.getOriginatingTranslationUnit())) {
- ast = fSharedAST;
- } else {
- ast = ASTProvider.getASTProvider().acquireSharedAST(tu, fIndex,
- ASTProvider.WAIT_ACTIVE_ONLY, pm);
+ tu = CModelUtil.toWorkingCopy(tu);
+ // Try to get a shared AST before creating our own.
+ IASTTranslationUnit ast = fASTCache.get(tu);
+ if (ast == null) {
+ if (fSharedAST != null && tu.equals(fSharedAST.getOriginatingTranslationUnit())) {
+ ast = fSharedAST;
+ } else {
+ ast = ASTProvider.getASTProvider().acquireSharedAST(tu, fIndex, ASTProvider.WAIT_ACTIVE_ONLY, pm);
if (ast != null && ast.hasNodesOmitted()) {
// Don't use an incomplete AST.
ASTProvider.getASTProvider().releaseSharedAST(ast);
ast = null;
}
- if (ast == null) {
- if (pm != null && pm.isCanceled())
+ if (ast == null) {
+ if (pm != null && pm.isCanceled())
throw new OperationCanceledException();
- ast= tu.getAST(fIndex, PARSE_MODE);
- fASTCache.put(tu, ast);
- } else {
- if (fSharedAST != null) {
- ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
- }
- fSharedAST = ast;
- }
- }
- }
- if (pm != null) {
- pm.done();
- }
- return ast;
- }
+ ast = tu.getAST(fIndex, PARSE_MODE);
+ fASTCache.put(tu, ast);
+ } else {
+ if (fSharedAST != null) {
+ ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
+ }
+ fSharedAST = ast;
+ }
+ }
+ }
+ if (pm != null) {
+ pm.done();
+ }
+ return ast;
+ }
/**
* Returns the index that can be safely used for reading until the cache is disposed.
- *
+ *
* @return The index.
*/
public IIndex getIndex() throws CoreException, OperationCanceledException {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java
index ce89455b9d4..0f61094f55c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS)- initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java
index 5a44394c3c2..fce47442580 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS)- initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -47,8 +47,8 @@ public abstract class CRefactoringDescriptor extends RefactoringDescriptor {
public static final String SELECTION = "selection"; //$NON-NLS-1$
protected Map<String, String> arguments;
- public CRefactoringDescriptor(String id, String project, String description, String comment,
- int flags, Map<String, String> arguments) {
+ public CRefactoringDescriptor(String id, String project, String description, String comment, int flags,
+ Map<String, String> arguments) {
super(id, project, description, comment, flags);
this.arguments = arguments;
}
@@ -62,7 +62,7 @@ public abstract class CRefactoringDescriptor extends RefactoringDescriptor {
@Override
public CRefactoringContext createRefactoringContext(RefactoringStatus status) throws CoreException {
- CRefactoring refactoring= createRefactoring(status);
+ CRefactoring refactoring = createRefactoring(status);
if (refactoring == null)
return null;
return new CRefactoringContext(refactoring);
@@ -76,8 +76,8 @@ public abstract class CRefactoringDescriptor extends RefactoringDescriptor {
int length = Integer.parseInt(selectStrings[1]);
selection = new TextSelection(offset, length);
} else {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
- Messages.CRefactoringDescriptor_illegal_selection));
+ throw new CoreException(
+ new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, Messages.CRefactoringDescriptor_illegal_selection));
}
return selection;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java
index 4d571140a56..fe224b3cb59 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring;
import org.eclipse.core.resources.IFile;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java
index 40c6eff3863..8a16c0ebea0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java
@@ -73,25 +73,27 @@ public class ChangeExceptionHandler {
private String fName;
private static class RefactorErrorDialog extends ErrorDialog {
- public RefactorErrorDialog(Shell parentShell, String dialogTitle, String dialogMessage, IStatus status, int displayMask) {
+ public RefactorErrorDialog(Shell parentShell, String dialogTitle, String dialogMessage, IStatus status,
+ int displayMask) {
super(parentShell, dialogTitle, dialogMessage, status, displayMask);
}
-
+
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
- Button ok= getButton(IDialogConstants.OK_ID);
+ Button ok = getButton(IDialogConstants.OK_ID);
ok.setText(Messages.ChangeExceptionHandler_undo_button);
- Button abort= createButton(parent, IDialogConstants.CANCEL_ID, Messages.ChangeExceptionHandler_abort_button, true);
+ Button abort = createButton(parent, IDialogConstants.CANCEL_ID,
+ Messages.ChangeExceptionHandler_abort_button, true);
abort.moveBelow(ok);
abort.setFocus();
}
-
+
@Override
protected Control createMessageArea(Composite parent) {
- Control result= super.createMessageArea(parent);
+ Control result = super.createMessageArea(parent);
new Label(parent, SWT.NONE); // filler
- Label label= new Label(parent, SWT.NONE);
+ Label label = new Label(parent, SWT.NONE);
label.setText(Messages.ChangeExceptionHandler_message);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
applyDialogFont(result);
@@ -100,19 +102,19 @@ public class ChangeExceptionHandler {
}
public ChangeExceptionHandler(Shell parent, Refactoring refactoring) {
- fParent= parent;
- fName= refactoring.getName();
+ fParent = parent;
+ fName = refactoring.getName();
}
public void handle(Change change, RuntimeException exception) {
CUIPlugin.log(exception);
- IStatus status= null;
+ IStatus status = null;
if (exception.getMessage() == null) {
- status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
- Messages.ChangeExceptionHandler_status_without_detail, exception);
+ status = new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
+ Messages.ChangeExceptionHandler_status_without_detail, exception);
} else {
- status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
- exception.getMessage(), exception);
+ status = new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, exception.getMessage(),
+ exception);
}
handle(change, status);
}
@@ -124,35 +126,34 @@ public class ChangeExceptionHandler {
private void handle(Change change, IStatus status) {
if (change instanceof CompositeChange) {
- Change undo= ((CompositeChange)change).getUndoUntilException();
+ Change undo = ((CompositeChange) change).getUndoUntilException();
if (undo != null) {
CUIPlugin.log(status);
- final ErrorDialog dialog= new RefactorErrorDialog(fParent,
- Messages.ChangeExceptionHandler_dialog_title,
- NLS.bind(Messages.ChangeExceptionHandler_dialog_message, fName),
- status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
- int result= dialog.open();
+ final ErrorDialog dialog = new RefactorErrorDialog(fParent,
+ Messages.ChangeExceptionHandler_dialog_title,
+ NLS.bind(Messages.ChangeExceptionHandler_dialog_message, fName), status,
+ IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
+ int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
performUndo(undo);
}
return;
}
}
- ErrorDialog dialog= new ErrorDialog(fParent,
- Messages.ChangeExceptionHandler_dialog_title,
- NLS.bind(Messages.ChangeExceptionHandler_dialog_message, fName),
- status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
+ ErrorDialog dialog = new ErrorDialog(fParent, Messages.ChangeExceptionHandler_dialog_title,
+ NLS.bind(Messages.ChangeExceptionHandler_dialog_message, fName), status,
+ IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
dialog.open();
}
private void performUndo(final Change undo) {
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", 11); //$NON-NLS-1$
+ monitor.beginTask("", 11); //$NON-NLS-1$
try {
undo.initializeValidationData(new NotCancelableProgressMonitor(new SubProgressMonitor(monitor, 1)));
- if (undo.isValid(new SubProgressMonitor(monitor,1)).hasFatalError()) {
+ if (undo.isValid(new SubProgressMonitor(monitor, 1)).hasFatalError()) {
monitor.done();
return;
}
@@ -162,15 +163,14 @@ public class ChangeExceptionHandler {
}
}
};
- WorkbenchRunnableAdapter adapter= new WorkbenchRunnableAdapter(runnable,
- ResourcesPlugin.getWorkspace().getRoot());
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(fParent);
+ WorkbenchRunnableAdapter adapter = new WorkbenchRunnableAdapter(runnable,
+ ResourcesPlugin.getWorkspace().getRoot());
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(fParent);
try {
dialog.run(false, false, adapter);
} catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, fParent,
- Messages.ChangeExceptionHandler_undo_dialog_title,
- NLS.bind(Messages.ChangeExceptionHandler_undo_dialog_message, fName));
+ ExceptionHandler.handle(e, fParent, Messages.ChangeExceptionHandler_undo_dialog_title,
+ NLS.bind(Messages.ChangeExceptionHandler_undo_dialog_message, fName));
} catch (InterruptedException e) {
// can't happen
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeParametersControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeParametersControl.java
index ff7d4a144ac..b1dd0f065f8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeParametersControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeParametersControl.java
@@ -76,7 +76,7 @@ public class ChangeParametersControl extends Composite {
public static enum Mode {
EXTRACT_METHOD, EXTRACT_METHOD_FIXED_RETURN, CHANGE_METHOD_SIGNATURE, INTRODUCE_PARAMETER;
-
+
public boolean canChangeTypes() {
return this == CHANGE_METHOD_SIGNATURE;
}
@@ -106,9 +106,9 @@ public class ChangeParametersControl extends Composite {
}
private NameInformation[] removeMarkedAsDeleted(List<NameInformation> params) {
- List<NameInformation> result= new ArrayList<NameInformation>(params.size());
- for (Iterator<NameInformation> iter= params.iterator(); iter.hasNext();) {
- NameInformation info= iter.next();
+ List<NameInformation> result = new ArrayList<NameInformation>(params.size());
+ for (Iterator<NameInformation> iter = params.iterator(); iter.hasNext();) {
+ NameInformation info = iter.next();
if (!info.isDeleted())
result.add(info);
}
@@ -135,7 +135,7 @@ public class ChangeParametersControl extends Composite {
@Override
public String getColumnText(Object element, int columnIndex) {
- NameInformation info= (NameInformation) element;
+ NameInformation info = (NameInformation) element;
if (columnIndex == indexType) {
return info.getTypeName();
} else if (columnIndex == indexDirection) {
@@ -143,11 +143,11 @@ public class ChangeParametersControl extends Composite {
} else if (columnIndex == indexName) {
return info.getNewName();
} else if (columnIndex == indexDefault) {
- if (info.isAdded()) {
- return info.getDefaultValue();
- } else {
- return "-"; //$NON-NLS-1$
- }
+ if (info.isAdded()) {
+ return info.getDefaultValue();
+ } else {
+ return "-"; //$NON-NLS-1$
+ }
} else {
throw new IllegalArgumentException(columnIndex + ": " + element); //$NON-NLS-1$
}
@@ -155,7 +155,7 @@ public class ChangeParametersControl extends Composite {
@Override
public Font getFont(Object element, int columnIndex) {
- NameInformation info= (NameInformation) element;
+ NameInformation info = (NameInformation) element;
if (info.isAdded()) {
return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
}
@@ -199,19 +199,19 @@ public class ChangeParametersControl extends Composite {
@Override
public void modify(Object element, String property, Object value) {
if (element instanceof TableItem)
- element= ((TableItem) element).getData();
+ element = ((TableItem) element).getData();
if (!(element instanceof NameInformation))
return;
String[] columnsToUpdate = new String[] { property };
boolean unchanged;
- NameInformation parameterInfo= (NameInformation) element;
+ NameInformation parameterInfo = (NameInformation) element;
if (property.equals(columnProperties[indexType])) {
- unchanged= parameterInfo.getTypeName().equals(value);
+ unchanged = parameterInfo.getTypeName().equals(value);
parameterInfo.setTypeName((String) value);
} else if (property.equals(columnProperties[indexDirection])) {
columnsToUpdate = new String[] { property, columnProperties[indexType] };
boolean isReturn = value.equals(INDEX_RETURN);
- unchanged= isReturn == parameterInfo.isReturnValue();
+ unchanged = isReturn == parameterInfo.isReturnValue();
if (!unchanged && isReturn) {
for (NameInformation param : fParameters) {
if (param != parameterInfo && param.isOutput()) {
@@ -224,10 +224,10 @@ public class ChangeParametersControl extends Composite {
}
parameterInfo.setReturnValue(isReturn);
} else if (property.equals(columnProperties[indexName])) {
- unchanged= parameterInfo.getNewName().equals(value);
+ unchanged = parameterInfo.getNewName().equals(value);
parameterInfo.setNewName((String) value);
} else if (property.equals(columnProperties[indexDefault])) {
- unchanged= parameterInfo.getDefaultValue().equals(value);
+ unchanged = parameterInfo.getDefaultValue().equals(value);
parameterInfo.setDefaultValue((String) value);
} else {
throw new IllegalStateException();
@@ -241,11 +241,8 @@ public class ChangeParametersControl extends Composite {
private static class DirectionCellEditor extends ComboBoxCellEditor {
DirectionCellEditor(Table table) {
- super(table,
- new String[] {
- /* INDEX_OUTPUT */ Messages.ChangeParametersControl_output,
- /* INDEX_RETURN */ Messages.ChangeParametersControl_return},
- SWT.READ_ONLY);
+ super(table, new String[] { /* INDEX_OUTPUT */ Messages.ChangeParametersControl_output,
+ /* INDEX_RETURN */ Messages.ChangeParametersControl_return }, SWT.READ_ONLY);
}
@Override
@@ -270,7 +267,7 @@ public class ChangeParametersControl extends Composite {
private static final int ROW_COUNT = 7;
static final Integer INDEX_OUTPUT = 0;
- static final Integer INDEX_RETURN = 1;
+ static final Integer INDEX_RETURN = 1;
private final Mode fMode;
private final IParameterListChangeListener fListener;
@@ -286,18 +283,18 @@ public class ChangeParametersControl extends Composite {
private Button fAddButton;
private Button fRemoveButton;
- public ChangeParametersControl(Composite parent, int style, String label,
- IParameterListChangeListener listener, Mode mode, StubTypeContext typeContext) {
+ public ChangeParametersControl(Composite parent, int style, String label, IParameterListChangeListener listener,
+ Mode mode, StubTypeContext typeContext) {
this(parent, style, label, listener, mode, typeContext, new String[0]);
}
- public ChangeParametersControl(Composite parent, int style, String label,
- IParameterListChangeListener listener, Mode mode) {
+ public ChangeParametersControl(Composite parent, int style, String label, IParameterListChangeListener listener,
+ Mode mode) {
this(parent, style, label, listener, mode, null, new String[0]);
}
- public ChangeParametersControl(Composite parent, int style, String label,
- IParameterListChangeListener listener, Mode mode, String[] paramNameProposals) {
+ public ChangeParametersControl(Composite parent, int style, String label, IParameterListChangeListener listener,
+ Mode mode, String[] paramNameProposals) {
this(parent, style, label, listener, mode, null, paramNameProposals);
}
@@ -305,15 +302,14 @@ public class ChangeParametersControl extends Composite {
* @param label the label before the table or <code>null</code>
* @param typeContext the package in which to complete types
*/
- private ChangeParametersControl(Composite parent, int style, String label,
- IParameterListChangeListener listener, Mode mode, StubTypeContext typeContext,
- String[] paramNameProposals) {
+ private ChangeParametersControl(Composite parent, int style, String label, IParameterListChangeListener listener,
+ Mode mode, StubTypeContext typeContext, String[] paramNameProposals) {
super(parent, style);
Assert.isNotNull(listener);
- fListener= listener;
- fMode= mode;
- fTypeContext= typeContext;
- fParamNameProposals= paramNameProposals;
+ fListener = listener;
+ fMode = mode;
+ fTypeContext = typeContext;
+ fParamNameProposals = paramNameProposals;
ArrayList<String> properties = new ArrayList<String>();
indexType = properties.size();
@@ -336,17 +332,17 @@ public class ChangeParametersControl extends Composite {
indexDefault = -1;
}
columnProperties = properties.toArray(new String[properties.size()]);
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
setLayout(layout);
if (label != null) {
- Label tableLabel= new Label(this, SWT.NONE);
- GridData labelGd= new GridData();
- labelGd.horizontalSpan= 2;
+ Label tableLabel = new Label(this, SWT.NONE);
+ GridData labelGd = new GridData();
+ labelGd.horizontalSpan = 2;
tableLabel.setLayoutData(labelGd);
tableLabel.setText(label);
}
@@ -357,7 +353,7 @@ public class ChangeParametersControl extends Composite {
public void setInput(List<NameInformation> parameterInfos) {
Assert.isNotNull(parameterInfos);
- fParameters= parameterInfos;
+ fParameters = parameterInfos;
fTableViewer.setInput(fParameters);
if (fParameters.size() > 0)
fTableViewer.setSelection(new StructuredSelection(fParameters.get(0)));
@@ -376,39 +372,39 @@ public class ChangeParametersControl extends Composite {
// ---- Parameter table -----------------------------------------------------------------------------------
private void createParameterList(Composite parent) {
- TableLayoutComposite layouter= new TableLayoutComposite(parent, SWT.NONE);
+ TableLayoutComposite layouter = new TableLayoutComposite(parent, SWT.NONE);
addColumnLayoutData(layouter);
- final Table table= new Table(layouter, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
+ final Table table = new Table(layouter, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tc;
- tc= new TableColumn(table, SWT.NONE, indexType);
+ tc = new TableColumn(table, SWT.NONE, indexType);
tc.setResizable(true);
tc.setText(Messages.ChangeParametersControl_table_type);
if (indexDirection >= 0) {
- tc= new TableColumn(table, SWT.NONE, indexDirection);
+ tc = new TableColumn(table, SWT.NONE, indexDirection);
tc.setResizable(true);
tc.setText(Messages.ChangeParametersControl_table_direction);
}
- tc= new TableColumn(table, SWT.NONE, indexName);
+ tc = new TableColumn(table, SWT.NONE, indexName);
tc.setResizable(true);
tc.setText(Messages.ChangeParametersControl_table_name);
if (indexDefault >= 0) {
- tc= new TableColumn(table, SWT.NONE, indexDefault);
+ tc = new TableColumn(table, SWT.NONE, indexDefault);
tc.setResizable(true);
tc.setText(Messages.ChangeParametersControl_table_default_value);
}
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= SWTUtil.getTableHeightHint(table, ROW_COUNT);
- gd.widthHint= 40;
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = SWTUtil.getTableHeightHint(table, ROW_COUNT);
+ gd.widthHint = 40;
layouter.setLayoutData(gd);
- fTableViewer= new TableViewer(table);
+ fTableViewer = new TableViewer(table);
fTableViewer.setUseHashlookup(true);
fTableViewer.setContentProvider(new NameInformationContentProvider());
fTableViewer.setLabelProvider(new NameInformationLabelProvider());
@@ -424,7 +420,7 @@ public class ChangeParametersControl extends Composite {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN && e.stateMask == SWT.NONE) {
editColumnOrNextPossible(0);
- e.detail= SWT.TRAVERSE_NONE;
+ e.detail = SWT.TRAVERSE_NONE;
}
}
});
@@ -433,7 +429,7 @@ public class ChangeParametersControl extends Composite {
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.F2 && e.stateMask == SWT.NONE) {
editColumnOrNextPossible(0);
- e.doit= false;
+ e.doit = false;
}
}
});
@@ -442,36 +438,34 @@ public class ChangeParametersControl extends Composite {
}
private static String getDirectionLabel(NameInformation parameter) {
- return parameter.isReturnValue() ?
- Messages.ChangeParametersControl_return :
- parameter.isOutput() ?
- Messages.ChangeParametersControl_output :
- Messages.ChangeParametersControl_input;
+ return parameter.isReturnValue() ? Messages.ChangeParametersControl_return
+ : parameter.isOutput() ? Messages.ChangeParametersControl_output
+ : Messages.ChangeParametersControl_input;
}
private void editColumnOrNextPossible(int column) {
- NameInformation[] selected= getSelectedElements();
+ NameInformation[] selected = getSelectedElements();
if (selected.length != 1)
return;
- int nextColumn= column;
+ int nextColumn = column;
do {
fTableViewer.editElement(selected[0], nextColumn);
if (fTableViewer.isCellEditorActive())
return;
- nextColumn= nextColumn(nextColumn);
+ nextColumn = nextColumn(nextColumn);
} while (nextColumn != column);
}
private void editColumnOrPrevPossible(int column) {
- NameInformation[] selected= getSelectedElements();
+ NameInformation[] selected = getSelectedElements();
if (selected.length != 1)
return;
- int prevColumn= column;
+ int prevColumn = column;
do {
fTableViewer.editElement(selected[0], prevColumn);
if (fTableViewer.isCellEditorActive())
- return;
- prevColumn= prevColumn(prevColumn);
+ return;
+ prevColumn = prevColumn(prevColumn);
} while (prevColumn != column);
}
@@ -490,48 +484,48 @@ public class ChangeParametersControl extends Composite {
}
private NameInformation[] getSelectedElements() {
- ISelection selection= fTableViewer.getSelection();
+ ISelection selection = fTableViewer.getSelection();
if (selection == null)
return new NameInformation[0];
if (!(selection instanceof IStructuredSelection))
return new NameInformation[0];
- List<?> selected= ((IStructuredSelection) selection).toList();
+ List<?> selected = ((IStructuredSelection) selection).toList();
return selected.toArray(new NameInformation[selected.size()]);
}
// ---- Button bar --------------------------------------------------------------------------------------
private void createButtonComposite(Composite parent) {
- Composite buttonComposite= new Composite(parent, SWT.NONE);
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- GridLayout gl= new GridLayout();
- gl.marginHeight= 0;
- gl.marginWidth= 0;
+ GridLayout gl = new GridLayout();
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
buttonComposite.setLayout(gl);
if (fMode.canAddParameters())
- fAddButton= createAddButton(buttonComposite);
+ fAddButton = createAddButton(buttonComposite);
- fEditButton= createEditButton(buttonComposite);
+ fEditButton = createEditButton(buttonComposite);
if (fMode.canAddParameters())
- fRemoveButton= createRemoveButton(buttonComposite);
+ fRemoveButton = createRemoveButton(buttonComposite);
if (buttonComposite.getChildren().length != 0)
addSpacer(buttonComposite);
- fUpButton= createButton(buttonComposite, Messages.ChangeParametersControl_buttons_move_up, true);
- fDownButton= createButton(buttonComposite, Messages.ChangeParametersControl_buttons_move_down, false);
+ fUpButton = createButton(buttonComposite, Messages.ChangeParametersControl_buttons_move_up, true);
+ fDownButton = createButton(buttonComposite, Messages.ChangeParametersControl_buttons_move_down, false);
updateButtonsEnabledState();
}
private void addSpacer(Composite parent) {
- Label label= new Label(parent, SWT.NONE);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint= 5;
+ Label label = new Label(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 5;
label.setLayoutData(gd);
}
@@ -559,7 +553,7 @@ public class ChangeParametersControl extends Composite {
}
private Button createEditButton(Composite buttonComposite) {
- Button button= new Button(buttonComposite, SWT.PUSH);
+ Button button = new Button(buttonComposite, SWT.PUSH);
button.setText(Messages.ChangeParametersControl_buttons_edit);
button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
SWTUtil.setButtonDimensionHint(button);
@@ -567,10 +561,10 @@ public class ChangeParametersControl extends Composite {
@Override
public void widgetSelected(SelectionEvent e) {
try {
- NameInformation[] selected= getSelectedElements();
+ NameInformation[] selected = getSelectedElements();
Assert.isTrue(selected.length == 1);
- NameInformation parameterInfo= selected[0];
- ParameterEditDialog dialog= new ParameterEditDialog(getShell(), parameterInfo,
+ NameInformation parameterInfo = selected[0];
+ ParameterEditDialog dialog = new ParameterEditDialog(getShell(), parameterInfo,
fMode.canChangeTypes(), fMode.canChangeDefault(),
fMode.canChangeReturn() && parameterInfo.isOutput());
dialog.open();
@@ -585,22 +579,22 @@ public class ChangeParametersControl extends Composite {
}
private Button createAddButton(Composite buttonComposite) {
- Button button= new Button(buttonComposite, SWT.PUSH);
+ Button button = new Button(buttonComposite, SWT.PUSH);
button.setText(Messages.ChangeParametersControl_buttons_add);
button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
SWTUtil.setButtonDimensionHint(button);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- Set<String> excludedParamNames= new HashSet<String>(fParameters.size());
- for (int i= 0; i < fParameters.size(); i++) {
- NameInformation info= fParameters.get(i);
+ Set<String> excludedParamNames = new HashSet<String>(fParameters.size());
+ for (int i = 0; i < fParameters.size(); i++) {
+ NameInformation info = fParameters.get(i);
excludedParamNames.add(info.getNewName());
}
- String newParamName= StubUtility.suggestParameterName("newParam", excludedParamNames, //$NON-NLS-1$
+ String newParamName = StubUtility.suggestParameterName("newParam", excludedParamNames, //$NON-NLS-1$
fTypeContext != null ? fTypeContext.getTranslationUnit() : null);
- NameInformation newInfo= NameInformation.createInfoForAddedParameter("int", newParamName, "0"); //$NON-NLS-1$ //$NON-NLS-2$
- int insertIndex= fParameters.size();
+ NameInformation newInfo = NameInformation.createInfoForAddedParameter("int", newParamName, "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ int insertIndex = fParameters.size();
fParameters.add(insertIndex, newInfo);
fListener.parameterAdded(newInfo);
fTableViewer.refresh();
@@ -614,16 +608,16 @@ public class ChangeParametersControl extends Composite {
}
private Button createRemoveButton(Composite buttonComposite) {
- final Button button= new Button(buttonComposite, SWT.PUSH);
+ final Button button = new Button(buttonComposite, SWT.PUSH);
button.setText(Messages.ChangeParametersControl_buttons_remove);
button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
SWTUtil.setButtonDimensionHint(button);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- int index= getTable().getSelectionIndices()[0];
- NameInformation[] selected= getSelectedElements();
- for (int i= 0; i < selected.length; i++) {
+ int index = getTable().getSelectionIndices()[0];
+ NameInformation[] selected = getSelectedElements();
+ for (int i = 0; i < selected.length; i++) {
if (selected[i].isAdded()) {
fParameters.remove(selected[i]);
} else {
@@ -636,11 +630,11 @@ public class ChangeParametersControl extends Composite {
private void restoreSelection(int index) {
fTableViewer.refresh();
fTableViewer.getControl().setFocus();
- int itemCount= getTableItemCount();
+ int itemCount = getTableItemCount();
if (itemCount != 0) {
- if (index >= itemCount)
- index= itemCount - 1;
- getTable().setSelection(index);
+ if (index >= itemCount)
+ index = itemCount - 1;
+ getTable().setSelection(index);
}
fListener.parameterListChanged();
updateButtonsEnabledState();
@@ -650,17 +644,17 @@ public class ChangeParametersControl extends Composite {
}
private Button createButton(Composite buttonComposite, String text, final boolean up) {
- Button button= new Button(buttonComposite, SWT.PUSH);
+ Button button = new Button(buttonComposite, SWT.PUSH);
button.setText(text);
button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
SWTUtil.setButtonDimensionHint(button);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- ISelection savedSelection= fTableViewer.getSelection();
+ ISelection savedSelection = fTableViewer.getSelection();
if (savedSelection == null)
return;
- NameInformation[] selection= getSelectedElements();
+ NameInformation[] selection = getSelectedElements();
if (selection.length == 0)
return;
@@ -684,26 +678,26 @@ public class ChangeParametersControl extends Composite {
fTableViewer.setColumnProperties(columnProperties);
ArrayList<CellEditor> editors = new ArrayList<CellEditor>();
- TableTextCellEditor cellEditorType= new TableTextCellEditor(fTableViewer, indexType);
+ TableTextCellEditor cellEditorType = new TableTextCellEditor(fTableViewer, indexType);
editors.add(cellEditorType);
if (indexDirection >= 0) {
- ComboBoxCellEditor cellEditorDirection= new DirectionCellEditor(fTableViewer.getTable());
+ ComboBoxCellEditor cellEditorDirection = new DirectionCellEditor(fTableViewer.getTable());
editors.add(cellEditorDirection);
}
- TableTextCellEditor cellEditorName= new TableTextCellEditor(fTableViewer, indexName);
+ TableTextCellEditor cellEditorName = new TableTextCellEditor(fTableViewer, indexName);
editors.add(cellEditorName);
if (indexDefault >= 0) {
- TableTextCellEditor cellEditorDefault= new TableTextCellEditor(fTableViewer, indexDefault);
+ TableTextCellEditor cellEditorDefault = new TableTextCellEditor(fTableViewer, indexDefault);
editors.add(cellEditorDefault);
}
if (fParamNameProposals.length > 0) {
- SubjectControlContentAssistant assistant= installParameterNameContentAssist(cellEditorName.getText());
+ SubjectControlContentAssistant assistant = installParameterNameContentAssist(cellEditorName.getText());
cellEditorName.setContentAssistant(assistant);
}
for (int i = 0; i < editors.size(); i++) {
- final int editorColumn= i;
+ final int editorColumn = i;
final CellEditor editor = editors.get(i);
// Support tabbing between columns while editing
Control control = editor.getControl();
@@ -713,12 +707,12 @@ public class ChangeParametersControl extends Composite {
switch (e.detail) {
case SWT.TRAVERSE_TAB_NEXT:
editColumnOrNextPossible(nextColumn(editorColumn));
- e.detail= SWT.TRAVERSE_NONE;
+ e.detail = SWT.TRAVERSE_NONE;
break;
case SWT.TRAVERSE_TAB_PREVIOUS:
editColumnOrPrevPossible(prevColumn(editorColumn));
- e.detail= SWT.TRAVERSE_NONE;
+ e.detail = SWT.TRAVERSE_NONE;
break;
}
}
@@ -731,7 +725,7 @@ public class ChangeParametersControl extends Composite {
cellEditorName.setActivationListener(new TableTextCellEditor.IActivationListener() {
@Override
public void activate() {
- NameInformation[] selected= getSelectedElements();
+ NameInformation[] selected = getSelectedElements();
if (selected.length == 1 && fNameContentAssistHandler != null) {
fNameContentAssistHandler.setEnabled(selected[0].isAdded());
}
@@ -755,11 +749,11 @@ public class ChangeParametersControl extends Composite {
}
private static void moveUp(List<NameInformation> elements, List<NameInformation> move) {
- List<NameInformation> res= new ArrayList<NameInformation>(elements.size());
- List<NameInformation> deleted= new ArrayList<NameInformation>();
- NameInformation floating= null;
- for (Iterator<NameInformation> iter= elements.iterator(); iter.hasNext();) {
- NameInformation curr= iter.next();
+ List<NameInformation> res = new ArrayList<NameInformation>(elements.size());
+ List<NameInformation> deleted = new ArrayList<NameInformation>();
+ NameInformation floating = null;
+ for (Iterator<NameInformation> iter = elements.iterator(); iter.hasNext();) {
+ NameInformation curr = iter.next();
if (move.contains(curr)) {
res.add(curr);
} else if (curr.isDeleted()) {
@@ -767,7 +761,7 @@ public class ChangeParametersControl extends Composite {
} else {
if (floating != null)
res.add(floating);
- floating= curr;
+ floating = curr;
}
}
if (floating != null) {
@@ -775,20 +769,20 @@ public class ChangeParametersControl extends Composite {
}
res.addAll(deleted);
elements.clear();
- for (Iterator<NameInformation> iter= res.iterator(); iter.hasNext();) {
+ for (Iterator<NameInformation> iter = res.iterator(); iter.hasNext();) {
elements.add(iter.next());
}
}
private boolean canMove(boolean up) {
- int notDeletedInfosCount= getNotDeletedInfosCount();
+ int notDeletedInfosCount = getNotDeletedInfosCount();
if (notDeletedInfosCount == 0)
return false;
- int[] indc= getTable().getSelectionIndices();
+ int[] indc = getTable().getSelectionIndices();
if (indc.length == 0)
return false;
- int invalid= up ? 0 : notDeletedInfosCount - 1;
- for (int i= 0; i < indc.length; i++) {
+ int invalid = up ? 0 : notDeletedInfosCount - 1;
+ for (int i = 0; i < indc.length; i++) {
if (indc[i] == invalid)
return false;
}
@@ -798,9 +792,9 @@ public class ChangeParametersControl extends Composite {
private int getNotDeletedInfosCount() {
if (fParameters == null) // during initialization
return 0;
- int result= 0;
- for (Iterator<NameInformation> iter= fParameters.iterator(); iter.hasNext();) {
- NameInformation info= iter.next();
+ int result = 0;
+ for (Iterator<NameInformation> iter = fParameters.iterator(); iter.hasNext();) {
+ NameInformation info = iter.next();
if (!info.isDeleted())
result++;
}
@@ -809,10 +803,10 @@ public class ChangeParametersControl extends Composite {
private SubjectControlContentAssistant installParameterNameContentAssist(Text text) {
return null;
- // TODO(sprigogin): Implement to support parameter name content assist.
-// VariableNamesProcessor processor= new VariableNamesProcessor(fParamNameProposals);
-// SubjectControlContentAssistant contentAssistant= ControlContentAssistHelper.createCContentAssistant(processor);
-// fNameContentAssistHandler= ContentAssistHandler.createHandlerForText(text, contentAssistant);
-// return contentAssistant;
+ // TODO(sprigogin): Implement to support parameter name content assist.
+ // VariableNamesProcessor processor= new VariableNamesProcessor(fParamNameProposals);
+ // SubjectControlContentAssistant contentAssistant= ControlContentAssistHelper.createCContentAssistant(processor);
+ // fNameContentAssistHandler= ContentAssistHandler.createHandlerForText(text, contentAssistant);
+ // return contentAssistant;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java
index 78d0dfaa7ea..50d8bc9a875 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring;
@@ -26,7 +26,7 @@ import org.eclipse.cdt.ui.refactoring.CTextFileChange;
* @author Emanuel Graf
*/
public class ChangeTreeSet {
-
+
private static final class ChangePositionComparator implements Comparator<CTextFileChange> {
@Override
public int compare(CTextFileChange o1, CTextFileChange o2) {
@@ -36,16 +36,16 @@ public class ChangeTreeSet {
return o2.getFile().hashCode() - o1.getFile().hashCode();
}
}
-
+
private final TreeSet<CTextFileChange> changes = new TreeSet<CTextFileChange>(new ChangePositionComparator());
-
+
public void add(CTextFileChange change) {
changes.add(change);
}
-
+
public CompositeChange getCompositeChange(String name) {
CompositeChange allChanges = new CompositeChange(name);
-
+
for (Change change : changes) {
allChanges.add(change);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ClassMemberInserter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ClassMemberInserter.java
index 7ad0d1d85ec..e4598bccafb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ClassMemberInserter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ClassMemberInserter.java
@@ -103,11 +103,10 @@ public class ClassMemberInserter {
* @param collector the modification collector recording the insertion
* @return the rewriter for making further modifications to the inserted node
*/
- public static ASTRewrite createChange(ICPPASTCompositeTypeSpecifier classNode,
- VisibilityEnum visibility, IASTNode nodeToAdd, boolean isField,
- ModificationCollector collector) {
- List<ASTRewrite> addedNodesRewrites =
- createChange(classNode, visibility, Collections.singletonList(nodeToAdd), isField, collector);
+ public static ASTRewrite createChange(ICPPASTCompositeTypeSpecifier classNode, VisibilityEnum visibility,
+ IASTNode nodeToAdd, boolean isField, ModificationCollector collector) {
+ List<ASTRewrite> addedNodesRewrites = createChange(classNode, visibility, Collections.singletonList(nodeToAdd),
+ isField, collector);
return addedNodesRewrites.get(0);
}
@@ -121,9 +120,8 @@ public class ClassMemberInserter {
* @param collector the modification collector recording the insertion
* @return the rewriters for making further modifications to the inserted nodes
*/
- public static List<ASTRewrite> createChange(ICPPASTCompositeTypeSpecifier classNode,
- VisibilityEnum visibility, List<IASTNode> nodesToAdd, boolean isField,
- ModificationCollector collector) {
+ public static List<ASTRewrite> createChange(ICPPASTCompositeTypeSpecifier classNode, VisibilityEnum visibility,
+ List<IASTNode> nodesToAdd, boolean isField, ModificationCollector collector) {
InsertionInfo info = findInsertionPoint(classNode, visibility, isField);
ASTRewrite rewrite = collector.rewriterForTranslationUnit(classNode.getTranslationUnit());
@@ -146,11 +144,12 @@ public class ClassMemberInserter {
return addedNodeRewrites;
}
- public static InsertionInfo findInsertionPoint(ICPPASTCompositeTypeSpecifier classNode,
- VisibilityEnum visibility, boolean isField) {
+ public static InsertionInfo findInsertionPoint(ICPPASTCompositeTypeSpecifier classNode, VisibilityEnum visibility,
+ boolean isField) {
InsertionInfo info = new InsertionInfo(classNode);
- VisibilityEnum defaultVisibility = classNode.getKey() == IASTCompositeTypeSpecifier.k_struct ?
- VisibilityEnum.v_public : VisibilityEnum.v_private;
+ VisibilityEnum defaultVisibility = classNode.getKey() == IASTCompositeTypeSpecifier.k_struct
+ ? VisibilityEnum.v_public
+ : VisibilityEnum.v_private;
VisibilityEnum currentVisibility = defaultVisibility;
boolean ascendingVisibilityOrder = isAscendingVisibilityOrder(classNode);
@@ -188,8 +187,8 @@ public class ClassMemberInserter {
}
}
- int index = isField && lastFieldIndex >= 0 || !isField && lastFunctionIndex < 0 ?
- lastFieldIndex : lastFunctionIndex;
+ int index = isField && lastFieldIndex >= 0 || !isField && lastFunctionIndex < 0 ? lastFieldIndex
+ : lastFunctionIndex;
if (index < 0)
index = lastMatchingVisibilityIndex;
if (index < 0)
@@ -198,12 +197,11 @@ public class ClassMemberInserter {
if (index < members.length)
info.insertBeforeNode = members[index];
- if (lastMatchingVisibilityIndex < 0 &&
- !(index == 0 && classNode.getKey() == IASTCompositeTypeSpecifier.k_struct &&
- visibility == defaultVisibility)) {
+ if (lastMatchingVisibilityIndex < 0 && !(index == 0 && classNode.getKey() == IASTCompositeTypeSpecifier.k_struct
+ && visibility == defaultVisibility)) {
info.prologue = new CPPASTVisibilityLabel(visibility.getVisibilityLabelValue());
- if (index == 0 && info.insertBeforeNode != null &&
- !(info.insertBeforeNode instanceof ICPPASTVisibilityLabel)) {
+ if (index == 0 && info.insertBeforeNode != null
+ && !(info.insertBeforeNode instanceof ICPPASTVisibilityLabel)) {
info.epilogue = new CPPASTVisibilityLabel(defaultVisibility.getVisibilityLabelValue());
}
}
@@ -211,8 +209,8 @@ public class ClassMemberInserter {
}
private static TextEditGroup createEditDescription(ICPPASTCompositeTypeSpecifier classNode) {
- return new TextEditGroup(NLS.bind(Messages.AddDeclarationNodeToClassChange_AddDeclaration,
- classNode.getName()));
+ return new TextEditGroup(
+ NLS.bind(Messages.AddDeclarationNodeToClassChange_AddDeclaration, classNode.getName()));
}
private static boolean isAscendingVisibilityOrder(ICPPASTCompositeTypeSpecifier classNode) {
@@ -220,8 +218,7 @@ public class ClassMemberInserter {
IASTTranslationUnit ast = classNode.getTranslationUnit();
ITranslationUnit tu = ast.getOriginatingTranslationUnit();
IProject project = tu != null ? tu.getCProject().getProject() : null;
- return preferences.getBoolean(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER, false,
- PreferenceConstants.getPreferenceScopes(project));
+ return preferences.getBoolean(CUIPlugin.PLUGIN_ID, PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER,
+ false, PreferenceConstants.getPreferenceScopes(project));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Container.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Container.java
index 4f1fd03856a..ab562672db1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Container.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Container.java
@@ -1,29 +1,29 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring;
/**
* Simple container for one Object, with getters and setters.
- *
+ *
* @author Mirko Stocker
*
* @param <T> The type of the encapsulated node.
*/
public class Container<T> {
private T object;
-
+
public Container(T object) {
this.object = object;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java
index 6acb2b41d01..9043ae728c4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
@@ -54,10 +54,10 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory;
/**
* Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
- * same algorithm as the text widget to determine the buffer's line delimiter.
+ * same algorithm as the text widget to determine the buffer's line delimiter.
* All text inserted into the buffer is converted to this line delimiter.
* This class is <code>public</code> for test purposes only.
- *
+ *
* This class is similar to the JDT DocumentAdapter class.
*/
public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
@@ -66,14 +66,14 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
*/
protected class DocumentSetCommand implements Runnable {
private String fContents;
-
+
@Override
public void run() {
fDocument.set(fContents);
}
-
+
public void set(String contents) {
- fContents= contents;
+ fContents = contents;
Display.getDefault().syncExec(this);
}
}
@@ -85,7 +85,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
private int fOffset;
private int fLength;
private String fText;
-
+
@Override
public void run() {
try {
@@ -94,76 +94,125 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
// ignore
}
}
-
+
public void replace(int offset, int length, String text) {
- fOffset= offset;
- fLength= length;
- fText= text;
+ fOffset = offset;
+ fLength = length;
+ fText = text;
Display.getDefault().syncExec(this);
}
}
- private static final boolean DEBUG_LINE_DELIMITERS= true;
+ private static final boolean DEBUG_LINE_DELIMITERS = true;
public static final IBuffer NULL_BUFFER = new IBuffer() {
@Override
- public void addBufferChangedListener(IBufferChangedListener listener) {}
+ public void addBufferChangedListener(IBufferChangedListener listener) {
+ }
+
@Override
- public void append(char[] text) {}
+ public void append(char[] text) {
+ }
+
@Override
- public void append(String text) {}
+ public void append(String text) {
+ }
+
@Override
- public void close() {}
+ public void close() {
+ }
+
@Override
- public char getChar(int position) { return 0; }
+ public char getChar(int position) {
+ return 0;
+ }
+
@Override
- public char[] getCharacters() { return new char[0]; }
+ public char[] getCharacters() {
+ return new char[0];
+ }
+
@Override
- public String getContents() { return ""; } //$NON-NLS-1$
+ public String getContents() {
+ return ""; //$NON-NLS-1$
+ }
+
@Override
- public int getLength() { return 0; }
+ public int getLength() {
+ return 0;
+ }
+
@Override
- public IOpenable getOwner() {return null;}
+ public IOpenable getOwner() {
+ return null;
+ }
+
@Override
- public String getText(int offset, int length) { return ""; } //$NON-NLS-1$
+ public String getText(int offset, int length) {
+ return ""; //$NON-NLS-1$
+ }
+
@Override
- public IResource getUnderlyingResource() { return null; }
+ public IResource getUnderlyingResource() {
+ return null;
+ }
+
@Override
- public boolean hasUnsavedChanges() { return false; }
+ public boolean hasUnsavedChanges() {
+ return false;
+ }
+
@Override
- public boolean isClosed() { return false; }
+ public boolean isClosed() {
+ return false;
+ }
+
@Override
- public boolean isReadOnly() { return true; }
+ public boolean isReadOnly() {
+ return true;
+ }
+
@Override
- public void removeBufferChangedListener(IBufferChangedListener listener) {}
+ public void removeBufferChangedListener(IBufferChangedListener listener) {
+ }
+
@Override
- public void replace(int position, int length, char[] text) {}
+ public void replace(int position, int length, char[] text) {
+ }
+
@Override
- public void replace(int position, int length, String text) {}
+ public void replace(int position, int length, String text) {
+ }
+
@Override
- public void save(IProgressMonitor progress, boolean force) throws CModelException {}
+ public void save(IProgressMonitor progress, boolean force) throws CModelException {
+ }
+
@Override
- public void setContents(char[] contents) {}
+ public void setContents(char[] contents) {
+ }
+
@Override
- public void setContents(String contents) {}
+ public void setContents(String contents) {
+ }
};
- public static IBufferFactory FACTORY= new IBufferFactory() {
- @Override
+ public static IBufferFactory FACTORY = new IBufferFactory() {
+ @Override
public IBuffer createBuffer(IOpenable owner) {
- if (owner instanceof IWorkingCopy) {
- IWorkingCopy wc= (IWorkingCopy) owner;
- ITranslationUnit tu= wc.getOriginalElement();
- if (tu != null) {
- IResource r= tu.getResource();
- if (r instanceof IFile) {
- return new DocumentAdapter(wc, (IFile) r);
- }
- }
- }
- assert false;
- return DocumentAdapter.NULL_BUFFER;
- }
- };
+ if (owner instanceof IWorkingCopy) {
+ IWorkingCopy wc = (IWorkingCopy) owner;
+ ITranslationUnit tu = wc.getOriginalElement();
+ if (tu != null) {
+ IResource r = tu.getResource();
+ if (r instanceof IFile) {
+ return new DocumentAdapter(wc, (IFile) r);
+ }
+ }
+ }
+ assert false;
+ return DocumentAdapter.NULL_BUFFER;
+ }
+ };
private ITranslationUnit fTranslationUnit;
private IWorkingCopy fOwner;
@@ -171,35 +220,34 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
private ITextFileBuffer fTextFileBuffer;
IDocument fDocument;
- private DocumentSetCommand fSetCmd= new DocumentSetCommand();
- private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
+ private DocumentSetCommand fSetCmd = new DocumentSetCommand();
+ private DocumentReplaceCommand fReplaceCmd = new DocumentReplaceCommand();
private Set<String> fLegalLineDelimiters;
- private List<IBufferChangedListener> fBufferListeners= new ArrayList<IBufferChangedListener>(3);
+ private List<IBufferChangedListener> fBufferListeners = new ArrayList<IBufferChangedListener>(3);
private IStatus fStatus;
-
public DocumentAdapter(IWorkingCopy owner, IFile file) {
- fOwner= owner;
- fFile= file;
- fTranslationUnit= owner.getOriginalElement();
+ fOwner = owner;
+ fFile = file;
+ fTranslationUnit = owner.getOriginalElement();
if (fTranslationUnit != null) {
addBufferChangedListener(fTranslationUnit);
}
- initialize();
+ initialize();
}
private void initialize() {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- IPath location= fFile.getFullPath();
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
+ IPath location = fFile.getFullPath();
try {
manager.connect(location, LocationKind.IFILE, new NullProgressMonitor());
- fTextFileBuffer= manager.getTextFileBuffer(location, LocationKind.IFILE);
- fDocument= fTextFileBuffer.getDocument();
+ fTextFileBuffer = manager.getTextFileBuffer(location, LocationKind.IFILE);
+ fDocument = fTextFileBuffer.getDocument();
} catch (CoreException x) {
- fStatus= x.getStatus();
- fDocument= manager.createEmptyDocument(location, LocationKind.IFILE);
+ fStatus = x.getStatus();
+ fDocument = manager.createEmptyDocument(location, LocationKind.IFILE);
}
fDocument.addPrenotifiedDocumentListener(this);
}
@@ -214,10 +262,10 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
return fTextFileBuffer.getStatus();
return null;
}
-
+
/**
* Returns the adapted document.
- *
+ *
* @return the adapted document
*/
public IDocument getDocument() {
@@ -233,7 +281,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
if (!fBufferListeners.contains(listener))
fBufferListeners.add(listener);
}
-
+
/*
* @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
*/
@@ -242,14 +290,13 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
Assert.isNotNull(listener);
fBufferListeners.remove(listener);
}
-
/**
* @see org.eclipse.cdt.core.model.IBuffer#append(char[])
*/
@Override
public void append(char[] text) {
- append(new String(text));
+ append(new String(text));
}
/**
@@ -260,10 +307,9 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
if (DEBUG_LINE_DELIMITERS) {
validateLineDelimiters(text);
}
- fReplaceCmd.replace(fDocument.getLength(), 0, text);
+ fReplaceCmd.replace(fDocument.getLength(), 0, text);
}
-
/**
* @see org.eclipse.cdt.core.model.IBuffer#close()
*/
@@ -271,21 +317,21 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
public void close() {
if (isClosed())
return;
-
- IDocument d= fDocument;
- fDocument= null;
+
+ IDocument d = fDocument;
+ fDocument = null;
d.removePrenotifiedDocumentListener(this);
-
+
if (fTextFileBuffer != null) {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
try {
manager.disconnect(fTextFileBuffer.getLocation(), LocationKind.IFILE, new NullProgressMonitor());
} catch (CoreException x) {
// ignore
}
- fTextFileBuffer= null;
+ fTextFileBuffer = null;
}
-
+
fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
fBufferListeners.clear();
}
@@ -307,7 +353,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
*/
@Override
public char[] getCharacters() {
- String content= getContents();
+ String content = getContents();
return content == null ? null : content.toCharArray();
}
@@ -376,14 +422,14 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
*/
@Override
public boolean isReadOnly() {
- IResource resource= getUnderlyingResource();
+ IResource resource = getUnderlyingResource();
if (resource != null) {
ResourceAttributes attributes = resource.getResourceAttributes();
if (attributes != null) {
return attributes.isReadOnly();
}
}
- return false;
+ return false;
}
/**
@@ -391,7 +437,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
*/
@Override
public void replace(int position, int length, char[] text) {
- replace(position, length, new String(text));
+ replace(position, length, new String(text));
}
/**
@@ -423,7 +469,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
*/
@Override
public void setContents(char[] contents) {
- setContents(new String(contents));
+ setContents(new String(contents));
}
/**
@@ -431,8 +477,8 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
*/
@Override
public void setContents(String contents) {
- int oldLength= fDocument.getLength();
-
+ int oldLength = fDocument.getLength();
+
if (contents == null) {
if (oldLength != 0)
fSetCmd.set(""); //$NON-NLS-1$
@@ -441,8 +487,8 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
if (DEBUG_LINE_DELIMITERS) {
validateLineDelimiters(contents);
}
-
- int newLength= contents.length();
+
+ int newLength = contents.length();
if (oldLength != newLength || !contents.equals(fDocument.get()))
fSetCmd.set(contents);
}
@@ -451,11 +497,11 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
private void validateLineDelimiters(String contents) {
if (fLegalLineDelimiters == null) {
// collect all line delimiters in the document
- HashSet<String> existingDelimiters= new HashSet<String>();
+ HashSet<String> existingDelimiters = new HashSet<String>();
- for (int i= fDocument.getNumberOfLines() - 1; i >= 0; i-- ) {
+ for (int i = fDocument.getNumberOfLines() - 1; i >= 0; i--) {
try {
- String curr= fDocument.getLineDelimiter(i);
+ String curr = fDocument.getLineDelimiter(i);
if (curr != null) {
existingDelimiters.add(curr);
}
@@ -466,29 +512,29 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
if (existingDelimiters.isEmpty()) {
return; // first insertion of a line delimiter: no test
}
- fLegalLineDelimiters= existingDelimiters;
-
+ fLegalLineDelimiters = existingDelimiters;
+
}
-
- DefaultLineTracker tracker= new DefaultLineTracker();
+
+ DefaultLineTracker tracker = new DefaultLineTracker();
tracker.set(contents);
-
- int lines= tracker.getNumberOfLines();
+
+ int lines = tracker.getNumberOfLines();
if (lines <= 1)
return;
-
- for (int i= 0; i < lines; i++) {
+
+ for (int i = 0; i < lines; i++) {
try {
- String curr= tracker.getLineDelimiter(i);
+ String curr = tracker.getLineDelimiter(i);
if (curr != null && !fLegalLineDelimiters.contains(curr)) {
- StringBuilder buf= new StringBuilder("New line delimiter added to new code: "); //$NON-NLS-1$
- for (int k= 0; k < curr.length(); k++) {
+ StringBuilder buf = new StringBuilder("New line delimiter added to new code: "); //$NON-NLS-1$
+ for (int k = 0; k < curr.length(); k++) {
buf.append(String.valueOf((int) curr.charAt(k)));
}
CUIPlugin.log(new Exception(buf.toString()));
}
} catch (BadLocationException e) {
- CUIPlugin.log(e);
+ CUIPlugin.log(e);
}
}
}
@@ -508,10 +554,10 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
public void documentChanged(DocumentEvent event) {
fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText()));
}
-
+
private void fireBufferChanged(BufferChangedEvent event) {
if (fBufferListeners != null && fBufferListeners.size() > 0) {
- Iterator<IBufferChangedListener> e= new ArrayList<IBufferChangedListener>(fBufferListeners).iterator();
+ Iterator<IBufferChangedListener> e = new ArrayList<IBufferChangedListener>(fBufferListeners).iterator();
while (e.hasNext())
e.next().bufferChanged(event);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java
index 48d6788f7eb..14e967c2d51 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java
@@ -1,14 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
+ * SPDX-License-Identifier: EPL-2.0
+ *
* Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
@@ -37,8 +37,7 @@ public class IndexToASTNameHelper {
return visitor.getMatches();
}
- public static IASTName findMatchingASTName(IASTTranslationUnit tu, IName name, IIndex index)
- throws CoreException {
+ public static IASTName findMatchingASTName(IASTTranslationUnit tu, IName name, IIndex index) throws CoreException {
if (name instanceof IASTName) {
return (IASTName) name;
} else if (!(name instanceof IIndexName)) {
@@ -97,7 +96,8 @@ public class IndexToASTNameHelper {
}
private boolean isEquivalent(IASTName candidate) {
- return CharArrayUtils.equals(candidate.getSimpleID(), toFindName) && bindingToFind.equals(index.adaptBinding(candidate.resolveBinding()));
+ return CharArrayUtils.equals(candidate.getSimpleID(), toFindName)
+ && bindingToFind.equals(index.adaptBinding(candidate.resolveBinding()));
}
public List<IASTName> getMatches() {
@@ -141,10 +141,10 @@ public class IndexToASTNameHelper {
private boolean matchesIndexName(IASTName candidate) {
IASTFileLocation candidateLocation = candidate.getFileLocation();
- return locationToFind.getNodeOffset() == candidateLocation.getNodeOffset() &&
- locationToFind.getNodeLength() == candidateLocation.getNodeLength() &&
- locationToFind.getFileName().equals(candidateLocation.getFileName()) &&
- CharArrayUtils.equals(candidate.getSimpleID(), charNameToFind);
+ return locationToFind.getNodeOffset() == candidateLocation.getNodeOffset()
+ && locationToFind.getNodeLength() == candidateLocation.getNodeLength()
+ && locationToFind.getFileName().equals(candidateLocation.getFileName())
+ && CharArrayUtils.equals(candidate.getSimpleID(), charNameToFind);
}
public IASTName getMatch() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java
index c5c29e01c0c..706d70c8909 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2015 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java
index 211c6700846..58ab243e65b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java
@@ -35,7 +35,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
* if two methods are in the same class.
*/
public class MethodContext {
- public enum ContextType { NONE, FUNCTION, METHOD }
+ public enum ContextType {
+ NONE, FUNCTION, METHOD
+ }
private ContextType type;
private IASTName declarationName;
@@ -88,10 +90,10 @@ public class MethodContext {
public static boolean isSameOrSubClass(MethodContext context1, MethodContext contextOfSameOrSubclass) {
ICPPInternalBinding bind1 = getICPPInternalBinding(context1);
ICPPInternalBinding subclassBind = getICPPInternalBinding(contextOfSameOrSubclass);
- if (isSameClass(bind1,subclassBind)) {
+ if (isSameClass(bind1, subclassBind)) {
return true;
}
- return isSubclass(bind1,subclassBind);
+ return isSubclass(bind1, subclassBind);
}
private static boolean isSubclass(ICPPInternalBinding bind1, ICPPInternalBinding subclassBind) {
@@ -100,7 +102,7 @@ public class MethodContext {
ICPPBase[] bases;
bases = classType.getBases();
for (ICPPBase base : bases) {
- if (isSameClass(base,bind1)) {
+ if (isSameClass(base, bind1)) {
return true;
}
}
@@ -111,7 +113,7 @@ public class MethodContext {
public static boolean isSameClass(MethodContext context1, MethodContext context2) {
ICPPInternalBinding bind1 = getICPPInternalBinding(context1);
ICPPInternalBinding bind2 = getICPPInternalBinding(context2);
- return isSameClass(bind1,bind2);
+ return isSameClass(bind1, bind2);
}
private static boolean isSameClass(ICPPBase base, ICPPInternalBinding bind2) {
@@ -198,8 +200,8 @@ public class MethodContext {
private static ICPPClassType getClassBinding(IASTName declName1) {
if (declName1.getParent().getParent().getParent() instanceof ICPPASTCompositeTypeSpecifier) {
- ICPPASTCompositeTypeSpecifier compTypeSpec =
- (ICPPASTCompositeTypeSpecifier) declName1.getParent().getParent().getParent();
+ ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) declName1.getParent()
+ .getParent().getParent();
return (ICPPClassType) compTypeSpec.getName().resolveBinding();
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java
index bc1ae92766a..372e1dedf5a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -45,10 +45,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor;
/**
- * Additional information about an IASTName in code being refactored.
+ * Additional information about an IASTName in code being refactored.
*/
public class NameInformation {
- public static enum Indirection { NONE, POINTER, REFERENCE }
+ public static enum Indirection {
+ NONE, POINTER, REFERENCE
+ }
public static final int INDEX_FOR_ADDED = -1;
@@ -73,9 +75,8 @@ public class NameInformation {
referencesInSelection = new ArrayList<>();
}
- public static NameInformation createInfoForAddedParameter(String type, String name,
- String defaultValue) {
- NameInformation info= new NameInformation(null);
+ public static NameInformation createInfoForAddedParameter(String type, String name, String defaultValue) {
+ NameInformation info = new NameInformation(null);
info.setTypeName(type);
info.setNewName(name);
info.setDefaultValue(defaultValue);
@@ -157,7 +158,7 @@ public class NameInformation {
public void markAsDeleted() {
Assert.isTrue(!isAdded()); // Added parameters should be simply removed from the list
- isDeleted= true;
+ isDeleted = true;
}
public boolean isAdded() {
@@ -171,7 +172,7 @@ public class NameInformation {
public void setDefaultValue(String value) {
Assert.isNotNull(value);
- defaultValue= value;
+ defaultValue = value;
}
public IASTName getDeclarationName() {
@@ -193,8 +194,8 @@ public class NameInformation {
}
void setDeclarationName(IASTName declarationName) {
- Assert.isTrue(declarationName.getPropertyInParent() == IASTDeclarator.DECLARATOR_NAME ||
- declarationName.getPropertyInParent() == IASTLabelStatement.NAME);
+ Assert.isTrue(declarationName.getPropertyInParent() == IASTDeclarator.DECLARATOR_NAME
+ || declarationName.getPropertyInParent() == IASTLabelStatement.NAME);
this.declarationName = declarationName;
indirection = null;
}
@@ -204,7 +205,7 @@ public class NameInformation {
}
public boolean isRenamed() {
- return name == null ? newName != null : !String.valueOf(name.getSimpleID()).equals(newName);
+ return name == null ? newName != null : !String.valueOf(name.getSimpleID()).equals(newName);
}
void addReference(IASTName name, int startOffset, int endOffset) {
@@ -229,7 +230,7 @@ public class NameInformation {
public void setTypeName(String type) {
Assert.isNotNull(type);
- newTypeName= type;
+ newTypeName = type;
}
public String getReturnType() {
@@ -259,13 +260,12 @@ public class NameInformation {
IASTDeclarator sourceDeclarator = getDeclarator();
IASTDeclSpecifier declSpec;
IASTDeclarator declarator;
- if (sourceDeclSpec instanceof IASTSimpleDeclSpecifier &&
- ((IASTSimpleDeclSpecifier) sourceDeclSpec).getType() == IASTSimpleDeclSpecifier.t_auto) {
+ if (sourceDeclSpec instanceof IASTSimpleDeclSpecifier
+ && ((IASTSimpleDeclSpecifier) sourceDeclSpec).getType() == IASTSimpleDeclSpecifier.t_auto) {
IType type = CPPVisitor.createType(sourceDeclarator);
DeclarationGenerator generator = DeclarationGenerator.create(nodeFactory);
declSpec = generator.createDeclSpecFromType(type);
- declarator = generator.createDeclaratorFromType(type,
- paramName == null ? null : paramName.toCharArray());
+ declarator = generator.createDeclaratorFromType(type, paramName == null ? null : paramName.toCharArray());
} else {
declSpec = safeCopy(sourceDeclSpec);
declarator = createDeclarator(nodeFactory, sourceDeclarator, paramName);
@@ -313,10 +313,8 @@ public class NameInformation {
return indirection;
}
- private IASTDeclarator createDeclarator(INodeFactory nodeFactory, IASTDeclarator sourceDeclarator,
- String name) {
- IASTName astName = name != null ?
- nodeFactory.newName(name.toCharArray()) : nodeFactory.newName();
+ private IASTDeclarator createDeclarator(INodeFactory nodeFactory, IASTDeclarator sourceDeclarator, String name) {
+ IASTName astName = name != null ? nodeFactory.newName(name.toCharArray()) : nodeFactory.newName();
IASTDeclarator declarator;
if (sourceDeclarator instanceof IASTArrayDeclarator) {
IASTArrayDeclarator arrDeclarator = (IASTArrayDeclarator) sourceDeclarator;
@@ -325,7 +323,7 @@ public class NameInformation {
for (IASTArrayModifier arrayModifier : arrayModifiers) {
arrayDeclarator.addArrayModifier(arrayModifier.copy(CopyStyle.withLocations));
}
- declarator= arrayDeclarator;
+ declarator = arrayDeclarator;
} else {
declarator = nodeFactory.newDeclarator(astName);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java
index 8713d50636d..e3a3fba74bb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java
@@ -117,8 +117,7 @@ public class NodeContainer {
names.add(nameInfo);
}
} catch (DOMException e) {
- IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
- e.getMessage(), e);
+ IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, e.getMessage(), e);
CUIPlugin.log(status);
}
} else if (binding instanceof IVariable) {
@@ -189,8 +188,8 @@ public class NodeContainer {
}
}
}
- if (nameInfo.isWriteAccess() &&
- externalReads.contains(nameInfo.getName().resolveBinding())) {
+ if (nameInfo.isWriteAccess()
+ && externalReads.contains(nameInfo.getName().resolveBinding())) {
nameInfo.setOutput(true);
}
}
@@ -208,17 +207,17 @@ public class NodeContainer {
return Collections.emptySet();
IASTNode firstNode = nodes.get(0);
- IASTFunctionDefinition enclosingFunction =
- ASTQueries.findAncestorWithType(firstNode, IASTFunctionDefinition.class);
- FlowContext flowContext= new FlowContext(enclosingFunction);
+ IASTFunctionDefinition enclosingFunction = ASTQueries.findAncestorWithType(firstNode,
+ IASTFunctionDefinition.class);
+ FlowContext flowContext = new FlowContext(enclosingFunction);
flowContext.setConsiderAccessMode(true);
flowContext.setComputeMode(FlowContext.ARGUMENTS);
// Compute a selection that exactly covers the selected nodes
- Selection selection= Selection.createFromStartEnd(ASTNodes.offset(firstNode),
+ Selection selection = Selection.createFromStartEnd(ASTNodes.offset(firstNode),
ASTNodes.endOffset(nodes.get(nodes.size() - 1)));
InputFlowAnalyzer analyzer = new InputFlowAnalyzer(flowContext, selection, true);
- FlowInfo argInfo= analyzer.perform(enclosingFunction);
+ FlowInfo argInfo = analyzer.perform(enclosingFunction);
Set<IVariable> variables = argInfo.get(flowContext, FlowInfo.READ | FlowInfo.READ_POTENTIAL | FlowInfo.UNKNOWN);
// Remove variables with scopes limited to the selection.
@@ -308,7 +307,7 @@ public class NodeContainer {
} else {
nodeOffset = node.getFileLocation().getNodeOffset();
}
- if (nodeOffset < nodeStart) {
+ if (nodeOffset < nodeStart) {
nodeStart = nodeOffset;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ParameterEditDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ParameterEditDialog.java
index aef53599a95..3c36bdc471c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ParameterEditDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ParameterEditDialog.java
@@ -10,7 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring;
@@ -57,9 +57,9 @@ public class ParameterEditDialog extends StatusDialog {
public ParameterEditDialog(Shell parentShell, NameInformation parameter, boolean canEditType,
boolean canEditDefault, boolean canChangeReturn) {
super(parentShell);
- fParameter= parameter;
- fEditType= canEditType;
- fEditDefault= canEditDefault;
+ fParameter = parameter;
+ fEditType = canEditType;
+ fEditDefault = canEditDefault;
fEditReturn = canChangeReturn;
}
@@ -71,72 +71,68 @@ public class ParameterEditDialog extends StatusDialog {
@Override
protected Control createDialogArea(Composite parent) {
- Composite result= (Composite) super.createDialogArea(parent);
- GridLayout layout= (GridLayout) result.getLayout();
- layout.numColumns= 2;
+ Composite result = (Composite) super.createDialogArea(parent);
+ GridLayout layout = (GridLayout) result.getLayout();
+ layout.numColumns = 2;
Label label;
GridData gd;
- label= new Label(result, SWT.NONE);
+ label = new Label(result, SWT.NONE);
String newName = fParameter.getNewName();
if (newName.isEmpty()) {
label.setText(Messages.ParameterEditDialog_message_new);
} else {
- label.setText(NLS.bind(Messages.ParameterEditDialog_message,
- BasicElementLabels.getCElementName(newName)));
+ label.setText(NLS.bind(Messages.ParameterEditDialog_message, BasicElementLabels.getCElementName(newName)));
}
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
label.setLayoutData(gd);
if (fEditType) {
- label= new Label(result, SWT.NONE);
+ label = new Label(result, SWT.NONE);
label.setText(Messages.ParameterEditDialog_type);
- fType= new Text(result, SWT.BORDER);
- gd= new GridData(GridData.FILL_HORIZONTAL);
+ fType = new Text(result, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
fType.setLayoutData(gd);
fType.setText(fParameter.getTypeName());
- fType.addModifyListener(
- new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- validate((Text) e.widget);
- }
- });
+ fType.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate((Text) e.widget);
+ }
+ });
TextFieldNavigationHandler.install(fType);
}
- label= new Label(result, SWT.NONE);
- fName= new Text(result, SWT.BORDER);
+ label = new Label(result, SWT.NONE);
+ fName = new Text(result, SWT.BORDER);
initializeDialogUnits(fName);
label.setText(Messages.ParameterEditDialog_name);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(45);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = convertWidthInCharsToPixels(45);
fName.setLayoutData(gd);
fName.setText(newName);
- fName.addModifyListener(
- new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- validate((Text) e.widget);
- }
- });
+ fName.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate((Text) e.widget);
+ }
+ });
TextFieldNavigationHandler.install(fName);
if (fEditDefault && fParameter.isAdded()) {
- label= new Label(result, SWT.NONE);
+ label = new Label(result, SWT.NONE);
label.setText(Messages.ParameterEditDialog_default_value);
- fDefaultValue= new Text(result, SWT.BORDER);
- gd= new GridData(GridData.FILL_HORIZONTAL);
+ fDefaultValue = new Text(result, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
fDefaultValue.setLayoutData(gd);
fDefaultValue.setText(fParameter.getDefaultValue());
- fDefaultValue.addModifyListener(
- new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- validate((Text) e.widget);
- }
- });
+ fDefaultValue.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate((Text) e.widget);
+ }
+ });
TextFieldNavigationHandler.install(fDefaultValue);
}
if (fEditReturn) {
@@ -165,22 +161,22 @@ public class ParameterEditDialog extends StatusDialog {
}
private void validate(Text first) {
- IStatus[] result= new IStatus[3];
+ IStatus[] result = new IStatus[3];
if (first == fType) {
- result[0]= validateType();
- result[1]= validateName();
- result[2]= validateDefaultValue();
+ result[0] = validateType();
+ result[1] = validateName();
+ result[2] = validateDefaultValue();
} else if (first == fName) {
- result[0]= validateName();
- result[1]= validateType();
- result[2]= validateDefaultValue();
+ result[0] = validateName();
+ result[1] = validateType();
+ result[2] = validateDefaultValue();
} else {
- result[0]= validateDefaultValue();
- result[1]= validateName();
- result[2]= validateType();
+ result[0] = validateDefaultValue();
+ result[1] = validateName();
+ result[2] = validateType();
}
- for (int i= 0; i < result.length; i++) {
- IStatus status= result[i];
+ for (int i = 0; i < result.length; i++) {
+ IStatus status = result[i];
if (status != null && !status.isOK()) {
updateStatus(status);
return;
@@ -197,10 +193,10 @@ public class ParameterEditDialog extends StatusDialog {
private IStatus validateName() {
if (fName == null)
return null;
- String name= fName.getText();
+ String name = fName.getText();
if (name.isEmpty())
return createErrorStatus(Messages.ParameterEditDialog_name_error);
- IStatus status= CConventions.validateFieldName(name);
+ IStatus status = CConventions.validateFieldName(name);
if (status.matches(IStatus.ERROR))
return status;
return Status.OK_STATUS;
@@ -209,7 +205,7 @@ public class ParameterEditDialog extends StatusDialog {
private IStatus validateDefaultValue() {
if (fDefaultValue == null)
return null;
- String defaultValue= fDefaultValue.getText();
+ String defaultValue = fDefaultValue.getText();
if (defaultValue.isEmpty())
return createErrorStatus(Messages.ParameterEditDialog_default_value_error);
// TODO(sprigogin): Implement real default value validation.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java
index fb5a7af1ba2..9dcda5bfd2f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java
@@ -67,10 +67,10 @@ public class RefactoringExecutionHelper {
final boolean fCancelable;
public Operation(boolean forked, boolean forkChangeExecution, boolean cancelable) {
- fForked= forked;
- fForkChangeExecution= forkChangeExecution;
+ fForked = forked;
+ fForkChangeExecution = forkChangeExecution;
this.fCancelable = cancelable;
- }
+ }
@Override
public void run(IProgressMonitor pm) throws CoreException {
@@ -78,32 +78,35 @@ public class RefactoringExecutionHelper {
pm.beginTask("", fForked && !fForkChangeExecution ? 7 : 11); //$NON-NLS-1$
pm.subTask(""); //$NON-NLS-1$
- final RefactoringStatus status= fRefactoring.checkAllConditions(
+ final RefactoringStatus status = fRefactoring.checkAllConditions(
new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
if (status.getSeverity() >= fStopSeverity) {
- final boolean[] canceled= { false };
+ final boolean[] canceled = { false };
if (fForked) {
fParent.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
- canceled[0]= showStatusDialog(status);
+ canceled[0] = showStatusDialog(status);
}
});
} else {
- canceled[0]= showStatusDialog(status);
+ canceled[0] = showStatusDialog(status);
}
if (canceled[0]) {
throw new OperationCanceledException();
}
}
- fChange= fRefactoring.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- fChange.initializeValidationData(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ fChange = fRefactoring
+ .createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ fChange.initializeValidationData(
+ new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
fPerformChangeOperation = createPerformChangeOperation(fChange);
if (!fForked || fForkChangeExecution)
- fPerformChangeOperation.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ fPerformChangeOperation
+ .run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
} finally {
pm.done();
}
@@ -114,7 +117,7 @@ public class RefactoringExecutionHelper {
* @return <code>true</code> iff the operation should be cancelled
*/
private boolean showStatusDialog(RefactoringStatus status) {
- Dialog dialog= RefactoringUI.createRefactoringStatusDialog(status, fParent, fRefactoring.getName(), false);
+ Dialog dialog = RefactoringUI.createRefactoringStatusDialog(status, fParent, fRefactoring.getName(), false);
return dialog.open() == IDialogConstants.CANCEL_ID;
}
}
@@ -134,11 +137,11 @@ public class RefactoringExecutionHelper {
Assert.isNotNull(refactoring);
Assert.isNotNull(parent);
Assert.isNotNull(context);
- fRefactoring= refactoring;
- fStopSeverity= stopSeverity;
- fParent= parent;
- fExecContext= context;
- fSaveMode= saveMode;
+ fRefactoring = refactoring;
+ fStopSeverity = stopSeverity;
+ fParent = parent;
+ fExecContext = context;
+ fSaveMode = saveMode;
}
/**
@@ -168,14 +171,13 @@ public class RefactoringExecutionHelper {
performOperation(operation, null, fork);
}
- public void performChange(Change change, boolean fork)
- throws InterruptedException, InvocationTargetException {
+ public void performChange(Change change, boolean fork) throws InterruptedException, InvocationTargetException {
PerformChangeOperation operation = createPerformChangeOperation(change);
performOperation(null, operation, fork);
}
/**
- * Executes either a complete refactoring operation or a change operation.
+ * Executes either a complete refactoring operation or a change operation.
* @param operation The refactoring operation. Can be <code>null</code>.
* @param changeOperation The change operation. Has to be <code>null</code> if {@code operation}
* is not <code>null</code> and not <code>null</code> otherwise.
@@ -185,11 +187,11 @@ public class RefactoringExecutionHelper {
throws InterruptedException, InvocationTargetException {
Assert.isTrue((operation == null) != (changeOperation == null));
Assert.isTrue(Display.getCurrent() != null);
- final IJobManager manager= Job.getJobManager();
+ final IJobManager manager = Job.getJobManager();
final ISchedulingRule rule = getSchedulingRule();
try {
try {
- Runnable r= new Runnable() {
+ Runnable r = new Runnable() {
@Override
public void run() {
manager.beginRule(rule, null);
@@ -200,7 +202,7 @@ public class RefactoringExecutionHelper {
throw new InterruptedException(e.getMessage());
}
- RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(fSaveMode);
+ RefactoringSaveHelper saveHelper = new RefactoringSaveHelper(fSaveMode);
if (operation != null) {
if (!saveHelper.saveEditors(fParent))
throw new InterruptedException();
@@ -212,11 +214,11 @@ public class RefactoringExecutionHelper {
changeOperation = operation.fPerformChangeOperation;
fork = fork && !operation.fForkChangeExecution;
}
-
+
if (changeOperation != null) {
if (fork)
fExecContext.run(false, false, new WorkbenchRunnableAdapter(changeOperation, rule, true));
- RefactoringStatus validationStatus= changeOperation.getValidationStatus();
+ RefactoringStatus validationStatus = changeOperation.getValidationStatus();
if (validationStatus != null && validationStatus.hasFatalError()) {
MessageDialog.openError(fParent, fRefactoring.getName(),
NLS.bind(Messages.RefactoringExecutionHelper_cannot_execute,
@@ -226,12 +228,12 @@ public class RefactoringExecutionHelper {
}
} catch (InvocationTargetException e) {
if (changeOperation != null && changeOperation.changeExecutionFailed()) {
- ChangeExceptionHandler handler= new ChangeExceptionHandler(fParent, fRefactoring);
- Throwable inner= e.getTargetException();
+ ChangeExceptionHandler handler = new ChangeExceptionHandler(fParent, fRefactoring);
+ Throwable inner = e.getTargetException();
if (inner instanceof RuntimeException) {
- handler.handle(changeOperation.getChange(), (RuntimeException)inner);
+ handler.handle(changeOperation.getChange(), (RuntimeException) inner);
} else if (inner instanceof CoreException) {
- handler.handle(changeOperation.getChange(), (CoreException)inner);
+ handler.handle(changeOperation.getChange(), (CoreException) inner);
} else {
throw e;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java
index c665d0411a0..be977029e4c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java
@@ -32,9 +32,9 @@ public abstract class RefactoringRunner {
public RefactoringRunner(ICElement element, ISelection selection, IShellProvider shellProvider,
ICProject cProject) {
this.selection = selection;
- this.element= element;
+ this.element = element;
this.project = cProject;
- this.shellProvider= shellProvider;
+ this.shellProvider = shellProvider;
}
public abstract void run();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java
index 9599a56fd58..73a8a4724f8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java
@@ -49,10 +49,10 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
/**
* Helper to save dirty editors prior to starting a refactoring.
- *
+ *
* @see PreferenceConstants#REFACTOR_SAVE_ALL_EDITORS
* @since 5.3
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
public class RefactoringSaveHelper {
@@ -62,41 +62,39 @@ public class RefactoringSaveHelper {
/**
* Save mode to save all dirty editors (always ask).
*/
- public static final int SAVE_ALL_ALWAYS_ASK= 1;
+ public static final int SAVE_ALL_ALWAYS_ASK = 1;
/**
* Save mode to save all dirty editors.
*/
- public static final int SAVE_ALL= 2;
+ public static final int SAVE_ALL = 2;
/**
* Save mode to not save any editors.
*/
- public static final int SAVE_NOTHING= 3;
-
+ public static final int SAVE_NOTHING = 3;
+
/**
* Save mode to save all editors that are known to cause trouble for C refactorings, e.g.
* editors on compilation units that are not in working copy mode.
*/
- public static final int SAVE_REFACTORING= 4;
-
+ public static final int SAVE_REFACTORING = 4;
+
/**
* Creates a refactoring save helper with the given save mode.
- *
+ *
* @param saveMode one of the SAVE_* constants
*/
public RefactoringSaveHelper(int saveMode) {
- Assert.isLegal(saveMode == SAVE_ALL_ALWAYS_ASK
- || saveMode == SAVE_ALL
- || saveMode == SAVE_NOTHING
+ Assert.isLegal(saveMode == SAVE_ALL_ALWAYS_ASK || saveMode == SAVE_ALL || saveMode == SAVE_NOTHING
|| saveMode == SAVE_REFACTORING);
- fSaveMode= saveMode;
+ fSaveMode = saveMode;
}
/**
* Saves all editors. Depending on the {@link PreferenceConstants#REFACTOR_SAVE_ALL_EDITORS}
* preference, the user is asked to save affected dirty editors.
- *
+ *
* @param shell the parent shell for the confirmation dialog
* @return <code>true</code> if save was successful and refactoring can proceed;
* false if the refactoring must be canceled
@@ -104,20 +102,20 @@ public class RefactoringSaveHelper {
public boolean saveEditors(Shell shell) {
final IEditorPart[] dirtyEditors;
switch (fSaveMode) {
- case SAVE_ALL_ALWAYS_ASK:
- case SAVE_ALL:
- dirtyEditors= EditorUtility.getDirtyEditors(true);
- break;
+ case SAVE_ALL_ALWAYS_ASK:
+ case SAVE_ALL:
+ dirtyEditors = EditorUtility.getDirtyEditors(true);
+ break;
- case SAVE_REFACTORING:
- dirtyEditors= EditorUtility.getDirtyEditorsToSave(false); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=175495
- break;
+ case SAVE_REFACTORING:
+ dirtyEditors = EditorUtility.getDirtyEditorsToSave(false); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=175495
+ break;
- case SAVE_NOTHING:
- return true;
+ case SAVE_NOTHING:
+ return true;
- default:
- throw new IllegalStateException(Integer.toString(fSaveMode));
+ default:
+ throw new IllegalStateException(Integer.toString(fSaveMode));
}
if (dirtyEditors.length == 0)
return true;
@@ -129,14 +127,14 @@ public class RefactoringSaveHelper {
if (!CUIPlugin.getActiveWorkbenchWindow().getWorkbench().saveAllEditors(false))
return false;
} else {
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor pm) throws InterruptedException {
- int count= dirtyEditors.length;
+ int count = dirtyEditors.length;
SubMonitor progress = SubMonitor.convert(pm, "", count); //$NON-NLS-1$
try {
- for (int i= 0; i < count; i++) {
- IEditorPart editor= dirtyEditors[i];
+ for (int i = 0; i < count; i++) {
+ IEditorPart editor = dirtyEditors[i];
editor.doSave(progress.split(1));
}
} catch (OperationCanceledException e) {
@@ -147,16 +145,17 @@ public class RefactoringSaveHelper {
}
};
try {
- PlatformUI.getWorkbench().getProgressService().runInUI(CUIPlugin.getActiveWorkbenchWindow(), runnable, null);
+ PlatformUI.getWorkbench().getProgressService().runInUI(CUIPlugin.getActiveWorkbenchWindow(), runnable,
+ null);
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, shell,
- Messages.RefactoringSaveHelper_saving, Messages.RefactoringSaveHelper_unexpected_exception);
+ ExceptionHandler.handle(e, shell, Messages.RefactoringSaveHelper_saving,
+ Messages.RefactoringSaveHelper_unexpected_exception);
return false;
}
}
- fFilesSaved= true;
+ fFilesSaved = true;
return true;
}
@@ -165,32 +164,34 @@ public class RefactoringSaveHelper {
*/
public void triggerIncrementalBuild() {
if (fFilesSaved && ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding()) {
- new GlobalBuildAction(CUIPlugin.getActiveWorkbenchWindow(), IncrementalProjectBuilder.INCREMENTAL_BUILD).run();
+ new GlobalBuildAction(CUIPlugin.getActiveWorkbenchWindow(), IncrementalProjectBuilder.INCREMENTAL_BUILD)
+ .run();
}
}
/**
* Returns whether this save helper did actually save any files.
- *
+ *
* @return <code>true</code> iff files have been saved
*/
public boolean didSaveFiles() {
return fFilesSaved;
}
-
+
private boolean askSaveAllDirtyEditors(Shell shell, IEditorPart[] dirtyEditors) {
- final boolean canSaveAutomatically= fSaveMode != SAVE_ALL_ALWAYS_ASK;
+ final boolean canSaveAutomatically = fSaveMode != SAVE_ALL_ALWAYS_ASK;
if (canSaveAutomatically && RefactoringSavePreferences.getSaveAllEditors()) //must save everything
return true;
- ListDialog dialog= new ListDialog(shell) {
+ ListDialog dialog = new ListDialog(shell) {
{
setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL);
}
+
@Override
protected Control createDialogArea(Composite parent) {
- Composite result= (Composite) super.createDialogArea(parent);
+ Composite result = (Composite) super.createDialogArea(parent);
if (canSaveAutomatically) {
- final Button check= new Button(result, SWT.CHECK);
+ final Button check = new Button(result, SWT.CHECK);
check.setText(Messages.RefactoringSaveHelper_always_save);
check.setSelection(RefactoringSavePreferences.getSaveAllEditors());
check.addSelectionListener(new SelectionAdapter() {
@@ -218,6 +219,7 @@ public class RefactoringSaveHelper {
public Image getImage(Object element) {
return ((IEditorPart) element).getTitleImage();
}
+
@Override
public String getText(Object element) {
return ((IEditorPart) element).getTitle();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferences.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferences.java
index d09e16a8e4f..da648f95426 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferences.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferences.java
@@ -20,15 +20,15 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
public class RefactoringSavePreferences {
- public static final String PREF_SAVE_ALL_EDITORS= PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS;
+ public static final String PREF_SAVE_ALL_EDITORS = PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS;
public static boolean getSaveAllEditors() {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
return store.getBoolean(PREF_SAVE_ALL_EDITORS);
}
public static void setSaveAllEditors(boolean save) {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
store.setValue(PREF_SAVE_ALL_EDITORS, save);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java
index eec16ee80b2..9ff0dc0a582 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java
@@ -27,15 +27,16 @@ public class RefactoringStarter {
private RefactoringStatus fStatus;
public boolean activate(RefactoringWizard wizard, Shell parent, String dialogTitle, int saveMode) {
- RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(saveMode);
+ RefactoringSaveHelper saveHelper = new RefactoringSaveHelper(saveMode);
if (!saveHelper.saveEditors(parent))
return false;
try {
- RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
- int result= op.run(parent, dialogTitle);
- fStatus= op.getInitialConditionCheckingStatus();
- if (result == IDialogConstants.CANCEL_ID || result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED) {
+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
+ int result = op.run(parent, dialogTitle);
+ fStatus = op.getInitialConditionCheckingStatus();
+ if (result == IDialogConstants.CANCEL_ID
+ || result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED) {
saveHelper.triggerIncrementalBuild();
return false;
} else {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/VariableNameInformation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/VariableNameInformation.java
index 17343c3e11f..1f39ea694ab 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/VariableNameInformation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/VariableNameInformation.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -22,11 +22,11 @@ import java.util.List;
* Contains the name for a new variable and holds a list of used names.
*/
public class VariableNameInformation {
- private String name = ""; //$NON-NLS-1$
+ private String name = ""; //$NON-NLS-1$
private final ArrayList<String> usedNames = new ArrayList<String>();
public String getName() {
- return name;
+ return name;
}
public void setName(String name) {
@@ -36,11 +36,11 @@ public class VariableNameInformation {
public List<String> getUsedNames() {
return usedNames;
}
-
+
public void addNameToUsedNames(String name) {
usedNames.add(name);
}
-
+
public void addNamesToUsedNames(List<String> names) {
usedNames.addAll(names);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/AbstractCElementRenameChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/AbstractCElementRenameChange.java
index eefb366e079..82455978510 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/AbstractCElementRenameChange.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/AbstractCElementRenameChange.java
@@ -39,10 +39,10 @@ public abstract class AbstractCElementRenameChange extends ResourceChange {
protected AbstractCElementRenameChange(IPath resourcePath, String oldName, String newName, long stampToRestore) {
Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
Assert.isNotNull(oldName, "old name"); //$NON-NLS-1$
- fResourcePath= resourcePath;
- fOldName= oldName;
- fNewName= newName;
- fStampToRestore= stampToRestore;
+ fResourcePath = resourcePath;
+ fOldName = oldName;
+ fNewName = newName;
+ fStampToRestore = stampToRestore;
}
protected abstract IPath createNewPath();
@@ -81,12 +81,12 @@ public abstract class AbstractCElementRenameChange extends ResourceChange {
public final Change perform(IProgressMonitor pm) throws CoreException {
try {
pm.beginTask(Messages.AbstractCElementRenameChange_renaming, 1);
- IResource resource= getResource();
- IPath newPath= createNewPath();
- Change result= createUndoChange(resource.getModificationStamp());
+ IResource resource = getResource();
+ IPath newPath = createNewPath();
+ Change result = createUndoChange(resource.getModificationStamp());
doRename(new SubProgressMonitor(pm, 1));
if (fStampToRestore != IResource.NULL_STAMP) {
- IResource newResource= ResourcesPlugin.getWorkspace().getRoot().findMember(newPath);
+ IResource newResource = ResourcesPlugin.getWorkspace().getRoot().findMember(newPath);
newResource.revertModificationStamp(fStampToRestore);
}
return result;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CCompositeChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CCompositeChange.java
index 52a6cda1cba..d91c137f63e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CCompositeChange.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CCompositeChange.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.changes;
@@ -24,7 +24,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
*/
public class CCompositeChange extends CompositeChange {
private RefactoringChangeDescriptor desc;
-
+
public CCompositeChange(String name, Change[] children) {
super(name, children);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CreateFileChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CreateFileChange.java
index 2b97285a07e..dd4bbc3b755 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CreateFileChange.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/CreateFileChange.java
@@ -75,10 +75,10 @@ public class CreateFileChange extends ResourceChange {
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
- RefactoringStatus result= new RefactoringStatus();
- IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ RefactoringStatus result = new RefactoringStatus();
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- URI location= file.getLocationURI();
+ URI location = file.getLocationURI();
if (location == null) {
result.addFatalError(NLS.bind(Messages.CreateFileChange_unknown_location, file.getFullPath().toString()));
return result;
@@ -93,7 +93,7 @@ public class CreateFileChange extends ResourceChange {
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
- IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
InputStream is = new ByteArrayInputStream(source.getBytes());
file.create(is, false, new SubProgressMonitor(pm, 1));
if (encoding != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/DeleteFileChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/DeleteFileChange.java
index af979f8e502..a6db7f97ca0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/DeleteFileChange.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/DeleteFileChange.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -31,8 +31,8 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.osgi.util.NLS;
/**
- * The counterpart to the {@link CreateFileChange}, a change to delete a file.
- *
+ * The counterpart to the {@link CreateFileChange}, a change to delete a file.
+ *
* @author Emanuel Graf
*/
public class DeleteFileChange extends Change {
@@ -50,7 +50,7 @@ public class DeleteFileChange extends Change {
@Override
public String getName() {
- return NLS.bind(Messages.DeleteFileChange_delete_file, path.toOSString());
+ return NLS.bind(Messages.DeleteFileChange_delete_file, path.toOSString());
}
@Override
@@ -63,42 +63,42 @@ public class DeleteFileChange extends Change {
RefactoringStatus status = new RefactoringStatus();
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (!file.exists()) {
- status.addFatalError(NLS.bind(Messages.DeleteFileChange_file_does_not_exist, path.toString()));
+ status.addFatalError(NLS.bind(Messages.DeleteFileChange_file_does_not_exist, path.toString()));
}
return status;
}
-
+
private String getSource(IFile file) throws CoreException {
- String encoding= null;
+ String encoding = null;
try {
- encoding= file.getCharset();
+ encoding = file.getCharset();
} catch (CoreException e) {
// fall through. Take default encoding.
}
- StringBuilder sb= new StringBuilder();
- BufferedReader br= null;
- InputStream in= null;
+ StringBuilder sb = new StringBuilder();
+ BufferedReader br = null;
+ InputStream in = null;
try {
- in= file.getContents();
- if (encoding != null) {
- br= new BufferedReader(new InputStreamReader(in, encoding));
- } else {
- br= new BufferedReader(new InputStreamReader(in));
- }
- int read= 0;
- while ((read= br.read()) != -1) {
+ in = file.getContents();
+ if (encoding != null) {
+ br = new BufferedReader(new InputStreamReader(in, encoding));
+ } else {
+ br = new BufferedReader(new InputStreamReader(in));
+ }
+ int read = 0;
+ while ((read = br.read()) != -1) {
sb.append((char) read);
}
br.close();
- } catch (IOException e){
-
+ } catch (IOException e) {
+
}
return sb.toString();
}
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
- IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
source = getSource(file);
Change undo = new CreateFileChange(file.getFullPath(), source, file.getCharset());
file.delete(true, true, pm);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java
index 3412ceeff93..994189f5084 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java
@@ -40,7 +40,7 @@ public final class RenameTranslationUnitChange extends AbstractCElementRenameCha
@Override
protected IPath createNewPath() {
- IPath path= getResourcePath();
+ IPath path = getResourcePath();
return path.removeLastSegments(1).append(getNewName());
}
@@ -51,15 +51,14 @@ public final class RenameTranslationUnitChange extends AbstractCElementRenameCha
@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
- ITranslationUnit tu= (ITranslationUnit) getModifiedElement();
+ ITranslationUnit tu = (ITranslationUnit) getModifiedElement();
if (tu != null)
tu.rename(getNewName(), false, pm);
}
@Override
public String getName() {
- return NLS.bind(Messages.RenameTranslationUnitChange_name,
- BasicElementLabels.getCElementName(getOldName()),
+ return NLS.bind(Messages.RenameTranslationUnitChange_name, BasicElementLabels.getCElementName(getOldName()),
BasicElementLabels.getCElementName(getNewName()));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/UndoCTextFileChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/UndoCTextFileChange.java
index ec59dd81c40..f92c971a1d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/UndoCTextFileChange.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/UndoCTextFileChange.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - Initial API and implementation
* Markus Schorn (Wind River Systems)
@@ -38,58 +38,55 @@ import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.ui.refactoring.DocumentAdapter;
/**
- * UndoCTextFileChange that uses a working copy in order to generate CModel events.
+ * UndoCTextFileChange that uses a working copy in order to generate CModel events.
* @author janees
*/
-public class UndoCTextFileChange
- extends UndoTextFileChange {
-
- UndoEdit mUndoEdit = null;
+public class UndoCTextFileChange extends UndoTextFileChange {
+
+ UndoEdit mUndoEdit = null;
+
+ public UndoCTextFileChange(String name, IFile file, UndoEdit undo, ContentStamp stamp, int saveMode) {
+ super(name, file, undo, stamp, saveMode);
+ mUndoEdit = undo;
+ }
- public UndoCTextFileChange(String name, IFile file, UndoEdit undo, ContentStamp stamp, int saveMode) {
- super(name, file, undo, stamp, saveMode);
- mUndoEdit = undo;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.UndoTextFileChange#perform(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public Change perform(IProgressMonitor pm)
- throws CoreException {
- if (pm == null){
- pm= new NullProgressMonitor();
- }
- Object obj = getModifiedElement();
- if(!(obj instanceof IFile)){
- throw new IllegalArgumentException();
- }
- final IFile file = (IFile) obj;
- ICElement element = CoreModel.getDefault().create(file);
- if (!(element instanceof TranslationUnit)) {
- return super.perform(pm);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.UndoTextFileChange#perform(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ if (pm == null) {
+ pm = new NullProgressMonitor();
+ }
+ Object obj = getModifiedElement();
+ if (!(obj instanceof IFile)) {
+ throw new IllegalArgumentException();
+ }
+ final IFile file = (IFile) obj;
+ ICElement element = CoreModel.getDefault().create(file);
+ if (!(element instanceof TranslationUnit)) {
+ return super.perform(pm);
+ }
- final TranslationUnit tu = (TranslationUnit) element;
- IWorkingCopy wc= tu.getWorkingCopy(pm, DocumentAdapter.FACTORY);
- final IBuffer buffer= wc.getBuffer();
- assert buffer instanceof DocumentAdapter;
- if (buffer instanceof DocumentAdapter) {
- IDocument document= ((DocumentAdapter) buffer).getDocument();
- try {
- UndoEdit redo= mUndoEdit.apply(document, TextEdit.CREATE_UNDO);
- wc.commit(false, pm);
- return new UndoCTextFileChange(getName(), file, redo, null, getSaveMode());
- } catch (MalformedTreeException e) {
- CUIPlugin.log(e);
- } catch (BadLocationException e) {
- CUIPlugin.log(e);
- }
- finally {
- wc.destroy();
- }
- }
- return null;
- }
+ final TranslationUnit tu = (TranslationUnit) element;
+ IWorkingCopy wc = tu.getWorkingCopy(pm, DocumentAdapter.FACTORY);
+ final IBuffer buffer = wc.getBuffer();
+ assert buffer instanceof DocumentAdapter;
+ if (buffer instanceof DocumentAdapter) {
+ IDocument document = ((DocumentAdapter) buffer).getDocument();
+ try {
+ UndoEdit redo = mUndoEdit.apply(document, TextEdit.CREATE_UNDO);
+ wc.commit(false, pm);
+ return new UndoCTextFileChange(getName(), file, redo, null, getSaveMode());
+ } catch (MalformedTreeException e) {
+ CUIPlugin.log(e);
+ } catch (BadLocationException e) {
+ CUIPlugin.log(e);
+ } finally {
+ wc.destroy();
+ }
+ }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java
index b5c93c6f904..e27e794eb59 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.dialogs;
@@ -54,13 +54,13 @@ import org.eclipse.cdt.internal.ui.text.CTextTools;
* @author Emanuel Graf
*
*/
-public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
-
+public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
+
private CPPMergeViewer viewer;
private CTextEditChangePane viewerPane;
private CTextEditChangePreviewViewerContentProvider textEditChangeContentProvider;
-
- private static class CTextEditChangePane extends CompareViewerPane{
+
+ private static class CTextEditChangePane extends CompareViewerPane {
/**
* @param parent
@@ -69,10 +69,10 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
public CTextEditChangePane(Composite parent, int style) {
super(parent, style);
}
-
+
}
-
- private class CPPMergeViewer extends CMergeViewer{
+
+ private class CPPMergeViewer extends CMergeViewer {
/**
* @param parent
@@ -85,23 +85,22 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
@Override
protected CSourceViewerConfiguration getSourceViewerConfiguration() {
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- return new CSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning());
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ return new CSourceViewerConfiguration(tools.getColorManager(), store, null,
+ tools.getDocumentPartitioning());
}
@Override
protected void configureTextViewer(TextViewer textViewer) {
if (textViewer instanceof SourceViewer) {
- ((SourceViewer)textViewer).configure(getSourceViewerConfiguration());
+ ((SourceViewer) textViewer).configure(getSourceViewerConfiguration());
}
}
-
-
+
}
-
- private class CTextEditChangePreviewViewerContentProvider implements IMergeViewerContentProvider{
+ private class CTextEditChangePreviewViewerContentProvider implements IMergeViewerContentProvider {
@Override
public Object getAncestorContent(Object input) {
@@ -114,7 +113,7 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
public Image getAncestorImage(Object input) {
if (input instanceof ICompareInput) {
ITypedElement ancestor = ((ICompareInput) input).getAncestor();
- if(ancestor != null) {
+ if (ancestor != null) {
return ancestor.getImage();
}
}
@@ -125,7 +124,7 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
public String getAncestorLabel(Object input) {
if (input instanceof ICompareInput) {
ITypedElement ancestor = ((ICompareInput) input).getAncestor();
- if(ancestor != null) {
+ if (ancestor != null) {
return ancestor.getName();
}
}
@@ -148,7 +147,7 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
@Override
public String getLeftLabel(Object input) {
- return Messages.CTextEditChangePreviewViewer_OrgSource;
+ return Messages.CTextEditChangePreviewViewer_OrgSource;
}
@Override
@@ -167,7 +166,7 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
@Override
public String getRightLabel(Object input) {
- return Messages.CTextEditChangePreviewViewer_RefactoredSource;
+ return Messages.CTextEditChangePreviewViewer_RefactoredSource;
}
@Override
@@ -205,31 +204,36 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
//Nothing to do
}
-
+
}
-
+
private static class CompareElement implements ITypedElement, IEncodedStreamContentAccessor, IResourceProvider {
- private static final String ENCODING= "UTF-8"; //$NON-NLS-1$
+ private static final String ENCODING = "UTF-8"; //$NON-NLS-1$
private final String fContent;
private final String fType;
private final IResource fResource;
+
public CompareElement(String content, String type, IResource resource) {
- fContent= content;
- fType= type;
- fResource= resource;
+ fContent = content;
+ fType = type;
+ fResource = resource;
}
+
@Override
public String getName() {
return ""; //$NON-NLS-1$
}
+
@Override
public Image getImage() {
return null;
}
+
@Override
public String getType() {
return fType;
}
+
@Override
public InputStream getContents() throws CoreException {
try {
@@ -238,10 +242,12 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
return new ByteArrayInputStream(fContent.getBytes());
}
}
+
@Override
public String getCharset() {
return ENCODING;
}
+
@Override
public IResource getResource() {
return fResource;
@@ -254,7 +260,7 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
compConfig.setLeftEditable(false);
compConfig.setRightEditable(false);
viewerPane = new CTextEditChangePane(parent, SWT.BORDER | SWT.FLAT);
- viewer = new CPPMergeViewer(viewerPane,SWT.MULTI | SWT.FULL_SELECTION, compConfig);
+ viewer = new CPPMergeViewer(viewerPane, SWT.MULTI | SWT.FULL_SELECTION, compConfig);
textEditChangeContentProvider = new CTextEditChangePreviewViewerContentProvider();
viewer.setContentProvider(textEditChangeContentProvider);
viewerPane.setContent(viewer.getControl());
@@ -268,10 +274,11 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
@Override
public void setInput(ChangePreviewViewerInput input) {
try {
- Change change= input.getChange();
+ Change change = input.getChange();
if (change instanceof CTextFileChange) {
- CTextFileChange editChange= (CTextFileChange)change;
- setInput(editChange, editChange.getCurrentContent(new NullProgressMonitor()), editChange.getPreviewContent(new NullProgressMonitor()), editChange.getTextType());
+ CTextFileChange editChange = (CTextFileChange) change;
+ setInput(editChange, editChange.getCurrentContent(new NullProgressMonitor()),
+ editChange.getPreviewContent(new NullProgressMonitor()), editChange.getTextType());
return;
}
viewer.setInput(null);
@@ -284,9 +291,8 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
IFile resource = change.getFile();
viewerPane.setText(resource.getName());
viewerPane.setImage(new CElementLabelProvider().getImage(resource));
- viewer.setInput(new DiffNode(
- new CompareElement(left, type, resource),
- new CompareElement(right, type, resource)));
+ viewer.setInput(
+ new DiffNode(new CompareElement(left, type, resource), new CompareElement(right, type, resource)));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java
index bec1f0a9834..4a79a5e75af 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.dialogs;
@@ -38,28 +38,28 @@ import org.eclipse.cdt.internal.ui.util.ViewerPane;
* @author Emanuel Graf
*/
public class CreateFileChangePreview implements IChangePreviewViewer {
-
+
private static class CreateFileChangePane extends ViewerPane {
public CreateFileChangePane(Composite parent, int style) {
super(parent, style);
}
}
-
+
private CreateFileChangePane control;
private SourceViewer srcViewer;
private CTextTools textTools;
-
+
@Override
public void createControl(Composite parent) {
- control = new CreateFileChangePane(parent, SWT.BORDER | SWT.FLAT);
+ control = new CreateFileChangePane(parent, SWT.BORDER | SWT.FLAT);
Dialog.applyDialogFont(control);
- srcViewer= new CSourceViewer(control, null, null, false,
+ srcViewer = new CSourceViewer(control, null, null, false,
SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION,
CUIPlugin.getDefault().getPreferenceStore());
textTools = CUIPlugin.getDefault().getTextTools();
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- CSourceViewerConfiguration configuration =
- new CSourceViewerConfiguration(textTools.getColorManager(), store, null, textTools.getDocumentPartitioning());
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(textTools.getColorManager(), store,
+ null, textTools.getDocumentPartitioning());
srcViewer.configure(configuration);
srcViewer.setEditable(false);
control.setContent(srcViewer.getControl());
@@ -73,7 +73,7 @@ public class CreateFileChangePreview implements IChangePreviewViewer {
@Override
public void setInput(ChangePreviewViewerInput input) {
Assert.isNotNull(input);
- if(control != null) {
+ if (control != null) {
Change change = input.getChange();
if (change instanceof CreateFileChange) {
CreateFileChange createFileChange = (CreateFileChange) change;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField.java
index 11a7f07913e..2c5498b8d19 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.dialogs;
@@ -29,35 +29,35 @@ import org.eclipse.swt.widgets.Text;
public class LabeledTextField extends Composite {
private final Text textField;
- public LabeledTextField(Composite parent, String labelName, String textContent) {
+ public LabeledTextField(Composite parent, String labelName, String textContent) {
super(parent, SWT.NONE);
-
+
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
setLayout(layout);
-
+
Label label = new Label(this, SWT.NONE);
label.setText(labelName);
label.setLayoutData(new GridData());
-
+
textField = new Text(this, SWT.BORDER | SWT.SINGLE);
textField.setText(textContent);
textField.selectAll();
- GridData textData = new GridData(GridData.FILL_HORIZONTAL);
+ GridData textData = new GridData(GridData.FILL_HORIZONTAL);
textData.grabExcessHorizontalSpace = true;
textField.setLayoutData(textData);
}
-
- public LabeledTextField(Composite parent, String labelName) {
+
+ public LabeledTextField(Composite parent, String labelName) {
this(parent, labelName, ""); //$NON-NLS-1$
}
-
- public Text getText() {
+
+ public Text getText() {
return textField;
}
- public String getFieldContent(){
+ public String getFieldContent() {
return textField.getText();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.java
index 5c4efc73cd6..e7f36d10b91 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.dialogs;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilityComposite.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilityComposite.java
index 870c2bbda80..5a31fd5f2fd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilityComposite.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilityComposite.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.dialogs;
@@ -26,50 +26,49 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
/**
* Composite to query for a name and visibility.
- *
+ *
* @author Thomas Corbat
*
*/
public class NameAndVisibilityComposite extends Composite {
-
+
private LabeledTextField constantName;
private final String labelName;
private final VisibilitySelectionPanel visibilityPanel;
-
+
public NameAndVisibilityComposite(Composite parent, String labelName, String defaultName) {
this(parent, labelName, VisibilityEnum.v_public, defaultName);
}
-
- public NameAndVisibilityComposite(Composite parent, String labelName, VisibilityEnum defaultVisibility, String defaultName){
+
+ public NameAndVisibilityComposite(Composite parent, String labelName, VisibilityEnum defaultVisibility,
+ String defaultName) {
super(parent, SWT.NONE);
-
+
this.labelName = labelName;
-
+
setLayout(new GridLayout());
-
+
createNewMethodNameComposite(this, defaultName);
- visibilityPanel = new VisibilitySelectionPanel(this, defaultVisibility,SWT.NONE);
+ visibilityPanel = new VisibilitySelectionPanel(this, defaultVisibility, SWT.NONE);
}
-
public Text getConstantNameText() {
return constantName.getText();
}
-
+
public Group getVisibiltyGroup() {
return visibilityPanel.getGroup();
}
-
+
public void visibilityPanelsetVisible(boolean visible) {
visibilityPanel.setVisible(visible);
}
-
private void createNewMethodNameComposite(Composite control, String defaultName) {
Composite methodNameComposite = new Composite(control, SWT.NONE);
FillLayout compositeLayout = new FillLayout(SWT.HORIZONTAL);
- GridData gridData = new GridData(SWT.FILL,SWT.BEGINNING, true, false);
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
gridData.horizontalAlignment = GridData.FILL;
methodNameComposite.setLayoutData(gridData);
methodNameComposite.setLayout(compositeLayout);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabeledTextField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabeledTextField.java
index 7d12a2fd561..c06e12c6b97 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabeledTextField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabeledTextField.java
@@ -1,19 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.internal.ui.refactoring.dialogs;
import java.util.ArrayList;
@@ -35,23 +34,22 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
-
/**
* @author Mirko Stocker
- *
+ *
* Text field with a description and error handling using the Validator-Callback. Can also be used for multiple inputs.
*
*/
public class ValidatingLabeledTextField extends Composite {
-
+
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private final Map<Text, Boolean> validationStatus = new HashMap<Text, Boolean>();
-
+
private final ArrayList<Listener> inputTextListeners = new ArrayList<Listener>();
-
+
private final Color errorColor = new Color(getShell().getDisplay(), new RGB(255, 208, 196));
-
+
/**
* The Validator is used for feedback about the validation status of the inputs and to validate the input.
*/
@@ -60,29 +58,33 @@ public class ValidatingLabeledTextField extends Composite {
/**
* Is called if all input texts contain valid input.
*/
- public void hasErrors() {}
-
+ public void hasErrors() {
+ }
+
/**
* Is called if any input text contains invalid input.
*/
- public void hasNoErrors() {}
-
+ public void hasNoErrors() {
+ }
+
/**
* @param text the new value of the field
* @return whether the value is valid or not
*/
- public boolean isValidInput(String text) { return true; }
+ public boolean isValidInput(String text) {
+ return true;
+ }
public String errorMessageForEmptyField() {
- return Messages.ValidatingLabeledTextField_CantBeEmpty;
+ return Messages.ValidatingLabeledTextField_CantBeEmpty;
}
public String errorMessageForInvalidInput() {
- return Messages.ValidatingLabeledTextField_InvalidCharacters;
+ return Messages.ValidatingLabeledTextField_InvalidCharacters;
}
public String errorMessageForDuplicateValues() {
- return Messages.ValidatingLabeledTextField_DuplicatedNames;
+ return Messages.ValidatingLabeledTextField_DuplicatedNames;
}
public String errorIsKeywordMessage() {
@@ -92,51 +94,50 @@ public class ValidatingLabeledTextField extends Composite {
public ValidatingLabeledTextField(Composite parent, int style) {
super(parent, style);
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 4;
-
- setLayout(gridLayout);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 4;
+
+ setLayout(gridLayout);
}
public ValidatingLabeledTextField(Composite parent) {
this(parent, SWT.NONE);
}
-
+
public void addElement(String description, String initialText, boolean readOnly, final Validator validator) {
-
+
Label label = new Label(this, SWT.NONE);
label.setText(description);
label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- final Text textField = new Text(this, SWT.BORDER |SWT.SINGLE);
+ final Text textField = new Text(this, SWT.BORDER | SWT.SINGLE);
textField.setText(initialText);
textField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- if(readOnly) {
+
+ if (readOnly) {
//readOnly inputs are always valid:
validationStatus.put(textField, Boolean.TRUE);
textField.setEnabled(false);
return;
}
validationStatus.put(textField, Boolean.FALSE);
-
+
final Label errorImageLabel = new Label(this, SWT.NONE);
errorImageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
errorImageLabel.setLayoutData(new GridData());
errorImageLabel.setVisible(false);
-
+
final Label errorLabel = new Label(this, SWT.NONE);
errorLabel.setLayoutData(new GridData());
final Color defaultColor = textField.getBackground();
-
- Listener listener = new Listener(){
-
+
+ Listener listener = new Listener() {
+
@SuppressWarnings("unchecked")
public void checkField() {
String newName = textField.getText();
-
boolean isEmpty = (newName.length() == 0);
@@ -150,27 +151,28 @@ public class ValidatingLabeledTextField extends Composite {
setErrorStatus(EMPTY_STRING);
} else if (isEmpty) {
setErrorStatus(validator.errorMessageForEmptyField());
- } else if (!isValid || !isValidName) {
+ } else if (!isValid || !isValidName) {
setErrorStatus(validator.errorMessageForInvalidInput());
} else if (isKeyword) {
setErrorStatus(validator.errorIsKeywordMessage());
- }else if (isNameAlreadyInUse) {
+ } else if (isNameAlreadyInUse) {
setErrorStatus(validator.errorMessageForDuplicateValues());
- }
+ }
validationStatus.put(textField, isOk);
-
- if(validationStatus.values().contains(Boolean.FALSE) || isEmpty || isNameAlreadyInUse || isKeyword || !isValidName) {
+
+ if (validationStatus.values().contains(Boolean.FALSE) || isEmpty || isNameAlreadyInUse || isKeyword
+ || !isValidName) {
validator.hasErrors();
} else {
validator.hasNoErrors();
}
-
+
layout();
-
- // recheck all other listeners in case duplicate names have been resolved,
+
+ // recheck all other listeners in case duplicate names have been resolved,
// but remove this first to avoid an infinite loop
inputTextListeners.remove(this);
- for(Listener listener : (ArrayList<Listener>) inputTextListeners.clone()) {
+ for (Listener listener : (ArrayList<Listener>) inputTextListeners.clone()) {
listener.handleEvent(null);
}
inputTextListeners.add(this);
@@ -178,7 +180,7 @@ public class ValidatingLabeledTextField extends Composite {
private boolean nameAlreadyInUse(final Text textField, String newName) {
for (Text text : validationStatus.keySet()) {
- if(text != textField && text.getText().equals(newName)) {
+ if (text != textField && text.getText().equals(newName)) {
return true;
}
}
@@ -196,17 +198,18 @@ public class ValidatingLabeledTextField extends Composite {
errorImageLabel.setVisible(true);
}
}
-
+
@Override
public void handleEvent(Event event) {
checkField();
- }};
-
+ }
+ };
+
//we need to keep a list of all listeners so we get access from other textfields to resolve duplicate names
inputTextListeners.add(listener);
-
+
listener.handleEvent(null);
-
+
textField.addListener(SWT.Modify, listener);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelectionPanel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelectionPanel.java
index 5bb445ff393..12b90cd188b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelectionPanel.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelectionPanel.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.dialogs;
@@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
/**
* Three radio buttons in a group, labeled according to the corresponding visibility name
* (public, private, protected).
- *
+ *
* @author Thomas Corbat
*/
public class VisibilitySelectionPanel extends Composite {
@@ -38,13 +38,13 @@ public class VisibilitySelectionPanel extends Composite {
public VisibilitySelectionPanel(Composite parent, VisibilityEnum defaultVisibility, int style) {
super(parent, style);
-
+
FillLayout compositeLayout = new FillLayout(SWT.HORIZONTAL);
setLayout(compositeLayout);
- GridData gridData = new GridData(SWT.FILL,SWT.BEGINNING, true, false);
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
gridData.horizontalAlignment = GridData.FILL;
setLayoutData(gridData);
-
+
createAccessModifierComposite(this);
setSelected(defaultVisibility);
}
@@ -54,14 +54,14 @@ public class VisibilitySelectionPanel extends Composite {
RowLayout groupLayout = new RowLayout(SWT.HORIZONTAL);
groupLayout.fill = true;
accessModifierGroup.setLayout(groupLayout);
- accessModifierGroup.setText(Messages.VisibilitySelectionPanel_AccessModifier);
-
+ accessModifierGroup.setText(Messages.VisibilitySelectionPanel_AccessModifier);
+
publicAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
publicAccessRadioButton.setText(VisibilityEnum.v_public.toString());
-
+
protectedAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
protectedAccessRadioButton.setText(VisibilityEnum.v_protected.toString());
-
+
privateAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
privateAccessRadioButton.setText(VisibilityEnum.v_private.toString());
}
@@ -82,8 +82,8 @@ public class VisibilitySelectionPanel extends Composite {
public Group getGroup() {
return accessModifierGroup;
- }
-
+ }
+
@Override
public void setEnabled(boolean enabled) {
accessModifierGroup.setEnabled(enabled);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantInfo.java
index 7ac1d118b0f..3477b800b4a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantInfo.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS) - initial API and implementation
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
@@ -50,6 +50,7 @@ public class ExtractConstantInfo extends VariableNameInformation {
public MethodContext getMethodContext() {
return methodContext;
}
+
public void setMethodContext(MethodContext context) {
methodContext = context;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java
index 4bd76da1c44..644faa1dbb3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
@@ -77,7 +77,7 @@ import org.eclipse.cdt.internal.ui.util.NameComposer;
/**
* The main class of the Extract Constant refactoring.
- *
+ *
* @author Mirko Stocker
*/
public class ExtractConstantRefactoring extends CRefactoring {
@@ -93,8 +93,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
if (SelectionHelper.nodeMatchesSelection(expression, selectedRegion)) {
selectedExpression = expression;
return PROCESS_ABORT;
- } else if (expression instanceof IASTLiteralExpression &&
- SelectionHelper.isSelectionInsideNode(expression, selectedRegion)) {
+ } else if (expression instanceof IASTLiteralExpression
+ && SelectionHelper.isSelectionInsideNode(expression, selectedRegion)) {
selectedExpression = expression;
return PROCESS_ABORT;
}
@@ -104,8 +104,7 @@ public class ExtractConstantRefactoring extends CRefactoring {
private static final String PREFIX_FOR_NAME_WITH_LEADING_DIGIT = "_"; //$NON-NLS-1$
- public static final String ID =
- "org.eclipse.cdt.ui.refactoring.extractconstant.ExtractConstantRefactoring"; //$NON-NLS-1$
+ public static final String ID = "org.eclipse.cdt.ui.refactoring.extractconstant.ExtractConstantRefactoring"; //$NON-NLS-1$
private IASTExpression target;
private final ExtractConstantInfo info;
@@ -117,7 +116,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
}
@Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor monitor)
+ throws CoreException, OperationCanceledException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 12);
RefactoringStatus status = super.checkInitialConditions(subMonitor.split(8));
@@ -155,7 +155,7 @@ public class ExtractConstantRefactoring extends CRefactoring {
subMonitor.split(1);
IScope containingScope = CPPVisitor.getContainingScope(target);
IASTTranslationUnit ast = target.getTranslationUnit();
- info.setNameUsedChecker((String name) -> {
+ info.setNameUsedChecker((String name) -> {
IBinding[] bindingsForName = containingScope.find(name, ast);
return bindingsForName.length != 0;
});
@@ -183,8 +183,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
}
if (expression instanceof IASTBinaryExpression) {
IASTBinaryExpression binaryExpression = (IASTBinaryExpression) expression;
- return isExtractableExpression(binaryExpression.getOperand1()) &&
- isExtractableExpression(binaryExpression.getOperand2());
+ return isExtractableExpression(binaryExpression.getOperand1())
+ && isExtractableExpression(binaryExpression.getOperand2());
}
return false;
}
@@ -206,10 +206,10 @@ public class ExtractConstantRefactoring extends CRefactoring {
PreferenceConstants.NAME_STYLE_CAPITALIZATION_UPPER_CASE, null);
String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
PreferenceConstants.NAME_STYLE_CONSTANT_WORD_DELIMITER, "_", null); //$NON-NLS-1$
- String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CONSTANT_PREFIX, "", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CONSTANT_SUFFIX, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_CONSTANT_PREFIX, "", //$NON-NLS-1$
+ null);
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_CONSTANT_SUFFIX, "", //$NON-NLS-1$
+ null);
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
return composer;
}
@@ -229,8 +229,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
@Override
public int visit(IASTExpression expression) {
if (expression instanceof IASTLiteralExpression) {
- if (!(expression.getNodeLocations().length == 1 &&
- expression.getNodeLocations()[0] instanceof IASTMacroExpansionLocation)) {
+ if (!(expression.getNodeLocations().length == 1
+ && expression.getNodeLocations()[0] instanceof IASTMacroExpansionLocation)) {
IASTLiteralExpression literal = (IASTLiteralExpression) expression;
result.add(literal);
}
@@ -244,16 +244,17 @@ public class ExtractConstantRefactoring extends CRefactoring {
@Override
protected void collectModifications(IProgressMonitor monitor, ModificationCollector collector)
- throws CoreException, OperationCanceledException{
+ throws CoreException, OperationCanceledException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 10);
Collection<IASTExpression> expressionsToReplace = findExpressionsToExtract(subMonitor.split(4));
- Collection<IASTExpression> expressionsToReplaceInSameContext =
- filterLiteralsInSameContext(expressionsToReplace, subMonitor.split(3));
+ Collection<IASTExpression> expressionsToReplaceInSameContext = filterLiteralsInSameContext(expressionsToReplace,
+ subMonitor.split(3));
replaceLiteralsWithConstant(expressionsToReplaceInSameContext, collector, subMonitor.split(2));
insertConstantDeclaration(collector, subMonitor.split(1));
}
- private void insertConstantDeclaration(ModificationCollector collector, IProgressMonitor monitor) throws CoreException {
+ private void insertConstantDeclaration(ModificationCollector collector, IProgressMonitor monitor)
+ throws CoreException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 10);
MethodContext context = info.getMethodContext();
@@ -262,7 +263,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
String constName = info.getName();
if (context.getType() == MethodContext.ContextType.METHOD) {
IASTDeclaration methodDeclaration = context.getMethodDeclaration();
- ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) methodDeclaration.getParent();
+ ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) methodDeclaration
+ .getParent();
IASTDeclaration memberDeclaration = createConstantDeclarationForClass(constName);
ClassMemberInserter.createChange(classDefinition, info.getVisibility(), memberDeclaration, true, collector);
} else {
@@ -273,7 +275,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
}
}
- private void replaceLiteralsWithConstant(Collection<IASTExpression> literals, ModificationCollector collector, IProgressMonitor monitor) {
+ private void replaceLiteralsWithConstant(Collection<IASTExpression> literals, ModificationCollector collector,
+ IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, literals.size());
String constName = info.getName();
for (IASTExpression each : literals) {
@@ -286,7 +289,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
}
}
- private Collection<IASTExpression> filterLiteralsInSameContext(Collection<IASTExpression> literalsToReplace, IProgressMonitor monitor) throws CoreException {
+ private Collection<IASTExpression> filterLiteralsInSameContext(Collection<IASTExpression> literalsToReplace,
+ IProgressMonitor monitor) throws CoreException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
MethodContext context = info.getMethodContext();
@@ -294,7 +298,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
if (context.getType() == MethodContext.ContextType.METHOD) {
SubMonitor loopMonitor = subMonitor.split(literalsToReplace.size());
for (IASTExpression expression : literalsToReplace) {
- MethodContext exprContext = NodeHelper.findMethodContext(expression, refactoringContext, loopMonitor.split(1));
+ MethodContext exprContext = NodeHelper.findMethodContext(expression, refactoringContext,
+ loopMonitor.split(1));
if (exprContext.getType() == MethodContext.ContextType.METHOD) {
if (context.getMethodQName() != null) {
if (MethodContext.isSameClass(exprContext.getMethodQName(), context.getMethodQName())) {
@@ -307,14 +312,14 @@ public class ExtractConstantRefactoring extends CRefactoring {
}
} else {
subMonitor.split(1);
- literalsToReplace.stream()
- .filter(expr -> expr.getTranslationUnit().getOriginatingTranslationUnit() != null)
- .collect(Collectors.toCollection(() -> locLiteralsToReplace));
+ literalsToReplace.stream().filter(expr -> expr.getTranslationUnit().getOriginatingTranslationUnit() != null)
+ .collect(Collectors.toCollection(() -> locLiteralsToReplace));
}
return locLiteralsToReplace;
}
- private Collection<IASTExpression> findExpressionsToExtract(IProgressMonitor monitor) throws OperationCanceledException, CoreException {
+ private Collection<IASTExpression> findExpressionsToExtract(IProgressMonitor monitor)
+ throws OperationCanceledException, CoreException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 5);
final Collection<IASTExpression> result = new ArrayList<>();
@@ -325,12 +330,12 @@ public class ExtractConstantRefactoring extends CRefactoring {
{
shouldVisitExpressions = true;
}
-
+
@Override
public int visit(IASTExpression expression) {
if (isSameExpressionTree(expression, target)) {
- if (!(expression.getNodeLocations().length == 1 &&
- expression.getNodeLocations()[0] instanceof IASTMacroExpansionLocation)) {
+ if (!(expression.getNodeLocations().length == 1
+ && expression.getNodeLocations()[0] instanceof IASTMacroExpansionLocation)) {
result.add(expression);
}
}
@@ -349,8 +354,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
if (expression1 instanceof IASTLiteralExpression && expression2 instanceof IASTLiteralExpression) {
IASTLiteralExpression literalExpression1 = (IASTLiteralExpression) expression1;
IASTLiteralExpression literalExpression2 = (IASTLiteralExpression) expression2;
- return literalExpression1.getKind() == literalExpression2.getKind() &&
- String.valueOf(expression1).equals(String.valueOf(expression2));
+ return literalExpression1.getKind() == literalExpression2.getKind()
+ && String.valueOf(expression1).equals(String.valueOf(expression2));
}
if (expression1 instanceof IASTUnaryExpression && expression2 instanceof IASTUnaryExpression) {
IASTUnaryExpression unaryExpression1 = (IASTUnaryExpression) expression1;
@@ -363,7 +368,7 @@ public class ExtractConstantRefactoring extends CRefactoring {
IASTBinaryExpression binaryExpression1 = (IASTBinaryExpression) expression1;
IASTBinaryExpression binaryExpression2 = (IASTBinaryExpression) expression2;
if (binaryExpression1.getOperator() == binaryExpression2.getOperator()) {
- return isSameExpressionTree(binaryExpression1.getOperand1(), binaryExpression2.getOperand1())
+ return isSameExpressionTree(binaryExpression1.getOperand1(), binaryExpression2.getOperand1())
&& isSameExpressionTree(binaryExpression1.getOperand2(), binaryExpression2.getOperand2());
}
}
@@ -393,7 +398,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
arguments.put(CRefactoringDescriptor.SELECTION, selectedRegion.getOffset() + "," + selectedRegion.getLength()); //$NON-NLS-1$
arguments.put(ExtractConstantRefactoringDescriptor.NAME, info.getName());
arguments.put(ExtractConstantRefactoringDescriptor.VISIBILITY, info.getVisibility().toString());
- arguments.put(ExtractConstantRefactoringDescriptor.REPLACE_ALL, Boolean.toString(info.isReplaceAllOccurences()));
+ arguments.put(ExtractConstantRefactoringDescriptor.REPLACE_ALL,
+ Boolean.toString(info.isReplaceAllOccurences()));
return arguments;
}
@@ -421,8 +427,8 @@ public class ExtractConstantRefactoring extends CRefactoring {
IASTSimpleDeclaration simple = createConstantDeclaration(newName);
if (nodeFactory instanceof ICPPNodeFactory) {
- ICPPASTNamespaceDefinition namespace =
- ((ICPPNodeFactory) nodeFactory).newNamespaceDefinition(nodeFactory.newName());
+ ICPPASTNamespaceDefinition namespace = ((ICPPNodeFactory) nodeFactory)
+ .newNamespaceDefinition(nodeFactory.newName());
namespace.addDeclaration(simple);
return namespace;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java
index 7629e5cf588..96e99de9859 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
@@ -26,8 +26,8 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
public class ExtractConstantRefactoringContribution extends CRefactoringContribution {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
- public RefactoringDescriptor createDescriptor(String id, String project, String description,
- String comment, Map arguments, int flags) throws IllegalArgumentException {
+ public RefactoringDescriptor createDescriptor(String id, String project, String description, String comment,
+ Map arguments, int flags) throws IllegalArgumentException {
if (id.equals(ExtractConstantRefactoring.ID)) {
return new ExtractConstantRefactoringDescriptor(project, description, comment, arguments);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java
index c4b88855251..26f45c70d43 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2009, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS)- initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
@@ -36,19 +36,19 @@ public class ExtractConstantRefactoringDescriptor extends CRefactoringDescriptor
protected static final String NAME = "name"; //$NON-NLS-1$
protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$
protected static final String REPLACE_ALL = "replaceAll"; //$NON-NLS-1$
-
- protected ExtractConstantRefactoringDescriptor(String project,
- String description, String comment, Map<String, String> arguments) {
- super(ExtractConstantRefactoring.ID, project, description, comment,
- RefactoringDescriptor.MULTI_CHANGE, arguments);
+
+ protected ExtractConstantRefactoringDescriptor(String project, String description, String comment,
+ Map<String, String> arguments) {
+ super(ExtractConstantRefactoring.ID, project, description, comment, RefactoringDescriptor.MULTI_CHANGE,
+ arguments);
}
-
+
@Override
public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException {
ISelection selection = getSelection();
ICProject project = getCProject();
- ExtractConstantRefactoring refactoring =
- new ExtractConstantRefactoring(getTranslationUnit(), selection, project);
+ ExtractConstantRefactoring refactoring = new ExtractConstantRefactoring(getTranslationUnit(), selection,
+ project);
ExtractConstantInfo info = refactoring.getRefactoringInfo();
info.setName(arguments.get(NAME));
info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY)));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java
index e389eafed83..4920fd12265 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -29,15 +29,14 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
*/
public class ExtractConstantRefactoringRunner extends RefactoringRunner {
- public ExtractConstantRefactoringRunner(ICElement element, ISelection selection,
- IShellProvider shellProvider, ICProject cProject) {
+ public ExtractConstantRefactoringRunner(ICElement element, ISelection selection, IShellProvider shellProvider,
+ ICProject cProject) {
super(element, selection, shellProvider, cProject);
}
@Override
public void run() {
- ExtractConstantRefactoring refactoring =
- new ExtractConstantRefactoring(element, selection, project);
+ ExtractConstantRefactoring refactoring = new ExtractConstantRefactoring(element, selection, project);
ExtractConstantWizard wizard = new ExtractConstantWizard(refactoring);
run(wizard, refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantWizard.java
index f0e9dcfb19b..5b7dcc081b0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantWizard.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPage.java
index 15301dd8253..5b97a4a6a49 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPage.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -64,7 +64,7 @@ public class InputPage extends UserInputWizardPage {
buttons.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
- String text = ((Button)e.getSource()).getText();
+ String text = ((Button) e.getSource()).getText();
visibilityChange(text);
}
});
@@ -93,19 +93,19 @@ public class InputPage extends UserInputWizardPage {
setPageComplete(true);
verifyName(methodName);
} else {
- setErrorMessage(result.getMessage());
+ setErrorMessage(result.getMessage());
setPageComplete(false);
}
}
private void verifyName(String name) {
if (info.isNameUsed(name)) {
- setErrorMessage(NLS.bind(Messages.InputPage_NameAlreadyDefined, name));
+ setErrorMessage(NLS.bind(Messages.InputPage_NameAlreadyDefined, name));
setPageComplete(false);
}
}
private void visibilityChange(String visibilityText) {
info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(visibilityText));
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.java
index c9aaf910ff6..3e446b691c2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExpressionExtractor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExpressionExtractor.java
index bd3737d5b37..2f5cbaf0a15 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExpressionExtractor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExpressionExtractor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2017 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -51,7 +51,7 @@ import org.eclipse.cdt.internal.ui.refactoring.NameInformation;
/**
* Handles the extraction of expression nodes, for example, return type determination.
- *
+ *
* @author Mirko Stocker
*/
public class ExpressionExtractor extends FunctionExtractor {
@@ -87,7 +87,7 @@ public class ExpressionExtractor extends FunctionExtractor {
@Override
public IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation nameInfo,
List<IASTPointerOperator> pointerOperators) {
- IType returnType = determineReturnType(extractedNode);
+ IType returnType = determineReturnType(extractedNode);
INodeFactory factory = extractedNode.getTranslationUnit().getASTNodeFactory();
DeclarationGenerator generator = DeclarationGenerator.create(factory);
IASTDeclarator declarator = generator.createDeclaratorFromType(returnType, null);
@@ -116,7 +116,7 @@ public class ExpressionExtractor extends FunctionExtractor {
{
shouldVisitExpressions = true;
}
-
+
@Override
public int visit(IASTExpression expression) {
if (expression instanceof IASTIdExpression) {
@@ -141,8 +141,7 @@ public class ExpressionExtractor extends FunctionExtractor {
}
@Override
- public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt,
- IASTExpression callExpression) {
+ public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression) {
return callExpression;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java
index ca8a583fa8e..02e4e790586 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java
@@ -113,14 +113,10 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
layout.marginWidth = 0;
group.setLayout(layout);
- String[] labels = new String[] {
- Messages.ExtractFunctionInputPage_public,
- Messages.ExtractFunctionInputPage_protected,
- Messages.ExtractFunctionInputPage_private
- };
- VisibilityEnum[] visibilityValues = new VisibilityEnum[] {
- VisibilityEnum.v_public, VisibilityEnum.v_protected, VisibilityEnum.v_private
- };
+ String[] labels = new String[] { Messages.ExtractFunctionInputPage_public,
+ Messages.ExtractFunctionInputPage_protected, Messages.ExtractFunctionInputPage_private };
+ VisibilityEnum[] visibilityValues = new VisibilityEnum[] { VisibilityEnum.v_public, VisibilityEnum.v_protected,
+ VisibilityEnum.v_private };
VisibilityEnum visibility = info.getVisibility();
for (int i = 0; i < labels.length; i++) {
Button radio = new Button(group, SWT.RADIO);
@@ -140,11 +136,10 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
layouter.perform(label, group, 1);
if (!info.getParameters().isEmpty()) {
- Mode mode = info.getMandatoryReturnVariable() != null ?
- Mode.EXTRACT_METHOD_FIXED_RETURN : Mode.EXTRACT_METHOD;
+ Mode mode = info.getMandatoryReturnVariable() != null ? Mode.EXTRACT_METHOD_FIXED_RETURN
+ : Mode.EXTRACT_METHOD;
ChangeParametersControl paramControl = new ChangeParametersControl(result, SWT.NONE,
- Messages.ExtractFunctionInputPage_parameters,
- new IParameterListChangeListener() {
+ Messages.ExtractFunctionInputPage_parameters, new IParameterListChangeListener() {
@Override
public void parameterChanged(NameInformation parameter) {
parameterModified();
@@ -159,9 +154,7 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
public void parameterAdded(NameInformation parameter) {
updatePreview(getText());
}
- },
- mode,
- new StubTypeContext(refactoring.getTranslationUnit()));
+ }, mode, new StubTypeContext(refactoring.getTranslationUnit()));
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
paramControl.setLayoutData(gd);
@@ -175,8 +168,7 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
} else if (duplicates == 1) {
checkBox.setText(Messages.ExtractFunctionInputPage_duplicates_single);
} else {
- checkBox.setText(NLS.bind(
- Messages.ExtractFunctionInputPage_duplicates_multi, Integer.valueOf(duplicates)));
+ checkBox.setText(NLS.bind(Messages.ExtractFunctionInputPage_duplicates_multi, Integer.valueOf(duplicates)));
}
checkBox.setSelection(info.isReplaceDuplicates());
checkBox.setEnabled(duplicates > 0);
@@ -195,8 +187,7 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
createSignaturePreview(result, layouter);
Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
- ICHelpContextIds.EXTRACT_FUNCTION_WIZARD_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.EXTRACT_FUNCTION_WIZARD_PAGE);
}
private Text createTextInputField(Composite parent, int style) {
@@ -217,7 +208,7 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
return textField.getText();
}
- private String getLabelText(){
+ private String getLabelText() {
return Messages.ExtractFunctionInputPage_label_text;
}
@@ -232,8 +223,10 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
layouter.perform(previewLabel);
IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
- signaturePreview = new CSourceViewer(composite, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store);
- signaturePreview.configure(new CSourceViewerConfiguration(CUIPlugin.getDefault().getTextTools().getColorManager(), store, null, null));
+ signaturePreview = new CSourceViewer(composite, null, null, false,
+ SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store);
+ signaturePreview.configure(new CSourceViewerConfiguration(
+ CUIPlugin.getDefault().getTextTools().getColorManager(), store, null, null));
signaturePreview.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
signaturePreview.adaptBackgroundColor(composite);
signaturePreview.setDocument(signaturePreviewDocument);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java
index dbf2defc75f..3d3b12116d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java
@@ -132,8 +132,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
import org.eclipse.cdt.internal.ui.viewsupport.BasicElementLabels;
public class ExtractFunctionRefactoring extends CRefactoring {
- public static final String ID =
- "org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"; //$NON-NLS-1$
+ public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"; //$NON-NLS-1$
private static final String[] EMPTY_STRING_ARRAY = {};
static final Integer NULL_INTEGER = Integer.valueOf(0);
@@ -204,7 +203,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
if (initStatus.hasFatalError())
return initStatus;
- extractor = FunctionExtractor.createFor(container.getNodesToWrite());
+ extractor = FunctionExtractor.createFor(container.getNodesToWrite());
if (extractor.canChooseReturnValue() && info.getMandatoryReturnVariable() == null) {
chooseReturnVariable();
@@ -220,8 +219,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
info.setExtractExpression(isExtractExpression);
info.setDeclarator(getDeclaration(container.getNodesToWrite().get(0)));
- MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0),
- refactoringContext, sm.newChild(1));
+ MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0), refactoringContext,
+ sm.newChild(1));
if (context.getType() == ContextType.METHOD && context.getMethodDeclarationName() == null) {
initStatus.addFatalError(Messages.ExtractFunctionRefactoring_no_declaration_of_surrounding_method);
return initStatus;
@@ -246,8 +245,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
return;
}
}
- if (candidate == null &&
- !TypeHelper.shouldBePassedByReference(type, declarator.getTranslationUnit())) {
+ if (candidate == null && !TypeHelper.shouldBePassedByReference(type, declarator.getTranslationUnit())) {
candidate = param;
}
}
@@ -302,8 +300,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
if (context.getType() == ContextType.METHOD && !context.isInline()) {
IASTDeclaration contextDeclaration = context.getMethodDeclaration();
- ICPPASTCompositeTypeSpecifier classDeclaration =
- (ICPPASTCompositeTypeSpecifier) contextDeclaration.getParent();
+ ICPPASTCompositeTypeSpecifier classDeclaration = (ICPPASTCompositeTypeSpecifier) contextDeclaration
+ .getParent();
IASTSimpleDeclaration methodDeclaration = getDeclaration(methodName);
if (isMethodAllreadyDefined(methodDeclaration, classDeclaration, getIndex())) {
@@ -330,8 +328,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
createMethodCalls(methodName, context, collector);
}
- private void createMethodCalls(IASTName methodName, MethodContext context,
- ModificationCollector collector) throws CoreException {
+ private void createMethodCalls(IASTName methodName, MethodContext context, ModificationCollector collector)
+ throws CoreException {
String title;
if (context.getType() == MethodContext.ContextType.METHOD) {
title = Messages.ExtractFunctionRefactoring_CreateMethodCall;
@@ -342,12 +340,11 @@ public class ExtractFunctionRefactoring extends CRefactoring {
IASTNode methodCall = getMethodCall(methodName);
IASTNode firstNodeToWrite = container.getNodesToWrite().get(0);
- ASTRewrite rewriter = collector.rewriterForTranslationUnit(
- firstNodeToWrite.getTranslationUnit());
+ ASTRewrite rewriter = collector.rewriterForTranslationUnit(firstNodeToWrite.getTranslationUnit());
TextEditGroup editGroup = new TextEditGroup(title);
if (methodCall instanceof IASTDeclaration) {
- CPPASTDeclarationStatement declarationStatement =
- new CPPASTDeclarationStatement((IASTDeclaration) methodCall);
+ CPPASTDeclarationStatement declarationStatement = new CPPASTDeclarationStatement(
+ (IASTDeclaration) methodCall);
methodCall = declarationStatement;
}
insertCallIntoTree(methodCall, container.getNodesToWrite(), rewriter, editGroup);
@@ -366,8 +363,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private void insertCallIntoTree(IASTNode methodCall, List<IASTNode> list, ASTRewrite rewriter,
TextEditGroup editGroup) {
IASTNode firstNode = list.get(0);
- if (list.size() > 1 && firstNode.getParent() instanceof IASTBinaryExpression &&
- firstNode.getParent().getParent() instanceof IASTBinaryExpression) {
+ if (list.size() > 1 && firstNode.getParent() instanceof IASTBinaryExpression
+ && firstNode.getParent().getParent() instanceof IASTBinaryExpression) {
IASTBinaryExpression parent = (IASTBinaryExpression) firstNode.getParent();
IASTExpression leftSubTree = parent.getOperand1();
int op = parent.getOperator();
@@ -384,17 +381,17 @@ public class ExtractFunctionRefactoring extends CRefactoring {
}
private IASTBinaryExpression getRootBinExp(IASTBinaryExpression binExp, List<IASTNode> nodeList) {
- while (binExp.getParent() instanceof IASTBinaryExpression &&
- nodeList.contains(((IASTBinaryExpression) binExp.getParent()).getOperand2())) {
+ while (binExp.getParent() instanceof IASTBinaryExpression
+ && nodeList.contains(((IASTBinaryExpression) binExp.getParent()).getOperand2())) {
binExp = (IASTBinaryExpression) binExp.getParent();
}
return binExp;
}
- private void createMethodDefinition(final IASTName methodName, MethodContext context,
- IASTNode firstExtractedNode, ModificationCollector collector) {
- IASTFunctionDefinition functionToExtractFrom =
- ASTQueries.findAncestorWithType(firstExtractedNode, IASTFunctionDefinition.class);
+ private void createMethodDefinition(final IASTName methodName, MethodContext context, IASTNode firstExtractedNode,
+ ModificationCollector collector) {
+ IASTFunctionDefinition functionToExtractFrom = ASTQueries.findAncestorWithType(firstExtractedNode,
+ IASTFunctionDefinition.class);
if (functionToExtractFrom != null) {
String title;
if (context.getType() == MethodContext.ContextType.METHOD) {
@@ -410,13 +407,13 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private void createMethodDeclaration(final IASTName astMethodName, MethodContext context,
ModificationCollector collector) {
- ICPPASTCompositeTypeSpecifier classDeclaration =
- (ICPPASTCompositeTypeSpecifier) context.getMethodDeclaration().getParent();
+ ICPPASTCompositeTypeSpecifier classDeclaration = (ICPPASTCompositeTypeSpecifier) context.getMethodDeclaration()
+ .getParent();
IASTSimpleDeclaration methodDeclaration = getDeclaration(collector, astMethodName);
- ASTRewrite rewrite = ClassMemberInserter.createChange(classDeclaration, info.getVisibility(),
- methodDeclaration, false, collector);
+ ASTRewrite rewrite = ClassMemberInserter.createChange(classDeclaration, info.getVisibility(), methodDeclaration,
+ false, collector);
// Names of external bindings may have to be qualified to be used in a header file.
if (classDeclaration.getTranslationUnit().isHeaderUnit())
@@ -535,9 +532,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
trail.add(node);
return PROCESS_SKIP;
} else if (node instanceof IASTName) {
- if (node instanceof ICPPASTConversionName &&
- node instanceof ICPPASTOperatorName &&
- node instanceof ICPPASTTemplateId) {
+ if (node instanceof ICPPASTConversionName && node instanceof ICPPASTOperatorName
+ && node instanceof ICPPASTTemplateId) {
trail.add(node);
return super.visitAll(node);
} else {
@@ -554,9 +550,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
}
trailName.setNameNumber(actCount);
- if (info.getReturnVariable() != null &&
- info.getReturnVariable().getName().getRawSignature().equals(
- name.getRawSignature())) {
+ if (info.getReturnVariable() != null && info.getReturnVariable().getName().getRawSignature()
+ .equals(name.getRawSignature())) {
returnNumber = actCount;
}
@@ -576,8 +571,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
boolean isStatementInTrail(final IASTStatement stmt, final List<IASTNode> trail) {
final boolean same[] = { true };
- final TrailNodeEqualityChecker equalityChecker =
- new TrailNodeEqualityChecker(names, namesCounter, index);
+ final TrailNodeEqualityChecker equalityChecker = new TrailNodeEqualityChecker(names, namesCounter, index);
stmt.accept(new CPPASTAllVisitor() {
@Override
@@ -615,12 +609,11 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private boolean isMethodAllreadyDefined(IASTSimpleDeclaration methodDeclaration,
ICPPASTCompositeTypeSpecifier classDeclaration, IIndex index) {
- TrailNodeEqualityChecker equalityChecker =
- new TrailNodeEqualityChecker(names, namesCounter, index);
+ TrailNodeEqualityChecker equalityChecker = new TrailNodeEqualityChecker(names, namesCounter, index);
IBinding bind = classDeclaration.getName().resolveBinding();
- IASTStandardFunctionDeclarator declarator =
- (IASTStandardFunctionDeclarator) methodDeclaration.getDeclarators()[0];
+ IASTStandardFunctionDeclarator declarator = (IASTStandardFunctionDeclarator) methodDeclaration
+ .getDeclarators()[0];
String name = new String(declarator.getName().toCharArray());
if (bind instanceof ICPPClassType) {
ICPPClassType classBind = (ICPPClassType) bind;
@@ -637,16 +630,15 @@ public class ExtractFunctionRefactoring extends CRefactoring {
if (parameters.length == declarator.getParameters().length) {
for (int i = 0; i < parameters.length; i++) {
IASTName[] origParameterName = ast.getDeclarationsInAST(parameters[i]);
- IASTParameterDeclaration origParameter =
- (IASTParameterDeclaration) origParameterName[0].getParent().getParent();
+ IASTParameterDeclaration origParameter = (IASTParameterDeclaration) origParameterName[0]
+ .getParent().getParent();
IASTParameterDeclaration newParameter = declarator.getParameters()[i];
// If not the same break;
if (!(equalityChecker.isEqual(origParameter.getDeclSpecifier(),
- newParameter.getDeclSpecifier()) &&
- ASTHelper.samePointers(origParameter.getDeclarator().getPointerOperators(),
- newParameter.getDeclarator().getPointerOperators(),
- equalityChecker))) {
+ newParameter.getDeclSpecifier())
+ && ASTHelper.samePointers(origParameter.getDeclarator().getPointerOperators(),
+ newParameter.getDeclarator().getPointerOperators(), equalityChecker))) {
break;
}
@@ -680,10 +672,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
IASTDeclSpecifier returnType = getReturnType(pointerOperators);
func.setDeclSpecifier(returnType);
- IASTStandardFunctionDeclarator declarator =
- extractor.createFunctionDeclarator(qname,
- info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
- info.getParameters(), nodeFactory);
+ IASTStandardFunctionDeclarator declarator = extractor.createFunctionDeclarator(qname, info.getDeclarator(),
+ info.getReturnVariable(), container.getNodesToWrite(), info.getParameters(), nodeFactory);
for (IASTPointerOperator operator : pointerOperators) {
declarator.addPointerOperator(operator);
}
@@ -718,23 +708,22 @@ public class ExtractFunctionRefactoring extends CRefactoring {
} else {
// Inserting into a translation unit or a namespace.
// TODO(sprigogin): Use insertBeforeNode instead of functionToExtractFrom when creating InsertionInfo
-// IASTNode insertBeforeNode = info.getMethodContext().getType() == ContextType.METHOD ?
-// null : functionToExtractFrom;
+ // IASTNode insertBeforeNode = info.getMethodContext().getType() == ContextType.METHOD ?
+ // null : functionToExtractFrom;
insertion = new InsertionInfo(parent, functionToExtractFrom);
}
if (insertion.getPrologue() != null) {
- rewrite.insertBefore(insertion.getParentNode(), insertion.getInsertBeforeNode(),
- insertion.getPrologue(), group);
+ rewrite.insertBefore(insertion.getParentNode(), insertion.getInsertBeforeNode(), insertion.getPrologue(),
+ group);
}
- subRewrite = rewrite.insertBefore(insertion.getParentNode(),
- insertion.getInsertBeforeNode(), nodeToInsert, group);
+ subRewrite = rewrite.insertBefore(insertion.getParentNode(), insertion.getInsertBeforeNode(), nodeToInsert,
+ group);
if (insertion.getEpilogue() != null) {
- rewrite.insertBefore(insertion.getParentNode(),
- insertion.getInsertBeforeNode(), insertion.getEpilogue(), group);
+ rewrite.insertBefore(insertion.getParentNode(), insertion.getInsertBeforeNode(), insertion.getEpilogue(),
+ group);
}
- extractor.constructMethodBody(compound, container.getNodesToWrite(),
- info.getParameters(), subRewrite, group);
+ extractor.constructMethodBody(compound, container.getNodesToWrite(), info.getParameters(), subRewrite, group);
// Set return value
NameInformation returnVariable = info.getReturnVariable();
@@ -762,8 +751,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
}
protected IASTNode getMethodCall(IASTName astMethodName, Map<String, Integer> trailNameTable,
- Map<String, Integer> similarNameTable, NodeContainer myContainer,
- NodeContainer mySimilarContainer) {
+ Map<String, Integer> similarNameTable, NodeContainer myContainer, NodeContainer mySimilarContainer) {
IASTExpressionStatement stmt = new CPPASTExpressionStatement();
IASTFunctionCallExpression callExpression = new CPPASTFunctionCallExpression();
IASTIdExpression idExpression = new CPPASTIdExpression();
@@ -781,7 +769,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
for (Entry<String, Integer> entry : similarNameTable.entrySet()) {
if (entry.getValue().equals(trailSeqNumber)) {
origName = entry.getKey();
- if (info.getReturnVariable() != null && trailSeqNumber.intValue() == returnNumber) {
+ if (info.getReturnVariable() != null && trailSeqNumber.intValue() == returnNumber) {
theRetName = true;
}
}
@@ -799,8 +787,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
if (theRetName) {
theRetName = false;
- retName = new CPPASTName(
- simNameInfo.getDeclarationName().getRawSignature().toCharArray());
+ retName = new CPPASTName(simNameInfo.getDeclarationName().getRawSignature().toCharArray());
}
}
}
@@ -846,12 +833,11 @@ public class ExtractFunctionRefactoring extends CRefactoring {
return getReturnAssignment(statement, callExpression, retName);
}
- private IASTNode getReturnAssignment(IASTExpressionStatement stmt,
- IASTFunctionCallExpression callExpression, IASTName retname) {
+ private IASTNode getReturnAssignment(IASTExpressionStatement stmt, IASTFunctionCallExpression callExpression,
+ IASTName retname) {
if (info.getReturnVariable().equals(info.getMandatoryReturnVariable())) {
- IASTSimpleDeclaration orgDecl =
- ASTQueries.findAncestorWithType(info.getReturnVariable().getDeclarationName(),
- IASTSimpleDeclaration.class);
+ IASTSimpleDeclaration orgDecl = ASTQueries
+ .findAncestorWithType(info.getReturnVariable().getDeclarationName(), IASTSimpleDeclaration.class);
IASTSimpleDeclaration decl = new CPPASTSimpleDeclaration();
decl.setDeclSpecifier(orgDecl.getDeclSpecifier().copy(CopyStyle.withLocations));
@@ -889,10 +875,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private IASTSimpleDeclaration getDeclaration(IASTName name) {
IASTSimpleDeclaration simpleDecl = new CPPASTSimpleDeclaration();
- IASTStandardFunctionDeclarator declarator =
- extractor.createFunctionDeclarator(name,
- info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
- info.getParameters(), nodeFactory);
+ IASTStandardFunctionDeclarator declarator = extractor.createFunctionDeclarator(name, info.getDeclarator(),
+ info.getReturnVariable(), container.getNodesToWrite(), info.getParameters(), nodeFactory);
simpleDecl.addDeclarator(declarator);
return simpleDecl;
}
@@ -905,10 +889,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
((ICPPASTDeclSpecifier) declSpec).setVirtual(true);
}
simpleDecl.setParent(ast);
- IASTStandardFunctionDeclarator declarator =
- extractor.createFunctionDeclarator(name,
- info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
- info.getParameters(), nodeFactory);
+ IASTStandardFunctionDeclarator declarator = extractor.createFunctionDeclarator(name, info.getDeclarator(),
+ info.getReturnVariable(), container.getNodesToWrite(), info.getParameters(), nodeFactory);
for (IASTPointerOperator operator : pointerOperators) {
declarator.addPointerOperator(operator);
}
@@ -975,20 +957,17 @@ public class ExtractFunctionRefactoring extends CRefactoring {
@Override
protected RefactoringDescriptor getRefactoringDescriptor() {
Map<String, String> arguments = getArgumentMap();
- RefactoringDescriptor desc =
- new ExtractFunctionRefactoringDescriptor(project.getProject().getName(),
- "Extract Method Refactoring", "Create method " + info.getMethodName(), arguments); //$NON-NLS-1$//$NON-NLS-2$
+ RefactoringDescriptor desc = new ExtractFunctionRefactoringDescriptor(project.getProject().getName(),
+ "Extract Method Refactoring", "Create method " + info.getMethodName(), arguments); //$NON-NLS-1$//$NON-NLS-2$
return desc;
}
private Map<String, String> getArgumentMap() {
Map<String, String> arguments = new HashMap<String, String>();
arguments.put(CRefactoringDescriptor.FILE_NAME, tu.getLocationURI().toString());
- arguments.put(CRefactoringDescriptor.SELECTION,
- selectedRegion.getOffset() + "," + selectedRegion.getLength()); //$NON-NLS-1$
+ arguments.put(CRefactoringDescriptor.SELECTION, selectedRegion.getOffset() + "," + selectedRegion.getLength()); //$NON-NLS-1$
arguments.put(ExtractFunctionRefactoringDescriptor.NAME, info.getMethodName());
- arguments.put(ExtractFunctionRefactoringDescriptor.VISIBILITY,
- info.getVisibility().toString());
+ arguments.put(ExtractFunctionRefactoringDescriptor.VISIBILITY, info.getVisibility().toString());
arguments.put(ExtractFunctionRefactoringDescriptor.REPLACE_DUPLICATES,
Boolean.toString(info.isReplaceDuplicates()));
return arguments;
@@ -1012,7 +991,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
* @return validation status
*/
public RefactoringStatus checkParameterNames() {
- RefactoringStatus result= new RefactoringStatus();
+ RefactoringStatus result = new RefactoringStatus();
List<NameInformation> parameters = info.getParameters();
Set<String> usedNames = new HashSet<String>();
Set<IASTName> declarations = new HashSet<IASTName>();
@@ -1045,7 +1024,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
* @return validation status
*/
public RefactoringStatus checkParameterAndReturnTypes() {
- RefactoringStatus result= new RefactoringStatus();
+ RefactoringStatus result = new RefactoringStatus();
for (NameInformation parameter : info.getParameters()) {
String typeName = parameter.getTypeName();
if (typeName == null || typeName.isEmpty()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java
index 7920855b7f2..2b4658b946d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
@@ -26,8 +26,8 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
public class ExtractFunctionRefactoringContribution extends CRefactoringContribution {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
- public RefactoringDescriptor createDescriptor(String id, String project, String description,
- String comment, Map arguments, int flags) throws IllegalArgumentException {
+ public RefactoringDescriptor createDescriptor(String id, String project, String description, String comment,
+ Map arguments, int flags) throws IllegalArgumentException {
if (id.equals(ExtractFunctionRefactoring.ID)) {
return new ExtractFunctionRefactoringDescriptor(project, description, comment, arguments);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java
index a4da70ae3f8..8db271943cb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS)- initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -38,16 +38,16 @@ public class ExtractFunctionRefactoringDescriptor extends CRefactoringDescriptor
public ExtractFunctionRefactoringDescriptor(String project, String description, String comment,
Map<String, String> arguments) {
- super(ExtractFunctionRefactoring.ID, project, description, comment,
- RefactoringDescriptor.MULTI_CHANGE, arguments);
+ super(ExtractFunctionRefactoring.ID, project, description, comment, RefactoringDescriptor.MULTI_CHANGE,
+ arguments);
}
@Override
public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException {
ISelection selection = getSelection();
ICProject project = getCProject();
- ExtractFunctionRefactoring refactoring =
- new ExtractFunctionRefactoring(getTranslationUnit(), selection, project);
+ ExtractFunctionRefactoring refactoring = new ExtractFunctionRefactoring(getTranslationUnit(), selection,
+ project);
ExtractFunctionInformation info = refactoring.getRefactoringInfo();
info.setMethodName(arguments.get(NAME));
info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY)));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java
index faec89e85b7..3deb4d5eee9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -27,17 +27,16 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
/**
* @author Emanuel Graf
*/
-public class ExtractFunctionRefactoringRunner extends RefactoringRunner {
+public class ExtractFunctionRefactoringRunner extends RefactoringRunner {
- public ExtractFunctionRefactoringRunner(ICElement element, ISelection selection,
- IShellProvider shellProvider, ICProject cProject) {
+ public ExtractFunctionRefactoringRunner(ICElement element, ISelection selection, IShellProvider shellProvider,
+ ICProject cProject) {
super(element, selection, shellProvider, cProject);
}
@Override
public void run() {
- ExtractFunctionRefactoring refactoring =
- new ExtractFunctionRefactoring(element, selection, project);
+ ExtractFunctionRefactoring refactoring = new ExtractFunctionRefactoring(element, selection, project);
ExtractFunctionWizard wizard = new ExtractFunctionWizard(refactoring);
run(wizard, refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionWizard.java
index 20c03888fc2..c0d7792f758 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionWizard.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -31,4 +31,3 @@ public class ExtractFunctionWizard extends RefactoringWizard {
addPage(new ExtractFunctionInputPage());
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/FunctionExtractor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/FunctionExtractor.java
index c7ce41e6631..1903c1692f6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/FunctionExtractor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/FunctionExtractor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -48,14 +48,14 @@ import org.eclipse.cdt.internal.ui.refactoring.NameInformation.Indirection;
* @author Mirko Stocker
*/
public abstract class FunctionExtractor {
-
+
public static FunctionExtractor createFor(List<IASTNode> list) {
if (list.get(0) instanceof IASTExpression) {
return new ExpressionExtractor();
}
return new StatementExtractor();
}
-
+
public abstract boolean canChooseReturnValue();
public abstract void constructMethodBody(IASTCompoundStatement compound, List<IASTNode> nodes,
@@ -70,35 +70,34 @@ public abstract class FunctionExtractor {
* @param pointerOperators output parameter - pointer operators for the function declarator
* @return the declarator specifier of the function
*/
- public abstract IASTDeclSpecifier determineReturnType(IASTNode extractedNode,
- NameInformation returnVariable, List<IASTPointerOperator> pointerOperators);
+ public abstract IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation returnVariable,
+ List<IASTPointerOperator> pointerOperators);
public abstract IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt,
IASTExpression callExpression);
-
+
IASTStandardFunctionDeclarator createFunctionDeclarator(IASTName name,
IASTStandardFunctionDeclarator functionDeclarator, NameInformation returnVariable,
- List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames,
- INodeFactory nodeFactory) {
+ List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
-
- if (functionDeclarator instanceof ICPPASTFunctionDeclarator &&
- declarator instanceof ICPPASTFunctionDeclarator) {
+
+ if (functionDeclarator instanceof ICPPASTFunctionDeclarator
+ && declarator instanceof ICPPASTFunctionDeclarator) {
if (((ICPPASTFunctionDeclarator) functionDeclarator).isConst()) {
((ICPPASTFunctionDeclarator) declarator).setConst(true);
}
}
-
+
for (IASTParameterDeclaration param : getParameterDeclarations(allUsedNames, nodeFactory)) {
declarator.addParameterDeclaration(param);
}
-
+
return declarator;
}
-
- public List<IASTParameterDeclaration> getParameterDeclarations(
- Collection<NameInformation> parameterNames, INodeFactory nodeFactory) {
- List<IASTParameterDeclaration> result = new ArrayList<>(parameterNames.size());
+
+ public List<IASTParameterDeclaration> getParameterDeclarations(Collection<NameInformation> parameterNames,
+ INodeFactory nodeFactory) {
+ List<IASTParameterDeclaration> result = new ArrayList<>(parameterNames.size());
for (NameInformation param : parameterNames) {
result.add(param.getParameterDeclaration(nodeFactory));
}
@@ -108,7 +107,7 @@ public abstract class FunctionExtractor {
/**
* Adjusts parameter references under the given node to account for renamed parameters and
* parameters passed by pointer.
- *
+ *
* @param node the root node of the AST subtree to be adjusted
* @param changedParameters the map from references to changed parameters to parameters
* themselves
@@ -133,11 +132,11 @@ public abstract class FunctionExtractor {
if (param.isRenamed()) {
newName = nodeFactory.newName(param.getNewName().toCharArray());
}
- if (param.getIndirection() == Indirection.POINTER &&
- name.getPropertyInParent() == IASTIdExpression.ID_NAME) {
+ if (param.getIndirection() == Indirection.POINTER
+ && name.getPropertyInParent() == IASTIdExpression.ID_NAME) {
IASTIdExpression idExp = (IASTIdExpression) name.getParent();
- if (idExp.getPropertyInParent() == IASTFieldReference.FIELD_OWNER &&
- !((IASTFieldReference) idExp.getParent()).isPointerDereference()) {
+ if (idExp.getPropertyInParent() == IASTFieldReference.FIELD_OWNER
+ && !((IASTFieldReference) idExp.getParent()).isPointerDereference()) {
IASTFieldReference dotRef = (IASTFieldReference) idExp.getParent();
IASTFieldReference arrowRef = dotRef.copy(CopyStyle.withLocations);
arrowRef.setIsPointerDereference(true);
@@ -148,15 +147,15 @@ public abstract class FunctionExtractor {
rewrite.replace(dotRef, arrowRef, group);
} else {
IASTIdExpression newIdExp = idExp.copy(CopyStyle.withLocations);
- IASTUnaryExpression starExp =
- nodeFactory.newUnaryExpression(IASTUnaryExpression.op_star, newIdExp);
+ IASTUnaryExpression starExp = nodeFactory.newUnaryExpression(IASTUnaryExpression.op_star,
+ newIdExp);
if (newName != null) {
newIdExp.setName(newName);
}
rewrite.replace(idExp, starExp, group);
}
} else if (newName != null) {
- rewrite.replace(name, newName, group);
+ rewrite.replace(name, newName, group);
}
}
return super.visit(name);
@@ -168,8 +167,8 @@ public abstract class FunctionExtractor {
* Returns a map from references to parameters inside the body of the extracted function to
* the parameters themselves. The map includes only the parameters that are either renamed,
* or passed by pointer.
- *
- * @param parameters the function parameters.
+ *
+ * @param parameters the function parameters.
* @return a map from references to parameters to parameters themselves.
*/
protected static Map<IASTName, NameInformation> getChangedParameterReferences(List<NameInformation> parameters) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java
index 9afd61dd308..e16ef070dd0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtractableStatementFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtractableStatementFinder.java
index 2760220278f..b970fc8df5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtractableStatementFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtractableStatementFinder.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -31,7 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement;
class NonExtractableStatementFinder extends ASTVisitor {
private boolean containsContinueStmt;
private boolean containsBreakStmt;
-
+
{
shouldVisitStatements = true;
}
@@ -44,11 +44,9 @@ class NonExtractableStatementFinder extends ASTVisitor {
} else if (statement instanceof IASTBreakStatement) {
containsBreakStmt = true;
return ASTVisitor.PROCESS_SKIP;
- } else if (statement instanceof IASTForStatement ||
- statement instanceof ICPPASTRangeBasedForStatement ||
- statement instanceof IASTWhileStatement ||
- statement instanceof IASTDoStatement ||
- statement instanceof IASTSwitchStatement) {
+ } else if (statement instanceof IASTForStatement || statement instanceof ICPPASTRangeBasedForStatement
+ || statement instanceof IASTWhileStatement || statement instanceof IASTDoStatement
+ || statement instanceof IASTSwitchStatement) {
// Extracting a whole loop or switch statement is allowed.
return ASTVisitor.PROCESS_SKIP;
}
@@ -58,7 +56,7 @@ class NonExtractableStatementFinder extends ASTVisitor {
public boolean containsContinue() {
return containsContinueStmt;
}
-
+
public boolean containsBreak() {
return containsBreakStmt;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnStatementFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnStatementFinder.java
index ab3c7992c77..96d199e2243 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnStatementFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnStatementFinder.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
@@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
/**
* @author Emanuel Graf IFS
*/
-class ReturnStatementFinder extends ASTVisitor{
+class ReturnStatementFinder extends ASTVisitor {
private boolean containsReturnStmt;
{
@@ -36,7 +36,7 @@ class ReturnStatementFinder extends ASTVisitor{
}
return ASTVisitor.PROCESS_CONTINUE;
}
-
+
public boolean containsReturn() {
return containsReturnStmt;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java
index 06ad2efc24e..f63df0f3890 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -35,8 +35,8 @@ abstract class SimilarFinderVisitor extends ASTVisitor {
private final List<IASTNode> statements;
private int statementCount;
- SimilarFinderVisitor(ExtractFunctionRefactoring refactoring, NodeContainer extractedNodes,
- List<IASTNode> trail, List<IASTNode> statements) {
+ SimilarFinderVisitor(ExtractFunctionRefactoring refactoring, NodeContainer extractedNodes, List<IASTNode> trail,
+ List<IASTNode> statements) {
this.refactoring = refactoring;
this.extractedNodes = extractedNodes;
this.trail = trail;
@@ -49,7 +49,7 @@ abstract class SimilarFinderVisitor extends ASTVisitor {
public int visit(IASTStatement statement) {
if (!isInSelection(statement) && refactoring.isStatementInTrail(statement, trail)) {
stmtToReplace.add(statement);
- similarContainer.add(statement);
+ similarContainer.add(statement);
++statementCount;
if (statementCount == statements.size()) {
@@ -57,7 +57,8 @@ abstract class SimilarFinderVisitor extends ASTVisitor {
boolean similarOnReturnWays = true;
for (NameInformation nameInfo : similarContainer.getParameterCandidates()) {
if (refactoring.names.containsKey(nameInfo.getDeclarationName().getRawSignature())) {
- Integer nameOrderNumber = refactoring.names.get(nameInfo.getDeclarationName().getRawSignature());
+ Integer nameOrderNumber = refactoring.names
+ .get(nameInfo.getDeclarationName().getRawSignature());
if (refactoring.nameTrail.containsValue(nameOrderNumber)) {
String orgName = null;
boolean found = false;
@@ -69,8 +70,8 @@ abstract class SimilarFinderVisitor extends ASTVisitor {
}
if (orgName != null) {
for (NameInformation orgNameInfo : extractedNodes.getParameterCandidates()) {
- if (orgName.equals(orgNameInfo.getDeclarationName().getRawSignature()) &&
- (orgNameInfo.isOutput() || !nameInfo.isOutput())) {
+ if (orgName.equals(orgNameInfo.getDeclarationName().getRawSignature())
+ && (orgNameInfo.isOutput() || !nameInfo.isOutput())) {
found = true;
break;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarReplacerVisitor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarReplacerVisitor.java
index 0148ae536c5..fac5a121d5a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarReplacerVisitor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarReplacerVisitor.java
@@ -29,8 +29,8 @@ final class SimilarReplacerVisitor extends SimilarFinderVisitor {
private final ModificationCollector collector;
- SimilarReplacerVisitor(ExtractFunctionRefactoring refactoring, NodeContainer extractedNodes, ModificationCollector collector,
- List<IASTNode> trail, IASTName name, List<IASTNode> statements) {
+ SimilarReplacerVisitor(ExtractFunctionRefactoring refactoring, NodeContainer extractedNodes,
+ ModificationCollector collector, List<IASTNode> trail, IASTName name, List<IASTNode> statements) {
super(refactoring, extractedNodes, trail, statements);
this.name = name;
this.collector = collector;
@@ -38,10 +38,9 @@ final class SimilarReplacerVisitor extends SimilarFinderVisitor {
@Override
protected void foundSimilar() {
- IASTNode call = refactoring.getMethodCall(name, refactoring.nameTrail,
- refactoring.names, extractedNodes, similarContainer);
- ASTRewrite rewrite =
- collector.rewriterForTranslationUnit(stmtToReplace.get(0).getTranslationUnit());
+ IASTNode call = refactoring.getMethodCall(name, refactoring.nameTrail, refactoring.names, extractedNodes,
+ similarContainer);
+ ASTRewrite rewrite = collector.rewriterForTranslationUnit(stmtToReplace.get(0).getTranslationUnit());
TextEditGroup editGroup = new TextEditGroup(Messages.SimilarFinderVisitor_replaceDuplicateCode);
rewrite.replace(stmtToReplace.get(0), call, editGroup);
if (stmtToReplace.size() > 1) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/StatementExtractor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/StatementExtractor.java
index 2c582549288..9f755bf1fc0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/StatementExtractor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/StatementExtractor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -59,8 +59,8 @@ public class StatementExtractor extends FunctionExtractor {
}
@Override
- public IASTDeclSpecifier determineReturnType(IASTNode extractedNode,
- NameInformation returnVariable, List<IASTPointerOperator> pointerOperators) {
+ public IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation returnVariable,
+ List<IASTPointerOperator> pointerOperators) {
if (returnVariable != null) {
IASTName declarationName = returnVariable.getDeclarationName();
IASTDeclarator declarator = ASTHelper.getDeclaratorForNode(declarationName);
@@ -77,8 +77,7 @@ public class StatementExtractor extends FunctionExtractor {
}
@Override
- public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt,
- IASTExpression callExpression) {
+ public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression) {
stmt.setExpression(callExpression);
return stmt;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailName.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailName.java
index da98fa760f1..c306041e58e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailName.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailName.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
@@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
class TrailName extends ASTNode {
private int nameNumber;
private IASTName realName;
-
+
public TrailName(IASTName realName) {
super();
this.realName = realName;
@@ -51,7 +51,7 @@ class TrailName extends ASTNode {
return cppBind.isGloballyQualified();
}
} catch (DOMException e) {
- }
+ }
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java
index 13cbc59940a..a23db6f8a8f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java
@@ -76,8 +76,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
private final Container<Integer> namesCounter;
private final IIndex index;
- public TrailNodeEqualityChecker(Map<String, Integer> names, Container<Integer> namesCounter,
- IIndex index) {
+ public TrailNodeEqualityChecker(Map<String, Integer> names, Container<Integer> namesCounter, IIndex index) {
super();
this.names = names;
this.namesCounter = namesCounter;
@@ -120,7 +119,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
if (trailNode instanceof ICPPASTConversionName) {
return true;
} else if (trailNode instanceof ICPPASTOperatorName) {
- ICPPASTOperatorName trailName= (ICPPASTOperatorName) trailNode;
+ ICPPASTOperatorName trailName = (ICPPASTOperatorName) trailNode;
ICPPASTOperatorName name = (ICPPASTOperatorName) node;
return trailName.equals(name);
} else if (trailNode instanceof TrailName && node instanceof IASTName) {
@@ -140,43 +139,32 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
} else if (trailNode instanceof ICPPASTNamedTypeSpecifier) {
ICPPASTNamedTypeSpecifier trailDecl = (ICPPASTNamedTypeSpecifier) trailNode;
ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
- return isDeclSpecifierEqual(trailDecl, decl)
- && isSameNamedTypeSpecifierName(trailDecl, decl)
- && trailDecl.isConstexpr() == decl.isConstexpr()
- && trailDecl.isExplicit() == decl.isExplicit()
- && trailDecl.isFriend() == decl.isFriend()
- && trailDecl.isThreadLocal() == decl.isThreadLocal()
- && trailDecl.isTypename() == decl.isTypename()
- && trailDecl.isVirtual() == decl.isVirtual();
+ return isDeclSpecifierEqual(trailDecl, decl) && isSameNamedTypeSpecifierName(trailDecl, decl)
+ && trailDecl.isConstexpr() == decl.isConstexpr() && trailDecl.isExplicit() == decl.isExplicit()
+ && trailDecl.isFriend() == decl.isFriend() && trailDecl.isThreadLocal() == decl.isThreadLocal()
+ && trailDecl.isTypename() == decl.isTypename() && trailDecl.isVirtual() == decl.isVirtual();
} else if (trailNode instanceof IASTNamedTypeSpecifier) {
IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node;
- return isDeclSpecifierEqual(trailDecl, decl)
- && isSameNamedTypeSpecifierName(trailDecl, decl);
+ return isDeclSpecifierEqual(trailDecl, decl) && isSameNamedTypeSpecifierName(trailDecl, decl);
} else if (trailNode instanceof IASTElaboratedTypeSpecifier) {
IASTElaboratedTypeSpecifier trailDecl = (IASTElaboratedTypeSpecifier) trailNode;
IASTElaboratedTypeSpecifier decl = (IASTElaboratedTypeSpecifier) node;
- return isDeclSpecifierEqual(trailDecl, decl)
- && trailDecl.getKind() == decl.getKind();
+ return isDeclSpecifierEqual(trailDecl, decl) && trailDecl.getKind() == decl.getKind();
} else if (trailNode instanceof IASTCompositeTypeSpecifier) {
IASTCompositeTypeSpecifier trailDecl = (IASTCompositeTypeSpecifier) trailNode;
IASTCompositeTypeSpecifier decl = (IASTCompositeTypeSpecifier) node;
- return isDeclSpecifierEqual(trailDecl, decl)
- && trailDecl.getKey() == decl.getKey();
+ return isDeclSpecifierEqual(trailDecl, decl) && trailDecl.getKey() == decl.getKey();
} else if (trailNode instanceof ICPPASTDeclSpecifier) {
ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode;
ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node;
- return isDeclSpecifierEqual(trailDecl, decl)
- && trailDecl.isConstexpr() == decl.isConstexpr()
- && trailDecl.isExplicit() == decl.isExplicit()
- && trailDecl.isFriend() == decl.isFriend()
- && trailDecl.isThreadLocal() == decl.isThreadLocal()
- && trailDecl.isVirtual() == decl.isVirtual();
+ return isDeclSpecifierEqual(trailDecl, decl) && trailDecl.isConstexpr() == decl.isConstexpr()
+ && trailDecl.isExplicit() == decl.isExplicit() && trailDecl.isFriend() == decl.isFriend()
+ && trailDecl.isThreadLocal() == decl.isThreadLocal() && trailDecl.isVirtual() == decl.isVirtual();
} else if (trailNode instanceof ICASTDeclSpecifier) {
ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node;
- return isDeclSpecifierEqual(trailDecl, decl)
- && trailDecl.isRestrict() == decl.isRestrict();
+ return isDeclSpecifierEqual(trailDecl, decl) && trailDecl.isRestrict() == decl.isRestrict();
} else if (trailNode instanceof IASTDeclSpecifier) {
IASTDeclSpecifier trailDecl = (IASTDeclSpecifier) trailNode;
IASTDeclSpecifier decl = (IASTDeclSpecifier) node;
@@ -195,8 +183,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
} else if (trailNode instanceof ICPPASTFunctionDeclarator) {
ICPPASTFunctionDeclarator trailFunc = (ICPPASTFunctionDeclarator) trailNode;
ICPPASTFunctionDeclarator func = (ICPPASTFunctionDeclarator) node;
- return trailFunc.isConst() == func.isConst()
- && trailFunc.isPureVirtual() == func.isPureVirtual()
+ return trailFunc.isConst() == func.isConst() && trailFunc.isPureVirtual() == func.isPureVirtual()
&& trailFunc.isVolatile() == func.isVolatile();
} else {
//same type
@@ -239,8 +226,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
if (trailNode instanceof IASTPointer) {
IASTPointer trailGPointer = (IASTPointer) trailNode;
IASTPointer gPointer = (IASTPointer) node;
- return trailGPointer.isConst() == gPointer.isConst()
- && trailGPointer.isRestrict() == gPointer.isRestrict()
+ return trailGPointer.isConst() == gPointer.isConst() && trailGPointer.isRestrict() == gPointer.isRestrict()
&& trailGPointer.isVolatile() == gPointer.isVolatile();
} else {
//same type
@@ -279,11 +265,12 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
} else if (trailNode instanceof IASTLiteralExpression) {
IASTLiteralExpression trailLiteral = (IASTLiteralExpression) trailNode;
IASTLiteralExpression literal = (IASTLiteralExpression) node;
- return trailLiteral.getKind() == literal.getKind() && trailLiteral.getRawSignature().equals(literal.getRawSignature());
+ return trailLiteral.getKind() == literal.getKind()
+ && trailLiteral.getRawSignature().equals(literal.getRawSignature());
} else if (trailNode instanceof IASTUnaryExpression) {
IASTUnaryExpression trailExpr = (IASTUnaryExpression) trailNode;
IASTUnaryExpression expr = (IASTUnaryExpression) node;
- return trailExpr.getOperator() == expr.getOperator();
+ return trailExpr.getOperator() == expr.getOperator();
} else if (trailNode instanceof IASTTypeIdExpression) {
IASTTypeIdExpression trailIdExpr = (IASTTypeIdExpression) trailNode;
IASTTypeIdExpression idExpr = (IASTTypeIdExpression) node;
@@ -319,28 +306,25 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
private boolean isDeclSpecifierEqual(IASTDeclSpecifier trailDeclSpeci, IASTDeclSpecifier declSpeci) {
if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
- ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
- ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
- if (trailCppDecl.isConstexpr() != cppDecl.isConstexpr()
- || trailCppDecl.isExplicit() != cppDecl.isExplicit()
+ ICPPASTDeclSpecifier trailCppDecl = (ICPPASTDeclSpecifier) trailDeclSpeci;
+ ICPPASTDeclSpecifier cppDecl = (ICPPASTDeclSpecifier) declSpeci;
+ if (trailCppDecl.isConstexpr() != cppDecl.isConstexpr() || trailCppDecl.isExplicit() != cppDecl.isExplicit()
|| trailCppDecl.isFriend() != cppDecl.isFriend()
|| trailCppDecl.isThreadLocal() != cppDecl.isThreadLocal()
|| trailCppDecl.isVirtual() != cppDecl.isVirtual()) {
return false;
}
}
- return trailDeclSpeci.isConst() == declSpeci.isConst()
- && trailDeclSpeci.isInline() == declSpeci.isInline()
+ return trailDeclSpeci.isConst() == declSpeci.isConst() && trailDeclSpeci.isInline() == declSpeci.isInline()
&& trailDeclSpeci.isVolatile() == declSpeci.isVolatile()
&& trailDeclSpeci.isRestrict() == declSpeci.isRestrict()
&& trailDeclSpeci.getStorageClass() == declSpeci.getStorageClass();
}
- private boolean isSimpleDeclSpecifierEqual(IASTSimpleDeclSpecifier trailDeclSpeci, IASTSimpleDeclSpecifier declSpeci) {
- return isDeclSpecifierEqual(trailDeclSpeci, declSpeci)
- && trailDeclSpeci.isLong() == declSpeci.isLong()
- && trailDeclSpeci.isShort() == declSpeci.isShort()
- && trailDeclSpeci.isSigned() == declSpeci.isSigned()
+ private boolean isSimpleDeclSpecifierEqual(IASTSimpleDeclSpecifier trailDeclSpeci,
+ IASTSimpleDeclSpecifier declSpeci) {
+ return isDeclSpecifierEqual(trailDeclSpeci, declSpeci) && trailDeclSpeci.isLong() == declSpeci.isLong()
+ && trailDeclSpeci.isShort() == declSpeci.isShort() && trailDeclSpeci.isSigned() == declSpeci.isSigned()
&& trailDeclSpeci.isUnsigned() == declSpeci.isUnsigned()
&& trailDeclSpeci.getType() == declSpeci.getType()
&& trailDeclSpeci.isComplex() == declSpeci.isComplex()
@@ -396,7 +380,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
IType nType = getType(nameBind);
if (oType == null || nType == null)
return false;
-
+
if (oType.isSameType(nType))
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java
index a7a9c778206..e1adb624af0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java
@@ -88,8 +88,7 @@ import org.eclipse.cdt.internal.ui.util.NameComposer;
* @author Tom Ball
*/
public class ExtractLocalVariableRefactoring extends CRefactoring {
- public static final String ID =
- "org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocalVariableRefactoring"; //$NON-NLS-1$
+ public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocalVariableRefactoring"; //$NON-NLS-1$
private IASTExpression target;
private final VariableNameInformation info;
@@ -123,8 +122,8 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
boolean oneMarked = selectedRegion != null && isOneMarked(container.getNodesToWrite(), selectedRegion);
if (!oneMarked) {
- initStatus.addFatalError(target == null ?
- Messages.NoExpressionSelected : Messages.TooManyExpressionsSelected);
+ initStatus.addFatalError(
+ target == null ? Messages.NoExpressionSelected : Messages.TooManyExpressionsSelected);
return initStatus;
}
sm.worked(1);
@@ -183,8 +182,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
for (IASTNode node : selectedNodes) {
if (node instanceof IASTExpression) {
IASTExpression expression = (IASTExpression) node;
- if (expression.isPartOfTranslationUnitFile() &&
- isExpressionInSelection(expression, textSelection)) {
+ if (expression.isPartOfTranslationUnitFile() && isExpressionInSelection(expression, textSelection)) {
if (target == null) {
target = expression;
oneMarked = true;
@@ -219,8 +217,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
return false;
}
- private NodeContainer findAllExpressions(IProgressMonitor pm)
- throws OperationCanceledException, CoreException {
+ private NodeContainer findAllExpressions(IProgressMonitor pm) throws OperationCanceledException, CoreException {
final NodeContainer container = new NodeContainer();
IASTTranslationUnit ast = getAST(tu, pm);
@@ -263,8 +260,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
rewriter.insertBefore(declInsertPoint.getParent(), declInsertPoint, declaration, editGroup);
// Replace target with reference to temporary variable
- CPPASTIdExpression idExpression =
- new CPPASTIdExpression(new CPPASTName(variableName.toCharArray()));
+ CPPASTIdExpression idExpression = new CPPASTIdExpression(new CPPASTName(variableName.toCharArray()));
rewriter.replace(target, idExpression, editGroup);
}
@@ -288,8 +284,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
declSpec.setStorageClass(IASTDeclSpecifier.sc_unspecified);
simple.setDeclSpecifier(declSpec);
- IASTDeclarator decl = generator.createDeclaratorFromType(target.getExpressionType(),
- newName.toCharArray());
+ IASTDeclarator decl = generator.createDeclaratorFromType(target.getExpressionType(), newName.toCharArray());
IASTEqualsInitializer init = new CPPASTEqualsInitializer();
init.setInitializerClause(deblock(target.copy(CopyStyle.withLocations)));
@@ -305,7 +300,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
*/
private static IASTExpression deblock(IASTExpression expression) {
if (expression instanceof IASTUnaryExpression) {
- IASTUnaryExpression unary = (IASTUnaryExpression)expression;
+ IASTUnaryExpression unary = (IASTUnaryExpression) expression;
if (unary.getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
return deblock(unary.getOperand());
}
@@ -314,7 +309,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
}
public String guessTempName() {
- String[] proposals= guessTempNames();
+ String[] proposals = guessTempNames();
if (proposals.length == 0) {
return info.getName();
} else {
@@ -380,22 +375,22 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
IASTLiteralExpression literal = (IASTLiteralExpression) expression;
String name = null;
switch (literal.getKind()) {
- case IASTLiteralExpression.lk_char_constant:
- name = "c"; //$NON-NLS-1$
- break;
- case IASTLiteralExpression.lk_float_constant:
- name = "f"; //$NON-NLS-1$
- break;
- case IASTLiteralExpression.lk_integer_constant:
- name = "i"; //$NON-NLS-1$
- break;
- case IASTLiteralExpression.lk_string_literal:
- name = literal.toString();
- break;
- case IASTLiteralExpression.lk_false:
- case IASTLiteralExpression.lk_true:
- name = "b"; //$NON-NLS-1$
- break;
+ case IASTLiteralExpression.lk_char_constant:
+ name = "c"; //$NON-NLS-1$
+ break;
+ case IASTLiteralExpression.lk_float_constant:
+ name = "f"; //$NON-NLS-1$
+ break;
+ case IASTLiteralExpression.lk_integer_constant:
+ name = "i"; //$NON-NLS-1$
+ break;
+ case IASTLiteralExpression.lk_string_literal:
+ name = literal.toString();
+ break;
+ case IASTLiteralExpression.lk_false:
+ case IASTLiteralExpression.lk_true:
+ name = "b"; //$NON-NLS-1$
+ break;
}
if (name != null) {
addTempName(name);
@@ -407,18 +402,18 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
private void addTempName(String name) {
name = trimPrefixes(name);
- IPreferencesService preferences = Platform.getPreferencesService();
- int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION,
- PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE, null);
- String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER, "", null); //$NON-NLS-1$
- String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX, "", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", null); //$NON-NLS-1$
- NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
- name = composer.compose(name);
+ IPreferencesService preferences = Platform.getPreferencesService();
+ int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE, null);
+ String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX, "", null); //$NON-NLS-1$
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", null); //$NON-NLS-1$
+ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+ name = composer.compose(name);
if (name.length() > 0) {
if (nameAvailable(name, guessedTempNames, scope)) {
@@ -459,8 +454,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
if (start > 0) {
String nameWithoutPrefix = name.substring(start);
if (Character.isUpperCase(nameWithoutPrefix.charAt(0))) {
- nameWithoutPrefix = nameWithoutPrefix.substring(0, 1).toLowerCase()
- + nameWithoutPrefix.substring(1);
+ nameWithoutPrefix = nameWithoutPrefix.substring(0, 1).toLowerCase() + nameWithoutPrefix.substring(1);
}
if (!Character.isJavaIdentifierStart(nameWithoutPrefix.charAt(0))) {
@@ -487,7 +481,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
List<String> noNames = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
for (String used : usedNames) {
- String name = used + i; // such as "i2"
+ String name = used + i; // such as "i2"
if (nameAvailable(name, noNames, scope)) {
return name;
}
@@ -500,7 +494,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
protected RefactoringDescriptor getRefactoringDescriptor() {
Map<String, String> arguments = getArgumentMap();
RefactoringDescriptor desc = new ExtractLocalVariableRefactoringDescriptor(project.getProject().getName(),
- "Extract Local Variable Refactoring", "Extract " + target.getRawSignature(), arguments); //$NON-NLS-1$//$NON-NLS-2$
+ "Extract Local Variable Refactoring", "Extract " + target.getRawSignature(), arguments); //$NON-NLS-1$//$NON-NLS-2$
return desc;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java
index 5461800febf..66e1afbde0c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
@@ -26,8 +26,8 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
public class ExtractLocalVariableRefactoringContribution extends CRefactoringContribution {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
- public RefactoringDescriptor createDescriptor(String id, String project, String description,
- String comment, Map arguments, int flags) throws IllegalArgumentException {
+ public RefactoringDescriptor createDescriptor(String id, String project, String description, String comment,
+ Map arguments, int flags) throws IllegalArgumentException {
if (id.equals(ExtractLocalVariableRefactoring.ID)) {
return new ExtractLocalVariableRefactoringDescriptor(project, description, comment, arguments);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java
index 9bf111d9d56..bb76c899aaa 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS)- initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -31,20 +31,20 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescriptor;
* @author Emanuel Graf IFS
*/
public class ExtractLocalVariableRefactoringDescriptor extends CRefactoringDescriptor {
- static protected final String NAME = "name"; //$NON-NLS-1$
+ static protected final String NAME = "name"; //$NON-NLS-1$
- public ExtractLocalVariableRefactoringDescriptor(String project, String description,
- String comment, Map<String, String> arguments) {
- super(ExtractLocalVariableRefactoring.ID, project, description, comment,
- RefactoringDescriptor.MULTI_CHANGE, arguments);
+ public ExtractLocalVariableRefactoringDescriptor(String project, String description, String comment,
+ Map<String, String> arguments) {
+ super(ExtractLocalVariableRefactoring.ID, project, description, comment, RefactoringDescriptor.MULTI_CHANGE,
+ arguments);
}
@Override
public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException {
ISelection selection = getSelection();
ICProject proj = getCProject();
- ExtractLocalVariableRefactoring refactoring =
- new ExtractLocalVariableRefactoring(getTranslationUnit(), selection, proj);
+ ExtractLocalVariableRefactoring refactoring = new ExtractLocalVariableRefactoring(getTranslationUnit(),
+ selection, proj);
refactoring.getRefactoringInfo().setName(arguments.get(NAME));
return refactoring;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java
index 1d4631752ab..b1f49212580 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Tom Ball (Google) - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -26,20 +26,19 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
/**
* Extract Local Variable refactoring runner.
- *
+ *
* @author Tom Ball
*/
public class ExtractLocalVariableRefactoringRunner extends RefactoringRunner {
- public ExtractLocalVariableRefactoringRunner(ICElement element, ISelection selection,
- IShellProvider shellProvider, ICProject cProject) {
+ public ExtractLocalVariableRefactoringRunner(ICElement element, ISelection selection, IShellProvider shellProvider,
+ ICProject cProject) {
super(element, selection, shellProvider, cProject);
}
@Override
public void run() {
- ExtractLocalVariableRefactoring refactoring =
- new ExtractLocalVariableRefactoring(element, selection, project);
+ ExtractLocalVariableRefactoring refactoring = new ExtractLocalVariableRefactoring(element, selection, project);
ExtractLocalVariableWizard wizard = new ExtractLocalVariableWizard(refactoring);
run(wizard, refactoring, RefactoringSaveHelper.SAVE_NOTHING);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableWizard.java
index a14430ca8bc..3f0124be325 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableWizard.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Tom Ball (Google) - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -21,7 +21,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* The wizard page for Extract Local Variable refactoring, creates the UI page.
- *
+ *
* @author Tom Ball
*/
public class ExtractLocalVariableWizard extends RefactoringWizard {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/InputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/InputPage.java
index 7a56f5ef85d..bc647433220 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/InputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/InputPage.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Tom Ball (Google)
* Sergey Prigogin (Google)
@@ -34,7 +34,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult;
/**
* Input verification page for the ExtractLocalVariable refactoring, cloned
* from org.eclipse.cdt.internal.ui.refactoring.extractconstant.InputPage.
- *
+ *
* @author Tom Ball
*/
public class InputPage extends UserInputWizardPage {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.java
index 99c7bd09d83..6c1deabd93c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Google
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorDescriptor.java
index dbb8814ed61..51deb9c774a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorDescriptor.java
@@ -22,8 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
public class AccessorDescriptor implements Comparable<AccessorDescriptor> {
public enum AccessorKind {
- GETTER,
- SETTER;
+ GETTER, SETTER;
}
private static final Collator collator = Collator.getInstance();
@@ -42,10 +41,10 @@ public class AccessorDescriptor implements Comparable<AccessorDescriptor> {
this.accessorName = accessorName;
this.fieldName = fieldDescriptor.getFieldName();
if (accessorName != null) {
- this.accessorFactory = AccessorFactory.createFactory(kind, fieldName,
- fieldDescriptor.getFieldDeclarator(), accessorName);
+ this.accessorFactory = AccessorFactory.createFactory(kind, fieldName, fieldDescriptor.getFieldDeclarator(),
+ accessorName);
this.accessorDeclaration = accessorFactory.createDeclaration();
-
+
for (IASTFunctionDefinition currentDefinition : context.existingFunctionDefinitions) {
if (currentDefinition.getDeclarator().getName().toString().equals(accessorName)) {
existingAccessorDefinition = currentDefinition;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorFactory.java
index eab8ef304bf..57f25d8dcbe 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorFactory.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
* Marc-Andre Laperle (Ericsson)
@@ -58,15 +58,15 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind;
-public abstract class AccessorFactory {
+public abstract class AccessorFactory {
protected final IASTName fieldName;
protected final IASTDeclarator fieldDeclarator;
private final IASTDeclSpecifier declSpecifier;
protected final String accessorName;
protected boolean passByReference;
- public static AccessorFactory createFactory(AccessorKind kind, IASTName fieldName,
- IASTDeclarator declarator, String accessorName) {
+ public static AccessorFactory createFactory(AccessorKind kind, IASTName fieldName, IASTDeclarator declarator,
+ String accessorName) {
if (kind == AccessorKind.GETTER) {
return new GetterFactory(fieldName, declarator, accessorName);
} else {
@@ -78,8 +78,8 @@ public abstract class AccessorFactory {
this.fieldName = fieldName;
this.fieldDeclarator = fieldDeclarator;
this.accessorName = accessorName;
- IASTSimpleDeclaration declaration =
- ASTQueries.findAncestorWithType(fieldDeclarator, IASTSimpleDeclaration.class);
+ IASTSimpleDeclaration declaration = ASTQueries.findAncestorWithType(fieldDeclarator,
+ IASTSimpleDeclaration.class);
this.declSpecifier = declaration.getDeclSpecifier();
IType type = CPPVisitor.createType(declSpecifier);
passByReference = TypeHelper.shouldBePassedByReference(type, fieldDeclarator.getTranslationUnit());
@@ -92,7 +92,7 @@ public abstract class AccessorFactory {
/**
* Creates an accessor definition.
- *
+ *
* @param declaratorName name to use for the declarator
*/
public abstract IASTFunctionDefinition createDefinition(IASTName declaratorName);
@@ -121,7 +121,7 @@ public abstract class AccessorFactory {
@Override
public IASTFunctionDefinition createDefinition(IASTName declaratorName) {
IASTFunctionDefinition getter = new CPPASTFunctionDefinition();
-
+
getter.setDeclSpecifier(getParamOrReturnDeclSpecifier());
IASTDeclarator getterDeclarator = getGetterDeclarator(declaratorName);
// IASTFunctionDefinition expects the outermost IASTFunctionDeclarator in declarator hierarchy
@@ -148,7 +148,7 @@ public abstract class AccessorFactory {
private IASTDeclarator getGetterDeclarator(IASTName declaratorName) {
// Copy declarator hierarchy
IASTDeclarator topDeclarator = fieldDeclarator.copy(CopyStyle.withLocations);
-
+
if (topDeclarator instanceof IASTArrayDeclarator) {
boolean isCpp = topDeclarator instanceof ICPPASTArrayDeclarator;
IASTDeclarator decl = isCpp ? new CPPASTDeclarator() : new CASTDeclarator();
@@ -166,18 +166,18 @@ public abstract class AccessorFactory {
innermost = innermost.getNestedDeclarator();
}
- // Create a new innermost function declarator based on the field declarator
+ // Create a new innermost function declarator based on the field declarator
CPPASTFunctionDeclarator functionDeclarator = new CPPASTFunctionDeclarator();
functionDeclarator.setConst(true);
functionDeclarator.setName(declaratorName);
- for (IASTPointerOperator pointer : innermost.getPointerOperators()){
+ for (IASTPointerOperator pointer : innermost.getPointerOperators()) {
functionDeclarator.addPointerOperator(pointer.copy(CopyStyle.withLocations));
}
if (passByReference) {
functionDeclarator.addPointerOperator(new CPPASTReferenceOperator(false));
}
-
+
// Replace the innermost with functionDeclarator and return the whole declarator tree
if (innermost == topDeclarator) {
// No tree
@@ -206,7 +206,7 @@ public abstract class AccessorFactory {
@Override
public IASTFunctionDefinition createDefinition(IASTName declaratorName) {
IASTFunctionDefinition setter = new CPPASTFunctionDefinition();
- setter.setDeclSpecifier(getVoidDeclSpec());
+ setter.setDeclSpecifier(getVoidDeclSpec());
setter.setDeclarator(getSetterDeclarator(declaratorName));
setter.setBody(getSetterBody());
return setter;
@@ -224,7 +224,8 @@ public abstract class AccessorFactory {
CPPASTName parameterName = getSetterParameterName();
if (Arrays.equals(fieldName.getSimpleID(), parameterName.getSimpleID())) {
CPPASTFieldReference fieldRef = new CPPASTFieldReference();
- CPPASTLiteralExpression litExpr = new CPPASTLiteralExpression(ICPPASTLiteralExpression.lk_this, Keywords.cTHIS);
+ CPPASTLiteralExpression litExpr = new CPPASTLiteralExpression(ICPPASTLiteralExpression.lk_this,
+ Keywords.cTHIS);
fieldRef.setFieldOwner(litExpr);
fieldRef.setIsPointerDereference(true);
fieldRef.setFieldName(fieldName.copy(CopyStyle.withLocations));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FieldDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FieldDescriptor.java
index 53455cbd83c..ab26ba31564 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FieldDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FieldDescriptor.java
@@ -41,18 +41,18 @@ class FieldDescriptor {
private final AccessorDescriptor setter;
private final AccessorDescriptor[] childNodes;
private final GetterSetterContext context;
-
+
FieldDescriptor(IASTDeclarator field, GetterSetterContext context) {
this.fieldName = GetterSetterContext.getDeclaratorName(field);
this.fieldDeclarator = field;
this.context = context;
Set<String> namesToAvoid = getNamesToAvoid();
String name = GetterSetterNameGenerator.generateGetterName(fieldName, namesToAvoid);
- this.getter = new AccessorDescriptor(AccessorKind.GETTER, name, this);
+ this.getter = new AccessorDescriptor(AccessorKind.GETTER, name, this);
name = GetterSetterNameGenerator.generateSetterName(fieldName, namesToAvoid);
- if (!isAssignable(field))
- name = null;
- this.setter = new AccessorDescriptor(AccessorKind.SETTER, name, this);
+ if (!isAssignable(field))
+ name = null;
+ this.setter = new AccessorDescriptor(AccessorKind.SETTER, name, this);
List<AccessorDescriptor> children = new ArrayList<AccessorDescriptor>(2);
if (getter.canBeGenerated()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java
index 5349bb228b6..ecfc4aa330d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
@@ -44,7 +44,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl
private GetterSetterLabelProvider labelProvider;
public GenerateGettersAndSettersInputPage(GetterSetterContext context) {
- super(Messages.GenerateGettersAndSettersInputPage_Name);
+ super(Messages.GenerateGettersAndSettersInputPage_Name);
this.context = context;
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID);
// We are listening for changes in the Name Style preferences
@@ -55,13 +55,13 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl
public void createControl(Composite parent) {
setTitle(Messages.GenerateGettersAndSettersInputPage_Name);
setMessage(Messages.GenerateGettersAndSettersInputPage_Header);
-
+
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(2, false));
createTree(comp);
GridData gd = new GridData(GridData.FILL_BOTH);
variableSelectionView.getTree().setLayoutData(gd);
-
+
Composite buttonContainer = createButtonComposite(comp);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
@@ -81,7 +81,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl
}
});
- Link link= new Link(comp, SWT.WRAP);
+ Link link = new Link(comp, SWT.WRAP);
link.setText(Messages.GenerateGettersAndSettersInputPage_LinkDescription);
link.addSelectionListener(new SelectionAdapter() {
@Override
@@ -104,7 +104,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl
FillLayout layout = new FillLayout(SWT.VERTICAL);
layout.spacing = 4;
btComp.setLayout(layout);
-
+
Button selectAll = new Button(btComp, SWT.PUSH);
selectAll.setText(Messages.GenerateGettersAndSettersInputPage_SelectAll);
selectAll.addSelectionListener(new SelectionAdapter() {
@@ -117,10 +117,10 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl
updateSelectedFunctions();
}
});
-
+
Button deselectAll = new Button(btComp, SWT.PUSH);
deselectAll.setText(Messages.GenerateGettersAndSettersInputPage_DeselectAll);
- deselectAll.addSelectionListener(new SelectionAdapter(){
+ deselectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (Object treeItem : context.getElements(null)) {
@@ -129,28 +129,28 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl
updateSelectedFunctions();
}
});
-
+
Button selectGetter = new Button(btComp, SWT.PUSH);
selectGetter.setText(Messages.GenerateGettersAndSettersInputPage_SelectGetters);
- selectGetter.addSelectionListener(new SelectionAdapter(){
+ selectGetter.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectAccessors(AccessorKind.GETTER);
}
});
-
+
Button selectSetter = new Button(btComp, SWT.PUSH);
selectSetter.setText(Messages.GenerateGettersAndSettersInputPage_SelectSetters);
- selectSetter.addSelectionListener(new SelectionAdapter(){
+ selectSetter.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectAccessors(AccessorKind.SETTER);
}
});
-
+
return btComp;
}
-
+
private void selectAccessors(AccessorKind kind) {
for (Object treeItem : context.getElements(null)) {
if (treeItem instanceof FieldDescriptor) {
@@ -213,7 +213,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl
if (variableSelectionView.getTree().isDisposed()) {
return;
}
-
+
if (GetterSetterNameGenerator.getGenerateGetterSettersPreferenceKeys().contains(event.getKey())) {
context.recreateFieldDescriptors();
variableSelectionView.refresh();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java
index 51979caea9d..620c538dd9b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java
@@ -1,18 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
- * Marc-Andre Laperle - do not search for definition insert location twice.
+ * Marc-Andre Laperle - do not search for definition insert location twice.
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
@@ -87,20 +87,19 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
return ASTVisitor.PROCESS_ABORT;
}
}
-
+
return super.visit(declSpec);
}
}
private final GetterSetterContext context;
- private InsertLocation definitionInsertLocation;
-
- public GenerateGettersAndSettersRefactoring(ICElement element, ISelection selection,
- ICProject project) {
+ private InsertLocation definitionInsertLocation;
+
+ public GenerateGettersAndSettersRefactoring(ICElement element, ISelection selection, ICProject project) {
super(element, selection, project);
context = new GetterSetterContext();
}
-
+
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
@@ -112,22 +111,21 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
}
if (!initStatus.hasFatalError()) {
- initRefactoring(pm);
+ initRefactoring(pm);
if (context.existingFields.isEmpty()) {
initStatus.addFatalError(Messages.GenerateGettersAndSettersRefactoring_NoFields);
}
- }
+ }
return initStatus;
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext checkContext) throws CoreException, OperationCanceledException {
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext checkContext)
+ throws CoreException, OperationCanceledException {
RefactoringStatus status = new RefactoringStatus();
if (context.isDefinitionSeparate()) {
findDefinitionInsertLocation(pm);
- if (definitionInsertLocation == null ||
- definitionInsertLocation.getTranslationUnit() == null) {
+ if (definitionInsertLocation == null || definitionInsertLocation.getTranslationUnit() == null) {
status.addInfo(Messages.GenerateGettersAndSettersRefactoring_NoImplFile);
}
}
@@ -165,7 +163,7 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
initStatus.addFatalError(Messages.GenerateGettersAndSettersRefactoring_NoClassDefFound);
}
}
-
+
private IASTCompositeTypeSpecifier findCurrentCompositeTypeSpecifier(IASTTranslationUnit ast)
throws OperationCanceledException, CoreException {
final int start = selectedRegion.getOffset();
@@ -229,17 +227,19 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
throws CoreException, OperationCanceledException {
List<IASTNode> getterAndSetters = new ArrayList<IASTNode>();
List<IASTFunctionDefinition> definitions = new ArrayList<IASTFunctionDefinition>();
- ICPPASTCompositeTypeSpecifier classDefinition =
- ASTQueries.findAncestorWithType(context.existingFields.get(0), ICPPASTCompositeTypeSpecifier.class);
+ ICPPASTCompositeTypeSpecifier classDefinition = ASTQueries.findAncestorWithType(context.existingFields.get(0),
+ ICPPASTCompositeTypeSpecifier.class);
for (AccessorDescriptor accessor : context.selectedAccessors) {
IASTName accessorName = new CPPASTName(accessor.toString().toCharArray());
if (context.isDefinitionSeparate()) {
getterAndSetters.add(accessor.getAccessorDeclaration());
- IASTName declaratorName = NameHelper.createQualifiedNameFor(
- accessorName, classDefinition.getTranslationUnit().getOriginatingTranslationUnit(), classDefinition.getFileLocation().getNodeOffset(),
- definitionInsertLocation.getTranslationUnit(), definitionInsertLocation.getInsertPosition(), refactoringContext);
+ IASTName declaratorName = NameHelper.createQualifiedNameFor(accessorName,
+ classDefinition.getTranslationUnit().getOriginatingTranslationUnit(),
+ classDefinition.getFileLocation().getNodeOffset(),
+ definitionInsertLocation.getTranslationUnit(), definitionInsertLocation.getInsertPosition(),
+ refactoringContext);
IASTFunctionDefinition functionDefinition = accessor.getAccessorDefinition(declaratorName);
- // Standalone definitions in a header file have to be declared inline.
+ // Standalone definitions in a header file have to be declared inline.
if (definitionInsertLocation.getTranslationUnit().isHeaderUnit()) {
functionDefinition.getDeclSpecifier().setInline(true);
}
@@ -252,12 +252,11 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
addDefinition(collector, definitions, pm);
}
- ClassMemberInserter.createChange(classDefinition, VisibilityEnum.v_public,
- getterAndSetters, false, collector);
+ ClassMemberInserter.createChange(classDefinition, VisibilityEnum.v_public, getterAndSetters, false, collector);
}
- private void addDefinition(ModificationCollector collector, List<IASTFunctionDefinition> definitions, IProgressMonitor pm)
- throws CoreException {
+ private void addDefinition(ModificationCollector collector, List<IASTFunctionDefinition> definitions,
+ IProgressMonitor pm) throws CoreException {
findDefinitionInsertLocation(pm);
IASTNode parent = definitionInsertLocation.getParentOfNodeToInsertBefore();
IASTTranslationUnit ast = parent.getTranslationUnit();
@@ -273,22 +272,22 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
public GetterSetterContext getContext() {
return context;
}
-
+
private void findDefinitionInsertLocation(IProgressMonitor pm) throws CoreException {
if (definitionInsertLocation != null) {
return;
}
-
- IASTSimpleDeclaration decl =
- ASTQueries.findAncestorWithType(context.existingFields.get(0), IASTSimpleDeclaration.class);
+
+ IASTSimpleDeclaration decl = ASTQueries.findAncestorWithType(context.existingFields.get(0),
+ IASTSimpleDeclaration.class);
MethodDefinitionInsertLocationFinder locationFinder = new MethodDefinitionInsertLocationFinder();
- InsertLocation location = locationFinder.find(tu, decl.getFileLocation(), decl.getParent(),
- refactoringContext, pm);
+ InsertLocation location = locationFinder.find(tu, decl.getFileLocation(), decl.getParent(), refactoringContext,
+ pm);
if (location.getFile() == null || NodeHelper.isContainedInTemplateDeclaration(decl)) {
location.setNodeToInsertAfter(NodeHelper.findTopLevelParent(decl), tu);
}
-
+
definitionInsertLocation = location;
}
@@ -296,5 +295,5 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
protected RefactoringDescriptor getRefactoringDescriptor() {
// TODO egraf Add descriptor
return null;
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java
index a8628a730ef..ea141361bf1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -41,10 +41,9 @@ public class GenerateGettersAndSettersRefactoringRunner extends RefactoringRunne
@Override
public void run() {
if (getActiveEditor() instanceof ITextEditor) {
- GenerateGettersAndSettersRefactoring refactoring =
- new GenerateGettersAndSettersRefactoring(element, selection, project);
- RefactoringWizard wizard =
- new GenerateGettersAndSettersWizard(refactoring);
+ GenerateGettersAndSettersRefactoring refactoring = new GenerateGettersAndSettersRefactoring(element,
+ selection, project);
+ RefactoringWizard wizard = new GenerateGettersAndSettersWizard(refactoring);
run(wizard, refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java
index b2282750d93..0d202132ca3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
@@ -21,8 +21,7 @@ import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
* @author Thomas Corbat
*/
public class GenerateGettersAndSettersWizard extends RefactoringWizard {
- public GenerateGettersAndSettersWizard(
- GenerateGettersAndSettersRefactoring refactoring) {
+ public GenerateGettersAndSettersWizard(GenerateGettersAndSettersRefactoring refactoring) {
super(refactoring, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
setDefaultPageTitle(Messages.GenerateGettersAndSettersInputPage_Name);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java
index 2fa14e20ea7..ce846390bc5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -65,7 +65,7 @@ public class GetterSetterContext implements ITreeContentProvider {
public Object[] getElements(Object inputElement) {
return getFieldDescriptors().toArray();
}
-
+
@Override
public void dispose() {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java
index e80c7e2e16c..acf98a3f356 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java
index bd099805770..e7d0445e38f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java
@@ -49,14 +49,14 @@ public class GetterSetterNameGenerator {
// Do not instantiate.
private GetterSetterNameGenerator() {
}
-
+
public static Set<String> getGenerateGetterSettersPreferenceKeys() {
return generateGetterSettersPreferenceKeys;
}
/**
* Generates getter name for a given field name.
- *
+ *
* @param fieldName the name of the field
* @param namesToAvoid the set of names to avoid
* @return the generated getter name, or <code>null</code> if a valid name could not be
@@ -67,7 +67,7 @@ public class GetterSetterNameGenerator {
return StubUtility.suggestGetterName(StubUtility.trimFieldName(fieldName.toString()),
isBooleanDeclaratorName(fieldName), namesToAvoid, tu);
}
-
+
private static boolean isBooleanDeclaratorName(IASTName name) {
if (IASTDeclarator.DECLARATOR_NAME.equals(name.getPropertyInParent())) {
IASTDeclarator declarator = (IASTDeclarator) name.getParent();
@@ -82,7 +82,7 @@ public class GetterSetterNameGenerator {
/**
* Generates setter name for a given field name.
- *
+ *
* @param fieldName the name of the field
* @param namesToAvoid the set of names to avoid
* @return the generated setter name, or <code>null</code> if a valid name could not be
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java
index 09e0a3ce224..97223dcfb1c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java
index f954b5c8f7f..808ec1382bc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -85,49 +85,51 @@ public class HideMethodRefactoring extends CRefactoring {
super(element, selection, project);
name = Messages.HideMethodRefactoring_HIDE_METHOD;
}
-
+
@Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
SubMonitor sm = SubMonitor.convert(pm, 10);
try {
super.checkInitialConditions(sm.newChild(8));
-
+
if (initStatus.hasFatalError()) {
return initStatus;
}
-
+
if (isProgressMonitorCanceled(sm, initStatus))
return initStatus;
-
+
List<IASTName> names = findAllMarkedNames();
if (names.isEmpty()) {
- initStatus.addFatalError(Messages.HideMethodRefactoring_NoNameSelected);
+ initStatus.addFatalError(Messages.HideMethodRefactoring_NoNameSelected);
return initStatus;
}
IASTName name = names.get(names.size() - 1);
methodName = DefinitionFinder.getMemberDeclaration(name, refactoringContext, sm.newChild(1));
if (methodName == null) {
- initStatus.addFatalError(Messages.HideMethodRefactoring_NoMethodNameSelected);
+ initStatus.addFatalError(Messages.HideMethodRefactoring_NoMethodNameSelected);
return initStatus;
}
IASTDeclarator decl = (IASTDeclarator) methodName.getParent();
decl = CPPVisitor.findOutermostDeclarator(decl);
methodDeclaration = (IASTDeclaration) decl.getParent();
- if (methodDeclaration == null ||
- !(methodDeclaration.getParent() instanceof ICPPASTCompositeTypeSpecifier)) {
- initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods);
+ if (methodDeclaration == null
+ || !(methodDeclaration.getParent() instanceof ICPPASTCompositeTypeSpecifier)) {
+ initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods);
return initStatus;
}
-
+
if (isProgressMonitorCanceled(sm, initStatus))
return initStatus;
if (methodDeclaration instanceof IASTFunctionDefinition) {
IASTDeclarator declarator = ((IASTFunctionDefinition) methodDeclaration).getDeclarator();
- if (ASTQueries.findInnermostDeclarator(declarator).getName().getRawSignature().equals(name.getRawSignature())) {
+ if (ASTQueries.findInnermostDeclarator(declarator).getName().getRawSignature()
+ .equals(name.getRawSignature())) {
if (!(declarator instanceof IASTFunctionDeclarator)) {
- initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods);
+ initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods);
return initStatus;
}
}
@@ -135,22 +137,22 @@ public class HideMethodRefactoring extends CRefactoring {
for (IASTDeclarator declarator : ((IASTSimpleDeclaration) methodDeclaration).getDeclarators()) {
if (declarator.getName().getRawSignature().equals(name.getRawSignature())) {
if (!(declarator instanceof IASTFunctionDeclarator)) {
- initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods);
+ initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods);
return initStatus;
}
}
- }
+ }
} else {
- initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods);
+ initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods);
return initStatus;
}
-
- IASTCompositeTypeSpecifier classNode =
- ASTQueries.findAncestorWithType(methodName, IASTCompositeTypeSpecifier.class);
+
+ IASTCompositeTypeSpecifier classNode = ASTQueries.findAncestorWithType(methodName,
+ IASTCompositeTypeSpecifier.class);
if (classNode == null) {
initStatus.addError(Messages.HideMethodRefactoring_EnclosingClassNotFound);
}
-
+
if (checkIfPrivate(classNode, methodDeclaration)) {
initStatus.addError(Messages.HideMethodRefactoring_IsAlreadyPrivate);
}
@@ -165,12 +167,12 @@ public class HideMethodRefactoring extends CRefactoring {
int currentVisibility = ICPPASTVisibilityLabel.v_private;
if (IASTCompositeTypeSpecifier.k_struct == classNode.getKey()) {
currentVisibility = ICPPASTVisibilityLabel.v_public;
- }
+ }
for (IASTDeclaration declaration : members) {
if (declaration instanceof ICPPASTVisibilityLabel) {
- currentVisibility =((ICPPASTVisibilityLabel) declaration).getVisibility();
+ currentVisibility = ((ICPPASTVisibilityLabel) declaration).getVisibility();
}
-
+
if (declaration != null) {
if (decl == declaration) {
break;
@@ -182,10 +184,10 @@ public class HideMethodRefactoring extends CRefactoring {
}
return false;
}
-
+
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext checkContext) throws CoreException, OperationCanceledException {
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext checkContext)
+ throws CoreException, OperationCanceledException {
SubMonitor sm = SubMonitor.convert(pm, 10);
try {
RefactoringStatus status = new RefactoringStatus();
@@ -203,8 +205,8 @@ public class HideMethodRefactoring extends CRefactoring {
}
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof ITranslationUnitEditorInput) {
- ITranslationUnit tu =
- CModelUtil.toWorkingCopy(((ITranslationUnitEditorInput) editorInput).getTranslationUnit());
+ ITranslationUnit tu = CModelUtil
+ .toWorkingCopy(((ITranslationUnitEditorInput) editorInput).getTranslationUnit());
searchedFiles.add(tu.getLocation().toOSString());
IASTTranslationUnit ast = getAST(tu, loopProgress.newChild(1));
for (IASTName reference : ast.getReferences(methodBinding)) {
@@ -215,7 +217,7 @@ public class HideMethodRefactoring extends CRefactoring {
}
}
}
-
+
IIndexName[] referencesFromIndex = index.findReferences(methodBinding);
int remainingCount = referencesFromIndex.length;
loopProgress = sm.newChild(6).setWorkRemaining(remainingCount);
@@ -223,8 +225,7 @@ public class HideMethodRefactoring extends CRefactoring {
if (sm.isCanceled()) {
throw new OperationCanceledException();
}
- ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(
- name.getFile().getLocation(), null);
+ ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(name.getFile().getLocation(), null);
if (searchedFiles.add(tu.getLocation().toOSString())) {
IASTTranslationUnit ast = getAST(tu, loopProgress.newChild(1));
for (IASTName reference : ast.getReferences(methodBinding)) {
@@ -237,7 +238,7 @@ public class HideMethodRefactoring extends CRefactoring {
}
loopProgress.setWorkRemaining(--remainingCount);
}
-
+
return status;
} finally {
sm.done();
@@ -245,12 +246,15 @@ public class HideMethodRefactoring extends CRefactoring {
}
@Override
- protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) throws CoreException, OperationCanceledException {
+ protected void collectModifications(IProgressMonitor pm, ModificationCollector collector)
+ throws CoreException, OperationCanceledException {
ASTRewrite rewriter = collector.rewriterForTranslationUnit(methodName.getTranslationUnit());
- TextEditGroup editGroup = new TextEditGroup(Messages.HideMethodRefactoring_FILE_CHANGE_TEXT+ methodName.getRawSignature());
+ TextEditGroup editGroup = new TextEditGroup(
+ Messages.HideMethodRefactoring_FILE_CHANGE_TEXT + methodName.getRawSignature());
ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) methodDeclaration.getParent();
- ClassMemberInserter.createChange(classDefinition, VisibilityEnum.v_private, methodDeclaration, false, collector);
+ ClassMemberInserter.createChange(classDefinition, VisibilityEnum.v_private, methodDeclaration, false,
+ collector);
rewriter.remove(methodDeclaration, editGroup);
}
@@ -266,7 +270,8 @@ public class HideMethodRefactoring extends CRefactoring {
@Override
public int visit(IASTName name) {
- if (name.isPartOfTranslationUnitFile() && SelectionHelper.doesNodeOverlapWithRegion(name, selectedRegion)) {
+ if (name.isPartOfTranslationUnitFile()
+ && SelectionHelper.doesNodeOverlapWithRegion(name, selectedRegion)) {
if (!(name instanceof ICPPASTQualifiedName)) {
namesVector.add(name);
}
@@ -280,7 +285,8 @@ public class HideMethodRefactoring extends CRefactoring {
@Override
protected RefactoringDescriptor getRefactoringDescriptor() {
Map<String, String> arguments = getArgumentMap();
- RefactoringDescriptor desc = new HideMethodRefactoringDescriptor( project.getProject().getName(), "Hide Method Refactoring", "Hide Method " + methodName.getRawSignature(), arguments); //$NON-NLS-1$//$NON-NLS-2$
+ RefactoringDescriptor desc = new HideMethodRefactoringDescriptor(project.getProject().getName(),
+ "Hide Method Refactoring", "Hide Method " + methodName.getRawSignature(), arguments); //$NON-NLS-1$//$NON-NLS-2$
return desc;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java
index 72fa0e592c6..0e4763106a0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
@@ -26,8 +26,8 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
public class HideMethodRefactoringContribution extends CRefactoringContribution {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
- public RefactoringDescriptor createDescriptor(String id, String project, String description,
- String comment, Map arguments, int flags) throws IllegalArgumentException {
+ public RefactoringDescriptor createDescriptor(String id, String project, String description, String comment,
+ Map arguments, int flags) throws IllegalArgumentException {
if (id.equals(HideMethodRefactoring.ID)) {
return new HideMethodRefactoringDescriptor(project, description, comment, arguments);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java
index 927b32880e1..828b8008488 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS)- initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
@@ -34,8 +34,8 @@ public class HideMethodRefactoringDescriptor extends CRefactoringDescriptor {
public HideMethodRefactoringDescriptor(String project, String description, String comment,
Map<String, String> arguments) {
- super(HideMethodRefactoring.ID, project, description, comment,
- RefactoringDescriptor.STRUCTURAL_CHANGE, arguments);
+ super(HideMethodRefactoring.ID, project, description, comment, RefactoringDescriptor.STRUCTURAL_CHANGE,
+ arguments);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java
index 754861977ce..19d90ef2a20 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -29,8 +29,8 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
*/
public class HideMethodRefactoringRunner extends RefactoringRunner {
- public HideMethodRefactoringRunner(ICElement element, ISelection selection,
- IShellProvider shellProvider, ICProject cProject) {
+ public HideMethodRefactoringRunner(ICElement element, ISelection selection, IShellProvider shellProvider,
+ ICProject cProject) {
super(element, selection, shellProvider, cProject);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodWizard.java
index 644ddc67fd8..04a90854bdc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodWizard.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.java
index d12ebcc43c9..f8d8ac78ef9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodData.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodData.java
index 74fdcb017e4..4c1b7d11f86 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodData.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodData.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
@@ -26,21 +26,20 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
* @author Emanuel Graf IFS
*
*/
-public class ImplementMethodData implements ITreeContentProvider{
+public class ImplementMethodData implements ITreeContentProvider {
public ImplementMethodData() {
}
-
private List<MethodToImplementConfig> methodDeclarations;
public void setMethodDeclarations(List<IASTSimpleDeclaration> methodDeclarations) {
this.methodDeclarations = new ArrayList<MethodToImplementConfig>();
-
+
for (IASTSimpleDeclaration declaration : methodDeclarations) {
this.methodDeclarations.add(new MethodToImplementConfig(declaration, new ParameterHandler(declaration)));
}
-
+
// Only one declaration available, might as well check it
if (this.methodDeclarations.size() == 1) {
this.methodDeclarations.get(0).setChecked(true);
@@ -79,47 +78,47 @@ public class ImplementMethodData implements ITreeContentProvider{
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
-
+
public List<MethodToImplementConfig> getMethodsToImplement() {
List<MethodToImplementConfig> ret = new ArrayList<MethodToImplementConfig>();
for (MethodToImplementConfig config : methodDeclarations) {
- if(config.isChecked()) {
+ if (config.isChecked()) {
ret.add(config);
}
}
return ret;
}
-
+
public boolean needParameterInput() {
for (MethodToImplementConfig config : getMethodsToImplement()) {
- if(config.getParaHandler().needsAdditionalArgumentNames())return true;
+ if (config.getParaHandler().needsAdditionalArgumentNames())
+ return true;
}
return false;
}
-
+
public MethodToImplementConfig getNextConfigNeedingParameterNames(MethodToImplementConfig currentConfig) {
int i = 0;
List<MethodToImplementConfig> methodsToImplement = getMethodsToImplement();
- for(;i < methodsToImplement.size();++i) {
- if(currentConfig == methodsToImplement.get(i)) {
+ for (; i < methodsToImplement.size(); ++i) {
+ if (currentConfig == methodsToImplement.get(i)) {
++i;
break;
}
}
-
- for(;i < methodsToImplement.size();++i) {
- if(methodsToImplement.get(i).getParaHandler().needsAdditionalArgumentNames()) {
+
+ for (; i < methodsToImplement.size(); ++i) {
+ if (methodsToImplement.get(i).getParaHandler().needsAdditionalArgumentNames()) {
return methodsToImplement.get(i);
}
}
return null;
}
-
public MethodToImplementConfig getFirstConfigNeedingParameterNames() {
List<MethodToImplementConfig> methodsToImplement = getMethodsToImplement();
for (MethodToImplementConfig config : methodsToImplement) {
- if(config.getParaHandler().needsAdditionalArgumentNames()) {
+ if (config.getParaHandler().needsAdditionalArgumentNames()) {
return config;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodInputPage.java
index 49c0116cf8b..749bcee1b6f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodInputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodInputPage.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
@@ -53,56 +53,56 @@ public class ImplementMethodInputPage extends UserInputWizardPage {
public void createControl(Composite parent) {
setTitle(Messages.ImplementMethodInputPage_PageTitle);
setMessage(Messages.ImplementMethodInputPage_Header);
-
- Composite comp = new Composite(parent, SWT.NONE );
+
+ Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(2, false));
createTree(comp);
createFieldManagementButtonsComposite(comp);
-
+
setControl(comp);
checkPage();
}
-
+
private Composite createFieldManagementButtonsComposite(Composite comp) {
Composite btComp = new Composite(comp, SWT.NONE);
FillLayout layout = new FillLayout(SWT.VERTICAL);
layout.spacing = 4;
btComp.setLayout(layout);
-
+
GridData gd = new GridData();
gd.verticalAlignment = SWT.TOP;
btComp.setLayoutData(gd);
-
+
final Button selectAll = new Button(btComp, SWT.PUSH);
selectAll.setText(Messages.ImplementMethodInputPage_SelectAll);
- selectAll.addSelectionListener(new SelectionAdapter(){
+ selectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] items = data.getElements(null);
for (Object treeItem : items) {
- MethodToImplementConfig method = (MethodToImplementConfig)treeItem;
+ MethodToImplementConfig method = (MethodToImplementConfig) treeItem;
method.setChecked(true);
tree.setChecked(treeItem, true);
}
checkPage();
}
});
-
+
final Button deselectAll = new Button(btComp, SWT.PUSH);
deselectAll.setText(Messages.ImplementMethodInputPage_DeselectAll);
- deselectAll.addSelectionListener(new SelectionAdapter(){
+ deselectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] items = data.getElements(null);
for (Object treeItem : items) {
- MethodToImplementConfig method = (MethodToImplementConfig)treeItem;
+ MethodToImplementConfig method = (MethodToImplementConfig) treeItem;
method.setChecked(false);
tree.setChecked(treeItem, false);
}
checkPage();
}
});
-
+
return btComp;
}
@@ -112,15 +112,16 @@ public class ImplementMethodInputPage extends UserInputWizardPage {
tree.setAutoExpandLevel(2);
tree.setInput(""); //$NON-NLS-1$
tree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
tree.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
- MethodToImplementConfig config = ((MethodToImplementConfig)event.getElement());
+ MethodToImplementConfig config = ((MethodToImplementConfig) event.getElement());
config.setChecked(event.getChecked());
checkPage();
- }});
-
+ }
+ });
+
for (MethodToImplementConfig config : data.getMethodsToImplement()) {
tree.setChecked(config, config.isChecked());
}
@@ -135,10 +136,10 @@ public class ImplementMethodInputPage extends UserInputWizardPage {
}
}
- @Override
+ @Override
public ImplementMethodWizard getWizard() {
- return (ImplementMethodWizard) super.getWizard();
- }
+ return (ImplementMethodWizard) super.getWizard();
+ }
public void setData(ImplementMethodData data) {
this.data = data;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
index 9441f67e4a8..a6974d6c53a 100755
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Marc-Andre Laperle
* Sergey Prigogin (Google)
@@ -73,7 +73,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
/**
* Main class of the ImplementMethodRefactoring (Source generator).
* Checks conditions, finds insert location and generates the ImplementationNode.
- *
+ *
* @author Mirko Stocker, Lukas Felber, Emanuel Graf
*/
public class ImplementMethodRefactoring extends CRefactoring {
@@ -82,14 +82,14 @@ public class ImplementMethodRefactoring extends CRefactoring {
private MethodDefinitionInsertLocationFinder methodDefinitionInsertLocationFinder;
private Map<IASTSimpleDeclaration, InsertLocation> insertLocations;
private static ICPPNodeFactory nodeFactory = ASTNodeFactoryFactory.getDefaultCPPNodeFactory();
-
+
public ImplementMethodRefactoring(ICElement element, ISelection selection, ICProject project) {
super(element, selection, project);
data = new ImplementMethodData();
methodDefinitionInsertLocationFinder = new MethodDefinitionInsertLocationFinder();
insertLocations = new HashMap<IASTSimpleDeclaration, InsertLocation>();
}
-
+
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
@@ -97,16 +97,15 @@ public class ImplementMethodRefactoring extends CRefactoring {
super.checkInitialConditions(sm.newChild(6));
if (!initStatus.hasFatalError()) {
- List<IASTSimpleDeclaration> unimplementedMethodDeclarations =
- findUnimplementedMethodDeclarations(pm);
+ List<IASTSimpleDeclaration> unimplementedMethodDeclarations = findUnimplementedMethodDeclarations(pm);
if (unimplementedMethodDeclarations.isEmpty()) {
initStatus.addFatalError(Messages.ImplementMethodRefactoring_NoMethodToImplement);
} else {
data.setMethodDeclarations(unimplementedMethodDeclarations);
if (selectedRegion.getLength() > 0) {
- IASTSimpleDeclaration methodDeclaration =
- SelectionHelper.findFirstSelectedDeclaration(selectedRegion, getAST(tu, pm));
+ IASTSimpleDeclaration methodDeclaration = SelectionHelper
+ .findFirstSelectedDeclaration(selectedRegion, getAST(tu, pm));
if (NodeHelper.isMethodDeclaration(methodDeclaration)) {
for (MethodToImplementConfig config : data.getMethodDeclarations()) {
if (config.getDeclaration() == methodDeclaration) {
@@ -140,7 +139,7 @@ public class ImplementMethodRefactoring extends CRefactoring {
IBinding binding = declarators[0].getName().resolveBinding();
if (isUnimplementedMethodBinding(binding, sm.newChild(0))) {
list.add(simpleDeclaration);
- return ASTVisitor.PROCESS_SKIP;
+ return ASTVisitor.PROCESS_SKIP;
}
}
}
@@ -158,14 +157,14 @@ public class ImplementMethodRefactoring extends CRefactoring {
return false; // Pure virtual not handled for now, see bug 303870
}
}
-
+
try {
return !DefinitionFinder.hasDefinition(binding, refactoringContext, pm);
} catch (CoreException e) {
CUIPlugin.log(e);
}
}
-
+
return false;
}
@@ -189,7 +188,7 @@ public class ImplementMethodRefactoring extends CRefactoring {
if (subMonitor.isCanceled()) {
throw new OperationCanceledException();
}
-
+
subMonitor.worked(1);
IASTNode parent = insertLocation.getParentOfNodeToInsertBefore();
IASTTranslationUnit ast = parent.getTranslationUnit();
@@ -202,14 +201,16 @@ public class ImplementMethodRefactoring extends CRefactoring {
IASTNode nodeToInsertBefore = insertLocation.getNodeToInsertBefore();
IASTNode createdMethodDefinition = createFunctionDefinition(ast, decl, insertLocation);
subMonitor.worked(1);
- ASTRewrite methodRewrite = translationUnitRewrite.insertBefore(parent, nodeToInsertBefore, createdMethodDefinition , null);
+ ASTRewrite methodRewrite = translationUnitRewrite.insertBefore(parent, nodeToInsertBefore,
+ createdMethodDefinition, null);
createParameterModifications(methodRewrite, config.getParaHandler());
subMonitor.done();
}
-
+
private void createParameterModifications(ASTRewrite methodRewrite, ParameterHandler handler) {
for (ParameterInfo actParameterInfo : handler.getParameterInfos()) {
- ASTRewrite parameterRewrite = methodRewrite.insertBefore(createdMethodDeclarator, null, actParameterInfo.getParameter(), null);
+ ASTRewrite parameterRewrite = methodRewrite.insertBefore(createdMethodDeclarator, null,
+ actParameterInfo.getParameter(), null);
createNewNameInsertModification(actParameterInfo, parameterRewrite);
createRemoveDefaultValueModification(actParameterInfo, parameterRewrite);
}
@@ -229,42 +230,45 @@ public class ImplementMethodRefactoring extends CRefactoring {
}
}
- private InsertLocation findInsertLocation(IASTSimpleDeclaration methodDeclaration, IProgressMonitor subMonitor) throws CoreException {
+ private InsertLocation findInsertLocation(IASTSimpleDeclaration methodDeclaration, IProgressMonitor subMonitor)
+ throws CoreException {
if (insertLocations.containsKey(methodDeclaration)) {
return insertLocations.get(methodDeclaration);
}
- InsertLocation insertLocation =
- methodDefinitionInsertLocationFinder.find(tu, methodDeclaration.getFileLocation(),
- methodDeclaration.getParent(), refactoringContext, subMonitor);
-
- if (insertLocation.getTranslationUnit() == null || NodeHelper.isContainedInTemplateDeclaration(methodDeclaration)) {
+ InsertLocation insertLocation = methodDefinitionInsertLocationFinder.find(tu,
+ methodDeclaration.getFileLocation(), methodDeclaration.getParent(), refactoringContext, subMonitor);
+
+ if (insertLocation.getTranslationUnit() == null
+ || NodeHelper.isContainedInTemplateDeclaration(methodDeclaration)) {
insertLocation.setNodeToInsertAfter(NodeHelper.findTopLevelParent(methodDeclaration), tu);
}
insertLocations.put(methodDeclaration, insertLocation);
return insertLocation;
}
- private IASTDeclaration createFunctionDefinition(IASTTranslationUnit unit, IASTSimpleDeclaration methodDeclaration, InsertLocation insertLocation) throws CoreException {
+ private IASTDeclaration createFunctionDefinition(IASTTranslationUnit unit, IASTSimpleDeclaration methodDeclaration,
+ InsertLocation insertLocation) throws CoreException {
IASTDeclSpecifier declSpecifier = methodDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations);
- ICPPASTFunctionDeclarator functionDeclarator = (ICPPASTFunctionDeclarator) methodDeclaration.getDeclarators()[0];
+ ICPPASTFunctionDeclarator functionDeclarator = (ICPPASTFunctionDeclarator) methodDeclaration
+ .getDeclarators()[0];
IASTNode declarationParent = methodDeclaration.getParent();
-
+
if (declSpecifier instanceof ICPPASTDeclSpecifier) {
((ICPPASTDeclSpecifier) declSpecifier).setVirtual(false);
((ICPPASTDeclSpecifier) declSpecifier).setExplicit(false);
}
-
+
String currentFileName = declarationParent.getNodeLocations()[0].asFileLocation().getFileName();
if (Path.fromOSString(currentFileName).equals(insertLocation.getFile().getLocation())) {
declSpecifier.setInline(true);
}
-
+
if (declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_static) {
declSpecifier.setStorageClass(IASTDeclSpecifier.sc_unspecified);
}
-
+
ICPPASTQualifiedName qName = createQualifiedNameFor(functionDeclarator, declarationParent, insertLocation);
-
+
createdMethodDeclarator = nodeFactory.newFunctionDeclarator(qName);
createdMethodDeclarator.setConst(functionDeclarator.isConst());
createdMethodDeclarator.setRefQualifier(functionDeclarator.getRefQualifier());
@@ -275,34 +279,37 @@ public class ImplementMethodRefactoring extends CRefactoring {
if (exceptionSpecification != ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION) {
createdMethodDeclarator.setEmptyExceptionSpecification();
for (IASTTypeId typeId : exceptionSpecification) {
- createdMethodDeclarator.addExceptionSpecificationTypeId(typeId == null ? null : typeId.copy(CopyStyle.withLocations));
+ createdMethodDeclarator
+ .addExceptionSpecificationTypeId(typeId == null ? null : typeId.copy(CopyStyle.withLocations));
}
}
- IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier, createdMethodDeclarator, nodeFactory.newCompoundStatement());
+ IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier,
+ createdMethodDeclarator, nodeFactory.newCompoundStatement());
functionDefinition.setParent(unit);
-
- ICPPASTTemplateDeclaration templateDeclaration = ASTQueries.findAncestorWithType(declarationParent, ICPPASTTemplateDeclaration.class);
+
+ ICPPASTTemplateDeclaration templateDeclaration = ASTQueries.findAncestorWithType(declarationParent,
+ ICPPASTTemplateDeclaration.class);
if (templateDeclaration != null) {
ICPPASTTemplateDeclaration newTemplateDeclaration = nodeFactory.newTemplateDeclaration(functionDefinition);
newTemplateDeclaration.setParent(unit);
-
+
for (ICPPASTTemplateParameter templateParameter : templateDeclaration.getTemplateParameters()) {
newTemplateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
}
-
+
return newTemplateDeclaration;
}
return functionDefinition;
}
private ICPPASTQualifiedName createQualifiedNameFor(IASTFunctionDeclarator functionDeclarator,
- IASTNode declarationParent, InsertLocation insertLocation) throws CoreException {
+ IASTNode declarationParent, InsertLocation insertLocation) throws CoreException {
int insertOffset = insertLocation.getInsertPosition();
- return NameHelper.createQualifiedNameFor(
- functionDeclarator.getName(), tu, functionDeclarator.getFileLocation().getNodeOffset(),
- insertLocation.getTranslationUnit(), insertOffset, refactoringContext);
+ return NameHelper.createQualifiedNameFor(functionDeclarator.getName(), tu,
+ functionDeclarator.getFileLocation().getNodeOffset(), insertLocation.getTranslationUnit(), insertOffset,
+ refactoringContext);
}
-
+
public ImplementMethodData getRefactoringData() {
return data;
}
@@ -312,21 +319,21 @@ public class ImplementMethodRefactoring extends CRefactoring {
// TODO egraf add Descriptor
return null;
}
-
+
private IFile[] getAllFilesToModify() {
List<IFile> files = new ArrayList<IFile>(2);
IFile file = (IFile) tu.getResource();
if (file != null) {
files.add(file);
}
-
+
for (InsertLocation insertLocation : insertLocations.values()) {
if (insertLocation != null) {
file = insertLocation.getFile();
if (file != null) {
files.add(file);
}
- }
+ }
}
return files.toArray(new IFile[files.size()]);
@@ -342,17 +349,17 @@ public class ImplementMethodRefactoring extends CRefactoring {
Checks.addModifiedFilesToChecker(getAllFilesToModify(), checkContext);
return result;
}
-
+
private boolean isOneOrMoreImplementationInHeader(IProgressMonitor subProgressMonitor) throws CoreException {
for (MethodToImplementConfig config : data.getMethodsToImplement()) {
IASTSimpleDeclaration decl = config.getDeclaration();
- findInsertLocation(decl, subProgressMonitor);
+ findInsertLocation(decl, subProgressMonitor);
}
-
+
if (insertLocations.isEmpty()) {
return true;
}
-
+
for (InsertLocation insertLocation : insertLocations.values()) {
if (insertLocation != null && tu.equals(insertLocation.getTranslationUnit())) {
return true;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java
index 6ec6e033a0c..5d2fdb7344b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Marc-Andre Laperle
* Sergey Prigogin (Google)
@@ -30,15 +30,14 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
*/
public class ImplementMethodRefactoringRunner extends RefactoringRunner {
- public ImplementMethodRefactoringRunner(ICElement element, ISelection selection,
- IShellProvider shellProvider, ICProject cProject) {
+ public ImplementMethodRefactoringRunner(ICElement element, ISelection selection, IShellProvider shellProvider,
+ ICProject cProject) {
super(element, selection, shellProvider, cProject);
}
@Override
public void run() {
- ImplementMethodRefactoring refactoring =
- new ImplementMethodRefactoring(element, selection, project);
+ ImplementMethodRefactoring refactoring = new ImplementMethodRefactoring(element, selection, project);
ImplementMethodWizard wizard = new ImplementMethodWizard(refactoring);
run(wizard, refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodWizard.java
index b8c1bdf3bab..a50ebb6eb86 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodWizard.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Marc-Andre Laperle
*******************************************************************************/
@@ -29,9 +29,8 @@ import org.eclipse.cdt.ui.CUIPlugin;
* @author Mirko Stocker
*/
public class ImplementMethodWizard extends RefactoringWizard {
- private final ImplementMethodRefactoring refactoring;
- private Map<MethodToImplementConfig, ParameterNamesInputPage> pagesMap =
- new HashMap<MethodToImplementConfig, ParameterNamesInputPage>();
+ private final ImplementMethodRefactoring refactoring;
+ private Map<MethodToImplementConfig, ParameterNamesInputPage> pagesMap = new HashMap<MethodToImplementConfig, ParameterNamesInputPage>();
public ImplementMethodWizard(ImplementMethodRefactoring refactoring) {
super(refactoring, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
@@ -51,7 +50,7 @@ public class ImplementMethodWizard extends RefactoringWizard {
}
}
}
-
+
public ParameterNamesInputPage getPageForConfig(MethodToImplementConfig config) {
return pagesMap.get(config);
}
@@ -60,7 +59,7 @@ public class ImplementMethodWizard extends RefactoringWizard {
* When canceling the wizard, CRefactoringContext gets disposed and releases the lock on
* the index but the preview jobs might still be running and access the index or an index-based
* AST so we need to make sure they are done before disposing the cache
- * <p>
+ * <p>
* When proceeding to the last page and finishing the wizard, the refactoring will run
* and possibly use concurrently the same ASTs that the jobs use, so we need to make
* sure the jobs are joined.
@@ -70,7 +69,7 @@ public class ImplementMethodWizard extends RefactoringWizard {
for (ParameterNamesInputPage parameterNamesInputPage : pagesMap.values()) {
isOnePreviewJobRunning |= parameterNamesInputPage.cancelPreviewJob();
}
-
+
// There are good chances that one job is still running, show a progress bar to the user,
// join everything.
if (isOnePreviewJobRunning) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java
index 94a56b0d814..c24e30a7549 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -25,7 +25,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
/**
* Is returned when using the find method of the MethodDefinitionInsertLocationFinder.
* Contains all the information needed to insert at the correct position.
- *
+ *
* @author Lukas Felber
*/
public class InsertLocation {
@@ -53,7 +53,7 @@ public class InsertLocation {
public ITranslationUnit getTranslationUnit() {
return tu;
}
-
+
public IFile getFile() {
return tu != null ? (IFile) tu.getResource() : null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java
index 7874fefb843..963a9351a96 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM - initial API and implementation
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDefinitionInsertLocationFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDefinitionInsertLocationFinder.java
index e3353f5d413..cc9899b0fe6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDefinitionInsertLocationFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDefinitionInsertLocationFinder.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
* Marc-Andre Laperle
@@ -44,7 +44,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
/**
* Finds the information that are needed to tell where a method definition of a certain
* method declaration should be inserted.
- *
+ *
* @author Mirko Stocker, Lukas Felber
*/
public class MethodDefinitionInsertLocationFinder {
@@ -52,18 +52,17 @@ public class MethodDefinitionInsertLocationFinder {
// might want to find multiple insert locations in the same translation unit. This prevents
// many redundant calls to DefinitionFinder.getDefinition and speeds up the process quite
// a bit. Unfortunately, this has the minor side-effect or having to instantiate this class.
- Map<IASTSimpleDeclaration, IASTName> cachedDeclarationToDefinition =
- new HashMap<IASTSimpleDeclaration, IASTName>();
+ Map<IASTSimpleDeclaration, IASTName> cachedDeclarationToDefinition = new HashMap<IASTSimpleDeclaration, IASTName>();
public InsertLocation find(ITranslationUnit declarationTu, IASTFileLocation methodDeclarationLocation,
IASTNode parent, CRefactoringContext refactoringContext, IProgressMonitor pm) throws CoreException {
IASTDeclaration[] declarations = NodeHelper.getDeclarations(parent);
InsertLocation insertLocation = new InsertLocation();
- Collection<IASTSimpleDeclaration> allPreviousSimpleDeclarationsFromClassInReverseOrder =
- getAllPreviousSimpleDeclarationsFromClassInReverseOrder(declarations, methodDeclarationLocation, pm);
- Collection<IASTSimpleDeclaration> allFollowingSimpleDeclarationsFromClass =
- getAllFollowingSimpleDeclarationsFromClass(declarations, methodDeclarationLocation, pm);
+ Collection<IASTSimpleDeclaration> allPreviousSimpleDeclarationsFromClassInReverseOrder = getAllPreviousSimpleDeclarationsFromClassInReverseOrder(
+ declarations, methodDeclarationLocation, pm);
+ Collection<IASTSimpleDeclaration> allFollowingSimpleDeclarationsFromClass = getAllFollowingSimpleDeclarationsFromClass(
+ declarations, methodDeclarationLocation, pm);
for (IASTSimpleDeclaration simpleDeclaration : allPreviousSimpleDeclarationsFromClassInReverseOrder) {
if (pm != null && pm.isCanceled()) {
@@ -77,14 +76,14 @@ public class MethodDefinitionInsertLocationFinder {
IASTName name = simpleDeclaration.getDeclarators()[0].getName();
definition = DefinitionFinder.getDefinition(name, refactoringContext, pm);
if (definition != null) {
- cachedDeclarationToDefinition.put(simpleDeclaration, definition);
+ cachedDeclarationToDefinition.put(simpleDeclaration, definition);
}
}
- if (definition != null) {
- insertLocation.setNodeToInsertAfter(findFirstSurroundingParentFunctionNode(
- definition), definition.getTranslationUnit().getOriginatingTranslationUnit());
- }
+ if (definition != null) {
+ insertLocation.setNodeToInsertAfter(findFirstSurroundingParentFunctionNode(definition),
+ definition.getTranslationUnit().getOriginatingTranslationUnit());
+ }
}
for (IASTSimpleDeclaration simpleDeclaration : allFollowingSimpleDeclarationsFromClass) {
@@ -111,8 +110,8 @@ public class MethodDefinitionInsertLocationFinder {
if (insertLocation.getTranslationUnit() == null) {
if (declarationTu.isHeaderUnit()) {
- ITranslationUnit partner = SourceHeaderPartnerFinder.getPartnerTranslationUnit(
- declarationTu, refactoringContext);
+ ITranslationUnit partner = SourceHeaderPartnerFinder.getPartnerTranslationUnit(declarationTu,
+ refactoringContext);
if (partner != null) {
insertLocation.setParentNode(refactoringContext.getAST(partner, null), partner);
}
@@ -150,10 +149,10 @@ public class MethodDefinitionInsertLocationFinder {
/**
* Searches the given class for all IASTSimpleDeclarations occurring before 'method'
* and returns them in reverse order.
- *
+ *
* @param declarations to be searched
* @param methodPosition on which the search aborts
- * @param pm
+ * @param pm
* @return all declarations, sorted in reverse order
*/
private static Collection<IASTSimpleDeclaration> getAllPreviousSimpleDeclarationsFromClassInReverseOrder(
@@ -185,18 +184,17 @@ public class MethodDefinitionInsertLocationFinder {
if (pm != null && pm.isCanceled()) {
return outputDeclarations;
}
- if (isMemberFunctionDeclaration(decl) &&
- decl.getFileLocation().getStartingLineNumber() > methodPosition.getStartingLineNumber() ) {
+ if (isMemberFunctionDeclaration(decl)
+ && decl.getFileLocation().getStartingLineNumber() > methodPosition.getStartingLineNumber()) {
outputDeclarations.add((IASTSimpleDeclaration) decl);
}
}
}
return outputDeclarations;
}
-
+
private static boolean isMemberFunctionDeclaration(IASTDeclaration decl) {
- return decl instanceof IASTSimpleDeclaration &&
- ((IASTSimpleDeclaration) decl).getDeclarators().length > 0 &&
- ((IASTSimpleDeclaration) decl).getDeclarators()[0] instanceof IASTFunctionDeclarator;
+ return decl instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration) decl).getDeclarators().length > 0
+ && ((IASTSimpleDeclaration) decl).getDeclarators()[0] instanceof IASTFunctionDeclarator;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodToImplementConfig.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodToImplementConfig.java
index cd3a2812b12..1b42787876a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodToImplementConfig.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodToImplementConfig.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
@@ -21,13 +21,12 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
*
*/
public class MethodToImplementConfig {
-
+
private IASTSimpleDeclaration declaration;
private ParameterHandler paraHandler;
private boolean checked;
-
- public MethodToImplementConfig(IASTSimpleDeclaration declaration,
- ParameterHandler paraHandler) {
+
+ public MethodToImplementConfig(IASTSimpleDeclaration declaration, ParameterHandler paraHandler) {
super();
this.declaration = declaration;
this.paraHandler = paraHandler;
@@ -40,12 +39,12 @@ public class MethodToImplementConfig {
public ParameterHandler getParaHandler() {
return paraHandler;
}
-
+
@Override
public String toString() {
return declaration.getRawSignature();
}
-
+
public boolean isChecked() {
return checked;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterHandler.java
index f122d5f0f05..d523cb9357a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterHandler.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
@@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.PseudoNameGenerator;
/**
* Manages and creates Method Parameter Infos.
- *
+ *
* @author Lukas Felber
*
*/
@@ -36,29 +36,31 @@ public class ParameterHandler {
private PseudoNameGenerator pseudoNameGenerator;
private ArrayList<ParameterInfo> parameterInfos;
private IASTSimpleDeclaration method;
-
+
public ParameterHandler(IASTSimpleDeclaration method) {
this.method = method;
initArgumentNames();
}
-
+
public boolean needsAdditionalArgumentNames() {
return needsAditionalArgumentNames;
}
-
+
public void initArgumentNames() {
- if(parameterInfos != null) {
+ if (parameterInfos != null) {
return;
}
- needsAditionalArgumentNames = false;
+ needsAditionalArgumentNames = false;
parameterInfos = new ArrayList<ParameterInfo>();
- for(IASTParameterDeclaration actParam : getParametersFromMethodNode()) {
+ for (IASTParameterDeclaration actParam : getParametersFromMethodNode()) {
String actName = actParam.getDeclarator().getName().toString();
boolean isChangable = false;
- if(actParam.getDeclSpecifier()instanceof IASTSimpleDeclSpecifier && ((IASTSimpleDeclSpecifier)actParam.getDeclSpecifier()).getType() == IASTSimpleDeclSpecifier.t_void) {
+ if (actParam.getDeclSpecifier() instanceof IASTSimpleDeclSpecifier
+ && ((IASTSimpleDeclSpecifier) actParam.getDeclSpecifier())
+ .getType() == IASTSimpleDeclSpecifier.t_void) {
actName = ""; //$NON-NLS-1$
isChangable = false;
- }else if(actName.length() == 0) {
+ } else if (actName.length() == 0) {
needsAditionalArgumentNames = true;
isChangable = true;
actName = findNameForParameter(NameHelper.getTypeName(actParam));
@@ -68,20 +70,20 @@ public class ParameterHandler {
}
private String findNameForParameter(String typeName) {
- if(pseudoNameGenerator == null) {
+ if (pseudoNameGenerator == null) {
pseudoNameGenerator = new PseudoNameGenerator();
- for(IASTParameterDeclaration parameter : getParametersFromMethodNode()) {
- if(parameter.getDeclarator().getName().toString().length() != 0) {
+ for (IASTParameterDeclaration parameter : getParametersFromMethodNode()) {
+ if (parameter.getDeclarator().getName().toString().length() != 0) {
pseudoNameGenerator.addExistingName(parameter.getDeclarator().getName().toString());
}
}
}
return pseudoNameGenerator.generateNewName(typeName);
}
-
+
private IASTParameterDeclaration[] getParametersFromMethodNode() {
- if(method.getDeclarators().length < 1) {
+ if (method.getDeclarators().length < 1) {
return null;
}
return ((ICPPASTFunctionDeclarator) method.getDeclarators()[0]).getParameters();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterInfo.java
index 12423e579b2..8d02b52520f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterInfo.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
@@ -29,17 +29,17 @@ public class ParameterInfo {
private IASTParameterDeclaration parameter;
private boolean hasNewName;
private String parameterName;
-
+
public ParameterInfo(IASTParameterDeclaration parameter, String parameterName, boolean hasNewName) {
this.parameter = parameter;
this.hasNewName = hasNewName;
this.parameterName = parameterName;
}
-
+
public boolean hasNewName() {
return hasNewName;
}
-
+
public boolean hasDefaultValue() {
return getDefaultValueNode() != null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java
index 3c11af58ae9..bb343522173 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Marc-Andre Laperle
*******************************************************************************/
@@ -48,7 +48,7 @@ import org.eclipse.cdt.internal.ui.refactoring.dialogs.ValidatingLabeledTextFiel
/**
* InputPage used by the ImplementMethod refactoring if its necessary to enter additional parameter names.
- *
+ *
* @author Mirko Stocker
*/
public class ParameterNamesInputPage extends UserInputWizardPage {
@@ -67,21 +67,22 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
@Override
public void createControl(Composite parent) {
Composite superComposite = new Composite(parent, SWT.NONE);
-
- superComposite.setLayout(new GridLayout());
-
+
+ superComposite.setLayout(new GridLayout());
+
setTitle(Messages.ImplementMethodInputPage_PageTitle);
setMessage(Messages.ParameterNamesInputPage_CompleteMissingMails);
-
+
ValidatingLabeledTextField validatingLabeledTextField = new ValidatingLabeledTextField(superComposite);
- validatingLabeledTextField.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
-
+ validatingLabeledTextField
+ .setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+
for (final ParameterInfo actParameterInfo : config.getParaHandler().getParameterInfos()) {
String type = actParameterInfo.getTypeName();
String content = actParameterInfo.getParameterName();
boolean readOnly = !actParameterInfo.hasNewName();
-
- validatingLabeledTextField.addElement(type, content, readOnly, new ValidatingLabeledTextField.Validator(){
+
+ validatingLabeledTextField.addElement(type, content, readOnly, new ValidatingLabeledTextField.Validator() {
@Override
public void hasErrors() {
setPageComplete(false);
@@ -97,13 +98,14 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
actParameterInfo.setParameterName(newName);
updatePreview();
return true;
- }});
+ }
+ });
}
createPreview(superComposite);
setControl(superComposite);
}
-
+
private InsertEdit getInsertEdit(CompositeChange compositeChange) {
for (Change actChange : compositeChange.getChildren()) {
if (actChange instanceof CompositeChange) {
@@ -124,18 +126,19 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
}
}
return null;
- }
-
+ }
+
public String createFunctionDefinitionSignature(IProgressMonitor monitor) {
try {
ModificationCollector collector = new ModificationCollector();
- ImplementMethodRefactoring implementMethodRefactoring = (ImplementMethodRefactoring) wizard.getRefactoring();
+ ImplementMethodRefactoring implementMethodRefactoring = (ImplementMethodRefactoring) wizard
+ .getRefactoring();
CCompositeChange finalChange = null;
// We can have multiple preview jobs. We don't
// want multiple jobs concurrently using the same ASTs
synchronized (implementMethodRefactoring) {
implementMethodRefactoring.createDefinition(collector, config, monitor);
- finalChange = collector.createFinalChange();
+ finalChange = collector.createFinalChange();
}
InsertEdit insertEdit = getInsertEdit(finalChange);
if (insertEdit == null) {
@@ -151,8 +154,9 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
private void createPreview(Composite superComposite) {
translationUnitPreview = new TranslationUnitPreview(new HashMap<String, String>(), superComposite);
- translationUnitPreview.getControl().setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
-
+ translationUnitPreview.getControl()
+ .setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+
delayedPreviewUpdater = new Job(Messages.ImplementMethodRefactoringPage_GeneratingPreview) {
@Override
protected IStatus run(IProgressMonitor monitor) {
@@ -183,18 +187,19 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
}
}
};
-
+
delayedPreviewUpdater.schedule(PREVIEW_UPDATE_DELAY);
}
-
+
@Override
public boolean canFlipToNextPage() {
return isPageComplete();
}
-
+
@Override
public IWizardPage getNextPage() {
- MethodToImplementConfig nextConfig = ((ImplementMethodRefactoring)wizard.getRefactoring()).getRefactoringData().getNextConfigNeedingParameterNames(config);
+ MethodToImplementConfig nextConfig = ((ImplementMethodRefactoring) wizard.getRefactoring()).getRefactoringData()
+ .getNextConfigNeedingParameterNames(config);
if (nextConfig != null) {
return wizard.getPageForConfig(nextConfig);
} else {
@@ -204,7 +209,7 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
}
/**
- * @return true if the preview job could still be running, false otherwise
+ * @return true if the preview job could still be running, false otherwise
*/
protected boolean cancelPreviewJob() {
if (delayedPreviewUpdater == null) {
@@ -218,11 +223,11 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
}
return !delayedPreviewUpdater.cancel();
}
-
+
protected void joinPreviewJob() {
if (delayedPreviewUpdater == null)
return;
-
+
try {
delayedPreviewUpdater.join();
} catch (InterruptedException e) {
@@ -236,7 +241,7 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
delayedPreviewUpdater.schedule(PREVIEW_UPDATE_DELAY);
}
-
+
@Override
public boolean isPageComplete() {
if (!config.isChecked()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java
index 8427a1b6cea..9720689ffd6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java
@@ -150,13 +150,13 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
*/
public class BindingClassifier {
private static final String[] TEMPLATES_ALLOWING_INCOMPLETE_ARGUMENT_TYPE = {
- // Please keep alphabetical order.
- "enable_shared_from_this", // 20.7.2.4 //$NON-NLS-1$
- "declval", // 20.2.4 //$NON-NLS-1$
- "default_delete", // 20.7.1.1 //$NON-NLS-1$
- "shared_ptr", // 20.7.2.2 //$NON-NLS-1$
- "unique_ptr", // 20.7.1 //$NON-NLS-1$
- "weak_ptr" // 20.7.2.3 //$NON-NLS-1$
+ // Please keep alphabetical order.
+ "enable_shared_from_this", // 20.7.2.4 //$NON-NLS-1$
+ "declval", // 20.2.4 //$NON-NLS-1$
+ "default_delete", // 20.7.1.1 //$NON-NLS-1$
+ "shared_ptr", // 20.7.2.2 //$NON-NLS-1$
+ "unique_ptr", // 20.7.1 //$NON-NLS-1$
+ "weak_ptr" // 20.7.2.3 //$NON-NLS-1$
};
private class BindingCollector extends ASTVisitor {
@@ -200,17 +200,16 @@ public class BindingClassifier {
if (declSpecifier instanceof IASTNamedTypeSpecifier) {
// We only handle simple declarations here whose declaration specifiers are
// named type specifiers.
- boolean staticMember =
- simpleDeclaration.getParent() instanceof IASTCompositeTypeSpecifier &&
- declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_static;
+ boolean staticMember = simpleDeclaration.getParent() instanceof IASTCompositeTypeSpecifier
+ && declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_static;
// Declare the named type specifier if all declarators are either pointers,
// references or functions.
boolean canBeDeclared = true;
if (!staticMember) {
for (IASTDeclarator declarator : declarators) {
- if (!(declarator instanceof IASTFunctionDeclarator) &&
- declarator.getPointerOperators().length == 0) {
+ if (!(declarator instanceof IASTFunctionDeclarator)
+ && declarator.getPointerOperators().length == 0) {
canBeDeclared = false;
break;
}
@@ -242,9 +241,9 @@ public class BindingClassifier {
* Example 2:
* X& foo() { } // definition of X is not required here
*/
- IASTName name = declarator.getPropertyInParent() == ICPPASTLambdaExpression.DECLARATOR ?
- ((ICPPASTLambdaExpression) declarator.getParent()).getFunctionCallOperatorName() :
- declarator.getName();
+ IASTName name = declarator.getPropertyInParent() == ICPPASTLambdaExpression.DECLARATOR
+ ? ((ICPPASTLambdaExpression) declarator.getParent()).getFunctionCallOperatorName()
+ : declarator.getName();
IBinding binding = name.resolveBinding();
if (binding instanceof IFunction) {
IFunction function = (IFunction) binding;
@@ -252,20 +251,19 @@ public class BindingClassifier {
IFunctionType functionType = function.getType();
try {
CPPSemantics.pushLookupPoint(declarator);
- if (declarator.getPropertyInParent() == IASTFunctionDefinition.DECLARATOR ||
- declarator.getPropertyInParent() == ICPPASTLambdaExpression.DECLARATOR) {
+ if (declarator.getPropertyInParent() == IASTFunctionDefinition.DECLARATOR
+ || declarator.getPropertyInParent() == ICPPASTLambdaExpression.DECLARATOR) {
// Define the return type if necessary.
IType returnType = functionType.getReturnType();
if (!(returnType instanceof IPointerType || returnType instanceof ICPPReferenceType)) {
defineTypeExceptTypedefOrNonFixedEnum(returnType);
}
-
+
// Define parameter types if necessary.
IType[] parameterTypes = functionType.getParameterTypes();
for (IType type : parameterTypes) {
if (!(type instanceof IPointerType)) {
- if (!(type instanceof ICPPReferenceType) ||
- isTypeWithConvertingConstructor(type)) {
+ if (!(type instanceof ICPPReferenceType) || isTypeWithConvertingConstructor(type)) {
defineTypeExceptTypedefOrNonFixedEnum(type);
}
}
@@ -420,10 +418,10 @@ public class BindingClassifier {
if (argument instanceof IASTExpression) {
IASTExpression expression = (IASTExpression) argument;
IType argumentType = expression.getExpressionType();
- if (targetType instanceof ICPPReferenceType
- && expression instanceof IASTUnaryExpression
- && ((IASTUnaryExpression) expression).getOperator() == IASTUnaryExpression.op_star) {
- argumentType = new CPPReferenceType(argumentType, false);
+ if (targetType instanceof ICPPReferenceType && expression instanceof IASTUnaryExpression
+ && ((IASTUnaryExpression) expression)
+ .getOperator() == IASTUnaryExpression.op_star) {
+ argumentType = new CPPReferenceType(argumentType, false);
}
if (isTypeDefinitionRequiredForConversion(argumentType, targetType)) {
// Types don't match. Define both types.
@@ -460,7 +458,8 @@ public class BindingClassifier {
if (returnValue != null) {
// Get the containing function definition.
IASTNode functionDefinitionNode = returnStatement;
- while (functionDefinitionNode != null && !(functionDefinitionNode instanceof IASTFunctionDefinition)) {
+ while (functionDefinitionNode != null
+ && !(functionDefinitionNode instanceof IASTFunctionDefinition)) {
functionDefinitionNode = functionDefinitionNode.getParent();
}
@@ -519,8 +518,7 @@ public class BindingClassifier {
try {
CPPSemantics.pushLookupPoint(expression);
ASTNodeProperty propertyInParent = expression.getPropertyInParent();
- if (propertyInParent == IASTIfStatement.CONDITION
- || propertyInParent == IASTForStatement.CONDITION
+ if (propertyInParent == IASTIfStatement.CONDITION || propertyInParent == IASTForStatement.CONDITION
|| propertyInParent == IASTWhileStatement.CONDITIONEXPRESSION
|| propertyInParent == IASTDoStatement.CONDITION
|| propertyInParent == IASTConditionalExpression.LOGICAL_CONDITION) {
@@ -538,7 +536,7 @@ public class BindingClassifier {
defineTypeExceptTypedefOrNonFixedEnum(conditionExpressionType);
}
}
-
+
if (expression instanceof IASTIdExpression) {
/*
* The type of an identifier expression doesn't need to be defined if it's a pointer
@@ -550,7 +548,7 @@ public class BindingClassifier {
* }
*/
IASTIdExpression idExpression = (IASTIdExpression) expression;
-
+
IBinding binding = idExpression.getName().resolveBinding();
if (binding instanceof IVariable) {
// Get the declared type.
@@ -581,7 +579,7 @@ public class BindingClassifier {
*/
IASTUnaryExpression unaryExpression = (IASTUnaryExpression) expression;
IASTExpression operand = unaryExpression.getOperand();
- if (operand != null) { // A throw expression may have no operand.
+ if (operand != null) { // A throw expression may have no operand.
if (unaryExpression instanceof ICPPASTUnaryExpression) {
ICPPFunction overload = ((ICPPASTUnaryExpression) unaryExpression).getOverload();
if (overload != null) {
@@ -589,7 +587,7 @@ public class BindingClassifier {
return PROCESS_CONTINUE;
}
}
-
+
boolean expressionDefinitionRequired = true;
switch (unaryExpression.getOperator()) {
case IASTUnaryExpression.op_amper:
@@ -612,7 +610,7 @@ public class BindingClassifier {
}
break;
}
-
+
if (expressionDefinitionRequired) {
defineTypeExceptTypedefOrNonFixedEnum(operand.getExpressionType());
}
@@ -647,13 +645,13 @@ public class BindingClassifier {
if (binaryExpression instanceof ICPPASTBinaryExpression) {
ICPPFunction overload = ((ICPPASTBinaryExpression) binaryExpression).getOverload();
if (overload != null) {
- IASTInitializerClause[] arguments = new IASTInitializerClause[]
- { binaryExpression.getOperand1(), binaryExpression.getOperand2() };
+ IASTInitializerClause[] arguments = new IASTInitializerClause[] {
+ binaryExpression.getOperand1(), binaryExpression.getOperand2() };
defineForFunctionCall(overload, true, arguments);
return PROCESS_CONTINUE;
}
}
-
+
IType operand1Type = binaryExpression.getOperand1().getExpressionType();
IASTInitializerClause operand2 = binaryExpression.getInitOperand2();
IType operand2Type;
@@ -675,10 +673,10 @@ public class BindingClassifier {
} else {
operand2Type = operand1Type;
}
-
+
boolean expression1DefinitionRequired = true;
boolean expression2DefinitionRequired = true;
-
+
switch (binaryExpression.getOperator()) {
case IASTBinaryExpression.op_logicalAnd:
case IASTBinaryExpression.op_logicalOr:
@@ -711,7 +709,7 @@ public class BindingClassifier {
expression2DefinitionRequired = false;
}
}
-
+
if (expression1DefinitionRequired) {
defineTypeExceptTypedefOrNonFixedEnum(operand1Type);
}
@@ -748,7 +746,7 @@ public class BindingClassifier {
IASTExpression functionNameExpression = functionCallExpression.getFunctionNameExpression();
if (isPartOfExternalMacroDefinition(functionNameExpression))
return PROCESS_CONTINUE;
-
+
IASTInitializerClause[] arguments = functionCallExpression.getArguments();
IASTName functionName = getNameOfIdOrFieldReferenceExpression(functionNameExpression);
if (functionName != null) {
@@ -768,20 +766,21 @@ public class BindingClassifier {
name = ((ICPPASTTemplateId) functionName).getTemplateName();
}
boolean defineFunction = !isPartOfExternalMacroDefinition(name);
-
+
if (defineFunction) {
LookupData data = new LookupData(functionName);
IType impliedObjectType = data.getImpliedObjectType();
if (impliedObjectType != null)
defineTypeExceptTypedefOrNonFixedEnum(impliedObjectType);
}
-
+
defineBindingForFunctionCall(function, defineFunction, arguments);
}
}
-
+
if (functionCallExpression instanceof IASTImplicitNameOwner) {
- IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) functionCallExpression).getImplicitNames();
+ IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) functionCallExpression)
+ .getImplicitNames();
for (IASTName name : implicitNames) {
IBinding binding = name.resolveBinding();
if (binding instanceof IFunction) {
@@ -799,7 +798,7 @@ public class BindingClassifier {
* x2->bar(); // definition of typeof(x2) is required here
* }
*/
-
+
IASTExpression fieldOwner = ((IASTFieldReference) expression).getFieldOwner();
IType expressionType = fieldOwner.getExpressionType();
defineIndirectTypes(expressionType);
@@ -828,7 +827,8 @@ public class BindingClassifier {
* delete x; // definition of typeof(x) is required here
* }
*/
- defineTypeExceptTypedefOrNonFixedEnum(((ICPPASTDeleteExpression) expression).getOperand().getExpressionType());
+ defineTypeExceptTypedefOrNonFixedEnum(
+ ((ICPPASTDeleteExpression) expression).getOperand().getExpressionType());
} else if (expression instanceof IASTCastExpression) {
/*
* Explicit type casts always need the definition of the underlying types.
@@ -841,7 +841,7 @@ public class BindingClassifier {
IASTCastExpression castExpression = (IASTCastExpression) expression;
IType targetType = castExpression.getExpressionType();
IType sourceType = castExpression.getOperand().getExpressionType();
-
+
if (isTypeDefinitionRequiredForConversion(sourceType, targetType)) {
// Source and target types of the cast expression are different.
// We need to define both types, even if they're pointers.
@@ -905,8 +905,8 @@ public class BindingClassifier {
defineBinding(owner); // Member access requires definition of the containing type.
if (binding instanceof IProblemBinding)
declareBinding(binding);
- if (!isDefinedLocally(owner) &&
- (!(binding instanceof ICPPMember) || !((ICPPMember) binding).isStatic())) {
+ if (!isDefinedLocally(owner)
+ && (!(binding instanceof ICPPMember) || !((ICPPMember) binding).isStatic())) {
// Record the fact that the header file defining the owner must also
// provide a definition of the type of this member (bug 442841).
IType type = null;
@@ -925,10 +925,9 @@ public class BindingClassifier {
}
}
-
- if (binding instanceof ICPPTemplateInstance &&
- !((ICPPTemplateInstance) binding).isExplicitSpecialization() &&
- isDeclaredLocally(((ICPPTemplateInstance) binding).getSpecializedBinding())) {
+ if (binding instanceof ICPPTemplateInstance
+ && !((ICPPTemplateInstance) binding).isExplicitSpecialization()
+ && isDeclaredLocally(((ICPPTemplateInstance) binding).getSpecializedBinding())) {
fInstancesOfLocallyDefinedTemplates.add((ICPPTemplateInstance) binding);
}
}
@@ -954,15 +953,15 @@ public class BindingClassifier {
boolean found;
LocalNameFinder() {
- shouldVisitNames = true;
+ shouldVisitNames = true;
}
@Override
public int visit(IASTName name) {
if (!(name instanceof ICPPASTQualifiedName)) {
IASTImageLocation imageLocation = name.getImageLocation();
- if (imageLocation != null &&
- imageLocation.getFileName().equals(name.getTranslationUnit().getFilePath())) {
+ if (imageLocation != null
+ && imageLocation.getFileName().equals(name.getTranslationUnit().getFilePath())) {
found = true;
return PROCESS_ABORT;
}
@@ -1084,9 +1083,8 @@ public class BindingClassifier {
// As a matter of policy, a header declaring the function is responsible for
// defining parameter types that allow implicit conversion.
parameterType = getNestedType(parameterType, REF | ALLCVQ);
- if (!(parameterType instanceof ICPPClassType) ||
- fAst.getDeclarationsInAST(function).length != 0 ||
- !hasConvertingConstructor((ICPPClassType) parameterType, argument)) {
+ if (!(parameterType instanceof ICPPClassType) || fAst.getDeclarationsInAST(function).length != 0
+ || !hasConvertingConstructor((ICPPClassType) parameterType, argument)) {
defineTypeExceptTypedefOrNonFixedEnum(parameterType);
} else if (!functionIsDeclared) {
declareType(parameterType);
@@ -1207,11 +1205,11 @@ public class BindingClassifier {
// Normally we don't need to define parameters of a template specialization
// that were not specified explicitly. std::hash and __gnu_cxx::hash are
// exceptions from that rule.
- if (type instanceof IBinding && CharArrayUtils.equals(((IBinding) type).getNameCharArray(), "hash")) { //$NON-NLS-1$
+ if (type instanceof IBinding
+ && CharArrayUtils.equals(((IBinding) type).getNameCharArray(), "hash")) { //$NON-NLS-1$
IBinding owner = ((IBinding) type).getOwner();
- if (owner instanceof ICPPNamespace &&
- (CharArrayUtils.equals(owner.getNameCharArray(), STD) ||
- CharArrayUtils.equals(owner.getNameCharArray(), "__gnu_cxx"))) { //$NON-NLS-1$
+ if (owner instanceof ICPPNamespace && (CharArrayUtils.equals(owner.getNameCharArray(), STD)
+ || CharArrayUtils.equals(owner.getNameCharArray(), "__gnu_cxx"))) { //$NON-NLS-1$
addRequiredBindings((IBinding) type, queue);
}
}
@@ -1242,8 +1240,8 @@ public class BindingClassifier {
} else {
// No candidate bindings available. Check whether this is a macro.
try {
- IIndexMacro[] indexMacros =
- fContext.getIndex().findMacros(binding.getNameCharArray(), IndexFilter.ALL, null);
+ IIndexMacro[] indexMacros = fContext.getIndex().findMacros(binding.getNameCharArray(),
+ IndexFilter.ALL, null);
Collections.addAll(newBindings, indexMacros);
} catch (CoreException e) {
}
@@ -1255,7 +1253,7 @@ public class BindingClassifier {
if (owner != null)
newBindings.add(owner);
} else if (binding instanceof ICPPMethod) {
- newBindings.add(binding); // Include the method in case we need its inline definition.
+ newBindings.add(binding); // Include the method in case we need its inline definition.
if (binding instanceof ICPPConstructor)
newBindings.add(binding.getOwner());
} else if (binding instanceof IType) {
@@ -1287,7 +1285,7 @@ public class BindingClassifier {
if (!fProcessedDeclaredBindings.add(binding))
return;
if (isDeclaredLocally(binding))
- return; // Declared locally.
+ return; // Declared locally.
if (!canForwardDeclare(binding)) {
defineBinding(binding);
return;
@@ -1296,12 +1294,11 @@ public class BindingClassifier {
Collection<IBinding> requiredBindings = getRequiredBindings(binding);
for (IBinding requiredBinding : requiredBindings) {
- if (fBindingsToForwardDeclare.contains(requiredBinding) ||
- fBindingsToDefine.contains(requiredBinding)) {
+ if (fBindingsToForwardDeclare.contains(requiredBinding) || fBindingsToDefine.contains(requiredBinding)) {
return;
}
if (isDeclaredLocally(requiredBinding) || isDefinedLocally(requiredBinding)) {
- return; // Declared or defined locally.
+ return; // Declared or defined locally.
}
if (canForwardDeclare(requiredBinding)) {
@@ -1326,10 +1323,12 @@ public class BindingClassifier {
private boolean canForwardDeclare(IBinding binding) {
boolean canDeclare = false;
if (binding instanceof IProblemBinding && ((IProblemBinding) binding).getCandidateBindings().length != 0) {
- return true; // Return true to consider delegates later on.
- } if (binding instanceof ICPPUsingDeclaration) {
- return true; // Return true to consider delegates later on.
- } if (binding instanceof ICompositeType) {
+ return true; // Return true to consider delegates later on.
+ }
+ if (binding instanceof ICPPUsingDeclaration) {
+ return true; // Return true to consider delegates later on.
+ }
+ if (binding instanceof ICompositeType) {
canDeclare = fPreferences.forwardDeclareCompositeTypes;
} else if (binding instanceof IEnumeration) {
canDeclare = fPreferences.forwardDeclareEnums && isEnumerationWithoutFixedUnderlyingType(binding);
@@ -1340,8 +1339,8 @@ public class BindingClassifier {
canDeclare = fPreferences.forwardDeclareExternalVariables;
}
- if (canDeclare && !fPreferences.forwardDeclareTemplates &&
- (binding instanceof ICPPTemplateDefinition || binding instanceof ICPPSpecialization)) {
+ if (canDeclare && !fPreferences.forwardDeclareTemplates
+ && (binding instanceof ICPPTemplateDefinition || binding instanceof ICPPSpecialization)) {
canDeclare = false;
}
return canDeclare;
@@ -1354,8 +1353,8 @@ public class BindingClassifier {
IBinding binding = getTypeBinding(type);
if (binding == null)
return false;
- if (!fPreferences.assumeTemplatesMayBeForwardDeclared &&
- (binding instanceof ICPPTemplateDefinition || binding instanceof ICPPSpecialization)) {
+ if (!fPreferences.assumeTemplatesMayBeForwardDeclared
+ && (binding instanceof ICPPTemplateDefinition || binding instanceof ICPPSpecialization)) {
return false;
}
if (binding instanceof ICompositeType)
@@ -1390,7 +1389,7 @@ public class BindingClassifier {
if (!markAsDefined(binding))
return;
if (isDefinedLocally(binding))
- return; // Defined locally.
+ return; // Defined locally.
Collection<IBinding> requiredBindings = getRequiredBindings(binding);
for (IBinding requiredBinding : requiredBindings) {
@@ -1399,7 +1398,7 @@ public class BindingClassifier {
if (!markAsDefined(requiredBinding))
continue;
if (isDefinedLocally(requiredBinding))
- continue; // Defined locally.
+ continue; // Defined locally.
}
fBindingsToDefine.add(requiredBinding);
}
@@ -1458,8 +1457,7 @@ public class BindingClassifier {
return true;
}
- private void defineForFunctionCall(IFunction function, boolean defineFunction,
- IASTInitializerClause[] arguments) {
+ private void defineForFunctionCall(IFunction function, boolean defineFunction, IASTInitializerClause[] arguments) {
if (defineFunction) {
if (!fProcessedDefinedBindings.contains(function)) {
if (!(function instanceof ICPPMethod)
@@ -1471,7 +1469,7 @@ public class BindingClassifier {
declareBinding(function);
}
}
-
+
// Handle return or expression type of the function or constructor call.
IType returnType = function.getType().getReturnType();
defineTypeForBinding(function, returnType);
@@ -1498,8 +1496,8 @@ public class BindingClassifier {
}
private boolean canBeIncluded(IIndexFile indexFile) throws CoreException {
- return !IncludeUtil.isSource(indexFile, fContext.getProject()) ||
- fContext.getIndex().findIncludedBy(indexFile, 0).length != 0;
+ return !IncludeUtil.isSource(indexFile, fContext.getProject())
+ || fContext.getIndex().findIncludedBy(indexFile, 0).length != 0;
}
private void defineTypeForBinding(IBinding binding, IType type) {
@@ -1512,7 +1510,7 @@ public class BindingClassifier {
/**
* For a pointer or a reference type, defines the contained type. For an instance of a template
- * allowing incomplete argument types, defines the argument type.
+ * allowing incomplete argument types, defines the argument type.
*/
private void defineIndirectTypes(IType type) {
IType resolvedType = removeQualifiers(resolveTypedef(type));
@@ -1623,8 +1621,8 @@ public class BindingClassifier {
if (template instanceof IProblemBinding)
return true;
IBinding owner = template.getOwner();
- if (!(owner instanceof ICPPNamespace) ||
- !CharArrayUtils.equals(owner.getNameCharArray(), STD) || owner.getOwner() != null) {
+ if (!(owner instanceof ICPPNamespace) || !CharArrayUtils.equals(owner.getNameCharArray(), STD)
+ || owner.getOwner() != null) {
return true;
}
if (!isTemplateAllowingIncompleteArgumentType(template))
@@ -1656,8 +1654,8 @@ public class BindingClassifier {
}
private static boolean isEnumerationWithoutFixedUnderlyingType(IBinding typeBinding) {
- return typeBinding instanceof IEnumeration
- && (!(typeBinding instanceof ICPPEnumeration) || ((ICPPEnumeration) typeBinding).getFixedType() == null);
+ return typeBinding instanceof IEnumeration && (!(typeBinding instanceof ICPPEnumeration)
+ || ((ICPPEnumeration) typeBinding).getFixedType() == null);
}
private static boolean isPartOfExternalMacroDefinition(IASTNode node) {
@@ -1685,7 +1683,7 @@ public class BindingClassifier {
* Returns the declaration specifier node for the given declarator.
*/
private static IASTDeclSpecifier getDeclarationSpecifier(IASTDeclarator declarator) {
- declarator= CPPVisitor.findOutermostDeclarator(declarator);
+ declarator = CPPVisitor.findOutermostDeclarator(declarator);
IASTNode parent = declarator.getParent();
IASTDeclSpecifier declSpec = null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/GCCHeaderSubstitutionMaps.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/GCCHeaderSubstitutionMaps.java
index a9d5f518214..1de9b064064 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/GCCHeaderSubstitutionMaps.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/GCCHeaderSubstitutionMaps.java
@@ -18,482 +18,170 @@ import java.util.List;
public class GCCHeaderSubstitutionMaps {
@SuppressWarnings("nls")
- private static final String[] symbolExportMap = new String[] {
- "EOF", "<stdio.h>",
- "EOF", "<cstdio>",
- "EOF", "<libio.h>",
- "NULL", "<stddef.h>",
- "NULL", "<cstddef>",
- "NULL", "<stdlib.h>",
- "NULL", "<cstdlib>",
- "NULL", "<stdio.h>",
- "NULL", "<cstdio>",
- "NULL", "<string.h>",
- "NULL", "<cstring>",
- "NULL", "<string>",
- "NULL", "<wchar.h>",
- "NULL", "<cwchar>",
- "NULL", "<locale.h>",
- "NULL", "<time.h>",
- "NULL", "<ctime>",
- "blkcnt_t", "<sys/stat.h>",
- "blkcnt_t", "<sys/types.h>",
- "blksize_t", "<sys/types.h>",
- "blksize_t", "<sys/stat.h>",
- "calloc", "<stdlib.h>",
- "calloc", "<cstdlib>",
- "daddr_t", "<sys/types.h>",
- "daddr_t", "<rpc/types.h>",
- "dev_t", "<sys/types.h>",
- "dev_t", "<sys/stat.h>",
- "error_t", "<errno.h>",
- "error_t", "<argp.h>",
- "error_t", "<argz.h>",
- "free", "<stdlib.h>",
- "free", "<cstdlib>",
- "fsblkcnt_t", "<sys/types.h>",
- "fsblkcnt_t", "<sys/statvfs.h>",
- "fsfilcnt_t", "<sys/types.h>",
- "fsfilcnt_t", "<sys/statvfs.h>",
- "gid_t", "<sys/types.h>",
- "gid_t", "<grp.h>",
- "gid_t", "<pwd.h>",
- "gid_t", "<stropts.h>",
- "gid_t", "<sys/ipc.h>",
- "gid_t", "<sys/stat.h>",
- "gid_t", "<unistd.h>",
- "id_t", "<sys/types.h>",
- "id_t", "<sys/resource.h>",
- "ino64_t", "<sys/types.h>",
- "ino64_t", "<dirent.h>",
- "ino_t", "<sys/types.h>",
- "ino_t", "<dirent.h>",
- "ino_t", "<sys/stat.h>",
- "int8_t", "<sys/types.h>",
- "int8_t", "<stdint.h>",
- "intptr_t", "<stdint.h>",
- "intptr_t", "<unistd.h>",
- "key_t", "<sys/types.h>",
- "key_t", "<sys/ipc.h>",
- "malloc", "<stdlib.h>",
- "malloc", "<cstdlib>",
- "mode_t", "<sys/types.h>",
- "mode_t", "<sys/stat.h>",
- "mode_t", "<sys/ipc.h>",
- "mode_t", "<sys/mman.h>",
- "nlink_t", "<sys/types.h>",
- "nlink_t", "<sys/stat.h>",
- "off64_t", "<sys/types.h>",
- "off64_t", "<unistd.h>",
- "off_t", "<sys/types.h>",
- "off_t", "<unistd.h>",
- "off_t", "<sys/stat.h>",
- "off_t", "<sys/mman.h>",
- "pid_t", "<sys/types.h>",
- "pid_t", "<unistd.h>",
- "pid_t", "<signal.h>",
- "pid_t", "<sys/msg.h>",
- "pid_t", "<sys/shm.h>",
- "pid_t", "<termios.h>",
- "pid_t", "<time.h>",
- "pid_t", "<ctime>",
- "pid_t", "<utmpx.h>",
- "realloc", "<stdlib.h>",
- "realloc", "<cstdlib>",
- "sigset_t", "<signal.h>",
- "sigset_t", "<sys/epoll.h>",
- "sigset_t", "<sys/select.h>",
- "size_t", "<stddef.h>",
- "size_t", "<cstddef>",
- "socklen_t", "<bits/socket.h>",
- "socklen_t", "<unistd.h>",
- "socklen_t", "<arpa/inet.h>",
- "ssize_t", "<sys/types.h>",
- "ssize_t", "<unistd.h>",
- "ssize_t", "<monetary.h>",
- "ssize_t", "<sys/msg.h>",
- "std::allocator", "<memory>",
- "std::allocator", "<string>",
- "std::allocator", "<vector>",
- "std::allocator", "<map>",
- "std::allocator", "<set>",
- "std::char_traits", "<string>",
- "std::char_traits", "<ostream>",
- "std::char_traits", "<istream>",
- "std::swap", "<bits/move.h>",
- "suseconds_t", "<sys/types.h>",
- "suseconds_t", "<sys/time.h>",
- "suseconds_t", "<sys/select.h>",
- "u_char", "<sys/types.h>",
- "u_char", "<rpc/types.h>",
- "uid_t", "<sys/types.h>",
- "uid_t", "<unistd.h>",
- "uid_t", "<pwd.h>",
- "uid_t", "<signal.h>",
- "uid_t", "<stropts.h>",
- "uid_t", "<sys/ipc.h>",
- "uid_t", "<sys/stat.h>",
- "useconds_t", "<sys/types.h>",
- "useconds_t", "<unistd.h>",
- "va_list", "<stdarg.h>",
- "va_list", "<cstdarg>",
- };
+ private static final String[] symbolExportMap = new String[] { "EOF", "<stdio.h>", "EOF", "<cstdio>", "EOF",
+ "<libio.h>", "NULL", "<stddef.h>", "NULL", "<cstddef>", "NULL", "<stdlib.h>", "NULL", "<cstdlib>", "NULL",
+ "<stdio.h>", "NULL", "<cstdio>", "NULL", "<string.h>", "NULL", "<cstring>", "NULL", "<string>", "NULL",
+ "<wchar.h>", "NULL", "<cwchar>", "NULL", "<locale.h>", "NULL", "<time.h>", "NULL", "<ctime>", "blkcnt_t",
+ "<sys/stat.h>", "blkcnt_t", "<sys/types.h>", "blksize_t", "<sys/types.h>", "blksize_t", "<sys/stat.h>",
+ "calloc", "<stdlib.h>", "calloc", "<cstdlib>", "daddr_t", "<sys/types.h>", "daddr_t", "<rpc/types.h>",
+ "dev_t", "<sys/types.h>", "dev_t", "<sys/stat.h>", "error_t", "<errno.h>", "error_t", "<argp.h>", "error_t",
+ "<argz.h>", "free", "<stdlib.h>", "free", "<cstdlib>", "fsblkcnt_t", "<sys/types.h>", "fsblkcnt_t",
+ "<sys/statvfs.h>", "fsfilcnt_t", "<sys/types.h>", "fsfilcnt_t", "<sys/statvfs.h>", "gid_t", "<sys/types.h>",
+ "gid_t", "<grp.h>", "gid_t", "<pwd.h>", "gid_t", "<stropts.h>", "gid_t", "<sys/ipc.h>", "gid_t",
+ "<sys/stat.h>", "gid_t", "<unistd.h>", "id_t", "<sys/types.h>", "id_t", "<sys/resource.h>", "ino64_t",
+ "<sys/types.h>", "ino64_t", "<dirent.h>", "ino_t", "<sys/types.h>", "ino_t", "<dirent.h>", "ino_t",
+ "<sys/stat.h>", "int8_t", "<sys/types.h>", "int8_t", "<stdint.h>", "intptr_t", "<stdint.h>", "intptr_t",
+ "<unistd.h>", "key_t", "<sys/types.h>", "key_t", "<sys/ipc.h>", "malloc", "<stdlib.h>", "malloc",
+ "<cstdlib>", "mode_t", "<sys/types.h>", "mode_t", "<sys/stat.h>", "mode_t", "<sys/ipc.h>", "mode_t",
+ "<sys/mman.h>", "nlink_t", "<sys/types.h>", "nlink_t", "<sys/stat.h>", "off64_t", "<sys/types.h>",
+ "off64_t", "<unistd.h>", "off_t", "<sys/types.h>", "off_t", "<unistd.h>", "off_t", "<sys/stat.h>", "off_t",
+ "<sys/mman.h>", "pid_t", "<sys/types.h>", "pid_t", "<unistd.h>", "pid_t", "<signal.h>", "pid_t",
+ "<sys/msg.h>", "pid_t", "<sys/shm.h>", "pid_t", "<termios.h>", "pid_t", "<time.h>", "pid_t", "<ctime>",
+ "pid_t", "<utmpx.h>", "realloc", "<stdlib.h>", "realloc", "<cstdlib>", "sigset_t", "<signal.h>", "sigset_t",
+ "<sys/epoll.h>", "sigset_t", "<sys/select.h>", "size_t", "<stddef.h>", "size_t", "<cstddef>", "socklen_t",
+ "<bits/socket.h>", "socklen_t", "<unistd.h>", "socklen_t", "<arpa/inet.h>", "ssize_t", "<sys/types.h>",
+ "ssize_t", "<unistd.h>", "ssize_t", "<monetary.h>", "ssize_t", "<sys/msg.h>", "std::allocator", "<memory>",
+ "std::allocator", "<string>", "std::allocator", "<vector>", "std::allocator", "<map>", "std::allocator",
+ "<set>", "std::char_traits", "<string>", "std::char_traits", "<ostream>", "std::char_traits", "<istream>",
+ "std::swap", "<bits/move.h>", "suseconds_t", "<sys/types.h>", "suseconds_t", "<sys/time.h>", "suseconds_t",
+ "<sys/select.h>", "u_char", "<sys/types.h>", "u_char", "<rpc/types.h>", "uid_t", "<sys/types.h>", "uid_t",
+ "<unistd.h>", "uid_t", "<pwd.h>", "uid_t", "<signal.h>", "uid_t", "<stropts.h>", "uid_t", "<sys/ipc.h>",
+ "uid_t", "<sys/stat.h>", "useconds_t", "<sys/types.h>", "useconds_t", "<unistd.h>", "va_list", "<stdarg.h>",
+ "va_list", "<cstdarg>", };
@SuppressWarnings("nls")
- private static final String[] cIncludeMap = new String[] {
- "<asm/errno-base.h>", "<errno.h>",
- "<asm/errno.h>", "<errno.h>",
- "<asm/ioctls.h>", "<sys/ioctl.h>",
- "<asm/posix_types_32.h>", "<asm/posix_types.h>",
- "<asm/posix_types_64.h>", "<asm/posix_types.h>",
- "<asm/ptrace-abi.h>", "<asm/ptrace.h>",
- "<asm/socket.h>", "<sys/socket.h>",
- "<asm/unistd.h>", "<syscall.h>",
- "<asm/unistd_32.h>", "<syscall.h>",
- "<asm/unistd_64.h>", "<syscall.h>",
- "<bits/a.out.h>", "<a.out.h>",
- "<bits/byteswap.h>", "<byteswap.h>",
- "<bits/cmathcalls.h>", "<complex.h>",
- "<bits/confname.h>", "<unistd.h>",
- "<bits/dirent.h>", "<dirent.h>",
- "<bits/dlfcn.h>", "<dlfcn.h>",
- "<bits/elfclass.h>", "<link.h>",
- "<bits/endian.h>", "<endian.h>",
- "<bits/environments.h>", "<unistd.h>",
- "<bits/errno.h>", "<errno.h>",
- "<bits/error.h>", "<error.h>",
- "<bits/fcntl.h>", "<fcntl.h>",
- "<bits/fcntl2.h>", "<fcntl.h>",
- "<bits/fcntl-linux.h>", "<fcntl.h>",
- "<bits/fenv.h>", "<fenv.h>",
- "<bits/fenvinline.h>", "<fenv.h>",
- "<bits/huge_val.h>", "<math.h>",
- "<bits/huge_valf.h>", "<math.h>",
- "<bits/huge_vall.h>", "<math.h>",
- "<bits/in.h>", "<netinet/in.h>",
- "<bits/inf.h>", "<math.h>",
- "<bits/ioctl-types.h>", "<sys/ioctl.h>",
- "<bits/ioctls.h>", "<sys/ioctl.h>",
- "<bits/ipc.h>", "<sys/ipc.h>",
- "<bits/ipctypes.h>", "<sys/ipc.h>",
- "<bits/libio-ldbl.h>", "<libio.h>",
- "<bits/link.h>", "<link.h>",
- "<bits/locale.h>", "<locale.h>",
- "<bits/mathcalls.h>", "<math.h>",
- "<bits/mathdef.h>", "<math.h>",
- "<bits/mathinline.h>", "<math.h>",
- "<bits/mman.h>", "<sys/mman.h>",
- "<bits/monetary-ldbl.h>", "<monetary.h>",
- "<bits/mqueue.h>", "<mqueue.h>",
- "<bits/mqueue2.h>", "<mqueue.h>",
- "<bits/msq.h>", "<sys/msg.h>",
- "<bits/nan.h>", "<math.h>",
- "<bits/netdb.h>", "<netdb.h>",
- "<bits/poll.h>", "<poll.h>",
- "<bits/posix1_lim.h>", "<limits.h>",
- "<bits/posix2_lim.h>", "<limits.h>",
- "<bits/posix_opt.h>", "<unistd.h>",
- "<bits/predefs.h>", "<features.h>",
- "<bits/printf-ldbl.h>", "<printf.h>",
- "<bits/pthreadtypes.h>", "<pthread.h>",
- "<bits/resource.h>", "<sys/resource.h>",
- "<bits/sched.h>", "<sched.h>",
- "<bits/select.h>", "<sys/select.h>",
- "<bits/sem.h>", "<sys/sem.h>",
- "<bits/semaphore.h>", "<semaphore.h>",
- "<bits/setjmp.h>", "<setjmp.h>",
- "<bits/shm.h>", "<sys/shm.h>",
- "<bits/sigaction.h>", "<signal.h>",
- "<bits/sigcontext.h>", "<signal.h>",
- "<bits/siginfo.h>", "<signal.h>",
- "<bits/signum.h>", "<signal.h>",
- "<bits/sigset.h>", "<signal.h>",
- "<bits/sigstack.h>", "<signal.h>",
- "<bits/sigthread.h>", "<signal.h>",
- "<bits/sockaddr.h>", "<sys/un.h>",
- "<bits/socket.h>", "<sys/socket.h>",
- "<bits/stab.def>", "<stab.h>",
- "<bits/stat.h>", "<sys/stat.h>",
- "<bits/statfs.h>", "<sys/statfs.h>",
- "<bits/statvfs.h>", "<sys/statvfs.h>",
- "<bits/stdio-ldbl.h>", "<stdio.h>",
- "<bits/stdio-lock.h>", "<libio.h>",
- "<bits/stdio.h>", "<stdio.h>",
- "<bits/stdio2.h>", "<stdio.h>",
- "<bits/stdio_lim.h>", "<stdio.h>",
- "<bits/stdlib-ldbl.h>", "<stdlib.h>",
- "<bits/stdlib.h>", "<stdlib.h>",
- "<bits/string.h>", "<string.h>",
- "<bits/string2.h>", "<string.h>",
- "<bits/string3.h>", "<string.h>",
- "<bits/stropts.h>", "<stropts.h>",
- "<bits/sys_errlist.h>", "<stdio.h>",
- "<bits/syscall.h>", "<syscall.h>",
- "<bits/syslog-ldbl.h>", "<syslog.h>",
- "<bits/syslog-path.h>", "<syslog.h>",
- "<bits/syslog.h>", "<syslog.h>",
- "<bits/termios.h>", "<termios.h>",
- "<bits/time.h>", "<sys/time.h>",
- "<bits/types.h>", "<sys/types.h>",
- "<bits/uio.h>", "<sys/uio.h>",
- "<bits/unistd.h>", "<unistd.h>",
- "<bits/ustat.h>", "<ustat.h>",
- "<bits/utmp.h>", "<utmp.h>",
- "<bits/utmpx.h>", "<utmpx.h>",
- "<bits/utsname.h>", "<sys/utsname.h>",
- "<bits/waitflags.h>", "<sys/wait.h>",
- "<bits/waitstatus.h>", "<sys/wait.h>",
- "<bits/wchar-ldbl.h>", "<wchar.h>",
- "<bits/wchar.h>", "<wchar.h>",
- "<bits/wchar2.h>", "<wchar.h>",
- "<bits/xopen_lim.h>", "<limits.h>",
- "<bits/xtitypes.h>", "<stropts.h>",
- "<linux/errno.h>", "<errno.h>",
- "<linux/limits.h>", "<limits.h>",
- "<linux/socket.h>", "<sys/socket.h>",
- "<sys/poll.h>", "<poll.h>",
- "<sys/syscall.h>", "<syscall.h>",
- "<sys/syslog.h>", "<syslog.h>",
- "<sys/ucontext.h>", "<ucontext.h>",
- "<sys/ustat.h>", "<ustat.h>",
- "<wait.h>", "<sys/wait.h>",
- };
+ private static final String[] cIncludeMap = new String[] { "<asm/errno-base.h>", "<errno.h>", "<asm/errno.h>",
+ "<errno.h>", "<asm/ioctls.h>", "<sys/ioctl.h>", "<asm/posix_types_32.h>", "<asm/posix_types.h>",
+ "<asm/posix_types_64.h>", "<asm/posix_types.h>", "<asm/ptrace-abi.h>", "<asm/ptrace.h>", "<asm/socket.h>",
+ "<sys/socket.h>", "<asm/unistd.h>", "<syscall.h>", "<asm/unistd_32.h>", "<syscall.h>", "<asm/unistd_64.h>",
+ "<syscall.h>", "<bits/a.out.h>", "<a.out.h>", "<bits/byteswap.h>", "<byteswap.h>", "<bits/cmathcalls.h>",
+ "<complex.h>", "<bits/confname.h>", "<unistd.h>", "<bits/dirent.h>", "<dirent.h>", "<bits/dlfcn.h>",
+ "<dlfcn.h>", "<bits/elfclass.h>", "<link.h>", "<bits/endian.h>", "<endian.h>", "<bits/environments.h>",
+ "<unistd.h>", "<bits/errno.h>", "<errno.h>", "<bits/error.h>", "<error.h>", "<bits/fcntl.h>", "<fcntl.h>",
+ "<bits/fcntl2.h>", "<fcntl.h>", "<bits/fcntl-linux.h>", "<fcntl.h>", "<bits/fenv.h>", "<fenv.h>",
+ "<bits/fenvinline.h>", "<fenv.h>", "<bits/huge_val.h>", "<math.h>", "<bits/huge_valf.h>", "<math.h>",
+ "<bits/huge_vall.h>", "<math.h>", "<bits/in.h>", "<netinet/in.h>", "<bits/inf.h>", "<math.h>",
+ "<bits/ioctl-types.h>", "<sys/ioctl.h>", "<bits/ioctls.h>", "<sys/ioctl.h>", "<bits/ipc.h>", "<sys/ipc.h>",
+ "<bits/ipctypes.h>", "<sys/ipc.h>", "<bits/libio-ldbl.h>", "<libio.h>", "<bits/link.h>", "<link.h>",
+ "<bits/locale.h>", "<locale.h>", "<bits/mathcalls.h>", "<math.h>", "<bits/mathdef.h>", "<math.h>",
+ "<bits/mathinline.h>", "<math.h>", "<bits/mman.h>", "<sys/mman.h>", "<bits/monetary-ldbl.h>",
+ "<monetary.h>", "<bits/mqueue.h>", "<mqueue.h>", "<bits/mqueue2.h>", "<mqueue.h>", "<bits/msq.h>",
+ "<sys/msg.h>", "<bits/nan.h>", "<math.h>", "<bits/netdb.h>", "<netdb.h>", "<bits/poll.h>", "<poll.h>",
+ "<bits/posix1_lim.h>", "<limits.h>", "<bits/posix2_lim.h>", "<limits.h>", "<bits/posix_opt.h>",
+ "<unistd.h>", "<bits/predefs.h>", "<features.h>", "<bits/printf-ldbl.h>", "<printf.h>",
+ "<bits/pthreadtypes.h>", "<pthread.h>", "<bits/resource.h>", "<sys/resource.h>", "<bits/sched.h>",
+ "<sched.h>", "<bits/select.h>", "<sys/select.h>", "<bits/sem.h>", "<sys/sem.h>", "<bits/semaphore.h>",
+ "<semaphore.h>", "<bits/setjmp.h>", "<setjmp.h>", "<bits/shm.h>", "<sys/shm.h>", "<bits/sigaction.h>",
+ "<signal.h>", "<bits/sigcontext.h>", "<signal.h>", "<bits/siginfo.h>", "<signal.h>", "<bits/signum.h>",
+ "<signal.h>", "<bits/sigset.h>", "<signal.h>", "<bits/sigstack.h>", "<signal.h>", "<bits/sigthread.h>",
+ "<signal.h>", "<bits/sockaddr.h>", "<sys/un.h>", "<bits/socket.h>", "<sys/socket.h>", "<bits/stab.def>",
+ "<stab.h>", "<bits/stat.h>", "<sys/stat.h>", "<bits/statfs.h>", "<sys/statfs.h>", "<bits/statvfs.h>",
+ "<sys/statvfs.h>", "<bits/stdio-ldbl.h>", "<stdio.h>", "<bits/stdio-lock.h>", "<libio.h>", "<bits/stdio.h>",
+ "<stdio.h>", "<bits/stdio2.h>", "<stdio.h>", "<bits/stdio_lim.h>", "<stdio.h>", "<bits/stdlib-ldbl.h>",
+ "<stdlib.h>", "<bits/stdlib.h>", "<stdlib.h>", "<bits/string.h>", "<string.h>", "<bits/string2.h>",
+ "<string.h>", "<bits/string3.h>", "<string.h>", "<bits/stropts.h>", "<stropts.h>", "<bits/sys_errlist.h>",
+ "<stdio.h>", "<bits/syscall.h>", "<syscall.h>", "<bits/syslog-ldbl.h>", "<syslog.h>",
+ "<bits/syslog-path.h>", "<syslog.h>", "<bits/syslog.h>", "<syslog.h>", "<bits/termios.h>", "<termios.h>",
+ "<bits/time.h>", "<sys/time.h>", "<bits/types.h>", "<sys/types.h>", "<bits/uio.h>", "<sys/uio.h>",
+ "<bits/unistd.h>", "<unistd.h>", "<bits/ustat.h>", "<ustat.h>", "<bits/utmp.h>", "<utmp.h>",
+ "<bits/utmpx.h>", "<utmpx.h>", "<bits/utsname.h>", "<sys/utsname.h>", "<bits/waitflags.h>", "<sys/wait.h>",
+ "<bits/waitstatus.h>", "<sys/wait.h>", "<bits/wchar-ldbl.h>", "<wchar.h>", "<bits/wchar.h>", "<wchar.h>",
+ "<bits/wchar2.h>", "<wchar.h>", "<bits/xopen_lim.h>", "<limits.h>", "<bits/xtitypes.h>", "<stropts.h>",
+ "<linux/errno.h>", "<errno.h>", "<linux/limits.h>", "<limits.h>", "<linux/socket.h>", "<sys/socket.h>",
+ "<sys/poll.h>", "<poll.h>", "<sys/syscall.h>", "<syscall.h>", "<sys/syslog.h>", "<syslog.h>",
+ "<sys/ucontext.h>", "<ucontext.h>", "<sys/ustat.h>", "<ustat.h>", "<wait.h>", "<sys/wait.h>", };
- private static final String[] cIncludeMapWeak = new String[] {
- };
+ private static final String[] cIncludeMapWeak = new String[] {};
@SuppressWarnings("nls")
- private static final String[] cppIncludeMap = new String[] {
- "<auto_ptr.h>", "<memory>",
- "<backward/auto_ptr.h>", "<memory>",
- "<backward/binders.h>", "<functional>",
- "<backward/hash_fun.h>", "<hash_map>",
- "<backward/hash_fun.h>", "<hash_set>",
- "<backward/hashtable.h>", "<hash_map>",
- "<backward/hashtable.h>", "<hash_set>",
- "<backward/strstream>", "<strstream>",
- "<binders.h>", "<functional>",
- "<bits/algorithmfwd.h>", "<algorithm>",
- "<bits/allocator.h>", "<memory>",
- "<bits/atomic_word.h>", "<ext/atomicity.h>",
- "<bits/basic_file.h>", "<fstream>",
- "<bits/basic_ios.h>", "<ios>",
- "<bits/basic_string.h>", "<string>",
- "<bits/basic_string.tcc>", "<string>",
- "<bits/boost_concept_check.h>", "<bits/concept_check.h>",
- "<bits/boost_sp_shared_count.h>", "<memory>",
- "<bits/c++allocator.h>", "<memory>",
- "<bits/c++config.h>", "<cstddef>",
- "<bits/c++io.h>", "<ext/stdio_sync_filebuf.h>",
- "<bits/char_traits.h>", "<string>",
- "<bits/cmath.tcc>", "<cmath>",
- "<bits/codecvt.h>", "<fstream>",
- "<bits/codecvt.h>", "<locale>",
- "<bits/ctype_base.h>", "<locale>",
- "<bits/ctype_base.h>", "<ios>",
- "<bits/ctype_inline.h>", "<locale>",
- "<bits/ctype_inline.h>", "<ios>",
- "<bits/cxxabi_tweaks.h>", "<cxxabi.h>",
- "<bits/deque.tcc>", "<deque>",
- "<bits/exception_defines.h>", "<exception>",
- "<bits/fstream.tcc>", "<fstream>",
- "<bits/functexcept.h>", "<algorithm>",
- "<bits/functional_hash.h>", "<unordered_map>",
- "<bits/gslice.h>", "<valarray>",
- "<bits/gslice_array.h>", "<valarray>",
- "<bits/hashtable.h>", "<unordered_map>",
- "<bits/hashtable.h>", "<unordered_set>",
- "<bits/indirect_array.h>", "<valarray>",
- "<bits/ios_base.h>", "<ios>",
- "<bits/ios_base.h>", "<iostream>",
- "<bits/ios_base.h>", "<iomanip>",
- "<bits/istream.tcc>", "<istream>",
- "<bits/list.tcc>", "<list>",
- "<bits/locale_classes.h>", "<locale>",
- "<bits/locale_classes.h>", "<ios>",
- "<bits/locale_classes.tcc>", "<locale>",
- "<bits/locale_classes.tcc>", "<ios>",
- "<bits/locale_facets.h>", "<locale>",
- "<bits/locale_facets.h>", "<ios>",
- "<bits/locale_facets.tcc>", "<locale>",
- "<bits/locale_facets.tcc>", "<ios>",
- "<bits/locale_facets_nonio.h>", "<locale>",
- "<bits/locale_facets_nonio.tcc>", "<locale>",
- "<bits/localefwd.h>", "<locale>",
- "<bits/mask_array.h>", "<valarray>",
- "<bits/messages_members.h>", "<locale>",
- "<bits/move.h>", "<algorithm>",
- "<bits/ostream.tcc>", "<ostream>",
- "<bits/ostream_insert.h>", "<ostream>",
- "<bits/postypes.h>", "<iostream>",
- "<bits/postypes.h>", "<string>",
- "<bits/shared_ptr.h>", "<memory>",
- "<bits/slice_array.h>", "<valarray>",
- "<bits/sstream.tcc>", "<sstream>",
- "<bits/stl_algo.h>", "<algorithm>",
- "<bits/stl_algobase.h>", "<algorithm>",
- "<bits/stl_bvector.h>", "<vector>",
- "<bits/stl_construct.h>", "<memory>",
- "<bits/stl_deque.h>", "<deque>",
- "<bits/stl_function.h>", "<functional>",
- "<bits/stl_heap.h>", "<queue>",
- "<bits/stl_iterator.h>", "<iterator>",
- "<bits/stl_iterator_base_funcs.h>", "<iterator>",
- "<bits/stl_iterator_base_types.h>", "<iterator>",
- "<bits/stl_list.h>", "<list>",
- "<bits/stl_map.h>", "<map>",
- "<bits/stl_move.h>", "<algorithm>",
- "<bits/stl_multimap.h>", "<map>",
- "<bits/stl_multiset.h>", "<set>",
- "<bits/stl_numeric.h>", "<numeric>",
- "<bits/stl_pair.h>", "<utility>",
- "<bits/stl_pair.h>", "<tr1/utility>",
- "<bits/stl_queue.h>", "<queue>",
- "<bits/stl_raw_storage_iter.h>", "<memory>",
- "<bits/stl_relops.h>", "<utility>",
- "<bits/stl_set.h>", "<set>",
- "<bits/stl_stack.h>", "<stack>",
- "<bits/stl_tempbuf.h>", "<memory>",
- "<bits/stl_tree.h>", "<map>",
- "<bits/stl_tree.h>", "<set>",
- "<bits/stl_uninitialized.h>", "<memory>",
- "<bits/stl_vector.h>", "<vector>",
- "<bits/stream_iterator.h>", "<iterator>",
- "<bits/streambuf.tcc>", "<streambuf>",
- "<bits/streambuf_iterator.h>", "<iterator>",
- "<bits/streambuf_iterator.h>", "<ios>",
- "<bits/stringfwd.h>", "<string>",
- "<bits/unique_ptr.h>", "<memory>",
- "<bits/valarray_after.h>", "<valarray>",
- "<bits/valarray_array.h>", "<valarray>",
- "<bits/valarray_array.tcc>", "<valarray>",
- "<bits/valarray_before.h>", "<valarray>",
- "<bits/vector.tcc>", "<vector>",
- "<debug/safe_iterator.tcc>", "<debug/safe_iterator.h>",
- "<exception_defines.h>", "<exception>",
- "<ext/algorithm>", "<algorithm>",
- "<ext/functional>", "<functional>",
- "<ext/hash_map>", "<hash_map>",
- "<ext/hash_set>", "<hash_set>",
- "<ext/numeric>", "<numeric>",
- "<ext/slist>", "<slist>",
- "<ext/sso_string_base.h>", "<string>",
- "<ext/vstring.h>", "<string>",
- "<ext/vstring.tcc>", "<string>",
- "<ext/vstring_fwd.h>", "<string>",
- "<hash_fun.h>", "<hash_map>",
- "<hash_fun.h>", "<hash_set>",
- "<hashtable.h>", "<hash_map>",
- "<hashtable.h>", "<hash_set>",
- "<tr1/bessel_function.tcc>", "<tr1/cmath>",
- "<tr1/beta_function.tcc>", "<tr1/cmath>",
- "<tr1/ell_integral.tcc>", "<tr1/cmath>",
- "<tr1/exp_integral.tcc>", "<tr1/cmath>",
- "<tr1/gamma.tcc>", "<tr1/cmath>",
- "<tr1/hypergeometric.tcc>", "<tr1/cmath>",
- "<tr1/legendre_function.tcc>", "<tr1/cmath>",
- "<tr1/modified_bessel_func.tcc>", "<tr1/cmath>",
- "<tr1/poly_hermite.tcc>", "<tr1/cmath>",
- "<tr1/poly_laguerre.tcc>", "<tr1/cmath>",
- "<tr1/riemann_zeta.tcc>", "<tr1/cmath>",
- "<tr1_impl/array>", "<array>",
- "<tr1_impl/array>", "<tr1/array>",
- "<tr1_impl/boost_shared_ptr.h>", "<memory>",
- "<tr1_impl/boost_shared_ptr.h>", "<tr1/memory>",
- "<tr1_impl/boost_sp_counted_base.h>", "<memory>",
- "<tr1_impl/boost_sp_counted_base.h>", "<tr1/memory>",
- "<tr1_impl/cctype>", "<cctype>",
- "<tr1_impl/cctype>", "<tr1/cctype>",
- "<tr1_impl/cfenv>", "<cfenv>",
- "<tr1_impl/cfenv>", "<tr1/cfenv>",
- "<tr1_impl/cinttypes>", "<cinttypes>",
- "<tr1_impl/cinttypes>", "<tr1/cinttypes>",
- "<tr1_impl/cmath>", "<cmath>",
- "<tr1_impl/cmath>", "<tr1/cmath>",
- "<tr1_impl/complex>", "<complex>",
- "<tr1_impl/complex>", "<tr1/complex>",
- "<tr1_impl/cstdint>", "<cstdint>",
- "<tr1_impl/cstdint>", "<tr1/cstdint>",
- "<tr1_impl/cstdio>", "<cstdio>",
- "<tr1_impl/cstdio>", "<tr1/cstdio>",
- "<tr1_impl/cstdlib>", "<cstdlib>",
- "<tr1_impl/cstdlib>", "<tr1/cstdlib>",
- "<tr1_impl/cwchar>", "<cwchar>",
- "<tr1_impl/cwchar>", "<tr1/cwchar>",
- "<tr1_impl/cwctype>", "<cwctype>",
- "<tr1_impl/cwctype>", "<tr1/cwctype>",
- "<tr1_impl/functional>", "<functional>",
- "<tr1_impl/functional>", "<tr1/functional>",
- "<tr1_impl/functional_hash.h>", "<tr1/functional_hash.h>",
- "<tr1_impl/hashtable>", "<tr1/hashtable.h>",
- "<tr1_impl/random.tcc>", "<random>",
- "<tr1_impl/random.tcc>", "<tr1/random>",
- "<tr1_impl/random>", "<random>",
- "<tr1_impl/random>", "<tr1/random>",
- "<tr1_impl/regex>", "<regex>",
- "<tr1_impl/regex>", "<tr1/regex>",
- "<tr1_impl/type_traits>", "<tr1/type_traits>",
- "<tr1_impl/type_traits>", "<type_traits>",
- "<tr1_impl/unordered_map>", "<tr1/unordered_map>",
- "<tr1_impl/unordered_map>", "<unordered_map>",
- "<tr1_impl/unordered_set>", "<tr1/unordered_set>",
- "<tr1_impl/unordered_set>", "<unordered_set>",
- "<tr1_impl/utility>", "<tr1/utility>",
- "<tr1_impl/utility>", "<utility>",
- };
+ private static final String[] cppIncludeMap = new String[] { "<auto_ptr.h>", "<memory>", "<backward/auto_ptr.h>",
+ "<memory>", "<backward/binders.h>", "<functional>", "<backward/hash_fun.h>", "<hash_map>",
+ "<backward/hash_fun.h>", "<hash_set>", "<backward/hashtable.h>", "<hash_map>", "<backward/hashtable.h>",
+ "<hash_set>", "<backward/strstream>", "<strstream>", "<binders.h>", "<functional>", "<bits/algorithmfwd.h>",
+ "<algorithm>", "<bits/allocator.h>", "<memory>", "<bits/atomic_word.h>", "<ext/atomicity.h>",
+ "<bits/basic_file.h>", "<fstream>", "<bits/basic_ios.h>", "<ios>", "<bits/basic_string.h>", "<string>",
+ "<bits/basic_string.tcc>", "<string>", "<bits/boost_concept_check.h>", "<bits/concept_check.h>",
+ "<bits/boost_sp_shared_count.h>", "<memory>", "<bits/c++allocator.h>", "<memory>", "<bits/c++config.h>",
+ "<cstddef>", "<bits/c++io.h>", "<ext/stdio_sync_filebuf.h>", "<bits/char_traits.h>", "<string>",
+ "<bits/cmath.tcc>", "<cmath>", "<bits/codecvt.h>", "<fstream>", "<bits/codecvt.h>", "<locale>",
+ "<bits/ctype_base.h>", "<locale>", "<bits/ctype_base.h>", "<ios>", "<bits/ctype_inline.h>", "<locale>",
+ "<bits/ctype_inline.h>", "<ios>", "<bits/cxxabi_tweaks.h>", "<cxxabi.h>", "<bits/deque.tcc>", "<deque>",
+ "<bits/exception_defines.h>", "<exception>", "<bits/fstream.tcc>", "<fstream>", "<bits/functexcept.h>",
+ "<algorithm>", "<bits/functional_hash.h>", "<unordered_map>", "<bits/gslice.h>", "<valarray>",
+ "<bits/gslice_array.h>", "<valarray>", "<bits/hashtable.h>", "<unordered_map>", "<bits/hashtable.h>",
+ "<unordered_set>", "<bits/indirect_array.h>", "<valarray>", "<bits/ios_base.h>", "<ios>",
+ "<bits/ios_base.h>", "<iostream>", "<bits/ios_base.h>", "<iomanip>", "<bits/istream.tcc>", "<istream>",
+ "<bits/list.tcc>", "<list>", "<bits/locale_classes.h>", "<locale>", "<bits/locale_classes.h>", "<ios>",
+ "<bits/locale_classes.tcc>", "<locale>", "<bits/locale_classes.tcc>", "<ios>", "<bits/locale_facets.h>",
+ "<locale>", "<bits/locale_facets.h>", "<ios>", "<bits/locale_facets.tcc>", "<locale>",
+ "<bits/locale_facets.tcc>", "<ios>", "<bits/locale_facets_nonio.h>", "<locale>",
+ "<bits/locale_facets_nonio.tcc>", "<locale>", "<bits/localefwd.h>", "<locale>", "<bits/mask_array.h>",
+ "<valarray>", "<bits/messages_members.h>", "<locale>", "<bits/move.h>", "<algorithm>", "<bits/ostream.tcc>",
+ "<ostream>", "<bits/ostream_insert.h>", "<ostream>", "<bits/postypes.h>", "<iostream>", "<bits/postypes.h>",
+ "<string>", "<bits/shared_ptr.h>", "<memory>", "<bits/slice_array.h>", "<valarray>", "<bits/sstream.tcc>",
+ "<sstream>", "<bits/stl_algo.h>", "<algorithm>", "<bits/stl_algobase.h>", "<algorithm>",
+ "<bits/stl_bvector.h>", "<vector>", "<bits/stl_construct.h>", "<memory>", "<bits/stl_deque.h>", "<deque>",
+ "<bits/stl_function.h>", "<functional>", "<bits/stl_heap.h>", "<queue>", "<bits/stl_iterator.h>",
+ "<iterator>", "<bits/stl_iterator_base_funcs.h>", "<iterator>", "<bits/stl_iterator_base_types.h>",
+ "<iterator>", "<bits/stl_list.h>", "<list>", "<bits/stl_map.h>", "<map>", "<bits/stl_move.h>",
+ "<algorithm>", "<bits/stl_multimap.h>", "<map>", "<bits/stl_multiset.h>", "<set>", "<bits/stl_numeric.h>",
+ "<numeric>", "<bits/stl_pair.h>", "<utility>", "<bits/stl_pair.h>", "<tr1/utility>", "<bits/stl_queue.h>",
+ "<queue>", "<bits/stl_raw_storage_iter.h>", "<memory>", "<bits/stl_relops.h>", "<utility>",
+ "<bits/stl_set.h>", "<set>", "<bits/stl_stack.h>", "<stack>", "<bits/stl_tempbuf.h>", "<memory>",
+ "<bits/stl_tree.h>", "<map>", "<bits/stl_tree.h>", "<set>", "<bits/stl_uninitialized.h>", "<memory>",
+ "<bits/stl_vector.h>", "<vector>", "<bits/stream_iterator.h>", "<iterator>", "<bits/streambuf.tcc>",
+ "<streambuf>", "<bits/streambuf_iterator.h>", "<iterator>", "<bits/streambuf_iterator.h>", "<ios>",
+ "<bits/stringfwd.h>", "<string>", "<bits/unique_ptr.h>", "<memory>", "<bits/valarray_after.h>",
+ "<valarray>", "<bits/valarray_array.h>", "<valarray>", "<bits/valarray_array.tcc>", "<valarray>",
+ "<bits/valarray_before.h>", "<valarray>", "<bits/vector.tcc>", "<vector>", "<debug/safe_iterator.tcc>",
+ "<debug/safe_iterator.h>", "<exception_defines.h>", "<exception>", "<ext/algorithm>", "<algorithm>",
+ "<ext/functional>", "<functional>", "<ext/hash_map>", "<hash_map>", "<ext/hash_set>", "<hash_set>",
+ "<ext/numeric>", "<numeric>", "<ext/slist>", "<slist>", "<ext/sso_string_base.h>", "<string>",
+ "<ext/vstring.h>", "<string>", "<ext/vstring.tcc>", "<string>", "<ext/vstring_fwd.h>", "<string>",
+ "<hash_fun.h>", "<hash_map>", "<hash_fun.h>", "<hash_set>", "<hashtable.h>", "<hash_map>", "<hashtable.h>",
+ "<hash_set>", "<tr1/bessel_function.tcc>", "<tr1/cmath>", "<tr1/beta_function.tcc>", "<tr1/cmath>",
+ "<tr1/ell_integral.tcc>", "<tr1/cmath>", "<tr1/exp_integral.tcc>", "<tr1/cmath>", "<tr1/gamma.tcc>",
+ "<tr1/cmath>", "<tr1/hypergeometric.tcc>", "<tr1/cmath>", "<tr1/legendre_function.tcc>", "<tr1/cmath>",
+ "<tr1/modified_bessel_func.tcc>", "<tr1/cmath>", "<tr1/poly_hermite.tcc>", "<tr1/cmath>",
+ "<tr1/poly_laguerre.tcc>", "<tr1/cmath>", "<tr1/riemann_zeta.tcc>", "<tr1/cmath>", "<tr1_impl/array>",
+ "<array>", "<tr1_impl/array>", "<tr1/array>", "<tr1_impl/boost_shared_ptr.h>", "<memory>",
+ "<tr1_impl/boost_shared_ptr.h>", "<tr1/memory>", "<tr1_impl/boost_sp_counted_base.h>", "<memory>",
+ "<tr1_impl/boost_sp_counted_base.h>", "<tr1/memory>", "<tr1_impl/cctype>", "<cctype>", "<tr1_impl/cctype>",
+ "<tr1/cctype>", "<tr1_impl/cfenv>", "<cfenv>", "<tr1_impl/cfenv>", "<tr1/cfenv>", "<tr1_impl/cinttypes>",
+ "<cinttypes>", "<tr1_impl/cinttypes>", "<tr1/cinttypes>", "<tr1_impl/cmath>", "<cmath>", "<tr1_impl/cmath>",
+ "<tr1/cmath>", "<tr1_impl/complex>", "<complex>", "<tr1_impl/complex>", "<tr1/complex>",
+ "<tr1_impl/cstdint>", "<cstdint>", "<tr1_impl/cstdint>", "<tr1/cstdint>", "<tr1_impl/cstdio>", "<cstdio>",
+ "<tr1_impl/cstdio>", "<tr1/cstdio>", "<tr1_impl/cstdlib>", "<cstdlib>", "<tr1_impl/cstdlib>",
+ "<tr1/cstdlib>", "<tr1_impl/cwchar>", "<cwchar>", "<tr1_impl/cwchar>", "<tr1/cwchar>", "<tr1_impl/cwctype>",
+ "<cwctype>", "<tr1_impl/cwctype>", "<tr1/cwctype>", "<tr1_impl/functional>", "<functional>",
+ "<tr1_impl/functional>", "<tr1/functional>", "<tr1_impl/functional_hash.h>", "<tr1/functional_hash.h>",
+ "<tr1_impl/hashtable>", "<tr1/hashtable.h>", "<tr1_impl/random.tcc>", "<random>", "<tr1_impl/random.tcc>",
+ "<tr1/random>", "<tr1_impl/random>", "<random>", "<tr1_impl/random>", "<tr1/random>", "<tr1_impl/regex>",
+ "<regex>", "<tr1_impl/regex>", "<tr1/regex>", "<tr1_impl/type_traits>", "<tr1/type_traits>",
+ "<tr1_impl/type_traits>", "<type_traits>", "<tr1_impl/unordered_map>", "<tr1/unordered_map>",
+ "<tr1_impl/unordered_map>", "<unordered_map>", "<tr1_impl/unordered_set>", "<tr1/unordered_set>",
+ "<tr1_impl/unordered_set>", "<unordered_set>", "<tr1_impl/utility>", "<tr1/utility>", "<tr1_impl/utility>",
+ "<utility>", };
@SuppressWarnings("nls")
- private static final String[] cppIncludeMapWeak = new String[] {
- "<assert.h>", "<cassert>",
- "<complex.h>", "<ccomplex>",
- "<ctype.h>", "<cctype>",
- "<errno.h>", "<cerrno>",
- "<fenv.h>", "<cfenv>",
- "<float.h>", "<cfloat>",
- "<inttypes.h>", "<cinttypes>",
- "<iso646.h>", "<ciso646>",
- "<limits.h>", "<climits>",
- "<locale.h>", "<clocale>",
- "<math.h>", "<cmath>",
- "<setjmp.h>", "<csetjmp>",
- "<signal.h>", "<csignal>",
- "<stdalign.h", "<cstdalign>",
- "<stdarg.h>", "<cstdarg>",
- "<stdbool.h>", "<cstdbool>",
- "<stddef.h>", "<cstddef>",
- "<stdint.h>", "<cstdint>",
- "<stdio.h>", "<cstdio>",
- "<stdlib.h>", "<cstdlib>",
- "<string.h>", "<cstring>",
- "<tgmath.h>", "<ctgmath>",
- "<time.h>", "<ctime>",
- "<uchar.h>", "<cuchar>",
- "<wchar.h>", "<cwchar>",
- "<wctype.h>", "<cwctype>",
- "<ios>", "<iostream>",
- "<ios>", "<istream>",
- "<ios>", "<ostream>",
- "<iosfwd>", "<ios>",
- "<iosfwd>", "<streambuf>",
- "<istream>", "<iostream>",
- "<istream>", "<fstream>",
- "<istream>", "<sstream>",
- "<ostream>", "<iostream>",
- "<ostream>", "<fstream>",
- "<ostream>", "<istream>",
- "<ostream>", "<sstream>",
- "<streambuf>", "<ios>",
- };
+ private static final String[] cppIncludeMapWeak = new String[] { "<assert.h>", "<cassert>", "<complex.h>",
+ "<ccomplex>", "<ctype.h>", "<cctype>", "<errno.h>", "<cerrno>", "<fenv.h>", "<cfenv>", "<float.h>",
+ "<cfloat>", "<inttypes.h>", "<cinttypes>", "<iso646.h>", "<ciso646>", "<limits.h>", "<climits>",
+ "<locale.h>", "<clocale>", "<math.h>", "<cmath>", "<setjmp.h>", "<csetjmp>", "<signal.h>", "<csignal>",
+ "<stdalign.h", "<cstdalign>", "<stdarg.h>", "<cstdarg>", "<stdbool.h>", "<cstdbool>", "<stddef.h>",
+ "<cstddef>", "<stdint.h>", "<cstdint>", "<stdio.h>", "<cstdio>", "<stdlib.h>", "<cstdlib>", "<string.h>",
+ "<cstring>", "<tgmath.h>", "<ctgmath>", "<time.h>", "<ctime>", "<uchar.h>", "<cuchar>", "<wchar.h>",
+ "<cwchar>", "<wctype.h>", "<cwctype>", "<ios>", "<iostream>", "<ios>", "<istream>", "<ios>", "<ostream>",
+ "<iosfwd>", "<ios>", "<iosfwd>", "<streambuf>", "<istream>", "<iostream>", "<istream>", "<fstream>",
+ "<istream>", "<sstream>", "<ostream>", "<iostream>", "<ostream>", "<fstream>", "<ostream>", "<istream>",
+ "<ostream>", "<sstream>", "<streambuf>", "<ios>", };
public static List<HeaderSubstitutionMap> getDefaultMaps() {
return Arrays.asList(new HeaderSubstitutionMap[] {
new HeaderSubstitutionMap(Messages.GCCHeaderSubstitutionMaps_c_map, false,
- new IncludeMap(true, cIncludeMap),
- new IncludeMap(false, cIncludeMapWeak)),
+ new IncludeMap(true, cIncludeMap), new IncludeMap(false, cIncludeMapWeak)),
new HeaderSubstitutionMap(Messages.GCCHeaderSubstitutionMaps_cpp_map, true,
- new IncludeMap(true, cppIncludeMap),
- new IncludeMap(false, cppIncludeMapWeak)),
- });
+ new IncludeMap(true, cppIncludeMap), new IncludeMap(false, cppIncludeMapWeak)), });
}
public static SymbolExportMap getSymbolExportMap() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutionMap.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutionMap.java
index 2ffd604b7bf..0791c92a2c5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutionMap.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutionMap.java
@@ -51,8 +51,8 @@ public class HeaderSubstitutionMap {
this.optionalSubstitutionMap = new IncludeMap(false);
}
- public HeaderSubstitutionMap(String name, boolean cppOnly,
- IncludeMap unconditionalSubstitutionMap, IncludeMap optionalSubstitutionMap) {
+ public HeaderSubstitutionMap(String name, boolean cppOnly, IncludeMap unconditionalSubstitutionMap,
+ IncludeMap optionalSubstitutionMap) {
this.name = name;
this.cppOnly = cppOnly;
this.unconditionalSubstitutionMap = unconditionalSubstitutionMap;
@@ -61,7 +61,7 @@ public class HeaderSubstitutionMap {
/**
* Indicates that the header file {@code to} should be used instead of {@code from}.
- *
+ *
* @param from The header file to be replaced.
* @param to The header file to be used instead.
* @param unconditionalSubstitution {@code true} if the header substitution is mandatory.
@@ -119,8 +119,10 @@ public class HeaderSubstitutionMap {
String name = memento.getString(TAG_NAME);
Boolean b = memento.getBoolean(TAG_CPP_ONLY);
boolean cppOnly = b != null && b.booleanValue();
- IncludeMap unconditionalSubstitutionMap = IncludeMap.fromMemento(true, memento.getChild(TAG_UNCONDITIONAL_SUBSTITUTION_MAP));
- IncludeMap optionalSubstitutionMap = IncludeMap.fromMemento(false, memento.getChild(TAG_OPTIONAL_SUBSTITUTION_MAP));
+ IncludeMap unconditionalSubstitutionMap = IncludeMap.fromMemento(true,
+ memento.getChild(TAG_UNCONDITIONAL_SUBSTITUTION_MAP));
+ IncludeMap optionalSubstitutionMap = IncludeMap.fromMemento(false,
+ memento.getChild(TAG_OPTIONAL_SUBSTITUTION_MAP));
// Remove potential redundant substitutions from optionalSubstitutionMap.
for (IncludeInfo header : unconditionalSubstitutionMap.getMap().keySet()) {
optionalSubstitutionMap.removeMapping(header);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutor.java
index dd23164ac67..c41904de51e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/HeaderSubstitutor.java
@@ -39,8 +39,8 @@ public class HeaderSubstitutor {
private static int HEURISTIC_SCORE_NOT_AUTO_EXPORTED_HEADER = 0x1;
private static int HEURISTIC_SCORE_NAME_MATCH = 0x2;
private static int HEURISTIC_SCORE_NO_EXTENSION = 0x4;
- private static int HEURISTIC_SCORE_MAX =
- HEURISTIC_SCORE_NOT_AUTO_EXPORTED_HEADER + HEURISTIC_SCORE_NAME_MATCH + HEURISTIC_SCORE_NO_EXTENSION;
+ private static int HEURISTIC_SCORE_MAX = HEURISTIC_SCORE_NOT_AUTO_EXPORTED_HEADER + HEURISTIC_SCORE_NAME_MATCH
+ + HEURISTIC_SCORE_NO_EXTENSION;
private final IncludeCreationContext fContext;
private IncludeMap[] fIncludeMaps;
@@ -51,8 +51,8 @@ public class HeaderSubstitutor {
fIncludeMaps = new IncludeMap[] { new IncludeMap(true), new IncludeMap(false) };
IPreferencesService preferences = Platform.getPreferencesService();
IScopeContext[] scopes = PreferenceConstants.getPreferenceScopes(context.getProject());
- String str = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.INCLUDES_HEADER_SUBSTITUTION, null, scopes);
+ String str = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.INCLUDES_HEADER_SUBSTITUTION, null,
+ scopes);
if (str != null) {
List<HeaderSubstitutionMap> maps = HeaderSubstitutionMap.deserializeMaps(str);
for (HeaderSubstitutionMap map : maps) {
@@ -67,8 +67,8 @@ public class HeaderSubstitutor {
fIncludeMaps[1].transitivelyClose();
fSymbolExportMap = new SymbolExportMap();
- str = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.INCLUDES_SYMBOL_EXPORTING_HEADERS, null, scopes);
+ str = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.INCLUDES_SYMBOL_EXPORTING_HEADERS, null,
+ scopes);
if (str != null) {
List<SymbolExportMap> maps = SymbolExportMap.deserializeMaps(str);
for (SymbolExportMap map : maps) {
@@ -199,8 +199,7 @@ public class HeaderSubstitutor {
}
}
- return firstIncludedPreviously != null ?
- firstIncludedPreviously : firstResolved != null ? firstResolved : path;
+ return firstIncludedPreviously != null ? firstIncludedPreviously : firstResolved != null ? firstResolved : path;
}
/**
@@ -216,7 +215,7 @@ public class HeaderSubstitutor {
String symbolName = request.getBinding().getName();
int bestScore = getScore(preferredHeader.toString(), symbolName);
if (bestScore == HEURISTIC_SCORE_MAX)
- return preferredHeader; // Nothing can be better than preferredHeader.
+ return preferredHeader; // Nothing can be better than preferredHeader.
IIndexFile bestCandidate = null;
Set<IIndexFile> indexFiles = request.getDeclaringFiles().keySet();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IElementSelector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IElementSelector.java
index cf7b206cb2d..4ebebf479ab 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IElementSelector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IElementSelector.java
@@ -16,14 +16,14 @@ package org.eclipse.cdt.internal.ui.refactoring.includes;
import java.util.Collection;
/**
- * Interface for selecting one of a set of elements.
+ * Interface for selecting one of a set of elements.
*/
public interface IElementSelector {
/**
* Selects one element from a set of elements.
- *
+ *
* @param elements the objects to select from
- * @return the selected element or {@code null} if nothing was selected
+ * @return the selected element or {@code null} if nothing was selected
*/
public <T> T selectElement(Collection<T> elements);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IHeaderChooser.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IHeaderChooser.java
index 13685a75e68..fa43cd629e1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IHeaderChooser.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IHeaderChooser.java
@@ -18,15 +18,15 @@ import java.util.Collection;
import org.eclipse.core.runtime.IPath;
/**
- * Interface for selecting one of alternative headers.
+ * Interface for selecting one of alternative headers.
*/
public interface IHeaderChooser {
/**
* Chooses one header out of multiple alternatives.
- *
+ *
* @param bindingName the name of the binding for which the header is selected
* @param headers absolute file system locations of the headers defining the binding
- * @return the chosen header or {@code null} if nothing was selected
+ * @return the chosen header or {@code null} if nothing was selected
*/
public IPath chooseHeader(String bindingName, Collection<IPath> headers);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreationContext.java
index f5805851c87..6e5363f6b5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreationContext.java
@@ -58,28 +58,28 @@ public final class IncludeCreationContext extends InclusionContext {
return getTranslationUnit().isCXXLanguage();
}
- /**
- * Removes headers that are exported by other headers that will be included.
- */
- public void removeExportedHeaders() throws CoreException {
- // Index files keyed by their absolute paths.
- Map<IPath, IIndexFile> filesByPath = new HashMap<>();
- for (IIndexFile file : fIndex.getAllFiles()) {
- IPath path = getPath(file);
- filesByPath.put(path, file);
- }
-
- removeExportedHeaders(fHeadersAlreadyIncluded, filesByPath);
- removeExportedHeaders(fHeadersToInclude, filesByPath);
- }
-
- private void removeExportedHeaders(Set<IPath> exportingHeaders,
- Map<IPath, IIndexFile> filesByPath) throws CoreException {
+ /**
+ * Removes headers that are exported by other headers that will be included.
+ */
+ public void removeExportedHeaders() throws CoreException {
+ // Index files keyed by their absolute paths.
+ Map<IPath, IIndexFile> filesByPath = new HashMap<>();
+ for (IIndexFile file : fIndex.getAllFiles()) {
+ IPath path = getPath(file);
+ filesByPath.put(path, file);
+ }
+
+ removeExportedHeaders(fHeadersAlreadyIncluded, filesByPath);
+ removeExportedHeaders(fHeadersToInclude, filesByPath);
+ }
+
+ private void removeExportedHeaders(Set<IPath> exportingHeaders, Map<IPath, IIndexFile> filesByPath)
+ throws CoreException {
Set<IPath> exportedHeaders = new HashSet<>();
for (IPath path : exportingHeaders) {
if (!exportedHeaders.contains(path)) {
IIndexFile file = filesByPath.get(path);
- if (file != null) { // file can be null if the header was not indexed.
+ if (file != null) { // file can be null if the header was not indexed.
ArrayDeque<IIndexFile> queue = new ArrayDeque<>();
queue.add(file);
while ((file = queue.pollFirst()) != null) {
@@ -164,8 +164,7 @@ public final class IncludeCreationContext extends InclusionContext {
* file, or if it is already included by some other file.
*/
public final boolean canBeIncluded(IIndexFile indexFile) throws CoreException {
- return !IncludeUtil.isSource(indexFile, getProject()) ||
- fIndex.findIncludedBy(indexFile, 0).length != 0;
+ return !IncludeUtil.isSource(indexFile, getProject()) || fIndex.findIncludedBy(indexFile, 0).length != 0;
}
public final boolean isHeaderFile(String filename) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreator.java
index 62ca11051dc..e1d21d16fe0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeCreator.java
@@ -108,8 +108,7 @@ public class IncludeCreator {
fContext = new IncludeCreationContext(tu, index);
}
- public MultiTextEdit createInclude(IASTTranslationUnit ast, ITextSelection selection)
- throws CoreException {
+ public MultiTextEdit createInclude(IASTTranslationUnit ast, ITextSelection selection) throws CoreException {
try {
CPPSemantics.enablePromiscuousBindingResolution();
return createIncludeImpl(ast, selection);
@@ -117,9 +116,8 @@ public class IncludeCreator {
CPPSemantics.disablePromiscuousBindingResolution();
}
}
-
- private MultiTextEdit createIncludeImpl(IASTTranslationUnit ast, ITextSelection selection)
- throws CoreException {
+
+ private MultiTextEdit createIncludeImpl(IASTTranslationUnit ast, ITextSelection selection) throws CoreException {
MultiTextEdit rootEdit = new MultiTextEdit();
ITranslationUnit tu = fContext.getTranslationUnit();
IASTNodeSelector selector = ast.getNodeSelector(tu.getLocation().toOSString());
@@ -143,7 +141,7 @@ public class IncludeCreator {
return rootEdit;
}
- final Map<String, IncludeCandidate> candidatesMap= new HashMap<>();
+ final Map<String, IncludeCandidate> candidatesMap = new HashMap<>();
final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false);
final List<IncludeInfo> requiredIncludes = new ArrayList<>();
@@ -152,13 +150,13 @@ public class IncludeCreator {
List<IIndexBinding> bindings = new ArrayList<>();
try {
IIndex index = fContext.getIndex();
- IIndexBinding adaptedBinding= index.adaptBinding(binding);
+ IIndexBinding adaptedBinding = index.adaptBinding(binding);
if (adaptedBinding == null) {
bindings.addAll(Arrays.asList(index.findBindings(nameChars, false, filter, new NullProgressMonitor())));
} else {
bindings.add(adaptedBinding);
while (adaptedBinding instanceof ICPPSpecialization) {
- adaptedBinding= index.adaptBinding(((ICPPSpecialization) adaptedBinding).getSpecializedBinding());
+ adaptedBinding = index.adaptBinding(((ICPPSpecialization) adaptedBinding).getSpecializedBinding());
if (adaptedBinding != null) {
bindings.add(adaptedBinding);
}
@@ -172,18 +170,17 @@ public class IncludeCreator {
if (indexBinding instanceof ICPPConstructor) {
indexBinding = indexBinding.getOwner();
}
- IIndexName[] definitions= null;
+ IIndexName[] definitions = null;
// class, struct, union, enum-type, enum-item
if (indexBinding instanceof ICompositeType || indexBinding instanceof IEnumeration
|| indexBinding instanceof IEnumerator) {
- definitions= index.findDefinitions(indexBinding);
+ definitions = index.findDefinitions(indexBinding);
} else if (indexBinding instanceof ITypedef || indexBinding instanceof IFunction) {
definitions = index.findDeclarations(indexBinding);
}
if (definitions != null) {
for (IIndexName definition : definitions) {
- considerForInclusion(ast, definition, indexBinding, index, headerSubstitutor,
- candidatesMap);
+ considerForInclusion(ast, definition, indexBinding, index, headerSubstitutor, candidatesMap);
}
if (definitions.length > 0 && adaptedBinding != null)
break;
@@ -302,7 +299,7 @@ public class IncludeCreator {
for (IncludeCandidate candidate : candidates) {
if (SemanticUtil.isSameNamespace(sourceNamespace, getContainingNamespace(candidate.binding))) {
if (winner != null) {
- return null; // ambiguous between 'winner' and 'candidate'
+ return null; // ambiguous between 'winner' and 'candidate'
}
winner = candidate;
}
@@ -310,13 +307,11 @@ public class IncludeCreator {
return winner;
}
- private MultiTextEdit createEdit(List<IncludeInfo> includes,
- List<UsingDeclaration> usingDeclarations, IASTTranslationUnit ast,
- ITextSelection selection) {
+ private MultiTextEdit createEdit(List<IncludeInfo> includes, List<UsingDeclaration> usingDeclarations,
+ IASTTranslationUnit ast, ITextSelection selection) {
NodeCommentMap commentedNodeMap = ASTCommenter.getCommentedNodeMap(ast);
String contents = fContext.getSourceContents();
- IRegion includeRegion =
- IncludeUtil.getSafeIncludeReplacementRegion(contents, ast, commentedNodeMap);
+ IRegion includeRegion = IncludeUtil.getSafeIncludeReplacementRegion(contents, ast, commentedNodeMap);
IncludePreferences preferences = fContext.getPreferences();
@@ -337,8 +332,7 @@ public class IncludeCreator {
}
Collections.sort(styledIncludes, preferences);
- List<StyledInclude> mergedIncludes =
- IncludeUtil.getIncludesInRegion(existingIncludes, includeRegion, fContext);
+ List<StyledInclude> mergedIncludes = IncludeUtil.getIncludesInRegion(existingIncludes, includeRegion, fContext);
if (preferences.allowReordering) {
// Since the order of existing include statements may not match the include order
@@ -346,7 +340,8 @@ public class IncludeCreator {
// from the bottom of the include insertion region.
for (StyledInclude include : styledIncludes) {
int i = mergedIncludes.size();
- while (--i >= 0 && preferences.compare(include, mergedIncludes.get(i)) < 0) {}
+ while (--i >= 0 && preferences.compare(include, mergedIncludes.get(i)) < 0) {
+ }
mergedIncludes.add(i + 1, include);
}
} else {
@@ -367,7 +362,8 @@ public class IncludeCreator {
if (contents.charAt(offset - 1) != '\n')
text.append(fContext.getLineDelimiter());
}
- if (include.getStyle().isBlankLineNeededAfter(previousInclude.getStyle(), preferences.includeStyles)) {
+ if (include.getStyle().isBlankLineNeededAfter(previousInclude.getStyle(),
+ preferences.includeStyles)) {
if (TextUtil.isLineBlank(contents, offset)) {
offset = TextUtil.skipToNextLine(contents, offset);
} else {
@@ -378,17 +374,18 @@ public class IncludeCreator {
text.append(include.getIncludeInfo().composeIncludeStatement());
text.append(fContext.getLineDelimiter());
} else {
- if (previousInclude != null && previousInclude.getExistingInclude() == null &&
- include.getStyle().isBlankLineNeededAfter(previousInclude.getStyle(), preferences.includeStyles) &&
- !TextUtil.isPreviousLineBlank(contents, ASTNodes.offset(existingInclude))) {
+ if (previousInclude != null && previousInclude.getExistingInclude() == null
+ && include.getStyle().isBlankLineNeededAfter(previousInclude.getStyle(),
+ preferences.includeStyles)
+ && !TextUtil.isPreviousLineBlank(contents, ASTNodes.offset(existingInclude))) {
text.append(fContext.getLineDelimiter());
}
flushEditBuffer(offset, text, rootEdit);
}
previousInclude = include;
}
- if (includeRegion.getLength() == 0 && !TextUtil.isLineBlank(contents, includeRegion.getOffset()) &&
- !includes.isEmpty()) {
+ if (includeRegion.getLength() == 0 && !TextUtil.isLineBlank(contents, includeRegion.getOffset())
+ && !includes.isEmpty()) {
text.append(fContext.getLineDelimiter());
}
flushEditBuffer(offset, text, rootEdit);
@@ -408,8 +405,8 @@ public class IncludeCreator {
List<UsingDeclaration> temp = null;
for (Iterator<UsingDeclaration> iter = mergedUsingDeclarations.iterator(); iter.hasNext();) {
UsingDeclaration usingDeclaration = iter.next();
- if (usingDeclaration.existingDeclaration.isPartOfTranslationUnitFile() &&
- ASTNodes.endOffset(usingDeclaration.existingDeclaration) <= selection.getOffset()) {
+ if (usingDeclaration.existingDeclaration.isPartOfTranslationUnitFile()
+ && ASTNodes.endOffset(usingDeclaration.existingDeclaration) <= selection.getOffset()) {
if (temp == null)
temp = new ArrayList<>();
temp.add(usingDeclaration);
@@ -425,7 +422,7 @@ public class IncludeCreator {
if (mergedUsingDeclarations.isEmpty()) {
offset = includeRegion.getOffset() + includeRegion.getLength();
- text.append(fContext.getLineDelimiter()); // Blank line between includes and using declarations.
+ text.append(fContext.getLineDelimiter()); // Blank line between includes and using declarations.
} else {
offset = commentedNodeMap.getOffsetIncludingComments(mergedUsingDeclarations.get(0).existingDeclaration);
}
@@ -435,7 +432,8 @@ public class IncludeCreator {
// the using declaration list.
for (UsingDeclaration using : usingDeclarations) {
int i = mergedUsingDeclarations.size();
- while (--i >= 0 && using.compareTo(mergedUsingDeclarations.get(i)) < 0) {}
+ while (--i >= 0 && using.compareTo(mergedUsingDeclarations.get(i)) < 0) {
+ }
mergedUsingDeclarations.add(i + 1, using);
}
@@ -483,7 +481,7 @@ public class IncludeCreator {
/**
* Adds an include candidate to the {@code candidates} map if the file containing the definition
- * is suitable for inclusion.
+ * is suitable for inclusion.
*/
private void considerForInclusion(IASTTranslationUnit ast, IIndexName definition, IIndexBinding binding,
IIndex index, HeaderSubstitutor headerSubstitutor, Map<String, IncludeCandidate> candidates)
@@ -500,8 +498,8 @@ public class IncludeCreator {
header = headerSubstitutor.getPreferredRepresentativeHeader(header);
if (fContext.getPreferences().heuristicHeaderSubstitution) {
boolean reachable = ast.getIndexFileSet().contains(file);
- InclusionRequest request =
- new InclusionRequest(binding, Collections.singletonMap(file, header), reachable);
+ InclusionRequest request = new InclusionRequest(binding, Collections.singletonMap(file, header),
+ reachable);
header = headerSubstitutor.getPreferredRepresentativeHeaderByHeuristic(request, header);
}
IncludeGroupStyle style = fContext.getIncludeStyle(header);
@@ -516,18 +514,17 @@ public class IncludeCreator {
}
}
- private UsingDeclaration deduceUsingDeclaration(IBinding source, IBinding target,
- IASTTranslationUnit ast) {
+ private UsingDeclaration deduceUsingDeclaration(IBinding source, IBinding target, IASTTranslationUnit ast) {
if (source.equals(target)) {
- return null; // No using declaration is needed.
+ return null; // No using declaration is needed.
}
ArrayList<String> targetChain = getUsingChain(target);
if (targetChain.size() <= 1) {
- return null; // Target is not in a namespace.
+ return null; // Target is not in a namespace.
}
// Check if any of the existing using declarations and directives matches the target.
- final IASTDeclaration[] declarations= ast.getDeclarations(false);
+ final IASTDeclaration[] declarations = ast.getDeclarations(false);
for (IASTDeclaration declaration : declarations) {
if (declaration.isPartOfTranslationUnitFile()) {
IASTName name = null;
@@ -554,7 +551,7 @@ public class IncludeCreator {
}
}
if (j <= 0) {
- return null; // Source is in the target's namespace
+ return null; // Source is in the target's namespace
}
}
StringBuilder buf = new StringBuilder();
@@ -679,14 +676,14 @@ public class IncludeCreator {
* @throws CoreException
*/
private static String getBindingQualifiedName(IIndexBinding binding) throws CoreException {
- String[] qname= CPPVisitor.getQualifiedName(binding);
+ String[] qname = CPPVisitor.getQualifiedName(binding);
StringBuilder result = new StringBuilder();
- boolean needSep= false;
+ boolean needSep = false;
for (String element : qname) {
if (needSep)
result.append(Keywords.cpCOLONCOLON);
result.append(element);
- needSep= true;
+ needSep = true;
}
return result.toString();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeGroupStyle.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeGroupStyle.java
index fb593c7624f..9b8474be84b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeGroupStyle.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeGroupStyle.java
@@ -36,41 +36,29 @@ public class IncludeGroupStyle implements Comparable<IncludeGroupStyle> {
public enum IncludeKind {
RELATED(PreferencesMessages.IncludeCategoriesBlock_related_headers_node,
- PreferencesMessages.IncludeCategoriesBlock_related_headers_node_description,
- null),
+ PreferencesMessages.IncludeCategoriesBlock_related_headers_node_description, null),
PARTNER(PreferencesMessages.IncludeCategoriesBlock_partner_header_node,
- PreferencesMessages.IncludeCategoriesBlock_partner_header_node_description,
- RELATED),
+ PreferencesMessages.IncludeCategoriesBlock_partner_header_node_description, RELATED),
IN_SAME_FOLDER(PreferencesMessages.IncludeCategoriesBlock_same_folder_header_node,
- PreferencesMessages.IncludeCategoriesBlock_same_folder_header_node_description,
- RELATED),
+ PreferencesMessages.IncludeCategoriesBlock_same_folder_header_node_description, RELATED),
IN_SUBFOLDER(PreferencesMessages.IncludeCategoriesBlock_subfolder_header_node,
- PreferencesMessages.IncludeCategoriesBlock_subfolder_header_node_description,
- RELATED),
+ PreferencesMessages.IncludeCategoriesBlock_subfolder_header_node_description, RELATED),
SYSTEM(PreferencesMessages.IncludeCategoriesBlock_system_headers_node,
- PreferencesMessages.IncludeCategoriesBlock_system_headers_node_description,
- null),
+ PreferencesMessages.IncludeCategoriesBlock_system_headers_node_description, null),
SYSTEM_WITH_EXTENSION(PreferencesMessages.IncludeCategoriesBlock_system_headers_with_extension_node,
- PreferencesMessages.IncludeCategoriesBlock_system_headers_with_extension_node_description,
- SYSTEM),
+ PreferencesMessages.IncludeCategoriesBlock_system_headers_with_extension_node_description, SYSTEM),
SYSTEM_WITHOUT_EXTENSION(PreferencesMessages.IncludeCategoriesBlock_system_headers_without_extension_node,
- PreferencesMessages.IncludeCategoriesBlock_system_headers_without_extension_node_description,
- SYSTEM),
+ PreferencesMessages.IncludeCategoriesBlock_system_headers_without_extension_node_description, SYSTEM),
OTHER(PreferencesMessages.IncludeCategoriesBlock_unrelated_headers_node,
- PreferencesMessages.IncludeCategoriesBlock_unrelated_headers_node_description,
- null),
+ PreferencesMessages.IncludeCategoriesBlock_unrelated_headers_node_description, null),
IN_SAME_PROJECT(PreferencesMessages.IncludeCategoriesBlock_same_project_headers_node,
- PreferencesMessages.IncludeCategoriesBlock_same_project_headers_node_description,
- OTHER),
+ PreferencesMessages.IncludeCategoriesBlock_same_project_headers_node_description, OTHER),
IN_OTHER_PROJECT(PreferencesMessages.IncludeCategoriesBlock_other_project_headers_node,
- PreferencesMessages.IncludeCategoriesBlock_other_project_headers_node_description,
- OTHER),
+ PreferencesMessages.IncludeCategoriesBlock_other_project_headers_node_description, OTHER),
EXTERNAL(PreferencesMessages.IncludeCategoriesBlock_external_headers_node,
- PreferencesMessages.IncludeCategoriesBlock_external_headers_node_description,
- OTHER),
+ PreferencesMessages.IncludeCategoriesBlock_external_headers_node_description, OTHER),
MATCHING_PATTERN(PreferencesMessages.IncludeCategoriesBlock_user_defined_categories_node,
- PreferencesMessages.IncludeCategoriesBlock_user_defined_categories_node_description,
- null);
+ PreferencesMessages.IncludeCategoriesBlock_user_defined_categories_node_description, null);
public final String name;
public final String description;
@@ -194,7 +182,7 @@ public class IncludeGroupStyle implements Comparable<IncludeGroupStyle> {
style = new IncludeGroupStyle(name, Pattern.compile(pattern));
} else {
style = new IncludeGroupStyle(includeKind);
- }
+ }
style.setKeepTogether(nullToFalse(memento.getBoolean(TAG_KEEP_TOGETHER)));
style.setBlankLineBefore(nullToFalse(memento.getBoolean(TAG_BLANK_LINE_BEFORE)));
if (!includeKind.hasChildren()) {
@@ -298,8 +286,7 @@ public class IncludeGroupStyle implements Comparable<IncludeGroupStyle> {
return true;
IncludeGroupStyle parentStyle = groupingStyle.getParentStyle(stylesMap);
IncludeGroupStyle previousParentStyle = previousGroupingStyle.getParentStyle(stylesMap);
- return parentStyle != null && previousParentStyle != null &&
- parentStyle != previousParentStyle && parentStyle.isKeepTogether() &&
- parentStyle.isBlankLineBefore();
+ return parentStyle != null && previousParentStyle != null && parentStyle != previousParentStyle
+ && parentStyle.isKeepTogether() && parentStyle.isBlankLineBefore();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeMap.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeMap.java
index bbf9c339a3c..61cc3d52dbf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeMap.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeMap.java
@@ -36,7 +36,7 @@ public class IncludeMap {
private static final String TAG_KEY = "key"; //$NON-NLS-1$
private static final String TAG_VALUE = "value"; //$NON-NLS-1$
- private final boolean unconditionalSubstitution; // Not serialized when saving to a memento.
+ private final boolean unconditionalSubstitution; // Not serialized when saving to a memento.
// The order is not crucial but can make a difference when calculating transitive closure.
private final LinkedHashMap<IncludeInfo, List<IncludeInfo>> map;
@@ -48,7 +48,7 @@ public class IncludeMap {
/**
* @param keysAndValues an array of keys and values: [key1, value1, key2, value2, ...].
* Keys and values may be optionally surrounded by double quotes or angle brackets.
- * Angle brackets indicate a system include.
+ * Angle brackets indicate a system include.
*/
public IncludeMap(boolean unconditionalSubstitution, String[] keysAndValues) {
if (keysAndValues.length % 2 != 0)
@@ -69,13 +69,13 @@ public class IncludeMap {
/**
* Indicates that header file {@code to} should be used instead of {@code from}.
- *
+ *
* @param from The header file to be replaced.
* @param to The header file to be used.
*/
protected void addMapping(IncludeInfo from, IncludeInfo to) {
if (from.equals(to))
- return; // Don't allow mapping to itself.
+ return; // Don't allow mapping to itself.
List<IncludeInfo> list = map.get(from);
if (list == null) {
list = new ArrayList<>(2);
@@ -99,10 +99,10 @@ public class IncludeMap {
/**
* Returns header files that should be used instead of the given one.
- *
+ *
* @param from The header file to be replaced. A system header has to match exactly.
* A non-system header matches both, non-system and system headers.
- * @return The list of header files ordered by decreasing preference.
+ * @return The list of header files ordered by decreasing preference.
*/
public List<IncludeInfo> getMapping(IncludeInfo from) {
List<IncludeInfo> list = map.get(from);
@@ -120,7 +120,7 @@ public class IncludeMap {
*
* @param from the header file to remove substitutions for
* @return the previous substitutions associated with the header file, or
- * {@code null} if there were no substitutions for the header.
+ * {@code null} if there were no substitutions for the header.
*/
public List<IncludeInfo> removeMapping(String from) {
return removeMapping(new IncludeInfo(from));
@@ -131,7 +131,7 @@ public class IncludeMap {
*
* @param from the header file to remove substitutions for
* @return the previous substitutions associated with the header file, or
- * {@code null} if there were no substitutions for the header.
+ * {@code null} if there were no substitutions for the header.
*/
public List<IncludeInfo> removeMapping(IncludeInfo from) {
return map.remove(from);
@@ -139,10 +139,10 @@ public class IncludeMap {
/**
* Returns header files that should be used instead of the given one.
- *
+ *
* @param from The header file to be replaced. A system header has to match exactly.
* A non-system header matches both, non-system and system headers.
- * @return The list of header files ordered by decreasing preference.
+ * @return The list of header files ordered by decreasing preference.
*/
public List<IncludeInfo> getMapping(String from) {
return getMapping(new IncludeInfo(from));
@@ -208,7 +208,7 @@ public class IncludeMap {
targets.clear();
HashSet<IncludeInfo> processed = new HashSet<>();
if (!unconditionalSubstitution)
- processed.add(source); // Don't allow mapping to itself.
+ processed.add(source); // Don't allow mapping to itself.
HashSet<IncludeInfo> seenTargets = new HashSet<>();
IncludeInfo target;
queueLoop: while ((target = queue.pollFirst()) != null) {
@@ -224,7 +224,7 @@ public class IncludeMap {
IncludeInfo newTarget = newTargets.get(i);
if (!processed.contains(newTarget)) {
if (unconditionalSubstitution && newTarget.equals(source)) {
- break queueLoop; // Leave the mapping empty.
+ break queueLoop; // Leave the mapping empty.
}
queue.addFirst(newTarget);
added = true;
@@ -257,7 +257,7 @@ public class IncludeMap {
if (targets.isEmpty() || (targets.size() == 1 && source.equals(targets.get(0)))) {
iter.remove();
}
- }
+ }
}
}
@@ -277,7 +277,7 @@ public class IncludeMap {
if (i > 0)
buf.append(", "); //$NON-NLS-1$
buf.append(targets.get(i));
- }
+ }
}
return buf.toString();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java
index ab10b4c709f..024819f71f4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java
@@ -88,8 +88,8 @@ import org.eclipse.cdt.internal.formatter.ChangeFormatter;
* Organizes the include directives and forward declarations of a source or header file.
*/
public class IncludeOrganizer {
- private static boolean DEBUG_HEADER_SUBSTITUTION =
- Boolean.parseBoolean(Platform.getDebugOption(CUIPlugin.PLUGIN_ID + "/debug/includeOrganizer/headerSubstitution")); //$NON-NLS-1$
+ private static boolean DEBUG_HEADER_SUBSTITUTION = Boolean
+ .parseBoolean(Platform.getDebugOption(CUIPlugin.PLUGIN_ID + "/debug/includeOrganizer/headerSubstitution")); //$NON-NLS-1$
private static final Collator COLLATOR = Collator.getInstance();
@@ -109,7 +109,7 @@ public class IncludeOrganizer {
* Initializes an include prototype object for an existing include. {@code header} may be
* {@code null} if the include was not resolved.
*/
- IncludePrototype(IPath header, IncludeInfo includeInfo, IncludeGroupStyle style,
+ IncludePrototype(IPath header, IncludeInfo includeInfo, IncludeGroupStyle style,
IASTPreprocessorIncludeStatement existingInclude, boolean required) {
super(header, includeInfo, style, existingInclude);
this.required = required;
@@ -120,7 +120,9 @@ public class IncludeOrganizer {
}
}
- private static enum DeclarationType { TYPE, FUNCTION, VARIABLE, NAMESPACE }
+ private static enum DeclarationType {
+ TYPE, FUNCTION, VARIABLE, NAMESPACE
+ }
private static class ForwardDeclarationNode implements Comparable<ForwardDeclarationNode> {
final String name;
@@ -218,16 +220,16 @@ public class IncludeOrganizer {
String path = include.getPath();
// An empty path means that the include was not resolved.
IPath header = path.isEmpty() ? null : Path.fromOSString(path);
- IncludeGroupStyle style =
- header != null ? fContext.getIncludeStyle(header) : fContext.getIncludeStyle(includeInfo);
+ IncludeGroupStyle style = header != null ? fContext.getIncludeStyle(header)
+ : fContext.getIncludeStyle(includeInfo);
boolean required = hasPragmaKeep(include, commentedNodeMap);
IncludePrototype prototype = new IncludePrototype(header, includeInfo, style, include, required);
updateIncludePrototypes(includePrototypes, prototype);
}
}
- IRegion includeReplacementRegion =
- IncludeUtil.getSafeIncludeReplacementRegion(fContext.getSourceContents(), ast, commentedNodeMap);
+ IRegion includeReplacementRegion = IncludeUtil.getSafeIncludeReplacementRegion(fContext.getSourceContents(),
+ ast, commentedNodeMap);
IncludePreferences preferences = fContext.getPreferences();
boolean allowReordering = preferences.allowReordering || existingIncludes.length == 0;
@@ -235,11 +237,11 @@ public class IncludeOrganizer {
MultiTextEdit rootEdit = new MultiTextEdit();
@SuppressWarnings("unchecked")
- List<IncludePrototype>[] groupedPrototypes =
- (List<IncludePrototype>[]) new List<?>[preferences.includeStyles.size()];
+ List<IncludePrototype>[] groupedPrototypes = (List<IncludePrototype>[]) new List<?>[preferences.includeStyles
+ .size()];
for (IncludePrototype prototype : includePrototypes.keySet()) {
- if (prototype.getExistingInclude() == null
- || (allowReordering && isContainedInRegion(prototype.getExistingInclude(), includeReplacementRegion))) {
+ if (prototype.getExistingInclude() == null || (allowReordering
+ && isContainedInRegion(prototype.getExistingInclude(), includeReplacementRegion))) {
IncludeGroupStyle groupingStyle = prototype.getStyle().getGroupingStyle(preferences.includeStyles);
// If reordering is not allowed, group everything together.
int position = allowReordering ? groupingStyle.getOrder() : 0;
@@ -250,8 +252,8 @@ public class IncludeOrganizer {
}
prototypes.add(prototype);
}
- if (!allowReordering && prototype.getExistingInclude() != null
- && !prototype.isRequired() && prototype.getHeader() != null // Unused and resolved.
+ if (!allowReordering && prototype.getExistingInclude() != null && !prototype.isRequired()
+ && prototype.getHeader() != null // Unused and resolved.
&& !fContext.isPartnerFile(prototype.getHeader())
&& isContainedInRegion(prototype.getExistingInclude(), includeReplacementRegion)) {
switch (preferences.unusedStatementsDisposition) {
@@ -273,21 +275,22 @@ public class IncludeOrganizer {
if (prototypes != null && !prototypes.isEmpty()) {
Collections.sort(prototypes, preferences);
IncludeGroupStyle style = prototypes.get(0).getStyle();
- if (!includeDirectives.isEmpty() &&
- style.isBlankLineNeededAfter(previousStyle, preferences.includeStyles)) {
+ if (!includeDirectives.isEmpty()
+ && style.isBlankLineNeededAfter(previousStyle, preferences.includeStyles)) {
includeDirectives.add(""); // Blank line separator //$NON-NLS-1$
}
previousStyle = style;
for (IncludePrototype prototype : prototypes) {
String trailingComment = ""; //$NON-NLS-1$
IASTPreprocessorIncludeStatement include = prototype.getExistingInclude();
- if (include == null
- || (allowReordering && IncludeUtil.isContainedInRegion(include, includeReplacementRegion))) {
+ if (include == null || (allowReordering
+ && IncludeUtil.isContainedInRegion(include, includeReplacementRegion))) {
if (include != null) {
List<IASTComment> comments = commentedNodeMap.getTrailingCommentsForNode(include);
StringBuilder buf = new StringBuilder();
for (IASTComment comment : comments) {
- buf.append(ASTNodes.getPrecedingWhitespaceInLine(fContext.getSourceContents(), comment));
+ buf.append(
+ ASTNodes.getPrecedingWhitespaceInLine(fContext.getSourceContents(), comment));
buf.append(comment.getRawSignature());
}
trailingComment = buf.toString();
@@ -313,13 +316,12 @@ public class IncludeOrganizer {
if (allowReordering) {
if (buf.length() != 0) {
if (offset != 0 && !TextUtil.isPreviousLineBlank(fContext.getSourceContents(), offset))
- buf.insert(0, fContext.getLineDelimiter()); // Blank line before.
+ buf.insert(0, fContext.getLineDelimiter()); // Blank line before.
}
String text = buf.toString();
// TODO(sprigogin): Add a diff algorithm and produce narrower replacements.
- if (text.length() != length ||
- !fContext.getSourceContents().regionMatches(offset, text, 0, length)) {
+ if (text.length() != length || !fContext.getSourceContents().regionMatches(offset, text, 0, length)) {
rootEdit.addChild(new ReplaceEdit(offset, length, text));
}
} else if (buf.length() != 0) {
@@ -328,23 +330,24 @@ public class IncludeOrganizer {
}
createForwardDeclarations(ast, bindingClassifier,
- includeReplacementRegion.getOffset() + includeReplacementRegion.getLength(),
- buf.length() != 0, rootEdit);
+ includeReplacementRegion.getOffset() + includeReplacementRegion.getLength(), buf.length() != 0,
+ rootEdit);
- return ChangeFormatter.formatChangedCode(new String(fContext.getSourceContents()), fContext.getTranslationUnit(), rootEdit);
+ return ChangeFormatter.formatChangedCode(new String(fContext.getSourceContents()),
+ fContext.getTranslationUnit(), rootEdit);
}
/**
* Creates forward declarations by examining the list of bindings which have to be declared.
*/
- private void createForwardDeclarations(IASTTranslationUnit ast, BindingClassifier classifier,
- int offset, boolean pendingBlankLine, MultiTextEdit rootEdit) throws CoreException {
+ private void createForwardDeclarations(IASTTranslationUnit ast, BindingClassifier classifier, int offset,
+ boolean pendingBlankLine, MultiTextEdit rootEdit) throws CoreException {
ForwardDeclarationNode typeDeclarationsRoot = new ForwardDeclarationNode(""); //$NON-NLS-1$
ForwardDeclarationNode nonTypeDeclarationsRoot = new ForwardDeclarationNode(""); //$NON-NLS-1$
IIndexFileSet reachableHeaders = ast.getIndexFileSet();
- Set<IBinding> bindings =
- removeBindingsDefinedInIncludedHeaders(ast, classifier.getBindingsToForwardDeclare(), reachableHeaders);
+ Set<IBinding> bindings = removeBindingsDefinedInIncludedHeaders(ast, classifier.getBindingsToForwardDeclare(),
+ reachableHeaders);
for (IBinding binding : bindings) {
// Create the text of the forward declaration of this binding.
StringBuilder declarationText = new StringBuilder();
@@ -448,8 +451,7 @@ public class IncludeOrganizer {
declarationText.append(variable.getName());
declarationText.append(';');
} else {
- CUIPlugin.log(new IllegalArgumentException(
- "Unexpected type of binding " + binding.getName() + //$NON-NLS-1$
+ CUIPlugin.log(new IllegalArgumentException("Unexpected type of binding " + binding.getName() + //$NON-NLS-1$
" - " + binding.getClass().getSimpleName())); //$NON-NLS-1$
continue;
}
@@ -468,8 +470,8 @@ public class IncludeOrganizer {
} catch (DOMException e) {
}
- ForwardDeclarationNode parentNode = declarationType == DeclarationType.TYPE ?
- typeDeclarationsRoot : nonTypeDeclarationsRoot;
+ ForwardDeclarationNode parentNode = declarationType == DeclarationType.TYPE ? typeDeclarationsRoot
+ : nonTypeDeclarationsRoot;
Collections.reverse(namespaces);
for (String ns : namespaces) {
@@ -477,8 +479,8 @@ public class IncludeOrganizer {
parentNode = parentNode.findOrAddChild(node);
}
- ForwardDeclarationNode node =
- new ForwardDeclarationNode(binding.getName(), declarationText.toString(), declarationType);
+ ForwardDeclarationNode node = new ForwardDeclarationNode(binding.getName(), declarationText.toString(),
+ declarationType);
parentNode.findOrAddChild(node);
}
@@ -509,11 +511,13 @@ public class IncludeOrganizer {
private void printNode(ForwardDeclarationNode node, StringBuilder buf) throws CoreException {
if (node.declaration == null) {
- buf.append(CodeGeneration.getNamespaceBeginContent(fContext.getTranslationUnit(), node.name, fContext.getLineDelimiter()));
+ buf.append(CodeGeneration.getNamespaceBeginContent(fContext.getTranslationUnit(), node.name,
+ fContext.getLineDelimiter()));
for (ForwardDeclarationNode child : node.children) {
printNode(child, buf);
}
- buf.append(CodeGeneration.getNamespaceEndContent(fContext.getTranslationUnit(), node.name, fContext.getLineDelimiter()));
+ buf.append(CodeGeneration.getNamespaceEndContent(fContext.getTranslationUnit(), node.name,
+ fContext.getLineDelimiter()));
} else {
buf.append(node.declaration);
}
@@ -568,8 +572,8 @@ public class IncludeOrganizer {
return true;
}
- private Set<IBinding> removeBindingsDefinedInIncludedHeaders(IASTTranslationUnit ast,
- Set<IBinding> bindings, IIndexFileSet reachableHeaders) throws CoreException {
+ private Set<IBinding> removeBindingsDefinedInIncludedHeaders(IASTTranslationUnit ast, Set<IBinding> bindings,
+ IIndexFileSet reachableHeaders) throws CoreException {
List<InclusionRequest> requests = createInclusionRequests(ast, bindings, true, reachableHeaders);
Set<IPath> allIncludedHeaders = new HashSet<>();
allIncludedHeaders.addAll(fContext.getHeadersAlreadyIncluded());
@@ -633,8 +637,7 @@ public class IncludeOrganizer {
}
}
}
- if (partnerHeader != null
- && fContext.isClosePartnerFile(getAbsolutePath(partnerHeader.getLocation()))) {
+ if (partnerHeader != null && fContext.isClosePartnerFile(getAbsolutePath(partnerHeader.getLocation()))) {
for (IIndexInclude include : partnerHeader.getIncludes()) {
IIndexFileLocation headerLocation = include.getIncludesLocation();
if (headerLocation != null) {
@@ -655,8 +658,9 @@ public class IncludeOrganizer {
if (fContext.isIncluded(path)) {
request.resolve(path);
if (DEBUG_HEADER_SUBSTITUTION) {
- System.out.println(request.toString() +
- (fContext.isToBeIncluded(path) ? " (decided earlier)" : " (was previously included)")); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out
+ .println(request.toString() + (fContext.isToBeIncluded(path) ? " (decided earlier)" //$NON-NLS-1$
+ : " (was previously included)")); //$NON-NLS-1$
}
break;
} else {
@@ -694,8 +698,9 @@ public class IncludeOrganizer {
if (fContext.isIncluded(path)) {
request.resolve(path);
if (DEBUG_HEADER_SUBSTITUTION) {
- System.out.println(request.toString() +
- (fContext.isToBeIncluded(path) ? " (decided earlier)" : " (was previously included)")); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out
+ .println(request.toString() + (fContext.isToBeIncluded(path) ? " (decided earlier)" //$NON-NLS-1$
+ : " (was previously included)")); //$NON-NLS-1$
}
} else {
IPath header = headerSubstitutor.getPreferredRepresentativeHeader(path);
@@ -723,8 +728,9 @@ public class IncludeOrganizer {
if (fContext.isIncluded(path)) {
request.resolve(path);
if (DEBUG_HEADER_SUBSTITUTION) {
- System.out.println(request.toString() +
- (fContext.isToBeIncluded(path) ? " (decided earlier)" : " (was previously included)")); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out
+ .println(request.toString() + (fContext.isToBeIncluded(path) ? " (decided earlier)" //$NON-NLS-1$
+ : " (was previously included)")); //$NON-NLS-1$
}
break;
}
@@ -755,8 +761,9 @@ public class IncludeOrganizer {
if (fContext.isIncluded(path)) {
request.resolve(path);
if (DEBUG_HEADER_SUBSTITUTION) {
- System.out.println(request.toString() +
- (fContext.isToBeIncluded(path) ? " (decided earlier)" : " (was previously included)")); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println(
+ request.toString() + (fContext.isToBeIncluded(path) ? " (decided earlier)" //$NON-NLS-1$
+ : " (was previously included)")); //$NON-NLS-1$
}
break;
}
@@ -772,8 +779,9 @@ public class IncludeOrganizer {
if (fContext.isIncluded(path)) {
request.resolve(path);
if (DEBUG_HEADER_SUBSTITUTION) {
- System.out.println(request.toString() +
- (fContext.isToBeIncluded(path) ? " (decided earlier)" : " (was previously included)")); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out
+ .println(request.toString() + (fContext.isToBeIncluded(path) ? " (decided earlier)" //$NON-NLS-1$
+ : " (was previously included)")); //$NON-NLS-1$
}
break;
}
@@ -800,8 +808,8 @@ public class IncludeOrganizer {
request.resolve(header);
if (DEBUG_HEADER_SUBSTITUTION) {
- System.out.println(request.toString() +
- (candidatePaths.size() == 1 ? " (the only choice)" : " (user's choice)")); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println(request.toString()
+ + (candidatePaths.size() == 1 ? " (the only choice)" : " (user's choice)")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (!fContext.isAlreadyIncluded(header))
fContext.addHeaderToInclude(header);
@@ -824,9 +832,8 @@ public class IncludeOrganizer {
return headerSubstitutor.getExportingHeaders(symbol);
}
- private List<InclusionRequest> createInclusionRequests(IASTTranslationUnit ast,
- Set<IBinding> bindingsToInclude, boolean allowDeclarations,
- IIndexFileSet reachableHeaders) throws CoreException {
+ private List<InclusionRequest> createInclusionRequests(IASTTranslationUnit ast, Set<IBinding> bindingsToInclude,
+ boolean allowDeclarations, IIndexFileSet reachableHeaders) throws CoreException {
List<InclusionRequest> requests = new ArrayList<>(bindingsToInclude.size());
IIndex index = fContext.getIndex();
@@ -930,8 +937,7 @@ public class IncludeOrganizer {
private String createIncludeDirective(IncludePrototype include, String lineComment) {
StringBuilder buf = new StringBuilder();
// Unresolved includes are preserved out of caution. Partner include is always preserved.
- if (!include.isRequired() && include.getHeader() != null
- && !fContext.isPartnerFile(include.getHeader())) {
+ if (!include.isRequired() && include.getHeader() != null && !fContext.isPartnerFile(include.getHeader())) {
switch (fContext.getPreferences().unusedStatementsDisposition) {
case REMOVE:
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java
index 0f4e6c07307..7b8b784621d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java
@@ -36,7 +36,9 @@ public class IncludePreferences implements Comparator<StyledInclude> {
private static final String DEFAULT_PARTNER_FILE_SUFFIXES = "test,unittest"; //$NON-NLS-1$
private static final String DEFAULT_EXTENSIONS_OF_AUTO_EXPORTED_FILES = "inc"; //$NON-NLS-1$
- public static enum UnusedStatementDisposition { REMOVE, COMMENT_OUT, KEEP }
+ public static enum UnusedStatementDisposition {
+ REMOVE, COMMENT_OUT, KEEP
+ }
public final Map<IncludeKind, IncludeGroupStyle> includeStyles;
public final boolean allowReordering;
@@ -62,7 +64,8 @@ public class IncludePreferences implements Comparator<StyledInclude> {
loadStyle(IncludeKind.IN_SUBFOLDER, PreferenceConstants.INCLUDE_STYLE_SUBFOLDER, project);
loadStyle(IncludeKind.SYSTEM, PreferenceConstants.INCLUDE_STYLE_SYSTEM, project);
loadStyle(IncludeKind.SYSTEM_WITH_EXTENSION, PreferenceConstants.INCLUDE_STYLE_SYSTEM_WITH_EXTENSION, project);
- loadStyle(IncludeKind.SYSTEM_WITHOUT_EXTENSION, PreferenceConstants.INCLUDE_STYLE_SYSTEM_WITHOUT_EXTENSION, project);
+ loadStyle(IncludeKind.SYSTEM_WITHOUT_EXTENSION, PreferenceConstants.INCLUDE_STYLE_SYSTEM_WITHOUT_EXTENSION,
+ project);
loadStyle(IncludeKind.OTHER, PreferenceConstants.INCLUDE_STYLE_OTHER, project);
loadStyle(IncludeKind.IN_SAME_PROJECT, PreferenceConstants.INCLUDE_STYLE_SAME_PROJECT, project);
loadStyle(IncludeKind.IN_OTHER_PROJECT, PreferenceConstants.INCLUDE_STYLE_OTHER_PROJECT, project);
@@ -77,48 +80,47 @@ public class IncludePreferences implements Comparator<StyledInclude> {
}
// TODO(sprigogin): Load styles for headers matching patterns.
- forwardDeclareCompositeTypes = PreferenceConstants.getPreference(
- PreferenceConstants.FORWARD_DECLARE_COMPOSITE_TYPES, project, true);
- forwardDeclareEnums = PreferenceConstants.getPreference(
- PreferenceConstants.FORWARD_DECLARE_ENUMS, project, false);
- forwardDeclareFunctions = PreferenceConstants.getPreference(
- PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, project, false);
- forwardDeclareExternalVariables = PreferenceConstants.getPreference(
- PreferenceConstants.FORWARD_DECLARE_EXTERNAL_VARIABLES, project, false);
- forwardDeclareTemplates = PreferenceConstants.getPreference(
- PreferenceConstants.FORWARD_DECLARE_TEMPLATES, project, false);
- forwardDeclareNamespaceElements = PreferenceConstants.getPreference(
- PreferenceConstants.FORWARD_DECLARE_NAMESPACE_ELEMENTS, project, true);
+ forwardDeclareCompositeTypes = PreferenceConstants
+ .getPreference(PreferenceConstants.FORWARD_DECLARE_COMPOSITE_TYPES, project, true);
+ forwardDeclareEnums = PreferenceConstants.getPreference(PreferenceConstants.FORWARD_DECLARE_ENUMS, project,
+ false);
+ forwardDeclareFunctions = PreferenceConstants.getPreference(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS,
+ project, false);
+ forwardDeclareExternalVariables = PreferenceConstants
+ .getPreference(PreferenceConstants.FORWARD_DECLARE_EXTERNAL_VARIABLES, project, false);
+ forwardDeclareTemplates = PreferenceConstants.getPreference(PreferenceConstants.FORWARD_DECLARE_TEMPLATES,
+ project, false);
+ forwardDeclareNamespaceElements = PreferenceConstants
+ .getPreference(PreferenceConstants.FORWARD_DECLARE_NAMESPACE_ELEMENTS, project, true);
// Although templates may be forward declared, it is done so rarely that we assume that it
// never happens.
// TODO(sprigogin): Create a preference for this.
assumeTemplatesMayBeForwardDeclared = false;
- String value = PreferenceConstants.getPreference(
- PreferenceConstants.INCLUDES_PARTNER_FILE_SUFFIXES, project, DEFAULT_PARTNER_FILE_SUFFIXES);
+ String value = PreferenceConstants.getPreference(PreferenceConstants.INCLUDES_PARTNER_FILE_SUFFIXES, project,
+ DEFAULT_PARTNER_FILE_SUFFIXES);
partnerFileSuffixes = value.split(","); //$NON-NLS-1$
-
- value = PreferenceConstants.getPreference(
- PreferenceConstants.INCLUDES_EXTENSIONS_OF_AUTO_EXPORTED_FILES, project,
- DEFAULT_EXTENSIONS_OF_AUTO_EXPORTED_FILES);
+
+ value = PreferenceConstants.getPreference(PreferenceConstants.INCLUDES_EXTENSIONS_OF_AUTO_EXPORTED_FILES,
+ project, DEFAULT_EXTENSIONS_OF_AUTO_EXPORTED_FILES);
extensionsOfAutoExportedFiles = value.split(","); //$NON-NLS-1$
- heuristicHeaderSubstitution = PreferenceConstants.getPreference(
- PreferenceConstants.INCLUDES_HEURISTIC_HEADER_SUBSTITUTION, project, true);
+ heuristicHeaderSubstitution = PreferenceConstants
+ .getPreference(PreferenceConstants.INCLUDES_HEURISTIC_HEADER_SUBSTITUTION, project, true);
- allowReordering = PreferenceConstants.getPreference(
- PreferenceConstants.INCLUDES_ALLOW_REORDERING, project, true);
+ allowReordering = PreferenceConstants.getPreference(PreferenceConstants.INCLUDES_ALLOW_REORDERING, project,
+ true);
// TODO(sprigogin): Create a preference for this.
allowIndirectInclusion = false;
- allowPartnerIndirectInclusion = PreferenceConstants.getPreference(
- PreferenceConstants.INCLUDES_ALLOW_PARTNER_INDIRECT_INCLUSION, project, true);
+ allowPartnerIndirectInclusion = PreferenceConstants
+ .getPreference(PreferenceConstants.INCLUDES_ALLOW_PARTNER_INDIRECT_INCLUSION, project, true);
// Unused include handling preferences
- value = PreferenceConstants.getPreference(
- PreferenceConstants.INCLUDES_UNUSED_STATEMENTS_DISPOSITION, project, null);
+ value = PreferenceConstants.getPreference(PreferenceConstants.INCLUDES_UNUSED_STATEMENTS_DISPOSITION, project,
+ null);
UnusedStatementDisposition disposition = null;
if (value != null)
disposition = UnusedStatementDisposition.valueOf(value);
@@ -198,14 +200,14 @@ public class IncludePreferences implements Comparator<StyledInclude> {
store.setDefault(PreferenceConstants.INCLUDES_HEADER_SUBSTITUTION,
HeaderSubstitutionMap.serializeMaps(GCCHeaderSubstitutionMaps.getDefaultMaps()));
- store.setDefault(PreferenceConstants.INCLUDES_SYMBOL_EXPORTING_HEADERS,
- SymbolExportMap.serializeMaps(Collections.singletonList(GCCHeaderSubstitutionMaps.getSymbolExportMap())));
+ store.setDefault(PreferenceConstants.INCLUDES_SYMBOL_EXPORTING_HEADERS, SymbolExportMap
+ .serializeMaps(Collections.singletonList(GCCHeaderSubstitutionMaps.getSymbolExportMap())));
}
@Override
public int compare(StyledInclude include1, StyledInclude include2) {
- int c = include1.getStyle().getGroupingStyle(includeStyles).getOrder() -
- include2.getStyle().getGroupingStyle(includeStyles).getOrder();
+ int c = include1.getStyle().getGroupingStyle(includeStyles).getOrder()
+ - include2.getStyle().getGroupingStyle(includeStyles).getOrder();
if (c != 0)
return c;
return include1.getIncludeInfo().compareTo(include2.getIncludeInfo());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeUtil.java
index eb4fd6dea02..414652b3306 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeUtil.java
@@ -55,7 +55,8 @@ import org.eclipse.cdt.internal.corext.codemanipulation.StyledInclude;
public class IncludeUtil {
/** Not instantiatable. All methods are static. */
- private IncludeUtil() {}
+ private IncludeUtil() {
+ }
/**
* Checks if a file is a source file (.c, .cpp, .cc, etc). Header files are not considered
@@ -71,7 +72,7 @@ public class IncludeUtil {
* @return {@code true} if the the file is a source file.
*/
public static boolean isSource(String filename, IProject project) {
- IContentType ct= CCorePlugin.getContentType(project, filename);
+ IContentType ct = CCorePlugin.getContentType(project, filename);
if (ct != null) {
String id = ct.getId();
if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id) || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
@@ -87,7 +88,7 @@ public class IncludeUtil {
* @return {@code true} if the the file is a header file.
*/
public static boolean isHeader(String filename, IProject project) {
- IContentType ct= CCorePlugin.getContentType(project, filename);
+ IContentType ct = CCorePlugin.getContentType(project, filename);
if (ct != null) {
String id = ct.getId();
if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id) || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
@@ -135,7 +136,7 @@ public class IncludeUtil {
IASTDeclaration[] declarations = ast.getDeclarations(true);
if (declarations.length != 0)
maxSafeOffset = declarations[0].getFileLocation().getNodeOffset();
-
+
boolean topCommentSkipped = false;
int includeOffset = -1;
int includeEndOffset = -1;
@@ -148,7 +149,7 @@ public class IncludeUtil {
if (offset >= maxSafeOffset)
break;
int endOffset = offset + fileLocation.getNodeLength();
-
+
if (includeGuardStatementsToSkip > 0) {
--includeGuardStatementsToSkip;
includeGuardEndOffset = endOffset;
@@ -159,7 +160,7 @@ public class IncludeUtil {
if (includeOffset < 0)
includeOffset = offset;
includeEndOffset = endOffset;
- includeGuardStatementsToSkip = 0; // Just in case
+ includeGuardStatementsToSkip = 0; // Just in case
} else {
break;
}
@@ -172,9 +173,9 @@ public class IncludeUtil {
includeOffset = 0;
}
if (!topCommentSkipped) {
- // Skip the first comment block near the top of the file.
- includeOffset = skipStandaloneCommentBlock(contents, includeOffset, maxSafeOffset,
- ast.getComments(), commentMap);
+ // Skip the first comment block near the top of the file.
+ includeOffset = skipStandaloneCommentBlock(contents, includeOffset, maxSafeOffset, ast.getComments(),
+ commentMap);
}
includeEndOffset = includeOffset;
} else {
@@ -202,8 +203,8 @@ public class IncludeUtil {
String path = include.getPath();
// An empty path means that the include was not resolved.
IPath header = path.isEmpty() ? null : Path.fromOSString(path);
- IncludeGroupStyle style =
- header != null ? inclusionContext.getIncludeStyle(header) : inclusionContext.getIncludeStyle(includeInfo);
+ IncludeGroupStyle style = header != null ? inclusionContext.getIncludeStyle(header)
+ : inclusionContext.getIncludeStyle(includeInfo);
StyledInclude prototype = new StyledInclude(header, includeInfo, style, include);
includes.add(prototype);
}
@@ -234,7 +235,7 @@ public class IncludeUtil {
i++;
}
IASTPreprocessorStatement statement = preprocessorStatements[i];
-
+
int offset = 0;
if (isPragmaOnce(statement)) {
offset = ASTNodes.endOffset(statement);
@@ -250,8 +251,8 @@ public class IncludeUtil {
statement = preprocessorStatements[i];
if (statement.isPartOfTranslationUnitFile()) {
if (count < 2) {
- findGuardInRange(contents, guard, ASTNodes.offset(statement),
- ASTNodes.endOffset(statement), includeGuardPositions);
+ findGuardInRange(contents, guard, ASTNodes.offset(statement), ASTNodes.endOffset(statement),
+ includeGuardPositions);
count++;
} else {
lastStatement = statement;
@@ -259,8 +260,7 @@ public class IncludeUtil {
}
}
if (lastStatement != null) {
- findGuardInRange(contents, guard, ASTNodes.offset(lastStatement),
- contents.length(), includeGuardPositions);
+ findGuardInRange(contents, guard, ASTNodes.offset(lastStatement), contents.length(), includeGuardPositions);
}
return guard;
}
@@ -269,12 +269,12 @@ public class IncludeUtil {
IASTPreprocessorStatement statement = findFirstPreprocessorStatement(ast);
if (statement == null)
return 0;
-
+
int num = 0;
int offset = 0;
if (isPragmaOnce(statement)) {
num++;
- offset = ASTNodes.endOffset(statement);
+ offset = ASTNodes.endOffset(statement);
}
char[] guard = detectIncludeGuard(contents, offset);
if (guard != null) {
@@ -287,10 +287,10 @@ public class IncludeUtil {
char[] contentsChars = contents.toCharArray();
if (offset != 0)
contentsChars = Arrays.copyOfRange(contentsChars, offset, contentsChars.length);
- CharArrayIntMap ppKeywords= new CharArrayIntMap(40, -1);
+ CharArrayIntMap ppKeywords = new CharArrayIntMap(40, -1);
Keywords.addKeywordsPreprocessor(ppKeywords);
- char[] guardChars = IncludeGuardDetection.detectIncludeGuard(
- new CharArray(contentsChars), new LexerOptions(), ppKeywords);
+ char[] guardChars = IncludeGuardDetection.detectIncludeGuard(new CharArray(contentsChars), new LexerOptions(),
+ ppKeywords);
return guardChars;
}
@@ -302,8 +302,8 @@ public class IncludeUtil {
}
}
- private static int skipStandaloneCommentBlock(String contents, int offset, int endOffset,
- IASTComment[] comments, NodeCommentMap commentMap) {
+ private static int skipStandaloneCommentBlock(String contents, int offset, int endOffset, IASTComment[] comments,
+ NodeCommentMap commentMap) {
Map<IASTComment, IASTNode> inverseLeadingMap = new HashMap<>();
for (Map.Entry<IASTNode, List<IASTComment>> entry : commentMap.getLeadingMap().entrySet()) {
IASTNode node = entry.getKey();
@@ -322,7 +322,7 @@ public class IncludeUtil {
}
}
}
-
+
for (int i = 0; i < comments.length; i++) {
IASTComment comment = comments[i];
int commentOffset = ASTNodes.offset(comment);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/InclusionRequest.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/InclusionRequest.java
index ad9318a5009..c3d631d7155 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/InclusionRequest.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/InclusionRequest.java
@@ -41,11 +41,10 @@ class InclusionRequest {
/**
* @param binding the binding that requires inclusion
* @param declaringHeaders headers that can be included to declare the binding and paths
- * that can be used to include them
+ * that can be used to include them
* @param reachable indicates whether the headers were previously included or not
*/
- public InclusionRequest(IBinding binding, Map<IIndexFile, IPath> declaringHeaders,
- boolean reachable) {
+ public InclusionRequest(IBinding binding, Map<IIndexFile, IPath> declaringHeaders, boolean reachable) {
fBinding = binding;
fDeclaringFiles = Collections.unmodifiableMap(declaringHeaders);
fReachable = reachable;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/Messages.java
index 6fc9189823c..026a8226b57 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/Messages.java
@@ -18,7 +18,7 @@ import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
public static String GCCHeaderSubstitutionMaps_c_map;
public static String GCCHeaderSubstitutionMaps_cpp_map;
-
+
private Messages() {
// Do not instantiate
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/SymbolExportMap.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/SymbolExportMap.java
index 5c2af944ab3..007823dc074 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/SymbolExportMap.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/SymbolExportMap.java
@@ -55,7 +55,7 @@ public class SymbolExportMap {
/**
* @param keysAndValues an array of keys and values: [key1, value1, key2, value2, ...].
* Keys and values may be optionally surrounded by double quotes or angle brackets.
- * Angle brackets indicate a system include.
+ * Angle brackets indicate a system include.
*/
public SymbolExportMap(String[] keysAndValues) {
if (keysAndValues.length % 2 != 0)
@@ -80,7 +80,7 @@ public class SymbolExportMap {
*/
protected void addMapping(String symbol, IncludeInfo header) {
if (symbol.equals(header))
- return; // Don't allow mapping to itself.
+ return; // Don't allow mapping to itself.
Set<IncludeInfo> list = map.get(symbol);
if (list == null) {
list = new LinkedHashSet<IncludeInfo>();
@@ -103,10 +103,10 @@ public class SymbolExportMap {
/**
* Returns header files that should be used instead of the given one.
- *
+ *
* @param from The header file to be replaced. A system header has to match exactly.
* A non-system header matches both, non-system and system headers.
- * @return The list of header files ordered by decreasing preference.
+ * @return The list of header files ordered by decreasing preference.
*/
public Set<IncludeInfo> getMapping(String from) {
Set<IncludeInfo> list = map.get(from);
@@ -181,7 +181,7 @@ public class SymbolExportMap {
if (i > 0)
buf.append(", "); //$NON-NLS-1$
buf.append(targets.get(i));
- }
+ }
}
return buf.toString();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java
index da32a421473..260379f4eca 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java
@@ -1,18 +1,18 @@
-/*******************************************************************************
+/*******************************************************************************
* Copyright (c) 2005, 2015 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
* IBM Corporation
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.util.ArrayList;
@@ -124,637 +124,634 @@ public class ASTManager implements IDisposable {
| ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
| ITranslationUnit.AST_PARSE_INACTIVE_CODE;
- public final static int TRUE= 1;
- public final static int FALSE= 0;
- public final static int UNKNOWN= -1;
-
- // TODO(sprigogin): Replace fSharedAST and fTranslationUnits with CRefactoringContext.
+ public final static int TRUE = 1;
+ public final static int FALSE = 0;
+ public final static int UNKNOWN = -1;
+
+ // TODO(sprigogin): Replace fSharedAST and fTranslationUnits with CRefactoringContext.
private IASTTranslationUnit fSharedAST;
- private final Map<IFile, IASTTranslationUnit> fTranslationUnits= new HashMap<>();
- private final Set<String> fProblemUnits= new HashSet<>();
- private final CRefactoringArgument fArgument;
- private IBinding[] fValidBindings;
- private String fRenameTo;
- private HashMap<IBinding, Integer> fKnownBindings;
- private HashSet<IBinding> fConflictingBinding;
+ private final Map<IFile, IASTTranslationUnit> fTranslationUnits = new HashMap<>();
+ private final Set<String> fProblemUnits = new HashSet<>();
+ private final CRefactoringArgument fArgument;
+ private IBinding[] fValidBindings;
+ private String fRenameTo;
+ private HashMap<IBinding, Integer> fKnownBindings;
+ private HashSet<IBinding> fConflictingBinding;
private boolean fDisposed;
- public static String nth_of_m(int n, int m) {
- StringBuilder nofm= new StringBuilder();
- append_nth_of_m(n, m, nofm);
- return nofm.toString();
- }
-
- static void append_nth_of_m(int n, int m, StringBuilder buf) {
- buf.append(n);
- switch (n) {
- case 1:
- buf.append("st"); //$NON-NLS-1$
- break;
- case 2:
- buf.append("nd"); //$NON-NLS-1$
- break;
- case 3:
- buf.append("rd"); //$NON-NLS-1$
- break;
- default:
- buf.append("th"); //$NON-NLS-1$
- break;
- }
- buf.append(" of "); //$NON-NLS-1$
- buf.append(m);
- }
-
- public static IASTFileLocation getLocationInTranslationUnit(IASTNode node) {
- return node.getFileLocation();
- }
-
- public static IASTName getSimpleName(IASTName name) {
- if (name instanceof ICPPASTQualifiedName) {
- if (name.getLastName() != null) {
- name= name.getLastName();
- }
- }
- return name;
- }
-
- /**
- * Returns TRUE, FALSE or UNKNOWN.
- * @throws DOMException
- */
- public static int isSameBinding(IIndex index, IBinding b1, IBinding b2) throws DOMException {
- if (b1 == null || b2 == null) {
- return UNKNOWN;
- }
- if (b1.equals(b2)) {
- return TRUE;
- }
- if (b1 instanceof IIndexBinding || b2 instanceof IIndexBinding) {
- if (index != null) {
- IIndexBinding b11 = index.adaptBinding(b1);
- if (b11 != null)
- b1= b11;
- IIndexBinding b21 = index.adaptBinding(b2);
- if (b21 != null)
- b2= b21;
- if (b1.equals(b2))
- return TRUE;
- }
- }
-
- String n1= b1.getName();
- String n2= b2.getName();
- if (n1 == null || n2 == null) {
- return UNKNOWN;
- }
- if (!n1.equals(n2)) {
- return FALSE;
- }
- if (b1 instanceof ICompositeType) {
- if (!(b2 instanceof ICompositeType)) {
- return FALSE;
- }
- ICompositeType c1= (ICompositeType) b1;
- ICompositeType c2= (ICompositeType) b2;
- if (c1.getKey() != c2.getKey()) {
- return FALSE;
- }
- IScope s1= c1.getCompositeScope();
- if (s1 != null) s1= s1.getParent();
- IScope s2= c2.getCompositeScope();
- if (s2 != null) s2= s2.getParent();
- return isSameScope(s1, s2, false);
- }
-
- if (b1 instanceof IFunction) {
- if (!(b2 instanceof IFunction)) {
- return FALSE;
- }
- boolean isStatic= false;
- boolean checkSig= true;
- IFunction c1= (IFunction) b1;
- IFunction c2= (IFunction) b2;
- if (b1 instanceof ICPPMethod) {
- if (!(b2 instanceof ICPPMethod)) {
- return FALSE;
- }
- } else {
- if (b2 instanceof ICPPMethod) {
- return FALSE;
- }
- isStatic= c1.isStatic() || c2.isStatic();
- if ((!(b1 instanceof ICPPFunction) || ((ICPPFunction) b1).isExternC()) &&
- (!(b2 instanceof ICPPFunction) || ((ICPPFunction) b2).isExternC())) {
- checkSig= false;
- }
- }
-
- int r1= isSameScope(b1.getScope(), b2.getScope(), isStatic);
- if (r1 == FALSE) {
- return FALSE;
- }
-
- int r2= checkSig ? hasSameSignature(c1, c2) : TRUE;
- if (r2 == FALSE) {
- return FALSE;
- }
- if (r1 != r2) {
- return UNKNOWN;
- }
- return r1;
- }
-
- if (b1 instanceof IVariable) {
- boolean fileStatic= false;
- if (!(b2 instanceof IVariable)) {
- return FALSE;
- }
-
- IVariable c1= (IVariable) b1;
- IVariable c2= (IVariable) b2;
- if (b1 instanceof IField) {
- if (!(b2 instanceof IField)) {
- return FALSE;
- }
- } else if (b1 instanceof IParameter) {
- if (!(b2 instanceof IParameter)) {
- return FALSE;
- }
- } else {
- if (b2 instanceof IField || b2 instanceof IParameter) {
- return FALSE;
- }
- fileStatic= c1.isStatic() || c2.isStatic();
- }
- int result= isSameScope(c1.getScope(), c2.getScope(), fileStatic);
- return result == UNKNOWN ? TRUE : result;
- }
-
- if (b1 instanceof IEnumerator) {
- if (!(b2 instanceof IEnumerator)) {
- return FALSE;
- }
- return isSameScope(b1.getScope(), b2.getScope(), false);
- }
-
- if (b1 instanceof ITypedef) {
- if (!(b2 instanceof ITypedef)) {
- return FALSE;
- }
- return isSameScope(b1.getScope(), b2.getScope(), false);
- }
-
- if (b1 instanceof IMacroBinding) {
- if (!(b2 instanceof IMacroBinding)) {
- return FALSE;
- }
- return TRUE;
- }
- if (b1 instanceof IEnumeration) {
- if (!(b2 instanceof IEnumeration)) {
- return FALSE;
- }
- return isSameScope(b1.getScope(), b2.getScope(), false);
- }
- int scopeCmp= isSameScope(b1.getScope(), b2.getScope(), false);
- if (scopeCmp != TRUE) {
- return scopeCmp;
- }
-
- if (b1.getClass().equals(b2.getClass())) {
- return TRUE;
- }
- return UNKNOWN;
- }
-
- public static int isSameScope(IScope s1, IScope s2, boolean fileStatic) throws DOMException {
- if (s1 == s2) {
- return TRUE;
- }
- IASTNode node1= ASTInternal.getPhysicalNodeOfScope(s1);
- IASTNode node2= ASTInternal.getPhysicalNodeOfScope(s2);
-
- // Forward declarations do not have parent scopes.
- if (s1 == null) {
- if (!fileStatic && node2 instanceof IASTTranslationUnit) {
- return TRUE;
- }
- return UNKNOWN;
- }
- if (s2 == null) {
- if (!fileStatic && node1 instanceof IASTTranslationUnit) {
- return TRUE;
- }
- return UNKNOWN;
- }
-
- if (s1.equals(s2)) {
- return TRUE;
- }
-
- if (node1 instanceof IASTTranslationUnit && node2 instanceof IASTTranslationUnit) {
- return hasSameLocation(node1, node2, fileStatic);
- }
-
- if (s1.getKind() == EScopeKind.eGlobal && s2.getKind() == EScopeKind.eGlobal)
- return TRUE;
-
-
- if (s1 instanceof ICPPBlockScope) {
- if (s2 instanceof ICPPBlockScope) {
- return hasSameLocation(node1, node2, fileStatic);
- }
- return FALSE;
- }
-
- String name1= getName(s1);
- String name2= getName(s2);
- if (s1 instanceof ICPPNamespaceScope) {
- if (s2 instanceof ICPPNamespaceScope) {
- ICPPNamespaceScope n1= (ICPPNamespaceScope) s1;
- ICPPNamespaceScope n2= (ICPPNamespaceScope) s2;
- int r1= hasSameLocation(node1, node2, fileStatic);
- if (r1 == TRUE) {
- return r1;
- }
- if (name1 == null || name2 == null || !name1.equals(name2)) {
- return FALSE;
- }
- return isSameScope(n1.getParent(), n2.getParent(), fileStatic);
- }
- return FALSE;
- }
-
- if (name1 != null && name2 != null && !name1.equals(name2)) {
- return FALSE;
- }
-
- // Classes.
- if (s1 instanceof ICPPClassScope || s1 instanceof ICCompositeTypeScope) {
- if (s2 instanceof ICPPClassScope || s2 instanceof ICCompositeTypeScope) {
- return isSameScope(s1.getParent(), s2.getParent(), fileStatic);
- }
- return FALSE;
- }
- // Functions.
- if (s1 instanceof ICPPFunctionScope) {
- if (s2 instanceof ICPPFunctionScope) {
- return hasSameLocation(node1, node2, true);
- }
- return FALSE;
- }
- if (s1 instanceof ICFunctionScope || s1 instanceof ICFunctionPrototypeScope
- || s1 instanceof ICScope) {
- if (s2 instanceof ICFunctionScope || s2 instanceof ICFunctionPrototypeScope
- || s2 instanceof ICScope) {
- return hasSameLocation(node1, node2, true);
- }
- return FALSE;
- }
-
- return isSameScope(s1.getParent(), s2.getParent(), fileStatic);
- }
-
- public static String getName(IScope scope) {
- String name= null;
- if (scope instanceof IIndexScope) {
- IIndexScope indexScope= (IIndexScope) scope;
+ public static String nth_of_m(int n, int m) {
+ StringBuilder nofm = new StringBuilder();
+ append_nth_of_m(n, m, nofm);
+ return nofm.toString();
+ }
+
+ static void append_nth_of_m(int n, int m, StringBuilder buf) {
+ buf.append(n);
+ switch (n) {
+ case 1:
+ buf.append("st"); //$NON-NLS-1$
+ break;
+ case 2:
+ buf.append("nd"); //$NON-NLS-1$
+ break;
+ case 3:
+ buf.append("rd"); //$NON-NLS-1$
+ break;
+ default:
+ buf.append("th"); //$NON-NLS-1$
+ break;
+ }
+ buf.append(" of "); //$NON-NLS-1$
+ buf.append(m);
+ }
+
+ public static IASTFileLocation getLocationInTranslationUnit(IASTNode node) {
+ return node.getFileLocation();
+ }
+
+ public static IASTName getSimpleName(IASTName name) {
+ if (name instanceof ICPPASTQualifiedName) {
+ if (name.getLastName() != null) {
+ name = name.getLastName();
+ }
+ }
+ return name;
+ }
+
+ /**
+ * Returns TRUE, FALSE or UNKNOWN.
+ * @throws DOMException
+ */
+ public static int isSameBinding(IIndex index, IBinding b1, IBinding b2) throws DOMException {
+ if (b1 == null || b2 == null) {
+ return UNKNOWN;
+ }
+ if (b1.equals(b2)) {
+ return TRUE;
+ }
+ if (b1 instanceof IIndexBinding || b2 instanceof IIndexBinding) {
+ if (index != null) {
+ IIndexBinding b11 = index.adaptBinding(b1);
+ if (b11 != null)
+ b1 = b11;
+ IIndexBinding b21 = index.adaptBinding(b2);
+ if (b21 != null)
+ b2 = b21;
+ if (b1.equals(b2))
+ return TRUE;
+ }
+ }
+
+ String n1 = b1.getName();
+ String n2 = b2.getName();
+ if (n1 == null || n2 == null) {
+ return UNKNOWN;
+ }
+ if (!n1.equals(n2)) {
+ return FALSE;
+ }
+ if (b1 instanceof ICompositeType) {
+ if (!(b2 instanceof ICompositeType)) {
+ return FALSE;
+ }
+ ICompositeType c1 = (ICompositeType) b1;
+ ICompositeType c2 = (ICompositeType) b2;
+ if (c1.getKey() != c2.getKey()) {
+ return FALSE;
+ }
+ IScope s1 = c1.getCompositeScope();
+ if (s1 != null)
+ s1 = s1.getParent();
+ IScope s2 = c2.getCompositeScope();
+ if (s2 != null)
+ s2 = s2.getParent();
+ return isSameScope(s1, s2, false);
+ }
+
+ if (b1 instanceof IFunction) {
+ if (!(b2 instanceof IFunction)) {
+ return FALSE;
+ }
+ boolean isStatic = false;
+ boolean checkSig = true;
+ IFunction c1 = (IFunction) b1;
+ IFunction c2 = (IFunction) b2;
+ if (b1 instanceof ICPPMethod) {
+ if (!(b2 instanceof ICPPMethod)) {
+ return FALSE;
+ }
+ } else {
+ if (b2 instanceof ICPPMethod) {
+ return FALSE;
+ }
+ isStatic = c1.isStatic() || c2.isStatic();
+ if ((!(b1 instanceof ICPPFunction) || ((ICPPFunction) b1).isExternC())
+ && (!(b2 instanceof ICPPFunction) || ((ICPPFunction) b2).isExternC())) {
+ checkSig = false;
+ }
+ }
+
+ int r1 = isSameScope(b1.getScope(), b2.getScope(), isStatic);
+ if (r1 == FALSE) {
+ return FALSE;
+ }
+
+ int r2 = checkSig ? hasSameSignature(c1, c2) : TRUE;
+ if (r2 == FALSE) {
+ return FALSE;
+ }
+ if (r1 != r2) {
+ return UNKNOWN;
+ }
+ return r1;
+ }
+
+ if (b1 instanceof IVariable) {
+ boolean fileStatic = false;
+ if (!(b2 instanceof IVariable)) {
+ return FALSE;
+ }
+
+ IVariable c1 = (IVariable) b1;
+ IVariable c2 = (IVariable) b2;
+ if (b1 instanceof IField) {
+ if (!(b2 instanceof IField)) {
+ return FALSE;
+ }
+ } else if (b1 instanceof IParameter) {
+ if (!(b2 instanceof IParameter)) {
+ return FALSE;
+ }
+ } else {
+ if (b2 instanceof IField || b2 instanceof IParameter) {
+ return FALSE;
+ }
+ fileStatic = c1.isStatic() || c2.isStatic();
+ }
+ int result = isSameScope(c1.getScope(), c2.getScope(), fileStatic);
+ return result == UNKNOWN ? TRUE : result;
+ }
+
+ if (b1 instanceof IEnumerator) {
+ if (!(b2 instanceof IEnumerator)) {
+ return FALSE;
+ }
+ return isSameScope(b1.getScope(), b2.getScope(), false);
+ }
+
+ if (b1 instanceof ITypedef) {
+ if (!(b2 instanceof ITypedef)) {
+ return FALSE;
+ }
+ return isSameScope(b1.getScope(), b2.getScope(), false);
+ }
+
+ if (b1 instanceof IMacroBinding) {
+ if (!(b2 instanceof IMacroBinding)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+ if (b1 instanceof IEnumeration) {
+ if (!(b2 instanceof IEnumeration)) {
+ return FALSE;
+ }
+ return isSameScope(b1.getScope(), b2.getScope(), false);
+ }
+ int scopeCmp = isSameScope(b1.getScope(), b2.getScope(), false);
+ if (scopeCmp != TRUE) {
+ return scopeCmp;
+ }
+
+ if (b1.getClass().equals(b2.getClass())) {
+ return TRUE;
+ }
+ return UNKNOWN;
+ }
+
+ public static int isSameScope(IScope s1, IScope s2, boolean fileStatic) throws DOMException {
+ if (s1 == s2) {
+ return TRUE;
+ }
+ IASTNode node1 = ASTInternal.getPhysicalNodeOfScope(s1);
+ IASTNode node2 = ASTInternal.getPhysicalNodeOfScope(s2);
+
+ // Forward declarations do not have parent scopes.
+ if (s1 == null) {
+ if (!fileStatic && node2 instanceof IASTTranslationUnit) {
+ return TRUE;
+ }
+ return UNKNOWN;
+ }
+ if (s2 == null) {
+ if (!fileStatic && node1 instanceof IASTTranslationUnit) {
+ return TRUE;
+ }
+ return UNKNOWN;
+ }
+
+ if (s1.equals(s2)) {
+ return TRUE;
+ }
+
+ if (node1 instanceof IASTTranslationUnit && node2 instanceof IASTTranslationUnit) {
+ return hasSameLocation(node1, node2, fileStatic);
+ }
+
+ if (s1.getKind() == EScopeKind.eGlobal && s2.getKind() == EScopeKind.eGlobal)
+ return TRUE;
+
+ if (s1 instanceof ICPPBlockScope) {
+ if (s2 instanceof ICPPBlockScope) {
+ return hasSameLocation(node1, node2, fileStatic);
+ }
+ return FALSE;
+ }
+
+ String name1 = getName(s1);
+ String name2 = getName(s2);
+ if (s1 instanceof ICPPNamespaceScope) {
+ if (s2 instanceof ICPPNamespaceScope) {
+ ICPPNamespaceScope n1 = (ICPPNamespaceScope) s1;
+ ICPPNamespaceScope n2 = (ICPPNamespaceScope) s2;
+ int r1 = hasSameLocation(node1, node2, fileStatic);
+ if (r1 == TRUE) {
+ return r1;
+ }
+ if (name1 == null || name2 == null || !name1.equals(name2)) {
+ return FALSE;
+ }
+ return isSameScope(n1.getParent(), n2.getParent(), fileStatic);
+ }
+ return FALSE;
+ }
+
+ if (name1 != null && name2 != null && !name1.equals(name2)) {
+ return FALSE;
+ }
+
+ // Classes.
+ if (s1 instanceof ICPPClassScope || s1 instanceof ICCompositeTypeScope) {
+ if (s2 instanceof ICPPClassScope || s2 instanceof ICCompositeTypeScope) {
+ return isSameScope(s1.getParent(), s2.getParent(), fileStatic);
+ }
+ return FALSE;
+ }
+ // Functions.
+ if (s1 instanceof ICPPFunctionScope) {
+ if (s2 instanceof ICPPFunctionScope) {
+ return hasSameLocation(node1, node2, true);
+ }
+ return FALSE;
+ }
+ if (s1 instanceof ICFunctionScope || s1 instanceof ICFunctionPrototypeScope || s1 instanceof ICScope) {
+ if (s2 instanceof ICFunctionScope || s2 instanceof ICFunctionPrototypeScope || s2 instanceof ICScope) {
+ return hasSameLocation(node1, node2, true);
+ }
+ return FALSE;
+ }
+
+ return isSameScope(s1.getParent(), s2.getParent(), fileStatic);
+ }
+
+ public static String getName(IScope scope) {
+ String name = null;
+ if (scope instanceof IIndexScope) {
+ IIndexScope indexScope = (IIndexScope) scope;
final IIndexName scopeName = indexScope.getScopeName();
if (scopeName != null) {
- name= scopeName.toString();
+ name = scopeName.toString();
}
} else {
- name= getNameOrNull(ASTInternal.getPhysicalNodeOfScope(scope));
- }
- return name;
- }
-
- public static int hasSameSignature(IFunction f1, IFunction f2) throws DOMException {
- if (f1.takesVarArgs() != f2.takesVarArgs())
- return FALSE;
-
- if (f1 instanceof ICPPMethod != f2 instanceof ICPPMethod)
- return FALSE;
-
- return hasSameSignature(f1.getType(), f2.getType());
- }
-
- public static int hasSameSignature(IFunctionType t1, IFunctionType t2) throws DOMException {
- if (t1 instanceof ICPPFunctionType && t2 instanceof ICPPFunctionType) {
- ICPPFunctionType cppt1= (ICPPFunctionType) t1;
- ICPPFunctionType cppt2= (ICPPFunctionType) t2;
- if (cppt1.isConst() != cppt2.isConst())
- return FALSE;
- if (cppt1.isVolatile() != cppt2.isVolatile())
- return FALSE;
- }
- return isSameParameterList(t1.getParameterTypes(), t2.getParameterTypes());
- }
-
- private static int isSameParameterList(IType[] p1, IType[] p2) throws DOMException {
- if (p1 == p2) {
- return TRUE;
- }
- if (p1 == null || p2 == null) {
- return UNKNOWN;
- }
- if (p1.length != p2.length) {
- return FALSE;
- }
- int retval= TRUE;
- for (int i = 0; i < p2.length; i++) {
- switch (isSameType(p1[i], p2[i])) {
- case FALSE:
- return FALSE;
- case UNKNOWN:
- retval= UNKNOWN;
- break;
- }
- }
-
- return retval;
- }
-
- private static int isSameType(IType t1, IType t2) throws DOMException {
- if (t1 != null && t2 != null && t1.isSameType(t2)) {
- return TRUE;
- }
- t1= getRealType(t1);
- t2= getRealType(t2);
- if (t1 == t2) {
- return TRUE;
- }
- if (t1 == null || t2 == null || t1 instanceof ISemanticProblem || t2 instanceof ISemanticProblem) {
- return UNKNOWN;
- }
-
- if (t1 instanceof IArrayType) {
- if (t2 instanceof IArrayType) {
- IArrayType a1= (IArrayType) t1;
- IArrayType a2= (IArrayType) t2;
- return isSameType(a1.getType(), a2.getType());
- }
- return FALSE;
- }
-
- if (t1 instanceof IBasicType) {
- if (t2 instanceof IBasicType) {
- IBasicType a1= (IBasicType) t1;
- IBasicType a2= (IBasicType) t2;
- if (a1.getKind() != a2.getKind()) {
- return FALSE;
- }
- if (getSigned(a1) != getSigned(a2) || a1.isUnsigned() != a2.isUnsigned()) {
- return FALSE;
- }
- if (a1.isLong() != a2.isLong() || a1.isShort() != a2.isShort()) {
- return FALSE;
- }
- return TRUE;
- }
- return FALSE;
- }
-
- if (t1 instanceof ICompositeType) {
- if (t2 instanceof ICompositeType) {
- ICompositeType a1= (ICompositeType) t1;
- ICompositeType a2= (ICompositeType) t2;
- if (a1.getKey() != a2.getKey()) {
- return FALSE;
- }
- return isSameScope(a1.getCompositeScope(), a2.getCompositeScope(), false);
- }
- return FALSE;
- }
-
- if (t1 instanceof ICPPReferenceType) {
- if (t2 instanceof ICPPReferenceType) {
- ICPPReferenceType a1= (ICPPReferenceType) t1;
- ICPPReferenceType a2= (ICPPReferenceType) t2;
- return isSameType(a1.getType(), a2.getType());
- }
- return FALSE;
- }
-
- if (t1 instanceof ICPPTemplateTypeParameter) {
- if (t2 instanceof ICPPTemplateTypeParameter) {
- return TRUE;
- }
- return FALSE;
- }
-
- if (t1 instanceof IEnumeration) {
- if (t2 instanceof IEnumeration) {
- IEnumeration a1= (IEnumeration) t1;
- IEnumeration a2= (IEnumeration) t2;
-
- return isSameScope(a1.getScope(), a2.getScope(), false);
- }
- return FALSE;
- }
-
- if (t1 instanceof IFunctionType) {
- if (t2 instanceof IFunctionType) {
- IFunctionType a1= (IFunctionType) t1;
- IFunctionType a2= (IFunctionType) t2;
- return hasSameSignature(a1, a2);
- }
- return FALSE;
- }
-
- if (t1 instanceof IPointerType) {
- if (t2 instanceof IPointerType) {
- IPointerType a1= (IPointerType) t1;
- IPointerType a2= (IPointerType) t2;
- if (a1.isConst() != a2.isConst() || a1.isVolatile() != a2.isVolatile() || a1.isRestrict() != a2.isRestrict()) {
- return FALSE;
- }
- return isSameType(a1.getType(), a2.getType());
- }
- return FALSE;
- }
-
- if (t1 instanceof IQualifierType) {
- if (t2 instanceof IQualifierType) {
- IQualifierType a1= (IQualifierType) t1;
- IQualifierType a2= (IQualifierType) t2;
- if (a1.isConst() != a2.isConst() || a1.isVolatile() != a2.isVolatile()) {
- return FALSE;
- }
- return isSameType(a1.getType(), a2.getType());
- }
- return FALSE;
- }
-
- return UNKNOWN;
- }
-
- private static boolean getSigned(IBasicType a2) {
- if (a2.isSigned()) {
- return true;
- }
- if (a2.isUnsigned()) {
- return false;
- }
- switch (a2.getKind()) {
- case eInt:
- case eUnspecified:
- return true;
- default:
- break;
- }
- return false;
- }
-
- private static IType getRealType(IType t) {
- while (t instanceof ITypedef) {
- t= ((ITypedef) t).getType();
- }
- return t;
- }
-
- private static String getNameOrNull(IASTNode node) {
- if (node instanceof IASTDeclarator) {
- return getSimpleName(((IASTDeclarator) node).getName()).toString();
- }
- if (node instanceof IASTNamedTypeSpecifier) {
- return getSimpleName(((IASTNamedTypeSpecifier) node).getName()).toString();
- }
- if (node instanceof IASTCompositeTypeSpecifier) {
- return getSimpleName(((IASTCompositeTypeSpecifier) node).getName()).toString();
- }
- if (node instanceof ICPPASTNamespaceDefinition) {
- return getSimpleName(((ICPPASTNamespaceDefinition) node).getName()).toString();
- }
- if (node instanceof IASTTranslationUnit) {
- return ((IASTTranslationUnit) node).getFilePath();
- }
- return null;
- }
-
- private static int hasSameLocation(IASTNode node1, IASTNode node2, boolean fileStatic) {
- if (node1 == null || node2 == null) {
- return UNKNOWN;
- }
- if (!fileStatic && node1 instanceof IASTTranslationUnit &&
- node2 instanceof IASTTranslationUnit) {
- return TRUE;
- }
-
- IASTFileLocation l1= node1.getNodeLocations()[0].asFileLocation();
- IASTFileLocation l2= node2.getNodeLocations()[0].asFileLocation();
- if (l1 == null || l2 == null) {
- return UNKNOWN;
- }
- if (!l1.getFileName().equals(l2.getFileName())) {
- return FALSE;
- }
- if (l1.getNodeOffset() != l2.getNodeOffset()) {
- return FALSE;
- }
- if (l1.getNodeLength() != l2.getNodeLength()) {
- return FALSE;
- }
- return TRUE;
- }
-
- private static IScope getContainingScope(IASTName name) {
- IASTTranslationUnit tu= name.getTranslationUnit();
- if (tu == null) {
- return null;
- }
- if (tu instanceof ICPPASTTranslationUnit) {
- return CPPVisitor.getContainingScope(name);
- }
- return CVisitor.getContainingScope(name);
- }
-
- public static boolean isLocalVariable(IVariable v, IScope scope) {
- if (v instanceof IParameter) {
- return false;
- }
- while (scope != null) {
- if (scope instanceof ICPPFunctionScope ||
- scope instanceof ICPPBlockScope ||
- scope instanceof ICFunctionScope) {
- return true;
- }
- try {
- scope= scope.getParent();
- } catch (DOMException e) {
- scope= null;
- }
- }
- return false;
- }
-
- public static boolean isLocalVariable(IVariable v) {
- try {
- return isLocalVariable(v, v.getScope());
- } catch (DOMException e) {
- return false;
- }
- }
-
- public static IBinding[] findInScope(final IScope scope, String name, IASTTranslationUnit tu,
- boolean removeGlobalsWhenClassScope) throws DOMException {
- IBinding[] result= null;
- result = scope.find(name, tu);
- if (result == null || result.length == 0) {
- return result;
- }
-
- // eliminate global bindings when looking up in a class type
- if (removeGlobalsWhenClassScope &&
- (scope instanceof ICPPClassScope || scope instanceof ICCompositeTypeScope)) {
- int count= 0;
- for (int i = 0; i < result.length; i++) {
- IBinding binding = result[i];
- IScope bscope= binding.getScope();
- if (!(bscope instanceof ICPPClassScope || bscope instanceof ICCompositeTypeScope)) {
- result[i]= null;
- } else {
- count++;
- }
- }
- if (count < result.length) {
- IBinding[] copy= new IBinding[count];
- int i= 0;
- for (IBinding b : result) {
- if (b != null) {
- copy[i++]= b;
- }
- }
- result= copy;
- }
- }
-
- // Try to find constructors.
- if (scope instanceof ICPPBlockScope) {
- for (int i = 0; i < result.length; i++) {
- IBinding binding = result[i];
- if (binding instanceof ICPPClassType) {
- ICPPClassType classType= (ICPPClassType) binding;
- if (classType.getKey() == ICPPClassType.k_class) {
- IBinding[] cons= classType.getConstructors();
- if (cons.length > 0 && ! (cons[0] instanceof IProblemBinding)) {
- result[i]= cons[0];
- }
- }
- }
- }
- }
-
- return result;
- }
-
- public ASTManager(CRefactoringArgument arg) {
- fArgument= arg;
- }
+ name = getNameOrNull(ASTInternal.getPhysicalNodeOfScope(scope));
+ }
+ return name;
+ }
+
+ public static int hasSameSignature(IFunction f1, IFunction f2) throws DOMException {
+ if (f1.takesVarArgs() != f2.takesVarArgs())
+ return FALSE;
+
+ if (f1 instanceof ICPPMethod != f2 instanceof ICPPMethod)
+ return FALSE;
+
+ return hasSameSignature(f1.getType(), f2.getType());
+ }
+
+ public static int hasSameSignature(IFunctionType t1, IFunctionType t2) throws DOMException {
+ if (t1 instanceof ICPPFunctionType && t2 instanceof ICPPFunctionType) {
+ ICPPFunctionType cppt1 = (ICPPFunctionType) t1;
+ ICPPFunctionType cppt2 = (ICPPFunctionType) t2;
+ if (cppt1.isConst() != cppt2.isConst())
+ return FALSE;
+ if (cppt1.isVolatile() != cppt2.isVolatile())
+ return FALSE;
+ }
+ return isSameParameterList(t1.getParameterTypes(), t2.getParameterTypes());
+ }
+
+ private static int isSameParameterList(IType[] p1, IType[] p2) throws DOMException {
+ if (p1 == p2) {
+ return TRUE;
+ }
+ if (p1 == null || p2 == null) {
+ return UNKNOWN;
+ }
+ if (p1.length != p2.length) {
+ return FALSE;
+ }
+ int retval = TRUE;
+ for (int i = 0; i < p2.length; i++) {
+ switch (isSameType(p1[i], p2[i])) {
+ case FALSE:
+ return FALSE;
+ case UNKNOWN:
+ retval = UNKNOWN;
+ break;
+ }
+ }
+
+ return retval;
+ }
+
+ private static int isSameType(IType t1, IType t2) throws DOMException {
+ if (t1 != null && t2 != null && t1.isSameType(t2)) {
+ return TRUE;
+ }
+ t1 = getRealType(t1);
+ t2 = getRealType(t2);
+ if (t1 == t2) {
+ return TRUE;
+ }
+ if (t1 == null || t2 == null || t1 instanceof ISemanticProblem || t2 instanceof ISemanticProblem) {
+ return UNKNOWN;
+ }
+
+ if (t1 instanceof IArrayType) {
+ if (t2 instanceof IArrayType) {
+ IArrayType a1 = (IArrayType) t1;
+ IArrayType a2 = (IArrayType) t2;
+ return isSameType(a1.getType(), a2.getType());
+ }
+ return FALSE;
+ }
+
+ if (t1 instanceof IBasicType) {
+ if (t2 instanceof IBasicType) {
+ IBasicType a1 = (IBasicType) t1;
+ IBasicType a2 = (IBasicType) t2;
+ if (a1.getKind() != a2.getKind()) {
+ return FALSE;
+ }
+ if (getSigned(a1) != getSigned(a2) || a1.isUnsigned() != a2.isUnsigned()) {
+ return FALSE;
+ }
+ if (a1.isLong() != a2.isLong() || a1.isShort() != a2.isShort()) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ if (t1 instanceof ICompositeType) {
+ if (t2 instanceof ICompositeType) {
+ ICompositeType a1 = (ICompositeType) t1;
+ ICompositeType a2 = (ICompositeType) t2;
+ if (a1.getKey() != a2.getKey()) {
+ return FALSE;
+ }
+ return isSameScope(a1.getCompositeScope(), a2.getCompositeScope(), false);
+ }
+ return FALSE;
+ }
+
+ if (t1 instanceof ICPPReferenceType) {
+ if (t2 instanceof ICPPReferenceType) {
+ ICPPReferenceType a1 = (ICPPReferenceType) t1;
+ ICPPReferenceType a2 = (ICPPReferenceType) t2;
+ return isSameType(a1.getType(), a2.getType());
+ }
+ return FALSE;
+ }
+
+ if (t1 instanceof ICPPTemplateTypeParameter) {
+ if (t2 instanceof ICPPTemplateTypeParameter) {
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ if (t1 instanceof IEnumeration) {
+ if (t2 instanceof IEnumeration) {
+ IEnumeration a1 = (IEnumeration) t1;
+ IEnumeration a2 = (IEnumeration) t2;
+
+ return isSameScope(a1.getScope(), a2.getScope(), false);
+ }
+ return FALSE;
+ }
+
+ if (t1 instanceof IFunctionType) {
+ if (t2 instanceof IFunctionType) {
+ IFunctionType a1 = (IFunctionType) t1;
+ IFunctionType a2 = (IFunctionType) t2;
+ return hasSameSignature(a1, a2);
+ }
+ return FALSE;
+ }
+
+ if (t1 instanceof IPointerType) {
+ if (t2 instanceof IPointerType) {
+ IPointerType a1 = (IPointerType) t1;
+ IPointerType a2 = (IPointerType) t2;
+ if (a1.isConst() != a2.isConst() || a1.isVolatile() != a2.isVolatile()
+ || a1.isRestrict() != a2.isRestrict()) {
+ return FALSE;
+ }
+ return isSameType(a1.getType(), a2.getType());
+ }
+ return FALSE;
+ }
+
+ if (t1 instanceof IQualifierType) {
+ if (t2 instanceof IQualifierType) {
+ IQualifierType a1 = (IQualifierType) t1;
+ IQualifierType a2 = (IQualifierType) t2;
+ if (a1.isConst() != a2.isConst() || a1.isVolatile() != a2.isVolatile()) {
+ return FALSE;
+ }
+ return isSameType(a1.getType(), a2.getType());
+ }
+ return FALSE;
+ }
+
+ return UNKNOWN;
+ }
+
+ private static boolean getSigned(IBasicType a2) {
+ if (a2.isSigned()) {
+ return true;
+ }
+ if (a2.isUnsigned()) {
+ return false;
+ }
+ switch (a2.getKind()) {
+ case eInt:
+ case eUnspecified:
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
+
+ private static IType getRealType(IType t) {
+ while (t instanceof ITypedef) {
+ t = ((ITypedef) t).getType();
+ }
+ return t;
+ }
+
+ private static String getNameOrNull(IASTNode node) {
+ if (node instanceof IASTDeclarator) {
+ return getSimpleName(((IASTDeclarator) node).getName()).toString();
+ }
+ if (node instanceof IASTNamedTypeSpecifier) {
+ return getSimpleName(((IASTNamedTypeSpecifier) node).getName()).toString();
+ }
+ if (node instanceof IASTCompositeTypeSpecifier) {
+ return getSimpleName(((IASTCompositeTypeSpecifier) node).getName()).toString();
+ }
+ if (node instanceof ICPPASTNamespaceDefinition) {
+ return getSimpleName(((ICPPASTNamespaceDefinition) node).getName()).toString();
+ }
+ if (node instanceof IASTTranslationUnit) {
+ return ((IASTTranslationUnit) node).getFilePath();
+ }
+ return null;
+ }
+
+ private static int hasSameLocation(IASTNode node1, IASTNode node2, boolean fileStatic) {
+ if (node1 == null || node2 == null) {
+ return UNKNOWN;
+ }
+ if (!fileStatic && node1 instanceof IASTTranslationUnit && node2 instanceof IASTTranslationUnit) {
+ return TRUE;
+ }
+
+ IASTFileLocation l1 = node1.getNodeLocations()[0].asFileLocation();
+ IASTFileLocation l2 = node2.getNodeLocations()[0].asFileLocation();
+ if (l1 == null || l2 == null) {
+ return UNKNOWN;
+ }
+ if (!l1.getFileName().equals(l2.getFileName())) {
+ return FALSE;
+ }
+ if (l1.getNodeOffset() != l2.getNodeOffset()) {
+ return FALSE;
+ }
+ if (l1.getNodeLength() != l2.getNodeLength()) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ private static IScope getContainingScope(IASTName name) {
+ IASTTranslationUnit tu = name.getTranslationUnit();
+ if (tu == null) {
+ return null;
+ }
+ if (tu instanceof ICPPASTTranslationUnit) {
+ return CPPVisitor.getContainingScope(name);
+ }
+ return CVisitor.getContainingScope(name);
+ }
+
+ public static boolean isLocalVariable(IVariable v, IScope scope) {
+ if (v instanceof IParameter) {
+ return false;
+ }
+ while (scope != null) {
+ if (scope instanceof ICPPFunctionScope || scope instanceof ICPPBlockScope
+ || scope instanceof ICFunctionScope) {
+ return true;
+ }
+ try {
+ scope = scope.getParent();
+ } catch (DOMException e) {
+ scope = null;
+ }
+ }
+ return false;
+ }
+
+ public static boolean isLocalVariable(IVariable v) {
+ try {
+ return isLocalVariable(v, v.getScope());
+ } catch (DOMException e) {
+ return false;
+ }
+ }
+
+ public static IBinding[] findInScope(final IScope scope, String name, IASTTranslationUnit tu,
+ boolean removeGlobalsWhenClassScope) throws DOMException {
+ IBinding[] result = null;
+ result = scope.find(name, tu);
+ if (result == null || result.length == 0) {
+ return result;
+ }
+
+ // eliminate global bindings when looking up in a class type
+ if (removeGlobalsWhenClassScope && (scope instanceof ICPPClassScope || scope instanceof ICCompositeTypeScope)) {
+ int count = 0;
+ for (int i = 0; i < result.length; i++) {
+ IBinding binding = result[i];
+ IScope bscope = binding.getScope();
+ if (!(bscope instanceof ICPPClassScope || bscope instanceof ICCompositeTypeScope)) {
+ result[i] = null;
+ } else {
+ count++;
+ }
+ }
+ if (count < result.length) {
+ IBinding[] copy = new IBinding[count];
+ int i = 0;
+ for (IBinding b : result) {
+ if (b != null) {
+ copy[i++] = b;
+ }
+ }
+ result = copy;
+ }
+ }
+
+ // Try to find constructors.
+ if (scope instanceof ICPPBlockScope) {
+ for (int i = 0; i < result.length; i++) {
+ IBinding binding = result[i];
+ if (binding instanceof ICPPClassType) {
+ ICPPClassType classType = (ICPPClassType) binding;
+ if (classType.getKey() == ICPPClassType.k_class) {
+ IBinding[] cons = classType.getConstructors();
+ if (cons.length > 0 && !(cons[0] instanceof IProblemBinding)) {
+ result[i] = cons[0];
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public ASTManager(CRefactoringArgument arg) {
+ fArgument = arg;
+ }
@Override
public void dispose() {
- Assert.isTrue(!fDisposed, "ASTManager.dispose() called more than once"); //$NON-NLS-1$
+ Assert.isTrue(!fDisposed, "ASTManager.dispose() called more than once"); //$NON-NLS-1$
fDisposed = true;
if (fSharedAST != null) {
ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
@@ -769,75 +766,74 @@ public class ASTManager implements IDisposable {
}
void analyzeArgument(IIndex index, IProgressMonitor pm, RefactoringStatus status) {
- if (fArgument == null) {
- return;
- }
-
- if (fArgument.getArgumentKind() != CRefactory.ARGUMENT_UNKNOWN) {
- return;
- }
-
- if (fArgument.getSourceFile() == null)
- return;
-
- pm.beginTask(RenameMessages.ASTManager_task_analyze, 2);
- IASTTranslationUnit tu= getAST(index, fArgument.getSourceFile(), true, status);
- pm.worked(1);
- if (tu != null) {
- final IASTNodeSelector nodeSelector = tu.getNodeSelector(tu.getFilePath());
+ if (fArgument == null) {
+ return;
+ }
+
+ if (fArgument.getArgumentKind() != CRefactory.ARGUMENT_UNKNOWN) {
+ return;
+ }
+
+ if (fArgument.getSourceFile() == null)
+ return;
+
+ pm.beginTask(RenameMessages.ASTManager_task_analyze, 2);
+ IASTTranslationUnit tu = getAST(index, fArgument.getSourceFile(), true, status);
+ pm.worked(1);
+ if (tu != null) {
+ final IASTNodeSelector nodeSelector = tu.getNodeSelector(tu.getFilePath());
final int offset = fArgument.getOffset();
final int length = fArgument.getLength();
- IASTName name= nodeSelector.findEnclosingName(offset, length);
- if (name != null) {
- name= name.getLastName();
- } else {
- IASTNode node= nodeSelector.findEnclosingNode(offset, length);
- if (node instanceof IASTPreprocessorMacroDefinition ||
- node instanceof IASTPreprocessorElifStatement ||
- node instanceof IASTPreprocessorIfdefStatement ||
- node instanceof IASTPreprocessorIfndefStatement ||
- node instanceof IASTPreprocessorIfStatement) {
- final IASTFileLocation fileLocation = node.getFileLocation();
- if (fileLocation != null) {
- final String ident= extractIdentifier(node.getRawSignature(),
- offset - fileLocation.getNodeOffset(), length);
- if (ident != null) {
- IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions();
- for (IASTPreprocessorMacroDefinition mdef : mdefs) {
- IASTName n= mdef.getName();
- if (ident.equals(n.toString())) {
- name= n;
- break;
- }
- }
- }
- }
- }
- }
- if (name != null) {
- fArgument.setName(name);
- IBinding binding= name.resolveBinding();
- if (binding != null) {
- IScope scope= null;
- try {
- scope = binding.getScope();
- } catch (DOMException e) {
- handleDOMException(tu, e, status);
- }
- fArgument.setBinding(name.getTranslationUnit(), binding, scope);
- }
- }
- }
- pm.worked(1);
- pm.done();
- }
+ IASTName name = nodeSelector.findEnclosingName(offset, length);
+ if (name != null) {
+ name = name.getLastName();
+ } else {
+ IASTNode node = nodeSelector.findEnclosingNode(offset, length);
+ if (node instanceof IASTPreprocessorMacroDefinition || node instanceof IASTPreprocessorElifStatement
+ || node instanceof IASTPreprocessorIfdefStatement
+ || node instanceof IASTPreprocessorIfndefStatement
+ || node instanceof IASTPreprocessorIfStatement) {
+ final IASTFileLocation fileLocation = node.getFileLocation();
+ if (fileLocation != null) {
+ final String ident = extractIdentifier(node.getRawSignature(),
+ offset - fileLocation.getNodeOffset(), length);
+ if (ident != null) {
+ IASTPreprocessorMacroDefinition[] mdefs = tu.getMacroDefinitions();
+ for (IASTPreprocessorMacroDefinition mdef : mdefs) {
+ IASTName n = mdef.getName();
+ if (ident.equals(n.toString())) {
+ name = n;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (name != null) {
+ fArgument.setName(name);
+ IBinding binding = name.resolveBinding();
+ if (binding != null) {
+ IScope scope = null;
+ try {
+ scope = binding.getScope();
+ } catch (DOMException e) {
+ handleDOMException(tu, e, status);
+ }
+ fArgument.setBinding(name.getTranslationUnit(), binding, scope);
+ }
+ }
+ }
+ pm.worked(1);
+ pm.done();
+ }
private String extractIdentifier(String rawSignature, int offset, int length) {
- char[] sig= rawSignature.toCharArray();
- int end= offset + length;
+ char[] sig = rawSignature.toCharArray();
+ int end = offset + length;
if (offset < 0 || end > sig.length)
return null;
-
+
for (int i = offset; i < end; i++) {
if (!Character.isJavaIdentifierPart(sig[i]))
return null;
@@ -863,649 +859,646 @@ public class ASTManager implements IDisposable {
* @param astStyle the style to pass to {@link ITranslationUnit#getAST(IIndex, int)} method.
* If a previously cached AST is returned, the style is not guaranteed to match
* the requested one.
- * @param cacheIt if {@code true}, the AST will be cached for later reuse
+ * @param cacheIt if {@code true}, the AST will be cached for later reuse
* @return the requested AST or {@code null}
* @throws CoreException
*/
- public synchronized IASTTranslationUnit getAST(IIndex index, IFile sourceFile, int astStyle,
- boolean cacheIt) throws CoreException {
- IASTTranslationUnit ast= fTranslationUnits.get(sourceFile);
- if (ast == null) {
- ICElement celem= CoreModel.getDefault().create(sourceFile);
- if (celem instanceof ITranslationUnit) {
- ITranslationUnit tu= CModelUtil.toWorkingCopy((ITranslationUnit) celem);
- if (fSharedAST != null && tu.equals(fSharedAST.getOriginatingTranslationUnit())) {
- ast = fSharedAST;
- } else {
- // Try to get a shared AST before creating our own.
- ast = ASTProvider.getASTProvider().acquireSharedAST(tu, index,
- ASTProvider.WAIT_ACTIVE_ONLY, null);
- if (ast != null) {
- if (fSharedAST != null) {
- ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
- }
- fSharedAST = ast;
- } else {
- ast= tu.getAST(index, astStyle);
- if (cacheIt) {
- fTranslationUnits.put(sourceFile, ast);
- }
- }
- }
- }
- }
- return ast;
- }
-
- private IASTTranslationUnit getAST(IIndex index, IFile sourceFile, boolean cacheIt,
- RefactoringStatus status) {
+ public synchronized IASTTranslationUnit getAST(IIndex index, IFile sourceFile, int astStyle, boolean cacheIt)
+ throws CoreException {
+ IASTTranslationUnit ast = fTranslationUnits.get(sourceFile);
+ if (ast == null) {
+ ICElement celem = CoreModel.getDefault().create(sourceFile);
+ if (celem instanceof ITranslationUnit) {
+ ITranslationUnit tu = CModelUtil.toWorkingCopy((ITranslationUnit) celem);
+ if (fSharedAST != null && tu.equals(fSharedAST.getOriginatingTranslationUnit())) {
+ ast = fSharedAST;
+ } else {
+ // Try to get a shared AST before creating our own.
+ ast = ASTProvider.getASTProvider().acquireSharedAST(tu, index, ASTProvider.WAIT_ACTIVE_ONLY, null);
+ if (ast != null) {
+ if (fSharedAST != null) {
+ ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
+ }
+ fSharedAST = ast;
+ } else {
+ ast = tu.getAST(index, astStyle);
+ if (cacheIt) {
+ fTranslationUnits.put(sourceFile, ast);
+ }
+ }
+ }
+ }
+ }
+ return ast;
+ }
+
+ private IASTTranslationUnit getAST(IIndex index, IFile sourceFile, boolean cacheIt, RefactoringStatus status) {
try {
return getAST(index, sourceFile, PARSE_MODE, cacheIt);
} catch (CoreException e) {
status.addError(e.getMessage());
return null;
}
- }
-
- public void analyzeTextMatches(IIndex index, Collection<CRefactoringMatch> matches,
- IProgressMonitor monitor, RefactoringStatus status) {
- CRefactoringMatchStore store= new CRefactoringMatchStore();
- for (CRefactoringMatch match : matches) {
- store.addMatch(match);
- }
-
- int count= store.getFileCount();
- String taskName= RenameMessages.ASTManager_task_generateAst;
- monitor.beginTask(taskName, 2 * count);
- monitor.setTaskName(taskName);
-
- List<IFile> files= store.getFileList();
- int cc= 0;
- long now= System.currentTimeMillis();
- long update= now;
- for (IFile file : files) {
- cc++;
- if (store.contains(file)) {
- if ((now = System.currentTimeMillis()) > update) {
- String nofm= nth_of_m(cc, count);
- String taskname= NLS.bind(RenameMessages.ASTManager_subtask_analyzing, nofm);
- monitor.subTask(taskname);
- update= now + 1000;
- }
- boolean doParse= false;
- Collection<CRefactoringMatch> fm= store.getMatchesForFile(file);
- for (Iterator<CRefactoringMatch> iterator = fm.iterator(); !doParse && iterator.hasNext();) {
- CRefactoringMatch match = iterator.next();
- switch (match.getLocation()) {
- case CRefactory.OPTION_IN_COMMENT:
- case CRefactory.OPTION_IN_INCLUDE_DIRECTIVE:
- case CRefactory.OPTION_IN_STRING_LITERAL:
- break;
- default:
- doParse= true;
- }
- }
-
- if (doParse) {
- IASTTranslationUnit tu= getAST(index, file, false, status);
- monitor.worked(1);
- analyzeTextMatchesOfTranslationUnit(tu, store, status);
- if (status.hasFatalError()) {
- return;
- }
- monitor.worked(1);
- } else {
- monitor.worked(2);
- }
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- } else {
- monitor.worked(2);
- }
- }
- monitor.done();
- }
-
- private void analyzeTextMatchesOfTranslationUnit(IASTTranslationUnit tu,
- final CRefactoringMatchStore store, final RefactoringStatus status) {
- fKnownBindings= new HashMap<>();
- fConflictingBinding= new HashSet<>();
- final Set<IPath> paths= new HashSet<>();
- boolean renamesMacro= fArgument.getArgumentKind() == CRefactory.ARGUMENT_MACRO;
-
- analyzeMacroMatches(tu, store, paths, status);
- if (status.hasFatalError()) return;
-
- if (renamesMacro) {
- findConflictingBindingsWithNewName(tu, store, paths, status);
- if (status.hasFatalError()) return;
- }
-
- analyzeLanguageMatches(tu, store, paths, status);
- if (status.hasFatalError()) return;
-
- for (IPath path : paths) {
- if (path != null) {
- store.removePath(path);
- }
- }
- handleConflictingBindings(tu, status);
- fKnownBindings= null;
- fConflictingBinding= null;
- }
-
- private void analyzeLanguageMatches(IASTTranslationUnit tu, final CRefactoringMatchStore store,
- final Set<IPath> paths, final RefactoringStatus status) {
- ASTNameVisitor nv = new ASTSpecificNameVisitor(fArgument.getName()) {
- @Override
+ }
+
+ public void analyzeTextMatches(IIndex index, Collection<CRefactoringMatch> matches, IProgressMonitor monitor,
+ RefactoringStatus status) {
+ CRefactoringMatchStore store = new CRefactoringMatchStore();
+ for (CRefactoringMatch match : matches) {
+ store.addMatch(match);
+ }
+
+ int count = store.getFileCount();
+ String taskName = RenameMessages.ASTManager_task_generateAst;
+ monitor.beginTask(taskName, 2 * count);
+ monitor.setTaskName(taskName);
+
+ List<IFile> files = store.getFileList();
+ int cc = 0;
+ long now = System.currentTimeMillis();
+ long update = now;
+ for (IFile file : files) {
+ cc++;
+ if (store.contains(file)) {
+ if ((now = System.currentTimeMillis()) > update) {
+ String nofm = nth_of_m(cc, count);
+ String taskname = NLS.bind(RenameMessages.ASTManager_subtask_analyzing, nofm);
+ monitor.subTask(taskname);
+ update = now + 1000;
+ }
+ boolean doParse = false;
+ Collection<CRefactoringMatch> fm = store.getMatchesForFile(file);
+ for (Iterator<CRefactoringMatch> iterator = fm.iterator(); !doParse && iterator.hasNext();) {
+ CRefactoringMatch match = iterator.next();
+ switch (match.getLocation()) {
+ case CRefactory.OPTION_IN_COMMENT:
+ case CRefactory.OPTION_IN_INCLUDE_DIRECTIVE:
+ case CRefactory.OPTION_IN_STRING_LITERAL:
+ break;
+ default:
+ doParse = true;
+ }
+ }
+
+ if (doParse) {
+ IASTTranslationUnit tu = getAST(index, file, false, status);
+ monitor.worked(1);
+ analyzeTextMatchesOfTranslationUnit(tu, store, status);
+ if (status.hasFatalError()) {
+ return;
+ }
+ monitor.worked(1);
+ } else {
+ monitor.worked(2);
+ }
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ } else {
+ monitor.worked(2);
+ }
+ }
+ monitor.done();
+ }
+
+ private void analyzeTextMatchesOfTranslationUnit(IASTTranslationUnit tu, final CRefactoringMatchStore store,
+ final RefactoringStatus status) {
+ fKnownBindings = new HashMap<>();
+ fConflictingBinding = new HashSet<>();
+ final Set<IPath> paths = new HashSet<>();
+ boolean renamesMacro = fArgument.getArgumentKind() == CRefactory.ARGUMENT_MACRO;
+
+ analyzeMacroMatches(tu, store, paths, status);
+ if (status.hasFatalError())
+ return;
+
+ if (renamesMacro) {
+ findConflictingBindingsWithNewName(tu, store, paths, status);
+ if (status.hasFatalError())
+ return;
+ }
+
+ analyzeLanguageMatches(tu, store, paths, status);
+ if (status.hasFatalError())
+ return;
+
+ for (IPath path : paths) {
+ if (path != null) {
+ store.removePath(path);
+ }
+ }
+ handleConflictingBindings(tu, status);
+ fKnownBindings = null;
+ fConflictingBinding = null;
+ }
+
+ private void analyzeLanguageMatches(IASTTranslationUnit tu, final CRefactoringMatchStore store,
+ final Set<IPath> paths, final RefactoringStatus status) {
+ ASTNameVisitor nv = new ASTSpecificNameVisitor(fArgument.getName()) {
+ @Override
protected int visitName(IASTName name, boolean isDestructor) {
- IPath path= analyzeAstMatch(name, store, isDestructor, status);
- paths.add(path);
- return ASTVisitor.PROCESS_CONTINUE;
- }
- };
- tu.accept(nv);
- }
-
- private void analyzeMacroMatches(IASTTranslationUnit tu, final CRefactoringMatchStore store,
- final Set<IPath> pathsVisited, final RefactoringStatus status) {
- String lookfor= fArgument.getName();
- IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions();
- for (IASTPreprocessorMacroDefinition mdef : mdefs) {
- IASTName macroName= mdef.getName();
- String macroNameStr= macroName.toString();
- if (fRenameTo.equals(macroNameStr)) {
- status.addFatalError(NLS.bind(RenameMessages.ASTManager_error_macro_name_conflict, fRenameTo));
- return;
- } else if (lookfor.equals(macroNameStr)) {
- IPath path= analyzeAstMatch(macroName, store, false, status);
- pathsVisited.add(path);
- IBinding macroBinding= macroName.resolveBinding();
- if (macroBinding != null) {
- IASTName[] refs= tu.getReferences(macroBinding);
- for (IASTName ref : refs) {
- path= analyzeAstMatch(ref, store, false, status);
- pathsVisited.add(path);
- }
- }
- }
- if (mdef instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
- boolean nameIsPar= false;
- IASTPreprocessorFunctionStyleMacroDefinition fm= (IASTPreprocessorFunctionStyleMacroDefinition) mdef;
- IASTFunctionStyleMacroParameter[] pars= fm.getParameters();
- if (pars != null) {
- for (int j = 0; !nameIsPar && j<pars.length; j++) {
- IASTFunctionStyleMacroParameter par = pars[j];
- String name= par.getParameter();
- if (lookfor.equals(name)) {
- nameIsPar= true;
- }
- }
- if (nameIsPar) {
- IASTFileLocation floc= mdef.getNodeLocations()[0].asFileLocation();
- int offset= floc.getNodeOffset();
- int end= offset+ floc.getNodeLength();
- Collection<CRefactoringMatch> matches= store.findMatchesInRange(
- new Path(floc.getFileName()), offset, end);
- for (CRefactoringMatch match : matches) {
- match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER);
- }
- }
- }
- }
- }
- }
-
-// private void markPreprocessorMatchesAsReference(
-// IASTTranslationUnit tu, final CRefactoringMatchStore store,
-// final Set pathsVisited, final RefactoringStatus status) {
-// IASTPreprocessorStatement[] pdefs= tu.getAllPreprocessorStatements();
-// for (int i = 0; i < pdefs.length; i++) {
-// IASTPreprocessorStatement pdef = pdefs[i];
-// if (pdef instanceof IASTPreprocessorIfdefStatement
-// || pdef instanceof IASTPreprocessorIfndefStatement
-// || pdef instanceof IASTPreprocessorIfStatement
-// || pdef instanceof IASTPreprocessorElifStatement
-//// || pdef instanceof IASTPreprocessorElseStatement
-// || pdef instanceof IASTPreprocessorUndefStatement) {
-// IPath path= new Path(tu.getContainingFilename());
-// if (!store.getMatchesForPath(path).isEmpty()) {
-// IASTFileLocation floc= pdef.getNodeLocations()[0].asFileLocation();
-// int offset= floc.getNodeOffset();
-// int end= offset+ floc.getNodeLength();
-// Collection matches= store.findMatchesInRange(
-// new Path(floc.getFileName()), offset, end);
-// for (Iterator iter = matches.iterator(); iter.hasNext();) {
-// CRefactoringMatch match = (CRefactoringMatch) iter.next();
-// match.setASTInformation(CRefactoringMatch.AST_REFERENCE);
-// }
-// }
-// }
-// }
-// }
-
- private void findConflictingBindingsWithNewName(IASTTranslationUnit tu, CRefactoringMatchStore store,
- final Set<IPath> paths, final RefactoringStatus status) {
- ASTNameVisitor nv = new ASTSpecificNameVisitor(fRenameTo) {
- @Override
+ IPath path = analyzeAstMatch(name, store, isDestructor, status);
+ paths.add(path);
+ return ASTVisitor.PROCESS_CONTINUE;
+ }
+ };
+ tu.accept(nv);
+ }
+
+ private void analyzeMacroMatches(IASTTranslationUnit tu, final CRefactoringMatchStore store,
+ final Set<IPath> pathsVisited, final RefactoringStatus status) {
+ String lookfor = fArgument.getName();
+ IASTPreprocessorMacroDefinition[] mdefs = tu.getMacroDefinitions();
+ for (IASTPreprocessorMacroDefinition mdef : mdefs) {
+ IASTName macroName = mdef.getName();
+ String macroNameStr = macroName.toString();
+ if (fRenameTo.equals(macroNameStr)) {
+ status.addFatalError(NLS.bind(RenameMessages.ASTManager_error_macro_name_conflict, fRenameTo));
+ return;
+ } else if (lookfor.equals(macroNameStr)) {
+ IPath path = analyzeAstMatch(macroName, store, false, status);
+ pathsVisited.add(path);
+ IBinding macroBinding = macroName.resolveBinding();
+ if (macroBinding != null) {
+ IASTName[] refs = tu.getReferences(macroBinding);
+ for (IASTName ref : refs) {
+ path = analyzeAstMatch(ref, store, false, status);
+ pathsVisited.add(path);
+ }
+ }
+ }
+ if (mdef instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
+ boolean nameIsPar = false;
+ IASTPreprocessorFunctionStyleMacroDefinition fm = (IASTPreprocessorFunctionStyleMacroDefinition) mdef;
+ IASTFunctionStyleMacroParameter[] pars = fm.getParameters();
+ if (pars != null) {
+ for (int j = 0; !nameIsPar && j < pars.length; j++) {
+ IASTFunctionStyleMacroParameter par = pars[j];
+ String name = par.getParameter();
+ if (lookfor.equals(name)) {
+ nameIsPar = true;
+ }
+ }
+ if (nameIsPar) {
+ IASTFileLocation floc = mdef.getNodeLocations()[0].asFileLocation();
+ int offset = floc.getNodeOffset();
+ int end = offset + floc.getNodeLength();
+ Collection<CRefactoringMatch> matches = store.findMatchesInRange(new Path(floc.getFileName()),
+ offset, end);
+ for (CRefactoringMatch match : matches) {
+ match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // private void markPreprocessorMatchesAsReference(
+ // IASTTranslationUnit tu, final CRefactoringMatchStore store,
+ // final Set pathsVisited, final RefactoringStatus status) {
+ // IASTPreprocessorStatement[] pdefs= tu.getAllPreprocessorStatements();
+ // for (int i = 0; i < pdefs.length; i++) {
+ // IASTPreprocessorStatement pdef = pdefs[i];
+ // if (pdef instanceof IASTPreprocessorIfdefStatement
+ // || pdef instanceof IASTPreprocessorIfndefStatement
+ // || pdef instanceof IASTPreprocessorIfStatement
+ // || pdef instanceof IASTPreprocessorElifStatement
+ //// || pdef instanceof IASTPreprocessorElseStatement
+ // || pdef instanceof IASTPreprocessorUndefStatement) {
+ // IPath path= new Path(tu.getContainingFilename());
+ // if (!store.getMatchesForPath(path).isEmpty()) {
+ // IASTFileLocation floc= pdef.getNodeLocations()[0].asFileLocation();
+ // int offset= floc.getNodeOffset();
+ // int end= offset+ floc.getNodeLength();
+ // Collection matches= store.findMatchesInRange(
+ // new Path(floc.getFileName()), offset, end);
+ // for (Iterator iter = matches.iterator(); iter.hasNext();) {
+ // CRefactoringMatch match = (CRefactoringMatch) iter.next();
+ // match.setASTInformation(CRefactoringMatch.AST_REFERENCE);
+ // }
+ // }
+ // }
+ // }
+ // }
+
+ private void findConflictingBindingsWithNewName(IASTTranslationUnit tu, CRefactoringMatchStore store,
+ final Set<IPath> paths, final RefactoringStatus status) {
+ ASTNameVisitor nv = new ASTSpecificNameVisitor(fRenameTo) {
+ @Override
protected int visitName(IASTName name, boolean isDestructor) {
- IPath path= addConflictingBindingForName(status, name);
- paths.add(path);
- return ASTVisitor.PROCESS_CONTINUE;
- }
- };
- tu.accept(nv);
- }
-
- protected IPath addConflictingBindingForName(final RefactoringStatus status, IASTName name) {
- IASTNodeLocation[] locations= name.getNodeLocations();
- IPath path= null;
- if (locations != null && locations.length == 1) {
- IASTNodeLocation loc= locations[0];
- IASTFileLocation floc= loc.asFileLocation();
- if (floc != null) {
- path= new Path(floc.getFileName());
- IBinding binding= name.resolveBinding();
- if (binding instanceof IProblemBinding) {
- handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status);
- } else if (binding != null) {
- fConflictingBinding.add(binding);
- }
- }
- }
- return path;
- }
-
- protected IPath analyzeAstMatch(IASTName name, CRefactoringMatchStore store, boolean isDestructor,
- RefactoringStatus status) {
- IPath path= null;
- CRefactoringMatch match= null;
-
- IASTFileLocation loc = getImageFileLocation(name);
- if (loc != null) {
- path= new Path(loc.getFileName());
- match= store.findMatch(path, loc.getNodeOffset() + (isDestructor ? 1 : 0));
- if (match != null) {
- analyzeAstTextMatchPair(match, name, status);
- }
- }
- return path;
- }
+ IPath path = addConflictingBindingForName(status, name);
+ paths.add(path);
+ return ASTVisitor.PROCESS_CONTINUE;
+ }
+ };
+ tu.accept(nv);
+ }
+
+ protected IPath addConflictingBindingForName(final RefactoringStatus status, IASTName name) {
+ IASTNodeLocation[] locations = name.getNodeLocations();
+ IPath path = null;
+ if (locations != null && locations.length == 1) {
+ IASTNodeLocation loc = locations[0];
+ IASTFileLocation floc = loc.asFileLocation();
+ if (floc != null) {
+ path = new Path(floc.getFileName());
+ IBinding binding = name.resolveBinding();
+ if (binding instanceof IProblemBinding) {
+ handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status);
+ } else if (binding != null) {
+ fConflictingBinding.add(binding);
+ }
+ }
+ }
+ return path;
+ }
+
+ protected IPath analyzeAstMatch(IASTName name, CRefactoringMatchStore store, boolean isDestructor,
+ RefactoringStatus status) {
+ IPath path = null;
+ CRefactoringMatch match = null;
+
+ IASTFileLocation loc = getImageFileLocation(name);
+ if (loc != null) {
+ path = new Path(loc.getFileName());
+ match = store.findMatch(path, loc.getNodeOffset() + (isDestructor ? 1 : 0));
+ if (match != null) {
+ analyzeAstTextMatchPair(match, name, status);
+ }
+ }
+ return path;
+ }
static IASTFileLocation getImageFileLocation(IASTName name) {
return name.getImageLocation();
}
- private void analyzeAstTextMatchPair(CRefactoringMatch match, IASTName name, RefactoringStatus status) {
- IBinding binding= name.resolveBinding();
- int cmp= FALSE;
- Integer cmpObj= fKnownBindings.get(binding);
- if (cmpObj != null) {
- cmp= cmpObj.intValue();
- } else if (binding instanceof IProblemBinding) {
- cmp= UNKNOWN;
- handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status);
- } else {
- // Check whether a qualifier has a problem binding.
- boolean problemInQualifier= false;
- IASTNode parent= name.getParent();
- if (parent instanceof ICPPASTQualifiedName) {
- ICPPASTNameSpecifier[] qualifier = ((ICPPASTQualifiedName) parent).getQualifier();
- for (ICPPASTNameSpecifier n : qualifier) {
+ private void analyzeAstTextMatchPair(CRefactoringMatch match, IASTName name, RefactoringStatus status) {
+ IBinding binding = name.resolveBinding();
+ int cmp = FALSE;
+ Integer cmpObj = fKnownBindings.get(binding);
+ if (cmpObj != null) {
+ cmp = cmpObj.intValue();
+ } else if (binding instanceof IProblemBinding) {
+ cmp = UNKNOWN;
+ handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status);
+ } else {
+ // Check whether a qualifier has a problem binding.
+ boolean problemInQualifier = false;
+ IASTNode parent = name.getParent();
+ if (parent instanceof ICPPASTQualifiedName) {
+ ICPPASTNameSpecifier[] qualifier = ((ICPPASTQualifiedName) parent).getQualifier();
+ for (ICPPASTNameSpecifier n : qualifier) {
if (n == name)
break;
final IBinding b = n.resolveBinding();
if (b instanceof IProblemBinding) {
handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) b, status);
- problemInQualifier= true;
+ problemInQualifier = true;
break;
}
}
- }
- if (problemInQualifier) {
- cmp= UNKNOWN;
- } else {
- final IASTTranslationUnit tu = name.getTranslationUnit();
- final IIndex index= tu != null ? tu.getIndex() : null;
- IBinding[] bindings = binding instanceof ICPPUsingDeclaration ?
- ((ICPPUsingDeclaration) binding).getDelegates() : new IBinding[] { binding };
- // When a 'using' declaration has multiple delegate bindings and only some of them
- // are being renamed, to preserve correctness of the code we would have to split
- // the 'using' declaration into two separate ones. We currently don't do that and
- // rename the 'using' declaration if at least one of its delegate bindings is being
- // renamed.
- outer: for (IBinding b : bindings) {
- for (IBinding renameBinding : fValidBindings) {
- try {
- int cmp0= isSameBinding(index, b, renameBinding);
- if (cmp0 != FALSE) {
- cmp= cmp0;
- }
- if (cmp0 == TRUE) {
- break outer;
- }
- } catch (DOMException e) {
- handleDOMException(name.getTranslationUnit(), e, status);
- cmp= UNKNOWN;
- }
- }
- }
- }
- fKnownBindings.put(binding, Integer.valueOf(cmp));
- }
- switch (cmp) {
- case TRUE:
- match.setASTInformation(CRefactoringMatch.AST_REFERENCE);
- if (fRenameTo != null) {
- IScope scope= getContainingScope(name);
- if (scope != null) {
- IBinding[] conflicting= null;
- try {
- conflicting= findInScope(scope, fRenameTo, name.getTranslationUnit(), true);
- } catch (Exception e) {
- CUIPlugin.log(e);
- }
- if (conflicting != null && conflicting.length > 0) {
- fConflictingBinding.addAll(Arrays.asList(conflicting));
- }
- }
- }
- break;
- case FALSE:
- match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER);
- break;
- }
- }
-
- public void handleDOMException(IASTTranslationUnit tu, final DOMException e, RefactoringStatus status) {
- handleProblemBinding(tu, e.getProblem(), status);
- }
-
- public void handleProblemBinding(IASTTranslationUnit tu, final IProblemBinding pb,
- RefactoringStatus status) {
- if (tu != null) {
- String fpath= tu.getFilePath();
- if (fProblemUnits.add(fpath)) {
- String msg= pb.getMessage();
- if (msg != null && msg.length() > 0) {
- msg= NLS.bind(RenameMessages.ASTManager_warning_parsingError_detailed, msg);
- } else {
- msg= RenameMessages.ASTManager_warning_parsingError;
- }
- int line= pb.getLineNumber();
- if (line >= 1) {
- msg= NLS.bind(RenameMessages.ASTManager_warning_parsingError_withFileAndLine,
- new Object[] { msg, fpath, line });
- } else {
- msg= NLS.bind(RenameMessages.ASTManager_warning_parsingError_withFile, msg, fpath);
- }
- status.addWarning(msg);
- }
- }
- }
+ }
+ if (problemInQualifier) {
+ cmp = UNKNOWN;
+ } else {
+ final IASTTranslationUnit tu = name.getTranslationUnit();
+ final IIndex index = tu != null ? tu.getIndex() : null;
+ IBinding[] bindings = binding instanceof ICPPUsingDeclaration
+ ? ((ICPPUsingDeclaration) binding).getDelegates()
+ : new IBinding[] { binding };
+ // When a 'using' declaration has multiple delegate bindings and only some of them
+ // are being renamed, to preserve correctness of the code we would have to split
+ // the 'using' declaration into two separate ones. We currently don't do that and
+ // rename the 'using' declaration if at least one of its delegate bindings is being
+ // renamed.
+ outer: for (IBinding b : bindings) {
+ for (IBinding renameBinding : fValidBindings) {
+ try {
+ int cmp0 = isSameBinding(index, b, renameBinding);
+ if (cmp0 != FALSE) {
+ cmp = cmp0;
+ }
+ if (cmp0 == TRUE) {
+ break outer;
+ }
+ } catch (DOMException e) {
+ handleDOMException(name.getTranslationUnit(), e, status);
+ cmp = UNKNOWN;
+ }
+ }
+ }
+ }
+ fKnownBindings.put(binding, Integer.valueOf(cmp));
+ }
+ switch (cmp) {
+ case TRUE:
+ match.setASTInformation(CRefactoringMatch.AST_REFERENCE);
+ if (fRenameTo != null) {
+ IScope scope = getContainingScope(name);
+ if (scope != null) {
+ IBinding[] conflicting = null;
+ try {
+ conflicting = findInScope(scope, fRenameTo, name.getTranslationUnit(), true);
+ } catch (Exception e) {
+ CUIPlugin.log(e);
+ }
+ if (conflicting != null && conflicting.length > 0) {
+ fConflictingBinding.addAll(Arrays.asList(conflicting));
+ }
+ }
+ }
+ break;
+ case FALSE:
+ match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER);
+ break;
+ }
+ }
+
+ public void handleDOMException(IASTTranslationUnit tu, final DOMException e, RefactoringStatus status) {
+ handleProblemBinding(tu, e.getProblem(), status);
+ }
+
+ public void handleProblemBinding(IASTTranslationUnit tu, final IProblemBinding pb, RefactoringStatus status) {
+ if (tu != null) {
+ String fpath = tu.getFilePath();
+ if (fProblemUnits.add(fpath)) {
+ String msg = pb.getMessage();
+ if (msg != null && msg.length() > 0) {
+ msg = NLS.bind(RenameMessages.ASTManager_warning_parsingError_detailed, msg);
+ } else {
+ msg = RenameMessages.ASTManager_warning_parsingError;
+ }
+ int line = pb.getLineNumber();
+ if (line >= 1) {
+ msg = NLS.bind(RenameMessages.ASTManager_warning_parsingError_withFileAndLine,
+ new Object[] { msg, fpath, line });
+ } else {
+ msg = NLS.bind(RenameMessages.ASTManager_warning_parsingError_withFile, msg, fpath);
+ }
+ status.addWarning(msg);
+ }
+ }
+ }
@SuppressWarnings("unchecked")
- protected void handleConflictingBindings(IASTTranslationUnit tu, RefactoringStatus status) {
- if (fConflictingBinding.isEmpty()) {
- return;
- }
-
- int argKind= fArgument.getArgumentKind();
- boolean isVarParEnumerator= false;
- boolean isLocalVarPar= false;
- boolean isFunction= false;
- boolean isContainer = false;
- boolean isMacro= false;
-
- switch (argKind) {
- case CRefactory.ARGUMENT_LOCAL_VAR:
- case CRefactory.ARGUMENT_PARAMETER:
- isLocalVarPar= true;
- isVarParEnumerator= true;
- break;
- case CRefactory.ARGUMENT_FILE_LOCAL_VAR:
- case CRefactory.ARGUMENT_GLOBAL_VAR:
- case CRefactory.ARGUMENT_FIELD:
- case CRefactory.ARGUMENT_ENUMERATOR:
- isVarParEnumerator= true;
- break;
- case CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION:
- case CRefactory.ARGUMENT_GLOBAL_FUNCTION:
- case CRefactory.ARGUMENT_VIRTUAL_METHOD:
- case CRefactory.ARGUMENT_NON_VIRTUAL_METHOD:
- isFunction= true;
- break;
- case CRefactory.ARGUMENT_TYPE:
- case CRefactory.ARGUMENT_CLASS_TYPE:
- case CRefactory.ARGUMENT_NAMESPACE:
- isContainer = true;
- break;
- case CRefactory.ARGUMENT_MACRO:
- isMacro= true;
- break;
- case CRefactory.ARGUMENT_INCLUDE_DIRECTIVE:
- break;
- }
-
- Collection<IBinding>[] cflc=
- new Collection[] { new HashSet<IBinding>(), new ArrayList<IBinding>(),
- new ArrayList<IBinding>() };
- String[] errs= null;
- if (isMacro) {
- errs= new String[] { RenameMessages.CRenameLocalProcessor_error_conflict };
- cflc[0]= fConflictingBinding;
- } else {
- errs= new String[] {
- RenameMessages.CRenameLocalProcessor_error_shadow,
- RenameMessages.CRenameLocalProcessor_error_redeclare,
- RenameMessages.CRenameLocalProcessor_error_isShadowed,
- RenameMessages.CRenameLocalProcessor_error_overloads };
- classifyConflictingBindings(tu, (Set<IBinding>) cflc[0], (List<IBinding>) cflc[1],
- (List<IBinding>) cflc[2], status);
- }
-
- for (int i = 0; i < 3; i++) {
- Collection<?> coll= cflc[i];
- for (Object name : coll) {
- boolean warn= false;
- String msg= errs[i];
- IBinding conflict = (IBinding) name;
- String what= null;
- if (conflict instanceof IEnumerator) {
- if (isVarParEnumerator || isFunction || isMacro) {
- what= RenameMessages.CRenameLocalProcessor_enumerator;
- }
- } else if (conflict instanceof ICPPField) {
- if (isVarParEnumerator || isFunction || isMacro) {
- what= RenameMessages.CRenameLocalProcessor_field;
- }
- } else if (conflict instanceof IParameter) {
- if (isVarParEnumerator || isFunction || isMacro) {
- if (i == 1 && argKind == CRefactory.ARGUMENT_LOCAL_VAR) {
- msg= errs[0];
- }
- what= RenameMessages.CRenameLocalProcessor_parameter;
- }
- } else if (conflict instanceof IVariable) {
- if (isVarParEnumerator || isFunction || isMacro) {
- IVariable conflictingVar= (IVariable) conflict;
- what= RenameMessages.CRenameLocalProcessor_globalVariable;
- if (ASTManager.isLocalVariable(conflictingVar)) {
- if (i == 1 && argKind == CRefactory.ARGUMENT_PARAMETER) {
- msg= errs[2];
- }
- what= RenameMessages.CRenameLocalProcessor_localVariable;
- } else {
- if (conflictingVar.isStatic()) {
- what= RenameMessages.CRenameProcessorDelegate_fileStaticVariable;
+ protected void handleConflictingBindings(IASTTranslationUnit tu, RefactoringStatus status) {
+ if (fConflictingBinding.isEmpty()) {
+ return;
+ }
+
+ int argKind = fArgument.getArgumentKind();
+ boolean isVarParEnumerator = false;
+ boolean isLocalVarPar = false;
+ boolean isFunction = false;
+ boolean isContainer = false;
+ boolean isMacro = false;
+
+ switch (argKind) {
+ case CRefactory.ARGUMENT_LOCAL_VAR:
+ case CRefactory.ARGUMENT_PARAMETER:
+ isLocalVarPar = true;
+ isVarParEnumerator = true;
+ break;
+ case CRefactory.ARGUMENT_FILE_LOCAL_VAR:
+ case CRefactory.ARGUMENT_GLOBAL_VAR:
+ case CRefactory.ARGUMENT_FIELD:
+ case CRefactory.ARGUMENT_ENUMERATOR:
+ isVarParEnumerator = true;
+ break;
+ case CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION:
+ case CRefactory.ARGUMENT_GLOBAL_FUNCTION:
+ case CRefactory.ARGUMENT_VIRTUAL_METHOD:
+ case CRefactory.ARGUMENT_NON_VIRTUAL_METHOD:
+ isFunction = true;
+ break;
+ case CRefactory.ARGUMENT_TYPE:
+ case CRefactory.ARGUMENT_CLASS_TYPE:
+ case CRefactory.ARGUMENT_NAMESPACE:
+ isContainer = true;
+ break;
+ case CRefactory.ARGUMENT_MACRO:
+ isMacro = true;
+ break;
+ case CRefactory.ARGUMENT_INCLUDE_DIRECTIVE:
+ break;
+ }
+
+ Collection<IBinding>[] cflc = new Collection[] { new HashSet<IBinding>(), new ArrayList<IBinding>(),
+ new ArrayList<IBinding>() };
+ String[] errs = null;
+ if (isMacro) {
+ errs = new String[] { RenameMessages.CRenameLocalProcessor_error_conflict };
+ cflc[0] = fConflictingBinding;
+ } else {
+ errs = new String[] { RenameMessages.CRenameLocalProcessor_error_shadow,
+ RenameMessages.CRenameLocalProcessor_error_redeclare,
+ RenameMessages.CRenameLocalProcessor_error_isShadowed,
+ RenameMessages.CRenameLocalProcessor_error_overloads };
+ classifyConflictingBindings(tu, (Set<IBinding>) cflc[0], (List<IBinding>) cflc[1], (List<IBinding>) cflc[2],
+ status);
+ }
+
+ for (int i = 0; i < 3; i++) {
+ Collection<?> coll = cflc[i];
+ for (Object name : coll) {
+ boolean warn = false;
+ String msg = errs[i];
+ IBinding conflict = (IBinding) name;
+ String what = null;
+ if (conflict instanceof IEnumerator) {
+ if (isVarParEnumerator || isFunction || isMacro) {
+ what = RenameMessages.CRenameLocalProcessor_enumerator;
+ }
+ } else if (conflict instanceof ICPPField) {
+ if (isVarParEnumerator || isFunction || isMacro) {
+ what = RenameMessages.CRenameLocalProcessor_field;
+ }
+ } else if (conflict instanceof IParameter) {
+ if (isVarParEnumerator || isFunction || isMacro) {
+ if (i == 1 && argKind == CRefactory.ARGUMENT_LOCAL_VAR) {
+ msg = errs[0];
+ }
+ what = RenameMessages.CRenameLocalProcessor_parameter;
+ }
+ } else if (conflict instanceof IVariable) {
+ if (isVarParEnumerator || isFunction || isMacro) {
+ IVariable conflictingVar = (IVariable) conflict;
+ what = RenameMessages.CRenameLocalProcessor_globalVariable;
+ if (ASTManager.isLocalVariable(conflictingVar)) {
+ if (i == 1 && argKind == CRefactory.ARGUMENT_PARAMETER) {
+ msg = errs[2];
+ }
+ what = RenameMessages.CRenameLocalProcessor_localVariable;
+ } else {
+ if (conflictingVar.isStatic()) {
+ what = RenameMessages.CRenameProcessorDelegate_fileStaticVariable;
+ }
+ }
+ }
+ } else if (conflict instanceof ICPPConstructor) {
+ if (isVarParEnumerator || isFunction || isMacro) {
+ what = RenameMessages.CRenameLocalProcessor_constructor;
+ }
+ } else if (conflict instanceof ICPPMethod) {
+ if (isVarParEnumerator || isFunction || isMacro) {
+ if (i == 1) {
+ IBinding r = fArgument.getBinding();
+ if (r instanceof ICPPMethod) {
+ try {
+ if (ASTManager.hasSameSignature((ICPPMethod) r,
+ (ICPPMethod) conflict) == ASTManager.FALSE) {
+ msg = errs[3];
+ warn = true;
+ }
+ } catch (DOMException e) {
+ }
}
- }
- }
- } else if (conflict instanceof ICPPConstructor) {
- if (isVarParEnumerator || isFunction || isMacro) {
- what= RenameMessages.CRenameLocalProcessor_constructor;
- }
- } else if (conflict instanceof ICPPMethod) {
- if (isVarParEnumerator || isFunction || isMacro) {
- if (i == 1) {
- IBinding r= fArgument.getBinding();
- if (r instanceof ICPPMethod) {
- try {
- if (ASTManager.hasSameSignature((ICPPMethod) r,
- (ICPPMethod) conflict) == ASTManager.FALSE) {
- msg= errs[3];
- warn= true;
- }
- } catch (DOMException e) {
- }
- }
- }
- what= RenameMessages.CRenameLocalProcessor_method;
- }
- } else if (conflict instanceof IFunction) {
- if (isVarParEnumerator || isFunction || isMacro) {
- boolean ignore= false;
- if (isLocalVarPar) {
- IASTName[] refs=
- fArgument.getTranslationUnit().getReferences(conflict);
- if (refs == null || refs.length == 0) {
- ignore= true;
- }
- }
- if (!ignore) {
- IFunction conflictingFunction= (IFunction) conflict;
- if (i == 1 && conflict instanceof ICPPFunction) {
- IBinding r= fArgument.getBinding();
- if (r instanceof ICPPFunction) {
- try {
- if (ASTManager.hasSameSignature((ICPPFunction) r,
- conflictingFunction) == ASTManager.FALSE) {
- msg= errs[3];
- warn= true;
- }
- } catch (DOMException e) {
- }
- }
- }
-
- boolean isStatic= conflictingFunction.isStatic();
- if (isStatic) {
- what= RenameMessages.CRenameProcessorDelegate_fileStaticFunction;
- } else {
- what= RenameMessages.CRenameProcessorDelegate_globalFunction;
- }
- }
- }
- } else if (conflict instanceof ICompositeType ||
- conflict instanceof IEnumeration ||
- conflict instanceof ITypedef) {
- if (isContainer || isMacro) {
- what= RenameMessages.CRenameProcessorDelegate_type;
- }
- } else if (conflict instanceof ICPPNamespace) {
- if (isContainer || isMacro) {
- what= RenameMessages.CRenameProcessorDelegate_namespace;
- if (argKind == CRefactory.ARGUMENT_NAMESPACE) {
- warn= true;
- }
- }
- }
- if (what != null) {
- String message = RenameMessages.CRenameLocalProcessor_error_message;
- String message1 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message1, msg);
- String message2 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message2, conflict.getName());
- String message3 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message3, what);
- String space = " \n"; //$NON-NLS-1$
- String formatted = message + space + message1 + space + message2 + space + message3;
- RefactoringStatusEntry[] entries= status.getEntries();
- for (RefactoringStatusEntry entry : entries) {
- if (formatted.equals(entry.getMessage())) {
- formatted= null;
- break;
- }
- }
- if (formatted != null) {
- if (warn) {
- status.addWarning(formatted);
- } else {
- status.addError(formatted);
- }
- }
- }
- }
- }
- }
-
- protected void classifyConflictingBindings(IASTTranslationUnit tu, Set<IBinding> shadows,
- Collection<IBinding> redecl, Collection<IBinding> barriers, RefactoringStatus status) {
- // Collect bindings on higher or equal level.
- String name= fArgument.getName();
- IBinding[] newBindingsAboverOrEqual= null;
- IScope oldBindingsScope= null;
- for (Map.Entry<IBinding, Integer> entry : fKnownBindings.entrySet()) {
- IBinding oldBinding= entry.getKey();
- Integer value= entry.getValue();
- if (value.intValue() == TRUE && oldBinding.getName().equals(name)) {
- try {
- oldBindingsScope = oldBinding.getScope();
- if (oldBindingsScope != null) {
- newBindingsAboverOrEqual = ASTManager.findInScope(oldBindingsScope, fRenameTo, null, false);
- }
- } catch (DOMException e) {
- handleDOMException(tu, e, status);
- }
- }
-
- if (newBindingsAboverOrEqual != null && newBindingsAboverOrEqual.length > 0) {
- break;
- }
- }
- if (newBindingsAboverOrEqual == null) {
- newBindingsAboverOrEqual= IBinding.EMPTY_BINDING_ARRAY;
- }
-
- // Check conflicting bindings for being from above or equal level.
- for (IBinding conflictingBinding : fConflictingBinding) {
- if (conflictingBinding != null) {
- boolean isAboveOrEqual= false;
- for (int i = 0; !isAboveOrEqual && i < newBindingsAboverOrEqual.length; i++) {
- IBinding aboveBinding = newBindingsAboverOrEqual[i];
- try {
- if (isSameBinding(tu.getIndex(), aboveBinding, conflictingBinding) == TRUE) {
- isAboveOrEqual= true;
- }
- } catch (DOMException e) {
- handleDOMException(tu, e, status);
- }
- }
- if (!isAboveOrEqual) {
- barriers.add(conflictingBinding);
- }
- }
- }
-
- // Find bindings on same level.
- for (IBinding aboveBinding : newBindingsAboverOrEqual) {
- IScope aboveScope;
- try {
- aboveScope = aboveBinding.getScope();
- if (isSameScope(aboveScope, oldBindingsScope, false) == TRUE) {
- redecl.add(aboveBinding);
- } else {
- shadows.add(aboveBinding);
- }
- } catch (DOMException e) {
- handleDOMException(tu, e, status);
- }
- }
- }
-
- public void setValidBindings(IBinding[] validBindings) {
- fValidBindings= validBindings;
- }
-
- public void setRenameTo(String renameTo) {
- fRenameTo= renameTo;
- }
+ }
+ what = RenameMessages.CRenameLocalProcessor_method;
+ }
+ } else if (conflict instanceof IFunction) {
+ if (isVarParEnumerator || isFunction || isMacro) {
+ boolean ignore = false;
+ if (isLocalVarPar) {
+ IASTName[] refs = fArgument.getTranslationUnit().getReferences(conflict);
+ if (refs == null || refs.length == 0) {
+ ignore = true;
+ }
+ }
+ if (!ignore) {
+ IFunction conflictingFunction = (IFunction) conflict;
+ if (i == 1 && conflict instanceof ICPPFunction) {
+ IBinding r = fArgument.getBinding();
+ if (r instanceof ICPPFunction) {
+ try {
+ if (ASTManager.hasSameSignature((ICPPFunction) r,
+ conflictingFunction) == ASTManager.FALSE) {
+ msg = errs[3];
+ warn = true;
+ }
+ } catch (DOMException e) {
+ }
+ }
+ }
+
+ boolean isStatic = conflictingFunction.isStatic();
+ if (isStatic) {
+ what = RenameMessages.CRenameProcessorDelegate_fileStaticFunction;
+ } else {
+ what = RenameMessages.CRenameProcessorDelegate_globalFunction;
+ }
+ }
+ }
+ } else if (conflict instanceof ICompositeType || conflict instanceof IEnumeration
+ || conflict instanceof ITypedef) {
+ if (isContainer || isMacro) {
+ what = RenameMessages.CRenameProcessorDelegate_type;
+ }
+ } else if (conflict instanceof ICPPNamespace) {
+ if (isContainer || isMacro) {
+ what = RenameMessages.CRenameProcessorDelegate_namespace;
+ if (argKind == CRefactory.ARGUMENT_NAMESPACE) {
+ warn = true;
+ }
+ }
+ }
+ if (what != null) {
+ String message = RenameMessages.CRenameLocalProcessor_error_message;
+ String message1 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message1, msg);
+ String message2 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message2, conflict.getName());
+ String message3 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message3, what);
+ String space = " \n"; //$NON-NLS-1$
+ String formatted = message + space + message1 + space + message2 + space + message3;
+ RefactoringStatusEntry[] entries = status.getEntries();
+ for (RefactoringStatusEntry entry : entries) {
+ if (formatted.equals(entry.getMessage())) {
+ formatted = null;
+ break;
+ }
+ }
+ if (formatted != null) {
+ if (warn) {
+ status.addWarning(formatted);
+ } else {
+ status.addError(formatted);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void classifyConflictingBindings(IASTTranslationUnit tu, Set<IBinding> shadows,
+ Collection<IBinding> redecl, Collection<IBinding> barriers, RefactoringStatus status) {
+ // Collect bindings on higher or equal level.
+ String name = fArgument.getName();
+ IBinding[] newBindingsAboverOrEqual = null;
+ IScope oldBindingsScope = null;
+ for (Map.Entry<IBinding, Integer> entry : fKnownBindings.entrySet()) {
+ IBinding oldBinding = entry.getKey();
+ Integer value = entry.getValue();
+ if (value.intValue() == TRUE && oldBinding.getName().equals(name)) {
+ try {
+ oldBindingsScope = oldBinding.getScope();
+ if (oldBindingsScope != null) {
+ newBindingsAboverOrEqual = ASTManager.findInScope(oldBindingsScope, fRenameTo, null, false);
+ }
+ } catch (DOMException e) {
+ handleDOMException(tu, e, status);
+ }
+ }
+
+ if (newBindingsAboverOrEqual != null && newBindingsAboverOrEqual.length > 0) {
+ break;
+ }
+ }
+ if (newBindingsAboverOrEqual == null) {
+ newBindingsAboverOrEqual = IBinding.EMPTY_BINDING_ARRAY;
+ }
+
+ // Check conflicting bindings for being from above or equal level.
+ for (IBinding conflictingBinding : fConflictingBinding) {
+ if (conflictingBinding != null) {
+ boolean isAboveOrEqual = false;
+ for (int i = 0; !isAboveOrEqual && i < newBindingsAboverOrEqual.length; i++) {
+ IBinding aboveBinding = newBindingsAboverOrEqual[i];
+ try {
+ if (isSameBinding(tu.getIndex(), aboveBinding, conflictingBinding) == TRUE) {
+ isAboveOrEqual = true;
+ }
+ } catch (DOMException e) {
+ handleDOMException(tu, e, status);
+ }
+ }
+ if (!isAboveOrEqual) {
+ barriers.add(conflictingBinding);
+ }
+ }
+ }
+
+ // Find bindings on same level.
+ for (IBinding aboveBinding : newBindingsAboverOrEqual) {
+ IScope aboveScope;
+ try {
+ aboveScope = aboveBinding.getScope();
+ if (isSameScope(aboveScope, oldBindingsScope, false) == TRUE) {
+ redecl.add(aboveBinding);
+ } else {
+ shadows.add(aboveBinding);
+ }
+ } catch (DOMException e) {
+ handleDOMException(tu, e, status);
+ }
+ }
+ }
+
+ public void setValidBindings(IBinding[] validBindings) {
+ fValidBindings = validBindings;
+ }
+
+ public void setRenameTo(String renameTo) {
+ fRenameTo = renameTo;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.java
index 3c81eb066f1..28cb2488069 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.java
@@ -1,16 +1,16 @@
/*******************************************************************************
* Copyright (c) 2005, 2014 Wind River Systems, Inc.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
- ******************************************************************************/
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@@ -23,76 +23,76 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
/**
* Visitor to prefer simple ASTNames over the qualified ones. This is different
- * to the strategy used within the dom-package.
+ * to the strategy used within the dom-package.
*/
public abstract class ASTNameVisitor extends ASTVisitor {
- private final int fOffset;
- private final String fFileName;
+ private final int fOffset;
+ private final String fFileName;
+
+ public ASTNameVisitor(String fileName) {
+ this(fileName, -1);
+ }
+
+ public ASTNameVisitor(String fileName, int offset) {
+ fFileName = fileName;
+ fOffset = offset;
+ shouldVisitNames = true;
+ }
- public ASTNameVisitor(String fileName) {
- this(fileName, -1);
- }
-
- public ASTNameVisitor(String fileName, int offset) {
- fFileName= fileName;
- fOffset= offset;
- shouldVisitNames = true;
- }
-
- abstract protected int visitName(IASTName name);
-
- @Override
+ abstract protected int visitName(IASTName name);
+
+ @Override
public final int visit(IASTName name) {
- if (name instanceof ICPPASTQualifiedName) {
- ICPPASTQualifiedName qn= (ICPPASTQualifiedName) name;
- ICPPASTNameSpecifier[] segments= qn.getQualifier();
- boolean visited= false;
- for (int i = 0; i <= segments.length; i++) {
- IASTNode segment = i < segments.length ? segments[i] : qn.getLastName();
+ if (name instanceof ICPPASTQualifiedName) {
+ ICPPASTQualifiedName qn = (ICPPASTQualifiedName) name;
+ ICPPASTNameSpecifier[] segments = qn.getQualifier();
+ boolean visited = false;
+ for (int i = 0; i <= segments.length; i++) {
+ IASTNode segment = i < segments.length ? segments[i] : qn.getLastName();
if (segment instanceof IASTName && checkLocation(segment)) {
- if (visitName((IASTName) segment) == PROCESS_ABORT) {
- return PROCESS_ABORT;
- }
- visited= true;
- }
- }
- if (!visited) {
- if (checkLocation(name)) {
- return visitName(name.getLastName());
- }
- }
- } else if (checkLocation(name)) {
- return visitName(name);
- }
- return PROCESS_CONTINUE;
- }
-
- private boolean checkLocation(IASTNode node) {
- if (fFileName == null) {
- return true;
- }
- if (!fFileName.equals(node.getContainingFilename())) {
- return false;
- }
- IASTFileLocation loc= null;
- if (node instanceof IASTName) {
- loc= ASTManager.getImageFileLocation((IASTName) node);
- } else {
- IASTNodeLocation[] locs= node.getNodeLocations();
- if (locs != null && locs.length == 1) {
- if (locs[0] instanceof IASTFileLocation) {
- loc= (IASTFileLocation) locs[0];
- }
- }
- }
- if (loc == null) {
- return false;
- }
- if (fOffset == -1) {
- return true;
- }
- int off= loc.getNodeOffset();
- int len = loc.getNodeLength();
- return off <= fOffset && fOffset < off + len;
- }
+ if (visitName((IASTName) segment) == PROCESS_ABORT) {
+ return PROCESS_ABORT;
+ }
+ visited = true;
+ }
+ }
+ if (!visited) {
+ if (checkLocation(name)) {
+ return visitName(name.getLastName());
+ }
+ }
+ } else if (checkLocation(name)) {
+ return visitName(name);
+ }
+ return PROCESS_CONTINUE;
+ }
+
+ private boolean checkLocation(IASTNode node) {
+ if (fFileName == null) {
+ return true;
+ }
+ if (!fFileName.equals(node.getContainingFilename())) {
+ return false;
+ }
+ IASTFileLocation loc = null;
+ if (node instanceof IASTName) {
+ loc = ASTManager.getImageFileLocation((IASTName) node);
+ } else {
+ IASTNodeLocation[] locs = node.getNodeLocations();
+ if (locs != null && locs.length == 1) {
+ if (locs[0] instanceof IASTFileLocation) {
+ loc = (IASTFileLocation) locs[0];
+ }
+ }
+ }
+ if (loc == null) {
+ return false;
+ }
+ if (fOffset == -1) {
+ return true;
+ }
+ int off = loc.getNodeOffset();
+ int len = loc.getNodeLength();
+ return off <= fOffset && fOffset < off + len;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVisitor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVisitor.java
index a6ca5b435c6..62d3074b504 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVisitor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVisitor.java
@@ -1,16 +1,16 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 Wind River Systems, Inc.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
- ******************************************************************************/
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@@ -19,34 +19,34 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
public abstract class ASTSpecificNameVisitor extends ASTNameVisitor {
- private final String fSearchForName;
+ private final String fSearchForName;
+
+ public ASTSpecificNameVisitor(String name) {
+ super(null);
+ fSearchForName = name;
+ }
- public ASTSpecificNameVisitor(String name) {
- super(null);
- fSearchForName= name;
- }
-
- @Override
+ @Override
public final int visitName(IASTName name) {
- if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
- return PROCESS_CONTINUE;
-
- String nameStr= name.toString();
- if (nameStr != null) {
- final int len= nameStr.length();
- final int searchForLen= fSearchForName.length();
- if (len == searchForLen) {
- if (nameStr.equals(fSearchForName)) {
- return visitName(name, false);
- }
- } else if (len == searchForLen + 1) {
- if (nameStr.charAt(0) == '~' && nameStr.endsWith(fSearchForName)) {
- return visitName(name, true);
- }
- }
- }
- return ASTVisitor.PROCESS_CONTINUE;
- }
+ if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
+ return PROCESS_CONTINUE;
+
+ String nameStr = name.toString();
+ if (nameStr != null) {
+ final int len = nameStr.length();
+ final int searchForLen = fSearchForName.length();
+ if (len == searchForLen) {
+ if (nameStr.equals(fSearchForName)) {
+ return visitName(name, false);
+ }
+ } else if (len == searchForLen + 1) {
+ if (nameStr.charAt(0) == '~' && nameStr.endsWith(fSearchForName)) {
+ return visitName(name, true);
+ }
+ }
+ }
+ return ASTVisitor.PROCESS_CONTINUE;
+ }
- protected abstract int visitName(IASTName name, boolean isDestructor);
+ protected abstract int visitName(IASTName name, boolean isDestructor);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java
index 24c24e0c28c..bccd37055fc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2004, 2015 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.core.resources.IFile;
@@ -44,129 +44,129 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
* can be calculated from the AST.
*/
public class CRefactoringArgument {
- private int fOffset;
- private int fLength;
- private String fText= ""; //$NON-NLS-1$
- private int fKind= CRefactory.ARGUMENT_UNKNOWN;
- private IFile fFile;
-
- private IBinding fBinding;
- private IScope fScope;
- private IASTTranslationUnit fTranslationUnit;
-
- public CRefactoringArgument(IFile file, int offset, int length) {
- fKind= CRefactory.ARGUMENT_UNKNOWN;
- fFile= file;
- fOffset= offset;
- fLength= length;
- }
-
- public CRefactoringArgument(ICElement elem) {
- fKind= CRefactory.ARGUMENT_UNKNOWN;
- if (elem instanceof ISourceReference) {
- ISourceReference sref= (ISourceReference) elem;
- ISourceRange sr;
+ private int fOffset;
+ private int fLength;
+ private String fText = ""; //$NON-NLS-1$
+ private int fKind = CRefactory.ARGUMENT_UNKNOWN;
+ private IFile fFile;
+
+ private IBinding fBinding;
+ private IScope fScope;
+ private IASTTranslationUnit fTranslationUnit;
+
+ public CRefactoringArgument(IFile file, int offset, int length) {
+ fKind = CRefactory.ARGUMENT_UNKNOWN;
+ fFile = file;
+ fOffset = offset;
+ fLength = length;
+ }
+
+ public CRefactoringArgument(ICElement elem) {
+ fKind = CRefactory.ARGUMENT_UNKNOWN;
+ if (elem instanceof ISourceReference) {
+ ISourceReference sref = (ISourceReference) elem;
+ ISourceRange sr;
try {
sr = sref.getSourceRange();
- fFile= (IFile) sref.getTranslationUnit().getResource();
- fOffset= sr.getIdStartPos();
- fLength= sr.getIdLength();
+ fFile = (IFile) sref.getTranslationUnit().getResource();
+ fOffset = sr.getIdStartPos();
+ fLength = sr.getIdLength();
} catch (CModelException e) {
CUIPlugin.log(e);
}
- }
- }
-
- public String getName() {
- return fText;
- }
-
- public IFile getSourceFile() {
- return fFile;
- }
-
- public int getArgumentKind() {
- return fKind;
- }
-
- public int getOffset() {
- return fOffset;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public void setName(String name) {
- fText= name.toString();
- }
-
- public void setName(IASTName name) {
- setName(name.toString());
- }
-
- public void setBinding(IASTTranslationUnit tu, IBinding binding, IScope scope) {
- fTranslationUnit= tu;
- fBinding= binding;
- fScope= scope;
- if (binding instanceof IVariable) {
- IVariable var= (IVariable) binding;
- if (binding instanceof IField) {
- fKind= CRefactory.ARGUMENT_FIELD;
- } else if (binding instanceof IParameter) {
- fKind= CRefactory.ARGUMENT_PARAMETER;
- } else {
- if (ASTManager.isLocalVariable(var, scope)) {
- fKind= CRefactory.ARGUMENT_LOCAL_VAR;
- } else {
- boolean isStatic= false;
- isStatic= var.isStatic();
- if (isStatic) {
- fKind= CRefactory.ARGUMENT_FILE_LOCAL_VAR;
- } else {
- fKind= CRefactory.ARGUMENT_GLOBAL_VAR;
- }
- }
- }
- } else if (binding instanceof IEnumerator) {
- fKind= CRefactory.ARGUMENT_ENUMERATOR;
- } else if (binding instanceof IFunction) {
- fKind= CRefactory.ARGUMENT_NON_VIRTUAL_METHOD;
- IFunction func= (IFunction) binding;
- if (binding instanceof ICPPMethod) {
- ICPPMethod method= (ICPPMethod) binding;
- if (ClassTypeHelper.isVirtual(method)) {
- fKind= CRefactory.ARGUMENT_VIRTUAL_METHOD;
- }
- } else {
- boolean isStatic= false;
- isStatic= func.isStatic();
- if (isStatic) {
- fKind= CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION;
- } else {
- fKind= CRefactory.ARGUMENT_GLOBAL_FUNCTION;
- }
- }
- } else if (binding instanceof ICompositeType) {
- fKind= CRefactory.ARGUMENT_CLASS_TYPE;
- } else if (binding instanceof IEnumeration || binding instanceof ITypedef) {
- fKind= CRefactory.ARGUMENT_TYPE;
- } else if (binding instanceof ICPPNamespace) {
- fKind= CRefactory.ARGUMENT_NAMESPACE;
- } else if (binding instanceof IMacroBinding) {
- fKind= CRefactory.ARGUMENT_MACRO;
- }
- }
-
- public IScope getScope() {
- return fScope;
- }
-
- public IBinding getBinding() {
- return fBinding;
- }
-
- public IASTTranslationUnit getTranslationUnit() {
- return fTranslationUnit;
- }
+ }
+ }
+
+ public String getName() {
+ return fText;
+ }
+
+ public IFile getSourceFile() {
+ return fFile;
+ }
+
+ public int getArgumentKind() {
+ return fKind;
+ }
+
+ public int getOffset() {
+ return fOffset;
+ }
+
+ public int getLength() {
+ return fLength;
+ }
+
+ public void setName(String name) {
+ fText = name.toString();
+ }
+
+ public void setName(IASTName name) {
+ setName(name.toString());
+ }
+
+ public void setBinding(IASTTranslationUnit tu, IBinding binding, IScope scope) {
+ fTranslationUnit = tu;
+ fBinding = binding;
+ fScope = scope;
+ if (binding instanceof IVariable) {
+ IVariable var = (IVariable) binding;
+ if (binding instanceof IField) {
+ fKind = CRefactory.ARGUMENT_FIELD;
+ } else if (binding instanceof IParameter) {
+ fKind = CRefactory.ARGUMENT_PARAMETER;
+ } else {
+ if (ASTManager.isLocalVariable(var, scope)) {
+ fKind = CRefactory.ARGUMENT_LOCAL_VAR;
+ } else {
+ boolean isStatic = false;
+ isStatic = var.isStatic();
+ if (isStatic) {
+ fKind = CRefactory.ARGUMENT_FILE_LOCAL_VAR;
+ } else {
+ fKind = CRefactory.ARGUMENT_GLOBAL_VAR;
+ }
+ }
+ }
+ } else if (binding instanceof IEnumerator) {
+ fKind = CRefactory.ARGUMENT_ENUMERATOR;
+ } else if (binding instanceof IFunction) {
+ fKind = CRefactory.ARGUMENT_NON_VIRTUAL_METHOD;
+ IFunction func = (IFunction) binding;
+ if (binding instanceof ICPPMethod) {
+ ICPPMethod method = (ICPPMethod) binding;
+ if (ClassTypeHelper.isVirtual(method)) {
+ fKind = CRefactory.ARGUMENT_VIRTUAL_METHOD;
+ }
+ } else {
+ boolean isStatic = false;
+ isStatic = func.isStatic();
+ if (isStatic) {
+ fKind = CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION;
+ } else {
+ fKind = CRefactory.ARGUMENT_GLOBAL_FUNCTION;
+ }
+ }
+ } else if (binding instanceof ICompositeType) {
+ fKind = CRefactory.ARGUMENT_CLASS_TYPE;
+ } else if (binding instanceof IEnumeration || binding instanceof ITypedef) {
+ fKind = CRefactory.ARGUMENT_TYPE;
+ } else if (binding instanceof ICPPNamespace) {
+ fKind = CRefactory.ARGUMENT_NAMESPACE;
+ } else if (binding instanceof IMacroBinding) {
+ fKind = CRefactory.ARGUMENT_MACRO;
+ }
+ }
+
+ public IScope getScope() {
+ return fScope;
+ }
+
+ public IBinding getBinding() {
+ return fBinding;
+ }
+
+ public IASTTranslationUnit getTranslationUnit() {
+ return fTranslationUnit;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java
index b7ef77513d0..922340dab86 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java
@@ -1,16 +1,16 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
- ******************************************************************************/
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.core.resources.IFile;
@@ -21,82 +21,80 @@ import org.eclipse.core.resources.IFile;
* whether it has been verified via AST or not.
*/
public class CRefactoringMatch {
- public static final int POTENTIAL= 0;
- public static final int AST_REFERENCE= 1;
- public static final int AST_REFERENCE_OTHER= 2;
- public static final int AST_REFEREENCE_CONFLICTING= 3;
- public static final int IN_COMMENT = 4;
+ public static final int POTENTIAL = 0;
+ public static final int AST_REFERENCE = 1;
+ public static final int AST_REFERENCE_OTHER = 2;
+ public static final int AST_REFEREENCE_CONFLICTING = 3;
+ public static final int IN_COMMENT = 4;
- private static String[] LABELS= {
- RenameMessages.CRefactoringMatch_label_potentialOccurrences,
- RenameMessages.CRefactoringMatch_label_occurrences,
- "", //$NON-NLS-1$
- RenameMessages.CRefactoringMatch_label_potentialOccurrences,
- RenameMessages.CRefactoringMatch_label_inComment };
+ private static String[] LABELS = { RenameMessages.CRefactoringMatch_label_potentialOccurrences,
+ RenameMessages.CRefactoringMatch_label_occurrences, "", //$NON-NLS-1$
+ RenameMessages.CRefactoringMatch_label_potentialOccurrences,
+ RenameMessages.CRefactoringMatch_label_inComment };
- private IFile fFile;
- private int fOffset;
- private int fLength;
- private int fLocation;
- private int fAstInformation;
+ private IFile fFile;
+ private int fOffset;
+ private int fLength;
+ private int fLocation;
+ private int fAstInformation;
- public int getAstInformation() {
- return fAstInformation;
- }
+ public int getAstInformation() {
+ return fAstInformation;
+ }
- public CRefactoringMatch(IFile file, int offset, int length, int location) {
- fFile= file;
- fOffset= offset;
- fLength= length;
- fLocation= location;
- }
+ public CRefactoringMatch(IFile file, int offset, int length, int location) {
+ fFile = file;
+ fOffset = offset;
+ fLength = length;
+ fLocation = location;
+ }
- public int getOffset() {
- return fOffset;
- }
+ public int getOffset() {
+ return fOffset;
+ }
- public void setLocation(int location) {
- fLocation= location;
- }
+ public void setLocation(int location) {
+ fLocation = location;
+ }
- public int getLocation() {
- return fLocation;
- }
+ public int getLocation() {
+ return fLocation;
+ }
- public int getLength() {
- return fLength;
- }
+ public int getLength() {
+ return fLength;
+ }
- public IFile getFile() {
- return fFile;
- }
+ public IFile getFile() {
+ return fFile;
+ }
- public void setASTInformation(int val) {
- switch (fAstInformation) {
- case AST_REFERENCE:
- case AST_REFERENCE_OTHER:
- case AST_REFEREENCE_CONFLICTING:
- if (val != fAstInformation) {
- fAstInformation= AST_REFEREENCE_CONFLICTING;
- }
- break;
- default:
- fAstInformation= val;
- break;
- }
- }
+ public void setASTInformation(int val) {
+ switch (fAstInformation) {
+ case AST_REFERENCE:
+ case AST_REFERENCE_OTHER:
+ case AST_REFEREENCE_CONFLICTING:
+ if (val != fAstInformation) {
+ fAstInformation = AST_REFEREENCE_CONFLICTING;
+ }
+ break;
+ default:
+ fAstInformation = val;
+ break;
+ }
+ }
- public String getLabel() {
- if (fAstInformation == AST_REFERENCE) {
- return LABELS[AST_REFERENCE];
- }
- if (isInComment()) {
- return LABELS[IN_COMMENT];
- }
- return LABELS[POTENTIAL];
- }
+ public String getLabel() {
+ if (fAstInformation == AST_REFERENCE) {
+ return LABELS[AST_REFERENCE];
+ }
+ if (isInComment()) {
+ return LABELS[IN_COMMENT];
+ }
+ return LABELS[POTENTIAL];
+ }
- public boolean isInComment() {
- return (fLocation & CRefactory.OPTION_IN_COMMENT) != 0;
- }
+ public boolean isInComment() {
+ return (fLocation & CRefactory.OPTION_IN_COMMENT) != 0;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java
index c473b25ce3f..1354b6a8f6c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java
@@ -1,16 +1,16 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
- ******************************************************************************/
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.util.ArrayList;
@@ -29,98 +29,98 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class CRefactoringMatchStore {
- private Map<IFile, IPath> fFileToPathMap= new HashMap<>();
- private Map<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>> fPathToMatches= new HashMap<>();
- private Comparator<CRefactoringMatch> fOffsetComparator;
+ private Map<IFile, IPath> fFileToPathMap = new HashMap<>();
+ private Map<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>> fPathToMatches = new HashMap<>();
+ private Comparator<CRefactoringMatch> fOffsetComparator;
- public CRefactoringMatchStore() {
- fOffsetComparator= new Comparator<CRefactoringMatch>() {
- @Override
+ public CRefactoringMatchStore() {
+ fOffsetComparator = new Comparator<CRefactoringMatch>() {
+ @Override
public int compare(CRefactoringMatch o1, CRefactoringMatch o2) {
- return o1.getOffset() - o2.getOffset();
- }
- };
- }
-
- public void addMatch(CRefactoringMatch match) {
- IPath path= resolvePath(match.getFile());
- if (path != null) {
- Map<CRefactoringMatch, CRefactoringMatch> matchesForPath= getMapForPath(path, true);
- matchesForPath.put(match, match);
- }
- }
-
- private Map<CRefactoringMatch, CRefactoringMatch> getMapForPath(IPath path, boolean create) {
- SortedMap<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
- if (map == null && create) {
- map= new TreeMap<>(fOffsetComparator);
- fPathToMatches.put(path, map);
- }
- return map;
- }
+ return o1.getOffset() - o2.getOffset();
+ }
+ };
+ }
+
+ public void addMatch(CRefactoringMatch match) {
+ IPath path = resolvePath(match.getFile());
+ if (path != null) {
+ Map<CRefactoringMatch, CRefactoringMatch> matchesForPath = getMapForPath(path, true);
+ matchesForPath.put(match, match);
+ }
+ }
+
+ private Map<CRefactoringMatch, CRefactoringMatch> getMapForPath(IPath path, boolean create) {
+ SortedMap<CRefactoringMatch, CRefactoringMatch> map = fPathToMatches.get(path);
+ if (map == null && create) {
+ map = new TreeMap<>(fOffsetComparator);
+ fPathToMatches.put(path, map);
+ }
+ return map;
+ }
- private IPath resolvePath(IFile file) {
- IPath path= fFileToPathMap.get(file);
- if (path == null) {
- path= file.getLocation();
- if (path == null) {
- path= file.getFullPath();
- }
- fFileToPathMap.put(file, path);
- }
- return path;
- }
+ private IPath resolvePath(IFile file) {
+ IPath path = fFileToPathMap.get(file);
+ if (path == null) {
+ path = file.getLocation();
+ if (path == null) {
+ path = file.getFullPath();
+ }
+ fFileToPathMap.put(file, path);
+ }
+ return path;
+ }
- public int getFileCount() {
- return fFileToPathMap.size();
- }
+ public int getFileCount() {
+ return fFileToPathMap.size();
+ }
- public List<IFile> getFileList() {
- return new ArrayList<>(fFileToPathMap.keySet());
- }
+ public List<IFile> getFileList() {
+ return new ArrayList<>(fFileToPathMap.keySet());
+ }
- public boolean contains(IResource file) {
- return fFileToPathMap.containsKey(file);
- }
+ public boolean contains(IResource file) {
+ return fFileToPathMap.containsKey(file);
+ }
- public Collection<CRefactoringMatch> getMatchesForFile(IResource file) {
- return getMatchesForPath(fFileToPathMap.get(file));
- }
+ public Collection<CRefactoringMatch> getMatchesForFile(IResource file) {
+ return getMatchesForPath(fFileToPathMap.get(file));
+ }
- public Collection<CRefactoringMatch> getMatchesForPath(IPath path) {
- if (path != null) {
- Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
- if (map != null) {
- return map.keySet();
- }
- }
- return Collections.emptySet();
- }
+ public Collection<CRefactoringMatch> getMatchesForPath(IPath path) {
+ if (path != null) {
+ Map<CRefactoringMatch, CRefactoringMatch> map = fPathToMatches.get(path);
+ if (map != null) {
+ return map.keySet();
+ }
+ }
+ return Collections.emptySet();
+ }
- public CRefactoringMatch findMatch(IPath path, int nodeOffset) {
- Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
- if (map != null) {
- return map.get(new CRefactoringMatch(null, nodeOffset, 0, 0));
- }
- return null;
- }
+ public CRefactoringMatch findMatch(IPath path, int nodeOffset) {
+ Map<CRefactoringMatch, CRefactoringMatch> map = fPathToMatches.get(path);
+ if (map != null) {
+ return map.get(new CRefactoringMatch(null, nodeOffset, 0, 0));
+ }
+ return null;
+ }
- public void removePath(IPath path) {
- Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.remove(path);
- if (map != null && !map.isEmpty()) {
- IFile file= (map.values().iterator().next()).getFile();
- fFileToPathMap.remove(file);
- }
- }
+ public void removePath(IPath path) {
+ Map<CRefactoringMatch, CRefactoringMatch> map = fPathToMatches.remove(path);
+ if (map != null && !map.isEmpty()) {
+ IFile file = (map.values().iterator().next()).getFile();
+ fFileToPathMap.remove(file);
+ }
+ }
- public Collection<CRefactoringMatch> findMatchesInRange(Path path, int offset, int end) {
- if (path != null) {
- SortedMap<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
- if (map != null) {
- return map.subMap(new CRefactoringMatch(null, offset, 0, 0),
- new CRefactoringMatch(null, end, 0, 0)).keySet();
- }
- }
- return Collections.emptySet();
- }
+ public Collection<CRefactoringMatch> findMatchesInRange(Path path, int offset, int end) {
+ if (path != null) {
+ SortedMap<CRefactoringMatch, CRefactoringMatch> map = fPathToMatches.get(path);
+ if (map != null) {
+ return map.subMap(new CRefactoringMatch(null, offset, 0, 0), new CRefactoringMatch(null, end, 0, 0))
+ .keySet();
+ }
+ }
+ return Collections.emptySet();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils.java
index 2389ce47a70..30c24bb2da1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils.java
@@ -1,16 +1,16 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
- ******************************************************************************/
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
/**
@@ -18,26 +18,26 @@ package org.eclipse.cdt.internal.ui.refactoring.rename;
*/
public class CRefactoringUtils {
- public static boolean isIdentifierChar(char c) {
- return isLeadingIdentifierChar(c) || ('0'<=c && c<='9');
- }
+ public static boolean isIdentifierChar(char c) {
+ return isLeadingIdentifierChar(c) || ('0' <= c && c <= '9');
+ }
- public static boolean isLeadingIdentifierChar(char c) {
- return ('A'<=c && c<='Z') || ('a'<=c && c<='z') || c=='_';
- }
+ public static boolean isLeadingIdentifierChar(char c) {
+ return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || c == '_';
+ }
- public static boolean checkIdentifier(String id) {
- if (id.length() == 0) {
- return false;
- }
- if (!isLeadingIdentifierChar(id.charAt(0))) {
- return false;
- }
- for (int i= 1; i < id.length(); i++) {
- if (!isIdentifierChar(id.charAt(i))) {
- return false;
- }
- }
- return true;
- }
+ public static boolean checkIdentifier(String id) {
+ if (id.length() == 0) {
+ return false;
+ }
+ if (!isLeadingIdentifierChar(id.charAt(0))) {
+ return false;
+ }
+ for (int i = 1; i < id.length(); i++) {
+ if (!isIdentifierChar(id.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java
index d8aae533eda..b4bb89e5765 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2004, 2018 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.util.Arrays;
@@ -35,72 +35,71 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
* Serves to launch the various refactorings.
*/
public class CRefactory {
- public static final int OPTION_IN_CODE_REFERENCES = 0x01;
- public static final int OPTION_IN_INACTIVE_CODE = 0x02;
- public static final int OPTION_IN_COMMENT = 0x04;
- public static final int OPTION_IN_STRING_LITERAL = 0x08;
- public static final int OPTION_IN_INCLUDE_DIRECTIVE = 0x10;
- public static final int OPTION_IN_MACRO_DEFINITION = 0x20;
- public static final int OPTION_IN_PREPROCESSOR_DIRECTIVE = 0x40;
- public static final int OPTION_DO_VIRTUAL = 0x80;
- public static final int OPTION_EXHAUSTIVE_FILE_SEARCH = 0x100;
+ public static final int OPTION_IN_CODE_REFERENCES = 0x01;
+ public static final int OPTION_IN_INACTIVE_CODE = 0x02;
+ public static final int OPTION_IN_COMMENT = 0x04;
+ public static final int OPTION_IN_STRING_LITERAL = 0x08;
+ public static final int OPTION_IN_INCLUDE_DIRECTIVE = 0x10;
+ public static final int OPTION_IN_MACRO_DEFINITION = 0x20;
+ public static final int OPTION_IN_PREPROCESSOR_DIRECTIVE = 0x40;
+ public static final int OPTION_DO_VIRTUAL = 0x80;
+ public static final int OPTION_EXHAUSTIVE_FILE_SEARCH = 0x100;
+
+ public static final int ARGUMENT_UNKNOWN = 0;
+ public static final int ARGUMENT_LOCAL_VAR = 1;
+ public static final int ARGUMENT_PARAMETER = 2;
+ public static final int ARGUMENT_FILE_LOCAL_VAR = 3;
+ public static final int ARGUMENT_GLOBAL_VAR = 4;
+ public static final int ARGUMENT_FIELD = 5;
+ public static final int ARGUMENT_FILE_LOCAL_FUNCTION = 6;
+ public static final int ARGUMENT_GLOBAL_FUNCTION = 7;
+ public static final int ARGUMENT_VIRTUAL_METHOD = 8;
+ public static final int ARGUMENT_NON_VIRTUAL_METHOD = 9;
+ public static final int ARGUMENT_TYPE = 10;
+ public static final int ARGUMENT_MACRO = 11;
+ public static final int ARGUMENT_INCLUDE_DIRECTIVE = 12;
+ public static final int ARGUMENT_ENUMERATOR = 13;
+ public static final int ARGUMENT_CLASS_TYPE = 14;
+ public static final int ARGUMENT_NAMESPACE = 15;
+
+ private static CRefactory sInstance = new CRefactory();
+ private TextSearchWrapper fTextSearch;
- public static final int ARGUMENT_UNKNOWN = 0;
- public static final int ARGUMENT_LOCAL_VAR = 1;
- public static final int ARGUMENT_PARAMETER = 2;
- public static final int ARGUMENT_FILE_LOCAL_VAR = 3;
- public static final int ARGUMENT_GLOBAL_VAR = 4;
- public static final int ARGUMENT_FIELD = 5;
- public static final int ARGUMENT_FILE_LOCAL_FUNCTION = 6;
- public static final int ARGUMENT_GLOBAL_FUNCTION = 7;
- public static final int ARGUMENT_VIRTUAL_METHOD = 8;
- public static final int ARGUMENT_NON_VIRTUAL_METHOD = 9;
- public static final int ARGUMENT_TYPE = 10;
- public static final int ARGUMENT_MACRO = 11;
- public static final int ARGUMENT_INCLUDE_DIRECTIVE = 12;
- public static final int ARGUMENT_ENUMERATOR = 13;
- public static final int ARGUMENT_CLASS_TYPE = 14;
- public static final int ARGUMENT_NAMESPACE = 15;
+ public static CRefactory getInstance() {
+ return sInstance;
+ }
+
+ private CRefactory() {
+ }
+
+ // Runs the rename refactoring.
+ public void rename(Shell shell, ICElement arg) {
+ if (!IDE.saveAllEditors(new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, false)) {
+ return;
+ }
+ CRefactoringArgument iarg = new CRefactoringArgument(arg);
+ final CRenameProcessor processor = new CRenameProcessor(this, iarg);
+ CRenameRefactoring refactoring = new CRenameRefactoring(processor);
+ RenameSupport.openDialog(shell, refactoring);
+ }
- private static CRefactory sInstance= new CRefactory();
- private TextSearchWrapper fTextSearch;
-
- public static CRefactory getInstance() {
- return sInstance;
- }
-
- private CRefactory() {
- }
-
- // Runs the rename refactoring.
- public void rename(Shell shell, ICElement arg) {
- if (!IDE.saveAllEditors(new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, false)) {
- return;
- }
- CRefactoringArgument iarg= new CRefactoringArgument(arg);
- final CRenameProcessor processor = new CRenameProcessor(this, iarg);
- CRenameRefactoring refactoring= new CRenameRefactoring(processor);
- RenameSupport.openDialog(shell, refactoring);
- }
-
public void rename(Shell shell, IWorkingCopy workingCopy, ITextSelection selection) {
- IResource res= workingCopy.getResource();
- if (!(res instanceof IFile)) {
- return;
- }
- if (!IDE.saveAllEditors(new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, false)) {
- return;
- }
- CRefactoringArgument iarg=
- new CRefactoringArgument((IFile) res, selection.getOffset(), selection.getLength());
- final CRenameProcessor processor = new CRenameProcessor(this, iarg);
- CRenameRefactoring refactoring= new CRenameRefactoring(processor);
- RenameSupport.openDialog(shell, refactoring);
+ IResource res = workingCopy.getResource();
+ if (!(res instanceof IFile)) {
+ return;
+ }
+ if (!IDE.saveAllEditors(new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, false)) {
+ return;
+ }
+ CRefactoringArgument iarg = new CRefactoringArgument((IFile) res, selection.getOffset(), selection.getLength());
+ final CRenameProcessor processor = new CRenameProcessor(this, iarg);
+ CRenameRefactoring refactoring = new CRenameRefactoring(processor);
+ RenameSupport.openDialog(shell, refactoring);
}
/**
* Rename a resource selected in the navigator
- *
+ *
* @param shell
* @param selected
*/
@@ -111,40 +110,39 @@ public class CRefactory {
RenameSupport.openRenameResourceDialog(shell, selected);
}
- public TextSearchWrapper getTextSearch() {
- if (fTextSearch == null) {
- return new TextSearchWrapper();
- }
- return fTextSearch;
- }
-
- public String[] getCCppPatterns() {
- IContentType[] cts= Platform.getContentTypeManager().getAllContentTypes();
- HashSet<String> all= new HashSet<String>();
- for (IContentType candidate : cts) {
- IContentType type = candidate;
- boolean useIt= false;
- while (!useIt && type != null) {
- String id= type.getId();
- if (id.equals(CCorePlugin.CONTENT_TYPE_CHEADER) ||
- id.equals(CCorePlugin.CONTENT_TYPE_CSOURCE) ||
- id.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) ||
- id.equals(CCorePlugin.CONTENT_TYPE_CXXSOURCE)) {
- useIt= true;
- } else {
- type= type.getBaseType();
- }
- }
- if (useIt) {
- String exts[] = candidate.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
- all.addAll(Arrays.asList(exts));
- }
- }
- String[] result= new String[all.size()];
- Iterator<String> it= all.iterator();
- for (int i= 0; i < result.length; i++) {
- result[i]= "*." + it.next(); //$NON-NLS-1$
- }
- return result;
- }
+ public TextSearchWrapper getTextSearch() {
+ if (fTextSearch == null) {
+ return new TextSearchWrapper();
+ }
+ return fTextSearch;
+ }
+
+ public String[] getCCppPatterns() {
+ IContentType[] cts = Platform.getContentTypeManager().getAllContentTypes();
+ HashSet<String> all = new HashSet<String>();
+ for (IContentType candidate : cts) {
+ IContentType type = candidate;
+ boolean useIt = false;
+ while (!useIt && type != null) {
+ String id = type.getId();
+ if (id.equals(CCorePlugin.CONTENT_TYPE_CHEADER) || id.equals(CCorePlugin.CONTENT_TYPE_CSOURCE)
+ || id.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER)
+ || id.equals(CCorePlugin.CONTENT_TYPE_CXXSOURCE)) {
+ useIt = true;
+ } else {
+ type = type.getBaseType();
+ }
+ }
+ if (useIt) {
+ String exts[] = candidate.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+ all.addAll(Arrays.asList(exts));
+ }
+ }
+ String[] result = new String[all.size()];
+ Iterator<String> it = all.iterator();
+ for (int i = 0; i < result.length; i++) {
+ result[i] = "*." + it.next(); //$NON-NLS-1$
+ }
+ return result;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java
index b01a851d0bd..fdf42246eb1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2005, 2015 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.util.ArrayList;
@@ -59,9 +59,9 @@ import org.eclipse.cdt.internal.ui.util.NameComposer;
public class CRenameClassProcessor extends CRenameTypeProcessor {
private final List<Change> tuRenames = new ArrayList<>();
- public CRenameClassProcessor(CRenameProcessor processor, String kind) {
- super(processor, kind);
- }
+ public CRenameClassProcessor(CRenameProcessor processor, String kind) {
+ super(processor, kind);
+ }
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
@@ -83,44 +83,44 @@ public class CRenameClassProcessor extends CRenameTypeProcessor {
return compositeChange;
}
- @Override
+ @Override
protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) {
- tuRenames.clear();
- CRefactoringArgument argument= getArgument();
- IBinding binding= argument.getBinding();
- ArrayList<IBinding> bindings= new ArrayList<>();
- if (binding != null) {
- recordRename(binding);
- bindings.add(binding);
- }
- if (binding instanceof ICPPClassType) {
- ICPPClassType ctype= (ICPPClassType) binding;
- ICPPConstructor[] ctors= ctype.getConstructors();
+ tuRenames.clear();
+ CRefactoringArgument argument = getArgument();
+ IBinding binding = argument.getBinding();
+ ArrayList<IBinding> bindings = new ArrayList<>();
+ if (binding != null) {
+ recordRename(binding);
+ bindings.add(binding);
+ }
+ if (binding instanceof ICPPClassType) {
+ ICPPClassType ctype = (ICPPClassType) binding;
+ ICPPConstructor[] ctors = ctype.getConstructors();
if (ctors != null) {
- ArrayUtil.addAll(bindings, ctors);
+ ArrayUtil.addAll(bindings, ctors);
}
- IScope scope= ctype.getCompositeScope();
+ IScope scope = ctype.getCompositeScope();
if (scope != null) {
- IBinding[] dtors= scope.find("~" + argument.getName(), argument.getTranslationUnit()); //$NON-NLS-1$
- if (dtors != null) {
- ArrayUtil.addAll(bindings, dtors);
- }
+ IBinding[] dtors = scope.find("~" + argument.getName(), argument.getTranslationUnit()); //$NON-NLS-1$
+ if (dtors != null) {
+ ArrayUtil.addAll(bindings, dtors);
+ }
}
renameTranslationUnits(ctype);
- }
- return bindings.toArray(new IBinding[bindings.size()]);
- }
+ }
+ return bindings.toArray(new IBinding[bindings.size()]);
+ }
private void renameTranslationUnits(ICPPBinding binding) {
- IIndex index = getIndex();
- if (index == null) {
- return;
- }
- try {
- index.acquireReadLock();
- Set<IIndexFileLocation> locations = new HashSet<>();
+ IIndex index = getIndex();
+ if (index == null) {
+ return;
+ }
+ try {
+ index.acquireReadLock();
+ Set<IIndexFileLocation> locations = new HashSet<>();
IIndexName[] names = index.findNames(binding, IIndex.FIND_DEFINITIONS);
for (IIndexName name : names) {
locations.add(name.getFile().getLocation());
@@ -132,68 +132,68 @@ public class CRenameClassProcessor extends CRenameTypeProcessor {
if (fullPath == null)
return;
IPath headerPath = new Path(fullPath);
- IResource file = ResourcesPlugin.getWorkspace().getRoot().findMember(headerPath);
- if (file == null || file.getType() != IResource.FILE)
- return;
-
- IProject project = getProject();
- int headerCapitalization = PreferenceConstants.getPreference(
- PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION, project,
- PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL);
- String headerWordDelimiter = PreferenceConstants.getPreference(
- PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER, project, ""); //$NON-NLS-1$
- int sourceCapitalization = PreferenceConstants.getPreference(
- PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION, project,
- PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL);
- String sourceWordDelimiter = PreferenceConstants.getPreference(
- PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER, project, ""); //$NON-NLS-1$
+ IResource file = ResourcesPlugin.getWorkspace().getRoot().findMember(headerPath);
+ if (file == null || file.getType() != IResource.FILE)
+ return;
+
+ IProject project = getProject();
+ int headerCapitalization = PreferenceConstants.getPreference(
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION, project,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL);
+ String headerWordDelimiter = PreferenceConstants
+ .getPreference(PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER, project, ""); //$NON-NLS-1$
+ int sourceCapitalization = PreferenceConstants.getPreference(
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION, project,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL);
+ String sourceWordDelimiter = PreferenceConstants
+ .getPreference(PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER, project, ""); //$NON-NLS-1$
String headerName = headerPath.lastSegment();
String className = binding.getName();
- NameComposer nameComposer = NameComposer.createByExample(className, headerName,
- headerCapitalization, headerWordDelimiter);
+ NameComposer nameComposer = NameComposer.createByExample(className, headerName, headerCapitalization,
+ headerWordDelimiter);
if (nameComposer == null)
return;
String newClassName = getReplacementText();
String newHeaderName = nameComposer.compose(newClassName);
- if (!newHeaderName.equals(headerName)) {
- renameTranslationUnit((IFile) file, newHeaderName);
- }
+ if (!newHeaderName.equals(headerName)) {
+ renameTranslationUnit((IFile) file, newHeaderName);
+ }
- IIndexInclude[] includedBy = index.findIncludedBy(names[0].getFile());
- for (IIndexInclude include : includedBy) {
+ IIndexInclude[] includedBy = index.findIncludedBy(names[0].getFile());
+ for (IIndexInclude include : includedBy) {
location = include.getIncludedByLocation();
fullPath = location.getFullPath();
if (fullPath == null)
continue;
IPath filePath = new Path(fullPath);
- file = ResourcesPlugin.getWorkspace().getRoot().findMember(filePath);
- if (file != null && file.getType() == IResource.FILE) {
- String fileName = filePath.lastSegment();
+ file = ResourcesPlugin.getWorkspace().getRoot().findMember(filePath);
+ if (file != null && file.getType() == IResource.FILE) {
+ String fileName = filePath.lastSegment();
if (CoreModel.isValidHeaderUnitName(project, fileName)) {
- nameComposer = NameComposer.createByExample(className, fileName,
- headerCapitalization, headerWordDelimiter);
- } else {
- nameComposer = NameComposer.createByExample(className, fileName,
- sourceCapitalization, sourceWordDelimiter);
- }
+ nameComposer = NameComposer.createByExample(className, fileName, headerCapitalization,
+ headerWordDelimiter);
+ } else {
+ nameComposer = NameComposer.createByExample(className, fileName, sourceCapitalization,
+ sourceWordDelimiter);
+ }
if (nameComposer != null) {
String newName = nameComposer.compose(newClassName);
- if (!newName.equals(fileName)) {
- renameTranslationUnit((IFile) file, newName);
- }
- }
- }
+ if (!newName.equals(fileName)) {
+ renameTranslationUnit((IFile) file, newName);
+ }
+ }
+ }
}
} catch (CoreException e) {
CUIPlugin.log(e);
return;
} catch (InterruptedException e) {
- return; // Ignore.
+ return; // Ignore.
} finally {
- index.releaseReadLock();
- }
+ index.releaseReadLock();
+ }
}
protected void renameTranslationUnit(IFile file, String newName) {
@@ -205,9 +205,9 @@ public class CRenameClassProcessor extends CRenameTypeProcessor {
}
protected IProject getProject() {
- IFile file= getArgument().getSourceFile();
+ IFile file = getArgument().getSourceFile();
if (file == null)
return null;
- return file.getProject();
+ return file.getProject();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java
index 624b4a8f820..cb50d4e52c6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2005, 2011 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
@@ -21,14 +21,11 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
*/
public class CRenameGlobalProcessor extends CRenameProcessorDelegate {
- public CRenameGlobalProcessor(CRenameProcessor processor, String name) {
- super(processor, name);
- setAvailableOptions(
- CRefactory.OPTION_IN_CODE_REFERENCES |
- CRefactory.OPTION_IN_COMMENT |
- CRefactory.OPTION_IN_MACRO_DEFINITION |
- CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
- }
+ public CRenameGlobalProcessor(CRenameProcessor processor, String name) {
+ super(processor, name);
+ setAvailableOptions(CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_COMMENT
+ | CRefactory.OPTION_IN_MACRO_DEFINITION | CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
+ }
@Override
public int getSaveMode() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java
index a0a0502edca..97f221ca97f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
@@ -20,21 +20,19 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
* Rename processor setting up input page for renaming include directives.
*/
public class CRenameIncludeProcessor extends CRenameProcessorDelegate {
-
- public CRenameIncludeProcessor(CRenameProcessor input, String kind) {
- super(input, kind);
- setAvailableOptions(
- CRefactory.OPTION_IN_COMMENT |
- CRefactory.OPTION_IN_MACRO_DEFINITION |
- CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
- setOptionsForcingPreview(-1);
- setOptionsEnablingExhaustiveSearch(-1);
- }
- @Override
+ public CRenameIncludeProcessor(CRenameProcessor input, String kind) {
+ super(input, kind);
+ setAvailableOptions(CRefactory.OPTION_IN_COMMENT | CRefactory.OPTION_IN_MACRO_DEFINITION
+ | CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
+ setOptionsForcingPreview(-1);
+ setOptionsEnablingExhaustiveSearch(-1);
+ }
+
+ @Override
protected int getAcceptedLocations(int selectedOptions) {
- return selectedOptions | CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
- }
+ return selectedOptions | CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
+ }
@Override
public int getSaveMode() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java
index 44930f4bad6..ad305b6e4da 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.util.Collection;
@@ -30,62 +30,61 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
-
/**
* Rename processor, setting up input page for a local rename.
*/
public class CRenameLocalProcessor extends CRenameProcessorDelegate {
- private IScope fScope;
+ private IScope fScope;
+
+ public CRenameLocalProcessor(CRenameProcessor input, String kind, IScope scope) {
+ super(input, kind);
+ fScope = scope;
+ setAvailableOptions(0);
+ setOptionsForcingPreview(0);
+ }
- public CRenameLocalProcessor(CRenameProcessor input, String kind, IScope scope) {
- super(input, kind);
- fScope= scope;
- setAvailableOptions(0);
- setOptionsForcingPreview(0);
- }
-
- @Override
+ @Override
protected int getAcceptedLocations(int selectedOptions) {
- return CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_MACRO_DEFINITION | selectedOptions;
- }
-
- @Override
+ return CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_MACRO_DEFINITION | selectedOptions;
+ }
+
+ @Override
protected int getSearchScope() {
- return TextSearchWrapper.SCOPE_FILE;
- }
-
+ return TextSearchWrapper.SCOPE_FILE;
+ }
+
@Override
protected void analyzeTextMatches(IBinding[] renameBindings, Collection<CRefactoringMatch> matches,
IProgressMonitor monitor, RefactoringStatus status) {
- super.analyzeTextMatches(renameBindings, matches, monitor, status);
- if (fScope != null) {
- CRefactoringArgument argument = getArgument();
- int[] result= new int[] {0, Integer.MAX_VALUE};
- IScope scope= argument.getScope();
- IASTNode node= null;
- node = ASTInternal.getPhysicalNodeOfScope(scope);
+ super.analyzeTextMatches(renameBindings, matches, monitor, status);
+ if (fScope != null) {
+ CRefactoringArgument argument = getArgument();
+ int[] result = new int[] { 0, Integer.MAX_VALUE };
+ IScope scope = argument.getScope();
+ IASTNode node = null;
+ node = ASTInternal.getPhysicalNodeOfScope(scope);
if (argument.getBinding() instanceof IParameter) {
- node= node.getParent();
+ node = node.getParent();
}
- if (node != null) {
- IASTFileLocation loc= ASTManager.getLocationInTranslationUnit(node);
- if (loc != null) {
- result[0]= loc.getNodeOffset();
- result[1]= result[0] + loc.getNodeLength();
- }
- }
- int[] range= result;
- for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
- CRefactoringMatch m = iter.next();
- if (m.getAstInformation() != CRefactoringMatch.AST_REFERENCE) {
- int off= m.getOffset();
- if (off < range[0] || off > range[1]) {
- iter.remove();
- }
- }
- }
- }
- }
+ if (node != null) {
+ IASTFileLocation loc = ASTManager.getLocationInTranslationUnit(node);
+ if (loc != null) {
+ result[0] = loc.getNodeOffset();
+ result[1] = result[0] + loc.getNodeLength();
+ }
+ }
+ int[] range = result;
+ for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
+ CRefactoringMatch m = iter.next();
+ if (m.getAstInformation() != CRefactoringMatch.AST_REFERENCE) {
+ int off = m.getOffset();
+ if (off < range[0] || off > range[1]) {
+ iter.remove();
+ }
+ }
+ }
+ }
+ }
@Override
public int getSaveMode() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java
index 2235596f8ae..fde11b53c04 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
@@ -26,32 +26,29 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
*/
public class CRenameMacroProcessor extends CRenameGlobalProcessor {
- public CRenameMacroProcessor(CRenameProcessor processor, String name) {
- super(processor, name);
- setAvailableOptions(
- CRefactory.OPTION_IN_CODE_REFERENCES |
- CRefactory.OPTION_IN_COMMENT |
- CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE |
- CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
- }
+ public CRenameMacroProcessor(CRenameProcessor processor, String name) {
+ super(processor, name);
+ setAvailableOptions(CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_COMMENT
+ | CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE | CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
+ }
- @Override
+ @Override
protected int getAcceptedLocations(int selectedOptions) {
- return selectedOptions | CRefactory.OPTION_IN_MACRO_DEFINITION;
- }
+ return selectedOptions | CRefactory.OPTION_IN_MACRO_DEFINITION;
+ }
@Override
protected void analyzeTextMatches(IBinding[] renameBindings, Collection<CRefactoringMatch> matches,
IProgressMonitor monitor, RefactoringStatus status) {
- for (CRefactoringMatch m : matches) {
- if ((m.getLocation() & CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE) != 0 ||
- // Occurrences in code are reliable only when exhaustive file search is not used.
- // TODO(sprigogin): Use index matches to endorse matches obtained from the file search.
- (getSelectedOptions() & CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH) == 0 &&
- (m.getLocation() & CRefactory.OPTION_IN_CODE_REFERENCES) != 0) {
- m.setASTInformation(CRefactoringMatch.AST_REFERENCE);
- }
- }
- super.analyzeTextMatches(renameBindings, matches, monitor, status);
- }
+ for (CRefactoringMatch m : matches) {
+ if ((m.getLocation() & CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE) != 0 ||
+ // Occurrences in code are reliable only when exhaustive file search is not used.
+ // TODO(sprigogin): Use index matches to endorse matches obtained from the file search.
+ (getSelectedOptions() & CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH) == 0
+ && (m.getLocation() & CRefactory.OPTION_IN_CODE_REFERENCES) != 0) {
+ m.setASTInformation(CRefactoringMatch.AST_REFERENCE);
+ }
+ }
+ super.analyzeTextMatches(renameBindings, matches, monitor, status);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java
index 0a428636753..add457f9fab 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2005, 2014 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
- * Sergey Prigogin (Google)
- ******************************************************************************/
+ * Sergey Prigogin (Google)
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.util.ArrayList;
@@ -39,91 +39,97 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
* Rename processor for methods.
*/
public class CRenameMethodProcessor extends CRenameGlobalProcessor {
- public CRenameMethodProcessor(CRenameProcessor processor, String kind, boolean isVirtual) {
- super(processor, kind);
- if (isVirtual)
- setAvailableOptions(getAvailableOptions() | CRefactory.OPTION_DO_VIRTUAL);
- }
+ public CRenameMethodProcessor(CRenameProcessor processor, String kind, boolean isVirtual) {
+ super(processor, kind);
+ if (isVirtual)
+ setAvailableOptions(getAvailableOptions() | CRefactory.OPTION_DO_VIRTUAL);
+ }
+
+ @Override
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws OperationCanceledException, CoreException {
+ CRefactoringArgument argument = getArgument();
+ IBinding binding = argument.getBinding();
+ if (binding instanceof ICPPConstructor) {
+ return RefactoringStatus
+ .createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameConstructor);
+ }
+ String identifier = argument.getName();
+ if (identifier.startsWith("~")) { //$NON-NLS-1$
+ return RefactoringStatus
+ .createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameDestructor);
+ }
+ if (identifier.startsWith("operator") && //$NON-NLS-1$
+ identifier.length() > 8 && !CRefactoringUtils.isIdentifierChar(identifier.charAt(8))) {
+ return RefactoringStatus
+ .createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameOperator);
+ }
+ return super.checkInitialConditions(pm);
+ }
- @Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
- throws OperationCanceledException, CoreException {
- CRefactoringArgument argument= getArgument();
- IBinding binding= argument.getBinding();
- if (binding instanceof ICPPConstructor) {
- return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameConstructor);
- }
- String identifier= argument.getName();
- if (identifier.startsWith("~")) { //$NON-NLS-1$
- return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameDestructor);
- }
- if (identifier.startsWith("operator") && //$NON-NLS-1$
- identifier.length() > 8 &&
- !CRefactoringUtils.isIdentifierChar(identifier.charAt(8))) {
- return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameOperator);
- }
- return super.checkInitialConditions(pm);
- }
-
- @Override
+ @Override
public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context)
- throws OperationCanceledException, CoreException {
- CRefactoringArgument argument= getArgument();
- RefactoringStatus result= new RefactoringStatus();
- IScope scope= argument.getScope();
- if (scope != null) {
- IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope);
- if (node instanceof IASTCompositeTypeSpecifier) {
- IASTCompositeTypeSpecifier se= (IASTCompositeTypeSpecifier) node;
- IASTName name= ASTManager.getSimpleName(se.getName());
- if (getReplacementText().equals(name.toString())) {
- return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameToConstructor);
- }
- if (getReplacementText().startsWith("~")) { //$NON-NLS-1$
- return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameToDestructor);
- }
- if (!CRefactoringUtils.checkIdentifier(getReplacementText())) {
- result.merge(RefactoringStatus.createErrorStatus(RenameMessages.CRenameMethodProcessor_warning_illegalCharacters));
- }
- }
- }
- if (argument.getArgumentKind() == CRefactory.ARGUMENT_VIRTUAL_METHOD &&
- (getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
- result.merge(RefactoringStatus.createWarningStatus(RenameMessages.CRenameMethodProcessor_warning_renameVirtual));
- }
+ throws OperationCanceledException, CoreException {
+ CRefactoringArgument argument = getArgument();
+ RefactoringStatus result = new RefactoringStatus();
+ IScope scope = argument.getScope();
+ if (scope != null) {
+ IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope);
+ if (node instanceof IASTCompositeTypeSpecifier) {
+ IASTCompositeTypeSpecifier se = (IASTCompositeTypeSpecifier) node;
+ IASTName name = ASTManager.getSimpleName(se.getName());
+ if (getReplacementText().equals(name.toString())) {
+ return RefactoringStatus.createFatalErrorStatus(
+ RenameMessages.CRenameMethodProcessor_fatalError_renameToConstructor);
+ }
+ if (getReplacementText().startsWith("~")) { //$NON-NLS-1$
+ return RefactoringStatus.createFatalErrorStatus(
+ RenameMessages.CRenameMethodProcessor_fatalError_renameToDestructor);
+ }
+ if (!CRefactoringUtils.checkIdentifier(getReplacementText())) {
+ result.merge(RefactoringStatus
+ .createErrorStatus(RenameMessages.CRenameMethodProcessor_warning_illegalCharacters));
+ }
+ }
+ }
+ if (argument.getArgumentKind() == CRefactory.ARGUMENT_VIRTUAL_METHOD
+ && (getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
+ result.merge(
+ RefactoringStatus.createWarningStatus(RenameMessages.CRenameMethodProcessor_warning_renameVirtual));
+ }
- result.merge(super.checkFinalConditions(monitor, context));
- return result;
- }
-
- @Override
+ result.merge(super.checkFinalConditions(monitor, context));
+ return result;
+ }
+
+ @Override
protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) {
- if ((getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
- return super.getBindingsToBeRenamed(status);
- }
-
- CRefactoringArgument argument= getArgument();
- IBinding binding= argument.getBinding();
- IASTNode node= ASTInternal.getPhysicalNodeOfScope(argument.getScope());
- ArrayList<IBinding> bindings= new ArrayList<>();
- if (binding != null) {
- recordRename(binding);
- bindings.add(binding);
- }
- if (binding instanceof ICPPMethod) {
- ICPPMethod m= (ICPPMethod) binding;
- try {
- CPPSemantics.pushLookupPoint(node);
- IBinding[] bs= ClassTypeHelper.findOverridden(m);
- bindings.addAll(Arrays.asList(bs));
- bs= ClassTypeHelper.findOverriders(getIndex(), m);
- bindings.addAll(Arrays.asList(bs));
- } catch (CoreException e) {
- status.addError(e.getMessage());
- } finally {
- CPPSemantics.popLookupPoint();
- }
- }
- return bindings.toArray(new IBinding[bindings.size()]);
- }
+ if ((getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
+ return super.getBindingsToBeRenamed(status);
+ }
+
+ CRefactoringArgument argument = getArgument();
+ IBinding binding = argument.getBinding();
+ IASTNode node = ASTInternal.getPhysicalNodeOfScope(argument.getScope());
+ ArrayList<IBinding> bindings = new ArrayList<>();
+ if (binding != null) {
+ recordRename(binding);
+ bindings.add(binding);
+ }
+ if (binding instanceof ICPPMethod) {
+ ICPPMethod m = (ICPPMethod) binding;
+ try {
+ CPPSemantics.pushLookupPoint(node);
+ IBinding[] bs = ClassTypeHelper.findOverridden(m);
+ bindings.addAll(Arrays.asList(bs));
+ bs = ClassTypeHelper.findOverriders(getIndex(), m);
+ bindings.addAll(Arrays.asList(bs));
+ } catch (CoreException e) {
+ status.addError(e.getMessage());
+ } finally {
+ CPPSemantics.popLookupPoint();
+ }
+ }
+ return bindings.toArray(new IBinding[bindings.size()]);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java
index f6d04d8b79a..aa91dbbad0d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java
@@ -9,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
@@ -50,282 +50,274 @@ import org.eclipse.cdt.ui.CUIPlugin;
* use and forwards further calls to the delegate.
*/
public class CRenameProcessor extends RenameProcessor {
- public static final String IDENTIFIER= "org.eclips.cdt.refactoring.RenameProcessor"; //$NON-NLS-1$
-
- private static final String[] AFFECTED_PROJECT_NATURES =
- { CCProjectNature.CC_NATURE_ID, CProjectNature.C_NATURE_ID };
-
- private final CRefactoringArgument fArgument;
- private CRenameProcessorDelegate fDelegate;
- private String fReplacementText;
- private String fWorkingSetName;
- private int fExhaustiveSearchScope;
- private int fSelectedOptions;
- private final CRefactory fManager;
- private final ASTManager fAstManager;
+ public static final String IDENTIFIER = "org.eclips.cdt.refactoring.RenameProcessor"; //$NON-NLS-1$
+
+ private static final String[] AFFECTED_PROJECT_NATURES = { CCProjectNature.CC_NATURE_ID,
+ CProjectNature.C_NATURE_ID };
+
+ private final CRefactoringArgument fArgument;
+ private CRenameProcessorDelegate fDelegate;
+ private String fReplacementText;
+ private String fWorkingSetName;
+ private int fExhaustiveSearchScope;
+ private int fSelectedOptions;
+ private final CRefactory fManager;
+ private final ASTManager fAstManager;
private IIndex fIndex;
private int fIndexLockCount;
private RefactoringStatus fInitialConditionsStatus;
-
- public CRenameProcessor(CRefactory refactoringManager, CRefactoringArgument arg) {
- fManager= refactoringManager;
- fArgument= arg;
- fAstManager= new ASTManager(arg);
- }
-
- public CRefactoringArgument getArgument() {
- return fArgument;
- }
-
- @Override
+
+ public CRenameProcessor(CRefactory refactoringManager, CRefactoringArgument arg) {
+ fManager = refactoringManager;
+ fArgument = arg;
+ fAstManager = new ASTManager(arg);
+ }
+
+ public CRefactoringArgument getArgument() {
+ return fArgument;
+ }
+
+ @Override
public Object[] getElements() {
- return new Object[] { fArgument.getBinding() };
- }
+ return new Object[] { fArgument.getBinding() };
+ }
- @Override
+ @Override
public String getProcessorName() {
- String result= null;
- if (fDelegate != null) {
- result= fDelegate.getProcessorName();
- }
- if (result == null) {
- String identifier= getArgument().getName();
- if (identifier != null && identifier.length() > 0) {
- result= NLS.bind(RenameMessages.CRenameTopProcessor_wizard_title, identifier);
- }
- }
- if (result == null) {
- result= RenameMessages.CRenameTopProcessor_wizard_backup_title;
- }
-
- return result;
- }
-
- @Override
+ String result = null;
+ if (fDelegate != null) {
+ result = fDelegate.getProcessorName();
+ }
+ if (result == null) {
+ String identifier = getArgument().getName();
+ if (identifier != null && identifier.length() > 0) {
+ result = NLS.bind(RenameMessages.CRenameTopProcessor_wizard_title, identifier);
+ }
+ }
+ if (result == null) {
+ result = RenameMessages.CRenameTopProcessor_wizard_backup_title;
+ }
+
+ return result;
+ }
+
+ @Override
public boolean isApplicable() throws CoreException {
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
- throws CoreException, OperationCanceledException {
- if (fInitialConditionsStatus != null) {
- return fInitialConditionsStatus; // Already checked.
- }
- String identifier= null;
- fInitialConditionsStatus= new RefactoringStatus();
- if (fArgument != null) {
- fAstManager.analyzeArgument(fIndex, pm, fInitialConditionsStatus);
- identifier= fArgument.getName();
- }
- if (identifier == null || identifier.length() == 0) {
- fInitialConditionsStatus.addFatalError(RenameMessages.CRenameTopProcessor_error_invalidTextSelection);
- return fInitialConditionsStatus;
- }
- IFile file= fArgument.getSourceFile();
- IPath path= null;
- if (file != null) {
- path= file.getLocation();
- }
- if (path == null) {
- return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameTopProcessor_error_renameWithoutSourceFile);
- }
-
- updateBinding();
-
- fDelegate= createDelegate();
- if (fDelegate == null) {
- fInitialConditionsStatus.addFatalError(RenameMessages.CRenameTopProcessor_error_invalidName);
- return fInitialConditionsStatus;
- }
- RefactoringStatus status= fDelegate.checkInitialConditions(new NullProgressMonitor());
- fInitialConditionsStatus.merge(status);
- return fInitialConditionsStatus;
- }
+ throws CoreException, OperationCanceledException {
+ if (fInitialConditionsStatus != null) {
+ return fInitialConditionsStatus; // Already checked.
+ }
+ String identifier = null;
+ fInitialConditionsStatus = new RefactoringStatus();
+ if (fArgument != null) {
+ fAstManager.analyzeArgument(fIndex, pm, fInitialConditionsStatus);
+ identifier = fArgument.getName();
+ }
+ if (identifier == null || identifier.length() == 0) {
+ fInitialConditionsStatus.addFatalError(RenameMessages.CRenameTopProcessor_error_invalidTextSelection);
+ return fInitialConditionsStatus;
+ }
+ IFile file = fArgument.getSourceFile();
+ IPath path = null;
+ if (file != null) {
+ path = file.getLocation();
+ }
+ if (path == null) {
+ return RefactoringStatus
+ .createFatalErrorStatus(RenameMessages.CRenameTopProcessor_error_renameWithoutSourceFile);
+ }
+
+ updateBinding();
+
+ fDelegate = createDelegate();
+ if (fDelegate == null) {
+ fInitialConditionsStatus.addFatalError(RenameMessages.CRenameTopProcessor_error_invalidName);
+ return fInitialConditionsStatus;
+ }
+ RefactoringStatus status = fDelegate.checkInitialConditions(new NullProgressMonitor());
+ fInitialConditionsStatus.merge(status);
+ return fInitialConditionsStatus;
+ }
/**
- * Change the binding for the renaming of constructors and destructor to the class.
+ * Change the binding for the renaming of constructors and destructor to the class.
*/
private void updateBinding() {
- IBinding binding= fArgument.getBinding();
- if (binding instanceof ICPPConstructor ||
- (binding instanceof ICPPMethod && ((ICPPMethod) binding).isDestructor())) {
- // Switch binding to class level when constructor or destructor selected
- IBinding newBinding = ((ICPPMember) binding).getClassOwner();
- IScope scope = fArgument.getScope();
- try {
- scope = newBinding.getScope();
- } catch (DOMException e) {
- CUIPlugin.log(e);
- }
- fArgument.setBinding(fArgument.getTranslationUnit(), newBinding, scope);
-
- if (fArgument.getName().startsWith("~")) { //$NON-NLS-1$
- fArgument.setName(newBinding.getName());
- }
- }
+ IBinding binding = fArgument.getBinding();
+ if (binding instanceof ICPPConstructor
+ || (binding instanceof ICPPMethod && ((ICPPMethod) binding).isDestructor())) {
+ // Switch binding to class level when constructor or destructor selected
+ IBinding newBinding = ((ICPPMember) binding).getClassOwner();
+ IScope scope = fArgument.getScope();
+ try {
+ scope = newBinding.getScope();
+ } catch (DOMException e) {
+ CUIPlugin.log(e);
+ }
+ fArgument.setBinding(fArgument.getTranslationUnit(), newBinding, scope);
+
+ if (fArgument.getName().startsWith("~")) { //$NON-NLS-1$
+ fArgument.setName(newBinding.getName());
+ }
+ }
}
- private CRenameProcessorDelegate createDelegate() {
- switch (fArgument.getArgumentKind()) {
- case CRefactory.ARGUMENT_LOCAL_VAR:
- return new CRenameLocalProcessor(this,
- RenameMessages.CRenameTopProcessor_localVar,
- fArgument.getScope());
- case CRefactory.ARGUMENT_PARAMETER:
- return new CRenameLocalProcessor(this,
- RenameMessages.CRenameTopProcessor_parameter,
- fArgument.getScope());
- case CRefactory.ARGUMENT_FILE_LOCAL_VAR:
- return new CRenameLocalProcessor(this,
- RenameMessages.CRenameTopProcessor_filelocalVar,
- null);
- case CRefactory.ARGUMENT_GLOBAL_VAR:
- return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_globalVar);
- case CRefactory.ARGUMENT_ENUMERATOR:
- return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_enumerator);
- case CRefactory.ARGUMENT_FIELD:
- return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_field);
- case CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION:
- return new CRenameLocalProcessor(this,
- RenameMessages.CRenameTopProcessor_filelocalFunction,
- null);
- case CRefactory.ARGUMENT_GLOBAL_FUNCTION:
- return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_globalFunction);
- case CRefactory.ARGUMENT_VIRTUAL_METHOD:
- return new CRenameMethodProcessor(this, RenameMessages.CRenameTopProcessor_virtualMethod, true);
- case CRefactory.ARGUMENT_NON_VIRTUAL_METHOD:
- return new CRenameMethodProcessor(this, RenameMessages.CRenameTopProcessor_method, false);
- case CRefactory.ARGUMENT_CLASS_TYPE:
- return new CRenameClassProcessor(this, RenameMessages.CRenameTopProcessor_type);
- case CRefactory.ARGUMENT_NAMESPACE:
- return new CRenameTypeProcessor(this, RenameMessages.CRenameTopProcessor_namespace);
- case CRefactory.ARGUMENT_TYPE:
- return new CRenameTypeProcessor(this, RenameMessages.CRenameTopProcessor_type);
- case CRefactory.ARGUMENT_MACRO:
- return new CRenameMacroProcessor(this, RenameMessages.CRenameTopProcessor_macro);
- case CRefactory.ARGUMENT_INCLUDE_DIRECTIVE:
- return new CRenameIncludeProcessor(this, RenameMessages.CRenameIncludeProcessor_includeDirective);
- default:
- return null;
- }
- }
-
- @Override
+ private CRenameProcessorDelegate createDelegate() {
+ switch (fArgument.getArgumentKind()) {
+ case CRefactory.ARGUMENT_LOCAL_VAR:
+ return new CRenameLocalProcessor(this, RenameMessages.CRenameTopProcessor_localVar, fArgument.getScope());
+ case CRefactory.ARGUMENT_PARAMETER:
+ return new CRenameLocalProcessor(this, RenameMessages.CRenameTopProcessor_parameter, fArgument.getScope());
+ case CRefactory.ARGUMENT_FILE_LOCAL_VAR:
+ return new CRenameLocalProcessor(this, RenameMessages.CRenameTopProcessor_filelocalVar, null);
+ case CRefactory.ARGUMENT_GLOBAL_VAR:
+ return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_globalVar);
+ case CRefactory.ARGUMENT_ENUMERATOR:
+ return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_enumerator);
+ case CRefactory.ARGUMENT_FIELD:
+ return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_field);
+ case CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION:
+ return new CRenameLocalProcessor(this, RenameMessages.CRenameTopProcessor_filelocalFunction, null);
+ case CRefactory.ARGUMENT_GLOBAL_FUNCTION:
+ return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_globalFunction);
+ case CRefactory.ARGUMENT_VIRTUAL_METHOD:
+ return new CRenameMethodProcessor(this, RenameMessages.CRenameTopProcessor_virtualMethod, true);
+ case CRefactory.ARGUMENT_NON_VIRTUAL_METHOD:
+ return new CRenameMethodProcessor(this, RenameMessages.CRenameTopProcessor_method, false);
+ case CRefactory.ARGUMENT_CLASS_TYPE:
+ return new CRenameClassProcessor(this, RenameMessages.CRenameTopProcessor_type);
+ case CRefactory.ARGUMENT_NAMESPACE:
+ return new CRenameTypeProcessor(this, RenameMessages.CRenameTopProcessor_namespace);
+ case CRefactory.ARGUMENT_TYPE:
+ return new CRenameTypeProcessor(this, RenameMessages.CRenameTopProcessor_type);
+ case CRefactory.ARGUMENT_MACRO:
+ return new CRenameMacroProcessor(this, RenameMessages.CRenameTopProcessor_macro);
+ case CRefactory.ARGUMENT_INCLUDE_DIRECTIVE:
+ return new CRenameIncludeProcessor(this, RenameMessages.CRenameIncludeProcessor_includeDirective);
+ default:
+ return null;
+ }
+ }
+
+ @Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
- throws CoreException, OperationCanceledException {
+ throws CoreException, OperationCanceledException {
return fDelegate.checkFinalConditions(pm, context);
- }
+ }
- @Override
+ @Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
- return fDelegate.createChange(pm);
- }
+ return fDelegate.createChange(pm);
+ }
@Override
- public final RefactoringParticipant[] loadParticipants(RefactoringStatus status,
- SharableParticipants shared) throws CoreException {
+ public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared)
+ throws CoreException {
return fDelegate.getRenameModifications().loadParticipants(status, this, AFFECTED_PROJECT_NATURES, shared);
}
- /**
- * Options for the input page in the refactoring wizard.
- */
- public int getAvailableOptions() {
- if (fDelegate == null) {
- return 0;
- }
- return fDelegate.getAvailableOptions();
- }
-
- /**
- * Options for the input page that trigger the preview.
- */
- public int getOptionsForcingPreview() {
- if (fDelegate == null) {
- return 0;
- }
- return fDelegate.getOptionsForcingPreview();
- }
-
- /**
- * The options that may need exhaustive file search since index lookup is not guaranteed to
- * return all files participating in refactoring. When one of these options is selected,
- * the exhaustive file search is enabled.
- */
- public int getOptionsEnablingExhaustiveSearch() {
- if (fDelegate == null) {
- return 0;
- }
- return fDelegate.getOptionsEnablingExhaustiveSearch();
- }
-
- @Override
+ /**
+ * Options for the input page in the refactoring wizard.
+ */
+ public int getAvailableOptions() {
+ if (fDelegate == null) {
+ return 0;
+ }
+ return fDelegate.getAvailableOptions();
+ }
+
+ /**
+ * Options for the input page that trigger the preview.
+ */
+ public int getOptionsForcingPreview() {
+ if (fDelegate == null) {
+ return 0;
+ }
+ return fDelegate.getOptionsForcingPreview();
+ }
+
+ /**
+ * The options that may need exhaustive file search since index lookup is not guaranteed to
+ * return all files participating in refactoring. When one of these options is selected,
+ * the exhaustive file search is enabled.
+ */
+ public int getOptionsEnablingExhaustiveSearch() {
+ if (fDelegate == null) {
+ return 0;
+ }
+ return fDelegate.getOptionsEnablingExhaustiveSearch();
+ }
+
+ @Override
public String getIdentifier() {
- return IDENTIFIER;
- }
-
- public int getExhaustiveSearchScope() {
- return (fSelectedOptions & CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH) != 0 ?
- fExhaustiveSearchScope : TextSearchWrapper.SCOPE_FILE;
- }
-
- public void setExhaustiveSearchScope(int scope) {
- fExhaustiveSearchScope = scope;
- }
-
- public int getSelectedOptions() {
- return fSelectedOptions;
- }
-
- public void setSelectedOptions(int selectedOptions) {
- fSelectedOptions = selectedOptions;
- }
-
- public boolean isPreviewRequired() {
- return (fSelectedOptions & getOptionsForcingPreview()) != 0;
- }
-
- public String getWorkingSetName() {
- return fWorkingSetName;
- }
-
- /**
- * Sets the name of the working set. If the name of the working set is invalid,
- * it's set to an empty string.
- */
- public void setWorkingSetName(String workingSet) {
- fWorkingSetName = checkWorkingSet(workingSet);
- }
-
- public String getReplacementText() {
- return fReplacementText;
- }
-
- public void setReplacementText(String replacementText) {
- fReplacementText = replacementText;
- }
-
- public CRefactory getManager() {
- return fManager;
- }
-
- public ASTManager getAstManager() {
- return fAstManager;
- }
+ return IDENTIFIER;
+ }
+
+ public int getExhaustiveSearchScope() {
+ return (fSelectedOptions & CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH) != 0 ? fExhaustiveSearchScope
+ : TextSearchWrapper.SCOPE_FILE;
+ }
+
+ public void setExhaustiveSearchScope(int scope) {
+ fExhaustiveSearchScope = scope;
+ }
+
+ public int getSelectedOptions() {
+ return fSelectedOptions;
+ }
+
+ public void setSelectedOptions(int selectedOptions) {
+ fSelectedOptions = selectedOptions;
+ }
+
+ public boolean isPreviewRequired() {
+ return (fSelectedOptions & getOptionsForcingPreview()) != 0;
+ }
+
+ public String getWorkingSetName() {
+ return fWorkingSetName;
+ }
+
+ /**
+ * Sets the name of the working set. If the name of the working set is invalid,
+ * it's set to an empty string.
+ */
+ public void setWorkingSetName(String workingSet) {
+ fWorkingSetName = checkWorkingSet(workingSet);
+ }
+
+ public String getReplacementText() {
+ return fReplacementText;
+ }
+
+ public void setReplacementText(String replacementText) {
+ fReplacementText = replacementText;
+ }
+
+ public CRefactory getManager() {
+ return fManager;
+ }
+
+ public ASTManager getAstManager() {
+ return fAstManager;
+ }
public void lockIndex() throws CoreException, InterruptedException {
if (fIndexLockCount == 0) {
if (fIndex == null) {
- ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
- fIndex = CCorePlugin.getIndexManager().getIndex(projects,
- IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
+ ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
+ fIndex = CCorePlugin.getIndexManager().getIndex(projects, IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
}
fIndex.acquireReadLock();
}
fIndexLockCount++;
}
-
+
public void unlockIndex() {
if (--fIndexLockCount <= 0) {
if (fAstManager != null) {
@@ -334,7 +326,7 @@ public class CRenameProcessor extends RenameProcessor {
if (fIndex != null) {
fIndex.releaseReadLock();
}
- fIndex= null;
+ fIndex = null;
}
}
@@ -349,13 +341,13 @@ public class CRenameProcessor extends RenameProcessor {
return fDelegate.getSaveMode();
}
- private String checkWorkingSet(String workingSet) {
+ private String checkWorkingSet(String workingSet) {
if (workingSet != null && workingSet.length() > 0) {
- IWorkingSetManager wsManager= PlatformUI.getWorkbench().getWorkingSetManager();
- if (wsManager.getWorkingSet(workingSet) != null) {
- return workingSet;
- }
+ IWorkingSetManager wsManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ if (wsManager.getWorkingSet(workingSet) != null) {
+ return workingSet;
+ }
}
- return ""; //$NON-NLS-1$
- }
+ return ""; //$NON-NLS-1$
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java
index 0f13c4c1bc0..d5f33ffe64a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java
@@ -1,18 +1,18 @@
/*******************************************************************************
* Copyright (c) 2004, 2015 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
* IBM Corporation - Bug 112366
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.util.ArrayList;
@@ -57,149 +57,142 @@ import org.eclipse.cdt.ui.refactoring.CTextFileChange;
* Abstract base for all different rename processors used by the top processor.
*/
public abstract class CRenameProcessorDelegate {
- private CRenameProcessor fTopProcessor;
- private ArrayList<CRefactoringMatch> fMatches;
+ private CRenameProcessor fTopProcessor;
+ private ArrayList<CRefactoringMatch> fMatches;
private final RenameModifications fRenameModifications = new RenameModifications();
- protected String fProcessorBaseName;
- private int fAvailableOptions=
- CRefactory.OPTION_IN_CODE_REFERENCES |
- CRefactory.OPTION_IN_COMMENT |
- CRefactory.OPTION_IN_MACRO_DEFINITION |
- CRefactory.OPTION_IN_STRING_LITERAL |
- CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH;
-
- private int fOptionsForcingPreview=
- CRefactory.OPTION_IN_COMMENT |
- CRefactory.OPTION_IN_MACRO_DEFINITION |
- CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE |
- CRefactory.OPTION_IN_STRING_LITERAL;
-
- private int fOptionsEnablingExhaustiveSearch= fOptionsForcingPreview |
- CRefactory.OPTION_IN_INACTIVE_CODE | CRefactory.OPTION_IN_CODE_REFERENCES;
-
- protected CRenameProcessorDelegate(CRenameProcessor topProcessor, String name) {
- fTopProcessor= topProcessor;
- fProcessorBaseName= name;
- }
-
- final public CRefactoringArgument getArgument() {
- return fTopProcessor.getArgument();
- }
-
- final public String getReplacementText() {
- return fTopProcessor.getReplacementText();
- }
-
- final public int getSelectedScope() {
- return fTopProcessor.getExhaustiveSearchScope();
- }
-
- final public int getSelectedOptions() {
- return fTopProcessor.getSelectedOptions() & fAvailableOptions;
- }
-
- final public String getSelectedWorkingSet() {
- return fTopProcessor.getWorkingSetName();
- }
-
- final public CRefactory getManager() {
- return fTopProcessor.getManager();
- }
-
- final public ASTManager getAstManager() {
- return fTopProcessor.getAstManager();
- }
-
- final public IIndex getIndex() {
- return fTopProcessor.getIndex();
- }
-
- final public String getProcessorName() {
- String identifier= getArgument().getName();
- if (identifier != null) {
- return NLS.bind(RenameMessages.CRenameProcessorDelegate_wizard_title, fProcessorBaseName,
- identifier);
- }
- return null;
- }
-
- /**
- * The options presented by the page in the refactoring wizard.
- */
- public void setAvailableOptions(int options) {
- fAvailableOptions= options;
- }
-
- final int getAvailableOptions() {
- return fAvailableOptions;
- }
-
- /**
- * The options each of which forces the preview, when selected.
- */
- public void setOptionsForcingPreview(int options) {
- fOptionsForcingPreview= options;
- }
-
- final int getOptionsForcingPreview() {
- return fOptionsForcingPreview;
- }
-
- /**
- * Sets the options that enable exhaustive file search.
- * @see #getOptionsEnablingExhaustiveSearch()
- */
- void setOptionsEnablingExhaustiveSearch(int options) {
- fOptionsEnablingExhaustiveSearch= options;
- }
-
- /**
- * The options that may need exhaustive file search since index lookup is not guaranteed to
- * return all files participating in refactoring. When one of these options is selected,
- * the exhaustive file search is enabled.
- */
- final int getOptionsEnablingExhaustiveSearch() {
- return fOptionsEnablingExhaustiveSearch;
- }
-
- protected int getSearchScope() {
- return getSelectedScope();
- }
-
- /**
- * Builds an index-based file filter for the name search.
- *
- * @param bindings bindings being renamed
- * @return A set of files containing references to the bindings.
- */
- private Collection<IFile> getReferringFiles(IBinding[] bindings) {
+ protected String fProcessorBaseName;
+ private int fAvailableOptions = CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_COMMENT
+ | CRefactory.OPTION_IN_MACRO_DEFINITION | CRefactory.OPTION_IN_STRING_LITERAL
+ | CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH;
+
+ private int fOptionsForcingPreview = CRefactory.OPTION_IN_COMMENT | CRefactory.OPTION_IN_MACRO_DEFINITION
+ | CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE | CRefactory.OPTION_IN_STRING_LITERAL;
+
+ private int fOptionsEnablingExhaustiveSearch = fOptionsForcingPreview | CRefactory.OPTION_IN_INACTIVE_CODE
+ | CRefactory.OPTION_IN_CODE_REFERENCES;
+
+ protected CRenameProcessorDelegate(CRenameProcessor topProcessor, String name) {
+ fTopProcessor = topProcessor;
+ fProcessorBaseName = name;
+ }
+
+ final public CRefactoringArgument getArgument() {
+ return fTopProcessor.getArgument();
+ }
+
+ final public String getReplacementText() {
+ return fTopProcessor.getReplacementText();
+ }
+
+ final public int getSelectedScope() {
+ return fTopProcessor.getExhaustiveSearchScope();
+ }
+
+ final public int getSelectedOptions() {
+ return fTopProcessor.getSelectedOptions() & fAvailableOptions;
+ }
+
+ final public String getSelectedWorkingSet() {
+ return fTopProcessor.getWorkingSetName();
+ }
+
+ final public CRefactory getManager() {
+ return fTopProcessor.getManager();
+ }
+
+ final public ASTManager getAstManager() {
+ return fTopProcessor.getAstManager();
+ }
+
+ final public IIndex getIndex() {
+ return fTopProcessor.getIndex();
+ }
+
+ final public String getProcessorName() {
+ String identifier = getArgument().getName();
+ if (identifier != null) {
+ return NLS.bind(RenameMessages.CRenameProcessorDelegate_wizard_title, fProcessorBaseName, identifier);
+ }
+ return null;
+ }
+
+ /**
+ * The options presented by the page in the refactoring wizard.
+ */
+ public void setAvailableOptions(int options) {
+ fAvailableOptions = options;
+ }
+
+ final int getAvailableOptions() {
+ return fAvailableOptions;
+ }
+
+ /**
+ * The options each of which forces the preview, when selected.
+ */
+ public void setOptionsForcingPreview(int options) {
+ fOptionsForcingPreview = options;
+ }
+
+ final int getOptionsForcingPreview() {
+ return fOptionsForcingPreview;
+ }
+
+ /**
+ * Sets the options that enable exhaustive file search.
+ * @see #getOptionsEnablingExhaustiveSearch()
+ */
+ void setOptionsEnablingExhaustiveSearch(int options) {
+ fOptionsEnablingExhaustiveSearch = options;
+ }
+
+ /**
+ * The options that may need exhaustive file search since index lookup is not guaranteed to
+ * return all files participating in refactoring. When one of these options is selected,
+ * the exhaustive file search is enabled.
+ */
+ final int getOptionsEnablingExhaustiveSearch() {
+ return fOptionsEnablingExhaustiveSearch;
+ }
+
+ protected int getSearchScope() {
+ return getSelectedScope();
+ }
+
+ /**
+ * Builds an index-based file filter for the name search.
+ *
+ * @param bindings bindings being renamed
+ * @return A set of files containing references to the bindings.
+ */
+ private Collection<IFile> getReferringFiles(IBinding[] bindings) {
ArrayList<IFile> files = new ArrayList<>();
- IIndex index = getIndex();
- if (index == null) {
- return files;
- }
+ IIndex index = getIndex();
+ if (index == null) {
+ return files;
+ }
Set<IIndexFileLocation> locations = new HashSet<>();
- try {
- index.acquireReadLock();
- for (IBinding binding : bindings) {
+ try {
+ index.acquireReadLock();
+ for (IBinding binding : bindings) {
IIndexName[] names = index.findNames(binding,
IIndex.FIND_ALL_OCCURRENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
for (IIndexName name : names) {
locations.add(name.getFile().getLocation());
}
- }
+ }
} catch (CoreException | InterruptedException e) {
return files;
} finally {
- index.releaseReadLock();
- }
+ index.releaseReadLock();
+ }
- files.ensureCapacity(locations.size());
+ files.ensureCapacity(locations.size());
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
for (IIndexFileLocation location : locations) {
- String fullPath= location.getFullPath();
+ String fullPath = location.getFullPath();
if (fullPath != null) {
- IResource file= workspaceRoot.findMember(fullPath);
+ IResource file = workspaceRoot.findMember(fullPath);
if (file instanceof IFile) {
files.add((IFile) file);
}
@@ -209,192 +202,195 @@ public abstract class CRenameProcessorDelegate {
return files;
}
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
- return new RefactoringStatus();
- }
-
- public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context)
- throws CoreException, OperationCanceledException {
- RefactoringStatus result= new RefactoringStatus();
- monitor.beginTask(RenameMessages.CRenameProcessorDelegate_task_checkFinalCondition, 2);
- IFile file= getArgument().getSourceFile();
- //assert file != null;
-
- IBinding[] renameBindings= getBindingsToBeRenamed(result);
-
- // Perform text search.
- fMatches= new ArrayList<>();
- TextSearchWrapper txtSearch= getManager().getTextSearch();
- Collection<IFile> filesToSearch = getReferringFiles(renameBindings);
- if (!filesToSearch.contains(file)) {
- filesToSearch.add(file);
- }
- IStatus stat= txtSearch.searchWord(filesToSearch.toArray(new IFile[filesToSearch.size()]),
- getSearchScope(), file, getSelectedWorkingSet(), getManager().getCCppPatterns(),
- getArgument().getName(), new SubProgressMonitor(monitor, 1), fMatches);
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- result.merge(RefactoringStatus.create(stat));
- if (result.hasFatalError()) {
- return result;
- }
- selectMatchesByLocation(fMatches);
- analyzeTextMatches(renameBindings, fMatches, new SubProgressMonitor(monitor, 1), result);
- if (result.hasFatalError()) {
- return result;
- }
-
- HashSet<IFile> fileset= new HashSet<>();
- int potentialMatchCount= 0;
- int commentCount= 0;
- for (Iterator<CRefactoringMatch> iter = fMatches.iterator(); iter.hasNext();) {
- CRefactoringMatch tm = iter.next();
- if (tm.isInComment()) {
- commentCount++;
- fileset.add(tm.getFile());
- } else {
- switch (tm.getAstInformation()) {
- case CRefactoringMatch.AST_REFERENCE_OTHER:
- iter.remove();
- break;
- case CRefactoringMatch.POTENTIAL:
- potentialMatchCount++;
- fileset.add(tm.getFile());
- break;
- default:
- fileset.add(tm.getFile());
- break;
- }
- }
- }
- if (potentialMatchCount != 0) {
- String msg= null;
- if (potentialMatchCount == 1) {
- msg= RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_singular;
- } else {
- msg= NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_plural,
- potentialMatchCount);
- }
- result.addWarning(msg);
- }
- if (commentCount != 0) {
- String msg= null;
- if (commentCount == 1) {
- msg= RenameMessages.CRenameProcessorDelegate_warning_commentMatch_singular;
- } else {
- msg= NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_commentMatch_plural,
- commentCount);
- }
- result.addWarning(msg);
- }
- if (context != null) {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context)
+ throws CoreException, OperationCanceledException {
+ RefactoringStatus result = new RefactoringStatus();
+ monitor.beginTask(RenameMessages.CRenameProcessorDelegate_task_checkFinalCondition, 2);
+ IFile file = getArgument().getSourceFile();
+ //assert file != null;
+
+ IBinding[] renameBindings = getBindingsToBeRenamed(result);
+
+ // Perform text search.
+ fMatches = new ArrayList<>();
+ TextSearchWrapper txtSearch = getManager().getTextSearch();
+ Collection<IFile> filesToSearch = getReferringFiles(renameBindings);
+ if (!filesToSearch.contains(file)) {
+ filesToSearch.add(file);
+ }
+ IStatus stat = txtSearch.searchWord(filesToSearch.toArray(new IFile[filesToSearch.size()]), getSearchScope(),
+ file, getSelectedWorkingSet(), getManager().getCCppPatterns(), getArgument().getName(),
+ new SubProgressMonitor(monitor, 1), fMatches);
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ result.merge(RefactoringStatus.create(stat));
+ if (result.hasFatalError()) {
+ return result;
+ }
+ selectMatchesByLocation(fMatches);
+ analyzeTextMatches(renameBindings, fMatches, new SubProgressMonitor(monitor, 1), result);
+ if (result.hasFatalError()) {
+ return result;
+ }
+
+ HashSet<IFile> fileset = new HashSet<>();
+ int potentialMatchCount = 0;
+ int commentCount = 0;
+ for (Iterator<CRefactoringMatch> iter = fMatches.iterator(); iter.hasNext();) {
+ CRefactoringMatch tm = iter.next();
+ if (tm.isInComment()) {
+ commentCount++;
+ fileset.add(tm.getFile());
+ } else {
+ switch (tm.getAstInformation()) {
+ case CRefactoringMatch.AST_REFERENCE_OTHER:
+ iter.remove();
+ break;
+ case CRefactoringMatch.POTENTIAL:
+ potentialMatchCount++;
+ fileset.add(tm.getFile());
+ break;
+ default:
+ fileset.add(tm.getFile());
+ break;
+ }
+ }
+ }
+ if (potentialMatchCount != 0) {
+ String msg = null;
+ if (potentialMatchCount == 1) {
+ msg = RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_singular;
+ } else {
+ msg = NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_plural,
+ potentialMatchCount);
+ }
+ result.addWarning(msg);
+ }
+ if (commentCount != 0) {
+ String msg = null;
+ if (commentCount == 1) {
+ msg = RenameMessages.CRenameProcessorDelegate_warning_commentMatch_singular;
+ } else {
+ msg = NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_commentMatch_plural, commentCount);
+ }
+ result.addWarning(msg);
+ }
+ if (context != null) {
ResourceChangeChecker checker = context.getChecker(ResourceChangeChecker.class);
IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
- ValidateEditChecker editChecker = context.getChecker(ValidateEditChecker.class);
+ ValidateEditChecker editChecker = context.getChecker(ValidateEditChecker.class);
for (IFile changedFile : fileset) {
deltaFactory.change(changedFile);
editChecker.addFile(changedFile);
}
- fRenameModifications.buildDelta(deltaFactory);
- fRenameModifications.buildValidateEdits(editChecker);
- }
- monitor.done();
- return result;
- }
+ fRenameModifications.buildDelta(deltaFactory);
+ fRenameModifications.buildValidateEdits(editChecker);
+ }
+ monitor.done();
+ return result;
+ }
protected void analyzeTextMatches(IBinding[] renameBindings, Collection<CRefactoringMatch> matches,
IProgressMonitor monitor, RefactoringStatus status) {
- if (renameBindings.length > 0 && getArgument().getArgumentKind() != CRefactory.ARGUMENT_UNKNOWN) {
- ASTManager mngr= getAstManager();
- mngr.setValidBindings(renameBindings);
- mngr.setRenameTo(getReplacementText());
- mngr.analyzeTextMatches(fTopProcessor.getIndex(), matches, monitor, status);
- }
- }
-
- private void selectMatchesByLocation(Collection<CRefactoringMatch> matches) {
- int acceptTextLocation= getAcceptedLocations(getSelectedOptions());
- for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
- CRefactoringMatch match = iter.next();
- int location= match.getLocation();
- if (location != 0 && (location & acceptTextLocation) == 0) {
- iter.remove();
- }
- }
- }
-
- protected int getAcceptedLocations(int selectedOptions) {
- return selectedOptions;
- }
-
- public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
- if (fMatches.isEmpty()) {
- return null;
- }
- Collections.sort(fMatches, new Comparator<CRefactoringMatch>() {
- @Override
+ if (renameBindings.length > 0 && getArgument().getArgumentKind() != CRefactory.ARGUMENT_UNKNOWN) {
+ ASTManager mngr = getAstManager();
+ mngr.setValidBindings(renameBindings);
+ mngr.setRenameTo(getReplacementText());
+ mngr.analyzeTextMatches(fTopProcessor.getIndex(), matches, monitor, status);
+ }
+ }
+
+ private void selectMatchesByLocation(Collection<CRefactoringMatch> matches) {
+ int acceptTextLocation = getAcceptedLocations(getSelectedOptions());
+ for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
+ CRefactoringMatch match = iter.next();
+ int location = match.getLocation();
+ if (location != 0 && (location & acceptTextLocation) == 0) {
+ iter.remove();
+ }
+ }
+ }
+
+ protected int getAcceptedLocations(int selectedOptions) {
+ return selectedOptions;
+ }
+
+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ if (fMatches.isEmpty()) {
+ return null;
+ }
+ Collections.sort(fMatches, new Comparator<CRefactoringMatch>() {
+ @Override
public int compare(CRefactoringMatch m1, CRefactoringMatch m2) {
- IFile f1= m1.getFile();
- IFile f2= m2.getFile();
- int cmp= f1.getName().compareTo(f2.getName());
- if (cmp != 0) return cmp;
-
- cmp= f1.getFullPath().toString().compareTo(f2.getFullPath().toString());
- if (cmp != 0) return cmp;
-
- return m1.getOffset() - m2.getOffset();
- }});
- pm.beginTask(RenameMessages.CRenameProcessorDelegate_task_createChange, fMatches.size());
- final String identifier= getArgument().getName();
- final String replacement= getReplacementText();
- CompositeChange overallChange= new CompositeChange(getProcessorName());
- IFile file= null;
- TextFileChange fileChange= null;
- MultiTextEdit fileEdit= null;
- for (CRefactoringMatch match : fMatches) {
- switch (match.getAstInformation()) {
- case CRefactoringMatch.AST_REFERENCE_OTHER:
- continue;
- case CRefactoringMatch.IN_COMMENT:
- case CRefactoringMatch.POTENTIAL:
- break;
- case CRefactoringMatch.AST_REFERENCE:
- break;
- }
- if (match.getAstInformation() != CRefactoringMatch.AST_REFERENCE_OTHER) {
- IFile mfile= match.getFile();
- if (file == null || !file.equals(mfile) || fileEdit == null || fileChange == null) {
- file= mfile;
- fileEdit= new MultiTextEdit();
- fileChange = new CTextFileChange(file.getName(), file);
- fileChange.setEdit(fileEdit);
- overallChange.add(fileChange);
- }
-
- ReplaceEdit replaceEdit= new ReplaceEdit(match.getOffset(), identifier.length(), replacement);
- fileEdit.addChild(replaceEdit);
- TextEditGroup editGroup= new TextEditGroup(match.getLabel(), replaceEdit);
- TextEditChangeGroup changeGroup= new TextEditChangeGroup(fileChange, editGroup);
- fileChange.addTextEditChangeGroup(changeGroup);
- }
- pm.worked(1);
- }
- return overallChange;
- }
+ IFile f1 = m1.getFile();
+ IFile f2 = m2.getFile();
+ int cmp = f1.getName().compareTo(f2.getName());
+ if (cmp != 0)
+ return cmp;
+
+ cmp = f1.getFullPath().toString().compareTo(f2.getFullPath().toString());
+ if (cmp != 0)
+ return cmp;
+
+ return m1.getOffset() - m2.getOffset();
+ }
+ });
+ pm.beginTask(RenameMessages.CRenameProcessorDelegate_task_createChange, fMatches.size());
+ final String identifier = getArgument().getName();
+ final String replacement = getReplacementText();
+ CompositeChange overallChange = new CompositeChange(getProcessorName());
+ IFile file = null;
+ TextFileChange fileChange = null;
+ MultiTextEdit fileEdit = null;
+ for (CRefactoringMatch match : fMatches) {
+ switch (match.getAstInformation()) {
+ case CRefactoringMatch.AST_REFERENCE_OTHER:
+ continue;
+ case CRefactoringMatch.IN_COMMENT:
+ case CRefactoringMatch.POTENTIAL:
+ break;
+ case CRefactoringMatch.AST_REFERENCE:
+ break;
+ }
+ if (match.getAstInformation() != CRefactoringMatch.AST_REFERENCE_OTHER) {
+ IFile mfile = match.getFile();
+ if (file == null || !file.equals(mfile) || fileEdit == null || fileChange == null) {
+ file = mfile;
+ fileEdit = new MultiTextEdit();
+ fileChange = new CTextFileChange(file.getName(), file);
+ fileChange.setEdit(fileEdit);
+ overallChange.add(fileChange);
+ }
+
+ ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(), identifier.length(), replacement);
+ fileEdit.addChild(replaceEdit);
+ TextEditGroup editGroup = new TextEditGroup(match.getLabel(), replaceEdit);
+ TextEditChangeGroup changeGroup = new TextEditChangeGroup(fileChange, editGroup);
+ fileChange.addTextEditChangeGroup(changeGroup);
+ }
+ pm.worked(1);
+ }
+ return overallChange;
+ }
/**
- * Returns the array of bindings that must be renamed.
- */
- protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) {
- IBinding binding = getArgument().getBinding();
- recordRename(binding);
+ * Returns the array of bindings that must be renamed.
+ */
+ protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) {
+ IBinding binding = getArgument().getBinding();
+ recordRename(binding);
return new IBinding[] { binding };
- }
+ }
- /**
- * Returns the modifications associated with the refactoring.
- */
+ /**
+ * Returns the modifications associated with the refactoring.
+ */
public RenameModifications getRenameModifications() {
return fRenameModifications;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoring.java
index 0488a01949d..67ec9021bb2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoring.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
- * Sergey Prigogin (Google)
- ******************************************************************************/
+ * Sergey Prigogin (Google)
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.core.runtime.CoreException;
@@ -27,25 +27,25 @@ public class CRenameRefactoring extends ProcessorBasedRefactoring {
public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.rename.CRenameRefactoring"; //$NON-NLS-1$
private Change fChange;
- public CRenameRefactoring(CRenameProcessor processor) {
- super(processor);
- }
+ public CRenameRefactoring(CRenameProcessor processor) {
+ super(processor);
+ }
@Override
public CRenameProcessor getProcessor() {
return (CRenameProcessor) super.getProcessor();
}
- @Override
+ @Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
- fChange = super.createChange(pm);
- return fChange;
- }
+ fChange = super.createChange(pm);
+ return fChange;
+ }
- /**
- * Returns the change if it has been created, or {@code null} otherwise.
- */
+ /**
+ * Returns the change if it has been created, or {@code null} otherwise.
+ */
Change getChange() {
- return fChange;
- }
+ return fChange;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java
index 8d7eef33c89..3ab8908dd2d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java
@@ -1,18 +1,18 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
* Emanuel Graf (Institute for Software, HSR Hochschule fuer Technik)
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.jface.dialogs.Dialog;
@@ -43,461 +43,460 @@ import org.eclipse.cdt.core.CConventions;
*/
public class CRenameRefactoringInputPage extends UserInputWizardPage {
public static final String PAGE_NAME = "RenameRefactoringPage"; //$NON-NLS-1$
-
+
final CRenameRefactoringPreferences fPreferences;
private String fSearchString;
- private int fOptions;
- private int fForcePreviewOptions= 0;
- private int fExhaustiveSearchEnablingOptions;
+ private int fOptions;
+ private int fForcePreviewOptions = 0;
+ private int fExhaustiveSearchEnablingOptions;
- private Text fNewName;
+ private Text fNewName;
private Button fDoVirtual;
- private Button fWorkspace;
- private Button fDependent;
- private Button fInComment;
- private Button fInString;
- private Button fInInclude;
- private Button fInInactiveCode;
- private Button fReferences;
- private Button fSingle;
- private Button fWorkingSet;
- private Text fWorkingSetSpec;
- private Button fWorkingSetButton;
- private Button fInMacro;
- private Button fInPreprocessor;
- private Button fExhausiveFileSearch;
-
- public CRenameRefactoringInputPage() {
- super(PAGE_NAME);
- fPreferences = new CRenameRefactoringPreferences();
- }
-
- private boolean hasOption(int options) {
- return (fOptions & options) == options;
- }
-
- @Override
+ private Button fWorkspace;
+ private Button fDependent;
+ private Button fInComment;
+ private Button fInString;
+ private Button fInInclude;
+ private Button fInInactiveCode;
+ private Button fReferences;
+ private Button fSingle;
+ private Button fWorkingSet;
+ private Text fWorkingSetSpec;
+ private Button fWorkingSetButton;
+ private Button fInMacro;
+ private Button fInPreprocessor;
+ private Button fExhausiveFileSearch;
+
+ public CRenameRefactoringInputPage() {
+ super(PAGE_NAME);
+ fPreferences = new CRenameRefactoringPreferences();
+ }
+
+ private boolean hasOption(int options) {
+ return (fOptions & options) == options;
+ }
+
+ @Override
public void createControl(Composite parent) {
- CRenameProcessor processor= getRenameProcessor();
- fSearchString= processor.getArgument().getName();
- fOptions= processor.getAvailableOptions();
- fForcePreviewOptions= processor.getOptionsForcingPreview();
- fExhaustiveSearchEnablingOptions= processor.getOptionsEnablingExhaustiveSearch();
-
- Composite top= new Composite(parent, SWT.NONE);
- initializeDialogUnits(top);
- setControl(top);
-
- top.setLayout(new GridLayout(2, false));
-
- // New name
- Composite group= top;
- GridData gd;
- GridLayout gl;
-
- Label label= new Label(top, SWT.NONE);
- label.setText(RenameMessages.CRenameRefactoringInputPage_label_newName);
- fNewName= new Text(top, SWT.BORDER);
- String name = processor.getReplacementText();
- if (name == null) {
- name = fSearchString;
- }
+ CRenameProcessor processor = getRenameProcessor();
+ fSearchString = processor.getArgument().getName();
+ fOptions = processor.getAvailableOptions();
+ fForcePreviewOptions = processor.getOptionsForcingPreview();
+ fExhaustiveSearchEnablingOptions = processor.getOptionsEnablingExhaustiveSearch();
+
+ Composite top = new Composite(parent, SWT.NONE);
+ initializeDialogUnits(top);
+ setControl(top);
+
+ top.setLayout(new GridLayout(2, false));
+
+ // New name
+ Composite group = top;
+ GridData gd;
+ GridLayout gl;
+
+ Label label = new Label(top, SWT.NONE);
+ label.setText(RenameMessages.CRenameRefactoringInputPage_label_newName);
+ fNewName = new Text(top, SWT.BORDER);
+ String name = processor.getReplacementText();
+ if (name == null) {
+ name = fSearchString;
+ }
fNewName.setText(name);
- fNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fNewName.selectAll();
-
- if (hasOption(CRefactory.OPTION_DO_VIRTUAL)) {
- fDoVirtual= new Button(top, SWT.CHECK);
- fDoVirtual.setText(RenameMessages.CRenameRefactoringInputPage_renameBaseAndDerivedMethods);
- fDoVirtual.setLayoutData(gd= new GridData());
- gd.horizontalSpan= 2;
- }
-
- boolean skippedLine= false;
- group= null;
- if (hasOption(CRefactory.OPTION_IN_CODE_REFERENCES)) {
- group= createLabelAndGroup(group, skippedLine, top);
- fReferences= new Button(group, SWT.CHECK);
- fReferences.setText(RenameMessages.CRenameRefactoringInputPage_button_sourceCode);
- }
- if (hasOption(CRefactory.OPTION_IN_INACTIVE_CODE)) {
- group= createLabelAndGroup(group, skippedLine, top);
- fInInactiveCode= new Button(group, SWT.CHECK);
- fInInactiveCode.setText(RenameMessages.CRenameRefactoringInputPage_button_inactiveCode);
- }
- if (hasOption(CRefactory.OPTION_IN_COMMENT)) {
- group= createLabelAndGroup(group, skippedLine, top);
- fInComment= new Button(group, SWT.CHECK);
- fInComment.setText(RenameMessages.CRenameRefactoringInputPage_button_comments);
- }
- if (hasOption(CRefactory.OPTION_IN_STRING_LITERAL)) {
- group= createLabelAndGroup(group, skippedLine, top);
- fInString= new Button(group, SWT.CHECK);
- fInString.setText(RenameMessages.CRenameRefactoringInputPage_button_strings);
- }
- if (hasOption(CRefactory.OPTION_IN_MACRO_DEFINITION)) {
- group= createLabelAndGroup(group, skippedLine, top);
- fInMacro= new Button(group, SWT.CHECK);
- fInMacro.setText(RenameMessages.CRenameRefactoringInputPage_button_macroDefinitions);
- }
- if (hasOption(CRefactory.OPTION_IN_INCLUDE_DIRECTIVE)) {
- group= createLabelAndGroup(group, skippedLine, top);
- fInInclude= new Button(group, SWT.CHECK);
- fInInclude.setText(RenameMessages.CRenameRefactoringInputPage_button_includes);
- }
- if (hasOption(CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE)) {
- group= createLabelAndGroup(group, skippedLine, top);
- fInPreprocessor= new Button(group, SWT.CHECK);
- fInPreprocessor.setText(RenameMessages.CRenameRefactoringInputPage_button_preprocessor);
- }
-
- if (hasOption(CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH)) {
- skipLine(top);
- fExhausiveFileSearch= new Button(top, SWT.CHECK);
- fExhausiveFileSearch.setText(RenameMessages.CRenameRefactoringInputPage_button_exhaustiveFileSearch);
- fExhausiveFileSearch.setLayoutData(gd= new GridData());
- gd.horizontalIndent= 5;
- gd.horizontalSpan= 2;
-
- // Specify the scope.
- group= new Composite(top, SWT.NONE);
- group.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
- gd.horizontalSpan= 2;
- gd.horizontalIndent= 16;
- group.setLayout(gl= new GridLayout(4, false));
- gl.marginHeight= 0;
- gl.marginLeft = gl.marginWidth;
- gl.marginWidth = 0;
-
- fWorkspace= new Button(group, SWT.RADIO);
- fWorkspace.setText(RenameMessages.CRenameRefactoringInputPage_button_workspace);
- fWorkspace.setLayoutData(gd= new GridData());
-
- fDependent= new Button(group, SWT.RADIO);
- fDependent.setText(RenameMessages.CRenameRefactoringInputPage_button_relatedProjects);
- fDependent.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- gd.horizontalIndent= 8;
-
- fSingle= new Button(group, SWT.RADIO);
- fSingle.setText(RenameMessages.CRenameRefactoringInputPage_button_singleProject);
- fSingle.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- gd.horizontalIndent= 8;
- gd.horizontalSpan= 2;
-
- fWorkingSet= new Button(group, SWT.RADIO);
- fWorkingSet.setText(RenameMessages.CRenameRefactoringInputPage_button_workingSet);
-
- fWorkingSetSpec= new Text(group, SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY);
- fWorkingSetSpec.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
- gd.horizontalIndent= 8;
- gd.horizontalSpan= 2;
- fWorkingSetButton= new Button(group, SWT.PUSH);
- fWorkingSetButton.setText(RenameMessages.CRenameRefactoringInputPage_button_chooseWorkingSet);
- setButtonLayoutData(fWorkingSetButton);
- }
-
- Dialog.applyDialogFont(top);
- hookSelectionListeners();
- readPreferences();
- onSelectOption(); // transfers the option to the refactoring / enablement
- updatePageComplete();
- }
-
- private Composite createLabelAndGroup(Composite group, boolean skippedLine, Composite top) {
- if (group != null) {
- return group;
- }
- if (!skippedLine) {
- skipLine(top);
- }
- GridData gd;
- Label label = new Label(top, SWT.NONE);
- label.setText(RenameMessages.CRenameRefactoringInputPage_label_updateWithin);
- label.setLayoutData(gd= new GridData());
- gd.horizontalSpan= 2;
- group= new Composite(top, SWT.NONE);
- group.setLayoutData(gd= new GridData());
- gd.horizontalSpan= 2;
- group.setLayout(new GridLayout(1, true));
- return group;
- }
-
- private void skipLine(Composite top) {
- new Label(top, SWT.NONE);
- new Label(top, SWT.NONE);
- }
-
- private void hookSelectionListeners() {
- fNewName.addModifyListener(new ModifyListener() {
+ fNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fNewName.selectAll();
+
+ if (hasOption(CRefactory.OPTION_DO_VIRTUAL)) {
+ fDoVirtual = new Button(top, SWT.CHECK);
+ fDoVirtual.setText(RenameMessages.CRenameRefactoringInputPage_renameBaseAndDerivedMethods);
+ fDoVirtual.setLayoutData(gd = new GridData());
+ gd.horizontalSpan = 2;
+ }
+
+ boolean skippedLine = false;
+ group = null;
+ if (hasOption(CRefactory.OPTION_IN_CODE_REFERENCES)) {
+ group = createLabelAndGroup(group, skippedLine, top);
+ fReferences = new Button(group, SWT.CHECK);
+ fReferences.setText(RenameMessages.CRenameRefactoringInputPage_button_sourceCode);
+ }
+ if (hasOption(CRefactory.OPTION_IN_INACTIVE_CODE)) {
+ group = createLabelAndGroup(group, skippedLine, top);
+ fInInactiveCode = new Button(group, SWT.CHECK);
+ fInInactiveCode.setText(RenameMessages.CRenameRefactoringInputPage_button_inactiveCode);
+ }
+ if (hasOption(CRefactory.OPTION_IN_COMMENT)) {
+ group = createLabelAndGroup(group, skippedLine, top);
+ fInComment = new Button(group, SWT.CHECK);
+ fInComment.setText(RenameMessages.CRenameRefactoringInputPage_button_comments);
+ }
+ if (hasOption(CRefactory.OPTION_IN_STRING_LITERAL)) {
+ group = createLabelAndGroup(group, skippedLine, top);
+ fInString = new Button(group, SWT.CHECK);
+ fInString.setText(RenameMessages.CRenameRefactoringInputPage_button_strings);
+ }
+ if (hasOption(CRefactory.OPTION_IN_MACRO_DEFINITION)) {
+ group = createLabelAndGroup(group, skippedLine, top);
+ fInMacro = new Button(group, SWT.CHECK);
+ fInMacro.setText(RenameMessages.CRenameRefactoringInputPage_button_macroDefinitions);
+ }
+ if (hasOption(CRefactory.OPTION_IN_INCLUDE_DIRECTIVE)) {
+ group = createLabelAndGroup(group, skippedLine, top);
+ fInInclude = new Button(group, SWT.CHECK);
+ fInInclude.setText(RenameMessages.CRenameRefactoringInputPage_button_includes);
+ }
+ if (hasOption(CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE)) {
+ group = createLabelAndGroup(group, skippedLine, top);
+ fInPreprocessor = new Button(group, SWT.CHECK);
+ fInPreprocessor.setText(RenameMessages.CRenameRefactoringInputPage_button_preprocessor);
+ }
+
+ if (hasOption(CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH)) {
+ skipLine(top);
+ fExhausiveFileSearch = new Button(top, SWT.CHECK);
+ fExhausiveFileSearch.setText(RenameMessages.CRenameRefactoringInputPage_button_exhaustiveFileSearch);
+ fExhausiveFileSearch.setLayoutData(gd = new GridData());
+ gd.horizontalIndent = 5;
+ gd.horizontalSpan = 2;
+
+ // Specify the scope.
+ group = new Composite(top, SWT.NONE);
+ group.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
+ gd.horizontalSpan = 2;
+ gd.horizontalIndent = 16;
+ group.setLayout(gl = new GridLayout(4, false));
+ gl.marginHeight = 0;
+ gl.marginLeft = gl.marginWidth;
+ gl.marginWidth = 0;
+
+ fWorkspace = new Button(group, SWT.RADIO);
+ fWorkspace.setText(RenameMessages.CRenameRefactoringInputPage_button_workspace);
+ fWorkspace.setLayoutData(gd = new GridData());
+
+ fDependent = new Button(group, SWT.RADIO);
+ fDependent.setText(RenameMessages.CRenameRefactoringInputPage_button_relatedProjects);
+ fDependent.setLayoutData(gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ gd.horizontalIndent = 8;
+
+ fSingle = new Button(group, SWT.RADIO);
+ fSingle.setText(RenameMessages.CRenameRefactoringInputPage_button_singleProject);
+ fSingle.setLayoutData(gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ gd.horizontalIndent = 8;
+ gd.horizontalSpan = 2;
+
+ fWorkingSet = new Button(group, SWT.RADIO);
+ fWorkingSet.setText(RenameMessages.CRenameRefactoringInputPage_button_workingSet);
+
+ fWorkingSetSpec = new Text(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ fWorkingSetSpec.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
+ gd.horizontalIndent = 8;
+ gd.horizontalSpan = 2;
+ fWorkingSetButton = new Button(group, SWT.PUSH);
+ fWorkingSetButton.setText(RenameMessages.CRenameRefactoringInputPage_button_chooseWorkingSet);
+ setButtonLayoutData(fWorkingSetButton);
+ }
+
+ Dialog.applyDialogFont(top);
+ hookSelectionListeners();
+ readPreferences();
+ onSelectOption(); // transfers the option to the refactoring / enablement
+ updatePageComplete();
+ }
+
+ private Composite createLabelAndGroup(Composite group, boolean skippedLine, Composite top) {
+ if (group != null) {
+ return group;
+ }
+ if (!skippedLine) {
+ skipLine(top);
+ }
+ GridData gd;
+ Label label = new Label(top, SWT.NONE);
+ label.setText(RenameMessages.CRenameRefactoringInputPage_label_updateWithin);
+ label.setLayoutData(gd = new GridData());
+ gd.horizontalSpan = 2;
+ group = new Composite(top, SWT.NONE);
+ group.setLayoutData(gd = new GridData());
+ gd.horizontalSpan = 2;
+ group.setLayout(new GridLayout(1, true));
+ return group;
+ }
+
+ private void skipLine(Composite top) {
+ new Label(top, SWT.NONE);
+ new Label(top, SWT.NONE);
+ }
+
+ private void hookSelectionListeners() {
+ fNewName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onKeyReleaseInNameField();
}
});
- registerScopeListener(fWorkspace, TextSearchWrapper.SCOPE_WORKSPACE);
- registerScopeListener(fDependent, TextSearchWrapper.SCOPE_RELATED_PROJECTS);
- registerScopeListener(fSingle, TextSearchWrapper.SCOPE_SINGLE_PROJECT);
- registerScopeListener(fWorkingSet, TextSearchWrapper.SCOPE_WORKING_SET);
-
- if (fWorkingSetButton != null) {
- fWorkingSetButton.addSelectionListener(new SelectionAdapter() {
- @Override
+ registerScopeListener(fWorkspace, TextSearchWrapper.SCOPE_WORKSPACE);
+ registerScopeListener(fDependent, TextSearchWrapper.SCOPE_RELATED_PROJECTS);
+ registerScopeListener(fSingle, TextSearchWrapper.SCOPE_SINGLE_PROJECT);
+ registerScopeListener(fWorkingSet, TextSearchWrapper.SCOPE_WORKING_SET);
+
+ if (fWorkingSetButton != null) {
+ fWorkingSetButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- onSelectWorkingSet();
- }
- });
- }
- SelectionListener listenOption= new SelectionAdapter() {
- @Override
+ onSelectWorkingSet();
+ }
+ });
+ }
+ SelectionListener listenOption = new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- onSelectOption();
- }
- };
- registerOptionListener(fDoVirtual, listenOption);
- registerOptionListener(fReferences, listenOption);
- registerOptionListener(fInComment, listenOption);
- registerOptionListener(fInInactiveCode, listenOption);
- registerOptionListener(fInInclude, listenOption);
- registerOptionListener(fInMacro, listenOption);
- registerOptionListener(fInString, listenOption);
- registerOptionListener(fInPreprocessor, listenOption);
- registerOptionListener(fExhausiveFileSearch, listenOption);
- }
-
- private void registerScopeListener(Button button, final int scope) {
- if (button != null) {
- button.addSelectionListener(new SelectionAdapter() {
- @Override
+ onSelectOption();
+ }
+ };
+ registerOptionListener(fDoVirtual, listenOption);
+ registerOptionListener(fReferences, listenOption);
+ registerOptionListener(fInComment, listenOption);
+ registerOptionListener(fInInactiveCode, listenOption);
+ registerOptionListener(fInInclude, listenOption);
+ registerOptionListener(fInMacro, listenOption);
+ registerOptionListener(fInString, listenOption);
+ registerOptionListener(fInPreprocessor, listenOption);
+ registerOptionListener(fExhausiveFileSearch, listenOption);
+ }
+
+ private void registerScopeListener(Button button, final int scope) {
+ if (button != null) {
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- onSelectedScope(scope);
- }
- });
- }
- }
-
- private void registerOptionListener(Button button, SelectionListener listenOption) {
- if (button != null) {
- button.addSelectionListener(listenOption);
- }
- }
-
- protected void onSelectedScope(int scope) {
- getRenameProcessor().setExhaustiveSearchScope(scope);
- updateEnablement();
- }
-
- private void onSelectOption() {
- int selectedOptions= computeSelectedOptions();
- boolean forcePreview= fForcePreviewOptions == -1 ||
- (selectedOptions & fForcePreviewOptions) != 0;
- getRenameProcessor().setSelectedOptions(selectedOptions);
- getRefactoringWizard().setForcePreviewReview(forcePreview);
- updateEnablement();
- }
-
- protected void onKeyReleaseInNameField() {
- getRenameProcessor().setReplacementText(fNewName.getText());
- updatePageComplete();
- }
-
- @Override
+ onSelectedScope(scope);
+ }
+ });
+ }
+ }
+
+ private void registerOptionListener(Button button, SelectionListener listenOption) {
+ if (button != null) {
+ button.addSelectionListener(listenOption);
+ }
+ }
+
+ protected void onSelectedScope(int scope) {
+ getRenameProcessor().setExhaustiveSearchScope(scope);
+ updateEnablement();
+ }
+
+ private void onSelectOption() {
+ int selectedOptions = computeSelectedOptions();
+ boolean forcePreview = fForcePreviewOptions == -1 || (selectedOptions & fForcePreviewOptions) != 0;
+ getRenameProcessor().setSelectedOptions(selectedOptions);
+ getRefactoringWizard().setForcePreviewReview(forcePreview);
+ updateEnablement();
+ }
+
+ protected void onKeyReleaseInNameField() {
+ getRenameProcessor().setReplacementText(fNewName.getText());
+ updatePageComplete();
+ }
+
+ @Override
public void dispose() {
- storePreferences();
- super.dispose();
- }
-
- private void readPreferences() {
- CRenameProcessor processor= getRenameProcessor();
-
- if (fWorkspace != null) {
- int scope = fPreferences.getScope();
-
- switch (scope) {
- case TextSearchWrapper.SCOPE_WORKSPACE:
- fWorkspace.setSelection(true);
- break;
- case TextSearchWrapper.SCOPE_SINGLE_PROJECT:
- fSingle.setSelection(true);
- break;
- case TextSearchWrapper.SCOPE_WORKING_SET:
- fWorkingSet.setSelection(true);
- break;
- default:
- scope= TextSearchWrapper.SCOPE_RELATED_PROJECTS;
- fDependent.setSelection(true);
- break;
- }
- processor.setExhaustiveSearchScope(scope);
-
- String workingSet= fPreferences.getWorkingSet();
- processor.setWorkingSetName(workingSet); // CRenameProcessor validates the working set name.
- fWorkingSetSpec.setText(processor.getWorkingSetName());
- }
-
- if (fDoVirtual != null) {
- boolean val= !fPreferences.getBoolean(CRenameRefactoringPreferences.KEY_IGNORE_VIRTUAL);
- fDoVirtual.setSelection(val);
- }
- if (fReferences != null) {
- boolean val= !fPreferences.getBoolean(CRenameRefactoringPreferences.KEY_REFERENCES_INV);
- fReferences.setSelection(val);
- }
- initOption(fInInactiveCode, CRenameRefactoringPreferences.KEY_INACTIVE);
- initOption(fInComment, CRenameRefactoringPreferences.KEY_COMMENT);
- initOption(fInString, CRenameRefactoringPreferences.KEY_STRING);
- initOption(fInInclude, CRenameRefactoringPreferences.KEY_INCLUDE);
- initOption(fInMacro, CRenameRefactoringPreferences.KEY_MACRO_DEFINITION);
- initOption(fInPreprocessor, CRenameRefactoringPreferences.KEY_PREPROCESSOR);
- initOption(fExhausiveFileSearch, CRenameRefactoringPreferences.KEY_EXHAUSTIVE_FILE_SEARCH);
- }
-
- private int computeSelectedOptions() {
- int options= fPreferences.getOptions();
- options = updateOptions(options, fDoVirtual, CRefactory.OPTION_DO_VIRTUAL);
- options = updateOptions(options, fInInactiveCode, CRefactory.OPTION_IN_INACTIVE_CODE);
- options = updateOptions(options, fInComment, CRefactory.OPTION_IN_COMMENT);
- options = updateOptions(options, fInString, CRefactory.OPTION_IN_STRING_LITERAL);
- options = updateOptions(options, fInInclude, CRefactory.OPTION_IN_INCLUDE_DIRECTIVE);
- options = updateOptions(options, fInMacro, CRefactory.OPTION_IN_MACRO_DEFINITION);
- options = updateOptions(options, fInPreprocessor, CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE);
- options = updateOptions(options, fReferences, CRefactory.OPTION_IN_CODE_REFERENCES);
- options = updateOptions(options, fExhausiveFileSearch, CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
- return options;
- }
-
- private int updateOptions(int options, Button button, int optionMask) {
- if (button == null)
- return options;
- if (button.getSelection()) {
- return options | optionMask;
- } else {
- return options & ~optionMask;
- }
- }
-
- private void initOption(Button button, String key) {
- initOption(button, key, false);
- }
-
- private void initOption(Button button, String key, boolean defaultValue) {
- if (button != null) {
- boolean val= fPreferences.getBoolean(key, defaultValue);
- button.setSelection(val);
- }
- }
-
- private void storePreferences() {
- if (fWorkspace != null) {
- int choice= TextSearchWrapper.SCOPE_RELATED_PROJECTS;
- if (fWorkspace.getSelection()) {
- choice= TextSearchWrapper.SCOPE_WORKSPACE;
- } else if (fSingle.getSelection()) {
- choice= TextSearchWrapper.SCOPE_SINGLE_PROJECT;
- } else if (fWorkingSet.getSelection()) {
- choice= TextSearchWrapper.SCOPE_WORKING_SET;
- }
- fPreferences.put(CRenameRefactoringPreferences.KEY_SCOPE, choice);
- fPreferences.put(CRenameRefactoringPreferences.KEY_WORKING_SET_NAME, fWorkingSetSpec.getText());
- }
- if (fDoVirtual != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_IGNORE_VIRTUAL, !fDoVirtual.getSelection());
- }
- if (fReferences != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_REFERENCES_INV, !fReferences.getSelection());
- }
- if (fInComment != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_COMMENT, fInComment.getSelection());
- }
- if (fInString != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_STRING, fInString.getSelection());
- }
- if (fInInclude != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_INCLUDE, fInInclude.getSelection());
- }
- if (fInPreprocessor != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_PREPROCESSOR, fInPreprocessor.getSelection());
- }
- if (fInMacro != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_MACRO_DEFINITION, fInMacro.getSelection());
- }
- if (fInInactiveCode != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_INACTIVE, fInInactiveCode.getSelection());
- }
- if (fExhausiveFileSearch != null) {
- fPreferences.put(CRenameRefactoringPreferences.KEY_EXHAUSTIVE_FILE_SEARCH, fExhausiveFileSearch.getSelection());
- }
- }
-
- protected void onSelectWorkingSet() {
- CRenameProcessor processor= getRenameProcessor();
- String wsName= fWorkingSetSpec.getText();
- IWorkingSetManager wsManager= PlatformUI.getWorkbench().getWorkingSetManager();
- IWorkingSetSelectionDialog dlg=
- wsManager.createWorkingSetSelectionDialog(getShell(), false);
- IWorkingSet currentWorkingSet= wsManager.getWorkingSet(wsName);
+ storePreferences();
+ super.dispose();
+ }
+
+ private void readPreferences() {
+ CRenameProcessor processor = getRenameProcessor();
+
+ if (fWorkspace != null) {
+ int scope = fPreferences.getScope();
+
+ switch (scope) {
+ case TextSearchWrapper.SCOPE_WORKSPACE:
+ fWorkspace.setSelection(true);
+ break;
+ case TextSearchWrapper.SCOPE_SINGLE_PROJECT:
+ fSingle.setSelection(true);
+ break;
+ case TextSearchWrapper.SCOPE_WORKING_SET:
+ fWorkingSet.setSelection(true);
+ break;
+ default:
+ scope = TextSearchWrapper.SCOPE_RELATED_PROJECTS;
+ fDependent.setSelection(true);
+ break;
+ }
+ processor.setExhaustiveSearchScope(scope);
+
+ String workingSet = fPreferences.getWorkingSet();
+ processor.setWorkingSetName(workingSet); // CRenameProcessor validates the working set name.
+ fWorkingSetSpec.setText(processor.getWorkingSetName());
+ }
+
+ if (fDoVirtual != null) {
+ boolean val = !fPreferences.getBoolean(CRenameRefactoringPreferences.KEY_IGNORE_VIRTUAL);
+ fDoVirtual.setSelection(val);
+ }
+ if (fReferences != null) {
+ boolean val = !fPreferences.getBoolean(CRenameRefactoringPreferences.KEY_REFERENCES_INV);
+ fReferences.setSelection(val);
+ }
+ initOption(fInInactiveCode, CRenameRefactoringPreferences.KEY_INACTIVE);
+ initOption(fInComment, CRenameRefactoringPreferences.KEY_COMMENT);
+ initOption(fInString, CRenameRefactoringPreferences.KEY_STRING);
+ initOption(fInInclude, CRenameRefactoringPreferences.KEY_INCLUDE);
+ initOption(fInMacro, CRenameRefactoringPreferences.KEY_MACRO_DEFINITION);
+ initOption(fInPreprocessor, CRenameRefactoringPreferences.KEY_PREPROCESSOR);
+ initOption(fExhausiveFileSearch, CRenameRefactoringPreferences.KEY_EXHAUSTIVE_FILE_SEARCH);
+ }
+
+ private int computeSelectedOptions() {
+ int options = fPreferences.getOptions();
+ options = updateOptions(options, fDoVirtual, CRefactory.OPTION_DO_VIRTUAL);
+ options = updateOptions(options, fInInactiveCode, CRefactory.OPTION_IN_INACTIVE_CODE);
+ options = updateOptions(options, fInComment, CRefactory.OPTION_IN_COMMENT);
+ options = updateOptions(options, fInString, CRefactory.OPTION_IN_STRING_LITERAL);
+ options = updateOptions(options, fInInclude, CRefactory.OPTION_IN_INCLUDE_DIRECTIVE);
+ options = updateOptions(options, fInMacro, CRefactory.OPTION_IN_MACRO_DEFINITION);
+ options = updateOptions(options, fInPreprocessor, CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE);
+ options = updateOptions(options, fReferences, CRefactory.OPTION_IN_CODE_REFERENCES);
+ options = updateOptions(options, fExhausiveFileSearch, CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
+ return options;
+ }
+
+ private int updateOptions(int options, Button button, int optionMask) {
+ if (button == null)
+ return options;
+ if (button.getSelection()) {
+ return options | optionMask;
+ } else {
+ return options & ~optionMask;
+ }
+ }
+
+ private void initOption(Button button, String key) {
+ initOption(button, key, false);
+ }
+
+ private void initOption(Button button, String key, boolean defaultValue) {
+ if (button != null) {
+ boolean val = fPreferences.getBoolean(key, defaultValue);
+ button.setSelection(val);
+ }
+ }
+
+ private void storePreferences() {
+ if (fWorkspace != null) {
+ int choice = TextSearchWrapper.SCOPE_RELATED_PROJECTS;
+ if (fWorkspace.getSelection()) {
+ choice = TextSearchWrapper.SCOPE_WORKSPACE;
+ } else if (fSingle.getSelection()) {
+ choice = TextSearchWrapper.SCOPE_SINGLE_PROJECT;
+ } else if (fWorkingSet.getSelection()) {
+ choice = TextSearchWrapper.SCOPE_WORKING_SET;
+ }
+ fPreferences.put(CRenameRefactoringPreferences.KEY_SCOPE, choice);
+ fPreferences.put(CRenameRefactoringPreferences.KEY_WORKING_SET_NAME, fWorkingSetSpec.getText());
+ }
+ if (fDoVirtual != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_IGNORE_VIRTUAL, !fDoVirtual.getSelection());
+ }
+ if (fReferences != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_REFERENCES_INV, !fReferences.getSelection());
+ }
+ if (fInComment != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_COMMENT, fInComment.getSelection());
+ }
+ if (fInString != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_STRING, fInString.getSelection());
+ }
+ if (fInInclude != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_INCLUDE, fInInclude.getSelection());
+ }
+ if (fInPreprocessor != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_PREPROCESSOR, fInPreprocessor.getSelection());
+ }
+ if (fInMacro != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_MACRO_DEFINITION, fInMacro.getSelection());
+ }
+ if (fInInactiveCode != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_INACTIVE, fInInactiveCode.getSelection());
+ }
+ if (fExhausiveFileSearch != null) {
+ fPreferences.put(CRenameRefactoringPreferences.KEY_EXHAUSTIVE_FILE_SEARCH,
+ fExhausiveFileSearch.getSelection());
+ }
+ }
+
+ protected void onSelectWorkingSet() {
+ CRenameProcessor processor = getRenameProcessor();
+ String wsName = fWorkingSetSpec.getText();
+ IWorkingSetManager wsManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ IWorkingSetSelectionDialog dlg = wsManager.createWorkingSetSelectionDialog(getShell(), false);
+ IWorkingSet currentWorkingSet = wsManager.getWorkingSet(wsName);
if (currentWorkingSet != null) {
dlg.setSelection(new IWorkingSet[] { currentWorkingSet });
}
- IWorkingSet ws= null;
+ IWorkingSet ws = null;
if (dlg.open() == Window.OK) {
- IWorkingSet wsa[]= dlg.getSelection();
+ IWorkingSet wsa[] = dlg.getSelection();
if (wsa != null && wsa.length > 0) {
- ws= wsa[0];
+ ws = wsa[0];
}
if (ws != null) {
- fWorkspace.setSelection(false);
- fDependent.setSelection(false);
- fSingle.setSelection(false);
- fWorkingSet.setSelection(true);
- processor.setExhaustiveSearchScope(TextSearchWrapper.SCOPE_WORKING_SET);
- wsName= ws.getName();
+ fWorkspace.setSelection(false);
+ fDependent.setSelection(false);
+ fSingle.setSelection(false);
+ fWorkingSet.setSelection(true);
+ processor.setExhaustiveSearchScope(TextSearchWrapper.SCOPE_WORKING_SET);
+ wsName = ws.getName();
}
}
-
- processor.setWorkingSetName(wsName); // CRenameProcessor validates the working set name.
+
+ processor.setWorkingSetName(wsName); // CRenameProcessor validates the working set name.
fWorkingSetSpec.setText(processor.getWorkingSetName());
- updateEnablement();
- }
-
- protected void updatePageComplete() {
- String txt= fNewName.getText();
- if (txt.length() == 0 || txt.equals(fSearchString)) {
- setErrorMessage(null);
- setPageComplete(false);
- } else if (!CConventions.isValidIdentifier(txt)) {
- setErrorMessage(NLS.bind(RenameMessages.CRenameRefactoringInputPage_errorInvalidIdentifier, txt));
- setPageComplete(false);
- } else {
- setErrorMessage(null);
- setPageComplete(true);
- }
- }
-
- protected void updateEnablement() {
- if (fExhausiveFileSearch != null) {
- boolean enable= fExhaustiveSearchEnablingOptions == -1 ||
- (computeSelectedOptions() & fExhaustiveSearchEnablingOptions) != 0;
-
- fExhausiveFileSearch.setEnabled(enable);
- enable = enable && fExhausiveFileSearch.getSelection();
- if (fWorkspace != null) {
- fWorkspace.setEnabled(enable);
- fDependent.setEnabled(enable);
- fSingle.setEnabled(enable);
-
- boolean enableSpec= false;
- fWorkingSet.setEnabled(enable);
- if (enable && fWorkingSet.getSelection()) {
- enableSpec= true;
- }
- fWorkingSetSpec.setEnabled(enableSpec);
- fWorkingSetButton.setEnabled(enable);
- }
- }
- }
-
- private CRenameProcessor getRenameProcessor() {
- return ((CRenameRefactoring) getRefactoring()).getProcessor();
- }
+ updateEnablement();
+ }
+
+ protected void updatePageComplete() {
+ String txt = fNewName.getText();
+ if (txt.length() == 0 || txt.equals(fSearchString)) {
+ setErrorMessage(null);
+ setPageComplete(false);
+ } else if (!CConventions.isValidIdentifier(txt)) {
+ setErrorMessage(NLS.bind(RenameMessages.CRenameRefactoringInputPage_errorInvalidIdentifier, txt));
+ setPageComplete(false);
+ } else {
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+ }
+
+ protected void updateEnablement() {
+ if (fExhausiveFileSearch != null) {
+ boolean enable = fExhaustiveSearchEnablingOptions == -1
+ || (computeSelectedOptions() & fExhaustiveSearchEnablingOptions) != 0;
+
+ fExhausiveFileSearch.setEnabled(enable);
+ enable = enable && fExhausiveFileSearch.getSelection();
+ if (fWorkspace != null) {
+ fWorkspace.setEnabled(enable);
+ fDependent.setEnabled(enable);
+ fSingle.setEnabled(enable);
+
+ boolean enableSpec = false;
+ fWorkingSet.setEnabled(enable);
+ if (enable && fWorkingSet.getSelection()) {
+ enableSpec = true;
+ }
+ fWorkingSetSpec.setEnabled(enableSpec);
+ fWorkingSetButton.setEnabled(enable);
+ }
+ }
+ }
+
+ private CRenameProcessor getRenameProcessor() {
+ return ((CRenameRefactoring) getRefactoring()).getProcessor();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java
index fc15b9c93e9..d9baace0333 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java
@@ -20,28 +20,28 @@ import org.eclipse.cdt.ui.CUIPlugin;
public class CRenameRefactoringPreferences {
private static final String DIALOG_SETTINGS_KEY = "CRenameRefactoringInputPage"; //$NON-NLS-1$
- public static final String KEY_IGNORE_VIRTUAL = "ignoreVirtual"; //$NON-NLS-1$
- public static final String KEY_REFERENCES_INV = "references_inv"; //$NON-NLS-1$
- public static final String KEY_COMMENT = "comment"; //$NON-NLS-1$
- public static final String KEY_STRING = "string"; //$NON-NLS-1$
- public static final String KEY_INACTIVE = "inactive"; //$NON-NLS-1$
- public static final String KEY_SCOPE = "scope"; //$NON-NLS-1$
- public static final String KEY_WORKING_SET_NAME = "workingset"; //$NON-NLS-1$
+ public static final String KEY_IGNORE_VIRTUAL = "ignoreVirtual"; //$NON-NLS-1$
+ public static final String KEY_REFERENCES_INV = "references_inv"; //$NON-NLS-1$
+ public static final String KEY_COMMENT = "comment"; //$NON-NLS-1$
+ public static final String KEY_STRING = "string"; //$NON-NLS-1$
+ public static final String KEY_INACTIVE = "inactive"; //$NON-NLS-1$
+ public static final String KEY_SCOPE = "scope"; //$NON-NLS-1$
+ public static final String KEY_WORKING_SET_NAME = "workingset"; //$NON-NLS-1$
- public static final String KEY_INCLUDE = "include"; //$NON-NLS-1$
- public static final String KEY_MACRO_DEFINITION = "macroDefinition"; //$NON-NLS-1$
- public static final String KEY_PREPROCESSOR = "preprocessor"; //$NON-NLS-1$
- public static final String KEY_EXHAUSTIVE_FILE_SEARCH = "exhausiveFileSearch"; //$NON-NLS-1$
+ public static final String KEY_INCLUDE = "include"; //$NON-NLS-1$
+ public static final String KEY_MACRO_DEFINITION = "macroDefinition"; //$NON-NLS-1$
+ public static final String KEY_PREPROCESSOR = "preprocessor"; //$NON-NLS-1$
+ public static final String KEY_EXHAUSTIVE_FILE_SEARCH = "exhausiveFileSearch"; //$NON-NLS-1$
- private IDialogSettings fDialogSettings;
+ private IDialogSettings fDialogSettings;
- public CRenameRefactoringPreferences() {
+ public CRenameRefactoringPreferences() {
super();
- IDialogSettings ds= CUIPlugin.getDefault().getDialogSettings();
- fDialogSettings= ds.getSection(DIALOG_SETTINGS_KEY);
- if (fDialogSettings == null) {
- fDialogSettings= ds.addNewSection(DIALOG_SETTINGS_KEY);
- }
+ IDialogSettings ds = CUIPlugin.getDefault().getDialogSettings();
+ fDialogSettings = ds.getSection(DIALOG_SETTINGS_KEY);
+ if (fDialogSettings == null) {
+ fDialogSettings = ds.addNewSection(DIALOG_SETTINGS_KEY);
+ }
}
public boolean getBoolean(String key) {
@@ -66,11 +66,11 @@ public class CRenameRefactoringPreferences {
}
public int getScope() {
- try {
- return fDialogSettings.getInt(KEY_SCOPE);
- } catch (Exception e) {
- return TextSearchWrapper.SCOPE_RELATED_PROJECTS;
- }
+ try {
+ return fDialogSettings.getInt(KEY_SCOPE);
+ } catch (Exception e) {
+ return TextSearchWrapper.SCOPE_RELATED_PROJECTS;
+ }
}
public String getWorkingSet() {
@@ -78,25 +78,25 @@ public class CRenameRefactoringPreferences {
}
public int getOptions() {
- int options= 0;
- if (!getBoolean(KEY_IGNORE_VIRTUAL))
- options |= CRefactory.OPTION_DO_VIRTUAL;
- if (!getBoolean(KEY_REFERENCES_INV))
- options |= CRefactory.OPTION_IN_CODE_REFERENCES;
- if (getBoolean(KEY_INACTIVE))
- options |= CRefactory.OPTION_IN_INACTIVE_CODE;
- if (getBoolean(KEY_COMMENT))
- options |= CRefactory.OPTION_IN_COMMENT;
- if (getBoolean(KEY_STRING))
- options |= CRefactory.OPTION_IN_STRING_LITERAL;
- if (getBoolean(KEY_INCLUDE))
- options |= CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
- if (getBoolean(KEY_MACRO_DEFINITION))
- options |= CRefactory.OPTION_IN_MACRO_DEFINITION;
- if (getBoolean(KEY_PREPROCESSOR))
- options |= CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE;
- if (getBoolean(KEY_EXHAUSTIVE_FILE_SEARCH))
- options |= CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH;
- return options;
- }
+ int options = 0;
+ if (!getBoolean(KEY_IGNORE_VIRTUAL))
+ options |= CRefactory.OPTION_DO_VIRTUAL;
+ if (!getBoolean(KEY_REFERENCES_INV))
+ options |= CRefactory.OPTION_IN_CODE_REFERENCES;
+ if (getBoolean(KEY_INACTIVE))
+ options |= CRefactory.OPTION_IN_INACTIVE_CODE;
+ if (getBoolean(KEY_COMMENT))
+ options |= CRefactory.OPTION_IN_COMMENT;
+ if (getBoolean(KEY_STRING))
+ options |= CRefactory.OPTION_IN_STRING_LITERAL;
+ if (getBoolean(KEY_INCLUDE))
+ options |= CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
+ if (getBoolean(KEY_MACRO_DEFINITION))
+ options |= CRefactory.OPTION_IN_MACRO_DEFINITION;
+ if (getBoolean(KEY_PREPROCESSOR))
+ options |= CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE;
+ if (getBoolean(KEY_EXHAUSTIVE_FILE_SEARCH))
+ options |= CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH;
+ return options;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringWizard.java
index a9fd4e20f86..e6a5e7f693b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringWizard.java
@@ -1,16 +1,16 @@
/*******************************************************************************
* Copyright (c) 2004, 2008 Wind River Systems, Inc. and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
- ******************************************************************************/
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
@@ -20,15 +20,15 @@ import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
*/
public class CRenameRefactoringWizard extends RefactoringWizard {
- public CRenameRefactoringWizard(CRenameRefactoring r) {
- super(r, DIALOG_BASED_USER_INTERFACE);
- }
+ public CRenameRefactoringWizard(CRenameRefactoring r) {
+ super(r, DIALOG_BASED_USER_INTERFACE);
+ }
- // overrider
- @Override
+ // overrider
+ @Override
protected void addUserInputPages() {
- setDefaultPageTitle(getRefactoring().getName());
- CRenameRefactoringInputPage page= new CRenameRefactoringInputPage();
- addPage(page);
- }
+ setDefaultPageTitle(getRefactoring().getName());
+ CRenameRefactoringInputPage page = new CRenameRefactoringInputPage();
+ addPage(page);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java
index 1a357bc5cf1..996f8db425c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java
@@ -1,16 +1,16 @@
/*******************************************************************************
* Copyright (c) 2005, 2012 Wind River Systems, Inc. and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Markus Schorn - initial API and implementation
- ******************************************************************************/
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
/**
@@ -18,7 +18,7 @@ package org.eclipse.cdt.internal.ui.refactoring.rename;
*/
public class CRenameTypeProcessor extends CRenameGlobalProcessor {
- public CRenameTypeProcessor(CRenameProcessor processor, String kind) {
- super(processor, kind);
- }
+ public CRenameTypeProcessor(CRenameProcessor processor, String kind) {
+ super(processor, kind);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java
index 501df064dea..73251a594b4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java
@@ -87,7 +87,7 @@ public class HeaderFileMoveParticipant extends MoveParticipant implements IShara
final IPath destinationLocation = destination.getLocation();
if (destinationLocation.equals(movedResource.getLocation().removeLastSegments(1)))
continue;
-
+
if (movedResource instanceof IFolder) {
IFolder folder = (IFolder) movedResource;
final int prefixLength = folder.getFullPath().segmentCount() - 1;
@@ -98,7 +98,8 @@ public class HeaderFileMoveParticipant extends MoveParticipant implements IShara
return false;
if (proxy.getType() == IResource.FILE) {
IFile file = (IFile) proxy.requestResource();
- movedFiles.put(file, destination.getFile(file.getFullPath().removeFirstSegments(prefixLength)));
+ movedFiles.put(file,
+ destination.getFile(file.getFullPath().removeFirstSegments(prefixLength)));
return false;
}
return true;
@@ -111,7 +112,7 @@ public class HeaderFileMoveParticipant extends MoveParticipant implements IShara
}
HeaderFileReferenceAdjuster includeAdjuster = new HeaderFileReferenceAdjuster(movedFiles,
- Collections.<IContainer, IContainer>emptyMap(), getProcessor());
+ Collections.<IContainer, IContainer>emptyMap(), getProcessor());
change = includeAdjuster.createChange(context, pm);
} catch (CoreException e) {
return RefactoringStatus.create(e.getStatus());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileReferenceAdjuster.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileReferenceAdjuster.java
index 5e87affec67..7b8d3ccc015 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileReferenceAdjuster.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileReferenceAdjuster.java
@@ -98,8 +98,7 @@ import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeUtil;
*/
public class HeaderFileReferenceAdjuster {
private static final int PARSE_MODE = ITranslationUnit.AST_SKIP_ALL_HEADERS
- | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
- | ITranslationUnit.AST_SKIP_FUNCTION_BODIES
+ | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_FUNCTION_BODIES
| ITranslationUnit.AST_PARSE_INACTIVE_CODE;
private final Map<IFile, IFile> movedFiles;
@@ -113,17 +112,16 @@ public class HeaderFileReferenceAdjuster {
* @param movedFiles keys are files being moved or renamed, values are new, not yet existing,
* files
* @param renamedContainers keys are folders and projects being renamed, values are new,
- * not yet existing folders and projects.
+ * not yet existing folders and projects.
* @param processor the refactoring processor
*/
- public HeaderFileReferenceAdjuster(Map<IFile, IFile> movedFiles,
- Map<IContainer, IContainer> renamedContainers, RefactoringProcessor processor) {
+ public HeaderFileReferenceAdjuster(Map<IFile, IFile> movedFiles, Map<IContainer, IContainer> renamedContainers,
+ RefactoringProcessor processor) {
this.movedFiles = movedFiles;
this.movedFilesByLocation = new HashMap<>();
for (Entry<IFile, IFile> entry : movedFiles.entrySet()) {
//Construct map using normalised file paths
- this.movedFilesByLocation.put(entry.getKey().getLocation().toString(),
- entry.getValue().getLocation());
+ this.movedFilesByLocation.put(entry.getKey().getLocation().toString(), entry.getValue().getLocation());
}
this.renamedContainers = renamedContainers;
this.astManager = getASTManager(processor);
@@ -173,7 +171,7 @@ public class HeaderFileReferenceAdjuster {
progress = SubMonitor.convert(progress.newChild(9), workingCopies.length + affectedFiles.size());
List<Change> changes = new ArrayList<>();
- ValidateEditChecker checker= context.getChecker(ValidateEditChecker.class);
+ ValidateEditChecker checker = context.getChecker(ValidateEditChecker.class);
for (ITranslationUnit tu : workingCopies) {
addFileChange(tu, changes, checker, progress.newChild(1));
}
@@ -183,7 +181,7 @@ public class HeaderFileReferenceAdjuster {
ITranslationUnit tu = (ITranslationUnit) coreModel.create(file);
if (tu != null) {
if (workingCopyManager.findSharedWorkingCopy(tu) != null)
- continue; // Shared working copies have already been processed.
+ continue; // Shared working copies have already been processed.
addFileChange(tu, changes, checker, progress.newChild(1));
}
}
@@ -217,7 +215,7 @@ public class HeaderFileReferenceAdjuster {
fileChange.addEdit(edit);
}
}
- fileChange.addTextEditGroup(editGroup);
+ fileChange.addTextEditGroup(editGroup);
changes.add(fileChange);
checker.addFile(fileChange.getFile());
}
@@ -233,7 +231,7 @@ public class HeaderFileReferenceAdjuster {
if (ast == null)
return null;
return createEdit(ast, tu, progress.newChild(1));
- }
+ }
private TextEditGroup createEdit(IASTTranslationUnit ast, ITranslationUnit tu, IProgressMonitor pm)
throws CoreException, OperationCanceledException {
@@ -256,7 +254,7 @@ public class HeaderFileReferenceAdjuster {
if (include.isActive()) {
location = include.getPath();
if (location.isEmpty())
- continue; // Unresolved include.
+ continue; // Unresolved include.
if (File.separatorChar == '\\') {
// Normalize path separators on Windows.
location = new Path(location).toString();
@@ -277,16 +275,15 @@ public class HeaderFileReferenceAdjuster {
}
if (!affectedIncludes.isEmpty()) {
NodeCommentMap commentedNodeMap = ASTCommenter.getCommentedNodeMap(ast);
- IRegion includeRegion =
- IncludeUtil.getSafeIncludeReplacementRegion(contents, ast, commentedNodeMap);
-
+ IRegion includeRegion = IncludeUtil.getSafeIncludeReplacementRegion(contents, ast, commentedNodeMap);
+
IncludePreferences preferences = context.getPreferences();
-
+
if (rootEdit == null)
rootEdit = new MultiTextEdit();
-
+
context.addHeadersIncludedPreviously(existingIncludes);
-
+
if (preferences.allowReordering) {
List<StyledInclude> modifiedIncludes = new ArrayList<>();
// Put the changed includes into modifiedIncludes.
@@ -300,12 +297,12 @@ public class HeaderFileReferenceAdjuster {
modifiedIncludes.add(include);
}
}
-
+
Collections.sort(modifiedIncludes, preferences);
-
+
// Populate a list of the existing unchanged includes in the include insertion region.
- List<StyledInclude> mergedIncludes =
- IncludeUtil.getIncludesInRegion(existingIncludes, includeRegion, context);
+ List<StyledInclude> mergedIncludes = IncludeUtil.getIncludesInRegion(existingIncludes, includeRegion,
+ context);
Deque<DeleteEdit> deletes = new ArrayDeque<>();
// Create text deletes for old locations of the includes that will be changed.
int deleteOffset = -1;
@@ -343,19 +340,21 @@ public class HeaderFileReferenceAdjuster {
mergedIncludes.remove(mergedIncludes.size() - 1);
}
if (deleteOffset >= 0)
- deletes.add(new DeleteEdit(deleteOffset, includeRegion.getOffset() + includeRegion.getLength() - deleteOffset));
-
+ deletes.add(new DeleteEdit(deleteOffset,
+ includeRegion.getOffset() + includeRegion.getLength() - deleteOffset));
+
// Since the order of existing include statements may not match the include order
// preferences, we find positions for the new include statements by pushing them up
// from the bottom of the include insertion region.
for (StyledInclude include : modifiedIncludes) {
if (IncludeUtil.isContainedInRegion(include.getExistingInclude(), includeRegion)) {
int i = mergedIncludes.size();
- while (--i >= 0 && preferences.compare(include, mergedIncludes.get(i)) < 0) {}
+ while (--i >= 0 && preferences.compare(include, mergedIncludes.get(i)) < 0) {
+ }
mergedIncludes.add(i + 1, include);
}
}
-
+
int offset = includeRegion.getOffset();
StringBuilder text = new StringBuilder();
StyledInclude previousInclude = null;
@@ -389,9 +388,11 @@ public class HeaderFileReferenceAdjuster {
}
text.append(context.getLineDelimiter());
} else {
- if (previousInclude != null && affectedIncludes.containsKey(previousInclude.getExistingInclude()) &&
- isBlankLineNeededBetween(previousInclude, include, preferences) &&
- TextUtil.findBlankLine(contents, skipDeletedRegion(offset, deletes), ASTNodes.offset(existingInclude)) < 0) {
+ if (previousInclude != null
+ && affectedIncludes.containsKey(previousInclude.getExistingInclude())
+ && isBlankLineNeededBetween(previousInclude, include, preferences)
+ && TextUtil.findBlankLine(contents, skipDeletedRegion(offset, deletes),
+ ASTNodes.offset(existingInclude)) < 0) {
text.append(context.getLineDelimiter());
}
flushEditBuffer(offset, text, deletes, rootEdit);
@@ -404,11 +405,11 @@ public class HeaderFileReferenceAdjuster {
offset = includeRegion.getOffset() + includeRegion.getLength();
flushEditBuffer(offset, text, deletes, rootEdit);
}
-
+
for (IASTPreprocessorIncludeStatement existingInclude : existingIncludes) {
IPath header = affectedIncludes.get(existingInclude);
- if (header != null &&
- (!preferences.allowReordering || !IncludeUtil.isContainedInRegion(existingInclude, includeRegion))) {
+ if (header != null && (!preferences.allowReordering
+ || !IncludeUtil.isContainedInRegion(existingInclude, includeRegion))) {
IncludeGroupStyle style = context.getIncludeStyle(header);
IncludeInfo includeInfo = context.createIncludeInfo(header, style);
IASTName name = existingInclude.getName();
@@ -423,13 +424,10 @@ public class HeaderFileReferenceAdjuster {
return null;
int numEdits = rootEdit.getChildrenSize();
- String message =
- numEdits == numIncludeGuardEdits ?
- RenameMessages.HeaderReferenceAdjuster_update_include_guards :
- numIncludeGuardEdits == 0 ?
- RenameMessages.HeaderReferenceAdjuster_update_includes :
- RenameMessages.HeaderReferenceAdjuster_update_include_guards_and_includes;
- TextEditGroup editGroup= new TextEditGroup(message, rootEdit);
+ String message = numEdits == numIncludeGuardEdits ? RenameMessages.HeaderReferenceAdjuster_update_include_guards
+ : numIncludeGuardEdits == 0 ? RenameMessages.HeaderReferenceAdjuster_update_includes
+ : RenameMessages.HeaderReferenceAdjuster_update_include_guards_and_includes;
+ TextEditGroup editGroup = new TextEditGroup(message, rootEdit);
return editGroup;
}
@@ -561,9 +559,8 @@ public class HeaderFileReferenceAdjuster {
private void lockIndex() throws CoreException, OperationCanceledException {
if (indexLockCount == 0) {
if (index == null) {
- ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
- index = CCorePlugin.getIndexManager().getIndex(projects,
- IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
+ ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
+ index = CCorePlugin.getIndexManager().getIndex(projects, IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
}
try {
index.acquireReadLock();
@@ -615,8 +612,7 @@ public class HeaderFileReferenceAdjuster {
private static int getIncludeGuardScheme(IProject project) {
IPreferencesService preferences = Platform.getPreferencesService();
IScopeContext[] scopes = PreferenceConstants.getPreferenceScopes(project);
- int scheme = preferences.getInt(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME,
+ int scheme = preferences.getInt(CUIPlugin.PLUGIN_ID, PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME,
PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME, scopes);
return scheme;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java
index 893beb637af..71ffead4933 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java
@@ -80,14 +80,14 @@ public class HeaderFileRenameParticipant extends RenameParticipant implements IS
if (renamedResource.isLinked())
continue;
String newName = args.getNewName();
-
+
if (renamedResource instanceof IContainer) {
IContainer container = (IContainer) renamedResource;
final IPath oldPath = container.getFullPath();
final IPath newPath = oldPath.removeLastSegments(1).append(newName);
final IWorkspaceRoot workspaceRoot = container.getWorkspace().getRoot();
- IContainer newContainer = container.getType() == IResource.FOLDER ?
- workspaceRoot.getFolder(newPath) : workspaceRoot.getProject(newName);
+ IContainer newContainer = container.getType() == IResource.FOLDER ? workspaceRoot.getFolder(newPath)
+ : workspaceRoot.getProject(newName);
renamedContainers.put(container, newContainer);
container.accept(new IResourceProxyVisitor() {
@Override
@@ -108,8 +108,8 @@ public class HeaderFileRenameParticipant extends RenameParticipant implements IS
movedFiles.put(file, file.getParent().getFile(new Path(newName)));
}
}
- HeaderFileReferenceAdjuster includeAdjuster =
- new HeaderFileReferenceAdjuster(movedFiles, renamedContainers, getProcessor());
+ HeaderFileReferenceAdjuster includeAdjuster = new HeaderFileReferenceAdjuster(movedFiles, renamedContainers,
+ getProcessor());
change = includeAdjuster.createChange(context, pm);
} catch (CoreException e) {
return RefactoringStatus.create(e.getStatus());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java
index 970f0d7be38..507858abdaf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2015 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS)- initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -63,8 +63,8 @@ public class RenameCSourceFolderChange extends Change {
@Override
public String getName() {
- return NLS.bind(RenameMessages.RenameCSourceFolderChange_Name0,
- oldFolderPath.lastSegment(), newFolderPath.lastSegment());
+ return NLS.bind(RenameMessages.RenameCSourceFolderChange_Name0, oldFolderPath.lastSegment(),
+ newFolderPath.lastSegment());
}
@Override
@@ -74,7 +74,7 @@ public class RenameCSourceFolderChange extends Change {
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
if (oldFolder.exists()) {
- return RefactoringStatus.create(Status.OK_STATUS);
+ return RefactoringStatus.create(Status.OK_STATUS);
} else {
return RefactoringStatus.create(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
NLS.bind(RenameMessages.RenameCSourceFolderChange_ErrorMsg, oldFolder.getName())));
@@ -87,7 +87,7 @@ public class RenameCSourceFolderChange extends Change {
IFolder newFolder = project.getFolder(newFolderPath.removeFirstSegments(1));
return new RenameCSourceFolderChange(newFolder, oldFolderPath);
}
-
+
private void changeEntryInAllCfgs(ICProjectDescription des) throws WriteAccessException, CoreException {
ICConfigurationDescription cfgs[] = des.getConfigurations();
for (ICConfigurationDescription cfg : cfgs) {
@@ -97,7 +97,7 @@ public class RenameCSourceFolderChange extends Change {
}
CCorePlugin.getDefault().setProjectDescription(project, des, false, new NullProgressMonitor());
}
-
+
private ICSourceEntry[] renameSourceEntries(ICSourceEntry[] sourceEntries) {
Set<ICSourceEntry> set = new HashSet<>();
for (ICSourceEntry entry : sourceEntries) {
@@ -120,7 +120,7 @@ public class RenameCSourceFolderChange extends Change {
exclusionPatterns.add(pattern);
}
}
-
+
return new CSourceEntry(sourceEntry.getValue(),
exclusionPatterns.toArray(new IPath[exclusionPatterns.size()]), sourceEntry.getFlags());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java
index 8f037a5ef86..c54782be08d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java
@@ -91,13 +91,13 @@ import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
- private class PopupVisibilityManager implements IPartListener2, ControlListener, MouseListener,
- KeyListener, ITextListener, IViewportListener {
+ private class PopupVisibilityManager
+ implements IPartListener2, ControlListener, MouseListener, KeyListener, ITextListener, IViewportListener {
public void start() {
fEditor.getSite().getWorkbenchWindow().getPartService().addPartListener(this);
- final ISourceViewer viewer= fEditor.getViewer();
- final StyledText textWidget= viewer.getTextWidget();
+ final ISourceViewer viewer = fEditor.getViewer();
+ final StyledText textWidget = viewer.getTextWidget();
textWidget.addControlListener(this);
textWidget.addMouseListener(this);
textWidget.addKeyListener(this);
@@ -107,7 +107,8 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
fPopup.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
- fEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(PopupVisibilityManager.this);
+ fEditor.getSite().getWorkbenchWindow().getPartService()
+ .removePartListener(PopupVisibilityManager.this);
if (!textWidget.isDisposed()) {
textWidget.removeControlListener(PopupVisibilityManager.this);
textWidget.removeMouseListener(PopupVisibilityManager.this);
@@ -118,11 +119,11 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
viewer.removeViewportListener(PopupVisibilityManager.this);
if (fMenuImage != null) {
fMenuImage.dispose();
- fMenuImage= null;
+ fMenuImage = null;
}
if (fMenuManager != null) {
fMenuManager.dispose();
- fMenuManager= null;
+ fMenuManager = null;
}
fRenameLinkedMode.cancel();
}
@@ -131,7 +132,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
@Override
public void partActivated(IWorkbenchPartReference partRef) {
- IWorkbenchPart fPart= fEditor.getEditorSite().getPart();
+ IWorkbenchPart fPart = fEditor.getEditorSite().getPart();
if (partRef.getPart(false) == fPart) {
updateVisibility();
}
@@ -147,7 +148,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
- IWorkbenchPart fPart= fEditor.getEditorSite().getPart();
+ IWorkbenchPart fPart = fEditor.getEditorSite().getPart();
if (fPopup != null && !fPopup.isDisposed() && partRef.getPart(false) == fPart) {
fPopup.setVisible(false);
}
@@ -226,38 +227,38 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
*/
private static boolean MAC = Util.isMac();
- private static final int WIDGET_PRIORITY= 1000;
+ private static final int WIDGET_PRIORITY = 1000;
- private static final String DIALOG_SETTINGS_SECTION= "RenameInformationPopup"; //$NON-NLS-1$
- private static final String SNAP_POSITION_KEY= "snap_position"; //$NON-NLS-1$
+ private static final String DIALOG_SETTINGS_SECTION = "RenameInformationPopup"; //$NON-NLS-1$
+ private static final String SNAP_POSITION_KEY = "snap_position"; //$NON-NLS-1$
- private static final int SNAP_POSITION_UNDER_RIGHT_FIELD= 0;
- private static final int SNAP_POSITION_OVER_RIGHT_FIELD= 1;
- private static final int SNAP_POSITION_UNDER_LEFT_FIELD= 2;
- private static final int SNAP_POSITION_OVER_LEFT_FIELD= 3;
- private static final int SNAP_POSITION_LOWER_RIGHT= 4;
+ private static final int SNAP_POSITION_UNDER_RIGHT_FIELD = 0;
+ private static final int SNAP_POSITION_OVER_RIGHT_FIELD = 1;
+ private static final int SNAP_POSITION_UNDER_LEFT_FIELD = 2;
+ private static final int SNAP_POSITION_OVER_LEFT_FIELD = 3;
+ private static final int SNAP_POSITION_LOWER_RIGHT = 4;
- private static final int POPUP_VISIBILITY_DELAY= 300;
+ private static final int POPUP_VISIBILITY_DELAY = 300;
/**
* Offset of info hover arrow from the left or right side.
*/
- private static final int HAO= 10;
+ private static final int HAO = 10;
/**
* Width of info hover arrow.
*/
- private static final int HAW= 8;
+ private static final int HAW = 8;
/**
* Height of info hover arrow.
*/
- private static final int HAH= 10;
+ private static final int HAH = 10;
/**
* Gap between linked position and popup.
*/
- private static final int GAP= 2;
+ private static final int GAP = 2;
private final CEditor fEditor;
private final RenameLinkedMode fRenameLinkedMode;
@@ -271,26 +272,26 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
private Image fMenuImage;
private MenuManager fMenuManager;
private ToolBar fToolBar;
- private String fOpenDialogBinding= ""; //$NON-NLS-1$
- private boolean fIsMenuUp= false;
+ private String fOpenDialogBinding = ""; //$NON-NLS-1$
+ private boolean fIsMenuUp = false;
- private boolean fDelayJobFinished= false;
+ private boolean fDelayJobFinished = false;
public RenameInformationPopup(CEditor editor, RenameLinkedMode renameLinkedMode) {
- fEditor= editor;
- fRenameLinkedMode= renameLinkedMode;
+ fEditor = editor;
+ fRenameLinkedMode = renameLinkedMode;
restoreSnapPosition();
}
private void restoreSnapPosition() {
- IDialogSettings settings= getDialogSettings();
+ IDialogSettings settings = getDialogSettings();
try {
- fSnapPosition= settings.getInt(SNAP_POSITION_KEY);
+ fSnapPosition = settings.getInt(SNAP_POSITION_KEY);
} catch (NumberFormatException e) {
// default:
- fSnapPosition= SNAP_POSITION_UNDER_LEFT_FIELD;
+ fSnapPosition = SNAP_POSITION_UNDER_LEFT_FIELD;
}
- fSnapPositionChanged= true;
+ fSnapPositionChanged = true;
}
private IDialogSettings getDialogSettings() {
@@ -299,17 +300,17 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
public void open() {
// Must cache here, since editor context is not available in menu from popup shell:
- fOpenDialogBinding= getOpenDialogBinding();
+ fOpenDialogBinding = getOpenDialogBinding();
- Shell workbenchShell= fEditor.getSite().getShell();
- final Display display= workbenchShell.getDisplay();
+ Shell workbenchShell = fEditor.getSite().getShell();
+ final Display display = workbenchShell.getDisplay();
- fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
- fPopupLayout= new GridLayout(2, false);
- fPopupLayout.marginWidth= 1;
- fPopupLayout.marginHeight= 1;
- fPopupLayout.marginLeft= 4;
- fPopupLayout.horizontalSpacing= 0;
+ fPopup = new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
+ fPopupLayout = new GridLayout(2, false);
+ fPopupLayout.marginWidth = 1;
+ fPopupLayout.marginHeight = 1;
+ fPopupLayout.marginLeft = 4;
+ fPopupLayout.horizontalSpacing = 0;
fPopup.setLayout(fPopupLayout);
createContent(fPopup);
@@ -324,12 +325,12 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
if (fIsMenuUp)
return;
- final Shell editorShell= fEditor.getSite().getShell();
+ final Shell editorShell = fEditor.getSite().getShell();
display.asyncExec(new Runnable() {
// Post to UI thread since editor shell only gets activated after popup has lost focus
@Override
public void run() {
- Shell activeShell= display.getActiveShell();
+ Shell activeShell = display.getActiveShell();
if (activeShell != editorShell) {
fRenameLinkedMode.cancel();
}
@@ -347,10 +348,10 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
});
}
- UIJob delayJob= new UIJob(display, RenameMessages.RenameInformationPopup_delayJobName) {
+ UIJob delayJob = new UIJob(display, RenameMessages.RenameInformationPopup_delayJobName) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- fDelayJobFinished= true;
+ fDelayJobFinished = true;
if (fPopup != null && !fPopup.isDisposed()) {
updateVisibility();
}
@@ -367,7 +368,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
if (!fPopup.isDisposed()) {
fPopup.close();
}
- fPopup= null;
+ fPopup = null;
}
releaseWidgetToken();
if (fRegion != null) {
@@ -386,34 +387,34 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
return;
packPopup();
- Point loc= computePopupLocation(fSnapPosition);
+ Point loc = computePopupLocation(fSnapPosition);
if (loc != null && !loc.equals(fPopup.getLocation())) {
fPopup.setLocation(loc);
// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
-// fPopup.moveBelow(fEditor.getSite().getShell().getShells()[0]);
+ // fPopup.moveBelow(fEditor.getSite().getShell().getShells()[0]);
}
}
private void updateVisibility() {
if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) {
- boolean visible= false;
+ boolean visible = false;
//TODO: Check for visibility of linked position, not whether popup is outside of editor?
if (fRenameLinkedMode.isCaretInLinkedPosition()) {
- StyledText textWidget= fEditor.getViewer().getTextWidget();
- Rectangle eArea= Geometry.toDisplay(textWidget, textWidget.getClientArea());
- Rectangle pBounds= fPopup.getBounds();
+ StyledText textWidget = fEditor.getViewer().getTextWidget();
+ Rectangle eArea = Geometry.toDisplay(textWidget, textWidget.getClientArea());
+ Rectangle pBounds = fPopup.getBounds();
pBounds.x -= GAP;
pBounds.y -= GAP;
pBounds.width += 2 * GAP;
pBounds.height += 2 * GAP;
if (eArea.intersects(pBounds)) {
- visible= true;
+ visible = true;
}
}
if (visible && !fPopup.isVisible()) {
- ISourceViewer viewer= fEditor.getViewer();
+ ISourceViewer viewer = fEditor.getViewer();
if (viewer instanceof IWidgetTokenOwnerExtension) {
- IWidgetTokenOwnerExtension widgetTokenOwnerExtension= (IWidgetTokenOwnerExtension) viewer;
+ IWidgetTokenOwnerExtension widgetTokenOwnerExtension = (IWidgetTokenOwnerExtension) viewer;
widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY);
}
} else if (!visible && fPopup.isVisible()) {
@@ -424,9 +425,9 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
}
private void releaseWidgetToken() {
- ISourceViewer viewer= fEditor.getViewer();
+ ISourceViewer viewer = fEditor.getViewer();
if (viewer instanceof IWidgetTokenOwner) {
- IWidgetTokenOwner widgetTokenOwner= (IWidgetTokenOwner) viewer;
+ IWidgetTokenOwner widgetTokenOwner = (IWidgetTokenOwner) viewer;
widgetTokenOwner.releaseWidgetToken(this);
}
}
@@ -440,68 +441,66 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
return null;
switch (snapPosition) {
- case SNAP_POSITION_LOWER_RIGHT:
- {
- StyledText eWidget= fEditor.getViewer().getTextWidget();
- Rectangle eBounds= eWidget.getClientArea();
- Point eLowerRight= eWidget.toDisplay(eBounds.x + eBounds.width, eBounds.y + eBounds.height);
- Point pSize= getExtent();
- return new Point(eLowerRight.x - pSize.x - 5, eLowerRight.y - pSize.y - 5);
+ case SNAP_POSITION_LOWER_RIGHT: {
+ StyledText eWidget = fEditor.getViewer().getTextWidget();
+ Rectangle eBounds = eWidget.getClientArea();
+ Point eLowerRight = eWidget.toDisplay(eBounds.x + eBounds.width, eBounds.y + eBounds.height);
+ Point pSize = getExtent();
+ return new Point(eLowerRight.x - pSize.x - 5, eLowerRight.y - pSize.y - 5);
+ }
+
+ case SNAP_POSITION_UNDER_RIGHT_FIELD:
+ case SNAP_POSITION_OVER_RIGHT_FIELD: {
+ LinkedPosition position = fRenameLinkedMode.getCurrentLinkedPosition();
+ if (position == null)
+ return null;
+ ISourceViewer viewer = fEditor.getViewer();
+ ITextViewerExtension5 viewer5 = (ITextViewerExtension5) viewer;
+ int widgetOffset = viewer5.modelOffset2WidgetOffset(position.offset + position.length);
+
+ StyledText textWidget = viewer.getTextWidget();
+ Point pos = textWidget.getLocationAtOffset(widgetOffset);
+ Point pSize = getExtent();
+ if (snapPosition == SNAP_POSITION_OVER_RIGHT_FIELD) {
+ pos.y -= pSize.y + GAP;
+ } else {
+ pos.y += textWidget.getLineHeight(widgetOffset) + GAP;
}
-
- case SNAP_POSITION_UNDER_RIGHT_FIELD:
- case SNAP_POSITION_OVER_RIGHT_FIELD:
- {
- LinkedPosition position= fRenameLinkedMode.getCurrentLinkedPosition();
- if (position == null)
- return null;
- ISourceViewer viewer= fEditor.getViewer();
- ITextViewerExtension5 viewer5= (ITextViewerExtension5) viewer;
- int widgetOffset= viewer5.modelOffset2WidgetOffset(position.offset + position.length);
-
- StyledText textWidget= viewer.getTextWidget();
- Point pos= textWidget.getLocationAtOffset(widgetOffset);
- Point pSize= getExtent();
- if (snapPosition == SNAP_POSITION_OVER_RIGHT_FIELD) {
- pos.y-= pSize.y + GAP;
- } else {
- pos.y+= textWidget.getLineHeight(widgetOffset) + GAP;
- }
- pos.x+= GAP;
- Point dPos= textWidget.toDisplay(pos);
- Rectangle displayBounds= textWidget.getDisplay().getClientArea();
- Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize);
- Geometry.moveInside(dPopupRect, displayBounds);
- return new Point(dPopupRect.x, dPopupRect.y);
- }
-
- case SNAP_POSITION_UNDER_LEFT_FIELD:
- case SNAP_POSITION_OVER_LEFT_FIELD:
- default: // same as SNAP_POSITION_UNDER_LEFT_FIELD
- {
- LinkedPosition position= fRenameLinkedMode.getCurrentLinkedPosition();
- if (position == null)
- return null;
- ISourceViewer viewer= fEditor.getViewer();
- ITextViewerExtension5 viewer5= (ITextViewerExtension5) viewer;
- int widgetOffset= viewer5.modelOffset2WidgetOffset(position.offset/* + position.length*/);
-
- StyledText textWidget= viewer.getTextWidget();
- Point pos= textWidget.getLocationAtOffset(widgetOffset);
- Point pSize= getExtent();
- pSize.y+= HAH + 1;
- pos.x-= HAO;
- if (snapPosition == SNAP_POSITION_OVER_LEFT_FIELD) {
- pos.y-= pSize.y;
- } else {
- pos.y+= textWidget.getLineHeight(widgetOffset);
- }
- Point dPos= textWidget.toDisplay(pos);
- Rectangle displayBounds= textWidget.getDisplay().getClientArea();
- Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize);
- Geometry.moveInside(dPopupRect, displayBounds);
- return new Point(dPopupRect.x, dPopupRect.y);
+ pos.x += GAP;
+ Point dPos = textWidget.toDisplay(pos);
+ Rectangle displayBounds = textWidget.getDisplay().getClientArea();
+ Rectangle dPopupRect = Geometry.createRectangle(dPos, pSize);
+ Geometry.moveInside(dPopupRect, displayBounds);
+ return new Point(dPopupRect.x, dPopupRect.y);
+ }
+
+ case SNAP_POSITION_UNDER_LEFT_FIELD:
+ case SNAP_POSITION_OVER_LEFT_FIELD:
+ default: // same as SNAP_POSITION_UNDER_LEFT_FIELD
+ {
+ LinkedPosition position = fRenameLinkedMode.getCurrentLinkedPosition();
+ if (position == null)
+ return null;
+ ISourceViewer viewer = fEditor.getViewer();
+ ITextViewerExtension5 viewer5 = (ITextViewerExtension5) viewer;
+ int widgetOffset = viewer5.modelOffset2WidgetOffset(position.offset/* + position.length*/);
+
+ StyledText textWidget = viewer.getTextWidget();
+ Point pos = textWidget.getLocationAtOffset(widgetOffset);
+ Point pSize = getExtent();
+ pSize.y += HAH + 1;
+ pos.x -= HAO;
+ if (snapPosition == SNAP_POSITION_OVER_LEFT_FIELD) {
+ pos.y -= pSize.y;
+ } else {
+ pos.y += textWidget.getLineHeight(widgetOffset);
}
+ Point dPos = textWidget.toDisplay(pos);
+ Rectangle displayBounds = textWidget.getDisplay().getClientArea();
+ Rectangle dPopupRect = Geometry.createRectangle(dPos, pSize);
+ Geometry.moveInside(dPopupRect, displayBounds);
+ return new Point(dPopupRect.x, dPopupRect.y);
+ }
}
}
@@ -514,10 +513,10 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
return;
}
- final Point POPUP_SOURCE= popupShell.getLocation();
- final StyledText textWidget= fEditor.getViewer().getTextWidget();
- Point pSize= getExtent();
- int originalSnapPosition= fSnapPosition;
+ final Point POPUP_SOURCE = popupShell.getLocation();
+ final StyledText textWidget = fEditor.getViewer().getTextWidget();
+ Point pSize = getExtent();
+ int originalSnapPosition = fSnapPosition;
/*
* Feature in Tracker: it is not possible to directly control the feedback,
@@ -527,64 +526,58 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
* Workaround is to have an offscreen rectangle for tracking mouse movement
* and a manually updated rectangle for the actual drop target.
*/
- final Tracker tracker= new Tracker(textWidget, SWT.NONE);
+ final Tracker tracker = new Tracker(textWidget, SWT.NONE);
- final Point[] LOCATIONS= {
- textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_RIGHT_FIELD)),
+ final Point[] LOCATIONS = { textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_RIGHT_FIELD)),
textWidget.toControl(computePopupLocation(SNAP_POSITION_OVER_RIGHT_FIELD)),
textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_LEFT_FIELD)),
textWidget.toControl(computePopupLocation(SNAP_POSITION_OVER_LEFT_FIELD)),
- textWidget.toControl(computePopupLocation(SNAP_POSITION_LOWER_RIGHT))
- };
+ textWidget.toControl(computePopupLocation(SNAP_POSITION_LOWER_RIGHT)) };
- final Rectangle[] DROP_TARGETS= {
- Geometry.createRectangle(LOCATIONS[0], pSize),
- Geometry.createRectangle(LOCATIONS[1], pSize),
- new Rectangle(LOCATIONS[2].x, LOCATIONS[2].y + HAH, pSize.x, pSize.y),
- Geometry.createRectangle(LOCATIONS[3], pSize),
- Geometry.createRectangle(LOCATIONS[4], pSize)
- };
- final Rectangle MOUSE_MOVE_SOURCE= new Rectangle(1000000, 0, 0, 0);
+ final Rectangle[] DROP_TARGETS = { Geometry.createRectangle(LOCATIONS[0], pSize),
+ Geometry.createRectangle(LOCATIONS[1], pSize),
+ new Rectangle(LOCATIONS[2].x, LOCATIONS[2].y + HAH, pSize.x, pSize.y),
+ Geometry.createRectangle(LOCATIONS[3], pSize), Geometry.createRectangle(LOCATIONS[4], pSize) };
+ final Rectangle MOUSE_MOVE_SOURCE = new Rectangle(1000000, 0, 0, 0);
tracker.setRectangles(new Rectangle[] { MOUSE_MOVE_SOURCE, DROP_TARGETS[fSnapPosition] });
tracker.setStippled(true);
- ControlListener moveListener= new ControlAdapter() {
+ ControlListener moveListener = new ControlAdapter() {
/*
* @see org.eclipse.swt.events.ControlAdapter#controlMoved(org.eclipse.swt.events.ControlEvent)
*/
@Override
public void controlMoved(ControlEvent moveEvent) {
- Rectangle[] currentRects= tracker.getRectangles();
- final Rectangle mouseMoveCurrent= currentRects[0];
- Point popupLoc= new Point(
- POPUP_SOURCE.x + mouseMoveCurrent.x - MOUSE_MOVE_SOURCE.x,
+ Rectangle[] currentRects = tracker.getRectangles();
+ final Rectangle mouseMoveCurrent = currentRects[0];
+ Point popupLoc = new Point(POPUP_SOURCE.x + mouseMoveCurrent.x - MOUSE_MOVE_SOURCE.x,
POPUP_SOURCE.y + mouseMoveCurrent.y - MOUSE_MOVE_SOURCE.y);
popupShell.setLocation(popupLoc);
- Point ePopupLoc= textWidget.toControl(popupLoc);
- int minDist= Integer.MAX_VALUE;
- for (int snapPos= 0; snapPos < DROP_TARGETS.length; snapPos++) {
- int dist= Geometry.distanceSquared(ePopupLoc, LOCATIONS[snapPos]);
+ Point ePopupLoc = textWidget.toControl(popupLoc);
+ int minDist = Integer.MAX_VALUE;
+ for (int snapPos = 0; snapPos < DROP_TARGETS.length; snapPos++) {
+ int dist = Geometry.distanceSquared(ePopupLoc, LOCATIONS[snapPos]);
if (dist < minDist) {
- minDist= dist;
- fSnapPosition= snapPos;
- fSnapPositionChanged= true;
- currentRects[1]= DROP_TARGETS[snapPos];
+ minDist = dist;
+ fSnapPosition = snapPos;
+ fSnapPositionChanged = true;
+ currentRects[1] = DROP_TARGETS[snapPos];
}
}
tracker.setRectangles(currentRects);
}
};
tracker.addControlListener(moveListener);
- boolean committed= tracker.open();
+ boolean committed = tracker.open();
tracker.close();
tracker.dispose();
if (committed) {
getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition);
} else {
- fSnapPosition= originalSnapPosition;
- fSnapPositionChanged= true;
+ fSnapPosition = originalSnapPosition;
+ fSnapPositionChanged = true;
}
updatePopupLocation(true);
activateEditor();
@@ -596,23 +589,23 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
if (!fSnapPositionChanged) {
return;
}
- fSnapPositionChanged= false;
-
- boolean isUnderLeft= fSnapPosition == SNAP_POSITION_UNDER_LEFT_FIELD;
- boolean isOverLeft= fSnapPosition == SNAP_POSITION_OVER_LEFT_FIELD;
- fPopupLayout.marginTop= isUnderLeft ? HAH : 0;
- fPopupLayout.marginBottom= isOverLeft ? HAH + 1 : 0;
+ fSnapPositionChanged = false;
+
+ boolean isUnderLeft = fSnapPosition == SNAP_POSITION_UNDER_LEFT_FIELD;
+ boolean isOverLeft = fSnapPosition == SNAP_POSITION_OVER_LEFT_FIELD;
+ fPopupLayout.marginTop = isUnderLeft ? HAH : 0;
+ fPopupLayout.marginBottom = isOverLeft ? HAH + 1 : 0;
fPopup.pack();
- Region oldRegion= fRegion;
+ Region oldRegion = fRegion;
if (isUnderLeft || isOverLeft) {
- fRegion= new Region();
+ fRegion = new Region();
fRegion.add(getPolygon(false));
fPopup.setRegion(fRegion);
- Rectangle bounds= fRegion.getBounds();
+ Rectangle bounds = fRegion.getBounds();
fPopup.setSize(bounds.width, bounds.height + 1);
} else {
- fRegion= null;
+ fRegion = null;
fPopup.setRegion(null);
}
@@ -624,12 +617,12 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
private Point getExtent() {
Point e = fPopup.getSize();
switch (fSnapPosition) {
- case SNAP_POSITION_UNDER_LEFT_FIELD:
- e.y -= HAH;
- break;
- case SNAP_POSITION_OVER_LEFT_FIELD:
- e.y -= HAH + 1;
- break;
+ case SNAP_POSITION_UNDER_LEFT_FIELD:
+ e.y -= HAH;
+ break;
+ case SNAP_POSITION_OVER_LEFT_FIELD:
+ e.y -= HAH + 1;
+ break;
}
return e;
}
@@ -637,57 +630,38 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
private int[] getPolygon(boolean border) {
Point e = getExtent();
int b = border ? 1 : 0;
- boolean isRTL= (fPopup.getStyle() & SWT.RIGHT_TO_LEFT) != 0;
- int ha1= isRTL ? e.x - HAO : HAO + HAW;
- int ha2= isRTL ? e.x - HAO - HAW / 2 : HAO + HAW / 2;
- int ha3= isRTL ? e.x - HAO - HAW : HAO;
- int[] poly;
- switch (fSnapPosition) {
- case SNAP_POSITION_OVER_LEFT_FIELD:
- poly= new int[] {
- 0, 0,
- e.x - b, 0,
- e.x - b, e.y - b,
- ha1, e.y - b,
- ha2, e.y + HAH - b,
- ha3, e.y - b,
- 0, e.y - b,
- 0, 0 };
- break;
-
- case SNAP_POSITION_UNDER_LEFT_FIELD:
- poly= new int[] {
- 0, HAH,
- ha3 + b, HAH,
- ha2, b,
- ha1 - b, HAH,
- e.x - b, HAH,
- e.x - b, e.y + HAH - b,
- 0, e.y + HAH - b,
- 0, HAH };
- break;
-
- default:
- poly= new int[] {
- 0, 0,
- e.x - b, 0,
- e.x - b, e.y - b,
- 0, e.y - b,
- 0, 0 };
- break;
- }
+ boolean isRTL = (fPopup.getStyle() & SWT.RIGHT_TO_LEFT) != 0;
+ int ha1 = isRTL ? e.x - HAO : HAO + HAW;
+ int ha2 = isRTL ? e.x - HAO - HAW / 2 : HAO + HAW / 2;
+ int ha3 = isRTL ? e.x - HAO - HAW : HAO;
+ int[] poly;
+ switch (fSnapPosition) {
+ case SNAP_POSITION_OVER_LEFT_FIELD:
+ poly = new int[] { 0, 0, e.x - b, 0, e.x - b, e.y - b, ha1, e.y - b, ha2, e.y + HAH - b, ha3, e.y - b, 0,
+ e.y - b, 0, 0 };
+ break;
+
+ case SNAP_POSITION_UNDER_LEFT_FIELD:
+ poly = new int[] { 0, HAH, ha3 + b, HAH, ha2, b, ha1 - b, HAH, e.x - b, HAH, e.x - b, e.y + HAH - b, 0,
+ e.y + HAH - b, 0, HAH };
+ break;
+
+ default:
+ poly = new int[] { 0, 0, e.x - b, 0, e.x - b, e.y - b, 0, e.y - b, 0, 0 };
+ break;
+ }
return poly;
}
private void createContent(Composite parent) {
- Display display= parent.getDisplay();
- Color foreground= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- Color background= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ Display display = parent.getDisplay();
+ Color foreground = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+ Color background = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
addMoveSupport(fPopup, parent);
- StyledText hint= new StyledText(fPopup, SWT.READ_ONLY | SWT.SINGLE);
- String enterKeyName= getEnterBinding();
- String hintTemplate= RenameMessages.RenameInformationPopup_EnterNewName;
+ StyledText hint = new StyledText(fPopup, SWT.READ_ONLY | SWT.SINGLE);
+ String enterKeyName = getEnterBinding();
+ String hintTemplate = RenameMessages.RenameInformationPopup_EnterNewName;
hint.setText(NLS.bind(hintTemplate, enterKeyName));
hint.setForeground(foreground);
hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$
@@ -700,9 +674,9 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
}
private ToolBar addViewMenu(final Composite parent) {
- fToolBar= new ToolBar(parent, SWT.FLAT);
+ fToolBar = new ToolBar(parent, SWT.FLAT);
final ToolItem menuButton = new ToolItem(fToolBar, SWT.PUSH, 0);
- fMenuImage= CPluginImages.DESC_ELCL_VIEW_MENU.createImage();
+ fMenuImage = CPluginImages.DESC_ELCL_VIEW_MENU.createImage();
menuButton.setImage(fMenuImage);
menuButton.setToolTipText(RenameMessages.RenameInformationPopup_menu);
fToolBar.addMouseListener(new MouseAdapter() {
@@ -722,9 +696,9 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
}
private void showMenu(ToolBar toolBar) {
- Menu menu= getMenuManager().createContextMenu(toolBar);
+ Menu menu = getMenuManager().createContextMenu(toolBar);
menu.setLocation(toolBar.toDisplay(0, toolBar.getSize().y));
- fIsMenuUp= true;
+ fIsMenuUp = true;
menu.setVisible(true);
}
@@ -733,20 +707,20 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
return fMenuManager;
}
- fMenuManager= new MenuManager();
+ fMenuManager = new MenuManager();
fMenuManager.setRemoveAllWhenShown(true);
fMenuManager.addMenuListener(new IMenuListener2() {
@Override
public void menuAboutToHide(IMenuManager manager) {
- fIsMenuUp= false;
+ fIsMenuUp = false;
}
@Override
public void menuAboutToShow(IMenuManager manager) {
- boolean canRefactor= !fRenameLinkedMode.isOriginalName();
-
- IAction refactorAction= new Action(RenameMessages.RenameInformationPopup_RenameInWorkspace) {
+ boolean canRefactor = !fRenameLinkedMode.isOriginalName();
+
+ IAction refactorAction = new Action(RenameMessages.RenameInformationPopup_RenameInWorkspace) {
@Override
public void run() {
activateEditor();
@@ -757,7 +731,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
refactorAction.setEnabled(canRefactor);
manager.add(refactorAction);
- IAction previewAction= new Action(RenameMessages.RenameInformationPopup_Preview) {
+ IAction previewAction = new Action(RenameMessages.RenameInformationPopup_Preview) {
@Override
public void run() {
activateEditor();
@@ -768,7 +742,8 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
previewAction.setEnabled(canRefactor);
manager.add(previewAction);
- IAction openDialogAction= new Action(RenameMessages.RenameInformationPopup_OpenDialog + '\t' + fOpenDialogBinding) {
+ IAction openDialogAction = new Action(
+ RenameMessages.RenameInformationPopup_OpenDialog + '\t' + fOpenDialogBinding) {
@Override
public void run() {
activateEditor();
@@ -779,21 +754,27 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
manager.add(new Separator());
- MenuManager subMenuManager= new MenuManager(RenameMessages.RenameInformationPopup_SnapTo);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_UNDER_LEFT_FIELD, RenameMessages.RenameInformationPopup_snap_under_left);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_UNDER_RIGHT_FIELD, RenameMessages.RenameInformationPopup_snap_under_right);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_OVER_LEFT_FIELD, RenameMessages.RenameInformationPopup_snap_over_left);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_OVER_RIGHT_FIELD, RenameMessages.RenameInformationPopup_snap_over_right);
- addMoveMenuItem(subMenuManager, SNAP_POSITION_LOWER_RIGHT, RenameMessages.RenameInformationPopup_snap_bottom_right);
+ MenuManager subMenuManager = new MenuManager(RenameMessages.RenameInformationPopup_SnapTo);
+ addMoveMenuItem(subMenuManager, SNAP_POSITION_UNDER_LEFT_FIELD,
+ RenameMessages.RenameInformationPopup_snap_under_left);
+ addMoveMenuItem(subMenuManager, SNAP_POSITION_UNDER_RIGHT_FIELD,
+ RenameMessages.RenameInformationPopup_snap_under_right);
+ addMoveMenuItem(subMenuManager, SNAP_POSITION_OVER_LEFT_FIELD,
+ RenameMessages.RenameInformationPopup_snap_over_left);
+ addMoveMenuItem(subMenuManager, SNAP_POSITION_OVER_RIGHT_FIELD,
+ RenameMessages.RenameInformationPopup_snap_over_right);
+ addMoveMenuItem(subMenuManager, SNAP_POSITION_LOWER_RIGHT,
+ RenameMessages.RenameInformationPopup_snap_bottom_right);
manager.add(subMenuManager);
- IAction prefsAction= new Action(RenameMessages.RenameInformationPopup_preferences) {
+ IAction prefsAction = new Action(RenameMessages.RenameInformationPopup_preferences) {
@Override
public void run() {
fRenameLinkedMode.cancel();
- String linkedModePrefPageID= "org.eclipse.ui.editors.preferencePages.LinkedModePreferencePage"; //$NON-NLS-1$
- String refactoringPrefPageID= CPluginPreferencePage.C_BASE_PREF_PAGE_ID;
- PreferencesUtil.createPreferenceDialogOn(fEditor.getSite().getShell(), refactoringPrefPageID, new String[] { linkedModePrefPageID, refactoringPrefPageID }, null).open();
+ String linkedModePrefPageID = "org.eclipse.ui.editors.preferencePages.LinkedModePreferencePage"; //$NON-NLS-1$
+ String refactoringPrefPageID = CPluginPreferencePage.C_BASE_PREF_PAGE_ID;
+ PreferencesUtil.createPreferenceDialogOn(fEditor.getSite().getShell(), refactoringPrefPageID,
+ new String[] { linkedModePrefPageID, refactoringPrefPageID }, null).open();
}
};
manager.add(prefsAction);
@@ -803,11 +784,11 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
}
private void addMoveMenuItem(IMenuManager manager, final int snapPosition, String text) {
- IAction action= new Action(text, IAction.AS_RADIO_BUTTON) {
+ IAction action = new Action(text, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
- fSnapPosition= snapPosition;
- fSnapPositionChanged= true;
+ fSnapPosition = snapPosition;
+ fSnapPositionChanged = true;
getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition);
updatePopupLocation(true);
activateEditor();
@@ -826,18 +807,18 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
* @return the keybinding for Refactor &gt; Rename
*/
private static String getOpenDialogBinding() {
- IBindingService bindingService= PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
if (bindingService == null)
return ""; //$NON-NLS-1$
- String binding= bindingService.getBestActiveBindingFormattedFor(ICEditorActionDefinitionIds.RENAME_ELEMENT);
+ String binding = bindingService.getBestActiveBindingFormattedFor(ICEditorActionDefinitionIds.RENAME_ELEMENT);
return binding == null ? "" : binding; //$NON-NLS-1$
}
private static void recursiveSetBackgroundColor(Control control, Color color) {
control.setBackground(color);
if (control instanceof Composite) {
- Control[] children= ((Composite) control).getChildren();
- for (int i= 0; i < children.length; i++) {
+ Control[] children = ((Composite) control).getChildren();
+ for (int i = 0; i < children.length; i++) {
recursiveSetBackgroundColor(children[i], color);
}
}
@@ -848,7 +829,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK
return true;
if (fPopup == null || fPopup.isDisposed())
return false;
- Shell activeShell= fPopup.getDisplay().getActiveShell();
+ Shell activeShell = fPopup.getDisplay().getActiveShell();
if (fPopup == activeShell)
return true;
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java
index 4f24aff2677..ab1f7ddc0a3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java
@@ -94,8 +94,8 @@ public class RenameLinkedMode {
return true;
}
- Shell editorShell= fEditor.getSite().getShell();
- Shell activeShell= editorShell.getDisplay().getActiveShell();
+ Shell editorShell = fEditor.getSite().getShell();
+ Shell activeShell = editorShell.getDisplay().getActiveShell();
if (editorShell == activeShell)
return true;
return false;
@@ -132,17 +132,16 @@ public class RenameLinkedMode {
@Override
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
- fShowPreview= (event.stateMask & SWT.CTRL) != 0
- && (event.character == SWT.CR || event.character == SWT.LF);
+ fShowPreview = (event.stateMask & SWT.CTRL) != 0
+ && (event.character == SWT.CR || event.character == SWT.LF);
return super.doExit(model, event, offset, length);
}
}
-
private static RenameLinkedMode fgActiveLinkedMode;
private final CEditor fEditor;
-
+
private RenameInformationPopup fInfoPopup;
private Point fOriginalSelection;
@@ -163,21 +162,21 @@ public class RenameLinkedMode {
public RenameLinkedMode(CEditor editor) {
Assert.isNotNull(editor);
- fEditor= editor;
- fFocusEditingSupport= new FocusEditingSupport();
+ fEditor = editor;
+ fFocusEditingSupport = new FocusEditingSupport();
}
public static RenameLinkedMode getActiveLinkedMode() {
if (fgActiveLinkedMode != null) {
- ISourceViewer viewer= fgActiveLinkedMode.fEditor.getViewer();
+ ISourceViewer viewer = fgActiveLinkedMode.fEditor.getViewer();
if (viewer != null) {
- StyledText textWidget= viewer.getTextWidget();
+ StyledText textWidget = viewer.getTextWidget();
if (textWidget != null && !textWidget.isDisposed()) {
return fgActiveLinkedMode;
}
}
// Make sure we don't hold onto the active linked mode if anything went wrong with canceling.
- fgActiveLinkedMode= null;
+ fgActiveLinkedMode = null;
}
return null;
}
@@ -189,45 +188,45 @@ public class RenameLinkedMode {
return;
}
- ISourceViewer viewer= fEditor.getViewer();
- fOriginalSelection= viewer.getSelectedRange();
- final int offset= fOriginalSelection.x;
+ ISourceViewer viewer = fEditor.getViewer();
+ fOriginalSelection = viewer.getSelectedRange();
+ final int offset = fOriginalSelection.x;
try {
fLocations = null;
- Point selection= viewer.getSelectedRange();
+ Point selection = viewer.getSelectedRange();
final int secectionOffset = selection.x;
final int selectionLength = selection.y;
- final IDocument document= viewer.getDocument();
+ final IDocument document = viewer.getDocument();
ASTProvider.getASTProvider().runOnAST(fEditor.getInputCElement(), ASTProvider.WAIT_ACTIVE_ONLY,
new NullProgressMonitor(), new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
- if (astRoot == null)
- return Status.CANCEL_STATUS;
-
- IASTNodeSelector selector= astRoot.getNodeSelector(null);
- IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
- if (name != null) {
- fOriginalName = name.toString();
- fLocations = LinkedNamesFinder.findByName(astRoot, name);
- }
- return Status.OK_STATUS;
- }
- });
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+ if (astRoot == null)
+ return Status.CANCEL_STATUS;
+
+ IASTNodeSelector selector = astRoot.getNodeSelector(null);
+ IASTName name = selector.findEnclosingName(secectionOffset, selectionLength);
+ if (name != null) {
+ fOriginalName = name.toString();
+ fLocations = LinkedNamesFinder.findByName(astRoot, name);
+ }
+ return Status.OK_STATUS;
+ }
+ });
if (fLocations == null || fLocations.length == 0) {
return;
}
if (viewer instanceof ITextViewerExtension6) {
- IUndoManager undoManager= ((ITextViewerExtension6) viewer).getUndoManager();
+ IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
if (undoManager instanceof IUndoManagerExtension) {
- IUndoManagerExtension undoManagerExtension= (IUndoManagerExtension) undoManager;
- IUndoContext undoContext= undoManagerExtension.getUndoContext();
- IOperationHistory operationHistory= OperationHistoryFactory.getOperationHistory();
- fStartingUndoOperation= operationHistory.getUndoOperation(undoContext);
+ IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
+ IUndoContext undoContext = undoManagerExtension.getUndoContext();
+ IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
+ fStartingUndoOperation = operationHistory.getUndoOperation(undoContext);
}
}
@@ -246,31 +245,31 @@ public class RenameLinkedMode {
* @return the rank of the location with respect to the invocation offset
*/
private int rank(IRegion location) {
- int relativeRank= location.getOffset() + location.getLength() - offset;
+ int relativeRank = location.getOffset() + location.getLength() - offset;
if (relativeRank < 0)
return Integer.MAX_VALUE + relativeRank;
else
return relativeRank;
}
});
-
- fLinkedPositionGroup= new LinkedPositionGroup();
- for (int i= 0; i < fLocations.length; i++) {
- IRegion item= fLocations[i];
+
+ fLinkedPositionGroup = new LinkedPositionGroup();
+ for (int i = 0; i < fLocations.length; i++) {
+ IRegion item = fLocations[i];
LinkedPosition linkedPosition = new LinkedPosition(document, item.getOffset(), item.getLength(), i);
if (i == 0) {
- fNamePosition= linkedPosition;
+ fNamePosition = linkedPosition;
}
fLinkedPositionGroup.addPosition(linkedPosition);
}
- fLinkedModeModel= new LinkedModeModel();
+ fLinkedModeModel = new LinkedModeModel();
fLinkedModeModel.addGroup(fLinkedPositionGroup);
fLinkedModeModel.forceInstall();
fLinkedModeModel.addLinkingListener(new EditorHighlightingSynchronizer(fEditor));
fLinkedModeModel.addLinkingListener(new EditorSynchronizer());
-
- LinkedModeUI ui= new EditorLinkedModeUI(fLinkedModeModel, viewer);
+
+ LinkedModeUI ui = new EditorLinkedModeUI(fLinkedModeModel, viewer);
ui.setExitPolicy(new ExitPolicy(document));
ui.setExitPosition(viewer, offset, 0, LinkedPositionGroup.NO_STOP);
ui.enter();
@@ -279,12 +278,12 @@ public class RenameLinkedMode {
viewer.setSelectedRange(selection.x, selection.y);
if (viewer instanceof IEditingSupportRegistry) {
- IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
+ IEditingSupportRegistry registry = (IEditingSupportRegistry) viewer;
registry.register(fFocusEditingSupport);
}
openSecondaryPopup();
- fgActiveLinkedMode= this;
+ fgActiveLinkedMode = this;
} catch (BadLocationException e) {
CUIPlugin.log(e);
}
@@ -293,56 +292,56 @@ public class RenameLinkedMode {
void doRename(boolean showPreview) {
cancel();
- Image image= null;
- Label label= null;
+ Image image = null;
+ Label label = null;
- fShowPreview|= showPreview;
+ fShowPreview |= showPreview;
try {
- ISourceViewer viewer= fEditor.getViewer();
+ ISourceViewer viewer = fEditor.getViewer();
if (viewer instanceof SourceViewer) {
- SourceViewer sourceViewer= (SourceViewer) viewer;
- Control viewerControl= sourceViewer.getControl();
+ SourceViewer sourceViewer = (SourceViewer) viewer;
+ Control viewerControl = sourceViewer.getControl();
if (viewerControl instanceof Composite) {
- Composite composite= (Composite) viewerControl;
- Display display= composite.getDisplay();
+ Composite composite = (Composite) viewerControl;
+ Display display = composite.getDisplay();
// Flush pending redraw requests:
while (!display.isDisposed() && display.readAndDispatch()) {
}
// Copy editor area:
- GC gc= new GC(composite);
+ GC gc = new GC(composite);
Point size;
try {
- size= composite.getSize();
- image= new Image(gc.getDevice(), size.x, size.y);
+ size = composite.getSize();
+ image = new Image(gc.getDevice(), size.x, size.y);
gc.copyArea(image, 0, 0);
} finally {
gc.dispose();
- gc= null;
+ gc = null;
}
// Persist editor area while executing refactoring:
- label= new Label(composite, SWT.NONE);
+ label = new Label(composite, SWT.NONE);
label.setImage(image);
label.setBounds(0, 0, size.x, size.y);
label.moveAbove(null);
}
}
- String newName= fNamePosition.getContent();
+ String newName = fNamePosition.getContent();
if (fOriginalName.equals(newName))
return;
- RenameSupport renameSupport= undoAndCreateRenameSupport(newName);
+ RenameSupport renameSupport = undoAndCreateRenameSupport(newName);
if (renameSupport == null)
return;
- Shell shell= fEditor.getSite().getShell();
+ Shell shell = fEditor.getSite().getShell();
boolean executed;
if (fShowPreview) { // could have been updated by undoAndCreateRenameSupport(..)
- executed= renameSupport.openDialog(shell, true);
+ executed = renameSupport.openDialog(shell, true);
} else {
- executed= renameSupport.perform(shell, fEditor.getSite().getWorkbenchWindow());
+ executed = renameSupport.perform(shell, fEditor.getSite().getWorkbenchWindow());
}
if (executed) {
restoreFullSelection();
@@ -373,10 +372,10 @@ public class RenameLinkedMode {
private void restoreFullSelection() {
if (fOriginalSelection.y != 0) {
- int originalOffset= fOriginalSelection.x;
- LinkedPosition[] positions= fLinkedPositionGroup.getPositions();
- for (int i= 0; i < positions.length; i++) {
- LinkedPosition position= positions[i];
+ int originalOffset = fOriginalSelection.x;
+ LinkedPosition[] positions = fLinkedPositionGroup.getPositions();
+ for (int i = 0; i < positions.length; i++) {
+ LinkedPosition position = positions[i];
if (!position.isDeleted() && position.includes(originalOffset)) {
fEditor.getViewer().setSelectedRange(position.offset, position.length);
return;
@@ -387,7 +386,7 @@ public class RenameLinkedMode {
private RenameSupport undoAndCreateRenameSupport(String newName) throws CoreException {
// Assumption: the linked mode model should be shut down by now.
- final ISourceViewer viewer= fEditor.getViewer();
+ final ISourceViewer viewer = fEditor.getViewer();
try {
if (!fOriginalName.equals(newName)) {
@@ -395,14 +394,14 @@ public class RenameLinkedMode {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (viewer instanceof ITextViewerExtension6) {
- IUndoManager undoManager= ((ITextViewerExtension6) viewer).getUndoManager();
+ IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
if (undoManager instanceof IUndoManagerExtension) {
- IUndoManagerExtension undoManagerExtension= (IUndoManagerExtension) undoManager;
- IUndoContext undoContext= undoManagerExtension.getUndoContext();
- IOperationHistory operationHistory= OperationHistoryFactory.getOperationHistory();
+ IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
+ IUndoContext undoContext = undoManagerExtension.getUndoContext();
+ IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
while (undoManager.undoable()) {
- if (fStartingUndoOperation != null &&
- fStartingUndoOperation.equals(operationHistory.getUndoOperation(undoContext)))
+ if (fStartingUndoOperation != null && fStartingUndoOperation
+ .equals(operationHistory.getUndoOperation(undoContext)))
return;
undoManager.undo();
}
@@ -427,18 +426,18 @@ public class RenameLinkedMode {
return null;
IWorkingCopy workingCopy = getWorkingCopy();
- IResource resource= workingCopy.getResource();
- if (!(resource instanceof IFile)) {
- return null;
- }
- CRefactoringArgument arg=
- new CRefactoringArgument((IFile) resource, fOriginalSelection.x, fOriginalSelection.y);
- CRenameProcessor processor= new CRenameProcessor(CRefactory.getInstance(), arg);
- processor.setReplacementText(newName);
- CRenameRefactoringPreferences preferences = new CRenameRefactoringPreferences();
- processor.setSelectedOptions(preferences.getOptions());
- processor.setExhaustiveSearchScope(preferences.getScope());
- processor.setWorkingSetName(preferences.getWorkingSet());
+ IResource resource = workingCopy.getResource();
+ if (!(resource instanceof IFile)) {
+ return null;
+ }
+ CRefactoringArgument arg = new CRefactoringArgument((IFile) resource, fOriginalSelection.x,
+ fOriginalSelection.y);
+ CRenameProcessor processor = new CRenameProcessor(CRefactory.getInstance(), arg);
+ processor.setReplacementText(newName);
+ CRenameRefactoringPreferences preferences = new CRenameRefactoringPreferences();
+ processor.setSelectedOptions(preferences.getOptions());
+ processor.setExhaustiveSearchScope(preferences.getScope());
+ processor.setWorkingSetName(preferences.getWorkingSet());
return RenameSupport.create(processor);
}
@@ -459,8 +458,8 @@ public class RenameLinkedMode {
cancel();
try {
- String newName= fNamePosition.getContent();
- RenameSupport renameSupport= undoAndCreateRenameSupport(newName);
+ String newName = fNamePosition.getContent();
+ RenameSupport renameSupport = undoAndCreateRenameSupport(newName);
if (renameSupport != null)
renameSupport.openDialog(fEditor.getSite().getShell());
} catch (CoreException e) {
@@ -471,20 +470,20 @@ public class RenameLinkedMode {
}
private void linkedModeLeft() {
- fgActiveLinkedMode= null;
+ fgActiveLinkedMode = null;
if (fInfoPopup != null) {
fInfoPopup.close();
}
- ISourceViewer viewer= fEditor.getViewer();
+ ISourceViewer viewer = fEditor.getViewer();
if (viewer instanceof IEditingSupportRegistry) {
- IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
+ IEditingSupportRegistry registry = (IEditingSupportRegistry) viewer;
registry.unregister(fFocusEditingSupport);
}
}
private void openSecondaryPopup() {
- fInfoPopup= new RenameInformationPopup(fEditor, this);
+ fInfoPopup = new RenameInformationPopup(fEditor, this);
fInfoPopup.open();
}
@@ -493,12 +492,12 @@ public class RenameLinkedMode {
}
public LinkedPosition getCurrentLinkedPosition() {
- Point selection= fEditor.getViewer().getSelectedRange();
- int start= selection.x;
- int end= start + selection.y;
- LinkedPosition[] positions= fLinkedPositionGroup.getPositions();
- for (int i= 0; i < positions.length; i++) {
- LinkedPosition position= positions[i];
+ Point selection = fEditor.getViewer().getSelectedRange();
+ int start = selection.x;
+ int end = start + selection.y;
+ LinkedPosition[] positions = fLinkedPositionGroup.getPositions();
+ for (int i = 0; i < positions.length; i++) {
+ LinkedPosition position = positions[i];
if (position.includes(start) && position.includes(end))
return position;
}
@@ -507,7 +506,7 @@ public class RenameLinkedMode {
public boolean isEnabled() {
try {
- String newName= fNamePosition.getContent();
+ String newName = fNamePosition.getContent();
if (fOriginalName.equals(newName))
return false;
return CConventions.validateIdentifier(newName, getLanguage()).isOK();
@@ -528,10 +527,10 @@ public class RenameLinkedMode {
}
return GPPLanguage.getDefault();
}
-
+
public boolean isOriginalName() {
try {
- String newName= fNamePosition.getContent();
+ String newName = fNamePosition.getContent();
return fOriginalName.equals(newName);
} catch (BadLocationException e) {
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java
index 457b5ab0c0f..a0313d23a0e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java
@@ -1,23 +1,23 @@
/*******************************************************************************
* Copyright (c) 2004, 2018 Wind River Systems, Inc.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- ******************************************************************************/
+ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.osgi.util.NLS;
class RenameMessages extends NLS {
- public static String ASTManager_error_macro_name_conflict;
+ public static String ASTManager_error_macro_name_conflict;
public static String ASTManager_subtask_analyzing;
public static String ASTManager_task_analyze;
public static String ASTManager_task_generateAst;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameModifications.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameModifications.java
index 2da4bf359d5..117aeac7c30 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameModifications.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameModifications.java
@@ -42,7 +42,7 @@ import org.eclipse.cdt.internal.corext.refactoring.participants.ResourceModifica
import org.eclipse.cdt.internal.ui.refactoring.reorg.RefactoringModifications;
/**
- * Stores objects renamed by the rename refactoring.
+ * Stores objects renamed by the rename refactoring.
*/
public class RenameModifications extends RefactoringModifications {
private List<Object> fRename;
@@ -73,14 +73,15 @@ public class RenameModifications extends RefactoringModifications {
public void rename(ITranslationUnit unit, RenameArguments args) {
add(unit, args, null);
if (unit.getResource() != null) {
- getResourceModifications().addRename(unit.getResource(), new RenameArguments(args.getNewName(), args.getUpdateReferences()));
+ getResourceModifications().addRename(unit.getResource(),
+ new RenameArguments(args.getNewName(), args.getUpdateReferences()));
}
}
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
for (int i = 0; i < fRename.size(); i++) {
- Object element= fRename.get(i);
+ Object element = fRename.get(i);
if (element instanceof IResource) {
ResourceModifications.buildMoveDelta(builder, (IResource) element,
(RenameArguments) fRenameArguments.get(i));
@@ -108,12 +109,8 @@ public class RenameModifications extends RefactoringModifications {
String[] natures, SharableParticipants shared) {
List<RefactoringParticipant> result = new ArrayList<>();
for (int i = 0; i < fRename.size(); i++) {
- ArrayUtil.addAll(result,
- ParticipantManager.loadRenameParticipants(status,
- owner, fRename.get(i),
- (RenameArguments) fRenameArguments.get(i),
- fParticipantDescriptorFilter.get(i),
- natures, shared));
+ ArrayUtil.addAll(result, ParticipantManager.loadRenameParticipants(status, owner, fRename.get(i),
+ (RenameArguments) fRenameArguments.get(i), fParticipantDescriptorFilter.get(i), natures, shared));
}
ArrayUtil.addAll(result, getResourceModifications().getParticipants(status, owner, natures, shared));
return result.toArray(new RefactoringParticipant[result.size()]);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameParticipantHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameParticipantHelper.java
index 35586bc43ef..107e96df83a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameParticipantHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameParticipantHelper.java
@@ -29,7 +29,7 @@ public class RenameParticipantHelper {
* the refactoring processor. If the two changes are be affecting the same files, the part of
* the refactoring participant's change that affects the files also modified by the refactoring
* processor is merged into the processor's change. The remaining part, if any, is returned from
- * the method.
+ * the method.
*
* @param change the change produced by a refactoring participant
* @param participant the refactoring participant
@@ -38,10 +38,8 @@ public class RenameParticipantHelper {
public static Change postprocessParticipantChange(Change change, RefactoringParticipant participant) {
if (change == null)
return null;
- CompositeChange compositeChange = change instanceof CompositeChange ?
- (CompositeChange) change : null;
- Change[] changes = compositeChange != null ?
- compositeChange.getChildren() : new Change[] { change };
+ CompositeChange compositeChange = change instanceof CompositeChange ? (CompositeChange) change : null;
+ Change[] changes = compositeChange != null ? compositeChange.getChildren() : new Change[] { change };
for (Change ch : changes) {
if (ch instanceof TextChange) {
TextChange textChange = (TextChange) ch;
@@ -74,5 +72,6 @@ public class RenameParticipantHelper {
}
}
- private RenameParticipantHelper() {}
+ private RenameParticipantHelper() {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java
index 56e2839ad9a..24e621945a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java
@@ -43,29 +43,35 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringStarter;
*/
public class RenameSupport {
/** Flag indication that no additional update is to be performed. */
- public static final int NONE= 0;
+ public static final int NONE = 0;
/** Flag indicating that references are to be updated as well. */
- public static final int UPDATE_REFERENCES= 1 << 0;
+ public static final int UPDATE_REFERENCES = 1 << 0;
/**
* Flag indicating that textual matches in comments and in string literals
* are to be updated as well.
*/
- public static final int UPDATE_TEXTUAL_MATCHES= 1 << 6;
+ public static final int UPDATE_TEXTUAL_MATCHES = 1 << 6;
/** Flag indicating that the getter method is to be updated as well. */
- public static final int UPDATE_GETTER_METHOD= 1 << 4;
+ public static final int UPDATE_GETTER_METHOD = 1 << 4;
/** Flag indicating that the setter method is to be updated as well. */
- public static final int UPDATE_SETTER_METHOD= 1 << 5;
+ public static final int UPDATE_SETTER_METHOD = 1 << 5;
- /** @see #openDialog(Shell, CRenameRefactoring, DialogMode) */
- private enum DialogMode { ALL_PAGES, PREVIEW_ONLY, CONDITIONAL_PREVIEW }
- /** @see #openDialog(Shell, CRenameRefactoring, DialogMode) */
- private enum DialogResult { OK, CANCELED, SKIPPED }
- // Same as org.eclipse.ltk.internal.ui.refactoring.IErrorWizardPage#PAGE_NAME
- private static final String ERROR_PAGE_NAME = "ErrorPage"; //$NON-NLS-1$
+ /** @see #openDialog(Shell, CRenameRefactoring, DialogMode) */
+ private enum DialogMode {
+ ALL_PAGES, PREVIEW_ONLY, CONDITIONAL_PREVIEW
+ }
+
+ /** @see #openDialog(Shell, CRenameRefactoring, DialogMode) */
+ private enum DialogResult {
+ OK, CANCELED, SKIPPED
+ }
+
+ // Same as org.eclipse.ltk.internal.ui.refactoring.IErrorWizardPage#PAGE_NAME
+ private static final String ERROR_PAGE_NAME = "ErrorPage"; //$NON-NLS-1$
private CRenameRefactoring fRefactoring;
private RefactoringStatus fPreCheckStatus;
@@ -104,7 +110,7 @@ public class RenameSupport {
* @see #openDialog(Shell, boolean)
*/
public boolean openDialog(Shell shell) throws CoreException {
- return openDialog(shell, false);
+ return openDialog(shell, false);
}
/**
@@ -133,8 +139,8 @@ public class RenameSupport {
return false;
}
- DialogMode mode = showPreviewOnly ? DialogMode.PREVIEW_ONLY : DialogMode.ALL_PAGES;
- return openDialog(shell, fRefactoring, mode) == DialogResult.OK;
+ DialogMode mode = showPreviewOnly ? DialogMode.PREVIEW_ONLY : DialogMode.ALL_PAGES;
+ return openDialog(shell, fRefactoring, mode) == DialogResult.OK;
}
/**
@@ -146,7 +152,7 @@ public class RenameSupport {
* @see #openDialog(Shell, boolean)
*/
public static void openDialog(Shell shell, CRenameRefactoring refactoring) {
- openDialog(shell, refactoring, DialogMode.ALL_PAGES);
+ openDialog(shell, refactoring, DialogMode.ALL_PAGES);
}
/**
@@ -169,56 +175,54 @@ public class RenameSupport {
static DialogResult openDialog(Shell shell, CRenameRefactoring refactoring, final DialogMode mode) {
try {
final boolean[] dialogSkipped = new boolean[1];
- CRenameRefactoringWizard wizard;
- if (mode == DialogMode.ALL_PAGES) {
- wizard = new CRenameRefactoringWizard(refactoring);
- } else {
- wizard = new CRenameRefactoringWizard(refactoring) {
+ CRenameRefactoringWizard wizard;
+ if (mode == DialogMode.ALL_PAGES) {
+ wizard = new CRenameRefactoringWizard(refactoring);
+ } else {
+ wizard = new CRenameRefactoringWizard(refactoring) {
@Override
protected void addUserInputPages() {
- // Nothing to add
- }
+ // Nothing to add
+ }
@Override
public IWizardPage getStartingPage() {
IWizardPage startingPage = super.getStartingPage();
- if (mode == DialogMode.CONDITIONAL_PREVIEW &&
- !startingPage.getName().equals(ERROR_PAGE_NAME)) {
+ if (mode == DialogMode.CONDITIONAL_PREVIEW && !startingPage.getName().equals(ERROR_PAGE_NAME)) {
dialogSkipped[0] = true;
return null;
}
return startingPage;
}
- };
- wizard.setForcePreviewReview(mode != DialogMode.ALL_PAGES);
- }
- RefactoringStarter starter = new RefactoringStarter();
+ };
+ wizard.setForcePreviewReview(mode != DialogMode.ALL_PAGES);
+ }
+ RefactoringStarter starter = new RefactoringStarter();
CRenameProcessor processor = refactoring.getProcessor();
- processor.lockIndex();
- try {
- RefactoringStatus status = processor.checkInitialConditions(new NullProgressMonitor());
- if (status.hasFatalError()) {
+ processor.lockIndex();
+ try {
+ RefactoringStatus status = processor.checkInitialConditions(new NullProgressMonitor());
+ if (status.hasFatalError()) {
showInformation(shell, status);
- return DialogResult.CANCELED;
- }
- if (starter.activate(wizard, shell, RenameMessages.CRefactory_title_rename,
- processor.getSaveMode())) {
- return DialogResult.OK;
- }
- if (dialogSkipped[0]) {
- // If the dialog was not shown, it is our responsibility to close it.
- wizard.getContainer().getShell().close();
- return DialogResult.SKIPPED;
- }
- } finally {
- processor.unlockIndex();
- }
- } catch (InterruptedException e) {
+ return DialogResult.CANCELED;
+ }
+ if (starter.activate(wizard, shell, RenameMessages.CRefactory_title_rename, processor.getSaveMode())) {
+ return DialogResult.OK;
+ }
+ if (dialogSkipped[0]) {
+ // If the dialog was not shown, it is our responsibility to close it.
+ wizard.getContainer().getShell().close();
+ return DialogResult.SKIPPED;
+ }
+ } finally {
+ processor.unlockIndex();
+ }
+ } catch (InterruptedException e) {
Thread.currentThread().interrupt();
- } catch (CoreException e) {
- CUIPlugin.log(e);
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
}
- return DialogResult.CANCELED;
+ return DialogResult.CANCELED;
}
/**
@@ -257,7 +261,8 @@ public class RenameSupport {
static DialogResult openRenameResourceDialog(Shell shell, final DialogMode mode, IResource resource) {
CResourceRenameRefactoringWizard wizard = new CResourceRenameRefactoringWizard(resource);
RefactoringStarter starter = new RefactoringStarter();
- if (starter.activate(wizard, shell, RenameMessages.RenameSupport_rename_resource, RefactoringSaveHelper.SAVE_ALL)) {
+ if (starter.activate(wizard, shell, RenameMessages.RenameSupport_rename_resource,
+ RefactoringSaveHelper.SAVE_ALL)) {
return DialogResult.OK;
}
@@ -284,7 +289,8 @@ public class RenameSupport {
* @see #openDialog(Shell)
* @see IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
*/
- public boolean perform(Shell parent, IWorkbenchWindow context) throws InterruptedException, InvocationTargetException {
+ public boolean perform(Shell parent, IWorkbenchWindow context)
+ throws InterruptedException, InvocationTargetException {
try {
ensureChecked();
if (fPreCheckStatus.hasFatalError()) {
@@ -300,15 +306,14 @@ public class RenameSupport {
showInformation(parent, fPreCheckStatus);
return false;
}
- DialogResult result = openDialog(context.getShell(), fRefactoring,
- DialogMode.CONDITIONAL_PREVIEW);
+ DialogResult result = openDialog(context.getShell(), fRefactoring, DialogMode.CONDITIONAL_PREVIEW);
switch (result) {
case OK:
return true;
case SKIPPED:
- RefactoringExecutionHelper helper= new RefactoringExecutionHelper(fRefactoring,
- RefactoringCore.getConditionCheckingFailedSeverity(),
- renameProcessor.getSaveMode(), parent, context);
+ RefactoringExecutionHelper helper = new RefactoringExecutionHelper(fRefactoring,
+ RefactoringCore.getConditionCheckingFailedSeverity(), renameProcessor.getSaveMode(), parent,
+ context);
Change change = fRefactoring.getChange();
Assert.isNotNull(change);
helper.performChange(change, true);
@@ -325,7 +330,7 @@ public class RenameSupport {
}
private RenameSupport(CRenameProcessor processor) {
- fRefactoring= new CRenameRefactoring(processor);
+ fRefactoring = new CRenameRefactoring(processor);
}
/**
@@ -343,15 +348,15 @@ public class RenameSupport {
private void ensureChecked() throws CoreException {
if (fPreCheckStatus == null) {
if (!fRefactoring.isApplicable()) {
- fPreCheckStatus= RefactoringStatus.createFatalErrorStatus(RenameMessages.RenameSupport_not_available);
+ fPreCheckStatus = RefactoringStatus.createFatalErrorStatus(RenameMessages.RenameSupport_not_available);
} else {
- fPreCheckStatus= new RefactoringStatus();
+ fPreCheckStatus = new RefactoringStatus();
}
}
}
private static void showInformation(Shell parent, RefactoringStatus status) {
- String message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL);
+ String message = status.getMessageMatchingSeverity(RefactoringStatus.FATAL);
MessageDialog.openInformation(parent, RenameMessages.RenameSupport_dialog_title, message);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/SourceFolderRenameParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/SourceFolderRenameParticipant.java
index 7693bb0ec74..8248e0e4ecd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/SourceFolderRenameParticipant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/SourceFolderRenameParticipant.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2009, 2015 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
@@ -44,7 +44,7 @@ public class SourceFolderRenameParticipant extends RenameParticipant {
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
- String newName = getArguments().getNewName();
+ String newName = getArguments().getNewName();
IPath newFolderPath = oldFolder.getFullPath().removeLastSegments(1).append(newName);
return new RenameCSourceFolderChange(oldFolder, newFolderPath);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java
index efad774e225..940a26df8e7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java
@@ -60,26 +60,26 @@ import org.eclipse.cdt.internal.formatter.scanner.Token;
* by location (comments, string-literals, etc.).
*/
public class TextSearchWrapper {
- public final static int SCOPE_FILE = 1;
- public final static int SCOPE_WORKSPACE = 2;
- public final static int SCOPE_RELATED_PROJECTS = 3;
- public final static int SCOPE_SINGLE_PROJECT = 4;
- public final static int SCOPE_WORKING_SET = 5;
+ public final static int SCOPE_FILE = 1;
+ public final static int SCOPE_WORKSPACE = 2;
+ public final static int SCOPE_RELATED_PROJECTS = 3;
+ public final static int SCOPE_SINGLE_PROJECT = 4;
+ public final static int SCOPE_WORKING_SET = 5;
- private static class SearchScope extends TextSearchScope {
- public static SearchScope newSearchScope(IFile[] files, IWorkingSet ws) {
- IAdaptable[] adaptables= ws.getElements();
- ArrayList<IResource> resources = new ArrayList<IResource>();
- for (int i = 0; i < adaptables.length; i++) {
- IAdaptable adaptable = adaptables[i];
- IResource resource= adaptable.getAdapter(IResource.class);
- if (resource != null) {
- resources.add(resource);
- }
- }
- return newSearchScope(files, resources.toArray(new IResource[resources.size()]));
+ private static class SearchScope extends TextSearchScope {
+ public static SearchScope newSearchScope(IFile[] files, IWorkingSet ws) {
+ IAdaptable[] adaptables = ws.getElements();
+ ArrayList<IResource> resources = new ArrayList<IResource>();
+ for (int i = 0; i < adaptables.length; i++) {
+ IAdaptable adaptable = adaptables[i];
+ IResource resource = adaptable.getAdapter(IResource.class);
+ if (resource != null) {
+ resources.add(resource);
+ }
+ }
+ return newSearchScope(files, resources.toArray(new IResource[resources.size()]));
}
-
+
public static SearchScope newSearchScope(IFile[] files, IResource[] roots) {
if (files != null) {
ArrayList<IResource> resources = new ArrayList<IResource>(files.length + roots.length);
@@ -97,299 +97,294 @@ public class TextSearchWrapper {
/**
* Checks is a file belongs to one of the given containers.
*/
- private static boolean isInForest(IResource file, IResource[] roots) {
- IPath filePath = file.getFullPath();
- for (IResource root : roots) {
- if (PathUtil.isPrefix(root.getFullPath(), filePath)) {
- return true;
- }
- }
+ private static boolean isInForest(IResource file, IResource[] roots) {
+ IPath filePath = file.getFullPath();
+ for (IResource root : roots) {
+ if (PathUtil.isPrefix(root.getFullPath(), filePath)) {
+ return true;
+ }
+ }
return false;
}
private IResource[] fRootResources;
- private ArrayList<Matcher> fFileMatcher= new ArrayList<Matcher>();
+ private ArrayList<Matcher> fFileMatcher = new ArrayList<Matcher>();
- private SearchScope(IResource[] roots) {
- fRootResources= roots;
- }
+ private SearchScope(IResource[] roots) {
+ fRootResources = roots;
+ }
@Override
public IResource[] getRoots() {
- return fRootResources;
- }
+ return fRootResources;
+ }
- @Override
+ @Override
public boolean contains(IResourceProxy proxy) {
- if (proxy.isDerived()) {
- return false;
- }
- if (proxy.getType() == IResource.FILE) {
- return containsFile(proxy.getName());
- }
- return true;
+ if (proxy.isDerived()) {
+ return false;
+ }
+ if (proxy.getType() == IResource.FILE) {
+ return containsFile(proxy.getName());
+ }
+ return true;
}
private boolean containsFile(String name) {
- for (Iterator<Matcher> iter = fFileMatcher.iterator(); iter.hasNext();) {
- Matcher matcher = iter.next();
- matcher.reset(name);
- if (matcher.matches()) {
- return true;
- }
- }
- return false;
- }
+ for (Iterator<Matcher> iter = fFileMatcher.iterator(); iter.hasNext();) {
+ Matcher matcher = iter.next();
+ matcher.reset(name);
+ if (matcher.matches()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void addFileNamePattern(String filePattern) {
+ Pattern p = Pattern.compile(filePatternToRegex(filePattern));
+ fFileMatcher.add(p.matcher("")); //$NON-NLS-1$
+ }
+
+ private String filePatternToRegex(String filePattern) {
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < filePattern.length(); i++) {
+ char c = filePattern.charAt(i);
+ switch (c) {
+ case '\\':
+ case '(':
+ case ')':
+ case '{':
+ case '}':
+ case '.':
+ case '[':
+ case ']':
+ case '$':
+ case '^':
+ case '+':
+ case '|':
+ result.append('\\');
+ result.append(c);
+ break;
+ case '?':
+ result.append('.');
+ break;
+ case '*':
+ result.append(".*"); //$NON-NLS-1$
+ break;
+ default:
+ result.append(c);
+ break;
+ }
+ }
+ return result.toString();
+ }
+ }
+
+ public TextSearchWrapper() {
+ }
+
+ private TextSearchScope createSearchScope(IFile[] files, int scope, IFile file, String workingSetName,
+ String[] patterns) {
+ switch (scope) {
+ case SCOPE_WORKSPACE:
+ return defineSearchScope(files, file.getWorkspace().getRoot(), patterns);
+ case SCOPE_SINGLE_PROJECT:
+ return defineSearchScope(files, file.getProject(), patterns);
+ case SCOPE_FILE:
+ return defineSearchScope(files, file, patterns);
+ case SCOPE_WORKING_SET: {
+ return defineWorkingSetAsSearchScope(files, workingSetName, patterns);
+ }
+ }
+ return defineRelatedProjectsAsSearchScope(files, file.getProject(), patterns);
+ }
- public void addFileNamePattern(String filePattern) {
- Pattern p= Pattern.compile(filePatternToRegex(filePattern));
- fFileMatcher.add(p.matcher("")); //$NON-NLS-1$
+ private TextSearchScope defineRelatedProjectsAsSearchScope(IFile[] files, IProject project, String[] patterns) {
+ HashSet<IProject> projects = new HashSet<IProject>();
+ LinkedList<IProject> workThrough = new LinkedList<IProject>();
+ workThrough.add(project);
+ while (!workThrough.isEmpty()) {
+ IProject proj = workThrough.removeLast();
+ if (projects.add(proj)) {
+ try {
+ workThrough.addAll(Arrays.asList(proj.getReferencedProjects()));
+ workThrough.addAll(Arrays.asList(proj.getReferencingProjects()));
+ } catch (CoreException e) {
+ // need to ignore
+ }
+ }
}
+ IResource[] roots = projects.toArray(new IResource[projects.size()]);
+ return defineSearchScope(files, roots, patterns);
+ }
- private String filePatternToRegex(String filePattern) {
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < filePattern.length(); i++) {
- char c = filePattern.charAt(i);
- switch (c) {
- case '\\':
- case '(':
- case ')':
- case '{':
- case '}':
- case '.':
- case '[':
- case ']':
- case '$':
- case '^':
- case '+':
- case '|':
- result.append('\\');
- result.append(c);
- break;
- case '?':
- result.append('.');
- break;
- case '*':
- result.append(".*"); //$NON-NLS-1$
- break;
- default:
- result.append(c);
- break;
- }
- }
- return result.toString();
- }
- }
+ private TextSearchScope defineWorkingSetAsSearchScope(IFile[] files, String workingSetName, String[] patterns) {
+ IWorkingSet workingSet = workingSetName != null
+ ? PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName)
+ : null;
+ SearchScope result = workingSet != null ? SearchScope.newSearchScope(files, workingSet)
+ : SearchScope.newSearchScope(files, new IResource[0]);
+ applyFilePatterns(result, patterns);
+ return result;
+ }
- public TextSearchWrapper() {
- }
-
- private TextSearchScope createSearchScope(IFile[] files, int scope, IFile file,
- String workingSetName, String[] patterns) {
- switch (scope) {
- case SCOPE_WORKSPACE:
- return defineSearchScope(files, file.getWorkspace().getRoot(), patterns);
- case SCOPE_SINGLE_PROJECT:
- return defineSearchScope(files, file.getProject(), patterns);
- case SCOPE_FILE:
- return defineSearchScope(files, file, patterns);
- case SCOPE_WORKING_SET: {
- return defineWorkingSetAsSearchScope(files, workingSetName, patterns);
- }
- }
- return defineRelatedProjectsAsSearchScope(files, file.getProject(), patterns);
- }
-
- private TextSearchScope defineRelatedProjectsAsSearchScope(IFile[] files, IProject project, String[] patterns) {
- HashSet<IProject> projects= new HashSet<IProject>();
- LinkedList<IProject> workThrough= new LinkedList<IProject>();
- workThrough.add(project);
- while (!workThrough.isEmpty()) {
- IProject proj= workThrough.removeLast();
- if (projects.add(proj)) {
- try {
- workThrough.addAll(Arrays.asList(proj.getReferencedProjects()));
- workThrough.addAll(Arrays.asList(proj.getReferencingProjects()));
- } catch (CoreException e) {
- // need to ignore
- }
- }
- }
- IResource[] roots= projects.toArray(new IResource[projects.size()]);
- return defineSearchScope(files, roots, patterns);
- }
+ private void applyFilePatterns(SearchScope scope, String[] patterns) {
+ for (String pattern : patterns) {
+ scope.addFileNamePattern(pattern);
+ }
+ }
+
+ private TextSearchScope defineSearchScope(IFile[] files, IResource root, String[] patterns) {
+ SearchScope result = SearchScope.newSearchScope(files, new IResource[] { root });
+ applyFilePatterns(result, patterns);
+ return result;
+ }
- private TextSearchScope defineWorkingSetAsSearchScope(IFile[] files, String workingSetName, String[] patterns) {
- IWorkingSet workingSet = workingSetName != null ?
- PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName) :
- null;
- SearchScope result= workingSet != null ?
- SearchScope.newSearchScope(files, workingSet) :
- SearchScope.newSearchScope(files, new IResource[0]);
+ private TextSearchScope defineSearchScope(IFile[] files, IResource[] roots, String[] patterns) {
+ SearchScope result = SearchScope.newSearchScope(files, roots);
applyFilePatterns(result, patterns);
return result;
- }
+ }
- private void applyFilePatterns(SearchScope scope, String[] patterns) {
- for (String pattern : patterns) {
- scope.addFileNamePattern(pattern);
- }
- }
+ /**
+ * Searches for a given word.
+ *
+ * @param filesToSearch The files to search.
+ * @param scope Together with {@code file} and {@code workingSet} defines set of additional
+ * file to search. One of SCOPE_FILE, SCOPE_WORKSPACE, SCOPE_RELATED_PROJECTS,
+ * SCOPE_SINGLE_PROJECT, or SCOPE_WORKING_SET.
+ * @param scopeAnchor The file used as an anchor for the scope.
+ * @param workingSet The name of a working set. Ignored if {@code scope} is not
+ * SCOPE_WORKING_SET.
+ * @param patterns File name patterns.
+ * @param word The word to search for.
+ * @param monitor A progress monitor.
+ * @param target The list that gets populated with search results.
+ */
+ public IStatus searchWord(IFile[] filesToSearch, int scope, IFile scopeAnchor, String workingSet, String[] patterns,
+ String word, IProgressMonitor monitor, final List<CRefactoringMatch> target) {
+ int startPos = target.size();
+ TextSearchEngine engine = TextSearchEngine.create();
+ StringBuilder searchPattern = new StringBuilder(word.length() + 8);
+ searchPattern.append("\\b"); //$NON-NLS-1$
+ searchPattern.append("\\Q"); //$NON-NLS-1$
+ searchPattern.append(word);
+ searchPattern.append("\\E"); //$NON-NLS-1$
+ searchPattern.append("\\b"); //$NON-NLS-1$
- private TextSearchScope defineSearchScope(IFile[] files, IResource root, String[] patterns) {
- SearchScope result= SearchScope.newSearchScope(files, new IResource[] { root });
- applyFilePatterns(result, patterns);
- return result;
- }
-
- private TextSearchScope defineSearchScope(IFile[] files, IResource[] roots, String[] patterns) {
- SearchScope result= SearchScope.newSearchScope(files, roots);
- applyFilePatterns(result, patterns);
- return result;
- }
-
- /**
- * Searches for a given word.
- *
- * @param filesToSearch The files to search.
- * @param scope Together with {@code file} and {@code workingSet} defines set of additional
- * file to search. One of SCOPE_FILE, SCOPE_WORKSPACE, SCOPE_RELATED_PROJECTS,
- * SCOPE_SINGLE_PROJECT, or SCOPE_WORKING_SET.
- * @param scopeAnchor The file used as an anchor for the scope.
- * @param workingSet The name of a working set. Ignored if {@code scope} is not
- * SCOPE_WORKING_SET.
- * @param patterns File name patterns.
- * @param word The word to search for.
- * @param monitor A progress monitor.
- * @param target The list that gets populated with search results.
- */
- public IStatus searchWord(IFile[] filesToSearch, int scope, IFile scopeAnchor, String workingSet,
- String[] patterns, String word, IProgressMonitor monitor,
- final List<CRefactoringMatch> target) {
- int startPos= target.size();
- TextSearchEngine engine= TextSearchEngine.create();
- StringBuilder searchPattern= new StringBuilder(word.length() + 8);
- searchPattern.append("\\b"); //$NON-NLS-1$
- searchPattern.append("\\Q"); //$NON-NLS-1$
- searchPattern.append(word);
- searchPattern.append("\\E"); //$NON-NLS-1$
- searchPattern.append("\\b"); //$NON-NLS-1$
+ Pattern pattern = Pattern.compile(searchPattern.toString());
- Pattern pattern= Pattern.compile(searchPattern.toString());
-
- TextSearchScope searchscope= createSearchScope(filesToSearch, scope, scopeAnchor, workingSet, patterns);
- TextSearchRequestor requestor= new TextSearchRequestor() {
- @Override
+ TextSearchScope searchscope = createSearchScope(filesToSearch, scope, scopeAnchor, workingSet, patterns);
+ TextSearchRequestor requestor = new TextSearchRequestor() {
+ @Override
public boolean acceptPatternMatch(TextSearchMatchAccess access) {
- IFile file= access.getFile();
- ICElement elem= CoreModel.getDefault().create(file);
- if (elem instanceof ITranslationUnit) {
- target.add(new CRefactoringMatch(file,
- access.getMatchOffset(), access.getMatchLength(), 0));
- }
- return true;
- }
- };
- IStatus result= engine.search(searchscope, requestor, pattern,
- new SubProgressMonitor(monitor, 95));
- categorizeMatches(target.subList(startPos, target.size()),
- new SubProgressMonitor(monitor, 5));
+ IFile file = access.getFile();
+ ICElement elem = CoreModel.getDefault().create(file);
+ if (elem instanceof ITranslationUnit) {
+ target.add(new CRefactoringMatch(file, access.getMatchOffset(), access.getMatchLength(), 0));
+ }
+ return true;
+ }
+ };
+ IStatus result = engine.search(searchscope, requestor, pattern, new SubProgressMonitor(monitor, 95));
+ categorizeMatches(target.subList(startPos, target.size()), new SubProgressMonitor(monitor, 5));
+
+ return result;
+ }
- return result;
- }
-
- public void categorizeMatches(List<CRefactoringMatch> matches, IProgressMonitor monitor) {
- monitor.beginTask(RenameMessages.TextSearch_monitor_categorizeMatches, matches.size());
- IFile file= null;
- ArrayList<int[]> locations= null;
- for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
- CRefactoringMatch match = iter.next();
- IFile tfile= match.getFile();
- if (file == null || !file.equals(tfile)) {
- file= tfile;
- locations= new ArrayList<int[]>();
- computeLocations(file, locations);
- }
- match.setLocation(findLocation(match, locations));
- monitor.worked(1);
- }
- }
+ public void categorizeMatches(List<CRefactoringMatch> matches, IProgressMonitor monitor) {
+ monitor.beginTask(RenameMessages.TextSearch_monitor_categorizeMatches, matches.size());
+ IFile file = null;
+ ArrayList<int[]> locations = null;
+ for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
+ CRefactoringMatch match = iter.next();
+ IFile tfile = match.getFile();
+ if (file == null || !file.equals(tfile)) {
+ file = tfile;
+ locations = new ArrayList<int[]>();
+ computeLocations(file, locations);
+ }
+ match.setLocation(findLocation(match, locations));
+ monitor.worked(1);
+ }
+ }
- final static Comparator<int[]> COMPARE_FIRST_INTEGER= new Comparator<int[]>() {
- @Override
+ final static Comparator<int[]> COMPARE_FIRST_INTEGER = new Comparator<int[]>() {
+ @Override
public int compare(int[] o1, int[] o2) {
- return (o1)[0] - (o2)[0];
- }
- };
+ return (o1)[0] - (o2)[0];
+ }
+ };
- private int findLocation(CRefactoringMatch match, ArrayList<int[]> states) {
- int pos = Collections.binarySearch(states, new int[] {match.getOffset()}, COMPARE_FIRST_INTEGER);
- if (pos < 0) {
- pos= -pos - 2;
- if (pos < 0) {
- pos = 0;
- }
- }
- int endOffset= match.getOffset() + match.getLength();
- int location= 0;
- while (pos < states.size()) {
- int[] info= states.get(pos);
- if (info[0] >= endOffset) {
- break;
- }
- location |= info[1];
- pos++;
- }
- return location;
- }
+ private int findLocation(CRefactoringMatch match, ArrayList<int[]> states) {
+ int pos = Collections.binarySearch(states, new int[] { match.getOffset() }, COMPARE_FIRST_INTEGER);
+ if (pos < 0) {
+ pos = -pos - 2;
+ if (pos < 0) {
+ pos = 0;
+ }
+ }
+ int endOffset = match.getOffset() + match.getLength();
+ int location = 0;
+ while (pos < states.size()) {
+ int[] info = states.get(pos);
+ if (info[0] >= endOffset) {
+ break;
+ }
+ location |= info[1];
+ pos++;
+ }
+ return location;
+ }
- private void computeLocations(IFile file, ArrayList<int[]> locations) {
- Reader reader;
- SimpleScanner scanner= new SimpleScanner();
- try {
- reader = new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()));
- } catch (CoreException e) {
- return;
- } catch (UnsupportedEncodingException e) {
- return;
- }
- try {
- scanner.initialize(reader, null);
- scanner.setReuseToken(true);
- Token token;
- int lastState= 0;
- while ((token= scanner.nextToken()) != null) {
- int state= CRefactory.OPTION_IN_CODE_REFERENCES;
- switch (token.getType()) {
- case Token.tLINECOMMENT:
- case Token.tBLOCKCOMMENT:
- state= CRefactory.OPTION_IN_COMMENT;
- break;
- case Token.tSTRING:
- case Token.tLSTRING:
- case Token.tCHAR:
- state= CRefactory.OPTION_IN_STRING_LITERAL;
- break;
- case Token.tPREPROCESSOR:
- state= CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE;
- break;
- case Token.tPREPROCESSOR_DEFINE:
- state= CRefactory.OPTION_IN_MACRO_DEFINITION;
- break;
- case Token.tPREPROCESSOR_INCLUDE:
- state= CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
- break;
- }
- if (state != lastState) {
- locations.add(new int[] { token.getOffset(), state });
- lastState= state;
- }
- }
- } finally {
- try {
- reader.close();
- } catch (IOException e) {
- }
- }
- }
+ private void computeLocations(IFile file, ArrayList<int[]> locations) {
+ Reader reader;
+ SimpleScanner scanner = new SimpleScanner();
+ try {
+ reader = new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()));
+ } catch (CoreException e) {
+ return;
+ } catch (UnsupportedEncodingException e) {
+ return;
+ }
+ try {
+ scanner.initialize(reader, null);
+ scanner.setReuseToken(true);
+ Token token;
+ int lastState = 0;
+ while ((token = scanner.nextToken()) != null) {
+ int state = CRefactory.OPTION_IN_CODE_REFERENCES;
+ switch (token.getType()) {
+ case Token.tLINECOMMENT:
+ case Token.tBLOCKCOMMENT:
+ state = CRefactory.OPTION_IN_COMMENT;
+ break;
+ case Token.tSTRING:
+ case Token.tLSTRING:
+ case Token.tCHAR:
+ state = CRefactory.OPTION_IN_STRING_LITERAL;
+ break;
+ case Token.tPREPROCESSOR:
+ state = CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE;
+ break;
+ case Token.tPREPROCESSOR_DEFINE:
+ state = CRefactory.OPTION_IN_MACRO_DEFINITION;
+ break;
+ case Token.tPREPROCESSOR_INCLUDE:
+ state = CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
+ break;
+ }
+ if (state != lastState) {
+ locations.add(new int[] { token.getOffset(), state });
+ lastState = state;
+ }
+ }
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/reorg/RefactoringModifications.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/reorg/RefactoringModifications.java
index a801cf09f1b..c6b1894c247 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/reorg/RefactoringModifications.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/reorg/RefactoringModifications.java
@@ -27,15 +27,15 @@ public abstract class RefactoringModifications {
private ResourceModifications fResourceModifications;
public RefactoringModifications() {
- fResourceModifications= new ResourceModifications();
+ fResourceModifications = new ResourceModifications();
}
public ResourceModifications getResourceModifications() {
return fResourceModifications;
}
- public abstract RefactoringParticipant[] loadParticipants(RefactoringStatus status,
- RefactoringProcessor owner, String[] natures, SharableParticipants shared);
+ public abstract RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner,
+ String[] natures, SharableParticipants shared);
public abstract void buildDelta(IResourceChangeDescriptionFactory builder);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java
index 5324f83c7d4..80df507c6c6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -54,16 +54,14 @@ public class DeclaratorFinder {
return foundDeclarator.getName();
}
- private IASTFunctionDeclarator findDeclaratorInSelection(ITextSelection selection,
- IASTTranslationUnit unit) {
+ private IASTFunctionDeclarator findDeclaratorInSelection(ITextSelection selection, IASTTranslationUnit unit) {
IASTNodeSelector nodeSelector = unit.getNodeSelector(null);
- IASTNode firstNodeInsideSelection =
- nodeSelector.findFirstContainedNode(selection.getOffset(), selection.getLength());
+ IASTNode firstNodeInsideSelection = nodeSelector.findFirstContainedNode(selection.getOffset(),
+ selection.getLength());
IASTFunctionDeclarator declarator = findDeclaratorInAncestors(firstNodeInsideSelection);
-
+
if (declarator == null) {
- firstNodeInsideSelection = nodeSelector.findEnclosingNode(
- selection.getOffset(), selection.getLength());
+ firstNodeInsideSelection = nodeSelector.findEnclosingNode(selection.getOffset(), selection.getLength());
declarator = findDeclaratorInAncestors(firstNodeInsideSelection);
}
return declarator;
@@ -101,7 +99,7 @@ public class DeclaratorFinder {
if (declarators.length > 1) {
throw new NotSupportedException(Messages.DeclaratorFinder_MultipleDeclarators);
}
-
+
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator)
return (IASTFunctionDeclarator) declarators[0];
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRefactoringStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRefactoringStrategy.java
index 00e75dd47a3..b820a10cbc7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRefactoringStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRefactoringStrategy.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/InsertionPointFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/InsertionPointFinder.java
index b66a25f5ca4..5d1c2000d7f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/InsertionPointFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/InsertionPointFinder.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Martin Schwab & Thomas Kallenberg - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Martin Schwab & Thomas Kallenberg - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
@@ -37,26 +37,26 @@ public class InsertionPointFinder {
private static ArrayList<ICPPASTFunctionDeclarator> allafterdeclarations;
private static ArrayList<ICPPASTFunctionDefinition> alldefinitionsoutside;
private static IASTDeclaration position;
-
- public static IASTDeclaration findInsertionPoint(IASTTranslationUnit classunit,
- IASTTranslationUnit functiondefunit, IASTFunctionDeclarator funcDecl) {
+
+ public static IASTDeclaration findInsertionPoint(IASTTranslationUnit classunit, IASTTranslationUnit functiondefunit,
+ IASTFunctionDeclarator funcDecl) {
position = null;
findAllDeclarationsAfterInClass(classunit, funcDecl);
findAllDefinitionsoutSideClass(functiondefunit);
findRightPlace();
return position;
}
-
+
private static void findRightPlace() {
if (allafterdeclarations == null || alldefinitionsoutside == null)
return;
- for(ICPPASTFunctionDeclarator decl: allafterdeclarations) {
+ for (ICPPASTFunctionDeclarator decl : allafterdeclarations) {
if (decl.getName() == null) {
// Could be a lambda expression
continue;
}
String decl_name = decl.getName().toString();
- for(ICPPASTFunctionDefinition def: alldefinitionsoutside) {
+ for (ICPPASTFunctionDefinition def : alldefinitionsoutside) {
String def_name = null;
IASTName name = def.getDeclarator().getName();
if (name != null)
@@ -80,7 +80,7 @@ public class InsertionPointFinder {
if (klass != null)
allafterdeclarations = getDeclarationsInClass(klass, funcDecl);
}
-
+
/**
* @param ast the translation unit where to find the definitions
*/
@@ -90,72 +90,71 @@ public class InsertionPointFinder {
alldefinitionsoutside = definitions;
return;
}
- ast.accept(
- new ASTVisitor() {
- {
- shouldVisitDeclarations = true;
- }
-
- @Override
- public int visit(IASTDeclaration declaration) {
- if (declaration instanceof ICPPASTFunctionDefinition) {
- if (declaration.getParent() != null &&
- ASTQueries.findAncestorWithType(declaration, CPPASTCompositeTypeSpecifier.class) != null) {
- return PROCESS_CONTINUE;
- }
- definitions.add((ICPPASTFunctionDefinition) declaration);
+ ast.accept(new ASTVisitor() {
+ {
+ shouldVisitDeclarations = true;
+ }
+
+ @Override
+ public int visit(IASTDeclaration declaration) {
+ if (declaration instanceof ICPPASTFunctionDefinition) {
+ if (declaration.getParent() != null && ASTQueries.findAncestorWithType(declaration,
+ CPPASTCompositeTypeSpecifier.class) != null) {
+ return PROCESS_CONTINUE;
}
- return super.visit(declaration);
+ definitions.add((ICPPASTFunctionDefinition) declaration);
}
- });
+ return super.visit(declaration);
+ }
+ });
alldefinitionsoutside = definitions;
}
- private static ArrayList<ICPPASTFunctionDeclarator> getDeclarationsInClass(ICPPASTCompositeTypeSpecifier klass, final IASTFunctionDeclarator selected) {
+ private static ArrayList<ICPPASTFunctionDeclarator> getDeclarationsInClass(ICPPASTCompositeTypeSpecifier klass,
+ final IASTFunctionDeclarator selected) {
final ArrayList<ICPPASTFunctionDeclarator> declarations = new ArrayList<ICPPASTFunctionDeclarator>();
-
- klass.accept(
- new ASTVisitor() {
- {
- shouldVisitDeclarators = true;
- }
-
- boolean got = false;
- @Override
- public int visit(IASTDeclarator declarator) {
- if (declarator instanceof ICPPASTFunctionDeclarator) {
- if (((ICPPASTFunctionDeclarator) declarator) == selected) {
- got = true;
- }
- if (got) {
- declarations.add((ICPPASTFunctionDeclarator) declarator);
- }
+
+ klass.accept(new ASTVisitor() {
+ {
+ shouldVisitDeclarators = true;
+ }
+
+ boolean got = false;
+
+ @Override
+ public int visit(IASTDeclarator declarator) {
+ if (declarator instanceof ICPPASTFunctionDeclarator) {
+ if (((ICPPASTFunctionDeclarator) declarator) == selected) {
+ got = true;
+ }
+ if (got) {
+ declarations.add((ICPPASTFunctionDeclarator) declarator);
}
- return super.visit(declarator);
}
- });
-
+ return super.visit(declarator);
+ }
+ });
+
return declarations;
}
private static ICPPASTCompositeTypeSpecifier getklass(IASTTranslationUnit unit) {
final Container<ICPPASTCompositeTypeSpecifier> result = new Container<ICPPASTCompositeTypeSpecifier>();
- unit.accept(
- new ASTVisitor() {
- {
- shouldVisitDeclSpecifiers = true;
- }
-
- @Override
- public int visit(IASTDeclSpecifier declSpec) {
- if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
- result.setObject((ICPPASTCompositeTypeSpecifier) declSpec);
- return PROCESS_ABORT;
- }
- return super.visit(declSpec);
+ unit.accept(new ASTVisitor() {
+ {
+ shouldVisitDeclSpecifiers = true;
+ }
+
+ @Override
+ public int visit(IASTDeclSpecifier declSpec) {
+ if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
+ result.setObject((ICPPASTCompositeTypeSpecifier) declSpec);
+ return PROCESS_ABORT;
}
- });
+ return super.visit(declSpec);
+ }
+ });
return result.getObject();
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java
index 2816425bd92..0f317b001d1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2015 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Emanuel Graf IFS - initial API and implementation
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSupportedException.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSupportedException.java
index e0c2215c619..947040dbc67 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSupportedException.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSupportedException.java
@@ -1,23 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Martin Schwab & Thomas Kallenberg - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Martin Schwab & Thomas Kallenberg - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
/**
* Thrown when the developer had no time to implement a special case the user
* tried to refactor.
- *
+ *
*/
public class NotSupportedException extends RuntimeException {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/RefactoringJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/RefactoringJob.java
index 25b49ea2a5d..1d7bcadb584 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/RefactoringJob.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/RefactoringJob.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -34,18 +34,18 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContext;
class RefactoringJob extends Job {
public final static Object FAMILY_TOGGLE_DEFINITION = new Object();
private final ToggleRefactoring refactoring;
-
+
RefactoringJob(ToggleRefactoring refactoring) {
super("Toggle Function Definition code automation"); //$NON-NLS-1$
this.refactoring = refactoring;
setPriority(Job.SHORT);
}
-
+
@Override
public boolean belongsTo(Object family) {
return family == FAMILY_TOGGLE_DEFINITION;
}
-
+
@Override
protected IStatus run(IProgressMonitor monitor) {
CRefactoringContext context = new CRefactoringContext(refactoring);
@@ -56,7 +56,8 @@ class RefactoringJob extends Job {
try {
RefactoringStatus status = refactoring.checkAllConditions(monitor);
if (status.hasFatalError())
- return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, status.getMessageMatchingSeverity(RefactoringStatus.ERROR));
+ return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+ status.getMessageMatchingSeverity(RefactoringStatus.ERROR));
change = refactoring.createChange(monitor);
change.initializeValidationData(monitor);
if (!change.isValid(monitor).isOK()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java
index 0b81136e971..9cea37bbd8e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
+ * SPDX-License-Identifier: EPL-2.0
+ *
* Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
@@ -48,8 +48,7 @@ public class ToggleFileCreator {
change.perform(new NullProgressMonitor());
return (IFile) change.getModifiedElement();
} catch (CoreException e) {
- throw new NotSupportedException(NLS.bind(Messages.ToggleFileCreator_CanNotCreateNewFile,
- path.toString()));
+ throw new NotSupportedException(NLS.bind(Messages.ToggleFileCreator_CanNotCreateNewFile, path.toString()));
}
}
@@ -68,7 +67,7 @@ public class ToggleFileCreator {
} else {
functionName = context.getDefinition().getDeclarator().getRawSignature();
}
- answer[0] = MessageDialog.openQuestion(shell, Messages.ToggleFileCreator_NewImplFile,
+ answer[0] = MessageDialog.openQuestion(shell, Messages.ToggleFileCreator_NewImplFile,
NLS.bind(Messages.ToggleFileCreator_CreateNewFilePrompt, getNewFileName(), functionName));
}
};
@@ -77,13 +76,14 @@ public class ToggleFileCreator {
}
public String getIncludeStatement() {
- return "#include \"" + ToggleNodeHelper.getFilenameWithoutExtension(getNewFileName()) + ".h\"\n"; //$NON-NLS-1$//$NON-NLS-2$
+ return "#include \"" + ToggleNodeHelper.getFilenameWithoutExtension(getNewFileName()) + ".h\"\n"; //$NON-NLS-1$//$NON-NLS-2$
}
-
+
private String getNewFileName() {
- return ToggleNodeHelper.getFilenameWithoutExtension(context.getSelectionFile().getFullPath().toString()) + ending;
+ return ToggleNodeHelper.getFilenameWithoutExtension(context.getSelectionFile().getFullPath().toString())
+ + ending;
}
-
+
private String getPath() {
String result = context.getSelectionFile().getFullPath().toOSString();
return result.replaceAll("(\\w)*\\.(\\w)*", EMPTY_STRING); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromClassToInHeaderStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromClassToInHeaderStrategy.java
index 05bab37e529..f43168104e7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromClassToInHeaderStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromClassToInHeaderStrategy.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
@@ -46,8 +46,7 @@ public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStra
}
private boolean isInClass(IASTNode node) {
- return node != null &&
- ASTQueries.findAncestorWithType(node, ICPPASTCompositeTypeSpecifier.class) != null;
+ return node != null && ASTQueries.findAncestorWithType(node, ICPPASTCompositeTypeSpecifier.class) != null;
}
@Override
@@ -57,15 +56,14 @@ public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStra
IASTSimpleDeclaration newDeclaration = getNewDeclaration();
ASTRewrite rewriter = replaceDefinitionWithDeclaration(modifications, newDeclaration);
IASTNode insertion_point = getInsertionPoint(parentNamespace);
- rewriter.insertBefore(parentNamespace,
- insertion_point, newDefinition, infoText);
+ rewriter.insertBefore(parentNamespace, insertion_point, newDefinition, infoText);
}
private IASTNode getNewDefinition(IASTNode parentNamespace) {
- IASTNode newDefinition = ToggleNodeHelper.getQualifiedNameDefinition(
- context.getDefinition(), context.getDefinitionAST(), parentNamespace);
- ((IASTFunctionDefinition) newDefinition).setBody(
- context.getDefinition().getBody().copy(CopyStyle.withLocations));
+ IASTNode newDefinition = ToggleNodeHelper.getQualifiedNameDefinition(context.getDefinition(),
+ context.getDefinitionAST(), parentNamespace);
+ ((IASTFunctionDefinition) newDefinition)
+ .setBody(context.getDefinition().getBody().copy(CopyStyle.withLocations));
if (newDefinition instanceof ICPPASTFunctionWithTryBlock) {
ICPPASTFunctionWithTryBlock newTryFun = (ICPPASTFunctionWithTryBlock) newDefinition;
ICPPASTFunctionWithTryBlock oldTryFun = (ICPPASTFunctionWithTryBlock) context.getDefinition();
@@ -73,8 +71,8 @@ public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStra
newTryFun.addCatchHandler(catchH.copy(CopyStyle.withLocations));
}
}
- ICPPASTTemplateDeclaration templdecl = ToggleNodeHelper.getTemplateDeclaration(
- context.getDefinition(), (IASTFunctionDefinition) newDefinition);
+ ICPPASTTemplateDeclaration templdecl = ToggleNodeHelper.getTemplateDeclaration(context.getDefinition(),
+ (IASTFunctionDefinition) newDefinition);
if (templdecl != null) {
newDefinition = templdecl;
}
@@ -83,8 +81,8 @@ public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStra
}
private IASTNode getParentNamespace() {
- IASTNode parentNamespace =
- ASTQueries.findAncestorWithType(context.getDefinition(), ICPPASTNamespaceDefinition.class);
+ IASTNode parentNamespace = ASTQueries.findAncestorWithType(context.getDefinition(),
+ ICPPASTNamespaceDefinition.class);
if (parentNamespace == null)
parentNamespace = context.getDefinitionAST();
return parentNamespace;
@@ -92,28 +90,24 @@ public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStra
private IASTNode getInsertionPoint(IASTNode parentNamespace) {
IASTTranslationUnit unit = parentNamespace.getTranslationUnit();
- IASTNode insertion_point = InsertionPointFinder.findInsertionPoint(
- unit, unit, context.getDefinition().getDeclarator());
+ IASTNode insertion_point = InsertionPointFinder.findInsertionPoint(unit, unit,
+ context.getDefinition().getDeclarator());
return insertion_point;
}
- private ASTRewrite replaceDefinitionWithDeclaration(
- ModificationCollector modifications,
+ private ASTRewrite replaceDefinitionWithDeclaration(ModificationCollector modifications,
IASTSimpleDeclaration newDeclaration) {
- ASTRewrite rewriter = modifications.rewriterForTranslationUnit(
- context.getDefinitionAST());
+ ASTRewrite rewriter = modifications.rewriterForTranslationUnit(context.getDefinitionAST());
rewriter.replace(context.getDefinition(), newDeclaration, infoText);
return rewriter;
}
private IASTSimpleDeclaration getNewDeclaration() {
INodeFactory factory = context.getDefinitionAST().getASTNodeFactory();
- IASTDeclSpecifier newDeclSpecifier =
- context.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations);
+ IASTDeclSpecifier newDeclSpecifier = context.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations);
newDeclSpecifier.setInline(false);
IASTSimpleDeclaration newDeclaration = factory.newSimpleDeclaration(newDeclSpecifier);
- IASTFunctionDeclarator newDeclarator =
- context.getDefinition().getDeclarator().copy(CopyStyle.withLocations);
+ IASTFunctionDeclarator newDeclarator = context.getDefinition().getDeclarator().copy(CopyStyle.withLocations);
newDeclaration.addDeclarator(newDeclarator);
newDeclaration.setParent(context.getDefinition().getParent());
return newDeclaration;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java
index 816c5173b2e..354fa091336 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
@@ -56,16 +56,16 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
private boolean isFreeFunction(IASTFunctionDefinition definition) {
return definition.getDeclarator().getName() instanceof ICPPASTQualifiedName;
}
-
+
@Override
public void run(ModificationCollector modifications) throws CoreException {
newFileCheck();
ASTRewrite implAst = modifications.rewriterForTranslationUnit(context.getDefinitionAST());
- List<IASTComment>leadingComments = implAst.getComments(context.getDefinition(), CommentPosition.leading);
+ List<IASTComment> leadingComments = implAst.getComments(context.getDefinition(), CommentPosition.leading);
removeDefinitionFromImplementation(implAst);
if (includeNode != null) {
- implAst.insertBefore(context.getDefinitionAST(),
- context.getDefinitionAST().getChildren()[0], includeNode, infoText);
+ implAst.insertBefore(context.getDefinitionAST(), context.getDefinitionAST().getChildren()[0], includeNode,
+ infoText);
}
if (context.getDeclarationAST() != null) {
addDefinitionToClass(modifications, leadingComments);
@@ -87,7 +87,8 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
otherAst = context.getAST(file, null);
includeNode = new ASTLiteralNode(fileCreator.getIncludeStatement() + "\n\n"); //$NON-NLS-1$
} else {
- throw new NotSupportedException(Messages.ToggleFromImplementationToHeaderOrClassStrategy_CanNotCreateNewFile);
+ throw new NotSupportedException(
+ Messages.ToggleFromImplementationToHeaderOrClassStrategy_CanNotCreateNewFile);
}
}
}
@@ -102,27 +103,25 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
newDefinition.setParent(otherAst);
headerRewrite.insertBefore(otherAst.getTranslationUnit(), null, newDefinition, infoText);
restoreBody(headerRewrite, newDefinition, modifications);
- for (IASTComment comment : leadingComments) {
+ for (IASTComment comment : leadingComments) {
headerRewrite.addComment(newDefinition, comment, CommentPosition.leading);
}
}
private void addDefinitionToClass(ModificationCollector modifications, List<IASTComment> leadingComments) {
- ASTRewrite headerRewrite = modifications.rewriterForTranslationUnit(
- context.getDeclarationAST());
- IASTFunctionDefinition newDefinition = ToggleNodeHelper.createInClassDefinition(
- context.getDeclaration(), context.getDefinition(), context.getDeclarationAST());
+ ASTRewrite headerRewrite = modifications.rewriterForTranslationUnit(context.getDeclarationAST());
+ IASTFunctionDefinition newDefinition = ToggleNodeHelper.createInClassDefinition(context.getDeclaration(),
+ context.getDefinition(), context.getDeclarationAST());
newDefinition.setParent(getParent());
restoreBody(headerRewrite, newDefinition, modifications);
headerRewrite.replace(context.getDeclaration().getParent(), newDefinition, infoText);
- for (IASTComment comment : leadingComments) {
+ for (IASTComment comment : leadingComments) {
headerRewrite.addComment(newDefinition, comment, CommentPosition.leading);
}
}
private IASTNode getParent() {
- IASTNode parent = ASTQueries.findAncestorWithType(context.getDefinition(),
- ICPPASTCompositeTypeSpecifier.class);
+ IASTNode parent = ASTQueries.findAncestorWithType(context.getDefinition(), ICPPASTCompositeTypeSpecifier.class);
IASTNode parentnode = null;
if (parent != null) {
parentnode = parent;
@@ -136,18 +135,19 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
ModificationCollector modifications) {
IASTFunctionDefinition oldDefinition = context.getDefinition();
newDefinition.setBody(oldDefinition.getBody().copy(CopyStyle.withLocations));
-
- if (newDefinition instanceof ICPPASTFunctionWithTryBlock &&
- oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
+
+ if (newDefinition instanceof ICPPASTFunctionWithTryBlock
+ && oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
ICPPASTFunctionWithTryBlock newTryDef = (ICPPASTFunctionWithTryBlock) newDefinition;
ICPPASTFunctionWithTryBlock oldTryDef = (ICPPASTFunctionWithTryBlock) oldDefinition;
for (ICPPASTCatchHandler handler : oldTryDef.getCatchHandlers()) {
newTryDef.addCatchHandler(handler.copy(CopyStyle.withLocations));
}
}
- copyAllCommentsToNewLocation(oldDefinition, modifications.rewriterForTranslationUnit(oldDefinition.getTranslationUnit()), headerRewrite);
+ copyAllCommentsToNewLocation(oldDefinition,
+ modifications.rewriterForTranslationUnit(oldDefinition.getTranslationUnit()), headerRewrite);
}
-
+
private void copyAllCommentsToNewLocation(IASTNode node, final ASTRewrite oldRw, final ASTRewrite newRw) {
//Bug 486036: In case oldRw == newRw (same file), there's no need to copy anything, the comments will follow along.
if (oldRw == newRw) {
@@ -155,7 +155,7 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
}
node.accept(new CPPASTAllVisitor() {
@Override
- public int visitAll(IASTNode node){
+ public int visitAll(IASTNode node) {
copyComments(oldRw, newRw, node, CommentPosition.leading);
copyComments(oldRw, newRw, node, CommentPosition.trailing);
copyComments(oldRw, newRw, node, CommentPosition.freestanding);
@@ -182,7 +182,8 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
}
private ICPPASTNamespaceDefinition findOutermostNonemptyNamspace() {
- List<ICPPASTNamespaceDefinition> namespaces = ToggleNodeHelper.findSurroundingNamespaces(context.getDefinition());
+ List<ICPPASTNamespaceDefinition> namespaces = ToggleNodeHelper
+ .findSurroundingNamespaces(context.getDefinition());
Collections.reverse(namespaces);
IASTFunctionDefinition definition = context.getDefinition();
ICPPASTNamespaceDefinition ns = null;
@@ -196,8 +197,7 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
return ns;
}
- private boolean isSingleElementInNamespace(ICPPASTNamespaceDefinition ns,
- IASTFunctionDefinition definition) {
+ private boolean isSingleElementInNamespace(ICPPASTNamespaceDefinition ns, IASTFunctionDefinition definition) {
return ns.getChildren().length == 2 && (ns.contains(definition));
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToClassStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToClassStrategy.java
index 6097187df7d..3f726fb4f72 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToClassStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToClassStrategy.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Martin Schwab & Thomas Kallenberg - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Martin Schwab & Thomas Kallenberg - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
@@ -44,16 +44,16 @@ public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStra
public ToggleFromInHeaderToClassStrategy(ToggleRefactoringContext context) {
if (isFreeFunction(context))
- throw new NotSupportedException(Messages.ToggleFromInHeaderToClassStrategy_CanNotToggleTemplateFreeFunction);
+ throw new NotSupportedException(
+ Messages.ToggleFromInHeaderToClassStrategy_CanNotToggleTemplateFreeFunction);
this.context = context;
- this.infoText = new TextEditGroup(Messages.EditGroupName);
+ this.infoText = new TextEditGroup(Messages.EditGroupName);
}
private boolean isFreeFunction(ToggleRefactoringContext context) {
- return isNotInsideAClass(context.getDefinition().getDeclarator(),
- context.getDeclaration());
+ return isNotInsideAClass(context.getDefinition().getDeclarator(), context.getDeclaration());
}
-
+
boolean isNotInsideAClass(IASTFunctionDeclarator declarator, IASTFunctionDeclarator backup) {
if (declarator.getName() instanceof ICPPASTQualifiedName) {
declarator = backup;
@@ -66,17 +66,16 @@ public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStra
ASTRewrite rewriter = removeDefinition(modifications);
IASTFunctionDefinition newDefinition = getNewDefinition();
replaceDeclarationWithDefinition(rewriter, newDefinition);
-
- IASTNode parentTemplateDeclaration =
- ToggleNodeHelper.getParentTemplateDeclaration(context.getDeclaration());
+
+ IASTNode parentTemplateDeclaration = ToggleNodeHelper.getParentTemplateDeclaration(context.getDeclaration());
if (!(parentTemplateDeclaration instanceof ICPPASTTemplateDeclaration)) {
restoreLeadingComments(rewriter, newDefinition);
}
}
private void restoreLeadingComments(ASTRewrite rewriter, IASTFunctionDefinition newDefinition) {
- List<IASTComment>comments = rewriter.getComments(context.getDefinition().getParent(), CommentPosition.leading);
- if(comments != null) {
+ List<IASTComment> comments = rewriter.getComments(context.getDefinition().getParent(), CommentPosition.leading);
+ if (comments != null) {
for (IASTComment comment : comments) {
rewriter.addComment(newDefinition, comment, CommentPosition.leading);
rewriter.remove(comment, infoText);
@@ -92,8 +91,8 @@ public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStra
}
private IASTFunctionDefinition getNewDefinition() {
- IASTFunctionDefinition newDefinition = ToggleNodeHelper.createInClassDefinition(
- context.getDeclaration(), context.getDefinition(), context.getDefinitionAST());
+ IASTFunctionDefinition newDefinition = ToggleNodeHelper.createInClassDefinition(context.getDeclaration(),
+ context.getDefinition(), context.getDefinitionAST());
newDefinition.setBody(context.getDefinition().getBody().copy(CopyStyle.withLocations));
if (newDefinition instanceof ICPPASTFunctionWithTryBlock) {
ICPPASTFunctionWithTryBlock newTryFun = (ICPPASTFunctionWithTryBlock) newDefinition;
@@ -102,7 +101,7 @@ public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStra
newTryFun.addCatchHandler(catchH.copy(CopyStyle.withLocations));
}
}
-
+
IASTNode parent = ASTQueries.findAncestorWithType(context.getDefinition(), ICPPASTCompositeTypeSpecifier.class);
if (parent != null) {
newDefinition.setParent(parent);
@@ -112,9 +111,9 @@ public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStra
return newDefinition;
}
- private ASTRewrite replaceDeclarationWithDefinition(ASTRewrite rewriter,
- IASTFunctionDefinition newDefinition) {
- IASTSimpleDeclaration fullDeclaration = ASTQueries.findAncestorWithType(context.getDeclaration(), CPPASTSimpleDeclaration.class);
+ private ASTRewrite replaceDeclarationWithDefinition(ASTRewrite rewriter, IASTFunctionDefinition newDefinition) {
+ IASTSimpleDeclaration fullDeclaration = ASTQueries.findAncestorWithType(context.getDeclaration(),
+ CPPASTSimpleDeclaration.class);
ASTRewrite newRewriter = rewriter.replace(fullDeclaration, newDefinition, infoText);
return newRewriter;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java
index 51f56a38050..66acd6e32a2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2015 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Sergey Prigogin (Google)
* Marc-Andre Laperle (Ericsson)
@@ -103,6 +103,7 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
return super.leave(namespaceDefinition);
}
}
+
private IASTTranslationUnit implAst;
private ToggleRefactoringContext context;
private TextEditGroup infoText;
@@ -129,10 +130,10 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
if (includeNode != null) {
implRewrite.insertBefore(implAst, null, includeNode, infoText);
}
-
+
IASTNode insertionParent = implAst.getTranslationUnit();
List<ICPPASTNamespaceDefinition> namespaces = getSurroundingNamespaces();
-
+
if (!namespaces.isEmpty()) {
IASTNode namespaceInImplementation = searchNamespaceInImplementation(namespaces);
if (namespaceInImplementation != null) {
@@ -147,14 +148,13 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
insertionParent = newNamespace;
}
}
-
+
newDefinition.setParent(insertionParent);
-
- IASTNode insertionPoint = findInsertionPoint(insertionParent,
- context.getDeclarationAST());
- ASTRewrite newRewriter = implRewrite.insertBefore(insertionParent,
- insertionPoint, newDefinition, infoText);
- copyCommentsToNewFile(newDefinition, newRewriter, collector.rewriterForTranslationUnit(context.getDefinitionAST()));
+
+ IASTNode insertionPoint = findInsertionPoint(insertionParent, context.getDeclarationAST());
+ ASTRewrite newRewriter = implRewrite.insertBefore(insertionParent, insertionPoint, newDefinition, infoText);
+ copyCommentsToNewFile(newDefinition, newRewriter,
+ collector.rewriterForTranslationUnit(context.getDefinitionAST()));
restoreLeadingComments(newDefinition, newRewriter, collector);
}
@@ -322,15 +322,15 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
if (declarator == null) {
declarator = context.getDefinition().getDeclarator();
}
- IASTNode insertion_point = InsertionPointFinder.findInsertionPoint(
- unit, insertionParent.getTranslationUnit(), declarator);
+ IASTNode insertion_point = InsertionPointFinder.findInsertionPoint(unit, insertionParent.getTranslationUnit(),
+ declarator);
return insertion_point;
}
- private void restoreLeadingComments(ICPPASTFunctionDefinition newDefinition,
- ASTRewrite newRewriter, ModificationCollector collector) {
+ private void restoreLeadingComments(ICPPASTFunctionDefinition newDefinition, ASTRewrite newRewriter,
+ ModificationCollector collector) {
ASTRewrite rw = collector.rewriterForTranslationUnit(context.getDefinitionAST());
- List<IASTComment>comments = rw.getComments(context.getDefinition(), CommentPosition.leading);
+ List<IASTComment> comments = rw.getComments(context.getDefinition(), CommentPosition.leading);
if (comments != null) {
for (IASTComment comment : comments) {
newRewriter.addComment(newDefinition, comment, CommentPosition.leading);
@@ -342,24 +342,22 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
}
private void replaceDefinitionWithDeclaration(ModificationCollector collector) {
- IASTSimpleDeclaration newdeclarator =
- ToggleNodeHelper.createDeclarationFromDefinition(context.getDefinition());
+ IASTSimpleDeclaration newdeclarator = ToggleNodeHelper.createDeclarationFromDefinition(context.getDefinition());
ASTRewrite rewrite = collector.rewriterForTranslationUnit(context.getDefinitionAST());
rewrite.replace(context.getDefinition(), newdeclarator, infoText);
}
private ICPPASTFunctionDefinition getNewDefinition() {
- ICPPASTFunctionDefinition newDefinition =
- ToggleNodeHelper.createFunctionSignatureWithEmptyBody(
- context.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations),
- context.getDefinition().getDeclarator().copy(CopyStyle.withLocations),
- context.getDefinition().copy(CopyStyle.withLocations));
+ ICPPASTFunctionDefinition newDefinition = ToggleNodeHelper.createFunctionSignatureWithEmptyBody(
+ context.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations),
+ context.getDefinition().getDeclarator().copy(CopyStyle.withLocations),
+ context.getDefinition().copy(CopyStyle.withLocations));
newDefinition.getDeclSpecifier().setInline(false);
newDefinition.setBody(context.getDefinition().getBody().copy(CopyStyle.withLocations));
if (newDefinition instanceof ICPPASTFunctionWithTryBlock) {
ICPPASTFunctionWithTryBlock newTryFun = (ICPPASTFunctionWithTryBlock) newDefinition;
ICPPASTFunctionWithTryBlock oldTryFun = (ICPPASTFunctionWithTryBlock) context.getDefinition();
- for (ICPPASTCatchHandler catchHandler : oldTryFun.getCatchHandlers()) {
+ for (ICPPASTCatchHandler catchHandler : oldTryFun.getCatchHandlers()) {
newTryFun.addCatchHandler(catchHandler.copy(CopyStyle.withLocations));
}
}
@@ -397,8 +395,7 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
}
private void removeDefinitionFromHeader(ModificationCollector collector) {
- ASTRewrite header_rewrite = collector.rewriterForTranslationUnit(
- context.getDefinitionAST());
+ ASTRewrite header_rewrite = collector.rewriterForTranslationUnit(context.getDefinitionAST());
header_rewrite.remove(ToggleNodeHelper.getParentRemovePoint(context.getDefinition()), infoText);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNodeHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNodeHelper.java
index f77003be166..d19c2fd92e0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNodeHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNodeHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Marc-Andre Laperle (Ericsson)
* Thomas Corbat (IFS)
@@ -86,9 +86,8 @@ public class ToggleNodeHelper extends NodeHelper {
}
private static List<ICPPASTConstructorChainInitializer> getInitializerList(IASTFunctionDefinition definition) {
- ArrayList<ICPPASTConstructorChainInitializer> initalizers =
- new ArrayList<ICPPASTConstructorChainInitializer>();
-
+ ArrayList<ICPPASTConstructorChainInitializer> initalizers = new ArrayList<ICPPASTConstructorChainInitializer>();
+
for (IASTNode node : definition.getChildren()) {
if (node instanceof ICPPASTConstructorChainInitializer) {
initalizers.add(((ICPPASTConstructorChainInitializer) node).copy(CopyStyle.withLocations));
@@ -105,9 +104,8 @@ public class ToggleNodeHelper extends NodeHelper {
return newDeclaration;
}
- static ICPPASTFunctionDefinition createFunctionSignatureWithEmptyBody(
- IASTDeclSpecifier newDeclSpec, IASTFunctionDeclarator newFuncDecl,
- IASTFunctionDefinition oldDefinition) {
+ static ICPPASTFunctionDefinition createFunctionSignatureWithEmptyBody(IASTDeclSpecifier newDeclSpec,
+ IASTFunctionDeclarator newFuncDecl, IASTFunctionDefinition oldDefinition) {
ICPPASTFunctionDefinition newFunc = null;
newFuncDecl = adjustParamNames(newFuncDecl, oldDefinition);
if (oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
@@ -118,15 +116,17 @@ public class ToggleNodeHelper extends NodeHelper {
copyInitializerList(newFunc, oldDefinition);
return newFunc;
}
-
+
private static IASTFunctionDeclarator adjustParamNames(IASTFunctionDeclarator newFuncDecl,
IASTFunctionDefinition oldDefinition) {
if (oldDefinition.getDeclarator() instanceof IASTStandardFunctionDeclarator) {
IASTStandardFunctionDeclarator oldStdDec = (IASTStandardFunctionDeclarator) oldDefinition.getDeclarator();
IASTParameterDeclaration[] definitionParams = oldStdDec.getParameters();
- IASTParameterDeclaration[] declarationParams = ((IASTStandardFunctionDeclarator)newFuncDecl).getParameters();
- for(int i = 0; i < declarationParams.length; ++i) {
- declarationParams[i].getDeclarator().setName(definitionParams[i].getDeclarator().getName().copy(CopyStyle.withLocations));
+ IASTParameterDeclaration[] declarationParams = ((IASTStandardFunctionDeclarator) newFuncDecl)
+ .getParameters();
+ for (int i = 0; i < declarationParams.length; ++i) {
+ declarationParams[i].getDeclarator()
+ .setName(definitionParams[i].getDeclarator().getName().copy(CopyStyle.withLocations));
}
}
return newFuncDecl;
@@ -139,15 +139,15 @@ public class ToggleNodeHelper extends NodeHelper {
}
}
- static IASTFunctionDefinition getQualifiedNameDefinition(IASTFunctionDefinition oldDefinition,
+ static IASTFunctionDefinition getQualifiedNameDefinition(IASTFunctionDefinition oldDefinition,
IASTTranslationUnit definitionUnit, IASTNode nameSpace) {
ICPPASTDeclSpecifier newDeclSpecifier = createDeclSpecifier(oldDefinition);
IASTFunctionDeclarator newDeclarator = oldDefinition.getDeclarator().copy(CopyStyle.withLocations);
newDeclarator.setName(getQualifiedName(oldDefinition.getDeclarator(), nameSpace));
removeParameterInitializations(newDeclarator);
- ICPPASTFunctionDefinition newFunction =
- createFunctionSignatureWithEmptyBody(newDeclSpecifier, newDeclarator, oldDefinition);
+ ICPPASTFunctionDefinition newFunction = createFunctionSignatureWithEmptyBody(newDeclSpecifier, newDeclarator,
+ oldDefinition);
// Virt-specifiers are only valid in the class declaration.
if (newFunction.getDeclarator() instanceof ICPPASTFunctionDeclarator) {
ICPPASTFunctionDeclarator functionDeclarator = (ICPPASTFunctionDeclarator) newFunction.getDeclarator();
@@ -159,7 +159,8 @@ public class ToggleNodeHelper extends NodeHelper {
private static ICPPASTDeclSpecifier createDeclSpecifier(IASTFunctionDefinition oldDefinition) {
IASTDeclSpecifier originalDeclSpecifier = oldDefinition.getDeclSpecifier();
- ICPPASTDeclSpecifier newDeclSpecifier = (ICPPASTDeclSpecifier) originalDeclSpecifier.copy(CopyStyle.withLocations);
+ ICPPASTDeclSpecifier newDeclSpecifier = (ICPPASTDeclSpecifier) originalDeclSpecifier
+ .copy(CopyStyle.withLocations);
if (newDeclSpecifier instanceof ICPPASTNamedTypeSpecifier) {
ICPPASTNamedTypeSpecifier newNamedTypeSpecifier = (ICPPASTNamedTypeSpecifier) newDeclSpecifier;
IASTName typename = ((ICPPASTNamedTypeSpecifier) originalDeclSpecifier).getName();
@@ -172,8 +173,7 @@ public class ToggleNodeHelper extends NodeHelper {
return newDeclSpecifier;
}
- private static void adaptTemplateQualifiers(ICPPASTNamedTypeSpecifier newDeclSpecifier,
- IBinding typenameBinding) {
+ private static void adaptTemplateQualifiers(ICPPASTNamedTypeSpecifier newDeclSpecifier, IBinding typenameBinding) {
if (typenameBinding instanceof ICPPBinding) {
try {
String[] nameParts = ((ICPPBinding) typenameBinding).getQualifiedName();
@@ -232,12 +232,14 @@ public class ToggleNodeHelper extends NodeHelper {
return newTemplateId;
}
- private static ICPPASTTemplateId createTemplateIdForArguments(IASTName qualifierName, ICPPTemplateArgument[] templateArguments) {
+ private static ICPPASTTemplateId createTemplateIdForArguments(IASTName qualifierName,
+ ICPPTemplateArgument[] templateArguments) {
ICPPASTTemplateId newTemplateId = factory.newTemplateId(qualifierName);
for (ICPPTemplateArgument templateArgument : templateArguments) {
IType type = templateArgument.getOriginalTypeValue();
DeclarationGeneratorImpl declarationGeneratorImpl = new DeclarationGeneratorImpl(factory);
- IASTDeclarator abstractDeclarator = declarationGeneratorImpl.createDeclaratorFromType(type, EMPTY_STRING.toCharArray());
+ IASTDeclarator abstractDeclarator = declarationGeneratorImpl.createDeclaratorFromType(type,
+ EMPTY_STRING.toCharArray());
IType ultimateType = SemanticUtil.getUltimateType(type, false);
IASTName templateParameterName = factory.newName(ASTTypeUtil.getType(ultimateType, false));
ICPPASTNamedTypeSpecifier typeSpecifier = factory.newNamedTypeSpecifier(templateParameterName);
@@ -260,8 +262,8 @@ public class ToggleNodeHelper extends NodeHelper {
return newTemplateId;
}
- public static ICPPASTTemplateDeclaration getTemplateDeclaration(
- IASTFunctionDefinition oldFunction, IASTFunctionDefinition newFunction) {
+ public static ICPPASTTemplateDeclaration getTemplateDeclaration(IASTFunctionDefinition oldFunction,
+ IASTFunctionDefinition newFunction) {
ArrayList<ICPPASTTemplateDeclaration> templateDeclarations = getAllTemplateDeclarations(oldFunction);
return addTemplateDeclarationsInOrder(templateDeclarations, newFunction);
}
@@ -296,17 +298,16 @@ public class ToggleNodeHelper extends NodeHelper {
return templdecs;
}
- static IASTFunctionDefinition createInClassDefinition(IASTFunctionDeclarator dec,
- IASTFunctionDefinition def, IASTTranslationUnit insertionAst) {
+ static IASTFunctionDefinition createInClassDefinition(IASTFunctionDeclarator dec, IASTFunctionDefinition def,
+ IASTTranslationUnit insertionAst) {
IASTFunctionDeclarator declarator = dec.copy(CopyStyle.withLocations);
- IASTDeclSpecifier declSpec =
- def.getDeclSpecifier().copy(CopyStyle.withLocations);
+ IASTDeclSpecifier declSpec = def.getDeclSpecifier().copy(CopyStyle.withLocations);
declSpec.setInline(false);
if (declSpec instanceof ICPPASTDeclSpecifier && ToggleNodeHelper.isVirtual(dec)) {
((ICPPASTDeclSpecifier) declSpec).setVirtual(true);
}
declSpec.setStorageClass(getStorageClass(dec));
-
+
return createFunctionSignatureWithEmptyBody(declSpec, declarator, def);
}
@@ -317,7 +318,7 @@ public class ToggleNodeHelper extends NodeHelper {
}
return false;
}
-
+
static int getStorageClass(IASTFunctionDeclarator fdec) {
if (fdec.getParent() instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration dec = (IASTSimpleDeclaration) fdec.getParent();
@@ -328,8 +329,7 @@ public class ToggleNodeHelper extends NodeHelper {
static IASTNode getParentRemovePoint(IASTFunctionDefinition definition) {
IASTNode toremove = definition;
- while (toremove.getParent() != null &&
- toremove.getParent() instanceof ICPPASTTemplateDeclaration) {
+ while (toremove.getParent() != null && toremove.getParent() instanceof ICPPASTTemplateDeclaration) {
toremove = toremove.getParent();
}
return toremove;
@@ -362,8 +362,8 @@ public class ToggleNodeHelper extends NodeHelper {
return qName;
}
- private static Stack<IASTNode> getQualifiedNames(IASTFunctionDeclarator declarator,
- IASTNode limiter, IASTNode node) {
+ private static Stack<IASTNode> getQualifiedNames(IASTFunctionDeclarator declarator, IASTNode limiter,
+ IASTNode node) {
IASTName lastName = declarator.getName();
Stack<IASTNode> nodes = new Stack<IASTNode>();
while (node.getParent() != null && node.getParent() != limiter) {
@@ -379,15 +379,14 @@ public class ToggleNodeHelper extends NodeHelper {
nodes.pop();
ICPPASTTemplateId templateID = getTemplateParameter(node, lastName);
nodes.add(templateID);
- }
+ }
}
return nodes;
}
private static boolean shouldAddTemplateBrackets(IASTNode node) {
return node instanceof ICPPASTTemplateDeclaration
- && !(((ICPPASTTemplateDeclaration) node).getDeclaration()
- instanceof ICPPASTFunctionDefinition);
+ && !(((ICPPASTTemplateDeclaration) node).getDeclaration() instanceof ICPPASTFunctionDefinition);
}
private static ICPPASTTemplateId getTemplateParameter(IASTNode node, IASTName name) {
@@ -415,11 +414,11 @@ public class ToggleNodeHelper extends NodeHelper {
/**
* Will extract the innermost ICPPASTFunctionDefinition out of a template declaration.
- *
+ *
* template<typename T> // <-- input this node
* template<typename U>
- * void function(T t, U u) { ... } // <-- will find this node here
- *
+ * void function(T t, U u) { ... } // <-- will find this node here
+ *
* @param declaration the template declaration that should be searched for the function definition.
* @return null if a declaration is found instead of a definition.
*/
@@ -439,35 +438,31 @@ public class ToggleNodeHelper extends NodeHelper {
}
return null;
}
-
+
/**
* Gets comments inside the body of a function.
* @return The body as a string and all the catch handlers
*/
public static String getBody(IASTFunctionDefinition oldDefinition, IASTTranslationUnit ast,
ModificationCollector modifications) {
- return getBodyOnly(oldDefinition, ast, modifications)
- + getCatchHandlers(oldDefinition, ast, modifications);
+ return getBodyOnly(oldDefinition, ast, modifications) + getCatchHandlers(oldDefinition, ast, modifications);
}
private static String getBodyOnly(IASTFunctionDefinition oldDefinition, IASTTranslationUnit ast,
ModificationCollector modifications) {
- String leadingComments = getCommentsAsString(getLeadingCommentsFromNode(oldDefinition.getBody(),
- ast, modifications));
- String trailingComments = getCommentsAsString(getTrailingComments(oldDefinition.getBody(),
- ast, modifications));
+ String leadingComments = getCommentsAsString(
+ getLeadingCommentsFromNode(oldDefinition.getBody(), ast, modifications));
+ String trailingComments = getCommentsAsString(getTrailingComments(oldDefinition.getBody(), ast, modifications));
return leadingComments + oldDefinition.getBody().getRawSignature() + trailingComments;
}
private static String getCatchHandlers(IASTFunctionDefinition oldDefinition, IASTTranslationUnit ast,
ModificationCollector modifications) {
if (oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
- ICPPASTCatchHandler[] oldCatches =
- ((ICPPASTFunctionWithTryBlock) oldDefinition).getCatchHandlers();
+ ICPPASTCatchHandler[] oldCatches = ((ICPPASTFunctionWithTryBlock) oldDefinition).getCatchHandlers();
String allCatchHandlers = ""; //$NON-NLS-1$
for (int i = 0; i < oldCatches.length; i++) {
- String lead = getCommentsAsString(getLeadingCommentsFromNode(oldCatches[i], ast,
- modifications));
+ String lead = getCommentsAsString(getLeadingCommentsFromNode(oldCatches[i], ast, modifications));
String trail = getCommentsAsString(getTrailingComments(oldCatches[i], ast, modifications));
allCatchHandlers += lead + oldCatches[i].getRawSignature() + trail;
}
@@ -476,14 +471,14 @@ public class ToggleNodeHelper extends NodeHelper {
return ""; //$NON-NLS-1$
}
- private static List<IASTComment> getLeadingCommentsFromNode(IASTNode existingNode,
- IASTTranslationUnit ast, ModificationCollector modifications) {
+ private static List<IASTComment> getLeadingCommentsFromNode(IASTNode existingNode, IASTTranslationUnit ast,
+ ModificationCollector modifications) {
ASTRewrite rw = modifications.rewriterForTranslationUnit(ast);
return rw.getComments(existingNode, CommentPosition.leading);
}
- private static List<IASTComment> getTrailingComments(IASTNode existingNode,
- IASTTranslationUnit ast, ModificationCollector modifications) {
+ private static List<IASTComment> getTrailingComments(IASTNode existingNode, IASTTranslationUnit ast,
+ ModificationCollector modifications) {
ASTRewrite rw = modifications.rewriterForTranslationUnit(ast);
return rw.getComments(existingNode, CommentPosition.trailing);
}
@@ -503,7 +498,7 @@ public class ToggleNodeHelper extends NodeHelper {
}
return lastSeen;
}
-
+
private static String getCommentsAsString(List<IASTComment> commentList) {
String comments = EMPTY_STRING;
for (IASTComment c : commentList) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoring.java
index a7cd6410a07..a9d990fb671 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoring.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2015 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
@@ -41,7 +41,7 @@ public class ToggleRefactoring extends CRefactoring {
private ITextSelection selection;
private IToggleRefactoringStrategy strategy;
private ToggleRefactoringContext context;
-
+
public ToggleRefactoring(ICElement element, ITextSelection selection, ICProject project) {
super(element, selection, project);
if (selection == null || tu.getResource() == null || project == null)
@@ -68,7 +68,7 @@ public class ToggleRefactoring extends CRefactoring {
return initStatus;
}
- private void prepareIndexer(IProgressMonitor pm) throws CoreException {
+ private void prepareIndexer(IProgressMonitor pm) throws CoreException {
IIndexManager im = CCorePlugin.getIndexManager();
while (!im.isProjectIndexed(project)) {
im.joinIndexer(500, pm);
@@ -80,15 +80,14 @@ public class ToggleRefactoring extends CRefactoring {
}
@Override
- protected void collectModifications(IProgressMonitor pm, ModificationCollector modifications)
- throws CoreException {
+ protected void collectModifications(IProgressMonitor pm, ModificationCollector modifications) throws CoreException {
pm.subTask(Messages.ToggleRefactoring_CalculateModifications);
strategy.run(modifications);
}
@Override
protected RefactoringDescriptor getRefactoringDescriptor() {
- return null; // Refactoring history is not supported.
+ return null; // Refactoring history is not supported.
}
public ToggleRefactoringContext getContext() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringContext.java
index 50918a02743..319ece180b4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringContext.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -58,7 +58,7 @@ public class ToggleRefactoringContext {
public ToggleRefactoringContext(CRefactoringContext refactoringContext, IIndex index,
ITranslationUnit translationUnit, ITextSelection selection)
- throws OperationCanceledException, CoreException {
+ throws OperationCanceledException, CoreException {
this.refactoringContext = refactoringContext;
this.index = index;
this.selectionTU = translationUnit;
@@ -76,7 +76,7 @@ public class ToggleRefactoringContext {
public void findBinding() {
try {
binding = index.findBinding(selectionName);
- if(binding == null) {
+ if (binding == null) {
binding = selectionName.resolveBinding();
}
} catch (CoreException e) {
@@ -89,12 +89,10 @@ public class ToggleRefactoringContext {
try {
IIndexName[] decnames = index.findNames(binding, IIndex.FIND_DECLARATIONS);
if (decnames.length > 1)
- throw new NotSupportedException(
- Messages.ToggleRefactoringContext_MultipleDeclarations);
+ throw new NotSupportedException(Messages.ToggleRefactoringContext_MultipleDeclarations);
for (IIndexName iname : decnames) {
selectionAST = getASTForIndexName(iname);
- IASTName astname = IndexToASTNameHelper.findMatchingASTName(
- selectionAST, iname, index);
+ IASTName astname = IndexToASTNameHelper.findMatchingASTName(selectionAST, iname, index);
if (astname != null) {
targetDeclaration = findFunctionDeclarator(astname);
targetDeclarationAST = selectionAST;
@@ -153,8 +151,7 @@ public class ToggleRefactoringContext {
}
public IASTTranslationUnit getASTForPartnerFile() throws CoreException {
- ITranslationUnit tu =
- SourceHeaderPartnerFinder.getPartnerTranslationUnit(selectionTU, refactoringContext);
+ ITranslationUnit tu = SourceHeaderPartnerFinder.getPartnerTranslationUnit(selectionTU, refactoringContext);
if (tu == null)
return null;
return refactoringContext.getAST(tu, null);
@@ -166,21 +163,18 @@ public class ToggleRefactoringContext {
throw new NotSupportedException(Messages.ToggleRefactoringContext_NoTuFound);
}
- private IASTTranslationUnit getASTForIndexName(IIndexName indexName)
- throws CModelException, CoreException {
+ private IASTTranslationUnit getASTForIndexName(IIndexName indexName) throws CModelException, CoreException {
if (isSameFileAsInTU(indexName)) {
return selectionAST;
}
- ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(
- indexName.getFile().getLocation(), null);
+ ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(indexName.getFile().getLocation(), null);
if (tu == null)
return null;
return refactoringContext.getAST(tu, null);
}
private boolean isSameFileAsInTU(IIndexName indexName) {
- return indexName.getFileLocation().getFileName().equals(
- selectionAST.getFileLocation().getFileName());
+ return indexName.getFileLocation().getFileName().equals(selectionAST.getFileLocation().getFileName());
}
private IASTFunctionDeclarator findFunctionDeclarator(IASTNode node) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringRunner.java
index cbb30407ad1..afe21932c8a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringRunner.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
@@ -33,8 +33,8 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
*/
public class ToggleRefactoringRunner extends RefactoringRunner {
- public ToggleRefactoringRunner(ICElement element, ITextSelection selection,
- IShellProvider shellProvider, ICProject project) {
+ public ToggleRefactoringRunner(ICElement element, ITextSelection selection, IShellProvider shellProvider,
+ ICProject project) {
super(element, selection, shellProvider, project);
}
@@ -42,15 +42,14 @@ public class ToggleRefactoringRunner extends RefactoringRunner {
public void run() {
Job[] jobs = Job.getJobManager().find(RefactoringJob.FAMILY_TOGGLE_DEFINITION);
if (jobs.length > 0) {
- CUIPlugin.log("No concurrent toggling allowed", new NotSupportedException("")); //$NON-NLS-1$//$NON-NLS-2$
+ CUIPlugin.log("No concurrent toggling allowed", new NotSupportedException("")); //$NON-NLS-1$//$NON-NLS-2$
return;
}
- RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(RefactoringSaveHelper.SAVE_REFACTORING);
+ RefactoringSaveHelper saveHelper = new RefactoringSaveHelper(RefactoringSaveHelper.SAVE_REFACTORING);
if (!saveHelper.saveEditors(shellProvider.getShell()))
return;
- ToggleRefactoring refactoring =
- new ToggleRefactoring(element, (ITextSelection) selection, project);
+ ToggleRefactoring refactoring = new ToggleRefactoring(element, (ITextSelection) selection, project);
new RefactoringJob(refactoring).schedule();
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStrategyFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStrategyFactory.java
index 0ee9aa71c6c..741f69c9f8d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStrategyFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStrategyFactory.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Martin Schwab & Thomas Kallenberg - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Martin Schwab & Thomas Kallenberg - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
@@ -39,15 +39,14 @@ public class ToggleStrategyFactory {
return new ToggleFromInHeaderToImplementationStrategy(context);
throw new NotSupportedException(Messages.ToggleStrategyFactory_UnsupportedSituation);
}
-
+
private boolean isinHeaderSituation() {
- return (context.getDefinition() != null)
- && (context.getDefinitionAST().isHeaderUnit());
+ return (context.getDefinition() != null) && (context.getDefinitionAST().isHeaderUnit());
}
private boolean isInClassSituation() {
- return (context.getDeclaration() == null) &&
- (ASTQueries.findAncestorWithType(context.getDefinition(), IASTCompositeTypeSpecifier.class) != null);
+ return (context.getDeclaration() == null)
+ && (ASTQueries.findAncestorWithType(context.getDefinition(), IASTCompositeTypeSpecifier.class) != null);
}
private boolean isTemplateSituation() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingActionDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingActionDelegate.java
index ac56d978dd3..9e5caffaec2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingActionDelegate.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingActionDelegate.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
@@ -29,19 +29,19 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* Represents the interface between the user who invokes the action and the
* actual refactoring mechanism. Starts the ToggleRefactoringRunner.
- *
+ *
* Order of execution is: constructor, init, selectionChanged, run
*/
public class TogglingActionDelegate implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
private TextSelection selection;
-
+
@Override
public void init(IWorkbenchWindow window) {
this.window = window;
assert (window != null);
}
-
+
@Override
public void selectionChanged(IAction action, ISelection selection) {
boolean isTextSelection = selection != null && selection instanceof TextSelection;
@@ -49,7 +49,8 @@ public class TogglingActionDelegate implements IWorkbenchWindowActionDelegate {
if (!isTextSelection)
return;
// Get our own selection due to (a possible) bug?
- this.selection = (TextSelection) CUIPlugin.getActivePage().getActiveEditor().getEditorSite().getSelectionProvider().getSelection();
+ this.selection = (TextSelection) CUIPlugin.getActivePage().getActiveEditor().getEditorSite()
+ .getSelectionProvider().getSelection();
}
@Override
@@ -60,8 +61,7 @@ public class TogglingActionDelegate implements IWorkbenchWindowActionDelegate {
IEditorPart editor = activePage.getActiveEditor();
if (editor == null || editor.getEditorInput() == null)
return;
- ITranslationUnit tu =
- CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+ ITranslationUnit tu = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
if (tu == null || tu.getResource() == null)
return;
new ToggleRefactoringRunner(tu, selection, window, tu.getCProject()).run();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.java
index 7e0f3b7c243..2d3faf70c11 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
@@ -44,7 +44,8 @@ public class ASTHelper {
}
public static IASTNode getDeclarationForNode(IASTNode node) {
- while (node != null && !(node instanceof IASTSimpleDeclaration) && !(node instanceof IASTParameterDeclaration)) {
+ while (node != null && !(node instanceof IASTSimpleDeclaration)
+ && !(node instanceof IASTParameterDeclaration)) {
node = node.getParent();
}
return node;
@@ -79,8 +80,8 @@ public class ASTHelper {
return null;
}
- public static boolean samePointers(IASTPointerOperator[] pointerOperators1,
- IASTPointerOperator[] pointerOperators2, TrailNodeEqualityChecker checker) {
+ public static boolean samePointers(IASTPointerOperator[] pointerOperators1, IASTPointerOperator[] pointerOperators2,
+ TrailNodeEqualityChecker checker) {
if (pointerOperators2.length == pointerOperators1.length) {
for (int i = 0; i < pointerOperators2.length; i++) {
IASTPointerOperator operator1 = pointerOperators1[i];
@@ -120,28 +121,29 @@ public class ASTHelper {
baseNode.accept(visitor);
return specifiers;
}
-
- public static Collection<IASTPreprocessorStatement> getAllInFilePreprocessorStatements(
- IASTTranslationUnit unit, String aktFileName) {
+
+ public static Collection<IASTPreprocessorStatement> getAllInFilePreprocessorStatements(IASTTranslationUnit unit,
+ String aktFileName) {
Collection<IASTPreprocessorStatement> statements = new ArrayList<IASTPreprocessorStatement>();
for (IASTPreprocessorStatement aktStatement : unit.getAllPreprocessorStatements()) {
- if (aktStatement.getFileLocation() != null && aktStatement.getFileLocation().getFileName().equals(aktFileName)) {
+ if (aktStatement.getFileLocation() != null
+ && aktStatement.getFileLocation().getFileName().equals(aktFileName)) {
statements.add(aktStatement);
}
}
return statements;
}
-
+
public static Collection<IASTDeclaration> getAllInFileDeclarations(IASTTranslationUnit unit, String aktFileName) {
Collection<IASTDeclaration> decls = new ArrayList<IASTDeclaration>();
- for (IASTDeclaration aktDecl: unit.getDeclarations()) {
+ for (IASTDeclaration aktDecl : unit.getDeclarations()) {
if (aktDecl.getFileLocation() != null && aktDecl.getFileLocation().getFileName().equals(aktFileName)) {
decls.add(aktDecl);
}
}
return decls;
}
-
+
public static ICPPASTUsingDirective getActiveUsingDirecitveForNode(IASTNode node, IASTTranslationUnit unit) {
ICPPASTUsingDirective activeDirective = null;
for (IASTDeclaration aktDeclaration : getAllInFileDeclarations(unit, node.getFileLocation().getFileName())) {
@@ -151,7 +153,7 @@ public class ASTHelper {
if (aktDeclaration instanceof ICPPASTUsingDirective) {
activeDirective = (ICPPASTUsingDirective) aktDeclaration;
}
- }
+ }
return activeDirective;
}
@@ -174,7 +176,7 @@ public class ASTHelper {
}
return null;
}
-
+
public static Collection<IASTFunctionDeclarator> getFunctionDeclaratorsForClass(IASTCompositeTypeSpecifier klass) {
Collection<IASTFunctionDeclarator> declarators = new ArrayList<IASTFunctionDeclarator>();
for (IASTDeclaration aktDeclaration : klass.getMembers()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.java
index 3f6cf930ed9..eaa8032043b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
@@ -33,7 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
public class CPPASTAllVisitor extends ASTVisitor {
-
+
{
shouldVisitNames = true;
shouldVisitDeclarations = true;
@@ -52,8 +52,7 @@ public class CPPASTAllVisitor extends ASTVisitor {
shouldVisitNamespaces = true;
shouldVisitTemplateParameters = true;
}
-
-
+
@Override
public int visit(IASTTranslationUnit tu) {
return visitAll(tu);
@@ -108,12 +107,12 @@ public class CPPASTAllVisitor extends ASTVisitor {
public int visit(IASTEnumerator enumerator) {
return visitAll(enumerator);
}
-
+
@Override
- public int visit( IASTProblem problem ){
+ public int visit(IASTProblem problem) {
return visitAll(problem);
}
-
+
/**
* Visit BaseSpecifiers.
*/
@@ -137,8 +136,8 @@ public class CPPASTAllVisitor extends ASTVisitor {
public int visit(ICPPASTTemplateParameter parameter) {
return visitAll(parameter);
}
-
- public int visitAll(IASTNode node){
+
+ public int visitAll(IASTNode node) {
return PROCESS_CONTINUE;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Checks.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Checks.java
index e036f63e9bf..70a9ff84e5a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Checks.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Checks.java
@@ -48,7 +48,7 @@ public class Checks {
/*
* no instances
*/
- private Checks(){
+ private Checks() {
}
public static boolean startsWithUpperCase(String s) {
@@ -62,12 +62,12 @@ public class Checks {
}
}
- public static boolean startsWithLowerCase(String s){
+ public static boolean startsWithLowerCase(String s) {
if (s == null) {
return false;
} else if (s.isEmpty()) {
return false;
- } else {
+ } else {
// Workaround for JDK bug (see 26529)
return s.charAt(0) == Character.toLowerCase(s.charAt(0));
}
@@ -111,26 +111,26 @@ public class Checks {
* @return RefactoringStatus based on the given status or the name, if empty.
*/
public static RefactoringStatus checkName(String name, IStatus status) {
- RefactoringStatus result= new RefactoringStatus();
+ RefactoringStatus result = new RefactoringStatus();
if (name.isEmpty())
return RefactoringStatus.createFatalErrorStatus(Messages.Checks_choose_name);
if (status.isOK())
return result;
- switch (status.getSeverity()){
- case IStatus.ERROR:
- return RefactoringStatus.createFatalErrorStatus(status.getMessage());
- case IStatus.WARNING:
- return RefactoringStatus.createWarningStatus(status.getMessage());
- case IStatus.INFO:
- return RefactoringStatus.createInfoStatus(status.getMessage());
- default: // Nothing
- return new RefactoringStatus();
+ switch (status.getSeverity()) {
+ case IStatus.ERROR:
+ return RefactoringStatus.createFatalErrorStatus(status.getMessage());
+ case IStatus.WARNING:
+ return RefactoringStatus.createWarningStatus(status.getMessage());
+ case IStatus.INFO:
+ return RefactoringStatus.createInfoStatus(status.getMessage());
+ default: // Nothing
+ return new RefactoringStatus();
}
}
- public static boolean resourceExists(IPath resourcePath){
+ public static boolean resourceExists(IPath resourcePath) {
return ResourcesPlugin.getWorkspace().getRoot().findMember(resourcePath) != null;
}
@@ -147,22 +147,22 @@ public class Checks {
}
public static boolean isReadOnly(IResource res) throws CModelException {
- ResourceAttributes attributes= res.getResourceAttributes();
+ ResourceAttributes attributes = res.getResourceAttributes();
if (attributes != null && attributes.isReadOnly())
return true;
if (!(res instanceof IContainer))
return false;
- IContainer container= (IContainer)res;
+ IContainer container = (IContainer) res;
IResource[] children;
try {
children = container.members();
- for (int i= 0; i < children.length; i++) {
+ for (int i = 0; i < children.length; i++) {
if (isReadOnly(children[i]))
return true;
}
- } catch (CModelException e){
+ } catch (CModelException e) {
throw e;
} catch (CoreException e) {
throw new CModelException(e);
@@ -173,11 +173,11 @@ public class Checks {
//-------- validateEdit checks ----
public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify, Object context) {
- RefactoringStatus result= new RefactoringStatus();
- IStatus status= Resources.checkInSync(filesToModify);
+ 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()) {
@@ -188,23 +188,23 @@ public class Checks {
}
public static void addModifiedFilesToChecker(IFile[] filesToModify, CheckConditionsContext context) {
- ResourceChangeChecker checker= context.getChecker(ResourceChangeChecker.class);
- IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
+ ResourceChangeChecker checker = context.getChecker(ResourceChangeChecker.class);
+ IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
- for (int i= 0; i < filesToModify.length; i++) {
+ for (int i = 0; i < filesToModify.length; i++) {
deltaFactory.change(filesToModify[i]);
}
}
public static RefactoringStatus validateEdit(ITranslationUnit tu, Object context) {
- IResource resource= CModelUtil.toOriginal(tu).getResource();
- RefactoringStatus result= new RefactoringStatus();
+ IResource resource = CModelUtil.toOriginal(tu).getResource();
+ RefactoringStatus result = new RefactoringStatus();
if (resource == null)
return result;
- IStatus status= Resources.checkInSync(resource);
+ IStatus status = Resources.checkInSync(resource);
if (!status.isOK())
result.merge(RefactoringStatus.create(status));
- status= Resources.makeCommittable(resource, context);
+ status = Resources.makeCommittable(resource, context);
if (!status.isOK()) {
result.merge(RefactoringStatus.create(status));
if (!result.hasFatalError()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.java
index 850d67f0266..5f68ea039f6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.java
@@ -53,7 +53,7 @@ public class DefinitionFinder {
/**
* Finds the definition for the given name. The definition and the original name may belong
* to a different ASTs. The search is done in the index and in the ASTs of dirty editors.
- *
+ *
* @param name the name to find the definition for
* @param context the refactoring context
* @param pm the progress monitor
@@ -61,8 +61,8 @@ public class DefinitionFinder {
* not unique.
* @throws CoreException thrown in case of errors
*/
- public static IASTName getDefinition(IASTName name, CRefactoringContext context,
- IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ public static IASTName getDefinition(IASTName name, CRefactoringContext context, IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
IBinding binding = name.resolveBinding();
if (binding == null) {
return null;
@@ -73,19 +73,19 @@ public class DefinitionFinder {
/**
* Finds the definition for the given binding. The search is done in the index and in the ASTs
* of dirty editors.
- *
+ *
* @param binding the binding to find the definition for
* @param contextTu the translation unit that determines the set of files to search for
* the definition. Only the files directly or indirectly included by the translation unit
- * are considered.
+ * are considered.
* @param context the refactoring context
* @param pm the progress monitor
* @return the definition name, or {@code null} if there is no definition or if it is
* not unique.
* @throws CoreException thrown in case of errors
*/
- public static IASTName getDefinition(IBinding binding, IASTTranslationUnit contextTu,
- CRefactoringContext context, IProgressMonitor pm) throws CoreException {
+ public static IASTName getDefinition(IBinding binding, IASTTranslationUnit contextTu, CRefactoringContext context,
+ IProgressMonitor pm) throws CoreException {
SubMonitor sm = SubMonitor.convert(pm, 10);
IIndex index = context.getIndex();
if (index == null) {
@@ -96,8 +96,8 @@ public class DefinitionFinder {
return null;
Set<String> searchedFiles = new HashSet<String>();
List<IASTName> definitions = new ArrayList<IASTName>();
- IIndexName[] definitionsFromIndex =
- index.findNames(indexBinding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ IIndexName[] definitionsFromIndex = index.findNames(indexBinding,
+ IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
int remainingCount = definitionsFromIndex.length;
SubMonitor loopProgress = sm.newChild(6).setWorkRemaining(remainingCount);
for (IIndexName name : definitionsFromIndex) {
@@ -105,10 +105,8 @@ public class DefinitionFinder {
throw new OperationCanceledException();
}
IIndexFile indexFile = name.getFile();
- if (contextTu.getASTFileSet().contains(indexFile) ||
- contextTu.getIndexFileSet().contains(indexFile)) {
- ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(
- indexFile.getLocation(), null);
+ if (contextTu.getASTFileSet().contains(indexFile) || contextTu.getIndexFileSet().contains(indexFile)) {
+ ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(indexFile.getLocation(), null);
if (searchedFiles.add(tu.getLocation().toOSString())) {
findDefinitionsInTranslationUnit(indexBinding, tu, context, definitions, pm);
if (definitions.size() > 1)
@@ -129,7 +127,8 @@ public class DefinitionFinder {
if (editorInput instanceof ITranslationUnitEditorInput) {
ITranslationUnit tu = ((ITranslationUnitEditorInput) editorInput).getTranslationUnit();
if (searchedFiles.add(tu.getLocation().toOSString())) {
- findDefinitionsInTranslationUnit(indexBinding, tu, context, definitions, loopProgress.newChild(1));
+ findDefinitionsInTranslationUnit(indexBinding, tu, context, definitions,
+ loopProgress.newChild(1));
if (definitions.size() > 1)
return null;
}
@@ -143,15 +142,15 @@ public class DefinitionFinder {
/**
* Checks if the given binding has a definition. The search is done in the index and in the ASTs
* of dirty editors.
- *
+ *
* @param binding the binding to find the definition for
* @param context the refactoring context
* @param pm the progress monitor
* @return <code>true</code> if the binding has a definition.
* @throws CoreException thrown in case of errors
*/
- public static boolean hasDefinition(IBinding binding, CRefactoringContext context,
- IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ public static boolean hasDefinition(IBinding binding, CRefactoringContext context, IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
SubMonitor sm = SubMonitor.convert(pm, 10);
IIndex index = context.getIndex();
if (index == null) {
@@ -171,20 +170,18 @@ public class DefinitionFinder {
}
Set<String> searchedFiles = new HashSet<String>();
- IIndexName[] definitionsFromIndex =
- index.findNames(indexBinding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ IIndexName[] definitionsFromIndex = index.findNames(indexBinding,
+ IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
int remainingCount = definitionsFromIndex.length;
SubMonitor loopProgress = sm.newChild(6).setWorkRemaining(remainingCount);
for (IIndexName name : definitionsFromIndex) {
if (sm.isCanceled()) {
throw new OperationCanceledException();
}
- ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(
- name.getFile().getLocation(), null);
+ ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(name.getFile().getLocation(), null);
String filename = tu.getLocation().toOSString();
- if (searchedFiles.add(filename) &&
- (!dirtyFiles.contains(filename) ||
- hasDefinitionsInTranslationUnit(indexBinding, tu, context, loopProgress.newChild(1)))) {
+ if (searchedFiles.add(filename) && (!dirtyFiles.contains(filename)
+ || hasDefinitionsInTranslationUnit(indexBinding, tu, context, loopProgress.newChild(1)))) {
return true;
}
loopProgress.setWorkRemaining(--remainingCount);
@@ -200,8 +197,8 @@ public class DefinitionFinder {
if (editorInput instanceof ITranslationUnitEditorInput) {
ITranslationUnit tu = ((ITranslationUnitEditorInput) editorInput).getTranslationUnit();
String filename = tu.getLocation().toOSString();
- if (searchedFiles.add(filename) &&
- hasDefinitionsInTranslationUnit(indexBinding, tu, context, loopProgress.newChild(1))) {
+ if (searchedFiles.add(filename)
+ && hasDefinitionsInTranslationUnit(indexBinding, tu, context, loopProgress.newChild(1))) {
return true;
}
}
@@ -218,8 +215,7 @@ public class DefinitionFinder {
}
private static boolean hasDefinitionsInTranslationUnit(IIndexBinding binding, ITranslationUnit tu,
- CRefactoringContext context, IProgressMonitor pm)
- throws CoreException, OperationCanceledException {
+ CRefactoringContext context, IProgressMonitor pm) throws CoreException, OperationCanceledException {
IASTTranslationUnit ast = context.getAST(tu, pm);
return ast.getDefinitionsInAST(binding).length != 0;
}
@@ -228,7 +224,7 @@ public class DefinitionFinder {
* Finds the declaration for the given class member. The declaration and the original member
* name may belong to a different ASTs. The search is done in the index and in the ASTs of dirty
* editors.
- *
+ *
* @param memberName the name of the class member to find the declaration for
* @param context the refactoring context
* @param pm the progress monitor
@@ -236,8 +232,8 @@ public class DefinitionFinder {
* not unique.
* @throws CoreException thrown in case of errors
*/
- public static IASTName getMemberDeclaration(IASTName memberName, CRefactoringContext context,
- IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ public static IASTName getMemberDeclaration(IASTName memberName, CRefactoringContext context, IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
IBinding binding = memberName.resolveBinding();
if (!(binding instanceof ICPPMember))
return null;
@@ -248,11 +244,11 @@ public class DefinitionFinder {
* Finds the declaration for the given class member. The declaration and the original member
* name may belong to a different ASTs. The search is done in the index and in the ASTs of dirty
* editors.
- *
+ *
* @param member the class member binding to find the declaration for
* @param contextTu the translation unit that determines the set of files to search for
* the declaration. Only the files directly or indirectly included by the translation unit
- * are considered.
+ * are considered.
* @param context the refactoring context
* @param pm the progress monitor
* @return the declaration name, or {@code null} if there is no declaration or if it is
@@ -264,8 +260,8 @@ public class DefinitionFinder {
IASTName classDefintionName = getDefinition(member.getClassOwner(), contextTu, context, pm);
if (classDefintionName == null)
return null;
- IASTCompositeTypeSpecifier compositeTypeSpecifier =
- ASTQueries.findAncestorWithType(classDefintionName, IASTCompositeTypeSpecifier.class);
+ IASTCompositeTypeSpecifier compositeTypeSpecifier = ASTQueries.findAncestorWithType(classDefintionName,
+ IASTCompositeTypeSpecifier.class);
IASTTranslationUnit ast = classDefintionName.getTranslationUnit();
IIndex index = context.getIndex();
if (index == null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java
index ba60b5ddf50..75c61dbe3b6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java
@@ -141,11 +141,11 @@ public class EclipseObjects {
Object o = selection.getFirstElement();
if (o instanceof ICElement) {
- ICElement e= (ICElement) o;
- IResource r= e.getUnderlyingResource();
- if (r instanceof IFile) {
- return (IFile) r;
- }
+ ICElement e = (ICElement) o;
+ IResource r = e.getUnderlyingResource();
+ if (r instanceof IFile) {
+ return (IFile) r;
+ }
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.java
index fa884ec603f..f9981aee3c7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
@@ -27,8 +27,8 @@ import org.eclipse.cdt.internal.ui.refactoring.Container;
/**
* @author Guido Zgraggen IFS
*/
-public class ExpressionFinder {
-
+public class ExpressionFinder {
+
public static IASTName findExpressionInTranslationUnit(IASTTranslationUnit transUnit, final IIndexName indexName) {
final Container<IASTName> expName = new Container<IASTName>();
transUnit.accept(new ASTVisitor() {
@@ -40,9 +40,10 @@ public class ExpressionFinder {
public int visit(IASTName name) {
if (name.isReference() && name.getNodeLocations().length > 0) {
IASTNodeLocation nodeLocation = name.getNodeLocations()[0];
- if (indexName.getNodeOffset() == nodeLocation.getNodeOffset()
+ if (indexName.getNodeOffset() == nodeLocation.getNodeOffset()
&& indexName.getNodeLength() == nodeLocation.getNodeLength()
- && new Path(indexName.getFileLocation().getFileName()).equals(new Path(nodeLocation.asFileLocation().getFileName()))) {
+ && new Path(indexName.getFileLocation().getFileName())
+ .equals(new Path(nodeLocation.asFileLocation().getFileName()))) {
expName.setObject(name);
return ASTVisitor.PROCESS_ABORT;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.java
index 80ad3a21b71..21f4e262f03 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
@@ -25,30 +25,30 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.ui.CUIPlugin;
/**
- * Some helper methods to access part of the content of an iFile
- *
+ * Some helper methods to access part of the content of an iFile
+ *
* @author Emanuel Graf
*
*/
public class FileContentHelper {
-
+
private static final int bufferSize = 512;
- public static String getContent(IFile file, int start) throws CoreException, IOException{
- InputStreamReader reader = getReaderForFile(file);
+ public static String getContent(IFile file, int start) throws CoreException, IOException {
+ InputStreamReader reader = getReaderForFile(file);
skip(start, reader);
return readRest(reader);
}
-
+
public static String getContent(IFile file, int start, int length) {
try {
InputStreamReader r = getReaderForFile(file);
char[] bytes = new char[length];
-
+
skip(start, r);
-
+
read(length, r, bytes);
-
+
return new String(bytes);
} catch (IOException e) {
CUIPlugin.log(e);
@@ -58,30 +58,28 @@ public class FileContentHelper {
return ""; //$NON-NLS-1$
}
- private static InputStreamReader getReaderForFile(IFile file)
- throws CoreException, UnsupportedEncodingException {
+ private static InputStreamReader getReaderForFile(IFile file) throws CoreException, UnsupportedEncodingException {
InputStream contents = file.getContents();
InputStreamReader r = new InputStreamReader(contents, file.getCharset());
return r;
}
- private static String readRest(InputStreamReader reader) throws IOException{
+ private static String readRest(InputStreamReader reader) throws IOException {
StringBuilder content = new StringBuilder();
char[] buffer = new char[bufferSize];
int bytesRead = 0;
- while((bytesRead = reader.read(buffer)) >= 0){
+ while ((bytesRead = reader.read(buffer)) >= 0) {
content.append(buffer, 0, bytesRead);
}
return content.toString();
}
-
- private static void read(int length, InputStreamReader r, char[] bytes)
- throws IOException {
+
+ private static void read(int length, InputStreamReader r, char[] bytes) throws IOException {
int bufferOffset = 0;
int charactersRead = 0;
- while(charactersRead >= 0 && length > 0){
+ while (charactersRead >= 0 && length > 0) {
charactersRead = r.read(bytes, bufferOffset, length);
- if(charactersRead > 0){
+ if (charactersRead > 0) {
bufferOffset += charactersRead;
length -= charactersRead;
}
@@ -90,9 +88,9 @@ public class FileContentHelper {
private static void skip(int count, InputStreamReader r) throws IOException {
long skipped = 0;
- while(skipped >= 0 && count > 0 && r.ready()){
+ while (skipped >= 0 && count > 0 && r.ready()) {
skipped = r.skip(count);
- if(skipped > 0){
+ if (skipped > 0) {
count -= skipped;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.java
index b19d96bd1a2..c0db9b997a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
@@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
/**
* Helper class concerning files.
- *
+ *
* @author Lukas Felber
*/
public class FileHelper {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java
index b61aa979f8d..c5b565639ee 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* IBM Corporation
*******************************************************************************/
@@ -28,7 +28,7 @@ import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
/**
* Class to verify that an identifier meets the C++ rules for valid names.
- *
+ *
* @author Thomas Corbat
*/
public class IdentifierHelper {
@@ -45,18 +45,23 @@ public class IdentifierHelper {
}
if (isValidIdentifier(identifier)) {
if (isKeyword(identifier)) {
- return new IdentifierResult(IdentifierResult.KEYWORD, NLS.bind(Messages.IdentifierHelper_isKeyword, identifier));
+ return new IdentifierResult(IdentifierResult.KEYWORD,
+ NLS.bind(Messages.IdentifierHelper_isKeyword, identifier));
}
- return new IdentifierResult(IdentifierResult.VALID, NLS.bind(Messages.IdentifierHelper_isValid, identifier));
+ return new IdentifierResult(IdentifierResult.VALID,
+ NLS.bind(Messages.IdentifierHelper_isValid, identifier));
} else if (isLeadingADigit(identifier)) {
- return new IdentifierResult(IdentifierResult.DIGIT_FIRST, NLS.bind(Messages.IdentifierHelper_leadingDigit, identifier));
+ return new IdentifierResult(IdentifierResult.DIGIT_FIRST,
+ NLS.bind(Messages.IdentifierHelper_leadingDigit, identifier));
} else if (identifier.length() == 0) {
- return new IdentifierResult(IdentifierResult.EMPTY, Messages.IdentifierHelper_emptyIdentifier);
+ return new IdentifierResult(IdentifierResult.EMPTY, Messages.IdentifierHelper_emptyIdentifier);
} else if (hasIllegalCharacters(identifier)) {
- return new IdentifierResult(IdentifierResult.ILLEGAL_CHARACTER, NLS.bind(Messages.IdentifierHelper_illegalCharacter, identifier));
+ return new IdentifierResult(IdentifierResult.ILLEGAL_CHARACTER,
+ NLS.bind(Messages.IdentifierHelper_illegalCharacter, identifier));
}
-
- return new IdentifierResult(IdentifierResult.UNKNOWN, NLS.bind(Messages.IdentifierHelper_unidentifiedMistake, identifier));
+
+ return new IdentifierResult(IdentifierResult.UNKNOWN,
+ NLS.bind(Messages.IdentifierHelper_unidentifiedMistake, identifier));
}
private static boolean isKeyword(String identifier) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.java
index 5f0393009e9..6e1e713fe14 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.java
@@ -1,24 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
-
/**
* Holds the result of a name validation, used by the IdentifierHelper.
- *
+ *
* @author Thomas Corbat
*
*/
@@ -30,20 +29,19 @@ public class IdentifierResult {
public static final int DIGIT_FIRST = 3;
public static final int KEYWORD = 4;
public static final int UNKNOWN = 5;
-
-
+
private final int result;
private final String message;
-
- public boolean isCorrect(){
+
+ public boolean isCorrect() {
return result == VALID;
}
-
- public int getResult(){
+
+ public int getResult() {
return result;
}
-
- public String getMessage(){
+
+ public String getMessage() {
return message;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.java
index 5ad969c8659..660d4d0c4d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java
index ee76813dcaf..f1b0d47a152 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
@@ -38,7 +38,7 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContext;
/**
* Helps with IASTNames.
- *
+ *
* @author Mirko Stocker
*/
public class NameHelper {
@@ -47,7 +47,7 @@ public class NameHelper {
public static boolean isValidLocalVariableName(String name) {
return localVariableRegexp.matcher(name).matches();
}
-
+
public static boolean isKeyword(String name) {
CharArrayIntMap keywords = new CharArrayIntMap(0, -1);
Keywords.addKeywordsC(keywords);
@@ -55,32 +55,32 @@ public class NameHelper {
Keywords.addKeywordsPreprocessor(keywords);
return keywords.containsKey(name.toCharArray());
}
-
+
/**
* Constructs the fully qualified name from the given parameters. The file and offset parameters
* are used to determine the namespace at the declaration position and the target namespace at
* the target position.
- *
+ *
* @param declaratorName of the method or function
* @param declarationTu translation unit of the method or function declaration
* @param insertFileTu translation unit of the file where the implementation is being inserted
* @param selectionOffset the offset in the declarationFile, usually the position or selection
* of the declaration
- * @param insertLocation
+ * @param insertLocation
* @return the correct name for the target
- * @throws CoreException
+ * @throws CoreException
*/
- public static ICPPASTQualifiedName createQualifiedNameFor(IASTName declaratorName,
- ITranslationUnit declarationTu, int selectionOffset, ITranslationUnit insertFileTu,
- int insertLocation, CRefactoringContext astCache) throws CoreException {
+ public static ICPPASTQualifiedName createQualifiedNameFor(IASTName declaratorName, ITranslationUnit declarationTu,
+ int selectionOffset, ITranslationUnit insertFileTu, int insertLocation, CRefactoringContext astCache)
+ throws CoreException {
ICPPASTQualifiedName qname = new CPPASTQualifiedName(
(ICPPASTName) declaratorName.copy(CopyStyle.withLocations));
-
- ICPPASTName[] declarationNames =
- NamespaceHelper.getSurroundingNamespace(declarationTu, selectionOffset, astCache);
- ICPPASTName[] implementationNames =
- NamespaceHelper.getSurroundingNamespace(insertFileTu, insertLocation, astCache);
-
+
+ ICPPASTName[] declarationNames = NamespaceHelper.getSurroundingNamespace(declarationTu, selectionOffset,
+ astCache);
+ ICPPASTName[] implementationNames = NamespaceHelper.getSurroundingNamespace(insertFileTu, insertLocation,
+ astCache);
+
for (int i = 0; i < declarationNames.length; i++) {
if (i >= implementationNames.length) {
qname.addNameSpecifier(declarationNames[i]);
@@ -91,7 +91,7 @@ public class NameHelper {
return qname;
}
-
+
public static String getTypeName(IASTParameterDeclaration parameter) {
IASTName name = parameter.getDeclarator().getName();
IBinding binding = name.resolveBinding();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java
index 50ddbc90ff2..31ab480bfef 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
@@ -48,40 +48,40 @@ public class NamespaceHelper {
/**
* Returns the qualified name of all namespaces that are defined at the specified translation
* unit and offset.
- *
+ *
* @param translationUnit
* @param offset
* @param astCache
* @return ICPPASTQualifiedName with the names of all namespaces
- * @throws CoreException
+ * @throws CoreException
*/
- public static ICPPASTName[] getSurroundingNamespace(final ITranslationUnit translationUnit,
- final int offset, CRefactoringContext astCache) throws CoreException {
+ public static ICPPASTName[] getSurroundingNamespace(final ITranslationUnit translationUnit, final int offset,
+ CRefactoringContext astCache) throws CoreException {
final List<ICPPASTName> names = new ArrayList<>();
-
+
astCache.getAST(translationUnit, null).accept(new CPPASTAllVisitor() {
@Override
public int visit(IASTDeclSpecifier declSpec) {
- if (declSpec instanceof ICPPASTCompositeTypeSpecifier &&
- checkFileNameAndLocation(translationUnit.getLocation(), offset, declSpec)) {
+ if (declSpec instanceof ICPPASTCompositeTypeSpecifier
+ && checkFileNameAndLocation(translationUnit.getLocation(), offset, declSpec)) {
names.add((ICPPASTName) createNameWithTemplates(declSpec));
}
return super.visit(declSpec);
}
-
+
@Override
public int visit(ICPPASTNamespaceDefinition namespace) {
if (checkFileNameAndLocation(translationUnit.getLocation(), offset, namespace)) {
- names.add((ICPPASTName) namespace.getName().copy(CopyStyle.withLocations));
+ names.add((ICPPASTName) namespace.getName().copy(CopyStyle.withLocations));
}
-
+
return super.visit(namespace);
}
});
return names.toArray(new ICPPASTName[names.size()]);
}
-
+
private static boolean checkFileNameAndLocation(final IPath path, final int offset, IASTNode namespace) {
IASTFileLocation fileLoc = namespace.getFileLocation();
if (fileLoc == null) {
@@ -91,7 +91,7 @@ public class NamespaceHelper {
if (!fileNameOk) {
return false;
}
-
+
for (IASTNodeLocation nodeLocation : namespace.getNodeLocations()) {
int nodeOffset = nodeLocation.getNodeOffset();
boolean locationOk = offset >= nodeOffset && offset < nodeOffset + nodeLocation.getNodeLength();
@@ -99,40 +99,40 @@ public class NamespaceHelper {
return true;
}
}
-
+
return false;
}
-
+
private static IASTName createNameWithTemplates(IASTNode declarationParent) {
- IASTName parentName = ((ICPPASTCompositeTypeSpecifier) declarationParent).getName().copy(
- CopyStyle.withLocations);
-
+ IASTName parentName = ((ICPPASTCompositeTypeSpecifier) declarationParent).getName()
+ .copy(CopyStyle.withLocations);
+
if (classHasTemplates(declarationParent)) {
CPPASTTemplateId templateId = new CPPASTTemplateId();
templateId.setTemplateName(parentName);
-
- for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) declarationParent.getParent().getParent()).getTemplateParameters()) {
+
+ for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) declarationParent
+ .getParent().getParent()).getTemplateParameters()) {
if (templateParameter instanceof CPPASTSimpleTypeTemplateParameter) {
CPPASTSimpleTypeTemplateParameter simpleTypeTemplateParameter = (CPPASTSimpleTypeTemplateParameter) templateParameter;
-
+
CPPASTTypeId id = new CPPASTTypeId();
-
+
CPPASTNamedTypeSpecifier namedTypeSpecifier = new CPPASTNamedTypeSpecifier();
- namedTypeSpecifier.setName(simpleTypeTemplateParameter.getName().copy(
- CopyStyle.withLocations));
+ namedTypeSpecifier.setName(simpleTypeTemplateParameter.getName().copy(CopyStyle.withLocations));
id.setDeclSpecifier(namedTypeSpecifier);
-
+
templateId.addTemplateArgument(id);
}
}
-
+
parentName = templateId;
}
return parentName;
}
private static boolean classHasTemplates(IASTNode declarationParent) {
- return declarationParent.getParent() != null
- && declarationParent.getParent().getParent() instanceof ICPPASTTemplateDeclaration;
+ return declarationParent.getParent() != null
+ && declarationParent.getParent().getParent() instanceof ICPPASTTemplateDeclaration;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java
index 83870dcbf70..1de29632ebc 100755
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
/**
* General class for common Node operations.
- *
+ *
* @author Lukas Felber & Guido Zgraggen
*/
public class NodeHelper {
@@ -59,7 +59,7 @@ public class NodeHelper {
} else if (parent instanceof CPPASTNamespaceDefinition) {
return ((CPPASTNamespaceDefinition) parent).getDeclarations();
}
- return IASTDeclaration.EMPTY_DECLARATION_ARRAY;
+ return IASTDeclaration.EMPTY_DECLARATION_ARRAY;
}
public static IASTNode findFollowingNode(IASTNode currentNode) {
@@ -89,9 +89,10 @@ public class NodeHelper {
if (node1 == null || node2 == null) {
return false;
}
- return node1.getNodeLocations()[0].getNodeOffset() == node2.getNodeLocations()[0].getNodeOffset()
- && node1.getNodeLocations()[0].getNodeLength() == node2.getNodeLocations()[0].getNodeLength()
- && new Path(node1.getFileLocation().getFileName()).equals(new Path(node2.getFileLocation().getFileName()));
+ return node1.getNodeLocations()[0].getNodeOffset() == node2.getNodeLocations()[0].getNodeOffset()
+ && node1.getNodeLocations()[0].getNodeLength() == node2.getNodeLocations()[0].getNodeLength()
+ && new Path(node1.getFileLocation().getFileName())
+ .equals(new Path(node2.getFileLocation().getFileName()));
}
public static MethodContext findMethodContext(IASTNode node, CRefactoringContext refactoringContext,
@@ -118,9 +119,8 @@ public class NodeHelper {
return context;
}
- private static void getMethodContexWithIndex(CRefactoringContext refactoringContext,
- IASTTranslationUnit ast, IASTName name, MethodContext context, IProgressMonitor pm)
- throws CoreException {
+ private static void getMethodContexWithIndex(CRefactoringContext refactoringContext, IASTTranslationUnit ast,
+ IASTName name, MethodContext context, IProgressMonitor pm) throws CoreException {
if (name instanceof ICPPASTQualifiedName) {
ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
context.setMethodQName(qname);
@@ -139,8 +139,7 @@ public class NodeHelper {
}
final IASTDeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
final IASTDeclarator[] declarators = simpleDeclaration.getDeclarators();
- if ((declSpecifier instanceof ICPPASTDeclSpecifier)
- && ((ICPPASTDeclSpecifier) declSpecifier).isFriend()) {
+ if ((declSpecifier instanceof ICPPASTDeclSpecifier) && ((ICPPASTDeclSpecifier) declSpecifier).isFriend()) {
return false;
}
return declarators.length == 1 && declarators[0] instanceof ICPPASTFunctionDeclarator;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerator.java
index 5eb79105ab0..f9171854df7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerator.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils;
@@ -19,18 +19,18 @@ import java.util.Set;
/**
* Helps to generate new unused names.
- *
+ *
* @author Mirko Stocker
*
*/
public class PseudoNameGenerator {
-
+
private final Set<String> names = new HashSet<String>();
-
+
public void addExistingName(String name) {
names.add(name);
}
-
+
public String generateNewName(String typeName) {
String[] nameParts = typeName.split("::"); //$NON-NLS-1$
typeName = nameParts[nameParts.length - 1];
@@ -46,7 +46,7 @@ public class PseudoNameGenerator {
if (i <= 0) {
typeName = nameParts[i];
} else {
- typeName = typeName.concat(nameParts[i].substring(0,1).toUpperCase());
+ typeName = typeName.concat(nameParts[i].substring(0, 1).toUpperCase());
if (nameParts[i].length() > 1) {
typeName = typeName.concat(nameParts[i].substring(1));
}
@@ -56,7 +56,7 @@ public class PseudoNameGenerator {
String numberString = ""; //$NON-NLS-1$
String newNameCandidate;
int index = 0;
-
+
do {
newNameCandidate = typeName + numberString;
if (!NameHelper.isValidLocalVariableName(newNameCandidate)) {
@@ -65,7 +65,7 @@ public class PseudoNameGenerator {
index++;
numberString = Integer.toString(index);
} while (names.contains(newNameCandidate) || NameHelper.isKeyword(newNameCandidate));
-
+
names.add(newNameCandidate);
return newNameCandidate;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.java
index 0fffaf1ddd3..616c4f171fd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
@@ -34,19 +34,19 @@ import org.eclipse.cdt.internal.ui.refactoring.Container;
/**
* Helper class to support operations concerning a selection.
- *
+ *
* @author Mirko Stocker, Lukas Felber
*/
public class SelectionHelper {
public static Region getRegion(ISelection selection) {
if (selection instanceof ITextSelection) {
- final ITextSelection txtSelection= (ITextSelection) selection;
+ final ITextSelection txtSelection = (ITextSelection) selection;
return new Region(txtSelection.getOffset(), txtSelection.getLength());
}
return null;
}
-
+
public static IASTSimpleDeclaration findFirstSelectedDeclaration(final IRegion textSelection,
IASTTranslationUnit translationUnit) {
final Container<IASTSimpleDeclaration> container = new Container<>();
@@ -55,10 +55,11 @@ public class SelectionHelper {
{
shouldVisitDeclarations = true;
}
+
@Override
public int visit(IASTDeclaration declaration) {
- if (declaration instanceof IASTSimpleDeclaration &&
- doesNodeOverlapWithRegion(declaration, textSelection)) {
+ if (declaration instanceof IASTSimpleDeclaration
+ && doesNodeOverlapWithRegion(declaration, textSelection)) {
container.setObject((IASTSimpleDeclaration) declaration);
}
return super.visit(declaration);
@@ -67,11 +68,11 @@ public class SelectionHelper {
return container.getObject();
}
-
+
public static boolean doesNodeOverlapWithRegion(IASTNode node, IRegion region) {
return doRegionsOverlap(getNodeSpan(node), region);
}
-
+
public static boolean isNodeInsideRegion(IASTNode node, IRegion region) {
return isRegionInside(getNodeSpan(node), region);
}
@@ -82,8 +83,7 @@ public class SelectionHelper {
private static boolean isRegionInside(IRegion region1, IRegion region2) {
int offset1 = region1.getOffset();
int offset2 = region2.getOffset();
- return offset1 >= offset2 &&
- offset1 + region1.getLength() <= offset2 + region2.getLength();
+ return offset1 >= offset2 && offset1 + region1.getLength() <= offset2 + region2.getLength();
}
/**
@@ -92,8 +92,7 @@ public class SelectionHelper {
private static boolean doRegionsOverlap(IRegion region1, IRegion region2) {
int offset1 = region1.getOffset();
int offset2 = region2.getOffset();
- return offset1 + region1.getLength() >= offset2 &&
- offset1 <= offset2 + region2.getLength();
+ return offset1 + region1.getLength() >= offset2 && offset1 <= offset2 + region2.getLength();
}
public static boolean isNodeInsideSelection(IASTNode node, IRegion selection) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.java
index 4df43001361..92f0fd1f40d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -22,18 +22,18 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
*/
public enum VisibilityEnum {
// The values are ordered by increasing visibility.
- v_private("private", ICPPASTVisibilityLabel.v_private), //$NON-NLS-1$
- v_protected("protected", ICPPASTVisibilityLabel.v_protected), //$NON-NLS-1$
+ v_private("private", ICPPASTVisibilityLabel.v_private), //$NON-NLS-1$
+ v_protected("protected", ICPPASTVisibilityLabel.v_protected), //$NON-NLS-1$
v_public("public", ICPPASTVisibilityLabel.v_public); //$NON-NLS-1$
private final String stringRepresentation;
private final int visibilityLabelValue;
-
+
private VisibilityEnum(String stringRepresentation, int visibilityLabelValue) {
this.stringRepresentation = stringRepresentation;
this.visibilityLabelValue = visibilityLabelValue;
}
-
+
public static VisibilityEnum from(ICPPASTVisibilityLabel visibility) {
switch (visibility.getVisibility()) {
case ICPPASTVisibilityLabel.v_private:
@@ -45,11 +45,11 @@ public enum VisibilityEnum {
}
return null;
}
-
+
public int getVisibilityLabelValue() {
return visibilityLabelValue;
}
-
+
public static VisibilityEnum getEnumForStringRepresentation(String visibility) {
if (VisibilityEnum.v_private.toString().equals(visibility)) {
return VisibilityEnum.v_private;
@@ -60,7 +60,7 @@ public enum VisibilityEnum {
}
return null;
}
-
+
@Override
public String toString() {
return stringRepresentation;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/resources/ResourceExclusionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/resources/ResourceExclusionContributor.java
index b573a9e0e07..c0500edff00 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/resources/ResourceExclusionContributor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/resources/ResourceExclusionContributor.java
@@ -53,16 +53,16 @@ import org.eclipse.cdt.internal.core.resources.ResourceExclusion;
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
- *
+ *
* @author vkong
* @since 5.3
- *
+ *
*/
public class ResourceExclusionContributor extends RefreshExclusionContributor {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createExclusion()
*/
@Override
@@ -77,7 +77,7 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createProperiesUI(org.eclipse.swt.widgets.
* Composite, org.eclipse.cdt.core.resources.RefreshExclusion)
@@ -139,15 +139,14 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(shell,
- WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
- new ITreeContentProvider() {
+ WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), new ITreeContentProvider() {
@Override
public void dispose() {
@@ -202,8 +201,7 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
dialog.setInput(getResourceRoot(exclusion));
if (exclusionInstanceResources.values().size() > 0) {
- dialog.setInitialElementSelections(Arrays.asList(exclusionInstanceResources.values()
- .toArray()));
+ dialog.setInitialElementSelections(Arrays.asList(exclusionInstanceResources.values().toArray()));
}
dialog.setMessage(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogMessage);
dialog.setTitle(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogTitle);
@@ -220,12 +218,10 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
Object selected = selection[i];
if (selected instanceof IFolder) {
IPath path = ((IFolder) selected).getFullPath();
- IPath relativePath = path
- .makeRelativeTo(getResourceRoot(exclusion).getFullPath());
+ IPath relativePath = path.makeRelativeTo(getResourceRoot(exclusion).getFullPath());
exceptionsList.add(relativePath.toString());
- ExclusionInstance instance = oldExclusionInstanceStrings.get(relativePath
- .toString());
+ ExclusionInstance instance = oldExclusionInstanceStrings.get(relativePath.toString());
if (instance == null) {
instance = new ExclusionInstance();
instance.setExclusionType(ExclusionType.FOLDER);
@@ -266,7 +262,7 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElement.java
index 36b24ca3e05..8af62b9f4de 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElement.java
@@ -33,7 +33,7 @@ public class CSearchElement implements IAdaptable {
private final IIndexFileLocation location;
public CSearchElement(IIndexFileLocation loc) {
- this.location= loc;
+ this.location = loc;
}
@Override
@@ -57,7 +57,7 @@ public class CSearchElement implements IAdaptable {
@SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Class adapterType) {
if (adapterType.isAssignableFrom(IFile.class)) {
- String fullPath= location.getFullPath();
+ String fullPath = location.getFullPath();
if (fullPath != null) {
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fullPath));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java
index 06a35d5ba70..60844e02f8e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java
@@ -34,21 +34,21 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
public class CSearchElementQuery extends CSearchQuery {
private final ISourceReference element;
private String label;
-
+
public CSearchElementQuery(ICElement[] scope, ISourceReference element, int flags) {
super(scope, flags | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
this.element = element;
- this.label= (element instanceof ICElement) ?
- ((ICElement) element).getElementName() : CSearchMessages.PDOMSearchElementQuery_something;
+ this.label = (element instanceof ICElement) ? ((ICElement) element).getElementName()
+ : CSearchMessages.PDOMSearchElementQuery_something;
}
@Override
public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
try {
if (element instanceof ICElement) {
- IBinding binding= IndexUI.elementToBinding(index, (ICElement) element);
+ IBinding binding = IndexUI.elementToBinding(index, (ICElement) element);
if (binding != null) {
- label= labelForBinding(index, binding, label);
+ label = labelForBinding(index, binding, label);
// We should call CPPSemantics.pushLookupPoint() here.
// Until we do, instantiation of dependent expressions may not work.
createMatches(index, binding);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchLabelProvider.java
index a3803f8b038..4182eb4549b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchLabelProvider.java
@@ -12,7 +12,7 @@
* Markus Schorn - initial API and implementation
* Ed Swartz (Nokia)
* Andrey Eremchenko (LEDAS)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
import java.net.URI;
@@ -58,13 +58,14 @@ public class CSearchLabelProvider extends LabelProvider implements IStyledLabelP
protected final CSearchViewPage fPage;
private final TypeInfoLabelProvider fTypeInfoLabelProvider;
private final CUILabelProvider fCElementLabelProvider;
-
+
public CSearchLabelProvider(CSearchViewPage page) {
- fTypeInfoLabelProvider= new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED | TypeInfoLabelProvider.SHOW_PARAMETERS);
- fCElementLabelProvider= new CUILabelProvider(0, CElementImageProvider.SMALL_ICONS);
- fPage= page;
+ fTypeInfoLabelProvider = new TypeInfoLabelProvider(
+ TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED | TypeInfoLabelProvider.SHOW_PARAMETERS);
+ fCElementLabelProvider = new CUILabelProvider(0, CElementImageProvider.SMALL_ICONS);
+ fPage = page;
}
-
+
@Override
public Image getImage(Object element) {
if (element instanceof LineSearchElement) {
@@ -74,19 +75,18 @@ public class CSearchLabelProvider extends LabelProvider implements IStyledLabelP
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SEARCH_LINE);
element = enclosingElement;
}
-
+
if (element instanceof TypeInfoSearchElement)
- return fTypeInfoLabelProvider.getImage(((TypeInfoSearchElement)element).getTypeInfo());
+ return fTypeInfoLabelProvider.getImage(((TypeInfoSearchElement) element).getTypeInfo());
if (element instanceof ProblemSearchElement) {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_WARNING);
}
-
- if (element instanceof IIndexFileLocation
- || element instanceof URI) {
+
+ if (element instanceof IIndexFileLocation || element instanceof URI) {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDE);
}
-
+
if (element == IPDOMSearchContentProvider.URI_CONTAINER) {
// TODO: perhaps a better icon?
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
@@ -95,20 +95,20 @@ public class CSearchLabelProvider extends LabelProvider implements IStyledLabelP
if (element instanceof IPath) {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
}
-
+
if (element instanceof IStatus) {
IStatus status = (IStatus) element;
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
switch (status.getSeverity()) {
- case IStatus.WARNING:
- return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- case IStatus.ERROR:
- return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- default:
- return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ case IStatus.WARNING:
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ case IStatus.ERROR:
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ default:
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
}
}
-
+
return fCElementLabelProvider.getImage(element);
}
@@ -121,39 +121,39 @@ public class CSearchLabelProvider extends LabelProvider implements IStyledLabelP
if (element instanceof TypeInfoSearchElement) {
return fTypeInfoLabelProvider.getText(((TypeInfoSearchElement) element).getTypeInfo());
} else if (element instanceof ProblemSearchElement) {
- ProblemSearchElement pse= (ProblemSearchElement) element;
- return ASTProblem.getMessage(pse.getProblemID(), pse.getDetail());
+ ProblemSearchElement pse = (ProblemSearchElement) element;
+ return ASTProblem.getMessage(pse.getProblemID(), pse.getDetail());
}
-
+
if (element instanceof IPath) {
return ((IPath) element).toString();
}
-
+
if (element instanceof IIndexFileLocation) {
- IPath path= IndexLocationFactory.getPath((IIndexFileLocation) element);
+ IPath path = IndexLocationFactory.getPath((IIndexFileLocation) element);
if (path != null) {
// these are categorized into directories already
return path.lastSegment();
}
}
-
+
if (element instanceof URI) {
return ((URI) element).toString();
}
-
+
if (element instanceof IStatus) {
return ((IStatus) element).getMessage();
}
-
+
return fCElementLabelProvider.getText(element);
}
-
+
protected int getMatchCount(Object element) {
if (element instanceof TranslationUnit) {
TranslationUnit translationUnit = (TranslationUnit) element;
AbstractTextSearchResult searchResult = fPage.getInput();
if (searchResult instanceof CSearchResult) {
- CSearchResult pdomSearchResult = (CSearchResult)searchResult;
+ CSearchResult pdomSearchResult = (CSearchResult) searchResult;
return pdomSearchResult.computeContainedMatches(searchResult, translationUnit.getFile()).length;
}
}
@@ -171,7 +171,8 @@ public class CSearchLabelProvider extends LabelProvider implements IStyledLabelP
for (Match match : lineElement.getMatches()) {
int offset = Math.max(0, match.getOffset() - lineOffset);
int length = Math.min(match.getLength(), lineContent.length() - offset);
- Styler style = match.isWriteAccess() ? ColoringLabelProvider.HIGHLIGHT_WRITE_STYLE : ColoringLabelProvider.HIGHLIGHT_STYLE;
+ Styler style = match.isWriteAccess() ? ColoringLabelProvider.HIGHLIGHT_WRITE_STYLE
+ : ColoringLabelProvider.HIGHLIGHT_STYLE;
styled.setStyle(offset, length, style);
}
return styled;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListContentProvider.java
index d2a30cc9560..5c8b2e0820b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListContentProvider.java
@@ -41,18 +41,18 @@ public class CSearchListContentProvider implements IStructuredContentProvider, I
private final CSearchViewPage fPage;
CSearchListContentProvider(CSearchViewPage page) {
- fPage= page;
+ fPage = page;
}
@Override
public Object[] getElements(Object inputElement) {
- Set<String> uncoveredProjects = new HashSet<String>();
-
+ Set<String> uncoveredProjects = new HashSet<String>();
+
CSearchResult result = (CSearchResult) inputElement;
-
+
Object[] results = result.getElements();
List<Object> resultList = new ArrayList<Object>();
-
+
// see which projects returned results
for (int i = 0; i < results.length; i++) {
if (results[i] instanceof CSearchElement) {
@@ -87,22 +87,20 @@ public class CSearchListContentProvider implements IStructuredContentProvider, I
}
}
}
-
+
return resultList.toArray();
}
private Status createUnindexedProjectWarningElement(ICProject project) {
return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
- MessageFormat.format(
- CSearchMessages.PDOMSearchListContentProvider_IndexerNotEnabledMessageFormat,
- new Object[] { project.getProject().getName() }));
+ MessageFormat.format(CSearchMessages.PDOMSearchListContentProvider_IndexerNotEnabledMessageFormat,
+ new Object[] { project.getProject().getName() }));
}
private Status createClosedProjectWarningElement(ICProject project) {
return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
- MessageFormat.format(
- CSearchMessages.PDOMSearchListContentProvider_ProjectClosedMessageFormat,
- new Object[] { project.getProject().getName() }));
+ MessageFormat.format(CSearchMessages.PDOMSearchListContentProvider_ProjectClosedMessageFormat,
+ new Object[] { project.getProject().getName() }));
}
@Override
@@ -111,8 +109,8 @@ public class CSearchListContentProvider implements IStructuredContentProvider, I
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- this.viewer = (TableViewer)viewer;
- result = (CSearchResult)newInput;
+ this.viewer = (TableViewer) viewer;
+ result = (CSearchResult) newInput;
viewer.refresh();
}
@@ -120,8 +118,8 @@ public class CSearchListContentProvider implements IStructuredContentProvider, I
public void elementsChanged(Object[] elements) {
if (result == null)
return;
-
- for (int i= 0; i < elements.length; i++) {
+
+ for (int i = 0; i < elements.length; i++) {
if (fPage.getDisplayedMatchCount(elements[i]) > 0) {
if (viewer.testFindItem(elements[i]) != null)
viewer.refresh(elements[i]);
@@ -132,7 +130,7 @@ public class CSearchListContentProvider implements IStructuredContentProvider, I
}
}
}
-
+
@Override
public void clear() {
viewer.refresh();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListLabelProvider.java
index 604fcc54b18..da2ffc9a0b4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListLabelProvider.java
@@ -31,13 +31,13 @@ import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
public class CSearchListLabelProvider extends ColoringLabelProvider {
private final CSearchViewPage fPage;
private final int fColumnIndex;
-
+
public CSearchListLabelProvider(CSearchViewPage page, int columnIndex) {
super(new CSearchLabelProvider(page));
fPage = page;
fColumnIndex = columnIndex;
}
-
+
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java
index b1780013d8a..2a9cabdbd53 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java
@@ -20,7 +20,7 @@ import org.eclipse.search.ui.text.Match;
import org.eclipse.cdt.core.index.IIndexFileLocation;
/**
- * Base class for search matches found by various index searches.
+ * Base class for search matches found by various index searches.
*/
public class CSearchMatch extends Match {
private boolean fIsPolymorphicCall;
@@ -33,7 +33,7 @@ public class CSearchMatch extends Match {
IIndexFileLocation getLocation() {
return ((CSearchElement) getElement()).getLocation();
}
-
+
@Override
public boolean equals(Object obj) {
if (obj == this)
@@ -41,15 +41,14 @@ public class CSearchMatch extends Match {
if (!(obj instanceof CSearchMatch))
return false;
CSearchMatch other = (CSearchMatch) obj;
- return getElement().equals(other.getElement())
- && getOffset() == other.getOffset()
+ return getElement().equals(other.getElement()) && getOffset() == other.getOffset()
&& getLength() == other.getLength();
}
public void setIsPolymorphicCall() {
- fIsPolymorphicCall= true;
+ fIsPolymorphicCall = true;
}
-
+
public boolean isPolymorphicCall() {
return fIsPolymorphicCall;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
index a1ffa8a79ab..7abc7516d5d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
@@ -37,8 +37,8 @@ public final class CSearchMessages extends NLS {
public static String CSearchPage_searchFor_macro;
public static String CSearchPage_searchFor_any;
public static String CSearchPage_searchFor_classStruct;
- public static String CSearchPage_label_note;
- public static String CSearchPage_label_activeCodeRemark;
+ public static String CSearchPage_label_note;
+ public static String CSearchPage_label_activeCodeRemark;
public static String CSearchPage_limitTo_label;
public static String CSearchPage_limitTo_declarations;
public static String CSearchPage_limitTo_definitions;
@@ -105,7 +105,7 @@ public final class CSearchMessages extends NLS {
NLS.initializeMessages(CSearchMessages.class.getName(), CSearchMessages.class);
}
- private CSearchMessages() {
- // Do not instantiate
- }
+ private CSearchMessages() {
+ // Do not instantiate
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
index 5b6b83948d2..778dc0db1cc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
@@ -77,7 +77,7 @@ import org.eclipse.cdt.internal.ui.util.RowLayouter;
*/
public class CSearchPage extends DialogPage implements ISearchPage {
public static final String EXTENSION_ID = CUIPlugin.PLUGIN_ID + ".pdomSearchPage"; //$NON-NLS-1$
-
+
//Dialog store id constants
private final static String PAGE_NAME = "PDOMSearchPage"; //$NON-NLS-1$
private final static String STORE_CASE_SENSITIVE = "caseSensitive"; //$NON-NLS-1$
@@ -85,183 +85,159 @@ public class CSearchPage extends DialogPage implements ISearchPage {
private final static String STORE_SEARCH_FLAGS = "searchFlags"; //$NON-NLS-1$
/** Preference key for external marker enablement */
- public final static String EXTERNALMATCH_ENABLED = "externMatchEnable"; //$NON-NLS-1$
- /** Preference key for external marker visibilty */
- public final static String EXTERNALMATCH_VISIBLE = "externMatchVisible"; //$NON-NLS-1$
-
- private static final String[] searchForText= {
- CSearchMessages.CSearchPage_searchFor_classStruct,
- CSearchMessages.CSearchPage_searchFor_function,
- CSearchMessages.CSearchPage_searchFor_variable,
- CSearchMessages.CSearchPage_searchFor_union,
- CSearchMessages.CSearchPage_searchFor_method,
- CSearchMessages.CSearchPage_searchFor_field,
- CSearchMessages.CSearchPage_searchFor_enum,
- CSearchMessages.CSearchPage_searchFor_enumr,
- CSearchMessages.CSearchPage_searchFor_namespace,
- CSearchMessages.CSearchPage_searchFor_typedef,
- CSearchMessages.CSearchPage_searchFor_macro,
- CSearchMessages.CSearchPage_searchFor_any
- };
+ public final static String EXTERNALMATCH_ENABLED = "externMatchEnable"; //$NON-NLS-1$
+ /** Preference key for external marker visibilty */
+ public final static String EXTERNALMATCH_VISIBLE = "externMatchVisible"; //$NON-NLS-1$
+
+ private static final String[] searchForText = { CSearchMessages.CSearchPage_searchFor_classStruct,
+ CSearchMessages.CSearchPage_searchFor_function, CSearchMessages.CSearchPage_searchFor_variable,
+ CSearchMessages.CSearchPage_searchFor_union, CSearchMessages.CSearchPage_searchFor_method,
+ CSearchMessages.CSearchPage_searchFor_field, CSearchMessages.CSearchPage_searchFor_enum,
+ CSearchMessages.CSearchPage_searchFor_enumr, CSearchMessages.CSearchPage_searchFor_namespace,
+ CSearchMessages.CSearchPage_searchFor_typedef, CSearchMessages.CSearchPage_searchFor_macro,
+ CSearchMessages.CSearchPage_searchFor_any };
// These must be in the same order as the Text
- private static final Integer[] searchForData = {
- CSearchPatternQuery.FIND_CLASS_STRUCT,
- CSearchPatternQuery.FIND_FUNCTION,
- CSearchPatternQuery.FIND_VARIABLE,
- CSearchPatternQuery.FIND_UNION,
- CSearchPatternQuery.FIND_METHOD,
- CSearchPatternQuery.FIND_FIELD,
- CSearchPatternQuery.FIND_ENUM,
- CSearchPatternQuery.FIND_ENUMERATOR,
- CSearchPatternQuery.FIND_NAMESPACE,
- CSearchPatternQuery.FIND_TYPEDEF,
- CSearchPatternQuery.FIND_MACRO,
- CSearchPatternQuery.FIND_ALL_TYPES
- };
-
+ private static final Integer[] searchForData = { CSearchPatternQuery.FIND_CLASS_STRUCT,
+ CSearchPatternQuery.FIND_FUNCTION, CSearchPatternQuery.FIND_VARIABLE, CSearchPatternQuery.FIND_UNION,
+ CSearchPatternQuery.FIND_METHOD, CSearchPatternQuery.FIND_FIELD, CSearchPatternQuery.FIND_ENUM,
+ CSearchPatternQuery.FIND_ENUMERATOR, CSearchPatternQuery.FIND_NAMESPACE, CSearchPatternQuery.FIND_TYPEDEF,
+ CSearchPatternQuery.FIND_MACRO, CSearchPatternQuery.FIND_ALL_TYPES };
+
// the index of FIND_ALL_TYPES
private static final int searchAllButtonIndex = searchForData.length - 1;
- private static String[] limitToText = {
- CSearchMessages.CSearchPage_limitTo_declarations,
- CSearchMessages.CSearchPage_limitTo_definitions,
- CSearchMessages.CSearchPage_limitTo_references,
- CSearchMessages.CSearchPage_limitTo_allOccurrences
- };
+ private static String[] limitToText = { CSearchMessages.CSearchPage_limitTo_declarations,
+ CSearchMessages.CSearchPage_limitTo_definitions, CSearchMessages.CSearchPage_limitTo_references,
+ CSearchMessages.CSearchPage_limitTo_allOccurrences };
// Must be in the same order as the text
- private static Integer[] limitToData = {
- CSearchQuery.FIND_DECLARATIONS,
- CSearchQuery.FIND_DEFINITIONS,
- CSearchQuery.FIND_REFERENCES,
- CSearchQuery.FIND_ALL_OCCURRENCES,
- };
-
+ private static Integer[] limitToData = { CSearchQuery.FIND_DECLARATIONS, CSearchQuery.FIND_DEFINITIONS,
+ CSearchQuery.FIND_REFERENCES, CSearchQuery.FIND_ALL_OCCURRENCES, };
+
// The index of FIND_ALL_OCCURANCES
private static final int limitToAllButtonIndex = limitToData.length - 1;
-
+
private Combo patternCombo;
private String[] previousPatterns;
private Button caseSensitiveButton;
-
+
private Button[] searchForButtons;
private Button[] limitToButtons;
-
+
private boolean firstTime = true;
private IStructuredSelection structuredSelection;
private ITextSelection textSelection;
private ISearchPageContainer pageContainer;
-
+
private IStatusLineManager fLineManager;
private static ICProject getProject(String name) {
return CoreModel.getDefault().create(ResourcesPlugin.getWorkspace().getRoot().getProject(name));
}
-
+
private ICElement getElement(Object obj) {
if (obj instanceof IResource) {
return CoreModel.getDefault().create((IResource) obj);
- }
+ }
if (obj instanceof ICElement) {
- ICElement elem= (ICElement) obj;
+ ICElement elem = (ICElement) obj;
if (elem instanceof ISourceReference)
return ((ISourceReference) elem).getTranslationUnit();
if (elem instanceof ITranslationUnit || elem instanceof ICContainer || elem instanceof ICProject)
return elem;
-
+
return elem.getCProject();
}
return null;
}
-
@Override
public boolean performAction() {
- fLineManager.setErrorMessage(null);
-
- boolean isCaseSensitive = caseSensitiveButton.getSelection();
-
- // get the pattern and turn it into a regular expression
- String patternStr = patternCombo.getText();
-
- // Get search flags
- int searchFlags = 0;
- if (searchForButtons[searchAllButtonIndex].getSelection()) {
- searchFlags |= CSearchPatternQuery.FIND_ALL_TYPES;
- } else {
- for (int i = 0; i < searchForButtons.length; ++i) {
- if (searchForButtons[i].getSelection())
- searchFlags |= ((Integer) searchForButtons[i].getData()).intValue();
- }
- }
- for (int i = 0; i < limitToButtons.length; ++i) {
- if (limitToButtons[i].getSelection())
- searchFlags |= ((Integer) limitToButtons[i].getData()).intValue();
- }
-
+ fLineManager.setErrorMessage(null);
+
+ boolean isCaseSensitive = caseSensitiveButton.getSelection();
+
+ // get the pattern and turn it into a regular expression
+ String patternStr = patternCombo.getText();
+
+ // Get search flags
+ int searchFlags = 0;
+ if (searchForButtons[searchAllButtonIndex].getSelection()) {
+ searchFlags |= CSearchPatternQuery.FIND_ALL_TYPES;
+ } else {
+ for (int i = 0; i < searchForButtons.length; ++i) {
+ if (searchForButtons[i].getSelection())
+ searchFlags |= ((Integer) searchForButtons[i].getData()).intValue();
+ }
+ }
+ for (int i = 0; i < limitToButtons.length; ++i) {
+ if (limitToButtons[i].getSelection())
+ searchFlags |= ((Integer) limitToButtons[i].getData()).intValue();
+ }
+
// get the list of elements for the scope
Set<ICElement> elements = new HashSet<ICElement>();
String scopeDescription = ""; //$NON-NLS-1$
switch (getContainer().getSelectedScope()) {
case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
final String[] prjNames = getContainer().getSelectedProjectNames();
- scopeDescription= CSearchMessages.ProjectScope;
- int ip= 0;
- for (String prjName: prjNames) {
+ scopeDescription = CSearchMessages.ProjectScope;
+ int ip = 0;
+ for (String prjName : prjNames) {
ICProject project = getProject(prjName);
if (project != null) {
elements.add(project);
- switch(ip++) {
- case 0:
- scopeDescription+= " '" + prjName + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ switch (ip++) {
+ case 0:
+ scopeDescription += " '" + prjName + "'"; //$NON-NLS-1$//$NON-NLS-2$
break;
case 1:
- scopeDescription= scopeDescription + ", '" + prjName + "'"; //$NON-NLS-1$ //$NON-NLS-2$
+ scopeDescription = scopeDescription + ", '" + prjName + "'"; //$NON-NLS-1$ //$NON-NLS-2$
break;
case 2:
- scopeDescription+= ", ..."; //$NON-NLS-1$
+ scopeDescription += ", ..."; //$NON-NLS-1$
break;
default:
break;
- }
+ }
}
}
break;
case ISearchPageContainer.SELECTION_SCOPE:
if (structuredSelection != null) {
- scopeDescription = CSearchMessages.SelectionScope;
- int ie= 0;
+ scopeDescription = CSearchMessages.SelectionScope;
+ int ie = 0;
for (Object sel : structuredSelection.toList()) {
- ICElement elem= getElement(sel);
+ ICElement elem = getElement(sel);
if (elem != null) {
elements.add(elem);
- switch(ie++) {
- case 0:
- scopeDescription= " '" + elem.toString() + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ switch (ie++) {
+ case 0:
+ scopeDescription = " '" + elem.toString() + "'"; //$NON-NLS-1$//$NON-NLS-2$
break;
case 1:
- scopeDescription= scopeDescription + ", '" + elem.toString() + "'"; //$NON-NLS-1$ //$NON-NLS-2$
+ scopeDescription = scopeDescription + ", '" + elem.toString() + "'"; //$NON-NLS-1$ //$NON-NLS-2$
break;
case 2:
- scopeDescription+= ", ..."; //$NON-NLS-1$
+ scopeDescription += ", ..."; //$NON-NLS-1$
break;
default:
break;
- }
+ }
}
}
break;
}
break;
case ISearchPageContainer.WORKSPACE_SCOPE:
- scopeDescription = CSearchMessages.WorkspaceScope;
+ scopeDescription = CSearchMessages.WorkspaceScope;
// Don't add anything
break;
case ISearchPageContainer.WORKING_SET_SCOPE:
- IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
- scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(workingSets));
+ IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets();
+ scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(workingSets));
for (int i = 0; i < workingSets.length; ++i) {
IAdaptable[] wsElements = workingSets[i].getElements();
for (int j = 0; j < wsElements.length; ++j) {
@@ -272,26 +248,25 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
break;
}
-
- ICElement[] scope = elements.isEmpty() ?
- null : elements.toArray(new ICElement[elements.size()]);
-
+
+ ICElement[] scope = elements.isEmpty() ? null : elements.toArray(new ICElement[elements.size()]);
+
try {
- CSearchPatternQuery job = new CSearchPatternQuery(scope, scopeDescription, patternStr,
- isCaseSensitive, searchFlags);
+ CSearchPatternQuery job = new CSearchPatternQuery(scope, scopeDescription, patternStr, isCaseSensitive,
+ searchFlags);
NewSearchUI.activateSearchResultView();
-
+
NewSearchUI.runQueryInBackground(job);
} catch (PatternSyntaxException e) {
- fLineManager.setErrorMessage(CSearchMessages.PDOMSearch_query_pattern_error);
+ fLineManager.setErrorMessage(CSearchMessages.PDOMSearch_query_pattern_error);
return false;
}
-
+
// Save our settings
IDialogSettings settings = getDialogSettings();
settings.put(STORE_CASE_SENSITIVE, isCaseSensitive);
-
+
if (previousPatterns == null) {
previousPatterns = new String[] { patternStr };
} else {
@@ -313,7 +288,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
settings.put(STORE_PREVIOUS_PATTERNS, previousPatterns);
-
+
settings.put(STORE_SEARCH_FLAGS, searchFlags);
return true;
@@ -322,104 +297,99 @@ public class CSearchPage extends DialogPage implements ISearchPage {
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
-
+
GridData gd;
- Composite result = new Composite(parent, SWT.NONE);
+ Composite result = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 10;
result.setLayout(layout);
result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
RowLayouter layouter = new RowLayouter(layout.numColumns);
gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL;
-
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL;
+
layouter.setDefaultGridData(gd, 0);
layouter.setDefaultGridData(gd, 1);
layouter.setDefaultSpan();
layouter.perform(createExpression(result));
layouter.perform(createSearchFor(result), createLimitTo(result), -1);
-
+
createNote(result);
-
+
setControl(result);
-
+
fLineManager = getStatusLineManager();
-
+
Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(result, ICHelpContextIds.C_SEARCH_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(result, ICHelpContextIds.C_SEARCH_PAGE);
}
private void createNote(Composite result) {
// Create a note that tells the user that this search only processes the active code (not grayed out in editor)
GridData gd;
- String noteTitle= CSearchMessages.CSearchPage_label_note;
- String noteMessage= CSearchMessages.CSearchPage_label_activeCodeRemark;
- Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
+ String noteTitle = CSearchMessages.CSearchPage_label_note;
+ String noteMessage = CSearchMessages.CSearchPage_label_activeCodeRemark;
+ Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
noteControl.setLayoutData(gd);
}
- /**
- * Creates a composite with a highlighted Note entry and a message text.
- * This is designed to take up the full width of the page.<br>
- * This method has been copied from class {@link PreferencePage}
- *
- * @param font the font to use
- * @param composite the parent composite
- * @param title the title of the note
- * @param message the message for the note
- * @return the composite for the note
- */
- protected Composite createNoteComposite(Font font, Composite composite,
- String title, String message) {
- Composite messageComposite = new Composite(composite, SWT.NONE);
- GridLayout messageLayout = new GridLayout();
- messageLayout.numColumns = 2;
- messageLayout.marginWidth = 0;
- messageLayout.marginHeight = 0;
- messageComposite.setLayout(messageLayout);
- messageComposite.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_FILL));
- messageComposite.setFont(font);
-
- final Label noteLabel = new Label(messageComposite, SWT.BOLD);
- noteLabel.setText(title);
- noteLabel.setFont(JFaceResources.getFontRegistry().getBold(
- JFaceResources.DIALOG_FONT));
- noteLabel
- .setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-
- Label messageLabel = new Label(messageComposite, SWT.WRAP);
- messageLabel.setText(message);
- messageLabel.setFont(font);
- return messageComposite;
- }
-
-
- private IStatusLineManager getStatusLineManager(){
-
- IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ /**
+ * Creates a composite with a highlighted Note entry and a message text.
+ * This is designed to take up the full width of the page.<br>
+ * This method has been copied from class {@link PreferencePage}
+ *
+ * @param font the font to use
+ * @param composite the parent composite
+ * @param title the title of the note
+ * @param message the message for the note
+ * @return the composite for the note
+ */
+ protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
+ Composite messageComposite = new Composite(composite, SWT.NONE);
+ GridLayout messageLayout = new GridLayout();
+ messageLayout.numColumns = 2;
+ messageLayout.marginWidth = 0;
+ messageLayout.marginHeight = 0;
+ messageComposite.setLayout(messageLayout);
+ messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ messageComposite.setFont(font);
+
+ final Label noteLabel = new Label(messageComposite, SWT.BOLD);
+ noteLabel.setText(title);
+ noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
+ noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+ Label messageLabel = new Label(messageComposite, SWT.WRAP);
+ messageLabel.setText(message);
+ messageLabel.setFont(font);
+ return messageComposite;
+ }
+
+ private IStatusLineManager getStatusLineManager() {
+
+ IWorkbenchWindow wbWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (wbWindow != null) {
- IWorkbenchPage page= wbWindow.getActivePage();
+ IWorkbenchPage page = wbWindow.getActivePage();
if (page != null) {
- IWorkbenchPartSite workbenchSite = page.getActivePart().getSite();
- if (workbenchSite instanceof IViewSite){
- return ((IViewSite) workbenchSite).getActionBars().getStatusLineManager();
- } else if (workbenchSite instanceof IEditorSite){
- return ((IEditorSite) workbenchSite).getActionBars().getStatusLineManager();
- }
+ IWorkbenchPartSite workbenchSite = page.getActivePart().getSite();
+ if (workbenchSite instanceof IViewSite) {
+ return ((IViewSite) workbenchSite).getActionBars().getStatusLineManager();
+ } else if (workbenchSite instanceof IEditorSite) {
+ return ((IEditorSite) workbenchSite).getActionBars().getStatusLineManager();
+ }
}
}
-
+
return null;
}
private Control createExpression(Composite parent) {
- Composite result = new Composite(parent, SWT.NONE);
+ Composite result = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
result.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
@@ -429,7 +399,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
// Pattern text + info
Label label = new Label(result, SWT.LEFT);
- label.setText(CSearchMessages.CSearchPage_expression_label);
+ label.setText(CSearchMessages.CSearchPage_expression_label);
gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 2;
label.setLayoutData(gd);
@@ -440,29 +410,40 @@ public class CSearchPage extends DialogPage implements ISearchPage {
@Override
public void verifyText(VerifyEvent event) {
final String text = patternCombo.getText();
- final char[] newChars= event.text.toCharArray();
- final StringBuilder result= new StringBuilder(newChars.length);
- boolean relax= prefix(text, event.start, result).contains(Keywords.OPERATOR);
+ final char[] newChars = event.text.toCharArray();
+ final StringBuilder result = new StringBuilder(newChars.length);
+ boolean relax = prefix(text, event.start, result).contains(Keywords.OPERATOR);
for (final char c : newChars) {
switch (c) {
- case '_':
+ case '_':
case ':': // scope operator
- case '?': case '*': // wild cards
+ case '?':
+ case '*': // wild cards
case '\\': // escaping wild-cards
result.append(c);
break;
case ' ':
if (prefix(text, event.start, result).endsWith(Keywords.OPERATOR)) {
- relax= true;
+ relax = true;
result.append(c);
}
break;
- case '&': case '|': case '+': case '-':
- case '!': case '=': case '>': case '<':
- case '%': case '^': case '(': case ')':
- case '[': case ']':
+ case '&':
+ case '|':
+ case '+':
+ case '-':
+ case '!':
+ case '=':
+ case '>':
+ case '<':
+ case '%':
+ case '^':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
if (prefix(text, event.start, result).endsWith(Keywords.OPERATOR)) {
- relax= true;
+ relax = true;
}
if (relax)
result.append(c);
@@ -474,49 +455,48 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
break;
}
- event.text= result.toString();
+ event.text = result.toString();
}
}
private String prefix(String text, int len, StringBuilder rest) {
- StringBuilder result= new StringBuilder(len + rest.length());
+ StringBuilder result = new StringBuilder(len + rest.length());
result.append(text, 0, len);
result.append(rest);
return result.toString();
}
});
-
+
patternCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
setPerformActionEnabled();
}
});
-
+
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalIndent = -gd.horizontalIndent;
patternCombo.setLayoutData(gd);
-
- // Ignore case checkbox
- caseSensitiveButton= new Button(result, SWT.CHECK);
- caseSensitiveButton.setText(CSearchMessages.CSearchPage_expression_caseSensitive);
- gd= new GridData();
+ // Ignore case checkbox
+ caseSensitiveButton = new Button(result, SWT.CHECK);
+ caseSensitiveButton.setText(CSearchMessages.CSearchPage_expression_caseSensitive);
+ gd = new GridData();
caseSensitiveButton.setLayoutData(gd);
caseSensitiveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
-// isCaseSensitive = caseSensitiveButton.getSelection();
+ // isCaseSensitive = caseSensitiveButton.getSelection();
setPerformActionEnabled();
}
});
-
+
return result;
}
private Control createLimitTo(Composite parent) {
Group result = new Group(parent, SWT.NONE);
- result.setText(CSearchMessages.CSearchPage_limitTo_label);
+ result.setText(CSearchMessages.CSearchPage_limitTo_label);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
result.setLayout(layout);
@@ -524,7 +504,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
Listener limitToListener = new Listener() {
@Override
public void handleEvent(Event event) {
- Button me = (Button)event.widget;
+ Button me = (Button) event.widget;
if (me == limitToButtons[limitToAllButtonIndex]) {
if (me.getSelection()) {
for (int i = 0; i < limitToButtons.length; ++i) {
@@ -545,9 +525,9 @@ public class CSearchPage extends DialogPage implements ISearchPage {
setPerformActionEnabled();
}
};
-
+
limitToButtons = new Button[limitToText.length];
- for(int i = 0; i < limitToText.length; i++){
+ for (int i = 0; i < limitToText.length; i++) {
Button button = new Button(result, SWT.CHECK);
button.setText(limitToText[i]);
button.setData(limitToData[i]);
@@ -555,20 +535,20 @@ public class CSearchPage extends DialogPage implements ISearchPage {
limitToButtons[i] = button;
}
- return result;
+ return result;
}
-
+
private Control createSearchFor(Composite parent) {
- Group result= new Group(parent, SWT.NONE);
- result.setText(CSearchMessages.CSearchPage_searchFor_label);
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
+ Group result = new Group(parent, SWT.NONE);
+ result.setText(CSearchMessages.CSearchPage_searchFor_label);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
result.setLayout(layout);
-
+
SelectionAdapter searchForSelectionAdapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- Button me = (Button)event.widget;
+ Button me = (Button) event.widget;
if (me == searchForButtons[searchAllButtonIndex]) {
if (me.getSelection()) {
for (int i = 0; i < searchForButtons.length; ++i) {
@@ -590,34 +570,34 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
};
- searchForButtons= new Button[searchForText.length];
- for (int i= 0; i < searchForText.length; i++) {
- Button button= new Button(result, SWT.CHECK);
+ searchForButtons = new Button[searchForText.length];
+ for (int i = 0; i < searchForText.length; i++) {
+ Button button = new Button(result, SWT.CHECK);
button.setText(searchForText[i]);
button.setData(searchForData[i]);
button.addSelectionListener(searchForSelectionAdapter);
- searchForButtons[i]= button;
+ searchForButtons[i] = button;
}
- return result;
+ return result;
}
-
+
@Override
public void setContainer(ISearchPageContainer container) {
pageContainer = container;
}
-
+
private ISearchPageContainer getContainer() {
return pageContainer;
}
-
+
private void setPerformActionEnabled() {
// Need a text string to search
if (this.patternCombo.getText().length() == 0) {
getContainer().setPerformActionEnabled(false);
return;
}
-
+
// Need a type
boolean any = false;
for (int i = 0; i < this.searchForButtons.length; ++i) {
@@ -630,7 +610,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
getContainer().setPerformActionEnabled(false);
return;
}
-
+
// Set limit to
any = false;
@@ -646,7 +626,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
getContainer().setPerformActionEnabled(true);
}
-
+
private IDialogSettings getDialogSettings() {
IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
IDialogSettings searchSettings = settings.getSection(PAGE_NAME);
@@ -659,10 +639,10 @@ public class CSearchPage extends DialogPage implements ISearchPage {
public void setVisible(boolean visible) {
if (visible) {
if (firstTime) {
- firstTime= false;
-
+ firstTime = false;
+
IDialogSettings settings = getDialogSettings();
-
+
int searchFlags = CSearchPatternQuery.FIND_ALL_TYPES | CSearchQuery.FIND_ALL_OCCURRENCES;
try {
searchFlags = settings.getInt(STORE_SEARCH_FLAGS);
@@ -673,16 +653,16 @@ public class CSearchPage extends DialogPage implements ISearchPage {
previousPatterns = settings.getArray(STORE_PREVIOUS_PATTERNS);
if (previousPatterns != null)
patternCombo.setItems(previousPatterns);
-
+
patternCombo.setVisibleItemCount(15);
// Initialize the selection
ISelection selection = getContainer().getSelection();
if (selection instanceof IStructuredSelection) {
- structuredSelection = (IStructuredSelection)selection;
+ structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
if (obj instanceof ICElement) {
- ICElement element = (ICElement)obj;
+ ICElement element = (ICElement) obj;
patternCombo.setText(element.getElementName());
// Clear the type flags so we can set them correctly for what we have selected
searchFlags = searchFlags & ~CSearchPatternQuery.FIND_ALL_TYPES;
@@ -728,17 +708,18 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
}
} else if (selection instanceof ITextSelection) {
- textSelection = (ITextSelection)selection;
+ textSelection = (ITextSelection) selection;
patternCombo.setText(textSelection.getText());
// TODO it might be good to do a selection parse to ensure that
// the selection is valid.
}
- if (patternCombo.getText().trim().length() == 0 && previousPatterns != null && previousPatterns.length > 0) {
+ if (patternCombo.getText().trim().length() == 0 && previousPatterns != null
+ && previousPatterns.length > 0) {
patternCombo.setText(previousPatterns[0]);
}
caseSensitiveButton.setSelection(settings.getBoolean(STORE_CASE_SENSITIVE));
-
+
if ((searchFlags & CSearchPatternQuery.FIND_ALL_TYPES) == CSearchPatternQuery.FIND_ALL_TYPES) {
searchForButtons[searchAllButtonIndex].setSelection(true);
for (int i = 0; i < searchForButtons.length; ++i) {
@@ -752,11 +733,11 @@ public class CSearchPage extends DialogPage implements ISearchPage {
for (int i = 0; i < searchForButtons.length; ++i) {
if (i != searchAllButtonIndex) {
searchForButtons[i].setSelection(
- (searchFlags & ((Integer)searchForButtons[i].getData()).intValue()) != 0);
+ (searchFlags & ((Integer) searchForButtons[i].getData()).intValue()) != 0);
}
}
}
-
+
if ((searchFlags & CSearchQuery.FIND_ALL_OCCURRENCES) == CSearchQuery.FIND_ALL_OCCURRENCES) {
limitToButtons[limitToAllButtonIndex].setSelection(true);
for (int i = 0; i < limitToButtons.length; ++i) {
@@ -768,12 +749,12 @@ public class CSearchPage extends DialogPage implements ISearchPage {
} else {
limitToButtons[limitToAllButtonIndex].setSelection(false);
for (int i = 0; i < limitToButtons.length - 1; ++i) {
- limitToButtons[i].setSelection(
- (searchFlags & ((Integer)limitToButtons[i].getData()).intValue()) != 0);
+ limitToButtons[i]
+ .setSelection((searchFlags & ((Integer) limitToButtons[i].getData()).intValue()) != 0);
}
}
}
-
+
patternCombo.setFocus();
setPerformActionEnabled();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java
index d84698ca162..6c0c74a3c87 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java
@@ -59,126 +59,126 @@ public class CSearchPatternQuery extends CSearchQuery {
public static final int FIND_NAMESPACE = 0x4000;
public static final int FIND_TYPEDEF = 0x10000;
public static final int FIND_MACRO = 0x20000;
- public static final int FIND_ALL_TYPES =
- FIND_CLASS_STRUCT | FIND_FUNCTION | FIND_VARIABLE |
- FIND_UNION | FIND_METHOD | FIND_FIELD | FIND_ENUM |
- FIND_ENUMERATOR | FIND_NAMESPACE | FIND_TYPEDEF | FIND_MACRO;
-
+ public static final int FIND_ALL_TYPES = FIND_CLASS_STRUCT | FIND_FUNCTION | FIND_VARIABLE | FIND_UNION
+ | FIND_METHOD | FIND_FIELD | FIND_ENUM | FIND_ENUMERATOR | FIND_NAMESPACE | FIND_TYPEDEF | FIND_MACRO;
+
private final String scopeDesc;
private final String patternStr;
private final Pattern[] pattern;
-
- public CSearchPatternQuery(
- ICElement[] scope,
- String scopeDesc,
- String patternStr,
- boolean isCaseSensitive,
+
+ public CSearchPatternQuery(ICElement[] scope, String scopeDesc, String patternStr, boolean isCaseSensitive,
int flags) throws PatternSyntaxException {
super(scope, flags);
this.scopeDesc = scopeDesc;
// adjust the pattern string to accomodate searches for operators
patternStr = CSearchUtil.adjustSearchStringForOperators(patternStr);
-
+
// remove spurious whitespace, which will make the search fail 100% of the time
this.patternStr = patternStr.trim();
-
+
// Parse the pattern string
List<Pattern> patternList = new ArrayList<Pattern>();
- StringBuilder buff = new StringBuilder();
- int n = patternStr.length();
- for (int i = 0; i < n; ++i) {
- char c = patternStr.charAt(i);
- switch (c) {
- case '\\':
- if (i+1 < n) {
- switch(patternStr.charAt(i+1)) {
- case '?':
- buff.append("\\?"); //$NON-NLS-1$
- break;
- case '*':
- buff.append("\\*"); //$NON-NLS-1$
- break;
- default:
- buff.append('\\');
- }
- } else {
- buff.append('\\');
- }
- break;
- case '*':
- buff.append(".*"); //$NON-NLS-1$
- break;
- case '?':
- buff.append('.');
- break;
- case ':':
- if (buff.length() > 0) {
- if (isCaseSensitive)
- patternList.add(Pattern.compile(buff.toString()));
- else
- patternList.add(Pattern.compile(buff.toString(),Pattern.CASE_INSENSITIVE));
- buff = new StringBuilder();
- }
- break;
- case '|': case '+': case '^': case '(': case ')': case '[': case ']':
+ StringBuilder buff = new StringBuilder();
+ int n = patternStr.length();
+ for (int i = 0; i < n; ++i) {
+ char c = patternStr.charAt(i);
+ switch (c) {
+ case '\\':
+ if (i + 1 < n) {
+ switch (patternStr.charAt(i + 1)) {
+ case '?':
+ buff.append("\\?"); //$NON-NLS-1$
+ break;
+ case '*':
+ buff.append("\\*"); //$NON-NLS-1$
+ break;
+ default:
+ buff.append('\\');
+ }
+ } else {
+ buff.append('\\');
+ }
+ break;
+ case '*':
+ buff.append(".*"); //$NON-NLS-1$
+ break;
+ case '?':
+ buff.append('.');
+ break;
+ case ':':
+ if (buff.length() > 0) {
+ if (isCaseSensitive)
+ patternList.add(Pattern.compile(buff.toString()));
+ else
+ patternList.add(Pattern.compile(buff.toString(), Pattern.CASE_INSENSITIVE));
+ buff = new StringBuilder();
+ }
+ break;
+ case '|':
+ case '+':
+ case '^':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
buff.append('\\').append(c);
break;
- default:
- buff.append(c);
- }
- }
-
- if (buff.length() > 0) {
+ default:
+ buff.append(c);
+ }
+ }
+
+ if (buff.length() > 0) {
if (isCaseSensitive)
patternList.add(Pattern.compile(buff.toString()));
else
- patternList.add(Pattern.compile(buff.toString(),Pattern.CASE_INSENSITIVE));
- }
-
- pattern = patternList.toArray(new Pattern[patternList.size()]);
+ patternList.add(Pattern.compile(buff.toString(), Pattern.CASE_INSENSITIVE));
+ }
+
+ pattern = patternList.toArray(new Pattern[patternList.size()]);
}
-
+
@Override
public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
try {
- IndexFilter filter= IndexFilter.ALL;
+ IndexFilter filter = IndexFilter.ALL;
IIndexBinding[] bindings = index.findBindings(pattern, false, filter, monitor);
ArrayList<IIndexBinding> matchedBindings = new ArrayList<IIndexBinding>();
for (int i = 0; i < bindings.length; ++i) {
IIndexBinding pdomBinding = bindings[i];
- // Select the requested bindings
- boolean matches= false;
+ // Select the requested bindings
+ boolean matches = false;
if ((flags & FIND_ALL_TYPES) == FIND_ALL_TYPES) {
- matches= true;
+ matches = true;
} else if (pdomBinding instanceof ICompositeType) {
- ICompositeType ct= (ICompositeType) pdomBinding;
+ ICompositeType ct = (ICompositeType) pdomBinding;
switch (ct.getKey()) {
case ICompositeType.k_struct:
case ICPPClassType.k_class:
- matches= (flags & FIND_CLASS_STRUCT) != 0;
+ matches = (flags & FIND_CLASS_STRUCT) != 0;
break;
case ICompositeType.k_union:
- matches= (flags & FIND_UNION) != 0;
+ matches = (flags & FIND_UNION) != 0;
break;
}
} else if (pdomBinding instanceof IEnumeration) {
- matches= (flags & FIND_ENUM) != 0;
+ matches = (flags & FIND_ENUM) != 0;
} else if (pdomBinding instanceof IEnumerator) {
- matches= (flags & FIND_ENUMERATOR) != 0;
+ matches = (flags & FIND_ENUMERATOR) != 0;
} else if (pdomBinding instanceof IField) {
- matches= (flags & FIND_FIELD) != 0;
+ matches = (flags & FIND_FIELD) != 0;
} else if (pdomBinding instanceof ICPPMethod) {
- matches= (flags & FIND_METHOD) != 0;
+ matches = (flags & FIND_METHOD) != 0;
} else if (pdomBinding instanceof IVariable) {
- matches= (flags & FIND_VARIABLE) != 0;
+ matches = (flags & FIND_VARIABLE) != 0;
} else if (pdomBinding instanceof IFunction) {
- matches= (flags & FIND_FUNCTION) != 0;
+ matches = (flags & FIND_FUNCTION) != 0;
} else if (pdomBinding instanceof ICPPNamespace || pdomBinding instanceof ICPPNamespaceAlias) {
- matches= (flags & FIND_NAMESPACE) != 0;
+ matches = (flags & FIND_NAMESPACE) != 0;
} else if (pdomBinding instanceof ITypedef) {
- matches= (flags & FIND_TYPEDEF) != 0;
+ matches = (flags & FIND_TYPEDEF) != 0;
}
if (matches) {
matchedBindings.add(pdomBinding);
@@ -196,12 +196,12 @@ public class CSearchPatternQuery extends CSearchQuery {
} catch (CoreException e) {
return e.getStatus();
}
-
+
return Status.OK_STATUS;
}
@Override
public String getResultLabel(int numMatches) {
- return getResultLabel(patternStr, scopeDesc, numMatches);
+ return getResultLabel(patternStr, scopeDesc, numMatches);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchProviderManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchProviderManager.java
index b8932081332..fc24b19cffe 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchProviderManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchProviderManager.java
@@ -39,7 +39,8 @@ public class CSearchProviderManager {
public static CSearchProviderManager INSTANCE = new CSearchProviderManager();
- private CSearchProviderManager() {}
+ private CSearchProviderManager() {
+ }
public List<IExternalSearchProvider> getExternalSearchProviders() {
if (externalSearchProviders == null) {
@@ -50,14 +51,15 @@ public class CSearchProviderManager {
try {
for (IConfigurationElement element : extension.getConfigurationElements()) {
if (ELEMENT_PROVIDER.equals(element.getName())) {
- Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
- if (provider instanceof IExternalSearchProvider) {
- externalSearchProviders.add((IExternalSearchProvider) provider);
- } else {
- CUIPlugin.logError(NLS.bind(CSearchMessages.CSearchProviderManager_InvalidSearchProvider,
- extension.getContributor().getName()));
- }
- }
+ Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
+ if (provider instanceof IExternalSearchProvider) {
+ externalSearchProviders.add((IExternalSearchProvider) provider);
+ } else {
+ CUIPlugin
+ .logError(NLS.bind(CSearchMessages.CSearchProviderManager_InvalidSearchProvider,
+ extension.getContributor().getName()));
+ }
+ }
}
} catch (CoreException e) {
CUIPlugin.log(e);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
index 7b4d2e1ce86..9a24686b830 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
@@ -86,10 +86,8 @@ public abstract class CSearchQuery implements ISearchQuery {
public static final int FIND_DECLARATIONS_DEFINITIONS = FIND_DECLARATIONS | FIND_DEFINITIONS;
public static final int FIND_ALL_OCCURRENCES = FIND_DECLARATIONS | FIND_DEFINITIONS | FIND_REFERENCES;
- protected static final long LABEL_FLAGS=
- CElementLabels.M_PARAMETER_TYPES |
- CElementLabels.ALL_FULLY_QUALIFIED |
- CElementLabels.TEMPLATE_ARGUMENTS;
+ protected static final long LABEL_FLAGS = CElementLabels.M_PARAMETER_TYPES | CElementLabels.ALL_FULLY_QUALIFIED
+ | CElementLabels.TEMPLATE_ARGUMENTS;
protected CSearchResult result;
protected int flags;
@@ -117,14 +115,14 @@ public abstract class CSearchQuery implements ISearchQuery {
} else {
Map<String, ICProject> projectMap = new HashMap<>();
Set<String> pathFilter = new HashSet<>();
- boolean needFilter= false;
+ boolean needFilter = false;
for (int i = 0; i < scope.length; ++i) {
ICProject project = scope[i].getCProject();
if (project != null && project.getProject().isOpen()) {
- IResource res= scope[i].getResource();
+ IResource res = scope[i].getResource();
if (res != null) {
pathFilter.add(res.getFullPath().toString());
- needFilter= needFilter || !(res instanceof IProject);
+ needFilter = needFilter || !(res instanceof IProject);
}
projectMap.put(project.getElementName(), project);
}
@@ -132,7 +130,7 @@ public abstract class CSearchQuery implements ISearchQuery {
projects = projectMap.values().toArray(new ICProject[projectMap.size()]);
if (needFilter) {
- fullPathFilter= pathFilter;
+ fullPathFilter = pathFilter;
}
}
} catch (CoreException e) {
@@ -140,11 +138,10 @@ public abstract class CSearchQuery implements ISearchQuery {
}
}
- protected String labelForBinding(final IIndex index, IBinding binding, String defaultLabel)
- throws CoreException {
- IIndexName[] names= index.findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS);
+ protected String labelForBinding(final IIndex index, IBinding binding, String defaultLabel) throws CoreException {
+ IIndexName[] names = index.findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS);
if (names.length > 0) {
- ICElementHandle elem= IndexUI.getCElementForName((ICProject) null, index, names[0]);
+ ICElementHandle elem = IndexUI.getCElementForName((ICProject) null, index, names[0]);
if (elem != null) {
return CElementLabels.getElementLabel(elem, LABEL_FLAGS);
}
@@ -160,7 +157,7 @@ public abstract class CSearchQuery implements ISearchQuery {
} else if ((flags & FIND_DECLARATIONS) != 0) {
type = CSearchMessages.PDOMSearchQuery_decls_label;
} else {
- type = CSearchMessages.PDOMSearchQuery_defs_label;
+ type = CSearchMessages.PDOMSearchQuery_defs_label;
}
return type;
}
@@ -174,7 +171,7 @@ public abstract class CSearchQuery implements ISearchQuery {
public String getResultLabel(String pattern, String scope, int matchCount) {
// Report pattern and number of matches
String label;
- final int kindFlags= flags & FIND_ALL_OCCURRENCES;
+ final int kindFlags = flags & FIND_ALL_OCCURRENCES;
switch (kindFlags) {
case FIND_REFERENCES:
label = NLS.bind(CSearchMessages.PDOMSearchQuery_refs_result_label, pattern);
@@ -194,8 +191,7 @@ public abstract class CSearchQuery implements ISearchQuery {
}
if (scope != null) {
- label= NLS.bind(CSearchMessages.PDOMSearchPatternQuery_PatternQuery_labelPatternInScope,
- label, scope);
+ label = NLS.bind(CSearchMessages.PDOMSearchPatternQuery_PatternQuery_labelPatternInScope, label, scope);
}
String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches, matchCount);
@@ -254,7 +250,8 @@ public abstract class CSearchQuery implements ISearchQuery {
enclosingElement = IndexUI.getCElementForName(preferred, index, enclosingDefinition);
} else {
// Get names from the external search providers.
- for (IExternalSearchProvider provider : CSearchProviderManager.INSTANCE.getExternalSearchProviders()) {
+ for (IExternalSearchProvider provider : CSearchProviderManager.INSTANCE
+ .getExternalSearchProviders()) {
enclosingElement = provider.getEnclosingElement(name);
if (enclosingElement != null)
break;
@@ -262,8 +259,7 @@ public abstract class CSearchQuery implements ISearchQuery {
}
boolean isWriteAccess = name.isWriteAccess();
- matches.add(new Match(nodeOffset, nodeLength, isPolymorphicOnly, enclosingElement,
- isWriteAccess));
+ matches.add(new Match(nodeOffset, nodeLength, isPolymorphicOnly, enclosingElement, isWriteAccess));
}
}
}
@@ -290,8 +286,8 @@ public abstract class CSearchQuery implements ISearchQuery {
return matches;
}
- private void collectNames(IIndex index, Collection<IIndexName> names,
- Collection<IIndexName> polymorphicNames) throws CoreException {
+ private void collectNames(IIndex index, Collection<IIndexName> names, Collection<IIndexName> polymorphicNames)
+ throws CoreException {
// group all matched names by files
Map<IIndexFile, Set<Match>> fileMatches = new HashMap<>();
createMatchesFromNames(index, fileMatches, names, false);
@@ -301,10 +297,10 @@ public abstract class CSearchQuery implements ISearchQuery {
Map<IPath, ITextEditor> pathsDirtyEditors = new HashMap<>();
for (IEditorPart editorPart : dirtyEditors) {
if (editorPart instanceof ITextEditor) {
- ITextEditor textEditor = (ITextEditor)editorPart;
+ ITextEditor textEditor = (ITextEditor) editorPart;
IEditorInput editorInput = editorPart.getEditorInput();
if (editorInput instanceof IPathEditorInput) {
- IPathEditorInput pathEditorInput = (IPathEditorInput)editorInput;
+ IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
pathsDirtyEditors.put(pathEditorInput.getPath(), textEditor);
}
}
@@ -353,9 +349,9 @@ public abstract class CSearchQuery implements ISearchQuery {
protected void createMatches(IIndex index, IBinding[] bindings) throws CoreException {
if (bindings == null)
return;
- List<IIndexName> names= new ArrayList<>();
- List<IIndexName> polymorphicNames= null;
- HashSet<IBinding> handled= new HashSet<>();
+ List<IIndexName> names = new ArrayList<>();
+ List<IIndexName> polymorphicNames = null;
+ HashSet<IBinding> handled = new HashSet<>();
for (IBinding binding : bindings) {
if (binding != null && handled.add(binding)) {
@@ -374,11 +370,11 @@ public abstract class CSearchQuery implements ISearchQuery {
}
if (binding instanceof ICPPMethod) {
- ICPPMethod m= (ICPPMethod) binding;
+ ICPPMethod m = (ICPPMethod) binding;
ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m);
if (msInBases.length > 0) {
if (polymorphicNames == null) {
- polymorphicNames= new ArrayList<>();
+ polymorphicNames = new ArrayList<>();
}
for (ICPPMethod mInBase : msInBases) {
if (mInBase != null && handled.add(mInBase)) {
@@ -404,12 +400,12 @@ public abstract class CSearchQuery implements ISearchQuery {
}
private void createMatches1(IIndex index, IBinding binding, List<IIndexName> names) throws CoreException {
- IIndexName[] bindingNames= index.findNames(binding, flags);
+ IIndexName[] bindingNames = index.findNames(binding, flags);
if (fullPathFilter == null) {
names.addAll(Arrays.asList(bindingNames));
} else {
for (IIndexName name : bindingNames) {
- String fullPath= name.getFile().getLocation().getFullPath();
+ String fullPath = name.getFile().getLocation().getFullPath();
if (fullPath != null && accept(fullPath))
names.add(name);
}
@@ -420,16 +416,16 @@ public abstract class CSearchQuery implements ISearchQuery {
while (true) {
if (fullPathFilter.contains(fullPath))
return true;
- int idx= fullPath.lastIndexOf('/');
+ int idx = fullPath.lastIndexOf('/');
if (idx < 0)
return false;
- fullPath= fullPath.substring(0, idx);
+ fullPath = fullPath.substring(0, idx);
}
}
protected void createLocalMatches(IASTTranslationUnit ast, IBinding binding) throws CoreException {
if (binding != null) {
- Set<IASTName> names= new HashSet<>();
+ Set<IASTName> names = new HashSet<>();
names.addAll(Arrays.asList(ast.getDeclarationsInAST(binding)));
names.addAll(Arrays.asList(ast.getDefinitionsInAST(binding)));
names.addAll(Arrays.asList(ast.getReferences(binding)));
@@ -437,26 +433,25 @@ public abstract class CSearchQuery implements ISearchQuery {
IIndexFileLocation fileLocation = null;
Set<Match> localMatches = new HashSet<>();
for (IASTName name : names) {
- if (((flags & FIND_DECLARATIONS) != 0 && name.isDeclaration()) ||
- ((flags & FIND_DEFINITIONS) != 0 && name.isDefinition()) ||
- ((flags & FIND_REFERENCES) != 0 && name.isReference())) {
- ASTTypeInfo typeInfo= ASTTypeInfo.create(name);
+ if (((flags & FIND_DECLARATIONS) != 0 && name.isDeclaration())
+ || ((flags & FIND_DEFINITIONS) != 0 && name.isDefinition())
+ || ((flags & FIND_REFERENCES) != 0 && name.isReference())) {
+ ASTTypeInfo typeInfo = ASTTypeInfo.create(name);
if (typeInfo != null) {
- ITypeReference ref= typeInfo.getResolvedReference();
+ ITypeReference ref = typeInfo.getResolvedReference();
if (ref != null) {
ICElement element = null;
IASTNode node = name;
while (node != null && !(node instanceof IASTFunctionDefinition)) {
- node= node.getParent();
+ node = node.getParent();
}
if (node != null) {
IASTFunctionDefinition definition = (IASTFunctionDefinition) node;
- element = IndexUI.getCElementForName(getPreferredProject(),
- ast.getIndex(), definition.getDeclarator().getName());
+ element = IndexUI.getCElementForName(getPreferredProject(), ast.getIndex(),
+ definition.getDeclarator().getName());
}
boolean isWrite = CSearchUtil.isWriteOccurrence(name, binding);
- localMatches.add(new Match(ref.getOffset(), ref.getLength(), false,
- element, isWrite));
+ localMatches.add(new Match(ref.getOffset(), ref.getLength(), false, element, isWrite));
fileLocation = typeInfo.getIFL();
}
}
@@ -507,16 +502,16 @@ public abstract class CSearchQuery implements ISearchQuery {
}
private ICProject getPreferredProject() {
- ICProject preferred= null;
+ ICProject preferred = null;
if (projects != null && projects.length == 1) {
- preferred= projects[0];
+ preferred = projects[0];
}
return preferred;
}
@Override
public final IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
- CSearchResult result= (CSearchResult) getSearchResult();
+ CSearchResult result = (CSearchResult) getSearchResult();
result.removeAll();
result.setIndexerBusy(!CCorePlugin.getIndexManager().isIndexerIdle());
@@ -550,7 +545,7 @@ public abstract class CSearchQuery implements ISearchQuery {
}
public String getScopeDescription() {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
switch (scope.length) {
case 0:
break;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java
index 00200afed3e..6a109be6746 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java
@@ -53,7 +53,8 @@ import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
public class CSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
private static final String KEY_SHOW_POLYMORPHIC_CALLS = "ShowPolymorphicCalls"; //$NON-NLS-1$
private static final String KEY_HIDE_READ_ONLY_REFERENCES = "HideReadOnlyReferences"; //$NON-NLS-1$
- final static MatchFilter[] ALL_FILTERS = new MatchFilter[] { HidePolymorphicCalls.FILTER, HideReadOnlyReferences.READ_ONLY_FILTER };
+ final static MatchFilter[] ALL_FILTERS = new MatchFilter[] { HidePolymorphicCalls.FILTER,
+ HideReadOnlyReferences.READ_ONLY_FILTER };
private CSearchQuery query;
private boolean indexerBusy;
@@ -74,27 +75,27 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
}
private String getFileName(IEditorPart editor) {
- final IEditorInput input= editor.getEditorInput();
- IPath path= null;
+ final IEditorInput input = editor.getEditorInput();
+ IPath path = null;
if (input instanceof FileEditorInput) {
final FileEditorInput fileInput = (FileEditorInput) input;
- path= fileInput.getFile().getLocation();
+ path = fileInput.getFile().getLocation();
} else if (input instanceof ExternalEditorInput) {
final ExternalEditorInput extInput = (ExternalEditorInput) input;
- path= extInput.getPath();
+ path = extInput.getPath();
} else if (input instanceof IStorageEditorInput) {
try {
- final IStorage storage= ((IStorageEditorInput) input).getStorage();
- path= storage.getFullPath();
+ final IStorage storage = ((IStorageEditorInput) input).getStorage();
+ path = storage.getFullPath();
} catch (CoreException e) {
CUIPlugin.log(e);
}
} else if (input instanceof IPathEditorInput) {
- path= ((IPathEditorInput) input).getPath();
+ path = ((IPathEditorInput) input).getPath();
} else {
- ILocationProvider provider= input.getAdapter(ILocationProvider.class);
+ ILocationProvider provider = input.getAdapter(ILocationProvider.class);
if (provider != null) {
- path= provider.getPath(input);
+ path = provider.getPath(input);
}
}
if (path != null)
@@ -105,16 +106,16 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
@Override
public boolean isShownInEditor(Match match, IEditorPart editor) {
- final String fileName= getFileName(editor);
+ final String fileName = getFileName(editor);
if (fileName != null && match instanceof CSearchMatch) {
- final IPath filePath= new Path(fileName);
+ final IPath filePath = new Path(fileName);
return filePath.equals(IndexLocationFactory.getAbsolutePath(((CSearchMatch) match).getLocation()));
}
return false;
}
private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException {
- IPath pfilename= new Path(filename);
+ IPath pfilename = new Path(filename);
List<Match> list = new ArrayList<>();
Object[] elements = result.getElements();
for (int i = 0; i < elements.length; ++i) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java
index 0ab0357c6f6..03fe57163f0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java
@@ -46,13 +46,12 @@ public class CSearchTextSelectionQuery extends CSearchQuery {
private ITranslationUnit tu;
private ITextSelection selection;
private String label;
-
- public CSearchTextSelectionQuery(ICElement[] scope, ITranslationUnit tu, ITextSelection selection,
- int flags) {
+
+ public CSearchTextSelectionQuery(ICElement[] scope, ITranslationUnit tu, ITextSelection selection, int flags) {
super(scope, flags | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
this.tu = tu;
this.selection = selection;
- this.label= selection.getText();
+ this.label = selection.getText();
}
@Override
@@ -61,15 +60,16 @@ public class CSearchTextSelectionQuery extends CSearchQuery {
@Override
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
if (ast != null) {
- IASTName searchName= ast.getNodeSelector(null).findEnclosingName(selection.getOffset(), selection.getLength());
+ IASTName searchName = ast.getNodeSelector(null).findEnclosingName(selection.getOffset(),
+ selection.getLength());
if (searchName != null) {
try {
CPPSemantics.pushLookupPoint(searchName);
- label= searchName.toString();
- IBinding binding= searchName.resolveBinding();
+ label = searchName.toString();
+ IBinding binding = searchName.resolveBinding();
if (!(binding instanceof IProblemBinding)) {
if (binding != null) {
- IScope scope= null;
+ IScope scope = null;
try {
scope = binding.getScope();
} catch (DOMException e) {
@@ -80,9 +80,9 @@ public class CSearchTextSelectionQuery extends CSearchQuery {
}
}
binding = index.findBinding(searchName);
- binding= CPPTemplates.findDeclarationForSpecialization(binding);
+ binding = CPPTemplates.findDeclarationForSpecialization(binding);
if (binding != null) {
- label= labelForBinding(index, binding, label);
+ label = labelForBinding(index, binding, label);
createMatches(index, binding);
return Status.OK_STATUS;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeContentProvider.java
index c67079d7270..95c77e7b94d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeContentProvider.java
@@ -53,7 +53,7 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
private final CSearchViewPage fPage;
CSearchTreeContentProvider(CSearchViewPage page) {
- fPage= page;
+ fPage = page;
}
@Override
@@ -76,9 +76,9 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
return null;
}
- @Override
+ @Override
public boolean hasChildren(Object element) {
- return tree.get(element) != null;
+ return tree.get(element) != null;
}
@Override
@@ -92,7 +92,7 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- this.viewer = (TreeViewer)viewer;
+ this.viewer = (TreeViewer) viewer;
this.result = (CSearchResult) newInput;
initialize(result);
viewer.refresh();
@@ -104,9 +104,8 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
*/
private void insertUnindexedProjectWarningElement(ICProject project) {
insertCElement(project);
- insertChild(project,
- new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
- CSearchMessages.PDOMSearchTreeContentProvider_IndexerNotEnabledWarning));
+ insertChild(project, new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ CSearchMessages.PDOMSearchTreeContentProvider_IndexerNotEnabledWarning));
}
/**
@@ -115,11 +114,10 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
*/
private void insertClosedProjectWarningElement(ICProject project) {
insertCElement(project);
- insertChild(project,
- new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
- CSearchMessages.PDOMSearchTreeContentProvider_ProjectClosedWarning));
+ insertChild(project, new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ CSearchMessages.PDOMSearchTreeContentProvider_ProjectClosedWarning));
}
-
+
private boolean insertChild(Object parent, Object child) {
Set<Object> children = tree.get(parent);
if (children == null) {
@@ -128,27 +126,27 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
}
return children.add(child);
}
-
+
private void insertSearchElement(CSearchElement element) {
- IIndexFileLocation location= element.getLocation();
+ IIndexFileLocation location = element.getLocation();
IFile[] files;
- if(location.getFullPath()!=null) {
- files= new IFile[] {ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()))};
+ if (location.getFullPath() != null) {
+ files = new IFile[] { ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath())) };
} else {
- IPath path= IndexLocationFactory.getAbsolutePath(element.getLocation());
- files= ResourceLookup.findFilesForLocation(path);
+ IPath path = IndexLocationFactory.getAbsolutePath(element.getLocation());
+ files = ResourceLookup.findFilesForLocation(path);
}
- boolean handled= false;
+ boolean handled = false;
if (files.length > 0) {
for (int j = 0; j < files.length; ++j) {
ICElement celement = CoreModel.getDefault().create(files[j]);
if (celement != null) {
insertChild(celement, element);
insertCElement(celement);
- handled= true;
+ handled = true;
}
}
- }
+ }
if (!handled) {
// insert a folder and then the file under that
IPath path = IndexLocationFactory.getAbsolutePath(location);
@@ -164,7 +162,7 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
}
}
}
-
+
private void insertCElement(ICElement element) {
if (element instanceof ICProject)
insertChild(result, element);
@@ -177,12 +175,12 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
insertCElement(parent);
}
}
-
+
@Override
public void elementsChanged(Object[] elements) {
if (elements != null) {
for (int i = 0; i < elements.length; ++i) {
- CSearchElement element = (CSearchElement)elements[i];
+ CSearchElement element = (CSearchElement) elements[i];
if (fPage.getDisplayedMatchCount(element) > 0) {
insertSearchElement(element);
} else {
@@ -214,30 +212,30 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
}
return false;
}
-
+
@Override
public void clear() {
initialize(result);
}
-
+
private void initialize(final CSearchResult result) {
this.result = result;
tree.clear();
if (result != null) {
// if indexer was busy, record that
if (result.wasIndexerBusy()) {
- insertChild(result, IPDOMSearchContentProvider.INCOMPLETE_RESULTS_NODE);
+ insertChild(result, IPDOMSearchContentProvider.INCOMPLETE_RESULTS_NODE);
}
-
+
Object[] elements = result.getElements();
for (int i = 0; i < elements.length; ++i) {
- final CSearchElement element = (CSearchElement)elements[i];
+ final CSearchElement element = (CSearchElement) elements[i];
if (fPage.getDisplayedMatchCount(element) > 0)
insertSearchElement(element);
}
// add all the projects which have no results
- ICProject[] projects = ((CSearchQuery)result.getQuery()).getProjects();
+ ICProject[] projects = ((CSearchQuery) result.getQuery()).getProjects();
for (int i = 0; i < projects.length; ++i) {
ICProject project = projects[i];
Object projectResults = tree.get(project);
@@ -247,16 +245,16 @@ public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSe
}
}
}
-
+
protected void remove(Object element) {
Object parent = getParent(element);
if (parent == null)
// reached the search result
return;
-
+
Set<Object> siblings = tree.get(parent);
siblings.remove(element);
-
+
if (siblings.isEmpty()) {
// remove the parent
remove(parent);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeLabelProvider.java
index 57a19db3152..27efefe9691 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeLabelProvider.java
@@ -26,30 +26,30 @@ import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.ui.util.Messages;
public class CSearchTreeLabelProvider extends CSearchLabelProvider {
-
+
public CSearchTreeLabelProvider(CSearchViewPage page) {
super(page);
}
-
+
@Override
public String getText(Object element) {
- final String text= super.getText(element);
- final int count= getMatchCount(element);
+ final String text = super.getText(element);
+ final int count = getMatchCount(element);
if (count <= 1) {
return text;
}
return text + " " //$NON-NLS-1$
- + Messages.format(CSearchMessages.CSearchResultCollector_matches, Integer.valueOf(count));
+ + Messages.format(CSearchMessages.CSearchResultCollector_matches, Integer.valueOf(count));
}
@Override
public StyledString getStyledText(Object element) {
if (element instanceof TranslationUnit) {
StyledString styled = new StyledString(super.getText(element));
- final int count= getMatchCount(element);
+ final int count = getMatchCount(element);
if (count > 1) {
final String matchesCount = " " //$NON-NLS-1$
- + Messages.format(CSearchMessages.CSearchResultCollector_matches, Integer.valueOf(count));
+ + Messages.format(CSearchMessages.CSearchResultCollector_matches, Integer.valueOf(count));
styled.append(matchesCount, StyledString.COUNTER_STYLER);
return styled;
}
@@ -72,7 +72,7 @@ public class CSearchTreeLabelProvider extends CSearchLabelProvider {
private String getElementDescription(ICElement element) {
ICElement parent = element.getParent();
if (parent instanceof IStructure) {
- return parent.getElementName() + "::" + element.getElementName(); //$NON-NLS-1$
+ return parent.getElementName() + "::" + element.getElementName(); //$NON-NLS-1$
}
return element.getElementName();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUnresolvedIncludesQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUnresolvedIncludesQuery.java
index efcd4923d8b..4c420fa2bbf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUnresolvedIncludesQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUnresolvedIncludesQuery.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
import org.eclipse.core.runtime.CoreException;
@@ -44,9 +44,9 @@ public class CSearchUnresolvedIncludesQuery extends CSearchQuery {
for (IIndexFile file : index.getFilesWithUnresolvedIncludes()) {
for (IIndexInclude include : file.getIncludes()) {
if (include.isActive() && !include.isResolved()) {
- result.addMatch(new CSearchMatch(new ProblemSearchElement(
- IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, include.getFullName(),
- include.getIncludedByLocation()),
+ result.addMatch(new CSearchMatch(
+ new ProblemSearchElement(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND,
+ include.getFullName(), include.getIncludedByLocation()),
include.getNameOffset(), include.getNameLength()));
}
}
@@ -64,7 +64,8 @@ public class CSearchUnresolvedIncludesQuery extends CSearchQuery {
@Override
public String getResultLabel(int matchCount) {
- String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches, Integer.valueOf(matchCount));
+ String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches,
+ Integer.valueOf(matchCount));
return getLabel() + " " + countLabel; //$NON-NLS-1$
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
index b40e9fb7bce..cbe484bebbf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
@@ -25,9 +25,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWri
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
public class CSearchUtil {
- public static int LRU_WORKINGSET_LIST_SIZE= 3;
+ public static int LRU_WORKINGSET_LIST_SIZE = 3;
private static LRUWorkingSets workingSetsCache;
-
+
public CSearchUtil() {
super();
}
@@ -35,7 +35,7 @@ public class CSearchUtil {
public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
if (workingSets == null || workingSets.length < 1)
return;
-
+
CSearchUtil.getLRUWorkingSets().add(workingSets);
}
@@ -45,19 +45,19 @@ public class CSearchUtil {
}
return CSearchUtil.workingSetsCache;
}
-
+
public static String toString(IWorkingSet[] workingSets) {
if (workingSets != null && workingSets.length > 0) {
String string = ""; //$NON-NLS-1$
for (int i = 0; i < workingSets.length; i++) {
if (i > 0)
- string += ", "; //$NON-NLS-1$
+ string += ", "; //$NON-NLS-1$
string += workingSets[i].getName();
}
-
+
return string;
}
-
+
return null;
}
@@ -65,22 +65,31 @@ public class CSearchUtil {
boolean isWrite;
if (binding instanceof ICPPVariable) {
isWrite = ((CPPVariableReadWriteFlags.getReadWriteFlags(node) & PDOMName.WRITE_ACCESS) != 0);
- } else {
+ } else {
isWrite = ((CVariableReadWriteFlags.getReadWriteFlags(node) & PDOMName.WRITE_ACCESS) != 0);
}
return isWrite;
}
-
-
+
/**
- * Returns true whether 'ch' could the first character of an overloadable C++ operator.
+ * Returns true whether 'ch' could the first character of an overloadable C++ operator.
*/
private static boolean isOperatorChar(char ch) {
switch (ch) {
- case '&': case '|': case '+': case '-':
- case '!': case '=': case '>': case '<':
- case '%': case '^': case '(': case ')':
- case '[': case '~':
+ case '&':
+ case '|':
+ case '+':
+ case '-':
+ case '!':
+ case '=':
+ case '>':
+ case '<':
+ case '%':
+ case '^':
+ case '(':
+ case ')':
+ case '[':
+ case '~':
return true;
default:
return false;
@@ -91,13 +100,13 @@ public class CSearchUtil {
* If 'searchStr' contains the name of an overloadable operator with no
* space between 'operator' and the operator (e.g. 'operator<'), insert
* a space (yielding e.g. 'operator <'). This is necessary because the
- * binding names for overloaded operators in the index contain such a
- * space, and the search wouldn't find them otherwise.
+ * binding names for overloaded operators in the index contain such a
+ * space, and the search wouldn't find them otherwise.
*/
public static String adjustSearchStringForOperators(String searchStr) {
- int operatorIndex = searchStr.indexOf("operator"); //$NON-NLS-1$
+ int operatorIndex = searchStr.indexOf("operator"); //$NON-NLS-1$
if (operatorIndex >= 0) { // Only do this if string actually contains "operator"
- int operatorCharIndex = operatorIndex + 8; // "operator" is 8 characters
+ int operatorCharIndex = operatorIndex + 8; // "operator" is 8 characters
if (operatorCharIndex < searchStr.length() && isOperatorChar(searchStr.charAt(operatorCharIndex))) {
searchStr = searchStr.substring(0, operatorCharIndex) + ' ' + searchStr.substring(operatorCharIndex);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewPage.java
index 3f20b7620c0..e0e06fae8f2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewPage.java
@@ -54,16 +54,14 @@ import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
* Implementation of the search view page for index based searches.
*/
public class CSearchViewPage extends AbstractTextSearchViewPage {
- public static final int LOCATION_COLUMN_INDEX = 0;
+ public static final int LOCATION_COLUMN_INDEX = 0;
public static final int DEFINITION_COLUMN_INDEX = 1;
public static final int MATCH_COLUMN_INDEX = 2;
- private static final String[] fColumnLabels = new String[] {
- CSearchMessages.PDOMSearchViewPageLocationColumn_label,
- CSearchMessages.PDOMSearchViewPageDefinitionColumn_label,
- CSearchMessages.PDOMSearchViewPageMatchColumn_label
- };
-
+ private static final String[] fColumnLabels = new String[] { CSearchMessages.PDOMSearchViewPageLocationColumn_label,
+ CSearchMessages.PDOMSearchViewPageDefinitionColumn_label,
+ CSearchMessages.PDOMSearchViewPageMatchColumn_label };
+
private static final String KEY_LOCATION_COLUMN_WIDTH = "locationColumnWidth"; //$NON-NLS-1$
private static final String KEY_DEFINITION_COLUMN_WIDTH = "definitionColumnWidth"; //$NON-NLS-1$
private static final String KEY_MATCH_COLUMN_WIDTH = "matchColumnWidth"; //$NON-NLS-1$
@@ -73,19 +71,19 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
private boolean fShowEnclosingDefinitions;
private ShowEnclosingDefinitionsAction fShowEnclosingDefinitionsAction;
private final int[] fColumnWidths = { 300, 150, 300 };
-
+
private class ShowEnclosingDefinitionsAction extends Action {
public ShowEnclosingDefinitionsAction() {
super(CSearchMessages.PDOMSearchViewPage_ShowEnclosingDefinitions_actionLabel, SWT.CHECK);
setChecked(fShowEnclosingDefinitions);
}
-
+
@Override
public void run() {
setShowEnclosingDefinitions(isChecked());
}
}
-
+
public CSearchViewPage(int supportedLayouts) {
super(supportedLayouts);
}
@@ -98,7 +96,7 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
public void init(IPageSite pageSite) {
super.init(pageSite);
fShowEnclosingDefinitionsAction = new ShowEnclosingDefinitionsAction();
- IMenuManager menuManager= pageSite.getActionBars().getMenuManager();
+ IMenuManager menuManager = pageSite.getActionBars().getMenuManager();
menuManager.add(fShowEnclosingDefinitionsAction);
menuManager.updateAll(true);
pageSite.getActionBars().updateActionBars();
@@ -126,7 +124,7 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
}
setShowEnclosingDefinitions(showEnclosingDefinitions);
}
-
+
@Override
public void saveState(IMemento memento) {
super.saveState(memento);
@@ -136,7 +134,7 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
memento.putInteger(KEY_MATCH_COLUMN_WIDTH, fColumnWidths[MATCH_COLUMN_INDEX]);
memento.putBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS, fShowEnclosingDefinitions);
}
-
+
public void setShowEnclosingDefinitions(boolean showEnclosingDefinitions) {
if (fShowEnclosingDefinitions == showEnclosingDefinitions)
return;
@@ -179,19 +177,19 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
/**
* Supply a sorter for the list and tree content providers to supply some order to the
- * large numbers of matches that may result.
+ * large numbers of matches that may result.
* <p>
* This sorter categorizes the different kinds of ICElement matches (as well as IStatus
* messages and External Files groups) to place them in groups. The items within a
* category are sorted in the default way {@link ViewerComparator#compare(Viewer, Object, Object)} works,
* by comparing text labels.
* <p>
- * A potential concern here is that, in sorting the elements by name, the user may
+ * A potential concern here is that, in sorting the elements by name, the user may
* find himself randomly jumping around a file when navigating search results in order.
* As this only happens when a search matches different identifiers or identifiers of
* different types, and since the user can use a textual search within a file to navigate
* the same results (ignoring extraneous hits in comments or disabled code), I argue it's not
- * a big deal. Furthermore, usually it would be a wildcard search that would result in
+ * a big deal. Furthermore, usually it would be a wildcard search that would result in
* this situation -- indicating the user doesn't know the identifier and wants to find it using
* search. In such a case, a sorted list of results in much more friendly to navigate.
*/
@@ -212,17 +210,17 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
}
return super.compare(viewer, e1, e2);
}
-
+
@Override
public int category(Object element) {
// place status messages first
- if (element instanceof IStatus) {
+ if (element instanceof IStatus) {
return -1000;
}
-
+
// keep elements of the same type together
if (element instanceof TypeInfoSearchElement) {
- TypeInfoSearchElement searchElement = (TypeInfoSearchElement)element;
+ TypeInfoSearchElement searchElement = (TypeInfoSearchElement) element;
int type = searchElement.getTypeInfo().getCElementType();
// handle unknown types
if (type < 0) {
@@ -237,26 +235,26 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
}
return Math.min(Math.max(0, type), 900);
}
-
+
// place external folders next to last
if (element instanceof IPath || element instanceof IIndexFileLocation) {
return 999;
}
-
+
// place external file matches last
if (element == IPDOMSearchContentProvider.URI_CONTAINER) {
return 1000;
}
-
+
return 2000;
}
}
-
+
@Override
protected void configureTreeViewer(TreeViewer viewer) {
contentProvider = new CSearchTreeContentProvider(this);
viewer.setComparator(new SearchViewerComparator());
- viewer.setContentProvider((CSearchTreeContentProvider)contentProvider);
+ viewer.setContentProvider((CSearchTreeContentProvider) contentProvider);
CSearchTreeLabelProvider innerLabelProvider = new CSearchTreeLabelProvider(this);
ColoringLabelProvider labelProvider = new ColoringLabelProvider(innerLabelProvider);
viewer.setLabelProvider(labelProvider);
@@ -267,9 +265,9 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
createColumns(viewer);
contentProvider = new CSearchListContentProvider(this);
viewer.setComparator(new SearchViewerComparator());
- viewer.setContentProvider((CSearchListContentProvider)contentProvider);
+ viewer.setContentProvider((CSearchListContentProvider) contentProvider);
}
-
+
@Override
protected TableViewer createTableViewer(Composite parent) {
TableViewer tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
@@ -281,7 +279,7 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
});
return tableViewer;
}
-
+
private void saveColumnWidths() {
StructuredViewer viewer = getViewer();
if (viewer instanceof TableViewer) {
@@ -289,8 +287,8 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
for (int i = 0; i < fColumnLabels.length; i++) {
if (i == DEFINITION_COLUMN_INDEX && !fShowEnclosingDefinitions)
continue;
- fColumnWidths[i] = tableViewer.getTable().getColumn(i).getWidth();
- }
+ fColumnWidths[i] = tableViewer.getTable().getColumn(i).getWidth();
+ }
}
}
@@ -314,13 +312,14 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
}
@Override
- protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException {
+ protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate)
+ throws PartInitException {
if (!(match instanceof CSearchMatch))
return;
-
+
try {
- Object element= ((CSearchMatch) match).getElement();
- IIndexFileLocation ifl= ((CSearchElement) element).getLocation();
+ Object element = ((CSearchMatch) match).getElement();
+ IIndexFileLocation ifl = ((CSearchElement) element).getLocation();
IPath path = IndexLocationFactory.getPath(ifl);
IEditorPart editor = EditorUtility.openInEditor(path, null, activate);
if (editor instanceof ITextEditor) {
@@ -331,7 +330,7 @@ public class CSearchViewPage extends AbstractTextSearchViewPage {
CUIPlugin.log(e);
}
}
-
+
@Override
public StructuredViewer getViewer() {
return super.getViewer();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CountLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CountLabelProvider.java
index d35d1a4d593..4ae22a3e9c2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CountLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CountLabelProvider.java
@@ -38,10 +38,10 @@ public class CountLabelProvider extends LabelProvider {
private AbstractTextSearchViewPage fPage;
public CountLabelProvider(AbstractTextSearchViewPage page, ILabelProvider inner) {
- fPage= page;
- fLabelProvider= inner;
+ fPage = page;
+ fLabelProvider = inner;
}
-
+
public ILabelProvider getLabelProvider() {
return fLabelProvider;
}
@@ -54,12 +54,13 @@ public class CountLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
int c = fPage.getInput().getMatchCount(element);
-
- String text= fLabelProvider.getText(element);
+
+ String text = fLabelProvider.getText(element);
if (c == 0)
return text;
- Integer matchCount= c;
- return fLabelProvider.getText(element) + " "+ Messages.format(CSearchMessages.CSearchResultCollector_matches, matchCount); //$NON-NLS-1$
+ Integer matchCount = c;
+ return fLabelProvider.getText(element) + " " //$NON-NLS-1$
+ + Messages.format(CSearchMessages.CSearchResultCollector_matches, matchCount);
}
@Override
@@ -67,6 +68,5 @@ public class CountLabelProvider extends LabelProvider {
fLabelProvider.dispose();
super.dispose();
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.java
index 5e84a4e1b7e..5e979b5f659 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.java
@@ -18,10 +18,10 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
public interface IOccurrencesFinder {
- public static final int K_OCCURRENCE= 5;
-
- public static final int F_WRITE_OCCURRENCE= 1;
- public static final int F_READ_OCCURRENCE= 2;
+ public static final int K_OCCURRENCE = 5;
+
+ public static final int F_WRITE_OCCURRENCE = 1;
+ public static final int F_READ_OCCURRENCE = 2;
/**
* Element representing an occurrence
@@ -33,10 +33,10 @@ public interface IOccurrencesFinder {
private final String fDescription;
public OccurrenceLocation(int offset, int length, int flags, String description) {
- fOffset= offset;
- fLength= length;
- fFlags= flags;
- fDescription= description;
+ fOffset = offset;
+ fLength = length;
+ fFlags = flags;
+ fDescription = description;
}
public int getOffset() {
@@ -60,7 +60,7 @@ public interface IOccurrencesFinder {
return "[" + fOffset + " / " + fLength + "] " + fDescription; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
}
-
+
public String initialize(IASTTranslationUnit root, IASTNode node);
/**
@@ -73,7 +73,7 @@ public interface IOccurrencesFinder {
* @return the unformatted label
*/
public String getUnformattedPluralLabel();
-
+
/**
* Returns the singular label for this finder with 2 placeholders:
* <ul>
@@ -83,7 +83,7 @@ public interface IOccurrencesFinder {
* @return the unformatted label
*/
public String getUnformattedSingularLabel();
-
+
/**
* Returns the name of the element to look for or <code>null</code> if the finder hasn't
* been initialized yet.
@@ -93,20 +93,20 @@ public interface IOccurrencesFinder {
/**
* Returns the AST root.
- *
+ *
* @return the AST root
*/
public IASTTranslationUnit getASTRoot();
/**
* Returns the occurrences
- *
+ *
* @return the occurrences
*/
public OccurrenceLocation[] getOccurrences();
public int getSearchKind();
-
+
/**
* Returns the id of this finder.
* @return returns the id of this finder.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java
index 947c29ca7ae..a100f73729a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java
@@ -37,18 +37,17 @@ public interface IPDOMSearchContentProvider {
/** This node encapsulates results in the search tree for results not resolvable to files. */
static Object URI_CONTAINER = new Object();
-
+
/** This node appears in the tree when the indexer was running during the search
- * to warn the user that the results are suspicious.
+ * to warn the user that the results are suspicious.
* <p>
* TODO: it would be better if IIndexManager told us which projects specifically
* were being indexed at the time, so we could annotate per-project whose results are suspicious
- * (which may be none at all for a given search).
+ * (which may be none at all for a given search).
* See the handling of {@link CSearchResult#wasIndexerBusy()}.
*/
- static IStatus INCOMPLETE_RESULTS_NODE =
- new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
- CSearchMessages.CSearchMessages_IndexRunningIncompleteWarning);
+ static IStatus INCOMPLETE_RESULTS_NODE = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ CSearchMessages.CSearchMessages_IndexRunningIncompleteWarning);
public void elementsChanged(Object[] elements);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LRUWorkingSets.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LRUWorkingSets.java
index 480641472d2..aba35cb0b71 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LRUWorkingSets.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LRUWorkingSets.java
@@ -28,8 +28,6 @@ import java.util.Set;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;
-
-
/**
* @author bgheorgh
*
@@ -37,53 +35,53 @@ import org.eclipse.ui.PlatformUI;
* Window - Preferences - Java - Code Style - Code Templates
*/
public class LRUWorkingSets {
-
+
ArrayList<IWorkingSet[]> workingSetsCache = null;
- int size=0;
-
- public LRUWorkingSets(int size){
+ int size = 0;
+
+ public LRUWorkingSets(int size) {
workingSetsCache = new ArrayList<IWorkingSet[]>(size);
this.size = size;
}
-
- public void add(IWorkingSet[] workingSet){
+
+ public void add(IWorkingSet[] workingSet) {
cleanUpCache();
- //See if this working set has been previously added to the
- IWorkingSet[] existingWorkingSets= find(workingSetsCache, workingSet);
+ //See if this working set has been previously added to the
+ IWorkingSet[] existingWorkingSets = find(workingSetsCache, workingSet);
if (existingWorkingSets != null)
workingSetsCache.remove(existingWorkingSets);
else if (workingSetsCache.size() == size)
workingSetsCache.remove(size - 1);
workingSetsCache.add(0, workingSet);
}
-
+
private IWorkingSet[] find(ArrayList<IWorkingSet[]> list, IWorkingSet[] workingSet) {
- Set<IWorkingSet> workingSetList= new HashSet<IWorkingSet>(Arrays.asList(workingSet));
- Iterator<IWorkingSet[]> iter= list.iterator();
+ Set<IWorkingSet> workingSetList = new HashSet<IWorkingSet>(Arrays.asList(workingSet));
+ Iterator<IWorkingSet[]> iter = list.iterator();
while (iter.hasNext()) {
- IWorkingSet[] lruWorkingSets= iter.next();
- Set<IWorkingSet> lruWorkingSetList= new HashSet<IWorkingSet>(Arrays.asList(lruWorkingSets));
+ IWorkingSet[] lruWorkingSets = iter.next();
+ Set<IWorkingSet> lruWorkingSetList = new HashSet<IWorkingSet>(Arrays.asList(lruWorkingSets));
if (lruWorkingSetList.equals(workingSetList))
return lruWorkingSets;
}
return null;
}
- private void cleanUpCache(){
- //Remove any previously deleted entries
- Iterator<IWorkingSet[]> iter = workingSetsCache.iterator();
- while (iter.hasNext()){
- IWorkingSet[] workingSet = iter.next();
- for (int i= 0; i < workingSet.length; i++) {
- if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSet[i].getName()) == null) {
- workingSetsCache.remove(workingSet);
- break;
+ private void cleanUpCache() {
+ //Remove any previously deleted entries
+ Iterator<IWorkingSet[]> iter = workingSetsCache.iterator();
+ while (iter.hasNext()) {
+ IWorkingSet[] workingSet = iter.next();
+ for (int i = 0; i < workingSet.length; i++) {
+ if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSet[i].getName()) == null) {
+ workingSetsCache.remove(workingSet);
+ break;
+ }
}
}
- }
}
public Iterator<IWorkingSet[]> iterator() {
- return workingSetsCache.iterator();
+ return workingSetsCache.iterator();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java
index f9687756b80..a9a69170624 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java
@@ -9,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Andrey Eremchenko, kamre@ngs.ru - 222495 C/C++ search should show line matches and line numbers
+ * Andrey Eremchenko, kamre@ngs.ru - 222495 C/C++ search should show line matches and line numbers
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -62,7 +62,7 @@ public class LineSearchElement extends CSearchElement {
public boolean isPolymorphicCall() {
return fIsPolymorphicCall;
}
-
+
public ICElement getEnclosingElement() {
return fEnclosingElement;
}
@@ -70,7 +70,7 @@ public class LineSearchElement extends CSearchElement {
public boolean isWriteAccess() {
return fIsWriteAccess;
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Match))
@@ -88,9 +88,9 @@ public class LineSearchElement extends CSearchElement {
private static final class MatchesComparator implements Comparator<Match> {
@Override
public int compare(Match m1, Match m2) {
- int diff= m1.getOffset() - m2.getOffset();
+ int diff = m1.getOffset() - m2.getOffset();
if (diff == 0)
- diff= m2.getLength() -m1.getLength();
+ diff = m2.getLength() - m1.getLength();
return diff;
}
}
@@ -101,8 +101,7 @@ public class LineSearchElement extends CSearchElement {
private final Match[] fMatches;
private final static MatchesComparator MATCHES_COMPARATOR = new MatchesComparator();
- private LineSearchElement(IIndexFileLocation file, Match[] matches, int number, String content,
- int offset) {
+ private LineSearchElement(IIndexFileLocation file, Match[] matches, int number, String content, int offset) {
super(file);
fMatches = matches;
fNumber = number;
@@ -159,7 +158,7 @@ public class LineSearchElement extends CSearchElement {
// sort matches according to their offsets
Arrays.sort(matches, MATCHES_COMPARATOR);
LineSearchElement[] result = {};
-
+
// read the content of file
FileContent content = FileContent.create(fileLocation);
if (content != null) {
@@ -176,7 +175,7 @@ public class LineSearchElement extends CSearchElement {
Arrays.sort(matches, MATCHES_COMPARATOR);
// Group all matches by lines and create LineSearchElements
List<LineSearchElement> result = new ArrayList<LineSearchElement>();
- List<Match> matchCollector= new ArrayList<Match>();
+ List<Match> matchCollector = new ArrayList<Match>();
int minOffset = 0;
int lineNumber = 0;
int lineOffset = 0;
@@ -185,21 +184,22 @@ public class LineSearchElement extends CSearchElement {
try {
for (final Match match : matches) {
- final int offset= match.getOffset();
+ final int offset = match.getOffset();
if (offset < lineEndOffset) {
// Match on same line
if (offset < minOffset) {
// Match is not overlapped by previous one.
matchCollector.add(match);
- minOffset= offset + match.getLength();
+ minOffset = offset + match.getLength();
}
} else {
// Match is on a new line
if (!matchCollector.isEmpty()) {
// Complete a line
String content = document.get(lineOffset, lineLength);
- Match[] lineMatches= matchCollector.toArray(new Match[matchCollector.size()]);
- result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber + 1, content, lineOffset));
+ Match[] lineMatches = matchCollector.toArray(new Match[matchCollector.size()]);
+ result.add(
+ new LineSearchElement(fileLocation, lineMatches, lineNumber + 1, content, lineOffset));
matchCollector.clear();
}
// Setup next line
@@ -208,12 +208,12 @@ public class LineSearchElement extends CSearchElement {
lineLength = document.getLineLength(lineNumber);
lineEndOffset = lineOffset + lineLength;
matchCollector.add(match);
- }
+ }
}
if (!matchCollector.isEmpty()) {
// Complete a line
String content = document.get(lineOffset, lineLength);
- Match[] lineMatches= matchCollector.toArray(new Match[matchCollector.size()]);
+ Match[] lineMatches = matchCollector.toArray(new Match[matchCollector.size()]);
result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber + 1, content, lineOffset));
matchCollector.clear();
}
@@ -226,33 +226,33 @@ public class LineSearchElement extends CSearchElement {
private static LineSearchElement[] collectLineElements(AbstractCharArray buf, Match[] matches,
IIndexFileLocation fileLocation) {
List<LineSearchElement> result = new ArrayList<LineSearchElement>();
- List<Match> matchCollector= new ArrayList<Match>();
+ List<Match> matchCollector = new ArrayList<Match>();
boolean skipLF = false;
int lineNumber = 1;
int lineOffset = 0;
int i = 0;
- Match match= matches[i];
+ Match match = matches[i];
int matchOffset = match.getOffset();
for (int pos = 0; buf.isValidOffset(pos); pos++) {
if (matchOffset <= pos && match != null) {
// We are on the line of the match, store it.
matchCollector.add(match);
- final int minOffset= matchOffset + match.getLength();
- match= null;
- matchOffset= Integer.MAX_VALUE;
- for(i= i + 1; i < matches.length; i++) {
+ final int minOffset = matchOffset + match.getLength();
+ match = null;
+ matchOffset = Integer.MAX_VALUE;
+ for (i = i + 1; i < matches.length; i++) {
// Advance to next match that is not overlapped
- final Match nextMatch= matches[i];
- final int nextOffset= nextMatch.getOffset();
+ final Match nextMatch = matches[i];
+ final int nextOffset = nextMatch.getOffset();
if (nextOffset >= minOffset) {
- match= nextMatch;
- matchOffset= nextOffset;
+ match = nextMatch;
+ matchOffset = nextOffset;
break;
}
}
}
-
+
char c = buf.get(pos);
// consider '\n' and '\r'
if (skipLF) {
@@ -266,12 +266,11 @@ public class LineSearchElement extends CSearchElement {
// Create new LineElement for collected matches on this line
if (!matchCollector.isEmpty()) {
int lineLength = pos - lineOffset;
- Match[] lineMatches= matchCollector.toArray(new Match[matchCollector.size()]);
- char[] lineChars= new char[lineLength];
+ Match[] lineMatches = matchCollector.toArray(new Match[matchCollector.size()]);
+ char[] lineChars = new char[lineLength];
buf.arraycopy(lineOffset, lineChars, 0, lineLength);
String lineContent = new String(lineChars);
- result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent,
- lineOffset));
+ result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent, lineOffset));
matchCollector.clear();
if (match == null)
break;
@@ -286,12 +285,11 @@ public class LineSearchElement extends CSearchElement {
// Create new LineElement for matches on the last line
if (!matchCollector.isEmpty()) {
int lineLength = buf.getLength() - lineOffset;
- Match[] lineMatches= matchCollector.toArray(new Match[matchCollector.size()]);
- char[] lineChars= new char[lineLength];
+ Match[] lineMatches = matchCollector.toArray(new Match[matchCollector.size()]);
+ char[] lineChars = new char[lineLength];
buf.arraycopy(lineOffset, lineChars, 0, lineLength);
String lineContent = new String(lineChars);
- result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent,
- lineOffset));
+ result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent, lineOffset));
}
return result.toArray(new LineSearchElement[result.size()]);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java
index f6d6e21849f..8e6acf28cd2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java
@@ -88,8 +88,8 @@ public class LinkedNamesFinder {
return;
}
- if (target instanceof ICPPConstructor ||
- target instanceof ICPPMethod && ((ICPPMethod) target).isDestructor()) {
+ if (target instanceof ICPPConstructor
+ || target instanceof ICPPMethod && ((ICPPMethod) target).isDestructor()) {
target = ((ICPPMethod) target).getClassOwner();
}
@@ -108,11 +108,11 @@ public class LinkedNamesFinder {
}
}
} else if (target instanceof ICPPMethod) {
- ICPPMethod method= (ICPPMethod) target;
- for (ICPPMethod m : ClassTypeHelper.findOverridden(method)) {
+ ICPPMethod method = (ICPPMethod) target;
+ for (ICPPMethod m : ClassTypeHelper.findOverridden(method)) {
findBinding(m);
}
- try {
+ try {
for (ICPPMethod m : findOverridersInAST(method)) {
findBinding(m);
}
@@ -127,7 +127,7 @@ public class LinkedNamesFinder {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
final ICPPClassType ownerClass = method.getClassOwner();
- if (ownerClass == null)
+ if (ownerClass == null)
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
SubclassFinder subclassFinder = new SubclassFinder(ownerClass);
@@ -143,13 +143,13 @@ public class LinkedNamesFinder {
}
private void findBinding(IBinding target) {
- IASTName[] names= root.getDeclarationsInAST(target);
+ IASTName[] names = root.getDeclarationsInAST(target);
for (IASTName candidate : names) {
if (candidate.isPartOfTranslationUnitFile()) {
addLocation(candidate);
}
}
- names= root.getReferences(target);
+ names = root.getReferences(target);
for (IASTName candidate : names) {
if (candidate.isPartOfTranslationUnitFile()) {
addLocation(candidate);
@@ -161,15 +161,15 @@ public class LinkedNamesFinder {
IBinding binding = name.resolveBinding();
if (binding != null) {
if (name instanceof ICPPASTTemplateId) {
- name= ((ICPPASTTemplateId) name).getTemplateName();
+ name = ((ICPPASTTemplateId) name).getTemplateName();
}
- IASTFileLocation fileLocation= name.getImageLocation();
+ IASTFileLocation fileLocation = name.getImageLocation();
if (fileLocation == null || !root.getFilePath().equals(fileLocation.getFileName())) {
- fileLocation= name.getFileLocation();
+ fileLocation = name.getFileLocation();
}
if (fileLocation != null) {
- int offset= fileLocation.getNodeOffset();
- int length= fileLocation.getNodeLength();
+ int offset = fileLocation.getNodeOffset();
+ int length = fileLocation.getNodeLength();
if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isDestructor()) {
// Skip tilde.
offset++;
@@ -187,8 +187,8 @@ public class LinkedNamesFinder {
* may belong to multiple macro bindings with the same name. Macro names are also
* looked for in the comments of #else and #endif statements.
* Comments of #else and #endif statements related to #ifdef or #ifndef are searched
- * for the macro name referenced by the #if[n]def.
- * @param target a binding representing a macro.
+ * for the macro name referenced by the #if[n]def.
+ * @param target a binding representing a macro.
*/
private void findMacro(IMacroBinding target) {
findBinding(target);
@@ -246,8 +246,8 @@ public class LinkedNamesFinder {
private void findInStatementComment(char[] nameChars, IASTPreprocessorStatement statement) {
IASTFileLocation location = statement.getFileLocation();
IASTComment comment = findComment(location.getNodeOffset() + location.getNodeLength());
- if (comment != null &&
- comment.getFileLocation().getStartingLineNumber() == location.getStartingLineNumber()) {
+ if (comment != null
+ && comment.getFileLocation().getStartingLineNumber() == location.getStartingLineNumber()) {
findInComment(nameChars, comment);
}
}
@@ -281,16 +281,15 @@ public class LinkedNamesFinder {
*/
private void findInComment(char[] name, IASTComment comment) {
char[] text = comment.getComment();
- int j = 0;
- // First two characters are either /* or //
- for (int i = 2; i <= text.length - name.length + j; i++) {
- char c = text[i];
+ int j = 0;
+ // First two characters are either /* or //
+ for (int i = 2; i <= text.length - name.length + j; i++) {
+ char c = text[i];
if (!Character.isJavaIdentifierPart(c)) {
j = 0;
} else if (j >= 0 && j < name.length && name[j] == c) {
j++;
- if (j == name.length &&
- (i + 1 == text.length || !Character.isJavaIdentifierPart(text[i + 1]))) {
+ if (j == name.length && (i + 1 == text.length || !Character.isJavaIdentifierPart(text[i + 1]))) {
int offset = comment.getFileLocation().getNodeOffset() + i + 1 - name.length;
locations.add(new Region(offset, name.length));
j = 0;
@@ -298,7 +297,7 @@ public class LinkedNamesFinder {
} else {
j = -1;
}
- }
+ }
}
}
@@ -307,13 +306,13 @@ public class LinkedNamesFinder {
*/
static class SubclassFinder extends ASTVisitor {
{
- shouldVisitNames= true;
+ shouldVisitNames = true;
}
private final ICPPClassType baseClass;
private Set<ICPPClassType> subclasses = new HashSet<ICPPClassType>();
private Set<IBinding> seenClasses = new HashSet<IBinding>();
-
+
SubclassFinder(ICPPClassType baseClass) {
this.baseClass = baseClass;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java
index 0be2a818723..c7b5582eb54 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java
@@ -33,13 +33,13 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.ui.util.Messages;
public class OccurrencesFinder implements IOccurrencesFinder {
- public static final String ID= "OccurrencesFinder"; //$NON-NLS-1$
-
+ public static final String ID = "OccurrencesFinder"; //$NON-NLS-1$
+
/**
* If set, don't search for implicit references.
*/
public static final int OPTION_EXCLUDE_IMPLICIT_REFERENCES = 1;
-
+
private IASTTranslationUnit fRoot;
private IASTName fSelectedNode;
private IBinding fTarget;
@@ -48,54 +48,55 @@ public class OccurrencesFinder implements IOccurrencesFinder {
private String fReadDescription;
private String fWriteDescription;
-
+
private int fOptions;
-
+
public OccurrencesFinder() {
super();
}
-
+
@Override
public String initialize(IASTTranslationUnit root, IASTNode node) {
if (!(node instanceof IASTName))
- return CSearchMessages.OccurrencesFinder_no_element;
- fRoot= root;
- fSelectedNode= (IASTName) node;
- fTarget= fSelectedNode.resolveBinding();
+ return CSearchMessages.OccurrencesFinder_no_element;
+ fRoot = root;
+ fSelectedNode = (IASTName) node;
+ fTarget = fSelectedNode.resolveBinding();
if (fTarget == null)
- return CSearchMessages.OccurrencesFinder_no_binding;
-
- fReadDescription= Messages.format(CSearchMessages.OccurrencesFinder_occurrence_description, fTarget.getName());
- fWriteDescription= Messages.format(CSearchMessages.OccurrencesFinder_occurrence_write_description, fTarget.getName());
+ return CSearchMessages.OccurrencesFinder_no_binding;
+
+ fReadDescription = Messages.format(CSearchMessages.OccurrencesFinder_occurrence_description, fTarget.getName());
+ fWriteDescription = Messages.format(CSearchMessages.OccurrencesFinder_occurrence_write_description,
+ fTarget.getName());
return null;
}
-
+
/**
* Specify search options.
- *
+ *
* @param options
*/
public void setOptions(int options) {
fOptions = options;
}
-
+
private void performSearch() {
if (fResult == null) {
- fResult= new ArrayList<>();
- IASTName[] names= fRoot.getDeclarationsInAST(fTarget);
+ fResult = new ArrayList<>();
+ IASTName[] names = fRoot.getDeclarationsInAST(fTarget);
for (IASTName candidate : names) {
if (candidate.isPartOfTranslationUnitFile()) {
addUsage(candidate, candidate.resolveBinding());
}
}
- names= fRoot.getReferences(fTarget);
+ names = fRoot.getReferences(fTarget);
for (IASTName candidate : names) {
if (candidate.isPartOfTranslationUnitFile()) {
addUsage(candidate, candidate.resolveBinding());
}
}
if (needImplicitReferences() && canHaveImplicitReference(fTarget)) {
- names= CPPVisitor.getImplicitReferences(fRoot, fTarget);
+ names = CPPVisitor.getImplicitReferences(fRoot, fTarget);
for (IASTName candidate : names) {
if (candidate.isPartOfTranslationUnitFile()) {
addUsage(candidate, candidate.resolveBinding());
@@ -104,7 +105,7 @@ public class OccurrencesFinder implements IOccurrencesFinder {
}
}
}
-
+
private boolean needImplicitReferences() {
return (fOptions & OPTION_EXCLUDE_IMPLICIT_REFERENCES) == 0;
}
@@ -122,7 +123,7 @@ public class OccurrencesFinder implements IOccurrencesFinder {
}
if (binding instanceof ICPPConstructor)
return true;
-
+
return false;
}
@@ -138,7 +139,7 @@ public class OccurrencesFinder implements IOccurrencesFinder {
public IASTTranslationUnit getASTRoot() {
return fRoot;
}
-
+
@Override
public String getElementName() {
if (fSelectedNode != null) {
@@ -146,29 +147,29 @@ public class OccurrencesFinder implements IOccurrencesFinder {
}
return null;
}
-
+
@Override
public String getUnformattedPluralLabel() {
return CSearchMessages.OccurrencesFinder_label_plural;
}
-
+
@Override
public String getUnformattedSingularLabel() {
return CSearchMessages.OccurrencesFinder_label_singular;
}
-
+
private boolean addUsage(IASTName node, IBinding binding) {
if (binding != null /* && Bindings.equals(binding, fTarget) */) {
if (node instanceof ICPPASTTemplateId) {
- node= ((ICPPASTTemplateId) node).getTemplateName();
+ node = ((ICPPASTTemplateId) node).getTemplateName();
}
- IASTFileLocation fileLocation= node.getImageLocation();
+ IASTFileLocation fileLocation = node.getImageLocation();
if (fileLocation == null || !fRoot.getFilePath().equals(fileLocation.getFileName())) {
- fileLocation= node.getFileLocation();
+ fileLocation = node.getFileLocation();
}
if (fileLocation != null) {
- final int offset= fileLocation.getNodeOffset();
- final int length= fileLocation.getNodeLength();
+ final int offset = fileLocation.getNodeOffset();
+ final int length = fileLocation.getNodeLength();
if (offset >= 0 && length > 0) {
if (binding instanceof IVariable) {
final boolean isWriteOccurrence = CSearchUtil.isWriteOccurrence(node, binding);
@@ -189,7 +190,7 @@ public class OccurrencesFinder implements IOccurrencesFinder {
public int getSearchKind() {
return K_OCCURRENCE;
}
-
+
@Override
public String getID() {
return ID;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java
index c6a6f8d4908..7cc451b7eb9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java
@@ -30,7 +30,7 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate;
public class OpenCSearchPageAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow fWindow;
-
+
public OpenCSearchPageAction() {
super();
// TODO Auto-generated constructor stub
@@ -38,7 +38,7 @@ public class OpenCSearchPageAction implements IWorkbenchWindowActionDelegate {
@Override
public void init(IWorkbenchWindow window) {
- fWindow= window;
+ fWindow = window;
}
@Override
@@ -57,13 +57,13 @@ public class OpenCSearchPageAction implements IWorkbenchWindowActionDelegate {
@Override
public void dispose() {
- fWindow= null;
+ fWindow = null;
}
protected void beep() {
- Shell shell= CUIPlugin.getActiveWorkbenchShell();
+ Shell shell = CUIPlugin.getActiveWorkbenchShell();
if (shell != null && shell.getDisplay() != null)
shell.getDisplay().beep();
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java
index 2490ff3ccf1..7bf4e97cf13 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
import org.eclipse.cdt.core.index.IIndexFileLocation;
@@ -25,10 +25,10 @@ public class ProblemSearchElement extends CSearchElement {
public ProblemSearchElement(int problemID, String detail, IIndexFileLocation floc) {
super(floc);
- fProblemID= problemID;
- fDetail= detail;
+ fProblemID = problemID;
+ fDetail = detail;
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@@ -62,11 +62,11 @@ public class ProblemSearchElement extends CSearchElement {
return false;
return true;
}
-
+
public final int getProblemID() {
return fProblemID;
}
-
+
public final String getDetail() {
return fDetail;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java
index 87bcaac788a..ad23f166dbb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
import org.eclipse.core.runtime.CoreException;
@@ -31,19 +31,19 @@ public class TypeInfoSearchElement extends CSearchElement {
public TypeInfoSearchElement(IIndex index, IIndexName name, IIndexBinding binding) throws CoreException {
super(name.getFile().getLocation());
- this.typeInfo= IndexTypeInfo.create(index, binding);
+ this.typeInfo = IndexTypeInfo.create(index, binding);
}
public TypeInfoSearchElement(ASTTypeInfo typeInfo) {
super(typeInfo.getIFL());
- this.typeInfo= typeInfo;
+ this.typeInfo = typeInfo;
}
@Override
public int hashCode() {
- return super.hashCode() + typeInfo.hashCode()*31;
+ return super.hashCode() + typeInfo.hashCode() * 31;
}
-
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -51,7 +51,7 @@ public class TypeInfoSearchElement extends CSearchElement {
}
if (!(obj instanceof TypeInfoSearchElement))
return false;
- TypeInfoSearchElement other= (TypeInfoSearchElement)obj;
+ TypeInfoSearchElement other = (TypeInfoSearchElement) obj;
return super.equals(other) && typeInfo.equals(other.typeInfo);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java
index 90b7ee95459..82519afc633 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java
@@ -37,7 +37,6 @@ import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
import org.eclipse.cdt.internal.ui.search.CSearchUtil;
-
public class DeclarationsSearchGroup extends ActionGroup {
private CEditor fEditor;
@@ -48,31 +47,33 @@ public class DeclarationsSearchGroup extends ActionGroup {
private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction;
public DeclarationsSearchGroup(IWorkbenchSite site) {
- fFindDeclarationsAction= new FindDeclarationsAction(site);
+ fFindDeclarationsAction = new FindDeclarationsAction(site);
fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site);
fFindDeclarationsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
- fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site,null);
+ fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site, null);
fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
fSite = site;
}
+
/**
* @param editor
*/
public DeclarationsSearchGroup(CEditor editor) {
fEditor = editor;
- fFindDeclarationsAction= new FindDeclarationsAction(editor);
+ fFindDeclarationsAction = new FindDeclarationsAction(editor);
fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(editor);
fFindDeclarationsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_PROJECT, fFindDeclarationsProjectAction);
- fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor,null);
+ fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor, null);
fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET, fFindDeclarationsInWorkingSetAction);
}
+
/*
* Method declared on ActionGroup.
*/
@@ -82,9 +83,10 @@ public class DeclarationsSearchGroup extends ActionGroup {
IMenuManager incomingMenu = menu;
- IMenuManager declarationsMenu = new MenuManager(CSearchMessages.group_declarations, IContextMenuConstants.GROUP_SEARCH);
+ IMenuManager declarationsMenu = new MenuManager(CSearchMessages.group_declarations,
+ IContextMenuConstants.GROUP_SEARCH);
- if (fEditor != null){
+ if (fEditor != null) {
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
} else {
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
@@ -104,41 +106,46 @@ public class DeclarationsSearchGroup extends ActionGroup {
@Override
public void fillActionBars(IActionBars actionBars) {
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
- actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL_PROJECT, fFindDeclarationsProjectAction);
- actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET, fFindDeclarationsInWorkingSetAction);
+ actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL_PROJECT,
+ fFindDeclarationsProjectAction);
+ actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET,
+ fFindDeclarationsInWorkingSetAction);
}
private FindAction[] getWorkingSetActions() {
- ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
+ ArrayList<FindAction> actions = new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
- Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
+ Iterator<IWorkingSet[]> iter = CSearchUtil.getLRUWorkingSets().iterator();
while (iter.hasNext()) {
- IWorkingSet[] workingSets= iter.next();
+ IWorkingSet[] workingSets = iter.next();
FindAction action;
if (fEditor != null)
- action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
+ action = new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets),
+ CSearchUtil.toString(workingSets));
else
- action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
+ action = new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets),
+ CSearchUtil.toString(workingSets));
actions.add(action);
}
return actions.toArray(new FindAction[actions.size()]);
}
+
public static boolean canActionBeAdded(ISelection selection) {
- if(selection instanceof ITextSelection) {
- return (((ITextSelection)selection).getLength() > 0);
+ if (selection instanceof ITextSelection) {
+ return (((ITextSelection) selection).getLength() > 0);
}
return getElement(selection) != null;
}
private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
- List<?> list= ((IStructuredSelection)sel).toList();
+ List<?> list = ((IStructuredSelection) sel).toList();
if (list.size() == 1) {
- Object element= list.get(0);
+ Object element = list.get(0);
if (element instanceof ICElement) {
- return (ICElement)element;
+ return (ICElement) element;
}
}
}
@@ -150,9 +157,9 @@ public class DeclarationsSearchGroup extends ActionGroup {
*/
@Override
public void dispose() {
- fFindDeclarationsAction= null;
- fFindDeclarationsProjectAction=null;
- fFindDeclarationsInWorkingSetAction= null;
+ fFindDeclarationsAction = null;
+ fFindDeclarationsProjectAction = null;
+ fFindDeclarationsInWorkingSetAction = null;
super.dispose();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
index d6beda4223a..17c9499a94e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
@@ -35,25 +35,24 @@ import org.eclipse.cdt.internal.ui.search.CSearchQuery;
import org.eclipse.cdt.internal.ui.search.CSearchTextSelectionQuery;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
-
public abstract class FindAction extends SelectionParseAction {
- public FindAction(CEditor editor){
+ public FindAction(CEditor editor) {
super(editor);
}
-
- public FindAction(IWorkbenchSite site){
+
+ public FindAction(IWorkbenchSite site) {
super(site);
}
-
+
@Override
public void run() {
ISearchQuery searchJob = null;
ISelection selection = getSelection();
- if (selection instanceof IStructuredSelection) {
- Object object = ((IStructuredSelection) selection).getFirstElement();
- if (object instanceof ISourceReference)
- searchJob = createQuery((ISourceReference) object);
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection) selection).getFirstElement();
+ if (object instanceof ISourceReference)
+ searchJob = createQuery((ISourceReference) object);
} else if (selection instanceof ITextSelection) {
ITextSelection selNode = (ITextSelection) selection;
ICElement element = fEditor.getTranslationUnit();
@@ -61,20 +60,20 @@ public abstract class FindAction extends SelectionParseAction {
element = element.getParent();
if (element != null) {
if (selNode.getLength() == 0) {
- IDocument document= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
- IRegion reg= CWordFinder.findWord(document, selNode.getOffset());
+ IDocument document = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+ IRegion reg = CWordFinder.findWord(document, selNode.getOffset());
selNode = new TextSelection(document, reg.getOffset(), reg.getLength());
}
searchJob = createQuery(element, selNode);
}
- }
+ }
- if (searchJob == null) {
- showStatusLineMessage(CSearchMessages.CSearchOperation_operationUnavailable_message);
- return;
- }
+ if (searchJob == null) {
+ showStatusLineMessage(CSearchMessages.CSearchOperation_operationUnavailable_message);
+ return;
+ }
- clearStatusLine();
+ clearStatusLine();
NewSearchUI.activateSearchResultView();
NewSearchUI.runQueryInBackground(searchJob);
}
@@ -84,13 +83,12 @@ public abstract class FindAction extends SelectionParseAction {
}
protected CSearchQuery createQuery(ICElement element, ITextSelection selNode) {
- return new CSearchTextSelectionQuery(getScope(),
- (ITranslationUnit) element, selNode, getLimitTo());
+ return new CSearchTextSelectionQuery(getScope(), (ITranslationUnit) element, selNode, getLimitTo());
}
-
- abstract protected String getScopeDescription();
+
+ abstract protected String getScopeDescription();
abstract protected ICElement[] getScope();
-
+
abstract protected int getLimitTo();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java
index e44becc7018..bcb224a9d6c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java
@@ -20,25 +20,22 @@ import org.eclipse.cdt.internal.ui.search.CSearchMessages;
import org.eclipse.cdt.internal.ui.search.CSearchQuery;
import org.eclipse.ui.IWorkbenchSite;
-
public class FindDeclarationsAction extends FindAction {
-
- public FindDeclarationsAction(CEditor editor, String label, String tooltip){
+
+ public FindDeclarationsAction(CEditor editor, String label, String tooltip) {
super(editor);
- setText(label);
- setToolTipText(tooltip);
+ setText(label);
+ setToolTipText(tooltip);
}
-
- public FindDeclarationsAction(CEditor editor){
- this(editor,
- CSearchMessages.CSearch_FindDeclarationAction_label,
- CSearchMessages.CSearch_FindDeclarationAction_tooltip);
+
+ public FindDeclarationsAction(CEditor editor) {
+ this(editor, CSearchMessages.CSearch_FindDeclarationAction_label,
+ CSearchMessages.CSearch_FindDeclarationAction_tooltip);
}
-
- public FindDeclarationsAction(IWorkbenchSite site){
- this(site,
- CSearchMessages.CSearch_FindDeclarationAction_label,
- CSearchMessages.CSearch_FindDeclarationAction_tooltip);
+
+ public FindDeclarationsAction(IWorkbenchSite site) {
+ this(site, CSearchMessages.CSearch_FindDeclarationAction_label,
+ CSearchMessages.CSearch_FindDeclarationAction_tooltip);
}
public FindDeclarationsAction(IWorkbenchSite site, String label, String tooltip) {
@@ -51,12 +48,12 @@ public class FindDeclarationsAction extends FindAction {
protected ICElement[] getScope() {
return null;
}
-
+
@Override
protected String getScopeDescription() {
- return CSearchMessages.WorkspaceScope;
+ return CSearchMessages.WorkspaceScope;
}
-
+
@Override
protected int getLimitTo() {
return CSearchQuery.FIND_DECLARATIONS_DEFINITIONS;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java
index 1f1954c7423..da7b45dd320 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java
@@ -24,17 +24,13 @@ import org.eclipse.cdt.internal.ui.search.CSearchQuery;
public class FindDeclarationsInWorkingSetAction extends FindInWorkingSetAction {
public FindDeclarationsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) {
- super(site,
- CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
- CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip,
- workingSets);
+ super(site, CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
+ CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip, workingSets);
}
public FindDeclarationsInWorkingSetAction(CEditor editor, IWorkingSet[] workingSets) {
- super(editor,
- CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
- CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip,
- workingSets);
+ super(editor, CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
+ CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip, workingSets);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java
index 35b887d27d8..ac5c8c3c207 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java
@@ -26,22 +26,20 @@ import org.eclipse.ui.IWorkbenchSite;
public class FindDeclarationsProjectAction extends FindAction {
- public FindDeclarationsProjectAction(CEditor editor, String label, String tooltip){
+ public FindDeclarationsProjectAction(CEditor editor, String label, String tooltip) {
super(editor);
- setText(label);
- setToolTipText(tooltip);
+ setText(label);
+ setToolTipText(tooltip);
}
-
- public FindDeclarationsProjectAction(CEditor editor){
- this(editor,
- CSearchMessages.CSearch_FindDeclarationsProjectAction_label,
- CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip);
+
+ public FindDeclarationsProjectAction(CEditor editor) {
+ this(editor, CSearchMessages.CSearch_FindDeclarationsProjectAction_label,
+ CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip);
}
-
- public FindDeclarationsProjectAction(IWorkbenchSite site){
- this(site,
- CSearchMessages.CSearch_FindDeclarationsProjectAction_label,
- CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip);
+
+ public FindDeclarationsProjectAction(IWorkbenchSite site) {
+ this(site, CSearchMessages.CSearch_FindDeclarationsProjectAction_label,
+ CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip);
}
public FindDeclarationsProjectAction(IWorkbenchSite site, String label, String tooltip) {
@@ -54,24 +52,24 @@ public class FindDeclarationsProjectAction extends FindAction {
protected ICElement[] getScope() {
ICProject project = null;
if (fEditor != null) {
- project = fEditor.getTranslationUnit().getCProject();
- } else if (fSite != null){
+ project = fEditor.getTranslationUnit().getCProject();
+ } else if (fSite != null) {
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
- Object element = ((IStructuredSelection)selection).getFirstElement();
+ Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof IResource)
- project = CoreModel.getDefault().create(((IResource)element).getProject());
+ project = CoreModel.getDefault().create(((IResource) element).getProject());
else if (element instanceof ICElement)
- project = ((ICElement)element).getCProject();
+ project = ((ICElement) element).getCProject();
}
}
-
+
return project != null ? new ICElement[] { project } : null;
}
@Override
protected String getScopeDescription() {
- return CSearchMessages.ProjectScope;
+ return CSearchMessages.ProjectScope;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetAction.java
index bdd5e20448d..e2fe7e271d3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetAction.java
@@ -43,24 +43,24 @@ public abstract class FindInWorkingSetAction extends FindAction {
fWorkingSets = workingSets;
}
- public FindInWorkingSetAction(IWorkbenchSite site, String label, String tooltip, IWorkingSet[] workingSets){
+ public FindInWorkingSetAction(IWorkbenchSite site, String label, String tooltip, IWorkingSet[] workingSets) {
super(site);
setText(label);
setToolTipText(tooltip);
- fWorkingSets= workingSets;
+ fWorkingSets = workingSets;
}
@Override
final public void run() {
- IWorkingSet[] initial= fWorkingSets;
+ IWorkingSet[] initial = fWorkingSets;
if (fWorkingSets == null) {
- fWorkingSets= askForWorkingSets();
+ fWorkingSets = askForWorkingSets();
}
if (fWorkingSets != null) {
scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(fWorkingSets));
super.run();
}
- fWorkingSets= initial;
+ fWorkingSets = initial;
}
@Override
@@ -87,15 +87,14 @@ public abstract class FindInWorkingSetAction extends FindAction {
}
private IWorkingSet[] askForWorkingSets() {
- IWorkingSetManager wsm= PlatformUI.getWorkbench().getWorkingSetManager();
- IWorkingSetSelectionDialog dlg=
- wsm.createWorkingSetSelectionDialog(getSite().getShell(), true);
- IWorkingSet[] mru= wsm.getRecentWorkingSets();
+ IWorkingSetManager wsm = PlatformUI.getWorkbench().getWorkingSetManager();
+ IWorkingSetSelectionDialog dlg = wsm.createWorkingSetSelectionDialog(getSite().getShell(), true);
+ IWorkingSet[] mru = wsm.getRecentWorkingSets();
if (mru != null && mru.length > 0) {
- dlg.setSelection(new IWorkingSet[] {mru[0]});
+ dlg.setSelection(new IWorkingSet[] { mru[0] });
}
if (dlg.open() == Window.OK) {
- mru= dlg.getSelection();
+ mru = dlg.getSelection();
if (mru != null && mru.length == 1) {
wsm.addRecentWorkingSet(mru[0]);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java
index 376657d3692..bf9d22b3526 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java
@@ -22,21 +22,19 @@ import org.eclipse.ui.IWorkbenchSite;
public class FindRefsAction extends FindAction {
public FindRefsAction(CEditor editor) {
- this(editor,
- CSearchMessages.CSearch_FindReferencesAction_label,
- CSearchMessages.CSearch_FindReferencesAction_tooltip);
+ this(editor, CSearchMessages.CSearch_FindReferencesAction_label,
+ CSearchMessages.CSearch_FindReferencesAction_tooltip);
+ }
+
+ public FindRefsAction(IWorkbenchSite site) {
+ this(site, CSearchMessages.CSearch_FindReferencesAction_label,
+ CSearchMessages.CSearch_FindReferencesAction_tooltip);
}
-
- public FindRefsAction(IWorkbenchSite site){
- this(site,
- CSearchMessages.CSearch_FindReferencesAction_label,
- CSearchMessages.CSearch_FindReferencesAction_tooltip);
- }
public FindRefsAction(CEditor editor, String label, String tooltip) {
super(editor);
- setText(label);
- setToolTipText(tooltip);
+ setText(label);
+ setToolTipText(tooltip);
}
public FindRefsAction(IWorkbenchSite site, String label, String tooltip) {
@@ -47,13 +45,13 @@ public class FindRefsAction extends FindAction {
@Override
protected String getScopeDescription() {
- return CSearchMessages.WorkspaceScope;
+ return CSearchMessages.WorkspaceScope;
}
@Override
protected ICElement[] getScope() {
- return null;
- }
+ return null;
+ }
@Override
protected int getLimitTo() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java
index 70f5be487cc..3f1d841d77c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java
@@ -22,21 +22,17 @@ import org.eclipse.cdt.internal.ui.search.CSearchMessages;
import org.eclipse.cdt.internal.ui.search.CSearchQuery;
public class FindRefsInWorkingSetAction extends FindInWorkingSetAction {
-
+
public FindRefsInWorkingSetAction(CEditor editor, IWorkingSet[] workingSets) {
- super(editor,
- CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
- CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip,
- workingSets);
+ super(editor, CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
+ CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip, workingSets);
}
-
- public FindRefsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets){
- super (site,
- CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
- CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip,
- workingSets);
+
+ public FindRefsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) {
+ super(site, CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
+ CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip, workingSets);
}
-
+
@Override
protected int getLimitTo() {
return CSearchQuery.FIND_REFERENCES;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java
index dedca7633bf..a0dfc2655f8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java
@@ -26,22 +26,20 @@ import org.eclipse.ui.IWorkbenchSite;
public class FindRefsProjectAction extends FindAction {
- public FindRefsProjectAction(CEditor editor, String label, String tooltip){
+ public FindRefsProjectAction(CEditor editor, String label, String tooltip) {
super(editor);
- setText(label);
- setToolTipText(tooltip);
+ setText(label);
+ setToolTipText(tooltip);
}
-
- public FindRefsProjectAction(CEditor editor){
- this(editor,
- CSearchMessages.CSearch_FindReferencesProjectAction_label,
- CSearchMessages.CSearch_FindReferencesProjectAction_tooltip);
+
+ public FindRefsProjectAction(CEditor editor) {
+ this(editor, CSearchMessages.CSearch_FindReferencesProjectAction_label,
+ CSearchMessages.CSearch_FindReferencesProjectAction_tooltip);
}
-
- public FindRefsProjectAction(IWorkbenchSite site){
- this(site,
- CSearchMessages.CSearch_FindReferencesProjectAction_label,
- CSearchMessages.CSearch_FindReferencesProjectAction_tooltip);
+
+ public FindRefsProjectAction(IWorkbenchSite site) {
+ this(site, CSearchMessages.CSearch_FindReferencesProjectAction_label,
+ CSearchMessages.CSearch_FindReferencesProjectAction_tooltip);
}
public FindRefsProjectAction(IWorkbenchSite site, String label, String tooltip) {
@@ -54,24 +52,24 @@ public class FindRefsProjectAction extends FindAction {
protected ICElement[] getScope() {
ICProject project = null;
if (fEditor != null) {
- project = fEditor.getTranslationUnit().getCProject();
- } else if (fSite != null){
+ project = fEditor.getTranslationUnit().getCProject();
+ } else if (fSite != null) {
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
- Object element = ((IStructuredSelection)selection).getFirstElement();
+ Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof IResource)
- project = CoreModel.getDefault().create(((IResource)element).getProject());
+ project = CoreModel.getDefault().create(((IResource) element).getProject());
else if (element instanceof ICElement)
- project = ((ICElement)element).getCProject();
+ project = ((ICElement) element).getCProject();
}
}
-
+
return project != null ? new ICElement[] { project } : null;
}
@Override
protected String getScopeDescription() {
- return CSearchMessages.ProjectScope;
+ return CSearchMessages.ProjectScope;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesHandler.java
index 907a691fe94..cf8c372fd1e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesHandler.java
@@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.ui.actions.AbstractUpdateIndexHandler;
public class FindUnresolvedIncludesHandler extends AbstractUpdateIndexHandler {
private final FindUnresolvedIncludesProjectAction findUnresolvedIncludesAction = new FindUnresolvedIncludesProjectAction();
-
+
@Override
public AbstractUpdateIndexAction getAction() {
return findUnresolvedIncludesAction;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java
index 61e41fa3021..262a47896b6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.search.actions;
import org.eclipse.jface.action.IAction;
@@ -39,11 +39,12 @@ public class FindUnresolvedIncludesProjectAction extends AbstractUpdateIndexActi
@Override
protected void doRun(ICElement[] elements) {
if (elements.length == 0) {
- StatusLineHandler.showStatusLineMessage(fSite, CSearchMessages.CSearchOperation_operationUnavailable_message);
- return;
- }
+ StatusLineHandler.showStatusLineMessage(fSite,
+ CSearchMessages.CSearchOperation_operationUnavailable_message);
+ return;
+ }
- ISearchQuery searchJob= new CSearchUnresolvedIncludesQuery(elements);
+ ISearchQuery searchJob = new CSearchUnresolvedIncludesQuery(elements);
StatusLineHandler.clearStatusLine(fSite);
NewSearchUI.activateSearchResultView();
@@ -52,7 +53,7 @@ public class FindUnresolvedIncludesProjectAction extends AbstractUpdateIndexActi
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fSite= targetPart.getSite();
+ fSite = targetPart.getSite();
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
index 70b4c1fa44c..bbdc8434c09 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
@@ -38,7 +38,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
* Navigates to the definition of a name, or to the declaration if invoked on the definition.
*/
public class OpenDeclarationsAction extends SelectionParseAction {
- public static boolean sDisallowAmbiguousInput = false;
+ public static boolean sDisallowAmbiguousInput = false;
ITextSelection fTextSelection;
@@ -47,9 +47,9 @@ public class OpenDeclarationsAction extends SelectionParseAction {
*/
public OpenDeclarationsAction(ICModelBasedEditor editor) {
super(editor);
- setText(CEditorMessages.OpenDeclarations_label);
- setToolTipText(CEditorMessages.OpenDeclarations_tooltip);
- setDescription(CEditorMessages.OpenDeclarations_description);
+ setText(CEditorMessages.OpenDeclarations_label);
+ setToolTipText(CEditorMessages.OpenDeclarations_tooltip);
+ setDescription(CEditorMessages.OpenDeclarations_description);
}
@Override
@@ -67,6 +67,7 @@ public class OpenDeclarationsAction extends SelectionParseAction {
if (job != null)
job.performNavigation(new NullProgressMonitor());
}
+
public void runSync(ITargetDisambiguator targetDisambiguator) throws CoreException {
OpenDeclarationsJob job = createJob(targetDisambiguator);
if (job != null)
@@ -74,28 +75,27 @@ public class OpenDeclarationsAction extends SelectionParseAction {
}
private OpenDeclarationsJob createJob(ITargetDisambiguator targetDisambiguator) {
- String text= computeSelectedWord();
- OpenDeclarationsJob job= null;
- ICElement elem= fEditor.getTranslationUnit();
+ String text = computeSelectedWord();
+ OpenDeclarationsJob job = null;
+ ICElement elem = fEditor.getTranslationUnit();
if (elem instanceof ITranslationUnit && fTextSelection != null) {
- job= new OpenDeclarationsJob(this, (ITranslationUnit) elem, fTextSelection, text,
- targetDisambiguator);
+ job = new OpenDeclarationsJob(this, (ITranslationUnit) elem, fTextSelection, text, targetDisambiguator);
}
return job;
}
private String computeSelectedWord() {
fTextSelection = getSelectedStringFromEditor();
- String text= null;
+ String text = null;
if (fTextSelection != null) {
if (fTextSelection.getLength() > 0) {
- text= fTextSelection.getText();
+ text = fTextSelection.getText();
} else {
- IDocument document= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
- IRegion reg= CWordFinder.findWord(document, fTextSelection.getOffset());
+ IDocument document = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+ IRegion reg = CWordFinder.findWord(document, fTextSelection.getOffset());
if (reg != null && reg.getLength() > 0) {
try {
- text= document.get(reg.getOffset(), reg.getLength());
+ text = document.get(reg.getOffset(), reg.getLength());
} catch (BadLocationException e) {
CUIPlugin.log(e);
}
@@ -104,7 +104,7 @@ public class OpenDeclarationsAction extends SelectionParseAction {
}
return text;
}
-
+
/**
* Used to diambiguate between multiple candidate targets for this action.
*/
@@ -113,16 +113,18 @@ public class OpenDeclarationsAction extends SelectionParseAction {
}
/**
- * Disambiguates by showing the user a dialog to choose.
+ * Disambiguates by showing the user a dialog to choose.
*/
private static class DialogTargetDisambiguator implements ITargetDisambiguator {
@Override
public ICElement disambiguateTargets(ICElement[] targets, SelectionParseAction action) {
return OpenActionUtil.selectCElement(targets, action.getSite().getShell(),
- CEditorMessages.OpenDeclarationsAction_dialog_title, CEditorMessages.OpenDeclarationsAction_selectMessage,
- CElementLabels.ALL_DEFAULT | CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.MF_POST_FILE_QUALIFIED, 0);
+ CEditorMessages.OpenDeclarationsAction_dialog_title,
+ CEditorMessages.OpenDeclarationsAction_selectMessage, CElementLabels.ALL_DEFAULT
+ | CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.MF_POST_FILE_QUALIFIED,
+ 0);
}
}
-
+
private static final ITargetDisambiguator sDefaultDisambiguator = new DialogTargetDisambiguator();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java
index 71c9e93fb60..1a7c89b8130 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java
@@ -123,7 +123,9 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction.ITarget
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
class OpenDeclarationsJob extends Job implements ASTRunnable {
- private enum NameKind { REFERENCE, DECLARATION, USING_DECL, DEFINITION }
+ private enum NameKind {
+ REFERENCE, DECLARATION, USING_DECL, DEFINITION
+ }
private final SelectionParseAction fAction;
private IProgressMonitor fMonitor;
@@ -133,14 +135,14 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
private final String fSelectedText;
private final ITargetDisambiguator fTargetDisambiguator;
- OpenDeclarationsJob(SelectionParseAction action, ITranslationUnit editorInput,
- ITextSelection textSelection, String text, ITargetDisambiguator targetDisambiguator) {
+ OpenDeclarationsJob(SelectionParseAction action, ITranslationUnit editorInput, ITextSelection textSelection,
+ String text, ITargetDisambiguator targetDisambiguator) {
super(CEditorMessages.OpenDeclarations_dialog_title);
- fAction= action;
- fTranslationUnit= editorInput;
- fTextSelection= textSelection;
- fSelectedText= text;
- fTargetDisambiguator= targetDisambiguator;
+ fAction = action;
+ fTranslationUnit = editorInput;
+ fTextSelection = textSelection;
+ fSelectedText = text;
+ fTargetDisambiguator = targetDisambiguator;
}
@Override
@@ -159,9 +161,9 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
if (fIndex != null)
return Status.CANCEL_STATUS;
- fMonitor= monitor;
- fIndex= CCorePlugin.getIndexManager().getIndex(fTranslationUnit.getCProject(),
- IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
+ fMonitor = monitor;
+ fIndex = CCorePlugin.getIndexManager().getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES
+ | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
try {
fIndex.acquireReadLock();
@@ -193,10 +195,10 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
if (fSelectedText != null && fSelectedText.length() > 0) {
final ICProject project = fTranslationUnit.getCProject();
final char[] name = fSelectedText.toCharArray();
- List<ICElement> elems= new ArrayList<>();
-
+ List<ICElement> elems = new ArrayList<>();
+
// Search for an element in the assembly file.
- // Some things in assembly files like macro definitions are
+ // Some things in assembly files like macro definitions are
// modelled in the C model, so those will be found here.
fTranslationUnit.accept(new ICElementVisitor() {
@Override
@@ -205,22 +207,23 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
elems.add(element);
}
return true;
- }});
-
+ }
+ });
+
// Search for a binding in the index.
final IndexFilter filter = IndexFilter.ALL;
final IIndexBinding[] bindings = fIndex.findBindings(name, false, filter, fMonitor);
for (IIndexBinding binding : bindings) {
// Convert bindings to CElements.
- IName[] declNames = fIndex.findNames(binding, IIndex.FIND_DECLARATIONS |
- IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ IName[] declNames = fIndex.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.FIND_DEFINITIONS
+ | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
convertToCElements(project, fIndex, declNames, elems);
}
// Search for a macro in the index.
- IIndexMacro[] macros= fIndex.findMacros(name, filter, fMonitor);
+ IIndexMacro[] macros = fIndex.findMacros(name, filter, fMonitor);
for (IIndexMacro macro : macros) {
- ICElement elem= IndexUI.getCElementForMacro(project, fIndex, macro);
+ ICElement elem = IndexUI.getCElementForMacro(project, fIndex, macro);
if (elem != null) {
elems.add(elem);
}
@@ -238,7 +241,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
fAction.reportSelectionMatchFailure();
return Status.OK_STATUS;
}
-
+
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
if (ast == null) {
@@ -257,7 +260,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
} else {
CPPSemantics.pushLookupPoint(sourceName);
try {
- boolean found= false;
+ boolean found = false;
final IASTNode parent = sourceName.getParent();
if (parent instanceof IASTPreprocessorIncludeStatement) {
openInclude(((IASTPreprocessorIncludeStatement) parent));
@@ -291,8 +294,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
// To try to do something useful anyways, we try to heuristically
// resolve the unknown binding to one or more concrete bindings,
// and use those instead.
- IBinding[] resolved = HeuristicResolver.resolveUnknownBinding(
- (ICPPUnknownBinding) binding);
+ IBinding[] resolved = HeuristicResolver.resolveUnknownBinding((ICPPUnknownBinding) binding);
if (resolved.length > 0) {
bindings = ArrayUtil.addAll(bindings, resolved);
continue;
@@ -306,8 +308,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
IName[] names = findDeclNames(ast, kind, binding);
for (final IName name : names) {
if (name != null) {
- if (name instanceof IIndexName &&
- filename.equals(((IIndexName) name).getFileLocation().getFileName())) {
+ if (name instanceof IIndexName
+ && filename.equals(((IIndexName) name).getFileLocation().getFileName())) {
// Exclude index names from the current file.
} else if (areOverlappingNames(name, sourceName)) {
// Exclude the current location.
@@ -328,7 +330,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
targets = ArrayUtil.trim(ArrayUtil.addAll(targets, implicitTargets));
if (navigateViaCElements(fTranslationUnit.getCProject(), fIndex, targets)) {
- found= true;
+ found = true;
} else {
// Leave old method as fallback for local variables, parameters and
// everything else not covered by ICElementHandle.
@@ -344,14 +346,14 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
// No enclosing name, check if we're in an include statement
- IASTNode node= nodeSelector.findEnclosingNode(selectionStart, selectionLength);
+ IASTNode node = nodeSelector.findEnclosingNode(selectionStart, selectionLength);
if (node instanceof IASTPreprocessorIncludeStatement) {
openInclude((IASTPreprocessorIncludeStatement) node);
return Status.OK_STATUS;
} else if (node instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
- IASTPreprocessorFunctionStyleMacroDefinition mdef= (IASTPreprocessorFunctionStyleMacroDefinition) node;
- for (IASTFunctionStyleMacroParameter par: mdef.getParameters()) {
- String parName= par.getParameter();
+ IASTPreprocessorFunctionStyleMacroDefinition mdef = (IASTPreprocessorFunctionStyleMacroDefinition) node;
+ for (IASTFunctionStyleMacroParameter par : mdef.getParameters()) {
+ String parName = par.getParameter();
if (parName.equals(fSelectedText)) {
if (navigateToLocation(par.getFileLocation())) {
return Status.OK_STATUS;
@@ -379,30 +381,31 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
if (declNames.length == 0 && binding instanceof ICPPMethod) {
// Bug 86829, handle implicit methods.
- ICPPMethod method= (ICPPMethod) binding;
+ ICPPMethod method = (ICPPMethod) binding;
if (method.isImplicit()) {
- IBinding clsBinding= method.getClassOwner();
+ IBinding clsBinding = method.getClassOwner();
if (clsBinding != null && !(clsBinding instanceof IProblemBinding)) {
- declNames= findNames(fIndex, ast, NameKind.REFERENCE, clsBinding);
+ declNames = findNames(fIndex, ast, NameKind.REFERENCE, clsBinding);
}
}
}
return declNames;
}
- private IName[] findNames(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding) throws CoreException {
+ private IName[] findNames(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding)
+ throws CoreException {
IName[] declNames;
if (kind == NameKind.DEFINITION) {
- declNames= findDeclarations(index, ast, binding);
+ declNames = findDeclarations(index, ast, binding);
} else {
- declNames= findDefinitions(index, ast, binding);
+ declNames = findDefinitions(index, ast, binding);
}
if (declNames.length == 0) {
if (kind == NameKind.DEFINITION) {
- declNames= findDefinitions(index, ast, binding);
+ declNames = findDefinitions(index, ast, binding);
} else {
- declNames= findDeclarations(index, ast, binding);
+ declNames = findDeclarations(index, ast, binding);
}
}
return declNames;
@@ -418,7 +421,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
List<IName> permissiveMatches = new ArrayList<>();
exactAstMatches.addAll(Arrays.asList(ast.getDefinitionsInAST(binding, /* permissive = */ true)));
for (Iterator<IASTName> i = exactAstMatches.iterator(); i.hasNext();) {
- IASTName name= i.next();
+ IASTName name = i.next();
final IBinding b2 = name.resolveBinding();
if (b2 instanceof ICPPUsingDeclaration) {
i.remove();
@@ -426,9 +429,9 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
if (binding != b2 && binding instanceof ICPPSpecialization) {
// Make sure binding specializes b2 so that for instance we do not navigate from
// one partial specialization to another.
- IBinding spec= binding;
+ IBinding spec = binding;
while (spec instanceof ICPPSpecialization) {
- spec= ((ICPPSpecialization) spec).getSpecializedBinding();
+ spec = ((ICPPSpecialization) spec).getSpecializedBinding();
if (spec == b2)
break;
}
@@ -446,8 +449,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
// Try definition in index.
- IName[] indexMatches = index.findNames(binding, IIndex.FIND_DEFINITIONS |
- IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES | IIndex.FIND_POTENTIAL_MATCHES);
+ IName[] indexMatches = index.findNames(binding,
+ IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES | IIndex.FIND_POTENTIAL_MATCHES);
List<IName> exactIndexMatches = new ArrayList<>();
exactIndexMatches.addAll(Arrays.asList(indexMatches));
for (Iterator<IName> i = exactIndexMatches.iterator(); i.hasNext();) {
@@ -460,29 +463,29 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
if (!exactIndexMatches.isEmpty()) {
return exactIndexMatches.toArray(new IName[exactIndexMatches.size()]);
}
-
+
if (!permissiveMatches.isEmpty()) {
return permissiveMatches.toArray(new IName[permissiveMatches.size()]);
}
-
+
return IName.EMPTY_ARRAY;
}
private IName[] findDeclarations(IIndex index, IASTTranslationUnit ast, IBinding binding) throws CoreException {
- IASTName[] astNames= ast.getDeclarationsInAST(binding);
+ IASTName[] astNames = ast.getDeclarationsInAST(binding);
ArrayList<IASTName> usingDeclarations = null;
for (int i = 0; i < astNames.length; i++) {
IASTName name = astNames[i];
if (name.isDefinition()) {
- astNames[i]= null;
+ astNames[i] = null;
} else if (ASTQueries.findAncestorWithType(name, ICPPASTUsingDeclaration.class) != null) {
if (usingDeclarations == null)
usingDeclarations = new ArrayList<>(1);
usingDeclarations.add(name);
- astNames[i]= null;
+ astNames[i] = null;
}
}
- IName[] declNames= ArrayUtil.removeNulls(astNames);
+ IName[] declNames = ArrayUtil.removeNulls(astNames);
if (declNames.length == 0) {
declNames = index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
}
@@ -495,12 +498,12 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
/**
* Returns definitions of bindings referenced by implicit name at the given location.
- *
+ *
* Also, if the given location is over the 'auto' in a variable declaration, the
* variable's type is opened.
*/
- private IName[] findImplicitTargets(IASTTranslationUnit ast, IASTNodeSelector nodeSelector,
- int offset, int length) throws CoreException {
+ private IName[] findImplicitTargets(IASTTranslationUnit ast, IASTNodeSelector nodeSelector, int offset, int length)
+ throws CoreException {
IName[] definitions = IName.EMPTY_ARRAY;
IASTName firstName = nodeSelector.findEnclosingImplicitName(offset, length);
if (firstName != null) {
@@ -571,19 +574,18 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
IASTFileLocation loc2 = getFileLocation(n2);
if (loc1 == null || loc2 == null)
return false;
- return loc1.getFileName().equals(loc2.getFileName()) &&
- max(loc1.getNodeOffset(), loc2.getNodeOffset()) <
- min(loc1.getNodeOffset() + loc1.getNodeLength(), loc2.getNodeOffset() + loc2.getNodeLength());
+ return loc1.getFileName().equals(loc2.getFileName())
+ && max(loc1.getNodeOffset(), loc2.getNodeOffset()) < min(loc1.getNodeOffset() + loc1.getNodeLength(),
+ loc2.getNodeOffset() + loc2.getNodeLength());
}
-
+
private static IASTFileLocation getFileLocation(IName name) {
IASTFileLocation fileLocation = name.getFileLocation();
if (name instanceof IASTName) {
IASTName astName = (IASTName) name;
IASTImageLocation imageLocation = astName.getImageLocation();
- if (imageLocation != null &&
- imageLocation.getLocationKind() != IASTImageLocation.MACRO_DEFINITION &&
- astName.getTranslationUnit().getFilePath().equals(fileLocation.getFileName())) {
+ if (imageLocation != null && imageLocation.getLocationKind() != IASTImageLocation.MACRO_DEFINITION
+ && astName.getTranslationUnit().getFilePath().equals(fileLocation.getFileName())) {
fileLocation = imageLocation;
}
}
@@ -594,7 +596,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
if (funcDeclName instanceof IASTName) {
IASTDeclaration fdecl = getEnclosingFunctionDeclaration((IASTNode) funcDeclName);
return fdecl != null && fdecl.contains(refName);
- }
+ }
return false;
}
@@ -608,10 +610,10 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
return false;
}
-
+
private static IASTDeclaration getEnclosingFunctionDeclaration(IASTNode node) {
while (node != null && !isFunctionDeclaration(node)) {
- node= node.getParent();
+ node = node.getParent();
}
return (IASTDeclaration) node;
}
@@ -620,13 +622,13 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
if (templateDeclName instanceof IASTName) {
IASTDeclaration template = getEnclosingTemplateDeclaration(refName);
return template != null && template.contains(refName);
- }
+ }
return false;
}
private static IASTDeclaration getEnclosingTemplateDeclaration(IASTNode node) {
while (node != null && !(node instanceof ICPPASTTemplateDeclaration)) {
- node= node.getParent();
+ node = node.getParent();
}
return (IASTDeclaration) node;
}
@@ -647,27 +649,27 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
private ICElementHandle getCElementForName(ICProject project, IIndex index, IName declName) throws CoreException {
if (declName instanceof IIndexName) {
IIndexName indexName = (IIndexName) declName;
- ITranslationUnit tu= IndexUI.getTranslationUnit(project, indexName);
+ ITranslationUnit tu = IndexUI.getTranslationUnit(project, indexName);
if (tu != null) {
// If the file containing the target name is accessible via multiple
// workspace paths, choose the one that most closely matches the
// workspace path of the file originating the action.
tu = IndexUI.getPreferredTranslationUnit(tu, fTranslationUnit);
-
+
return IndexUI.getCElementForName(tu, index, indexName);
}
return null;
}
if (declName instanceof IASTName) {
IASTName astName = (IASTName) declName;
- IBinding binding= astName.resolveBinding();
+ IBinding binding = astName.resolveBinding();
if (binding != null) {
- ITranslationUnit tu= IndexUI.getTranslationUnit(astName);
+ ITranslationUnit tu = IndexUI.getTranslationUnit(astName);
if (tu != null) {
if (tu instanceof IWorkingCopy)
tu = ((IWorkingCopy) tu).getOriginalElement();
- IASTFileLocation loc= getFileLocation(astName);
- IRegion region= new Region(loc.getNodeOffset(), loc.getNodeLength());
+ IASTFileLocation loc = getFileLocation(astName);
+ IRegion region = new Region(loc.getNodeOffset(), loc.getNodeLength());
return CElementHandleFactory.create(tu, binding, astName.isDefinition(), region, 0);
}
}
@@ -677,7 +679,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
private boolean navigateViaCElements(ICProject project, IIndex index, IName[] declNames) {
- final ArrayList<ICElement> elements= new ArrayList<>();
+ final ArrayList<ICElement> elements = new ArrayList<>();
convertToCElements(project, index, declNames, elements);
return navigateCElements(elements);
}
@@ -689,47 +691,47 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
final List<ICElement> uniqueElements;
if (elements.size() < 2) {
- uniqueElements= elements;
+ uniqueElements = elements;
} else {
// Make sure only one element per location is proposed
- Set<String> sigs= new HashSet<>();
+ Set<String> sigs = new HashSet<>();
sigs.add(null);
-
- uniqueElements= new ArrayList<>();
+
+ uniqueElements = new ArrayList<>();
for (ICElement elem : elements) {
if (sigs.add(getLocationSignature((ISourceReference) elem))) {
uniqueElements.add(elem);
}
}
}
-
+
runInUIThread(new Runnable() {
@Override
public void run() {
- ISourceReference target= null;
+ ISourceReference target = null;
if (uniqueElements.size() == 1) {
- target= (ISourceReference) uniqueElements.get(0);
+ target = (ISourceReference) uniqueElements.get(0);
} else {
if (uniqueElements.size() == 2) {
final ICElement e0 = uniqueElements.get(0);
final ICElement e1 = uniqueElements.get(1);
// Prefer a method of a class, to the class itself.
if (isMethodOfClass(e1, e0)) {
- target= (ISourceReference) e1;
+ target = (ISourceReference) e1;
} else if (isMethodOfClass(e0, e1)) {
- target= (ISourceReference) e0;
+ target = (ISourceReference) e0;
}
}
if (target == null) {
if (OpenDeclarationsAction.sDisallowAmbiguousInput) {
throw new RuntimeException("ambiguous input: " + uniqueElements.size()); //$NON-NLS-1$
}
- ICElement[] elemArray= uniqueElements.toArray(new ICElement[uniqueElements.size()]);
+ ICElement[] elemArray = uniqueElements.toArray(new ICElement[uniqueElements.size()]);
target = (ISourceReference) fTargetDisambiguator.disambiguateTargets(elemArray, fAction);
}
}
if (target != null) {
- ITranslationUnit tu= target.getTranslationUnit();
+ ITranslationUnit tu = target.getTranslationUnit();
ISourceRange sourceRange;
try {
sourceRange = target.getSourceRange();
@@ -741,24 +743,23 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
}
}
-
+
private boolean isMethodOfClass(ICElement method, ICElement clazz) {
- return method instanceof IMethodDeclaration
- && clazz instanceof IStructureDeclaration
- && method.getParent() != null
- && method.getParent().equals(clazz);
+ return method instanceof IMethodDeclaration && clazz instanceof IStructureDeclaration
+ && method.getParent() != null && method.getParent().equals(clazz);
}
});
return true;
}
private String getLocationSignature(ISourceReference elem) {
- ITranslationUnit tu= elem.getTranslationUnit();
+ ITranslationUnit tu = elem.getTranslationUnit();
ISourceRange sourceRange;
try {
sourceRange = elem.getSourceRange();
if (tu != null && sourceRange != null) {
- return tu.getPath().toString() + IPath.SEPARATOR + sourceRange.getIdStartPos() + IPath.SEPARATOR + sourceRange.getIdLength();
+ return tu.getPath().toString() + IPath.SEPARATOR + sourceRange.getIdStartPos() + IPath.SEPARATOR
+ + sourceRange.getIdLength();
}
} catch (CoreException e) {
CUIPlugin.log(e);
@@ -777,13 +778,14 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
try {
if (!indexFileSet.contains(((IIndexName) name).getFile()))
continue;
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
}
result = ArrayUtil.append(result, name);
}
return result;
}
-
+
private boolean navigateOneLocation(IASTTranslationUnit ast, IName[] names) {
// If there is more than one name, try to filter out
// ones defined in a file not in the AST's index file set.
@@ -846,7 +848,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
});
}
-
+
private void openInclude(IASTPreprocessorIncludeStatement incStmt) {
String name = null;
if (incStmt.isResolved())
@@ -871,7 +873,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
openInclude(paths, new String(incStmt.getName().toCharArray()));
}
-
+
private void openInclude(List<IPath> paths, String includeName) {
if (paths == null || paths.isEmpty()) {
fAction.reportIncludeLookupFailure(includeName);
@@ -881,8 +883,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
runInUIThread(new Runnable() {
@Override
public void run() {
- IPath selected = OpenActionUtil.selectPath(paths,
- CEditorMessages.OpenDeclarationsAction_dialog_title,
+ IPath selected = OpenActionUtil.selectPath(paths,
+ CEditorMessages.OpenDeclarationsAction_dialog_title,
CEditorMessages.OpenDeclarationsAction_selectMessage);
if (selected != null) {
openInclude(selected);
@@ -898,16 +900,16 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
try {
final ICProject project = fTranslationUnit.getCProject();
final char[] name = fSelectedText.toCharArray();
- List<ICElement> elems= new ArrayList<>();
-
+ List<ICElement> elems = new ArrayList<>();
+
// Bug 252549, search for names in the AST first.
- Set<IBinding> primaryBindings= new HashSet<>();
- ASTNameCollector nc= new ASTNameCollector(fSelectedText);
+ Set<IBinding> primaryBindings = new HashSet<>();
+ ASTNameCollector nc = new ASTNameCollector(fSelectedText);
ast.accept(nc);
- IASTName[] candidates= nc.getNames();
+ IASTName[] candidates = nc.getNames();
for (IASTName astName : candidates) {
try {
- IBinding b= astName.resolveBinding();
+ IBinding b = astName.resolveBinding();
if (b != null && !(b instanceof IProblemBinding)) {
primaryBindings.add(b);
}
@@ -924,9 +926,9 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
// Search for a macro in the index.
- IIndexMacro[] macros= fIndex.findMacros(name, filter, fMonitor);
+ IIndexMacro[] macros = fIndex.findMacros(name, filter, fMonitor);
for (IIndexMacro macro : macros) {
- ICElement elem= IndexUI.getCElementForMacro(project, fIndex, macro);
+ ICElement elem = IndexUI.getCElementForMacro(project, fIndex, macro);
if (elem != null) {
elems.add(elem);
}
@@ -934,13 +936,13 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
Collection<IBinding> secondaryBindings;
if (ast instanceof ICPPASTTranslationUnit) {
- secondaryBindings= cppRemoveSecondaryBindings(primaryBindings, sourceName);
+ secondaryBindings = cppRemoveSecondaryBindings(primaryBindings, sourceName);
} else {
- secondaryBindings= defaultRemoveSecondaryBindings(primaryBindings, sourceName);
+ secondaryBindings = defaultRemoveSecondaryBindings(primaryBindings, sourceName);
}
// Convert bindings to CElements.
- Collection<IBinding> bs= primaryBindings;
+ Collection<IBinding> bs = primaryBindings;
for (int k = 0; k < 2; k++) {
for (IBinding binding : bs) {
IName[] names = findNames(fIndex, ast, kind, binding);
@@ -956,7 +958,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
// In case we did not find anything, consider the secondary bindings.
if (!elems.isEmpty())
break;
- bs= secondaryBindings;
+ bs = secondaryBindings;
}
if (navigateCElements(elems)) {
return true;
@@ -974,8 +976,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
private Collection<IBinding> defaultRemoveSecondaryBindings(Set<IBinding> primaryBindings, IASTName sourceName) {
if (sourceName != null) {
- IBinding b= sourceName.resolveBinding();
- if (b != null && ! (b instanceof IProblemBinding)) {
+ IBinding b = sourceName.resolveBinding();
+ if (b != null && !(b instanceof IProblemBinding)) {
try {
for (Iterator<IBinding> iterator = primaryBindings.iterator(); iterator.hasNext();) {
if (!checkOwnerNames(b, iterator.next()))
@@ -1005,17 +1007,17 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
private Collection<IBinding> cppRemoveSecondaryBindings(Set<IBinding> primaryBindings, IASTName sourceName) {
- List<IBinding> result= new ArrayList<>();
- String[] sourceQualifiedName= null;
- int funcArgCount= -1;
+ List<IBinding> result = new ArrayList<>();
+ String[] sourceQualifiedName = null;
+ int funcArgCount = -1;
if (sourceName != null) {
final IBinding binding = sourceName.resolveBinding();
if (binding != null) {
- sourceQualifiedName= CPPVisitor.getQualifiedName(binding);
+ sourceQualifiedName = CPPVisitor.getQualifiedName(binding);
if (binding instanceof ICPPUnknownBinding) {
- LookupData data= CPPSemantics.createLookupData(sourceName);
+ LookupData data = CPPSemantics.createLookupData(sourceName);
if (data.isFunctionCall()) {
- funcArgCount= data.getFunctionArgumentCount();
+ funcArgCount = data.getFunctionArgumentCount();
}
}
}
@@ -1033,7 +1035,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
if (funcArgCount >= 0) {
// For C++ we can check the number of parameters.
if (binding instanceof ICPPFunction) {
- ICPPFunction f= (ICPPFunction) binding;
+ ICPPFunction f = (ICPPFunction) binding;
if (f.getRequiredArgumentCount() > funcArgCount) {
iterator.remove();
result.add(binding);
@@ -1041,9 +1043,9 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
if (!f.takesVarArgs() && !f.hasParameterPack()) {
final IType[] parameterTypes = f.getType().getParameterTypes();
- int maxArgs= parameterTypes.length;
+ int maxArgs = parameterTypes.length;
if (maxArgs == 1 && SemanticUtil.isVoidType(parameterTypes[0])) {
- maxArgs= 0;
+ maxArgs = 0;
}
if (maxArgs < funcArgCount) {
iterator.remove();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java
index 16b9458d9f5..187d9f1c565 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java
@@ -40,13 +40,13 @@ public class ReferencesSearchGroup extends ActionGroup {
private IWorkbenchSite fSite;
public ReferencesSearchGroup(IWorkbenchSite site) {
- fFindRefsAction= new FindRefsAction(site);
+ fFindRefsAction = new FindRefsAction(site);
fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
fFindRefsProjectAction = new FindRefsProjectAction(site);
fFindRefsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(site, null);
fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
- fSite=site;
+ fSite = site;
}
/**
@@ -55,7 +55,7 @@ public class ReferencesSearchGroup extends ActionGroup {
public ReferencesSearchGroup(CEditor editor) {
fEditor = editor;
- fFindRefsAction= new FindRefsAction(editor);
+ fFindRefsAction = new FindRefsAction(editor);
fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
fFindRefsProjectAction = new FindRefsProjectAction(editor);
@@ -78,7 +78,7 @@ public class ReferencesSearchGroup extends ActionGroup {
IMenuManager refsMenu = new MenuManager(CSearchMessages.group_references, IContextMenuConstants.GROUP_SEARCH);
- if (fEditor != null){
+ if (fEditor != null) {
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
} else {
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu);
@@ -105,16 +105,18 @@ public class ReferencesSearchGroup extends ActionGroup {
}
private FindAction[] getWorkingSetActions() {
- ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
+ ArrayList<FindAction> actions = new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
- Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
+ Iterator<IWorkingSet[]> iter = CSearchUtil.getLRUWorkingSets().iterator();
while (iter.hasNext()) {
- IWorkingSet[] workingSets= iter.next();
+ IWorkingSet[] workingSets = iter.next();
FindAction action;
if (fEditor != null)
- action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
+ action = new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets),
+ CSearchUtil.toString(workingSets));
else
- action= new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
+ action = new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets),
+ CSearchUtil.toString(workingSets));
actions.add(action);
}
@@ -127,9 +129,9 @@ public class ReferencesSearchGroup extends ActionGroup {
*/
@Override
public void dispose() {
- fFindRefsAction= null;
- fFindRefsProjectAction=null;
- fFindRefsInWorkingSetAction= null;
+ fFindRefsAction = null;
+ fFindRefsProjectAction = null;
+ fFindRefsInWorkingSetAction = null;
super.dispose();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java
index f3dcba09100..99af9842110 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java
@@ -40,29 +40,29 @@ import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
* Created on Jun 2, 2004
*/
public class SelectionParseAction extends Action {
-
+
protected IWorkbenchSite fSite;
protected ICModelBasedEditor fEditor;
public SelectionParseAction() {
super();
}
-
+
public SelectionParseAction(ICModelBasedEditor editor) {
super();
- fEditor= editor;
- fSite= editor.getSite();
+ fEditor = editor;
+ fSite = editor.getSite();
}
-
+
public SelectionParseAction(IWorkbenchSite site) {
super();
- fSite= site;
+ fSite = site;
}
public IWorkbenchSite getSite() {
return fSite;
}
-
+
protected void showStatusLineMessage(final String message) {
StatusLineHandler.showStatusLineMessage(fSite, message);
}
@@ -70,24 +70,24 @@ public class SelectionParseAction extends Action {
protected void clearStatusLine() {
StatusLineHandler.clearStatusLine(fSite);
}
-
+
protected ISelection getSelection() {
ISelection sel = null;
if (fSite != null && fSite.getSelectionProvider() != null) {
sel = fSite.getSelectionProvider().getSelection();
}
-
+
return sel;
}
-
- protected ITextSelection getSelectedStringFromEditor() {
- ISelection selection = getSelection();
- if (!(selection instanceof ITextSelection))
- return null;
-
- return (ITextSelection) selection;
- }
-
+
+ protected ITextSelection getSelectedStringFromEditor() {
+ ISelection selection = getSelection();
+ if (!(selection instanceof ITextSelection))
+ return null;
+
+ return (ITextSelection) selection;
+ }
+
protected void open(IPath path, int currentOffset, int currentLength) throws CoreException {
clearStatusLine();
@@ -112,25 +112,22 @@ public class SelectionParseAction extends Action {
}
}
- protected void reportSourceFileOpenFailure(IPath path) {
- showStatusLineMessage(MessageFormat.format(
- CSearchMessages.SelectionParseAction_FileOpenFailure_format,
- new Object[] { path.toOSString() }));
- }
-
- protected void reportSelectionMatchFailure() {
- showStatusLineMessage(CSearchMessages.SelectionParseAction_SelectedTextNotSymbol_message);
- }
-
- protected void reportSymbolLookupFailure(String symbol) {
- showStatusLineMessage(MessageFormat.format(
- CSearchMessages.SelectionParseAction_SymbolNotFoundInIndex_format,
- new Object[] { symbol }));
- }
-
- protected void reportIncludeLookupFailure(String filename) {
- showStatusLineMessage(MessageFormat.format(
- CSearchMessages.SelectionParseAction_IncludeNotFound_format,
- new Object[] { filename }));
- }
+ protected void reportSourceFileOpenFailure(IPath path) {
+ showStatusLineMessage(MessageFormat.format(CSearchMessages.SelectionParseAction_FileOpenFailure_format,
+ new Object[] { path.toOSString() }));
+ }
+
+ protected void reportSelectionMatchFailure() {
+ showStatusLineMessage(CSearchMessages.SelectionParseAction_SelectedTextNotSymbol_message);
+ }
+
+ protected void reportSymbolLookupFailure(String symbol) {
+ showStatusLineMessage(MessageFormat.format(CSearchMessages.SelectionParseAction_SymbolNotFoundInIndex_format,
+ new Object[] { symbol }));
+ }
+
+ protected void reportIncludeLookupFailure(String filename) {
+ showStatusLineMessage(MessageFormat.format(CSearchMessages.SelectionParseAction_IncludeNotFound_format,
+ new Object[] { filename }));
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java
index 708eab86261..2cf4d2d118e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java
@@ -36,26 +36,29 @@ public class SelectionSearchGroup extends ActionGroup {
private DeclarationsSearchGroup fDeclarationsSearchGroup;
private ReferencesSearchGroup fRefSearchGroup;
- public SelectionSearchGroup(CEditor editor){
+ public SelectionSearchGroup(CEditor editor) {
Assert.isNotNull(editor);
- fEditor= editor;
+ fEditor = editor;
- fDeclarationsSearchGroup= new DeclarationsSearchGroup(fEditor);
+ fDeclarationsSearchGroup = new DeclarationsSearchGroup(fEditor);
fRefSearchGroup = new ReferencesSearchGroup(fEditor);
}
+
/**
* @param page
*/
public SelectionSearchGroup(Page page) {
this(page.getSite());
}
+
/**
* @param site
*/
public SelectionSearchGroup(IWorkbenchSite site) {
- fDeclarationsSearchGroup= new DeclarationsSearchGroup(site);
+ fDeclarationsSearchGroup = new DeclarationsSearchGroup(site);
fRefSearchGroup = new ReferencesSearchGroup(site);
}
+
/*
* Method declared on ActionGroup.
*/
@@ -76,19 +79,19 @@ public class SelectionSearchGroup extends ActionGroup {
}
public static boolean canActionBeAdded(ISelection selection) {
- if(selection instanceof ITextSelection) {
- return (((ITextSelection)selection).getLength() > 0);
+ if (selection instanceof ITextSelection) {
+ return (((ITextSelection) selection).getLength() > 0);
}
return getElement(selection) != null;
}
private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
- List<?> list= ((IStructuredSelection)sel).toList();
+ List<?> list = ((IStructuredSelection) sel).toList();
if (list.size() == 1) {
- Object element= list.get(0);
+ Object element = list.get(0);
if (element instanceof ICElement) {
- return (ICElement)element;
+ return (ICElement) element;
}
}
}
@@ -102,15 +105,15 @@ public class SelectionSearchGroup extends ActionGroup {
public void dispose() {
if (fDeclarationsSearchGroup != null) {
fDeclarationsSearchGroup.dispose();
- fDeclarationsSearchGroup= null;
+ fDeclarationsSearchGroup = null;
}
if (fRefSearchGroup != null) {
fRefSearchGroup.dispose();
- fRefSearchGroup= null;
+ fRefSearchGroup = null;
}
- fEditor= null;
+ fEditor = null;
super.dispose();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.java
index 8241265fdd1..0ea8a4ff28a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.java
@@ -26,17 +26,17 @@ import org.eclipse.ui.IWorkbenchSite;
public class WorkingSetFindAction extends FindAction {
private FindAction findAction;
-
+
public WorkingSetFindAction(CEditor editor, FindAction action, String string) {
- super ( editor );
+ super(editor);
this.findAction = action;
- setText(string);
+ setText(string);
}
- public WorkingSetFindAction(IWorkbenchSite site,FindAction action, String string) {
+ public WorkingSetFindAction(IWorkbenchSite site, FindAction action, String string) {
super(site);
this.findAction = action;
- setText(string);
+ setText(string);
}
@Override
@@ -53,7 +53,7 @@ public class WorkingSetFindAction extends FindAction {
protected int getLimitTo() {
return findAction.getLimitTo();
}
-
+
@Override
public void run() {
findAction.run();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java
index 279e88de387..e945dedc8fb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java
@@ -54,22 +54,26 @@ import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
*
* @since 5.0
*/
-public abstract class AbstractCompareViewerInformationControl extends org.eclipse.jface.text.AbstractInformationControl implements IInformationControlExtension2, DisposeListener {
+public abstract class AbstractCompareViewerInformationControl extends org.eclipse.jface.text.AbstractInformationControl
+ implements IInformationControlExtension2, DisposeListener {
protected class CompareViewerControl extends ViewForm {
private CompareConfiguration fCompareConfiguration;
private Viewer fViewer;
+
public CompareViewerControl(Composite parent, int styles, CompareConfiguration cc) {
super(parent, styles & ~SWT.BORDER);
- verticalSpacing= 0;
- fCompareConfiguration= cc;
+ verticalSpacing = 0;
+ fCompareConfiguration = cc;
}
+
public CompareConfiguration getCompareConfiguration() {
return fCompareConfiguration;
}
+
public void setInput(ICompareInput input) {
if (fViewer == null) {
- fViewer= createContentViewer(this, input, fCompareConfiguration);
+ fViewer = createContentViewer(this, input, fCompareConfiguration);
setContent(fViewer.getControl());
}
fViewer.setInput(input);
@@ -111,45 +115,46 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
}
private void initializeColors() {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
RGB bgRGB;
if (store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
- bgRGB= SourceViewerInformationControl.getVisibleBackgroundColor(getShell().getDisplay());
+ bgRGB = SourceViewerInformationControl.getVisibleBackgroundColor(getShell().getDisplay());
} else {
- bgRGB= PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
+ bgRGB = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
}
if (bgRGB != null) {
- fBackgroundColor= new Color(getShell().getDisplay(), bgRGB);
- fIsSystemBackgroundColor= false;
+ fBackgroundColor = new Color(getShell().getDisplay(), bgRGB);
+ fIsSystemBackgroundColor = false;
} else {
- fBackgroundColor= getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fIsSystemBackgroundColor= true;
+ fBackgroundColor = getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ fIsSystemBackgroundColor = true;
}
}
-
+
@Override
protected void createContent(Composite parent) {
initializeColors();
- Composite content= new Composite(parent, SWT.NONE);
- final GridLayout gridLayout= new GridLayout();
- gridLayout.marginWidth= 0;
- gridLayout.marginHeight= 0;
- gridLayout.verticalSpacing= 0;
+ Composite content = new Composite(parent, SWT.NONE);
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ gridLayout.verticalSpacing = 0;
content.setLayout(gridLayout);
if (hasHeader()) {
createTitleLabel(content);
}
- CompareConfiguration compareConfig= new CompareConfiguration();
+ CompareConfiguration compareConfig = new CompareConfiguration();
compareConfig.setLeftEditable(false);
compareConfig.setRightEditable(false);
- fCompareViewerControl= createCompareViewerControl(content, SWT.NONE, compareConfig);
+ fCompareViewerControl = createCompareViewerControl(content, SWT.NONE, compareConfig);
addDisposeListener(this);
}
- protected CompareViewerControl createCompareViewerControl(Composite parent, int style, CompareConfiguration compareConfig) {
- CompareViewerControl compareViewer= new CompareViewerControl(parent, style, compareConfig);
+ protected CompareViewerControl createCompareViewerControl(Composite parent, int style,
+ CompareConfiguration compareConfig) {
+ CompareViewerControl compareViewer = new CompareViewerControl(parent, style, compareConfig);
return compareViewer;
}
@@ -158,19 +163,19 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
}
private void createTitleLabel(Composite parent) {
- fTitleLabel= new Label(parent, SWT.LEFT);
+ fTitleLabel = new Label(parent, SWT.LEFT);
fTitleLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Label separator= new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fTitleLabel.setFont(JFaceResources.getDialogFont());
- Display display= parent.getDisplay();
- Color foreground= display.getSystemColor(SWT.COLOR_TITLE_FOREGROUND);
- Color background= display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND);
+ Display display = parent.getDisplay();
+ Color foreground = display.getSystemColor(SWT.COLOR_TITLE_FOREGROUND);
+ Color background = display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND);
fTitleLabel.setForeground(foreground);
fTitleLabel.setBackground(background);
-
+
addMoveSupport(fTitleLabel);
}
@@ -182,7 +187,7 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
/**
* Returns the compare viewer.
- *
+ *
* @return the compare viewer.
*/
protected final CompareViewerControl getCompareViewer() {
@@ -191,7 +196,7 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
/**
* Returns the compare configuration.
- *
+ *
* @return the compare configuration.
*/
protected final CompareConfiguration getCompareConfiguration() {
@@ -203,7 +208,7 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
* <p>
* The default is to return <code>false</code>.
* </p>
- *
+ *
* @return <code>true</code> if the control has a header
*/
protected boolean hasHeader() {
@@ -222,14 +227,14 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
@Override
public void setInput(Object input) {
if (input instanceof ICompareInput) {
- fCompareInput= (ICompareInput) input;
+ fCompareInput = (ICompareInput) input;
if (fCompareViewerControl != null) {
fCompareViewerControl.setInput(fCompareInput);
}
} else if (input instanceof String) {
// do nothing
} else {
- fCompareInput= null;
+ fCompareInput = null;
if (fCompareViewerControl != null) {
fCompareViewerControl.setInput(fCompareInput);
}
@@ -261,7 +266,7 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
*/
@Override
public void widgetDisposed(DisposeEvent event) {
- fCompareViewerControl= null;
+ fCompareViewerControl = null;
}
@Override
@@ -272,19 +277,19 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
@Override
public Point computeSizeHint() {
// compute the preferred size
- int x= SWT.DEFAULT;
- int y= SWT.DEFAULT;
- Point size= getShell().computeSize(x, y);
- Point constraints= getSizeConstraints();
+ int x = SWT.DEFAULT;
+ int y = SWT.DEFAULT;
+ Point size = getShell().computeSize(x, y);
+ Point constraints = getSizeConstraints();
if (constraints != null) {
if (size.x < constraints.x)
- x= constraints.x;
+ x = constraints.x;
if (size.y < constraints.y)
- y= constraints.y;
+ y = constraints.y;
}
// recompute using the constraints if the preferred size is smaller than the constraints
if (x != SWT.DEFAULT || y != SWT.DEFAULT)
- size= getShell().computeSize(x, y, false);
+ size = getShell().computeSize(x, y, false);
return size;
}
@@ -297,35 +302,35 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
@Override
public Rectangle computeTrim() {
- Rectangle trim= super.computeTrim();
+ Rectangle trim = super.computeTrim();
addInternalTrim(trim);
return trim;
}
/**
* Adds the internal trimmings to the given trim of the shell.
- *
+ *
* @param trim the shell's trim, will be updated
* @since 5.0
*/
private void addInternalTrim(Rectangle trim) {
- Rectangle textTrim= fCompareViewerControl.computeTrim(0, 0, 0, 0);
- trim.x+= textTrim.x;
- trim.y+= textTrim.y;
- trim.width+= textTrim.width;
- trim.height+= textTrim.height;
+ Rectangle textTrim = fCompareViewerControl.computeTrim(0, 0, 0, 0);
+ trim.x += textTrim.x;
+ trim.y += textTrim.y;
+ trim.width += textTrim.width;
+ trim.height += textTrim.height;
if (fTitleLabel != null) {
- trim.height+= fTitleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+ trim.height += fTitleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
}
}
@Override
public Point computeSizeConstraints(int widthInChars, int heightInChars) {
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
- GC gc= new GC(fCompareViewerControl);
+ Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+ GC gc = new GC(fCompareViewerControl);
gc.setFont(font);
- int width= gc.getFontMetrics().getAverageCharWidth();
- int height= gc.getFontMetrics().getHeight();
+ int width = gc.getFontMetrics().getAverageCharWidth();
+ int height = gc.getFontMetrics().getHeight();
gc.dispose();
return new Point(widthInChars * width, heightInChars * height);
@@ -337,24 +342,24 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
}
protected final void addMoveSupport(final Control control) {
- MouseAdapter moveSupport= new MouseAdapter() {
+ MouseAdapter moveSupport = new MouseAdapter() {
private MouseMoveListener fMoveListener;
- private final Control fShell= getShell();
+ private final Control fShell = getShell();
@Override
public void mouseDown(MouseEvent e) {
- Point shellLoc= fShell.getLocation();
- final int shellX= shellLoc.x;
- final int shellY= shellLoc.y;
- Point mouseLoc= control.toDisplay(e.x, e.y);
- final int mouseX= mouseLoc.x;
- final int mouseY= mouseLoc.y;
- fMoveListener= new MouseMoveListener() {
+ Point shellLoc = fShell.getLocation();
+ final int shellX = shellLoc.x;
+ final int shellY = shellLoc.y;
+ Point mouseLoc = control.toDisplay(e.x, e.y);
+ final int mouseX = mouseLoc.x;
+ final int mouseY = mouseLoc.y;
+ fMoveListener = new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e2) {
- Point mouseLoc2= control.toDisplay(e2.x, e2.y);
- int dx= mouseLoc2.x - mouseX;
- int dy= mouseLoc2.y - mouseY;
+ Point mouseLoc2 = control.toDisplay(e2.x, e2.y);
+ int dx = mouseLoc2.x - mouseX;
+ int dy = mouseLoc2.y - mouseY;
fShell.setLocation(shellX + dx, shellY + dy);
}
};
@@ -364,7 +369,7 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
@Override
public void mouseUp(MouseEvent e) {
control.removeMouseMoveListener(fMoveListener);
- fMoveListener= null;
+ fMoveListener = null;
}
};
control.addMouseListener(moveSupport);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java
index 0a76f8befce..c10b502afe1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
@@ -81,7 +81,8 @@ import org.eclipse.cdt.internal.ui.util.StringMatcher;
*
* @since 4.0
*/
-public abstract class AbstractInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {
+public abstract class AbstractInformationControl extends PopupDialog
+ implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {
private final String COLON_COLON = String.valueOf(Keywords.cpCOLONCOLON);
private final Pattern PATTERN_COLON_COLON = Pattern.compile(COLON_COLON);
@@ -99,12 +100,12 @@ public abstract class AbstractInformationControl extends PopupDialog implements
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- StringMatcher matcher= getMatcher();
+ StringMatcher matcher = getMatcher();
if (matcher == null || !(viewer instanceof TreeViewer))
return true;
- TreeViewer treeViewer= (TreeViewer) viewer;
+ TreeViewer treeViewer = (TreeViewer) viewer;
- String matchName= ((ILabelProvider) treeViewer.getLabelProvider()).getText(element);
+ String matchName = ((ILabelProvider) treeViewer.getLabelProvider()).getText(element);
if (matchName != null) {
if (nameMatches(matchName, matcher))
return true;
@@ -115,7 +116,7 @@ public abstract class AbstractInformationControl extends PopupDialog implements
private boolean hasUnfilteredChild(TreeViewer viewer, Object element) {
if (element instanceof IParent || element instanceof CElementGrouping) {
- Object[] children= ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element);
+ Object[] children = ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element);
for (Object element2 : children)
if (select(viewer, element, element2))
return true;
@@ -144,8 +145,8 @@ public abstract class AbstractInformationControl extends PopupDialog implements
*/
private int fTreeStyle;
private Command fInvokingCommand;
- private TriggerSequence fInvokingTriggerSequence;
-
+ private TriggerSequence fInvokingTriggerSequence;
+
/**
* Creates a tree information control with the given shell as parent. The given
* styles are applied to the shell and the tree widget.
@@ -156,23 +157,24 @@ public abstract class AbstractInformationControl extends PopupDialog implements
* @param invokingCommandId the id of the command that invoked this control or <code>null</code>
* @param showStatusField <code>true</code> if the control has a status field at the bottom
*/
- public AbstractInformationControl(Shell parent, int shellStyle, int treeStyle, String invokingCommandId, boolean showStatusField) {
+ public AbstractInformationControl(Shell parent, int shellStyle, int treeStyle, String invokingCommandId,
+ boolean showStatusField) {
super(parent, shellStyle, true, true, true, true, true, null, null);
if (invokingCommandId != null) {
IWorkbench workbench = PlatformUI.getWorkbench();
ICommandService commandSupport = workbench.getAdapter(ICommandService.class);
- if (commandSupport != null) {
+ if (commandSupport != null) {
fInvokingCommand = commandSupport.getCommand(invokingCommandId);
if (fInvokingCommand != null && !fInvokingCommand.isDefined())
- fInvokingCommand= null;
+ fInvokingCommand = null;
else {
IBindingService bindingService = workbench.getService(IBindingService.class);
fInvokingTriggerSequence = bindingService.getBestActiveBindingFor(invokingCommandId);
}
}
}
- fTreeStyle= treeStyle;
- // Title and status text must be set to get the title label created, so force empty values here.
+ fTreeStyle = treeStyle;
+ // Title and status text must be set to get the title label created, so force empty values here.
if (hasHeader())
setTitleText(""); //$NON-NLS-1$
setInfoText(""); // //$NON-NLS-1$
@@ -186,24 +188,25 @@ public abstract class AbstractInformationControl extends PopupDialog implements
/**
* Create the main content for this information control.
- *
+ *
* @param parent The parent composite
* @return The control representing the main content.
- *
+ *
*/
@Override
protected Control createDialogArea(Composite parent) {
- fTreeViewer= createTreeViewer(parent, fTreeStyle);
+ fTreeViewer = createTreeViewer(parent, fTreeStyle);
- fCustomFiltersActionGroup= new CustomFiltersActionGroup(getId(), fTreeViewer);
+ fCustomFiltersActionGroup = new CustomFiltersActionGroup(getId(), fTreeViewer);
- final Tree tree= fTreeViewer.getTree();
+ final Tree tree = fTreeViewer.getTree();
tree.addKeyListener(new KeyListener() {
@Override
- public void keyPressed(KeyEvent e) {
+ public void keyPressed(KeyEvent e) {
if (e.character == 0x1B) // ESC
dispose();
}
+
@Override
public void keyReleased(KeyEvent e) {
// do nothing
@@ -215,36 +218,38 @@ public abstract class AbstractInformationControl extends PopupDialog implements
public void widgetSelected(SelectionEvent e) {
// do nothing
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
gotoSelectedElement();
}
});
- tree.addMouseMoveListener(new MouseMoveListener() {
- TreeItem fLastItem= null;
+ tree.addMouseMoveListener(new MouseMoveListener() {
+ TreeItem fLastItem = null;
+
@Override
public void mouseMove(MouseEvent e) {
if (tree.equals(e.getSource())) {
- Object o= tree.getItem(new Point(e.x, e.y));
+ Object o = tree.getItem(new Point(e.x, e.y));
if (o instanceof TreeItem) {
if (!o.equals(fLastItem)) {
- fLastItem= (TreeItem)o;
+ fLastItem = (TreeItem) o;
tree.setSelection(new TreeItem[] { fLastItem });
} else if (e.y < tree.getItemHeight() / 4) {
// Scroll up
- Point p= tree.toDisplay(e.x, e.y);
- Item item= fTreeViewer.scrollUp(p.x, p.y);
+ Point p = tree.toDisplay(e.x, e.y);
+ Item item = fTreeViewer.scrollUp(p.x, p.y);
if (item instanceof TreeItem) {
- fLastItem= (TreeItem)item;
+ fLastItem = (TreeItem) item;
tree.setSelection(new TreeItem[] { fLastItem });
}
} else if (e.y > tree.getBounds().height - tree.getItemHeight() / 4) {
// Scroll down
- Point p= tree.toDisplay(e.x, e.y);
- Item item= fTreeViewer.scrollDown(p.x, p.y);
+ Point p = tree.toDisplay(e.x, e.y);
+ Item item = fTreeViewer.scrollDown(p.x, p.y);
if (item instanceof TreeItem) {
- fLastItem= (TreeItem)item;
+ fLastItem = (TreeItem) item;
tree.setSelection(new TreeItem[] { fLastItem });
}
}
@@ -264,8 +269,8 @@ public abstract class AbstractInformationControl extends PopupDialog implements
return;
if (tree.equals(e.getSource())) {
- Object o= tree.getItem(new Point(e.x, e.y));
- TreeItem selection= tree.getSelection()[0];
+ Object o = tree.getItem(new Point(e.x, e.y));
+ TreeItem selection = tree.getSelection()[0];
if (selection.equals(o))
gotoSelectedElement();
}
@@ -277,7 +282,7 @@ public abstract class AbstractInformationControl extends PopupDialog implements
addDisposeListener(this);
return fTreeViewer.getControl();
}
-
+
/**
* Creates a tree information control with the given shell as parent. The given
* styles are applied to the shell and the tree widget.
@@ -308,7 +313,7 @@ public abstract class AbstractInformationControl extends PopupDialog implements
* <p>
* The default is to return <code>false</code>.
* </p>
- *
+ *
* @return <code>true</code> if the control has a header
*/
protected boolean hasHeader() {
@@ -321,17 +326,17 @@ public abstract class AbstractInformationControl extends PopupDialog implements
}
protected Text createFilterText(Composite parent) {
- fFilterText= new Text(parent, SWT.NONE);
+ fFilterText = new Text(parent, SWT.NONE);
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- GC gc= new GC(parent);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ GC gc = new GC(parent);
gc.setFont(parent.getFont());
- FontMetrics fontMetrics= gc.getFontMetrics();
+ FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
- data.heightHint= Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
- data.horizontalAlignment= GridData.FILL;
- data.verticalAlignment= GridData.CENTER;
+ data.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
+ data.horizontalAlignment = GridData.FILL;
+ data.verticalAlignment = GridData.CENTER;
fFilterText.setLayoutData(data);
fFilterText.addKeyListener(new KeyListener() {
@@ -346,6 +351,7 @@ public abstract class AbstractInformationControl extends PopupDialog implements
if (e.character == 0x1B) // ESC
dispose();
}
+
@Override
public void keyReleased(KeyEvent e) {
// do nothing
@@ -358,7 +364,7 @@ public abstract class AbstractInformationControl extends PopupDialog implements
protected void updateStatusFieldText() {
setInfoText(getStatusFieldText());
}
-
+
protected String getStatusFieldText() {
return ""; //$NON-NLS-1$
}
@@ -369,10 +375,10 @@ public abstract class AbstractInformationControl extends PopupDialog implements
fFilterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
- String text= ((Text) e.widget).getText();
- int length= text.length();
- if (length > 0 && text.charAt(length -1 ) != '*') {
- text= text + '*';
+ String text = ((Text) e.widget).getText();
+ int length = text.length();
+ if (length > 0 && text.charAt(length - 1) != '*') {
+ text = text + '*';
}
setMatcherString(text, true);
}
@@ -405,12 +411,12 @@ public abstract class AbstractInformationControl extends PopupDialog implements
*/
protected void setMatcherString(String pattern, boolean update) {
if (pattern.length() == 0) {
- fStringMatcher= null;
+ fStringMatcher = null;
} else {
- boolean ignoreCase= pattern.toLowerCase().equals(pattern);
- fStringMatcher= new StringMatcher(pattern, ignoreCase, false);
+ boolean ignoreCase = pattern.toLowerCase().equals(pattern);
+ fStringMatcher = new StringMatcher(pattern, ignoreCase, false);
}
-
+
if (update)
stringMatcherUpdated();
}
@@ -432,11 +438,11 @@ public abstract class AbstractInformationControl extends PopupDialog implements
}
private void gotoSelectedElement() {
- Object selectedElement= getSelectedElement();
+ Object selectedElement = getSelectedElement();
if (selectedElement != null) {
try {
dispose();
- IEditorPart part= EditorUtility.openInEditor(selectedElement, true);
+ IEditorPart part = EditorUtility.openInEditor(selectedElement, true);
if (part != null && selectedElement instanceof ICElement)
EditorUtility.revealInEditor(part, (ICElement) selectedElement);
} catch (CoreException ex) {
@@ -450,8 +456,8 @@ public abstract class AbstractInformationControl extends PopupDialog implements
* matches the current filter pattern.
*/
protected void selectFirstMatch() {
- Tree tree= fTreeViewer.getTree();
- Object element= findElement(tree.getItems());
+ Tree tree = fTreeViewer.getTree();
+ Object element = findElement(tree.getItems());
if (element != null)
fTreeViewer.setSelection(new StructuredSelection(element), true);
else
@@ -459,20 +465,20 @@ public abstract class AbstractInformationControl extends PopupDialog implements
}
private ICElement findElement(TreeItem[] items) {
- ILabelProvider labelProvider= (ILabelProvider)fTreeViewer.getLabelProvider();
+ ILabelProvider labelProvider = (ILabelProvider) fTreeViewer.getLabelProvider();
for (TreeItem treeItem : items) {
- Object data= treeItem.getData();
- ICElement element= null;
+ Object data = treeItem.getData();
+ ICElement element = null;
if (data instanceof ICElement) {
- element= (ICElement)data;
+ element = (ICElement) data;
if (fStringMatcher == null)
return element;
-
- String label= labelProvider.getText(element);
+
+ String label = labelProvider.getText(element);
if (label != null && nameMatches(label, fStringMatcher))
return element;
}
- element= findElement(treeItem.getItems());
+ element = findElement(treeItem.getItems());
if (element != null)
return element;
}
@@ -505,9 +511,9 @@ public abstract class AbstractInformationControl extends PopupDialog implements
/*
* Overridden to call the old framework method.
- *
+ *
* @see org.eclipse.jface.dialogs.PopupDialog#fillDialogMenu(IMenuManager)
- *
+ *
*/
@Override
protected void fillDialogMenu(IMenuManager dialogMenu) {
@@ -553,8 +559,8 @@ public abstract class AbstractInformationControl extends PopupDialog implements
*/
@Override
public void widgetDisposed(DisposeEvent event) {
- fTreeViewer= null;
- fFilterText= null;
+ fTreeViewer = null;
+ fFilterText = null;
}
/**
@@ -593,7 +599,7 @@ public abstract class AbstractInformationControl extends PopupDialog implements
* computed in Window#getInitialLocation, which will center it in the parent shell / main
* monitor, which is wrong for two reasons:
* - we want to center over the editor / subject control, not the parent shell
- * - the center is computed via the initalSize, which may be also wrong since the size may
+ * - the center is computed via the initalSize, which may be also wrong since the size may
* have been updated since via min/max sizing of AbstractInformationControlManager.
* In that case, override the location with the one computed by the manager. Note that
* the call to constrainShellSize in PopupDialog.open will still ensure that the shell is
@@ -679,37 +685,37 @@ public abstract class AbstractInformationControl extends PopupDialog implements
final protected Command getInvokingCommand() {
return fInvokingCommand;
}
-
+
final protected TriggerSequence getInvokingCommandTriggerSequence() {
return fInvokingTriggerSequence;
}
-
+
/*
* @see org.eclipse.jface.dialogs.PopupDialog#getDialogSettings()
*/
@Override
protected IDialogSettings getDialogSettings() {
- String sectionName= getId();
+ String sectionName = getId();
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null)
- settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
+ settings = CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
return settings;
}
-
+
/*
* Overridden to insert the filter text into the title and menu area.
*/
@Override
protected Control createTitleMenuArea(Composite parent) {
- fViewMenuButtonComposite= (Composite) super.createTitleMenuArea(parent);
+ fViewMenuButtonComposite = (Composite) super.createTitleMenuArea(parent);
// If there is a header, then the filter text must be created
// underneath the title and menu area.
if (hasHeader()) {
- fFilterText= createFilterText(parent);
+ fFilterText = createFilterText(parent);
}
return fViewMenuButtonComposite;
@@ -718,17 +724,17 @@ public abstract class AbstractInformationControl extends PopupDialog implements
/*
* Overridden to insert the filter text into the title control
* if there is no header specified.
- *
+ *
*/
@Override
protected Control createTitleControl(Composite parent) {
if (hasHeader()) {
return super.createTitleControl(parent);
}
- fFilterText= createFilterText(parent);
+ fFilterText = createFilterText(parent);
return fFilterText;
}
-
+
/*
* @see org.eclipse.jface.dialogs.PopupDialog#setTabOrder(org.eclipse.swt.widgets.Composite)
*/
@@ -748,11 +754,11 @@ public abstract class AbstractInformationControl extends PopupDialog implements
boolean nameMatches(String name, StringMatcher matcher) {
if (matcher.match(name))
return true;
-
+
Matcher match = PATTERN_COLON_COLON.matcher(name);
- while(match.find()) {
+ while (match.find()) {
int idx = match.start();
- if (matcher.match(name.substring(idx+COLON_COLON.length())))
+ if (matcher.match(name.substring(idx + COLON_COLON.length())))
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java
index 230afe1f2bb..21bd2607e8b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java
@@ -51,7 +51,8 @@ import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
*
* @since 5.0
*/
-public abstract class AbstractSourceViewerInformationControl extends org.eclipse.jface.text.AbstractInformationControl implements IInformationControlExtension2, DisposeListener {
+public abstract class AbstractSourceViewerInformationControl extends org.eclipse.jface.text.AbstractInformationControl
+ implements IInformationControlExtension2, DisposeListener {
private ISourceViewer fSourceViewer;
private Color fBackgroundColor;
@@ -94,43 +95,44 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse
}
private void initializeColors() {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
RGB bgRGB;
if (store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
- bgRGB= SourceViewerInformationControl.getVisibleBackgroundColor(getShell().getDisplay());
+ bgRGB = SourceViewerInformationControl.getVisibleBackgroundColor(getShell().getDisplay());
} else {
- bgRGB= PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
+ bgRGB = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
}
if (bgRGB != null) {
- fBackgroundColor= new Color(getShell().getDisplay(), bgRGB);
- fIsSystemBackgroundColor= false;
+ fBackgroundColor = new Color(getShell().getDisplay(), bgRGB);
+ fIsSystemBackgroundColor = false;
} else {
- fBackgroundColor= getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fIsSystemBackgroundColor= true;
+ fBackgroundColor = getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ fIsSystemBackgroundColor = true;
}
}
-
+
@Override
public void createContent(Composite parent) {
- Composite content= new Composite(parent, SWT.NONE);
- final GridLayout gridLayout= new GridLayout();
- gridLayout.marginWidth= 0;
- gridLayout.marginHeight= 0;
- gridLayout.verticalSpacing= 0;
+ Composite content = new Composite(parent, SWT.NONE);
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ gridLayout.verticalSpacing = 0;
content.setLayout(gridLayout);
if (hasHeader()) {
createTitleLabel(content);
}
- fSourceViewer= createSourceViewer(content, SWT.NONE);
+ fSourceViewer = createSourceViewer(content, SWT.NONE);
- final StyledText text= fSourceViewer.getTextWidget();
+ final StyledText text = fSourceViewer.getTextWidget();
text.addKeyListener(new KeyListener() {
@Override
- public void keyPressed(KeyEvent e) {
+ public void keyPressed(KeyEvent e) {
if (e.character == 0x1B) // ESC
dispose();
}
+
@Override
public void keyReleased(KeyEvent e) {
// do nothing
@@ -139,38 +141,39 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse
addDisposeListener(this);
}
-
+
protected final ISourceViewer createSourceViewer(Composite parent, int style) {
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- SourceViewer sourceViewer= new CSourceViewer(parent, null, null, false, style, store);
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ SourceViewer sourceViewer = new CSourceViewer(parent, null, null, false, style, store);
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null,
+ ICPartitions.C_PARTITIONING, false));
sourceViewer.setEditable(false);
- fText= sourceViewer.getTextWidget();
- GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
+ fText = sourceViewer.getTextWidget();
+ GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
fText.setLayoutData(gd);
initializeColors();
fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
fText.setBackground(fBackgroundColor);
-
- fTextFont= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+
+ fTextFont = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
fText.setFont(fTextFont);
return sourceViewer;
}
private void createTitleLabel(Composite parent) {
- fTitleLabel= new Label(parent, SWT.LEFT);
+ fTitleLabel = new Label(parent, SWT.LEFT);
fTitleLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Label separator= new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fTitleLabel.setFont(JFaceResources.getDialogFont());
- Display display= parent.getDisplay();
- Color foreground= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- Color background= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ Display display = parent.getDisplay();
+ Color foreground = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+ Color background = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
fTitleLabel.setForeground(foreground);
fTitleLabel.setBackground(background);
}
@@ -183,7 +186,7 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse
/**
* Returns the source viewer.
- *
+ *
* @return the source viewer.
*/
protected final ISourceViewer getSourceViewer() {
@@ -197,7 +200,7 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse
return;
}
- IDocument doc= new Document(content);
+ IDocument doc = new Document(content);
CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
fSourceViewer.setDocument(doc);
}
@@ -205,7 +208,7 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse
@Override
public void setInput(Object input) {
if (input instanceof String)
- setInformation((String)input);
+ setInformation((String) input);
else
setInformation(null);
}
@@ -227,7 +230,7 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse
*/
@Override
public void widgetDisposed(DisposeEvent event) {
- fSourceViewer= null;
+ fSourceViewer = null;
}
@Override
@@ -243,10 +246,10 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse
@Override
public Point computeSizeConstraints(int widthInChars, int heightInChars) {
- GC gc= new GC(fText);
+ GC gc = new GC(fText);
gc.setFont(fTextFont);
- int width= gc.getFontMetrics().getAverageCharWidth();
- int height= gc.getFontMetrics().getHeight();
+ int width = gc.getFontMetrics().getAverageCharWidth();
+ int height = gc.getFontMetrics().getHeight();
gc.dispose();
return new Point(widthInChars * width, heightInChars * height);
@@ -255,19 +258,19 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse
@Override
public Point computeSizeHint() {
// compute the preferred size
- int x= SWT.DEFAULT;
- int y= SWT.DEFAULT;
- Point size= getShell().computeSize(x, y);
- Point constraints= getSizeConstraints();
+ int x = SWT.DEFAULT;
+ int y = SWT.DEFAULT;
+ Point size = getShell().computeSize(x, y);
+ Point constraints = getSizeConstraints();
if (constraints != null) {
if (size.x > constraints.x)
- x= constraints.x;
+ x = constraints.x;
if (size.y > constraints.y)
- y= constraints.y;
+ y = constraints.y;
}
// recompute using the constraints if the preferred size is larger than the constraints
if (x != SWT.DEFAULT || y != SWT.DEFAULT)
- size= getShell().computeSize(x, y, false);
+ size = getShell().computeSize(x, y, false);
return size;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java
index 0433d574f1a..55ed709134d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java
@@ -20,152 +20,152 @@ import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.core.runtime.Assert;
/**
- * A buffered document scanner. The buffer always contains a section
+ * A buffered document scanner. The buffer always contains a section
* of a fixed size of the document to be scanned.
*/
public final class BufferedDocumentScanner implements ICharacterScanner {
- /** The document being scanned. */
- private IDocument fDocument;
- /** The offset of the document range to scan. */
- private int fRangeOffset;
- /** The length of the document range to scan. */
- private int fRangeLength;
- /** The delimiters of the document. */
- private char[][] fDelimiters;
-
- /** The buffer. */
- private final char[] fBuffer;
- /** The offset of the buffer within the document. */
- private int fBufferOffset;
- /** The valid length of the buffer for access. */
- private int fBufferLength;
- /** The offset of the scanner within the buffer. */
- private int fOffset;
-
- /**
- * Creates a new buffered document scanner.
- * The buffer size is set to the given number of characters.
- *
- * @param size the buffer size
- */
- public BufferedDocumentScanner(int size) {
- Assert.isTrue(size >= 1);
- fBuffer= new char[size];
- }
-
- /**
- * Fills the buffer with the contents of the document starting at the given offset.
- *
- * @param offset the document offset at which the buffer starts
- */
- private final void updateBuffer(int offset) {
-
- // Clamp at start of the file document range
- if (offset < 0)
- offset = 0;
-
- fBufferOffset= offset;
- fBufferLength= fBuffer.length;
-
- // assert(offset >= fRangeOffset && offset < fRangeOffset + fRangeLength);
-
- if (fBufferOffset + fBufferLength > fRangeOffset + fRangeLength)
- fBufferLength= fRangeOffset + fRangeLength - fBufferOffset;
-
- try {
- final String content= fDocument.get(fBufferOffset, fBufferLength);
- content.getChars(0, fBufferLength, fBuffer, 0);
-
- } catch (BadLocationException e) {
- }
- }
-
- /**
- * Configures the scanner by providing access to the document range over which to scan.
- *
- * @param document the document to scan
- * @param offset the offset of the document range to scan
- * @param length the length of the document range to scan
- */
- public final void setRange(IDocument document, int offset, int length) {
-
- fDocument= document;
- fRangeOffset= offset;
- fRangeLength= length;
-
- // Clamp at end of the real document
- if (fRangeLength + fRangeOffset > fDocument.getLength())
- fRangeLength = fDocument.getLength() - fRangeOffset;
-
- String[] delimiters= document.getLegalLineDelimiters();
- fDelimiters= new char[delimiters.length][];
- for (int i= 0; i < delimiters.length; i++)
- fDelimiters[i]= delimiters[i].toCharArray();
-
- updateBuffer(offset);
- fOffset= 0;
- }
-
- /*
- * @see ICharacterScanner#read()
- */
- @Override
+ /** The document being scanned. */
+ private IDocument fDocument;
+ /** The offset of the document range to scan. */
+ private int fRangeOffset;
+ /** The length of the document range to scan. */
+ private int fRangeLength;
+ /** The delimiters of the document. */
+ private char[][] fDelimiters;
+
+ /** The buffer. */
+ private final char[] fBuffer;
+ /** The offset of the buffer within the document. */
+ private int fBufferOffset;
+ /** The valid length of the buffer for access. */
+ private int fBufferLength;
+ /** The offset of the scanner within the buffer. */
+ private int fOffset;
+
+ /**
+ * Creates a new buffered document scanner.
+ * The buffer size is set to the given number of characters.
+ *
+ * @param size the buffer size
+ */
+ public BufferedDocumentScanner(int size) {
+ Assert.isTrue(size >= 1);
+ fBuffer = new char[size];
+ }
+
+ /**
+ * Fills the buffer with the contents of the document starting at the given offset.
+ *
+ * @param offset the document offset at which the buffer starts
+ */
+ private final void updateBuffer(int offset) {
+
+ // Clamp at start of the file document range
+ if (offset < 0)
+ offset = 0;
+
+ fBufferOffset = offset;
+ fBufferLength = fBuffer.length;
+
+ // assert(offset >= fRangeOffset && offset < fRangeOffset + fRangeLength);
+
+ if (fBufferOffset + fBufferLength > fRangeOffset + fRangeLength)
+ fBufferLength = fRangeOffset + fRangeLength - fBufferOffset;
+
+ try {
+ final String content = fDocument.get(fBufferOffset, fBufferLength);
+ content.getChars(0, fBufferLength, fBuffer, 0);
+
+ } catch (BadLocationException e) {
+ }
+ }
+
+ /**
+ * Configures the scanner by providing access to the document range over which to scan.
+ *
+ * @param document the document to scan
+ * @param offset the offset of the document range to scan
+ * @param length the length of the document range to scan
+ */
+ public final void setRange(IDocument document, int offset, int length) {
+
+ fDocument = document;
+ fRangeOffset = offset;
+ fRangeLength = length;
+
+ // Clamp at end of the real document
+ if (fRangeLength + fRangeOffset > fDocument.getLength())
+ fRangeLength = fDocument.getLength() - fRangeOffset;
+
+ String[] delimiters = document.getLegalLineDelimiters();
+ fDelimiters = new char[delimiters.length][];
+ for (int i = 0; i < delimiters.length; i++)
+ fDelimiters[i] = delimiters[i].toCharArray();
+
+ updateBuffer(offset);
+ fOffset = 0;
+ }
+
+ /*
+ * @see ICharacterScanner#read()
+ */
+ @Override
public final int read() {
-
- if (fOffset >= fBufferLength) {
- if (fBufferOffset + fBufferLength >= fRangeOffset + fRangeLength)
- return EOF;
- updateBuffer(fBufferOffset + fBufferLength);
- fOffset= 0;
- }
-
- return fBuffer[fOffset++];
- }
-
- /*
- * @see ICharacterScanner#unread
- */
- @Override
+
+ if (fOffset >= fBufferLength) {
+ if (fBufferOffset + fBufferLength >= fRangeOffset + fRangeLength)
+ return EOF;
+ updateBuffer(fBufferOffset + fBufferLength);
+ fOffset = 0;
+ }
+
+ return fBuffer[fOffset++];
+ }
+
+ /*
+ * @see ICharacterScanner#unread
+ */
+ @Override
public final void unread() {
- if (fOffset <= 0) {
- if (fBufferOffset <= fRangeOffset) {
- // error: BOF
- } else {
- updateBuffer(fBufferOffset - fBuffer.length);
- fOffset = fBuffer.length - 1; // should always be a valid place
- }
- } else {
- --fOffset;
- }
- }
-
- /*
- * @see ICharacterScanner#getColumn()
- */
- @Override
+ if (fOffset <= 0) {
+ if (fBufferOffset <= fRangeOffset) {
+ // error: BOF
+ } else {
+ updateBuffer(fBufferOffset - fBuffer.length);
+ fOffset = fBuffer.length - 1; // should always be a valid place
+ }
+ } else {
+ --fOffset;
+ }
+ }
+
+ /*
+ * @see ICharacterScanner#getColumn()
+ */
+ @Override
public final int getColumn() {
- try {
- final int offset= fBufferOffset + fOffset;
- final int line= fDocument.getLineOfOffset(offset);
- final int start= fDocument.getLineOffset(line);
-
- return offset - start;
-
- } catch (BadLocationException e) {
- }
-
- return -1;
- }
-
- /*
- * @see ICharacterScanner#getLegalLineDelimiters()
- */
- @Override
+ try {
+ final int offset = fBufferOffset + fOffset;
+ final int line = fDocument.getLineOfOffset(offset);
+ final int start = fDocument.getLineOffset(line);
+
+ return offset - start;
+
+ } catch (BadLocationException e) {
+ }
+
+ return -1;
+ }
+
+ /*
+ * @see ICharacterScanner#getLegalLineDelimiters()
+ */
+ @Override
public final char[][] getLegalLineDelimiters() {
- return fDelimiters;
- }
+ return fDelimiters;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
index add769e3143..f311b2c5f49 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
@@ -51,18 +51,18 @@ import org.eclipse.cdt.internal.ui.text.CIndenter.MatchMode;
*/
public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
/** The line comment introducer. Value is "{@value}" */
- private static final String LINE_COMMENT= "//"; //$NON-NLS-1$
-// private static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
-
-// private static class CompilationUnitInfo {
-// char[] buffer;
-// int delta;
-//
-// CompilationUnitInfo(char[] buffer, int delta) {
-// this.buffer = buffer;
-// this.delta = delta;
-// }
-// }
+ private static final String LINE_COMMENT = "//"; //$NON-NLS-1$
+ // private static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
+
+ // private static class CompilationUnitInfo {
+ // char[] buffer;
+ // int delta;
+ //
+ // CompilationUnitInfo(char[] buffer, int delta) {
+ // this.buffer = buffer;
+ // this.delta = delta;
+ // }
+ // }
private boolean fCloseBrace;
private boolean fIsSmartMode;
@@ -84,55 +84,56 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
public CAutoIndentStrategy(String partitioning, ICProject project) {
fPartitioning = partitioning;
fProject = project;
- }
+ }
public CAutoIndentStrategy(String partitioning, ICProject project, boolean alwaysUseSmartMode) {
this(partitioning, project);
this.alwaysUseSmartMode = alwaysUseSmartMode;
}
- private int getBracketCount(IDocument d, int start, int end, boolean ignoreCloseBrackets) throws BadLocationException {
+ private int getBracketCount(IDocument d, int start, int end, boolean ignoreCloseBrackets)
+ throws BadLocationException {
int bracketcount = 0;
while (start < end) {
char curr = d.getChar(start);
start++;
switch (curr) {
- case '/' :
- if (start < end) {
- char next = d.getChar(start);
- if (next == '*') {
- // a comment starts, advance to the comment end
- start = getCommentEnd(d, start + 1, end);
- } else if (next == '/') {
- // '//'-comment: nothing to do anymore on this line
- start = end;
- }
- }
- break;
- case '*' :
- if (start < end) {
- char next = d.getChar(start);
- if (next == '/') {
- // we have been in a comment: forget what we read before
- bracketcount = 0;
- start++;
- }
+ case '/':
+ if (start < end) {
+ char next = d.getChar(start);
+ if (next == '*') {
+ // a comment starts, advance to the comment end
+ start = getCommentEnd(d, start + 1, end);
+ } else if (next == '/') {
+ // '//'-comment: nothing to do anymore on this line
+ start = end;
}
- break;
- case '{' :
- bracketcount++;
- ignoreCloseBrackets = false;
- break;
- case '}' :
- if (!ignoreCloseBrackets) {
- bracketcount--;
+ }
+ break;
+ case '*':
+ if (start < end) {
+ char next = d.getChar(start);
+ if (next == '/') {
+ // we have been in a comment: forget what we read before
+ bracketcount = 0;
+ start++;
}
- break;
- case '"' :
- case '\'' :
- start = getStringEnd(d, start, end, curr);
- break;
- default :
+ }
+ break;
+ case '{':
+ bracketcount++;
+ ignoreCloseBrackets = false;
+ break;
+ case '}':
+ if (!ignoreCloseBrackets) {
+ bracketcount--;
+ }
+ break;
+ case '"':
+ case '\'':
+ start = getStringEnd(d, start, end, curr);
+ break;
+ default:
}
}
return bracketcount;
@@ -187,8 +188,8 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
int start = d.getLineOffset(line);
int whiteend = findEndOfWhiteSpace(d, start, c.offset);
- CHeuristicScanner scanner= new CHeuristicScanner(d);
- ITypedRegion partition= TextUtilities.getPartition(d, fPartitioning, p, false);
+ CHeuristicScanner scanner = new CHeuristicScanner(d);
+ ITypedRegion partition = TextUtilities.getPartition(d, fPartitioning, p, false);
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
scanner = new CHeuristicScanner(d, fPartitioning, ICPartitions.C_PREPROCESSOR);
}
@@ -223,8 +224,8 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
int p = (c.offset == d.getLength() ? c.offset - 1 : c.offset);
try {
- CHeuristicScanner scanner= new CHeuristicScanner(d);
- ITypedRegion partition= TextUtilities.getPartition(d, fPartitioning, p, false);
+ CHeuristicScanner scanner = new CHeuristicScanner(d);
+ ITypedRegion partition = TextUtilities.getPartition(d, fPartitioning, p, false);
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
scanner = new CHeuristicScanner(d, fPartitioning, ICPartitions.C_PREPROCESSOR);
}
@@ -263,13 +264,14 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
if (c.offset == -1 || docLength == 0)
return;
- int addIndent= 0;
- CHeuristicScanner scanner= new CHeuristicScanner(d);
+ int addIndent = 0;
+ CHeuristicScanner scanner = new CHeuristicScanner(d);
try {
- ITypedRegion partition= TextUtilities.getPartition(d, fPartitioning, c.offset, false);
- if (ICPartitions.C_PREPROCESSOR.equals(partition.getType()) && c.offset > 0 && d.getChar(c.offset-1) == '\\') {
+ ITypedRegion partition = TextUtilities.getPartition(d, fPartitioning, c.offset, false);
+ if (ICPartitions.C_PREPROCESSOR.equals(partition.getType()) && c.offset > 0
+ && d.getChar(c.offset - 1) == '\\') {
scanner = new CHeuristicScanner(d, fPartitioning, ICPartitions.C_PREPROCESSOR);
- addIndent= 1;
+ addIndent = 1;
}
int line = d.getLineOfOffset(c.offset);
@@ -277,28 +279,28 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
int start = reg.getOffset();
int lineEnd = start + reg.getLength();
- StringBuilder indent= null;
- CIndenter indenter= new CIndenter(d, scanner, fProject);
+ StringBuilder indent = null;
+ CIndenter indenter = new CIndenter(d, scanner, fProject);
if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_AUTO_INDENT)) {
- indent= indenter.computeIndentation(c.offset);
+ indent = indenter.computeIndentation(c.offset);
} else {
// reuse existing indent
- int wsEnd= findEndOfWhiteSpace(d, start, c.offset);
+ int wsEnd = findEndOfWhiteSpace(d, start, c.offset);
if (wsEnd > start) {
- indent= new StringBuilder(d.get(start, wsEnd - start));
- addIndent= 0;
+ indent = new StringBuilder(d.get(start, wsEnd - start));
+ addIndent = 0;
}
}
if (indent == null) {
- indent= new StringBuilder();
+ indent = new StringBuilder();
}
if (addIndent > 0 && indent.length() == 0) {
- indent= indenter.createReusingIndent(indent, addIndent, 0);
+ indent = indenter.createReusingIndent(indent, addIndent, 0);
}
StringBuilder buf = new StringBuilder(c.text + indent);
int contentStart = findEndOfWhiteSpace(d, c.offset, lineEnd);
- c.length = Math.max(contentStart - c.offset, 0);
+ c.length = Math.max(contentStart - c.offset, 0);
// insert closing brace on new line after an unclosed opening brace
if (getBracketCount(d, start, c.offset, true) > 0 && fCloseBrace && !isClosedBrace(d, c.offset, c.length)) {
@@ -309,7 +311,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
// unless we think we are inserting an anonymous type definition
if (c.offset == 0 || !(computeAnonymousPosition(d, c.offset - 1, fPartitioning, lineEnd) != -1)) {
if (lineEnd - contentStart > 0) {
- c.length = lineEnd - c.offset;
+ c.length = lineEnd - c.offset;
buf.append(d.get(contentStart, lineEnd - contentStart).toCharArray());
}
}
@@ -324,11 +326,11 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
if (reference != null)
buf.append(reference);
buf.append('}');
- int bound= c.offset > 200 ? c.offset - 200 : CHeuristicScanner.UNBOUND;
+ int bound = c.offset > 200 ? c.offset - 200 : CHeuristicScanner.UNBOUND;
int bracePos = scanner.findOpeningPeer(c.offset - 1, bound, '{', '}');
if (bracePos != CHeuristicScanner.NOT_FOUND) {
- if (scanner.looksLikeCompositeTypeDefinitionBackward(bracePos, bound) ||
- scanner.previousToken(bracePos - 1, bound) == Symbols.TokenEQUAL) {
+ if (scanner.looksLikeCompositeTypeDefinitionBackward(bracePos, bound)
+ || scanner.previousToken(bracePos - 1, bound) == Symbols.TokenEQUAL) {
buf.append(';');
}
}
@@ -359,7 +361,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
CUIPlugin.log(e);
}
}
-
+
/**
* Computes an insert position for an opening brace if <code>offset</code> maps to a position in
* <code>document</code> with a expression in parenthesis that will take a block after the closing parenthesis.
@@ -370,7 +372,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
* @param max the max position
* @return an insert position relative to the line start if <code>line</code> contains a parenthesized expression that can be followed by a block, -1 otherwise
*/
- private static int computeAnonymousPosition(IDocument document, int offset, String partitioning, int max) {
+ private static int computeAnonymousPosition(IDocument document, int offset, String partitioning, int max) {
// find the opening parenthesis for every closing parenthesis on the current line after offset
// return the position behind the closing parenthesis if it looks like a method declaration
// or an expression for an if, while, for, catch statement
@@ -424,98 +426,98 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
private boolean isClosedBrace(IDocument document, int offset, int length) {
return getBlockBalance(document, offset, fPartitioning) <= 0;
//TODO: Use smarter algorithm based on
-// CompilationUnitInfo info = getCompilationUnitForMethod(document, offset, fPartitioning);
-// if (info == null)
-// return false;
-//
-// CodeReader reader = new CodeReader(info.buffer);
-// ICodeReaderFactory fileCreator = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
-//
-// IScanner domScanner = new DOMScanner(reader, new ScannerInfo(), ParserMode.COMPLETE_PARSE,
-// ParserLanguage.C, ParserFactory.createDefaultLogService(),
-// C_GNU_SCANNER_EXTENSION, fileCreator);
-//
-// ISourceCodeParser parser = new GNUCPPSourceParser(
-// domScanner,
-// ParserMode.COMPLETE_PARSE,
-// ParserUtil.getParserLogService(),
-// new GPPParserExtensionConfiguration());
-//
-// IASTTranslationUnit translationUnit = parser.parse();
-// final int relativeOffset = offset - info.delta;
-// IASTNode node = translationUnit.selectNodeForLocation(reader.getPath(), relativeOffset, length);
-//
-// if (node == null)
-// return false;
-//
-// if (node instanceof IASTCompoundStatement) {
-// return getBlockBalance(document, offset, fPartitioning) <= 0;
-// } else if (node instanceof IASTIfStatement) {
-// IASTIfStatement ifStatement = (IASTIfStatement) node;
-// IASTExpression expression = ifStatement.getConditionExpression();
-// IRegion expressionRegion = createRegion(expression, info.delta);
-// IASTStatement thenStatement = ifStatement.getThenClause();
-// IRegion thenRegion = createRegion(thenStatement, info.delta);
-//
-// // Between expression and then statement
-// if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= thenRegion.getOffset())
-// return thenStatement != null;
-//
-// IASTStatement elseStatement = ifStatement.getElseClause();
-// IRegion elseRegion = createRegion(elseStatement, info.delta);
-//
-// if (elseStatement != null) {
-// int sourceOffset = thenRegion.getOffset() + thenRegion.getLength();
-// int sourceLength = elseRegion.getOffset() - sourceOffset;
-// CHeuristicScanner scanner = new CHeuristicScanner(new SimpleDocument(info.buffer));
-// int pos = sourceOffset;
-// int id;
-// while ((id = scanner.nextToken(pos, sourceOffset + sourceLength - pos)) != CHeuristicScanner.TokenEOF) {
-// if (id == CHeuristicScanner.TokenELSE) {
-// pos = scanner.getPosition();
-// // Between 'else' token and else statement.
-// return pos <= offset && offset + length < elseRegion.getOffset();
-// }
-// }
-//
-// return true;
-// }
-// } else if (node instanceof IASTForStatement) {
-// IASTExpression expression = ((IASTForStatement) node).getConditionExpression();
-// IRegion expressionRegion = createRegion(expression, info.delta);
-// IASTStatement body = ((IASTForStatement) node).getBody();
-// IRegion bodyRegion = createRegion(body, info.delta);
-//
-// // Between expression and body statement
-// if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
-// return body != null;
-// }
-// } else if (node instanceof IASTWhileStatement) {
-// IASTExpression expression = ((IASTWhileStatement) node).getCondition();
-// IRegion expressionRegion = createRegion(expression, info.delta);
-// IASTStatement body = ((IASTWhileStatement) node).getBody();
-// IRegion bodyRegion = createRegion(body, info.delta);
-//
-// // Between expression and body statement
-// if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
-// return body != null;
-// }
-// } else if (node instanceof IASTDoStatement) {
-// IASTDoStatement doStatement = (IASTDoStatement) node;
-// IRegion doRegion = createRegion(doStatement, info.delta);
-// IASTStatement body = doStatement.getBody();
-// IRegion bodyRegion = createRegion(body, info.delta);
-//
-// // Between 'do' and body statement.
-// if (doRegion.getOffset() + doRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
-// return body != null;
-// }
-// }
-//
-// return true;
+ // CompilationUnitInfo info = getCompilationUnitForMethod(document, offset, fPartitioning);
+ // if (info == null)
+ // return false;
+ //
+ // CodeReader reader = new CodeReader(info.buffer);
+ // ICodeReaderFactory fileCreator = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
+ //
+ // IScanner domScanner = new DOMScanner(reader, new ScannerInfo(), ParserMode.COMPLETE_PARSE,
+ // ParserLanguage.C, ParserFactory.createDefaultLogService(),
+ // C_GNU_SCANNER_EXTENSION, fileCreator);
+ //
+ // ISourceCodeParser parser = new GNUCPPSourceParser(
+ // domScanner,
+ // ParserMode.COMPLETE_PARSE,
+ // ParserUtil.getParserLogService(),
+ // new GPPParserExtensionConfiguration());
+ //
+ // IASTTranslationUnit translationUnit = parser.parse();
+ // final int relativeOffset = offset - info.delta;
+ // IASTNode node = translationUnit.selectNodeForLocation(reader.getPath(), relativeOffset, length);
+ //
+ // if (node == null)
+ // return false;
+ //
+ // if (node instanceof IASTCompoundStatement) {
+ // return getBlockBalance(document, offset, fPartitioning) <= 0;
+ // } else if (node instanceof IASTIfStatement) {
+ // IASTIfStatement ifStatement = (IASTIfStatement) node;
+ // IASTExpression expression = ifStatement.getConditionExpression();
+ // IRegion expressionRegion = createRegion(expression, info.delta);
+ // IASTStatement thenStatement = ifStatement.getThenClause();
+ // IRegion thenRegion = createRegion(thenStatement, info.delta);
+ //
+ // // Between expression and then statement
+ // if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= thenRegion.getOffset())
+ // return thenStatement != null;
+ //
+ // IASTStatement elseStatement = ifStatement.getElseClause();
+ // IRegion elseRegion = createRegion(elseStatement, info.delta);
+ //
+ // if (elseStatement != null) {
+ // int sourceOffset = thenRegion.getOffset() + thenRegion.getLength();
+ // int sourceLength = elseRegion.getOffset() - sourceOffset;
+ // CHeuristicScanner scanner = new CHeuristicScanner(new SimpleDocument(info.buffer));
+ // int pos = sourceOffset;
+ // int id;
+ // while ((id = scanner.nextToken(pos, sourceOffset + sourceLength - pos)) != CHeuristicScanner.TokenEOF) {
+ // if (id == CHeuristicScanner.TokenELSE) {
+ // pos = scanner.getPosition();
+ // // Between 'else' token and else statement.
+ // return pos <= offset && offset + length < elseRegion.getOffset();
+ // }
+ // }
+ //
+ // return true;
+ // }
+ // } else if (node instanceof IASTForStatement) {
+ // IASTExpression expression = ((IASTForStatement) node).getConditionExpression();
+ // IRegion expressionRegion = createRegion(expression, info.delta);
+ // IASTStatement body = ((IASTForStatement) node).getBody();
+ // IRegion bodyRegion = createRegion(body, info.delta);
+ //
+ // // Between expression and body statement
+ // if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
+ // return body != null;
+ // }
+ // } else if (node instanceof IASTWhileStatement) {
+ // IASTExpression expression = ((IASTWhileStatement) node).getCondition();
+ // IRegion expressionRegion = createRegion(expression, info.delta);
+ // IASTStatement body = ((IASTWhileStatement) node).getBody();
+ // IRegion bodyRegion = createRegion(body, info.delta);
+ //
+ // // Between expression and body statement
+ // if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
+ // return body != null;
+ // }
+ // } else if (node instanceof IASTDoStatement) {
+ // IASTDoStatement doStatement = (IASTDoStatement) node;
+ // IRegion doRegion = createRegion(doStatement, info.delta);
+ // IASTStatement body = doStatement.getBody();
+ // IRegion bodyRegion = createRegion(body, info.delta);
+ //
+ // // Between 'do' and body statement.
+ // if (doRegion.getOffset() + doRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
+ // return body != null;
+ // }
+ // }
+ //
+ // return true;
}
- private boolean isLineDelimiter(IDocument document, String text) {
+ private boolean isLineDelimiter(IDocument document, String text) {
String[] delimiters = document.getLegalLineDelimiters();
if (delimiters != null)
return TextUtilities.equals(delimiters, text) > -1;
@@ -528,15 +530,10 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
* @param document the document
*/
private static void installCPartitioner(Document document) {
- String[] types= new String[] {
- ICPartitions.C_MULTI_LINE_COMMENT,
- ICPartitions.C_SINGLE_LINE_COMMENT,
- ICPartitions.C_STRING,
- ICPartitions.C_CHARACTER,
- ICPartitions.C_PREPROCESSOR,
- IDocument.DEFAULT_CONTENT_TYPE
- };
- FastPartitioner partitioner= new FastPartitioner(new FastCPartitionScanner(), types);
+ String[] types = new String[] { ICPartitions.C_MULTI_LINE_COMMENT, ICPartitions.C_SINGLE_LINE_COMMENT,
+ ICPartitions.C_STRING, ICPartitions.C_CHARACTER, ICPartitions.C_PREPROCESSOR,
+ IDocument.DEFAULT_CONTENT_TYPE };
+ FastPartitioner partitioner = new FastPartitioner(new FastCPartitionScanner(), types);
partitioner.connect(document);
document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
}
@@ -549,85 +546,85 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
private static void removeCPartitioner(Document document) {
document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, null);
}
-
+
private void smartPaste(IDocument document, DocumentCommand command) {
- int newOffset= command.offset;
- int newLength= command.length;
- String newText= command.text;
+ int newOffset = command.offset;
+ int newLength = command.length;
+ String newText = command.text;
try {
- CHeuristicScanner scanner= new CHeuristicScanner(document);
- CIndenter indenter= new CIndenter(document, scanner, fProject);
- int offset= newOffset;
+ CHeuristicScanner scanner = new CHeuristicScanner(document);
+ CIndenter indenter = new CIndenter(document, scanner, fProject);
+ int offset = newOffset;
// reference position to get the indent from
- int refOffset= indenter.findReferencePosition(offset);
+ int refOffset = indenter.findReferencePosition(offset);
if (refOffset == CHeuristicScanner.NOT_FOUND)
return;
- int peerOffset= getPeerPosition(document, command);
- peerOffset= indenter.findReferencePosition(peerOffset);
+ int peerOffset = getPeerPosition(document, command);
+ peerOffset = indenter.findReferencePosition(peerOffset);
if (peerOffset == CHeuristicScanner.NOT_FOUND)
return;
- refOffset= Math.min(refOffset, peerOffset);
+ refOffset = Math.min(refOffset, peerOffset);
// eat any WS before the insertion to the beginning of the line
- int firstLine= 1; // don't format the first line per default, as it has other content before it
- IRegion line= document.getLineInformationOfOffset(offset);
- String notSelected= document.get(line.getOffset(), offset - line.getOffset());
+ int firstLine = 1; // don't format the first line per default, as it has other content before it
+ IRegion line = document.getLineInformationOfOffset(offset);
+ String notSelected = document.get(line.getOffset(), offset - line.getOffset());
if (notSelected.trim().length() == 0) {
newLength += notSelected.length();
- newOffset= line.getOffset();
- firstLine= 0;
+ newOffset = line.getOffset();
+ firstLine = 0;
}
// Prefix: the part we need for formatting but won't paste.
// Take up to 100 previous lines to preserve enough context.
- int firstPrefixLine= Math.max(document.getLineOfOffset(refOffset) - 100, 0);
- int prefixOffset= document.getLineInformation(firstPrefixLine).getOffset();
- String prefix= document.get(prefixOffset, newOffset - prefixOffset);
+ int firstPrefixLine = Math.max(document.getLineOfOffset(refOffset) - 100, 0);
+ int prefixOffset = document.getLineInformation(firstPrefixLine).getOffset();
+ String prefix = document.get(prefixOffset, newOffset - prefixOffset);
// Handle the indentation computation inside a temporary document
- Document temp= new Document(prefix + newText);
- DocumentRewriteSession session= temp.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
- scanner= new CHeuristicScanner(temp);
- indenter= new CIndenter(temp, scanner, fProject);
+ Document temp = new Document(prefix + newText);
+ DocumentRewriteSession session = temp.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
+ scanner = new CHeuristicScanner(temp);
+ indenter = new CIndenter(temp, scanner, fProject);
installCPartitioner(temp);
// Indent the first and second line
// compute the relative indentation difference from the second line
// (as the first might be partially selected) and use the value to
// indent all other lines.
- boolean isIndentDetected= false;
- StringBuilder addition= new StringBuilder();
- int insertLength= 0;
- int first= document.computeNumberOfLines(prefix) + firstLine; // don't format first line
- int lines= temp.getNumberOfLines();
- boolean changed= false;
- boolean indentInsideLineComments= IndentUtil.indentInsideLineComments(fProject);
-
- for (int l= first; l < lines; l++) { // we don't change the number of lines while adding indents
- IRegion r= temp.getLineInformation(l);
- int lineOffset= r.getOffset();
- int lineLength= r.getLength();
+ boolean isIndentDetected = false;
+ StringBuilder addition = new StringBuilder();
+ int insertLength = 0;
+ int first = document.computeNumberOfLines(prefix) + firstLine; // don't format first line
+ int lines = temp.getNumberOfLines();
+ boolean changed = false;
+ boolean indentInsideLineComments = IndentUtil.indentInsideLineComments(fProject);
+
+ for (int l = first; l < lines; l++) { // we don't change the number of lines while adding indents
+ IRegion r = temp.getLineInformation(l);
+ int lineOffset = r.getOffset();
+ int lineLength = r.getLength();
if (lineLength == 0) // don't modify empty lines
continue;
if (!isIndentDetected) {
// indent the first pasted line
- String current= IndentUtil.getCurrentIndent(temp, l, indentInsideLineComments);
- StringBuilder correct= new StringBuilder(IndentUtil.computeIndent(temp, l, indenter, scanner));
+ String current = IndentUtil.getCurrentIndent(temp, l, indentInsideLineComments);
+ StringBuilder correct = new StringBuilder(IndentUtil.computeIndent(temp, l, indenter, scanner));
- insertLength= subtractIndent(correct, current, addition);
+ insertLength = subtractIndent(correct, current, addition);
// workaround for bug 181139
if (/*l != first && */temp.get(lineOffset, lineLength).trim().length() != 0) {
- isIndentDetected= true;
+ isIndentDetected = true;
if (insertLength == 0) {
- // no adjustment needed, bail out
+ // no adjustment needed, bail out
if (firstLine == 0) {
// but we still need to adjust the first line
- command.offset= newOffset;
- command.length= newLength;
+ command.offset = newOffset;
+ command.length = newLength;
if (changed)
break; // still need to get the leading indent of the first line
}
@@ -635,7 +632,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
}
removeCPartitioner(temp);
} else {
- changed= insertLength != 0;
+ changed = insertLength != 0;
}
}
@@ -647,11 +644,11 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
}
temp.stopRewriteSession(session);
- newText= temp.get(prefix.length(), temp.getLength() - prefix.length());
+ newText = temp.get(prefix.length(), temp.getLength() - prefix.length());
- command.offset= newOffset;
- command.length= newLength;
- command.text= newText;
+ command.offset = newOffset;
+ command.length = newLength;
+ command.text = newText;
} catch (BadLocationException e) {
CUIPlugin.log(e);
}
@@ -668,16 +665,16 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
* @return the difference in lenght of <code>correct</code> and <code>current</code>
*/
private int subtractIndent(CharSequence correct, CharSequence current, StringBuilder difference) {
- int c1= computeVisualLength(correct);
- int c2= computeVisualLength(current);
- int diff= c1 - c2;
+ int c1 = computeVisualLength(correct);
+ int c2 = computeVisualLength(current);
+ int diff = c1 - c2;
if (diff <= 0)
return diff;
difference.setLength(0);
- int len= 0, i= 0;
+ int len = 0, i = 0;
while (len < diff) {
- char c= correct.charAt(i++);
+ char c = correct.charAt(i++);
difference.append(c);
len += computeVisualLength(c);
}
@@ -695,10 +692,11 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
* @param indentInsideLineComments option whether to indent inside line comments starting at column 0
* @throws BadLocationException on concurrent document modification
*/
- private static void addIndent(Document document, int line, CharSequence indent, boolean indentInsideLineComments) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- int insert= region.getOffset();
- int endOffset= region.getOffset() + region.getLength();
+ private static void addIndent(Document document, int line, CharSequence indent, boolean indentInsideLineComments)
+ throws BadLocationException {
+ IRegion region = document.getLineInformation(line);
+ int insert = region.getOffset();
+ int endOffset = region.getOffset() + region.getLength();
if (indentInsideLineComments) {
// go behind line comments
@@ -721,10 +719,11 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
* @param indentInsideLineComments option whether to indent inside line comments starting at column 0
* @throws BadLocationException on concurrent document modification
*/
- private void cutIndent(Document document, int line, int toDelete, boolean indentInsideLineComments) throws BadLocationException {
- IRegion region= document.getLineInformation(line);
- int from= region.getOffset();
- int endOffset= region.getOffset() + region.getLength();
+ private void cutIndent(Document document, int line, int toDelete, boolean indentInsideLineComments)
+ throws BadLocationException {
+ IRegion region = document.getLineInformation(line);
+ int from = region.getOffset();
+ int endOffset = region.getOffset() + region.getLength();
if (indentInsideLineComments) {
// go behind line comments
@@ -732,9 +731,9 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
from += 2;
}
- int to= from;
+ int to = from;
while (toDelete > 0 && to < endOffset) {
- char ch= document.getChar(to);
+ char ch = document.getChar(to);
if (!Character.isWhitespace(ch))
break;
toDelete -= computeVisualLength(ch);
@@ -755,11 +754,11 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
* @return the visual length of <code>seq</code>
*/
private int computeVisualLength(CharSequence seq) {
- int size= 0;
- int tablen= getVisualTabLengthPreference();
+ int size = 0;
+ int tablen = getVisualTabLengthPreference();
- for (int i= 0; i < seq.length(); i++) {
- char ch= seq.charAt(i);
+ for (int i = 0; i < seq.length(); i++) {
+ char ch = seq.charAt(i);
if (ch == '\t') {
if (tablen != 0)
size += tablen - size % tablen;
@@ -796,20 +795,20 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
private int getPeerPosition(IDocument document, DocumentCommand command) {
if (document.getLength() == 0)
return 0;
- /*
- * Search for scope closers in the pasted text and find their opening peers
- * in the document.
- */
- Document pasted= new Document(command.text);
- installCPartitioner(pasted);
- int firstPeer= command.offset;
-
- CHeuristicScanner pScanner= new CHeuristicScanner(pasted);
- CHeuristicScanner dScanner= new CHeuristicScanner(document);
-
- // add scope relevant after context to peer search
- int afterToken= dScanner.nextToken(command.offset + command.length, CHeuristicScanner.UNBOUND);
- try {
+ /*
+ * Search for scope closers in the pasted text and find their opening peers
+ * in the document.
+ */
+ Document pasted = new Document(command.text);
+ installCPartitioner(pasted);
+ int firstPeer = command.offset;
+
+ CHeuristicScanner pScanner = new CHeuristicScanner(pasted);
+ CHeuristicScanner dScanner = new CHeuristicScanner(document);
+
+ // add scope relevant after context to peer search
+ int afterToken = dScanner.nextToken(command.offset + command.length, CHeuristicScanner.UNBOUND);
+ try {
switch (afterToken) {
case Symbols.TokenRBRACE:
pasted.replace(pasted.getLength(), 0, "}"); //$NON-NLS-1$
@@ -826,133 +825,131 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
Assert.isTrue(false);
}
- int pPos= 0; // paste text position (increasing from 0)
- int dPos= Math.max(0, command.offset - 1); // document position (decreasing from paste offset)
- while (true) {
- int token= pScanner.nextToken(pPos, CHeuristicScanner.UNBOUND);
- pPos= pScanner.getPosition();
- switch (token) {
- case Symbols.TokenLBRACE:
- case Symbols.TokenLBRACKET:
- case Symbols.TokenLPAREN:
- pPos= skipScope(pScanner, pPos, token);
- if (pPos == CHeuristicScanner.NOT_FOUND)
- return firstPeer;
- break; // closed scope -> keep searching
- case Symbols.TokenRBRACE:
- int peer= dScanner.findOpeningPeer(dPos, '{', '}');
- dPos= peer - 1;
- if (peer == CHeuristicScanner.NOT_FOUND)
- return firstPeer;
- firstPeer= peer;
- break; // keep searching
- case Symbols.TokenRBRACKET:
- peer= dScanner.findOpeningPeer(dPos, '[', ']');
- dPos= peer - 1;
- if (peer == CHeuristicScanner.NOT_FOUND)
- return firstPeer;
- firstPeer= peer;
- break; // keep searching
- case Symbols.TokenRPAREN:
- peer= dScanner.findOpeningPeer(dPos, '(', ')');
- dPos= peer - 1;
- if (peer == CHeuristicScanner.NOT_FOUND)
- return firstPeer;
- firstPeer= peer;
- break; // keep searching
-
- case Symbols.TokenCASE:
- case Symbols.TokenDEFAULT:
- {
- CIndenter indenter= new CIndenter(document, dScanner, fProject);
- peer= indenter.findReferencePosition(dPos, false, MatchMode.MATCH_CASE);
- if (peer == CHeuristicScanner.NOT_FOUND)
- return firstPeer;
- firstPeer= peer;
- }
- break; // keep searching
-
- case Symbols.TokenPUBLIC:
- case Symbols.TokenPROTECTED:
- case Symbols.TokenPRIVATE:
- {
- CIndenter indenter= new CIndenter(document, dScanner, fProject);
- peer= indenter.findReferencePosition(dPos, false, MatchMode.MATCH_ACCESS_SPECIFIER);
- if (peer == CHeuristicScanner.NOT_FOUND)
- return firstPeer;
- firstPeer= peer;
- }
- break; // keep searching
-
- case Symbols.TokenEOF:
- return firstPeer;
- default:
- // keep searching
- }
- }
- }
-
- /**
- * Skips the scope opened by <code>token</code> in <code>document</code>,
- * returns either the position of the
- * @param pos
- * @param token
- * @return the position after the scope
- */
- private static int skipScope(CHeuristicScanner scanner, int pos, int token) {
- int openToken= token;
- int closeToken;
- switch (token) {
- case Symbols.TokenLPAREN:
- closeToken= Symbols.TokenRPAREN;
- break;
- case Symbols.TokenLBRACKET:
- closeToken= Symbols.TokenRBRACKET;
- break;
- case Symbols.TokenLBRACE:
- closeToken= Symbols.TokenRBRACE;
- break;
- default:
- Assert.isTrue(false);
- return -1; // dummy
- }
-
- int depth= 1;
- int p= pos;
-
- while (true) {
- int tok= scanner.nextToken(p, CHeuristicScanner.UNBOUND);
- p= scanner.getPosition();
-
- if (tok == openToken) {
- depth++;
- } else if (tok == closeToken) {
- depth--;
- if (depth == 0)
- return p + 1;
- } else if (tok == Symbols.TokenEOF) {
- return CHeuristicScanner.NOT_FOUND;
- }
- }
- }
+ int pPos = 0; // paste text position (increasing from 0)
+ int dPos = Math.max(0, command.offset - 1); // document position (decreasing from paste offset)
+ while (true) {
+ int token = pScanner.nextToken(pPos, CHeuristicScanner.UNBOUND);
+ pPos = pScanner.getPosition();
+ switch (token) {
+ case Symbols.TokenLBRACE:
+ case Symbols.TokenLBRACKET:
+ case Symbols.TokenLPAREN:
+ pPos = skipScope(pScanner, pPos, token);
+ if (pPos == CHeuristicScanner.NOT_FOUND)
+ return firstPeer;
+ break; // closed scope -> keep searching
+ case Symbols.TokenRBRACE:
+ int peer = dScanner.findOpeningPeer(dPos, '{', '}');
+ dPos = peer - 1;
+ if (peer == CHeuristicScanner.NOT_FOUND)
+ return firstPeer;
+ firstPeer = peer;
+ break; // keep searching
+ case Symbols.TokenRBRACKET:
+ peer = dScanner.findOpeningPeer(dPos, '[', ']');
+ dPos = peer - 1;
+ if (peer == CHeuristicScanner.NOT_FOUND)
+ return firstPeer;
+ firstPeer = peer;
+ break; // keep searching
+ case Symbols.TokenRPAREN:
+ peer = dScanner.findOpeningPeer(dPos, '(', ')');
+ dPos = peer - 1;
+ if (peer == CHeuristicScanner.NOT_FOUND)
+ return firstPeer;
+ firstPeer = peer;
+ break; // keep searching
+
+ case Symbols.TokenCASE:
+ case Symbols.TokenDEFAULT: {
+ CIndenter indenter = new CIndenter(document, dScanner, fProject);
+ peer = indenter.findReferencePosition(dPos, false, MatchMode.MATCH_CASE);
+ if (peer == CHeuristicScanner.NOT_FOUND)
+ return firstPeer;
+ firstPeer = peer;
+ }
+ break; // keep searching
+
+ case Symbols.TokenPUBLIC:
+ case Symbols.TokenPROTECTED:
+ case Symbols.TokenPRIVATE: {
+ CIndenter indenter = new CIndenter(document, dScanner, fProject);
+ peer = indenter.findReferencePosition(dPos, false, MatchMode.MATCH_ACCESS_SPECIFIER);
+ if (peer == CHeuristicScanner.NOT_FOUND)
+ return firstPeer;
+ firstPeer = peer;
+ }
+ break; // keep searching
+
+ case Symbols.TokenEOF:
+ return firstPeer;
+ default:
+ // keep searching
+ }
+ }
+ }
+
+ /**
+ * Skips the scope opened by <code>token</code> in <code>document</code>,
+ * returns either the position of the
+ * @param pos
+ * @param token
+ * @return the position after the scope
+ */
+ private static int skipScope(CHeuristicScanner scanner, int pos, int token) {
+ int openToken = token;
+ int closeToken;
+ switch (token) {
+ case Symbols.TokenLPAREN:
+ closeToken = Symbols.TokenRPAREN;
+ break;
+ case Symbols.TokenLBRACKET:
+ closeToken = Symbols.TokenRBRACKET;
+ break;
+ case Symbols.TokenLBRACE:
+ closeToken = Symbols.TokenRBRACE;
+ break;
+ default:
+ Assert.isTrue(false);
+ return -1; // dummy
+ }
+
+ int depth = 1;
+ int p = pos;
+
+ while (true) {
+ int tok = scanner.nextToken(p, CHeuristicScanner.UNBOUND);
+ p = scanner.getPosition();
+
+ if (tok == openToken) {
+ depth++;
+ } else if (tok == closeToken) {
+ depth--;
+ if (depth == 0)
+ return p + 1;
+ } else if (tok == Symbols.TokenEOF) {
+ return CHeuristicScanner.NOT_FOUND;
+ }
+ }
+ }
private void smartIndentOnKeypress(IDocument document, DocumentCommand command) {
switch (command.text.charAt(0)) {
- case '}':
- smartIndentAfterClosingBracket(document, command);
- break;
- case '{':
- smartIndentAfterOpeningBracket(document, command);
- break;
- case 'e':
- smartIndentUponE(document, command);
- break;
- case ':':
- smartIndentAfterColumn(document, command);
- break;
- case '#':
- smartIndentAfterHash(document, command);
- break;
+ case '}':
+ smartIndentAfterClosingBracket(document, command);
+ break;
+ case '{':
+ smartIndentAfterOpeningBracket(document, command);
+ break;
+ case 'e':
+ smartIndentUponE(document, command);
+ break;
+ case ':':
+ smartIndentAfterColumn(document, command);
+ break;
+ case '#':
+ smartIndentAfterHash(document, command);
+ break;
}
}
@@ -1056,22 +1053,22 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
CHeuristicScanner scanner = new CHeuristicScanner(doc);
int prevToken = scanner.previousToken(offset - 1, lineOffset);
switch (prevToken) {
- case Symbols.TokenDEFAULT:
- case Symbols.TokenPUBLIC:
- case Symbols.TokenPROTECTED:
- case Symbols.TokenPRIVATE:
- break;
-
- default:
- return;
+ case Symbols.TokenDEFAULT:
+ case Symbols.TokenPUBLIC:
+ case Symbols.TokenPROTECTED:
+ case Symbols.TokenPRIVATE:
+ break;
+
+ default:
+ return;
}
-
+
int p = scanner.getPosition() + 1;
// Make sure we don't have any leading comments etc.
if (doc.get(lineOffset, p - lineOffset).trim().length() != 0)
return;
-
+
// Line of last C code
int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
if (pos == -1)
@@ -1091,9 +1088,9 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
int refLine = doc.getLineOfOffset(ref);
int nextToken = scanner.nextToken(ref, CHeuristicScanner.UNBOUND);
String indent;
- if (nextToken == Symbols.TokenCASE || nextToken == Symbols.TokenDEFAULT ||
- nextToken == Symbols.TokenPUBLIC || nextToken == Symbols.TokenPROTECTED ||
- nextToken == Symbols.TokenPRIVATE) {
+ if (nextToken == Symbols.TokenCASE || nextToken == Symbols.TokenDEFAULT
+ || nextToken == Symbols.TokenPUBLIC || nextToken == Symbols.TokenPROTECTED
+ || nextToken == Symbols.TokenPRIVATE) {
indent = getIndentOfLine(doc, refLine);
} else { // at the brace of the switch or the class
indent = indenter.computeIndentation(p).toString();
@@ -1114,10 +1111,10 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
private void smartIndentAfterHash(IDocument doc, DocumentCommand c) {
try {
- ITypedRegion partition= TextUtilities.getPartition(doc, fPartitioning, c.offset, false);
+ ITypedRegion partition = TextUtilities.getPartition(doc, fPartitioning, c.offset, false);
if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
- IRegion startLine= doc.getLineInformationOfOffset(c.offset);
- String indent= doc.get(startLine.getOffset(), c.offset - startLine.getOffset());
+ IRegion startLine = doc.getLineInformationOfOffset(c.offset);
+ String indent = doc.get(startLine.getOffset(), c.offset - startLine.getOffset());
if (indent.trim().length() == 0) {
c.offset -= indent.length();
c.length += indent.length();
@@ -1138,14 +1135,13 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
super.customizeDocumentCommand(d, c);
return;
}
-
- boolean isNewLine= c.length == 0 && c.text != null && isLineDelimiter(d, c.text);
+
+ boolean isNewLine = c.length == 0 && c.text != null && isLineDelimiter(d, c.text);
if (isNewLine) {
smartIndentAfterNewLine(d, c);
} else if (c.text.length() == 1 && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_AUTO_INDENT)) {
smartIndentOnKeypress(d, c);
- } else if (c.text.length() > 1
- && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_PASTE)
+ } else if (c.text.length() > 1 && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_PASTE)
&& c.text.trim().length() != 0) {
smartPaste(d, c); // no smart backspace for paste
}
@@ -1156,20 +1152,20 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
}
private void clearCachedValues() {
- IPreferenceStore preferenceStore = getPreferenceStore();
+ IPreferenceStore preferenceStore = getPreferenceStore();
fCloseBrace = preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACES);
fIsSmartMode = computeSmartMode();
}
private boolean computeSmartMode() {
IWorkbenchPage page = CUIPlugin.getActivePage();
- if (page != null) {
+ if (page != null) {
if (alwaysUseSmartMode) {
return true;
}
IEditorPart part = page.getActiveEditor();
if (part instanceof MultiPageEditorPart) {
- part= (IEditorPart)part.getAdapter(ITextEditorExtension3.class);
+ part = (IEditorPart) part.getAdapter(ITextEditorExtension3.class);
}
if (part instanceof ITextEditorExtension3) {
ITextEditorExtension3 extension = (ITextEditorExtension3) part;
@@ -1183,29 +1179,29 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
return false;
}
-// private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset, String partitioning) {
-// try {
-// CHeuristicScanner scanner = new CHeuristicScanner(document);
-//
-// IRegion sourceRange = scanner.findSurroundingBlock(offset);
-// if (sourceRange == null)
-// return null;
-// String source = document.get(sourceRange.getOffset(), sourceRange.getLength());
-//
-// StringBuilder contents = new StringBuilder();
-// contents.append("class ____C{void ____m()"); //$NON-NLS-1$
-// final int methodOffset = contents.length();
-// contents.append(source);
-// contents.append("};"); //$NON-NLS-1$
-//
-// char[] buffer = contents.toString().toCharArray();
-// return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset);
-// } catch (BadLocationException e) {
-// CUIPlugin.log(e);
-// }
-//
-// return null;
-// }
+ // private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset, String partitioning) {
+ // try {
+ // CHeuristicScanner scanner = new CHeuristicScanner(document);
+ //
+ // IRegion sourceRange = scanner.findSurroundingBlock(offset);
+ // if (sourceRange == null)
+ // return null;
+ // String source = document.get(sourceRange.getOffset(), sourceRange.getLength());
+ //
+ // StringBuilder contents = new StringBuilder();
+ // contents.append("class ____C{void ____m()"); //$NON-NLS-1$
+ // final int methodOffset = contents.length();
+ // contents.append(source);
+ // contents.append("};"); //$NON-NLS-1$
+ //
+ // char[] buffer = contents.toString().toCharArray();
+ // return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset);
+ // } catch (BadLocationException e) {
+ // CUIPlugin.log(e);
+ // }
+ //
+ // return null;
+ // }
/**
* Returns the block balance, i.e. zero if the blocks are balanced at
@@ -1240,8 +1236,8 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
}
}
-// private static IRegion createRegion(IASTNode node, int delta) {
-// IASTNodeLocation nodeLocation = node.getNodeLocations()[0];
-// return node == null ? null : new Region(nodeLocation.getNodeOffset() + delta, nodeLocation.getNodeLength());
-// }
+ // private static IRegion createRegion(IASTNode node, int delta) {
+ // IASTNodeLocation nodeLocation = node.getNodeLocations()[0];
+ // return node == null ? null : new Region(nodeLocation.getNodeOffset() + delta, nodeLocation.getNodeLength());
+ // }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBraceRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBraceRule.java
index 904164c9e04..67182795c98 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBraceRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBraceRule.java
@@ -20,26 +20,22 @@ import org.eclipse.jface.text.rules.IToken;
*
* @author P.Tomaszewski
*/
-public class CBraceRule extends SingleCharRule
-{
+public class CBraceRule extends SingleCharRule {
- /**
- * Creates new rule.
- * @param token Style token.
- */
- public CBraceRule(IToken token)
- {
- super(token);
- }
+ /**
+ * Creates new rule.
+ * @param token Style token.
+ */
+ public CBraceRule(IToken token) {
+ super(token);
+ }
- /**
- * @see org.eclipse.cdt.internal.ui.text.SingleCharRule#isRuleChar(int)
- */
- @Override
- protected boolean isRuleChar(int ch)
- {
- return ch == '{' || ch == '}' || ch == '[' || ch == ']' || ch == '(' || ch == ')';
- }
+ /**
+ * @see org.eclipse.cdt.internal.ui.text.SingleCharRule#isRuleChar(int)
+ */
+ @Override
+ protected boolean isRuleChar(int ch) {
+ return ch == '{' || ch == '}' || ch == '[' || ch == ']' || ch == '(' || ch == ')';
+ }
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java
index c8f7403d80f..a6652fcde03 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.Assert;
import com.ibm.icu.text.BreakIterator;
-
/**
* A C break iterator. It returns all breaks, including before and after
* whitespace, and it returns all camel case breaks.
@@ -72,7 +71,7 @@ public class CBreakIterator extends BreakIterator {
* Resets this run to the initial state.
*/
protected void init() {
- length= 0;
+ length = 0;
}
}
@@ -86,8 +85,8 @@ public class CBreakIterator 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';
/*
* @see org.eclipse.cdt.internal.ui.text.CBreakIterator.Run#init()
@@ -95,7 +94,7 @@ public class CBreakIterator extends BreakIterator {
@Override
protected void init() {
super.init();
- fState= INIT;
+ fState = INIT;
}
/*
@@ -107,11 +106,11 @@ public class CBreakIterator 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 {
@@ -137,30 +136,30 @@ public class CBreakIterator 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_UNDERSCORE= 4;
- private static final int S_EXIT= 5;
- private static final int S_EXIT_MINUS_ONE= 6;
+ 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_UNDERSCORE = 4;
+ private static final int S_EXIT = 5;
+ private static final int S_EXIT_MINUS_ONE = 6;
/* 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_UNDERSCORE= 3;
- private static final int K_OTHER= 4;
+ 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_UNDERSCORE = 3;
+ private static final int K_OTHER = 4;
private int fState;
- private static final int[][] MATRIX= new int[][] {
+ private static final int[][] MATRIX = new int[][] {
// K_INVALID, K_LOWER, K_UPPER, K_UNDERSCORE, K_OTHER
- { S_EXIT, S_LOWER, S_ONE_CAP, S_UNDERSCORE, S_LOWER }, // S_INIT
- { S_EXIT, S_LOWER, S_EXIT, S_UNDERSCORE, S_LOWER }, // S_LOWER
- { S_EXIT, S_LOWER, S_ALL_CAPS, S_UNDERSCORE, S_LOWER }, // S_ONE_CAP
- { S_EXIT, S_EXIT_MINUS_ONE, S_ALL_CAPS, S_UNDERSCORE, S_LOWER }, // S_ALL_CAPS
- { S_EXIT, S_EXIT, S_EXIT, S_UNDERSCORE, S_EXIT }, // S_UNDERSCORE
+ { S_EXIT, S_LOWER, S_ONE_CAP, S_UNDERSCORE, S_LOWER }, // S_INIT
+ { S_EXIT, S_LOWER, S_EXIT, S_UNDERSCORE, S_LOWER }, // S_LOWER
+ { S_EXIT, S_LOWER, S_ALL_CAPS, S_UNDERSCORE, S_LOWER }, // S_ONE_CAP
+ { S_EXIT, S_EXIT_MINUS_ONE, S_ALL_CAPS, S_UNDERSCORE, S_LOWER }, // S_ALL_CAPS
+ { S_EXIT, S_EXIT, S_EXIT, S_UNDERSCORE, S_EXIT }, // S_UNDERSCORE
};
/*
@@ -169,7 +168,7 @@ public class CBreakIterator extends BreakIterator {
@Override
protected void init() {
super.init();
- fState= S_INIT;
+ fState = S_INIT;
}
/*
@@ -177,23 +176,23 @@ public class CBreakIterator extends BreakIterator {
*/
@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:
- case S_UNDERSCORE:
- 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:
+ case S_UNDERSCORE:
+ length++;
+ return true;
+ case S_EXIT:
+ return false;
+ case S_EXIT_MINUS_ONE:
+ length--;
+ return false;
+ default:
+ Assert.isTrue(false);
+ return false;
}
}
@@ -233,11 +232,11 @@ public class CBreakIterator extends BreakIterator {
}
}
- private static final Run WHITESPACE= new Whitespace();
- private static final Run DELIMITER= new LineDelimiter();
- private static final Run IDENTIFIER= new Identifier();
- private static final Run CAMELCASE= new CamelCaseIdentifier();
- 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 IDENTIFIER = new Identifier();
+ private static final Run CAMELCASE = new CamelCaseIdentifier();
+ private static final Run OTHER = new Other();
/** The platform break iterator (word instance) used as a base. */
protected final BreakIterator fIterator;
@@ -248,13 +247,12 @@ public class CBreakIterator extends BreakIterator {
/** Break on camel case word boundaries */
private boolean fCamelCaseBreakEnabled = true;
-
/**
* Creates a new break iterator.
*/
public CBreakIterator() {
- fIterator= BreakIterator.getWordInstance();
- fIndex= fIterator.current();
+ fIterator = BreakIterator.getWordInstance();
+ fIndex = fIterator.current();
}
/*
@@ -270,7 +268,7 @@ public class CBreakIterator extends BreakIterator {
*/
@Override
public int first() {
- fIndex= fIterator.first();
+ fIndex = fIterator.first();
return fIndex;
}
@@ -283,7 +281,7 @@ public class CBreakIterator extends BreakIterator {
if (offset == getText().getEndIndex())
return DONE;
- int next= fIterator.following(offset);
+ int next = fIterator.following(offset);
if (next == DONE)
return DONE;
@@ -291,7 +289,7 @@ public class CBreakIterator 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;
}
@@ -304,12 +302,12 @@ public class CBreakIterator extends BreakIterator {
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;
@@ -324,17 +322,16 @@ public class CBreakIterator extends BreakIterator {
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 (IDENTIFIER.isValid(ch)) {
if (fCamelCaseBreakEnabled)
- run= CAMELCASE;
+ run = CAMELCASE;
else
- run= IDENTIFIER;
- }
- else if (OTHER.isValid(ch))
- run= OTHER;
+ run = IDENTIFIER;
+ } else if (OTHER.isValid(ch))
+ run = OTHER;
else {
Assert.isTrue(false);
return null;
@@ -357,8 +354,8 @@ public class CBreakIterator extends BreakIterator {
*/
@Override
public boolean isBoundary(int offset) {
- if (offset == getText().getBeginIndex())
- return true;
+ if (offset == getText().getBeginIndex())
+ return true;
return following(offset - 1) == offset;
}
@@ -367,7 +364,7 @@ public class CBreakIterator extends BreakIterator {
*/
@Override
public int last() {
- fIndex= fIterator.last();
+ fIndex = fIterator.last();
return fIndex;
}
@@ -376,7 +373,7 @@ public class CBreakIterator extends BreakIterator {
*/
@Override
public int next() {
- fIndex= following(fIndex);
+ fIndex = following(fIndex);
return fIndex;
}
@@ -399,15 +396,15 @@ public class CBreakIterator 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;
@@ -418,7 +415,7 @@ public class CBreakIterator extends BreakIterator {
*/
@Override
public int previous() {
- fIndex= preceding(fIndex);
+ fIndex = preceding(fIndex);
return fIndex;
}
@@ -435,7 +432,7 @@ public class CBreakIterator extends BreakIterator {
* @param newText the new text
*/
public void setText(CharSequence newText) {
- fText= newText;
+ fText = newText;
fIterator.setText(new SequenceCharacterIterator(newText));
first();
}
@@ -446,7 +443,7 @@ public class CBreakIterator extends BreakIterator {
@Override
public void setText(CharacterIterator newText) {
if (newText instanceof CharSequence) {
- fText= (CharSequence) newText;
+ fText = (CharSequence) newText;
fIterator.setText(newText);
first();
} else {
@@ -456,7 +453,7 @@ public class CBreakIterator extends BreakIterator {
/**
* Enables breaks at word boundaries inside a camel case identifier.
- *
+ *
* @param camelCaseBreakEnabled <code>true</code> to enable, <code>false</code> to disable.
*/
public void setCamelCaseBreakEnabled(boolean camelCaseBreakEnabled) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java
index ed6f7622413..1a53aad61f9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java
@@ -24,64 +24,65 @@ import org.eclipse.jface.text.IDocument;
* skip comments and strings.
*/
public class CCodeReader extends SingleCharReader {
-
+
/** The EOF character */
- public static final int EOF= -1;
-
- private boolean fSkipComments= false;
- private boolean fSkipStrings= false;
- private boolean fForward= false;
-
+ public static final int EOF = -1;
+
+ private boolean fSkipComments = false;
+ private boolean fSkipStrings = false;
+ private boolean fForward = false;
+
private IDocument fDocument;
private int fOffset;
-
- private int fEnd= -1;
- private int fCachedLineNumber= -1;
- private int fCachedLineOffset= -1;
-
-
+
+ private int fEnd = -1;
+ private int fCachedLineNumber = -1;
+ private int fCachedLineOffset = -1;
+
public CCodeReader() {
}
-
+
/**
* Returns the offset of the last read character. Should only be called after read has been called.
*/
public int getOffset() {
- return fForward ? fOffset -1 : fOffset;
+ return fForward ? fOffset - 1 : fOffset;
}
-
- public void configureForwardReader(IDocument document, int offset, int length, boolean skipComments, boolean skipStrings) throws IOException {
- fDocument= document;
- fOffset= offset;
- fSkipComments= skipComments;
- fSkipStrings= skipStrings;
-
- fForward= true;
- fEnd= Math.min(fDocument.getLength(), fOffset + length);
+
+ public void configureForwardReader(IDocument document, int offset, int length, boolean skipComments,
+ boolean skipStrings) throws IOException {
+ fDocument = document;
+ fOffset = offset;
+ fSkipComments = skipComments;
+ fSkipStrings = skipStrings;
+
+ fForward = true;
+ fEnd = Math.min(fDocument.getLength(), fOffset + length);
}
-
- public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings) throws IOException {
- fDocument= document;
- fOffset= offset;
- fSkipComments= skipComments;
- fSkipStrings= skipStrings;
-
- fForward= false;
+
+ public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings)
+ throws IOException {
+ fDocument = document;
+ fOffset = offset;
+ fSkipComments = skipComments;
+ fSkipStrings = skipStrings;
+
+ fForward = false;
try {
- fCachedLineNumber= fDocument.getLineOfOffset(fOffset);
+ fCachedLineNumber = fDocument.getLineOfOffset(fOffset);
} catch (BadLocationException x) {
throw new IOException(x.getMessage());
}
}
-
+
/*
* @see Reader#close()
*/
@Override
public void close() throws IOException {
- fDocument= null;
+ fDocument = null;
}
-
+
/*
* @see SingleCharReader#read()
*/
@@ -93,149 +94,149 @@ public class CCodeReader extends SingleCharReader {
throw new IOException(x.getMessage());
}
}
-
+
private void gotoCommentEnd() throws BadLocationException {
while (fOffset < fEnd) {
- char current= fDocument.getChar(fOffset++);
+ char current = fDocument.getChar(fOffset++);
if (current == '*') {
if (fOffset < fEnd && fDocument.getChar(fOffset) == '/') {
- ++ fOffset;
+ ++fOffset;
return;
}
}
}
}
-
+
private void gotoStringEnd(char delimiter) throws BadLocationException {
while (fOffset < fEnd) {
- char current= fDocument.getChar(fOffset++);
+ char current = fDocument.getChar(fOffset++);
if (current == '\\') {
// ignore escaped characters
- ++ fOffset;
+ ++fOffset;
} else if (current == delimiter) {
return;
}
}
}
-
+
private void gotoLineEnd() throws BadLocationException {
- int line= fDocument.getLineOfOffset(fOffset);
- fOffset= fDocument.getLineOffset(line + 1);
+ int line = fDocument.getLineOfOffset(fOffset);
+ fOffset = fDocument.getLineOffset(line + 1);
}
-
+
private int readForwards() throws BadLocationException {
while (fOffset < fEnd) {
- char current= fDocument.getChar(fOffset++);
-
+ char current = fDocument.getChar(fOffset++);
+
switch (current) {
- case '/':
-
- if (fSkipComments && fOffset < fEnd) {
- char next= fDocument.getChar(fOffset);
- if (next == '*') {
- // a comment starts, advance to the comment end
- ++ fOffset;
- gotoCommentEnd();
- continue;
- } else if (next == '/') {
- // '//'-comment starts, advance to the line end
- gotoLineEnd();
- continue;
- }
- }
-
- return current;
-
- case '"':
- case '\'':
-
- if (fSkipStrings) {
- gotoStringEnd(current);
+ case '/':
+
+ if (fSkipComments && fOffset < fEnd) {
+ char next = fDocument.getChar(fOffset);
+ if (next == '*') {
+ // a comment starts, advance to the comment end
+ ++fOffset;
+ gotoCommentEnd();
+ continue;
+ } else if (next == '/') {
+ // '//'-comment starts, advance to the line end
+ gotoLineEnd();
continue;
}
-
- return current;
+ }
+
+ return current;
+
+ case '"':
+ case '\'':
+
+ if (fSkipStrings) {
+ gotoStringEnd(current);
+ continue;
+ }
+
+ return current;
}
-
+
return current;
}
-
+
return EOF;
}
-
+
private void handleSingleLineComment() throws BadLocationException {
- int line= fDocument.getLineOfOffset(fOffset);
+ int line = fDocument.getLineOfOffset(fOffset);
if (line < fCachedLineNumber) {
- fCachedLineNumber= line;
- fCachedLineOffset= fDocument.getLineOffset(line);
- int offset= fOffset;
+ fCachedLineNumber = line;
+ fCachedLineOffset = fDocument.getLineOffset(line);
+ int offset = fOffset;
while (fCachedLineOffset < offset) {
- char current= fDocument.getChar(offset--);
+ char current = fDocument.getChar(offset--);
if (current == '/' && fCachedLineOffset <= offset && fDocument.getChar(offset) == '/') {
- fOffset= offset;
+ fOffset = offset;
return;
}
}
}
}
-
+
private void gotoCommentStart() throws BadLocationException {
while (0 < fOffset) {
- char current= fDocument.getChar(fOffset--);
+ char current = fDocument.getChar(fOffset--);
if (current == '*' && 0 <= fOffset && fDocument.getChar(fOffset) == '/')
return;
}
}
-
+
private void gotoStringStart(char delimiter) throws BadLocationException {
while (0 < fOffset) {
- char current= fDocument.getChar(fOffset);
+ char current = fDocument.getChar(fOffset);
if (current == delimiter) {
- if ( !(0 <= fOffset && fDocument.getChar(fOffset -1) == '\\'))
+ if (!(0 <= fOffset && fDocument.getChar(fOffset - 1) == '\\'))
return;
}
- -- fOffset;
+ --fOffset;
}
}
-
+
private int readBackwards() throws BadLocationException {
-
+
while (0 < fOffset) {
- -- fOffset;
-
+ --fOffset;
+
handleSingleLineComment();
-
- char current= fDocument.getChar(fOffset);
+
+ char current = fDocument.getChar(fOffset);
switch (current) {
- case '/':
-
- if (fSkipComments && fOffset > 1) {
- char next= fDocument.getChar(fOffset - 1);
- if (next == '*') {
- // a comment ends, advance to the comment start
- fOffset -= 2;
- gotoCommentStart();
- continue;
- }
- }
-
- return current;
-
- case '"':
- case '\'':
-
- if (fSkipStrings) {
- -- fOffset;
- gotoStringStart(current);
+ case '/':
+
+ if (fSkipComments && fOffset > 1) {
+ char next = fDocument.getChar(fOffset - 1);
+ if (next == '*') {
+ // a comment ends, advance to the comment start
+ fOffset -= 2;
+ gotoCommentStart();
continue;
}
-
- return current;
+ }
+
+ return current;
+
+ case '"':
+ case '\'':
+
+ if (fSkipStrings) {
+ --fOffset;
+ gotoStringStart(current);
+ continue;
+ }
+
+ return current;
}
-
+
return current;
}
-
+
return EOF;
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
index 71aec8d055d..98d39bc0b9d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -30,74 +30,68 @@ import org.eclipse.cdt.ui.text.ITokenStoreFactory;
import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
-
/**
* A C/C++ code scanner.
*/
public final class CCodeScanner extends AbstractCScanner {
-
- /** Properties for tokens. */
- private static String[] fgTokenProperties= {
- ICColorConstants.C_KEYWORD,
- ICColorConstants.C_TYPE,
- ICColorConstants.C_OPERATOR,
- ICColorConstants.C_BRACES,
- ICColorConstants.C_NUMBER,
- ICColorConstants.C_DEFAULT,
- };
+
+ /** Properties for tokens. */
+ private static String[] fgTokenProperties = { ICColorConstants.C_KEYWORD, ICColorConstants.C_TYPE,
+ ICColorConstants.C_OPERATOR, ICColorConstants.C_BRACES, ICColorConstants.C_NUMBER,
+ ICColorConstants.C_DEFAULT, };
private ICLanguageKeywords fKeywords;
/**
* Creates a C/C++ code scanner.
- * @param factory
- * @param keywords the keywords defined by the language dialect
+ * @param factory
+ * @param keywords the keywords defined by the language dialect
*/
public CCodeScanner(ITokenStoreFactory factory, ICLanguageKeywords keywords) {
super(factory.createTokenStore(fgTokenProperties));
- fKeywords= keywords;
+ fKeywords = keywords;
setRules(createRules());
}
-
+
/*
* @see AbstractCScanner#createRules()
*/
protected List<IRule> createRules() {
-
- List<IRule> rules= new ArrayList<IRule>();
+
+ List<IRule> rules = new ArrayList<IRule>();
IToken token;
-
- token= getToken(ICColorConstants.C_DEFAULT);
+
+ token = getToken(ICColorConstants.C_DEFAULT);
// Add generic white space rule.
rules.add(new CWhitespaceRule(token));
// Add word rule for keywords, types, and constants.
- WordRule wordRule= new WordRule(new CWordDetector(), token);
-
- token= getToken(ICColorConstants.C_KEYWORD);
- String[] keywords= fKeywords.getKeywords();
+ WordRule wordRule = new WordRule(new CWordDetector(), token);
+
+ token = getToken(ICColorConstants.C_KEYWORD);
+ String[] keywords = fKeywords.getKeywords();
for (int i = 0; i < keywords.length; i++) {
wordRule.addWord(keywords[i], token);
}
- token= getToken(ICColorConstants.C_TYPE);
- String[] types= fKeywords.getBuiltinTypes();
+ token = getToken(ICColorConstants.C_TYPE);
+ String[] types = fKeywords.getBuiltinTypes();
for (int i = 0; i < types.length; i++) {
wordRule.addWord(types[i], token);
}
- rules.add(wordRule);
-
- token = getToken(ICColorConstants.C_NUMBER);
- NumberRule numberRule = new NumberRule(token);
- rules.add(numberRule);
-
- token = getToken(ICColorConstants.C_OPERATOR);
- COperatorRule opRule = new COperatorRule(token);
- rules.add(opRule);
-
- token = getToken(ICColorConstants.C_BRACES);
- CBraceRule braceRule = new CBraceRule(token);
- rules.add(braceRule);
-
+ rules.add(wordRule);
+
+ token = getToken(ICColorConstants.C_NUMBER);
+ NumberRule numberRule = new NumberRule(token);
+ rules.add(numberRule);
+
+ token = getToken(ICColorConstants.C_OPERATOR);
+ COperatorRule opRule = new COperatorRule(token);
+ rules.add(opRule);
+
+ token = getToken(ICColorConstants.C_BRACES);
+ CBraceRule braceRule = new CBraceRule(token);
+ rules.add(braceRule);
+
setDefaultReturnToken(getToken(ICColorConstants.C_DEFAULT));
return rules;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java
index 6bc81713058..7b5c68bf925 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -30,22 +30,23 @@ import org.eclipse.cdt.ui.text.ITokenStoreFactory;
* task tags.
*/
public class CCommentScanner extends AbstractCScanner {
- private static String TASK_TAG_KEY= PreferenceConstants.EDITOR_TASK_TAG_COLOR;
-
+ private static String TASK_TAG_KEY = PreferenceConstants.EDITOR_TASK_TAG_COLOR;
+
public CCommentScanner(ITokenStoreFactory tokenStoreFactory, String defaultTokenProperty) {
this(tokenStoreFactory, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG_KEY });
}
- private CCommentScanner(ITokenStoreFactory tokenStoreFactory, String defaultTokenProperty, String[] tokenProperties) {
+ private CCommentScanner(ITokenStoreFactory tokenStoreFactory, String defaultTokenProperty,
+ String[] tokenProperties) {
super(tokenStoreFactory.createTokenStore(tokenProperties));
setRules(createRules(defaultTokenProperty));
}
- protected List<IRule> createRules(String defaultTokenProperty) {
- setDefaultReturnToken(getToken(defaultTokenProperty));
- IPreferenceStore store= fTokenStore.getPreferenceStore();
- TaskTagRule taskTagRule= new TaskTagRule(getToken(TASK_TAG_KEY), fDefaultReturnToken, store, null);
- addPropertyChangeParticipant(taskTagRule);
- return Collections.singletonList((IRule) taskTagRule);
- }
+ protected List<IRule> createRules(String defaultTokenProperty) {
+ setDefaultReturnToken(getToken(defaultTokenProperty));
+ IPreferenceStore store = fTokenStore.getPreferenceStore();
+ TaskTagRule taskTagRule = new TaskTagRule(getToken(TASK_TAG_KEY), fDefaultReturnToken, store, null);
+ addPropertyChangeParticipant(taskTagRule);
+ return Collections.singletonList((IRule) taskTagRule);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.java
index 2dba2b5a0f4..1dc1749c22c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.java
@@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.text.spelling.CSpellingReconcileStrategy;
* Reconciling strategy for C/C++ code. This is a composite strategy containing
* the regular C/C++ model reconciler and the comment spelling strategy.
*/
-public class CCompositeReconcilingStrategy extends CompositeReconcilingStrategy {
+public class CCompositeReconcilingStrategy extends CompositeReconcilingStrategy {
private ITextEditor fEditor;
private CReconcilingStrategy fCStrategy;
@@ -39,12 +39,10 @@ public class CCompositeReconcilingStrategy extends CompositeReconcilingStrategy
* @param documentPartitioning the document partitioning this strategy uses for configuration
*/
public CCompositeReconcilingStrategy(ISourceViewer viewer, ITextEditor editor, String documentPartitioning) {
- fEditor= editor;
- fCStrategy= new CReconcilingStrategy(editor);
- setReconcilingStrategies(new IReconcilingStrategy[] {
- fCStrategy,
- new CSpellingReconcileStrategy(viewer, editor)
- });
+ fEditor = editor;
+ fCStrategy = new CReconcilingStrategy(editor);
+ setReconcilingStrategies(
+ new IReconcilingStrategy[] { fCStrategy, new CSpellingReconcileStrategy(viewer, editor) });
}
/**
@@ -68,7 +66,7 @@ public class CCompositeReconcilingStrategy extends CompositeReconcilingStrategy
*/
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
- IProblemRequestorExtension e= getProblemRequestorExtension();
+ IProblemRequestorExtension e = getProblemRequestorExtension();
if (e != null) {
try {
e.beginReportingSequence();
@@ -86,7 +84,7 @@ public class CCompositeReconcilingStrategy extends CompositeReconcilingStrategy
*/
@Override
public void reconcile(IRegion partition) {
- IProblemRequestorExtension e= getProblemRequestorExtension();
+ IProblemRequestorExtension e = getProblemRequestorExtension();
if (e != null) {
try {
e.beginReportingSequence();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java
index adf6a7feabb..0b5fbb6e20c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java
@@ -25,8 +25,8 @@ import org.eclipse.jface.text.ITextViewer;
*/
public class CDoubleClickSelector implements ITextDoubleClickStrategy {
- protected static char[] fgBrackets= {'{', '}', '(', ')', '[', ']', '<', '>'};
- private CPairMatcher fPairMatcher= new CPairMatcher(fgBrackets);
+ protected static char[] fgBrackets = { '{', '}', '(', ')', '[', ']', '<', '>' };
+ private CPairMatcher fPairMatcher = new CPairMatcher(fgBrackets);
public CDoubleClickSelector() {
super();
@@ -37,18 +37,18 @@ public class CDoubleClickSelector implements ITextDoubleClickStrategy {
*/
@Override
public void doubleClicked(ITextViewer textViewer) {
- int offset= textViewer.getSelectedRange().x;
+ int offset = textViewer.getSelectedRange().x;
if (offset < 0)
return;
- IDocument document= textViewer.getDocument();
+ IDocument document = textViewer.getDocument();
- IRegion region= fPairMatcher.match(document, offset);
+ IRegion region = fPairMatcher.match(document, offset);
if (region != null && region.getLength() >= 2) {
textViewer.setSelectedRange(region.getOffset() + 1, region.getLength() - 2);
} else {
- region= selectWord(document, offset);
+ region = selectWord(document, offset);
if (region != null && region.getLength() > 0) {
textViewer.setSelectedRange(region.getOffset(), region.getLength());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
index 18f96149bc1..43ed65e81da 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
@@ -48,11 +48,11 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
}
}
- private final Deque<WorkItem> fWorkItems= new ArrayDeque<>();
+ private final Deque<WorkItem> fWorkItems = new ArrayDeque<>();
/**
* Creates a new formatting strategy.
- */
+ */
public CFormattingStrategy() {
super();
}
@@ -62,19 +62,17 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
super.format();
WorkItem workItem = fWorkItems.getFirst();
- IDocument document= workItem.document;
- TypedPosition partition= workItem.partition;
-
+ IDocument document = workItem.document;
+ TypedPosition partition = workItem.partition;
+
if (document == null || partition == null)
return;
Map<String, String> preferences = getPreferences();
try {
- TextEdit edit = CodeFormatterUtil.format(
- CodeFormatter.K_TRANSLATION_UNIT, document.get(),
- partition.getOffset(), partition.getLength(), 0,
- TextUtilities.getDefaultLineDelimiter(document),
+ TextEdit edit = CodeFormatterUtil.format(CodeFormatter.K_TRANSLATION_UNIT, document.get(),
+ partition.getOffset(), partition.getLength(), 0, TextUtilities.getDefaultLineDelimiter(document),
preferences);
if (edit != null)
@@ -85,14 +83,14 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
// Can only happen on concurrent document modification - log and bail out.
CUIPlugin.log(e);
}
- }
+ }
@Override
public void formatterStarts(final IFormattingContext context) {
super.formatterStarts(context);
-
+
TypedPosition partition = (TypedPosition) context.getProperty(FormattingContextProperties.CONTEXT_PARTITION);
- IDocument document= (IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
+ IDocument document = (IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
fWorkItems.addLast(new WorkItem(document, partition));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java
index ecfe584d834..518c54b6bd5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java
@@ -31,7 +31,7 @@ public class CHeaderRule implements IRule {
/**
* Creates a new CHeaderRule.
- *
+ *
* @param token
* Style token.
*/
@@ -57,13 +57,13 @@ public class CHeaderRule implements IRule {
if (contentLength < 1) {
break;
}
-
+
// Rewind and check for an #include.
seek(scanner, -lookAhead);
if (!followsIncludeDirective(scanner)) {
return Token.UNDEFINED;
}
-
+
seek(scanner, lookAhead);
return fToken;
}
@@ -77,7 +77,7 @@ public class CHeaderRule implements IRule {
/**
* Repositions the scanner.
- *
+ *
* @param scanner
* Scanner.
* @param characters
@@ -101,7 +101,7 @@ public class CHeaderRule implements IRule {
/**
* Returns true if the previous contents of the scanner is an #include
* directive.
- *
+ *
* @param scanner
* Scanner.
* @return true if the previous contents of the scanner is an #include
@@ -121,7 +121,7 @@ public class CHeaderRule implements IRule {
}
scanner.read();
--lookBehind;
- if (current == 'e' && searchBackwards(scanner, "include") || //$NON-NLS-1$
+ if (current == 'e' && searchBackwards(scanner, "include") || //$NON-NLS-1$
current == 't' && searchBackwards(scanner, "include_next")) { //$NON-NLS-1$
result = true;
}
@@ -133,7 +133,7 @@ public class CHeaderRule implements IRule {
/**
* Returns true if the given String was the last String read from the
* scanner.
- *
+ *
* @param scanner
* Scanner.
* @param string
@@ -156,7 +156,7 @@ public class CHeaderRule implements IRule {
/**
* Unreads a single character from the scanner.
- *
+ *
* @param scanner
* Scanner.
* @return the last character read from the scanner.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java
index f6c3171185b..0d698730b2f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.internal.ui.text;
@@ -26,7 +26,7 @@ import org.w3c.dom.NodeList;
/**
* This class represents the CHelpBook settings
- *
+ *
* @since 2.1
*/
public class CHelpBookDescriptor {
@@ -38,99 +38,99 @@ public class CHelpBookDescriptor {
private boolean fEnabled = true;
private ICHelpBook fCHelpBook;
-
- CHelpBookDescriptor(ICHelpBook book){
- this(book,null);
+
+ CHelpBookDescriptor(ICHelpBook book) {
+ this(book, null);
}
- CHelpBookDescriptor(ICHelpBook book, Element parentElement){
+ CHelpBookDescriptor(ICHelpBook book, Element parentElement) {
fCHelpBook = book;
-
- if(parentElement == null)
+
+ if (parentElement == null)
return;
-
+
NodeList bookElements = parentElement.getElementsByTagName(ELEMENT_BOOK);
- if(bookElements.getLength() == 0)
+ if (bookElements.getLength() == 0)
return;
-
+
String title = book.getTitle();
- for(int i = 0; i < bookElements.getLength(); i++){
- Element bookElement = (Element)bookElements.item(i);
- if(title.equals(bookElement.getAttribute(ATTRIBUTE_TITLE))){
+ for (int i = 0; i < bookElements.getLength(); i++) {
+ Element bookElement = (Element) bookElements.item(i);
+ if (title.equals(bookElement.getAttribute(ATTRIBUTE_TITLE))) {
fEnabled = VALUE_TRUE.equalsIgnoreCase(bookElement.getAttribute(ATTRIBUTE_ENABLED));
break;
}
}
}
-
- public boolean isEnabled(){
+
+ public boolean isEnabled() {
return fEnabled;
}
-
- public boolean matches(ICHelpInvocationContext context){
+
+ public boolean matches(ICHelpInvocationContext context) {
ITranslationUnit unit = context.getTranslationUnit();
- if(unit != null)
+ if (unit != null)
return matches(unit);
IProject project = context.getProject();
- if(project != null)
+ if (project != null)
return matches(project);
return true;
}
-
- public boolean matches(IProject project){
+
+ public boolean matches(IProject project) {
ICHelpBook book = getCHelpBook();
boolean bMatches = false;
- switch(book.getCHelpType()){
- case ICHelpBook.HELP_TYPE_CPP:
- try{
- bMatches = project.hasNature(CCProjectNature.CC_NATURE_ID);
- }catch(CoreException e){
- }
- break;
- case ICHelpBook.HELP_TYPE_C:
- case ICHelpBook.HELP_TYPE_ASM:
- try{
- bMatches = project.hasNature(CProjectNature.C_NATURE_ID);
- }catch(CoreException e){
- }
- break;
- default:
- bMatches = true;
+ switch (book.getCHelpType()) {
+ case ICHelpBook.HELP_TYPE_CPP:
+ try {
+ bMatches = project.hasNature(CCProjectNature.CC_NATURE_ID);
+ } catch (CoreException e) {
+ }
+ break;
+ case ICHelpBook.HELP_TYPE_C:
+ case ICHelpBook.HELP_TYPE_ASM:
+ try {
+ bMatches = project.hasNature(CProjectNature.C_NATURE_ID);
+ } catch (CoreException e) {
+ }
+ break;
+ default:
+ bMatches = true;
}
return bMatches;
}
-
- public boolean matches(ITranslationUnit unit){
+
+ public boolean matches(ITranslationUnit unit) {
ICHelpBook book = getCHelpBook();
boolean bMatches = false;
- switch(book.getCHelpType()){
- case ICHelpBook.HELP_TYPE_CPP:
- bMatches = unit.isCXXLanguage();
- break;
- case ICHelpBook.HELP_TYPE_C:
- bMatches = unit.isCLanguage() || unit.isCXXLanguage();
- break;
- case ICHelpBook.HELP_TYPE_ASM:
- bMatches = unit.isASMLanguage();
- break;
- default:
- bMatches = true;
+ switch (book.getCHelpType()) {
+ case ICHelpBook.HELP_TYPE_CPP:
+ bMatches = unit.isCXXLanguage();
+ break;
+ case ICHelpBook.HELP_TYPE_C:
+ bMatches = unit.isCLanguage() || unit.isCXXLanguage();
+ break;
+ case ICHelpBook.HELP_TYPE_ASM:
+ bMatches = unit.isASMLanguage();
+ break;
+ default:
+ bMatches = true;
}
return bMatches;
}
-
- public void enable(boolean enable){
+
+ public void enable(boolean enable) {
fEnabled = enable;
}
-
- public ICHelpBook getCHelpBook(){
+
+ public ICHelpBook getCHelpBook() {
return fCHelpBook;
}
-
- public void serialize(Document doc, Element parentElement){
+
+ public void serialize(Document doc, Element parentElement) {
Element bookElement = doc.createElement(ELEMENT_BOOK);
- bookElement.setAttribute(ATTRIBUTE_TITLE,getCHelpBook().getTitle());
- bookElement.setAttribute(ATTRIBUTE_ENABLED,fEnabled ? VALUE_TRUE : VALUE_FALSE);
+ bookElement.setAttribute(ATTRIBUTE_TITLE, getCHelpBook().getTitle());
+ bookElement.setAttribute(ATTRIBUTE_ENABLED, fEnabled ? VALUE_TRUE : VALUE_FALSE);
parentElement.appendChild(bookElement);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
index 9feed9defd6..7da1cf4a366 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.internal.ui.text;
@@ -32,11 +32,11 @@ import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
/**
* This class represents the CHelpProvider settings
- *
+ *
* @since 2.1
*/
public class CHelpProviderDescriptor {
- private static final String CLASS= "class"; //$NON-NLS-1$
+ private static final String CLASS = "class"; //$NON-NLS-1$
final private static String ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$
final private static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
@@ -48,139 +48,139 @@ public class CHelpProviderDescriptor {
private CHelpBookDescriptor fHelpBookDescriptors[] = null;
private IProject fProject;
- public CHelpProviderDescriptor(IProject project, IConfigurationElement element){
- this(project,element,null);
+ public CHelpProviderDescriptor(IProject project, IConfigurationElement element) {
+ this(project, element, null);
}
-
- public CHelpProviderDescriptor(IProject project, IConfigurationElement configElement, Element parentElement){
+
+ public CHelpProviderDescriptor(IProject project, IConfigurationElement configElement, Element parentElement) {
fConfigElement = configElement;
fProject = project;
-
- if(parentElement == null)
+
+ if (parentElement == null)
return;
Element projectElement = getDescriptorElement(parentElement);
-
- if(projectElement == null)
+
+ if (projectElement == null)
return;
-
+
getCHelpBookDescriptors(projectElement);
}
-
- private Element getDescriptorElement(Element parentElement){
+
+ private Element getDescriptorElement(Element parentElement) {
String id = getConfigurationElement().getAttribute(ATTRIBUTE_ID);
- if(id == null || id.isEmpty())
+ if (id == null || id.isEmpty())
return null;
NodeList nodes = parentElement.getElementsByTagName(ELEMENT_PROVIDER);
- for(int i = 0; i < nodes.getLength(); i++){
- Element descriptorEl = (Element)nodes.item(i);
- if(id.equals(descriptorEl.getAttribute(ATTRIBUTE_ID))){
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Element descriptorEl = (Element) nodes.item(i);
+ if (id.equals(descriptorEl.getAttribute(ATTRIBUTE_ID))) {
return descriptorEl;
}
}
return null;
}
- private static Map<String, ICHelpProvider> getProvidersMap(){
- if(fProvidersMap == null){
+ private static Map<String, ICHelpProvider> getProvidersMap() {
+ if (fProvidersMap == null) {
fProvidersMap = new HashMap<String, ICHelpProvider>();
}
return fProvidersMap;
}
-
- private static ICHelpProvider getCHelpProvider(IConfigurationElement element){
+
+ private static ICHelpProvider getCHelpProvider(IConfigurationElement element) {
String id = element.getAttribute(ATTRIBUTE_ID);
- if(id == null || id.isEmpty())
+ if (id == null || id.isEmpty())
return null;
Map<String, ICHelpProvider> providersMap = getProvidersMap();
- try{
+ try {
ICHelpProvider provider = providersMap.get(id);
- if(provider == null){
- provider = (ICHelpProvider)element.createExecutableExtension(CLASS);
- providersMap.put(id,provider);
-
- final ICHelpProvider c = provider;
- // Run the initialiser the class
- ISafeRunnable runnable = new ISafeRunnable() {
- @Override
- public void run() throws Exception {
- // Initialize
- c.initialize();
- }
- @Override
- public void handleException(Throwable exception) {
- }
- };
- SafeRunner.run(runnable);
+ if (provider == null) {
+ provider = (ICHelpProvider) element.createExecutableExtension(CLASS);
+ providersMap.put(id, provider);
+
+ final ICHelpProvider c = provider;
+ // Run the initialiser the class
+ ISafeRunnable runnable = new ISafeRunnable() {
+ @Override
+ public void run() throws Exception {
+ // Initialize
+ c.initialize();
+ }
+
+ @Override
+ public void handleException(Throwable exception) {
+ }
+ };
+ SafeRunner.run(runnable);
}
return provider;
- }
- catch(Exception e){
+ } catch (Exception e) {
return null;
}
}
-
- public IConfigurationElement getConfigurationElement(){
+
+ public IConfigurationElement getConfigurationElement() {
return fConfigElement;
}
- public ICHelpProvider getCHelpProvider(){
- if(fHelpProvider == null)
+ public ICHelpProvider getCHelpProvider() {
+ if (fHelpProvider == null)
fHelpProvider = getCHelpProvider(fConfigElement);
return fHelpProvider;
}
-
- public CHelpBookDescriptor [] getCHelpBookDescriptors(Element projectElement){
- if (fHelpBookDescriptors == null || projectElement != null){
+
+ public CHelpBookDescriptor[] getCHelpBookDescriptors(Element projectElement) {
+ if (fHelpBookDescriptors == null || projectElement != null) {
ICHelpProvider provider = getCHelpProvider();
if (provider != null && fProject != null) {
ICHelpBook books[] = provider.getCHelpBooks();
- if(books != null){
+ if (books != null) {
List<CHelpBookDescriptor> descriptorList = new ArrayList<CHelpBookDescriptor>();
- for(int i = 0; i < books.length; i++){
- CHelpBookDescriptor des = new CHelpBookDescriptor(books[i],projectElement);
- if(des.matches(fProject))
+ for (int i = 0; i < books.length; i++) {
+ CHelpBookDescriptor des = new CHelpBookDescriptor(books[i], projectElement);
+ if (des.matches(fProject))
descriptorList.add(des);
}
fHelpBookDescriptors = descriptorList.toArray(new CHelpBookDescriptor[descriptorList.size()]);
}
}
- if(fHelpBookDescriptors == null)
+ if (fHelpBookDescriptors == null)
fHelpBookDescriptors = new CHelpBookDescriptor[0];
}
return fHelpBookDescriptors;
}
- public CHelpBookDescriptor [] getCHelpBookDescriptors(){
+ public CHelpBookDescriptor[] getCHelpBookDescriptors() {
return getCHelpBookDescriptors(null);
}
- ICHelpBook[] getEnabledMatchedCHelpBooks(ICHelpInvocationContext context){
+ ICHelpBook[] getEnabledMatchedCHelpBooks(ICHelpInvocationContext context) {
CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
- if(bookDescriptors.length == 0)
+ if (bookDescriptors.length == 0)
return null;
List<ICHelpBook> bookList = new ArrayList<ICHelpBook>();
- for(int i = 0; i < bookDescriptors.length; i++){
- if(bookDescriptors[i].isEnabled() && bookDescriptors[i].matches(context))
+ for (int i = 0; i < bookDescriptors.length; i++) {
+ if (bookDescriptors[i].isEnabled() && bookDescriptors[i].matches(context))
bookList.add(bookDescriptors[i].getCHelpBook());
}
return bookList.toArray(new ICHelpBook[bookList.size()]);
}
-
- public void serialize(Document doc, Element parentElement){
+
+ public void serialize(Document doc, Element parentElement) {
String id = getConfigurationElement().getAttribute(ATTRIBUTE_ID);
- if(id == null || id.isEmpty())
+ if (id == null || id.isEmpty())
return;
CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
Element providerElement = doc.createElement(ELEMENT_PROVIDER);
- providerElement.setAttribute(ATTRIBUTE_ID,id);
+ providerElement.setAttribute(ATTRIBUTE_ID, id);
parentElement.appendChild(providerElement);
-
- for(int i = 0; i < bookDescriptors.length; i++){
- bookDescriptors[i].serialize(doc,providerElement);
+
+ for (int i = 0; i < bookDescriptors.length; i++) {
+ bookDescriptors[i].serialize(doc, providerElement);
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
index 3fe19229d66..c15fa38cf4d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.internal.ui.text;
@@ -32,7 +32,7 @@ import org.w3c.dom.NodeList;
/**
* This class represents the Help settings for the current project
- *
+ *
* @since 2.1
*/
public class CHelpSettings {
@@ -44,146 +44,147 @@ public class CHelpSettings {
private IProject fProject;
private static IConfigurationElement fConfigElements[] = null;
private CHelpProviderDescriptor fProviderDescriptors[] = null;
-
- public CHelpSettings(IProject project){
- this(project,null);
+
+ public CHelpSettings(IProject project) {
+ this(project, null);
}
-
- public CHelpSettings(IProject project, Element parentElement){
+
+ public CHelpSettings(IProject project, Element parentElement) {
fProject = project;
-
- if(parentElement == null)
+
+ if (parentElement == null)
return;
-
+
Element projectElement = getProjectElement(parentElement);
- if(projectElement == null)
+ if (projectElement == null)
return;
-
+
getCHelpProviderDescriptors(projectElement);
}
-
- private Element getProjectElement(Element parentElement){
+
+ private Element getProjectElement(Element parentElement) {
NodeList nodes = parentElement.getElementsByTagName(ELEMENT_PROJECT);
- for(int i = 0; i < nodes.getLength(); i++){
- Element curProject = (Element)nodes.item(i);
- if(getProject().getName().equals(curProject.getAttribute(ATTRIBUTE_NAME)))
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Element curProject = (Element) nodes.item(i);
+ if (getProject().getName().equals(curProject.getAttribute(ATTRIBUTE_NAME)))
return curProject;
}
return null;
}
- public IProject getProject(){
+ public IProject getProject() {
return fProject;
}
-
- public CHelpProviderDescriptor[] getCHelpProviderDescriptors(Element projectElement){
- if(fProviderDescriptors == null || projectElement != null){
+
+ public CHelpProviderDescriptor[] getCHelpProviderDescriptors(Element projectElement) {
+ if (fProviderDescriptors == null || projectElement != null) {
IConfigurationElement congifElements[] = getConfigElements();
fProviderDescriptors = new CHelpProviderDescriptor[congifElements.length];
- for(int i = 0; i < congifElements.length; i++){
- fProviderDescriptors[i] = new CHelpProviderDescriptor(fProject,congifElements[i],projectElement);
+ for (int i = 0; i < congifElements.length; i++) {
+ fProviderDescriptors[i] = new CHelpProviderDescriptor(fProject, congifElements[i], projectElement);
}
}
return fProviderDescriptors;
}
- public CHelpProviderDescriptor[] getCHelpProviderDescriptors(){
+ public CHelpProviderDescriptor[] getCHelpProviderDescriptors() {
return getCHelpProviderDescriptors(null);
}
- public CHelpBookDescriptor[] getCHelpBookDescriptors(){
+ public CHelpBookDescriptor[] getCHelpBookDescriptors() {
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
- if(providerDescriptors.length == 0)
+ if (providerDescriptors.length == 0)
return new CHelpBookDescriptor[0];
-
- List<CHelpBookDescriptor> bookList = new ArrayList<CHelpBookDescriptor>();
- for(int i = 0; i < providerDescriptors.length; i++){
+
+ List<CHelpBookDescriptor> bookList = new ArrayList<CHelpBookDescriptor>();
+ for (int i = 0; i < providerDescriptors.length; i++) {
CHelpBookDescriptor bookDescriptors[] = providerDescriptors[i].getCHelpBookDescriptors();
- if(bookDescriptors.length != 0)
+ if (bookDescriptors.length != 0)
bookList.addAll(Arrays.asList(bookDescriptors));
}
return bookList.toArray(new CHelpBookDescriptor[bookList.size()]);
}
-
- private static IConfigurationElement[] getConfigElements(){
- if(fConfigElements == null){
- fConfigElements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, CONTRIBUTION_EXTENSION);
- if(fConfigElements == null)
+
+ private static IConfigurationElement[] getConfigElements() {
+ if (fConfigElements == null) {
+ fConfigElements = Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID,
+ CONTRIBUTION_EXTENSION);
+ if (fConfigElements == null)
fConfigElements = new IConfigurationElement[0];
}
return fConfigElements;
}
-
- public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, String name){
+
+ public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, String name) {
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
- for(int i = 0; i < providerDescriptors.length; i++){
+ for (int i = 0; i < providerDescriptors.length; i++) {
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
- if(books != null && books.length != 0){
+ if (books != null && books.length != 0) {
ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
- if(provider != null){
- IFunctionSummary summary = provider.getFunctionInfo(context,books,name);
- if(summary != null)
+ if (provider != null) {
+ IFunctionSummary summary = provider.getFunctionInfo(context, books, name);
+ if (summary != null)
return summary;
}
}
}
return null;
}
-
- public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag){
+
+ public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag) {
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
List<IFunctionSummary> sumaryList = new ArrayList<IFunctionSummary>();
- for(int i = 0; i < providerDescriptors.length; i++){
+ for (int i = 0; i < providerDescriptors.length; i++) {
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
- if(books != null && books.length != 0){
+ if (books != null && books.length != 0) {
ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
- if(provider != null){
- IFunctionSummary summaries[] = provider.getMatchingFunctions(context,books,frag);
- if(summaries != null && summaries.length != 0)
+ if (provider != null) {
+ IFunctionSummary summaries[] = provider.getMatchingFunctions(context, books, frag);
+ if (summaries != null && summaries.length != 0)
sumaryList.addAll(Arrays.asList(summaries));
}
}
}
- if(sumaryList.size() == 0)
+ if (sumaryList.size() == 0)
return null;
-
+
return sumaryList.toArray(new IFunctionSummary[sumaryList.size()]);
}
-
- public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
+
+ public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name) {
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
List<ICHelpResourceDescriptor> resourcesList = new ArrayList<ICHelpResourceDescriptor>();
- for(int i = 0; i < providerDescriptors.length; i++){
+ for (int i = 0; i < providerDescriptors.length; i++) {
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
- if(books != null && books.length != 0){
+ if (books != null && books.length != 0) {
ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
- if(provider != null){
- ICHelpResourceDescriptor resources[] = provider.getHelpResources(context,books,name);
- if(resources != null && resources.length != 0)
+ if (provider != null) {
+ ICHelpResourceDescriptor resources[] = provider.getHelpResources(context, books, name);
+ if (resources != null && resources.length != 0)
resourcesList.addAll(Arrays.asList(resources));
}
}
}
- if(resourcesList.size() == 0)
+ if (resourcesList.size() == 0)
return null;
-
+
return resourcesList.toArray(new ICHelpResourceDescriptor[resourcesList.size()]);
}
-
- public void serialize(Document doc, Element parentElement){
+
+ public void serialize(Document doc, Element parentElement) {
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
Element oldProjectElement = getProjectElement(parentElement);
Element projectElement = doc.createElement(ELEMENT_PROJECT);
- projectElement.setAttribute(ATTRIBUTE_NAME,getProject().getName());
+ projectElement.setAttribute(ATTRIBUTE_NAME, getProject().getName());
- if(oldProjectElement != null)
- parentElement.replaceChild(projectElement,oldProjectElement);
+ if (oldProjectElement != null)
+ parentElement.replaceChild(projectElement, oldProjectElement);
else
parentElement.appendChild(projectElement);
- for(int i = 0; i < providerDescriptors.length; i++){
- providerDescriptors[i].serialize(doc,projectElement);
+ for (int i = 0; i < providerDescriptors.length; i++) {
+ providerDescriptors[i].serialize(doc, projectElement);
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java
index bfb7863da5b..c6d0d558c5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java
@@ -39,33 +39,32 @@ public final class CHeuristicScanner implements Symbols {
* Returned by all methods when the requested position could not be found, or if a
* {@link BadLocationException} was thrown while scanning.
*/
- public static final int NOT_FOUND= -1;
+ public static final int NOT_FOUND = -1;
/**
* Special bound parameter that means either -1 (backward scanning) or
* <code>fDocument.getLength()</code> (forward scanning).
*/
- public static final int UNBOUND= -2;
-
+ public static final int UNBOUND = -2;
/* character constants */
- private static final char LBRACE= '{';
- private static final char RBRACE= '}';
- private static final char LPAREN= '(';
- private static final char RPAREN= ')';
- private static final char SEMICOLON= ';';
- private static final char COLON= ':';
- private static final char COMMA= ',';
- private static final char LBRACKET= '[';
- private static final char RBRACKET= ']';
- private static final char QUESTIONMARK= '?';
- private static final char EQUAL= '=';
- private static final char LANGLE= '<';
- private static final char RANGLE= '>';
- private static final char DOT= '.';
- private static final char MINUS= '-';
- private static final char PLUS= '+';
- private static final char TILDE= '~';
+ private static final char LBRACE = '{';
+ private static final char RBRACE = '}';
+ private static final char LPAREN = '(';
+ private static final char RPAREN = ')';
+ private static final char SEMICOLON = ';';
+ private static final char COLON = ':';
+ private static final char COMMA = ',';
+ private static final char LBRACKET = '[';
+ private static final char RBRACKET = ']';
+ private static final char QUESTIONMARK = '?';
+ private static final char EQUAL = '=';
+ private static final char LANGLE = '<';
+ private static final char RANGLE = '>';
+ private static final char DOT = '.';
+ private static final char MINUS = '-';
+ private static final char PLUS = '+';
+ private static final char TILDE = '~';
/**
* Specifies the stop condition, upon which the <code>scanXXX</code> methods will decide whether
@@ -125,16 +124,16 @@ public final class CHeuristicScanner implements Symbols {
*/
@Override
public int nextPosition(int position, boolean forward) {
- ITypedRegion partition= getPartition(position);
+ ITypedRegion partition = getPartition(position);
if (fPartition.equals(partition.getType()))
return super.nextPosition(position, forward);
if (forward) {
- int end= partition.getOffset() + partition.getLength();
+ int end = partition.getOffset() + partition.getLength();
if (position < end)
return end;
} else {
- int offset= partition.getOffset();
+ int offset = partition.getOffset();
if (position > offset)
return offset - 1;
}
@@ -174,16 +173,16 @@ public final class CHeuristicScanner implements Symbols {
*/
@Override
public int nextPosition(int position, boolean forward) {
- ITypedRegion partition= getPartition(position);
+ ITypedRegion partition = getPartition(position);
if (fPartition.equals(partition.getType()))
return super.nextPosition(position, forward);
if (forward) {
- int end= partition.getOffset() + partition.getLength();
+ int end = partition.getOffset() + partition.getLength();
if (position < end)
return end;
} else {
- int offset= partition.getOffset();
+ int offset = partition.getOffset();
if (position > offset)
return offset - 1;
}
@@ -202,7 +201,7 @@ public final class CHeuristicScanner implements Symbols {
* @param ch the single character to match
*/
public CharacterMatch(char ch) {
- this(new char[] {ch});
+ this(new char[] { ch });
}
/**
@@ -212,7 +211,7 @@ public final class CHeuristicScanner implements Symbols {
public CharacterMatch(char[] chars) {
Assert.isNotNull(chars);
Assert.isTrue(chars.length > 0);
- fChars= chars;
+ fChars = chars;
Arrays.sort(chars);
}
@@ -229,16 +228,16 @@ public final class CHeuristicScanner implements Symbols {
*/
@Override
public int nextPosition(int position, boolean forward) {
- ITypedRegion partition= getPartition(position);
+ ITypedRegion partition = getPartition(position);
if (fPartition.equals(partition.getType()))
return super.nextPosition(position, forward);
if (forward) {
- int end= partition.getOffset() + partition.getLength();
+ int end = partition.getOffset() + partition.getLength();
if (position < end)
return end;
} else {
- int offset= partition.getOffset();
+ int offset = partition.getOffset();
if (position > offset)
return offset - 1;
}
@@ -262,12 +261,12 @@ public final class CHeuristicScanner implements Symbols {
/**
* The most recently used partition.
*/
- private ITypedRegion fCachedPartition= new TypedRegion(-1, 0, "__no_partition_at_all"); //$NON-NLS-1$
+ private ITypedRegion fCachedPartition = new TypedRegion(-1, 0, "__no_partition_at_all"); //$NON-NLS-1$
/* preset stop conditions */
- private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition();
- private static final StopCondition fNonWS= new NonWhitespace();
- private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition();
+ private final StopCondition fNonWSDefaultPart = new NonWhitespaceDefaultPartition();
+ private static final StopCondition fNonWS = new NonWhitespace();
+ private final StopCondition fNonIdent = new NonJavaIdentifierPartDefaultPartition();
/**
* Creates a new instance.
@@ -280,9 +279,9 @@ public final class CHeuristicScanner implements Symbols {
Assert.isLegal(document != null);
Assert.isLegal(partitioning != null);
Assert.isLegal(partition != null);
- fDocument= document;
- fPartitioning= partitioning;
- fPartition= partition;
+ fDocument = document;
+ fPartitioning = partitioning;
+ fPartition = partition;
}
/**
@@ -314,108 +313,107 @@ public final class CHeuristicScanner implements Symbols {
* @return a constant from {@link Symbols} describing the next token
*/
public int nextToken(int start, int bound) {
- int pos= scanForward(start, bound, fNonWS);
+ int pos = scanForward(start, bound, fNonWS);
if (pos == NOT_FOUND)
return TokenEOF;
try {
// check for string or char literal
char ch = fDocument.getChar(pos);
if (ch == '"' || ch == '\'') {
- fChar= ch;
- fPos= fNonWSDefaultPart.nextPosition(pos, true);
+ fChar = ch;
+ fPos = fNonWSDefaultPart.nextPosition(pos, true);
return TokenOTHER;
}
} catch (BadLocationException exc) {
}
- pos= scanForward(pos, bound, fNonWSDefaultPart);
+ pos = scanForward(pos, bound, fNonWSDefaultPart);
if (pos == NOT_FOUND)
return TokenEOF;
fPos++;
switch (fChar) {
- case LBRACE:
- return TokenLBRACE;
- case RBRACE:
- return TokenRBRACE;
- case LBRACKET:
- return TokenLBRACKET;
- case RBRACKET:
- return TokenRBRACKET;
- case LPAREN:
- return TokenLPAREN;
- case RPAREN:
- return TokenRPAREN;
- case SEMICOLON:
- return TokenSEMICOLON;
+ case LBRACE:
+ return TokenLBRACE;
+ case RBRACE:
+ return TokenRBRACE;
+ case LBRACKET:
+ return TokenLBRACKET;
+ case RBRACKET:
+ return TokenRBRACKET;
+ case LPAREN:
+ return TokenLPAREN;
+ case RPAREN:
+ return TokenRPAREN;
+ case SEMICOLON:
+ return TokenSEMICOLON;
+ case COLON:
+ switch (peekNextChar()) {
case COLON:
- switch (peekNextChar()) {
- case COLON:
- ++fPos;
- return TokenDOUBLECOLON;
- }
- return TokenCOLON;
- case COMMA:
- return TokenCOMMA;
- case QUESTIONMARK:
- return TokenQUESTIONMARK;
- case EQUAL:
- return TokenEQUAL;
+ ++fPos;
+ return TokenDOUBLECOLON;
+ }
+ return TokenCOLON;
+ case COMMA:
+ return TokenCOMMA;
+ case QUESTIONMARK:
+ return TokenQUESTIONMARK;
+ case EQUAL:
+ return TokenEQUAL;
+ case LANGLE:
+ switch (peekNextChar()) {
case LANGLE:
- switch (peekNextChar()) {
- case LANGLE:
- ++fPos;
- return TokenSHIFTLEFT;
- case EQUAL:
- ++fPos;
- return TokenOTHER;
- }
- return TokenLESSTHAN;
+ ++fPos;
+ return TokenSHIFTLEFT;
+ case EQUAL:
+ ++fPos;
+ return TokenOTHER;
+ }
+ return TokenLESSTHAN;
+ case RANGLE:
+ switch (peekNextChar()) {
case RANGLE:
- switch (peekNextChar()) {
- case RANGLE:
- ++fPos;
- return TokenSHIFTRIGHT;
- case EQUAL:
- ++fPos;
- return TokenOTHER;
- }
- return TokenGREATERTHAN;
- case DOT:
- return TokenDOT;
- case MINUS:
- switch (peekNextChar()) {
- case RANGLE:
- ++fPos;
- return TokenARROW;
- }
- return TokenMINUS;
- case PLUS:
- return TokenPLUS;
- case TILDE:
- return TokenTILDE;
+ ++fPos;
+ return TokenSHIFTRIGHT;
+ case EQUAL:
+ ++fPos;
+ return TokenOTHER;
+ }
+ return TokenGREATERTHAN;
+ case DOT:
+ return TokenDOT;
+ case MINUS:
+ switch (peekNextChar()) {
+ case RANGLE:
+ ++fPos;
+ return TokenARROW;
+ }
+ return TokenMINUS;
+ case PLUS:
+ return TokenPLUS;
+ case TILDE:
+ return TokenTILDE;
}
// else
if (Character.isJavaIdentifierPart(fChar)) {
// assume an identifier or keyword
- int from= pos, to;
- pos= scanForward(pos + 1, bound, fNonIdent);
+ int from = pos, to;
+ pos = scanForward(pos + 1, bound, fNonIdent);
if (pos == NOT_FOUND)
- to= bound == UNBOUND ? fDocument.getLength() : bound;
+ to = bound == UNBOUND ? fDocument.getLength() : bound;
else
- to= pos;
+ to = pos;
String identOrKeyword;
try {
- identOrKeyword= fDocument.get(from, to - from);
+ identOrKeyword = fDocument.get(from, to - from);
} catch (BadLocationException e) {
return TokenEOF;
}
return getToken(identOrKeyword);
-
}
// operators, number literals etc
return TokenOTHER;
@@ -432,86 +430,86 @@ public final class CHeuristicScanner implements Symbols {
* @return a constant from {@link Symbols} describing the previous token
*/
public int previousToken(int start, int bound) {
- int pos= scanBackward(start, bound, fNonWSDefaultPart);
+ int pos = scanBackward(start, bound, fNonWSDefaultPart);
if (pos == NOT_FOUND)
return TokenEOF;
fPos--;
switch (fChar) {
- case LBRACE:
- return TokenLBRACE;
- case RBRACE:
- return TokenRBRACE;
- case LBRACKET:
- return TokenLBRACKET;
- case RBRACKET:
- return TokenRBRACKET;
- case LPAREN:
- return TokenLPAREN;
- case RPAREN:
- return TokenRPAREN;
- case SEMICOLON:
- return TokenSEMICOLON;
+ case LBRACE:
+ return TokenLBRACE;
+ case RBRACE:
+ return TokenRBRACE;
+ case LBRACKET:
+ return TokenLBRACKET;
+ case RBRACKET:
+ return TokenRBRACKET;
+ case LPAREN:
+ return TokenLPAREN;
+ case RPAREN:
+ return TokenRPAREN;
+ case SEMICOLON:
+ return TokenSEMICOLON;
+ case COLON:
+ switch (peekPreviousChar()) {
case COLON:
- switch (peekPreviousChar()) {
- case COLON:
- --fPos;
- return TokenDOUBLECOLON;
- }
- return TokenCOLON;
- case COMMA:
- return TokenCOMMA;
- case QUESTIONMARK:
- return TokenQUESTIONMARK;
- case EQUAL:
- switch (peekPreviousChar()) {
- case RANGLE:
- case LANGLE:
- --fPos;
- return TokenOTHER;
- }
- return TokenEQUAL;
+ --fPos;
+ return TokenDOUBLECOLON;
+ }
+ return TokenCOLON;
+ case COMMA:
+ return TokenCOMMA;
+ case QUESTIONMARK:
+ return TokenQUESTIONMARK;
+ case EQUAL:
+ switch (peekPreviousChar()) {
+ case RANGLE:
case LANGLE:
- switch (peekPreviousChar()) {
- case LANGLE:
- --fPos;
- return TokenSHIFTLEFT;
- }
- return TokenLESSTHAN;
+ --fPos;
+ return TokenOTHER;
+ }
+ return TokenEQUAL;
+ case LANGLE:
+ switch (peekPreviousChar()) {
+ case LANGLE:
+ --fPos;
+ return TokenSHIFTLEFT;
+ }
+ return TokenLESSTHAN;
+ case RANGLE:
+ switch (peekPreviousChar()) {
case RANGLE:
- switch (peekPreviousChar()) {
- case RANGLE:
- --fPos;
- return TokenSHIFTRIGHT;
- case MINUS:
- --fPos;
- return TokenARROW;
- }
- return TokenGREATERTHAN;
- case DOT:
- return TokenDOT;
+ --fPos;
+ return TokenSHIFTRIGHT;
case MINUS:
- return TokenMINUS;
- case PLUS:
- return TokenPLUS;
- case TILDE:
- return TokenTILDE;
+ --fPos;
+ return TokenARROW;
+ }
+ return TokenGREATERTHAN;
+ case DOT:
+ return TokenDOT;
+ case MINUS:
+ return TokenMINUS;
+ case PLUS:
+ return TokenPLUS;
+ case TILDE:
+ return TokenTILDE;
}
// else
if (Character.isJavaIdentifierPart(fChar)) {
// assume an ident or keyword
- int from, to= pos + 1;
- pos= scanBackward(pos - 1, bound, fNonIdent);
+ int from, to = pos + 1;
+ pos = scanBackward(pos - 1, bound, fNonIdent);
if (pos == NOT_FOUND)
- from= bound == UNBOUND ? 0 : bound + 1;
+ from = bound == UNBOUND ? 0 : bound + 1;
else
- from= pos + 1;
+ from = pos + 1;
String identOrKeyword;
try {
- identOrKeyword= fDocument.get(from, to - from);
+ identOrKeyword = fDocument.get(from, to - from);
} catch (BadLocationException e) {
return TokenEOF;
}
@@ -532,7 +530,7 @@ public final class CHeuristicScanner implements Symbols {
} catch (BadLocationException exc) {
}
}
- return (char)-1;
+ return (char) -1;
}
/**
@@ -545,7 +543,7 @@ public final class CHeuristicScanner implements Symbols {
} catch (BadLocationException e) {
}
}
- return (char)-1;
+ return (char) -1;
}
/**
@@ -558,91 +556,91 @@ public final class CHeuristicScanner implements Symbols {
Assert.isNotNull(s);
switch (s.length()) {
- case 2:
- if ("if".equals(s)) //$NON-NLS-1$
- return TokenIF;
- if ("do".equals(s)) //$NON-NLS-1$
- return TokenDO;
- break;
- case 3:
- if ("for".equals(s)) //$NON-NLS-1$
- return TokenFOR;
- if ("try".equals(s)) //$NON-NLS-1$
- return TokenTRY;
- if ("new".equals(s)) //$NON-NLS-1$
- return TokenNEW;
- break;
- case 4:
- if ("case".equals(s)) //$NON-NLS-1$
- return TokenCASE;
- if ("else".equals(s)) //$NON-NLS-1$
- return TokenELSE;
- if ("enum".equals(s)) //$NON-NLS-1$
- return TokenENUM;
- if ("goto".equals(s)) //$NON-NLS-1$
- return TokenGOTO;
- break;
- case 5:
- if ("break".equals(s)) //$NON-NLS-1$
- return TokenBREAK;
- if ("catch".equals(s)) //$NON-NLS-1$
- return TokenCATCH;
- if ("class".equals(s)) //$NON-NLS-1$
- return TokenCLASS;
- if ("const".equals(s)) //$NON-NLS-1$
- return TokenCONST;
- if ("while".equals(s)) //$NON-NLS-1$
- return TokenWHILE;
- if ("union".equals(s)) //$NON-NLS-1$
- return TokenUNION;
- if ("using".equals(s)) //$NON-NLS-1$
- return TokenUSING;
- if ("throw".equals(s)) //$NON-NLS-1$
- return TokenTHROW;
- break;
- case 6:
- if ("delete".equals(s)) //$NON-NLS-1$
- return TokenDELETE;
- if ("public".equals(s)) //$NON-NLS-1$
- return TokenPUBLIC;
- if ("return".equals(s)) //$NON-NLS-1$
- return TokenRETURN;
- if ("static".equals(s)) //$NON-NLS-1$
- return TokenSTATIC;
- if ("struct".equals(s)) //$NON-NLS-1$
- return TokenSTRUCT;
- if ("switch".equals(s)) //$NON-NLS-1$
- return TokenSWITCH;
- if ("extern".equals(s)) //$NON-NLS-1$
- return TokenEXTERN;
- break;
- case 7:
- if ("default".equals(s)) //$NON-NLS-1$
- return TokenDEFAULT;
- if ("private".equals(s)) //$NON-NLS-1$
- return TokenPRIVATE;
- if ("typedef".equals(s)) //$NON-NLS-1$
- return TokenTYPEDEF;
- if ("virtual".equals(s)) //$NON-NLS-1$
- return TokenVIRTUAL;
- break;
- case 8:
- if ("operator".equals(s)) //$NON-NLS-1$
- return TokenOPERATOR;
- if ("template".equals(s)) //$NON-NLS-1$
- return TokenTEMPLATE;
- if ("typename".equals(s)) //$NON-NLS-1$
- return TokenTYPENAME;
- if ("noexcept".equals(s)) //$NON-NLS-1$
- return TokenNOEXCEPT;
- if ("override".equals(s)) //$NON-NLS-1$
- return TokenOVERRIDE;
- break;
- case 9:
- if ("namespace".equals(s)) //$NON-NLS-1$
- return TokenNAMESPACE;
- if ("protected".equals(s)) //$NON-NLS-1$
- return TokenPROTECTED;
+ case 2:
+ if ("if".equals(s)) //$NON-NLS-1$
+ return TokenIF;
+ if ("do".equals(s)) //$NON-NLS-1$
+ return TokenDO;
+ break;
+ case 3:
+ if ("for".equals(s)) //$NON-NLS-1$
+ return TokenFOR;
+ if ("try".equals(s)) //$NON-NLS-1$
+ return TokenTRY;
+ if ("new".equals(s)) //$NON-NLS-1$
+ return TokenNEW;
+ break;
+ case 4:
+ if ("case".equals(s)) //$NON-NLS-1$
+ return TokenCASE;
+ if ("else".equals(s)) //$NON-NLS-1$
+ return TokenELSE;
+ if ("enum".equals(s)) //$NON-NLS-1$
+ return TokenENUM;
+ if ("goto".equals(s)) //$NON-NLS-1$
+ return TokenGOTO;
+ break;
+ case 5:
+ if ("break".equals(s)) //$NON-NLS-1$
+ return TokenBREAK;
+ if ("catch".equals(s)) //$NON-NLS-1$
+ return TokenCATCH;
+ if ("class".equals(s)) //$NON-NLS-1$
+ return TokenCLASS;
+ if ("const".equals(s)) //$NON-NLS-1$
+ return TokenCONST;
+ if ("while".equals(s)) //$NON-NLS-1$
+ return TokenWHILE;
+ if ("union".equals(s)) //$NON-NLS-1$
+ return TokenUNION;
+ if ("using".equals(s)) //$NON-NLS-1$
+ return TokenUSING;
+ if ("throw".equals(s)) //$NON-NLS-1$
+ return TokenTHROW;
+ break;
+ case 6:
+ if ("delete".equals(s)) //$NON-NLS-1$
+ return TokenDELETE;
+ if ("public".equals(s)) //$NON-NLS-1$
+ return TokenPUBLIC;
+ if ("return".equals(s)) //$NON-NLS-1$
+ return TokenRETURN;
+ if ("static".equals(s)) //$NON-NLS-1$
+ return TokenSTATIC;
+ if ("struct".equals(s)) //$NON-NLS-1$
+ return TokenSTRUCT;
+ if ("switch".equals(s)) //$NON-NLS-1$
+ return TokenSWITCH;
+ if ("extern".equals(s)) //$NON-NLS-1$
+ return TokenEXTERN;
+ break;
+ case 7:
+ if ("default".equals(s)) //$NON-NLS-1$
+ return TokenDEFAULT;
+ if ("private".equals(s)) //$NON-NLS-1$
+ return TokenPRIVATE;
+ if ("typedef".equals(s)) //$NON-NLS-1$
+ return TokenTYPEDEF;
+ if ("virtual".equals(s)) //$NON-NLS-1$
+ return TokenVIRTUAL;
+ break;
+ case 8:
+ if ("operator".equals(s)) //$NON-NLS-1$
+ return TokenOPERATOR;
+ if ("template".equals(s)) //$NON-NLS-1$
+ return TokenTEMPLATE;
+ if ("typename".equals(s)) //$NON-NLS-1$
+ return TokenTYPENAME;
+ if ("noexcept".equals(s)) //$NON-NLS-1$
+ return TokenNOEXCEPT;
+ if ("override".equals(s)) //$NON-NLS-1$
+ return TokenOVERRIDE;
+ break;
+ case 9:
+ if ("namespace".equals(s)) //$NON-NLS-1$
+ return TokenNAMESPACE;
+ if ("protected".equals(s)) //$NON-NLS-1$
+ return TokenPROTECTED;
}
return TokenIDENT;
}
@@ -680,10 +678,10 @@ public final class CHeuristicScanner implements Symbols {
Assert.isLegal(start >= 0);
try {
- int depth= 1;
+ int depth = 1;
start -= 1;
while (true) {
- start= scanForward(start + 1, bound, new CharacterMatch(new char[] {openingPeer, closingPeer}));
+ start = scanForward(start + 1, bound, new CharacterMatch(new char[] { openingPeer, closingPeer }));
if (start == NOT_FOUND)
return NOT_FOUND;
@@ -734,11 +732,11 @@ public final class CHeuristicScanner implements Symbols {
Assert.isLegal(start < fDocument.getLength());
try {
- final CharacterMatch match= new CharacterMatch(new char[] {openingPeer, closingPeer});
- int depth= 1;
+ final CharacterMatch match = new CharacterMatch(new char[] { openingPeer, closingPeer });
+ int depth = 1;
start += 1;
while (true) {
- start= scanBackward(start - 1, bound, match);
+ start = scanBackward(start - 1, bound, match);
if (start == NOT_FOUND)
return NOT_FOUND;
@@ -768,8 +766,8 @@ public final class CHeuristicScanner implements Symbols {
if (offset < 1 || offset >= fDocument.getLength())
return null;
- int begin= findOpeningPeer(offset - 1, CHeuristicScanner.UNBOUND, LBRACE, RBRACE);
- int end= findClosingPeer(offset, UNBOUND, LBRACE, RBRACE);
+ int begin = findOpeningPeer(offset - 1, CHeuristicScanner.UNBOUND, LBRACE, RBRACE);
+ int end = findClosingPeer(offset, UNBOUND, LBRACE, RBRACE);
if (begin == NOT_FOUND || end == NOT_FOUND)
return null;
return new Region(begin, end + 1 - begin);
@@ -826,26 +824,25 @@ public final class CHeuristicScanner implements Symbols {
Assert.isLegal(start >= 0);
if (bound == UNBOUND)
- bound= fDocument.getLength();
+ bound = fDocument.getLength();
Assert.isLegal(bound <= fDocument.getLength());
try {
- fPos= start;
+ fPos = start;
while (fPos < bound) {
- fChar= fDocument.getChar(fPos);
+ fChar = fDocument.getChar(fPos);
if (condition.stop(fChar, fPos, true))
return fPos;
- fPos= condition.nextPosition(fPos, true);
+ fPos = condition.nextPosition(fPos, true);
}
} catch (BadLocationException e) {
}
return NOT_FOUND;
}
-
/**
* Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
* and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code>
@@ -885,20 +882,20 @@ public final class CHeuristicScanner implements Symbols {
*/
public int scanBackward(int start, int bound, StopCondition condition) {
if (bound == UNBOUND)
- bound= -1;
+ bound = -1;
Assert.isLegal(bound >= -1);
- Assert.isLegal(start < fDocument.getLength() );
+ Assert.isLegal(start < fDocument.getLength());
try {
- fPos= start;
+ fPos = start;
while (fPos > bound) {
- fChar= fDocument.getChar(fPos);
+ fChar = fDocument.getChar(fPos);
if (condition.stop(fChar, fPos, false))
return fPos;
- fPos= condition.nextPosition(fPos, false);
+ fPos = condition.nextPosition(fPos, false);
}
} catch (BadLocationException e) {
}
@@ -954,11 +951,11 @@ public final class CHeuristicScanner implements Symbols {
if (!contains(fCachedPartition, position)) {
Assert.isTrue(position >= 0);
Assert.isTrue(position <= fDocument.getLength());
-
+
try {
- fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, position, false);
+ fCachedPartition = TextUtilities.getPartition(fDocument, fPartitioning, position, false);
} catch (BadLocationException e) {
- fCachedPartition= new TypedRegion(position, 0, "__no_partition_at_all"); //$NON-NLS-1$
+ fCachedPartition = new TypedRegion(position, 0, "__no_partition_at_all"); //$NON-NLS-1$
}
}
@@ -967,13 +964,13 @@ public final class CHeuristicScanner implements Symbols {
/**
* Returns <code>true</code> if <code>region</code> contains <code>position</code>.
- *
+ *
* @param region a region
* @param position an offset
* @return <code>true</code> if <code>region</code> contains <code>position</code>
*/
private boolean contains(IRegion region, int position) {
- int offset= region.getOffset();
+ int offset = region.getOffset();
return offset <= position && position < offset + region.getLength();
}
@@ -998,46 +995,46 @@ public final class CHeuristicScanner implements Symbols {
return false;
switch (previousToken(position, bound)) {
- case TokenDO:
- case TokenELSE:
- return true;
- case TokenRPAREN:
- position= findOpeningPeer(fPos, CHeuristicScanner.UNBOUND, LPAREN, RPAREN);
- if (position > 0) {
- switch (previousToken(position - 1, bound)) {
- case TokenIF:
- case TokenFOR:
- case TokenWHILE:
- return true;
- }
+ case TokenDO:
+ case TokenELSE:
+ return true;
+ case TokenRPAREN:
+ position = findOpeningPeer(fPos, CHeuristicScanner.UNBOUND, LPAREN, RPAREN);
+ if (position > 0) {
+ switch (previousToken(position - 1, bound)) {
+ case TokenIF:
+ case TokenFOR:
+ case TokenWHILE:
+ return true;
}
+ }
}
return false;
}
-
+
/**
* Returns <code>true</code> if the document, when scanned backwards from <code>start</code>
* appears to contain a class instance creation, i.e. a possibly qualified name preceded by a
* <code>new</code> keyword. The <code>start</code> must be at the end of the type name, and
* before any generic signature or constructor parameter list. The heuristic will return
* <code>true</code> if <code>start</code> is at the following positions (|):
- *
+ *
* <pre>
* new std::vector&lt;std::string&gt;|(10)
* new str_vector |(10)
* new / * comment * / str_vector |(10)
* </pre>
- *
+ *
* but not the following:
- *
+ *
* <pre>
* new std::vector&lt;std::string&gt;(10)|
* new std::vector&lt;std::string&gt;|(10)
* new vector (10)|
* vector |(10)
* </pre>
- *
+ *
* @param start the position where the type name of the class instance creation supposedly ends
* @param bound the first position in <code>fDocument</code> to not consider any more, with
* <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
@@ -1045,14 +1042,14 @@ public final class CHeuristicScanner implements Symbols {
* instance creation
*/
public boolean looksLikeClassInstanceCreationBackward(int start, int bound) {
- int token= previousToken(start - 1, bound);
+ int token = previousToken(start - 1, bound);
if (token == Symbols.TokenIDENT) { // type name
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
while (token == Symbols.TokenDOUBLECOLON) { // qualification
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token != Symbols.TokenIDENT) // qualification name
return false;
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
}
return token == Symbols.TokenNEW;
}
@@ -1061,18 +1058,18 @@ public final class CHeuristicScanner implements Symbols {
/**
* Returns <code>true</code> if the document, when scanned backwards from <code>start</code>
- * appears to contain a field reference, i.e. a (optional) name preceded by a <code>.</code>
+ * appears to contain a field reference, i.e. a (optional) name preceded by a <code>.</code>
* or <code>-&gt;</code> or <code>::</code>.
- *
+ *
* @param start the position after the field reference operator.
* @param bound the first position in <code>fDocument</code> to not consider any more, with
* <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
* @return <code>true</code> if the current position looks like a field reference
*/
public boolean looksLikeFieldReferenceBackward(int start, int bound) {
- int token= previousToken(start - 1, bound);
+ int token = previousToken(start - 1, bound);
if (token == Symbols.TokenIDENT) { // field name
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
}
if (token == Symbols.TokenDOT) {
return true;
@@ -1084,11 +1081,11 @@ public final class CHeuristicScanner implements Symbols {
}
return false;
}
-
+
/**
* Returns <code>true</code> if the document, when scanned backwards from <code>start</code>
* appears to be a composite type (class, struct, union) or enum definition. Examples:
- *
+ *
* <pre>
* class A {
* struct A {
@@ -1096,21 +1093,21 @@ public final class CHeuristicScanner implements Symbols {
* class A : virtual public B, protected C&lt;T&gt; {
* enum E {
* </pre>
- *
+ *
* @param start the position of the opening brace.
* @param bound the first position in <code>fDocument</code> to not consider any more, with
* <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
* @return <code>true</code> if the current position looks like a composite type definition
*/
public boolean looksLikeCompositeTypeDefinitionBackward(int start, int bound) {
- int token= previousToken(start - 1, bound);
+ int token = previousToken(start - 1, bound);
switch (token) {
case Symbols.TokenSTRUCT:
case Symbols.TokenUNION:
case Symbols.TokenENUM:
return true; // anonymous
case Symbols.TokenIDENT:
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
switch (token) {
case Symbols.TokenCLASS:
case Symbols.TokenSTRUCT:
@@ -1119,56 +1116,56 @@ public final class CHeuristicScanner implements Symbols {
return true; // no base-clause
default:
// backtrack
- token= previousToken(start - 1, bound);
+ token = previousToken(start - 1, bound);
}
break;
default:
// backtrack
- token= previousToken(start - 1, bound);
+ token = previousToken(start - 1, bound);
break;
}
// match base-clause
if (token == Symbols.TokenGREATERTHAN) {
findOpeningPeer(getPosition(), bound, '<', '>');
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token != Symbols.TokenLESSTHAN) {
return false;
}
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
}
outerWhile: while (token == Symbols.TokenIDENT) {// type name or base type
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
// match nested-name-specifier
while (token == Symbols.TokenCOLON) { // colon of qualification
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token != Symbols.TokenCOLON) { // second colon of qualification
break outerWhile;
}
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token != Symbols.TokenIDENT) // qualification name?
break;
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
}
switch (token) {
case Symbols.TokenVIRTUAL:
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
//$FALL-THROUGH$
case Symbols.TokenPUBLIC:
case Symbols.TokenPROTECTED:
case Symbols.TokenPRIVATE:
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token == Symbols.TokenVIRTUAL) {
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
}
if (token == Symbols.TokenCOMMA) {
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token == Symbols.TokenGREATERTHAN) {
findOpeningPeer(getPosition(), bound, '<', '>');
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token != Symbols.TokenLESSTHAN) {
return false;
}
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
}
continue; // another base type
}
@@ -1176,17 +1173,17 @@ public final class CHeuristicScanner implements Symbols {
return false;
//$FALL-THROUGH$
case Symbols.TokenCOLON:
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
break outerWhile;
case Symbols.TokenCOMMA:
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token == Symbols.TokenGREATERTHAN) {
findOpeningPeer(getPosition(), bound, '<', '>');
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
if (token != Symbols.TokenLESSTHAN) {
return false;
}
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
}
continue; // another base type
case Symbols.TokenIDENT:
@@ -1198,12 +1195,12 @@ public final class CHeuristicScanner implements Symbols {
if (token != Symbols.TokenIDENT) {
return false;
}
- token= previousToken(getPosition(), bound);
+ token = previousToken(getPosition(), bound);
switch (token) {
case Symbols.TokenCLASS:
case Symbols.TokenSTRUCT:
case Symbols.TokenUNION:
- case Symbols.TokenENUM: // enum is actually not valid here
+ case Symbols.TokenENUM: // enum is actually not valid here
return true;
default:
return false;
@@ -1212,7 +1209,7 @@ public final class CHeuristicScanner implements Symbols {
/**
* A simplified interface to CHeuristicScanner's
- * nextToken() and previousToken() methods.
+ * nextToken() and previousToken() methods.
*/
public static class TokenStream {
private CHeuristicScanner fScanner;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java
index fc9c42a9b32..0832ea30b5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java
@@ -83,7 +83,7 @@ public final class CIndenter {
final boolean prefHasTemplates;
final String prefTabChar;
final boolean prefTabsOnlyForLeadingIndents;
-
+
private final IPreferencesService preferenceService;
private final IScopeContext[] preferenceContexts;
private final ICProject fProject;
@@ -108,45 +108,45 @@ public final class CIndenter {
CorePrefs(ICProject project) {
preferenceService = Platform.getPreferencesService();
- preferenceContexts = project != null ?
- new IScopeContext[] { new ProjectScope(project.getProject()),
- InstanceScope.INSTANCE, DefaultScope.INSTANCE } :
- new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE };
- fProject= project;
- prefUseTabs= prefUseTabs();
- prefTabSize= prefTabSize();
- prefIndentationSize= prefIndentationSize();
- prefArrayDimensionsDeepIndent= prefArrayDimensionsDeepIndent();
- prefContinuationIndent= prefContinuationIndent();
- prefBlockIndent= prefBlockIndent();
- prefArrayIndent= prefArrayIndent();
- prefArrayDeepIndent= prefArrayDeepIndent();
- prefTernaryDeepAlign= false;
- prefTernaryIndent= prefContinuationIndent();
- prefCaseIndent= prefCaseIndent();
- prefCaseBlockIndent= prefCaseBlockIndent();
- prefAssignmentIndent= prefAssignmentIndent();
- prefIndentBracesForBlocks= prefIndentBracesForBlocks();
- prefSimpleIndent= prefSimpleIndent();
- prefBracketIndent= prefBracketIndent();
- prefMethodDeclDeepIndent= prefMethodDeclDeepIndent();
- prefMethodDeclFirstParameterDeepIndent= prefMethodDeclFirstParameterDeepIndent();
- prefMethodDeclIndent= prefMethodDeclIndent();
- prefMethodCallDeepIndent= prefMethodCallDeepIndent();
- prefMethodCallFirstParameterDeepIndent= prefMethodCallFirstParameterDeepIndent();
- prefMethodCallIndent= prefMethodCallIndent();
- prefParenthesisDeepIndent= prefParenthesisDeepIndent();
- prefParenthesisIndent= prefParenthesisIndent();
- prefMethodBodyIndent= prefMethodBodyIndent();
- prefTypeIndent= prefTypeIndent();
- prefAccessSpecifierIndent= prefAccessSpecifierIndent();
- prefAccessSpecifierExtraSpaces= prefAccessSpecifierExtraSpaces();
- prefNamespaceBodyIndent= prefNamespaceBodyIndent();
- prefIndentBracesForArrays= prefIndentBracesForArrays();
- prefIndentBracesForMethods= prefIndentBracesForMethods();
- prefIndentBracesForTypes= prefIndentBracesForTypes();
- prefHasTemplates= hasTemplates();
- prefTabChar= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+ preferenceContexts = project != null
+ ? new IScopeContext[] { new ProjectScope(project.getProject()), InstanceScope.INSTANCE,
+ DefaultScope.INSTANCE }
+ : new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE };
+ fProject = project;
+ prefUseTabs = prefUseTabs();
+ prefTabSize = prefTabSize();
+ prefIndentationSize = prefIndentationSize();
+ prefArrayDimensionsDeepIndent = prefArrayDimensionsDeepIndent();
+ prefContinuationIndent = prefContinuationIndent();
+ prefBlockIndent = prefBlockIndent();
+ prefArrayIndent = prefArrayIndent();
+ prefArrayDeepIndent = prefArrayDeepIndent();
+ prefTernaryDeepAlign = false;
+ prefTernaryIndent = prefContinuationIndent();
+ prefCaseIndent = prefCaseIndent();
+ prefCaseBlockIndent = prefCaseBlockIndent();
+ prefAssignmentIndent = prefAssignmentIndent();
+ prefIndentBracesForBlocks = prefIndentBracesForBlocks();
+ prefSimpleIndent = prefSimpleIndent();
+ prefBracketIndent = prefBracketIndent();
+ prefMethodDeclDeepIndent = prefMethodDeclDeepIndent();
+ prefMethodDeclFirstParameterDeepIndent = prefMethodDeclFirstParameterDeepIndent();
+ prefMethodDeclIndent = prefMethodDeclIndent();
+ prefMethodCallDeepIndent = prefMethodCallDeepIndent();
+ prefMethodCallFirstParameterDeepIndent = prefMethodCallFirstParameterDeepIndent();
+ prefMethodCallIndent = prefMethodCallIndent();
+ prefParenthesisDeepIndent = prefParenthesisDeepIndent();
+ prefParenthesisIndent = prefParenthesisIndent();
+ prefMethodBodyIndent = prefMethodBodyIndent();
+ prefTypeIndent = prefTypeIndent();
+ prefAccessSpecifierIndent = prefAccessSpecifierIndent();
+ prefAccessSpecifierExtraSpaces = prefAccessSpecifierExtraSpaces();
+ prefNamespaceBodyIndent = prefNamespaceBodyIndent();
+ prefIndentBracesForArrays = prefIndentBracesForArrays();
+ prefIndentBracesForMethods = prefIndentBracesForMethods();
+ prefIndentBracesForTypes = prefIndentBracesForTypes();
+ prefHasTemplates = hasTemplates();
+ prefTabChar = getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
prefTabsOnlyForLeadingIndents = prefTabsOnlyForLeadingIndents();
}
@@ -167,7 +167,8 @@ public final class CIndenter {
}
private int prefArrayIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST);
try {
if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
return 1;
@@ -179,9 +180,11 @@ public final class CIndenter {
}
private boolean prefArrayDeepIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST);
try {
- return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+ return DefaultCodeFormatterConstants
+ .getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
} catch (IllegalArgumentException e) {
// ignore and return default
}
@@ -190,14 +193,16 @@ public final class CIndenter {
}
private int prefCaseIndent() {
- if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH)))
+ if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH)))
return 1;
else
return 0;
}
private int prefCaseBlockIndent() {
- if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES)))
+ if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES)))
return 1;
else
return 0;
@@ -219,7 +224,8 @@ public final class CIndenter {
}
private boolean prefMethodDeclDeepIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
try {
int indentStyle = DefaultCodeFormatterConstants.getIndentStyle(option);
return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
@@ -231,13 +237,14 @@ public final class CIndenter {
}
private boolean prefMethodDeclFirstParameterDeepIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
try {
int indentStyle = DefaultCodeFormatterConstants.getIndentStyle(option);
int wrappingStyle = DefaultCodeFormatterConstants.getWrappingStyle(option);
- return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN &&
- (wrappingStyle == DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK ||
- wrappingStyle == DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE);
+ return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN
+ && (wrappingStyle == DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK
+ || wrappingStyle == DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE);
} catch (IllegalArgumentException e) {
// ignore and return default
}
@@ -246,7 +253,8 @@ public final class CIndenter {
}
private int prefMethodDeclIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
try {
if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
return 1;
@@ -259,7 +267,8 @@ public final class CIndenter {
}
private boolean prefMethodCallDeepIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
try {
int indentStyle = DefaultCodeFormatterConstants.getIndentStyle(option);
return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
@@ -270,13 +279,14 @@ public final class CIndenter {
}
private boolean prefMethodCallFirstParameterDeepIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
try {
int indentStyle = DefaultCodeFormatterConstants.getIndentStyle(option);
int wrappingStyle = DefaultCodeFormatterConstants.getWrappingStyle(option);
- return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN &&
- (wrappingStyle == DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK ||
- wrappingStyle == DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE);
+ return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN
+ && (wrappingStyle == DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK
+ || wrappingStyle == DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE);
} catch (IllegalArgumentException e) {
// ignore and return default
}
@@ -284,7 +294,8 @@ public final class CIndenter {
}
private int prefMethodCallIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
try {
if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
return 1;
@@ -299,12 +310,12 @@ public final class CIndenter {
private boolean prefParenthesisDeepIndent() {
// don't do parenthesis deep indentation
-// String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
-// try {
-// return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
-// } catch (IllegalArgumentException e) {
-// // ignore and return default
-// }
+ // String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
+ // try {
+ // return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+ // } catch (IllegalArgumentException e) {
+ // // ignore and return default
+ // }
return false;
}
@@ -314,7 +325,8 @@ public final class CIndenter {
}
private int prefBlockIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
if (DefaultCodeFormatterConstants.FALSE.equals(option))
return 0;
@@ -322,71 +334,81 @@ public final class CIndenter {
}
private int prefMethodBodyIndent() {
- if (DefaultCodeFormatterConstants.FALSE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY)))
+ if (DefaultCodeFormatterConstants.FALSE.equals(
+ getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY)))
return 0;
return 1; // sensible default
}
private int prefTypeIndent() {
- String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER);
+ String option = getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER);
if (DefaultCodeFormatterConstants.FALSE.equals(option))
return 0;
return 1; // sensible default
}
-
+
private int prefAccessSpecifierIndent() {
- if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER)))
+ if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER)))
return 1;
else
return 0;
}
private int prefAccessSpecifierExtraSpaces() {
- return getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_EXTRA_SPACES, 0);
+ return getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_EXTRA_SPACES,
+ 0);
}
private int prefNamespaceBodyIndent() {
- if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_NAMESPACE_HEADER)))
+ if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_NAMESPACE_HEADER)))
return prefBlockIndent();
else
return 0;
}
private boolean prefIndentBracesForBlocks() {
- return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK));
+ return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED
+ .equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK));
}
private boolean prefIndentBracesForArrays() {
- return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST));
+ return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST));
}
private boolean prefIndentBracesForMethods() {
- return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION));
+ return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION));
}
private boolean prefIndentBracesForTypes() {
- return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION));
+ return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION));
}
private int prefContinuationIndent() {
try {
- return Integer.parseInt(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION));
+ return Integer.parseInt(
+ getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION));
} catch (NumberFormatException e) {
// ignore and return default
}
return 2; // sensible default
}
-
+
private boolean hasTemplates() {
return true;
}
private boolean prefTabsOnlyForLeadingIndents() {
- return DefaultCodeFormatterConstants.TRUE.equals(
- getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS));
+ return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(
+ DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS));
}
}
@@ -443,9 +465,9 @@ public final class CIndenter {
public CIndenter(IDocument document, CHeuristicScanner scanner, ICProject project) {
Assert.isNotNull(document);
Assert.isNotNull(scanner);
- fDocument= document;
- fScanner= scanner;
- fPrefs= new CorePrefs(project);
+ fDocument = document;
+ fScanner = scanner;
+ fPrefs = new CorePrefs(project);
}
/**
@@ -470,8 +492,7 @@ public final class CIndenter {
* if it cannot be determined
*/
private StringBuilder getReferenceIndentation(int offset, boolean assumeOpeningBrace) {
- int unit= findReferencePosition(offset,
- assumeOpeningBrace ? Symbols.TokenLBRACE : peekToken(offset));
+ int unit = findReferencePosition(offset, assumeOpeningBrace ? Symbols.TokenLBRACE : peekToken(offset));
// if we were unable to find anything, return null
if (unit == NOT_FOUND)
@@ -502,14 +523,14 @@ public final class CIndenter {
* determined
*/
public StringBuilder computeIndentation(int offset, boolean assumeOpeningBrace) {
- StringBuilder reference= getReferenceIndentation(offset, assumeOpeningBrace);
+ StringBuilder reference = getReferenceIndentation(offset, assumeOpeningBrace);
// handle special alignment
if (fAlign != NOT_FOUND) {
try {
// a special case has been detected.
- IRegion line= fDocument.getLineInformationOfOffset(fAlign);
- int lineOffset= line.getOffset();
+ IRegion line = fDocument.getLineInformationOfOffset(fAlign);
+ int lineOffset = line.getOffset();
return createIndent(lineOffset, fAlign, !fPrefs.prefTabsOnlyForLeadingIndents);
} catch (BadLocationException e) {
return null;
@@ -533,15 +554,15 @@ public final class CIndenter {
* @throws BadLocationException
*/
public StringBuilder computeContinuationLineIndentation(int offset) throws BadLocationException {
- StringBuilder reference= getLeadingWhitespace(offset);
- IRegion line= fDocument.getLineInformationOfOffset(offset);
- String string= fDocument.get(line.getOffset(), offset - line.getOffset());
+ StringBuilder reference = getLeadingWhitespace(offset);
+ IRegion line = fDocument.getLineInformationOfOffset(offset);
+ String string = fDocument.get(line.getOffset(), offset - line.getOffset());
if (string.trim().isEmpty())
return reference;
// Add additional indent
return createReusingIndent(reference, fPrefs.prefContinuationIndent, 0);
}
-
+
/**
* Computes the length of a <code>CharacterSequence</code>, counting
* a tab character as the size until the next tab stop and every other
@@ -551,14 +572,14 @@ public final class CIndenter {
* @return the visual length in characters
*/
private int computeVisualLength(CharSequence indent) {
- final int tabSize= fPrefs.prefTabSize;
- int length= 0;
- for (int i= 0; i < indent.length(); i++) {
- char ch= indent.charAt(i);
+ final int tabSize = fPrefs.prefTabSize;
+ int length = 0;
+ for (int i = 0; i < indent.length(); i++) {
+ char ch = indent.charAt(i);
switch (ch) {
case '\t':
if (tabSize > 0) {
- int reminder= length % tabSize;
+ int reminder = length % tabSize;
length += tabSize - reminder;
}
break;
@@ -579,16 +600,16 @@ public final class CIndenter {
* @return the stripped <code>reference</code>
*/
private StringBuilder stripExceedingChars(StringBuilder reference, int indentLength) {
- final int tabSize= fPrefs.prefTabSize;
- int measured= 0;
- int chars= reference.length();
- int i= 0;
+ final int tabSize = fPrefs.prefTabSize;
+ int measured = 0;
+ int chars = reference.length();
+ int i = 0;
for (; measured < indentLength && i < chars; i++) {
- char ch= reference.charAt(i);
+ char ch = reference.charAt(i);
switch (ch) {
case '\t':
if (tabSize > 0) {
- int reminder= measured % tabSize;
+ int reminder = measured % tabSize;
measured += tabSize - reminder;
}
break;
@@ -597,7 +618,7 @@ public final class CIndenter {
break;
}
}
- int deleteFrom= measured > indentLength ? i - 1 : i;
+ int deleteFrom = measured > indentLength ? i - 1 : i;
return reference.delete(deleteFrom, chars);
}
@@ -612,11 +633,11 @@ public final class CIndenter {
* <code>offset</code> is located
*/
private StringBuilder getLeadingWhitespace(int offset) {
- StringBuilder indent= new StringBuilder();
+ StringBuilder indent = new StringBuilder();
try {
- IRegion line= fDocument.getLineInformationOfOffset(offset);
- int lineOffset= line.getOffset();
- int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, lineOffset + line.getLength());
+ IRegion line = fDocument.getLineInformationOfOffset(offset);
+ int lineOffset = line.getOffset();
+ int nonWS = fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, lineOffset + line.getLength());
indent.append(fDocument.get(lineOffset, nonWS - lineOffset));
return indent;
} catch (BadLocationException e) {
@@ -645,21 +666,21 @@ public final class CIndenter {
* by <code>start</code> and <code>indent</code>
*/
private StringBuilder createIndent(int start, final int indent, final boolean convertSpaceRunsToTabs) {
- final boolean convertTabs= fPrefs.prefUseTabs && convertSpaceRunsToTabs;
- final int tabLen= fPrefs.prefTabSize;
- final StringBuilder ret= new StringBuilder();
+ final boolean convertTabs = fPrefs.prefUseTabs && convertSpaceRunsToTabs;
+ final int tabLen = fPrefs.prefTabSize;
+ final StringBuilder ret = new StringBuilder();
try {
- int spaces= 0;
+ int spaces = 0;
while (start < indent) {
- char ch= fDocument.getChar(start);
+ char ch = fDocument.getChar(start);
if (ch == '\t') {
ret.append('\t');
- spaces= 0;
+ spaces = 0;
} else if (convertTabs) {
spaces++;
if (spaces == tabLen) {
ret.append('\t');
- spaces= 0;
+ spaces = 0;
}
} else {
ret.append(' ');
@@ -688,30 +709,30 @@ public final class CIndenter {
* adapted to <code>additional</code>
*/
public StringBuilder createReusingIndent(StringBuilder buffer, int additional, int extraSpaces) {
- int refLength= computeVisualLength(buffer);
- int addLength= fPrefs.prefIndentationSize * additional + extraSpaces; // may be < 0
- int totalLength= Math.max(0, refLength + addLength);
+ int refLength = computeVisualLength(buffer);
+ int addLength = fPrefs.prefIndentationSize * additional + extraSpaces; // may be < 0
+ int totalLength = Math.max(0, refLength + addLength);
// copy the reference indentation for the indent up to the last tab
// stop within the maxCopy area
- int minLength= Math.min(totalLength, refLength);
- int tabSize= fPrefs.prefTabSize;
- int maxCopyLength= tabSize > 0 ? minLength - minLength % tabSize : minLength; // maximum indent to copy
+ int minLength = Math.min(totalLength, refLength);
+ int tabSize = fPrefs.prefTabSize;
+ int maxCopyLength = tabSize > 0 ? minLength - minLength % tabSize : minLength; // maximum indent to copy
stripExceedingChars(buffer, maxCopyLength);
// add additional indent
- int missing= totalLength - maxCopyLength;
+ int missing = totalLength - maxCopyLength;
final int tabs, spaces;
if (CCorePlugin.SPACE.equals(fPrefs.prefTabChar)) {
- tabs= 0;
- spaces= missing;
+ tabs = 0;
+ spaces = missing;
} else {
- tabs= tabSize > 0 ? missing / tabSize : 0;
- spaces= tabSize > 0 ? missing % tabSize : missing;
+ tabs = tabSize > 0 ? missing / tabSize : 0;
+ spaces = tabSize > 0 ? missing % tabSize : missing;
}
- for (int i= 0; i < tabs; i++)
+ for (int i = 0; i < tabs; i++)
buffer.append('\t');
- for (int i= 0; i < spaces; i++)
+ for (int i = 0; i < spaces; i++)
buffer.append(' ');
return buffer;
}
@@ -748,9 +769,9 @@ public final class CIndenter {
private int peekToken(int offset) {
if (offset < fDocument.getLength()) {
try {
- IRegion line= fDocument.getLineInformationOfOffset(offset);
- int lineEnd= line.getOffset() + line.getLength();
- int next= fScanner.nextToken(offset, lineEnd);
+ IRegion line = fDocument.getLineInformationOfOffset(offset);
+ int lineEnd = line.getOffset() + line.getLength();
+ int next = fScanner.nextToken(offset, lineEnd);
return next;
} catch (BadLocationException e) {
}
@@ -768,8 +789,8 @@ public final class CIndenter {
private int peekSecondToken(int offset) {
if (offset < fDocument.getLength()) {
try {
- IRegion line= fDocument.getLineInformationOfOffset(offset);
- int lineEnd= line.getOffset() + line.getLength();
+ IRegion line = fDocument.getLineInformationOfOffset(offset);
+ int lineEnd = line.getOffset() + line.getLength();
fScanner.nextToken(offset, lineEnd);
int next = fScanner.nextToken(fScanner.getPosition(), lineEnd);
return next;
@@ -806,9 +827,9 @@ public final class CIndenter {
* should be indented, or {@link CHeuristicScanner#NOT_FOUND NOT_FOUND}
*/
public int findReferencePosition(int offset, int nextToken) {
- boolean danglingElse= false;
- boolean cancelIndent= false; // If set to true, fIndent is ignored.
- int extraIndent= 0; // Can be either positive or negative.
+ boolean danglingElse = false;
+ boolean cancelIndent = false; // If set to true, fIndent is ignored.
+ int extraIndent = 0; // Can be either positive or negative.
MatchMode matchMode = MatchMode.REGULAR;
// Account for un-indentation characters already typed in, but after position.
@@ -817,45 +838,45 @@ public final class CIndenter {
// Also account for a dangling else.
if (offset < fDocument.getLength()) {
try {
- IRegion line= fDocument.getLineInformationOfOffset(offset);
- int lineOffset= line.getOffset();
- int prevPos= Math.max(offset - 1, 0);
- boolean isFirstTokenOnLine=
- fDocument.get(lineOffset, prevPos + 1 - lineOffset).trim().length() == 0;
- int prevToken= fScanner.previousToken(prevPos, CHeuristicScanner.UNBOUND);
- boolean bracelessBlockStart= fScanner.isBracelessBlockStart(prevPos, CHeuristicScanner.UNBOUND);
+ IRegion line = fDocument.getLineInformationOfOffset(offset);
+ int lineOffset = line.getOffset();
+ int prevPos = Math.max(offset - 1, 0);
+ boolean isFirstTokenOnLine = fDocument.get(lineOffset, prevPos + 1 - lineOffset).trim().length() == 0;
+ int prevToken = fScanner.previousToken(prevPos, CHeuristicScanner.UNBOUND);
+ boolean bracelessBlockStart = fScanner.isBracelessBlockStart(prevPos, CHeuristicScanner.UNBOUND);
switch (nextToken) {
case Symbols.TokenELSE:
- danglingElse= true;
+ danglingElse = true;
break;
-
+
case Symbols.TokenCASE:
case Symbols.TokenDEFAULT:
if (isFirstTokenOnLine)
matchMode = MatchMode.MATCH_CASE;
break;
-
+
case Symbols.TokenPUBLIC:
case Symbols.TokenPROTECTED:
case Symbols.TokenPRIVATE:
if (isFirstTokenOnLine && peekSecondToken(offset) != Symbols.TokenIDENT)
matchMode = MatchMode.MATCH_ACCESS_SPECIFIER;
break;
-
+
case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
if (bracelessBlockStart) {
- extraIndent= fPrefs.prefIndentBracesForBlocks ? 0 : -1;
+ extraIndent = fPrefs.prefIndentBracesForBlocks ? 0 : -1;
} else if (prevToken == Symbols.TokenCOLON && !fPrefs.prefIndentBracesForBlocks) {
- extraIndent= -1;
- } else if ((prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET) &&
- !fPrefs.prefIndentBracesForArrays) {
- cancelIndent= true;
- } else if ((prevToken == Symbols.TokenRPAREN || prevToken == Symbols.TokenCONST) && fPrefs.prefIndentBracesForMethods) {
- extraIndent= 1;
+ extraIndent = -1;
+ } else if ((prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET)
+ && !fPrefs.prefIndentBracesForArrays) {
+ cancelIndent = true;
+ } else if ((prevToken == Symbols.TokenRPAREN || prevToken == Symbols.TokenCONST)
+ && fPrefs.prefIndentBracesForMethods) {
+ extraIndent = 1;
} else if (prevToken == Symbols.TokenIDENT) {
if (fPrefs.prefIndentBracesForTypes) {
- extraIndent= 1;
+ extraIndent = 1;
}
int pos = fPosition;
fPosition = offset;
@@ -865,12 +886,12 @@ public final class CIndenter {
fPosition = pos;
}
break;
-
+
case Symbols.TokenRBRACE: // closing braces get unindented
if (isFirstTokenOnLine || prevToken != Symbols.TokenLBRACE)
matchMode = MatchMode.MATCH_BRACE;
break;
-
+
case Symbols.TokenRPAREN:
if (isFirstTokenOnLine)
matchMode = MatchMode.MATCH_PAREN;
@@ -880,14 +901,14 @@ public final class CIndenter {
}
} else {
// Don't assume an else could come if we are at the end of file.
- danglingElse= false;
+ danglingElse = false;
}
- int ref= findReferencePosition(offset, danglingElse, matchMode);
+ int ref = findReferencePosition(offset, danglingElse, matchMode);
if (cancelIndent) {
fIndent = 0;
} else if (extraIndent > 0) {
- fAlign= NOT_FOUND;
+ fAlign = NOT_FOUND;
fIndent += extraIndent;
} else {
fIndent += extraIndent;
@@ -909,7 +930,7 @@ public final class CIndenter {
MATCH_BRACE,
/**
* The position of the matching parenthesis should be returned instead of doing code
- * analysis.
+ * analysis.
*/
MATCH_PAREN,
/**
@@ -945,10 +966,10 @@ public final class CIndenter {
* should be indented, or {@link CHeuristicScanner#NOT_FOUND}
*/
public int findReferencePosition(int offset, boolean danglingElse, MatchMode matchMode) {
- fIndent= 0; // The indentation modification
- fExtraSpaces= 0;
- fAlign= NOT_FOUND;
- fPosition= offset;
+ fIndent = 0; // The indentation modification
+ fExtraSpaces = 0;
+ fAlign = NOT_FOUND;
+ fPosition = offset;
// Forward cases.
// An unindentation happens sometimes if the next token is special, namely on braces,
@@ -959,22 +980,21 @@ public final class CIndenter {
if (skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE)) {
try {
// Align with the opening brace that is on a line by its own
- int lineOffset= fDocument.getLineOffset(fLine);
- if (lineOffset <= fPosition &&
- fDocument.get(lineOffset, fPosition - lineOffset).trim().isEmpty()) {
+ int lineOffset = fDocument.getLineOffset(fLine);
+ if (lineOffset <= fPosition && fDocument.get(lineOffset, fPosition - lineOffset).trim().isEmpty()) {
return fPosition;
}
} catch (BadLocationException e) {
// Concurrent modification - walk default path
}
// If the opening brace is not on the start of the line, skip to the start.
- int pos= skipToStatementStart(true, true);
- fIndent= 0; // indent is aligned with reference position
+ int pos = skipToStatementStart(true, true);
+ fIndent = 0; // indent is aligned with reference position
return pos;
} else {
// If we can't find the matching brace, the heuristic is to unindent
// by one against the normal position
- int pos= findReferencePosition(offset, danglingElse, MatchMode.REGULAR);
+ int pos = findReferencePosition(offset, danglingElse, MatchMode.REGULAR);
fIndent--;
return pos;
}
@@ -986,7 +1006,7 @@ public final class CIndenter {
} else {
// If we can't find the matching paren, the heuristic is to unindent by one
// against the normal position.
- int pos= findReferencePosition(offset, danglingElse, MatchMode.REGULAR);
+ int pos = findReferencePosition(offset, danglingElse, MatchMode.REGULAR);
fIndent--;
return pos;
}
@@ -1011,7 +1031,7 @@ public final class CIndenter {
}
if (peekToken(offset) == Symbols.TokenCOLON) {
- int pos= fPosition;
+ int pos = fPosition;
if (looksLikeTypeInheritanceDecl()) {
fIndent = fPrefs.prefContinuationIndent;
return fPosition;
@@ -1025,15 +1045,15 @@ public final class CIndenter {
nextToken();
}
- int line= fLine;
+ int line = fLine;
switch (fToken) {
case Symbols.TokenGREATERTHAN:
case Symbols.TokenRBRACE:
// Skip the block and fall through.
// If we can't complete the scope, reset the scan position
- int pos= fPosition;
+ int pos = fPosition;
if (!skipScope())
- fPosition= pos;
+ fPosition = pos;
return skipToStatementStart(danglingElse, false);
case Symbols.TokenSEMICOLON:
@@ -1055,39 +1075,39 @@ public final class CIndenter {
case Symbols.TokenEQUAL:
// indent assignments
- fIndent= fPrefs.prefAssignmentIndent;
+ fIndent = fPrefs.prefAssignmentIndent;
return fPosition;
case Symbols.TokenCOLON:
- pos= fPosition;
+ pos = fPosition;
if (looksLikeCaseStatement()) {
- fIndent= fPrefs.prefCaseBlockIndent;
+ fIndent = fPrefs.prefCaseBlockIndent;
return pos;
}
- fPosition= pos;
+ fPosition = pos;
if (looksLikeTypeInheritanceDecl()) {
- fIndent= fPrefs.prefContinuationIndent;
+ fIndent = fPrefs.prefContinuationIndent;
return pos;
}
- fPosition= pos;
+ fPosition = pos;
if (looksLikeConstructorInitializer()) {
- fIndent= fPrefs.prefBlockIndent;
+ fIndent = fPrefs.prefBlockIndent;
return pos;
}
- fPosition= pos;
+ fPosition = pos;
if (isConditional()) {
- fPosition= offset;
- fLine= line;
+ fPosition = offset;
+ fLine = line;
return skipToPreviousListItemOrListStart();
}
- fPosition= pos;
+ fPosition = pos;
return skipToPreviousListItemOrListStart();
case Symbols.TokenQUESTIONMARK:
if (fPrefs.prefTernaryDeepAlign) {
setFirstElementAlignment(fPosition, offset + 1);
} else {
- fIndent= fPrefs.prefTernaryIndent;
+ fIndent = fPrefs.prefTernaryIndent;
}
return fPosition;
@@ -1095,7 +1115,7 @@ public final class CIndenter {
case Symbols.TokenDO:
case Symbols.TokenWHILE:
case Symbols.TokenELSE:
- fIndent= fPrefs.prefSimpleIndent;
+ fIndent = fPrefs.prefSimpleIndent;
return fPosition;
case Symbols.TokenTRY:
@@ -1116,16 +1136,16 @@ public final class CIndenter {
//$FALL-THROUGH$
case Symbols.TokenRPAREN:
if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN)) {
- int scope= fPosition;
+ int scope = fPosition;
nextToken();
if (fToken == Symbols.TokenIF || fToken == Symbols.TokenWHILE || fToken == Symbols.TokenFOR) {
- fIndent= fPrefs.prefSimpleIndent;
+ fIndent = fPrefs.prefSimpleIndent;
return fPosition;
}
if (fToken == Symbols.TokenSWITCH) {
return fPosition;
}
- fPosition= scope;
+ fPosition = scope;
// "noexcept" at this point would be a noexcept-with-argument, which should be
// attached to a method declaration:
if (looksLikeMethodDecl() || fToken == Symbols.TokenNOEXCEPT) {
@@ -1134,14 +1154,14 @@ public final class CIndenter {
if (fToken == Symbols.TokenCATCH) {
return skipToStatementStart(danglingElse, false);
}
- fPosition= scope;
+ fPosition = scope;
if (looksLikeAnonymousTypeDecl()) {
return skipToStatementStart(danglingElse, false);
}
}
// restore
- fPosition= offset;
- fLine= line;
+ fPosition = offset;
+ fLine = line;
// else: fall through to default
return skipToPreviousListItemOrListStart();
@@ -1177,20 +1197,15 @@ public final class CIndenter {
private int matchTypeDeclaration() {
while (true) {
nextToken();
- if (fToken == Symbols.TokenIDENT
- || fToken == Symbols.TokenCOMMA
- || fToken == Symbols.TokenCOLON
- || fToken == Symbols.TokenPUBLIC
- || fToken == Symbols.TokenPROTECTED
+ if (fToken == Symbols.TokenIDENT || fToken == Symbols.TokenCOMMA || fToken == Symbols.TokenCOLON
+ || fToken == Symbols.TokenPUBLIC || fToken == Symbols.TokenPROTECTED
|| fToken == Symbols.TokenPRIVATE) {
continue;
}
- if (fToken == Symbols.TokenCLASS
- || fToken == Symbols.TokenSTRUCT
- || fToken == Symbols.TokenUNION) {
+ if (fToken == Symbols.TokenCLASS || fToken == Symbols.TokenSTRUCT || fToken == Symbols.TokenUNION) {
// inside a type declaration? Only so if not preceded by '(' or ',' as in
// a parameter list. To be safe, only accept ';' or EOF
- int pos= fPosition;
+ int pos = fPosition;
nextToken();
if (fToken == Symbols.TokenSEMICOLON || fToken == Symbols.TokenEOF) {
return pos;
@@ -1205,7 +1220,7 @@ public final class CIndenter {
/**
* Test whether the colon at the current position marks a case statement
- *
+ *
* @return <code>true</code> if this looks like a case statement
*/
private boolean looksLikeCaseStatement() {
@@ -1240,7 +1255,7 @@ public final class CIndenter {
/**
* Test whether the colon at the current position marks a type inheritance decl.
- *
+ *
* @return <code>true</code> if this looks like a type inheritance decl.
*/
private boolean looksLikeTypeInheritanceDecl() {
@@ -1264,7 +1279,7 @@ public final class CIndenter {
/**
* Test whether the colon at the current position marks a constructor initializer list.
- *
+ *
* @return <code>true</code> if this looks like a constructor initializer list.
*/
private boolean looksLikeConstructorInitializer() {
@@ -1294,15 +1309,15 @@ public final class CIndenter {
case Symbols.TokenCOLON:
nextToken();
switch (fToken) {
- case Symbols.TokenCOLON: // A::A() :
- case Symbols.TokenPUBLIC: // public: A() :
+ case Symbols.TokenCOLON: // A::A() :
+ case Symbols.TokenPUBLIC: // public: A() :
case Symbols.TokenPROTECTED:
case Symbols.TokenPRIVATE:
return true;
}
return false;
-
- case Symbols.TokenLBRACE: // class A { A() :
+
+ case Symbols.TokenLBRACE: // class A { A() :
case Symbols.TokenRBRACE:
case Symbols.TokenSEMICOLON:
return true;
@@ -1312,7 +1327,7 @@ public final class CIndenter {
/**
* Test whether the left brace at the current position marks an enum decl.
- *
+ *
* @return <code>true</code> if this looks like an enum decl.
*/
private boolean looksLikeEnumDeclaration() {
@@ -1332,14 +1347,13 @@ public final class CIndenter {
return false;
}
-
/**
* Test whether the colon at the current position marks an access specifier.
- *
+ *
* @return <code>true</code> if current position marks an access specifier
*/
private boolean isAccessSpecifier() {
- int pos= fPosition;
+ int pos = fPosition;
int token = fToken;
nextToken();
switch (fToken) {
@@ -1349,7 +1363,7 @@ public final class CIndenter {
return true;
}
fToken = token;
- fPosition= pos;
+ fPosition = pos;
return false;
}
@@ -1362,14 +1376,14 @@ public final class CIndenter {
* @return the reference offset of the start of the statement
*/
private int skipToStatementStart(boolean danglingElse, boolean isInBlock) {
- final int NOTHING= 0;
- final int READ_PARENS= 1;
- final int READ_IDENT= 2;
- int mayBeMethodBody= NOTHING;
- boolean isTypeBody= false;
+ final int NOTHING = 0;
+ final int READ_PARENS = 1;
+ final int READ_IDENT = 2;
+ int mayBeMethodBody = NOTHING;
+ boolean isTypeBody = false;
int startLine = fLine;
while (true) {
- int prevToken= fToken;
+ int prevToken = fToken;
nextToken();
if (isInBlock) {
@@ -1387,11 +1401,11 @@ public final class CIndenter {
case Symbols.TokenCLASS:
case Symbols.TokenSTRUCT:
case Symbols.TokenUNION:
- isTypeBody= true;
+ isTypeBody = true;
break;
case Symbols.TokenSWITCH:
- fIndent= fPrefs.prefCaseIndent;
+ fIndent = fPrefs.prefCaseIndent;
return fPosition;
}
}
@@ -1408,7 +1422,7 @@ public final class CIndenter {
// -> the next token is the start of the statement (i.e. previousPos when backward scanning)
case Symbols.TokenLPAREN:
if (peekToken() == Symbols.TokenFOR) {
- nextToken(); // Consume 'for'
+ nextToken(); // Consume 'for'
fIndent = fPrefs.prefContinuationIndent;
return fPosition;
}
@@ -1418,7 +1432,7 @@ public final class CIndenter {
case Symbols.TokenSEMICOLON:
case Symbols.TokenEOF:
if (isInBlock)
- fIndent= getBlockIndent(mayBeMethodBody == READ_IDENT, isTypeBody);
+ fIndent = getBlockIndent(mayBeMethodBody == READ_IDENT, isTypeBody);
return fPreviousPos;
case Symbols.TokenCOLON:
@@ -1438,7 +1452,7 @@ public final class CIndenter {
continue;
}
}
- int pos= fPreviousPos;
+ int pos = fPreviousPos;
if (!isConditional())
return pos;
break;
@@ -1446,7 +1460,7 @@ public final class CIndenter {
case Symbols.TokenRBRACE:
// RBRACE is a little tricky: it can be the end of an array definition, but
// usually it is the end of a previous block
- pos= fPreviousPos; // store state
+ pos = fPreviousPos; // store state
if (skipScope()) {
if (looksLikeArrayInitializerIntro()) {
continue; // it's an array
@@ -1457,29 +1471,29 @@ public final class CIndenter {
}
}
if (isInBlock)
- fIndent= getBlockIndent(mayBeMethodBody == READ_IDENT, isTypeBody);
+ fIndent = getBlockIndent(mayBeMethodBody == READ_IDENT, isTypeBody);
return pos; // it's not - do as with all the above
// scopes: skip them
case Symbols.TokenRPAREN:
if (isInBlock)
- mayBeMethodBody= READ_PARENS;
+ mayBeMethodBody = READ_PARENS;
// fall thru
- pos= fPreviousPos;
+ pos = fPreviousPos;
if (skipScope())
break;
else
return pos;
case Symbols.TokenRBRACKET:
- pos= fPreviousPos;
+ pos = fPreviousPos;
if (skipScope())
break;
else
return pos;
- // IF / ELSE: align the position after the conditional block with the if
- // so we are ready for an else, except if danglingElse is false
- // in order for this to work, we must skip an else to its if
+ // IF / ELSE: align the position after the conditional block with the if
+ // so we are ready for an else, except if danglingElse is false
+ // in order for this to work, we must skip an else to its if
case Symbols.TokenIF:
if (danglingElse)
return fPosition;
@@ -1487,7 +1501,7 @@ public final class CIndenter {
break;
case Symbols.TokenELSE:
// skip behind the next if, as we have that one covered
- pos= fPosition;
+ pos = fPosition;
if (skipNextIF())
break;
else
@@ -1500,18 +1514,18 @@ public final class CIndenter {
case Symbols.TokenWHILE:
// this one is tricky: while can be the start of a while loop
// or the end of a do - while
- pos= fPosition;
+ pos = fPosition;
if (hasMatchingDo()) {
// continue searching from the DO on
break;
} else {
// continue searching from the WHILE on
- fPosition= pos;
+ fPosition = pos;
break;
}
case Symbols.TokenIDENT:
if (mayBeMethodBody == READ_PARENS)
- mayBeMethodBody= READ_IDENT;
+ mayBeMethodBody = READ_IDENT;
break;
default:
@@ -1538,7 +1552,7 @@ public final class CIndenter {
*/
private boolean isConditional() {
while (true) {
- int previous= fToken;
+ int previous = fToken;
nextToken();
switch (fToken) {
// search for case labels, which consist of (possibly qualified) identifiers or numbers
@@ -1553,10 +1567,10 @@ public final class CIndenter {
case Symbols.TokenMINUS:
case Symbols.TokenPLUS:
continue;
-
+
case Symbols.TokenQUESTIONMARK:
return true;
-
+
case Symbols.TokenSEMICOLON:
case Symbols.TokenLBRACE:
case Symbols.TokenRBRACE:
@@ -1594,16 +1608,16 @@ public final class CIndenter {
case Symbols.TokenLBRACKET:
case Symbols.TokenEOF:
return fPosition;
-
+
case Symbols.TokenSWITCH:
// start of switch statement
- fIndent= fPrefs.prefCaseIndent;
+ fIndent = fPrefs.prefCaseIndent;
return fPosition;
-
+
case Symbols.TokenCASE:
case Symbols.TokenDEFAULT:
// align with previous label
- fIndent= 0;
+ fIndent = 0;
return fPosition;
// scopes: skip them
@@ -1639,12 +1653,12 @@ public final class CIndenter {
case Symbols.TokenLBRACKET:
case Symbols.TokenEOF:
return fPosition;
-
+
case Symbols.TokenLBRACE:
// opening brace of class body
- int pos= fPosition;
- int typeDeclPos= matchTypeDeclaration();
- fIndent= fPrefs.prefAccessSpecifierIndent;
+ int pos = fPosition;
+ int typeDeclPos = matchTypeDeclaration();
+ fIndent = fPrefs.prefAccessSpecifierIndent;
fExtraSpaces = fPrefs.prefAccessSpecifierExtraSpaces;
if (typeDeclPos != NOT_FOUND) {
return typeDeclPos;
@@ -1654,7 +1668,7 @@ public final class CIndenter {
case Symbols.TokenPROTECTED:
case Symbols.TokenPRIVATE:
// align with previous access specifier
- fIndent= 0;
+ fIndent = 0;
return fPosition;
// scopes: skip them
@@ -1682,12 +1696,11 @@ public final class CIndenter {
* that has its own indentation, or the list introduction start.
*/
private int skipToPreviousListItemOrListStart() {
- int startLine= fLine;
- int startPosition= fPosition;
+ int startLine = fLine;
+ int startPosition = fPosition;
int linesSkippedInsideScopes = 0;
- boolean continuationLineCandidate =
- fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT ||
- fToken == Symbols.TokenRPAREN;
+ boolean continuationLineCandidate = fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT
+ || fToken == Symbols.TokenRPAREN;
while (true) {
int previous = fToken;
nextToken();
@@ -1695,17 +1708,18 @@ public final class CIndenter {
// If any line item comes with its own indentation, adapt to it
if (fLine < startLine - linesSkippedInsideScopes) {
try {
- int lineOffset= fDocument.getLineOffset(startLine);
- int bound= Math.min(fDocument.getLength(), startPosition + 1);
- if ((fToken == Symbols.TokenSEMICOLON || fToken == Symbols.TokenRBRACE ||
- fToken == Symbols.TokenLBRACE && !looksLikeArrayInitializerIntro() && !looksLikeEnumDeclaration()) &&
- continuationLineCandidate) {
+ int lineOffset = fDocument.getLineOffset(startLine);
+ int bound = Math.min(fDocument.getLength(), startPosition + 1);
+ if ((fToken == Symbols.TokenSEMICOLON || fToken == Symbols.TokenRBRACE
+ || fToken == Symbols.TokenLBRACE && !looksLikeArrayInitializerIntro()
+ && !looksLikeEnumDeclaration())
+ && continuationLineCandidate) {
fIndent = fPrefs.prefContinuationIndent;
} else {
- fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, bound);
- // If the reference line starts with a colon, skip the colon.
+ fAlign = fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, bound);
+ // If the reference line starts with a colon, skip the colon.
if (peekToken(fAlign) == Symbols.TokenCOLON) {
- fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(fAlign + 1, bound);
+ fAlign = fScanner.findNonWhitespaceForwardInAnyPartition(fAlign + 1, bound);
}
}
} catch (BadLocationException e) {
@@ -1739,7 +1753,7 @@ public final class CIndenter {
if (fPrefs.prefTernaryDeepAlign) {
setFirstElementAlignment(fPosition - 1, fPosition + 1);
} else {
- fIndent= fPrefs.prefTernaryIndent;
+ fIndent = fPrefs.prefTernaryIndent;
}
return fPosition;
@@ -1794,29 +1808,29 @@ public final class CIndenter {
case Symbols.TokenGREATERTHAN:
if (!fPrefs.prefHasTemplates)
return false;
- int storedPosition= fPosition;
- int storedToken= fToken;
+ int storedPosition = fPosition;
+ int storedToken = fToken;
nextToken();
switch (fToken) {
- case Symbols.TokenIDENT:
- fPosition = storedPosition;
- if (skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN))
- return true;
- break;
- case Symbols.TokenQUESTIONMARK:
- case Symbols.TokenGREATERTHAN:
- fPosition = storedPosition;
- if (skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN))
- return true;
- break;
+ case Symbols.TokenIDENT:
+ fPosition = storedPosition;
+ if (skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN))
+ return true;
+ break;
+ case Symbols.TokenQUESTIONMARK:
+ case Symbols.TokenGREATERTHAN:
+ fPosition = storedPosition;
+ if (skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN))
+ return true;
+ break;
}
// <> are harder to detect - restore the position if we fail
- fPosition= storedPosition;
- fToken= storedToken;
+ fPosition = storedPosition;
+ fToken = storedToken;
return false;
default:
- // programming error
+ // programming error
Assert.isTrue(false);
return false;
}
@@ -1851,7 +1865,7 @@ public final class CIndenter {
* @return the indent
*/
private int handleScopeIntroduction(int bound, boolean firstToken) {
- int pos= fPosition; // store
+ int pos = fPosition; // store
switch (fToken) {
// scope introduction: special treat who special is
@@ -1861,16 +1875,16 @@ public final class CIndenter {
if (firstToken ? fPrefs.prefMethodDeclFirstParameterDeepIndent : fPrefs.prefMethodDeclDeepIndent) {
return setFirstElementAlignment(pos, bound);
} else {
- fIndent= fPrefs.prefMethodDeclIndent;
+ fIndent = fPrefs.prefMethodDeclIndent;
return pos;
}
} else {
- fPosition= pos;
+ fPosition = pos;
if (looksLikeMethodCall()) {
if (firstToken ? fPrefs.prefMethodCallFirstParameterDeepIndent : fPrefs.prefMethodCallDeepIndent) {
return setFirstElementAlignment(pos, bound);
} else {
- fIndent= fPrefs.prefMethodCallIndent;
+ fIndent = fPrefs.prefMethodCallIndent;
return pos;
}
} else if (fPrefs.prefParenthesisDeepIndent) {
@@ -1879,34 +1893,34 @@ public final class CIndenter {
}
// normal: return the parenthesis as reference
- fIndent= fPrefs.prefParenthesisIndent;
+ fIndent = fPrefs.prefParenthesisIndent;
return pos;
case Symbols.TokenLBRACE:
- final boolean looksLikeArrayInitializerIntro= looksLikeArrayInitializerIntro();
+ final boolean looksLikeArrayInitializerIntro = looksLikeArrayInitializerIntro();
// special: array initializer
if (looksLikeArrayInitializerIntro) {
if (fPrefs.prefArrayDeepIndent)
return setFirstElementAlignment(pos, bound);
else
- fIndent= fPrefs.prefArrayIndent;
+ fIndent = fPrefs.prefArrayIndent;
} else if (isNamespace() || isLinkageSpec()) {
- fIndent= fPrefs.prefNamespaceBodyIndent;
+ fIndent = fPrefs.prefNamespaceBodyIndent;
} else if (looksLikeEnumDeclaration()) {
fIndent = fPrefs.prefTypeIndent;
} else {
int typeDeclPos = matchTypeDeclaration();
if (typeDeclPos == NOT_FOUND) {
- fIndent= fPrefs.prefBlockIndent;
+ fIndent = fPrefs.prefBlockIndent;
} else {
- fIndent= fPrefs.prefAccessSpecifierIndent + fPrefs.prefTypeIndent;
+ fIndent = fPrefs.prefAccessSpecifierIndent + fPrefs.prefTypeIndent;
}
}
// normal: skip to the statement start before the scope introducer
// opening braces are often on differently ending indents than e.g. a method definition
if (!looksLikeArrayInitializerIntro) {
- fPosition= pos; // restore
+ fPosition = pos; // restore
return skipToStatementStart(true, true); // set to true to match the first if
} else {
return pos;
@@ -1919,7 +1933,7 @@ public final class CIndenter {
}
// normal: return the bracket as reference
- fIndent= fPrefs.prefBracketIndent;
+ fIndent = fPrefs.prefBracketIndent;
return pos; // restore
default:
@@ -1940,15 +1954,15 @@ public final class CIndenter {
* @return the reference position
*/
private int setFirstElementAlignment(int scopeIntroducerOffset, int bound) {
- int firstPossible= scopeIntroducerOffset + 1; // align with the first position after the scope intro
- fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(firstPossible, bound);
+ int firstPossible = scopeIntroducerOffset + 1; // align with the first position after the scope intro
+ fAlign = fScanner.findNonWhitespaceForwardInAnyPartition(firstPossible, bound);
if (fAlign == NOT_FOUND) {
- fAlign= firstPossible;
+ fAlign = firstPossible;
} else {
try {
IRegion lineRegion = fDocument.getLineInformationOfOffset(scopeIntroducerOffset);
if (fAlign > lineRegion.getOffset() + lineRegion.getLength()) {
- fAlign= firstPossible;
+ fAlign = firstPossible;
}
} catch (BadLocationException e) {
// Ignore.
@@ -1965,7 +1979,7 @@ public final class CIndenter {
* @return <code>true</code> if the next elements look like the start of an array definition
*/
private boolean looksLikeArrayInitializerIntro() {
- int pos= fPosition;
+ int pos = fPosition;
nextToken();
switch (fToken) {
case Symbols.TokenEQUAL:
@@ -1974,15 +1988,15 @@ public final class CIndenter {
return skipBrackets();
case Symbols.TokenLBRACE:
if (looksLikeArrayInitializerIntro()) {
- fPosition= pos;
+ fPosition = pos;
return true;
}
return false;
case Symbols.TokenCOMMA:
- fPosition= pos;
+ fPosition = pos;
return true;
}
- fPosition= pos;
+ fPosition = pos;
return false;
}
@@ -1997,12 +2011,12 @@ public final class CIndenter {
nextToken();
if (fToken == Symbols.TokenNAMESPACE) {
fPosition = pos;
- return true; // Anonymous namespace
+ return true; // Anonymous namespace
} else if (fToken == Symbols.TokenIDENT) {
- nextToken(); // Get previous token
+ nextToken(); // Get previous token
if (fToken == Symbols.TokenNAMESPACE) {
fPosition = pos;
- return true; // Named namespace
+ return true; // Named namespace
}
}
fPosition = pos;
@@ -2098,7 +2112,7 @@ public final class CIndenter {
*/
private boolean skipPointerOperators() {
if (fToken == Symbols.TokenOTHER) {
- CharSequence token= getTokenContent().toString().trim();
+ CharSequence token = getTokenContent().toString().trim();
if (token.length() == 1 && token.charAt(0) == '*' || token.charAt(0) == '&') {
return true;
}
@@ -2127,7 +2141,7 @@ public final class CIndenter {
/**
* Skips scope qualifiers of identifiers.
- *
+ *
* @return <code>true</code> if a qualifier was encountered, the last token
* will be an IDENT.
*/
@@ -2158,13 +2172,13 @@ public final class CIndenter {
* @param start the start offset from which to scan backwards
*/
private void nextToken(int start) {
- fToken= fScanner.previousToken(start - 1, CHeuristicScanner.UNBOUND);
- fPreviousPos= start;
- fPosition= fScanner.getPosition() + 1;
+ fToken = fScanner.previousToken(start - 1, CHeuristicScanner.UNBOUND);
+ fPreviousPos = start;
+ fPosition = fScanner.getPosition() + 1;
try {
- fLine= fDocument.getLineOfOffset(fPosition);
+ fLine = fDocument.getLineOfOffset(fPosition);
} catch (BadLocationException e) {
- fLine= -1;
+ fLine = -1;
}
}
@@ -2189,7 +2203,7 @@ public final class CIndenter {
nextToken();
switch (fToken) {
case Symbols.TokenIDENT: // method name
- int pos= fPosition;
+ int pos = fPosition;
nextToken();
// check destructor tilde
if (fToken == Symbols.TokenTILDE) {
@@ -2210,11 +2224,11 @@ public final class CIndenter {
return true;
case Symbols.TokenSEMICOLON:
case Symbols.TokenRBRACE:
- fPosition= pos;
+ fPosition = pos;
return true;
case Symbols.TokenLBRACE:
if (fScanner.looksLikeCompositeTypeDefinitionBackward(fPosition, CHeuristicScanner.UNBOUND)) {
- fPosition= pos;
+ fPosition = pos;
return true;
}
break;
@@ -2233,7 +2247,7 @@ public final class CIndenter {
case Symbols.TokenPUBLIC:
case Symbols.TokenPROTECTED:
case Symbols.TokenPRIVATE:
- fPosition= pos;
+ fPosition = pos;
return true;
case Symbols.TokenRPAREN:
// constructor initializer
@@ -2302,7 +2316,7 @@ public final class CIndenter {
* header (i.e. a type name (potentially qualified) and a new keyword). The heuristic calls
* <code>nextToken</code> and expects a possibly qualified identifier (type name) and a new
* keyword
- *
+ *
* @return <code>true</code> if the current position looks like a anonymous type declaration
* header.
*/
@@ -2351,7 +2365,7 @@ public final class CIndenter {
* otherwise
*/
private boolean skipScope(int openToken, int closeToken) {
- int depth= 1;
+ int depth = 1;
while (true) {
nextToken();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COperatorRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COperatorRule.java
index 14a87ea3e58..9bfe8fd3527 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COperatorRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COperatorRule.java
@@ -20,26 +20,22 @@ import org.eclipse.jface.text.rules.IToken;
*
* @author P.Tomaszewski
*/
-public class COperatorRule extends SingleCharRule
-{
- /**
- * Creates new rule.
- * @param token Style token.
- */
- public COperatorRule(IToken token)
- {
- super(token);
- }
+public class COperatorRule extends SingleCharRule {
+ /**
+ * Creates new rule.
+ * @param token Style token.
+ */
+ public COperatorRule(IToken token) {
+ super(token);
+ }
- /**
- * @see org.eclipse.cdt.internal.ui.text.SingleCharRule#isRuleChar(int)
- */
- @Override
- public boolean isRuleChar(int ch)
- {
- return (ch == ';' || ch == '.' || ch == ':' || ch == '=' || ch == '-'
- || ch == '+' || ch == '\\' || ch == '*' || ch == '!' || ch == '%'
- || ch == '^' || ch == '&' || ch == '~' || ch == '>' || ch == '<')
- || ch == '|' || ch == '/' || ch == '?' || ch == ',';
- }
+ /**
+ * @see org.eclipse.cdt.internal.ui.text.SingleCharRule#isRuleChar(int)
+ */
+ @Override
+ public boolean isRuleChar(int ch) {
+ return (ch == ';' || ch == '.' || ch == ':' || ch == '=' || ch == '-' || ch == '+' || ch == '\\' || ch == '*'
+ || ch == '!' || ch == '%' || ch == '^' || ch == '&' || ch == '~' || ch == '>' || ch == '<') || ch == '|'
+ || ch == '/' || ch == '?' || ch == ',';
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java
index 574f0767a82..171fd18c7c5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java
@@ -40,55 +40,56 @@ import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
/**
* Control which shows outline information in C/C++ editor. Based on
* AbstracInformationContol/JavaOutlineInformationControl from JDT.
- *
+ *
* @author P.Tomaszewski
*/
public class COutlineInformationControl extends AbstractInformationControl {
- private static final long TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE;
+ private static final long TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS
+ | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE;
private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS;
private ICElement fInput = null;
-
- private IContentProvider fOutlineContentProvider;
- /** The action to toggle sorting */
+ private IContentProvider fOutlineContentProvider;
+
+ /** The action to toggle sorting */
private LexicalSortingAction fSortingAction;
- /**
- * Creates new outline control.
- *
- * @param parent
- * Shell parent.
- * @param shellStyle
- * Style of new shell.
- * @param treeStyle
- * Style of the tree viewer.
- */
- public COutlineInformationControl(Shell parent, int shellStyle, int treeStyle) {
- super(parent, shellStyle, treeStyle, null, false);
- }
+ /**
+ * Creates new outline control.
+ *
+ * @param parent
+ * Shell parent.
+ * @param shellStyle
+ * Style of new shell.
+ * @param treeStyle
+ * Style of the tree viewer.
+ */
+ public COutlineInformationControl(Shell parent, int shellStyle, int treeStyle) {
+ super(parent, shellStyle, treeStyle, null, false);
+ }
/**
* {@inheritDoc}
*/
- @Override
+ @Override
protected TreeViewer createTreeViewer(Composite parent, int treeStyle) {
- TreeViewer treeViewer = new ProblemTreeViewer(parent, treeStyle);
- final Tree tree = treeViewer.getTree();
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
- fOutlineContentProvider = new CContentOutlinerProvider(treeViewer);
- treeViewer.setContentProvider(fOutlineContentProvider);
- fSortingAction= new LexicalSortingAction(treeViewer, ".isChecked"); //$NON-NLS-1$
+ TreeViewer treeViewer = new ProblemTreeViewer(parent, treeStyle);
+ final Tree tree = treeViewer.getTree();
+ tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fOutlineContentProvider = new CContentOutlinerProvider(treeViewer);
+ treeViewer.setContentProvider(fOutlineContentProvider);
+ fSortingAction = new LexicalSortingAction(treeViewer, ".isChecked"); //$NON-NLS-1$
treeViewer.addFilter(new NamePatternFilter());
long textFlags = TEXT_FLAGS;
if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS))
textFlags = textFlags | CElementLabels.M_SIMPLE_NAME | CElementLabels.F_SIMPLE_NAME;
- treeViewer.setLabelProvider(new DecoratingCLabelProvider(new AppearanceAwareLabelProvider(textFlags,
- IMAGE_FLAGS), true));
- treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
- return treeViewer;
- }
+ treeViewer.setLabelProvider(
+ new DecoratingCLabelProvider(new AppearanceAwareLabelProvider(textFlags, IMAGE_FLAGS), true));
+ treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
+ return treeViewer;
+ }
/*
* @see org.eclipse.cdt.internal.ui.text.AbstractInformationControl#getId()
@@ -107,8 +108,8 @@ public class COutlineInformationControl extends AbstractInformationControl {
inputChanged(null, null);
return;
}
- ICElement ce = (ICElement)information;
- ITranslationUnit tu = (ITranslationUnit)ce.getAncestor(ICElement.C_UNIT);
+ ICElement ce = (ICElement) information;
+ ITranslationUnit tu = (ITranslationUnit) ce.getAncestor(ICElement.C_UNIT);
if (tu != null)
fInput = tu;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
index a65cd283c5d..0af4f83713d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
@@ -33,9 +33,9 @@ import org.eclipse.cdt.ui.text.ICPartitions;
public class CPairMatcher extends DefaultCharacterPairMatcher {
private static final int ANGLE_BRACKETS_SEARCH_BOUND = 200;
-
- private boolean fMatchAngularBrackets= true;
- private int fAnchor= -1;
+
+ private boolean fMatchAngularBrackets = true;
+ private int fAnchor = -1;
public CPairMatcher(char[] pairs) {
super(pairs, ICPartitions.C_PARTITIONING);
@@ -50,7 +50,7 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
return null;
}
}
-
+
/*
* @see org.eclipse.jface.text.source.DefaultCharacterPairMatcher#getAnchor()
*/
@@ -64,30 +64,31 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
/*
* Performs the actual work of matching for #match(IDocument, int).
- */
+ */
private IRegion performMatch(IDocument document, int offset) throws BadLocationException {
- if (offset < 0 || document == null) return null;
- final char prevChar= document.getChar(Math.max(offset - 1, 0));
+ if (offset < 0 || document == null)
+ return null;
+ final char prevChar = document.getChar(Math.max(offset - 1, 0));
if ((prevChar == '<' || prevChar == '>') && !fMatchAngularBrackets)
return null;
final IRegion region;
if (prevChar == '<') {
- region= findClosingAngleBracket(document, offset - 1);
- fAnchor= ICharacterPairMatcher.LEFT;
+ region = findClosingAngleBracket(document, offset - 1);
+ fAnchor = ICharacterPairMatcher.LEFT;
} else if (prevChar == '>') {
- region= findOpeningAngleBracket(document, offset - 1);
- fAnchor= ICharacterPairMatcher.RIGHT;
+ region = findOpeningAngleBracket(document, offset - 1);
+ fAnchor = ICharacterPairMatcher.RIGHT;
} else {
- region= super.match(document, offset);
- fAnchor= -1;
+ region = super.match(document, offset);
+ fAnchor = -1;
}
if (region != null) {
if (prevChar == '>') {
- final int peer= region.getOffset();
+ final int peer = region.getOffset();
if (isLessThanOperator(document, peer))
return null;
} else if (prevChar == '<') {
- final int peer= region.getOffset() + region.getLength() - 1;
+ final int peer = region.getOffset() + region.getLength() - 1;
if (isGreaterThanOperator(document, peer))
return null;
}
@@ -97,18 +98,19 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
/**
* Returns the region enclosing the matching angle brackets.
- *
+ *
* @param document a document
* @param offset an offset within the document pointing after the closing angle bracket
* @return the matching region or {@link NullPointerException} if no match could be found
- * @throws BadLocationException
+ * @throws BadLocationException
*/
private IRegion findOpeningAngleBracket(IDocument document, int offset) throws BadLocationException {
- if (offset < 0) return null;
- final String contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
- CHeuristicScanner scanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
+ if (offset < 0)
+ return null;
+ final String contentType = TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
+ CHeuristicScanner scanner = new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
if (isTemplateParameterCloseBracket(offset, document, scanner)) {
- int pos= scanner.findOpeningPeer(offset - 1, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND), '<', '>');
+ int pos = scanner.findOpeningPeer(offset - 1, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND), '<', '>');
if (pos != CHeuristicScanner.NOT_FOUND) {
return new Region(pos, offset - pos + 1);
}
@@ -118,18 +120,20 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
/**
* Returns the region enclosing the matching angle brackets.
- *
+ *
* @param document a document
* @param offset an offset within the document pointing after the opening angle bracket
* @return the matching region or {@link NullPointerException} if no match could be found
- * @throws BadLocationException
+ * @throws BadLocationException
*/
private IRegion findClosingAngleBracket(IDocument document, int offset) throws BadLocationException {
- if (offset < 0) return null;
- final String contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
- CHeuristicScanner scanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
+ if (offset < 0)
+ return null;
+ final String contentType = TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
+ CHeuristicScanner scanner = new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
if (isTemplateParameterOpenBracket(offset, document, scanner)) {
- int pos= scanner.findClosingPeer(offset + 1, Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND), '<', '>');
+ int pos = scanner.findClosingPeer(offset + 1,
+ Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND), '<', '>');
if (pos != CHeuristicScanner.NOT_FOUND) {
return new Region(offset, pos - offset + 1);
}
@@ -141,7 +145,7 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
* Returns true if the character at the specified offset is a
* less-than sign, rather than an template parameter list open
* angle bracket.
- *
+ *
* @param document a document
* @param offset an offset within the document
* @return true if the character at the specified offset is not
@@ -149,9 +153,10 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
* @throws BadLocationException
*/
private boolean isLessThanOperator(IDocument document, int offset) throws BadLocationException {
- if (offset < 0) return false;
- final String contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
- CHeuristicScanner scanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
+ if (offset < 0)
+ return false;
+ final String contentType = TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
+ CHeuristicScanner scanner = new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
return !isTemplateParameterOpenBracket(offset, document, scanner);
}
@@ -159,7 +164,7 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
* Returns true if the character at the specified offset is a
* greater-than sign, rather than an template parameter list close
* angle bracket.
- *
+ *
* @param document a document
* @param offset an offset within the document
* @return true if the character at the specified offset is not
@@ -167,9 +172,10 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
* @throws BadLocationException
*/
private boolean isGreaterThanOperator(IDocument document, int offset) throws BadLocationException {
- if (offset < 0) return false;
- final String contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
- CHeuristicScanner scanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
+ if (offset < 0)
+ return false;
+ final String contentType = TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
+ CHeuristicScanner scanner = new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
return !isTemplateParameterCloseBracket(offset, document, scanner);
}
@@ -184,10 +190,11 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
* <code>false</code> otherwise
*/
private boolean isTemplateParameterOpenBracket(int offset, IDocument document, CHeuristicScanner scanner) {
- int nextToken = scanner.nextToken(offset + 1, Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND));
+ int nextToken = scanner.nextToken(offset + 1,
+ Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND));
if (nextToken == Symbols.TokenSHIFTLEFT || nextToken == Symbols.TokenLESSTHAN)
return false;
- int prevToken= scanner.previousToken(offset - 1, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
+ int prevToken = scanner.previousToken(offset - 1, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
if (prevToken == Symbols.TokenIDENT || prevToken == Symbols.TokenTEMPLATE) {
return true;
}
@@ -208,15 +215,16 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
private boolean isTemplateParameterCloseBracket(int offset, IDocument document, CHeuristicScanner scanner) {
if (offset >= document.getLength() - 1)
return true;
- int thisToken= scanner.previousToken(offset, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
+ int thisToken = scanner.previousToken(offset, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
if (thisToken == Symbols.TokenSHIFTRIGHT)
return true;
if (thisToken != Symbols.TokenGREATERTHAN)
return false;
- int prevToken= scanner.previousToken(scanner.getPosition(), Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
+ int prevToken = scanner.previousToken(scanner.getPosition(), Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
if (prevToken == Symbols.TokenGREATERTHAN)
return true;
- int nextToken= scanner.nextToken(offset + 1, Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND));
+ int nextToken = scanner.nextToken(offset + 1,
+ Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND));
switch (nextToken) {
case Symbols.TokenGREATERTHAN:
@@ -235,7 +243,7 @@ public class CPairMatcher extends DefaultCharacterPairMatcher {
* @param language
*/
public void configure(ILanguage language) {
- fMatchAngularBrackets= language != null && language.getLinkageID() == ILinkage.CPP_LINKAGE_ID;
+ fMatchAngularBrackets = language != null && language.getLinkageID() == ILinkage.CPP_LINKAGE_ID;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
index 53abfa7abd6..11084bbf995 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
@@ -34,35 +34,35 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CProposalContextInformatio
/**
* This class provides the function parameter parsing for the C/C++ Editor hover.
* It is based heavily on the Java class JavaParameterListValidator.
- *
+ *
* @author thomasf
*/
public class CParameterListValidator implements IContextInformationValidator, IContextInformationPresenter {
private int fPosition;
private ITextViewer fViewer;
private IContextInformation fInformation;
-
+
private int fCurrentParameter;
-
+
public CParameterListValidator() {
}
-
+
/**
* @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
* @see IContextInformationPresenter#install(IContextInformation, ITextViewer, int)
*/
@Override
public void install(IContextInformation info, ITextViewer viewer, int documentPosition) {
- fPosition= documentPosition;
- fViewer= viewer;
- fInformation= info;
-
- fCurrentParameter= -1;
+ fPosition = documentPosition;
+ fViewer = viewer;
+ fInformation = info;
+
+ fCurrentParameter = -1;
}
-
+
private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {
while (pos < end) {
- char curr= d.getChar(pos);
+ char curr = d.getChar(pos);
pos++;
if (curr == '*') {
if (pos < end && d.getChar(pos) == '/') {
@@ -75,7 +75,7 @@ public class CParameterListValidator implements IContextInformationValidator, IC
private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {
while (pos < end) {
- char curr= d.getChar(pos);
+ char curr = d.getChar(pos);
pos++;
if (curr == '\\') {
// Ignore escaped characters.
@@ -86,11 +86,11 @@ public class CParameterListValidator implements IContextInformationValidator, IC
}
return end;
}
-
+
private int getCharCount(IDocument document, int start, int end, char increment, char decrement,
boolean considerNesting) throws BadLocationException {
Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
-
+
int parenNestingLevel = 0;
int braceNestingLevel = 0;
int charCount = 0;
@@ -99,31 +99,31 @@ public class CParameterListValidator implements IContextInformationValidator, IC
switch (curr) {
case '/':
if (start < end) {
- char next= document.getChar(start);
+ char next = document.getChar(start);
if (next == '*') {
// A comment starts, advance to the comment end.
- start= getCommentEnd(document, start + 1, end);
+ start = getCommentEnd(document, start + 1, end);
} else if (next == '/') {
- // '//'-comment: nothing to do anymore on this line
- start= end;
+ // '//'-comment: nothing to do anymore on this line
+ start = end;
}
}
break;
case '*':
if (start < end) {
- char next= document.getChar(start);
+ char next = document.getChar(start);
if (next == '/') {
// We have been in a comment: forget what we read before.
- charCount= 0;
- ++ start;
+ charCount = 0;
+ ++start;
}
}
break;
case '"':
case '\'':
- start= getStringEnd(document, start, end, curr);
+ start = getStringEnd(document, start, end, curr);
break;
default:
@@ -133,7 +133,7 @@ public class CParameterListValidator implements IContextInformationValidator, IC
} else if (')' == curr) {
--parenNestingLevel;
}
-
+
if (parenNestingLevel != 0)
break;
@@ -142,68 +142,68 @@ public class CParameterListValidator implements IContextInformationValidator, IC
} else if ('}' == curr) {
--braceNestingLevel;
}
-
+
if (braceNestingLevel != 0)
break;
}
-
+
if (increment != 0) {
if (curr == increment)
++charCount;
}
-
+
if (decrement != 0) {
if (curr == decrement)
--charCount;
}
}
}
-
+
return charCount;
}
-
+
/**
* @see IContextInformationValidator#isContextInformationValid(int)
*/
@Override
- public boolean isContextInformationValid(int position) {
+ public boolean isContextInformationValid(int position) {
try {
if (position < fPosition)
return false;
-
- IDocument document= fViewer.getDocument();
+
+ IDocument document = fViewer.getDocument();
return getCharCount(document, fPosition, position, '(', ')', false) >= 0;
} catch (BadLocationException x) {
return false;
}
}
-
+
@Override
public boolean updatePresentation(int position, TextPresentation presentation) {
- int currentParameter= -1;
-
+ int currentParameter = -1;
+
try {
- currentParameter= getCharCount(fViewer.getDocument(), fPosition, position, ',', (char) 0, true);
+ currentParameter = getCharCount(fViewer.getDocument(), fPosition, position, ',', (char) 0, true);
} catch (BadLocationException x) {
return false;
}
-
+
if (fCurrentParameter != -1) {
if (currentParameter == fCurrentParameter)
return false;
}
-
+
presentation.clear();
- fCurrentParameter= currentParameter;
-
+ fCurrentParameter = currentParameter;
+
// Don't presume what has been done to the string, rather use as is.
String s = fInformation.getInformationDisplayString();
String params = s;
// Context information objects of type CProposalContextInformation can have
// an optional prefix before and suffix after the parameter list.
- // In such a case, query the indices that bound the parameter list part of
- // the string, so we can parse the comma positions accurately.
+ // In such a case, query the indices that bound the parameter list part of
+ // the string, so we can parse the comma positions accurately.
int paramlistStartIndex = 0;
int paramlistEndIndex = s.length();
if (fInformation instanceof CProposalContextInformation) {
@@ -214,15 +214,15 @@ public class CParameterListValidator implements IContextInformationValidator, IC
params = s.substring(paramlistStartIndex, paramlistEndIndex);
}
}
-
- int[] commas= computeCommaPositions(params);
+
+ int[] commas = computeCommaPositions(params);
if (commas.length - 2 < fCurrentParameter) {
presentation.addStyleRange(new StyleRange(0, s.length(), null, null, SWT.NORMAL));
return true;
}
-
- int start= commas[fCurrentParameter] + 1;
- int end= commas[fCurrentParameter + 1];
+
+ int start = commas[fCurrentParameter] + 1;
+ int end = commas[fCurrentParameter + 1];
if (start > 0)
presentation.addStyleRange(new StyleRange(paramlistStartIndex, start, null, null, SWT.NORMAL));
@@ -230,53 +230,54 @@ public class CParameterListValidator implements IContextInformationValidator, IC
presentation.addStyleRange(new StyleRange(paramlistStartIndex + start, end - start, null, null, SWT.BOLD));
if (end < s.length())
- presentation.addStyleRange(new StyleRange(paramlistStartIndex + end, params.length() - end, null, null, SWT.NORMAL));
+ presentation.addStyleRange(
+ new StyleRange(paramlistStartIndex + end, params.length() - end, null, null, SWT.NORMAL));
return true;
}
private int[] computeCommaPositions(String code) {
- final int length= code.length();
- int pos= 0;
- List<Integer> positions= new ArrayList<>();
+ final int length = code.length();
+ int pos = 0;
+ List<Integer> positions = new ArrayList<>();
positions.add(Integer.valueOf(-1));
while (pos < length && pos != -1) {
- char ch= code.charAt(pos);
+ char ch = code.charAt(pos);
switch (ch) {
- case ',':
- positions.add(Integer.valueOf(pos));
- break;
- case '(':
- pos= indexOfClosingPeer(code, '(', ')', pos);
- break;
- case '<':
- pos= indexOfClosingPeer(code, '<', '>', pos);
- break;
- case '[':
- pos= indexOfClosingPeer(code, '[', ']', pos);
- break;
- case '{':
- pos= indexOfClosingPeer(code, '{', '}', pos);
- break;
- default:
- break;
- }
+ case ',':
+ positions.add(Integer.valueOf(pos));
+ break;
+ case '(':
+ pos = indexOfClosingPeer(code, '(', ')', pos);
+ break;
+ case '<':
+ pos = indexOfClosingPeer(code, '<', '>', pos);
+ break;
+ case '[':
+ pos = indexOfClosingPeer(code, '[', ']', pos);
+ break;
+ case '{':
+ pos = indexOfClosingPeer(code, '{', '}', pos);
+ break;
+ default:
+ break;
+ }
if (pos != -1)
pos++;
}
positions.add(Integer.valueOf(length));
-
- int[] fields= new int[positions.size()];
- for (int i= 0; i < fields.length; i++)
- fields[i]= positions.get(i).intValue();
- return fields;
- }
+
+ int[] fields = new int[positions.size()];
+ for (int i = 0; i < fields.length; i++)
+ fields[i] = positions.get(i).intValue();
+ return fields;
+ }
private int indexOfClosingPeer(String code, char left, char right, int pos) {
- int level= 0;
- final int length= code.length();
+ int level = 0;
+ final int length = code.length();
while (pos < length) {
- char ch= code.charAt(pos);
+ char ch = code.charAt(pos);
if (ch == left) {
++level;
} else if (ch == right) {
@@ -289,4 +290,3 @@ public class CParameterListValidator implements IContextInformationValidator, IC
return -1;
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java
index ce8481e1564..ead9d890c65 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java
@@ -35,24 +35,19 @@ import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
* @since 4.0
*/
public class CPreprocessorScanner extends AbstractCScanner {
- /** Properties for tokens. */
- private static String[] fgTokenProperties= {
- ICColorConstants.C_KEYWORD,
- ICColorConstants.PP_DIRECTIVE,
- ICColorConstants.PP_DEFAULT,
- ICColorConstants.C_TYPE,
- ICColorConstants.C_STRING,
- ICColorConstants.PP_HEADER
- };
+ /** Properties for tokens. */
+ private static String[] fgTokenProperties = { ICColorConstants.C_KEYWORD, ICColorConstants.PP_DIRECTIVE,
+ ICColorConstants.PP_DEFAULT, ICColorConstants.C_TYPE, ICColorConstants.C_STRING,
+ ICColorConstants.PP_HEADER };
private ICLanguageKeywords fKeywords;
-
+
/**
* Creates a C/C++ preprocessor scanner.
- * @param keywords the keywords defined by the language dialect
+ * @param keywords the keywords defined by the language dialect
*/
public CPreprocessorScanner(ITokenStoreFactory factory, ICLanguageKeywords keywords) {
super(factory.createTokenStore(fgTokenProperties));
- fKeywords= keywords;
+ fKeywords = keywords;
setRules(createRules());
}
@@ -60,17 +55,17 @@ public class CPreprocessorScanner extends AbstractCScanner {
* @see org.eclipse.cdt.internal.ui.text.AbstractCScanner#createRules()
*/
protected List<IRule> createRules() {
- IToken defaultToken= getToken(ICColorConstants.PP_DEFAULT);
+ IToken defaultToken = getToken(ICColorConstants.PP_DEFAULT);
- List<IRule> rules= new ArrayList<IRule>();
+ List<IRule> rules = new ArrayList<IRule>();
IToken token;
-
+
// Add generic white space rule.
rules.add(new CWhitespaceRule(defaultToken));
-
- token= getToken(ICColorConstants.PP_DIRECTIVE);
+
+ token = getToken(ICColorConstants.PP_DIRECTIVE);
PreprocessorRule preprocessorRule = new PreprocessorRule(new CWordDetector(), defaultToken);
- String[] ppKeywords= fKeywords.getPreprocessorKeywords();
+ String[] ppKeywords = fKeywords.getPreprocessorKeywords();
for (int i = 0; i < ppKeywords.length; i++) {
preprocessorRule.addWord(ppKeywords[i], token);
}
@@ -80,33 +75,33 @@ public class CPreprocessorScanner extends AbstractCScanner {
rules.add(preprocessorRule);
// Add word rule for keywords, types, and constants.
- WordRule wordRule= new WordRule(new CWordDetector(), defaultToken);
-
- token= getToken(ICColorConstants.C_KEYWORD);
- String[] keywords= fKeywords.getKeywords();
+ WordRule wordRule = new WordRule(new CWordDetector(), defaultToken);
+
+ token = getToken(ICColorConstants.C_KEYWORD);
+ String[] keywords = fKeywords.getKeywords();
for (int i = 0; i < keywords.length; i++) {
wordRule.addWord(keywords[i], token);
}
- token= getToken(ICColorConstants.C_TYPE);
- String[] types= fKeywords.getBuiltinTypes();
+ token = getToken(ICColorConstants.C_TYPE);
+ String[] types = fKeywords.getBuiltinTypes();
for (int i = 0; i < types.length; i++) {
wordRule.addWord(types[i], token);
}
- rules.add(wordRule);
-
- token = getToken(ICColorConstants.PP_HEADER);
- CHeaderRule headerRule = new CHeaderRule(token);
- rules.add(headerRule);
+ rules.add(wordRule);
+
+ token = getToken(ICColorConstants.PP_HEADER);
+ CHeaderRule headerRule = new CHeaderRule(token);
+ rules.add(headerRule);
- token = getToken(ICColorConstants.C_STRING);
- IRule stringRule = new PatternRule("\"", "\"", token, '\\', true, true, true); //$NON-NLS-1$ //$NON-NLS-2$
- rules.add(stringRule);
+ token = getToken(ICColorConstants.C_STRING);
+ IRule stringRule = new PatternRule("\"", "\"", token, '\\', true, true, true); //$NON-NLS-1$ //$NON-NLS-2$
+ rules.add(stringRule);
- token = getToken(ICColorConstants.C_STRING);
- IRule charRule = new PatternRule("'", "'", token, '\\', true, true, true); //$NON-NLS-1$ //$NON-NLS-2$
- rules.add(charRule);
+ token = getToken(ICColorConstants.C_STRING);
+ IRule charRule = new PatternRule("'", "'", token, '\\', true, true, true); //$NON-NLS-1$ //$NON-NLS-2$
+ rules.add(charRule);
- setDefaultReturnToken(defaultToken);
+ setDefaultReturnToken(defaultToken);
return rules;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPresentationReconciler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPresentationReconciler.java
index 640571e95ca..f011fb1690c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPresentationReconciler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPresentationReconciler.java
@@ -22,7 +22,7 @@ import org.eclipse.jface.text.presentation.PresentationReconciler;
/**
* Presentation reconciler, adding functionality for operation without a viewer.
* Cloned from JDT.
- *
+ *
* @since 4.0
*/
public class CPresentationReconciler extends PresentationReconciler {
@@ -44,7 +44,7 @@ public class CPresentationReconciler extends PresentationReconciler {
if (document != fLastDocument) {
setDocumentToDamagers(document);
setDocumentToRepairers(document);
- fLastDocument= document;
+ fLastDocument = document;
}
return createPresentation(damage, document);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java
index 9b5304bc7de..f4fa7d72141 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java
@@ -56,7 +56,7 @@ import org.eclipse.cdt.ui.IWorkingCopyManager;
/**
* A single strategy C reconciler.
- *
+ *
* @since 4.0
*/
public class CReconciler extends MonoReconciler {
@@ -66,7 +66,7 @@ public class CReconciler extends MonoReconciler {
SingletonJob(String name, Runnable code) {
super(name);
- fCode= code;
+ fCode = code;
setPriority(Job.SHORT);
setRule(this);
setUser(false);
@@ -144,7 +144,7 @@ public class CReconciler extends MonoReconciler {
public ActivationListener(Control control) {
Assert.isNotNull(control);
- fControl= control;
+ fControl = control;
}
@Override
@@ -189,16 +189,14 @@ public class CReconciler extends MonoReconciler {
setCModelChanged(true);
}
}
- if ((flags & (
- ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE |
- ICElementDelta.F_CHANGED_PATHENTRY_MACRO
- )) != 0) {
+ if ((flags
+ & (ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE | ICElementDelta.F_CHANGED_PATHENTRY_MACRO)) != 0) {
if (isRelevantProject(delta.getElement().getCProject())) {
return true;
}
}
if ((flags & ICElementDelta.F_CHILDREN) != 0) {
- ICElementDelta[] childDeltas= delta.getChangedChildren();
+ ICElementDelta[] childDeltas = delta.getChangedChildren();
for (int i = 0; i < childDeltas.length; i++) {
if (isRelevantDelta(childDeltas[i])) {
return true;
@@ -216,7 +214,7 @@ public class CReconciler extends MonoReconciler {
public void indexChanged(IIndexerStateEvent event) {
if (event.indexerIsIdle()) {
if (fIndexChanged || hasCModelChanged()) {
- fIndexChanged= false;
+ fIndexChanged = false;
if (!fIsReconciling && isEditorActive() && fInitialProcessDone) {
CReconciler.this.scheduleReconciling();
} else {
@@ -229,7 +227,7 @@ public class CReconciler extends MonoReconciler {
@Override
public void indexChanged(IIndexChangeEvent event) {
if (!fIndexChanged && isRelevantProject(event.getAffectedProject())) {
- fIndexChanged= true;
+ fIndexChanged = true;
}
}
}
@@ -243,75 +241,76 @@ public class CReconciler extends MonoReconciler {
/** The C element changed listener. */
private IElementChangedListener fCElementChangedListener;
/** The indexer listener */
- private IndexerListener fIndexerListener;
+ private IndexerListener fIndexerListener;
/** Tells whether the C model might have changed. */
private volatile boolean fHasCModelChanged;
/** Tells whether this reconciler's editor is active. */
- private volatile boolean fIsEditorActive= true;
+ private volatile boolean fIsEditorActive = true;
/** Tells whether a reconcile is in progress. */
private volatile boolean fIsReconciling;
-
+
private boolean fInitialProcessDone;
private Job fTriggerReconcilerJob;
/**
* Create a reconciler for the given editor and strategy.
- *
+ *
* @param editor the text editor
* @param strategy the C reconciling strategy
*/
public CReconciler(ITextEditor editor, CCompositeReconcilingStrategy strategy) {
super(strategy, false);
- fTextEditor= editor;
+ fTextEditor = editor;
}
@Override
public void install(ITextViewer textViewer) {
super.install(textViewer);
-
- fPartListener= new PartListener();
- IWorkbenchPartSite site= fTextEditor.getSite();
- IWorkbenchWindow window= site.getWorkbenchWindow();
+
+ fPartListener = new PartListener();
+ IWorkbenchPartSite site = fTextEditor.getSite();
+ IWorkbenchWindow window = site.getWorkbenchWindow();
window.getPartService().addPartListener(fPartListener);
- fActivationListener= new ActivationListener(textViewer.getTextWidget());
- Shell shell= window.getShell();
+ fActivationListener = new ActivationListener(textViewer.getTextWidget());
+ Shell shell = window.getShell();
shell.addShellListener(fActivationListener);
- fCElementChangedListener= new ElementChangedListener();
+ fCElementChangedListener = new ElementChangedListener();
CoreModel.getDefault().addElementChangedListener(fCElementChangedListener);
-
- fIndexerListener= new IndexerListener();
+
+ fIndexerListener = new IndexerListener();
CCorePlugin.getIndexManager().addIndexerStateListener(fIndexerListener);
CCorePlugin.getIndexManager().addIndexChangeListener(fIndexerListener);
-
- fTriggerReconcilerJob= new SingletonJob("Trigger Reconciler", new Runnable() { //$NON-NLS-1$
+
+ fTriggerReconcilerJob = new SingletonJob("Trigger Reconciler", new Runnable() { //$NON-NLS-1$
@Override
public void run() {
forceReconciling();
- }});
+ }
+ });
}
@Override
public void uninstall() {
fTriggerReconcilerJob.cancel();
-
- IWorkbenchPartSite site= fTextEditor.getSite();
- IWorkbenchWindow window= site.getWorkbenchWindow();
+
+ IWorkbenchPartSite site = fTextEditor.getSite();
+ IWorkbenchWindow window = site.getWorkbenchWindow();
window.getPartService().removePartListener(fPartListener);
- fPartListener= null;
+ fPartListener = null;
- Shell shell= window.getShell();
+ Shell shell = window.getShell();
if (shell != null && !shell.isDisposed())
shell.removeShellListener(fActivationListener);
- fActivationListener= null;
+ fActivationListener = null;
CoreModel.getDefault().removeElementChangedListener(fCElementChangedListener);
- fCElementChangedListener= null;
+ fCElementChangedListener = null;
CCorePlugin.getIndexManager().removeIndexerStateListener(fIndexerListener);
CCorePlugin.getIndexManager().removeIndexChangeListener(fIndexerListener);
- fIndexerListener= null;
+ fIndexerListener = null;
super.uninstall();
}
@@ -332,25 +331,26 @@ public class CReconciler extends MonoReconciler {
@Override
protected void aboutToBeReconciled() {
- CCompositeReconcilingStrategy strategy= (CCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
+ CCompositeReconcilingStrategy strategy = (CCompositeReconcilingStrategy) getReconcilingStrategy(
+ IDocument.DEFAULT_CONTENT_TYPE);
strategy.aboutToBeReconciled();
}
@Override
protected void initialProcess() {
super.initialProcess();
- fInitialProcessDone= true;
+ fInitialProcessDone = true;
if (!fIsReconciling && isEditorActive() && hasCModelChanged()) {
CReconciler.this.scheduleReconciling();
- }
+ }
}
@Override
protected void process(DirtyRegion dirtyRegion) {
- fIsReconciling= true;
+ fIsReconciling = true;
setCModelChanged(false);
super.process(dirtyRegion);
- fIsReconciling= false;
+ fIsReconciling = false;
}
/**
@@ -368,9 +368,9 @@ public class CReconciler extends MonoReconciler {
* @param state <code>true</code> iff the C model has changed
*/
private synchronized void setCModelChanged(boolean state) {
- fHasCModelChanged= state;
+ fHasCModelChanged = state;
}
-
+
/**
* Tells whether this reconciler's editor is active.
*
@@ -386,7 +386,7 @@ public class CReconciler extends MonoReconciler {
* @param state <code>true</code> iff the editor is active
*/
private synchronized void setEditorActive(boolean active) {
- fIsEditorActive= active;
+ fIsEditorActive = active;
if (!active) {
fTriggerReconcilerJob.cancel();
}
@@ -400,9 +400,9 @@ public class CReconciler extends MonoReconciler {
return false;
}
if (element instanceof ITranslationUnit) {
- IEditorInput input= fTextEditor.getEditorInput();
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
- IWorkingCopy copy= manager.getWorkingCopy(input);
+ IEditorInput input = fTextEditor.getEditorInput();
+ IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+ IWorkingCopy copy = manager.getWorkingCopy(input);
if (copy == null || copy.getOriginalElement().equals(element)) {
return false;
}
@@ -415,23 +415,23 @@ public class CReconciler extends MonoReconciler {
if (affectedProject == null) {
return false;
}
- IEditorInput input= fTextEditor.getEditorInput();
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
- IWorkingCopy copy= manager.getWorkingCopy(input);
+ IEditorInput input = fTextEditor.getEditorInput();
+ IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+ IWorkingCopy copy = manager.getWorkingCopy(input);
if (copy == null) {
return false;
}
if (copy.getCProject().equals(affectedProject)) {
return true;
}
- IProject project= copy.getCProject().getProject();
+ IProject project = copy.getCProject().getProject();
if (project == null) {
return false;
}
try {
- IProject[] referencedProjects= project.getReferencedProjects();
- for (int i= 0; i < referencedProjects.length; i++) {
- project= referencedProjects[i];
+ IProject[] referencedProjects = project.getReferencedProjects();
+ for (int i = 0; i < referencedProjects.length; i++) {
+ project = referencedProjects[i];
if (project.equals(affectedProject.getProject())) {
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
index d66d3469ec0..1e00c60f1ce 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
@@ -41,10 +41,10 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
private IProgressMonitor fProgressMonitor;
// used by tests
protected boolean fInitialProcessDone;
-
+
public CReconcilingStrategy(ITextEditor editor) {
- fEditor= editor;
- fManager= CUIPlugin.getDefault().getWorkingCopyManager();
+ fEditor = editor;
+ fManager = CUIPlugin.getDefault().getWorkingCopyManager();
}
@Override
@@ -58,7 +58,7 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
@Override
public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor= monitor;
+ fProgressMonitor = monitor;
}
@Override
@@ -67,39 +67,39 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
}
private void reconcile(final boolean initialReconcile) {
- boolean computeAST= fEditor instanceof ICReconcilingListener;
- IASTTranslationUnit ast= null;
- IWorkingCopy workingCopy= fManager.getWorkingCopy(fEditor.getEditorInput());
+ boolean computeAST = fEditor instanceof ICReconcilingListener;
+ IASTTranslationUnit ast = null;
+ IWorkingCopy workingCopy = fManager.getWorkingCopy(fEditor.getEditorInput());
if (workingCopy == null) {
return;
}
- boolean forced= false;
+ boolean forced = false;
try {
// reconcile
synchronized (workingCopy) {
- forced= workingCopy.isConsistent();
- ast= workingCopy.reconcile(computeAST, true, fProgressMonitor);
+ forced = workingCopy.isConsistent();
+ ast = workingCopy.reconcile(computeAST, true, fProgressMonitor);
}
} catch (OperationCanceledException e) {
// document was modified while parsing
} catch (CModelException e) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
- "Error in CDT UI during reconcile", e); //$NON-NLS-1$
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
+ "Error in CDT UI during reconcile", e); //$NON-NLS-1$
CUIPlugin.log(status);
} finally {
if (computeAST) {
- IIndex index= null;
+ IIndex index = null;
if (ast != null) {
- index= ast.getIndex();
+ index = ast.getIndex();
}
try {
final boolean canceled = fProgressMonitor.isCanceled();
if (ast == null || canceled) {
- ((ICReconcilingListener)fEditor).reconciled(null, forced, fProgressMonitor);
+ ((ICReconcilingListener) fEditor).reconciled(null, forced, fProgressMonitor);
} else {
((ASTTranslationUnit) ast).beginExclusiveAccess();
try {
- ((ICReconcilingListener)fEditor).reconciled(ast, forced, fProgressMonitor);
+ ((ICReconcilingListener) fEditor).reconciled(ast, forced, fProgressMonitor);
} finally {
((ASTTranslationUnit) ast).endExclusiveAccess();
}
@@ -108,8 +108,8 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
aboutToBeReconciled();
}
} catch (Exception e) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
- "Error in CDT UI during reconcile", e); //$NON-NLS-1$
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
+ "Error in CDT UI during reconcile", e); //$NON-NLS-1$
CUIPlugin.log(status);
} finally {
if (index != null) {
@@ -118,17 +118,17 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
}
}
}
- }
+ }
@Override
public void initialReconcile() {
reconcile(true);
- fInitialProcessDone= true;
+ fInitialProcessDone = true;
}
void aboutToBeReconciled() {
if (fEditor instanceof ICReconcilingListener) {
- ((ICReconcilingListener)fEditor).aboutToBeReconciled();
+ ((ICReconcilingListener) fEditor).aboutToBeReconciled();
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java
index e3f722d90b0..846a6a7afa8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -30,29 +30,29 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
* Configuration for an <code>SourceViewer</code> which shows C/C++ code.
* It turns off some editor features when scalability mode options are enabled.
*/
-public class CSourceViewerScalableConfiguration extends
- CSourceViewerConfiguration {
+public class CSourceViewerScalableConfiguration extends CSourceViewerConfiguration {
- public CSourceViewerScalableConfiguration(
- IColorManager colorManager, IPreferenceStore preferenceStore,
+ public CSourceViewerScalableConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore,
ITextEditor editor, String partitioning) {
super(colorManager, preferenceStore, editor, partitioning);
}
-
+
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
- if (((CEditor)getEditor()).isEnableScalablilityMode() && fPreferenceStore.getBoolean(PreferenceConstants.SCALABILITY_RECONCILER))
- return null;
+ if (((CEditor) getEditor()).isEnableScalablilityMode()
+ && fPreferenceStore.getBoolean(PreferenceConstants.SCALABILITY_RECONCILER))
+ return null;
return super.getReconciler(sourceViewer);
}
-
+
/**
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
*/
- @Override
+ @Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- if (((CEditor)getEditor()).isEnableScalablilityMode() && fPreferenceStore.getBoolean(PreferenceConstants.SCALABILITY_SYNTAX_COLOR))
- return null;
+ if (((CEditor) getEditor()).isEnableScalablilityMode()
+ && fPreferenceStore.getBoolean(PreferenceConstants.SCALABILITY_SYNTAX_COLOR))
+ return null;
return super.getPresentationReconciler(sourceViewer);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java
index 0d943cf7673..909b7dce995 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java
@@ -77,36 +77,36 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
}
StringBuilder tokenBuffer = new StringBuilder();
- for (int i = 0; i < token.length(); i++){
+ for (int i = 0; i < token.length(); i++) {
char c = token.charAt(i);
switch (c) {
- case '\r' :
- tokenBuffer.append("\\r"); //$NON-NLS-1$
- break;
- case '\n' :
- tokenBuffer.append("\\n"); //$NON-NLS-1$
- break;
- case '\b' :
- tokenBuffer.append("\\b"); //$NON-NLS-1$
- break;
- case '\t' :
- // keep tabs verbatim
- tokenBuffer.append("\t"); //$NON-NLS-1$
- break;
- case '\f' :
- tokenBuffer.append("\\f"); //$NON-NLS-1$
- break;
- case '\"' :
- tokenBuffer.append("\\\""); //$NON-NLS-1$
- break;
- case '\'' :
- tokenBuffer.append("\\'"); //$NON-NLS-1$
- break;
- case '\\' :
- tokenBuffer.append("\\\\"); //$NON-NLS-1$
- break;
- default :
- tokenBuffer.append(c);
+ case '\r':
+ tokenBuffer.append("\\r"); //$NON-NLS-1$
+ break;
+ case '\n':
+ tokenBuffer.append("\\n"); //$NON-NLS-1$
+ break;
+ case '\b':
+ tokenBuffer.append("\\b"); //$NON-NLS-1$
+ break;
+ case '\t':
+ // keep tabs verbatim
+ tokenBuffer.append("\t"); //$NON-NLS-1$
+ break;
+ case '\f':
+ tokenBuffer.append("\\f"); //$NON-NLS-1$
+ break;
+ case '\"':
+ tokenBuffer.append("\\\""); //$NON-NLS-1$
+ break;
+ case '\'':
+ tokenBuffer.append("\\'"); //$NON-NLS-1$
+ break;
+ case '\\':
+ tokenBuffer.append("\\\\"); //$NON-NLS-1$
+ break;
+ default:
+ tokenBuffer.append(c);
}
}
buffer.append(tokenBuffer);
@@ -126,7 +126,7 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
}
private boolean isLineDelimiter(IDocument document, String text) {
- String[] delimiters= document.getLegalLineDelimiters();
+ String[] delimiters = document.getLegalLineDelimiters();
if (delimiters != null)
return TextUtilities.equals(delimiters, text) > -1;
return false;
@@ -137,39 +137,39 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
}
private void indentStringAfterNewLine(IDocument document, DocumentCommand command) throws BadLocationException {
- ITypedRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset, true);
- int offset= partition.getOffset();
- int length= partition.getLength();
+ ITypedRegion partition = TextUtilities.getPartition(document, fPartitioning, command.offset, true);
+ int offset = partition.getOffset();
+ int length = partition.getLength();
if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"')
return;
- if (offset > 0 && document.getChar(offset - 1) == 'R') // raw string
+ if (offset > 0 && document.getChar(offset - 1) == 'R') // raw string
return;
-
+
CHeuristicScanner scanner = new CHeuristicScanner(document);
CIndenter indenter = new CIndenter(document, scanner, fProject);
StringBuilder indentation = indenter.computeContinuationLineIndentation(offset);
if (indentation == null)
indentation = new StringBuilder();
- String delimiter= TextUtilities.getDefaultLineDelimiter(document);
- IPreferenceStore preferenceStore= CUIPlugin.getDefault().getPreferenceStore();
+ String delimiter = TextUtilities.getDefaultLineDelimiter(document);
+ IPreferenceStore preferenceStore = CUIPlugin.getDefault().getPreferenceStore();
if (isLineDelimiter(document, command.text))
- command.text= "\"" + command.text + indentation + "\""; //$NON-NLS-1$//$NON-NLS-2$
+ command.text = "\"" + command.text + indentation + "\""; //$NON-NLS-1$//$NON-NLS-2$
else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS))
- command.text= getModifiedText(command.text, indentation, delimiter);
+ command.text = getModifiedText(command.text, indentation, delimiter);
}
private boolean isSmartMode() {
- IWorkbenchPage page= CUIPlugin.getActivePage();
- if (page != null) {
- IEditorPart part= page.getActiveEditor();
+ IWorkbenchPage page = CUIPlugin.getActivePage();
+ if (page != null) {
+ IEditorPart part = page.getActiveEditor();
if (part instanceof MultiPageEditorPart) {
- part= (IEditorPart)part.getAdapter(ITextEditorExtension3.class);
+ part = (IEditorPart) part.getAdapter(ITextEditorExtension3.class);
}
if (part instanceof ITextEditorExtension3) {
- ITextEditorExtension3 extension= (ITextEditorExtension3) part;
+ ITextEditorExtension3 extension = (ITextEditorExtension3) part;
return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
}
}
@@ -185,7 +185,7 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
if (command.length != 0 || command.text == null)
return;
- IPreferenceStore preferenceStore= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore preferenceStore = CUIPlugin.getDefault().getPreferenceStore();
if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) && isSmartMode()) {
indentStringAfterNewLine(document, command);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.java
index aaba76f5b0a..44048fef3fa 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.java
@@ -53,10 +53,9 @@ public class CStringDoubleClickSelector extends CDoubleClickSelector {
* @param partitioning the document partitioning
* @param doubleClickStrategy the fallback double click strategy
*/
- public CStringDoubleClickSelector(String partitioning,
- ITextDoubleClickStrategy doubleClickStrategy) {
- fPartitioning= partitioning;
- fFallbackStrategy= doubleClickStrategy;
+ public CStringDoubleClickSelector(String partitioning, ITextDoubleClickStrategy doubleClickStrategy) {
+ fPartitioning = partitioning;
+ fFallbackStrategy = doubleClickStrategy;
}
/*
@@ -64,14 +63,14 @@ public class CStringDoubleClickSelector extends CDoubleClickSelector {
*/
@Override
public void doubleClicked(ITextViewer textViewer) {
- int offset= textViewer.getSelectedRange().x;
+ int offset = textViewer.getSelectedRange().x;
if (offset < 0)
return;
- IDocument document= textViewer.getDocument();
+ IDocument document = textViewer.getDocument();
- IRegion region= matchString(document, offset);
+ IRegion region = matchString(document, offset);
if (region != null) {
if (region.getLength() >= 2) {
textViewer.setSelectedRange(region.getOffset() + 1, region.getLength() - 2);
@@ -79,7 +78,7 @@ public class CStringDoubleClickSelector extends CDoubleClickSelector {
} else if (fFallbackStrategy != null) {
fFallbackStrategy.doubleClicked(textViewer);
} else {
- region= selectWord(document, offset);
+ region = selectWord(document, offset);
if (region != null) {
textViewer.setSelectedRange(region.getOffset(), region.getLength());
}
@@ -88,19 +87,18 @@ public class CStringDoubleClickSelector extends CDoubleClickSelector {
private IRegion matchString(IDocument document, int offset) {
try {
- if ((document.getChar(offset) == '"') || (document.getChar(offset) == '\'') ||
- (document.getChar(offset - 1) == '"') || (document.getChar(offset - 1) == '\''))
- {
- ITypedRegion region= TextUtilities.getPartition(document, fPartitioning, offset, true);
+ if ((document.getChar(offset) == '"') || (document.getChar(offset) == '\'')
+ || (document.getChar(offset - 1) == '"') || (document.getChar(offset - 1) == '\'')) {
+ ITypedRegion region = TextUtilities.getPartition(document, fPartitioning, offset, true);
// little hack: in case this strategy is used in preprocessor partitions, the string
// partition inside the preprocessor partition must be computed in an extra step
if (ICPartitions.C_PREPROCESSOR.equals(region.getType())) {
- String ppDirective= document.get(region.getOffset(), region.getLength());
- int hashIdx= ppDirective.indexOf('#');
- document= new Document(ppDirective.substring(hashIdx+1));
+ String ppDirective = document.get(region.getOffset(), region.getLength());
+ int hashIdx = ppDirective.indexOf('#');
+ document = new Document(ppDirective.substring(hashIdx + 1));
new CDocumentSetupParticipant().setup(document);
- int delta= region.getOffset() + hashIdx + 1;
- region= TextUtilities.getPartition(document, fPartitioning, offset - delta, true);
+ int delta = region.getOffset() + hashIdx + 1;
+ region = TextUtilities.getPartition(document, fPartitioning, offset - delta, true);
return new Region(region.getOffset() + delta, region.getLength());
}
return region;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
index 8ea5a66a5cb..b386f5a641d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -33,7 +33,6 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
import org.eclipse.cdt.internal.ui.text.util.CColorManager;
-
/**
* Tools required to configure a C/C++ source viewer.
* Scanners must be configured using a {@link CSourceViewerConfiguration}.
@@ -53,7 +52,7 @@ public class CTextTools {
* Creates a new C text tools instance.
*/
public CTextTools() {
- fColorManager= new CColorManager(true);
+ fColorManager = new CColorManager(true);
}
/**
@@ -62,7 +61,7 @@ public class CTextTools {
public void dispose() {
if (fColorManager != null) {
fColorManager.dispose();
- fColorManager= null;
+ fColorManager = null;
}
}
@@ -74,7 +73,7 @@ public class CTextTools {
}
/**
- * Returns a scanner which is configured to scan
+ * Returns a scanner which is configured to scan
* C-specific partitions, which are preprocessor directives, comments,
* and regular C source code.
*
@@ -94,15 +93,15 @@ public class CTextTools {
/**
* Sets up the document partitioner for the given document for the given partitioning.
- *
+ *
* @param document
* @param partitioning
* @param owner may be null
*/
public void setupCDocumentPartitioner(IDocument document, String partitioning, IDocCommentOwner owner) {
- IDocumentPartitioner partitioner= createDocumentPartitioner(owner);
+ IDocumentPartitioner partitioner = createDocumentPartitioner(owner);
if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
+ IDocumentExtension3 extension3 = (IDocumentExtension3) document;
extension3.setDocumentPartitioner(partitioning, partitioner);
} else {
document.setDocumentPartitioner(partitioner);
@@ -112,19 +111,19 @@ public class CTextTools {
/**
* Sets up the given document for the default partitioning.
- *
+ *
* @param document the document to be set up
* @param location the path of the resource backing the document. May be null.
* @param locationKind the type of path specified above. May be null.
*/
public void setupCDocument(IDocument document, IPath location, LocationKind locationKind) {
- IDocCommentOwner owner= getDocumentationCommentOwner(location, locationKind);
+ IDocCommentOwner owner = getDocumentationCommentOwner(location, locationKind);
setupCDocumentPartitioner(document, fDocumentPartitioning, owner);
}
/**
* Sets up the given document for the default partitioning.
- *
+ *
* @param document the document to be set up
*/
public void setupCDocument(IDocument document) {
@@ -133,7 +132,7 @@ public class CTextTools {
/**
* Get the document partitioning used for the C partitioner.
- *
+ *
* @return the document partitioning used for the C partitioner
*/
public String getDocumentPartitioning() {
@@ -146,7 +145,7 @@ public class CTextTools {
public void setDocumentPartitioning(String documentPartitioning) {
fDocumentPartitioning = documentPartitioning;
}
-
+
/**
* @param location
* @param locationKind
@@ -155,8 +154,8 @@ public class CTextTools {
* workspace default is returned.
*/
private IDocCommentOwner getDocumentationCommentOwner(IPath location, LocationKind locationKind) {
- if(location!=null && LocationKind.IFILE.equals(locationKind)) {
- IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(location);
+ if (location != null && LocationKind.IFILE.equals(locationKind)) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(location);
return DocCommentOwnerManager.getInstance().getCommentOwner(file);
}
return DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
index e731a28858c..32b08615b53 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
@@ -19,18 +19,17 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
-
/**
* This is a helper class for the text editor to be able to determine, given a
* particular offset in a document, various candidates segments for things like
* context help, proposals and hovering.
*/
public class CWordFinder {
-
+
private static final char CBRACE_L = '{';
private static final char CBRACE_R = '}';
- private static final char PAREN_R = ')';
-
+ private static final char PAREN_R = ')';
+
/**
* This method determines for a given offset into a given document what the
* region is which defines the current word. A word is defined as a contiguous
@@ -44,7 +43,7 @@ public class CWordFinder {
* afunction(int a,| int b) --> word = length 0
* afunction(|) --> word = length 0
* </pre>
- *
+ *
* @param document
* The document to be examined
* @param offset
@@ -100,7 +99,7 @@ public class CWordFinder {
/**
* This method will determine the region for the name of the function within
* which the current offset is contained.
- *
+ *
* @param document
* The document to be examined
* @param offset
@@ -213,16 +212,16 @@ public class CWordFinder {
}
/**
- * This method will determine whether current offset is contained
- * in any function's body or it's outside it.
- *
+ * This method will determine whether current offset is contained
+ * in any function's body or it's outside it.
+ *
* @param document
* The document to be examined
* @param offset
* The offset into the document
- * @return
- * <code>true</code> if there is no function body around offset
- * <code>false</code> otherwise
+ * @return
+ * <code>true</code> if there is no function body around offset
+ * <code>false</code> otherwise
*/
public static boolean isGlobal(IDocument document, int offset) {
try {
@@ -244,30 +243,30 @@ public class CWordFinder {
return false;
} while (Character.isWhitespace(c));
// Container block seems to be not a function or statement body
- pos++; // step back one symbol
- bracketcount = 0; // let's search for upper block
+ pos++; // step back one symbol
+ bracketcount = 0; // let's search for upper block
}
}
}
} catch (BadLocationException x) {
// Ignore
}
- return true; // return true in case of unknown result or exception
+ return true; // return true in case of unknown result or exception
}
-
+
/**
* Searches for line feed symbols in string.
* First met '\r' or '\n' is treated as LF symbol
- *
+ *
* @param s
* string to search in.
* @return number of LFs met.
*/
- public static int countLFs (String s) {
+ public static int countLFs(String s) {
int counter = 0;
char lf = 0;
char c;
- for (int i= 0; i < s.length(); i++) {
+ for (int i = 0; i < s.length(); i++) {
c = s.charAt(i);
if (lf == 0) {
if (c == '\n' || c == '\r') {
@@ -282,14 +281,14 @@ public class CWordFinder {
}
/**
- * Checks whether the string contains any C-block delimiters ( { } )
- *
- * @param s
+ * Checks whether the string contains any C-block delimiters ( { } )
+ *
+ * @param s
* text to check
* @return true if curled brace found.
*/
- public static boolean hasCBraces (String s) {
- if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1)
+ public static boolean hasCBraces(String s) {
+ if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1)
return true;
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordIterator.java
index 036b8d84739..b519901a5e2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordIterator.java
@@ -39,7 +39,7 @@ public class CWordIterator extends BreakIterator {
* Creates a new word iterator.
*/
public CWordIterator() {
- fIterator= new CBreakIterator();
+ fIterator = new CBreakIterator();
first();
}
@@ -48,7 +48,7 @@ public class CWordIterator extends BreakIterator {
*/
@Override
public int first() {
- fIndex= fIterator.first();
+ fIndex = fIterator.first();
return fIndex;
}
@@ -57,7 +57,7 @@ public class CWordIterator extends BreakIterator {
*/
@Override
public int last() {
- fIndex= fIterator.last();
+ fIndex = fIterator.last();
return fIndex;
}
@@ -66,9 +66,9 @@ public class CWordIterator extends BreakIterator {
*/
@Override
public int next(int n) {
- int next= 0;
+ int next = 0;
while (--n > 0 && next != DONE) {
- next= next();
+ next = next();
}
return next;
}
@@ -78,7 +78,7 @@ public class CWordIterator extends BreakIterator {
*/
@Override
public int next() {
- fIndex= following(fIndex);
+ fIndex = following(fIndex);
return fIndex;
}
@@ -87,19 +87,18 @@ public class CWordIterator extends BreakIterator {
*/
@Override
public int previous() {
- fIndex= preceding(fIndex);
+ fIndex = preceding(fIndex);
return fIndex;
}
-
/*
* @see com.ibm.icu.text.BreakIterator#preceding(int)
*/
@Override
public int preceding(int offset) {
- int first= fIterator.preceding(offset);
+ int first = fIterator.preceding(offset);
if (isWhitespace(first, offset)) {
- int second= fIterator.preceding(first);
+ int second = fIterator.preceding(first);
if (second != DONE && !isDelimiter(second, first))
return second;
}
@@ -111,9 +110,9 @@ public class CWordIterator extends BreakIterator {
*/
@Override
public int following(int offset) {
- int first= fIterator.following(offset);
+ int first = fIterator.following(offset);
if (eatFollowingWhitespace(offset, first)) {
- int second= fIterator.following(first);
+ int second = fIterator.following(first);
if (isWhitespace(first, second))
return second;
}
@@ -148,10 +147,10 @@ public class CWordIterator extends BreakIterator {
Assert.isTrue(exclusiveEnd <= getText().getEndIndex());
Assert.isTrue(exclusiveEnd > offset);
- CharSequence seq= fIterator.fText;
+ CharSequence seq = fIterator.fText;
while (offset < exclusiveEnd) {
- char ch= seq.charAt(offset);
+ char ch = seq.charAt(offset);
if (ch != '\n' && ch != '\r')
return false;
offset++;
@@ -176,10 +175,10 @@ public class CWordIterator extends BreakIterator {
Assert.isTrue(exclusiveEnd <= getText().getEndIndex());
Assert.isTrue(exclusiveEnd > offset);
- CharSequence seq= fIterator.fText;
+ CharSequence seq = fIterator.fText;
while (offset < exclusiveEnd) {
- char ch= seq.charAt(offset);
+ char ch = seq.charAt(offset);
if (!Character.isWhitespace(ch))
return false;
if (ch == '\n' || ch == '\r')
@@ -234,7 +233,7 @@ public class CWordIterator extends BreakIterator {
/**
* Enables breaks at word boundaries inside a camel case identifier.
- *
+ *
* @param camelCaseBreakEnabled <code>true</code> to enable,
* <code>false</code> to disable.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CombinedWordRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CombinedWordRule.java
index bce36990889..98ce819224b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CombinedWordRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CombinedWordRule.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -50,7 +50,7 @@ public class CombinedWordRule implements IRule {
*/
public static class WordMatcher {
/** The table of predefined words and token for this matcher */
- private Map<CharacterBuffer, IToken> fWords= new HashMap<CharacterBuffer, IToken>();
+ private Map<CharacterBuffer, IToken> fWords = new HashMap<CharacterBuffer, IToken>();
/**
* Adds a word and the token to be returned if it is detected.
@@ -73,7 +73,7 @@ public class CombinedWordRule implements IRule {
* @return the token or <code>null</code> if none is associated by this matcher
*/
public IToken evaluate(ICharacterScanner scanner, CharacterBuffer word) {
- IToken token= fWords.get(word);
+ IToken token = fWords.get(word);
if (token != null)
return token;
return Token.UNDEFINED;
@@ -94,10 +94,10 @@ public class CombinedWordRule implements IRule {
/** Buffer content */
private char[] fContent;
/** Buffer content size */
- private int fLength= 0;
+ private int fLength = 0;
/** Is hash code cached? */
- private boolean fIsHashCached= false;
+ private boolean fIsHashCached = false;
/** The hash code */
private int fHashCode;
@@ -107,7 +107,7 @@ public class CombinedWordRule implements IRule {
* @param capacity the initial capacity
*/
public CharacterBuffer(int capacity) {
- fContent= new char[capacity];
+ fContent = new char[capacity];
}
/**
@@ -116,16 +116,16 @@ public class CombinedWordRule implements IRule {
* @param content the initial content
*/
public CharacterBuffer(String content) {
- fContent= content.toCharArray();
- fLength= content.length();
+ fContent = content.toCharArray();
+ fLength = content.length();
}
/**
* Empties this buffer.
*/
public void clear() {
- fIsHashCached= false;
- fLength= 0;
+ fIsHashCached = false;
+ fLength = 0;
}
/**
@@ -134,13 +134,13 @@ public class CombinedWordRule implements IRule {
* @param c the character
*/
public void append(char c) {
- fIsHashCached= false;
+ fIsHashCached = false;
if (fLength == fContent.length) {
- char[] old= fContent;
- fContent= new char[old.length << 1];
+ char[] old = fContent;
+ fContent = new char[old.length << 1];
System.arraycopy(old, 0, fContent, 0, old.length);
}
- fContent[fLength++]= c;
+ fContent[fLength++] = c;
}
/**
@@ -180,11 +180,11 @@ public class CombinedWordRule implements IRule {
if (fIsHashCached)
return fHashCode;
- int hash= 0;
- for (int i= 0, n= fLength; i < n; i++)
- hash= 29*hash + fContent[i];
- fHashCode= hash;
- fIsHashCached= true;
+ int hash = 0;
+ for (int i = 0, n = fLength; i < n; i++)
+ hash = 29 * hash + fContent[i];
+ fHashCode = hash;
+ fIsHashCached = true;
return hash;
}
@@ -197,11 +197,11 @@ public class CombinedWordRule implements IRule {
return true;
if (!(obj instanceof CharacterBuffer))
return false;
- CharacterBuffer buffer= (CharacterBuffer) obj;
- int length= buffer.length();
+ CharacterBuffer buffer = (CharacterBuffer) obj;
+ int length = buffer.length();
if (length != fLength)
return false;
- for (int i= 0; i < length; i++)
+ for (int i = 0; i < length; i++)
if (buffer.charAt(i) != fContent[i])
return false;
return true;
@@ -214,10 +214,10 @@ public class CombinedWordRule implements IRule {
* @return <code>true</code> iff the content is the same character sequence as in the string
*/
public boolean equals(String string) {
- int length= string.length();
+ int length = string.length();
if (length != fLength)
return false;
- for (int i= 0; i < length; i++)
+ for (int i = 0; i < length; i++)
if (string.charAt(i) != fContent[i])
return false;
return true;
@@ -225,19 +225,19 @@ public class CombinedWordRule implements IRule {
}
/** Internal setting for the uninitialized column constraint */
- private static final int UNDEFINED= -1;
+ private static final int UNDEFINED = -1;
/** The word detector used by this rule */
private IWordDetector fDetector;
/** The default token to be returned on success and if nothing else has been specified. */
private IToken fDefaultToken;
/** The column constraint */
- private int fColumn= UNDEFINED;
+ private int fColumn = UNDEFINED;
/** Buffer used for pattern detection */
- private CharacterBuffer fBuffer= new CharacterBuffer(16);
+ private CharacterBuffer fBuffer = new CharacterBuffer(16);
/** List of word matchers */
- private List<WordMatcher> fMatchers= new ArrayList<WordMatcher>();
+ private List<WordMatcher> fMatchers = new ArrayList<WordMatcher>();
/**
* Creates a rule which, with the help of an word detector, will return the token
@@ -300,8 +300,8 @@ public class CombinedWordRule implements IRule {
Assert.isNotNull(detector);
Assert.isNotNull(defaultToken);
- fDetector= detector;
- fDefaultToken= defaultToken;
+ fDetector = detector;
+ fDefaultToken = defaultToken;
if (matcher != null)
addWordMatcher(matcher);
}
@@ -325,8 +325,8 @@ public class CombinedWordRule implements IRule {
*/
public void setColumnConstraint(int column) {
if (column < 0)
- column= UNDEFINED;
- fColumn= column;
+ column = UNDEFINED;
+ fColumn = column;
}
/*
@@ -334,19 +334,19 @@ public class CombinedWordRule implements IRule {
*/
@Override
public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
+ int c = scanner.read();
if (fDetector.isWordStart((char) c)) {
if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
fBuffer.clear();
do {
fBuffer.append((char) c);
- c= scanner.read();
+ c = scanner.read();
} while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
scanner.unread();
- for (int i= 0, n= fMatchers.size(); i < n; i++) {
- IToken token= fMatchers.get(i).evaluate(scanner, fBuffer);
+ for (int i = 0, n = fMatchers.size(); i < n; i++) {
+ IToken token = fMatchers.get(i).evaluate(scanner, fBuffer);
if (!token.isUndefined())
return token;
}
@@ -368,7 +368,7 @@ public class CombinedWordRule implements IRule {
* @param scanner the scanner to be used
*/
private void unreadBuffer(ICharacterScanner scanner) {
- for (int i= fBuffer.length() - 1; i >= 0; i--)
+ for (int i = fBuffer.length() - 1; i >= 0; i--)
scanner.unread();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.java
index ba08da2fc7f..909a9207111 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.java
@@ -25,7 +25,7 @@ import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
* A reconciling strategy consisting of a sequence of internal reconciling strategies.
* By default, all requests are passed on to the contained strategies.
*/
-public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
+public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
/** The list of internal reconciling strategies. */
private IReconcilingStrategy[] fStrategies;
@@ -42,7 +42,7 @@ public class CompositeReconcilingStrategy implements IReconcilingStrategy, IRec
* @param strategies the strategies to be set or <code>null</code>
*/
public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
- fStrategies= strategies;
+ fStrategies = strategies;
}
/**
@@ -62,7 +62,7 @@ public class CompositeReconcilingStrategy implements IReconcilingStrategy, IRec
if (fStrategies == null)
return;
- for (int i= 0; i < fStrategies.length; i++)
+ for (int i = 0; i < fStrategies.length; i++)
fStrategies[i].setDocument(document);
}
@@ -74,7 +74,7 @@ public class CompositeReconcilingStrategy implements IReconcilingStrategy, IRec
if (fStrategies == null)
return;
- for (int i= 0; i < fStrategies.length; i++)
+ for (int i = 0; i < fStrategies.length; i++)
fStrategies[i].reconcile(dirtyRegion, subRegion);
}
@@ -86,7 +86,7 @@ public class CompositeReconcilingStrategy implements IReconcilingStrategy, IRec
if (fStrategies == null)
return;
- for (int i= 0; i < fStrategies.length; i++)
+ for (int i = 0; i < fStrategies.length; i++)
fStrategies[i].reconcile(partition);
}
@@ -98,9 +98,9 @@ public class CompositeReconcilingStrategy implements IReconcilingStrategy, IRec
if (fStrategies == null)
return;
- for (int i=0; i < fStrategies.length; i++) {
+ for (int i = 0; i < fStrategies.length; i++) {
if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
+ IReconcilingStrategyExtension extension = (IReconcilingStrategyExtension) fStrategies[i];
extension.setProgressMonitor(monitor);
}
}
@@ -116,7 +116,7 @@ public class CompositeReconcilingStrategy implements IReconcilingStrategy, IRec
for (int i = 0; i < fStrategies.length; i++) {
if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
- IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
+ IReconcilingStrategyExtension extension = (IReconcilingStrategyExtension) fStrategies[i];
extension.initialReconcile();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java
index 2123baa6609..3da600296a8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java
@@ -19,7 +19,6 @@ 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
@@ -34,7 +33,7 @@ import org.eclipse.jface.text.IDocument;
*/
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;
@@ -80,10 +79,10 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
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();
}
@@ -144,7 +143,7 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
@Override
public char setIndex(int position) {
if (position >= getBeginIndex() && position <= getEndIndex())
- fIndex= position;
+ fIndex = position;
else
throw new IllegalArgumentException();
@@ -232,7 +231,7 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
throw new IndexOutOfBoundsException();
return new DocumentCharacterIterator(fDocument, getBeginIndex() + start, getBeginIndex() + end);
}
-
+
/*
* @see java.lang.CharSequence#toString()
*/
@@ -240,7 +239,7 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
public String toString() {
int length = length();
char[] chs = new char[length];
- for (int i=0; i<length; ++i) {
+ for (int i = 0; i < length; ++i) {
chs[i] = charAt(i);
}
return new String(chs);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java
index b32f2b78c1f..c5d14418b4b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java
@@ -33,47 +33,45 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
*/
public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPartitions {
// states
- private static final int CCODE= 0;
- private static final int SINGLE_LINE_COMMENT= 1;
- private static final int MULTI_LINE_COMMENT= 2;
- private static final int CHARACTER= 3;
- private static final int STRING= 4;
- private static final int RAW_STRING= 5;
- private static final int PREPROCESSOR= 6;
- private static final int PREPROCESSOR_MULTI_LINE_COMMENT= 7;
- private static final int PREPROCESSOR_STRING= 8;
- private static final int SINGLE_LINE_DOC_COMMENT= 9;
- private static final int MULTI_LINE_DOC_COMMENT= 10;
-
+ private static final int CCODE = 0;
+ private static final int SINGLE_LINE_COMMENT = 1;
+ private static final int MULTI_LINE_COMMENT = 2;
+ private static final int CHARACTER = 3;
+ private static final int STRING = 4;
+ private static final int RAW_STRING = 5;
+ private static final int PREPROCESSOR = 6;
+ private static final int PREPROCESSOR_MULTI_LINE_COMMENT = 7;
+ private static final int PREPROCESSOR_STRING = 8;
+ private static final int SINGLE_LINE_DOC_COMMENT = 9;
+ private static final int MULTI_LINE_DOC_COMMENT = 10;
+
/**
* Sub state for raw strings.
*/
private enum RawStringState {
- OPEN_DELIMITER,
- CONTENT,
- CLOSE_DELIMITER
+ OPEN_DELIMITER, CONTENT, CLOSE_DELIMITER
}
-
+
// beginning of prefixes and postfixes
- private static final int NONE= 0;
- private static final int BACKSLASH= 1; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
- private static final int SLASH= 2; // prefix for SINGLE_LINE or MULTI_LINE
- private static final int SLASH_STAR= 3; // prefix for MULTI_LINE_COMMENT
- private static final int STAR= 4; // postfix for MULTI_LINE_COMMENT
- private static final int CARRIAGE_RETURN=5; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
- private static final int BACKSLASH_CR= 6; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
- private static final int BACKSLASH_BACKSLASH= 7; // postfix for STRING, CHARACTER
- private static final int RAW_STRING_R= 8; // prefix for RAW_STRING
- private static final int IDENT= 9;
-
+ private static final int NONE = 0;
+ private static final int BACKSLASH = 1; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+ private static final int SLASH = 2; // prefix for SINGLE_LINE or MULTI_LINE
+ private static final int SLASH_STAR = 3; // prefix for MULTI_LINE_COMMENT
+ private static final int STAR = 4; // postfix for MULTI_LINE_COMMENT
+ private static final int CARRIAGE_RETURN = 5; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+ private static final int BACKSLASH_CR = 6; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+ private static final int BACKSLASH_BACKSLASH = 7; // postfix for STRING, CHARACTER
+ private static final int RAW_STRING_R = 8; // prefix for RAW_STRING
+ private static final int IDENT = 9;
+
/** The scanner. */
- private final BufferedDocumentScanner fScanner= new BufferedDocumentScanner(1000); // faster implementation
-
+ private final BufferedDocumentScanner fScanner = new BufferedDocumentScanner(1000); // faster implementation
+
/** The offset of the last returned token. */
private int fTokenOffset;
/** The length of the last returned token. */
private int fTokenLength;
-
+
/** The state of the scanner. */
private int fState;
/** The last significant characters read. */
@@ -81,34 +79,25 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
/** The amount of characters already read on first call to nextToken(). */
private int fPrefixLength;
/** Indicate whether current char is first non-whitespace char on the line*/
- private boolean fFirstCharOnLine= true;
+ private boolean fFirstCharOnLine = true;
/** An optional (possibly null) comment owner for detecting documentation-comments */
private final IDocCommentOwner fOwner;
-
+
private IDocument fDocument;
-
- private final IToken[] fTokens= new IToken[] {
- new Token(null),
- new Token(C_SINGLE_LINE_COMMENT),
- new Token(C_MULTI_LINE_COMMENT),
- new Token(C_CHARACTER),
- new Token(C_STRING),
- new Token(C_STRING),
- new Token(C_PREPROCESSOR),
- new Token(C_MULTI_LINE_COMMENT),
- new Token(C_PREPROCESSOR),
- new Token(C_SINGLE_LINE_DOC_COMMENT),
- new Token(C_MULTI_LINE_DOC_COMMENT)
- };
-
+
+ private final IToken[] fTokens = new IToken[] { new Token(null), new Token(C_SINGLE_LINE_COMMENT),
+ new Token(C_MULTI_LINE_COMMENT), new Token(C_CHARACTER), new Token(C_STRING), new Token(C_STRING),
+ new Token(C_PREPROCESSOR), new Token(C_MULTI_LINE_COMMENT), new Token(C_PREPROCESSOR),
+ new Token(C_SINGLE_LINE_DOC_COMMENT), new Token(C_MULTI_LINE_DOC_COMMENT) };
+
private final StringBuilder fRawStringDelimiter = new StringBuilder(12);
public FastCPartitionScanner(IDocCommentOwner owner) {
- fOwner = owner;
+ fOwner = owner;
}
-
+
public FastCPartitionScanner() {
- this(null);
+ this(null);
}
/*
@@ -117,52 +106,52 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
@Override
public IToken nextToken() {
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
RawStringState rawStringState = RawStringState.OPEN_DELIMITER;
int rawStringDelimiterIdx = 0;
-
+
while (true) {
- final int ch= fScanner.read();
-
- final boolean isFirstCharOnLine= fFirstCharOnLine;
+ final int ch = fScanner.read();
+
+ final boolean isFirstCharOnLine = fFirstCharOnLine;
if (isFirstCharOnLine && ch != ' ' && ch != '\t') {
- fFirstCharOnLine= false;
+ fFirstCharOnLine = false;
}
// characters
- switch (ch) {
- case ICharacterScanner.EOF:
- fLast= NONE; // ignore last
- if (fTokenLength > 0) {
- return preFix(fState, CCODE, NONE, 0);
- } else {
- fPrefixLength= 0;
+ switch (ch) {
+ case ICharacterScanner.EOF:
+ fLast = NONE; // ignore last
+ if (fTokenLength > 0) {
+ return preFix(fState, CCODE, NONE, 0);
+ } else {
+ fPrefixLength = 0;
return Token.EOF;
- }
+ }
- case '\r':
- fFirstCharOnLine= true;
- if (fLast == BACKSLASH || fLast == BACKSLASH_BACKSLASH) {
- fLast= BACKSLASH_CR;
+ case '\r':
+ fFirstCharOnLine = true;
+ if (fLast == BACKSLASH || fLast == BACKSLASH_BACKSLASH) {
+ fLast = BACKSLASH_CR;
fTokenLength++;
- continue;
- } else if (fLast != CARRIAGE_RETURN) {
- fLast= CARRIAGE_RETURN;
- fTokenLength++;
- continue;
- } else {
- // fLast == CARRIAGE_RETURN
+ continue;
+ } else if (fLast != CARRIAGE_RETURN) {
+ fLast = CARRIAGE_RETURN;
+ fTokenLength++;
+ continue;
+ } else {
+ // fLast == CARRIAGE_RETURN
switch (fState) {
case SINGLE_LINE_COMMENT:
case CHARACTER:
case STRING:
case PREPROCESSOR:
if (fTokenLength > 0) {
- IToken token= fTokens[fState];
- fLast= CARRIAGE_RETURN;
- fPrefixLength= 1;
+ IToken token = fTokens[fState];
+ fLast = CARRIAGE_RETURN;
+ fPrefixLength = 1;
- fState= CCODE;
+ fState = CCODE;
return token;
} else {
consume();
@@ -173,24 +162,24 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
consume();
continue;
}
- }
+ }
- case '\\':
+ case '\\':
switch (fState) {
case CHARACTER:
case STRING:
case PREPROCESSOR_STRING:
fTokenLength++;
- fLast= fLast == BACKSLASH ? BACKSLASH_BACKSLASH : BACKSLASH;
+ fLast = fLast == BACKSLASH ? BACKSLASH_BACKSLASH : BACKSLASH;
continue;
default:
fTokenLength++;
- fLast= BACKSLASH;
+ fLast = BACKSLASH;
continue;
- }
+ }
- case '\n':
- fFirstCharOnLine= true;
+ case '\n':
+ fFirstCharOnLine = true;
switch (fState) {
case SINGLE_LINE_COMMENT:
case CHARACTER:
@@ -222,60 +211,60 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
int newState;
switch (ch) {
case '/':
- last= SLASH;
- newState= CCODE;
+ last = SLASH;
+ newState = CCODE;
break;
case '*':
- last= STAR;
- newState= CCODE;
+ last = STAR;
+ newState = CCODE;
break;
case '\'':
- last= NONE;
- newState= CHARACTER;
+ last = NONE;
+ newState = CHARACTER;
break;
case '"':
- last= NONE;
- newState= STRING;
+ last = NONE;
+ newState = STRING;
break;
case '\r':
- last= CARRIAGE_RETURN;
- newState= CCODE;
+ last = CARRIAGE_RETURN;
+ newState = CCODE;
break;
case '\\':
- last= BACKSLASH;
- newState= CCODE;
+ last = BACKSLASH;
+ newState = CCODE;
break;
case '#':
- last= NONE;
- newState= PREPROCESSOR;
+ last = NONE;
+ newState = PREPROCESSOR;
break;
default:
- last= NONE;
- newState= CCODE;
+ last = NONE;
+ newState = CCODE;
break;
}
- fLast= NONE; // ignore fLast
+ fLast = NONE; // ignore fLast
return preFix(fState, newState, last, 1);
case CCODE:
if (ch == '#' && isFirstCharOnLine) {
- fLast= NONE; // ignore fLast
- int column= fScanner.getColumn() - 1;
+ fLast = NONE; // ignore fLast
+ int column = fScanner.getColumn() - 1;
fTokenLength -= column;
if (fTokenLength > 0) {
return preFix(fState, PREPROCESSOR, NONE, column + 1);
} else {
preFix(fState, PREPROCESSOR, NONE, column + 1);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
}
@@ -288,8 +277,8 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
}
// states
- switch (fState) {
- case CCODE:
+ switch (fState) {
+ case CCODE:
switch (ch) {
case '/':
if (fLast == SLASH) {
@@ -298,15 +287,15 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
} else {
preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
} else {
fTokenLength++;
- fLast= SLASH;
+ fLast = SLASH;
break;
}
-
+
case '*':
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0) {
@@ -314,22 +303,22 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
} else {
preFix(CCODE, MULTI_LINE_COMMENT, SLASH_STAR, 2);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
} else {
consume();
break;
}
-
+
case '\'':
- fLast= NONE; // ignore fLast
+ fLast = NONE; // ignore fLast
if (fTokenLength > 0) {
return preFix(CCODE, CHARACTER, NONE, 1);
} else {
preFix(CCODE, CHARACTER, NONE, 1);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
@@ -341,15 +330,15 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
}
fTokenLength++;
continue;
-
- case 'R':
- if (fLast == RAW_STRING_R) {
- fLast = IDENT;
- } else if (fLast != IDENT) {
- fLast = RAW_STRING_R;
- }
- fTokenLength++;
- continue;
+
+ case 'R':
+ if (fLast == RAW_STRING_R) {
+ fLast = IDENT;
+ } else if (fLast != IDENT) {
+ fLast = RAW_STRING_R;
+ }
+ fTokenLength++;
+ continue;
case '"':
int newState = STRING;
@@ -358,33 +347,33 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
rawStringState = RawStringState.OPEN_DELIMITER;
fRawStringDelimiter.setLength(0);
}
- fLast= NONE; // ignore fLast
- if (fTokenLength > 0 ) {
+ fLast = NONE; // ignore fLast
+ if (fTokenLength > 0) {
return preFix(CCODE, newState, NONE, 1);
} else {
preFix(CCODE, newState, NONE, 1);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
-
+
case '#':
if (isFirstCharOnLine) {
- int column= fScanner.getColumn() - 1;
+ int column = fScanner.getColumn() - 1;
fTokenLength -= column;
if (fTokenLength > 0) {
return preFix(fState, PREPROCESSOR, NONE, column + 1);
} else {
preFix(fState, PREPROCESSOR, NONE, column + 1);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
}
consume();
break;
default:
- if ('a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch =='_') {
+ if ('a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_') {
fLast = IDENT;
fTokenOffset++;
} else if ('0' <= ch && ch <= '9' && fLast == IDENT) {
@@ -396,12 +385,12 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
}
break;
- case SINGLE_LINE_COMMENT:
+ case SINGLE_LINE_COMMENT:
consume();
- break;
+ break;
- case PREPROCESSOR:
- switch (ch) {
+ case PREPROCESSOR:
+ switch (ch) {
case '/':
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0) {
@@ -409,15 +398,15 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
} else {
preFix(fState, SINGLE_LINE_COMMENT, SLASH, 2);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
} else {
fTokenLength++;
- fLast= SLASH;
+ fLast = SLASH;
}
break;
-
+
case '*':
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0) {
@@ -425,7 +414,7 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
} else {
preFix(fState, PREPROCESSOR_MULTI_LINE_COMMENT, SLASH_STAR, 2);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
}
@@ -434,61 +423,61 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
case '"':
if (fLast != BACKSLASH) {
- fState= PREPROCESSOR_STRING;
+ fState = PREPROCESSOR_STRING;
}
consume();
break;
-
- default:
+
+ default:
consume();
- break;
- }
- break;
+ break;
+ }
+ break;
- case PREPROCESSOR_STRING:
+ case PREPROCESSOR_STRING:
switch (ch) {
case '"':
if (fLast != BACKSLASH) {
- fState= PREPROCESSOR;
+ fState = PREPROCESSOR;
}
consume();
break;
-
- default:
+
+ default:
consume();
- break;
+ break;
}
break;
-
- case PREPROCESSOR_MULTI_LINE_COMMENT:
+
+ case PREPROCESSOR_MULTI_LINE_COMMENT:
switch (ch) {
case '*':
fTokenLength++;
- fLast= STAR;
+ fLast = STAR;
break;
-
+
case '/':
if (fLast == STAR) {
- IToken token= postFix(fState);
- fState= PREPROCESSOR;
+ IToken token = postFix(fState);
+ fState = PREPROCESSOR;
return token;
}
consume();
break;
-
+
default:
consume();
break;
}
break;
-
- case MULTI_LINE_COMMENT:
+
+ case MULTI_LINE_COMMENT:
switch (ch) {
case '*':
fTokenLength++;
- fLast= STAR;
+ fLast = STAR;
break;
-
+
case '/':
if (fLast == STAR) {
return postFix(MULTI_LINE_COMMENT);
@@ -496,98 +485,98 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
consume();
break;
}
-
+
default:
consume();
break;
}
break;
-
- case STRING:
- switch (ch) {
+
+ case STRING:
+ switch (ch) {
case '\"':
- if (fLast != BACKSLASH) {
- return postFix(STRING);
- } else {
- consume();
- break;
- }
-
- default:
+ if (fLast != BACKSLASH) {
+ return postFix(STRING);
+ } else {
+ consume();
+ break;
+ }
+
+ default:
consume();
- break;
- }
- break;
-
- case RAW_STRING:
- switch (rawStringState) {
- case OPEN_DELIMITER:
- switch (ch) {
- case '(':
- rawStringState = RawStringState.CONTENT;
- break;
+ break;
+ }
+ break;
+
+ case RAW_STRING:
+ switch (rawStringState) {
+ case OPEN_DELIMITER:
+ switch (ch) {
+ case '(':
+ rawStringState = RawStringState.CONTENT;
+ break;
case ' ':
- case '\\':
- case ')':
- case '\t':
- case '\n':
- case '\f':
- case 11: // Vertical tab
- fState = STRING;
- break;
- default:
- if (fRawStringDelimiter.length() < 12) {
- fRawStringDelimiter.append((char) ch);
- } else {
- fState = STRING;
- }
- }
- consume();
- break;
- case CONTENT:
- if (ch == ')') {
- rawStringState = RawStringState.CLOSE_DELIMITER;
- rawStringDelimiterIdx = 0;
- }
- consume();
- break;
- case CLOSE_DELIMITER:
- if (ch == ')') {
- rawStringDelimiterIdx = 0;
- } else if (rawStringDelimiterIdx < fRawStringDelimiter.length()) {
- if (fRawStringDelimiter.charAt(rawStringDelimiterIdx) != ch) {
- rawStringState = RawStringState.CONTENT;
- } else {
- ++rawStringDelimiterIdx;
- }
- } else if (ch == '"') {
- return postFix(RAW_STRING);
- } else {
- rawStringState = RawStringState.CONTENT;
- }
- consume();
- break;
- }
- break;
-
- case CHARACTER:
- switch (ch) {
- case '\'':
- if (fLast != BACKSLASH) {
- return postFix(CHARACTER);
- } else {
- consume();
- break;
- }
-
- default:
+ case '\\':
+ case ')':
+ case '\t':
+ case '\n':
+ case '\f':
+ case 11: // Vertical tab
+ fState = STRING;
+ break;
+ default:
+ if (fRawStringDelimiter.length() < 12) {
+ fRawStringDelimiter.append((char) ch);
+ } else {
+ fState = STRING;
+ }
+ }
+ consume();
+ break;
+ case CONTENT:
+ if (ch == ')') {
+ rawStringState = RawStringState.CLOSE_DELIMITER;
+ rawStringDelimiterIdx = 0;
+ }
+ consume();
+ break;
+ case CLOSE_DELIMITER:
+ if (ch == ')') {
+ rawStringDelimiterIdx = 0;
+ } else if (rawStringDelimiterIdx < fRawStringDelimiter.length()) {
+ if (fRawStringDelimiter.charAt(rawStringDelimiterIdx) != ch) {
+ rawStringState = RawStringState.CONTENT;
+ } else {
+ ++rawStringDelimiterIdx;
+ }
+ } else if (ch == '"') {
+ return postFix(RAW_STRING);
+ } else {
+ rawStringState = RawStringState.CONTENT;
+ }
consume();
- break;
- }
- break;
- }
+ break;
+ }
+ break;
+
+ case CHARACTER:
+ switch (ch) {
+ case '\'':
+ if (fLast != BACKSLASH) {
+ return postFix(CHARACTER);
+ } else {
+ consume();
+ break;
+ }
+
+ default:
+ consume();
+ break;
+ }
+ break;
+ }
}
- }
+ }
private static final int getLastLength(int last) {
switch (last) {
@@ -597,7 +586,7 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
case NONE:
case IDENT:
return 0;
-
+
case CARRIAGE_RETURN:
case BACKSLASH:
case SLASH:
@@ -614,26 +603,26 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
private final void consume() {
fTokenLength++;
- fLast= NONE;
+ fLast = NONE;
}
-
+
private final IToken postFix(int state) {
return postFix(state, CCODE);
}
-
+
private final IToken postFix(int state, int newState) {
fTokenLength++;
- fLast= NONE;
- fState= newState;
- fPrefixLength= 0;
+ fLast = NONE;
+ fState = newState;
+ fPrefixLength = 0;
return fTokens[interceptTokenState(state)];
}
private final IToken preFix(int state, int newState, int last, int prefixLength) {
fTokenLength -= getLastLength(fLast);
- fLast= last;
- fPrefixLength= prefixLength;
- fState= newState;
+ fLast = last;
+ fPrefixLength = prefixLength;
+ fState = newState;
return fTokens[interceptTokenState(state)];
}
@@ -664,14 +653,14 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
*/
@Override
public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
- fDocument= document;
+ fDocument = document;
fScanner.setRange(document, offset, length);
- fTokenOffset= partitionOffset;
- fTokenLength= 0;
- fPrefixLength= offset - partitionOffset;
- fLast= NONE;
-
- fState= getState(contentType);
+ fTokenOffset = partitionOffset;
+ fTokenLength = 0;
+ fPrefixLength = offset - partitionOffset;
+ fLast = NONE;
+
+ fState = getState(contentType);
if (fState == STRING) {
// raw string is a special case: need to restart from partition offset
try {
@@ -690,32 +679,32 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
}
if (offset == partitionOffset) {
// restart at beginning of partition
- fState= CCODE;
+ fState = CCODE;
}
try {
- int column= fScanner.getColumn();
- fFirstCharOnLine= column == 0 || document.get(offset-column, column).trim().length() == 0;
+ int column = fScanner.getColumn();
+ fFirstCharOnLine = column == 0 || document.get(offset - column, column).trim().length() == 0;
} catch (BadLocationException exc) {
- fFirstCharOnLine= true;
+ fFirstCharOnLine = true;
}
}
@Override
public void setRange(IDocument document, int offset, int length) {
- fDocument= document;
+ fDocument = document;
fScanner.setRange(document, offset, length);
- fTokenOffset= offset;
- fTokenLength= 0;
- fPrefixLength= 0;
- fLast= NONE;
- fState= CCODE;
+ fTokenOffset = offset;
+ fTokenLength = 0;
+ fPrefixLength = 0;
+ fLast = NONE;
+ fState = CCODE;
try {
- int column= fScanner.getColumn();
- fFirstCharOnLine= column == 0 || document.get(offset-column, column).trim().length() == 0;
+ int column = fScanner.getColumn();
+ fFirstCharOnLine = column == 0 || document.get(offset - column, column).trim().length() == 0;
} catch (BadLocationException exc) {
- fFirstCharOnLine= true;
+ fFirstCharOnLine = true;
}
}
@@ -752,7 +741,7 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
}
return proposedTokenState;
}
-
+
/**
* @return the DocCommentOwner associated with this partition scanner, or null
* if there is no owner.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java
index 1382b6eb2a1..8efae427f7b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java
@@ -28,7 +28,7 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
public class FastCPartitioner extends FastPartitioner {
/**
* Creates a new partitioner for the given content types.
- *
+ *
* @param scanner
* @param legalContentTypes
*/
@@ -67,7 +67,7 @@ public class FastCPartitioner extends FastPartitioner {
}
return super.getPartition(offset, preferOpenPartitions);
}
-
+
/**
* @return the DocCommentOwner associated with this partition scanner, or null
* if there is no owner.
@@ -75,7 +75,7 @@ public class FastCPartitioner extends FastPartitioner {
*/
public IDocCommentOwner getDocCommentOwner() {
if (fScanner instanceof FastCPartitionScanner) {
- return ((FastCPartitionScanner)fScanner).getDocCommentOwner();
+ return ((FastCPartitionScanner) fScanner).getDocCommentOwner();
}
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java
index ce8ab1d031c..5eb11346314 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java
@@ -33,7 +33,7 @@ public class HTMLAnnotationHover extends DefaultAnnotationHover {
*/
@Override
protected String formatSingleMessage(String message) {
- StringBuilder buffer= new StringBuilder();
+ StringBuilder buffer = new StringBuilder();
HTMLPrinter.addPageProlog(buffer);
HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message));
HTMLPrinter.addPageEpilog(buffer);
@@ -46,12 +46,13 @@ public class HTMLAnnotationHover extends DefaultAnnotationHover {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected String formatMultipleMessages(List messages) {
- StringBuilder buffer= new StringBuilder();
+ StringBuilder buffer = new StringBuilder();
HTMLPrinter.addPageProlog(buffer);
- HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(CUIMessages.CAnnotationHover_multipleMarkers));
+ HTMLPrinter.addParagraph(buffer,
+ HTMLPrinter.convertToHTMLContent(CUIMessages.CAnnotationHover_multipleMarkers));
HTMLPrinter.startBulletList(buffer);
- Iterator<String> e= messages.iterator();
+ Iterator<String> e = messages.iterator();
while (e.hasNext())
HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent(e.next()));
HTMLPrinter.endBulletList(buffer);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java
index 055f8b9289e..e8ee5310ab7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java
@@ -18,7 +18,6 @@ package org.eclipse.cdt.internal.ui.text;
import java.io.IOException;
import java.io.Reader;
-
/**
* Provides a set of convenience methods for creating HTML pages.
*/
@@ -27,66 +26,65 @@ public class HTMLPrinter {
private static final String LB = "<"; //$NON-NLS-1$
private static final String CB = "</"; //$NON-NLS-1$
private static final String RB = ">"; //$NON-NLS-1$
-
-
+
private HTMLPrinter() {
}
-
+
private static String replace(String text, char c, String s) {
-
- int previous= 0;
- int current= text.indexOf(c, previous);
-
+
+ int previous = 0;
+ int current = text.indexOf(c, previous);
+
if (current == -1)
return text;
-
- StringBuilder buffer= new StringBuilder();
+
+ StringBuilder buffer = new StringBuilder();
while (current > -1) {
buffer.append(text.substring(previous, current));
buffer.append(s);
- previous= current + 1;
- current= text.indexOf(c, previous);
+ previous = current + 1;
+ current = text.indexOf(c, previous);
}
buffer.append(text.substring(previous));
-
+
return buffer.toString();
}
-
+
public static String convertToHTMLContent(String content) {
- content= replace(content, '<', "&lt;"); //$NON-NLS-1$
+ content = replace(content, '<', "&lt;"); //$NON-NLS-1$
return replace(content, '>', "&gt;"); //$NON-NLS-1$
}
-
+
public static String read(Reader rd) {
-
- StringBuilder buffer= new StringBuilder();
- char[] readBuffer= new char[2048];
-
+
+ StringBuilder buffer = new StringBuilder();
+ char[] readBuffer = new char[2048];
+
try {
- int n= rd.read(readBuffer);
+ int n = rd.read(readBuffer);
while (n > 0) {
buffer.append(readBuffer, 0, n);
- n= rd.read(readBuffer);
+ n = rd.read(readBuffer);
}
return buffer.toString();
} catch (IOException x) {
}
-
+
return null;
}
public static void insertPageProlog(StringBuffer buffer, int position) {
buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
}
-
+
public static void insertPageProlog(StringBuilder buffer, int position) {
buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
}
-
+
public static void addPageProlog(StringBuffer buffer) {
insertPageProlog(buffer, buffer.length());
}
-
+
public static void addPageProlog(StringBuilder buffer) {
insertPageProlog(buffer, buffer.length());
}
@@ -94,7 +92,7 @@ public class HTMLPrinter {
public static void addPageEpilog(StringBuffer buffer) {
buffer.append("</font></body></html>"); //$NON-NLS-1$
}
-
+
public static void addPageEpilog(StringBuilder buffer) {
buffer.append("</font></body></html>"); //$NON-NLS-1$
}
@@ -102,11 +100,11 @@ public class HTMLPrinter {
public static void startBulletList(StringBuffer buffer) {
buffer.append("<ul>"); //$NON-NLS-1$
}
-
+
public static void startBulletList(StringBuilder buffer) {
buffer.append("<ul>"); //$NON-NLS-1$
}
-
+
public static void endBulletList(StringBuffer buffer) {
buffer.append("</ul>"); //$NON-NLS-1$
}
@@ -126,7 +124,7 @@ public class HTMLPrinter {
buffer.append(RB);
}
}
-
+
private static void addTag(StringBuilder buffer, String bullet, String tag) {
if (bullet != null && tag != null) {
buffer.append(LB);
@@ -138,11 +136,11 @@ public class HTMLPrinter {
buffer.append(RB);
}
}
-
+
public static void addBullet(StringBuffer buffer, String bullet) {
addTag(buffer, bullet, "li"); //$NON-NLS-1$
}
-
+
public static void addBullet(StringBuilder buffer, String bullet) {
addTag(buffer, bullet, "li"); //$NON-NLS-1$
}
@@ -150,7 +148,7 @@ public class HTMLPrinter {
public static void addSmallHeader(StringBuffer buffer, String header) {
addTag(buffer, header, "h5"); //$NON-NLS-1$
}
-
+
public static void addSmallHeader(StringBuilder buffer, String header) {
addTag(buffer, header, "h5"); //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICReconcilingListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICReconcilingListener.java
index d6016fcd882..fd351362ba8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICReconcilingListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICReconcilingListener.java
@@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
/**
* Interface of an object listening to (AST-) reconciling.
* Inspired by JDT.
- *
+ *
* @since 4.0
*/
public interface ICReconcilingListener {
@@ -32,7 +32,7 @@ public interface ICReconcilingListener {
/**
* Called after reconciling has been finished.
- *
+ *
* @param ast
* the translation unit AST or <code>null</code> if the working
* copy was consistent or reconciliation has been cancelled
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.java
index 54cd03102ab..30aa2336689 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.java
@@ -19,29 +19,32 @@ package org.eclipse.cdt.internal.ui.text;
*/
public interface IHtmlTagConstants {
/** Html tag close prefix */
- public static final String HTML_CLOSE_PREFIX= "</"; //$NON-NLS-1$
+ public static final String HTML_CLOSE_PREFIX = "</"; //$NON-NLS-1$
/** Html entity characters */
- public static final char[] HTML_ENTITY_CHARACTERS= new char[] { '<', '>', ' ', '&', '^', '~', '\"' };
+ public static final char[] HTML_ENTITY_CHARACTERS = new char[] { '<', '>', ' ', '&', '^', '~', '\"' };
/**
* Html entity start.
*/
- public static final char HTML_ENTITY_START= '&';
+ public static final char HTML_ENTITY_START = '&';
/**
* Html entity end.
*/
- public static final char HTML_ENTITY_END= ';';
-
+ public static final char HTML_ENTITY_END = ';';
+
/** Html entity codes */
- public static final String[] HTML_ENTITY_CODES= new String[] { "&lt;", "&gt;", "&nbsp;", "&amp;", "&circ;", "&tilde;", "&quot;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ public static final String[] HTML_ENTITY_CODES = new String[] { "&lt;", "&gt;", "&nbsp;", "&amp;", "&circ;", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
+ "&tilde;", "&quot;" }; //$NON-NLS-1$ //$NON-NLS-2$
/** Html general tags */
- public static final String[] HTML_GENERAL_TAGS= new String[] { "a", "b", "blockquote", "br", "code", "dd", "dl", "dt", "em", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "i", "li", "nl", "ol", "p", "pre", "q", "strong", "tbody", "td", "th", "tr", "tt", "ul" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$ //$NON-NLS-30$
+ public static final String[] HTML_GENERAL_TAGS = new String[] { "a", "b", "blockquote", "br", "code", "dd", "dl", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$
+ "dt", "em", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "i", "li", "nl", "ol", "p", "pre", "q", "strong", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$//$NON-NLS-8$//$NON-NLS-9$//$NON-NLS-10$//$NON-NLS-11$//$NON-NLS-12$//$NON-NLS-13$//$NON-NLS-14$//$NON-NLS-15$//$NON-NLS-16$//$NON-NLS-17$
+ "tbody", "td", "th", "tr", "tt", "ul" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
/** Html tag postfix */
- public static final char HTML_TAG_POSTFIX= '>';
+ public static final char HTML_TAG_POSTFIX = '>';
/** Html tag prefix */
- public static final char HTML_TAG_PREFIX= '<';
+ public static final char HTML_TAG_PREFIX = '<';
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.java
index 52d8309937c..8e81e614274 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.java
@@ -21,33 +21,33 @@ import org.eclipse.core.runtime.IProgressMonitor;
* IProblemRequestorExtension
*/
public interface IProblemRequestorExtension {
-
+
/**
* Sets the progress monitor to this problem requestor.
- *
+ *
* @param monitor the progress monitor to be used
*/
void setProgressMonitor(IProgressMonitor monitor);
-
+
/**
* Sets the active state of this problem requestor.
- *
+ *
* @param isActive the state of this problem requestor
*/
void setIsActive(boolean isActive);
-
+
/**
* Informs the problem requestor that a sequence of reportings is about to start. While
* a sequence is active, multiple peering calls of <code>beginReporting</code> and
* <code>endReporting</code> can appear.
- *
+ *
* @since 3.0
*/
void beginReportingSequence();
-
+
/**
* Informs the problem requestor that the sequence of reportings has been finished.
- *
+ *
* @since 3.0
*/
void endReportingSequence();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineComparator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineComparator.java
index 8291cfaccea..eb15d8b9d32 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineComparator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineComparator.java
@@ -24,7 +24,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* This implementation of <code>IRangeComparator</code> compares lines of a document.
* The lines are compared using a DJB hash function.
- *
+ *
* @since 5.1
*/
public class LineComparator implements IRangeComparator {
@@ -32,32 +32,32 @@ public class LineComparator implements IRangeComparator {
private final IDocument fDocument;
private final long[] fHashes;
- /**
+ /**
* Create a line comparator for the given document.
- *
+ *
* @param document
*/
public LineComparator(IDocument document) {
- fDocument= document;
+ fDocument = document;
- fHashes= new long[fDocument.getNumberOfLines()];
+ fHashes = new long[fDocument.getNumberOfLines()];
for (int i = 0; i < fHashes.length; i++) {
fHashes[i] = UNKNOWN_HASH;
}
- }
+ }
/*
- * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount()
- */
- @Override
+ * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount()
+ */
+ @Override
public int getRangeCount() {
- return fDocument.getNumberOfLines();
- }
+ return fDocument.getNumberOfLines();
+ }
- /*
- * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int)
- */
- @Override
+ /*
+ * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int)
+ */
+ @Override
public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) {
try {
return getHash(thisIndex) == ((LineComparator) other).getHash(otherIndex);
@@ -65,7 +65,7 @@ public class LineComparator implements IRangeComparator {
CUIPlugin.log(e);
return false;
}
- }
+ }
/*
* @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator)
@@ -81,11 +81,11 @@ public class LineComparator implements IRangeComparator {
* @throws BadLocationException if the line number is invalid
*/
private int getHash(int line) throws BadLocationException {
- long hash= fHashes[line];
+ long hash = fHashes[line];
if (hash == UNKNOWN_HASH) {
- IRegion lineRegion= fDocument.getLineInformation(line);
- String lineContents= fDocument.get(lineRegion.getOffset(), lineRegion.getLength());
- hash= computeDJBHash(lineContents);
+ IRegion lineRegion = fDocument.getLineInformation(line);
+ String lineContents = fDocument.get(lineRegion.getOffset(), lineRegion.getLength());
+ hash = computeDJBHash(lineContents);
fHashes[line] = hash;
}
@@ -94,18 +94,18 @@ public class LineComparator implements IRangeComparator {
/**
* Compute a hash using the DJB hash algorithm
- *
+ *
* @param string the string for which to compute a hash
* @return the DJB hash value of the string
*/
private int computeDJBHash(String string) {
- int hash= 5381;
- int len= string.length();
- for (int i= 0; i < len; i++) {
- char ch= string.charAt(i);
- hash= (hash << 5) + hash + ch;
+ int hash = 5381;
+ int len = string.length();
+ for (int i = 0; i < len; i++) {
+ char ch = string.charAt(i);
+ hash = (hash << 5) + hash + ch;
}
return hash;
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/NumberRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/NumberRule.java
index c6bd44bd06b..20fc9e96b4f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/NumberRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/NumberRule.java
@@ -24,104 +24,96 @@ import org.eclipse.jface.text.rules.Token;
*
* @author P.Tomaszewski
*/
-public class NumberRule implements IRule
-{
- /** Style token. */
- private IToken token;
+public class NumberRule implements IRule {
+ /** Style token. */
+ private IToken token;
-
- /**
- * Creates new number rule.
- * @param token Style token.
- */
- public NumberRule(IToken token)
- {
- super();
- this.token = token;
- }
+ /**
+ * Creates new number rule.
+ * @param token Style token.
+ */
+ public NumberRule(IToken token) {
+ super();
+ this.token = token;
+ }
- /**
- * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
- */
- @Override
- public IToken evaluate(ICharacterScanner scanner)
- {
- int startCh = scanner.read();
- int ch;
- int unreadCount = 1;
+ /**
+ * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+ */
+ @Override
+ public IToken evaluate(ICharacterScanner scanner) {
+ int startCh = scanner.read();
+ int ch;
+ int unreadCount = 1;
- if (isNumberStart(startCh))
- {
- ch = startCh;
- if (startCh == '-' || startCh == '+') {
- ch = scanner.read();
- ++unreadCount;
- }
- if (ch == '0') {
- int xCh = scanner.read();
- if (xCh == 'x' || xCh == 'X') {
- // hexnumber starting with [+-]?0[xX]
- do {
- ch = scanner.read();
- } while (isHexNumberPart((char)ch));
- scanner.unread();
- return token;
- }
- scanner.unread();
- // assert ch == '0';
- } else if (ch == '.') {
- ch = scanner.read();
- ++unreadCount;
- }
- if (Character.isDigit((char)ch)) {
- // need at least one digit
- do {
- ch = scanner.read();
- } while (Character.isDigit((char)ch));
- if (ch == '.' && startCh != '.') {
- // fraction
- do {
- ch = scanner.read();
- } while (Character.isDigit((char)ch));
- }
- if (ch == 'e' || ch == 'E') {
- // exponent
- ch = scanner.read();
- if (ch == '-' || ch == '+' || Character.isDigit((char)ch)) {
- do {
- ch = scanner.read();
- } while (Character.isDigit((char)ch));
- }
- }
- scanner.unread();
- return token;
- }
- }
- do {
- scanner.unread();
- } while (--unreadCount > 0);
- return Token.UNDEFINED;
- }
+ if (isNumberStart(startCh)) {
+ ch = startCh;
+ if (startCh == '-' || startCh == '+') {
+ ch = scanner.read();
+ ++unreadCount;
+ }
+ if (ch == '0') {
+ int xCh = scanner.read();
+ if (xCh == 'x' || xCh == 'X') {
+ // hexnumber starting with [+-]?0[xX]
+ do {
+ ch = scanner.read();
+ } while (isHexNumberPart((char) ch));
+ scanner.unread();
+ return token;
+ }
+ scanner.unread();
+ // assert ch == '0';
+ } else if (ch == '.') {
+ ch = scanner.read();
+ ++unreadCount;
+ }
+ if (Character.isDigit((char) ch)) {
+ // need at least one digit
+ do {
+ ch = scanner.read();
+ } while (Character.isDigit((char) ch));
+ if (ch == '.' && startCh != '.') {
+ // fraction
+ do {
+ ch = scanner.read();
+ } while (Character.isDigit((char) ch));
+ }
+ if (ch == 'e' || ch == 'E') {
+ // exponent
+ ch = scanner.read();
+ if (ch == '-' || ch == '+' || Character.isDigit((char) ch)) {
+ do {
+ ch = scanner.read();
+ } while (Character.isDigit((char) ch));
+ }
+ }
+ scanner.unread();
+ return token;
+ }
+ }
+ do {
+ scanner.unread();
+ } while (--unreadCount > 0);
+ return Token.UNDEFINED;
+ }
- /**
- * Checks if start of number.
- * @param ch Char to check.
- * @return <b>true</b> if Number.
- */
- private boolean isNumberStart(int ch)
- {
- return ch == '-' || ch == '+' || ch == '.' || Character.isDigit((char)ch);
- }
-
- /**
- * Checks if part of hex number;
- * @param ch Char to check.
- * @return <b>true</b>
- */
- private boolean isHexNumberPart(int ch)
- {
- return Character.isDigit((char)ch) || ch == 'a' || ch == 'b'
- || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f' || ch == 'A'
- || ch == 'B' || ch == 'C' || ch == 'D' || ch == 'E' || ch == 'F';
- }
+ /**
+ * Checks if start of number.
+ * @param ch Char to check.
+ * @return <b>true</b> if Number.
+ */
+ private boolean isNumberStart(int ch) {
+ return ch == '-' || ch == '+' || ch == '.' || Character.isDigit((char) ch);
+ }
+
+ /**
+ * Checks if part of hex number;
+ * @param ch Char to check.
+ * @return <b>true</b>
+ */
+ private boolean isHexNumberPart(int ch) {
+ return Character.isDigit((char) ch) || ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd' || ch == 'e'
+ || ch == 'f' || ch == 'A' || ch == 'B' || ch == 'C' || ch == 'D' || ch == 'E' || ch == 'F';
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PartitionDamager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PartitionDamager.java
index b108de6e11e..924c0e77beb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PartitionDamager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PartitionDamager.java
@@ -25,7 +25,7 @@ import org.eclipse.jface.text.presentation.IPresentationDamager;
/**
* A simple presentation damager always damaging the whole partition.
* This is necessary if the partition contains multiline highlight regions.
- *
+ *
* @since 4.0
*/
public class PartitionDamager implements IPresentationDamager {
@@ -34,14 +34,13 @@ public class PartitionDamager implements IPresentationDamager {
* @see org.eclipse.jface.text.presentation.IPresentationDamager#getDamageRegion(org.eclipse.jface.text.ITypedRegion, org.eclipse.jface.text.DocumentEvent, boolean)
*/
@Override
- public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event,
- boolean documentPartitioningChanged) {
+ public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged) {
if (!documentPartitioningChanged && event.getOffset() == partition.getOffset() + partition.getLength()) {
IRegion lineRegion;
try {
lineRegion = event.fDocument.getLineInformationOfOffset(event.getOffset());
- int start= partition.getOffset();
- int end= lineRegion.getOffset() + lineRegion.getLength();
+ int start = partition.getOffset();
+ int end = lineRegion.getOffset() + lineRegion.getLength();
return new Region(start, end - start);
} catch (BadLocationException exc) {
// ignore
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java
index 66d5f1382cf..6083c6707e0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java
@@ -22,7 +22,7 @@ import org.eclipse.jface.text.rules.WordRule;
/**
* Implementation of <code>IRule</code> for C/C++ preprocessor scanning.
- * It is capable of detecting a pattern which begins with 0 or more whitespaces
+ * It is capable of detecting a pattern which begins with 0 or more whitespaces
* at the beginning of the string, then '#' sign, then 0 or more whitespaces
* again, and then directive itself.
*/
@@ -33,8 +33,8 @@ public class PreprocessorRule extends WordRule {
/**
* Creates a rule which, with the help of a word detector, will return the token
- * associated with the detected word. If no token has been associated, the scanner
- * will be rolled back and an undefined token will be returned in order to allow
+ * associated with the detected word. If no token has been associated, the scanner
+ * will be rolled back and an undefined token will be returned in order to allow
* any subsequent rules to analyze the characters.
*
* @param detector the word detector to be used by this rule, may not be <code>null</code>
@@ -51,7 +51,7 @@ public class PreprocessorRule extends WordRule {
* specified default token will be returned.
*
* @param detector the word detector to be used by this rule, may not be <code>null</code>
- * @param defaultToken the default token to be returned on success
+ * @param defaultToken the default token to be returned on success
* if nothing else is specified, may not be <code>null</code>
*
* @see WordRule#addWord
@@ -66,15 +66,15 @@ public class PreprocessorRule extends WordRule {
* specified default token will be returned.
*
* @param detector the word detector to be used by this rule, may not be <code>null</code>
- * @param defaultToken the default token to be returned on success
+ * @param defaultToken the default token to be returned on success
* if nothing else is specified, may not be <code>null</code>
* @param malformedToken the token to be returned if the directive is malformed
- *
+ *
* @see WordRule#addWord
*/
public PreprocessorRule(IWordDetector detector, IToken defaultToken, IToken malformedToken) {
super(detector, defaultToken);
- fMalformedToken= malformedToken;
+ fMalformedToken = malformedToken;
}
/*
@@ -83,7 +83,7 @@ public class PreprocessorRule extends WordRule {
@Override
public void addWord(String word, IToken token) {
if (word.charAt(0) == '#') {
- word= word.substring(1);
+ word = word.substring(1);
}
super.addWord(word, token);
}
@@ -101,7 +101,7 @@ public class PreprocessorRule extends WordRule {
c = scanner.read();
nCharsToRollback++;
} while (c == ' ' || c == '\t');
-
+
// Di- and trigraph support
if (c == '#') {
hashSignDetected = true;
@@ -145,7 +145,7 @@ public class PreprocessorRule extends WordRule {
IToken token = fWords.get(fBuffer.toString());
if (token != null)
return token;
-
+
if (fMalformedToken != null) {
do {
c = scanner.read();
@@ -157,7 +157,7 @@ public class PreprocessorRule extends WordRule {
}
// Doesn't start with '#', roll back scanner
-
+
for (int i = 0; i < nCharsToRollback; i++) {
scanner.unread();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java
index febd4d92369..edfd0ea6965 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java
@@ -17,7 +17,6 @@ import java.text.CharacterIterator;
import org.eclipse.core.runtime.Assert;
-
/**
* A <code>CharSequence</code> based implementation of <code>CharacterIterator</code>.
*
@@ -25,7 +24,7 @@ import org.eclipse.core.runtime.Assert;
*/
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;
@@ -70,10 +69,10 @@ public class SequenceCharacterIterator implements CharacterIterator {
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();
}
@@ -130,7 +129,7 @@ public class SequenceCharacterIterator implements CharacterIterator {
@Override
public char setIndex(int position) {
if (position >= getBeginIndex() && position <= getEndIndex())
- fIndex= position;
+ fIndex = position;
else
throw new IllegalArgumentException();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java
index aa3a1461dc6..d15e4204e25 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin, Google
@@ -29,7 +29,6 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.ui.text.IColorManager;
-
/**
* A simple {@linkplain org.eclipse.cdt.ui.text.CSourceViewerConfiguration C source viewer configuration}.
* <p>
@@ -39,7 +38,6 @@ import org.eclipse.cdt.ui.text.IColorManager;
*/
public class SimpleCSourceViewerConfiguration extends CSourceViewerConfiguration {
-
private boolean fConfigureFormatter;
/**
@@ -52,11 +50,12 @@ public class SimpleCSourceViewerConfiguration extends CSourceViewerConfiguration
* @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
* @param configureFormatter <code>true</code> if a content formatter should be configured
*/
- public SimpleCSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning, boolean configureFormatter) {
+ public SimpleCSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore,
+ ITextEditor editor, String partitioning, boolean configureFormatter) {
super(colorManager, preferenceStore, editor, partitioning);
- fConfigureFormatter= configureFormatter;
+ fConfigureFormatter = configureFormatter;
}
-
+
/*
* @see SourceViewerConfiguration#getAutoEditStrategies(ISourceViewer, String)
*/
@@ -138,7 +137,7 @@ public class SimpleCSourceViewerConfiguration extends CSourceViewerConfiguration
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
return null;
}
-
+
/*
* @see CSourceViewerConfiguration#getOutlinePresenter(ISourceViewer)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java
index 9fa50a075bc..ce25ba0083d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java
@@ -17,51 +17,49 @@ package org.eclipse.cdt.internal.ui.text;
import java.io.IOException;
import java.io.Reader;
-
public abstract class SingleCharReader extends Reader {
-
+
/**
* @see Reader#read()
*/
@Override
public abstract int read() throws IOException;
-
/**
* @see Reader#read(char[],int,int)
*/
@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;
}
return i - off;
}
- cbuf[i]= (char)ch;
+ cbuf[i] = (char) ch;
}
return len;
- }
-
+ }
+
/**
* @see Reader#ready()
- */
- @Override
+ */
+ @Override
public boolean ready() throws IOException {
return true;
}
-
+
/**
* Gets the content as a String
*/
public String getString() throws IOException {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
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/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharRule.java
index 99c6ef7378f..f7d8d675b62 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharRule.java
@@ -23,42 +23,38 @@ import org.eclipse.jface.text.rules.Token;
*
* @author P.Tomaszewski
*/
-public abstract class SingleCharRule implements IRule
-{
+public abstract class SingleCharRule implements IRule {
- /** Style token. */
- private IToken token;
+ /** Style token. */
+ private IToken token;
- /**
- * Creates new rule.
- * @param token Style token.
- */
- public SingleCharRule(IToken token)
- {
- super();
- this.token = token;
- }
+ /**
+ * Creates new rule.
+ * @param token Style token.
+ */
+ public SingleCharRule(IToken token) {
+ super();
+ this.token = token;
+ }
- /**
- * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
- */
- @Override
- public IToken evaluate(ICharacterScanner scanner)
- {
- int ch = scanner.read();
+ /**
+ * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+ */
+ @Override
+ public IToken evaluate(ICharacterScanner scanner) {
+ int ch = scanner.read();
- if (isRuleChar(ch))
- {
- return token;
- }
- scanner.unread();
- return Token.UNDEFINED;
- }
+ if (isRuleChar(ch)) {
+ return token;
+ }
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
- /**
- * Checks if char is rule char.
- * @param ch Char to check.
- * @return <b>true</b> if rule char.
- */
- protected abstract boolean isRuleChar(int ch);
+ /**
+ * Checks if char is rule char.
+ * @param ch Char to check.
+ * @return <b>true</b> if rule char.
+ */
+ protected abstract boolean isRuleChar(int ch);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java
index 0cbcaea6c37..ec41cc81292 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -19,12 +19,12 @@ import org.eclipse.cdt.ui.text.AbstractCScanner;
import org.eclipse.cdt.ui.text.ITokenStoreFactory;
/**
- *
+ *
*/
public final class SingleTokenCScanner extends AbstractCScanner {
-
+
public SingleTokenCScanner(ITokenStoreFactory factory, String property) {
- super(factory.createTokenStore(new String[] {property}), 20);
+ super(factory.createTokenStore(new String[] { property }), 20);
setDefaultReturnToken(getToken(property));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java
index 68e2cce660c..c1f5894d687 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java
@@ -14,83 +14,80 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text;
-
import java.io.IOException;
import java.io.Reader;
-
/**
* Reads the text contents from a reader and computes for each character
- * a potential substitution. The substitution may eat more characters than
+ * 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;
private boolean fWasWhiteSpace;
private int fCharAfterWhiteSpace;
-
+
private boolean fReadFromBuffer;
private StringBuilder fBuffer;
private int fIndex;
-
protected SubstitutionTextReader(Reader reader) {
- fReader= reader;
- fBuffer= new StringBuilder();
- fIndex= 0;
- fReadFromBuffer= false;
- fCharAfterWhiteSpace= -1;
- fWasWhiteSpace= true;
+ fReader = reader;
+ fBuffer = new StringBuilder();
+ fIndex = 0;
+ fReadFromBuffer = false;
+ fCharAfterWhiteSpace = -1;
+ fWasWhiteSpace = true;
}
-
+
/**
- * Implement to compute the substitution for the given character and
+ * 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;
-
+
/**
* Returns the internal reader.
*/
protected Reader getReader() {
return fReader;
}
-
+
/**
* 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;
}
- int ch= fCharAfterWhiteSpace;
+ int ch = fCharAfterWhiteSpace;
if (ch == -1) {
- ch= fReader.read();
+ ch = fReader.read();
}
- if (Character.isWhitespace((char)ch)) {
+ if (Character.isWhitespace((char) ch)) {
do {
- ch= fReader.read();
- } while (Character.isWhitespace((char)ch));
+ ch = fReader.read();
+ } while (Character.isWhitespace((char) ch));
if (ch != -1) {
- fCharAfterWhiteSpace= ch;
+ fCharAfterWhiteSpace = ch;
return ' ';
}
} else {
- fCharAfterWhiteSpace= -1;
+ fCharAfterWhiteSpace = -1;
}
return ch;
}
-
+
/**
* @see Reader#read()
*/
@@ -98,48 +95,48 @@ public abstract class SubstitutionTextReader extends SingleCharReader {
public int read() throws IOException {
int c;
do {
-
- c= nextChar();
+
+ c = nextChar();
while (!fReadFromBuffer) {
- 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 (fWasWhiteSpace && (c == ' '));
-
- fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n');
+
+ fWasWhiteSpace = (c == ' ' || c == '\r' || c == '\n');
return c;
}
-
+
/**
* @see Reader#ready()
- */
- @Override
+ */
+ @Override
public boolean ready() throws IOException {
return fReader.ready();
}
-
+
/**
* @see Reader#close()
- */
+ */
@Override
public void close() throws IOException {
fReader.close();
}
-
+
/**
* @see Reader#reset()
- */
+ */
@Override
public void reset() throws IOException {
fReader.reset();
- fWasWhiteSpace= true;
- fCharAfterWhiteSpace= -1;
+ fWasWhiteSpace = true;
+ fCharAfterWhiteSpace = -1;
fBuffer.setLength(0);
- fIndex= 0;
+ fIndex = 0;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java
index 633234876f9..df2a01c424a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java
@@ -19,63 +19,63 @@ package org.eclipse.cdt.internal.ui.text;
* Symbols for the heuristic C/C++ scanner.
*/
public interface Symbols {
- int TokenEOF= -1;
- int TokenLBRACE= 1;
- int TokenRBRACE= 2;
- int TokenLBRACKET= 3;
- int TokenRBRACKET= 4;
- int TokenLPAREN= 5;
- int TokenRPAREN= 6;
- int TokenSEMICOLON= 7;
- int TokenOTHER= 8;
- int TokenCOLON= 9;
- int TokenQUESTIONMARK= 10;
- int TokenCOMMA= 11;
- int TokenEQUAL= 12;
- int TokenLESSTHAN= 13;
- int TokenGREATERTHAN= 14;
- int TokenDOT= 15;
- int TokenMINUS= 16;
- int TokenTILDE= 17;
- int TokenSHIFTRIGHT= 18;
- int TokenARROW= 19;
- int TokenDOUBLECOLON= 20;
- int TokenSHIFTLEFT= 21;
- int TokenPLUS= 22;
- int TokenIF= 109;
- int TokenDO= 1010;
- int TokenFOR= 1011;
- int TokenTRY= 1012;
- int TokenCASE= 1013;
- int TokenELSE= 1014;
- int TokenBREAK= 1015;
- int TokenCATCH= 1016;
- int TokenWHILE= 1017;
- int TokenRETURN= 1018;
- int TokenSTATIC= 1019;
- int TokenSWITCH= 1020;
- int TokenGOTO= 1021;
- int TokenDEFAULT= 1022;
- int TokenPRIVATE= 1023;
- int TokenPROTECTED= 1024;
- int TokenPUBLIC= 1025;
- int TokenNEW= 1026;
- int TokenDELETE= 1027;
- int TokenCLASS= 1028;
- int TokenSTRUCT= 1029;
- int TokenUNION= 1030;
- int TokenENUM= 1031;
- int TokenVIRTUAL= 1032;
- int TokenNAMESPACE= 1033;
- int TokenOPERATOR= 1034;
- int TokenTHROW= 1035;
- int TokenCONST= 1036;
- int TokenEXTERN= 1037;
- int TokenTYPEDEF= 1038;
- int TokenUSING= 1039;
- int TokenTEMPLATE= 1040;
- int TokenTYPENAME= 1041;
- int TokenNOEXCEPT= 1042;
- int TokenOVERRIDE= 1043;
- int TokenIDENT= 2000;
+ int TokenEOF = -1;
+ int TokenLBRACE = 1;
+ int TokenRBRACE = 2;
+ int TokenLBRACKET = 3;
+ int TokenRBRACKET = 4;
+ int TokenLPAREN = 5;
+ int TokenRPAREN = 6;
+ int TokenSEMICOLON = 7;
+ int TokenOTHER = 8;
+ int TokenCOLON = 9;
+ int TokenQUESTIONMARK = 10;
+ int TokenCOMMA = 11;
+ int TokenEQUAL = 12;
+ int TokenLESSTHAN = 13;
+ int TokenGREATERTHAN = 14;
+ int TokenDOT = 15;
+ int TokenMINUS = 16;
+ int TokenTILDE = 17;
+ int TokenSHIFTRIGHT = 18;
+ int TokenARROW = 19;
+ int TokenDOUBLECOLON = 20;
+ int TokenSHIFTLEFT = 21;
+ int TokenPLUS = 22;
+ int TokenIF = 109;
+ int TokenDO = 1010;
+ int TokenFOR = 1011;
+ int TokenTRY = 1012;
+ int TokenCASE = 1013;
+ int TokenELSE = 1014;
+ int TokenBREAK = 1015;
+ int TokenCATCH = 1016;
+ int TokenWHILE = 1017;
+ int TokenRETURN = 1018;
+ int TokenSTATIC = 1019;
+ int TokenSWITCH = 1020;
+ int TokenGOTO = 1021;
+ int TokenDEFAULT = 1022;
+ int TokenPRIVATE = 1023;
+ int TokenPROTECTED = 1024;
+ int TokenPUBLIC = 1025;
+ int TokenNEW = 1026;
+ int TokenDELETE = 1027;
+ int TokenCLASS = 1028;
+ int TokenSTRUCT = 1029;
+ int TokenUNION = 1030;
+ int TokenENUM = 1031;
+ int TokenVIRTUAL = 1032;
+ int TokenNAMESPACE = 1033;
+ int TokenOPERATOR = 1034;
+ int TokenTHROW = 1035;
+ int TokenCONST = 1036;
+ int TokenEXTERN = 1037;
+ int TokenTYPEDEF = 1038;
+ int TokenUSING = 1039;
+ int TokenTEMPLATE = 1040;
+ int TokenTYPENAME = 1041;
+ int TokenNOEXCEPT = 1042;
+ int TokenOVERRIDE = 1043;
+ int TokenIDENT = 2000;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.java
index feefe982520..d236bf082bc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.java
@@ -33,13 +33,12 @@ public class TabsToSpacesConverter implements IAutoEditStrategy {
private int fTabRatio;
private ILineTracker fLineTracker;
-
public void setNumberOfSpacesPerTab(int ratio) {
- fTabRatio= ratio;
+ fTabRatio = ratio;
}
public void setLineTracker(ILineTracker lineTracker) {
- fLineTracker= lineTracker;
+ fLineTracker = lineTracker;
}
private int insertTabString(StringBuilder buffer, int offsetInLine) {
@@ -47,55 +46,56 @@ public class TabsToSpacesConverter implements IAutoEditStrategy {
if (fTabRatio == 0)
return 0;
- int remainder= offsetInLine % fTabRatio;
- remainder= fTabRatio - remainder;
- for (int i= 0; i < remainder; i++)
+ int remainder = offsetInLine % fTabRatio;
+ remainder = fTabRatio - remainder;
+ for (int i = 0; i < remainder; i++)
buffer.append(' ');
return remainder;
}
@Override
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- String text= command.text;
+ String text = command.text;
if (text == null)
return;
- int index= text.indexOf('\t');
+ int index = text.indexOf('\t');
if (index > -1) {
- StringBuilder buffer= new StringBuilder();
+ StringBuilder buffer = new StringBuilder();
fLineTracker.set(command.text);
- int lines= fLineTracker.getNumberOfLines();
+ int lines = fLineTracker.getNumberOfLines();
try {
- for (int i= 0; i < lines; i++) {
+ for (int i = 0; i < lines; i++) {
- int offset= fLineTracker.getLineOffset(i);
- int endOffset= offset + fLineTracker.getLineLength(i);
- String line= text.substring(offset, endOffset);
+ int offset = fLineTracker.getLineOffset(i);
+ int endOffset = offset + fLineTracker.getLineLength(i);
+ String line = text.substring(offset, endOffset);
- int position= 0;
+ int position = 0;
if (i == 0) {
- IRegion firstLine= document.getLineInformationOfOffset(command.offset);
- position= computeVisualLength(document.get(firstLine.getOffset(), command.offset - firstLine.getOffset()));
+ IRegion firstLine = document.getLineInformationOfOffset(command.offset);
+ position = computeVisualLength(
+ document.get(firstLine.getOffset(), command.offset - firstLine.getOffset()));
}
- int length= line.length();
- for (int j= 0; j < length; j++) {
- char c= line.charAt(j);
+ int length = line.length();
+ for (int j = 0; j < length; j++) {
+ char c = line.charAt(j);
if (c == '\t') {
position += insertTabString(buffer, position);
} else {
buffer.append(c);
- ++ position;
+ ++position;
}
}
}
- command.text= buffer.toString();
+ command.text = buffer.toString();
} catch (BadLocationException x) {
}
@@ -105,7 +105,7 @@ public class TabsToSpacesConverter implements IAutoEditStrategy {
private int computeVisualLength(String text) {
int length = text.length();
int offset = 0;
- for (int i=0; i < length; ++i) {
+ for (int i = 0; i < length; ++i) {
if (text.charAt(i) == '\t') {
if (fTabRatio != 0)
offset += fTabRatio - offset % fTabRatio;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java
index 090639f2120..c9d85afa69c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -33,11 +33,11 @@ import org.eclipse.cdt.ui.IPropertyChangeParticipant;
/**
* Which words should be recognized as task tags is specified under {@link CCorePreferenceConstants#TODO_TASK_TAGS} as a
* comma delimited list.
- *
+ *
* @see CCorePreferenceConstants#TODO_TASK_TAGS
* @since 5.0
*/
-public final class TaskTagRule extends CombinedWordRule implements IPropertyChangeParticipant {
+public final class TaskTagRule extends CombinedWordRule implements IPropertyChangeParticipant {
private static class TaskTagDetector implements IWordDetector {
@Override
public boolean isWordStart(char c) {
@@ -56,18 +56,18 @@ public final class TaskTagRule extends CombinedWordRule implements IPropertyChan
/**
* Uppercase words
*/
- private Map<CharacterBuffer, IToken> fUppercaseWords= new HashMap<CharacterBuffer, IToken>();
+ private Map<CharacterBuffer, IToken> fUppercaseWords = new HashMap<CharacterBuffer, IToken>();
/**
* <code>true</code> if task tag detection is case-sensitive.
*/
- private boolean fCaseSensitive= true;
+ private boolean fCaseSensitive = true;
/**
* Buffer for uppercase word
*/
- private CharacterBuffer fBuffer= new CharacterBuffer(16);
+ private CharacterBuffer fBuffer = new CharacterBuffer(16);
public TaskTagMatcher(IToken token) {
- fToken= token;
+ fToken = token;
}
/*
@@ -80,7 +80,7 @@ public final class TaskTagRule extends CombinedWordRule implements IPropertyChan
}
public synchronized void addTaskTags(String value) {
- String[] taskTags= value.split(","); //$NON-NLS-1$
+ String[] taskTags = value.split(","); //$NON-NLS-1$
for (String tag : taskTags) {
if (tag.length() > 0) {
addWord(tag, fToken);
@@ -109,10 +109,10 @@ public final class TaskTagRule extends CombinedWordRule implements IPropertyChan
return super.evaluate(scanner, word);
fBuffer.clear();
- for (int i= 0, n= word.length(); i < n; i++)
+ for (int i = 0, n = word.length(); i < n; i++)
fBuffer.append(Character.toUpperCase(word.charAt(i)));
- IToken token= fUppercaseWords.get(fBuffer);
+ IToken token = fUppercaseWords.get(fBuffer);
if (token != null)
return token;
return Token.UNDEFINED;
@@ -124,18 +124,18 @@ public final class TaskTagRule extends CombinedWordRule implements IPropertyChan
* @param caseSensitive <code>true</code> iff case-sensitivity should be enabled
*/
public void setCaseSensitive(boolean caseSensitive) {
- fCaseSensitive= caseSensitive;
+ fCaseSensitive = caseSensitive;
}
}
- private static final String TODO_TASK_TAGS= CCorePreferenceConstants.TODO_TASK_TAGS;
- private static final String TODO_TASK_CASE_SENSITIVE= CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE;
+ private static final String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS;
+ private static final String TODO_TASK_CASE_SENSITIVE = CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE;
private TaskTagMatcher fMatcher;
/**
* Creates a new task tag rule
* @param token the token to return for words recognized as task tags
- * @param defaultToken
+ * @param defaultToken
* @param preferenceStore
* @param corePreferenceStore
*/
@@ -144,21 +144,21 @@ public final class TaskTagRule extends CombinedWordRule implements IPropertyChan
super(new TaskTagDetector(), defaultToken);
fMatcher = new TaskTagMatcher(token);
addWordMatcher(fMatcher);
- String taskWords= null;
+ String taskWords = null;
if (preferenceStore.contains(TODO_TASK_TAGS)) {
- taskWords= preferenceStore.getString(TODO_TASK_TAGS);
+ taskWords = preferenceStore.getString(TODO_TASK_TAGS);
} else if (corePreferenceStore != null) {
- taskWords= corePreferenceStore.getString(TODO_TASK_TAGS);
+ taskWords = corePreferenceStore.getString(TODO_TASK_TAGS);
}
if (taskWords != null) {
addTaskTags(taskWords);
}
- boolean isCaseSensitive= true;
+ boolean isCaseSensitive = true;
if (preferenceStore.contains(TODO_TASK_CASE_SENSITIVE)) {
- isCaseSensitive= preferenceStore.getBoolean(TODO_TASK_CASE_SENSITIVE);
+ isCaseSensitive = preferenceStore.getBoolean(TODO_TASK_CASE_SENSITIVE);
} else if (corePreferenceStore != null) {
- isCaseSensitive= corePreferenceStore.getBoolean(TODO_TASK_CASE_SENSITIVE);
+ isCaseSensitive = corePreferenceStore.getBoolean(TODO_TASK_CASE_SENSITIVE);
}
fMatcher.setCaseSensitive(isCaseSensitive);
}
@@ -193,7 +193,7 @@ public final class TaskTagRule extends CombinedWordRule implements IPropertyChan
@Override
public void adaptToPreferenceChange(PropertyChangeEvent event) {
if (event.getProperty().equals(TODO_TASK_TAGS)) {
- Object value= event.getNewValue();
+ Object value = event.getNewValue();
if (value instanceof String) {
synchronized (fMatcher) {
fMatcher.clearWords();
@@ -201,7 +201,7 @@ public final class TaskTagRule extends CombinedWordRule implements IPropertyChan
}
}
} else if (event.getProperty().equals(TODO_TASK_CASE_SENSITIVE)) {
- Object value= event.getNewValue();
+ Object value = event.getNewValue();
if (value instanceof String)
fMatcher.setCaseSensitive(Boolean.parseBoolean((String) value));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java
index 645fb06328c..66c82bb28ff 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -34,7 +34,6 @@ import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.IColorManager;
import org.eclipse.cdt.ui.text.ITokenStore;
-
/**
* Maintains a pool of tokens identified by a String ID.
* Supports styles per token.
@@ -45,11 +44,11 @@ public class TokenStore implements ITokenStore {
private IColorManager fColorManager;
private IPreferenceStore fPreferenceStore;
- private Map<String, IToken> fTokenMap= new HashMap<String, IToken>();
+ private Map<String, IToken> fTokenMap = new HashMap<String, IToken>();
private String[] fPropertyNamesColor;
private boolean fNeedsLazyColorLoading;
-
+
/**
* Maintains tokens for a specified set of property keys. Automatically also
* copes with bold, italic, strike-through and underlined versions of the key.
@@ -57,14 +56,14 @@ public class TokenStore implements ITokenStore {
* @param store the {@link IPreferenceStore} to fetch property preferences from
*/
public TokenStore(IColorManager manager, IPreferenceStore store, String[] propertyNamesColor) {
- fColorManager= manager;
- fPreferenceStore= store;
-
- fPropertyNamesColor= propertyNamesColor;
-
- fNeedsLazyColorLoading= Display.getCurrent() == null;
- for (int i= 0; i < fPropertyNamesColor.length; i++) {
- if(fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_BOLD_SUFFIX)
+ fColorManager = manager;
+ fPreferenceStore = store;
+
+ fPropertyNamesColor = propertyNamesColor;
+
+ fNeedsLazyColorLoading = Display.getCurrent() == null;
+ for (int i = 0; i < fPropertyNamesColor.length; i++) {
+ if (fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_BOLD_SUFFIX)
|| fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_ITALIC_SUFFIX)
|| fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX)
|| fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_UNDERLINE_SUFFIX)) {
@@ -76,18 +75,18 @@ public class TokenStore implements ITokenStore {
addToken(fPropertyNamesColor[i]);
}
}
-
+
/**
* In the case where at the time of IToken construction, the Display was not
- * ready to construct colors.
+ * ready to construct colors.
*/
@Override
public void ensureTokensInitialised() {
if (fNeedsLazyColorLoading && Display.getCurrent() != null) {
- for (int i= 0; i < fPropertyNamesColor.length; i++) {
+ for (int i = 0; i < fPropertyNamesColor.length; i++) {
addToken(fPropertyNamesColor[i]);
}
- fNeedsLazyColorLoading= false;
+ fNeedsLazyColorLoading = false;
}
}
@@ -97,7 +96,7 @@ public class TokenStore implements ITokenStore {
private void addToken(String colorKey) {
if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) {
- RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey);
+ RGB rgb = PreferenceConverter.getColor(fPreferenceStore, colorKey);
fColorManager.unbindColor(colorKey);
fColorManager.bindColor(colorKey, rgb);
}
@@ -105,7 +104,7 @@ public class TokenStore implements ITokenStore {
if (!fNeedsLazyColorLoading)
fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, false)));
else {
- Token token= ((Token)fTokenMap.get(colorKey));
+ Token token = ((Token) fTokenMap.get(colorKey));
if (token != null)
token.setData(createTextAttribute(colorKey, false));
}
@@ -123,16 +122,16 @@ public class TokenStore implements ITokenStore {
* @since 3.0
*/
private TextAttribute createTextAttribute(String colorKey, boolean isNull) {
- Color color= null;
+ Color color = null;
if (!isNull)
- color= fColorManager.getColor(colorKey);
-
- String boldKey= colorKey + PreferenceConstants.EDITOR_BOLD_SUFFIX;
- String italicKey= colorKey + PreferenceConstants.EDITOR_ITALIC_SUFFIX;
- String strikethroughKey= colorKey + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
- String underlineKey= colorKey + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
-
- int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
+ color = fColorManager.getColor(colorKey);
+
+ String boldKey = colorKey + PreferenceConstants.EDITOR_BOLD_SUFFIX;
+ String italicKey = colorKey + PreferenceConstants.EDITOR_ITALIC_SUFFIX;
+ String strikethroughKey = colorKey + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
+ String underlineKey = colorKey + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
+
+ int style = fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
if (fPreferenceStore.getBoolean(italicKey))
style |= SWT.ITALIC;
@@ -153,7 +152,7 @@ public class TokenStore implements ITokenStore {
public IToken getToken(String key) {
return getTokenInner(key);
}
-
+
private Token getTokenInner(String key) {
ensureTokensInitialised();
return (Token) fTokenMap.get(key);
@@ -161,17 +160,17 @@ public class TokenStore implements ITokenStore {
private int indexOf(String property) {
if (property != null) {
- int length= fPropertyNamesColor.length;
- for (int i= 0; i < length; i++) {
+ int length = fPropertyNamesColor.length;
+ for (int i = 0; i < length; i++) {
if (property.startsWith(fPropertyNamesColor[i])) {
- int pLength= property.length();
- if(fPropertyNamesColor[i].length() < pLength) {
- String end= property.substring(fPropertyNamesColor[i].length());
+ int pLength = property.length();
+ if (fPropertyNamesColor[i].length() < pLength) {
+ String end = property.substring(fPropertyNamesColor[i].length());
if (end.equals(PreferenceConstants.EDITOR_BOLD_SUFFIX)
- || end.equals(PreferenceConstants.EDITOR_ITALIC_SUFFIX)
- || end.equals(PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX)
- || end.equals(PreferenceConstants.EDITOR_UNDERLINE_SUFFIX)) {
- return i;
+ || end.equals(PreferenceConstants.EDITOR_ITALIC_SUFFIX)
+ || end.equals(PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX)
+ || end.equals(PreferenceConstants.EDITOR_UNDERLINE_SUFFIX)) {
+ return i;
}
} else if (fPropertyNamesColor[i].equals(property)) {
return i;
@@ -197,14 +196,14 @@ public class TokenStore implements ITokenStore {
*/
@Override
public void adaptToPreferenceChange(PropertyChangeEvent event) {
- String property= event.getProperty();
- int i= indexOf(property);
+ String property = event.getProperty();
+ int i = indexOf(property);
if (property.startsWith(fPropertyNamesColor[i])) {
- Token token= getTokenInner(fPropertyNamesColor[i]);
- if(property.length() == fPropertyNamesColor[i].length()) {
+ Token token = getTokenInner(fPropertyNamesColor[i]);
+ if (property.length() == fPropertyNamesColor[i].length()) {
adaptToColorChange(token, event);
} else {
- String end= property.substring(fPropertyNamesColor[i].length());
+ String end = property.substring(fPropertyNamesColor[i].length());
if (end.equals(PreferenceConstants.EDITOR_BOLD_SUFFIX)) {
adaptToStyleChange(token, event, SWT.BOLD);
} else if (end.equals(PreferenceConstants.EDITOR_ITALIC_SUFFIX)) {
@@ -219,51 +218,52 @@ public class TokenStore implements ITokenStore {
}
private void adaptToColorChange(Token token, PropertyChangeEvent event) {
- RGB rgb= null;
+ RGB rgb = null;
- Object value= event.getNewValue();
+ Object value = event.getNewValue();
if (value instanceof RGB)
- rgb= (RGB) value;
+ rgb = (RGB) value;
else if (value instanceof String)
- rgb= StringConverter.asRGB((String) value);
+ rgb = StringConverter.asRGB((String) value);
if (rgb != null) {
- String property= event.getProperty();
- Color color= fColorManager.getColor(property);
+ String property = event.getProperty();
+ Color color = fColorManager.getColor(property);
if ((color == null || !rgb.equals(color.getRGB()))) {
fColorManager.unbindColor(property);
fColorManager.bindColor(property, rgb);
- color= fColorManager.getColor(property);
+ color = fColorManager.getColor(property);
}
- Object data= token.getData();
+ Object data = token.getData();
if (data instanceof TextAttribute) {
- TextAttribute oldAttr= (TextAttribute) data;
+ TextAttribute oldAttr = (TextAttribute) data;
token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
}
}
}
private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) {
- boolean eventValue= false;
- Object value= event.getNewValue();
+ boolean eventValue = false;
+ Object value = event.getNewValue();
if (value instanceof Boolean)
- eventValue= ((Boolean) value).booleanValue();
+ eventValue = ((Boolean) value).booleanValue();
else if (IPreferenceStore.TRUE.equals(value))
- eventValue= true;
+ eventValue = true;
- Object data= token.getData();
+ Object data = token.getData();
if (data instanceof TextAttribute) {
- TextAttribute oldAttr= (TextAttribute) data;
- boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute;
+ TextAttribute oldAttr = (TextAttribute) data;
+ boolean activeValue = (oldAttr.getStyle() & styleAttribute) == styleAttribute;
if (activeValue != eventValue)
- token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
+ token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(),
+ eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
}
}
-
+
/**
* Returns the preference store.
*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.java
index e0bc45dde13..3921ee2c0ea 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.java
@@ -15,7 +15,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text.asm;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.rules.ICharacterScanner;
@@ -27,7 +26,6 @@ import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.ui.text.BufferedDocumentScanner;
-
/**
* This scanner recognizes
* <ul>
@@ -57,34 +55,34 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
* Characters known to be used as line end comments.
*/
private static final String KNOWN_LINE_END_COMMENT_CHARS = "#;@|!"; //$NON-NLS-1$
-
+
// states
- private static final int CCODE= 0;
- private static final int SINGLE_LINE_COMMENT= 1;
- private static final int MULTI_LINE_COMMENT= 2;
- private static final int CHARACTER= 3;
- private static final int STRING= 4;
- private static final int PREPROCESSOR= 5;
- private static final int PREPROCESSOR_MULTI_LINE_COMMENT= 6;
+ private static final int CCODE = 0;
+ private static final int SINGLE_LINE_COMMENT = 1;
+ private static final int MULTI_LINE_COMMENT = 2;
+ private static final int CHARACTER = 3;
+ private static final int STRING = 4;
+ private static final int PREPROCESSOR = 5;
+ private static final int PREPROCESSOR_MULTI_LINE_COMMENT = 6;
// beginning of prefixes and postfixes
- private static final int NONE= 0;
- private static final int BACKSLASH= 1; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
- private static final int SLASH= 2; // prefix for SINGLE_LINE or MULTI_LINE
- private static final int SLASH_STAR= 3; // prefix for MULTI_LINE_COMMENT
- private static final int STAR= 4; // postfix for MULTI_LINE_COMMENT
- private static final int CARRIAGE_RETURN=5; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
- private static final int BACKSLASH_CR= 6; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
- private static final int BACKSLASH_BACKSLASH= 7; // postfix for STRING, CHARACTER
-
+ private static final int NONE = 0;
+ private static final int BACKSLASH = 1; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+ private static final int SLASH = 2; // prefix for SINGLE_LINE or MULTI_LINE
+ private static final int SLASH_STAR = 3; // prefix for MULTI_LINE_COMMENT
+ private static final int STAR = 4; // postfix for MULTI_LINE_COMMENT
+ private static final int CARRIAGE_RETURN = 5; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+ private static final int BACKSLASH_CR = 6; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+ private static final int BACKSLASH_BACKSLASH = 7; // postfix for STRING, CHARACTER
+
/** The scanner. */
- private final BufferedDocumentScanner fScanner= new BufferedDocumentScanner(1000);
-
+ private final BufferedDocumentScanner fScanner = new BufferedDocumentScanner(1000);
+
/** The offset of the last returned token. */
private int fTokenOffset;
/** The length of the last returned token. */
private int fTokenLength;
-
+
/** The state of the scanner. */
private int fState;
/** The last significant character read. */
@@ -92,23 +90,17 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
/** The amount of characters already read on first call to nextToken(). */
private int fPrefixLength;
/** Indicate whether current char is first non-whitespace char on the line*/
- private boolean fFirstCharOnLine= true;
-
- private final IToken[] fTokens= new IToken[] {
- new Token(null),
- new Token(C_SINGLE_LINE_COMMENT),
- new Token(C_MULTI_LINE_COMMENT),
- new Token(C_CHARACTER),
- new Token(C_STRING),
- new Token(C_PREPROCESSOR),
- new Token(C_MULTI_LINE_COMMENT)
- };
-
- private String fLineCommentChars= ""; //$NON-NLS-1$
- private String fLineEndCommentChars= ""; //$NON-NLS-1$
- private String fLineStartCommentChars= ";!|@"; //$NON-NLS-1$
- private boolean fDetectPreprocessor= true;
-
+ private boolean fFirstCharOnLine = true;
+
+ private final IToken[] fTokens = new IToken[] { new Token(null), new Token(C_SINGLE_LINE_COMMENT),
+ new Token(C_MULTI_LINE_COMMENT), new Token(C_CHARACTER), new Token(C_STRING), new Token(C_PREPROCESSOR),
+ new Token(C_MULTI_LINE_COMMENT) };
+
+ private String fLineCommentChars = ""; //$NON-NLS-1$
+ private String fLineEndCommentChars = ""; //$NON-NLS-1$
+ private String fLineStartCommentChars = ";!|@"; //$NON-NLS-1$
+ private boolean fDetectPreprocessor = true;
+
public AsmPartitionScanner() {
}
@@ -118,11 +110,11 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
* These characters are considered line comment introducers at any position
* in the code.
* </p>
- *
+ *
* @param chars
*/
public void setLineCommentCharacters(String chars) {
- fLineCommentChars= chars != null ? chars : ""; //$NON-NLS-1$
+ fLineCommentChars = chars != null ? chars : ""; //$NON-NLS-1$
}
/**
@@ -131,11 +123,11 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
* These characters are considered line comment introducers only as first
* non-whitespace character on the line.
* </p>
- *
+ *
* @param chars
*/
public void setLineStartCommentCharacters(String chars) {
- fLineStartCommentChars= chars != null ? chars : ""; //$NON-NLS-1$
+ fLineStartCommentChars = chars != null ? chars : ""; //$NON-NLS-1$
}
/**
@@ -144,22 +136,22 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
* These characters are considered line comment introducers at the end of a
* instruction line.
* </p>
- *
+ *
* @param chars
*/
public void setLineEndCommentCharacters(String chars) {
- fLineEndCommentChars= chars != null ? chars : ""; //$NON-NLS-1$
+ fLineEndCommentChars = chars != null ? chars : ""; //$NON-NLS-1$
}
/**
* Configure whether preprocessor directives should be detected.
- *
+ *
* @param detectPreprocessor
*/
public void setDetectPreprocessorDiretives(boolean detectPreprocessor) {
- fDetectPreprocessor= detectPreprocessor;
+ fDetectPreprocessor = detectPreprocessor;
}
-
+
/*
* @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
*/
@@ -167,52 +159,52 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
public IToken nextToken() {
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
while (true) {
- final int ch= fScanner.read();
-
- final boolean isFirstCharOnLine= fFirstCharOnLine;
+ final int ch = fScanner.read();
+
+ final boolean isFirstCharOnLine = fFirstCharOnLine;
if (fFirstCharOnLine && ch != ' ' && ch != '\t') {
- fFirstCharOnLine= false;
+ fFirstCharOnLine = false;
}
// characters
- switch (ch) {
- case ICharacterScanner.EOF:
- if (fTokenLength > 0) {
- fLast= NONE; // ignore last
- return preFix(fState, CCODE, NONE, 0);
-
- } else {
- fLast= NONE;
- fPrefixLength= 0;
+ switch (ch) {
+ case ICharacterScanner.EOF:
+ if (fTokenLength > 0) {
+ fLast = NONE; // ignore last
+ return preFix(fState, CCODE, NONE, 0);
+
+ } else {
+ fLast = NONE;
+ fPrefixLength = 0;
return Token.EOF;
- }
+ }
- case '\r':
- fFirstCharOnLine= true;
- if (fLast == BACKSLASH || fLast == BACKSLASH_BACKSLASH) {
- fLast= BACKSLASH_CR;
+ case '\r':
+ fFirstCharOnLine = true;
+ if (fLast == BACKSLASH || fLast == BACKSLASH_BACKSLASH) {
+ fLast = BACKSLASH_CR;
fTokenLength++;
- continue;
- } else if (fLast != CARRIAGE_RETURN) {
- fLast= CARRIAGE_RETURN;
- fTokenLength++;
- continue;
- } else {
- // fLast == CARRIAGE_RETURN
+ continue;
+ } else if (fLast != CARRIAGE_RETURN) {
+ fLast = CARRIAGE_RETURN;
+ fTokenLength++;
+ continue;
+ } else {
+ // fLast == CARRIAGE_RETURN
switch (fState) {
case SINGLE_LINE_COMMENT:
case CHARACTER:
case STRING:
case PREPROCESSOR:
if (fTokenLength > 0) {
- IToken token= fTokens[fState];
+ IToken token = fTokens[fState];
- fLast= CARRIAGE_RETURN;
- fPrefixLength= 1;
+ fLast = CARRIAGE_RETURN;
+ fPrefixLength = 1;
- fState= CCODE;
+ fState = CCODE;
return token;
} else {
@@ -224,23 +216,23 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
consume();
continue;
}
- }
+ }
- case '\\':
+ case '\\':
switch (fState) {
case CHARACTER:
case STRING:
fTokenLength++;
- fLast= fLast == BACKSLASH ? BACKSLASH_BACKSLASH : BACKSLASH;
+ fLast = fLast == BACKSLASH ? BACKSLASH_BACKSLASH : BACKSLASH;
continue;
default:
fTokenLength++;
- fLast= BACKSLASH;
+ fLast = BACKSLASH;
continue;
- }
+ }
- case '\n':
- fFirstCharOnLine= true;
+ case '\n':
+ fFirstCharOnLine = true;
switch (fState) {
case SINGLE_LINE_COMMENT:
case CHARACTER:
@@ -258,10 +250,10 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
continue;
}
- case ' ':
- case '\t':
- consume();
- continue;
+ case ' ':
+ case '\t':
+ consume();
+ continue;
default:
if (fLast == CARRIAGE_RETURN) {
@@ -275,60 +267,60 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
int newState;
switch (ch) {
case '/':
- last= SLASH;
- newState= CCODE;
+ last = SLASH;
+ newState = CCODE;
break;
case '*':
- last= STAR;
- newState= CCODE;
+ last = STAR;
+ newState = CCODE;
break;
case '\'':
- last= NONE;
- newState= CHARACTER;
+ last = NONE;
+ newState = CHARACTER;
break;
case '"':
- last= NONE;
- newState= STRING;
+ last = NONE;
+ newState = STRING;
break;
case '\r':
- last= CARRIAGE_RETURN;
- newState= CCODE;
+ last = CARRIAGE_RETURN;
+ newState = CCODE;
break;
case '\\':
- last= BACKSLASH;
- newState= CCODE;
+ last = BACKSLASH;
+ newState = CCODE;
break;
case '#':
- last= NONE;
- newState= PREPROCESSOR;
+ last = NONE;
+ newState = PREPROCESSOR;
break;
default:
- last= NONE;
- newState= CCODE;
+ last = NONE;
+ newState = CCODE;
break;
}
- fLast= NONE; // ignore fLast
+ fLast = NONE; // ignore fLast
return preFix(fState, newState, last, 1);
case CCODE:
if (fDetectPreprocessor && ch == '#' && isFirstCharOnLine) {
- fLast= NONE; // ignore fLast
- int column= fScanner.getColumn() - 1;
+ fLast = NONE; // ignore fLast
+ int column = fScanner.getColumn() - 1;
fTokenLength -= column;
if (fTokenLength > 0) {
return preFix(fState, PREPROCESSOR, NONE, column + 1);
} else {
preFix(fState, PREPROCESSOR, NONE, column + 1);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
}
@@ -341,32 +333,36 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
}
// states
- switch (fState) {
- case CCODE:
- if (fLast == NONE) {
- boolean isLineComment= false;
- if (ch == '#' && fDetectPreprocessor && isFirstCharOnLine) {
- // don't consume as line comment
- } else if (fLineCommentChars.indexOf(ch) >= 0 || (isFirstCharOnLine && fLineStartCommentChars.indexOf(ch) >= 0) || (!isFirstCharOnLine && fLineEndCommentChars.indexOf(ch) >= 0)) {
- isLineComment= true;
- } else if (isFirstCharOnLine && !Character.isLetterOrDigit((char)ch) && NON_LINE_COMMENT_CHARS.indexOf(ch) < 0) {
- fLineStartCommentChars += (char)ch;
- isLineComment= true;
- }
- if (isLineComment) {
- if (isFirstCharOnLine && fLineEndCommentChars.indexOf(ch) < 0 && KNOWN_LINE_END_COMMENT_CHARS.indexOf(ch) >= 0) {
- fLineEndCommentChars += (char)ch;
- }
+ switch (fState) {
+ case CCODE:
+ if (fLast == NONE) {
+ boolean isLineComment = false;
+ if (ch == '#' && fDetectPreprocessor && isFirstCharOnLine) {
+ // don't consume as line comment
+ } else if (fLineCommentChars.indexOf(ch) >= 0
+ || (isFirstCharOnLine && fLineStartCommentChars.indexOf(ch) >= 0)
+ || (!isFirstCharOnLine && fLineEndCommentChars.indexOf(ch) >= 0)) {
+ isLineComment = true;
+ } else if (isFirstCharOnLine && !Character.isLetterOrDigit((char) ch)
+ && NON_LINE_COMMENT_CHARS.indexOf(ch) < 0) {
+ fLineStartCommentChars += (char) ch;
+ isLineComment = true;
+ }
+ if (isLineComment) {
+ if (isFirstCharOnLine && fLineEndCommentChars.indexOf(ch) < 0
+ && KNOWN_LINE_END_COMMENT_CHARS.indexOf(ch) >= 0) {
+ fLineEndCommentChars += (char) ch;
+ }
if (fTokenLength - getLastLength(fLast) > 0) {
- return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 1);
- } else {
- preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 1);
- fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
- }
- break;
- }
- }
+ return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 1);
+ } else {
+ preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 1);
+ fTokenOffset += fTokenLength;
+ fTokenLength = fPrefixLength;
+ }
+ break;
+ }
+ }
switch (ch) {
case '/':
@@ -377,15 +373,15 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
} else {
preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
} else {
fTokenLength++;
- fLast= SLASH;
+ fLast = SLASH;
break;
}
-
+
case '*':
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0) {
@@ -393,46 +389,46 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
} else {
preFix(CCODE, MULTI_LINE_COMMENT, SLASH_STAR, 2);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
} else {
consume();
break;
}
-
+
case '\'':
- fLast= NONE; // ignore fLast
+ fLast = NONE; // ignore fLast
if (fTokenLength > 0) {
return preFix(CCODE, CHARACTER, NONE, 1);
} else {
preFix(CCODE, CHARACTER, NONE, 1);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
case '"':
- fLast= NONE; // ignore fLast
- if (fTokenLength > 0 ) {
+ fLast = NONE; // ignore fLast
+ if (fTokenLength > 0) {
return preFix(CCODE, STRING, NONE, 1);
} else {
preFix(CCODE, STRING, NONE, 1);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
-
+
case '#':
if (fDetectPreprocessor && isFirstCharOnLine) {
- int column= fScanner.getColumn() - 1;
+ int column = fScanner.getColumn() - 1;
fTokenLength -= column;
if (fTokenLength > 0) {
return preFix(fState, PREPROCESSOR, NONE, column + 1);
} else {
preFix(fState, PREPROCESSOR, NONE, column + 1);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
}
@@ -444,22 +440,22 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
}
break;
- case SINGLE_LINE_COMMENT:
+ case SINGLE_LINE_COMMENT:
consume();
- break;
+ break;
- case PREPROCESSOR:
- switch (ch) {
+ case PREPROCESSOR:
+ switch (ch) {
case '/':
if (fLast == SLASH) {
consume();
break;
} else {
fTokenLength++;
- fLast= SLASH;
+ fLast = SLASH;
break;
}
-
+
case '*':
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0) {
@@ -467,48 +463,48 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
} else {
preFix(fState, PREPROCESSOR_MULTI_LINE_COMMENT, SLASH_STAR, 2);
fTokenOffset += fTokenLength;
- fTokenLength= fPrefixLength;
+ fTokenLength = fPrefixLength;
break;
}
} else {
consume();
break;
}
- default:
+ default:
consume();
- break;
- }
- break;
+ break;
+ }
+ break;
- case PREPROCESSOR_MULTI_LINE_COMMENT:
+ case PREPROCESSOR_MULTI_LINE_COMMENT:
switch (ch) {
case '*':
fTokenLength++;
- fLast= STAR;
+ fLast = STAR;
break;
-
+
case '/':
if (fLast == STAR) {
- IToken token= postFix(fState);
- fState= PREPROCESSOR;
+ IToken token = postFix(fState);
+ fState = PREPROCESSOR;
return token;
}
consume();
break;
-
+
default:
consume();
break;
}
break;
-
- case MULTI_LINE_COMMENT:
+
+ case MULTI_LINE_COMMENT:
switch (ch) {
case '*':
fTokenLength++;
- fLast= STAR;
+ fLast = STAR;
break;
-
+
case '/':
if (fLast == STAR) {
return postFix(MULTI_LINE_COMMENT);
@@ -516,47 +512,47 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
consume();
break;
}
-
+
default:
consume();
break;
}
break;
-
- case STRING:
- switch (ch) {
+
+ case STRING:
+ switch (ch) {
case '\"':
- if (fLast != BACKSLASH) {
- return postFix(STRING);
-
- } else {
- consume();
- break;
- }
-
- default:
+ if (fLast != BACKSLASH) {
+ return postFix(STRING);
+
+ } else {
+ consume();
+ break;
+ }
+
+ default:
consume();
- break;
- }
- break;
-
- case CHARACTER:
- switch (ch) {
+ break;
+ }
+ break;
+
+ case CHARACTER:
+ switch (ch) {
case '\\':
- fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
+ fLast = (fLast == BACKSLASH) ? NONE : BACKSLASH;
fTokenLength++;
- if (fLast != BACKSLASH) {
- return preFix(CHARACTER, CCODE, NONE, 1);
- }
+ if (fLast != BACKSLASH) {
+ return preFix(CHARACTER, CCODE, NONE, 1);
+ }
break;
-
- default:
- return postFix(CHARACTER);
- }
- break;
- }
+
+ default:
+ return postFix(CHARACTER);
+ }
+ break;
+ }
}
- }
+ }
private static final int getLastLength(int last) {
switch (last) {
@@ -565,7 +561,7 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
case NONE:
return 0;
-
+
case CARRIAGE_RETURN:
case BACKSLASH:
case SLASH:
@@ -582,23 +578,23 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
private final void consume() {
fTokenLength++;
- fLast= NONE;
+ fLast = NONE;
}
-
+
private final IToken postFix(int state) {
fTokenLength++;
- fLast= NONE;
- fState= CCODE;
- fPrefixLength= 0;
+ fLast = NONE;
+ fState = CCODE;
+ fPrefixLength = 0;
return fTokens[state];
}
private final IToken preFix(int state, int newState, int last, int prefixLength) {
fTokenLength -= getLastLength(fLast);
- fLast= last;
- fPrefixLength= prefixLength;
- IToken token= fTokens[state];
- fState= newState;
+ fLast = last;
+ fPrefixLength = prefixLength;
+ IToken token = fTokens[state];
+ fState = newState;
return token;
}
@@ -621,7 +617,7 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
else if (contentType.equals(C_PREPROCESSOR))
return PREPROCESSOR;
-
+
else
return CCODE;
}
@@ -633,23 +629,23 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
fScanner.setRange(document, offset, length);
- fTokenOffset= partitionOffset;
- fTokenLength= 0;
- fPrefixLength= offset - partitionOffset;
- fLast= NONE;
-
+ fTokenOffset = partitionOffset;
+ fTokenLength = 0;
+ fPrefixLength = offset - partitionOffset;
+ fLast = NONE;
+
if (offset == partitionOffset) {
// restart at beginning of partition
- fState= CCODE;
+ fState = CCODE;
} else {
- fState= getState(contentType);
+ fState = getState(contentType);
}
try {
- int column= fScanner.getColumn();
- fFirstCharOnLine= column == 0 || document.get(offset-column, column).trim().length() == 0;
+ int column = fScanner.getColumn();
+ fFirstCharOnLine = column == 0 || document.get(offset - column, column).trim().length() == 0;
} catch (BadLocationException exc) {
- fFirstCharOnLine= true;
+ fFirstCharOnLine = true;
}
}
@@ -660,17 +656,17 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
public void setRange(IDocument document, int offset, int length) {
fScanner.setRange(document, offset, length);
- fTokenOffset= offset;
- fTokenLength= 0;
- fPrefixLength= 0;
- fLast= NONE;
- fState= CCODE;
+ fTokenOffset = offset;
+ fTokenLength = 0;
+ fPrefixLength = 0;
+ fLast = NONE;
+ fState = CCODE;
try {
- int column= fScanner.getColumn();
- fFirstCharOnLine= column == 0 || document.get(offset-column, column).trim().length() == 0;
+ int column = fScanner.getColumn();
+ fFirstCharOnLine = column == 0 || document.get(offset - column, column).trim().length() == 0;
} catch (BadLocationException exc) {
- fFirstCharOnLine= true;
+ fFirstCharOnLine = true;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java
index 8586039b6a2..91b48f9f301 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java
@@ -97,7 +97,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
/**
* An annotation info contains information about an {@link Annotation}
- *
+ *
* @since 5.0
*/
protected static class AnnotationInfo {
@@ -106,15 +106,15 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
public final ITextViewer viewer;
public AnnotationInfo(Annotation annotation, Position position, ITextViewer textViewer) {
- this.annotation= annotation;
- this.position= position;
- this.viewer= textViewer;
+ this.annotation = annotation;
+ this.position = position;
+ this.viewer = textViewer;
}
/**
* Create completion proposals which can resolve the given annotation at
* the given position. Returns an empty array if no such proposals exist.
- *
+ *
* @return the proposals or an empty array
*/
public ICompletionProposal[] getCompletionProposals() {
@@ -123,12 +123,13 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
/**
* Adds actions to the given toolbar.
- *
+ *
* @param manager the toolbar manager to add actions to
* @param infoControl the information control
*/
public void fillToolBar(ToolBarManager manager, IInformationControl infoControl) {
- ConfigureAnnotationsAction configureAnnotationsAction= new ConfigureAnnotationsAction(annotation, infoControl);
+ ConfigureAnnotationsAction configureAnnotationsAction = new ConfigureAnnotationsAction(annotation,
+ infoControl);
manager.add(configureAnnotationsAction);
}
}
@@ -137,10 +138,11 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
* The annotation information control shows informations about a given
* {@link AbstractAnnotationHover.AnnotationInfo}. It can also show a toolbar
* and a list of {@link ICompletionProposal}s.
- *
+ *
* @since 5.0
*/
- private static class AnnotationInformationControl extends AbstractInformationControl implements IInformationControlExtension2 {
+ private static class AnnotationInformationControl extends AbstractInformationControl
+ implements IInformationControlExtension2 {
private final DefaultMarkerAnnotationAccess fMarkerAnnotationAccess;
private Control fFocusControl;
private AnnotationInfo fInput;
@@ -148,18 +150,18 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
public AnnotationInformationControl(Shell parentShell, String statusFieldText) {
super(parentShell, statusFieldText);
-
- fMarkerAnnotationAccess= new DefaultMarkerAnnotationAccess();
+
+ fMarkerAnnotationAccess = new DefaultMarkerAnnotationAccess();
create();
}
public AnnotationInformationControl(Shell parentShell, ToolBarManager toolBarManager) {
super(parentShell, toolBarManager);
-
- fMarkerAnnotationAccess= new DefaultMarkerAnnotationAccess();
+
+ fMarkerAnnotationAccess = new DefaultMarkerAnnotationAccess();
create();
}
-
+
/*
* @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String)
*/
@@ -174,11 +176,11 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
@Override
public void setInput(Object input) {
Assert.isLegal(input instanceof AnnotationInfo);
- fInput= (AnnotationInfo)input;
+ fInput = (AnnotationInfo) input;
disposeDeferredCreatedContent();
deferredCreateContent();
}
-
+
/*
* @see org.eclipse.jface.text.IInformationControlExtension#hasContents()
*/
@@ -186,7 +188,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
public boolean hasContents() {
return fInput != null;
}
-
+
private AnnotationInfo getAnnotationInfo() {
return fInput;
}
@@ -210,13 +212,13 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
disposeDeferredCreatedContent();
super.setVisible(visible);
}
-
+
protected void disposeDeferredCreatedContent() {
- Control[] children= fParent.getChildren();
+ Control[] children = fParent.getChildren();
for (Control element : children) {
element.dispose();
}
- ToolBarManager toolBarManager= getToolBarManager();
+ ToolBarManager toolBarManager = getToolBarManager();
if (toolBarManager != null)
toolBarManager.removeAll();
}
@@ -226,30 +228,30 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
*/
@Override
protected void createContent(Composite parent) {
- fParent= parent;
- GridLayout layout= new GridLayout(1, false);
- layout.verticalSpacing= 0;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+ fParent = parent;
+ GridLayout layout = new GridLayout(1, false);
+ layout.verticalSpacing = 0;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
fParent.setLayout(layout);
}
-
+
/*
* @see org.eclipse.jface.text.AbstractInformationControl#computeSizeHint()
*/
@Override
public Point computeSizeHint() {
- Point preferedSize= getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ Point preferedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- Point constrains= getSizeConstraints();
+ Point constrains = getSizeConstraints();
if (constrains == null)
return preferedSize;
- Point constrainedSize= getShell().computeSize(constrains.x, SWT.DEFAULT, true);
-
- int width= Math.min(preferedSize.x, constrainedSize.x);
- int height= Math.max(preferedSize.y, constrainedSize.y);
-
+ Point constrainedSize = getShell().computeSize(constrains.x, SWT.DEFAULT, true);
+
+ int width = Math.min(preferedSize.x, constrainedSize.x);
+ int height = Math.max(preferedSize.y, constrainedSize.y);
+
return new Point(width, height);
}
@@ -258,7 +260,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
* is called after the input has been set.
*/
protected void fillToolbar() {
- ToolBarManager toolBarManager= getToolBarManager();
+ ToolBarManager toolBarManager = getToolBarManager();
if (toolBarManager == null)
return;
fInput.fillToolBar(toolBarManager, this);
@@ -271,11 +273,11 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
*/
protected void deferredCreateContent() {
fillToolbar();
-
+
createAnnotationInformation(fParent, getAnnotationInfo().annotation);
setColorAndFont(fParent, fParent.getForeground(), fParent.getBackground(), JFaceResources.getDialogFont());
- ICompletionProposal[] proposals= getAnnotationInfo().getCompletionProposals();
+ ICompletionProposal[] proposals = getAnnotationInfo().getCompletionProposals();
if (proposals.length > 0)
createCompletionProposalsControl(fParent, proposals);
@@ -286,9 +288,9 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
control.setForeground(foreground);
control.setBackground(background);
control.setFont(font);
-
+
if (control instanceof Composite) {
- Control[] children= ((Composite) control).getChildren();
+ Control[] children = ((Composite) control).getChildren();
for (Control element : children) {
setColorAndFont(element, foreground, background, font);
}
@@ -296,18 +298,18 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
}
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- GridLayout layout= new GridLayout(2, false);
- layout.marginHeight= 2;
- layout.marginWidth= 2;
- layout.horizontalSpacing= 0;
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 2;
+ layout.marginWidth = 2;
+ layout.horizontalSpacing = 0;
composite.setLayout(layout);
- final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
- GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
- gridData.widthHint= 17;
- gridData.heightHint= 16;
+ final Canvas canvas = new Canvas(composite, SWT.NO_FOCUS);
+ GridData gridData = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
+ gridData.widthHint = 17;
+ gridData.heightHint = 16;
canvas.setLayoutData(gridData);
canvas.addPaintListener(new PaintListener() {
@Override
@@ -317,34 +319,35 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
}
});
- StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
- GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
+ StyledText text = new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(data);
text.setText(annotation.getText());
}
private void createCompletionProposalsControl(Composite parent, ICompletionProposal[] proposals) {
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- GridLayout layout2= new GridLayout(1, false);
- layout2.marginHeight= 0;
- layout2.marginWidth= 0;
- layout2.verticalSpacing= 2;
+ GridLayout layout2 = new GridLayout(1, false);
+ layout2.marginHeight = 0;
+ layout2.marginWidth = 0;
+ layout2.verticalSpacing = 2;
composite.setLayout(layout2);
- Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- GridData gridData= new GridData(SWT.FILL, SWT.CENTER, true, false);
+ Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
separator.setLayoutData(gridData);
- Label quickFixLabel= new Label(composite, SWT.NONE);
- GridData layoutData= new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
- layoutData.horizontalIndent= 4;
+ Label quickFixLabel = new Label(composite, SWT.NONE);
+ GridData layoutData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
+ layoutData.horizontalIndent = 4;
quickFixLabel.setLayoutData(layoutData);
String text;
if (proposals.length == 1) {
- text= CHoverMessages.AbstractAnnotationHover_message_singleQuickFix;
+ text = CHoverMessages.AbstractAnnotationHover_message_singleQuickFix;
} else {
- text= MessageFormat.format(CHoverMessages.AbstractAnnotationHover_message_multipleQuickFix, new Object[] {String.valueOf(proposals.length)});
+ text = MessageFormat.format(CHoverMessages.AbstractAnnotationHover_message_multipleQuickFix,
+ new Object[] { String.valueOf(proposals.length) });
}
quickFixLabel.setText(text);
@@ -353,68 +356,69 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
}
private void createCompletionProposalsList(Composite parent, ICompletionProposal[] proposals) {
- final ScrolledComposite scrolledComposite= new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
- GridData gridData= new GridData(SWT.FILL, SWT.FILL, true, true);
+ final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
scrolledComposite.setLayoutData(gridData);
scrolledComposite.setExpandVertical(false);
scrolledComposite.setExpandHorizontal(false);
- Composite composite= new Composite(scrolledComposite, SWT.NONE);
+ Composite composite = new Composite(scrolledComposite, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- GridLayout layout= new GridLayout(3, false);
- layout.verticalSpacing= 2;
+ GridLayout layout = new GridLayout(3, false);
+ layout.verticalSpacing = 2;
composite.setLayout(layout);
- final Link[] links= new Link[proposals.length];
- for (int i= 0; i < proposals.length; i++) {
- Label indent= new Label(composite, SWT.NONE);
- GridData gridData1= new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
- gridData1.widthHint= 0;
+ final Link[] links = new Link[proposals.length];
+ for (int i = 0; i < proposals.length; i++) {
+ Label indent = new Label(composite, SWT.NONE);
+ GridData gridData1 = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
+ gridData1.widthHint = 0;
indent.setLayoutData(gridData1);
- links[i]= createCompletionProposalLink(composite, proposals[i]);
+ links[i] = createCompletionProposalLink(composite, proposals[i]);
}
scrolledComposite.setContent(composite);
- setColorAndFont(scrolledComposite, parent.getForeground(), parent.getBackground(), JFaceResources.getDialogFont());
-
- Point contentSize= composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ setColorAndFont(scrolledComposite, parent.getForeground(), parent.getBackground(),
+ JFaceResources.getDialogFont());
+
+ Point contentSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
composite.setSize(contentSize);
-
- Point constraints= getSizeConstraints();
+
+ Point constraints = getSizeConstraints();
if (constraints != null && contentSize.x < constraints.x) {
- ScrollBar horizontalBar= scrolledComposite.getHorizontalBar();
-
+ ScrollBar horizontalBar = scrolledComposite.getHorizontalBar();
+
int scrollBarHeight;
if (horizontalBar == null) {
- Point scrollSize= scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- scrollBarHeight= scrollSize.y - contentSize.y;
+ Point scrollSize = scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ scrollBarHeight = scrollSize.y - contentSize.y;
} else {
- scrollBarHeight= horizontalBar.getSize().y;
+ scrollBarHeight = horizontalBar.getSize().y;
}
- gridData.heightHint= contentSize.y - scrollBarHeight;
+ gridData.heightHint = contentSize.y - scrollBarHeight;
}
- fFocusControl= links[0];
- for (int i= 0; i < links.length; i++) {
- final int index= i;
- final Link link= links[index];
+ fFocusControl = links[0];
+ for (int i = 0; i < links.length; i++) {
+ final int index = i;
+ final Link link = links[index];
link.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
switch (e.keyCode) {
- case SWT.ARROW_DOWN:
- if (index + 1 < links.length) {
- links[index + 1].setFocus();
- }
- break;
- case SWT.ARROW_UP:
- if (index > 0) {
- links[index - 1].setFocus();
- }
- break;
- default:
- break;
+ case SWT.ARROW_DOWN:
+ if (index + 1 < links.length) {
+ links[index + 1].setFocus();
+ }
+ break;
+ case SWT.ARROW_UP:
+ if (index > 0) {
+ links[index - 1].setFocus();
+ }
+ break;
+ default:
+ break;
}
}
@@ -426,13 +430,13 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
link.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
- int currentPosition= scrolledComposite.getOrigin().y;
- int hight= scrolledComposite.getSize().y;
- int linkPosition= link.getLocation().y;
+ int currentPosition = scrolledComposite.getOrigin().y;
+ int hight = scrolledComposite.getSize().y;
+ int linkPosition = link.getLocation().y;
if (linkPosition < currentPosition) {
if (linkPosition < 10)
- linkPosition= 0;
+ linkPosition = 0;
scrolledComposite.setOrigin(0, linkPosition);
} else if (linkPosition + 20 > currentPosition + hight) {
@@ -448,9 +452,9 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
}
private Link createCompletionProposalLink(Composite parent, final ICompletionProposal proposal) {
- Label proposalImage= new Label(parent, SWT.NONE);
+ Label proposalImage = new Label(parent, SWT.NONE);
proposalImage.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
- Image image= proposal.getImage();
+ Image image = proposal.getImage();
if (image != null) {
proposalImage.setImage(image);
@@ -474,7 +478,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
});
}
- Link proposalLink= new Link(parent, SWT.WRAP);
+ Link proposalLink = new Link(parent, SWT.WRAP);
proposalLink.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
proposalLink.setText("<a>" + proposal.getDisplayString() + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
proposalLink.addSelectionListener(new SelectionAdapter() {
@@ -494,29 +498,29 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
//Focus needs to be in the text viewer, otherwise linked mode does not work
dispose();
- IRewriteTarget target= null;
+ IRewriteTarget target = null;
try {
- IDocument document= viewer.getDocument();
+ IDocument document = viewer.getDocument();
if (viewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) viewer;
- target= extension.getRewriteTarget();
+ ITextViewerExtension extension = (ITextViewerExtension) viewer;
+ target = extension.getRewriteTarget();
}
if (target != null)
target.beginCompoundChange();
if (p instanceof ICompletionProposalExtension2) {
- ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p;
+ ICompletionProposalExtension2 e = (ICompletionProposalExtension2) p;
e.apply(viewer, (char) 0, SWT.NONE, offset);
} else if (p instanceof ICompletionProposalExtension) {
- ICompletionProposalExtension e= (ICompletionProposalExtension) p;
+ ICompletionProposalExtension e = (ICompletionProposalExtension) p;
e.apply(document, (char) 0, offset);
} else {
p.apply(document);
}
- Point selection= p.getSelection(document);
+ Point selection = p.getSelection(document);
if (selection != null) {
viewer.setSelectedRange(selection.x, selection.y);
viewer.revealRange(selection.x, selection.y);
@@ -543,7 +547,6 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
}
}
-
/**
* Hover control creator.
*
@@ -553,9 +556,9 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
private final IInformationControlCreator fPresenterControlCreator;
public HoverControlCreator(IInformationControlCreator presenterControlCreator) {
- fPresenterControlCreator= presenterControlCreator;
+ fPresenterControlCreator = presenterControlCreator;
}
-
+
/*
* @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell)
*/
@@ -571,7 +574,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
}
};
}
-
+
/*
* @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#canReuse(org.eclipse.jface.text.IInformationControl)
*/
@@ -586,10 +589,10 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
return true;
}
}
-
+
/**
* Action to configure the annotation preferences.
- *
+ *
* @since 5.0
*/
private static final class ConfigureAnnotationsAction extends Action {
@@ -599,8 +602,8 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
public ConfigureAnnotationsAction(Annotation annotation, IInformationControl infoControl) {
super();
- fAnnotation= annotation;
- fInfoControl= infoControl;
+ fAnnotation = annotation;
+ fInfoControl = infoControl;
setImageDescriptor(CPluginImages.DESC_ELCL_CONFIGURE_ANNOTATIONS);
setDisabledImageDescriptor(CPluginImages.DESC_DLCL_CONFIGURE_ANNOTATIONS);
setToolTipText(CHoverMessages.AbstractAnnotationHover_action_configureAnnotationPreferences);
@@ -611,39 +614,41 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
*/
@Override
public void run() {
- Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-
- Object data= null;
- AnnotationPreference preference= getAnnotationPreference(fAnnotation);
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+
+ Object data = null;
+ AnnotationPreference preference = getAnnotationPreference(fAnnotation);
if (preference != null)
- data= preference.getPreferenceLabel();
-
+ data = preference.getPreferenceLabel();
+
fInfoControl.dispose(); //FIXME: should have protocol to hide, rather than dispose
- PreferencesUtil.createPreferenceDialogOn(shell, "org.eclipse.ui.editors.preferencePages.Annotations", null, data).open(); //$NON-NLS-1$
+ PreferencesUtil
+ .createPreferenceDialogOn(shell, "org.eclipse.ui.editors.preferencePages.Annotations", null, data) //$NON-NLS-1$
+ .open();
}
}
- private final IPreferenceStore fStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
- private final DefaultMarkerAnnotationAccess fAnnotationAccess= new DefaultMarkerAnnotationAccess();
+ private final IPreferenceStore fStore = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ private final DefaultMarkerAnnotationAccess fAnnotationAccess = new DefaultMarkerAnnotationAccess();
private final boolean fAllAnnotations;
/**
* The hover control creator.
- *
+ *
* @since 5.0
*/
private IInformationControlCreator fHoverControlCreator;
/**
* The presentation control creator.
- *
+ *
* @since 5.0
*/
private IInformationControlCreator fPresenterControlCreator;
-
+
public AbstractAnnotationHover(boolean allAnnotations) {
- fAllAnnotations= allAnnotations;
+ fAllAnnotations = allAnnotations;
}
-
+
/*
* @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
*/
@@ -661,12 +666,12 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
IPath path;
IAnnotationModel model;
if (textViewer instanceof ISourceViewer) {
- path= null;
- model= ((ISourceViewer)textViewer).getAnnotationModel();
+ path = null;
+ model = ((ISourceViewer) textViewer).getAnnotationModel();
} else {
// Get annotation model from file buffer manager
- path= getEditorInputPath();
- model= getAnnotationModel(path);
+ path = getEditorInputPath();
+ model = getAnnotationModel(path);
}
if (model == null)
return null;
@@ -675,32 +680,36 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
@SuppressWarnings("rawtypes")
Iterator parent;
if (model instanceof IAnnotationModelExtension2)
- parent= ((IAnnotationModelExtension2) model).getAnnotationIterator(hoverRegion.getOffset(), hoverRegion.getLength(), true, true);
+ parent = ((IAnnotationModelExtension2) model).getAnnotationIterator(hoverRegion.getOffset(),
+ hoverRegion.getLength(), true, true);
else
- parent= model.getAnnotationIterator();
+ parent = model.getAnnotationIterator();
@SuppressWarnings("unchecked")
- Iterator<Annotation> e= new CAnnotationIterator(parent, fAllAnnotations);
-
- int layer= -1;
- Annotation annotation= null;
- Position position= null;
+ Iterator<Annotation> e = new CAnnotationIterator(parent, fAllAnnotations);
+
+ int layer = -1;
+ Annotation annotation = null;
+ Position position = null;
while (e.hasNext()) {
- Annotation a= e.next();
+ Annotation a = e.next();
- AnnotationPreference preference= getAnnotationPreference(a);
- if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
+ AnnotationPreference preference = getAnnotationPreference(a);
+ if (preference == null || !(preference.getTextPreferenceKey() != null
+ && fStore.getBoolean(preference.getTextPreferenceKey())
+ || (preference.getHighlightPreferenceKey() != null
+ && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
continue;
- Position p= model.getPosition(a);
+ Position p = model.getPosition(a);
- int l= fAnnotationAccess.getLayer(a);
+ int l = fAnnotationAccess.getLayer(a);
if (l > layer && p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
- String msg= a.getText();
+ String msg = a.getText();
if (msg != null && msg.trim().length() > 0) {
- layer= l;
- annotation= a;
- position= p;
+ layer = l;
+ annotation = a;
+ position = p;
}
}
}
@@ -710,7 +719,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
} finally {
try {
if (path != null) {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.disconnect(path, LocationKind.NORMALIZE, null);
}
} catch (CoreException e) {
@@ -732,7 +741,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
@Override
public IInformationControlCreator getHoverControlCreator() {
if (fHoverControlCreator == null)
- fHoverControlCreator= new HoverControlCreator(getInformationPresenterControlCreator());
+ fHoverControlCreator = new HoverControlCreator(getInformationPresenterControlCreator());
return fHoverControlCreator;
}
@@ -743,7 +752,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
if (fPresenterControlCreator == null)
- fPresenterControlCreator= new PresenterControlCreator();
+ fPresenterControlCreator = new PresenterControlCreator();
return fPresenterControlCreator;
}
@@ -751,10 +760,10 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
if (getEditor() == null)
return null;
- IEditorInput input= getEditor().getEditorInput();
+ IEditorInput input = getEditor().getEditorInput();
if (input instanceof IStorageEditorInput) {
try {
- return ((IStorageEditorInput)input).getStorage().getFullPath();
+ return ((IStorageEditorInput) input).getStorage().getFullPath();
} catch (CoreException e) {
CUIPlugin.log(e.getStatus());
}
@@ -766,7 +775,7 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
if (path == null)
return null;
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
try {
manager.connect(path, LocationKind.NORMALIZE, null);
} catch (CoreException e) {
@@ -774,9 +783,9 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
return null;
}
- IAnnotationModel model= null;
+ IAnnotationModel model = null;
try {
- model= manager.getTextFileBuffer(path, LocationKind.NORMALIZE).getAnnotationModel();
+ model = manager.getTextFileBuffer(path, LocationKind.NORMALIZE).getAnnotationModel();
return model;
} finally {
if (model == null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHover.java
index e737c2de8d5..c71a0dcf625 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHover.java
@@ -36,8 +36,8 @@ import org.eclipse.cdt.internal.ui.text.CWordFinder;
/**
* Abstract class for providing hover information for C elements.
*/
-public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITextHoverExtension,
- ITextHoverExtension2, IInformationProviderExtension2 {
+public abstract class AbstractCEditorTextHover
+ implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2, IInformationProviderExtension2 {
private IEditorPart fEditor;
/*
@@ -63,11 +63,10 @@ public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITe
* region for the whole selection.
*/
Point selectedRange = textViewer.getSelectedRange();
- if (selectedRange.x >= 0 && selectedRange.y > 0
- && offset >= selectedRange.x
+ if (selectedRange.x >= 0 && selectedRange.y > 0 && offset >= selectedRange.x
&& offset <= selectedRange.x + selectedRange.y)
return new Region(selectedRange.x, selectedRange.y);
-
+
return CWordFinder.findWord(textViewer.getDocument(), offset);
}
return null;
@@ -117,7 +116,7 @@ public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITe
/**
* Returns the tool tip affordance string.
- *
+ *
* @return the affordance string or <code>null</code> if disabled or no
* key binding is defined
* @since 3.0
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpandHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpandHover.java
index 79b7f5f79a6..1b0765969ec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpandHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpandHover.java
@@ -53,10 +53,9 @@ import org.eclipse.jface.text.source.VerticalRulerEvent;
import org.eclipse.cdt.internal.ui.text.c.hover.AnnotationExpansionControl.AnnotationHoverInput;
-
/**
* This class was copied from org.eclipse.jdt.internal.ui.text.java.hover.AnnotationExpansionControl
- *
+ *
* @since 6.1
*/
public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHoverExtension {
@@ -115,9 +114,8 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover
}
}
-
- private final IInformationControlCreator fgCreator= new InformationControlCreator();
- protected final IVerticalRulerListener fgListener= new VerticalRulerListener();
+ private final IInformationControlCreator fgCreator = new InformationControlCreator();
+ protected final IVerticalRulerListener fgListener = new VerticalRulerListener();
protected CompositeRuler fCompositeRuler;
protected IDoubleClickListener fDblClickListener;
protected IAnnotationAccess fAnnotationAccess;
@@ -129,10 +127,11 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover
* @param access
* @param doubleClickListener
*/
- public AnnotationExpandHover(CompositeRuler ruler, IAnnotationAccess access, IDoubleClickListener doubleClickListener) {
- fCompositeRuler= ruler;
- fAnnotationAccess= access;
- fDblClickListener= doubleClickListener;
+ public AnnotationExpandHover(CompositeRuler ruler, IAnnotationAccess access,
+ IDoubleClickListener doubleClickListener) {
+ fCompositeRuler = ruler;
+ fAnnotationAccess = access;
+ fDblClickListener = doubleClickListener;
}
/*
@@ -145,19 +144,19 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover
}
protected Object getHoverInfoForLine(ISourceViewer viewer, int line) {
- IAnnotationModel model= viewer.getAnnotationModel();
- IDocument document= viewer.getDocument();
+ IAnnotationModel model = viewer.getAnnotationModel();
+ IDocument document = viewer.getDocument();
if (model == null)
return null;
- List<Annotation> exact= new ArrayList<>();
- HashMap<Position, Object> messagesAtPosition= new HashMap<>();
+ List<Annotation> exact = new ArrayList<>();
+ HashMap<Position, Object> messagesAtPosition = new HashMap<>();
- Iterator<Annotation> e= model.getAnnotationIterator();
+ Iterator<Annotation> e = model.getAnnotationIterator();
while (e.hasNext()) {
- Annotation annotation= e.next();
- Position position= model.getPosition(annotation);
+ Annotation annotation = e.next();
+ Position position = model.getPosition(annotation);
if (position == null)
continue;
@@ -177,13 +176,13 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover
if (exact.size() > 0)
setLastRulerMouseLocation(viewer, line);
- AnnotationHoverInput input= new AnnotationHoverInput();
- input.fAnnotations= exact.toArray(new Annotation[0]);
- input.fViewer= viewer;
- input.fRulerInfo= fCompositeRuler;
- input.fAnnotationListener= fgListener;
- input.fDoubleClickListener= fDblClickListener;
- input.model= model;
+ AnnotationHoverInput input = new AnnotationHoverInput();
+ input.fAnnotations = exact.toArray(new Annotation[0]);
+ input.fViewer = viewer;
+ input.fRulerInfo = fCompositeRuler;
+ input.fAnnotationListener = fgListener;
+ input.fDoubleClickListener = fDblClickListener;
+ input.model = model;
return input;
}
@@ -213,7 +212,7 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover
protected int getOrder(Annotation annotation) {
if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
+ IAnnotationAccessExtension extension = (IAnnotationAccessExtension) fAnnotationAccess;
return extension.getLayer(annotation);
}
return IAnnotationAccessExtension.DEFAULT_LAYER;
@@ -224,18 +223,18 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover
return false;
if (messagesAtPosition.containsKey(position)) {
- Object value= messagesAtPosition.get(position);
+ Object value = messagesAtPosition.get(position);
if (message.equals(value))
return true;
if (value instanceof List) {
@SuppressWarnings("unchecked")
- List<String> messages= ((List<String>)value);
- if (messages.contains(message))
+ List<String> messages = ((List<String>) value);
+ if (messages.contains(message))
return true;
messages.add(message);
} else {
- ArrayList<Object> messages= new ArrayList<>();
+ ArrayList<Object> messages = new ArrayList<>();
messages.add(value);
messages.add(message);
messagesAtPosition.put(position, messages);
@@ -248,16 +247,16 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover
protected void setLastRulerMouseLocation(ISourceViewer viewer, int line) {
// set last mouse activity in order to get the correct context menu
if (fCompositeRuler != null) {
- StyledText st= viewer.getTextWidget();
+ StyledText st = viewer.getTextWidget();
if (st != null && !st.isDisposed()) {
if (viewer instanceof ITextViewerExtension5) {
- int widgetLine= ((ITextViewerExtension5)viewer).modelLine2WidgetLine(line);
- Point loc= st.getLocationAtOffset(st.getOffsetAtLine(widgetLine));
+ int widgetLine = ((ITextViewerExtension5) viewer).modelLine2WidgetLine(line);
+ Point loc = st.getLocationAtOffset(st.getOffsetAtLine(widgetLine));
fCompositeRuler.setLocationOfLastMouseButtonActivity(0, loc.y);
} else if (viewer instanceof TextViewer) {
// TODO remove once TextViewer implements the extension
- int widgetLine= ((TextViewer)viewer).modelLine2WidgetLine(line);
- Point loc= st.getLocationAtOffset(st.getOffsetAtLine(widgetLine));
+ int widgetLine = ((TextViewer) viewer).modelLine2WidgetLine(line);
+ Point loc = st.getLocationAtOffset(st.getOffsetAtLine(widgetLine));
fCompositeRuler.setLocationOfLastMouseButtonActivity(0, loc.y);
}
}
@@ -276,7 +275,7 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover
if (position.getOffset() > -1 && position.getLength() > -1) {
try {
- int firstLine= document.getLineOfOffset(position.getOffset());
+ int firstLine = document.getLineOfOffset(position.getOffset());
if (line == firstLine)
return 1;
if (firstLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength()))
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java
index b84f859071f..b8abab670e4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java
@@ -72,7 +72,6 @@ import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.text.source.IVerticalRulerListener;
import org.eclipse.jface.text.source.VerticalRulerEvent;
-
/**
* A control that can display a number of annotations. The control can decide how it layouts the
* annotations to present them to the user.
@@ -83,8 +82,8 @@ import org.eclipse.jface.text.source.VerticalRulerEvent;
*
* @since 6.1
*/
-public class AnnotationExpansionControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, IInformationControlExtension5 {
-
+public class AnnotationExpansionControl implements IInformationControl, IInformationControlExtension,
+ IInformationControlExtension2, IInformationControlExtension5 {
public interface ICallback {
void run(IInformationControlExtension2 control);
@@ -113,25 +112,25 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
StyleRange[] oldStyles;
public void selected() {
- Display disp= fShell.getDisplay();
+ Display disp = fShell.getDisplay();
canvas.setCursor(getHandCursor(disp));
// TODO: shade - for now: set grey background
canvas.setBackground(getSelectionColor(disp));
// highlight the viewer background at its position
- oldStyles= setViewerBackground(fAnnotation);
+ oldStyles = setViewerBackground(fAnnotation);
// set the selection
- fSelection= this;
+ fSelection = this;
if (fHoverManager == null) {
- fHoverManager= createHoverManager(fComposite, true);
+ fHoverManager = createHoverManager(fComposite, true);
} else {
fHoverManager.showInformation();
}
if (fInput.fAnnotationListener != null) {
- VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation);
+ VerticalRulerEvent event = new VerticalRulerEvent(fAnnotation);
fInput.fAnnotationListener.annotationSelected(event);
}
@@ -139,18 +138,18 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
public void defaultSelected(MouseEvent e) {
if (fInput.fAnnotationListener != null) {
- Event swtEvent= new Event();
- swtEvent.type= SWT.MouseDown;
- swtEvent.display= e.display;
- swtEvent.widget= e.widget;
- swtEvent.time= e.time;
- swtEvent.data= e.data;
- swtEvent.x= e.x;
- swtEvent.y= e.y;
- swtEvent.button= e.button;
- swtEvent.stateMask= e.stateMask;
- swtEvent.count= e.count;
- VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation, swtEvent);
+ Event swtEvent = new Event();
+ swtEvent.type = SWT.MouseDown;
+ swtEvent.display = e.display;
+ swtEvent.widget = e.widget;
+ swtEvent.time = e.time;
+ swtEvent.data = e.data;
+ swtEvent.x = e.x;
+ swtEvent.y = e.y;
+ swtEvent.button = e.button;
+ swtEvent.stateMask = e.stateMask;
+ swtEvent.count = e.count;
+ VerticalRulerEvent event = new VerticalRulerEvent(fAnnotation, swtEvent);
fInput.fAnnotationListener.annotationDefaultSelected(event);
}
@@ -159,15 +158,15 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
public void deselect() {
// hide the popup
-// fHoverManager.disposeInformationControl();
+ // fHoverManager.disposeInformationControl();
// deselect
- fSelection= null;
+ fSelection = null;
resetViewerBackground(oldStyles);
- oldStyles= null;
+ oldStyles = null;
- Display disp= fShell.getDisplay();
+ Display disp = fShell.getDisplay();
canvas.setCursor(null);
// TODO: remove shading - for now: set standard background
canvas.setBackground(disp.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
@@ -185,11 +184,11 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
*/
@Override
public void widgetDisposed(DisposeEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
+ Item item = (Item) ((Widget) e.getSource()).getData();
item.deselect();
- item.canvas= null;
- item.fAnnotation= null;
- item.oldStyles= null;
+ item.canvas = null;
+ item.fAnnotation = null;
+ item.oldStyles = null;
((Widget) e.getSource()).setData(null);
}
@@ -208,9 +207,9 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
// TODO: show per-item menu
// for now: show ruler context menu
if (fInput != null) {
- Control ruler= fInput.fRulerInfo.getControl();
+ Control ruler = fInput.fRulerInfo.getControl();
if (ruler != null && !ruler.isDisposed()) {
- Menu menu= ruler.getMenu();
+ Menu menu = ruler.getMenu();
if (menu != null && !menu.isDisposed()) {
menu.setLocation(event.x, event.y);
menu.addMenuListener(new MenuListener() {
@@ -233,7 +232,6 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
}
}
-
/**
* Listener on mouse events on the items.
*/
@@ -243,38 +241,38 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
*/
@Override
public void mouseDoubleClick(MouseEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
+ Item item = (Item) ((Widget) e.getSource()).getData();
if (e.button == 1 && item.fAnnotation == fInput.fAnnotations[0] && fInput.fDoubleClickListener != null) {
fInput.fDoubleClickListener.doubleClick(null);
// special code for JDT to renew the annotation set.
if (fInput.redoAction != null)
fInput.redoAction.run(AnnotationExpansionControl.this);
}
-// dispose();
+ // dispose();
// TODO special action to invoke double-click action on the vertical ruler
// how about
-// Canvas can= (Canvas) e.getSource();
-// Annotation a= (Annotation) can.getData();
-// if (a != null) {
-// a.getDoubleClickAction().run();
-// }
+ // Canvas can= (Canvas) e.getSource();
+ // Annotation a= (Annotation) can.getData();
+ // if (a != null) {
+ // a.getDoubleClickAction().run();
+ // }
}
/*
* JDT uses mouseDown here rather than mouseUp to fix a bug
* (details see https://bugs.eclipse.org/bugs/show_bug.cgi?id=165533)
- *
+ *
* However this causes an issue where the top annotation is fired if the user
* click the 1st item in the expansion control. Due to mouseUp going to the ruler
* after the expansion is close.
- *
+ *
* Bug as described in JDT does not seems to affect CDT so reverting to mouseUp.
*
* @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
+ Item item = (Item) ((Widget) e.getSource()).getData();
// TODO for now, to make double click work: disable single click on the first item
// disable later when the annotationlistener selectively handles input
if (item != null && e.button == 1) // && item.fAnnotation != fInput.fAnnotations[0])
@@ -292,7 +290,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
*/
@Override
public void mouseEnter(MouseEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
+ Item item = (Item) ((Widget) e.getSource()).getData();
if (item != null)
item.selected();
}
@@ -303,26 +301,25 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
@Override
public void mouseExit(MouseEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
+ Item item = (Item) ((Widget) e.getSource()).getData();
if (item != null)
item.deselect();
// if the event lies outside the entire popup, dispose
- org.eclipse.swt.graphics.Region region= fShell.getRegion();
- Canvas can= (Canvas) e.getSource();
- Point p= can.toDisplay(e.x, e.y);
+ org.eclipse.swt.graphics.Region region = fShell.getRegion();
+ Canvas can = (Canvas) e.getSource();
+ Point p = can.toDisplay(e.x, e.y);
if (region == null) {
- Rectangle bounds= fShell.getBounds();
-// p= fShell.toControl(p);
+ Rectangle bounds = fShell.getBounds();
+ // p= fShell.toControl(p);
if (!bounds.contains(p))
dispose();
} else {
- p= fShell.toControl(p);
+ p = fShell.toControl(p);
if (!region.contains(p))
dispose();
}
-
}
/*
@@ -331,16 +328,16 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
@Override
public void mouseHover(MouseEvent e) {
if (fHoverManager == null) {
- fHoverManager= createHoverManager(fComposite, true);
+ fHoverManager = createHoverManager(fComposite, true);
}
}
}
-
+
private HoverManager createHoverManager(Composite target, boolean show) {
HoverManager hoverManager = new HoverManager();
hoverManager.takesFocusWhenVisible(false);
hoverManager.install(target);
- if(show) {
+ if (show) {
hoverManager.showInformation();
}
return hoverManager;
@@ -351,23 +348,23 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
*/
public class LinearLayouter {
- private static final int ANNOTATION_SIZE= 14;
- private static final int BORDER_WIDTH= 2;
+ private static final int ANNOTATION_SIZE = 14;
+ private static final int BORDER_WIDTH = 2;
public Layout getLayout(int itemCount) {
// simple layout: a row of items
- GridLayout layout= new GridLayout(itemCount, true);
- layout.horizontalSpacing= 1;
- layout.verticalSpacing= 0;
- layout.marginHeight= 1;
- layout.marginWidth= 1;
+ GridLayout layout = new GridLayout(itemCount, true);
+ layout.horizontalSpacing = 1;
+ layout.verticalSpacing = 0;
+ layout.marginHeight = 1;
+ layout.marginWidth = 1;
return layout;
}
public Object getLayoutData() {
- GridData gridData= new GridData(ANNOTATION_SIZE + 2 * BORDER_WIDTH, ANNOTATION_SIZE + 2 * BORDER_WIDTH);
- gridData.horizontalAlignment= GridData.CENTER;
- gridData.verticalAlignment= GridData.CENTER;
+ GridData gridData = new GridData(ANNOTATION_SIZE + 2 * BORDER_WIDTH, ANNOTATION_SIZE + 2 * BORDER_WIDTH);
+ gridData.horizontalAlignment = GridData.CENTER;
+ gridData.verticalAlignment = GridData.CENTER;
return gridData;
}
@@ -392,7 +389,6 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
}
-
/**
* Listener on paint events on the items. Paints the annotation image on the given <code>GC</code>.
*/
@@ -402,10 +398,11 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
*/
@Override
public void paintControl(PaintEvent e) {
- Canvas can= (Canvas) e.getSource();
- Annotation a= ((Item) can.getData()).fAnnotation;
+ Canvas can = (Canvas) e.getSource();
+ Annotation a = ((Item) can.getData()).fAnnotation;
if (a != null) {
- Rectangle rect= new Rectangle(fLayouter.getBorderWidth(), fLayouter.getBorderWidth(), fLayouter.getAnnotationSize(), fLayouter.getAnnotationSize());
+ Rectangle rect = new Rectangle(fLayouter.getBorderWidth(), fLayouter.getBorderWidth(),
+ fLayouter.getAnnotationSize(), fLayouter.getAnnotationSize());
if (fAnnotationAccessExtension != null)
fAnnotationAccessExtension.paint(a, e.gc, can, rect);
}
@@ -430,7 +427,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
setMargins(5, 10);
setAnchor(ANCHOR_BOTTOM);
- setFallbackAnchors(new Anchor[] {ANCHOR_BOTTOM, ANCHOR_LEFT, ANCHOR_RIGHT} );
+ setFallbackAnchors(new Anchor[] { ANCHOR_BOTTOM, ANCHOR_LEFT, ANCHOR_RIGHT });
}
/*
@@ -439,19 +436,18 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
@Override
protected void computeInformation() {
if (fSelection != null) {
- Rectangle subjectArea= fSelection.canvas.getBounds();
- Annotation annotation= fSelection.fAnnotation;
+ Rectangle subjectArea = fSelection.canvas.getBounds();
+ Annotation annotation = fSelection.fAnnotation;
String msg;
if (annotation != null)
- msg= annotation.getText();
+ msg = annotation.getText();
else
- msg= null;
+ msg = null;
setInformation(msg, subjectArea);
}
}
-
}
/** Model data. */
@@ -467,7 +463,6 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
/** The annotation access extension. */
private IAnnotationAccessExtension fAnnotationAccessExtension;
-
/* listener legion */
private final MyPaintListener fPaintListener;
private final MyMouseTrackListener fMouseTrackListener;
@@ -486,12 +481,12 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
* @param access the annotation access
*/
public AnnotationExpansionControl(Shell parent, int shellStyle, IAnnotationAccess access) {
- fPaintListener= new MyPaintListener();
- fMouseTrackListener= new MyMouseTrackListener();
- fMouseListener= new MyMouseListener();
- fMenuDetectListener= new MyMenuDetectListener();
- fDisposeListener= new MyDisposeListener();
- fViewportListener= new IViewportListener() {
+ fPaintListener = new MyPaintListener();
+ fMouseTrackListener = new MyMouseTrackListener();
+ fMouseListener = new MyMouseListener();
+ fMenuDetectListener = new MyMenuDetectListener();
+ fDisposeListener = new MyDisposeListener();
+ fViewportListener = new IViewportListener() {
@Override
public void viewportChanged(int verticalOffset) {
@@ -499,36 +494,36 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
}
};
- fLayouter= new LinearLayouter();
+ fLayouter = new LinearLayouter();
if (access instanceof IAnnotationAccessExtension)
- fAnnotationAccessExtension= (IAnnotationAccessExtension) access;
+ fAnnotationAccessExtension = (IAnnotationAccessExtension) access;
- fShell= new Shell(parent, shellStyle | SWT.NO_FOCUS | SWT.ON_TOP);
- Display display= fShell.getDisplay();
+ fShell = new Shell(parent, shellStyle | SWT.NO_FOCUS | SWT.ON_TOP);
+ Display display = fShell.getDisplay();
fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
- fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM);
-// fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.V_SCROLL);
+ fComposite = new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM);
+ // fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.V_SCROLL);
- GridLayout layout= new GridLayout(1, true);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ GridLayout layout = new GridLayout(1, true);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
fShell.setLayout(layout);
- GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= fLayouter.getAnnotationSize() + 2 * fLayouter.getBorderWidth() + 4;
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = fLayouter.getAnnotationSize() + 2 * fLayouter.getBorderWidth() + 4;
fComposite.setLayoutData(data);
fComposite.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
if (fComposite == null)
- return;
- Control[] children= fComposite.getChildren();
- Rectangle bounds= null;
- for (int i= 0; i < children.length; i++) {
+ return;
+ Control[] children = fComposite.getChildren();
+ Rectangle bounds = null;
+ for (int i = 0; i < children.length; i++) {
if (bounds == null)
- bounds= children[i].getBounds();
+ bounds = children[i].getBounds();
else
bounds.add(children[i].getBounds());
if (bounds.contains(e.x, e.y))
@@ -541,18 +536,18 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
});
-// fComposite.getVerticalBar().addListener(SWT.Selection, new Listener() {
-//
-// public void handleEvent(Event event) {
-// Rectangle bounds= fShell.getBounds();
-// int x= bounds.x - fLayouter.getAnnotationSize() - fLayouter.getBorderWidth();
-// int y= bounds.y;
-// fShell.setBounds(x, y, bounds.width, bounds.height);
-// }
-//
-// });
-
- Cursor handCursor= getHandCursor(display);
+ // fComposite.getVerticalBar().addListener(SWT.Selection, new Listener() {
+ //
+ // public void handleEvent(Event event) {
+ // Rectangle bounds= fShell.getBounds();
+ // int x= bounds.x - fLayouter.getAnnotationSize() - fLayouter.getBorderWidth();
+ // int y= bounds.y;
+ // fShell.setBounds(x, y, bounds.width, bounds.height);
+ // }
+ //
+ // });
+
+ Cursor handCursor = getHandCursor(display);
fShell.setCursor(handCursor);
fComposite.setCursor(handCursor);
@@ -560,7 +555,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
}
private void setInfoSystemColor() {
- Display display= fShell.getDisplay();
+ Display display = fShell.getDisplay();
setForegroundColor(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
setBackgroundColor(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
}
@@ -573,7 +568,6 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
setInput(null);
}
-
/*
* @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
*/
@@ -583,15 +577,15 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
fInput.fViewer.removeViewportListener(fViewportListener);
if (input instanceof AnnotationHoverInput)
- fInput= (AnnotationHoverInput) input;
+ fInput = (AnnotationHoverInput) input;
else
- fInput= null;
+ fInput = null;
inputChanged(fInput, null);
}
/**
- * Internal hook method called when the input is
+ * Internal hook method called when the input is
* initially set or subsequently changed.
*
* @param newInput the new input
@@ -615,15 +609,15 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
fShell.setRegion(fLayouter.getShellRegion(fInput.fAnnotations.length));
- Layout layout= fLayouter.getLayout(fInput.fAnnotations.length);
+ Layout layout = fLayouter.getLayout(fInput.fAnnotations.length);
fComposite.setLayout(layout);
- Control[] children= fComposite.getChildren();
- for (int i= 0; i < fInput.fAnnotations.length; i++) {
- Canvas canvas= (Canvas) children[i];
- Item item= new Item();
- item.canvas= canvas;
- item.fAnnotation= fInput.fAnnotations[i];
+ Control[] children = fComposite.getChildren();
+ for (int i = 0; i < fInput.fAnnotations.length; i++) {
+ Canvas canvas = (Canvas) children[i];
+ Item item = new Item();
+ item.canvas = canvas;
+ item.fAnnotation = fInput.fAnnotations[i];
canvas.setData(item);
canvas.redraw();
}
@@ -634,16 +628,16 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
if (fComposite == null)
return;
- Control[] children= fComposite.getChildren();
- int oldSize= children.length;
- int newSize= fInput == null ? 0 : fInput.fAnnotations.length;
+ Control[] children = fComposite.getChildren();
+ int oldSize = children.length;
+ int newSize = fInput == null ? 0 : fInput.fAnnotations.length;
- Display display= fShell.getDisplay();
+ Display display = fShell.getDisplay();
// add missing items
- for (int i= oldSize; i < newSize; i++) {
- Canvas canvas= new Canvas(fComposite, SWT.NONE);
- Object gridData= fLayouter.getLayoutData();
+ for (int i = oldSize; i < newSize; i++) {
+ Canvas canvas = new Canvas(fComposite, SWT.NONE);
+ Object gridData = fLayouter.getLayoutData();
canvas.setLayoutData(gridData);
canvas.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
@@ -659,8 +653,8 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
}
// dispose of exceeding resources
- for (int i= oldSize; i > newSize; i--) {
- Item item= (Item) children[i - 1].getData();
+ for (int i = oldSize; i > newSize; i--) {
+ Item item = (Item) children[i - 1].getData();
item.deselect();
children[i - 1].dispose();
}
@@ -673,18 +667,18 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
@Override
public void setVisible(boolean visible) {
fShell.setVisible(visible);
- if(visible) {
+ if (visible) {
/*
* Force 1st item to be selected when made visible
- *
+ *
* This causes the tooltip to be displayed without additional
* delay.
*/
- Control[] children= fComposite.getChildren();
- if(fHoverManager == null && children.length > 0) {
+ Control[] children = fComposite.getChildren();
+ if (fHoverManager == null && children.length > 0) {
Object data = children[0].getData();
- if(data instanceof Item) {
- ((Item)data).selected();
+ if (data instanceof Item) {
+ ((Item) data).selected();
}
}
}
@@ -698,12 +692,12 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
if (fShell != null) {
if (!fShell.isDisposed())
fShell.dispose();
- fShell= null;
- fComposite= null;
+ fShell = null;
+ fComposite = null;
if (fHoverManager != null)
fHoverManager.dispose();
- fHoverManager= null;
- fSelection= null;
+ fHoverManager = null;
+ fSelection = null;
}
}
@@ -813,38 +807,38 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
}
private StyleRange[] setViewerBackground(Annotation annotation) {
- StyledText text= fInput.fViewer.getTextWidget();
+ StyledText text = fInput.fViewer.getTextWidget();
if (text == null || text.isDisposed())
return null;
- Display disp= text.getDisplay();
+ Display disp = text.getDisplay();
- Position pos= fInput.model.getPosition(annotation);
+ Position pos = fInput.model.getPosition(annotation);
if (pos == null)
return null;
- IRegion region= ((TextViewer)fInput.fViewer).modelRange2WidgetRange(new Region(pos.offset, pos.length));
+ IRegion region = ((TextViewer) fInput.fViewer).modelRange2WidgetRange(new Region(pos.offset, pos.length));
if (region == null)
return null;
- StyleRange[] ranges= text.getStyleRanges(region.getOffset(), region.getLength());
+ StyleRange[] ranges = text.getStyleRanges(region.getOffset(), region.getLength());
- List<StyleRange> undoRanges= new ArrayList<>(ranges.length);
- for (int i= 0; i < ranges.length; i++) {
- undoRanges.add((StyleRange)ranges[i].clone());
+ List<StyleRange> undoRanges = new ArrayList<>(ranges.length);
+ for (int i = 0; i < ranges.length; i++) {
+ undoRanges.add((StyleRange) ranges[i].clone());
}
- int offset= region.getOffset();
- StyleRange current= undoRanges.size() > 0 ? undoRanges.get(0) : null;
- int curStart= current != null ? current.start : region.getOffset() + region.getLength();
- int curEnd= current != null ? current.start + current.length : -1;
- int index= 0;
+ int offset = region.getOffset();
+ StyleRange current = undoRanges.size() > 0 ? undoRanges.get(0) : null;
+ int curStart = current != null ? current.start : region.getOffset() + region.getLength();
+ int curEnd = current != null ? current.start + current.length : -1;
+ int index = 0;
// fill no-style regions
while (curEnd < region.getOffset() + region.getLength()) {
// add empty range
if (curStart > offset) {
- StyleRange undoRange= new StyleRange(offset, curStart - offset, null, null);
+ StyleRange undoRange = new StyleRange(offset, curStart - offset, null, null);
undoRanges.add(index, undoRange);
index++;
}
@@ -852,30 +846,30 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
// step
index++;
if (index < undoRanges.size()) {
- offset= curEnd;
- current= undoRanges.get(index);
- curStart= current.start;
- curEnd= current.start + current.length;
+ offset = curEnd;
+ current = undoRanges.get(index);
+ curStart = current.start;
+ curEnd = current.start + current.length;
} else if (index == undoRanges.size()) {
// last one
- offset= curEnd;
- current= null;
- curStart= region.getOffset() + region.getLength();
- curEnd= -1;
+ offset = curEnd;
+ current = null;
+ curStart = region.getOffset() + region.getLength();
+ curEnd = -1;
} else
- curEnd= region.getOffset() + region.getLength();
+ curEnd = region.getOffset() + region.getLength();
}
// create modified styles (with background)
- List<StyleRange> shadedRanges= new ArrayList<>(undoRanges.size());
- for (Iterator<StyleRange> it= undoRanges.iterator(); it.hasNext(); ) {
- StyleRange range= (StyleRange) it.next().clone();
+ List<StyleRange> shadedRanges = new ArrayList<>(undoRanges.size());
+ for (Iterator<StyleRange> it = undoRanges.iterator(); it.hasNext();) {
+ StyleRange range = (StyleRange) it.next().clone();
shadedRanges.add(range);
- range.background= getHighlightColor(disp);
+ range.background = getHighlightColor(disp);
}
// set the ranges one by one
- for (Iterator<StyleRange> iter= shadedRanges.iterator(); iter.hasNext(); ) {
+ for (Iterator<StyleRange> iter = shadedRanges.iterator(); iter.hasNext();) {
text.setStyleRange(iter.next());
}
@@ -891,12 +885,12 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
if (fInput == null)
return;
- StyledText text= fInput.fViewer.getTextWidget();
+ StyledText text = fInput.fViewer.getTextWidget();
if (text == null || text.isDisposed())
return;
// set the ranges one by one
- for (int i= 0; i < oldRanges.length; i++) {
+ for (int i = 0; i < oldRanges.length; i++) {
text.setStyleRange(oldRanges[i]);
}
}
@@ -933,7 +927,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
return true;
if (control instanceof Shell)
return false;
- control= control.getParent();
+ control = control.getParent();
} while (control != null);
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.java
index 43c5014d5be..d5cfe1fc8d5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.java
@@ -17,7 +17,7 @@ package org.eclipse.cdt.internal.ui.text.c.hover;
/**
* AnnotationHover
* This annotation hover shows the description of the
- * selected annotation.
+ * selected annotation.
*/
public class AnnotationHover extends AbstractAnnotationHover {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java
index 604cd2acd85..5c270d99ab1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java
@@ -34,9 +34,9 @@ import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
/**
* 'Fake' hover used to choose the best available hover.
* This hover is always the first hover used and will delegate the hover
- * request to the best of the real hovers. The 'best' hover is the first
+ * request to the best of the real hovers. The 'best' hover is the first
* hover that returns some text for the specified parameters.
- *
+ *
* Note that hovers are ordered by plugin dependency, with the most specific
* hovers being placed before less specific ones.
*/
@@ -56,19 +56,19 @@ public class BestMatchHover extends AbstractCEditorTextHover {
this();
setEditor(editor);
}
-
+
/**
* Installs all text hovers.
*/
private void installTextHovers() {
- CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
-
+ CEditorTextHoverDescriptor[] hoverDescs = CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
+
// Initialize lists - indicates that the initialization happened
- fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(hoverDescs.length-1);
- fInstantiatedTextHovers= new ArrayList<ITextHover>(hoverDescs.length-1);
+ fTextHoverSpecifications = new ArrayList<CEditorTextHoverDescriptor>(hoverDescs.length - 1);
+ fInstantiatedTextHovers = new ArrayList<ITextHover>(hoverDescs.length - 1);
// Populate list
- for (int i= 0; i < hoverDescs.length; i++) {
+ for (int i = 0; i < hoverDescs.length; i++) {
// Ensure that we don't add ourselves to the list
if (!PreferenceConstants.ID_BESTMATCH_HOVER.equals(hoverDescs[i].getId())) {
fTextHoverSpecifications.add(hoverDescs[i]);
@@ -83,11 +83,12 @@ public class BestMatchHover extends AbstractCEditorTextHover {
return;
boolean allCreated = true;
- for (int i= 0; i < fTextHoverSpecifications.size(); ++i) {
- CEditorTextHoverDescriptor spec= fTextHoverSpecifications.get(i);
- if (spec == null) continue;
-
- ICEditorTextHover hover= spec.createTextHover();
+ for (int i = 0; i < fTextHoverSpecifications.size(); ++i) {
+ CEditorTextHoverDescriptor spec = fTextHoverSpecifications.get(i);
+ if (spec == null)
+ continue;
+
+ ICEditorTextHover hover = spec.createTextHover();
if (hover != null) {
hover.setEditor(getEditor());
// Remember instance and mark as created
@@ -97,7 +98,7 @@ public class BestMatchHover extends AbstractCEditorTextHover {
allCreated = false;
}
}
-
+
if (allCreated) {
fTextHoverSpecifications = null;
}
@@ -110,17 +111,18 @@ public class BestMatchHover extends AbstractCEditorTextHover {
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
checkTextHovers();
- fBestHover= null;
+ fBestHover = null;
if (fInstantiatedTextHovers == null)
return null;
for (ITextHover hover : fInstantiatedTextHovers) {
- if (hover == null) continue;
+ if (hover == null)
+ continue;
- String s= hover.getHoverInfo(textViewer, hoverRegion);
+ String s = hover.getHoverInfo(textViewer, hoverRegion);
if (s != null && s.trim().length() > 0) {
- fBestHover= hover;
+ fBestHover = hover;
return s;
}
}
@@ -135,29 +137,30 @@ public class BestMatchHover extends AbstractCEditorTextHover {
@Override
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
checkTextHovers();
- fBestHover= null;
-
+ fBestHover = null;
+
if (fInstantiatedTextHovers == null)
return null;
-
+
for (ITextHover hover : fInstantiatedTextHovers) {
- if (hover == null) continue;
+ if (hover == null)
+ continue;
if (hover instanceof ITextHoverExtension2) {
- Object info= ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion);
+ Object info = ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion);
if (info != null) {
- fBestHover= hover;
+ fBestHover = hover;
return info;
}
} else {
- String s= hover.getHoverInfo(textViewer, hoverRegion);
+ String s = hover.getHoverInfo(textViewer, hoverRegion);
if (s != null && s.trim().length() > 0) {
- fBestHover= hover;
+ fBestHover = hover;
return s;
}
}
}
-
+
return null;
}
@@ -168,7 +171,7 @@ public class BestMatchHover extends AbstractCEditorTextHover {
@Override
public IInformationControlCreator getHoverControlCreator() {
if (fBestHover instanceof ITextHoverExtension)
- return ((ITextHoverExtension)fBestHover).getHoverControlCreator();
+ return ((ITextHoverExtension) fBestHover).getHoverControlCreator();
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
index 996ec587d5f..825b2057d8f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
@@ -46,8 +46,8 @@ public class CDocHover extends AbstractCEditorTextHover {
@Override
public String getHoverInfo(ITextViewer viewer, IRegion region) {
String expression = null;
-
- if (getEditor() == null)
+
+ if (getEditor() == null)
return null;
try {
IDocument document = viewer.getDocument();
@@ -57,7 +57,7 @@ public class CDocHover extends AbstractCEditorTextHover {
expression = document.get(region.getOffset(), region.getLength());
expression = expression.trim();
if (expression.isEmpty())
- return null;
+ return null;
StringBuilder buffer = new StringBuilder();
final IRegion hoverRegion = region;
@@ -76,44 +76,44 @@ public class CDocHover extends AbstractCEditorTextHover {
@Override
public ITranslationUnit getTranslationUnit() {
- IEditorInput editorInput= getEditor().getEditorInput();
+ IEditorInput editorInput = getEditor().getEditorInput();
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
}
@Override
public IRegion getHoverRegion() {
- return hoverRegion;
+ return hoverRegion;
}
};
IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
if (fs != null) {
- buffer.append(CEditorMessages.DefaultCEditorTextHover_html_name);
+ buffer.append(CEditorMessages.DefaultCEditorTextHover_html_name);
buffer.append(HTMLPrinter.convertToHTMLContent(fs.getName()));
final IFunctionPrototypeSummary prototype = fs.getPrototype();
if (prototype != null) {
- buffer.append(CEditorMessages.DefaultCEditorTextHover_html_prototype);
+ buffer.append(CEditorMessages.DefaultCEditorTextHover_html_prototype);
buffer.append(HTMLPrinter.convertToHTMLContent(prototype.getPrototypeString(false)));
}
if (fs.getDescription() != null) {
- buffer.append(CEditorMessages.DefaultCEditorTextHover_html_description);
+ buffer.append(CEditorMessages.DefaultCEditorTextHover_html_description);
//Don't convert this description since it could already be formatted
buffer.append(fs.getDescription());
}
IRequiredInclude[] incs = fs.getIncludes();
if (incs != null && incs.length > 0) {
- buffer.append(CEditorMessages.DefaultCEditorTextHover_html_includes);
+ buffer.append(CEditorMessages.DefaultCEditorTextHover_html_includes);
int count = 0;
for (IRequiredInclude inc : incs) {
buffer.append(inc.getIncludeName());
- buffer.append("<br>"); //$NON-NLS-1$
+ buffer.append("<br>"); //$NON-NLS-1$
if (count++ > 4) {
buffer.append("...<br>"); //$NON-NLS-1$
- break; // too long list: do not display all
+ break; // too long list: do not display all
}
}
}
- }
+ }
if (buffer.length() > 0) {
HTMLPrinter.insertPageProlog(buffer, 0);
HTMLPrinter.addPageEpilog(buffer);
@@ -122,7 +122,7 @@ public class CDocHover extends AbstractCEditorTextHover {
} catch (Exception e) {
/* Ignore */
}
-
+
return null;
}
@@ -133,13 +133,11 @@ public class CDocHover extends AbstractCEditorTextHover {
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
if (viewer != null) {
Point selectedRange = viewer.getSelectedRange();
- if (selectedRange.x >= 0 &&
- selectedRange.y > 0 &&
- offset >= selectedRange.x &&
- offset <= selectedRange.x + selectedRange.y) {
+ if (selectedRange.x >= 0 && selectedRange.y > 0 && offset >= selectedRange.x
+ && offset <= selectedRange.x + selectedRange.y) {
return new Region(selectedRange.x, selectedRange.y);
}
-
+
return CWordFinder.findWord(viewer.getDocument(), offset);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java
index ee35657aaaa..9af653a7760 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java
@@ -42,57 +42,56 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
*/
public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDescriptor> {
- private static final String C_EDITOR_TEXT_HOVER_EXTENSION_POINT= "org.eclipse.cdt.ui.textHovers"; //$NON-NLS-1$
- private static final String HOVER_TAG= "hover"; //$NON-NLS-1$
- private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
- private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
- private static final String LABEL_ATTRIBUTE= "label"; //$NON-NLS-1$
- private static final String ACTIVATE_PLUG_IN_ATTRIBUTE= "activate"; //$NON-NLS-1$
- private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
- private static final String PERSPECTIVE= "perspective"; //$NON-NLS-1$
-
- public static final String NO_MODIFIER= "0"; //$NON-NLS-1$
- public static final String DISABLED_TAG= "!"; //$NON-NLS-1$
- public static final String VALUE_SEPARATOR= ";"; //$NON-NLS-1$
+ private static final String C_EDITOR_TEXT_HOVER_EXTENSION_POINT = "org.eclipse.cdt.ui.textHovers"; //$NON-NLS-1$
+ private static final String HOVER_TAG = "hover"; //$NON-NLS-1$
+ private static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
+ private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+ private static final String LABEL_ATTRIBUTE = "label"; //$NON-NLS-1$
+ private static final String ACTIVATE_PLUG_IN_ATTRIBUTE = "activate"; //$NON-NLS-1$
+ private static final String DESCRIPTION_ATTRIBUTE = "description"; //$NON-NLS-1$
+ private static final String PERSPECTIVE = "perspective"; //$NON-NLS-1$
+
+ public static final String NO_MODIFIER = "0"; //$NON-NLS-1$
+ public static final String DISABLED_TAG = "!"; //$NON-NLS-1$
+ public static final String VALUE_SEPARATOR = ";"; //$NON-NLS-1$
private int fStateMask;
private String fModifierString;
private boolean fIsEnabled;
private IConfigurationElement fElement;
-
-
+
/**
* Returns all C editor text hovers contributed to the workbench.
*/
public static CEditorTextHoverDescriptor[] getContributedHovers() {
- IExtensionRegistry registry= Platform.getExtensionRegistry();
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(C_EDITOR_TEXT_HOVER_EXTENSION_POINT);
- CEditorTextHoverDescriptor[] hoverDescs= createDescriptors(elements);
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor(C_EDITOR_TEXT_HOVER_EXTENSION_POINT);
+ CEditorTextHoverDescriptor[] hoverDescs = createDescriptors(elements);
initializeFromPreferences(hoverDescs);
return hoverDescs;
- }
+ }
/**
* Computes the state mask for the given modifier string.
- *
+ *
* @param modifiers 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) {
if (modifiers == null)
return -1;
-
+
if (modifiers.length() == 0)
return SWT.NONE;
- int stateMask= 0;
- StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
+ int stateMask = 0;
+ StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
while (modifierTokenizer.hasMoreTokens()) {
- int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
+ int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
if (modifier == 0 || (stateMask & modifier) == modifier)
return -1;
- stateMask= stateMask | modifier;
+ stateMask = stateMask | modifier;
}
return stateMask;
}
@@ -102,33 +101,34 @@ public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDe
*/
private CEditorTextHoverDescriptor(IConfigurationElement element) {
Assert.isNotNull(element);
- fElement= element;
+ fElement = element;
}
/**
* Creates the C editor text hover.
*/
public ICEditorTextHover createTextHover() {
- String pluginId = fElement.getDeclaringExtension().getContributor().getName();
- boolean isHoversPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE;
+ String pluginId = fElement.getDeclaringExtension().getContributor().getName();
+ boolean isHoversPlugInActivated = Platform.getBundle(pluginId).getState() == Bundle.ACTIVE;
if (isHoversPlugInActivated || canActivatePlugIn()) {
try {
- return (ICEditorTextHover)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ return (ICEditorTextHover) fElement.createExecutableExtension(CLASS_ATTRIBUTE);
} catch (CoreException x) {
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 0, "CEditorTextHover.createTextHover", null)); //$NON-NLS-1$
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 0, "CEditorTextHover.createTextHover", //$NON-NLS-1$
+ null));
}
}
-
+
return null;
}
-
+
//---- XML Attribute accessors ---------------------------------------------
-
+
/**
* Returns the hover's id.
*/
public String getId() {
- return fElement.getAttribute(ID_ATTRIBUTE);
+ return fElement.getAttribute(ID_ATTRIBUTE);
}
/**
@@ -137,18 +137,18 @@ public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDe
public String getHoverClassName() {
return fElement.getAttribute(CLASS_ATTRIBUTE);
}
-
+
/**
* Returns the hover's label.
*/
public String getLabel() {
- String label= fElement.getAttribute(LABEL_ATTRIBUTE);
+ String label = fElement.getAttribute(LABEL_ATTRIBUTE);
if (label != null)
return label;
-
+
// Return simple class name
- label= getHoverClassName();
- int lastDot= label.lastIndexOf('.');
+ label = getHoverClassName();
+ int lastDot = label.lastIndexOf('.');
if (lastDot >= 0 && lastDot < label.length() - 1) {
return label.substring(lastDot + 1);
}
@@ -157,7 +157,7 @@ public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDe
/**
* Returns the hover's description.
- *
+ *
* @return the hover's description or <code>null</code> if not provided
*/
public String getDescription() {
@@ -176,14 +176,14 @@ public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDe
public boolean equals(Object obj) {
if (obj == null || !obj.getClass().equals(this.getClass()) || getId() == null)
return false;
- return getId().equals(((CEditorTextHoverDescriptor)obj).getId());
+ return getId().equals(((CEditorTextHoverDescriptor) obj).getId());
}
@Override
public int hashCode() {
return getId().hashCode();
}
-
+
/**
* {@inheritDoc}
*/
@@ -193,10 +193,10 @@ public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDe
}
private static CEditorTextHoverDescriptor[] createDescriptors(IConfigurationElement[] elements) {
- List<CEditorTextHoverDescriptor> result= new ArrayList<CEditorTextHoverDescriptor>(elements.length);
+ List<CEditorTextHoverDescriptor> result = new ArrayList<CEditorTextHoverDescriptor>(elements.length);
for (IConfigurationElement element : elements) {
if (HOVER_TAG.equals(element.getName())) {
- CEditorTextHoverDescriptor desc= new CEditorTextHoverDescriptor(element);
+ CEditorTextHoverDescriptor desc = new CEditorTextHoverDescriptor(element);
result.add(desc);
}
}
@@ -205,65 +205,67 @@ public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDe
}
private static void initializeFromPreferences(CEditorTextHoverDescriptor[] hovers) {
- String compiledTextHoverModifiers= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
-
- StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, VALUE_SEPARATOR);
- HashMap<String, String> idToModifier= new HashMap<String, String>(tokenizer.countTokens() / 2);
+ String compiledTextHoverModifiers = CUIPlugin.getDefault().getPreferenceStore()
+ .getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
+
+ StringTokenizer tokenizer = new StringTokenizer(compiledTextHoverModifiers, VALUE_SEPARATOR);
+ HashMap<String, String> idToModifier = new HashMap<String, String>(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
- String id= tokenizer.nextToken();
+ String id = tokenizer.nextToken();
if (tokenizer.hasMoreTokens())
idToModifier.put(id, tokenizer.nextToken());
}
- String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
+ String compiledTextHoverModifierMasks = CUIPlugin.getDefault().getPreferenceStore()
+ .getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
- tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, VALUE_SEPARATOR);
- HashMap<String, String> idToModifierMask= new HashMap<String, String>(tokenizer.countTokens() / 2);
+ tokenizer = new StringTokenizer(compiledTextHoverModifierMasks, VALUE_SEPARATOR);
+ HashMap<String, String> idToModifierMask = new HashMap<String, String>(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
- String id= tokenizer.nextToken();
+ String id = tokenizer.nextToken();
if (tokenizer.hasMoreTokens())
idToModifierMask.put(id, tokenizer.nextToken());
}
- for (int i= 0; i < hovers.length; i++) {
- String modifierString= idToModifier.get(hovers[i].getId());
- boolean enabled= true;
+ for (int i = 0; i < hovers.length; i++) {
+ String modifierString = idToModifier.get(hovers[i].getId());
+ boolean enabled = true;
if (modifierString == null)
- modifierString= DISABLED_TAG;
-
+ modifierString = DISABLED_TAG;
+
if (modifierString.startsWith(DISABLED_TAG)) {
- enabled= false;
- modifierString= modifierString.substring(1);
+ enabled = false;
+ modifierString = modifierString.substring(1);
}
if (modifierString.equals(NO_MODIFIER))
- modifierString= ""; //$NON-NLS-1$
+ modifierString = ""; //$NON-NLS-1$
- hovers[i].fModifierString= modifierString;
- hovers[i].fIsEnabled= enabled;
- hovers[i].fStateMask= computeStateMask(modifierString);
+ hovers[i].fModifierString = modifierString;
+ hovers[i].fIsEnabled = enabled;
+ hovers[i].fStateMask = computeStateMask(modifierString);
if (hovers[i].fStateMask == -1) {
// Fallback: use stored modifier masks
try {
- hovers[i].fStateMask= Integer.parseInt(idToModifierMask.get(hovers[i].getId()));
+ hovers[i].fStateMask = Integer.parseInt(idToModifierMask.get(hovers[i].getId()));
} catch (NumberFormatException ex) {
- hovers[i].fStateMask= -1;
+ hovers[i].fStateMask = -1;
}
// Fix modifier string
- int stateMask= hovers[i].fStateMask;
+ int stateMask = hovers[i].fStateMask;
if (stateMask == -1)
- hovers[i].fModifierString= ""; //$NON-NLS-1$
+ hovers[i].fModifierString = ""; //$NON-NLS-1$
else
- hovers[i].fModifierString= EditorUtility.getModifierString(stateMask);
+ hovers[i].fModifierString = EditorUtility.getModifierString(stateMask);
}
}
}
-
+
/**
* Returns the configured modifier getStateMask for this hover.
- *
+ *
* @return the hover modifier stateMask or -1 if no hover is configured
*/
public int getStateMask() {
@@ -272,7 +274,7 @@ public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDe
/**
* Returns the modifier String as set in the preference store.
- *
+ *
* @return the modifier string
*/
public String getModifierString() {
@@ -281,16 +283,16 @@ public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDe
/**
* Returns whether this hover is enabled or not.
- *
+ *
* @return <code>true</code> if enabled
*/
public boolean isEnabled() {
return fIsEnabled;
}
-
+
/**
* Returns this hover descriptors configuration element.
- *
+ *
* @return the configuration element
*/
public IConfigurationElement getConfigurationElement() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.java
index 30bdc1fa7f5..a32e983c97b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.java
@@ -32,7 +32,7 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
private ICEditorTextHover fHover;
public CEditorTextHoverProxy(CEditorTextHoverDescriptor descriptor, IEditorPart editor) {
- fHoverDescriptor= descriptor;
+ fHoverDescriptor = descriptor;
setEditor(editor);
}
@@ -61,7 +61,7 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
return null;
}
-
+
/*
* @see ITextHover#getHoverInfo(ITextViewer, IRegion)
*/
@@ -74,7 +74,6 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
return null;
}
-
/*
* @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
* @since 5.0
@@ -85,7 +84,7 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
if (ensureHoverCreated()) {
if (fHover instanceof ITextHoverExtension2)
return ((ITextHoverExtension2) fHover).getHoverInfo2(textViewer, hoverRegion);
-
+
return fHover.getHoverInfo(textViewer, hoverRegion);
}
@@ -103,7 +102,7 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
}
private boolean createHover() {
- fHover= fHoverDescriptor.createTextHover();
+ fHover = fHoverDescriptor.createTextHover();
if (fHover != null)
fHover.setEditor(getEditor());
return isCreated();
@@ -116,7 +115,7 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
@Override
public IInformationControlCreator getHoverControlCreator() {
if (ensureHoverCreated() && (fHover instanceof ITextHoverExtension))
- return ((ITextHoverExtension)fHover).getHoverControlCreator();
+ return ((ITextHoverExtension) fHover).getHoverControlCreator();
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CExpandHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CExpandHover.java
index c45914cb3f4..aa216f46ea6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CExpandHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CExpandHover.java
@@ -52,7 +52,6 @@ import org.eclipse.cdt.internal.ui.editor.ICAnnotation;
import org.eclipse.cdt.internal.ui.editor.CMarkerAnnotation;
import org.eclipse.cdt.internal.ui.text.c.hover.AnnotationExpansionControl.AnnotationHoverInput;
-
/**
* Originally copied from org.eclipse.jdt.internal.ui.text.java.hover.JavaExpandHover
* @since 6.1
@@ -61,9 +60,9 @@ public class CExpandHover extends AnnotationExpandHover {
/** Id of CDT Breakpoint annotation type */
private static final String ANNOTATION_TYPE_BREAKPOINT = "org.eclipse.cdt.debug.core.breakpoint"; //$NON-NLS-1$
-
+
/** Id of the no breakpoint fake annotation */
- public static final String NO_BREAKPOINT_ANNOTATION= "org.eclipse.cdt.internal.ui.NoBreakpointAnnotation"; //$NON-NLS-1$
+ public static final String NO_BREAKPOINT_ANNOTATION = "org.eclipse.cdt.internal.ui.NoBreakpointAnnotation"; //$NON-NLS-1$
private static class NoBreakpointAnnotation extends Annotation implements IAnnotationPresentation {
@@ -77,7 +76,7 @@ public class CExpandHover extends AnnotationExpandHover {
@Override
public void paint(GC gc, Canvas canvas, Rectangle bounds) {
// draw affordance so the user know she can click here to get a breakpoint
- Image fImage= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_PUBLIC_FIELD);
+ Image fImage = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_PUBLIC_FIELD);
ImageUtilities.drawImage(fImage, gc, canvas, bounds, SWT.CENTER);
}
@@ -90,8 +89,8 @@ public class CExpandHover extends AnnotationExpandHover {
}
}
- private AnnotationPreferenceLookup fLookup= new AnnotationPreferenceLookup();
- private IPreferenceStore fStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
+ private AnnotationPreferenceLookup fLookup = new AnnotationPreferenceLookup();
+ private IPreferenceStore fStore = CUIPlugin.getDefault().getCombinedPreferenceStore();
public CExpandHover(CompositeRuler ruler, IAnnotationAccess access, IDoubleClickListener doubleClickListener) {
super(ruler, access, doubleClickListener);
@@ -103,35 +102,36 @@ public class CExpandHover extends AnnotationExpandHover {
@Override
protected Object getHoverInfoForLine(final ISourceViewer viewer, final int line) {
//Use EDITOR_EVALUATE_TEMPORARY_PROBLEMS rather than EDITOR_CORRECTION_INDICATION as EDITOR_CORRECTION_INDICATION is not used in CDT
- final boolean showTemporaryProblems= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS);
- IAnnotationModel model= viewer.getAnnotationModel();
- IDocument document= viewer.getDocument();
+ final boolean showTemporaryProblems = PreferenceConstants.getPreferenceStore()
+ .getBoolean(PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS);
+ IAnnotationModel model = viewer.getAnnotationModel();
+ IDocument document = viewer.getDocument();
if (model == null)
return null;
- List<Annotation> exact= new ArrayList<>();
- HashMap<Position, Object> messagesAtPosition= new HashMap<>();
+ List<Annotation> exact = new ArrayList<>();
+ HashMap<Position, Object> messagesAtPosition = new HashMap<>();
- Iterator<Annotation> e= model.getAnnotationIterator();
+ Iterator<Annotation> e = model.getAnnotationIterator();
while (e.hasNext()) {
- Annotation annotation= e.next();
+ Annotation annotation = e.next();
if (fAnnotationAccess instanceof IAnnotationAccessExtension)
- if (!((IAnnotationAccessExtension)fAnnotationAccess).isPaintable(annotation))
+ if (!((IAnnotationAccessExtension) fAnnotationAccess).isPaintable(annotation))
continue;
- if (annotation instanceof ICAnnotation && !isIncluded((ICAnnotation)annotation, showTemporaryProblems))
+ if (annotation instanceof ICAnnotation && !isIncluded((ICAnnotation) annotation, showTemporaryProblems))
continue;
- AnnotationPreference pref= fLookup.getAnnotationPreference(annotation);
+ AnnotationPreference pref = fLookup.getAnnotationPreference(annotation);
if (pref != null) {
- String key= pref.getVerticalRulerPreferenceKey();
+ String key = pref.getVerticalRulerPreferenceKey();
if (key != null && !fStore.getBoolean(key))
continue;
}
- Position position= model.getPosition(annotation);
+ Position position = model.getPosition(annotation);
if (position == null)
continue;
@@ -159,13 +159,13 @@ public class CExpandHover extends AnnotationExpandHover {
if (exact.size() <= 1)
return null;
- AnnotationHoverInput input= new AnnotationHoverInput();
- input.fAnnotations= exact.toArray(new Annotation[0]);
- input.fViewer= viewer;
- input.fRulerInfo= fCompositeRuler;
- input.fAnnotationListener= fgListener;
- input.fDoubleClickListener= fDblClickListener;
- input.redoAction= new AnnotationExpansionControl.ICallback() {
+ AnnotationHoverInput input = new AnnotationHoverInput();
+ input.fAnnotations = exact.toArray(new Annotation[0]);
+ input.fViewer = viewer;
+ input.fRulerInfo = fCompositeRuler;
+ input.fAnnotationListener = fgListener;
+ input.fDoubleClickListener = fDblClickListener;
+ input.redoAction = new AnnotationExpansionControl.ICallback() {
@Override
public void run(IInformationControlExtension2 control) {
@@ -173,7 +173,7 @@ public class CExpandHover extends AnnotationExpandHover {
}
};
- input.model= model;
+ input.model = model;
return input;
}
@@ -181,7 +181,8 @@ public class CExpandHover extends AnnotationExpandHover {
private boolean isIncluded(ICAnnotation annotation, boolean showTemporaryProblems) {
// XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138601
- if (annotation instanceof ProblemAnnotation && CMarkerAnnotation.TASK_ANNOTATION_TYPE.equals(annotation.getType()))
+ if (annotation instanceof ProblemAnnotation
+ && CMarkerAnnotation.TASK_ANNOTATION_TYPE.equals(annotation.getType()))
return false;
if (!annotation.isProblem())
@@ -193,7 +194,6 @@ public class CExpandHover extends AnnotationExpandHover {
if (annotation.hasOverlay() && !annotation.isMarkedDeleted())
return true;
-
if (annotation.hasOverlay())
return (!isIncluded(annotation.getOverlay(), showTemporaryProblems));
@@ -202,14 +202,14 @@ public class CExpandHover extends AnnotationExpandHover {
}
@Override
- protected int getAnnotationOffsetForSort(IAnnotationModel model, Annotation a) {
- if(this.isBreakpointAnnotation(a)) {
+ protected int getAnnotationOffsetForSort(IAnnotationModel model, Annotation a) {
+ if (this.isBreakpointAnnotation(a)) {
return Integer.MAX_VALUE; //Force breakpoints to end
} else {
return model.getPosition(a).offset;
}
}
-
+
/*
* @see org.eclipse.ui.internal.texteditor.AnnotationExpandHover#getOrder(org.eclipse.jface.text.source.Annotation)
*/
@@ -224,14 +224,14 @@ public class CExpandHover extends AnnotationExpandHover {
private boolean isBreakpointAnnotation(Annotation a) {
return a.getType().equals(ANNOTATION_TYPE_BREAKPOINT);
}
-
+
private boolean containsBreakpointAnnotation(List<Annotation> annotations) {
- for(Annotation a : annotations) {
- if(isBreakpointAnnotation(a)) {
+ for (Annotation a : annotations) {
+ if (isBreakpointAnnotation(a)) {
return true;
}
}
-
+
return false;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.java
index 712bdf327b0..989ea651ee6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.java
@@ -32,7 +32,7 @@ public final class CHoverMessages extends NLS {
public static String CMacroExpansionControl_title_macroExpansion;
public static String CMacroExpansionControl_title_macroExpansionExploration;
public static String CMacroExpansionControl_title_original;
-
+
public static String CMacroExpansionInput_jobTitle;
public static String CSourceHover_jobTitle;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.java
index f2f662d690d..a92d27a3f6a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.java
@@ -33,11 +33,12 @@ import org.eclipse.ui.IWorkbenchWindow;
/**
* Provides information for the current word under the cursor based on the documentation hover
* and spelling correction hover.
- *
+ *
* @see CTypeHover
* @since 5.0
*/
-public class CInformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
+public class CInformationProvider
+ implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
/**
* Default control creator.
@@ -48,7 +49,6 @@ public class CInformationProvider implements IInformationProvider, IInformationP
return new DefaultInformationControl(parent);
}
}
-
/**
* Part listener handling editor close.
@@ -57,19 +57,23 @@ public class CInformationProvider implements IInformationProvider, IInformationP
@Override
public void partOpened(IWorkbenchPart part) {
}
+
@Override
public void partDeactivated(IWorkbenchPart part) {
}
+
@Override
public void partClosed(IWorkbenchPart part) {
if (part == fEditor) {
fEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener);
- fPartListener= null;
+ fPartListener = null;
}
}
+
@Override
public void partActivated(IWorkbenchPart part) {
}
+
@Override
public void partBroughtToTop(IWorkbenchPart part) {
}
@@ -84,15 +88,15 @@ public class CInformationProvider implements IInformationProvider, IInformationP
* The default presentation control creator.
*/
private IInformationControlCreator fPresenterControlCreator;
-
+
public CInformationProvider(IEditorPart editor) {
- fEditor= editor;
+ fEditor = editor;
if (fEditor != null) {
- fPartListener= new EditorWatcher();
- IWorkbenchWindow window= fEditor.getSite().getWorkbenchWindow();
+ fPartListener = new EditorWatcher();
+ IWorkbenchWindow window = fEditor.getSite().getWorkbenchWindow();
window.getPartService().addPartListener(fPartListener);
- fImplementation= new CTypeHover();
+ fImplementation = new CTypeHover();
fImplementation.setEditor(fEditor);
}
}
@@ -114,7 +118,7 @@ public class CInformationProvider implements IInformationProvider, IInformationP
@Override
public String getInformation(ITextViewer textViewer, IRegion subject) {
if (fImplementation != null) {
- String s= fImplementation.getHoverInfo(textViewer, subject);
+ String s = fImplementation.getHoverInfo(textViewer, subject);
if (s != null && s.trim().length() > 0) {
return s;
}
@@ -141,7 +145,7 @@ public class CInformationProvider implements IInformationProvider, IInformationP
return ((IInformationProviderExtension2) fImplementation).getInformationPresenterControlCreator();
}
if (fPresenterControlCreator == null)
- fPresenterControlCreator= new ControlCreator();
+ fPresenterControlCreator = new ControlCreator();
return fPresenterControlCreator;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java
index aa4c4dcc777..325481ea06c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java
@@ -41,7 +41,7 @@ import org.eclipse.cdt.internal.ui.compare.CMergeViewer;
*/
class CMacroCompareViewer extends CMergeViewer {
- private static final RGB CHANGE_COLOR= new RGB(212,212,212);
+ private static final RGB CHANGE_COLOR = new RGB(212, 212, 212);
private class ReplaceEditsHighlighter implements ITextPresentationListener {
private boolean fBefore;
@@ -50,24 +50,24 @@ class CMacroCompareViewer extends CMergeViewer {
private Color fBackground;
public ReplaceEditsHighlighter(Color background, boolean before) {
- fBackground= background;
- fBefore= before;
+ fBackground = background;
+ fBefore = before;
}
public void setReplaceEdits(int prefixLength, ReplaceEdit[] edits) {
- fStarts= new int[edits.length];
- fLengths= new int[edits.length];
- int delta= 0;
- for (int i= 0; i < edits.length; i++) {
- ReplaceEdit edit= edits[i];
- fStarts[i]= prefixLength + edit.getOffset() + delta;
- fLengths[i]= fBefore ? edit.getLength() : edit.getText().length();
+ fStarts = new int[edits.length];
+ fLengths = new int[edits.length];
+ int delta = 0;
+ for (int i = 0; i < edits.length; i++) {
+ ReplaceEdit edit = edits[i];
+ fStarts[i] = prefixLength + edit.getOffset() + delta;
+ fLengths[i] = fBefore ? edit.getLength() : edit.getText().length();
if (!fBefore) {
delta += edit.getText().length() - edit.getLength();
}
}
}
-
+
/*
* @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation)
*/
@@ -88,18 +88,22 @@ class CMacroCompareViewer extends CMergeViewer {
public int getTokenLength(int index) {
return 0;
}
+
@Override
public int getTokenStart(int index) {
return 0;
}
+
@Override
public int getRangeCount() {
return 0;
}
+
@Override
public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) {
return true;
}
+
@Override
public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
return true;
@@ -113,23 +117,23 @@ class CMacroCompareViewer extends CMergeViewer {
private TextViewer fLeftViewer;
private TextViewer fRightViewer;
private TextViewer fTopViewer;
-
+
private int fViewerIndex;
private CMacroExpansionInput fInput;
private int fStepIndex;
private int fPrefixLength;
-
+
public CMacroCompareViewer(Composite parent, int styles, CompareConfiguration mp) {
super(parent, styles, mp);
- RGB expansionHighlight = CMacroCompareViewer.createColor(getPreferenceStore(),
+ RGB expansionHighlight = CMacroCompareViewer.createColor(getPreferenceStore(),
AbstractTextEditor.PREFERENCE_COLOR_FIND_SCOPE);
- if(expansionHighlight == null)
+ if (expansionHighlight == null)
expansionHighlight = CHANGE_COLOR;
- fChangeBackground= new Color(parent.getDisplay(), expansionHighlight);
- fLeftHighlighter= new ReplaceEditsHighlighter(fChangeBackground, true);
- fRightHighlighter= new ReplaceEditsHighlighter(fChangeBackground, false);
- fViewerIndex= 0;
+ fChangeBackground = new Color(parent.getDisplay(), expansionHighlight);
+ fLeftHighlighter = new ReplaceEditsHighlighter(fChangeBackground, true);
+ fRightHighlighter = new ReplaceEditsHighlighter(fChangeBackground, false);
+ fViewerIndex = 0;
}
/*
@@ -146,38 +150,38 @@ class CMacroCompareViewer extends CMergeViewer {
fChangeBackground.dispose();
super.handleDispose(event);
}
-
+
@Override
protected IToolBarManager getToolBarManager(Composite parent) {
// no toolbar
return null;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#configureTextViewer(org.eclipse.jface.text.TextViewer)
*/
@Override
protected void configureTextViewer(TextViewer textViewer) {
super.configureTextViewer(textViewer);
-
+
// hack: gain access to text viewers
switch (fViewerIndex++) {
case 0:
- fTopViewer= textViewer;
+ fTopViewer = textViewer;
fTopViewer.getTextWidget().setFont(JFaceResources.getFont(CMergeViewer.class.getName()));
break;
case 1:
- fLeftViewer= textViewer;
+ fLeftViewer = textViewer;
fLeftViewer.getTextWidget().setFont(JFaceResources.getFont(CMergeViewer.class.getName()));
fLeftViewer.addTextPresentationListener(fLeftHighlighter);
break;
case 2:
- fRightViewer= textViewer;
+ fRightViewer = textViewer;
fRightViewer.getTextWidget().setFont(JFaceResources.getFont(CMergeViewer.class.getName()));
fRightViewer.addTextPresentationListener(fRightHighlighter);
}
}
-
+
/*
* @see org.eclipse.compare.contentmergeviewer.TextMergeViewer#createTokenComparator(java.lang.String)
*/
@@ -188,12 +192,12 @@ class CMacroCompareViewer extends CMergeViewer {
/**
* Set the macro expansion input.
- *
+ *
* @param input
*/
public void setMacroExpansionInput(CMacroExpansionInput input) {
- fInput= input;
- fPrefixLength= 0;
+ fInput = input;
+ fPrefixLength = 0;
}
/*
@@ -201,29 +205,29 @@ class CMacroCompareViewer extends CMergeViewer {
*/
@Override
public void setInput(Object input) {
- boolean redraw= true;
+ boolean redraw = true;
if (fLeftViewer != null && fRightViewer != null) {
- redraw= false;
+ redraw = false;
fLeftViewer.setRedraw(false);
fRightViewer.setRedraw(false);
}
ReplaceEdit[] edits = null;
-
+
try {
if (fInput != null) {
final IMacroExpansionStep step;
if (fStepIndex < fInput.fExplorer.getExpansionStepCount()) {
- step= fInput.fExplorer.getExpansionStep(fStepIndex);
+ step = fInput.fExplorer.getExpansionStep(fStepIndex);
} else {
- step= fInput.fExplorer.getFullExpansion();
+ step = fInput.fExplorer.getFullExpansion();
}
- edits= step.getReplacements();
-
+ edits = step.getReplacements();
+
fLeftHighlighter.setReplaceEdits(fPrefixLength, edits);
fRightHighlighter.setReplaceEdits(fPrefixLength, edits);
- }
+ }
super.setInput(input);
-
+
} finally {
if (!redraw && fLeftViewer != null && fRightViewer != null) {
fLeftViewer.setRedraw(true);
@@ -232,7 +236,7 @@ class CMacroCompareViewer extends CMergeViewer {
}
if (edits != null && edits.length > 0) {
if (fLeftViewer != null && fRightViewer != null) {
- final int firstDiffOffset= fPrefixLength + edits[0].getOffset();
+ final int firstDiffOffset = fPrefixLength + edits[0].getOffset();
fLeftViewer.revealRange(firstDiffOffset, edits[0].getLength());
fRightViewer.revealRange(firstDiffOffset, edits[0].getText().length());
}
@@ -240,7 +244,7 @@ class CMacroCompareViewer extends CMergeViewer {
}
public void setMacroExpansionStep(int index) {
- fStepIndex= index;
+ fStepIndex = index;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java
index f18b6d32cad..46e4b2cf93e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java
@@ -34,7 +34,7 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
/**
* Creates a new control for use as a hover which does not take the focus.
- *
+ *
* @param parent parent shell
* @param statusFieldText text to be displayed in the status field, may be <code>null</code>
*/
@@ -45,7 +45,7 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
/**
* Creates a new control for use as a hover which optionally takes the focus.
- *
+ *
* @param parent parent shell
* @param isResizable whether this control should be resizable
*/
@@ -62,9 +62,9 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
@Override
public void setInput(Object input) {
if (input instanceof CMacroExpansionInput) {
- CMacroExpansionInput macroExpansionInput= (CMacroExpansionInput) input;
+ CMacroExpansionInput macroExpansionInput = (CMacroExpansionInput) input;
setInformation(macroExpansionInput.fExplorer.getFullExpansion().getCodeAfterStep());
- fInput= macroExpansionInput;
+ fInput = macroExpansionInput;
updateStatusText();
} else {
fInput = null;
@@ -85,9 +85,10 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
return;
}
if (fInput.fExplorer.getExpansionStepCount() > 1) {
- IBindingService bindingService= PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
if (bindingService != null) {
- String keySequence= bindingService.getBestActiveBindingFormattedFor(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
+ String keySequence = bindingService
+ .getBestActiveBindingFormattedFor(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
if (keySequence != null) {
setStatusText(NLS.bind(CHoverMessages.CMacroExpansionControl_exploreMacroExpansion, keySequence));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java
index 00613a95d13..e57413e3d35 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java
@@ -92,9 +92,9 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
*/
public class CMacroExpansionExplorationControl extends AbstractCompareViewerInformationControl {
- private static final String COMMAND_ID_EXPANSION_BACK= "org.eclipse.cdt.ui.hover.backwardMacroExpansion"; //$NON-NLS-1$
- private static final String COMMAND_ID_EXPANSION_FORWARD= "org.eclipse.cdt.ui.hover.forwardMacroExpansion"; //$NON-NLS-1$
- private static final String CONTEXT_ID_MACRO_EXPANSION_HOVER= "org.eclipse.cdt.ui.macroExpansionHoverScope"; //$NON-NLS-1$
+ private static final String COMMAND_ID_EXPANSION_BACK = "org.eclipse.cdt.ui.hover.backwardMacroExpansion"; //$NON-NLS-1$
+ private static final String COMMAND_ID_EXPANSION_FORWARD = "org.eclipse.cdt.ui.hover.forwardMacroExpansion"; //$NON-NLS-1$
+ private static final String CONTEXT_ID_MACRO_EXPANSION_HOVER = "org.eclipse.cdt.ui.macroExpansionHoverScope"; //$NON-NLS-1$
/** Dialog settings key to persist control bounds. */
public static final String KEY_CONTROL_BOUNDS = "org.eclipse.cdt.ui.text.hover.CMacroExpansionExploration"; //$NON-NLS-1$
@@ -108,17 +108,21 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
public CDiffNode(DocumentRangeNode parent, int type, String id, IDocument doc, int start, int length) {
super(parent, type, id, doc, start, length);
}
+
public CDiffNode(int type, String id, IDocument doc, int start, int length) {
super(type, id, doc, start, length);
}
+
@Override
public String getName() {
return getId();
}
+
@Override
public String getType() {
return "c2"; //$NON-NLS-1$
}
+
@Override
public Image getImage() {
return null;
@@ -140,7 +144,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
/**
* Creates a new control for use as a "quick view" where the control immediately takes the focus.
- *
+ *
* @param parent parent shell
* @param input the input object, may be <code>null</code>
*/
@@ -152,6 +156,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
public void focusGained(FocusEvent e) {
registerCommandHandlers();
}
+
@Override
public void focusLost(FocusEvent e) {
unregisterCommandHandlers();
@@ -161,14 +166,15 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
@Override
public void handleEvent(Event event) {
widgetClosed();
- }});
+ }
+ });
fillToolBar();
setDefaultSize(MIN_WIDTH, MIN_HEIGHT);
}
/**
* Creates a new control for use as a "quick view" where the control immediately takes the focus.
- *
+ *
* @param parent parent shell
*/
public CMacroExpansionExplorationControl(Shell parent) {
@@ -177,35 +183,35 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
/**
* Creates a new control for use as a "quick view" where the control immediately takes the focus.
- *
+ *
* @param parent parent shell
* @param restoreSize whether control size should be restored
*/
public CMacroExpansionExplorationControl(Shell parent, boolean restoreSize) {
this(parent, null);
- fRestoreSize= restoreSize;
+ fRestoreSize = restoreSize;
if (restoreSize) {
restoreSize();
}
}
private void restoreSize() {
- String sectionName= KEY_CONTROL_BOUNDS_INTERNAL;
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+ String sectionName = KEY_CONTROL_BOUNDS_INTERNAL;
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null) {
return;
}
try {
- int width= settings.getInt(AbstractInformationControlManager.STORE_SIZE_WIDTH);
- int height= settings.getInt(AbstractInformationControlManager.STORE_SIZE_HEIGHT);
+ int width = settings.getInt(AbstractInformationControlManager.STORE_SIZE_WIDTH);
+ int height = settings.getInt(AbstractInformationControlManager.STORE_SIZE_HEIGHT);
setDefaultSize(width, height);
} catch (NumberFormatException exc) {
// Ignore
}
}
-
+
private void setDefaultSize(int width, int height) {
- fDefaultSize= new Point(width, height);
+ fDefaultSize = new Point(width, height);
}
private void storeSize() {
@@ -213,12 +219,12 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
if (shell == null) {
return;
}
- String sectionName= KEY_CONTROL_BOUNDS_INTERNAL;
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+ String sectionName = KEY_CONTROL_BOUNDS_INTERNAL;
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null) {
- settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
+ settings = CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
}
- Point size= shell.getSize();
+ Point size = shell.getSize();
settings.put(AbstractInformationControlManager.STORE_SIZE_WIDTH, size.x);
settings.put(AbstractInformationControlManager.STORE_SIZE_HEIGHT, size.y);
}
@@ -229,26 +235,27 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
}
@Override
- protected CompareViewerControl createCompareViewerControl(Composite parent, int style, CompareConfiguration compareConfig) {
- Splitter splitter= new Splitter(parent, SWT.VERTICAL);
+ protected CompareViewerControl createCompareViewerControl(Composite parent, int style,
+ CompareConfiguration compareConfig) {
+ Splitter splitter = new Splitter(parent, SWT.VERTICAL);
splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
// text viewer to show the macro definition
- fTextScroller= new ScrolledComposite(splitter, SWT.H_SCROLL | SWT.V_SCROLL);
- fMacroViewer= createSourceViewer(fTextScroller, style);
- final StyledText textWidget= fMacroViewer.getTextWidget();
+ fTextScroller = new ScrolledComposite(splitter, SWT.H_SCROLL | SWT.V_SCROLL);
+ fMacroViewer = createSourceViewer(fTextScroller, style);
+ final StyledText textWidget = fMacroViewer.getTextWidget();
fTextScroller.setBackground(textWidget.getBackground());
fTextScroller.setContent(textWidget);
- final Point size= textWidget.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ final Point size = textWidget.computeSize(SWT.DEFAULT, SWT.DEFAULT);
textWidget.setSize(size);
// compare viewer
- CompareViewerControl control= super.createCompareViewerControl(splitter, style, compareConfig);
+ CompareViewerControl control = super.createCompareViewerControl(splitter, style, compareConfig);
splitter.setWeights(new int[] { 20, 80 });
return control;
}
@Override
protected Viewer createContentViewer(Composite parent, ICompareInput input, CompareConfiguration cc) {
- fMacroCompareViewer= new CMacroCompareViewer(parent, SWT.NULL, cc);
+ fMacroCompareViewer = new CMacroCompareViewer(parent, SWT.NULL, cc);
if (fInput != null) {
fMacroCompareViewer.setMacroExpansionInput(fInput);
fMacroCompareViewer.setMacroExpansionStep(fIndex);
@@ -257,22 +264,23 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
}
protected ISourceViewer createSourceViewer(Composite parent, int style) {
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- SourceViewer sourceViewer= new CSourceViewer(parent, null, null, false, style, store);
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ SourceViewer sourceViewer = new CSourceViewer(parent, null, null, false, style, store);
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null,
+ ICPartitions.C_PARTITIONING, false));
sourceViewer.setEditable(false);
- fMacroText= sourceViewer.getTextWidget();
+ fMacroText = sourceViewer.getTextWidget();
- Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+ Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
fMacroText.setFont(font);
- GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
- gd.heightHint= fMacroText.getLineHeight() * 2;
+ GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
+ gd.heightHint = fMacroText.getLineHeight() * 2;
fMacroText.setLayoutData(gd);
- final Document doc= new Document();
+ final Document doc = new Document();
CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
sourceViewer.setDocument(doc);
return sourceViewer;
@@ -282,11 +290,11 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
if (fHandlerService != null) {
fHandlerService.deactivateHandlers(fHandlerActivations);
fHandlerActivations.clear();
- fHandlerService= null;
+ fHandlerService = null;
}
if (fContextActivation != null) {
fContextService.deactivateContext(fContextActivation);
- fContextActivation= null;
+ fContextActivation = null;
}
}
@@ -294,48 +302,49 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
if (fContextActivation != null) {
return;
}
- IHandler backwardHandler= new AbstractHandler() {
- @Override
+ IHandler backwardHandler = new AbstractHandler() {
+ @Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- backward();
- return null;
- }
- };
- IHandler forwardHandler= new AbstractHandler() {
- @Override
+ backward();
+ return null;
+ }
+ };
+ IHandler forwardHandler = new AbstractHandler() {
+ @Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- forward();
- return null;
- }
- };
- IHandler gotoDefinitionHandler= new AbstractHandler() {
- @Override
+ forward();
+ return null;
+ }
+ };
+ IHandler gotoDefinitionHandler = new AbstractHandler() {
+ @Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- gotoMacroDefinition();
- return null;
- }
- };
-
- IWorkbench workbench= PlatformUI.getWorkbench();
- fHandlerService= workbench.getService(IHandlerService.class);
- fContextService= workbench.getService(IContextService.class);
- fContextActivation= fContextService.activateContext(CONTEXT_ID_MACRO_EXPANSION_HOVER);
- fHandlerActivations= new ArrayList<IHandlerActivation>();
- fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_BACK, backwardHandler));
- fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_FORWARD, forwardHandler));
- fHandlerActivations.add(fHandlerService.activateHandler(ICEditorActionDefinitionIds.OPEN_DECL, gotoDefinitionHandler));
-
- String infoText= getInfoText();
- if (infoText != null) {
- setStatusText(infoText);
- //bug 234952 - truncation in the info label
- PixelConverter converter = new PixelConverter(getShell());
- Point pt = getShell().getSize();
- int stringLengthInPixel = converter.convertWidthInCharsToPixels(infoText.length()+5);
- if (pt.x < stringLengthInPixel) {
- getShell().setSize(new Point(stringLengthInPixel, pt.y));
- }
- }
+ gotoMacroDefinition();
+ return null;
+ }
+ };
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ fHandlerService = workbench.getService(IHandlerService.class);
+ fContextService = workbench.getService(IContextService.class);
+ fContextActivation = fContextService.activateContext(CONTEXT_ID_MACRO_EXPANSION_HOVER);
+ fHandlerActivations = new ArrayList<IHandlerActivation>();
+ fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_BACK, backwardHandler));
+ fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_FORWARD, forwardHandler));
+ fHandlerActivations
+ .add(fHandlerService.activateHandler(ICEditorActionDefinitionIds.OPEN_DECL, gotoDefinitionHandler));
+
+ String infoText = getInfoText();
+ if (infoText != null) {
+ setStatusText(infoText);
+ //bug 234952 - truncation in the info label
+ PixelConverter converter = new PixelConverter(getShell());
+ Point pt = getShell().getSize();
+ int stringLengthInPixel = converter.convertWidthInCharsToPixels(infoText.length() + 5);
+ if (pt.x < stringLengthInPixel) {
+ getShell().setSize(new Point(stringLengthInPixel, pt.y));
+ }
+ }
}
private void fillToolBar() {
@@ -343,32 +352,35 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
if (mgr == null) {
return;
}
- IWorkbench workbench= PlatformUI.getWorkbench();
- CommandContributionItemParameter param= new CommandContributionItemParameter(workbench, null, COMMAND_ID_EXPANSION_BACK, CommandContributionItem.STYLE_PUSH);
- param.icon= CPluginImages.DESC_ELCL_NAVIGATE_BACKWARD;
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ CommandContributionItemParameter param = new CommandContributionItemParameter(workbench, null,
+ COMMAND_ID_EXPANSION_BACK, CommandContributionItem.STYLE_PUSH);
+ param.icon = CPluginImages.DESC_ELCL_NAVIGATE_BACKWARD;
+ mgr.add(new CommandContributionItem(param));
+ param = new CommandContributionItemParameter(workbench, null, COMMAND_ID_EXPANSION_FORWARD,
+ CommandContributionItem.STYLE_PUSH);
+ param.icon = CPluginImages.DESC_ELCL_NAVIGATE_FORWARD;
mgr.add(new CommandContributionItem(param));
- param = new CommandContributionItemParameter(workbench, null, COMMAND_ID_EXPANSION_FORWARD, CommandContributionItem.STYLE_PUSH);
- param.icon= CPluginImages.DESC_ELCL_NAVIGATE_FORWARD;
- mgr.add(new CommandContributionItem(param));
- param = new CommandContributionItemParameter(workbench, null, ICEditorActionDefinitionIds.OPEN_DECL, CommandContributionItem.STYLE_PUSH);
- param.icon = CPluginImages.DESC_ELCL_OPEN_DECLARATION;
- mgr.add(new CommandContributionItem(param));
- mgr.update(true);
+ param = new CommandContributionItemParameter(workbench, null, ICEditorActionDefinitionIds.OPEN_DECL,
+ CommandContributionItem.STYLE_PUSH);
+ param.icon = CPluginImages.DESC_ELCL_OPEN_DECLARATION;
+ mgr.add(new CommandContributionItem(param));
+ mgr.update(true);
}
protected final void gotoMacroDefinition() {
- int index= fIndex < getStepCount() ? fIndex : 0;
- final IMacroExpansionStep step= fInput.fExplorer.getExpansionStep(index);
- IASTFileLocation fileLocation= step.getLocationOfExpandedMacroDefinition();
+ int index = fIndex < getStepCount() ? fIndex : 0;
+ final IMacroExpansionStep step = fInput.fExplorer.getExpansionStep(index);
+ IASTFileLocation fileLocation = step.getLocationOfExpandedMacroDefinition();
if (fileLocation != null) {
- final IPath path= new Path(fileLocation.getFileName());
- final int offset= fileLocation.getNodeOffset();
- final int length= fileLocation.getNodeLength();
+ final IPath path = new Path(fileLocation.getFileName());
+ final int offset = fileLocation.getNodeOffset();
+ final int length = fileLocation.getNodeLength();
IEditorPart editor;
try {
editor = EditorUtility.openInEditor(path, null);
if (editor instanceof ITextEditor) {
- ITextEditor textEditor = (ITextEditor)editor;
+ ITextEditor textEditor = (ITextEditor) editor;
textEditor.selectAndReveal(offset, length);
}
dispose();
@@ -379,9 +391,9 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
}
protected final void forward() {
- fIndex= fixIndex(fIndex + 1);
+ fIndex = fixIndex(fIndex + 1);
if (fIndex > getStepCount()) {
- fIndex= 0;
+ fIndex = 0;
}
showExpansion();
}
@@ -389,7 +401,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
protected final void backward() {
--fIndex;
if (fIndex < 0) {
- fIndex= fixIndex(getStepCount());
+ fIndex = fixIndex(getStepCount());
}
showExpansion();
}
@@ -401,14 +413,15 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
* @return The text to be shown in the popup's information area or <code>null</code>
*/
private String getInfoText() {
- IWorkbench workbench= PlatformUI.getWorkbench();
- IBindingService bindingService= workbench.getService(IBindingService.class);
- String formattedBindingBack= bindingService.getBestActiveBindingFormattedFor(COMMAND_ID_EXPANSION_BACK);
- String formattedBindingForward= bindingService.getBestActiveBindingFormattedFor(COMMAND_ID_EXPANSION_FORWARD);
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IBindingService bindingService = workbench.getService(IBindingService.class);
+ String formattedBindingBack = bindingService.getBestActiveBindingFormattedFor(COMMAND_ID_EXPANSION_BACK);
+ String formattedBindingForward = bindingService.getBestActiveBindingFormattedFor(COMMAND_ID_EXPANSION_FORWARD);
- String infoText= null;
+ String infoText = null;
if (formattedBindingBack != null && formattedBindingForward != null) {
- infoText= NLS.bind(CHoverMessages.CMacroExpansionControl_statusText, formattedBindingBack, formattedBindingForward);
+ infoText = NLS.bind(CHoverMessages.CMacroExpansionControl_statusText, formattedBindingBack,
+ formattedBindingForward);
}
return infoText;
}
@@ -431,7 +444,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
@Override
public void setSizeConstraints(int maxWidth, int maxHeight) {
- Point constraints= getSizeConstraints();
+ Point constraints = getSizeConstraints();
if (constraints != null) {
super.setSizeConstraints(Math.max(constraints.x, maxWidth), Math.max(constraints.y, maxHeight));
} else {
@@ -442,9 +455,9 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
@Override
public void setSize(int width, int height) {
if (fDefaultSize != null) {
- width= Math.max(fDefaultSize.x, width);
- height= Math.max(fDefaultSize.y, height);
- fDefaultSize= null;
+ width = Math.max(fDefaultSize.x, width);
+ height = Math.max(fDefaultSize.y, height);
+ fDefaultSize = null;
}
super.setSize(width, height);
}
@@ -467,7 +480,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
private void widgetClosed() {
if (fRestoreSize) {
storeSize();
- fRestoreSize= false;
+ fRestoreSize = false;
}
unregisterCommandHandlers();
}
@@ -477,7 +490,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
if (!visible) {
if (fRestoreSize) {
storeSize();
- fRestoreSize= false;
+ fRestoreSize = false;
}
}
super.setVisible(visible);
@@ -488,23 +501,23 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
@Override
public Rectangle computeTrim() {
- Rectangle trim= super.computeTrim();
+ Rectangle trim = super.computeTrim();
addInternalTrim(trim);
return trim;
}
/**
* Adds the internal trimmings to the given trim of the shell.
- *
+ *
* @param trim the shell's trim, will be updated
* @since 5.0
*/
private void addInternalTrim(Rectangle trim) {
- Rectangle textTrim= fMacroText.computeTrim(0, 0, 0, 0);
- trim.x+= textTrim.x;
- trim.y+= textTrim.y;
- trim.width+= textTrim.width;
- trim.height+= textTrim.height;
+ Rectangle textTrim = fMacroText.computeTrim(0, 0, 0, 0);
+ trim.x += textTrim.x;
+ trim.y += textTrim.y;
+ trim.width += textTrim.width;
+ trim.height += textTrim.height;
}
/**
@@ -512,12 +525,12 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
* @param input
*/
private void setMacroExpansionInput(CMacroExpansionInput input) {
- fInput= input;
+ fInput = input;
if (fMacroCompareViewer != null) {
fMacroCompareViewer.setMacroExpansionInput(input);
}
if (fInput != null) {
- fIndex= fixIndex(input.fStartWithFullExpansion ? getStepCount() : 0);
+ fIndex = fixIndex(input.fStartWithFullExpansion ? getStepCount() : 0);
showExpansion();
}
}
@@ -534,20 +547,20 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
}
private void showExpansion() {
- final int idxLeft= fIndex == getStepCount() ? 0 : fIndex;
- final int idxRight= fIndex + 1;
+ final int idxLeft = fIndex == getStepCount() ? 0 : fIndex;
+ final int idxRight = fIndex + 1;
- CompareConfiguration config= getCompareConfiguration();
+ CompareConfiguration config = getCompareConfiguration();
config.setLeftLabel(getLabelForIndex(idxLeft));
config.setRightLabel(getLabelForIndex(idxRight));
- final ITypedElement left= getContentForIndex(fIndex, true);
- final ITypedElement right= getContentForIndex(fIndex, false);
-
+ final ITypedElement left = getContentForIndex(fIndex, true);
+ final ITypedElement right = getContentForIndex(fIndex, false);
+
setTitleText(NLS.bind(CHoverMessages.CMacroExpansionControl_title_macroExpansionExploration, getStepCount()));
fMacroViewer.getDocument().set(getMacroText(fIndex));
- final StyledText textWidget= fMacroViewer.getTextWidget();
- final Point size= textWidget.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ final StyledText textWidget = fMacroViewer.getTextWidget();
+ final Point size = textWidget.computeSize(SWT.DEFAULT, SWT.DEFAULT);
textWidget.setSize(size);
setInput(createCompareInput(null, left, right));
}
@@ -556,50 +569,51 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
if (index == 0) {
return CHoverMessages.CMacroExpansionControl_title_original;
} else if (index < getStepCount()) {
- return NLS.bind(CHoverMessages.CMacroExpansionControl_title_expansion,
- String.valueOf(index), String.valueOf(getStepCount()));
+ return NLS.bind(CHoverMessages.CMacroExpansionControl_title_expansion, String.valueOf(index),
+ String.valueOf(getStepCount()));
} else {
return CHoverMessages.CMacroExpansionControl_title_fullyExpanded;
}
}
+
private Object createCompareInput(ITypedElement original, ITypedElement left, ITypedElement right) {
- Differencer d= new Differencer();
+ Differencer d = new Differencer();
return d.findDifferences(false, new NullProgressMonitor(), null, original, left, right);
}
private ITypedElement getContentForIndex(int index, boolean before) {
final IMacroExpansionStep expansionStep;
if (index < getStepCount()) {
- expansionStep= fInput.fExplorer.getExpansionStep(index);
+ expansionStep = fInput.fExplorer.getExpansionStep(index);
} else {
- expansionStep= fInput.fExplorer.getFullExpansion();
+ expansionStep = fInput.fExplorer.getFullExpansion();
}
final String text;
if (before) {
- text= expansionStep.getCodeBeforeStep();
+ text = expansionStep.getCodeBeforeStep();
} else {
- text= expansionStep.getCodeAfterStep();
+ text = expansionStep.getCodeAfterStep();
}
- final Document doc= new Document(text);
+ final Document doc = new Document(text);
CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
return new CDiffNode(0, String.valueOf(index), doc, 0, text.length());
}
private String getMacroText(int index) {
- index= index < getStepCount() ? index : 0;
- final IMacroExpansionStep expansionStep= fInput.fExplorer.getExpansionStep(index);
- IMacroBinding binding= expansionStep.getExpandedMacro();
- StringBuilder buffer= new StringBuilder();
+ index = index < getStepCount() ? index : 0;
+ final IMacroExpansionStep expansionStep = fInput.fExplorer.getExpansionStep(index);
+ IMacroBinding binding = expansionStep.getExpandedMacro();
+ StringBuilder buffer = new StringBuilder();
buffer.append("#define ").append(binding.getName()); //$NON-NLS-1$
- char[][] params= binding.getParameterList();
+ char[][] params = binding.getParameterList();
if (params != null) {
buffer.append('(');
- for (int i= 0; i < params.length; i++) {
+ for (int i = 0; i < params.length; i++) {
if (i > 0) {
buffer.append(',');
buffer.append(' ');
}
- char[] param= params[i];
+ char[] param = params[i];
buffer.append(new String(param));
}
buffer.append(')');
@@ -607,9 +621,8 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
buffer.append(' ');
if (!binding.isDynamic()) {
buffer.append(binding.getExpansionImage());
- }
- else {
- ReplaceEdit[] replacements= expansionStep.getReplacements();
+ } else {
+ ReplaceEdit[] replacements = expansionStep.getReplacements();
if (replacements.length == 1) {
buffer.append(replacements[0].getText());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java
index a9a77de9dfa..3d6ded79500 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java
@@ -30,19 +30,19 @@ import org.eclipse.ui.part.IWorkbenchPartOrientation;
public class CMacroExpansionHover extends AbstractCEditorTextHover {
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
- Object hoverInfo= getHoverInfo2(textViewer, hoverRegion);
+ Object hoverInfo = getHoverInfo2(textViewer, hoverRegion);
return hoverInfo != null ? hoverInfo.toString() : null;
}
-
+
/*
* @see AbstractCEditorTextHover#getHoverInfo2(ITextViewer, IRegion)
*/
@Override
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
- CMacroExpansionInput input= CMacroExpansionInput.create(getEditor(), hoverRegion, false);
+ CMacroExpansionInput input = CMacroExpansionInput.create(getEditor(), hoverRegion, false);
return input;
}
-
+
/*
* @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
*/
@@ -64,10 +64,10 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
- IEditorPart editor= getEditor();
- int orientation= SWT.NONE;
+ IEditorPart editor = getEditor();
+ int orientation = SWT.NONE;
if (editor instanceof IWorkbenchPartOrientation)
- orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
+ orientation = ((IWorkbenchPartOrientation) editor).getOrientation();
return new SourceViewerInformationControl(parent, true, orientation, null);
}
};
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformationProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformationProvider.java
index 852c36ec017..c020b1d0b9d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformationProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformationProvider.java
@@ -25,18 +25,18 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.texteditor.ITextEditor;
-
/**
* Information provider for macro exploration.
*
* @since 5.0
*/
-public class CMacroExpansionInformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
+public class CMacroExpansionInformationProvider
+ implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
private final ITextEditor fEditor;
public CMacroExpansionInformationProvider(ITextEditor editor) {
- fEditor= editor;
+ fEditor = editor;
}
/*
@@ -52,7 +52,7 @@ public class CMacroExpansionInformationProvider implements IInformationProvider,
*/
@Override
public IRegion getSubject(ITextViewer textViewer, int offset) {
- Point selection= textViewer.getSelectedRange();
+ Point selection = textViewer.getSelectedRange();
return new Region(selection.x, selection.y);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.java
index ed1b29185ec..a8a02d1d6df 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.java
@@ -58,17 +58,19 @@ import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
/**
* An input object to the {@link CMacroExpansionExplorationControl}.
- *
+ *
* @since 5.0
*/
public class CMacroExpansionInput {
private static class SingletonRule implements ISchedulingRule {
public static final ISchedulingRule INSTANCE = new SingletonRule();
+
@Override
public boolean contains(ISchedulingRule rule) {
return rule == this;
}
+
@Override
public boolean isConflicting(ISchedulingRule rule) {
return rule == this;
@@ -82,13 +84,13 @@ public class CMacroExpansionInput {
private final Position fTextRegion;
private final boolean fAllowSelection;
private IASTNode fEnclosingNode;
- private List<IASTNode> fExpansionNodes= new ArrayList<IASTNode>();
+ private List<IASTNode> fExpansionNodes = new ArrayList<IASTNode>();
private MacroExpansionExplorer fExplorer;
private IRegion fExpansionRegion;
private ExpansionRegionComputer(ITranslationUnit tUnit, IRegion textRegion, boolean allowSelection) {
- fTextRegion= new Position(textRegion.getOffset(), textRegion.getLength());
- fAllowSelection= allowSelection;
+ fTextRegion = new Position(textRegion.getOffset(), textRegion.getLength());
+ fAllowSelection = allowSelection;
}
/*
@@ -99,13 +101,13 @@ public class CMacroExpansionInput {
if (ast != null) {
final IASTNodeSelector nodeSelector = ast.getNodeSelector(ast.getFilePath());
// try exact macro name match first
- IASTNode node= nodeSelector.findName(fTextRegion.getOffset(), fTextRegion.getLength());
+ IASTNode node = nodeSelector.findName(fTextRegion.getOffset(), fTextRegion.getLength());
if (node instanceof IASTName) {
- IASTName macroName= (IASTName) node;
- IBinding binding= macroName.getBinding();
+ IASTName macroName = (IASTName) node;
+ IBinding binding = macroName.getBinding();
// skip macro references that belong to a macro definition or an undef directive
- if (binding instanceof IMacroBinding && !macroName.isDefinition() &&
- macroName.getParent() instanceof IASTPreprocessorMacroExpansion) {
+ if (binding instanceof IMacroBinding && !macroName.isDefinition()
+ && macroName.getParent() instanceof IASTPreprocessorMacroExpansion) {
addExpansionNode(node);
createMacroExpansionExplorer(ast);
return Status.OK_STATUS;
@@ -113,32 +115,32 @@ public class CMacroExpansionInput {
}
if (fAllowSelection) {
// selection
- boolean macroOccurrence= false;
- fEnclosingNode= nodeSelector.findEnclosingNode(fTextRegion.getOffset(), fTextRegion.getLength());
+ boolean macroOccurrence = false;
+ fEnclosingNode = nodeSelector.findEnclosingNode(fTextRegion.getOffset(), fTextRegion.getLength());
if (fEnclosingNode == null) {
// selection beyond last declaration
- fEnclosingNode= ast;
- }
- else if (fEnclosingNode.getParent() instanceof IASTPreprocessorMacroExpansion) {
+ fEnclosingNode = ast;
+ } else if (fEnclosingNode.getParent() instanceof IASTPreprocessorMacroExpansion) {
// selection enclosed by the name of a macro expansion
- fEnclosingNode= fEnclosingNode.getParent();
+ fEnclosingNode = fEnclosingNode.getParent();
}
-
+
if (fEnclosingNode instanceof IASTPreprocessorMacroExpansion) {
// selection enclosed by a macro expansion
addExpansionNode(fEnclosingNode);
- macroOccurrence= true;
- }
- else {
- IASTNodeLocation[] locations= fEnclosingNode.getNodeLocations();
+ macroOccurrence = true;
+ } else {
+ IASTNodeLocation[] locations = fEnclosingNode.getNodeLocations();
for (int i = 0; i < locations.length; i++) {
- IASTNodeLocation location= locations[i];
+ IASTNodeLocation location = locations[i];
if (location instanceof IASTMacroExpansionLocation) {
- IASTFileLocation fileLocation= location.asFileLocation();
+ IASTFileLocation fileLocation = location.asFileLocation();
if (fileLocation != null && ast.getFilePath().equals(fileLocation.getFileName())) {
- if (fTextRegion.overlapsWith(fileLocation.getNodeOffset(), fileLocation.getNodeLength())) {
- addExpansionNode(nodeSelector.findEnclosingNode(fileLocation.getNodeOffset(), fileLocation.getNodeLength()));
- macroOccurrence= true;
+ if (fTextRegion.overlapsWith(fileLocation.getNodeOffset(),
+ fileLocation.getNodeLength())) {
+ addExpansionNode(nodeSelector.findEnclosingNode(fileLocation.getNodeOffset(),
+ fileLocation.getNodeLength()));
+ macroOccurrence = true;
}
}
}
@@ -154,16 +156,16 @@ public class CMacroExpansionInput {
}
private void createMacroExpansionExplorer(IASTTranslationUnit ast) {
- IRegion region= getExpansionRegion();
+ IRegion region = getExpansionRegion();
if (region != null) {
- fExplorer= MacroExpansionExplorer.create(ast, region);
- fExpansionRegion= region;
+ fExplorer = MacroExpansionExplorer.create(ast, region);
+ fExpansionRegion = region;
}
}
private void addExpansionNode(IASTNode node) {
if (node != null) {
- fEnclosingNode= computeCommonAncestor(node, fEnclosingNode);
+ fEnclosingNode = computeCommonAncestor(node, fEnclosingNode);
fExpansionNodes.add(node);
}
}
@@ -178,16 +180,16 @@ public class CMacroExpansionInput {
if (node == other) {
return other;
}
- List<IASTNode> ancestors= new ArrayList<IASTNode>();
+ List<IASTNode> ancestors = new ArrayList<IASTNode>();
while (node != null) {
- node= node.getParent();
+ node = node.getParent();
ancestors.add(node);
}
while (other != null) {
if (ancestors.contains(other)) {
return other;
}
- other= other.getParent();
+ other = other.getParent();
}
return null;
}
@@ -196,52 +198,52 @@ public class CMacroExpansionInput {
if (fExpansionRegion != null)
return fExpansionRegion;
if (fEnclosingNode != null) {
- int startOffset= Integer.MAX_VALUE;
- int endOffset= fTextRegion.getOffset() + fTextRegion.getLength();
- for (Iterator<IASTNode> it= fExpansionNodes.iterator(); it.hasNext(); ) {
- IASTNode node= it.next();
+ int startOffset = Integer.MAX_VALUE;
+ int endOffset = fTextRegion.getOffset() + fTextRegion.getLength();
+ for (Iterator<IASTNode> it = fExpansionNodes.iterator(); it.hasNext();) {
+ IASTNode node = it.next();
if (node != fEnclosingNode) {
while (node != null && node.getParent() != fEnclosingNode) {
- node= node.getParent();
+ node = node.getParent();
}
}
if (node != null) {
- IASTFileLocation location= node.getFileLocation();
+ IASTFileLocation location = node.getFileLocation();
if (location != null) {
- startOffset= Math.min(startOffset, location.getNodeOffset());
- endOffset= Math.max(endOffset, location.getNodeOffset() + location.getNodeLength());
+ startOffset = Math.min(startOffset, location.getNodeOffset());
+ endOffset = Math.max(endOffset, location.getNodeOffset() + location.getNodeLength());
}
}
}
if (endOffset > startOffset) {
- startOffset= Math.min(startOffset, fTextRegion.getOffset());
+ startOffset = Math.min(startOffset, fTextRegion.getOffset());
return new Region(startOffset, endOffset - startOffset);
}
}
return null;
}
-
+
MacroExpansionExplorer getMacroExpansionExplorer() {
return fExplorer;
}
}
final MacroExpansionExplorer fExplorer;
- boolean fStartWithFullExpansion= true;
+ boolean fStartWithFullExpansion = true;
private CMacroExpansionInput(MacroExpansionExplorer explorer) {
Assert.isNotNull(explorer);
- fExplorer= explorer;
+ fExplorer = explorer;
}
@Override
public String toString() {
return fExplorer.getFullExpansion().getCodeAfterStep();
}
-
+
/**
* Creates an input object for the macro expansion exploration control {@link CMacroExpansionExplorationControl}.
- *
+ *
* @param editor the active editor
* @param textRegion the text region where to consider macro expansions
* @param force force computation of the input, if <code>true</code> this may trigger a parse
@@ -251,8 +253,8 @@ public class CMacroExpansionInput {
if (editor == null || !(editor instanceof ITextEditor)) {
return null;
}
- IEditorInput editorInput= editor.getEditorInput();
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
+ IEditorInput editorInput = editor.getEditorInput();
+ IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
IWorkingCopy tu = manager.getWorkingCopy(editorInput);
try {
if (tu == null || !tu.isConsistent()) {
@@ -261,26 +263,27 @@ public class CMacroExpansionInput {
} catch (CModelException exc) {
return null;
}
-
- ExpansionRegionComputer computer= new ExpansionRegionComputer(tu, textRegion, force);
+
+ ExpansionRegionComputer computer = new ExpansionRegionComputer(tu, textRegion, force);
doRunOnAST(computer, tu, force);
- MacroExpansionExplorer explorer= computer.getMacroExpansionExplorer();
+ MacroExpansionExplorer explorer = computer.getMacroExpansionExplorer();
if (explorer == null) {
return null;
}
- CMacroExpansionInput input= new CMacroExpansionInput(explorer);
+ CMacroExpansionInput input = new CMacroExpansionInput(explorer);
return input;
}
private static void doRunOnAST(final ASTRunnable runnable, final ITranslationUnit tu, boolean force) {
- Job job= new Job(CHoverMessages.CMacroExpansionInput_jobTitle) {
+ Job job = new Job(CHoverMessages.CMacroExpansionInput_jobTitle) {
@Override
protected IStatus run(IProgressMonitor monitor) {
return ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_ACTIVE_ONLY, monitor, runnable);
- }};
+ }
+ };
// If the hover thread is interrupted this might have negative
// effects on the index - see http://bugs.eclipse.org/219834
@@ -299,7 +302,7 @@ public class CMacroExpansionInput {
/**
* Expand the given text region to span complete lines of the document and
* add a number of lines before and after the region.
- *
+ *
* @param region the text region
* @param document the underlying text document
* @param contextLines the number of lines to add
@@ -307,23 +310,23 @@ public class CMacroExpansionInput {
*/
public static final IRegion expandRegion(IRegion region, IDocument document, int contextLines) {
try {
- int start= document.getLineOfOffset(region.getOffset());
- start= Math.max(start - contextLines, 0);
- int offset= document.getLineOffset(start);
- CHeuristicScanner scanner= new CHeuristicScanner(document);
- offset= scanner.findNonWhitespaceForward(offset, region.getOffset() + 1);
-
- int end= document.getLineOfOffset(region.getOffset() + region.getLength());
- end= Math.min(end + contextLines, document.getNumberOfLines() - 1);
+ int start = document.getLineOfOffset(region.getOffset());
+ start = Math.max(start - contextLines, 0);
+ int offset = document.getLineOffset(start);
+ CHeuristicScanner scanner = new CHeuristicScanner(document);
+ offset = scanner.findNonWhitespaceForward(offset, region.getOffset() + 1);
+
+ int end = document.getLineOfOffset(region.getOffset() + region.getLength());
+ end = Math.min(end + contextLines, document.getNumberOfLines() - 1);
final int endOffset;
if (document.getNumberOfLines() > end + 1) {
- endOffset= document.getLineOffset(end + 1);
+ endOffset = document.getLineOffset(end + 1);
} else {
- endOffset= document.getLineOffset(end) + document.getLineLength(end);
+ endOffset = document.getLineOffset(end) + document.getLineLength(end);
}
return new Region(offset, endOffset - offset);
-
+
} catch (BadLocationException x) {
return region;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
index 94710a69ffe..607b5c87554 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
@@ -147,14 +147,14 @@ public class CSourceHover extends AbstractCEditorTextHover {
/**
* @param tUnit the translation unit
* @param textRegion the selected region
- * @param selection the text of the selected region without
+ * @param selection the text of the selected region without
*/
public ComputeSourceRunnable(ITranslationUnit tUnit, IRegion textRegion, String selection) {
- fTU= tUnit;
- fTextRegion= textRegion;
+ fTU = tUnit;
+ fTextRegion = textRegion;
fSelection = selection;
- fMonitor= new NullProgressMonitor();
- fSource= null;
+ fMonitor = new NullProgressMonitor();
+ fSource = null;
}
@Override
@@ -169,13 +169,14 @@ public class CSourceHover extends AbstractCEditorTextHover {
if (type != null && !(type instanceof IProblemType))
fSource = ASTTypeUtil.getType(type, false);
} else {
- IASTName name= nodeSelector.findEnclosingName(fTextRegion.getOffset(), fTextRegion.getLength());
+ IASTName name = nodeSelector.findEnclosingName(fTextRegion.getOffset(),
+ fTextRegion.getLength());
if (name != null) {
IASTNode parent = name.getParent();
if (parent instanceof ICPPASTTemplateId) {
name = (IASTName) parent;
}
- IBinding binding= name.resolveBinding();
+ IBinding binding = name.resolveBinding();
if (binding != null) {
// Check for implicit names first, could be an implicit constructor call.
if (name.getParent() instanceof IASTImplicitNameOwner) {
@@ -203,18 +204,18 @@ public class CSourceHover extends AbstractCEditorTextHover {
if (binding instanceof IProblemBinding) {
// Report problem as source comment.
if (DEBUG) {
- IProblemBinding problem= (IProblemBinding) binding;
- fSource= "/* Problem:\n" + //$NON-NLS-1$
- " * " + problem.getMessage() + //$NON-NLS-1$
+ IProblemBinding problem = (IProblemBinding) binding;
+ fSource = "/* Problem:\n" + //$NON-NLS-1$
+ " * " + problem.getMessage() + //$NON-NLS-1$
"\n */"; //$NON-NLS-1$
}
} else if (binding instanceof IMacroBinding) {
- fSource= computeSourceForMacro(ast, name, binding);
+ fSource = computeSourceForMacro(ast, name, binding);
} else if (binding instanceof IEnumerator) {
// Show integer value for enumerators (bug 285126).
- fSource= computeSourceForEnumerator(ast, (IEnumerator) binding);
+ fSource = computeSourceForEnumerator(ast, (IEnumerator) binding);
} else {
- fSource= computeSourceForBinding(ast, binding);
+ fSource = computeSourceForBinding(ast, binding);
}
}
}
@@ -235,19 +236,19 @@ public class CSourceHover extends AbstractCEditorTextHover {
* Compute the source for a macro. If the source location of the macro definition can be
* determined, the source is taken from there, otherwise the source is constructed as
* a {@code #define} directive.
- *
+ *
* @param ast the AST of the translation unit
* @param name the macro occurrence in the AST
* @param binding the binding of the macro name
* @return the source or {@code null}
- * @throws CoreException
+ * @throws CoreException
*/
private String computeSourceForMacro(IASTTranslationUnit ast, IASTName name, IBinding binding)
throws CoreException {
// Search for the macro definition
IName[] defs = ast.getDefinitions(binding);
for (IName def : defs) {
- String source= computeSourceForName(def, binding);
+ String source = computeSourceForName(def, binding);
if (source != null) {
return source;
}
@@ -265,8 +266,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
* @return the enumerator value, source or {@code null}
* @throws CoreException
*/
- private String computeSourceForEnumerator(IASTTranslationUnit ast, IEnumerator binding)
- throws CoreException {
+ private String computeSourceForEnumerator(IASTTranslationUnit ast, IEnumerator binding) throws CoreException {
Number numValue = binding.getValue().numberValue();
if (numValue != null) {
return numValue.toString();
@@ -274,7 +274,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
// Search for the enumerator definition
IName[] defs = ast.getDefinitions(binding);
for (IName def : defs) {
- String source= computeSourceForName(def, binding);
+ String source = computeSourceForName(def, binding);
if (source != null) {
return source;
}
@@ -287,7 +287,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
* Find a definition or declaration for the given binding and returns the source for it.
* Definitions are preferred over declarations. In case of multiple definitions or
* declarations, and the first name which yields source is taken.
- *
+ *
* @param ast the AST of the translation unit
* @param binding the binding
* @return a source string or {@code null}, if no source could be computed
@@ -298,7 +298,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
private String computeSourceForBinding(IASTTranslationUnit ast, IBinding binding)
throws CoreException, DOMException {
IName[] names = findDefsOrDecls(ast, binding);
-
+
// In case the binding is a non-explicit specialization we need
// to consider the original binding (bug 281396).
while (names.length == 0 && binding instanceof ICPPSpecialization) {
@@ -306,13 +306,13 @@ public class CSourceHover extends AbstractCEditorTextHover {
if (specializedBinding == null || specializedBinding instanceof IProblemBinding) {
break;
}
-
+
names = findDefsOrDecls(ast, specializedBinding);
binding = specializedBinding;
}
if (names.length > 0) {
for (IName name : names) {
- String source= computeSourceForName(name, binding);
+ String source = computeSourceForName(name, binding);
if (source != null) {
return source;
}
@@ -322,104 +322,108 @@ public class CSourceHover extends AbstractCEditorTextHover {
}
private IName[] findDefsOrDecls(IASTTranslationUnit ast, IBinding binding) throws CoreException {
- IName[] names= findDefinitions(ast, binding);
+ IName[] names = findDefinitions(ast, binding);
if (names.length == 0) {
- names= findDeclarations(ast, binding);
+ names = findDeclarations(ast, binding);
}
return names;
}
/**
* Returns the source for the given name from the underlying file.
- *
+ *
* @param name the name to get the source for
* @param binding the binding of the name
* @return the source string or {@code null}, if the source could not be computed
* @throws CoreException if the file could not be loaded
*/
private String computeSourceForName(IName name, IBinding binding) throws CoreException {
- IASTFileLocation fileLocation= name.getFileLocation();
+ IASTFileLocation fileLocation = name.getFileLocation();
if (fileLocation == null) {
return null;
}
- int nodeOffset= fileLocation.getNodeOffset();
- int nodeLength= fileLocation.getNodeLength();
-
- String fileName= fileLocation.getFileName();
- if (DEBUG) System.out.println("[CSourceHover] Computing source for " + name + " in " + fileName); //$NON-NLS-1$//$NON-NLS-2$
- IPath location= Path.fromOSString(fileName);
- LocationKind locationKind= LocationKind.LOCATION;
+ int nodeOffset = fileLocation.getNodeOffset();
+ int nodeLength = fileLocation.getNodeLength();
+
+ String fileName = fileLocation.getFileName();
+ if (DEBUG)
+ System.out.println("[CSourceHover] Computing source for " + name + " in " + fileName); //$NON-NLS-1$//$NON-NLS-2$
+ IPath location = Path.fromOSString(fileName);
+ LocationKind locationKind = LocationKind.LOCATION;
if (name instanceof IASTName && !name.isReference()) {
- IASTName astName= (IASTName) name;
+ IASTName astName = (IASTName) name;
if (astName.getTranslationUnit().getFilePath().equals(fileName)) {
int hoverOffset = fTextRegion.getOffset();
- if (hoverOffset <= nodeOffset && nodeOffset < hoverOffset + fTextRegion.getLength() ||
- hoverOffset >= nodeOffset && hoverOffset < nodeOffset + nodeLength) {
+ if (hoverOffset <= nodeOffset && nodeOffset < hoverOffset + fTextRegion.getLength()
+ || hoverOffset >= nodeOffset && hoverOffset < nodeOffset + nodeLength) {
// Bug 359352 - don't show source if its the same we are hovering on.
return computeHoverForDeclaration(astName);
}
if (fTU.getResource() != null) {
// Reuse editor buffer for names local to the translation unit
- location= fTU.getResource().getFullPath();
- locationKind= LocationKind.IFILE;
+ location = fTU.getResource().getFullPath();
+ locationKind = LocationKind.IFILE;
}
}
} else {
// Try to resolve path to a resource for proper encoding (bug 221029)
- IFile file= EditorUtility.getWorkspaceFileAtLocation(location, fTU);
+ IFile file = EditorUtility.getWorkspaceFileAtLocation(location, fTU);
if (file != null) {
- location= file.getFullPath();
- locationKind= LocationKind.IFILE;
+ location = file.getFullPath();
+ locationKind = LocationKind.IFILE;
if (name instanceof IIndexName) {
// Need to adjust index offsets to current offsets
// in case file has been modified since last index time.
- IIndexName indexName= (IIndexName) name;
- long timestamp= indexName.getFile().getTimestamp();
- IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(file, timestamp);
+ IIndexName indexName = (IIndexName) name;
+ long timestamp = indexName.getFile().getTimestamp();
+ IPositionConverter converter = CCorePlugin.getPositionTrackerManager()
+ .findPositionConverter(file, timestamp);
if (converter != null) {
- IRegion currentLocation= converter.historicToActual(new Region(nodeOffset, nodeLength));
- nodeOffset= currentLocation.getOffset();
- nodeLength= currentLocation.getLength();
+ IRegion currentLocation = converter.historicToActual(new Region(nodeOffset, nodeLength));
+ nodeOffset = currentLocation.getOffset();
+ nodeLength = currentLocation.getLength();
}
}
}
}
- ITextFileBufferManager mgr= FileBuffers.getTextFileBufferManager();
+ ITextFileBufferManager mgr = FileBuffers.getTextFileBufferManager();
mgr.connect(location, locationKind, fMonitor);
- ITextFileBuffer buffer= mgr.getTextFileBuffer(location, locationKind);
+ ITextFileBuffer buffer = mgr.getTextFileBuffer(location, locationKind);
try {
- IRegion nameRegion= new Region(nodeOffset, nodeLength);
- final int nameOffset= nameRegion.getOffset();
+ IRegion nameRegion = new Region(nodeOffset, nodeLength);
+ final int nameOffset = nameRegion.getOffset();
final int sourceStart;
final int sourceEnd;
- IDocument doc= buffer.getDocument();
+ IDocument doc = buffer.getDocument();
if (nameOffset >= doc.getLength() || nodeLength <= 0) {
return null;
}
if (binding instanceof IMacroBinding) {
- ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, nameOffset, false);
+ ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, nameOffset,
+ false);
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
- int directiveStart= partition.getOffset();
- int commentStart= searchCommentBackward(doc, directiveStart, -1);
+ int directiveStart = partition.getOffset();
+ int commentStart = searchCommentBackward(doc, directiveStart, -1);
if (commentStart >= 0) {
- sourceStart= commentStart;
+ sourceStart = commentStart;
} else {
- sourceStart= directiveStart;
+ sourceStart = directiveStart;
}
- sourceEnd= directiveStart + partition.getLength();
+ sourceEnd = directiveStart + partition.getLength();
} else {
return null;
}
} else {
// Expand source range to include preceding comment, if any
- boolean isKnR= isKnRSource(name);
- sourceStart= computeSourceStart(doc, nameOffset, binding, isKnR);
+ boolean isKnR = isKnRSource(name);
+ sourceStart = computeSourceStart(doc, nameOffset, binding, isKnR);
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
return null;
}
- sourceEnd= computeSourceEnd(doc, nameOffset + nameRegion.getLength(), binding, name.isDefinition(), isKnR);
+ sourceEnd = computeSourceEnd(doc, nameOffset + nameRegion.getLength(), binding, name.isDefinition(),
+ isKnR);
}
- String source= buffer.getDocument().get(sourceStart, sourceEnd - sourceStart);
+ String source = buffer.getDocument().get(sourceStart, sourceEnd - sourceStart);
return source;
} catch (BadLocationException e) {
CUIPlugin.log(e);
@@ -432,7 +436,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
/**
* Computes the hover containing the deduced type for a declaration based on {@code auto}
* keyword.
- *
+ *
* @param name the name of the declarator
* @return the hover text, if the declaration is based on {@code auto} keyword,
* otherwise {@code null}.
@@ -448,8 +452,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
} else if (declaration instanceof IASTParameterDeclaration) {
declSpec = ((IASTParameterDeclaration) declaration).getDeclSpecifier();
}
- if (!(declSpec instanceof ICPPASTSimpleDeclSpecifier) ||
- ((ICPPASTSimpleDeclSpecifier) declSpec).getType() != IASTSimpleDeclSpecifier.t_auto) {
+ if (!(declSpec instanceof ICPPASTSimpleDeclSpecifier)
+ || ((ICPPASTSimpleDeclSpecifier) declSpec).getType() != IASTSimpleDeclSpecifier.t_auto) {
return null;
}
IType type = CPPVisitor.createType(declarator);
@@ -466,105 +470,114 @@ public class CSourceHover extends AbstractCEditorTextHover {
*/
private boolean isKnRSource(IName name) {
if (name instanceof IASTName) {
- IASTNode node= (IASTNode)name;
+ IASTNode node = (IASTNode) name;
while (node.getParent() != null) {
if (node instanceof ICASTKnRFunctionDeclarator) {
return node.getParent() instanceof IASTFunctionDefinition;
}
- node= node.getParent();
+ node = node.getParent();
}
}
return false;
}
- private int computeSourceStart(IDocument doc, int nameOffset, IBinding binding, boolean isKnR) throws BadLocationException {
- int sourceStart= nameOffset;
- CHeuristicScanner scanner= new CHeuristicScanner(doc);
+ private int computeSourceStart(IDocument doc, int nameOffset, IBinding binding, boolean isKnR)
+ throws BadLocationException {
+ int sourceStart = nameOffset;
+ CHeuristicScanner scanner = new CHeuristicScanner(doc);
if (binding instanceof IParameter) {
if (isKnR) {
- sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
+ sourceStart = scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
} else {
- sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '>', '(', ',' });
+ sourceStart = scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND,
+ new char[] { '>', '(', ',' });
if (sourceStart > 0 && doc.getChar(sourceStart) == '>') {
- sourceStart= scanner.findOpeningPeer(sourceStart - 1, '<', '>');
+ sourceStart = scanner.findOpeningPeer(sourceStart - 1, '<', '>');
if (sourceStart > 0) {
- sourceStart= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '(', ',' });
+ sourceStart = scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND,
+ new char[] { '(', ',' });
}
}
}
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
return sourceStart;
}
- sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
+ sourceStart = scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
sourceStart = nameOffset;
}
} else if (binding instanceof ICPPTemplateParameter) {
- sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '>', '<', ',' });
+ sourceStart = scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '>', '<', ',' });
if (sourceStart > 0 && doc.getChar(sourceStart) == '>') {
- sourceStart= scanner.findOpeningPeer(sourceStart - 1, '<', '>');
+ sourceStart = scanner.findOpeningPeer(sourceStart - 1, '<', '>');
if (sourceStart > 0) {
- sourceStart= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '<', ',' });
+ sourceStart = scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND,
+ new char[] { '<', ',' });
}
}
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
return sourceStart;
}
- sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
+ sourceStart = scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
sourceStart = nameOffset;
}
} else if (binding instanceof IEnumerator) {
- sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '{', ',' });
+ sourceStart = scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '{', ',' });
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
return sourceStart;
}
- sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
+ sourceStart = scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
sourceStart = nameOffset;
}
} else {
final boolean expectClosingBrace;
- IType type= null;
+ IType type = null;
if (binding instanceof ITypedef) {
- type= ((ITypedef)binding).getType();
+ type = ((ITypedef) binding).getType();
} else if (binding instanceof IVariable) {
- type= ((IVariable)binding).getType();
+ type = ((IVariable) binding).getType();
}
- expectClosingBrace= (type instanceof ICompositeType || type instanceof IEnumeration) && !(binding instanceof IVariable);
- final int nameLine= doc.getLineOfOffset(nameOffset);
- sourceStart= nameOffset;
+ expectClosingBrace = (type instanceof ICompositeType || type instanceof IEnumeration)
+ && !(binding instanceof IVariable);
+ final int nameLine = doc.getLineOfOffset(nameOffset);
+ sourceStart = nameOffset;
int commentBound;
if (isKnR) {
- commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
+ commentBound = scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND,
+ new char[] { ')', ';' });
} else {
- commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '{', '}', ';' });
+ commentBound = scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND,
+ new char[] { '{', '}', ';' });
}
while (expectClosingBrace && commentBound > 0 && doc.getChar(commentBound) == '}') {
- int openingBrace= scanner.findOpeningPeer(commentBound - 1, '{', '}');
+ int openingBrace = scanner.findOpeningPeer(commentBound - 1, '{', '}');
if (openingBrace != CHeuristicScanner.NOT_FOUND) {
- sourceStart= openingBrace - 1;
+ sourceStart = openingBrace - 1;
}
if (isKnR) {
- commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
+ commentBound = scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND,
+ new char[] { ')', ';' });
} else {
- commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '{', '}', ';' });
+ commentBound = scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND,
+ new char[] { '{', '}', ';' });
}
}
if (commentBound == CHeuristicScanner.NOT_FOUND) {
- commentBound= -1; // unbound
+ commentBound = -1; // unbound
}
- sourceStart= Math.min(sourceStart, doc.getLineOffset(nameLine));
- int commentStart= searchCommentBackward(doc, sourceStart, commentBound);
+ sourceStart = Math.min(sourceStart, doc.getLineOffset(nameLine));
+ int commentStart = searchCommentBackward(doc, sourceStart, commentBound);
if (commentStart >= 0) {
- sourceStart= commentStart;
+ sourceStart = commentStart;
} else {
- int nextNonWS= scanner.findNonWhitespaceForward(commentBound+1, sourceStart);
+ int nextNonWS = scanner.findNonWhitespaceForward(commentBound + 1, sourceStart);
if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
- int nextNonWSLine= doc.getLineOfOffset(nextNonWS);
- int lineOffset= doc.getLineOffset(nextNonWSLine);
+ int nextNonWSLine = doc.getLineOfOffset(nextNonWS);
+ int lineOffset = doc.getLineOffset(nextNonWSLine);
if (doc.get(lineOffset, nextNonWS - lineOffset).trim().isEmpty()) {
- sourceStart= doc.getLineOffset(nextNonWSLine);
+ sourceStart = doc.getLineOffset(nextNonWSLine);
}
}
}
@@ -572,79 +585,82 @@ public class CSourceHover extends AbstractCEditorTextHover {
return sourceStart;
}
- private int computeSourceEnd(IDocument doc, int start, IBinding binding, boolean isDefinition, boolean isKnR) throws BadLocationException {
- int sourceEnd= start;
- CHeuristicScanner scanner= new CHeuristicScanner(doc);
+ private int computeSourceEnd(IDocument doc, int start, IBinding binding, boolean isDefinition, boolean isKnR)
+ throws BadLocationException {
+ int sourceEnd = start;
+ CHeuristicScanner scanner = new CHeuristicScanner(doc);
// Expand forward to the end of the definition/declaration
- boolean searchBrace= false;
- boolean searchSemi= false;
- boolean searchComma= false;
+ boolean searchBrace = false;
+ boolean searchSemi = false;
+ boolean searchComma = false;
if (binding instanceof ICompositeType && isDefinition || binding instanceof IEnumeration) {
- searchBrace= true;
+ searchBrace = true;
} else if (binding instanceof ICPPTemplateDefinition) {
- searchBrace= true;
+ searchBrace = true;
} else if (binding instanceof IFunction && isDefinition) {
- searchBrace= true;
+ searchBrace = true;
} else if (binding instanceof IParameter) {
if (isKnR) {
- searchSemi= true;
+ searchSemi = true;
} else {
- searchComma= true;
+ searchComma = true;
}
} else if (binding instanceof IEnumerator || binding instanceof ICPPTemplateParameter) {
- searchComma= true;
+ searchComma = true;
} else if (binding instanceof IVariable || binding instanceof ITypedef) {
- searchSemi= true;
+ searchSemi = true;
} else if (!isDefinition) {
- searchSemi= true;
+ searchSemi = true;
}
if (searchBrace) {
- int brace= scanner.scanForward(start, CHeuristicScanner.UNBOUND, '{');
+ int brace = scanner.scanForward(start, CHeuristicScanner.UNBOUND, '{');
if (brace != CHeuristicScanner.NOT_FOUND) {
- sourceEnd= scanner.findClosingPeer(brace + 1, '{', '}');
+ sourceEnd = scanner.findClosingPeer(brace + 1, '{', '}');
if (sourceEnd == CHeuristicScanner.NOT_FOUND) {
- sourceEnd= doc.getLength();
+ sourceEnd = doc.getLength();
}
}
// Expand region to include whole line
- IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
- sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
+ IRegion lineRegion = doc.getLineInformationOfOffset(sourceEnd);
+ sourceEnd = lineRegion.getOffset() + lineRegion.getLength();
} else if (searchSemi) {
- int semi= scanner.scanForward(start, CHeuristicScanner.UNBOUND, ';');
+ int semi = scanner.scanForward(start, CHeuristicScanner.UNBOUND, ';');
if (semi != CHeuristicScanner.NOT_FOUND) {
- sourceEnd= semi+1;
+ sourceEnd = semi + 1;
}
// Expand region to include whole line
- IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
- sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
+ IRegion lineRegion = doc.getLineInformationOfOffset(sourceEnd);
+ sourceEnd = lineRegion.getOffset() + lineRegion.getLength();
} else if (searchComma) {
int bound;
if (binding instanceof IParameter) {
- bound= scanner.findClosingPeer(start, '(', ')');
+ bound = scanner.findClosingPeer(start, '(', ')');
} else if (binding instanceof ICPPTemplateParameter) {
- bound= scanner.findClosingPeer(start, '<', '>');
+ bound = scanner.findClosingPeer(start, '<', '>');
} else if (binding instanceof IEnumerator) {
- bound= scanner.findClosingPeer(start, '{', '}');
+ bound = scanner.findClosingPeer(start, '{', '}');
} else {
bound = CHeuristicScanner.NOT_FOUND;
}
if (bound == CHeuristicScanner.NOT_FOUND) {
- bound= Math.min(doc.getLength(), start + 100);
+ bound = Math.min(doc.getLength(), start + 100);
}
- int comma= scanner.scanForward(start, bound, ',');
+ int comma = scanner.scanForward(start, bound, ',');
if (comma == CHeuristicScanner.NOT_FOUND) {
// last argument
- sourceEnd= bound;
+ sourceEnd = bound;
} else {
- sourceEnd= comma;
+ sourceEnd = comma;
// expand region to include whole line if rest is comment
- IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
- int lineEnd= lineRegion.getOffset() + lineRegion.getLength();
- int nextNonWS= scanner.findNonWhitespaceForwardInAnyPartition(sourceEnd + 1, lineEnd);
+ IRegion lineRegion = doc.getLineInformationOfOffset(sourceEnd);
+ int lineEnd = lineRegion.getOffset() + lineRegion.getLength();
+ int nextNonWS = scanner.findNonWhitespaceForwardInAnyPartition(sourceEnd + 1, lineEnd);
if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
- String contentType= TextUtilities.getContentType(doc, ICPartitions.C_PARTITIONING, nextNonWS, false);
- if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType) || ICPartitions.C_SINGLE_LINE_COMMENT.equals(contentType)) {
- sourceEnd= lineEnd;
+ String contentType = TextUtilities.getContentType(doc, ICPartitions.C_PARTITIONING, nextNonWS,
+ false);
+ if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType)
+ || ICPartitions.C_SINGLE_LINE_COMMENT.equals(contentType)) {
+ sourceEnd = lineEnd;
}
}
}
@@ -654,7 +670,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
/**
* Search for definitions for the given binding.
- *
+ *
* @param ast the AST of the translation unit
* @param binding the binding
* @return an array of definitions, never {@code null}
@@ -664,27 +680,29 @@ public class CSourceHover extends AbstractCEditorTextHover {
if (binding instanceof ICPPAliasTemplateInstance) {
binding = ((ICPPAliasTemplateInstance) binding).getTemplateDefinition();
}
- IName[] declNames= ast.getDefinitionsInAST(binding);
+ IName[] declNames = ast.getDefinitionsInAST(binding);
if (declNames.length == 0 && ast.getIndex() != null) {
// search definitions in index
- declNames = ast.getIndex().findNames(binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ declNames = ast.getIndex().findNames(binding,
+ IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
}
return declNames;
}
/**
* Search for declarations for the given binding.
- *
+ *
* @param ast the AST of the translation unit
* @param binding the binding
* @return an array of declarations, never {@code null}
* @throws CoreException
*/
private IName[] findDeclarations(IASTTranslationUnit ast, IBinding binding) throws CoreException {
- IName[] declNames= ast.getDeclarationsInAST(binding);
+ IName[] declNames = ast.getDeclarationsInAST(binding);
if (declNames.length == 0 && ast.getIndex() != null) {
// search declarations in index
- declNames= ast.getIndex().findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ declNames = ast.getIndex().findNames(binding,
+ IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
}
return declNames;
}
@@ -698,7 +716,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
}
/**
- *
+ *
*/
public CSourceHover() {
super();
@@ -708,8 +726,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
IEditorPart editor = getEditor();
if (editor != null) {
- IEditorInput input= editor.getEditorInput();
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
+ IEditorInput input = editor.getEditorInput();
+ IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
IWorkingCopy workingCopy = manager.getWorkingCopy(input);
try {
if (workingCopy == null || !workingCopy.isConsistent()) {
@@ -718,7 +736,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
} catch (CModelException e) {
return null;
}
-
+
String expression;
try {
expression = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
@@ -732,19 +750,19 @@ public class CSourceHover extends AbstractCEditorTextHover {
return null;
// Try with the indexer.
- String source= searchInIndex(workingCopy, hoverRegion, expression);
+ String source = searchInIndex(workingCopy, hoverRegion, expression);
if (source == null || source.trim().isEmpty())
return null;
// We are actually interested in the comments, too.
-// source= removeLeadingComments(source);
+ // source= removeLeadingComments(source);
- String delim= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ String delim = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- String[] sourceLines= Strings.convertIntoLines(source);
- String firstLine= sourceLines[0];
- boolean ignoreFirstLine= firstLine.length() > 0 && !Character.isWhitespace(firstLine.charAt(0));
+ String[] sourceLines = Strings.convertIntoLines(source);
+ String firstLine = sourceLines[0];
+ boolean ignoreFirstLine = firstLine.length() > 0 && !Character.isWhitespace(firstLine.charAt(0));
Strings.trimIndentation(sourceLines, getTabWidth(), getTabWidth(), !ignoreFirstLine);
source = Strings.concatenate(sourceLines, delim);
@@ -759,42 +777,42 @@ public class CSourceHover extends AbstractCEditorTextHover {
* Searches the start of the comment preceding the given source offset.
* Continuous line comments are considered as one comment until a block
* comment is reached or a non-comment partition.
- *
+ *
* @param doc the document
* @param start the start of the backward search
* @param bound search boundary (exclusive)
* @return the comment start offset or {@code -1}, if no suitable comment was found
- * @throws BadLocationException
+ * @throws BadLocationException
*/
private static int searchCommentBackward(IDocument doc, int start, int bound) throws BadLocationException {
- int firstLine= doc.getLineOfOffset(start);
+ int firstLine = doc.getLineOfOffset(start);
if (firstLine == 0) {
return 0;
}
- ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, start, true);
- int currentOffset= Math.max(doc.getLineOffset(firstLine - 1), partition.getOffset() - 1);
- int commentOffset= -1;
+ ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, start, true);
+ int currentOffset = Math.max(doc.getLineOffset(firstLine - 1), partition.getOffset() - 1);
+ int commentOffset = -1;
while (currentOffset > bound) {
- partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, currentOffset, true);
- currentOffset= partition.getOffset() - 1;
- if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType())
+ partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, currentOffset, true);
+ currentOffset = partition.getOffset() - 1;
+ if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType())
|| ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
- final int partitionOffset= partition.getOffset();
- final int startLine= doc.getLineOfOffset(partitionOffset);
- final int lineOffset= doc.getLineOffset(startLine);
- if (partitionOffset == lineOffset ||
- doc.get(lineOffset, partitionOffset - lineOffset).trim().isEmpty()) {
+ final int partitionOffset = partition.getOffset();
+ final int startLine = doc.getLineOfOffset(partitionOffset);
+ final int lineOffset = doc.getLineOffset(startLine);
+ if (partitionOffset == lineOffset
+ || doc.get(lineOffset, partitionOffset - lineOffset).trim().isEmpty()) {
return lineOffset;
}
return commentOffset;
} else if (ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType())
|| ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(partition.getType())) {
- final int partitionOffset= partition.getOffset();
- final int startLine= doc.getLineOfOffset(partitionOffset);
- final int lineOffset= doc.getLineOffset(startLine);
- if (partitionOffset == lineOffset ||
- doc.get(lineOffset, partitionOffset - lineOffset).trim().isEmpty()) {
- commentOffset= lineOffset;
+ final int partitionOffset = partition.getOffset();
+ final int startLine = doc.getLineOfOffset(partitionOffset);
+ final int lineOffset = doc.getLineOffset(startLine);
+ if (partitionOffset == lineOffset
+ || doc.get(lineOffset, partitionOffset - lineOffset).trim().isEmpty()) {
+ commentOffset = lineOffset;
continue;
}
return commentOffset;
@@ -818,24 +836,24 @@ public class CSourceHover extends AbstractCEditorTextHover {
/**
* Strip the leading comment from the given source string.
- *
+ *
* @param source
* @return the source string without leading comments
*/
protected static String removeLeadingComments(String source) {
- CCodeReader reader= new CCodeReader();
- IDocument document= new Document(source);
+ CCodeReader reader = new CCodeReader();
+ IDocument document = new Document(source);
int i;
try {
reader.configureForwardReader(document, 0, document.getLength(), true, false);
- int c= reader.read();
+ int c = reader.read();
while (c != -1 && (c == '\r' || c == '\n')) {
- c= reader.read();
+ c = reader.read();
}
- i= reader.getOffset();
+ i = reader.getOffset();
reader.close();
} catch (IOException e) {
- i= 0;
+ i = 0;
} finally {
try {
reader.close();
@@ -850,13 +868,13 @@ public class CSourceHover extends AbstractCEditorTextHover {
}
protected String searchInIndex(final ITranslationUnit tUnit, IRegion textRegion, String selection) {
- final ComputeSourceRunnable computer= new ComputeSourceRunnable(tUnit, textRegion, selection);
- Job job= new Job(CHoverMessages.CSourceHover_jobTitle) {
+ final ComputeSourceRunnable computer = new ComputeSourceRunnable(tUnit, textRegion, selection);
+ Job job = new Job(CHoverMessages.CSourceHover_jobTitle) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- return ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_ACTIVE_ONLY,
- monitor, computer);
+ return ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor,
+ computer);
} catch (Throwable t) {
CUIPlugin.log(t);
}
@@ -881,13 +899,13 @@ public class CSourceHover extends AbstractCEditorTextHover {
/**
* Checks whether the given name is a known keyword.
- *
+ *
* @param name
* @return {@code true} if the name is a known keyword or {@code false} if the
* name is not considered a keyword
*/
private boolean selectionIsKeyword(String name) {
- Set<String> keywords= ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
+ Set<String> keywords = ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
return keywords.contains(name);
}
@@ -896,12 +914,11 @@ public class CSourceHover extends AbstractCEditorTextHover {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
- IEditorPart editor= getEditor();
- int orientation= SWT.NONE;
+ IEditorPart editor = getEditor();
+ int orientation = SWT.NONE;
if (editor instanceof IWorkbenchPartOrientation)
- orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
- return new SourceViewerInformationControl(parent, false, orientation,
- getTooltipAffordanceString());
+ orientation = ((IWorkbenchPartOrientation) editor).getOrientation();
+ return new SourceViewerInformationControl(parent, false, orientation, getTooltipAffordanceString());
}
};
}
@@ -911,10 +928,10 @@ public class CSourceHover extends AbstractCEditorTextHover {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
- IEditorPart editor= getEditor();
- int orientation= SWT.NONE;
+ IEditorPart editor = getEditor();
+ int orientation = SWT.NONE;
if (editor instanceof IWorkbenchPartOrientation)
- orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
+ orientation = ((IWorkbenchPartOrientation) editor).getOrientation();
return new SourceViewerInformationControl(parent, true, orientation, null);
}
};
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.java
index 8b76499fddc..4032bba4961 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.java
@@ -29,7 +29,8 @@ import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
* Aggregator of problem and doc hovers.
* @since 5.0
*/
-public class CTypeHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2, IInformationProviderExtension2 {
+public class CTypeHover
+ implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2, IInformationProviderExtension2 {
private AbstractCEditorTextHover fProblemHover;
private AbstractCEditorTextHover fCDocHover;
private AbstractCEditorTextHover fBestMatchHover;
@@ -37,9 +38,9 @@ public class CTypeHover implements ICEditorTextHover, ITextHoverExtension, IText
private AbstractCEditorTextHover fCurrentHover;
public CTypeHover() {
- fProblemHover= new ProblemHover();
- fCDocHover= new CDocHover();
- fCurrentHover= null;
+ fProblemHover = new ProblemHover();
+ fCDocHover = new CDocHover();
+ fCurrentHover = null;
fBestMatchHover = new BestMatchHover();
}
@@ -51,7 +52,7 @@ public class CTypeHover implements ICEditorTextHover, ITextHoverExtension, IText
fProblemHover.setEditor(editor);
fCDocHover.setEditor(editor);
fBestMatchHover.setEditor(editor);
- fCurrentHover= null;
+ fCurrentHover = null;
}
/*
@@ -67,7 +68,7 @@ public class CTypeHover implements ICEditorTextHover, ITextHoverExtension, IText
*/
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
- Object info= getHoverInfo2(textViewer, hoverRegion);
+ Object info = getHoverInfo2(textViewer, hoverRegion);
if (info != null) {
return String.valueOf(info);
}
@@ -79,22 +80,22 @@ public class CTypeHover implements ICEditorTextHover, ITextHoverExtension, IText
*/
@Override
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
- Object hoverInfo= fProblemHover.getHoverInfo2(textViewer, hoverRegion);
+ Object hoverInfo = fProblemHover.getHoverInfo2(textViewer, hoverRegion);
if (hoverInfo != null) {
- fCurrentHover= fProblemHover;
+ fCurrentHover = fProblemHover;
return hoverInfo;
}
hoverInfo = fCDocHover.getHoverInfo2(textViewer, hoverRegion);
- if(hoverInfo != null){
- fCurrentHover= fCDocHover;
+ if (hoverInfo != null) {
+ fCurrentHover = fCDocHover;
}
-
+
hoverInfo = fBestMatchHover.getHoverInfo(textViewer, hoverRegion);
- if(hoverInfo != null){
+ if (hoverInfo != null) {
fCurrentHover = fBestMatchHover;
}
-
+
return hoverInfo;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.java
index 4ff14fe6b38..9a0679f7fe0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.java
@@ -54,7 +54,7 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
public class ProblemHover extends AbstractAnnotationHover {
protected static class ProblemInfo extends AnnotationInfo {
- private static final ICompletionProposal[] NO_PROPOSALS= new ICompletionProposal[0];
+ private static final ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];
public ProblemInfo(Annotation annotation, Position position, ITextViewer textViewer) {
super(annotation, position, textViewer);
@@ -75,18 +75,19 @@ public class ProblemHover extends AbstractAnnotationHover {
}
private ICompletionProposal[] getCAnnotationFixes(ICAnnotation cAnnotation) {
- ProblemLocation location= new ProblemLocation(position.getOffset(), position.getLength(), cAnnotation);
- ITranslationUnit tu= cAnnotation.getTranslationUnit();
+ ProblemLocation location = new ProblemLocation(position.getOffset(), position.getLength(), cAnnotation);
+ ITranslationUnit tu = cAnnotation.getTranslationUnit();
- ISourceViewer sourceViewer= null;
+ ISourceViewer sourceViewer = null;
if (viewer instanceof ISourceViewer)
- sourceViewer= (ISourceViewer) viewer;
+ sourceViewer = (ISourceViewer) viewer;
- CorrectionContext context= new CorrectionContext(tu, sourceViewer, location.getOffset(), location.getLength());
+ CorrectionContext context = new CorrectionContext(tu, sourceViewer, location.getOffset(),
+ location.getLength());
if (!SpellingAnnotation.TYPE.equals(cAnnotation.getType()))
return NO_PROPOSALS;
- List<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>();
+ List<ICCompletionProposal> proposals = new ArrayList<ICCompletionProposal>();
CCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { location }, proposals);
Collections.sort(proposals, new CCompletionProposalComparator());
@@ -97,7 +98,7 @@ public class ProblemHover extends AbstractAnnotationHover {
if (markerAnnotation.isQuickFixableStateSet() && !markerAnnotation.isQuickFixable())
return NO_PROPOSALS;
- IMarker marker= markerAnnotation.getMarker();
+ IMarker marker = markerAnnotation.getMarker();
IEditorInput input = null;
try {
@@ -107,22 +108,24 @@ public class ProblemHover extends AbstractAnnotationHover {
if (input == null)
return NO_PROPOSALS;
- ITranslationUnit tu= getTranslationUnit(input);
+ ITranslationUnit tu = getTranslationUnit(input);
if (tu == null)
return NO_PROPOSALS;
- IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(input);
+ IAnnotationModel model = CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(input);
if (model == null)
return NO_PROPOSALS;
-
- ISourceViewer sourceViewer= null;
+
+ ISourceViewer sourceViewer = null;
if (viewer instanceof ISourceViewer)
- sourceViewer= (ISourceViewer) viewer;
+ sourceViewer = (ISourceViewer) viewer;
- CorrectionContext context= new CorrectionContext(tu, sourceViewer, position.getOffset(), position.getLength());
+ CorrectionContext context = new CorrectionContext(tu, sourceViewer, position.getOffset(),
+ position.getLength());
- List<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>();
- CCorrectionProcessor.collectProposals(context, model, new Annotation[] { markerAnnotation }, true, false, proposals);
+ List<ICCompletionProposal> proposals = new ArrayList<ICCompletionProposal>();
+ CCorrectionProcessor.collectProposals(context, model, new Annotation[] { markerAnnotation }, true, false,
+ proposals);
return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java
index 2dbbffcad27..94714b9fec0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java
@@ -66,7 +66,8 @@ import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
* Displays information in a source viewer.
*
*/
-public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension5, DisposeListener {
+public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension,
+ IInformationControlExtension3, IInformationControlExtension5, DisposeListener {
/** The control's shell */
private Shell fShell;
@@ -102,12 +103,12 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
* The width size constraint.
* @since 4.0
*/
- private int fMaxWidth= SWT.DEFAULT;
+ private int fMaxWidth = SWT.DEFAULT;
/**
* The height size constraint.
* @since 4.0
*/
- private int fMaxHeight= SWT.DEFAULT;
+ private int fMaxHeight = SWT.DEFAULT;
/**
* The orientation of the shell
* @since 3.4
@@ -115,7 +116,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
private final int fOrientation;
private Color fBackgroundColor;
- private boolean fIsSystemBackgroundColor= true;
+ private boolean fIsSystemBackgroundColor = true;
/**
* Creates a source viewer information control with the given shell as parent. The given
@@ -130,49 +131,50 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
*/
public SourceViewerInformationControl(Shell parent, boolean isResizable, int orientation, String statusFieldText) {
Assert.isLegal(orientation == SWT.RIGHT_TO_LEFT || orientation == SWT.LEFT_TO_RIGHT || orientation == SWT.NONE);
- fOrientation= orientation;
-
+ fOrientation = orientation;
+
GridLayout layout;
GridData gd;
- int shellStyle= SWT.TOOL | SWT.ON_TOP | orientation | (isResizable ? SWT.RESIZE : 0);
- int textStyle= isResizable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE;
+ int shellStyle = SWT.TOOL | SWT.ON_TOP | orientation | (isResizable ? SWT.RESIZE : 0);
+ int textStyle = isResizable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE;
- fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
- Display display= fShell.getDisplay();
+ fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
+ Display display = fShell.getDisplay();
initializeColors();
- Composite composite= fShell;
- layout= new GridLayout(1, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ Composite composite = fShell;
+ layout = new GridLayout(1, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
composite.setLayout(layout);
- gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
composite.setLayoutData(gd);
if (statusFieldText != null) {
- composite= new Composite(composite, SWT.NONE);
- layout= new GridLayout(1, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.verticalSpacing= 1;
+ composite = new Composite(composite, SWT.NONE);
+ layout = new GridLayout(1, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 1;
composite.setLayout(layout);
- gd= new GridData(GridData.FILL_BOTH);
+ gd = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(gd);
composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
composite.setBackground(fBackgroundColor);
}
// Source viewer
- IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
- fViewer= new CSourceViewer(composite, null, null, false, textStyle, store);
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
+ IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ fViewer = new CSourceViewer(composite, null, null, false, textStyle, store);
+ CTextTools tools = CUIPlugin.getDefault().getTextTools();
+ fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null,
+ ICPartitions.C_PARTITIONING, false));
fViewer.setEditable(false);
- fText= fViewer.getTextWidget();
- gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
+ fText = fViewer.getTextWidget();
+ gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
fText.setLayoutData(gd);
fText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
fText.setBackground(fBackgroundColor);
@@ -182,36 +184,38 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
fText.addKeyListener(new KeyListener() {
@Override
- public void keyPressed(KeyEvent e) {
+ public void keyPressed(KeyEvent e) {
if (e.character == 0x1B) // ESC
fShell.dispose();
}
@Override
- public void keyReleased(KeyEvent e) {}
+ public void keyReleased(KeyEvent e) {
+ }
});
// Status field
if (statusFieldText != null) {
// Horizontal separator line
- fSeparator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
+ fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Status field label
- fStatusField= new Label(composite, SWT.RIGHT);
+ fStatusField = new Label(composite, SWT.RIGHT);
fStatusField.setText(statusFieldText);
- Font font= fStatusField.getFont();
- FontData[] fontDatas= font.getFontData();
+ Font font = fStatusField.getFont();
+ FontData[] fontDatas = font.getFontData();
for (FontData fontData : fontDatas)
fontData.setHeight(fontData.getHeight() * 9 / 10);
- fStatusTextFont= new Font(fStatusField.getDisplay(), fontDatas);
+ fStatusTextFont = new Font(fStatusField.getDisplay(), fontDatas);
fStatusField.setFont(fStatusTextFont);
- GridData gd2= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ GridData gd2 = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
fStatusField.setLayoutData(gd2);
- RGB defaultColor= CDTUITools.getColorManager().getColor(ICColorConstants.C_DEFAULT).getRGB();
- fStatusTextForegroundColor= new Color(fStatusField.getDisplay(), blend(fBackgroundColor.getRGB(), defaultColor, 0.56f));
+ RGB defaultColor = CDTUITools.getColorManager().getColor(ICColorConstants.C_DEFAULT).getRGB();
+ fStatusTextForegroundColor = new Color(fStatusField.getDisplay(),
+ blend(fBackgroundColor.getRGB(), defaultColor, 0.56f));
fStatusField.setForeground(fStatusTextForegroundColor);
fStatusField.setBackground(fBackgroundColor);
}
@@ -235,50 +239,48 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
Assert.isLegal(bg != null);
Assert.isLegal(fg != null);
Assert.isLegal(factor >= 0f && factor <= 1f);
-
- float complement= 1f - factor;
- return new RGB(
- (int) (complement * bg.red + factor * fg.red),
- (int) (complement * bg.green + factor * fg.green),
- (int) (complement * bg.blue + factor * fg.blue)
- );
- }
-
+
+ float complement = 1f - factor;
+ return new RGB((int) (complement * bg.red + factor * fg.red), (int) (complement * bg.green + factor * fg.green),
+ (int) (complement * bg.blue + factor * fg.blue));
+ }
+
private void initializeColors() {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
RGB bgRGB;
if (store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
- bgRGB= getVisibleBackgroundColor(fShell.getDisplay());
+ bgRGB = getVisibleBackgroundColor(fShell.getDisplay());
} else {
- bgRGB= PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
+ bgRGB = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
}
if (bgRGB != null) {
- fBackgroundColor= new Color(fShell.getDisplay(), bgRGB);
- fIsSystemBackgroundColor= false;
+ fBackgroundColor = new Color(fShell.getDisplay(), bgRGB);
+ fIsSystemBackgroundColor = false;
} else {
- fBackgroundColor= fShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- fIsSystemBackgroundColor= true;
+ fBackgroundColor = fShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ fIsSystemBackgroundColor = true;
}
}
/**
* Returns <code>null</code> if {@link SWT#COLOR_INFO_BACKGROUND} is visibly distinct from the
* default source text color. Otherwise, returns the editor background color.
- *
+ *
* @param display the display
* @return an RGB or <code>null</code>
*/
public static RGB getVisibleBackgroundColor(Display display) {
- float[] infoBgHSB= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB().getHSB();
-
- Color defaultColor= CDTUITools.getColorManager().getColor(ICColorConstants.C_DEFAULT);
- RGB defaultRGB= defaultColor != null ? defaultColor.getRGB() : new RGB(255, 255, 255);
- float[] defaultHSB= defaultRGB.getHSB();
-
+ float[] infoBgHSB = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB().getHSB();
+
+ Color defaultColor = CDTUITools.getColorManager().getColor(ICColorConstants.C_DEFAULT);
+ RGB defaultRGB = defaultColor != null ? defaultColor.getRGB() : new RGB(255, 255, 255);
+ float[] defaultHSB = defaultRGB.getHSB();
+
if (Math.abs(infoBgHSB[2] - defaultHSB[2]) < 0.5f) {
// workaround for dark tooltip background color, see https://bugs.eclipse.org/365051
- IPreferenceStore preferenceStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
- boolean useDefault= preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+ IPreferenceStore preferenceStore = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ boolean useDefault = preferenceStore
+ .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
if (useDefault)
return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
return PreferenceConverter.getColor(preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
@@ -292,8 +294,8 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
* @since 4.0
*/
private void initializeFont() {
- fTextFont= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
- StyledText styledText= getViewer().getTextWidget();
+ fTextFont = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+ StyledText styledText = getViewer().getTextWidget();
styledText.setFont(fTextFont);
}
@@ -302,7 +304,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
*/
public void setInput(Object input) {
if (input instanceof String)
- setInformation((String)input);
+ setInformation((String) input);
else
setInformation(null);
}
@@ -317,7 +319,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
return;
}
- IDocument doc= new Document(content);
+ IDocument doc = new Document(content);
CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
fViewer.setInput(doc);
}
@@ -341,12 +343,12 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
if (fStatusTextForegroundColor != null && !fStatusTextForegroundColor.isDisposed())
fStatusTextForegroundColor.dispose();
-
- fStatusTextForegroundColor= null;
- fStatusTextFont= null;
- fTextFont= null;
- fShell= null;
- fText= null;
+
+ fStatusTextForegroundColor = null;
+ fStatusTextFont = null;
+ fTextFont = null;
+ fShell = null;
+ fText = null;
}
/**
@@ -383,8 +385,8 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
*/
@Override
public void setSizeConstraints(int maxWidth, int maxHeight) {
- fMaxWidth= maxWidth;
- fMaxHeight= maxHeight;
+ fMaxWidth = maxWidth;
+ fMaxHeight = maxHeight;
}
/*
@@ -393,17 +395,17 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
@Override
public Point computeSizeHint() {
// compute the preferred size
- int x= SWT.DEFAULT;
- int y= SWT.DEFAULT;
- Point size= fShell.computeSize(x, y);
+ int x = SWT.DEFAULT;
+ int y = SWT.DEFAULT;
+ Point size = fShell.computeSize(x, y);
if (size.x > fMaxWidth)
- x= fMaxWidth;
+ x = fMaxWidth;
if (size.y > fMaxHeight)
- y= fMaxHeight;
+ y = fMaxHeight;
// recompute using the constraints if the preferred size is larger than the constraints
if (x != SWT.DEFAULT || y != SWT.DEFAULT)
- size= fShell.computeSize(x, y, false);
+ size = fShell.computeSize(x, y, false);
return size;
}
@@ -481,7 +483,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
return fText.getCharCount() > 0;
}
- protected ISourceViewer getViewer() {
+ protected ISourceViewer getViewer() {
return fViewer;
}
@@ -491,28 +493,28 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
*/
@Override
public Rectangle computeTrim() {
- Rectangle trim= fShell.computeTrim(0, 0, 0, 0);
+ Rectangle trim = fShell.computeTrim(0, 0, 0, 0);
addInternalTrim(trim);
return trim;
}
/**
* Adds the internal trimmings to the given trim of the shell.
- *
+ *
* @param trim the shell's trim, will be updated
* @since 5.0
*/
private void addInternalTrim(Rectangle trim) {
- Rectangle textTrim= fText.computeTrim(0, 0, 0, 0);
- trim.x+= textTrim.x;
- trim.y+= textTrim.y;
- trim.width+= textTrim.width;
- trim.height+= textTrim.height;
-
+ Rectangle textTrim = fText.computeTrim(0, 0, 0, 0);
+ trim.x += textTrim.x;
+ trim.y += textTrim.y;
+ trim.width += textTrim.width;
+ trim.height += textTrim.height;
+
if (fStatusField != null) {
- trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
- trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
- trim.height+= 1; // verticalSpacing
+ trim.height += fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+ trim.height += fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+ trim.height += 1; // verticalSpacing
}
}
@@ -568,7 +570,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
return true;
if (control instanceof Shell)
return false;
- control= control.getParent();
+ control = control.getParent();
} while (control != null);
return false;
}
@@ -581,16 +583,16 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
public boolean isVisible() {
return fShell != null && !fShell.isDisposed() && fShell.isVisible();
}
-
+
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#computeSizeConstraints(int, int)
*/
@Override
public Point computeSizeConstraints(int widthInChars, int heightInChars) {
- GC gc= new GC(fText);
+ GC gc = new GC(fText);
gc.setFont(fTextFont);
- int width= gc.getFontMetrics().getAverageCharWidth();
- int height= gc.getFontMetrics().getHeight();
+ int width = gc.getFontMetrics().getAverageCharWidth();
+ int height = gc.getFontMetrics().getHeight();
gc.dispose();
return new Point(widthInChars * width, heightInChars * height);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
index f2ebd9c60a9..11082d8d419 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Rational Software - Initial API and implementation
* Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
@@ -58,10 +58,10 @@ import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
import org.eclipse.cdt.internal.ui.text.CTextTools;
-
-public class CCompletionProposal implements ICCompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3 {
+public class CCompletionProposal implements ICCompletionProposal, ICompletionProposalExtension,
+ ICompletionProposalExtension2, ICompletionProposalExtension3 {
private String fDisplayString;
- private String fIdString;
+ private String fIdString;
private String fReplacementString;
private int fReplacementOffset;
private int fReplacementLength;
@@ -72,8 +72,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
private String fProposalInfo;
private char[] fTriggerCharacters;
protected boolean fToggleEating;
- protected ITextViewer fTextViewer;
-
+ protected ITextViewer fTextViewer;
+
private int fRelevance;
private StyleRange fRememberedStyleRange;
@@ -87,85 +87,88 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* @param displayString the string to be displayed for the proposal
* If set to {@code null}, the replacement string will be taken as display string.
*/
- public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance) {
- this(replacementString, replacementOffset, replacementLength, image, displayString, null, relevance, null);
- }
-
- /**
- * 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
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal
- * @param viewer the text viewer for which this proposal is computed, may be {@code null}
- * If set to {@code null}, the replacement string will be taken as display string.
- */
- public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance, ITextViewer viewer) {
- this(replacementString, replacementOffset, replacementLength, image, displayString, null, relevance, viewer);
- }
-
- /**
- * 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
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal
- * @param idString the string to be uniquely identify this proposal
- * @param viewer the text viewer for which this proposal is computed, may be {@code null}
- * If set to {@code null}, the replacement string will be taken as display string.
- */
- public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, String idString, int relevance, ITextViewer viewer) {
- Assert.isNotNull(replacementString);
+ public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image,
+ String displayString, int relevance) {
+ this(replacementString, replacementOffset, replacementLength, image, displayString, null, relevance, null);
+ }
+
+ /**
+ * 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
+ * @param replacementOffset the offset of the text to be replaced
+ * @param replacementLength the length of the text to be replaced
+ * @param image the image to display for this proposal
+ * @param displayString the string to be displayed for the proposal
+ * @param viewer the text viewer for which this proposal is computed, may be {@code null}
+ * If set to {@code null}, the replacement string will be taken as display string.
+ */
+ public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image,
+ String displayString, int relevance, ITextViewer viewer) {
+ this(replacementString, replacementOffset, replacementLength, image, displayString, null, relevance, viewer);
+ }
+
+ /**
+ * 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
+ * @param replacementOffset the offset of the text to be replaced
+ * @param replacementLength the length of the text to be replaced
+ * @param image the image to display for this proposal
+ * @param displayString the string to be displayed for the proposal
+ * @param idString the string to be uniquely identify this proposal
+ * @param viewer the text viewer for which this proposal is computed, may be {@code null}
+ * If set to {@code null}, the replacement string will be taken as display string.
+ */
+ public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image,
+ String displayString, String idString, int relevance, ITextViewer viewer) {
+ Assert.isNotNull(replacementString);
Assert.isTrue(replacementOffset >= 0);
Assert.isTrue(replacementLength >= 0);
-
+
fReplacementString = replacementString;
fReplacementOffset = replacementOffset;
fReplacementLength = replacementLength;
fImage = image;
- fRelevance = relevance;
- fTextViewer = viewer;
-
+ fRelevance = relevance;
+ fTextViewer = viewer;
+
fDisplayString = displayString != null ? displayString : replacementString;
- fIdString = idString != null ? idString : displayString;
+ fIdString = idString != null ? idString : displayString;
fCursorPosition = replacementString.length();
-
+
fContextInformation = null;
fContextInformationPosition = -1;
fTriggerCharacters = null;
fProposalInfo = null;
}
-
+
/**
* Sets the context information.
* @param contextInformation The context information associated with this proposal
*/
public void setContextInformation(IContextInformation contextInformation) {
- fContextInformation= contextInformation;
- fContextInformationPosition= (fContextInformation != null ? fCursorPosition : -1);
+ fContextInformation = contextInformation;
+ fContextInformationPosition = (fContextInformation != null ? fCursorPosition : -1);
}
-
+
/**
* Sets the trigger characters.
* @param triggerCharacters The set of characters which can trigger the application of this completion proposal
*/
public void setTriggerCharacters(char[] triggerCharacters) {
- fTriggerCharacters= triggerCharacters;
+ fTriggerCharacters = triggerCharacters;
}
-
+
/**
* Sets the proposal info.
* @param proposalInfo The additional information associated with this proposal or {@code null}
*/
public void setAdditionalProposalInfo(String proposalInfo) {
- fProposalInfo= proposalInfo;
+ fProposalInfo = proposalInfo;
}
-
+
/**
* Sets the cursor position relative to the insertion offset. By default this is the length of the completion string
* (Cursor positioned after the completion)
@@ -173,45 +176,46 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
*/
public void setCursorPosition(int cursorPosition) {
Assert.isTrue(cursorPosition >= 0);
- fCursorPosition= cursorPosition;
- fContextInformationPosition= fContextInformation != null ? fCursorPosition : -1;
+ fCursorPosition = cursorPosition;
+ fContextInformationPosition = fContextInformation != null ? fCursorPosition : -1;
}
-
+
@Override
public void apply(IDocument document, char trigger, int offset) {
try {
// patch replacement length
- int delta= offset - (fReplacementOffset + fReplacementLength);
+ int delta = offset - (fReplacementOffset + fReplacementLength);
if (delta > 0)
fReplacementLength += delta;
-
+
String string;
if (trigger == (char) 0) {
- string= fReplacementString;
+ string = fReplacementString;
} else {
- StringBuilder buffer= new StringBuilder(fReplacementString);
+ StringBuilder buffer = new StringBuilder(fReplacementString);
// fix for PR #5533. Assumes that no eating takes place.
- if ((fCursorPosition > 0 && fCursorPosition <= buffer.length() && buffer.charAt(fCursorPosition - 1) != trigger)) {
+ if ((fCursorPosition > 0 && fCursorPosition <= buffer.length()
+ && buffer.charAt(fCursorPosition - 1) != trigger)) {
buffer.insert(fCursorPosition, trigger);
++fCursorPosition;
}
-
- string= buffer.toString();
+
+ string = buffer.toString();
}
// reference position just at the end of the document change.
- int referenceOffset= fReplacementOffset + fReplacementLength;
- final ReferenceTracker referenceTracker= new ReferenceTracker();
+ int referenceOffset = fReplacementOffset + fReplacementLength;
+ final ReferenceTracker referenceTracker = new ReferenceTracker();
referenceTracker.preReplace(document, referenceOffset);
replace(document, fReplacementOffset, fReplacementLength, string);
- referenceOffset= referenceTracker.postReplace(document);
- fReplacementOffset= referenceOffset - (string == null ? 0 : string.length());
+ referenceOffset = referenceTracker.postReplace(document);
+ fReplacementOffset = referenceOffset - (string == null ? 0 : string.length());
if (fTextViewer != null && string != null) {
- int index= string.indexOf("()"); //$NON-NLS-1$
+ int index = string.indexOf("()"); //$NON-NLS-1$
if (index != -1 && index + 1 == fCursorPosition) {
addParameterListLinkedMode(document, ')');
}
@@ -222,20 +226,20 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
} catch (BadLocationException x) {
// Ignore
- }
+ }
}
private void addParameterListLinkedMode(IDocument document, char endSymbol) throws BadLocationException {
- int newOffset= fReplacementOffset + fCursorPosition;
-
- LinkedPositionGroup group= new LinkedPositionGroup();
+ int newOffset = fReplacementOffset + fCursorPosition;
+
+ LinkedPositionGroup group = new LinkedPositionGroup();
group.addPosition(new LinkedPosition(document, newOffset, 0, LinkedPositionGroup.NO_STOP));
-
- LinkedModeModel model= new LinkedModeModel();
+
+ LinkedModeModel model = new LinkedModeModel();
model.addGroup(group);
model.forceInstall();
-
- LinkedModeUI ui= new EditorLinkedModeUI(model, fTextViewer);
+
+ LinkedModeUI ui = new EditorLinkedModeUI(model, fTextViewer);
ui.setSimpleMode(true);
ui.setExitPolicy(new ExitPolicy(endSymbol));
ui.setExitPosition(fTextViewer, newOffset + 1, 0, Integer.MAX_VALUE);
@@ -244,19 +248,19 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
/**
- * A class to simplify tracking a reference position in a document.
+ * A class to simplify tracking a reference position in a document.
*/
private static final class ReferenceTracker {
/** The reference position category name. */
- private static final String CATEGORY= "reference_position"; //$NON-NLS-1$
+ private static final String CATEGORY = "reference_position"; //$NON-NLS-1$
/** The position updater of the reference position. */
- private final IPositionUpdater fPositionUpdater= new DefaultPositionUpdater(CATEGORY);
+ private final IPositionUpdater fPositionUpdater = new DefaultPositionUpdater(CATEGORY);
/** The reference position. */
- private final Position fPosition= new Position(0);
-
+ private final Position fPosition = new Position(0);
+
/**
* Called before document changes occur. It must be followed by a call to postReplace().
- *
+ *
* @param document the document on which to track the reference position.
*/
public void preReplace(IDocument document, int offset) throws BadLocationException {
@@ -270,10 +274,10 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
CUIPlugin.log(e);
}
}
-
+
/**
* Called after the document changed occured. It must be preceded by a call to preReplace().
- *
+ *
* @param document the document on which to track the reference position.
*/
public int postReplace(IDocument document) {
@@ -287,13 +291,13 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
return fPosition.getOffset();
}
- }
-
+ }
+
protected static class ExitPolicy implements IExitPolicy {
final char fExitCharacter;
-
+
public ExitPolicy(char exitCharacter) {
- fExitCharacter= exitCharacter;
+ fExitCharacter = exitCharacter;
}
@Override
@@ -301,20 +305,20 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
if (event.character == fExitCharacter) {
if (environment.anyPositionContains(offset))
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
-
+
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
- }
-
- switch (event.character) {
+ }
+
+ switch (event.character) {
case ';':
return new ExitFlags(ILinkedModeListener.NONE, true);
-
+
default:
return null;
- }
+ }
}
- }
-
+ }
+
// #6410 - File unchanged but dirtied by code assist
private void replace(IDocument document, int offset, int length, String string) throws BadLocationException {
if (!document.get(offset, length).equals(string))
@@ -328,7 +332,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
public void apply(IDocument document) {
apply(document, (char) 0, fReplacementOffset + fReplacementLength);
}
-
+
@Override
public Point getSelection(IDocument document) {
return new Point(fReplacementOffset + fCursorPosition, 0);
@@ -349,16 +353,16 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
return fDisplayString;
}
- /**
- * This method is used by the comparator to compare proposals. It ignores the return type of a function.
- *
- * @return the string representing the display name without the return type (if any).
- */
- @Override
+ /**
+ * This method is used by the comparator to compare proposals. It ignores the return type of a function.
+ *
+ * @return the string representing the display name without the return type (if any).
+ */
+ @Override
public String getIdString() {
- return fIdString;
- }
-
+ return fIdString;
+ }
+
@Override
public String getAdditionalProposalInfo() {
if (fProposalInfo != null) {
@@ -366,7 +370,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
return null;
}
-
+
@Override
public char[] getTriggerCharacters() {
return fTriggerCharacters;
@@ -376,7 +380,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
public int getContextInformationPosition() {
return fReplacementOffset + fContextInformationPosition;
}
-
+
/**
* Gets the replacement offset.
* @return Returns a int
@@ -384,7 +388,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
public int getReplacementOffset() {
return fReplacementOffset;
}
-
+
@Override
public int getPrefixCompletionStart(IDocument document, int completionOffset) {
return getReplacementOffset();
@@ -396,8 +400,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
*/
public void setReplacementOffset(int replacementOffset) {
Assert.isTrue(replacementOffset >= 0);
- fReplacementOffset= replacementOffset;
- }
+ fReplacementOffset = replacementOffset;
+ }
/**
* Gets the replacement length.
@@ -413,7 +417,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
*/
public void setReplacementLength(int replacementLength) {
Assert.isTrue(replacementLength >= 0);
- fReplacementLength= replacementLength;
+ fReplacementLength = replacementLength;
}
/**
@@ -423,11 +427,11 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
public String getReplacementString() {
return fReplacementString;
}
-
+
@Override
public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
- String string= getReplacementString();
- int pos= string.indexOf('(');
+ String string = getReplacementString();
+ int pos = string.indexOf('(');
if (pos > 0)
return string.subSequence(0, pos);
return string;
@@ -438,7 +442,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* @param replacementString The replacement string to set
*/
public void setReplacementString(String replacementString) {
- fReplacementString= replacementString;
+ fReplacementString = replacementString;
}
/**
@@ -446,7 +450,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* @param image The image to set
*/
public void setImage(Image image) {
- fImage= image;
+ fImage = image;
}
@Override
@@ -458,18 +462,18 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
public boolean validate(IDocument document, int offset, DocumentEvent event) {
if (offset < fReplacementOffset)
return false;
-
- boolean validated= match(document, offset, fReplacementString);
+
+ boolean validated = match(document, offset, fReplacementString);
if (validated && event != null) {
// Adapt replacement range to document change
- int delta= (event.fText == null ? 0 : event.fText.length()) - event.fLength;
- fReplacementLength += delta;
+ int delta = (event.fText == null ? 0 : event.fText.length()) - event.fLength;
+ fReplacementLength += delta;
}
return validated;
}
-
+
/**
* Gets the proposal's relevance.
* @return Returns a int
@@ -484,79 +488,82 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* @param relevance The relevance to set
*/
public void setRelevance(int relevance) {
- fRelevance= relevance;
+ fRelevance = relevance;
}
/**
* Returns {@code true} if a words matches the code completion prefix in the document,
* {@code false} otherwise.
- */
+ */
protected boolean match(IDocument document, int offset, String word) {
- if (word == null)
+ if (word == null)
return false;
-
- final int wordLength= word.length();
- if (offset > fReplacementOffset + wordLength)
+
+ final int wordLength = word.length();
+ if (offset > fReplacementOffset + wordLength)
return false;
-
+
try {
- int length= offset - fReplacementOffset;
- String pattern= document.get(fReplacementOffset, length);
+ int length = offset - fReplacementOffset;
+ String pattern = document.get(fReplacementOffset, length);
return ContentAssistMatcherFactory.getInstance().match(pattern.toCharArray(), word.toCharArray());
} catch (BadLocationException x) {
}
-
- return false;
- }
+
+ return false;
+ }
private static boolean insertCompletion() {
- IPreferenceStore preference= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore preference = CUIPlugin.getDefault().getPreferenceStore();
return preference.getBoolean(ContentAssistPreference.AUTOINSERT);
}
@Override
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDocument document= viewer.getDocument();
+ IDocument document = viewer.getDocument();
// Don't eat if not in preferences, XOR with modifier key 1 (Ctrl)
// but: if there is a selection, replace it!
- Point selection= viewer.getSelectedRange();
- fToggleEating= (stateMask & SWT.MOD1) != 0;
+ Point selection = viewer.getSelectedRange();
+ fToggleEating = (stateMask & SWT.MOD1) != 0;
if (insertCompletion() ^ fToggleEating)
- fReplacementLength= selection.x + selection.y - fReplacementOffset;
-
+ fReplacementLength = selection.x + selection.y - fReplacementOffset;
+
apply(document, trigger, offset);
- fToggleEating= false;
+ fToggleEating = false;
}
private static Color getForegroundColor(StyledText text) {
- IPreferenceStore preference= CUIPlugin.getDefault().getPreferenceStore();
- RGB rgb= PreferenceConverter.getColor(preference, ContentAssistPreference.PROPOSALS_FOREGROUND);
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+ IPreferenceStore preference = CUIPlugin.getDefault().getPreferenceStore();
+ RGB rgb = PreferenceConverter.getColor(preference, ContentAssistPreference.PROPOSALS_FOREGROUND);
+ CTextTools textTools = CUIPlugin.getDefault().getTextTools();
return textTools.getColorManager().getColor(rgb);
}
private static Color getBackgroundColor(StyledText text) {
- IPreferenceStore preference= CUIPlugin.getDefault().getPreferenceStore();
- RGB rgb= PreferenceConverter.getColor(preference, ContentAssistPreference.PROPOSALS_BACKGROUND);
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+ IPreferenceStore preference = CUIPlugin.getDefault().getPreferenceStore();
+ RGB rgb = PreferenceConverter.getColor(preference, ContentAssistPreference.PROPOSALS_BACKGROUND);
+ CTextTools textTools = CUIPlugin.getDefault().getTextTools();
return textTools.getColorManager().getColor(rgb);
}
-
+
private void repairPresentation(ITextViewer viewer) {
if (fRememberedStyleRange != null) {
- if (viewer instanceof ITextViewerExtension2) {
- // Attempts to reduce the redraw area
- ITextViewerExtension2 viewer2= (ITextViewerExtension2) viewer;
-
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- IRegion widgetRange= extension.modelRange2WidgetRange(new Region(fRememberedStyleRange.start, fRememberedStyleRange.length));
- if (widgetRange != null)
- viewer2.invalidateTextPresentation(widgetRange.getOffset(), widgetRange.getLength());
- } else {
- viewer2.invalidateTextPresentation(fRememberedStyleRange.start + viewer.getVisibleRegion().getOffset(), fRememberedStyleRange.length);
- }
+ if (viewer instanceof ITextViewerExtension2) {
+ // Attempts to reduce the redraw area
+ ITextViewerExtension2 viewer2 = (ITextViewerExtension2) viewer;
+
+ if (viewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
+ IRegion widgetRange = extension.modelRange2WidgetRange(
+ new Region(fRememberedStyleRange.start, fRememberedStyleRange.length));
+ if (widgetRange != null)
+ viewer2.invalidateTextPresentation(widgetRange.getOffset(), widgetRange.getLength());
+ } else {
+ viewer2.invalidateTextPresentation(
+ fRememberedStyleRange.start + viewer.getVisibleRegion().getOffset(),
+ fRememberedStyleRange.length);
+ }
} else {
viewer.invalidateTextPresentation();
}
@@ -564,44 +571,44 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
private void updateStyle(ITextViewer viewer) {
- StyledText text= viewer.getTextWidget();
+ StyledText text = viewer.getTextWidget();
if (text == null || text.isDisposed())
return;
- int widgetCaret= text.getCaretOffset();
-
- int modelCaret= 0;
+ int widgetCaret = text.getCaretOffset();
+
+ int modelCaret = 0;
if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- modelCaret= extension.widgetOffset2ModelOffset(widgetCaret);
+ ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
+ modelCaret = extension.widgetOffset2ModelOffset(widgetCaret);
} else {
- IRegion visibleRegion= viewer.getVisibleRegion();
- modelCaret= widgetCaret + visibleRegion.getOffset();
+ IRegion visibleRegion = viewer.getVisibleRegion();
+ modelCaret = widgetCaret + visibleRegion.getOffset();
}
-
+
if (modelCaret >= fReplacementOffset + fReplacementLength) {
repairPresentation(viewer);
return;
}
-
- int offset= widgetCaret;
- int length= fReplacementOffset + fReplacementLength - modelCaret;
-
- Color foreground= getForegroundColor(text);
- Color background= getBackgroundColor(text);
- StyleRange range= text.getStyleRangeAtOffset(offset);
- int fontStyle= range != null ? range.fontStyle : SWT.NORMAL;
+ int offset = widgetCaret;
+ int length = fReplacementOffset + fReplacementLength - modelCaret;
+
+ Color foreground = getForegroundColor(text);
+ Color background = getBackgroundColor(text);
+
+ StyleRange range = text.getStyleRangeAtOffset(offset);
+ int fontStyle = range != null ? range.fontStyle : SWT.NORMAL;
repairPresentation(viewer);
- fRememberedStyleRange= new StyleRange(offset, length, foreground, background, fontStyle);
-
+ fRememberedStyleRange = new StyleRange(offset, length, foreground, background, fontStyle);
+
// http://dev.eclipse.org/bugs/show_bug.cgi?id=34754
try {
text.setStyleRange(fRememberedStyleRange);
} catch (IllegalArgumentException x) {
// Catching exception as offset + length might be outside of the text widget
- fRememberedStyleRange= null;
+ fRememberedStyleRange = null;
}
}
@@ -611,14 +618,14 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
updateStyle(viewer);
} else {
repairPresentation(viewer);
- fRememberedStyleRange= null;
+ fRememberedStyleRange = null;
}
}
@Override
public void unselected(ITextViewer viewer) {
repairPresentation(viewer);
- fRememberedStyleRange= null;
+ fRememberedStyleRange = null;
}
@Override
@@ -641,8 +648,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
@Override
public boolean equals(Object other) {
- if(!(other instanceof ICCompletionProposal))
+ if (!(other instanceof ICCompletionProposal))
return false;
- return fIdString.equalsIgnoreCase(((ICCompletionProposal)other).getIdString());
+ return fIdString.equalsIgnoreCase(((ICCompletionProposal) other).getIdString());
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java
index e9d86e1ff77..7760a10b0a7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text.contentassist;
-
import java.util.Comparator;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
@@ -27,31 +26,29 @@ public class CCompletionProposalComparator implements Comparator<ICCompletionPro
* Constructor for CompletionProposalComparator.
*/
public CCompletionProposalComparator() {
- fOrderAlphabetically= false;
+ fOrderAlphabetically = false;
}
-
+
public void setOrderAlphabetically(boolean orderAlphabetically) {
- fOrderAlphabetically= orderAlphabetically;
+ fOrderAlphabetically = orderAlphabetically;
}
-
+
/*
* @see Comparator#compare(Object, Object)
*/
@Override
public int compare(ICCompletionProposal c1, ICCompletionProposal c2) {
if (!fOrderAlphabetically) {
- int relevanceDif= c2.getRelevance() - c1.getRelevance();
+ int relevanceDif = c2.getRelevance() - c1.getRelevance();
if (relevanceDif != 0) {
return relevanceDif;
}
}
-
- String id1 = c1.getIdString();
- String id2 = c2.getIdString();
-
- return id1.compareTo(id2);
- }
-
-}
+ String id1 = c1.getIdString();
+ String id2 = c2.getIdString();
+ return id1.compareTo(id2);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java
index a50033811f5..551b6375717 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java
@@ -55,13 +55,12 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
import org.eclipse.cdt.internal.ui.text.Symbols;
-
/**
* Describes the context of a content assist invocation in a C/C++ editor.
* <p>
* Clients may instantiate. A client that created a context is responsible for its disposal.
* </p>
- *
+ *
* @since 4.0
*/
public class CContentAssistInvocationContext extends ContentAssistInvocationContext
@@ -93,14 +92,14 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
if (result != getInvocationOffset()) {
// If guessCompletionPosition() chose a parse offset that's different
// from the invocation offset, we are proposing completions for a name
- // that's not right under the cursor, and so we just want to show
+ // that's not right under the cursor, and so we just want to show
// context information.
- fIsContextInformationStyle= true;
+ fIsContextInformationStyle = true;
}
fAdjustedParseOffset = result;
return result;
}
-
+
private int doCalculate() {
if (fIsCompletion) {
return guessCompletionPosition(getInvocationOffset());
@@ -118,58 +117,57 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
if (completionName.getSimpleID().length > 0) {
return null;
}
- if (completionName.getParent() instanceof IASTIdExpression &&
- completionName.getParent().getParent() instanceof IASTInitializerList) {
+ if (completionName.getParent() instanceof IASTIdExpression
+ && completionName.getParent().getParent() instanceof IASTInitializerList) {
IASTNode initList = completionName.getParent().getParent();
- if (initList.getParent() instanceof IASTDeclarator &&
- initList.getParent().getParent() instanceof IASTSimpleDeclaration) {
- IASTSimpleDeclaration decl = (IASTSimpleDeclaration) completionName.getParent().getParent()
- .getParent().getParent();
+ if (initList.getParent() instanceof IASTDeclarator
+ && initList.getParent().getParent() instanceof IASTSimpleDeclaration) {
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) completionName.getParent().getParent().getParent()
+ .getParent();
if (decl.getDeclSpecifier() instanceof IASTNamedTypeSpecifier) {
return ((IASTNamedTypeSpecifier) decl.getDeclSpecifier()).getName();
- }
+ }
} else if (initList.getParent() instanceof ICPPASTSimpleTypeConstructorExpression) {
- ICPPASTSimpleTypeConstructorExpression expr =
- (ICPPASTSimpleTypeConstructorExpression) initList.getParent();
+ ICPPASTSimpleTypeConstructorExpression expr = (ICPPASTSimpleTypeConstructorExpression) initList
+ .getParent();
if (expr.getDeclSpecifier() instanceof IASTNamedTypeSpecifier) {
return ((IASTNamedTypeSpecifier) expr.getDeclSpecifier()).getName();
}
} else if (initList.getParent() instanceof ICPPASTConstructorChainInitializer) {
- ICPPASTConstructorChainInitializer ctorInit =
- (ICPPASTConstructorChainInitializer) initList.getParent();
+ ICPPASTConstructorChainInitializer ctorInit = (ICPPASTConstructorChainInitializer) initList.getParent();
return ctorInit.getMemberInitializerId();
}
}
return null;
}
-
+
/**
* Choose a better completion node based on information in the AST.
- *
+ *
* Currently, this makes an adjustment in one case: if the completion node is
* an empty name at the top level of one of the initializers of an initializer
* list that may be a constructor call, the completion name is adjusted to
* instead be the name preceding the initializer list (which will either name
* the type being constructed, or a variable of that type). This allows us to
* offer completions for the constructors of this type.
- *
+ *
* Currently we handle initializer lists in three contexts:
* 1) simple declaration
* 2) simple type constructor expression
* 3) constructor chain initializer
- *
+ *
* TODO: Handle the additional context of a return-expression:
* S foo() {
* return {...}; // can invoke S constructor with args inside {...}
- * }
- *
+ * }
+ *
* Note that for constructor calls with () rather than {} syntax, we
* accomplish the same goal by different means: in getParseOffset(), we choose
* a parse offset that will give us the desired completion node to begin with.
* We can't do this with the {} syntax, because in getParseOffset() we don't
* have an AST yet (the choice is made using CHeuristicScanner), and we cannot
- * distinguish other uses of {} from the desired ones.
- *
+ * distinguish other uses of {} from the desired ones.
+ *
* @param completionName the initial completion name, based on the parse offset
* chosen using CHeuristicScanner
* @return the adjusted completion name, if different from the initial completion
@@ -191,7 +189,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
} catch (ExpansionOverlapsBoundaryException e) {
}
if (newCompletionToken != null) {
- ASTCompletionNode newCompletionNode = new ASTCompletionNode(newCompletionToken,
+ ASTCompletionNode newCompletionNode = new ASTCompletionNode(newCompletionToken,
existing.getTranslationUnit());
newCompletionNode.addName(newCompletionName);
return newCompletionNode;
@@ -199,7 +197,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
}
return null;
}
-
+
private final Lazy<IASTCompletionNode> fCN = new Lazy<IASTCompletionNode>() {
@Override
protected IASTCompletionNode calculateValue() {
@@ -207,7 +205,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
if (offset < 0)
return null;
- ICProject proj= getProject();
+ ICProject proj = getProject();
if (proj == null)
return null;
@@ -215,8 +213,9 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
if (fIndex != null)
throw new IllegalStateException("The method should not be called multiple times."); //$NON-NLS-1$
- IIndexManager manager= CCorePlugin.getIndexManager();
- fIndex = manager.getIndex(proj, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST);
+ IIndexManager manager = CCorePlugin.getIndexManager();
+ fIndex = manager.getIndex(proj,
+ IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST);
try {
fIndex.acquireReadLock();
@@ -224,8 +223,10 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
fIndex = null;
}
- boolean parseNonIndexed= CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
- int flags = parseNonIndexed ? ITranslationUnit.AST_SKIP_INDEXED_HEADERS : ITranslationUnit.AST_SKIP_ALL_HEADERS;
+ boolean parseNonIndexed = CUIPlugin.getDefault().getPreferenceStore()
+ .getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
+ int flags = parseNonIndexed ? ITranslationUnit.AST_SKIP_INDEXED_HEADERS
+ : ITranslationUnit.AST_SKIP_ALL_HEADERS;
flags |= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
IASTCompletionNode result = fTU.value().getCompletionNode(fIndex, flags, offset);
@@ -242,8 +243,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
if (adjusted.getNames().length > 0) {
// Make a corresponding adjustment to the parse offset.
IASTFileLocation adjustedLocation = adjusted.getNames()[0].getFileLocation();
- fAdjustedParseOffset = adjustedLocation.getNodeOffset() +
- adjustedLocation.getNodeLength();
+ fAdjustedParseOffset = adjustedLocation.getNodeOffset() + adjustedLocation.getNodeLength();
}
}
}
@@ -319,7 +319,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
// Before that, there may be any number of "namespace::" token pairs.
while (token == Symbols.TokenDOUBLECOLON) {
token = tokenStream.previousToken();
- if (token == Symbols.TokenUSING) { // there could also be a leading "::" for global namespace
+ if (token == Symbols.TokenUSING) { // there could also be a leading "::" for global namespace
return true;
} else if (token != Symbols.TokenIDENT) {
return false;
@@ -343,8 +343,8 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
return token == Symbols.TokenSEMICOLON;
}
};
-
- private final Lazy<Boolean> followedByOpeningParen = new Lazy<Boolean>() {
+
+ private final Lazy<Boolean> followedByOpeningParen = new Lazy<Boolean>() {
@Override
protected Boolean calculateValue() {
final IDocument doc = getDocument();
@@ -375,20 +375,20 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
/**
* Creates a new context.
- *
+ *
* @param viewer the viewer used by the editor
* @param offset the invocation offset
* @param editor the editor that content assist is invoked in
* @param isAutoActivated indicates whether content assist was auto-activated
*/
- public CContentAssistInvocationContext(ITextViewer viewer, int offset, IEditorPart editor,
- boolean isCompletion, boolean isAutoActivated) {
+ public CContentAssistInvocationContext(ITextViewer viewer, int offset, IEditorPart editor, boolean isCompletion,
+ boolean isAutoActivated) {
super(viewer, offset);
Assert.isNotNull(editor);
- fEditor= editor;
- fIsCompletion= isCompletion;
- fIsContextInformationStyle= !isCompletion;
- fIsAutoActivated= isAutoActivated;
+ fEditor = editor;
+ fIsCompletion = isCompletion;
+ fIsContextInformationStyle = !isCompletion;
+ fIsAutoActivated = isAutoActivated;
fTU = new Lazy<ITranslationUnit>() {
@Override
protected ITranslationUnit calculateValue() {
@@ -396,30 +396,30 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
}
};
}
-
+
/**
* Creates a new context.
- *
+ *
* @param unit the translation unit in <code>document</code>
*/
public CContentAssistInvocationContext(final ITranslationUnit unit, boolean isCompletion) {
super();
- fTU= new Lazy<ITranslationUnit>() {
+ fTU = new Lazy<ITranslationUnit>() {
@Override
protected ITranslationUnit calculateValue() {
return unit;
}
};
- fEditor= null;
- fIsCompletion= isCompletion;
- fIsContextInformationStyle= !isCompletion;
- fIsAutoActivated= false;
+ fEditor = null;
+ fIsCompletion = isCompletion;
+ fIsContextInformationStyle = !isCompletion;
+ fIsAutoActivated = false;
}
-
+
/**
* Returns the translation unit that content assist is invoked in, <code>null</code> if there
* is none.
- *
+ *
* @return the translation unit that content assist is invoked in, possibly <code>null</code>
*/
@Override
@@ -427,27 +427,27 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
assertNotDisposed();
return fTU.value();
}
-
+
/**
* Returns the project of the translation unit that content assist is invoked in,
* <code>null</code> if none.
- *
+ *
* @return the current C project, possibly <code>null</code>
*/
@Override
public ICProject getProject() {
assertNotDisposed();
- ITranslationUnit unit= getTranslationUnit();
+ ITranslationUnit unit = getTranslationUnit();
return unit == null ? null : unit.getCProject();
}
-
+
@Override
public IASTCompletionNode getCompletionNode() {
assertNotDisposed();
// For scalability.
if (fEditor != null && fEditor instanceof CEditor) {
CEditor editor = (CEditor) fEditor;
-
+
// Check to make sure we should attempt local parsing completions... for remote projects
// we should not do this.
if (!editor.shouldProcessLocalParsingCompletions()) {
@@ -464,13 +464,13 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
}
return fCN.value();
}
-
+
@Override
public int getParseOffset() {
assertNotDisposed();
return fParseOffset.value();
}
-
+
public int getAdjustedParseOffset() {
assertNotDisposed();
return fAdjustedParseOffset;
@@ -484,93 +484,98 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
assertNotDisposed();
return fContextInfoPosition.value();
}
-
+
/**
* Try to find a sensible completion position backwards in case the given offset
* is inside a function call argument list or in template arguments.
- *
+ *
* @param contextPosition the starting position
* @return a sensible completion offset
*/
protected int guessCompletionPosition(int contextPosition) {
assertNotDisposed();
- CHeuristicScanner scanner= new CHeuristicScanner(getDocument());
- int bound= Math.max(-1, contextPosition - 200);
-
- int pos= scanner.findNonWhitespaceBackward(contextPosition - 1, bound);
- if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
-
- int token= scanner.previousToken(pos, bound);
-
+ CHeuristicScanner scanner = new CHeuristicScanner(getDocument());
+ int bound = Math.max(-1, contextPosition - 200);
+
+ int pos = scanner.findNonWhitespaceBackward(contextPosition - 1, bound);
+ if (pos == CHeuristicScanner.NOT_FOUND)
+ return contextPosition;
+
+ int token = scanner.previousToken(pos, bound);
+
if (token == Symbols.TokenCOMMA) {
int openingParenthesisPos = scanner.findOpeningPeer(pos, bound, '(', ')');
int openingAngleBracketPos = scanner.findOpeningPeer(pos, bound, '<', '>');
pos = Math.max(openingParenthesisPos, openingAngleBracketPos);
- if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
-
+ if (pos == CHeuristicScanner.NOT_FOUND)
+ return contextPosition;
+
token = scanner.previousToken(pos, bound);
}
-
+
if (token == Symbols.TokenLPAREN || token == Symbols.TokenLESSTHAN) {
- pos= scanner.findNonWhitespaceBackward(pos - 1, bound);
- if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
-
- token= scanner.previousToken(pos, bound);
-
+ pos = scanner.findNonWhitespaceBackward(pos - 1, bound);
+ if (pos == CHeuristicScanner.NOT_FOUND)
+ return contextPosition;
+
+ token = scanner.previousToken(pos, bound);
+
if (token == Symbols.TokenGREATERTHAN) {
// skip template arguments
- pos= scanner.findOpeningPeer(pos - 1, '<', '>');
- if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
- pos= scanner.findNonWhitespaceBackward(pos - 1, bound);
- if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
- token= scanner.previousToken(pos, bound);
+ pos = scanner.findOpeningPeer(pos - 1, '<', '>');
+ if (pos == CHeuristicScanner.NOT_FOUND)
+ return contextPosition;
+ pos = scanner.findNonWhitespaceBackward(pos - 1, bound);
+ if (pos == CHeuristicScanner.NOT_FOUND)
+ return contextPosition;
+ token = scanner.previousToken(pos, bound);
}
-
+
if (token == Symbols.TokenIDENT) {
return pos + 1;
}
}
-
+
return contextPosition;
}
-
+
/**
* Try to find the smallest offset inside the opening parenthesis of a function call
* argument list.
- *
+ *
* @return the offset of the function call parenthesis plus 1 or -1 if the invocation
* offset is not inside a function call (or similar)
*/
protected int guessContextInformationPosition() {
assertNotDisposed();
- final int contextPosition= getInvocationOffset();
-
- CHeuristicScanner scanner= new CHeuristicScanner(getDocument());
- int bound= Math.max(-1, contextPosition - 200);
-
+ final int contextPosition = getInvocationOffset();
+
+ CHeuristicScanner scanner = new CHeuristicScanner(getDocument());
+ int bound = Math.max(-1, contextPosition - 200);
+
// try the innermost scope of parentheses that looks like a method call
- int pos= contextPosition - 1;
+ int pos = contextPosition - 1;
do {
- int paren= scanner.findOpeningPeer(pos, bound, '(', ')');
- int angle= scanner.findOpeningPeer(pos, bound, '<', '>');
+ int paren = scanner.findOpeningPeer(pos, bound, '(', ')');
+ int angle = scanner.findOpeningPeer(pos, bound, '<', '>');
int nearestPeer = Math.max(paren, angle);
if (nearestPeer == CHeuristicScanner.NOT_FOUND)
break;
- int token= scanner.previousToken(nearestPeer - 1, bound);
+ int token = scanner.previousToken(nearestPeer - 1, bound);
// next token must be a method name (identifier) or the closing angle of a
// constructor call of a template type.
if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN) {
return nearestPeer + 1;
}
- pos= nearestPeer - 1;
+ pos = nearestPeer - 1;
} while (true);
-
+
return -1;
}
-
+
/**
* Get the editor content assist is invoked in.
- *
+ *
* @return the editor, may be <code>null</code>
*/
@Override
@@ -584,7 +589,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
assertNotDisposed();
return fIsContextInformationStyle;
}
-
+
public boolean isAutoActivated() {
assertNotDisposed();
return fIsAutoActivated;
@@ -618,8 +623,8 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
assertNotDisposed();
return followedBySemicolon.value();
}
-
- public boolean isFollowedByOpeningParen() {
+
+ public boolean isFollowedByOpeningParen() {
assertNotDisposed();
return followedByOpeningParen.value();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
index fce7ae982d9..0128ec5e0a9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
@@ -81,7 +81,7 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
private ICompletionProposal fWrappedProposal;
public CCompletionProposalWrapper(ICompletionProposal proposal) {
- fWrappedProposal= proposal;
+ fWrappedProposal = proposal;
}
@Override
@@ -139,13 +139,13 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
public CContentAssistProcessor(IEditorPart editor, ContentAssistant assistant, String partition) {
super(assistant, partition);
- fEditor= editor;
+ fEditor = editor;
}
@Override
public IContextInformationValidator getContextInformationValidator() {
if (fValidator == null) {
- fValidator= new CParameterListValidator();
+ fValidator = new CParameterListValidator();
}
return fValidator;
}
@@ -154,46 +154,47 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
protected List<ICompletionProposal> filterAndSortProposals(List<ICompletionProposal> proposals,
IProgressMonitor monitor, ContentAssistInvocationContext context) {
IProposalFilter filter = getCompletionFilter();
- ICCompletionProposal[] proposalsInput= new ICCompletionProposal[proposals.size()];
+ ICCompletionProposal[] proposalsInput = new ICCompletionProposal[proposals.size()];
// Wrap proposals which are no ICCompletionProposals.
- boolean wrapped= false;
- int i= 0;
+ boolean wrapped = false;
+ int i = 0;
for (ICompletionProposal proposal : proposals) {
if (proposal instanceof ICCompletionProposal) {
- proposalsInput[i++]= (ICCompletionProposal) proposal;
+ proposalsInput[i++] = (ICCompletionProposal) proposal;
} else {
- wrapped= true;
- proposalsInput[i++]= new CCompletionProposalWrapper(proposal);
+ wrapped = true;
+ proposalsInput[i++] = new CCompletionProposalWrapper(proposal);
}
}
// Filter.
ICCompletionProposal[] proposalsFiltered = filter.filterProposals(proposalsInput);
// Sort.
- boolean sortByAlphabet= CUIPlugin.getDefault().getPreferenceStore().getBoolean(ContentAssistPreference.ORDER_PROPOSALS);
+ boolean sortByAlphabet = CUIPlugin.getDefault().getPreferenceStore()
+ .getBoolean(ContentAssistPreference.ORDER_PROPOSALS);
if (sortByAlphabet) {
// Already sorted alphabetically by DefaultProposalFilter
// in case of custom proposal filter, keep ordering applied by filter.
} else {
// Sort by relevance.
- CCompletionProposalComparator propsComp= new CCompletionProposalComparator();
+ CCompletionProposalComparator propsComp = new CCompletionProposalComparator();
propsComp.setOrderAlphabetically(sortByAlphabet);
Arrays.sort(proposalsFiltered, propsComp);
}
List<ICompletionProposal> filteredList;
if (wrapped) {
// Unwrap again.
- filteredList= new ArrayList<>(proposalsFiltered.length);
+ filteredList = new ArrayList<>(proposalsFiltered.length);
for (ICCompletionProposal proposal : proposalsFiltered) {
if (proposal instanceof CCompletionProposalWrapper) {
- filteredList.add(((CCompletionProposalWrapper)proposal).unwrap());
+ filteredList.add(((CCompletionProposalWrapper) proposal).unwrap());
} else {
filteredList.add(proposal);
}
}
} else {
- final ICompletionProposal[] tmp= proposalsFiltered;
- filteredList= Arrays.asList(tmp);
+ final ICompletionProposal[] tmp = proposalsFiltered;
+ filteredList = Arrays.asList(tmp);
}
return filteredList;
}
@@ -244,7 +245,7 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
* @param activationSet the activation set
*/
public void setReplacementAutoActivationCharacters(String activationSet) {
- fReplacementAutoActivationCharacters= new ActivationSet(activationSet);
+ fReplacementAutoActivationCharacters = new ActivationSet(activationSet);
}
/**
@@ -262,24 +263,25 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
* @param activationSet the activation set
*/
public void setCContentAutoActivationCharacters(String activationSet) {
- fCContentAutoActivationCharacters= new ActivationSet(activationSet);
+ fCContentAutoActivationCharacters = new ActivationSet(activationSet);
}
@Override
protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset, boolean isCompletion) {
char activationChar = getActivationChar(viewer, offset);
- CContentAssistInvocationContext context =
- new CContentAssistInvocationContext(viewer, offset, fEditor, isCompletion, isAutoActivated());
+ CContentAssistInvocationContext context = new CContentAssistInvocationContext(viewer, offset, fEditor,
+ isCompletion, isAutoActivated());
try {
- if (isCompletion && activationChar == '.' && fReplacementAutoActivationCharacters != null &&
- fReplacementAutoActivationCharacters.contains('.')) {
+ if (isCompletion && activationChar == '.' && fReplacementAutoActivationCharacters != null
+ && fReplacementAutoActivationCharacters.contains('.')) {
IASTCompletionNode node = context.getCompletionNode();
if (node != null) {
IASTName[] names = node.getNames();
if (names.length > 0 && names[0].getParent() instanceof IASTFieldReference) {
IASTFieldReference ref = (IASTFieldReference) names[0].getParent();
IASTExpression ownerExpr = ref.getFieldOwner();
- IType ownerExprType = SemanticUtil.getNestedType(ownerExpr.getExpressionType(), SemanticUtil.TDEF);
+ IType ownerExprType = SemanticUtil.getNestedType(ownerExpr.getExpressionType(),
+ SemanticUtil.TDEF);
if (ownerExprType instanceof ICPPUnknownType) {
try {
CPPSemantics.pushLookupPoint(names[0]);
@@ -293,7 +295,8 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
}
}
}
- if (context != null && isAutoActivated() && !fCContentAutoActivationCharacters.contains(activationChar)) {
+ if (context != null && isAutoActivated()
+ && !fCContentAutoActivationCharacters.contains(activationChar)) {
// Auto-replace, but not auto-content-assist - bug 344387.
context.dispose();
context = null;
@@ -308,8 +311,8 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
return context;
}
- private CContentAssistInvocationContext replaceDotWithArrow(ITextViewer viewer, int offset,
- boolean isCompletion, CContentAssistInvocationContext context, char activationChar) {
+ private CContentAssistInvocationContext replaceDotWithArrow(ITextViewer viewer, int offset, boolean isCompletion,
+ CContentAssistInvocationContext context, char activationChar) {
IDocument doc = viewer.getDocument();
try {
doc.replace(offset - 1, 1, "->"); //$NON-NLS-1$
@@ -318,8 +321,8 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
// If user turned on activation only for replacement characters,
// setting the context to null will skip the proposals popup later.
if (!isAutoActivated() || fCContentAutoActivationCharacters.contains(activationChar)) {
- context = new CContentAssistInvocationContext(viewer, offset + 1, fEditor,
- isCompletion, isAutoActivated());
+ context = new CContentAssistInvocationContext(viewer, offset + 1, fEditor, isCompletion,
+ isAutoActivated());
}
} catch (BadLocationException e) {
// Ignore
@@ -335,7 +338,7 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
* @return the activation character
*/
private char getActivationChar(ITextViewer viewer, int offset) {
- IDocument doc= viewer.getDocument();
+ IDocument doc = viewer.getDocument();
if (doc == null) {
return 0;
}
@@ -351,7 +354,7 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
@Override
protected boolean verifyAutoActivation(ITextViewer viewer, int offset) {
- IDocument doc= viewer.getDocument();
+ IDocument doc = viewer.getDocument();
if (doc == null) {
return false;
}
@@ -359,7 +362,7 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
return false;
}
try {
- char activationChar= doc.getChar(--offset);
+ char activationChar = doc.getChar(--offset);
switch (activationChar) {
case ':':
return offset > 0 && doc.getChar(--offset) == ':';
@@ -367,10 +370,11 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
return offset > 0 && doc.getChar(--offset) == '-';
case '.':
// Avoid completion of float literals
- CHeuristicScanner scanner= new CHeuristicScanner(doc);
- int token= scanner.previousToken(--offset, Math.max(0, offset - 200));
+ CHeuristicScanner scanner = new CHeuristicScanner(doc);
+ int token = scanner.previousToken(--offset, Math.max(0, offset - 200));
// The scanner reports numbers as identifiers
- if (token == Symbols.TokenIDENT && !Character.isJavaIdentifierStart(doc.getChar(scanner.getPosition() + 1))) {
+ if (token == Symbols.TokenIDENT
+ && !Character.isJavaIdentifierStart(doc.getChar(scanner.getPosition() + 1))) {
// Not a valid identifier
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextInformation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextInformation.java
index d6abd30b5ac..aac90ae8716 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextInformation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextInformation.java
@@ -43,22 +43,25 @@ public class CProposalContextInformation implements IContextInformation, IContex
private boolean fHasPrefixSuffix;
private int fParamlistStartIndex;
private int fParamlistEndIndex;
-
+
public void setHasPrefixSuffix(int paramlistStartIndex, int paramlistEndIndex) {
fHasPrefixSuffix = true;
fParamlistStartIndex = paramlistStartIndex;
fParamlistEndIndex = paramlistEndIndex;
}
+
public boolean hasPrefixSuffix() {
return fHasPrefixSuffix;
}
+
public int getArglistStartIndex() {
return fParamlistStartIndex;
}
+
public int getArglistEndIndex() {
return fParamlistEndIndex;
}
-
+
/**
* Creates a new context information without an image.
*
@@ -79,33 +82,34 @@ public class CProposalContextInformation implements IContextInformation, IContex
*/
public CProposalContextInformation(Image image, String contextDisplayString, String informationDisplayString) {
//Assert.isNotNull(informationDisplayString);
- fImage= image;
- fContextDisplayString= contextDisplayString;
- fInformationDisplayString= informationDisplayString;
+ fImage = image;
+ fContextDisplayString = contextDisplayString;
+ fInformationDisplayString = informationDisplayString;
}
@Override
public boolean equals(Object object) {
if (object instanceof IContextInformation) {
- IContextInformation contextInformation= (IContextInformation) object;
- boolean equals= fInformationDisplayString.equalsIgnoreCase(contextInformation.getInformationDisplayString());
- if (fContextDisplayString != null)
- equals= equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString());
+ IContextInformation contextInformation = (IContextInformation) object;
+ boolean equals = fInformationDisplayString
+ .equalsIgnoreCase(contextInformation.getInformationDisplayString());
+ if (fContextDisplayString != null)
+ equals = equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString());
return equals;
}
return false;
}
-
+
@Override
public String getInformationDisplayString() {
return fInformationDisplayString;
}
-
+
@Override
public Image getImage() {
return fImage;
}
-
+
@Override
public String getContextDisplayString() {
if (fContextDisplayString != null)
@@ -117,7 +121,7 @@ public class CProposalContextInformation implements IContextInformation, IContex
public int getContextInformationPosition() {
return fInformationPosition;
}
-
+
public void setContextInformationPosition(int pos) {
fInformationPosition = pos;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java
index 4e5d22ea1b9..d488d7ffa58 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java
@@ -41,65 +41,66 @@ import org.eclipse.cdt.internal.ui.util.Messages;
/**
* Describes a category extension to the "completionProposalComputer" extension point.
- *
+ *
* @since 4.0
*/
public final class CompletionProposalCategory {
/** The extension schema name of the icon attribute. */
- private static final String ICON= "icon"; //$NON-NLS-1$
+ private static final String ICON = "icon"; //$NON-NLS-1$
private final String fId;
private final String fName;
private final IConfigurationElement fElement;
/** The image descriptor for this category, or {@code null} if none specified. */
private final ImageDescriptor fImage;
-
- private boolean fIsSeparateCommand= true;
- private boolean fIsEnabled= true;
- private boolean fIsIncluded= true;
+
+ private boolean fIsSeparateCommand = true;
+ private boolean fIsEnabled = true;
+ private boolean fIsIncluded = true;
private final CompletionProposalComputerRegistry fRegistry;
-
- private int fSortOrder= 0x10000;
+
+ private int fSortOrder = 0x10000;
private String fLastError;
- CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry) throws CoreException {
- fElement= element;
- fRegistry= registry;
- IExtension parent= (IExtension) element.getParent();
- fId= parent.getUniqueIdentifier();
+ CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry)
+ throws CoreException {
+ fElement = element;
+ fRegistry = registry;
+ IExtension parent = (IExtension) element.getParent();
+ fId = parent.getUniqueIdentifier();
checkNotNull(fId, "id"); //$NON-NLS-1$
- String name= parent.getLabel();
+ String name = parent.getLabel();
if (name == null) {
- fName= fId;
+ fName = fId;
} else {
- fName= name;
+ fName = name;
}
-
- String icon= element.getAttribute(ICON);
- ImageDescriptor img= null;
+
+ String icon = element.getAttribute(ICON);
+ ImageDescriptor img = null;
if (icon != null) {
- Bundle bundle= getBundle();
+ Bundle bundle = getBundle();
if (bundle != null) {
- Path path= new Path(icon);
- URL url= FileLocator.find(bundle, path, null);
- img= ImageDescriptor.createFromURL(url);
+ Path path = new Path(icon);
+ URL url = FileLocator.find(bundle, path, null);
+ img = ImageDescriptor.createFromURL(url);
}
}
- fImage= img;
+ fImage = img;
}
CompletionProposalCategory(String id, String name, CompletionProposalComputerRegistry registry) {
- fRegistry= registry;
- fId= id;
- fName= name;
- fElement= null;
- fImage= null;
+ fRegistry = registry;
+ fId = id;
+ fName = name;
+ fElement = null;
+ fImage = null;
}
private Bundle getBundle() {
- String namespace= fElement.getDeclaringExtension().getContributor().getName();
- Bundle bundle= Platform.getBundle(namespace);
+ String namespace = fElement.getDeclaringExtension().getContributor().getName();
+ Bundle bundle = Platform.getBundle(namespace);
return bundle;
}
@@ -112,9 +113,10 @@ public final class CompletionProposalCategory {
*/
private void checkNotNull(Object obj, String attribute) throws CoreException {
if (obj == null) {
- Object[] args= { getId(), fElement.getContributor().getName(), attribute };
- String message= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
- IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null);
+ Object[] args = { getId(), fElement.getContributor().getName(), attribute };
+ String message = Messages
+ .format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
+ IStatus status = new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null);
CUIPlugin.log(status);
throw new CoreException(status);
}
@@ -131,58 +133,58 @@ public final class CompletionProposalCategory {
/**
* Returns the name of the described extension.
- *
+ *
* @return Returns the name
*/
public String getName() {
return fName;
}
-
+
/**
* Returns the name of the described extension
* without mnemonic hint in order to be displayed
* in a message.
- *
+ *
* @return Returns the name
*/
public String getDisplayName() {
return LegacyActionTools.removeMnemonics(fName);
}
-
+
/**
* Returns the image descriptor of the described category.
- *
+ *
* @return the image descriptor of the described category
*/
public ImageDescriptor getImageDescriptor() {
return fImage;
}
-
+
/**
* Sets the separate command state of the category.
- *
+ *
* @param enabled the new enabled state.
*/
public void setSeparateCommand(boolean enabled) {
- fIsSeparateCommand= enabled;
+ fIsSeparateCommand = enabled;
}
-
+
/**
* Returns the enablement state of the category.
- *
+ *
* @return the enablement state of the category
*/
public boolean isSeparateCommand() {
return fIsSeparateCommand;
}
-
+
/**
* @param included the included
*/
public void setIncluded(boolean included) {
- fIsIncluded= included;
+ fIsIncluded = included;
}
-
+
/**
* @return included
*/
@@ -195,60 +197,60 @@ public final class CompletionProposalCategory {
}
public void setEnabled(boolean isEnabled) {
- fIsEnabled= isEnabled;
+ fIsEnabled = isEnabled;
}
/**
* Returns {@code true} if the category contains any computers, {@code false}
* otherwise.
- *
+ *
* @return {@code true} if the category contains any computers, {@code false}
* otherwise
*/
public boolean hasComputers() {
- List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors();
+ List<CompletionProposalComputerDescriptor> descriptors = fRegistry.getProposalComputerDescriptors();
for (CompletionProposalComputerDescriptor desc : descriptors) {
if (desc.getCategory() == this)
return true;
}
return false;
}
-
+
/**
* Returns {@code true} if the category contains any computers in the given partition,
* {@code false} otherwise.
- *
+ *
* @param partition the partition
* @return {@code true} if the category contains any computers, {@code false} otherwise
*/
public boolean hasComputers(String partition) {
- List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors(partition);
+ List<CompletionProposalComputerDescriptor> descriptors = fRegistry.getProposalComputerDescriptors(partition);
for (CompletionProposalComputerDescriptor desc : descriptors) {
if (desc.getCategory() == this)
return true;
}
return false;
}
-
+
/**
* @return sortOrder
*/
public int getSortOrder() {
return fSortOrder;
}
-
+
/**
* @param sortOrder the sortOrder
*/
public void setSortOrder(int sortOrder) {
- fSortOrder= sortOrder;
+ fSortOrder = sortOrder;
}
/**
* Safely computes completion proposals of all computers of this category through their
* extension. If an extension is disabled, throws an exception or otherwise does not adhere to
* the contract described in {@link ICompletionProposalComputer}, it is disabled.
- *
+ *
* @param context the invocation context passed on to the extension
* @param partition the partition type where to invocation occurred
* @param monitor the progress monitor passed on to the extension
@@ -257,14 +259,15 @@ public final class CompletionProposalCategory {
*/
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
String partition, IProgressMonitor monitor) {
- fLastError= null;
- List<ICompletionProposal> result= new ArrayList<>();
- List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<>(fRegistry.getProposalComputerDescriptors(partition));
+ fLastError = null;
+ List<ICompletionProposal> result = new ArrayList<>();
+ List<CompletionProposalComputerDescriptor> descriptors = new ArrayList<>(
+ fRegistry.getProposalComputerDescriptors(partition));
for (CompletionProposalComputerDescriptor desc : descriptors) {
if (desc.getCategory() == this)
result.addAll(desc.computeCompletionProposals(context, monitor));
if (fLastError == null)
- fLastError= desc.getErrorMessage();
+ fLastError = desc.getErrorMessage();
}
return result;
}
@@ -273,31 +276,31 @@ public final class CompletionProposalCategory {
* Safely computes context information objects of all computers of this category through their
* extension. If an extension is disabled, throws an exception or otherwise does not adhere to
* the contract described in {@link ICompletionProposalComputer}, it is disabled.
- *
+ *
* @param context the invocation context passed on to the extension
* @param partition the partition type where to invocation occurred
* @param monitor the progress monitor passed on to the extension
* @return the list of computed context information objects (element type:
* {@link org.eclipse.jface.text.contentassist.IContextInformation})
*/
- public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
- String partition, IProgressMonitor monitor) {
- fLastError= null;
- List<IContextInformation> result= new ArrayList<>();
- List<CompletionProposalComputerDescriptor> descriptors=
- new ArrayList<>(fRegistry.getProposalComputerDescriptors(partition));
- for (CompletionProposalComputerDescriptor desc : descriptors) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, String partition,
+ IProgressMonitor monitor) {
+ fLastError = null;
+ List<IContextInformation> result = new ArrayList<>();
+ List<CompletionProposalComputerDescriptor> descriptors = new ArrayList<>(
+ fRegistry.getProposalComputerDescriptors(partition));
+ for (CompletionProposalComputerDescriptor desc : descriptors) {
if (desc.getCategory() == this)
result.addAll(desc.computeContextInformation(context, monitor));
if (fLastError == null)
- fLastError= desc.getErrorMessage();
+ fLastError = desc.getErrorMessage();
}
return result;
}
/**
* Returns the error message from the computers in this category.
- *
+ *
* @return the error message from the computers in this category
*/
public String getErrorMessage() {
@@ -308,25 +311,27 @@ public final class CompletionProposalCategory {
* Notifies the computers in this category of a proposal computation session start.
*/
public void sessionStarted() {
- List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<>(fRegistry.getProposalComputerDescriptors());
+ List<CompletionProposalComputerDescriptor> descriptors = new ArrayList<>(
+ fRegistry.getProposalComputerDescriptors());
for (CompletionProposalComputerDescriptor desc : descriptors) {
if (desc.getCategory() == this)
desc.sessionStarted();
if (fLastError == null)
- fLastError= desc.getErrorMessage();
+ fLastError = desc.getErrorMessage();
}
}
-
+
/**
* Notifies the computers in this category of a proposal computation session end.
*/
public void sessionEnded() {
- List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<>(fRegistry.getProposalComputerDescriptors());
+ List<CompletionProposalComputerDescriptor> descriptors = new ArrayList<>(
+ fRegistry.getProposalComputerDescriptors());
for (CompletionProposalComputerDescriptor desc : descriptors) {
if (desc.getCategory() == this)
desc.sessionEnded();
if (fLastError == null)
- fLastError= desc.getErrorMessage();
+ fLastError = desc.getErrorMessage();
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java
index 4b738184f2e..7cb481d35a7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java
@@ -48,45 +48,45 @@ import org.eclipse.cdt.internal.ui.util.Messages;
* The description of an extension to the
* <code>org.eclipse.cdt.ui.completionProposalComputer</code> extension point. Instances are
* immutable. Instances can be obtained from a {@link CompletionProposalComputerRegistry}.
- *
+ *
* @see CompletionProposalComputerRegistry
* @since 4.0
*/
final class CompletionProposalComputerDescriptor {
/** The default category id. */
- private static final String DEFAULT_CATEGORY_ID= "org.eclipse.cdt.ui.defaultProposalCategory"; //$NON-NLS-1$
+ private static final String DEFAULT_CATEGORY_ID = "org.eclipse.cdt.ui.defaultProposalCategory"; //$NON-NLS-1$
/** The extension schema name of the category id attribute. */
- private static final String CATEGORY_ID= "categoryId"; //$NON-NLS-1$
+ private static final String CATEGORY_ID = "categoryId"; //$NON-NLS-1$
/** The extension schema name of the partition type attribute. */
- private static final String TYPE= "type"; //$NON-NLS-1$
+ private static final String TYPE = "type"; //$NON-NLS-1$
/** The extension schema name of the class attribute. */
- private static final String CLASS= "class"; //$NON-NLS-1$
+ private static final String CLASS = "class"; //$NON-NLS-1$
/** The extension schema name of the activate attribute. */
- private static final String ACTIVATE= "activate"; //$NON-NLS-1$
+ private static final String ACTIVATE = "activate"; //$NON-NLS-1$
/** The extension schema name of the partition child elements. */
- private static final String PARTITION= "partition"; //$NON-NLS-1$
+ private static final String PARTITION = "partition"; //$NON-NLS-1$
/** Set of Java partition types. */
private static final Set<String> PARTITION_SET;
/** The name of the performance event used to trace extensions. */
- private static final String PERFORMANCE_EVENT= CUIPlugin.getPluginId() + "/perf/content_assist/extensions"; //$NON-NLS-1$
+ private static final String PERFORMANCE_EVENT = CUIPlugin.getPluginId() + "/perf/content_assist/extensions"; //$NON-NLS-1$
/**
* If <code>true</code>, execution time of extensions is measured and the data forwarded to
* core's {@link PerformanceStats} service.
*/
- private static final boolean MEASURE_PERFORMANCE= PerformanceStats.isEnabled(PERFORMANCE_EVENT);
-
+ private static final boolean MEASURE_PERFORMANCE = PerformanceStats.isEnabled(PERFORMANCE_EVENT);
+
/* log constants */
- private static final String COMPUTE_COMPLETION_PROPOSALS= "computeCompletionProposals()"; //$NON-NLS-1$
- private static final String COMPUTE_CONTEXT_INFORMATION= "computeContextInformation()"; //$NON-NLS-1$
- private static final String SESSION_STARTED= "sessionStarted()"; //$NON-NLS-1$
- private static final String SESSION_ENDED= "sessionEnded()"; //$NON-NLS-1$
-
+ private static final String COMPUTE_COMPLETION_PROPOSALS = "computeCompletionProposals()"; //$NON-NLS-1$
+ private static final String COMPUTE_CONTEXT_INFORMATION = "computeContextInformation()"; //$NON-NLS-1$
+ private static final String SESSION_STARTED = "sessionStarted()"; //$NON-NLS-1$
+ private static final String SESSION_ENDED = "sessionEnded()"; //$NON-NLS-1$
+
static {
- Set<String> partitions= new HashSet<String>();
+ Set<String> partitions = new HashSet<String>();
partitions.add(IDocument.DEFAULT_CONTENT_TYPE);
partitions.addAll(Arrays.asList(ICPartitions.ALL_CPARTITIONS));
-
- PARTITION_SET= Collections.unmodifiableSet(partitions);
+
+ PARTITION_SET = Collections.unmodifiableSet(partitions);
}
/** The identifier of the extension. */
@@ -114,70 +114,71 @@ final class CompletionProposalComputerDescriptor {
* We start timing execution after the first session because the first may take
* longer due to plug-in activation and initialization.
*/
- private boolean fIsReportingDelay= false;
+ private boolean fIsReportingDelay = false;
/** The start of the last operation. */
private long fStart;
/**
* Creates a new descriptor.
- *
+ *
* @param element the configuration element to read
* @param registry the computer registry creating this descriptor
* @param categories the categories
* @throws InvalidRegistryObjectException if this extension is no longer valid
* @throws CoreException if the configuration element is invalid
*/
- CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List<CompletionProposalCategory> categories) throws InvalidRegistryObjectException, CoreException {
+ CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry,
+ List<CompletionProposalCategory> categories) throws InvalidRegistryObjectException, CoreException {
Assert.isNotNull(registry);
Assert.isNotNull(element);
-
- fRegistry= registry;
- fElement= element;
- IExtension extension= element.getDeclaringExtension();
- fId= extension.getUniqueIdentifier();
+
+ fRegistry = registry;
+ fElement = element;
+ IExtension extension = element.getDeclaringExtension();
+ fId = extension.getUniqueIdentifier();
checkNotNull(fId, "id"); //$NON-NLS-1$
- String name= extension.getLabel();
+ String name = extension.getLabel();
if (name.length() == 0)
- fName= fId;
+ fName = fId;
else
- fName= name;
-
- Set<String> partitions= new HashSet<String>();
- IConfigurationElement[] children= element.getChildren(PARTITION);
+ fName = name;
+
+ Set<String> partitions = new HashSet<String>();
+ IConfigurationElement[] children = element.getChildren(PARTITION);
if (children.length == 0) {
- fPartitions= PARTITION_SET; // add to all partition types if no partition is configured
+ fPartitions = PARTITION_SET; // add to all partition types if no partition is configured
} else {
for (IConfigurationElement element2 : children) {
- String type= element2.getAttribute(TYPE);
+ String type = element2.getAttribute(TYPE);
checkNotNull(type, TYPE);
partitions.add(type);
}
- fPartitions= Collections.unmodifiableSet(partitions);
+ fPartitions = Collections.unmodifiableSet(partitions);
}
-
- String activateAttribute= element.getAttribute(ACTIVATE);
- fActivate= Boolean.valueOf(activateAttribute).booleanValue();
- fClass= element.getAttribute(CLASS);
+ String activateAttribute = element.getAttribute(ACTIVATE);
+ fActivate = Boolean.valueOf(activateAttribute).booleanValue();
+
+ fClass = element.getAttribute(CLASS);
checkNotNull(fClass, CLASS);
-
- String categoryId= element.getAttribute(CATEGORY_ID);
+
+ String categoryId = element.getAttribute(CATEGORY_ID);
if (categoryId == null)
- categoryId= DEFAULT_CATEGORY_ID;
- CompletionProposalCategory category= null;
+ categoryId = DEFAULT_CATEGORY_ID;
+ CompletionProposalCategory category = null;
for (CompletionProposalCategory cat : categories) {
if (cat.getId().equals(categoryId)) {
- category= cat;
+ category = cat;
break;
}
}
if (category == null) {
// create a category if it does not exist
- fCategory= new CompletionProposalCategory(categoryId, fName, registry);
+ fCategory = new CompletionProposalCategory(categoryId, fName, registry);
categories.add(fCategory);
} else {
- fCategory= category;
+ fCategory = category;
}
}
@@ -190,9 +191,10 @@ final class CompletionProposalComputerDescriptor {
*/
private void checkNotNull(Object obj, String attribute) throws CoreException {
if (obj == null) {
- Object[] args= { getId(), fElement.getContributor().getName(), attribute };
- String message= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
- IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null);
+ Object[] args = { getId(), fElement.getContributor().getName(), attribute };
+ String message = Messages
+ .format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
+ IStatus status = new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null);
CUIPlugin.log(status);
throw new CoreException(status);
}
@@ -209,48 +211,49 @@ final class CompletionProposalComputerDescriptor {
/**
* Returns the name of the described extension.
- *
+ *
* @return Returns the name
*/
public String getName() {
return fName;
}
-
+
/**
* Returns the partition types of the described extension.
- *
+ *
* @return the set of partition types (element type: {@link String})
*/
public Set<String> getPartitions() {
return fPartitions;
}
-
+
/**
* Returns a cached instance of the computer as described in the
* extension's xml. The computer is
* {@link #createComputer() created} the first time that this method
* is called and then cached.
- *
+ *
* @return a new instance of the completion proposal computer as
* described by this descriptor
* @throws CoreException if the creation fails
* @throws InvalidRegistryObjectException if the extension is not
* valid any longer (e.g. due to plug-in unloading)
*/
- private synchronized ICompletionProposalComputer getComputer() throws CoreException, InvalidRegistryObjectException {
+ private synchronized ICompletionProposalComputer getComputer()
+ throws CoreException, InvalidRegistryObjectException {
if (fComputer == null && (fActivate || isPluginLoaded()))
- fComputer= createComputer();
+ fComputer = createComputer();
return fComputer;
}
private boolean isPluginLoaded() {
- Bundle bundle= getBundle();
+ Bundle bundle = getBundle();
return bundle != null && bundle.getState() == Bundle.ACTIVE;
}
private Bundle getBundle() {
- String namespace= fElement.getDeclaringExtension().getContributor().getName();
- Bundle bundle= Platform.getBundle(namespace);
+ String namespace = fElement.getDeclaringExtension().getContributor().getName();
+ Bundle bundle = Platform.getBundle(namespace);
return bundle;
}
@@ -261,7 +264,7 @@ final class CompletionProposalComputerDescriptor {
* and {@linkplain #computeContextInformation}
* methods. These delegate the functionality to the contributed
* computer, but handle instance creation and any exceptions thrown.
- *
+ *
* @return a new instance of the completion proposal computer as
* described by this descriptor
* @throws CoreException if the creation fails
@@ -271,46 +274,47 @@ final class CompletionProposalComputerDescriptor {
public ICompletionProposalComputer createComputer() throws CoreException, InvalidRegistryObjectException {
return (ICompletionProposalComputer) fElement.createExecutableExtension(CLASS);
}
-
+
/**
* Safely computes completion proposals through the described extension. If the extension
* is disabled, throws an exception or otherwise does not adhere to the contract described in
* {@link ICompletionProposalComputer}, an empty list is returned.
- *
+ *
* @param context the invocation context passed on to the extension
* @param monitor the progress monitor passed on to the extension
* @return the list of computed completion proposals (element type:
* {@link org.eclipse.jface.text.contentassist.ICompletionProposal})
*/
- public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
if (!isEnabled())
return Collections.emptyList();
IStatus status;
try {
- ICompletionProposalComputer computer= getComputer();
+ ICompletionProposalComputer computer = getComputer();
if (computer == null) // not active yet
return Collections.emptyList();
-
+
try {
- PerformanceStats stats= startMeter(context, computer);
- List<ICompletionProposal> proposals= computer.computeCompletionProposals(context, monitor);
+ PerformanceStats stats = startMeter(context, computer);
+ List<ICompletionProposal> proposals = computer.computeCompletionProposals(context, monitor);
stopMeter(stats, COMPUTE_COMPLETION_PROPOSALS);
-
+
if (proposals != null) {
- fLastError= computer.getErrorMessage();
+ fLastError = computer.getErrorMessage();
return proposals;
}
} finally {
- fIsReportingDelay= true;
+ fIsReportingDelay = true;
}
- status= createAPIViolationStatus(COMPUTE_COMPLETION_PROPOSALS);
+ status = createAPIViolationStatus(COMPUTE_COMPLETION_PROPOSALS);
} catch (InvalidRegistryObjectException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} catch (CoreException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} catch (RuntimeException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} finally {
monitor.done();
}
@@ -324,47 +328,47 @@ final class CompletionProposalComputerDescriptor {
* Safely computes context information objects through the described extension. If the extension
* is disabled, throws an exception or otherwise does not adhere to the contract described in
* {@link ICompletionProposalComputer}, an empty list is returned.
- *
+ *
* @param context the invocation context passed on to the extension
* @param monitor the progress monitor passed on to the extension
* @return the list of computed context information objects (element type:
* {@link org.eclipse.jface.text.contentassist.IContextInformation})
*/
- public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
if (!isEnabled())
return Collections.emptyList();
-
+
IStatus status;
try {
- ICompletionProposalComputer computer= getComputer();
+ ICompletionProposalComputer computer = getComputer();
if (computer == null) // not active yet
return Collections.emptyList();
- PerformanceStats stats= startMeter(context, computer);
- List<IContextInformation> proposals= computer.computeContextInformation(context, monitor);
+ PerformanceStats stats = startMeter(context, computer);
+ List<IContextInformation> proposals = computer.computeContextInformation(context, monitor);
stopMeter(stats, COMPUTE_CONTEXT_INFORMATION);
-
+
if (proposals != null) {
- fLastError= computer.getErrorMessage();
+ fLastError = computer.getErrorMessage();
return proposals;
}
-
- status= createAPIViolationStatus(COMPUTE_CONTEXT_INFORMATION);
+
+ status = createAPIViolationStatus(COMPUTE_CONTEXT_INFORMATION);
} catch (InvalidRegistryObjectException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} catch (CoreException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} catch (RuntimeException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} finally {
monitor.done();
}
-
+
fRegistry.informUser(this, status);
-
+
return Collections.emptyList();
}
-
/**
* Notifies the described extension of a proposal computation session start.
@@ -376,26 +380,26 @@ final class CompletionProposalComputerDescriptor {
public void sessionStarted() {
if (!isEnabled())
return;
-
+
IStatus status;
try {
- ICompletionProposalComputer computer= getComputer();
+ ICompletionProposalComputer computer = getComputer();
if (computer == null) // not active yet
return;
-
- PerformanceStats stats= startMeter(SESSION_STARTED, computer);
+
+ PerformanceStats stats = startMeter(SESSION_STARTED, computer);
computer.sessionStarted();
stopMeter(stats, SESSION_ENDED);
-
+
return;
} catch (InvalidRegistryObjectException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} catch (CoreException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} catch (RuntimeException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
}
-
+
fRegistry.informUser(this, status);
}
@@ -412,21 +416,21 @@ final class CompletionProposalComputerDescriptor {
IStatus status;
try {
- ICompletionProposalComputer computer= getComputer();
+ ICompletionProposalComputer computer = getComputer();
if (computer == null) // not active yet
return;
- PerformanceStats stats= startMeter(SESSION_ENDED, computer);
+ PerformanceStats stats = startMeter(SESSION_ENDED, computer);
computer.sessionEnded();
stopMeter(stats, SESSION_ENDED);
return;
} catch (InvalidRegistryObjectException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} catch (CoreException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
} catch (RuntimeException x) {
- status= createExceptionStatus(x);
+ status = createExceptionStatus(x);
}
fRegistry.informUser(this, status);
@@ -435,16 +439,16 @@ final class CompletionProposalComputerDescriptor {
private PerformanceStats startMeter(Object context, ICompletionProposalComputer computer) {
final PerformanceStats stats;
if (MEASURE_PERFORMANCE) {
- stats= PerformanceStats.getStats(PERFORMANCE_EVENT, computer);
+ stats = PerformanceStats.getStats(PERFORMANCE_EVENT, computer);
stats.startRun(context.toString());
} else {
- stats= null;
+ stats = null;
}
-
+
if (fIsReportingDelay) {
- fStart= System.currentTimeMillis();
+ fStart = System.currentTimeMillis();
}
-
+
return stats;
}
@@ -452,16 +456,16 @@ final class CompletionProposalComputerDescriptor {
if (MEASURE_PERFORMANCE) {
stats.endRun();
if (stats.isFailure()) {
- IStatus status= createPerformanceStatus(operation);
+ IStatus status = createPerformanceStatus(operation);
fRegistry.informUser(this, status);
return;
}
}
-
+
if (fIsReportingDelay) {
- long current= System.currentTimeMillis();
+ long current = System.currentTimeMillis();
if (current - fStart > getMaxDelay()) {
- IStatus status= createPerformanceStatus(operation);
+ IStatus status = createPerformanceStatus(operation);
fRegistry.informUser(this, status);
}
}
@@ -469,80 +473,83 @@ final class CompletionProposalComputerDescriptor {
/**
* Independently of the {@link PerformanceStats} service, any operation that takes longer than
- * the milliseconds returned by this method will be flagged as an violation. This timeout does
- * not apply to the first invocation, as it may take longer due to plug-in initialization etc.
- * See also {@link #fIsReportingDelay}.
- * <p>
- * The max duration is stored in the preference {@link ContentAssistPreference#PROPOSALS_TIMEOUT}
- *
- * @return the max duration (ms) a proposal computer is allowed to compute until it is
+ * the milliseconds returned by this method will be flagged as an violation. This timeout does
+ * not apply to the first invocation, as it may take longer due to plug-in initialization etc.
+ * See also {@link #fIsReportingDelay}.
+ * <p>
+ * The max duration is stored in the preference {@link ContentAssistPreference#PROPOSALS_TIMEOUT}
+ *
+ * @return the max duration (ms) a proposal computer is allowed to compute until it is
* assumed to be buggy and will be disabled.<br>
* Is always > 0
*/
private long getMaxDelay() {
- long timeout = CUIPlugin.getDefault().getPreferenceStore().getLong(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT);
- if (timeout <= 0L)
- return Long.MAX_VALUE;
- return timeout;
+ long timeout = CUIPlugin.getDefault().getPreferenceStore()
+ .getLong(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT);
+ if (timeout <= 0L)
+ return Long.MAX_VALUE;
+ return timeout;
}
-
+
private IStatus createExceptionStatus(InvalidRegistryObjectException x) {
// extension has become invalid - log & disable
- String blame= createBlameMessage();
- String reason= ContentAssistMessages.CompletionProposalComputerDescriptor_reason_invalid;
+ String blame = createBlameMessage();
+ String reason = ContentAssistMessages.CompletionProposalComputerDescriptor_reason_invalid;
return new Status(IStatus.INFO, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, x); //$NON-NLS-1$
}
private IStatus createExceptionStatus(CoreException x) {
// unable to instantiate the extension - log & disable
- String blame= createBlameMessage();
- String reason= ContentAssistMessages.CompletionProposalComputerDescriptor_reason_instantiation;
+ String blame = createBlameMessage();
+ String reason = ContentAssistMessages.CompletionProposalComputerDescriptor_reason_instantiation;
return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, x); //$NON-NLS-1$
}
-
+
private IStatus createExceptionStatus(RuntimeException x) {
// misbehaving extension - log & disable
- String blame= createBlameMessage();
- String reason= ContentAssistMessages.CompletionProposalComputerDescriptor_reason_runtime_ex;
+ String blame = createBlameMessage();
+ String reason = ContentAssistMessages.CompletionProposalComputerDescriptor_reason_runtime_ex;
return new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, x); //$NON-NLS-1$
}
private IStatus createAPIViolationStatus(String operation) {
- String blame= createBlameMessage();
- Object[] args= {operation};
- String reason= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_reason_API, args);
+ String blame = createBlameMessage();
+ Object[] args = { operation };
+ String reason = Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_reason_API, args);
return new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, null); //$NON-NLS-1$
}
private IStatus createPerformanceStatus(String operation) {
- String blame= createBlameMessage();
- Object[] args= {operation};
- String reason= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_reason_performance, args);
+ String blame = createBlameMessage();
+ Object[] args = { operation };
+ String reason = Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_reason_performance,
+ args);
return new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, null); //$NON-NLS-1$
}
private String createBlameMessage() {
- Object[] args= { getName(), fElement.getDeclaringExtension().getContributor().getName() };
- String disable= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_blame_message, args);
+ Object[] args = { getName(), fElement.getDeclaringExtension().getContributor().getName() };
+ String disable = Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_blame_message,
+ args);
return disable;
}
-
+
/**
* Returns the enablement state of the described extension.
- *
+ *
* @return the enablement state of the described extension
*/
private boolean isEnabled() {
return fCategory.isEnabled();
}
-
+
CompletionProposalCategory getCategory() {
return fCategory;
}
/**
* Returns the error message from the described extension.
- *
+ *
* @return the error message from the described extension
*/
public String getErrorMessage() {
@@ -551,15 +558,15 @@ final class CompletionProposalComputerDescriptor {
/**
* Returns the contributor of the described extension.
- *
+ *
* @return the contributor of the described extension
*/
- IContributor getContributor() {
- try {
- return fElement.getContributor();
- } catch (InvalidRegistryObjectException e) {
- return null;
- }
- }
-
+ IContributor getContributor() {
+ try {
+ return fElement.getContributor();
+ } catch (InvalidRegistryObjectException e) {
+ return null;
+ }
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java
index 32be92ccb0f..ce6a56e1636 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java
@@ -54,61 +54,62 @@ import org.eclipse.cdt.internal.ui.util.Messages;
* A registry for all extensions to the
* <code>org.eclipse.cdt.ui.completionProposalComputer</code>
* extension point.
- *
+ *
* @since 4.0
*/
public final class CompletionProposalComputerRegistry {
- private static final String EXTENSION_POINT= "completionProposalComputer"; //$NON-NLS-1$
-
+ private static final String EXTENSION_POINT = "completionProposalComputer"; //$NON-NLS-1$
+
/** The singleton instance. */
- private static CompletionProposalComputerRegistry fgSingleton= null;
-
+ private static CompletionProposalComputerRegistry fgSingleton = null;
+
/**
* Returns the default computer registry.
* <p>
* TODO keep this or add some other singleton, e.g. CUIPlugin?
* </p>
- *
+ *
* @return the singleton instance
*/
public static synchronized CompletionProposalComputerRegistry getDefault() {
if (fgSingleton == null) {
- fgSingleton= new CompletionProposalComputerRegistry();
+ fgSingleton = new CompletionProposalComputerRegistry();
}
-
+
return fgSingleton;
}
-
+
/**
* The sets of descriptors, grouped by partition type (key type:
* {@link String}, value type:
* {@linkplain List List&lt;CompletionProposalComputerDescriptor&gt;}).
*/
- private final Map<String, List<CompletionProposalComputerDescriptor>> fDescriptorsByPartition= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
+ private final Map<String, List<CompletionProposalComputerDescriptor>> fDescriptorsByPartition = new HashMap<String, List<CompletionProposalComputerDescriptor>>();
/**
* Unmodifiable versions of the sets stored in
* <code>fDescriptorsByPartition</code> (key type: {@link String},
* value type:
* {@linkplain List List&lt;CompletionProposalComputerDescriptor&gt;}).
*/
- private final Map<String, List<CompletionProposalComputerDescriptor>> fPublicDescriptorsByPartition= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
+ private final Map<String, List<CompletionProposalComputerDescriptor>> fPublicDescriptorsByPartition = new HashMap<String, List<CompletionProposalComputerDescriptor>>();
/**
* All descriptors (element type:
* {@link CompletionProposalComputerDescriptor}).
*/
- private final List<CompletionProposalComputerDescriptor> fDescriptors= new ArrayList<CompletionProposalComputerDescriptor>();
+ private final List<CompletionProposalComputerDescriptor> fDescriptors = new ArrayList<CompletionProposalComputerDescriptor>();
/**
* Unmodifiable view of <code>fDescriptors</code>
*/
- private final List<CompletionProposalComputerDescriptor> fPublicDescriptors= Collections.unmodifiableList(fDescriptors);
-
- private final List<CompletionProposalCategory> fCategories= new ArrayList<CompletionProposalCategory>();
- private final List<CompletionProposalCategory> fPublicCategories= Collections.unmodifiableList(fCategories);
+ private final List<CompletionProposalComputerDescriptor> fPublicDescriptors = Collections
+ .unmodifiableList(fDescriptors);
+
+ private final List<CompletionProposalCategory> fCategories = new ArrayList<CompletionProposalCategory>();
+ private final List<CompletionProposalCategory> fPublicCategories = Collections.unmodifiableList(fCategories);
/**
* <code>true</code> if this registry has been loaded.
*/
- private boolean fLoaded= false;
+ private boolean fLoaded = false;
/**
* Creates a new instance.
@@ -134,7 +135,7 @@ public final class CompletionProposalComputerRegistry {
* computing proposals, it is therefore imperative to copy the returned list before iterating
* over it.
* </p>
- *
+ *
* @param partition
* the partition type for which to retrieve the computer descriptors
* @return the list of extensions to the <code>completionProposalComputer</code> extension
@@ -142,8 +143,8 @@ public final class CompletionProposalComputerRegistry {
*/
List<CompletionProposalComputerDescriptor> getProposalComputerDescriptors(String partition) {
ensureExtensionPointRead();
- List<CompletionProposalComputerDescriptor> result= fPublicDescriptorsByPartition.get(partition);
- if (result == null)
+ List<CompletionProposalComputerDescriptor> result = fPublicDescriptorsByPartition.get(partition);
+ if (result == null)
return Collections.emptyList();
return result;
}
@@ -159,7 +160,7 @@ public final class CompletionProposalComputerRegistry {
* computing proposals, it is therefore imperative to copy the returned list before iterating
* over it.
* </p>
- *
+ *
* @return the list of extensions to the <code>completionProposalComputer</code> extension
* point (element type: {@link CompletionProposalComputerDescriptor})
*/
@@ -167,7 +168,7 @@ public final class CompletionProposalComputerRegistry {
ensureExtensionPointRead();
return fPublicDescriptors;
}
-
+
/**
* Returns the list of proposal categories contributed to the
* <code>completionProposalComputer</code> extension point.
@@ -177,7 +178,7 @@ public final class CompletionProposalComputerRegistry {
* There are no duplicate elements in the returned list. The returned list may change if
* plug-ins are loaded or unloaded while the application is running.
* </p>
- *
+ *
* @return list of proposal categories contributed to the
* <code>completionProposalComputer</code> extension point (element type:
* {@link CompletionProposalCategory})
@@ -194,8 +195,8 @@ public final class CompletionProposalComputerRegistry {
private void ensureExtensionPointRead() {
boolean reload;
synchronized (this) {
- reload= !fLoaded;
- fLoaded= true;
+ reload = !fLoaded;
+ fLoaded = true;
}
if (reload)
reload();
@@ -209,51 +210,54 @@ public final class CompletionProposalComputerRegistry {
* </p>
*/
public void reload() {
- IExtensionRegistry registry= Platform.getExtensionRegistry();
- List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT)));
-
- Map<String, List<CompletionProposalComputerDescriptor>> map= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
- List<CompletionProposalComputerDescriptor> all= new ArrayList<CompletionProposalComputerDescriptor>();
-
- List<CompletionProposalCategory> categories= getCategories(elements);
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ List<IConfigurationElement> elements = new ArrayList<IConfigurationElement>(
+ Arrays.asList(registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT)));
+
+ Map<String, List<CompletionProposalComputerDescriptor>> map = new HashMap<String, List<CompletionProposalComputerDescriptor>>();
+ List<CompletionProposalComputerDescriptor> all = new ArrayList<CompletionProposalComputerDescriptor>();
+
+ List<CompletionProposalCategory> categories = getCategories(elements);
for (IConfigurationElement element : elements) {
try {
- CompletionProposalComputerDescriptor desc= new CompletionProposalComputerDescriptor(element, this, categories);
- Set<String> partitions= desc.getPartitions();
+ CompletionProposalComputerDescriptor desc = new CompletionProposalComputerDescriptor(element, this,
+ categories);
+ Set<String> partitions = desc.getPartitions();
for (Object element2 : partitions) {
- String partition= (String) element2;
- List<CompletionProposalComputerDescriptor> list= map.get(partition);
+ String partition = (String) element2;
+ List<CompletionProposalComputerDescriptor> list = map.get(partition);
if (list == null) {
- list= new ArrayList<CompletionProposalComputerDescriptor>();
+ list = new ArrayList<CompletionProposalComputerDescriptor>();
map.put(partition, list);
}
list.add(desc);
}
all.add(desc);
-
+
} catch (CoreException x) {
/*
* Element is not valid any longer as the contributing plug-in was unloaded or for
* some other reason. Do not include the extension in the list and inform the user
* about it.
*/
- Object[] args= {element.toString()};
- String message= Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_invalid_message, args);
- IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, x);
+ Object[] args = { element.toString() };
+ String message = Messages
+ .format(ContentAssistMessages.CompletionProposalComputerRegistry_invalid_message, args);
+ IStatus status = new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, x);
informUser(status);
}
}
-
+
synchronized (this) {
fCategories.clear();
fCategories.addAll(categories);
-
- Set<String> partitions= map.keySet();
+
+ Set<String> partitions = map.keySet();
fDescriptorsByPartition.keySet().retainAll(partitions);
fPublicDescriptorsByPartition.keySet().retainAll(partitions);
for (String partition : partitions) {
- List<CompletionProposalComputerDescriptor> old= fDescriptorsByPartition.get(partition);
- List<CompletionProposalComputerDescriptor> current= map.get(partition);
+ List<CompletionProposalComputerDescriptor> old = fDescriptorsByPartition.get(partition);
+ List<CompletionProposalComputerDescriptor> current = map.get(partition);
if (old != null) {
old.clear();
old.addAll(current);
@@ -262,43 +266,43 @@ public final class CompletionProposalComputerRegistry {
fPublicDescriptorsByPartition.put(partition, Collections.unmodifiableList(current));
}
}
-
+
fDescriptors.clear();
fDescriptors.addAll(all);
}
}
private List<CompletionProposalCategory> getCategories(List<IConfigurationElement> elements) {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- String preference= store.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
- Set<String> disabled= new HashSet<String>();
- StringTokenizer tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ String preference = store.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
+ Set<String> disabled = new HashSet<String>();
+ StringTokenizer tok = new StringTokenizer(preference, "\0"); //$NON-NLS-1$
while (tok.hasMoreTokens())
disabled.add(tok.nextToken());
- Map<String, Integer> ordered= new HashMap<String, Integer>();
- preference= store.getString(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
- tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$
+ Map<String, Integer> ordered = new HashMap<String, Integer>();
+ preference = store.getString(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
+ tok = new StringTokenizer(preference, "\0"); //$NON-NLS-1$
while (tok.hasMoreTokens()) {
- StringTokenizer inner= new StringTokenizer(tok.nextToken(), ":"); //$NON-NLS-1$
- String id= inner.nextToken();
- int rank= Integer.parseInt(inner.nextToken());
+ StringTokenizer inner = new StringTokenizer(tok.nextToken(), ":"); //$NON-NLS-1$
+ String id = inner.nextToken();
+ int rank = Integer.parseInt(inner.nextToken());
ordered.put(id, Integer.valueOf(rank));
}
-
- List<CompletionProposalCategory> categories= new ArrayList<CompletionProposalCategory>();
- for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) {
- IConfigurationElement element= iter.next();
+
+ List<CompletionProposalCategory> categories = new ArrayList<CompletionProposalCategory>();
+ for (Iterator<IConfigurationElement> iter = elements.iterator(); iter.hasNext();) {
+ IConfigurationElement element = iter.next();
try {
if (element.getName().equals("proposalCategory")) { //$NON-NLS-1$
iter.remove(); // remove from list to leave only computers
-
- CompletionProposalCategory category= new CompletionProposalCategory(element, this);
+
+ CompletionProposalCategory category = new CompletionProposalCategory(element, this);
categories.add(category);
category.setIncluded(!disabled.contains(category.getId()));
- Integer rank= ordered.get(category.getId());
+ Integer rank = ordered.get(category.getId());
if (rank != null) {
- int r= rank.intValue();
- boolean separate= r < 0xffff;
+ int r = rank.intValue();
+ boolean separate = r < 0xffff;
category.setSeparateCommand(separate);
category.setSortOrder(r);
}
@@ -309,9 +313,10 @@ public final class CompletionProposalComputerRegistry {
* some other reason. Do not include the extension in the list and inform the user
* about it.
*/
- Object[] args= {element.toString()};
- String message= Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_invalid_message, args);
- IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, x);
+ Object[] args = { element.toString() };
+ String message = Messages
+ .format(ContentAssistMessages.CompletionProposalComputerRegistry_invalid_message, args);
+ IStatus status = new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, x);
informUser(status);
}
}
@@ -320,80 +325,87 @@ public final class CompletionProposalComputerRegistry {
/**
* Log the status and inform the user about a misbehaving extension.
- *
+ *
* @param descriptor the descriptor of the misbehaving extension
* @param status a status object that will be logged
*/
void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) {
CUIPlugin.log(status);
- String title= ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
- CompletionProposalCategory category= descriptor.getCategory();
- IContributor culprit= descriptor.getContributor();
- Set<String> affectedPlugins= getAffectedContributors(category, culprit);
-
+ String title = ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
+ CompletionProposalCategory category = descriptor.getCategory();
+ IContributor culprit = descriptor.getContributor();
+ Set<String> affectedPlugins = getAffectedContributors(category, culprit);
+
final String avoidHint;
- final String culpritName= culprit == null ? null : culprit.getName();
+ final String culpritName = culprit == null ? null : culprit.getName();
if (affectedPlugins.isEmpty()) {
if (CUIPlugin.PLUGIN_ID.equals(culpritName)) {
// don't warn about internal computers
return;
}
- avoidHint= Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] {culpritName, category.getDisplayName()});
+ avoidHint = Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_messageAvoidanceHint,
+ new Object[] { culpritName, category.getDisplayName() });
} else {
- avoidHint= Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] {culpritName, category.getDisplayName(), toString(affectedPlugins)});
- }
- String message= status.getMessage();
- // inlined from MessageDialog.openError
- MessageDialog dialog = new MessageDialog(CUIPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {
- @Override
+ avoidHint = Messages.format(
+ ContentAssistMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning,
+ new Object[] { culpritName, category.getDisplayName(), toString(affectedPlugins) });
+ }
+ String message = status.getMessage();
+ // inlined from MessageDialog.openError
+ MessageDialog dialog = new MessageDialog(CUIPlugin.getActiveWorkbenchShell(), title, null /* default image */,
+ message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {
+ @Override
protected Control createCustomArea(Composite parent) {
- Link link= new Link(parent, SWT.NONE);
- link.setText(avoidHint);
- link.addSelectionListener(new SelectionAdapter() {
- @Override
+ Link link = new Link(parent, SWT.NONE);
+ link.setText(avoidHint);
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
- }
- });
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gridData.widthHint= this.getMinimumMessageWidth();
+ PreferencesUtil
+ .createPreferenceDialogOn(getShell(),
+ "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
+ .open();
+ }
+ });
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ gridData.widthHint = this.getMinimumMessageWidth();
link.setLayoutData(gridData);
- return link;
- }
- };
- dialog.open();
+ return link;
+ }
+ };
+ dialog.open();
}
/**
- * Returns the names of contributors affected by disabling a category.
- *
+ * Returns the names of contributors affected by disabling a category.
+ *
* @param category the category that would be disabled
* @param culprit the culprit plug-in, which is not included in the returned list
* @return the names of the contributors other than <code>culprit</code> that contribute to <code>category</code> (element type: {@link String})
*/
private Set<String> getAffectedContributors(CompletionProposalCategory category, IContributor culprit) {
- Set<String> affectedPlugins= new HashSet<String>();
- for (CompletionProposalComputerDescriptor desc : getProposalComputerDescriptors()) {
- CompletionProposalCategory cat= desc.getCategory();
- if (cat.equals(category)) {
- IContributor contributor= desc.getContributor();
- if (contributor != null && !culprit.equals(contributor))
- affectedPlugins.add(contributor.getName());
- }
- }
- return affectedPlugins;
- }
+ Set<String> affectedPlugins = new HashSet<String>();
+ for (CompletionProposalComputerDescriptor desc : getProposalComputerDescriptors()) {
+ CompletionProposalCategory cat = desc.getCategory();
+ if (cat.equals(category)) {
+ IContributor contributor = desc.getContributor();
+ if (contributor != null && !culprit.equals(contributor))
+ affectedPlugins.add(contributor.getName());
+ }
+ }
+ return affectedPlugins;
+ }
- private Object toString(Collection<String> collection) {
- // strip brackets off AbstractCollection.toString()
- String string= collection.toString();
- return string.substring(1, string.length() - 1);
- }
+ private Object toString(Collection<String> collection) {
+ // strip brackets off AbstractCollection.toString()
+ String string = collection.toString();
+ return string.substring(1, string.length() - 1);
+ }
private void informUser(IStatus status) {
CUIPlugin.log(status);
- String title= ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
- String message= status.getMessage();
+ String title = ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
+ String message = status.getMessage();
MessageDialog.openError(CUIPlugin.getActiveWorkbenchShell(), title, message);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java
index 2eccbe30127..c22f5ff5716 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java
@@ -22,7 +22,7 @@ import org.eclipse.core.commands.IParameterValues;
/**
* Map of parameters for the specific content assist command.
- *
+ *
* @since 4.0
*/
public final class ContentAssistComputerParameter implements IParameterValues {
@@ -30,9 +30,10 @@ public final class ContentAssistComputerParameter implements IParameterValues {
* @see org.eclipse.core.commands.IParameterValues#getParameterValues()
*/
@Override
- public Map<String,String> getParameterValues() {
- Collection<CompletionProposalCategory> descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
- Map<String, String> map= new HashMap<String, String>(descriptors.size());
+ public Map<String, String> getParameterValues() {
+ Collection<CompletionProposalCategory> descriptors = CompletionProposalComputerRegistry.getDefault()
+ .getProposalCategories();
+ Map<String, String> map = new HashMap<String, String>(descriptors.size());
for (CompletionProposalCategory category : descriptors) {
map.put(category.getDisplayName(), category.getId());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHandler.java
index 0d5cbd87662..b3b2d15b833 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHandler.java
@@ -27,12 +27,13 @@ import org.eclipse.cdt.internal.ui.editor.SpecificContentAssistExecutor;
/**
* A command handler to invoke a content assist for a specific proposal category.
- *
+ *
* @since 4.0
*/
public final class ContentAssistHandler extends AbstractHandler {
- private final SpecificContentAssistExecutor fExecutor= new SpecificContentAssistExecutor(CompletionProposalComputerRegistry.getDefault());
-
+ private final SpecificContentAssistExecutor fExecutor = new SpecificContentAssistExecutor(
+ CompletionProposalComputerRegistry.getDefault());
+
public ContentAssistHandler() {
}
@@ -41,25 +42,25 @@ public final class ContentAssistHandler extends AbstractHandler {
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- ITextEditor editor= getActiveEditor();
+ ITextEditor editor = getActiveEditor();
if (editor == null)
return null;
-
- String categoryId= event.getParameter("org.eclipse.cdt.ui.specific_content_assist.category_id"); //$NON-NLS-1$
+
+ String categoryId = event.getParameter("org.eclipse.cdt.ui.specific_content_assist.category_id"); //$NON-NLS-1$
if (categoryId == null)
return null;
-
+
fExecutor.invokeContentAssist(editor, categoryId);
return null;
}
private ITextEditor getActiveEditor() {
- IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
- IWorkbenchPage page= window.getActivePage();
+ IWorkbenchPage page = window.getActivePage();
if (page != null) {
- IEditorPart editor= page.getActiveEditor();
+ IEditorPart editor = page.getActiveEditor();
if (editor instanceof ITextEditor)
return (ITextEditor) editor;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.java
index 8d2dfd93c43..565b0ac5040 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.java
@@ -21,7 +21,7 @@ import org.eclipse.osgi.util.NLS;
*/
public final class ContentAssistMessages extends NLS {
- private static final String BUNDLE_NAME= ContentAssistMessages.class.getName();
+ private static final String BUNDLE_NAME = ContentAssistMessages.class.getName();
static {
NLS.initializeMessages(BUNDLE_NAME, ContentAssistMessages.class);
@@ -37,7 +37,7 @@ public final class ContentAssistMessages extends NLS {
public static String ContentAssistProcessor_all_disabled_preference_link;
public static String ContentAssistProcessor_all_disabled_title;
public static String ContentAssistProcessor_no_completions;
-
+
public static String ContentAssistProcessor_computing_proposals;
public static String ContentAssistProcessor_collecting_proposals;
public static String ContentAssistProcessor_sorting_proposals;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java
index fd241f73084..c157e9e0448 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java
@@ -36,91 +36,91 @@ import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
import org.eclipse.cdt.internal.ui.text.CTextTools;
public class ContentAssistPreference {
-// /** Preference key for content assist auto activation (unused) */
-// public final static String AUTOACTIVATION= "content_assist_autoactivation";
+ // /** Preference key for content assist auto activation (unused) */
+ // public final static String AUTOACTIVATION= "content_assist_autoactivation";
/** Preference key for content assist auto activation delay */
- public final static String AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay"; //$NON-NLS-1$
+ public final static String AUTOACTIVATION_DELAY = "content_assist_autoactivation_delay"; //$NON-NLS-1$
/** Preference key for content assist timeout delay (unused) */
- public final static String TIMEOUT_DELAY= "content_assist_timeout_delay"; //$NON-NLS-1$
+ public final static String TIMEOUT_DELAY = "content_assist_timeout_delay"; //$NON-NLS-1$
/** Preference key for completion proposal timeout */
- public final static String PROPOSALS_TIMEOUT= PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT;
+ public final static String PROPOSALS_TIMEOUT = PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT;
/** Preference key for content assist proposal color */
- public final static String PROPOSALS_FOREGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
+ public final static String PROPOSALS_FOREGROUND = PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
/** Preference key for content assist proposal color */
- public final static String PROPOSALS_BACKGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
+ public final static String PROPOSALS_BACKGROUND = PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
/** Preference key for content assist parameters color */
- public final static String PARAMETERS_FOREGROUND= PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
+ public final static String PARAMETERS_FOREGROUND = PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
/** Preference key for content assist parameters color */
- public final static String PARAMETERS_BACKGROUND= PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
+ public final static String PARAMETERS_BACKGROUND = PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
/** Preference key for content assist auto insert */
- public final static String AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$
+ public final static String AUTOINSERT = "content_assist_autoinsert"; //$NON-NLS-1$
/** Preference key for content assist to insert the common prefix */
- public final static String PREFIX_COMPLETION= "content_assist_prefix_completion"; //$NON-NLS-1$
+ public final static String PREFIX_COMPLETION = "content_assist_prefix_completion"; //$NON-NLS-1$
/** Preference key for content assist to guess function arguments. */
- public final static String GUESS_ARGUMENTS= "content_assist_guess_arguments"; //$NON-NLS-1$
+ public final static String GUESS_ARGUMENTS = "content_assist_guess_arguments"; //$NON-NLS-1$
/** Preference key for C/CPP content assist auto activation triggers */
- public final static String AUTOACTIVATION_TRIGGERS_DOT= "content_assist_autoactivation_trigger_dot"; //$NON-NLS-1$
- public final static String AUTOACTIVATION_TRIGGERS_ARROW= "content_assist_autoactivation_trigger_arrow"; //$NON-NLS-1$
- public final static String AUTOACTIVATION_TRIGGERS_DOUBLECOLON= "content_assist_autoactivation_trigger_doublecolon"; //$NON-NLS-1$
- public final static String AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW= "content_assist_autoactivation_trigger_replace_dot_with_arrow"; //$NON-NLS-1$
+ public final static String AUTOACTIVATION_TRIGGERS_DOT = "content_assist_autoactivation_trigger_dot"; //$NON-NLS-1$
+ public final static String AUTOACTIVATION_TRIGGERS_ARROW = "content_assist_autoactivation_trigger_arrow"; //$NON-NLS-1$
+ public final static String AUTOACTIVATION_TRIGGERS_DOUBLECOLON = "content_assist_autoactivation_trigger_doublecolon"; //$NON-NLS-1$
+ public final static String AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW = "content_assist_autoactivation_trigger_replace_dot_with_arrow"; //$NON-NLS-1$
/** Preference key for display of defaulted parameters in content assist */
public final static String DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT = "content_assist_default_argument_display_parameters_with_default_argument"; //$NON-NLS-1$
/** Preference key for display of default arguments in content assist */
public final static String DEFAULT_ARGUMENT_DISPLAY_ARGUMENTS = "content_assist_default_argument_display_arguments"; //$NON-NLS-1$
-// /** Preference key for visibility of proposals (unused) */
-// public final static String SHOW_DOCUMENTED_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$
+ // /** Preference key for visibility of proposals (unused) */
+ // public final static String SHOW_DOCUMENTED_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$
/** Preference key for alphabetic ordering of proposals */
- public final static String ORDER_PROPOSALS= "content_assist_order_proposals"; //$NON-NLS-1$
-// /** Preference key for case sensitivity of proposals */
-// public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity";
-// /** Preference key for adding includes on code assist (unused) */
-// public final static String ADD_INCLUDE= "content_assist_add_import"; //$NON-NLS-1$
+ public final static String ORDER_PROPOSALS = "content_assist_order_proposals"; //$NON-NLS-1$
+ // /** Preference key for case sensitivity of proposals */
+ // public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity";
+ // /** Preference key for adding includes on code assist (unused) */
+ // public final static String ADD_INCLUDE= "content_assist_add_import"; //$NON-NLS-1$
/** Preference key for completion search scope (unused) */
- public final static String CURRENT_FILE_SEARCH_SCOPE= "content_assist_current_file_search_scope"; //$NON-NLS-1$
+ public final static String CURRENT_FILE_SEARCH_SCOPE = "content_assist_current_file_search_scope"; //$NON-NLS-1$
/** Preference key for completion search scope (unused) */
- public final static String PROJECT_SEARCH_SCOPE= "content_assist_project_search_scope"; //$NON-NLS-1$
+ public final static String PROJECT_SEARCH_SCOPE = "content_assist_project_search_scope"; //$NON-NLS-1$
/** Preference key for completion filtering */
- public final static String PROPOSALS_FILTER= "content_assist_proposal_filter"; //$NON-NLS-1$
+ public final static String PROPOSALS_FILTER = "content_assist_proposal_filter"; //$NON-NLS-1$
/** Key for boolean preference telling whether camel case/underscore matches are to be shown by content assist features or not*/
public static final String SHOW_CAMEL_CASE_MATCHES = "contentAssist.showCamelCaseMatches"; //$NON-NLS-1$
private static Color getColor(IPreferenceStore store, String key, IColorManager manager) {
- RGB rgb= PreferenceConverter.getColor(store, key);
+ RGB rgb = PreferenceConverter.getColor(store, key);
return manager.getColor(rgb);
}
private static Color getColor(IPreferenceStore store, String key) {
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+ CTextTools textTools = CUIPlugin.getDefault().getTextTools();
return getColor(store, key, textTools.getColorManager());
}
private static CContentAssistProcessor getCProcessor(ContentAssistant assistant) {
- IContentAssistProcessor p= assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
+ IContentAssistProcessor p = assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
if (p instanceof CContentAssistProcessor)
- return (CContentAssistProcessor) p;
+ return (CContentAssistProcessor) p;
return null;
}
private static void configureCProcessor(ContentAssistant assistant, IPreferenceStore store) {
- CContentAssistProcessor ccp= getCProcessor(assistant);
+ CContentAssistProcessor ccp = getCProcessor(assistant);
if (ccp == null)
return;
configureActivationCharacters(store, ccp);
-// boolean enabled;
-// enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
-// ccp.restrictProposalsToVisibility(enabled);
-//
-// enabled= store.getBoolean(CASE_SENSITIVITY);
-// ccp.restrictProposalsToMatchingCases(enabled);
+ // boolean enabled;
+ // enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
+ // ccp.restrictProposalsToVisibility(enabled);
+ //
+ // enabled= store.getBoolean(CASE_SENSITIVITY);
+ // ccp.restrictProposalsToMatchingCases(enabled);
-// enabled= store.getBoolean(ORDER_PROPOSALS);
-// ccp.orderProposalsAlphabetically(enabled);
+ // enabled= store.getBoolean(ORDER_PROPOSALS);
+ // ccp.orderProposalsAlphabetically(enabled);
-// enabled= store.getBoolean(ADD_INCLUDE);
-// ccp.allowAddingIncludes(enabled);
+ // enabled= store.getBoolean(ADD_INCLUDE);
+ // ccp.allowAddingIncludes(enabled);
}
private static void configureActivationCharacters(IPreferenceStore store, CContentAssistProcessor ccp) {
@@ -130,7 +130,7 @@ public class ContentAssistPreference {
boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
if (useDotAsTrigger)
- triggers = "."; //$NON-NLS-1$
+ triggers = "."; //$NON-NLS-1$
if (useArrowAsTrigger)
triggers += ">"; //$NON-NLS-1$
if (useDoubleColonAsTrigger)
@@ -147,9 +147,9 @@ public class ContentAssistPreference {
triggers += "."; //$NON-NLS-1$
ccp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
- triggers = ""; //$NON-NLS-1$
+ triggers = ""; //$NON-NLS-1$
if (dotTriggersAutoReplace)
- triggers = "."; //$NON-NLS-1$
+ triggers = "."; //$NON-NLS-1$
ccp.setReplacementAutoActivationCharacters(triggers);
}
@@ -157,35 +157,35 @@ public class ContentAssistPreference {
* Configure the given content assistant from the given store.
*/
public static void configure(ContentAssistant assistant, IPreferenceStore store) {
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
- IColorManager manager= textTools.getColorManager();
+ CTextTools textTools = CUIPlugin.getDefault().getTextTools();
+ IColorManager manager = textTools.getColorManager();
- boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
- boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
- boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
- boolean enabledReplaceDotWithArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
+ boolean enabledDot = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
+ boolean enabledArrow = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
+ boolean enabledDoubleColon = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
+ boolean enabledReplaceDotWithArrow = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
boolean enabled = (enabledDot || enabledArrow || enabledDoubleColon || enabledReplaceDotWithArrow);
assistant.enableAutoActivation(enabled);
- int delay= store.getInt(AUTOACTIVATION_DELAY);
+ int delay = store.getInt(AUTOACTIVATION_DELAY);
assistant.setAutoActivationDelay(delay);
- Color c1= getColor(store, PROPOSALS_FOREGROUND, manager);
+ Color c1 = getColor(store, PROPOSALS_FOREGROUND, manager);
assistant.setProposalSelectorForeground(c1);
- Color c2= getColor(store, PROPOSALS_BACKGROUND, manager);
+ Color c2 = getColor(store, PROPOSALS_BACKGROUND, manager);
assistant.setProposalSelectorBackground(c2);
- Color c3= getColor(store, PARAMETERS_FOREGROUND, manager);
+ Color c3 = getColor(store, PARAMETERS_FOREGROUND, manager);
assistant.setContextInformationPopupForeground(c3);
assistant.setContextSelectorForeground(c3);
- Color c4= getColor(store, PARAMETERS_BACKGROUND, manager);
+ Color c4 = getColor(store, PARAMETERS_BACKGROUND, manager);
assistant.setContextInformationPopupBackground(c4);
assistant.setContextSelectorBackground(c4);
- enabled= store.getBoolean(AUTOINSERT);
+ enabled = store.getBoolean(AUTOINSERT);
assistant.enableAutoInsert(enabled);
enabled = store.getBoolean(PREFIX_COMPLETION);
@@ -195,72 +195,71 @@ public class ContentAssistPreference {
}
private static void changeCProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
- CContentAssistProcessor ccp= getCProcessor(assistant);
+ CContentAssistProcessor ccp = getCProcessor(assistant);
if (ccp == null)
return;
- if ((AUTOACTIVATION_TRIGGERS_DOT.equals(key))
- || (AUTOACTIVATION_TRIGGERS_ARROW.equals(key))
+ if ((AUTOACTIVATION_TRIGGERS_DOT.equals(key)) || (AUTOACTIVATION_TRIGGERS_ARROW.equals(key))
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key))
- || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(key))){
+ || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(key))) {
configureActivationCharacters(store, ccp);
}
-// else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) {
-// boolean enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
-// ccp.restrictProposalsToVisibility(enabled);
-// }
-// else if (CASE_SENSITIVITY.equals(key)) {
-// boolean enabled= store.getBoolean(CASE_SENSITIVITY);
-// ccp.restrictProposalsToMatchingCases(enabled);
-// }
-// else if (ORDER_PROPOSALS.equals(key)) {
-// boolean enable= store.getBoolean(ORDER_PROPOSALS);
-// ccp.orderProposalsAlphabetically(enable);
-// } else if (ADD_INCLUDE.equals(key)) {
-// boolean enabled= store.getBoolean(ADD_INCLUDE);
-// ccp.allowAddingIncludes(enabled);
-// }
+ // else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) {
+ // boolean enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
+ // ccp.restrictProposalsToVisibility(enabled);
+ // }
+ // else if (CASE_SENSITIVITY.equals(key)) {
+ // boolean enabled= store.getBoolean(CASE_SENSITIVITY);
+ // ccp.restrictProposalsToMatchingCases(enabled);
+ // }
+ // else if (ORDER_PROPOSALS.equals(key)) {
+ // boolean enable= store.getBoolean(ORDER_PROPOSALS);
+ // ccp.orderProposalsAlphabetically(enable);
+ // } else if (ADD_INCLUDE.equals(key)) {
+ // boolean enabled= store.getBoolean(ADD_INCLUDE);
+ // ccp.allowAddingIncludes(enabled);
+ // }
}
/**
* Changes the configuration of the given content assistant according to the given property
* change event and the given preference store.
*/
- public static void changeConfiguration(ContentAssistant assistant, IPreferenceStore store, PropertyChangeEvent event) {
- String p= event.getProperty();
+ public static void changeConfiguration(ContentAssistant assistant, IPreferenceStore store,
+ PropertyChangeEvent event) {
+ String p = event.getProperty();
- if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p))
- || (AUTOACTIVATION_TRIGGERS_ARROW.equals(p))
+ if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p)) || (AUTOACTIVATION_TRIGGERS_ARROW.equals(p))
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(p))
- || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(p))){
- boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
- boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
- boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
- boolean enabledReplaceDotWithArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
- boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ) || (enabledReplaceDotWithArrow ));
+ || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(p))) {
+ boolean enabledDot = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
+ boolean enabledArrow = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
+ boolean enabledDoubleColon = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
+ boolean enabledReplaceDotWithArrow = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
+ boolean enabled = ((enabledDot) || (enabledArrow) || (enabledDoubleColon) || (enabledReplaceDotWithArrow));
assistant.enableAutoActivation(enabled);
} else if (AUTOACTIVATION_DELAY.equals(p)) {
- int delay= store.getInt(AUTOACTIVATION_DELAY);
+ int delay = store.getInt(AUTOACTIVATION_DELAY);
assistant.setAutoActivationDelay(delay);
} else if (PROPOSALS_FOREGROUND.equals(p)) {
- Color c= getColor(store, PROPOSALS_FOREGROUND);
+ Color c = getColor(store, PROPOSALS_FOREGROUND);
assistant.setProposalSelectorForeground(c);
} else if (PROPOSALS_BACKGROUND.equals(p)) {
- Color c= getColor(store, PROPOSALS_BACKGROUND);
+ Color c = getColor(store, PROPOSALS_BACKGROUND);
assistant.setProposalSelectorBackground(c);
} else if (PARAMETERS_FOREGROUND.equals(p)) {
- Color c= getColor(store, PARAMETERS_FOREGROUND);
+ Color c = getColor(store, PARAMETERS_FOREGROUND);
assistant.setContextInformationPopupForeground(c);
assistant.setContextSelectorForeground(c);
} else if (PARAMETERS_BACKGROUND.equals(p)) {
- Color c= getColor(store, PARAMETERS_BACKGROUND);
+ Color c = getColor(store, PARAMETERS_BACKGROUND);
assistant.setContextInformationPopupBackground(c);
assistant.setContextSelectorBackground(c);
} else if (AUTOINSERT.equals(p)) {
- boolean enabled= store.getBoolean(AUTOINSERT);
+ boolean enabled = store.getBoolean(AUTOINSERT);
assistant.enableAutoInsert(enabled);
} else if (PREFIX_COMPLETION.equals(p)) {
- boolean enabled= store.getBoolean(PREFIX_COMPLETION);
+ boolean enabled = store.getBoolean(PREFIX_COMPLETION);
assistant.enablePrefixCompletion(enabled);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java
index 835a9ab42aa..59960d28cfc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java
@@ -81,35 +81,36 @@ import org.eclipse.cdt.internal.ui.util.Messages;
* contexts are provided)</li>
* <li>{@code getErrorMessage} to change error reporting</li>
* </ul>
- *
+ *
* @since 4.0
*/
public class ContentAssistProcessor implements IContentAssistProcessor {
- private static final boolean DEBUG= Boolean.parseBoolean(Platform.getDebugOption("org.eclipse.cdt.ui/debug/contentassist")); //$NON-NLS-1$
+ private static final boolean DEBUG = Boolean
+ .parseBoolean(Platform.getDebugOption("org.eclipse.cdt.ui/debug/contentassist")); //$NON-NLS-1$
/**
* Dialog settings key for the "all categories are disabled" warning dialog.
* See {@link OptionalMessageDialog}.
*/
- private static final String PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY= "EmptyDefaultAssistCategory"; //$NON-NLS-1$
+ private static final String PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY = "EmptyDefaultAssistCategory"; //$NON-NLS-1$
- private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR= new Comparator<CompletionProposalCategory>() {
+ private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR = new Comparator<CompletionProposalCategory>() {
@Override
public int compare(CompletionProposalCategory d1, CompletionProposalCategory d2) {
return d1.getSortOrder() - d2.getSortOrder();
}
};
- private static final ICompletionProposal[] NO_PROPOSALS= {};
-
+ private static final ICompletionProposal[] NO_PROPOSALS = {};
+
private final List<CompletionProposalCategory> fCategories;
private final String fPartition;
private final ContentAssistant fAssistant;
-
+
private char[] fCompletionAutoActivationCharacters;
-
+
/* cycling stuff */
- private int fRepetition= -1;
+ private int fRepetition = -1;
private List<List<CompletionProposalCategory>> fCategoryIteration;
private String fIterationGesture;
private int fNumberOfComputedResults;
@@ -119,29 +120,29 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
public ContentAssistProcessor(ContentAssistant assistant, String partition) {
Assert.isNotNull(partition);
Assert.isNotNull(assistant);
- fPartition= partition;
- fCategories= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
- fAssistant= assistant;
+ fPartition = partition;
+ fCategories = CompletionProposalComputerRegistry.getDefault().getProposalCategories();
+ fAssistant = assistant;
fAssistant.addCompletionListener(new ICompletionListener() {
@Override
public void assistSessionStarted(ContentAssistEvent event) {
if (event.processor != ContentAssistProcessor.this)
return;
- fIsAutoActivated= event.isAutoActivated;
- fIterationGesture= getIterationGesture();
- KeySequence binding= getIterationBinding();
+ fIsAutoActivated = event.isAutoActivated;
+ fIterationGesture = getIterationGesture();
+ KeySequence binding = getIterationBinding();
// This may show the warning dialog if all categories are disabled.
- fCategoryIteration= getCategoryIteration();
+ fCategoryIteration = getCategoryIteration();
for (Object element : fCategories) {
- CompletionProposalCategory cat= (CompletionProposalCategory) element;
+ CompletionProposalCategory cat = (CompletionProposalCategory) element;
cat.sessionStarted();
}
-
- fRepetition= 0;
+
+ fRepetition = 0;
if (event.assistant instanceof IContentAssistantExtension2) {
- IContentAssistantExtension2 extension= (IContentAssistantExtension2) event.assistant;
+ IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;
if (fCategoryIteration.size() == 1) {
extension.setRepeatedInvocationMode(false);
@@ -152,84 +153,85 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
extension.setStatusMessage(createIterationMessage());
extension.setShowEmptyList(true);
if (extension instanceof IContentAssistantExtension3) {
- IContentAssistantExtension3 ext3= (IContentAssistantExtension3) extension;
+ IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
((ContentAssistant) ext3).setRepeatedInvocationTrigger(binding);
}
}
-
+
}
}
-
+
@Override
public void assistSessionEnded(ContentAssistEvent event) {
if (event.processor != ContentAssistProcessor.this)
return;
for (Object element : fCategories) {
- CompletionProposalCategory cat= (CompletionProposalCategory) element;
+ CompletionProposalCategory cat = (CompletionProposalCategory) element;
cat.sessionEnded();
}
- fCategoryIteration= null;
- fRepetition= -1;
- fIterationGesture= null;
+ fCategoryIteration = null;
+ fRepetition = -1;
+ fIterationGesture = null;
if (event.assistant instanceof IContentAssistantExtension2) {
- IContentAssistantExtension2 extension= (IContentAssistantExtension2) event.assistant;
+ IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;
extension.setShowEmptyList(false);
extension.setRepeatedInvocationMode(false);
extension.setStatusLineVisible(false);
if (extension instanceof IContentAssistantExtension3) {
- IContentAssistantExtension3 ext3= (IContentAssistantExtension3) extension;
+ IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
((ContentAssistant) ext3).setRepeatedInvocationTrigger(null);
}
}
}
@Override
- public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {}
-
+ public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
+ }
+
});
}
@Override
public final ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- long start= DEBUG ? System.currentTimeMillis() : 0;
-
+ long start = DEBUG ? System.currentTimeMillis() : 0;
+
if (isAutoActivated() && !verifyAutoActivation(viewer, offset)) {
return NO_PROPOSALS;
}
-
+
clearState();
-
- IProgressMonitor monitor= createProgressMonitor();
+
+ IProgressMonitor monitor = createProgressMonitor();
monitor.beginTask(ContentAssistMessages.ContentAssistProcessor_computing_proposals, fCategories.size() + 1);
- ContentAssistInvocationContext context= createContext(viewer, offset, true);
+ ContentAssistInvocationContext context = createContext(viewer, offset, true);
if (context == null)
return null;
try {
- long setup= DEBUG ? System.currentTimeMillis() : 0;
-
+ long setup = DEBUG ? System.currentTimeMillis() : 0;
+
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_proposals);
- List<ICompletionProposal> proposals= collectProposals(viewer, offset, monitor, context);
- long collect= DEBUG ? System.currentTimeMillis() : 0;
+ List<ICompletionProposal> proposals = collectProposals(viewer, offset, monitor, context);
+ long collect = DEBUG ? System.currentTimeMillis() : 0;
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_proposals);
- List<ICompletionProposal> filtered= filterAndSortProposals(proposals, monitor, context);
- fNumberOfComputedResults= filtered.size();
- long filter= DEBUG ? System.currentTimeMillis() : 0;
-
- ICompletionProposal[] result= filtered.toArray(new ICompletionProposal[filtered.size()]);
+ List<ICompletionProposal> filtered = filterAndSortProposals(proposals, monitor, context);
+ fNumberOfComputedResults = filtered.size();
+ long filter = DEBUG ? System.currentTimeMillis() : 0;
+
+ ICompletionProposal[] result = filtered.toArray(new ICompletionProposal[filtered.size()]);
monitor.done();
-
+
if (DEBUG) {
System.out.println("Code Assist Stats (" + result.length + " proposals)"); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("Code Assist (setup):\t" + (setup - start)); //$NON-NLS-1$
System.out.println("Code Assist (collect):\t" + (collect - setup)); //$NON-NLS-1$
System.out.println("Code Assist (sort):\t" + (filter - collect)); //$NON-NLS-1$
}
-
+
return result;
} finally {
context.dispose();
@@ -240,7 +242,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
* Verifies that auto activation is allowed.
* <p>
* The default implementation always returns {@code true}.
- *
+ *
* @param viewer the text viewer
* @param offset the offset where content assist was invoked on
* @return {@code true} if auto activation is allowed
@@ -250,29 +252,29 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
}
private void clearState() {
- fErrorMessage=null;
- fNumberOfComputedResults= 0;
+ fErrorMessage = null;
+ fNumberOfComputedResults = 0;
}
- private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset,
- IProgressMonitor monitor, ContentAssistInvocationContext context) {
- List<ICompletionProposal> proposals= new ArrayList<>();
- List<CompletionProposalCategory> providers= getCategories();
+ private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor,
+ ContentAssistInvocationContext context) {
+ List<ICompletionProposal> proposals = new ArrayList<>();
+ List<CompletionProposalCategory> providers = getCategories();
SubMonitor progress = SubMonitor.convert(monitor, providers.size());
for (CompletionProposalCategory cat : providers) {
- List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, progress.split(1));
+ List<ICompletionProposal> computed = cat.computeCompletionProposals(context, fPartition, progress.split(1));
proposals.addAll(computed);
if (fErrorMessage == null)
- fErrorMessage= cat.getErrorMessage();
+ fErrorMessage = cat.getErrorMessage();
}
-
+
return proposals;
}
/**
* Filters and sorts the proposals. The passed list may be modified
* and returned, or a new list may be created and returned.
- *
+ *
* @param proposals the list of collected proposals (element type: {@link ICompletionProposal})
* @param monitor a progress monitor
* @param context TODO
@@ -288,37 +290,37 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
clearState();
- IProgressMonitor monitor= createProgressMonitor();
+ IProgressMonitor monitor = createProgressMonitor();
monitor.beginTask(ContentAssistMessages.ContentAssistProcessor_computing_contexts, fCategories.size() + 1);
-
+
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_contexts);
- List<IContextInformation> proposals= collectContextInformation(viewer, offset, monitor);
-
+ List<IContextInformation> proposals = collectContextInformation(viewer, offset, monitor);
+
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_contexts);
- List<IContextInformation> filtered= filterAndSortContextInformation(proposals, monitor);
- fNumberOfComputedResults= filtered.size();
-
- IContextInformation[] result= filtered.toArray(new IContextInformation[filtered.size()]);
+ List<IContextInformation> filtered = filterAndSortContextInformation(proposals, monitor);
+ fNumberOfComputedResults = filtered.size();
+
+ IContextInformation[] result = filtered.toArray(new IContextInformation[filtered.size()]);
monitor.done();
return result;
}
private List<IContextInformation> collectContextInformation(ITextViewer viewer, int offset,
IProgressMonitor monitor) {
- List<IContextInformation> proposals= new ArrayList<>();
- ContentAssistInvocationContext context= createContext(viewer, offset, false);
-
+ List<IContextInformation> proposals = new ArrayList<>();
+ ContentAssistInvocationContext context = createContext(viewer, offset, false);
+
try {
- List<CompletionProposalCategory> providers= getCategories();
+ List<CompletionProposalCategory> providers = getCategories();
SubMonitor progress = SubMonitor.convert(monitor, providers.size());
for (CompletionProposalCategory cat : providers) {
- List<IContextInformation> computed=
- cat.computeContextInformation(context, fPartition, progress.split(1));
+ List<IContextInformation> computed = cat.computeContextInformation(context, fPartition,
+ progress.split(1));
proposals.addAll(computed);
if (fErrorMessage == null)
- fErrorMessage= cat.getErrorMessage();
+ fErrorMessage = cat.getErrorMessage();
}
-
+
return proposals;
} finally {
context.dispose();
@@ -328,7 +330,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
/**
* Filters and sorts the context information objects. The passed list may be modified
* and returned, or a new list may be created and returned.
- *
+ *
* @param contexts the list of collected proposals (element type: {@link IContextInformation})
* @param monitor a progress monitor
* @return the list of filtered and sorted proposals, ready for
@@ -346,7 +348,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
* @param activationSet the activation set
*/
public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
- fCompletionAutoActivationCharacters= activationSet;
+ fCompletionAutoActivationCharacters = activationSet;
}
@Override
@@ -377,7 +379,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
* Creates a progress monitor.
* <p>
* The default implementation creates a {@code NullProgressMonitor}.
- *
+ *
* @return a progress monitor
*/
protected IProgressMonitor createProgressMonitor() {
@@ -386,7 +388,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
/**
* Creates the context that is passed to the completion proposal computers.
- *
+ *
* @param viewer the viewer that content assist is invoked on
* @param offset the content assist offset
* @return the context to be passed to the computers,
@@ -398,7 +400,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
/**
* Test whether the current session was auto-activated.
- *
+ *
* @return {@code true} if the current session was auto-activated.
*/
protected boolean isAutoActivated() {
@@ -408,19 +410,19 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
private List<CompletionProposalCategory> getCategories() {
if (fCategoryIteration == null)
return fCategories;
-
- int iteration= fRepetition % fCategoryIteration.size();
+
+ int iteration = fRepetition % fCategoryIteration.size();
fAssistant.setStatusMessage(createIterationMessage());
fAssistant.setEmptyMessage(createEmptyMessage());
fRepetition++;
-
-// fAssistant.setShowMessage(fRepetition % 2 != 0);
-//
+
+ // fAssistant.setShowMessage(fRepetition % 2 != 0);
+ //
return fCategoryIteration.get(iteration);
}
private List<List<CompletionProposalCategory>> getCategoryIteration() {
- List<List<CompletionProposalCategory>> sequence= new ArrayList<>();
+ List<List<CompletionProposalCategory>> sequence = new ArrayList<>();
sequence.add(getDefaultCategories());
for (CompletionProposalCategory cat : getSeparateCategories()) {
sequence.add(Collections.singletonList(cat));
@@ -430,20 +432,20 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
private List<CompletionProposalCategory> getDefaultCategories() {
// default mix - enable all included computers
- List<CompletionProposalCategory> included= getDefaultCategoriesUnchecked();
+ List<CompletionProposalCategory> included = getDefaultCategoriesUnchecked();
if (IDocument.DEFAULT_CONTENT_TYPE.equals(fPartition) && included.isEmpty() && !fCategories.isEmpty())
if (informUserAboutEmptyDefaultCategory())
// preferences were restored - recompute the default categories
- included= getDefaultCategoriesUnchecked();
+ included = getDefaultCategoriesUnchecked();
return included;
}
private List<CompletionProposalCategory> getDefaultCategoriesUnchecked() {
- List<CompletionProposalCategory> included= new ArrayList<>();
+ List<CompletionProposalCategory> included = new ArrayList<>();
for (Object element : fCategories) {
- CompletionProposalCategory category= (CompletionProposalCategory) element;
+ CompletionProposalCategory category = (CompletionProposalCategory) element;
if (category.isIncluded() && category.hasComputers(fPartition))
included.add(category);
}
@@ -456,118 +458,127 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
*/
private boolean informUserAboutEmptyDefaultCategory() {
if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
- final Shell shell= CUIPlugin.getActiveWorkbenchShell();
- String title= ContentAssistMessages.ContentAssistProcessor_all_disabled_title;
- String message= ContentAssistMessages.ContentAssistProcessor_all_disabled_message;
+ final Shell shell = CUIPlugin.getActiveWorkbenchShell();
+ String title = ContentAssistMessages.ContentAssistProcessor_all_disabled_title;
+ String message = ContentAssistMessages.ContentAssistProcessor_all_disabled_message;
// see PreferencePage#createControl for the 'defaults' label
- final String restoreButtonLabel= JFaceResources.getString("defaults"); //$NON-NLS-1$
- final String linkMessage= Messages.format(ContentAssistMessages.ContentAssistProcessor_all_disabled_preference_link, LegacyActionTools.removeMnemonics(restoreButtonLabel));
- final int restoreId= IDialogConstants.CLIENT_ID + 10;
- final int settingsId= IDialogConstants.CLIENT_ID + 11;
- final OptionalMessageDialog dialog= new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell, title, null /* default image */, message, MessageDialog.WARNING, new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
+ final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$
+ final String linkMessage = Messages.format(
+ ContentAssistMessages.ContentAssistProcessor_all_disabled_preference_link,
+ LegacyActionTools.removeMnemonics(restoreButtonLabel));
+ final int restoreId = IDialogConstants.CLIENT_ID + 10;
+ final int settingsId = IDialogConstants.CLIENT_ID + 11;
+ final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell,
+ title, null /* default image */, message, MessageDialog.WARNING,
+ new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
@Override
protected Control createCustomArea(Composite composite) {
// wrap link and checkbox in one composite without space
- Composite parent= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.verticalSpacing= 0;
+ Composite parent = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
parent.setLayout(layout);
-
- Composite linkComposite= new Composite(parent, SWT.NONE);
- layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+
+ Composite linkComposite = new Composite(parent, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
linkComposite.setLayout(layout);
- Link link= new Link(linkComposite, SWT.NONE);
- link.setText(linkMessage);
- link.addSelectionListener(new SelectionAdapter() {
- @Override
+ Link link = new Link(linkComposite, SWT.NONE);
+ link.setText(linkMessage);
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- setReturnCode(settingsId);
- close();
- }
- });
- GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- gridData.widthHint= this.getMinimumMessageWidth();
+ setReturnCode(settingsId);
+ close();
+ }
+ });
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ gridData.widthHint = this.getMinimumMessageWidth();
link.setLayoutData(gridData);
// create checkbox and "don't show this message" prompt
super.createCustomArea(parent);
-
+
return parent;
- }
-
+ }
+
@Override
protected void createButtonsForButtonBar(Composite parent) {
- Button[] buttons= new Button[2];
- buttons[0]= createButton(parent, restoreId, restoreButtonLabel, false);
- buttons[1]= createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);
- setButtons(buttons);
+ Button[] buttons = new Button[2];
+ buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
+ buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);
+ setButtons(buttons);
}
- };
- int returnValue= dialog.open();
- if (restoreId == returnValue || settingsId == returnValue) {
- if (restoreId == returnValue) {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
- store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
- }
- if (settingsId == returnValue)
- PreferencesUtil.createPreferenceDialogOn(shell, "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
- CompletionProposalComputerRegistry registry= CompletionProposalComputerRegistry.getDefault();
- registry.reload();
- return true;
- }
+ };
+ int returnValue = dialog.open();
+ if (restoreId == returnValue || settingsId == returnValue) {
+ if (restoreId == returnValue) {
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
+ store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
+ }
+ if (settingsId == returnValue)
+ PreferencesUtil.createPreferenceDialogOn(shell,
+ "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
+ CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
+ registry.reload();
+ return true;
+ }
}
return false;
}
private List<CompletionProposalCategory> getSeparateCategories() {
- ArrayList<CompletionProposalCategory> sorted= new ArrayList<>();
+ ArrayList<CompletionProposalCategory> sorted = new ArrayList<>();
for (Object element : fCategories) {
- CompletionProposalCategory category= (CompletionProposalCategory) element;
+ CompletionProposalCategory category = (CompletionProposalCategory) element;
if (category.isSeparateCommand() && category.hasComputers(fPartition))
sorted.add(category);
}
Collections.sort(sorted, ORDER_COMPARATOR);
return sorted;
}
-
+
private String createEmptyMessage() {
- return Messages.format(ContentAssistMessages.ContentAssistProcessor_empty_message, getCategoryLabel(fRepetition));
+ return Messages.format(ContentAssistMessages.ContentAssistProcessor_empty_message,
+ getCategoryLabel(fRepetition));
}
-
+
private String createIterationMessage() {
- return Messages.format(ContentAssistMessages.ContentAssistProcessor_toggle_affordance_update_message, getCategoryLabel(fRepetition), fIterationGesture, getCategoryLabel(fRepetition + 1));
+ return Messages.format(ContentAssistMessages.ContentAssistProcessor_toggle_affordance_update_message,
+ getCategoryLabel(fRepetition), fIterationGesture, getCategoryLabel(fRepetition + 1));
}
-
+
private String getCategoryLabel(int repetition) {
- int iteration= repetition % fCategoryIteration.size();
+ int iteration = repetition % fCategoryIteration.size();
if (iteration == 0)
return ContentAssistMessages.ContentAssistProcessor_defaultProposalCategory;
return toString(fCategoryIteration.get(iteration).get(0));
}
-
+
private String toString(CompletionProposalCategory category) {
return category.getDisplayName();
}
private String getIterationGesture() {
- TriggerSequence binding= getIterationBinding();
- return binding != null ?
- Messages.format(ContentAssistMessages.ContentAssistProcessor_toggle_affordance_press_gesture, new Object[] { binding.format() })
+ TriggerSequence binding = getIterationBinding();
+ return binding != null
+ ? Messages.format(ContentAssistMessages.ContentAssistProcessor_toggle_affordance_press_gesture,
+ new Object[] { binding.format() })
: ContentAssistMessages.ContentAssistProcessor_toggle_affordance_click_gesture;
}
private KeySequence getIterationBinding() {
- final IBindingService bindingSvc= PlatformUI.getWorkbench().getAdapter(IBindingService.class);
- TriggerSequence binding= bindingSvc.getBestActiveBindingFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ final IBindingService bindingSvc = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ TriggerSequence binding = bindingSvc
+ .getBestActiveBindingFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
if (binding instanceof KeySequence)
return (KeySequence) binding;
return null;
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
index 5fd376c24cf..d744d1cdbc0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
@@ -156,7 +156,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
// Add only macros.
if (prefix.length() == 0) {
try {
- prefix= context.computeIdentifierPrefix().toString();
+ prefix = context.computeIdentifierPrefix().toString();
} catch (BadLocationException exc) {
CUIPlugin.log(exc);
}
@@ -164,7 +164,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
addMacroProposals(context, prefix, proposals);
}
} else {
- boolean handleMacros= false;
+ boolean handleMacros = false;
CompletionNameEntry[] entries = ((ASTCompletionNode) completionNode).getEntries();
for (CompletionNameEntry entry : entries) {
@@ -180,8 +180,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
IASTCompletionContext astContext = getCompletionContext(name, entry.fParent);
if (astContext == null) {
continue;
- } else if (astContext instanceof IASTIdExpression
- || astContext instanceof IASTNamedTypeSpecifier) {
+ } else if (astContext instanceof IASTIdExpression || astContext instanceof IASTNamedTypeSpecifier) {
// Handle macros only if there is a prefix.
handleMacros = prefix.length() > 0;
}
@@ -189,13 +188,13 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
CPPSemantics.pushLookupPoint(name);
try {
IBinding[] bindings = astContext.findBindings(name, !context.isContextInformationStyle());
-
+
if (bindings != null) {
AccessContext accessibilityContext = new AccessContext(name, true);
- for (IBinding binding : bindings) {
- if (accessibilityContext.isAccessible(binding))
- handleBinding(binding, context, prefix, astContext, proposals);
- }
+ for (IBinding binding : bindings) {
+ if (accessibilityContext.isAccessible(binding))
+ handleBinding(binding, context, prefix, astContext, proposals);
+ }
}
} finally {
CPPSemantics.popLookupPoint();
@@ -215,7 +214,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
return name.getCompletionContext();
}
-
+
/**
* Checks whether the invocation offset is inside or before the preprocessor directive keyword.
*
@@ -227,10 +226,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
int offset = context.getInvocationOffset();
try {
- final ITypedRegion partition=
- TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+ final ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
- String ppPrefix= doc.get(partition.getOffset(), offset - partition.getOffset());
+ String ppPrefix = doc.get(partition.getOffset(), offset - partition.getOffset());
if (ppPrefix.matches("\\s*#\\s*\\w*")) { //$NON-NLS-1$
// We are inside the directive keyword.
return true;
@@ -253,8 +251,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
int offset = context.getInvocationOffset();
try {
- final ITypedRegion partition=
- TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+ final ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
return true;
}
@@ -267,29 +264,26 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
List<ICompletionProposal> proposals) {
IASTCompletionNode completionNode = context.getCompletionNode();
- addMacroProposals(context, prefix, proposals,
- completionNode.getTranslationUnit().getMacroDefinitions());
- addMacroProposals(context, prefix, proposals,
- completionNode.getTranslationUnit().getBuiltinMacroDefinitions());
+ addMacroProposals(context, prefix, proposals, completionNode.getTranslationUnit().getMacroDefinitions());
+ addMacroProposals(context, prefix, proposals, completionNode.getTranslationUnit().getBuiltinMacroDefinitions());
}
private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
List<ICompletionProposal> proposals, IASTPreprocessorMacroDefinition[] macros) {
if (macros != null) {
- char[] prefixChars= prefix.toCharArray();
- final boolean matchPrefix= !context.isContextInformationStyle();
+ char[] prefixChars = prefix.toCharArray();
+ final boolean matchPrefix = !context.isContextInformationStyle();
if (matchPrefix) {
- IContentAssistMatcher matcher =
- ContentAssistMatcherFactory.getInstance().createMatcher(prefixChars);
+ IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(prefixChars);
for (int i = 0; i < macros.length; ++i) {
- final char[] macroName= macros[i].getName().toCharArray();
+ final char[] macroName = macros[i].getName().toCharArray();
if (matcher.match(macroName)) {
handleMacro(macros[i], context, prefix, proposals);
}
}
} else {
for (int i = 0; i < macros.length; ++i) {
- final char[] macroName= macros[i].getName().toCharArray();
+ final char[] macroName = macros[i].getName().toCharArray();
if (CharArrayUtils.equals(macroName, 0, macroName.length, prefixChars, true)) {
handleMacro(macros[i], context, prefix, proposals);
}
@@ -301,13 +295,12 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
private void handleMacro(IASTPreprocessorMacroDefinition macro, CContentAssistInvocationContext context,
String prefix, List<ICompletionProposal> proposals) {
final String macroName = macro.getName().toString();
- final int baseRelevance= computeBaseRelevance(prefix, macroName);
+ final int baseRelevance = computeBaseRelevance(prefix, macroName);
Image image = getImage(CElementImageProvider.getMacroImageDescriptor());
if (macro instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
- IASTPreprocessorFunctionStyleMacroDefinition functionMacro =
- (IASTPreprocessorFunctionStyleMacroDefinition) macro;
+ IASTPreprocessorFunctionStyleMacroDefinition functionMacro = (IASTPreprocessorFunctionStyleMacroDefinition) macro;
StringBuilder repStringBuff = new StringBuilder();
repStringBuff.append(macroName);
@@ -346,8 +339,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
if (!argString.isEmpty()) {
- CProposalContextInformation info =
- new CProposalContextInformation(image, descString, argString);
+ CProposalContextInformation info = new CProposalContextInformation(image, descString, argString);
info.setContextInformationPosition(context.getContextInformationOffset());
proposal.setContextInformation(info);
}
@@ -361,14 +353,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
protected void handleBinding(IBinding binding, CContentAssistInvocationContext cContext, String prefix,
IASTCompletionContext astContext, List<ICompletionProposal> proposals) {
- if ((binding instanceof CPPImplicitFunction
- || binding instanceof CPPImplicitTypedef
- || binding instanceof CPPBuiltinVariable
- || binding instanceof CPPBuiltinParameter
- || binding instanceof CImplicitFunction
- || binding instanceof CImplicitTypedef
- || binding instanceof CBuiltinVariable
- || binding instanceof CBuiltinParameter
+ if ((binding instanceof CPPImplicitFunction || binding instanceof CPPImplicitTypedef
+ || binding instanceof CPPBuiltinVariable || binding instanceof CPPBuiltinParameter
+ || binding instanceof CImplicitFunction || binding instanceof CImplicitTypedef
+ || binding instanceof CBuiltinVariable || binding instanceof CBuiltinParameter
|| binding instanceof ICPPClassTemplatePartialSpecialization)
&& !(binding instanceof CPPImplicitMethod)) {
return;
@@ -376,7 +364,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
if (!isAnonymousBinding(binding)) {
final String name = binding.getName();
- final int baseRelevance= computeBaseRelevance(prefix, name);
+ final int baseRelevance = computeBaseRelevance(prefix, name);
if (binding instanceof ICPPClassType) {
handleClass((ICPPClassType) binding, astContext, cContext, baseRelevance, proposals);
} else if (binding instanceof ICPPAliasTemplate) {
@@ -406,16 +394,16 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
private boolean isAnonymousBinding(IBinding binding) {
- char[] name= binding.getNameCharArray();
+ char[] name = binding.getNameCharArray();
return name.length == 0 || name[0] == '{';
}
-
- private void addProposalForClassTemplate(ICPPClassTemplate templateType,
- CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
+
+ private void addProposalForClassTemplate(ICPPClassTemplate templateType, CContentAssistInvocationContext context,
+ int baseRelevance, List<ICompletionProposal> proposals) {
int relevance = getClassTypeRelevance(templateType);
addProposalForTemplateDefinition(templateType, context, baseRelevance + relevance, proposals);
}
-
+
private void addProposalForTemplateDefinition(ICPPTemplateDefinition templateType,
CContentAssistInvocationContext context, int relevance, List<ICompletionProposal> proposals) {
StringBuilder representation = new StringBuilder(templateType.getName());
@@ -433,8 +421,8 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
relevance, context);
if (!inUsingDeclaration) {
- CProposalContextInformation info = new CProposalContextInformation(
- getImage(templateType), displayString, templateParameterRepresentation);
+ CProposalContextInformation info = new CProposalContextInformation(getImage(templateType), displayString,
+ templateParameterRepresentation);
info.setContextInformationPosition(context.getContextInformationOffset());
proposal.setContextInformation(info);
if (!context.isContextInformationStyle()) {
@@ -444,7 +432,8 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
proposals.add(proposal);
}
- private String buildTemplateParameters(ICPPTemplateDefinition templateType, CContentAssistInvocationContext context) {
+ private String buildTemplateParameters(ICPPTemplateDefinition templateType,
+ CContentAssistInvocationContext context) {
ICPPTemplateParameter[] parameters = templateType.getTemplateParameters();
StringBuilder representation = new StringBuilder();
@@ -467,10 +456,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
} else if (parameter instanceof ICPPTemplateTypeParameter) {
representation.append(TYPENAME);
} else if (parameter instanceof ICPPTemplateTemplateParameter) {
- String templateParameterParameters =
- buildTemplateParameters((ICPPTemplateTemplateParameter) parameter, context);
- representation.append(
- MessageFormat.format(TEMPLATE_PARAMETER_PATTERN, templateParameterParameters));
+ String templateParameterParameters = buildTemplateParameters((ICPPTemplateTemplateParameter) parameter,
+ context);
+ representation.append(MessageFormat.format(TEMPLATE_PARAMETER_PATTERN, templateParameterParameters));
representation.append(templateParameterParameters);
}
if (parameter.isParameterPack()) {
@@ -479,13 +467,12 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
representation.append(' ');
representation.append(parameter.getName());
if (addDefaultArguments && defaultValue != null) {
- String defaultArgumentRepresentation =
- MessageFormat.format(DEFAULT_ARGUMENT_PATTERN, defaultValue);
+ String defaultArgumentRepresentation = MessageFormat.format(DEFAULT_ARGUMENT_PATTERN, defaultValue);
for (int parameterIndex = 0; parameterIndex < i; parameterIndex++) {
String templateArgumentID = HASH + parameterIndex;
String templateArgumentValue = parameters[parameterIndex].getName();
- defaultArgumentRepresentation =
- defaultArgumentRepresentation.replaceAll(templateArgumentID, templateArgumentValue);
+ defaultArgumentRepresentation = defaultArgumentRepresentation.replaceAll(templateArgumentID,
+ templateArgumentValue);
}
representation.append(defaultArgumentRepresentation);
}
@@ -502,7 +489,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
} else {
int relevance = getClassTypeRelevance(classType);
if (astContext instanceof IASTName && !(astContext instanceof ICPPASTQualifiedName)) {
- IASTName name= (IASTName)astContext;
+ IASTName name = (IASTName) astContext;
if (name.getParent() instanceof IASTDeclarator) {
proposals.add(createProposal(classType.getName() + "::", classType.getName(), //$NON-NLS-1$
getImage(classType), baseRelevance + relevance, cContext));
@@ -516,10 +503,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
baseRelevance + RelevanceConstants.CLASS_TYPE_RELEVANCE, cContext));
}
}
-
- private void handleAliasTemplate(ICPPAliasTemplate aliasTemplate,
- CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
- addProposalForTemplateDefinition(aliasTemplate, context,
+
+ private void handleAliasTemplate(ICPPAliasTemplate aliasTemplate, CContentAssistInvocationContext context,
+ int baseRelevance, List<ICompletionProposal> proposals) {
+ addProposalForTemplateDefinition(aliasTemplate, context,
baseRelevance + RelevanceConstants.TYPEDEF_TYPE_RELEVANCE, proposals);
}
@@ -532,29 +519,29 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
private int getClassTypeRelevance(ICPPClassType classType) {
- int relevance= 0;
+ int relevance = 0;
switch (classType.getKey()) {
case ICPPClassType.k_class:
- relevance= RelevanceConstants.CLASS_TYPE_RELEVANCE;
+ relevance = RelevanceConstants.CLASS_TYPE_RELEVANCE;
break;
case ICompositeType.k_struct:
- relevance= RelevanceConstants.STRUCT_TYPE_RELEVANCE;
+ relevance = RelevanceConstants.STRUCT_TYPE_RELEVANCE;
break;
case ICompositeType.k_union:
- relevance= RelevanceConstants.UNION_TYPE_RELEVANCE;
+ relevance = RelevanceConstants.UNION_TYPE_RELEVANCE;
break;
}
return relevance;
}
// Returns whether a function name being completed could be a call to that function.
- private boolean canBeCall(IFunction function, IASTCompletionContext astContext,
+ private boolean canBeCall(IFunction function, IASTCompletionContext astContext,
CContentAssistInvocationContext cContext) {
// Can't have a call in a using-directive.
if (cContext.isInUsingDirective()) {
return false;
}
-
+
// Otherwise, it can be call unless the function is a nonstatic method,
// and we are not inside the class's scope.
if (astContext instanceof CPPASTQualifiedName) {
@@ -565,7 +552,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
return true;
}
-
+
// Returns whether a function name being completed could be a definition of that function.
private boolean canBeDefinition(IFunction function, IASTCompletionContext astContext) {
if (!(astContext instanceof IASTName)) {
@@ -582,7 +569,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
IASTName name = (IASTName) astContext;
return name.getRoleOfName(false) == IASTNameOwner.r_definition;
}
-
+
private String getFunctionNameForReplacement(IFunction function, IASTCompletionContext astContext) {
// If we are completiong a destructor name ...
if (function instanceof ICPPMethod && ((ICPPMethod) function).isDestructor()) {
@@ -600,8 +587,8 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
return function.getName();
}
-
- private void handleFunction(IFunction function, IASTCompletionContext astContext,
+
+ private void handleFunction(IFunction function, IASTCompletionContext astContext,
CContentAssistInvocationContext cContext, int baseRelevance, List<ICompletionProposal> proposals) {
Image image = getImage(function);
@@ -611,9 +598,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
boolean canBeCall = canBeCall(function, astContext, cContext);
boolean canBeDefinition = canBeDefinition(function, astContext);
boolean wantParens = canBeCall || canBeDefinition;
-
+
StringBuilder dispArgs = new StringBuilder(); // For the dispArgString
- StringBuilder idArgs = new StringBuilder(); // For the idArgString
+ StringBuilder idArgs = new StringBuilder(); // For the idArgString
boolean hasArgs = true;
String returnTypeStr = null;
IParameter[] params = function.getParameters();
@@ -641,8 +628,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
if (param instanceof ICPPParameter) {
ICPPParameter cppParam = (ICPPParameter) param;
if (cppParam.hasDefaultValue() && isDisplayDefaultArguments()) {
- dispArgs.append(
- MessageFormat.format(DEFAULT_ARGUMENT_PATTERN, cppParam.getDefaultValue()));
+ dispArgs.append(MessageFormat.format(DEFAULT_ARGUMENT_PATTERN, cppParam.getDefaultValue()));
}
}
}
@@ -668,36 +654,36 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
hasArgs = ASTTypeUtil.functionTakesParameters(function);
- String dispArgString = dispArgs.toString();
- String idArgString = idArgs.toString();
- StringBuilder dispStringBuff = new StringBuilder(function.getName());
- dispStringBuff.append('(');
+ String dispArgString = dispArgs.toString();
+ String idArgString = idArgs.toString();
+ StringBuilder dispStringBuff = new StringBuilder(function.getName());
+ dispStringBuff.append('(');
dispStringBuff.append(dispArgString);
- dispStringBuff.append(')');
- if (returnTypeStr != null && !returnTypeStr.isEmpty()) {
- dispStringBuff.append(" : "); //$NON-NLS-1$
- dispStringBuff.append(returnTypeStr);
- }
- String dispString = dispStringBuff.toString();
-
- StringBuilder idStringBuff = new StringBuilder(function.getName());
- idStringBuff.append('(');
- idStringBuff.append(idArgString);
- idStringBuff.append(')');
- String idString = idStringBuff.toString();
+ dispStringBuff.append(')');
+ if (returnTypeStr != null && !returnTypeStr.isEmpty()) {
+ dispStringBuff.append(" : "); //$NON-NLS-1$
+ dispStringBuff.append(returnTypeStr);
+ }
+ String dispString = dispStringBuff.toString();
+
+ StringBuilder idStringBuff = new StringBuilder(function.getName());
+ idStringBuff.append('(');
+ idStringBuff.append(idArgString);
+ idStringBuff.append(')');
+ String idString = idStringBuff.toString();
String contextInfoString = null;
int paramlistStartIndex = 0, paramlistEndIndex = 0;
if (hasArgs) {
StringBuilder contextInfo = new StringBuilder();
if (function instanceof ICPPMethod && isVirtual((ICPPMethod) function, cContext)) {
- contextInfo.append("virtual "); //$NON-NLS-1$
+ contextInfo.append("virtual "); //$NON-NLS-1$
}
contextInfo.append(returnTypeStr);
contextInfo.append(' ');
if (function instanceof ICPPMethod) {
contextInfo.append(function.getOwner().getName());
- contextInfo.append("::"); //$NON-NLS-1$
+ contextInfo.append("::"); //$NON-NLS-1$
}
contextInfo.append(function.getName());
contextInfo.append('(');
@@ -710,31 +696,29 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
boolean inUsingDeclaration = cContext.isInUsingDirective();
- if (wantParens && !cContext.isFollowedByOpeningParen()) {
- // If we might be calling or defining the function in this context, assume we are
- // (since that's the most common case) and emit parentheses.
- repStringBuff.append('(');
- repStringBuff.append(')');
- } else if (inUsingDeclaration && !cContext.isFollowedBySemicolon()) {
- // In a using declaration, emitting a semicolon instead is useful.
+ if (wantParens && !cContext.isFollowedByOpeningParen()) {
+ // If we might be calling or defining the function in this context, assume we are
+ // (since that's the most common case) and emit parentheses.
+ repStringBuff.append('(');
+ repStringBuff.append(')');
+ } else if (inUsingDeclaration && !cContext.isFollowedBySemicolon()) {
+ // In a using declaration, emitting a semicolon instead is useful.
repStringBuff.append(';');
}
-
- String repString = repStringBuff.toString();
- final int relevance = function instanceof ICPPMethod ?
- RelevanceConstants.METHOD_TYPE_RELEVANCE : RelevanceConstants.FUNCTION_TYPE_RELEVANCE;
+ String repString = repStringBuff.toString();
+
+ final int relevance = function instanceof ICPPMethod ? RelevanceConstants.METHOD_TYPE_RELEVANCE
+ : RelevanceConstants.FUNCTION_TYPE_RELEVANCE;
CCompletionProposal proposal = createProposal(repString, dispString, idString,
cContext.getCompletionNode().getLength(), image, baseRelevance + relevance, cContext);
if (!cContext.isContextInformationStyle()) {
- int cursorPosition = !inUsingDeclaration && hasArgs ?
- repString.length() - 1 : repString.length();
+ int cursorPosition = !inUsingDeclaration && hasArgs ? repString.length() - 1 : repString.length();
proposal.setCursorPosition(cursorPosition);
}
if (contextInfoString != null && !inUsingDeclaration) {
- CProposalContextInformation info =
- new CProposalContextInformation(image, dispString, contextInfoString);
+ CProposalContextInformation info = new CProposalContextInformation(image, dispString, contextInfoString);
info.setContextInformationPosition(cContext.getContextInformationOffset());
info.setHasPrefixSuffix(paramlistStartIndex, paramlistEndIndex);
proposal.setContextInformation(info);
@@ -743,10 +727,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
// The ParameterGuessingProposal will be active if the function accepts parameters and the content
// assist is invoked before typing any parameters. Otherwise, the normal parameter hint proposal will
// be added.
- if (fGuessArguments && canBeCall && function.getParameters() != null
- && function.getParameters().length != 0 && isBeforeParameters(cContext)) {
- proposals.add(ParameterGuessingProposal.createProposal(cContext, fAvailableElements, proposal,
- function, fPrefix));
+ if (fGuessArguments && canBeCall && function.getParameters() != null && function.getParameters().length != 0
+ && isBeforeParameters(cContext)) {
+ proposals.add(ParameterGuessingProposal.createProposal(cContext, fAvailableElements, proposal, function,
+ fPrefix));
} else {
proposals.add(proposal);
}
@@ -777,13 +761,12 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
// Invocation offset and parse offset are the same if content assist is invoked while in the function
// name (i.e. before the '('). After that, the parse offset will indicate the end of the name part.
// If there is no difference between them, then we're still inside the function name part.
- int parseOffset = context.getAdjustedParseOffset();
+ int parseOffset = context.getAdjustedParseOffset();
int relativeOffset = context.getInvocationOffset() - parseOffset;
if (relativeOffset == 0)
return true;
int startOffset = parseOffset;
- String completePrefix = context.getDocument().get().substring(startOffset,
- context.getInvocationOffset());
+ String completePrefix = context.getDocument().get().substring(startOffset, context.getInvocationOffset());
int lastChar = getLastNonWhitespaceChar(completePrefix);
if (lastChar != -1 && completePrefix.charAt(lastChar) == '(')
return true;
@@ -804,25 +787,24 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
*/
private List<IBinding> getDefinedElements(CContentAssistInvocationContext context) {
// Get all variables accessible at the start of the statement.
- // ex1: int a = foo(
- // ^ --> We don't want 'a' as a suggestion.
- // ex2: char* foo(int a, int b) { return NULL; }
- // void bar(char* name) {}
+ // ex1: int a = foo(
+ // ^ --> We don't want 'a' as a suggestion.
+ // ex2: char* foo(int a, int b) { return NULL; }
+ // void bar(char* name) {}
// ...
- // bar( foo(
+ // bar( foo(
// ^ --> If this offset is used, the only defined name will be "bar(char*)".
IASTCompletionNode node = context.getCompletionNode();
if (node == null)
return Collections.emptyList();
- // Find the enclosing statement at the point of completion.
+ // Find the enclosing statement at the point of completion.
IASTStatement completionStatement = null;
IASTName[] completionNames = node.getNames();
for (IASTName name : completionNames) {
IASTStatement statement = ASTQueries.findAncestorWithType(name, IASTStatement.class);
if (statement != null && statement.getParent() != null) {
- if (completionStatement == null
- || getNodeOffset(statement) < getNodeOffset(completionStatement)) {
+ if (completionStatement == null || getNodeOffset(statement) < getNodeOffset(completionStatement)) {
completionStatement = statement;
}
}
@@ -831,7 +813,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
return Collections.emptyList();
// Get content assist results for an empty prefix at the start of the statement.
- final int statementOffset = getNodeOffset(completionStatement);
+ final int statementOffset = getNodeOffset(completionStatement);
IToken token = new TokenWithImage(IToken.tCOMPLETION, null, statementOffset, statementOffset,
CharArrayUtils.EMPTY_CHAR_ARRAY);
IASTTranslationUnit ast = node.getTranslationUnit();
@@ -846,27 +828,26 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
// Get all variables declared in the translation unit.
final Set<IBinding> declaredVariables = new HashSet<>();
ast.accept(new ASTVisitor(true) {
- @Override
+ @Override
public int visit(IASTName name) {
- if (getNodeOffset(name) >= statementOffset)
- return PROCESS_ABORT;
- int role = name.getRoleOfName(true);
- if (role == IASTNameOwner.r_declaration || role == IASTNameOwner.r_definition) {
+ if (getNodeOffset(name) >= statementOffset)
+ return PROCESS_ABORT;
+ int role = name.getRoleOfName(true);
+ if (role == IASTNameOwner.r_declaration || role == IASTNameOwner.r_definition) {
IBinding binding = name.resolveBinding();
if (binding instanceof IVariable) {
declaredVariables.add(binding);
}
- }
- return PROCESS_SKIP; // Do non visit internals of qualified names.
- }
+ }
+ return PROCESS_SKIP; // Do non visit internals of qualified names.
+ }
});
Map<String, IBinding> elementsMap = new HashMap<>();
AccessContext accessibilityContext = new AccessContext(name, true);
for (IBinding binding : bindings) {
// Consider only fields and variables that are declared in the current translation unit.
- if (binding instanceof IVariable
- && !elementsMap.containsKey(binding.getName())
+ if (binding instanceof IVariable && !elementsMap.containsKey(binding.getName())
&& (binding instanceof ICPPField || declaredVariables.contains(binding))
&& accessibilityContext.isAccessible(binding)) {
elementsMap.put(binding.getName(), binding);
@@ -886,17 +867,17 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
private boolean skipDefaultedParameter(IParameter param) {
- return !isDisplayDefaultedParameters() && param instanceof ICPPParameter && ((ICPPParameter)param).hasDefaultValue();
+ return !isDisplayDefaultedParameters() && param instanceof ICPPParameter
+ && ((ICPPParameter) param).hasDefaultValue();
}
private void handleVariable(IVariable variable, IASTCompletionContext astContext,
- CContentAssistInvocationContext cContext,
- int baseRelevance, List<ICompletionProposal> proposals) {
+ CContentAssistInvocationContext cContext, int baseRelevance, List<ICompletionProposal> proposals) {
if (cContext.isContextInformationStyle()) {
IType t = variable.getType();
- t= unwindTypedefs(t);
+ t = unwindTypedefs(t);
if (t instanceof ICPPClassType) {
- ICPPClassType classType= (ICPPClassType) t;
+ ICPPClassType classType = (ICPPClassType) t;
ICPPConstructor[] constructors = classType.getConstructors();
for (ICPPConstructor constructor : constructors) {
handleFunction(constructor, astContext, cContext, baseRelevance, proposals);
@@ -913,33 +894,31 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
if (varType != null)
returnTypeStr = ASTTypeUtil.getType(varType, false);
- StringBuilder dispStringBuff = new StringBuilder(repStringBuff);
- if (returnTypeStr != null) {
- dispStringBuff.append(" : "); //$NON-NLS-1$
- dispStringBuff.append(returnTypeStr);
- }
- String dispString = dispStringBuff.toString();
+ StringBuilder dispStringBuff = new StringBuilder(repStringBuff);
+ if (returnTypeStr != null) {
+ dispStringBuff.append(" : "); //$NON-NLS-1$
+ dispStringBuff.append(returnTypeStr);
+ }
+ String dispString = dispStringBuff.toString();
- StringBuilder idStringBuff = new StringBuilder(repStringBuff);
- String idString = idStringBuff.toString();
+ StringBuilder idStringBuff = new StringBuilder(repStringBuff);
+ String idString = idStringBuff.toString();
- String repString = repStringBuff.toString();
+ String repString = repStringBuff.toString();
Image image = getImage(variable);
- final int relevance = isLocalVariable(variable) ?
- RelevanceConstants.LOCAL_VARIABLE_TYPE_RELEVANCE :
- isField(variable) ?
- RelevanceConstants.FIELD_TYPE_RELEVANCE :
- RelevanceConstants.VARIABLE_TYPE_RELEVANCE;
+ final int relevance = isLocalVariable(variable) ? RelevanceConstants.LOCAL_VARIABLE_TYPE_RELEVANCE
+ : isField(variable) ? RelevanceConstants.FIELD_TYPE_RELEVANCE
+ : RelevanceConstants.VARIABLE_TYPE_RELEVANCE;
CCompletionProposal proposal = createProposal(repString, dispString, idString,
cContext.getCompletionNode().getLength(), image, baseRelevance + relevance, cContext);
proposals.add(proposal);
}
private IType unwindTypedefs(final IType t) {
- IType r= t;
+ IType r = t;
while (r instanceof ITypedef) {
- r= ((ITypedef) r).getType();
+ r = ((ITypedef) r).getType();
}
return r != null ? r : t;
}
@@ -956,25 +935,23 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
}
- private static boolean isLocalScope(IScope scope) {
- while (scope != null) {
- if (scope instanceof ICPPFunctionScope ||
- scope instanceof ICPPBlockScope ||
- scope instanceof ICFunctionScope) {
- return true;
- }
- try {
- scope= scope.getParent();
- } catch (DOMException e) {
- scope= null;
- }
- }
- return false;
- }
+ private static boolean isLocalScope(IScope scope) {
+ while (scope != null) {
+ if (scope instanceof ICPPFunctionScope || scope instanceof ICPPBlockScope
+ || scope instanceof ICFunctionScope) {
+ return true;
+ }
+ try {
+ scope = scope.getParent();
+ } catch (DOMException e) {
+ scope = null;
+ }
+ }
+ return false;
+ }
private void handleNamespace(ICPPNamespace namespace, IASTCompletionContext astContext,
- CContentAssistInvocationContext cContext, int baseRelevance,
- List<ICompletionProposal> proposals) {
+ CContentAssistInvocationContext cContext, int baseRelevance, List<ICompletionProposal> proposals) {
if (astContext instanceof ICPPASTQualifiedName) {
IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext).getCompletionContext();
handleNamespace(namespace, parent, cContext, baseRelevance, proposals);
@@ -984,8 +961,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
StringBuilder repStringBuff = new StringBuilder();
repStringBuff.append(namespace.getName());
- if (!(astContext instanceof ICPPASTUsingDeclaration)
- && !(astContext instanceof ICPPASTUsingDirective)) {
+ if (!(astContext instanceof ICPPASTUsingDeclaration) && !(astContext instanceof ICPPASTUsingDirective)) {
repStringBuff.append("::"); //$NON-NLS-1$
}
@@ -994,19 +970,19 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
baseRelevance + RelevanceConstants.NAMESPACE_TYPE_RELEVANCE, cContext));
}
- private CCompletionProposal createProposal(String repString, String dispString, Image image,
- int relevance, CContentAssistInvocationContext context) {
- return createProposal(repString, dispString, null, context.getCompletionNode().getLength(), image,
- relevance, context);
+ private CCompletionProposal createProposal(String repString, String dispString, Image image, int relevance,
+ CContentAssistInvocationContext context) {
+ return createProposal(repString, dispString, null, context.getCompletionNode().getLength(), image, relevance,
+ context);
}
- private CCompletionProposal createProposal(String repString, String dispString, int prefixLength,
- Image image, int relevance, CContentAssistInvocationContext context) {
+ private CCompletionProposal createProposal(String repString, String dispString, int prefixLength, Image image,
+ int relevance, CContentAssistInvocationContext context) {
return createProposal(repString, dispString, null, prefixLength, image, relevance, context);
}
- private CCompletionProposal createProposal(String repString, String dispString, String idString,
- int prefixLength, Image image, int relevance, CContentAssistInvocationContext context) {
+ private CCompletionProposal createProposal(String repString, String dispString, String idString, int prefixLength,
+ Image image, int relevance, CContentAssistInvocationContext context) {
int parseOffset = context.getParseOffset();
int invocationOffset = context.getInvocationOffset();
boolean doReplacement = !context.isContextInformationStyle();
@@ -1015,8 +991,8 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
int repOffset = doReplacement ? parseOffset - repLength : invocationOffset;
repString = doReplacement ? repString : ""; //$NON-NLS-1$
- return new CCompletionProposal(repString, repOffset, repLength, image, dispString, idString,
- relevance, context.getViewer());
+ return new CCompletionProposal(repString, repOffset, repLength, image, dispString, idString, relevance,
+ context.getViewer());
}
private Image getImage(ImageDescriptor desc) {
@@ -1029,14 +1005,14 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
if (binding instanceof ITypedef || binding instanceof ICPPAliasTemplate) {
imageDescriptor = CElementImageProvider.getTypedefImageDescriptor();
} else if (binding instanceof ICompositeType) {
- if (((ICompositeType)binding).getKey() == ICPPClassType.k_class || binding instanceof ICPPClassTemplate)
+ if (((ICompositeType) binding).getKey() == ICPPClassType.k_class || binding instanceof ICPPClassTemplate)
imageDescriptor = CElementImageProvider.getClassImageDescriptor();
- else if (((ICompositeType)binding).getKey() == ICompositeType.k_struct)
+ else if (((ICompositeType) binding).getKey() == ICompositeType.k_struct)
imageDescriptor = CElementImageProvider.getStructImageDescriptor();
- else if (((ICompositeType)binding).getKey() == ICompositeType.k_union)
+ else if (((ICompositeType) binding).getKey() == ICompositeType.k_union)
imageDescriptor = CElementImageProvider.getUnionImageDescriptor();
} else if (binding instanceof ICPPMethod) {
- switch (((ICPPMethod)binding).getVisibility()) {
+ switch (((ICPPMethod) binding).getVisibility()) {
case ICPPMember.v_private:
imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PRIVATE);
break;
@@ -1050,7 +1026,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
} else if (binding instanceof IFunction) {
imageDescriptor = CElementImageProvider.getFunctionImageDescriptor();
} else if (binding instanceof ICPPField) {
- switch (((ICPPField)binding).getVisibility()) {
+ switch (((ICPPField) binding).getVisibility()) {
case ICPPMember.v_private:
imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PRIVATE);
break;
@@ -1068,7 +1044,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
} else if (binding instanceof IEnumeration) {
imageDescriptor = CElementImageProvider.getEnumerationImageDescriptor();
} else if (binding instanceof IEnumerator) {
- imageDescriptor = CElementImageProvider.getEnumeratorImageDescriptor();
+ imageDescriptor = CElementImageProvider.getEnumeratorImageDescriptor();
} else if (binding instanceof ICPPNamespace) {
imageDescriptor = CElementImageProvider.getNamespaceImageDescriptor();
} else if (binding instanceof ICPPFunctionTemplate) {
@@ -1079,8 +1055,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
return getImage(delegates[0]);
}
- return imageDescriptor != null ?
- CUIPlugin.getImageDescriptorRegistry().get(imageDescriptor) : null;
+ return imageDescriptor != null ? CUIPlugin.getImageDescriptorRegistry().get(imageDescriptor) : null;
}
private static boolean isDisplayDefaultArguments() {
@@ -1090,7 +1065,8 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
private static boolean isDisplayDefaultedParameters() {
IPreferenceStore preferenceStore = getPreferenceStore();
- return preferenceStore.getBoolean(ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT);
+ return preferenceStore
+ .getBoolean(ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT);
}
private static IPreferenceStore getPreferenceStore() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/FunctionCompletionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/FunctionCompletionProposal.java
index a778cf0f4ce..cac46408981 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/FunctionCompletionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/FunctionCompletionProposal.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Tom Eicher <eclipse@tom.eicher.name> - [content assist] prefix complete casted method proposals - https://bugs.eclipse.org/bugs/show_bug.cgi?id=247547
@@ -36,7 +36,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* This is a modified version of org.eclipse.jdt.internal.ui.text.java.JavaMethodCompletionProposal
- *
+ *
* This class adds a linked mode function compilation proposal with exit policy.
*/
public class FunctionCompletionProposal extends CCompletionProposal {
@@ -49,10 +49,10 @@ public class FunctionCompletionProposal extends CCompletionProposal {
protected IDocument fDocument;
public FunctionCompletionProposal(String replacementString, int replacementOffset, int replacementLength,
- Image image, String displayString, String idString, int relevance, ITextViewer viewer,
- IFunction function, int invocationOffset, int parseOffset, ITranslationUnit translationUnit, IDocument document) {
- super(replacementString, replacementOffset, replacementLength, image, displayString, idString,
- relevance, viewer);
+ Image image, String displayString, String idString, int relevance, ITextViewer viewer, IFunction function,
+ int invocationOffset, int parseOffset, ITranslationUnit translationUnit, IDocument document) {
+ super(replacementString, replacementOffset, replacementLength, image, displayString, idString, relevance,
+ viewer);
fFunctionParameters = function.getParameters();
fInvocationOffset = invocationOffset;
fParseOffset = parseOffset;
@@ -118,8 +118,7 @@ public class FunctionCompletionProposal extends CCompletionProposal {
int exit = getReplacementOffset() + getReplacementString().length();
try {
LinkedPositionGroup group = new LinkedPositionGroup();
- group.addPosition(new LinkedPosition(document, fInvocationOffset, 0,
- LinkedPositionGroup.NO_STOP));
+ group.addPosition(new LinkedPosition(document, fInvocationOffset, 0, LinkedPositionGroup.NO_STOP));
LinkedModeModel model = new LinkedModeModel();
model.addGroup(group);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java
index 1342b827a33..dc9bab66990 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java
@@ -40,40 +40,38 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer {
@Override
- protected List<ICompletionProposal> computeCompletionProposals(
- CContentAssistInvocationContext cContext,
- IASTCompletionNode completionNode, String prefix)
- throws CoreException {
-
+ protected List<ICompletionProposal> computeCompletionProposals(CContentAssistInvocationContext cContext,
+ IASTCompletionNode completionNode, String prefix) throws CoreException {
+
boolean handleHelp = false;
if (completionNode != null) {
IASTName[] names = completionNode.getNames();
for (int i = 0; i < names.length; ++i) {
IASTName name = names[i];
-
+
// Ignore if not connected.
// See the corresponding code in DOMCompletionProposalComputer for why
// inactive completion names are special.
if (name.getTranslationUnit() == null && !(name instanceof IASTInactiveCompletionName))
continue;
-
+
// ignore if this is a member access
if (name.getParent() instanceof IASTFieldReference)
continue;
-
+
handleHelp = true;
break;
}
}
-
+
if (!handleHelp) {
return Collections.emptyList();
}
-
+
final ITranslationUnit tu = cContext.getTranslationUnit();
final IASTCompletionNode cn = completionNode;
final int cc = cContext.getInvocationOffset();
-
+
// Find matching functions
ICHelpInvocationContext helpContext = new IContentAssistHelpInvocationContext() {
@@ -86,28 +84,26 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
public ITranslationUnit getTranslationUnit() {
return tu;
}
-
+
@Override
public int getInvocationOffset() {
return cc;
}
-
+
@Override
public IASTCompletionNode getCompletionNode() {
return cn;
}
};
- IFunctionSummary[] summaries = CHelpProviderManager.getDefault()
- .getMatchingFunctions(helpContext, prefix);
+ IFunctionSummary[] summaries = CHelpProviderManager.getDefault().getMatchingFunctions(helpContext, prefix);
if (summaries == null)
return Collections.emptyList();
boolean doReplacement = !cContext.isContextInformationStyle();
int repLength = doReplacement ? prefix.length() : 0;
int repOffset = cContext.getInvocationOffset() - repLength;
- Image image = CUIPlugin.getImageDescriptorRegistry().get(
- CElementImageProvider.getFunctionImageDescriptor());
+ Image image = CUIPlugin.getImageDescriptorRegistry().get(CElementImageProvider.getFunctionImageDescriptor());
// If we are only providing context information, "prefix" is a complete
// function name, and we only want functions matching it exactly as
@@ -123,25 +119,18 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
if (requireExactMatch && !summary.getName().equals(prefix)) {
continue;
}
-
+
String fname = summary.getName() + "()"; //$NON-NLS-1$
String fdesc = summary.getDescription();
- IFunctionSummary.IFunctionPrototypeSummary fproto = summary
- .getPrototype();
+ IFunctionSummary.IFunctionPrototypeSummary fproto = summary.getPrototype();
String fargs = fproto.getArguments();
- String repString = doReplacement ? fname : ""; //$NON-NLS-1$
-
+ String repString = doReplacement ? fname : ""; //$NON-NLS-1$
+
int relevance = computeBaseRelevance(prefix, summary.getName()) + RelevanceConstants.HELP_TYPE_RELEVANCE;
CCompletionProposal proposal;
- proposal = new CCompletionProposal(
- repString,
- repOffset,
- repLength,
- image,
- fproto.getPrototypeString(true),
- relevance,
- cContext.getViewer());
+ proposal = new CCompletionProposal(repString, repOffset, repLength, image, fproto.getPrototypeString(true),
+ relevance, cContext.getViewer());
if (fdesc != null) {
proposal.setAdditionalProposalInfo(fdesc);
@@ -156,7 +145,7 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
proposal.setCursorPosition(fname.length());
}
}
-
+
if (fargs != null && fargs.length() > 0) {
CProposalContextInformation info = new CProposalContextInformation(image, fname, fargs);
info.setContextInformationPosition(cContext.getContextInformationOffset());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java
index 88ab54c785a..f2f945a5759 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java
@@ -25,27 +25,27 @@ import org.eclipse.ui.texteditor.HippieProposalProcessor;
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
-
/**
* A computer wrapper for the hippie processor.
- *
+ *
* @since 4.0
*/
public final class HippieProposalComputer implements ICompletionProposalComputer {
/** The wrapped processor. */
- private final HippieProposalProcessor fProcessor= new HippieProposalProcessor();
+ private final HippieProposalProcessor fProcessor = new HippieProposalProcessor();
/**
* Default ctor to make it instantiatable via the extension mechanism.
*/
public HippieProposalComputer() {
}
-
+
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
return Arrays.asList(fProcessor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset()));
}
@@ -53,7 +53,8 @@ public final class HippieProposalComputer implements ICompletionProposalComputer
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
return Arrays.asList(fProcessor.computeContextInformation(context.getViewer(), context.getInvocationOffset()));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java
index 1f1f8f4094a..8b2088c6e09 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java
@@ -65,19 +65,20 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
private String fErrorMessage;
@Override
- public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
- List<ICompletionProposal> proposals= Collections.emptyList();
- fErrorMessage= null;
-
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
+ List<ICompletionProposal> proposals = Collections.emptyList();
+ fErrorMessage = null;
+
if (context instanceof CContentAssistInvocationContext) {
- CContentAssistInvocationContext cContext= (CContentAssistInvocationContext) context;
+ CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context;
if (inIncludeDirective(cContext)) {
// add include file proposals
- proposals= new ArrayList<ICompletionProposal>();
+ proposals = new ArrayList<ICompletionProposal>();
try {
addInclusionProposals(cContext, proposals);
} catch (Exception exc) {
- fErrorMessage= exc.getMessage();
+ fErrorMessage = exc.getMessage();
CUIPlugin.log(exc);
}
}
@@ -86,7 +87,8 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
}
@Override
- public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
return null;
}
@@ -105,24 +107,24 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
/**
* Test whether the invocation offset is inside the file name part if an include directive.
- *
+ *
* @param context the invocation context
* @return <code>true</code> if the invocation offset is inside or before the directive keyword
*/
private boolean inIncludeDirective(CContentAssistInvocationContext context) {
IDocument doc = context.getDocument();
int offset = context.getInvocationOffset();
-
+
try {
- final ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+ final ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
- String ppPrefix= doc.get(partition.getOffset(), offset - partition.getOffset());
+ String ppPrefix = doc.get(partition.getOffset(), offset - partition.getOffset());
if (ppPrefix.matches("\\s*#\\s*include\\s*[\"<][^\">]*")) { //$NON-NLS-1$
// we are inside the file name part of the include directive
return true;
}
}
-
+
} catch (BadLocationException exc) {
}
return false;
@@ -130,53 +132,56 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
private static class PotentialInclude {
public String fPath;
- public boolean fKnownContentType; // true for directories and files known to be headers
-
+ public boolean fKnownContentType; // true for directories and files known to be headers
+
public PotentialInclude(String path, boolean knownContentType) {
fPath = path;
fKnownContentType = knownContentType;
}
}
-
- private void addInclusionProposals(CContentAssistInvocationContext context, List<ICompletionProposal> proposals) throws Exception {
+
+ private void addInclusionProposals(CContentAssistInvocationContext context, List<ICompletionProposal> proposals)
+ throws Exception {
if (context.isContextInformationStyle()) {
return;
}
- final ITranslationUnit tu= context.getTranslationUnit();
+ final ITranslationUnit tu = context.getTranslationUnit();
if (tu == null) {
return;
}
String prefix;
- boolean angleBrackets= false;
+ boolean angleBrackets = false;
prefix = computeIncludePrefix(context);
if (prefix.length() > 0) {
- angleBrackets= prefix.charAt(0) == '<';
- prefix= prefix.substring(1);
+ angleBrackets = prefix.charAt(0) == '<';
+ prefix = prefix.substring(1);
}
- IPath prefixPath= new Path(prefix);
- PotentialInclude[] potentialIncludes= collectIncludeFiles(tu, prefixPath, angleBrackets);
+ IPath prefixPath = new Path(prefix);
+ PotentialInclude[] potentialIncludes = collectIncludeFiles(tu, prefixPath, angleBrackets);
if (potentialIncludes.length > 0) {
- IInclude[] includes= tu.getIncludes();
- Set<String> alreadyIncluded= new HashSet<String>();
+ IInclude[] includes = tu.getIncludes();
+ Set<String> alreadyIncluded = new HashSet<String>();
for (IInclude includeDirective : includes) {
alreadyIncluded.add(includeDirective.getElementName());
}
Image image = getImage(CElementImageProvider.getIncludeImageDescriptor());
for (PotentialInclude include : potentialIncludes) {
if (alreadyIncluded.add(include.fPath)) {
- final char openingBracket= angleBrackets ? '<' : '"';
- final char closingBracket= angleBrackets ? '>' : '"';
- String repString= openingBracket + include.fPath;
- final String dispString= repString + closingBracket;
+ final char openingBracket = angleBrackets ? '<' : '"';
+ final char closingBracket = angleBrackets ? '>' : '"';
+ String repString = openingBracket + include.fPath;
+ final String dispString = repString + closingBracket;
int repLength = prefix.length() + 1;
- int repOffset= context.getInvocationOffset() - repLength;
- final boolean needClosingBracket= context.getDocument().getChar(repOffset + repLength) != closingBracket;
+ int repOffset = context.getInvocationOffset() - repLength;
+ final boolean needClosingBracket = context.getDocument()
+ .getChar(repOffset + repLength) != closingBracket;
if (needClosingBracket) {
repString += closingBracket;
}
- final boolean isDir= include.fPath.endsWith("/"); //$NON-NLS-1$
- final int relevance= computeRelevance(prefix, include) + (isDir ? 0 : 1);
- final CCompletionProposal proposal= createProposal(repOffset, repLength, repString, dispString, image, relevance, context);
+ final boolean isDir = include.fPath.endsWith("/"); //$NON-NLS-1$
+ final int relevance = computeRelevance(prefix, include) + (isDir ? 0 : 1);
+ final CCompletionProposal proposal = createProposal(repOffset, repLength, repString, dispString,
+ image, relevance, context);
if (!isDir && !needClosingBracket) {
// put cursor behind closing bracket
proposal.setCursorPosition(repString.length() + 1);
@@ -186,32 +191,33 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
}
}
}
-
+
/**
* Collect potential include files for the given translation unit.
- *
+ *
* @param tu the translation unit to include the file
* @param prefixPath the path part to match the sub-directory and file name
* @param angleBrackets whether angle brackets enclose the include file name
* @return an array of incude file names
* @throws CoreException
*/
- private PotentialInclude[] collectIncludeFiles(final ITranslationUnit tu, IPath prefixPath, boolean angleBrackets) throws CoreException {
- final List<PotentialInclude> includeFiles= new ArrayList<>();
+ private PotentialInclude[] collectIncludeFiles(final ITranslationUnit tu, IPath prefixPath, boolean angleBrackets)
+ throws CoreException {
+ final List<PotentialInclude> includeFiles = new ArrayList<>();
if (!angleBrackets) {
// search in current directory
- IResource resource= tu.getResource();
+ IResource resource = tu.getResource();
if (resource != null) {
- IContainer parent= resource.getParent();
+ IContainer parent = resource.getParent();
collectIncludeFilesFromContainer(tu, parent, prefixPath, includeFiles);
} else {
- IPath location= tu.getLocation();
+ IPath location = tu.getLocation();
if (location != null) {
collectIncludeFilesFromDirectory(tu, location.removeLastSegments(1), prefixPath, includeFiles);
}
}
}
- IScannerInfo info= tu.getScannerInfo(true);
+ IScannerInfo info = tu.getScannerInfo(true);
if (info != null) {
collectIncludeFilesFromScannerInfo(tu, info, prefixPath, angleBrackets, includeFiles);
}
@@ -225,49 +231,49 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
* @param angleBrackets whether angle brackets enclose the include file name
* @param includeFiles the result list
*/
- private void collectIncludeFilesFromScannerInfo(ITranslationUnit tu, IScannerInfo info, IPath prefixPath,
+ private void collectIncludeFilesFromScannerInfo(ITranslationUnit tu, IScannerInfo info, IPath prefixPath,
boolean angleBrackets, List<PotentialInclude> includeFiles) {
if (!angleBrackets && info instanceof IExtendedScannerInfo) {
- IExtendedScannerInfo extendedInfo= (IExtendedScannerInfo) info;
- String[] quoteIncludes= extendedInfo.getLocalIncludePath();
-
+ IExtendedScannerInfo extendedInfo = (IExtendedScannerInfo) info;
+ String[] quoteIncludes = extendedInfo.getLocalIncludePath();
+
if (quoteIncludes != null) {
for (String quoteInclude : quoteIncludes) {
- IPath includeDir= new Path(quoteInclude);
+ IPath includeDir = new Path(quoteInclude);
collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
}
}
}
-
- String[] allIncludes= info.getIncludePaths();
+
+ String[] allIncludes = info.getIncludePaths();
for (String allInclude : allIncludes) {
- IPath includeDir= new Path(allInclude);
+ IPath includeDir = new Path(allInclude);
collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
}
}
/**
* Collect include files from the given file system directory.
- *
+ *
* @param tu the translation unit to include the file
* @param directory the file system path of the directory
* @param prefixPath the path part to match the sub-directory and file name
* @param includeFiles the result list
*/
- private void collectIncludeFilesFromDirectory(ITranslationUnit tu, IPath directory, IPath prefixPath,
+ private void collectIncludeFilesFromDirectory(ITranslationUnit tu, IPath directory, IPath prefixPath,
List<PotentialInclude> includeFiles) {
final String namePrefix;
if (prefixPath.segmentCount() == 0) {
- namePrefix= ""; //$NON-NLS-1$
+ namePrefix = ""; //$NON-NLS-1$
} else if (prefixPath.hasTrailingSeparator()) {
- namePrefix= ""; //$NON-NLS-1$
- prefixPath= prefixPath.removeTrailingSeparator();
- directory= directory.append(prefixPath);
+ namePrefix = ""; //$NON-NLS-1$
+ prefixPath = prefixPath.removeTrailingSeparator();
+ directory = directory.append(prefixPath);
} else {
- namePrefix= prefixPath.lastSegment();
- prefixPath= prefixPath.removeLastSegments(1);
+ namePrefix = prefixPath.lastSegment();
+ prefixPath = prefixPath.removeLastSegments(1);
if (prefixPath.segmentCount() > 0) {
- directory= directory.append(prefixPath);
+ directory = directory.append(prefixPath);
}
}
final File fileDir = directory.toFile();
@@ -275,57 +281,56 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
return;
}
final int prefixLength = namePrefix.length();
- final IProject project= tu.getCProject().getProject();
- File[] files= fileDir.listFiles();
+ final IProject project = tu.getCProject().getProject();
+ File[] files = fileDir.listFiles();
if (files == null) {
return;
}
IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(namePrefix);
for (File file : files) {
- final String name= file.getName();
+ final String name = file.getName();
if (name.length() >= prefixLength && matcher.match(name.toCharArray())) {
maybeAddInclude(prefixPath, includeFiles, project, file.isFile(), file.isDirectory(), name);
}
}
}
- private static void maybeAddInclude(IPath prefixPath, List<PotentialInclude> includeFiles,
- final IProject project, boolean isFile, boolean isDirectory, final String name) {
+ private static void maybeAddInclude(IPath prefixPath, List<PotentialInclude> includeFiles, final IProject project,
+ boolean isFile, boolean isDirectory, final String name) {
if (isFile) {
boolean definitelyHeader = CoreModel.isValidHeaderUnitName(project, name);
boolean definitelyNotHeader = false;
if (!definitelyHeader) {
- definitelyNotHeader = CoreModel.isValidSourceUnitName(project, name) || name.startsWith("."); //$NON-NLS-1$
+ definitelyNotHeader = CoreModel.isValidSourceUnitName(project, name) || name.startsWith("."); //$NON-NLS-1$
}
if (definitelyHeader || !definitelyNotHeader) {
includeFiles.add(new PotentialInclude(prefixPath.append(name).toString(), definitelyHeader));
}
} else if (isDirectory) {
- includeFiles.add(new PotentialInclude(
- prefixPath.append(name).addTrailingSeparator().toString(), true));
+ includeFiles.add(new PotentialInclude(prefixPath.append(name).addTrailingSeparator().toString(), true));
}
}
/**
* Collect include files from the given resource container.
- *
+ *
* @param tu the translation unit to include the file
* @param parent the resource container
* @param prefixPath the path part to match the sub-directory and file name
* @param includeFiles the result list
* @throws CoreException
*/
- private void collectIncludeFilesFromContainer(final ITranslationUnit tu, IContainer parent,
- IPath prefixPath, final List<PotentialInclude> includeFiles) throws CoreException {
+ private void collectIncludeFilesFromContainer(final ITranslationUnit tu, IContainer parent, IPath prefixPath,
+ final List<PotentialInclude> includeFiles) throws CoreException {
final String namePrefix;
if (prefixPath.segmentCount() == 0) {
- namePrefix= ""; //$NON-NLS-1$
+ namePrefix = ""; //$NON-NLS-1$
} else if (prefixPath.hasTrailingSeparator()) {
- namePrefix= ""; //$NON-NLS-1$
- prefixPath= prefixPath.removeTrailingSeparator();
+ namePrefix = ""; //$NON-NLS-1$
+ prefixPath = prefixPath.removeTrailingSeparator();
} else {
- namePrefix= prefixPath.lastSegment();
- prefixPath= prefixPath.removeLastSegments(1);
+ namePrefix = prefixPath.lastSegment();
+ prefixPath = prefixPath.removeLastSegments(1);
}
if (prefixPath.segmentCount() > 0) {
IPath parentPath = parent.getFullPath().append(prefixPath);
@@ -340,18 +345,19 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
if (!parent.exists()) {
return;
}
- final IPath cPrefixPath= prefixPath;
+ final IPath cPrefixPath = prefixPath;
final int prefixLength = namePrefix.length();
final IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(namePrefix);
- final IProject project= tu.getCProject().getProject();
+ final IProject project = tu.getCProject().getProject();
parent.accept(new IResourceProxyVisitor() {
- boolean fFirstVisit= true;
+ boolean fFirstVisit = true;
+
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
- final int type= proxy.getType();
- final String name= proxy.getName();
+ final int type = proxy.getType();
+ final String name = proxy.getName();
if (fFirstVisit) {
- fFirstVisit= false;
+ fFirstVisit = false;
return true;
}
if (name.length() >= prefixLength && matcher.match(name.toCharArray())) {
@@ -359,41 +365,41 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
type == IResource.FOLDER, name);
}
return false;
- }}, IResource.DEPTH_ONE);
+ }
+ }, IResource.DEPTH_ONE);
}
/**
* Compute the file name portion in an incomplete include directive.
- *
+ *
* @param context
* @return the file name portion including the opening bracket or quote
* @throws BadLocationException
*/
private String computeIncludePrefix(CContentAssistInvocationContext context) throws BadLocationException {
- IDocument document= context.getDocument();
+ IDocument document = context.getDocument();
if (document == null)
return null;
- int end= context.getInvocationOffset();
- int start= end;
+ int end = context.getInvocationOffset();
+ int start = end;
while (--start >= 0) {
- final char ch= document.getChar(start);
+ final char ch = document.getChar(start);
if (ch == '"' || ch == '<')
break;
}
return document.get(start, end - start);
}
-
/**
* Compute base relevance depending on quality of name / prefix match.
- *
+ *
* @param prefix the completion pefix
* @param match the matching identifier
* @return a relevance value inidicating the quality of the name match
*/
protected int computeRelevance(String prefix, PotentialInclude match) {
- int baseRelevance= 0;
- boolean caseMatch= prefix.length() > 0 && match.fPath.startsWith(prefix);
+ int baseRelevance = 0;
+ boolean caseMatch = prefix.length() > 0 && match.fPath.startsWith(prefix);
if (caseMatch) {
baseRelevance += RelevanceConstants.CASE_MATCH_RELEVANCE;
}
@@ -403,12 +409,14 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
return baseRelevance;
}
- private CCompletionProposal createProposal(int repOffset, int repLength, String repString, String dispString, Image image, int relevance, CContentAssistInvocationContext context) {
- return new CCompletionProposal(repString, repOffset, repLength, image, dispString, dispString, relevance, context.getViewer());
+ private CCompletionProposal createProposal(int repOffset, int repLength, String repString, String dispString,
+ Image image, int relevance, CContentAssistInvocationContext context) {
+ return new CCompletionProposal(repString, repOffset, repLength, image, dispString, dispString, relevance,
+ context.getViewer());
}
private Image getImage(ImageDescriptor desc) {
return desc != null ? CUIPlugin.getImageDescriptorRegistry().get(desc) : null;
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java
index 9912e577926..20b9f51ba6c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java
@@ -41,51 +41,48 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
public class KeywordCompletionProposalComputer extends ParsingBasedProposalComputer {
private static final int MIN_KEYWORD_LENGTH = 5;
-
+
@Override
- protected List<ICompletionProposal> computeCompletionProposals(
- CContentAssistInvocationContext context,
- IASTCompletionNode completionNode, String prefix)
- throws CoreException {
+ protected List<ICompletionProposal> computeCompletionProposals(CContentAssistInvocationContext context,
+ IASTCompletionNode completionNode, String prefix) throws CoreException {
if (prefix.length() == 0) {
try {
- prefix= context.computeIdentifierPrefix().toString();
+ prefix = context.computeIdentifierPrefix().toString();
} catch (BadLocationException exc) {
CUIPlugin.log(exc);
}
}
final int prefixLength = prefix.length();
// No prefix, no completions
- if (prefixLength == 0 || context.isContextInformationStyle())
- return Collections.emptyList();
+ if (prefixLength == 0 || context.isContextInformationStyle())
+ return Collections.emptyList();
- // keywords are matched case-sensitive
+ // keywords are matched case-sensitive
final int relevance = RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.KEYWORD_TYPE_RELEVANCE;
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
ICLanguageKeywords languageKeywords = null;
ITranslationUnit tu = context.getTranslationUnit();
- if(tu != null) {
- ILanguage language = tu.getLanguage();
- if(language != null)
- languageKeywords = language.getAdapter(ICLanguageKeywords.class);
- }
-
- if(languageKeywords == null)
- return Collections.emptyList();
-
-
+ if (tu != null) {
+ ILanguage language = tu.getLanguage();
+ if (language != null)
+ languageKeywords = language.getAdapter(ICLanguageKeywords.class);
+ }
+
+ if (languageKeywords == null)
+ return Collections.emptyList();
+
if (inPreprocessorDirective(context)) {
// TODO split this into a separate proposal computer?
- boolean needDirectiveKeyword= inPreprocessorKeyword(context);
+ boolean needDirectiveKeyword = inPreprocessorKeyword(context);
// add matching preprocessor keyword proposals
ImageDescriptor imagedesc = CElementImageProvider.getKeywordImageDescriptor();
Image image = imagedesc != null ? CUIPlugin.getImageDescriptorRegistry().get(imagedesc) : null;
-
- for(String keyword : languageKeywords.getPreprocessorKeywords()) {
+
+ for (String keyword : languageKeywords.getPreprocessorKeywords()) {
if (keyword.startsWith(prefix) && keyword.length() > prefixLength) {
String repString = keyword + ' ';
int repLength = prefixLength;
@@ -94,38 +91,39 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
// strip leading '#' from replacement
repLength--;
repOffset++;
- repString= repString.substring(1);
+ repString = repString.substring(1);
} else if (needDirectiveKeyword) {
continue;
}
- proposals.add(new CCompletionProposal(repString, repOffset,
- repLength, image, keyword, relevance, context.getViewer()));
+ proposals.add(new CCompletionProposal(repString, repOffset, repLength, image, keyword, relevance,
+ context.getViewer()));
}
}
} else {
- if (!isValidContext(completionNode))
- return Collections.emptyList();
-
+ if (!isValidContext(completionNode))
+ return Collections.emptyList();
+
// add matching keyword proposals
- ImageDescriptor imagedesc = CElementImageProvider.getKeywordImageDescriptor();
- Image image = imagedesc != null ? CUIPlugin.getImageDescriptorRegistry().get(imagedesc) : null;
-
- for(String keyword : languageKeywords.getKeywords()) {
- if (keyword.startsWith(prefix) && keyword.length() > prefixLength && keyword.length() >= MIN_KEYWORD_LENGTH) {
- int repLength = prefixLength;
- int repOffset = context.getInvocationOffset() - repLength;
- proposals.add(new CCompletionProposal(keyword, repOffset,
- repLength, image, keyword, relevance, context.getViewer()));
- }
- }
+ ImageDescriptor imagedesc = CElementImageProvider.getKeywordImageDescriptor();
+ Image image = imagedesc != null ? CUIPlugin.getImageDescriptorRegistry().get(imagedesc) : null;
+
+ for (String keyword : languageKeywords.getKeywords()) {
+ if (keyword.startsWith(prefix) && keyword.length() > prefixLength
+ && keyword.length() >= MIN_KEYWORD_LENGTH) {
+ int repLength = prefixLength;
+ int repOffset = context.getInvocationOffset() - repLength;
+ proposals.add(new CCompletionProposal(keyword, repOffset, repLength, image, keyword, relevance,
+ context.getViewer()));
+ }
+ }
}
-
- return proposals;
+
+ return proposals;
}
/**
* Checks whether the given invocation context looks valid for template completion.
- *
+ *
* @param context the content assist invocation context
* @return <code>false</code> if the given invocation context looks like a field reference
*/
@@ -133,41 +131,41 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
IASTName[] names = completionNode.getNames();
for (int i = 0; i < names.length; ++i) {
IASTName name = names[i];
-
+
// ignore if not connected
if (name.getTranslationUnit() == null)
continue;
-
+
// ignore if this is a member access
if (name.getParent() instanceof IASTFieldReference)
continue;
-
+
return true;
}
-
+
return false;
}
/**
* Test whether the invocation offset is inside or before the preprocessor directive keyword.
- *
+ *
* @param context the invocation context
* @return <code>true</code> if the invocation offset is inside or before the directive keyword
*/
private boolean inPreprocessorKeyword(CContentAssistInvocationContext context) {
IDocument doc = context.getDocument();
int offset = context.getInvocationOffset();
-
+
try {
- final ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+ final ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
- String ppPrefix= doc.get(partition.getOffset(), offset - partition.getOffset());
+ String ppPrefix = doc.get(partition.getOffset(), offset - partition.getOffset());
if (ppPrefix.matches("\\s*#\\s*\\w*")) { //$NON-NLS-1$
// we are inside the directive keyword
return true;
}
}
-
+
} catch (BadLocationException exc) {
}
return false;
@@ -175,20 +173,20 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
/**
* Check if the invocation offset is inside a preprocessor directive.
- *
+ *
* @param context the content asist invocation context
* @return <code>true</code> if invocation offset is inside a preprocessor directive
*/
private boolean inPreprocessorDirective(CContentAssistInvocationContext context) {
IDocument doc = context.getDocument();
int offset = context.getInvocationOffset();
-
+
try {
- final ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+ final ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
return true;
}
-
+
} catch (BadLocationException exc) {
}
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuesser.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuesser.java
index b72f6d32b1d..f6707458269 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuesser.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuesser.java
@@ -64,7 +64,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
/**
* This class is based on org.eclipse.jdt.internal.ui.text.java.ParameterGuesser
- *
+ *
* This class produces a logically-ordered list of applicable variables for later use as parameter guessing
* proposals for a function parameter.
*/
@@ -72,13 +72,11 @@ public class ParameterGuesser {
private final Set<String> fAlreadyMatchedNames = new HashSet<>();
/**
- * Variable type. Used to choose the best guess based on scope (LOCAL is preferred over FIELD,
+ * Variable type. Used to choose the best guess based on scope (LOCAL is preferred over FIELD,
* which is preferred over GLOBAL).
*/
static enum VariableType {
- LOCAL(0),
- FIELD(1),
- GLOBAL(3); // Give the global variables a lower priority.
+ LOCAL(0), FIELD(1), GLOBAL(3); // Give the global variables a lower priority.
private final int priority;
@@ -95,7 +93,7 @@ public class ParameterGuesser {
public final String name;
public final VariableType variableType;
public final int positionScore;
-
+
public int totalScore;
public final char[] triggerChars;
@@ -103,8 +101,8 @@ public class ParameterGuesser {
public boolean alreadyMatched;
- public Variable(String name, VariableType variableType, int positionScore,
- char[] triggerChars, ImageDescriptor descriptor) {
+ public Variable(String name, VariableType variableType, int positionScore, char[] triggerChars,
+ ImageDescriptor descriptor) {
this.name = name;
this.variableType = variableType;
this.positionScore = positionScore;
@@ -140,17 +138,13 @@ public class ParameterGuesser {
return null;
}
- private Variable createVariable(IBinding element, IType enclosingType, int positionScore)
- throws CModelException {
+ private Variable createVariable(IBinding element, IType enclosingType, int positionScore) throws CModelException {
IType elementType = getType(element);
String elementName = element.getName();
if (elementType != null && enclosingType != null
- && (elementType.toString().equals(enclosingType.toString())
- || elementType.isSameType(enclosingType)
- || isImplicitlyConvertible(enclosingType, elementType)
- || isParent(elementType, enclosingType)
- || isReferenceTo(enclosingType, elementType)
- || isReferenceTo(elementType, enclosingType))) {
+ && (elementType.toString().equals(enclosingType.toString()) || elementType.isSameType(enclosingType)
+ || isImplicitlyConvertible(enclosingType, elementType) || isParent(elementType, enclosingType)
+ || isReferenceTo(enclosingType, elementType) || isReferenceTo(elementType, enclosingType))) {
VariableType variableType = VariableType.GLOBAL;
if (element instanceof ICPPField) {
variableType = VariableType.FIELD;
@@ -185,11 +179,11 @@ public class ParameterGuesser {
}
return false;
}
-
+
private boolean isImplicitlyConvertible(IType orginType, IType candidateType) {
try {
- Cost cost = Conversions.checkImplicitConversionSequence(orginType, candidateType,
- ValueCategory.LVALUE, UDCMode.ALLOWED, Context.ORDINARY);
+ Cost cost = Conversions.checkImplicitConversionSequence(orginType, candidateType, ValueCategory.LVALUE,
+ UDCMode.ALLOWED, Context.ORDINARY);
if (cost.converts())
return true;
} catch (DOMException e) {
@@ -202,9 +196,9 @@ public class ParameterGuesser {
* Returns true, if the parent type is a direct/indirect parent of the child type
*/
private boolean isParent(IType child, IType parent) {
- if (child != null && parent != null
- && child instanceof ICPPClassType && !(child instanceof ICPPClassSpecialization)
- && parent instanceof ICPPClassType && !(parent instanceof ICPPClassSpecialization)) {
+ if (child != null && parent != null && child instanceof ICPPClassType
+ && !(child instanceof ICPPClassSpecialization) && parent instanceof ICPPClassType
+ && !(parent instanceof ICPPClassSpecialization)) {
ICPPBase[] bases = ((ICPPClassType) child).getBases();
for (ICPPBase base : bases) {
IType tmpType = base.getBaseClassType();
@@ -223,8 +217,7 @@ public class ParameterGuesser {
if (binding instanceof ITypedef) {
imageDescriptor = CElementImageProvider.getTypedefImageDescriptor();
} else if (binding instanceof ICompositeType) {
- if (((ICompositeType) binding).getKey() == ICPPClassType.k_class
- || binding instanceof ICPPClassTemplate)
+ if (((ICompositeType) binding).getKey() == ICPPClassType.k_class || binding instanceof ICPPClassTemplate)
imageDescriptor = CElementImageProvider.getClassImageDescriptor();
else if (((ICompositeType) binding).getKey() == ICompositeType.k_struct)
imageDescriptor = CElementImageProvider.getStructImageDescriptor();
@@ -236,8 +229,7 @@ public class ParameterGuesser {
imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PRIVATE);
break;
case ICPPMember.v_protected:
- imageDescriptor =
- CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PROTECTED);
+ imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PROTECTED);
break;
default:
imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PUBLIC);
@@ -251,8 +243,7 @@ public class ParameterGuesser {
imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PRIVATE);
break;
case ICPPMember.v_protected:
- imageDescriptor =
- CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PROTECTED);
+ imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PROTECTED);
break;
default:
imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC);
@@ -280,7 +271,7 @@ public class ParameterGuesser {
/**
* Returns the matches for the type and name argument, ordered by match quality.
- *
+ *
* @param expectedType the qualified type of the parameter we are trying to match
* @param paramName the name of the parameter (used to find similarly named matches)
* @param pos the position
@@ -289,8 +280,7 @@ public class ParameterGuesser {
* @return returns the name of the best match, or <code>null</code> if no match found
*/
public ICompletionProposal[] parameterProposals(IType expectedType, String paramName, Position pos,
- List<IBinding> suggestions, boolean isLastParameter)
- throws CModelException {
+ List<IBinding> suggestions, boolean isLastParameter) throws CModelException {
List<Variable> typeMatches = new ArrayList<>(evaluateVisibleMatches(expectedType, suggestions));
orderMatches(typeMatches, paramName);
@@ -313,8 +303,8 @@ public class ParameterGuesser {
System.arraycopy(v.triggerChars, 0, triggers, 0, v.triggerChars.length);
triggers[triggers.length - 1] = ',';
}
- ret[i++] = new PositionBasedCompletionProposal(v.name, pos, replacementLength,
- getImage(v.descriptor), displayString, null, null, triggers);
+ ret[i++] = new PositionBasedCompletionProposal(v.name, pos, replacementLength, getImage(v.descriptor),
+ displayString, null, null, triggers);
}
return ret;
}
@@ -365,7 +355,7 @@ public class ParameterGuesser {
/**
* The four order criteria as described below - put already used into bit 10, all others into bits
* 0-9, 11-20, 21-30; 31 is sign - always 0
- *
+ *
* @param v the variable
* @param parameterName the name of the parameter to be replaced.
* @return the score for <code>v</code>
@@ -379,12 +369,12 @@ public class ParameterGuesser {
int shorter = Math.min(v.name.length(), parameterName.length());
if (subStringScore < 0.6 * shorter)
subStringScore = 0;
-
+
int positionScore = v.positionScore;
int matchedScore = v.alreadyMatched ? 0 : 1;
-
+
int score = variableScore << 21 | subStringScore << 11 | matchedScore << 10 | positionScore;
-
+
return score;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java
index 1f64efbce3b..2d3815d5547 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParameterGuessingProposal.java
@@ -68,16 +68,16 @@ import org.eclipse.cdt.internal.ui.editor.EditorHighlightingSynchronizer;
/**
* This class is based on org.eclipse.jdt.internal.ui.text.java.ParameterGuessingProposal
- *
+ *
* Extents the basic Function Completion Proposal to add a linked mode for each of the function parameters
* with a list of suggestions for each parameter.
*/
public class ParameterGuessingProposal extends FunctionCompletionProposal {
- private ICompletionProposal[][] fChoices; // Initialized by guessParameters()
- private Position[] fPositions; // Initialized by guessParameters()
- private IRegion fSelectedRegion; // Initialized by apply()
+ private ICompletionProposal[][] fChoices; // Initialized by guessParameters()
+ private Position[] fPositions; // Initialized by guessParameters()
+ private IRegion fSelectedRegion; // Initialized by apply()
private IPositionUpdater fUpdater;
- private String fFullPrefix; // The string from the start of the statement to the invocation offset.
+ private String fFullPrefix; // The string from the start of the statement to the invocation offset.
private CEditor fCEditor;
private char[][] fParametersNames;
private IType[] fParametersTypes;
@@ -85,8 +85,7 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
private IASTCompletionNode fCompletionNode;
public static ParameterGuessingProposal createProposal(CContentAssistInvocationContext context,
- List<IBinding> availableElements, CCompletionProposal proposal, IFunction function,
- String prefix) {
+ List<IBinding> availableElements, CCompletionProposal proposal, IFunction function, String prefix) {
String replacement = getParametersList(function);
String fullPrefix = function.getName() + "("; //$NON-NLS-1$
int replacementOffset = proposal.getReplacementOffset();
@@ -120,10 +119,10 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
replacementOffset = proposal.getReplacementOffset();
}
replacementLength = prefix.length();
- ParameterGuessingProposal ret = new ParameterGuessingProposal(replacement, replacementOffset,
- replacementLength, proposal.getImage(), proposal.getDisplayString(), proposal.getIdString(),
- proposal.getRelevance(), context.getViewer(), function, invocationOffset, parseOffset,
- context.getTranslationUnit(), document, context.getCompletionNode());
+ ParameterGuessingProposal ret = new ParameterGuessingProposal(replacement, replacementOffset, replacementLength,
+ proposal.getImage(), proposal.getDisplayString(), proposal.getIdString(), proposal.getRelevance(),
+ context.getViewer(), function, invocationOffset, parseOffset, context.getTranslationUnit(), document,
+ context.getCompletionNode());
ret.setContextInformation(proposal.getContextInformation());
ret.fFullPrefix = fullPrefix;
ret.fCEditor = getCEditor(context.getEditor());
@@ -150,11 +149,11 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
}
public ParameterGuessingProposal(String replacementString, int replacementOffset, int replacementLength,
- Image image, String displayString, String idString, int relevance, ITextViewer viewer,
- IFunction function, int invocationOffset, int parseOffset, ITranslationUnit tu,
- IDocument document, IASTCompletionNode completionNode) {
- super(replacementString, replacementOffset, replacementLength, image, displayString, idString,
- relevance, viewer, function, invocationOffset, parseOffset, tu, document);
+ Image image, String displayString, String idString, int relevance, ITextViewer viewer, IFunction function,
+ int invocationOffset, int parseOffset, ITranslationUnit tu, IDocument document,
+ IASTCompletionNode completionNode) {
+ super(replacementString, replacementOffset, replacementLength, image, displayString, idString, relevance,
+ viewer, function, invocationOffset, parseOffset, tu, document);
fCompletionNode = completionNode;
}
@@ -181,7 +180,7 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
super.apply(document, trigger, offset);
generateParameterGuesses();
-
+
int baseOffset = getReplacementOffset();
String replacement = getReplacementString();
try {
@@ -230,8 +229,7 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
} else if (event.character == ')' && exitChar != ')') {
// exit from link mode when user is in the last ')' position.
Position position = fPositions[fPositions.length - 1];
- if (position.offset <= offset2
- && offset2 + length <= position.offset + position.length) {
+ if (position.offset <= offset2 && offset2 + length <= position.offset + position.length) {
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
}
}
@@ -258,24 +256,24 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
}
-
+
public void generateParameterGuesses() {
- IStatus status = ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_NO,
+ IStatus status = ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_NO,
new NullProgressMonitor(), new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
- try {
- CPPSemantics.pushLookupPoint(fCompletionNode.getTranslationUnit());
- guessParameters();
- } catch (Exception e) {
- CUIPlugin.log(e);
- return Status.CANCEL_STATUS;
- } finally {
- CPPSemantics.popLookupPoint();
- }
- return Status.OK_STATUS;
- }
- });
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+ try {
+ CPPSemantics.pushLookupPoint(fCompletionNode.getTranslationUnit());
+ guessParameters();
+ } catch (Exception e) {
+ CUIPlugin.log(e);
+ return Status.CANCEL_STATUS;
+ } finally {
+ CPPSemantics.popLookupPoint();
+ }
+ return Status.OK_STATUS;
+ }
+ });
if (Status.CANCEL_STATUS == status)
return;
}
@@ -297,8 +295,8 @@ public class ParameterGuessingProposal extends FunctionCompletionProposal {
boolean isLastParameter = i == count - 1;
ArrayList<ICompletionProposal> allProposals = new ArrayList<>();
- ICompletionProposal[] argumentProposals = guesser.parameterProposals(fParametersTypes[i],
- paramName, position, fAssignableElements, isLastParameter);
+ ICompletionProposal[] argumentProposals = guesser.parameterProposals(fParametersTypes[i], paramName,
+ position, fAssignableElements, isLastParameter);
allProposals.addAll(Arrays.asList(argumentProposals));
fPositions[i] = position;
fChoices[i] = argumentProposals;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java
index 3bce076964f..8209134f32d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java
@@ -33,21 +33,21 @@ import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
/**
* The base class for any proposal computers that require a completion node in
* order to determine its completion proposals.
- *
+ *
* @author Bryan Wilkinson
*/
public abstract class ParsingBasedProposalComputer implements ICompletionProposalComputer {
private String fErrorMessage;
-
+
@Override
- public List<ICompletionProposal> computeCompletionProposals(
- ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
try {
if (context instanceof CContentAssistInvocationContext) {
CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context;
-
+
IASTCompletionNode completionNode = cContext.getCompletionNode();
- if (completionNode == null)
+ if (completionNode == null)
return Collections.emptyList();
String prefix = completionNode.getPrefix();
if (prefix == null) {
@@ -63,26 +63,24 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
return Collections.emptyList();
}
-
- protected abstract List<ICompletionProposal> computeCompletionProposals(
- CContentAssistInvocationContext context,
- IASTCompletionNode completionNode,
- String prefix) throws CoreException;
-
+
+ protected abstract List<ICompletionProposal> computeCompletionProposals(CContentAssistInvocationContext context,
+ IASTCompletionNode completionNode, String prefix) throws CoreException;
+
@Override
- public List<IContextInformation> computeContextInformation(
- ContentAssistInvocationContext context, IProgressMonitor monitor) {
- Collection<ICompletionProposal> proposals= computeCompletionProposals(context, monitor);
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
+ Collection<ICompletionProposal> proposals = computeCompletionProposals(context, monitor);
// Remove duplicates
- proposals= (new LinkedHashSet<ICompletionProposal>(proposals));
- List<IContextInformation> result= new ArrayList<IContextInformation>();
+ proposals = (new LinkedHashSet<ICompletionProposal>(proposals));
+ List<IContextInformation> result = new ArrayList<IContextInformation>();
for (ICompletionProposal proposal : proposals) {
- IContextInformation contextInformation= proposal.getContextInformation();
+ IContextInformation contextInformation = proposal.getContextInformation();
if (contextInformation != null) {
result.add(contextInformation);
}
}
-
+
return result;
}
@@ -102,17 +100,17 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
/**
* Computes base relevance depending on quality of name / prefix match.
- *
+ *
* @param prefix the completion prefix
* @param match the matching identifier
* @return a relevance value indicating the quality of the name match
*/
protected int computeBaseRelevance(String prefix, String match) {
- boolean caseMatch= prefix.length() > 0 && match.startsWith(prefix);
+ boolean caseMatch = prefix.length() > 0 && match.startsWith(prefix);
if (caseMatch) {
return RelevanceConstants.CASE_MATCH_RELEVANCE;
}
- boolean exactNameMatch= match.equalsIgnoreCase(prefix);
+ boolean exactNameMatch = match.equalsIgnoreCase(prefix);
if (exactNameMatch) {
return RelevanceConstants.EXACT_NAME_MATCH_RELEVANCE;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/PositionBasedCompletionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/PositionBasedCompletionProposal.java
index ecb8c962c79..5208dffa23c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/PositionBasedCompletionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/PositionBasedCompletionProposal.java
@@ -31,7 +31,8 @@ import org.eclipse.swt.graphics.Point;
* An enhanced implementation of the <code>ICompletionProposal</code> interface implementing all the extension interfaces.
* It uses a position to track its replacement offset and length. The position must be set up externally.
*/
-public class PositionBasedCompletionProposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2 {
+public class PositionBasedCompletionProposal
+ implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2 {
/** The string to be displayed in the completion proposal popup */
private String fDisplayString;
/** The replacement string */
@@ -73,18 +74,20 @@ public class PositionBasedCompletionProposal implements ICompletionProposal, ICo
* @param additionalProposalInfo the additional information associated with this proposal
* @param triggers the trigger characters
*/
- public PositionBasedCompletionProposal(String replacementString, Position replacementPosition, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo, char[] triggers) {
+ public PositionBasedCompletionProposal(String replacementString, Position replacementPosition, int cursorPosition,
+ Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,
+ char[] triggers) {
Assert.isNotNull(replacementString);
Assert.isTrue(replacementPosition != null);
- fReplacementString= replacementString;
- fReplacementPosition= replacementPosition;
- fCursorPosition= cursorPosition;
- fImage= image;
- fDisplayString= displayString;
- fContextInformation= contextInformation;
- fAdditionalProposalInfo= additionalProposalInfo;
- fTriggerCharacters= triggers;
+ fReplacementString = replacementString;
+ fReplacementPosition = replacementPosition;
+ fCursorPosition = cursorPosition;
+ fImage = image;
+ fDisplayString = displayString;
+ fContextInformation = contextInformation;
+ fAdditionalProposalInfo = additionalProposalInfo;
+ fTriggerCharacters = triggers;
}
@Override
@@ -139,7 +142,7 @@ public class PositionBasedCompletionProposal implements ICompletionProposal, ICo
@Override
public boolean validate(IDocument document, int offset, DocumentEvent event) {
try {
- String content= document.get(fReplacementPosition.getOffset(), offset - fReplacementPosition.getOffset());
+ String content = document.get(fReplacementPosition.getOffset(), offset - fReplacementPosition.getOffset());
if (fReplacementString.startsWith(content))
return true;
} catch (BadLocationException e) {
@@ -169,4 +172,3 @@ public class PositionBasedCompletionProposal implements ICompletionProposal, ICo
return fReplacementPosition.getOffset();
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java
index e2d8e3e3679..eabd40da411 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java
@@ -15,18 +15,18 @@
package org.eclipse.cdt.internal.ui.text.contentassist;
public interface RelevanceConstants {
- /**
+ /**
* For inclusion proposals only, relevance increment for matches
* with a file type known to be a header file.
*/
final int FILE_TYPE_RELEVANCE = 2000;
-
+
/** Relevance increment for same case matches */
final int CASE_MATCH_RELEVANCE = 1000;
/** Relevance increment for exact name matches (disregarding case) */
final int EXACT_NAME_MATCH_RELEVANCE = 40;
-
+
/** Relevance constant for proposals contributed by help provider */
final int HELP_TYPE_RELEVANCE = 200;
@@ -48,8 +48,8 @@ public interface RelevanceConstants {
/** Relevance constant for (key-)word proposals */
final int KEYWORD_TYPE_RELEVANCE = 10;
-
+
/** Relevance constant for editor template proposals */
final int TEMPLATE_TYPE_RELEVANCE = 5;
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
index 8b2f8bb844e..2f057fbf330 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
@@ -53,51 +53,56 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
* Default constructor is required (executable extension).
*/
public TemplateCompletionProposalComputer() {
- TemplateContextType contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CContextType.ID);
+ TemplateContextType contextType = CUIPlugin.getDefault().getTemplateContextRegistry()
+ .getContextType(CContextType.ID);
if (contextType == null) {
- contextType= new CContextType();
+ contextType = new CContextType();
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
}
- fCTemplateEngine= new TemplateEngine(contextType);
- contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CommentContextType.ID);
+ fCTemplateEngine = new TemplateEngine(contextType);
+ contextType = CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CommentContextType.ID);
if (contextType == null) {
- contextType= new CommentContextType();
+ contextType = new CommentContextType();
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
}
- fCommentTemplateEngine= new TemplateEngine(contextType);
- contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(DocCommentContextType.ID);
+ fCommentTemplateEngine = new TemplateEngine(contextType);
+ contextType = CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(DocCommentContextType.ID);
if (contextType == null) {
- contextType= new DocCommentContextType();
+ contextType = new DocCommentContextType();
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
}
- fDocCommentTemplateEngine= new TemplateEngine(contextType);
+ fDocCommentTemplateEngine = new TemplateEngine(contextType);
}
-
+
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
- ITextViewer viewer= context.getViewer();
- int offset= context.getInvocationOffset();
- TemplateEngine engine= null;
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
+ ITextViewer viewer = context.getViewer();
+ int offset = context.getInvocationOffset();
+ TemplateEngine engine = null;
try {
- String partition= TextUtilities.getContentType(viewer.getDocument(), ICPartitions.C_PARTITIONING, offset, true);
- if (partition.equals(ICPartitions.C_MULTI_LINE_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
- engine= fCommentTemplateEngine;
- } else if (partition.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_DOC_COMMENT)) {
- engine= fDocCommentTemplateEngine;
+ String partition = TextUtilities.getContentType(viewer.getDocument(), ICPartitions.C_PARTITIONING, offset,
+ true);
+ if (partition.equals(ICPartitions.C_MULTI_LINE_COMMENT)
+ || partition.equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
+ engine = fCommentTemplateEngine;
+ } else if (partition.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)
+ || partition.equals(ICPartitions.C_SINGLE_LINE_DOC_COMMENT)) {
+ engine = fDocCommentTemplateEngine;
} else {
if (isValidContext(context)) {
- engine= fCTemplateEngine;
+ engine = fCTemplateEngine;
}
}
} catch (BadLocationException x) {
return Collections.emptyList();
}
-
+
if (engine != null && context instanceof CContentAssistInvocationContext) {
- CContentAssistInvocationContext cContext= (CContentAssistInvocationContext)context;
+ CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context;
ITranslationUnit tUnit = cContext.getTranslationUnit();
if (tUnit == null) {
return Collections.emptyList();
@@ -105,7 +110,7 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
engine.reset();
engine.complete(viewer, offset, tUnit);
- List<ICompletionProposal> result= engine.getResults();
+ List<ICompletionProposal> result = engine.getResults();
return result;
}
@@ -114,21 +119,22 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
/**
* Checks whether the given invocation context looks valid for template completion.
- *
+ *
* @param context the content assist invocation context
* @return <code>false</code> if the given invocation context looks like a field reference
*/
private boolean isValidContext(ContentAssistInvocationContext context) {
- CHeuristicScanner scanner= new CHeuristicScanner(context.getDocument());
- int start= context.getInvocationOffset();
- return !scanner.looksLikeFieldReferenceBackward(start, Math.max(0, start-100));
+ CHeuristicScanner scanner = new CHeuristicScanner(context.getDocument());
+ int start = context.getInvocationOffset();
+ return !scanner.looksLikeFieldReferenceBackward(start, Math.max(0, start - 100));
}
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
return Collections.emptyList();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java
index 0f6258f477f..7e1d8d4e0a7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -74,24 +74,25 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
public CCorrectionAssistant(ITextEditor editor) {
super();
Assert.isNotNull(editor);
- fEditor= editor;
+ fEditor = editor;
- CCorrectionProcessor processor= new CCorrectionProcessor(this);
+ CCorrectionProcessor processor = new CCorrectionProcessor(this);
setQuickAssistProcessor(processor);
- enableColoredLabels(PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
+ enableColoredLabels(
+ PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
setInformationControlCreator(getInformationControlCreator());
- CTextTools textTools= CUIPlugin.getDefault().getTextTools();
- IColorManager manager= textTools.getColorManager();
+ CTextTools textTools = CUIPlugin.getDefault().getTextTools();
+ IColorManager manager = textTools.getColorManager();
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- Color c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
+ Color c = getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
setProposalSelectorForeground(c);
- c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
+ c = getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
setProposalSelectorBackground(c);
}
@@ -99,7 +100,6 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
return fEditor;
}
-
private IInformationControlCreator getInformationControlCreator() {
return new IInformationControlCreator() {
@Override
@@ -110,7 +110,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
}
private static Color getColor(IPreferenceStore store, String key, IColorManager manager) {
- RGB rgb= PreferenceConverter.getColor(store, key);
+ RGB rgb = PreferenceConverter.getColor(store, key);
return manager.getColor(rgb);
}
@@ -120,9 +120,9 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
@Override
public void install(ISourceViewer sourceViewer) {
super.install(sourceViewer);
- fViewer= sourceViewer;
+ fViewer = sourceViewer;
- fLightBulbUpdater= new QuickAssistLightBulbUpdater(fEditor, sourceViewer);
+ fLightBulbUpdater = new QuickAssistLightBulbUpdater(fEditor, sourceViewer);
fLightBulbUpdater.install();
}
@@ -133,7 +133,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
public void uninstall() {
if (fLightBulbUpdater != null) {
fLightBulbUpdater.uninstall();
- fLightBulbUpdater= null;
+ fLightBulbUpdater = null;
}
super.uninstall();
}
@@ -149,22 +149,21 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
*/
@Override
public String showPossibleQuickAssists() {
- fPosition= null;
- fCurrentAnnotations= null;
-
+ fPosition = null;
+ fCurrentAnnotations = null;
+
if (fViewer == null || fViewer.getDocument() == null)
// Let superclass deal with this
return super.showPossibleQuickAssists();
-
- ArrayList<Annotation> resultingAnnotations= new ArrayList<Annotation>(20);
+ ArrayList<Annotation> resultingAnnotations = new ArrayList<Annotation>(20);
try {
- Point selectedRange= fViewer.getSelectedRange();
- int currOffset= selectedRange.x;
- int currLength= selectedRange.y;
- boolean goToClosest= (currLength == 0);
-
- int newOffset= collectQuickFixableAnnotations(fEditor, currOffset, goToClosest, resultingAnnotations);
+ Point selectedRange = fViewer.getSelectedRange();
+ int currOffset = selectedRange.x;
+ int currLength = selectedRange.y;
+ boolean goToClosest = (currLength == 0);
+
+ int newOffset = collectQuickFixableAnnotations(fEditor, currOffset, goToClosest, resultingAnnotations);
if (newOffset != currOffset) {
storePosition(currOffset, currLength);
fViewer.setSelectedRange(newOffset, 0);
@@ -173,60 +172,61 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
} catch (BadLocationException e) {
CUIPlugin.log(e);
}
- fCurrentAnnotations= resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
+ fCurrentAnnotations = resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
return super.showPossibleQuickAssists();
}
-
-
+
private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException {
- IDocumentProvider documentProvider= editor.getDocumentProvider();
+ IDocumentProvider documentProvider = editor.getDocumentProvider();
if (documentProvider == null) {
return null;
}
- IDocument document= documentProvider.getDocument(editor.getEditorInput());
+ IDocument document = documentProvider.getDocument(editor.getEditorInput());
if (document == null) {
return null;
}
return document.getLineInformationOfOffset(invocationLocation);
}
-
- public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation, boolean goToClosest, ArrayList<Annotation> resultingAnnotations) throws BadLocationException {
- IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(editor.getEditorInput());
+
+ public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation, boolean goToClosest,
+ ArrayList<Annotation> resultingAnnotations) throws BadLocationException {
+ IAnnotationModel model = CUIPlugin.getDefault().getDocumentProvider()
+ .getAnnotationModel(editor.getEditorInput());
if (model == null) {
return invocationLocation;
}
-
+
ensureUpdatedAnnotations(editor);
-
- Iterator<?> iter= model.getAnnotationIterator();
+
+ Iterator<?> iter = model.getAnnotationIterator();
if (goToClosest) {
- IRegion lineInfo= getRegionOfInterest(editor, invocationLocation);
+ IRegion lineInfo = getRegionOfInterest(editor, invocationLocation);
if (lineInfo == null) {
return invocationLocation;
}
- int rangeStart= lineInfo.getOffset();
- int rangeEnd= rangeStart + lineInfo.getLength();
-
- ArrayList<Annotation> allAnnotations= new ArrayList<Annotation>();
- ArrayList<Position> allPositions= new ArrayList<Position>();
- int bestOffset= Integer.MAX_VALUE;
+ int rangeStart = lineInfo.getOffset();
+ int rangeEnd = rangeStart + lineInfo.getLength();
+
+ ArrayList<Annotation> allAnnotations = new ArrayList<Annotation>();
+ ArrayList<Position> allPositions = new ArrayList<Position>();
+ int bestOffset = Integer.MAX_VALUE;
while (iter.hasNext()) {
- Annotation annot= (Annotation) iter.next();
+ Annotation annot = (Annotation) iter.next();
if (CCorrectionProcessor.isQuickFixableType(annot)) {
- Position pos= model.getPosition(annot);
+ Position pos = model.getPosition(annot);
if (pos != null && isInside(pos.offset, rangeStart, rangeEnd)) { // inside our range?
allAnnotations.add(annot);
allPositions.add(pos);
- bestOffset= processAnnotation(annot, pos, invocationLocation, bestOffset);
+ bestOffset = processAnnotation(annot, pos, invocationLocation, bestOffset);
}
}
}
if (bestOffset == Integer.MAX_VALUE) {
return invocationLocation;
}
- for (int i= 0; i < allPositions.size(); i++) {
- Position pos= allPositions.get(i);
+ for (int i = 0; i < allPositions.size(); i++) {
+ Position pos = allPositions.get(i);
if (isInside(bestOffset, pos.offset, pos.offset + pos.length)) {
resultingAnnotations.add(allAnnotations.get(i));
}
@@ -234,9 +234,9 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
return bestOffset;
}
while (iter.hasNext()) {
- Annotation annot= (Annotation) iter.next();
+ Annotation annot = (Annotation) iter.next();
if (CCorrectionProcessor.isQuickFixableType(annot)) {
- Position pos= model.getPosition(annot);
+ Position pos = model.getPosition(annot);
if (pos != null && isInside(invocationLocation, pos.offset, pos.offset + pos.length)) {
resultingAnnotations.add(annot);
}
@@ -246,26 +246,27 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
}
private static void ensureUpdatedAnnotations(ITextEditor editor) {
- Object inputElement= editor.getEditorInput().getAdapter(ICElement.class);
+ Object inputElement = editor.getEditorInput().getAdapter(ICElement.class);
if (inputElement instanceof ITranslationUnit) {
- final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
- astProvider.runOnAST((ITranslationUnit) inputElement, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTCache.ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
- return Status.OK_STATUS;
- }
- });
+ final ASTProvider astProvider = CUIPlugin.getDefault().getASTProvider();
+ astProvider.runOnAST((ITranslationUnit) inputElement, ASTProvider.WAIT_ACTIVE_ONLY, null,
+ new ASTCache.ASTRunnable() {
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+ return Status.OK_STATUS;
+ }
+ });
}
}
private static int processAnnotation(Annotation annot, Position pos, int invocationLocation, int bestOffset) {
- int posBegin= pos.offset;
- int posEnd= posBegin + pos.length;
+ int posBegin = pos.offset;
+ int posEnd = posBegin + pos.length;
if (isInside(invocationLocation, posBegin, posEnd)) { // covers invocation location?
return invocationLocation;
} else if (bestOffset != invocationLocation) {
- int newClosestPosition= computeBestOffset(posBegin, invocationLocation, bestOffset);
- if (newClosestPosition != -1) {
+ int newClosestPosition = computeBestOffset(posBegin, invocationLocation, bestOffset);
+ if (newClosestPosition != -1) {
if (newClosestPosition != bestOffset) { // new best
if (CCorrectionProcessor.hasCorrections(annot)) { // only jump to it if there are proposals
return newClosestPosition;
@@ -316,7 +317,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
}
private void storePosition(int currOffset, int currLength) {
- fPosition= new Position(currOffset, currLength);
+ fPosition = new Position(currOffset, currLength);
}
private void restorePosition() {
@@ -324,7 +325,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
fViewer.setSelectedRange(fPosition.offset, fPosition.length);
fViewer.revealRange(fPosition.offset, fPosition.length);
}
- fPosition= null;
+ fPosition = null;
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java
index 6ef615bb3f5..0342e7d2f63 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java
@@ -56,19 +56,21 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposalCompara
import org.eclipse.cdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal;
public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.IQuickAssistProcessor {
- private static final String QUICKFIX_PROCESSOR_CONTRIBUTION_ID= "quickFixProcessors"; //$NON-NLS-1$
- private static final String QUICKASSIST_PROCESSOR_CONTRIBUTION_ID= "quickAssistProcessors"; //$NON-NLS-1$
+ private static final String QUICKFIX_PROCESSOR_CONTRIBUTION_ID = "quickFixProcessors"; //$NON-NLS-1$
+ private static final String QUICKASSIST_PROCESSOR_CONTRIBUTION_ID = "quickAssistProcessors"; //$NON-NLS-1$
- private static ContributedProcessorDescriptor[] fgContributedAssistProcessors= null;
- private static ContributedProcessorDescriptor[] fgContributedCorrectionProcessors= null;
+ private static ContributedProcessorDescriptor[] fgContributedAssistProcessors = null;
+ private static ContributedProcessorDescriptor[] fgContributedCorrectionProcessors = null;
- private static ContributedProcessorDescriptor[] getProcessorDescriptors(String contributionId, boolean testMarkerTypes) {
- IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, contributionId);
- ArrayList<ContributedProcessorDescriptor> res= new ArrayList<ContributedProcessorDescriptor>(elements.length);
+ private static ContributedProcessorDescriptor[] getProcessorDescriptors(String contributionId,
+ boolean testMarkerTypes) {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry()
+ .getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, contributionId);
+ ArrayList<ContributedProcessorDescriptor> res = new ArrayList<ContributedProcessorDescriptor>(elements.length);
- for (int i= 0; i < elements.length; i++) {
- ContributedProcessorDescriptor desc= new ContributedProcessorDescriptor(elements[i], testMarkerTypes);
- IStatus status= desc.checkSyntax();
+ for (int i = 0; i < elements.length; i++) {
+ ContributedProcessorDescriptor desc = new ContributedProcessorDescriptor(elements[i], testMarkerTypes);
+ IStatus status = desc.checkSyntax();
if (status.isOK()) {
res.add(desc);
} else {
@@ -80,22 +82,22 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
private static ContributedProcessorDescriptor[] getCorrectionProcessors() {
if (fgContributedCorrectionProcessors == null) {
- fgContributedCorrectionProcessors= getProcessorDescriptors(QUICKFIX_PROCESSOR_CONTRIBUTION_ID, true);
+ fgContributedCorrectionProcessors = getProcessorDescriptors(QUICKFIX_PROCESSOR_CONTRIBUTION_ID, true);
}
return fgContributedCorrectionProcessors;
}
private static ContributedProcessorDescriptor[] getAssistProcessors() {
if (fgContributedAssistProcessors == null) {
- fgContributedAssistProcessors= getProcessorDescriptors(QUICKASSIST_PROCESSOR_CONTRIBUTION_ID, false);
+ fgContributedAssistProcessors = getProcessorDescriptors(QUICKASSIST_PROCESSOR_CONTRIBUTION_ID, false);
}
return fgContributedAssistProcessors;
}
public static boolean hasCorrections(ITranslationUnit tu, int problemId, String markerType) {
- ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
- SafeHasCorrections collector= new SafeHasCorrections(tu, problemId);
- for (int i= 0; i < processors.length; i++) {
+ ContributedProcessorDescriptor[] processors = getCorrectionProcessors();
+ SafeHasCorrections collector = new SafeHasCorrections(tu, problemId);
+ for (int i = 0; i < processors.length; i++) {
if (processors[i].canHandleMarkerType(markerType)) {
collector.process(processors[i]);
if (collector.hasCorrections()) {
@@ -107,15 +109,16 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
}
public static boolean isQuickFixableType(Annotation annotation) {
- return (annotation instanceof ICAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
+ return (annotation instanceof ICAnnotation || annotation instanceof SimpleMarkerAnnotation)
+ && !annotation.isMarkedDeleted();
}
public static boolean hasCorrections(Annotation annotation) {
if (annotation instanceof ICAnnotation) {
- ICAnnotation cAnnotation= (ICAnnotation) annotation;
- int problemId= cAnnotation.getId();
+ ICAnnotation cAnnotation = (ICAnnotation) annotation;
+ int problemId = cAnnotation.getId();
if (problemId != -1) {
- ITranslationUnit tu= cAnnotation.getTranslationUnit();
+ ITranslationUnit tu = cAnnotation.getTranslationUnit();
if (tu != null) {
return hasCorrections(tu, problemId, cAnnotation.getMarkerType());
}
@@ -131,15 +134,15 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
if (marker == null || !marker.exists())
return false;
- IMarkerHelpRegistry registry= IDE.getMarkerHelpRegistry();
+ IMarkerHelpRegistry registry = IDE.getMarkerHelpRegistry();
return registry != null && registry.hasResolutions(marker);
}
public static boolean hasAssists(CorrectionContext context) {
- ContributedProcessorDescriptor[] processors= getAssistProcessors();
- SafeHasAssist collector= new SafeHasAssist(context);
+ ContributedProcessorDescriptor[] processors = getAssistProcessors();
+ SafeHasAssist collector = new SafeHasAssist(context);
- for (int i= 0; i < processors.length; i++) {
+ for (int i = 0; i < processors.length; i++) {
collector.process(processors[i]);
if (collector.hasAssists()) {
return true;
@@ -155,14 +158,14 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
* Constructor for CCorrectionProcessor.
*/
public CCorrectionProcessor(CCorrectionAssistant assistant) {
- fAssistant= assistant;
+ fAssistant = assistant;
fAssistant.addCompletionListener(new ICompletionListener() {
-
+
@Override
public void assistSessionEnded(ContentAssistEvent event) {
fAssistant.setStatusLineVisible(false);
}
-
+
@Override
public void assistSessionStarted(ContentAssistEvent event) {
fAssistant.setStatusLineVisible(true);
@@ -171,8 +174,8 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
@Override
public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
if (proposal instanceof IStatusLineProposal) {
- IStatusLineProposal statusLineProposal= (IStatusLineProposal)proposal;
- String message= statusLineProposal.getStatusMessage();
+ IStatusLineProposal statusLineProposal = (IStatusLineProposal) proposal;
+ String message = statusLineProposal.getStatusMessage();
if (message != null) {
fAssistant.setStatusMessage(message);
} else {
@@ -190,35 +193,36 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
*/
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) {
- ISourceViewer viewer= quickAssistContext.getSourceViewer();
- int documentOffset= quickAssistContext.getOffset();
-
- IEditorPart part= fAssistant.getEditor();
-
- ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(part.getEditorInput());
- IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(part.getEditorInput());
-
- int length= viewer != null ? viewer.getSelectedRange().y : 0;
- CorrectionContext context= new CorrectionContext(tu, viewer, documentOffset, length);
-
- Annotation[] annotations= fAssistant.getAnnotationsAtOffset();
-
- fErrorMessage= null;
-
- ICCompletionProposal[] res= null;
+ ISourceViewer viewer = quickAssistContext.getSourceViewer();
+ int documentOffset = quickAssistContext.getOffset();
+
+ IEditorPart part = fAssistant.getEditor();
+
+ ITranslationUnit tu = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(part.getEditorInput());
+ IAnnotationModel model = CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(part.getEditorInput());
+
+ int length = viewer != null ? viewer.getSelectedRange().y : 0;
+ CorrectionContext context = new CorrectionContext(tu, viewer, documentOffset, length);
+
+ Annotation[] annotations = fAssistant.getAnnotationsAtOffset();
+
+ fErrorMessage = null;
+
+ ICCompletionProposal[] res = null;
if (model != null && annotations != null) {
- ArrayList<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>(10);
- IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals);
- res= proposals.toArray(new ICCompletionProposal[proposals.size()]);
+ ArrayList<ICCompletionProposal> proposals = new ArrayList<ICCompletionProposal>(10);
+ IStatus status = collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(),
+ proposals);
+ res = proposals.toArray(new ICCompletionProposal[proposals.size()]);
if (!status.isOK()) {
- fErrorMessage= status.getMessage();
+ fErrorMessage = status.getMessage();
CUIPlugin.log(status);
}
}
-
+
if (res == null || res.length == 0) {
- return new ICCompletionProposal[]
- { new ChangeCorrectionProposal(CorrectionMessages.NoCorrectionProposal_description, new NullChange(""), 0, null) }; //$NON-NLS-1$
+ return new ICCompletionProposal[] { new ChangeCorrectionProposal(
+ CorrectionMessages.NoCorrectionProposal_description, new NullChange(""), 0, null) }; //$NON-NLS-1$
}
if (res.length > 1) {
Arrays.sort(res, new CCompletionProposalComparator());
@@ -226,14 +230,15 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
return res;
}
- public static IStatus collectProposals(CorrectionContext context, IAnnotationModel model, Annotation[] annotations, boolean addQuickFixes, boolean addQuickAssists, Collection<ICCompletionProposal> proposals) {
- ArrayList<ProblemLocation> problems= new ArrayList<ProblemLocation>();
-
+ public static IStatus collectProposals(CorrectionContext context, IAnnotationModel model, Annotation[] annotations,
+ boolean addQuickFixes, boolean addQuickAssists, Collection<ICCompletionProposal> proposals) {
+ ArrayList<ProblemLocation> problems = new ArrayList<ProblemLocation>();
+
// collect problem locations and corrections from marker annotations
- for (int i= 0; i < annotations.length; i++) {
- Annotation curr= annotations[i];
+ for (int i = 0; i < annotations.length; i++) {
+ Annotation curr = annotations[i];
if (curr instanceof ICAnnotation) {
- ProblemLocation problemLocation= getProblemLocation((ICAnnotation) curr, model);
+ ProblemLocation problemLocation = getProblemLocation((ICAnnotation) curr, model);
if (problemLocation != null) {
problems.add(problemLocation);
}
@@ -243,21 +248,23 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
collectMarkerProposals((SimpleMarkerAnnotation) curr, proposals);
}
}
- MultiStatus resStatus= null;
-
- IProblemLocation[] problemLocations= problems.toArray(new IProblemLocation[problems.size()]);
+ MultiStatus resStatus = null;
+
+ IProblemLocation[] problemLocations = problems.toArray(new IProblemLocation[problems.size()]);
if (addQuickFixes) {
- IStatus status= collectCorrections(context, problemLocations, proposals);
+ IStatus status = collectCorrections(context, problemLocations, proposals);
if (!status.isOK()) {
- resStatus= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.ERROR, CorrectionMessages.CCorrectionProcessor_error_quickfix_message, null);
+ resStatus = new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.ERROR,
+ CorrectionMessages.CCorrectionProcessor_error_quickfix_message, null);
resStatus.add(status);
}
}
if (addQuickAssists) {
- IStatus status= collectAssists(context, problemLocations, proposals);
+ IStatus status = collectAssists(context, problemLocations, proposals);
if (!status.isOK()) {
if (resStatus == null) {
- resStatus= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.ERROR, CorrectionMessages.CCorrectionProcessor_error_quickassist_message, null);
+ resStatus = new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.ERROR,
+ CorrectionMessages.CCorrectionProcessor_error_quickassist_message, null);
}
resStatus.add(status);
}
@@ -267,11 +274,11 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
}
return Status.OK_STATUS;
}
-
+
private static ProblemLocation getProblemLocation(ICAnnotation cAnnotation, IAnnotationModel model) {
- int problemId= cAnnotation.getId();
+ int problemId = cAnnotation.getId();
if (problemId != -1) {
- Position pos= model.getPosition((Annotation) cAnnotation);
+ Position pos = model.getPosition((Annotation) cAnnotation);
if (pos != null) {
return new ProblemLocation(pos.getOffset(), pos.getLength(), cAnnotation); // java problems all handled by the quick assist processors
}
@@ -279,29 +286,30 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
return null;
}
- private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection<ICCompletionProposal> proposals) {
- IMarker marker= annotation.getMarker();
- IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
+ private static void collectMarkerProposals(SimpleMarkerAnnotation annotation,
+ Collection<ICCompletionProposal> proposals) {
+ IMarker marker = annotation.getMarker();
+ IMarkerResolution[] res = IDE.getMarkerHelpRegistry().getResolutions(marker);
if (res.length > 0) {
- for (int i= 0; i < res.length; i++) {
+ for (int i = 0; i < res.length; i++) {
proposals.add(new MarkerResolutionProposal(res[i], marker));
}
}
}
private static abstract class SafeCorrectionProcessorAccess implements ISafeRunnable {
- private MultiStatus fMulti= null;
+ private MultiStatus fMulti = null;
private ContributedProcessorDescriptor fDescriptor;
public void process(ContributedProcessorDescriptor[] desc) {
- for (int i= 0; i < desc.length; i++) {
- fDescriptor= desc[i];
+ for (int i = 0; i < desc.length; i++) {
+ fDescriptor = desc[i];
SafeRunner.run(this);
}
}
public void process(ContributedProcessorDescriptor desc) {
- fDescriptor= desc;
+ fDescriptor = desc;
SafeRunner.run(this);
}
@@ -315,9 +323,11 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
@Override
public void handleException(Throwable exception) {
if (fMulti == null) {
- fMulti= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.OK, CorrectionMessages.CCorrectionProcessor_error_status, null);
+ fMulti = new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.OK,
+ CorrectionMessages.CCorrectionProcessor_error_status, null);
}
- fMulti.merge(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR, CorrectionMessages.CCorrectionProcessor_error_status, exception));
+ fMulti.merge(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR,
+ CorrectionMessages.CCorrectionProcessor_error_status, exception));
}
public IStatus getStatus() {
@@ -334,21 +344,21 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
private IProblemLocation[] fLocations;
public SafeCorrectionCollector(CorrectionContext context, Collection<ICCompletionProposal> proposals) {
- fContext= context;
- fProposals= proposals;
+ fContext = context;
+ fProposals = proposals;
}
-
+
public void setProblemLocations(IProblemLocation[] locations) {
- fLocations= locations;
+ fLocations = locations;
}
@Override
public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
- IQuickFixProcessor curr= (IQuickFixProcessor) desc.getProcessor(fContext.getTranslationUnit());
+ IQuickFixProcessor curr = (IQuickFixProcessor) desc.getProcessor(fContext.getTranslationUnit());
if (curr != null) {
- ICCompletionProposal[] res= curr.getCorrections(fContext, fLocations);
+ ICCompletionProposal[] res = curr.getCorrections(fContext, fLocations);
if (res != null) {
- for (int k= 0; k < res.length; k++) {
+ for (int k = 0; k < res.length; k++) {
fProposals.add(res[k]);
}
}
@@ -361,19 +371,20 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
private final IProblemLocation[] fLocations;
private final Collection<ICCompletionProposal> fProposals;
- public SafeAssistCollector(IInvocationContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
- fContext= context;
- fLocations= locations;
- fProposals= proposals;
+ public SafeAssistCollector(IInvocationContext context, IProblemLocation[] locations,
+ Collection<ICCompletionProposal> proposals) {
+ fContext = context;
+ fLocations = locations;
+ fProposals = proposals;
}
@Override
public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
- IQuickAssistProcessor curr= (IQuickAssistProcessor) desc.getProcessor(fContext.getTranslationUnit());
+ IQuickAssistProcessor curr = (IQuickAssistProcessor) desc.getProcessor(fContext.getTranslationUnit());
if (curr != null) {
- ICCompletionProposal[] res= curr.getAssists(fContext, fLocations);
+ ICCompletionProposal[] res = curr.getAssists(fContext, fLocations);
if (res != null) {
- for (int k= 0; k < res.length; k++) {
+ for (int k = 0; k < res.length; k++) {
fProposals.add(res[k]);
}
}
@@ -386,8 +397,8 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
private boolean fHasAssists;
public SafeHasAssist(CorrectionContext context) {
- fContext= context;
- fHasAssists= false;
+ fContext = context;
+ fHasAssists = false;
}
public boolean hasAssists() {
@@ -396,9 +407,9 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
@Override
public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
- IQuickAssistProcessor processor= (IQuickAssistProcessor) desc.getProcessor(fContext.getTranslationUnit());
+ IQuickAssistProcessor processor = (IQuickAssistProcessor) desc.getProcessor(fContext.getTranslationUnit());
if (processor != null && processor.hasAssists(fContext)) {
- fHasAssists= true;
+ fHasAssists = true;
}
}
}
@@ -409,9 +420,9 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
private boolean fHasCorrections;
public SafeHasCorrections(ITranslationUnit tu, int problemId) {
- fCu= tu;
- fProblemId= problemId;
- fHasCorrections= false;
+ fCu = tu;
+ fProblemId = problemId;
+ fHasCorrections = false;
}
public boolean hasCorrections() {
@@ -420,19 +431,20 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
@Override
public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
- IQuickFixProcessor processor= (IQuickFixProcessor) desc.getProcessor(fCu);
+ IQuickFixProcessor processor = (IQuickFixProcessor) desc.getProcessor(fCu);
if (processor != null && processor.hasCorrections(fCu, fProblemId)) {
- fHasCorrections= true;
+ fHasCorrections = true;
}
}
}
- public static IStatus collectCorrections(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
- ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
- SafeCorrectionCollector collector= new SafeCorrectionCollector(context, proposals);
- for (int i= 0; i < processors.length; i++) {
- ContributedProcessorDescriptor curr= processors[i];
- IProblemLocation[] handled= getHandledProblems(locations, curr);
+ public static IStatus collectCorrections(CorrectionContext context, IProblemLocation[] locations,
+ Collection<ICCompletionProposal> proposals) {
+ ContributedProcessorDescriptor[] processors = getCorrectionProcessors();
+ SafeCorrectionCollector collector = new SafeCorrectionCollector(context, proposals);
+ for (int i = 0; i < processors.length; i++) {
+ ContributedProcessorDescriptor curr = processors[i];
+ IProblemLocation[] handled = getHandledProblems(locations, curr);
if (handled != null) {
collector.setProblemLocations(handled);
collector.process(curr);
@@ -441,27 +453,28 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
return collector.getStatus();
}
- private static IProblemLocation[] getHandledProblems(IProblemLocation[] locations, ContributedProcessorDescriptor processor) {
+ private static IProblemLocation[] getHandledProblems(IProblemLocation[] locations,
+ ContributedProcessorDescriptor processor) {
// implementation tries to avoid creating a new array
- boolean allHandled= true;
- ArrayList<IProblemLocation> res= null;
- for (int i= 0; i < locations.length; i++) {
- IProblemLocation curr= locations[i];
+ boolean allHandled = true;
+ ArrayList<IProblemLocation> res = null;
+ for (int i = 0; i < locations.length; i++) {
+ IProblemLocation curr = locations[i];
if (processor.canHandleMarkerType(curr.getMarkerType())) {
if (!allHandled) { // first handled problem
if (res == null) {
- res= new ArrayList<IProblemLocation>(locations.length - i);
+ res = new ArrayList<IProblemLocation>(locations.length - i);
}
res.add(curr);
}
- } else if (allHandled) {
- if (i > 0) { // first non handled problem
- res= new ArrayList<IProblemLocation>(locations.length - i);
- for (int k= 0; k < i; k++) {
+ } else if (allHandled) {
+ if (i > 0) { // first non handled problem
+ res = new ArrayList<IProblemLocation>(locations.length - i);
+ for (int k = 0; k < i; k++) {
res.add(locations[k]);
}
}
- allHandled= false;
+ allHandled = false;
}
}
if (allHandled) {
@@ -473,9 +486,10 @@ public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.
return res.toArray(new IProblemLocation[res.size()]);
}
- public static IStatus collectAssists(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
- ContributedProcessorDescriptor[] processors= getAssistProcessors();
- SafeAssistCollector collector= new SafeAssistCollector(context, locations, proposals);
+ public static IStatus collectAssists(CorrectionContext context, IProblemLocation[] locations,
+ Collection<ICCompletionProposal> proposals) {
+ ContributedProcessorDescriptor[] processors = getAssistProcessors();
+ SafeAssistCollector collector = new SafeAssistCollector(context, locations, proposals);
collector.process(processors);
return collector.getStatus();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java
index caa35a24bd3..b9693fef977 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java
@@ -46,144 +46,146 @@ import org.eclipse.cdt.internal.ui.editor.OverrideIndicatorManager;
*/
public class CSelectAnnotationRulerAction extends SelectMarkerRulerAction {
- private ITextEditor fTextEditor;
- private Position fPosition;
- private AnnotationPreferenceLookup fAnnotationPreferenceLookup;
- private IPreferenceStore fStore;
- private ResourceBundle fBundle;
- // Annotations at the ruler's current line of activity, keyed by their presentation layer,
- // in decreasing order (i.e. top to bottom).
- private static Comparator<Integer> decreasingOrder = new Comparator<Integer>(){
+ private ITextEditor fTextEditor;
+ private Position fPosition;
+ private AnnotationPreferenceLookup fAnnotationPreferenceLookup;
+ private IPreferenceStore fStore;
+ private ResourceBundle fBundle;
+ // Annotations at the ruler's current line of activity, keyed by their presentation layer,
+ // in decreasing order (i.e. top to bottom).
+ private static Comparator<Integer> decreasingOrder = new Comparator<Integer>() {
@Override
public int compare(Integer a, Integer b) {
return b - a;
- }};
- private TreeMap<Integer, Annotation> fAnnotations = new TreeMap<>(decreasingOrder);
- // For each layer, whether the annotation at that layer has a correction.
- private TreeMap<Integer, Boolean> fHasCorrection = new TreeMap<>(decreasingOrder);
-
- public CSelectAnnotationRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo ruler) {
- super(bundle, prefix, editor, ruler);
- fBundle= bundle;
- fTextEditor= editor;
+ }
+ };
+ private TreeMap<Integer, Annotation> fAnnotations = new TreeMap<>(decreasingOrder);
+ // For each layer, whether the annotation at that layer has a correction.
+ private TreeMap<Integer, Boolean> fHasCorrection = new TreeMap<>(decreasingOrder);
+
+ public CSelectAnnotationRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor,
+ IVerticalRulerInfo ruler) {
+ super(bundle, prefix, editor, ruler);
+ fBundle = bundle;
+ fTextEditor = editor;
+
+ fAnnotationPreferenceLookup = EditorsUI.getAnnotationPreferenceLookup();
+ fStore = CUIPlugin.getDefault().getCombinedPreferenceStore();
+ }
+
+ @Override
+ public void run() {
+ // is there an equivalent preference for the C Editor?
+ // if (fStore.getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
+ // return;
- fAnnotationPreferenceLookup= EditorsUI.getAnnotationPreferenceLookup();
- fStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
- }
+ runWithEvent(null);
+ }
- @Override
- public void run() {
- // is there an equivalent preference for the C Editor?
- // if (fStore.getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
- // return;
-
- runWithEvent(null);
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
- */
- @Override
+ /*
+ * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
public void runWithEvent(Event event) {
- // Give each annotation at the current line, from top to bottom, a chance to handle
- // the action. If there are no takers, fall back to the super class implementation.
- for (Integer layer : fAnnotations.keySet()) {
- Annotation annotation = fAnnotations.get(layer);
+ // Give each annotation at the current line, from top to bottom, a chance to handle
+ // the action. If there are no takers, fall back to the super class implementation.
+ for (Integer layer : fAnnotations.keySet()) {
+ Annotation annotation = fAnnotations.get(layer);
if (annotation instanceof OverrideIndicatorManager.OverrideIndicator) {
- ((OverrideIndicatorManager.OverrideIndicator)annotation).open();
+ ((OverrideIndicatorManager.OverrideIndicator) annotation).open();
+ return;
+ }
+
+ if (fHasCorrection.get(layer)) {
+ ITextOperationTarget operation = fTextEditor.getAdapter(ITextOperationTarget.class);
+ final int opCode = ISourceViewer.QUICK_ASSIST;
+ if (operation != null && operation.canDoOperation(opCode)) {
+ fTextEditor.selectAndReveal(fPosition.getOffset(), fPosition.getLength());
+ operation.doOperation(opCode);
+ }
return;
}
-
- if (fHasCorrection.get(layer)) {
- ITextOperationTarget operation= fTextEditor.getAdapter(ITextOperationTarget.class);
- final int opCode= ISourceViewer.QUICK_ASSIST;
- if (operation != null && operation.canDoOperation(opCode)) {
- fTextEditor.selectAndReveal(fPosition.getOffset(), fPosition.getLength());
- operation.doOperation(opCode);
- }
- return;
- }
- }
-
- super.run();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.texteditor.SelectMarkerRulerAction#update()
- */
- @Override
+ }
+
+ super.run();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.texteditor.SelectMarkerRulerAction#update()
+ */
+ @Override
public void update() {
- findCAnnotation();
- setEnabled(true);
+ findCAnnotation();
+ setEnabled(true);
- for (Integer layer : fAnnotations.keySet()) {
- Annotation annotation = fAnnotations.get(layer);
+ for (Integer layer : fAnnotations.keySet()) {
+ Annotation annotation = fAnnotations.get(layer);
if (annotation instanceof OverrideIndicatorManager.OverrideIndicator) {
initialize(fBundle, "CSelectAnnotationRulerAction.OpenSuperImplementation."); //$NON-NLS-1$
return;
}
- if (fHasCorrection.get(layer)) {
- initialize(fBundle, "CSelectAnnotationRulerAction.QuickFix."); //$NON-NLS-1$
- return;
- }
- }
-
- initialize(fBundle, "CSelectAnnotationRulerAction.GotoAnnotation."); //$NON-NLS-1$;
- super.update();
- }
-
- private void findCAnnotation() {
- fPosition= null;
- fAnnotations.clear();
- fHasCorrection.clear();
-
- AbstractMarkerAnnotationModel model= getAnnotationModel();
- IAnnotationAccessExtension annotationAccess= getAnnotationAccessExtension();
-
- IDocument document= getDocument();
- if (model == null)
- return ;
-
- Iterator<?> iter= model.getAnnotationIterator();
-
- while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
- if (annotation.isMarkedDeleted())
- continue;
-
- int layer = IAnnotationAccessExtension.DEFAULT_LAYER;
- if (annotationAccess != null) {
- layer= annotationAccess.getLayer(annotation);
- }
-
- Position position= model.getPosition(annotation);
- if (!includesRulerLine(position, document))
- continue;
-
- boolean isReadOnly = fTextEditor instanceof ITextEditorExtension && ((ITextEditorExtension)fTextEditor).isEditorInputReadOnly();
-
- if (!isReadOnly && CCorrectionProcessor.hasCorrections(annotation)) {
-
- fPosition= position;
- fAnnotations.put(layer, annotation);
- fHasCorrection.put(layer, true);
- continue;
- }
- AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
+ if (fHasCorrection.get(layer)) {
+ initialize(fBundle, "CSelectAnnotationRulerAction.QuickFix."); //$NON-NLS-1$
+ return;
+ }
+ }
+
+ initialize(fBundle, "CSelectAnnotationRulerAction.GotoAnnotation."); //$NON-NLS-1$;
+ super.update();
+ }
+
+ private void findCAnnotation() {
+ fPosition = null;
+ fAnnotations.clear();
+ fHasCorrection.clear();
+
+ AbstractMarkerAnnotationModel model = getAnnotationModel();
+ IAnnotationAccessExtension annotationAccess = getAnnotationAccessExtension();
+
+ IDocument document = getDocument();
+ if (model == null)
+ return;
+
+ Iterator<?> iter = model.getAnnotationIterator();
+
+ while (iter.hasNext()) {
+ Annotation annotation = (Annotation) iter.next();
+ if (annotation.isMarkedDeleted())
+ continue;
+
+ int layer = IAnnotationAccessExtension.DEFAULT_LAYER;
+ if (annotationAccess != null) {
+ layer = annotationAccess.getLayer(annotation);
+ }
+
+ Position position = model.getPosition(annotation);
+ if (!includesRulerLine(position, document))
+ continue;
+
+ boolean isReadOnly = fTextEditor instanceof ITextEditorExtension
+ && ((ITextEditorExtension) fTextEditor).isEditorInputReadOnly();
+
+ if (!isReadOnly && CCorrectionProcessor.hasCorrections(annotation)) {
+
+ fPosition = position;
+ fAnnotations.put(layer, annotation);
+ fHasCorrection.put(layer, true);
+ continue;
+ }
+ AnnotationPreference preference = fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
if (preference == null)
- continue;
+ continue;
- String key= preference.getVerticalRulerPreferenceKey();
+ String key = preference.getVerticalRulerPreferenceKey();
if (key == null)
- continue;
+ continue;
if (fStore.getBoolean(key)) {
- fPosition= position;
- fAnnotations.put(layer, annotation);
- fHasCorrection.put(layer, false);
+ fPosition = position;
+ fAnnotations.put(layer, annotation);
+ fHasCorrection.put(layer, false);
}
- }
- }
+ }
+ }
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.java
index 1b46359fc57..2b11b9a083a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.java
@@ -23,11 +23,12 @@ import org.eclipse.cdt.internal.ui.editor.ConstructedCEditorMessages;
public class CSelectRulerAction extends AbstractRulerActionDelegate {
- /*
- * @see AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
- */
- @Override
+ /*
+ * @see AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
+ */
+ @Override
protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
- return new CSelectAnnotationRulerAction(ConstructedCEditorMessages.getResourceBundle(), "CSelectAnnotationRulerAction.", editor, rulerInfo); //$NON-NLS-1$
- }
+ return new CSelectAnnotationRulerAction(ConstructedCEditorMessages.getResourceBundle(),
+ "CSelectAnnotationRulerAction.", editor, rulerInfo); //$NON-NLS-1$
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
index 788a30081bc..a8d65fb53d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
@@ -41,29 +41,29 @@ public final class ContributedProcessorDescriptor {
private boolean fLastResult;
private final Set<String> fHandledMarkerTypes;
- private static final String ID= "id"; //$NON-NLS-1$
- private static final String CLASS= "class"; //$NON-NLS-1$
-
- private static final String HANDLED_MARKER_TYPES= "handledMarkerTypes"; //$NON-NLS-1$
- private static final String MARKER_TYPE= "markerType"; //$NON-NLS-1$
-
+ private static final String ID = "id"; //$NON-NLS-1$
+ private static final String CLASS = "class"; //$NON-NLS-1$
+
+ private static final String HANDLED_MARKER_TYPES = "handledMarkerTypes"; //$NON-NLS-1$
+ private static final String MARKER_TYPE = "markerType"; //$NON-NLS-1$
+
public ContributedProcessorDescriptor(IConfigurationElement element, boolean testMarkerTypes) {
- fConfigurationElement= element;
- fProcessorInstance= null;
- fStatus= null; // undefined
+ fConfigurationElement = element;
+ fProcessorInstance = null;
+ fStatus = null; // undefined
if (fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT).length == 0) {
- fStatus= Boolean.TRUE;
+ fStatus = Boolean.TRUE;
}
- fHandledMarkerTypes= testMarkerTypes ? getHandledMarkerTypes(element) : null;
+ fHandledMarkerTypes = testMarkerTypes ? getHandledMarkerTypes(element) : null;
}
private Set<String> getHandledMarkerTypes(IConfigurationElement element) {
- HashSet<String> map= new HashSet<String>(7);
- IConfigurationElement[] children= element.getChildren(HANDLED_MARKER_TYPES);
+ HashSet<String> map = new HashSet<String>(7);
+ IConfigurationElement[] children = element.getChildren(HANDLED_MARKER_TYPES);
for (IConfigurationElement element2 : children) {
- IConfigurationElement[] types= element2.getChildren(MARKER_TYPE);
+ IConfigurationElement[] types = element2.getChildren(MARKER_TYPE);
for (IConfigurationElement type : types) {
- String attribute= type.getAttribute(ID);
+ String attribute = type.getAttribute(ID);
if (attribute != null) {
map.add(attribute);
}
@@ -76,9 +76,9 @@ public final class ContributedProcessorDescriptor {
}
public IStatus checkSyntax() {
- IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
+ IConfigurationElement[] children = fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
if (children.length > 1) {
- String id= fConfigurationElement.getAttribute(ID);
+ String id = fConfigurationElement.getAttribute(ID);
return new StatusInfo(IStatus.ERROR, "Only one < enablement > element allowed. Disabling " + id); //$NON-NLS-1$
}
return new StatusInfo(IStatus.OK, "Syntactically correct quick assist/fix processor"); //$NON-NLS-1$
@@ -89,36 +89,36 @@ public final class ContributedProcessorDescriptor {
return fStatus.booleanValue();
}
- IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
+ IConfigurationElement[] children = fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
if (children.length == 1) {
try {
- ExpressionConverter parser= ExpressionConverter.getDefault();
- Expression expression= parser.perform(children[0]);
- EvaluationContext evalContext= new EvaluationContext(null, cunit);
+ ExpressionConverter parser = ExpressionConverter.getDefault();
+ Expression expression = parser.perform(children[0]);
+ EvaluationContext evalContext = new EvaluationContext(null, cunit);
evalContext.addVariable("compilationUnit", cunit); //$NON-NLS-1$
- ICProject cProject= cunit.getCProject();
- String[] natures= cProject.getProject().getDescription().getNatureIds();
+ ICProject cProject = cunit.getCProject();
+ String[] natures = cProject.getProject().getDescription().getNatureIds();
evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$
- fLastResult= !(expression.evaluate(evalContext) != EvaluationResult.TRUE);
+ fLastResult = !(expression.evaluate(evalContext) != EvaluationResult.TRUE);
return fLastResult;
} catch (CoreException e) {
CUIPlugin.log(e);
}
}
- fStatus= Boolean.FALSE;
+ fStatus = Boolean.FALSE;
return false;
}
-
+
public Object getProcessor(ITranslationUnit cunit) throws CoreException {
if (matches(cunit)) {
if (fProcessorInstance == null) {
- fProcessorInstance= fConfigurationElement.createExecutableExtension(CLASS);
+ fProcessorInstance = fConfigurationElement.createExecutableExtension(CLASS);
}
return fProcessorInstance;
}
return null;
}
-
+
public boolean canHandleMarkerType(String markerType) {
return fHandledMarkerTypes == null || fHandledMarkerTypes.contains(markerType);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
index 6c79149d3b5..ffb512ae4e0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
@@ -65,9 +65,9 @@ public class CorrectionCommandHandler extends AbstractHandler {
private final boolean fIsAssist;
public CorrectionCommandHandler(CEditor editor, String id, boolean isAssist) {
- fEditor= editor;
- fId= id;
- fIsAssist= isAssist;
+ fEditor = editor;
+ fId = id;
+ fIsAssist = isAssist;
}
/* (non-Javadoc)
@@ -81,29 +81,31 @@ public class CorrectionCommandHandler extends AbstractHandler {
/**
* Try to execute the correction command.
- *
+ *
* @return <code>true</code> iff the correction could be started
* @since 5.3
*/
public boolean doExecute() {
- ISelection selection= fEditor.getSelectionProvider().getSelection();
- ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
- IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
+ ISelection selection = fEditor.getSelectionProvider().getSelection();
+ ITranslationUnit tu = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
+ IAnnotationModel model = CUIPlugin.getDefault().getDocumentProvider()
+ .getAnnotationModel(fEditor.getEditorInput());
if (selection instanceof ITextSelection && tu != null && model != null) {
if (!ActionUtil.isEditable(fEditor)) {
return false;
}
- ICompletionProposal proposal= findCorrection(fId, fIsAssist, (ITextSelection) selection, tu, model);
+ ICompletionProposal proposal = findCorrection(fId, fIsAssist, (ITextSelection) selection, tu, model);
if (proposal != null) {
invokeProposal(proposal, ((ITextSelection) selection).getOffset());
}
}
return false;
}
-
- private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, ITranslationUnit tu, IAnnotationModel model) {
- CorrectionContext context= new CorrectionContext(tu, selection.getOffset(), selection.getLength());
- Collection<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>(10);
+
+ private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection,
+ ITranslationUnit tu, IAnnotationModel model) {
+ CorrectionContext context = new CorrectionContext(tu, selection.getOffset(), selection.getLength());
+ Collection<ICCompletionProposal> proposals = new ArrayList<ICCompletionProposal>(10);
if (isAssist) {
if (id.equals(LinkedNamesAssistProposal.ASSIST_ID)) {
return getLocalRenameProposal(context); // shortcut for local rename
@@ -111,15 +113,15 @@ public class CorrectionCommandHandler extends AbstractHandler {
CCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals);
} else {
try {
- boolean goToClosest= selection.getLength() == 0;
- Annotation[] annotations= getAnnotations(selection.getOffset(), goToClosest);
+ boolean goToClosest = selection.getLength() == 0;
+ Annotation[] annotations = getAnnotations(selection.getOffset(), goToClosest);
CCorrectionProcessor.collectProposals(context, model, annotations, true, false, proposals);
} catch (BadLocationException e) {
return null;
}
}
- for (Iterator<ICCompletionProposal> iter= proposals.iterator(); iter.hasNext();) {
- Object curr= iter.next();
+ for (Iterator<ICCompletionProposal> iter = proposals.iterator(); iter.hasNext();) {
+ Object curr = iter.next();
if (curr instanceof ICommandAccess) {
if (id.equals(((ICommandAccess) curr).getCommandId())) {
return (ICompletionProposal) curr;
@@ -130,64 +132,65 @@ public class CorrectionCommandHandler extends AbstractHandler {
}
private Annotation[] getAnnotations(int offset, boolean goToClosest) throws BadLocationException {
- ArrayList<Annotation> resultingAnnotations= new ArrayList<Annotation>();
+ ArrayList<Annotation> resultingAnnotations = new ArrayList<Annotation>();
CCorrectionAssistant.collectQuickFixableAnnotations(fEditor, offset, goToClosest, resultingAnnotations);
return resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
}
-
+
private ICompletionProposal getLocalRenameProposal(final IInvocationContext context) {
- final ICCompletionProposal[] proposals= new ICCompletionProposal[1];
+ final ICCompletionProposal[] proposals = new ICCompletionProposal[1];
ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(), ASTProvider.WAIT_ACTIVE_ONLY,
new NullProgressMonitor(), new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
- IASTNodeSelector selector= astRoot.getNodeSelector(null);
- IASTName name= selector.findEnclosingName(context.getSelectionOffset(), context.getSelectionLength());
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+ IASTNodeSelector selector = astRoot.getNodeSelector(null);
+ IASTName name = selector.findEnclosingName(context.getSelectionOffset(),
+ context.getSelectionLength());
- // Activate the proposal only if a simple name is selected.
- if (name != null && name == name.getLastName()) {
- IBinding binding= name.resolveBinding();
- if (binding != null) {
- proposals[0]= new LinkedNamesAssistProposal(context.getTranslationUnit());
+ // Activate the proposal only if a simple name is selected.
+ if (name != null && name == name.getLastName()) {
+ IBinding binding = name.resolveBinding();
+ if (binding != null) {
+ proposals[0] = new LinkedNamesAssistProposal(context.getTranslationUnit());
+ }
+ }
+ return Status.OK_STATUS;
}
- }
- return Status.OK_STATUS;
- }
- });
+ });
return proposals[0];
}
private IDocument getDocument() {
return CUIPlugin.getDefault().getDocumentProvider().getDocument(fEditor.getEditorInput());
}
-
+
private void invokeProposal(ICompletionProposal proposal, int offset) {
if (proposal instanceof ICompletionProposalExtension2) {
- ITextViewer viewer= fEditor.getViewer();
+ ITextViewer viewer = fEditor.getViewer();
if (viewer != null) {
((ICompletionProposalExtension2) proposal).apply(viewer, (char) 0, 0, offset);
return;
}
} else if (proposal instanceof ICompletionProposalExtension) {
- IDocument document= getDocument();
+ IDocument document = getDocument();
if (document != null) {
((ICompletionProposalExtension) proposal).apply(document, (char) 0, offset);
return;
}
}
- IDocument document= getDocument();
+ IDocument document = getDocument();
if (document != null) {
proposal.apply(document);
}
}
-
+
public static String getShortCutString(String proposalId) {
if (proposalId != null) {
- IBindingService bindingService= PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
if (bindingService != null) {
- TriggerSequence[] activeBindingsFor= bindingService.getActiveBindingsFor(proposalId);
+ TriggerSequence[] activeBindingsFor = bindingService.getActiveBindingsFor(proposalId);
if (activeBindingsFor.length > 0) {
return activeBindingsFor[0].format();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java
index 13ef3973086..22f6cff1c68 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java
@@ -34,50 +34,51 @@ public class CorrectionCommandInstaller {
/**
* All correction commands must start with the following prefix.
*/
- public static final String COMMAND_PREFIX= "org.eclipse.jdt.ui.correction."; //$NON-NLS-1$
-
+ public static final String COMMAND_PREFIX = "org.eclipse.jdt.ui.correction."; //$NON-NLS-1$
+
/**
* Commands for quick assist must have the following suffix.
*/
- public static final String ASSIST_SUFFIX= ".assist"; //$NON-NLS-1$
-
+ public static final String ASSIST_SUFFIX = ".assist"; //$NON-NLS-1$
+
private List<IHandlerActivation> fCorrectionHandlerActivations;
-
+
public CorrectionCommandInstaller() {
- fCorrectionHandlerActivations= null;
+ fCorrectionHandlerActivations = null;
}
-
+
public void registerCommands(CEditor editor) {
- IWorkbench workbench= PlatformUI.getWorkbench();
- ICommandService commandService= workbench.getAdapter(ICommandService.class);
- IHandlerService handlerService= workbench.getAdapter(IHandlerService.class);
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ ICommandService commandService = workbench.getAdapter(ICommandService.class);
+ IHandlerService handlerService = workbench.getAdapter(IHandlerService.class);
if (commandService == null || handlerService == null) {
return;
}
-
+
if (fCorrectionHandlerActivations != null) {
CUIPlugin.logError("Correction handler activations not released"); //$NON-NLS-1$
}
- fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();
-
+ fCorrectionHandlerActivations = new ArrayList<IHandlerActivation>();
+
@SuppressWarnings("unchecked")
- Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
+ Collection<String> definedCommandIds = commandService.getDefinedCommandIds();
for (Object element : definedCommandIds) {
- String id= (String) element;
+ String id = (String) element;
if (id.startsWith(COMMAND_PREFIX)) {
- boolean isAssist= id.endsWith(ASSIST_SUFFIX);
- CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
- IHandlerActivation activation= handlerService.activateHandler(id, handler, new LegacyHandlerSubmissionExpression(null, null, editor.getSite()));
+ boolean isAssist = id.endsWith(ASSIST_SUFFIX);
+ CorrectionCommandHandler handler = new CorrectionCommandHandler(editor, id, isAssist);
+ IHandlerActivation activation = handlerService.activateHandler(id, handler,
+ new LegacyHandlerSubmissionExpression(null, null, editor.getSite()));
fCorrectionHandlerActivations.add(activation);
}
}
}
-
+
public void deregisterCommands() {
- IHandlerService handlerService= PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
if (handlerService != null && fCorrectionHandlerActivations != null) {
handlerService.deactivateHandlers(fCorrectionHandlerActivations);
- fCorrectionHandlerActivations= null;
+ fCorrectionHandlerActivations = null;
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.java
index 0b069d7e4cd..2b77a572068 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.java
@@ -28,9 +28,9 @@ public class CorrectionContext extends TextInvocationContext implements IInvocat
*/
public CorrectionContext(ITranslationUnit tu, ISourceViewer sourceViewer, int offset, int length) {
super(sourceViewer, offset, length);
- fTranslationUnit= tu;
+ fTranslationUnit = tu;
}
-
+
/*
* Constructor for CorrectionContext.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java
index 933af411e11..09c0cec1f66 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -33,7 +33,7 @@ public final class CorrectionMessages extends NLS {
public static String CCorrectionProcessor_error_status;
public static String MarkerResolutionProposal_additionaldesc;
public static String NoCorrectionProposal_description;
-
+
public static String ChangeCorrectionProposal_error_title;
public static String ChangeCorrectionProposal_error_message;
public static String ChangeCorrectionProposal_name_with_shortcut;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.java
index 38e8f957bfa..f9451193d15 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -15,8 +15,8 @@
package org.eclipse.cdt.internal.ui.text.correction;
/**
- * Correction proposals implement this interface to by invokable by a command.
- * (e.g. keyboard shortcut)
+ * Correction proposals implement this interface to by invokable by a command.
+ * (e.g. keyboard shortcut)
*/
public interface ICommandAccess {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.java
index 8be023ceaae..65d8763613b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.java
@@ -18,14 +18,14 @@ package org.eclipse.cdt.internal.ui.text.correction;
* A proposal which is able to show a message
* on the status line of the content assistant
* in which this proposal is shown.
- *
+ *
* @see org.eclipse.jface.text.contentassist.IContentAssistantExtension2
*/
public interface IStatusLineProposal {
/**
* The message to show when this proposal is
* selected by the user in the content assistant.
- *
+ *
* @return The message to show, or null for no message.
*/
public String getStatusMessage();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProposal.java
index f4d7bdd77e8..6710abb837c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProposal.java
@@ -36,8 +36,8 @@ public class MarkerResolutionProposal implements ICCompletionProposal {
* Constructor for MarkerResolutionProposal.
*/
public MarkerResolutionProposal(IMarkerResolution resolution, IMarker marker) {
- fResolution= resolution;
- fMarker= marker;
+ fResolution = resolution;
+ fMarker = marker;
}
/* (non-Javadoc)
@@ -60,9 +60,8 @@ public class MarkerResolutionProposal implements ICCompletionProposal {
return ((ICCompletionProposal) fResolution).getAdditionalProposalInfo();
}
try {
- String problemDesc= (String) fMarker.getAttribute(IMarker.MESSAGE);
- return NLS.bind(CorrectionMessages.MarkerResolutionProposal_additionaldesc,
- problemDesc);
+ String problemDesc = (String) fMarker.getAttribute(IMarker.MESSAGE);
+ return NLS.bind(CorrectionMessages.MarkerResolutionProposal_additionaldesc, problemDesc);
} catch (CoreException e) {
CUIPlugin.log(e);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.java
index 2a2e31a1e58..97b18ffd644 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.java
@@ -31,33 +31,33 @@ public class ProblemLocation implements IProblemLocation {
private final String fMarkerType;
public ProblemLocation(int offset, int length, ICAnnotation annotation) {
- fId= annotation.getId();
- fArguments= annotation.getArguments();
- fOffset= offset;
- fLength= length;
- fIsError= CMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType());
-
- String markerType= annotation.getMarkerType();
- fMarkerType= markerType != null ? markerType : ICModelMarker.C_MODEL_PROBLEM_MARKER;
+ fId = annotation.getId();
+ fArguments = annotation.getArguments();
+ fOffset = offset;
+ fLength = length;
+ fIsError = CMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType());
+
+ String markerType = annotation.getMarkerType();
+ fMarkerType = markerType != null ? markerType : ICModelMarker.C_MODEL_PROBLEM_MARKER;
}
public ProblemLocation(int offset, int length, int id, String[] arguments, boolean isError, String markerType) {
- fId= id;
- fArguments= arguments;
- fOffset= offset;
- fLength= length;
- fIsError= isError;
- fMarkerType= markerType;
+ fId = id;
+ fArguments = arguments;
+ fOffset = offset;
+ fLength = length;
+ fIsError = isError;
+ fMarkerType = markerType;
}
-
+
public ProblemLocation(IProblem problem) {
- fId= problem.getID();
- fArguments= problem.getArguments();
- fOffset= problem.getSourceStart();
- fLength= problem.getSourceEnd() - fOffset + 1;
- fIsError= problem.isError();
- fMarkerType= problem instanceof IPersistableProblem ?
- ((IPersistableProblem) problem).getMarkerType() : ICModelMarker.C_MODEL_PROBLEM_MARKER;
+ fId = problem.getID();
+ fArguments = problem.getArguments();
+ fOffset = problem.getSourceStart();
+ fLength = problem.getSourceEnd() - fOffset + 1;
+ fIsError = problem.isError();
+ fMarkerType = problem instanceof IPersistableProblem ? ((IPersistableProblem) problem).getMarkerType()
+ : ICModelMarker.C_MODEL_PROBLEM_MARKER;
}
@Override
@@ -89,24 +89,24 @@ public class ProblemLocation implements IProblemLocation {
public String getMarkerType() {
return fMarkerType;
}
-
+
@Override
public String toString() {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
buf.append("Id: ").append(getErrorCode(fId)).append('\n'); //$NON-NLS-1$
buf.append('[').append(fOffset).append(", ").append(fLength).append(']').append('\n'); //$NON-NLS-1$
- String[] arg= fArguments;
+ String[] arg = fArguments;
if (arg != null) {
- for (int i= 0; i < arg.length; i++) {
+ for (int i = 0; i < arg.length; i++) {
buf.append(arg[i]);
- buf.append('\n');
+ buf.append('\n');
}
}
return buf.toString();
}
private String getErrorCode(int code) {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
if ((code & IProblem.SCANNER_RELATED) != 0) {
buf.append("ScannerRelated + "); //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
index 118eb00b821..590d612cd58 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
@@ -68,12 +68,13 @@ public class QuickAssistLightBulbUpdater {
private static final int LAYER;
static {
- Annotation annotation= new Annotation("org.eclipse.jdt.ui.warning", false, null); //$NON-NLS-1$
- AnnotationPreference preference= EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
+ Annotation annotation = new Annotation("org.eclipse.jdt.ui.warning", false, null); //$NON-NLS-1$
+ AnnotationPreference preference = EditorsUI.getAnnotationPreferenceLookup()
+ .getAnnotationPreference(annotation);
if (preference != null)
- LAYER= preference.getPresentationLayer() - 1;
+ LAYER = preference.getPresentationLayer() - 1;
else
- LAYER= IAnnotationAccessExtension.DEFAULT_LAYER;
+ LAYER = IAnnotationAccessExtension.DEFAULT_LAYER;
}
private Image fImage;
@@ -91,7 +92,7 @@ public class QuickAssistLightBulbUpdater {
private Image getImage() {
if (fImage == null) {
- fImage= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_QUICK_ASSIST);
+ fImage = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_QUICK_ASSIST);
}
return fImage;
}
@@ -114,11 +115,11 @@ public class QuickAssistLightBulbUpdater {
private IPropertyChangeListener fPropertyChangeListener;
public QuickAssistLightBulbUpdater(ITextEditor part, ITextViewer viewer) {
- fEditor= part;
- fViewer= viewer;
- fAnnotation= new AssistAnnotation();
- fIsAnnotationShown= false;
- fPropertyChangeListener= null;
+ fEditor = part;
+ fViewer = viewer;
+ fAnnotation = new AssistAnnotation();
+ fIsAnnotationShown = false;
+ fPropertyChangeListener = null;
}
public boolean isSetInPreferences() {
@@ -126,10 +127,9 @@ public class QuickAssistLightBulbUpdater {
}
private void installSelectionListener() {
- fListener= new ISelectionListenerWithAST() {
+ fListener = new ISelectionListenerWithAST() {
@Override
- public void selectionChanged(IEditorPart part,
- ITextSelection selection, IASTTranslationUnit astRoot) {
+ public void selectionChanged(IEditorPart part, ITextSelection selection, IASTTranslationUnit astRoot) {
doSelectionChanged(selection.getOffset(), selection.getLength(), astRoot);
}
};
@@ -139,9 +139,9 @@ public class QuickAssistLightBulbUpdater {
private void uninstallSelectionListener() {
if (fListener != null) {
SelectionListenerWithASTManager.getDefault().removeListener(fEditor, fListener);
- fListener= null;
+ fListener = null;
}
- IAnnotationModel model= getAnnotationModel();
+ IAnnotationModel model = getAnnotationModel();
if (model != null) {
removeLightBulb(model);
}
@@ -152,7 +152,7 @@ public class QuickAssistLightBulbUpdater {
installSelectionListener();
}
if (fPropertyChangeListener == null) {
- fPropertyChangeListener= new IPropertyChangeListener() {
+ fPropertyChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
doPropertyChanged(event.getProperty());
@@ -166,26 +166,28 @@ public class QuickAssistLightBulbUpdater {
uninstallSelectionListener();
if (fPropertyChangeListener != null) {
PreferenceConstants.getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
- fPropertyChangeListener= null;
+ fPropertyChangeListener = null;
}
}
protected void doPropertyChanged(String property) {
if (property.equals(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB)) {
if (isSetInPreferences()) {
- IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
+ IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager()
+ .getWorkingCopy(fEditor.getEditorInput());
if (workingCopy != null) {
installSelectionListener();
- final Point point= fViewer.getSelectedRange();
- ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_IF_OPEN, null, new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
- if (astRoot != null) {
- doSelectionChanged(point.x, point.y, astRoot);
- }
- return Status.OK_STATUS;
- }
- });
+ final Point point = fViewer.getSelectedRange();
+ ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_IF_OPEN, null,
+ new ASTRunnable() {
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
+ if (astRoot != null) {
+ doSelectionChanged(point.x, point.y, astRoot);
+ }
+ return Status.OK_STATUS;
+ }
+ });
}
} else {
uninstallSelectionListener();
@@ -194,7 +196,7 @@ public class QuickAssistLightBulbUpdater {
}
private ITranslationUnit getTranslationUnit() {
- ICElement elem= EditorUtility.getEditorInputCElement(fEditor);
+ ICElement elem = EditorUtility.getEditorInputCElement(fEditor);
if (elem instanceof ITranslationUnit) {
return (ITranslationUnit) elem;
}
@@ -210,15 +212,15 @@ public class QuickAssistLightBulbUpdater {
}
private void doSelectionChanged(int offset, int length, IASTTranslationUnit astRoot) {
- final IAnnotationModel model= getAnnotationModel();
- final ITranslationUnit tu= getTranslationUnit();
+ final IAnnotationModel model = getAnnotationModel();
+ final ITranslationUnit tu = getTranslationUnit();
if (model == null || tu == null) {
return;
}
- final CorrectionContext context= new CorrectionContext(tu, offset, length);
+ final CorrectionContext context = new CorrectionContext(tu, offset, length);
- boolean hasQuickFix= hasQuickFixLightBulb(model, context.getSelectionOffset());
+ boolean hasQuickFix = hasQuickFixLightBulb(model, context.getSelectionOffset());
if (hasQuickFix) {
removeLightBulb(model);
return; // there is already a quick fix light bulb at the new location
@@ -231,21 +233,21 @@ public class QuickAssistLightBulbUpdater {
* Needs to be called synchronized
*/
private void calculateLightBulb(IAnnotationModel model, CorrectionContext context) {
- boolean needsAnnotation= CCorrectionProcessor.hasAssists(context);
+ boolean needsAnnotation = CCorrectionProcessor.hasAssists(context);
if (fIsAnnotationShown) {
model.removeAnnotation(fAnnotation);
}
if (needsAnnotation) {
model.addAnnotation(fAnnotation, new Position(context.getSelectionOffset(), context.getSelectionLength()));
}
- fIsAnnotationShown= needsAnnotation;
+ fIsAnnotationShown = needsAnnotation;
}
private void removeLightBulb(IAnnotationModel model) {
synchronized (this) {
if (fIsAnnotationShown) {
model.removeAnnotation(fAnnotation);
- fIsAnnotationShown= false;
+ fIsAnnotationShown = false;
}
}
}
@@ -255,7 +257,7 @@ public class QuickAssistLightBulbUpdater {
*/
private boolean hasQuickFixLightBulb(IAnnotationModel model, int offset) {
try {
- IDocument document= getDocument();
+ IDocument document = getDocument();
if (document == null) {
return false;
}
@@ -265,18 +267,18 @@ public class QuickAssistLightBulbUpdater {
// this goes boink
// may throw an IndexOutOfBoundsException upon concurrent document modification
- int currLine= document.getLineOfOffset(offset);
+ int currLine = document.getLineOfOffset(offset);
// this iterator is not protected, it may throw ConcurrentModificationExceptions
- Iterator<?> iter= model.getAnnotationIterator();
+ Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annot= (Annotation) iter.next();
+ Annotation annot = (Annotation) iter.next();
if (CCorrectionProcessor.isQuickFixableType(annot)) {
// may throw an IndexOutOfBoundsException upon concurrent annotation model changes
- Position pos= model.getPosition(annot);
+ Position pos = model.getPosition(annot);
if (pos != null) {
// may throw an IndexOutOfBoundsException upon concurrent document modification
- int startLine= document.getLineOfOffset(pos.getOffset());
+ int startLine = document.getLineOfOffset(pos.getOffset());
if (startLine == currLine && CCorrectionProcessor.hasCorrections(annot)) {
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor.java
index 5f6414c32f5..3222f765c82 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor.java
@@ -57,63 +57,64 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
IStatus status = ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(),
ASTProvider.WAIT_ACTIVE_ONLY, new NullProgressMonitor(), new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
- IASTNodeSelector selector= astRoot.getNodeSelector(null);
- IASTName name= selector.findEnclosingName(context.getSelectionOffset(), context.getSelectionLength());
-
- // Activate the proposal only if a simple name is selected.
- if (name != null && name == name.getLastName()) {
- IBinding binding= name.resolveBinding();
- if (binding != null) {
- return Status.OK_STATUS;
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+ IASTNodeSelector selector = astRoot.getNodeSelector(null);
+ IASTName name = selector.findEnclosingName(context.getSelectionOffset(),
+ context.getSelectionLength());
+
+ // Activate the proposal only if a simple name is selected.
+ if (name != null && name == name.getLastName()) {
+ IBinding binding = name.resolveBinding();
+ if (binding != null) {
+ return Status.OK_STATUS;
+ }
+ }
+ return Status.CANCEL_STATUS;
}
- }
- return Status.CANCEL_STATUS;
- }
- });
+ });
return status.isOK();
}
@Override
public ICCompletionProposal[] getAssists(final IInvocationContext context,
final IProblemLocation[] problemLocations) throws CoreException {
- final ArrayList<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>();
+ final ArrayList<ICCompletionProposal> proposals = new ArrayList<ICCompletionProposal>();
ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(), ASTProvider.WAIT_ACTIVE_ONLY,
- new NullProgressMonitor(),
- new ASTRunnable() {
-
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
- if (astRoot == null) {
- return Status.CANCEL_STATUS;
- }
-
- IASTNodeSelector selector= astRoot.getNodeSelector(null);
- IASTName name= selector.findEnclosingName(context.getSelectionOffset(), context.getSelectionLength());
-
- // Activate the proposal only if a simple name is selected.
- if (name != null && name == name.getLastName()) {
- IBinding binding= name.resolveBinding();
- if (binding != null) {
- boolean noErrorsAtLocation= noErrorsAtLocation(problemLocations);
-
- // Quick assists that show up also if there is an error/warning
- getRenameLocalProposals(context, problemLocations, noErrorsAtLocation, proposals);
- getRenameRefactoringProposal(context, problemLocations, noErrorsAtLocation, proposals);
+ new NullProgressMonitor(), new ASTRunnable() {
+
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+ if (astRoot == null) {
+ return Status.CANCEL_STATUS;
+ }
+
+ IASTNodeSelector selector = astRoot.getNodeSelector(null);
+ IASTName name = selector.findEnclosingName(context.getSelectionOffset(),
+ context.getSelectionLength());
+
+ // Activate the proposal only if a simple name is selected.
+ if (name != null && name == name.getLastName()) {
+ IBinding binding = name.resolveBinding();
+ if (binding != null) {
+ boolean noErrorsAtLocation = noErrorsAtLocation(problemLocations);
+
+ // Quick assists that show up also if there is an error/warning
+ getRenameLocalProposals(context, problemLocations, noErrorsAtLocation, proposals);
+ getRenameRefactoringProposal(context, problemLocations, noErrorsAtLocation, proposals);
+ }
+ }
+ return Status.OK_STATUS;
}
- }
- return Status.OK_STATUS;
- }
- });
-
+ });
+
return proposals.isEmpty() ? null : proposals.toArray(new ICCompletionProposal[proposals.size()]);
}
private boolean noErrorsAtLocation(IProblemLocation[] locations) {
if (locations != null) {
- for (int i= 0; i < locations.length; i++) {
+ for (int i = 0; i < locations.length; i++) {
if (locations[i].isError()) {
return false;
}
@@ -121,28 +122,27 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
}
return true;
}
-
+
private static void getRenameLocalProposals(IInvocationContext context, IProblemLocation[] locations,
boolean noErrorsAtLocation, Collection<ICCompletionProposal> proposals) {
- LinkedNamesAssistProposal proposal= new LinkedNamesAssistProposal(context.getTranslationUnit());
+ LinkedNamesAssistProposal proposal = new LinkedNamesAssistProposal(context.getTranslationUnit());
if (!noErrorsAtLocation) {
proposal.setRelevance(1);
}
-
+
proposals.add(proposal);
}
private static boolean getRenameRefactoringProposal(IInvocationContext context, IProblemLocation[] locations,
- boolean noErrorsAtLocation, Collection<ICCompletionProposal> proposals)
- throws CoreException {
- IEditorPart editor= CUIPlugin.getActivePage().getActiveEditor();
+ boolean noErrorsAtLocation, Collection<ICCompletionProposal> proposals) throws CoreException {
+ IEditorPart editor = CUIPlugin.getActivePage().getActiveEditor();
if (!(editor instanceof CEditor))
return false;
if (proposals == null) {
return true;
}
- RenameRefactoringProposal proposal= new RenameRefactoringProposal((CEditor) editor);
+ RenameRefactoringProposal proposal = new RenameRefactoringProposal((CEditor) editor);
if (!noErrorsAtLocation) {
proposal.setRelevance(1);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java
index c25c788d019..816717612c3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.ui.CUIStatus;
* Either a rewriter is directly passed in the constructor or method {@link #getRewrite()}
* is overridden to provide the AST rewriter that is evaluated to the document when the
* proposal is applied.
- *
+ *
* @since 5.1
*/
public class ASTRewriteCorrectionProposal extends TUCorrectionProposal {
@@ -41,7 +41,7 @@ public class ASTRewriteCorrectionProposal extends TUCorrectionProposal {
/**
* Constructs a AST rewrite correction proposal.
- *
+ *
* @param name the display name of the proposal.
* @param tu the translation unit that is modified.
* @param rewrite the AST rewrite that is invoked when the proposal is applied or
@@ -50,15 +50,16 @@ public class ASTRewriteCorrectionProposal extends TUCorrectionProposal {
* @param image The image that is displayed for this proposal or {@code null} if no
* image is desired.
*/
- public ASTRewriteCorrectionProposal(String name, ITranslationUnit tu, ASTRewrite rewrite, int relevance, Image image) {
+ public ASTRewriteCorrectionProposal(String name, ITranslationUnit tu, ASTRewrite rewrite, int relevance,
+ Image image) {
super(name, tu, relevance, image);
- fRewrite= rewrite;
+ fRewrite = rewrite;
}
@Override
protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
super.addEdits(document, editRoot);
- ASTRewrite rewrite= getRewrite();
+ ASTRewrite rewrite = getRewrite();
if (rewrite != null) {
try {
Change change = rewrite.rewriteAST();
@@ -87,13 +88,13 @@ public class ASTRewriteCorrectionProposal extends TUCorrectionProposal {
/**
* Returns the rewriter that has been passed in the constructor. Implementors can override this
* method to create the rewriter lazy. This method will only be called once.
- *
+ *
* @return returns the rewriter to be used.
* @throws CoreException an exception is thrown when the rewriter could not be created.
*/
protected ASTRewrite getRewrite() throws CoreException {
if (fRewrite == null) {
- IStatus status= CUIStatus.createError(IStatus.ERROR, "Rewriter not initialized", null); //$NON-NLS-1$
+ IStatus status = CUIStatus.createError(IStatus.ERROR, "Rewriter not initialized", null); //$NON-NLS-1$
throw new CoreException(status);
}
return fRewrite;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorrectionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorrectionProposal.java
index a7f47560ca8..15b4599a55b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorrectionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorrectionProposal.java
@@ -49,7 +49,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
* Implementation of a C completion proposal to be used for quick fix and quick assist
* proposals that invoke a {@link Change}. The proposal offers a proposal information but no context
* information.
- *
+ *
* @since 5.1
*/
public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandAccess, ICompletionProposalExtension6 {
@@ -61,7 +61,7 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
/**
* Constructs a change correction proposal.
- *
+ *
* @param name The name that is displayed in the proposal selection dialog.
* @param change The change that is executed when the proposal is applied or {@code null}
* if the change will be created by implementors of {@link #createChange()}.
@@ -73,11 +73,11 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
if (name == null) {
throw new IllegalArgumentException("Name must not be null"); //$NON-NLS-1$
}
- fName= name;
- fChange= change;
- fRelevance= relevance;
- fImage= image;
- fCommandId= null;
+ fName = name;
+ fChange = change;
+ fRelevance = relevance;
+ fImage = image;
+ fCommandId = null;
}
/*
@@ -88,13 +88,14 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
try {
performChange(CUIPlugin.getActivePage().getActiveEditor(), document);
} catch (CoreException e) {
- ExceptionHandler.handle(e, CorrectionMessages.ChangeCorrectionProposal_error_title, CorrectionMessages.ChangeCorrectionProposal_error_message);
+ ExceptionHandler.handle(e, CorrectionMessages.ChangeCorrectionProposal_error_title,
+ CorrectionMessages.ChangeCorrectionProposal_error_message);
}
}
/**
* Performs the change associated with this proposal.
- *
+ *
* @param activeEditor The editor currently active or {@code null} if no
* editor is active.
* @param document The document of the editor currently active or {@code null} if
@@ -102,31 +103,31 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
* @throws CoreException Thrown when the invocation of the change failed.
*/
protected void performChange(IEditorPart activeEditor, IDocument document) throws CoreException {
- Change change= null;
- IRewriteTarget rewriteTarget= null;
+ Change change = null;
+ IRewriteTarget rewriteTarget = null;
try {
- change= getChange();
+ change = getChange();
if (change != null) {
if (document != null) {
LinkedModeModel.closeAllModels(document);
}
if (activeEditor != null) {
- rewriteTarget= activeEditor.getAdapter(IRewriteTarget.class);
+ rewriteTarget = activeEditor.getAdapter(IRewriteTarget.class);
if (rewriteTarget != null) {
rewriteTarget.beginCompoundChange();
}
}
change.initializeValidationData(new NullProgressMonitor());
- RefactoringStatus valid= change.isValid(new NullProgressMonitor());
+ RefactoringStatus valid = change.isValid(new NullProgressMonitor());
if (valid.hasFatalError()) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
- valid.getMessageMatchingSeverity(RefactoringStatus.FATAL), null);
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
+ valid.getMessageMatchingSeverity(RefactoringStatus.FATAL), null);
throw new CoreException(status);
} else {
- IUndoManager manager= RefactoringCore.getUndoManager();
+ IUndoManager manager = RefactoringCore.getUndoManager();
manager.aboutToPerformChange(change);
- Change undoChange= change.perform(new NullProgressMonitor());
+ Change undoChange = change.perform(new NullProgressMonitor());
manager.changePerformed(change, true);
if (undoChange != null) {
undoChange.initializeValidationData(new NullProgressMonitor());
@@ -147,12 +148,12 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
@Override
public String getAdditionalProposalInfo() {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
buf.append("<p>"); //$NON-NLS-1$
try {
- Change change= getChange();
+ Change change = getChange();
if (change != null) {
- String name= change.getName();
+ String name = change.getName();
if (name.length() == 0) {
return null;
}
@@ -176,34 +177,36 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
@Override
public String getDisplayString() {
- String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+ String shortCutString = CorrectionCommandHandler.getShortCutString(getCommandId());
if (shortCutString != null) {
- return MessageFormat.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, new Object[] {getName(), shortCutString});
+ return MessageFormat.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+ new Object[] { getName(), shortCutString });
}
return getName();
}
-
+
@Override
public StyledString getStyledDisplayString() {
- StyledString str= new StyledString(getName());
-
- String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+ StyledString str = new StyledString(getName());
+
+ String shortCutString = CorrectionCommandHandler.getShortCutString(getCommandId());
if (shortCutString != null) {
- String decorated= MessageFormat.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, new Object[] {getName(), shortCutString});
- return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER);
+ String decorated = MessageFormat.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+ new Object[] { getName(), shortCutString });
+ return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER);
}
return str;
}
-
- /**
+
+ /**
* Returns the name of the proposal.
- *
+ *
* @return return the name of the proposal
*/
public String getName() {
return fName;
}
-
+
@Override
public Image getImage() {
return fImage;
@@ -216,22 +219,22 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
/**
* Sets the proposal's image or {@code null} if no image is desired.
- *
+ *
* @param image the desired image.
*/
public void setImage(Image image) {
- fImage= image;
+ fImage = image;
}
/**
* Returns the change that will be executed when the proposal is applied.
- *
+ *
* @return returns the change for this proposal.
* @throws CoreException thrown when the change could not be created
*/
public final Change getChange() throws CoreException {
if (fChange == null) {
- fChange= createChange();
+ fChange = createChange();
}
return fChange;
}
@@ -239,25 +242,25 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
/**
* Creates the text change for this proposal.
* This method is only called once and only when no text change has been passed in
- * {@link #ChangeCorrectionProposal(String, Change, int, Image)}.
- *
+ * {@link #ChangeCorrectionProposal(String, Change, int, Image)}.
+ *
* @return returns the created change.
* @throws CoreException thrown if the creation of the change failed.
*/
protected Change createChange() throws CoreException {
return new NullChange();
}
-
+
/**
* Sets the display name.
- *
+ *
* @param name the name to set
*/
public void setDisplayName(String name) {
if (name == null) {
throw new IllegalArgumentException("Name must not be null"); //$NON-NLS-1$
}
- fName= name;
+ fName = name;
}
@Override
@@ -271,22 +274,22 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
* @param relevance the relevance to set
*/
public void setRelevance(int relevance) {
- fRelevance= relevance;
+ fRelevance = relevance;
}
@Override
public String getCommandId() {
return fCommandId;
}
-
+
/**
* Sets the proposal id to allow assigning a shortcut to the correction proposal.
- *
+ *
* @param commandId The proposal id for this proposal or {@code null} if no command
* should be assigned to this proposal.
*/
public void setCommandId(String commandId) {
- fCommandId= commandId;
+ fCommandId = commandId;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java
index d01cb86c603..a30eed5d53f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.cdt.core.dom.rewrite.ITrackedNodePosition;
import org.eclipse.cdt.core.model.ITranslationUnit;
-
/**
* A proposal for quick fixes and quick assists that works on a AST rewriter and enters the
* linked mode when the proposal is set up.
@@ -39,8 +38,7 @@ public class LinkedCorrectionProposal extends ASTRewriteCorrectionProposal {
* @param image The image that is displayed for this proposal or {@code null} if no
* image is desired.
*/
- public LinkedCorrectionProposal(String name, ITranslationUnit tu, ASTRewrite rewrite,
- int relevance, Image image) {
+ public LinkedCorrectionProposal(String name, ITranslationUnit tu, ASTRewrite rewrite, int relevance, Image image) {
super(name, tu, rewrite, relevance, image);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java
index b459b92cf5b..dac5a747427 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java
@@ -67,35 +67,36 @@ import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
/**
* A proposal allowing user to edit in place all occurrences of a name.
*/
-public class LinkedNamesAssistProposal implements ICCompletionProposal, ICompletionProposalExtension2,
- ICompletionProposalExtension6, ICommandAccess {
+public class LinkedNamesAssistProposal
+ implements ICCompletionProposal, ICompletionProposalExtension2, ICompletionProposalExtension6, ICommandAccess {
/**
* An exit policy that skips Backspace and Delete at the beginning and at the end
* of a linked position, respectively.
- *
+ *
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=183925 .
*/
public static class DeleteBlockingExitPolicy implements IExitPolicy {
private IDocument fDocument;
public DeleteBlockingExitPolicy(IDocument document) {
- fDocument= document;
+ fDocument = document;
}
@Override
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
- LinkedPosition position= model.findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP));
+ LinkedPosition position = model
+ .findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP));
if (position != null) {
if (event.character == SWT.BS) {
if (offset - 1 < position.getOffset()) {
//skip backspace at beginning of linked position
- event.doit= false;
+ event.doit = false;
}
} else /* event.character == SWT.DEL */ {
if (offset + 1 > position.getOffset() + position.getLength()) {
//skip delete at end of linked position
- event.doit= false;
+ event.doit = false;
}
}
}
@@ -105,8 +106,7 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
}
}
-
- public static final String ASSIST_ID= "org.eclipse.cdt.ui.correction.renameInFile.assist"; //$NON-NLS-1$
+ public static final String ASSIST_ID = "org.eclipse.cdt.ui.correction.renameInFile.assist"; //$NON-NLS-1$
private ITranslationUnit fTranslationUnit;
private String fLabel;
@@ -116,40 +116,40 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
public LinkedNamesAssistProposal(ITranslationUnit tu) {
this(CorrectionMessages.LinkedNamesAssistProposal_description, tu, null);
- fTranslationUnit= tu;
- fRelevance= 8;
+ fTranslationUnit = tu;
+ fRelevance = 8;
}
public LinkedNamesAssistProposal(String label, ITranslationUnit tu, String valueSuggestion) {
- fLabel= label;
- fTranslationUnit= tu;
- fValueSuggestion= valueSuggestion;
- fRelevance= 8;
+ fLabel = label;
+ fTranslationUnit = tu;
+ fValueSuggestion = valueSuggestion;
+ fRelevance = 8;
}
@Override
public void apply(final ITextViewer viewer, char trigger, int stateMask, final int offset) {
try {
fLocations = null;
- Point selection= viewer.getSelectedRange();
+ Point selection = viewer.getSelectedRange();
final int secectionOffset = selection.x;
final int selectionLength = selection.y;
ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY,
new NullProgressMonitor(), new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
- if (astRoot == null)
- return Status.CANCEL_STATUS;
-
- IASTNodeSelector selector= astRoot.getNodeSelector(null);
- IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
- if (name != null) {
- fLocations = LinkedNamesFinder.findByName(astRoot, name);
- }
- return Status.OK_STATUS;
- }
- });
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+ if (astRoot == null)
+ return Status.CANCEL_STATUS;
+
+ IASTNodeSelector selector = astRoot.getNodeSelector(null);
+ IASTName name = selector.findEnclosingName(secectionOffset, selectionLength);
+ if (name != null) {
+ fLocations = LinkedNamesFinder.findByName(astRoot, name);
+ }
+ return Status.OK_STATUS;
+ }
+ });
if (fLocations == null || fLocations.length == 0) {
return;
@@ -170,7 +170,7 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
* @return the rank of the location with respect to the invocation offset
*/
private int rank(IRegion location) {
- int relativeRank= location.getOffset() + location.getLength() - offset;
+ int relativeRank = location.getOffset() + location.getLength() - offset;
if (relativeRank < 0) {
return Integer.MAX_VALUE + relativeRank;
} else {
@@ -178,31 +178,31 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
}
}
});
-
- IDocument document= viewer.getDocument();
- LinkedPositionGroup group= new LinkedPositionGroup();
- for (int i= 0; i < fLocations.length; i++) {
- IRegion item= fLocations[i];
+
+ IDocument document = viewer.getDocument();
+ LinkedPositionGroup group = new LinkedPositionGroup();
+ for (int i = 0; i < fLocations.length; i++) {
+ IRegion item = fLocations[i];
group.addPosition(new LinkedPosition(document, item.getOffset(), item.getLength(), i));
}
- LinkedModeModel model= new LinkedModeModel();
+ LinkedModeModel model = new LinkedModeModel();
model.addGroup(group);
model.forceInstall();
- CEditor editor= getCEditor();
+ CEditor editor = getCEditor();
if (editor != null) {
model.addLinkingListener(new EditorHighlightingSynchronizer(editor));
}
- LinkedModeUI ui= new EditorLinkedModeUI(model, viewer);
+ LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
ui.setExitPolicy(new DeleteBlockingExitPolicy(document));
ui.setExitPosition(viewer, offset, 0, LinkedPositionGroup.NO_STOP);
ui.enter();
if (fValueSuggestion != null) {
document.replace(fLocations[0].getOffset(), fLocations[0].getLength(), fValueSuggestion);
- IRegion selectedRegion= ui.getSelectedRegion();
- selection= new Point(selectedRegion.getOffset(), fValueSuggestion.length());
+ IRegion selectedRegion = ui.getSelectedRegion();
+ selection = new Point(selectedRegion.getOffset(), fValueSuggestion.length());
}
viewer.setSelectedRange(selection.x, selection.y); // By default full word is selected, restore original selection
@@ -217,7 +217,7 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
* @return the currently active C editor, or {@code null}
*/
private CEditor getCEditor() {
- IEditorPart part= CUIPlugin.getActivePage().getActiveEditor();
+ IEditorPart part = CUIPlugin.getActivePage().getActiveEditor();
if (part instanceof CEditor) {
return (CEditor) part;
} else {
@@ -242,23 +242,22 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
@Override
public String getDisplayString() {
- String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+ String shortCutString = CorrectionCommandHandler.getShortCutString(getCommandId());
if (shortCutString != null) {
- return NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
- fLabel, shortCutString);
+ return NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, fLabel, shortCutString);
}
return fLabel;
}
-
+
@Override
public StyledString getStyledDisplayString() {
- StyledString str= new StyledString(fLabel);
-
- String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+ StyledString str = new StyledString(fLabel);
+
+ String shortCutString = CorrectionCommandHandler.getShortCutString(getCommandId());
if (shortCutString != null) {
- String decorated= NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
- fLabel, shortCutString);
- return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER);
+ String decorated = NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, fLabel,
+ shortCutString);
+ return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER);
}
return str;
}
@@ -297,7 +296,7 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
}
public void setRelevance(int relevance) {
- fRelevance= relevance;
+ fRelevance = relevance;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefactoringProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefactoringProposal.java
index 074ebcf0e51..901a61f3666 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefactoringProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefactoringProposal.java
@@ -44,13 +44,13 @@ public class RenameRefactoringProposal implements ICCompletionProposal, IComplet
public RenameRefactoringProposal(CEditor editor) {
fEditor = editor;
- fLabel= CorrectionMessages.RenameRefactoringProposal_name;
- fRelevance= 8;
+ fLabel = CorrectionMessages.RenameRefactoringProposal_name;
+ fRelevance = 8;
}
@Override
public void apply(IDocument document) {
- CRenameAction action= new CRenameAction();
+ CRenameAction action = new CRenameAction();
action.setEditor(fEditor);
action.run();
}
@@ -67,7 +67,7 @@ public class RenameRefactoringProposal implements ICCompletionProposal, IComplet
@Override
public String getDisplayString() {
- String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+ String shortCutString = CorrectionCommandHandler.getShortCutString(getCommandId());
if (shortCutString != null) {
return Messages.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
new String[] { fLabel, shortCutString });
@@ -77,11 +77,11 @@ public class RenameRefactoringProposal implements ICCompletionProposal, IComplet
@Override
public StyledString getStyledDisplayString() {
- StyledString str= new StyledString(fLabel);
+ StyledString str = new StyledString(fLabel);
- String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+ String shortCutString = CorrectionCommandHandler.getShortCutString(getCommandId());
if (shortCutString != null) {
- String decorated= Messages.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+ String decorated = Messages.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
new String[] { fLabel, shortCutString });
return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.QUALIFIER_STYLER, str);
}
@@ -114,6 +114,6 @@ public class RenameRefactoringProposal implements ICCompletionProposal, IComplet
}
public void setRelevance(int relevance) {
- fRelevance= relevance;
+ fRelevance = relevance;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrectionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrectionProposal.java
index b21227ee8b5..beca666a37b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrectionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrectionProposal.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -69,7 +69,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.LinkedProposalModelPresenter;
*
* @since 5.1
*/
-public class TUCorrectionProposal extends ChangeCorrectionProposal {
+public class TUCorrectionProposal extends ChangeCorrectionProposal {
private ITranslationUnit fTranslationUnit;
private LinkedProposalModel fLinkedProposalModel;
@@ -90,7 +90,7 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
if (tu == null) {
throw new IllegalArgumentException("Translation unit must not be null"); //$NON-NLS-1$
}
- fTranslationUnit= tu;
+ fTranslationUnit = tu;
}
/**
@@ -98,7 +98,7 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
* <p>
* Users have to override {@link #addEdits(IDocument, TextEdit)} to provide
* the text edits or {@link #createTextChange()} to provide a text change.
- *
+ *
* @param name The name that is displayed in the proposal selection dialog.
* @param tu The compilation unit on that the change works.
* @param relevance The relevance of this proposal.
@@ -120,32 +120,32 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
* @throws CoreException can be thrown if adding the edits is failing.
*/
protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
-// if (false) {
-// throw new CoreException(CUIStatus.createError(IStatus.ERROR, "Implementors can throw an exception", null)); //$NON-NLS-1$
-// }
+ // if (false) {
+ // throw new CoreException(CUIStatus.createError(IStatus.ERROR, "Implementors can throw an exception", null)); //$NON-NLS-1$
+ // }
}
protected LinkedProposalModel getLinkedProposalModel() {
if (fLinkedProposalModel == null) {
- fLinkedProposalModel= new LinkedProposalModel();
+ fLinkedProposalModel = new LinkedProposalModel();
}
return fLinkedProposalModel;
}
public void setLinkedProposalModel(LinkedProposalModel model) {
- fLinkedProposalModel= model;
+ fLinkedProposalModel = model;
}
@Override
public String getAdditionalProposalInfo() {
- final StringBuilder buf= new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
try {
- final TextChange change= getTextChange();
+ final TextChange change = getTextChange();
change.setKeepPreviewEdits(true);
- final IDocument previewContent= change.getPreviewDocument(new NullProgressMonitor());
- final TextEdit rootEdit= change.getPreviewEdit(change.getEdit());
+ final IDocument previewContent = change.getPreviewDocument(new NullProgressMonitor());
+ final TextEdit rootEdit = change.getPreviewEdit(change.getEdit());
class EditAnnotator extends TextEditVisitor {
private int fWrittenToPos = 0;
@@ -214,26 +214,27 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
return buf.toString();
}
- private final int surroundLines= 1;
+ private final int surroundLines = 1;
- private void appendContent(IDocument text, int startOffset, int endOffset, StringBuilder buf, boolean surroundLinesOnly) {
+ private void appendContent(IDocument text, int startOffset, int endOffset, StringBuilder buf,
+ boolean surroundLinesOnly) {
try {
- int startLine= text.getLineOfOffset(startOffset);
- int endLine= text.getLineOfOffset(endOffset);
+ int startLine = text.getLineOfOffset(startOffset);
+ int endLine = text.getLineOfOffset(endOffset);
- boolean dotsAdded= false;
+ boolean dotsAdded = false;
if (surroundLinesOnly && startOffset == 0) { // No surround lines for the top no-change range
- startLine= Math.max(endLine - surroundLines, 0);
+ startLine = Math.max(endLine - surroundLines, 0);
buf.append("...<br>"); //$NON-NLS-1$
- dotsAdded= true;
+ dotsAdded = true;
}
- for (int i= startLine; i <= endLine; i++) {
+ for (int i = startLine; i <= endLine; i++) {
if (surroundLinesOnly) {
if ((i - startLine > surroundLines) && (endLine - i > surroundLines)) {
if (!dotsAdded) {
buf.append("...<br>"); //$NON-NLS-1$
- dotsAdded= true;
+ dotsAdded = true;
} else if (endOffset == text.getLength()) {
return; // No surround lines for the bottom no-change range
}
@@ -241,18 +242,18 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
}
}
- IRegion lineInfo= text.getLineInformation(i);
- int start= lineInfo.getOffset();
- int end= start + lineInfo.getLength();
+ IRegion lineInfo = text.getLineInformation(i);
+ int start = lineInfo.getOffset();
+ int end = start + lineInfo.getLength();
- int from= Math.max(start, startOffset);
- int to= Math.min(end, endOffset);
- String content= text.get(from, to - from);
+ int from = Math.max(start, startOffset);
+ int to = Math.min(end, endOffset);
+ String content = text.get(from, to - from);
if (surroundLinesOnly && from == start && Strings.containsOnlyWhitespaces(content)) {
continue; // Ignore empty lines except when range started in the middle of a line
}
- for (int k= 0; k < content.length(); k++) {
- char ch= content.charAt(k);
+ for (int k = 0; k < content.length(); k++) {
+ char ch = content.charAt(k);
if (ch == '<') {
buf.append("&lt;"); //$NON-NLS-1$
} else if (ch == '>') {
@@ -273,21 +274,21 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
@Override
public void apply(IDocument document) {
try {
- ITranslationUnit unit= getTranslationUnit();
- IEditorPart part= null;
+ ITranslationUnit unit = getTranslationUnit();
+ IEditorPart part = null;
if (unit.getResource().exists()) {
- boolean canEdit= performValidateEdit(unit);
+ boolean canEdit = performValidateEdit(unit);
if (!canEdit) {
return;
}
- part= EditorUtility.isOpenInEditor(unit);
+ part = EditorUtility.isOpenInEditor(unit);
if (part == null) {
- part= EditorUtility.openInEditor(unit);
+ part = EditorUtility.openInEditor(unit);
if (part != null) {
- document= CUIPlugin.getDefault().getDocumentProvider().getDocument(part.getEditorInput());
+ document = CUIPlugin.getDefault().getDocumentProvider().getDocument(part.getEditorInput());
}
}
- IWorkbenchPage page= CUIPlugin.getActivePage();
+ IWorkbenchPage page = CUIPlugin.getActivePage();
if (page != null && part != null) {
page.bringToTop(part);
}
@@ -303,10 +304,10 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
}
private boolean performValidateEdit(ITranslationUnit unit) {
- IStatus status= Resources.makeCommittable(unit.getResource(), CUIPlugin.getActiveWorkbenchShell());
+ IStatus status = Resources.makeCommittable(unit.getResource(), CUIPlugin.getActiveWorkbenchShell());
if (!status.isOK()) {
- String label= CorrectionMessages.TUCorrectionProposal_error_title;
- String message= CorrectionMessages.TUCorrectionProposal_error_message;
+ String label = CorrectionMessages.TUCorrectionProposal_error_title;
+ String message = CorrectionMessages.TUCorrectionProposal_error_message;
ErrorDialog.openError(CUIPlugin.getActiveWorkbenchShell(), label, message, status);
return false;
}
@@ -324,13 +325,13 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
if (fLinkedProposalModel != null) {
if (fLinkedProposalModel.hasLinkedPositions() && part instanceof CEditor) {
// enter linked mode
- ITextViewer viewer= ((CEditor) part).getViewer();
+ ITextViewer viewer = ((CEditor) part).getViewer();
new LinkedProposalModelPresenter().enterLinkedMode(viewer, part, fLinkedProposalModel);
} else if (part instanceof ITextEditor) {
- LinkedProposalPositionGroup.PositionInformation endPosition= fLinkedProposalModel.getEndPosition();
+ LinkedProposalPositionGroup.PositionInformation endPosition = fLinkedProposalModel.getEndPosition();
if (endPosition != null) {
// select a result
- int pos= endPosition.getOffset() + endPosition.getLength();
+ int pos = endPosition.getOffset() + endPosition.getLength();
((ITextEditor) part).selectAndReveal(pos, 0);
}
}
@@ -349,30 +350,30 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
* @throws CoreException thrown if the creation of the text change failed.
*/
protected TextChange createTextChange() throws CoreException {
- ITranslationUnit tu= getTranslationUnit();
- String name= getName();
+ ITranslationUnit tu = getTranslationUnit();
+ String name = getName();
TextChange change;
if (!tu.getResource().exists()) {
String source;
try {
- source= tu.getSource();
+ source = tu.getSource();
} catch (CModelException e) {
CUIPlugin.log(e);
- source= ""; //$NON-NLS-1$
+ source = ""; //$NON-NLS-1$
}
- Document document= new Document(source);
+ Document document = new Document(source);
document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(tu));
- change= new DocumentChange(name, document);
+ change = new DocumentChange(name, document);
} else {
CTextFileChange tuChange = new CTextFileChange(name, tu);
tuChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
- change= tuChange;
+ change = tuChange;
}
- TextEdit rootEdit= new MultiTextEdit();
+ TextEdit rootEdit = new MultiTextEdit();
change.setEdit(rootEdit);
// Initialize text change.
- IDocument document= change.getCurrentDocument(new NullProgressMonitor());
+ IDocument document = change.getCurrentDocument(new NullProgressMonitor());
addEdits(document, rootEdit);
return change;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java
index bfb0e1f4327..74d2f2ddc56 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java
@@ -33,23 +33,24 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
abstract class AbstractDocCommentProposalComputer implements ICompletionProposalComputer {
-
+
protected abstract IDocCommentViewerConfiguration getConfiguration(IDocCommentOwner owner);
-
+
protected final IDocCommentViewerConfiguration getConfiguration() {
- IResource resource= getResource();
- IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource);
+ IResource resource = getResource();
+ IDocCommentOwner owner = DocCommentOwnerManager.getInstance().getCommentOwner(resource);
return getConfiguration(owner);
}
-
+
@Override
- public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
return getConfiguration().createProposalComputer().computeCompletionProposals(context, monitor);
}
@Override
- public List<IContextInformation> computeContextInformation(
- ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
return getConfiguration().createProposalComputer().computeContextInformation(context, monitor);
}
@@ -65,30 +66,30 @@ abstract class AbstractDocCommentProposalComputer implements ICompletionProposal
@Override
public void sessionStarted() {
}
-
+
private static IResource getResource() {
- ITranslationUnit tu= getTranslationUnit();
+ ITranslationUnit tu = getTranslationUnit();
if (tu == null)
return null;
-
+
return tu.getResource();
}
-
+
private static ITranslationUnit getTranslationUnit() {
- IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null)
return null;
- IWorkbenchPage page= window.getActivePage();
+ IWorkbenchPage page = window.getActivePage();
if (page == null)
return null;
- IEditorPart editor= page.getActiveEditor();
+ IEditorPart editor = page.getActiveEditor();
if (editor == null)
return null;
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
- ITranslationUnit unit= manager.getWorkingCopy(editor.getEditorInput());
+ IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+ ITranslationUnit unit = manager.getWorkingCopy(editor.getEditorInput());
if (unit == null)
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.java
index f60c94791a4..667f9009d97 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.java
@@ -25,15 +25,19 @@ public class DocCommentOwner implements IDocCommentOwner {
private final String id;
private final String name;
private final IDocCommentViewerConfiguration multi, single;
-
- public DocCommentOwner(String id, String name, IDocCommentViewerConfiguration multi, IDocCommentViewerConfiguration single) {
- Assert.isNotNull(id); Assert.isNotNull(name); Assert.isNotNull(multi); Assert.isNotNull(single);
- this.id= id;
- this.name= name;
- this.multi= multi;
- this.single= single;
+
+ public DocCommentOwner(String id, String name, IDocCommentViewerConfiguration multi,
+ IDocCommentViewerConfiguration single) {
+ Assert.isNotNull(id);
+ Assert.isNotNull(name);
+ Assert.isNotNull(multi);
+ Assert.isNotNull(single);
+ this.id = id;
+ this.name = name;
+ this.multi = multi;
+ this.single = single;
}
-
+
/*
* @see org.eclipse.cdt.ui.text.ICCommentOwner#getID()
*/
@@ -41,7 +45,7 @@ public class DocCommentOwner implements IDocCommentOwner {
public String getID() {
return id;
}
-
+
/*
* @see org.eclipse.cdt.ui.text.ICCommentOwner#getName()
*/
@@ -49,7 +53,7 @@ public class DocCommentOwner implements IDocCommentOwner {
public String getName() {
return name;
}
-
+
/*
* @see org.eclipse.cdt.ui.text.ICCommentOwner#getMultilineConfiguration()
*/
@@ -57,7 +61,7 @@ public class DocCommentOwner implements IDocCommentOwner {
public IDocCommentViewerConfiguration getMultilineConfiguration() {
return multi;
}
-
+
/*
* @see org.eclipse.cdt.ui.text.ICCommentOwner#getSinglelineConfiguration()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java
index 887542ea301..fc86fcf4bac 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java
@@ -57,40 +57,40 @@ public class DocCommentOwnerManager {
private static final String ATTRKEY_OWNER_SINGLELINE = "singleline"; //$NON-NLS-1$
private static final String ATTRKEY_OWNER_MULTILINE = "multiline"; //$NON-NLS-1$
- private static final String QUALIFIER= CCorePlugin.PLUGIN_ID;
- private static final String WORKSPACE_DOC_TOOL_NODE= "doctool"; //$NON-NLS-1$
- private static final String PREFKEY_WORKSPACE_DEFAULT= "workspace.default"; //$NON-NLS-1$
-
+ private static final String QUALIFIER = CCorePlugin.PLUGIN_ID;
+ private static final String WORKSPACE_DOC_TOOL_NODE = "doctool"; //$NON-NLS-1$
+ private static final String PREFKEY_WORKSPACE_DEFAULT = "workspace.default"; //$NON-NLS-1$
+
private static DocCommentOwnerManager singleton;
public static DocCommentOwnerManager getInstance() {
- return singleton == null ? singleton= new DocCommentOwnerManager() : singleton;
+ return singleton == null ? singleton = new DocCommentOwnerManager() : singleton;
}
private Map<String, IDocCommentOwner> fOwners;
private IDocCommentOwner fWorkspaceOwner;
- private Map<IProject, ProjectMap> prj2map= new HashMap<IProject, ProjectMap>();
+ private Map<IProject, ProjectMap> prj2map = new HashMap<IProject, ProjectMap>();
private static List<IDocCommentOwnershipListener> fListeners;
private DocCommentOwnerManager() {
- fOwners= getCommentOwnerExtensions();
- fListeners= new ArrayList<IDocCommentOwnershipListener>();
-
- Preferences defaultPrefs = DefaultScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
- Preferences prefs= InstanceScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
- String id= prefs.get(PREFKEY_WORKSPACE_DEFAULT, defaultPrefs.get(PREFKEY_WORKSPACE_DEFAULT,
- NullDocCommentOwner.INSTANCE.getID()));
-
- fWorkspaceOwner= getOwner(id);
+ fOwners = getCommentOwnerExtensions();
+ fListeners = new ArrayList<IDocCommentOwnershipListener>();
+
+ Preferences defaultPrefs = DefaultScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
+ Preferences prefs = InstanceScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
+ String id = prefs.get(PREFKEY_WORKSPACE_DEFAULT,
+ defaultPrefs.get(PREFKEY_WORKSPACE_DEFAULT, NullDocCommentOwner.INSTANCE.getID()));
+
+ fWorkspaceOwner = getOwner(id);
if (fWorkspaceOwner == null) {
// this could occur if a plug-in is no longer available
- fWorkspaceOwner= NullDocCommentOwner.INSTANCE;
+ fWorkspaceOwner = NullDocCommentOwner.INSTANCE;
}
}
/**
* @param project a non-null project
- * @return whether the specified project defines any documentation owner association
+ * @return whether the specified project defines any documentation owner association
*/
public boolean projectDefinesOwnership(IProject project) {
return !getProjectMap(project).isEmpty();
@@ -102,14 +102,14 @@ public class DocCommentOwnerManager {
public void setWorkspaceCommentOwner(IDocCommentOwner newOwner) {
if (newOwner == null)
throw new IllegalArgumentException();
-
+
if (!fWorkspaceOwner.getID().equals(newOwner.getID())) {
- IDocCommentOwner oldOwner= fWorkspaceOwner;
- fWorkspaceOwner= newOwner;
+ IDocCommentOwner oldOwner = fWorkspaceOwner;
+ fWorkspaceOwner = newOwner;
- Preferences prefs= InstanceScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
+ Preferences prefs = InstanceScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
prefs.put(PREFKEY_WORKSPACE_DEFAULT, newOwner.getID());
-
+
fireWorkspaceOwnershipChanged(oldOwner, fWorkspaceOwner);
}
}
@@ -123,20 +123,20 @@ public class DocCommentOwnerManager {
}
/**
- *
+ *
* @param resource May be null.
* @return a non-null IDocCommentOwner. If the resource was null, the {@link NullDocCommentOwner} is returned.
*/
public IDocCommentOwner getCommentOwner(IResource resource) {
- if (resource==null)
+ if (resource == null)
return NullDocCommentOwner.INSTANCE;
if (ResourcesPlugin.getWorkspace().getRoot().equals(resource))
return getWorkspaceCommentOwner();
- ProjectMap pm= getProjectMap(resource);
- String ownerID= pm.getOwnerID(resource);
- IDocCommentOwner result= getOwner(ownerID);
+ ProjectMap pm = getProjectMap(resource);
+ String ownerID = pm.getOwnerID(resource);
+ IDocCommentOwner result = getOwner(ownerID);
return result == null ? fWorkspaceOwner : result;
}
@@ -168,12 +168,12 @@ public class DocCommentOwnerManager {
return;
}
- ProjectMap pm= getProjectMap(resource);
- IDocCommentOwner oldOwner= getCommentOwner(resource);
+ ProjectMap pm = getProjectMap(resource);
+ IDocCommentOwner oldOwner = getCommentOwner(resource);
pm.setCommentOwner(resource, newOwner);
-
- IDocCommentOwner newLogicalOwner= getCommentOwner(resource);
- if (!newLogicalOwner.getID().equals(oldOwner.getID())) {
+
+ IDocCommentOwner newLogicalOwner = getCommentOwner(resource);
+ if (!newLogicalOwner.getID().equals(oldOwner.getID())) {
fireOwnershipChanged(resource, removeSubMappings, oldOwner, newLogicalOwner);
}
}
@@ -186,7 +186,6 @@ public class DocCommentOwnerManager {
return fOwners.values().toArray(new IDocCommentOwner[fOwners.values().size()]);
}
-
/**
* @param listener registers a listener for doc-comment ownership events
*/
@@ -214,7 +213,7 @@ public class DocCommentOwnerManager {
*/
private ProjectMap getProjectMap(IResource resource) {
Assert.isNotNull(resource);
- IProject project= resource.getProject();
+ IProject project = resource.getProject();
if (!prj2map.containsKey(project)) {
prj2map.put(project, new ProjectMap(project));
@@ -228,7 +227,7 @@ public class DocCommentOwnerManager {
* via the DocCommentOwner extension point
*/
private static Map<String, IDocCommentOwner> getCommentOwnerExtensions() {
- Map<String, IDocCommentOwner> result= new HashMap<String, IDocCommentOwner>();
+ Map<String, IDocCommentOwner> result = new HashMap<String, IDocCommentOwner>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint indexProviders = registry.getExtensionPoint(CUIPlugin.ID_COMMENT_OWNER);
@@ -237,18 +236,21 @@ public class DocCommentOwnerManager {
try {
IConfigurationElement[] ce = extension.getConfigurationElements();
for (IConfigurationElement element : ce) {
- if (element.getName().equals(ELEMENT_OWNER)) {
- IDocCommentViewerConfiguration multi = (IDocCommentViewerConfiguration) element.createExecutableExtension(ATTRKEY_OWNER_MULTILINE);
- IDocCommentViewerConfiguration single = (IDocCommentViewerConfiguration) element.createExecutableExtension(ATTRKEY_OWNER_SINGLELINE);
- String id= element.getAttribute(ATTRKEY_OWNER_ID);
- String name= element.getAttribute(ATTRKEY_OWNER_NAME);
- if (result.put(id, new DocCommentOwner(id, name, multi, single))!=null) {
- String msg= MessageFormat.format(Messages.DocCommentOwnerManager_DuplicateMapping0, new Object[] {id});
+ if (element.getName().equals(ELEMENT_OWNER)) {
+ IDocCommentViewerConfiguration multi = (IDocCommentViewerConfiguration) element
+ .createExecutableExtension(ATTRKEY_OWNER_MULTILINE);
+ IDocCommentViewerConfiguration single = (IDocCommentViewerConfiguration) element
+ .createExecutableExtension(ATTRKEY_OWNER_SINGLELINE);
+ String id = element.getAttribute(ATTRKEY_OWNER_ID);
+ String name = element.getAttribute(ATTRKEY_OWNER_NAME);
+ if (result.put(id, new DocCommentOwner(id, name, multi, single)) != null) {
+ String msg = MessageFormat.format(Messages.DocCommentOwnerManager_DuplicateMapping0,
+ new Object[] { id });
CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, msg));
}
}
}
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
CUIPlugin.log(ce);
}
}
@@ -256,7 +258,8 @@ public class DocCommentOwnerManager {
return result;
}
- private void fireOwnershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
+ private void fireOwnershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner,
+ IDocCommentOwner newOwner) {
for (IDocCommentOwnershipListener docCommentOwnershipListener : fListeners) {
docCommentOwnershipListener.ownershipChanged(resource, submappingsRemoved, oldOwner, newOwner);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDictionary.java
index 9a23bc677a3..1f67cc5f05b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDictionary.java
@@ -28,15 +28,15 @@ import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary;
public class DocCommentSpellDictionary extends AbstractSpellDictionary {
protected IDocCommentSimpleDictionary fDict;
-
+
/**
* @param dict
*/
public DocCommentSpellDictionary(IDocCommentSimpleDictionary dict) {
Assert.isNotNull(dict);
- fDict= dict;
+ fDict = dict;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getName()
*/
@@ -52,10 +52,10 @@ public class DocCommentSpellDictionary extends AbstractSpellDictionary {
protected synchronized boolean load(final URL url) {
unload();
- String[] words= fDict.getAdditionalWords();
- for(int i=0; i<words.length; i++)
+ String[] words = fDict.getAdditionalWords();
+ for (int i = 0; i < words.length; i++)
hashWord(words[i]);
-
+
return false;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.java
index b301b5a56a9..ce996ab75a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.java
@@ -56,16 +56,16 @@ public class EditorReopener implements IDocCommentOwnershipListener {
* @see org.eclipse.cdt.ui.text.doctools.IDocCommentOwnershipListener#ownershipChanged(org.eclipse.core.resources.IResource, boolean, org.eclipse.cdt.ui.text.doctools.IDocCommentOwner, org.eclipse.cdt.ui.text.doctools.IDocCommentOwner)
*/
@Override
- public void ownershipChanged(IResource resource, boolean recursive,
- IDocCommentOwner old, IDocCommentOwner newOwner) {
- IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if(window!=null) {
+ public void ownershipChanged(IResource resource, boolean recursive, IDocCommentOwner old,
+ IDocCommentOwner newOwner) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
try {
- IEditorPart[] parts= getEditorsToRepon(window, resource);
- if(queryIfNeeded(window.getShell(), parts)) {
+ IEditorPart[] parts = getEditorsToRepon(window, resource);
+ if (queryIfNeeded(window.getShell(), parts)) {
reopenEditors(window, parts);
}
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
CUIPlugin.log(ce);
}
}
@@ -76,14 +76,14 @@ public class EditorReopener implements IDocCommentOwnershipListener {
*/
@Override
public void workspaceOwnershipChanged(IDocCommentOwner old, IDocCommentOwner newOwner) {
- IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if(window!=null) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
try {
- IEditorPart[] parts= getEditorsToRepon(window, null);
- if(queryIfNeeded(window.getShell(), parts)) {
+ IEditorPart[] parts = getEditorsToRepon(window, null);
+ if (queryIfNeeded(window.getShell(), parts)) {
reopenEditors(window, parts);
}
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
CUIPlugin.log(ce);
}
}
@@ -99,23 +99,23 @@ public class EditorReopener implements IDocCommentOwnershipListener {
* This could be smarter in determining smaller sets of editors to re-open
*/
private IEditorPart[] getEditorsToRepon(IWorkbenchWindow window, IResource resource) {
- List<IEditorPart> needReopening= new ArrayList<IEditorPart>();
- if(window.getActivePage()!=null) {
- IEditorReference[] es= window.getActivePage().getEditorReferences();
- for(int i=0; i<es.length; i++) {
- IEditorPart part= es[i].getEditor(false);
- if(part!=null) {
- IEditorInput iei= part.getEditorInput();
- if(resource!=null) {
- if(iei instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput) iei).getFile();
- IProject project= resource.getProject();
- if(file.getProject().equals(project) && CoreModel.hasCNature(project)) {
+ List<IEditorPart> needReopening = new ArrayList<IEditorPart>();
+ if (window.getActivePage() != null) {
+ IEditorReference[] es = window.getActivePage().getEditorReferences();
+ for (int i = 0; i < es.length; i++) {
+ IEditorPart part = es[i].getEditor(false);
+ if (part != null) {
+ IEditorInput iei = part.getEditorInput();
+ if (resource != null) {
+ if (iei instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput) iei).getFile();
+ IProject project = resource.getProject();
+ if (file.getProject().equals(project) && CoreModel.hasCNature(project)) {
needReopening.add(part);
}
}
} else {
- if(iei instanceof ITranslationUnitEditorInput || iei instanceof IFileEditorInput) {
+ if (iei instanceof ITranslationUnitEditorInput || iei instanceof IFileEditorInput) {
needReopening.add(part);
}
}
@@ -126,56 +126,56 @@ public class EditorReopener implements IDocCommentOwnershipListener {
}
private boolean queryIfNeeded(Shell shell, IEditorPart[] editorParts) throws CoreException {
- boolean anyUnsaved= false;
- for(int j=0; j<editorParts.length; j++)
- if(editorParts[j].isSaveOnCloseNeeded())
- anyUnsaved= true;
+ boolean anyUnsaved = false;
+ for (int j = 0; j < editorParts.length; j++)
+ if (editorParts[j].isSaveOnCloseNeeded())
+ anyUnsaved = true;
- boolean saveAndReopen= !anyUnsaved;
- if(anyUnsaved) {
- String title= Messages.EditorReopener_ShouldSave_Title;
- String msg= Messages.EditorReopener_ShouldSave_Message;
+ boolean saveAndReopen = !anyUnsaved;
+ if (anyUnsaved) {
+ String title = Messages.EditorReopener_ShouldSave_Title;
+ String msg = Messages.EditorReopener_ShouldSave_Message;
if (MessageDialog.openQuestion(shell, title, msg))
- saveAndReopen= true;
+ saveAndReopen = true;
}
return saveAndReopen;
}
private void reopenEditors(final IWorkbenchWindow window, final IEditorPart[] editorParts) throws CoreException {
- WorkbenchJob job= new WorkbenchJob(Messages.EditorReopener_ReopenJobStart) {
+ WorkbenchJob job = new WorkbenchJob(Messages.EditorReopener_ReopenJobStart) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- IEditorPart oldActive= window.getActivePage().getActiveEditor();
- IEditorPart newActive= null;
+ IEditorPart oldActive = window.getActivePage().getActiveEditor();
+ IEditorPart newActive = null;
- for(int j=0; j<editorParts.length; j++) {
- IEditorPart oldPart= editorParts[j];
- if(oldPart.isDirty()) {
+ for (int j = 0; j < editorParts.length; j++) {
+ IEditorPart oldPart = editorParts[j];
+ if (oldPart.isDirty()) {
oldPart.doSave(new NullProgressMonitor());
}
window.getActivePage().closeEditor(oldPart, false);
- IEditorInput oldInput= oldPart.getEditorInput();
+ IEditorInput oldInput = oldPart.getEditorInput();
try {
- IEditorPart newPart= null;
- if(oldInput instanceof IFileEditorInput) {
- newPart= EditorUtility.openInEditor(((IFileEditorInput)oldInput).getFile());
- } else if(oldInput instanceof ExternalEditorInput) {
- ExternalEditorInput eei= (ExternalEditorInput) oldInput;
- ICElement element= CoreModel.getDefault().create(eei.getMarkerResource());
- newPart= EditorUtility.openInEditor(eei.getPath(), element);
+ IEditorPart newPart = null;
+ if (oldInput instanceof IFileEditorInput) {
+ newPart = EditorUtility.openInEditor(((IFileEditorInput) oldInput).getFile());
+ } else if (oldInput instanceof ExternalEditorInput) {
+ ExternalEditorInput eei = (ExternalEditorInput) oldInput;
+ ICElement element = CoreModel.getDefault().create(eei.getMarkerResource());
+ newPart = EditorUtility.openInEditor(eei.getPath(), element);
}
- if(oldPart == oldActive)
- newActive= newPart;
- } catch(PartInitException pie) {
+ if (oldPart == oldActive)
+ newActive = newPart;
+ } catch (PartInitException pie) {
CUIPlugin.log(pie);
- } catch(CModelException cme) {
+ } catch (CModelException cme) {
CUIPlugin.log(cme);
}
}
- if(newActive != null) {
+ if (newActive != null) {
window.getActivePage().activate(newActive);
}
return new Status(IStatus.OK, CUIPlugin.PLUGIN_ID, Messages.EditorReopener_ReopenJobComplete);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.java
index 3eaeed7bd2f..f5c3ba5f62e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.java
@@ -17,13 +17,10 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
public final class NullDocCommentOwner extends DocCommentOwner {
private static final String ID = "org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner"; //$NON-NLS-1$
- public static final IDocCommentOwner INSTANCE= new NullDocCommentOwner();
+ public static final IDocCommentOwner INSTANCE = new NullDocCommentOwner();
+
private NullDocCommentOwner() {
- super(
- ID,
- Messages.NullDocCommentOwner_Name,
- NullDocCommentViewerConfiguration.INSTANCE,
- NullDocCommentViewerConfiguration.INSTANCE
- );
+ super(ID, Messages.NullDocCommentOwner_Name, NullDocCommentViewerConfiguration.INSTANCE,
+ NullDocCommentViewerConfiguration.INSTANCE);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerConfiguration.java
index 3cb9a8cae31..21b626728f6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerConfiguration.java
@@ -24,13 +24,13 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentDictionary;
import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
public class NullDocCommentViewerConfiguration implements IDocCommentViewerConfiguration {
- public static final IDocCommentViewerConfiguration INSTANCE= new NullDocCommentViewerConfiguration();
-
+ public static final IDocCommentViewerConfiguration INSTANCE = new NullDocCommentViewerConfiguration();
+
public NullDocCommentViewerConfiguration() {
}
-
+
@Override
- public IAutoEditStrategy createAutoEditStrategy() {
+ public IAutoEditStrategy createAutoEditStrategy() {
return null;
}
@@ -53,7 +53,7 @@ public class NullDocCommentViewerConfiguration implements IDocCommentViewerConfi
public boolean isDocumentationComment(IDocument doc, int offset, int length) {
return false;
}
-
+
@Override
public IDocCommentDictionary getSpellingDictionary() {
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java
index 08caa97e3a3..8a71a88c3ea 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java
@@ -39,47 +39,47 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
* <li>Manages persistence of these mappings to the .cproject file.
* </ul>
* for a particular {@link IProject}
- *
+ *
* @since 5.0
*/
class ProjectMap {
/** .cproject xml element/attribute names **/
- private static final String ATTRVAL_STORAGEID= "org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"; //$NON-NLS-1$
+ private static final String ATTRVAL_STORAGEID = "org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"; //$NON-NLS-1$
private static final String ELEMENT_DOC_COMMENT_OWNER = "doc-comment-owner"; //$NON-NLS-1$
private static final String ATTRKEY_DCO_ID = "id"; //$NON-NLS-1$
private static final String ELEMENT_PATH = "path"; //$NON-NLS-1$
private static final String ATTRKEY_PATH_VALUE = "value"; //$NON-NLS-1$
-
+
private IProject fProject;
private Map<IPath, String> fMap;
-
+
/**
* Loads the project map
* @param project
*/
public ProjectMap(IProject project) {
try {
- fMap= load(project);
- } catch(CoreException ce) {
+ fMap = load(project);
+ } catch (CoreException ce) {
CUIPlugin.log(ce);
- fMap= new HashMap<IPath, String>();
+ fMap = new HashMap<IPath, String>();
}
- fProject= project;
+ fProject = project;
}
-
+
/**
* Returns the id of the doc comment owner mapped to the resource specified, or null
* if no owner is mapped within this project. Ownership is inherited from parents and
- * may be overridden.
+ * may be overridden.
* @param resource
* @return possibly null
*/
public String getOwnerID(IResource resource) {
- String id= null;
+ String id = null;
if (resource != null) {
- for (IPath p= resource.getProjectRelativePath(); ; p= p.removeLastSegments(1)) {
+ for (IPath p = resource.getProjectRelativePath();; p = p.removeLastSegments(1)) {
if (fMap.containsKey(p)) {
- id= fMap.get(p);
+ id = fMap.get(p);
break;
}
if (p.isEmpty())
@@ -107,7 +107,7 @@ class ProjectMap {
}
try {
save();
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
CUIPlugin.log(ce);
}
}
@@ -115,10 +115,10 @@ class ProjectMap {
public boolean isEmpty() {
return fMap.isEmpty();
}
-
+
private static Map<IPath, String> load(IProject project) throws CoreException {
- Map<IPath, String> result= new HashMap<IPath, String>();
- ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(project, false);
+ Map<IPath, String> result = new HashMap<IPath, String>();
+ ICProjectDescription pd = CCorePlugin.getDefault().getProjectDescription(project, false);
if (pd != null) {
ICStorageElement element = pd.getStorage(ATTRVAL_STORAGEID, false);
if (element != null) {
@@ -126,8 +126,8 @@ class ProjectMap {
String commentOwnerID = node.getAttribute(ATTRKEY_DCO_ID);
if (commentOwnerID != null) {
for (ICStorageElement path : node.getChildrenByName(ELEMENT_PATH)) {
- String pathValue= path.getAttribute(ATTRKEY_PATH_VALUE);
- if(pathValue != null) {
+ String pathValue = path.getAttribute(ATTRKEY_PATH_VALUE);
+ if (pathValue != null) {
result.put(Path.fromPortableString(pathValue), commentOwnerID);
}
}
@@ -142,7 +142,7 @@ class ProjectMap {
* Write the map to the .cproject file
*/
public void save() throws CoreException {
- ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(fProject, true);
+ ICProjectDescription pd = CCorePlugin.getDefault().getProjectDescription(fProject, true);
// remove current associations
ICStorageElement data = pd.getStorage(ATTRVAL_STORAGEID, true);
@@ -150,14 +150,14 @@ class ProjectMap {
data.removeChild(child);
// invert and persist associations
- for (Iterator<String> i= fMap.values().iterator(); i.hasNext();) {
- String cid= i.next();
+ for (Iterator<String> i = fMap.values().iterator(); i.hasNext();) {
+ String cid = i.next();
ICStorageElement commentNode = data.createChild(ELEMENT_DOC_COMMENT_OWNER);
commentNode.setAttribute(ATTRKEY_DCO_ID, cid);
- for (Iterator<IPath> j= fMap.keySet().iterator(); j.hasNext(); ) {
- IPath path= j.next();
- String ccid= fMap.get(path);
- if(cid.equals(ccid)) {
+ for (Iterator<IPath> j = fMap.keySet().iterator(); j.hasNext();) {
+ IPath path = j.next();
+ String ccid = fMap.get(path);
+ if (cid.equals(ccid)) {
ICStorageElement pathNode = commentNode.createChild(ELEMENT_PATH);
pathNode.setAttribute(ATTRKEY_PATH_VALUE, path.toPortableString());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java
index 136e2466ab7..9d5f751410f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java
@@ -23,17 +23,17 @@ import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
/**
* Describes a contribution to the folding provider extension point.
- *
+ *
*/
public final class CFoldingStructureProviderDescriptor {
/* extension point attribute names */
-
- private static final String PREFERENCES_CLASS= "preferencesClass"; //$NON-NLS-1$
- private static final String CLASS= "class"; //$NON-NLS-1$
- private static final String NAME= "name"; //$NON-NLS-1$
- private static final String ID= "id"; //$NON-NLS-1$
-
+
+ private static final String PREFERENCES_CLASS = "preferencesClass"; //$NON-NLS-1$
+ private static final String CLASS = "class"; //$NON-NLS-1$
+ private static final String NAME = "name"; //$NON-NLS-1$
+ private static final String ID = "id"; //$NON-NLS-1$
+
/** The identifier of the extension. */
private String fId;
/** The name of the extension. */
@@ -47,69 +47,70 @@ public final class CFoldingStructureProviderDescriptor {
private boolean fHasPreferences;
/** The configuration element of this extension. */
private IConfigurationElement fElement;
-
+
/**
* Creates a new descriptor.
- *
+ *
* @param element the configuration element to read
*/
CFoldingStructureProviderDescriptor(IConfigurationElement element) {
- fElement= element;
- fId= element.getAttribute(ID);
+ fElement = element;
+ fId = element.getAttribute(ID);
Assert.isLegal(fId != null);
-
- fName= element.getAttribute(NAME);
+
+ fName = element.getAttribute(NAME);
if (fName == null)
- fName= fId;
-
- fClass= element.getAttribute(CLASS);
+ fName = fId;
+
+ fClass = element.getAttribute(CLASS);
Assert.isLegal(fClass != null);
-
+
if (element.getAttribute(PREFERENCES_CLASS) == null)
- fHasPreferences= false;
+ fHasPreferences = false;
else
- fHasPreferences= true;
+ fHasPreferences = true;
}
-
+
/**
* Creates a folding provider as described in the extension's xml.
- *
+ *
* @return a new instance of the folding provider described by this
* descriptor
* @throws CoreException if creation fails
*/
public ICFoldingStructureProvider createProvider() throws CoreException {
- ICFoldingStructureProvider prov= (ICFoldingStructureProvider) fElement.createExecutableExtension(CLASS);
+ ICFoldingStructureProvider prov = (ICFoldingStructureProvider) fElement.createExecutableExtension(CLASS);
return prov;
}
/**
* Creates a preferences object as described in the extension's xml.
- *
+ *
* @return a new instance of the reference provider described by this
* descriptor
* @throws CoreException if creation fails
*/
public ICFoldingPreferenceBlock createPreferences() throws CoreException {
if (fHasPreferences) {
- ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) fElement.createExecutableExtension(PREFERENCES_CLASS);
+ ICFoldingPreferenceBlock prefs = (ICFoldingPreferenceBlock) fElement
+ .createExecutableExtension(PREFERENCES_CLASS);
return prefs;
}
return new EmptyCFoldingPreferenceBlock();
}
-
+
/**
* Returns the identifier of the described extension.
- *
+ *
* @return Returns the id
*/
public String getId() {
return fId;
}
-
+
/**
* Returns the name of the described extension.
- *
+ *
* @return Returns the name
*/
public String getName() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java
index 9dcc236ba85..a1b2912af25 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java
@@ -28,21 +28,21 @@ import org.eclipse.core.runtime.Platform;
public class CFoldingStructureProviderRegistry {
- private static final String EXTENSION_POINT= "foldingStructureProviders"; //$NON-NLS-1$
-
+ private static final String EXTENSION_POINT = "foldingStructureProviders"; //$NON-NLS-1$
+
/** The map of descriptors, indexed by their identifiers. */
private Map<String, CFoldingStructureProviderDescriptor> fDescriptors;
/**
- * Creates a new instance.
+ * Creates a new instance.
*/
public CFoldingStructureProviderRegistry() {
}
-
+
/**
* Returns an array of <code>ICFoldingProviderDescriptor</code> describing
* all extension to the <code>foldingProviders</code> extension point.
- *
+ *
* @return the list of extensions to the
* <code>quickDiffReferenceProvider</code> extension point.
*/
@@ -52,11 +52,11 @@ public class CFoldingStructureProviderRegistry {
return fDescriptors.values().toArray(new CFoldingStructureProviderDescriptor[fDescriptors.size()]);
}
}
-
+
/**
* Returns the folding provider with identifier <code>id</code> or
* <code>null</code> if no such provider is registered.
- *
+ *
* @param id the identifier for which a provider is wanted
* @return the corresponding provider, or <code>null</code> if none can be
* found
@@ -67,16 +67,16 @@ public class CFoldingStructureProviderRegistry {
return fDescriptors.get(id);
}
}
-
+
/**
* Instantiates and returns the provider that is currently configured in the
* preferences.
- *
+ *
* @return the current provider according to the preferences
*/
public ICFoldingStructureProvider getCurrentFoldingProvider() {
- String id= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
- CFoldingStructureProviderDescriptor desc= getFoldingProviderDescriptor(id);
+ String id = CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
+ CFoldingStructureProviderDescriptor desc = getFoldingProviderDescriptor(id);
if (desc != null) {
try {
return desc.createProvider();
@@ -86,7 +86,7 @@ public class CFoldingStructureProviderRegistry {
}
return null;
}
-
+
/**
* Ensures that the extensions are read and stored in
* <code>fDescriptors</code>.
@@ -104,19 +104,19 @@ public class CFoldingStructureProviderRegistry {
* </p>
*/
public void reloadExtensions() {
- IExtensionRegistry registry= Platform.getExtensionRegistry();
- Map<String, CFoldingStructureProviderDescriptor> map= new HashMap<String, CFoldingStructureProviderDescriptor>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ Map<String, CFoldingStructureProviderDescriptor> map = new HashMap<String, CFoldingStructureProviderDescriptor>();
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT);
- for (int i= 0; i < elements.length; i++) {
- CFoldingStructureProviderDescriptor desc= new CFoldingStructureProviderDescriptor(elements[i]);
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor(CUIPlugin.getPluginId(),
+ EXTENSION_POINT);
+ for (int i = 0; i < elements.length; i++) {
+ CFoldingStructureProviderDescriptor desc = new CFoldingStructureProviderDescriptor(elements[i]);
map.put(desc.getId(), desc);
}
-
- synchronized(this) {
- fDescriptors= Collections.unmodifiableMap(map);
+
+ synchronized (this) {
+ fDescriptors = Collections.unmodifiableMap(map);
}
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java
index 9068363b2ba..1de4d6ce42f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java
@@ -46,16 +46,17 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
private IPreferenceStore fStore;
protected OverlayPreferenceStore fOverlayStore;
private OverlayKey[] fKeys;
- protected Map<Button, String> fCheckBoxes= new HashMap<Button, String>();
+ protected Map<Button, String> fCheckBoxes = new HashMap<Button, String>();
- private SelectionListener fCheckBoxListener= new SelectionListener() {
+ private SelectionListener fCheckBoxListener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
- String key= fCheckBoxes.get(button);
+ Button button = (Button) e.widget;
+ String key = fCheckBoxes.get(button);
fOverlayStore.setValue(key, button.getSelection());
updateEnablement(key);
}
@@ -65,28 +66,38 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
private Button fNonDocCommentsFoldingCheckBox;
private Button fHeaderCommentsFoldingCheckBox;
-
public DefaultCFoldingPreferenceBlock() {
- fStore= CUIPlugin.getDefault().getPreferenceStore();
- fKeys= createKeys();
- fOverlayStore= new OverlayPreferenceStore(fStore, fKeys);
+ fStore = CUIPlugin.getDefault().getPreferenceStore();
+ fKeys = createKeys();
+ fOverlayStore = new OverlayPreferenceStore(fStore, fKeys);
}
-
+
private OverlayKey[] createKeys() {
- ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_MACROS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_METHODS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_STRUCTURES));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_COMMENTS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_DOC_COMMENTS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_NON_DOC_COMMENTS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_HEADERS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_STATEMENTS));
-
+ ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
+
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_MACROS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_FUNCTIONS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_METHODS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_STRUCTURES));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_COMMENTS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_DOC_COMMENTS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_NON_DOC_COMMENTS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_HEADERS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+ PreferenceConstants.EDITOR_FOLDING_STATEMENTS));
+
return overlayKeys.toArray(new OverlayKey[overlayKeys.size()]);
}
@@ -97,53 +108,65 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
public Control createControl(Composite composite) {
fOverlayStore.load();
fOverlayStore.start();
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout(1, true);
- layout.verticalSpacing= 3;
- layout.marginWidth= 0;
+
+ Composite inner = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout(1, true);
+ layout.verticalSpacing = 3;
+ layout.marginWidth = 0;
inner.setLayout(layout);
- addCheckBox(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_preprocessor_enabled, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, 1);
- addCheckBox(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_statements_enabled, PreferenceConstants.EDITOR_FOLDING_STATEMENTS, 1);
+ addCheckBox(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_preprocessor_enabled,
+ PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, 1);
+ addCheckBox(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_statements_enabled,
+ PreferenceConstants.EDITOR_FOLDING_STATEMENTS, 1);
ControlFactory.createEmptySpace(inner);
- Composite group= ControlFactory.createGroup(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_title, 1);
-
- addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_macros, PreferenceConstants.EDITOR_FOLDING_MACROS, 0);
- addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_functions, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS, 0);
- addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_methods, PreferenceConstants.EDITOR_FOLDING_METHODS, 0);
- addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_structures, PreferenceConstants.EDITOR_FOLDING_STRUCTURES, 0);
- addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_comments, PreferenceConstants.EDITOR_FOLDING_COMMENTS, 0);
- fDocCommentsFoldingCheckBox = addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_doc_comments, PreferenceConstants.EDITOR_FOLDING_DOC_COMMENTS, 20);
- fNonDocCommentsFoldingCheckBox = addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_non_doc_comments, PreferenceConstants.EDITOR_FOLDING_NON_DOC_COMMENTS, 20);
- fHeaderCommentsFoldingCheckBox = addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_headers, PreferenceConstants.EDITOR_FOLDING_HEADERS, 20);
- fInactiveCodeFoldingCheckBox= addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_inactive_code, PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, 0);
+ Composite group = ControlFactory.createGroup(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_title, 1);
+
+ addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_macros,
+ PreferenceConstants.EDITOR_FOLDING_MACROS, 0);
+ addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_functions,
+ PreferenceConstants.EDITOR_FOLDING_FUNCTIONS, 0);
+ addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_methods,
+ PreferenceConstants.EDITOR_FOLDING_METHODS, 0);
+ addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_structures,
+ PreferenceConstants.EDITOR_FOLDING_STRUCTURES, 0);
+ addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_comments,
+ PreferenceConstants.EDITOR_FOLDING_COMMENTS, 0);
+ fDocCommentsFoldingCheckBox = addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_doc_comments,
+ PreferenceConstants.EDITOR_FOLDING_DOC_COMMENTS, 20);
+ fNonDocCommentsFoldingCheckBox = addCheckBox(group,
+ FoldingMessages.DefaultCFoldingPreferenceBlock_non_doc_comments,
+ PreferenceConstants.EDITOR_FOLDING_NON_DOC_COMMENTS, 20);
+ fHeaderCommentsFoldingCheckBox = addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_headers,
+ PreferenceConstants.EDITOR_FOLDING_HEADERS, 20);
+ fInactiveCodeFoldingCheckBox = addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_inactive_code,
+ PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, 0);
return inner;
}
-
- private Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox= new Button(parent, SWT.CHECK);
+
+ private Button addCheckBox(Composite parent, String label, String key, int indentation) {
+ Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setText(label);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 1;
- gd.grabExcessVerticalSpace= false;
+
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent = indentation;
+ gd.horizontalSpan = 1;
+ gd.grabExcessVerticalSpace = false;
checkBox.setLayoutData(gd);
checkBox.addSelectionListener(fCheckBoxListener);
-
+
fCheckBoxes.put(checkBox, key);
-
+
return checkBox;
}
-
+
private void initializeFields() {
- Iterator<Button> it= fCheckBoxes.keySet().iterator();
+ Iterator<Button> it = fCheckBoxes.keySet().iterator();
while (it.hasNext()) {
- Button b= it.next();
- String key= fCheckBoxes.get(b);
+ Button b = it.next();
+ String key = fCheckBoxes.get(b);
b.setSelection(fOverlayStore.getBoolean(key));
updateEnablement(key);
}
@@ -169,8 +192,7 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
public void performOk() {
fOverlayStore.propagate();
}
-
-
+
/*
* @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#initialize()
*/
@@ -178,7 +200,7 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
public void initialize() {
initializeFields();
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#performDefaults()
*/
@@ -187,7 +209,7 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
fOverlayStore.loadDefaults();
initializeFields();
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#dispose()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java
index fbebce7e1f3..47e5b26dfc1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java
@@ -126,8 +126,8 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
shouldVisitDeclarations = true;
}
private final Stack<StatementRegion> fStatements;
- int fLevel= 0;
- Stack<String> fScope= new Stack<String>();
+ int fLevel = 0;
+ Stack<String> fScope = new Stack<String>();
private StatementVisitor(Stack<StatementRegion> statements) {
fStatements = statements;
@@ -145,12 +145,14 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (statement instanceof IASTIfStatement) {
IASTIfStatement ifstmt = (IASTIfStatement) statement;
fl = ifstmt.getFileLocation();
- if (fl==null) return PROCESS_CONTINUE;
- int ifOffset= fl.getNodeOffset();
+ if (fl == null)
+ return PROCESS_CONTINUE;
+ int ifOffset = fl.getNodeOffset();
IASTStatement thenStmt;
mr = createRegion();
thenStmt = ifstmt.getThenClause();
- if (thenStmt==null) return PROCESS_CONTINUE;
+ if (thenStmt == null)
+ return PROCESS_CONTINUE;
fl = thenStmt.getFileLocation();
mr.setLength(fl.getNodeOffset() + fl.getNodeLength() - ifOffset);
mr.setOffset(ifOffset);
@@ -181,23 +183,25 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (statement instanceof IASTDoStatement)
mr.inclusive = false;
if (statement instanceof IASTSwitchStatement) {
- IASTStatement switchstmt = ((IASTSwitchStatement)statement).getBody();
+ IASTStatement switchstmt = ((IASTSwitchStatement) statement).getBody();
if (switchstmt instanceof IASTCompoundStatement) {
- IASTStatement[] stmts = ((IASTCompoundStatement)switchstmt).getStatements();
+ IASTStatement[] stmts = ((IASTCompoundStatement) switchstmt).getStatements();
boolean pushedMR = false;
for (IASTStatement tmpstmt : stmts) {
StatementRegion tmpmr;
if (!(tmpstmt instanceof IASTCaseStatement || tmpstmt instanceof IASTDefaultStatement)) {
- if (!pushedMR) return PROCESS_SKIP;
+ if (!pushedMR)
+ return PROCESS_SKIP;
IASTFileLocation tmpfl = tmpstmt.getFileLocation();
tmpmr = fStatements.peek();
- tmpmr.setLength(tmpfl.getNodeLength()+tmpfl.getNodeOffset()-tmpmr.getOffset());
- if (tmpstmt instanceof IASTBreakStatement) pushedMR = false;
+ tmpmr.setLength(tmpfl.getNodeLength() + tmpfl.getNodeOffset() - tmpmr.getOffset());
+ if (tmpstmt instanceof IASTBreakStatement)
+ pushedMR = false;
continue;
}
IASTFileLocation tmpfl;
tmpmr = createRegion();
- tmpmr.level= fLevel+1;
+ tmpmr.level = fLevel + 1;
tmpmr.inclusive = true;
if (tmpstmt instanceof IASTCaseStatement) {
IASTCaseStatement casestmt = (IASTCaseStatement) tmpstmt;
@@ -207,7 +211,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
} else if (tmpstmt instanceof IASTDefaultStatement) {
IASTDefaultStatement defstmt = (IASTDefaultStatement) tmpstmt;
tmpfl = defstmt.getFileLocation();
- tmpmr.setOffset(tmpfl.getNodeOffset()+tmpfl.getNodeLength());
+ tmpmr.setOffset(tmpfl.getNodeOffset() + tmpfl.getNodeLength());
tmpmr.setLength(0);
}
fStatements.push(tmpmr);
@@ -215,10 +219,8 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
}
}
- if (statement instanceof IASTForStatement
- || statement instanceof IASTWhileStatement
- || statement instanceof IASTDoStatement
- || statement instanceof IASTSwitchStatement
+ if (statement instanceof IASTForStatement || statement instanceof IASTWhileStatement
+ || statement instanceof IASTDoStatement || statement instanceof IASTSwitchStatement
|| statement instanceof ICPPASTRangeBasedForStatement) {
fl = statement.getFileLocation();
mr.setLength(fl.getNodeLength());
@@ -243,10 +245,10 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (!declaration.isPartOfTranslationUnitFile())
return PROCESS_SKIP;// we neither need its descendants
if (declaration instanceof IASTFunctionDefinition) {
- final IASTFunctionDeclarator declarator = ((IASTFunctionDefinition)declaration).getDeclarator();
+ final IASTFunctionDeclarator declarator = ((IASTFunctionDefinition) declaration).getDeclarator();
if (declarator != null) {
fScope.push(new String(ASTQueries.findInnermostDeclarator(declarator).getName().toCharArray()));
- fLevel= 0;
+ fLevel = 0;
}
} else if (declaration instanceof IASTSimpleDeclaration) {
IASTDeclSpecifier declSpecifier = ((IASTSimpleDeclaration) declaration).getDeclSpecifier();
@@ -283,10 +285,10 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
private final class SelectionListener implements ISelectionChangedListener {
@Override
public void selectionChanged(SelectionChangedEvent event) {
- ISelection s= event.getSelection();
+ ISelection s = event.getSelection();
if (s instanceof ITextSelection) {
- ITextSelection selection= (ITextSelection)event.getSelection();
- fCursorPosition= selection.getOffset();
+ ITextSelection selection = (ITextSelection) event.getSelection();
+ fCursorPosition = selection.getOffset();
}
}
}
@@ -302,7 +304,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
*/
@Override
public void aboutToBeReconciled() {
-
+
}
/*
@@ -317,26 +319,26 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (fReconciling) {
return;
}
- fReconciling= true;
+ fReconciling = true;
}
try {
- final boolean initialReconcile= fInitialReconcilePending;
- fInitialReconcilePending= false;
- FoldingStructureComputationContext ctx= createContext(initialReconcile);
+ final boolean initialReconcile = fInitialReconcilePending;
+ fInitialReconcilePending = false;
+ FoldingStructureComputationContext ctx = createContext(initialReconcile);
if (ctx != null) {
if (initialReconcile || !hasSyntaxError(ast)) {
- ctx.fAST= ast;
+ ctx.fAST = ast;
}
update(ctx);
}
} finally {
- fReconciling= false;
+ fReconciling = false;
}
}
/**
* Test whether the given ast contains one or more syntax errors.
- *
+ *
* @param ast
* @return <code>true</code> if the ast contains a syntax error
*/
@@ -344,13 +346,13 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (ast == null) {
return false;
}
- IASTProblem[] problems= ast.getPreprocessorProblems();
+ IASTProblem[] problems = ast.getPreprocessorProblems();
for (IASTProblem problem : problems) {
if ((problem.getID() & (IProblem.SYNTAX_ERROR | IProblem.SCANNER_RELATED)) != 0) {
return true;
}
}
- problems= CPPVisitor.getProblems(ast);
+ problems = CPPVisitor.getProblems(ast);
for (IASTProblem problem : problems) {
if ((problem.getID() & (IProblem.SYNTAX_ERROR | IProblem.SCANNER_RELATED)) != 0) {
return true;
@@ -361,7 +363,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
-
/**
* A context that contains the information needed to compute the folding structure of an
* {@link ITranslationUnit}. Computed folding regions are collected via
@@ -374,27 +375,28 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
private ISourceReference fFirstType;
private boolean fHasHeaderComment;
- private LinkedHashMap<CProjectionAnnotation,Position> fMap= new LinkedHashMap<CProjectionAnnotation,Position>();
+ private LinkedHashMap<CProjectionAnnotation, Position> fMap = new LinkedHashMap<CProjectionAnnotation, Position>();
private IASTTranslationUnit fAST;
- FoldingStructureComputationContext(IDocument document, ProjectionAnnotationModel model, boolean allowCollapsing) {
+ FoldingStructureComputationContext(IDocument document, ProjectionAnnotationModel model,
+ boolean allowCollapsing) {
Assert.isNotNull(document);
Assert.isNotNull(model);
- fDocument= document;
- fModel= model;
- fAllowCollapsing= allowCollapsing;
+ fDocument = document;
+ fModel = model;
+ fAllowCollapsing = allowCollapsing;
}
-
+
void setFirstType(ISourceReference reference) {
if (hasFirstType())
throw new IllegalStateException();
- fFirstType= reference;
+ fFirstType = reference;
}
-
+
boolean hasFirstType() {
return fFirstType != null;
}
-
+
ISourceReference getFirstType() {
return fFirstType;
}
@@ -404,15 +406,15 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
void setHasHeaderComment() {
- fHasHeaderComment= true;
+ fHasHeaderComment = true;
}
-
+
/**
* Returns <code>true</code> if newly created folding regions may be collapsed,
* <code>false</code> if not. This is usually <code>false</code> when updating the
* folding structure while typing; it may be <code>true</code> when computing or restoring
* the initial folding structure.
- *
+ *
* @return <code>true</code> if newly created folding regions may be collapsed,
* <code>false</code> if not
*/
@@ -422,7 +424,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Returns the document which contains the code being folded.
- *
+ *
* @return the document which contains the code being folded
*/
IDocument getDocument() {
@@ -432,12 +434,12 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
ProjectionAnnotationModel getModel() {
return fModel;
}
-
+
/**
* Adds a projection (folding) region to this context. The created annotation / position
* pair will be added to the {@link ProjectionAnnotationModel} of the
* {@link ProjectionViewer} of the editor.
- *
+ *
* @param annotation the annotation to add
* @param position the corresponding position
*/
@@ -474,7 +476,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Returns <code>true</code> if comments should be collapsed.
- *
+ *
* @return <code>true</code> if comments should be collapsed
*/
public boolean collapseComments() {
@@ -483,7 +485,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Returns <code>true</code> if functions should be collapsed.
- *
+ *
* @return <code>true</code> if functions should be collapsed
*/
public boolean collapseFunctions() {
@@ -492,7 +494,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Returns <code>true</code> if macros should be collapsed.
- *
+ *
* @return <code>true</code> if macros should be collapsed
*/
public boolean collapseMacros() {
@@ -501,7 +503,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Returns <code>true</code> if methods should be collapsed.
- *
+ *
* @return <code>true</code> if methods should be collapsed
*/
public boolean collapseMethods() {
@@ -510,7 +512,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Returns <code>true</code> if structures should be collapsed.
- *
+ *
* @return <code>true</code> if structures should be collapsed
*/
public boolean collapseStructures() {
@@ -519,7 +521,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Returns <code>true</code> if inactive code should be collapsed.
- *
+ *
* @return <code>true</code> if inactive code should be collapsed
*/
public boolean collapseInactiveCode() {
@@ -533,77 +535,76 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
return fAST;
}
}
-
public static class CProjectionAnnotation extends ProjectionAnnotation {
- public final static int CMODEL= 0;
- public final static int COMMENT= 1;
- public final static int BRANCH= 2;
- public final static int STATEMENT= 3;
-
+ public final static int CMODEL = 0;
+ public final static int COMMENT = 1;
+ public final static int BRANCH = 2;
+ public final static int STATEMENT = 3;
+
private Object fKey;
private int fCategory;
-
+
public CProjectionAnnotation(boolean isCollapsed, Object key, boolean isComment) {
this(isCollapsed, key, isComment ? COMMENT : 0);
}
-
+
public CProjectionAnnotation(boolean isCollapsed, Object key, int category) {
super(isCollapsed);
- fKey= key;
- fCategory= category;
+ fKey = key;
+ fCategory = category;
}
-
+
public Object getElement() {
return fKey;
}
-
+
public void setElement(Object element) {
- fKey= element;
+ fKey = element;
}
-
+
public int getCategory() {
return fCategory;
}
-// public void setCategory(int category) {
-// fCategory = category;
-// }
-//
-// public boolean isComment() {
-// return fCategory == COMMENT;
-// }
-//
-// public void setIsComment(boolean isComment) {
-// fCategory= isComment ? COMMENT : 0;
-// }
+ // public void setCategory(int category) {
+ // fCategory = category;
+ // }
+ //
+ // public boolean isComment() {
+ // return fCategory == COMMENT;
+ // }
+ //
+ // public void setIsComment(boolean isComment) {
+ // fCategory= isComment ? COMMENT : 0;
+ // }
/*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "CProjectionAnnotation:\n" + //$NON-NLS-1$
- "\tkey: \t"+ fKey + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ "\tkey: \t" + fKey + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
"\tcollapsed: \t" + isCollapsed() + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
"\tcategory: \t" + getCategory() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
-
private static final class Tuple {
CProjectionAnnotation annotation;
Position position;
+
Tuple(CProjectionAnnotation annotation, Position position) {
- this.annotation= annotation;
- this.position= position;
+ this.annotation = annotation;
+ this.position = position;
}
}
private static final class Counter {
int fCount;
}
-
+
/**
* Projection position that will return two foldable regions: one folding away
* the region from after the '/*' to the beginning of the content, the other
@@ -619,30 +620,30 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
*/
@Override
public IRegion[] computeProjectionRegions(IDocument document) throws BadLocationException {
- DocumentCharacterIterator sequence= new DocumentCharacterIterator(document, offset, offset + length);
- int prefixEnd= 0;
- int contentStart= findFirstContent(sequence, prefixEnd);
+ DocumentCharacterIterator sequence = new DocumentCharacterIterator(document, offset, offset + length);
+ int prefixEnd = 0;
+ int contentStart = findFirstContent(sequence, prefixEnd);
- int firstLine= document.getLineOfOffset(offset + prefixEnd);
- int captionLine= document.getLineOfOffset(offset + contentStart);
- int lastLine= document.getLineOfOffset(offset + length);
+ int firstLine = document.getLineOfOffset(offset + prefixEnd);
+ int captionLine = document.getLineOfOffset(offset + contentStart);
+ int lastLine = document.getLineOfOffset(offset + length);
Assert.isTrue(firstLine <= captionLine, "first folded line is greater than the caption line"); //$NON-NLS-1$
Assert.isTrue(captionLine <= lastLine, "caption line is greater than the last folded line"); //$NON-NLS-1$
IRegion preRegion;
if (firstLine < captionLine) {
- int preOffset= document.getLineOffset(firstLine);
- IRegion preEndLineInfo= document.getLineInformation(captionLine);
- int preEnd= preEndLineInfo.getOffset();
- preRegion= new Region(preOffset, preEnd - preOffset);
+ int preOffset = document.getLineOffset(firstLine);
+ IRegion preEndLineInfo = document.getLineInformation(captionLine);
+ int preEnd = preEndLineInfo.getOffset();
+ preRegion = new Region(preOffset, preEnd - preOffset);
} else {
- preRegion= null;
+ preRegion = null;
}
if (captionLine < lastLine) {
- int postOffset= document.getLineOffset(captionLine + 1);
- IRegion postRegion= new Region(postOffset, offset + length - postOffset);
+ int postOffset = document.getLineOffset(captionLine + 1);
+ IRegion postRegion = new Region(postOffset, offset + length - postOffset);
if (preRegion == null)
return new IRegion[] { postRegion };
@@ -665,8 +666,8 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* be found
*/
private int findFirstContent(final CharSequence content, int prefixEnd) {
- int lenght= content.length();
- for (int i= prefixEnd; i < lenght; i++) {
+ int lenght = content.length();
+ for (int i = prefixEnd; i < lenght; i++) {
if (Character.isUnicodeIdentifierPart(content.charAt(i)))
return i;
}
@@ -678,7 +679,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
*/
@Override
public int computeCaptionOffset(IDocument document) {
- DocumentCharacterIterator sequence= new DocumentCharacterIterator(document, offset, offset + length);
+ DocumentCharacterIterator sequence = new DocumentCharacterIterator(document, offset, offset + length);
return findFirstContent(sequence, 0);
}
}
@@ -695,20 +696,20 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
public CElementPosition(int offset, int length, ICElement element) {
super(offset, length);
Assert.isNotNull(element);
- fElement= element;
+ fElement = element;
}
-
+
public void setElement(ICElement member) {
Assert.isNotNull(member);
- fElement= member;
+ fElement = member;
}
-
+
/*
* @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeFoldingRegions(org.eclipse.jface.text.IDocument)
*/
@Override
public IRegion[] computeProjectionRegions(IDocument document) throws BadLocationException {
- int captionOffset= offset;
+ int captionOffset = offset;
try {
/* The member's name range may not be correct. However,
* reconciling would trigger another element delta which would
@@ -716,42 +717,42 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* assume that the name range is correct, but double check the
* received lines below. */
if (fElement instanceof ISourceReference) {
- ISourceRange sourceRange= ((ISourceReference) fElement).getSourceRange();
+ ISourceRange sourceRange = ((ISourceReference) fElement).getSourceRange();
if (sourceRange != null) {
// Use end of name range for the caption offset
// in case a qualified name is split on multiple lines (bug 248613).
- captionOffset= sourceRange.getIdStartPos() + sourceRange.getIdLength() - 1;
+ captionOffset = sourceRange.getIdStartPos() + sourceRange.getIdLength() - 1;
}
}
} catch (CModelException e) {
// ignore and use default
}
- int firstLine= document.getLineOfOffset(offset);
- int captionLine= document.getLineOfOffset(captionOffset);
- int lastLine= document.getLineOfOffset(offset + length);
+ int firstLine = document.getLineOfOffset(offset);
+ int captionLine = document.getLineOfOffset(captionOffset);
+ int lastLine = document.getLineOfOffset(offset + length);
/* see comment above - adjust the caption line to be inside the
* entire folded region, and rely on later element deltas to correct
* the name range. */
if (captionLine < firstLine)
- captionLine= firstLine;
+ captionLine = firstLine;
if (captionLine > lastLine)
- captionLine= lastLine;
+ captionLine = lastLine;
IRegion preRegion;
if (firstLine < captionLine) {
- int preOffset= document.getLineOffset(firstLine);
- IRegion preEndLineInfo= document.getLineInformation(captionLine);
- int preEnd= preEndLineInfo.getOffset();
- preRegion= new Region(preOffset, preEnd - preOffset);
+ int preOffset = document.getLineOffset(firstLine);
+ IRegion preEndLineInfo = document.getLineInformation(captionLine);
+ int preEnd = preEndLineInfo.getOffset();
+ preRegion = new Region(preOffset, preEnd - preOffset);
} else {
- preRegion= null;
+ preRegion = null;
}
if (captionLine < lastLine) {
- int postOffset= document.getLineOffset(captionLine + 1);
- IRegion postRegion= new Region(postOffset, offset + length - postOffset);
+ int postOffset = document.getLineOffset(captionLine + 1);
+ IRegion postRegion = new Region(postOffset, offset + length - postOffset);
if (preRegion == null)
return new IRegion[] { postRegion };
@@ -770,15 +771,15 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
*/
@Override
public int computeCaptionOffset(IDocument document) throws BadLocationException {
- int captionOffset= offset;
+ int captionOffset = offset;
try {
// need a reconcile here?
if (fElement instanceof ISourceReference) {
- ISourceRange sourceRange= ((ISourceReference) fElement).getSourceRange();
+ ISourceRange sourceRange = ((ISourceReference) fElement).getSourceRange();
if (sourceRange != null) {
- captionOffset= sourceRange.getIdStartPos() + sourceRange.getIdLength() - 1;
+ captionOffset = sourceRange.getIdStartPos() + sourceRange.getIdLength() - 1;
if (captionOffset < offset) {
- captionOffset= offset;
+ captionOffset = offset;
}
}
}
@@ -790,7 +791,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
}
-
+
/**
* Internal projection listener.
*/
@@ -799,25 +800,25 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Registers the listener with the viewer.
- *
+ *
* @param viewer the viewer to register a listener with
*/
public ProjectionListener(ProjectionViewer viewer) {
Assert.isLegal(viewer != null);
- fViewer= viewer;
+ fViewer = viewer;
fViewer.addProjectionListener(this);
}
-
+
/**
* Disposes of this listener and removes the projection listener from the viewer.
*/
public void dispose() {
if (fViewer != null) {
fViewer.removeProjectionListener(this);
- fViewer= null;
+ fViewer = null;
}
}
-
+
/*
* @see org.eclipse.jface.text.source.projection.IProjectionListener#projectionEnabled()
*/
@@ -843,6 +844,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
ModifiableRegion() {
super();
}
+
ModifiableRegion(int offset, int length) {
super(offset, length);
}
@@ -863,8 +865,8 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
Branch(int offset, int length, boolean taken, String key) {
super(offset, length);
- fTaken= taken;
- fCondition= key;
+ fTaken = taken;
+ fCondition = key;
}
public void setEndOffset(int endOffset) {
@@ -876,39 +878,39 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
public void setInclusive(boolean inclusive) {
- fInclusive= inclusive;
+ fInclusive = inclusive;
}
}
- private final static boolean DEBUG= Boolean.parseBoolean(Platform.getDebugOption("org.eclipse.cdt.ui/debug/folding")); //$NON-NLS-1$
+ private final static boolean DEBUG = Boolean
+ .parseBoolean(Platform.getDebugOption("org.eclipse.cdt.ui/debug/folding")); //$NON-NLS-1$
private ITextEditor fEditor;
private ProjectionListener fProjectionListener;
protected ICElement fInput;
-
- private boolean fCollapseHeaderComments= true;
- private boolean fCollapseComments= false;
- private boolean fCollapseDocComments= false;
- private boolean fCollapseNonDocComments= false;
- private boolean fCollapseMacros= false;
- private boolean fCollapseFunctions= true;
- private boolean fCollapseStructures= true;
- private boolean fCollapseMethods= false;
- private boolean fCollapseInactiveCode= true;
-
- private int fMinCommentLines= 1;
- private boolean fPreprocessorBranchFoldingEnabled= true;
- private boolean fStatementsFoldingEnabled= false;
- private boolean fCommentFoldingEnabled= true;
+
+ private boolean fCollapseHeaderComments = true;
+ private boolean fCollapseComments = false;
+ private boolean fCollapseDocComments = false;
+ private boolean fCollapseNonDocComments = false;
+ private boolean fCollapseMacros = false;
+ private boolean fCollapseFunctions = true;
+ private boolean fCollapseStructures = true;
+ private boolean fCollapseMethods = false;
+ private boolean fCollapseInactiveCode = true;
+
+ private int fMinCommentLines = 1;
+ private boolean fPreprocessorBranchFoldingEnabled = true;
+ private boolean fStatementsFoldingEnabled = false;
+ private boolean fCommentFoldingEnabled = true;
private ICReconcilingListener fReconilingListener;
- private volatile boolean fInitialReconcilePending= true;
+ private volatile boolean fInitialReconcilePending = true;
private int fCursorPosition;
private SelectionListener fSelectionListener;
-
/**
* Creates a new folding provider. It must be
* {@link #install(ITextEditor, ProjectionViewer) installed} on an editor/viewer pair before it
@@ -919,7 +921,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
*/
public DefaultCFoldingStructureProvider() {
}
-
+
/*
* @see org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider#install(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.source.projection.ProjectionViewer)
*/
@@ -929,10 +931,10 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
Assert.isLegal(viewer != null);
internalUninstall();
-
+
if (editor instanceof CEditor) {
- fEditor= editor;
- fProjectionListener= new ProjectionListener(viewer);
+ fEditor = editor;
+ fProjectionListener = new ProjectionListener(viewer);
}
}
@@ -943,7 +945,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
public void uninstall() {
internalUninstall();
}
-
+
/**
* Internal implementation of {@link #uninstall()}.
*/
@@ -951,20 +953,20 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (isInstalled()) {
handleProjectionDisabled();
fProjectionListener.dispose();
- fProjectionListener= null;
- fEditor= null;
+ fProjectionListener = null;
+ fEditor = null;
}
}
/**
* Returns <code>true</code> if the provider is installed, <code>false</code> otherwise.
- *
+ *
* @return <code>true</code> if the provider is installed, <code>false</code> otherwise
*/
protected final boolean isInstalled() {
return fEditor != null;
}
-
+
/**
* Called whenever projection is enabled, for example when the viewer issues a
* {@link IProjectionListener#projectionEnabled() projectionEnabled} message. When the provider
@@ -975,7 +977,8 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* </p>
*/
protected void handleProjectionEnabled() {
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.handleProjectionEnabled()"); //$NON-NLS-1$
+ if (DEBUG)
+ System.out.println("DefaultCFoldingStructureProvider.handleProjectionEnabled()"); //$NON-NLS-1$
// projectionEnabled messages are not always paired with projectionDisabled
// i.e. multiple enabled messages may be sent out.
// we have to make sure that we disable first when getting an enable
@@ -984,9 +987,9 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (fEditor instanceof CEditor) {
initialize();
- fReconilingListener= new FoldingStructureReconciler();
- ((CEditor)fEditor).addReconcileListener(fReconilingListener);
- fSelectionListener= new SelectionListener();
+ fReconilingListener = new FoldingStructureReconciler();
+ ((CEditor) fEditor).addReconcileListener(fReconilingListener);
+ fSelectionListener = new SelectionListener();
fEditor.getSelectionProvider().addSelectionChangedListener(fSelectionListener);
}
}
@@ -1003,12 +1006,12 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
*/
protected void handleProjectionDisabled() {
if (fReconilingListener != null) {
- ((CEditor)fEditor).removeReconcileListener(fReconilingListener);
- fReconilingListener= null;
+ ((CEditor) fEditor).removeReconcileListener(fReconilingListener);
+ fReconilingListener = null;
}
if (fSelectionListener != null) {
fEditor.getSelectionProvider().removeSelectionChangedListener(fSelectionListener);
- fSelectionListener= null;
+ fSelectionListener = null;
}
}
@@ -1017,116 +1020,127 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
*/
@Override
public final void initialize() {
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.initialize()"); //$NON-NLS-1$
- fInitialReconcilePending= true;
- fCursorPosition= -1;
+ if (DEBUG)
+ System.out.println("DefaultCFoldingStructureProvider.initialize()"); //$NON-NLS-1$
+ fInitialReconcilePending = true;
+ fCursorPosition = -1;
update(createInitialContext());
}
private FoldingStructureComputationContext createInitialContext() {
initializePreferences();
- fInput= getInputElement();
+ fInput = getInputElement();
if (fInput == null)
return null;
-
+
return createContext(true);
}
private FoldingStructureComputationContext createContext(boolean allowCollapse) {
if (!isInstalled())
return null;
- ProjectionAnnotationModel model= getModel();
+ ProjectionAnnotationModel model = getModel();
if (model == null)
return null;
- IDocument doc= getDocument();
+ IDocument doc = getDocument();
if (doc == null)
return null;
-
+
return new FoldingStructureComputationContext(doc, model, allowCollapse);
}
-
+
private ICElement getInputElement() {
if (fEditor instanceof CEditor) {
- return ((CEditor)fEditor).getInputCElement();
+ return ((CEditor) fEditor).getInputCElement();
}
return null;
}
private void initializePreferences() {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- fCollapseFunctions= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_FUNCTIONS);
- fCollapseStructures= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_STRUCTURES);
- fCollapseMacros= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_MACROS);
- fCollapseMethods= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_METHODS);
- fCollapseComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_COMMENTS);
- fCollapseDocComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_DOC_COMMENTS);
- fCollapseNonDocComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_NON_DOC_COMMENTS);
- fCollapseHeaderComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_HEADERS);
- fCollapseInactiveCode= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE);
- fPreprocessorBranchFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED);
- fStatementsFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_STATEMENTS);
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ fCollapseFunctions = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_FUNCTIONS);
+ fCollapseStructures = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_STRUCTURES);
+ fCollapseMacros = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_MACROS);
+ fCollapseMethods = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_METHODS);
+ fCollapseComments = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_COMMENTS);
+ fCollapseDocComments = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_DOC_COMMENTS);
+ fCollapseNonDocComments = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_NON_DOC_COMMENTS);
+ fCollapseHeaderComments = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_HEADERS);
+ fCollapseInactiveCode = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE);
+ fPreprocessorBranchFoldingEnabled = store
+ .getBoolean(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED);
+ fStatementsFoldingEnabled = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_STATEMENTS);
fCommentFoldingEnabled = true;
}
private void update(FoldingStructureComputationContext ctx) {
- if (ctx == null || !isConsistent(fInput))
+ if (ctx == null || !isConsistent(fInput))
return;
if (!fInitialReconcilePending && fSelectionListener != null) {
fEditor.getSelectionProvider().removeSelectionChangedListener(fSelectionListener);
- fSelectionListener= null;
+ fSelectionListener = null;
}
- Map<CProjectionAnnotation,Position> additions= new HashMap<CProjectionAnnotation,Position>();
- List<CProjectionAnnotation> deletions= new ArrayList<CProjectionAnnotation>();
- List<CProjectionAnnotation> updates= new ArrayList<CProjectionAnnotation>();
-
+ Map<CProjectionAnnotation, Position> additions = new HashMap<CProjectionAnnotation, Position>();
+ List<CProjectionAnnotation> deletions = new ArrayList<CProjectionAnnotation>();
+ List<CProjectionAnnotation> updates = new ArrayList<CProjectionAnnotation>();
+
computeFoldingStructure(ctx);
- Map<CProjectionAnnotation,Position> updated= ctx.fMap;
- Map<Object, List<Tuple>> previous= computeCurrentStructure(ctx);
+ Map<CProjectionAnnotation, Position> updated = ctx.fMap;
+ Map<Object, List<Tuple>> previous = computeCurrentStructure(ctx);
- Iterator<CProjectionAnnotation> e= updated.keySet().iterator();
+ Iterator<CProjectionAnnotation> e = updated.keySet().iterator();
while (e.hasNext()) {
- CProjectionAnnotation newAnnotation= e.next();
- Object key= newAnnotation.getElement();
- Position newPosition= updated.get(newAnnotation);
+ CProjectionAnnotation newAnnotation = e.next();
+ Object key = newAnnotation.getElement();
+ Position newPosition = updated.get(newAnnotation);
- List<Tuple> annotations= previous.get(key);
+ List<Tuple> annotations = previous.get(key);
if (annotations == null) {
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
+ if (DEBUG)
+ System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
additions.put(newAnnotation, newPosition);
} else {
- Iterator<Tuple> x= annotations.iterator();
- boolean matched= false;
+ Iterator<Tuple> x = annotations.iterator();
+ boolean matched = false;
while (x.hasNext()) {
- Tuple tuple= x.next();
- CProjectionAnnotation existingAnnotation= tuple.annotation;
- Position existingPosition= tuple.position;
+ Tuple tuple = x.next();
+ CProjectionAnnotation existingAnnotation = tuple.annotation;
+ Position existingPosition = tuple.position;
if (newAnnotation.getCategory() == existingAnnotation.getCategory()) {
- final boolean collapseChanged = ctx.allowCollapsing() && existingAnnotation.isCollapsed() != newAnnotation.isCollapsed();
+ final boolean collapseChanged = ctx.allowCollapsing()
+ && existingAnnotation.isCollapsed() != newAnnotation.isCollapsed();
if (existingPosition != null && (collapseChanged || !newPosition.equals(existingPosition))) {
existingPosition.setOffset(newPosition.getOffset());
existingPosition.setLength(newPosition.getLength());
if (collapseChanged) {
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() change annotation due to collapse state change " + newAnnotation); //$NON-NLS-1$
+ if (DEBUG)
+ System.out.println(
+ "DefaultCFoldingStructureProvider.update() change annotation due to collapse state change " //$NON-NLS-1$
+ + newAnnotation);
if (newAnnotation.isCollapsed())
existingAnnotation.markCollapsed();
else
existingAnnotation.markExpanded();
} else {
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() change annotation due to position change " + newAnnotation); //$NON-NLS-1$
+ if (DEBUG)
+ System.out.println(
+ "DefaultCFoldingStructureProvider.update() change annotation due to position change " //$NON-NLS-1$
+ + newAnnotation);
}
updates.add(existingAnnotation);
}
- matched= true;
+ matched = true;
x.remove();
break;
}
}
if (!matched) {
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
+ if (DEBUG)
+ System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
additions.put(newAnnotation, newPosition);
}
@@ -1135,26 +1149,29 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
}
- Iterator<List<Tuple>> e2= previous.values().iterator();
+ Iterator<List<Tuple>> e2 = previous.values().iterator();
while (e2.hasNext()) {
- List<Tuple> list= e2.next();
- int size= list.size();
- for (int i= 0; i < size; i++) {
- CProjectionAnnotation annotation= list.get(i).annotation;
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() deleted annotation " + annotation); //$NON-NLS-1$
+ List<Tuple> list = e2.next();
+ int size = list.size();
+ for (int i = 0; i < size; i++) {
+ CProjectionAnnotation annotation = list.get(i).annotation;
+ if (DEBUG)
+ System.out.println("DefaultCFoldingStructureProvider.update() deleted annotation " + annotation); //$NON-NLS-1$
deletions.add(annotation);
}
}
match(deletions, additions, updates, ctx);
- Annotation[] removals= new Annotation[deletions.size()];
+ Annotation[] removals = new Annotation[deletions.size()];
deletions.toArray(removals);
- Annotation[] changes= new Annotation[updates.size()];
+ Annotation[] changes = new Annotation[updates.size()];
updates.toArray(changes);
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() "+removals.length+" deleted, "+additions.size()+" added, "+changes.length+" changed"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ if (DEBUG)
+ System.out.println("DefaultCFoldingStructureProvider.update() " + removals.length + " deleted, " //$NON-NLS-1$//$NON-NLS-2$
+ + additions.size() + " added, " + changes.length + " changed"); //$NON-NLS-1$ //$NON-NLS-2$
ctx.getModel().modifyAnnotations(removals, additions, changes);
- }
+ }
/**
* Matches deleted annotations to changed or added ones. A deleted
@@ -1164,45 +1181,48 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* result is that more annotations are changed and fewer get
* deleted/re-added.
*/
- private void match(List<CProjectionAnnotation> deletions, Map<CProjectionAnnotation,Position> additions,
+ private void match(List<CProjectionAnnotation> deletions, Map<CProjectionAnnotation, Position> additions,
List<CProjectionAnnotation> changes, FoldingStructureComputationContext ctx) {
if (deletions.isEmpty() || (additions.isEmpty() && changes.isEmpty()))
return;
- List<CProjectionAnnotation> newDeletions= new ArrayList<CProjectionAnnotation>();
- List<CProjectionAnnotation> newChanges= new ArrayList<CProjectionAnnotation>();
+ List<CProjectionAnnotation> newDeletions = new ArrayList<CProjectionAnnotation>();
+ List<CProjectionAnnotation> newChanges = new ArrayList<CProjectionAnnotation>();
- Iterator<CProjectionAnnotation> deletionIterator= deletions.iterator();
+ Iterator<CProjectionAnnotation> deletionIterator = deletions.iterator();
while (deletionIterator.hasNext()) {
- CProjectionAnnotation deleted= deletionIterator.next();
- Position deletedPosition= ctx.getModel().getPosition(deleted);
+ CProjectionAnnotation deleted = deletionIterator.next();
+ Position deletedPosition = ctx.getModel().getPosition(deleted);
if (deletedPosition == null || deletedPosition.length < 5)
continue;
-
- Tuple deletedTuple= new Tuple(deleted, deletedPosition);
- Tuple match= findMatch(deletedTuple, changes, null, ctx);
- boolean addToDeletions= true;
+ Tuple deletedTuple = new Tuple(deleted, deletedPosition);
+
+ Tuple match = findMatch(deletedTuple, changes, null, ctx);
+ boolean addToDeletions = true;
if (match == null) {
- match= findMatch(deletedTuple, additions.keySet(), additions, ctx);
- addToDeletions= false;
+ match = findMatch(deletedTuple, additions.keySet(), additions, ctx);
+ addToDeletions = false;
}
-
+
if (match != null) {
- Object element= match.annotation.getElement();
+ Object element = match.annotation.getElement();
deleted.setElement(element);
deletedPosition.setLength(match.position.getLength());
if (deletedPosition instanceof CElementPosition && element instanceof ICElement) {
- CElementPosition cep= (CElementPosition) deletedPosition;
+ CElementPosition cep = (CElementPosition) deletedPosition;
cep.setElement((ICElement) element);
}
deletionIterator.remove();
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() changed annotation " + deleted); //$NON-NLS-1$
+ if (DEBUG)
+ System.out.println("DefaultCFoldingStructureProvider.update() changed annotation " + deleted); //$NON-NLS-1$
newChanges.add(deleted);
if (addToDeletions) {
- if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() deleted annotation " + match.annotation); //$NON-NLS-1$
+ if (DEBUG)
+ System.out.println(
+ "DefaultCFoldingStructureProvider.update() deleted annotation " + match.annotation); //$NON-NLS-1$
newDeletions.add(match.annotation);
}
}
@@ -1227,7 +1247,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* If a match is found, the annotation gets removed from
* <code>annotations</code>.
* </p>
- *
+ *
* @param tuple the tuple for which we want to find a match
* @param annotations collection of
* <code>CProjectionAnnotation</code>
@@ -1235,12 +1255,14 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* or <code>null</code>
* @return a matching tuple or <code>null</code> for no match
*/
- private Tuple findMatch(Tuple tuple, Collection<CProjectionAnnotation> annotations, Map<CProjectionAnnotation,Position> positionMap, FoldingStructureComputationContext ctx) {
- Iterator<CProjectionAnnotation> it= annotations.iterator();
+ private Tuple findMatch(Tuple tuple, Collection<CProjectionAnnotation> annotations,
+ Map<CProjectionAnnotation, Position> positionMap, FoldingStructureComputationContext ctx) {
+ Iterator<CProjectionAnnotation> it = annotations.iterator();
while (it.hasNext()) {
- CProjectionAnnotation annotation= it.next();
+ CProjectionAnnotation annotation = it.next();
if (tuple.annotation.getCategory() == annotation.getCategory()) {
- Position position= positionMap == null ? ctx.getModel().getPosition(annotation) : positionMap.get(annotation);
+ Position position = positionMap == null ? ctx.getModel().getPosition(annotation)
+ : positionMap.get(annotation);
if (position == null)
continue;
@@ -1250,42 +1272,42 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
}
}
-
+
return null;
}
private Map<Object, List<Tuple>> computeCurrentStructure(FoldingStructureComputationContext ctx) {
- boolean includeBranches= fPreprocessorBranchFoldingEnabled && ctx.fAST != null;
- boolean includeStmts= fStatementsFoldingEnabled && ctx.fAST != null;
- boolean includeCModel= ctx.fAST != null || !(fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled);
- Map<Object, List<Tuple>> map= new HashMap<Object, List<Tuple>>();
- ProjectionAnnotationModel model= ctx.getModel();
- Iterator<?> e= model.getAnnotationIterator();
+ boolean includeBranches = fPreprocessorBranchFoldingEnabled && ctx.fAST != null;
+ boolean includeStmts = fStatementsFoldingEnabled && ctx.fAST != null;
+ boolean includeCModel = ctx.fAST != null || !(fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled);
+ Map<Object, List<Tuple>> map = new HashMap<Object, List<Tuple>>();
+ ProjectionAnnotationModel model = ctx.getModel();
+ Iterator<?> e = model.getAnnotationIterator();
while (e.hasNext()) {
- Object annotation= e.next();
+ Object annotation = e.next();
if (annotation instanceof CProjectionAnnotation) {
- CProjectionAnnotation cAnnotation= (CProjectionAnnotation) annotation;
+ CProjectionAnnotation cAnnotation = (CProjectionAnnotation) annotation;
final boolean include;
switch (cAnnotation.getCategory()) {
case CProjectionAnnotation.BRANCH:
- include= includeBranches;
+ include = includeBranches;
break;
case CProjectionAnnotation.STATEMENT:
- include= includeStmts;
+ include = includeStmts;
break;
case CProjectionAnnotation.CMODEL:
- include= includeCModel;
+ include = includeCModel;
break;
default:
- include= true;
+ include = true;
break;
}
- Position position= model.getPosition(cAnnotation);
+ Position position = model.getPosition(cAnnotation);
assert position != null;
if (include || position.length < 5) {
- List<Tuple> list= map.get(cAnnotation.getElement());
+ List<Tuple> list = map.get(cAnnotation.getElement());
if (list == null) {
- list= new ArrayList<Tuple>(2);
+ list = new ArrayList<Tuple>(2);
map.put(cAnnotation.getElement(), list);
}
list.add(new Tuple(cAnnotation, position));
@@ -1293,42 +1315,43 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
}
- Comparator<Tuple> comparator= new Comparator<Tuple>() {
+ Comparator<Tuple> comparator = new Comparator<Tuple>() {
@Override
public int compare(Tuple t1, Tuple t2) {
return t1.position.getOffset() - t2.position.getOffset();
}
};
- for(List<Tuple> list : map.values()) {
+ for (List<Tuple> list : map.values()) {
Collections.sort(list, comparator);
}
return map;
}
-
+
private void computeFoldingStructure(final FoldingStructureComputationContext ctx) {
if (fCommentFoldingEnabled) {
// compute comment positions from partitioning
try {
- IDocument doc= ctx.getDocument();
- ITypedRegion[] partitions = TextUtilities.computePartitioning(doc, ICPartitions.C_PARTITIONING, 0, doc.getLength(), false);
+ IDocument doc = ctx.getDocument();
+ ITypedRegion[] partitions = TextUtilities.computePartitioning(doc, ICPartitions.C_PARTITIONING, 0,
+ doc.getLength(), false);
computeFoldingStructure(partitions, ctx);
} catch (BadLocationException e) {
// ignore
}
}
- final boolean needAST= fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled;
+ final boolean needAST = fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled;
if (needAST) {
- IASTTranslationUnit ast= ctx.getAST();
+ IASTTranslationUnit ast = ctx.getAST();
if (ast != null) {
computeFoldingStructure(ast, ctx);
} else if (fInitialReconcilePending) {
- final WAIT_FLAG waitFlag= ASTProvider.WAIT_ACTIVE_ONLY;
- final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
- IStatus status= astProvider.runOnAST(getInputElement(), waitFlag, null, new ASTCache.ASTRunnable() {
+ final WAIT_FLAG waitFlag = ASTProvider.WAIT_ACTIVE_ONLY;
+ final ASTProvider astProvider = CUIPlugin.getDefault().getASTProvider();
+ IStatus status = astProvider.runOnAST(getInputElement(), waitFlag, null, new ASTCache.ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
if (ast != null) {
- ctx.fAST= ast;
+ ctx.fAST = ast;
computeFoldingStructure(ast, ctx);
}
return Status.OK_STATUS;
@@ -1340,8 +1363,8 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
}
if (!needAST || ctx.getAST() != null) {
- fInitialReconcilePending= false;
- IParent parent= (IParent) fInput;
+ fInitialReconcilePending = false;
+ IParent parent = (IParent) fInput;
try {
computeFoldingStructure(parent.getChildren(), ctx);
} catch (CModelException x) {
@@ -1352,7 +1375,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
static boolean isConsistent(ICElement element) {
if (element instanceof ITranslationUnit) {
try {
- return ((ITranslationUnit)element).isConsistent();
+ return ((ITranslationUnit) element).isConsistent();
} catch (CModelException exc) {
}
}
@@ -1367,28 +1390,29 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
public final String function;
public int level;
public boolean inclusive;
+
public StatementRegion(String function, int level) {
- this.function= function;
- this.level= level;
+ this.function = function;
+ this.level = level;
}
}
/**
* Computes folding structure of statements for the given AST.
- *
+ *
* @param ast
* @param ctx
*/
private void computeStatementFoldingStructure(IASTTranslationUnit ast, FoldingStructureComputationContext ctx) {
- final Stack<StatementRegion> iral= new Stack<StatementRegion>();
+ final Stack<StatementRegion> iral = new Stack<StatementRegion>();
ast.accept(new StatementVisitor(iral));
while (!iral.empty()) {
StatementRegion mr = iral.pop();
- IRegion aligned = alignRegion(mr, ctx,mr.inclusive);
+ IRegion aligned = alignRegion(mr, ctx, mr.inclusive);
if (aligned != null) {
- Position alignedPos= new Position(aligned.getOffset(), aligned.getLength());
- ctx.addProjectionRange(new CProjectionAnnotation(
- false, mr.function + mr.level + computeKey(mr, ctx), CProjectionAnnotation.STATEMENT), alignedPos);
+ Position alignedPos = new Position(aligned.getOffset(), aligned.getLength());
+ ctx.addProjectionRange(new CProjectionAnnotation(false, mr.function + mr.level + computeKey(mr, ctx),
+ CProjectionAnnotation.STATEMENT), alignedPos);
}
}
}
@@ -1398,7 +1422,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* computes the folding structure for: preprocessor branches for the given
* AST. Also, it computes statements folding (if/else do/while for and
* switch)
- *
+ *
* @param ast
* @param ctx
*/
@@ -1420,7 +1444,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Computes folding structure for preprocessor branches for the given AST.
- *
+ *
* @param ast
* @param ctx
*/
@@ -1435,26 +1459,29 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
// preprocessor directive is from a different file
continue;
}
- IASTNodeLocation stmtLocation= statement.getFileLocation();
+ IASTNodeLocation stmtLocation = statement.getFileLocation();
if (stmtLocation == null) {
continue;
}
if (statement instanceof IASTPreprocessorIfStatement) {
- IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement)statement;
- branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifStmt.taken(), "#if " + new String(ifStmt.getCondition()))); //$NON-NLS-1$
+ IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement) statement;
+ branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifStmt.taken(),
+ "#if " + new String(ifStmt.getCondition()))); //$NON-NLS-1$
} else if (statement instanceof IASTPreprocessorIfdefStatement) {
- IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement)statement;
- branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifdefStmt.taken(), "#ifdef " + new String(ifdefStmt.getCondition()))); //$NON-NLS-1$
+ IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement) statement;
+ branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifdefStmt.taken(),
+ "#ifdef " + new String(ifdefStmt.getCondition()))); //$NON-NLS-1$
} else if (statement instanceof IASTPreprocessorIfndefStatement) {
- IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement)statement;
- branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifndefStmt.taken(), "#ifndef " + new String(ifndefStmt.getCondition()))); //$NON-NLS-1$
+ IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement) statement;
+ branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifndefStmt.taken(),
+ "#ifndef " + new String(ifndefStmt.getCondition()))); //$NON-NLS-1$
} else if (statement instanceof IASTPreprocessorElseStatement) {
if (branchStack.isEmpty()) {
// #else without #if
continue;
}
- Branch branch= branchStack.pop();
- IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement)statement;
+ Branch branch = branchStack.pop();
+ IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement) statement;
branchStack.push(new Branch(stmtLocation.getNodeOffset(), elseStmt.taken(), branch.fCondition));
branch.setEndOffset(stmtLocation.getNodeOffset());
branches.add(branch);
@@ -1463,7 +1490,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
// #elif without #if
continue;
}
- Branch branch= branchStack.pop();
+ Branch branch = branchStack.pop();
IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement) statement;
branchStack.push(new Branch(stmtLocation.getNodeOffset(), elifStmt.taken(), branch.fCondition));
branch.setEndOffset(stmtLocation.getNodeOffset());
@@ -1473,7 +1500,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
// #endif without #if
continue;
}
- Branch branch= branchStack.pop();
+ Branch branch = branchStack.pop();
branch.setEndOffset(stmtLocation.getNodeOffset() + stmtLocation.getNodeLength());
branch.setInclusive(true);
branches.add(branch);
@@ -1482,41 +1509,43 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (!branchStack.isEmpty()) {
// unterminated #if
- Branch branch= branchStack.pop();
+ Branch branch = branchStack.pop();
branch.setEndOffset(getDocument().getLength());
branch.setInclusive(true);
branches.add(branch);
}
-
- Map<String, Counter> keys= new HashMap<String, Counter>(branches.size());
+
+ Map<String, Counter> keys = new HashMap<String, Counter>(branches.size());
for (Branch branch : branches) {
IRegion aligned = alignRegion(branch, ctx, branch.fInclusive);
if (aligned != null) {
- Position alignedPos= new Position(aligned.getOffset(), aligned.getLength());
- final boolean collapse= !branch.taken() && ctx.collapseInactiveCode() && !alignedPos.includes(fCursorPosition);
+ Position alignedPos = new Position(aligned.getOffset(), aligned.getLength());
+ final boolean collapse = !branch.taken() && ctx.collapseInactiveCode()
+ && !alignedPos.includes(fCursorPosition);
// compute a stable key
String key = branch.fCondition;
- Counter counter= keys.get(key);
+ Counter counter = keys.get(key);
if (counter == null) {
keys.put(key, new Counter());
} else {
- key= Integer.toString(counter.fCount++) + key;
+ key = Integer.toString(counter.fCount++) + key;
}
- ctx.addProjectionRange(new CProjectionAnnotation(collapse, key, CProjectionAnnotation.BRANCH), alignedPos);
+ ctx.addProjectionRange(new CProjectionAnnotation(collapse, key, CProjectionAnnotation.BRANCH),
+ alignedPos);
}
}
}
/**
* Compute a key for recognizing an annotation based on the given position.
- *
+ *
* @param pos
* @param ctx
* @return a key to recognize an annotation position
*/
private Object computeKey(Position pos, FoldingStructureComputationContext ctx) {
try {
- final IDocument document= ctx.getDocument();
+ final IDocument document = ctx.getDocument();
return document.getLineOfOffset(pos.offset);
} catch (BadLocationException exc) {
return exc;
@@ -1525,45 +1554,51 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
/**
* Compute folding structure based on partioning information.
- *
+ *
* @param partitions array of document partitions
* @param ctx the folding structure context
- * @throws BadLocationException
+ * @throws BadLocationException
*/
- private void computeFoldingStructure(ITypedRegion[] partitions, FoldingStructureComputationContext ctx) throws BadLocationException {
+ private void computeFoldingStructure(ITypedRegion[] partitions, FoldingStructureComputationContext ctx)
+ throws BadLocationException {
boolean collapseDoc = ctx.collapseDocComments();
boolean collapseNonDoc = ctx.collapseNonDocComments();
- IDocument doc= ctx.getDocument();
+ IDocument doc = ctx.getDocument();
int startLine = -1;
int endLine = -1;
boolean startLineIsDocComment = false;
- List<Tuple> comments= new ArrayList<Tuple>();
+ List<Tuple> comments = new ArrayList<Tuple>();
ModifiableRegion commentRange = new ModifiableRegion();
for (ITypedRegion partition : partitions) {
- boolean singleLine= false;
+ boolean singleLine = false;
boolean collapse = collapseNonDoc;
if (ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())
- || ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(partition.getType())) {
+ || ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(partition.getType())) {
collapse = collapseDoc;
}
if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType())
- || ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
- Position position= createCommentPosition(alignRegion(partition, ctx, true));
+ || ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
+ Position position = createCommentPosition(alignRegion(partition, ctx, true));
if (position != null) {
if (startLine >= 0 && endLine - startLine >= fMinCommentLines) {
Position projection = createCommentPosition(alignRegion(commentRange, ctx, true));
if (projection != null) {
boolean collapseLast = startLineIsDocComment ? collapseDoc : collapseNonDoc;
- comments.add(new Tuple(new CProjectionAnnotation(collapseLast, doc.get(projection.offset, Math.min(16, projection.length)), true), projection));
+ comments.add(new Tuple(
+ new CProjectionAnnotation(collapseLast,
+ doc.get(projection.offset, Math.min(16, projection.length)), true),
+ projection));
}
- startLine= -1;
+ startLine = -1;
}
- comments.add(new Tuple(new CProjectionAnnotation(collapse, doc.get(position.offset, Math.min(16, position.length)), true), position));
+ comments.add(new Tuple(new CProjectionAnnotation(collapse,
+ doc.get(position.offset, Math.min(16, position.length)), true), position));
} else {
- singleLine= true;
+ singleLine = true;
}
} else {
- singleLine= ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType()) || ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(partition.getType());
+ singleLine = ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType())
+ || ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(partition.getType());
}
if (singleLine) {
// if comment starts at column 0 and spans only one line
@@ -1581,7 +1616,10 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
Position projection = createCommentPosition(alignRegion(commentRange, ctx, true));
if (projection != null) {
boolean collapseLast = startLineIsDocComment ? collapseDoc : collapseNonDoc;
- comments.add(new Tuple(new CProjectionAnnotation(collapseLast, doc.get(projection.offset, Math.min(16, projection.length)), true), projection));
+ comments.add(new Tuple(
+ new CProjectionAnnotation(collapseLast,
+ doc.get(projection.offset, Math.min(16, projection.length)), true),
+ projection));
}
}
startLine = lineNr;
@@ -1592,7 +1630,8 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
commentRange.length = lineRegion.getLength();
} else {
endLine = lineNr;
- int delta = lineRegion.getOffset() + lineRegion.getLength() - commentRange.offset - commentRange.length;
+ int delta = lineRegion.getOffset() + lineRegion.getLength() - commentRange.offset
+ - commentRange.length;
commentRange.length += delta;
}
}
@@ -1601,7 +1640,8 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
Position projection = createCommentPosition(alignRegion(commentRange, ctx, true));
if (projection != null) {
boolean collapseLast = startLineIsDocComment ? collapseDoc : collapseNonDoc;
- comments.add(new Tuple(new CProjectionAnnotation(collapseLast, doc.get(projection.offset, Math.min(16, projection.length)), true), projection));
+ comments.add(new Tuple(new CProjectionAnnotation(collapseLast,
+ doc.get(projection.offset, Math.min(16, projection.length)), true), projection));
}
}
if (!comments.isEmpty()) {
@@ -1624,12 +1664,13 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
}
- private void computeFoldingStructure(ICElement[] elements, FoldingStructureComputationContext ctx) throws CModelException {
+ private void computeFoldingStructure(ICElement[] elements, FoldingStructureComputationContext ctx)
+ throws CModelException {
for (ICElement element : elements) {
computeFoldingStructure(element, ctx);
if (element instanceof IParent) {
- IParent parent= (IParent) element;
+ IParent parent = (IParent) element;
computeFoldingStructure(parent.getChildren(), ctx);
}
}
@@ -1650,13 +1691,13 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* <li>multiline macro definitions</li>
* </ul>
* </p>
- *
+ *
* @param element the C element to compute the folding structure for
* @param ctx the computation context
*/
protected void computeFoldingStructure(ICElement element, FoldingStructureComputationContext ctx) {
- boolean collapse= false;
+ boolean collapse = false;
switch (element.getElementType()) {
case ICElement.C_STRUCT:
@@ -1666,18 +1707,18 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
case ICElement.C_TEMPLATE_STRUCT:
case ICElement.C_TEMPLATE_CLASS:
case ICElement.C_TEMPLATE_UNION:
- collapse= ctx.collapseStructures();
+ collapse = ctx.collapseStructures();
break;
case ICElement.C_MACRO:
- collapse= ctx.collapseMacros();
+ collapse = ctx.collapseMacros();
break;
case ICElement.C_FUNCTION:
case ICElement.C_TEMPLATE_FUNCTION:
- collapse= ctx.collapseFunctions();
+ collapse = ctx.collapseFunctions();
break;
case ICElement.C_METHOD:
case ICElement.C_TEMPLATE_METHOD:
- collapse= ctx.collapseMethods();
+ collapse = ctx.collapseMethods();
break;
case ICElement.C_NAMESPACE:
break;
@@ -1685,13 +1726,13 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
return;
}
- IRegion[] regions= computeProjectionRanges((ISourceReference) element, ctx);
+ IRegion[] regions = computeProjectionRanges((ISourceReference) element, ctx);
if (regions.length > 0) {
- IRegion normalized= alignRegion(regions[regions.length - 1], ctx, true);
+ IRegion normalized = alignRegion(regions[regions.length - 1], ctx, true);
if (normalized != null) {
- Position position= createElementPosition(normalized, element);
+ Position position = createElementPosition(normalized, element);
if (position != null) {
- collapse= collapse && !position.includes(fCursorPosition);
+ collapse = collapse && !position.includes(fCursorPosition);
ctx.addProjectionRange(new CProjectionAnnotation(collapse, element, false), position);
}
}
@@ -1707,17 +1748,16 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* element that implements the source reference. Any preceding regions describe comments
* of that element.
* </p>
- *
+ *
* @param reference a C element that is a source reference
* @param ctx the folding context
* @return the regions to be folded
*/
- protected final IRegion[] computeProjectionRanges(ISourceReference reference, FoldingStructureComputationContext ctx) {
+ protected final IRegion[] computeProjectionRanges(ISourceReference reference,
+ FoldingStructureComputationContext ctx) {
try {
- ISourceRange range= reference.getSourceRange();
- return new IRegion[] {
- new Region(range.getStartPos(), range.getLength())
- };
+ ISourceRange range = reference.getSourceRange();
+ return new IRegion[] { new Region(range.getStartPos(), range.getLength()) };
} catch (CModelException e) {
}
@@ -1728,7 +1768,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* Creates a comment folding position from an
* {@link #alignRegion(IRegion, DefaultCFoldingStructureProvider.FoldingStructureComputationContext, boolean) aligned}
* region.
- *
+ *
* @param aligned an aligned region
* @return a folding position corresponding to <code>aligned</code>
*/
@@ -1743,7 +1783,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* Creates a folding position that remembers its element from an
* {@link #alignRegion(IRegion, DefaultCFoldingStructureProvider.FoldingStructureComputationContext, boolean) aligned}
* region.
- *
+ *
* @param aligned an aligned region
* @param element the element to remember
* @return a folding position corresponding to <code>aligned</code>
@@ -1758,7 +1798,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* end of the document. <code>null</code> is returned if <code>region</code> is
* <code>null</code> itself or does not comprise at least one line delimiter, as a single line
* cannot be folded.
- *
+ *
* @param region the region to align, may be <code>null</code>
* @param ctx the folding context
* @return a region equal or greater than <code>region</code> that is aligned with line
@@ -1775,7 +1815,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
* end of the document. <code>null</code> is returned if <code>region</code> is
* <code>null</code> itself or does not comprise at least one line delimiter, as a single line
* cannot be folded.
- *
+ *
* @param region the region to align, may be <code>null</code>
* @param ctx the folding context
* @param inclusive include line of end offset
@@ -1786,40 +1826,40 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
protected final IRegion alignRegion(IRegion region, FoldingStructureComputationContext ctx, boolean inclusive) {
if (region == null)
return null;
-
- IDocument document= ctx.getDocument();
-
+
+ IDocument document = ctx.getDocument();
+
try {
-
- int start= document.getLineOfOffset(region.getOffset());
- int end= document.getLineOfOffset(region.getOffset() + region.getLength());
+
+ int start = document.getLineOfOffset(region.getOffset());
+ int end = document.getLineOfOffset(region.getOffset() + region.getLength());
if (start >= end)
return null;
-
- int offset= document.getLineOffset(start);
+
+ int offset = document.getLineOffset(start);
int endOffset;
if (inclusive) {
if (document.getNumberOfLines() > end + 1)
- endOffset= document.getLineOffset(end + 1);
+ endOffset = document.getLineOffset(end + 1);
else
- endOffset= document.getLineOffset(end) + document.getLineLength(end);
+ endOffset = document.getLineOffset(end) + document.getLineLength(end);
} else {
- endOffset= document.getLineOffset(end);
+ endOffset = document.getLineOffset(end);
}
return new Region(offset, endOffset - offset);
-
+
} catch (BadLocationException x) {
// concurrent modification
return null;
}
}
-
+
private ProjectionAnnotationModel getModel() {
return fEditor.getAdapter(ProjectionAnnotationModel.class);
}
private IDocument getDocument() {
- IDocumentProvider provider= fEditor.getDocumentProvider();
+ IDocumentProvider provider = fEditor.getDocumentProvider();
return provider.getDocument(fEditor.getEditorInput());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java
index 2dc166b8232..12fbf90da28 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java
@@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Label;
* Empty preference block for extensions to the
* <code>org.eclipse.cdt.ui.foldingStructureProviders</code> extension
* point that do not specify their own.
- *
+ *
* @since 3.0
*/
public class EmptyCFoldingPreferenceBlock implements ICFoldingPreferenceBlock {
@@ -35,24 +35,24 @@ public class EmptyCFoldingPreferenceBlock implements ICFoldingPreferenceBlock {
*/
@Override
public Control createControl(Composite composite) {
- Composite inner= new Composite(composite, SWT.NONE);
+ Composite inner = new Composite(composite, SWT.NONE);
inner.setLayout(new GridLayout(3, false));
- Label label= new Label(inner, SWT.CENTER);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= 30;
+ Label label = new Label(inner, SWT.CENTER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = 30;
label.setLayoutData(gd);
-
- label= new Label(inner, SWT.CENTER);
- label.setText(FoldingMessages.EmptyCFoldingPreferenceBlock_emptyCaption);
- gd= new GridData(GridData.CENTER);
+
+ label = new Label(inner, SWT.CENTER);
+ label.setText(FoldingMessages.EmptyCFoldingPreferenceBlock_emptyCaption);
+ gd = new GridData(GridData.CENTER);
label.setLayoutData(gd);
- label= new Label(inner, SWT.CENTER);
- gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= 30;
+ label = new Label(inner, SWT.CENTER);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = 30;
label.setLayoutData(gd);
-
+
return inner;
}
@@ -84,5 +84,4 @@ public class EmptyCFoldingPreferenceBlock implements ICFoldingPreferenceBlock {
public void dispose() {
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.java
index 38fed4e1658..8b9a7316d98 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.java
@@ -40,8 +40,8 @@ import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
* Proposal to add the unknown word to the dictionaries.
*/
public class AddWordProposal implements ICCompletionProposal {
- private static final String PREF_KEY_DO_NOT_ASK= "do_not_ask_to_install_user_dictionary"; //$NON-NLS-1$
-
+ private static final String PREF_KEY_DO_NOT_ASK = "do_not_ask_to_install_user_dictionary"; //$NON-NLS-1$
+
/** The invocation context */
private final IInvocationContext fContext;
@@ -57,8 +57,8 @@ public class AddWordProposal implements ICCompletionProposal {
* The invocation context
*/
public AddWordProposal(final String word, final IInvocationContext context) {
- fContext= context;
- fWord= word;
+ fContext = context;
+ fWord = word;
}
/*
@@ -66,30 +66,30 @@ public class AddWordProposal implements ICCompletionProposal {
*/
@Override
public final void apply(final IDocument document) {
- final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
- final ISpellChecker checker= engine.getSpellChecker();
+ final ISpellCheckEngine engine = SpellCheckEngine.getInstance();
+ final ISpellChecker checker = engine.getSpellChecker();
if (checker == null)
return;
-
- IQuickAssistInvocationContext quickAssistContext= null;
+
+ IQuickAssistInvocationContext quickAssistContext = null;
if (fContext instanceof IQuickAssistInvocationContext)
- quickAssistContext= (IQuickAssistInvocationContext)fContext;
-
+ quickAssistContext = (IQuickAssistInvocationContext) fContext;
+
if (!checker.acceptsWords()) {
final Shell shell;
if (quickAssistContext != null && quickAssistContext.getSourceViewer() != null)
- shell= quickAssistContext.getSourceViewer().getTextWidget().getShell();
+ shell = quickAssistContext.getSourceViewer().getTextWidget().getShell();
else
- shell= CUIPlugin.getActiveWorkbenchShell();
-
+ shell = CUIPlugin.getActiveWorkbenchShell();
+
if (!canAskToConfigure() || !askUserToConfigureUserDictionary(shell))
return;
-
- String[] preferencePageIds= new String[] { "org.eclipse.ui.editors.preferencePages.Spelling" }; //$NON-NLS-1$
+
+ String[] preferencePageIds = new String[] { "org.eclipse.ui.editors.preferencePages.Spelling" }; //$NON-NLS-1$
PreferencesUtil.createPreferenceDialogOn(shell, preferencePageIds[0], preferencePageIds, null).open();
}
-
+
if (checker.acceptsWords()) {
checker.addWord(fWord);
if (quickAssistContext != null && quickAssistContext.getSourceViewer() != null) {
@@ -101,29 +101,24 @@ public class AddWordProposal implements ICCompletionProposal {
/**
* Asks the user whether he wants to configure
* a user dictionary.
- *
+ *
* @param shell
* @return <code>true</code> if the user wants to configure the user dictionary
*/
private boolean askUserToConfigureUserDictionary(Shell shell) {
- MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
- shell,
- Messages.Spelling_add_askToConfigure_title,
- Messages.Spelling_add_askToConfigure_question,
- Messages.Spelling_add_askToConfigure_ignoreMessage,
- false,
- null,
- null);
-
+ MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(shell,
+ Messages.Spelling_add_askToConfigure_title, Messages.Spelling_add_askToConfigure_question,
+ Messages.Spelling_add_askToConfigure_ignoreMessage, false, null, null);
+
PreferenceConstants.getPreferenceStore().setValue(PREF_KEY_DO_NOT_ASK, toggleDialog.getToggleState());
-
+
return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
}
/**
* Tells whether this proposal can ask to
* configure a user dictionary.
- *
+ *
* @return <code>true</code> if it can ask the user
*/
static boolean canAskToConfigure() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java
index 30b14e01fbc..dbd3e0a63d1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -59,17 +59,21 @@ public class CSpellingEngine extends SpellingEngine {
@Override
public void ensureTokensInitialised() {
}
+
@Override
public IPreferenceStore getPreferenceStore() {
return null;
}
+
@Override
public IToken getToken(String property) {
return new Token(property);
}
+
@Override
public void adaptToPreferenceChange(PropertyChangeEvent event) {
}
+
@Override
public boolean affectsBehavior(PropertyChangeEvent event) {
return false;
@@ -80,59 +84,62 @@ public class CSpellingEngine extends SpellingEngine {
* @see org.eclipse.cdt.internal.ui.text.spelling.SpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- protected void check(IDocument document, IRegion[] regions, ISpellChecker checker, ISpellingProblemCollector collector, IProgressMonitor monitor) {
- ISpellEventListener listener= new SpellEventListener(collector, document);
- boolean isIgnoringStringLiterals= SpellingPreferences.isIgnoreStringLiterals();
-
- ISpellDictionary toRemove= null;
+ protected void check(IDocument document, IRegion[] regions, ISpellChecker checker,
+ ISpellingProblemCollector collector, IProgressMonitor monitor) {
+ ISpellEventListener listener = new SpellEventListener(collector, document);
+ boolean isIgnoringStringLiterals = SpellingPreferences.isIgnoreStringLiterals();
+
+ ISpellDictionary toRemove = null;
try {
checker.addListener(listener);
-
- IDocCommentOwner owner= null;
+
+ IDocCommentOwner owner = null;
if (document instanceof IDocumentExtension3) {
- IDocumentPartitioner partitioner= ((IDocumentExtension3)document).getDocumentPartitioner(ICPartitions.C_PARTITIONING);
+ IDocumentPartitioner partitioner = ((IDocumentExtension3) document)
+ .getDocumentPartitioner(ICPartitions.C_PARTITIONING);
if (partitioner instanceof FastCPartitioner) {
- owner= ((FastCPartitioner)partitioner).getDocCommentOwner();
+ owner = ((FastCPartitioner) partitioner).getDocCommentOwner();
}
}
-
+
try {
- for (int i= 0; i < regions.length; i++) {
- IRegion region= regions[i];
- ITypedRegion[] partitions= TextUtilities.computePartitioning(document,
- ICPartitions.C_PARTITIONING, region.getOffset(), region.getLength(), false);
- for (int index= 0; index < partitions.length; index++) {
+ for (int i = 0; i < regions.length; i++) {
+ IRegion region = regions[i];
+ ITypedRegion[] partitions = TextUtilities.computePartitioning(document, ICPartitions.C_PARTITIONING,
+ region.getOffset(), region.getLength(), false);
+ for (int index = 0; index < partitions.length; index++) {
if (monitor != null && monitor.isCanceled())
return;
- ITypedRegion partition= partitions[index];
- final String type= partition.getType();
-
+ ITypedRegion partition = partitions[index];
+ final String type = partition.getType();
+
if (isIgnoringStringLiterals && type.equals(ICPartitions.C_STRING))
continue;
- if (owner!=null) {
- IDocCommentDictionary dict= null;
-
+ if (owner != null) {
+ IDocCommentDictionary dict = null;
+
if (type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
- dict= owner.getMultilineConfiguration().getSpellingDictionary();
+ dict = owner.getMultilineConfiguration().getSpellingDictionary();
} else if (type.equals(ICPartitions.C_SINGLE_LINE_DOC_COMMENT)) {
- dict= owner.getSinglelineConfiguration().getSpellingDictionary();
+ dict = owner.getSinglelineConfiguration().getSpellingDictionary();
}
-
+
if (dict instanceof IDocCommentSimpleDictionary) {
- ISpellDictionary sd= new DocCommentSpellDictionary((IDocCommentSimpleDictionary)dict);
+ ISpellDictionary sd = new DocCommentSpellDictionary((IDocCommentSimpleDictionary) dict);
checker.addDictionary(sd);
- toRemove= sd;
+ toRemove = sd;
}
}
-
+
if (type.equals(ICPartitions.C_PREPROCESSOR)) {
RuleBasedScanner scanner = new CPreprocessorScanner(new ITokenStoreFactory() {
@Override
public ITokenStore createTokenStore(String[] propertyColorNames) {
return new SimpleTokenStore();
- }}, GPPLanguage.getDefault());
+ }
+ }, GPPLanguage.getDefault());
scanner.setRange(document, partition.getOffset(), partition.getLength());
int firstTokenOffset = -1;
int firstTokenLength = -1;
@@ -151,8 +158,8 @@ public class CSpellingEngine extends SpellingEngine {
String subregionType = null;
char c = document.getChar(offset);
if (c == '"') {
- if (!isIgnoringStringLiterals &&
- !isIncludeDirective(document, firstTokenOffset, firstTokenLength)) {
+ if (!isIgnoringStringLiterals
+ && !isIncludeDirective(document, firstTokenOffset, firstTokenLength)) {
subregionType = ICPartitions.C_STRING;
}
} else if (c == '/' && length >= 2) {
@@ -165,26 +172,26 @@ public class CSpellingEngine extends SpellingEngine {
}
if (subregionType != null) {
TypedRegion subregion = new TypedRegion(offset, length, subregionType);
- checker.execute(new SpellCheckIterator(document, subregion,
- checker.getLocale()));
+ checker.execute(
+ new SpellCheckIterator(document, subregion, checker.getLocale()));
}
}
}
- } else if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE) &&
- !type.equals(ICPartitions.C_CHARACTER)) {
+ } else if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE)
+ && !type.equals(ICPartitions.C_CHARACTER)) {
checker.execute(new SpellCheckIterator(document, partition, checker.getLocale()));
}
-
+
if (toRemove != null) {
checker.removeDictionary(toRemove);
- toRemove= null;
+ toRemove = null;
}
}
}
} catch (BadLocationException x) {
// Ignore BadLocationException since although it does happen from time to time,
// there seems to be not much harm from it.
-// CUIPlugin.log(x);
+ // CUIPlugin.log(x);
}
} finally {
if (toRemove != null)
@@ -194,7 +201,7 @@ public class CSpellingEngine extends SpellingEngine {
}
/**
- * Returns <code>true</code> if the token at the given offset and length is an include directive.
+ * Returns <code>true</code> if the token at the given offset and length is an include directive.
* @param document
* @param offset
* @param length
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java
index 52e425c4d22..7ee3703d12f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java
@@ -53,15 +53,15 @@ public class CSpellingProblem extends SpellingProblem {
/**
* Initialize with the given spell event.
- *
+ *
* @param spellEvent the spell event
* @param document the document
*/
public CSpellingProblem(ISpellEvent spellEvent, IDocument document) {
Assert.isLegal(document != null);
Assert.isLegal(spellEvent != null);
- fSpellEvent= spellEvent;
- fDocument= document;
+ fSpellEvent = spellEvent;
+ fDocument = document;
}
/*
@@ -96,96 +96,86 @@ public class CSpellingProblem extends SpellingProblem {
*/
@Override
public ICompletionProposal[] getProposals() {
- String[] arguments= getArguments();
+ String[] arguments = getArguments();
if (arguments == null)
return new ICompletionProposal[0];
-
- final int threshold= SpellingPreferences.spellingProposalThreshold();
- int size= 0;
- List<RankedWordProposal> proposals= null;
- RankedWordProposal proposal= null;
- ICCompletionProposal[] result= null;
- int index= 0;
+ final int threshold = SpellingPreferences.spellingProposalThreshold();
+ int size = 0;
+ List<RankedWordProposal> proposals = null;
+
+ RankedWordProposal proposal = null;
+ ICCompletionProposal[] result = null;
+ int index = 0;
- boolean fixed= false;
- boolean match= false;
- boolean sentence= false;
+ boolean fixed = false;
+ boolean match = false;
+ boolean sentence = false;
- final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
- final ISpellChecker checker= engine.getSpellChecker();
+ final ISpellCheckEngine engine = SpellCheckEngine.getInstance();
+ final ISpellChecker checker = engine.getSpellChecker();
if (checker != null) {
- CorrectionContext context= new CorrectionContext(null, getOffset(), getLength());
+ CorrectionContext context = new CorrectionContext(null, getOffset(), getLength());
// Hack borrowed from JDT.
- fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX;
+ fixed = arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX;
if ((sentence && match) && !fixed) {
- result= new ICCompletionProposal[] { new ChangeCaseProposal(
- arguments, getOffset(), getLength(), context,
- engine.getLocale()) };
- } else {
- proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0],
- sentence));
- size= proposals.size();
+ result = new ICCompletionProposal[] {
+ new ChangeCaseProposal(arguments, getOffset(), getLength(), context, engine.getLocale()) };
+ } else {
+ proposals = new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
+ size = proposals.size();
if (threshold > 0 && size > threshold) {
Collections.sort(proposals);
- proposals= proposals.subList(size - threshold - 1, size - 1);
- size= proposals.size();
+ proposals = proposals.subList(size - threshold - 1, size - 1);
+ size = proposals.size();
}
- boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false;
- result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
+ boolean extendable = !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false;
+ result = new ICCompletionProposal[size + (extendable ? 3 : 2)];
- for (index= 0; index < size; index++) {
- proposal= proposals.get(index);
- result[index]= new WordCorrectionProposal(proposal
- .getText(), arguments, getOffset(), getLength(),
+ for (index = 0; index < size; index++) {
+ proposal = proposals.get(index);
+ result[index] = new WordCorrectionProposal(proposal.getText(), arguments, getOffset(), getLength(),
context, proposal.getRank());
}
if (extendable)
- result[index++]= new AddWordProposal(arguments[0], context);
+ result[index++] = new AddWordProposal(arguments[0], context);
- result[index++]= new WordIgnoreProposal(arguments[0], context);
- result[index++]= new DisableSpellCheckingProposal(context);
+ result[index++] = new WordIgnoreProposal(arguments[0], context);
+ result[index++] = new DisableSpellCheckingProposal(context);
}
}
return result;
}
-
+
public String[] getArguments() {
- String prefix= ""; //$NON-NLS-1$
- String postfix= ""; //$NON-NLS-1$
+ String prefix = ""; //$NON-NLS-1$
+ String postfix = ""; //$NON-NLS-1$
String word;
try {
- word= fDocument.get(getOffset(), getLength());
+ word = fDocument.get(getOffset(), getLength());
} catch (BadLocationException e) {
return null;
}
try {
- IRegion line= fDocument.getLineInformationOfOffset(getOffset());
- int end= getOffset() + getLength();
- prefix= fDocument.get(line.getOffset(), getOffset()
- - line.getOffset());
- postfix= fDocument.get(end + 1, line.getOffset() + line.getLength()
- - end);
+ IRegion line = fDocument.getLineInformationOfOffset(getOffset());
+ int end = getOffset() + getLength();
+ prefix = fDocument.get(line.getOffset(), getOffset() - line.getOffset());
+ postfix = fDocument.get(end + 1, line.getOffset() + line.getLength() - end);
} catch (BadLocationException exception) {
// Do nothing
}
- return new String[] {
- word,
- prefix,
- postfix,
- isSentenceStart() ? Boolean.toString(true) : Boolean
- .toString(false),
- isDictionaryMatch() ? Boolean.toString(true) : Boolean
- .toString(false) };
+ return new String[] { word, prefix, postfix,
+ isSentenceStart() ? Boolean.toString(true) : Boolean.toString(false),
+ isDictionaryMatch() ? Boolean.toString(true) : Boolean.toString(false) };
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStrategy.java
index 5d32781a47c..3eaea0012e6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStrategy.java
@@ -49,21 +49,23 @@ public class CSpellingReconcileStrategy extends SpellingReconcileStrategy {
*/
@Override
public void accept(SpellingProblem problem) {
- IProblemRequestor requestor= fRequestor;
+ IProblemRequestor requestor = fRequestor;
if (requestor != null) {
try {
- int line= getDocument().getLineOfOffset(problem.getOffset()) + 1;
- String word= getDocument().get(problem.getOffset(), problem.getLength());
- boolean dictionaryMatch= false;
- boolean sentenceStart= false;
+ int line = getDocument().getLineOfOffset(problem.getOffset()) + 1;
+ String word = getDocument().get(problem.getOffset(), problem.getLength());
+ boolean dictionaryMatch = false;
+ boolean sentenceStart = false;
if (problem instanceof CSpellingProblem) {
- dictionaryMatch= ((CSpellingProblem)problem).isDictionaryMatch();
- sentenceStart= ((CSpellingProblem) problem).isSentenceStart();
+ dictionaryMatch = ((CSpellingProblem) problem).isDictionaryMatch();
+ sentenceStart = ((CSpellingProblem) problem).isSentenceStart();
}
// see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514
- IEditorInput editorInput= fEditor.getEditorInput();
+ IEditorInput editorInput = fEditor.getEditorInput();
if (editorInput != null) {
- CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName());
+ CoreSpellingProblem iProblem = new CoreSpellingProblem(problem.getOffset(),
+ problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word,
+ dictionaryMatch, sentenceStart, getDocument(), editorInput.getName());
requestor.acceptProblem(iProblem);
}
} catch (BadLocationException x) {
@@ -91,19 +93,19 @@ public class CSpellingReconcileStrategy extends SpellingReconcileStrategy {
}
}
-
/** The id of the problem */
- public static final int SPELLING_PROBLEM_ID= 0x80000000;
+ public static final int SPELLING_PROBLEM_ID = 0x80000000;
/** Properties file content type */
- private static final IContentType CXX_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
+ private static final IContentType CXX_CONTENT_TYPE = Platform.getContentTypeManager()
+ .getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
/** The text editor to operate on. */
private ITextEditor fEditor;
/** The problem requester. */
private IProblemRequestor fRequestor;
-
+
/**
* Creates a new comment reconcile strategy.
*
@@ -112,7 +114,7 @@ public class CSpellingReconcileStrategy extends SpellingReconcileStrategy {
*/
public CSpellingReconcileStrategy(ISourceViewer viewer, ITextEditor editor) {
super(viewer, CSpellingService.getInstance());
- fEditor= editor;
+ fEditor = editor;
}
/*
@@ -123,7 +125,7 @@ public class CSpellingReconcileStrategy extends SpellingReconcileStrategy {
if (fRequestor != null && isSpellingEnabled())
super.reconcile(region);
}
-
+
private boolean isSpellingEnabled() {
return EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED);
}
@@ -135,7 +137,7 @@ public class CSpellingReconcileStrategy extends SpellingReconcileStrategy {
protected ISpellingProblemCollector createSpellingProblemCollector() {
return new SpellingProblemCollector();
}
-
+
/*
* @see org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy#getContentType()
*/
@@ -157,16 +159,16 @@ public class CSpellingReconcileStrategy extends SpellingReconcileStrategy {
* Update the problem requester based on the current editor
*/
private void updateProblemRequester() {
- IAnnotationModel model= getAnnotationModel();
- fRequestor= (model instanceof IProblemRequestor) ? (IProblemRequestor) model : null;
+ IAnnotationModel model = getAnnotationModel();
+ fRequestor = (model instanceof IProblemRequestor) ? (IProblemRequestor) model : null;
}
-
+
/*
* @see org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy#getAnnotationModel()
*/
@Override
protected IAnnotationModel getAnnotationModel() {
- final IDocumentProvider documentProvider= fEditor.getDocumentProvider();
+ final IDocumentProvider documentProvider = fEditor.getDocumentProvider();
if (documentProvider == null)
return null;
return documentProvider.getAnnotationModel(fEditor.getEditorInput());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.java
index 351a6890517..a1659127d45 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.java
@@ -34,10 +34,9 @@ import org.eclipse.ui.texteditor.spelling.SpellingService;
*/
public class CSpellingService extends SpellingService {
private static CSpellingService fInstance;
-
+
private IPreferenceStore fPreferences;
private ISpellingEngine fEngine;
-
public static CSpellingService getInstance() {
if (fInstance == null) {
@@ -55,21 +54,22 @@ public class CSpellingService extends SpellingService {
if (fEngine == null) {
fEngine = new CSpellingEngine();
}
- ISafeRunnable runnable= new ISafeRunnable() {
- @Override
- public void run() throws Exception {
- fEngine.check(document, regions, context, collector, monitor);
- }
- @Override
- public void handleException(Throwable x) {
- }
- };
- SafeRunner.run(runnable);
+ ISafeRunnable runnable = new ISafeRunnable() {
+ @Override
+ public void run() throws Exception {
+ fEngine.check(document, regions, context, collector, monitor);
+ }
+
+ @Override
+ public void handleException(Throwable x) {
+ }
+ };
+ SafeRunner.run(runnable);
} finally {
collector.endCollecting();
}
}
-
+
private CSpellingService(IPreferenceStore preferences) {
super(preferences);
fPreferences = preferences;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.java
index 7fcda14328e..35e004b97a5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.java
@@ -35,8 +35,9 @@ public class ChangeCaseProposal extends WordCorrectionProposal {
*/
public ChangeCaseProposal(final String[] arguments, final int offset, final int length,
final IInvocationContext context, final Locale locale) {
- super(Character.isLowerCase(arguments[0].charAt(0)) ? Character.toUpperCase(arguments[0].charAt(0)) + arguments[0].substring(1) : arguments[0],
- arguments, offset, length, context, Integer.MAX_VALUE);
+ super(Character.isLowerCase(arguments[0].charAt(0))
+ ? Character.toUpperCase(arguments[0].charAt(0)) + arguments[0].substring(1)
+ : arguments[0], arguments, offset, length, context, Integer.MAX_VALUE);
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java
index 6b888e492bd..f8aef7e6ef9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -25,18 +25,18 @@ import org.eclipse.cdt.core.parser.AbstractPersistableProblem;
* Spelling problem to be accepted by problem requesters.
*/
public class CoreSpellingProblem extends AbstractPersistableProblem {
- // spelling 'marker type' name. Only virtual as spelling problems are never persisted in markers.
+ // spelling 'marker type' name. Only virtual as spelling problems are never persisted in markers.
// marker type is used in the quickFixProcessor extension point
- public static final String MARKER_TYPE= "org.eclipse.cdt.internal.spelling"; //$NON-NLS-1$
-
+ public static final String MARKER_TYPE = "org.eclipse.cdt.internal.spelling"; //$NON-NLS-1$
+
/** The end offset of the problem */
- private int fSourceEnd= 0;
+ private int fSourceEnd = 0;
/** The line number of the problem */
- private int fLineNumber= 1;
+ private int fLineNumber = 1;
/** The start offset of the problem */
- private int fSourceStart= 0;
+ private int fSourceStart = 0;
/** The description of the problem */
private String fMessage;
@@ -69,35 +69,38 @@ public class CoreSpellingProblem extends AbstractPersistableProblem {
* @param document the document
* @param origin the originating file name
*/
- public CoreSpellingProblem(int start, int end, int line, String message, String word, boolean match, boolean sentence, IDocument document, String origin) {
+ public CoreSpellingProblem(int start, int end, int line, String message, String word, boolean match,
+ boolean sentence, IDocument document, String origin) {
super();
- fSourceStart= start;
- fSourceEnd= end;
- fLineNumber= line;
- fMessage= message;
- fWord= word;
- fMatch= match;
- fSentence= sentence;
- fDocument= document;
- fOrigin= origin;
+ fSourceStart = start;
+ fSourceEnd = end;
+ fLineNumber = line;
+ fMessage = message;
+ fWord = word;
+ fMatch = match;
+ fSentence = sentence;
+ fDocument = document;
+ fOrigin = origin;
}
+
/*
* @see org.eclipse.cdt.core.parser.IProblem#getArguments()
*/
@Override
public String[] getArguments() {
- String prefix= ""; //$NON-NLS-1$
- String postfix= ""; //$NON-NLS-1$
+ String prefix = ""; //$NON-NLS-1$
+ String postfix = ""; //$NON-NLS-1$
try {
- IRegion line= fDocument.getLineInformationOfOffset(fSourceStart);
+ IRegion line = fDocument.getLineInformationOfOffset(fSourceStart);
- prefix= fDocument.get(line.getOffset(), fSourceStart - line.getOffset());
- postfix= fDocument.get(fSourceEnd + 1, line.getOffset() + line.getLength() - fSourceEnd);
+ prefix = fDocument.get(line.getOffset(), fSourceStart - line.getOffset());
+ postfix = fDocument.get(fSourceEnd + 1, line.getOffset() + line.getLength() - fSourceEnd);
} catch (BadLocationException exception) {
// Do nothing
}
- return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false), fMatch ? Boolean.toString(true) : Boolean.toString(false) };
+ return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false),
+ fMatch ? Boolean.toString(true) : Boolean.toString(false) };
}
/*
@@ -116,13 +119,12 @@ public class CoreSpellingProblem extends AbstractPersistableProblem {
return fMessage;
}
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IProblem#getMessageWithLocation()
*/
@Override
public String getMessageWithLocation() {
- return NLS.bind(Messages.Spelling_msgWithLocation, new Object[] {fMessage, fOrigin, fLineNumber});
+ return NLS.bind(Messages.Spelling_msgWithLocation, new Object[] { fMessage, fOrigin, fLineNumber });
}
/*
@@ -177,23 +179,23 @@ public class CoreSpellingProblem extends AbstractPersistableProblem {
* @see org.eclipse.cdt.core.parser.IProblem#setSourceStart(int)
*/
public void setSourceStart(int sourceStart) {
- fSourceStart= sourceStart;
+ fSourceStart = sourceStart;
}
/*
* @see org.eclipse.cdt.core.parser.IProblem#setSourceEnd(int)
*/
public void setSourceEnd(int sourceEnd) {
- fSourceEnd= sourceEnd;
+ fSourceEnd = sourceEnd;
}
/*
* @see org.eclipse.cdt.core.parser.IProblem#setSourceLineNumber(int)
*/
public void setSourceLineNumber(int lineNumber) {
- fLineNumber= lineNumber;
+ fLineNumber = lineNumber;
}
-
+
/*
* @see org.eclipse.cdt.core.parser.CategorizedProblem#getMarkerType()
*/
@@ -201,7 +203,7 @@ public class CoreSpellingProblem extends AbstractPersistableProblem {
public String getMarkerType() {
return MARKER_TYPE;
}
-
+
@Override
public boolean checkCategory(int bitmask) {
return (getID() & bitmask) != 0;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java
index 1ffe6a8bb6f..0f547d13435 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java
@@ -26,13 +26,12 @@ import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.cdt.ui.text.IInvocationContext;
-
/**
* Proposal to disable spell checking.
*/
public class DisableSpellCheckingProposal implements ICCompletionProposal {
private final String ID_DISABLE = "DISABLE"; //$NON-NLS-1$
-
+
/** The invocation context */
private IInvocationContext fContext;
@@ -42,7 +41,7 @@ public class DisableSpellCheckingProposal implements ICCompletionProposal {
* @param context the invocation context
*/
public DisableSpellCheckingProposal(IInvocationContext context) {
- fContext= context;
+ fContext = context;
}
/*
@@ -50,7 +49,7 @@ public class DisableSpellCheckingProposal implements ICCompletionProposal {
*/
@Override
public final void apply(final IDocument document) {
- IPreferenceStore store= EditorsUI.getPreferenceStore();
+ IPreferenceStore store = EditorsUI.getPreferenceStore();
store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, false);
}
@@ -101,7 +100,7 @@ public class DisableSpellCheckingProposal implements ICCompletionProposal {
public final Point getSelection(final IDocument document) {
return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength());
}
-
+
@Override
public String getIdString() {
return ID_DISABLE;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.java
index 8ce99a2e281..d0b86c0b3f1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.java
@@ -51,13 +51,15 @@ public class HtmlTagDictionary extends AbstractSpellDictionary {
protected synchronized boolean load(final URL url) {
unload();
- for (int index= 0; index < IHtmlTagConstants.HTML_GENERAL_TAGS.length; index++) {
- hashWord(IHtmlTagConstants.HTML_TAG_PREFIX + IHtmlTagConstants.HTML_GENERAL_TAGS[index] + IHtmlTagConstants.HTML_TAG_POSTFIX);
- hashWord(IHtmlTagConstants.HTML_CLOSE_PREFIX + IHtmlTagConstants.HTML_GENERAL_TAGS[index] + IHtmlTagConstants.HTML_TAG_POSTFIX);
+ for (int index = 0; index < IHtmlTagConstants.HTML_GENERAL_TAGS.length; index++) {
+ hashWord(IHtmlTagConstants.HTML_TAG_PREFIX + IHtmlTagConstants.HTML_GENERAL_TAGS[index]
+ + IHtmlTagConstants.HTML_TAG_POSTFIX);
+ hashWord(IHtmlTagConstants.HTML_CLOSE_PREFIX + IHtmlTagConstants.HTML_GENERAL_TAGS[index]
+ + IHtmlTagConstants.HTML_TAG_POSTFIX);
}
return true;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#stripNonLetters(java.lang.String)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java
index 1fcd9e69b5d..79153802d85 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java
@@ -50,11 +50,11 @@ import org.eclipse.cdt.internal.ui.text.spelling.engine.PersistentSpellDictionar
*/
public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListener {
/** The dictionary location */
- public static final String DICTIONARY_LOCATION= "dictionaries/"; //$NON-NLS-1$
+ public static final String DICTIONARY_LOCATION = "dictionaries/"; //$NON-NLS-1$
/** The singleton engine instance */
- private static ISpellCheckEngine fgEngine= null;
-
+ private static ISpellCheckEngine fgEngine = null;
+
/**
* Caches the locales of installed dictionaries.
*/
@@ -69,45 +69,47 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
public static Set<Locale> getLocalesWithInstalledDictionaries() {
if (fgLocalesWithInstalledDictionaries != null)
return fgLocalesWithInstalledDictionaries;
-
+
URL location;
try {
- location= getDictionaryLocation();
+ location = getDictionaryLocation();
if (location == null)
- return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+ return fgLocalesWithInstalledDictionaries = Collections.emptySet();
} catch (MalformedURLException ex) {
CUIPlugin.log(ex);
- return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+ return fgLocalesWithInstalledDictionaries = Collections.emptySet();
}
-
+
String[] fileNames;
try {
- URL url= FileLocator.toFileURL(location);
- File file= new File(url.getFile());
+ URL url = FileLocator.toFileURL(location);
+ File file = new File(url.getFile());
if (!file.isDirectory())
- return fgLocalesWithInstalledDictionaries= Collections.emptySet();
- fileNames= file.list();
+ return fgLocalesWithInstalledDictionaries = Collections.emptySet();
+ fileNames = file.list();
if (fileNames == null)
- return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+ return fgLocalesWithInstalledDictionaries = Collections.emptySet();
} catch (IOException ex) {
CUIPlugin.log(ex);
- return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+ return fgLocalesWithInstalledDictionaries = Collections.emptySet();
}
-
- fgLocalesWithInstalledDictionaries= new HashSet<Locale>();
- int fileNameCount= fileNames.length;
- for (int i= 0; i < fileNameCount; i++) {
- String fileName= fileNames[i];
- int localeEnd= fileName.indexOf(".dictionary"); //$NON-NLS-1$
+
+ fgLocalesWithInstalledDictionaries = new HashSet<Locale>();
+ int fileNameCount = fileNames.length;
+ for (int i = 0; i < fileNameCount; i++) {
+ String fileName = fileNames[i];
+ int localeEnd = fileName.indexOf(".dictionary"); //$NON-NLS-1$
if (localeEnd > 1) {
- String localeName= fileName.substring(0, localeEnd);
- int languageEnd=localeName.indexOf('_');
+ String localeName = fileName.substring(0, localeEnd);
+ int languageEnd = localeName.indexOf('_');
if (languageEnd == -1) {
fgLocalesWithInstalledDictionaries.add(new Locale(localeName));
} else if (languageEnd == 2 && localeName.length() == 5) {
- fgLocalesWithInstalledDictionaries.add(new Locale(localeName.substring(0, 2), localeName.substring(3)));
+ fgLocalesWithInstalledDictionaries
+ .add(new Locale(localeName.substring(0, 2), localeName.substring(3)));
} else if (localeName.length() > 6 && localeName.charAt(5) == '_') {
- fgLocalesWithInstalledDictionaries.add(new Locale(localeName.substring(0, 2), localeName.substring(3, 5), localeName.substring(6)));
+ fgLocalesWithInstalledDictionaries.add(new Locale(localeName.substring(0, 2),
+ localeName.substring(3, 5), localeName.substring(6)));
}
}
}
@@ -123,7 +125,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
public static Locale getDefaultLocale() {
return Locale.getDefault();
}
-
+
/**
* Returns the dictionary closest to the given locale.
*
@@ -131,18 +133,18 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
* @return the dictionary or <code>null</code> if none is suitable
*/
public ISpellDictionary findDictionary(Locale locale) {
- ISpellDictionary dictionary= fLocaleDictionaries.get(locale);
+ ISpellDictionary dictionary = fLocaleDictionaries.get(locale);
if (dictionary != null)
return dictionary;
-
+
// Try same language
- String language= locale.getLanguage();
+ String language = locale.getLanguage();
for (Entry<Locale, ISpellDictionary> entry : fLocaleDictionaries.entrySet()) {
- Locale dictLocale= entry.getKey();
+ Locale dictLocale = entry.getKey();
if (dictLocale.getLanguage().equals(language))
return entry.getValue();
}
-
+
return null;
}
@@ -152,22 +154,22 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
public static Locale findClosestLocale(Locale locale) {
if (locale == null || locale.toString().length() == 0)
return locale;
-
+
if (getLocalesWithInstalledDictionaries().contains(locale))
return locale;
// Try same language
- String language= locale.getLanguage();
+ String language = locale.getLanguage();
for (Locale dictLocale : getLocalesWithInstalledDictionaries()) {
if (dictLocale.getLanguage().equals(language))
return dictLocale;
}
-
+
// Try whether American English is present
- Locale defaultLocale= Locale.US;
+ Locale defaultLocale = Locale.US;
if (getLocalesWithInstalledDictionaries().contains(defaultLocale))
return defaultLocale;
-
+
return null;
}
@@ -185,7 +187,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
public static URL getDictionaryLocation() throws MalformedURLException {
// Unfortunately, dictionaries used by JDT are not accessible,
// so we have to provide our own copies of the same files.
- final CUIPlugin plugin= CUIPlugin.getDefault();
+ final CUIPlugin plugin = CUIPlugin.getDefault();
if (plugin != null)
return plugin.getBundle().getEntry("/" + DICTIONARY_LOCATION); //$NON-NLS-1$
@@ -199,32 +201,32 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
*/
public static final synchronized ISpellCheckEngine getInstance() {
if (fgEngine == null)
- fgEngine= new SpellCheckEngine();
+ fgEngine = new SpellCheckEngine();
return fgEngine;
}
-
+
/**
* Shuts down the singleton instance of the spell check engine.
*/
public static final synchronized void shutdownInstance() {
if (fgEngine != null) {
fgEngine.shutdown();
- fgEngine= null;
+ fgEngine = null;
}
}
/** The registered locale insensitive dictionaries */
- private Set<ISpellDictionary> fGlobalDictionaries= new HashSet<ISpellDictionary>();
+ private Set<ISpellDictionary> fGlobalDictionaries = new HashSet<ISpellDictionary>();
/** The spell checker for fLocale */
- private ISpellChecker fChecker= null;
+ private ISpellChecker fChecker = null;
/** The registered locale sensitive dictionaries */
- private Map<Locale, ISpellDictionary> fLocaleDictionaries= new HashMap<Locale, ISpellDictionary>();
+ private Map<Locale, ISpellDictionary> fLocaleDictionaries = new HashMap<Locale, ISpellDictionary>();
/** The user dictionary */
- private ISpellDictionary fUserDictionary= null;
+ private ISpellDictionary fUserDictionary = null;
/**
* Creates a new spell check manager.
@@ -234,7 +236,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
fGlobalDictionaries.add(new HtmlTagDictionary());
try {
- final URL location= getDictionaryLocation();
+ final URL location = getDictionaryLocation();
for (Locale locale : getLocalesWithInstalledDictionaries()) {
fLocaleDictionaries.put(locale, new LocaleSensitiveSpellDictionary(locale, location));
@@ -242,7 +244,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
} catch (MalformedURLException exception) {
// Do nothing
}
-
+
SpellingPreferences.addPropertyChangeListener(this);
}
@@ -253,25 +255,25 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
public final synchronized ISpellChecker getSpellChecker() throws IllegalStateException {
if (fGlobalDictionaries == null)
throw new IllegalStateException("spell checker has been shut down"); //$NON-NLS-1$
-
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- Locale locale= getCurrentLocale(store);
+
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ Locale locale = getCurrentLocale(store);
if (fUserDictionary == null && "".equals(locale.toString())) //$NON-NLS-1$
return null;
-
+
if (fChecker != null && fChecker.getLocale().equals(locale))
return fChecker;
-
+
resetSpellChecker();
-
- fChecker= new DefaultSpellChecker(store, locale);
+
+ fChecker = new DefaultSpellChecker(store, locale);
resetUserDictionary();
-
+
for (ISpellDictionary dictionary : fGlobalDictionaries) {
fChecker.addDictionary(dictionary);
}
- ISpellDictionary dictionary= findDictionary(fChecker.getLocale());
+ ISpellDictionary dictionary = findDictionary(fChecker.getLocale());
if (dictionary != null)
fChecker.addDictionary(dictionary);
@@ -287,15 +289,15 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
private Locale getCurrentLocale(IPreferenceStore store) {
return convertToLocale(SpellingPreferences.getSpellingLocale());
}
-
+
public static Locale convertToLocale(String locale) {
- Locale defaultLocale= SpellCheckEngine.getDefaultLocale();
+ Locale defaultLocale = SpellCheckEngine.getDefaultLocale();
if (locale.equals(defaultLocale.toString()))
return defaultLocale;
-
+
if (locale.length() >= 5)
return new Locale(locale.substring(0, 2), locale.substring(3, 5));
-
+
return new Locale(""); //$NON-NLS-1$
}
@@ -306,7 +308,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
public synchronized final Locale getLocale() {
if (fChecker == null)
return null;
-
+
return fChecker.getLocale();
}
@@ -319,12 +321,12 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
resetSpellChecker();
return;
}
-
+
if (event.getProperty().equals(SpellingPreferences.SPELLING_USER_DICTIONARY)) {
resetUserDictionary();
return;
}
-
+
if (event.getProperty().equals(SpellingPreferences.SPELLING_USER_DICTIONARY_ENCODING)) {
resetUserDictionary();
return;
@@ -337,38 +339,38 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
private synchronized void resetUserDictionary() {
if (fChecker == null)
return;
-
+
// Update user dictionary
if (fUserDictionary != null) {
fChecker.removeDictionary(fUserDictionary);
fUserDictionary.unload();
- fUserDictionary= null;
+ fUserDictionary = null;
}
- String filePath= SpellingPreferences.getSpellingUserDictionary();
+ String filePath = SpellingPreferences.getSpellingUserDictionary();
- VariablesPlugin variablesPlugin= VariablesPlugin.getDefault();
+ VariablesPlugin variablesPlugin = VariablesPlugin.getDefault();
if (variablesPlugin == null)
return;
- IStringVariableManager variableManager= variablesPlugin.getStringVariableManager();
+ IStringVariableManager variableManager = variablesPlugin.getStringVariableManager();
try {
- filePath= variableManager.performStringSubstitution(filePath);
+ filePath = variableManager.performStringSubstitution(filePath);
} catch (CoreException e) {
CUIPlugin.log(e);
return;
}
if (filePath.length() > 0) {
try {
- File file= new File(filePath);
+ File file = new File(filePath);
if (!file.exists() && !file.createNewFile())
return;
-
- final URL url= new URL("file", null, filePath); //$NON-NLS-1$
- InputStream stream= url.openStream();
+
+ final URL url = new URL("file", null, filePath); //$NON-NLS-1$
+ InputStream stream = url.openStream();
if (stream != null) {
try {
- fUserDictionary= new PersistentSpellDictionary(url);
+ fUserDictionary = new PersistentSpellDictionary(url);
fChecker.addDictionary(fUserDictionary);
} finally {
stream.close();
@@ -410,24 +412,24 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
for (ISpellDictionary dictionary : fGlobalDictionaries) {
dictionary.unload();
}
- fGlobalDictionaries= null;
+ fGlobalDictionaries = null;
for (ISpellDictionary dictionary : fLocaleDictionaries.values()) {
dictionary.unload();
}
- fLocaleDictionaries= null;
+ fLocaleDictionaries = null;
- fUserDictionary= null;
- fChecker= null;
+ fUserDictionary = null;
+ fChecker = null;
}
-
+
private synchronized void resetSpellChecker() {
if (fChecker != null) {
- ISpellDictionary dictionary= fLocaleDictionaries.get(fChecker.getLocale());
+ ISpellDictionary dictionary = fLocaleDictionaries.get(fChecker.getLocale());
if (dictionary != null)
dictionary.unload();
}
- fChecker= null;
+ fChecker = null;
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java
index bc79ab82418..bd13890292d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java
@@ -34,10 +34,10 @@ public class SpellCheckIterator implements ISpellCheckIterator {
protected final String fContent;
/** The last token */
- protected String fLastToken= null;
+ protected String fLastToken = null;
/** The next break */
- protected int fNext= 1;
+ protected int fNext = 1;
/** The offset of the region */
protected final int fOffset;
@@ -46,13 +46,13 @@ public class SpellCheckIterator implements ISpellCheckIterator {
private int fPredecessor;
/** The previous break */
- protected int fPrevious= 0;
+ protected int fPrevious = 0;
/** The sentence breaks */
- private final LinkedList<Integer> fSentenceBreaks= new LinkedList<Integer>();
+ private final LinkedList<Integer> fSentenceBreaks = new LinkedList<Integer>();
/** Does the current word start a sentence? */
- private boolean fStartsSentence= false;
+ private boolean fStartsSentence = false;
/** The successor break */
protected int fSuccessor;
@@ -82,37 +82,37 @@ public class SpellCheckIterator implements ISpellCheckIterator {
* @param breakIterator the break-iterator
*/
public SpellCheckIterator(IDocument document, IRegion region, Locale locale, BreakIterator breakIterator) {
- fOffset= region.getOffset();
- fWordIterator= breakIterator;
+ fOffset = region.getOffset();
+ fWordIterator = breakIterator;
String content;
try {
- content= document.get(region.getOffset(), region.getLength());
+ content = document.get(region.getOffset(), region.getLength());
} catch (Exception exception) {
- content= ""; //$NON-NLS-1$
+ content = ""; //$NON-NLS-1$
}
- fContent= content;
+ fContent = content;
fWordIterator.setText(content);
- fPredecessor= fWordIterator.first();
- fSuccessor= fWordIterator.next();
+ fPredecessor = fWordIterator.first();
+ fSuccessor = fWordIterator.next();
- final BreakIterator iterator= BreakIterator.getSentenceInstance(locale);
+ final BreakIterator iterator = BreakIterator.getSentenceInstance(locale);
iterator.setText(content);
- int offset= iterator.current();
+ int offset = iterator.current();
while (offset != BreakIterator.DONE) {
fSentenceBreaks.add(Integer.valueOf(offset));
- offset= iterator.next();
+ offset = iterator.next();
}
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckIterator#setIgnoreSingleLetters(boolean)
*/
@Override
public void setIgnoreSingleLetters(boolean state) {
- fIsIgnoringSingleLetters= state;
+ fIsIgnoringSingleLetters = state;
}
/*
@@ -149,12 +149,12 @@ public class SpellCheckIterator implements ISpellCheckIterator {
* least one letter only, <code>false</code> otherwise
*/
protected final boolean isAlphaNumeric(final int begin, final int end) {
- char character= 0;
- boolean letter= false;
- for (int index= begin; index < end; index++) {
- character= fContent.charAt(index);
+ char character = 0;
+ boolean letter = false;
+ for (int index = begin; index < end; index++) {
+ character = fContent.charAt(index);
if (Character.isLetter(character))
- letter= true;
+ letter = true;
if (!Character.isLetterOrDigit(character))
return false;
@@ -171,7 +171,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
protected final boolean isToken(final String[] tags) {
return isToken(fLastToken, tags);
}
-
+
/**
* Checks the given token against the given tags?
*
@@ -206,7 +206,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
if (begin < fContent.length() - 1 && !Character.isWhitespace(fContent.charAt(begin + 1)))
return false;
-
+
return true;
}
@@ -234,7 +234,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
* only, <code>false</code> otherwise
*/
protected final boolean isWhitespace(final int begin, final int end) {
- for (int index= begin; index < end; index++) {
+ for (int index = begin; index < end; index++) {
if (!Character.isWhitespace(fContent.charAt(index)))
return false;
}
@@ -246,11 +246,11 @@ public class SpellCheckIterator implements ISpellCheckIterator {
*/
@Override
public String next() {
- String token= nextToken();
+ String token = nextToken();
while (token == null && fSuccessor != BreakIterator.DONE)
- token= nextToken();
+ token = nextToken();
- fLastToken= token;
+ fLastToken = token;
return token;
}
@@ -258,9 +258,9 @@ public class SpellCheckIterator implements ISpellCheckIterator {
* Advances the end index to the next word break.
*/
protected final void nextBreak() {
- fNext= fSuccessor;
- fPredecessor= fSuccessor;
- fSuccessor= fWordIterator.next();
+ fNext = fSuccessor;
+ fPredecessor = fSuccessor;
+ fSuccessor = fWordIterator.next();
}
/**
@@ -279,14 +279,15 @@ public class SpellCheckIterator implements ISpellCheckIterator {
* iff the next token is not a candidate for spell checking.
*/
protected String nextToken() {
- String token= null;
- fPrevious= fPredecessor;
- fStartsSentence= false;
+ String token = null;
+ fPrevious = fPredecessor;
+ fStartsSentence = false;
nextBreak();
- boolean update= false;
+ boolean update = false;
if (fNext - fPrevious > 0) {
- if (fSuccessor != BreakIterator.DONE && fContent.charAt(fPrevious) == IHtmlTagConstants.HTML_TAG_PREFIX && (Character.isLetter(fContent.charAt(fNext)) || fContent.charAt(fNext) == '/')) {
+ if (fSuccessor != BreakIterator.DONE && fContent.charAt(fPrevious) == IHtmlTagConstants.HTML_TAG_PREFIX
+ && (Character.isLetter(fContent.charAt(fNext)) || fContent.charAt(fNext) == '/')) {
if (fContent.startsWith(IHtmlTagConstants.HTML_CLOSE_PREFIX, fPrevious))
nextBreak();
@@ -295,32 +296,34 @@ public class SpellCheckIterator implements ISpellCheckIterator {
if (fSuccessor != BreakIterator.DONE && fContent.charAt(fNext) == IHtmlTagConstants.HTML_TAG_POSTFIX) {
nextBreak();
if (fSuccessor != BreakIterator.DONE) {
- update= true;
- token= fContent.substring(fPrevious, fNext);
+ update = true;
+ token = fContent.substring(fPrevious, fNext);
}
}
- } else if (fSuccessor != BreakIterator.DONE && fContent.charAt(fPrevious) == IHtmlTagConstants.HTML_ENTITY_START && (Character.isLetter(fContent.charAt(fNext)))) {
+ } else if (fSuccessor != BreakIterator.DONE
+ && fContent.charAt(fPrevious) == IHtmlTagConstants.HTML_ENTITY_START
+ && (Character.isLetter(fContent.charAt(fNext)))) {
nextBreak();
if (fSuccessor != BreakIterator.DONE && fContent.charAt(fNext) == IHtmlTagConstants.HTML_ENTITY_END) {
nextBreak();
if (isToken(fContent.substring(fPrevious, fNext), IHtmlTagConstants.HTML_ENTITY_CODES)) {
skipTokens(fPrevious, IHtmlTagConstants.HTML_ENTITY_END);
- update= true;
+ update = true;
} else {
- token= fContent.substring(fPrevious, fNext);
+ token = fContent.substring(fPrevious, fNext);
}
} else {
- token= fContent.substring(fPrevious, fNext);
+ token = fContent.substring(fPrevious, fNext);
}
-
- update= true;
+
+ update = true;
} else if (!isWhitespace(fPrevious, fNext) && isAlphaNumeric(fPrevious, fNext)) {
if (isUrlToken(fPrevious)) {
skipTokens(fPrevious, ' ');
} else if (fNext - fPrevious > 1 || isSingleLetter(fPrevious) && !fIsIgnoringSingleLetters) {
- token= fContent.substring(fPrevious, fNext);
+ token = fContent.substring(fPrevious, fNext);
}
- update= true;
+ update = true;
}
}
@@ -329,7 +332,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
while (fSentenceBreaks.size() > 0 && fPrevious >= nextSentence())
fSentenceBreaks.removeFirst();
- fStartsSentence= (fLastToken == null) || (token != null);
+ fStartsSentence = (fLastToken == null) || (token != null);
}
}
return token;
@@ -350,17 +353,17 @@ public class SpellCheckIterator implements ISpellCheckIterator {
* @param stop the stop character
*/
protected final void skipTokens(final int begin, final char stop) {
- int end= begin;
+ int end = begin;
while (end < fContent.length() && fContent.charAt(end) != stop)
end++;
if (end < fContent.length()) {
- fNext= end;
- fPredecessor= fNext;
- fSuccessor= fWordIterator.following(fNext);
+ fNext = end;
+ fPredecessor = fNext;
+ fSuccessor = fWordIterator.following(fNext);
} else {
- fSuccessor= BreakIterator.DONE;
+ fSuccessor = BreakIterator.DONE;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.java
index 97601d540b8..2ea13446270 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.java
@@ -38,7 +38,7 @@ public abstract class SpellingEngine implements ISpellingEngine {
protected static class SpellEventListener implements ISpellEventListener {
/** Spelling problem collector */
private ISpellingProblemCollector fCollector;
-
+
/**
* The document.
*/
@@ -51,8 +51,8 @@ public abstract class SpellingEngine implements ISpellingEngine {
* @param document the document
*/
public SpellEventListener(ISpellingProblemCollector collector, IDocument document) {
- fCollector= collector;
- fDocument= document;
+ fCollector = collector;
+ fDocument = document;
}
/*
@@ -68,10 +68,11 @@ public abstract class SpellingEngine implements ISpellingEngine {
* @see org.eclipse.ui.texteditor.spelling.ISpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.ui.texteditor.spelling.SpellingContext, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void check(IDocument document, IRegion[] regions, SpellingContext context, ISpellingProblemCollector collector, IProgressMonitor monitor) {
+ public void check(IDocument document, IRegion[] regions, SpellingContext context,
+ ISpellingProblemCollector collector, IProgressMonitor monitor) {
if (collector != null) {
- final ISpellCheckEngine spellingEngine= SpellCheckEngine.getInstance();
- ISpellChecker checker= spellingEngine.getSpellChecker();
+ final ISpellCheckEngine spellingEngine = SpellCheckEngine.getInstance();
+ ISpellChecker checker = spellingEngine.getSpellChecker();
if (checker != null)
check(document, regions, checker, collector, monitor);
}
@@ -86,5 +87,6 @@ public abstract class SpellingEngine implements ISpellingEngine {
* @param collector the spelling problem collector
* @param monitor the progress monitor, can be <code>null</code>
*/
- protected abstract void check(IDocument document, IRegion[] regions, ISpellChecker checker, ISpellingProblemCollector collector, IProgressMonitor monitor);
+ protected abstract void check(IDocument document, IRegion[] regions, ISpellChecker checker,
+ ISpellingProblemCollector collector, IProgressMonitor monitor);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java
index 1bcfb7b7a4f..6de8417fec6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java
@@ -43,13 +43,17 @@ public class SpellingEngineDispatcher implements ISpellingEngine {
private static final String C_SPELLING_ENGINE_ID = "org.eclipse.cdt.internal.ui.text.spelling.CSpellingEngine"; //$NON-NLS-1$
/** C/C++ source content type */
- private static final IContentType CHEADER_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CHEADER);
- private static final IContentType CSOURCE_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE);
- private static final IContentType CXXHEADER_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER);
- private static final IContentType CXXSOURCE_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
+ private static final IContentType CHEADER_CONTENT_TYPE = Platform.getContentTypeManager()
+ .getContentType(CCorePlugin.CONTENT_TYPE_CHEADER);
+ private static final IContentType CSOURCE_CONTENT_TYPE = Platform.getContentTypeManager()
+ .getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE);
+ private static final IContentType CXXHEADER_CONTENT_TYPE = Platform.getContentTypeManager()
+ .getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER);
+ private static final IContentType CXXSOURCE_CONTENT_TYPE = Platform.getContentTypeManager()
+ .getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
/** Available spelling engines by content type */
- private Map<IContentType, SpellingEngine> fEngines= new HashMap<IContentType, SpellingEngine>();
+ private Map<IContentType, SpellingEngine> fEngines = new HashMap<IContentType, SpellingEngine>();
private ISpellingEngine defaultEngine;
/**
@@ -66,10 +70,9 @@ public class SpellingEngineDispatcher implements ISpellingEngine {
if (CXXSOURCE_CONTENT_TYPE != null)
fEngines.put(CXXSOURCE_CONTENT_TYPE, engine);
try {
- SpellingEngineDescriptor descriptor =
- EditorsUI.getSpellingService().getDefaultSpellingEngineDescriptor();
- if (!C_SPELLING_ENGINE_ID.equals(descriptor.getId())) { // Do not delegate to itself.
- defaultEngine = descriptor.createEngine();
+ SpellingEngineDescriptor descriptor = EditorsUI.getSpellingService().getDefaultSpellingEngineDescriptor();
+ if (!C_SPELLING_ENGINE_ID.equals(descriptor.getId())) { // Do not delegate to itself.
+ defaultEngine = descriptor.createEngine();
}
} catch (CoreException e) {
}
@@ -79,10 +82,11 @@ public class SpellingEngineDispatcher implements ISpellingEngine {
* @see org.eclipse.ui.texteditor.spelling.ISpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.ui.texteditor.spelling.SpellingContext, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void check(IDocument document, IRegion[] regions, SpellingContext context, ISpellingProblemCollector collector, IProgressMonitor monitor) {
- ISpellingEngine engine= getEngine(context.getContentType());
+ public void check(IDocument document, IRegion[] regions, SpellingContext context,
+ ISpellingProblemCollector collector, IProgressMonitor monitor) {
+ ISpellingEngine engine = getEngine(context.getContentType());
if (engine == null)
- engine= defaultEngine;
+ engine = defaultEngine;
if (engine != null)
engine.check(document, regions, context, collector, monitor);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.java
index 63a5424136d..2de685c8ba0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.java
@@ -37,20 +37,20 @@ public class SpellingPreferences {
private static final String SPELLING_IGNORE_STRING_LITERALS = PreferenceConstants.SPELLING_IGNORE_STRING_LITERALS;
private static final String SPELLING_IGNORE_UPPER = PreferenceConstants.SPELLING_IGNORE_UPPER;
private static final String SPELLING_IGNORE_URLS = PreferenceConstants.SPELLING_IGNORE_URLS;
-
+
/**
* @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
*/
- public static void addPropertyChangeListener(IPropertyChangeListener listener) {
- preferenceStore.addPropertyChangeListener(listener);
- }
-
+ public static void addPropertyChangeListener(IPropertyChangeListener listener) {
+ preferenceStore.addPropertyChangeListener(listener);
+ }
+
/**
* @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
*/
- public static void removePropertyChangeListener(IPropertyChangeListener listener) {
- preferenceStore.removePropertyChangeListener(listener);
- }
+ public static void removePropertyChangeListener(IPropertyChangeListener listener) {
+ preferenceStore.removePropertyChangeListener(listener);
+ }
/**
* The locale used for spell checking.
@@ -58,21 +58,21 @@ public class SpellingPreferences {
public static String getSpellingLocale() {
return preferenceStore.getString(SPELLING_LOCALE);
}
-
+
/**
* The workspace user dictionary.
*/
public static String getSpellingUserDictionary() {
return preferenceStore.getString(SPELLING_USER_DICTIONARY);
}
-
+
/**
* The encoding of the workspace user dictionary.
*/
public static String getSpellingUserDictionaryEncoding() {
return preferenceStore.getString(SPELLING_USER_DICTIONARY_ENCODING);
}
-
+
/**
* Returns the number of proposals offered during spell checking.
*/
@@ -86,7 +86,7 @@ public class SpellingPreferences {
public static boolean isEnabledSpellingContentAssist() {
return preferenceStore.getBoolean(SPELLING_ENABLE_CONTENTASSIST);
}
-
+
/**
* Returns <code>true</code> if words containing digits should
* be skipped during spell checking.
@@ -102,7 +102,7 @@ public class SpellingPreferences {
public static boolean isIgnoreMixed() {
return preferenceStore.getBoolean(SPELLING_IGNORE_MIXED);
}
-
+
/**
* Returns <code>true</code> if non-letters at word boundaries
* should be ignored during spell checking.
@@ -110,7 +110,7 @@ public class SpellingPreferences {
public static boolean isIgnoreNonLetters() {
return preferenceStore.getBoolean(SPELLING_IGNORE_NON_LETTERS);
}
-
+
/**
* Returns <code>true</code> if sentence capitalization should
* be ignored during spell checking.
@@ -118,7 +118,7 @@ public class SpellingPreferences {
public static boolean isIgnoreSentence() {
return preferenceStore.getBoolean(SPELLING_IGNORE_SENTENCE);
}
-
+
/**
* Returns <code>true</code> if single letters
* should be ignored during spell checking.
@@ -126,7 +126,7 @@ public class SpellingPreferences {
public static boolean isIgnoreSingleLetters() {
return preferenceStore.getBoolean(SPELLING_IGNORE_SINGLE_LETTERS);
}
-
+
/**
* Returns <code>true</code> if string literals
* should be ignored during spell checking.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.java
index 116f8b89603..23507a0348f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.java
@@ -45,7 +45,7 @@ public class TaskTagDictionary extends AbstractSpellDictionary implements IPrope
*/
@Override
protected synchronized boolean load(final URL url) {
- final CUIPlugin plugin= CUIPlugin.getDefault();
+ final CUIPlugin plugin = CUIPlugin.getDefault();
if (plugin != null) {
plugin.getCorePreferenceStore().addPropertyChangeListener(this);
return updateTaskTags();
@@ -67,7 +67,7 @@ public class TaskTagDictionary extends AbstractSpellDictionary implements IPrope
*/
@Override
public synchronized void unload() {
- final CUIPlugin plugin= CUIPlugin.getDefault();
+ final CUIPlugin plugin = CUIPlugin.getDefault();
if (plugin != null)
plugin.getCorePreferenceStore().removePropertyChangeListener(this);
@@ -76,15 +76,15 @@ public class TaskTagDictionary extends AbstractSpellDictionary implements IPrope
/**
* Handles the compiler task tags property change event.
- *
+ *
* @return <code>true</code> if the task tags got updated
*/
protected boolean updateTaskTags() {
- final String tags= CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_TAGS);
+ final String tags = CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_TAGS);
if (tags != null) {
unload();
- final StringTokenizer tokenizer= new StringTokenizer(tags, ","); //$NON-NLS-1$
+ final StringTokenizer tokenizer = new StringTokenizer(tags, ","); //$NON-NLS-1$
while (tokenizer.hasMoreTokens())
hashWord(tokenizer.nextToken());
@@ -92,7 +92,7 @@ public class TaskTagDictionary extends AbstractSpellDictionary implements IPrope
}
return false;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#stripNonLetters(java.lang.String)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.java
index 1c8cc7e74bb..21e122bfefc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.java
@@ -33,11 +33,12 @@ public class TextSpellingEngine extends SpellingEngine {
* @see org.eclipse.cdt.internal.ui.text.spelling.SpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- protected void check(IDocument document, IRegion[] regions, ISpellChecker checker, ISpellingProblemCollector collector, IProgressMonitor monitor) {
- ISpellEventListener listener= new SpellEventListener(collector, document);
+ protected void check(IDocument document, IRegion[] regions, ISpellChecker checker,
+ ISpellingProblemCollector collector, IProgressMonitor monitor) {
+ ISpellEventListener listener = new SpellEventListener(collector, document);
try {
checker.addListener(listener);
- for (int i= 0; i < regions.length; i++) {
+ for (int i = 0; i < regions.length; i++) {
if (monitor != null && monitor.isCanceled())
return;
checker.execute(new SpellCheckIterator(document, regions[i], checker.getLocale()));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java
index 02a406ff4e2..898b4a96a09 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java
@@ -44,44 +44,47 @@ import org.eclipse.cdt.internal.ui.text.spelling.engine.RankedWordProposal;
*/
public final class WordCompletionProposalComputer implements ICompletionProposalComputer {
/** The prefix rank shift */
- private static final int PREFIX_RANK_SHIFT= 500;
+ private static final int PREFIX_RANK_SHIFT = 500;
/*
* @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
if (contributes()) {
try {
- IDocument document= context.getDocument();
- final int offset= context.getInvocationOffset();
-
- final IRegion region= document.getLineInformationOfOffset(offset);
- final String content= document.get(region.getOffset(), region.getLength());
-
- int index= offset - region.getOffset() - 1;
+ IDocument document = context.getDocument();
+ final int offset = context.getInvocationOffset();
+
+ final IRegion region = document.getLineInformationOfOffset(offset);
+ final String content = document.get(region.getOffset(), region.getLength());
+
+ int index = offset - region.getOffset() - 1;
while (index >= 0 && Character.isLetter(content.charAt(index)))
index--;
-
- final int start= region.getOffset() + index + 1;
- final String candidate= content.substring(index + 1, offset - region.getOffset());
-
+
+ final int start = region.getOffset() + index + 1;
+ final String candidate = content.substring(index + 1, offset - region.getOffset());
+
if (candidate.length() > 0) {
- final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
- final ISpellChecker checker= engine.getSpellChecker();
-
+ final ISpellCheckEngine engine = SpellCheckEngine.getInstance();
+ final ISpellChecker checker = engine.getSpellChecker();
+
if (checker != null) {
- final List<RankedWordProposal> proposals= new ArrayList<RankedWordProposal>(checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0))));
- final List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(proposals.size());
-
+ final List<RankedWordProposal> proposals = new ArrayList<RankedWordProposal>(
+ checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0))));
+ final List<ICompletionProposal> result = new ArrayList<ICompletionProposal>(proposals.size());
+
for (Object element : proposals) {
- RankedWordProposal word= (RankedWordProposal) element;
- String text= word.getText();
+ RankedWordProposal word = (RankedWordProposal) element;
+ String text = word.getText();
if (text.startsWith(candidate))
word.setRank(word.getRank() + PREFIX_RANK_SHIFT);
-
+
result.add(new CCompletionProposal(text, start, candidate.length(),
- CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_RENAME), text, word.getRank()) {
+ CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_RENAME), text,
+ word.getRank()) {
/*
* @see org.eclipse.cdt.internal.ui.text.java.JavaCompletionProposal#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
*/
@@ -91,7 +94,7 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
}
});
}
-
+
return result;
}
}
@@ -111,7 +114,8 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
* @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
return Collections.emptyList();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal.java
index 60298a36084..ecdbbfcc60a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal.java
@@ -60,17 +60,18 @@ public class WordCorrectionProposal implements ICCompletionProposal {
* @param context the invocation context for this proposal
* @param relevance the relevance of this proposal
*/
- public WordCorrectionProposal(final String word, final String[] arguments, final int offset,
- final int length, final IInvocationContext context, final int relevance) {
- fWord= Character.isUpperCase(arguments[0].charAt(0)) ?
- Character.toUpperCase(word.charAt(0)) + word.substring(1) : word;
+ public WordCorrectionProposal(final String word, final String[] arguments, final int offset, final int length,
+ final IInvocationContext context, final int relevance) {
+ fWord = Character.isUpperCase(arguments[0].charAt(0))
+ ? Character.toUpperCase(word.charAt(0)) + word.substring(1)
+ : word;
- fOffset= offset;
- fLength= length;
- fContext= context;
- fRelevance= relevance;
+ fOffset = offset;
+ fLength = length;
+ fContext = context;
+ fRelevance = relevance;
- final StringBuilder buffer= new StringBuilder(80);
+ final StringBuilder buffer = new StringBuilder(80);
buffer.append("...<br>"); //$NON-NLS-1$
buffer.append(getHtmlRepresentation(arguments[1]));
@@ -80,7 +81,7 @@ public class WordCorrectionProposal implements ICCompletionProposal {
buffer.append(getHtmlRepresentation(arguments[2]));
buffer.append("<br>..."); //$NON-NLS-1$
- fLine= buffer.toString();
+ fLine = buffer.toString();
}
/*
@@ -140,10 +141,10 @@ public class WordCorrectionProposal implements ICCompletionProposal {
*/
@Override
public final Point getSelection(final IDocument document) {
- int offset= fContext.getSelectionOffset();
- int length= fContext.getSelectionLength();
+ int offset = fContext.getSelectionOffset();
+ int length = fContext.getSelectionLength();
- final int delta= fWord.length() - fLength;
+ final int delta = fWord.length() - fLength;
if (offset <= fOffset && offset + length >= fOffset) {
length += delta;
} else if (offset > fOffset && offset + length > fOffset + fLength) {
@@ -155,7 +156,7 @@ public class WordCorrectionProposal implements ICCompletionProposal {
return new Point(offset, length);
}
-
+
/**
* Returns the html representation of the specified string.
*
@@ -163,11 +164,11 @@ public class WordCorrectionProposal implements ICCompletionProposal {
* @return The html representation for the string
*/
public static String getHtmlRepresentation(final String string) {
- final int length= string.length();
- final StringBuilder buffer= new StringBuilder(string);
+ final int length = string.length();
+ final StringBuilder buffer = new StringBuilder(string);
- for (int offset= length - 1; offset >= 0; offset--) {
- for (int index= 0; index < IHtmlTagConstants.HTML_ENTITY_CHARACTERS.length; index++) {
+ for (int offset = length - 1; offset >= 0; offset--) {
+ for (int index = 0; index < IHtmlTagConstants.HTML_ENTITY_CHARACTERS.length; index++) {
if (string.charAt(offset) == IHtmlTagConstants.HTML_ENTITY_CHARACTERS[index]) {
buffer.replace(offset, offset + 1, String.valueOf(IHtmlTagConstants.HTML_ENTITY_CODES[index]));
break;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.java
index c373b5d1dd3..420907715bf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.java
@@ -48,8 +48,8 @@ public class WordIgnoreProposal implements ICCompletionProposal {
* @param context The invocation context
*/
public WordIgnoreProposal(final String word, final IInvocationContext context) {
- fWord= word;
- fContext= context;
+ fWord = word;
+ fContext = context;
}
/*
@@ -57,17 +57,17 @@ public class WordIgnoreProposal implements ICCompletionProposal {
*/
@Override
public final void apply(final IDocument document) {
- final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
- final ISpellChecker checker= engine.getSpellChecker();
- if (checker != null) {
- checker.ignoreWord(fWord);
- if (fContext instanceof IQuickAssistInvocationContext) {
- ISourceViewer sourceViewer= ((IQuickAssistInvocationContext) fContext).getSourceViewer();
- if (sourceViewer != null) {
- SpellingProblem.removeAll(sourceViewer, fWord);
- }
- }
- }
+ final ISpellCheckEngine engine = SpellCheckEngine.getInstance();
+ final ISpellChecker checker = engine.getSpellChecker();
+ if (checker != null) {
+ checker.ignoreWord(fWord);
+ if (fContext instanceof IQuickAssistInvocationContext) {
+ ISourceViewer sourceViewer = ((IQuickAssistInvocationContext) fContext).getSourceViewer();
+ if (sourceViewer != null) {
+ SpellingProblem.removeAll(sourceViewer, fWord);
+ }
+ }
+ }
}
/*
@@ -101,6 +101,7 @@ public class WordIgnoreProposal implements ICCompletionProposal {
public Image getImage() {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_NLS_NEVER_TRANSLATE);
}
+
/*
* @see org.eclipse.cdt.ui.text.java.IJavaCompletionProposal#getRelevance()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java
index 8f8a7027ce4..08a433a0848 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java
@@ -46,59 +46,64 @@ public class WordQuickFixProcessor implements IQuickFixProcessor {
* @see org.eclipse.cdt.ui.text.java.IQuickFixProcessor#getCorrections(org.eclipse.cdt.ui.text.java.ContentAssistInvocationContext,org.eclipse.cdt.ui.text.java.IProblemLocation[])
*/
@Override
- public ICCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException {
- final int threshold= SpellingPreferences.spellingProposalThreshold();
+ public ICCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations)
+ throws CoreException {
+ final int threshold = SpellingPreferences.spellingProposalThreshold();
- int size= 0;
- List<RankedWordProposal> proposals= null;
- String[] arguments= null;
+ int size = 0;
+ List<RankedWordProposal> proposals = null;
+ String[] arguments = null;
- IProblemLocation location= null;
- RankedWordProposal proposal= null;
- ICCompletionProposal[] result= null;
+ IProblemLocation location = null;
+ RankedWordProposal proposal = null;
+ ICCompletionProposal[] result = null;
- boolean fixed= false;
- boolean match= false;
- boolean sentence= false;
+ boolean fixed = false;
+ boolean match = false;
+ boolean sentence = false;
- final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
- final ISpellChecker checker= engine.getSpellChecker();
+ final ISpellCheckEngine engine = SpellCheckEngine.getInstance();
+ final ISpellChecker checker = engine.getSpellChecker();
if (checker != null) {
- for (int index= 0; index < locations.length; index++) {
- location= locations[index];
+ for (int index = 0; index < locations.length; index++) {
+ location = locations[index];
if (location.getProblemId() == CSpellingReconcileStrategy.SPELLING_PROBLEM_ID) {
- arguments= location.getProblemArguments();
+ arguments = location.getProblemArguments();
if (arguments != null && arguments.length > 4) {
- sentence= Boolean.valueOf(arguments[3]).booleanValue();
- match= Boolean.valueOf(arguments[4]).booleanValue();
- fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX;
+ sentence = Boolean.valueOf(arguments[3]).booleanValue();
+ match = Boolean.valueOf(arguments[4]).booleanValue();
+ fixed = arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX;
if ((sentence && match) && !fixed) {
- result= new ICCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())};
+ result = new ICCompletionProposal[] { new ChangeCaseProposal(arguments,
+ location.getOffset(), location.getLength(), context, engine.getLocale()) };
} else {
- proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
- size= proposals.size();
+ proposals = new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
+ size = proposals.size();
if (threshold > 0 && size > threshold) {
Collections.sort(proposals);
- proposals= proposals.subList(size - threshold - 1, size - 1);
- size= proposals.size();
+ proposals = proposals.subList(size - threshold - 1, size - 1);
+ size = proposals.size();
}
- boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false;
- result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
+ boolean extendable = !fixed
+ ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure())
+ : false;
+ result = new ICCompletionProposal[size + (extendable ? 3 : 2)];
- for (index= 0; index < size; index++) {
- proposal= proposals.get(index);
- result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
+ for (index = 0; index < size; index++) {
+ proposal = proposals.get(index);
+ result[index] = new WordCorrectionProposal(proposal.getText(), arguments,
+ location.getOffset(), location.getLength(), context, proposal.getRank());
}
if (extendable)
- result[index++]= new AddWordProposal(arguments[0], context);
+ result[index++] = new AddWordProposal(arguments[0], context);
- result[index++]= new WordIgnoreProposal(arguments[0], context);
- result[index++]= new DisableSpellCheckingProposal(context);
+ result[index++] = new WordIgnoreProposal(arguments[0], context);
+ result[index++] = new DisableSpellCheckingProposal(context);
}
break;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
index 810b07a4fa7..6a3afc60ece 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
@@ -49,37 +49,37 @@ import org.eclipse.cdt.internal.ui.text.spelling.SpellingPreferences;
*/
public abstract class AbstractSpellDictionary implements ISpellDictionary {
/** The bucket capacity */
- protected static final int BUCKET_CAPACITY= 4;
+ protected static final int BUCKET_CAPACITY = 4;
/** The word buffer capacity */
- protected static final int BUFFER_CAPACITY= 32;
+ protected static final int BUFFER_CAPACITY = 32;
/** The distance threshold */
- protected static final int DISTANCE_THRESHOLD= 160;
+ protected static final int DISTANCE_THRESHOLD = 160;
/** The hash capacity */
- protected static final int HASH_CAPACITY= 22 * 1024;
+ protected static final int HASH_CAPACITY = 22 * 1024;
/** The phonetic distance algorithm */
- private IPhoneticDistanceAlgorithm fDistanceAlgorithm= new DefaultPhoneticDistanceAlgorithm();
+ private IPhoneticDistanceAlgorithm fDistanceAlgorithm = new DefaultPhoneticDistanceAlgorithm();
/** The mapping from phonetic hashes to word lists */
- private final Map<String, Serializable> fHashBuckets= new HashMap<String, Serializable>(HASH_CAPACITY);
+ private final Map<String, Serializable> fHashBuckets = new HashMap<String, Serializable>(HASH_CAPACITY);
/** The phonetic hash provider */
- private IPhoneticHashProvider fHashProvider= new DefaultPhoneticHashProvider();
+ private IPhoneticHashProvider fHashProvider = new DefaultPhoneticHashProvider();
/** Is the dictionary already loaded? */
- private boolean fLoaded= false;
+ private boolean fLoaded = false;
/**
* Must the dictionary be loaded?
*/
- private boolean fMustLoad= true;
+ private boolean fMustLoad = true;
/**
* Tells whether to strip non-letters at word boundaries.
*/
- boolean fIsStrippingNonLetters= true;
+ boolean fIsStrippingNonLetters = true;
/**
* Returns all candidates with the same phonetic hash.
@@ -105,24 +105,25 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* Array of close hashes to find the matches
* @return Set of ranked words with bounded distance to the specified word
*/
- protected final Set<RankedWordProposal> getCandidates(final String word, final boolean sentence, final ArrayList<String> hashs) {
+ protected final Set<RankedWordProposal> getCandidates(final String word, final boolean sentence,
+ final ArrayList<String> hashs) {
- int distance= 0;
- String hash= null;
+ int distance = 0;
+ String hash = null;
- final StringBuilder buffer= new StringBuilder(BUFFER_CAPACITY);
- final HashSet<RankedWordProposal> result= new HashSet<RankedWordProposal>(BUCKET_CAPACITY * hashs.size());
+ final StringBuilder buffer = new StringBuilder(BUFFER_CAPACITY);
+ final HashSet<RankedWordProposal> result = new HashSet<RankedWordProposal>(BUCKET_CAPACITY * hashs.size());
- for (int index= 0; index < hashs.size(); index++) {
+ for (int index = 0; index < hashs.size(); index++) {
- hash= hashs.get(index);
+ hash = hashs.get(index);
- final Object candidates= getCandidates(hash);
+ final Object candidates = getCandidates(hash);
if (candidates == null)
continue;
else if (candidates instanceof String) {
- String candidate= (String)candidates;
- distance= fDistanceAlgorithm.getDistance(word, candidate);
+ String candidate = (String) candidates;
+ distance = fDistanceAlgorithm.getDistance(word, candidate);
if (distance < DISTANCE_THRESHOLD) {
buffer.setLength(0);
buffer.append(candidate);
@@ -134,11 +135,11 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
}
@SuppressWarnings("unchecked")
- final ArrayList<String> candidateList= (ArrayList<String>)candidates;
- for (int offset= 0; offset < candidateList.size(); offset++) {
+ final ArrayList<String> candidateList = (ArrayList<String>) candidates;
+ for (int offset = 0; offset < candidateList.size(); offset++) {
- String candidate= candidateList.get(offset);
- distance= fDistanceAlgorithm.getDistance(word, candidate);
+ String candidate = candidateList.get(offset);
+ distance = fDistanceAlgorithm.getDistance(word, candidate);
if (distance < DISTANCE_THRESHOLD) {
@@ -168,19 +169,20 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* Set of ranked words with smallest possible distance to the
* specified word
*/
- protected final void getCandidates(final String word, final boolean sentence, final Set<RankedWordProposal> result) {
+ protected final void getCandidates(final String word, final boolean sentence,
+ final Set<RankedWordProposal> result) {
- int distance= 0;
- int minimum= Integer.MAX_VALUE;
+ int distance = 0;
+ int minimum = Integer.MAX_VALUE;
- StringBuilder buffer= new StringBuilder(BUFFER_CAPACITY);
+ StringBuilder buffer = new StringBuilder(BUFFER_CAPACITY);
- final Object candidates= getCandidates(fHashProvider.getHash(word));
+ final Object candidates = getCandidates(fHashProvider.getHash(word));
if (candidates == null)
return;
else if (candidates instanceof String) {
- String candidate= (String)candidates;
- distance= fDistanceAlgorithm.getDistance(word, candidate);
+ String candidate = (String) candidates;
+ distance = fDistanceAlgorithm.getDistance(word, candidate);
buffer.append(candidate);
if (sentence)
buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0)));
@@ -189,15 +191,15 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
}
@SuppressWarnings("unchecked")
- final ArrayList<String> candidateList= (ArrayList<String>)candidates;
- final ArrayList<RankedWordProposal> matches= new ArrayList<RankedWordProposal>(candidateList.size());
+ final ArrayList<String> candidateList = (ArrayList<String>) candidates;
+ final ArrayList<RankedWordProposal> matches = new ArrayList<RankedWordProposal>(candidateList.size());
- for (int index= 0; index < candidateList.size(); index++) {
- String candidate= candidateList.get(index);
- distance= fDistanceAlgorithm.getDistance(word, candidate);
+ for (int index = 0; index < candidateList.size(); index++) {
+ String candidate = candidateList.get(index);
+ distance = fDistanceAlgorithm.getDistance(word, candidate);
if (distance <= minimum) {
-
+
if (distance < minimum)
matches.clear();
@@ -208,16 +210,16 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0)));
matches.add(new RankedWordProposal(buffer.toString(), -distance));
- minimum= distance;
+ minimum = distance;
}
}
result.addAll(matches);
}
-
+
/**
* Tells whether this dictionary is empty.
- *
+ *
* @return <code>true</code> if this dictionary is empty
*/
protected boolean isEmpty() {
@@ -252,7 +254,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
if (!fLoaded) {
synchronized (this) {
- fLoaded= load(getURL());
+ fLoaded = load(getURL());
if (fLoaded)
compact();
}
@@ -262,75 +264,75 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
// Do nothing
}
- final String hash= fHashProvider.getHash(word);
- final char[] mutators= fHashProvider.getMutators();
+ final String hash = fHashProvider.getHash(word);
+ final char[] mutators = fHashProvider.getMutators();
- final ArrayList<String> neighborhood= new ArrayList<String>((word.length() + 1) * (mutators.length + 2));
+ final ArrayList<String> neighborhood = new ArrayList<String>((word.length() + 1) * (mutators.length + 2));
neighborhood.add(hash);
- final Set<RankedWordProposal> candidates= getCandidates(word, sentence, neighborhood);
+ final Set<RankedWordProposal> candidates = getCandidates(word, sentence, neighborhood);
neighborhood.clear();
- char previous= 0;
- char next= 0;
+ char previous = 0;
+ char next = 0;
- char[] characters= word.toCharArray();
- for (int index= 0; index < word.length() - 1; index++) {
+ char[] characters = word.toCharArray();
+ for (int index = 0; index < word.length() - 1; index++) {
- next= characters[index];
- previous= characters[index + 1];
+ next = characters[index];
+ previous = characters[index + 1];
- characters[index]= previous;
- characters[index + 1]= next;
+ characters[index] = previous;
+ characters[index + 1] = next;
neighborhood.add(fHashProvider.getHash(new String(characters)));
- characters[index]= next;
- characters[index + 1]= previous;
+ characters[index] = next;
+ characters[index + 1] = previous;
}
- final String sentinel= word + " "; //$NON-NLS-1$
+ final String sentinel = word + " "; //$NON-NLS-1$
- characters= sentinel.toCharArray();
- int offset= characters.length - 1;
+ characters = sentinel.toCharArray();
+ int offset = characters.length - 1;
while (true) {
for (char mutator : mutators) {
- characters[offset]= mutator;
+ characters[offset] = mutator;
neighborhood.add(fHashProvider.getHash(new String(characters)));
}
if (offset == 0)
break;
- characters[offset]= characters[offset - 1];
+ characters[offset] = characters[offset - 1];
--offset;
}
- char mutated= 0;
- characters= word.toCharArray();
+ char mutated = 0;
+ characters = word.toCharArray();
- for (int index= 0; index < word.length(); index++) {
+ for (int index = 0; index < word.length(); index++) {
- mutated= characters[index];
+ mutated = characters[index];
for (char mutator2 : mutators) {
- characters[index]= mutator2;
+ characters[index] = mutator2;
neighborhood.add(fHashProvider.getHash(new String(characters)));
}
- characters[index]= mutated;
+ characters[index] = mutated;
}
- characters= word.toCharArray();
- final char[] deleted= new char[characters.length - 1];
+ characters = word.toCharArray();
+ final char[] deleted = new char[characters.length - 1];
- for (int index= 0; index < deleted.length; index++)
- deleted[index]= characters[index];
+ for (int index = 0; index < deleted.length; index++)
+ deleted[index] = characters[index];
- next= characters[characters.length - 1];
- offset= deleted.length;
+ next = characters[characters.length - 1];
+ offset = deleted.length;
while (true) {
@@ -338,15 +340,15 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
if (offset == 0)
break;
- previous= next;
- next= deleted[offset - 1];
+ previous = next;
+ next = deleted[offset - 1];
- deleted[offset - 1]= previous;
+ deleted[offset - 1] = previous;
--offset;
}
neighborhood.remove(hash);
- final Set<RankedWordProposal> matches= getCandidates(word, sentence, neighborhood);
+ final Set<RankedWordProposal> matches = getCandidates(word, sentence, neighborhood);
if (matches.size() == 0 && candidates.size() == 0)
getCandidates(word, sentence, candidates);
@@ -373,17 +375,17 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
*/
protected final void hashWord(final String word) {
- final String hash= fHashProvider.getHash(word);
- Object bucket= fHashBuckets.get(hash);
+ final String hash = fHashProvider.getHash(word);
+ Object bucket = fHashBuckets.get(hash);
if (bucket == null) {
fHashBuckets.put(hash, word);
} else if (bucket instanceof ArrayList<?>) {
- @SuppressWarnings({"unchecked", "rawtypes"})
- final ArrayList<Object> bucket2 = (ArrayList)bucket;
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ final ArrayList<Object> bucket2 = (ArrayList) bucket;
bucket2.add(word);
} else {
- ArrayList<Object> list= new ArrayList<Object>(BUCKET_CAPACITY);
+ ArrayList<Object> list = new ArrayList<Object>(BUCKET_CAPACITY);
list.add(bucket);
list.add(word);
fHashBuckets.put(hash, list);
@@ -395,12 +397,12 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
*/
@Override
public boolean isCorrect(String word) {
- word= stripNonLetters(word);
+ word = stripNonLetters(word);
try {
-
+
if (!fLoaded) {
synchronized (this) {
- fLoaded= load(getURL());
+ fLoaded = load(getURL());
if (fLoaded)
compact();
}
@@ -410,55 +412,55 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
// Do nothing
}
- final Object candidates= getCandidates(fHashProvider.getHash(word));
+ final Object candidates = getCandidates(fHashProvider.getHash(word));
if (candidates == null)
return false;
else if (candidates instanceof String) {
- String candidate= (String)candidates;
+ String candidate = (String) candidates;
if (candidate.equals(word) || candidate.equals(word.toLowerCase()))
return true;
return false;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
- final ArrayList<String> candidateList= (ArrayList)candidates;
+ final ArrayList<String> candidateList = (ArrayList) candidates;
if (candidateList.contains(word) || candidateList.contains(word.toLowerCase()))
return true;
return false;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#setStripNonLetters(boolean)
*/
@Override
public void setStripNonLetters(boolean state) {
- fIsStrippingNonLetters= state;
+ fIsStrippingNonLetters = state;
}
-
+
/**
* Strips non-letter characters from the given word.
* <p>
* This will only happen if the corresponding preference is enabled.
* </p>
- *
+ *
* @param word the word to strip
* @return the stripped word
*/
protected String stripNonLetters(String word) {
if (!fIsStrippingNonLetters)
return word;
-
- int i= 0;
- int j= word.length() - 1;
+
+ int i = 0;
+ int j = word.length() - 1;
while (i <= j && !Character.isLetter(word.charAt(i)))
i++;
if (i > j)
return ""; //$NON-NLS-1$
-
+
while (j > i && !Character.isLetter(word.charAt(j)))
j--;
-
- return word.substring(i, j+1);
+
+ return word.substring(i, j + 1);
}
/*
@@ -478,51 +480,51 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* otherwise
*/
protected synchronized boolean load(final URL url) {
- if (!fMustLoad)
- return fLoaded;
+ if (!fMustLoad)
+ return fLoaded;
if (url != null) {
- InputStream stream= null;
- int line= 0;
+ InputStream stream = null;
+ int line = 0;
try {
- stream= url.openStream();
+ stream = url.openStream();
if (stream != null) {
- String word= null;
-
+ String word = null;
+
// Setup a reader with a decoder in order to read over malformed input if needed.
- CharsetDecoder decoder= Charset.forName(getEncoding()).newDecoder();
+ CharsetDecoder decoder = Charset.forName(getEncoding()).newDecoder();
decoder.onMalformedInput(CodingErrorAction.REPORT);
decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
- final BufferedReader reader= new BufferedReader(new InputStreamReader(stream, decoder));
-
- boolean doRead= true;
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, decoder));
+
+ boolean doRead = true;
while (doRead) {
try {
- word= reader.readLine();
+ word = reader.readLine();
} catch (MalformedInputException ex) {
// Tell the decoder to replace malformed input in order to read the line.
decoder.onMalformedInput(CodingErrorAction.REPLACE);
decoder.reset();
- word= reader.readLine();
+ word = reader.readLine();
decoder.onMalformedInput(CodingErrorAction.REPORT);
-
- String message= NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
+
+ String message = NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
new String[] { word, decoder.replacement(), url.toString() });
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, ex);
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, ex);
CUIPlugin.log(status);
-
- doRead= word != null;
+
+ doRead = word != null;
continue;
}
- doRead= word != null;
+ doRead = word != null;
if (doRead)
hashWord(word);
}
return true;
}
} catch (FileNotFoundException e) {
- String urlString= url.toString();
- String lowercaseUrlString= urlString.toLowerCase();
+ String urlString = url.toString();
+ String lowercaseUrlString = urlString.toLowerCase();
if (urlString.equals(lowercaseUrlString)) {
CUIPlugin.log(e);
} else {
@@ -534,15 +536,15 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
}
} catch (IOException exception) {
if (line > 0) {
- String message= NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
- String.valueOf(line), url.toString());
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, exception);
+ String message = NLS.bind(Messages.AbstractSpellingDictionary_encodingError, String.valueOf(line),
+ url.toString());
+ IStatus status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, exception);
CUIPlugin.log(status);
} else {
CUIPlugin.log(exception);
}
} finally {
- fMustLoad= false;
+ fMustLoad = false;
try {
if (stream != null)
stream.close();
@@ -557,11 +559,11 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* Compacts the dictionary.
*/
private void compact() {
- Iterator<Serializable> iter= fHashBuckets.values().iterator();
+ Iterator<Serializable> iter = fHashBuckets.values().iterator();
while (iter.hasNext()) {
- Object element= iter.next();
+ Object element = iter.next();
if (element instanceof ArrayList<?>)
- ((ArrayList<?>)element).trimToSize();
+ ((ArrayList<?>) element).trimToSize();
}
}
@@ -572,7 +574,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* The phonetic distance algorithm
*/
protected final void setDistanceAlgorithm(final IPhoneticDistanceAlgorithm algorithm) {
- fDistanceAlgorithm= algorithm;
+ fDistanceAlgorithm = algorithm;
}
/**
@@ -582,7 +584,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* The phonetic hash provider
*/
protected final void setHashProvider(final IPhoneticHashProvider provider) {
- fHashProvider= provider;
+ fHashProvider = provider;
}
/*
@@ -590,8 +592,8 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
*/
@Override
public synchronized void unload() {
- fLoaded= false;
- fMustLoad= true;
+ fLoaded = false;
+ fMustLoad = true;
fHashBuckets.clear();
}
@@ -610,16 +612,16 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
public void addWord(final String word) {
// Do nothing
}
-
+
/**
* Returns the encoding of this dictionary.
- *
+ *
* @return the encoding of this dictionary
*/
protected String getEncoding() {
- String encoding= SpellingPreferences.getSpellingUserDictionaryEncoding();
+ String encoding = SpellingPreferences.getSpellingUserDictionaryEncoding();
if (encoding == null || encoding.isEmpty())
- encoding= ResourcesPlugin.getEncoding();
+ encoding = ResourcesPlugin.getEncoding();
return encoding;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java
index b82451d1ab7..9e5111271c4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java
@@ -24,19 +24,19 @@ package org.eclipse.cdt.internal.ui.text.spelling.engine;
public final class DefaultPhoneticDistanceAlgorithm implements IPhoneticDistanceAlgorithm {
/** The change case cost */
- public static final int COST_CASE= 10;
+ public static final int COST_CASE = 10;
/** The insert character cost */
- public static final int COST_INSERT= 95;
+ public static final int COST_INSERT = 95;
/** The remove character cost */
- public static final int COST_REMOVE= 95;
+ public static final int COST_REMOVE = 95;
/** The substitute characters cost */
- public static final int COST_SUBSTITUTE= 100;
+ public static final int COST_SUBSTITUTE = 100;
/** The swap characters cost */
- public static final int COST_SWAP= 90;
+ public static final int COST_SWAP = 90;
/*
* @see org.eclipse.spelling.done.IPhoneticDistanceAlgorithm#getDistance(java.lang.String,java.lang.String)
@@ -44,61 +44,61 @@ public final class DefaultPhoneticDistanceAlgorithm implements IPhoneticDistance
@Override
public final int getDistance(final String from, final String to) {
- final char[] first= (" " + from).toCharArray(); //$NON-NLS-1$
- final char[] second= (" " + to).toCharArray(); //$NON-NLS-1$
+ final char[] first = (" " + from).toCharArray(); //$NON-NLS-1$
+ final char[] second = (" " + to).toCharArray(); //$NON-NLS-1$
- final int rows= first.length;
- final int columns= second.length;
+ final int rows = first.length;
+ final int columns = second.length;
- final int[][] metric= new int[rows][columns];
- for (int column= 1; column < columns; column++)
- metric[0][column]= metric[0][column - 1] + COST_REMOVE;
+ final int[][] metric = new int[rows][columns];
+ for (int column = 1; column < columns; column++)
+ metric[0][column] = metric[0][column - 1] + COST_REMOVE;
- for (int row= 1; row < rows; row++)
- metric[row][0]= metric[row - 1][0] + COST_INSERT;
+ for (int row = 1; row < rows; row++)
+ metric[row][0] = metric[row - 1][0] + COST_INSERT;
char source, target;
- int swap= Integer.MAX_VALUE;
- int change= Integer.MAX_VALUE;
+ int swap = Integer.MAX_VALUE;
+ int change = Integer.MAX_VALUE;
int minimum, diagonal, insert, remove;
- for (int row= 1; row < rows; row++) {
+ for (int row = 1; row < rows; row++) {
- source= first[row];
- for (int column= 1; column < columns; column++) {
+ source = first[row];
+ for (int column = 1; column < columns; column++) {
- target= second[column];
- diagonal= metric[row - 1][column - 1];
+ target = second[column];
+ diagonal = metric[row - 1][column - 1];
if (source == target) {
- metric[row][column]= diagonal;
+ metric[row][column] = diagonal;
continue;
}
- change= Integer.MAX_VALUE;
+ change = Integer.MAX_VALUE;
if (Character.toLowerCase(source) == Character.toLowerCase(target))
- change= COST_CASE + diagonal;
+ change = COST_CASE + diagonal;
- swap= Integer.MAX_VALUE;
+ swap = Integer.MAX_VALUE;
if (row != 1 && column != 1 && source == second[column - 1] && first[row - 1] == target)
- swap= COST_SWAP + metric[row - 2][column - 2];
+ swap = COST_SWAP + metric[row - 2][column - 2];
- minimum= COST_SUBSTITUTE + diagonal;
+ minimum = COST_SUBSTITUTE + diagonal;
if (swap < minimum)
- minimum= swap;
+ minimum = swap;
- remove= metric[row][column - 1];
+ remove = metric[row][column - 1];
if (COST_REMOVE + remove < minimum)
- minimum= COST_REMOVE + remove;
+ minimum = COST_REMOVE + remove;
- insert= metric[row - 1][column];
+ insert = metric[row - 1][column];
if (COST_INSERT + insert < minimum)
- minimum= COST_INSERT + insert;
+ minimum = COST_INSERT + insert;
if (change < minimum)
- minimum= change;
+ minimum = change;
- metric[row][column]= minimum;
+ metric[row][column] = minimum;
}
}
return metric[rows - 1][columns - 1];
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
index a999c2fdfd1..131aa526296 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
@@ -23,107 +23,108 @@ package org.eclipse.cdt.internal.ui.text.spelling.engine;
* <p>
*/
public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider {
- private static final String[] meta01= { "ACH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta02= { "BACHER", "MACHER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta03= { "CAESAR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta04= { "CHIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta05= { "CH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta06= { "CHAE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta07= { "HARAC", "HARIS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta08= { "HOR", "HYM", "HIA", "HEM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private static final String[] meta09= { "CHORE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta10= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta11= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta12= { "ORCHES", "ARCHIT", "ORCHID", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta13= { "T", "S", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta14= { "A", "O", "U", "E", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private static final String[] meta15= { "L", "R", "N", "M", "B", "H", "F", "V", "W", " ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
- private static final String[] meta16= { "MC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta17= { "CZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta18= { "WICZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta19= { "CIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta20= { "CC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta21= { "I", "E", "H", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta22= { "HU", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta23= { "UCCEE", "UCCES", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta24= { "CK", "CG", "CQ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta25= { "CI", "CE", "CY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta26= { "GN", "KN", "PN", "WR", "PS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- private static final String[] meta27= { " C", " Q", " G", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta28= { "C", "K", "Q", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta29= { "CE", "CI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta30= { "DG", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta31= { "I", "E", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta32= { "DT", "DD", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta33= { "B", "H", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta34= { "B", "H", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta35= { "B", "H", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta36= { "C", "G", "L", "R", "T", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- private static final String[] meta37= { "EY", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta38= { "LI", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta39= { "ES", "EP", "EB", "EL", "EY", "IB", "IL", "IN", "IE", "EI", "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
- private static final String[] meta40= { "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta41= { "DANGER", "RANGER", "MANGER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta42= { "E", "I", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta43= { "RGY", "OGY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta44= { "E", "I", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta45= { "AGGI", "OGGI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta46= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta47= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta48= { "ET", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta49= { "C", "X", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta50= { "JOSE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta51= { "SAN ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta52= { "SAN ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta53= { "JOSE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta54= { "L", "T", "K", "S", "N", "M", "B", "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
- private static final String[] meta55= { "S", "K", "L", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta56= { "ILLO", "ILLA", "ALLE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta57= { "AS", "OS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta58= { "A", "O", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta59= { "ALLE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta60= { "UMB", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta61= { "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta62= { "P", "B", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta63= { "IE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta64= { "ME", "MA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta65= { "ISL", "YSL", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta66= { "SUGAR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta67= { "SH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta68= { "HEIM", "HOEK", "HOLM", "HOLZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private static final String[] meta69= { "SIO", "SIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta70= { "SIAN", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta71= { "M", "N", "L", "W", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private static final String[] meta72= { "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta73= { "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta74= { "SC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta75= { "OO", "ER", "EN", "UY", "ED", "EM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- private static final String[] meta76= { "ER", "EN", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta77= { "I", "E", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String[] meta78= { "AI", "OI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta79= { "S", "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta80= { "TION", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta81= { "TIA", "TCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta82= { "TH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta83= { "TTH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta84= { "OM", "AM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta85= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta86= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta87= { "T", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta88= { "WR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta89= { "WH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta90= { "EWSKI", "EWSKY", "OWSKI", "OWSKY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private static final String[] meta91= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String[] meta92= { "WICZ", "WITZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta93= { "IAU", "EAU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta94= { "AU", "OU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String[] meta95= { "W", "K", "CZ", "WITZ" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta01 = { "ACH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta02 = { "BACHER", "MACHER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta03 = { "CAESAR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta04 = { "CHIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta05 = { "CH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta06 = { "CHAE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta07 = { "HARAC", "HARIS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta08 = { "HOR", "HYM", "HIA", "HEM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ private static final String[] meta09 = { "CHORE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta10 = { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta11 = { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta12 = { "ORCHES", "ARCHIT", "ORCHID", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta13 = { "T", "S", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta14 = { "A", "O", "U", "E", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ private static final String[] meta15 = { "L", "R", "N", "M", "B", "H", "F", "V", "W", " ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
+ private static final String[] meta16 = { "MC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta17 = { "CZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta18 = { "WICZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta19 = { "CIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta20 = { "CC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta21 = { "I", "E", "H", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta22 = { "HU", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta23 = { "UCCEE", "UCCES", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta24 = { "CK", "CG", "CQ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta25 = { "CI", "CE", "CY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta26 = { "GN", "KN", "PN", "WR", "PS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ private static final String[] meta27 = { " C", " Q", " G", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta28 = { "C", "K", "Q", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta29 = { "CE", "CI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta30 = { "DG", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta31 = { "I", "E", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta32 = { "DT", "DD", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta33 = { "B", "H", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta34 = { "B", "H", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta35 = { "B", "H", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta36 = { "C", "G", "L", "R", "T", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ private static final String[] meta37 = { "EY", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta38 = { "LI", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta39 = { "ES", "EP", "EB", "EL", "EY", "IB", "IL", "IN", "IE", "EI", "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
+ private static final String[] meta40 = { "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta41 = { "DANGER", "RANGER", "MANGER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta42 = { "E", "I", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta43 = { "RGY", "OGY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta44 = { "E", "I", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta45 = { "AGGI", "OGGI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta46 = { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta47 = { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta48 = { "ET", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta49 = { "C", "X", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta50 = { "JOSE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta51 = { "SAN ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta52 = { "SAN ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta53 = { "JOSE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta54 = { "L", "T", "K", "S", "N", "M", "B", "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ private static final String[] meta55 = { "S", "K", "L", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta56 = { "ILLO", "ILLA", "ALLE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta57 = { "AS", "OS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta58 = { "A", "O", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta59 = { "ALLE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta60 = { "UMB", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta61 = { "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta62 = { "P", "B", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta63 = { "IE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta64 = { "ME", "MA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta65 = { "ISL", "YSL", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta66 = { "SUGAR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta67 = { "SH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta68 = { "HEIM", "HOEK", "HOLM", "HOLZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ private static final String[] meta69 = { "SIO", "SIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta70 = { "SIAN", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta71 = { "M", "N", "L", "W", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ private static final String[] meta72 = { "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta73 = { "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta74 = { "SC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta75 = { "OO", "ER", "EN", "UY", "ED", "EM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ private static final String[] meta76 = { "ER", "EN", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta77 = { "I", "E", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] meta78 = { "AI", "OI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta79 = { "S", "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta80 = { "TION", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta81 = { "TIA", "TCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta82 = { "TH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta83 = { "TTH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta84 = { "OM", "AM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta85 = { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta86 = { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta87 = { "T", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta88 = { "WR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta89 = { "WH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta90 = { "EWSKI", "EWSKY", "OWSKI", "OWSKY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ private static final String[] meta91 = { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String[] meta92 = { "WICZ", "WITZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta93 = { "IAU", "EAU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta94 = { "AU", "OU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] meta95 = { "W", "K", "CZ", "WITZ" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
/** The mutator characters */
- private static final char[] MUTATOR_CHARACTERS= { 'A', 'B', 'X', 'S', 'K', 'J', 'T', 'F', 'H', 'L', 'M', 'N', 'P', 'R', '0' };
+ private static final char[] MUTATOR_CHARACTERS = { 'A', 'B', 'X', 'S', 'K', 'J', 'T', 'F', 'H', 'L', 'M', 'N', 'P',
+ 'R', '0' };
/** The vowel characters */
- private static final char[] VOWEL_CHARACTERS= new char[] { 'A', 'E', 'I', 'O', 'U', 'Y' };
+ private static final char[] VOWEL_CHARACTERS = new char[] { 'A', 'E', 'I', 'O', 'U', 'Y' };
/**
* Test whether the specified string contains one of the candidates in the
@@ -140,11 +141,12 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
* @return <code>true</code> iff the string contains one of the
* candidates, <code>false</code> otherwise.
*/
- protected static final boolean hasOneOf(final String[] candidates, final char[] token, final int offset, final int length) {
+ protected static final boolean hasOneOf(final String[] candidates, final char[] token, final int offset,
+ final int length) {
if (offset < 0 || offset >= token.length || candidates.length == 0)
return false;
- final String checkable= new String(token, offset, length);
+ final String checkable = new String(token, offset, length);
for (String candidate : candidates) {
if (candidate.equals(checkable))
@@ -188,7 +190,7 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
*/
protected static final boolean hasVowel(final char[] token, final int offset, final int length) {
if (offset >= 0 && offset < length) {
- final char character= token[offset];
+ final char character = token[offset];
for (char element : VOWEL_CHARACTERS) {
if (element == character)
return true;
@@ -202,13 +204,13 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
*/
@Override
public final String getHash(final String word) {
- final String input= word.toUpperCase() + " "; //$NON-NLS-1$
- final char[] hashable= input.toCharArray();
+ final String input = word.toUpperCase() + " "; //$NON-NLS-1$
+ final char[] hashable = input.toCharArray();
- final boolean has95= hasOneOf(meta95, input);
- final StringBuilder buffer= new StringBuilder(hashable.length);
+ final boolean has95 = hasOneOf(meta95, input);
+ final StringBuilder buffer = new StringBuilder(hashable.length);
- int offset= 0;
+ int offset = 0;
if (hasOneOf(meta26, hashable, 0, 2))
offset += 1;
@@ -219,447 +221,474 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
while (offset < hashable.length) {
switch (hashable[offset]) {
- case 'A' :
- case 'E' :
- case 'I' :
- case 'O' :
- case 'U' :
- case 'Y' :
- if (offset == 0)
- buffer.append('A');
+ case 'A':
+ case 'E':
+ case 'I':
+ case 'O':
+ case 'U':
+ case 'Y':
+ if (offset == 0)
+ buffer.append('A');
+ offset += 1;
+ break;
+ case 'B':
+ buffer.append('P');
+ if (hashable[offset + 1] == 'B')
+ offset += 2;
+ else
offset += 1;
+ break;
+ case 'C':
+ if ((offset > 1) && !hasVowel(hashable, offset - 2, hashable.length)
+ && hasOneOf(meta01, hashable, (offset - 1), 3) && (hashable[offset + 2] != 'I')
+ && (hashable[offset + 2] != 'E') || hasOneOf(meta02, hashable, (offset - 2), 6)) {
+ buffer.append('K');
+ offset += 2;
break;
- case 'B' :
- buffer.append('P');
- if (hashable[offset + 1] == 'B')
- offset += 2;
- else
- offset += 1;
+ }
+ if ((offset == 0) && hasOneOf(meta03, hashable, offset, 6)) {
+ buffer.append('S');
+ offset += 2;
break;
- case 'C' :
- if ((offset > 1) && !hasVowel(hashable, offset - 2, hashable.length) && hasOneOf(meta01, hashable, (offset - 1), 3) && (hashable[offset + 2] != 'I') && (hashable[offset + 2] != 'E') || hasOneOf(meta02, hashable, (offset - 2), 6)) {
+ }
+ if (hasOneOf(meta04, hashable, offset, 4)) {
+ buffer.append('K');
+ offset += 2;
+ break;
+ }
+ if (hasOneOf(meta05, hashable, offset, 2)) {
+ if ((offset > 0) && hasOneOf(meta06, hashable, offset, 4)) {
buffer.append('K');
offset += 2;
break;
}
- if ((offset == 0) && hasOneOf(meta03, hashable, offset, 6)) {
- buffer.append('S');
- offset += 2;
- break;
- }
- if (hasOneOf(meta04, hashable, offset, 4)) {
+ if ((offset == 0) && hasOneOf(meta07, hashable, (offset + 1), 5)
+ || hasOneOf(meta08, hashable, offset + 1, 3) && !hasOneOf(meta09, hashable, 0, 5)) {
buffer.append('K');
offset += 2;
break;
}
- if (hasOneOf(meta05, hashable, offset, 2)) {
- if ((offset > 0) && hasOneOf(meta06, hashable, offset, 4)) {
- buffer.append('K');
- offset += 2;
- break;
- }
- if ((offset == 0) && hasOneOf(meta07, hashable, (offset + 1), 5) || hasOneOf(meta08, hashable, offset + 1, 3) && !hasOneOf(meta09, hashable, 0, 5)) {
- buffer.append('K');
- offset += 2;
- break;
- }
- if (hasOneOf(meta10, hashable, 0, 4) || hasOneOf(meta11, hashable, 0, 3) || hasOneOf(meta12, hashable, offset - 2, 6) || hasOneOf(meta13, hashable, offset + 2, 1) || (hasOneOf(meta14, hashable, offset - 1, 1) || (offset == 0)) && hasOneOf(meta15, hashable, offset + 2, 1)) {
- buffer.append('K');
- } else {
- if (offset > 0) {
- if (hasOneOf(meta16, hashable, 0, 2))
- buffer.append('K');
- else
- buffer.append('X');
- } else {
- buffer.append('X');
- }
- }
- offset += 2;
- break;
- }
- if (hasOneOf(meta17, hashable, offset, 2) && !hasOneOf(meta18, hashable, offset, 4)) {
- buffer.append('S');
- offset += 2;
- break;
- }
- if (hasOneOf(meta19, hashable, offset, 2)) {
- buffer.append('X');
- offset += 2;
- break;
- }
- if (hasOneOf(meta20, hashable, offset, 2) && !((offset == 1) && hashable[0] == 'M')) {
- if (hasOneOf(meta21, hashable, offset + 2, 1) && !hasOneOf(meta22, hashable, offset + 2, 2)) {
- if (((offset == 1) && (hashable[offset - 1] == 'A')) || hasOneOf(meta23, hashable, (offset - 1), 5))
- buffer.append("KS"); //$NON-NLS-1$
+ if (hasOneOf(meta10, hashable, 0, 4) || hasOneOf(meta11, hashable, 0, 3)
+ || hasOneOf(meta12, hashable, offset - 2, 6) || hasOneOf(meta13, hashable, offset + 2, 1)
+ || (hasOneOf(meta14, hashable, offset - 1, 1) || (offset == 0))
+ && hasOneOf(meta15, hashable, offset + 2, 1)) {
+ buffer.append('K');
+ } else {
+ if (offset > 0) {
+ if (hasOneOf(meta16, hashable, 0, 2))
+ buffer.append('K');
else
buffer.append('X');
- offset += 3;
} else {
- buffer.append('K');
- offset += 2;
+ buffer.append('X');
}
- break;
}
- if (hasOneOf(meta24, hashable, offset, 2)) {
+ offset += 2;
+ break;
+ }
+ if (hasOneOf(meta17, hashable, offset, 2) && !hasOneOf(meta18, hashable, offset, 4)) {
+ buffer.append('S');
+ offset += 2;
+ break;
+ }
+ if (hasOneOf(meta19, hashable, offset, 2)) {
+ buffer.append('X');
+ offset += 2;
+ break;
+ }
+ if (hasOneOf(meta20, hashable, offset, 2) && !((offset == 1) && hashable[0] == 'M')) {
+ if (hasOneOf(meta21, hashable, offset + 2, 1) && !hasOneOf(meta22, hashable, offset + 2, 2)) {
+ if (((offset == 1) && (hashable[offset - 1] == 'A'))
+ || hasOneOf(meta23, hashable, (offset - 1), 5))
+ buffer.append("KS"); //$NON-NLS-1$
+ else
+ buffer.append('X');
+ offset += 3;
+ } else {
buffer.append('K');
offset += 2;
- break;
- } else if (hasOneOf(meta25, hashable, offset, 2)) {
- buffer.append('S');
- offset += 2;
- break;
}
+ break;
+ }
+ if (hasOneOf(meta24, hashable, offset, 2)) {
buffer.append('K');
- if (hasOneOf(meta27, hashable, offset + 1, 2))
- offset += 3;
- else if (hasOneOf(meta28, hashable, offset + 1, 1) && !hasOneOf(meta29, hashable, offset + 1, 2))
- offset += 2;
- else
- offset += 1;
+ offset += 2;
break;
- case '\u00C7' :
+ } else if (hasOneOf(meta25, hashable, offset, 2)) {
buffer.append('S');
- offset += 1;
+ offset += 2;
break;
- case 'D' :
- if (hasOneOf(meta30, hashable, offset, 2)) {
- if (hasOneOf(meta31, hashable, offset + 2, 1)) {
- buffer.append('J');
- offset += 3;
- } else {
- buffer.append("TK"); //$NON-NLS-1$
- offset += 2;
- }
- break;
- }
- buffer.append('T');
- if (hasOneOf(meta32, hashable, offset, 2)) {
- offset += 2;
+ }
+ buffer.append('K');
+ if (hasOneOf(meta27, hashable, offset + 1, 2))
+ offset += 3;
+ else if (hasOneOf(meta28, hashable, offset + 1, 1) && !hasOneOf(meta29, hashable, offset + 1, 2))
+ offset += 2;
+ else
+ offset += 1;
+ break;
+ case '\u00C7':
+ buffer.append('S');
+ offset += 1;
+ break;
+ case 'D':
+ if (hasOneOf(meta30, hashable, offset, 2)) {
+ if (hasOneOf(meta31, hashable, offset + 2, 1)) {
+ buffer.append('J');
+ offset += 3;
} else {
- offset += 1;
+ buffer.append("TK"); //$NON-NLS-1$
+ offset += 2;
}
break;
- case 'F' :
- if (hashable[offset + 1] == 'F')
+ }
+ buffer.append('T');
+ if (hasOneOf(meta32, hashable, offset, 2)) {
+ offset += 2;
+ } else {
+ offset += 1;
+ }
+ break;
+ case 'F':
+ if (hashable[offset + 1] == 'F')
+ offset += 2;
+ else
+ offset += 1;
+ buffer.append('F');
+ break;
+ case 'G':
+ if (hashable[offset + 1] == 'H') {
+ if ((offset > 0) && !hasVowel(hashable, offset - 1, hashable.length)) {
+ buffer.append('K');
offset += 2;
- else
- offset += 1;
- buffer.append('F');
- break;
- case 'G' :
- if (hashable[offset + 1] == 'H') {
- if ((offset > 0) && !hasVowel(hashable, offset - 1, hashable.length)) {
- buffer.append('K');
+ break;
+ }
+ if (offset < 3) {
+ if (offset == 0) {
+ if (hashable[offset + 2] == 'I')
+ buffer.append('J');
+ else
+ buffer.append('K');
offset += 2;
break;
}
- if (offset < 3) {
- if (offset == 0) {
- if (hashable[offset + 2] == 'I')
- buffer.append('J');
- else
- buffer.append('K');
- offset += 2;
- break;
- }
- }
- if ((offset > 1) && hasOneOf(meta33, hashable, offset - 2, 1) || ((offset > 2) && hasOneOf(meta34, hashable, offset - 3, 1)) || ((offset > 3) && hasOneOf(meta35, hashable, offset - 4, 1))) {
- offset += 2;
- } else {
- if ((offset > 2) && (hashable[offset - 1] == 'U') && hasOneOf(meta36, hashable, offset - 3, 1)) {
- buffer.append('F');
- } else {
- if ((offset > 0) && (hashable[offset - 1] != 'I'))
- buffer.append('K');
- }
- offset += 2;
- }
- break;
}
- if (hashable[offset + 1] == 'N') {
- if ((offset == 1) && hasVowel(hashable, 0, hashable.length) && !has95) {
- buffer.append("KN"); //$NON-NLS-1$
+ if ((offset > 1) && hasOneOf(meta33, hashable, offset - 2, 1)
+ || ((offset > 2) && hasOneOf(meta34, hashable, offset - 3, 1))
+ || ((offset > 3) && hasOneOf(meta35, hashable, offset - 4, 1))) {
+ offset += 2;
+ } else {
+ if ((offset > 2) && (hashable[offset - 1] == 'U')
+ && hasOneOf(meta36, hashable, offset - 3, 1)) {
+ buffer.append('F');
} else {
- if (!hasOneOf(meta37, hashable, offset + 2, 2) && (hashable[offset + 1] != 'Y') && !has95) {
- buffer.append("N"); //$NON-NLS-1$
- } else {
- buffer.append("KN"); //$NON-NLS-1$
- }
+ if ((offset > 0) && (hashable[offset - 1] != 'I'))
+ buffer.append('K');
}
offset += 2;
- break;
- }
- if (hasOneOf(meta38, hashable, offset + 1, 2) && !has95) {
- buffer.append("KL"); //$NON-NLS-1$
- offset += 2;
- break;
}
- if ((offset == 0) && ((hashable[offset + 1] == 'Y') || hasOneOf(meta39, hashable, offset + 1, 2))) {
- buffer.append('K');
- offset += 2;
- break;
- }
- if ((hasOneOf(meta40, hashable, offset + 1, 2) || (hashable[offset + 1] == 'Y')) && !hasOneOf(meta41, hashable, 0, 6) && !hasOneOf(meta42, hashable, offset - 1, 1) && !hasOneOf(meta43, hashable, offset - 1, 3)) {
- buffer.append('K');
- offset += 2;
- break;
- }
- if (hasOneOf(meta44, hashable, offset + 1, 1) || hasOneOf(meta45, hashable, offset - 1, 4)) {
- if (hasOneOf(meta46, hashable, 0, 4) || hasOneOf(meta47, hashable, 0, 3) || hasOneOf(meta48, hashable, offset + 1, 2)) {
- buffer.append('K');
+ break;
+ }
+ if (hashable[offset + 1] == 'N') {
+ if ((offset == 1) && hasVowel(hashable, 0, hashable.length) && !has95) {
+ buffer.append("KN"); //$NON-NLS-1$
+ } else {
+ if (!hasOneOf(meta37, hashable, offset + 2, 2) && (hashable[offset + 1] != 'Y') && !has95) {
+ buffer.append("N"); //$NON-NLS-1$
} else {
- buffer.append('J');
+ buffer.append("KN"); //$NON-NLS-1$
}
- offset += 2;
- break;
}
- if (hashable[offset + 1] == 'G')
- offset += 2;
- else
- offset += 1;
+ offset += 2;
+ break;
+ }
+ if (hasOneOf(meta38, hashable, offset + 1, 2) && !has95) {
+ buffer.append("KL"); //$NON-NLS-1$
+ offset += 2;
+ break;
+ }
+ if ((offset == 0) && ((hashable[offset + 1] == 'Y') || hasOneOf(meta39, hashable, offset + 1, 2))) {
buffer.append('K');
+ offset += 2;
break;
- case 'H' :
- if (((offset == 0) || hasVowel(hashable, offset - 1, hashable.length)) && hasVowel(hashable, offset + 1, hashable.length)) {
- buffer.append('H');
- offset += 2;
+ }
+ if ((hasOneOf(meta40, hashable, offset + 1, 2) || (hashable[offset + 1] == 'Y'))
+ && !hasOneOf(meta41, hashable, 0, 6) && !hasOneOf(meta42, hashable, offset - 1, 1)
+ && !hasOneOf(meta43, hashable, offset - 1, 3)) {
+ buffer.append('K');
+ offset += 2;
+ break;
+ }
+ if (hasOneOf(meta44, hashable, offset + 1, 1) || hasOneOf(meta45, hashable, offset - 1, 4)) {
+ if (hasOneOf(meta46, hashable, 0, 4) || hasOneOf(meta47, hashable, 0, 3)
+ || hasOneOf(meta48, hashable, offset + 1, 2)) {
+ buffer.append('K');
} else {
- offset += 1;
+ buffer.append('J');
}
+ offset += 2;
break;
- case 'J' :
- if (hasOneOf(meta50, hashable, offset, 4) || hasOneOf(meta51, hashable, 0, 4)) {
- if ((offset == 0) && (hashable[offset + 4] == ' ') || hasOneOf(meta52, hashable, 0, 4)) {
- buffer.append('H');
- } else {
- buffer.append('J');
- }
- offset += 1;
- break;
+ }
+ if (hashable[offset + 1] == 'G')
+ offset += 2;
+ else
+ offset += 1;
+ buffer.append('K');
+ break;
+ case 'H':
+ if (((offset == 0) || hasVowel(hashable, offset - 1, hashable.length))
+ && hasVowel(hashable, offset + 1, hashable.length)) {
+ buffer.append('H');
+ offset += 2;
+ } else {
+ offset += 1;
+ }
+ break;
+ case 'J':
+ if (hasOneOf(meta50, hashable, offset, 4) || hasOneOf(meta51, hashable, 0, 4)) {
+ if ((offset == 0) && (hashable[offset + 4] == ' ') || hasOneOf(meta52, hashable, 0, 4)) {
+ buffer.append('H');
+ } else {
+ buffer.append('J');
}
- if ((offset == 0) && !hasOneOf(meta53, hashable, offset, 4)) {
+ offset += 1;
+ break;
+ }
+ if ((offset == 0) && !hasOneOf(meta53, hashable, offset, 4)) {
+ buffer.append('J');
+ } else {
+ if (hasVowel(hashable, offset - 1, hashable.length) && !has95
+ && ((hashable[offset + 1] == 'A') || hashable[offset + 1] == 'O')) {
buffer.append('J');
} else {
- if (hasVowel(hashable, offset - 1, hashable.length) && !has95 && ((hashable[offset + 1] == 'A') || hashable[offset + 1] == 'O')) {
+ if (offset == (hashable.length - 1)) {
buffer.append('J');
} else {
- if (offset == (hashable.length - 1)) {
+ if (!hasOneOf(meta54, hashable, offset + 1, 1)
+ && !hasOneOf(meta55, hashable, offset - 1, 1)) {
buffer.append('J');
- } else {
- if (!hasOneOf(meta54, hashable, offset + 1, 1) && !hasOneOf(meta55, hashable, offset - 1, 1)) {
- buffer.append('J');
- }
}
}
}
- if (hashable[offset + 1] == 'J')
- offset += 2;
- else
- offset += 1;
- break;
- case 'K' :
- if (hashable[offset + 1] == 'K')
- offset += 2;
- else
- offset += 1;
- buffer.append('K');
- break;
- case 'L' :
- if (hashable[offset + 1] == 'L') {
- if (((offset == (hashable.length - 3)) && hasOneOf(meta56, hashable, offset - 1, 4)) || ((hasOneOf(meta57, hashable, (hashable.length - 1) - 1, 2) || hasOneOf(meta58, hashable, hashable.length - 1, 1)) && hasOneOf(meta59, hashable, offset - 1, 4))) {
- buffer.append('L');
- offset += 2;
- break;
- }
- offset += 2;
- } else
- offset += 1;
- buffer.append('L');
- break;
- case 'M' :
- if ((hasOneOf(meta60, hashable, offset - 1, 3) && (((offset + 1) == (hashable.length - 1)) || hasOneOf(meta61, hashable, offset + 2, 2))) || (hashable[offset + 1] == 'M'))
+ }
+ if (hashable[offset + 1] == 'J')
+ offset += 2;
+ else
+ offset += 1;
+ break;
+ case 'K':
+ if (hashable[offset + 1] == 'K')
+ offset += 2;
+ else
+ offset += 1;
+ buffer.append('K');
+ break;
+ case 'L':
+ if (hashable[offset + 1] == 'L') {
+ if (((offset == (hashable.length - 3)) && hasOneOf(meta56, hashable, offset - 1, 4))
+ || ((hasOneOf(meta57, hashable, (hashable.length - 1) - 1, 2)
+ || hasOneOf(meta58, hashable, hashable.length - 1, 1))
+ && hasOneOf(meta59, hashable, offset - 1, 4))) {
+ buffer.append('L');
offset += 2;
- else
- offset += 1;
- buffer.append('M');
+ break;
+ }
+ offset += 2;
+ } else
+ offset += 1;
+ buffer.append('L');
+ break;
+ case 'M':
+ if ((hasOneOf(meta60, hashable, offset - 1, 3)
+ && (((offset + 1) == (hashable.length - 1)) || hasOneOf(meta61, hashable, offset + 2, 2)))
+ || (hashable[offset + 1] == 'M'))
+ offset += 2;
+ else
+ offset += 1;
+ buffer.append('M');
+ break;
+ case 'N':
+ if (hashable[offset + 1] == 'N')
+ offset += 2;
+ else
+ offset += 1;
+ buffer.append('N');
+ break;
+ case '\u00D1':
+ offset += 1;
+ buffer.append('N');
+ break;
+ case 'P':
+ if (hashable[offset + 1] == 'N') {
+ buffer.append('F');
+ offset += 2;
break;
- case 'N' :
- if (hashable[offset + 1] == 'N')
- offset += 2;
- else
- offset += 1;
- buffer.append('N');
+ }
+ if (hasOneOf(meta62, hashable, offset + 1, 1))
+ offset += 2;
+ else
+ offset += 1;
+ buffer.append('P');
+ break;
+ case 'Q':
+ if (hashable[offset + 1] == 'Q')
+ offset += 2;
+ else
+ offset += 1;
+ buffer.append('K');
+ break;
+ case 'R':
+ if (!((offset == (hashable.length - 1)) && !has95 && hasOneOf(meta63, hashable, offset - 2, 2)
+ && !hasOneOf(meta64, hashable, offset - 4, 2)))
+ buffer.append('R');
+ if (hashable[offset + 1] == 'R')
+ offset += 2;
+ else
+ offset += 1;
+ break;
+ case 'S':
+ if (hasOneOf(meta65, hashable, offset - 1, 3)) {
+ offset += 1;
break;
- case '\u00D1' :
+ }
+ if ((offset == 0) && hasOneOf(meta66, hashable, offset, 5)) {
+ buffer.append('X');
offset += 1;
- buffer.append('N');
break;
- case 'P' :
- if (hashable[offset + 1] == 'N') {
- buffer.append('F');
- offset += 2;
- break;
- }
- if (hasOneOf(meta62, hashable, offset + 1, 1))
- offset += 2;
+ }
+ if (hasOneOf(meta67, hashable, offset, 2)) {
+ if (hasOneOf(meta68, hashable, offset + 1, 4))
+ buffer.append('S');
else
- offset += 1;
- buffer.append('P');
+ buffer.append('X');
+ offset += 2;
break;
- case 'Q' :
- if (hashable[offset + 1] == 'Q')
- offset += 2;
- else
- offset += 1;
- buffer.append('K');
+ }
+ if (hasOneOf(meta69, hashable, offset, 3) || hasOneOf(meta70, hashable, offset, 4)) {
+ buffer.append('S');
+ offset += 3;
break;
- case 'R' :
- if (!((offset == (hashable.length - 1)) && !has95 && hasOneOf(meta63, hashable, offset - 2, 2) && !hasOneOf(meta64, hashable, offset - 4, 2)))
- buffer.append('R');
- if (hashable[offset + 1] == 'R')
+ }
+ if (((offset == 0) && hasOneOf(meta71, hashable, offset + 1, 1))
+ || hasOneOf(meta72, hashable, offset + 1, 1)) {
+ buffer.append('S');
+ if (hasOneOf(meta73, hashable, offset + 1, 1))
offset += 2;
else
offset += 1;
break;
- case 'S' :
- if (hasOneOf(meta65, hashable, offset - 1, 3)) {
- offset += 1;
- break;
- }
- if ((offset == 0) && hasOneOf(meta66, hashable, offset, 5)) {
- buffer.append('X');
- offset += 1;
- break;
- }
- if (hasOneOf(meta67, hashable, offset, 2)) {
- if (hasOneOf(meta68, hashable, offset + 1, 4))
- buffer.append('S');
- else
- buffer.append('X');
- offset += 2;
- break;
- }
- if (hasOneOf(meta69, hashable, offset, 3) || hasOneOf(meta70, hashable, offset, 4)) {
- buffer.append('S');
- offset += 3;
- break;
- }
- if (((offset == 0) && hasOneOf(meta71, hashable, offset + 1, 1)) || hasOneOf(meta72, hashable, offset + 1, 1)) {
- buffer.append('S');
- if (hasOneOf(meta73, hashable, offset + 1, 1))
- offset += 2;
- else
- offset += 1;
- break;
- }
- if (hasOneOf(meta74, hashable, offset, 2)) {
- if (hashable[offset + 2] == 'H') {
- if (hasOneOf(meta75, hashable, offset + 3, 2)) {
- if (hasOneOf(meta76, hashable, offset + 3, 2)) {
- buffer.append("X"); //$NON-NLS-1$
- } else {
- buffer.append("SK"); //$NON-NLS-1$
- }
- offset += 3;
+ }
+ if (hasOneOf(meta74, hashable, offset, 2)) {
+ if (hashable[offset + 2] == 'H') {
+ if (hasOneOf(meta75, hashable, offset + 3, 2)) {
+ if (hasOneOf(meta76, hashable, offset + 3, 2)) {
+ buffer.append("X"); //$NON-NLS-1$
} else {
- buffer.append('X');
- offset += 3;
+ buffer.append("SK"); //$NON-NLS-1$
}
- break;
- }
- if (hasOneOf(meta77, hashable, offset + 2, 1)) {
- buffer.append('S');
offset += 3;
- break;
+ } else {
+ buffer.append('X');
+ offset += 3;
}
- buffer.append("SK"); //$NON-NLS-1$
- offset += 3;
break;
}
- if (!((offset == (hashable.length - 1)) && hasOneOf(meta78, hashable, offset - 2, 2)))
+ if (hasOneOf(meta77, hashable, offset + 2, 1)) {
buffer.append('S');
- if (hasOneOf(meta79, hashable, offset + 1, 1))
- offset += 2;
- else
- offset += 1;
- break;
- case 'T' :
- if (hasOneOf(meta80, hashable, offset, 4)) {
- buffer.append('X');
- offset += 3;
- break;
- }
- if (hasOneOf(meta81, hashable, offset, 3)) {
- buffer.append('X');
offset += 3;
break;
}
- if (hasOneOf(meta82, hashable, offset, 2) || hasOneOf(meta83, hashable, offset, 3)) {
- if (hasOneOf(meta84, hashable, (offset + 2), 2) || hasOneOf(meta85, hashable, 0, 4) || hasOneOf(meta86, hashable, 0, 3)) {
- buffer.append('T');
- } else {
- buffer.append('0');
- }
- offset += 2;
- break;
- }
- if (hasOneOf(meta87, hashable, offset + 1, 1)) {
- offset += 2;
- } else
- offset += 1;
- buffer.append('T');
+ buffer.append("SK"); //$NON-NLS-1$
+ offset += 3;
break;
- case 'V' :
- if (hashable[offset + 1] == 'V')
- offset += 2;
- else
- offset += 1;
- buffer.append('F');
+ }
+ if (!((offset == (hashable.length - 1)) && hasOneOf(meta78, hashable, offset - 2, 2)))
+ buffer.append('S');
+ if (hasOneOf(meta79, hashable, offset + 1, 1))
+ offset += 2;
+ else
+ offset += 1;
+ break;
+ case 'T':
+ if (hasOneOf(meta80, hashable, offset, 4)) {
+ buffer.append('X');
+ offset += 3;
break;
- case 'W' :
- if (hasOneOf(meta88, hashable, offset, 2)) {
- buffer.append('R');
- offset += 2;
- break;
- }
- if ((offset == 0) && (hasVowel(hashable, offset + 1, hashable.length) || hasOneOf(meta89, hashable, offset, 2))) {
- buffer.append('A');
- }
- if (((offset == (hashable.length - 1)) && hasVowel(hashable, offset - 1, hashable.length)) || hasOneOf(meta90, hashable, offset - 1, 5) || hasOneOf(meta91, hashable, 0, 3)) {
- buffer.append('F');
- offset += 1;
- break;
- }
- if (hasOneOf(meta92, hashable, offset, 4)) {
- buffer.append("TS"); //$NON-NLS-1$
- offset += 4;
- break;
+ }
+ if (hasOneOf(meta81, hashable, offset, 3)) {
+ buffer.append('X');
+ offset += 3;
+ break;
+ }
+ if (hasOneOf(meta82, hashable, offset, 2) || hasOneOf(meta83, hashable, offset, 3)) {
+ if (hasOneOf(meta84, hashable, (offset + 2), 2) || hasOneOf(meta85, hashable, 0, 4)
+ || hasOneOf(meta86, hashable, 0, 3)) {
+ buffer.append('T');
+ } else {
+ buffer.append('0');
}
+ offset += 2;
+ break;
+ }
+ if (hasOneOf(meta87, hashable, offset + 1, 1)) {
+ offset += 2;
+ } else
offset += 1;
+ buffer.append('T');
+ break;
+ case 'V':
+ if (hashable[offset + 1] == 'V')
+ offset += 2;
+ else
+ offset += 1;
+ buffer.append('F');
+ break;
+ case 'W':
+ if (hasOneOf(meta88, hashable, offset, 2)) {
+ buffer.append('R');
+ offset += 2;
break;
- case 'X' :
- if (!((offset == (hashable.length - 1)) && (hasOneOf(meta93, hashable, offset - 3, 3) || hasOneOf(meta94, hashable, offset - 2, 2))))
- buffer.append("KS"); //$NON-NLS-1$
- if (hasOneOf(meta49, hashable, offset + 1, 1))
- offset += 2;
- else
- offset += 1;
+ }
+ if ((offset == 0)
+ && (hasVowel(hashable, offset + 1, hashable.length) || hasOneOf(meta89, hashable, offset, 2))) {
+ buffer.append('A');
+ }
+ if (((offset == (hashable.length - 1)) && hasVowel(hashable, offset - 1, hashable.length))
+ || hasOneOf(meta90, hashable, offset - 1, 5) || hasOneOf(meta91, hashable, 0, 3)) {
+ buffer.append('F');
+ offset += 1;
break;
- case 'Z' :
- if (hashable[offset + 1] == 'H') {
- buffer.append('J');
- offset += 2;
- break;
- }
- buffer.append('S');
- if (hashable[offset + 1] == 'Z')
- offset += 2;
- else
- offset += 1;
+ }
+ if (hasOneOf(meta92, hashable, offset, 4)) {
+ buffer.append("TS"); //$NON-NLS-1$
+ offset += 4;
+ break;
+ }
+ offset += 1;
+ break;
+ case 'X':
+ if (!((offset == (hashable.length - 1))
+ && (hasOneOf(meta93, hashable, offset - 3, 3) || hasOneOf(meta94, hashable, offset - 2, 2))))
+ buffer.append("KS"); //$NON-NLS-1$
+ if (hasOneOf(meta49, hashable, offset + 1, 1))
+ offset += 2;
+ else
+ offset += 1;
+ break;
+ case 'Z':
+ if (hashable[offset + 1] == 'H') {
+ buffer.append('J');
+ offset += 2;
break;
- default :
+ }
+ buffer.append('S');
+ if (hashable[offset + 1] == 'Z')
+ offset += 2;
+ else
offset += 1;
+ break;
+ default:
+ offset += 1;
}
}
return buffer.toString();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
index 6a9b1cfd312..aae636e8602 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
@@ -31,7 +31,8 @@ import org.eclipse.cdt.internal.ui.text.spelling.SpellingPreferences;
*/
public class DefaultSpellChecker implements ISpellChecker {
/** Array of URL prefixes */
- public static final String[] URL_PREFIXES= new String[] { "http://", "https://", "www.", "ftp://", "ftps://", "news://", "mailto://" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ public static final String[] URL_PREFIXES = new String[] { "http://", "https://", "www.", "ftp://", "ftps://", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
+ "news://", "mailto://" }; //$NON-NLS-1$ //$NON-NLS-2$
/**
* Does this word contain digits?
@@ -40,7 +41,7 @@ public class DefaultSpellChecker implements ISpellChecker {
* @return <code>true</code> iff this word contains digits, <code>false</code> otherwise
*/
protected static boolean isDigits(final String word) {
- for (int index= 0; index < word.length(); index++) {
+ for (int index = 0; index < word.length(); index++) {
if (Character.isDigit(word.charAt(index)))
return true;
}
@@ -59,19 +60,19 @@ public class DefaultSpellChecker implements ISpellChecker {
* otherwise
*/
protected static boolean isMixedCase(final String word, final boolean sentence) {
- final int length= word.length();
- boolean upper= Character.isUpperCase(word.charAt(0));
+ final int length = word.length();
+ boolean upper = Character.isUpperCase(word.charAt(0));
if (sentence && upper && (length > 1))
- upper= Character.isUpperCase(word.charAt(1));
+ upper = Character.isUpperCase(word.charAt(1));
if (upper) {
- for (int index= length - 1; index > 0; index--) {
+ for (int index = length - 1; index > 0; index--) {
if (Character.isLowerCase(word.charAt(index)))
return true;
}
} else {
- for (int index= length - 1; index > 0; index--) {
+ for (int index = length - 1; index > 0; index--) {
if (Character.isUpperCase(word.charAt(index)))
return true;
}
@@ -88,7 +89,7 @@ public class DefaultSpellChecker implements ISpellChecker {
* letters, <code>false</code> otherwise
*/
protected static boolean isUpperCase(final String word) {
- for (int index= word.length() - 1; index >= 0; index--) {
+ for (int index = word.length() - 1; index >= 0; index--) {
if (Character.isLowerCase(word.charAt(index)))
return false;
}
@@ -115,18 +116,18 @@ public class DefaultSpellChecker implements ISpellChecker {
* The dictionaries to use for spell checking. Synchronized to avoid
* concurrent modifications.
*/
- private final Set<ISpellDictionary> fDictionaries= Collections.synchronizedSet(new HashSet<ISpellDictionary>());
+ private final Set<ISpellDictionary> fDictionaries = Collections.synchronizedSet(new HashSet<ISpellDictionary>());
/**
* The words to be ignored. Synchronized to avoid concurrent modifications.
*/
- private final Set<String> fIgnored= Collections.synchronizedSet(new HashSet<String>());
+ private final Set<String> fIgnored = Collections.synchronizedSet(new HashSet<String>());
/**
* The spell event listeners. Synchronized to avoid concurrent
* modifications.
*/
- private final Set<ISpellEventListener> fListeners= Collections.synchronizedSet(new HashSet<ISpellEventListener>());
+ private final Set<ISpellEventListener> fListeners = Collections.synchronizedSet(new HashSet<ISpellEventListener>());
/**
* The locale of this checker.
@@ -142,8 +143,8 @@ public class DefaultSpellChecker implements ISpellChecker {
public DefaultSpellChecker(IPreferenceStore store, Locale locale) {
Assert.isLegal(store != null);
Assert.isLegal(locale != null);
-
- fLocale= locale;
+
+ fLocale = locale;
}
/*
@@ -174,12 +175,12 @@ public class DefaultSpellChecker implements ISpellChecker {
// the modifying methods add/checkWord (?)
Set<ISpellDictionary> copy;
synchronized (fDictionaries) {
- copy= new HashSet<ISpellDictionary>(fDictionaries);
+ copy = new HashSet<ISpellDictionary>(fDictionaries);
}
- ISpellDictionary dictionary= null;
- for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
- dictionary= iterator.next();
+ ISpellDictionary dictionary = null;
+ for (final Iterator<ISpellDictionary> iterator = copy.iterator(); iterator.hasNext();) {
+ dictionary = iterator.next();
if (dictionary.acceptsWords())
return true;
}
@@ -194,10 +195,10 @@ public class DefaultSpellChecker implements ISpellChecker {
// synchronizing is necessary as this is a write access
Set<ISpellDictionary> copy;
synchronized (fDictionaries) {
- copy= new HashSet<ISpellDictionary>(fDictionaries);
+ copy = new HashSet<ISpellDictionary>(fDictionaries);
}
- final String addable= word.toLowerCase();
+ final String addable = word.toLowerCase();
for (ISpellDictionary dictionary : copy) {
if (dictionary.acceptsWords())
dictionary.addWord(addable);
@@ -218,39 +219,41 @@ public class DefaultSpellChecker implements ISpellChecker {
*/
@Override
public void execute(final ISpellCheckIterator iterator) {
- final boolean ignoreDigits= SpellingPreferences.isIgnoreDigits();
- final boolean ignoreMixed= SpellingPreferences.isIgnoreMixed();
- final boolean ignoreSentence= SpellingPreferences.isIgnoreSentence();
- final boolean ignoreUpper= SpellingPreferences.isIgnoreUpper();
- final boolean ignoreUrls= SpellingPreferences.isIgnoreUrls();
- final boolean ignoreNonLetters= SpellingPreferences.isIgnoreNonLetters();
- final boolean ignoreSingleLetters= SpellingPreferences.isIgnoreSingleLetters();
-
+ final boolean ignoreDigits = SpellingPreferences.isIgnoreDigits();
+ final boolean ignoreMixed = SpellingPreferences.isIgnoreMixed();
+ final boolean ignoreSentence = SpellingPreferences.isIgnoreSentence();
+ final boolean ignoreUpper = SpellingPreferences.isIgnoreUpper();
+ final boolean ignoreUrls = SpellingPreferences.isIgnoreUrls();
+ final boolean ignoreNonLetters = SpellingPreferences.isIgnoreNonLetters();
+ final boolean ignoreSingleLetters = SpellingPreferences.isIgnoreSingleLetters();
+
iterator.setIgnoreSingleLetters(ignoreSingleLetters);
-
+
synchronized (fDictionaries) {
- Iterator<ISpellDictionary> iter= fDictionaries.iterator();
+ Iterator<ISpellDictionary> iter = fDictionaries.iterator();
while (iter.hasNext())
iter.next().setStripNonLetters(ignoreNonLetters);
}
- String word= null;
- boolean starts= false;
+ String word = null;
+ boolean starts = false;
while (iterator.hasNext()) {
- word= iterator.next();
+ word = iterator.next();
if (word != null) {
// synchronizing is necessary as this is called inside the reconciler
if (!fIgnored.contains(word)) {
- starts= iterator.startsSentence();
+ starts = iterator.startsSentence();
if (!isCorrect(word)) {
- boolean isMixed= isMixedCase(word, true);
- boolean isUpper= isUpperCase(word);
- boolean isDigits= isDigits(word);
- boolean isUrl= isUrl(word);
-
- if (!ignoreMixed && isMixed || !ignoreUpper && isUpper || !ignoreDigits && isDigits || !ignoreUrls && isUrl || !(isMixed || isUpper || isDigits || isUrl))
- fireEvent(new SpellEvent(this, word, iterator.getBegin(), iterator.getEnd(), starts, false));
+ boolean isMixed = isMixedCase(word, true);
+ boolean isUpper = isUpperCase(word);
+ boolean isDigits = isDigits(word);
+ boolean isUrl = isUrl(word);
+
+ if (!ignoreMixed && isMixed || !ignoreUpper && isUpper || !ignoreDigits && isDigits
+ || !ignoreUrls && isUrl || !(isMixed || isUpper || isDigits || isUrl))
+ fireEvent(
+ new SpellEvent(this, word, iterator.getBegin(), iterator.getEnd(), starts, false));
} else {
if (!ignoreSentence && starts && Character.isLowerCase(word.charAt(0)))
fireEvent(new SpellEvent(this, word, iterator.getBegin(), iterator.getEnd(), true, true));
@@ -270,7 +273,7 @@ public class DefaultSpellChecker implements ISpellChecker {
// synchronizing is necessary as this is called from execute
Set<ISpellEventListener> copy;
synchronized (fListeners) {
- copy= new HashSet<ISpellEventListener>(fListeners);
+ copy = new HashSet<ISpellEventListener>(fListeners);
}
for (ISpellEventListener spellEventListener : copy) {
spellEventListener.handle(event);
@@ -287,14 +290,14 @@ public class DefaultSpellChecker implements ISpellChecker {
// the modifying methods add/removeDictionary (?)
Set<ISpellDictionary> copy;
synchronized (fDictionaries) {
- copy= new HashSet<ISpellDictionary>(fDictionaries);
+ copy = new HashSet<ISpellDictionary>(fDictionaries);
}
- ISpellDictionary dictionary= null;
- final HashSet<RankedWordProposal> proposals= new HashSet<RankedWordProposal>();
+ ISpellDictionary dictionary = null;
+ final HashSet<RankedWordProposal> proposals = new HashSet<RankedWordProposal>();
- for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
- dictionary= iterator.next();
+ for (final Iterator<ISpellDictionary> iterator = copy.iterator(); iterator.hasNext();) {
+ dictionary = iterator.next();
proposals.addAll(dictionary.getProposals(word, sentence));
}
return proposals;
@@ -317,15 +320,15 @@ public class DefaultSpellChecker implements ISpellChecker {
// synchronizing is necessary as this is called from execute
Set<ISpellDictionary> copy;
synchronized (fDictionaries) {
- copy= new HashSet<ISpellDictionary>(fDictionaries);
+ copy = new HashSet<ISpellDictionary>(fDictionaries);
}
if (fIgnored.contains(word.toLowerCase()))
return true;
- ISpellDictionary dictionary= null;
- for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
- dictionary= iterator.next();
+ ISpellDictionary dictionary = null;
+ for (final Iterator<ISpellDictionary> iterator = copy.iterator(); iterator.hasNext();) {
+ dictionary = iterator.next();
if (dictionary.isCorrect(word))
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java
index 4d7692a37c7..5f3aad9eff2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java
@@ -82,5 +82,5 @@ public interface ISpellCheckEngine {
* @param dictionary the dictionary to unregister
*/
void unregisterDictionary(ISpellDictionary dictionary);
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
index 65f7530c483..9f986a38f9a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
@@ -45,7 +45,7 @@ public interface ISpellCheckIterator extends Iterator<String> {
/**
* Tells whether to ignore single letters
* from being checked.
- *
+ *
* @param state <code>true</code> if single letters should be ignored
*/
public void setIgnoreSingleLetters(boolean state);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java
index 54a4a584a23..ca720926a3a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java
@@ -106,7 +106,7 @@ public interface ISpellChecker {
* @param listener The listener to remove
*/
void removeListener(ISpellEventListener listener);
-
+
/**
* Returns the current locale of the spell check engine.
*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java
index 8f19972954b..692232654ec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java
@@ -67,7 +67,7 @@ public interface ISpellDictionary {
/**
* Tells whether to strip non-letters from word boundaries.
- *
+ *
* @param state <code>true</code> if non-letters should be stripped
*/
public void setStripNonLetters(boolean state);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java
index 7848bf3d767..6a06dadd084 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java
@@ -36,8 +36,8 @@ public class LocaleSensitiveSpellDictionary extends AbstractSpellDictionary {
* @param location The location of the locale sensitive dictionaries
*/
public LocaleSensitiveSpellDictionary(final Locale locale, final URL location) {
- fLocation= location;
- fLocale= locale;
+ fLocation = location;
+ fLocale = locale;
}
/**
@@ -54,6 +54,6 @@ public class LocaleSensitiveSpellDictionary extends AbstractSpellDictionary {
*/
@Override
protected final URL getURL() throws MalformedURLException {
- return new URL(fLocation, fLocale.toString() + ".dictionary"); //$NON-NLS-1$
+ return new URL(fLocation, fLocale.toString() + ".dictionary"); //$NON-NLS-1$
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
index 013be4b2a4c..62d1a839a2c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
@@ -36,7 +36,7 @@ public class PersistentSpellDictionary extends AbstractSpellDictionary {
* @param url The URL of the word list for this dictionary
*/
public PersistentSpellDictionary(final URL url) {
- fLocation= url;
+ fLocation = url;
}
/*
@@ -55,26 +55,26 @@ public class PersistentSpellDictionary extends AbstractSpellDictionary {
if (isCorrect(word))
return;
- FileOutputStream fileStream= null;
+ FileOutputStream fileStream = null;
try {
- Charset charset= Charset.forName(getEncoding());
- ByteBuffer byteBuffer= charset.encode(word + "\n"); //$NON-NLS-1$
- int size= byteBuffer.limit();
+ Charset charset = Charset.forName(getEncoding());
+ ByteBuffer byteBuffer = charset.encode(word + "\n"); //$NON-NLS-1$
+ int size = byteBuffer.limit();
final byte[] byteArray;
if (byteBuffer.hasArray())
- byteArray= byteBuffer.array();
+ byteArray = byteBuffer.array();
else {
- byteArray= new byte[size];
+ byteArray = new byte[size];
byteBuffer.get(byteArray);
}
-
- fileStream= new FileOutputStream(fLocation.getPath(), true);
-
+
+ fileStream = new FileOutputStream(fLocation.getPath(), true);
+
// Encoding UTF-16 charset writes a BOM. In which case we need to cut it away if the file isn't empty
- int bomCutSize= 0;
+ int bomCutSize = 0;
if (!isEmpty() && "UTF-16".equals(charset.name())) //$NON-NLS-1$
- bomCutSize= 2;
-
+ bomCutSize = 2;
+
fileStream.write(byteArray, bomCutSize, size - bomCutSize);
} catch (IOException exception) {
CUIPlugin.log(exception);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java
index d409510e895..b534b4470aa 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java
@@ -32,8 +32,8 @@ public class RankedWordProposal implements Comparable<RankedWordProposal> {
* @param rank The rank of this proposal
*/
public RankedWordProposal(final String text, final int rank) {
- fText= text;
- fRank= rank;
+ fText = text;
+ fRank = rank;
}
/*
@@ -42,7 +42,7 @@ public class RankedWordProposal implements Comparable<RankedWordProposal> {
@Override
public final int compareTo(RankedWordProposal word) {
- final int rank= word.getRank();
+ final int rank = word.getRank();
if (fRank < rank)
return -1;
@@ -96,6 +96,6 @@ public class RankedWordProposal implements Comparable<RankedWordProposal> {
* @param rank The rank to set
*/
public final void setRank(final int rank) {
- fRank= rank;
+ fRank = rank;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java
index b85c5f97689..ea0547e24be 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java
@@ -51,13 +51,14 @@ public class SpellEvent implements ISpellEvent {
* @param match <code>true</code> iff the word was found in the dictionary,
* <code>false</code> otherwise
*/
- protected SpellEvent(final ISpellChecker checker, final String word, final int begin, final int end, final boolean sentence, final boolean match) {
- fChecker= checker;
- fEnd= end;
- fBegin= begin;
- fWord= word;
- fSentence= sentence;
- fMatch= match;
+ protected SpellEvent(final ISpellChecker checker, final String word, final int begin, final int end,
+ final boolean sentence, final boolean match) {
+ fChecker = checker;
+ fEnd = end;
+ fBegin = begin;
+ fWord = word;
+ fSentence = sentence;
+ fMatch = match;
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
index ef1a1b62813..fc55726179f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
@@ -56,20 +56,20 @@ import org.eclipse.cdt.internal.ui.text.contentassist.RelevanceConstants;
public class TemplateEngine {
- private static final String $_LINE_SELECTION= "${" + GlobalTemplateVariables.LineSelection.NAME + '}'; //$NON-NLS-1$
- private static final String $_WORD_SELECTION= "${" + GlobalTemplateVariables.WordSelection.NAME + '}'; //$NON-NLS-1$
+ private static final String $_LINE_SELECTION = "${" + GlobalTemplateVariables.LineSelection.NAME + '}'; //$NON-NLS-1$
+ private static final String $_WORD_SELECTION = "${" + GlobalTemplateVariables.WordSelection.NAME + '}'; //$NON-NLS-1$
/** The context type. */
- private final TemplateContextType fContextType;
+ private final TemplateContextType fContextType;
/** The result proposals. */
- private final ArrayList<ICompletionProposal> fProposals= new ArrayList<ICompletionProposal>();
+ private final ArrayList<ICompletionProposal> fProposals = new ArrayList<ICompletionProposal>();
/** Positions created on the key documents to remove in reset. */
- private final Map<IDocument, Position> fPositions= new HashMap<IDocument, Position>();
+ private final Map<IDocument, Position> fPositions = new HashMap<IDocument, Position>();
/** Pattern to match the start of a line content */
private final Pattern fStartOfLineContentPattern = Pattern.compile("[^ \t]"); //$NON-NLS-1$
public static class CTemplateProposal extends TemplateProposal implements ICCompletionProposal {
-
+
@Override
public IInformationControlCreator getInformationControlCreator() {
return new IInformationControlCreator() {
@@ -82,22 +82,24 @@ public class TemplateEngine {
}
public CTemplateProposal(Template template, TemplateContext context, IRegion region, Image image) {
- super(template, context, region, image, RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.TEMPLATE_TYPE_RELEVANCE);
+ super(template, context, region, image,
+ RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.TEMPLATE_TYPE_RELEVANCE);
}
- @Override
+ @Override
public String getIdString() {
- return getDisplayString();
- }
-
+ return getDisplayString();
+ }
+
}
+
/**
* Creates the template engine for a particular context type.
* See <code>TemplateContext</code> for supported context types.
*/
public TemplateEngine(TemplateContextType contextType) {
Assert.isNotNull(contextType);
- fContextType= contextType;
+ fContextType = contextType;
}
/**
@@ -106,9 +108,9 @@ public class TemplateEngine {
public void reset() {
fProposals.clear();
for (Entry<IDocument, Position> entry2 : fPositions.entrySet()) {
- Entry<IDocument, Position> entry= entry2;
- IDocument doc= entry.getKey();
- Position position= entry.getValue();
+ Entry<IDocument, Position> entry = entry2;
+ IDocument doc = entry.getKey();
+ Position position = entry.getValue();
doc.removePosition(position);
}
fPositions.clear();
@@ -132,9 +134,9 @@ public class TemplateEngine {
if (!(fContextType instanceof TranslationUnitContextType))
return;
- IDocument document= viewer.getDocument();
- Point selection= viewer.getSelectedRange();
- boolean linesSelected= areLinesSelected(viewer);
+ IDocument document = viewer.getDocument();
+ Point selection = viewer.getSelectedRange();
+ boolean linesSelected = areLinesSelected(viewer);
boolean showLineSelectionTemplates = linesSelected;
boolean showWordSelectionTemplates = !linesSelected || isOnlyWordOnLine(viewer);
if (linesSelected) {
@@ -142,34 +144,36 @@ public class TemplateEngine {
try {
IRegion startLine = document.getLineInformationOfOffset(selection.x);
IRegion endLine = document.getLineInformationOfOffset(selection.x + selection.y - 1);
- completionPosition= selection.x= startLine.getOffset();
- selection.y= endLine.getOffset() + endLine.getLength() - startLine.getOffset();
+ completionPosition = selection.x = startLine.getOffset();
+ selection.y = endLine.getOffset() + endLine.getLength() - startLine.getOffset();
} catch (BadLocationException exc) {
}
}
- Position position= new Position(completionPosition, selection.y);
+ Position position = new Position(completionPosition, selection.y);
// remember selected text
- String selectedText= null;
+ String selectedText = null;
if (selection.y != 0) {
try {
- selectedText= document.get(selection.x, selection.y);
+ selectedText = document.get(selection.x, selection.y);
document.addPosition(position);
fPositions.put(document, position);
- } catch (BadLocationException e) {}
+ } catch (BadLocationException e) {
+ }
}
- TranslationUnitContext context= ((TranslationUnitContextType) fContextType).createContext(document, position, translationUnit);
+ TranslationUnitContext context = ((TranslationUnitContextType) fContextType).createContext(document, position,
+ translationUnit);
context.setVariable("selection", selectedText); //$NON-NLS-1$
- int start= context.getStart();
- int end= context.getEnd();
- IRegion region= new Region(start, end - start);
+ int start = context.getStart();
+ int end = context.getEnd();
+ IRegion region = new Region(start, end - start);
- Template[] templates= CUIPlugin.getDefault().getTemplateStore().getTemplates();
+ Template[] templates = CUIPlugin.getDefault().getTemplateStore().getTemplates();
- Image image= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TEMPLATE);
+ Image image = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TEMPLATE);
if (selection.y == 0) {
- for (int i= 0; i != templates.length; i++)
+ for (int i = 0; i != templates.length; i++)
if (context.canEvaluate(templates[i]))
fProposals.add(new CTemplateProposal(templates[i], context, region, image));
@@ -178,13 +182,13 @@ public class TemplateEngine {
if (linesSelected || context.getKey().length() == 0)
context.setForceEvaluation(true);
- for (int i= 0; i != templates.length; i++) {
- Template template= templates[i];
- if (context.canEvaluate(template) &&
- template.getContextTypeId().equals(context.getContextType().getId()) &&
- ((showWordSelectionTemplates && template.getPattern().indexOf($_WORD_SELECTION) != -1 ||
- (showLineSelectionTemplates && template.getPattern().indexOf($_LINE_SELECTION) != -1))))
- {
+ for (int i = 0; i != templates.length; i++) {
+ Template template = templates[i];
+ if (context.canEvaluate(template)
+ && template.getContextTypeId().equals(context.getContextType().getId())
+ && ((showWordSelectionTemplates && template.getPattern().indexOf($_WORD_SELECTION) != -1
+ || (showLineSelectionTemplates
+ && template.getPattern().indexOf($_LINE_SELECTION) != -1)))) {
fProposals.add(new CTemplateProposal(templates[i], context, region, image));
}
}
@@ -196,58 +200,58 @@ public class TemplateEngine {
* Returns <code>true</code> if one line is completely selected or if multiple lines are selected. Being
* completely selected means that all characters are selected except the new line characters and
* leading/trailing spaces.
- *
+ *
* @return <code>true</code> if one or multiple lines are selected
*/
private boolean areLinesSelected(ITextViewer viewer) {
if (viewer == null)
return false;
- Point s= viewer.getSelectedRange();
+ Point s = viewer.getSelectedRange();
if (s.y == 0)
return false;
try {
- IDocument document= viewer.getDocument();
- int startLine= document.getLineOfOffset(s.x);
- IRegion line= document.getLineInformation(startLine);
-
+ IDocument document = viewer.getDocument();
+ int startLine = document.getLineOfOffset(s.x);
+ IRegion line = document.getLineInformation(startLine);
+
String lineContent = document.get(line.getOffset(), line.getLength());
Matcher m = fStartOfLineContentPattern.matcher(lineContent);
int lineContentStart = 0;
- if(m.find())
+ if (m.find())
lineContentStart = m.start() + line.getOffset();
int lineContentLength = lineContent.trim().length();
-
+
return s.x <= lineContentStart && s.x + s.y >= lineContentStart + lineContentLength;
} catch (BadLocationException x) {
return false;
}
}
-
+
/**
* Returns <code>true</code> if there's only one word on the line
- *
+ *
* @return <code>true</code> if only one word is on the line
*/
private boolean isOnlyWordOnLine(ITextViewer viewer) {
if (viewer == null)
return false;
- Point s= viewer.getSelectedRange();
+ Point s = viewer.getSelectedRange();
if (s.y == 0)
return false;
try {
- IDocument document= viewer.getDocument();
- int startLine= document.getLineOfOffset(s.x);
- IRegion line= document.getLineInformation(startLine);
-
+ IDocument document = viewer.getDocument();
+ int startLine = document.getLineOfOffset(s.x);
+ IRegion line = document.getLineInformation(startLine);
+
String lineContent = document.get(line.getOffset(), line.getLength());
-
+
return lineContent.trim().lastIndexOf(' ', s.x) == -1;
} catch (BadLocationException x) {
@@ -255,4 +259,3 @@ public class TemplateEngine {
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
index d4817078055..18684e39229 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
@@ -28,11 +28,9 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.jface.text.templates.TemplateContextType;
import org.eclipse.jface.text.templates.TemplateVariableResolver;
-
-
public class TemplateVariableProcessor implements IContentAssistProcessor {
- private static Comparator<TemplateVariableProposal> fgTemplateVariableProposalComparator= new Comparator<TemplateVariableProposal>() {
+ private static Comparator<TemplateVariableProposal> fgTemplateVariableProposalComparator = new Comparator<TemplateVariableProposal>() {
@Override
public int compare(TemplateVariableProposal arg0, TemplateVariableProposal arg1) {
return arg0.getDisplayString().compareTo(arg1.getDisplayString());
@@ -44,22 +42,21 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
}
};
-
/** the context type */
private TemplateContextType fContextType;
/**
* Sets the context type.
- *
- * @param contextType the context type
+ *
+ * @param contextType the context type
*/
public void setContextType(TemplateContextType contextType) {
- fContextType= contextType;
+ fContextType = contextType;
}
/**
* Gets the context type.
- *
+ *
* @return the context type
*/
public TemplateContextType getContextType() {
@@ -70,42 +67,42 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
* @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
*/
@Override
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
if (fContextType == null)
return null;
- List<TemplateVariableProposal> proposals= new ArrayList<TemplateVariableProposal>();
+ List<TemplateVariableProposal> proposals = new ArrayList<TemplateVariableProposal>();
- String text= viewer.getDocument().get();
- int start= getStart(text, documentOffset);
- int end= documentOffset;
+ String text = viewer.getDocument().get();
+ int start = getStart(text, documentOffset);
+ int end = documentOffset;
- String string= text.substring(start, end);
- int colon= string.indexOf(':');
- boolean includeBrace= true;
- int offset= start;
- String prefix= string;
+ String string = text.substring(start, end);
+ int colon = string.indexOf(':');
+ boolean includeBrace = true;
+ int offset = start;
+ String prefix = string;
if (colon != -1) {
- includeBrace= false;
- offset= start + colon + 1;
- prefix= string.substring(colon + 1);
+ includeBrace = false;
+ offset = start + colon + 1;
+ prefix = string.substring(colon + 1);
} else {
- int escape= string.indexOf("${"); //$NON-NLS-1$
+ int escape = string.indexOf("${"); //$NON-NLS-1$
if (escape != -1) {
- offset= start + escape + 2;
- includeBrace= false;
- prefix= string.substring(escape + 2);
+ offset = start + escape + 2;
+ includeBrace = false;
+ prefix = string.substring(escape + 2);
}
}
if (prefix.equals("$")) //$NON-NLS-1$
- prefix= ""; //$NON-NLS-1$
+ prefix = ""; //$NON-NLS-1$
- int length= end - offset;
+ int length = end - offset;
final Iterator<TemplateVariableResolver> resolvers = fContextType.resolvers();
while (resolvers.hasNext()) {
- TemplateVariableResolver variable= resolvers.next();
+ TemplateVariableResolver variable = resolvers.next();
if (variable.getType().startsWith(prefix))
proposals.add(new TemplateVariableProposal(variable, offset, length, viewer, includeBrace));
@@ -117,14 +114,14 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
/* Guesses the start position of the completion */
private int getStart(String string, int end) {
- int start= end;
+ int start = end;
if (start >= 1 && string.charAt(start - 1) == '$')
return start - 1;
while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1)))
start--;
-
+
if (start >= 1 && string.charAt(start - 1) == ':') {
start--;
while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1)))
@@ -150,7 +147,7 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
*/
@Override
public char[] getCompletionProposalAutoActivationCharacters() {
- return new char[] {'$'};
+ return new char[] { '$' };
}
/*
@@ -178,4 +175,3 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java
index 2172d1b3841..a8580dc07ec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java
@@ -47,14 +47,15 @@ public class TemplateVariableProposal implements ICompletionProposal {
* @param offset the offset to replace
* @param length the length to replace
* @param viewer the viewer
- * @param includeBrace whether to also replace the ${
+ * @param includeBrace whether to also replace the ${
*/
- public TemplateVariableProposal(TemplateVariableResolver variable, int offset, int length, ITextViewer viewer, boolean includeBrace) {
- fResolver= variable;
- fOffset= offset;
- fLength= length;
- fViewer= viewer;
- fIncludeBrace= includeBrace;
+ public TemplateVariableProposal(TemplateVariableResolver variable, int offset, int length, ITextViewer viewer,
+ boolean includeBrace) {
+ fResolver = variable;
+ fOffset = offset;
+ fLength = length;
+ fViewer = viewer;
+ fIncludeBrace = includeBrace;
}
/*
@@ -65,20 +66,20 @@ public class TemplateVariableProposal implements ICompletionProposal {
try {
String variable;
- String type= fResolver.getType();
+ String type = fResolver.getType();
if (type.equals("dollar")) //$NON-NLS-1$
- variable= "$$"; //$NON-NLS-1$
+ variable = "$$"; //$NON-NLS-1$
else if (fIncludeBrace)
- variable= "${" + type + '}'; //$NON-NLS-1$
+ variable = "${" + type + '}'; //$NON-NLS-1$
else
- variable= type;
+ variable = type;
document.replace(fOffset, fLength, variable);
- fSelection= new Point(fOffset + variable.length(), 0);
+ fSelection = new Point(fOffset + variable.length(), 0);
} catch (BadLocationException e) {
CUIPlugin.log(e);
- Shell shell= fViewer.getTextWidget().getShell();
+ Shell shell = fViewer.getTextWidget().getShell();
MessageDialog.openError(shell, TemplateMessages.TemplateVariableProposal_error_title, e.getMessage());
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
index 46a603a7a9c..9e0ec4c93ae 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
@@ -14,7 +14,7 @@
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text.util;
-
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -29,9 +29,9 @@ import org.eclipse.cdt.ui.text.IColorManager;
* CDT color manager.
*/
public class CColorManager implements IColorManager {
- protected Map<String, RGB> fKeyTable= new HashMap<>(10);
- protected Map<Display, Map<RGB, Color>> fDisplayTable= new HashMap<>(2);
-
+ protected Map<String, RGB> fKeyTable = new HashMap<>(10);
+ protected Map<Display, Map<RGB, Color>> fDisplayTable = new HashMap<>(2);
+
/**
* Flag which tells if the colors are automatically disposed when
* the current display gets disposed.
@@ -58,27 +58,27 @@ public class CColorManager implements IColorManager {
* @since 4.0
*/
public CColorManager(boolean autoDisposeOnDisplayDispose) {
- fAutoDisposeOnDisplayDispose= autoDisposeOnDisplayDispose;
+ fAutoDisposeOnDisplayDispose = autoDisposeOnDisplayDispose;
}
- protected void dispose(Display display) {
- Map<RGB, Color> colorTable= fDisplayTable.get(display);
+ protected void dispose(Display display) {
+ Map<RGB, Color> colorTable = fDisplayTable.get(display);
if (colorTable != null) {
- Iterator<Color> e= colorTable.values().iterator();
+ Iterator<Color> e = colorTable.values().iterator();
while (e.hasNext())
(e.next()).dispose();
}
}
-
+
@Override
public Color getColor(RGB rgb) {
if (rgb == null)
return null;
-
- final Display display= Display.getCurrent();
- Map<RGB, Color> colorTable= fDisplayTable.get(display);
+
+ final Display display = Display.getCurrent();
+ Map<RGB, Color> colorTable = fDisplayTable.get(display);
if (colorTable == null) {
- colorTable= new HashMap<>(10);
+ colorTable = new HashMap<>(10);
fDisplayTable.put(display, colorTable);
if (fAutoDisposeOnDisplayDispose) {
display.disposeExec(new Runnable() {
@@ -89,16 +89,16 @@ public class CColorManager implements IColorManager {
});
}
}
-
- Color color= colorTable.get(rgb);
+
+ Color color = colorTable.get(rgb);
if (color == null) {
- color= new Color(Display.getCurrent(), rgb);
+ color = new Color(Display.getCurrent(), rgb);
colorTable.put(rgb, color);
}
-
+
return color;
}
-
+
@Override
public void dispose() {
if (!fAutoDisposeOnDisplayDispose)
@@ -107,20 +107,20 @@ public class CColorManager implements IColorManager {
@Override
public Color getColor(String key) {
-
+
if (key == null)
return null;
-
- RGB rgb= fKeyTable.get(key);
+
+ RGB rgb = fKeyTable.get(key);
return getColor(rgb);
}
-
+
@Override
public void bindColor(String key, RGB rgb) {
- Object value= fKeyTable.get(key);
+ Object value = fKeyTable.get(key);
if (value != null)
throw new UnsupportedOperationException();
-
+
fKeyTable.put(key, rgb);
}
@@ -129,5 +129,3 @@ public class CColorManager implements IColorManager {
fKeyTable.remove(key);
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.java
index 381d36f2b1d..f6b554eb040 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyAction.java
index b1c14449f0f..b410a5ba223 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyAction.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
@@ -24,8 +24,6 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
-
-
public class OpenTypeHierarchyAction extends SelectionDispatchAction {
private ITextEditor fEditor;
@@ -35,23 +33,24 @@ public class OpenTypeHierarchyAction extends SelectionDispatchAction {
setText(Messages.OpenTypeHierarchyAction_label);
setToolTipText(Messages.OpenTypeHierarchyAction_tooltip);
}
-
+
public OpenTypeHierarchyAction(ITextEditor editor) {
this(editor.getSite());
- fEditor= editor;
- setEnabled(fEditor != null && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
+ fEditor = editor;
+ setEnabled(fEditor != null
+ && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
}
@Override
public void run(ITextSelection sel) {
TypeHierarchyUI.open(fEditor, sel);
}
-
+
@Override
public void run(IStructuredSelection selection) {
if (!selection.isEmpty()) {
- Object selectedObject= selection.getFirstElement();
- ICElement elem= getAdapter(selectedObject, ICElement.class);
+ Object selectedObject = selection.getFirstElement();
+ ICElement elem = getAdapter(selectedObject, ICElement.class);
if (elem != null) {
TypeHierarchyUI.open(elem, getSite().getWorkbenchWindow());
}
@@ -61,20 +60,19 @@ public class OpenTypeHierarchyAction extends SelectionDispatchAction {
@Override
public void selectionChanged(ITextSelection sel) {
}
-
+
@Override
public void selectionChanged(IStructuredSelection selection) {
if (selection.isEmpty()) {
setEnabled(false);
return;
}
-
- Object selectedObject= selection.getFirstElement();
- ICElement elem= getAdapter(selectedObject, ICElement.class);
+
+ Object selectedObject = selection.getFirstElement();
+ ICElement elem = getAdapter(selectedObject, ICElement.class);
if (elem != null) {
setEnabled(TypeHierarchyUI.isValidInput(elem));
- }
- else {
+ } else {
setEnabled(false);
}
}
@@ -85,7 +83,7 @@ public class OpenTypeHierarchyAction extends SelectionDispatchAction {
return (T) object;
}
if (object instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) object;
+ IAdaptable adaptable = (IAdaptable) object;
return adaptable.getAdapter(desiredClass);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java
index 161dcf8a1da..9f0cb325878 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
@@ -35,10 +35,9 @@ import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate {
- private static final int[] VISIBLE_TYPES = {
- ICElement.C_CLASS, ICElement.C_STRUCT, ICElement.C_TYPEDEF, ICElement.C_ENUMERATION,
- ICElement.C_UNION };
-
+ private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT, ICElement.C_TYPEDEF,
+ ICElement.C_ENUMERATION, ICElement.C_UNION };
+
private IWorkbenchWindow fWorkbenchWindow;
public OpenTypeInHierarchyAction() {
@@ -51,26 +50,26 @@ public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate
int result = dialog.open();
if (result != IDialogConstants.OK_ID)
return;
-
+
ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
if (info == null)
return;
-
- ICElement[] elements= null;
+
+ ICElement[] elements = null;
ITypeReference location = info.getResolvedReference();
if (location != null) {
- elements= location.getCElements();
+ elements = location.getCElements();
}
if (elements == null || elements.length == 0) {
String title = Messages.OpenTypeInHierarchyAction_errorTitle;
- String message = NLS.bind(Messages.OpenTypeInHierarchyAction_errorNoDefinition, info.getQualifiedTypeName().toString());
+ String message = NLS.bind(Messages.OpenTypeInHierarchyAction_errorNoDefinition,
+ info.getQualifiedTypeName().toString());
MessageDialog.openError(getShell(), title, message);
- }
- else {
+ } else {
TypeHierarchyUI.open(elements[0], fWorkbenchWindow);
}
}
-
+
private void configureDialog(ElementSelectionDialog dialog) {
dialog.setDialogSettings(getClass().getName());
dialog.setVisibleTypes(VISIBLE_TYPES);
@@ -79,13 +78,13 @@ public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate
dialog.setMessage(Messages.OpenTypeInHierarchyAction_message);
if (fWorkbenchWindow != null) {
- IWorkbenchPage page= fWorkbenchWindow.getActivePage();
+ IWorkbenchPage page = fWorkbenchWindow.getActivePage();
if (page != null) {
- IWorkbenchPart part= page.getActivePart();
+ IWorkbenchPart part = page.getActivePart();
if (part instanceof ITextEditor) {
- ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection();
+ ISelection sel = ((ITextEditor) part).getSelectionProvider().getSelection();
if (sel instanceof ITextSelection) {
- String txt= ((ITextSelection) sel).getText();
+ String txt = ((ITextSelection) sel).getText();
if (txt.length() > 0 && txt.length() < 80) {
dialog.setFilter(txt, true);
}
@@ -101,14 +100,14 @@ public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate
@Override
public void dispose() {
- fWorkbenchWindow= null;
+ fWorkbenchWindow = null;
}
-
+
@Override
public void init(IWorkbenchWindow window) {
- fWorkbenchWindow= window;
+ fWorkbenchWindow = window;
}
-
+
@Override
public void selectionChanged(IAction action, ISelection selection) {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.java
index 2293e7c10c8..63ae5e8b947 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.java
@@ -10,58 +10,58 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
public class THContentProvider implements ITreeContentProvider {
- private static final Object[] NO_CHILDREN= {};
- private THHierarchyModel fModel;
+ private static final Object[] NO_CHILDREN = {};
+ private THHierarchyModel fModel;
public THContentProvider() {
}
- @Override
+ @Override
final public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- fModel= (THHierarchyModel) newInput;
- }
+ fModel = (THHierarchyModel) newInput;
+ }
- @Override
+ @Override
public void dispose() {
- fModel= null;
- }
+ fModel = null;
+ }
- @Override
+ @Override
final public Object[] getElements(Object inputElement) {
- if (fModel == null) {
- return NO_CHILDREN;
- }
- return fModel.getHierarchyRootElements();
- }
+ if (fModel == null) {
+ return NO_CHILDREN;
+ }
+ return fModel.getHierarchyRootElements();
+ }
- @Override
+ @Override
final public boolean hasChildren(Object element) {
- if (element instanceof THNode) {
- return ((THNode) element).hasChildren();
- }
- return false;
- }
+ if (element instanceof THNode) {
+ return ((THNode) element).hasChildren();
+ }
+ return false;
+ }
- @Override
+ @Override
public Object[] getChildren(Object element) {
- if (element instanceof THNode) {
- return ((THNode) element).getChildren();
- }
- return NO_CHILDREN;
- }
+ if (element instanceof THNode) {
+ return ((THNode) element).getChildren();
+ }
+ return NO_CHILDREN;
+ }
@Override
public Object getParent(Object element) {
- if (element instanceof THNode) {
- return ((THNode) element).getParent();
- }
- return null;
+ if (element instanceof THNode) {
+ return ((THNode) element).getParent();
+ }
+ return null;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java
index 2d3587dde5b..04014fa6c97 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
@@ -28,45 +28,44 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.cdt.core.model.ICElement;
-
public class THDropTargetListener implements DropTargetListener {
private ICElement fInput;
- private boolean fEnabled= true;
+ private boolean fEnabled = true;
private IWorkbenchWindow fWindow;
- public THDropTargetListener(THViewPart view) {
- fWindow= view.getSite().getWorkbenchWindow();
- }
-
- public void setEnabled(boolean val) {
- fEnabled= val;
- }
-
- @Override
+ public THDropTargetListener(THViewPart view) {
+ fWindow = view.getSite().getWorkbenchWindow();
+ }
+
+ public void setEnabled(boolean val) {
+ fEnabled = val;
+ }
+
+ @Override
public void dragEnter(DropTargetEvent event) {
- fInput= null;
- checkOperation(event);
- if (event.detail != DND.DROP_NONE) {
+ fInput = null;
+ checkOperation(event);
+ if (event.detail != DND.DROP_NONE) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
- fInput= checkLocalSelection();
+ fInput = checkLocalSelection();
if (!TypeHierarchyUI.isValidInput(fInput)) {
- event.detail= DND.DROP_NONE;
- fInput= null;
+ event.detail = DND.DROP_NONE;
+ fInput = null;
}
- }
- }
- }
+ }
+ }
+ }
private ICElement checkLocalSelection() {
- ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
+ ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
if (sel instanceof IStructuredSelection) {
- for (Iterator<?> iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
+ for (Iterator<?> iter = ((IStructuredSelection) sel).iterator(); iter.hasNext();) {
Object element = iter.next();
if (element instanceof ICElement) {
return (ICElement) element;
}
if (element instanceof IAdaptable) {
- ICElement adapter= ((IAdaptable) element).getAdapter(ICElement.class);
+ ICElement adapter = ((IAdaptable) element).getAdapter(ICElement.class);
if (adapter != null) {
return adapter;
}
@@ -76,39 +75,37 @@ public class THDropTargetListener implements DropTargetListener {
return null;
}
- @Override
+ @Override
public void dragLeave(DropTargetEvent event) {
- }
+ }
- @Override
+ @Override
public void dragOperationChanged(DropTargetEvent event) {
- checkOperation(event);
- }
+ checkOperation(event);
+ }
- @Override
+ @Override
public void dragOver(DropTargetEvent event) {
- }
+ }
- @Override
+ @Override
public void drop(DropTargetEvent event) {
- if (fInput == null) {
- Display.getCurrent().beep();
- }
- else {
- TypeHierarchyUI.open(fInput, fWindow);
- }
- }
+ if (fInput == null) {
+ Display.getCurrent().beep();
+ } else {
+ TypeHierarchyUI.open(fInput, fWindow);
+ }
+ }
- @Override
+ @Override
public void dropAccept(DropTargetEvent event) {
- }
-
- private void checkOperation(DropTargetEvent event) {
- if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
- event.detail= DND.DROP_COPY;
- }
- else {
- event.detail= DND.DROP_NONE;
- }
- }
+ }
+
+ private void checkOperation(DropTargetEvent event) {
+ if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
+ event.detail = DND.DROP_COPY;
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java
index 2452c57f6f4..13d8e5a8abc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
import java.util.ArrayList;
@@ -42,39 +42,39 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
class THGraph {
private static final ICElement[] NO_MEMBERS = {};
private THGraphNode fInputNode;
- private HashSet<THGraphNode> fRootNodes= new HashSet<>();
- private HashSet<THGraphNode> fLeafNodes= new HashSet<>();
- private HashMap<ICElement, THGraphNode> fNodes= new HashMap<>();
+ private HashSet<THGraphNode> fRootNodes = new HashSet<>();
+ private HashSet<THGraphNode> fLeafNodes = new HashSet<>();
+ private HashMap<ICElement, THGraphNode> fNodes = new HashMap<>();
private boolean fFileIsIndexed;
-
+
public THGraph() {
}
public THGraphNode getInputNode() {
return fInputNode;
}
-
+
public THGraphNode getNode(ICElement elem) {
return fNodes.get(elem);
}
private THGraphNode addNode(ICElement input) {
- THGraphNode node= fNodes.get(input);
+ THGraphNode node = fNodes.get(input);
if (node == null) {
- node= new THGraphNode(input);
+ node = new THGraphNode(input);
fNodes.put(input, node);
fRootNodes.add(node);
fLeafNodes.add(node);
}
return node;
}
-
+
private THGraphEdge addEdge(THGraphNode from, THGraphNode to) {
if (createsLoopOrIsDuplicate(from, to)) {
return null;
}
- THGraphEdge edge= new THGraphEdge(from, to);
+ THGraphEdge edge = new THGraphEdge(from, to);
from.startEdge(edge);
to.endEdge(edge);
fRootNodes.remove(to);
@@ -89,16 +89,16 @@ class THGraph {
if (to.getOutgoing().isEmpty() || from.getIncoming().isEmpty()) {
return false;
}
-
- HashSet<THGraphNode> checked= new HashSet<>();
- ArrayList<THGraphNode> stack= new ArrayList<>();
+
+ HashSet<THGraphNode> checked = new HashSet<>();
+ ArrayList<THGraphNode> stack = new ArrayList<>();
stack.add(to);
-
+
while (!stack.isEmpty()) {
- THGraphNode node= stack.remove(stack.size() - 1);
- List<THGraphEdge> out= node.getOutgoing();
+ THGraphNode node = stack.remove(stack.size() - 1);
+ List<THGraphEdge> out = node.getOutgoing();
for (THGraphEdge edge : out) {
- node= edge.getEndNode();
+ node = edge.getEndNode();
if (node == from) {
return true;
}
@@ -108,7 +108,7 @@ class THGraph {
}
}
// Check if edge is already there.
- List<THGraphEdge> out= from.getOutgoing();
+ List<THGraphEdge> out = from.getOutgoing();
for (THGraphEdge edge : out) {
if (edge.getEndNode() == to) {
return true;
@@ -129,9 +129,9 @@ class THGraph {
if (input != null) {
try {
if (IndexUI.isIndexed(index, input)) {
- fFileIsIndexed= true;
- input= IndexUI.attemptConvertionToHandle(index, input);
- fInputNode= addNode(input);
+ fFileIsIndexed = true;
+ input = IndexUI.attemptConvertionToHandle(index, input);
+ fInputNode = addNode(input);
}
} catch (CoreException e) {
CUIPlugin.log(e);
@@ -143,35 +143,35 @@ class THGraph {
if (fInputNode == null) {
return;
}
- HashSet<ICElement> handled= new HashSet<>();
- ArrayList<ICElement> stack= new ArrayList<>();
+ HashSet<ICElement> handled = new HashSet<>();
+ ArrayList<ICElement> stack = new ArrayList<>();
stack.add(fInputNode.getElement());
handled.add(fInputNode.getElement());
while (!stack.isEmpty()) {
if (monitor.isCanceled()) {
return;
}
- ICElement elem= stack.remove(stack.size() - 1);
- THGraphNode graphNode= addNode(elem);
+ ICElement elem = stack.remove(stack.size() - 1);
+ THGraphNode graphNode = addNode(elem);
try {
IIndexBinding binding = IndexUI.elementToBinding(index, elem);
if (binding != null) {
addMembers(index, graphNode, binding);
}
if (binding instanceof ICPPClassType) {
- ICPPClassType ct= (ICPPClassType) binding;
- ICPPBase[] bases= ct.getBases();
+ ICPPClassType ct = (ICPPClassType) binding;
+ ICPPBase[] bases = ct.getBases();
for (ICPPBase base : bases) {
if (monitor.isCanceled()) {
return;
}
- IType baseType= base.getBaseClassType();
+ IType baseType = base.getBaseClassType();
if (baseType instanceof IBinding) {
final IBinding baseBinding = (IBinding) baseType;
- ICElementHandle[] baseElems= IndexUI.findRepresentative(index, baseBinding);
+ ICElementHandle[] baseElems = IndexUI.findRepresentative(index, baseBinding);
for (ICElementHandle baseElem : baseElems) {
- THGraphNode baseGraphNode= addNode(baseElem);
- addMembers(index, baseGraphNode, baseBinding);
+ THGraphNode baseGraphNode = addNode(baseElem);
+ addMembers(index, baseGraphNode, baseBinding);
addEdge(graphNode, baseGraphNode);
if (handled.add(baseElem)) {
stack.add(baseElem);
@@ -180,15 +180,15 @@ class THGraph {
}
}
} else if (binding instanceof ITypedef) {
- ITypedef ct= (ITypedef) binding;
- IType type= ct.getType();
+ ITypedef ct = (ITypedef) binding;
+ IType type = ct.getType();
if (type instanceof IBinding) {
- IBinding basecl= (IBinding) type;
- ICElementHandle[] baseElems= IndexUI.findRepresentative(index, basecl);
+ IBinding basecl = (IBinding) type;
+ ICElementHandle[] baseElems = IndexUI.findRepresentative(index, basecl);
if (baseElems.length > 0) {
- ICElementHandle baseElem= baseElems[0];
- THGraphNode baseGraphNode= addNode(baseElem);
- addMembers(index, baseGraphNode, basecl);
+ ICElementHandle baseElem = baseElems[0];
+ THGraphNode baseGraphNode = addNode(baseElem);
+ addMembers(index, baseGraphNode, basecl);
addEdge(graphNode, baseGraphNode);
if (handled.add(baseElem)) {
stack.add(baseElem);
@@ -206,8 +206,8 @@ class THGraph {
if (fInputNode == null) {
return;
}
- HashSet<ICElement> handled= new HashSet<>();
- ArrayList<ICElement> stack= new ArrayList<>();
+ HashSet<ICElement> handled = new HashSet<>();
+ ArrayList<ICElement> stack = new ArrayList<>();
ICElement element = fInputNode.getElement();
stack.add(element);
handled.add(element);
@@ -215,26 +215,26 @@ class THGraph {
if (monitor.isCanceled()) {
return;
}
- ICElement elem= stack.remove(stack.size() - 1);
- THGraphNode graphNode= addNode(elem);
+ ICElement elem = stack.remove(stack.size() - 1);
+ THGraphNode graphNode = addNode(elem);
try {
IBinding binding = IndexUI.elementToBinding(index, elem);
if (binding != null) {
// TODO(nathanridge): Also find subclasses referenced via decltype-specifiers rather than names.
- IIndexName[] names= index.findNames(binding, IIndex.FIND_REFERENCES | IIndex.FIND_DEFINITIONS);
+ IIndexName[] names = index.findNames(binding, IIndex.FIND_REFERENCES | IIndex.FIND_DEFINITIONS);
for (IIndexName indexName : names) {
if (monitor.isCanceled()) {
return;
}
if (indexName.isBaseSpecifier()) {
- IIndexName subClassDef= indexName.getEnclosingDefinition();
+ IIndexName subClassDef = indexName.getEnclosingDefinition();
if (subClassDef != null) {
- IBinding subClass= index.findBinding(subClassDef);
- ICElementHandle[] subClassElems= IndexUI.findRepresentative(index, subClass);
+ IBinding subClass = index.findBinding(subClassDef);
+ ICElementHandle[] subClassElems = IndexUI.findRepresentative(index, subClass);
if (subClassElems.length > 0) {
- ICElementHandle subClassElem= subClassElems[0];
- THGraphNode subGraphNode= addNode(subClassElem);
- addMembers(index, subGraphNode, subClass);
+ ICElementHandle subClassElem = subClassElems[0];
+ THGraphNode subGraphNode = addNode(subClassElem);
+ addMembers(index, subGraphNode, subClass);
addEdge(subGraphNode, graphNode);
if (handled.add(subClassElem)) {
stack.add(subClassElem);
@@ -249,23 +249,23 @@ class THGraph {
}
}
}
-
+
private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws CoreException {
if (graphNode.getMembers(false) == null) {
- ArrayList<ICElement> memberList= new ArrayList<>();
+ ArrayList<ICElement> memberList = new ArrayList<>();
if (binding instanceof ICPPClassType) {
- ICPPClassType ct= (ICPPClassType) binding;
- IBinding[] members= ct.getDeclaredFields();
+ ICPPClassType ct = (ICPPClassType) binding;
+ IBinding[] members = ct.getDeclaredFields();
addMemberElements(index, members, memberList);
- members= ct.getDeclaredMethods();
+ members = ct.getDeclaredMethods();
addMemberElements(index, members, memberList);
} else if (binding instanceof ICompositeType) {
- ICompositeType ct= (ICompositeType) binding;
- IBinding[] members= ct.getFields();
+ ICompositeType ct = (ICompositeType) binding;
+ IBinding[] members = ct.getFields();
addMemberElements(index, members, memberList);
} else if (binding instanceof IEnumeration) {
- IEnumeration ct= (IEnumeration) binding;
- IBinding[] members= ct.getEnumerators();
+ IEnumeration ct = (IEnumeration) binding;
+ IBinding[] members = ct.getEnumerators();
addMemberElements(index, members, memberList);
}
@@ -276,11 +276,10 @@ class THGraph {
}
}
}
-
- private void addMemberElements(IIndex index, IBinding[] members, List<ICElement> memberList)
- throws CoreException {
+
+ private void addMemberElements(IIndex index, IBinding[] members, List<ICElement> memberList) throws CoreException {
for (IBinding binding : members) {
- ICElement[] elems= IndexUI.findRepresentative(index, binding);
+ ICElement[] elems = IndexUI.findRepresentative(index, binding);
if (elems.length > 0) {
memberList.add(elems[0]);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.java
index fbc6c614dc7..2739ea048f1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.java
@@ -10,22 +10,22 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
class THGraphEdge {
private THGraphNode fFrom;
private THGraphNode fTo;
-
+
THGraphEdge(THGraphNode from, THGraphNode to) {
- fFrom= from;
- fTo= to;
+ fFrom = from;
+ fTo = to;
}
-
+
THGraphNode getStartNode() {
return fFrom;
}
-
+
THGraphNode getEndNode() {
return fTo;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.java
index efcb61f5d18..1aa296b4215 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
import java.util.ArrayList;
@@ -21,23 +21,23 @@ import java.util.List;
import org.eclipse.cdt.core.model.ICElement;
class THGraphNode {
- private List<THGraphEdge> fOutgoing= Collections.emptyList();
- private List<THGraphEdge> fIncoming= Collections.emptyList();
+ private List<THGraphEdge> fOutgoing = Collections.emptyList();
+ private List<THGraphEdge> fIncoming = Collections.emptyList();
private ICElement fElement;
private ICElement[] fMembers;
-
+
THGraphNode(ICElement element) {
- fElement= element;
+ fElement = element;
}
-
+
void startEdge(THGraphEdge outgoing) {
- fOutgoing= addElement(fOutgoing, outgoing);
+ fOutgoing = addElement(fOutgoing, outgoing);
}
void endEdge(THGraphEdge incoming) {
- fIncoming= addElement(fIncoming, incoming);
+ fIncoming = addElement(fIncoming, incoming);
}
-
+
ICElement getElement() {
return fElement;
}
@@ -47,7 +47,7 @@ class THGraphNode {
case 0:
return Collections.singletonList(elem);
case 1:
- list= new ArrayList<>(list);
+ list = new ArrayList<>(list);
list.add(elem);
return list;
}
@@ -58,20 +58,20 @@ class THGraphNode {
List<THGraphEdge> getOutgoing() {
return fOutgoing;
}
-
+
List<THGraphEdge> getIncoming() {
return fIncoming;
}
public void setMembers(ICElement[] array) {
- fMembers= array;
+ fMembers = array;
}
-
+
public ICElement[] getMembers(boolean addInherited) {
if (!addInherited) {
return fMembers;
}
- ArrayList<ICElement> list= new ArrayList<>();
+ ArrayList<ICElement> list = new ArrayList<>();
collectMembers(new HashSet<THGraphNode>(), list);
return list.toArray(new ICElement[list.size()]);
}
@@ -81,7 +81,7 @@ class THGraphNode {
if (fMembers != null) {
Collections.addAll(list, fMembers);
}
- List<THGraphEdge> bases= getOutgoing();
+ List<THGraphEdge> bases = getOutgoing();
for (THGraphEdge edge : bases) {
edge.getEndNode().collectMembers(visited, list);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java
index e781abe2ad9..6b3cb5fb866 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
import java.util.ArrayList;
@@ -39,7 +39,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
class THHierarchyModel {
- public class BackgroundJob extends Job {
+ public class BackgroundJob extends Job {
public BackgroundJob() {
super(Messages.THHierarchyModel_Job_title);
}
@@ -49,39 +49,39 @@ class THHierarchyModel {
return onComputeGraph(this, monitor);
}
}
-
+
static final int TYPE_HIERARCHY = 0;
- static final int SUB_TYPE_HIERARCHY = 1;
- static final int SUPER_TYPE_HIERARCHY = 2;
+ static final int SUB_TYPE_HIERARCHY = 1;
+ static final int SUPER_TYPE_HIERARCHY = 2;
static final int END_OF_COMPUTATION = 0;
-
+
private static final ISchedulingRule RULE = new THSchedulingRule();
- private static final Object[] NO_CHILDREN= {};
+ private static final Object[] NO_CHILDREN = {};
private ICElement fInput;
private int fHierarchyKind;
private boolean fShowInheritedMembers;
-
+
private THGraph fGraph;
private THNode[] fRootNodes;
private THNode fSelectedTypeNode;
private ICElement fTypeToSelect;
private ICElement fSelectedMember;
private String fMemberSignatureToSelect;
-
+
private Job fJob;
private Display fDisplay;
private ITHModelPresenter fView;
private WorkingSetFilterUI fFilter;
private final boolean fHideNonImplementorLeaves;
-
+
public THHierarchyModel(ITHModelPresenter view, Display display, boolean hideNonImplementors) {
- fDisplay= display;
- fView= view;
- fHideNonImplementorLeaves= hideNonImplementors;
+ fDisplay = display;
+ fView = view;
+ fHideNonImplementorLeaves = hideNonImplementors;
}
-
+
public ICElement getInput() {
return fInput;
}
@@ -113,27 +113,27 @@ class THHierarchyModel {
}
public void setWorkingSetFilter(WorkingSetFilterUI filterUI) {
- fFilter= filterUI;
+ fFilter = filterUI;
computeNodes();
}
synchronized public void setInput(ICElement input, ICElement member) {
stopGraphComputation();
- fInput= input;
- fSelectedMember= member;
- fMemberSignatureToSelect= TypeHierarchyUI.getLocalElementSignature(fSelectedMember);
- fRootNodes= null;
- fSelectedTypeNode= null;
- fTypeToSelect= input;
- }
-
+ fInput = input;
+ fSelectedMember = member;
+ fMemberSignatureToSelect = TypeHierarchyUI.getLocalElementSignature(fSelectedMember);
+ fRootNodes = null;
+ fSelectedTypeNode = null;
+ fTypeToSelect = input;
+ }
+
synchronized public void computeGraph() {
if (fJob != null) {
fJob.cancel();
}
- fJob= new BackgroundJob();
+ fJob = new BackgroundJob();
fJob.setRule(RULE);
- IWorkbenchSiteProgressService ps= fView.getProgressService();
+ IWorkbenchSiteProgressService ps = fView.getProgressService();
if (ps != null) {
ps.schedule(fJob, 0L, true);
} else {
@@ -145,27 +145,28 @@ class THHierarchyModel {
if (fJob != null) {
fJob.cancel();
}
- fJob= null;
+ fJob = null;
}
protected IStatus onComputeGraph(Job job, IProgressMonitor monitor) {
- THGraph graph= new THGraph();
+ THGraph graph = new THGraph();
try {
- ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY);
+ ICProject[] scope = CoreModel.getDefault().getCModel().getCProjects();
+ IIndex index = CCorePlugin.getIndexManager().getIndex(scope,
+ IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY);
index.acquireReadLock();
try {
- if (monitor.isCanceled())
+ if (monitor.isCanceled())
return Status.CANCEL_STATUS;
graph.defineInputNode(index, fInput);
graph.addSuperClasses(index, monitor);
- if (monitor.isCanceled())
+ if (monitor.isCanceled())
return Status.CANCEL_STATUS;
graph.addSubClasses(index, monitor);
- if (monitor.isCanceled())
+ if (monitor.isCanceled())
return Status.CANCEL_STATUS;
} finally {
- index.releaseReadLock();
+ index.releaseReadLock();
}
} catch (CoreException e) {
CUIPlugin.log(e);
@@ -173,64 +174,64 @@ class THHierarchyModel {
return Status.CANCEL_STATUS;
} finally {
onJobDone(graph, job);
- }
+ }
return Status.OK_STATUS;
}
-
+
protected void computeNodes() {
if (fGraph == null) {
return;
}
- boolean fwd= fHierarchyKind == SUPER_TYPE_HIERARCHY;
- ArrayList<THNode> stack= new ArrayList<>();
- ArrayList<THNode> roots= new ArrayList<>();
- ArrayList<THNode> leafs= new ArrayList<>();
-
- THGraphNode inputNode= fGraph.getInputNode();
+ boolean fwd = fHierarchyKind == SUPER_TYPE_HIERARCHY;
+ ArrayList<THNode> stack = new ArrayList<>();
+ ArrayList<THNode> roots = new ArrayList<>();
+ ArrayList<THNode> leafs = new ArrayList<>();
+
+ THGraphNode inputNode = fGraph.getInputNode();
Collection<THGraphNode> groots;
-
+
if (fHierarchyKind == TYPE_HIERARCHY) {
- groots= fGraph.getLeafNodes();
+ groots = fGraph.getLeafNodes();
} else {
- THGraphNode node= fGraph.getInputNode();
+ THGraphNode node = fGraph.getInputNode();
if (node != null) {
- groots= Collections.singleton(node);
+ groots = Collections.singleton(node);
} else {
- groots= Collections.emptySet();
+ groots = Collections.emptySet();
}
}
-
+
for (THGraphNode gnode : groots) {
THNode node = createNode(null, gnode, inputNode);
roots.add(node);
stack.add(node);
}
-
+
while (!stack.isEmpty()) {
- THNode node= stack.remove(stack.size() - 1);
- THGraphNode gnode= fGraph.getNode(node.getElement());
- List<THGraphEdge> edges= fwd ? gnode.getOutgoing() : gnode.getIncoming();
+ THNode node = stack.remove(stack.size() - 1);
+ THGraphNode gnode = fGraph.getNode(node.getElement());
+ List<THGraphEdge> edges = fwd ? gnode.getOutgoing() : gnode.getIncoming();
if (edges.isEmpty()) {
leafs.add(node);
} else {
for (THGraphEdge edge : edges) {
- THGraphNode gchildNode= fwd ? edge.getEndNode() : edge.getStartNode();
- THNode childNode= createNode(node, gchildNode, inputNode);
+ THGraphNode gchildNode = fwd ? edge.getEndNode() : edge.getStartNode();
+ THNode childNode = createNode(node, gchildNode, inputNode);
node.addChild(childNode);
stack.add(childNode);
}
}
}
- fRootNodes= roots.toArray(new THNode[roots.size()]);
+ fRootNodes = roots.toArray(new THNode[roots.size()]);
removeFilteredLeaves(fRootNodes);
- fSelectedTypeNode= findSelection(fRootNodes);
+ fSelectedTypeNode = findSelection(fRootNodes);
if (fSelectedTypeNode != null) {
- fTypeToSelect= fSelectedTypeNode.getElement();
+ fTypeToSelect = fSelectedTypeNode.getElement();
updateSelectedMember();
}
-
+
updateImplementors();
- if (!fwd && fHideNonImplementorLeaves && fSelectedMember != null && fMemberSignatureToSelect != null)
+ if (!fwd && fHideNonImplementorLeaves && fSelectedMember != null && fMemberSignatureToSelect != null)
removeNonImplementorLeaves(fRootNodes);
}
@@ -247,7 +248,7 @@ class THHierarchyModel {
}
private THNode findSelection(THNode[] searchme) {
- THNode[] result= new THNode[2];
+ THNode[] result = new THNode[2];
findSelection(searchme, result);
if (result[0] != null) {
return result[0];
@@ -266,45 +267,45 @@ class THHierarchyModel {
private void findSelection(THNode node, THNode[] result) {
if (node.equals(fSelectedTypeNode)) {
- result[0]= node;
+ result[0] = node;
return;
} else if (result[1] == null) {
if (node.getElement().equals(fTypeToSelect)) {
- result[1]= node;
+ result[1] = node;
}
}
- THNode[] children= node.getChildren();
+ THNode[] children = node.getChildren();
findSelection(children, result);
}
private void updateSelectedMember() {
- ICElement oldSelection= fSelectedMember;
- fSelectedMember= null;
+ ICElement oldSelection = fSelectedMember;
+ fSelectedMember = null;
if (fSelectedTypeNode != null && fMemberSignatureToSelect != null) {
- THGraphNode gnode= fGraph.getNode(fSelectedTypeNode.getElement());
+ THGraphNode gnode = fGraph.getNode(fSelectedTypeNode.getElement());
if (gnode != null) {
- ICElement[] members= gnode.getMembers(fShowInheritedMembers);
+ ICElement[] members = gnode.getMembers(fShowInheritedMembers);
if (members != null) {
for (ICElement member : members) {
if (member.equals(oldSelection)) {
- fSelectedMember= member;
+ fSelectedMember = member;
return;
}
}
for (ICElement member : members) {
if (fMemberSignatureToSelect.equals(TypeHierarchyUI.getLocalElementSignature(member))) {
- fSelectedMember= member;
+ fSelectedMember = member;
return;
}
}
}
}
- }
+ }
}
private THNode createNode(THNode parent, THGraphNode gnode, THGraphNode inputNode) {
ICElement element = gnode.getElement();
- THNode node= new THNode(parent, element);
+ THNode node = new THNode(parent, element);
if (gnode != inputNode && fFilter != null && !fFilter.isPartOfWorkingSet(element)) {
node.setIsFiltered(true);
}
@@ -313,21 +314,21 @@ class THHierarchyModel {
synchronized private void onJobDone(final THGraph graph, Job job) {
if (fJob == job) {
- fJob= null;
- fDisplay.asyncExec(new Runnable(){
+ fJob = null;
+ fDisplay.asyncExec(new Runnable() {
@Override
public void run() {
- fGraph= graph;
- THGraphNode inputNode= fGraph.getInputNode();
+ fGraph = graph;
+ THGraphNode inputNode = fGraph.getInputNode();
if (!fGraph.isFileIndexed()) {
fView.setMessage(IndexUI.getFileNotIndexedMessage(fInput));
} else if (inputNode == null) {
fView.setMessage(Messages.THHierarchyModel_errorComputingHierarchy);
} else {
if (fTypeToSelect == fInput) {
- fTypeToSelect= inputNode.getElement();
+ fTypeToSelect = inputNode.getElement();
}
- fInput= inputNode.getElement();
+ fInput = inputNode.getElement();
}
computeNodes();
notifyEvent(END_OF_COMPUTATION);
@@ -345,7 +346,7 @@ class THHierarchyModel {
}
public boolean isComputed() {
- return fRootNodes!=null;
+ return fRootNodes != null;
}
public THNode getSelectionInHierarchy() {
@@ -353,9 +354,9 @@ class THHierarchyModel {
}
public void onHierarchySelectionChanged(THNode node) {
- fSelectedTypeNode= node;
+ fSelectedTypeNode = node;
if (node != null) {
- fTypeToSelect= node.getElement();
+ fTypeToSelect = node.getElement();
}
updateSelectedMember();
updateImplementors();
@@ -363,8 +364,8 @@ class THHierarchyModel {
public Object[] getMembers() {
if (fSelectedTypeNode != null) {
- THGraphNode gnode= fGraph.getNode(fSelectedTypeNode.getElement());
- Object[] result= gnode.getMembers(fShowInheritedMembers);
+ THGraphNode gnode = fGraph.getNode(fSelectedTypeNode.getElement());
+ Object[] result = gnode.getMembers(fShowInheritedMembers);
if (result != null) {
return result;
}
@@ -373,9 +374,9 @@ class THHierarchyModel {
}
public void onMemberSelectionChanged(ICElement elem) {
- fSelectedMember= elem;
+ fSelectedMember = elem;
if (fSelectedMember != null) {
- fMemberSignatureToSelect= TypeHierarchyUI.getLocalElementSignature(fSelectedMember);
+ fMemberSignatureToSelect = TypeHierarchyUI.getLocalElementSignature(fSelectedMember);
}
updateImplementors();
}
@@ -390,7 +391,7 @@ class THHierarchyModel {
private void updateImplementors(THNode node) {
node.setIsImplementor(isImplementor(node.getElement()));
- THNode[] children= node.getChildren();
+ THNode[] children = node.getChildren();
for (THNode child : children) {
updateImplementors(child);
}
@@ -400,9 +401,9 @@ class THHierarchyModel {
if (element == null || fSelectedMember == null || fMemberSignatureToSelect == null) {
return false;
}
- THGraphNode gnode= fGraph.getNode(element);
+ THGraphNode gnode = fGraph.getNode(element);
if (gnode != null) {
- ICElement[] members= gnode.getMembers(false);
+ ICElement[] members = gnode.getMembers(false);
if (members != null) {
for (ICElement member : members) {
if (member == fSelectedMember) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java
index b2aa2252bb4..234a14670bb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java
@@ -22,36 +22,33 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-
/**
* Action used for the include browser forward / backward buttons
*/
public class THHistoryAction extends Action {
- final static long LABEL_OPTIONS=
- CElementLabels.M_PARAMETER_TYPES |
- CElementLabels.ALL_FULLY_QUALIFIED |
- CElementLabels.MF_POST_FILE_QUALIFIED;
-
+ final static long LABEL_OPTIONS = CElementLabels.M_PARAMETER_TYPES | CElementLabels.ALL_FULLY_QUALIFIED
+ | CElementLabels.MF_POST_FILE_QUALIFIED;
+
private THViewPart fViewPart;
private ICElement fElement;
-
+
public THHistoryAction(THViewPart hierarchyView, ICElement element) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- fViewPart= hierarchyView;
- fElement= element;
-
- String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS);
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+ fViewPart = hierarchyView;
+ fElement = element;
+
+ String elementName = CElementLabels.getElementLabel(element, LABEL_OPTIONS);
setText(elementName);
setImageDescriptor(getImageDescriptor(element));
}
-
+
private ImageDescriptor getImageDescriptor(ICElement elem) {
- CElementImageProvider imageProvider= new CElementImageProvider();
- ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
+ CElementImageProvider imageProvider = new CElementImageProvider();
+ ImageDescriptor desc = imageProvider.getBaseImageDescriptor(elem, 0);
imageProvider.dispose();
return desc;
}
-
+
/*
* @see Action#run()
*/
@@ -59,5 +56,5 @@ public class THHistoryAction extends Action {
public void run() {
fViewPart.setInput(fElement, null);
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java
index fae12d49136..71751d69d85 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java
@@ -33,7 +33,7 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
public ClearHistoryAction(THViewPart view) {
super(Messages.THHistoryDropDownAction_ClearHistory);
- fView= view;
+ fView = view;
}
@Override
@@ -43,14 +43,14 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
}
}
- public static final int RESULTS_IN_DROP_DOWN= 10;
+ public static final int RESULTS_IN_DROP_DOWN = 10;
private THViewPart fHierarchyView;
private Menu fMenu;
public THHistoryDropDownAction(THViewPart viewPart) {
- fHierarchyView= viewPart;
- fMenu= null;
+ fHierarchyView = viewPart;
+ fMenu = null;
setToolTipText(Messages.THHistoryDropDownAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
setMenuCreator(this);
@@ -61,7 +61,7 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
// action is reused, can be called several times.
if (fMenu != null) {
fMenu.dispose();
- fMenu= null;
+ fMenu = null;
}
}
@@ -75,8 +75,8 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
if (fMenu != null) {
fMenu.dispose();
}
- fMenu= new Menu(parent);
- ICElement[] elements= fHierarchyView.getHistoryEntries();
+ fMenu = new Menu(parent);
+ ICElement[] elements = fHierarchyView.getHistoryEntries();
addEntries(fMenu, elements);
new MenuItem(fMenu, SWT.SEPARATOR);
addActionToMenu(fMenu, new THHistoryListAction(fHierarchyView));
@@ -85,13 +85,13 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
}
private boolean addEntries(Menu menu, ICElement[] elements) {
- boolean checked= false;
+ boolean checked = false;
- int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
- for (int i= 0; i < min; i++) {
- THHistoryAction action= new THHistoryAction(fHierarchyView, elements[i]);
+ int min = Math.min(elements.length, RESULTS_IN_DROP_DOWN);
+ for (int i = 0; i < min; i++) {
+ THHistoryAction action = new THHistoryAction(fHierarchyView, elements[i]);
action.setChecked(elements[i].equals(fHierarchyView.getInput()));
- checked= checked || action.isChecked();
+ checked = checked || action.isChecked();
addActionToMenu(menu, action);
}
@@ -99,7 +99,7 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
}
protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
+ ActionContributionItem item = new ActionContributionItem(action);
item.fill(parent, -1);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java
index 697294f2def..3aa26de922d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java
@@ -41,71 +41,71 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class THHistoryListAction extends Action {
-
+
private class HistoryListDialog extends StatusDialog {
private ListDialogField<ICElement> fHistoryList;
private IStatus fHistoryStatus;
private ICElement fResult;
-
+
private HistoryListDialog(Shell shell, ICElement[] historyEntries) {
super(shell);
- setHelpAvailable(false);
- setTitle(Messages.THHistoryListAction_HistoryList_title);
- String[] buttonLabels= new String[] {
- Messages.THHistoryListAction_Remove,
- };
-
- IListAdapter<ICElement> adapter= new IListAdapter<ICElement>() {
+ setHelpAvailable(false);
+ setTitle(Messages.THHistoryListAction_HistoryList_title);
+ String[] buttonLabels = new String[] { Messages.THHistoryListAction_Remove, };
+
+ IListAdapter<ICElement> adapter = new IListAdapter<ICElement>() {
@Override
public void customButtonPressed(ListDialogField<ICElement> field, int index) {
doCustomButtonPressed();
}
+
@Override
public void selectionChanged(ListDialogField<ICElement> field) {
doSelectionChanged();
}
-
+
@Override
public void doubleClicked(ListDialogField<ICElement> field) {
doDoubleClicked();
- }
+ }
};
-
- ILabelProvider labelProvider= new CUILabelProvider(THHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
-
- fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
- fHistoryList.setLabelText(Messages.THHistoryListAction_HistoryList_label);
+
+ ILabelProvider labelProvider = new CUILabelProvider(THHistoryAction.LABEL_OPTIONS,
+ CElementImageProvider.OVERLAY_ICONS);
+
+ fHistoryList = new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
+ fHistoryList.setLabelText(Messages.THHistoryListAction_HistoryList_label);
fHistoryList.setElements(Arrays.asList(historyEntries));
-
+
ISelection sel;
if (historyEntries.length > 0) {
- sel= new StructuredSelection(historyEntries[0]);
+ sel = new StructuredSelection(historyEntries[0]);
} else {
- sel= new StructuredSelection();
+ sel = new StructuredSelection();
}
-
+
fHistoryList.selectElements(sel);
}
-
+
/*
* @see Dialog#createDialogArea(Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
initializeDialogUnits(parent);
-
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
+
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Composite inner = new Composite(composite, SWT.NONE);
inner.setFont(parent.getFont());
-
+
inner.setLayoutData(new GridData(GridData.FILL_BOTH));
LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null), true);
- applyDialogFont(composite);
+ applyDialogFont(composite);
return composite;
}
@@ -115,7 +115,7 @@ public class THHistoryListAction extends Action {
private void doCustomButtonPressed() {
fHistoryList.removeElements(fHistoryList.getSelectedElements());
}
-
+
private void doDoubleClicked() {
if (fHistoryStatus.isOK()) {
okPressed();
@@ -123,35 +123,35 @@ public class THHistoryListAction extends Action {
}
private void doSelectionChanged() {
- StatusInfo status= new StatusInfo();
- List<?> selected= fHistoryList.getSelectedElements();
+ StatusInfo status = new StatusInfo();
+ List<?> selected = fHistoryList.getSelectedElements();
if (selected.size() != 1) {
status.setError(""); //$NON-NLS-1$
- fResult= null;
+ fResult = null;
} else {
- fResult= (ICElement) selected.get(0);
+ fResult = (ICElement) selected.get(0);
}
- fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
- fHistoryStatus= status;
- updateStatus(status);
+ fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
+ fHistoryStatus = status;
+ updateStatus(status);
}
-
+
public ICElement getResult() {
return fResult;
}
-
+
public ICElement[] getRemaining() {
- List<?> elems= fHistoryList.getElements();
+ List<?> elems = fHistoryList.getElements();
return elems.toArray(new ICElement[elems.size()]);
- }
-
+ }
+
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
}
/* (non-Javadoc)
@@ -163,25 +163,24 @@ public class THHistoryListAction extends Action {
super.create();
}
}
-
+
private THViewPart fView;
-
+
public THHistoryListAction(THViewPart hierarchyView) {
- fView= hierarchyView;
- setText(Messages.THHistoryListAction_label);
+ fView = hierarchyView;
+ setText(Messages.THHistoryListAction_label);
}
-
+
/*
* @see IAction#run()
*/
@Override
public void run() {
- ICElement[] historyEntries= fView.getHistoryEntries();
- HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
+ ICElement[] historyEntries = fView.getHistoryEntries();
+ HistoryListDialog dialog = new HistoryListDialog(fView.getSite().getShell(), historyEntries);
if (dialog.open() == Window.OK) {
fView.setHistoryEntries(dialog.getRemaining());
fView.setInput(dialog.getResult(), null);
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.java
index 1f4283fc40c..f59e7fc6caa 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Patrick Hofer [bug 325488]
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
import java.util.Iterator;
@@ -54,14 +54,14 @@ public class THInformationControl extends AbstractInformationControl implements
private TreeViewer fHierarchyTreeViewer;
private boolean fDisposed;
private KeyAdapter fKeyAdapter;
-
+
public THInformationControl(Shell parent, int shellStyle, int treeStyle) {
super(parent, shellStyle, treeStyle, ICEditorActionDefinitionIds.OPEN_QUICK_TYPE_HIERARCHY, true);
}
private KeyAdapter getKeyAdapter() {
if (fKeyAdapter == null) {
- fKeyAdapter= new KeyAdapter() {
+ fKeyAdapter = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
@@ -72,7 +72,7 @@ public class THInformationControl extends AbstractInformationControl implements
for (Trigger trigger : triggers) {
if (trigger.equals(keyStroke)) {
- e.doit= false;
+ e.doit = false;
toggleHierarchy();
return;
}
@@ -90,16 +90,16 @@ public class THInformationControl extends AbstractInformationControl implements
@Override
protected Text createFilterText(Composite parent) {
- Text text= super.createFilterText(parent);
+ Text text = super.createFilterText(parent);
text.addKeyListener(getKeyAdapter());
return text;
}
@Override
protected TreeViewer createTreeViewer(Composite parent, int style) {
- Display display= getShell().getDisplay();
- fModel= new THHierarchyModel(this, display, true);
- fHierarchyLabelProvider= new THLabelProvider(display, fModel);
+ Display display = getShell().getDisplay();
+ fModel = new THHierarchyModel(this, display, true);
+ fHierarchyLabelProvider = new THLabelProvider(display, fModel);
fHierarchyLabelProvider.setMarkImplementers(false);
fHierarchyTreeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
fHierarchyTreeViewer.setContentProvider(new THContentProvider());
@@ -111,7 +111,7 @@ public class THInformationControl extends AbstractInformationControl implements
}
protected void onOpenElement(ISelection selection) {
- ICElement elem= (ICElement) getSelectedElement();
+ ICElement elem = (ICElement) getSelectedElement();
if (elem != null) {
try {
EditorOpener.open(CUIPlugin.getActivePage(), elem);
@@ -124,7 +124,7 @@ public class THInformationControl extends AbstractInformationControl implements
@Override
public void setInput(Object input) {
if (input instanceof ICElement[]) {
- ICElement[] splitInput= (ICElement[]) input;
+ ICElement[] splitInput = (ICElement[]) input;
if (TypeHierarchyUI.isValidTypeInput(splitInput[0])) {
fModel.setInput(splitInput[0], splitInput[1]);
fHierarchyLabelProvider.setHideNonImplementers(splitInput[1] != null);
@@ -138,30 +138,27 @@ public class THInformationControl extends AbstractInformationControl implements
protected void updateTitle() {
setTitleText(computeTitleText());
}
-
+
private String computeTitleText() {
final ICElement input = fModel.getInput();
- final ICElement member= fModel.getSelectedMember();
- String elemName= member != null ? member.getElementName() : input.getElementName();
+ final ICElement member = fModel.getSelectedMember();
+ String elemName = member != null ? member.getElementName() : input.getElementName();
return NLS.bind(getFormatString(fModel.getHierarchyKind(), member != null), elemName);
}
-
+
private String getFormatString(int hierarchyKind, boolean forMember) {
switch (hierarchyKind) {
case THHierarchyModel.SUB_TYPE_HIERARCHY:
- return forMember
- ? Messages.THInformationControl_titleMemberInSubHierarchy
+ return forMember ? Messages.THInformationControl_titleMemberInSubHierarchy
: Messages.THInformationControl_titleSubHierarchy;
-
+
case THHierarchyModel.SUPER_TYPE_HIERARCHY:
- return forMember
- ? Messages.THInformationControl_titleMemberInSuperHierarchy
+ return forMember ? Messages.THInformationControl_titleMemberInSuperHierarchy
: Messages.THInformationControl_titleSuperHierarchy;
-
+
case THHierarchyModel.TYPE_HIERARCHY:
default:
- return forMember
- ? Messages.THInformationControl_titleMemberInHierarchy
+ return forMember ? Messages.THInformationControl_titleMemberInHierarchy
: Messages.THInformationControl_titleHierarchy;
}
}
@@ -173,12 +170,12 @@ public class THInformationControl extends AbstractInformationControl implements
@Override
protected Object getSelectedElement() {
- THNode node= selectionToNode(fHierarchyTreeViewer.getSelection());
+ THNode node = selectionToNode(fHierarchyTreeViewer.getSelection());
if (node != null) {
- ICElement elem= node.getElement();
+ ICElement elem = node.getElement();
if (node.isImplementor()) {
fModel.onHierarchySelectionChanged(node);
- ICElement melem= fModel.getSelectedMember();
+ ICElement melem = fModel.getSelectedMember();
if (melem != null) {
return melem;
}
@@ -190,9 +187,9 @@ public class THInformationControl extends AbstractInformationControl implements
private THNode selectionToNode(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) selection;
- for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
- Object cand= iter.next();
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ for (Iterator<?> iter = ss.iterator(); iter.hasNext();) {
+ Object cand = iter.next();
if (cand instanceof THNode) {
return (THNode) cand;
}
@@ -203,7 +200,7 @@ public class THInformationControl extends AbstractInformationControl implements
@Override
public void widgetDisposed(DisposeEvent event) {
- fDisposed= true;
+ fDisposed = true;
super.widgetDisposed(event);
}
@@ -216,13 +213,13 @@ public class THInformationControl extends AbstractInformationControl implements
fHierarchyLabelProvider.setHideNonImplementers(false);
}
fHierarchyTreeViewer.refresh();
- THNode selection= fModel.getSelectionInHierarchy();
+ THNode selection = fModel.getSelectionInHierarchy();
if (selection != null) {
fHierarchyTreeViewer.setSelection(new StructuredSelection(selection));
fHierarchyTreeViewer.expandToLevel(selection, 2);
}
break;
- }
+ }
}
}
@@ -238,11 +235,11 @@ public class THInformationControl extends AbstractInformationControl implements
@Override
protected String getStatusFieldText() {
TriggerSequence sequence = getInvokingCommandTriggerSequence();
- String keyName= ""; //$NON-NLS-1$
+ String keyName = ""; //$NON-NLS-1$
if (sequence != null)
- keyName= sequence.format();
+ keyName = sequence.format();
- String message= ""; //$NON-NLS-1$
+ String message = ""; //$NON-NLS-1$
switch (fModel.getHierarchyKind()) {
case THHierarchyModel.TYPE_HIERARCHY:
message = Messages.THInformationControl_toggle_superTypeHierarchy_label;
@@ -259,13 +256,13 @@ public class THInformationControl extends AbstractInformationControl implements
default:
break;
}
- return MessageFormat.format(message, new Object[] {keyName} );
+ return MessageFormat.format(message, new Object[] { keyName });
}
@Override
protected void selectFirstMatch() {
- Tree tree= fHierarchyTreeViewer.getTree();
- Object element= findElement(tree.getItems());
+ Tree tree = fHierarchyTreeViewer.getTree();
+ Object element = findElement(tree.getItems());
if (element != null) {
fHierarchyTreeViewer.setSelection(new StructuredSelection(element), true);
} else {
@@ -297,21 +294,21 @@ public class THInformationControl extends AbstractInformationControl implements
updateStatusFieldText();
updateTitle();
}
-
+
private THNode findElement(TreeItem[] items) {
for (TreeItem item2 : items) {
- Object item= item2.getData();
- THNode element= null;
+ Object item = item2.getData();
+ THNode element = null;
if (item instanceof THNode) {
- element= (THNode) item;
+ element = (THNode) item;
if (fStringMatcher == null)
return element;
-
- String label= fHierarchyLabelProvider.getText(element);
+
+ String label = fHierarchyLabelProvider.getText(element);
if (fStringMatcher.match(label))
return element;
}
- element= findElement(item2.getItems());
+ element = findElement(item2.getItems());
if (element != null)
return element;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.java
index 8941bd0c990..5e247247240 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
@@ -26,7 +26,7 @@ public class THInformationProvider implements IInformationProviderExtension, IIn
private ITextEditor fEditor;
public THInformationProvider(ITextEditor editor) {
- fEditor= editor;
+ fEditor = editor;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java
index 4b5be7b8d1d..4224b27b41d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
import java.util.HashMap;
@@ -37,135 +37,134 @@ import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
public class THLabelProvider extends AppearanceAwareLabelProvider {
- private final static long LABEL_OPTIONS_SIMPLE= CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE;
- private final static long LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED;
-
- private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, 0);
- private THHierarchyModel fModel;
- private HashMap<String, Image> fCachedImages= new HashMap<String, Image>();
+ private final static long LABEL_OPTIONS_SIMPLE = CElementLabels.ALL_FULLY_QUALIFIED
+ | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE;
+ private final static long LABEL_OPTIONS_SHOW_FILES = LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED;
+
+ private CUILabelProvider fCLabelProvider = new CUILabelProvider(LABEL_OPTIONS_SIMPLE, 0);
+ private THHierarchyModel fModel;
+ private HashMap<String, Image> fCachedImages = new HashMap<String, Image>();
private Color fColorInactive;
- private boolean fMarkImplementers= true;
- private boolean fHideNonImplementers= false;
-
- public THLabelProvider(Display display, THHierarchyModel model) {
- fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
- fModel= model;
- }
-
- @Override
+ private boolean fMarkImplementers = true;
+ private boolean fHideNonImplementers = false;
+
+ public THLabelProvider(Display display, THHierarchyModel model) {
+ fColorInactive = display.getSystemColor(SWT.COLOR_DARK_GRAY);
+ fModel = model;
+ }
+
+ @Override
public Image getImage(Object element) {
- if (element instanceof THNode) {
- THNode node= (THNode) element;
- ICElement decl= node.getElement();
- if (decl != null) {
- if (node.isFiltered() ||
- (fHideNonImplementers && !node.isImplementor())) {
- fCLabelProvider.setImageFlags(CElementImageProvider.LIGHT_TYPE_ICONS);
- }
- Image image= fCLabelProvider.getImage(decl);
- fCLabelProvider.setImageFlags(0);
- if (image != null) {
- return decorateImage(image, node);
- }
- }
- }
- else if (element instanceof ICElement) {
- return fCLabelProvider.getImage(element);
- }
- return super.getImage(element);
- }
-
- @Override
+ if (element instanceof THNode) {
+ THNode node = (THNode) element;
+ ICElement decl = node.getElement();
+ if (decl != null) {
+ if (node.isFiltered() || (fHideNonImplementers && !node.isImplementor())) {
+ fCLabelProvider.setImageFlags(CElementImageProvider.LIGHT_TYPE_ICONS);
+ }
+ Image image = fCLabelProvider.getImage(decl);
+ fCLabelProvider.setImageFlags(0);
+ if (image != null) {
+ return decorateImage(image, node);
+ }
+ }
+ } else if (element instanceof ICElement) {
+ return fCLabelProvider.getImage(element);
+ }
+ return super.getImage(element);
+ }
+
+ @Override
public String getText(Object element) {
- if (element instanceof THNode) {
- THNode node= (THNode) element;
- ICElement decl= node.getElement();
- if (decl != null) {
- String label= fCLabelProvider.getText(decl);
- return decorateText(label, element);
- }
- }
- return super.getText(element);
- }
-
- @Override
+ if (element instanceof THNode) {
+ THNode node = (THNode) element;
+ ICElement decl = node.getElement();
+ if (decl != null) {
+ String label = fCLabelProvider.getText(decl);
+ return decorateText(label, element);
+ }
+ }
+ return super.getText(element);
+ }
+
+ @Override
public StyledString getStyledText(Object element) {
if (element instanceof THNode) {
- THNode node= (THNode) element;
- ICElement decl= node.getElement();
- if (decl != null) {
- StyledString label= fCLabelProvider.getStyledText(decl);
- if (fModel.isShowInheritedMembers()) {
- }
- String decorated= decorateText(label.getString(), element);
- if (decorated != null) {
- return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, label);
- }
- return label;
- }
- }
+ THNode node = (THNode) element;
+ ICElement decl = node.getElement();
+ if (decl != null) {
+ StyledString label = fCLabelProvider.getStyledText(decl);
+ if (fModel.isShowInheritedMembers()) {
+ }
+ String decorated = decorateText(label.getString(), element);
+ if (decorated != null) {
+ return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER,
+ label);
+ }
+ return label;
+ }
+ }
return super.getStyledText(element);
}
-
+
@Override
public void dispose() {
- fCLabelProvider.dispose();
- for (Iterator<Image> iter = fCachedImages.values().iterator(); iter.hasNext();) {
- Image image = iter.next();
- image.dispose();
- }
- fCachedImages.clear();
- super.dispose();
- }
-
- private Image decorateImage(Image image, THNode node) {
- int flags= 0;
- if (node.hasChildren()) {
- if (fModel.getHierarchyKind() == THHierarchyModel.SUPER_TYPE_HIERARCHY) {
- flags |= CElementImageDescriptor.RELATES_TO;
- }
- else {
- flags |= CElementImageDescriptor.REFERENCED_BY;
- }
- }
- if (fMarkImplementers && node.isImplementor()) {
- flags |= CElementImageDescriptor.DEFINES;
- }
-
- String key= image.toString()+String.valueOf(flags);
- Image result= fCachedImages.get(key);
- if (result == null) {
- ImageDescriptor desc= new CElementImageDescriptor(
- new ImageImageDescriptor(image), flags, new Point(20,16));
- result= desc.createImage();
- fCachedImages.put(key, result);
- }
- return result;
- }
-
- @Override
+ fCLabelProvider.dispose();
+ for (Iterator<Image> iter = fCachedImages.values().iterator(); iter.hasNext();) {
+ Image image = iter.next();
+ image.dispose();
+ }
+ fCachedImages.clear();
+ super.dispose();
+ }
+
+ private Image decorateImage(Image image, THNode node) {
+ int flags = 0;
+ if (node.hasChildren()) {
+ if (fModel.getHierarchyKind() == THHierarchyModel.SUPER_TYPE_HIERARCHY) {
+ flags |= CElementImageDescriptor.RELATES_TO;
+ } else {
+ flags |= CElementImageDescriptor.REFERENCED_BY;
+ }
+ }
+ if (fMarkImplementers && node.isImplementor()) {
+ flags |= CElementImageDescriptor.DEFINES;
+ }
+
+ String key = image.toString() + String.valueOf(flags);
+ Image result = fCachedImages.get(key);
+ if (result == null) {
+ ImageDescriptor desc = new CElementImageDescriptor(new ImageImageDescriptor(image), flags,
+ new Point(20, 16));
+ result = desc.createImage();
+ fCachedImages.put(key, result);
+ }
+ return result;
+ }
+
+ @Override
public Color getForeground(Object element) {
- if (element instanceof THNode) {
- THNode node= (THNode) element;
- if (node.isFiltered()) {
- return fColorInactive;
- }
- }
- return null;
- }
-
- public void setShowFiles(boolean show) {
+ if (element instanceof THNode) {
+ THNode node = (THNode) element;
+ if (node.isFiltered()) {
+ return fColorInactive;
+ }
+ }
+ return null;
+ }
+
+ public void setShowFiles(boolean show) {
fCLabelProvider.setTextFlags(show ? LABEL_OPTIONS_SHOW_FILES : LABEL_OPTIONS_SIMPLE);
- }
+ }
public void setMarkImplementers(boolean val) {
- fMarkImplementers= val;
+ fMarkImplementers = val;
}
public void setHideNonImplementers(boolean val) {
- fHideNonImplementers= val;
+ fHideNonImplementers = val;
}
-
+
@Override
public void addLabelDecorator(ILabelDecorator decorator) {
super.addLabelDecorator(decorator);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvider.java
index 147110d9ad1..f1b88f1375b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
@@ -18,27 +18,27 @@ import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
public class THMemberContentProvider implements IStructuredContentProvider {
- private static final Object[] NO_CHILDREN= new Object[0];
- private THHierarchyModel fModel;
+ private static final Object[] NO_CHILDREN = new Object[0];
+ private THHierarchyModel fModel;
public THMemberContentProvider() {
}
-
- @Override
+
+ @Override
final public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- fModel= (THHierarchyModel) newInput;
- }
+ fModel = (THHierarchyModel) newInput;
+ }
- @Override
+ @Override
public void dispose() {
- fModel= null;
- }
+ fModel = null;
+ }
- @Override
+ @Override
final public Object[] getElements(Object inputElement) {
- if (fModel == null) {
- return NO_CHILDREN;
- }
- return fModel.getMembers();
- }
+ if (fModel == null) {
+ return NO_CHILDREN;
+ }
+ return fModel.getMembers();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THNode.java
index 1f499c89bc1..400d2c9fd78 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THNode.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
import java.util.ArrayList;
@@ -26,27 +26,27 @@ import org.eclipse.cdt.core.model.ICElement;
public class THNode implements IAdaptable {
private THNode fParent;
private ICElement fElement;
- private List<THNode> fChildren= Collections.emptyList();
-
- private int fHashCode;
- private boolean fIsFiltered;
- private boolean fIsImplementor;
-
- /**
- * Creates a new node for the type hierarchy browser.
- */
- public THNode(THNode parent, ICElement decl) {
- fParent= parent;
- fElement= decl;
- fHashCode= Objects.hash(fParent, fElement);
- }
+ private List<THNode> fChildren = Collections.emptyList();
+
+ private int fHashCode;
+ private boolean fIsFiltered;
+ private boolean fIsImplementor;
+
+ /**
+ * Creates a new node for the type hierarchy browser.
+ */
+ public THNode(THNode parent, ICElement decl) {
+ fParent = parent;
+ fElement = decl;
+ fHashCode = Objects.hash(fParent, fElement);
+ }
@Override
public int hashCode() {
- return fHashCode;
- }
+ return fHashCode;
+ }
- @Override
+ @Override
public boolean equals(Object o) {
if (!(o instanceof THNode)) {
return false;
@@ -58,19 +58,19 @@ public class THNode implements IAdaptable {
}
return Objects.equals(fElement, rhs.fElement);
- }
+ }
/**
- * Returns the parent node or {@code null} for the root node.
- */
- public THNode getParent() {
- return fParent;
- }
+ * Returns the parent node or {@code null} for the root node.
+ */
+ public THNode getParent() {
+ return fParent;
+ }
public ICElement getElement() {
return fElement;
}
-
+
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Class adapter) {
@@ -79,19 +79,19 @@ public class THNode implements IAdaptable {
}
return null;
}
-
+
public boolean isFiltered() {
return fIsFiltered;
}
public void setIsFiltered(boolean val) {
- fIsFiltered= val;
+ fIsFiltered = val;
}
public void addChild(THNode childNode) {
if (fChildren.isEmpty()) {
- fChildren= new ArrayList<>();
- }
+ fChildren = new ArrayList<>();
+ }
fChildren.add(childNode);
}
@@ -104,7 +104,7 @@ public class THNode implements IAdaptable {
}
public void setIsImplementor(boolean val) {
- fIsImplementor= val;
+ fIsImplementor = val;
}
public boolean isImplementor() {
@@ -131,4 +131,3 @@ public class THNode implements IAdaptable {
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.java
index 4ee6d20f04d..c4ccec20d6f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
@@ -20,11 +20,11 @@ public class THSchedulingRule implements ISchedulingRule {
@Override
public boolean contains(ISchedulingRule rule) {
- return rule==this;
+ return rule == this;
}
@Override
public boolean isConflicting(ISchedulingRule rule) {
- return rule==this;
+ return rule == this;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java
index a0a565fd3a3..48837fa3a6a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* IBM Corporation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
import java.util.ArrayList;
@@ -113,15 +113,15 @@ import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
*/
public class THViewPart extends ViewPart implements ITHModelPresenter {
private static final int MAX_HISTORY_SIZE = 10;
- private static final String TRUE = String.valueOf(true);
- private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
- private static final String KEY_SHOW_FILES= "showFilesInLabels"; //$NON-NLS-1$
- private static final String KEY_SHOW_INHERITED_MEMBERS= "showInheritedMembers"; //$NON-NLS-1$
- private static final String KEY_FILTER_FIELDS= "filterFields"; //$NON-NLS-1$
- private static final String KEY_FILTER_STATIC= "filterStatic"; //$NON-NLS-1$
- private static final String KEY_FILTER_NON_PUBLIC= "filterNonPublic"; //$NON-NLS-1$
- private static final String KEY_MODE= "hierarchyMode"; //$NON-NLS-1$
- private static final String KEY_ORIENTATION= "viewOrientation"; //$NON-NLS-1$
+ private static final String TRUE = String.valueOf(true);
+ private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
+ private static final String KEY_SHOW_FILES = "showFilesInLabels"; //$NON-NLS-1$
+ private static final String KEY_SHOW_INHERITED_MEMBERS = "showInheritedMembers"; //$NON-NLS-1$
+ private static final String KEY_FILTER_FIELDS = "filterFields"; //$NON-NLS-1$
+ private static final String KEY_FILTER_STATIC = "filterStatic"; //$NON-NLS-1$
+ private static final String KEY_FILTER_NON_PUBLIC = "filterNonPublic"; //$NON-NLS-1$
+ private static final String KEY_MODE = "hierarchyMode"; //$NON-NLS-1$
+ private static final String KEY_ORIENTATION = "viewOrientation"; //$NON-NLS-1$
private static final String KEY_SPLITTER_W1 = "splitterWeight1"; //$NON-NLS-1$
private static final String KEY_SPLITTER_W2 = "splitterWeight2"; //$NON-NLS-1$
@@ -130,51 +130,53 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
private static final int ORIENTATION_HORIZONTAL = 1;
private static final int ORIENTATION_VERTICAL = 2;
private static final int ORIENTATION_SINGLE = 3;
-
+
// options for label provider
- private static final long MEMBER_LABEL_OPTIONS_SIMPLE = CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE;
- private static final long MEMBER_LABEL_OPTIONS_QUALIFIED = MEMBER_LABEL_OPTIONS_SIMPLE | CElementLabels.ALL_POST_QUALIFIED;
+ private static final long MEMBER_LABEL_OPTIONS_SIMPLE = CElementLabels.M_PARAMETER_TYPES
+ | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE;
+ private static final long MEMBER_LABEL_OPTIONS_QUALIFIED = MEMBER_LABEL_OPTIONS_SIMPLE
+ | CElementLabels.ALL_POST_QUALIFIED;
private static final int MEMBER_ICON_OPTIONS = CElementImageProvider.OVERLAY_ICONS;
-
+
// state information
- private IMemento fMemento;
- private boolean fShowsMessage= true;
- private int fCurrentViewOrientation= -1;
- private boolean fInComputeOrientation= false;
- private ArrayList<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
- private int fIgnoreSelectionChanges= 0;
-
- // widgets
- private PageBook fPagebook;
- private Label fInfoText;
+ private IMemento fMemento;
+ private boolean fShowsMessage = true;
+ private int fCurrentViewOrientation = -1;
+ private boolean fInComputeOrientation = false;
+ private ArrayList<ICElement> fHistoryEntries = new ArrayList<ICElement>(MAX_HISTORY_SIZE);
+ private int fIgnoreSelectionChanges = 0;
+
+ // widgets
+ private PageBook fPagebook;
+ private Label fInfoText;
private SashForm fSplitter;
private ViewForm fHierarchyViewForm;
private ViewForm fMemberViewForm;
private CLabel fMemberLabel;
- // viewers and helpers
+ // viewers and helpers
private THHierarchyModel fModel;
private THLabelProvider fHierarchyLabelProvider;
private CUILabelProvider fMemberLabelProvider;
private TableViewer fMemberViewer;
private TreeViewer fHierarchyTreeViewer;
- // filters
+ // filters
private WorkingSetFilterUI fWorkingSetFilterUI;
private ViewerFilter fFieldFilter;
private ViewerFilter fStaticFilter;
private ViewerFilter fNonPublicFilter;
- // actions
+ // actions
private ToolBarManager fMemberToolbarManager;
-
+
private Action fShowSuperTypeHierarchyAction;
- private Action fShowSubTypeHierarchyAction;
- private Action fShowTypeHierarchyAction;
-
- private Action fShowFilesInLabelsAction;
- private Action fRefreshAction;
- private Action fCancelAction;
+ private Action fShowSubTypeHierarchyAction;
+ private Action fShowTypeHierarchyAction;
+
+ private Action fShowFilesInLabelsAction;
+ private Action fRefreshAction;
+ private Action fCancelAction;
private Action fHistoryAction;
private Action fOpenElement;
private CopyTreeAction fCopyAction;
@@ -184,7 +186,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
private Action fAutomaticOrientation;
private Action fSingleOrientation;
- private Action fShowInheritedMembersAction;
+ private Action fShowInheritedMembersAction;
private Action fFieldFilterAction;
private Action fStaticFilterAction;
private Action fNonPublicFilterAction;
@@ -194,135 +196,135 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
private SelectionSearchGroup fSelectionSearchGroup;
private CRefactoringActionGroup fRefactoringActionGroup;
private IContextActivation fContextActivation;
-
- @Override
+
+ @Override
public void setFocus() {
- fPagebook.setFocus();
- }
+ fPagebook.setFocus();
+ }
- @Override
+ @Override
public void setMessage(String msg) {
- fInfoText.setText(msg);
- fPagebook.showPage(fInfoText);
- fShowsMessage= true;
- updateDescription();
- updateActionEnablement();
- }
-
- void setInput(ICElement inputType, ICElement inputMember) {
- if (inputType == null) {
- setMessage(Messages.THViewPart_instruction);
- fHierarchyTreeViewer.setInput(null);
- fMemberViewer.setInput(null);
- return;
- }
- fShowsMessage= false;
- fModel.setInput(inputType, inputMember);
- fHierarchyTreeViewer.setInput(fModel);
- fMemberViewer.setInput(fModel);
- fPagebook.showPage(fSplitter);
- updateDescription();
- updateHistory(inputType);
- updateActionEnablement();
- fModel.computeGraph();
- }
+ fInfoText.setText(msg);
+ fPagebook.showPage(fInfoText);
+ fShowsMessage = true;
+ updateDescription();
+ updateActionEnablement();
+ }
+
+ void setInput(ICElement inputType, ICElement inputMember) {
+ if (inputType == null) {
+ setMessage(Messages.THViewPart_instruction);
+ fHierarchyTreeViewer.setInput(null);
+ fMemberViewer.setInput(null);
+ return;
+ }
+ fShowsMessage = false;
+ fModel.setInput(inputType, inputMember);
+ fHierarchyTreeViewer.setInput(fModel);
+ fMemberViewer.setInput(fModel);
+ fPagebook.showPage(fSplitter);
+ updateDescription();
+ updateHistory(inputType);
+ updateActionEnablement();
+ fModel.computeGraph();
+ }
@Override
public void createPartControl(Composite parent) {
- fPagebook = new PageBook(parent, SWT.NULL);
- createInfoPage();
- createViewerPage();
-
- initSelectionProvider();
-
- initDragAndDrop();
- createActions();
- createContextMenu();
-
- setMessage(Messages.THViewPart_instruction);
- initializeActionStates();
-
- IContextService ctxService = getSite().getService(IContextService.class);
- if (ctxService != null) {
- fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
- }
+ fPagebook = new PageBook(parent, SWT.NULL);
+ createInfoPage();
+ createViewerPage();
+
+ initSelectionProvider();
+
+ initDragAndDrop();
+ createActions();
+ createContextMenu();
+
+ setMessage(Messages.THViewPart_instruction);
+ initializeActionStates();
+
+ IContextService ctxService = getSite().getService(IContextService.class);
+ if (ctxService != null) {
+ fContextActivation = ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+ }
PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.TYPE_HIERARCHY_VIEW);
}
-
+
@Override
public void dispose() {
if (fContextActivation != null) {
IContextService ctxService = getSite().getService(IContextService.class);
- if (ctxService != null) {
- ctxService.deactivateContext(fContextActivation);
- }
+ if (ctxService != null) {
+ ctxService.deactivateContext(fContextActivation);
+ }
}
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.dispose();
- fOpenViewActionGroup= null;
+ fOpenViewActionGroup = null;
}
if (fSelectionSearchGroup != null) {
fSelectionSearchGroup.dispose();
- fSelectionSearchGroup= null;
+ fSelectionSearchGroup = null;
}
if (fRefactoringActionGroup != null) {
fRefactoringActionGroup.dispose();
- fRefactoringActionGroup= null;
+ fRefactoringActionGroup = null;
}
if (fWorkingSetFilterUI != null) {
fWorkingSetFilterUI.dispose();
- fWorkingSetFilterUI= null;
+ fWorkingSetFilterUI = null;
}
super.dispose();
}
-
+
private void initSelectionProvider() {
- SelectionProviderMediator mediator= new SelectionProviderMediator();
+ SelectionProviderMediator mediator = new SelectionProviderMediator();
mediator.addViewer(fHierarchyTreeViewer);
mediator.addViewer(fMemberViewer);
getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, mediator));
}
- private void initializeActionStates() {
- int mode= THHierarchyModel.TYPE_HIERARCHY;
- int orientation= ORIENTATION_AUTOMATIC;
- boolean showFiles= false;
- boolean showInheritedMembers= false;
- boolean hideFields= false;
- boolean hideStatic= false;
- boolean hideNonPublic= false;
- int[] weights= {35,65};
-
- if (fMemento != null) {
- showFiles= TRUE.equals(fMemento.getString(KEY_SHOW_FILES));
- showInheritedMembers= TRUE.equals(fMemento.getString(KEY_SHOW_INHERITED_MEMBERS));
- hideFields= TRUE.equals(fMemento.getString(KEY_FILTER_FIELDS));
- hideStatic= TRUE.equals(fMemento.getString(KEY_FILTER_STATIC));
- hideNonPublic= TRUE.equals(fMemento.getString(KEY_FILTER_NON_PUBLIC));
- Integer intval= fMemento.getInteger(KEY_MODE);
- if (intval != null) {
- mode= intval.intValue();
- }
- intval= fMemento.getInteger(KEY_ORIENTATION);
- if (intval != null) {
- orientation= intval.intValue();
- }
- intval= fMemento.getInteger(KEY_SPLITTER_W1);
- Integer intval2= fMemento.getInteger(KEY_SPLITTER_W2);
- if (intval != null && intval2 != null) {
- weights[0]= intval.intValue();
- weights[1]= intval2.intValue();
- }
- }
- restoreOrientation(orientation);
- restoreHierarchyKind(mode);
+ private void initializeActionStates() {
+ int mode = THHierarchyModel.TYPE_HIERARCHY;
+ int orientation = ORIENTATION_AUTOMATIC;
+ boolean showFiles = false;
+ boolean showInheritedMembers = false;
+ boolean hideFields = false;
+ boolean hideStatic = false;
+ boolean hideNonPublic = false;
+ int[] weights = { 35, 65 };
+
+ if (fMemento != null) {
+ showFiles = TRUE.equals(fMemento.getString(KEY_SHOW_FILES));
+ showInheritedMembers = TRUE.equals(fMemento.getString(KEY_SHOW_INHERITED_MEMBERS));
+ hideFields = TRUE.equals(fMemento.getString(KEY_FILTER_FIELDS));
+ hideStatic = TRUE.equals(fMemento.getString(KEY_FILTER_STATIC));
+ hideNonPublic = TRUE.equals(fMemento.getString(KEY_FILTER_NON_PUBLIC));
+ Integer intval = fMemento.getInteger(KEY_MODE);
+ if (intval != null) {
+ mode = intval.intValue();
+ }
+ intval = fMemento.getInteger(KEY_ORIENTATION);
+ if (intval != null) {
+ orientation = intval.intValue();
+ }
+ intval = fMemento.getInteger(KEY_SPLITTER_W1);
+ Integer intval2 = fMemento.getInteger(KEY_SPLITTER_W2);
+ if (intval != null && intval2 != null) {
+ weights[0] = intval.intValue();
+ weights[1] = intval2.intValue();
+ }
+ }
+ restoreOrientation(orientation);
+ restoreHierarchyKind(mode);
fSplitter.setWeights(weights);
fShowInheritedMembersAction.setChecked(showInheritedMembers);
fShowInheritedMembersAction.run();
-
+
fFieldFilterAction.setChecked(hideFields);
fFieldFilterAction.run();
fStaticFilterAction.setChecked(hideStatic);
@@ -331,80 +333,76 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
fNonPublicFilterAction.run();
fHierarchyLabelProvider.setShowFiles(showFiles);
- fShowFilesInLabelsAction.setChecked(showFiles);
-
+ fShowFilesInLabelsAction.setChecked(showFiles);
+
fMemberToolbarManager.update(true);
- }
+ }
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
- fMemento= memento;
- super.init(site, memento);
- }
-
+ fMemento = memento;
+ super.init(site, memento);
+ }
- @Override
+ @Override
public void saveState(IMemento memento) {
- if (fWorkingSetFilterUI != null) {
- fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
- }
- memento.putString(KEY_SHOW_INHERITED_MEMBERS, String.valueOf(fShowInheritedMembersAction.isChecked()));
- memento.putString(KEY_SHOW_FILES, String.valueOf(fShowFilesInLabelsAction.isChecked()));
- memento.putString(KEY_FILTER_FIELDS, String.valueOf(fFieldFilterAction.isChecked()));
- memento.putString(KEY_FILTER_STATIC, String.valueOf(fStaticFilterAction.isChecked()));
- memento.putString(KEY_FILTER_NON_PUBLIC, String.valueOf(fNonPublicFilterAction.isChecked()));
- int[] weights= fSplitter.getWeights();
- memento.putInteger(KEY_SPLITTER_W1, weights[0]);
- memento.putInteger(KEY_SPLITTER_W2, weights[1]);
- if (fAutomaticOrientation.isChecked()) {
- memento.putInteger(KEY_ORIENTATION, ORIENTATION_AUTOMATIC);
- }
- else {
- memento.putInteger(KEY_ORIENTATION, fCurrentViewOrientation);
- }
- super.saveState(memento);
- }
-
- private void createContextMenu() {
- IWorkbenchPartSite site = getSite();
-
- // hierarchy
- MenuManager manager = new MenuManager();
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
- @Override
+ if (fWorkingSetFilterUI != null) {
+ fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
+ }
+ memento.putString(KEY_SHOW_INHERITED_MEMBERS, String.valueOf(fShowInheritedMembersAction.isChecked()));
+ memento.putString(KEY_SHOW_FILES, String.valueOf(fShowFilesInLabelsAction.isChecked()));
+ memento.putString(KEY_FILTER_FIELDS, String.valueOf(fFieldFilterAction.isChecked()));
+ memento.putString(KEY_FILTER_STATIC, String.valueOf(fStaticFilterAction.isChecked()));
+ memento.putString(KEY_FILTER_NON_PUBLIC, String.valueOf(fNonPublicFilterAction.isChecked()));
+ int[] weights = fSplitter.getWeights();
+ memento.putInteger(KEY_SPLITTER_W1, weights[0]);
+ memento.putInteger(KEY_SPLITTER_W2, weights[1]);
+ if (fAutomaticOrientation.isChecked()) {
+ memento.putInteger(KEY_ORIENTATION, ORIENTATION_AUTOMATIC);
+ } else {
+ memento.putInteger(KEY_ORIENTATION, fCurrentViewOrientation);
+ }
+ super.saveState(memento);
+ }
+
+ private void createContextMenu() {
+ IWorkbenchPartSite site = getSite();
+
+ // hierarchy
+ MenuManager manager = new MenuManager();
+ manager.setRemoveAllWhenShown(true);
+ manager.addMenuListener(new IMenuListener() {
+ @Override
public void menuAboutToShow(IMenuManager m) {
- onContextMenuAboutToShow(m, true);
- }
- });
- Menu menu = manager.createContextMenu(fHierarchyTreeViewer.getControl());
- fHierarchyTreeViewer.getControl().setMenu(menu);
- site.registerContextMenu(CUIPlugin.ID_TYPE_HIERARCHY, manager, fHierarchyTreeViewer);
-
- manager = new MenuManager();
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
- @Override
+ onContextMenuAboutToShow(m, true);
+ }
+ });
+ Menu menu = manager.createContextMenu(fHierarchyTreeViewer.getControl());
+ fHierarchyTreeViewer.getControl().setMenu(menu);
+ site.registerContextMenu(CUIPlugin.ID_TYPE_HIERARCHY, manager, fHierarchyTreeViewer);
+
+ manager = new MenuManager();
+ manager.setRemoveAllWhenShown(true);
+ manager.addMenuListener(new IMenuListener() {
+ @Override
public void menuAboutToShow(IMenuManager m) {
- onContextMenuAboutToShow(m, false);
- }
- });
- menu = manager.createContextMenu(fMemberViewer.getControl());
- fMemberViewer.getControl().setMenu(menu);
- site.registerContextMenu(CUIPlugin.ID_TYPE_HIERARCHY + ".members", manager, fMemberViewer); //$NON-NLS-1$
- }
+ onContextMenuAboutToShow(m, false);
+ }
+ });
+ menu = manager.createContextMenu(fMemberViewer.getControl());
+ fMemberViewer.getControl().setMenu(menu);
+ site.registerContextMenu(CUIPlugin.ID_TYPE_HIERARCHY + ".members", manager, fMemberViewer); //$NON-NLS-1$
+ }
protected void onContextMenuAboutToShow(IMenuManager menu, boolean hierarchyView) {
CUIPlugin.createStandardGroups(menu);
- StructuredViewer viewer= hierarchyView ? (StructuredViewer) fHierarchyTreeViewer : fMemberViewer;
- final ICElement elem= selectionToElement(viewer.getSelection());
+ StructuredViewer viewer = hierarchyView ? (StructuredViewer) fHierarchyTreeViewer : fMemberViewer;
+ final ICElement elem = selectionToElement(viewer.getSelection());
if (elem != null) {
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenElement);
if (hierarchyView && !elem.equals(fModel.getInput())) {
- String label= MessageFormat.format(Messages.THViewPart_FocusOn,
- new Object[] {
- CElementLabels.getTextLabel(elem, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES)
- });
+ String label = MessageFormat.format(Messages.THViewPart_FocusOn, new Object[] { CElementLabels
+ .getTextLabel(elem, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES) });
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) {
@Override
public void run() {
@@ -413,7 +411,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
});
}
}
-
+
// action groups
ISelection selection = getSite().getSelectionProvider().getSelection();
if (OpenViewActionGroup.canActionBeAdded(selection)) {
@@ -421,7 +419,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
if (hierarchyView && fCopyAction.canActionBeAdded()) {
- menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fCopyAction);
+ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fCopyAction);
}
if (SelectionSearchGroup.canActionBeAdded(selection)) {
@@ -431,12 +429,13 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
private void createViewerPage() {
- fSplitter= new SashForm(fPagebook, SWT.VERTICAL);
+ fSplitter = new SashForm(fPagebook, SWT.VERTICAL);
fSplitter.setLayoutData(new GridData(GridData.FILL_BOTH));
fSplitter.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
+
@Override
public void controlResized(ControlEvent e) {
if (fAutomaticOrientation.isChecked()) {
@@ -445,21 +444,21 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
});
- fHierarchyViewForm= new ViewForm(fSplitter, SWT.NONE);
- Control hierarchyControl= createHierarchyControl(fHierarchyViewForm);
+ fHierarchyViewForm = new ViewForm(fSplitter, SWT.NONE);
+ Control hierarchyControl = createHierarchyControl(fHierarchyViewForm);
fHierarchyViewForm.setContent(hierarchyControl);
-
- fMemberViewForm= new ViewForm(fSplitter, SWT.NONE);
- Control memberControl= createMemberControl(fMemberViewForm);
+
+ fMemberViewForm = new ViewForm(fSplitter, SWT.NONE);
+ Control memberControl = createMemberControl(fMemberViewForm);
fMemberViewForm.setContent(memberControl);
-
+
fMemberLabel = new CLabel(fMemberViewForm, SWT.NONE);
- fMemberLabel.setText(Messages.THViewPart_MethodPane_title);
+ fMemberLabel.setText(Messages.THViewPart_MethodPane_title);
fMemberViewForm.setTopLeft(fMemberLabel);
}
-
+
private Control createMemberControl(ViewForm parent) {
- fMemberLabelProvider= new AppearanceAwareLabelProvider(MEMBER_LABEL_OPTIONS_SIMPLE, MEMBER_ICON_OPTIONS);
+ fMemberLabelProvider = new AppearanceAwareLabelProvider(MEMBER_LABEL_OPTIONS_SIMPLE, MEMBER_ICON_OPTIONS);
fMemberViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
fMemberViewer.setContentProvider(new THMemberContentProvider());
fMemberViewer.setLabelProvider(new DecoratingCLabelProvider(fMemberLabelProvider, true));
@@ -469,38 +468,41 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
onOpenElement(event.getSelection());
}
});
- fMemberViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ fMemberViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
onMemberSelectionChanged(event);
}
- });
- fMemberViewer.setSorter(new ViewerSorter() {
- @Override
+ });
+ fMemberViewer.setSorter(new ViewerSorter() {
+ @Override
public int category(Object element) {
- if (element instanceof ICElement) {
- ICElement celem= (ICElement)element;
- switch (celem.getElementType()) {
- case ICElement.C_FIELD: return 1;
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- IMethodDeclaration md= (IMethodDeclaration) celem;
- try {
- if (md.isConstructor()) return 2;
- if (md.isDestructor()) return 3;
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- break;
- }
- }
- return 10;
- }
- });
-
- final ToolBar memberToolBar= new ToolBar(parent, SWT.FLAT | SWT.WRAP);
+ if (element instanceof ICElement) {
+ ICElement celem = (ICElement) element;
+ switch (celem.getElementType()) {
+ case ICElement.C_FIELD:
+ return 1;
+ case ICElement.C_METHOD:
+ case ICElement.C_METHOD_DECLARATION:
+ IMethodDeclaration md = (IMethodDeclaration) celem;
+ try {
+ if (md.isConstructor())
+ return 2;
+ if (md.isDestructor())
+ return 3;
+ } catch (CModelException e) {
+ CUIPlugin.log(e);
+ }
+ break;
+ }
+ }
+ return 10;
+ }
+ });
+
+ final ToolBar memberToolBar = new ToolBar(parent, SWT.FLAT | SWT.WRAP);
parent.setTopCenter(memberToolBar);
-
+
memberToolBar.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
@@ -516,339 +518,351 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
});
- fMemberToolbarManager= new ToolBarManager(memberToolBar);
- return fMemberViewer.getControl();
+ fMemberToolbarManager = new ToolBarManager(memberToolBar);
+ return fMemberViewer.getControl();
}
protected void onMemberSelectionChanged(SelectionChangedEvent event) {
if (fIgnoreSelectionChanges == 0) {
- ICElement elem= selectionToElement(event.getSelection());
+ ICElement elem = selectionToElement(event.getSelection());
fModel.onMemberSelectionChanged(elem);
fHierarchyTreeViewer.refresh();
}
}
private Control createHierarchyControl(ViewForm parent) {
- Display display= getSite().getShell().getDisplay();
- fModel= new THHierarchyModel(this, display, false);
- fHierarchyLabelProvider= new THLabelProvider(display, fModel);
- fHierarchyTreeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- fHierarchyTreeViewer.setContentProvider(new THContentProvider());
- fHierarchyTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fHierarchyLabelProvider, true));
- fHierarchyTreeViewer.setSorter(new ViewerSorter());
- fHierarchyTreeViewer.setUseHashlookup(true);
- fHierarchyTreeViewer.addOpenListener(new IOpenListener() {
+ Display display = getSite().getShell().getDisplay();
+ fModel = new THHierarchyModel(this, display, false);
+ fHierarchyLabelProvider = new THLabelProvider(display, fModel);
+ fHierarchyTreeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ fHierarchyTreeViewer.setContentProvider(new THContentProvider());
+ fHierarchyTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fHierarchyLabelProvider, true));
+ fHierarchyTreeViewer.setSorter(new ViewerSorter());
+ fHierarchyTreeViewer.setUseHashlookup(true);
+ fHierarchyTreeViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
onOpenElement(event.getSelection());
}
});
- fHierarchyTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ fHierarchyTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
onHierarchySelectionChanged(event);
}
- });
-
- return fHierarchyTreeViewer.getControl();
- }
+ });
- protected void onHierarchySelectionChanged(SelectionChangedEvent event) {
+ return fHierarchyTreeViewer.getControl();
+ }
+
+ protected void onHierarchySelectionChanged(SelectionChangedEvent event) {
if (fIgnoreSelectionChanges == 0) {
- THNode node= selectionToNode(event.getSelection());
+ THNode node = selectionToNode(event.getSelection());
fModel.onHierarchySelectionChanged(node);
updateView();
}
}
private void createInfoPage() {
- fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
- }
-
- private void initDragAndDrop() {
- THDropTargetListener dropListener= new THDropTargetListener(this);
- Transfer[] localSelectionTransfer= new Transfer[] { LocalSelectionTransfer.getTransfer() };
- DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
- dropTarget.setTransfer(localSelectionTransfer);
- dropTarget.addDropListener(dropListener);
- }
-
- private void createActions() {
- // action groups
- fOpenViewActionGroup= new OpenViewActionGroup(this);
- fOpenViewActionGroup.setSuppressTypeHierarchy(true);
- fOpenViewActionGroup.setSuppressProperties(true);
- fOpenViewActionGroup.setEnableIncludeBrowser(true);
- fSelectionSearchGroup= new SelectionSearchGroup(getSite());
- fRefactoringActionGroup= new CRefactoringActionGroup(this);
-
- fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
- @Override
+ fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
+ }
+
+ private void initDragAndDrop() {
+ THDropTargetListener dropListener = new THDropTargetListener(this);
+ Transfer[] localSelectionTransfer = new Transfer[] { LocalSelectionTransfer.getTransfer() };
+ DropTarget dropTarget = new DropTarget(fPagebook,
+ DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
+ dropTarget.setTransfer(localSelectionTransfer);
+ dropTarget.addDropListener(dropListener);
+ }
+
+ private void createActions() {
+ // action groups
+ fOpenViewActionGroup = new OpenViewActionGroup(this);
+ fOpenViewActionGroup.setSuppressTypeHierarchy(true);
+ fOpenViewActionGroup.setSuppressProperties(true);
+ fOpenViewActionGroup.setEnableIncludeBrowser(true);
+ fSelectionSearchGroup = new SelectionSearchGroup(getSite());
+ fRefactoringActionGroup = new CRefactoringActionGroup(this);
+
+ fWorkingSetFilterUI = new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
+ @Override
protected void onWorkingSetChange() {
- updateWorkingSetFilter(this);
- }
- @Override
+ updateWorkingSetFilter(this);
+ }
+
+ @Override
protected void onWorkingSetNameChange() {
- updateDescription();
- }
- };
+ updateDescription();
+ }
+ };
- fHorizontalOrientation= new Action(Messages.THViewPart_HorizontalOrientation, IAction.AS_RADIO_BUTTON) {
+ fHorizontalOrientation = new Action(Messages.THViewPart_HorizontalOrientation, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
setOrientation(ORIENTATION_HORIZONTAL);
}
};
- CPluginImages.setImageDescriptors(fHorizontalOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_HORIZONTAL_ORIENTATION);
+ CPluginImages.setImageDescriptors(fHorizontalOrientation, CPluginImages.T_LCL,
+ CPluginImages.IMG_LCL_HORIZONTAL_ORIENTATION);
- fVerticalOrientation= new Action(Messages.THViewPart_VerticalOrientation, IAction.AS_RADIO_BUTTON) {
+ fVerticalOrientation = new Action(Messages.THViewPart_VerticalOrientation, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
setOrientation(ORIENTATION_VERTICAL);
}
};
- CPluginImages.setImageDescriptors(fVerticalOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_VERTICAL_ORIENTATION);
+ CPluginImages.setImageDescriptors(fVerticalOrientation, CPluginImages.T_LCL,
+ CPluginImages.IMG_LCL_VERTICAL_ORIENTATION);
- fAutomaticOrientation= new Action(Messages.THViewPart_AutomaticOrientation, IAction.AS_RADIO_BUTTON) {
+ fAutomaticOrientation = new Action(Messages.THViewPart_AutomaticOrientation, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
setOrientation(ORIENTATION_AUTOMATIC);
}
};
- CPluginImages.setImageDescriptors(fAutomaticOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_AUTOMATIC_ORIENTATION);
+ CPluginImages.setImageDescriptors(fAutomaticOrientation, CPluginImages.T_LCL,
+ CPluginImages.IMG_LCL_AUTOMATIC_ORIENTATION);
- fSingleOrientation= new Action(Messages.THViewPart_SinglePaneOrientation, IAction.AS_RADIO_BUTTON) {
+ fSingleOrientation = new Action(Messages.THViewPart_SinglePaneOrientation, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
setOrientation(ORIENTATION_SINGLE);
}
};
- CPluginImages.setImageDescriptors(fSingleOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SINGLE_ORIENTATION);
+ CPluginImages.setImageDescriptors(fSingleOrientation, CPluginImages.T_LCL,
+ CPluginImages.IMG_LCL_SINGLE_ORIENTATION);
- fShowTypeHierarchyAction= new Action(Messages.THViewPart_CompleteTypeHierarchy, IAction.AS_RADIO_BUTTON) {
+ fShowTypeHierarchyAction = new Action(Messages.THViewPart_CompleteTypeHierarchy, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (isChecked()) {
onSetHierarchyKind(THHierarchyModel.TYPE_HIERARCHY);
}
}
- };
- fShowTypeHierarchyAction.setToolTipText(Messages.THViewPart_CompleteTypeHierarchy_tooltip);
- CPluginImages.setImageDescriptors(fShowTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_TYPE_HIERARCHY);
+ };
+ fShowTypeHierarchyAction.setToolTipText(Messages.THViewPart_CompleteTypeHierarchy_tooltip);
+ CPluginImages.setImageDescriptors(fShowTypeHierarchyAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_LCL_TYPE_HIERARCHY);
- fShowSubTypeHierarchyAction= new Action(Messages.THViewPart_SubtypeHierarchy, IAction.AS_RADIO_BUTTON) {
+ fShowSubTypeHierarchyAction = new Action(Messages.THViewPart_SubtypeHierarchy, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (isChecked()) {
onSetHierarchyKind(THHierarchyModel.SUB_TYPE_HIERARCHY);
}
}
- };
- fShowSubTypeHierarchyAction.setToolTipText(Messages.THViewPart_SubtypeHierarchy_tooltip);
- CPluginImages.setImageDescriptors(fShowSubTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SUB_TYPE_HIERARCHY);
+ };
+ fShowSubTypeHierarchyAction.setToolTipText(Messages.THViewPart_SubtypeHierarchy_tooltip);
+ CPluginImages.setImageDescriptors(fShowSubTypeHierarchyAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_LCL_SUB_TYPE_HIERARCHY);
- fShowSuperTypeHierarchyAction= new Action(Messages.THViewPart_SupertypeHierarchy, IAction.AS_RADIO_BUTTON) {
+ fShowSuperTypeHierarchyAction = new Action(Messages.THViewPart_SupertypeHierarchy, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (isChecked()) {
onSetHierarchyKind(THHierarchyModel.SUPER_TYPE_HIERARCHY);
}
}
- };
- fShowSuperTypeHierarchyAction.setToolTipText(Messages.THViewPart_SupertypeHierarchy_tooltip);
- CPluginImages.setImageDescriptors(fShowSuperTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SUPER_TYPE_HIERARCHY);
+ };
+ fShowSuperTypeHierarchyAction.setToolTipText(Messages.THViewPart_SupertypeHierarchy_tooltip);
+ CPluginImages.setImageDescriptors(fShowSuperTypeHierarchyAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_LCL_SUPER_TYPE_HIERARCHY);
- fShowInheritedMembersAction= new Action(Messages.THViewPart_ShowInherited_label, IAction.AS_CHECK_BOX) {
+ fShowInheritedMembersAction = new Action(Messages.THViewPart_ShowInherited_label, IAction.AS_CHECK_BOX) {
@Override
public void run() {
onShowInheritedMembers(isChecked());
}
- };
- fShowInheritedMembersAction.setToolTipText(Messages.THViewPart_ShowInherited_tooltip);
- CPluginImages.setImageDescriptors(fShowInheritedMembersAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SHOW_INHERITED_MEMBERS);
+ };
+ fShowInheritedMembersAction.setToolTipText(Messages.THViewPart_ShowInherited_tooltip);
+ CPluginImages.setImageDescriptors(fShowInheritedMembersAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_LCL_SHOW_INHERITED_MEMBERS);
- fFieldFilter= new ViewerFilter() {
- @Override
+ fFieldFilter = new ViewerFilter() {
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof ICElement) {
- ICElement node= (ICElement) element;
- switch (node.getElementType()) {
- case ICElement.C_ENUMERATOR:
- case ICElement.C_FIELD:
- case ICElement.C_TEMPLATE_VARIABLE:
- case ICElement.C_VARIABLE:
- case ICElement.C_VARIABLE_DECLARATION:
- case ICElement.C_VARIABLE_LOCAL:
- return false;
- }
- }
- return true;
- }
- };
- fStaticFilter= new ViewerFilter() {
- @Override
+ if (element instanceof ICElement) {
+ ICElement node = (ICElement) element;
+ switch (node.getElementType()) {
+ case ICElement.C_ENUMERATOR:
+ case ICElement.C_FIELD:
+ case ICElement.C_TEMPLATE_VARIABLE:
+ case ICElement.C_VARIABLE:
+ case ICElement.C_VARIABLE_DECLARATION:
+ case ICElement.C_VARIABLE_LOCAL:
+ return false;
+ }
+ }
+ return true;
+ }
+ };
+ fStaticFilter = new ViewerFilter() {
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IDeclaration) {
- IDeclaration node= (IDeclaration) element;
- try {
+ if (element instanceof IDeclaration) {
+ IDeclaration node = (IDeclaration) element;
+ try {
return !node.isStatic();
} catch (CModelException e) {
CUIPlugin.log(e);
}
- }
- return true;
- }
- };
- fNonPublicFilter= new ViewerFilter() {
- @Override
+ }
+ return true;
+ }
+ };
+ fNonPublicFilter = new ViewerFilter() {
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IMember) {
- IMember node= (IMember) element;
- try {
+ if (element instanceof IMember) {
+ IMember node = (IMember) element;
+ try {
return ASTAccessVisibility.PUBLIC.equals(node.getVisibility());
} catch (CModelException e) {
CUIPlugin.log(e);
}
- }
- return true;
- }
- };
- fFieldFilterAction= new Action(Messages.THViewPart_HideFields_label, IAction.AS_CHECK_BOX) {
- @Override
+ }
+ return true;
+ }
+ };
+ fFieldFilterAction = new Action(Messages.THViewPart_HideFields_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- if (isChecked()) {
- fMemberViewer.addFilter(fFieldFilter);
- }
- else {
- fMemberViewer.removeFilter(fFieldFilter);
- }
- }
- };
- fFieldFilterAction.setToolTipText(Messages.THViewPart_HideFields_tooltip);
- CPluginImages.setImageDescriptors(fFieldFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
-
- fStaticFilterAction= new Action(Messages.THViewPart_HideStatic_label, IAction.AS_CHECK_BOX) {
- @Override
+ if (isChecked()) {
+ fMemberViewer.addFilter(fFieldFilter);
+ } else {
+ fMemberViewer.removeFilter(fFieldFilter);
+ }
+ }
+ };
+ fFieldFilterAction.setToolTipText(Messages.THViewPart_HideFields_tooltip);
+ CPluginImages.setImageDescriptors(fFieldFilterAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_HIDE_FIELDS);
+
+ fStaticFilterAction = new Action(Messages.THViewPart_HideStatic_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- if (isChecked()) {
- fMemberViewer.addFilter(fStaticFilter);
- } else {
- fMemberViewer.removeFilter(fStaticFilter);
- }
- }
- };
- fStaticFilterAction.setToolTipText(Messages.THViewPart_HideStatic_tooltip);
- CPluginImages.setImageDescriptors(fStaticFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC);
-
- fNonPublicFilterAction= new Action(Messages.THViewPart_HideNonPublic_label, IAction.AS_CHECK_BOX) {
- @Override
+ if (isChecked()) {
+ fMemberViewer.addFilter(fStaticFilter);
+ } else {
+ fMemberViewer.removeFilter(fStaticFilter);
+ }
+ }
+ };
+ fStaticFilterAction.setToolTipText(Messages.THViewPart_HideStatic_tooltip);
+ CPluginImages.setImageDescriptors(fStaticFilterAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_HIDE_STATIC);
+
+ fNonPublicFilterAction = new Action(Messages.THViewPart_HideNonPublic_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- if (isChecked()) {
- fMemberViewer.addFilter(fNonPublicFilter);
- } else {
- fMemberViewer.removeFilter(fNonPublicFilter);
- }
- }
- };
- fNonPublicFilterAction.setToolTipText(Messages.THViewPart_HideNonPublic_tooltip);
- CPluginImages.setImageDescriptors(fNonPublicFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC);
-
- fOpenElement= new Action(Messages.THViewPart_Open) {
- @Override
+ if (isChecked()) {
+ fMemberViewer.addFilter(fNonPublicFilter);
+ } else {
+ fMemberViewer.removeFilter(fNonPublicFilter);
+ }
+ }
+ };
+ fNonPublicFilterAction.setToolTipText(Messages.THViewPart_HideNonPublic_tooltip);
+ CPluginImages.setImageDescriptors(fNonPublicFilterAction, CPluginImages.T_LCL,
+ CPluginImages.IMG_ACTION_SHOW_PUBLIC);
+
+ fOpenElement = new Action(Messages.THViewPart_Open) {
+ @Override
public void run() {
- onOpenElement(getSite().getSelectionProvider().getSelection());
- }
- };
- fOpenElement.setToolTipText(Messages.THViewPart_Open_tooltip);
- fOpenElement.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
-
- fShowFilesInLabelsAction= new Action(Messages.THViewPart_ShowFileNames, IAction.AS_CHECK_BOX) {
- @Override
+ onOpenElement(getSite().getSelectionProvider().getSelection());
+ }
+ };
+ fOpenElement.setToolTipText(Messages.THViewPart_Open_tooltip);
+ fOpenElement.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
+
+ fShowFilesInLabelsAction = new Action(Messages.THViewPart_ShowFileNames, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
- onShowFilesInLabels(isChecked());
- }
- };
- fShowFilesInLabelsAction.setToolTipText(Messages.THViewPart_ShowFileNames_tooltip);
+ onShowFilesInLabels(isChecked());
+ }
+ };
+ fShowFilesInLabelsAction.setToolTipText(Messages.THViewPart_ShowFileNames_tooltip);
- fRefreshAction = new Action(Messages.THViewPart_Refresh) {
- @Override
+ fRefreshAction = new Action(Messages.THViewPart_Refresh) {
+ @Override
public void run() {
- onRefresh();
- }
- };
- fRefreshAction.setToolTipText(Messages.THViewPart_Refresh_tooltip);
- CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
-
- fCancelAction = new Action(Messages.THViewPart_Cancel) {
- @Override
+ onRefresh();
+ }
+ };
+ fRefreshAction.setToolTipText(Messages.THViewPart_Refresh_tooltip);
+ CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
+
+ fCancelAction = new Action(Messages.THViewPart_Cancel) {
+ @Override
public void run() {
- onCancel();
- }
- };
- fCancelAction.setToolTipText(Messages.THViewPart_Cancel_tooltip);
- CPluginImages.setImageDescriptors(fCancelAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_CANCEL);
-
- fHistoryAction = new THHistoryDropDownAction(this);
-
- fCopyAction= new CopyTypeHierarchyAction(this, fHierarchyTreeViewer);
-
- // setup action bar
- // global action hooks
- IActionBars actionBars = getViewSite().getActionBars();
- fRefactoringActionGroup.fillActionBars(actionBars);
- fOpenViewActionGroup.fillActionBars(actionBars);
- fSelectionSearchGroup.fillActionBars(actionBars);
-
- actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenElement);
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
- actionBars.updateActionBars();
-
- // local toolbar
- IToolBarManager tm = actionBars.getToolBarManager();
- tm.add(fShowTypeHierarchyAction);
- tm.add(fShowSuperTypeHierarchyAction);
- tm.add(fShowSubTypeHierarchyAction);
+ onCancel();
+ }
+ };
+ fCancelAction.setToolTipText(Messages.THViewPart_Cancel_tooltip);
+ CPluginImages.setImageDescriptors(fCancelAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_CANCEL);
+
+ fHistoryAction = new THHistoryDropDownAction(this);
+
+ fCopyAction = new CopyTypeHierarchyAction(this, fHierarchyTreeViewer);
+
+ // setup action bar
+ // global action hooks
+ IActionBars actionBars = getViewSite().getActionBars();
+ fRefactoringActionGroup.fillActionBars(actionBars);
+ fOpenViewActionGroup.fillActionBars(actionBars);
+ fSelectionSearchGroup.fillActionBars(actionBars);
+
+ actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenElement);
+ actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
+ actionBars.updateActionBars();
+
+ // local toolbar
+ IToolBarManager tm = actionBars.getToolBarManager();
+ tm.add(fShowTypeHierarchyAction);
+ tm.add(fShowSuperTypeHierarchyAction);
+ tm.add(fShowSubTypeHierarchyAction);
tm.add(fHistoryAction);
- tm.add(fRefreshAction);
- tm.add(fCancelAction);
+ tm.add(fRefreshAction);
+ tm.add(fCancelAction);
- // local menu
- IMenuManager mm = actionBars.getMenuManager();
+ // local menu
+ IMenuManager mm = actionBars.getMenuManager();
- fWorkingSetFilterUI.fillActionBars(actionBars);
- mm.add(new Separator(IContextMenuConstants.GROUP_SHOW));
- mm.add(fShowTypeHierarchyAction);
- mm.add(fShowSuperTypeHierarchyAction);
- mm.add(fShowSubTypeHierarchyAction);
- mm.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
+ fWorkingSetFilterUI.fillActionBars(actionBars);
+ mm.add(new Separator(IContextMenuConstants.GROUP_SHOW));
+ mm.add(fShowTypeHierarchyAction);
+ mm.add(fShowSuperTypeHierarchyAction);
+ mm.add(fShowSubTypeHierarchyAction);
+ mm.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
- MenuManager submenu= new MenuManager(Messages.THViewPart_LayoutMenu);
+ MenuManager submenu = new MenuManager(Messages.THViewPart_LayoutMenu);
submenu.add(fHorizontalOrientation);
submenu.add(fVerticalOrientation);
submenu.add(fAutomaticOrientation);
submenu.add(fSingleOrientation);
mm.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, submenu);
- mm.add(new Separator());
- mm.add(fShowFilesInLabelsAction);
-
- // member toolbar
- fMemberToolbarManager.add(fShowInheritedMembersAction);
- fMemberToolbarManager.add(new Separator());
- fMemberToolbarManager.add(fFieldFilterAction);
- fMemberToolbarManager.add(fStaticFilterAction);
- fMemberToolbarManager.add(fNonPublicFilterAction);
- }
-
+ mm.add(new Separator());
+ mm.add(fShowFilesInLabelsAction);
+
+ // member toolbar
+ fMemberToolbarManager.add(fShowInheritedMembersAction);
+ fMemberToolbarManager.add(new Separator());
+ fMemberToolbarManager.add(fFieldFilterAction);
+ fMemberToolbarManager.add(fStaticFilterAction);
+ fMemberToolbarManager.add(fNonPublicFilterAction);
+ }
+
protected void onOpenElement(ISelection selection) {
- ICElement elem= selectionToElement(selection);
- openElement(elem);
+ ICElement elem = selectionToElement(selection);
+ openElement(elem);
}
private void openElement(ICElement elem) {
if (elem != null) {
- IWorkbenchPage page= getSite().getPage();
+ IWorkbenchPage page = getSite().getPage();
try {
EditorOpener.open(page, elem);
} catch (CModelException e) {
@@ -857,67 +871,67 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
}
- protected void onRefresh() {
- fModel.refresh();
- updateActionEnablement();
- }
-
- protected void onCancel() {
- fModel.stopGraphComputation();
- updateView();
- }
-
- protected void onShowFilesInLabels(boolean show) {
- fHierarchyLabelProvider.setShowFiles(show);
- fHierarchyTreeViewer.refresh();
- }
-
- private void updateHistory(ICElement input) {
- if (input != null) {
- fHistoryEntries.remove(input);
- fHistoryEntries.add(0, input);
- if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
- fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
- }
- }
+ protected void onRefresh() {
+ fModel.refresh();
+ updateActionEnablement();
+ }
+
+ protected void onCancel() {
+ fModel.stopGraphComputation();
+ updateView();
}
-
- private void updateDescription() {
- String message= ""; //$NON-NLS-1$
- if (!fShowsMessage) {
- ICElement elem= getInput();
- if (elem != null) {
- String label;
-
- // label
- label= CElementLabels.getElementLabel(elem, 0);
-
- // scope
- IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet();
- if (workingSet == null) {
- message= label;
- } else {
- String scope= workingSet.getLabel();
- message= MessageFormat.format("{0} - {1}", new Object[] {label, scope}); //$NON-NLS-1$
- }
-
- label= ""; //$NON-NLS-1$
- Image image= null;
- THNode node= fModel.getSelectionInHierarchy();
- if (node != null) {
- elem= node.getElement();
- if (elem != null) {
- label= CElementLabels.getElementLabel(elem, 0);
- image= fHierarchyLabelProvider.getImage(elem);
- }
- }
- fMemberLabel.setText(label);
- fMemberLabel.setImage(image);
- }
- }
- setContentDescription(message);
- }
-
+
+ protected void onShowFilesInLabels(boolean show) {
+ fHierarchyLabelProvider.setShowFiles(show);
+ fHierarchyTreeViewer.refresh();
+ }
+
+ private void updateHistory(ICElement input) {
+ if (input != null) {
+ fHistoryEntries.remove(input);
+ fHistoryEntries.add(0, input);
+ if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
+ fHistoryEntries.remove(MAX_HISTORY_SIZE - 1);
+ }
+ }
+ }
+
+ private void updateDescription() {
+ String message = ""; //$NON-NLS-1$
+ if (!fShowsMessage) {
+ ICElement elem = getInput();
+ if (elem != null) {
+ String label;
+
+ // label
+ label = CElementLabels.getElementLabel(elem, 0);
+
+ // scope
+ IWorkingSet workingSet = fWorkingSetFilterUI.getWorkingSet();
+ if (workingSet == null) {
+ message = label;
+ } else {
+ String scope = workingSet.getLabel();
+ message = MessageFormat.format("{0} - {1}", new Object[] { label, scope }); //$NON-NLS-1$
+ }
+
+ label = ""; //$NON-NLS-1$
+ Image image = null;
+ THNode node = fModel.getSelectionInHierarchy();
+ if (node != null) {
+ elem = node.getElement();
+ if (elem != null) {
+ label = CElementLabels.getElementLabel(elem, 0);
+ image = fHierarchyLabelProvider.getImage(elem);
+ }
+ }
+ fMemberLabel.setText(label);
+ fMemberLabel.setImage(image);
+ }
+ }
+ setContentDescription(message);
+ }
+
private void updateActionEnablement() {
fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
fRefreshAction.setEnabled(!fShowsMessage);
@@ -927,63 +941,62 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
fShowTypeHierarchyAction.setEnabled(!fShowsMessage);
}
- private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
- fModel.setWorkingSetFilter(filterUI);
- updateView();
- }
-
- public void onSetHierarchyKind(int kind) {
- if (fModel.getHierarchyKind() != kind) {
- fModel.setHierarchyKind(kind);
- updateView();
- }
- }
-
- protected void onShowInheritedMembers(boolean show) {
- if (fModel.isShowInheritedMembers() != show) {
- fModel.setShowInheritedMembers(show);
- fMemberLabelProvider.setTextFlags(show ?
- MEMBER_LABEL_OPTIONS_QUALIFIED : MEMBER_LABEL_OPTIONS_SIMPLE);
- updateViewers();
- }
- }
-
- private void updateViewers() {
- if (!fShowsMessage) {
- fIgnoreSelectionChanges++;
- try {
- fHierarchyLabelProvider.setMarkImplementers(!fModel.hasTrivialHierarchy());
- fHierarchyTreeViewer.refresh();
- fMemberViewer.refresh();
- setSelections();
- } finally {
- fIgnoreSelectionChanges--;
- }
- }
+ private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
+ fModel.setWorkingSetFilter(filterUI);
+ updateView();
}
- private void updateView() {
- if (!fShowsMessage) {
- fIgnoreSelectionChanges++;
- try {
- updateViewers();
- updateDescription();
- updateActionEnablement();
- } finally {
- fIgnoreSelectionChanges--;
- }
- }
+ public void onSetHierarchyKind(int kind) {
+ if (fModel.getHierarchyKind() != kind) {
+ fModel.setHierarchyKind(kind);
+ updateView();
+ }
+ }
+
+ protected void onShowInheritedMembers(boolean show) {
+ if (fModel.isShowInheritedMembers() != show) {
+ fModel.setShowInheritedMembers(show);
+ fMemberLabelProvider.setTextFlags(show ? MEMBER_LABEL_OPTIONS_QUALIFIED : MEMBER_LABEL_OPTIONS_SIMPLE);
+ updateViewers();
+ }
+ }
+
+ private void updateViewers() {
+ if (!fShowsMessage) {
+ fIgnoreSelectionChanges++;
+ try {
+ fHierarchyLabelProvider.setMarkImplementers(!fModel.hasTrivialHierarchy());
+ fHierarchyTreeViewer.refresh();
+ fMemberViewer.refresh();
+ setSelections();
+ } finally {
+ fIgnoreSelectionChanges--;
+ }
+ }
+ }
+
+ private void updateView() {
+ if (!fShowsMessage) {
+ fIgnoreSelectionChanges++;
+ try {
+ updateViewers();
+ updateDescription();
+ updateActionEnablement();
+ } finally {
+ fIgnoreSelectionChanges--;
+ }
+ }
}
private void setSelections() {
fIgnoreSelectionChanges++;
try {
- THNode node= fModel.getSelectionInHierarchy();
+ THNode node = fModel.getSelectionInHierarchy();
if (node != null) {
fHierarchyTreeViewer.setSelection(new StructuredSelection(node));
fHierarchyTreeViewer.expandToLevel(node, 1);
}
- ICElement elem= fModel.getSelectedMember();
+ ICElement elem = fModel.getSelectedMember();
if (elem != null) {
fMemberViewer.setSelection(new StructuredSelection(elem));
}
@@ -994,14 +1007,14 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
private ICElement selectionToElement(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) selection;
- for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
- Object cand= iter.next();
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ for (Iterator<?> iter = ss.iterator(); iter.hasNext();) {
+ Object cand = iter.next();
if (cand instanceof ICElement) {
return (ICElement) cand;
}
if (cand instanceof IAdaptable) {
- ICElement elem= ((IAdaptable) cand).getAdapter(ICElement.class);
+ ICElement elem = ((IAdaptable) cand).getAdapter(ICElement.class);
if (elem != null) {
return elem;
}
@@ -1013,9 +1026,9 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
private THNode selectionToNode(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) selection;
- for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
- Object cand= iter.next();
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ for (Iterator<?> iter = ss.iterator(); iter.hasNext();) {
+ Object cand = iter.next();
if (cand instanceof THNode) {
return (THNode) cand;
}
@@ -1038,11 +1051,11 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
ICElement getInput() {
- Object input= fModel.getInput();
- if (input instanceof ICElement) {
- return (ICElement) input;
- }
- return null;
+ Object input = fModel.getInput();
+ if (input instanceof ICElement) {
+ return (ICElement) input;
+ }
+ return null;
}
public TreeViewer getHiearchyViewer() {
@@ -1052,28 +1065,28 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
public TableViewer getMemberViewer() {
return fMemberViewer;
}
-
+
private void restoreOrientation(int orientation) {
- switch(orientation) {
- case ORIENTATION_HORIZONTAL:
- fHorizontalOrientation.setChecked(true);
- break;
- case ORIENTATION_VERTICAL:
- fVerticalOrientation.setChecked(true);
- break;
- case ORIENTATION_SINGLE:
- fSingleOrientation.setChecked(true);
- break;
- default:
- orientation= ORIENTATION_AUTOMATIC;
- fAutomaticOrientation.setChecked(true);
- break;
+ switch (orientation) {
+ case ORIENTATION_HORIZONTAL:
+ fHorizontalOrientation.setChecked(true);
+ break;
+ case ORIENTATION_VERTICAL:
+ fVerticalOrientation.setChecked(true);
+ break;
+ case ORIENTATION_SINGLE:
+ fSingleOrientation.setChecked(true);
+ break;
+ default:
+ orientation = ORIENTATION_AUTOMATIC;
+ fAutomaticOrientation.setChecked(true);
+ break;
}
setOrientation(orientation);
}
-
- private void restoreHierarchyKind(int kind) {
- switch(kind) {
+
+ private void restoreHierarchyKind(int kind) {
+ switch (kind) {
case THHierarchyModel.SUB_TYPE_HIERARCHY:
fShowSubTypeHierarchyAction.setChecked(true);
break;
@@ -1081,10 +1094,10 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
fShowSuperTypeHierarchyAction.setChecked(true);
break;
default:
- kind= THHierarchyModel.TYPE_HIERARCHY;
+ kind = THHierarchyModel.TYPE_HIERARCHY;
fShowTypeHierarchyAction.setChecked(true);
break;
- }
+ }
fModel.setHierarchyKind(kind);
}
@@ -1092,12 +1105,12 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
if (fInComputeOrientation) {
return;
}
- fInComputeOrientation= true;
+ fInComputeOrientation = true;
try {
if (fCurrentViewOrientation != orientation) {
if (fSplitter != null && !fSplitter.isDisposed()) {
if (orientation == ORIENTATION_AUTOMATIC) {
- orientation= getBestOrientation();
+ orientation = getBestOrientation();
}
if (orientation == ORIENTATION_SINGLE) {
fMemberViewForm.setVisible(false);
@@ -1105,21 +1118,21 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
if (fCurrentViewOrientation == ORIENTATION_SINGLE) {
fMemberViewForm.setVisible(true);
}
- boolean horizontal= orientation == ORIENTATION_HORIZONTAL;
+ boolean horizontal = orientation == ORIENTATION_HORIZONTAL;
fSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
}
fSplitter.layout();
}
- fCurrentViewOrientation= orientation;
+ fCurrentViewOrientation = orientation;
}
} finally {
- fInComputeOrientation= false;
+ fInComputeOrientation = false;
}
}
private int getBestOrientation() {
- Point size= fSplitter.getSize();
- if (size.x != 0 && size.y != 0 && 3 * size.x < 2 * size.y) {
+ Point size = fSplitter.getSize();
+ if (size.x != 0 && size.y != 0 && 3 * size.x < 2 * size.y) {
return ORIENTATION_VERTICAL;
}
return ORIENTATION_HORIZONTAL;
@@ -1131,12 +1144,12 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
case THHierarchyModel.END_OF_COMPUTATION:
updateView();
break;
- }
+ }
}
@Override
public IWorkbenchSiteProgressService getProgressService() {
- return getSite().getAdapter(IWorkbenchSiteProgressService.class);
+ return getSite().getAdapter(IWorkbenchSiteProgressService.class);
}
private static class CopyTypeHierarchyAction extends CopyTreeAction {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java
index 9dbaf951b2f..1e32706d185 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.typehierarchy;
@@ -52,50 +52,50 @@ import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
public class TypeHierarchyUI {
- private static final int INDEX_SEARCH_OPTION = IIndexManager.ADD_DEPENDENCIES
- | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY;
+ private static final int INDEX_SEARCH_OPTION = IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT
+ | IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY;
public static THViewPart open(ICElement input, IWorkbenchWindow window) {
- if (!isValidInput(input)) {
- return null;
- }
- ICElement memberInput= null;
- if (!isValidTypeInput(input)) {
- memberInput= input;
- input= memberInput.getParent();
- if (!isValidTypeInput(input)) {
- ICElement[] inputs= findInput(memberInput);
- if (inputs != null) {
- input= inputs[0];
- memberInput= inputs[1];
- }
- }
- }
-
- if (isValidTypeInput(input)) {
- return openInViewPart(window, input, memberInput);
- }
- return null;
- }
+ if (!isValidInput(input)) {
+ return null;
+ }
+ ICElement memberInput = null;
+ if (!isValidTypeInput(input)) {
+ memberInput = input;
+ input = memberInput.getParent();
+ if (!isValidTypeInput(input)) {
+ ICElement[] inputs = findInput(memberInput);
+ if (inputs != null) {
+ input = inputs[0];
+ memberInput = inputs[1];
+ }
+ }
+ }
- private static THViewPart openInViewPart(IWorkbenchWindow window, ICElement input, ICElement member) {
- IWorkbenchPage page= window.getActivePage();
- try {
- THViewPart result= (THViewPart)page.showView(CUIPlugin.ID_TYPE_HIERARCHY);
- result.setInput(input, member);
- return result;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, window.getShell(), Messages.TypeHierarchyUI_OpenTypeHierarchy, null);
- }
- return null;
- }
+ if (isValidTypeInput(input)) {
+ return openInViewPart(window, input, memberInput);
+ }
+ return null;
+ }
+
+ private static THViewPart openInViewPart(IWorkbenchWindow window, ICElement input, ICElement member) {
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ THViewPart result = (THViewPart) page.showView(CUIPlugin.ID_TYPE_HIERARCHY);
+ result.setInput(input, member);
+ return result;
+ } catch (CoreException e) {
+ ExceptionHandler.handle(e, window.getShell(), Messages.TypeHierarchyUI_OpenTypeHierarchy, null);
+ }
+ return null;
+ }
public static ICElement[] getInput(final ITextEditor editor, IRegion region) {
if (editor != null) {
final IEditorInput editorInput = editor.getEditorInput();
ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
if (inputCElement != null) {
- final ICProject project= inputCElement.getCProject();
+ final ICProject project = inputCElement.getCProject();
try {
return findInput(project, editorInput, region);
} catch (CoreException e) {
@@ -106,34 +106,35 @@ public class TypeHierarchyUI {
return null;
}
- public static void open(final ITextEditor editor, final ITextSelection sel) {
+ public static void open(final ITextEditor editor, final ITextSelection sel) {
if (editor != null) {
- ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+ ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager()
+ .getWorkingCopy(editor.getEditorInput());
if (inputCElement != null) {
- final ICProject project= inputCElement.getCProject();
+ final ICProject project = inputCElement.getCProject();
final IEditorInput editorInput = editor.getEditorInput();
- final Display display= Display.getCurrent();
+ final Display display = Display.getCurrent();
- Job job= new Job(Messages.TypeHierarchyUI_OpenTypeHierarchy) {
+ Job job = new Job(Messages.TypeHierarchyUI_OpenTypeHierarchy) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
StatusLineHandler.clearStatusLine(editor.getSite());
- IRegion reg= new Region(sel.getOffset(), sel.getLength());
- final ICElement[] elems= findInput(project, editorInput, reg);
+ IRegion reg = new Region(sel.getOffset(), sel.getLength());
+ final ICElement[] elems = findInput(project, editorInput, reg);
if (elems != null && elems.length == 2) {
display.asyncExec(new Runnable() {
@Override
public void run() {
openInViewPart(editor.getSite().getWorkbenchWindow(), elems[0], elems[1]);
- }});
+ }
+ });
} else {
- StatusLineHandler.showStatusLineMessage(editor.getSite(),
+ StatusLineHandler.showStatusLineMessage(editor.getSite(),
Messages.TypeHierarchyUI_OpenFailure_message);
}
return Status.OK_STATUS;
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
return e.getStatus();
}
}
@@ -142,80 +143,75 @@ public class TypeHierarchyUI {
job.schedule();
}
}
- }
-
- private static ICElement[] findInput(ICProject project, IEditorInput editorInput, IRegion sel) throws CoreException {
+ }
+
+ private static ICElement[] findInput(ICProject project, IEditorInput editorInput, IRegion sel)
+ throws CoreException {
try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
index.acquireReadLock();
try {
- IASTName name= IndexUI.getSelectedName(editorInput, sel);
+ IASTName name = IndexUI.getSelectedName(editorInput, sel);
if (name != null) {
- IBinding binding= name.resolveBinding();
+ IBinding binding = name.resolveBinding();
if (!isValidInput(binding)) {
return null;
}
- ICElement member= null;
+ ICElement member = null;
if (!isValidTypeInput(binding)) {
- member= findDeclaration(project, index, name, binding);
- name= null;
- binding= findTypeBinding(binding);
+ member = findDeclaration(project, index, name, binding);
+ name = null;
+ binding = findTypeBinding(binding);
}
if (isValidTypeInput(binding)) {
- ICElement input= findDefinition(project, index, name, binding);
+ ICElement input = findDefinition(project, index, name, binding);
if (input != null) {
- return new ICElement[] {input, member};
+ return new ICElement[] { input, member };
}
}
}
- }
- finally {
+ } finally {
index.releaseReadLock();
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
CUIPlugin.log(e);
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
}
return null;
}
- private static ICElement[] findInput(ICElement member) {
- ICProject project= member.getCProject();
+ private static ICElement[] findInput(ICElement member) {
+ ICProject project = member.getCProject();
try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(project, INDEX_SEARCH_OPTION);
index.acquireReadLock();
try {
- IIndexName name= IndexUI.elementToName(index, member);
+ IIndexName name = IndexUI.elementToName(index, member);
if (name != null) {
- member= IndexUI.getCElementForName(project, index, name);
- IBinding binding= index.findBinding(name);
- binding= findTypeBinding(binding);
+ member = IndexUI.getCElementForName(project, index, name);
+ IBinding binding = index.findBinding(name);
+ binding = findTypeBinding(binding);
if (isValidTypeInput(binding)) {
- ICElement input= findDefinition(project, index, null, binding);
+ ICElement input = findDefinition(project, index, null, binding);
if (input != null) {
- return new ICElement[] {input, member};
+ return new ICElement[] { input, member };
}
}
}
- }
- finally {
+ } finally {
index.releaseReadLock();
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
CUIPlugin.log(e);
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
}
return null;
}
private static IBinding findTypeBinding(IBinding memberBinding) {
if (memberBinding instanceof IEnumerator) {
- IType type= ((IEnumerator) memberBinding).getType();
+ IType type = ((IEnumerator) memberBinding).getType();
if (type instanceof IBinding) {
return (IBinding) type;
}
@@ -227,26 +223,26 @@ public class TypeHierarchyUI {
return null;
}
- private static ICElement findDefinition(ICProject project, IIndex index, IASTName name, IBinding binding)
+ private static ICElement findDefinition(ICProject project, IIndex index, IASTName name, IBinding binding)
throws CoreException {
if (name != null && name.isDefinition()) {
return IndexUI.getCElementForName(project, index, name);
}
- ICElement[] elems= IndexUI.findAllDefinitions(index, binding);
+ ICElement[] elems = IndexUI.findAllDefinitions(index, binding);
if (elems.length > 0) {
return elems[0];
}
return IndexUI.findAnyDeclaration(index, project, binding);
}
- private static ICElement findDeclaration(ICProject project, IIndex index, IASTName name, IBinding binding)
+ private static ICElement findDeclaration(ICProject project, IIndex index, IASTName name, IBinding binding)
throws CoreException {
if (name != null && name.isDefinition()) {
return IndexUI.getCElementForName(project, index, name);
}
- ICElement[] elems= IndexUI.findAllDefinitions(index, binding);
+ ICElement[] elems = IndexUI.findAllDefinitions(index, binding);
if (elems.length > 0) {
return elems[0];
}
@@ -254,9 +250,7 @@ public class TypeHierarchyUI {
}
public static boolean isValidInput(IBinding binding) {
- if (isValidTypeInput(binding)
- || binding instanceof ICPPMember
- || binding instanceof IEnumerator
+ if (isValidTypeInput(binding) || binding instanceof ICPPMember || binding instanceof IEnumerator
|| binding instanceof IField) {
return true;
}
@@ -264,9 +258,7 @@ public class TypeHierarchyUI {
}
public static boolean isValidTypeInput(IBinding binding) {
- if (binding instanceof ICompositeType
- || binding instanceof IEnumeration
- || binding instanceof ITypedef) {
+ if (binding instanceof ICompositeType || binding instanceof IEnumeration || binding instanceof ITypedef) {
return true;
}
return false;
@@ -304,12 +296,12 @@ public class TypeHierarchyUI {
case ICElement.C_UNION_DECLARATION:
case ICElement.C_ENUMERATION:
case ICElement.C_TYPEDEF:
-// case ICElement.C_TEMPLATE_CLASS:
-// case ICElement.C_TEMPLATE_CLASS_DECLARATION:
-// case ICElement.C_TEMPLATE_STRUCT:
-// case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
-// case ICElement.C_TEMPLATE_UNION:
-// case ICElement.C_TEMPLATE_UNION_DECLARATION:
+ // case ICElement.C_TEMPLATE_CLASS:
+ // case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+ // case ICElement.C_TEMPLATE_STRUCT:
+ // case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+ // case ICElement.C_TEMPLATE_UNION:
+ // case ICElement.C_TEMPLATE_UNION_DECLARATION:
return true;
}
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java
index 0920956101c..5e9c9e953ed 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java
@@ -48,131 +48,129 @@ import org.eclipse.cdt.internal.core.AdapterUtil;
* Base class for command handlers operating on resources.
*/
public abstract class AbstractResourceActionHandler extends AbstractHandler {
- private IEvaluationContext evaluationContext;
- private IStructuredSelection selection;
-
- public void setSelection(ISelection selection) {
- this.selection = convertSelection(null, selection);
- }
-
- @Override
- public void setEnabled(Object evaluationContext) {
- this.evaluationContext = (IEvaluationContext) evaluationContext;
- selection = convertSelection(this.evaluationContext, null);
- }
-
- protected IStructuredSelection getSelection() {
- if (selection == null) {
- selection = convertSelection(evaluationContext, null);
- }
- return selection;
- }
-
- protected static IStructuredSelection getSelection(ExecutionEvent event) throws ExecutionException {
- Object selection = HandlerUtil.getActiveMenuSelection(event);
- if (selection == null) {
- selection = HandlerUtil.getCurrentSelectionChecked(event);
- }
- if (selection instanceof ITextSelection) {
- IEditorInput editorInput = HandlerUtil.getActiveEditorInputChecked(event);
- IResource resource = ResourceUtil.getResource(editorInput);
- if (resource != null) {
- return new StructuredSelection(resource);
- }
-
- resource = ResourceUtil.getFile(editorInput);
- if (resource != null) {
- return new StructuredSelection(resource);
- }
- }
- if (selection instanceof IStructuredSelection) {
- return (IStructuredSelection) selection;
- }
- return StructuredSelection.EMPTY;
- }
-
- private static IStructuredSelection convertSelection(IEvaluationContext context,
- Object selection) {
- if (selection == null) {
- if (context == null) {
- return StructuredSelection.EMPTY;
- }
- selection = context.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
- if (!(selection instanceof ISelection)) {
- selection = context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
- }
- }
- if (selection instanceof ITextSelection) {
- if (context == null) {
- context = getEvaluationContext();
- }
- IResource resource =
- ResourceUtil.getResource(context.getVariable(ISources.ACTIVE_EDITOR_INPUT_NAME));
- if (resource != null) {
- return new StructuredSelection(resource);
- }
- }
- if (selection instanceof IStructuredSelection) {
- return (IStructuredSelection) selection;
- }
- return StructuredSelection.EMPTY;
- }
-
- private static IEvaluationContext getEvaluationContext() {
- IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (activeWindow == null) {
- return null;
- }
- IHandlerService service = activeWindow.getService(IHandlerService.class);
- return service.getCurrentState();
- }
-
- /**
- * Returns the selected resources.
- */
- protected Collection<IResource> getSelectedResources() {
- return getSelectedResources(getSelection());
- }
-
- /**
- * Returns the selected resources.
- */
- protected static Collection<IResource> getSelectedResources(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection selection = getSelection(event);
- return getSelectedResources(selection);
- }
-
- private static Collection<IResource> getSelectedResources(IStructuredSelection selection) {
- Set<IResource> result = new LinkedHashSet<IResource>();
- for (Object obj : selection.toList()) {
- IResource resource = AdapterUtil.adapt(obj, IResource.class);
- if (resource != null) {
- result.add(resource);
- } else {
- result.addAll(extractResourcesFromMapping(obj));
- }
- }
- return result;
- }
-
- /**
- * Extracts resources associated with a {@link ResourceMapping}.
- *
- * @param obj an object adaptable to {@link ResourceMapping}
- * @return a list of resources associated with the mapping
- */
- private static List<IResource> extractResourcesFromMapping(Object obj) {
- ResourceMapping mapping = AdapterUtil.adapt(obj, ResourceMapping.class);
- if (mapping != null) {
- try {
- ResourceTraversal[] traversals = mapping.getTraversals(null, null);
- for (ResourceTraversal traversal : traversals) {
- return Arrays.asList(traversal.getResources());
- }
- } catch (CoreException e) {
- CUIPlugin.log(e);
- }
- }
- return Collections.emptyList();
- }
+ private IEvaluationContext evaluationContext;
+ private IStructuredSelection selection;
+
+ public void setSelection(ISelection selection) {
+ this.selection = convertSelection(null, selection);
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ this.evaluationContext = (IEvaluationContext) evaluationContext;
+ selection = convertSelection(this.evaluationContext, null);
+ }
+
+ protected IStructuredSelection getSelection() {
+ if (selection == null) {
+ selection = convertSelection(evaluationContext, null);
+ }
+ return selection;
+ }
+
+ protected static IStructuredSelection getSelection(ExecutionEvent event) throws ExecutionException {
+ Object selection = HandlerUtil.getActiveMenuSelection(event);
+ if (selection == null) {
+ selection = HandlerUtil.getCurrentSelectionChecked(event);
+ }
+ if (selection instanceof ITextSelection) {
+ IEditorInput editorInput = HandlerUtil.getActiveEditorInputChecked(event);
+ IResource resource = ResourceUtil.getResource(editorInput);
+ if (resource != null) {
+ return new StructuredSelection(resource);
+ }
+
+ resource = ResourceUtil.getFile(editorInput);
+ if (resource != null) {
+ return new StructuredSelection(resource);
+ }
+ }
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ private static IStructuredSelection convertSelection(IEvaluationContext context, Object selection) {
+ if (selection == null) {
+ if (context == null) {
+ return StructuredSelection.EMPTY;
+ }
+ selection = context.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
+ if (!(selection instanceof ISelection)) {
+ selection = context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
+ }
+ }
+ if (selection instanceof ITextSelection) {
+ if (context == null) {
+ context = getEvaluationContext();
+ }
+ IResource resource = ResourceUtil.getResource(context.getVariable(ISources.ACTIVE_EDITOR_INPUT_NAME));
+ if (resource != null) {
+ return new StructuredSelection(resource);
+ }
+ }
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ private static IEvaluationContext getEvaluationContext() {
+ IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (activeWindow == null) {
+ return null;
+ }
+ IHandlerService service = activeWindow.getService(IHandlerService.class);
+ return service.getCurrentState();
+ }
+
+ /**
+ * Returns the selected resources.
+ */
+ protected Collection<IResource> getSelectedResources() {
+ return getSelectedResources(getSelection());
+ }
+
+ /**
+ * Returns the selected resources.
+ */
+ protected static Collection<IResource> getSelectedResources(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = getSelection(event);
+ return getSelectedResources(selection);
+ }
+
+ private static Collection<IResource> getSelectedResources(IStructuredSelection selection) {
+ Set<IResource> result = new LinkedHashSet<IResource>();
+ for (Object obj : selection.toList()) {
+ IResource resource = AdapterUtil.adapt(obj, IResource.class);
+ if (resource != null) {
+ result.add(resource);
+ } else {
+ result.addAll(extractResourcesFromMapping(obj));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Extracts resources associated with a {@link ResourceMapping}.
+ *
+ * @param obj an object adaptable to {@link ResourceMapping}
+ * @return a list of resources associated with the mapping
+ */
+ private static List<IResource> extractResourcesFromMapping(Object obj) {
+ ResourceMapping mapping = AdapterUtil.adapt(obj, ResourceMapping.class);
+ if (mapping != null) {
+ try {
+ ResourceTraversal[] traversals = mapping.getTraversals(null, null);
+ for (ResourceTraversal traversal : traversals) {
+ return Arrays.asList(traversal.getResources());
+ }
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ return Collections.emptyList();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.java
index 9ee552b9805..5333d859e4a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.java
@@ -34,35 +34,38 @@ import org.eclipse.jface.operation.ModalContext;
public class BusyIndicatorRunnableContext implements IRunnableContext {
private static class BusyRunnable implements Runnable {
-
+
private static class ThreadContext extends Thread {
IRunnableWithProgress fRunnable;
Throwable fThrowable;
-
+
public ThreadContext(IRunnableWithProgress runnable) {
this(runnable, "BusyCursorRunnableContext-Thread"); //$NON-NLS-1$
- }
+ }
+
protected ThreadContext(IRunnableWithProgress runnable, String name) {
super(name);
- fRunnable= runnable;
+ fRunnable = runnable;
}
+
@Override
public void run() {
try {
fRunnable.run(new NullProgressMonitor());
} catch (InvocationTargetException e) {
- fThrowable= e;
+ fThrowable = e;
} catch (InterruptedException e) {
- fThrowable= e;
+ fThrowable = e;
} catch (ThreadDeath e) {
- fThrowable= e;
+ fThrowable = e;
throw e;
} catch (RuntimeException e) {
- fThrowable= e;
+ fThrowable = e;
} catch (Error e) {
- fThrowable= e;
+ fThrowable = e;
}
}
+
void sync() {
try {
join();
@@ -71,37 +74,41 @@ public class BusyIndicatorRunnableContext implements IRunnableContext {
}
}
}
-
+
public Throwable fThrowable;
private boolean fFork;
private IRunnableWithProgress fRunnable;
+
public BusyRunnable(boolean fork, IRunnableWithProgress runnable) {
- fFork= fork;
- fRunnable= runnable;
+ fFork = fork;
+ fRunnable = runnable;
}
+
@Override
public void run() {
try {
internalRun(fFork, fRunnable);
} catch (InvocationTargetException e) {
- fThrowable= e;
+ fThrowable = e;
} catch (InterruptedException e) {
- fThrowable= e;
+ fThrowable = e;
}
}
- private void internalRun(boolean fork, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
- Thread thread= Thread.currentThread();
+
+ private void internalRun(boolean fork, final IRunnableWithProgress runnable)
+ throws InvocationTargetException, InterruptedException {
+ Thread thread = Thread.currentThread();
// Do not spawn another thread if we are already in a modal context
// thread or inside a busy context thread.
if (thread instanceof ThreadContext || ModalContext.isModalContextThread(thread))
- fork= false;
-
+ fork = false;
+
if (fork) {
- final ThreadContext t= new ThreadContext(runnable);
+ final ThreadContext t = new ThreadContext(runnable);
t.start();
t.sync();
// Check if the separate thread was terminated by an exception
- Throwable throwable= t.fThrowable;
+ Throwable throwable = t.fThrowable;
if (throwable != null) {
if (throwable instanceof InvocationTargetException) {
throw (InvocationTargetException) throwable;
@@ -118,7 +125,7 @@ public class BusyIndicatorRunnableContext implements IRunnableContext {
runnable.run(new NullProgressMonitor());
} catch (OperationCanceledException e) {
throw new InterruptedException();
- }
+ }
}
}
}
@@ -127,14 +134,15 @@ public class BusyIndicatorRunnableContext implements IRunnableContext {
* Method declared on IRunnableContext.
*/
@Override
- public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
- BusyRunnable busyRunnable= new BusyRunnable(fork, runnable);
+ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
+ throws InvocationTargetException, InterruptedException {
+ BusyRunnable busyRunnable = new BusyRunnable(fork, runnable);
BusyIndicator.showWhile(null, busyRunnable);
- Throwable throwable= busyRunnable.fThrowable;
+ Throwable throwable = busyRunnable.fThrowable;
if (throwable instanceof InvocationTargetException) {
- throw (InvocationTargetException)throwable;
+ throw (InvocationTargetException) throwable;
} else if (throwable instanceof InterruptedException) {
- throw (InterruptedException)throwable;
+ throw (InterruptedException) throwable;
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java
index 26d43f2afb2..705d8707962 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
**********************************************************************/
@@ -39,42 +39,41 @@ import org.eclipse.cdt.internal.ui.CHelpProviderManager;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
/**
- *
+ *
* @since 2.1
*/
public class CHelpDisplayContext implements IContext {
-
+
private IHelpResource[] fHelpResources;
private String fText;
-
+
public static void displayHelp(String contextId, ITextEditor editor) throws CoreException {
String selected = getSelectedString(editor);
- IContext context= HelpSystem.getContext(contextId);
+ IContext context = HelpSystem.getContext(contextId);
if (context != null) {
if (selected != null && selected.length() > 0) {
- context= new CHelpDisplayContext(context, editor, selected);
+ context = new CHelpDisplayContext(context, editor, selected);
}
PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
}
}
-
- private static String getSelectedString(ITextEditor editor){
+
+ private static String getSelectedString(ITextEditor editor) {
String expression = null;
- try{
- ITextSelection selection = (ITextSelection)editor.getSite().getSelectionProvider().getSelection();
+ try {
+ ITextSelection selection = (ITextSelection) editor.getSite().getSelectionProvider().getSelection();
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
IRegion region = CWordFinder.findWord(document, selection.getOffset());
expression = document.get(region.getOffset(), region.getLength());
- }
- catch(Exception e){
+ } catch (Exception e) {
}
return expression;
}
- public CHelpDisplayContext(IContext context, final ITextEditor editor , String selected) throws CoreException {
+ public CHelpDisplayContext(IContext context, final ITextEditor editor, String selected) throws CoreException {
+
+ List<IHelpResource> helpResources = new ArrayList<IHelpResource>();
- List<IHelpResource> helpResources= new ArrayList<IHelpResource>();
-
ICHelpInvocationContext invocationContext = new ICHelpInvocationContext() {
@Override
@@ -88,33 +87,34 @@ public class CHelpDisplayContext implements IContext {
@Override
public ITranslationUnit getTranslationUnit() {
- IEditorInput editorInput= editor.getEditorInput();
+ IEditorInput editorInput = editor.getEditorInput();
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
- }
+ }
};
if (context != null) {
- IHelpResource[] resources= context.getRelatedTopics();
- if (resources != null){
+ IHelpResource[] resources = context.getRelatedTopics();
+ if (resources != null) {
helpResources.addAll(Arrays.asList(resources));
}
}
- ICHelpResourceDescriptor providerResources[] = CHelpProviderManager.getDefault().getHelpResources(invocationContext,selected);
- if(providerResources != null){
- for(int i = 0; i < providerResources.length; i++){
+ ICHelpResourceDescriptor providerResources[] = CHelpProviderManager.getDefault()
+ .getHelpResources(invocationContext, selected);
+ if (providerResources != null) {
+ for (int i = 0; i < providerResources.length; i++) {
helpResources.addAll(Arrays.asList(providerResources[i].getHelpResources()));
}
}
- fHelpResources= helpResources.toArray(new IHelpResource[helpResources.size()]);
+ fHelpResources = helpResources.toArray(new IHelpResource[helpResources.size()]);
if (fText == null || fText.length() == 0) {
if (context != null) {
- fText= context.getText();
+ fText = context.getText();
}
}
if (fText != null && fText.length() == 0) {
- fText= null;
+ fText = null;
}
}
@@ -128,4 +128,3 @@ public class CHelpDisplayContext implements IContext {
return fText;
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java
index ee8deff0ac1..5004d6d5fb7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
**********************************************************************/
@@ -33,13 +33,13 @@ import org.eclipse.swt.events.HelpListener;
import org.eclipse.ui.texteditor.ITextEditor;
/**
- *
+ *
* @since 2.1
*/
public class CUIHelp {
public static void setHelp(CEditor editor, StyledText text, String contextId) {
- CUIHelpListener listener= new CUIHelpListener(editor, contextId);
+ CUIHelpListener listener = new CUIHelpListener(editor, contextId);
text.addHelpListener(listener);
}
@@ -49,13 +49,13 @@ public class CUIHelp {
private CEditor fEditor;
public CUIHelpListener(CEditor editor, String contextId) {
- fContextId= contextId;
- fEditor= editor;
+ fContextId = contextId;
+ fEditor = editor;
}
/*
* @see HelpListener#helpRequested(HelpEvent)
- *
+ *
*/
@Override
public void helpRequested(HelpEvent e) {
@@ -69,7 +69,7 @@ public class CUIHelp {
/**
* A dynamic help context provider.
- *
+ *
* @since 4.0
*/
public static final class CUIHelpContextProvider implements IContextProvider {
@@ -81,7 +81,7 @@ public class CUIHelp {
* @param editor
*/
public CUIHelpContextProvider(ITextEditor editor) {
- fEditor= editor;
+ fEditor = editor;
}
/*
@@ -90,18 +90,18 @@ public class CUIHelp {
@Override
public IContext getContext(Object target) {
String selected = getSelectedString(fEditor);
- IContext context= HelpSystem.getContext(ICHelpContextIds.CEDITOR_VIEW);
+ IContext context = HelpSystem.getContext(ICHelpContextIds.CEDITOR_VIEW);
if (context != null) {
if (selected != null && selected.length() > 0) {
try {
- context= new CHelpDisplayContext(context, fEditor, selected);
+ context = new CHelpDisplayContext(context, fEditor, selected);
} catch (CoreException exc) {
}
}
}
return context;
}
-
+
/*
* @see org.eclipse.help.IContextProvider#getContextChangeMask()
*/
@@ -109,7 +109,7 @@ public class CUIHelp {
public int getContextChangeMask() {
return SELECTION;
}
-
+
/*
* @see org.eclipse.help.IContextProvider#getSearchExpression(java.lang.Object)
*/
@@ -117,21 +117,20 @@ public class CUIHelp {
public String getSearchExpression(Object target) {
return getSelectedString(fEditor);
}
-
- private static String getSelectedString(ITextEditor editor){
+
+ private static String getSelectedString(ITextEditor editor) {
String expression = null;
- try{
- ITextSelection selection = (ITextSelection)editor.getSite().getSelectionProvider().getSelection();
+ try {
+ ITextSelection selection = (ITextSelection) editor.getSite().getSelectionProvider().getSelection();
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
IRegion region = CWordFinder.findWord(document, selection.getOffset());
if (region != null)
expression = document.get(region.getOffset(), region.getLength());
- }
- catch(Exception e){
+ } catch (Exception e) {
}
return expression;
}
-
+
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java
index d340ffdd29b..b3affe73eb1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java
@@ -30,16 +30,17 @@ public class CoreUtility {
* {@link org.eclipse.ui.dialogs.ContainerGenerator} is too heavy
* (creates a runnable)
*/
- public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
+ public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor)
+ throws CoreException {
if (!folder.exists()) {
- IContainer parent= folder.getParent();
+ IContainer parent = folder.getParent();
if (parent instanceof IFolder) {
createFolder((IFolder) parent, force, local, null);
}
folder.create(force, local, monitor);
}
}
-
+
/**
* Creates an extension. If the extension plugin has not been loaded,
* a busy cursor will be activated during the duration of the load.
@@ -48,12 +49,13 @@ public class CoreUtility {
* @param classAttribute the name of the attribute carrying the class
* @return the extension object
*/
- public static Object createExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
+ public static Object createExtension(final IConfigurationElement element, final String classAttribute)
+ throws CoreException {
// If plugin has been loaded, create extension.
// Otherwise, show busy cursor then create extension.
- String id= element.getContributor().getName();
+ String id = element.getContributor().getName();
Bundle bundle = Platform.getBundle(id);
- if(bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
+ if (bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
return element.createExecutableExtension(classAttribute);
}
final Object[] ret = new Object[1];
@@ -72,5 +74,4 @@ public class CoreUtility {
throw exc[0];
return ret[0];
}
-}
-
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java
index f997aa3eb92..6a5cfba29f2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java
@@ -34,7 +34,7 @@ import org.eclipse.cdt.core.model.ICModelMarker;
*/
public class DeleteIProblemMarkerAction extends ActionDelegate implements IObjectActionDelegate {
- private IStructuredSelection selection;
+ private IStructuredSelection selection;
/**
* @see ActionDelegate#run(IAction)
@@ -51,7 +51,7 @@ public class DeleteIProblemMarkerAction extends ActionDelegate implements IObjec
List<IMarker> listMarkers = new ArrayList<IMarker>();
Iterator<?> iterator = list.iterator();
while (iterator.hasNext()) {
- IMarker marker = (IMarker)iterator.next();
+ IMarker marker = (IMarker) iterator.next();
if (marker.isSubtypeOf(ICModelMarker.INDEXER_MARKER)) {
listMarkers.add(marker);
}
@@ -86,9 +86,9 @@ public class DeleteIProblemMarkerAction extends ActionDelegate implements IObjec
try {
IMarker marker = (IMarker) object;
if (marker.isSubtypeOf(ICModelMarker.INDEXER_MARKER)) {
- enable = true;
+ enable = true;
}
- this.selection = (IStructuredSelection)selection;
+ this.selection = (IStructuredSelection) selection;
action.setEnabled(enable);
} catch (CoreException e) {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java
index 84849b7ae74..a43bb3ecfe1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.util;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -30,9 +29,8 @@ import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.cdt.core.model.ICModelMarker;
-public class DeleteTaskAction extends ActionDelegate implements IObjectActionDelegate
-{
- private IStructuredSelection selection;
+public class DeleteTaskAction extends ActionDelegate implements IObjectActionDelegate {
+ private IStructuredSelection selection;
/**
* @see ActionDelegate#run(IAction)
@@ -49,9 +47,9 @@ public class DeleteTaskAction extends ActionDelegate implements IObjectActionDel
List<IMarker> listMarkers = new ArrayList<IMarker>();
Iterator<?> iterator = list.iterator();
while (iterator.hasNext()) {
- IMarker marker = (IMarker)iterator.next();
+ IMarker marker = (IMarker) iterator.next();
if (marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)
- || marker.isSubtypeOf(ICModelMarker.C_MODEL_MARKER_VARIABLE)) {
+ || marker.isSubtypeOf(ICModelMarker.C_MODEL_MARKER_VARIABLE)) {
listMarkers.add(marker);
}
}
@@ -85,10 +83,10 @@ public class DeleteTaskAction extends ActionDelegate implements IObjectActionDel
try {
IMarker marker = (IMarker) object;
if (marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)
- || marker.isSubtypeOf(ICModelMarker.C_MODEL_MARKER_VARIABLE)) {
- enable = true;
+ || marker.isSubtypeOf(ICModelMarker.C_MODEL_MARKER_VARIABLE)) {
+ enable = true;
}
- this.selection = (IStructuredSelection)selection;
+ this.selection = (IStructuredSelection) selection;
action.setEnabled(enable);
} catch (CoreException e) {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
index 65e8eb45acf..28d1f52a9e5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
@@ -114,7 +114,7 @@ public class EditorUtility {
*/
public static final String DEFAULT_TEXT_EDITOR_ID = EditorsUI.DEFAULT_TEXT_EDITOR_ID;
- private EditorUtility () {
+ private EditorUtility() {
}
/**
@@ -131,7 +131,7 @@ public class EditorUtility {
}
if (input != null) {
- IWorkbenchPage p= CUIPlugin.getActivePage();
+ IWorkbenchPage p = CUIPlugin.getActivePage();
if (p != null) {
return p.findEditor(input);
}
@@ -180,9 +180,9 @@ public class EditorUtility {
((CEditor) part).setSelection(element);
} else if (part instanceof ITextEditor) {
if (element instanceof ISourceReference && !(element instanceof ITranslationUnit)) {
- ISourceReference reference= (ISourceReference) element;
+ ISourceReference reference = (ISourceReference) element;
try {
- ISourceRange range= reference.getSourceRange();
+ ISourceRange range = reference.getSourceRange();
((ITextEditor) part).selectAndReveal(range.getIdStartPos(), range.getIdLength());
} catch (CModelException exc) {
CUIPlugin.log(exc.getStatus());
@@ -257,16 +257,17 @@ public class EditorUtility {
private static void closedProject(IProject project) {
MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
errorMsg.setText(CUIPlugin.getResourceString("EditorUtility.closedproject")); //$NON-NLS-1$
- String desc= CUIPlugin.getResourceString("Editorutility.closedproject.description"); //$NON-NLS-1$
+ String desc = CUIPlugin.getResourceString("Editorutility.closedproject.description"); //$NON-NLS-1$
errorMsg.setMessage(MessageFormat.format(desc, new Object[] { project.getName() }));
errorMsg.open();
}
- private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
+ private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate)
+ throws PartInitException {
if (input != null) {
- IWorkbenchPage p= CUIPlugin.getActivePage();
+ IWorkbenchPage p = CUIPlugin.getActivePage();
if (p != null) {
- IEditorPart editorPart= p.openEditor(input, editorID, activate);
+ IEditorPart editorPart = p.openEditor(input, editorID, activate);
return editorPart;
}
}
@@ -275,18 +276,18 @@ public class EditorUtility {
private static IEditorInput getEditorInput(ICElement element) throws CModelException {
while (element != null) {
- if (element instanceof ISourceReference) {
- ITranslationUnit tu = ((ISourceReference) element).getTranslationUnit();
- if (tu != null) {
- element = tu;
- }
- }
+ if (element instanceof ISourceReference) {
+ ITranslationUnit tu = ((ISourceReference) element).getTranslationUnit();
+ if (tu != null) {
+ element = tu;
+ }
+ }
if (element instanceof IWorkingCopy && ((IWorkingCopy) element).isWorkingCopy())
- element= ((IWorkingCopy) element).getOriginalElement();
+ element = ((IWorkingCopy) element).getOriginalElement();
if (element instanceof ITranslationUnit) {
- ITranslationUnit unit= (ITranslationUnit) element;
- IResource resource= unit.getResource();
+ ITranslationUnit unit = (ITranslationUnit) element;
+ IResource resource = unit.getResource();
if (resource instanceof IFile) {
return new FileEditorInput((IFile) resource);
}
@@ -294,13 +295,13 @@ public class EditorUtility {
}
if (element instanceof IBinary) {
- IResource resource= element.getResource();
+ IResource resource = element.getResource();
if (resource instanceof IFile) {
return new FileEditorInput((IFile) resource);
}
}
- element= element.getParent();
+ element = element.getParent();
}
return null;
@@ -314,7 +315,7 @@ public class EditorUtility {
return new FileEditorInput((IFile) input);
}
if (input instanceof IStorage) {
- final IPath location= ((IStorage)input).getFullPath();
+ final IPath location = ((IStorage) input).getFullPath();
if (location != null) {
return new ExternalEditorInput(location);
}
@@ -335,13 +336,14 @@ public class EditorUtility {
return openInEditor(location, element, true);
}
- public static IEditorPart openInEditor(IPath location, ICElement element, boolean activate) throws PartInitException {
- IEditorInput input= getEditorInputForLocation(location, element);
+ public static IEditorPart openInEditor(IPath location, ICElement element, boolean activate)
+ throws PartInitException {
+ IEditorInput input = getEditorInputForLocation(location, element);
return EditorUtility.openInEditor(input, getEditorID(input, element), activate);
}
public static IEditorPart openInEditor(URI locationURI, ICElement element) throws PartInitException {
- IEditorInput input= getEditorInputForLocation(locationURI, element);
+ IEditorInput input = getEditorInputForLocation(locationURI, element);
return EditorUtility.openInEditor(input, getEditorID(input, element), true);
}
@@ -358,7 +360,7 @@ public class EditorUtility {
* @return an editor input
*/
public static IEditorInput getEditorInputForLocation(URI locationURI, ICElement context) {
- IFile resource= getWorkspaceFileAtLocation(locationURI, context);
+ IFile resource = getWorkspaceFileAtLocation(locationURI, context);
if (resource != null) {
return new FileEditorInput(resource);
}
@@ -386,7 +388,7 @@ public class EditorUtility {
}
if (context == null && projects.length > 0) {
// last resort: just take any of them
- context= projects[0];
+ context = projects[0];
}
} catch (CModelException e) {
}
@@ -394,7 +396,7 @@ public class EditorUtility {
if (context != null) {
// try to get a translation unit from the location and associated element
- ICProject cproject= context.getCProject();
+ ICProject cproject = context.getCProject();
if (cproject != null) {
ITranslationUnit unit = CoreModel.getDefault().createTranslationUnitFrom(cproject, locationURI);
if (unit != null) {
@@ -412,7 +414,7 @@ public class EditorUtility {
}
// no translation unit - still try to get a sensible marker resource
// from the associated element
- IResource markerResource= cproject.getProject();
+ IResource markerResource = cproject.getProject();
return new ExternalEditorInput(locationURI, markerResource);
}
}
@@ -420,7 +422,7 @@ public class EditorUtility {
}
public static IEditorInput getEditorInputForLocation(IPath location, ICElement context) {
- IFile resource= getWorkspaceFileAtLocation(location, context);
+ IFile resource = getWorkspaceFileAtLocation(location, context);
if (resource != null) {
return new FileEditorInput(resource);
}
@@ -444,7 +446,7 @@ public class EditorUtility {
}
if (context == null && projects.length > 0) {
// last resort: just take any of them
- context= projects[0];
+ context = projects[0];
}
} catch (CModelException e) {
}
@@ -452,7 +454,7 @@ public class EditorUtility {
if (context != null) {
// try to get a translation unit from the location and associated element
- ICProject cproject= context.getCProject();
+ ICProject cproject = context.getCProject();
if (cproject != null) {
ITranslationUnit unit = CoreModel.getDefault().createTranslationUnitFrom(cproject, location);
if (unit != null) {
@@ -460,7 +462,7 @@ public class EditorUtility {
}
// no translation unit - still try to get a sensible marker resource
// from the associated element
- IResource markerResource= cproject.getProject();
+ IResource markerResource = cproject.getProject();
return new ExternalEditorInput(location, markerResource);
}
}
@@ -477,27 +479,27 @@ public class EditorUtility {
* @return an {@code IFile} or {@code null}
*/
public static IFile getWorkspaceFileAtLocation(IPath location, ICElement context) {
- IProject project= null;
+ IProject project = null;
if (context != null) {
- ICProject cProject= context.getCProject();
+ ICProject cProject = context.getCProject();
if (cProject != null) {
- project= cProject.getProject();
+ project = cProject.getProject();
}
}
- IFile file= ResourceLookup.selectFileForLocation(location, project);
+ IFile file = ResourceLookup.selectFileForLocation(location, project);
if (file != null && file.isAccessible())
return file;
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
// workaround http://bugs.eclipse.org/233939
- file= root.getFileForLocation(location);
+ file = root.getFileForLocation(location);
if (file != null && file.isAccessible())
return file;
// try workspace relative path
if (location.segmentCount() >= 2) {
// @see IContainer#getFile for the required number of segments
- file= root.getFile(location);
+ file = root.getFile(location);
if (file != null && file.isAccessible())
return file;
}
@@ -514,15 +516,15 @@ public class EditorUtility {
* @return an {@code IFile} or {@code null}
*/
public static IFile getWorkspaceFileAtLocation(URI locationURI, ICElement context) {
- IProject project= null;
+ IProject project = null;
if (context != null) {
- ICProject cProject= context.getCProject();
+ ICProject cProject = context.getCProject();
if (cProject != null) {
- project= cProject.getProject();
+ project = cProject.getProject();
}
}
- IFile file= ResourceLookup.selectFileForLocationURI(locationURI, project);
+ IFile file = ResourceLookup.selectFileForLocationURI(locationURI, project);
if (file != null && file.isAccessible())
return file;
@@ -534,9 +536,9 @@ public class EditorUtility {
* return null
*/
public static ICElement getActiveEditorCInput() {
- IWorkbenchPage page= CUIPlugin.getActivePage();
+ IWorkbenchPage page = CUIPlugin.getActivePage();
if (page != null) {
- IEditorPart part= page.getActiveEditor();
+ IEditorPart part = page.getActiveEditor();
if (part != null) {
return getEditorInputCElement(part);
}
@@ -545,7 +547,7 @@ public class EditorUtility {
}
public static ICElement getEditorInputCElement(IEditorPart part) {
- IEditorInput editorInput= part.getEditorInput();
+ IEditorInput editorInput = part.getEditorInput();
if (editorInput == null) {
return null;
}
@@ -598,9 +600,9 @@ public class EditorUtility {
* @return a valid editor id, never {@code null}
*/
public static String getEditorID(IEditorInput input, Object inputObject) {
- ICElement cElement= null;
+ ICElement cElement = null;
if (input instanceof IFileEditorInput) {
- IFileEditorInput editorInput = (IFileEditorInput)input;
+ IFileEditorInput editorInput = (IFileEditorInput) input;
IFile file = editorInput.getFile();
// Try file specific editor.
try {
@@ -617,45 +619,45 @@ public class EditorUtility {
}
cElement = CoreModel.getDefault().create(file);
} else if (input instanceof ITranslationUnitEditorInput) {
- ITranslationUnitEditorInput editorInput = (ITranslationUnitEditorInput)input;
+ ITranslationUnitEditorInput editorInput = (ITranslationUnitEditorInput) input;
cElement = editorInput.getTranslationUnit();
} else if (inputObject instanceof ICElement) {
- cElement= (ICElement)inputObject;
+ cElement = (ICElement) inputObject;
}
// Choose an editor based on the content type
- IContentType contentType= null;
+ IContentType contentType = null;
if (cElement instanceof ITranslationUnit) {
- String contentTypeId= ((ITranslationUnit)cElement).getContentTypeId();
+ String contentTypeId = ((ITranslationUnit) cElement).getContentTypeId();
if (contentTypeId != null) {
- contentType= Platform.getContentTypeManager().getContentType(contentTypeId);
+ contentType = Platform.getContentTypeManager().getContentType(contentTypeId);
}
}
if (contentType == null) {
- IProject project= null;
+ IProject project = null;
if (cElement != null) {
- project= cElement.getCProject().getProject();
+ project = cElement.getCProject().getProject();
} else {
- IFile file= ResourceUtil.getFile(input);
+ IFile file = ResourceUtil.getFile(input);
if (file != null) {
- project= file.getProject();
+ project = file.getProject();
}
}
- contentType= CCorePlugin.getContentType(project, input.getName());
+ contentType = CCorePlugin.getContentType(project, input.getName());
}
// handle binary files without content-type (e.g. executables without extension)
if (contentType == null && cElement != null) {
- final int elementType= cElement.getElementType();
+ final int elementType = cElement.getElementType();
if (elementType == ICElement.C_ARCHIVE || elementType == ICElement.C_BINARY) {
- contentType= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
+ contentType = Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
}
}
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType);
+ IEditorDescriptor desc = registry.getDefaultEditor(input.getName(), contentType);
if (desc != null) {
- String editorID= desc.getId();
+ String editorID = desc.getId();
if (input instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)input).getFile();
+ IFile file = ((IFileEditorInput) input).getFile();
IDE.setDefaultEditor(file, editorID);
}
return editorID;
@@ -695,15 +697,15 @@ public class EditorUtility {
* @since 2.1.1
*/
public static String getModifierString(int stateMask) {
- String modifierString= ""; //$NON-NLS-1$
+ String modifierString = ""; //$NON-NLS-1$
if ((stateMask & SWT.CTRL) == SWT.CTRL)
- modifierString= appendModifierString(modifierString, SWT.CTRL);
+ modifierString = appendModifierString(modifierString, SWT.CTRL);
if ((stateMask & SWT.ALT) == SWT.ALT)
- modifierString= appendModifierString(modifierString, SWT.ALT);
+ modifierString = appendModifierString(modifierString, SWT.ALT);
if ((stateMask & SWT.SHIFT) == SWT.SHIFT)
- modifierString= appendModifierString(modifierString, SWT.SHIFT);
+ modifierString = appendModifierString(modifierString, SWT.SHIFT);
if ((stateMask & SWT.COMMAND) == SWT.COMMAND)
- modifierString= appendModifierString(modifierString, SWT.COMMAND);
+ modifierString = appendModifierString(modifierString, SWT.COMMAND);
return modifierString;
}
@@ -719,11 +721,12 @@ public class EditorUtility {
*/
private static String appendModifierString(String modifierString, int modifier) {
if (modifierString == null)
- modifierString= ""; //$NON-NLS-1$
- String newModifierString= Action.findModifierString(modifier);
+ modifierString = ""; //$NON-NLS-1$
+ String newModifierString = Action.findModifierString(modifier);
if (modifierString.length() == 0)
return newModifierString;
- return NLS.bind(CEditorMessages.EditorUtility_concatModifierStrings, new String[] {modifierString, newModifierString});
+ return NLS.bind(CEditorMessages.EditorUtility_concatModifierStrings,
+ new String[] { modifierString, newModifierString });
}
public static IStorage getStorage(IBinary bin) {
@@ -731,7 +734,7 @@ public class EditorUtility {
try {
IBuffer buffer = bin.getBuffer();
if (buffer != null) {
- store = new FileStorage (new ByteArrayInputStream(buffer.getContents().getBytes()), bin.getPath());
+ store = new FileStorage(new ByteArrayInputStream(buffer.getContents().getBytes()), bin.getPath());
}
} catch (CModelException e) {
// nothing;
@@ -749,22 +752,22 @@ public class EditorUtility {
* @since 5.0
*/
public static ICProject getCProject(IEditorInput input) {
- ICProject cProject= null;
+ ICProject cProject = null;
if (input instanceof IFileEditorInput) {
- IProject project= ((IFileEditorInput) input).getFile().getProject();
+ IProject project = ((IFileEditorInput) input).getFile().getProject();
if (project != null) {
- cProject= CoreModel.getDefault().create(project);
+ cProject = CoreModel.getDefault().create(project);
if (!cProject.exists())
- cProject= null;
+ cProject = null;
}
} else if (input instanceof ITranslationUnitEditorInput) {
- final ITranslationUnit tu= ((ITranslationUnitEditorInput) input).getTranslationUnit();
+ final ITranslationUnit tu = ((ITranslationUnitEditorInput) input).getTranslationUnit();
if (tu != null) {
- cProject= tu.getCProject();
+ cProject = tu.getCProject();
} else if (input instanceof ExternalEditorInput) {
- IResource resource= ((ExternalEditorInput) input).getMarkerResource();
+ IResource resource = ((ExternalEditorInput) input).getMarkerResource();
if (resource instanceof IProject) {
- cProject= CoreModel.getDefault().create((IProject) resource);
+ cProject = CoreModel.getDefault().create((IProject) resource);
}
}
}
@@ -781,16 +784,16 @@ public class EditorUtility {
* @since 5.3
*/
public static IEditorPart[] getDirtyEditors(boolean skipNonResourceEditors) {
- Set<IEditorInput> inputs= new HashSet<>();
- List<IEditorPart> result= new ArrayList<>();
- IWorkbench workbench= PlatformUI.getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
+ Set<IEditorInput> inputs = new HashSet<>();
+ List<IEditorPart> result = new ArrayList<>();
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
for (IWorkbenchWindow window : windows) {
- IWorkbenchPage[] pages= window.getPages();
+ IWorkbenchPage[] pages = window.getPages();
for (IWorkbenchPage page : pages) {
- IEditorPart[] editors= page.getDirtyEditors();
+ IEditorPart[] editors = page.getDirtyEditors();
for (IEditorPart ep : editors) {
- IEditorInput input= ep.getEditorInput();
+ IEditorInput input = ep.getEditorInput();
if (inputs.add(input)) {
if (!skipNonResourceEditors || isResourceEditorInput(input)) {
result.add(ep);
@@ -804,7 +807,7 @@ public class EditorUtility {
private static boolean isResourceEditorInput(IEditorInput input) {
if (input instanceof MultiEditorInput) {
- IEditorInput[] inputs= ((MultiEditorInput) input).getInput();
+ IEditorInput[] inputs = ((MultiEditorInput) input).getInput();
for (IEditorInput input2 : inputs) {
if (input2.getAdapter(IResource.class) != null) {
return true;
@@ -825,17 +828,17 @@ public class EditorUtility {
* @since 5.3
*/
public static IEditorPart[] getDirtyEditorsToSave(boolean saveUnknownEditors) {
- Set<IEditorInput> inputs= new HashSet<>();
- List<IEditorPart> result= new ArrayList<>();
- IWorkbench workbench= PlatformUI.getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
+ Set<IEditorInput> inputs = new HashSet<>();
+ List<IEditorPart> result = new ArrayList<>();
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
for (IWorkbenchWindow window : windows) {
- IWorkbenchPage[] pages= window.getPages();
+ IWorkbenchPage[] pages = window.getPages();
for (IWorkbenchPage page : pages) {
- IEditorPart[] editors= page.getDirtyEditors();
+ IEditorPart[] editors = page.getDirtyEditors();
for (IEditorPart editor : editors) {
- IEditorPart ep= editor;
- IEditorInput input= ep.getEditorInput();
+ IEditorPart ep = editor;
+ IEditorInput input = ep.getEditorInput();
if (!mustSaveDirtyEditor(ep, input, saveUnknownEditors))
continue;
@@ -858,13 +861,13 @@ public class EditorUtility {
* If {@code saveUnknownEditors} is {@code true}, save all editors
* whose implementation is probably not based on file buffers.
*/
- IResource resource= input.getAdapter(IResource.class);
+ IResource resource = input.getAdapter(IResource.class);
if (resource == null)
return saveUnknownEditors;
- ICElement element= CCorePlugin.getDefault().getCoreModel().create(resource);
+ ICElement element = CCorePlugin.getDefault().getCoreModel().create(resource);
if (element instanceof ITranslationUnit) {
- ITranslationUnit tu= (ITranslationUnit) element;
+ ITranslationUnit tu = (ITranslationUnit) element;
if (getWorkingCopy(tu) == null) {
return true;
}
@@ -874,7 +877,7 @@ public class EditorUtility {
if (textEditor == null)
return saveUnknownEditors;
- IDocumentProvider documentProvider= textEditor.getDocumentProvider();
+ IDocumentProvider documentProvider = textEditor.getDocumentProvider();
if (!(documentProvider instanceof TextFileDocumentProvider))
return saveUnknownEditors;
@@ -893,10 +896,10 @@ public class EditorUtility {
* @throws CoreException
* @since 5.1
*/
- public static IRegion[] calculateChangedLineRegions(final ITextFileBuffer buffer,
- final IProgressMonitor monitor) throws CoreException {
- final IRegion[][] result= new IRegion[1][];
- final IStatus[] errorStatus= new IStatus[] { Status.OK_STATUS };
+ public static IRegion[] calculateChangedLineRegions(final ITextFileBuffer buffer, final IProgressMonitor monitor)
+ throws CoreException {
+ final IRegion[][] result = new IRegion[1][];
+ final IStatus[] errorStatus = new IStatus[] { Status.OK_STATUS };
try {
SafeRunner.run(new ISafeRunnable() {
@@ -905,26 +908,26 @@ public class EditorUtility {
CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
ICStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, exception.getLocalizedMessage(),
exception));
- String msg= Messages.EditorUtility_error_calculatingChangedRegions;
- errorStatus[0]= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+ String msg = Messages.EditorUtility_error_calculatingChangedRegions;
+ errorStatus[0] = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
ICStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, msg, exception);
- result[0]= null;
+ result[0] = null;
}
@Override
public void run() throws Exception {
- SubMonitor progress =
- SubMonitor.convert(monitor, Messages.EditorUtility_calculatingChangedRegions_message, 4);
- IFileStore fileStore= buffer.getFileStore();
+ SubMonitor progress = SubMonitor.convert(monitor,
+ Messages.EditorUtility_calculatingChangedRegions_message, 4);
+ IFileStore fileStore = buffer.getFileStore();
- ITextFileBufferManager fileBufferManager= FileBuffers.createTextFileBufferManager();
+ ITextFileBufferManager fileBufferManager = FileBuffers.createTextFileBufferManager();
fileBufferManager.connectFileStore(fileStore, progress.split(3));
try {
- IDocument currentDocument= buffer.getDocument();
- IDocument oldDocument=
- ((ITextFileBuffer) fileBufferManager.getFileStoreFileBuffer(fileStore)).getDocument();
+ IDocument currentDocument = buffer.getDocument();
+ IDocument oldDocument = ((ITextFileBuffer) fileBufferManager.getFileStoreFileBuffer(fileStore))
+ .getDocument();
- result[0]= getChangedLineRegions(oldDocument, currentDocument);
+ result[0] = getChangedLineRegions(oldDocument, currentDocument);
} finally {
fileBufferManager.disconnectFileStore(fileStore, progress.split(1));
}
@@ -945,10 +948,11 @@ public class EditorUtility {
* here in order to prevent loading of the Compare plug-in at load
* time of this class.
*/
- Object leftSide= new LineComparator(oldDocument);
- Object rightSide= new LineComparator(currentDocument);
+ Object leftSide = new LineComparator(oldDocument);
+ Object rightSide = new LineComparator(currentDocument);
- RangeDifference[] differences= RangeDifferencer.findDifferences((IRangeComparator) leftSide, (IRangeComparator) rightSide);
+ RangeDifference[] differences = RangeDifferencer.findDifferences((IRangeComparator) leftSide,
+ (IRangeComparator) rightSide);
// It holds that:
// 1. Ranges are sorted:
@@ -956,12 +960,12 @@ public class EditorUtility {
// 2. Successive changed lines are merged into on RangeDifference
// forAll r1,r2 element differences: r1.rightStart() < r2.rightStart() -> r1.rightEnd() < r2.rightStart
- List<IRegion> regions= new ArrayList<>();
- final int numberOfLines= currentDocument.getNumberOfLines();
+ List<IRegion> regions = new ArrayList<>();
+ final int numberOfLines = currentDocument.getNumberOfLines();
for (RangeDifference curr : differences) {
if (curr.kind() == RangeDifference.CHANGE) {
- int startLine= Math.min(curr.rightStart(), numberOfLines - 1);
- int endLine= curr.rightEnd() - 1;
+ int startLine = Math.min(curr.rightStart(), numberOfLines - 1);
+ int endLine = curr.rightEnd() - 1;
IRegion startLineRegion;
try {
@@ -969,14 +973,14 @@ public class EditorUtility {
if (startLine >= endLine) {
// startLine > endLine indicates a deletion of one or more lines.
// Deletions are ignored except at the end of the document.
- if (startLine == endLine ||
- startLineRegion.getOffset() + startLineRegion.getLength() == currentDocument.getLength()) {
+ if (startLine == endLine || startLineRegion.getOffset()
+ + startLineRegion.getLength() == currentDocument.getLength()) {
regions.add(startLineRegion);
}
} else {
- IRegion endLineRegion= currentDocument.getLineInformation(endLine);
- int startOffset= startLineRegion.getOffset();
- int endOffset= endLineRegion.getOffset() + endLineRegion.getLength();
+ IRegion endLineRegion = currentDocument.getLineInformation(endLine);
+ int startOffset = startLineRegion.getOffset();
+ int endOffset = endLineRegion.getOffset() + endLineRegion.getLength();
regions.add(new Region(startOffset, endOffset - startOffset));
}
} catch (BadLocationException e) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java
index b2497f27cb3..28e1f7f9b3f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.util;
-
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
@@ -38,21 +37,20 @@ import org.eclipse.jface.dialogs.MessageDialog;
*/
public class ExceptionHandler {
- private static ExceptionHandler fgInstance= new ExceptionHandler();
-
+ private static ExceptionHandler fgInstance = new ExceptionHandler();
+
/**
* Logs the given exception using the platform's logging mechanism. The exception is
* logged as an error with the error code <code>JavaStatusConstants.INTERNAL_ERROR</code>.
*/
public static void log(Throwable t, String message) {
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
- CStatusConstants.INTERNAL_ERROR, message, t));
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), CStatusConstants.INTERNAL_ERROR, message, t));
}
-
+
/**
* 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
* @param title the dialog window's window title
* @param message message to be displayed by the dialog window
@@ -60,10 +58,10 @@ public class ExceptionHandler {
public static void handle(CoreException e, String title, String message) {
handle(e, CUIPlugin.getActiveWorkbenchShell(), title, message);
}
-
+
/**
- * Handles the given <code>CoreException</code>.
- *
+ * Handles the given <code>CoreException</code>.
+ *
* @param e the <code>CoreException</code> to be handled
* @param parent the dialog window's parent shell
* @param title the dialog window's window title
@@ -72,11 +70,11 @@ public class ExceptionHandler {
public static void handle(CoreException e, Shell parent, String title, String message) {
fgInstance.perform(e, parent, title, message);
}
-
+
/**
- * Handles the given <code>InvocationTargetException</code>. The workbench shell is used
+ * 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
* @param title the dialog window's window title
* @param message message to be displayed by the dialog window
@@ -84,10 +82,10 @@ public class ExceptionHandler {
public static void handle(InvocationTargetException e, String title, String message) {
handle(e, CUIPlugin.getActiveWorkbenchShell(), title, message);
}
-
+
/**
- * Handles the given <code>InvocationTargetException</code>.
- *
+ * Handles the given <code>InvocationTargetException</code>.
+ *
* @param e the <code>InvocationTargetException</code> to be handled
* @param parent the dialog window's parent shell
* @param title the dialog window's window title
@@ -98,10 +96,10 @@ public class ExceptionHandler {
}
//---- Hooks for subclasses to control exception handling ------------------------------------
-
+
protected void perform(CoreException e, Shell shell, String title, String message) {
CUIPlugin.log(e);
- IStatus status= e.getStatus();
+ IStatus status = e.getStatus();
if (status != null) {
ErrorDialog.openError(shell, title, message, status);
} else {
@@ -110,9 +108,9 @@ public class ExceptionHandler {
}
protected void perform(InvocationTargetException e, Shell shell, String title, String message) {
- Throwable target= e.getTargetException();
+ Throwable target = e.getTargetException();
if (target instanceof CoreException) {
- perform((CoreException)target, shell, title, message);
+ perform((CoreException) target, shell, title, message);
} else {
CUIPlugin.log(e);
if (e.getMessage() != null && e.getMessage().length() > 0) {
@@ -124,17 +122,17 @@ public class ExceptionHandler {
}
//---- Helper methods -----------------------------------------------------------------------
-
+
private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) {
- StringWriter msg= new StringWriter();
+ StringWriter msg = new StringWriter();
if (message != null) {
msg.write(message);
msg.write("\n\n"); //$NON-NLS-1$
}
if (exceptionMessage == null || exceptionMessage.length() == 0)
- msg.write(CUIMessages.ExceptionDialog_seeErrorLogMessage);
+ msg.write(CUIMessages.ExceptionDialog_seeErrorLogMessage);
else
msg.write(exceptionMessage);
- MessageDialog.openError(shell, title, msg.toString());
- }
+ MessageDialog.openError(shell, title, msg.toString());
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java
index 2f31fa5cfca..5cf0798118b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java
@@ -41,7 +41,7 @@ public final class ExternalEditorInput extends FileStoreEditorInput implements I
/**
* Creates an editor input for an external translation unit.
- *
+ *
* @param unit the translation unit
*/
public ExternalEditorInput(ITranslationUnit unit) {
@@ -52,7 +52,7 @@ public final class ExternalEditorInput extends FileStoreEditorInput implements I
/**
* Creates an editor input for an external file of the local file system.
- *
+ *
* @param location the file system location
*/
public ExternalEditorInput(IPath location) {
@@ -61,7 +61,7 @@ public final class ExternalEditorInput extends FileStoreEditorInput implements I
/**
* Creates an editor input for an external file of the local file system.
- *
+ *
* @param location the file system location
* @param markerResource the associated marker resource, may be <code>null</code>
*/
@@ -71,7 +71,7 @@ public final class ExternalEditorInput extends FileStoreEditorInput implements I
/**
* Creates an editor input for a location URI.
- *
+ *
* @param locationURI the location URI
*/
public ExternalEditorInput(URI locationURI) {
@@ -80,7 +80,7 @@ public final class ExternalEditorInput extends FileStoreEditorInput implements I
/**
* Creates an editor input for a location URI.
- *
+ *
* @param locationURI the location URI
* @param markerResource the associated marker resource, may be <code>null</code>
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.java
index 2a60c84ec7c..0083833366b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.java
@@ -41,51 +41,51 @@ public class ExternalEditorInputFactory implements IElementFactory {
public static final String ID = "org.eclipse.cdt.ui.ExternalEditorInputFactory"; //$NON-NLS-1$
- private static final String TAG_PATH = "path";//$NON-NLS-1$
- private static final String TAG_PROJECT = "project";//$NON-NLS-1$
+ private static final String TAG_PATH = "path";//$NON-NLS-1$
+ private static final String TAG_PROJECT = "project";//$NON-NLS-1$
/*
* @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
*/
@Override
public IAdaptable createElement(IMemento memento) {
- // Get the file name.
- String fileName = memento.getString(TAG_PATH);
- if (fileName == null) {
+ // Get the file name.
+ String fileName = memento.getString(TAG_PATH);
+ if (fileName == null) {
return null;
}
- IPath location= new Path(fileName);
- ICProject cProject= null;
-
- String projectName= memento.getString(TAG_PROJECT);
- if (projectName != null) {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if (project.isAccessible() && CoreModel.hasCNature(project)) {
- cProject= CoreModel.getDefault().create(project);
- }
- }
+ IPath location = new Path(fileName);
+ ICProject cProject = null;
+
+ String projectName = memento.getString(TAG_PROJECT);
+ if (projectName != null) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (project.isAccessible() && CoreModel.hasCNature(project)) {
+ cProject = CoreModel.getDefault().create(project);
+ }
+ }
return EditorUtility.getEditorInputForLocation(location, cProject);
}
/**
* Save the element state.
- *
+ *
* @param memento the storage
* @param input the element
*/
static void saveState(IMemento memento, ExternalEditorInput input) {
- IPath location= input.getPath();
+ IPath location = input.getPath();
if (location != null) {
memento.putString(TAG_PATH, location.toOSString());
}
- IProject project= null;
- ITranslationUnit unit= input.getTranslationUnit();
+ IProject project = null;
+ ITranslationUnit unit = input.getTranslationUnit();
if (unit != null) {
- project= unit.getCProject().getProject();
+ project = unit.getCProject().getProject();
}
if (project == null && input.getMarkerResource() instanceof IProject) {
- project= (IProject)input.getMarkerResource();
+ project = (IProject) input.getMarkerResource();
}
if (project != null) {
memento.putString(TAG_PROJECT, project.getName());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java
index 58d368ffa56..f389950df7d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java
@@ -15,11 +15,10 @@ package org.eclipse.cdt.internal.ui.util;
public interface IDebugLogConstants {
public class DebugLogConstant {
- private DebugLogConstant( int value )
- {
+ private DebugLogConstant(int value) {
}
}
-
- public static final DebugLogConstant CONTENTASSIST = new DebugLogConstant ( 1 );
-
+
+ public static final DebugLogConstant CONTENTASSIST = new DebugLogConstant(1);
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java
index 47e1bf40ed5..132a1711959 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java
@@ -21,11 +21,10 @@ import org.eclipse.core.resources.IResource;
* marker changes. Used to update error ticks.
*/
public interface IProblemChangedListener {
-
+
/**
* @param changedElements A set of type <code>IPath</code> that
* describe the resources that had an error marker change.
*/
void problemsChanged(IResource[] changedResources, boolean markerChanged);
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java
index 250c3925495..014abb395ef 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java
@@ -28,9 +28,9 @@ import org.eclipse.core.runtime.Assert;
*/
public class ImageDescriptorRegistry {
- private HashMap<ImageDescriptor, Image> fRegistry= new HashMap<ImageDescriptor, Image>(10);
+ private HashMap<ImageDescriptor, Image> fRegistry = new HashMap<ImageDescriptor, Image>(10);
private Display fDisplay;
-
+
/**
* Creates a new image descriptor registry for the current or default display,
* respectively.
@@ -38,36 +38,36 @@ public class ImageDescriptorRegistry {
public ImageDescriptorRegistry() {
this(SWTUtil.getStandardDisplay());
}
-
+
/**
* Creates a new image descriptor registry for the given display. All images
* managed by this registry will be disposed when the display gets disposed.
- *
- * @param display the display the images managed by this registry are allocated for
+ *
+ * @param display the display the images managed by this registry are allocated for
*/
public ImageDescriptorRegistry(Display display) {
- fDisplay= display;
+ fDisplay = display;
Assert.isNotNull(fDisplay);
hookDisplay();
}
-
+
/**
* Returns the image assiciated with the given image descriptor.
- *
+ *
* @param descriptor the image descriptor for which the registry manages an image
* @return the image associated with the image descriptor or <code>null</code>
* if the image descriptor can't create the requested image.
*/
public Image get(ImageDescriptor descriptor) {
if (descriptor == null)
- descriptor= ImageDescriptor.getMissingImageDescriptor();
-
- Image result= fRegistry.get(descriptor);
+ descriptor = ImageDescriptor.getMissingImageDescriptor();
+
+ Image result = fRegistry.get(descriptor);
if (result != null)
return result;
-
+
Assert.isTrue(fDisplay == SWTUtil.getStandardDisplay(), "Allocating image for wrong display."); //$NON-NLS-1$
- result= descriptor.createImage();
+ result = descriptor.createImage();
if (result != null)
fRegistry.put(descriptor, result);
return result;
@@ -75,23 +75,21 @@ public class ImageDescriptorRegistry {
/**
* Disposes all images managed by this registry.
- */
+ */
public void dispose() {
- for (Iterator<Image> iter= fRegistry.values().iterator(); iter.hasNext(); ) {
- Image image= iter.next();
+ for (Iterator<Image> iter = fRegistry.values().iterator(); iter.hasNext();) {
+ Image image = iter.next();
image.dispose();
}
fRegistry.clear();
}
-
+
private void hookDisplay() {
fDisplay.disposeExec(new Runnable() {
@Override
public void run() {
dispose();
- }
+ }
});
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.java
index 5f10794514d..61434e98d05 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.util;
import org.eclipse.osgi.util.NLS;
@@ -27,9 +27,9 @@ public class Messages extends NLS {
public static String OpenExternalProblemAction_ErrorOpeningFile;
public static String format(String pattern, Object... arguments) {
- return MessageFormat.format(pattern, arguments);
- }
-
+ return MessageFormat.format(pattern, arguments);
+ }
+
private Messages() {
// Do not instantiate
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/NameComposer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/NameComposer.java
index 1c2d8efb853..ae726898dd0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/NameComposer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/NameComposer.java
@@ -35,13 +35,8 @@ public class NameComposer {
private static final int CAPITALIZATION_LOWER_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CASE;
private static final int CAPITALIZATION_CAMEL_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE;
private static final int CAPITALIZATION_LOWER_CAMEL_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE;
- private static final int[] ALL_CAPITALIZATIONS = {
- CAPITALIZATION_ORIGINAL,
- CAPITALIZATION_UPPER_CASE,
- CAPITALIZATION_LOWER_CASE,
- CAPITALIZATION_CAMEL_CASE,
- CAPITALIZATION_LOWER_CAMEL_CASE,
- };
+ private static final int[] ALL_CAPITALIZATIONS = { CAPITALIZATION_ORIGINAL, CAPITALIZATION_UPPER_CASE,
+ CAPITALIZATION_LOWER_CASE, CAPITALIZATION_CAMEL_CASE, CAPITALIZATION_LOWER_CAMEL_CASE, };
private int capitalization;
private final String wordDelimiter;
@@ -50,7 +45,7 @@ public class NameComposer {
/**
* Creates a name composer for a given style.
- *
+ *
* @param capitalization capitalization transformation applied to a name. Possible values: <ul>
* <li>PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL,</li>
* <li>PreferenceConstants.NAME_STYLE_CAPITALIZATION_UPPER_CASE,</li>
@@ -71,7 +66,7 @@ public class NameComposer {
/**
* Composes a name according to the composer's style based on a seed name.
- *
+ *
* @param seedName the name used as an inspiration
* @return the composed name
*/
@@ -82,7 +77,7 @@ public class NameComposer {
/**
* Composes a name according to the composer's style based on a seed words.
- *
+ *
* @param words the words that that should be combined to form the name
* @return the composed name
*/
@@ -153,15 +148,14 @@ public class NameComposer {
private void appendTitleCase(StringBuilder buf, CharSequence word) {
for (int i = 0; i < word.length(); i++) {
- buf.append(i == 0 ?
- Character.toUpperCase(word.charAt(i)) : Character.toLowerCase(word.charAt(i)));
+ buf.append(i == 0 ? Character.toUpperCase(word.charAt(i)) : Character.toLowerCase(word.charAt(i)));
}
}
/**
* Creates a NameComposer such that it would compose {@code composedName} given {@code seedName}
* as a seed.
- *
+ *
* @param seedName the seed name
* @param composedName the composed name
* @param defaultCapitalization used to disambiguate capitalization if it cannot be uniquely
@@ -169,10 +163,10 @@ public class NameComposer {
* @param defaultWordDelimiter used to disambiguate word delimiter if it cannot be uniquely
* determined from the composed name
* @return a name composer based on the composed name, or {@code null} if such name composer
- * does not exist
+ * does not exist
*/
- public static NameComposer createByExample(String seedName, String composedName,
- int defaultCapitalization, String defaultWordDelimiter) {
+ public static NameComposer createByExample(String seedName, String composedName, int defaultCapitalization,
+ String defaultWordDelimiter) {
List<CharSequence> seedWords = splitIntoWords(seedName);
if (seedWords.isEmpty())
return null;
@@ -211,18 +205,17 @@ public class NameComposer {
}
private static int indexOfSublistIgnoreCase(List<CharSequence> list, List<CharSequence> subList) {
- int subListSize = subList.size();
- int limit = list.size() - subListSize;
-
- outer:
- for (int k = 0; k <= limit; k++) {
- for (int i = 0, j = k; i < subListSize; i++, j++) {
- if (!subList.get(i).toString().equalsIgnoreCase(list.get(j).toString()))
- continue outer;
- }
- return k;
- }
- return -1;
+ int subListSize = subList.size();
+ int limit = list.size() - subListSize;
+
+ outer: for (int k = 0; k <= limit; k++) {
+ for (int i = 0, j = k; i < subListSize; i++, j++) {
+ if (!subList.get(i).toString().equalsIgnoreCase(list.get(j).toString()))
+ continue outer;
+ }
+ return k;
+ }
+ return -1;
}
private static String deducePrefix(CharSequence name, int numPrefixWords) {
@@ -239,6 +232,6 @@ public class NameComposer {
}
if (wordCount == numPrefixWords)
return name.toString();
- throw new IllegalArgumentException(numPrefixWords + " is larger than the number of words in \"" + name + "\""); //$NON-NLS-1$//$NON-NLS-2$
+ throw new IllegalArgumentException(numPrefixWords + " is larger than the number of words in \"" + name + "\""); //$NON-NLS-1$//$NON-NLS-2$
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.java
index 03c039dce46..7123916d8c2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.java
@@ -42,15 +42,15 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.core.model.CModelManager;
public class OpenExternalProblemAction extends ActionDelegate implements IObjectActionDelegate {
-
- IStructuredSelection selection ;
+
+ IStructuredSelection selection;
public OpenExternalProblemAction() {
}
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
-
+
}
@Override
@@ -60,19 +60,21 @@ public class OpenExternalProblemAction extends ActionDelegate implements IObject
try {
IMarker marker = (IMarker) object;
Object attributeObject = marker.getAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
- if (attributeObject instanceof String) {
+ if (attributeObject instanceof String) {
String externalLocation = (String) attributeObject;
IPath externalPath = new Path(externalLocation);
-
- File file = externalPath.toFile() ;
+
+ File file = externalPath.toFile();
if (!file.canRead()) {
- MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
+ MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(),
+ SWT.ICON_ERROR | SWT.OK);
errorMsg.setText(Messages.OpenExternalProblemAction_ErrorOpeningFile);
- errorMsg.setMessage(NLS.bind(Messages.OpenExternalProblemAction_CannotReadExternalLocation, externalPath));
+ errorMsg.setMessage(
+ NLS.bind(Messages.OpenExternalProblemAction_CannotReadExternalLocation, externalPath));
errorMsg.open();
return;
}
-
+
IEditorPart editor = EditorUtility.openInEditor(externalPath, getCProject(marker));
if (editor != null) {
IDE.gotoMarker(editor, marker);
@@ -83,17 +85,17 @@ public class OpenExternalProblemAction extends ActionDelegate implements IObject
}
}
}
-
- private ICProject getCProject(IMarker marker) {
- ICProject cproject = null ;
-
+
+ private ICProject getCProject(IMarker marker) {
+ ICProject cproject = null;
+
if (marker.getResource() instanceof IProject) {
IProject project = (IProject) marker.getResource();
cproject = CModelManager.getDefault().create(project);
}
- return cproject ;
+ return cproject;
}
-
+
@Override
public void selectionChanged(IAction action, ISelection selection) {
boolean enable = false;
@@ -103,15 +105,15 @@ public class OpenExternalProblemAction extends ActionDelegate implements IObject
try {
IMarker marker = (IMarker) object;
if ((marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER))
- &&(null!=marker.getAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION, null))) {
- enable = true;
+ && (null != marker.getAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION, null))) {
+ enable = true;
}
- this.selection = (IStructuredSelection)selection;
+ this.selection = (IStructuredSelection) selection;
action.setEnabled(enable);
} catch (CoreException e) {
}
}
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.java
index f534327540d..c3aab59a988 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.java
@@ -23,68 +23,68 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
*/
public class PendingUpdateAdapter implements IWorkbenchAdapter, IAdaptable {
- boolean removed = false;
+ boolean removed = false;
- /**
- * Return whether or not this has been removed from the tree.
- * @return boolean
- */
- public boolean isRemoved() {
- return removed;
- }
+ /**
+ * Return whether or not this has been removed from the tree.
+ * @return boolean
+ */
+ public boolean isRemoved() {
+ return removed;
+ }
- /**
- * Set whether or not this has been removed from the tree.
- * @param removedValue boolean
- */
- public void setRemoved(boolean removedValue) {
- this.removed = removedValue;
- }
+ /**
+ * Set whether or not this has been removed from the tree.
+ * @param removedValue boolean
+ */
+ public void setRemoved(boolean removedValue) {
+ this.removed = removedValue;
+ }
- /**
- * Create a new instance of the receiver.
- */
- public PendingUpdateAdapter() {
- //No initial behavior
- }
+ /**
+ * Create a new instance of the receiver.
+ */
+ public PendingUpdateAdapter() {
+ //No initial behavior
+ }
- @Override
- @SuppressWarnings("unchecked")
+ @Override
+ @SuppressWarnings("unchecked")
public <T> T getAdapter(Class<T> adapter) {
- if (adapter == IWorkbenchAdapter.class)
- return (T) this;
- return null;
- }
+ if (adapter == IWorkbenchAdapter.class)
+ return (T) this;
+ return null;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+ */
+ @Override
public Object[] getChildren(Object o) {
- return new Object[0];
- }
+ return new Object[0];
+ }
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+ */
+ @Override
public ImageDescriptor getImageDescriptor(Object object) {
- return null;
- }
+ return null;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+ */
+ @Override
public String getLabel(Object o) {
- return "Pending"; //$NON-NLS-1$
- }
+ return "Pending"; //$NON-NLS-1$
+ }
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+ */
+ @Override
public Object getParent(Object o) {
- return null;
- }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java
index c8bb93a249a..e926b7e3a8a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java
@@ -41,7 +41,8 @@ import org.eclipse.cdt.internal.ui.editor.TranslationUnitAnnotationModelEvent;
* IMarker.PROBLEM Viewers showing error ticks should register as listener to
* this type.
*/
-public class ProblemMarkerManager implements IResourceChangeListener, IAnnotationModelListener, IAnnotationModelListenerExtension {
+public class ProblemMarkerManager
+ implements IResourceChangeListener, IAnnotationModelListener, IAnnotationModelListenerExtension {
/**
* Visitors used to filter the element delta changes
@@ -58,7 +59,7 @@ public class ProblemMarkerManager implements IResourceChangeListener, IAnnotatio
public boolean visit(IResourceDelta delta) throws CoreException {
IResource res = delta.getResource();
if (res instanceof IProject && delta.getKind() == IResourceDelta.CHANGED) {
- IProject project = (IProject)res;
+ IProject project = (IProject) res;
if (!project.isAccessible()) {
// only track open C projects
return false;
@@ -80,7 +81,7 @@ public class ProblemMarkerManager implements IResourceChangeListener, IAnnotatio
}
private boolean isErrorDelta(IResourceDelta delta) {
- if ( (delta.getFlags() & IResourceDelta.MARKERS) != 0) {
+ if ((delta.getFlags() & IResourceDelta.MARKERS) != 0) {
IMarkerDelta[] markerDeltas = delta.getMarkerDeltas();
for (IMarkerDelta markerDelta : markerDeltas) {
if (markerDelta.isSubtypeOf(IMarker.PROBLEM)) {
@@ -131,13 +132,13 @@ public class ProblemMarkerManager implements IResourceChangeListener, IAnnotatio
@Override
public void modelChanged(AnnotationModelEvent event) {
if (event instanceof TranslationUnitAnnotationModelEvent) {
- TranslationUnitAnnotationModelEvent cuEvent = (TranslationUnitAnnotationModelEvent)event;
+ TranslationUnitAnnotationModelEvent cuEvent = (TranslationUnitAnnotationModelEvent) event;
if (cuEvent.includesProblemMarkerAnnotationChanges()) {
//IResource[] changes= new IResource[]
// {cuEvent.getUnderlyingResource()};
IResource res = cuEvent.getUnderlyingResource();
if (res != null) {
- fireChanges(new IResource[]{res}, false);
+ fireChanges(new IResource[] { res }, false);
}
}
}
@@ -176,4 +177,3 @@ public class ProblemMarkerManager implements IResourceChangeListener, IAnnotatio
}
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTableViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTableViewer.java
index 7c60d8fcd8b..bdde67d0641 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTableViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTableViewer.java
@@ -66,9 +66,9 @@ public class ProblemTableViewer extends TableViewer {
}
private void initMapper() {
- fResourceToItemsMapper= new ResourceToItemsMapper(this);
+ fResourceToItemsMapper = new ResourceToItemsMapper(this);
}
-
+
/*
* @see StructuredViewer#mapElement(Object, Widget)
*/
@@ -87,7 +87,7 @@ public class ProblemTableViewer extends TableViewer {
protected void unmapElement(Object element, Widget item) {
if (item instanceof Item) {
fResourceToItemsMapper.removeFromMap(element, (Item) item);
- }
+ }
super.unmapElement(element, item);
}
@@ -99,24 +99,24 @@ public class ProblemTableViewer extends TableViewer {
fResourceToItemsMapper.clearMap();
super.unmapAllElements();
}
-
+
/*
* @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
*/
@Override
protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
if (event instanceof ProblemsLabelChangedEvent) {
- ProblemsLabelChangedEvent e= (ProblemsLabelChangedEvent) event;
+ ProblemsLabelChangedEvent e = (ProblemsLabelChangedEvent) event;
if (!e.isMarkerChange() && canIgnoreChangesFromAnnotionModel()) {
return;
}
}
-
- Object[] changed= event.getElements();
+
+ Object[] changed = event.getElements();
if (changed != null && !fResourceToItemsMapper.isEmpty()) {
- ArrayList<Object> others= new ArrayList<Object>(changed.length);
- for (int i= 0; i < changed.length; i++) {
- Object curr= changed[i];
+ ArrayList<Object> others = new ArrayList<Object>(changed.length);
+ for (int i = 0; i < changed.length; i++) {
+ Object curr = changed[i];
if (curr instanceof IResource) {
fResourceToItemsMapper.resourceChanged((IResource) curr);
} else {
@@ -126,18 +126,18 @@ public class ProblemTableViewer extends TableViewer {
if (others.isEmpty()) {
return;
}
- event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
+ event = new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
}
super.handleLabelProviderChanged(event);
}
-
+
/**
* Answers whether this viewer can ignore label provider changes resulting from
* marker changes in annotation models
*/
private boolean canIgnoreChangesFromAnnotionModel() {
-// Object contentProvider= getContentProvider();
-// return contentProvider instanceof IWorkingCopyProvider && !((IWorkingCopyProvider)contentProvider).providesWorkingCopies();
+ // Object contentProvider= getContentProvider();
+ // return contentProvider instanceof IWorkingCopyProvider && !((IWorkingCopyProvider)contentProvider).providesWorkingCopies();
return true;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java
index 33340bddab6..724a7573380 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java
@@ -27,7 +27,6 @@ import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.Widget;
-
/**
* Extends a TreeViewer to allow more performance when showing error ticks.
* A <code>ProblemItemMapper</code> is contained that maps all items in
@@ -60,15 +59,15 @@ public class ProblemTreeViewer extends TreeViewer {
super(tree);
initMapper();
}
-
+
private void initMapper() {
- fResourceToItemsMapper= new ResourceToItemsMapper(this);
+ fResourceToItemsMapper = new ResourceToItemsMapper(this);
}
-
-
+
protected void doUpdateItem(Item item) {
doUpdateItem(item, item.getData(), true);
}
+
/*
* @see StructuredViewer#mapElement(Object, Widget)
*/
@@ -79,7 +78,7 @@ public class ProblemTreeViewer extends TreeViewer {
fResourceToItemsMapper.addToMap(element, (Item) item);
}
}
-
+
/*
* @see StructuredViewer#unmapElement(Object, Widget)
*/
@@ -87,7 +86,7 @@ public class ProblemTreeViewer extends TreeViewer {
protected void unmapElement(Object element, Widget item) {
if (item instanceof Item) {
fResourceToItemsMapper.removeFromMap(element, (Item) item);
- }
+ }
super.unmapElement(element);
}
@@ -105,16 +104,16 @@ public class ProblemTreeViewer extends TreeViewer {
*/
@Override
protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
- Object source= event.getElement();
+ Object source = event.getElement();
if (source == null) {
super.handleLabelProviderChanged(event);
return;
}
- Object[] changed= event.getElements();
+ Object[] changed = event.getElements();
if (changed != null && !fResourceToItemsMapper.isEmpty()) {
- ArrayList<Object> others= new ArrayList<Object>(changed.length);
- for (int i= 0; i < changed.length; i++) {
- Object curr= changed[i];
+ ArrayList<Object> others = new ArrayList<Object>(changed.length);
+ for (int i = 0; i < changed.length; i++) {
+ Object curr = changed[i];
if (curr instanceof IResource) {
fResourceToItemsMapper.resourceChanged((IResource) curr);
} else {
@@ -124,25 +123,25 @@ public class ProblemTreeViewer extends TreeViewer {
if (others.isEmpty()) {
return;
}
- event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
- }
+ event = new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
+ }
super.handleLabelProviderChanged(event);
return;
}
-
-// /**
-// * @see org.eclipse.jface.viewers.StructuredViewer#update(java.lang.Object, java.lang.String[])
-// */
-// public void update(Object element, String[] properties)
-// {
- /* Calling StructuredViewer.update() causes
- * RunnableLock deadlock with StructuredViewer.doInternalUpdate()
- * when long h file (with lots of declarations) is edited.
- * This is only workaround, it only protects against
- * deadlock but may cause other problems. */
-// }
-// Yeah, and the problem tree no longer updates after a schecdule decoration job!!!!
-
+
+ // /**
+ // * @see org.eclipse.jface.viewers.StructuredViewer#update(java.lang.Object, java.lang.String[])
+ // */
+ // public void update(Object element, String[] properties)
+ // {
+ /* Calling StructuredViewer.update() causes
+ * RunnableLock deadlock with StructuredViewer.doInternalUpdate()
+ * when long h file (with lots of declarations) is edited.
+ * This is only workaround, it only protects against
+ * deadlock but may cause other problems. */
+ // }
+ // Yeah, and the problem tree no longer updates after a schecdule decoration job!!!!
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.AbstractTreeViewer#isExpandable(java.lang.Object)
*/
@@ -151,11 +150,10 @@ public class ProblemTreeViewer extends TreeViewer {
ITreeContentProvider cp = (ITreeContentProvider) getContentProvider();
if (cp == null)
return false;
- // since AbstractTreeViewer will run filteres here on element children this will cause binary search threads and TU parsering
- // to be started for each project/file tested for expandablity, this can be expensive if lots of project exists in workspace
+ // since AbstractTreeViewer will run filteres here on element children this will cause binary search threads and TU parsering
+ // to be started for each project/file tested for expandablity, this can be expensive if lots of project exists in workspace
// or lots of TUs exist in one folder so lets skip it....
return cp.hasChildren(element);
}
-
-}
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.java
index 5d7fdeeaffd..3e38e94f0e3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.java
@@ -36,36 +36,36 @@ import org.eclipse.ui.progress.WorkbenchJob;
* its children with a "pending" node, and then the real children when they are available.
* This avoids collapsing the viewer when a refresh is performed. This implementation is
* currently tied to the <code>RemoteTreeViewer</code>.
- *
+ *
* @since 3.1
*/
public class RemoteTreeContentManager {
- private RemoteTreeViewer fViewer;
- private IWorkbenchSiteProgressService progressService;
-
- /**
- * Job to fetch children
- */
- private Job fFetchJob = new FetchJob();
-
- /**
- * Queue of parents to fetch children for, and
- * associated element collectors and deferred adapters.
- */
- private List<Object> fElementQueue = new ArrayList<Object>();
- private List<IElementCollector> fCollectors = new ArrayList<IElementCollector>();
- private List<IDeferredWorkbenchAdapter> fAdapaters = new ArrayList<IDeferredWorkbenchAdapter>();
-
- /**
- * Fetching children is done in a single background job.
- * This makes fetching single threaded/serial per view.
- */
- class FetchJob extends Job {
-
- public FetchJob() {
- super("FetchJob"); //$NON-NLS-1$
- setSystem(true);
- }
+ private RemoteTreeViewer fViewer;
+ private IWorkbenchSiteProgressService progressService;
+
+ /**
+ * Job to fetch children
+ */
+ private Job fFetchJob = new FetchJob();
+
+ /**
+ * Queue of parents to fetch children for, and
+ * associated element collectors and deferred adapters.
+ */
+ private List<Object> fElementQueue = new ArrayList<Object>();
+ private List<IElementCollector> fCollectors = new ArrayList<IElementCollector>();
+ private List<IDeferredWorkbenchAdapter> fAdapaters = new ArrayList<IDeferredWorkbenchAdapter>();
+
+ /**
+ * Fetching children is done in a single background job.
+ * This makes fetching single threaded/serial per view.
+ */
+ class FetchJob extends Job {
+
+ public FetchJob() {
+ super("FetchJob"); //$NON-NLS-1$
+ setSystem(true);
+ }
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
@@ -92,203 +92,205 @@ public class RemoteTreeContentManager {
}
return Status.OK_STATUS;
}
-
- }
-
- /**
- * Element collector
- */
- public class Collector implements IElementCollector {
- // number of children added to the tree
- int offset = 0;
- Object fParent;
-
- public Collector(Object parent) {
- fParent = parent;
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.progress.IElementCollector#add(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
+
+ }
+
+ /**
+ * Element collector
+ */
+ public class Collector implements IElementCollector {
+ // number of children added to the tree
+ int offset = 0;
+ Object fParent;
+
+ public Collector(Object parent) {
+ fParent = parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.progress.IElementCollector#add(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
public void add(Object element, IProgressMonitor monitor) {
- add(new Object[] { element }, monitor);
- }
+ add(new Object[] { element }, monitor);
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.progress.IElementCollector#add(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.progress.IElementCollector#add(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
public void add(Object[] elements, IProgressMonitor monitor) {
- Object[] filtered = fViewer.filter(elements);
- fViewer.getSorter().sort(fViewer, filtered);
- if (filtered.length > 0) {
- replaceChildren(fParent, filtered, offset, monitor);
- offset = offset + filtered.length;
- }
- }
+ Object[] filtered = fViewer.filter(elements);
+ fViewer.getSorter().sort(fViewer, filtered);
+ if (filtered.length > 0) {
+ replaceChildren(fParent, filtered, offset, monitor);
+ offset = offset + filtered.length;
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.progress.IElementCollector#done()
- */
- @Override
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.progress.IElementCollector#done()
+ */
+ @Override
public void done() {
- prune(fParent, offset);
- }
- }
-
- /**
- * Contructs a new content manager.
- *
- * @param provider content provider
- * @param viewer viewer
- * @param site part site
- */
- public RemoteTreeContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site) {
- fViewer = viewer;
- if (site != null) {
- Object siteService = site.getAdapter(IWorkbenchSiteProgressService.class);
- if (siteService != null) {
- progressService = (IWorkbenchSiteProgressService) siteService;
- }
- }
- }
-
- /**
- * Create the element collector for the receiver.
- *@param parent
- * The parent object being filled in,
- * @param placeholder
- * The adapter that will be used to indicate that results are
- * pending, possibly <code>null</code>
- * @return IElementCollector
- */
- protected IElementCollector createElementCollector(Object parent, PendingUpdateAdapter placeholder) {
- return new Collector(parent);
- }
-
- /**
- * Returns the child elements of the given element, or in the case of a
- * deferred element, returns a placeholder. If a deferred element is used, a
- * job is created to fetch the children in the background.
- *
- * @param parent
- * The parent object.
- * @return Object[] or <code>null</code> if parent is not an instance of
- * IDeferredWorkbenchAdapter.
- */
- public Object[] getChildren(final Object parent) {
- IDeferredWorkbenchAdapter element = getAdapter(parent);
- if (element == null)
- return null;
- Object[] currentChildren = fViewer.getCurrentChildren(parent);
- PendingUpdateAdapter placeholder = null;
- if (currentChildren == null || currentChildren.length == 0) {
- placeholder = new PendingUpdateAdapter();
- }
- startFetchingDeferredChildren(parent, element, placeholder);
- if (placeholder == null) {
- return currentChildren;
- }
- return new Object[] { placeholder };
- }
-
- /**
- * Create a UIJob to replace the children of the parent in the tree viewer.
- *
- * @param parent the parent for which children are to be replaced
- * @param children the replacement children
- * @param offset the offset at which to start replacing children
- * @param monitor progress monitor
- */
- protected void replaceChildren(final Object parent, final Object[] children, final int offset, IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- return;
- }
- WorkbenchJob updateJob = new WorkbenchJob("IncrementalDeferredTreeContentManager") { //$NON-NLS-1$
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
+ prune(fParent, offset);
+ }
+ }
+
+ /**
+ * Contructs a new content manager.
+ *
+ * @param provider content provider
+ * @param viewer viewer
+ * @param site part site
+ */
+ public RemoteTreeContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site) {
+ fViewer = viewer;
+ if (site != null) {
+ Object siteService = site.getAdapter(IWorkbenchSiteProgressService.class);
+ if (siteService != null) {
+ progressService = (IWorkbenchSiteProgressService) siteService;
+ }
+ }
+ }
+
+ /**
+ * Create the element collector for the receiver.
+ *@param parent
+ * The parent object being filled in,
+ * @param placeholder
+ * The adapter that will be used to indicate that results are
+ * pending, possibly <code>null</code>
+ * @return IElementCollector
+ */
+ protected IElementCollector createElementCollector(Object parent, PendingUpdateAdapter placeholder) {
+ return new Collector(parent);
+ }
+
+ /**
+ * Returns the child elements of the given element, or in the case of a
+ * deferred element, returns a placeholder. If a deferred element is used, a
+ * job is created to fetch the children in the background.
+ *
+ * @param parent
+ * The parent object.
+ * @return Object[] or <code>null</code> if parent is not an instance of
+ * IDeferredWorkbenchAdapter.
+ */
+ public Object[] getChildren(final Object parent) {
+ IDeferredWorkbenchAdapter element = getAdapter(parent);
+ if (element == null)
+ return null;
+ Object[] currentChildren = fViewer.getCurrentChildren(parent);
+ PendingUpdateAdapter placeholder = null;
+ if (currentChildren == null || currentChildren.length == 0) {
+ placeholder = new PendingUpdateAdapter();
+ }
+ startFetchingDeferredChildren(parent, element, placeholder);
+ if (placeholder == null) {
+ return currentChildren;
+ }
+ return new Object[] { placeholder };
+ }
+
+ /**
+ * Create a UIJob to replace the children of the parent in the tree viewer.
+ *
+ * @param parent the parent for which children are to be replaced
+ * @param children the replacement children
+ * @param offset the offset at which to start replacing children
+ * @param monitor progress monitor
+ */
+ protected void replaceChildren(final Object parent, final Object[] children, final int offset,
+ IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+ WorkbenchJob updateJob = new WorkbenchJob("IncrementalDeferredTreeContentManager") { //$NON-NLS-1$
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
public IStatus runInUIThread(IProgressMonitor updateMonitor) {
- //Cancel the job if the tree viewer got closed
- if (fViewer.getControl().isDisposed())
- return Status.CANCEL_STATUS;
- fViewer.replace(parent, children, offset);
- return Status.OK_STATUS;
- }
- };
- updateJob.setSystem(true);
- updateJob.setPriority(Job.INTERACTIVE);
- updateJob.schedule();
- }
-
- /**
- * Create a UIJob to prune the children of the parent in the tree viewer, starting
- * at the given offset.
- *
- * @param parent the parent for which children should be pruned
- * @param offset the offset at which children should be pruned. All children at and after
- * this index will be removed from the tree.
- */
- protected void prune(final Object parent, final int offset) {
- WorkbenchJob updateJob = new WorkbenchJob("DeferredTree") { //$NON-NLS-1$
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
+ //Cancel the job if the tree viewer got closed
+ if (fViewer.getControl().isDisposed())
+ return Status.CANCEL_STATUS;
+ fViewer.replace(parent, children, offset);
+ return Status.OK_STATUS;
+ }
+ };
+ updateJob.setSystem(true);
+ updateJob.setPriority(Job.INTERACTIVE);
+ updateJob.schedule();
+ }
+
+ /**
+ * Create a UIJob to prune the children of the parent in the tree viewer, starting
+ * at the given offset.
+ *
+ * @param parent the parent for which children should be pruned
+ * @param offset the offset at which children should be pruned. All children at and after
+ * this index will be removed from the tree.
+ */
+ protected void prune(final Object parent, final int offset) {
+ WorkbenchJob updateJob = new WorkbenchJob("DeferredTree") { //$NON-NLS-1$
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
public IStatus runInUIThread(IProgressMonitor updateMonitor) {
- //Cancel the job if the tree viewer got closed
- if (fViewer.getControl().isDisposed())
- return Status.CANCEL_STATUS;
- fViewer.prune(parent, offset);
- return Status.OK_STATUS;
- }
- };
- updateJob.setSystem(true);
- updateJob.setPriority(Job.INTERACTIVE);
- updateJob.schedule();
- }
-
- /**
- * Run a job to clear the placeholder. This is used when the update
- * for the tree is complete so that the user is aware that no more
- * updates are pending.
- *
- * @param placeholder
- */
- protected void runClearPlaceholderJob(final PendingUpdateAdapter placeholder) {
- if (placeholder == null || placeholder.isRemoved() || !PlatformUI.isWorkbenchRunning())
- return;
- //Clear the placeholder if it is still there
- WorkbenchJob clearJob = new WorkbenchJob("DeferredTreeContentManager_ClearJob") { //$NON-NLS-1$
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
+ //Cancel the job if the tree viewer got closed
+ if (fViewer.getControl().isDisposed())
+ return Status.CANCEL_STATUS;
+ fViewer.prune(parent, offset);
+ return Status.OK_STATUS;
+ }
+ };
+ updateJob.setSystem(true);
+ updateJob.setPriority(Job.INTERACTIVE);
+ updateJob.schedule();
+ }
+
+ /**
+ * Run a job to clear the placeholder. This is used when the update
+ * for the tree is complete so that the user is aware that no more
+ * updates are pending.
+ *
+ * @param placeholder
+ */
+ protected void runClearPlaceholderJob(final PendingUpdateAdapter placeholder) {
+ if (placeholder == null || placeholder.isRemoved() || !PlatformUI.isWorkbenchRunning())
+ return;
+ //Clear the placeholder if it is still there
+ WorkbenchJob clearJob = new WorkbenchJob("DeferredTreeContentManager_ClearJob") { //$NON-NLS-1$
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- if (!placeholder.isRemoved()) {
- Control control = fViewer.getControl();
- if (control.isDisposed())
- return Status.CANCEL_STATUS;
- fViewer.remove(placeholder);
- placeholder.setRemoved(true);
- }
- return Status.OK_STATUS;
- }
- };
- clearJob.setSystem(true);
- clearJob.schedule();
- }
+ if (!placeholder.isRemoved()) {
+ Control control = fViewer.getControl();
+ if (control.isDisposed())
+ return Status.CANCEL_STATUS;
+ fViewer.remove(placeholder);
+ placeholder.setRemoved(true);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ clearJob.setSystem(true);
+ clearJob.schedule();
+ }
/* (non-Javadoc)
* @see org.eclipse.ui.progress.DeferredTreeContentManager#getFetchJobName(java.lang.Object, org.eclipse.ui.progress.IDeferredWorkbenchAdapter)
@@ -296,29 +298,28 @@ public class RemoteTreeContentManager {
protected String getFetchJobName(Object parent, IDeferredWorkbenchAdapter adapter) {
return "RemoteTreeContentManager"; //$NON-NLS-1$
}
-
- /**
- * Return the IDeferredWorkbenchAdapter for element or the element if it is
- * an instance of IDeferredWorkbenchAdapter. If it does not exist return
- * null.
- *
- * @param element
- * @return IDeferredWorkbenchAdapter or <code>null</code>
- */
- protected IDeferredWorkbenchAdapter getAdapter(Object element) {
- if (element instanceof IDeferredWorkbenchAdapter)
- return (IDeferredWorkbenchAdapter) element;
- if (!(element instanceof IAdaptable))
- return null;
- Object adapter = ((IAdaptable) element)
- .getAdapter(IDeferredWorkbenchAdapter.class);
- if (adapter == null)
- return null;
- return (IDeferredWorkbenchAdapter) adapter;
- }
-
- protected void startFetchingDeferredChildren(final Object parent, final IDeferredWorkbenchAdapter adapter, PendingUpdateAdapter placeholder) {
+ /**
+ * Return the IDeferredWorkbenchAdapter for element or the element if it is
+ * an instance of IDeferredWorkbenchAdapter. If it does not exist return
+ * null.
+ *
+ * @param element
+ * @return IDeferredWorkbenchAdapter or <code>null</code>
+ */
+ protected IDeferredWorkbenchAdapter getAdapter(Object element) {
+ if (element instanceof IDeferredWorkbenchAdapter)
+ return (IDeferredWorkbenchAdapter) element;
+ if (!(element instanceof IAdaptable))
+ return null;
+ Object adapter = ((IAdaptable) element).getAdapter(IDeferredWorkbenchAdapter.class);
+ if (adapter == null)
+ return null;
+ return (IDeferredWorkbenchAdapter) adapter;
+ }
+
+ protected void startFetchingDeferredChildren(final Object parent, final IDeferredWorkbenchAdapter adapter,
+ PendingUpdateAdapter placeholder) {
final IElementCollector collector = createElementCollector(parent, placeholder);
synchronized (fElementQueue) {
if (!fElementQueue.contains(parent)) {
@@ -333,33 +334,33 @@ public class RemoteTreeContentManager {
progressService.schedule(fFetchJob);
}
- /**
- * Provides an optimized lookup for determining if an element has children.
- * This is required because elements that are populated lazilly can't
- * answer <code>getChildren</code> just to determine the potential for
- * children. Throw an AssertionFailedException if element is null.
- *
- * @param element The Object being tested. This should not be
- * <code>null</code>.
- * @return boolean <code>true</code> if there are potentially children.
- * @throws RuntimeException if the element is null.
- */
- public boolean mayHaveChildren(Object element) {
- //Assert.isNotNull(element, ProgressMessages.DeferredTreeContentManager_NotDeferred);
- IDeferredWorkbenchAdapter adapter = getAdapter(element);
- return adapter != null && adapter.isContainer();
- }
+ /**
+ * Provides an optimized lookup for determining if an element has children.
+ * This is required because elements that are populated lazilly can't
+ * answer <code>getChildren</code> just to determine the potential for
+ * children. Throw an AssertionFailedException if element is null.
+ *
+ * @param element The Object being tested. This should not be
+ * <code>null</code>.
+ * @return boolean <code>true</code> if there are potentially children.
+ * @throws RuntimeException if the element is null.
+ */
+ public boolean mayHaveChildren(Object element) {
+ //Assert.isNotNull(element, ProgressMessages.DeferredTreeContentManager_NotDeferred);
+ IDeferredWorkbenchAdapter adapter = getAdapter(element);
+ return adapter != null && adapter.isContainer();
+ }
- /**
- * Cancels any content this provider is currently fetching.
- */
- public void cancel() {
- synchronized (fElementQueue) {
- fFetchJob.cancel();
- fElementQueue.clear();
- fAdapaters.clear();
- fCollectors.clear();
- }
- }
+ /**
+ * Cancels any content this provider is currently fetching.
+ */
+ public void cancel() {
+ synchronized (fElementQueue) {
+ fFetchJob.cancel();
+ fElementQueue.clear();
+ fAdapaters.clear();
+ fCollectors.clear();
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.java
index d39bc9a7dc2..d5d879d3165 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.java
@@ -36,407 +36,404 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.progress.UIJob;
public class RemoteTreeViewer extends ProblemTreeViewer {
- private ExpansionJob fExpansionJob = null;
- private SelectionJob fSelectionJob = null;
-
-
- class ExpansionJob extends UIJob {
-
- private Object element;
- private List<Object> parents = new ArrayList<Object>(); // top down
-
- /**
- * Constucts a job to expand the given element.
- *
- */
- public ExpansionJob() {
- super("Expansion"); //$NON-NLS-1$
- setPriority(Job.INTERACTIVE);
- setSystem(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
+ private ExpansionJob fExpansionJob = null;
+ private SelectionJob fSelectionJob = null;
+
+ class ExpansionJob extends UIJob {
+
+ private Object element;
+ private List<Object> parents = new ArrayList<Object>(); // top down
+
+ /**
+ * Constucts a job to expand the given element.
+ *
+ */
+ public ExpansionJob() {
+ super("Expansion"); //$NON-NLS-1$
+ setPriority(Job.INTERACTIVE);
+ setSystem(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- if (getControl().isDisposed() || element == null) {
- return Status.OK_STATUS;
- }
- synchronized (RemoteTreeViewer.this) {
- boolean allParentsExpanded = true;
- Iterator<Object> iterator = parents.iterator();
- while (iterator.hasNext() && !monitor.isCanceled()) {
- Object parent = iterator.next();
- Widget item = findItem(parent);
- if (item != null) {
- expandToLevel(parent, 1);
- } else {
- allParentsExpanded = false;
- break;
- }
- }
- if (allParentsExpanded) {
- Widget item = findItem(element);
- if (item != null) {
- if (isExpandable(element)) {
- expandToLevel(element, 1);
- }
- element = null;
- parents.clear();
- return Status.OK_STATUS;
- }
- }
- return Status.OK_STATUS;
- }
- }
-
- public void validate(Object object) {
- if (element != null) {
- if (element.equals(object) || parents.contains(object)) {
- cancel();
- element = null;
- }
- }
- }
-
- public void setDeferredExpansion(Object toExpand) {
- element = toExpand;
- parents.clear();
- addAllParents(parents, element);
- }
-
- }
-
- class SelectionJob extends UIJob {
-
- private IStructuredSelection selection;
- private Object first;
- private List<Object> parents = new ArrayList<Object>(); // top down
-
- /**
- * Constucts a job to select the given element.
- *
- */
- public SelectionJob() {
- super("Selection"); //$NON-NLS-1$
- setPriority(Job.INTERACTIVE);
- setSystem(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
+ if (getControl().isDisposed() || element == null) {
+ return Status.OK_STATUS;
+ }
+ synchronized (RemoteTreeViewer.this) {
+ boolean allParentsExpanded = true;
+ Iterator<Object> iterator = parents.iterator();
+ while (iterator.hasNext() && !monitor.isCanceled()) {
+ Object parent = iterator.next();
+ Widget item = findItem(parent);
+ if (item != null) {
+ expandToLevel(parent, 1);
+ } else {
+ allParentsExpanded = false;
+ break;
+ }
+ }
+ if (allParentsExpanded) {
+ Widget item = findItem(element);
+ if (item != null) {
+ if (isExpandable(element)) {
+ expandToLevel(element, 1);
+ }
+ element = null;
+ parents.clear();
+ return Status.OK_STATUS;
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ }
+
+ public void validate(Object object) {
+ if (element != null) {
+ if (element.equals(object) || parents.contains(object)) {
+ cancel();
+ element = null;
+ }
+ }
+ }
+
+ public void setDeferredExpansion(Object toExpand) {
+ element = toExpand;
+ parents.clear();
+ addAllParents(parents, element);
+ }
+
+ }
+
+ class SelectionJob extends UIJob {
+
+ private IStructuredSelection selection;
+ private Object first;
+ private List<Object> parents = new ArrayList<Object>(); // top down
+
+ /**
+ * Constucts a job to select the given element.
+ *
+ */
+ public SelectionJob() {
+ super("Selection"); //$NON-NLS-1$
+ setPriority(Job.INTERACTIVE);
+ setSystem(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- if (getControl().isDisposed() || selection == null) {
- return Status.OK_STATUS;
- }
- synchronized (RemoteTreeViewer.this) {
- boolean allParentsExpanded = true;
- Iterator<Object> iterator = parents.iterator();
- while (iterator.hasNext() && !monitor.isCanceled()) {
- Object parent = iterator.next();
- Widget item = findItem(parent);
- if (item != null) {
- expandToLevel(parent, 1);
- } else {
- allParentsExpanded = false;
- break;
- }
- }
- if (allParentsExpanded) {
- if (findItem(first) != null) {
- setSelection(selection, true);
- selection = null;
- first = null;
- parents.clear();
- return Status.OK_STATUS;
- }
- }
-
- return Status.OK_STATUS;
- }
- }
-
- public void setDeferredSelection(IStructuredSelection sel) {
- selection = sel;
- first = selection.getFirstElement();
- parents.clear();
- addAllParents(parents, first);
- }
-
- public void validate(Object object) {
- if (first != null) {
- if (first.equals(object) || parents.contains(object)) {
- cancel();
- selection = null;
- }
- }
- }
- }
-
-
- /**
- * Constructs a remote tree viewer parented by the given composite.
- *
- * @param parent parent composite
- */
- public RemoteTreeViewer(Composite parent) {
- super(parent);
- addDisposeListener();
- fExpansionJob = new ExpansionJob();
- fSelectionJob = new SelectionJob();
- }
-
- /**
- * Constructs a remote tree viewer parented by the given composite
- * with the given style.
- *
- * @param parent parent composite
- * @param style style bits
- */
- public RemoteTreeViewer(Composite parent, int style) {
- super(parent, style);
- addDisposeListener();
- fExpansionJob = new ExpansionJob();
- fSelectionJob = new SelectionJob();
- }
-
- /**
- * Constructs a remote tree viewer with the given tree.
- *
- * @param tree tree widget
- */
- public RemoteTreeViewer(Tree tree) {
- super(tree);
- addDisposeListener();
- fExpansionJob = new ExpansionJob();
- fSelectionJob = new SelectionJob();
- }
-
- private void addDisposeListener() {
- getControl().addDisposeListener(new DisposeListener() {
- @Override
+ if (getControl().isDisposed() || selection == null) {
+ return Status.OK_STATUS;
+ }
+ synchronized (RemoteTreeViewer.this) {
+ boolean allParentsExpanded = true;
+ Iterator<Object> iterator = parents.iterator();
+ while (iterator.hasNext() && !monitor.isCanceled()) {
+ Object parent = iterator.next();
+ Widget item = findItem(parent);
+ if (item != null) {
+ expandToLevel(parent, 1);
+ } else {
+ allParentsExpanded = false;
+ break;
+ }
+ }
+ if (allParentsExpanded) {
+ if (findItem(first) != null) {
+ setSelection(selection, true);
+ selection = null;
+ first = null;
+ parents.clear();
+ return Status.OK_STATUS;
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+ }
+
+ public void setDeferredSelection(IStructuredSelection sel) {
+ selection = sel;
+ first = selection.getFirstElement();
+ parents.clear();
+ addAllParents(parents, first);
+ }
+
+ public void validate(Object object) {
+ if (first != null) {
+ if (first.equals(object) || parents.contains(object)) {
+ cancel();
+ selection = null;
+ }
+ }
+ }
+ }
+
+ /**
+ * Constructs a remote tree viewer parented by the given composite.
+ *
+ * @param parent parent composite
+ */
+ public RemoteTreeViewer(Composite parent) {
+ super(parent);
+ addDisposeListener();
+ fExpansionJob = new ExpansionJob();
+ fSelectionJob = new SelectionJob();
+ }
+
+ /**
+ * Constructs a remote tree viewer parented by the given composite
+ * with the given style.
+ *
+ * @param parent parent composite
+ * @param style style bits
+ */
+ public RemoteTreeViewer(Composite parent, int style) {
+ super(parent, style);
+ addDisposeListener();
+ fExpansionJob = new ExpansionJob();
+ fSelectionJob = new SelectionJob();
+ }
+
+ /**
+ * Constructs a remote tree viewer with the given tree.
+ *
+ * @param tree tree widget
+ */
+ public RemoteTreeViewer(Tree tree) {
+ super(tree);
+ addDisposeListener();
+ fExpansionJob = new ExpansionJob();
+ fSelectionJob = new SelectionJob();
+ }
+
+ private void addDisposeListener() {
+ getControl().addDisposeListener(new DisposeListener() {
+ @Override
public void widgetDisposed(DisposeEvent e) {
- cancelJobs();
- }
- });
- }
-
- protected void runDeferredUpdates() {
- if (fExpansionJob != null) {
- fExpansionJob.schedule();
- }
- if (fSelectionJob != null) {
- fSelectionJob.schedule();
- }
- }
-
- /**
- * The given element is being removed from the tree. Cancel
- * any deferred updates for the element.
- *
- * @param element
- */
- protected void validateDeferredUpdates(Object element) {
- if (element != null) {
- if (fExpansionJob != null) {
- fExpansionJob.validate(element);
- }
- if (fSelectionJob != null) {
- fSelectionJob.validate(element);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object)
- */
- @Override
+ cancelJobs();
+ }
+ });
+ }
+
+ protected void runDeferredUpdates() {
+ if (fExpansionJob != null) {
+ fExpansionJob.schedule();
+ }
+ if (fSelectionJob != null) {
+ fSelectionJob.schedule();
+ }
+ }
+
+ /**
+ * The given element is being removed from the tree. Cancel
+ * any deferred updates for the element.
+ *
+ * @param element
+ */
+ protected void validateDeferredUpdates(Object element) {
+ if (element != null) {
+ if (fExpansionJob != null) {
+ fExpansionJob.validate(element);
+ }
+ if (fSelectionJob != null) {
+ fSelectionJob.validate(element);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object)
+ */
+ @Override
public synchronized void add(Object parentElement, Object childElement) {
- super.add(parentElement, childElement);
- runDeferredUpdates();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object[])
- */
- @Override
+ super.add(parentElement, childElement);
+ runDeferredUpdates();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object[])
+ */
+ @Override
public synchronized void add(Object parentElement, Object[] childElements) {
- super.add(parentElement, childElements);
- runDeferredUpdates();
- }
-
+ super.add(parentElement, childElements);
+ runDeferredUpdates();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object)
*/
@Override
public synchronized void remove(Object element) {
- validateDeferredUpdates(element);
+ validateDeferredUpdates(element);
super.remove(element);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object[])
*/
@Override
public synchronized void remove(Object[] elements) {
- for (int i = 0; i < elements.length; i++) {
- validateDeferredUpdates(elements[i]);
- }
+ for (int i = 0; i < elements.length; i++) {
+ validateDeferredUpdates(elements[i]);
+ }
super.remove(elements);
- }
-
- /**
- * Cancels any deferred updates currently scheduled/running.
- */
- public void cancelJobs() {
- cancel(fSelectionJob);
- cancel(fExpansionJob);
- }
-
- public synchronized void deferExpansion(Object element) {
- TreeItem treeItem = (TreeItem) findItem(element);
- if (treeItem == null) {
- fExpansionJob.setDeferredExpansion(element);
- fExpansionJob.schedule();
- } else {
- if (!getExpanded(treeItem)) {
- fExpansionJob.setDeferredExpansion(element);
- fExpansionJob.schedule();
- }
- }
- }
-
- public synchronized void deferSelection(IStructuredSelection selection) {
- if (fSelectionJob == null) {
- fSelectionJob = new SelectionJob();
- }
-
- fSelectionJob.setDeferredSelection(selection);
- fSelectionJob.schedule();
- }
-
- public IStructuredSelection getDeferredSelection() {
- if (fSelectionJob != null) {
- return fSelectionJob.selection;
- }
- return null;
- }
-
- private void cancel(Job job) {
- if (job != null) {
- job.cancel();
- }
- }
-
- private void addAllParents(List<Object> list, Object element) {
- if (element instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) element;
- IWorkbenchAdapter adapter = adaptable.getAdapter(IWorkbenchAdapter.class);
- if (adapter != null) {
- Object parent = adapter.getParent(element);
- if (parent != null) {
- list.add(0, parent);
- if (!(parent instanceof ITranslationUnit))
- addAllParents(list, parent);
- }
- }
- }
- }
-
- @Override
+ }
+
+ /**
+ * Cancels any deferred updates currently scheduled/running.
+ */
+ public void cancelJobs() {
+ cancel(fSelectionJob);
+ cancel(fExpansionJob);
+ }
+
+ public synchronized void deferExpansion(Object element) {
+ TreeItem treeItem = (TreeItem) findItem(element);
+ if (treeItem == null) {
+ fExpansionJob.setDeferredExpansion(element);
+ fExpansionJob.schedule();
+ } else {
+ if (!getExpanded(treeItem)) {
+ fExpansionJob.setDeferredExpansion(element);
+ fExpansionJob.schedule();
+ }
+ }
+ }
+
+ public synchronized void deferSelection(IStructuredSelection selection) {
+ if (fSelectionJob == null) {
+ fSelectionJob = new SelectionJob();
+ }
+
+ fSelectionJob.setDeferredSelection(selection);
+ fSelectionJob.schedule();
+ }
+
+ public IStructuredSelection getDeferredSelection() {
+ if (fSelectionJob != null) {
+ return fSelectionJob.selection;
+ }
+ return null;
+ }
+
+ private void cancel(Job job) {
+ if (job != null) {
+ job.cancel();
+ }
+ }
+
+ private void addAllParents(List<Object> list, Object element) {
+ if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) element;
+ IWorkbenchAdapter adapter = adaptable.getAdapter(IWorkbenchAdapter.class);
+ if (adapter != null) {
+ Object parent = adapter.getParent(element);
+ if (parent != null) {
+ list.add(0, parent);
+ if (!(parent instanceof ITranslationUnit))
+ addAllParents(list, parent);
+ }
+ }
+ }
+ }
+
+ @Override
public Object[] filter(Object[] elements) {
- return super.filter(elements);
- }
-
- public Object[] getCurrentChildren(Object parent) {
- Widget widget = findItem(parent);
- if (widget != null) {
- Item[] items = getChildren(widget);
- Object[] children = new Object[items.length];
- for (int i = 0; i < children.length; i++) {
- Object data = items[i].getData();
- if (data == null) {
- return null;
- }
- children[i] = data;
- }
- return children;
- }
- return null;
- }
-
- public synchronized void prune(final Object parent, final int offset) {
- Widget widget = findItem(parent);
- if (widget != null) {
- final Item[] currentChildren = getChildren(widget);
- if (offset < currentChildren.length) {
- preservingSelection(new Runnable() {
- @Override
+ return super.filter(elements);
+ }
+
+ public Object[] getCurrentChildren(Object parent) {
+ Widget widget = findItem(parent);
+ if (widget != null) {
+ Item[] items = getChildren(widget);
+ Object[] children = new Object[items.length];
+ for (int i = 0; i < children.length; i++) {
+ Object data = items[i].getData();
+ if (data == null) {
+ return null;
+ }
+ children[i] = data;
+ }
+ return children;
+ }
+ return null;
+ }
+
+ public synchronized void prune(final Object parent, final int offset) {
+ Widget widget = findItem(parent);
+ if (widget != null) {
+ final Item[] currentChildren = getChildren(widget);
+ if (offset < currentChildren.length) {
+ preservingSelection(new Runnable() {
+ @Override
public void run() {
- for (int i = offset; i < currentChildren.length; i++) {
- if (currentChildren[i].getData() != null) {
- disassociate(currentChildren[i]);
- }
- currentChildren[i].dispose();
- }
- }
- });
- }
- }
- }
-
- public synchronized void replace(final Object parent, final Object[] children, final int offset) {
- preservingSelection(new Runnable() {
- @Override
+ for (int i = offset; i < currentChildren.length; i++) {
+ if (currentChildren[i].getData() != null) {
+ disassociate(currentChildren[i]);
+ }
+ currentChildren[i].dispose();
+ }
+ }
+ });
+ }
+ }
+ }
+
+ public synchronized void replace(final Object parent, final Object[] children, final int offset) {
+ preservingSelection(new Runnable() {
+ @Override
public void run() {
- Widget widget = findItem(parent);
- if (widget == null) {
- add(parent, children);
- } else {
- Item[] currentChildren = getChildren(widget);
- int pos = offset;
- if (pos >= currentChildren.length) {
- // append
- add(parent, children);
- } else {
- // replace
- for (int i = 0; i < children.length; i++) {
- Object child = children[i];
- if (pos < currentChildren.length) {
- // replace
- Item item = currentChildren[pos];
- Object data = item.getData();
- if (!child.equals(data)) {
- // no need to cancel pending updates here, the child may have shifted up/down
- internalRefresh(item, child, true, true);
- } else {
- // If it's the same child, the label/content may still have changed
- doUpdateItem(item, child);
- updatePlus(item, child);
- }
- } else {
- // add
- int numLeft = children.length - i;
- if (numLeft > 1) {
- Object[] others = new Object[numLeft];
- System.arraycopy(children, i, others, 0, numLeft);
- add(parent, others);
- } else {
- add(parent, child);
- }
- break;
- }
- pos++;
- }
- }
- }
- runDeferredUpdates();
- }
- });
- }
-
+ Widget widget = findItem(parent);
+ if (widget == null) {
+ add(parent, children);
+ } else {
+ Item[] currentChildren = getChildren(widget);
+ int pos = offset;
+ if (pos >= currentChildren.length) {
+ // append
+ add(parent, children);
+ } else {
+ // replace
+ for (int i = 0; i < children.length; i++) {
+ Object child = children[i];
+ if (pos < currentChildren.length) {
+ // replace
+ Item item = currentChildren[pos];
+ Object data = item.getData();
+ if (!child.equals(data)) {
+ // no need to cancel pending updates here, the child may have shifted up/down
+ internalRefresh(item, child, true, true);
+ } else {
+ // If it's the same child, the label/content may still have changed
+ doUpdateItem(item, child);
+ updatePlus(item, child);
+ }
+ } else {
+ // add
+ int numLeft = children.length - i;
+ if (numLeft > 1) {
+ Object[] others = new Object[numLeft];
+ System.arraycopy(children, i, others, 0, numLeft);
+ add(parent, others);
+ } else {
+ add(parent, child);
+ }
+ break;
+ }
+ pos++;
+ }
+ }
+ }
+ runDeferredUpdates();
+ }
+ });
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.java
index e29180a3afb..8319d2d96fb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.java
@@ -37,52 +37,52 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
*/
public class ResourceToItemsMapper {
- private static final int NUMBER_LIST_REUSE= 10;
+ private static final int NUMBER_LIST_REUSE = 10;
// map from resource to item
private HashMap<IResource, Object> fResourceToItem;
private Stack<List<Item>> fReuseLists;
-
+
private ContentViewer fContentViewer;
public ResourceToItemsMapper(ContentViewer viewer) {
- fResourceToItem= new HashMap<IResource, Object>();
- fReuseLists= new Stack<List<Item>>();
-
- fContentViewer= viewer;
+ fResourceToItem = new HashMap<IResource, Object>();
+ fReuseLists = new Stack<List<Item>>();
+
+ fContentViewer = viewer;
}
/**
* Must be called from the UI thread.
*/
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
@SuppressWarnings("unchecked")
- List<Item> list= (List<Item>) obj;
- for (int k= 0; k < list.size(); k++) {
+ List<Item> list = (List<Item>) obj;
+ for (int k = 0; k < list.size(); k++) {
updateItem(list.get(k));
}
}
}
-
+
private void updateItem(Item item) {
if (!item.isDisposed()) { // defensive code
- ILabelProvider lprovider= (ILabelProvider) fContentViewer.getLabelProvider();
-
- Object data= item.getData();
-
+ ILabelProvider lprovider = (ILabelProvider) fContentViewer.getLabelProvider();
+
+ Object data = item.getData();
+
// If it is an IItemLabelProvider than short circuit: patch Tod (bug 55012)
if (data != null && lprovider instanceof IViewerLabelProvider) {
- IViewerLabelProvider provider= (IViewerLabelProvider) lprovider;
-
- ViewerLabel updateLabel= new ViewerLabel(item.getText(), item.getImage());
+ IViewerLabelProvider provider = (IViewerLabelProvider) lprovider;
+
+ ViewerLabel updateLabel = new ViewerLabel(item.getText(), item.getImage());
provider.updateLabel(updateLabel, data);
-
+
if (updateLabel.hasNewImage()) {
item.setImage(updateLabel.getImage());
}
@@ -90,13 +90,13 @@ public class ResourceToItemsMapper {
item.setText(updateLabel.getText());
}
} else {
- Image oldImage= item.getImage();
- Image image= lprovider.getImage(data);
+ Image oldImage = item.getImage();
+ Image image = lprovider.getImage(data);
if (image != null && !image.equals(oldImage)) {
item.setImage(image);
}
- String oldText= item.getText();
- String text= lprovider.getText(data);
+ String oldText = item.getText();
+ String text = lprovider.getText(data);
if (text != null && !text.equals(oldText)) {
item.setText(text);
}
@@ -110,21 +110,21 @@ public class ResourceToItemsMapper {
* @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<Item> list= getNewList();
+ List<Item> list = getNewList();
list.add((Item) existingMapping);
list.add(item);
fResourceToItem.put(resource, list);
}
- } else { // List
+ } else { // List
@SuppressWarnings("unchecked")
- List<Item> list= (List<Item>) existingMapping;
+ List<Item> list = (List<Item>) existingMapping;
if (!list.contains(item)) {
list.add(item);
}
@@ -134,18 +134,18 @@ public class ResourceToItemsMapper {
/**
* Removes an element from the map.
- */
+ */
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
@SuppressWarnings({ "unchecked", "rawtypes" })
- List<Item> list= (List) existingMapping;
+ List<Item> list = (List) existingMapping;
list.remove(item);
if (list.isEmpty()) {
fResourceToItem.remove(list);
@@ -154,54 +154,54 @@ public class ResourceToItemsMapper {
}
}
}
-
+
private List<Item> getNewList() {
if (!fReuseLists.isEmpty()) {
return fReuseLists.pop();
}
return new ArrayList<Item>(2);
}
-
+
private void releaseList(List<Item> list) {
if (fReuseLists.size() < NUMBER_LIST_REUSE) {
fReuseLists.push(list);
}
}
-
+
/**
* Clears the map.
*/
public void clearMap() {
fResourceToItem.clear();
}
-
+
/**
* Tests if the map is empty
*/
public boolean isEmpty() {
return fResourceToItem.isEmpty();
- }
-
+ }
+
/**
* Method that decides which elements can have error markers
* Returns null if an element can not have error markers.
- */
+ */
private static IResource getCorrespondingResource(Object element) {
if (element instanceof ICElement) {
- ICElement elem= (ICElement) element;
- IResource res= elem.getResource();
+ ICElement elem = (ICElement) element;
+ IResource res = elem.getResource();
if (res == null) {
- ITranslationUnit cu= (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
+ ITranslationUnit cu = (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
if (cu != null) {
// elements in compilation units are mapped to the underlying resource of the original cu
- res= cu.getResource();
+ res = cu.getResource();
}
}
- return res;
+ return res;
} else if (element instanceof IResource) {
return (IResource) element;
}
return null;
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RowLayouter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RowLayouter.java
index fd61d41411d..a24f833fb1b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RowLayouter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RowLayouter.java
@@ -19,169 +19,169 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.core.runtime.Assert;
/**
- * Helper class to layout a number of children if the composite uses a <code>GridLayout</code>.
- * If the numbers of widgets to be layouted into one row is smaller than the number of columns
+ * Helper class to layout a number of children if the composite uses a <code>GridLayout</code>.
+ * If the numbers of widgets to be layouted into one row is smaller than the number of columns
* defined for the grid layout the helper class assigns a corresponing value to the <code>
* GridData.horizontalSpan</code> field.
- *
+ *
* Additionally a row layouter manages a default <code>GridData</code> object for each column.
* If set this grid data is used for the widget if it doesn't manage its own grid data object.
- *
+ *
* Call one of the <code>perform</code> methods to assign the correct grid data objects to
* a set of widgets according to the number of columns passed to the layouter's constructor.
*/
public class RowLayouter {
- public int spanHorizontalAlignment= -1;
- public int spanGrabExcessHorizontalSpace= -1;
- public int spanHorizontalSpan= -1;
- public int spanHorizontalIndent= -1;
- public int spanWidthHint= -1;
-
- public int spanVerticalAlignment= -1;
- public int spanGrabExcessVerticalSpace= -1;
- public int spanVerticalSpan= -1;
- public int spanHeightHint= -1;
-
+ public int spanHorizontalAlignment = -1;
+ public int spanGrabExcessHorizontalSpace = -1;
+ public int spanHorizontalSpan = -1;
+ public int spanHorizontalIndent = -1;
+ public int spanWidthHint = -1;
+
+ public int spanVerticalAlignment = -1;
+ public int spanGrabExcessVerticalSpace = -1;
+ public int spanVerticalSpan = -1;
+ public int spanHeightHint = -1;
+
private int fNumColumns;
private boolean fOrder;
private Control fLastControl;
- private GridData[] fDefaultGridDatas= new GridData[4];
-
+ private GridData[] fDefaultGridDatas = new GridData[4];
+
public RowLayouter(int numColumns) {
this(numColumns, false);
}
public RowLayouter(int numColumns, boolean order) {
- fNumColumns= numColumns;
- fOrder= order;
+ fNumColumns = numColumns;
+ fOrder = order;
}
-
+
public void setDefaultSpan() {
- spanHorizontalAlignment= GridData.FILL;
- spanGrabExcessHorizontalSpace= 1;
+ spanHorizontalAlignment = GridData.FILL;
+ spanGrabExcessHorizontalSpace = 1;
}
-
+
public void perform(Control c1) {
- perform(new Control[] {c1}, 0);
+ perform(new Control[] { c1 }, 0);
}
-
+
public void perform(Control c1, Control c2, int span) {
- perform(new Control[] {c1, c2}, span);
+ perform(new Control[] { c1, c2 }, span);
}
-
+
public void perform(Control c1, Control c2, Control c3, int span) {
- perform(new Control[] {c1, c2, c3}, span);
+ perform(new Control[] { c1, c2, c3 }, span);
}
-
+
public void perform(Control[] controls, int spanColumn) {
- int numColumns= numColumns();
+ int numColumns = numColumns();
Assert.isTrue(controls.length <= numColumns);
order(controls);
- int gridIndex= 0;
- for (int i= 0; i < controls.length; i++) {
- Control control= controls[i];
- GridData gd= (GridData)control.getLayoutData();
+ int gridIndex = 0;
+ for (int i = 0; i < controls.length; i++) {
+ Control control = controls[i];
+ GridData gd = (GridData) control.getLayoutData();
if (gd == null)
- gd= getGridData(gridIndex);
-
+ gd = getGridData(gridIndex);
+
if (i == spanColumn) {
- int span= numColumns - (controls.length - 1);
- gridIndex+= span;
+ int span = numColumns - (controls.length - 1);
+ gridIndex += span;
if (gd == null)
- gd= new GridData();
+ gd = new GridData();
applyDelta(gd);
- gd.horizontalSpan= span;
+ gd.horizontalSpan = span;
} else {
gridIndex++;
}
control.setLayoutData(gd);
}
}
-
+
private void applyDelta(GridData gd) {
if (spanHorizontalAlignment != -1)
- gd.horizontalAlignment= spanHorizontalAlignment;
-
+ gd.horizontalAlignment = spanHorizontalAlignment;
+
if (spanGrabExcessHorizontalSpace != -1) {
if (spanGrabExcessHorizontalSpace == 0)
- gd.grabExcessHorizontalSpace= false;
+ gd.grabExcessHorizontalSpace = false;
else
- gd.grabExcessHorizontalSpace= true;
- }
-
-
+ gd.grabExcessHorizontalSpace = true;
+ }
+
if (spanHorizontalSpan != -1)
- gd.horizontalSpan= spanHorizontalSpan;
-
+ gd.horizontalSpan = spanHorizontalSpan;
+
if (spanHorizontalIndent != -1)
- gd.horizontalIndent= spanHorizontalIndent;
-
+ gd.horizontalIndent = spanHorizontalIndent;
+
if (spanWidthHint != -1)
- gd.widthHint= spanWidthHint;
-
+ gd.widthHint = spanWidthHint;
+
if (spanVerticalAlignment != -1)
- gd.verticalAlignment= spanVerticalAlignment;
-
+ gd.verticalAlignment = spanVerticalAlignment;
+
if (spanGrabExcessVerticalSpace != -1) {
if (spanGrabExcessVerticalSpace == 0)
- gd.grabExcessVerticalSpace= false;
+ gd.grabExcessVerticalSpace = false;
else
- gd.grabExcessVerticalSpace= true;
- }
-
+ gd.grabExcessVerticalSpace = true;
+ }
+
if (spanVerticalSpan != -1)
- gd.verticalSpan= spanVerticalSpan;
-
+ gd.verticalSpan = spanVerticalSpan;
+
if (spanHeightHint != -1)
- gd.heightHint= spanHeightHint;
+ gd.heightHint = spanHeightHint;
}
+
public void setDefaultGridData(GridData gd, int index) {
if (index >= fDefaultGridDatas.length) {
- GridData[] newDatas= new GridData[index + 4];
+ GridData[] newDatas = new GridData[index + 4];
System.arraycopy(fDefaultGridDatas, 0, newDatas, 0, fDefaultGridDatas.length);
- fDefaultGridDatas= newDatas;
+ fDefaultGridDatas = newDatas;
}
- fDefaultGridDatas[index]= gd;
+ fDefaultGridDatas[index] = gd;
}
-
+
public GridData getGridData(int index) {
if (index > fDefaultGridDatas.length)
return null;
-
+
return cloneGridData(fDefaultGridDatas[index]);
}
-
+
public int numColumns() {
return fNumColumns;
}
-
+
protected void order(Control[] controls) {
if (!fOrder)
return;
-
- for (int i= 0; i < controls.length; i++) {
- Control control= controls[i];
+
+ for (int i = 0; i < controls.length; i++) {
+ Control control = controls[i];
control.moveBelow(fLastControl);
- fLastControl= control;
+ fLastControl = control;
}
}
-
+
protected GridData cloneGridData(GridData gd) {
if (gd == null)
return null;
-
- GridData result= new GridData();
- result.horizontalAlignment= gd.horizontalAlignment;
- result.grabExcessHorizontalSpace= gd.grabExcessHorizontalSpace;
- result.horizontalSpan= gd.horizontalSpan;
- result.horizontalIndent= gd.horizontalIndent;
- result.widthHint= gd.widthHint;
-
- result.verticalAlignment= gd.verticalAlignment;
- result.grabExcessVerticalSpace= gd.grabExcessVerticalSpace;
- result.verticalSpan= gd.verticalSpan;
- result.heightHint= gd.heightHint;
+
+ GridData result = new GridData();
+ result.horizontalAlignment = gd.horizontalAlignment;
+ result.grabExcessHorizontalSpace = gd.grabExcessHorizontalSpace;
+ result.horizontalSpan = gd.horizontalSpan;
+ result.horizontalIndent = gd.horizontalIndent;
+ result.widthHint = gd.widthHint;
+
+ result.verticalAlignment = gd.verticalAlignment;
+ result.grabExcessVerticalSpace = gd.grabExcessVerticalSpace;
+ result.verticalSpan = gd.verticalSpan;
+ result.heightHint = gd.heightHint;
return result;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java
index 5aa568f3926..1e7532b71b4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.util;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.layout.PixelConverter;
@@ -33,10 +32,10 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Widget;
/**
- * Utility class to simplify access to some SWT resources.
+ * Utility class to simplify access to some SWT resources.
*/
public class SWTUtil {
-
+
/**
* Returns the standard display to be used. The method first checks, if
* the thread calling this method has an associated disaply. If so, this
@@ -44,35 +43,34 @@ public class SWTUtil {
*/
public static Display getStandardDisplay() {
Display display;
- display= Display.getCurrent();
+ display = Display.getCurrent();
if (display == null)
- display= Display.getDefault();
- return display;
+ display = Display.getDefault();
+ return display;
}
-
+
/**
* Returns the shell for the given widget. If the widget doesn't represent
* a SWT object that manage a shell, <code>null</code> is returned.
- *
+ *
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget) {
if (widget instanceof Control)
- return ((Control)widget).getShell();
+ return ((Control) widget).getShell();
if (widget instanceof Caret)
- return ((Caret)widget).getParent().getShell();
+ return ((Caret) widget).getParent().getShell();
if (widget instanceof DragSource)
- return ((DragSource)widget).getControl().getShell();
+ return ((DragSource) widget).getControl().getShell();
if (widget instanceof DropTarget)
- return ((DropTarget)widget).getControl().getShell();
+ return ((DropTarget) widget).getControl().getShell();
if (widget instanceof Menu)
- return ((Menu)widget).getParent().getShell();
+ return ((Menu) widget).getParent().getShell();
if (widget instanceof ScrollBar)
- return ((ScrollBar)widget).getParent().getShell();
-
- return null;
- }
+ return ((ScrollBar) widget).getParent().getShell();
+ return null;
+ }
/**
* Returns a width hint for a button control.
@@ -80,8 +78,8 @@ public class SWTUtil {
public static int getButtonWidthHint(Button button) {
if (button.getFont().equals(JFaceResources.getDefaultFont()))
button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter= new PixelConverter(button);
- int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ PixelConverter converter = new PixelConverter(button);
+ int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
@@ -89,39 +87,37 @@ public class SWTUtil {
* Returns a height hint for a button control.
* @deprecated
* @see IDialogConstants#BUTTON_HEIGHT
- */
+ */
@Deprecated
public static int getButtonHeigthHint(Button button) {
if (button.getFont().equals(JFaceResources.getDefaultFont()))
button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter= new PixelConverter(button);
+ PixelConverter converter = new PixelConverter(button);
return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- }
+ }
-
/**
* Sets width for the button control.
* <b>Note:</b> This is a NOP if the button's layout data is not
* an instance of <code>GridData</code>.
- *
+ *
* @param button a button for which to set the dimension hint
- */
+ */
public static void setButtonDimensionHint(Button button) {
Assert.isNotNull(button);
- Object gd= button.getLayoutData();
+ Object gd = button.getLayoutData();
if (gd instanceof GridData) {
- ((GridData)gd).widthHint= getButtonWidthHint(button);
+ ((GridData) gd).widthHint = getButtonWidthHint(button);
}
}
-
+
public static int getTableHeightHint(Table table, int rows) {
if (table.getFont().equals(JFaceResources.getDefaultFont()))
table.setFont(JFaceResources.getDialogFont());
- int result= table.getItemHeight() * rows + table.getHeaderHeight();
+ int result = table.getItemHeight() * rows + table.getHeaderHeight();
if (table.getLinesVisible())
- result+= table.getGridLineWidth() * (rows - 1);
- return result;
+ result += table.getGridLineWidth() * (rows - 1);
+ return result;
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
index 91cc2cbbb37..cb14432e286 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
@@ -31,18 +31,17 @@ public class SelectionUtil {
public static Object getSingleElement(ISelection s) {
if (!(s instanceof IStructuredSelection))
return null;
- IStructuredSelection selection= (IStructuredSelection) s;
+ IStructuredSelection selection = (IStructuredSelection) s;
if (selection.size() != 1)
return null;
return selection.getFirstElement();
}
-
/**
* Returns the selection in the currently active workbench window part.
* If the no selection exists or no selection exists in the active part <code>null</code> is returned.
- *
+ *
* @return the current selection in the active workbench window part or null
*/
public static ISelection getActiveSelection() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StatusLineHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StatusLineHandler.java
index 113b4f092ba..43466e5b93f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StatusLineHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StatusLineHandler.java
@@ -34,42 +34,41 @@ public abstract class StatusLineHandler {
public static void showStatusLineMessage(final IWorkbenchSite site, final String message) {
// run the code to update the status line on the Display thread
// this way any other thread can invoke operationNotAvailable(String)
- CUIPlugin.getStandardDisplay().asyncExec(new Runnable(){
+ CUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
IStatusLineManager statusManager = null;
- if (site instanceof IViewSite){
- statusManager = ((IViewSite) site).getActionBars().getStatusLineManager();
- }
- else if (site instanceof IEditorSite){
- statusManager = ((IEditorSite) site).getActionBars().getStatusLineManager();
- }
- if( statusManager != null )
- statusManager.setErrorMessage(message);
+ if (site instanceof IViewSite) {
+ statusManager = ((IViewSite) site).getActionBars().getStatusLineManager();
+ } else if (site instanceof IEditorSite) {
+ statusManager = ((IEditorSite) site).getActionBars().getStatusLineManager();
+ }
+ if (statusManager != null)
+ statusManager.setErrorMessage(message);
}
});
}
+
public static void clearStatusLine(final IWorkbenchSite site) {
// run the code to update the status line on the Display thread
// this way any other thread can invoke clearStatusLine()
- CUIPlugin.getStandardDisplay().asyncExec(new Runnable(){
+ CUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
IStatusLineManager statusManager = null;
- if (site instanceof IViewSite){
- statusManager = ((IViewSite) site).getActionBars().getStatusLineManager();
- }
- else if (site instanceof IEditorSite){
- statusManager = ((IEditorSite) site).getActionBars().getStatusLineManager();
- }
- if( statusManager != null )
- statusManager.setErrorMessage( "" ); //$NON-NLS-1$
+ if (site instanceof IViewSite) {
+ statusManager = ((IViewSite) site).getActionBars().getStatusLineManager();
+ } else if (site instanceof IEditorSite) {
+ statusManager = ((IEditorSite) site).getActionBars().getStatusLineManager();
+ }
+ if (statusManager != null)
+ statusManager.setErrorMessage(""); //$NON-NLS-1$
}
});
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java
index 4a7e9d6adf3..272f5ea6887 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java
@@ -27,25 +27,28 @@ public class StringMatcher {
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
+
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
@@ -69,10 +72,10 @@ public class StringMatcher {
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();
@@ -80,6 +83,7 @@ public class StringMatcher {
parseWildCards();
}
}
+
/**
* Find the first occurrence of the pattern between <code>start</code)(inclusive)
* and <code>end</code>(exclusive).
@@ -97,42 +101,43 @@ public class StringMatcher {
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;
+ int segCount = fSegments.length;
if (segCount == 0)//pattern contains only '*'(s)
- return new Position (start, end);
+ return new Position(start, end);
- int curPos= start;
- int matchStart= -1;
+ 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
* @return true if matched eitherwise false
@@ -141,6 +146,7 @@ public class StringMatcher {
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
@@ -158,35 +164,35 @@ public class StringMatcher {
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)
+ 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();
+ int tlen = text.length();
if (start < 0)
- start= 0;
+ start = 0;
if (end > tlen)
- end= tlen;
+ end = tlen;
- int tCurPos= start;
- int bound= end - fBound;
- if ( bound < 0)
+ 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;
+ tCurPos = tCurPos + segLength;
}
}
if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) {
@@ -195,28 +201,28 @@ public class StringMatcher {
}
/* 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);
+ 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;
}
/**
@@ -224,59 +230,60 @@ public class StringMatcher {
* 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.
*/
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<String> temp= new Vector<String>();
+ Vector<String> temp = new Vector<String>();
- int pos= 0;
- StringBuilder buf= new StringBuilder();
+ int pos = 0;
+ StringBuilder buf = new StringBuilder();
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);
}
}
@@ -286,9 +293,10 @@ public class StringMatcher {
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
@@ -296,22 +304,23 @@ public class StringMatcher {
* @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;
+ 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
@@ -320,21 +329,20 @@ public class StringMatcher {
* @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 plen = p.length();
- int max= end - plen;
- for (int i= start; i <= max; ++i) {
+ 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) {
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) {
@@ -357,6 +365,7 @@ public class StringMatcher {
}
return true;
}
+
/**
* @param text the string to match
* @param start the starting index in the text for search, inclusive
@@ -366,17 +375,17 @@ public class StringMatcher {
*/
protected int textPosIn(String text, int start, int end, String p) {
- int plen= p.length();
- int max= end - plen;
+ 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;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java
index 1463021336a..26ccb680901 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java
@@ -37,7 +37,7 @@ import org.eclipse.jface.viewers.ColumnWeightData;
*/
public class TableLayoutComposite extends Composite {
- private List<ColumnLayoutData> columns= new ArrayList<ColumnLayoutData>();
+ private List<ColumnLayoutData> columns = new ArrayList<ColumnLayoutData>();
/**
* Creates a new <code>TableLayoutComposite</code>.
@@ -47,10 +47,10 @@ public class TableLayoutComposite extends Composite {
addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
- Rectangle area= getClientArea();
- Table table= (Table)getChildren()[0];
- Point preferredSize= computeTableSize(table);
- int width= area.width - 2 * table.getBorderWidth();
+ Rectangle area = getClientArea();
+ Table table = (Table) getChildren()[0];
+ Point preferredSize = computeTableSize(table);
+ int width = area.width - 2 * table.getBorderWidth();
if (preferredSize.y > area.height) {
// Subtract the scrollbar width from the total column width
// if a vertical scrollbar will be required
@@ -61,7 +61,7 @@ public class TableLayoutComposite extends Composite {
}
});
}
-
+
/**
* Adds a new column of data to this table layout.
*
@@ -70,31 +70,31 @@ public class TableLayoutComposite extends Composite {
public void addColumnData(ColumnLayoutData data) {
columns.add(data);
}
-
+
//---- Helpers -------------------------------------------------------------------------------------
-
+
Point computeTableSize(Table table) {
- Point result= table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- int width= 0;
- int size= columns.size();
- for (int i= 0; i < size; ++i) {
- ColumnLayoutData layoutData= columns.get(i);
+ Point result = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+
+ int width = 0;
+ int size = columns.size();
+ for (int i = 0; i < size; ++i) {
+ ColumnLayoutData layoutData = columns.get(i);
if (layoutData instanceof ColumnPixelData) {
- ColumnPixelData col= (ColumnPixelData) layoutData;
+ ColumnPixelData col = (ColumnPixelData) layoutData;
width += col.width;
} else if (layoutData instanceof ColumnWeightData) {
- ColumnWeightData col= (ColumnWeightData) layoutData;
+ ColumnWeightData col = (ColumnWeightData) layoutData;
width += col.minimumWidth;
} else {
Assert.isTrue(false, "Unknown column layout data"); //$NON-NLS-1$
}
}
if (width > result.x)
- result.x= width;
+ result.x = width;
return result;
}
-
+
void layoutTable(Table table, int width, Rectangle area, boolean increase) {
// XXX: Layout is being called with an invalid value the first time
// it is being called on Linux. This method resets the
@@ -103,26 +103,26 @@ public class TableLayoutComposite extends Composite {
if (width <= 1)
return;
- TableColumn[] tableColumns= table.getColumns();
- int size= Math.min(columns.size(), tableColumns.length);
- int[] widths= new int[size];
- int fixedWidth= 0;
- int numberOfWeightColumns= 0;
- int totalWeight= 0;
+ TableColumn[] tableColumns = table.getColumns();
+ int size = Math.min(columns.size(), tableColumns.length);
+ int[] widths = new int[size];
+ int fixedWidth = 0;
+ int numberOfWeightColumns = 0;
+ int totalWeight = 0;
// First calc space occupied by fixed columns
- for (int i= 0; i < size; i++) {
- ColumnLayoutData col= columns.get(i);
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = columns.get(i);
if (col instanceof ColumnPixelData) {
- int pixels= ((ColumnPixelData) col).width;
- widths[i]= pixels;
+ int pixels = ((ColumnPixelData) col).width;
+ widths[i] = pixels;
fixedWidth += pixels;
} else if (col instanceof ColumnWeightData) {
- ColumnWeightData cw= (ColumnWeightData) col;
+ ColumnWeightData cw = (ColumnWeightData) col;
numberOfWeightColumns++;
// first time, use the weight specified by the column data, otherwise use the actual width as the weight
// int weight = firstTime ? cw.weight : tableColumns[i].getWidth();
- int weight= cw.weight;
+ int weight = cw.weight;
totalWeight += weight;
} else {
Assert.isTrue(false, "Unknown column layout data"); //$NON-NLS-1$
@@ -132,40 +132,40 @@ public class TableLayoutComposite extends Composite {
// Do we have columns that have a weight
if (numberOfWeightColumns > 0) {
// Now distribute the rest to the columns with weight.
- int rest= width - fixedWidth;
- int totalDistributed= 0;
- for (int i= 0; i < size; ++i) {
- ColumnLayoutData col= columns.get(i);
+ int rest = width - fixedWidth;
+ int totalDistributed = 0;
+ for (int i = 0; i < size; ++i) {
+ ColumnLayoutData col = columns.get(i);
if (col instanceof ColumnWeightData) {
- ColumnWeightData cw= (ColumnWeightData) col;
+ ColumnWeightData cw = (ColumnWeightData) col;
// calculate weight as above
// int weight = firstTime ? cw.weight : tableColumns[i].getWidth();
- int weight= cw.weight;
- int pixels= totalWeight == 0 ? 0 : weight * rest / totalWeight;
+ int weight = cw.weight;
+ int pixels = totalWeight == 0 ? 0 : weight * rest / totalWeight;
if (pixels < cw.minimumWidth)
- pixels= cw.minimumWidth;
+ pixels = cw.minimumWidth;
totalDistributed += pixels;
- widths[i]= pixels;
+ widths[i] = pixels;
}
}
// Distribute any remaining pixels to columns with weight.
- int diff= rest - totalDistributed;
- for (int i= 0; diff > 0; ++i) {
+ int diff = rest - totalDistributed;
+ for (int i = 0; diff > 0; ++i) {
if (i == size)
- i= 0;
- ColumnLayoutData col= columns.get(i);
+ i = 0;
+ ColumnLayoutData col = columns.get(i);
if (col instanceof ColumnWeightData) {
++widths[i];
--diff;
}
}
}
-
+
if (increase) {
table.setSize(area.width, area.height);
}
- for (int i= 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
tableColumns[i].setWidth(widths[i]);
}
if (!increase) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java
index 1c5166a3a5e..381cceaf9f8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java
@@ -21,54 +21,54 @@ import org.eclipse.core.runtime.Assert;
*/
public class TwoArrayQuickSort {
- private static void internalSort(String[] keys, Object[] values, int left, int right, boolean ignoreCase) {
- int original_left= left;
- int original_right= right;
-
- String mid= keys[(left + right) >>> 1];
- do {
- while (smaller(keys[left], mid, ignoreCase)) {
- left++;
- }
- while (smaller(mid, keys[right], ignoreCase)) {
- right--;
- }
- if (left <= right) {
- String tmp= keys[left];
- keys[left]= keys[right];
- keys[right]= tmp;
-
- Object tmp2= values[left];
- values[left]= values[right];
- values[right]= tmp2;
-
- left++;
- right--;
- }
+ private static void internalSort(String[] keys, Object[] values, int left, int right, boolean ignoreCase) {
+ int original_left = left;
+ int original_right = right;
+
+ String mid = keys[(left + right) >>> 1];
+ do {
+ while (smaller(keys[left], mid, ignoreCase)) {
+ left++;
+ }
+ while (smaller(mid, keys[right], ignoreCase)) {
+ right--;
+ }
+ if (left <= right) {
+ String tmp = keys[left];
+ keys[left] = keys[right];
+ keys[right] = tmp;
+
+ Object tmp2 = values[left];
+ values[left] = values[right];
+ values[right] = tmp2;
+
+ left++;
+ right--;
+ }
} while (left <= right);
-
+
if (original_left < right) {
- internalSort(keys , values, original_left, right, ignoreCase);
- }
+ internalSort(keys, values, original_left, right, ignoreCase);
+ }
if (left < original_right) {
- internalSort(keys, values, left, original_right, ignoreCase);
- }
+ internalSort(keys, values, left, original_right, ignoreCase);
+ }
}
private static boolean smaller(String left, String right, boolean ignoreCase) {
if (ignoreCase)
return left.compareToIgnoreCase(right) < 0;
- return left.compareTo(right) < 0;
+ return left.compareTo(right) < 0;
}
/**
* Sorts keys and values in parallel.
*/
- public static void sort(String[] keys, Object[] values, boolean ignoreCase) {
+ public static void sort(String[] keys, Object[] values, boolean ignoreCase) {
if (keys != null && values != null) {
Assert.isTrue(keys.length == values.length);
if (keys.length > 1)
- internalSort(keys, values, 0, keys.length - 1, ignoreCase);
+ internalSort(keys, values, 0, keys.length - 1, ignoreCase);
} else {
if (keys != null || values != null)
Assert.isTrue(false, "Either keys or values in null"); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Util.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Util.java
index 0960f9fd654..8a4433b0ae8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Util.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Util.java
@@ -15,19 +15,20 @@ package org.eclipse.cdt.internal.ui.util;
import org.eclipse.cdt.ui.CUIPlugin;
-public class Util implements IDebugLogConstants{
+public class Util implements IDebugLogConstants {
public static boolean VERBOSE_CONTENTASSIST = false;
private Util() {
}
-
+
/**
* Adds a log entry
*/
public static void debugLog(String message, DebugLogConstant client) {
- if( CUIPlugin.getDefault() == null ) return;
- if ( CUIPlugin.getDefault().isDebugging() && isActive(client)) {
- while (message.length() > 100) {
+ if (CUIPlugin.getDefault() == null)
+ return;
+ if (CUIPlugin.getDefault().isDebugging() && isActive(client)) {
+ while (message.length() > 100) {
String partial = message.substring(0, 100);
message = message.substring(100);
System.out.println(partial + "\\"); //$NON-NLS-1$
@@ -39,9 +40,9 @@ public class Util implements IDebugLogConstants{
}
}
}
-
+
public static boolean isActive(DebugLogConstant client) {
- if (client.equals(IDebugLogConstants.CONTENTASSIST)){
+ if (client.equals(IDebugLogConstants.CONTENTASSIST)) {
return VERBOSE_CONTENTASSIST;
}
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ViewerPane.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ViewerPane.java
index 1aba12dde68..66c389bc704 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ViewerPane.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ViewerPane.java
@@ -28,49 +28,49 @@ import org.eclipse.jface.action.ToolBarManager;
* <P>
*/
public class ViewerPane extends ViewForm {
-
+
private ToolBarManager fToolBarManager;
public ViewerPane(Composite parent, int style) {
super(parent, style);
-
- marginWidth= 0;
- marginHeight= 0;
-
- CLabel label= new CLabel(this, SWT.NONE);
+
+ marginWidth = 0;
+ marginHeight = 0;
+
+ CLabel label = new CLabel(this, SWT.NONE);
setTopLeft(label);
-
- ToolBar tb= new ToolBar(this, SWT.FLAT);
+
+ ToolBar tb = new ToolBar(this, SWT.FLAT);
setTopCenter(tb);
- fToolBarManager= new ToolBarManager(tb);
+ fToolBarManager = new ToolBarManager(tb);
}
-
+
/**
* Sets the receiver's title text.
*/
public void setText(String label) {
- CLabel cl= (CLabel) getTopLeft();
- cl.setText(label);
+ CLabel cl = (CLabel) getTopLeft();
+ cl.setText(label);
}
-
+
public String getText() {
- CLabel cl= (CLabel) getTopLeft();
+ CLabel cl = (CLabel) getTopLeft();
return cl.getText();
}
-
+
/**
* Sets the receiver's title image.
*/
public void setImage(Image image) {
- CLabel cl= (CLabel) getTopLeft();
+ CLabel cl = (CLabel) getTopLeft();
cl.setImage(image);
}
-
+
public Image getImage() {
- CLabel cl= (CLabel) getTopLeft();
+ CLabel cl = (CLabel) getTopLeft();
return cl.getImage();
}
-
+
public ToolBarManager getToolBarManager() {
return fToolBarManager;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvider.java
index 4d18cc0d473..149cdd430c7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
@@ -28,7 +28,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
/**
* A selection provider that adapts the elements of structured selections
- * to a requested type.
+ * to a requested type.
* @author markus.schorn@windriver.com
*/
public class AdaptingSelectionProvider implements ISelectionProvider, ISelectionChangedListener {
@@ -38,18 +38,18 @@ public class AdaptingSelectionProvider implements ISelectionProvider, ISelection
private ISelectionProvider fProvider;
public AdaptingSelectionProvider(Class<?> targetType, ISelectionProvider provider) {
- fProvider= provider;
- fTargetType= targetType;
- fListenerList= new ListenerList<>();
+ fProvider = provider;
+ fTargetType = targetType;
+ fListenerList = new ListenerList<>();
}
-
+
private ISelection convertSelection(ISelection selection) {
if (selection != null) {
if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) selection;
- ArrayList<Object> adapted= new ArrayList<Object>();
- for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
- Object elem= adaptElem(iter.next());
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ ArrayList<Object> adapted = new ArrayList<Object>();
+ for (Iterator<?> iter = ss.iterator(); iter.hasNext();) {
+ Object elem = adaptElem(iter.next());
if (elem != null) {
adapted.add(elem);
}
@@ -98,7 +98,7 @@ public class AdaptingSelectionProvider implements ISelectionProvider, ISelection
@Override
public void selectionChanged(SelectionChangedEvent event) {
- SelectionChangedEvent event2= new SelectionChangedEvent(this, convertSelection(event.getSelection()));
+ SelectionChangedEvent event2 = new SelectionChangedEvent(this, convertSelection(event.getSelection()));
for (ISelectionChangedListener l : fListenerList) {
l.selectionChanged(event2);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java
index 2120c971571..81e38b41236 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java
@@ -26,8 +26,10 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
*/
public class AppearanceAwareLabelProvider extends CUILabelProvider implements IPropertyChangeListener {
- public final static long DEFAULT_TEXTFLAGS= CElementLabels.M_PARAMETER_TYPES | CElementLabels.PROJECT_POST_QUALIFIED | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE;
- public final static int DEFAULT_IMAGEFLAGS= CElementImageProvider.OVERLAY_ICONS;
+ public final static long DEFAULT_TEXTFLAGS = CElementLabels.M_PARAMETER_TYPES
+ | CElementLabels.PROJECT_POST_QUALIFIED | CElementLabels.F_APP_TYPE_SIGNATURE
+ | CElementLabels.M_APP_RETURNTYPE;
+ public final static int DEFAULT_IMAGEFLAGS = CElementImageProvider.OVERLAY_ICONS;
/**
* Constructor for AppearanceAwareLabelProvider.
@@ -38,11 +40,11 @@ public class AppearanceAwareLabelProvider extends CUILabelProvider implements IP
/**
* Creates a labelProvider with DEFAULT_TEXTFLAGS and DEFAULT_IMAGEFLAGS
- */
+ */
public AppearanceAwareLabelProvider() {
this(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS);
}
-
+
/*
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider.java
index f39dd0e5649..39f6c5cba3c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
@@ -41,328 +41,321 @@ import org.eclipse.cdt.internal.ui.CUIMessages;
* children.
*/
public abstract class AsyncTreeContentProvider implements ITreeContentProvider {
- private static final int PRIORITY_LOW = 0;
- private static final int PRIORITY_HIGH = 10;
- protected static final Object[] NO_CHILDREN = new Object[0];
-
- private Object fInput;
- private HashMap<Object, Object[]> fChildNodes= new HashMap<Object, Object[]>();
- private HashSet<Object> fHighPriorityTasks= new HashSet<Object>();
- private HashSet<Object> fLowPriorityTasks= new HashSet<Object>();
- private HashMap<Object, Object[]> fViewUpdates= new HashMap<Object, Object[]>();
- private int fViewUpdateDelta;
- private Job fJob;
- private Display fDisplay;
- private TreeViewer fTreeViewer= null;
- private Runnable fScheduledViewupdate= null;
- private HashSet<Object> fAutoexpand;
- private Object fAutoSelect;
+ private static final int PRIORITY_LOW = 0;
+ private static final int PRIORITY_HIGH = 10;
+ protected static final Object[] NO_CHILDREN = new Object[0];
- public AsyncTreeContentProvider(Display disp) {
- fDisplay= disp;
- fJob= new Job(CUIMessages.AsyncTreeContentProvider_JobName) {
- @Override
+ private Object fInput;
+ private HashMap<Object, Object[]> fChildNodes = new HashMap<Object, Object[]>();
+ private HashSet<Object> fHighPriorityTasks = new HashSet<Object>();
+ private HashSet<Object> fLowPriorityTasks = new HashSet<Object>();
+ private HashMap<Object, Object[]> fViewUpdates = new HashMap<Object, Object[]>();
+ private int fViewUpdateDelta;
+ private Job fJob;
+ private Display fDisplay;
+ private TreeViewer fTreeViewer = null;
+ private Runnable fScheduledViewupdate = null;
+ private HashSet<Object> fAutoexpand;
+ private Object fAutoSelect;
+
+ public AsyncTreeContentProvider(Display disp) {
+ fDisplay = disp;
+ fJob = new Job(CUIMessages.AsyncTreeContentProvider_JobName) {
+ @Override
protected IStatus run(final IProgressMonitor monitor) {
- return runJob(monitor);
- }
- };
- fJob.setSystem(true);
- }
- /**
- * {@inheritDoc}
- * <p>
- * This implementation returns the parent for nodes indicating asyncronous computation.
- * It returns <code>null</code> for all other elements. It should be overridden and
- * called by derived classes.
- */
- @Override
+ return runJob(monitor);
+ }
+ };
+ fJob.setSystem(true);
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * This implementation returns the parent for nodes indicating asyncronous computation.
+ * It returns <code>null</code> for all other elements. It should be overridden and
+ * called by derived classes.
+ */
+ @Override
public Object getParent(Object element) {
- if (element instanceof AsyncTreeWorkInProgressNode) {
- AsyncTreeWorkInProgressNode wipNode = (AsyncTreeWorkInProgressNode) element;
- return wipNode.getParent();
- }
- return null;
- }
-
- /**
- * Returns the child elements of the given parent element, or <code>null</code>.
- * <p>
- * The method is called within the UI-thread and shall therefore return null in case
- * the computation of the children may take longer.
- * </p>
- * The result is neither modified by the content provider nor the viewer.
- *
- * @param parentElement the parent element
- * @return an array of child elements, or <code>null</code>
- */
- protected Object[] syncronouslyComputeChildren(Object parentElement) {
- return null;
- }
+ if (element instanceof AsyncTreeWorkInProgressNode) {
+ AsyncTreeWorkInProgressNode wipNode = (AsyncTreeWorkInProgressNode) element;
+ return wipNode.getParent();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the child elements of the given parent element, or <code>null</code>.
+ * <p>
+ * The method is called within the UI-thread and shall therefore return null in case
+ * the computation of the children may take longer.
+ * </p>
+ * The result is neither modified by the content provider nor the viewer.
+ *
+ * @param parentElement the parent element
+ * @return an array of child elements, or <code>null</code>
+ */
+ protected Object[] syncronouslyComputeChildren(Object parentElement) {
+ return null;
+ }
+
+ /**
+ * Returns the child elements of the given parent element.
+ * <p>
+ * The method is called outside the UI-thread. There is no need to report progress, the monitor
+ * is supplied such that implementations can check for cancel requests.
+ * </p>
+ * The result is neither modified by the content provider nor the viewer.
+ *
+ * @param parentElement the parent element
+ * @param monitor the monitor that can be checked for a cancel event.
+ * @return an array of child elements.
+ */
+ protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
+ return NO_CHILDREN;
+ }
+
+ /**
+ * Clears all caches and stops asyncronous computations. As a consequence
+ * child nodes requested by the viewer have to be computed from scratch.
+ * <p>
+ * Derived classes may override this method but must call <code>super.clearCaches()</code>.
+ */
+ protected void clear() {
+ fChildNodes.clear();
+ synchronized (fHighPriorityTasks) {
+ fScheduledViewupdate = null;
+ fHighPriorityTasks.clear();
+ fLowPriorityTasks.clear();
+ fViewUpdates.clear();
+ }
+ }
+
+ /**
+ * Recomputes all of the nodes, trying to keep the expanded state even with async
+ * computations.
+ */
+ public void recompute() {
+ if (getInput() != null) {
+ fAutoexpand = new HashSet<Object>();
+ fAutoexpand.addAll(Arrays.asList(fTreeViewer.getVisibleExpandedElements()));
+ fAutoSelect = null;
+ fAutoSelect = ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
+ clear();
+ refreshViewer();
+ }
+ }
- /**
- * Returns the child elements of the given parent element.
- * <p>
- * The method is called outside the UI-thread. There is no need to report progress, the monitor
- * is supplied such that implementations can check for cancel requests.
- * </p>
- * The result is neither modified by the content provider nor the viewer.
- *
- * @param parentElement the parent element
- * @param monitor the monitor that can be checked for a cancel event.
- * @return an array of child elements.
- */
- protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
- return NO_CHILDREN;
- }
+ /**
+ * Refreshes the viewer
+ */
+ private void refreshViewer() {
+ if (fTreeViewer != null) {
+ fTreeViewer.refresh();
+ }
+ }
- /**
- * Clears all caches and stops asyncronous computations. As a consequence
- * child nodes requested by the viewer have to be computed from scratch.
- * <p>
- * Derived classes may override this method but must call <code>super.clearCaches()</code>.
- */
- protected void clear() {
- fChildNodes.clear();
- synchronized (fHighPriorityTasks) {
- fScheduledViewupdate= null;
- fHighPriorityTasks.clear();
- fLowPriorityTasks.clear();
- fViewUpdates.clear();
- }
- }
-
- /**
- * Recomputes all of the nodes, trying to keep the expanded state even with async
- * computations.
- */
- public void recompute() {
- if (getInput() != null) {
- fAutoexpand= new HashSet<Object>();
- fAutoexpand.addAll(Arrays.asList(fTreeViewer.getVisibleExpandedElements()));
- fAutoSelect= null;
- fAutoSelect= ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
- clear();
- refreshViewer();
- }
- }
-
- /**
- * Refreshes the viewer
- */
- private void refreshViewer() {
- if (fTreeViewer != null) {
- fTreeViewer.refresh();
- }
- }
-
- @Override
+ @Override
final public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput != oldInput) {
- clear();
- fInput= newInput;
- }
- if (viewer instanceof TreeViewer) {
- fTreeViewer= (TreeViewer) viewer;
- }
- else {
- fTreeViewer= null;
- }
- }
+ if (newInput != oldInput) {
+ clear();
+ fInput = newInput;
+ }
+ if (viewer instanceof TreeViewer) {
+ fTreeViewer = (TreeViewer) viewer;
+ } else {
+ fTreeViewer = null;
+ }
+ }
- final public Object getInput() {
- return fInput;
- }
-
- @Override
+ final public Object getInput() {
+ return fInput;
+ }
+
+ @Override
final public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
+ return getChildren(inputElement);
+ }
- @Override
+ @Override
final public Object[] getChildren(Object parentElement) {
- Object[] children = internalGetChildren(parentElement);
- if (children == null) {
- scheduleQuery(parentElement, PRIORITY_HIGH);
- return new Object[] {new AsyncTreeWorkInProgressNode(parentElement)};
- }
- return children;
- }
+ Object[] children = internalGetChildren(parentElement);
+ if (children == null) {
+ scheduleQuery(parentElement, PRIORITY_HIGH);
+ return new Object[] { new AsyncTreeWorkInProgressNode(parentElement) };
+ }
+ return children;
+ }
- @Override
+ @Override
final public boolean hasChildren(Object element) {
- assert Display.getCurrent() != null;
+ assert Display.getCurrent() != null;
- Object[] children= internalGetChildren(element);
- if (children == null) {
- scheduleQuery(element, PRIORITY_LOW);
- return true;
- }
- return children.length > 0;
- }
+ Object[] children = internalGetChildren(element);
+ if (children == null) {
+ scheduleQuery(element, PRIORITY_LOW);
+ return true;
+ }
+ return children.length > 0;
+ }
- @Override
+ @Override
public void dispose() {
- fTreeViewer= null;
- clear();
- }
+ fTreeViewer = null;
+ clear();
+ }
- private void scheduleQuery(Object element, int priority) {
- synchronized(fHighPriorityTasks) {
- if (priority == PRIORITY_HIGH) {
- if (!fHighPriorityTasks.contains(element)) {
- fHighPriorityTasks.add(element);
- fLowPriorityTasks.remove(element);
- }
- }
- else {
- if (!fHighPriorityTasks.contains(element) &&
- !fLowPriorityTasks.contains(element)) {
- fLowPriorityTasks.add(element);
- }
- }
- fJob.schedule();
- }
- }
-
- private IStatus runJob(final IProgressMonitor monitor) {
- monitor.beginTask(CUIMessages.AsyncTreeContentProvider_TaskName, IProgressMonitor.UNKNOWN);
- try {
- Object parent= getParentForNextTask();
- while (parent != null) {
- Object[] children= asyncronouslyComputeChildren(parent, monitor);
- synchronized (fHighPriorityTasks) {
- if (fHighPriorityTasks.remove(parent) || fLowPriorityTasks.remove(parent)) {
- fViewUpdates.put(parent, children);
- scheduleViewerUpdate();
- }
- }
- parent= getParentForNextTask();
- }
- return Status.OK_STATUS;
- }
- finally {
- monitor.done();
- }
- }
-
- private void scheduleViewerUpdate() {
- Runnable runme= null;
- synchronized(fHighPriorityTasks) {
- if (fScheduledViewupdate != null) {
- return;
- }
- runme= fScheduledViewupdate= new Runnable(){
- @Override
- public void run() {
- HashMap<Object, Object[]> updates= null;
- synchronized(fHighPriorityTasks) {
- if (fViewUpdates.isEmpty()) {
- fScheduledViewupdate= null;
- return;
- }
- if (fScheduledViewupdate != this) {
- return;
- }
- updates= fViewUpdates;
- fViewUpdates= new HashMap<Object, Object[]>();
- }
- fChildNodes.putAll(updates);
- if (fTreeViewer instanceof ExtendedTreeViewer) {
- ((ExtendedTreeViewer) fTreeViewer).refresh(updates.keySet().toArray());
- }
- else if (fTreeViewer != null) {
- for (Iterator<Object> iter = updates.keySet().iterator(); iter.hasNext();) {
- fTreeViewer.refresh(iter.next());
- }
- }
- for (Iterator<Object[]> iter = updates.values().iterator(); iter.hasNext();) {
- checkForAutoExpand(iter.next());
- }
- fViewUpdateDelta= Math.min(1000, fViewUpdateDelta*2);
- fDisplay.timerExec(fViewUpdateDelta, this);
- }
- };
- }
- try {
- fViewUpdateDelta= 32;
- fDisplay.asyncExec(runme);
- }
- catch (SWTException e) {
- // display may have been disposed.
- }
- }
+ private void scheduleQuery(Object element, int priority) {
+ synchronized (fHighPriorityTasks) {
+ if (priority == PRIORITY_HIGH) {
+ if (!fHighPriorityTasks.contains(element)) {
+ fHighPriorityTasks.add(element);
+ fLowPriorityTasks.remove(element);
+ }
+ } else {
+ if (!fHighPriorityTasks.contains(element) && !fLowPriorityTasks.contains(element)) {
+ fLowPriorityTasks.add(element);
+ }
+ }
+ fJob.schedule();
+ }
+ }
- private void checkForAutoExpand(Object[] objects) {
- if (fTreeViewer == null) {
- return;
- }
- if (fAutoexpand != null && !fAutoexpand.isEmpty()) {
- for (int i = 0; i < objects.length; i++) {
- Object object = objects[i];
- if (fAutoexpand.remove(object)) {
- fTreeViewer.setExpandedState(object, true);
- }
- if (object.equals(fAutoSelect)) {
- if (fTreeViewer.getSelection().isEmpty()) {
- fTreeViewer.setSelection(new StructuredSelection(object));
- }
- fAutoSelect= null;
- }
- }
- }
- if (fAutoSelect != null) {
- if (fTreeViewer.getSelection().isEmpty()) {
- for (int i = 0; i < objects.length; i++) {
- Object object = objects[i];
- if (object.equals(fAutoSelect)) {
- fTreeViewer.setSelection(new StructuredSelection(object));
- fAutoSelect= null;
- }
- }
- }
- else {
- fAutoSelect= null;
- }
- }
- }
+ private IStatus runJob(final IProgressMonitor monitor) {
+ monitor.beginTask(CUIMessages.AsyncTreeContentProvider_TaskName, IProgressMonitor.UNKNOWN);
+ try {
+ Object parent = getParentForNextTask();
+ while (parent != null) {
+ Object[] children = asyncronouslyComputeChildren(parent, monitor);
+ synchronized (fHighPriorityTasks) {
+ if (fHighPriorityTasks.remove(parent) || fLowPriorityTasks.remove(parent)) {
+ fViewUpdates.put(parent, children);
+ scheduleViewerUpdate();
+ }
+ }
+ parent = getParentForNextTask();
+ }
+ return Status.OK_STATUS;
+ } finally {
+ monitor.done();
+ }
+ }
- private final Object getParentForNextTask() {
- synchronized(fHighPriorityTasks) {
- Object parent= null;
- if (!fHighPriorityTasks.isEmpty()) {
- parent= fHighPriorityTasks.iterator().next();
- }
- else if (!fLowPriorityTasks.isEmpty()) {
- parent= fLowPriorityTasks.iterator().next();
- }
- return parent;
- }
- }
+ private void scheduleViewerUpdate() {
+ Runnable runme = null;
+ synchronized (fHighPriorityTasks) {
+ if (fScheduledViewupdate != null) {
+ return;
+ }
+ runme = fScheduledViewupdate = new Runnable() {
+ @Override
+ public void run() {
+ HashMap<Object, Object[]> updates = null;
+ synchronized (fHighPriorityTasks) {
+ if (fViewUpdates.isEmpty()) {
+ fScheduledViewupdate = null;
+ return;
+ }
+ if (fScheduledViewupdate != this) {
+ return;
+ }
+ updates = fViewUpdates;
+ fViewUpdates = new HashMap<Object, Object[]>();
+ }
+ fChildNodes.putAll(updates);
+ if (fTreeViewer instanceof ExtendedTreeViewer) {
+ ((ExtendedTreeViewer) fTreeViewer).refresh(updates.keySet().toArray());
+ } else if (fTreeViewer != null) {
+ for (Iterator<Object> iter = updates.keySet().iterator(); iter.hasNext();) {
+ fTreeViewer.refresh(iter.next());
+ }
+ }
+ for (Iterator<Object[]> iter = updates.values().iterator(); iter.hasNext();) {
+ checkForAutoExpand(iter.next());
+ }
+ fViewUpdateDelta = Math.min(1000, fViewUpdateDelta * 2);
+ fDisplay.timerExec(fViewUpdateDelta, this);
+ }
+ };
+ }
+ try {
+ fViewUpdateDelta = 32;
+ fDisplay.asyncExec(runme);
+ } catch (SWTException e) {
+ // display may have been disposed.
+ }
+ }
+ private void checkForAutoExpand(Object[] objects) {
+ if (fTreeViewer == null) {
+ return;
+ }
+ if (fAutoexpand != null && !fAutoexpand.isEmpty()) {
+ for (int i = 0; i < objects.length; i++) {
+ Object object = objects[i];
+ if (fAutoexpand.remove(object)) {
+ fTreeViewer.setExpandedState(object, true);
+ }
+ if (object.equals(fAutoSelect)) {
+ if (fTreeViewer.getSelection().isEmpty()) {
+ fTreeViewer.setSelection(new StructuredSelection(object));
+ }
+ fAutoSelect = null;
+ }
+ }
+ }
+ if (fAutoSelect != null) {
+ if (fTreeViewer.getSelection().isEmpty()) {
+ for (int i = 0; i < objects.length; i++) {
+ Object object = objects[i];
+ if (object.equals(fAutoSelect)) {
+ fTreeViewer.setSelection(new StructuredSelection(object));
+ fAutoSelect = null;
+ }
+ }
+ } else {
+ fAutoSelect = null;
+ }
+ }
+ }
- private Object[] internalGetChildren(Object parentElement) {
- assert Display.getCurrent() != null;
+ private final Object getParentForNextTask() {
+ synchronized (fHighPriorityTasks) {
+ Object parent = null;
+ if (!fHighPriorityTasks.isEmpty()) {
+ parent = fHighPriorityTasks.iterator().next();
+ } else if (!fLowPriorityTasks.isEmpty()) {
+ parent = fLowPriorityTasks.iterator().next();
+ }
+ return parent;
+ }
+ }
- if (parentElement instanceof AsyncTreeWorkInProgressNode) {
- return NO_CHILDREN;
- }
- Object[] children= fChildNodes.get(parentElement);
- if (children == null) {
- children= syncronouslyComputeChildren(parentElement);
- if (children != null) {
- final Object[] finalChildren= children;
- fChildNodes.put(parentElement, children);
- fDisplay.asyncExec(new Runnable() {
- @Override
+ private Object[] internalGetChildren(Object parentElement) {
+ assert Display.getCurrent() != null;
+
+ if (parentElement instanceof AsyncTreeWorkInProgressNode) {
+ return NO_CHILDREN;
+ }
+ Object[] children = fChildNodes.get(parentElement);
+ if (children == null) {
+ children = syncronouslyComputeChildren(parentElement);
+ if (children != null) {
+ final Object[] finalChildren = children;
+ fChildNodes.put(parentElement, children);
+ fDisplay.asyncExec(new Runnable() {
+ @Override
public void run() {
- checkForAutoExpand(finalChildren);
- }});
- }
- }
- return children;
- }
-
- final protected Display getDisplay() {
- return fDisplay;
- }
+ checkForAutoExpand(finalChildren);
+ }
+ });
+ }
+ }
+ return children;
+ }
+
+ final protected Display getDisplay() {
+ return fDisplay;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressNode.java
index 0be13743a29..00f2585c6a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressNode.java
@@ -10,22 +10,24 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
public class AsyncTreeWorkInProgressNode {
- private Object fParent;
+ private Object fParent;
- public AsyncTreeWorkInProgressNode(Object parentElement) {
- fParent= parentElement;
- }
- public Object getParent() {
- return fParent;
- }
- @Override
+ public AsyncTreeWorkInProgressNode(Object parentElement) {
+ fParent = parentElement;
+ }
+
+ public Object getParent() {
+ return fParent;
+ }
+
+ @Override
public String toString() {
- return "..."; //$NON-NLS-1$
- }
+ return "..."; //$NON-NLS-1$
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.java
index cab9f57d555..f1e32860ffc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.java
@@ -29,10 +29,10 @@ import org.eclipse.cdt.internal.corext.util.Strings;
*/
public class BasicElementLabels {
// TextProcessor delimiters
- private static final String CODE_DELIMITERS= TextProcessor.getDefaultDelimiters() + "<>()?,{}+-*!%=^|&;[]~"; //$NON-NLS-1$
- private static final String FILE_PATTERN_DELIMITERS= TextProcessor.getDefaultDelimiters() + "*.?"; //$NON-NLS-1$
- private static final String URL_DELIMITERS= TextProcessor.getDefaultDelimiters() + ":@?-"; //$NON-NLS-1$
-
+ private static final String CODE_DELIMITERS = TextProcessor.getDefaultDelimiters() + "<>()?,{}+-*!%=^|&;[]~"; //$NON-NLS-1$
+ private static final String FILE_PATTERN_DELIMITERS = TextProcessor.getDefaultDelimiters() + "*.?"; //$NON-NLS-1$
+ private static final String URL_DELIMITERS = TextProcessor.getDefaultDelimiters() + ":@?-"; //$NON-NLS-1$
+
/**
* Returns the label of a path.
*
@@ -43,9 +43,9 @@ public class BasicElementLabels {
public static String getPathLabel(IPath path, boolean isOSPath) {
String label;
if (isOSPath) {
- label= path.toOSString();
+ label = path.toOSString();
} else {
- label= path.makeRelative().toString();
+ label = path.makeRelative().toString();
}
return Strings.markLTR(label);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.java
index ebd810ee73e..9f4a622b5a1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
@@ -50,36 +50,35 @@ import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
* CDT outline view is brought to the front, the CDT context is set.
*/
public class CDTContextActivator implements IWindowListener, IPartListener2 {
- private static CDTContextActivator sInstance= new CDTContextActivator();
-
+ private static CDTContextActivator sInstance = new CDTContextActivator();
+
private Map<ContentOutline, IContextActivation> fActivationPerOutline = new HashMap<ContentOutline, IContextActivation>();
- private Map<CommonNavigator, SelectionListener> fActivationPerNavigator= new HashMap<CommonNavigator, SelectionListener>();
- private Collection<IWorkbenchWindow> fWindows= new HashSet<IWorkbenchWindow>();
+ private Map<CommonNavigator, SelectionListener> fActivationPerNavigator = new HashMap<CommonNavigator, SelectionListener>();
+ private Collection<IWorkbenchWindow> fWindows = new HashSet<IWorkbenchWindow>();
-
private CDTContextActivator() {
}
-
+
public static CDTContextActivator getInstance() {
return sInstance;
}
-
+
public void install() {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null) {
// listen for new windows
workbench.addWindowListener(this);
- IWorkbenchWindow[] wnds= workbench.getWorkbenchWindows();
+ IWorkbenchWindow[] wnds = workbench.getWorkbenchWindows();
for (int i = 0; i < wnds.length; i++) {
IWorkbenchWindow window = wnds[i];
register(window);
}
// register open windows
- IWorkbenchWindow ww= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (ww != null) {
IWorkbenchPage activePage = ww.getActivePage();
if (activePage != null) {
- IWorkbenchPartReference part= activePage.getActivePartReference();
+ IWorkbenchPartReference part = activePage.getActivePartReference();
if (part != null) {
partActivated(part);
}
@@ -94,7 +93,7 @@ public class CDTContextActivator implements IWindowListener, IPartListener2 {
unregister(window);
}
for (Iterator<SelectionListener> iterator = fActivationPerNavigator.values().iterator(); iterator.hasNext();) {
- SelectionListener l= iterator.next();
+ SelectionListener l = iterator.next();
l.uninstall();
}
}
@@ -103,7 +102,7 @@ public class CDTContextActivator implements IWindowListener, IPartListener2 {
wnd.getPartService().addPartListener(this);
fWindows.add(wnd);
}
-
+
private void unregister(IWorkbenchWindow wnd) {
wnd.getPartService().removePartListener(this);
fWindows.remove(wnd);
@@ -122,7 +121,7 @@ public class CDTContextActivator implements IWindowListener, IPartListener2 {
@Override
public void windowActivated(IWorkbenchWindow window) {
}
-
+
@Override
public void windowDeactivated(IWorkbenchWindow window) {
}
@@ -130,19 +129,18 @@ public class CDTContextActivator implements IWindowListener, IPartListener2 {
private void onContentOutlineClosed(ContentOutline outline) {
fActivationPerOutline.remove(outline);
}
-
+
private void onContentOutlineActivated(ContentOutline outline) {
IPage page = outline.getCurrentPage();
if (page instanceof CContentOutlinePage) {
- if (!fActivationPerOutline.containsKey(outline)){
+ if (!fActivationPerOutline.containsKey(outline)) {
// cdt outline activated for the first time
IContextService ctxtService = outline.getViewSite().getService(IContextService.class);
IContextActivation activateContext = ctxtService.activateContext(CUIPlugin.CVIEWS_SCOPE);
- fActivationPerOutline.put(outline,activateContext);
+ fActivationPerOutline.put(outline, activateContext);
}
- }
- else {
- IContextActivation activation = fActivationPerOutline.remove(outline);
+ } else {
+ IContextActivation activation = fActivationPerOutline.remove(outline);
if (activation != null) {
// other outline page brought to front
IContextService ctxtService = outline.getViewSite().getService(IContextService.class);
@@ -157,10 +155,10 @@ public class CDTContextActivator implements IWindowListener, IPartListener2 {
private IContextActivation fActivation;
public SelectionListener(IWorkbenchPartSite site) {
- fSite= site;
- fCtxService= fSite.getService(IContextService.class);
- ISelectionProvider sp= site.getSelectionProvider();
-
+ fSite = site;
+ fCtxService = fSite.getService(IContextService.class);
+ ISelectionProvider sp = site.getSelectionProvider();
+
if (sp != null && fCtxService != null) {
sp.addSelectionChangedListener(this);
onNewSelection(sp.getSelection());
@@ -168,20 +166,20 @@ public class CDTContextActivator implements IWindowListener, IPartListener2 {
}
public void uninstall() {
- ISelectionProvider sp= fSite.getSelectionProvider();
+ ISelectionProvider sp = fSite.getSelectionProvider();
if (sp != null && fCtxService != null) {
onNewSelection(null);
sp.removeSelectionChangedListener(this);
}
}
-
+
@Override
public void selectionChanged(SelectionChangedEvent event) {
onNewSelection(event.getSelection());
}
private void onNewSelection(ISelection selection) {
- boolean isRelevant= false;
+ boolean isRelevant = false;
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
if (((IStructuredSelection) selection).getFirstElement() instanceof ICElement) {
isRelevant = true;
@@ -189,22 +187,21 @@ public class CDTContextActivator implements IWindowListener, IPartListener2 {
}
if (isRelevant) {
if (fActivation == null) {
- fActivation= fCtxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+ fActivation = fCtxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
}
- }
- else {
+ } else {
if (fActivation != null) {
fCtxService.deactivateContext(fActivation);
- fActivation= null;
+ fActivation = null;
}
}
}
}
private void onCommonNavigatorActivated(CommonNavigator part) {
- SelectionListener l= fActivationPerNavigator.get(part);
+ SelectionListener l = fActivationPerNavigator.get(part);
if (l == null) {
- l= new SelectionListener(part.getSite());
+ l = new SelectionListener(part.getSite());
fActivationPerNavigator.put(part, l);
}
}
@@ -215,22 +212,20 @@ public class CDTContextActivator implements IWindowListener, IPartListener2 {
@Override
public void partActivated(IWorkbenchPartReference partRef) {
- IWorkbenchPart part= partRef.getPart(false);
+ IWorkbenchPart part = partRef.getPart(false);
if (part instanceof ContentOutline) {
onContentOutlineActivated((ContentOutline) part);
- }
- else if (part instanceof CommonNavigator) {
+ } else if (part instanceof CommonNavigator) {
onCommonNavigatorActivated((CommonNavigator) part);
}
}
@Override
public void partClosed(IWorkbenchPartReference partRef) {
- IWorkbenchPart part= partRef.getPart(false);
+ IWorkbenchPart part = partRef.getPart(false);
if (part instanceof ContentOutline) {
- onContentOutlineClosed((ContentOutline)part);
- }
- else if (part instanceof CommonNavigator) {
+ onContentOutlineClosed((ContentOutline) part);
+ } else if (part instanceof CommonNavigator) {
onCommonNavigatorClosed((CommonNavigator) part);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java
index 62e05dd84ff..593a6a2034f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java
@@ -56,69 +56,68 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.core.model.CModelManager;
-
/**
* Default strategy of the C plugin for the construction of C element icons.
*/
public class CElementImageProvider {
-
+
/**
* Flags for the CElementImageProvider:
* Generate images with overlays.
*/
- public final static int OVERLAY_ICONS= 0x1;
+ public final static int OVERLAY_ICONS = 0x1;
/**
* Generate small sized images.
*/
- public final static int SMALL_ICONS= 0x2;
+ public final static int SMALL_ICONS = 0x2;
/**
* Use the 'light' style for rendering types.
- */
- public final static int LIGHT_TYPE_ICONS= 0x4;
-
+ */
+ public final static int LIGHT_TYPE_ICONS = 0x4;
+
/**
- * Show error overlay.
- */
- public final static int OVERLAY_ERROR= 0x8;
+ * Show error overlay.
+ */
+ public final static int OVERLAY_ERROR = 0x8;
/**
* Show warning overlay
- */
- public final static int OVERLAY_WARNING= 0x10;
-
+ */
+ public final static int OVERLAY_WARNING = 0x10;
+
/**
- * Show override overlay.
- */
- public final static int OVERLAY_OVERRIDE= 0x20;
+ * Show override overlay.
+ */
+ public final static int OVERLAY_OVERRIDE = 0x20;
/**
- * Show implements overlay.
- */
- public final static int OVERLAY_IMPLEMENTS= 0x40;
-
+ * Show implements overlay.
+ */
+ public final static int OVERLAY_IMPLEMENTS = 0x40;
+
/**
* Show external file overlay.
*/
- public final static int OVERLAY_EXTERNAL= 0x80;
-
- public static final Point SMALL_SIZE= new Point(16, 16);
- public static final Point BIG_SIZE= new Point(22, 16);
+ public final static int OVERLAY_EXTERNAL = 0x80;
+
+ public static final Point SMALL_SIZE = new Point(16, 16);
+ public static final Point BIG_SIZE = new Point(22, 16);
- private static ImageDescriptor DESC_OBJ_PROJECT_CLOSED;
- private static ImageDescriptor DESC_OBJ_PROJECT;
+ private static ImageDescriptor DESC_OBJ_PROJECT_CLOSED;
+ private static ImageDescriptor DESC_OBJ_PROJECT;
//private static ImageDescriptor DESC_OBJ_FOLDER;
{
- ISharedImages images= CUIPlugin.getDefault().getWorkbench().getSharedImages();
- DESC_OBJ_PROJECT_CLOSED= images.getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED);
- DESC_OBJ_PROJECT= images.getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
+ ISharedImages images = CUIPlugin.getDefault().getWorkbench().getSharedImages();
+ DESC_OBJ_PROJECT_CLOSED = images.getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED);
+ DESC_OBJ_PROJECT = images.getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
//DESC_OBJ_FOLDER= images.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
}
-
+
public CElementImageProvider() {
- }
-
+ }
+
/**
* Returns the icon for a given element. The icon depends on the element type
* and element properties. If configured, overlay icons are constructed for
@@ -126,38 +125,37 @@ public class CElementImageProvider {
* @param flags Flags as defined by the CElementImageProvider
*/
public Image getImageLabel(Object element, int flags) {
- ImageDescriptor descriptor= null;
+ ImageDescriptor descriptor = null;
if (element instanceof ICElement) {
- if (!CCorePlugin.showSourceRootsAtTopOfProject() &&
- element instanceof ICContainer && isParentOfSourceRoot(element)) {
-
+ if (!CCorePlugin.showSourceRootsAtTopOfProject() && element instanceof ICContainer
+ && isParentOfSourceRoot(element)) {
+
descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE2_ROOT);
} else {
- descriptor= getCImageDescriptor((ICElement) element, flags);
+ descriptor = getCImageDescriptor((ICElement) element, flags);
}
} else if (element instanceof IFile) {
// Check for Non Translation Unit.
- IFile file = (IFile)element;
+ IFile file = (IFile) element;
String name = file.getName();
- if (CoreModel.isValidTranslationUnitName(file.getProject(), name) ||
- CoreModel.isValidTranslationUnitName(null, name)) {
- if (CoreModel.isValidCHeaderUnitName(null, name) ||
- CoreModel.isValidCXXHeaderUnitName(null, name))
+ if (CoreModel.isValidTranslationUnitName(file.getProject(), name)
+ || CoreModel.isValidTranslationUnitName(null, name)) {
+ if (CoreModel.isValidCHeaderUnitName(null, name) || CoreModel.isValidCXXHeaderUnitName(null, name))
descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_RESOURCE_H);
else if (CoreModel.isValidASMSourceUnitName(null, name))
descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_RESOURCE_A);
else
descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_RESOURCE);
-
- Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
+
+ Point size = useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
descriptor = new CElementImageDescriptor(descriptor, 0, size);
}
- } else if (!CCorePlugin.showSourceRootsAtTopOfProject() &&
- element instanceof IFolder && isParentOfSourceRoot(element)) {
+ } else if (!CCorePlugin.showSourceRootsAtTopOfProject() && element instanceof IFolder
+ && isParentOfSourceRoot(element)) {
descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE2_ROOT);
}
if (descriptor == null && element instanceof IAdaptable) {
- descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags);
+ descriptor = getWorkbenchImageDescriptor((IAdaptable) element, flags);
}
if (descriptor != null) {
return CUIPlugin.getImageDescriptorRegistry().get(descriptor);
@@ -175,7 +173,7 @@ public class CElementImageProvider {
folder = (IFolder) element;
if (folder == null)
return false;
-
+
ICProject cproject = CModelManager.getDefault().getCModel().findCProject(folder.getProject());
if (cproject != null) {
try {
@@ -189,120 +187,120 @@ public class CElementImageProvider {
} catch (CModelException e) {
}
}
-
+
return false;
}
public static ImageDescriptor getImageDescriptor(int type) {
switch (type) {
- case ICElement.C_VCONTAINER:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
+ case ICElement.C_VCONTAINER:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
- case ICElement.C_BINARY:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARY);
-
- case ICElement.C_ARCHIVE:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
-
- case ICElement.C_UNIT:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
-
- case ICElement.C_CCONTAINER:
- //return DESC_OBJ_FOLDER;
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CFOLDER);
-
- case ICElement.C_PROJECT:
- return DESC_OBJ_PROJECT;
-
- case ICElement.C_STRUCT:
- case ICElement.C_TEMPLATE_STRUCT:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT);
-
- case ICElement.C_CLASS:
- case ICElement.C_TEMPLATE_CLASS:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
-
- case ICElement.C_UNION:
- case ICElement.C_TEMPLATE_UNION:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION);
-
- case ICElement.C_TYPEDEF:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF);
-
- case ICElement.C_ENUMERATION:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION);
-
- case ICElement.C_ENUMERATOR:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATOR);
-
- case ICElement.C_FIELD:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_FIELD);
-
- case ICElement.C_VARIABLE:
- case ICElement.C_TEMPLATE_VARIABLE:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_VARIABLE);
-
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- case ICElement.C_TEMPLATE_METHOD:
- case ICElement.C_TEMPLATE_METHOD_DECLARATION:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_METHOD);
-
- case ICElement.C_FUNCTION:
- case ICElement.C_TEMPLATE_FUNCTION:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_FUNCTION);
-
- case ICElement.C_STRUCT_DECLARATION:
- case ICElement.C_CLASS_DECLARATION:
- case ICElement.C_UNION_DECLARATION:
- case ICElement.C_VARIABLE_DECLARATION:
- case ICElement.C_TEMPLATE_CLASS_DECLARATION:
- case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
- case ICElement.C_TEMPLATE_UNION_DECLARATION:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_VAR_DECLARATION);
-
- case ICElement.C_FUNCTION_DECLARATION:
- case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_DECLARATION);
-
- case ICElement.C_INCLUDE:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDE);
-
- case ICElement.C_MACRO:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
-
- case ICElement.C_NAMESPACE:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE);
-
- case ICElement.C_USING:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_USING);
-
- case ICElement.ASM_LABEL:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LABEL);
-}
+ case ICElement.C_BINARY:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARY);
+
+ case ICElement.C_ARCHIVE:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
+
+ case ICElement.C_UNIT:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
+
+ case ICElement.C_CCONTAINER:
+ //return DESC_OBJ_FOLDER;
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CFOLDER);
+
+ case ICElement.C_PROJECT:
+ return DESC_OBJ_PROJECT;
+
+ case ICElement.C_STRUCT:
+ case ICElement.C_TEMPLATE_STRUCT:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT);
+
+ case ICElement.C_CLASS:
+ case ICElement.C_TEMPLATE_CLASS:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
+
+ case ICElement.C_UNION:
+ case ICElement.C_TEMPLATE_UNION:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION);
+
+ case ICElement.C_TYPEDEF:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF);
+
+ case ICElement.C_ENUMERATION:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION);
+
+ case ICElement.C_ENUMERATOR:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATOR);
+
+ case ICElement.C_FIELD:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_FIELD);
+
+ case ICElement.C_VARIABLE:
+ case ICElement.C_TEMPLATE_VARIABLE:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_VARIABLE);
+
+ case ICElement.C_METHOD:
+ case ICElement.C_METHOD_DECLARATION:
+ case ICElement.C_TEMPLATE_METHOD:
+ case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_METHOD);
+
+ case ICElement.C_FUNCTION:
+ case ICElement.C_TEMPLATE_FUNCTION:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_FUNCTION);
+
+ case ICElement.C_STRUCT_DECLARATION:
+ case ICElement.C_CLASS_DECLARATION:
+ case ICElement.C_UNION_DECLARATION:
+ case ICElement.C_VARIABLE_DECLARATION:
+ case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+ case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+ case ICElement.C_TEMPLATE_UNION_DECLARATION:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_VAR_DECLARATION);
+
+ case ICElement.C_FUNCTION_DECLARATION:
+ case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_DECLARATION);
+
+ case ICElement.C_INCLUDE:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDE);
+
+ case ICElement.C_MACRO:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
+
+ case ICElement.C_NAMESPACE:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE);
+
+ case ICElement.C_USING:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_USING);
+
+ case ICElement.ASM_LABEL:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LABEL);
+ }
return null;
}
private boolean showOverlayIcons(int flags) {
return (flags & OVERLAY_ICONS) != 0;
}
-
-// private boolean useLightIcons(int flags) {
-// return (flags & LIGHT_TYPE_ICONS) != 0;
-// }
-
+
+ // private boolean useLightIcons(int flags) {
+ // return (flags & LIGHT_TYPE_ICONS) != 0;
+ // }
+
private boolean useSmallSize(int flags) {
return (flags & SMALL_ICONS) != 0;
}
-
+
/**
* Returns an image descriptor for a C element. The descriptor includes overlays, if specified.
*/
public ImageDescriptor getCImageDescriptor(ICElement element, int flags) {
- int adornmentFlags= computeCAdornmentFlags(element, flags);
- Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
+ int adornmentFlags = computeCAdornmentFlags(element, flags);
+ Point size = useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
ImageDescriptor desc = getBaseImageDescriptor(element, flags);
- if(desc != null) {
+ if (desc != null) {
return new CElementImageDescriptor(desc, adornmentFlags, size);
}
return null;
@@ -311,206 +309,205 @@ public class CElementImageProvider {
/**
* Returns an image descriptor for a IAdaptable. The descriptor includes overlays, if specified (only error ticks apply).
* Returns <code>null</code> if no image could be found.
- */
+ */
public ImageDescriptor getWorkbenchImageDescriptor(IAdaptable adaptable, int flags) {
- IWorkbenchAdapter wbAdapter= adaptable.getAdapter(IWorkbenchAdapter.class);
+ IWorkbenchAdapter wbAdapter = adaptable.getAdapter(IWorkbenchAdapter.class);
if (wbAdapter == null) {
return null;
}
- ImageDescriptor descriptor= wbAdapter.getImageDescriptor(adaptable);
+ ImageDescriptor descriptor = wbAdapter.getImageDescriptor(adaptable);
if (descriptor == null) {
return null;
}
- int adornmentFlags= computeBasicAdornmentFlags(adaptable, flags);
- Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
+ int adornmentFlags = computeBasicAdornmentFlags(adaptable, flags);
+ Point size = useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
return new CElementImageDescriptor(descriptor, adornmentFlags, size);
}
-
+
// ---- Computation of base image key -------------------------------------------------
-
+
/**
* Returns an image descriptor for a C element. This is the base image, no overlays.
*/
public ImageDescriptor getBaseImageDescriptor(ICElement celement, int renderFlags) {
// Allow contributed languages to provide icons for their extensions to the ICElement hierarchy
if (celement instanceof IContributedCElement)
- return ((IContributedCElement)celement).getAdapter(ImageDescriptor.class);
-
+ return ((IContributedCElement) celement).getAdapter(ImageDescriptor.class);
+
int type = celement.getElementType();
switch (type) {
- case ICElement.C_VCONTAINER:
- if (celement instanceof IBinaryModule) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARY);
- } else if (celement instanceof ILibraryReference) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNKNOWN);
- } else if (celement instanceof IIncludeReference) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
- } else if (celement instanceof IArchiveContainer) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVES_CONTAINER);
- } else if (celement instanceof IBinaryContainer) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARIES_CONTAINER);
- }
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
-
- case ICElement.C_BINARY: {
- IBinary bin = (IBinary)celement;
- if (bin.isExecutable()) {
- if (bin.hasDebug())
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CEXEC_DEBUG);
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CEXEC);
- } else if (bin.isSharedLib()) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SHLIB);
- } else if (bin.isCore()) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CORE);
- }
+ case ICElement.C_VCONTAINER:
+ if (celement instanceof IBinaryModule) {
return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARY);
+ } else if (celement instanceof ILibraryReference) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNKNOWN);
+ } else if (celement instanceof IIncludeReference) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
+ } else if (celement instanceof IArchiveContainer) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVES_CONTAINER);
+ } else if (celement instanceof IBinaryContainer) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARIES_CONTAINER);
}
-
- case ICElement.C_ARCHIVE:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
-
- case ICElement.C_UNIT: {
- ITranslationUnit unit = (ITranslationUnit)celement;
- if (unit.isHeaderUnit()) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
- } else if (unit.isSourceUnit()) {
- if (unit.isASMLanguage()) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_ASM);
- }
- }
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
+
+ case ICElement.C_BINARY: {
+ IBinary bin = (IBinary) celement;
+ if (bin.isExecutable()) {
+ if (bin.hasDebug())
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CEXEC_DEBUG);
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CEXEC);
+ } else if (bin.isSharedLib()) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SHLIB);
+ } else if (bin.isCore()) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CORE);
}
-
- case ICElement.C_CCONTAINER:
- if (celement instanceof ISourceRoot) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ROOT);
- }
- //return DESC_OBJ_FOLDER;
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CFOLDER);
-
- case ICElement.C_PROJECT:
- ICProject cp= (ICProject)celement;
- if (cp.getProject().isOpen()) {
- IProject project= cp.getProject();
- IWorkbenchAdapter adapter= project.getAdapter(IWorkbenchAdapter.class);
- if (adapter != null) {
- ImageDescriptor result= adapter.getImageDescriptor(project);
- if (result != null)
- return result;
- }
- return DESC_OBJ_PROJECT;
- }
- return DESC_OBJ_PROJECT_CLOSED;
-
- case ICElement.C_STRUCT:
- case ICElement.C_TEMPLATE_STRUCT:
- return getStructImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
-
- case ICElement.C_CLASS:
- case ICElement.C_TEMPLATE_CLASS:
- return getClassImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
-
- case ICElement.C_UNION:
- case ICElement.C_TEMPLATE_UNION:
- return getUnionImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
-
- case ICElement.C_TYPEDEF:
- return getTypedefImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
-
- case ICElement.C_ENUMERATION:
- return getEnumerationImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
-
- case ICElement.C_ENUMERATOR:
- return getEnumeratorImageDescriptor();
-
- case ICElement.C_FIELD:
- try {
- IField field = (IField)celement;
- ASTAccessVisibility visibility = field.getVisibility();
- return getFieldImageDescriptor(visibility);
- } catch (CModelException e) {
- return null;
- }
-
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- case ICElement.C_TEMPLATE_METHOD:
- case ICElement.C_TEMPLATE_METHOD_DECLARATION:
- try {
- IMethodDeclaration md= (IMethodDeclaration)celement;
- ASTAccessVisibility visibility =md.getVisibility();
- return getMethodImageDescriptor(visibility);
- } catch (CModelException e) {
- return null;
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARY);
+ }
+
+ case ICElement.C_ARCHIVE:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
+
+ case ICElement.C_UNIT: {
+ ITranslationUnit unit = (ITranslationUnit) celement;
+ if (unit.isHeaderUnit()) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+ } else if (unit.isSourceUnit()) {
+ if (unit.isASMLanguage()) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_ASM);
}
- case ICElement.C_VARIABLE:
- case ICElement.C_TEMPLATE_VARIABLE:
- return getVariableImageDescriptor();
-
- case ICElement.C_FUNCTION:
- case ICElement.C_TEMPLATE_FUNCTION:
- return getFunctionImageDescriptor();
-
- case ICElement.C_STRUCT_DECLARATION:
- case ICElement.C_CLASS_DECLARATION:
- case ICElement.C_UNION_DECLARATION:
- case ICElement.C_VARIABLE_DECLARATION:
- case ICElement.C_TEMPLATE_CLASS_DECLARATION:
- case ICElement.C_TEMPLATE_UNION_DECLARATION:
- case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
- return getVariableDeclarationImageDescriptor();
-
- case ICElement.C_FUNCTION_DECLARATION:
- case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
- return getFunctionDeclarationImageDescriptor();
-
- case ICElement.C_INCLUDE:
- return getIncludeImageDescriptor();
-
- case ICElement.C_MACRO:
- return getMacroImageDescriptor();
-
- case ICElement.C_NAMESPACE:
- return getNamespaceImageDescriptor();
-
- case ICElement.C_USING:
- return getUsingImageDescriptor();
-
- default:
- return getImageDescriptor(type);
+ }
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
}
- }
+ case ICElement.C_CCONTAINER:
+ if (celement instanceof ISourceRoot) {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ROOT);
+ }
+ //return DESC_OBJ_FOLDER;
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CFOLDER);
+
+ case ICElement.C_PROJECT:
+ ICProject cp = (ICProject) celement;
+ if (cp.getProject().isOpen()) {
+ IProject project = cp.getProject();
+ IWorkbenchAdapter adapter = project.getAdapter(IWorkbenchAdapter.class);
+ if (adapter != null) {
+ ImageDescriptor result = adapter.getImageDescriptor(project);
+ if (result != null)
+ return result;
+ }
+ return DESC_OBJ_PROJECT;
+ }
+ return DESC_OBJ_PROJECT_CLOSED;
+
+ case ICElement.C_STRUCT:
+ case ICElement.C_TEMPLATE_STRUCT:
+ return getStructImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+
+ case ICElement.C_CLASS:
+ case ICElement.C_TEMPLATE_CLASS:
+ return getClassImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+
+ case ICElement.C_UNION:
+ case ICElement.C_TEMPLATE_UNION:
+ return getUnionImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+
+ case ICElement.C_TYPEDEF:
+ return getTypedefImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+
+ case ICElement.C_ENUMERATION:
+ return getEnumerationImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+
+ case ICElement.C_ENUMERATOR:
+ return getEnumeratorImageDescriptor();
+
+ case ICElement.C_FIELD:
+ try {
+ IField field = (IField) celement;
+ ASTAccessVisibility visibility = field.getVisibility();
+ return getFieldImageDescriptor(visibility);
+ } catch (CModelException e) {
+ return null;
+ }
+
+ case ICElement.C_METHOD:
+ case ICElement.C_METHOD_DECLARATION:
+ case ICElement.C_TEMPLATE_METHOD:
+ case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+ try {
+ IMethodDeclaration md = (IMethodDeclaration) celement;
+ ASTAccessVisibility visibility = md.getVisibility();
+ return getMethodImageDescriptor(visibility);
+ } catch (CModelException e) {
+ return null;
+ }
+ case ICElement.C_VARIABLE:
+ case ICElement.C_TEMPLATE_VARIABLE:
+ return getVariableImageDescriptor();
+
+ case ICElement.C_FUNCTION:
+ case ICElement.C_TEMPLATE_FUNCTION:
+ return getFunctionImageDescriptor();
+
+ case ICElement.C_STRUCT_DECLARATION:
+ case ICElement.C_CLASS_DECLARATION:
+ case ICElement.C_UNION_DECLARATION:
+ case ICElement.C_VARIABLE_DECLARATION:
+ case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+ case ICElement.C_TEMPLATE_UNION_DECLARATION:
+ case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+ return getVariableDeclarationImageDescriptor();
+
+ case ICElement.C_FUNCTION_DECLARATION:
+ case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+ return getFunctionDeclarationImageDescriptor();
+
+ case ICElement.C_INCLUDE:
+ return getIncludeImageDescriptor();
+
+ case ICElement.C_MACRO:
+ return getMacroImageDescriptor();
+
+ case ICElement.C_NAMESPACE:
+ return getNamespaceImageDescriptor();
+
+ case ICElement.C_USING:
+ return getUsingImageDescriptor();
+
+ default:
+ return getImageDescriptor(type);
+ }
+ }
// ---- Methods to compute the adornments flags ---------------------------------
-
+
private int computeCAdornmentFlags(ICElement element, int renderFlags) {
-
- int flags= computeBasicAdornmentFlags(element, renderFlags);
+
+ int flags = computeBasicAdornmentFlags(element, renderFlags);
if (showOverlayIcons(renderFlags)) {
try {
if (element instanceof IDeclaration) {
IDeclaration decl = (IDeclaration) element;
- if(decl.isStatic()){
+ if (decl.isStatic()) {
flags |= CElementImageDescriptor.STATIC;
}
- if(decl.isConst()){
+ if (decl.isConst()) {
flags |= CElementImageDescriptor.CONSTANT;
}
- if(decl.isVolatile()){
+ if (decl.isVolatile()) {
flags |= CElementImageDescriptor.VOLATILE;
}
- if(element instanceof ITemplate){
+ if (element instanceof ITemplate) {
flags |= CElementImageDescriptor.TEMPLATE;
}
- }
+ }
if (element instanceof ISourceReference) {
- ISourceReference sref= (ISourceReference) element;
+ ISourceReference sref = (ISourceReference) element;
if (!sref.isActive()) {
flags |= CElementImageDescriptor.INACTIVE;
} else {
if (element instanceof IInclude) {
- IInclude include= (IInclude) element;
+ IInclude include = (IInclude) element;
if (!include.isResolved()) {
flags |= CElementImageDescriptor.WARNING;
}
@@ -522,129 +519,134 @@ public class CElementImageProvider {
}
return flags;
}
-
+
private int computeBasicAdornmentFlags(Object element, int renderFlags) {
- int flags= 0;
- if ((renderFlags & OVERLAY_ERROR) !=0) {
+ int flags = 0;
+ if ((renderFlags & OVERLAY_ERROR) != 0) {
flags |= CElementImageDescriptor.ERROR;
}
- if ((renderFlags & OVERLAY_WARNING) !=0) {
+ if ((renderFlags & OVERLAY_WARNING) != 0) {
flags |= CElementImageDescriptor.WARNING;
}
-// if ((renderFlags & OVERLAY_OVERRIDE) !=0) {
-// flags |= CElementImageDescriptor.OVERRIDES;
-// }
-// if ((renderFlags & OVERLAY_IMPLEMENTS) !=0) {
-// flags |= CElementImageDescriptor.IMPLEMENTS;
-// }
+ // if ((renderFlags & OVERLAY_OVERRIDE) !=0) {
+ // flags |= CElementImageDescriptor.OVERRIDES;
+ // }
+ // if ((renderFlags & OVERLAY_IMPLEMENTS) !=0) {
+ // flags |= CElementImageDescriptor.IMPLEMENTS;
+ // }
if ((renderFlags & OVERLAY_EXTERNAL) != 0) {
flags |= CElementImageDescriptor.EXTERNAL_FILE;
}
- return flags;
- }
-
+ return flags;
+ }
+
public void dispose() {
}
- public static ImageDescriptor getStructImageDescriptor(){
+ public static ImageDescriptor getStructImageDescriptor() {
return getStructImageDescriptor(false);
}
- public static ImageDescriptor getStructImageDescriptor(boolean alt){
- return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT);
+ public static ImageDescriptor getStructImageDescriptor(boolean alt) {
+ return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT_ALT)
+ : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT);
}
-
- public static ImageDescriptor getClassImageDescriptor(){
+
+ public static ImageDescriptor getClassImageDescriptor() {
return getClassImageDescriptor(false);
}
- public static ImageDescriptor getClassImageDescriptor(boolean alt){
- return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
+ public static ImageDescriptor getClassImageDescriptor(boolean alt) {
+ return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS_ALT)
+ : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
}
- public static ImageDescriptor getUnionImageDescriptor(){
+ public static ImageDescriptor getUnionImageDescriptor() {
return getUnionImageDescriptor(false);
}
- public static ImageDescriptor getUnionImageDescriptor(boolean alt){
- return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION);
+ public static ImageDescriptor getUnionImageDescriptor(boolean alt) {
+ return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION_ALT)
+ : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION);
}
- public static ImageDescriptor getTypedefImageDescriptor(){
+ public static ImageDescriptor getTypedefImageDescriptor() {
return getTypedefImageDescriptor(false);
}
- public static ImageDescriptor getTypedefImageDescriptor(boolean alt){
- return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF);
+ public static ImageDescriptor getTypedefImageDescriptor(boolean alt) {
+ return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF_ALT)
+ : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF);
}
-
- public static ImageDescriptor getEnumerationImageDescriptor(){
+
+ public static ImageDescriptor getEnumerationImageDescriptor() {
return getEnumerationImageDescriptor(false);
}
- public static ImageDescriptor getEnumerationImageDescriptor(boolean alt){
- return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION);
+ public static ImageDescriptor getEnumerationImageDescriptor(boolean alt) {
+ return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION_ALT)
+ : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION);
}
-
- public static ImageDescriptor getEnumeratorImageDescriptor(){
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATOR);
+
+ public static ImageDescriptor getEnumeratorImageDescriptor() {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATOR);
}
public static ImageDescriptor getFieldImageDescriptor(ASTAccessVisibility visibility) {
if (visibility == ASTAccessVisibility.PUBLIC)
return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_FIELD);
- if( visibility == ASTAccessVisibility.PROTECTED)
+ if (visibility == ASTAccessVisibility.PROTECTED)
return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PROTECTED_FIELD);
-
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PRIVATE_FIELD);
+
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PRIVATE_FIELD);
}
public static ImageDescriptor getMethodImageDescriptor(ASTAccessVisibility visibility) {
- if( visibility == ASTAccessVisibility.PUBLIC)
+ if (visibility == ASTAccessVisibility.PUBLIC)
return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_METHOD);
- if( visibility == ASTAccessVisibility.PROTECTED)
+ if (visibility == ASTAccessVisibility.PROTECTED)
return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PROTECTED_METHOD);
-
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PRIVATE_METHOD);
+
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PRIVATE_METHOD);
}
- public static ImageDescriptor getVariableImageDescriptor(){
+ public static ImageDescriptor getVariableImageDescriptor() {
return getImageDescriptor(ICElement.C_VARIABLE);
}
- public static ImageDescriptor getLocalVariableImageDescriptor(){
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LOCAL_VARIABLE);
+ public static ImageDescriptor getLocalVariableImageDescriptor() {
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LOCAL_VARIABLE);
}
-
- public static ImageDescriptor getFunctionImageDescriptor(){
+
+ public static ImageDescriptor getFunctionImageDescriptor() {
return getImageDescriptor(ICElement.C_FUNCTION);
}
- public static ImageDescriptor getVariableDeclarationImageDescriptor(){
+ public static ImageDescriptor getVariableDeclarationImageDescriptor() {
return getImageDescriptor(ICElement.C_VARIABLE_DECLARATION);
}
- public static ImageDescriptor getFunctionDeclarationImageDescriptor(){
+ public static ImageDescriptor getFunctionDeclarationImageDescriptor() {
return getImageDescriptor(ICElement.C_FUNCTION_DECLARATION);
}
- public static ImageDescriptor getIncludeImageDescriptor(){
+ public static ImageDescriptor getIncludeImageDescriptor() {
return getImageDescriptor(ICElement.C_INCLUDE);
}
- public static ImageDescriptor getMacroImageDescriptor(){
+ public static ImageDescriptor getMacroImageDescriptor() {
return getImageDescriptor(ICElement.C_MACRO);
}
- public static ImageDescriptor getNamespaceImageDescriptor(){
+ public static ImageDescriptor getNamespaceImageDescriptor() {
return getImageDescriptor(ICElement.C_NAMESPACE);
}
- public static ImageDescriptor getUsingImageDescriptor(){
+ public static ImageDescriptor getUsingImageDescriptor() {
return getImageDescriptor(ICElement.C_USING);
}
- public static ImageDescriptor getKeywordImageDescriptor(){
+ public static ImageDescriptor getKeywordImageDescriptor() {
return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_KEYWORD);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java
index 2b09ebc71a2..f063bfa755b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java
@@ -96,7 +96,7 @@ public class CElementLabelComposer {
private final StringBuilder fStringBuilder;
public FlexibleStringBuffer(StringBuilder stringBuilder) {
- fStringBuilder= stringBuilder;
+ fStringBuilder = stringBuilder;
}
@Override
@@ -131,7 +131,7 @@ public class CElementLabelComposer {
private final StyledString fStyledString;
public FlexibleStyledString(StyledString stringBuffer) {
- fStyledString= stringBuffer;
+ fStyledString = stringBuffer;
}
@Override
@@ -162,11 +162,9 @@ public class CElementLabelComposer {
}
}
-
- private static final Styler QUALIFIER_STYLE= StyledString.QUALIFIER_STYLER;
+ private static final Styler QUALIFIER_STYLE = StyledString.QUALIFIER_STYLER;
//private static final Styler COUNTER_STYLE= StyledString.COUNTER_STYLER;
- private static final Styler DECORATIONS_STYLE= StyledString.DECORATIONS_STYLER;
-
+ private static final Styler DECORATIONS_STYLE = StyledString.DECORATIONS_STYLER;
private final FlexibleBuffer fBuffer;
@@ -176,7 +174,7 @@ public class CElementLabelComposer {
* @param buffer the buffer
*/
public CElementLabelComposer(FlexibleBuffer buffer) {
- fBuffer= buffer;
+ fBuffer = buffer;
}
/**
@@ -203,22 +201,22 @@ public class CElementLabelComposer {
* @param flags any of the flags (M_*, F_*, ROOT_*, etc.) defined in this class
*/
public void appendElementLabel(ICElement element, long flags) {
- int type= element.getElementType();
- ISourceRoot root= null;
+ int type = element.getElementType();
+ ISourceRoot root = null;
- if (type != ICElement.C_MODEL && type != ICElement.C_PROJECT &&
- !(type == ICElement.C_CCONTAINER && element instanceof ISourceRoot)) {
- root= getSourceRoot(element);
+ if (type != ICElement.C_MODEL && type != ICElement.C_PROJECT
+ && !(type == ICElement.C_CCONTAINER && element instanceof ISourceRoot)) {
+ root = getSourceRoot(element);
}
if (root != null && getFlag(flags, CElementLabels.PREPEND_ROOT_PATH)) {
getSourceRootLabel(root, CElementLabels.ROOT_QUALIFIED);
fBuffer.append(CElementLabels.CONCAT_STRING);
- }
+ }
switch (type) {
case ICElement.C_MACRO:
appendMacroLabel((IMacro) element, flags);
break;
- case ICElement.C_METHOD :
+ case ICElement.C_METHOD:
case ICElement.C_METHOD_DECLARATION:
case ICElement.C_TEMPLATE_METHOD:
case ICElement.C_TEMPLATE_METHOD_DECLARATION:
@@ -230,7 +228,7 @@ public class CElementLabelComposer {
case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
appendFunctionLabel((IFunctionDeclaration) element, flags);
break;
- case ICElement.C_FIELD :
+ case ICElement.C_FIELD:
appendFieldLabel((IField) element, flags);
break;
case ICElement.C_VARIABLE:
@@ -254,11 +252,11 @@ public class CElementLabelComposer {
appendTypeLabel(element, flags);
break;
case ICElement.C_TYPEDEF:
- appendTypeDefLabel((ITypeDef)element, flags);
+ appendTypeDefLabel((ITypeDef) element, flags);
break;
- case ICElement.C_UNIT:
+ case ICElement.C_UNIT:
appendTranslationUnitLabel((ITranslationUnit) element, flags);
- break;
+ break;
case ICElement.C_CCONTAINER:
ICContainer container = (ICContainer) element;
if (container instanceof ISourceRoot) {
@@ -276,7 +274,7 @@ public class CElementLabelComposer {
}
if (root != null && getFlag(flags, CElementLabels.APPEND_ROOT_PATH)) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
getSourceRootLabel(root, CElementLabels.ROOT_QUALIFIED);
if (getFlag(flags, CElementLabels.COLORIZE)) {
@@ -285,7 +283,7 @@ public class CElementLabelComposer {
}
if (element instanceof IBinary) {
- IBinary bin = (IBinary)element;
+ IBinary bin = (IBinary) element;
fBuffer.append(" - [" + bin.getCPU() + "/" + (bin.isLittleEndian() ? "le" : "be") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
}
@@ -304,9 +302,9 @@ public class CElementLabelComposer {
}
if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
- IPath path= macro.getPath();
+ IPath path = macro.getPath();
if (path != null) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
fBuffer.append(path.toString());
if (getFlag(flags, CElementLabels.COLORIZE)) {
@@ -333,7 +331,8 @@ public class CElementLabelComposer {
if (getFlag(flags, CElementLabels.M_FULLY_QUALIFIED)) {
ICElement parent = method.getParent();
if (parent != null && parent.exists() && !(parent instanceof ITranslationUnit)) {
- appendTypeLabel(parent, CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_ARGUMENTS));
+ appendTypeLabel(parent,
+ CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_ARGUMENTS));
fBuffer.append("::"); //$NON-NLS-1$
}
}
@@ -346,7 +345,7 @@ public class CElementLabelComposer {
// template parameters
if (method instanceof ITemplate) {
- appendTemplateParameters((ITemplate)method, flags);
+ appendTemplateParameters((ITemplate) method, flags);
}
// parameters
@@ -356,7 +355,7 @@ public class CElementLabelComposer {
String[] types = method.getParameterTypes();
if (types != null) {
- for (int i= 0; i < types.length; i++) {
+ for (int i = 0; i < types.length; i++) {
if (i > 0) {
fBuffer.append(CElementLabels.COMMA_STRING);
}
@@ -371,7 +370,7 @@ public class CElementLabelComposer {
String[] types = method.getExceptions();
if (types.length > 0) {
fBuffer.append(" throw ("); //$NON-NLS-1$
- for (int i= 0; i < types.length; i++) {
+ for (int i = 0; i < types.length; i++) {
if (i > 0) {
fBuffer.append(CElementLabels.COMMA_STRING);
}
@@ -381,31 +380,33 @@ public class CElementLabelComposer {
}
}
- if (getFlag(flags, CElementLabels.M_APP_RETURNTYPE) && method.exists() && !method.isConstructor() && !method.isDestructor()) {
- final String typeName= method.getReturnType();
+ if (getFlag(flags, CElementLabels.M_APP_RETURNTYPE) && method.exists() && !method.isConstructor()
+ && !method.isDestructor()) {
+ final String typeName = method.getReturnType();
if (typeName != null && typeName.length() > 0) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.DECL_STRING);
fBuffer.append(typeName);
if (getFlag(flags, CElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
}
}
- }
+ }
// post qualification
if (getFlag(flags, CElementLabels.M_POST_QUALIFIED)) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
- appendTypeLabel(method.getParent(), CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_ARGUMENTS));
+ appendTypeLabel(method.getParent(),
+ CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_ARGUMENTS));
if (getFlag(flags, CElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
}
if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
- IPath path= method.getPath();
+ IPath path = method.getPath();
if (path != null) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
fBuffer.append(path.toString());
if (getFlag(flags, CElementLabels.COLORIZE)) {
@@ -421,7 +422,7 @@ public class CElementLabelComposer {
/**
* Strip any qualifier from the given name.
- *
+ *
* @param elementName
* @return a "simple" name
*/
@@ -434,18 +435,18 @@ public class CElementLabelComposer {
}
private void appendTemplateParameters(ITemplate template, long flags) {
- String[] args= null;
+ String[] args = null;
if (getFlag(flags, CElementLabels.TEMPLATE_ARGUMENTS)) {
args = template.getTemplateArguments();
} else if (getFlag(flags, CElementLabels.TEMPLATE_PARAMETERS)) {
- args= template.getTemplateParameterTypes();
+ args = template.getTemplateParameterTypes();
} else {
return;
}
fBuffer.append('<');
if (args != null) {
- for (int i= 0; i < args.length; i++) {
+ for (int i = 0; i < args.length; i++) {
if (i > 0) {
fBuffer.append(',');
}
@@ -472,7 +473,8 @@ public class CElementLabelComposer {
if (getFlag(flags, CElementLabels.F_FULLY_QUALIFIED)) {
ICElement parent = field.getParent();
if (parent != null && parent.exists()) {
- appendTypeLabel(parent, CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_PARAMETERS));
+ appendTypeLabel(parent,
+ CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_PARAMETERS));
fBuffer.append("::"); //$NON-NLS-1$
}
}
@@ -484,27 +486,28 @@ public class CElementLabelComposer {
}
if (getFlag(flags, CElementLabels.F_APP_TYPE_SIGNATURE) && field.exists()) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.DECL_STRING);
- fBuffer.append(field.getTypeName());
+ fBuffer.append(field.getTypeName());
if (getFlag(flags, CElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
}
- }
+ }
// post qualification
if (getFlag(flags, CElementLabels.F_POST_QUALIFIED)) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
- appendTypeLabel(field.getParent(), CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_PARAMETERS));
+ appendTypeLabel(field.getParent(),
+ CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_PARAMETERS));
if (getFlag(flags, CElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
}
if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
- IPath path= field.getPath();
+ IPath path = field.getPath();
if (path != null) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
fBuffer.append(path.toString());
if (getFlag(flags, CElementLabels.COLORIZE)) {
@@ -543,19 +546,19 @@ public class CElementLabelComposer {
fBuffer.append(var.getElementName());
if (getFlag(flags, CElementLabels.F_APP_TYPE_SIGNATURE) && var.exists()) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.DECL_STRING);
- fBuffer.append(var.getTypeName());
+ fBuffer.append(var.getTypeName());
if (getFlag(flags, CElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
}
- }
+ }
// post qualification
if (getFlag(flags, CElementLabels.F_POST_QUALIFIED)) {
ICElement parent = var.getParent();
if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
appendTypeLabel(var.getParent(), CElementLabels.T_FULLY_QUALIFIED);
if (getFlag(flags, CElementLabels.COLORIZE)) {
@@ -564,8 +567,8 @@ public class CElementLabelComposer {
}
}
if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
- int offset= fBuffer.length();
- IPath path= var.getPath();
+ int offset = fBuffer.length();
+ IPath path = var.getPath();
if (path != null) {
fBuffer.append(CElementLabels.CONCAT_STRING);
fBuffer.append(path.toString());
@@ -605,8 +608,8 @@ public class CElementLabelComposer {
}
}
if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
- int offset= fBuffer.length();
- IPath path= var.getPath();
+ int offset = fBuffer.length();
+ IPath path = var.getPath();
if (path != null) {
fBuffer.append(CElementLabels.CONCAT_STRING);
fBuffer.append(path.toString());
@@ -642,7 +645,7 @@ public class CElementLabelComposer {
// template parameters
if (func instanceof ITemplate) {
- appendTemplateParameters((ITemplate)func, flags);
+ appendTemplateParameters((ITemplate) func, flags);
}
// parameters
@@ -652,7 +655,7 @@ public class CElementLabelComposer {
String[] types = func.getParameterTypes();
if (types != null) {
- for (int i= 0; i < types.length; i++) {
+ for (int i = 0; i < types.length; i++) {
if (i > 0) {
fBuffer.append(CElementLabels.COMMA_STRING);
}
@@ -667,7 +670,7 @@ public class CElementLabelComposer {
String[] types = func.getExceptions();
if (types.length > 0) {
fBuffer.append(" throw ("); //$NON-NLS-1$
- for (int i= 0; i < types.length; i++) {
+ for (int i = 0; i < types.length; i++) {
if (i > 0) {
fBuffer.append(CElementLabels.COMMA_STRING);
}
@@ -678,16 +681,16 @@ public class CElementLabelComposer {
}
if (getFlag(flags, CElementLabels.M_APP_RETURNTYPE) && func.exists()) {
- final String typeName= func.getReturnType();
+ final String typeName = func.getReturnType();
if (typeName != null && typeName.length() > 0) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.DECL_STRING);
fBuffer.append(typeName);
if (getFlag(flags, CElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
}
}
- }
+ }
// post qualification
if (getFlag(flags, CElementLabels.M_POST_QUALIFIED)) {
@@ -698,9 +701,9 @@ public class CElementLabelComposer {
}
}
if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
- IPath path= func.getPath();
+ IPath path = func.getPath();
if (path != null) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
fBuffer.append(path.toString());
if (getFlag(flags, CElementLabels.COLORIZE)) {
@@ -734,16 +737,16 @@ public class CElementLabelComposer {
fBuffer.append(typedef.getElementName());
if (getFlag(flags, CElementLabels.F_APP_TYPE_SIGNATURE) && typedef.exists()) {
- String typeName= typedef.getTypeName();
+ String typeName = typedef.getTypeName();
if (typeName != null && typeName.length() > 0) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.DECL_STRING);
fBuffer.append(typeName);
if (getFlag(flags, CElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
}
}
- }
+ }
// post qualification
if (getFlag(flags, CElementLabels.F_POST_QUALIFIED)) {
@@ -754,9 +757,9 @@ public class CElementLabelComposer {
}
}
if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
- IPath path= typedef.getPath();
+ IPath path = typedef.getPath();
if (path != null) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
fBuffer.append(path.toString());
if (getFlag(flags, CElementLabels.COLORIZE)) {
@@ -785,8 +788,8 @@ public class CElementLabelComposer {
}
private void appendFolderLabel(ICContainer container, long flags) {
- IResource resource= container.getResource();
- boolean rootQualified= getFlag(flags, CElementLabels.ROOT_QUALIFIED);
+ IResource resource = container.getResource();
+ boolean rootQualified = getFlag(flags, CElementLabels.ROOT_QUALIFIED);
if (rootQualified) {
fBuffer.append(container.getPath().makeRelative().toString());
} else {
@@ -814,13 +817,13 @@ public class CElementLabelComposer {
* @param tu a translation unit
* @param flags any of the TU_* flags
*/
- public void appendTranslationUnitLabel(ITranslationUnit tu, long flags) {
- IResource r= tu.getResource();
+ public void appendTranslationUnitLabel(ITranslationUnit tu, long flags) {
+ IResource r = tu.getResource();
IPath path;
if (r != null) {
- path= r.getFullPath().makeRelative();
+ path = r.getFullPath().makeRelative();
} else {
- path= tu.getPath();
+ path = tu.getPath();
}
if (path == null) {
@@ -845,8 +848,8 @@ public class CElementLabelComposer {
*/
private void appendTypeLabel(ICElement elem, long flags) {
if (getFlag(flags, CElementLabels.T_FULLY_QUALIFIED)) {
- ICElement parent= elem.getParent();
- boolean isQualifier= true;
+ ICElement parent = elem.getParent();
+ boolean isQualifier = true;
if (parent != null) {
switch (parent.getElementType()) {
case ICElement.C_ARCHIVE:
@@ -856,31 +859,31 @@ public class CElementLabelComposer {
case ICElement.C_PROJECT:
case ICElement.C_UNIT:
case ICElement.C_VCONTAINER:
- isQualifier= false;
+ isQualifier = false;
break;
}
}
// types cannot be qualified in plain c
if (isQualifier && !isCLanguage(parent)) {
- long qflags= flags & ~CElementLabels.MF_POST_FILE_QUALIFIED;
+ long qflags = flags & ~CElementLabels.MF_POST_FILE_QUALIFIED;
appendTypeLabel(parent, qflags);
fBuffer.append("::"); //$NON-NLS-1$
}
}
- String typeName= elem.getElementName();
+ String typeName = elem.getElementName();
if (typeName.length() == 0) { // anonymous
- typeName = CoreModelMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$
+ typeName = CoreModelMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$
}
fBuffer.append(typeName);
if (getFlag(flags, CElementLabels.T_INHERITANCE) && elem instanceof IInheritance) {
- IInheritance inheritance= (IInheritance)elem;
- String[] superclassNames= inheritance.getSuperClassesNames();
+ IInheritance inheritance = (IInheritance) elem;
+ String[] superclassNames = inheritance.getSuperClassesNames();
if (superclassNames != null && superclassNames.length > 0) {
fBuffer.append(CElementLabels.DECL_STRING);
for (int i = 0; i < superclassNames.length; i++) {
- if (i> 0) {
+ if (i > 0) {
fBuffer.append(CElementLabels.COMMA_STRING);
}
String superclass = superclassNames[i];
@@ -892,13 +895,13 @@ public class CElementLabelComposer {
// template parameters
if (elem instanceof ITemplate) {
- appendTemplateParameters((ITemplate)elem, flags);
+ appendTemplateParameters((ITemplate) elem, flags);
}
if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
- IPath path= elem.getPath();
+ IPath path = elem.getPath();
if (path != null) {
- int offset= fBuffer.length();
+ int offset = fBuffer.length();
fBuffer.append(CElementLabels.CONCAT_STRING);
fBuffer.append(path.toString());
if (getFlag(flags, CElementLabels.COLORIZE)) {
@@ -910,7 +913,7 @@ public class CElementLabelComposer {
private static boolean isCLanguage(ICElement elem) {
while (elem != null) {
- elem= elem.getParent();
+ elem = elem.getParent();
if (elem instanceof ITranslationUnit) {
return ((ITranslationUnit) elem).isCLanguage();
}
@@ -920,7 +923,7 @@ public class CElementLabelComposer {
/**
* Convert an <code>ASTAccessVisibility</code> into its string representation.
- *
+ *
* @param access
* @return "public", "protected" or "private"
*/
@@ -944,7 +947,7 @@ public class CElementLabelComposer {
ICElement root = element;
while (root != null) {
if (root instanceof ISourceRoot)
- return (ISourceRoot)root;
+ return (ISourceRoot) root;
ICElement parent = root.getAncestor(ICElement.C_CCONTAINER);
if (parent == root)
return null;
@@ -959,10 +962,10 @@ public class CElementLabelComposer {
* if the given root doesn't have an underlying resource.
*/
public static boolean isReferenced(ISourceRoot root) {
- IResource resource= root.getResource();
+ IResource resource = root.getResource();
if (resource != null) {
- IProject project= resource.getProject();
- IProject container= root.getCProject().getProject();
+ IProject project = resource.getProject();
+ IProject container = root.getCProject().getProject();
return !container.equals(project);
}
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java
index d54c516af07..fded42b05e5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java
@@ -36,7 +36,7 @@ import org.eclipse.cdt.internal.core.model.CoreModelMessages;
import org.eclipse.cdt.internal.corext.util.Strings;
/*
- * This class is basically a clone of org.eclipse.cdt.core.model.util.CElementLabels
+ * This class is basically a clone of org.eclipse.cdt.core.model.util.CElementLabels
* (refer to bug 325799 for the reasoning)
*/
@@ -48,197 +48,198 @@ public class CElementLabels {
* Method names contain parameter types.
* e.g. <code>foo(int)</code>
*/
- public final static long M_PARAMETER_TYPES= 1L << 0;
+ public final static long M_PARAMETER_TYPES = 1L << 0;
/**
* Method definition names without qualifier.
* e.g. <code>foo(int)</code>
*/
- public final static long M_SIMPLE_NAME= 1L << 1;
+ public final static long M_SIMPLE_NAME = 1L << 1;
/**
* Method names contain thrown exceptions.
* e.g. <code>foo throw (IOException)</code>
*/
- public final static long M_EXCEPTIONS= 1L << 2;
-
+ public final static long M_EXCEPTIONS = 1L << 2;
+
/**
* Method names contain return type (appended)
* e.g. <code>foo : int</code>
*/
- public final static long M_APP_RETURNTYPE= 1L << 3;
+ public final static long M_APP_RETURNTYPE = 1L << 3;
/**
* Method names contain return type (appended)
* e.g. <code>int foo</code>
*/
- public final static long M_PRE_RETURNTYPE= 1L << 4;
+ public final static long M_PRE_RETURNTYPE = 1L << 4;
/**
* Method names are fully qualified.
* e.g. <code>ClassName::size</code>
*/
- public final static long M_FULLY_QUALIFIED= 1L << 5;
+ public final static long M_FULLY_QUALIFIED = 1L << 5;
/**
* Method names are post qualified.
* e.g. <code>size - ClassName</code>
*/
- public final static long M_POST_QUALIFIED= 1L << 6;
+ public final static long M_POST_QUALIFIED = 1L << 6;
/**
* Templates are qualified with template parameters.
* e.g. <code>ClassName<T></code>
*/
- public final static long TEMPLATE_PARAMETERS= 1L << 7;
+ public final static long TEMPLATE_PARAMETERS = 1L << 7;
/**
* Static field names without qualifier.
* e.g. <code>fHello</code>
*/
- public final static long F_SIMPLE_NAME= 1L << 8;
+ public final static long F_SIMPLE_NAME = 1L << 8;
/**
* Field names contain the declared type (appended)
* e.g. <code>fHello: int</code>
*/
- public final static long F_APP_TYPE_SIGNATURE= 1L << 9;
+ public final static long F_APP_TYPE_SIGNATURE = 1L << 9;
/**
* Field names contain the declared type (prepended)
* e.g. <code>int fHello</code>
*/
- public final static long F_PRE_TYPE_SIGNATURE= 1L << 10;
+ public final static long F_PRE_TYPE_SIGNATURE = 1L << 10;
/**
* Fields names are fully qualified.
* e.g. <code>ClassName::fField</code>
*/
- public final static long F_FULLY_QUALIFIED= 1L << 11;
+ public final static long F_FULLY_QUALIFIED = 1L << 11;
/**
* Fields names are post qualified.
* e.g. <code>fField - ClassName</code>
*/
- public final static long F_POST_QUALIFIED= 1L << 12;
+ public final static long F_POST_QUALIFIED = 1L << 12;
/**
* Type names are fully qualified.
* e.g. <code>namespace::ClassName</code>
*/
- public final static long T_FULLY_QUALIFIED= 1L << 13;
+ public final static long T_FULLY_QUALIFIED = 1L << 13;
/**
* Instances and specializations are qualified with arguments, templates with template parameter names.
* The flag overrides {@link #TEMPLATE_PARAMETERS}.
*/
- public final static long TEMPLATE_ARGUMENTS= 1L << 14;
+ public final static long TEMPLATE_ARGUMENTS = 1L << 14;
/**
* Append base class specifications to type names.
* e.g. <code>MyClass : public BaseClass</code>
*/
- public final static long T_INHERITANCE= 1L << 16;
+ public final static long T_INHERITANCE = 1L << 16;
/**
* Translation unit names contain the full path.
* e.g. <code>/MyProject/src/ClassName.cpp</code>
- */
- public final static long TU_QUALIFIED= 1L << 20;
+ */
+ public final static long TU_QUALIFIED = 1L << 20;
/**
* Translation unit names are post qualified with their path.
* e.g. <code>ClassName.cpp - /MyProject/src</code>
- */
- public final static long TU_POST_QUALIFIED= 1L << 21;
+ */
+ public final static long TU_POST_QUALIFIED = 1L << 21;
/**
* Source roots contain the project name (prepended).
* e.g. <code>MyProject/src</code>
*/
- public final static long ROOT_QUALIFIED= 1L << 25;
+ public final static long ROOT_QUALIFIED = 1L << 25;
/**
* Source roots contain the project name (appended).
* e.g. <code>src - MyProject</code>
*/
- public final static long ROOT_POST_QUALIFIED= 1L << 26;
+ public final static long ROOT_POST_QUALIFIED = 1L << 26;
/**
* Add source root path.
* e.g. <code>func() - MyProject/src</code>
* Option only applies to getElementLabel
*/
- public final static long APPEND_ROOT_PATH= 1L << 27;
+ public final static long APPEND_ROOT_PATH = 1L << 27;
/**
* Prepend source root path.
* e.g. <code>MyProject/src - func()</code>
* Option only applies to getElementLabel
*/
- public final static long PREPEND_ROOT_PATH= 1L << 28;
+ public final static long PREPEND_ROOT_PATH = 1L << 28;
/**
* Post qualify container project. For example
* <code>folder - MyProject</code> if the folder is in project MyProject.
*/
- public final static long PROJECT_POST_QUALIFIED= 1L << 30;
+ public final static long PROJECT_POST_QUALIFIED = 1L << 30;
/**
- * Post qualify symbols with file.
- * e.g. <code>func() - /proj/folder/file.cpp</code>
+ * Post qualify symbols with file.
+ * e.g. <code>func() - /proj/folder/file.cpp</code>
*/
- public final static long MF_POST_FILE_QUALIFIED= 1L << 31;
+ public final static long MF_POST_FILE_QUALIFIED = 1L << 31;
/**
* Specifies to apply color styles to labels. This flag only applies to methods taking or returning a {@link StyledString}.
*/
- public final static long COLORIZE= 1L << 32;
-
+ public final static long COLORIZE = 1L << 32;
+
/**
* Qualify all elements
*/
- public final static long ALL_FULLY_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED | ROOT_QUALIFIED;
+ public final static long ALL_FULLY_QUALIFIED = F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED
+ | TU_QUALIFIED | ROOT_QUALIFIED;
/**
* Post qualify all elements
*/
- public final static long ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED | ROOT_POST_QUALIFIED;
+ public final static long ALL_POST_QUALIFIED = F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED
+ | ROOT_POST_QUALIFIED;
/**
* Default options (M_PARAMETER_TYPES enabled)
*/
- public final static long ALL_DEFAULT= M_PARAMETER_TYPES;
+ public final static long ALL_DEFAULT = M_PARAMETER_TYPES;
/**
* Default qualify options (All except Root)
*/
- public final static long DEFAULT_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED;
+ public final static long DEFAULT_QUALIFIED = F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED
+ | TU_QUALIFIED;
/**
* Default post qualify options (All except Root)
*/
- public final static long DEFAULT_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED;
+ public final static long DEFAULT_POST_QUALIFIED = F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED;
/**
* Separator for appending qualifiers
*/
- public final static String CONCAT_STRING= CoreModelMessages.getString("CElementLabels.concat_string"); // " - "; //$NON-NLS-1$
-
+ public final static String CONCAT_STRING = CoreModelMessages.getString("CElementLabels.concat_string"); // " - "; //$NON-NLS-1$
+
/**
* Separator for parameters, base classes, exceptions, etc.
*/
public final static String COMMA_STRING = CoreModelMessages.getString("CElementLabels.comma_string"); // ", "; //$NON-NLS-1$
-
+
/**
* Separator for appending (return) type
*/
- public final static String DECL_STRING = CoreModelMessages.getString("CElementLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$
+ public final static String DECL_STRING = CoreModelMessages.getString("CElementLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$
-
//====================
-
-
+
private CElementLabels() {
}
@@ -262,7 +263,7 @@ public class CElementLabels {
return BasicElementLabels.getResourceName(((IStorage) obj).getName());
} else if (obj instanceof IAdaptable) {
- IWorkbenchAdapter wbadapter= ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
+ IWorkbenchAdapter wbadapter = ((IAdaptable) obj).getAdapter(IWorkbenchAdapter.class);
if (wbadapter != null) {
return Strings.markLTR(wbadapter.getLabel(obj));
}
@@ -291,7 +292,7 @@ public class CElementLabels {
return getStyledStorageLabel((IStorage) obj);
} else if (obj instanceof IAdaptable) {
- IWorkbenchAdapter wbadapter= ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
+ IWorkbenchAdapter wbadapter = ((IAdaptable) obj).getAdapter(IWorkbenchAdapter.class);
if (wbadapter != null) {
return Strings.markLTR(new StyledString(wbadapter.getLabel(obj)));
}
@@ -307,7 +308,7 @@ public class CElementLabels {
* @return the styled string
*/
private static StyledString getStyledResourceLabel(IResource resource) {
- StyledString result= new StyledString(resource.getName());
+ StyledString result = new StyledString(resource.getName());
return Strings.markLTR(result);
}
@@ -319,11 +320,10 @@ public class CElementLabels {
* @return the styled string
*/
private static StyledString getStyledStorageLabel(IStorage storage) {
- StyledString result= new StyledString(storage.getName());
+ StyledString result = new StyledString(storage.getName());
return Strings.markLTR(result);
}
-
/**
* Returns the label for a Java element with the flags as defined by this class.
*
@@ -332,7 +332,7 @@ public class CElementLabels {
* @return the label of the Java element
*/
public static String getElementLabel(ICElement element, long flags) {
- StringBuilder result= new StringBuilder();
+ StringBuilder result = new StringBuilder();
getElementLabel(element, flags, result);
return Strings.markCElementLabelLTR(result.toString());
}
@@ -346,7 +346,7 @@ public class CElementLabels {
*
*/
public static StyledString getStyledElementLabel(ICElement element, long flags) {
- StyledString result= new StyledString();
+ StyledString result = new StyledString();
getElementLabel(element, flags, result);
return Strings.markCElementLabelLTR(result);
}
@@ -372,7 +372,7 @@ public class CElementLabels {
public static void getElementLabel(ICElement element, long flags, StyledString result) {
new CElementLabelComposer(result).appendElementLabel(element, flags);
}
-
+
/**
* Appends the label for a macro definition to a StringBuilder.
* @param macro a macro definition
@@ -393,7 +393,7 @@ public class CElementLabels {
public static void getMethodLabel(IMacro macro, long flags, StyledString result) {
new CElementLabelComposer(result).appendMacroLabel(macro, flags);
}
-
+
/**
* Appends the label for a method declaration to a StringBuilder.
* @param method a method declaration
@@ -414,7 +414,7 @@ public class CElementLabels {
public static void getMethodLabel(IMethodDeclaration method, long flags, StyledString result) {
new CElementLabelComposer(result).appendMethodLabel(method, flags);
}
-
+
/**
* Appends the label for a field to a StringBuilder.
* @param field a field
@@ -422,7 +422,7 @@ public class CElementLabels {
* @param buf the buffer to append the label
*/
public static void getFieldLabel(IField field, int flags, StringBuilder buf) {
- new CElementLabelComposer(buf).appendFieldLabel(field, flags);
+ new CElementLabelComposer(buf).appendFieldLabel(field, flags);
}
/**
@@ -432,7 +432,7 @@ public class CElementLabels {
* @param result the buffer to append the label
*/
public static void getFieldLabel(IField field, int flags, StyledString result) {
- new CElementLabelComposer(result).appendFieldLabel(field, flags);
+ new CElementLabelComposer(result).appendFieldLabel(field, flags);
}
/**
@@ -442,7 +442,7 @@ public class CElementLabels {
* @param buf the buffer to append the label
*/
public static void getVariableLabel(IVariableDeclaration var, int flags, StringBuilder buf) {
- new CElementLabelComposer(buf).appendVariableLabel(var, flags);
+ new CElementLabelComposer(buf).appendVariableLabel(var, flags);
}
/**
@@ -452,7 +452,7 @@ public class CElementLabels {
* @param result the buffer to append the label
*/
public static void getVariableLabel(IVariableDeclaration var, int flags, StyledString result) {
- new CElementLabelComposer(result).appendVariableLabel(var, flags);
+ new CElementLabelComposer(result).appendVariableLabel(var, flags);
}
/**
@@ -462,7 +462,7 @@ public class CElementLabels {
* @param buf the buffer to append the label
*/
public static void getEnumeratorLabel(IEnumerator var, int flags, StringBuilder buf) {
- new CElementLabelComposer(buf).appendEnumeratorLabel(var, flags);
+ new CElementLabelComposer(buf).appendEnumeratorLabel(var, flags);
}
/**
@@ -472,7 +472,7 @@ public class CElementLabels {
* @param result the buffer to append the label
*/
public static void getEnumeratorLabel(IEnumerator var, int flags, StyledString result) {
- new CElementLabelComposer(result).appendEnumeratorLabel(var, flags);
+ new CElementLabelComposer(result).appendEnumeratorLabel(var, flags);
}
/**
@@ -482,7 +482,7 @@ public class CElementLabels {
* @param buf the buffer to append the label
*/
public static void getFunctionLabel(IFunctionDeclaration func, int flags, StringBuilder buf) {
- new CElementLabelComposer(buf).appendFunctionLabel(func, flags);
+ new CElementLabelComposer(buf).appendFunctionLabel(func, flags);
}
/**
@@ -502,7 +502,7 @@ public class CElementLabels {
* @param buf the buffer to append the label
*/
public static void getTypeDefLabel(ITypeDef typedef, int flags, StringBuilder buf) {
- new CElementLabelComposer(buf).appendTypeDefLabel(typedef, flags);
+ new CElementLabelComposer(buf).appendTypeDefLabel(typedef, flags);
}
/**
@@ -512,6 +512,6 @@ public class CElementLabels {
* @param result the buffer to append the label
*/
public static void getTypeDefLabel(ITypeDef typedef, int flags, StyledString result) {
- new CElementLabelComposer(result).appendTypeDefLabel(typedef, flags);
+ new CElementLabelComposer(result).appendTypeDefLabel(typedef, flags);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java
index f81ab0e9ce4..8a9760ab01b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java
@@ -37,7 +37,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
public class CUILabelProvider extends LabelProvider implements IColorProvider, IStyledLabelProvider {
protected CElementImageProvider fImageLabelProvider;
protected StorageLabelProvider fStorageLabelProvider;
-
+
private ArrayList<ILabelDecorator> fLabelDecorators;
private int fImageFlags;
@@ -56,31 +56,31 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
* @param imageFlags Flags defined in <code>CElementImageProvider</code>.
*/
public CUILabelProvider(long textFlags, int imageFlags) {
- fImageLabelProvider= new CElementImageProvider();
- fLabelDecorators= null;
+ fImageLabelProvider = new CElementImageProvider();
+ fLabelDecorators = null;
- fStorageLabelProvider= new StorageLabelProvider();
- fImageFlags= imageFlags;
- fTextFlags= textFlags;
+ fStorageLabelProvider = new StorageLabelProvider();
+ fImageFlags = imageFlags;
+ fTextFlags = textFlags;
}
-
+
/**
* Adds a decorator to the label provider
* @param decorator the decorator to add
*/
public void addLabelDecorator(ILabelDecorator decorator) {
if (fLabelDecorators == null) {
- fLabelDecorators= new ArrayList<ILabelDecorator>(2);
+ fLabelDecorators = new ArrayList<ILabelDecorator>(2);
}
fLabelDecorators.add(decorator);
}
-
+
/**
* Sets the textFlags.
* @param textFlags The textFlags to set
*/
public final void setTextFlags(long textFlags) {
- fTextFlags= textFlags;
+ fTextFlags = textFlags;
}
/**
@@ -88,9 +88,9 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
* @param imageFlags The imageFlags to set
*/
public final void setImageFlags(int imageFlags) {
- fImageFlags= imageFlags;
+ fImageFlags = imageFlags;
}
-
+
/**
* Gets the image flags.
* Can be overwritten by super classes.
@@ -107,7 +107,7 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
public final long getTextFlags() {
return fTextFlags;
}
-
+
/**
* Evaluates the image flags for a element.
* Can be overwritten by super classes.
@@ -129,9 +129,9 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
protected Image decorateImage(Image image, Object element) {
if (fLabelDecorators != null && image != null) {
- for (int i= 0; i < fLabelDecorators.size(); i++) {
- ILabelDecorator decorator= fLabelDecorators.get(i);
- image= decorator.decorateImage(image, element);
+ for (int i = 0; i < fLabelDecorators.size(); i++) {
+ ILabelDecorator decorator = fLabelDecorators.get(i);
+ image = decorator.decorateImage(image, element);
}
}
return image;
@@ -139,87 +139,88 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
@Override
public Image getImage(Object element) {
- Image result= fImageLabelProvider.getImageLabel(element, evaluateImageFlags(element));
+ Image result = fImageLabelProvider.getImageLabel(element, evaluateImageFlags(element));
if (result == null && (element instanceof IStorage)) {
- result= fStorageLabelProvider.getImage(element);
+ result = fStorageLabelProvider.getImage(element);
}
-
+
return decorateImage(result, element);
}
protected String decorateText(String text, Object element) {
if (fLabelDecorators != null && text.length() > 0) {
- for (int i= 0; i < fLabelDecorators.size(); i++) {
- ILabelDecorator decorator= fLabelDecorators.get(i);
- text= decorator.decorateText(text, element);
+ for (int i = 0; i < fLabelDecorators.size(); i++) {
+ ILabelDecorator decorator = fLabelDecorators.get(i);
+ text = decorator.decorateText(text, element);
}
- }
+ }
return text;
}
@Override
public String getText(Object element) {
- String result= CElementLabels.getTextLabel(element, evaluateTextFlags(element));
+ String result = CElementLabels.getTextLabel(element, evaluateTextFlags(element));
if (result.length() == 0 && (element instanceof IStorage)) {
- result= fStorageLabelProvider.getText(element);
+ result = fStorageLabelProvider.getText(element);
}
-
+
return decorateText(result, element);
}
@Override
public StyledString getStyledText(Object element) {
- StyledString string= CElementLabels.getStyledTextLabel(element, (evaluateTextFlags(element) | CElementLabels.COLORIZE));
+ StyledString string = CElementLabels.getStyledTextLabel(element,
+ (evaluateTextFlags(element) | CElementLabels.COLORIZE));
if (string.length() == 0 && (element instanceof IStorage)) {
- string= new StyledString(fStorageLabelProvider.getText(element));
+ string = new StyledString(fStorageLabelProvider.getText(element));
}
- String decorated= decorateText(string.getString(), element);
+ String decorated = decorateText(string.getString(), element);
if (decorated != null) {
return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, string);
}
return string;
}
-
+
@Override
public void dispose() {
if (fLabelDecorators != null) {
- for (int i= 0; i < fLabelDecorators.size(); i++) {
- ILabelDecorator decorator= fLabelDecorators.get(i);
+ for (int i = 0; i < fLabelDecorators.size(); i++) {
+ ILabelDecorator decorator = fLabelDecorators.get(i);
decorator.dispose();
}
- fLabelDecorators= null;
+ fLabelDecorators = null;
}
fStorageLabelProvider.dispose();
fImageLabelProvider.dispose();
}
-
+
@Override
public void addListener(ILabelProviderListener listener) {
if (fLabelDecorators != null) {
- for (int i= 0; i < fLabelDecorators.size(); i++) {
- ILabelDecorator decorator= fLabelDecorators.get(i);
+ for (int i = 0; i < fLabelDecorators.size(); i++) {
+ ILabelDecorator decorator = fLabelDecorators.get(i);
decorator.addListener(listener);
}
}
- super.addListener(listener);
+ super.addListener(listener);
}
@Override
public boolean isLabelProperty(Object element, String property) {
- return true;
+ return true;
}
@Override
public void removeListener(ILabelProviderListener listener) {
if (fLabelDecorators != null) {
- for (int i= 0; i < fLabelDecorators.size(); i++) {
- ILabelDecorator decorator= fLabelDecorators.get(i);
+ for (int i = 0; i < fLabelDecorators.size(); i++) {
+ ILabelDecorator decorator = fLabelDecorators.get(i);
decorator.removeListener(listener);
}
}
- super.removeListener(listener);
+ super.removeListener(listener);
}
-
+
public static ILabelDecorator[] getDecorators(boolean errortick, ILabelDecorator extra) {
if (errortick) {
if (extra == null) {
@@ -236,10 +237,10 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
@Override
public Color getForeground(Object element) {
if (element instanceof ISourceReference) {
- ISourceReference sref= (ISourceReference)element;
+ ISourceReference sref = (ISourceReference) element;
if (!sref.isActive()) {
if (fInactiveColor == null && Display.getCurrent() != null) {
- fInactiveColor= CUIPlugin.getStandardDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
+ fInactiveColor = CUIPlugin.getStandardDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
}
return fInactiveColor;
}
@@ -250,5 +251,5 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
@Override
public Color getBackground(Object element) {
return null;
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.java
index f70be63079f..af1c9a4f89b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.java
@@ -27,25 +27,24 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
-
public class ColoredViewersManager implements IPropertyChangeListener {
- public static final String INHERITED_COLOR_NAME= "org.eclipse.cdt.ui.ColoredLabels.inherited"; //$NON-NLS-1$
-
- public static final String HIGHLIGHT_BG_COLOR_NAME= "org.eclipse.cdt.ui.ColoredLabels.match_highlight"; //$NON-NLS-1$
- public static final String HIGHLIGHT_WRITE_BG_COLOR_NAME= "org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight"; //$NON-NLS-1$
-
- private static ColoredViewersManager fgInstance= new ColoredViewersManager();
-
+ public static final String INHERITED_COLOR_NAME = "org.eclipse.cdt.ui.ColoredLabels.inherited"; //$NON-NLS-1$
+
+ public static final String HIGHLIGHT_BG_COLOR_NAME = "org.eclipse.cdt.ui.ColoredLabels.match_highlight"; //$NON-NLS-1$
+ public static final String HIGHLIGHT_WRITE_BG_COLOR_NAME = "org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight"; //$NON-NLS-1$
+
+ private static ColoredViewersManager fgInstance = new ColoredViewersManager();
+
private Set<ColoringLabelProvider> fManagedLabelProviders;
-
+
public ColoredViewersManager() {
- fManagedLabelProviders= new HashSet<ColoringLabelProvider>();
+ fManagedLabelProviders = new HashSet<ColoringLabelProvider>();
}
-
+
public void installColoredLabels(ColoringLabelProvider labelProvider) {
if (fManagedLabelProviders.contains(labelProvider))
return;
-
+
if (fManagedLabelProviders.isEmpty()) {
// first lp installed
PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
@@ -53,23 +52,25 @@ public class ColoredViewersManager implements IPropertyChangeListener {
}
fManagedLabelProviders.add(labelProvider);
}
-
+
public void uninstallColoredLabels(ColoringLabelProvider labelProvider) {
if (!fManagedLabelProviders.remove(labelProvider))
return; // not installed
-
+
if (fManagedLabelProviders.isEmpty()) {
PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
JFaceResources.getColorRegistry().removeListener(this);
// last viewer uninstalled
}
}
-
+
@Override
public void propertyChange(PropertyChangeEvent event) {
- String property= event.getProperty();
- if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR) || property.equals(JFacePreferences.DECORATIONS_COLOR)
- || property.equals(HIGHLIGHT_BG_COLOR_NAME) || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS) || property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME)) {
+ String property = event.getProperty();
+ if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR)
+ || property.equals(JFacePreferences.DECORATIONS_COLOR) || property.equals(HIGHLIGHT_BG_COLOR_NAME)
+ || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)
+ || property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME)) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
@@ -78,22 +79,22 @@ public class ColoredViewersManager implements IPropertyChangeListener {
});
}
}
-
+
protected final void refreshAllViewers() {
for (ColoringLabelProvider provider : fManagedLabelProviders) {
provider.refresh();
}
}
-
+
public static boolean showColoredLabels() {
return PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS);
}
-
+
public static void install(ColoringLabelProvider labelProvider) {
fgInstance.installColoredLabels(labelProvider);
}
-
+
public static void uninstall(ColoringLabelProvider labelProvider) {
fgInstance.uninstallColoredLabels(labelProvider);
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.java
index eb7fa510246..54124617657 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.java
@@ -27,14 +27,17 @@ import org.eclipse.jface.viewers.ViewerColumn;
import org.eclipse.jface.viewers.StyledString.Styler;
public class ColoringLabelProvider extends DecoratingStyledCellLabelProvider implements ILabelProvider {
- public static final Styler HIGHLIGHT_STYLE= StyledString.createColorRegistryStyler(null, ColoredViewersManager.HIGHLIGHT_BG_COLOR_NAME);
- public static final Styler HIGHLIGHT_WRITE_STYLE= StyledString.createColorRegistryStyler(null, ColoredViewersManager.HIGHLIGHT_WRITE_BG_COLOR_NAME);
-
+ public static final Styler HIGHLIGHT_STYLE = StyledString.createColorRegistryStyler(null,
+ ColoredViewersManager.HIGHLIGHT_BG_COLOR_NAME);
+ public static final Styler HIGHLIGHT_WRITE_STYLE = StyledString.createColorRegistryStyler(null,
+ ColoredViewersManager.HIGHLIGHT_WRITE_BG_COLOR_NAME);
+
public ColoringLabelProvider(IStyledLabelProvider labelProvider) {
this(labelProvider, null, null);
}
-
- public ColoringLabelProvider(IStyledLabelProvider labelProvider, ILabelDecorator decorator, IDecorationContext decorationContext) {
+
+ public ColoringLabelProvider(IStyledLabelProvider labelProvider, ILabelDecorator decorator,
+ IDecorationContext decorationContext) {
super(labelProvider, decorator, decorationContext);
}
@@ -42,23 +45,23 @@ public class ColoringLabelProvider extends DecoratingStyledCellLabelProvider imp
public void initialize(ColumnViewer viewer, ViewerColumn column) {
ColoredViewersManager.install(this);
setOwnerDrawEnabled(ColoredViewersManager.showColoredLabels());
-
+
super.initialize(viewer, column);
}
-
+
@Override
public void dispose() {
super.dispose();
ColoredViewersManager.uninstall(this);
}
-
+
public void refresh() {
- ColumnViewer viewer= getViewer();
-
+ ColumnViewer viewer = getViewer();
+
if (viewer == null) {
return;
}
- boolean showColoredLabels= ColoredViewersManager.showColoredLabels();
+ boolean showColoredLabels = ColoredViewersManager.showColoredLabels();
if (showColoredLabels != isOwnerDrawEnabled()) {
setOwnerDrawEnabled(showColoredLabels);
viewer.refresh();
@@ -66,32 +69,32 @@ public class ColoringLabelProvider extends DecoratingStyledCellLabelProvider imp
viewer.refresh();
}
}
-
+
@Override
protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors) {
if (!applyColors && styleRange.background != null) {
- styleRange= super.prepareStyleRange(styleRange, applyColors);
- styleRange.borderStyle= SWT.BORDER_DOT;
+ styleRange = super.prepareStyleRange(styleRange, applyColors);
+ styleRange.borderStyle = SWT.BORDER_DOT;
return styleRange;
}
return super.prepareStyleRange(styleRange, applyColors);
}
-
+
@Override
public String getText(Object element) {
return getStyledText(element).getString();
}
public static StyledString decorateStyledString(StyledString string, String decorated, Styler color) {
- String label= string.getString();
- int originalStart= decorated.indexOf(label);
+ String label = string.getString();
+ int originalStart = decorated.indexOf(label);
if (originalStart == -1) {
return new StyledString(decorated); // the decorator did something wild
}
if (originalStart > 0) {
- StyledString newString= new StyledString(decorated.substring(0, originalStart), color);
+ StyledString newString = new StyledString(decorated.substring(0, originalStart), color);
newString.append(string);
- string= newString;
+ string = newString;
}
if (decorated.length() > originalStart + label.length()) { // decorator appended something
return string.append(decorated.substring(originalStart + label.length()), color);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java
index 0f802744d7f..7b68d5a2802 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java
@@ -44,8 +44,10 @@ public class CustomBuildSettingsDecorator implements ILightweightLabelDecorator
public void decorate(Object element, IDecoration decoration) {
if (element instanceof IFile || element instanceof IFolder) {
IResource rc = (IResource) element;
- ICProjectDescriptionManager projectDescriptionManager = CoreModel.getDefault().getProjectDescriptionManager();
- ICProjectDescription prjDescription = projectDescriptionManager.getProjectDescription(rc.getProject(), ICProjectDescriptionManager.GET_IF_LOADDED);
+ ICProjectDescriptionManager projectDescriptionManager = CoreModel.getDefault()
+ .getProjectDescriptionManager();
+ ICProjectDescription prjDescription = projectDescriptionManager.getProjectDescription(rc.getProject(),
+ ICProjectDescriptionManager.GET_IF_LOADDED);
if (prjDescription != null) {
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
if (cfgDescription != null) {
@@ -57,20 +59,23 @@ public class CustomBuildSettingsDecorator implements ILightweightLabelDecorator
}
private static boolean isCustomizedResource(ICConfigurationDescription cfgDescription, IResource rc) {
- if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(rc.getProject()) && cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- IContainer parent = rc.getParent();
- List<String> languages = LanguageSettingsManager.getLanguages(rc, cfgDescription);
- for (ILanguageSettingsProvider provider: ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) {
- for (String languageId : languages) {
- List<ICLanguageSettingEntry> list = provider.getSettingEntries(cfgDescription, rc, languageId);
- if (list != null) {
- List<ICLanguageSettingEntry> listDefault = provider.getSettingEntries(cfgDescription, parent, languageId);
- // != is OK here due as the equal lists will have the same reference in WeakHashSet
- if (list != listDefault)
- return true;
- }
+ if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(rc.getProject())
+ && cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
+ IContainer parent = rc.getParent();
+ List<String> languages = LanguageSettingsManager.getLanguages(rc, cfgDescription);
+ for (ILanguageSettingsProvider provider : ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders()) {
+ for (String languageId : languages) {
+ List<ICLanguageSettingEntry> list = provider.getSettingEntries(cfgDescription, rc, languageId);
+ if (list != null) {
+ List<ICLanguageSettingEntry> listDefault = provider.getSettingEntries(cfgDescription, parent,
+ languageId);
+ // != is OK here due as the equal lists will have the same reference in WeakHashSet
+ if (list != listDefault)
+ return true;
}
}
+ }
}
ICResourceDescription rcDescription = cfgDescription.getResourceDescription(rc.getProjectRelativePath(), true);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java
index 04f0141da54..be513204439 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java
@@ -18,7 +18,7 @@ import org.eclipse.jface.viewers.DecorationContext;
import org.eclipse.ui.PlatformUI;
public class DecoratingCLabelProvider extends ColoringLabelProvider {
-
+
/**
* Decorating label provider for C/C++. Combines a CUILabelProvider
* with problem and override indicator with the workbench decorator (label
@@ -37,7 +37,8 @@ public class DecoratingCLabelProvider extends ColoringLabelProvider {
* @param errorTick show error ticks
*/
public DecoratingCLabelProvider(CUILabelProvider labelProvider, boolean errorTick) {
- super(labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), DecorationContext.DEFAULT_CONTEXT);
+ super(labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(),
+ DecorationContext.DEFAULT_CONTEXT);
if (errorTick) {
labelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java
index e3143467672..2a1e109a2d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Ed Swartz (Nokia)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
import java.net.URI;
@@ -50,25 +50,24 @@ import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
* An utility to open editors for references or elements.
*/
public class EditorOpener {
-
+
/**
* Opens the editor selecting the given region.
*/
public static void open(IWorkbenchPage page, IFile file, IRegion region, long timestamp) {
if (file.getLocationURI() != null) {
- IEditorPart editor= null;
+ IEditorPart editor = null;
if (timestamp == 0) {
- timestamp= file.getLocalTimeStamp();
+ timestamp = file.getLocalTimeStamp();
}
try {
// Bug 328321: Linked resources of closed projects report wrong location.
if (!file.exists()) {
final IWorkbenchPartSite site = page.getActivePart().getSite();
- showStatus(site, 3000,
- NLS.bind(Messages.EditorOpener_fileDoesNotExist, file.getName()));
+ showStatus(site, 3000, NLS.bind(Messages.EditorOpener_fileDoesNotExist, file.getName()));
return;
}
- editor= IDE.openEditor(page, file, false);
+ editor = IDE.openEditor(page, file, false);
} catch (PartInitException e) {
CUIPlugin.log(e);
}
@@ -78,7 +77,7 @@ public class EditorOpener {
private static void showStatus(final IWorkbenchPartSite site, int duration, String msg) {
StatusLineHandler.showStatusLineMessage(site, msg);
- Display.getCurrent().timerExec(duration, new Runnable() {
+ Display.getCurrent().timerExec(duration, new Runnable() {
@Override
public void run() {
StatusLineHandler.clearStatusLine(site);
@@ -88,57 +87,60 @@ public class EditorOpener {
private static void selectRegion(IPath filebufferKey, IRegion region, long timestamp, IEditorPart editor) {
if (editor instanceof ITextEditor) {
- ITextEditor te= (ITextEditor) editor;
- IPositionConverter pc= CCorePlugin.getPositionTrackerManager().findPositionConverter(filebufferKey, timestamp);
- if (pc != null) {
- region= pc.historicToActual(region);
- }
- te.selectAndReveal(region.getOffset(), region.getLength());
- }
+ ITextEditor te = (ITextEditor) editor;
+ IPositionConverter pc = CCorePlugin.getPositionTrackerManager().findPositionConverter(filebufferKey,
+ timestamp);
+ if (pc != null) {
+ region = pc.historicToActual(region);
+ }
+ te.selectAndReveal(region.getOffset(), region.getLength());
+ }
}
-
+
private static void selectRegion(URI locationURI, IRegion region, long timestamp, IEditorPart editor) {
if (editor instanceof ITextEditor) {
- ITextEditor te= (ITextEditor) editor;
- IPositionConverter pc= CCorePlugin.getPositionTrackerManager().findPositionConverter(locationURI, timestamp);
- if (pc != null) {
- region= pc.historicToActual(region);
- }
- te.selectAndReveal(region.getOffset(), region.getLength());
- }
+ ITextEditor te = (ITextEditor) editor;
+ IPositionConverter pc = CCorePlugin.getPositionTrackerManager().findPositionConverter(locationURI,
+ timestamp);
+ if (pc != null) {
+ region = pc.historicToActual(region);
+ }
+ te.selectAndReveal(region.getOffset(), region.getLength());
+ }
}
/**
* Opens the editor for an external location, selecting the given region.
*/
public static void openExternalFile(IWorkbenchPage page, IPath location, IRegion region, long timestamp) {
- IEditorPart editor= null;
+ IEditorPart editor = null;
try {
- editor= EditorUtility.openInEditor(location, null);
- if (timestamp == 0) {
- timestamp= location.toFile().lastModified();
- }
- selectRegion(location, region, timestamp, editor);
+ editor = EditorUtility.openInEditor(location, null);
+ if (timestamp == 0) {
+ timestamp = location.toFile().lastModified();
+ }
+ selectRegion(location, region, timestamp, editor);
} catch (PartInitException e) {
CUIPlugin.log(e);
}
}
-
+
/**
* Opens the editor for an external EFS location, selecting the given region.
*/
- public static void openExternalFile(IWorkbenchPage page, URI locationURI, IRegion region, long timestamp, ICElement context) {
- IEditorPart editor= null;
+ public static void openExternalFile(IWorkbenchPage page, URI locationURI, IRegion region, long timestamp,
+ ICElement context) {
+ IEditorPart editor = null;
try {
- editor= EditorUtility.openInEditor(locationURI, context);
- if (timestamp == 0) {
- try {
- timestamp= EFS.getStore(locationURI).fetchInfo().getLastModified();
+ editor = EditorUtility.openInEditor(locationURI, context);
+ if (timestamp == 0) {
+ try {
+ timestamp = EFS.getStore(locationURI).fetchInfo().getLastModified();
} catch (CoreException e) {
CUIPlugin.log(e);
}
- }
- selectRegion(locationURI, region, timestamp, editor);
+ }
+ selectRegion(locationURI, region, timestamp, editor);
} catch (PartInitException e) {
CUIPlugin.log(e);
}
@@ -146,16 +148,16 @@ public class EditorOpener {
/**
* Opens the editor for an ICElement, selecting the id.
- * @throws CModelException
+ * @throws CModelException
*/
public static void open(IWorkbenchPage page, ICElement element) throws CModelException {
if (element instanceof ISourceReference) {
- ISourceReference sr= (ISourceReference) element;
- ITranslationUnit tu= sr.getTranslationUnit();
- ISourceRange range= sr.getSourceRange();
- long timestamp= 0; // last modified of file.
+ ISourceReference sr = (ISourceReference) element;
+ ITranslationUnit tu = sr.getTranslationUnit();
+ ISourceRange range = sr.getSourceRange();
+ long timestamp = 0; // last modified of file.
if (tu.isWorkingCopy() || element instanceof ICElementHandle) {
- timestamp= -1;
+ timestamp = -1;
}
open(page, tu, new Region(range.getIdStartPos(), range.getIdLength()), timestamp);
}
@@ -166,14 +168,13 @@ public class EditorOpener {
*/
public static void open(IWorkbenchPage page, ITranslationUnit tu, Region region, long timestamp) {
if (tu != null) {
- IResource r= tu.getResource();
+ IResource r = tu.getResource();
if (r instanceof IFile) {
if (r.getLocationURI() != null) {
EditorOpener.open(page, (IFile) r, region, timestamp);
}
- }
- else {
- IPath location= tu.getPath();
+ } else {
+ IPath location = tu.getPath();
if (location != null) {
EditorOpener.openExternalFile(page, location, region, timestamp);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java
index 0ba14643c64..c48d8036132 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java
@@ -42,7 +42,8 @@ public class ExcludedFileDecorator implements ILightweightLabelDecorator {
if (element instanceof IFile || element instanceof IFolder) {
IResource resource = (IResource) element;
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
- ICProjectDescription desc = mngr.getProjectDescription(resource.getProject(), ICProjectDescriptionManager.GET_IF_LOADDED);
+ ICProjectDescription desc = mngr.getProjectDescription(resource.getProject(),
+ ICProjectDescriptionManager.GET_IF_LOADDED);
if (desc == null)
return;
ICConfigurationDescription conf = desc.getDefaultSettingConfiguration();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.java
index 49dd109e946..21df9ddb072 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
@@ -19,38 +19,38 @@ import org.eclipse.swt.widgets.Composite;
public class ExtendedTreeViewer extends TreeViewer {
- private boolean fPreservingSelection= false;
+ private boolean fPreservingSelection = false;
- public ExtendedTreeViewer(Composite parent) {
- super(parent);
- }
+ public ExtendedTreeViewer(Composite parent) {
+ super(parent);
+ }
- public ExtendedTreeViewer(Composite parent, int style) {
- super(parent, style);
- }
+ public ExtendedTreeViewer(Composite parent, int style) {
+ super(parent, style);
+ }
- public void refresh(final Object[] elements) {
- preservingSelection(new Runnable() {
- @Override
+ public void refresh(final Object[] elements) {
+ preservingSelection(new Runnable() {
+ @Override
public void run() {
- for (int i = 0; i < elements.length; i++) {
- refresh(elements[i]);
- }
- }
- });
- }
-
- @Override
+ for (int i = 0; i < elements.length; i++) {
+ refresh(elements[i]);
+ }
+ }
+ });
+ }
+
+ @Override
protected void preservingSelection(Runnable updateCode) {
- if (fPreservingSelection) {
- updateCode.run();
- } else {
- fPreservingSelection= true;
- try {
- super.preservingSelection(updateCode);
- } finally {
- fPreservingSelection= false;
- }
- }
- }
+ if (fPreservingSelection) {
+ updateCode.run();
+ } else {
+ fPreservingSelection = true;
+ try {
+ super.preservingSelection(updateCode);
+ } finally {
+ fPreservingSelection = false;
+ }
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAST.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAST.java
index 64fe27c7a1d..a181e3a045e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAST.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAST.java
@@ -24,11 +24,11 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
* Listeners can be registered in a <code>SelectionListenerWithASTManager</code>.
*/
public interface ISelectionListenerWithAST {
-
+
/**
* Called when a selection has changed. The method is called in a post selection event in an background
* thread.
- *
+ *
* @param part The editor part in which the selection change has occurred.
* @param selection The new text selection
* @param astRoot The AST tree corresponding to the editor's input. This AST is shared and must
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.java
index 4469f1b7dab..e40ce30d681 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.java
@@ -17,7 +17,7 @@ package org.eclipse.cdt.internal.ui.viewsupport;
* Interface common to all view parts that provide an input.
*/
public interface IViewPartInputProvider {
-
+
/**
* Returns the input.
*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.java
index 2107379ddd0..7ce9634e779 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.java
@@ -29,7 +29,7 @@ public class ImageImageDescriptor extends ImageDescriptor {
*/
public ImageImageDescriptor(Image image) {
super();
- fImage= image;
+ fImage = image;
}
/* (non-Javadoc)
@@ -45,7 +45,7 @@ public class ImageImageDescriptor extends ImageDescriptor {
*/
@Override
public boolean equals(Object obj) {
- return (obj != null) && getClass().equals(obj.getClass()) && fImage.equals(((ImageImageDescriptor)obj).fImage);
+ return (obj != null) && getClass().equals(obj.getClass()) && fImage.equals(((ImageImageDescriptor) obj).fImage);
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IncludeFolderDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IncludeFolderDecorator.java
index becd3adf87e..5d8346e4c9b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IncludeFolderDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IncludeFolderDecorator.java
@@ -38,7 +38,7 @@ public class IncludeFolderDecorator implements ILightweightLabelDecorator {
boolean isAccesible = true;
if (element instanceof IncludeReferenceProxy) {
- IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
+ IIncludeReference reference = ((IncludeReferenceProxy) element).getReference();
IPath path = reference.getPath();
IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
if (container != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
index 9c1a3a25bec..ce8ddb3cfbf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
@@ -111,16 +111,17 @@ public class IndexUI {
public static IIndexBinding elementToBinding(IIndex index, ICElement element, int linkageID) throws CoreException {
if (element instanceof ISourceReference) {
ISourceReference sf = ((ISourceReference) element);
- ISourceRange range= sf.getSourceRange();
+ ISourceRange range = sf.getSourceRange();
if (range.getIdLength() != 0) {
- IIndexName name= elementToName(index, element, linkageID);
+ IIndexName name = elementToName(index, element, linkageID);
if (name != null) {
return index.findBinding(name);
}
} else {
- String name= element.getElementName();
- name= name.substring(name.lastIndexOf(':') + 1);
- IIndexBinding[] bindings= index.findBindings(name.toCharArray(), IndexFilter.ALL, new NullProgressMonitor());
+ String name = element.getElementName();
+ name = name.substring(name.lastIndexOf(':') + 1);
+ IIndexBinding[] bindings = index.findBindings(name.toCharArray(), IndexFilter.ALL,
+ new NullProgressMonitor());
for (IIndexBinding binding : bindings) {
if (checkBinding(binding, element)) {
return binding;
@@ -139,16 +140,13 @@ public class IndexUI {
return binding instanceof ICPPNamespace;
case ICElement.C_STRUCT_DECLARATION:
case ICElement.C_STRUCT:
- return binding instanceof ICompositeType &&
- ((ICompositeType) binding).getKey() == ICompositeType.k_struct;
+ return binding instanceof ICompositeType && ((ICompositeType) binding).getKey() == ICompositeType.k_struct;
case ICElement.C_CLASS:
case ICElement.C_CLASS_DECLARATION:
- return binding instanceof ICPPClassType &&
- ((ICompositeType) binding).getKey() == ICPPClassType.k_class;
+ return binding instanceof ICPPClassType && ((ICompositeType) binding).getKey() == ICPPClassType.k_class;
case ICElement.C_UNION:
case ICElement.C_UNION_DECLARATION:
- return binding instanceof ICompositeType &&
- ((ICompositeType) binding).getKey() == ICompositeType.k_union;
+ return binding instanceof ICompositeType && ((ICompositeType) binding).getKey() == ICompositeType.k_union;
case ICElement.C_TYPEDEF:
return binding instanceof ITypedef;
case ICElement.C_METHOD:
@@ -190,18 +188,19 @@ public class IndexUI {
public static IIndexName elementToName(IIndex index, ICElement element, int linkageID) throws CoreException {
if (element instanceof ISourceReference) {
ISourceReference sf = ((ISourceReference) element);
- ITranslationUnit tu= sf.getTranslationUnit();
+ ITranslationUnit tu = sf.getTranslationUnit();
if (tu != null) {
- IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
+ IIndexFileLocation location = IndexLocationFactory.getIFL(tu);
if (location != null) {
- IIndexFile[] files= index.getFiles(location);
+ IIndexFile[] files = index.getFiles(location);
for (IIndexFile file : files) {
if (linkageID == -1 || file.getLinkageID() == linkageID) {
- String elementName= element.getElementName();
- int idx= elementName.lastIndexOf(":") + 1; //$NON-NLS-1$
- ISourceRange pos= sf.getSourceRange();
- IRegion region = getConvertedRegion(tu, file, pos.getIdStartPos() + idx, pos.getIdLength() - idx);
- IIndexName[] names= file.findNames(region.getOffset(), region.getLength());
+ String elementName = element.getElementName();
+ int idx = elementName.lastIndexOf(":") + 1; //$NON-NLS-1$
+ ISourceRange pos = sf.getSourceRange();
+ IRegion region = getConvertedRegion(tu, file, pos.getIdStartPos() + idx,
+ pos.getIdLength() - idx);
+ IIndexName[] names = file.findNames(region.getOffset(), region.getLength());
for (IIndexName name2 : names) {
IIndexName name = name2;
if (!name.isReference() && elementName.endsWith(new String(name.getSimpleID()))) {
@@ -219,11 +218,11 @@ public class IndexUI {
public static boolean isIndexed(IIndex index, ICElement element) throws CoreException {
if (element instanceof ISourceReference) {
ISourceReference sf = ((ISourceReference) element);
- ITranslationUnit tu= sf.getTranslationUnit();
+ ITranslationUnit tu = sf.getTranslationUnit();
if (tu != null) {
- IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
+ IIndexFileLocation location = IndexLocationFactory.getIFL(tu);
if (location != null) {
- IIndexFile[] files= index.getFiles(location);
+ IIndexFile[] files = index.getFiles(location);
return files.length > 0;
}
}
@@ -231,40 +230,40 @@ public class IndexUI {
return false;
}
- private static IRegion getConvertedRegion(ITranslationUnit tu, IIndexFile file, int pos,
- int length) throws CoreException {
- IRegion region= new Region(pos, length);
- IPositionConverter converter=
- CCorePlugin.getPositionTrackerManager().findPositionConverter(tu, file.getTimestamp());
+ private static IRegion getConvertedRegion(ITranslationUnit tu, IIndexFile file, int pos, int length)
+ throws CoreException {
+ IRegion region = new Region(pos, length);
+ IPositionConverter converter = CCorePlugin.getPositionTrackerManager().findPositionConverter(tu,
+ file.getTimestamp());
if (converter != null) {
- region= converter.actualToHistoric(region);
+ region = converter.actualToHistoric(region);
}
return region;
}
public static IIndexInclude elementToInclude(IIndex index, IInclude include) throws CoreException {
if (include != null) {
- ITranslationUnit tu= include.getTranslationUnit();
+ ITranslationUnit tu = include.getTranslationUnit();
if (tu != null) {
- IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
+ IIndexFileLocation location = IndexLocationFactory.getIFL(tu);
if (location != null) {
- IIndexFile[] files= index.getFiles(location);
+ IIndexFile[] files = index.getFiles(location);
for (IIndexFile file : files) {
- String elementName= include.getElementName();
- ISourceRange pos= include.getSourceRange();
- IRegion region= getConvertedRegion(tu, file, pos.getIdStartPos(), pos.getIdLength());
+ String elementName = include.getElementName();
+ ISourceRange pos = include.getSourceRange();
+ IRegion region = getConvertedRegion(tu, file, pos.getIdStartPos(), pos.getIdLength());
- IIndexInclude[] includes= index.findIncludes(file);
- int bestDiff= Integer.MAX_VALUE;
- IIndexInclude best= null;
+ IIndexInclude[] includes = index.findIncludes(file);
+ int bestDiff = Integer.MAX_VALUE;
+ IIndexInclude best = null;
for (IIndexInclude candidate : includes) {
- int diff= Math.abs(candidate.getNameOffset() - region.getOffset());
+ int diff = Math.abs(candidate.getNameOffset() - region.getOffset());
if (diff > bestDiff) {
break;
}
if (candidate.getFullName().endsWith(elementName)) {
- bestDiff= diff;
- best= candidate;
+ bestDiff = diff;
+ best = candidate;
}
}
if (best != null)
@@ -295,11 +294,12 @@ public class IndexUI {
public static ICElementHandle[] findAllDefinitions(IIndex index, IBinding binding) throws CoreException {
if (binding != null) {
- IIndexName[] defs= index.findNames(binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ IIndexName[] defs = index.findNames(binding,
+ IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
Set<ICElementHandle> result = new LinkedHashSet<>();
for (IIndexName in : defs) {
- ICElementHandle definition= getCElementForName((ICProject) null, index, in);
+ ICElementHandle definition = getCElementForName((ICProject) null, index, in);
if (definition != null) {
result.add(definition);
}
@@ -320,22 +320,23 @@ public class IndexUI {
public static ICElementHandle getCElementForName(ICProject preferProject, IIndex index, IASTName declName)
throws CoreException {
assert !declName.isReference();
- IBinding binding= declName.resolveBinding();
+ IBinding binding = declName.resolveBinding();
if (binding != null) {
- ITranslationUnit tu= getTranslationUnit(declName);
+ ITranslationUnit tu = getTranslationUnit(declName);
if (tu != null) {
if (tu instanceof IWorkingCopy)
tu = ((IWorkingCopy) tu).getOriginalElement();
- IFile file= (IFile) tu.getResource();
- long timestamp= file != null ? file.getLocalTimeStamp() : 0;
- IASTFileLocation loc= declName.getFileLocation();
+ IFile file = (IFile) tu.getResource();
+ long timestamp = file != null ? file.getLocalTimeStamp() : 0;
+ IASTFileLocation loc = declName.getFileLocation();
if (loc == null) {
return null;
}
- IRegion region= new Region(loc.getNodeOffset(), loc.getNodeLength());
- IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(tu, timestamp);
+ IRegion region = new Region(loc.getNodeOffset(), loc.getNodeLength());
+ IPositionConverter converter = CCorePlugin.getPositionTrackerManager().findPositionConverter(tu,
+ timestamp);
if (converter != null) {
- region= converter.actualToHistoric(region);
+ region = converter.actualToHistoric(region);
}
return CElementHandleFactory.create(tu, binding, declName.isDefinition(), region, timestamp);
}
@@ -359,7 +360,7 @@ public class IndexUI {
private static ITranslationUnit getTranslationUnit(ICProject cproject, final IASTFileLocation fileLocation) {
if (fileLocation != null) {
- IPath path= Path.fromOSString(fileLocation.getFileName());
+ IPath path = Path.fromOSString(fileLocation.getFileName());
try {
return CoreModelUtil.findTranslationUnitForLocation(path, cproject);
} catch (CModelException e) {
@@ -368,19 +369,18 @@ public class IndexUI {
}
return null;
}
-
+
/**
* Given a 'source' and a 'target' translation unit, return a translation unit
* that resolves to the same file as 'target' and has a workspace path that
* matches the workspace path of 'source' as closely as possible.
- *
+ *
* Most commonly, 'target' will be the only trasnlation unit that resolves to
* the file in question, and 'target' is returned. In the presence of linked
* folders, however, multiple workspace paths can refer to the same file, and
* this function chooses the one that's closest to 'source'.
*/
- public static ITranslationUnit getPreferredTranslationUnit(ITranslationUnit target,
- ITranslationUnit source) {
+ public static ITranslationUnit getPreferredTranslationUnit(ITranslationUnit target, ITranslationUnit source) {
// Get the files corresponding to the source and target translation units.
// These files encode the workspace paths.
IFile sourceFile = source.getFile();
@@ -388,25 +388,25 @@ public class IndexUI {
if (sourceFile == null || targetFile == null) {
return target;
}
-
+
// Resolve the location of the target in the filesystem.
IPath targetLocation = targetFile.getLocation();
if (targetLocation == null) {
return target;
}
-
+
// Find all files that resolve to the same location.
IFile[] candidates = ResourceLookup.findFilesForLocation(targetLocation);
-
+
// In the common case that there is one only file that resolves to that
// location, or if the search found no results, return the original target.
if (candidates.length <= 1) {
return target;
}
-
+
// Get the workspace path of the source translation unit's file.
final IPath sourcePath = sourceFile.getFullPath();
-
+
// Sort the candidates files by how closely they match 'sourcePath'.
Arrays.sort(candidates, new Comparator<IFile>() {
@Override
@@ -414,7 +414,7 @@ public class IndexUI {
// Get the workspace paths of the files being compared.
IPath p1 = f1.getFullPath();
IPath p2 = f2.getFullPath();
-
+
// Closeness of the match is defined by how many segments of
// the candidate's workspace path match 'sourcePath'.
int s1 = p1.matchingFirstSegments(sourcePath);
@@ -423,12 +423,12 @@ public class IndexUI {
return -1;
if (s1 < s2)
return 1;
-
+
// Fall back on alphabetical comparison.
return p1.toString().compareTo(p2.toString());
}
});
-
+
// Processing in the sorted order, return the first file for which
// a translation unit can be found.
for (IFile candidate : candidates) {
@@ -437,7 +437,7 @@ public class IndexUI {
return tu;
}
}
-
+
// Fall back on returning the original target.
return target;
}
@@ -445,7 +445,7 @@ public class IndexUI {
public static ICElementHandle getCElementForName(ICProject preferProject, IIndex index, IIndexName declName)
throws CoreException {
assert !declName.isReference();
- ITranslationUnit tu= getTranslationUnit(preferProject, declName);
+ ITranslationUnit tu = getTranslationUnit(preferProject, declName);
if (tu != null) {
return getCElementForName(tu, index, declName);
}
@@ -454,19 +454,20 @@ public class IndexUI {
public static ICElementHandle getCElementForName(ITranslationUnit tu, IIndex index, IIndexName declName)
throws CoreException {
- IRegion region= new Region(declName.getNodeOffset(), declName.getNodeLength());
- long timestamp= declName.getFile().getTimestamp();
- return CElementHandleFactory.create(tu, index.findBinding(declName), declName.isDefinition(), region, timestamp);
+ IRegion region = new Region(declName.getNodeOffset(), declName.getNodeLength());
+ long timestamp = declName.getFile().getTimestamp();
+ return CElementHandleFactory.create(tu, index.findBinding(declName), declName.isDefinition(), region,
+ timestamp);
}
public static ICElementHandle getCElementForMacro(ICProject preferProject, IIndex index, IIndexMacro macro)
throws CoreException {
- ITranslationUnit tu= getTranslationUnit(preferProject, macro.getFileLocation());
+ ITranslationUnit tu = getTranslationUnit(preferProject, macro.getFileLocation());
if (tu != null) {
- IIndexName name= macro.getDefinition();
+ IIndexName name = macro.getDefinition();
if (name != null) {
- IRegion region= new Region(name.getNodeOffset(), name.getNodeLength());
- long timestamp= macro.getFile().getTimestamp();
+ IRegion region = new Region(name.getNodeOffset(), name.getNodeLength());
+ long timestamp = macro.getFile().getTimestamp();
return CElementHandleFactory.create(tu, macro, region, timestamp);
}
}
@@ -476,9 +477,9 @@ public class IndexUI {
public static ICElementHandle findAnyDeclaration(IIndex index, ICProject preferProject, IBinding binding)
throws CoreException {
if (binding != null) {
- IIndexName[] names= index.findNames(binding, IIndex.FIND_DECLARATIONS);
+ IIndexName[] names = index.findNames(binding, IIndex.FIND_DECLARATIONS);
for (IIndexName name : names) {
- ICElementHandle elem= getCElementForName(preferProject, index, name);
+ ICElementHandle elem = getCElementForName(preferProject, index, name);
if (elem != null) {
return elem;
}
@@ -500,42 +501,43 @@ public class IndexUI {
if (workingCopy == null)
return null;
- final IASTName[] result= {null};
+ final IASTName[] result = { null };
ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
if (ast != null) {
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
- IASTName name= nodeSelector.findEnclosingName(offset, length);
+ IASTName name = nodeSelector.findEnclosingName(offset, length);
if (name == null) {
- name= nodeSelector.findImplicitName(offset, length);
+ name = nodeSelector.findImplicitName(offset, length);
}
if (name != null && name.getParent() instanceof IASTPreprocessorMacroExpansion) {
- IASTFileLocation floc= name.getParent().getFileLocation();
- IASTNode node= nodeSelector.findEnclosingNodeInExpansion(floc.getNodeOffset(), floc.getNodeLength());
+ IASTFileLocation floc = name.getParent().getFileLocation();
+ IASTNode node = nodeSelector.findEnclosingNodeInExpansion(floc.getNodeOffset(),
+ floc.getNodeLength());
if (node instanceof IASTName) {
- name= (IASTName) node;
- } else if (node instanceof IASTFunctionCallExpression){
- IASTExpression expr= ((IASTFunctionCallExpression) node).getFunctionNameExpression();
+ name = (IASTName) node;
+ } else if (node instanceof IASTFunctionCallExpression) {
+ IASTExpression expr = ((IASTFunctionCallExpression) node).getFunctionNameExpression();
if (expr instanceof IASTIdExpression) {
- name= ((IASTIdExpression) expr).getName();
+ name = ((IASTIdExpression) expr).getName();
}
} else {
if (node instanceof IASTSimpleDeclaration) {
- IASTNode[] dtors= ((IASTSimpleDeclaration) node).getDeclarators();
+ IASTNode[] dtors = ((IASTSimpleDeclaration) node).getDeclarators();
if (dtors != null && dtors.length > 0) {
- node= dtors[0];
+ node = dtors[0];
}
} else if (node instanceof IASTFunctionDefinition) {
- node= ((IASTFunctionDefinition) node).getDeclarator();
+ node = ((IASTFunctionDefinition) node).getDeclarator();
}
if (node instanceof IASTDeclarator) {
- IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) node);
- name= dtor.getName();
+ IASTDeclarator dtor = ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) node);
+ name = dtor.getName();
}
}
}
- result[0]= name;
+ result[0] = name;
}
return Status.OK_STATUS;
}
@@ -544,24 +546,26 @@ public class IndexUI {
}
public static String getFileNotIndexedMessage(ICElement input) {
- ITranslationUnit tu= null;
+ ITranslationUnit tu = null;
if (input instanceof ISourceReference) {
- ISourceReference ref= (ISourceReference) input;
- tu= ref.getTranslationUnit();
+ ISourceReference ref = (ISourceReference) input;
+ tu = ref.getTranslationUnit();
}
if (tu == null) {
return NLS.bind(Messages.IndexUI_infoNotInSource, input.getElementName());
}
- String msg= NLS.bind(Messages.IndexUI_infoNotInIndex, tu.getElementName());
+ String msg = NLS.bind(Messages.IndexUI_infoNotInIndex, tu.getElementName());
- IResource res= tu.getResource();
+ IResource res = tu.getResource();
if (res != null) {
- Properties props= IndexerPreferences.getProperties(res.getProject());
- if (props == null || !Boolean.parseBoolean((String) props.get(IndexerPreferences.KEY_INDEX_ALL_FILES)) ||
- (!Boolean.parseBoolean((String) props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG)) &&
- !Boolean.parseBoolean((String) props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG)))) {
- msg= msg + " " + Messages.IndexUI_infoSelectIndexAllFiles; //$NON-NLS-1$
+ Properties props = IndexerPreferences.getProperties(res.getProject());
+ if (props == null || !Boolean.parseBoolean((String) props.get(IndexerPreferences.KEY_INDEX_ALL_FILES))
+ || (!Boolean.parseBoolean(
+ (String) props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG))
+ && !Boolean.parseBoolean((String) props
+ .get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG)))) {
+ msg = msg + " " + Messages.IndexUI_infoSelectIndexAllFiles; //$NON-NLS-1$
}
}
return msg;
@@ -571,9 +575,9 @@ public class IndexUI {
if (input instanceof ICElementHandle) {
return input;
}
- IIndexName name= elementToName(index, input);
+ IIndexName name = elementToName(index, input);
if (name != null) {
- ICElement handle= getCElementForName(input.getCProject(), index, name);
+ ICElement handle = getCElementForName(input.getCProject(), index, name);
if (handle != null) {
return handle;
}
@@ -584,17 +588,16 @@ public class IndexUI {
/**
* Searches for all specializations that depend on the definition of the given binding.
*/
- public static List<? extends IBinding> findSpecializations(IIndex index, IBinding binding)
- throws CoreException {
- List<IBinding> result= null;
+ public static List<? extends IBinding> findSpecializations(IIndex index, IBinding binding) throws CoreException {
+ List<IBinding> result = null;
// Check for instances of the given binding.
if (binding instanceof ICPPInstanceCache) {
- ICPPTemplateInstance[] instances= ((ICPPInstanceCache) binding).getAllInstances();
+ ICPPTemplateInstance[] instances = ((ICPPInstanceCache) binding).getAllInstances();
for (ICPPTemplateInstance inst : instances) {
if (!ASTInternal.hasDeclaration(inst)) {
if (result == null)
- result= new ArrayList<>(instances.length);
+ result = new ArrayList<>(instances.length);
result.add(inst);
}
}
@@ -608,14 +611,15 @@ public class IndexUI {
if (specOwner instanceof ICPPClassSpecialization) {
// Add the specialized member.
IBinding specializedMember = ((ICPPClassSpecialization) specOwner).specializeMember(binding);
- specializedMember= index.adaptBinding(specializedMember);
+ specializedMember = index.adaptBinding(specializedMember);
if (specializedMember != null) {
if (result == null)
- result= new ArrayList<>(specializations.size());
+ result = new ArrayList<>(specializations.size());
result.add(specializedMember);
// Also add instances of the specialized member.
if (specializedMember instanceof ICPPInstanceCache) {
- ICPPTemplateInstance[] instances= ((ICPPInstanceCache) specializedMember).getAllInstances();
+ ICPPTemplateInstance[] instances = ((ICPPInstanceCache) specializedMember)
+ .getAllInstances();
for (ICPPTemplateInstance inst : instances) {
if (!ASTInternal.hasDeclaration(inst)) {
result.add(inst);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java
index 96356fbaae5..df9cc90bc26 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
import java.util.ArrayList;
@@ -53,6 +53,7 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
public boolean contains(ISchedulingRule rule) {
return rule == this;
}
+
@Override
public boolean isConflicting(ISchedulingRule rule) {
return rule == this;
@@ -63,16 +64,16 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
return INSTANCE;
}
- private final HashMap<String, Set<Integer>> fIndexedFiles= new HashMap<String, Set<Integer>>();
- private boolean fIsDirty= false;
- private boolean fActive= false;
+ private final HashMap<String, Set<Integer>> fIndexedFiles = new HashMap<String, Set<Integer>>();
+ private boolean fIsDirty = false;
+ private boolean fActive = false;
private void scheduleInitialize() {
- Job j= new Job(Messages.IndexedFilesCache_jobName) {
+ Job j = new Job(Messages.IndexedFilesCache_jobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- ICProject[] prj= CoreModel.getDefault().getCModel().getCProjects();
+ ICProject[] prj = CoreModel.getDefault().getCModel().getCProjects();
for (ICProject project : prj) {
initialize(project);
}
@@ -85,19 +86,20 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
checkTriggerDecorator(1);
return Status.OK_STATUS;
}
+
@Override
public boolean belongsTo(Object family) {
return family == IndexedFilesCache.this;
}
-
+
};
j.setSystem(true);
j.setRule(RULE);
- j.schedule();
+ j.schedule();
}
private void scheduleInitialize(final ICProject project) {
- Job j= new Job(Messages.IndexedFilesCache_jobName) {
+ Job j = new Job(Messages.IndexedFilesCache_jobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
@@ -111,6 +113,7 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
checkTriggerDecorator(1);
return Status.OK_STATUS;
}
+
@Override
public boolean belongsTo(Object family) {
return family == IndexedFilesCache.this;
@@ -118,44 +121,42 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
};
j.setSystem(true);
j.setRule(RULE);
- j.schedule();
+ j.schedule();
}
final protected void initialize(ICProject prj) throws CoreException, InterruptedException {
- IIndex index= CCorePlugin.getIndexManager().getIndex(prj);
- List<IIndexFileLocation> list= new ArrayList<IIndexFileLocation>();
+ IIndex index = CCorePlugin.getIndexManager().getIndex(prj);
+ List<IIndexFileLocation> list = new ArrayList<IIndexFileLocation>();
index.acquireReadLock();
try {
- IIndexFile[] files= index.getAllFiles();
+ IIndexFile[] files = index.getAllFiles();
for (IIndexFile ifile : files) {
if (ifile.getTimestamp() >= 0) {
list.add(ifile.getLocation());
}
}
if (!list.isEmpty()) {
- final String prjName= prj.getElementName();
- synchronized(fIndexedFiles) {
- Set<Integer> cache= fIndexedFiles.get(prjName);
+ final String prjName = prj.getElementName();
+ synchronized (fIndexedFiles) {
+ Set<Integer> cache = fIndexedFiles.get(prjName);
if (cache == null) {
- cache= new HashSet<Integer>();
+ cache = new HashSet<Integer>();
fIndexedFiles.put(prjName, cache);
- }
- else {
+ } else {
if (!cache.isEmpty()) {
cache.clear();
- fIsDirty= true;
+ fIsDirty = true;
}
}
- for (IIndexFileLocation ifl: list) {
- final int h= computeHash(ifl);
+ for (IIndexFileLocation ifl : list) {
+ final int h = computeHash(ifl);
if (cache.add(h)) {
- fIsDirty= true;
+ fIsDirty = true;
}
}
}
}
- }
- finally {
+ } finally {
index.releaseReadLock();
}
}
@@ -163,7 +164,7 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
@Override
public void indexChanged(IIndexChangeEvent e) {
// the index manager has reported a change to an index
- ICProject cproject= e.getAffectedProject();
+ ICProject cproject = e.getAffectedProject();
if (cproject == null) {
return;
}
@@ -173,32 +174,31 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
}
if (e.isReloaded()) {
scheduleInitialize(cproject);
- }
- else {
+ } else {
final String prjName = cproject.getElementName();
if (e.isCleared()) {
if (fIndexedFiles.remove(prjName) != null) {
- fIsDirty= true;
+ fIsDirty = true;
}
- }
+ }
final Set<IIndexFileLocation> filesCleared = e.getFilesCleared();
final Set<IIndexFileLocation> filesWritten = e.getFilesWritten();
if (!(filesCleared.isEmpty() && filesWritten.isEmpty())) {
- Set<Integer> cache= fIndexedFiles.get(prjName);
+ Set<Integer> cache = fIndexedFiles.get(prjName);
if (cache == null) {
- cache= new HashSet<Integer>();
+ cache = new HashSet<Integer>();
fIndexedFiles.put(prjName, cache);
}
- for (IIndexFileLocation ifl: filesCleared) {
- final int h= computeHash(ifl);
+ for (IIndexFileLocation ifl : filesCleared) {
+ final int h = computeHash(ifl);
if (cache.remove(h)) {
- fIsDirty= true;
+ fIsDirty = true;
}
}
- for (IIndexFileLocation ifl: filesWritten) {
- final int h= computeHash(ifl);
+ for (IIndexFileLocation ifl : filesWritten) {
+ final int h = computeHash(ifl);
if (cache.add(h)) {
- fIsDirty= true;
+ fIsDirty = true;
}
}
}
@@ -215,7 +215,7 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
private void activate() {
synchronized (fIndexedFiles) {
- fActive= true;
+ fActive = true;
PlatformUI.getWorkbench().getDecoratorManager().addListener(this);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.addIndexChangeListener(IndexedFilesCache.this);
@@ -226,7 +226,7 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
private void deactivate() {
synchronized (fIndexedFiles) {
- fActive= false;
+ fActive = false;
fIndexedFiles.clear();
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.removeIndexChangeListener(IndexedFilesCache.this);
@@ -235,48 +235,46 @@ class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener,
}
}
-
final protected void checkTriggerDecorator(int jobCount) {
- if (fIsDirty && CCorePlugin.getIndexManager().isIndexerIdle() &&
- Job.getJobManager().find(this).length == jobCount) {
- fIsDirty= false;
- final IWorkbench workbench= PlatformUI.getWorkbench();
+ if (fIsDirty && CCorePlugin.getIndexManager().isIndexerIdle()
+ && Job.getJobManager().find(this).length == jobCount) {
+ fIsDirty = false;
+ final IWorkbench workbench = PlatformUI.getWorkbench();
try {
- workbench.getDisplay().asyncExec(new Runnable(){
+ workbench.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- workbench.getDecoratorManager().update(DECORATOR_ID);
+ workbench.getDecoratorManager().update(DECORATOR_ID);
}
});
- }
- catch (SWTException e) {
+ } catch (SWTException e) {
// in case the display is no longer valid
}
}
}
-
+
public boolean isIndexed(IProject project, IIndexFileLocation ifl) {
// request from a label provider
- synchronized(fIndexedFiles) {
+ synchronized (fIndexedFiles) {
if (!fActive) {
activate();
}
- Set<Integer> cache= fIndexedFiles.get(project.getName());
+ Set<Integer> cache = fIndexedFiles.get(project.getName());
return cache != null && cache.contains(computeHash(ifl));
}
}
private int computeHash(IIndexFileLocation ifl) {
- final String fp= ifl.getFullPath();
- final int h1= fp == null ? 0 : fp.hashCode() * 43;
+ final String fp = ifl.getFullPath();
+ final int h1 = fp == null ? 0 : fp.hashCode() * 43;
return h1 + ifl.getURI().hashCode();
}
@Override
public void labelProviderChanged(LabelProviderChangedEvent event) {
- final Object src= event.getSource();
+ final Object src = event.getSource();
if (src instanceof IDecoratorManager) {
- IDecoratorManager mng= (IDecoratorManager) src;
+ IDecoratorManager mng = (IDecoratorManager) src;
if (!mng.getEnabled(DECORATOR_ID)) {
deactivate();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java
index af384152a0a..cbde8d270f0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* IBM Corporation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
import org.eclipse.core.resources.IFile;
@@ -34,70 +34,68 @@ import org.eclipse.cdt.ui.CUIPlugin;
* A label provider that marks all translation units that are currently part of the index.
*/
public class IndexedFilesLabelProvider implements ILightweightLabelDecorator {
- private static final ImageDescriptor INDEXED=
- AbstractUIPlugin.imageDescriptorFromPlugin(CUIPlugin.PLUGIN_ID, "$nl$/icons/ovr16/indexedFile.gif"); //$NON-NLS-1$
-
- public IndexedFilesLabelProvider() {
- }
+ private static final ImageDescriptor INDEXED = AbstractUIPlugin.imageDescriptorFromPlugin(CUIPlugin.PLUGIN_ID,
+ "$nl$/icons/ovr16/indexedFile.gif"); //$NON-NLS-1$
- @Override
+ public IndexedFilesLabelProvider() {
+ }
+
+ @Override
public void addListener(ILabelProviderListener listener) {
- }
+ }
- @Override
+ @Override
public void dispose() {
- }
+ }
- @Override
+ @Override
public boolean isLabelProperty(Object element, String property) {
- return false;
- }
+ return false;
+ }
- @Override
+ @Override
public void removeListener(ILabelProviderListener listener) {
- }
+ }
- /**
- * Adds the linked resource overlay if the given element is a linked
- * resource.
- *
- * @param element element to decorate
- * @param decoration The decoration we are adding to
- * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(Object, IDecoration)
- */
- @Override
+ /**
+ * Adds the linked resource overlay if the given element is a linked
+ * resource.
+ *
+ * @param element element to decorate
+ * @param decoration The decoration we are adding to
+ * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(Object, IDecoration)
+ */
+ @Override
public void decorate(Object element, IDecoration decoration) {
- IIndexFileLocation ifl= null;
- IProject project= null;
- if (element instanceof IFile) {
- final IFile file = (IFile) element;
- project= file.getProject();
-
+ IIndexFileLocation ifl = null;
+ IProject project = null;
+ if (element instanceof IFile) {
+ final IFile file = (IFile) element;
+ project = file.getProject();
+
try {
- if (project.hasNature(CProjectNature.C_NATURE_ID)
- || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
ifl = IndexLocationFactory.getWorkspaceIFL(file);
}
} catch (CoreException e) {
CUIPlugin.log(e);
}
-
- }
- else if (element instanceof ITranslationUnit) {
- final ITranslationUnit tu = (ITranslationUnit) element;
- ifl= IndexLocationFactory.getIFL(tu);
- project= tu.getCProject().getProject();
- }
- if (ifl != null && isIndexed(project, ifl)) {
- decoration.addOverlay(INDEXED, IDecoration.TOP_LEFT);
- }
- }
+
+ } else if (element instanceof ITranslationUnit) {
+ final ITranslationUnit tu = (ITranslationUnit) element;
+ ifl = IndexLocationFactory.getIFL(tu);
+ project = tu.getCProject().getProject();
+ }
+ if (ifl != null && isIndexed(project, ifl)) {
+ decoration.addOverlay(INDEXED, IDecoration.TOP_LEFT);
+ }
+ }
private boolean isIndexed(IProject project, IIndexFileLocation ifl) {
if (project == null || ifl == null) {
return false;
}
-
+
return IndexedFilesCache.getInstance().isIndexed(project, ifl);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPresenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPresenter.java
index 2cdb7b0da09..1513e1163cc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPresenter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPresenter.java
@@ -54,47 +54,50 @@ import org.eclipse.cdt.internal.ui.editor.EditorHighlightingSynchronizer;
* Does the setup of the linked mode from a {@link LinkedProposalModel}
*/
public class LinkedProposalModelPresenter {
-
+
public LinkedProposalModelPresenter() {
}
-
- public void enterLinkedMode(ITextViewer viewer, IEditorPart editor, LinkedProposalModel linkedProposalModel) throws BadLocationException {
- IDocument document= viewer.getDocument();
- LinkedModeModel model= new LinkedModeModel();
- boolean added= false;
+ public void enterLinkedMode(ITextViewer viewer, IEditorPart editor, LinkedProposalModel linkedProposalModel)
+ throws BadLocationException {
+ IDocument document = viewer.getDocument();
+
+ LinkedModeModel model = new LinkedModeModel();
+ boolean added = false;
- Iterator<LinkedProposalPositionGroup> iterator= linkedProposalModel.getPositionGroupIterator();
+ Iterator<LinkedProposalPositionGroup> iterator = linkedProposalModel.getPositionGroupIterator();
while (iterator.hasNext()) {
- LinkedProposalPositionGroup curr= iterator.next();
+ LinkedProposalPositionGroup curr = iterator.next();
- LinkedPositionGroup group= new LinkedPositionGroup();
+ LinkedPositionGroup group = new LinkedPositionGroup();
- LinkedProposalPositionGroup.PositionInformation[] positions= curr.getPositions();
+ LinkedProposalPositionGroup.PositionInformation[] positions = curr.getPositions();
if (positions.length > 0) {
- LinkedProposalPositionGroup.Proposal[] linkedModeProposals= curr.getProposals();
+ LinkedProposalPositionGroup.Proposal[] linkedModeProposals = curr.getProposals();
if (linkedModeProposals.length <= 1) {
- for (int i= 0; i < positions.length; i++) {
- LinkedProposalPositionGroup.PositionInformation pos= positions[i];
+ for (int i = 0; i < positions.length; i++) {
+ LinkedProposalPositionGroup.PositionInformation pos = positions[i];
if (pos.getOffset() != -1) {
- group.addPosition(new LinkedPosition(document, pos.getOffset(), pos.getLength(), pos.getSequenceRank()));
+ group.addPosition(new LinkedPosition(document, pos.getOffset(), pos.getLength(),
+ pos.getSequenceRank()));
}
}
} else {
- LinkedPositionProposalImpl[] proposalImpls= new LinkedPositionProposalImpl[linkedModeProposals.length];
- for (int i= 0; i < linkedModeProposals.length; i++) {
- proposalImpls[i]= new LinkedPositionProposalImpl(linkedModeProposals[i], model);
+ LinkedPositionProposalImpl[] proposalImpls = new LinkedPositionProposalImpl[linkedModeProposals.length];
+ for (int i = 0; i < linkedModeProposals.length; i++) {
+ proposalImpls[i] = new LinkedPositionProposalImpl(linkedModeProposals[i], model);
}
- for (int i= 0; i < positions.length; i++) {
- LinkedProposalPositionGroup.PositionInformation pos= positions[i];
+ for (int i = 0; i < positions.length; i++) {
+ LinkedProposalPositionGroup.PositionInformation pos = positions[i];
if (pos.getOffset() != -1) {
- group.addPosition(new ProposalPosition(document, pos.getOffset(), pos.getLength(), pos.getSequenceRank(), proposalImpls));
+ group.addPosition(new ProposalPosition(document, pos.getOffset(), pos.getLength(),
+ pos.getSequenceRank(), proposalImpls));
}
}
}
model.addGroup(group);
- added= true;
+ added = true;
}
}
@@ -105,12 +108,12 @@ public class LinkedProposalModelPresenter {
}
if (added) { // only set up UI if there are any positions set
- LinkedModeUI ui= new EditorLinkedModeUI(model, viewer);
- LinkedProposalPositionGroup.PositionInformation endPosition= linkedProposalModel.getEndPosition();
+ LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
+ LinkedProposalPositionGroup.PositionInformation endPosition = linkedProposalModel.getEndPosition();
if (endPosition != null && endPosition.getOffset() != -1) {
ui.setExitPosition(viewer, endPosition.getOffset() + endPosition.getLength(), 0, Integer.MAX_VALUE);
} else {
- int cursorPosition= viewer.getSelectedRange().x;
+ int cursorPosition = viewer.getSelectedRange().x;
if (cursorPosition != 0) {
ui.setExitPosition(viewer, cursorPosition, 0, Integer.MAX_VALUE);
}
@@ -118,7 +121,7 @@ public class LinkedProposalModelPresenter {
ui.setExitPolicy(new LinkedModeExitPolicy());
ui.enter();
- IRegion region= ui.getSelectedRegion();
+ IRegion region = ui.getSelectedRegion();
viewer.setSelectedRange(region.getOffset(), region.getLength());
viewer.revealRange(region.getOffset(), region.getLength());
}
@@ -129,8 +132,8 @@ public class LinkedProposalModelPresenter {
private final LinkedModeModel fLinkedPositionModel;
public LinkedPositionProposalImpl(LinkedProposalPositionGroup.Proposal proposal, LinkedModeModel model) {
- fProposal= proposal;
- fLinkedPositionModel= model;
+ fProposal = proposal;
+ fLinkedPositionModel = model;
}
/* (non-Javadoc)
@@ -138,19 +141,22 @@ public class LinkedProposalModelPresenter {
*/
@Override
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDocument doc= viewer.getDocument();
- LinkedPosition position= fLinkedPositionModel.findPosition(new LinkedPosition(doc, offset, 0));
+ IDocument doc = viewer.getDocument();
+ LinkedPosition position = fLinkedPositionModel.findPosition(new LinkedPosition(doc, offset, 0));
if (position != null) {
try {
try {
- TextEdit edit= fProposal.computeEdits(offset, position, trigger, stateMask, fLinkedPositionModel);
+ TextEdit edit = fProposal.computeEdits(offset, position, trigger, stateMask,
+ fLinkedPositionModel);
if (edit != null) {
edit.apply(position.getDocument(), 0);
}
} catch (MalformedTreeException e) {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR, "Unexpected exception applying edit", e)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR,
+ "Unexpected exception applying edit", e)); //$NON-NLS-1$
} catch (BadLocationException e) {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR, "Unexpected exception applying edit", e)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR,
+ "Unexpected exception applying edit", e)); //$NON-NLS-1$
}
} catch (CoreException e) {
CUIPlugin.log(e);
@@ -199,13 +205,22 @@ public class LinkedProposalModelPresenter {
}
@Override
- public Point getSelection(IDocument document) { return null; }
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
@Override
- public IContextInformation getContextInformation() { return null; }
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
@Override
- public void selected(ITextViewer viewer, boolean smartToggle) {}
+ public void selected(ITextViewer viewer, boolean smartToggle) {
+ }
+
@Override
- public void unselected(ITextViewer viewer) {}
+ public void unselected(ITextViewer viewer) {
+ }
/*
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
@@ -213,20 +228,20 @@ public class LinkedProposalModelPresenter {
@Override
public boolean validate(IDocument document, int offset, DocumentEvent event) {
// ignore event
- String insert= getDisplayString();
+ String insert = getDisplayString();
int off;
- LinkedPosition pos= fLinkedPositionModel.findPosition(new LinkedPosition(document, offset, 0));
+ LinkedPosition pos = fLinkedPositionModel.findPosition(new LinkedPosition(document, offset, 0));
if (pos != null) {
- off= pos.getOffset();
+ off = pos.getOffset();
} else {
- off= Math.max(0, offset - insert.length());
+ off = Math.max(0, offset - insert.length());
}
- int length= offset - off;
+ int length = offset - off;
if (offset <= document.getLength()) {
try {
- String content= document.get(off, length);
+ String content = document.get(off, length);
if (insert.startsWith(content))
return true;
} catch (BadLocationException e) {
@@ -242,11 +257,11 @@ public class LinkedProposalModelPresenter {
return getDisplayString();
}
}
-
+
private static class LinkedModeExitPolicy implements LinkedModeUI.IExitPolicy {
@Override
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
- if (event.character == '=') {
+ if (event.character == '=') {
return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.java
index 9a9c1518f52..1c512ebbfb7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
@@ -18,15 +18,15 @@ import java.util.List;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
-/**
+/**
* A specialized content provider to show a list of editor parts.
- */
+ */
public class ListContentProvider implements IStructuredContentProvider {
- List<?> fContents;
+ List<?> fContents;
public ListContentProvider() {
}
-
+
@Override
public Object[] getElements(Object input) {
if (fContents != null && fContents == input)
@@ -36,17 +36,17 @@ public class ListContentProvider implements IStructuredContentProvider {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof List<?>)
- fContents= (List<?>)newInput;
+ if (newInput instanceof List<?>)
+ fContents = (List<?>) newInput;
else
- fContents= null;
+ fContents = null;
// we use a fixed set.
}
@Override
public void dispose() {
}
-
+
public boolean isDeleted(Object o) {
return fContents != null && !fContents.contains(o);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java
index a93dcaff2ff..0b70ff04882 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java
@@ -24,23 +24,22 @@ import org.eclipse.cdt.core.model.IMember;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-
/**
* Filter for the methods viewer.
* Changing a filter property does not trigger a refiltering of the viewer
*/
-public class MemberFilter extends ViewerFilter{
+public class MemberFilter extends ViewerFilter {
+
+ public static final int FILTER_NONPUBLIC = 1;
+ public static final int FILTER_STATIC = 2;
+ public static final int FILTER_FIELDS = 4;
+ public static final int FILTER_INACTIVE = 0x10;
- public static final int FILTER_NONPUBLIC= 1;
- public static final int FILTER_STATIC= 2;
- public static final int FILTER_FIELDS= 4;
- public static final int FILTER_INACTIVE= 0x10;
-
/** @deprecated Unsupported filter constant */
@Deprecated
- public static final int FILTER_LOCALTYPES= 8;
-
+ public static final int FILTER_LOCALTYPES = 8;
+
private int fFilterProperties;
/**
@@ -49,45 +48,48 @@ public class MemberFilter extends ViewerFilter{
public final void addFilter(int filter) {
fFilterProperties |= filter;
}
+
/**
* Modifies filter and remove a property to filter for
- */
+ */
public final void removeFilter(int filter) {
fFilterProperties &= (-1 ^ filter);
}
+
/**
* Tests if a property is filtered
- */
+ */
public final boolean hasFilter(int filter) {
return (fFilterProperties & filter) != 0;
}
-
+
/*
* @see ViewerFilter@isFilterProperty
*/
public boolean isFilterProperty(Object element, Object property) {
return false;
}
+
/*
* @see ViewerFilter@select
- */
+ */
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if(element instanceof IDeclaration){
+ if (element instanceof IDeclaration) {
try {
IDeclaration declaration = (IDeclaration) element;
- if (hasFilter(FILTER_STATIC) && (declaration.isStatic()) ) {
+ if (hasFilter(FILTER_STATIC) && (declaration.isStatic())) {
return false;
}
if (element instanceof IMember) {
- IMember member= (IMember)element;
+ IMember member = (IMember) element;
if (hasFilter(FILTER_NONPUBLIC) && (member.getVisibility() != ASTAccessVisibility.PUBLIC)) {
return false;
}
-
+
if (hasFilter(FILTER_FIELDS) && element instanceof IField) {
return false;
- }
+ }
}
} catch (CModelException e) {
// ignore
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java
index 776039cf0ce..18c2e1dc16d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java
@@ -26,30 +26,31 @@ public class MemberFilterAction extends Action {
private int fFilterProperty;
private MemberFilterActionGroup fFilterActionGroup;
-
- public MemberFilterAction(MemberFilterActionGroup actionGroup, String title, int property, String contextHelpId, boolean initValue) {
+
+ public MemberFilterAction(MemberFilterActionGroup actionGroup, String title, int property, String contextHelpId,
+ boolean initValue) {
super(title);
- fFilterActionGroup= actionGroup;
- fFilterProperty= property;
-
+ fFilterActionGroup = actionGroup;
+ fFilterProperty = property;
+
if (contextHelpId != null) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, contextHelpId);
}
setChecked(initValue);
}
-
+
/**
* Returns this action's filter property.
*/
public int getFilterProperty() {
return fFilterProperty;
}
-
+
/*
* @see Action#actionPerformed
*/
@Override
- public void run() {
+ public void run() {
fFilterActionGroup.setMemberFilter(fFilterProperty, isChecked());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
index f08e60b2157..97f46b99e09 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
@@ -71,7 +71,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
public ProblemsLabelChangedEvent(IBaseLabelProvider source, IResource[] changedResource,
boolean isMarkerChange) {
super(source, changedResource);
- fMarkerChange= isMarkerChange;
+ fMarkerChange = isMarkerChange;
}
/**
@@ -94,7 +94,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
this.res = res;
this.depth = depth;
}
-
+
@Override
public int hashCode() {
return res.hashCode() + 31 * depth;
@@ -113,8 +113,8 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
}
- private static final int ERRORTICK_WARNING= CElementImageDescriptor.WARNING;
- private static final int ERRORTICK_ERROR= CElementImageDescriptor.ERROR;
+ private static final int ERRORTICK_WARNING = CElementImageDescriptor.WARNING;
+ private static final int ERRORTICK_ERROR = CElementImageDescriptor.ERROR;
private static final IMarker[] EMPTY_MARKER_ARRAY = {};
private ImageDescriptorRegistry fRegistry;
@@ -129,7 +129,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
*/
public ProblemsLabelDecorator() {
this(null);
- fUseNewRegistry= true;
+ fUseNewRegistry = true;
}
/**
@@ -140,13 +140,13 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
* image registry.
*/
public ProblemsLabelDecorator(ImageDescriptorRegistry registry) {
- fRegistry= registry;
- fProblemChangedListener= null;
+ fRegistry = registry;
+ fProblemChangedListener = null;
}
private ImageDescriptorRegistry getRegistry() {
if (fRegistry == null) {
- fRegistry= fUseNewRegistry ? new ImageDescriptorRegistry() : CUIPlugin.getImageDescriptorRegistry();
+ fRegistry = fUseNewRegistry ? new ImageDescriptorRegistry() : CUIPlugin.getImageDescriptorRegistry();
}
return fRegistry;
}
@@ -158,11 +158,12 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
@Override
public Image decorateImage(Image image, Object obj) {
- int adornmentFlags= computeAdornmentFlags(obj);
+ int adornmentFlags = computeAdornmentFlags(obj);
if (adornmentFlags != 0) {
- ImageDescriptor baseImage= new ImageImageDescriptor(image);
- Rectangle bounds= image.getBounds();
- return getRegistry().get(new CElementImageDescriptor(baseImage, adornmentFlags, new Point(bounds.width, bounds.height)));
+ ImageDescriptor baseImage = new ImageImageDescriptor(image);
+ Rectangle bounds = image.getBounds();
+ return getRegistry().get(
+ new CElementImageDescriptor(baseImage, adornmentFlags, new Point(bounds.width, bounds.height)));
}
return image;
}
@@ -173,25 +174,26 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
protected int computeAdornmentFlags(Object obj) {
try {
if (obj instanceof ICElement) {
- ICElement element= (ICElement) obj;
- int type= element.getElementType();
+ ICElement element = (ICElement) obj;
+ int type = element.getElementType();
switch (type) {
- case ICElement.C_PROJECT:
- case ICElement.C_CCONTAINER:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
- case ICElement.C_UNIT:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
- case ICElement.C_FUNCTION:
- case ICElement.C_CLASS:
- case ICElement.C_UNION:
- case ICElement.C_STRUCT:
- case ICElement.C_VARIABLE:
- case ICElement.C_METHOD:
- ITranslationUnit tu= ((ISourceReference)element).getTranslationUnit();
- if (tu != null && tu.exists()) {
- return getErrorTicksFromMarkers(tu.getResource(), IResource.DEPTH_ONE, (ISourceReference)element);
- }
- break;
+ case ICElement.C_PROJECT:
+ case ICElement.C_CCONTAINER:
+ return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
+ case ICElement.C_UNIT:
+ return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
+ case ICElement.C_FUNCTION:
+ case ICElement.C_CLASS:
+ case ICElement.C_UNION:
+ case ICElement.C_STRUCT:
+ case ICElement.C_VARIABLE:
+ case ICElement.C_METHOD:
+ ITranslationUnit tu = ((ISourceReference) element).getTranslationUnit();
+ if (tu != null && tu.exists()) {
+ return getErrorTicksFromMarkers(tu.getResource(), IResource.DEPTH_ONE,
+ (ISourceReference) element);
+ }
+ break;
}
} else if (obj instanceof IResource) {
return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null);
@@ -211,24 +213,24 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
if (res == null || !res.isAccessible()) {
return 0;
}
- int info= 0;
+ int info = 0;
MarkersCacheKey cacheKey = new MarkersCacheKey(res, depth);
- IMarker[] markers = fMarkersCache .get(cacheKey);
+ IMarker[] markers = fMarkersCache.get(cacheKey);
if (markers == null) {
- markers= res.findMarkers(IMarker.PROBLEM, true, depth);
+ markers = res.findMarkers(IMarker.PROBLEM, true, depth);
if (markers == null)
markers = EMPTY_MARKER_ARRAY;
fMarkersCache.put(cacheKey, markers);
}
- for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {
- IMarker curr= markers[i];
+ for (int i = 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {
+ IMarker curr = markers[i];
if (sourceElement == null || isMarkerInRange(curr, sourceElement)) {
- int priority= curr.getAttribute(IMarker.SEVERITY, -1);
+ int priority = curr.getAttribute(IMarker.SEVERITY, -1);
if (priority == IMarker.SEVERITY_WARNING) {
- info= ERRORTICK_WARNING;
+ info = ERRORTICK_WARNING;
} else if (priority == IMarker.SEVERITY_ERROR) {
- info= ERRORTICK_ERROR;
+ info = ERRORTICK_ERROR;
}
}
}
@@ -237,11 +239,11 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
private boolean isMarkerInRange(IMarker marker, ISourceReference sourceElement) throws CoreException {
if (marker.isSubtypeOf(IMarker.TEXT)) {
- int pos= marker.getAttribute(IMarker.CHAR_START, -1);
+ int pos = marker.getAttribute(IMarker.CHAR_START, -1);
if (pos == -1) {
- int line= MarkerUtilities.getLineNumber(marker);
+ int line = MarkerUtilities.getLineNumber(marker);
if (line >= 0) {
- return isInside( -1, line, sourceElement);
+ return isInside(-1, line, sourceElement);
}
}
return isInside(pos, -1, sourceElement);
@@ -263,12 +265,12 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
* @since 2.1
*/
protected boolean isInside(int offSet, int line, ISourceReference sourceElement) throws CoreException {
- ISourceRange range= sourceElement.getSourceRange();
+ ISourceRange range = sourceElement.getSourceRange();
if (range != null) {
if (offSet == -1) {
return (line >= range.getStartLine() && line <= range.getEndLine());
}
- int rangeOffset= range.getStartPos();
+ int rangeOffset = range.getStartPos();
return (rangeOffset <= offSet && rangeOffset + range.getLength() > offSet);
}
return false;
@@ -278,7 +280,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
public void dispose() {
if (fProblemChangedListener != null) {
CUIPlugin.getDefault().getProblemMarkerManager().removeListener(fProblemChangedListener);
- fProblemChangedListener= null;
+ fProblemChangedListener = null;
}
if (fRegistry != null && fUseNewRegistry) {
fRegistry.dispose();
@@ -293,11 +295,12 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
@Override
public void addListener(ILabelProviderListener listener) {
if (fListeners == null) {
- fListeners= new ListenerList<>();
+ fListeners = new ListenerList<>();
}
fListeners.add(listener);
if (fProblemChangedListener == null) {
- fProblemChangedListener= (changedResources, isMarkerChange) -> fireProblemsChanged(changedResources, isMarkerChange);
+ fProblemChangedListener = (changedResources, isMarkerChange) -> fireProblemsChanged(changedResources,
+ isMarkerChange);
CUIPlugin.getDefault().getProblemMarkerManager().addListener(fProblemChangedListener);
}
}
@@ -308,7 +311,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
fListeners.remove(listener);
if (fListeners.isEmpty() && fProblemChangedListener != null) {
CUIPlugin.getDefault().getProblemMarkerManager().removeListener(fProblemChangedListener);
- fProblemChangedListener= null;
+ fProblemChangedListener = null;
}
}
}
@@ -316,7 +319,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
protected void fireProblemsChanged(IResource[] changedResources, boolean isMarkerChange) {
fMarkersCache.clear();
if (fListeners != null && !fListeners.isEmpty()) {
- LabelProviderChangedEvent event= new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange);
+ LabelProviderChangedEvent event = new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange);
for (ILabelProviderListener listener : fListeners) {
listener.labelProviderChanged(event);
}
@@ -325,7 +328,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
@Override
public void decorate(Object element, IDecoration decoration) {
- int adornmentFlags= computeAdornmentFlags(element);
+ int adornmentFlags = computeAdornmentFlags(element);
if (adornmentFlags == ERRORTICK_ERROR) {
decoration.addOverlay(CPluginImages.DESC_OVR_ERROR);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.java
index c11c7a56163..8d57219bd64 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.java
@@ -35,18 +35,19 @@ import org.eclipse.cdt.ui.CUIPlugin;
* @since 5.0
*/
public final class ProjectTemplateStore {
- private static final String KEY= "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$
+ private static final String KEY = "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$
private final TemplateStore fInstanceStore;
private final TemplateStore fProjectStore;
public ProjectTemplateStore(IProject project) {
- fInstanceStore= CUIPlugin.getDefault().getCodeTemplateStore();
+ fInstanceStore = CUIPlugin.getDefault().getCodeTemplateStore();
if (project == null) {
- fProjectStore= null;
+ fProjectStore = null;
} else {
- final ScopedPreferenceStore projectSettings= new ScopedPreferenceStore(new ProjectScope(project), CUIPlugin.PLUGIN_ID);
- fProjectStore= new TemplateStore(projectSettings, KEY) {
+ final ScopedPreferenceStore projectSettings = new ScopedPreferenceStore(new ProjectScope(project),
+ CUIPlugin.PLUGIN_ID);
+ fProjectStore = new TemplateStore(projectSettings, KEY) {
/*
* Make sure we keep the id of added code templates - add removes
* it in the usual add() method
@@ -62,8 +63,8 @@ public final class ProjectTemplateStore {
@Override
public void save() throws IOException {
- StringWriter output= new StringWriter();
- TemplateReaderWriter writer= new TemplateReaderWriter();
+ StringWriter output = new StringWriter();
+ TemplateReaderWriter writer = new TemplateReaderWriter();
writer.save(getTemplateData(false), output);
projectSettings.setValue(KEY, output.toString());
@@ -74,13 +75,13 @@ public final class ProjectTemplateStore {
}
public static boolean hasProjectSpecificTempates(IProject project) {
- String pref= new ProjectScope(project).getNode(CUIPlugin.PLUGIN_ID).get(KEY, null);
+ String pref = new ProjectScope(project).getNode(CUIPlugin.PLUGIN_ID).get(KEY, null);
if (pref != null && pref.trim().length() > 0) {
- Reader input= new StringReader(pref);
- TemplateReaderWriter reader= new TemplateReaderWriter();
+ Reader input = new StringReader(pref);
+ TemplateReaderWriter reader = new TemplateReaderWriter();
TemplatePersistenceData[] datas;
try {
- datas= reader.read(input);
+ datas = reader.read(input);
return datas.length > 0;
} catch (IOException e) {
// ignore
@@ -97,11 +98,11 @@ public final class ProjectTemplateStore {
}
public Template findTemplateById(String id) {
- Template template= null;
+ Template template = null;
if (fProjectStore != null)
- template= fProjectStore.findTemplateById(id);
+ template = fProjectStore.findTemplateById(id);
if (template == null)
- template= fInstanceStore.findTemplateById(id);
+ template = fInstanceStore.findTemplateById(id);
return template;
}
@@ -110,24 +111,25 @@ public final class ProjectTemplateStore {
if (fProjectStore != null) {
fProjectStore.load();
- Set<String> datas= new HashSet<String>();
- TemplatePersistenceData[] data= fProjectStore.getTemplateData(false);
+ Set<String> datas = new HashSet<String>();
+ TemplatePersistenceData[] data = fProjectStore.getTemplateData(false);
for (TemplatePersistenceData element : data) {
- String id= element.getId();
+ String id = element.getId();
if (id == null) {
- id= element.getTemplate().getName();
+ id = element.getTemplate().getName();
}
datas.add(id);
}
- data= fInstanceStore.getTemplateData(false);
+ data = fInstanceStore.getTemplateData(false);
for (TemplatePersistenceData orig : data) {
- String origId= orig.getId();
+ String origId = orig.getId();
if (origId == null) {
- origId= orig.getTemplate().getName();
+ origId = orig.getTemplate().getName();
}
if (!datas.contains(orig.getId())) {
- TemplatePersistenceData copy= new TemplatePersistenceData(new Template(orig.getTemplate()), orig.isEnabled(), orig.getId());
+ TemplatePersistenceData copy = new TemplatePersistenceData(new Template(orig.getTemplate()),
+ orig.isEnabled(), orig.getId());
fProjectStore.add(copy);
copy.setDeleted(true);
}
@@ -149,7 +151,7 @@ public final class ProjectTemplateStore {
public void setProjectSpecific(String id, boolean projectSpecific) {
Assert.isNotNull(fProjectStore);
- TemplatePersistenceData data= fProjectStore.getTemplateData(id);
+ TemplatePersistenceData data = fProjectStore.getTemplateData(id);
if (data == null) {
return; // does not exist
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java
index f48959acea8..14dce94b7e6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java
@@ -45,17 +45,17 @@ import org.eclipse.cdt.internal.ui.editor.ASTProvider;
*/
public class SelectionListenerWithASTManager {
private static SelectionListenerWithASTManager fgDefault;
-
+
/**
* @return Returns the default manager instance.
*/
public static SelectionListenerWithASTManager getDefault() {
if (fgDefault == null) {
- fgDefault= new SelectionListenerWithASTManager();
+ fgDefault = new SelectionListenerWithASTManager();
}
return fgDefault;
}
-
+
private final static class PartListenerGroup {
private ITextEditor fPart;
private ISelectionListener fPostSelectionListener;
@@ -63,22 +63,22 @@ public class SelectionListenerWithASTManager {
private Job fCurrentJob;
private ListenerList<ISelectionListenerWithAST> fAstListeners;
/** Rule to make sure only one job is running at a time */
- private final ILock fJobLock= Job.getJobManager().newLock();
+ private final ILock fJobLock = Job.getJobManager().newLock();
private ISelectionValidator fValidator;
-
+
public PartListenerGroup(ITextEditor editorPart) {
- fPart= editorPart;
- fCurrentJob= null;
- fAstListeners= new ListenerList<>(ListenerList.IDENTITY);
-
- fSelectionListener= event -> {
- ISelection selection= event.getSelection();
+ fPart = editorPart;
+ fCurrentJob = null;
+ fAstListeners = new ListenerList<>(ListenerList.IDENTITY);
+
+ fSelectionListener = event -> {
+ ISelection selection = event.getSelection();
if (selection instanceof ITextSelection) {
fireSelectionChanged((ITextSelection) selection);
}
};
-
- fPostSelectionListener= (part, selection) -> {
+
+ fPostSelectionListener = (part, selection) -> {
if (part == fPart && selection instanceof ITextSelection)
firePostSelectionChanged((ITextSelection) selection);
};
@@ -91,50 +91,52 @@ public class SelectionListenerWithASTManager {
public void install(ISelectionListenerWithAST listener) {
if (isEmpty()) {
fPart.getEditorSite().getPage().addPostSelectionListener(fPostSelectionListener);
- ISelectionProvider selectionProvider= fPart.getSelectionProvider();
+ ISelectionProvider selectionProvider = fPart.getSelectionProvider();
if (selectionProvider != null) {
selectionProvider.addSelectionChangedListener(fSelectionListener);
if (selectionProvider instanceof ISelectionValidator) {
- fValidator= (ISelectionValidator) selectionProvider;
+ fValidator = (ISelectionValidator) selectionProvider;
}
}
}
fAstListeners.add(listener);
}
-
+
public void uninstall(ISelectionListenerWithAST listener) {
fAstListeners.remove(listener);
if (isEmpty()) {
fPart.getEditorSite().getPage().removePostSelectionListener(fPostSelectionListener);
- ISelectionProvider selectionProvider= fPart.getSelectionProvider();
+ ISelectionProvider selectionProvider = fPart.getSelectionProvider();
if (selectionProvider != null) {
selectionProvider.removeSelectionChangedListener(fSelectionListener);
}
- fValidator= null;
+ fValidator = null;
}
}
-
+
public void fireSelectionChanged(final ITextSelection selection) {
if (fCurrentJob != null) {
fCurrentJob.cancel();
}
}
-
+
public void firePostSelectionChanged(final ITextSelection selection) {
if (fCurrentJob != null) {
fCurrentJob.cancel();
}
-
- final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fPart.getEditorInput());
+
+ final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager()
+ .getWorkingCopy(fPart.getEditorInput());
if (workingCopy == null)
return;
-
- fCurrentJob= new Job(Messages.SelectionListenerWithASTManager_jobName) {
+
+ fCurrentJob = new Job(Messages.SelectionListenerWithASTManager_jobName) {
@Override
public IStatus run(IProgressMonitor monitor) {
try {
// Try to acquire the lock
- while (!monitor.isCanceled() && !fJobLock.acquire(10)) {}
+ while (!monitor.isCanceled() && !fJobLock.acquire(10)) {
+ }
if (!monitor.isCanceled() && isSelectionValid(selection)) {
return calculateASTandInform(workingCopy, selection, monitor);
}
@@ -153,7 +155,7 @@ public class SelectionListenerWithASTManager {
/**
* Verify that selection is still valid.
- *
+ *
* @param selection
* @return <code>true</code> if selection is valid
*/
@@ -161,41 +163,43 @@ public class SelectionListenerWithASTManager {
return fValidator == null || fValidator.isValid(selection);
}
- protected IStatus calculateASTandInform(final IWorkingCopy workingCopy, final ITextSelection selection, final IProgressMonitor monitor) {
- return ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, monitor, new ASTRunnable() {
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
- if (astRoot != null && !monitor.isCanceled() && isSelectionValid(selection)) {
- Object[] listeners;
- synchronized (PartListenerGroup.this) {
- listeners= fAstListeners.getListeners();
- }
- for (int i= 0; i < listeners.length; i++) {
- final Object l = listeners[i];
- try {
- ((ISelectionListenerWithAST) l).selectionChanged(fPart, selection, astRoot);
- } catch (RuntimeException e) {
- CUIPlugin.log(e);
- fAstListeners.remove(l);
- } catch (OutOfMemoryError e) {
- CUIPlugin.log(e);
- fAstListeners.remove(l);
+ protected IStatus calculateASTandInform(final IWorkingCopy workingCopy, final ITextSelection selection,
+ final IProgressMonitor monitor) {
+ return ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, monitor,
+ new ASTRunnable() {
+ @Override
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
+ if (astRoot != null && !monitor.isCanceled() && isSelectionValid(selection)) {
+ Object[] listeners;
+ synchronized (PartListenerGroup.this) {
+ listeners = fAstListeners.getListeners();
+ }
+ for (int i = 0; i < listeners.length; i++) {
+ final Object l = listeners[i];
+ try {
+ ((ISelectionListenerWithAST) l).selectionChanged(fPart, selection, astRoot);
+ } catch (RuntimeException e) {
+ CUIPlugin.log(e);
+ fAstListeners.remove(l);
+ } catch (OutOfMemoryError e) {
+ CUIPlugin.log(e);
+ fAstListeners.remove(l);
+ }
+ }
+ return Status.OK_STATUS;
}
+ return Status.CANCEL_STATUS;
}
- return Status.OK_STATUS;
- }
- return Status.CANCEL_STATUS;
- }
- });
+ });
}
}
-
+
private Map<ITextEditor, PartListenerGroup> fListenerGroups;
-
+
private SelectionListenerWithASTManager() {
- fListenerGroups= new HashMap<ITextEditor, PartListenerGroup>();
+ fListenerGroups = new HashMap<ITextEditor, PartListenerGroup>();
}
-
+
/**
* Registers a selection listener for the given editor part.
* @param part The editor part to listen to.
@@ -203,9 +207,9 @@ public class SelectionListenerWithASTManager {
*/
public void addListener(ITextEditor part, ISelectionListenerWithAST listener) {
synchronized (this) {
- PartListenerGroup partListener= fListenerGroups.get(part);
+ PartListenerGroup partListener = fListenerGroups.get(part);
if (partListener == null) {
- partListener= new PartListenerGroup(part);
+ partListener = new PartListenerGroup(part);
fListenerGroups.put(part, partListener);
}
partListener.install(listener);
@@ -219,7 +223,7 @@ public class SelectionListenerWithASTManager {
*/
public void removeListener(ITextEditor part, ISelectionListenerWithAST listener) {
synchronized (this) {
- PartListenerGroup partListener= fListenerGroups.get(part);
+ PartListenerGroup partListener = fListenerGroups.get(part);
if (partListener != null) {
partListener.uninstall(listener);
if (partListener.isEmpty()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediator.java
index 07b991fabc7..706a45da22c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediator.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
@@ -29,46 +29,47 @@ import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Control;
public class SelectionProviderMediator implements ISelectionProvider {
- private Map<Control, ISelectionProvider> fProviders= new HashMap<Control, ISelectionProvider>();
+ private Map<Control, ISelectionProvider> fProviders = new HashMap<Control, ISelectionProvider>();
private ISelectionProvider fActiveProvider = null;
private ISelectionChangedListener fSelectionChangedListener;
private FocusListener fFocusListener;
- private ListenerList<ISelectionChangedListener> fListenerList= new ListenerList<>();
+ private ListenerList<ISelectionChangedListener> fListenerList = new ListenerList<>();
public SelectionProviderMediator() {
- fSelectionChangedListener= event -> onSelectionChanged(event);
+ fSelectionChangedListener = event -> onSelectionChanged(event);
fFocusListener = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
onFocusGained(e);
}
+
@Override
public void focusLost(FocusEvent e) {
}
};
}
- @Override
+ @Override
final public void addSelectionChangedListener(ISelectionChangedListener listener) {
- fListenerList.add(listener);
- }
+ fListenerList.add(listener);
+ }
- @Override
+ @Override
final public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- fListenerList.remove(listener);
- }
+ fListenerList.remove(listener);
+ }
final protected void fireSelectionChanged() {
if (!fListenerList.isEmpty()) {
- SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
-
+ SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
+
for (ISelectionChangedListener listener : fListenerList) {
listener.selectionChanged(event);
}
}
}
-
+
public void addViewer(Viewer viewer) {
addSelectionProvider(viewer.getControl(), viewer);
}
@@ -87,6 +88,7 @@ public class SelectionProviderMediator implements ISelectionProvider {
}
return StructuredSelection.EMPTY;
}
+
// overrider
@Override
public void setSelection(ISelection selection) {
@@ -96,9 +98,9 @@ public class SelectionProviderMediator implements ISelectionProvider {
}
protected void onFocusGained(FocusEvent e) {
- ISelectionProvider provider= fProviders.get(e.widget);
+ ISelectionProvider provider = fProviders.get(e.widget);
if (provider != null) {
- fActiveProvider= provider;
+ fActiveProvider = provider;
fireSelectionChanged();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelProvider.java
index 5e01702064e..8134274f466 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelProvider.java
@@ -14,17 +14,15 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
-
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.cdt.ui.CUIPlugin;
-
/**
* CElementLabelProvider that respects settings from the Appearance preference page.
* Triggers a viewer update when a preference changes.
- *
+ *
* @deprecated Use {@link AppearanceAwareLabelProvider} instead.
*/
@Deprecated
@@ -43,11 +41,11 @@ public class StandardCElementLabelProvider extends AppearanceAwareLabelProvider
/**
* Creates a StandardCElementLabelProvider with DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS
* and the ErrorTickAdornmentProvider.
- */
+ */
public StandardCElementLabelProvider() {
super();
}
-
+
private void initMasks() {
// turn on or off the flags depending on property/preference changes.
}
@@ -64,7 +62,7 @@ public class StandardCElementLabelProvider extends AppearanceAwareLabelProvider
initMasks();
LabelProviderChangedEvent lpEvent= new LabelProviderChangedEvent(this, null); // refresh all
fireLabelProviderChanged(lpEvent);
- } */
+ } */
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java
index c2d47249b39..0bce2b19938 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
-
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
@@ -32,54 +31,53 @@ import org.eclipse.osgi.util.NLS;
* describing the selected elements.
*/
public class StatusBarUpdater implements ISelectionChangedListener {
-
- private final long LABEL_FLAGS= CElementLabels.DEFAULT_QUALIFIED | CElementLabels.ROOT_POST_QUALIFIED | CElementLabels.APPEND_ROOT_PATH |
- CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.M_EXCEPTIONS |
- CElementLabels.F_APP_TYPE_SIGNATURE;
+
+ private final long LABEL_FLAGS = CElementLabels.DEFAULT_QUALIFIED | CElementLabels.ROOT_POST_QUALIFIED
+ | CElementLabels.APPEND_ROOT_PATH | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE
+ | CElementLabels.M_EXCEPTIONS | CElementLabels.F_APP_TYPE_SIGNATURE;
private IStatusLineManager fStatusLineManager;
-
+
public StatusBarUpdater(IStatusLineManager statusLineManager) {
- fStatusLineManager= statusLineManager;
+ fStatusLineManager = statusLineManager;
}
-
+
/*
* @see ISelectionChangedListener#selectionChanged
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
- String statusBarMessage= formatMessage(event.getSelection());
+ String statusBarMessage = formatMessage(event.getSelection());
fStatusLineManager.setMessage(statusBarMessage);
}
-
-
+
protected String formatMessage(ISelection sel) {
if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
- IStructuredSelection selection= (IStructuredSelection) sel;
-
- int nElements= selection.size();
+ IStructuredSelection selection = (IStructuredSelection) sel;
+
+ int nElements = selection.size();
if (nElements > 1) {
- return NLS.bind(CUIMessages.StatusBarUpdater_num_elements_selected, String.valueOf(nElements));
- }
- Object elem= selection.getFirstElement();
+ return NLS.bind(CUIMessages.StatusBarUpdater_num_elements_selected, String.valueOf(nElements));
+ }
+ Object elem = selection.getFirstElement();
if (elem instanceof ICElement) {
return formatCElementMessage((ICElement) elem);
} else if (elem instanceof IResource) {
return formatResourceMessage((IResource) elem);
}
}
- return ""; //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
}
-
+
private String formatCElementMessage(ICElement element) {
return CElementLabels.getElementLabel(element, LABEL_FLAGS);
}
-
+
private String formatResourceMessage(IResource element) {
- IContainer parent= element.getParent();
+ IContainer parent = element.getParent();
if (parent != null && parent.getType() != IResource.ROOT)
return element.getName() + CElementLabels.CONCAT_STRING + parent.getFullPath().makeRelative().toString();
return element.getName();
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.java
index 790a11fd5ab..a43d3f4930d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
-
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -35,9 +34,9 @@ import org.eclipse.ui.PlatformUI;
* Use this class when you want to present IStorage objects in a viewer.
*/
public class StorageLabelProvider extends LabelProvider {
-
- private IEditorRegistry fEditorRegistry= PlatformUI.getWorkbench().getEditorRegistry();
- private Map<String, Image> fJarImageMap= new HashMap<String, Image>(10);
+
+ private IEditorRegistry fEditorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
+ private Map<String, Image> fJarImageMap = new HashMap<String, Image>(10);
private Image fDefaultImage;
/* (non-Javadoc)
@@ -45,8 +44,8 @@ public class StorageLabelProvider extends LabelProvider {
*/
@Override
public Image getImage(Object element) {
- if (element instanceof IStorage)
- return getImageForJarEntry((IStorage)element);
+ if (element instanceof IStorage)
+ return getImageForJarEntry((IStorage) element);
return super.getImage(element);
}
@@ -57,34 +56,34 @@ public class StorageLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
if (element instanceof IStorage)
- return ((IStorage)element).getName();
+ return ((IStorage) element).getName();
return super.getText(element);
}
/* (non-Javadoc)
- *
+ *
* @see IBaseLabelProvider#dispose
*/
@Override
public void dispose() {
if (fJarImageMap != null) {
- Iterator<Image> each= fJarImageMap.values().iterator();
+ Iterator<Image> each = fJarImageMap.values().iterator();
while (each.hasNext()) {
- Image image= each.next();
+ Image image = each.next();
image.dispose();
}
- fJarImageMap= null;
+ fJarImageMap = null;
}
if (fDefaultImage != null)
fDefaultImage.dispose();
- fDefaultImage= null;
+ fDefaultImage = null;
}
-
+
/*
* Gets and caches an image for a JarEntryFile.
* The image for a JarEntryFile is retrieved from the EditorRegistry.
- */
+ */
private Image getImageForJarEntry(IStorage element) {
if (fJarImageMap == null)
return getDefaultImage();
@@ -93,43 +92,43 @@ public class StorageLabelProvider extends LabelProvider {
return getDefaultImage();
// Try to find icon for full name
- String name= element.getName();
- Image image= fJarImageMap.get(name);
- if (image != null)
+ String name = element.getName();
+ Image image = fJarImageMap.get(name);
+ if (image != null)
return image;
- IFileEditorMapping[] mappings= fEditorRegistry.getFileEditorMappings();
- int i= 0;
+ IFileEditorMapping[] mappings = fEditorRegistry.getFileEditorMappings();
+ int i = 0;
while (i < mappings.length) {
if (mappings[i].getLabel().equals(name))
break;
i++;
}
- String key= name;
+ String key = name;
if (i == mappings.length) {
// Try to find icon for extension
- IPath path= element.getFullPath();
+ IPath path = element.getFullPath();
if (path == null)
return getDefaultImage();
- key= path.getFileExtension();
+ key = path.getFileExtension();
if (key == null)
return getDefaultImage();
- image= fJarImageMap.get(key);
- if (image != null)
+ image = fJarImageMap.get(key);
+ if (image != null)
return image;
}
- // Get the image from the editor registry
- ImageDescriptor desc= fEditorRegistry.getImageDescriptor(name);
- image= desc.createImage();
+ // Get the image from the editor registry
+ ImageDescriptor desc = fEditorRegistry.getImageDescriptor(name);
+ image = desc.createImage();
fJarImageMap.put(key, image);
return image;
}
-
+
private Image getDefaultImage() {
if (fDefaultImage == null)
- fDefaultImage= fEditorRegistry.getImageDescriptor((String)null).createImage();
+ fDefaultImage = fEditorRegistry.getImageDescriptor((String) null).createImage();
return fDefaultImage;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.java
index d7b9dd3f05f..cc4e6ece2d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
@@ -32,30 +32,30 @@ public class TreeNavigator {
* @param dataClass the required class for the data of the tree nodes, or <code>null</code>.
*/
public TreeNavigator(Tree tree, Class<?> dataClass) {
- fTree= tree;
- fDataClass= dataClass;
+ fTree = tree;
+ fDataClass = dataClass;
}
/**
- * Find the first valid item of the selection.
+ * Find the first valid item of the selection.
* @return the first valid item in the selection or <code>null</code>
- */
+ */
public TreeItem getSelectedItem() {
- return getItemOfClass(fTree.getSelection(), true);
+ return getItemOfClass(fTree.getSelection(), true);
}
-
+
private TreeItem getItemOfClass(TreeItem[] items, boolean fwd) {
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[fwd ? i : items.length-1-i];
- if (fDataClass==null || fDataClass.isInstance(item.getData())) {
- return item;
- }
- }
- return null;
+ for (int i = 0; i < items.length; i++) {
+ TreeItem item = items[fwd ? i : items.length - 1 - i];
+ if (fDataClass == null || fDataClass.isInstance(item.getData())) {
+ return item;
+ }
+ }
+ return null;
}
/**
- * Find the first valid item on the given level. All parents have to be valid also.
+ * Find the first valid item on the given level. All parents have to be valid also.
* @param level the level to search, use <code>0</code> for the root nodes of the tree.
* @param fwd if set to false the tree is searched reverse from the buttom.
* @return the first item on the given level, or <code>null</code>
@@ -63,15 +63,16 @@ public class TreeNavigator {
public TreeItem getFirstItemOnLevel(int level, boolean fwd) {
return getFirstOnLevel(fTree.getItems(), level, fwd);
}
+
private TreeItem getFirstOnLevel(TreeItem[] items, int level, boolean fwd) {
- TreeItem item= getItemOfClass(items, fwd);
+ TreeItem item = getItemOfClass(items, fwd);
if (level <= 0 || item == null) {
return item;
}
- return getFirstOnLevel(item.getItems(), level-1, fwd);
+ return getFirstOnLevel(item.getItems(), level - 1, fwd);
}
- /**
+ /**
* Combines the methods {@link TreeNavigator#getSelectedItem()} and
* {@link TreeNavigator#getFirstItemOnLevel(int, boolean)}.
* @param level the level to search, use <code>0</code> for the root nodes of the tree.
@@ -79,13 +80,13 @@ public class TreeNavigator {
* @return the first valid item of the selection or the first item on the given level, or <code>null</code>
*/
public TreeItem getSelectedItemOrFirstOnLevel(int level, boolean fwd) {
- TreeItem result= getSelectedItem();
+ TreeItem result = getSelectedItem();
if (result == null) {
- result= getFirstItemOnLevel(level, fwd);
+ result = getFirstItemOnLevel(level, fwd);
}
return result;
}
-
+
/**
* Searches for the next valid sibbling of the given item.
* @param current a tree item to start the search
@@ -93,24 +94,23 @@ public class TreeNavigator {
* @return the next sibbling after the given one, or <code>null</code>
*/
public TreeItem getNextSibbling(TreeItem current, boolean forward) {
- TreeItem parentItem= current.getParentItem();
- if (parentItem == null) {
- Tree tree= current.getParent();
- int itemCount = tree.getItemCount();
- if (itemCount > 0) {
- int index= tree.indexOf(current);
- index = (index + (forward ? 1 : itemCount-1)) % itemCount;
- return tree.getItem(index);
- }
- }
- else {
- int itemCount = parentItem.getItemCount();
- if (itemCount > 0) {
- int index= parentItem.indexOf(current);
- index = (index + (forward ? 1 : itemCount-1)) % itemCount;
- return parentItem.getItem(index);
- }
- }
- return null;
- }
+ TreeItem parentItem = current.getParentItem();
+ if (parentItem == null) {
+ Tree tree = current.getParent();
+ int itemCount = tree.getItemCount();
+ if (itemCount > 0) {
+ int index = tree.indexOf(current);
+ index = (index + (forward ? 1 : itemCount - 1)) % itemCount;
+ return tree.getItem(index);
+ }
+ } else {
+ int itemCount = parentItem.getItemCount();
+ if (itemCount > 0) {
+ int index = parentItem.indexOf(current);
+ index = (index + (forward ? 1 : itemCount - 1)) % itemCount;
+ return parentItem.getItem(index);
+ }
+ }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.java
index fd2129b6a1b..9194937ba8e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
@@ -24,72 +24,71 @@ import org.eclipse.ui.IWorkingSet;
public class WorkingSetFilter {
- private static final Object ACCEPT = new Object();
- private static final Object REJECT = new Object();
+ private static final Object ACCEPT = new Object();
+ private static final Object REJECT = new Object();
- private HashMap<IPath, Object> fResourceFilter= null;
+ private HashMap<IPath, Object> fResourceFilter = null;
- public synchronized boolean isPartOfWorkingSet(ICElement elem) {
- if (fResourceFilter == null) {
- return true;
- }
- if (elem == null) {
- return false;
- }
- IPath path= elem.getPath();
- if (path == null) {
- return false;
- }
- Object check= fResourceFilter.get(path);
- if (check == null) {
- check= checkWorkingSet(path);
- fResourceFilter.put(path, check);
- }
- return check == ACCEPT;
- }
+ public synchronized boolean isPartOfWorkingSet(ICElement elem) {
+ if (fResourceFilter == null) {
+ return true;
+ }
+ if (elem == null) {
+ return false;
+ }
+ IPath path = elem.getPath();
+ if (path == null) {
+ return false;
+ }
+ Object check = fResourceFilter.get(path);
+ if (check == null) {
+ check = checkWorkingSet(path);
+ fResourceFilter.put(path, check);
+ }
+ return check == ACCEPT;
+ }
- public synchronized boolean isPartOfWorkingSet(IPath resourceOrExternalPath) {
- if (fResourceFilter == null) {
- return true;
- }
- if (resourceOrExternalPath == null) {
- return false;
- }
- Object check= fResourceFilter.get(resourceOrExternalPath);
- if (check == null) {
- check= checkWorkingSet(resourceOrExternalPath);
- fResourceFilter.put(resourceOrExternalPath, check);
- }
- return check == ACCEPT;
- }
+ public synchronized boolean isPartOfWorkingSet(IPath resourceOrExternalPath) {
+ if (fResourceFilter == null) {
+ return true;
+ }
+ if (resourceOrExternalPath == null) {
+ return false;
+ }
+ Object check = fResourceFilter.get(resourceOrExternalPath);
+ if (check == null) {
+ check = checkWorkingSet(resourceOrExternalPath);
+ fResourceFilter.put(resourceOrExternalPath, check);
+ }
+ return check == ACCEPT;
+ }
- private synchronized Object checkWorkingSet(IPath path) {
- if (path.segmentCount() == 0) {
- return REJECT;
- }
+ private synchronized Object checkWorkingSet(IPath path) {
+ if (path.segmentCount() == 0) {
+ return REJECT;
+ }
- Object result= fResourceFilter.get(path);
- if (result == null) {
- result= checkWorkingSet(path.removeLastSegments(1));
- fResourceFilter.put(path, result);
- }
- return result;
- }
+ Object result = fResourceFilter.get(path);
+ if (result == null) {
+ result = checkWorkingSet(path.removeLastSegments(1));
+ fResourceFilter.put(path, result);
+ }
+ return result;
+ }
- public synchronized void setWorkingSet(IWorkingSet workingSetFilter) {
- if (workingSetFilter == null) {
- fResourceFilter= null;
- }
- else {
- IAdaptable[] input = workingSetFilter.getElements();
- fResourceFilter = new HashMap<IPath, Object>();
- for (int i = 0; i < input.length; i++) {
- IAdaptable adaptable = input[i];
- IResource res = adaptable.getAdapter(IResource.class);
- if (res != null) {
- fResourceFilter.put(res.getFullPath(), ACCEPT);
- }
- }
- }
- }
+ public synchronized void setWorkingSet(IWorkingSet workingSetFilter) {
+ if (workingSetFilter == null) {
+ fResourceFilter = null;
+ } else {
+ IAdaptable[] input = workingSetFilter.getElements();
+ fResourceFilter = new HashMap<IPath, Object>();
+ for (int i = 0; i < input.length; i++) {
+ IAdaptable adaptable = input[i];
+ IResource res = adaptable.getAdapter(IResource.class);
+ if (res != null) {
+ fResourceFilter.put(res.getFullPath(), ACCEPT);
+ }
+ }
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.java
index 77d8d6eb67f..a3415fe12ee 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
@@ -32,158 +32,154 @@ import org.eclipse.cdt.core.model.ICElement;
/**
* Wraps {@link WorkingSetFilterActionGroup} and handles the property changed
- * events
+ * events
*/
public abstract class WorkingSetFilterUI {
- private IPropertyChangeListener fWorkingSetListener;
- private IWorkingSet fWorkingSet;
- WorkingSetFilterActionGroup fWorkingSetFilterGroup;
- private IViewPart fViewPart;
- private WorkingSetFilter fWorkingSetFilter= null;
- private IWorkingSetManager fWSManager;
-
- public WorkingSetFilterUI(IViewPart viewPart, IMemento memento, String key) {
- fWSManager= PlatformUI.getWorkbench().getWorkingSetManager();
- fViewPart= viewPart;
-
- if (memento != null) {
- memento= memento.getChild(key);
- if (memento != null) {
- IWorkingSet ws= fWSManager.createWorkingSet(memento);
- if (ws != null) {
- fWorkingSet= fWSManager.getWorkingSet(ws.getName());
- if (fWorkingSet == null) {
- fWorkingSet= ws;
- fWSManager.addWorkingSet(ws);
- }
- }
- }
- }
- fWorkingSetListener = new IPropertyChangeListener() {
- @Override
+ private IPropertyChangeListener fWorkingSetListener;
+ private IWorkingSet fWorkingSet;
+ WorkingSetFilterActionGroup fWorkingSetFilterGroup;
+ private IViewPart fViewPart;
+ private WorkingSetFilter fWorkingSetFilter = null;
+ private IWorkingSetManager fWSManager;
+
+ public WorkingSetFilterUI(IViewPart viewPart, IMemento memento, String key) {
+ fWSManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ fViewPart = viewPart;
+
+ if (memento != null) {
+ memento = memento.getChild(key);
+ if (memento != null) {
+ IWorkingSet ws = fWSManager.createWorkingSet(memento);
+ if (ws != null) {
+ fWorkingSet = fWSManager.getWorkingSet(ws.getName());
+ if (fWorkingSet == null) {
+ fWorkingSet = ws;
+ fWSManager.addWorkingSet(ws);
+ }
+ }
+ }
+ }
+ fWorkingSetListener = new IPropertyChangeListener() {
+ @Override
public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
- onWorkingSetPropertyChange(event);
- }
- };
- fWSManager.addPropertyChangeListener(fWorkingSetListener);
- IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
- @Override
+ onWorkingSetPropertyChange(event);
+ }
+ };
+ fWSManager.addPropertyChangeListener(fWorkingSetListener);
+ IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
+ @Override
public void propertyChange(PropertyChangeEvent event) {
- onWorkingSetFilterUpdate(event);
- }
- };
-
- fWorkingSetFilterGroup= new WorkingSetFilterActionGroup(fViewPart.getSite().getShell(), workingSetUpdater);
- fWorkingSetFilterGroup.setWorkingSet(fWorkingSet);
- }
-
- public void dispose() {
- fWSManager.removePropertyChangeListener(fWorkingSetListener);
- fWorkingSetFilterGroup.dispose();
- }
-
- private void applyWorkingSetFilter() {
- if (fWorkingSet == null) {
- fWorkingSetFilter = null;
- }
- else {
- fWorkingSetFilter = new WorkingSetFilter();
- fWorkingSetFilter.setWorkingSet(fWorkingSet);
- }
- }
-
- protected void onWorkingSetPropertyChange(PropertyChangeEvent evt) {
- if (fWorkingSet == null) {
- return;
- }
- boolean doRefresh = false;
- String propertyName = evt.getProperty();
- Object newValue = evt.getNewValue();
- Object oldValue = evt.getOldValue();
-
- if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE)) {
- if (fWorkingSet == newValue) { // weired, but this is how it works
- doRefresh = true;
- }
- }
- else if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE)) {
- if (fWorkingSet == newValue) {
- onWorkingSetNameChange();
- }
- }
- else if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_REMOVE)) {
- if (fWorkingSet == oldValue) {
- fWorkingSet = null;
- doRefresh = true;
- }
- }
- if (doRefresh) {
- applyWorkingSetFilter();
- onWorkingSetChange();
- }
- }
-
- protected void onWorkingSetFilterUpdate(PropertyChangeEvent event) {
- String property = event.getProperty();
- if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {
- Object newValue = event.getNewValue();
-
- if (newValue instanceof IWorkingSet) {
- fWorkingSet = (IWorkingSet) newValue;
- fWSManager.addRecentWorkingSet(fWorkingSet);
- }
- else {
- fWorkingSet = null;
- }
- applyWorkingSetFilter();
- onWorkingSetChange();
- onWorkingSetNameChange();
- }
- }
-
- protected abstract void onWorkingSetChange();
- protected abstract void onWorkingSetNameChange();
-
- public void fillActionBars(IActionBars actionBars) {
- fWorkingSetFilterGroup.fillActionBars(actionBars);
- }
-
- public boolean isPartOfWorkingSet(ICElement element) {
- if (fWorkingSetFilter == null) {
- return true;
- }
- return fWorkingSetFilter.isPartOfWorkingSet(element);
- }
-
- public boolean isPartOfWorkingSet(IPath resourceOrExternalPath) {
- if (fWorkingSetFilter == null) {
- return true;
- }
- return fWorkingSetFilter.isPartOfWorkingSet(resourceOrExternalPath);
- }
-
- public IWorkingSet getWorkingSet() {
- return fWorkingSet;
- }
-
- public void setWorkingSet(IWorkingSet workingSet) {
- fWorkingSet= workingSet;
- fWorkingSetFilterGroup.setWorkingSet(fWorkingSet);
- }
-
- public List<String> getRecent() {
- IWorkingSet[] workingSets= fWSManager.getRecentWorkingSets();
- ArrayList<String> result= new ArrayList<String>(workingSets.length);
- for (int i = 0; i < workingSets.length; i++) {
- result.add(workingSets[i].getName());
- }
- return result;
- }
-
- public void saveState(IMemento memento, String key) {
- if (fWorkingSet != null) {
- fWorkingSet.saveState(memento.createChild(key));
- }
- }
-}
+ onWorkingSetFilterUpdate(event);
+ }
+ };
+
+ fWorkingSetFilterGroup = new WorkingSetFilterActionGroup(fViewPart.getSite().getShell(), workingSetUpdater);
+ fWorkingSetFilterGroup.setWorkingSet(fWorkingSet);
+ }
+
+ public void dispose() {
+ fWSManager.removePropertyChangeListener(fWorkingSetListener);
+ fWorkingSetFilterGroup.dispose();
+ }
+
+ private void applyWorkingSetFilter() {
+ if (fWorkingSet == null) {
+ fWorkingSetFilter = null;
+ } else {
+ fWorkingSetFilter = new WorkingSetFilter();
+ fWorkingSetFilter.setWorkingSet(fWorkingSet);
+ }
+ }
+
+ protected void onWorkingSetPropertyChange(PropertyChangeEvent evt) {
+ if (fWorkingSet == null) {
+ return;
+ }
+ boolean doRefresh = false;
+ String propertyName = evt.getProperty();
+ Object newValue = evt.getNewValue();
+ Object oldValue = evt.getOldValue();
+
+ if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE)) {
+ if (fWorkingSet == newValue) { // weired, but this is how it works
+ doRefresh = true;
+ }
+ } else if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE)) {
+ if (fWorkingSet == newValue) {
+ onWorkingSetNameChange();
+ }
+ } else if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_REMOVE)) {
+ if (fWorkingSet == oldValue) {
+ fWorkingSet = null;
+ doRefresh = true;
+ }
+ }
+ if (doRefresh) {
+ applyWorkingSetFilter();
+ onWorkingSetChange();
+ }
+ }
+
+ protected void onWorkingSetFilterUpdate(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {
+ Object newValue = event.getNewValue();
+
+ if (newValue instanceof IWorkingSet) {
+ fWorkingSet = (IWorkingSet) newValue;
+ fWSManager.addRecentWorkingSet(fWorkingSet);
+ } else {
+ fWorkingSet = null;
+ }
+ applyWorkingSetFilter();
+ onWorkingSetChange();
+ onWorkingSetNameChange();
+ }
+ }
+ protected abstract void onWorkingSetChange();
+
+ protected abstract void onWorkingSetNameChange();
+
+ public void fillActionBars(IActionBars actionBars) {
+ fWorkingSetFilterGroup.fillActionBars(actionBars);
+ }
+
+ public boolean isPartOfWorkingSet(ICElement element) {
+ if (fWorkingSetFilter == null) {
+ return true;
+ }
+ return fWorkingSetFilter.isPartOfWorkingSet(element);
+ }
+
+ public boolean isPartOfWorkingSet(IPath resourceOrExternalPath) {
+ if (fWorkingSetFilter == null) {
+ return true;
+ }
+ return fWorkingSetFilter.isPartOfWorkingSet(resourceOrExternalPath);
+ }
+
+ public IWorkingSet getWorkingSet() {
+ return fWorkingSet;
+ }
+
+ public void setWorkingSet(IWorkingSet workingSet) {
+ fWorkingSet = workingSet;
+ fWorkingSetFilterGroup.setWorkingSet(fWorkingSet);
+ }
+
+ public List<String> getRecent() {
+ IWorkingSet[] workingSets = fWSManager.getRecentWorkingSets();
+ ArrayList<String> result = new ArrayList<String>(workingSets.length);
+ for (int i = 0; i < workingSets.length; i++) {
+ result.add(workingSets[i].getName());
+ }
+ return result;
+ }
+
+ public void saveState(IMemento memento, String key) {
+ if (fWorkingSet != null) {
+ fWorkingSet.saveState(memento.createChild(key));
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java
index 634ad216d46..631b674d154 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java
@@ -47,7 +47,7 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
private Class<?>[] fActivatedOnTypes;
private boolean fAcceptEmptySelection;
-
+
/**
* Creates a AbstractOpenWizardAction.
* @param label The label of the action
@@ -63,11 +63,11 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
* @param activatedOnTypes The action is only enabled when all objects in the selection
* are of the given types. <code>null</code> will allow all types.
* @param acceptEmptySelection Specifies if the action allows an empty selection
- */
+ */
public AbstractOpenWizardAction(String label, Class<?>[] activatedOnTypes, boolean acceptEmptySelection) {
super(label);
- fActivatedOnTypes= activatedOnTypes;
- fAcceptEmptySelection= acceptEmptySelection;
+ fActivatedOnTypes = activatedOnTypes;
+ fAcceptEmptySelection = acceptEmptySelection;
}
/**
@@ -75,14 +75,14 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
* an empty selection.
*/
protected AbstractOpenWizardAction() {
- fActivatedOnTypes= null;
- fAcceptEmptySelection= true;
+ fActivatedOnTypes = null;
+ fAcceptEmptySelection = true;
}
-
+
protected IWorkbench getWorkbench() {
return CUIPlugin.getDefault().getWorkbench();
}
-
+
private boolean isOfAcceptedType(Object obj) {
if (fActivatedOnTypes != null) {
for (Class<?> activatedOnType : fActivatedOnTypes) {
@@ -94,38 +94,36 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
}
return true;
}
-
-
+
private boolean isEnabled(IStructuredSelection selection) {
- Iterator<?> iter= selection.iterator();
+ Iterator<?> iter = selection.iterator();
while (iter.hasNext()) {
- Object obj= iter.next();
+ Object obj = iter.next();
if (!isOfAcceptedType(obj) || !shouldAcceptElement(obj)) {
return false;
}
}
return true;
}
-
+
/**
* Can be overridden to add more checks.
* obj is guaranteed to be instance of one of the accepted types
*/
protected boolean shouldAcceptElement(Object obj) {
return true;
- }
-
+ }
+
/**
* Creates the specific wizard.
* (to be implemented by a subclass)
*/
abstract protected Wizard createWizard() throws CoreException;
-
protected IStructuredSelection getCurrentSelection() {
- IWorkbenchWindow window= CUIPlugin.getActiveWorkbenchWindow();
+ IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
if (window != null) {
- ISelection selection= window.getSelectionService().getSelection();
+ ISelection selection = window.getSelectionService().getSelection();
if (selection instanceof IStructuredSelection) {
return (IStructuredSelection) selection;
}
@@ -148,37 +146,38 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
*/
@Override
public void run() {
-/* if (!fNoChecking && !canActionBeAdded()) {
- return;
- }
- if (!checkWorkspaceNotEmpty()) {
- return;
- }
-*/ Shell shell= CUIPlugin.getActiveWorkbenchShell();
+ /* if (!fNoChecking && !canActionBeAdded()) {
+ return;
+ }
+ if (!checkWorkspaceNotEmpty()) {
+ return;
+ }
+ */ Shell shell = CUIPlugin.getActiveWorkbenchShell();
try {
- Wizard wizard= createWizard();
+ Wizard wizard = createWizard();
if (wizard instanceof IWorkbenchWizard) {
- ((IWorkbenchWizard)wizard).init(getWorkbench(), getCurrentSelection());
+ ((IWorkbenchWizard) wizard).init(getWorkbench(), getCurrentSelection());
}
-
- WizardDialog dialog= new WizardDialog(shell, wizard);
- PixelConverter converter= new PixelConverter(CUIPlugin.getActiveWorkbenchShell());
-
- dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
+
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ PixelConverter converter = new PixelConverter(CUIPlugin.getActiveWorkbenchShell());
+
+ dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70),
+ converter.convertHeightInCharsToPixels(20));
dialog.create();
dialog.open();
} catch (CoreException e) {
- String title= NewWizardMessages.AbstractOpenWizardAction_createerror_title;
- String message= NewWizardMessages.AbstractOpenWizardAction_createerror_message;
+ String title = NewWizardMessages.AbstractOpenWizardAction_createerror_title;
+ String message = NewWizardMessages.AbstractOpenWizardAction_createerror_message;
ExceptionHandler.handle(e, shell, title, message);
}
}
-
+
/**
* Tests if the action can be run on the current selection.
*/
public boolean canActionBeAdded() {
- IStructuredSelection selection= getCurrentSelection();
+ IStructuredSelection selection = getCurrentSelection();
if (selection == null || selection.isEmpty()) {
return fAcceptEmptySelection;
}
@@ -214,15 +213,15 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
public void selectionChanged(IAction action, ISelection selection) {
// selection taken from selectionprovider
}
-
+
protected boolean checkWorkspaceNotEmpty() {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace.getRoot().getProjects().length == 0) {
- Shell shell= CUIPlugin.getActiveWorkbenchShell();
- String title= NewWizardMessages.AbstractOpenWizardAction_noproject_title;
- String message= NewWizardMessages.AbstractOpenWizardAction_noproject_message;
+ Shell shell = CUIPlugin.getActiveWorkbenchShell();
+ String title = NewWizardMessages.AbstractOpenWizardAction_noproject_title;
+ String message = NewWizardMessages.AbstractOpenWizardAction_noproject_message;
if (MessageDialog.openQuestion(shell, title, message)) {
- IWorkbenchWindow window= CUIPlugin.getActiveWorkbenchWindow();
+ IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
(new NewProjectAction(window)).run();
return workspace.getRoot().getProjects().length != 0;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java
index e94d671323f..fc463959356 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java
@@ -26,36 +26,37 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
-public abstract class AbstractWizardDropDownAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 {
+public abstract class AbstractWizardDropDownAction extends Action
+ implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 {
protected final static IAction[] NO_ACTIONS = new IAction[0];
private Menu fMenu;
private IAction[] fActions;
private IRegistryChangeListener fListener;
private Object fLock = new Object();
-
+
public AbstractWizardDropDownAction() {
- fMenu= null;
- fActions= null;
+ fMenu = null;
+ fActions = null;
setMenuCreator(this);
-
+
// listen for changes to wizard extensions
fListener = new IRegistryChangeListener() {
- @Override
+ @Override
public void registryChanged(IRegistryChangeEvent event) {
- refreshActions();
- }
+ refreshActions();
+ }
};
Platform.getExtensionRegistry().addRegistryChangeListener(fListener);
}
-
+
public void refreshActions() {
- // force menu and actions to be created again
+ // force menu and actions to be created again
Menu oldMenu = null;
- synchronized(fLock) {
+ synchronized (fLock) {
oldMenu = fMenu;
- fActions = null;
- fMenu = null;
+ fActions = null;
+ fMenu = null;
}
if (oldMenu != null)
oldMenu.dispose();
@@ -65,7 +66,7 @@ public abstract class AbstractWizardDropDownAction extends Action implements IMe
public void dispose() {
if (fListener != null) {
Platform.getExtensionRegistry().removeRegistryChangeListener(fListener);
- fListener= null;
+ fListener = null;
}
refreshActions();
}
@@ -77,63 +78,63 @@ public abstract class AbstractWizardDropDownAction extends Action implements IMe
@Override
public Menu getMenu(Control parent) {
- synchronized(fLock) {
- fMenu= new Menu(parent);
- IAction[] actions= getActions();
- for (int i= 0; i < actions.length; i++) {
- ActionContributionItem item= new ActionContributionItem(actions[i]);
+ synchronized (fLock) {
+ fMenu = new Menu(parent);
+ IAction[] actions = getActions();
+ for (int i = 0; i < actions.length; i++) {
+ ActionContributionItem item = new ActionContributionItem(actions[i]);
item.fill(fMenu, -1);
}
return fMenu;
}
}
-
+
@Override
public void run() {
- // for now, run the default action
- // we might want the last run action at some point
- IAction action = getDefaultAction();
- if (action != null) {
- action.run();
- }
+ // for now, run the default action
+ // we might want the last run action at some point
+ IAction action = getDefaultAction();
+ if (action != null) {
+ action.run();
+ }
}
-
+
public IAction getDefaultAction() {
- IAction[] actions = getActions();
+ IAction[] actions = getActions();
if (actions.length > 0) {
- actions[0].getId();
- return actions[0];
-// for (int i = 0; i < actions.length; ++i) {
-// IAction action = actions[i];
-// if (action.isEnabled()) {
-// return action;
-// }
-// }
+ actions[0].getId();
+ return actions[0];
+ // for (int i = 0; i < actions.length; ++i) {
+ // IAction action = actions[i];
+ // if (action.isEnabled()) {
+ // return action;
+ // }
+ // }
}
return null;
}
-
+
private IAction[] getActions() {
- synchronized(fLock) {
- fActions = getWizardActions();
- if (fActions == null)
- fActions = NO_ACTIONS;
+ synchronized (fLock) {
+ fActions = getWizardActions();
+ if (fActions == null)
+ fActions = NO_ACTIONS;
- //TODO provide a way to sort the actions
+ //TODO provide a way to sort the actions
- return fActions;
+ return fActions;
}
}
-
+
protected abstract IAction[] getWizardActions();
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
@Override
public void init(IWorkbenchWindow window) {
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@@ -141,7 +142,7 @@ public abstract class AbstractWizardDropDownAction extends Action implements IMe
public void run(IAction action) {
run();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java
index c6722686d59..0d6e02185ee 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java
@@ -43,40 +43,37 @@ public class CWizardRegistry {
private final static String ATT_CFOLDER = "cfolder";//$NON-NLS-1$
private final static String ATT_CPROJECT = "cproject";//$NON-NLS-1$
private final static String ATT_CCPROJECT = "ccproject";//$NON-NLS-1$
- private final static String TAG_CLASS = "class"; //$NON-NLS-1$
- private final static String TAG_ID = "id"; //$NON-NLS-1$
- private final static String PL_NEW = "newWizards"; //$NON-NLS-1$
+ private final static String TAG_CLASS = "class"; //$NON-NLS-1$
+ private final static String TAG_ID = "id"; //$NON-NLS-1$
+ private final static String PL_NEW = "newWizards"; //$NON-NLS-1$
-
-
-
/**
* Checks if wizard supports C projects.
- *
+ *
* @param element the wizard element
- *
+ *
* @return <code>true</code> if the given wizard element applies to a C Project
*/
public static boolean isCProjectWizard(IConfigurationElement element) {
- String category = element.getAttribute(ATT_CATEGORY);
- return (category != null && category.equals(CUIPlugin.CWIZARD_CATEGORY_ID));
+ String category = element.getAttribute(ATT_CATEGORY);
+ return (category != null && category.equals(CUIPlugin.CWIZARD_CATEGORY_ID));
}
-
+
/**
* Checks if wizard supports C++ project.
- *
+ *
* @param element the wizard element
- *
+ *
* @return <code>true</code> if the given wizard element applies to a C++ Project
*/
public static boolean isCCProjectWizard(IConfigurationElement element) {
- String category = element.getAttribute(ATT_CATEGORY);
- return (category != null && category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID));
+ String category = element.getAttribute(ATT_CATEGORY);
+ return (category != null && category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID));
}
/**
* Returns IDs of all C/C++ project wizards contributed to the workbench.
- *
+ *
* @return an array of wizard ids
*/
public static String[] getProjectWizardIDs() {
@@ -97,37 +94,37 @@ public class CWizardRegistry {
* </description>
* </wizard>
*
- *
+ *
* @return an array of IConfigurationElement
*/
public static IConfigurationElement[] getProjectWizardElements() {
List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
- IConfigurationElement[] elements = getAllWizardElements();
- for (int i = 0; i < elements.length; ++i) {
+ IConfigurationElement[] elements = getAllWizardElements();
+ for (int i = 0; i < elements.length; ++i) {
IConfigurationElement element = elements[i];
if (isProjectWizard(element)) {
- elemList.add(element);
- }
- }
+ elemList.add(element);
+ }
+ }
return elemList.toArray(new IConfigurationElement[elemList.size()]);
}
-
- private static boolean isProjectWizard(IConfigurationElement element) {
- String project = element.getAttribute(ATT_PROJECT);
- if (project != null) {
- return Boolean.valueOf(project).booleanValue();
- }
-
- IConfigurationElement[] classElements = element.getChildren(TAG_CLASS);
+
+ private static boolean isProjectWizard(IConfigurationElement element) {
+ String project = element.getAttribute(ATT_PROJECT);
+ if (project != null) {
+ return Boolean.valueOf(project).booleanValue();
+ }
+
+ IConfigurationElement[] classElements = element.getChildren(TAG_CLASS);
if (classElements.length > 0) {
for (IConfigurationElement classElement : classElements) {
IConfigurationElement[] paramElements = classElement.getChildren(TAG_PARAMETER);
for (IConfigurationElement curr : paramElements) {
String name = curr.getAttribute(TAG_NAME);
if (name != null && (name.equals(ATT_CPROJECT) || name.equals(ATT_CCPROJECT))) {
- String value = curr.getAttribute(TAG_VALUE);
- if (value != null)
- return Boolean.valueOf(value).booleanValue();
+ String value = curr.getAttribute(TAG_VALUE);
+ if (value != null)
+ return Boolean.valueOf(value).booleanValue();
}
}
}
@@ -135,21 +132,21 @@ public class CWizardRegistry {
}
// fall back, if no <class> element found then assume it's a project wizard
return true;
- }
-
- public static IAction[] getProjectWizardActions() {
- return createActions(getProjectWizardElements());
- }
-
+ }
+
+ public static IAction[] getProjectWizardActions() {
+ return createActions(getProjectWizardElements());
+ }
+
/**
* Returns IDs of all C/C++ type wizards contributed to the workbench.
- *
+ *
* @return an array of wizard ids
*/
public static String[] getTypeWizardIDs() {
return getWizardIDs(getTypeWizardElements());
}
-
+
/**
* Returns extension data for all the C/C++ type wizards contributed to the workbench.
* <wizard
@@ -159,27 +156,27 @@ public class CWizardRegistry {
* id="xx.MyCWizard">
* <class class="org.xx.MyCWizard">
* <parameter name="ctype" value="true" />
- * </class>
+ * </class>
* <description>
* My C Wizard
* </description>
* </wizard>
- *
+ *
* @return an array of IConfigurationElement
*/
public static IConfigurationElement[] getTypeWizardElements() {
List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
- IConfigurationElement[] elements = getAllWizardElements();
- for (int i = 0; i < elements.length; ++i) {
+ IConfigurationElement[] elements = getAllWizardElements();
+ for (int i = 0; i < elements.length; ++i) {
IConfigurationElement element = elements[i];
if (isTypeWizard(element)) {
- elemList.add(element);
- }
- }
+ elemList.add(element);
+ }
+ }
return elemList.toArray(new IConfigurationElement[elemList.size()]);
}
-
- private static boolean isTypeWizard(IConfigurationElement element) {
+
+ private static boolean isTypeWizard(IConfigurationElement element) {
IConfigurationElement[] classElements = element.getChildren(TAG_CLASS);
if (classElements.length > 0) {
for (IConfigurationElement classElement : classElements) {
@@ -187,23 +184,23 @@ public class CWizardRegistry {
for (IConfigurationElement curr : paramElements) {
String name = curr.getAttribute(TAG_NAME);
if (name != null && name.equals(ATT_CTYPE)) {
- String value = curr.getAttribute(TAG_VALUE);
- if (value != null)
- return Boolean.valueOf(value).booleanValue();
+ String value = curr.getAttribute(TAG_VALUE);
+ if (value != null)
+ return Boolean.valueOf(value).booleanValue();
}
}
}
}
return false;
- }
-
- public static IAction[] getTypeWizardActions() {
- return createActions(getTypeWizardElements());
- }
-
+ }
+
+ public static IAction[] getTypeWizardActions() {
+ return createActions(getTypeWizardElements());
+ }
+
/**
* Returns IDs of all C/C++ file wizards contributed to the workbench.
- *
+ *
* @return an array of wizard ids
*/
public static String[] getFileWizardIDs() {
@@ -219,27 +216,27 @@ public class CWizardRegistry {
* id="xx.MyCWizard">
* <class class="org.xx.MyCFileWizard">
* <parameter name="cfile" value="true" />
- * </class>
+ * </class>
* <description>
* My C File Wizard
* </description>
* </wizard>
- *
+ *
* @return an array of IConfigurationElement
*/
public static IConfigurationElement[] getFileWizardElements() {
List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
- IConfigurationElement[] elements = getAllWizardElements();
- for (int i = 0; i < elements.length; ++i) {
+ IConfigurationElement[] elements = getAllWizardElements();
+ for (int i = 0; i < elements.length; ++i) {
IConfigurationElement element = elements[i];
if (isFileWizard(element)) {
- elemList.add(element);
- }
- }
+ elemList.add(element);
+ }
+ }
return elemList.toArray(new IConfigurationElement[elemList.size()]);
}
-
- private static boolean isFileWizard(IConfigurationElement element) {
+
+ private static boolean isFileWizard(IConfigurationElement element) {
IConfigurationElement[] classElements = element.getChildren(TAG_CLASS);
if (classElements.length > 0) {
for (IConfigurationElement classElement : classElements) {
@@ -247,23 +244,23 @@ public class CWizardRegistry {
for (IConfigurationElement curr : paramElements) {
String name = curr.getAttribute(TAG_NAME);
if (name != null && name.equals(ATT_CFILE)) {
- String value = curr.getAttribute(TAG_VALUE);
- if (value != null)
- return Boolean.valueOf(value).booleanValue();
+ String value = curr.getAttribute(TAG_VALUE);
+ if (value != null)
+ return Boolean.valueOf(value).booleanValue();
}
}
}
}
return false;
- }
-
- public static IAction[] getFolderWizardActions() {
- return createActions(getFolderWizardElements());
- }
+ }
+
+ public static IAction[] getFolderWizardActions() {
+ return createActions(getFolderWizardElements());
+ }
/**
* Returns IDs of all C/C++ folder wizards contributed to the workbench.
- *
+ *
* @return an array of wizard ids
*/
public static String[] getFolderWizardIDs() {
@@ -279,27 +276,27 @@ public class CWizardRegistry {
* id="xx.MyCWizard">
* <class class="org.xx.MyCFolderWizard">
* <parameter name="cfolder" value="true" />
- * </class>
+ * </class>
* <description>
* My C Folder Wizard
* </description>
* </wizard>
- *
+ *
* @return an array of IConfigurationElement
*/
public static IConfigurationElement[] getFolderWizardElements() {
List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
- IConfigurationElement[] elements = getAllWizardElements();
- for (int i = 0; i < elements.length; ++i) {
+ IConfigurationElement[] elements = getAllWizardElements();
+ for (int i = 0; i < elements.length; ++i) {
IConfigurationElement element = elements[i];
if (isFolderWizard(element)) {
- elemList.add(element);
- }
- }
+ elemList.add(element);
+ }
+ }
return elemList.toArray(new IConfigurationElement[elemList.size()]);
}
-
- private static boolean isFolderWizard(IConfigurationElement element) {
+
+ private static boolean isFolderWizard(IConfigurationElement element) {
IConfigurationElement[] classElements = element.getChildren(TAG_CLASS);
if (classElements.length > 0) {
for (IConfigurationElement classElement : classElements) {
@@ -307,87 +304,87 @@ public class CWizardRegistry {
for (IConfigurationElement curr : paramElements) {
String name = curr.getAttribute(TAG_NAME);
if (name != null && name.equals(ATT_CFOLDER)) {
- String value = curr.getAttribute(TAG_VALUE);
- if (value != null)
- return Boolean.valueOf(value).booleanValue();
+ String value = curr.getAttribute(TAG_VALUE);
+ if (value != null)
+ return Boolean.valueOf(value).booleanValue();
}
}
}
}
return false;
- }
-
- public static IAction[] getFileWizardActions() {
- return createActions(getFileWizardElements());
- }
-
+ }
+
+ public static IAction[] getFileWizardActions() {
+ return createActions(getFileWizardElements());
+ }
+
private static String[] getWizardIDs(IConfigurationElement[] elements) {
- List<String> idList = new ArrayList<String>();
+ List<String> idList = new ArrayList<String>();
- // add C wizards first
- for (int i = 0; i < elements.length; ++i) {
- IConfigurationElement element= elements[i];
+ // add C wizards first
+ for (int i = 0; i < elements.length; ++i) {
+ IConfigurationElement element = elements[i];
if (isCProjectWizard(element)) {
- String id = element.getAttribute(TAG_ID);
- if (id != null && !idList.contains(id)) {
- idList.add(id);
- }
+ String id = element.getAttribute(TAG_ID);
+ if (id != null && !idList.contains(id)) {
+ idList.add(id);
+ }
}
- }
- // now add C++ wizards
- for (int i = 0; i < elements.length; ++i) {
- IConfigurationElement element= elements[i];
+ }
+ // now add C++ wizards
+ for (int i = 0; i < elements.length; ++i) {
+ IConfigurationElement element = elements[i];
if (isCCProjectWizard(element)) {
- String id = element.getAttribute(TAG_ID);
- if (id != null && !idList.contains(id)) {
- idList.add(id);
- }
+ String id = element.getAttribute(TAG_ID);
+ if (id != null && !idList.contains(id)) {
+ idList.add(id);
+ }
}
- }
-
+ }
+
return idList.toArray(new String[idList.size()]);
}
-
- private static IAction[] createActions(IConfigurationElement[] elements) {
- List<String> idList = new ArrayList<String>();
- List<IAction> actionList = new ArrayList<IAction>();
- // add C wizards first
- for (int i = 0; i < elements.length; ++i) {
+ private static IAction[] createActions(IConfigurationElement[] elements) {
+ List<String> idList = new ArrayList<String>();
+ List<IAction> actionList = new ArrayList<IAction>();
+
+ // add C wizards first
+ for (int i = 0; i < elements.length; ++i) {
IConfigurationElement element = elements[i];
if (isCProjectWizard(element)) {
- String id = element.getAttribute(TAG_ID);
- if (id != null && !idList.contains(id)) {
- idList.add(id);
- IAction action = new OpenNewWizardAction(element);
- actionList.add(action);
- }
+ String id = element.getAttribute(TAG_ID);
+ if (id != null && !idList.contains(id)) {
+ idList.add(id);
+ IAction action = new OpenNewWizardAction(element);
+ actionList.add(action);
+ }
}
- }
- // now add C++ wizards
- for (int i = 0; i < elements.length; ++i) {
+ }
+ // now add C++ wizards
+ for (int i = 0; i < elements.length; ++i) {
IConfigurationElement element = elements[i];
if (isCCProjectWizard(element)) {
- String id = element.getAttribute(TAG_ID);
- if (id != null && !idList.contains(id)) {
- idList.add(id);
- IAction action = new OpenNewWizardAction(element);
- actionList.add(action);
- }
+ String id = element.getAttribute(TAG_ID);
+ if (id != null && !idList.contains(id)) {
+ idList.add(id);
+ IAction action = new OpenNewWizardAction(element);
+ actionList.add(action);
+ }
}
- }
-
+ }
+
return actionList.toArray(new IAction[actionList.size()]);
- }
-
- private static class WizardConfig implements IPluginContribution {
-
+ }
+
+ private static class WizardConfig implements IPluginContribution {
+
private IConfigurationElement fElement;
-
- public WizardConfig(IConfigurationElement element) {
+
+ public WizardConfig(IConfigurationElement element) {
fElement = element;
}
-
+
@Override
public String getLocalId() {
return fElement.getAttribute("id"); //$NON-NLS-1$
@@ -397,11 +394,10 @@ public class CWizardRegistry {
public String getPluginId() {
return fElement.getContributor().getName();
}
-
- }
-
- /**
+ }
+
+ /**
* Returns extension data for all the C/C++ wizards contributed to the workbench.
* <wizard
* name="My C Wizard"
@@ -412,28 +408,28 @@ public class CWizardRegistry {
* My C Wizard
* </description>
* </wizard>
- *
+ *
* @return an array of IConfigurationElement
*/
public static IConfigurationElement[] getAllWizardElements() {
List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, PL_NEW);
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID,
+ PL_NEW);
if (extensionPoint != null) {
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (IConfigurationElement element : elements) {
- if (element.getName().equals(TAG_WIZARD)) {
- if (!WorkbenchActivityHelper.filterItem(new WizardConfig(element))) {
- String category = element.getAttribute(ATT_CATEGORY);
- if (category != null &&
- (category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID)
- || category.equals(CUIPlugin.CWIZARD_CATEGORY_ID))) {
- elemList.add(element);
- }
+ if (element.getName().equals(TAG_WIZARD)) {
+ if (!WorkbenchActivityHelper.filterItem(new WizardConfig(element))) {
+ String category = element.getAttribute(ATT_CATEGORY);
+ if (category != null && (category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID)
+ || category.equals(CUIPlugin.CWIZARD_CATEGORY_ID))) {
+ elemList.add(element);
+ }
}
}
}
}
return elemList.toArray(new IConfigurationElement[elemList.size()]);
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.java
index 968e4412fa2..8bf2d0274cc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards;
-
import java.net.URI;
import org.eclipse.core.resources.IProject;
@@ -25,9 +24,9 @@ import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
*/
public interface ICDTCommonProjectWizard extends IWizard {
/**
- * First stage of creating the project but no progress displayed. Identical to
+ * First stage of creating the project but no progress displayed. Identical to
* calling createIProject(name, location, new NullProgressMonitor())
- *
+ *
* @param name name of the project
* @param location location URI for the project
* @return the project
@@ -37,80 +36,82 @@ public interface ICDTCommonProjectWizard extends IWizard {
/**
* First stage of creating the project. Only used internally.
- *
+ *
* @param name name of the project
* @param location location URI for the project
* @param monitor progress monitor
* @return the project
* @throws CoreException if project creation fails for any reason
*/
- public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException;
-
+ public IProject createIProject(final String name, final URI location, IProgressMonitor monitor)
+ throws CoreException;
+
/**
* Get the file content types supported by this project
- *
+ *
* @return array of file content types
*/
public String[] getContentTypeIDs();
/**
* Get the file extension specifications for each content type.
- *
+ *
* @return array of file extension specifications
*/
public String[] getExtensions();
/**
* Get the languages supported by each content type
- *
+ *
* @return array of languages
*/
public String[] getLanguageIDs();
-
+
/**
* Return the last project created by the call to getProject().
- *
+ *
* @return the last project created
*/
public IProject getLastProject();
/**
* Get the project natures provided by this project.
- *
+ *
* @return array of project natures
*/
public String[] getNatures();
-
+
/**
* Create and return the project specified by the wizard. Identical to calling
* getProject(defaults, true)
- *
+ *
* @param defaults true if called from the first wizard page
* @return the newly created project
*/
public IProject getProject(boolean defaults);
-
+
/**
* Create and return the project specified by the wizard.
- *
+ *
* @param defaults true if called from the first wizard page
* @param onFinish true if the method is called when finish is pressed, false
* otherwise. If onFinish is false, the project is temporary and can be removed
- * if cancel is pressed.
+ * if cancel is pressed.
* @return the newly created project
*/
public IProject getProject(boolean defaults, boolean onFinish);
-
+
/**
- * Can be used to pass a configuration element to update the perspective based
+ * Can be used to pass a configuration element to update the perspective based
* on the current settings in the Workbench/Perspectives preference page via
* {@link BasicNewProjectResourceWizard#updatePerspective(IConfigurationElement)}
- *
+ *
* @param config the configuration element
* @param propertyName not used
* @param data not used
* @throws CoreException
*/
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException;
-
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ throws CoreException;
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.java
index 31c3b8d54e3..ac566e0372b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.java
@@ -49,7 +49,7 @@ public class NewClassCreationWizard extends NewElementWizard {
/**
* Sets the class name for creation in the wizard.
- *
+ *
* @param className
* Name of the class or null, null will indicate default behavior
* which is extract class name from editor context. Setting an
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizard.java
index d329e941bf8..eb0278bebe7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizard.java
@@ -46,11 +46,11 @@ public abstract class NewElementWizard extends Wizard implements INewWizard {
public NewElementWizard() {
setNeedsProgressMonitor(true);
}
-
+
protected void openResource(final IFile resource) {
- final IWorkbenchPage activePage= CUIPlugin.getActivePage();
+ final IWorkbenchPage activePage = CUIPlugin.getActivePage();
if (activePage != null) {
- final Display display= getShell().getDisplay();
+ final Display display = getShell().getDisplay();
if (display != null) {
display.asyncExec(new Runnable() {
@Override
@@ -65,33 +65,33 @@ public abstract class NewElementWizard extends Wizard implements INewWizard {
}
}
}
-
+
/**
* Subclasses should override to perform the actions of the wizard.
* This method is run in the wizard container's context as a workspace runnable.
*/
protected abstract void finishPage(IProgressMonitor monitor) throws CoreException;
-
+
/**
* Returns the scheduling rule for creating the element.
*/
protected ISchedulingRule getSchedulingRule() {
return ResourcesPlugin.getWorkspace().getRoot(); // look all by default
}
-
+
protected boolean canRunForked() {
return true;
}
-
+
protected void handleFinishException(Shell shell, InvocationTargetException e) {
- String title= NewWizardMessages.NewElementWizard_op_error_title;
- String message= NewWizardMessages.NewElementWizard_op_error_message;
+ String title = NewWizardMessages.NewElementWizard_op_error_title;
+ String message = NewWizardMessages.NewElementWizard_op_error_message;
ExceptionHandler.handle(e, shell, title, message);
}
-
+
@Override
public boolean performFinish() {
- IWorkspaceRunnable op= new IWorkspaceRunnable() {
+ IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
finishPage(monitor);
@@ -107,13 +107,13 @@ public abstract class NewElementWizard extends Wizard implements INewWizard {
}
return true;
}
-
+
@Override
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
- fWorkbench= workbench;
- fSelection= currentSelection;
+ fWorkbench = workbench;
+ fSelection = currentSelection;
}
-
+
public IStructuredSelection getSelection() {
return fSelection;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.java
index 52b92c041d2..7a5b70ba770 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.java
@@ -26,22 +26,22 @@ import org.eclipse.jface.wizard.WizardPage;
public abstract class NewElementWizardPage extends WizardPage {
private IStatus fCurrStatus;
-
+
private boolean fPageVisible;
/**
* Creates a <code>NewElementWizardPage</code>.
- *
+ *
* @param name the wizard page's name
- */
+ */
public NewElementWizardPage(String name) {
super(name);
fPageVisible = false;
- fCurrStatus = new StatusInfo();
+ fCurrStatus = new StatusInfo();
}
-
+
// ---- WizardPage ----------------
-
+
/*
* @see WizardPage#becomesVisible
*/
@@ -52,15 +52,15 @@ public abstract class NewElementWizardPage extends WizardPage {
// policy: wizards are not allowed to come up with an error message
if (visible && fCurrStatus.matches(IStatus.ERROR)) {
StatusInfo status = new StatusInfo();
- status.setError(""); //$NON-NLS-1$
+ status.setError(""); //$NON-NLS-1$
fCurrStatus = status;
- }
+ }
updateStatus(fCurrStatus);
- }
+ }
/**
* Updates the status line and the ok button according to the given status
- *
+ *
* @param status status to apply
*/
protected void updateStatus(IStatus status) {
@@ -70,16 +70,16 @@ public abstract class NewElementWizardPage extends WizardPage {
StatusUtil.applyToStatusLine(this, status);
}
}
-
+
/**
* Updates the status line and the ok button according to the status evaluate from
- * an array of status. The most severe error is taken. In case that two status with
+ * an array of status. The most severe error is taken. In case that two status with
* the same severity exists, the status with lower index is taken.
- *
+ *
* @param status the array of status
*/
protected void updateStatus(IStatus[] status) {
updateStatus(StatusUtil.getMostSevere(status));
- }
-
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java
index 0d0c9183ddd..08db3ec466d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java
@@ -18,8 +18,8 @@ import org.eclipse.jface.action.IAction;
public class NewFileDropDownAction extends AbstractWizardDropDownAction {
public NewFileDropDownAction() {
- super();
-// WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_FILE_WIZARD_ACTION);
+ super();
+ // WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_FILE_WIZARD_ACTION);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java
index 40c5853632a..b7d60d47586 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java
@@ -18,8 +18,8 @@ import org.eclipse.jface.action.IAction;
public class NewFolderDropDownAction extends AbstractWizardDropDownAction {
public NewFolderDropDownAction() {
- super();
-// WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_FOLDER_WIZARD_ACTION);
+ super();
+ // WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_FOLDER_WIZARD_ACTION);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java
index 9503aaa8a0e..ed2e9950c71 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java
@@ -20,10 +20,10 @@ import org.eclipse.ui.PlatformUI;
public class NewProjectDropDownAction extends AbstractWizardDropDownAction {
public NewProjectDropDownAction() {
- super();
+ super();
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.OPEN_PROJECT_WIZARD_ACTION);
}
-
+
@Override
protected IAction[] getWizardActions() {
return CWizardRegistry.getProjectWizardActions();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java
index c3ae207d15c..0180db53fd7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java
@@ -20,7 +20,7 @@ import org.eclipse.ui.PlatformUI;
public class NewTypeDropDownAction extends AbstractWizardDropDownAction {
public NewTypeDropDownAction() {
- super();
+ super();
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.java
index 940b630db11..bda9e71fd9b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.java
@@ -24,29 +24,28 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
-
public class OpenNewWizardAction extends AbstractOpenWizardAction {
- private static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
private final static String ATT_NAME = "name";//$NON-NLS-1$
private final static String ATT_CLASS = "class";//$NON-NLS-1$
private final static String ATT_ICON = "icon";//$NON-NLS-1$
-
+
private IConfigurationElement fConfigurationElement;
public OpenNewWizardAction(IConfigurationElement element) {
- fConfigurationElement= element;
+ fConfigurationElement = element;
setText(element.getAttribute(ATT_NAME));
-
- String description= getDescriptionFromConfig(fConfigurationElement);
+
+ String description = getDescriptionFromConfig(fConfigurationElement);
setDescription(description);
setToolTipText(description);
setImageDescriptor(getIconFromConfig(fConfigurationElement));
}
-
- private String getDescriptionFromConfig(IConfigurationElement config) {
- IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION);
- if (children.length>=1) {
+
+ private String getDescriptionFromConfig(IConfigurationElement config) {
+ IConfigurationElement[] children = config.getChildren(TAG_DESCRIPTION);
+ if (children.length >= 1) {
return children[0].getValue();
}
return ""; //$NON-NLS-1$
@@ -56,7 +55,8 @@ public class OpenNewWizardAction extends AbstractOpenWizardAction {
try {
String iconName = config.getAttribute(ATT_ICON);
if (iconName != null) {
- URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
+ URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName())
+ .getEntry("/"); //$NON-NLS-1$
return ImageDescriptor.createFromURL(new URL(pluginInstallUrl, iconName));
}
return null;
@@ -64,9 +64,9 @@ public class OpenNewWizardAction extends AbstractOpenWizardAction {
CUIPlugin.logError("Unable to load wizard icon"); //$NON-NLS-1$
}
return ImageDescriptor.getMissingImageDescriptor();
-
+
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.wizards.AbstractOpenWizardAction#createWizard()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.java
index cb0955fcb54..bac5ecbbb28 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.java
@@ -32,23 +32,25 @@ import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
public class SourceFolderSelectionDialog extends ElementTreeSelectionDialog {
-
- private static final Class<?>[] VALIDATOR_CLASSES = new Class<?>[] { ICContainer.class, ICProject.class };
- private static final TypedElementSelectionValidator fValidator = new TypedElementSelectionValidator(VALIDATOR_CLASSES, false);
-
- private static final Class<?>[] FILTER_CLASSES = new Class<?>[] { ICModel.class, ICContainer.class, ICProject.class };
- private static final ViewerFilter fFilter = new TypedViewerFilter(FILTER_CLASSES);
-
- private static final ViewerSorter fSorter = new CElementSorter();
-
- public SourceFolderSelectionDialog(Shell parent) {
- super(parent, createLabelProvider(), createContentProvider());
- setValidator(fValidator);
- setComparator(fSorter);
- addFilter(fFilter);
- setTitle(NewWizardMessages.SourceFolderSelectionDialog_title);
- setMessage(NewWizardMessages.SourceFolderSelectionDialog_description);
- }
+
+ private static final Class<?>[] VALIDATOR_CLASSES = new Class<?>[] { ICContainer.class, ICProject.class };
+ private static final TypedElementSelectionValidator fValidator = new TypedElementSelectionValidator(
+ VALIDATOR_CLASSES, false);
+
+ private static final Class<?>[] FILTER_CLASSES = new Class<?>[] { ICModel.class, ICContainer.class,
+ ICProject.class };
+ private static final ViewerFilter fFilter = new TypedViewerFilter(FILTER_CLASSES);
+
+ private static final ViewerSorter fSorter = new CElementSorter();
+
+ public SourceFolderSelectionDialog(Shell parent) {
+ super(parent, createLabelProvider(), createContentProvider());
+ setValidator(fValidator);
+ setComparator(fSorter);
+ addFilter(fFilter);
+ setTitle(NewWizardMessages.SourceFolderSelectionDialog_title);
+ setMessage(NewWizardMessages.SourceFolderSelectionDialog_description);
+ }
private static ITreeContentProvider createContentProvider() {
return new CElementContentProvider();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java
index 488ff2b587d..507930f2c75 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java
@@ -20,87 +20,89 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public abstract class AbstractMethodStub implements IMethodStub {
- protected String fName;
- protected String fDescription;
- protected ASTAccessVisibility fAccess;
- protected boolean fIsVirtual;
- protected boolean fIsInline;
-
- public AbstractMethodStub(String name, ASTAccessVisibility access, boolean isVirtual, boolean isInline) {
- fName = name;
- fAccess = access;
- fIsVirtual = isVirtual;
- fIsInline = isInline;
- }
-
- @Override
+ protected String fName;
+ protected String fDescription;
+ protected ASTAccessVisibility fAccess;
+ protected boolean fIsVirtual;
+ protected boolean fIsInline;
+
+ public AbstractMethodStub(String name, ASTAccessVisibility access, boolean isVirtual, boolean isInline) {
+ fName = name;
+ fAccess = access;
+ fIsVirtual = isVirtual;
+ fIsInline = isInline;
+ }
+
+ @Override
public String getName() {
- return fName;
- }
+ return fName;
+ }
- @Override
+ @Override
public String getDescription() {
- return fDescription;
- }
+ return fDescription;
+ }
- @Override
+ @Override
public ASTAccessVisibility getAccess() {
- return fAccess;
- }
+ return fAccess;
+ }
- @Override
+ @Override
public void setAccess(ASTAccessVisibility access) {
- fAccess = access;
- }
+ fAccess = access;
+ }
- @Override
+ @Override
public boolean isVirtual() {
- return fIsVirtual;
- }
-
- @Override
+ return fIsVirtual;
+ }
+
+ @Override
public void setVirtual(boolean isVirtual) {
- fIsVirtual = isVirtual;
- }
+ fIsVirtual = isVirtual;
+ }
- @Override
+ @Override
public boolean isInline() {
- return fIsInline;
- }
+ return fIsInline;
+ }
- @Override
+ @Override
public void setInline(boolean isInline) {
- fIsInline = isInline;
- }
-
- @Override
+ fIsInline = isInline;
+ }
+
+ @Override
public boolean canModifyAccess() {
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public boolean canModifyVirtual() {
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public boolean canModifyInline() {
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public boolean isConstructor() {
- return false;
- }
+ return false;
+ }
- @Override
+ @Override
public boolean isDestructor() {
- return false;
- }
-
- @Override
- public abstract String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
-
- @Override
- public abstract String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
+ return false;
+ }
+
+ @Override
+ public abstract String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
+ String lineDelimiter) throws CoreException;
+
+ @Override
+ public abstract String createMethodImplementation(ITranslationUnit tu, String className,
+ IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java
index 6b91b36537b..992f6ffa749 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java
@@ -16,41 +16,40 @@ package org.eclipse.cdt.internal.ui.wizards.classwizard;
import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-
public class BaseClassInfo implements IBaseClassInfo {
-
- private ITypeInfo fType;
- private ASTAccessVisibility fAccess;
- private boolean fIsVirtual;
-
- public BaseClassInfo(ITypeInfo type, ASTAccessVisibility access, boolean isVirtual) {
- fType = type;
- fAccess = access;
- fIsVirtual = isVirtual;
- }
-
- @Override
+
+ private ITypeInfo fType;
+ private ASTAccessVisibility fAccess;
+ private boolean fIsVirtual;
+
+ public BaseClassInfo(ITypeInfo type, ASTAccessVisibility access, boolean isVirtual) {
+ fType = type;
+ fAccess = access;
+ fIsVirtual = isVirtual;
+ }
+
+ @Override
public ITypeInfo getType() {
- return fType;
- }
-
- @Override
+ return fType;
+ }
+
+ @Override
public ASTAccessVisibility getAccess() {
- return fAccess;
- }
-
+ return fAccess;
+ }
+
@Override
public boolean isVirtual() {
- return fIsVirtual;
+ return fIsVirtual;
}
- @Override
+ @Override
public void setAccess(ASTAccessVisibility access) {
- fAccess = access;
- }
+ fAccess = access;
+ }
- @Override
+ @Override
public void setVirtual(boolean isVirtual) {
- fIsVirtual = isVirtual;
- }
+ fIsVirtual = isVirtual;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
index db9d196a16c..649854ce292 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
@@ -21,26 +21,27 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
public final class BaseClassesLabelProvider implements ITableLabelProvider {
- private static final String YES_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_yes_label;
- private static final String NO_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_no_label;
- private static final String ACCESS_PUBLIC = NewClassWizardMessages.BaseClassesLabelProvider_access_public_label;
- private static final String ACCESS_PROTECTED = NewClassWizardMessages.BaseClassesLabelProvider_access_protected_label;
- private static final String ACCESS_PRIVATE = NewClassWizardMessages.BaseClassesLabelProvider_access_private_label;
+ private static final String YES_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_yes_label;
+ private static final String NO_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_no_label;
+ private static final String ACCESS_PUBLIC = NewClassWizardMessages.BaseClassesLabelProvider_access_public_label;
+ private static final String ACCESS_PROTECTED = NewClassWizardMessages.BaseClassesLabelProvider_access_protected_label;
+ private static final String ACCESS_PRIVATE = NewClassWizardMessages.BaseClassesLabelProvider_access_private_label;
- public static final String getYesNoText(boolean value) {
- return value ? YES_VALUE : NO_VALUE;
- }
+ public static final String getYesNoText(boolean value) {
+ return value ? YES_VALUE : NO_VALUE;
+ }
+
+ public static final String getAccessText(ASTAccessVisibility access) {
+ if (access == ASTAccessVisibility.PRIVATE)
+ return ACCESS_PRIVATE;
+ if (access == ASTAccessVisibility.PROTECTED)
+ return ACCESS_PROTECTED;
+ return ACCESS_PUBLIC;
+ }
- public static final String getAccessText(ASTAccessVisibility access) {
- if (access == ASTAccessVisibility.PRIVATE)
- return ACCESS_PRIVATE;
- if (access == ASTAccessVisibility.PROTECTED)
- return ACCESS_PROTECTED;
- return ACCESS_PUBLIC;
- }
+ private static TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(
+ TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
- private static TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
-
/*
* @see ITableLabelProvider#getColumnImage(Object, int)
*/
@@ -48,8 +49,8 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex != 0)
return null;
-
- IBaseClassInfo info = (IBaseClassInfo) element;
+
+ IBaseClassInfo info = (IBaseClassInfo) element;
return fTypeInfoLabelProvider.getImage(info.getType());
}
@@ -58,13 +59,13 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
*/
@Override
public String getColumnText(Object element, int columnIndex) {
- IBaseClassInfo info = (IBaseClassInfo) element;
-
+ IBaseClassInfo info = (IBaseClassInfo) element;
+
switch (columnIndex) {
case 0:
- return fTypeInfoLabelProvider.getText(info.getType());
+ return fTypeInfoLabelProvider.getText(info.getType());
case 1:
- return getAccessText(info.getAccess());
+ return getAccessText(info.getAccess());
case 2:
return getYesNoText(info.isVirtual());
default:
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListDialogField.java
index 5ad8c672a3f..bb2be1d1fe8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListDialogField.java
@@ -35,154 +35,135 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class BaseClassesListDialogField extends ListDialogField<IBaseClassInfo> {
-
- // column properties
- private static final String CP_NAME = "name"; //$NON-NLS-1$
- private static final String CP_ACCESS = "access"; //$NON-NLS-1$
- private static final String CP_VIRTUAL = "virtual"; //$NON-NLS-1$
- static final Integer INDEX_YES = 0;
- static final Integer INDEX_NO = 1;
- static final Integer INDEX_PUBLIC = 0;
- static final Integer INDEX_PROTECTED = 1;
- static final Integer INDEX_PRIVATE = 2;
-
- private final class CellHandler implements ICellModifier {
- @Override
+
+ // column properties
+ private static final String CP_NAME = "name"; //$NON-NLS-1$
+ private static final String CP_ACCESS = "access"; //$NON-NLS-1$
+ private static final String CP_VIRTUAL = "virtual"; //$NON-NLS-1$
+ static final Integer INDEX_YES = 0;
+ static final Integer INDEX_NO = 1;
+ static final Integer INDEX_PUBLIC = 0;
+ static final Integer INDEX_PROTECTED = 1;
+ static final Integer INDEX_PRIVATE = 2;
+
+ private final class CellHandler implements ICellModifier {
+ @Override
public boolean canModify(Object element, String property) {
- return (element instanceof IBaseClassInfo)
- && (property.equals(CP_ACCESS) || property.equals(CP_VIRTUAL));
- }
-
- @Override
+ return (element instanceof IBaseClassInfo) && (property.equals(CP_ACCESS) || property.equals(CP_VIRTUAL));
+ }
+
+ @Override
public Object getValue(Object element, String property) {
- if (!(element instanceof IBaseClassInfo))
- return null;
-
- IBaseClassInfo baseClass = (IBaseClassInfo) element;
- if (property.equals(CP_ACCESS)) {
- if (baseClass.getAccess() == ASTAccessVisibility.PRIVATE) {
- return INDEX_PRIVATE;
- } else if (baseClass.getAccess() == ASTAccessVisibility.PROTECTED) {
- return INDEX_PROTECTED;
- } else {
- return INDEX_PUBLIC;
- }
- } else if (property.equals(CP_VIRTUAL)) {
- if (baseClass.isVirtual())
- return INDEX_YES;
- return INDEX_NO;
- }
- return null;
- }
-
- @Override
+ if (!(element instanceof IBaseClassInfo))
+ return null;
+
+ IBaseClassInfo baseClass = (IBaseClassInfo) element;
+ if (property.equals(CP_ACCESS)) {
+ if (baseClass.getAccess() == ASTAccessVisibility.PRIVATE) {
+ return INDEX_PRIVATE;
+ } else if (baseClass.getAccess() == ASTAccessVisibility.PROTECTED) {
+ return INDEX_PROTECTED;
+ } else {
+ return INDEX_PUBLIC;
+ }
+ } else if (property.equals(CP_VIRTUAL)) {
+ if (baseClass.isVirtual())
+ return INDEX_YES;
+ return INDEX_NO;
+ }
+ return null;
+ }
+
+ @Override
public void modify(Object element, String property, Object value) {
- IBaseClassInfo baseClass = null;
- if (element instanceof IBaseClassInfo) {
- baseClass = (IBaseClassInfo) element;
- } else if (element instanceof Item) {
- Object data = ((Item)element).getData();
- if (data instanceof IBaseClassInfo)
- baseClass = (IBaseClassInfo) data;
- }
- if (baseClass != null) {
- if (property.equals(CP_ACCESS) && value instanceof Integer) {
- Integer access = (Integer)value;
- if (access.equals(INDEX_PRIVATE)) {
- baseClass.setAccess(ASTAccessVisibility.PRIVATE);
- } else if (access.equals(INDEX_PROTECTED)) {
- baseClass.setAccess(ASTAccessVisibility.PROTECTED);
- } else {
- baseClass.setAccess(ASTAccessVisibility.PUBLIC);
- }
- refresh();
- } else if (property.equals(CP_VIRTUAL) && value instanceof Integer) {
- Integer yesno = (Integer)value;
- baseClass.setVirtual(yesno.equals(INDEX_YES));
- refresh();
- }
- }
- }
- }
-
- public BaseClassesListDialogField(String title, IListAdapter<IBaseClassInfo> listAdapter) {
- super(listAdapter,
- new String[] {
- NewClassWizardMessages.BaseClassesListDialogField_buttons_add,
- NewClassWizardMessages.BaseClassesListDialogField_buttons_remove,
- NewClassWizardMessages.BaseClassesListDialogField_buttons_up,
- NewClassWizardMessages.BaseClassesListDialogField_buttons_down
- }, new BaseClassesLabelProvider());
- setRemoveButtonIndex(1);
- setUpButtonIndex(2);
- setDownButtonIndex(3);
- setLabelText(title);
-
- String[] headers = new String[] {
- NewClassWizardMessages.BaseClassesListDialogField_headings_name,
- NewClassWizardMessages.BaseClassesListDialogField_headings_access,
- NewClassWizardMessages.BaseClassesListDialogField_headings_virtual
- };
- ColumnLayoutData[] columns = new ColumnLayoutData[] {
- new ColumnWeightData(70, 30),
- new ColumnWeightData(30, 30),
- new ColumnWeightData(25, 25),
- };
- setTableColumns(new ListDialogField.ColumnsDescription(columns, headers, true));
- }
-
- @Override
+ IBaseClassInfo baseClass = null;
+ if (element instanceof IBaseClassInfo) {
+ baseClass = (IBaseClassInfo) element;
+ } else if (element instanceof Item) {
+ Object data = ((Item) element).getData();
+ if (data instanceof IBaseClassInfo)
+ baseClass = (IBaseClassInfo) data;
+ }
+ if (baseClass != null) {
+ if (property.equals(CP_ACCESS) && value instanceof Integer) {
+ Integer access = (Integer) value;
+ if (access.equals(INDEX_PRIVATE)) {
+ baseClass.setAccess(ASTAccessVisibility.PRIVATE);
+ } else if (access.equals(INDEX_PROTECTED)) {
+ baseClass.setAccess(ASTAccessVisibility.PROTECTED);
+ } else {
+ baseClass.setAccess(ASTAccessVisibility.PUBLIC);
+ }
+ refresh();
+ } else if (property.equals(CP_VIRTUAL) && value instanceof Integer) {
+ Integer yesno = (Integer) value;
+ baseClass.setVirtual(yesno.equals(INDEX_YES));
+ refresh();
+ }
+ }
+ }
+ }
+
+ public BaseClassesListDialogField(String title, IListAdapter<IBaseClassInfo> listAdapter) {
+ super(listAdapter,
+ new String[] { NewClassWizardMessages.BaseClassesListDialogField_buttons_add,
+ NewClassWizardMessages.BaseClassesListDialogField_buttons_remove,
+ NewClassWizardMessages.BaseClassesListDialogField_buttons_up,
+ NewClassWizardMessages.BaseClassesListDialogField_buttons_down },
+ new BaseClassesLabelProvider());
+ setRemoveButtonIndex(1);
+ setUpButtonIndex(2);
+ setDownButtonIndex(3);
+ setLabelText(title);
+
+ String[] headers = new String[] { NewClassWizardMessages.BaseClassesListDialogField_headings_name,
+ NewClassWizardMessages.BaseClassesListDialogField_headings_access,
+ NewClassWizardMessages.BaseClassesListDialogField_headings_virtual };
+ ColumnLayoutData[] columns = new ColumnLayoutData[] { new ColumnWeightData(70, 30),
+ new ColumnWeightData(30, 30), new ColumnWeightData(25, 25), };
+ setTableColumns(new ListDialogField.ColumnsDescription(columns, headers, true));
+ }
+
+ @Override
protected boolean managedButtonPressed(int index) {
- super.managedButtonPressed(index);
- return false;
- }
-
- @Override
+ super.managedButtonPressed(index);
+ return false;
+ }
+
+ @Override
protected TableViewer createTableViewer(Composite parent) {
- TableViewer viewer = super.createTableViewer(parent);
- Table table = viewer.getTable();
- table.getAccessible().addAccessibleListener(
- new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result = NewClassWizardMessages.NewClassCreationWizardPage_baseClasses_label;
- }
- }
- );
-
- CellEditor virtualCellEditor = new ComboBoxCellEditor(table,
- new String[] {
- /* INDEX_YES */BaseClassesLabelProvider.getYesNoText(true),
- /* INDEX_NO */BaseClassesLabelProvider.getYesNoText(false)
- }, SWT.READ_ONLY);
-
- CellEditor accessCellEditor = new ComboBoxCellEditor(table,
- new String[] {
- /* INDEX_PUBLIC */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PUBLIC),
- /* INDEX_PROTECTED */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PROTECTED),
- /* INDEX_PRIVATE */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PRIVATE)
- }, SWT.READ_ONLY);
-
- viewer.setCellEditors(new CellEditor[] {
- null,
- accessCellEditor,
- virtualCellEditor
+ TableViewer viewer = super.createTableViewer(parent);
+ Table table = viewer.getTable();
+ table.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ e.result = NewClassWizardMessages.NewClassCreationWizardPage_baseClasses_label;
+ }
});
- viewer.setColumnProperties(new String[] {
- CP_NAME,
- CP_ACCESS,
- CP_VIRTUAL
- });
- viewer.setCellModifier(new CellHandler());
- return viewer;
- }
-
- public void addBaseClass(IBaseClassInfo baseClass) {
- addElement(baseClass);
- }
-
- public IBaseClassInfo[] getBaseClasses() {
- List<IBaseClassInfo> baseClasses = getElements();
- return baseClasses.toArray(new IBaseClassInfo[baseClasses.size()]);
- }
+
+ CellEditor virtualCellEditor = new ComboBoxCellEditor(table,
+ new String[] { /* INDEX_YES */BaseClassesLabelProvider.getYesNoText(true),
+ /* INDEX_NO */BaseClassesLabelProvider.getYesNoText(false) },
+ SWT.READ_ONLY);
+
+ CellEditor accessCellEditor = new ComboBoxCellEditor(table,
+ new String[] { /* INDEX_PUBLIC */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PUBLIC),
+ /* INDEX_PROTECTED */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PROTECTED),
+ /* INDEX_PRIVATE */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PRIVATE) },
+ SWT.READ_ONLY);
+
+ viewer.setCellEditors(new CellEditor[] { null, accessCellEditor, virtualCellEditor });
+ viewer.setColumnProperties(new String[] { CP_NAME, CP_ACCESS, CP_VIRTUAL });
+ viewer.setCellModifier(new CellHandler());
+ return viewer;
+ }
+
+ public void addBaseClass(IBaseClassInfo baseClass) {
+ addElement(baseClass);
+ }
+
+ public IBaseClassInfo[] getBaseClasses() {
+ List<IBaseClassInfo> baseClasses = getElements();
+ return baseClasses.toArray(new IBaseClassInfo[baseClasses.size()]);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java
index 16a81aa6038..2a99fe4db97 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java
@@ -19,67 +19,68 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.ui.CodeGeneration;
-
public final class ConstructorMethodStub extends AbstractMethodStub {
- private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_constructor_name;
-
- public ConstructorMethodStub() {
- this(ASTAccessVisibility.PUBLIC, false);
- }
+ private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_constructor_name;
+
+ public ConstructorMethodStub() {
+ this(ASTAccessVisibility.PUBLIC, false);
+ }
- public ConstructorMethodStub(ASTAccessVisibility access, boolean isInline) {
- super(NAME, access, false, isInline);
- }
+ public ConstructorMethodStub(ASTAccessVisibility access, boolean isInline) {
+ super(NAME, access, false, isInline);
+ }
- @Override
- public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException {
- StringBuilder buf = new StringBuilder();
- buf.append(className);
- buf.append("()"); //$NON-NLS-1$
- if (fIsInline) {
- buf.append('{');
- buf.append(lineDelimiter);
- String body= CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
- if (body != null) {
- buf.append(body);
- buf.append(lineDelimiter);
- }
- buf.append('}');
- } else {
- buf.append(";"); //$NON-NLS-1$
- }
- return buf.toString();
- }
+ @Override
+ public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
+ String lineDelimiter) throws CoreException {
+ StringBuilder buf = new StringBuilder();
+ buf.append(className);
+ buf.append("()"); //$NON-NLS-1$
+ if (fIsInline) {
+ buf.append('{');
+ buf.append(lineDelimiter);
+ String body = CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
+ if (body != null) {
+ buf.append(body);
+ buf.append(lineDelimiter);
+ }
+ buf.append('}');
+ } else {
+ buf.append(";"); //$NON-NLS-1$
+ }
+ return buf.toString();
+ }
- @Override
- public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException {
- if (fIsInline) {
- return ""; //$NON-NLS-1$
- }
- StringBuilder buf = new StringBuilder();
- buf.append(className);
- buf.append("::"); //$NON-NLS-1$
- buf.append(className);
- buf.append("()"); //$NON-NLS-1$
- buf.append(lineDelimiter);
- buf.append('{');
- buf.append(lineDelimiter);
- String body= CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
- if (body != null) {
- buf.append(body);
- buf.append(lineDelimiter);
- }
- buf.append('}');
- return buf.toString();
- }
+ @Override
+ public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
+ String lineDelimiter) throws CoreException {
+ if (fIsInline) {
+ return ""; //$NON-NLS-1$
+ }
+ StringBuilder buf = new StringBuilder();
+ buf.append(className);
+ buf.append("::"); //$NON-NLS-1$
+ buf.append(className);
+ buf.append("()"); //$NON-NLS-1$
+ buf.append(lineDelimiter);
+ buf.append('{');
+ buf.append(lineDelimiter);
+ String body = CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
+ if (body != null) {
+ buf.append(body);
+ buf.append(lineDelimiter);
+ }
+ buf.append('}');
+ return buf.toString();
+ }
- @Override
+ @Override
public boolean isConstructor() {
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public boolean canModifyVirtual() {
- return false;
- }
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java
index 366b9896a19..f17bef00ba9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java
@@ -20,67 +20,68 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.ui.CodeGeneration;
-
public final class DestructorMethodStub extends AbstractMethodStub {
-
- private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_destructor_name;
-
- public DestructorMethodStub() {
- this(ASTAccessVisibility.PUBLIC, true, false);
- }
- public DestructorMethodStub(ASTAccessVisibility access, boolean isVirtual, boolean isInline) {
- super(NAME, access, isVirtual, isInline);
- }
+ private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_destructor_name;
+
+ public DestructorMethodStub() {
+ this(ASTAccessVisibility.PUBLIC, true, false);
+ }
+
+ public DestructorMethodStub(ASTAccessVisibility access, boolean isVirtual, boolean isInline) {
+ super(NAME, access, isVirtual, isInline);
+ }
- @Override
- public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException {
- StringBuilder buf = new StringBuilder();
- if (fIsVirtual){
- buf.append("virtual "); //$NON-NLS-1$
- }
- buf.append("~"); //$NON-NLS-1$
- buf.append(className);
- buf.append("()"); //$NON-NLS-1$
- if (fIsInline) {
- buf.append('{');
- buf.append(lineDelimiter);
- String body= CodeGeneration.getDestructorBodyContent(tu, className, null, lineDelimiter);
- if (body != null) {
- buf.append(body);
- buf.append(lineDelimiter);
- }
- buf.append('}');
- } else {
- buf.append(";"); //$NON-NLS-1$
- }
- return buf.toString();
- }
+ @Override
+ public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
+ String lineDelimiter) throws CoreException {
+ StringBuilder buf = new StringBuilder();
+ if (fIsVirtual) {
+ buf.append("virtual "); //$NON-NLS-1$
+ }
+ buf.append("~"); //$NON-NLS-1$
+ buf.append(className);
+ buf.append("()"); //$NON-NLS-1$
+ if (fIsInline) {
+ buf.append('{');
+ buf.append(lineDelimiter);
+ String body = CodeGeneration.getDestructorBodyContent(tu, className, null, lineDelimiter);
+ if (body != null) {
+ buf.append(body);
+ buf.append(lineDelimiter);
+ }
+ buf.append('}');
+ } else {
+ buf.append(";"); //$NON-NLS-1$
+ }
+ return buf.toString();
+ }
- @Override
- public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException {
- if (fIsInline) {
- return ""; //$NON-NLS-1$
- }
- StringBuilder buf = new StringBuilder();
- buf.append(className);
- buf.append("::~"); //$NON-NLS-1$
- buf.append(className);
- buf.append("()"); //$NON-NLS-1$
- buf.append(lineDelimiter);
- buf.append('{');
- buf.append(lineDelimiter);
- String body= CodeGeneration.getDestructorBodyContent(tu, className, null, lineDelimiter);
- if (body != null) {
- buf.append(body);
- buf.append(lineDelimiter);
- }
- buf.append('}');
- return buf.toString();
- }
+ @Override
+ public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
+ String lineDelimiter) throws CoreException {
+ if (fIsInline) {
+ return ""; //$NON-NLS-1$
+ }
+ StringBuilder buf = new StringBuilder();
+ buf.append(className);
+ buf.append("::~"); //$NON-NLS-1$
+ buf.append(className);
+ buf.append("()"); //$NON-NLS-1$
+ buf.append(lineDelimiter);
+ buf.append('{');
+ buf.append(lineDelimiter);
+ String body = CodeGeneration.getDestructorBodyContent(tu, className, null, lineDelimiter);
+ if (body != null) {
+ buf.append(body);
+ buf.append(lineDelimiter);
+ }
+ buf.append('}');
+ return buf.toString();
+ }
- @Override
+ @Override
public boolean isDestructor() {
- return true;
- }
+ return true;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSelectionDialog.java
index e4202108c1a..359d8238444 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSelectionDialog.java
@@ -18,16 +18,16 @@ import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
import org.eclipse.swt.widgets.Shell;
public class EnclosingClassSelectionDialog extends TypeSelectionDialog {
-
- private static final String DIALOG_SETTINGS = EnclosingClassSelectionDialog.class.getName();
- private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS };
-
- public EnclosingClassSelectionDialog(Shell parent) {
- super(parent);
- setTitle(NewClassWizardMessages.EnclosingClassSelectionDialog_title);
- setMessage(NewClassWizardMessages.EnclosingClassSelectionDialog_message);
- setDialogSettings(DIALOG_SETTINGS);
- setVisibleTypes(VISIBLE_TYPES);
- setFilter("*", true); //$NON-NLS-1$
- }
+
+ private static final String DIALOG_SETTINGS = EnclosingClassSelectionDialog.class.getName();
+ private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS };
+
+ public EnclosingClassSelectionDialog(Shell parent) {
+ super(parent);
+ setTitle(NewClassWizardMessages.EnclosingClassSelectionDialog_title);
+ setMessage(NewClassWizardMessages.EnclosingClassSelectionDialog_message);
+ setDialogSettings(DIALOG_SETTINGS);
+ setVisibleTypes(VISIBLE_TYPES);
+ setFilter("*", true); //$NON-NLS-1$
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java
index c16489cf2ad..ad36ea24389 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java
@@ -16,12 +16,14 @@ package org.eclipse.cdt.internal.ui.wizards.classwizard;
import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-
public interface IBaseClassInfo {
public ITypeInfo getType();
- public ASTAccessVisibility getAccess();
- public boolean isVirtual();
-
- public void setAccess(ASTAccessVisibility access);
- public void setVirtual(boolean isVirtual);
+
+ public ASTAccessVisibility getAccess();
+
+ public boolean isVirtual();
+
+ public void setAccess(ASTAccessVisibility access);
+
+ public void setVirtual(boolean isVirtual);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java
index 8de7d981ce0..cb53e612d03 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java
@@ -19,26 +19,36 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-
public interface IMethodStub {
- public String getName();
- public String getDescription();
-
- public ASTAccessVisibility getAccess();
- public boolean canModifyAccess();
- public void setAccess(ASTAccessVisibility access);
-
- public boolean isVirtual();
- public boolean canModifyVirtual();
- public void setVirtual(boolean isVirtual);
-
- public boolean isInline();
- public boolean canModifyInline();
- public void setInline(boolean isVirtual);
-
- public boolean isConstructor();
- public boolean isDestructor();
-
- public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
- public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
+ public String getName();
+
+ public String getDescription();
+
+ public ASTAccessVisibility getAccess();
+
+ public boolean canModifyAccess();
+
+ public void setAccess(ASTAccessVisibility access);
+
+ public boolean isVirtual();
+
+ public boolean canModifyVirtual();
+
+ public void setVirtual(boolean isVirtual);
+
+ public boolean isInline();
+
+ public boolean canModifyInline();
+
+ public void setInline(boolean isVirtual);
+
+ public boolean isConstructor();
+
+ public boolean isDestructor();
+
+ public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
+ String lineDelimiter) throws CoreException;
+
+ public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
+ String lineDelimiter) throws CoreException;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java
index 7d3c0e901fd..ea923a19d2e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java
@@ -23,7 +23,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-
public final class MethodStubsLabelProvider implements ITableLabelProvider {
/*
@@ -33,8 +32,8 @@ public final class MethodStubsLabelProvider implements ITableLabelProvider {
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex != 0)
return null;
-
- IMethodStub stub = (IMethodStub) element;
+
+ IMethodStub stub = (IMethodStub) element;
ImageDescriptor descriptor = CElementImageProvider.getMethodImageDescriptor(stub.getAccess());
if (descriptor != null) {
return CUIPlugin.getImageDescriptorRegistry().get(descriptor);
@@ -47,19 +46,19 @@ public final class MethodStubsLabelProvider implements ITableLabelProvider {
*/
@Override
public String getColumnText(Object element, int columnIndex) {
- IMethodStub stub = (IMethodStub) element;
-
+ IMethodStub stub = (IMethodStub) element;
+
switch (columnIndex) {
- case 0:
- return stub.getName();
- case 1:
- return BaseClassesLabelProvider.getAccessText(stub.getAccess());
- case 2:
- return BaseClassesLabelProvider.getYesNoText(stub.isVirtual());
- case 3:
- return BaseClassesLabelProvider.getYesNoText(stub.isInline());
- default:
- return null;
+ case 0:
+ return stub.getName();
+ case 1:
+ return BaseClassesLabelProvider.getAccessText(stub.getAccess());
+ case 2:
+ return BaseClassesLabelProvider.getYesNoText(stub.isVirtual());
+ case 3:
+ return BaseClassesLabelProvider.getYesNoText(stub.isInline());
+ default:
+ return null;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java
index cb0d0690b87..bc32af05271 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java
@@ -36,172 +36,152 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class MethodStubsListDialogField extends CheckedListDialogField<IMethodStub> {
- // column properties
- private static final String CP_NAME = "name"; //$NON-NLS-1$
- private static final String CP_ACCESS = "access"; //$NON-NLS-1$
- private static final String CP_VIRTUAL = "virtual"; //$NON-NLS-1$
- private static final String CP_INLINE = "inline"; //$NON-NLS-1$
- static final Integer INDEX_YES = 0;
- static final Integer INDEX_NO = 1;
- static final Integer INDEX_PUBLIC = 0;
- static final Integer INDEX_PROTECTED = 1;
- static final Integer INDEX_PRIVATE = 2;
-
- private final class CellHandler implements ICellModifier {
- @Override
+ // column properties
+ private static final String CP_NAME = "name"; //$NON-NLS-1$
+ private static final String CP_ACCESS = "access"; //$NON-NLS-1$
+ private static final String CP_VIRTUAL = "virtual"; //$NON-NLS-1$
+ private static final String CP_INLINE = "inline"; //$NON-NLS-1$
+ static final Integer INDEX_YES = 0;
+ static final Integer INDEX_NO = 1;
+ static final Integer INDEX_PUBLIC = 0;
+ static final Integer INDEX_PROTECTED = 1;
+ static final Integer INDEX_PRIVATE = 2;
+
+ private final class CellHandler implements ICellModifier {
+ @Override
public boolean canModify(Object element, String property) {
- if (element instanceof IMethodStub) {
- IMethodStub stub = (IMethodStub) element;
- if (property.equals(CP_ACCESS)) {
- return stub.canModifyAccess();
- } else if (property.equals(CP_VIRTUAL)) {
- return stub.canModifyVirtual();
- } else if (property.equals(CP_INLINE)) {
- return stub.canModifyInline();
- }
- }
- return false;
- }
-
- @Override
+ if (element instanceof IMethodStub) {
+ IMethodStub stub = (IMethodStub) element;
+ if (property.equals(CP_ACCESS)) {
+ return stub.canModifyAccess();
+ } else if (property.equals(CP_VIRTUAL)) {
+ return stub.canModifyVirtual();
+ } else if (property.equals(CP_INLINE)) {
+ return stub.canModifyInline();
+ }
+ }
+ return false;
+ }
+
+ @Override
public Object getValue(Object element, String property) {
- if (!(element instanceof IMethodStub))
- return null;
-
- IMethodStub stub = (IMethodStub) element;
- if (property.equals(CP_ACCESS)) {
- if (stub.getAccess() == ASTAccessVisibility.PRIVATE) {
- return INDEX_PRIVATE;
- } else if (stub.getAccess() == ASTAccessVisibility.PROTECTED) {
- return INDEX_PROTECTED;
- } else {
- return INDEX_PUBLIC;
- }
- } else if (property.equals(CP_VIRTUAL)) {
- if (stub.isVirtual())
- return INDEX_YES;
- return INDEX_NO;
- } else if (property.equals(CP_INLINE)) {
- if (stub.isInline())
- return INDEX_YES;
- return INDEX_NO;
- }
- return null;
- }
-
- @Override
+ if (!(element instanceof IMethodStub))
+ return null;
+
+ IMethodStub stub = (IMethodStub) element;
+ if (property.equals(CP_ACCESS)) {
+ if (stub.getAccess() == ASTAccessVisibility.PRIVATE) {
+ return INDEX_PRIVATE;
+ } else if (stub.getAccess() == ASTAccessVisibility.PROTECTED) {
+ return INDEX_PROTECTED;
+ } else {
+ return INDEX_PUBLIC;
+ }
+ } else if (property.equals(CP_VIRTUAL)) {
+ if (stub.isVirtual())
+ return INDEX_YES;
+ return INDEX_NO;
+ } else if (property.equals(CP_INLINE)) {
+ if (stub.isInline())
+ return INDEX_YES;
+ return INDEX_NO;
+ }
+ return null;
+ }
+
+ @Override
public void modify(Object element, String property, Object value) {
- IMethodStub stub = null;
- if (element instanceof IMethodStub) {
- stub = (IMethodStub)element;
- } else if (element instanceof Item) {
- Object data = ((Item)element).getData();
- if (data instanceof IMethodStub)
- stub = (IMethodStub)data;
- }
- if (stub != null) {
- if (property.equals(CP_ACCESS) && value instanceof Integer) {
- Integer access = (Integer) value;
- if (access.equals(INDEX_PRIVATE)) {
- stub.setAccess(ASTAccessVisibility.PRIVATE);
- } else if (access.equals(INDEX_PROTECTED)) {
- stub.setAccess(ASTAccessVisibility.PROTECTED);
- } else {
- stub.setAccess(ASTAccessVisibility.PUBLIC);
- }
- refresh();
- } else if (property.equals(CP_VIRTUAL) && value instanceof Integer) {
- Integer yesno = (Integer) value;
- stub.setVirtual(yesno.equals(INDEX_YES));
- refresh();
- } else if (property.equals(CP_INLINE) && value instanceof Integer) {
- Integer yesno = (Integer) value;
- stub.setInline(yesno.equals(INDEX_YES));
- refresh();
- }
- }
- }
- }
-
- public MethodStubsListDialogField(String title, IListAdapter<IMethodStub> listAdapter) {
- super(listAdapter, null, new MethodStubsLabelProvider());
- setLabelText(title);
-
- String[] headers = new String[] {
- NewClassWizardMessages.MethodStubsDialogField_headings_name,
- NewClassWizardMessages.MethodStubsDialogField_headings_access,
- NewClassWizardMessages.MethodStubsDialogField_headings_virtual,
- NewClassWizardMessages.MethodStubsDialogField_headings_inline
- };
- ColumnLayoutData[] columns = new ColumnLayoutData[] {
- new ColumnWeightData(70, 30),
- new ColumnWeightData(40, 30),
- new ColumnWeightData(30, 25),
- new ColumnWeightData(30, 25),
- };
- setTableColumns(new ListDialogField.ColumnsDescription(columns, headers, true));
- }
-
- @Override
+ IMethodStub stub = null;
+ if (element instanceof IMethodStub) {
+ stub = (IMethodStub) element;
+ } else if (element instanceof Item) {
+ Object data = ((Item) element).getData();
+ if (data instanceof IMethodStub)
+ stub = (IMethodStub) data;
+ }
+ if (stub != null) {
+ if (property.equals(CP_ACCESS) && value instanceof Integer) {
+ Integer access = (Integer) value;
+ if (access.equals(INDEX_PRIVATE)) {
+ stub.setAccess(ASTAccessVisibility.PRIVATE);
+ } else if (access.equals(INDEX_PROTECTED)) {
+ stub.setAccess(ASTAccessVisibility.PROTECTED);
+ } else {
+ stub.setAccess(ASTAccessVisibility.PUBLIC);
+ }
+ refresh();
+ } else if (property.equals(CP_VIRTUAL) && value instanceof Integer) {
+ Integer yesno = (Integer) value;
+ stub.setVirtual(yesno.equals(INDEX_YES));
+ refresh();
+ } else if (property.equals(CP_INLINE) && value instanceof Integer) {
+ Integer yesno = (Integer) value;
+ stub.setInline(yesno.equals(INDEX_YES));
+ refresh();
+ }
+ }
+ }
+ }
+
+ public MethodStubsListDialogField(String title, IListAdapter<IMethodStub> listAdapter) {
+ super(listAdapter, null, new MethodStubsLabelProvider());
+ setLabelText(title);
+
+ String[] headers = new String[] { NewClassWizardMessages.MethodStubsDialogField_headings_name,
+ NewClassWizardMessages.MethodStubsDialogField_headings_access,
+ NewClassWizardMessages.MethodStubsDialogField_headings_virtual,
+ NewClassWizardMessages.MethodStubsDialogField_headings_inline };
+ ColumnLayoutData[] columns = new ColumnLayoutData[] { new ColumnWeightData(70, 30),
+ new ColumnWeightData(40, 30), new ColumnWeightData(30, 25), new ColumnWeightData(30, 25), };
+ setTableColumns(new ListDialogField.ColumnsDescription(columns, headers, true));
+ }
+
+ @Override
protected boolean managedButtonPressed(int index) {
- super.managedButtonPressed(index);
- return false;
- }
-
- @Override
+ super.managedButtonPressed(index);
+ return false;
+ }
+
+ @Override
protected TableViewer createTableViewer(Composite parent) {
- TableViewer viewer = super.createTableViewer(parent);
- Table table = viewer.getTable();
- table.getAccessible().addAccessibleListener(
- new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result = NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label;
- }
- }
- );
-
- CellEditor virtualCellEditor = new ComboBoxCellEditor(table,
- new String[] {
- /* INDEX_YES */BaseClassesLabelProvider.getYesNoText(true),
- /* INDEX_NO */BaseClassesLabelProvider.getYesNoText(false)
- }, SWT.READ_ONLY);
-
- CellEditor accessCellEditor = new ComboBoxCellEditor(table,
- new String[] {
- /* INDEX_PUBLIC */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PUBLIC),
- /* INDEX_PROTECTED */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PROTECTED),
- /* INDEX_PRIVATE */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PRIVATE)
- }, SWT.READ_ONLY);
-
- viewer.setCellEditors(new CellEditor[] {
- null,
- accessCellEditor,
- virtualCellEditor,
- virtualCellEditor
+ TableViewer viewer = super.createTableViewer(parent);
+ Table table = viewer.getTable();
+ table.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ e.result = NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label;
+ }
});
- viewer.setColumnProperties(new String[] {
- CP_NAME,
- CP_ACCESS,
- CP_VIRTUAL,
- CP_INLINE
- });
- viewer.setCellModifier(new CellHandler());
- return viewer;
- }
-
- public void addMethodStub(IMethodStub methodStub, boolean checked) {
+
+ CellEditor virtualCellEditor = new ComboBoxCellEditor(table,
+ new String[] { /* INDEX_YES */BaseClassesLabelProvider.getYesNoText(true),
+ /* INDEX_NO */BaseClassesLabelProvider.getYesNoText(false) },
+ SWT.READ_ONLY);
+
+ CellEditor accessCellEditor = new ComboBoxCellEditor(table,
+ new String[] { /* INDEX_PUBLIC */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PUBLIC),
+ /* INDEX_PROTECTED */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PROTECTED),
+ /* INDEX_PRIVATE */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PRIVATE) },
+ SWT.READ_ONLY);
+
+ viewer.setCellEditors(new CellEditor[] { null, accessCellEditor, virtualCellEditor, virtualCellEditor });
+ viewer.setColumnProperties(new String[] { CP_NAME, CP_ACCESS, CP_VIRTUAL, CP_INLINE });
+ viewer.setCellModifier(new CellHandler());
+ return viewer;
+ }
+
+ public void addMethodStub(IMethodStub methodStub, boolean checked) {
addElement(methodStub);
setChecked(methodStub, checked);
- }
+ }
- public IMethodStub[] getMethodStubs() {
- List<IMethodStub> allStubs = getElements();
- return allStubs.toArray(new IMethodStub[allStubs.size()]);
- }
+ public IMethodStub[] getMethodStubs() {
+ List<IMethodStub> allStubs = getElements();
+ return allStubs.toArray(new IMethodStub[allStubs.size()]);
+ }
- public IMethodStub[] getCheckedMethodStubs() {
- List<IMethodStub> checkedStubs = getCheckedElements();
- return checkedStubs.toArray(new IMethodStub[checkedStubs.size()]);
- }
+ public IMethodStub[] getCheckedMethodStubs() {
+ List<IMethodStub> checkedStubs = getCheckedElements();
+ return checkedStubs.toArray(new IMethodStub[checkedStubs.size()]);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java
index c9917ccd256..8116d24ea0d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java
@@ -18,15 +18,15 @@ import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
import org.eclipse.swt.widgets.Shell;
public class NamespaceSelectionDialog extends TypeSelectionDialog {
- private static final String DIALOG_SETTINGS = NamespaceSelectionDialog.class.getName();
- private static final int[] VISIBLE_TYPES = { ICElement.C_NAMESPACE };
-
- public NamespaceSelectionDialog(Shell parent) {
- super(parent);
- setTitle(NewClassWizardMessages.NamespaceSelectionDialog_title);
- setMessage(NewClassWizardMessages.NamespaceSelectionDialog_message);
- setDialogSettings(DIALOG_SETTINGS);
- setVisibleTypes(VISIBLE_TYPES);
- setFilter("*", true); //$NON-NLS-1$
- }
+ private static final String DIALOG_SETTINGS = NamespaceSelectionDialog.class.getName();
+ private static final int[] VISIBLE_TYPES = { ICElement.C_NAMESPACE };
+
+ public NamespaceSelectionDialog(Shell parent) {
+ super(parent);
+ setTitle(NewClassWizardMessages.NamespaceSelectionDialog_title);
+ setMessage(NewClassWizardMessages.NamespaceSelectionDialog_message);
+ setDialogSettings(DIALOG_SETTINGS);
+ setVisibleTypes(VISIBLE_TYPES);
+ setFilter("*", true); //$NON-NLS-1$
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
index 8bea335226a..52dca8ae5db 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
@@ -32,55 +32,55 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
public class NewBaseClassSelectionDialog extends ElementSelectionDialog {
- private static final String DIALOG_SETTINGS = NewBaseClassSelectionDialog.class.getName();
- private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
- private static final int ADD_ID = IDialogConstants.CLIENT_ID + 1;
+ private static final String DIALOG_SETTINGS = NewBaseClassSelectionDialog.class.getName();
+ private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
+ private static final int ADD_ID = IDialogConstants.CLIENT_ID + 1;
private List<ITypeInfo> fTypeList;
private List<ITypeSelectionListener> fTypeListeners;
public interface ITypeSelectionListener {
- void typeAdded(ITypeInfo baseClass);
+ void typeAdded(ITypeInfo baseClass);
}
- public NewBaseClassSelectionDialog(Shell parent) {
- super(parent);
- setTitle(NewClassWizardMessages.NewBaseClassSelectionDialog_title);
- setMessage(NewClassWizardMessages.NewBaseClassSelectionDialog_message);
- setDialogSettings(DIALOG_SETTINGS);
- setVisibleTypes(VISIBLE_TYPES);
+ public NewBaseClassSelectionDialog(Shell parent) {
+ super(parent);
+ setTitle(NewClassWizardMessages.NewBaseClassSelectionDialog_title);
+ setMessage(NewClassWizardMessages.NewBaseClassSelectionDialog_message);
+ setDialogSettings(DIALOG_SETTINGS);
+ setVisibleTypes(VISIBLE_TYPES);
setStatusLineAboveButtons(true);
fTypeList = new ArrayList<ITypeInfo>();
fTypeListeners = new ArrayList<ITypeSelectionListener>();
- }
-
- public void addListener(ITypeSelectionListener listener) {
- if (!fTypeListeners.contains(listener))
- fTypeListeners.add(listener);
- }
-
- public void removeListener(ITypeSelectionListener listener) {
- fTypeListeners.remove(listener);
- }
-
- private void notifyTypeAddedListeners(ITypeInfo type) {
- // first copy listeners in case one calls removeListener
- List<ITypeSelectionListener> list = new ArrayList<ITypeSelectionListener>(fTypeListeners);
- for (Iterator<ITypeSelectionListener> i = list.iterator(); i.hasNext(); ) {
- ITypeSelectionListener listener = i.next();
- listener.typeAdded(type);
- }
- }
-
- public ITypeInfo[] getAddedTypes() {
- return fTypeList.toArray(new ITypeInfo[fTypeList.size()]);
- }
-
- /*
+ }
+
+ public void addListener(ITypeSelectionListener listener) {
+ if (!fTypeListeners.contains(listener))
+ fTypeListeners.add(listener);
+ }
+
+ public void removeListener(ITypeSelectionListener listener) {
+ fTypeListeners.remove(listener);
+ }
+
+ private void notifyTypeAddedListeners(ITypeInfo type) {
+ // first copy listeners in case one calls removeListener
+ List<ITypeSelectionListener> list = new ArrayList<ITypeSelectionListener>(fTypeListeners);
+ for (Iterator<ITypeSelectionListener> i = list.iterator(); i.hasNext();) {
+ ITypeSelectionListener listener = i.next();
+ listener.typeAdded(type);
+ }
+ }
+
+ public ITypeInfo[] getAddedTypes() {
+ return fTypeList.toArray(new ITypeInfo[fTypeList.size()]);
+ }
+
+ /*
* @see Dialog#createButtonsForButtonBar
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, ADD_ID, NewClassWizardMessages.NewBaseClassSelectionDialog_addButton_label, true);
+ createButton(parent, ADD_ID, NewClassWizardMessages.NewBaseClassSelectionDialog_addButton_label, true);
super.createButtonsForButtonBar(parent);
}
@@ -89,10 +89,10 @@ public class NewBaseClassSelectionDialog extends ElementSelectionDialog {
*/
@Override
protected void buttonPressed(int buttonId) {
- if (buttonId == ADD_ID){
+ if (buttonId == ADD_ID) {
addType(getLowerSelectedElement());
}
- super.buttonPressed(buttonId);
+ super.buttonPressed(buttonId);
}
/*
@@ -100,76 +100,80 @@ public class NewBaseClassSelectionDialog extends ElementSelectionDialog {
*/
@Override
protected void okPressed() {
- addType(getLowerSelectedElement());
+ addType(getLowerSelectedElement());
super.okPressed();
}
private void addType(Object elem) {
if (elem instanceof ITypeInfo) {
- ITypeInfo type = (ITypeInfo)elem;
- if (fTypeList.contains(type)) {
- String qualifiedName = type.getQualifiedTypeName().getFullyQualifiedName();
- String message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classalreadyadded_info, qualifiedName);
- updateStatus(new StatusInfo(IStatus.INFO, message));
- } else {
+ ITypeInfo type = (ITypeInfo) elem;
+ if (fTypeList.contains(type)) {
+ String qualifiedName = type.getQualifiedTypeName().getFullyQualifiedName();
+ String message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classalreadyadded_info,
+ qualifiedName);
+ updateStatus(new StatusInfo(IStatus.INFO, message));
+ } else {
String qualifiedName = type.getQualifiedTypeName().getFullyQualifiedName();
- String message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_addingclass_info, qualifiedName);
+ String message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_addingclass_info,
+ qualifiedName);
updateStatus(new StatusInfo(IStatus.INFO, message));
- boolean canAdd = true;
- if (verifyBaseClasses()) {
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- NewClassWizardUtil.resolveClassLocation(type, service);
- canAdd = (type.getResolvedReference() != null);
- }
-
-// // Resolve location of base class
-// if (type.getResolvedReference() == null) {
-// final ITypeInfo[] typesToResolve = new ITypeInfo[] { type };
-// IRunnableWithProgress runnable = new IRunnableWithProgress() {
-// public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
-// AllTypesCache.resolveTypeLocation(typesToResolve[0], progressMonitor);
-// if (progressMonitor.isCanceled()) {
-// throw new InterruptedException();
-// }
-// }
-// };
-//
-// IProgressService service = PlatformUI.getWorkbench().getProgressService();
-// try {
-// service.busyCursorWhile(runnable);
-// } catch (InvocationTargetException e) {
-// String title= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.title"); //$NON-NLS-1$
-// String errorMessage= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.message"); //$NON-NLS-1$
-// ExceptionHandler.handle(e, title, errorMessage);
-// } catch (InterruptedException e) {
-// // Cancelled by user
-// }
-// }
-
- if (canAdd) {
+ boolean canAdd = true;
+ if (verifyBaseClasses()) {
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ NewClassWizardUtil.resolveClassLocation(type, service);
+ canAdd = (type.getResolvedReference() != null);
+ }
+
+ // // Resolve location of base class
+ // if (type.getResolvedReference() == null) {
+ // final ITypeInfo[] typesToResolve = new ITypeInfo[] { type };
+ // IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ // public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
+ // AllTypesCache.resolveTypeLocation(typesToResolve[0], progressMonitor);
+ // if (progressMonitor.isCanceled()) {
+ // throw new InterruptedException();
+ // }
+ // }
+ // };
+ //
+ // IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ // try {
+ // service.busyCursorWhile(runnable);
+ // } catch (InvocationTargetException e) {
+ // String title= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.title"); //$NON-NLS-1$
+ // String errorMessage= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.message"); //$NON-NLS-1$
+ // ExceptionHandler.handle(e, title, errorMessage);
+ // } catch (InterruptedException e) {
+ // // Cancelled by user
+ // }
+ // }
+
+ if (canAdd) {
fTypeList.add(type);
- message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classadded_info, qualifiedName);
+ message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classadded_info,
+ qualifiedName);
updateStatus(new StatusInfo(IStatus.INFO, message));
notifyTypeAddedListeners(type);
} else {
- message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_error_classnotadded, qualifiedName);
+ message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_error_classnotadded,
+ qualifiedName);
updateStatus(new StatusInfo(IStatus.ERROR, message));
}
- }
+ }
}
}
- /**
- * Checks if the base classes need to be verified (i.e. they must exist in the project)
- *
- * @return <code>true</code> if the base classes should be verified
- */
- public boolean verifyBaseClasses() {
- return NewClassWizardPrefs.verifyBaseClasses();
- }
+ /**
+ * Checks if the base classes need to be verified (i.e. they must exist in the project)
+ *
+ * @return <code>true</code> if the base classes should be verified
+ */
+ public boolean verifyBaseClasses() {
+ return NewClassWizardPrefs.verifyBaseClasses();
+ }
/*
* @see AbstractElementListSelectionDialog#handleDefaultSelected()
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
index 1485ff488d9..ecd89848afb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
@@ -81,20 +81,20 @@ import org.eclipse.cdt.internal.ui.refactoring.includes.IncludePreferences;
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
public class NewClassCodeGenerator {
- private final IPath fHeaderPath;
- private final IPath fSourcePath;
- private final IPath fTestPath;
- private String fClassName;
- private IQualifiedTypeName fNamespace;
- private final IBaseClassInfo[] fBaseClasses;
- private final IMethodStub[] fMethodStubs;
- private ITranslationUnit fCreatedHeaderTU;
- private ITranslationUnit fCreatedSourceTU;
- private ITranslationUnit fCreatedTestTU;
- private ICElement fCreatedClass;
+ private final IPath fHeaderPath;
+ private final IPath fSourcePath;
+ private final IPath fTestPath;
+ private String fClassName;
+ private IQualifiedTypeName fNamespace;
+ private final IBaseClassInfo[] fBaseClasses;
+ private final IMethodStub[] fMethodStubs;
+ private ITranslationUnit fCreatedHeaderTU;
+ private ITranslationUnit fCreatedSourceTU;
+ private ITranslationUnit fCreatedTestTU;
+ private ICElement fCreatedClass;
private String fFullyQualifiedClassName;
private boolean fForceSourceFileCreation;
-
+
/**
* When set to <code>true</code>, the source file is created, even if no stubs have
* been selected.
@@ -104,18 +104,18 @@ public class NewClassCodeGenerator {
}
public static class CodeGeneratorException extends CoreException {
- /**
+ /**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = 1L;
-
- public CodeGeneratorException(String message) {
- super(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, message, null));
- }
-
- public CodeGeneratorException(Throwable e) {
- super(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, e.getMessage(), e));
- }
+
+ public CodeGeneratorException(String message) {
+ super(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, message, null));
+ }
+
+ public CodeGeneratorException(Throwable e) {
+ super(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, e.getMessage(), e));
+ }
}
/**
@@ -127,190 +127,187 @@ public class NewClassCodeGenerator {
* @param baseClasses the base classes
* @param methodStubs the method stubs
*/
- public NewClassCodeGenerator(IPath headerPath, IPath sourcePath, IPath testPath,
- String className, String namespace, IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs) {
- fHeaderPath = headerPath;
- fSourcePath = sourcePath;
- fTestPath = testPath;
- if (className != null && className.length() > 0) {
- fClassName = className;
- }
- if (namespace != null && namespace.length() > 0) {
- fNamespace = new QualifiedTypeName(namespace);
- }
- if (fNamespace != null) {
- fFullyQualifiedClassName= fNamespace.append(fClassName).getFullyQualifiedName();
- } else {
- fFullyQualifiedClassName= fClassName;
- }
- fBaseClasses = baseClasses;
- fMethodStubs = methodStubs;
- }
-
- public ICElement getCreatedClass() {
- return fCreatedClass;
- }
-
- public ITranslationUnit getCreatedHeaderTU() {
- return fCreatedHeaderTU;
- }
-
- public IFile getCreatedHeaderFile() {
- if (fCreatedHeaderTU != null) {
- return (IFile) fCreatedHeaderTU.getResource();
- }
- return null;
- }
-
- public ITranslationUnit getCreatedSourceTU() {
- return fCreatedSourceTU;
- }
-
- public IFile getCreatedSourceFile() {
- if (fCreatedSourceTU != null) {
- return (IFile) fCreatedSourceTU.getResource();
- }
- return null;
- }
-
- public IFile getCreatedTestFile() {
- if (fCreatedTestTU != null) {
- return (IFile) fCreatedTestTU.getResource();
- }
- return null;
- }
-
- /**
- * Creates the new class.
- *
- * @param monitor a progress monitor to report progress
- * @throws CoreException if the creation failed
- */
- public ICElement createClass(IProgressMonitor monitor) throws CoreException {
- SubMonitor progress = SubMonitor.convert(monitor,
- NewClassWizardMessages.NewClassCodeGeneration_createType_mainTask,
- (fHeaderPath != null ? 3 : 0) + (fSourcePath != null ? 3 : 0)+ (fTestPath != null ? 3 : 0));
-
- ITranslationUnit headerTU = null;
- ITranslationUnit sourceTU = null;
- ITranslationUnit testTU = null;
- ICElement createdClass = null;
-
- IWorkingCopy headerWorkingCopy = null;
- IWorkingCopy sourceWorkingCopy = null;
- IWorkingCopy testWorkingCopy = null;
- try {
- if (fHeaderPath != null) {
- // Get method stubs.
- List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, false);
- List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, false);
- List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, false);
-
- IFile headerFile =
- NewSourceFileGenerator.createHeaderFile(fHeaderPath, true, progress.split(1));
- if (headerFile != null) {
- headerTU = (ITranslationUnit) CoreModel.getDefault().create(headerFile);
- if (headerTU == null) {
- throw new CodeGeneratorException("Failed to create " + headerFile); //$NON-NLS-1$
- }
-
- // Create a working copy with a new owner.
- headerWorkingCopy = headerTU.getWorkingCopy();
-
- String headerContent = constructHeaderFileContent(headerTU, publicMethods,
- protectedMethods, privateMethods, headerWorkingCopy.getBuffer().getContents(),
- progress.split(1));
- if (headerContent != null) {
- headerContent= formatSource(headerContent, headerTU);
- } else {
- headerContent = ""; //$NON-NLS-1$
- }
- headerWorkingCopy.getBuffer().setContents(headerContent);
-
- headerWorkingCopy.reconcile();
- headerWorkingCopy.commit(true, progress.split(1));
-
- createdClass = headerWorkingCopy.getElement(fFullyQualifiedClassName);
- }
- fCreatedClass = createdClass;
- fCreatedHeaderTU = headerTU;
- }
-
- if (fSourcePath != null) {
- // Get method stubs.
- List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, true);
- List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, true);
- List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, true);
-
- if (fForceSourceFileCreation || !publicMethods.isEmpty() ||
- !protectedMethods.isEmpty() || !privateMethods.isEmpty()) {
- IFile sourceFile =
- NewSourceFileGenerator.createSourceFile(fSourcePath, true, progress.split(1));
- if (sourceFile != null) {
- sourceTU = (ITranslationUnit) CoreModel.getDefault().create(sourceFile);
- if (sourceTU == null) {
- throw new CodeGeneratorException("Failed to create " + sourceFile); //$NON-NLS-1$
- }
-
- // Create a working copy with a new owner.
- sourceWorkingCopy = sourceTU.getWorkingCopy();
-
- String sourceContent = constructSourceFileContent(sourceTU, headerTU,
- publicMethods, protectedMethods, privateMethods,
- sourceWorkingCopy.getBuffer().getContents(), progress.split(1));
- if (sourceContent != null) {
- sourceContent = formatSource(sourceContent, sourceTU);
- } else {
- sourceContent = ""; //$NON-NLS-1$
- }
- sourceWorkingCopy.getBuffer().setContents(sourceContent);
-
- sourceWorkingCopy.reconcile();
- sourceWorkingCopy.commit(true, progress.split(1));
- }
-
- fCreatedSourceTU = sourceTU;
- }
- }
-
- if (fTestPath != null) {
- IFile testFile = NewSourceFileGenerator.createTestFile(fTestPath, true, progress.split(1));
- if (testFile != null) {
- testTU = (ITranslationUnit) CoreModel.getDefault().create(testFile);
- if (testTU == null) {
- throw new CodeGeneratorException("Failed to create " + testFile); //$NON-NLS-1$
- }
-
- // Create a working copy with a new owner
- testWorkingCopy = testTU.getWorkingCopy();
-
- String testContent = constructTestFileContent(testTU, headerTU,
- testWorkingCopy.getBuffer().getContents(), progress.split(1));
- testContent= formatSource(testContent, testTU);
- testWorkingCopy.getBuffer().setContents(testContent);
-
- testWorkingCopy.reconcile();
- testWorkingCopy.commit(true, progress.split(1));
- }
-
- fCreatedTestTU = testTU;
- }
- } catch (CodeGeneratorException e) {
- deleteAllCreatedFiles();
- } finally {
- if (headerWorkingCopy != null) {
- headerWorkingCopy.destroy();
- }
- if (sourceWorkingCopy != null) {
- sourceWorkingCopy.destroy();
- }
- if (testWorkingCopy != null) {
- testWorkingCopy.destroy();
- }
- }
-
- return fCreatedClass;
- }
+ public NewClassCodeGenerator(IPath headerPath, IPath sourcePath, IPath testPath, String className, String namespace,
+ IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs) {
+ fHeaderPath = headerPath;
+ fSourcePath = sourcePath;
+ fTestPath = testPath;
+ if (className != null && className.length() > 0) {
+ fClassName = className;
+ }
+ if (namespace != null && namespace.length() > 0) {
+ fNamespace = new QualifiedTypeName(namespace);
+ }
+ if (fNamespace != null) {
+ fFullyQualifiedClassName = fNamespace.append(fClassName).getFullyQualifiedName();
+ } else {
+ fFullyQualifiedClassName = fClassName;
+ }
+ fBaseClasses = baseClasses;
+ fMethodStubs = methodStubs;
+ }
+
+ public ICElement getCreatedClass() {
+ return fCreatedClass;
+ }
+
+ public ITranslationUnit getCreatedHeaderTU() {
+ return fCreatedHeaderTU;
+ }
+
+ public IFile getCreatedHeaderFile() {
+ if (fCreatedHeaderTU != null) {
+ return (IFile) fCreatedHeaderTU.getResource();
+ }
+ return null;
+ }
+
+ public ITranslationUnit getCreatedSourceTU() {
+ return fCreatedSourceTU;
+ }
+
+ public IFile getCreatedSourceFile() {
+ if (fCreatedSourceTU != null) {
+ return (IFile) fCreatedSourceTU.getResource();
+ }
+ return null;
+ }
+
+ public IFile getCreatedTestFile() {
+ if (fCreatedTestTU != null) {
+ return (IFile) fCreatedTestTU.getResource();
+ }
+ return null;
+ }
+
+ /**
+ * Creates the new class.
+ *
+ * @param monitor a progress monitor to report progress
+ * @throws CoreException if the creation failed
+ */
+ public ICElement createClass(IProgressMonitor monitor) throws CoreException {
+ SubMonitor progress = SubMonitor.convert(monitor,
+ NewClassWizardMessages.NewClassCodeGeneration_createType_mainTask,
+ (fHeaderPath != null ? 3 : 0) + (fSourcePath != null ? 3 : 0) + (fTestPath != null ? 3 : 0));
+
+ ITranslationUnit headerTU = null;
+ ITranslationUnit sourceTU = null;
+ ITranslationUnit testTU = null;
+ ICElement createdClass = null;
+
+ IWorkingCopy headerWorkingCopy = null;
+ IWorkingCopy sourceWorkingCopy = null;
+ IWorkingCopy testWorkingCopy = null;
+ try {
+ if (fHeaderPath != null) {
+ // Get method stubs.
+ List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, false);
+ List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, false);
+ List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, false);
+
+ IFile headerFile = NewSourceFileGenerator.createHeaderFile(fHeaderPath, true, progress.split(1));
+ if (headerFile != null) {
+ headerTU = (ITranslationUnit) CoreModel.getDefault().create(headerFile);
+ if (headerTU == null) {
+ throw new CodeGeneratorException("Failed to create " + headerFile); //$NON-NLS-1$
+ }
+
+ // Create a working copy with a new owner.
+ headerWorkingCopy = headerTU.getWorkingCopy();
+
+ String headerContent = constructHeaderFileContent(headerTU, publicMethods, protectedMethods,
+ privateMethods, headerWorkingCopy.getBuffer().getContents(), progress.split(1));
+ if (headerContent != null) {
+ headerContent = formatSource(headerContent, headerTU);
+ } else {
+ headerContent = ""; //$NON-NLS-1$
+ }
+ headerWorkingCopy.getBuffer().setContents(headerContent);
+
+ headerWorkingCopy.reconcile();
+ headerWorkingCopy.commit(true, progress.split(1));
+
+ createdClass = headerWorkingCopy.getElement(fFullyQualifiedClassName);
+ }
+ fCreatedClass = createdClass;
+ fCreatedHeaderTU = headerTU;
+ }
+
+ if (fSourcePath != null) {
+ // Get method stubs.
+ List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, true);
+ List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, true);
+ List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, true);
+
+ if (fForceSourceFileCreation || !publicMethods.isEmpty() || !protectedMethods.isEmpty()
+ || !privateMethods.isEmpty()) {
+ IFile sourceFile = NewSourceFileGenerator.createSourceFile(fSourcePath, true, progress.split(1));
+ if (sourceFile != null) {
+ sourceTU = (ITranslationUnit) CoreModel.getDefault().create(sourceFile);
+ if (sourceTU == null) {
+ throw new CodeGeneratorException("Failed to create " + sourceFile); //$NON-NLS-1$
+ }
+
+ // Create a working copy with a new owner.
+ sourceWorkingCopy = sourceTU.getWorkingCopy();
+
+ String sourceContent = constructSourceFileContent(sourceTU, headerTU, publicMethods,
+ protectedMethods, privateMethods, sourceWorkingCopy.getBuffer().getContents(),
+ progress.split(1));
+ if (sourceContent != null) {
+ sourceContent = formatSource(sourceContent, sourceTU);
+ } else {
+ sourceContent = ""; //$NON-NLS-1$
+ }
+ sourceWorkingCopy.getBuffer().setContents(sourceContent);
+
+ sourceWorkingCopy.reconcile();
+ sourceWorkingCopy.commit(true, progress.split(1));
+ }
+
+ fCreatedSourceTU = sourceTU;
+ }
+ }
+
+ if (fTestPath != null) {
+ IFile testFile = NewSourceFileGenerator.createTestFile(fTestPath, true, progress.split(1));
+ if (testFile != null) {
+ testTU = (ITranslationUnit) CoreModel.getDefault().create(testFile);
+ if (testTU == null) {
+ throw new CodeGeneratorException("Failed to create " + testFile); //$NON-NLS-1$
+ }
+
+ // Create a working copy with a new owner
+ testWorkingCopy = testTU.getWorkingCopy();
+
+ String testContent = constructTestFileContent(testTU, headerTU,
+ testWorkingCopy.getBuffer().getContents(), progress.split(1));
+ testContent = formatSource(testContent, testTU);
+ testWorkingCopy.getBuffer().setContents(testContent);
+
+ testWorkingCopy.reconcile();
+ testWorkingCopy.commit(true, progress.split(1));
+ }
+
+ fCreatedTestTU = testTU;
+ }
+ } catch (CodeGeneratorException e) {
+ deleteAllCreatedFiles();
+ } finally {
+ if (headerWorkingCopy != null) {
+ headerWorkingCopy.destroy();
+ }
+ if (sourceWorkingCopy != null) {
+ sourceWorkingCopy.destroy();
+ }
+ if (testWorkingCopy != null) {
+ testWorkingCopy.destroy();
+ }
+ }
+
+ return fCreatedClass;
+ }
private void deleteAllCreatedFiles() {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@@ -325,132 +322,126 @@ public class NewClassCodeGenerator {
}
}
- /**
- * Format given source content according to the project's code style options.
- *
+ /**
+ * Format given source content according to the project's code style options.
+ *
* @param content the source content
* @param tu the translation unit
* @return the formatted source text or the original if the text could not be formatted successfully
- * @throws CModelException
+ * @throws CModelException
*/
private String formatSource(String content, ITranslationUnit tu) throws CModelException {
- String lineDelimiter= StubUtility.getLineDelimiterUsed(tu);
- Map<String, Object> options = new HashMap<String, Object>(tu.getCProject().getOptions(true));
- options.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu);
- TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_TRANSLATION_UNIT, content, 0,
- lineDelimiter, options);
- if (edit != null) {
- IDocument doc= new Document(content);
- try {
+ String lineDelimiter = StubUtility.getLineDelimiterUsed(tu);
+ Map<String, Object> options = new HashMap<String, Object>(tu.getCProject().getOptions(true));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu);
+ TextEdit edit = CodeFormatterUtil.format(CodeFormatter.K_TRANSLATION_UNIT, content, 0, lineDelimiter, options);
+ if (edit != null) {
+ IDocument doc = new Document(content);
+ try {
edit.apply(doc);
- content= doc.get();
+ content = doc.get();
} catch (MalformedTreeException e) {
CUIPlugin.log(e);
} catch (BadLocationException e) {
CUIPlugin.log(e);
}
- }
- return content;
+ }
+ return content;
}
public String constructHeaderFileContent(ITranslationUnit headerTU, List<IMethodStub> publicMethods,
List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String oldContents,
IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor,
- NewClassWizardMessages.NewClassCodeGeneration_createType_task_header, 1);
-
- String lineDelimiter= StubUtility.getLineDelimiterUsed(headerTU);
-
- String namespaceBegin = fNamespace == null ?
- null : constructNamespaceBegin(headerTU, lineDelimiter);
- String namespaceEnd = fNamespace == null ?
- null : constructNamespaceEnd(headerTU, lineDelimiter);
- String classDefinition = constructClassDefinition(headerTU, publicMethods, protectedMethods,
- privateMethods, lineDelimiter);
-
- String includes = null;
- if (fBaseClasses != null && fBaseClasses.length != 0) {
- includes = constructBaseClassIncludes(headerTU, lineDelimiter, progress.split(1));
- }
-
- if (oldContents != null) {
- if (oldContents.isEmpty()) {
- oldContents = null;
- } else if (!oldContents.endsWith(lineDelimiter)) {
- oldContents += lineDelimiter;
- }
- }
-
- String fileContent;
- if (oldContents != null) {
- int appendFirstCharPos = -1;
- StringBuilder text = new StringBuilder();
- int insertionPos = getClassDefInsertionPos(oldContents);
- if (insertionPos == -1) {
- text.append(oldContents);
- } else {
- // Skip over whitespace
- int prependLastCharPos = insertionPos - 1;
- while (prependLastCharPos >= 0 && Character.isWhitespace(oldContents.charAt(prependLastCharPos))) {
- --prependLastCharPos;
- }
- if (prependLastCharPos >= 0) {
- text.append(oldContents.substring(0, prependLastCharPos + 1));
- }
- appendFirstCharPos = prependLastCharPos + 1;
- }
- text.append(lineDelimiter);
-
- // Insert a blank line before class definition
- text.append(lineDelimiter);
- if (namespaceBegin != null) {
- text.append(namespaceBegin);
- text.append(lineDelimiter);
- text.append(lineDelimiter);
- }
- text.append(classDefinition);
- if (namespaceEnd != null) {
- if (!classDefinition.endsWith(lineDelimiter))
- text.append(lineDelimiter);
- text.append(lineDelimiter);
- text.append(namespaceEnd);
- }
- if (appendFirstCharPos != -1) {
- // Insert a blank line after class definition
- text.append(lineDelimiter);
-
- // Skip over any extra whitespace
- int len = oldContents.length();
- while (appendFirstCharPos < len &&
- Character.isWhitespace(oldContents.charAt(appendFirstCharPos))) {
- ++appendFirstCharPos;
- }
- if (appendFirstCharPos < len) {
- text.append(oldContents.substring(appendFirstCharPos));
- }
- }
- if (Strings.endsWith(text, lineDelimiter))
- text.append(lineDelimiter);
- fileContent= text.toString();
- } else {
- String namespaceName = fNamespace == null ?
- null : fNamespace.getFullyQualifiedName();
- String classComment = getClassComment(headerTU, lineDelimiter);
- fileContent= CodeGeneration.getHeaderFileContent(headerTU, includes, namespaceBegin,
- namespaceEnd, namespaceName, classComment, classDefinition, fClassName,
- lineDelimiter);
- }
- return fileContent;
- }
+ NewClassWizardMessages.NewClassCodeGeneration_createType_task_header, 1);
+
+ String lineDelimiter = StubUtility.getLineDelimiterUsed(headerTU);
+
+ String namespaceBegin = fNamespace == null ? null : constructNamespaceBegin(headerTU, lineDelimiter);
+ String namespaceEnd = fNamespace == null ? null : constructNamespaceEnd(headerTU, lineDelimiter);
+ String classDefinition = constructClassDefinition(headerTU, publicMethods, protectedMethods, privateMethods,
+ lineDelimiter);
+
+ String includes = null;
+ if (fBaseClasses != null && fBaseClasses.length != 0) {
+ includes = constructBaseClassIncludes(headerTU, lineDelimiter, progress.split(1));
+ }
+
+ if (oldContents != null) {
+ if (oldContents.isEmpty()) {
+ oldContents = null;
+ } else if (!oldContents.endsWith(lineDelimiter)) {
+ oldContents += lineDelimiter;
+ }
+ }
+
+ String fileContent;
+ if (oldContents != null) {
+ int appendFirstCharPos = -1;
+ StringBuilder text = new StringBuilder();
+ int insertionPos = getClassDefInsertionPos(oldContents);
+ if (insertionPos == -1) {
+ text.append(oldContents);
+ } else {
+ // Skip over whitespace
+ int prependLastCharPos = insertionPos - 1;
+ while (prependLastCharPos >= 0 && Character.isWhitespace(oldContents.charAt(prependLastCharPos))) {
+ --prependLastCharPos;
+ }
+ if (prependLastCharPos >= 0) {
+ text.append(oldContents.substring(0, prependLastCharPos + 1));
+ }
+ appendFirstCharPos = prependLastCharPos + 1;
+ }
+ text.append(lineDelimiter);
+
+ // Insert a blank line before class definition
+ text.append(lineDelimiter);
+ if (namespaceBegin != null) {
+ text.append(namespaceBegin);
+ text.append(lineDelimiter);
+ text.append(lineDelimiter);
+ }
+ text.append(classDefinition);
+ if (namespaceEnd != null) {
+ if (!classDefinition.endsWith(lineDelimiter))
+ text.append(lineDelimiter);
+ text.append(lineDelimiter);
+ text.append(namespaceEnd);
+ }
+ if (appendFirstCharPos != -1) {
+ // Insert a blank line after class definition
+ text.append(lineDelimiter);
+
+ // Skip over any extra whitespace
+ int len = oldContents.length();
+ while (appendFirstCharPos < len && Character.isWhitespace(oldContents.charAt(appendFirstCharPos))) {
+ ++appendFirstCharPos;
+ }
+ if (appendFirstCharPos < len) {
+ text.append(oldContents.substring(appendFirstCharPos));
+ }
+ }
+ if (Strings.endsWith(text, lineDelimiter))
+ text.append(lineDelimiter);
+ fileContent = text.toString();
+ } else {
+ String namespaceName = fNamespace == null ? null : fNamespace.getFullyQualifiedName();
+ String classComment = getClassComment(headerTU, lineDelimiter);
+ fileContent = CodeGeneration.getHeaderFileContent(headerTU, includes, namespaceBegin, namespaceEnd,
+ namespaceName, classComment, classDefinition, fClassName, lineDelimiter);
+ }
+ return fileContent;
+ }
public String constructNamespaceBegin(ITranslationUnit tu, String lineDelimiter) throws CoreException {
StringBuilder text = new StringBuilder();
for (int i = 0; i < fNamespace.segmentCount(); i++) {
- String namespaceName = fNamespace.segment(i);
- if (i > 0) {
- text.append(lineDelimiter);
- }
- text.append(CodeGeneration.getNamespaceBeginContent(tu, namespaceName, lineDelimiter));
+ String namespaceName = fNamespace.segment(i);
+ if (i > 0) {
+ text.append(lineDelimiter);
+ }
+ text.append(CodeGeneration.getNamespaceBeginContent(tu, namespaceName, lineDelimiter));
}
return text.toString();
}
@@ -458,43 +449,42 @@ public class NewClassCodeGenerator {
public String constructNamespaceEnd(ITranslationUnit tu, String lineDelimiter) throws CoreException {
StringBuilder text = new StringBuilder();
for (int i = fNamespace.segmentCount(); --i >= 0;) {
- String namespaceName = fNamespace.segment(i);
- text.append(CodeGeneration.getNamespaceEndContent(tu, namespaceName, lineDelimiter));
- if (i > 0) {
- text.append(lineDelimiter);
- }
+ String namespaceName = fNamespace.segment(i);
+ text.append(CodeGeneration.getNamespaceEndContent(tu, namespaceName, lineDelimiter));
+ if (i > 0) {
+ text.append(lineDelimiter);
+ }
}
return text.toString();
}
public String constructClassDefinition(ITranslationUnit tu, List<IMethodStub> publicMethods,
- List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods,
- String lineDelimiter) throws CoreException {
- StringBuilder code = new StringBuilder();
- String comment = getClassComment(tu, lineDelimiter);
- if (comment != null) {
- code.append(comment);
- code.append(lineDelimiter);
- }
- code.append("class "); //$NON-NLS-1$
- code.append(fClassName);
- code.append(constructBaseClassInheritance());
- code.append(" {"); //$NON-NLS-1$
- code.append(lineDelimiter);
- String body = constructMethodDeclarations(tu, publicMethods, protectedMethods,
- privateMethods, lineDelimiter);
- body = CodeGeneration.getClassBodyContent(tu, fClassName, body, lineDelimiter);
- if (body != null) {
- code.append(body);
- if (!body.endsWith(lineDelimiter)) {
- code.append(lineDelimiter);
- }
- }
- code.append("};"); //$NON-NLS-1$
- return removeRedundantVisibilityLabels(code.toString());
+ List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String lineDelimiter)
+ throws CoreException {
+ StringBuilder code = new StringBuilder();
+ String comment = getClassComment(tu, lineDelimiter);
+ if (comment != null) {
+ code.append(comment);
+ code.append(lineDelimiter);
+ }
+ code.append("class "); //$NON-NLS-1$
+ code.append(fClassName);
+ code.append(constructBaseClassInheritance());
+ code.append(" {"); //$NON-NLS-1$
+ code.append(lineDelimiter);
+ String body = constructMethodDeclarations(tu, publicMethods, protectedMethods, privateMethods, lineDelimiter);
+ body = CodeGeneration.getClassBodyContent(tu, fClassName, body, lineDelimiter);
+ if (body != null) {
+ code.append(body);
+ if (!body.endsWith(lineDelimiter)) {
+ code.append(lineDelimiter);
+ }
+ }
+ code.append("};"); //$NON-NLS-1$
+ return removeRedundantVisibilityLabels(code.toString());
}
- private String removeRedundantVisibilityLabels(String code) {
+ private String removeRedundantVisibilityLabels(String code) {
Scanner scanner = new Scanner();
scanner.setSource(code.toCharArray());
scanner.resetTo(0, code.length());
@@ -514,7 +504,8 @@ public class NewClassCodeGenerator {
if (previousTokenType == sectionType) {
IRegion region1 = doc.getLineInformationOfOffset(previousTokenOffset);
IRegion region2 = doc.getLineInformationOfOffset(token.offset);
- edit.addChild(new DeleteEdit(region1.getOffset(), region2.getOffset() + region2.getLength() - region1.getOffset()));
+ edit.addChild(new DeleteEdit(region1.getOffset(),
+ region2.getOffset() + region2.getLength() - region1.getOffset()));
}
sectionType = previousTokenType;
}
@@ -532,36 +523,35 @@ public class NewClassCodeGenerator {
}
private int getClassDefInsertionPos(String contents) {
- if (contents.length() == 0) {
- return -1;
- }
- //TODO temporary hack
- int insertPos = contents.lastIndexOf("#endif"); //$NON-NLS-1$
- if (insertPos != -1) {
- // check if any code follows the #endif
- if ((contents.indexOf('}', insertPos) != -1)
- || (contents.indexOf(';', insertPos) != -1)) {
- return -1;
- }
- }
- return insertPos;
- }
-
+ if (contents.length() == 0) {
+ return -1;
+ }
+ //TODO temporary hack
+ int insertPos = contents.lastIndexOf("#endif"); //$NON-NLS-1$
+ if (insertPos != -1) {
+ // check if any code follows the #endif
+ if ((contents.indexOf('}', insertPos) != -1) || (contents.indexOf(';', insertPos) != -1)) {
+ return -1;
+ }
+ }
+ return insertPos;
+ }
+
/**
* Retrieve the class comment. Returns the content of the 'type comment' template.
- *
+ *
* @param tu the translation unit
* @param lineDelimiter the line delimiter to use
- * @return the type comment or <code>null</code> if a type comment
+ * @return the type comment or <code>null</code> if a type comment
* is not desired
- *
- * @since 5.0
- */
+ *
+ * @since 5.0
+ */
private String getClassComment(ITranslationUnit tu, String lineDelimiter) {
if (isAddComments(tu)) {
try {
- String fqName= fFullyQualifiedClassName;
- String comment= CodeGeneration.getClassComment(tu, fqName, lineDelimiter);
+ String fqName = fFullyQualifiedClassName;
+ String comment = CodeGeneration.getClassComment(tu, fqName, lineDelimiter);
if (comment != null && isValidComment(comment)) {
return comment;
}
@@ -576,219 +566,220 @@ public class NewClassCodeGenerator {
// TODO verify comment
return true;
}
-
+
/**
* Returns if comments are added. The settings as specified in the preferences is used.
- *
+ *
* @param tu
* @return Returns <code>true</code> if comments can be added
* @since 5.0
*/
public boolean isAddComments(ITranslationUnit tu) {
- return StubUtility.doAddComments(tu.getCProject());
+ return StubUtility.doAddComments(tu.getCProject());
+ }
+
+ private String constructMethodDeclarations(ITranslationUnit tu, List<IMethodStub> publicMethods,
+ List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String lineDelimiter)
+ throws CoreException {
+ StringBuilder text = new StringBuilder();
+ if (!publicMethods.isEmpty()) {
+ text.append("public:"); //$NON-NLS-1$
+ text.append(lineDelimiter);
+ for (IMethodStub stub : publicMethods) {
+ String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
+ text.append('\t');
+ text.append(code);
+ text.append(lineDelimiter);
+ }
+ }
+
+ if (!protectedMethods.isEmpty()) {
+ if (text.length() > 0) {
+ text.append(lineDelimiter);
+ }
+ text.append("protected:"); //$NON-NLS-1$
+ text.append(lineDelimiter);
+ for (IMethodStub stub : protectedMethods) {
+ String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
+ text.append('\t');
+ text.append(code);
+ text.append(lineDelimiter);
+ }
+ }
+
+ if (!privateMethods.isEmpty()) {
+ if (text.length() > 0) {
+ text.append(lineDelimiter);
+ }
+ text.append("private:"); //$NON-NLS-1$
+ text.append(lineDelimiter);
+ for (IMethodStub stub : privateMethods) {
+ String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
+ text.append('\t');
+ text.append(code);
+ text.append(lineDelimiter);
+ }
+ }
+
+ return text.toString();
}
-
- private String constructMethodDeclarations(ITranslationUnit tu, List<IMethodStub> publicMethods,
- List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String lineDelimiter)
- throws CoreException {
- StringBuilder text = new StringBuilder();
- if (!publicMethods.isEmpty()) {
- text.append("public:"); //$NON-NLS-1$
- text.append(lineDelimiter);
- for (IMethodStub stub : publicMethods) {
- String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
- text.append('\t');
- text.append(code);
- text.append(lineDelimiter);
- }
- }
-
- if (!protectedMethods.isEmpty()) {
- if (text.length() > 0) {
- text.append(lineDelimiter);
- }
- text.append("protected:"); //$NON-NLS-1$
- text.append(lineDelimiter);
- for (IMethodStub stub : protectedMethods) {
- String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
- text.append('\t');
- text.append(code);
- text.append(lineDelimiter);
- }
- }
-
- if (!privateMethods.isEmpty()) {
- if (text.length() > 0) {
- text.append(lineDelimiter);
- }
- text.append("private:"); //$NON-NLS-1$
- text.append(lineDelimiter);
- for (IMethodStub stub : privateMethods) {
- String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
- text.append('\t');
- text.append(code);
- text.append(lineDelimiter);
- }
- }
-
- return text.toString();
- }
-
- private List<IMethodStub> getStubs(ASTAccessVisibility access, boolean skipInline) {
- List<IMethodStub> list = new ArrayList<IMethodStub>();
- if (fMethodStubs != null) {
- for (int i = 0; i < fMethodStubs.length; ++i) {
- IMethodStub stub = fMethodStubs[i];
- if (stub.getAccess() == access && (!skipInline || !stub.isInline())) {
- list.add(stub);
- }
- }
- }
- return list;
- }
-
- private String constructBaseClassInheritance() {
- if (fBaseClasses == null || fBaseClasses.length == 0) {
- return ""; //$NON-NLS-1$
- }
- StringBuilder text = new StringBuilder();
- text.append(" : "); //$NON-NLS-1$
- for (int i = 0; i < fBaseClasses.length; ++i) {
- IBaseClassInfo baseClass = fBaseClasses[i];
- IQualifiedTypeName qualifiedTypeName = baseClass.getType().getQualifiedTypeName();
-
- if (fNamespace != null)
- qualifiedTypeName = qualifiedTypeName.removeFirstSegments(qualifiedTypeName.matchingFirstSegments(fNamespace));
- String baseClassName = qualifiedTypeName.getFullyQualifiedName();
-
- if (i > 0)
- text.append(", "); //$NON-NLS-1$
- if (baseClass.getAccess() == ASTAccessVisibility.PRIVATE) {
- text.append("private"); //$NON-NLS-1$
- } else if (baseClass.getAccess() == ASTAccessVisibility.PROTECTED) {
- text.append("private"); //$NON-NLS-1$
- } else {
- text.append("public"); //$NON-NLS-1$
- }
- text.append(' ');
-
- if (baseClass.isVirtual())
- text.append("virtual "); //$NON-NLS-1$
-
- text.append(baseClassName);
- }
- return text.toString();
- }
-
- private String constructBaseClassIncludes(ITranslationUnit headerTU, String lineDelimiter,
- IProgressMonitor monitor) throws CodeGeneratorException {
- SubMonitor progress = SubMonitor.convert(monitor,
- NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_includePaths, 1);
-
- ICProject cProject = headerTU.getCProject();
- IProject project = cProject.getProject();
- IPath projectLocation = new Path(project.getLocationURI().getPath());
-
- List<IPath> includePaths = getIncludePaths(headerTU);
- List<IPath> baseClassPaths = getBaseClassPaths(verifyBaseClasses());
-
- // Add the missing include paths to the project
- if (createIncludePaths()) {
- List<IPath> newIncludePaths = getMissingIncludePaths(projectLocation, includePaths, baseClassPaths);
- if (!newIncludePaths.isEmpty()) {
- addIncludePaths(cProject, newIncludePaths, progress.split(1));
- }
- }
-
- InclusionContext inclusionContext = new InclusionContext(headerTU);
- List<StyledInclude> includes = new ArrayList<StyledInclude>();
- for (IPath baseClassLocation : baseClassPaths) {
- IncludeInfo includeInfo = inclusionContext.getIncludeForHeaderFile(baseClassLocation);
- if (includeInfo != null) {
- IncludeGroupStyle style = inclusionContext.getIncludeStyle(includeInfo);
- includes.add(new StyledInclude(baseClassLocation, includeInfo, style));
- }
- }
+
+ private List<IMethodStub> getStubs(ASTAccessVisibility access, boolean skipInline) {
+ List<IMethodStub> list = new ArrayList<IMethodStub>();
+ if (fMethodStubs != null) {
+ for (int i = 0; i < fMethodStubs.length; ++i) {
+ IMethodStub stub = fMethodStubs[i];
+ if (stub.getAccess() == access && (!skipInline || !stub.isInline())) {
+ list.add(stub);
+ }
+ }
+ }
+ return list;
+ }
+
+ private String constructBaseClassInheritance() {
+ if (fBaseClasses == null || fBaseClasses.length == 0) {
+ return ""; //$NON-NLS-1$
+ }
+ StringBuilder text = new StringBuilder();
+ text.append(" : "); //$NON-NLS-1$
+ for (int i = 0; i < fBaseClasses.length; ++i) {
+ IBaseClassInfo baseClass = fBaseClasses[i];
+ IQualifiedTypeName qualifiedTypeName = baseClass.getType().getQualifiedTypeName();
+
+ if (fNamespace != null)
+ qualifiedTypeName = qualifiedTypeName
+ .removeFirstSegments(qualifiedTypeName.matchingFirstSegments(fNamespace));
+ String baseClassName = qualifiedTypeName.getFullyQualifiedName();
+
+ if (i > 0)
+ text.append(", "); //$NON-NLS-1$
+ if (baseClass.getAccess() == ASTAccessVisibility.PRIVATE) {
+ text.append("private"); //$NON-NLS-1$
+ } else if (baseClass.getAccess() == ASTAccessVisibility.PROTECTED) {
+ text.append("private"); //$NON-NLS-1$
+ } else {
+ text.append("public"); //$NON-NLS-1$
+ }
+ text.append(' ');
+
+ if (baseClass.isVirtual())
+ text.append("virtual "); //$NON-NLS-1$
+
+ text.append(baseClassName);
+ }
+ return text.toString();
+ }
+
+ private String constructBaseClassIncludes(ITranslationUnit headerTU, String lineDelimiter, IProgressMonitor monitor)
+ throws CodeGeneratorException {
+ SubMonitor progress = SubMonitor.convert(monitor,
+ NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_includePaths, 1);
+
+ ICProject cProject = headerTU.getCProject();
+ IProject project = cProject.getProject();
+ IPath projectLocation = new Path(project.getLocationURI().getPath());
+
+ List<IPath> includePaths = getIncludePaths(headerTU);
+ List<IPath> baseClassPaths = getBaseClassPaths(verifyBaseClasses());
+
+ // Add the missing include paths to the project
+ if (createIncludePaths()) {
+ List<IPath> newIncludePaths = getMissingIncludePaths(projectLocation, includePaths, baseClassPaths);
+ if (!newIncludePaths.isEmpty()) {
+ addIncludePaths(cProject, newIncludePaths, progress.split(1));
+ }
+ }
+
+ InclusionContext inclusionContext = new InclusionContext(headerTU);
+ List<StyledInclude> includes = new ArrayList<StyledInclude>();
+ for (IPath baseClassLocation : baseClassPaths) {
+ IncludeInfo includeInfo = inclusionContext.getIncludeForHeaderFile(baseClassLocation);
+ if (includeInfo != null) {
+ IncludeGroupStyle style = inclusionContext.getIncludeStyle(includeInfo);
+ includes.add(new StyledInclude(baseClassLocation, includeInfo, style));
+ }
+ }
IncludePreferences preferences = inclusionContext.getPreferences();
- Collections.sort(includes, preferences);
+ Collections.sort(includes, preferences);
- StringBuilder text = new StringBuilder();
+ StringBuilder text = new StringBuilder();
IncludeGroupStyle previousStyle = null;
- for (StyledInclude include : includes) {
+ for (StyledInclude include : includes) {
IncludeGroupStyle style = include.getStyle();
if (style.isBlankLineNeededAfter(previousStyle, preferences.includeStyles))
text.append(lineDelimiter);
- text.append(include.getIncludeInfo().composeIncludeStatement());
- text.append(lineDelimiter);
- previousStyle = style;
+ text.append(include.getIncludeInfo().composeIncludeStatement());
+ text.append(lineDelimiter);
+ previousStyle = style;
}
- return text.toString();
- }
-
- /**
- * Checks if the base classes need to be verified (i.e. they must exist in the project)
- *
- * @return <code>true</code> if the base classes should be verified
- */
- private boolean verifyBaseClasses() {
- return NewClassWizardPrefs.verifyBaseClasses();
- }
-
- /**
- * Checks if include paths can be added to the project as needed.
- *
- * @return <code>true</code> if the include paths should be added
- */
- private boolean createIncludePaths() {
- return NewClassWizardPrefs.createIncludePaths();
- }
-
- private void addIncludePaths(ICProject cProject, List<IPath> newIncludePaths, IProgressMonitor monitor)
- throws CodeGeneratorException {
- SubMonitor progress = SubMonitor.convert(monitor,
- NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_addIncludePaths, 1);
-
- //TODO prefs option whether to add to project or parent source folder?
- IPath addToResourcePath = cProject.getPath();
- try {
- List<IPathEntry> pathEntryList = new ArrayList<IPathEntry>();
- List<IPathEntry> checkEntryList = new ArrayList<IPathEntry>();
-
- IPathEntry[] checkEntries = cProject.getResolvedPathEntries();
- IPathEntry[] pathEntries = cProject.getRawPathEntries();
- if (pathEntries != null) {
- for (int i = 0; i < pathEntries.length; ++i) {
- pathEntryList.add(pathEntries[i]);
- }
- }
- for (IPathEntry checkEntrie : checkEntries) {
- if (checkEntrie instanceof IIncludeEntry)
- checkEntryList.add(checkEntrie);
- }
-
- for (IPath folderToAdd : newIncludePaths) {
- // do not add any #includes that are local to the project
- if (cProject.getPath().segment(0).equals(folderToAdd.segment(0)))
- continue;
-
- ICProject includeProject = toCProject(PathUtil.getEnclosingProject(folderToAdd));
- if (includeProject != null) {
- // Make sure that the include is made the same way that build properties for
- // projects makes them, so .contains below is a valid check
- IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, null,
- new Path(includeProject.getProject().getLocationURI().getPath()), true);
-
- // If the path already exists in the #includes then don't add it.
- if (!checkEntryList.contains(entry))
- pathEntryList.add(entry);
- }
- }
- pathEntries = pathEntryList.toArray(new IPathEntry[pathEntryList.size()]);
- cProject.setRawPathEntries(pathEntries, progress.split(1));
- } catch (CModelException e) {
- throw new CodeGeneratorException(e);
- }
- }
+ return text.toString();
+ }
+
+ /**
+ * Checks if the base classes need to be verified (i.e. they must exist in the project)
+ *
+ * @return <code>true</code> if the base classes should be verified
+ */
+ private boolean verifyBaseClasses() {
+ return NewClassWizardPrefs.verifyBaseClasses();
+ }
+
+ /**
+ * Checks if include paths can be added to the project as needed.
+ *
+ * @return <code>true</code> if the include paths should be added
+ */
+ private boolean createIncludePaths() {
+ return NewClassWizardPrefs.createIncludePaths();
+ }
+
+ private void addIncludePaths(ICProject cProject, List<IPath> newIncludePaths, IProgressMonitor monitor)
+ throws CodeGeneratorException {
+ SubMonitor progress = SubMonitor.convert(monitor,
+ NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_addIncludePaths, 1);
+
+ //TODO prefs option whether to add to project or parent source folder?
+ IPath addToResourcePath = cProject.getPath();
+ try {
+ List<IPathEntry> pathEntryList = new ArrayList<IPathEntry>();
+ List<IPathEntry> checkEntryList = new ArrayList<IPathEntry>();
+
+ IPathEntry[] checkEntries = cProject.getResolvedPathEntries();
+ IPathEntry[] pathEntries = cProject.getRawPathEntries();
+ if (pathEntries != null) {
+ for (int i = 0; i < pathEntries.length; ++i) {
+ pathEntryList.add(pathEntries[i]);
+ }
+ }
+ for (IPathEntry checkEntrie : checkEntries) {
+ if (checkEntrie instanceof IIncludeEntry)
+ checkEntryList.add(checkEntrie);
+ }
+
+ for (IPath folderToAdd : newIncludePaths) {
+ // do not add any #includes that are local to the project
+ if (cProject.getPath().segment(0).equals(folderToAdd.segment(0)))
+ continue;
+
+ ICProject includeProject = toCProject(PathUtil.getEnclosingProject(folderToAdd));
+ if (includeProject != null) {
+ // Make sure that the include is made the same way that build properties for
+ // projects makes them, so .contains below is a valid check
+ IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, null,
+ new Path(includeProject.getProject().getLocationURI().getPath()), true);
+
+ // If the path already exists in the #includes then don't add it.
+ if (!checkEntryList.contains(entry))
+ pathEntryList.add(entry);
+ }
+ }
+ pathEntries = pathEntryList.toArray(new IPathEntry[pathEntryList.size()]);
+ cProject.setRawPathEntries(pathEntries, progress.split(1));
+ } catch (CModelException e) {
+ throw new CodeGeneratorException(e);
+ }
+ }
private ICProject toCProject(IProject enclosingProject) {
if (enclosingProject != null)
@@ -796,403 +787,397 @@ public class NewClassCodeGenerator {
return null;
}
- private List<IPath> getMissingIncludePaths(IPath projectLocation, List<IPath> includePaths, List<IPath> baseClassPaths) {
- // check for missing include paths
- List<IPath> newIncludePaths = new ArrayList<IPath>();
- for (IPath baseClassLocation : baseClassPaths) {
- // skip any paths inside the same project
- //TODO possibly a preferences option?
- if (projectLocation.isPrefixOf(baseClassLocation)) {
- continue;
- }
-
- IPath folderToAdd = baseClassLocation.removeLastSegments(1);
- IPath canonPath = PathUtil.getCanonicalPath(folderToAdd);
- if (canonPath != null)
- folderToAdd = canonPath;
-
- // see if folder or its parent hasn't already been added
- for (IPath newFolder : newIncludePaths) {
- if (newFolder.isPrefixOf(folderToAdd)) {
- folderToAdd = null;
- break;
- }
- }
-
- if (folderToAdd != null) {
- // search include paths
- boolean foundPath = false;
- for (IPath includePath : includePaths) {
- if (includePath.isPrefixOf(folderToAdd) || includePath.equals(folderToAdd)) {
- foundPath = true;
- break;
- }
- }
- if (!foundPath) {
- // remove any children of this folder
- for (Iterator<IPath> newIter = newIncludePaths.iterator(); newIter.hasNext(); ) {
- IPath newFolder = newIter.next();
- if (folderToAdd.isPrefixOf(newFolder)) {
- newIter.remove();
- }
- }
- if (!newIncludePaths.contains(folderToAdd)) {
- newIncludePaths.add(folderToAdd);
- }
- }
- }
- }
- return newIncludePaths;
- }
-
- private List<IPath> getIncludePaths(ITranslationUnit headerTU) throws CodeGeneratorException {
- IProject project = headerTU.getCProject().getProject();
- // get the parent source folder
- ICContainer sourceFolder = CModelUtil.getSourceFolder(headerTU);
- if (sourceFolder == null) {
- throw new CodeGeneratorException("Could not find source folder"); //$NON-NLS-1$
- }
-
- // get the include paths
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
- if (provider != null) {
- IScannerInfo info = provider.getScannerInformation(sourceFolder.getResource());
- if (info != null) {
- String[] includePaths = info.getIncludePaths();
- if (includePaths != null) {
- List<IPath> list = new ArrayList<IPath>();
- for (int i = 0; i < includePaths.length; ++i) {
- //TODO do we need to canonicalize these paths first?
- IPath path = new Path(includePaths[i]);
- if (!list.contains(path)) {
- list.add(path);
- }
- }
- return list;
- }
- }
- }
- return null;
- }
-
- private List<IPath> getBaseClassPaths(boolean verifyLocation) throws CodeGeneratorException {
- List<IPath> list = new ArrayList<IPath>();
- for (int i = 0; i < fBaseClasses.length; ++i) {
- IBaseClassInfo baseClass = fBaseClasses[i];
- ITypeReference ref = baseClass.getType().getResolvedReference();
- IPath baseClassLocation = null;
- if (ref != null) {
- baseClassLocation = ref.getLocation();
- }
-
- if (baseClassLocation == null) {
- if (verifyLocation) {
- throw new CodeGeneratorException("Could not find base class " + baseClass.toString()); //$NON-NLS-1$
- }
- } else if (!list.contains(baseClassLocation)) {
- list.add(baseClassLocation);
- }
- }
- return list;
- }
-
- public String constructSourceFileContent(ITranslationUnit sourceTU, ITranslationUnit headerTU,
- List<IMethodStub> publicMethods, List<IMethodStub> protectedMethods,
- List<IMethodStub> privateMethods, String oldContents, IProgressMonitor monitor) throws CoreException {
- SubMonitor progress = SubMonitor.convert(monitor,
- NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 2);
-
- String lineDelimiter= StubUtility.getLineDelimiterUsed(sourceTU);
- String includeString = null;
- if (headerTU != null) {
- includeString = getHeaderIncludeString(sourceTU, headerTU, progress.split(1));
- if (includeString != null) {
- // Check if file already has the include.
- if (oldContents != null && hasInclude(oldContents, includeString)) {
- // Don't bother to add it.
- includeString = null;
- }
- }
- }
-
- String methodBodies = null;
- if (!publicMethods.isEmpty() || !protectedMethods.isEmpty() || !privateMethods.isEmpty()) {
- // TODO sort methods (e.g. constructor always first?)
- methodBodies = constructMethodBodies(sourceTU, publicMethods, protectedMethods,
- privateMethods, lineDelimiter, progress.split(1));
- }
-
- String namespaceBegin = fNamespace == null ?
- null : constructNamespaceBegin(sourceTU, lineDelimiter);
- String namespaceEnd = fNamespace == null ?
- null : constructNamespaceEnd(sourceTU, lineDelimiter);
-
- if (oldContents != null) {
- if (oldContents.length() == 0) {
- oldContents = null;
- } else if (!oldContents.endsWith(lineDelimiter)) {
- oldContents += lineDelimiter;
- }
- }
-
- String fileContent;
- if (oldContents != null) {
- StringBuilder text = new StringBuilder();
-
- if (includeString != null) {
- int insertionPos = getIncludeInsertionPos(oldContents);
- if (insertionPos == -1) {
- text.append(oldContents);
- text.append(lineDelimiter);
- text.append(includeString);
- text.append(lineDelimiter);
- } else {
- text.append(oldContents.substring(0, insertionPos));
- text.append(includeString);
- text.append(lineDelimiter);
- text.append(oldContents.substring(insertionPos));
- }
- } else {
- text.append(oldContents);
- }
- // Add a blank line
- text.append(lineDelimiter);
-
- if (methodBodies != null) {
- if (namespaceBegin != null) {
- text.append(namespaceBegin);
- text.append(lineDelimiter);
- text.append(lineDelimiter);
- }
- text.append(methodBodies);
- if (namespaceEnd != null) {
- if (!methodBodies.endsWith(lineDelimiter))
- text.append(lineDelimiter);
- text.append(lineDelimiter);
- text.append(namespaceEnd);
- }
- }
-
- if (Strings.endsWith(text, lineDelimiter))
- text.append(lineDelimiter);
- fileContent = text.toString();
- } else {
- String namespaceName = fNamespace == null ?
- null : fNamespace.getFullyQualifiedName();
- fileContent= CodeGeneration.getBodyFileContent(sourceTU, includeString, namespaceBegin,
- namespaceEnd, namespaceName, null, methodBodies, fClassName, lineDelimiter);
- }
- return fileContent;
- }
-
- public String constructTestFileContent(ITranslationUnit testTU, ITranslationUnit headerTU,
- String oldContents, IProgressMonitor monitor) throws CoreException {
- SubMonitor progress = SubMonitor.convert(monitor,
- NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 1);
-
- String lineDelimiter= StubUtility.getLineDelimiterUsed(testTU);
-
- String includeString = null;
- if (headerTU != null) {
- includeString = getHeaderIncludeString(testTU, headerTU, progress.split(1));
- if (includeString != null) {
- // Check if file already has the include.
- if (oldContents != null && hasInclude(oldContents, includeString)) {
- // Don't bother to add it.
- includeString = null;
- }
- }
- }
-
- if (oldContents != null) {
- if (oldContents.length() == 0) {
- oldContents = null;
- } else if (!oldContents.endsWith(lineDelimiter)) {
- oldContents += lineDelimiter;
- }
- }
-
- String fileContent;
- if (oldContents != null) {
- StringBuilder text = new StringBuilder();
-
- if (includeString != null) {
- int insertionPos = getIncludeInsertionPos(oldContents);
- if (insertionPos == -1) {
- text.append(oldContents);
- text.append(lineDelimiter);
- text.append(includeString);
- text.append(lineDelimiter);
- } else {
- text.append(oldContents.substring(0, insertionPos));
- text.append(includeString);
- text.append(lineDelimiter);
- text.append(oldContents.substring(insertionPos));
- }
- } else {
- text.append(oldContents);
- }
-
- if (Strings.endsWith(text, lineDelimiter))
- text.append(lineDelimiter);
- fileContent = text.toString();
- } else {
- String namespaceBegin = fNamespace == null ?
- null : constructNamespaceBegin(testTU, lineDelimiter);
- String namespaceEnd = fNamespace == null ?
- null : constructNamespaceEnd(testTU, lineDelimiter);
- String namespaceName = fNamespace == null ?
- null : fNamespace.getFullyQualifiedName();
- fileContent= CodeGeneration.getTestFileContent(testTU, includeString, namespaceBegin,
- namespaceEnd, namespaceName, null, fClassName, lineDelimiter);
- }
- return fileContent;
- }
-
- private String getHeaderIncludeString(ITranslationUnit sourceTU, ITranslationUnit headerTU,
- IProgressMonitor monitor) {
- IPath headerLocation = new Path(headerTU.getResource().getLocationURI().getPath());
-
- InclusionContext inclusionContext = new InclusionContext(sourceTU);
- IncludeInfo includeInfo = inclusionContext.getIncludeForHeaderFile(headerLocation);
- if (includeInfo == null) {
- includeInfo = new IncludeInfo(headerLocation.toString(), false);
- }
-
- return "#include " + includeInfo.toString(); //$NON-NLS-1$
- }
-
- private boolean hasInclude(String contents, String include) {
- int maxStartPos = contents.length() - include.length() - 1;
- if (maxStartPos < 0) {
- return false;
- }
- int startPos = 0;
- while (startPos <= maxStartPos) {
- int includePos = contents.indexOf(include, startPos);
- if (includePos == -1) {
- return false;
- }
- if (includePos == startPos) {
- return true;
- }
-
- // TODO detect if it's commented out
-
- // make sure it's on a line by itself
- int linePos = findFirstLineChar(contents, includePos);
- if (linePos == -1 || linePos == includePos) {
- return true;
- }
- boolean badLine = false;
- for (int pos = linePos; pos < includePos; ++pos) {
- char c = contents.charAt(pos);
- if (!Character.isWhitespace(c)) {
- badLine = true;
- break;
- }
- }
- if (!badLine) {
- return true;
- }
-
- // keep searching
- startPos = includePos + include.length();
- }
- return false;
- }
-
- private int getIncludeInsertionPos(String contents) {
- if (contents.length() == 0) {
- return -1;
- }
- //TODO temporary hack
- int includePos = contents.lastIndexOf("#include "); //$NON-NLS-1$
- if (includePos != -1) {
- // Find the end of line
- int startPos = includePos + "#include ".length(); //$NON-NLS-1$
- int eolPos = findLastLineChar(contents, startPos);
- if (eolPos != -1) {
- int insertPos = eolPos + 1;
- if (insertPos < (contents.length() - 1)) {
- return insertPos;
- }
- }
- }
- return -1;
- }
-
- private String constructMethodBodies(ITranslationUnit tu, List<IMethodStub> publicMethods,
- List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String lineDelimiter,
- IProgressMonitor monitor) throws CoreException {
- StringBuilder text = new StringBuilder();
- if (!publicMethods.isEmpty()) {
- for (Iterator<IMethodStub> i = publicMethods.iterator(); i.hasNext();) {
- IMethodStub stub = i.next();
- String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
- text.append(code);
- text.append(lineDelimiter);
- if (i.hasNext())
- text.append(lineDelimiter);
- }
- }
-
- if (!protectedMethods.isEmpty()) {
- for (Iterator<IMethodStub> i = protectedMethods.iterator(); i.hasNext();) {
- IMethodStub stub = i.next();
- String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
- text.append(code);
- text.append(lineDelimiter);
- if (i.hasNext())
- text.append(lineDelimiter);
- }
- }
-
- if (!privateMethods.isEmpty()) {
- for (Iterator<IMethodStub> i = privateMethods.iterator(); i.hasNext();) {
- IMethodStub stub = i.next();
- String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
- text.append(code);
- text.append(lineDelimiter);
- if (i.hasNext())
- text.append(lineDelimiter);
- }
- }
- return text.toString();
- }
-
- private int findLastLineChar(String contents, int startPos) {
- int endPos = contents.length() - 1;
- int linePos = startPos;
- while (linePos <= endPos) {
- char c = contents.charAt(linePos);
- if (c == '\r') {
- // could be '\r\n' as one delimiter
- if (linePos < endPos && contents.charAt(linePos + 1) == '\n') {
- return linePos + 1;
- }
- return linePos;
- } else if (c == '\n') {
- return linePos;
- }
- ++linePos;
- }
- return -1;
- }
-
- private int findFirstLineChar(String contents, int startPos) {
- int linePos = startPos;
- while (linePos >= 0) {
- char c = contents.charAt(linePos);
- if (c == '\n' || c == '\r') {
- if (linePos + 1 < startPos) {
- return linePos + 1;
- }
- return -1;
- }
- --linePos;
- }
- return -1;
- }
-}
+ private List<IPath> getMissingIncludePaths(IPath projectLocation, List<IPath> includePaths,
+ List<IPath> baseClassPaths) {
+ // check for missing include paths
+ List<IPath> newIncludePaths = new ArrayList<IPath>();
+ for (IPath baseClassLocation : baseClassPaths) {
+ // skip any paths inside the same project
+ //TODO possibly a preferences option?
+ if (projectLocation.isPrefixOf(baseClassLocation)) {
+ continue;
+ }
+
+ IPath folderToAdd = baseClassLocation.removeLastSegments(1);
+ IPath canonPath = PathUtil.getCanonicalPath(folderToAdd);
+ if (canonPath != null)
+ folderToAdd = canonPath;
+
+ // see if folder or its parent hasn't already been added
+ for (IPath newFolder : newIncludePaths) {
+ if (newFolder.isPrefixOf(folderToAdd)) {
+ folderToAdd = null;
+ break;
+ }
+ }
+
+ if (folderToAdd != null) {
+ // search include paths
+ boolean foundPath = false;
+ for (IPath includePath : includePaths) {
+ if (includePath.isPrefixOf(folderToAdd) || includePath.equals(folderToAdd)) {
+ foundPath = true;
+ break;
+ }
+ }
+ if (!foundPath) {
+ // remove any children of this folder
+ for (Iterator<IPath> newIter = newIncludePaths.iterator(); newIter.hasNext();) {
+ IPath newFolder = newIter.next();
+ if (folderToAdd.isPrefixOf(newFolder)) {
+ newIter.remove();
+ }
+ }
+ if (!newIncludePaths.contains(folderToAdd)) {
+ newIncludePaths.add(folderToAdd);
+ }
+ }
+ }
+ }
+ return newIncludePaths;
+ }
+
+ private List<IPath> getIncludePaths(ITranslationUnit headerTU) throws CodeGeneratorException {
+ IProject project = headerTU.getCProject().getProject();
+ // get the parent source folder
+ ICContainer sourceFolder = CModelUtil.getSourceFolder(headerTU);
+ if (sourceFolder == null) {
+ throw new CodeGeneratorException("Could not find source folder"); //$NON-NLS-1$
+ }
+
+ // get the include paths
+ IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
+ if (provider != null) {
+ IScannerInfo info = provider.getScannerInformation(sourceFolder.getResource());
+ if (info != null) {
+ String[] includePaths = info.getIncludePaths();
+ if (includePaths != null) {
+ List<IPath> list = new ArrayList<IPath>();
+ for (int i = 0; i < includePaths.length; ++i) {
+ //TODO do we need to canonicalize these paths first?
+ IPath path = new Path(includePaths[i]);
+ if (!list.contains(path)) {
+ list.add(path);
+ }
+ }
+ return list;
+ }
+ }
+ }
+ return null;
+ }
+
+ private List<IPath> getBaseClassPaths(boolean verifyLocation) throws CodeGeneratorException {
+ List<IPath> list = new ArrayList<IPath>();
+ for (int i = 0; i < fBaseClasses.length; ++i) {
+ IBaseClassInfo baseClass = fBaseClasses[i];
+ ITypeReference ref = baseClass.getType().getResolvedReference();
+ IPath baseClassLocation = null;
+ if (ref != null) {
+ baseClassLocation = ref.getLocation();
+ }
+
+ if (baseClassLocation == null) {
+ if (verifyLocation) {
+ throw new CodeGeneratorException("Could not find base class " + baseClass.toString()); //$NON-NLS-1$
+ }
+ } else if (!list.contains(baseClassLocation)) {
+ list.add(baseClassLocation);
+ }
+ }
+ return list;
+ }
+
+ public String constructSourceFileContent(ITranslationUnit sourceTU, ITranslationUnit headerTU,
+ List<IMethodStub> publicMethods, List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods,
+ String oldContents, IProgressMonitor monitor) throws CoreException {
+ SubMonitor progress = SubMonitor.convert(monitor,
+ NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 2);
+
+ String lineDelimiter = StubUtility.getLineDelimiterUsed(sourceTU);
+ String includeString = null;
+ if (headerTU != null) {
+ includeString = getHeaderIncludeString(sourceTU, headerTU, progress.split(1));
+ if (includeString != null) {
+ // Check if file already has the include.
+ if (oldContents != null && hasInclude(oldContents, includeString)) {
+ // Don't bother to add it.
+ includeString = null;
+ }
+ }
+ }
+
+ String methodBodies = null;
+ if (!publicMethods.isEmpty() || !protectedMethods.isEmpty() || !privateMethods.isEmpty()) {
+ // TODO sort methods (e.g. constructor always first?)
+ methodBodies = constructMethodBodies(sourceTU, publicMethods, protectedMethods, privateMethods,
+ lineDelimiter, progress.split(1));
+ }
+
+ String namespaceBegin = fNamespace == null ? null : constructNamespaceBegin(sourceTU, lineDelimiter);
+ String namespaceEnd = fNamespace == null ? null : constructNamespaceEnd(sourceTU, lineDelimiter);
+
+ if (oldContents != null) {
+ if (oldContents.length() == 0) {
+ oldContents = null;
+ } else if (!oldContents.endsWith(lineDelimiter)) {
+ oldContents += lineDelimiter;
+ }
+ }
+
+ String fileContent;
+ if (oldContents != null) {
+ StringBuilder text = new StringBuilder();
+
+ if (includeString != null) {
+ int insertionPos = getIncludeInsertionPos(oldContents);
+ if (insertionPos == -1) {
+ text.append(oldContents);
+ text.append(lineDelimiter);
+ text.append(includeString);
+ text.append(lineDelimiter);
+ } else {
+ text.append(oldContents.substring(0, insertionPos));
+ text.append(includeString);
+ text.append(lineDelimiter);
+ text.append(oldContents.substring(insertionPos));
+ }
+ } else {
+ text.append(oldContents);
+ }
+ // Add a blank line
+ text.append(lineDelimiter);
+
+ if (methodBodies != null) {
+ if (namespaceBegin != null) {
+ text.append(namespaceBegin);
+ text.append(lineDelimiter);
+ text.append(lineDelimiter);
+ }
+ text.append(methodBodies);
+ if (namespaceEnd != null) {
+ if (!methodBodies.endsWith(lineDelimiter))
+ text.append(lineDelimiter);
+ text.append(lineDelimiter);
+ text.append(namespaceEnd);
+ }
+ }
+
+ if (Strings.endsWith(text, lineDelimiter))
+ text.append(lineDelimiter);
+ fileContent = text.toString();
+ } else {
+ String namespaceName = fNamespace == null ? null : fNamespace.getFullyQualifiedName();
+ fileContent = CodeGeneration.getBodyFileContent(sourceTU, includeString, namespaceBegin, namespaceEnd,
+ namespaceName, null, methodBodies, fClassName, lineDelimiter);
+ }
+ return fileContent;
+ }
+
+ public String constructTestFileContent(ITranslationUnit testTU, ITranslationUnit headerTU, String oldContents,
+ IProgressMonitor monitor) throws CoreException {
+ SubMonitor progress = SubMonitor.convert(monitor,
+ NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 1);
+
+ String lineDelimiter = StubUtility.getLineDelimiterUsed(testTU);
+
+ String includeString = null;
+ if (headerTU != null) {
+ includeString = getHeaderIncludeString(testTU, headerTU, progress.split(1));
+ if (includeString != null) {
+ // Check if file already has the include.
+ if (oldContents != null && hasInclude(oldContents, includeString)) {
+ // Don't bother to add it.
+ includeString = null;
+ }
+ }
+ }
+
+ if (oldContents != null) {
+ if (oldContents.length() == 0) {
+ oldContents = null;
+ } else if (!oldContents.endsWith(lineDelimiter)) {
+ oldContents += lineDelimiter;
+ }
+ }
+
+ String fileContent;
+ if (oldContents != null) {
+ StringBuilder text = new StringBuilder();
+
+ if (includeString != null) {
+ int insertionPos = getIncludeInsertionPos(oldContents);
+ if (insertionPos == -1) {
+ text.append(oldContents);
+ text.append(lineDelimiter);
+ text.append(includeString);
+ text.append(lineDelimiter);
+ } else {
+ text.append(oldContents.substring(0, insertionPos));
+ text.append(includeString);
+ text.append(lineDelimiter);
+ text.append(oldContents.substring(insertionPos));
+ }
+ } else {
+ text.append(oldContents);
+ }
+
+ if (Strings.endsWith(text, lineDelimiter))
+ text.append(lineDelimiter);
+ fileContent = text.toString();
+ } else {
+ String namespaceBegin = fNamespace == null ? null : constructNamespaceBegin(testTU, lineDelimiter);
+ String namespaceEnd = fNamespace == null ? null : constructNamespaceEnd(testTU, lineDelimiter);
+ String namespaceName = fNamespace == null ? null : fNamespace.getFullyQualifiedName();
+ fileContent = CodeGeneration.getTestFileContent(testTU, includeString, namespaceBegin, namespaceEnd,
+ namespaceName, null, fClassName, lineDelimiter);
+ }
+ return fileContent;
+ }
+
+ private String getHeaderIncludeString(ITranslationUnit sourceTU, ITranslationUnit headerTU,
+ IProgressMonitor monitor) {
+ IPath headerLocation = new Path(headerTU.getResource().getLocationURI().getPath());
+
+ InclusionContext inclusionContext = new InclusionContext(sourceTU);
+ IncludeInfo includeInfo = inclusionContext.getIncludeForHeaderFile(headerLocation);
+ if (includeInfo == null) {
+ includeInfo = new IncludeInfo(headerLocation.toString(), false);
+ }
+
+ return "#include " + includeInfo.toString(); //$NON-NLS-1$
+ }
+
+ private boolean hasInclude(String contents, String include) {
+ int maxStartPos = contents.length() - include.length() - 1;
+ if (maxStartPos < 0) {
+ return false;
+ }
+ int startPos = 0;
+ while (startPos <= maxStartPos) {
+ int includePos = contents.indexOf(include, startPos);
+ if (includePos == -1) {
+ return false;
+ }
+ if (includePos == startPos) {
+ return true;
+ }
+
+ // TODO detect if it's commented out
+
+ // make sure it's on a line by itself
+ int linePos = findFirstLineChar(contents, includePos);
+ if (linePos == -1 || linePos == includePos) {
+ return true;
+ }
+ boolean badLine = false;
+ for (int pos = linePos; pos < includePos; ++pos) {
+ char c = contents.charAt(pos);
+ if (!Character.isWhitespace(c)) {
+ badLine = true;
+ break;
+ }
+ }
+ if (!badLine) {
+ return true;
+ }
+
+ // keep searching
+ startPos = includePos + include.length();
+ }
+ return false;
+ }
+ private int getIncludeInsertionPos(String contents) {
+ if (contents.length() == 0) {
+ return -1;
+ }
+ //TODO temporary hack
+ int includePos = contents.lastIndexOf("#include "); //$NON-NLS-1$
+ if (includePos != -1) {
+ // Find the end of line
+ int startPos = includePos + "#include ".length(); //$NON-NLS-1$
+ int eolPos = findLastLineChar(contents, startPos);
+ if (eolPos != -1) {
+ int insertPos = eolPos + 1;
+ if (insertPos < (contents.length() - 1)) {
+ return insertPos;
+ }
+ }
+ }
+ return -1;
+ }
+
+ private String constructMethodBodies(ITranslationUnit tu, List<IMethodStub> publicMethods,
+ List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String lineDelimiter,
+ IProgressMonitor monitor) throws CoreException {
+ StringBuilder text = new StringBuilder();
+ if (!publicMethods.isEmpty()) {
+ for (Iterator<IMethodStub> i = publicMethods.iterator(); i.hasNext();) {
+ IMethodStub stub = i.next();
+ String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
+ text.append(code);
+ text.append(lineDelimiter);
+ if (i.hasNext())
+ text.append(lineDelimiter);
+ }
+ }
+
+ if (!protectedMethods.isEmpty()) {
+ for (Iterator<IMethodStub> i = protectedMethods.iterator(); i.hasNext();) {
+ IMethodStub stub = i.next();
+ String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
+ text.append(code);
+ text.append(lineDelimiter);
+ if (i.hasNext())
+ text.append(lineDelimiter);
+ }
+ }
+
+ if (!privateMethods.isEmpty()) {
+ for (Iterator<IMethodStub> i = privateMethods.iterator(); i.hasNext();) {
+ IMethodStub stub = i.next();
+ String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
+ text.append(code);
+ text.append(lineDelimiter);
+ if (i.hasNext())
+ text.append(lineDelimiter);
+ }
+ }
+ return text.toString();
+ }
+
+ private int findLastLineChar(String contents, int startPos) {
+ int endPos = contents.length() - 1;
+ int linePos = startPos;
+ while (linePos <= endPos) {
+ char c = contents.charAt(linePos);
+ if (c == '\r') {
+ // could be '\r\n' as one delimiter
+ if (linePos < endPos && contents.charAt(linePos + 1) == '\n') {
+ return linePos + 1;
+ }
+ return linePos;
+ } else if (c == '\n') {
+ return linePos;
+ }
+ ++linePos;
+ }
+ return -1;
+ }
+
+ private int findFirstLineChar(String contents, int startPos) {
+ int linePos = startPos;
+ while (linePos >= 0) {
+ char c = contents.charAt(linePos);
+ if (c == '\n' || c == '\r') {
+ if (linePos + 1 < startPos) {
+ return linePos + 1;
+ }
+ return -1;
+ }
+ --linePos;
+ }
+ return -1;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPrefs.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPrefs.java
index 3b74f781e3e..8db2e57965a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPrefs.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPrefs.java
@@ -15,36 +15,36 @@ package org.eclipse.cdt.internal.ui.wizards.classwizard;
public class NewClassWizardPrefs {
- /**
- * Checks if the base classes need to be verified (ie they must exist in the project)
- *
- * @return <code>true</code> if the base classes should be verified
- */
- public static boolean verifyBaseClasses() {
- //TODO this should be a prefs option
- return true;
- }
-
- /**
- * Checks if include paths can be added to the project as needed.
- *
- * @return <code>true</code> if the include paths should be added
- */
- public static boolean createIncludePaths() {
- //TODO this should be a prefs option
- return true;
- }
+ /**
+ * Checks if the base classes need to be verified (ie they must exist in the project)
+ *
+ * @return <code>true</code> if the base classes should be verified
+ */
+ public static boolean verifyBaseClasses() {
+ //TODO this should be a prefs option
+ return true;
+ }
+
+ /**
+ * Checks if include paths can be added to the project as needed.
+ *
+ * @return <code>true</code> if the include paths should be added
+ */
+ public static boolean createIncludePaths() {
+ //TODO this should be a prefs option
+ return true;
+ }
+
+ /**
+ * Returns whether the generated header and source files should be
+ * opened in editors after the finish button is pressed.
+ *
+ * @return <code>true</code> if the header and source file should be
+ * displayed
+ */
+ public static boolean openClassInEditor() {
+ //TODO this should be a prefs option
+ return true;
+ }
- /**
- * Returns whether the generated header and source files should be
- * opened in editors after the finish button is pressed.
- *
- * @return <code>true</code> if the header and source file should be
- * displayed
- */
- public static boolean openClassInEditor() {
- //TODO this should be a prefs option
- return true;
- }
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
index 12eea094317..4a0317bcedb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
@@ -63,262 +63,262 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
public class NewClassWizardUtil {
- /**
- * Returns the parent source folder of the given element. If the given
- * element is already a source folder, the element itself is returned.
- *
- * @param element the C Element
- * @return the source folder
- */
- public static ICContainer getSourceFolder(ICElement element) {
- ICContainer folder = null;
- boolean foundSourceRoot = false;
- ICElement curr = element;
- while (curr != null && !foundSourceRoot) {
- if (curr instanceof ICContainer && folder == null) {
- folder = (ICContainer) curr;
- }
- foundSourceRoot = (curr instanceof ISourceRoot);
- curr = curr.getParent();
- }
- if (folder == null) {
- ICProject cproject = element.getCProject();
- folder = cproject.findSourceRoot(cproject.getProject());
- }
- return folder;
- }
-
- /**
- * Returns the parent source folder for the given path. If the given
- * path is already a source folder, the corresponding C element is returned.
- *
- * @param path the path
- * @return the source folder
- */
- public static ICContainer getSourceFolder(IPath path) {
- if (path == null)
- return null;
- while (path.segmentCount() > 0) {
- IResource res = getWorkspaceRoot().findMember(path);
- if (res != null && res.exists()) {
- int resType = res.getType();
- if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
- ICElement elem = CoreModel.getDefault().create(res.getFullPath());
- if (elem != null) {
- ICContainer sourceFolder = getSourceFolder(elem);
- if (sourceFolder != null)
- return sourceFolder;
- if (resType == IResource.PROJECT) {
- if (elem instanceof ICContainer) {
- return (ICContainer)elem;
- }
- }
- }
- }
- }
- path = path.removeLastSegments(1);
- }
- return null;
- }
+ /**
+ * Returns the parent source folder of the given element. If the given
+ * element is already a source folder, the element itself is returned.
+ *
+ * @param element the C Element
+ * @return the source folder
+ */
+ public static ICContainer getSourceFolder(ICElement element) {
+ ICContainer folder = null;
+ boolean foundSourceRoot = false;
+ ICElement curr = element;
+ while (curr != null && !foundSourceRoot) {
+ if (curr instanceof ICContainer && folder == null) {
+ folder = (ICContainer) curr;
+ }
+ foundSourceRoot = (curr instanceof ISourceRoot);
+ curr = curr.getParent();
+ }
+ if (folder == null) {
+ ICProject cproject = element.getCProject();
+ folder = cproject.findSourceRoot(cproject.getProject());
+ }
+ return folder;
+ }
- /**
- * Checks if a given resource is under a source root.
- *
- * @param resource the resource
- * @return <code>true</code> if the resource is under one of the project source roots
- */
- public static boolean isOnSourceRoot(IResource resource) {
- IProject project = resource.getProject();
- ICProject cProject = CoreModel.getDefault().create(project);
- return cProject.isOnSourceRoot(resource);
- }
+ /**
+ * Returns the parent source folder for the given path. If the given
+ * path is already a source folder, the corresponding C element is returned.
+ *
+ * @param path the path
+ * @return the source folder
+ */
+ public static ICContainer getSourceFolder(IPath path) {
+ if (path == null)
+ return null;
+ while (path.segmentCount() > 0) {
+ IResource res = getWorkspaceRoot().findMember(path);
+ if (res != null && res.exists()) {
+ int resType = res.getType();
+ if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
+ ICElement elem = CoreModel.getDefault().create(res.getFullPath());
+ if (elem != null) {
+ ICContainer sourceFolder = getSourceFolder(elem);
+ if (sourceFolder != null)
+ return sourceFolder;
+ if (resType == IResource.PROJECT) {
+ if (elem instanceof ICContainer) {
+ return (ICContainer) elem;
+ }
+ }
+ }
+ }
+ }
+ path = path.removeLastSegments(1);
+ }
+ return null;
+ }
- /**
- * Checks if a given file path is under a source root.
- *
- * @param path the file path
- * @return <code>true</code> if the resource is under one of the project source roots
- */
- public static boolean isOnSourceRoot(IPath path) {
- IFile file = getWorkspaceRoot().getFile(path);
- return isOnSourceRoot(file);
- }
+ /**
+ * Checks if a given resource is under a source root.
+ *
+ * @param resource the resource
+ * @return <code>true</code> if the resource is under one of the project source roots
+ */
+ public static boolean isOnSourceRoot(IResource resource) {
+ IProject project = resource.getProject();
+ ICProject cProject = CoreModel.getDefault().create(project);
+ return cProject.isOnSourceRoot(resource);
+ }
- /**
- * Returns the first source root in the given project. If the project has
- * no source roots as children, the project itself is returned.
- *
- * @param cproject
- * @return the source root
- */
- public static ISourceRoot getFirstSourceRoot(ICProject cproject) {
- ISourceRoot folder = null;
- try {
- if (cproject.exists()) {
- ISourceRoot[] roots = cproject.getSourceRoots();
- if (roots != null && roots.length > 0)
- folder = roots[0];
- }
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- if (folder == null) {
- folder = cproject.findSourceRoot(cproject.getResource());
- }
- return folder;
- }
+ /**
+ * Checks if a given file path is under a source root.
+ *
+ * @param path the file path
+ * @return <code>true</code> if the resource is under one of the project source roots
+ */
+ public static boolean isOnSourceRoot(IPath path) {
+ IFile file = getWorkspaceRoot().getFile(path);
+ return isOnSourceRoot(file);
+ }
- /**
- * Returns the C Element which corresponds to the given selection.
- *
- * @param selection the selection to be inspected
- * @return a C element matching the selection, or <code>null</code>
- * if no C element exists in the given selection
- */
- public static ICElement getCElementFromSelection(IStructuredSelection selection) {
- ICElement celem = null;
- if (selection != null && !selection.isEmpty()) {
- Object selectedElement = selection.getFirstElement();
- if (selectedElement instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) selectedElement;
-
- celem = adaptable.getAdapter(ICElement.class);
- if (celem == null) {
- IResource resource = adaptable.getAdapter(IResource.class);
- if (resource != null && resource.getType() != IResource.ROOT) {
- while (celem == null && resource.getType() != IResource.PROJECT) {
- celem = resource.getAdapter(ICElement.class);
- resource = resource.getParent();
- }
- if (celem == null) {
- celem = CoreModel.getDefault().create(resource); // c project
- }
- }
- }
- }
- }
- return celem;
- }
-
- /**
- * Returns the C Element which corresponds to the active editor.
- *
- * @return a C element matching the active editor, or <code>null</code>
- * if no C element can be found
- */
- public static ICElement getCElementFromEditor() {
- ICElement celem = null;
- IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
- if (part instanceof ContentOutline) {
- part = CUIPlugin.getActivePage().getActiveEditor();
- }
- if (part instanceof IViewPartInputProvider) {
- Object elem = ((IViewPartInputProvider)part).getViewPartInput();
- if (elem instanceof ICElement) {
- celem = (ICElement) elem;
- }
- }
- if (celem == null && part instanceof CEditor) {
- IEditorInput input = ((IEditorPart)part).getEditorInput();
- if (input != null) {
- final IResource res = input.getAdapter(IResource.class);
- if (res != null && res instanceof IFile) {
- celem = CoreModel.getDefault().create((IFile)res);
- }
- }
- }
- return celem;
- }
-
- /**
- * Returns the parent namespace for the given element. If the given element is
- * already a namespace, the element itself is returned.
- *
- * @param element the given C Element
- * @return the C Element for the namespace, or <code>null</code> if not found
- */
- public static ICElement getNamespace(ICElement element) {
- ICElement curr = element;
- while (curr != null) {
- int type = curr.getElementType();
- if (type == ICElement.C_UNIT) {
- break;
- }
- if (type == ICElement.C_NAMESPACE) {
- return curr;
- }
- curr = curr.getParent();
- }
- return null;
- }
-
- /**
- * Returns the workspace root.
- *
- * @return the workspace root
- */
- public static IWorkspaceRoot getWorkspaceRoot() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
- /**
- * Resolves the location of the given class.
- *
- * @param type the class to resolve
- * @param context the runnable context
- * @return the class location, or <code>null</code> if not found
- */
- public static ITypeReference resolveClassLocation(ITypeInfo type, IRunnableContext context) {
- return type.getResolvedReference();
- }
+ /**
+ * Returns the first source root in the given project. If the project has
+ * no source roots as children, the project itself is returned.
+ *
+ * @param cproject
+ * @return the source root
+ */
+ public static ISourceRoot getFirstSourceRoot(ICProject cproject) {
+ ISourceRoot folder = null;
+ try {
+ if (cproject.exists()) {
+ ISourceRoot[] roots = cproject.getSourceRoots();
+ if (roots != null && roots.length > 0)
+ folder = roots[0];
+ }
+ } catch (CModelException e) {
+ CUIPlugin.log(e);
+ }
+ if (folder == null) {
+ folder = cproject.findSourceRoot(cproject.getResource());
+ }
+ return folder;
+ }
+
+ /**
+ * Returns the C Element which corresponds to the given selection.
+ *
+ * @param selection the selection to be inspected
+ * @return a C element matching the selection, or <code>null</code>
+ * if no C element exists in the given selection
+ */
+ public static ICElement getCElementFromSelection(IStructuredSelection selection) {
+ ICElement celem = null;
+ if (selection != null && !selection.isEmpty()) {
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) selectedElement;
+
+ celem = adaptable.getAdapter(ICElement.class);
+ if (celem == null) {
+ IResource resource = adaptable.getAdapter(IResource.class);
+ if (resource != null && resource.getType() != IResource.ROOT) {
+ while (celem == null && resource.getType() != IResource.PROJECT) {
+ celem = resource.getAdapter(ICElement.class);
+ resource = resource.getParent();
+ }
+ if (celem == null) {
+ celem = CoreModel.getDefault().create(resource); // c project
+ }
+ }
+ }
+ }
+ }
+ return celem;
+ }
- /**
- * Checks whether the given type can be found in the given project or the
- * given include paths.
- *
- * @param type the type
- * @param project the project
- * @param includePaths the include paths
- * @return <code>true</code> if the given type is found
- */
- public static boolean isTypeReachable(ITypeInfo type, ICProject project, String[] includePaths) {
- ICProject baseProject = type.getEnclosingProject();
- if (baseProject != null && baseProject.equals(project)) {
- return true;
- }
-
- // check the include paths
- ITypeReference ref = type.getResolvedReference();
- IPath location = ref == null ? null : ref.getLocation();
- boolean isTypeLocation= true;
- if (location == null) {
- isTypeLocation= false;
-
- if (baseProject != null) {
- location = baseProject.getProject().getLocation();
- }
- if (location == null)
- return false;
- }
-
- for (int i = 0; i < includePaths.length; ++i) {
- IPath includePath = new Path(includePaths[i]);
- if (isTypeLocation) {
+ /**
+ * Returns the C Element which corresponds to the active editor.
+ *
+ * @return a C element matching the active editor, or <code>null</code>
+ * if no C element can be found
+ */
+ public static ICElement getCElementFromEditor() {
+ ICElement celem = null;
+ IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
+ if (part instanceof ContentOutline) {
+ part = CUIPlugin.getActivePage().getActiveEditor();
+ }
+ if (part instanceof IViewPartInputProvider) {
+ Object elem = ((IViewPartInputProvider) part).getViewPartInput();
+ if (elem instanceof ICElement) {
+ celem = (ICElement) elem;
+ }
+ }
+ if (celem == null && part instanceof CEditor) {
+ IEditorInput input = ((IEditorPart) part).getEditorInput();
+ if (input != null) {
+ final IResource res = input.getAdapter(IResource.class);
+ if (res != null && res instanceof IFile) {
+ celem = CoreModel.getDefault().create((IFile) res);
+ }
+ }
+ }
+ return celem;
+ }
+
+ /**
+ * Returns the parent namespace for the given element. If the given element is
+ * already a namespace, the element itself is returned.
+ *
+ * @param element the given C Element
+ * @return the C Element for the namespace, or <code>null</code> if not found
+ */
+ public static ICElement getNamespace(ICElement element) {
+ ICElement curr = element;
+ while (curr != null) {
+ int type = curr.getElementType();
+ if (type == ICElement.C_UNIT) {
+ break;
+ }
+ if (type == ICElement.C_NAMESPACE) {
+ return curr;
+ }
+ curr = curr.getParent();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the workspace root.
+ *
+ * @return the workspace root
+ */
+ public static IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ /**
+ * Resolves the location of the given class.
+ *
+ * @param type the class to resolve
+ * @param context the runnable context
+ * @return the class location, or <code>null</code> if not found
+ */
+ public static ITypeReference resolveClassLocation(ITypeInfo type, IRunnableContext context) {
+ return type.getResolvedReference();
+ }
+
+ /**
+ * Checks whether the given type can be found in the given project or the
+ * given include paths.
+ *
+ * @param type the type
+ * @param project the project
+ * @param includePaths the include paths
+ * @return <code>true</code> if the given type is found
+ */
+ public static boolean isTypeReachable(ITypeInfo type, ICProject project, String[] includePaths) {
+ ICProject baseProject = type.getEnclosingProject();
+ if (baseProject != null && baseProject.equals(project)) {
+ return true;
+ }
+
+ // check the include paths
+ ITypeReference ref = type.getResolvedReference();
+ IPath location = ref == null ? null : ref.getLocation();
+ boolean isTypeLocation = true;
+ if (location == null) {
+ isTypeLocation = false;
+
+ if (baseProject != null) {
+ location = baseProject.getProject().getLocation();
+ }
+ if (location == null)
+ return false;
+ }
+
+ for (int i = 0; i < includePaths.length; ++i) {
+ IPath includePath = new Path(includePaths[i]);
+ if (isTypeLocation) {
if (includePath.isPrefixOf(location))
- return true;
- } else {
- // we don't have the real location, so just check the project path
+ return true;
+ } else {
+ // we don't have the real location, so just check the project path
if (location.isPrefixOf(includePath))
- return true;
- }
- }
-
- return false;
- }
+ return true;
+ }
+ }
+
+ return false;
+ }
- public static final int SEARCH_MATCH_ERROR = -1; // some error, search failed
- public static final int SEARCH_MATCH_NOTFOUND = 0; // no match found
- public static final int SEARCH_MATCH_FOUND_EXACT = 1; // exact match
+ public static final int SEARCH_MATCH_ERROR = -1; // some error, search failed
+ public static final int SEARCH_MATCH_NOTFOUND = 0; // no match found
+ public static final int SEARCH_MATCH_FOUND_EXACT = 1; // exact match
public static final int SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE = 2; // same name found, by different type
public static final int SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE = 3; // same type name exits in different scope
public static final int SEARCH_MATCH_FOUND_ANOTHER_TYPE = 4; // same name used by another type in different scope
@@ -326,20 +326,21 @@ public class NewClassWizardUtil {
/**
* Search for the given qualified name of the give
* @param typeName qualified name of the type to search
- * @param project
+ * @param project
* @param queryType Class of interface type to search for (e.g. ICPPClassType.class)
- * @return one of {@link #SEARCH_MATCH_ERROR},
+ * @return one of {@link #SEARCH_MATCH_ERROR},
* {@link #SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE},
- * {@link #SEARCH_MATCH_FOUND_ANOTHER_TYPE},
+ * {@link #SEARCH_MATCH_FOUND_ANOTHER_TYPE},
* {@link #SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE},
* {@link #SEARCH_MATCH_FOUND_EXACT} or
- * {@link #SEARCH_MATCH_NOTFOUND}.
+ * {@link #SEARCH_MATCH_NOTFOUND}.
*/
public static int searchForCppType(IQualifiedTypeName typeName, ICProject project, Class<?> queryType) {
- IIndex index= null;
+ IIndex index = null;
try {
if (project != null) {
- index = CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
+ index = CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES
+ | IIndexManager.ADD_DEPENDENT | IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
index.acquireReadLock();
}
} catch (CoreException e) {
@@ -355,11 +356,12 @@ public class NewClassWizardUtil {
try {
String fullyQualifiedTypeName = typeName.getFullyQualifiedName();
try {
- IndexFilter filter= IndexFilter.getDeclaredBindingFilter(ILinkage.CPP_LINKAGE_ID, true);
+ IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ILinkage.CPP_LINKAGE_ID, true);
//bug 165636: findBindings(char[][]...) does not find nested nodes (classes)
//therefore switching back to findBindings(Pattern...)
- IBinding[] bindings = index.findBindings(typeName.getName().toCharArray(), false, filter, new NullProgressMonitor());
- boolean sameTypeNameExists = false;
+ IBinding[] bindings = index.findBindings(typeName.getName().toCharArray(), false, filter,
+ new NullProgressMonitor());
+ boolean sameTypeNameExists = false;
boolean sameNameDifferentTypeExists = false;
for (int i = 0; i < bindings.length; ++i) {
@@ -368,36 +370,36 @@ public class NewClassWizardUtil {
//get the fully qualified name of this binding
String bindingFullName = renderQualifiedName(binding.getQualifiedName());
Class<? extends ICPPBinding> currentNodeType = binding.getClass();
- // full binding
- if (queryType.isAssignableFrom(currentNodeType)) {
+ // full binding
+ if (queryType.isAssignableFrom(currentNodeType)) {
if (bindingFullName.equals(fullyQualifiedTypeName)) {
//bug 165636: there is a match only if there is a definition for the binding
//otherwise, users can create a new class definition for this binding
- if (index.findDefinitions(binding).length > 0) {
+ if (index.findDefinitions(binding).length > 0) {
return SEARCH_MATCH_FOUND_EXACT;
- }
+ }
} else {
// same type , same name , but different name space
// see if there is an exact match;
sameTypeNameExists = true;
}
- } else if(ICPPClassType.class.isAssignableFrom(currentNodeType) ||
- IEnumeration.class.isAssignableFrom(currentNodeType) || // TODO - this should maybe be ICPPEnumeration
- ICPPNamespace.class.isAssignableFrom(currentNodeType) ||
- ITypedef.class.isAssignableFrom(currentNodeType) ||
- ICPPBasicType.class.isAssignableFrom(currentNodeType)) {
- if (bindingFullName.equals(fullyQualifiedTypeName)) {
+ } else if (ICPPClassType.class.isAssignableFrom(currentNodeType)
+ || IEnumeration.class.isAssignableFrom(currentNodeType) || // TODO - this should maybe be ICPPEnumeration
+ ICPPNamespace.class.isAssignableFrom(currentNodeType)
+ || ITypedef.class.isAssignableFrom(currentNodeType)
+ || ICPPBasicType.class.isAssignableFrom(currentNodeType)) {
+ if (bindingFullName.equals(fullyQualifiedTypeName)) {
return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE;
}
// different type , same name , but different name space
sameNameDifferentTypeExists = true;
}
}
- if(sameTypeNameExists){
+ if (sameTypeNameExists) {
return SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE;
}
- if(sameNameDifferentTypeExists){
+ if (sameNameDifferentTypeExists) {
return SEARCH_MATCH_FOUND_ANOTHER_TYPE;
}
} catch (CoreException e) {
@@ -413,12 +415,12 @@ public class NewClassWizardUtil {
private static String renderQualifiedName(String[] qn) {
StringBuilder result = new StringBuilder();
- boolean needSep= false;
+ boolean needSep = false;
for (String element : qn) {
if (needSep)
result.append(Keywords.cpCOLONCOLON);
- result.append(element);
- needSep= true;
+ result.append(element);
+ needSep = true;
}
return result.toString();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java
index c429ed3c3c1..451f2bf44fc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java
@@ -70,199 +70,192 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
public class SourceFileSelectionDialog extends SelectionStatusDialog {
-
- TreeViewer fViewer;
- private final ITreeContentProvider fContentProvider = new CElementContentProvider();
- private final ILabelProvider fLabelProvider = new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT);
- IStatus fCurrStatus = new StatusInfo();
- IStatus fFolderNameStatus = new StatusInfo();
- IStatus fFileNameStatus = new StatusInfo();
- ICElement fInput;
- private int fWidth = 60;
- private int fHeight = 18;
- StringDialogField fFolderNameDialogField;
- StringDialogField fFileNameDialogField;
- private IWorkspaceRoot fWorkspaceRoot;
- private final FieldsAdapter fFieldsAdapter = new FieldsAdapter();
-
+
+ TreeViewer fViewer;
+ private final ITreeContentProvider fContentProvider = new CElementContentProvider();
+ private final ILabelProvider fLabelProvider = new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT);
+ IStatus fCurrStatus = new StatusInfo();
+ IStatus fFolderNameStatus = new StatusInfo();
+ IStatus fFileNameStatus = new StatusInfo();
+ ICElement fInput;
+ private int fWidth = 60;
+ private int fHeight = 18;
+ StringDialogField fFolderNameDialogField;
+ StringDialogField fFileNameDialogField;
+ private IWorkspaceRoot fWorkspaceRoot;
+ private final FieldsAdapter fFieldsAdapter = new FieldsAdapter();
+
private ICElement fCurrentFolder = null;
private String fCurrentFileString = null;
- String fInitialFolderName = null;
- String fInitialFileName = null;
-
- private final class FieldsAdapter extends SelectionAdapter
- implements ISelectionChangedListener, IDoubleClickListener, IDialogFieldListener {
-
- // -- SelectionAdapter --
- @Override
+ String fInitialFolderName = null;
+ String fInitialFileName = null;
+
+ private final class FieldsAdapter extends SelectionAdapter
+ implements ISelectionChangedListener, IDoubleClickListener, IDialogFieldListener {
+
+ // -- SelectionAdapter --
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {
- doStatusUpdate();
- if (fCurrStatus.isOK())
- buttonPressed(IDialogConstants.OK_ID);
- }
-
- // -- ISelectionChangedListener --
- @Override
+ doStatusUpdate();
+ if (fCurrStatus.isOK())
+ buttonPressed(IDialogConstants.OK_ID);
+ }
+
+ // -- ISelectionChangedListener --
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
- setResult(((IStructuredSelection) event.getSelection()).toList());
- ISelection sel = event.getSelection();
- if (sel instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) sel).getFirstElement();
- if (obj instanceof ICElement) {
- ICElement elem = (ICElement) obj;
- IPath path = elem.getPath();
- String fileName = fFileNameDialogField.getText();
- String folderName = fFolderNameDialogField.getText();
- if (elem instanceof ICContainer || elem instanceof ICProject) {
- folderName = path.toString();
- } else {
- folderName = path.removeLastSegments(1).toString();
- fileName = path.lastSegment();
- }
- setPathFields(folderName, fileName);
- }
- }
- doStatusUpdate();
- }
-
- // -- IDoubleClickListener --
- @Override
+ setResult(((IStructuredSelection) event.getSelection()).toList());
+ ISelection sel = event.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ Object obj = ((IStructuredSelection) sel).getFirstElement();
+ if (obj instanceof ICElement) {
+ ICElement elem = (ICElement) obj;
+ IPath path = elem.getPath();
+ String fileName = fFileNameDialogField.getText();
+ String folderName = fFolderNameDialogField.getText();
+ if (elem instanceof ICContainer || elem instanceof ICProject) {
+ folderName = path.toString();
+ } else {
+ folderName = path.removeLastSegments(1).toString();
+ fileName = path.lastSegment();
+ }
+ setPathFields(folderName, fileName);
+ }
+ }
+ doStatusUpdate();
+ }
+
+ // -- IDoubleClickListener --
+ @Override
public void doubleClick(DoubleClickEvent event) {
- doStatusUpdate();
-
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection) {
- Object item = ((IStructuredSelection)selection).getFirstElement();
- if (fCurrStatus.getSeverity() != IStatus.ERROR) {
- if (item instanceof ITranslationUnit) {
- setResult(((IStructuredSelection)selection).toList());
- close();
- return;
- }
- }
- if (fViewer.getExpandedState(item))
- fViewer.collapseToLevel(item, 1);
- else
- fViewer.expandToLevel(item, 1);
- }
- }
-
- // -- IDialogFieldListener --
- @Override
+ doStatusUpdate();
+
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object item = ((IStructuredSelection) selection).getFirstElement();
+ if (fCurrStatus.getSeverity() != IStatus.ERROR) {
+ if (item instanceof ITranslationUnit) {
+ setResult(((IStructuredSelection) selection).toList());
+ close();
+ return;
+ }
+ }
+ if (fViewer.getExpandedState(item))
+ fViewer.collapseToLevel(item, 1);
+ else
+ fViewer.expandToLevel(item, 1);
+ }
+ }
+
+ // -- IDialogFieldListener --
+ @Override
public void dialogFieldChanged(DialogField field) {
- if (field == fFolderNameDialogField) {
- fFolderNameStatus = folderNameChanged();
- fFileNameStatus = fileNameChanged();
- } else if (field == fFileNameDialogField) {
- fFileNameStatus = fileNameChanged();
- }
- doStatusUpdate();
- }
- }
-
- static final Class<?>[] FILTER_TYPES = new Class[] {
- ICModel.class,
- ICProject.class,
- ICContainer.class,
- ITranslationUnit.class
- };
-
- private final class Filter extends TypedViewerFilter {
-
- private Filter() {
- super(FILTER_TYPES);
- }
-
- @Override
+ if (field == fFolderNameDialogField) {
+ fFolderNameStatus = folderNameChanged();
+ fFileNameStatus = fileNameChanged();
+ } else if (field == fFileNameDialogField) {
+ fFileNameStatus = fileNameChanged();
+ }
+ doStatusUpdate();
+ }
+ }
+
+ static final Class<?>[] FILTER_TYPES = new Class[] { ICModel.class, ICProject.class, ICContainer.class,
+ ITranslationUnit.class };
+
+ private final class Filter extends TypedViewerFilter {
+
+ private Filter() {
+ super(FILTER_TYPES);
+ }
+
+ @Override
public boolean select(Viewer viewer, Object parent, Object obj) {
- if (obj instanceof ICElement) {
- ICElement elem = (ICElement)obj;
- if (!(fInput instanceof ICModel)) {
- return elem.getCProject().equals(fInput.getCProject());
- }
- return true;
- }
- return super.select(viewer, parent, obj);
- }
- }
-
- /**
- * Constructs an instance of <code>ElementTreeSelectionDialog</code>.
- *
- * @param parent
- * The parent shell for the dialog
- */
- public SourceFileSelectionDialog(Shell parent) {
- super(parent);
-
- fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- fInput = CoreModel.create(fWorkspaceRoot);
-
- fFolderNameDialogField = new StringDialogField();
- fFolderNameDialogField.setDialogFieldListener(fFieldsAdapter);
- fFolderNameDialogField.setLabelText(NewClassWizardMessages.SourceFileSelectionDialog_folderName_label);
-
- fFileNameDialogField = new StringDialogField();
- fFileNameDialogField.setDialogFieldListener(fFieldsAdapter);
- fFileNameDialogField.setLabelText(NewClassWizardMessages.SourceFileSelectionDialog_fileName_label);
-
+ if (obj instanceof ICElement) {
+ ICElement elem = (ICElement) obj;
+ if (!(fInput instanceof ICModel)) {
+ return elem.getCProject().equals(fInput.getCProject());
+ }
+ return true;
+ }
+ return super.select(viewer, parent, obj);
+ }
+ }
+
+ /**
+ * Constructs an instance of <code>ElementTreeSelectionDialog</code>.
+ *
+ * @param parent
+ * The parent shell for the dialog
+ */
+ public SourceFileSelectionDialog(Shell parent) {
+ super(parent);
+
+ fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ fInput = CoreModel.create(fWorkspaceRoot);
+
+ fFolderNameDialogField = new StringDialogField();
+ fFolderNameDialogField.setDialogFieldListener(fFieldsAdapter);
+ fFolderNameDialogField.setLabelText(NewClassWizardMessages.SourceFileSelectionDialog_folderName_label);
+
+ fFileNameDialogField = new StringDialogField();
+ fFileNameDialogField.setDialogFieldListener(fFieldsAdapter);
+ fFileNameDialogField.setLabelText(NewClassWizardMessages.SourceFileSelectionDialog_fileName_label);
+
setResult(new ArrayList<Object>(0));
- setStatusLineAboveButtons(true);
-
- int shellStyle = getShellStyle();
- setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
- }
-
- /**
- * Sets the tree input.
- *
- * @param input
- * the tree input.
- */
- public void setInput(ICElement input) {
- fInput = input;
- }
-
- protected void doStatusUpdate() {
+ setStatusLineAboveButtons(true);
+
+ int shellStyle = getShellStyle();
+ setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
+ }
+
+ /**
+ * Sets the tree input.
+ *
+ * @param input
+ * the tree input.
+ */
+ public void setInput(ICElement input) {
+ fInput = input;
+ }
+
+ protected void doStatusUpdate() {
// status of all used components
- IStatus[] status = new IStatus[] {
- fFolderNameStatus,
- fFileNameStatus
- };
-
+ IStatus[] status = new IStatus[] { fFolderNameStatus, fFileNameStatus };
+
// the mode severe status will be displayed and the ok button enabled/disabled.
updateStatus(status);
}
-
+
/**
* Updates the status line and the ok button according to the given status
- *
+ *
* @param status status to apply
*/
@Override
protected void updateStatus(IStatus status) {
fCurrStatus = status;
- super.updateStatus(status);
+ super.updateStatus(status);
}
-
+
/**
* Updates the status line and the ok button according to the status evaluate from
- * an array of status. The most severe error is taken. In case that two status with
+ * an array of status. The most severe error is taken. In case that two status with
* the same severity exists, the status with lower index is taken.
- *
+ *
* @param status the array of status
*/
protected void updateStatus(IStatus[] status) {
updateStatus(StatusUtil.getMostSevere(status));
}
-
+
IStatus folderNameChanged() {
- StatusInfo status = new StatusInfo();
-
+ StatusInfo status = new StatusInfo();
+
fCurrentFolder = null;
- String str = fFolderNameDialogField.getText();
+ String str = fFolderNameDialogField.getText();
if (str.length() == 0) {
- status.setError(NewClassWizardMessages.SourceFileSelectionDialog_error_EnterFolderName);
+ status.setError(NewClassWizardMessages.SourceFileSelectionDialog_error_EnterFolderName);
return status;
}
@@ -273,41 +266,42 @@ public class SourceFileSelectionDialog extends SelectionStatusDialog {
if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
IProject proj = res.getProject();
if (!proj.isOpen()) {
- status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFolder, str));
+ status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFolder, str));
return status;
}
- ICElement e = CoreModel.getDefault().create(res.getFullPath());
- fCurrentFolder = CModelUtil.getSourceFolder(e);
+ ICElement e = CoreModel.getDefault().create(res.getFullPath());
+ fCurrentFolder = CModelUtil.getSourceFolder(e);
if (fCurrentFolder == null) {
- status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotASourceFolder, str));
+ status.setError(
+ NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotASourceFolder, str));
return status;
}
- if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+ if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
if (resType == IResource.PROJECT) {
- status.setError(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotACProject);
+ status.setError(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotACProject);
return status;
}
- status.setWarning(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotInACProject);
+ status.setWarning(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotInACProject);
}
} else {
- status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFolder, str));
+ status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFolder, str));
return status;
}
} else {
- status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_FolderDoesNotExist, str));
+ status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_FolderDoesNotExist, str));
return status;
}
- return status;
+ return status;
}
IStatus fileNameChanged() {
- StatusInfo status = new StatusInfo();
-
- fCurrentFileString = null;
+ StatusInfo status = new StatusInfo();
+
+ fCurrentFileString = null;
ICElement existingFile = null;
- String str = fFileNameDialogField.getText();
+ String str = fFileNameDialogField.getText();
if (str.length() == 0) {
- status.setError(NewClassWizardMessages.SourceFileSelectionDialog_error_EnterFileName);
+ status.setError(NewClassWizardMessages.SourceFileSelectionDialog_error_EnterFileName);
return status;
}
@@ -322,252 +316,256 @@ public class SourceFileSelectionDialog extends SelectionStatusDialog {
if (resType == IResource.FILE) {
IProject proj = res.getProject();
if (!proj.isOpen()) {
- status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFile, str));
+ status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFile, str));
return status;
}
- ICElement e = CoreModel.getDefault().create(res.getFullPath());
- if (e instanceof ITranslationUnit) {
- existingFile = e;
- }
+ ICElement e = CoreModel.getDefault().create(res.getFullPath());
+ if (e instanceof ITranslationUnit) {
+ existingFile = e;
+ }
if (existingFile == null) {
- status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotASourceFile, str));
+ status.setError(
+ NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotASourceFile, str));
return status;
}
- if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
- status.setWarning(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotInACProject);
+ if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+ status.setWarning(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotInACProject);
}
} else {
- status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFile, str));
+ status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFile, str));
return status;
}
}
}
if (existingFile != null) {
- status.setWarning(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_warning_SourceFileExists, str));
+ status.setWarning(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_warning_SourceFileExists, str));
}
fCurrentFileString = str;
- return status;
+ return status;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#open()
- */
- @Override
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#open()
+ */
+ @Override
public int open() {
- super.open();
- return getReturnCode();
- }
-
- /**
- * Handles cancel button pressed event.
- */
- @Override
+ super.open();
+ return getReturnCode();
+ }
+
+ /**
+ * Handles cancel button pressed event.
+ */
+ @Override
protected void cancelPressed() {
- setResult(null);
- super.cancelPressed();
- }
-
- /*
- * @see SelectionStatusDialog#computeResult()
- */
- @Override
+ setResult(null);
+ super.cancelPressed();
+ }
+
+ /*
+ * @see SelectionStatusDialog#computeResult()
+ */
+ @Override
protected void computeResult() {
- setResult(((IStructuredSelection) fViewer.getSelection()).toList());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#create()
- */
- @Override
+ setResult(((IStructuredSelection) fViewer.getSelection()).toList());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#create()
+ */
+ @Override
public void create() {
- BusyIndicator.showWhile(null, new Runnable() {
- @Override
+ BusyIndicator.showWhile(null, new Runnable() {
+ @Override
public void run() {
- superCreate();
- fViewer.setSelection(new StructuredSelection(getInitialElementSelections()), true);
- setPathFields(fInitialFolderName, fInitialFileName);
- fFileNameDialogField.setFocus();
- doStatusUpdate();
- }
- });
- }
- void superCreate() {
- super.create();
- }
-
- /*
- * @see Dialog#createDialogArea(Composite)
- */
- @Override
+ superCreate();
+ fViewer.setSelection(new StructuredSelection(getInitialElementSelections()), true);
+ setPathFields(fInitialFolderName, fInitialFileName);
+ fFileNameDialogField.setFocus();
+ doStatusUpdate();
+ }
+ });
+ }
+
+ void superCreate() {
+ super.create();
+ }
+
+ /*
+ * @see Dialog#createDialogArea(Composite)
+ */
+ @Override
protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- // Label messageLabel = createMessageArea(composite);
- int nColumns = 4;
- fFolderNameDialogField.doFillIntoGrid(composite, nColumns - 1);
- DialogField.createEmptySpace(composite);
- LayoutUtil.setWidthHint(fFolderNameDialogField.getTextControl(null), getMaxFieldWidth());
-
- TreeViewer treeViewer = createTreeViewer(composite);
-
- GridData data = new GridData(GridData.FILL_BOTH);
- data.widthHint = convertWidthInCharsToPixels(fWidth);
- data.heightHint = convertHeightInCharsToPixels(fHeight);
-
- Tree treeWidget = treeViewer.getTree();
- treeWidget.setLayoutData(data);
- treeWidget.setFont(parent.getFont());
-
- fFileNameDialogField.doFillIntoGrid(composite, nColumns - 1);
- DialogField.createEmptySpace(composite);
- LayoutUtil.setWidthHint(fFileNameDialogField.getTextControl(null), getMaxFieldWidth());
-
- return composite;
- }
-
- /**
- * Returns the recommended maximum width for text fields (in pixels). This
- * method requires that createContent has been called before this method is
- * call. Subclasses may override to change the maximum width for text
- * fields.
- *
- * @return the recommended maximum width for text fields.
- */
- protected int getMaxFieldWidth() {
- return convertWidthInCharsToPixels(60);
- }
-
- /**
- * Creates the tree viewer.
- *
- * @param parent
- * the parent composite
- * @return the tree viewer
- */
- protected TreeViewer createTreeViewer(Composite parent) {
- int style = (SWT.BORDER | SWT.SINGLE);
-
- fViewer = new TreeViewer(new Tree(parent, style));
- fViewer.setContentProvider(fContentProvider);
- fViewer.setLabelProvider(fLabelProvider);
- fViewer.addSelectionChangedListener(fFieldsAdapter);
-
- fViewer.setSorter(new CElementSorter());
- fViewer.addFilter(new Filter());
-
- Tree tree = fViewer.getTree();
- tree.addSelectionListener(fFieldsAdapter);
- fViewer.addDoubleClickListener(fFieldsAdapter);
-
- fViewer.setInput(fInput.getCModel());
-
- return fViewer;
- }
-
- /**
- * Returns the tree viewer.
- *
- * @return the tree viewer
- */
- protected TreeViewer getTreeViewer() {
- return fViewer;
- }
-
- /**
- * @see org.eclipse.jface.window.Window#handleShellCloseEvent()
- */
- @Override
+ Composite composite = (Composite) super.createDialogArea(parent);
+ // Label messageLabel = createMessageArea(composite);
+ int nColumns = 4;
+ fFolderNameDialogField.doFillIntoGrid(composite, nColumns - 1);
+ DialogField.createEmptySpace(composite);
+ LayoutUtil.setWidthHint(fFolderNameDialogField.getTextControl(null), getMaxFieldWidth());
+
+ TreeViewer treeViewer = createTreeViewer(composite);
+
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = convertWidthInCharsToPixels(fWidth);
+ data.heightHint = convertHeightInCharsToPixels(fHeight);
+
+ Tree treeWidget = treeViewer.getTree();
+ treeWidget.setLayoutData(data);
+ treeWidget.setFont(parent.getFont());
+
+ fFileNameDialogField.doFillIntoGrid(composite, nColumns - 1);
+ DialogField.createEmptySpace(composite);
+ LayoutUtil.setWidthHint(fFileNameDialogField.getTextControl(null), getMaxFieldWidth());
+
+ return composite;
+ }
+
+ /**
+ * Returns the recommended maximum width for text fields (in pixels). This
+ * method requires that createContent has been called before this method is
+ * call. Subclasses may override to change the maximum width for text
+ * fields.
+ *
+ * @return the recommended maximum width for text fields.
+ */
+ protected int getMaxFieldWidth() {
+ return convertWidthInCharsToPixels(60);
+ }
+
+ /**
+ * Creates the tree viewer.
+ *
+ * @param parent
+ * the parent composite
+ * @return the tree viewer
+ */
+ protected TreeViewer createTreeViewer(Composite parent) {
+ int style = (SWT.BORDER | SWT.SINGLE);
+
+ fViewer = new TreeViewer(new Tree(parent, style));
+ fViewer.setContentProvider(fContentProvider);
+ fViewer.setLabelProvider(fLabelProvider);
+ fViewer.addSelectionChangedListener(fFieldsAdapter);
+
+ fViewer.setSorter(new CElementSorter());
+ fViewer.addFilter(new Filter());
+
+ Tree tree = fViewer.getTree();
+ tree.addSelectionListener(fFieldsAdapter);
+ fViewer.addDoubleClickListener(fFieldsAdapter);
+
+ fViewer.setInput(fInput.getCModel());
+
+ return fViewer;
+ }
+
+ /**
+ * Returns the tree viewer.
+ *
+ * @return the tree viewer
+ */
+ protected TreeViewer getTreeViewer() {
+ return fViewer;
+ }
+
+ /**
+ * @see org.eclipse.jface.window.Window#handleShellCloseEvent()
+ */
+ @Override
protected void handleShellCloseEvent() {
- super.handleShellCloseEvent();
-
- //Handle the closing of the shell by selecting the close icon
- if (getReturnCode() == CANCEL)
- setResult(null);
- }
-
- public String getFolderName() {
- if (fCurrentFolder != null) {
- return fCurrentFolder.getPath().toString();
- }
- return null;
- }
-
- public String getFileName() {
- return fCurrentFileString;
- }
-
- public IPath getFilePath() {
- IPath path = null;
- if (fCurrentFolder != null) {
- path = fCurrentFolder.getPath();
- if (fCurrentFileString != null)
- path = path.append(fCurrentFileString);
- } else if (fCurrentFileString != null) {
- path = new Path(fCurrentFileString);
- }
- return path;
- }
-
- void setPathFields(String folderName, String fileName) {
- fFolderNameDialogField.setTextWithoutUpdate(folderName != null ? folderName : ""); //$NON-NLS-1$
- fFileNameDialogField.setTextWithoutUpdate(fileName != null ? fileName : ""); //$NON-NLS-1$
+ super.handleShellCloseEvent();
+
+ //Handle the closing of the shell by selecting the close icon
+ if (getReturnCode() == CANCEL)
+ setResult(null);
+ }
+
+ public String getFolderName() {
+ if (fCurrentFolder != null) {
+ return fCurrentFolder.getPath().toString();
+ }
+ return null;
+ }
+
+ public String getFileName() {
+ return fCurrentFileString;
+ }
+
+ public IPath getFilePath() {
+ IPath path = null;
+ if (fCurrentFolder != null) {
+ path = fCurrentFolder.getPath();
+ if (fCurrentFileString != null)
+ path = path.append(fCurrentFileString);
+ } else if (fCurrentFileString != null) {
+ path = new Path(fCurrentFileString);
+ }
+ return path;
+ }
+
+ void setPathFields(String folderName, String fileName) {
+ fFolderNameDialogField.setTextWithoutUpdate(folderName != null ? folderName : ""); //$NON-NLS-1$
+ fFileNameDialogField.setTextWithoutUpdate(fileName != null ? fileName : ""); //$NON-NLS-1$
fFolderNameStatus = folderNameChanged();
fFileNameStatus = fileNameChanged();
- }
-
- /**
- * Sets the initial selection. Convenience method.
- */
- public void setInitialSelection(String folderName, String fileName) {
- fInitialFileName = (fileName != null && fileName.length() > 0) ? fileName : null;
- fInitialFolderName = null;
- if (folderName != null && folderName.length() > 0) {
- // find a folder that actually exists
- IPath initialFolderPath = new Path(folderName);
- final IPath folderPath = PathUtil.getValidEnclosingFolder(initialFolderPath);
- if (folderPath != null) {
- fInitialFolderName = folderPath.toString();
+ }
+
+ /**
+ * Sets the initial selection. Convenience method.
+ */
+ public void setInitialSelection(String folderName, String fileName) {
+ fInitialFileName = (fileName != null && fileName.length() > 0) ? fileName : null;
+ fInitialFolderName = null;
+ if (folderName != null && folderName.length() > 0) {
+ // find a folder that actually exists
+ IPath initialFolderPath = new Path(folderName);
+ final IPath folderPath = PathUtil.getValidEnclosingFolder(initialFolderPath);
+ if (folderPath != null) {
+ fInitialFolderName = folderPath.toString();
if (fInput != null) {
- final ICElement[] foundElem = {/*base_folder*/ null, /*exact_folder*/ null, /*exact_file*/ null};
- try {
- fInput.accept(new ICElementVisitor() {
- @Override
+ final ICElement[] foundElem = { /*base_folder*/ null, /*exact_folder*/ null, /*exact_file*/ null };
+ try {
+ fInput.accept(new ICElementVisitor() {
+ @Override
public boolean visit(ICElement elem) {
- IPath path = elem.getPath();
- if (path.isPrefixOf(folderPath)) {
- if (foundElem[0] == null || path.segmentCount() > foundElem[0].getPath().segmentCount()) {
- foundElem[0] = elem; /*base_folder*/
- }
- if (path.equals(folderPath)) {
- foundElem[1] = elem; /*exact_folder*/
- if (fInitialFileName == null)
- return false; // no need to search children
- } else if (fInitialFileName != null && elem.getElementName().equals(fInitialFileName)) {
- foundElem[2] = elem; /*exact_file*/
- return false; // no need to search children
- }
- return true;
- }
- return false;
- }
- });
-
- ICElement selectedElement = foundElem[2]; /*exact_file*/
- if (selectedElement == null)
- selectedElement = foundElem[1]; /*exact_folder*/
- if (selectedElement == null)
- selectedElement = foundElem[0]; /*base_folder*/
-
- if (selectedElement != null) {
- setInitialSelections(new Object[] { selectedElement });
- }
- } catch (CoreException e) {
- }
- }
- }
- }
- }
+ IPath path = elem.getPath();
+ if (path.isPrefixOf(folderPath)) {
+ if (foundElem[0] == null
+ || path.segmentCount() > foundElem[0].getPath().segmentCount()) {
+ foundElem[0] = elem; /*base_folder*/
+ }
+ if (path.equals(folderPath)) {
+ foundElem[1] = elem; /*exact_folder*/
+ if (fInitialFileName == null)
+ return false; // no need to search children
+ } else if (fInitialFileName != null
+ && elem.getElementName().equals(fInitialFileName)) {
+ foundElem[2] = elem; /*exact_file*/
+ return false; // no need to search children
+ }
+ return true;
+ }
+ return false;
+ }
+ });
+
+ ICElement selectedElement = foundElem[2]; /*exact_file*/
+ if (selectedElement == null)
+ selectedElement = foundElem[1]; /*exact_folder*/
+ if (selectedElement == null)
+ selectedElement = foundElem[0]; /*base_folder*/
+
+ if (selectedElement != null) {
+ setInitialSelections(new Object[] { selectedElement });
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
index 80fc3dee1ba..cacac52cb17 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
@@ -37,41 +37,41 @@ import org.eclipse.swt.widgets.Table;
public class CheckedListDialogField<T> extends ListDialogField<T> {
private int fCheckAllButtonIndex;
private int fUncheckAllButtonIndex;
-
+
private List<T> fCheckElements;
public CheckedListDialogField(IListAdapter<T> adapter, String[] customButtonLabels, IBaseLabelProvider lprovider) {
super(adapter, customButtonLabels, lprovider);
- fCheckElements= new ArrayList<T>();
-
- fCheckAllButtonIndex= -1;
- fUncheckAllButtonIndex= -1;
+ fCheckElements = new ArrayList<T>();
+
+ fCheckAllButtonIndex = -1;
+ fUncheckAllButtonIndex = -1;
}
/**
* Sets the index of the 'check' button in the button label array passed in the constructor.
* The behaviour of the button marked as the check button will then be handled internally.
* (enable state, button invocation behaviour)
- */
+ */
public void setCheckAllButtonIndex(int checkButtonIndex) {
Assert.isTrue(checkButtonIndex < fButtonLabels.length);
- fCheckAllButtonIndex= checkButtonIndex;
+ fCheckAllButtonIndex = checkButtonIndex;
}
/**
* Sets the index of the 'uncheck' button in the button label array passed in the constructor.
* The behaviour of the button marked as the uncheck button will then be handled internally.
* (enable state, button invocation behaviour)
- */
+ */
public void setUncheckAllButtonIndex(int uncheckButtonIndex) {
Assert.isTrue(uncheckButtonIndex < fButtonLabels.length);
- fUncheckAllButtonIndex= uncheckButtonIndex;
+ fUncheckAllButtonIndex = uncheckButtonIndex;
}
@Override
protected TableViewer createTableViewer(Composite parent) {
- Table table= new Table(parent, SWT.CHECK + getListStyle());
- CheckboxTableViewer tableViewer= new CheckboxTableViewer(table);
+ Table table = new Table(parent, SWT.CHECK + getListStyle());
+ CheckboxTableViewer tableViewer = new CheckboxTableViewer(table);
tableViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent e) {
@@ -79,35 +79,35 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
}
});
return tableViewer;
- }
+ }
@Override
public Control getListControl(Composite parent) {
- Control control= super.getListControl(parent);
+ Control control = super.getListControl(parent);
if (parent != null) {
- ((CheckboxTableViewer)fTable).setCheckedElements(fCheckElements.toArray());
+ ((CheckboxTableViewer) fTable).setCheckedElements(fCheckElements.toArray());
}
return control;
- }
-
+ }
+
/*
* @see DialogField#dialogFieldChanged
* Hooks in to get element changes to update check model.
*/
@Override
public void dialogFieldChanged() {
- for (int i= fCheckElements.size() -1; i >= 0; i--) {
+ for (int i = fCheckElements.size() - 1; i >= 0; i--) {
if (!fElements.contains(fCheckElements.get(i))) {
fCheckElements.remove(i);
}
}
super.dialogFieldChanged();
- }
-
+ }
+
private void checkStateChanged() {
// Call super and do not update check model
super.dialogFieldChanged();
- }
+ }
/**
* Gets the checked elements.
@@ -115,43 +115,43 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
public List<T> getCheckedElements() {
return new ArrayList<T>(fCheckElements);
}
-
+
/**
* Returns the number of checked elements.
*/
public int getCheckedSize() {
return fCheckElements.size();
}
-
+
/**
* Returns true if the element is checked.
*/
public boolean isChecked(Object obj) {
return fCheckElements.contains(obj);
- }
-
+ }
+
/**
* Sets the checked elements.
- */
+ */
public void setCheckedElements(Collection<T> list) {
- fCheckElements= new ArrayList<T>(list);
+ fCheckElements = new ArrayList<T>(list);
if (fTable != null) {
- ((CheckboxTableViewer)fTable).setCheckedElements(list.toArray());
+ ((CheckboxTableViewer) fTable).setCheckedElements(list.toArray());
}
checkStateChanged();
}
/**
* Sets the checked state of an element.
- */
+ */
public void setChecked(T object, boolean state) {
setCheckedWithoutUpdate(object, state);
checkStateChanged();
}
-
+
/**
* Sets the checked state of an element. No dialog changed listener is informed.
- */
+ */
public void setCheckedWithoutUpdate(T object, boolean state) {
if (state) {
if (!fCheckElements.contains(object)) {
@@ -167,10 +167,10 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
/**
* Sets the check state of all elements
- */
+ */
public void checkAll(boolean state) {
if (state) {
- fCheckElements= getElements();
+ fCheckElements = getElements();
} else {
fCheckElements.clear();
}
@@ -179,27 +179,27 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
}
checkStateChanged();
}
-
+
void doCheckStateChanged(CheckStateChangedEvent e) {
if (e.getChecked()) {
@SuppressWarnings("unchecked")
- T elem= (T) e.getElement();
+ T elem = (T) e.getElement();
fCheckElements.add(elem);
} else {
fCheckElements.remove(e.getElement());
- }
+ }
checkStateChanged();
}
-
+
@Override
public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
- boolean wasChecked= isChecked(oldElement);
+ boolean wasChecked = isChecked(oldElement);
super.replaceElement(oldElement, newElement);
setChecked(newElement, wasChecked);
}
-
+
// ------ enable / disable management
-
+
/*
* @see ListDialogField#getManagedButtonState
*/
@@ -211,11 +211,11 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
return !fElements.isEmpty();
}
return super.getManagedButtonState(sel, index);
- }
+ }
/*
* @see ListDialogField#extraButtonPressed
- */
+ */
@Override
protected boolean managedButtonPressed(int index) {
if (index == fCheckAllButtonIndex) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
index 3ba8783d190..36008944e1a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
@@ -27,57 +27,57 @@ import org.eclipse.swt.widgets.Label;
* Dialog field containing a label and a combo control.
*/
public class ComboDialogField extends DialogField {
-
+
private String fText;
private int fSelectionIndex;
private String[] fItems;
private Combo fComboControl;
private ModifyListener fModifyListener;
private int fFlags;
-
+
public ComboDialogField(int flags) {
super();
- fText= ""; //$NON-NLS-1$
- fItems= new String[0];
- fFlags= flags;
- fSelectionIndex= -1;
+ fText = ""; //$NON-NLS-1$
+ fItems = new String[0];
+ fFlags = flags;
+ fSelectionIndex = -1;
}
-
+
// ------- layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
- Combo combo= getComboControl(parent);
+ Combo combo = getComboControl(parent);
combo.setLayoutData(gridDataForCombo(nColumns - 1));
-
+
return new Control[] { label, combo };
- }
+ }
/*
* @see DialogField#getNumberOfControls
*/
@Override
public int getNumberOfControls() {
- return 2;
+ return 2;
}
-
+
protected static GridData gridDataForCombo(int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = false;
+ gd.horizontalSpan = span;
return gd;
- }
-
+ }
+
// ------- focus methods
-
+
/*
* @see DialogField#setFocus
*/
@@ -88,34 +88,35 @@ public class ComboDialogField extends DialogField {
}
return true;
}
-
- // ------- ui creation
+
+ // ------- ui creation
/**
* Creates or returns the created combo control.
* @param parent The parent composite or <code>null</code> when the widget has
* already been created.
- */
+ */
public Combo getComboControl(Composite parent) {
if (fComboControl == null) {
assertCompositeNotNull(parent);
- fModifyListener= new ModifyListener() {
+ fModifyListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
doModifyText(e);
}
};
- SelectionListener selectionListener= new SelectionListener() {
+ SelectionListener selectionListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
doSelectionChanged(e);
}
-
+
@Override
- public void widgetDefaultSelected(SelectionEvent e) { }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
};
-
- fComboControl= new Combo(parent, fFlags);
+
+ fComboControl = new Combo(parent, fFlags);
// moved up due to 1GEUNW2
fComboControl.setItems(fItems);
if (fSelectionIndex != -1) {
@@ -129,107 +130,106 @@ public class ComboDialogField extends DialogField {
fComboControl.setEnabled(isEnabled());
}
return fComboControl;
- }
-
+ }
+
protected void doModifyText(ModifyEvent e) {
if (isOkToUse(fComboControl)) {
- fText= fComboControl.getText();
- fSelectionIndex= fComboControl.getSelectionIndex();
+ fText = fComboControl.getText();
+ fSelectionIndex = fComboControl.getSelectionIndex();
}
dialogFieldChanged();
}
-
+
protected void doSelectionChanged(SelectionEvent e) {
if (isOkToUse(fComboControl)) {
- fItems= fComboControl.getItems();
- fText= fComboControl.getText();
- fSelectionIndex= fComboControl.getSelectionIndex();
+ fItems = fComboControl.getItems();
+ fText = fComboControl.getText();
+ fSelectionIndex = fComboControl.getSelectionIndex();
}
- dialogFieldChanged();
+ dialogFieldChanged();
}
-
+
// ------ enable / disable management
-
+
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
- super.updateEnableState();
+ super.updateEnableState();
if (isOkToUse(fComboControl)) {
fComboControl.setEnabled(isEnabled());
- }
- }
-
- // ------ text access
-
+ }
+ }
+
+ // ------ text access
+
/**
* Gets the combo items.
- */
+ */
public String[] getItems() {
return fItems;
}
-
+
/**
* Sets the combo items. Triggers a dialog-changed event.
*/
public void setItems(String[] items) {
- fItems= items;
+ fItems = items;
if (isOkToUse(fComboControl)) {
fComboControl.setItems(items);
}
dialogFieldChanged();
}
-
+
/**
* Gets the text.
- */
+ */
public String getText() {
return fText;
}
-
+
/**
* Sets the text. Triggers a dialog-changed event.
*/
public void setText(String text) {
- fText= text;
+ fText = text;
if (isOkToUse(fComboControl)) {
fComboControl.setText(text);
} else {
dialogFieldChanged();
- }
+ }
}
/**
* Selects an item.
- */
+ */
public void selectItem(int index) {
if (isOkToUse(fComboControl)) {
fComboControl.select(index);
} else {
if (index >= 0 && index < fItems.length) {
- fText= fItems[index];
- fSelectionIndex= index;
+ fText = fItems[index];
+ fSelectionIndex = index;
}
}
dialogFieldChanged();
}
-
+
public int getSelectionIndex() {
return fSelectionIndex;
}
-
/**
* Sets the text without triggering a dialog-changed event.
*/
public void setTextWithoutUpdate(String text) {
- fText= text;
+ fText = text;
if (isOkToUse(fComboControl)) {
fComboControl.removeModifyListener(fModifyListener);
fComboControl.setText(text);
fComboControl.addModifyListener(fModifyListener);
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
index 7fbe5aeff41..5f06bfa9bc9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -26,44 +26,44 @@ public class DialogField {
private Label fLabel;
protected String fLabelText;
-
+
private IDialogFieldListener fDialogFieldListener;
-
+
private boolean fEnabled;
public DialogField() {
- fEnabled= true;
- fLabel= null;
- fLabelText= ""; //$NON-NLS-1$
+ fEnabled = true;
+ fLabel = null;
+ fLabelText = ""; //$NON-NLS-1$
}
-
+
/**
* Sets the label of the dialog field.
*/
public void setLabelText(String labeltext) {
- fLabelText= labeltext;
+ fLabelText = labeltext;
}
-
+
// ------ change listener
-
+
/**
* Defines the listener for this dialog field.
- */
+ */
public final void setDialogFieldListener(IDialogFieldListener listener) {
- fDialogFieldListener= listener;
+ fDialogFieldListener = listener;
}
/**
* Programmatical invocation of a dialog field change.
- */
+ */
public void dialogFieldChanged() {
if (fDialogFieldListener != null) {
fDialogFieldListener.dialogFieldChanged(this);
}
- }
-
+ }
+
// ------- focus management
-
+
/**
* Tries to set the focus to the dialog field.
* Returns <code>true</code> if the dialog field can take focus.
@@ -75,22 +75,20 @@ public class DialogField {
/**
* Posts <code>setFocus</code> to the display event queue.
- */
+ */
public void postSetFocusOnDialogField(Display display) {
if (display != null) {
- display.asyncExec(
- new Runnable() {
- @Override
- public void run() {
- setFocus();
- }
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ setFocus();
}
- );
+ });
}
- }
-
+ }
+
// ------- layout helpers
-
+
/**
* Creates all controls of the dialog field and fills it to a composite.
* The composite is assumed to have <code>MGridLayout</code> as
@@ -100,48 +98,48 @@ public class DialogField {
*/
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(nColumns));
-
+
return new Control[] { label };
}
-
+
/**
* Returns the number of columns of the dialog field.
* To be reimplemented by dialog field implementors.
*/
public int getNumberOfControls() {
- return 1;
- }
-
+ return 1;
+ }
+
protected static GridData gridDataForLabel(int span) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= span;
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = span;
return gd;
}
-
+
// ------- ui creation
/**
* Creates or returns the created label widget.
* @param parent The parent composite or <code>null</code> if the widget has
* already been created.
- */
+ */
public Label getLabelControl(Composite parent) {
if (fLabel == null) {
assertCompositeNotNull(parent);
-
- fLabel= new Label(parent, SWT.LEFT);
+
+ fLabel = new Label(parent, SWT.LEFT);
fLabel.setFont(parent.getFont());
- fLabel.setEnabled(fEnabled);
+ fLabel.setEnabled(fEnabled);
if (fLabelText != null && !fLabelText.isEmpty()) {
fLabel.setText(fLabelText);
} else {
// XXX: to avoid a 16 pixel wide empty label - revisit
fLabel.setText("."); //$NON-NLS-1$
fLabel.setVisible(false);
- }
+ }
}
return fLabel;
}
@@ -150,7 +148,7 @@ public class DialogField {
* Creates a spacer control.
*
* @param parent The parent composite
- */
+ */
public static Control createEmptySpace(Composite parent) {
return createEmptySpace(parent, 1);
}
@@ -160,39 +158,39 @@ public class DialogField {
* The composite is assumed to have {@link GridLayout} as layout.
*
* @param parent The parent composite
- */
+ */
public static Control createEmptySpace(Composite parent, int span) {
- Label label= new Label(parent, SWT.LEFT);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
- gd.horizontalIndent= 0;
- gd.widthHint= 0;
- gd.heightHint= 0;
+ Label label = new Label(parent, SWT.LEFT);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = false;
+ gd.horizontalSpan = span;
+ gd.horizontalIndent = 0;
+ gd.widthHint = 0;
+ gd.heightHint = 0;
label.setLayoutData(gd);
return label;
}
-
+
/**
* Tests is the control is not <code>null</code> and not disposed.
*/
protected final boolean isOkToUse(Control control) {
return (control != null) && !(control.isDisposed());
}
-
+
// --------- enable / disable management
-
+
/**
* Sets the enable state of the dialog field.
*/
public final void setEnabled(boolean enabled) {
if (enabled != fEnabled) {
- fEnabled= enabled;
+ fEnabled = enabled;
updateEnableState();
}
}
-
+
/**
* Called when the enable state changed.
* To be extended by dialog field implementors.
@@ -205,7 +203,7 @@ public class DialogField {
/**
* Gets the enable state of the dialog field.
- */
+ */
public final boolean isEnabled() {
return fEnabled;
}
@@ -213,12 +211,9 @@ public class DialogField {
protected final void assertCompositeNotNull(Composite comp) {
Assert.isNotNull(comp, "uncreated control requested with composite null"); //$NON-NLS-1$
}
-
+
protected final void assertEnoughColumns(int nColumns) {
Assert.isTrue(nColumns >= getNumberOfControls(), "given number of columns is too small"); //$NON-NLS-1$
}
-
-
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
index bdf3f7a988a..28145614849 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
@@ -14,6 +14,6 @@
package org.eclipse.cdt.internal.ui.wizards.dialogfields;
public interface IDialogFieldListener {
-
+
void dialogFieldChanged(DialogField field);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
index dc079ca1267..f4f8ead0b91 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
@@ -17,20 +17,20 @@ package org.eclipse.cdt.internal.ui.wizards.dialogfields;
* Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code>
*/
public interface IListAdapter<T> {
-
+
/**
* A button from the button bar has been pressed.
*/
void customButtonPressed(ListDialogField<T> field, int index);
-
+
/**
* The selection of the list has changed.
- */
+ */
void selectionChanged(ListDialogField<T> field);
-
+
/**
* En entry in the list has been double clicked
*/
- void doubleClicked(ListDialogField<T> field);
+ void doubleClicked(ListDialogField<T> field);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
index 35c4c235bb6..53ba6774c99 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
@@ -14,6 +14,6 @@
package org.eclipse.cdt.internal.ui.wizards.dialogfields;
public interface IStringButtonAdapter {
-
+
void changeControlPressed(DialogField field);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java
index cea235b352c..1d47c091c6a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java
@@ -19,15 +19,15 @@ import org.eclipse.swt.events.KeyEvent;
* Change listener used by <code>TreeListDialogField</code>
*/
public interface ITreeListAdapter<T> {
-
+
/**
* A button from the button bar has been pressed.
*/
void customButtonPressed(TreeListDialogField<T> field, int index);
-
+
/**
* The selection of the list has changed.
- */
+ */
void selectionChanged(TreeListDialogField<T> field);
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
index b5047867845..7e2cddf2d89 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
@@ -27,9 +27,9 @@ public class LayoutUtil {
* Calculates the number of columns needed by field editors
*/
public static int getNumberOfColumns(DialogField[] editors) {
- int nColumns= 0;
- for (int i= 0; i < editors.length; i++) {
- nColumns= Math.max(editors[i].getNumberOfControls(), nColumns);
+ int nColumns = 0;
+ for (int i = 0; i < editors.length; i++) {
+ nColumns = Math.max(editors[i].getNumberOfControls(), nColumns);
}
return nColumns;
}
@@ -42,11 +42,11 @@ public class LayoutUtil {
Layout layout = composite.getLayout();
return layout instanceof GridLayout ? ((GridLayout) layout).numColumns : 1;
}
-
+
/**
* Creates a composite and fills in the given editors.
* @param labelOnTop Defines if the label of all fields should be on top of the fields
- */
+ */
public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop) {
doDefaultLayout(parent, editors, labelOnTop, 0, 0, 0, 0);
}
@@ -55,10 +55,10 @@ public class LayoutUtil {
* Creates a composite and fills in the given editors.
* @param labelOnTop Defines if the label of all fields should be on top of the fields
* @param minWidth The minimal width of the composite
- * @param minHeight The minimal height of the composite
+ * @param minHeight The minimal height of the composite
*/
- public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop,
- int minWidth, int minHeight) {
+ public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth,
+ int minHeight) {
doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0);
}
@@ -69,88 +69,88 @@ public class LayoutUtil {
* @param minHeight The minimal height of the composite
* @param marginWidth The margin width to be used by the composite
* @param marginHeight The margin height to be used by the composite
- */
- private static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop,
- int minWidth, int minHeight, int marginWidth, int marginHeight) {
- int nCulumns= getNumberOfColumns(editors);
- Control[][] controls= new Control[editors.length][];
- for (int i= 0; i < editors.length; i++) {
- controls[i]= editors[i].doFillIntoGrid(parent, nCulumns);
+ */
+ private static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth,
+ int minHeight, int marginWidth, int marginHeight) {
+ int nCulumns = getNumberOfColumns(editors);
+ Control[][] controls = new Control[editors.length][];
+ for (int i = 0; i < editors.length; i++) {
+ controls[i] = editors[i].doFillIntoGrid(parent, nCulumns);
}
if (labelOnTop) {
nCulumns--;
modifyLabelSpans(controls, nCulumns);
}
- GridLayout layout= new GridLayout();
+ GridLayout layout = new GridLayout();
if (marginWidth != SWT.DEFAULT) {
- layout.marginWidth= marginWidth;
+ layout.marginWidth = marginWidth;
}
if (marginHeight != SWT.DEFAULT) {
- layout.marginHeight= marginHeight;
+ layout.marginHeight = marginHeight;
}
- layout.numColumns= nCulumns;
+ layout.numColumns = nCulumns;
parent.setLayout(layout);
}
-
+
private static void modifyLabelSpans(Control[][] controls, int nCulumns) {
- for (int i= 0; i < controls.length; i++) {
+ for (int i = 0; i < controls.length; i++) {
setHorizontalSpan(controls[i][0], nCulumns);
}
}
-
+
/**
* Sets the span of a control. Assumes that GridData is used.
*/
public static void setHorizontalSpan(Control control, int span) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).horizontalSpan= span;
+ ((GridData) ld).horizontalSpan = span;
} else if (span != 1) {
- GridData gd= new GridData();
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
control.setLayoutData(gd);
}
- }
+ }
/**
* Sets the width hint of a control. Assumes that GridData is used.
*/
public static void setWidthHint(Control control, int widthHint) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).widthHint= widthHint;
+ ((GridData) ld).widthHint = widthHint;
}
}
-
+
/**
* Sets the heigthHint hint of a control. Assumes that GridData is used.
*/
public static void setHeightHint(Control control, int heigthHint) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).heightHint= heigthHint;
+ ((GridData) ld).heightHint = heigthHint;
}
- }
-
+ }
+
/**
* Sets the horizontal indent of a control. Assumes that GridData is used.
*/
public static void setHorizontalIndent(Control control, int horizontalIndent) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).horizontalIndent= horizontalIndent;
+ ((GridData) ld).horizontalIndent = horizontalIndent;
}
}
-
+
/**
* Sets the horizontal alignment of a control. Assumes that GridData is used.
*/
public static void setHorizontalAlignment(Control control, int horizontalAlignment) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).horizontalAlignment= horizontalAlignment;
+ ((GridData) ld).horizontalAlignment = horizontalAlignment;
}
- }
+ }
/**
* Makes a control grab all available horizontal space. Assumes that GridData is used.
@@ -164,9 +164,9 @@ public class LayoutUtil {
* @param value <code>true</code> to grab, <code>false</code> not to grab
*/
public static void setHorizontalGrabbing(Control control, boolean value) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).grabExcessHorizontalSpace= value;
+ ((GridData) ld).grabExcessHorizontalSpace = value;
}
}
@@ -175,9 +175,9 @@ public class LayoutUtil {
* @param value <code>true</code> to grab, <code>false</code> not to grab
*/
public static void setVerticalGrabbing(Control control, boolean value) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).grabExcessVerticalSpace= value;
+ ((GridData) ld).grabExcessVerticalSpace = value;
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
index 0d832164618..9763ea8c313 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
@@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Text;
/**
* This class is part of the NewClassWizard.
- * It handles the Link to file part.
+ * It handles the Link to file part.
*/
public class LinkToFileGroup extends StringButtonDialogField {
protected Listener listener;
@@ -64,56 +64,56 @@ public class LinkToFileGroup extends StringButtonDialogField {
private Label resolvedPathLabelText;
private Label resolvedPathLabelData;
boolean preventDialogFieldChanged = false;
-
+
public LinkToFileGroup(IStringButtonAdapter adapter, Listener listener) {
super(adapter);
this.listener = listener;
this.type = IResource.FILE;
}
-
+
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
//initializeDialogUnits(parent);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
-
- getLinkCheckButtonControl(parent);
- Text text= getTextControl(parent);
+ getLinkCheckButtonControl(parent);
+
+ Text text = getTextControl(parent);
text.setLayoutData(gridDataForText(2));
- Button browseButton = getBrowseButtonControl(parent);
+ Button browseButton = getBrowseButtonControl(parent);
browseButton.setLayoutData(gridDataForButton(browseButton, 1));
-
+
DialogField.createEmptySpace(parent);
resolvedPathLabelText = new Label(parent, SWT.SINGLE);
- resolvedPathLabelText.setText(NewWizardMessages.CreateLinkedResourceGroup_resolvedPathLabel);
- resolvedPathLabelText.setVisible(true);
-
+ resolvedPathLabelText.setText(NewWizardMessages.CreateLinkedResourceGroup_resolvedPathLabel);
+ resolvedPathLabelText.setVisible(true);
+
resolvedPathLabelData = new Label(parent, SWT.SINGLE);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 3;
resolvedPathLabelData.setLayoutData(data);
resolvedPathLabelData.setVisible(true);
-
+
return null;
}
-
+
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 4;
+ return 4;
}
-
- public Button getLinkCheckButtonControl(Composite parent){
- if (linkButton == null){
+
+ public Button getLinkCheckButtonControl(Composite parent) {
+ if (linkButton == null) {
linkButton = new Button(parent, SWT.CHECK);
- linkButton.setText(NewWizardMessages.NewClassWizardPage_files_linkFileButton);
+ linkButton.setText(NewWizardMessages.NewClassWizardPage_files_linkFileButton);
linkButton.setSelection(createLink);
linkButton.setFont(parent.getFont());
SelectionListener selectionListener = new SelectionAdapter() {
@@ -133,12 +133,12 @@ public class LinkToFileGroup extends StringButtonDialogField {
}
return linkButton;
}
-
+
@Override
public String getText() {
return linkTargetField.getText();
}
-
+
@Override
public void setText(String text) {
if (isOkToUse(linkTargetField)) {
@@ -146,12 +146,12 @@ public class LinkToFileGroup extends StringButtonDialogField {
linkTargetField.setText(text);
preventDialogFieldChanged = false;
}
-// dialogFieldChanged();
+ // dialogFieldChanged();
}
-
+
@Override
- public Text getTextControl(Composite parent){
- if (linkTargetField == null){
+ public Text getTextControl(Composite parent) {
+ if (linkTargetField == null) {
assertCompositeNotNull(parent);
linkTargetField = new Text(parent, SWT.BORDER);
linkTargetField.setFont(parent.getFont());
@@ -169,26 +169,26 @@ public class LinkToFileGroup extends StringButtonDialogField {
if (initialLinkTarget != null)
linkTargetField.setText(initialLinkTarget);
}
- return linkTargetField;
+ return linkTargetField;
}
-
- public static GridData gridDataForText(int span){
+
+ public static GridData gridDataForText(int span) {
GridData data = new GridData();
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- data.horizontalAlignment= GridData.FILL;
- data.grabExcessHorizontalSpace= false;
- data.horizontalSpan= span;
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = false;
+ data.horizontalSpan = span;
return data;
}
-
- public Button getBrowseButtonControl(Composite parent){
+
+ public Button getBrowseButtonControl(Composite parent) {
// browse button
- if (browseButton == null){
+ if (browseButton == null) {
assertCompositeNotNull(parent);
browseButton = new Button(parent, SWT.PUSH);
//setButtonLayoutData(browseButton);
browseButton.setFont(parent.getFont());
- browseButton.setText(NewWizardMessages.CreateLinkedResourceGroup_browseButton);
+ browseButton.setText(NewWizardMessages.CreateLinkedResourceGroup_browseButton);
browseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
@@ -202,19 +202,15 @@ public class LinkToFileGroup extends StringButtonDialogField {
/**
* Returns a new status object with the given severity and message.
- *
+ *
* @return a new status object with the given severity and message.
*/
private IStatus createStatus(int severity, String message) {
- return new Status(
- severity,
- CUIPlugin.getPluginId(),
- severity,
- message,
- null);
- }
+ return new Status(severity, CUIPlugin.getPluginId(), severity, message, null);
+ }
+
/**
- * Returns the link target location entered by the user.
+ * Returns the link target location entered by the user.
*
* @return the link target location entered by the user. null if the user
* chose not to create a link.
@@ -240,43 +236,43 @@ public class LinkToFileGroup extends StringButtonDialogField {
String linkTargetName = linkTargetField.getText();
File file = null;
String selection = null;
-
- if ("".equals(linkTargetName) == false) { //$NON-NLS-1$
+
+ if ("".equals(linkTargetName) == false) { //$NON-NLS-1$
file = new File(linkTargetName);
if (file.exists() == false)
file = null;
}
if (type == IResource.FILE) {
FileDialog dialog = new FileDialog(linkTargetField.getShell());
- dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open);
+ dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open);
if (file != null) {
if (file.isFile())
dialog.setFileName(linkTargetName);
else
dialog.setFilterPath(linkTargetName);
}
- selection = dialog.open();
- }
- else {
+ selection = dialog.open();
+ } else {
DirectoryDialog dialog = new DirectoryDialog(linkTargetField.getShell());
- dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open);
+ dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open);
if (file != null) {
if (file.isFile())
linkTargetName = file.getParent();
if (linkTargetName != null)
dialog.setFilterPath(linkTargetName);
}
- dialog.setMessage(NewWizardMessages.CreateLinkedResourceGroup_targetSelectionLabel);
+ dialog.setMessage(NewWizardMessages.CreateLinkedResourceGroup_targetSelectionLabel);
selection = dialog.open();
- }
+ }
if (selection != null) {
linkTargetField.setText(selection);
if (!preventDialogFieldChanged)
dialogFieldChanged();
}
}
+
/**
- * Tries to resolve the value entered in the link target field as
+ * Tries to resolve the value entered in the link target field as
* a variable, if the value is a relative path.
* Displays the resolved value if the entered value is a variable.
*/
@@ -285,16 +281,17 @@ public class LinkToFileGroup extends StringButtonDialogField {
resolvedPathLabelData.setText(""); //$NON-NLS-1$
return;
}
-
+
IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
IPath path = new Path(linkTargetField.getText());
IPath resolvedPath = pathVariableManager.resolvePath(path);
-
+
resolvedPathLabelData.setText(resolvedPath.toOSString());
}
+
/**
* Sets the value of the link target field
- *
+ *
* @param target the value of the link target field
*/
public void setLinkTarget(String target) {
@@ -305,44 +302,42 @@ public class LinkToFileGroup extends StringButtonDialogField {
dialogFieldChanged();
}
}
+
/**
* Validates the type of the given file against the link type specified
* in the constructor.
- *
+ *
* @param linkTargetFile file to validate
- * @return IStatus indicating the validation result. IStatus.OK if the
+ * @return IStatus indicating the validation result. IStatus.OK if the
* given file is valid.
*/
private IStatus validateFileType(File linkTargetFile) {
if (type == IResource.FILE && linkTargetFile.isFile() == false) {
- return createStatus(
- IStatus.ERROR,
- NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFile);
+ return createStatus(IStatus.ERROR, NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFile);
} else if (type == IResource.FOLDER && linkTargetFile.isDirectory() == false) {
- return createStatus(
- IStatus.ERROR,
- NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFolder);
+ return createStatus(IStatus.ERROR, NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFolder);
}
return createStatus(IStatus.OK, ""); //$NON-NLS-1$
}
+
/**
* Validates this page's controls.
*
- * @return IStatus indicating the validation result. IStatus.OK if the
+ * @return IStatus indicating the validation result. IStatus.OK if the
* specified link target is valid given the linkHandle.
*/
public IStatus validateLinkLocation(IResource linkHandle) {
if (linkTargetField == null || linkTargetField.isDisposed())
- return createStatus(IStatus.OK, ""); //$NON-NLS-1$
-
+ return createStatus(IStatus.OK, ""); //$NON-NLS-1$
+
IWorkspace workspace = ResourcesPlugin.getWorkspace();
String linkTargetName = linkTargetField.getText();
IPath path = new Path(linkTargetName);
-
+
if (createLink == false)
return createStatus(IStatus.OK, ""); //$NON-NLS-1$
- IStatus locationStatus = workspace.validateLinkLocation(linkHandle, path);
+ IStatus locationStatus = workspace.validateLinkLocation(linkHandle, path);
if (locationStatus.getSeverity() == IStatus.ERROR)
return locationStatus;
@@ -356,14 +351,12 @@ public class LinkToFileGroup extends StringButtonDialogField {
return fileTypeStatus;
} else if (locationStatus.getSeverity() == IStatus.OK) {
// locationStatus takes precedence over missing location warning.
- return createStatus(
- IStatus.WARNING,
- NewWizardMessages.CreateLinkedResourceGroup_linkTargetNonExistent);
+ return createStatus(IStatus.WARNING, NewWizardMessages.CreateLinkedResourceGroup_linkTargetNonExistent);
}
return locationStatus;
}
-
- public boolean linkCreated (){
+
+ public boolean linkCreated() {
return createLink;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
index 1f2d6d240ba..ad8b69e2f3c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
@@ -59,35 +59,35 @@ import org.eclipse.cdt.internal.ui.util.TableLayoutComposite;
* DialogFields controls are: Label, List and Composite containing buttons.
*/
public class ListDialogField<T> extends DialogField {
-
+
public static class ColumnsDescription {
protected ColumnLayoutData[] columns;
protected String[] headers;
protected boolean drawLines;
-
+
public ColumnsDescription(ColumnLayoutData[] columns, String[] headers, boolean drawLines) {
- this.columns= columns;
- this.headers= headers;
- this.drawLines= drawLines;
+ this.columns = columns;
+ this.headers = headers;
+ this.drawLines = drawLines;
}
-
+
public ColumnsDescription(String[] headers, boolean drawLines) {
this(createColumnWeightData(headers.length), headers, drawLines);
}
-
+
public ColumnsDescription(int nColumns, boolean drawLines) {
this(createColumnWeightData(nColumns), null, drawLines);
}
-
+
private static ColumnLayoutData[] createColumnWeightData(int nColumns) {
- ColumnLayoutData[] data= new ColumnLayoutData[nColumns];
- for (int i= 0; i < nColumns; i++) {
- data[i]= new ColumnWeightData(1);
- }
+ ColumnLayoutData[] data = new ColumnLayoutData[nColumns];
+ for (int i = 0; i < nColumns; i++) {
+ data[i] = new ColumnWeightData(1);
+ }
return data;
}
}
-
+
protected TableViewer fTable;
protected IBaseLabelProvider fLabelProvider;
protected ListViewerAdapter fListViewerAdapter;
@@ -96,25 +96,24 @@ public class ListDialogField<T> extends DialogField {
protected String[] fButtonLabels;
private Button[] fButtonControls;
-
+
private boolean[] fButtonsEnabled;
-
+
private int fRemoveButtonIndex;
private int fUpButtonIndex;
private int fDownButtonIndex;
-
+
private Label fLastSeparator;
-
+
protected Control fTableControl;
private Composite fButtonsControl;
private ISelection fSelectionWhenEnabled;
-
+
private IListAdapter<T> fListAdapter;
-
+
private Object fParentElement;
-
+
protected ColumnsDescription fTableColumns;
-
/**
* Creates the <code>ListDialogField</code>.
@@ -123,87 +122,86 @@ public class ListDialogField<T> extends DialogField {
* @param buttonLabels The labels of all buttons: <code>null</code> is a valid array entry and
* marks a separator.
* @param lprovider The label provider to render the table entries
- */
+ */
public ListDialogField(IListAdapter<T> adapter, String[] buttonLabels, IBaseLabelProvider lprovider) {
super();
- fListAdapter= adapter;
+ fListAdapter = adapter;
+
+ fLabelProvider = lprovider;
+ fListViewerAdapter = new ListViewerAdapter();
+ fParentElement = this;
- fLabelProvider= lprovider;
- fListViewerAdapter= new ListViewerAdapter();
- fParentElement= this;
+ fElements = new ArrayList<T>(10);
- fElements= new ArrayList<T>(10);
-
- fButtonLabels= buttonLabels;
+ fButtonLabels = buttonLabels;
if (fButtonLabels != null) {
- int nButtons= fButtonLabels.length;
- fButtonsEnabled= new boolean[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtonsEnabled[i]= true;
+ int nButtons = fButtonLabels.length;
+ fButtonsEnabled = new boolean[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtonsEnabled[i] = true;
}
- }
-
- fTable= null;
- fTableControl= null;
- fButtonsControl= null;
- fTableColumns= null;
-
- fRemoveButtonIndex= -1;
- fUpButtonIndex= -1;
- fDownButtonIndex= -1;
- }
-
+ }
+
+ fTable = null;
+ fTableControl = null;
+ fButtonsControl = null;
+ fTableColumns = null;
+
+ fRemoveButtonIndex = -1;
+ fUpButtonIndex = -1;
+ fDownButtonIndex = -1;
+ }
+
/**
* Sets the index of the 'remove' button in the button label array passed in the constructor.
* The behaviour of the button marked as the 'remove' button will then be handled internally.
* (enable state, button invocation behaviour)
- */
+ */
public void setRemoveButtonIndex(int removeButtonIndex) {
Assert.isTrue(removeButtonIndex < fButtonLabels.length);
- fRemoveButtonIndex= removeButtonIndex;
+ fRemoveButtonIndex = removeButtonIndex;
}
/**
* Sets the index of the 'up' button in the button label array passed in the constructor.
* The behaviour of the button marked as the 'up' button will then be handled internally.
* (enable state, button invocation behaviour)
- */
+ */
public void setUpButtonIndex(int upButtonIndex) {
Assert.isTrue(upButtonIndex < fButtonLabels.length);
- fUpButtonIndex= upButtonIndex;
+ fUpButtonIndex = upButtonIndex;
}
/**
* Sets the index of the 'down' button in the button label array passed in the constructor.
* The behaviour of the button marked as the 'down' button will then be handled internally.
* (enable state, button invocation behaviour)
- */
+ */
public void setDownButtonIndex(int downButtonIndex) {
Assert.isTrue(downButtonIndex < fButtonLabels.length);
- fDownButtonIndex= downButtonIndex;
+ fDownButtonIndex = downButtonIndex;
}
-
+
/**
* Sets the viewerComparator.
* @param viewerComparator The viewerComparator to set
*/
public void setViewerComparator(ViewerComparator viewerComparator) {
- fViewerComparator= viewerComparator;
+ fViewerComparator = viewerComparator;
}
-
+
public void setTableColumns(ColumnsDescription column) {
- fTableColumns= column;
+ fTableColumns = column;
}
-
-
+
// ------ adapter communication
-
+
private void buttonPressed(int index) {
if (!managedButtonPressed(index) && fListAdapter != null) {
fListAdapter.customButtonPressed(this, index);
}
}
-
+
/**
* Checks if the button pressed is handled internally
* @return Returns true if button has been handled.
@@ -220,68 +218,66 @@ public class ListDialogField<T> extends DialogField {
}
return true;
}
-
// ------ layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- PixelConverter converter= new PixelConverter(parent);
-
+ PixelConverter converter = new PixelConverter(parent);
+
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
- GridData gd= gridDataForLabel(1);
- gd.verticalAlignment= GridData.BEGINNING;
+
+ Label label = getLabelControl(parent);
+ GridData gd = gridDataForLabel(1);
+ gd.verticalAlignment = GridData.BEGINNING;
label.setLayoutData(gd);
-
- Control list= getListControl(parent);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- gd.horizontalSpan= nColumns - 2;
- gd.widthHint= converter.convertWidthInCharsToPixels(50);
- gd.heightHint= converter.convertHeightInCharsToPixels(6);
+
+ Control list = getListControl(parent);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalSpan = nColumns - 2;
+ gd.widthHint = converter.convertWidthInCharsToPixels(50);
+ gd.heightHint = converter.convertHeightInCharsToPixels(6);
list.setLayoutData(gd);
-
- Composite buttons= getButtonBox(parent);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- gd.horizontalSpan= 1;
+
+ Composite buttons = getButtonBox(parent);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = false;
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalSpan = 1;
buttons.setLayoutData(gd);
-
+
return new Control[] { label, list, buttons };
}
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 3;
+ return 3;
}
/**
* Sets the minimal width of the buttons. Must be called after widget creation.
- */
+ */
public void setButtonsMinWidth(int minWidth) {
if (fLastSeparator != null) {
- ((GridData)fLastSeparator.getLayoutData()).widthHint= minWidth;
+ ((GridData) fLastSeparator.getLayoutData()).widthHint = minWidth;
}
}
-
-
+
// ------ ui creation
-
+
/**
* Returns the list control. When called the first time, the control will be created.
* @param parent the parent composite when called the first time, or <code>null</code>
@@ -290,26 +286,26 @@ public class ListDialogField<T> extends DialogField {
public Control getListControl(Composite parent) {
if (fTableControl == null) {
assertCompositeNotNull(parent);
-
+
if (fTableColumns == null) {
- fTable= createTableViewer(parent);
- Table tableControl= fTable.getTable();
-
- fTableControl= tableControl;
+ fTable = createTableViewer(parent);
+ Table tableControl = fTable.getTable();
+
+ fTableControl = tableControl;
tableControl.setLayout(new TableLayout());
} else {
- TableLayoutComposite composite= new TableLayoutComposite(parent, SWT.NONE);
- fTableControl= composite;
-
- fTable= createTableViewer(composite);
- Table tableControl= fTable.getTable();
-
+ TableLayoutComposite composite = new TableLayoutComposite(parent, SWT.NONE);
+ fTableControl = composite;
+
+ fTable = createTableViewer(composite);
+ Table tableControl = fTable.getTable();
+
tableControl.setHeaderVisible(fTableColumns.headers != null);
tableControl.setLinesVisible(fTableColumns.drawLines);
- ColumnLayoutData[] columns= fTableColumns.columns;
- for (int i= 0; i < columns.length; i++) {
+ ColumnLayoutData[] columns = fTableColumns.columns;
+ for (int i = 0; i < columns.length; i++) {
composite.addColumnData(columns[i]);
- TableColumn column= new TableColumn(tableControl, SWT.NONE);
+ TableColumn column = new TableColumn(tableControl, SWT.NONE);
//tableLayout.addColumnData(columns[i]);
if (fTableColumns.headers != null) {
column.setText(fTableColumns.headers[i]);
@@ -323,20 +319,20 @@ public class ListDialogField<T> extends DialogField {
handleKeyPressed(e);
}
});
-
- //fTableControl.setLayout(tableLayout);
-
+
+ //fTableControl.setLayout(tableLayout);
+
fTable.setContentProvider(fListViewerAdapter);
fTable.setLabelProvider(fLabelProvider);
fTable.addSelectionChangedListener(fListViewerAdapter);
fTable.addDoubleClickListener(fListViewerAdapter);
-
+
fTable.setInput(fParentElement);
-
+
if (fViewerComparator != null) {
fTable.setComparator(fViewerComparator);
}
-
+
fTableControl.setEnabled(isEnabled());
if (fSelectionWhenEnabled != null) {
postSetSelection(fSelectionWhenEnabled);
@@ -347,105 +343,106 @@ public class ListDialogField<T> extends DialogField {
/**
* Returns the internally used table viewer.
- */
+ */
public TableViewer getTableViewer() {
return fTable;
}
-
- /*
+
+ /*
* Subclasses may override to specify a different style.
*/
- protected int getListStyle(){
- int style= SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL ;
+ protected int getListStyle() {
+ int style = SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
if (fTableColumns != null) {
style |= SWT.FULL_SELECTION;
}
- return style;
+ return style;
}
-
+
protected TableViewer createTableViewer(Composite parent) {
- Table table= new Table(parent, getListStyle());
+ Table table = new Table(parent, getListStyle());
return new TableViewer(table);
- }
-
+ }
+
protected Button createButton(Composite parent, String label, SelectionListener listener) {
- Button button= new Button(parent, SWT.PUSH);
+ Button button = new Button(parent, SWT.PUSH);
button.setText(label);
button.addSelectionListener(listener);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.verticalAlignment= GridData.BEGINNING;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.verticalAlignment = GridData.BEGINNING;
gd.widthHint = SWTUtil.getButtonWidthHint(button);
-
+
button.setLayoutData(gd);
return button;
}
-
+
private Label createSeparator(Composite parent) {
- Label separator= new Label(parent, SWT.NONE);
+ Label separator = new Label(parent, SWT.NONE);
separator.setVisible(false);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.verticalAlignment= GridData.BEGINNING;
- gd.heightHint= 4;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.heightHint = 4;
separator.setLayoutData(gd);
return separator;
- }
+ }
/**
* Returns the composite containing the buttons. When called the first time, the control
* will be created.
* @param parent the parent composite when called the first time, or <code>null</code>
* after.
- */
+ */
public Composite getButtonBox(Composite parent) {
if (fButtonsControl == null) {
assertCompositeNotNull(parent);
-
- SelectionListener listener= new SelectionListener() {
+
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
doButtonSelected(e);
}
+
@Override
public void widgetSelected(SelectionEvent e) {
doButtonSelected(e);
}
};
-
- Composite contents= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+
+ Composite contents = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
contents.setLayout(layout);
-
+
if (fButtonLabels != null) {
- fButtonControls= new Button[fButtonLabels.length];
- for (int i= 0; i < fButtonLabels.length; i++) {
- String currLabel= fButtonLabels[i];
+ fButtonControls = new Button[fButtonLabels.length];
+ for (int i = 0; i < fButtonLabels.length; i++) {
+ String currLabel = fButtonLabels[i];
if (currLabel != null) {
- fButtonControls[i]= createButton(contents, currLabel, listener);
+ fButtonControls[i] = createButton(contents, currLabel, listener);
fButtonControls[i].setEnabled(isEnabled() && fButtonsEnabled[i]);
} else {
- fButtonControls[i]= null;
+ fButtonControls[i] = null;
createSeparator(contents);
}
}
}
-
- fLastSeparator= createSeparator(contents);
-
+
+ fLastSeparator = createSeparator(contents);
+
updateButtonState();
- fButtonsControl= contents;
+ fButtonsControl = contents;
}
-
+
return fButtonsControl;
}
-
+
protected void doButtonSelected(SelectionEvent e) {
if (fButtonControls != null) {
- for (int i= 0; i < fButtonControls.length; i++) {
+ for (int i = 0; i < fButtonControls.length; i++) {
if (e.widget == fButtonControls[i]) {
buttonPressed(i);
return;
@@ -453,7 +450,7 @@ public class ListDialogField<T> extends DialogField {
}
}
}
-
+
/**
* Handles key events in the table viewer. Specifically
* when the delete key is pressed.
@@ -463,35 +460,35 @@ public class ListDialogField<T> extends DialogField {
if (fRemoveButtonIndex != -1 && isButtonEnabled(fTable.getSelection(), fRemoveButtonIndex)) {
managedButtonPressed(fRemoveButtonIndex);
}
- }
- }
-
+ }
+ }
+
// ------ enable / disable management
/*
* @see DialogField#dialogFieldChanged
- */
+ */
@Override
public void dialogFieldChanged() {
super.dialogFieldChanged();
updateButtonState();
}
-
+
/*
* Updates the enable state of the all buttons
- */
+ */
protected void updateButtonState() {
if (fButtonControls != null) {
- ISelection sel= fTable.getSelection();
- for (int i= 0; i < fButtonControls.length; i++) {
- Button button= fButtonControls[i];
+ ISelection sel = fTable.getSelection();
+ for (int i = 0; i < fButtonControls.length; i++) {
+ Button button = fButtonControls[i];
if (isOkToUse(button)) {
button.setEnabled(isButtonEnabled(sel, i));
- }
+ }
}
}
}
-
+
protected boolean getManagedButtonState(ISelection sel, int index) {
if (index == fRemoveButtonIndex) {
return !sel.isEmpty();
@@ -501,23 +498,23 @@ public class ListDialogField<T> extends DialogField {
return !sel.isEmpty() && canMoveDown();
}
return true;
- }
+ }
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
super.updateEnableState();
-
- boolean enabled= isEnabled();
+
+ boolean enabled = isEnabled();
if (isOkToUse(fTableControl)) {
if (!enabled) {
- fSelectionWhenEnabled= fTable.getSelection();
+ fSelectionWhenEnabled = fTable.getSelection();
selectElements(null);
} else {
selectElements(fSelectionWhenEnabled);
- fSelectionWhenEnabled= null;
+ fSelectionWhenEnabled = null;
}
fTableControl.setEnabled(enabled);
}
@@ -526,27 +523,26 @@ public class ListDialogField<T> extends DialogField {
/**
* Sets a button enabled or disabled.
- */
+ */
public void enableButton(int index, boolean enable) {
if (fButtonsEnabled != null && index < fButtonsEnabled.length) {
- fButtonsEnabled[index]= enable;
+ fButtonsEnabled[index] = enable;
updateButtonState();
}
}
-
+
private boolean isButtonEnabled(ISelection sel, int index) {
- boolean extraState= getManagedButtonState(sel, index);
+ boolean extraState = getManagedButtonState(sel, index);
return isEnabled() && extraState && fButtonsEnabled[index];
- }
-
+ }
// ------ model access
-
+
/**
* Sets the elements shown in the list.
*/
public void setElements(List<? extends T> elements) {
- fElements= new ArrayList<T>(elements);
+ fElements = new ArrayList<T>(elements);
if (fTable != null) {
fTable.refresh();
}
@@ -556,34 +552,34 @@ public class ListDialogField<T> extends DialogField {
/**
* Gets the elements shown in the list.
* The list returned is a copy, so it can be modified by the user.
- */
+ */
public List<T> getElements() {
return new ArrayList<T>(fElements);
}
/**
* Gets the elements shown at the given index.
- */
+ */
public T getElement(int index) {
return fElements.get(index);
}
-
+
/**
* Gets the index of an element in the list or -1 if element is not in list.
*/
public int getIndexOfElement(Object elem) {
return fElements.indexOf(elem);
- }
+ }
/**
* Replace an element.
- */
- public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
- int idx= fElements.indexOf(oldElement);
+ */
+ public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
+ int idx = fElements.indexOf(oldElement);
if (idx != -1) {
fElements.set(idx, newElement);
if (fTable != null) {
- List<T> selected= getSelectedElements();
+ List<T> selected = getSelectedElements();
if (selected.remove(oldElement)) {
selected.add(newElement);
}
@@ -594,12 +590,12 @@ public class ListDialogField<T> extends DialogField {
} else {
throw new IllegalArgumentException();
}
- }
+ }
/**
* Adds an element at the end of the list.
- */
- public void addElement(T element) {
+ */
+ public void addElement(T element) {
if (fElements.contains(element)) {
return;
}
@@ -612,19 +608,19 @@ public class ListDialogField<T> extends DialogField {
/**
* Adds elements at the end of the list.
- */
+ */
public void addElements(List<? extends T> elements) {
- int nElements= elements.size();
-
+ int nElements = elements.size();
+
if (nElements > 0) {
// filter duplicated
- ArrayList<T> elementsToAdd= new ArrayList<T>(nElements);
-
- for (int i= 0; i < nElements; i++) {
- T elem= elements.get(i);
+ ArrayList<T> elementsToAdd = new ArrayList<T>(nElements);
+
+ for (int i = 0; i < nElements; i++) {
+ T elem = elements.get(i);
if (!fElements.contains(elem)) {
elementsToAdd.add(elem);
- }
+ }
}
fElements.addAll(elementsToAdd);
if (fTable != null) {
@@ -632,11 +628,11 @@ public class ListDialogField<T> extends DialogField {
}
dialogFieldChanged();
}
- }
+ }
/**
* Adds an element at a position.
- */
+ */
public void insertElementAt(T element, int index) {
if (fElements.contains(element)) {
return;
@@ -645,13 +641,13 @@ public class ListDialogField<T> extends DialogField {
if (fTable != null) {
fTable.add(element);
}
-
+
dialogFieldChanged();
- }
+ }
/**
* Adds an element at a position.
- */
+ */
public void removeAllElements() {
if (fElements.size() > 0) {
fElements.clear();
@@ -661,10 +657,10 @@ public class ListDialogField<T> extends DialogField {
dialogFieldChanged();
}
}
-
+
/**
* Removes an element from the list.
- */
+ */
public void removeElement(Object element) throws IllegalArgumentException {
if (fElements.remove(element)) {
if (fTable != null) {
@@ -678,7 +674,7 @@ public class ListDialogField<T> extends DialogField {
/**
* Removes elements from the list.
- */
+ */
public void removeElements(List<?> elements) {
if (elements.size() > 0) {
fElements.removeAll(elements);
@@ -691,39 +687,39 @@ public class ListDialogField<T> extends DialogField {
/**
* Gets the number of elements
- */
+ */
public int getSize() {
return fElements.size();
}
public void selectElements(ISelection selection) {
- fSelectionWhenEnabled= selection;
+ fSelectionWhenEnabled = selection;
if (fTable != null) {
fTable.setSelection(selection, true);
}
}
-
+
public void selectFirstElement() {
- Object element= null;
+ Object element = null;
if (fViewerComparator != null) {
- Object[] arr= fElements.toArray();
+ Object[] arr = fElements.toArray();
fViewerComparator.sort(fTable, arr);
if (arr.length > 0) {
- element= arr[0];
+ element = arr[0];
}
} else {
if (fElements.size() > 0) {
- element= fElements.get(0);
+ element = fElements.get(0);
}
}
if (element != null) {
selectElements(new StructuredSelection(element));
}
}
-
+
public void postSetSelection(final ISelection selection) {
if (isOkToUse(fTableControl)) {
- Display d= fTableControl.getDisplay();
+ Display d = fTableControl.getDisplay();
d.asyncExec(new Runnable() {
@Override
public void run() {
@@ -734,7 +730,7 @@ public class ListDialogField<T> extends DialogField {
});
}
}
-
+
/**
* Refreshes the table.
*/
@@ -743,68 +739,68 @@ public class ListDialogField<T> extends DialogField {
fTable.refresh();
}
}
-
+
// ------- list maintenance
-
+
private List<T> moveUp(List<? extends T> elements, List<? extends T> move) {
- int nElements= elements.size();
- List<T> res= new ArrayList<T>(nElements);
- T floating= null;
- for (int i= 0; i < nElements; i++) {
- T curr= elements.get(i);
+ int nElements = elements.size();
+ List<T> res = new ArrayList<T>(nElements);
+ T floating = null;
+ for (int i = 0; i < nElements; i++) {
+ T curr = elements.get(i);
if (move.contains(curr)) {
res.add(curr);
} else {
if (floating != null) {
res.add(floating);
}
- floating= curr;
+ floating = curr;
}
}
if (floating != null) {
res.add(floating);
}
return res;
- }
-
+ }
+
private void moveUp(List<? extends T> toMoveUp) {
if (toMoveUp.size() > 0) {
setElements(moveUp(fElements, toMoveUp));
fTable.reveal(toMoveUp.get(0));
}
}
-
+
private void moveDown(List<? extends T> toMoveDown) {
if (toMoveDown.size() > 0) {
setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
fTable.reveal(toMoveDown.get(toMoveDown.size() - 1));
}
}
-
+
private List<T> reverse(List<? extends T> p) {
- List<T> reverse= new ArrayList<T>(p.size());
- for (int i= p.size()-1; i >= 0; i--) {
+ List<T> reverse = new ArrayList<T>(p.size());
+ for (int i = p.size() - 1; i >= 0; i--) {
reverse.add(p.get(i));
}
return reverse;
}
-
+
protected void remove() {
removeElements(getSelectedElements());
}
-
+
protected void up() {
moveUp(getSelectedElements());
}
-
+
protected void down() {
moveDown(getSelectedElements());
}
-
+
protected boolean canMoveUp() {
if (isOkToUse(fTableControl)) {
- int[] indc= fTable.getTable().getSelectionIndices();
- for (int i= 0; i < indc.length; i++) {
+ int[] indc = fTable.getTable().getSelectionIndices();
+ for (int i = 0; i < indc.length; i++) {
if (indc[i] != i) {
return true;
}
@@ -812,30 +808,30 @@ public class ListDialogField<T> extends DialogField {
}
return false;
}
-
+
protected boolean canMoveDown() {
if (isOkToUse(fTableControl)) {
- int[] indc= fTable.getTable().getSelectionIndices();
- int k= fElements.size() - 1;
- for (int i= indc.length - 1; i >= 0 ; i--, k--) {
+ int[] indc = fTable.getTable().getSelectionIndices();
+ int k = fElements.size() - 1;
+ for (int i = indc.length - 1; i >= 0; i--, k--) {
if (indc[i] != k) {
return true;
}
}
}
return false;
- }
+ }
/**
* Returns the selected elements.
*/
public List<T> getSelectedElements() {
- List<T> result= new ArrayList<T>();
+ List<T> result = new ArrayList<T>();
if (fTable != null) {
- ISelection selection= fTable.getSelection();
+ ISelection selection = fTable.getSelection();
if (selection instanceof IStructuredSelection) {
@SuppressWarnings("unchecked")
- Iterator<T> iter= ((IStructuredSelection)selection).iterator();
+ Iterator<T> iter = ((IStructuredSelection) selection).iterator();
while (iter.hasNext()) {
result.add(iter.next());
}
@@ -843,34 +839,35 @@ public class ListDialogField<T> extends DialogField {
}
return result;
}
-
+
// ------- ListViewerAdapter
-
- private class ListViewerAdapter implements IStructuredContentProvider, ISelectionChangedListener, IDoubleClickListener {
+
+ private class ListViewerAdapter
+ implements IStructuredContentProvider, ISelectionChangedListener, IDoubleClickListener {
// ------- ITableContentProvider Interface ------------
-
+
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// will never happen
}
-
+
@Override
public void dispose() {
}
-
+
@Override
public Object[] getElements(Object obj) {
return fElements.toArray();
}
-
+
// ------- ISelectionChangedListener Interface ------------
-
+
@Override
public void selectionChanged(SelectionChangedEvent event) {
doListSelected(event);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
*/
@@ -879,17 +876,17 @@ public class ListDialogField<T> extends DialogField {
doDoubleClick(event);
}
}
-
+
protected void doListSelected(SelectionChangedEvent event) {
updateButtonState();
if (fListAdapter != null) {
fListAdapter.selectionChanged(this);
}
}
-
+
protected void doDoubleClick(DoubleClickEvent event) {
if (fListAdapter != null) {
fListAdapter.doubleClicked(this);
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
index b486e228e20..4bf31d3c2a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
@@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
* Dialog Field containing a single button such as a radio or checkbox button.
*/
public class SelectionButtonDialogField extends DialogField {
-
+
private Button fButton;
private boolean fIsSelected;
private DialogField[] fAttachedDialogFields;
@@ -39,11 +39,11 @@ public class SelectionButtonDialogField extends DialogField {
*/
public SelectionButtonDialogField(int buttonStyle) {
super();
- fIsSelected= false;
- fAttachedDialogFields= null;
- fButtonStyle= buttonStyle;
+ fIsSelected = false;
+ fAttachedDialogFields = null;
+ fButtonStyle = buttonStyle;
}
-
+
/**
* Attaches a field to the selection state of the selection button.
* The attached field will be disabled if the selection button is not selected.
@@ -55,20 +55,20 @@ public class SelectionButtonDialogField extends DialogField {
/**
* Attaches fields to the selection state of the selection button.
* The attached fields will be disabled if the selection button is not selected.
- */
+ */
public void attachDialogFields(DialogField[] dialogFields) {
- fAttachedDialogFields= dialogFields;
- for (int i= 0; i < dialogFields.length; i++) {
+ fAttachedDialogFields = dialogFields;
+ for (int i = 0; i < dialogFields.length; i++) {
dialogFields[i].setEnabled(fIsSelected);
}
- }
-
+ }
+
/**
* Returns <code>true</code> is teh gived field is attached to the selection button.
*/
public boolean isAttached(DialogField editor) {
if (fAttachedDialogFields != null) {
- for (int i=0; i < fAttachedDialogFields.length; i++) {
+ for (int i = 0; i < fAttachedDialogFields.length; i++) {
if (fAttachedDialogFields[i] == editor) {
return true;
}
@@ -76,50 +76,50 @@ public class SelectionButtonDialogField extends DialogField {
}
return false;
}
-
+
// ------- layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Button button= getSelectionButton(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
- gd.horizontalAlignment= GridData.FILL;
+
+ Button button = getSelectionButton(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns;
+ gd.horizontalAlignment = GridData.FILL;
if (fButtonStyle == SWT.PUSH) {
gd.widthHint = SWTUtil.getButtonWidthHint(button);
- }
-
+ }
+
button.setLayoutData(gd);
-
+
return new Control[] { button };
- }
+ }
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 1;
- }
-
- // ------- ui creation
+ return 1;
+ }
+
+ // ------- ui creation
/**
* Returns the selection button widget. When called the first time, the widget will be created.
* @param group the parent composite when called the first time, or <code>null</code>
* after.
- */
+ */
public Button getSelectionButton(Composite group) {
if (fButton == null) {
assertCompositeNotNull(group);
-
- fButton= new Button(group, fButtonStyle);
- fButton.setFont(group.getFont());
+
+ fButton = new Button(group, fButtonStyle);
+ fButton.setFont(group.getFont());
fButton.setText(fLabelText);
fButton.setEnabled(isEnabled());
fButton.setSelection(fIsSelected);
@@ -128,30 +128,31 @@ public class SelectionButtonDialogField extends DialogField {
public void widgetDefaultSelected(SelectionEvent e) {
doWidgetSelected(e);
}
+
@Override
public void widgetSelected(SelectionEvent e) {
doWidgetSelected(e);
}
- });
+ });
}
return fButton;
}
-
+
protected void doWidgetSelected(SelectionEvent e) {
if (isOkToUse(fButton)) {
changeValue(fButton.getSelection());
}
- }
-
+ }
+
private void changeValue(boolean newState) {
if (fIsSelected != newState) {
- fIsSelected= newState;
+ fIsSelected = newState;
if (fAttachedDialogFields != null) {
- boolean focusSet= false;
- for (int i= 0; i < fAttachedDialogFields.length; i++) {
+ boolean focusSet = false;
+ for (int i = 0; i < fAttachedDialogFields.length; i++) {
fAttachedDialogFields[i].setEnabled(fIsSelected);
if (fIsSelected && !focusSet) {
- focusSet= fAttachedDialogFields[i].setFocus();
+ focusSet = fAttachedDialogFields[i].setFocus();
}
}
}
@@ -159,10 +160,10 @@ public class SelectionButtonDialogField extends DialogField {
} else if (fButtonStyle == SWT.PUSH) {
dialogFieldChanged();
}
- }
+ }
+
+ // ------ model access
- // ------ model access
-
/**
* Returns the selection state of the button.
*/
@@ -172,7 +173,7 @@ public class SelectionButtonDialogField extends DialogField {
/**
* Sets the selection state of the button.
- */
+ */
public void setSelection(boolean selected) {
changeValue(selected);
if (isOkToUse(fButton)) {
@@ -184,16 +185,13 @@ public class SelectionButtonDialogField extends DialogField {
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
super.updateEnableState();
if (isOkToUse(fButton)) {
fButton.setEnabled(isEnabled());
- }
+ }
}
-
-
-
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
index ee331faa876..44f567d397f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
@@ -30,96 +30,95 @@ import org.eclipse.core.runtime.Assert;
* Dialog field describing a group with buttons (Checkboxes, radio buttons..)
*/
public class SelectionButtonDialogFieldGroup extends DialogField {
-
+
private Composite fButtonComposite;
-
+
private Button[] fButtons;
private String[] fButtonNames;
private boolean[] fButtonsSelected;
private boolean[] fButtonsEnabled;
-
+
private int fGroupBorderStyle;
private int fGroupNumberOfColumns;
- private int fButtonsStyle;
-
+ private int fButtonsStyle;
+
/**
* Creates a group without border.
*/
public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) {
- this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
- }
-
-
+ 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>
- */
+ */
public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) {
super();
-
+
Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
- fButtonNames= buttonNames;
-
- 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;
+ fButtonNames = buttonNames;
+
+ 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 (fButtonsStyle == SWT.RADIO) {
- fButtonsSelected[0]= true;
+ fButtonsSelected[0] = true;
}
-
- fGroupBorderStyle= borderStyle;
- fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns;
-
- fButtonsStyle= buttonsStyle;
-
+
+ fGroupBorderStyle = borderStyle;
+ fGroupNumberOfColumns = (nColumns <= 0) ? nButtons : nColumns;
+
+ fButtonsStyle = buttonsStyle;
+
}
-
+
// ------- layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
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 };
}
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns;
buttonsgroup.setLayoutData(gd);
-
+
return new Control[] { buttonsgroup };
- }
+ }
/*
* @see DialogField#doFillIntoGrid
- */
+ */
@Override
public int getNumberOfControls() {
return (fGroupBorderStyle == SWT.NONE) ? 2 : 1;
}
-
+
// ------- ui creation
-
+
private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
- Button button= new Button(group, fButtonsStyle | SWT.LEFT);
- button.setFont(group.getFont());
+ Button button = new Button(group, fButtonsStyle | SWT.LEFT);
+ button.setFont(group.getFont());
button.setText(fButtonNames[index]);
button.setEnabled(isEnabled() && fButtonsEnabled[index]);
button.setSelection(fButtonsSelected[index]);
@@ -136,43 +135,44 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
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);
if (fLabelText != null && fLabelText.length() > 0) {
group.setText(fLabelText);
}
- fButtonComposite= group;
+ fButtonComposite = group;
} else {
- fButtonComposite= new Composite(parent, SWT.NULL);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ fButtonComposite = new Composite(parent, SWT.NULL);
+ 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);
}
}
@@ -181,26 +181,26 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
/**
* Returns a button from the group or <code>null</code> if not yet created.
- */
+ */
public Button getSelectionButton(int index) {
if (index >= 0 && index < fButtons.length) {
return fButtons[index];
}
return null;
}
-
+
protected 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;
}
}
- }
-
- // ------ model access
+ }
+
+ // ------ model access
/**
* Returns the selection state of a button contained in the group.
@@ -212,16 +212,16 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
}
return false;
}
-
+
/**
* Sets the selection state of a button contained in the group.
*/
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);
}
@@ -231,33 +231,33 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
}
// ------ enable / disable management
-
+
@Override
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]);
}
}
}
}
-
+
/**
* Sets the enable state of a button contained in the group.
- */
+ */
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);
}
}
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
index eaa74dda1e9..b5094c11d29 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -25,41 +24,41 @@ import org.eclipse.swt.layout.GridData;
* Dialog field describing a separator.
*/
public class Separator extends DialogField {
-
+
private Label fSeparator;
private int fStyle;
-
+
public Separator() {
this(SWT.NONE);
- }
-
+ }
+
/**
* @param style of the separator. See <code>Label</code> for possible
* styles.
*/
public Separator(int style) {
super();
- fStyle= style;
+ fStyle = style;
}
-
+
// ------- layout helpers
/**
* Creates the separator and fills it in a MGridLayout.
* @param height The heigth of the separator
- */
+ */
public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) {
assertEnoughColumns(nColumns);
-
- Control separator= getSeparator(parent);
+
+ Control separator = getSeparator(parent);
separator.setLayoutData(gridDataForSeperator(nColumns, height));
-
+
return new Control[] { separator };
}
/*
* @see DialogField#doFillIntoGrid
- */
+ */
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
return doFillIntoGrid(parent, nColumns, 4);
@@ -67,33 +66,33 @@ public class Separator extends DialogField {
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 1;
+ return 1;
}
-
+
protected static GridData gridDataForSeperator(int span, int height) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.verticalAlignment= GridData.BEGINNING;
- gd.heightHint= height;
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.heightHint = height;
+ gd.horizontalSpan = span;
return gd;
}
-
- // ------- ui creation
+
+ // ------- ui creation
/**
* Creates or returns the created separator.
* @param parent The parent composite or <code>null</code> if the widget has
* already been created.
- */
+ */
public Control getSeparator(Composite parent) {
if (fSeparator == null) {
assertCompositeNotNull(parent);
- fSeparator= new Label(parent, fStyle);
- }
+ fSeparator = new Label(parent, fStyle);
+ }
return fSeparator;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
index 798d3259a72..7f96fb38ffb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
@@ -29,84 +29,84 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
* Dialog field containing a label, text control and a button control.
*/
public class StringButtonDialogField extends StringDialogField {
-
+
private Button fBrowseButton;
private String fBrowseButtonLabel;
private IStringButtonAdapter fStringButtonAdapter;
-
+
private boolean fButtonEnabled;
-
+
public StringButtonDialogField(IStringButtonAdapter adapter) {
super();
- fStringButtonAdapter= adapter;
- fBrowseButtonLabel= "!Browse...!"; //$NON-NLS-1$
- fButtonEnabled= true;
+ fStringButtonAdapter = adapter;
+ fBrowseButtonLabel = "!Browse...!"; //$NON-NLS-1$
+ fButtonEnabled = true;
}
/**
* Sets the label of the button.
*/
public void setButtonLabel(String label) {
- fBrowseButtonLabel= label;
+ fBrowseButtonLabel = label;
}
-
+
// ------ adapter communication
/**
* Programmatical pressing of the button
- */
+ */
public void changeControlPressed() {
fStringButtonAdapter.changeControlPressed(this);
}
-
+
// ------- layout helpers
/*
* @see DialogField#doFillIntoGrid
- */
+ */
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
- Text text= getTextControl(parent);
+ Text text = getTextControl(parent);
text.setLayoutData(gridDataForText(nColumns - 2));
- Button button= getChangeControl(parent);
+ Button button = getChangeControl(parent);
button.setLayoutData(gridDataForButton(button, 1));
-
+
return new Control[] { label, text, button };
- }
+ }
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 3;
+ return 3;
}
-
+
protected static GridData gridDataForButton(Button button, int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
- gd.widthHint = SWTUtil.getButtonWidthHint(button);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = false;
+ gd.horizontalSpan = span;
+ gd.widthHint = SWTUtil.getButtonWidthHint(button);
return gd;
- }
-
- // ------- ui creation
+ }
+
+ // ------- ui creation
/**
* Creates or returns the created buttom widget.
* @param parent The parent composite or <code>null</code> if the widget has
* already been created.
- */
+ */
public Button getChangeControl(Composite parent) {
if (fBrowseButton == null) {
assertCompositeNotNull(parent);
-
- fBrowseButton= new Button(parent, SWT.PUSH);
+
+ fBrowseButton = new Button(parent, SWT.PUSH);
fBrowseButton.setText(fBrowseButtonLabel);
fBrowseButton.setEnabled(isEnabled() && fButtonEnabled);
fBrowseButton.addSelectionListener(new SelectionListener() {
@@ -114,18 +114,19 @@ public class StringButtonDialogField extends StringDialogField {
public void widgetDefaultSelected(SelectionEvent e) {
changeControlPressed();
}
+
@Override
public void widgetSelected(SelectionEvent e) {
changeControlPressed();
}
- });
-
+ });
+
}
return fBrowseButton;
}
-
+
// ------ enable / disable management
-
+
/**
* Sets the enable state of the button.
*/
@@ -133,17 +134,17 @@ public class StringButtonDialogField extends StringDialogField {
if (isOkToUse(fBrowseButton)) {
fBrowseButton.setEnabled(isEnabled() && enable);
}
- fButtonEnabled= enable;
+ fButtonEnabled = enable;
}
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
super.updateEnableState();
if (isOkToUse(fBrowseButton)) {
fBrowseButton.setEnabled(isEnabled() && fButtonEnabled);
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
index 0720c8daae2..4df4938746d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
@@ -17,7 +17,6 @@ package org.eclipse.cdt.internal.ui.wizards.dialogfields;
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -28,53 +27,52 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-
public class StringDialogField extends DialogField {
-
+
private String fText;
private Text fTextControl;
private ModifyListener fModifyListener;
-
+
public StringDialogField() {
super();
- fText= ""; //$NON-NLS-1$
+ fText = ""; //$NON-NLS-1$
}
-
+
// ------- layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
- Text text= getTextControl(parent);
+ Text text = getTextControl(parent);
text.setLayoutData(gridDataForText(nColumns - 1));
-
+
return new Control[] { label, text };
- }
+ }
/*
* @see DialogField#getNumberOfControls
*/
@Override
public int getNumberOfControls() {
- return 2;
+ return 2;
}
-
+
protected static GridData gridDataForText(int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = span;
return gd;
- }
-
+ }
+
// ------- focus methods
-
+
/*
* @see DialogField#setFocus
*/
@@ -86,86 +84,86 @@ public class StringDialogField extends DialogField {
}
return true;
}
-
- // ------- ui creation
+
+ // ------- ui creation
/**
* Creates or returns the created text control.
* @param parent The parent composite or <code>null</code> when the widget has
* already been created.
- */
+ */
public Text getTextControl(Composite parent) {
if (fTextControl == null) {
assertCompositeNotNull(parent);
- fModifyListener= new ModifyListener() {
+ fModifyListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
doModifyText(e);
}
};
-
- fTextControl= new Text(parent, SWT.SINGLE | SWT.BORDER);
+
+ fTextControl = new Text(parent, SWT.SINGLE | SWT.BORDER);
// moved up due to 1GEUNW2
fTextControl.setText(fText);
fTextControl.setFont(parent.getFont());
fTextControl.addModifyListener(fModifyListener);
-
+
fTextControl.setEnabled(isEnabled());
}
return fTextControl;
}
-
+
protected void doModifyText(ModifyEvent e) {
if (isOkToUse(fTextControl)) {
- fText= fTextControl.getText();
+ fText = fTextControl.getText();
}
dialogFieldChanged();
- }
-
+ }
+
// ------ enable / disable management
-
+
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
- super.updateEnableState();
+ super.updateEnableState();
if (isOkToUse(fTextControl)) {
fTextControl.setEnabled(isEnabled());
- }
- }
-
- // ------ text access
-
+ }
+ }
+
+ // ------ text access
+
/**
* Gets the text. Can not be <code>null</code>
- */
+ */
public String getText() {
return fText;
}
-
+
/**
* Sets the text. Triggers a dialog-changed event.
*/
public void setText(String text) {
- fText= text;
+ fText = text;
if (isOkToUse(fTextControl)) {
fTextControl.setText(text);
} else {
dialogFieldChanged();
- }
+ }
}
/**
* Sets the text without triggering a dialog-changed event.
*/
public void setTextWithoutUpdate(String text) {
- fText= text;
+ fText = text;
if (isOkToUse(fTextControl)) {
fTextControl.removeModifyListener(fModifyListener);
fTextControl.setText(text);
fTextControl.addModifyListener(fModifyListener);
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java
index c31a0357c99..bb6ce3747d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java
@@ -148,10 +148,10 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Sets the viewerSorter.
- *
+ *
* @param viewerSorter
* The viewerSorter to set
- *
+ *
* @deprecated Use {@link #setViewerComparator(ViewerComparator)} instead.
*/
@Deprecated
@@ -161,7 +161,7 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Sets the viewerComparator.
- *
+ *
* @param viewerComparator
* The viewerComparator to set
*/
@@ -186,7 +186,7 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Checks if the button pressed is handled internally
- *
+ *
* @return Returns true if button has been handled.
*/
protected boolean managedButtonPressed(int index) {
@@ -239,7 +239,7 @@ public class TreeListDialogField<T> extends DialogField {
gd.horizontalSpan = 1;
buttons.setLayoutData(gd);
- return new Control[] { label, list, buttons};
+ return new Control[] { label, list, buttons };
}
/*
@@ -265,8 +265,8 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Returns the tree control. When called the first time, the control will be
* created.
- *
- * @param parent
+ *
+ * @param parent
* parent composite when called the first time, or <code>null</code>
* after.
*/
@@ -352,7 +352,7 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Returns the composite containing the buttons. When called the first time,
* the control will be created.
- *
+ *
* @param parent
* parent composite when called the first time, or <code>null</code>
* after.
@@ -898,7 +898,7 @@ public class TreeListDialogField<T> extends DialogField {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java
index a5f6ef00cb0..7fef2288433 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java
@@ -26,41 +26,41 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.wizards.NewElementWizard;
public abstract class AbstractFileCreationWizard extends NewElementWizard {
- protected AbstractFileCreationWizardPage fPage;
-
- public AbstractFileCreationWizard() {
- super();
- setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_FILE);
- setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
- setWindowTitle(NewFileWizardMessages.AbstractFileCreationWizard_title);
- }
-
- @Override
+ protected AbstractFileCreationWizardPage fPage;
+
+ public AbstractFileCreationWizard() {
+ super();
+ setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_FILE);
+ setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+ setWindowTitle(NewFileWizardMessages.AbstractFileCreationWizard_title);
+ }
+
+ @Override
protected boolean canRunForked() {
- return true;
- }
-
- @Override
+ return true;
+ }
+
+ @Override
protected void finishPage(IProgressMonitor monitor) throws CoreException {
- fPage.createFile(monitor); // Use the full progress monitor.
- }
-
- @Override
+ fPage.createFile(monitor); // Use the full progress monitor.
+ }
+
+ @Override
public boolean performFinish() {
- boolean result = super.performFinish();
- if (result) {
- //TODO need prefs option for opening editor
- boolean openInEditor = true;
-
+ boolean result = super.performFinish();
+ if (result) {
+ //TODO need prefs option for opening editor
+ boolean openInEditor = true;
+
ITranslationUnit headerTU = fPage.getCreatedFileTU();
if (headerTU != null) {
- IResource resource= headerTU.getResource();
+ IResource resource = headerTU.getResource();
selectAndReveal(resource);
if (openInEditor) {
openResource((IFile) resource);
}
}
- }
- return result;
- }
+ }
+ return result;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java
index 0ae211f5169..552513e55d9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java
@@ -100,11 +100,11 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
private final IStatus STATUS_OK = new StatusInfo();
/**
- * This flag isFirstTime is used to keep a note
- * that the file creation wizard has just been
- * created.
- */
- private boolean isFirstTime = true;
+ * This flag isFirstTime is used to keep a note
+ * that the file creation wizard has just been
+ * created.
+ */
+ private boolean isFirstTime = true;
private Template[] fTemplates;
@@ -121,11 +121,12 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
fSourceFolderDialogField = new StringButtonDialogField(sourceFolderAdapter);
fSourceFolderDialogField.setDialogFieldListener(sourceFolderAdapter);
fSourceFolderDialogField.setLabelText(NewFileWizardMessages.AbstractFileCreationWizardPage_sourceFolder_label);
- fSourceFolderDialogField.setButtonLabel(NewFileWizardMessages.AbstractFileCreationWizardPage_sourceFolder_button);
+ fSourceFolderDialogField
+ .setButtonLabel(NewFileWizardMessages.AbstractFileCreationWizardPage_sourceFolder_button);
- fTemplates= getApplicableTemplates();
+ fTemplates = getApplicableTemplates();
if (fTemplates != null && fTemplates.length > 0) {
- fTemplateDialogField= new ComboDialogField(SWT.READ_ONLY);
+ fTemplateDialogField = new ComboDialogField(SWT.READ_ONLY);
fTemplateDialogField.setLabelText(NewFileWizardMessages.AbstractFileCreationWizardPage_template_label);
}
@@ -138,31 +139,31 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
@Override
public void createControl(Composite parent) {
- initializeDialogUnits(parent);
+ initializeDialogUnits(parent);
- Composite composite = new Composite(parent, SWT.NONE);
- int nColumns = 3;
+ Composite composite = new Composite(parent, SWT.NONE);
+ int nColumns = 3;
- GridLayout layout = new GridLayout();
- layout.numColumns = nColumns;
- composite.setLayout(layout);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = nColumns;
+ composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setFont(parent.getFont());
- createSourceFolderControls(composite, nColumns);
+ createSourceFolderControls(composite, nColumns);
- createFileControls(composite, nColumns - 1);
- // Placeholder for the right column.
- (new Composite(composite, SWT.NO_FOCUS)).setLayoutData(new GridData(1, 1));
+ createFileControls(composite, nColumns - 1);
+ // Placeholder for the right column.
+ (new Composite(composite, SWT.NO_FOCUS)).setLayoutData(new GridData(1, 1));
- createTemplateControls(composite, nColumns);
+ createTemplateControls(composite, nColumns);
composite.layout();
setErrorMessage(null);
setMessage(null);
setControl(composite);
- }
+ }
/**
* Creates a separator line. Expects a <code>GridLayout</code> with at least 1 column.
@@ -171,7 +172,8 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
* @param nColumns number of columns to span
*/
protected void createSeparator(Composite composite, int nColumns) {
- (new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns, convertHeightInCharsToPixels(1));
+ (new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns,
+ convertHeightInCharsToPixels(1));
}
/**
@@ -210,7 +212,7 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
protected void createTemplateControls(Composite parent, int columns) {
if (fTemplateDialogField != null) {
fTemplateDialogField.doFillIntoGrid(parent, columns - 1);
- Button configureButton= new Button(parent, SWT.PUSH);
+ Button configureButton = new Button(parent, SWT.PUSH);
configureButton.setText(NewFileWizardMessages.AbstractFileCreationWizardPage_configure_label);
configureButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
configureButton.addSelectionListener(new SelectionAdapter() {
@@ -219,24 +221,25 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
editTemplates();
}
});
- Combo comboControl= fTemplateDialogField.getComboControl(null);
+ Combo comboControl = fTemplateDialogField.getComboControl(null);
LayoutUtil.setWidthHint(comboControl, getMaxFieldWidth());
}
}
protected void editTemplates() {
- String prefPageId= CodeTemplatePreferencePage.PREF_ID;
- Map<String, String> data= null;
- String templateName= null;
- Template template= getSelectedTemplate();
+ String prefPageId = CodeTemplatePreferencePage.PREF_ID;
+ Map<String, String> data = null;
+ String templateName = null;
+ Template template = getSelectedTemplate();
if (template != null) {
- templateName= template.getName();
+ templateName = template.getName();
}
if (templateName != null) {
- data= new HashMap<String, String>();
+ data = new HashMap<String, String>();
data.put(CodeTemplatePreferencePage.DATA_SELECT_TEMPLATE, templateName);
}
- PreferenceDialog dialog= PreferencesUtil.createPreferenceDialogOn(getShell(), prefPageId, new String[] { prefPageId }, data);
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), prefPageId,
+ new String[] { prefPageId }, data);
if (dialog.open() == Window.OK) {
updateTemplates();
}
@@ -244,27 +247,25 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
protected void updateTemplates() {
if (fTemplateDialogField != null) {
- Template selected= getSelectedTemplate();
- String name = selected != null ?
- selected.getName() :
- getDefaultTemplateName();
- fTemplates= getApplicableTemplates();
- int idx= NO_TEMPLATE.equals(name) ? 0 : 1;
- String[] names= new String[fTemplates.length + 1];
+ Template selected = getSelectedTemplate();
+ String name = selected != null ? selected.getName() : getDefaultTemplateName();
+ fTemplates = getApplicableTemplates();
+ int idx = NO_TEMPLATE.equals(name) ? 0 : 1;
+ String[] names = new String[fTemplates.length + 1];
for (int i = 0; i < fTemplates.length; i++) {
- names[i + 1]= fTemplates[i].getName();
+ names[i + 1] = fTemplates[i].getName();
if (name != null && name.equals(names[i + 1])) {
- idx= i + 1;
+ idx = i + 1;
}
}
- names[0]= NewFileWizardMessages.AbstractFileCreationWizardPage_noTemplate;
+ names[0] = NewFileWizardMessages.AbstractFileCreationWizardPage_noTemplate;
fTemplateDialogField.setItems(names);
fTemplateDialogField.selectItem(idx);
}
}
/**
- * Configure the set of templates to select from.
+ * Configure the set of templates to select from.
* @return the set of templates
*/
protected abstract Template[] getApplicableTemplates();
@@ -282,7 +283,7 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
private Template getSelectedTemplate() {
if (fTemplateDialogField != null) {
- int index= fTemplateDialogField.getSelectionIndex() - 1;
+ int index = fTemplateDialogField.getSelectionIndex() - 1;
if (index >= 0 && index < fTemplates.length) {
return fTemplates[index];
}
@@ -290,151 +291,151 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
return null;
}
- /**
- * The wizard owning this page is responsible for calling this method with the
- * current selection. The selection is used to initialize the fields of the wizard
- * page.
- *
- * @param selection used to initialize the fields
- */
- public void init(IStructuredSelection selection) {
- ICElement celem = getInitialCElement(selection);
- initFields(celem);
- doStatusUpdate();
- }
-
- /**
- * Utility method to inspect a selection to find a C element.
- *
- * @param selection the selection to be inspected
- * @return a C element to be used as the initial selection, or <code>null</code>,
- * if no C element exists in the given selection
- */
- protected ICElement getInitialCElement(IStructuredSelection selection) {
- ICElement celem = null;
- if (selection != null && !selection.isEmpty()) {
- Object selectedElement = selection.getFirstElement();
- if (selectedElement instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) selectedElement;
-
- celem = adaptable.getAdapter(ICElement.class);
- if (celem == null) {
- IResource resource = adaptable.getAdapter(IResource.class);
- if (resource != null && resource.getType() != IResource.ROOT) {
- while (celem == null && resource.getType() != IResource.PROJECT) {
- celem = resource.getAdapter(ICElement.class);
- resource = resource.getParent();
- }
- if (celem == null) {
- celem = CoreModel.getDefault().create(resource); // c project
- }
- }
- }
- }
- }
- if (celem == null) {
- IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
- if (part instanceof ContentOutline) {
- part = CUIPlugin.getActivePage().getActiveEditor();
- }
-
- if (part instanceof IViewPartInputProvider) {
- Object elem = ((IViewPartInputProvider)part).getViewPartInput();
- if (elem instanceof ICElement) {
- celem = (ICElement) elem;
- }
- }
-
- if (celem == null && part instanceof CEditor) {
- IEditorInput input = ((IEditorPart)part).getEditorInput();
- if (input != null) {
+ /**
+ * The wizard owning this page is responsible for calling this method with the
+ * current selection. The selection is used to initialize the fields of the wizard
+ * page.
+ *
+ * @param selection used to initialize the fields
+ */
+ public void init(IStructuredSelection selection) {
+ ICElement celem = getInitialCElement(selection);
+ initFields(celem);
+ doStatusUpdate();
+ }
+
+ /**
+ * Utility method to inspect a selection to find a C element.
+ *
+ * @param selection the selection to be inspected
+ * @return a C element to be used as the initial selection, or <code>null</code>,
+ * if no C element exists in the given selection
+ */
+ protected ICElement getInitialCElement(IStructuredSelection selection) {
+ ICElement celem = null;
+ if (selection != null && !selection.isEmpty()) {
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) selectedElement;
+
+ celem = adaptable.getAdapter(ICElement.class);
+ if (celem == null) {
+ IResource resource = adaptable.getAdapter(IResource.class);
+ if (resource != null && resource.getType() != IResource.ROOT) {
+ while (celem == null && resource.getType() != IResource.PROJECT) {
+ celem = resource.getAdapter(ICElement.class);
+ resource = resource.getParent();
+ }
+ if (celem == null) {
+ celem = CoreModel.getDefault().create(resource); // c project
+ }
+ }
+ }
+ }
+ }
+ if (celem == null) {
+ IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
+ if (part instanceof ContentOutline) {
+ part = CUIPlugin.getActivePage().getActiveEditor();
+ }
+
+ if (part instanceof IViewPartInputProvider) {
+ Object elem = ((IViewPartInputProvider) part).getViewPartInput();
+ if (elem instanceof ICElement) {
+ celem = (ICElement) elem;
+ }
+ }
+
+ if (celem == null && part instanceof CEditor) {
+ IEditorInput input = ((IEditorPart) part).getEditorInput();
+ if (input != null) {
final IResource res = input.getAdapter(IResource.class);
if (res != null && res instanceof IFile) {
- celem = CoreModel.getDefault().create((IFile)res);
+ celem = CoreModel.getDefault().create((IFile) res);
}
- }
- }
- }
-
- if (celem == null || celem.getElementType() == ICElement.C_MODEL) {
- try {
- ICProject[] projects = CoreModel.create(getWorkspaceRoot()).getCProjects();
- if (projects.length == 1) {
- celem = projects[0];
- }
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- }
- return celem;
- }
+ }
+ }
+ }
+
+ if (celem == null || celem.getElementType() == ICElement.C_MODEL) {
+ try {
+ ICProject[] projects = CoreModel.create(getWorkspaceRoot()).getCProjects();
+ if (projects.length == 1) {
+ celem = projects[0];
+ }
+ } catch (CModelException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ return celem;
+ }
+
+ /**
+ * Initializes all fields provided by the page with a given selection.
+ *
+ * @param elem the selection used to initialize this page or <code>
+ * null</code> if no selection was available
+ */
+ protected void initFields(ICElement elem) {
+ initSourceFolder(elem);
+ updateTemplates();
+ handleFieldChanged(ALL_FIELDS);
+ }
/**
- * Initializes all fields provided by the page with a given selection.
- *
- * @param elem the selection used to initialize this page or <code>
- * null</code> if no selection was available
- */
- protected void initFields(ICElement elem) {
- initSourceFolder(elem);
- updateTemplates();
- handleFieldChanged(ALL_FIELDS);
- }
-
- /**
- * Initializes the source folder field.
- *
- * @param elem the C element used to compute the initial folder
- */
- protected void initSourceFolder(ICElement elem) {
- IPath folderPath = null;
- if (elem != null) {
- ICContainer folder = NewClassWizardUtil.getSourceFolder(elem);
- if (folder == null) {
- ICProject cproject = elem.getCProject();
- if (cproject != null) {
- folder = NewClassWizardUtil.getFirstSourceRoot(cproject);
- }
- }
- if (folder != null) {
- folderPath = folder.getResource().getFullPath();
- }
- }
- setSourceFolderFullPath(folderPath, false);
- }
-
- /**
- * Returns the recommended maximum width for text fields (in pixels). This
- * method requires that createContent has been called before this method is
- * call. Subclasses may override to change the maximum width for text
- * fields.
+ * Initializes the source folder field.
*
- * @return the recommended maximum width for text fields.
+ * @param elem the C element used to compute the initial folder
*/
+ protected void initSourceFolder(ICElement elem) {
+ IPath folderPath = null;
+ if (elem != null) {
+ ICContainer folder = NewClassWizardUtil.getSourceFolder(elem);
+ if (folder == null) {
+ ICProject cproject = elem.getCProject();
+ if (cproject != null) {
+ folder = NewClassWizardUtil.getFirstSourceRoot(cproject);
+ }
+ }
+ if (folder != null) {
+ folderPath = folder.getResource().getFullPath();
+ }
+ }
+ setSourceFolderFullPath(folderPath, false);
+ }
+
+ /**
+ * Returns the recommended maximum width for text fields (in pixels). This
+ * method requires that createContent has been called before this method is
+ * call. Subclasses may override to change the maximum width for text
+ * fields.
+ *
+ * @return the recommended maximum width for text fields.
+ */
protected int getMaxFieldWidth() {
return convertWidthInCharsToPixels(MAX_FIELD_CHARS);
}
- /**
- * Returns the test selection of the current editor. <code>null</code> is returned
- * when the current editor does not have focus or does not return a text selection.
- * @return Returns the test selection of the current editor or <code>null</code>.
- *
- * @since 3.0
- */
- protected ITextSelection getCurrentTextSelection() {
- IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
- if (part instanceof IEditorPart) {
- ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
- if (selectionProvider != null) {
- ISelection selection = selectionProvider.getSelection();
- if (selection instanceof ITextSelection) {
- return (ITextSelection) selection;
- }
- }
- }
- return null;
- }
+ /**
+ * Returns the test selection of the current editor. <code>null</code> is returned
+ * when the current editor does not have focus or does not return a text selection.
+ * @return Returns the test selection of the current editor or <code>null</code>.
+ *
+ * @since 3.0
+ */
+ protected ITextSelection getCurrentTextSelection() {
+ IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
+ if (part instanceof IEditorPart) {
+ ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
+ if (selectionProvider != null) {
+ ISelection selection = selectionProvider.getSelection();
+ if (selection instanceof ITextSelection) {
+ return (ITextSelection) selection;
+ }
+ }
+ }
+ return null;
+ }
/**
* Sets the focus to the source folder's text field.
@@ -443,34 +444,34 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
fSourceFolderDialogField.setFocus();
}
- protected final class StatusFocusListener implements FocusListener {
- private final int fieldID;
+ protected final class StatusFocusListener implements FocusListener {
+ private final int fieldID;
- public StatusFocusListener(int fieldID) {
- this.fieldID = fieldID;
- }
+ public StatusFocusListener(int fieldID) {
+ this.fieldID = fieldID;
+ }
- @Override
+ @Override
public void focusGained(FocusEvent e) {
- fLastFocusedField = this.fieldID;
- if (isFirstTime) {
- isFirstTime = false;
- return;
- }
- doStatusUpdate();
- }
-
- @Override
+ fLastFocusedField = this.fieldID;
+ if (isFirstTime) {
+ isFirstTime = false;
+ return;
+ }
+ doStatusUpdate();
+ }
+
+ @Override
public void focusLost(FocusEvent e) {
- fLastFocusedField = 0;
- doStatusUpdate();
- }
- }
+ fLastFocusedField = 0;
+ doStatusUpdate();
+ }
+ }
- private class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
+ private class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
@Override
public void changeControlPressed(DialogField field) {
- IPath oldFolderPath = getSourceFolderFullPath();
+ IPath oldFolderPath = getSourceFolderFullPath();
IPath newFolderPath = chooseSourceFolder(oldFolderPath);
if (newFolderPath != null) {
setSourceFolderFullPath(newFolderPath, false);
@@ -484,7 +485,7 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
}
}
- // ----------- validation ----------
+ // ----------- validation ----------
/**
* This method is a hook which gets called after the source folder's
@@ -509,27 +510,31 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
IProject proj = res.getProject();
if (!proj.isOpen()) {
- status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotAFolder, folderPath));
+ status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotAFolder,
+ folderPath));
return status;
}
- if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+ if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
if (resType == IResource.PROJECT) {
status.setError(NewFileWizardMessages.AbstractFileCreationWizardPage_warning_NotACProject);
return status;
}
status.setWarning(NewFileWizardMessages.AbstractFileCreationWizardPage_warning_NotInACProject);
}
- ICElement e = CoreModel.getDefault().create(res.getFullPath());
- if (CModelUtil.getSourceFolder(e) == null) {
- status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotASourceFolder, folderPath));
+ ICElement e = CoreModel.getDefault().create(res.getFullPath());
+ if (CModelUtil.getSourceFolder(e) == null) {
+ status.setError(NLS.bind(
+ NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotASourceFolder, folderPath));
return status;
}
} else {
- status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotAFolder, folderPath));
+ status.setError(
+ NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotAFolder, folderPath));
return status;
}
} else {
- status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_FolderDoesNotExist, folderPath));
+ status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_FolderDoesNotExist,
+ folderPath));
return status;
}
@@ -542,72 +547,70 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
* @param fields Bitwise-OR'd ids of the fields that changed.
*/
protected void handleFieldChanged(int fields) {
- if (fields == 0)
- return; // no change
+ if (fields == 0)
+ return; // no change
- if (fieldChanged(fields, SOURCE_FOLDER_ID)) {
+ if (fieldChanged(fields, SOURCE_FOLDER_ID)) {
fSourceFolderStatus = sourceFolderChanged();
- }
- if (fieldChanged(fields, NEW_FILE_ID)) {
- fNewFileStatus = fileNameChanged();
- }
+ }
+ if (fieldChanged(fields, NEW_FILE_ID)) {
+ fNewFileStatus = fileNameChanged();
+ }
doStatusUpdate();
}
private boolean fieldChanged(int fields, int fieldID) {
- return ((fields & fieldID) != 0);
+ return ((fields & fieldID) != 0);
}
protected void doStatusUpdate() {
- // do the last focused field first
- IStatus lastStatus = getLastFocusedStatus();
+ // do the last focused field first
+ IStatus lastStatus = getLastFocusedStatus();
- // status of all used components
- IStatus[] status = new IStatus[] {
- lastStatus,
- (fSourceFolderStatus != lastStatus) ? fSourceFolderStatus : STATUS_OK,
- (fNewFileStatus != lastStatus) ? fNewFileStatus : STATUS_OK,
- };
+ // status of all used components
+ IStatus[] status = new IStatus[] { lastStatus,
+ (fSourceFolderStatus != lastStatus) ? fSourceFolderStatus : STATUS_OK,
+ (fNewFileStatus != lastStatus) ? fNewFileStatus : STATUS_OK, };
// the mode severe status will be displayed and the ok button enabled/disabled.
updateStatus(status);
}
private IStatus getLastFocusedStatus() {
- switch (fLastFocusedField) {
- case SOURCE_FOLDER_ID:
- return fSourceFolderStatus;
- case NEW_FILE_ID:
- return fNewFileStatus;
- default:
- return STATUS_OK;
- }
- }
+ switch (fLastFocusedField) {
+ case SOURCE_FOLDER_ID:
+ return fSourceFolderStatus;
+ case NEW_FILE_ID:
+ return fNewFileStatus;
+ default:
+ return STATUS_OK;
+ }
+ }
public IPath getSourceFolderFullPath() {
String text = fSourceFolderDialogField.getText();
if (text.length() > 0)
- return new Path(text).makeAbsolute();
- return null;
+ return new Path(text).makeAbsolute();
+ return null;
}
public void setSourceFolderFullPath(IPath folderPath, boolean update) {
String str = (folderPath != null) ? folderPath.makeRelative().toString() : ""; //.makeRelative().toString(); //$NON-NLS-1$
fSourceFolderDialogField.setTextWithoutUpdate(str);
if (update) {
- fSourceFolderDialogField.dialogFieldChanged();
+ fSourceFolderDialogField.dialogFieldChanged();
}
}
protected IProject getCurrentProject() {
- IPath folderPath = getSourceFolderFullPath();
- if (folderPath != null) {
- return PathUtil.getEnclosingProject(folderPath);
- }
- return null;
+ IPath folderPath = getSourceFolderFullPath();
+ if (folderPath != null) {
+ return PathUtil.getEnclosingProject(folderPath);
+ }
+ return null;
}
- /**
+ /**
* Returns the workspace root.
*
* @return the workspace root
@@ -633,13 +636,13 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
protected abstract void setFocus();
IPath chooseSourceFolder(IPath initialPath) {
- ICElement initElement = getSourceFolderFromPath(initialPath);
- if (initElement instanceof ISourceRoot) {
- ICProject cProject = initElement.getCProject();
- ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject());
- if (projRoot != null && projRoot.equals(initElement))
- initElement = cProject;
- }
+ ICElement initElement = getSourceFolderFromPath(initialPath);
+ if (initElement instanceof ISourceRoot) {
+ ICProject cProject = initElement.getCProject();
+ ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject());
+ if (projRoot != null && projRoot.equals(initElement))
+ initElement = cProject;
+ }
SourceFolderSelectionDialog dialog = new SourceFolderSelectionDialog(getShell());
dialog.setInput(CoreModel.create(fWorkspaceRoot));
@@ -648,12 +651,12 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
if (dialog.open() == Window.OK) {
Object result = dialog.getFirstResult();
if (result instanceof ICElement) {
- ICElement element = (ICElement)result;
+ ICElement element = (ICElement) result;
if (element instanceof ICProject) {
- ICProject cproject = (ICProject)element;
+ ICProject cproject = (ICProject) element;
ISourceRoot folder = cproject.findSourceRoot(cproject.getProject());
if (folder != null)
- return folder.getResource().getFullPath();
+ return folder.getResource().getFullPath();
}
return element.getResource().getFullPath();
}
@@ -662,24 +665,24 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
}
private ICElement getSourceFolderFromPath(IPath path) {
- if (path == null)
- return null;
- while (path.segmentCount() > 0) {
- IResource res = fWorkspaceRoot.findMember(path);
+ if (path == null)
+ return null;
+ while (path.segmentCount() > 0) {
+ IResource res = fWorkspaceRoot.findMember(path);
if (res != null && res.exists()) {
int resType = res.getType();
if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
- ICElement elem = CoreModel.getDefault().create(res.getFullPath());
- ICContainer sourceFolder = CModelUtil.getSourceFolder(elem);
- if (sourceFolder != null)
- return sourceFolder;
- if (resType == IResource.PROJECT) {
- return elem;
- }
+ ICElement elem = CoreModel.getDefault().create(res.getFullPath());
+ ICContainer sourceFolder = CModelUtil.getSourceFolder(elem);
+ if (sourceFolder != null)
+ return sourceFolder;
+ if (resType == IResource.PROJECT) {
+ return elem;
+ }
}
}
path = path.removeLastSegments(1);
- }
+ }
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTemplateWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTemplateWizard.java
index 1ce2188d528..7925009f71f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTemplateWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTemplateWizard.java
@@ -39,97 +39,95 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
* @since 5.0
*/
public class NewFileFromTemplateWizard extends BasicNewResourceWizard {
- private WizardNewFileCreationPage mainPage;
+ private WizardNewFileCreationPage mainPage;
- /**
- * Creates a wizard for creating a new file resource in the workspace.
- */
- public NewFileFromTemplateWizard() {
- super();
- }
+ /**
+ * Creates a wizard for creating a new file resource in the workspace.
+ */
+ public NewFileFromTemplateWizard() {
+ super();
+ }
- /*
- * Method declared on IWizard.
- */
- @Override
+ /*
+ * Method declared on IWizard.
+ */
+ @Override
public void addPages() {
- super.addPages();
- mainPage = new WizardNewFileFromTemplateCreationPage("newFilePage1", getSelection());//$NON-NLS-1$
- mainPage.setTitle(NewFileWizardMessages.NewFileFromTemplateWizard_pageTitle);
- mainPage.setDescription(NewFileWizardMessages.NewFileFromTemplateWizard_description);
- addPage(mainPage);
- }
+ super.addPages();
+ mainPage = new WizardNewFileFromTemplateCreationPage("newFilePage1", getSelection());//$NON-NLS-1$
+ mainPage.setTitle(NewFileWizardMessages.NewFileFromTemplateWizard_pageTitle);
+ mainPage.setDescription(NewFileWizardMessages.NewFileFromTemplateWizard_description);
+ addPage(mainPage);
+ }
- /*
- * Method declared on IWorkbenchWizard.
- */
- @Override
+ /*
+ * Method declared on IWorkbenchWizard.
+ */
+ @Override
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
- super.init(workbench, currentSelection);
- setWindowTitle(NewFileWizardMessages.NewFileFromTemplateWizard_shellTitle);
- setNeedsProgressMonitor(true);
- }
+ super.init(workbench, currentSelection);
+ setWindowTitle(NewFileWizardMessages.NewFileFromTemplateWizard_shellTitle);
+ setNeedsProgressMonitor(true);
+ }
- /*
- * Method declared on BasicNewResourceWizard.
- */
- @Override
+ /*
+ * Method declared on BasicNewResourceWizard.
+ */
+ @Override
protected void initializeDefaultPageImageDescriptor() {
- ImageDescriptor desc = CPluginImages.DESC_WIZBAN_NEW_FILE;
- setDefaultPageImageDescriptor(desc);
- }
+ ImageDescriptor desc = CPluginImages.DESC_WIZBAN_NEW_FILE;
+ setDefaultPageImageDescriptor(desc);
+ }
- /*
- * Method declared on IWizard.
- */
- @Override
+ /*
+ * Method declared on IWizard.
+ */
+ @Override
public boolean performFinish() {
- IFile file = mainPage.createNewFile();
- if (file == null) {
+ IFile file = mainPage.createNewFile();
+ if (file == null) {
return false;
}
- selectAndReveal(file);
+ selectAndReveal(file);
- // Open editor on new file.
- IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
- try {
- if (dw != null) {
- IWorkbenchPage page = dw.getActivePage();
- if (page != null) {
- IDE.openEditor(page, file, true);
- }
- }
- } catch (PartInitException e) {
- openError(getShell(), NewFileWizardMessages.NewFileFromTemplateWizard_errorMessage, e.getMessage(), e);
- }
+ // Open editor on new file.
+ IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
+ try {
+ if (dw != null) {
+ IWorkbenchPage page = dw.getActivePage();
+ if (page != null) {
+ IDE.openEditor(page, file, true);
+ }
+ }
+ } catch (PartInitException e) {
+ openError(getShell(), NewFileWizardMessages.NewFileFromTemplateWizard_errorMessage, e.getMessage(), e);
+ }
- return true;
- }
+ return true;
+ }
- /**
- * Open an error style dialog for PartInitException by
- * including any extra information from the nested
- * CoreException if present.
- */
- public static void openError(Shell parent, String title, String message,
- PartInitException exception) {
- // Check for a nested CoreException
- CoreException nestedException = null;
- IStatus status = exception.getStatus();
- if (status != null && status.getException() instanceof CoreException) {
+ /**
+ * Open an error style dialog for PartInitException by
+ * including any extra information from the nested
+ * CoreException if present.
+ */
+ public static void openError(Shell parent, String title, String message, PartInitException exception) {
+ // Check for a nested CoreException
+ CoreException nestedException = null;
+ IStatus status = exception.getStatus();
+ if (status != null && status.getException() instanceof CoreException) {
nestedException = (CoreException) status.getException();
}
- if (nestedException != null) {
- // Open an error dialog and include the extra
- // status information from the nested CoreException
- ErrorDialog.openError(parent, title, message, nestedException
- .getStatus());
- } else {
- // Open a regular error dialog since there is no
- // extra information to display
- MessageDialog.openError(parent, title, message);
- }
- }
+ if (nestedException != null) {
+ // Open an error dialog and include the extra
+ // status information from the nested CoreException
+ ErrorDialog.openError(parent, title, message, nestedException.getStatus());
+ } else {
+ // Open a regular error dialog since there is no
+ // extra information to display
+ MessageDialog.openError(parent, title, message);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java
index 5726e60c05f..57b0400c96c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java
@@ -48,11 +48,11 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
private ITranslationUnit fNewFileTU = null;
private StringDialogField fNewFileDialogField;
-
+
public NewHeaderFileCreationWizardPage() {
super(NewFileWizardMessages.NewHeaderFileCreationWizard_title);
setTitle(NewFileWizardMessages.NewHeaderFileCreationWizardPage_title);
- setDescription(NewFileWizardMessages.NewHeaderFileCreationWizardPage_description);
+ setDescription(NewFileWizardMessages.NewHeaderFileCreationWizardPage_description);
fNewFileDialogField = new StringDialogField();
fNewFileDialogField.setDialogFieldListener(new IDialogFieldListener() {
@@ -61,24 +61,24 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
handleFieldChanged(NEW_FILE_ID);
}
});
- fNewFileDialogField.setLabelText(NewFileWizardMessages.NewHeaderFileCreationWizardPage_headerFile_label);
+ fNewFileDialogField.setLabelText(NewFileWizardMessages.NewHeaderFileCreationWizardPage_headerFile_label);
}
-
+
/**
* Sets the focus on the starting input field.
- */
+ */
@Override
protected void setFocus() {
fNewFileDialogField.setFocus();
}
/**
- * Creates the controls for the file name field. Expects a <code>GridLayout</code> with at
+ * Creates the controls for the file name field. Expects a <code>GridLayout</code> with at
* least 2 columns.
- *
+ *
* @param parent the parent composite
* @param nColumns number of columns to span
- */
+ */
@Override
protected void createFileControls(Composite parent, int nColumns) {
fNewFileDialogField.doFillIntoGrid(parent, nColumns);
@@ -86,94 +86,98 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
textControl.addFocusListener(new StatusFocusListener(NEW_FILE_ID));
}
-
+
@Override
public IPath getFileFullPath() {
String str = fNewFileDialogField.getText();
- IPath path = null;
- if (str.length() > 0) {
- path = new Path(str);
- if (!path.isAbsolute()) {
- IPath folderPath = getSourceFolderFullPath();
- if (folderPath != null)
- path = folderPath.append(path);
- }
- }
- return path;
+ IPath path = null;
+ if (str.length() > 0) {
+ path = new Path(str);
+ if (!path.isAbsolute()) {
+ IPath folderPath = getSourceFolderFullPath();
+ if (folderPath != null)
+ path = folderPath.append(path);
+ }
+ }
+ return path;
}
@Override
protected IStatus fileNameChanged() {
StatusInfo status = new StatusInfo();
-
+
IPath filePath = getFileFullPath();
if (filePath == null) {
- status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_EnterFileName);
+ status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_EnterFileName);
return status;
}
IPath sourceFolderPath = getSourceFolderFullPath();
if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(filePath)) {
- status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FileNotInSourceFolder);
+ status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FileNotInSourceFolder);
return status;
}
-
+
// check if file already exists
IResource file = getWorkspaceRoot().findMember(filePath);
if (file != null && file.exists()) {
- if (file.getType() == IResource.FILE) {
- status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FileExists);
- } else if (file.getType() == IResource.FOLDER) {
- status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_MatchingFolderExists);
- } else {
- status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_MatchingResourceExists);
- }
+ if (file.getType() == IResource.FILE) {
+ status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FileExists);
+ } else if (file.getType() == IResource.FOLDER) {
+ status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_MatchingFolderExists);
+ } else {
+ status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_MatchingResourceExists);
+ }
return status;
}
-
+
// check if folder exists
IPath folderPath = filePath.removeLastSegments(1).makeRelative();
IResource folder = getWorkspaceRoot().findMember(folderPath);
- if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
- status.setError(NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FolderDoesNotExist, folderPath));
+ if (folder == null || !folder.exists()
+ || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+ status.setError(NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FolderDoesNotExist,
+ folderPath));
return status;
}
IStatus convStatus = CConventions.validateHeaderFileName(getCurrentProject(), filePath.lastSegment());
if (convStatus.getSeverity() == IStatus.ERROR) {
- status.setError(NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_InvalidFileName, convStatus.getMessage()));
+ status.setError(NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_InvalidFileName,
+ convStatus.getMessage()));
return status;
} else if (convStatus.getSeverity() == IStatus.WARNING) {
- status.setWarning(NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_warning_FileNameDiscouraged, convStatus.getMessage()));
+ status.setWarning(
+ NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_warning_FileNameDiscouraged,
+ convStatus.getMessage()));
}
return status;
}
-
+
@Override
public void createFile(IProgressMonitor monitor) throws CoreException {
- IPath filePath = getFileFullPath();
- if (filePath != null) {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- try {
- fNewFileTU = null;
- IFile newFile = NewSourceFileGenerator.createHeaderFile(filePath, true, monitor);
- if (newFile != null) {
- fNewFileTU = (ITranslationUnit) CoreModel.getDefault().create(newFile);
- if (fNewFileTU != null) {
- String lineDelimiter= StubUtility.getLineDelimiterUsed(fNewFileTU);
- String content= CodeGeneration.getHeaderFileContent(getTemplate(),
- fNewFileTU, lineDelimiter);
+ IPath filePath = getFileFullPath();
+ if (filePath != null) {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ try {
+ fNewFileTU = null;
+ IFile newFile = NewSourceFileGenerator.createHeaderFile(filePath, true, monitor);
+ if (newFile != null) {
+ fNewFileTU = (ITranslationUnit) CoreModel.getDefault().create(newFile);
+ if (fNewFileTU != null) {
+ String lineDelimiter = StubUtility.getLineDelimiterUsed(fNewFileTU);
+ String content = CodeGeneration.getHeaderFileContent(getTemplate(), fNewFileTU, lineDelimiter);
if (content != null) {
fNewFileTU.getBuffer().setContents(content.toCharArray());
fNewFileTU.save(monitor, true);
}
- }
- }
- } finally {
- monitor.done();
- }
- }
+ }
+ }
+ } finally {
+ monitor.done();
+ }
+ }
}
/* (non-Javadoc)
@@ -192,7 +196,7 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
return StubUtility.getFileTemplatesForContentTypes(
new String[] { CCorePlugin.CONTENT_TYPE_CXXHEADER, CCorePlugin.CONTENT_TYPE_CHEADER }, null);
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getDefaultTemplateName()
*/
@@ -202,10 +206,9 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
if (name == null) {
IProject project = getCurrentProject();
if (project != null) {
- String contentType = CProject.hasCCNature(project) ?
- CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
- Template[] templates =
- StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
+ String contentType = CProject.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER
+ : CCorePlugin.CONTENT_TYPE_CHEADER;
+ Template[] templates = StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
if (templates.length != 0) {
name = templates[0].getName();
}
@@ -213,7 +216,7 @@ public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardP
}
return name;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#savePreferredTemplateName(String)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java
index 72857229526..5c54b18c9c7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java
@@ -52,11 +52,11 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
private ITranslationUnit fNewFileTU = null;
private StringDialogField fNewFileDialogField;
-
+
public NewSourceFileCreationWizardPage() {
super(NewFileWizardMessages.NewSourceFileCreationWizard_title);
setTitle(NewFileWizardMessages.NewSourceFileCreationWizardPage_title);
- setDescription(NewFileWizardMessages.NewSourceFileCreationWizardPage_description);
+ setDescription(NewFileWizardMessages.NewSourceFileCreationWizardPage_description);
fNewFileDialogField = new StringDialogField();
fNewFileDialogField.setDialogFieldListener(new IDialogFieldListener() {
@@ -65,9 +65,9 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
handleFieldChanged(NEW_FILE_ID);
}
});
- fNewFileDialogField.setLabelText(NewFileWizardMessages.NewSourceFileCreationWizardPage_sourceFile_label);
+ fNewFileDialogField.setLabelText(NewFileWizardMessages.NewSourceFileCreationWizardPage_sourceFile_label);
}
-
+
/**
* Sets the focus on the starting input field.
*/
@@ -77,12 +77,12 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
}
/**
- * Creates the controls for the file name field. Expects a <code>GridLayout</code> with at
+ * Creates the controls for the file name field. Expects a <code>GridLayout</code> with at
* least 2 columns.
- *
+ *
* @param parent the parent composite
* @param nColumns number of columns to span
- */
+ */
@Override
protected void createFileControls(Composite parent, int nColumns) {
fNewFileDialogField.doFillIntoGrid(parent, nColumns);
@@ -91,93 +91,99 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
textControl.addFocusListener(new StatusFocusListener(NEW_FILE_ID));
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getParent(), ICHelpContextIds.NEW_C_FILE_WIZARD_PAGE);
}
-
+
@Override
public IPath getFileFullPath() {
String str = fNewFileDialogField.getText();
- IPath path = null;
- if (str.length() > 0) {
- path = new Path(str);
- if (!path.isAbsolute()) {
- IPath folderPath = getSourceFolderFullPath();
- if (folderPath != null)
- path = folderPath.append(path);
- }
- }
- return path;
+ IPath path = null;
+ if (str.length() > 0) {
+ path = new Path(str);
+ if (!path.isAbsolute()) {
+ IPath folderPath = getSourceFolderFullPath();
+ if (folderPath != null)
+ path = folderPath.append(path);
+ }
+ }
+ return path;
}
-
+
@Override
protected IStatus fileNameChanged() {
StatusInfo status = new StatusInfo();
-
+
IPath filePath = getFileFullPath();
if (filePath == null) {
- status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_EnterFileName);
+ status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_EnterFileName);
return status;
}
IPath sourceFolderPath = getSourceFolderFullPath();
if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(filePath)) {
- status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FileNotInSourceFolder);
+ status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FileNotInSourceFolder);
return status;
}
-
+
// check if file already exists
IResource file = getWorkspaceRoot().findMember(filePath);
if (file != null && file.exists()) {
- if (file.getType() == IResource.FILE) {
- status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FileExists);
- } else if (file.getType() == IResource.FOLDER) {
- status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_MatchingFolderExists);
- } else {
- status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_MatchingResourceExists);
- }
+ if (file.getType() == IResource.FILE) {
+ status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FileExists);
+ } else if (file.getType() == IResource.FOLDER) {
+ status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_MatchingFolderExists);
+ } else {
+ status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_MatchingResourceExists);
+ }
return status;
}
-
+
// check if folder exists
IPath folderPath = filePath.removeLastSegments(1).makeRelative();
IResource folder = getWorkspaceRoot().findMember(folderPath);
- if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
- status.setError(NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FolderDoesNotExist, folderPath));
+ if (folder == null || !folder.exists()
+ || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+ status.setError(NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FolderDoesNotExist,
+ folderPath));
return status;
}
IStatus convStatus = CConventions.validateSourceFileName(getCurrentProject(), filePath.lastSegment());
if (convStatus.getSeverity() == IStatus.ERROR) {
- status.setError(NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_InvalidFileName, convStatus.getMessage()));
+ status.setError(NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_InvalidFileName,
+ convStatus.getMessage()));
return status;
} else if (convStatus.getSeverity() == IStatus.WARNING) {
- status.setWarning(NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_warning_FileNameDiscouraged, convStatus.getMessage()));
+ status.setWarning(
+ NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_warning_FileNameDiscouraged,
+ convStatus.getMessage()));
}
return status;
}
-
+
@Override
public void createFile(IProgressMonitor monitor) throws CoreException {
- IPath filePath = getFileFullPath();
- if (filePath != null) {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- try {
- fNewFileTU = null;
- IFile newFile = NewSourceFileGenerator.createSourceFile(filePath, true, monitor);
- if (newFile != null) {
- fNewFileTU = (ITranslationUnit) CoreModel.getDefault().create(newFile);
- if (fNewFileTU != null) {
- String lineDelimiter= StubUtility.getLineDelimiterUsed(fNewFileTU);
- String content= CodeGeneration.getBodyFileContent(getTemplate(), fNewFileTU, null, null, lineDelimiter);
+ IPath filePath = getFileFullPath();
+ if (filePath != null) {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ try {
+ fNewFileTU = null;
+ IFile newFile = NewSourceFileGenerator.createSourceFile(filePath, true, monitor);
+ if (newFile != null) {
+ fNewFileTU = (ITranslationUnit) CoreModel.getDefault().create(newFile);
+ if (fNewFileTU != null) {
+ String lineDelimiter = StubUtility.getLineDelimiterUsed(fNewFileTU);
+ String content = CodeGeneration.getBodyFileContent(getTemplate(), fNewFileTU, null, null,
+ lineDelimiter);
if (content != null) {
fNewFileTU.getBuffer().setContents(content.toCharArray());
fNewFileTU.save(monitor, true);
}
- }
- }
- } finally {
- monitor.done();
- }
- }
+ }
+ }
+ } finally {
+ monitor.done();
+ }
+ }
}
/* (non-Javadoc)
@@ -196,7 +202,7 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
return StubUtility.getFileTemplatesForContentTypes(
new String[] { CCorePlugin.CONTENT_TYPE_CXXSOURCE, CCorePlugin.CONTENT_TYPE_CSOURCE }, null);
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getDefaultTemplateName()
*/
@@ -206,10 +212,9 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
if (name == null) {
IProject project = getCurrentProject();
if (project != null) {
- String contentType = CProject.hasCCNature(project) ?
- CCorePlugin.CONTENT_TYPE_CXXSOURCE : CCorePlugin.CONTENT_TYPE_CSOURCE;
- Template[] templates =
- StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
+ String contentType = CProject.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXSOURCE
+ : CCorePlugin.CONTENT_TYPE_CSOURCE;
+ Template[] templates = StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
if (templates.length != 0) {
name = templates[0].getName();
}
@@ -217,7 +222,7 @@ public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardP
}
return name;
}
-
+
/*
* @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#savePreferredTemplateName(String)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java
index 1598bce26bd..5ffef30bd54 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java
@@ -37,141 +37,137 @@ import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.ui.dialogs.ContainerGenerator;
public class NewSourceFileGenerator {
- /**
- * Creates a header file name from the given class name. This is the file name
- * to be used when the class is created. eg. "MyClass" -> "MyClass.h"
- *
- * @param className the class name
- * @return the header file name for the given class
- */
- public static String generateHeaderFileNameFromClass(String className) {
- IPreferencesService preferences = Platform.getPreferencesService();
- int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION,
- PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
- String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER, "", null); //$NON-NLS-1$
- String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX, "", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_HEADER_SUFFIX, ".h", null); //$NON-NLS-1$
- NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
- return composer.compose(className);
- }
-
- /**
- * Creates a source file name from the given class name. This is the file name
- * to be used when the class is created. e.g. "MyClass" -> "MyClass.cpp"
- *
- * @param className the class name
- * @return the source file name for the given class
- */
- public static String generateSourceFileNameFromClass(String className) {
- IPreferencesService preferences = Platform.getPreferencesService();
- int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION,
- PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
- String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER, "", null); //$NON-NLS-1$
- String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_SOURCE_PREFIX, "", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_SOURCE_SUFFIX, ".cpp", null); //$NON-NLS-1$
- NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
- return composer.compose(className);
- }
-
- /**
- * Creates a file name for the unit test from the given class name. This is the file name
- * to be used when the test is created. e.g. "MyClass" -> "MyClass_test.cpp"
- *
- * @param className the class name
- * @return the test file name for the given class
- */
- public static String generateTestFileNameFromClass(String className) {
- IPreferencesService preferences = Platform.getPreferencesService();
- int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_TEST_CAPITALIZATION,
- PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
- String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_TEST_WORD_DELIMITER, "", null); //$NON-NLS-1$
- String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_TEST_PREFIX, "", null); //$NON-NLS-1$
- String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
- PreferenceConstants.NAME_STYLE_CPP_TEST_SUFFIX, "_test.cpp", null); //$NON-NLS-1$
- NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
- return composer.compose(className);
- }
-
- public static IFile createHeaderFile(IPath filePath, boolean force, IProgressMonitor monitor)
- throws CoreException {
+ /**
+ * Creates a header file name from the given class name. This is the file name
+ * to be used when the class is created. eg. "MyClass" -> "MyClass.h"
+ *
+ * @param className the class name
+ * @return the header file name for the given class
+ */
+ public static String generateHeaderFileNameFromClass(String className) {
+ IPreferencesService preferences = Platform.getPreferencesService();
+ int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+ String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX, "", //$NON-NLS-1$
+ null);
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_CPP_HEADER_SUFFIX,
+ ".h", null); //$NON-NLS-1$
+ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+ return composer.compose(className);
+ }
+
+ /**
+ * Creates a source file name from the given class name. This is the file name
+ * to be used when the class is created. e.g. "MyClass" -> "MyClass.cpp"
+ *
+ * @param className the class name
+ * @return the source file name for the given class
+ */
+ public static String generateSourceFileNameFromClass(String className) {
+ IPreferencesService preferences = Platform.getPreferencesService();
+ int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+ String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_CPP_SOURCE_PREFIX, "", //$NON-NLS-1$
+ null);
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_CPP_SOURCE_SUFFIX,
+ ".cpp", null); //$NON-NLS-1$
+ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+ return composer.compose(className);
+ }
+
+ /**
+ * Creates a file name for the unit test from the given class name. This is the file name
+ * to be used when the test is created. e.g. "MyClass" -> "MyClass_test.cpp"
+ *
+ * @param className the class name
+ * @return the test file name for the given class
+ */
+ public static String generateTestFileNameFromClass(String className) {
+ IPreferencesService preferences = Platform.getPreferencesService();
+ int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_TEST_CAPITALIZATION,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+ String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_TEST_WORD_DELIMITER, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_CPP_TEST_PREFIX, "", //$NON-NLS-1$
+ null);
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_CPP_TEST_SUFFIX,
+ "_test.cpp", null); //$NON-NLS-1$
+ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+ return composer.compose(className);
+ }
+
+ public static IFile createHeaderFile(IPath filePath, boolean force, IProgressMonitor monitor) throws CoreException {
return createEmptyFile(filePath, force, monitor);
- }
-
- public static IFile createSourceFile(IPath filePath, boolean force, IProgressMonitor monitor)
- throws CoreException {
+ }
+
+ public static IFile createSourceFile(IPath filePath, boolean force, IProgressMonitor monitor) throws CoreException {
return createEmptyFile(filePath, force, monitor);
- }
+ }
- public static IFile createTestFile(IPath filePath, boolean force, IProgressMonitor monitor)
- throws CoreException {
+ public static IFile createTestFile(IPath filePath, boolean force, IProgressMonitor monitor) throws CoreException {
return createEmptyFile(filePath, force, monitor);
- }
+ }
- public static IFile createEmptyFile(IPath filePath, boolean force, IProgressMonitor monitor)
- throws CoreException {
- ByteArrayInputStream stream = new ByteArrayInputStream(new byte[0]);
+ public static IFile createEmptyFile(IPath filePath, boolean force, IProgressMonitor monitor) throws CoreException {
+ ByteArrayInputStream stream = new ByteArrayInputStream(new byte[0]);
return createNewFile(filePath, stream, force, monitor);
- }
-
- private static IFile createNewFile(IPath newFilePath, InputStream contents, boolean force,
- IProgressMonitor monitor) throws CoreException {
- int totalWork = 100;
- int createFileWork = totalWork;
-
- monitor.beginTask(NewFileWizardMessages.NewSourceFileGenerator_createFile_task, totalWork);
-
- IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
- IFile newFile = root.getFileForLocation(newFilePath);
- if (newFile == null)
- newFile = root.getFile(newFilePath);
- if (newFile.exists()) {
- monitor.done();
- return newFile;
- }
-
- if (newFilePath.segmentCount() > 1) {
- IPath containerPath = newFilePath.removeLastSegments(1);
- if (root.getContainerForLocation(containerPath) == null) {
- int containerWork = totalWork / 2;
- createFileWork = totalWork / 2;
- ContainerGenerator generator = new ContainerGenerator(containerPath);
- generator.generateContainer(new SubProgressMonitor(monitor, containerWork));
- }
- }
-
- createFile(newFile, contents, force, new SubProgressMonitor(monitor, createFileWork));
- monitor.done();
-
- return newFile;
- }
-
- private static void createFile(IFile fileHandle, InputStream contents, boolean force,
- IProgressMonitor monitor) throws CoreException {
- if (contents == null)
- contents = new ByteArrayInputStream(new byte[0]);
-
- try {
- fileHandle.create(contents, force, monitor);
- } catch (CoreException e) {
- // If the file already existed locally, just refresh to get contents
- if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED)
- fileHandle.refreshLocal(IResource.DEPTH_ZERO, null);
- else
- throw e;
- }
-
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- }
+ }
+
+ private static IFile createNewFile(IPath newFilePath, InputStream contents, boolean force, IProgressMonitor monitor)
+ throws CoreException {
+ int totalWork = 100;
+ int createFileWork = totalWork;
+
+ monitor.beginTask(NewFileWizardMessages.NewSourceFileGenerator_createFile_task, totalWork);
+
+ IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
+ IFile newFile = root.getFileForLocation(newFilePath);
+ if (newFile == null)
+ newFile = root.getFile(newFilePath);
+ if (newFile.exists()) {
+ monitor.done();
+ return newFile;
+ }
+
+ if (newFilePath.segmentCount() > 1) {
+ IPath containerPath = newFilePath.removeLastSegments(1);
+ if (root.getContainerForLocation(containerPath) == null) {
+ int containerWork = totalWork / 2;
+ createFileWork = totalWork / 2;
+ ContainerGenerator generator = new ContainerGenerator(containerPath);
+ generator.generateContainer(new SubProgressMonitor(monitor, containerWork));
+ }
+ }
+
+ createFile(newFile, contents, force, new SubProgressMonitor(monitor, createFileWork));
+ monitor.done();
+
+ return newFile;
+ }
+
+ private static void createFile(IFile fileHandle, InputStream contents, boolean force, IProgressMonitor monitor)
+ throws CoreException {
+ if (contents == null)
+ contents = new ByteArrayInputStream(new byte[0]);
+
+ try {
+ fileHandle.create(contents, force, monitor);
+ } catch (CoreException e) {
+ // If the file already existed locally, just refresh to get contents
+ if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED)
+ fileHandle.refreshLocal(IResource.DEPTH_ZERO, null);
+ else
+ throw e;
+ }
+
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java
index 8433528688f..2d4366aa8ed 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java
@@ -62,11 +62,11 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
private Combo fTemplatesCombo;
private Template[] fTemplates;
- protected boolean fUseTemplate= true;
+ protected boolean fUseTemplate = true;
/**
* Create a new 'file from template' page.
- *
+ *
* @param pageName
* @param selection
*/
@@ -79,39 +79,39 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
*/
@Override
protected void createAdvancedControls(Composite parent) {
- Composite groupComposite= new Composite(parent,SWT.NONE);
+ Composite groupComposite = new Composite(parent, SWT.NONE);
groupComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
groupComposite.setLayout(layout);
- final Button useTemplateButton= new Button(groupComposite, SWT.CHECK);
+ final Button useTemplateButton = new Button(groupComposite, SWT.CHECK);
useTemplateButton.setText(NewFileWizardMessages.WizardNewFileFromTemplateCreationPage_useTemplate_label);
useTemplateButton.setSelection(fUseTemplate);
- SelectionListener useTemplateListener= new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- fUseTemplate= useTemplateButton.getSelection();
- fTemplatesCombo.setEnabled(fUseTemplate);
- }
- };
+ SelectionListener useTemplateListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ fUseTemplate = useTemplateButton.getSelection();
+ fTemplatesCombo.setEnabled(fUseTemplate);
+ }
+ };
useTemplateButton.addSelectionListener(useTemplateListener);
- fTemplatesCombo= new Combo(groupComposite, SWT.READ_ONLY);
+ fTemplatesCombo = new Combo(groupComposite, SWT.READ_ONLY);
fTemplatesCombo.setEnabled(fUseTemplate);
fTemplatesCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- final Button configureButton= new Button(groupComposite, SWT.PUSH);
+
+ final Button configureButton = new Button(groupComposite, SWT.PUSH);
configureButton.setText(NewFileWizardMessages.WizardNewFileFromTemplateCreationPage_configure_label);
- SelectionListener changeTemplateListener= new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- editTemplates();
- }
- };
+ SelectionListener changeTemplateListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ editTemplates();
+ }
+ };
configureButton.addSelectionListener(changeTemplateListener);
updateTemplates();
@@ -119,18 +119,19 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
}
protected void editTemplates() {
- String prefPageId= CodeTemplatePreferencePage.PREF_ID;
- Map<String, String> data= null;
- String templateName= null;
- Template template= getSelectedTemplate();
+ String prefPageId = CodeTemplatePreferencePage.PREF_ID;
+ Map<String, String> data = null;
+ String templateName = null;
+ Template template = getSelectedTemplate();
if (template != null) {
- templateName= template.getName();
+ templateName = template.getName();
}
if (templateName != null) {
- data= new HashMap<String, String>();
+ data = new HashMap<String, String>();
data.put(CodeTemplatePreferencePage.DATA_SELECT_TEMPLATE, templateName);
}
- PreferenceDialog dialog= PreferencesUtil.createPreferenceDialogOn(getShell(), prefPageId, new String[] { prefPageId }, data);
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), prefPageId,
+ new String[] { prefPageId }, data);
if (dialog.open() == Window.OK) {
updateTemplates();
}
@@ -141,15 +142,15 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
*/
@Override
protected InputStream getInitialContents() {
- Template template= getSelectedTemplate();
+ Template template = getSelectedTemplate();
if (fUseTemplate && template != null) {
- IFile fileHandle= createFileHandle(getContainerFullPath().append(getResourceName()));
- String lineDelimiter= StubUtility.getLineDelimiterPreference(getContainterProject());
+ IFile fileHandle = createFileHandle(getContainerFullPath().append(getResourceName()));
+ String lineDelimiter = StubUtility.getLineDelimiterPreference(getContainterProject());
try {
- String content= StubUtility.getFileContent(template, fileHandle, lineDelimiter);
+ String content = StubUtility.getFileContent(template, fileHandle, lineDelimiter);
if (content != null) {
try {
- String charset= fileHandle.getParent().getDefaultCharset();
+ String charset = fileHandle.getParent().getDefaultCharset();
return new ByteArrayInputStream(content.getBytes(charset));
} catch (UnsupportedEncodingException exc) {
return new ByteArrayInputStream(content.getBytes());
@@ -171,20 +172,21 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
}
protected void updateTemplates() {
- Template selected= getSelectedTemplate();
- boolean isDefaultSelected= (selected != null && fTemplates.length == 1) || (fTemplatesCombo != null && fTemplatesCombo.getSelectionIndex() == 0);
- fTemplates= getApplicableTemplates();
- int idx= 0;
- String[] names= new String[fTemplates.length];
+ Template selected = getSelectedTemplate();
+ boolean isDefaultSelected = (selected != null && fTemplates.length == 1)
+ || (fTemplatesCombo != null && fTemplatesCombo.getSelectionIndex() == 0);
+ fTemplates = getApplicableTemplates();
+ int idx = 0;
+ String[] names = new String[fTemplates.length];
for (int i = 0; i < names.length; i++) {
- names[i]= fTemplates[i].getName();
+ names[i] = fTemplates[i].getName();
if (!isDefaultSelected && selected != null && selected.getName().equals(names[i])) {
- idx= i;
+ idx = i;
}
}
if (fTemplatesCombo != null) {
if (names.length == 0) {
- names= new String[] { NewFileWizardMessages.WizardNewFileFromTemplateCreationPage_noTemplate_name };
+ names = new String[] { NewFileWizardMessages.WizardNewFileFromTemplateCreationPage_noTemplate_name };
}
fTemplatesCombo.setItems(names);
fTemplatesCombo.select(idx);
@@ -196,11 +198,11 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
*/
protected Template getSelectedTemplate() {
if (fTemplates != null) {
- int index= 0;
+ int index = 0;
if (fTemplatesCombo != null) {
- index= fTemplatesCombo.getSelectionIndex();
+ index = fTemplatesCombo.getSelectionIndex();
if (index < 0) {
- index= 0;
+ index = 0;
}
}
if (index < fTemplates.length) {
@@ -211,8 +213,8 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
}
private String getResourceName() {
- String fileName= getFileName();
- String fileExtension= getFileExtension();
+ String fileName = getFileName();
+ String fileExtension = getFileExtension();
if (fileExtension != null && fileExtension.length() > 0 && !fileName.endsWith('.' + fileExtension)) {
fileName += '.';
fileName += fileExtension;
@@ -221,7 +223,7 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
}
private IProject getContainterProject() {
- IPath containerPath= getContainerFullPath();
+ IPath containerPath = getContainerFullPath();
if (containerPath != null) {
return ResourcesPlugin.getWorkspace().getRoot().getProject(containerPath.segment(0));
}
@@ -229,46 +231,46 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
}
/**
- * Configure the set of selectable templates.
+ * Configure the set of selectable templates.
* @return the set of templates
*/
protected Template[] getApplicableTemplates() {
- IProject project= getContainterProject();
- String fileName= getResourceName();
- String[] contentTypes= getAllContentTypeIdsForFileName(project, fileName);
+ IProject project = getContainterProject();
+ String fileName = getResourceName();
+ String[] contentTypes = getAllContentTypeIdsForFileName(project, fileName);
return StubUtility.getFileTemplatesForContentTypes(contentTypes, project);
}
private static String[] getAllContentTypeIdsForFileName(IProject project, String fileName) {
IContentTypeMatcher matcher;
if (project == null || !project.isAccessible()) {
- IContentTypeManager contentTypeMgr= Platform.getContentTypeManager();
- matcher= contentTypeMgr;
+ IContentTypeManager contentTypeMgr = Platform.getContentTypeManager();
+ matcher = contentTypeMgr;
} else {
try {
- matcher= project.getContentTypeMatcher();
+ matcher = project.getContentTypeMatcher();
} catch (CoreException exc) {
- IContentTypeManager contentTypeMgr= Platform.getContentTypeManager();
- matcher= contentTypeMgr;
+ IContentTypeManager contentTypeMgr = Platform.getContentTypeManager();
+ matcher = contentTypeMgr;
}
}
- IContentType[] contentTypes= matcher.findContentTypesFor(fileName);
- List<String> result= new ArrayList<String>(contentTypes.length * 2);
+ IContentType[] contentTypes = matcher.findContentTypesFor(fileName);
+ List<String> result = new ArrayList<String>(contentTypes.length * 2);
for (int i = 0; i < contentTypes.length; i++) {
IContentType contentType = contentTypes[i];
- String id= contentType.getId();
+ String id = contentType.getId();
result.add(id);
}
// add base types
for (int i = 0; i < contentTypes.length; i++) {
IContentType contentType = contentTypes[i].getBaseType();
while (contentType != null) {
- String id= contentType.getId();
+ String id = contentType.getId();
if (result.contains(id)) {
break;
}
result.add(id);
- contentType= contentType.getBaseType();
+ contentType = contentType.getBaseType();
}
}
if (result.isEmpty()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java
index 7d749265ec9..42edfe4f1d6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java
@@ -77,7 +77,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFie
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
public class NewSourceFolderWizardPage extends NewElementWizardPage {
- private static final String PAGE_NAME= "NewSourceFolderWizardPage"; //$NON-NLS-1$
+ private static final String PAGE_NAME = "NewSourceFolderWizardPage"; //$NON-NLS-1$
private StringButtonDialogField fProjectField;
private StatusInfo fProjectStatus;
@@ -104,26 +104,26 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
setTitle(NewFolderWizardMessages.NewSourceFolderWizardPage_title);
setDescription(NewFolderWizardMessages.NewSourceFolderWizardPage_description);
- fWorkspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
+ fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- RootFieldAdapter adapter= new RootFieldAdapter();
+ RootFieldAdapter adapter = new RootFieldAdapter();
- fProjectField= new StringButtonDialogField(adapter);
+ fProjectField = new StringButtonDialogField(adapter);
fProjectField.setDialogFieldListener(adapter);
fProjectField.setLabelText(NewFolderWizardMessages.NewSourceFolderWizardPage_project_label);
fProjectField.setButtonLabel(NewFolderWizardMessages.NewSourceFolderWizardPage_project_button);
- fRootDialogField= new StringButtonDialogField(adapter);
+ fRootDialogField = new StringButtonDialogField(adapter);
fRootDialogField.setDialogFieldListener(adapter);
fRootDialogField.setLabelText(NewFolderWizardMessages.NewSourceFolderWizardPage_root_label);
fRootDialogField.setButtonLabel(NewFolderWizardMessages.NewSourceFolderWizardPage_root_button);
- fExcludeInOthersFields= new SelectionButtonDialogField(SWT.CHECK);
+ fExcludeInOthersFields = new SelectionButtonDialogField(SWT.CHECK);
fExcludeInOthersFields.setDialogFieldListener(adapter);
fExcludeInOthersFields.setLabelText(NewFolderWizardMessages.NewSourceFolderWizardPage_exclude_label);
- fRootStatus= new StatusInfo();
- fProjectStatus= new StatusInfo();
+ fRootStatus = new StatusInfo();
+ fProjectStatus = new StatusInfo();
}
// -------- Initialization ---------
@@ -134,22 +134,22 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
return;
}
- Object selectedElement= selection.getFirstElement();
+ Object selectedElement = selection.getFirstElement();
if (selectedElement == null) {
- selectedElement= EditorUtility.getActiveEditorCInput();
+ selectedElement = EditorUtility.getActiveEditorCInput();
}
- String projPath= null;
+ String projPath = null;
if (selectedElement instanceof IResource) {
- IProject proj= ((IResource) selectedElement).getProject();
+ IProject proj = ((IResource) selectedElement).getProject();
if (proj != null) {
- projPath= proj.getFullPath().makeRelative().toString();
+ projPath = proj.getFullPath().makeRelative().toString();
}
} else if (selectedElement instanceof ICElement) {
- ICProject jproject= ((ICElement) selectedElement).getCProject();
+ ICProject jproject = ((ICElement) selectedElement).getCProject();
if (jproject != null) {
- projPath= jproject.getProject().getFullPath().makeRelative().toString();
+ projPath = jproject.getProject().getFullPath().makeRelative().toString();
}
}
@@ -162,14 +162,14 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
}
private void setDefaultAttributes() {
- String projPath= ""; //$NON-NLS-1$
+ String projPath = ""; //$NON-NLS-1$
try {
// find the first C project
- IProject[] projects= fWorkspaceRoot.getProjects();
+ IProject[] projects = fWorkspaceRoot.getProjects();
for (IProject proj : projects) {
if (proj.hasNature(CProjectNature.C_NATURE_ID) || proj.hasNature(CCProjectNature.CC_NATURE_ID)) {
- projPath= proj.getFullPath().makeRelative().toString();
+ projPath = proj.getFullPath().makeRelative().toString();
break;
}
}
@@ -177,7 +177,7 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
// ignore here
}
fProjectField.setText(projPath);
- fRootDialogField.setText(""); //$NON-NLS-1$
+ fRootDialogField.setText(""); //$NON-NLS-1$
}
// -------- UI Creation ---------
@@ -186,19 +186,19 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
public void createControl(Composite parent) {
initializeDialogUnits(parent);
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- layout.numColumns= 3;
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 3;
composite.setLayout(layout);
fProjectField.doFillIntoGrid(composite, 3);
fRootDialogField.doFillIntoGrid(composite, 3);
fExcludeInOthersFields.doFillIntoGrid(composite, 3);
- int maxFieldWidth= convertWidthInCharsToPixels(40);
+ int maxFieldWidth = convertWidthInCharsToPixels(40);
LayoutUtil.setWidthHint(fProjectField.getTextControl(null), maxFieldWidth);
LayoutUtil.setHorizontalGrabbing(fProjectField.getTextControl(null), true);
LayoutUtil.setWidthHint(fRootDialogField.getTextControl(null), maxFieldWidth);
@@ -235,18 +235,18 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
protected void packRootChangeControlPressed(DialogField field) {
if (field == fRootDialogField) {
- IPath initialPath= new Path(fRootDialogField.getText());
- String title= NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseExistingRootDialog_title;
- String message= NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseExistingRootDialog_description;
- IFolder folder= chooseFolder(title, message, initialPath);
+ IPath initialPath = new Path(fRootDialogField.getText());
+ String title = NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseExistingRootDialog_title;
+ String message = NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseExistingRootDialog_description;
+ IFolder folder = chooseFolder(title, message, initialPath);
if (folder != null) {
- IPath path= folder.getFullPath().removeFirstSegments(1);
+ IPath path = folder.getFullPath().removeFirstSegments(1);
fRootDialogField.setText(path.toString());
}
} else if (field == fProjectField) {
- ICProject jproject= chooseProject();
+ ICProject jproject = chooseProject();
if (jproject != null) {
- IPath path= jproject.getProject().getFullPath().makeRelative();
+ IPath path = jproject.getProject().getFullPath().makeRelative();
fProjectField.setText(path.toString());
}
}
@@ -265,100 +265,103 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
}
private void updateProjectStatus() {
- fCurrCProject= null;
- fIsProjectAsSourceFolder= false;
+ fCurrCProject = null;
+ fIsProjectAsSourceFolder = false;
- String str= fProjectField.getText();
+ String str = fProjectField.getText();
if (str.isEmpty()) {
fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_EnterProjectName);
return;
}
- IPath path= new Path(str);
+ IPath path = new Path(str);
if (path.segmentCount() != 1) {
fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_InvalidProjectPath);
return;
}
- IProject project= fWorkspaceRoot.getProject(path.toString());
+ IProject project = fWorkspaceRoot.getProject(path.toString());
if (!project.exists()) {
fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_ProjectNotExists);
return;
}
try {
if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- fCurrCProject= CoreModel.getDefault().create(project);
- fEntries= fCurrCProject.getRawPathEntries();
+ fCurrCProject = CoreModel.getDefault().create(project);
+ fEntries = fCurrCProject.getRawPathEntries();
fProjectStatus.setOK();
return;
}
} catch (CoreException e) {
CUIPlugin.log(e);
- fCurrCProject= null;
+ fCurrCProject = null;
}
fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_NotACProject);
}
private void updateRootStatus() {
fRootDialogField.enableButton(fCurrCProject != null);
- fIsProjectAsSourceFolder= false;
+ fIsProjectAsSourceFolder = false;
if (fCurrCProject == null) {
return;
}
fRootStatus.setOK();
- IPath projPath= fCurrCProject.getProject().getFullPath();
- String str= fRootDialogField.getText();
+ IPath projPath = fCurrCProject.getProject().getFullPath();
+ String str = fRootDialogField.getText();
if (str.length() == 0) {
- fRootStatus.setError(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_error_EnterRootName, fCurrCProject.getProject().getFullPath().toString()));
+ fRootStatus.setError(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_error_EnterRootName,
+ fCurrCProject.getProject().getFullPath().toString()));
} else {
- IPath path= projPath.append(str);
- IStatus validate= fWorkspaceRoot.getWorkspace().validatePath(path.toString(), IResource.FOLDER);
+ IPath path = projPath.append(str);
+ IStatus validate = fWorkspaceRoot.getWorkspace().validatePath(path.toString(), IResource.FOLDER);
if (validate.matches(IStatus.ERROR)) {
- fRootStatus.setError(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_error_InvalidRootName, validate.getMessage()));
+ fRootStatus.setError(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_error_InvalidRootName,
+ validate.getMessage()));
} else {
- IResource res= fWorkspaceRoot.findMember(path);
+ IResource res = fWorkspaceRoot.findMember(path);
if (res != null) {
if (res.getType() != IResource.FOLDER) {
fRootStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_NotAFolder);
return;
}
}
- ArrayList<IPathEntry> newEntries= new ArrayList<>(fEntries.length + 1);
- int projectEntryIndex= -1;
+ ArrayList<IPathEntry> newEntries = new ArrayList<>(fEntries.length + 1);
+ int projectEntryIndex = -1;
- for (int i= 0; i < fEntries.length; i++) {
- IPathEntry curr= fEntries[i];
+ for (int i = 0; i < fEntries.length; i++) {
+ IPathEntry curr = fEntries[i];
if (curr.getEntryKind() == IPathEntry.CDT_SOURCE) {
if (path.equals(curr.getPath())) {
- fRootStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_AlreadyExisting);
+ fRootStatus
+ .setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_AlreadyExisting);
return;
}
if (projPath.equals(curr.getPath())) {
- projectEntryIndex= i;
+ projectEntryIndex = i;
}
}
newEntries.add(curr);
}
- IPathEntry newEntry= CoreModel.newSourceEntry(path);
+ IPathEntry newEntry = CoreModel.newSourceEntry(path);
- Set<IPathEntry> modified= new HashSet<>();
+ Set<IPathEntry> modified = new HashSet<>();
if (fExcludeInOthersFields.isSelected()) {
InternalCoreModelUtil.addExclusionPatterns(newEntry, newEntries, modified);
newEntries.add(CoreModel.newSourceEntry(path));
} else {
if (projectEntryIndex >= 0) {
- fIsProjectAsSourceFolder= true;
+ fIsProjectAsSourceFolder = true;
newEntries.set(projectEntryIndex, newEntry);
} else {
newEntries.add(CoreModel.newSourceEntry(path));
}
}
- fNewEntries= newEntries.toArray(new IPathEntry[newEntries.size()]);
+ fNewEntries = newEntries.toArray(new IPathEntry[newEntries.size()]);
- ICModelStatus status= PathEntryManager.getDefault().validatePathEntry(fCurrCProject, fNewEntries);
+ ICModelStatus status = PathEntryManager.getDefault().validatePathEntry(fCurrCProject, fNewEntries);
if (!status.isOK()) {
- IStatus status2= PathEntryManager.getDefault().validatePathEntry(fCurrCProject, fNewEntries);
+ IStatus status2 = PathEntryManager.getDefault().validatePathEntry(fCurrCProject, fNewEntries);
if (status2.isOK()) {
return;
}
@@ -369,7 +372,9 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
return;
}
if (!modified.isEmpty()) {
- fRootStatus.setInfo(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_warning_AddedExclusions, String.valueOf(modified.size())));
+ fRootStatus
+ .setInfo(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_warning_AddedExclusions,
+ String.valueOf(modified.size())));
return;
}
}
@@ -387,45 +392,45 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
}
public void createSourceRoot(IProgressMonitor monitor) throws CoreException {
- SubMonitor progress = SubMonitor.convert(monitor,
- NewFolderWizardMessages.NewSourceFolderWizardPage_operation, 3);
- String relPath= fRootDialogField.getText();
+ SubMonitor progress = SubMonitor.convert(monitor, NewFolderWizardMessages.NewSourceFolderWizardPage_operation,
+ 3);
+ String relPath = fRootDialogField.getText();
IProject project = fCurrCProject.getProject();
- IFolder folder= project.getFolder(relPath);
+ IFolder folder = project.getFolder(relPath);
if (!folder.exists()) {
CoreUtility.createFolder(folder, true, true, progress.split(1));
}
if (CCorePlugin.getDefault().isNewStyleProject(project)) {
- InternalCoreModelUtil.addSourceEntry(project, folder, fIsProjectAsSourceFolder, progress.split(2));
+ InternalCoreModelUtil.addSourceEntry(project, folder, fIsProjectAsSourceFolder, progress.split(2));
} else {
fCurrCProject.setRawPathEntries(fNewEntries, progress.split(2));
}
- fCreatedRoot= fCurrCProject.findSourceRoot(folder);
+ fCreatedRoot = fCurrCProject.findSourceRoot(folder);
}
// ------------- choose dialogs
private IFolder chooseFolder(String title, String message, IPath initialPath) {
- Class<?>[] acceptedClasses= new Class<?>[] { IFolder.class };
- ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
- ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);
+ Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class };
+ ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses, null);
- ILabelProvider lp= new WorkbenchLabelProvider();
- ITreeContentProvider cp= new WorkbenchContentProvider();
+ ILabelProvider lp = new WorkbenchLabelProvider();
+ ITreeContentProvider cp = new WorkbenchContentProvider();
- IProject currProject= fCurrCProject.getProject();
+ IProject currProject = fCurrCProject.getProject();
- ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setValidator(validator);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.addFilter(filter);
dialog.setInput(currProject);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
- IResource res= currProject.findMember(initialPath);
+ IResource res = currProject.findMember(initialPath);
if (res != null) {
dialog.setInitialSelection(res);
}
@@ -439,14 +444,14 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
private ICProject chooseProject() {
ICProject[] projects;
try {
- projects= CoreModel.create(fWorkspaceRoot).getCProjects();
+ projects = CoreModel.create(fWorkspaceRoot).getCProjects();
} catch (CModelException e) {
CUIPlugin.log(e);
- projects= new ICProject[0];
+ projects = new ICProject[0];
}
- ILabelProvider labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT);
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+ ILabelProvider labelProvider = new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT);
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
dialog.setTitle(NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_title);
dialog.setMessage(NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_description);
dialog.setElements(projects);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableLabelProvider.java
index b425b897303..5bdc0d02c2a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableLabelProvider.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.indexwizards;
@@ -22,14 +22,14 @@ import org.eclipse.jface.viewers.LabelProvider;
* @since 4.0
*/
public class StringVariableLabelProvider extends LabelProvider {
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(Object element) {
if (element instanceof IStringVariable) {
- IStringVariable variable = (IStringVariable)element;
+ IStringVariable variable = (IStringVariable) element;
return variable.getName();
}
return super.getText(element);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableSelectionDialog.java
index 1f39a714030..e1678dfaf35 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableSelectionDialog.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* IBM Corporation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.indexwizards;
@@ -38,7 +38,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
* @since 4.0
*/
public class StringVariableSelectionDialog extends ElementListSelectionDialog {
-
+
// variable description
private Text fDescriptionText;
// the argument value
@@ -47,29 +47,29 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog {
/**
* Constructs a new string substitution variable selection dialog.
- *
+ *
* @param parent parent shell
*/
public StringVariableSelectionDialog(Shell parent) {
super(parent, new StringVariableLabelProvider());
setShellStyle(getShellStyle() | SWT.RESIZE);
- setTitle(Messages.StringVariableSelectionDialog_title);
- setMessage(Messages.StringVariableSelectionDialog_message);
+ setTitle(Messages.StringVariableSelectionDialog_title);
+ setMessage(Messages.StringVariableSelectionDialog_message);
setMultipleSelection(false);
setElements(VariablesPlugin.getDefault().getStringVariableManager().getVariables());
}
-
+
/**
* Returns the variable expression the user generated from this
* dialog, or <code>null</code> if none.
- *
+ *
* @return variable expression the user generated from this
* dialog, or <code>null</code> if none
*/
public String getVariableExpression() {
Object[] selected = getResult();
if (selected != null && selected.length == 1) {
- IStringVariable variable = (IStringVariable)selected[0];
+ IStringVariable variable = (IStringVariable) selected[0];
StringBuilder buffer = new StringBuilder();
buffer.append("${"); //$NON-NLS-1$
buffer.append(variable.getName());
@@ -89,14 +89,14 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog {
@Override
protected Control createDialogArea(Composite parent) {
Control control = super.createDialogArea(parent);
- createArgumentArea((Composite)control);
+ createArgumentArea((Composite) control);
return control;
}
/**
* Creates an area to display a description of the selected variable
* and a button to configure the variable's argument.
- *
+ *
* @param parent parent widget
*/
private void createArgumentArea(Composite parent) {
@@ -110,14 +110,14 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
container.setLayoutData(gd);
container.setFont(parent.getFont());
-
+
Label desc = new Label(container, SWT.NONE);
desc.setFont(parent.getFont());
- desc.setText(Messages.StringVariableSelectionDialog_columnArgument);
+ desc.setText(Messages.StringVariableSelectionDialog_columnArgument);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
- desc.setLayoutData(gd);
-
+ desc.setLayoutData(gd);
+
Composite args = new Composite(container, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
@@ -127,25 +127,25 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog {
gd.horizontalSpan = 2;
args.setLayoutData(gd);
args.setFont(container.getFont());
-
+
fArgumentText = new Text(args, SWT.BORDER);
fArgumentText.setFont(container.getFont());
gd = new GridData(GridData.FILL_HORIZONTAL);
- fArgumentText.setLayoutData(gd);
- fArgumentText.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- @Override
+ fArgumentText.setLayoutData(gd);
+ fArgumentText.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
public void getName(AccessibleEvent e) {
- e.result = Messages.StringVariableSelectionDialog_columnArgument;
- }
+ e.result = Messages.StringVariableSelectionDialog_columnArgument;
+ }
});
-
+
desc = new Label(container, SWT.NONE);
desc.setFont(parent.getFont());
- desc.setText(Messages.StringVariableSelectionDialog_columnDescription);
+ desc.setText(Messages.StringVariableSelectionDialog_columnDescription);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
desc.setLayoutData(gd);
-
+
fDescriptionText = new Text(container, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
fDescriptionText.setFont(container.getFont());
fDescriptionText.setEditable(false);
@@ -157,7 +157,7 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog {
/**
* Update variable description and argument button enablement.
- *
+ *
* @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#handleSelectionChanged()
*/
@Override
@@ -167,11 +167,11 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog {
boolean argEnabled = false;
String text = null;
if (objects.length == 1) {
- IStringVariable variable = (IStringVariable)objects[0];
- if (variable instanceof IDynamicVariable) {
- argEnabled = ((IDynamicVariable)variable).supportsArgument();
- }
- text = variable.getDescription();
+ IStringVariable variable = (IStringVariable) objects[0];
+ if (variable instanceof IDynamicVariable) {
+ argEnabled = ((IDynamicVariable) variable).supportsArgument();
+ }
+ text = variable.getDescription();
}
if (text == null) {
text = ""; //$NON-NLS-1$
@@ -191,23 +191,23 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog {
/**
* Returns the name of the section that this dialog stores its settings in
- *
+ *
* @return String
*/
private String getDialogSettingsSectionName() {
return CUIPlugin.PLUGIN_ID + ".STRING_VARIABLE_SELECTION_DIALOG_SECTION"; //$NON-NLS-1$
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
- */
- @Override
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
+ */
+ @Override
protected IDialogSettings getDialogBoundsSettings() {
- IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
- IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
- if (section == null) {
- section = settings.addNewSection(getDialogSettingsSectionName());
- }
- return section;
- }
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
+ if (section == null) {
+ section = settings.addNewSection(getDialogSettingsSectionName());
+ }
+ return section;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java
index 3a881b284cd..817c899e0fc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.indexwizards;
@@ -30,32 +30,32 @@ public class TeamProjectIndexExportWizard extends Wizard implements IExportWizar
private IStructuredSelection fSelection;
public TeamProjectIndexExportWizard() {
- IDialogSettings workbenchSettings = CUIPlugin.getDefault().getDialogSettings();
- IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS_SECTION);
- if (section == null) {
+ IDialogSettings workbenchSettings = CUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS_SECTION);
+ if (section == null) {
section = workbenchSettings.addNewSection(DIALOG_SETTINGS_SECTION);
}
- setDialogSettings(section);
+ setDialogSettings(section);
}
- @Override
+ @Override
public void addPages() {
- super.addPages();
- fMainPage = new TeamProjectIndexExportWizardPage(fSelection);
- addPage(fMainPage);
- }
+ super.addPages();
+ fMainPage = new TeamProjectIndexExportWizardPage(fSelection);
+ addPage(fMainPage);
+ }
@Override
public boolean performFinish() {
- return fMainPage.finish();
- }
+ return fMainPage.finish();
+ }
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- fSelection= selection;
- setWindowTitle(Messages.TeamProjectIndexExportWizard_title);
- setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_EXPORTINDEX);
- setNeedsProgressMonitor(true);
+ fSelection = selection;
+ setWindowTitle(Messages.TeamProjectIndexExportWizard_title);
+ setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_EXPORTINDEX);
+ setNeedsProgressMonitor(true);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java
index c6fb457ab4e..2d066dc22eb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.indexwizards;
import java.lang.reflect.InvocationTargetException;
@@ -60,257 +60,253 @@ import org.eclipse.cdt.internal.core.pdom.TeamPDOMExportOperation;
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
-
+
public class TeamProjectIndexExportWizardPage extends WizardPage implements Listener {
- private static final int SIZING_TEXT_FIELD_WIDTH = 250;
+ private static final int SIZING_TEXT_FIELD_WIDTH = 250;
- private IStructuredSelection fInitialSelection;
+ private IStructuredSelection fInitialSelection;
private CheckboxTableViewer fProjectViewer;
- private Text fDestinationField;
- private Button fResourceSnapshotButton;
-
- /**
- * Create an instance of this class
- */
- protected TeamProjectIndexExportWizardPage(String name, IStructuredSelection selection) {
- super(name);
- fInitialSelection= selection;
- }
-
- /**
- * Create an instance of this class.
- *
- * @param selection the selection
- */
- public TeamProjectIndexExportWizardPage(IStructuredSelection selection) {
- this("indexExportPage", selection); //$NON-NLS-1$
- setTitle(Messages.TeamProjectIndexExportWizardPage_title);
- setDescription(Messages.TeamProjectIndexExportWizardPage_description);
- }
-
- @Override
+ private Text fDestinationField;
+ private Button fResourceSnapshotButton;
+
+ /**
+ * Create an instance of this class
+ */
+ protected TeamProjectIndexExportWizardPage(String name, IStructuredSelection selection) {
+ super(name);
+ fInitialSelection = selection;
+ }
+
+ /**
+ * Create an instance of this class.
+ *
+ * @param selection the selection
+ */
+ public TeamProjectIndexExportWizardPage(IStructuredSelection selection) {
+ this("indexExportPage", selection); //$NON-NLS-1$
+ setTitle(Messages.TeamProjectIndexExportWizardPage_title);
+ setDescription(Messages.TeamProjectIndexExportWizardPage_description);
+ }
+
+ @Override
public void createControl(Composite parent) {
- initializeDialogUnits(parent);
+ initializeDialogUnits(parent);
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
- | GridData.HORIZONTAL_ALIGN_FILL));
- composite.setFont(parent.getFont());
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+ composite.setFont(parent.getFont());
- createResourcesGroup(composite);
- createDestinationGroup(composite);
+ createResourcesGroup(composite);
+ createDestinationGroup(composite);
- restoreWidgetValues();
- if (fInitialSelection != null) {
+ restoreWidgetValues();
+ if (fInitialSelection != null) {
setupBasedOnInitialSelections();
}
- setupDestination();
+ setupDestination();
- updateWidgetEnablements();
- setPageComplete(determinePageCompletion());
- setErrorMessage(null); // should not initially have error message
-
- setControl(composite);
- giveFocusToDestination();
- }
+ updateWidgetEnablements();
+ setPageComplete(determinePageCompletion());
+ setErrorMessage(null); // should not initially have error message
+
+ setControl(composite);
+ giveFocusToDestination();
+ }
/**
- * Creates the checkbox tree and list for selecting resources.
- *
- * @param parent the parent control
- */
- private final void createResourcesGroup(Composite parent) {
- Composite resourcesGroup = new Composite(parent, SWT.NONE);
- resourcesGroup.setLayout(new GridLayout());
- resourcesGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
- resourcesGroup.setFont(parent.getFont());
-
- new Label(resourcesGroup, SWT.NONE).setText(Messages.TeamProjectIndexExportWizardPage_labelProjectTable);
- Table table= new Table(resourcesGroup, SWT.CHECK | SWT.BORDER);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
- fProjectViewer= new CheckboxTableViewer(table);
+ * Creates the checkbox tree and list for selecting resources.
+ *
+ * @param parent the parent control
+ */
+ private final void createResourcesGroup(Composite parent) {
+ Composite resourcesGroup = new Composite(parent, SWT.NONE);
+ resourcesGroup.setLayout(new GridLayout());
+ resourcesGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+ resourcesGroup.setFont(parent.getFont());
+
+ new Label(resourcesGroup, SWT.NONE).setText(Messages.TeamProjectIndexExportWizardPage_labelProjectTable);
+ Table table = new Table(resourcesGroup, SWT.CHECK | SWT.BORDER);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fProjectViewer = new CheckboxTableViewer(table);
fProjectViewer.setContentProvider(new ListContentProvider());
- fProjectViewer.setLabelProvider(new CElementLabelProvider());
- ICheckStateListener checkListener = new ICheckStateListener() {
- @Override
+ fProjectViewer.setLabelProvider(new CElementLabelProvider());
+ ICheckStateListener checkListener = new ICheckStateListener() {
+ @Override
public void checkStateChanged(CheckStateChangedEvent event) {
- updateWidgetEnablements();
- }
- };
- fProjectViewer.addCheckStateListener(checkListener);
-
-
- // top level group
- Composite buttonComposite = new Composite(resourcesGroup, SWT.NONE);
- buttonComposite.setFont(parent.getFont());
+ updateWidgetEnablements();
+ }
+ };
+ fProjectViewer.addCheckStateListener(checkListener);
- GridLayout layout = new GridLayout(2, true);
- layout.marginHeight= layout.marginWidth= 0;
- buttonComposite.setLayout(layout);
- buttonComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
- | GridData.HORIZONTAL_ALIGN_FILL));
+ // top level group
+ Composite buttonComposite = new Composite(resourcesGroup, SWT.NONE);
+ buttonComposite.setFont(parent.getFont());
+ GridLayout layout = new GridLayout(2, true);
+ layout.marginHeight = layout.marginWidth = 0;
+ buttonComposite.setLayout(layout);
+ buttonComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
- Button selectButton = createButton(buttonComposite,
- IDialogConstants.SELECT_ALL_ID, Messages.TeamProjectIndexExportWizardPage_selectAll, false);
+ Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID,
+ Messages.TeamProjectIndexExportWizardPage_selectAll, false);
- SelectionAdapter listener = new SelectionAdapter() {
- @Override
+ SelectionAdapter listener = new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- fProjectViewer.setAllChecked(true);
- updateWidgetEnablements();
- }
- };
- selectButton.addSelectionListener(listener);
+ fProjectViewer.setAllChecked(true);
+ updateWidgetEnablements();
+ }
+ };
+ selectButton.addSelectionListener(listener);
- Button deselectButton = createButton(buttonComposite,
- IDialogConstants.DESELECT_ALL_ID, Messages.TeamProjectIndexExportWizardPage_deselectAll, false);
+ Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID,
+ Messages.TeamProjectIndexExportWizardPage_deselectAll, false);
- listener = new SelectionAdapter() {
- @Override
+ listener = new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- fProjectViewer.setAllChecked(false);
- updateWidgetEnablements();
- }
- };
- deselectButton.addSelectionListener(listener);
-
- initProjects();
- }
-
- private Button createButton(Composite parent, int id, String label,
- boolean defaultButton) {
- Button button = new Button(parent, SWT.PUSH);
-
- GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
- button.setLayoutData(buttonData);
-
- button.setData(Integer.valueOf(id));
- button.setText(label);
- button.setFont(parent.getFont());
-
- if (defaultButton) {
- Shell shell = parent.getShell();
- if (shell != null) {
- shell.setDefaultButton(button);
- }
- button.setFocus();
- }
- button.setFont(parent.getFont());
- setButtonLayoutData(button);
- return button;
- }
-
- private void initProjects() {
- ArrayList<ICProject> input = new ArrayList<ICProject>();
- ICProject[] projects;
+ fProjectViewer.setAllChecked(false);
+ updateWidgetEnablements();
+ }
+ };
+ deselectButton.addSelectionListener(listener);
+
+ initProjects();
+ }
+
+ private Button createButton(Composite parent, int id, String label, boolean defaultButton) {
+ Button button = new Button(parent, SWT.PUSH);
+
+ GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
+ button.setLayoutData(buttonData);
+
+ button.setData(Integer.valueOf(id));
+ button.setText(label);
+ button.setFont(parent.getFont());
+
+ if (defaultButton) {
+ Shell shell = parent.getShell();
+ if (shell != null) {
+ shell.setDefaultButton(button);
+ }
+ button.setFocus();
+ }
+ button.setFont(parent.getFont());
+ setButtonLayoutData(button);
+ return button;
+ }
+
+ private void initProjects() {
+ ArrayList<ICProject> input = new ArrayList<ICProject>();
+ ICProject[] projects;
try {
projects = CoreModel.getDefault().getCModel().getCProjects();
- for (ICProject project : projects) {
- if (project.getProject().isOpen()) {
+ for (ICProject project : projects) {
+ if (project.getProject().isOpen()) {
input.add(project);
}
- }
+ }
} catch (CModelException e) {
CUIPlugin.log(e);
}
fProjectViewer.setInput(input);
}
- private void setupBasedOnInitialSelections() {
- HashSet<String> names= new HashSet<String>();
- Iterator<?> it = fInitialSelection.iterator();
- while (it.hasNext()) {
- IProject project = (IProject) it.next();
- names.add(project.getName());
- }
-
- Collection<?> prjs= (Collection<?>) fProjectViewer.getInput();
- for (Object element : prjs) {
+ private void setupBasedOnInitialSelections() {
+ HashSet<String> names = new HashSet<String>();
+ Iterator<?> it = fInitialSelection.iterator();
+ while (it.hasNext()) {
+ IProject project = (IProject) it.next();
+ names.add(project.getName());
+ }
+
+ Collection<?> prjs = (Collection<?>) fProjectViewer.getInput();
+ for (Object element : prjs) {
ICProject prj = (ICProject) element;
if (names.contains(prj.getElementName())) {
- fProjectViewer.setChecked(prj, true);
+ fProjectViewer.setChecked(prj, true);
}
}
- }
-
- private void setupDestination() {
- String dest;
- ICProject[] prjs= getCheckedElements();
- if (prjs.length > 0) {
- dest= IndexerPreferences.getIndexImportLocation(prjs[0].getProject());
- }
- else {
- dest= IndexerPreferences.getIndexImportLocation(null);
- }
- fDestinationField.setText(dest);
- }
-
-
- private void createDestinationGroup(Composite parent) {
- GridData gd;
- Font font = parent.getFont();
- // destination specification group
- Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
- destinationSelectionGroup.setLayout(new GridLayout(2, false));
- destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
- destinationSelectionGroup.setFont(font);
-
- Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
- destinationLabel.setText(Messages.TeamProjectIndexExportWizardPage_destinationLabel);
- destinationLabel.setFont(font);
- destinationLabel.setLayoutData(gd= new GridData());
- gd.horizontalSpan= 2;
-
- // destination name entry field
- fDestinationField = new Text(destinationSelectionGroup, SWT.BORDER);
- fDestinationField.addListener(SWT.Modify, this);
- fDestinationField.addListener(SWT.Selection, this);
- fDestinationField.setFont(font);
- fDestinationField.setLayoutData(gd= new GridData());
- gd.grabExcessHorizontalSpace= true;
- gd.horizontalAlignment= GridData.FILL;
- gd.widthHint = SIZING_TEXT_FIELD_WIDTH;
-
- Button button= createButton(destinationSelectionGroup, IDialogConstants.CLIENT_ID, Messages.TeamProjectIndexExportWizardPage_variableButton, false);
- SelectionAdapter listener = new SelectionAdapter() {
- @Override
+ }
+
+ private void setupDestination() {
+ String dest;
+ ICProject[] prjs = getCheckedElements();
+ if (prjs.length > 0) {
+ dest = IndexerPreferences.getIndexImportLocation(prjs[0].getProject());
+ } else {
+ dest = IndexerPreferences.getIndexImportLocation(null);
+ }
+ fDestinationField.setText(dest);
+ }
+
+ private void createDestinationGroup(Composite parent) {
+ GridData gd;
+ Font font = parent.getFont();
+ // destination specification group
+ Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
+ destinationSelectionGroup.setLayout(new GridLayout(2, false));
+ destinationSelectionGroup
+ .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ destinationSelectionGroup.setFont(font);
+
+ Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
+ destinationLabel.setText(Messages.TeamProjectIndexExportWizardPage_destinationLabel);
+ destinationLabel.setFont(font);
+ destinationLabel.setLayoutData(gd = new GridData());
+ gd.horizontalSpan = 2;
+
+ // destination name entry field
+ fDestinationField = new Text(destinationSelectionGroup, SWT.BORDER);
+ fDestinationField.addListener(SWT.Modify, this);
+ fDestinationField.addListener(SWT.Selection, this);
+ fDestinationField.setFont(font);
+ fDestinationField.setLayoutData(gd = new GridData());
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.widthHint = SIZING_TEXT_FIELD_WIDTH;
+
+ Button button = createButton(destinationSelectionGroup, IDialogConstants.CLIENT_ID,
+ Messages.TeamProjectIndexExportWizardPage_variableButton, false);
+ SelectionAdapter listener = new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- onInsertVariable();
- }
- };
- button.addSelectionListener(listener);
-
- // resource snapshot destination group
- Composite resourceSnapshotDestinationGroup = new Composite(parent, SWT.NONE);
- resourceSnapshotDestinationGroup.setLayout(new GridLayout(1, false));
- resourceSnapshotDestinationGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
- resourceSnapshotDestinationGroup.setFont(font);
-
- fResourceSnapshotButton = new Button(resourceSnapshotDestinationGroup, SWT.CHECK);
- fResourceSnapshotButton.setText(Messages.TeamProjectIndexExportWizardPage_resourceSnapshotButton);
- fResourceSnapshotButton.setFont(font);
- fResourceSnapshotButton.setLayoutData(gd= new GridData());
- gd.grabExcessHorizontalSpace= true;
- gd.horizontalAlignment= GridData.FILL;
- }
+ onInsertVariable();
+ }
+ };
+ button.addSelectionListener(listener);
+
+ // resource snapshot destination group
+ Composite resourceSnapshotDestinationGroup = new Composite(parent, SWT.NONE);
+ resourceSnapshotDestinationGroup.setLayout(new GridLayout(1, false));
+ resourceSnapshotDestinationGroup
+ .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ resourceSnapshotDestinationGroup.setFont(font);
+
+ fResourceSnapshotButton = new Button(resourceSnapshotDestinationGroup, SWT.CHECK);
+ fResourceSnapshotButton.setText(Messages.TeamProjectIndexExportWizardPage_resourceSnapshotButton);
+ fResourceSnapshotButton.setFont(font);
+ fResourceSnapshotButton.setLayoutData(gd = new GridData());
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+ }
protected void onInsertVariable() {
- StringVariableSelectionDialog dlg= new StringVariableSelectionDialog(getShell());
+ StringVariableSelectionDialog dlg = new StringVariableSelectionDialog(getShell());
if (dlg.open() == Window.OK) {
- String var= dlg.getVariableExpression();
+ String var = dlg.getVariableExpression();
fDestinationField.insert(var);
}
}
public boolean finish() {
- ICProject[] projectsToExport= getCheckedElements();
+ ICProject[] projectsToExport = getCheckedElements();
- // about to invoke the operation so save our state
- saveWidgetValues();
- return executeExportOperation(projectsToExport);
- }
+ // about to invoke the operation so save our state
+ saveWidgetValues();
+ return executeExportOperation(projectsToExport);
+ }
private void saveWidgetValues() {
}
@@ -318,26 +314,25 @@ public class TeamProjectIndexExportWizardPage extends WizardPage implements List
private void restoreWidgetValues() {
}
-
private ICProject[] getCheckedElements() {
- Object[] obj= fProjectViewer.getCheckedElements();
- ICProject[] prjs= new ICProject[obj.length];
+ Object[] obj = fProjectViewer.getCheckedElements();
+ ICProject[] prjs = new ICProject[obj.length];
System.arraycopy(obj, 0, prjs, 0, obj.length);
return prjs;
}
- private boolean executeExportOperation(final ICProject[] projects) {
- final String dest= getDestinationValue();
- final MultiStatus status= new MultiStatus(CUIPlugin.PLUGIN_ID,
- 0, Messages.TeamProjectIndexExportWizardPage_errorExporting, null);
- final boolean exportResourceSnapshot = fResourceSnapshotButton.getSelection();
+ private boolean executeExportOperation(final ICProject[] projects) {
+ final String dest = getDestinationValue();
+ final MultiStatus status = new MultiStatus(CUIPlugin.PLUGIN_ID, 0,
+ Messages.TeamProjectIndexExportWizardPage_errorExporting, null);
+ final boolean exportResourceSnapshot = fResourceSnapshotButton.getSelection();
- IRunnableWithProgress op= new IRunnableWithProgress() {
+ IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("", projects.length); //$NON-NLS-1$
for (ICProject project : projects) {
- TeamPDOMExportOperation op= new TeamPDOMExportOperation(project);
+ TeamPDOMExportOperation op = new TeamPDOMExportOperation(project);
op.setTargetLocation(dest);
if (exportResourceSnapshot) {
op.setOptions(TeamPDOMExportOperation.EXPORT_OPTION_RESOURCE_SNAPSHOT);
@@ -349,139 +344,134 @@ public class TeamProjectIndexExportWizardPage extends WizardPage implements List
}
}
}
- };
- try {
- getContainer().run(true, true, op);
- } catch (InterruptedException e) {
- return false;
- } catch (InvocationTargetException e) {
- CUIPlugin.log(Messages.TeamProjectIndexExportWizardPage_errorExporting,
- e.getTargetException());
- displayErrorDialog(e.getTargetException());
- return false;
- }
-
- if (!status.isOK()) {
- CUIPlugin.log(status);
- ErrorDialog.openError(getContainer().getShell(),
- getErrorDialogTitle(),
- null, // no special message
- status);
- return false;
- }
-
- return true;
- }
-
- private String getDestinationValue() {
- return fDestinationField.getText().trim();
- }
-
- private void giveFocusToDestination() {
- fDestinationField.setFocus();
- }
-
- /**
- * Answer a boolean indicating whether the receivers destination specification
- * widgets currently all contain valid values.
- */
+ };
+ try {
+ getContainer().run(true, true, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ CUIPlugin.log(Messages.TeamProjectIndexExportWizardPage_errorExporting, e.getTargetException());
+ displayErrorDialog(e.getTargetException());
+ return false;
+ }
+
+ if (!status.isOK()) {
+ CUIPlugin.log(status);
+ ErrorDialog.openError(getContainer().getShell(), getErrorDialogTitle(), null, // no special message
+ status);
+ return false;
+ }
+
+ return true;
+ }
+
+ private String getDestinationValue() {
+ return fDestinationField.getText().trim();
+ }
+
+ private void giveFocusToDestination() {
+ fDestinationField.setFocus();
+ }
+
+ /**
+ * Answer a boolean indicating whether the receivers destination specification
+ * widgets currently all contain valid values.
+ */
protected boolean validateDestinationGroup() {
- String destinationValue = getDestinationValue();
- if (destinationValue.length() == 0) {
- setMessage(Messages.TeamProjectIndexExportWizardPage_destinationMessage);
- return false;
- }
+ String destinationValue = getDestinationValue();
+ if (destinationValue.length() == 0) {
+ setMessage(Messages.TeamProjectIndexExportWizardPage_destinationMessage);
+ return false;
+ }
- setErrorMessage(null);
- return true;
- }
+ setErrorMessage(null);
+ return true;
+ }
protected boolean validateSourceGroup() {
- // there must be some resources selected for Export
- boolean isValid = true;
- Object[] projectsToExport = getCheckedElements();
- if (projectsToExport.length == 0){
- setErrorMessage(Messages.TeamProjectIndexExportWizardPage_noProjectError);
- isValid = false;
- } else {
+ // there must be some resources selected for Export
+ boolean isValid = true;
+ Object[] projectsToExport = getCheckedElements();
+ if (projectsToExport.length == 0) {
+ setErrorMessage(Messages.TeamProjectIndexExportWizardPage_noProjectError);
+ isValid = false;
+ } else {
setErrorMessage(null);
}
return isValid;
}
protected void updateWidgetEnablements() {
- boolean pageComplete = determinePageCompletion();
- setPageComplete(pageComplete);
- if (pageComplete) {
+ boolean pageComplete = determinePageCompletion();
+ setPageComplete(pageComplete);
+ if (pageComplete) {
setMessage(null);
}
- }
-
+ }
@Override
public void handleEvent(Event event) {
updateWidgetEnablements();
}
-
+
protected String getErrorDialogTitle() {
- return Messages.TeamProjectIndexExportWizardPage_errorDlgTitle;
- }
-
- /**
- * Returns whether this page is complete. This determination is made based upon
- * the current contents of this page's controls. Subclasses wishing to include
- * their controls in this determination should override the hook methods
- * <code>validateSourceGroup</code> and/or <code>validateOptionsGroup</code>.
- *
- * @return <code>true</code> if this page is complete, and <code>false</code> if
- * incomplete
- * @see #validateSourceGroup
- * @see #validateDestinationGroup
- */
- private boolean determinePageCompletion() {
- boolean complete = validateSourceGroup() && validateDestinationGroup();
-
- // Avoid draw flicker by not clearing the error
- // message unless all is valid.
- if (complete) {
+ return Messages.TeamProjectIndexExportWizardPage_errorDlgTitle;
+ }
+
+ /**
+ * Returns whether this page is complete. This determination is made based upon
+ * the current contents of this page's controls. Subclasses wishing to include
+ * their controls in this determination should override the hook methods
+ * <code>validateSourceGroup</code> and/or <code>validateOptionsGroup</code>.
+ *
+ * @return <code>true</code> if this page is complete, and <code>false</code> if
+ * incomplete
+ * @see #validateSourceGroup
+ * @see #validateDestinationGroup
+ */
+ private boolean determinePageCompletion() {
+ boolean complete = validateSourceGroup() && validateDestinationGroup();
+
+ // Avoid draw flicker by not clearing the error
+ // message unless all is valid.
+ if (complete) {
+ setErrorMessage(null);
+ }
+
+ return complete;
+ }
+
+ /**
+ * Determine if the page is complete and update the page appropriately.
+ */
+ protected void updatePageCompletion() {
+ boolean pageComplete = determinePageCompletion();
+ setPageComplete(pageComplete);
+ if (pageComplete) {
setErrorMessage(null);
}
+ }
- return complete;
- }
-
- /**
- * Determine if the page is complete and update the page appropriately.
- */
- protected void updatePageCompletion() {
- boolean pageComplete = determinePageCompletion();
- setPageComplete(pageComplete);
- if (pageComplete) {
- setErrorMessage(null);
- }
- }
-
- /**
- * Display an error dialog with the specified message.
- *
- * @param message the error message
- */
- private void displayErrorDialog(String message) {
- MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
- getErrorDialogTitle(), message, SWT.SHEET);
- }
-
- /**
- * Display an error dislog with the information from the
- * supplied exception.
- * @param exception Throwable
- */
- private void displayErrorDialog(Throwable exception) {
- String message = exception.getMessage();
- //Some system exceptions have no message
- if (message == null) {
+ /**
+ * Display an error dialog with the specified message.
+ *
+ * @param message the error message
+ */
+ private void displayErrorDialog(String message) {
+ MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), getErrorDialogTitle(), message, SWT.SHEET);
+ }
+
+ /**
+ * Display an error dislog with the information from the
+ * supplied exception.
+ * @param exception Throwable
+ */
+ private void displayErrorDialog(Throwable exception) {
+ String message = exception.getMessage();
+ //Some system exceptions have no message
+ if (message == null) {
message = NLS.bind(Messages.TeamProjectIndexExportWizardPage_errorInOperation, exception);
}
- displayErrorDialog(message);
- }
+ displayErrorDialog(message);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPage.java
index e7518df3177..2bacab85eaa 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -18,35 +18,34 @@ import java.util.List;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
/**
- * Defines the methods that the strategies can call on the
+ * Defines the methods that the strategies can call on the
* wizard page.
- *
- * This interface exists mainly so that it can be implemented by a
+ *
+ * This interface exists mainly so that it can be implemented by a
* mock object, which makes testing the strategies easy.
- *
+ *
* @author Mike Kucera
* @since 5.1
*/
public interface IProjectSettingsWizardPage {
static final String FILENAME_EXTENSION = "xml"; //$NON-NLS-1$
-
/**
* Sets the input list for the displayed list of settings processors.
*/
void setDisplayedSettingsProcessors(List<ISettingsProcessor> processors);
-
+
/**
* Returns a list of all the available settings processors.
*/
List<ISettingsProcessor> getSettingsProcessors();
-
+
/**
* Returns a list of the settings processors that were selected by the user.
*/
List<ISettingsProcessor> getSelectedSettingsProcessors();
-
+
/**
* Returns the contents of the file path text box.
*/
@@ -54,12 +53,12 @@ public interface IProjectSettingsWizardPage {
/**
* Returns the configuration that was selected by the user.
- *
- * The selected project can be determined by calling
+ *
+ * The selected project can be determined by calling
* ICCOnfigurationDescription.getProjectDescription().getProject();
*/
ICConfigurationDescription getSelectedConfiguration();
-
+
/**
* Causes an error dialog to be shown to the user.
*/
@@ -71,5 +70,4 @@ public interface IProjectSettingsWizardPage {
*/
void setMessage(String message, int flag);
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPageStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPageStrategy.java
index abc2049ee4d..f6bc83c2df8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPageStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPageStrategy.java
@@ -17,15 +17,16 @@ package org.eclipse.cdt.internal.ui.wizards.settingswizards;
* The wizard page is very similar for importing and exporting,
* the wizard page delegates to a strategy object which defines
* the behavior that is specific to import and export.
- *
+ *
* @author Mike Kucera
* @since 5.1
*/
public interface IProjectSettingsWizardPageStrategy {
-
- enum MessageType { TITLE, MESSAGE, SETTINGS, CHECKBOX, FILE }
-
-
+
+ enum MessageType {
+ TITLE, MESSAGE, SETTINGS, CHECKBOX, FILE
+ }
+
/**
* Some of the strings displayed on the wizard page are
* different, this method returns the correct string
@@ -33,25 +34,22 @@ public interface IProjectSettingsWizardPageStrategy {
*/
String getMessage(MessageType messageType);
-
/**
* Event sent to strategy object when the
* page has been created (at the end of createControl())
*/
void pageCreated(IProjectSettingsWizardPage page);
-
-
+
/**
* Event sent to strategy object when the user selects
* a file name.
*/
void fileSelected(IProjectSettingsWizardPage page);
-
-
+
/**
* Event sent to strategy object when the user clicks
* finish on the wizard page.
*/
boolean finish(IProjectSettingsWizardPage page);
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsProcessor.java
index 0686ce16175..91538cd5c84 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsProcessor.java
@@ -13,25 +13,23 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.settingswizards;
-
import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Element;
import org.xml.sax.ContentHandler;
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
-
/**
* The exported XML file is divided into 'section' elements, each
* ISettingsProcessor is responsible for reading and writing
* a particular section.
- *
+ *
* A section can contain anything, for example include paths or macros.
* No schema is defined for the XML file, that way additional settings
* processors can be easily added. In the future there may be an extension
* point for adding settings processors.
- *
- *
+ *
+ *
* @author Mike Kucera
* @since 5.1
*/
@@ -42,37 +40,33 @@ public interface ISettingsProcessor {
* on the wizard page.
*/
String getDisplayName();
-
-
+
/**
* Return the image that will appear in the selection list
* on the wizard page.
*/
Image getIcon();
-
-
+
/**
* The name of the section in the XML file.
- *
+ *
* This String should be unique, so prefix it with the package
* name or something.
*/
String getSectionName();
-
/**
* Outputs a section of the XML file using the given SAX ContentHandler.
- *
+ *
* @param projectRoot The folder description for the selected project and configuration
* @throws SettingsImportExportException if the section could not be written
*/
void writeSectionXML(ICFolderDescription projectRoot, ContentHandler content) throws SettingsImportExportException;
-
-
+
/**
- * Passed part of the DOM tree that represents the section
+ * Passed part of the DOM tree that represents the section
* that is processed by this importer.
- *
+ *
* @param projectRoot The folder description for the selected project and configuration
* @throws SettingsImportExportException if the section could not be read and imported
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java
index 20df5dee15b..535863f9526 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java
@@ -29,7 +29,6 @@ import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin;
-
/**
* A settings processor that imports and exports include paths.
*
@@ -43,10 +42,10 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor {
private static final String INCLUDE_PATH_ELEMENT = "includepath"; //$NON-NLS-1$
private static final String WORKSPACE_PATH_ATTR = "workspace_path"; //$NON-NLS-1$
-
@Override
public Image getIcon() {
- return CUIPlugin.getImageDescriptorRegistry().get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER));
+ return CUIPlugin.getImageDescriptorRegistry()
+ .get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER));
}
@Override
@@ -65,12 +64,13 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor {
}
@Override
- protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting) throws SettingsImportExportException {
+ protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting)
+ throws SettingsImportExportException {
char[] value = setting.getValue().toCharArray();
try {
AttributesImpl attrib = null;
- if( (setting.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) > 0 ) {
+ if ((setting.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) > 0) {
attrib = new AttributesImpl();
attrib.addAttribute(NONE, NONE, WORKSPACE_PATH_ATTR, NONE, Boolean.TRUE.toString());
}
@@ -84,23 +84,22 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor {
}
}
-
@Override
protected void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException {
List<ICLanguageSettingEntry> includes = new ArrayList<ICLanguageSettingEntry>();
List<Element> includeNodes = XMLUtils.extractChildElements(language, INCLUDE_PATH_ELEMENT);
- for(Element includeElement : includeNodes) {
+ for (Element includeElement : includeNodes) {
String include = includeElement.getTextContent();
int flags = 0;
- if(include != null && include.length() > 0) {
- if( includeElement.getAttribute(WORKSPACE_PATH_ATTR).equalsIgnoreCase(Boolean.TRUE.toString()) )
+ if (include != null && include.length() > 0) {
+ if (includeElement.getAttribute(WORKSPACE_PATH_ATTR).equalsIgnoreCase(Boolean.TRUE.toString()))
flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
includes.add(CDataUtil.createCIncludePathEntry(include, flags));
}
}
- if(includes.isEmpty())
+ if (includes.isEmpty())
return;
// need to do this or existing settings will disappear
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java
index 969fbad0fd8..b2a17372bd6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.settingswizards;
-
import java.util.ArrayList;
import java.util.List;
@@ -44,13 +43,13 @@ public class MacroSettingsProcessor extends SettingsProcessor {
public static final String SECTION_NAME = "org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros"; //$NON-NLS-1$
private static final String MACRO_ELEMENT = "macro"; //$NON-NLS-1$
- private static final String NAME_ELEMENT = "name"; //$NON-NLS-1$
+ private static final String NAME_ELEMENT = "name"; //$NON-NLS-1$
private static final String VALUE_ELEMENT = "value"; //$NON-NLS-1$
-
@Override
public Image getIcon() {
- return CUIPlugin.getImageDescriptorRegistry().get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO));
+ return CUIPlugin.getImageDescriptorRegistry()
+ .get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO));
}
@Override
@@ -69,7 +68,8 @@ public class MacroSettingsProcessor extends SettingsProcessor {
}
@Override
- protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting) throws SettingsImportExportException {
+ protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting)
+ throws SettingsImportExportException {
char[] name = setting.getName().toCharArray();
char[] value = setting.getValue().toCharArray();
@@ -89,37 +89,36 @@ public class MacroSettingsProcessor extends SettingsProcessor {
content.endElement(NONE, NONE, MACRO_ELEMENT);
newline(content);
- } catch(SAXException e) {
+ } catch (SAXException e) {
throw new SettingsImportExportException(e);
}
}
-
@Override
protected void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException {
List<ICLanguageSettingEntry> macros = new ArrayList<ICLanguageSettingEntry>();
List<Element> macrosNodes = XMLUtils.extractChildElements(language, MACRO_ELEMENT);
- for(Element macroElement : macrosNodes) {
+ for (Element macroElement : macrosNodes) {
String name = null;
String value = null;
NodeList nodeList = macroElement.getChildNodes();
- for(int i = 0; i < nodeList.getLength(); i++) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
- switch(node.getNodeType()) {
+ switch (node.getNodeType()) {
case Node.TEXT_NODE:
- Text text = (Text)node;
- if(XMLUtils.isWhitespace(text.getData()))
+ Text text = (Text) node;
+ if (XMLUtils.isWhitespace(text.getData()))
break;
throw new SettingsImportExportException("Unknown text: '" + text.getData() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
case Node.ELEMENT_NODE:
- Element element = (Element)node;
+ Element element = (Element) node;
String tagName = element.getTagName();
- if(name == null && tagName.equals(NAME_ELEMENT))
+ if (name == null && tagName.equals(NAME_ELEMENT))
name = element.getTextContent();
- else if(value == null && tagName.equals(VALUE_ELEMENT))
+ else if (value == null && tagName.equals(VALUE_ELEMENT))
value = element.getTextContent();
else
throw new SettingsImportExportException("Unknown or extra tag: " + tagName); //$NON-NLS-1$
@@ -129,15 +128,15 @@ public class MacroSettingsProcessor extends SettingsProcessor {
}
}
- if(name == null)
+ if (name == null)
throw new SettingsImportExportException("There must be one <name> element"); //$NON-NLS-1$
- if(value == null)
+ if (value == null)
throw new SettingsImportExportException("There must be one <value> element"); //$NON-NLS-1$
macros.add(CDataUtil.createCMacroEntry(name, value, 0));
}
- if(macros.isEmpty())
+ if (macros.isEmpty())
return;
// need to do this or existing settings will disappear
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.java
index cb1ad456fbe..275af2b88f6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.java
@@ -15,66 +15,45 @@ package org.eclipse.cdt.internal.ui.wizards.settingswizards;
import org.eclipse.osgi.util.NLS;
-
class Messages extends NLS {
-
- private static final String BUNDLE_NAME =
- "org.eclipse.cdt.internal.ui.wizards.settingswizards.messages"; //$NON-NLS-1$
+
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.wizards.settingswizards.messages"; //$NON-NLS-1$
static {
initializeMessages(BUNDLE_NAME, Messages.class);
}
-
- private Messages() { }
-
-
+
+ private Messages() {
+ }
+
// messages specific to the import page
- public static String
- ProjectSettingsWizardPage_Import_title,
- ProjectSettingsWizardPage_Import_message,
- ProjectSettingsWizardPage_Import_selectSettings,
- ProjectSettingsWizardPage_Import_checkBox,
- ProjectSettingsWizardPage_Import_file,
- ProjectSettingsWizardPage_Import_parseError,
- ProjectSettingsWizardPage_Import_openError;
-
+ public static String ProjectSettingsWizardPage_Import_title, ProjectSettingsWizardPage_Import_message,
+ ProjectSettingsWizardPage_Import_selectSettings, ProjectSettingsWizardPage_Import_checkBox,
+ ProjectSettingsWizardPage_Import_file, ProjectSettingsWizardPage_Import_parseError,
+ ProjectSettingsWizardPage_Import_openError;
+
// messages specific to the export page
- public static String
- ProjectSettingsWizardPage_Export_title,
- ProjectSettingsWizardPage_Export_message,
- ProjectSettingsWizardPage_Export_selectSettings,
- ProjectSettingsWizardPage_Export_checkBox,
- ProjectSettingsWizardPage_Export_file;
-
+ public static String ProjectSettingsWizardPage_Export_title, ProjectSettingsWizardPage_Export_message,
+ ProjectSettingsWizardPage_Export_selectSettings, ProjectSettingsWizardPage_Export_checkBox,
+ ProjectSettingsWizardPage_Export_file;
+
// messages common to both
- public static String
- ProjectSettingsWizardPage_selectAll,
- ProjectSettingsWizardPage_deselectAll,
- ProjectSettingsWizardPage_selectProject,
- ProjectSettingsWizardPage_browse,
- ProjectSettingsWizardPage_noOpenProjects,
- ProjectSettingsWizardPage_selectConfiguration,
- ProjectSettingsWizardPage_active;
-
+ public static String ProjectSettingsWizardPage_selectAll, ProjectSettingsWizardPage_deselectAll,
+ ProjectSettingsWizardPage_selectProject, ProjectSettingsWizardPage_browse,
+ ProjectSettingsWizardPage_noOpenProjects, ProjectSettingsWizardPage_selectConfiguration,
+ ProjectSettingsWizardPage_active;
+
// messages for settings processors
- public static String
- ProjectSettingsWizardPage_Processor_Includes,
- ProjectSettingsWizardPage_Processor_Macros;
-
+ public static String ProjectSettingsWizardPage_Processor_Includes, ProjectSettingsWizardPage_Processor_Macros;
+
// error messages during export
- public static String
- ProjectSettingsExportStrategy_couldNotOpen,
- ProjectSettingsExportStrategy_exportError,
- ProjectSettingsExportStrategy_exportFailed,
- ProjectSettingsExportStrategy_fileOpenError,
- ProjectSettingsExportStrategy_xmlError;
-
+ public static String ProjectSettingsExportStrategy_couldNotOpen, ProjectSettingsExportStrategy_exportError,
+ ProjectSettingsExportStrategy_exportFailed, ProjectSettingsExportStrategy_fileOpenError,
+ ProjectSettingsExportStrategy_xmlError;
+
// error messages during import
- public static String
- ProjectSettingsImportStrategy_couldNotImport,
- ProjectSettingsImportStrategy_couldNotOpen,
- ProjectSettingsImportStrategy_fileOpenError,
- ProjectSettingsImportStrategy_importError,
- ProjectSettingsImportStrategy_saveError;
-
+ public static String ProjectSettingsImportStrategy_couldNotImport, ProjectSettingsImportStrategy_couldNotOpen,
+ ProjectSettingsImportStrategy_fileOpenError, ProjectSettingsImportStrategy_importError,
+ ProjectSettingsImportStrategy_saveError;
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java
index 686c6ead6db..a2faa63a832 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.settingswizards;
-
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
@@ -40,10 +39,9 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
import org.eclipse.cdt.ui.CUIPlugin;
-
/**
* Custom behavior for the Export wizard.
- *
+ *
* @author Mike Kucera
* @since 5.1
*
@@ -53,47 +51,45 @@ public class ProjectSettingsExportStrategy implements IProjectSettingsWizardPage
public static final String ROOT_ELEMENT = "cdtprojectproperties"; //$NON-NLS-1$
public static final String SECTION_ELEMENT = "section"; //$NON-NLS-1$
public static final String SECTION_NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
-
-
-
+
private static final String NONE = ""; //$NON-NLS-1$
private static final String CDATA = "CDATA"; //$NON-NLS-1$
-
-
-
+
@Override
public String getMessage(MessageType type) {
- switch(type) {
- case TITLE: return Messages.ProjectSettingsWizardPage_Export_title;
- case MESSAGE: return Messages.ProjectSettingsWizardPage_Export_message;
- case CHECKBOX: return Messages.ProjectSettingsWizardPage_Export_checkBox;
- case FILE: return Messages.ProjectSettingsWizardPage_Export_file;
- case SETTINGS: return Messages.ProjectSettingsWizardPage_Export_selectSettings;
- default: return null;
+ switch (type) {
+ case TITLE:
+ return Messages.ProjectSettingsWizardPage_Export_title;
+ case MESSAGE:
+ return Messages.ProjectSettingsWizardPage_Export_message;
+ case CHECKBOX:
+ return Messages.ProjectSettingsWizardPage_Export_checkBox;
+ case FILE:
+ return Messages.ProjectSettingsWizardPage_Export_file;
+ case SETTINGS:
+ return Messages.ProjectSettingsWizardPage_Export_selectSettings;
+ default:
+ return null;
}
}
-
@Override
public void pageCreated(IProjectSettingsWizardPage page) {
// do nothing
}
-
@Override
public void fileSelected(IProjectSettingsWizardPage page) {
// do nothing
}
-
private Writer getWriter(IProjectSettingsWizardPage page) throws IOException {
IPath path = new Path(page.getDestinationFilePath());
- if(!IProjectSettingsWizardPage.FILENAME_EXTENSION.equals(path.getFileExtension()))
+ if (!IProjectSettingsWizardPage.FILENAME_EXTENSION.equals(path.getFileExtension()))
path.addFileExtension(IProjectSettingsWizardPage.FILENAME_EXTENSION);
-
+
return new FileWriter(path.toFile());
}
-
/**
* Exports the selected project settings to an XML file.
@@ -106,85 +102,80 @@ public class ProjectSettingsExportStrategy implements IProjectSettingsWizardPage
handler = factory.newTransformerHandler();
} catch (TransformerConfigurationException e) {
CUIPlugin.log(e);
- page.showErrorDialog(Messages.ProjectSettingsExportStrategy_exportError,
- Messages.ProjectSettingsExportStrategy_exportFailed);
+ page.showErrorDialog(Messages.ProjectSettingsExportStrategy_exportError,
+ Messages.ProjectSettingsExportStrategy_exportFailed);
return false;
}
-
+
// gets a writer for the file that was selected by the user
Writer writer;
try {
writer = getWriter(page);
- } catch(IOException e) {
- page.showErrorDialog(Messages.ProjectSettingsExportStrategy_fileOpenError,
- Messages.ProjectSettingsExportStrategy_couldNotOpen);
+ } catch (IOException e) {
+ page.showErrorDialog(Messages.ProjectSettingsExportStrategy_fileOpenError,
+ Messages.ProjectSettingsExportStrategy_couldNotOpen);
return false;
}
-
+
// stream the results to the writer as text
handler.setResult(new StreamResult(writer));
-
+
// write out the XML header
Transformer transformer = handler.getTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
-
+
List<ISettingsProcessor> exporters = page.getSelectedSettingsProcessors();
-
+
ICConfigurationDescription config = page.getSelectedConfiguration();
ICFolderDescription projectRoot = config.getRootFolderDescription();
-
+
boolean result = false;
try {
AttributesImpl attributes = new AttributesImpl();
-
+
handler.startDocument();
newline(handler);
handler.startElement(NONE, NONE, ROOT_ELEMENT, null);
newline(handler);
-
- for(ISettingsProcessor exporter : exporters) {
+
+ for (ISettingsProcessor exporter : exporters) {
attributes.clear();
attributes.addAttribute(NONE, NONE, SECTION_NAME_ATTRIBUTE, CDATA, exporter.getSectionName());
handler.startElement(NONE, NONE, SECTION_ELEMENT, attributes);
newline(handler);
-
+
// each exporter is responsible for writing out its own section of the file
exporter.writeSectionXML(projectRoot, handler);
-
+
handler.endElement(NONE, NONE, SECTION_ELEMENT);
newline(handler);
}
-
+
handler.endElement(NONE, NONE, ROOT_ELEMENT);
newline(handler);
handler.endDocument();
newline(handler);
-
+
result = true;
} catch (SAXException e) {
CUIPlugin.log(e);
- page.showErrorDialog(Messages.ProjectSettingsExportStrategy_exportError,
- Messages.ProjectSettingsExportStrategy_xmlError);
+ page.showErrorDialog(Messages.ProjectSettingsExportStrategy_exportError,
+ Messages.ProjectSettingsExportStrategy_xmlError);
result = false;
- } catch(SettingsImportExportException e) {
+ } catch (SettingsImportExportException e) {
CUIPlugin.log(e);
- page.showErrorDialog(Messages.ProjectSettingsExportStrategy_fileOpenError,
- Messages.ProjectSettingsExportStrategy_couldNotOpen);
+ page.showErrorDialog(Messages.ProjectSettingsExportStrategy_fileOpenError,
+ Messages.ProjectSettingsExportStrategy_couldNotOpen);
result = false;
}
-
+
URI uri = URIUtil.toURI(page.getDestinationFilePath());
ResourcesUtil.refreshWorkspaceFiles(uri);
-
+
return result;
}
-
-
-
-
-
-
+
/**
* Outputs a newline (\n) to the given ContentHandler.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportWizard.java
index 8d211f37754..ab1213eedba 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportWizard.java
@@ -22,17 +22,15 @@ import org.eclipse.ui.IWorkbench;
*/
public class ProjectSettingsExportWizard extends ProjectSettingsWizard implements IExportWizard {
-
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
super.init(workbench, selection);
- setWindowTitle(Messages.ProjectSettingsWizardPage_Export_title);
+ setWindowTitle(Messages.ProjectSettingsWizardPage_Export_title);
}
@Override
public ProjectSettingsWizardPage getPage() {
return ProjectSettingsWizardPage.createExportWizardPage();
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java
index 6f97964ac2e..93312d29b8f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java
@@ -43,26 +43,30 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* Custom behavior for the Import wizard.
- *
+ *
* @author Mike Kucera
* @since 5.1
*
*/
public class ProjectSettingsImportStrategy implements IProjectSettingsWizardPageStrategy {
-
@Override
public String getMessage(MessageType type) {
- switch(type) {
- case TITLE: return Messages.ProjectSettingsWizardPage_Import_title;
- case MESSAGE: return Messages.ProjectSettingsWizardPage_Import_message;
- case CHECKBOX: return Messages.ProjectSettingsWizardPage_Import_checkBox;
- case FILE: return Messages.ProjectSettingsWizardPage_Import_file;
- case SETTINGS: return Messages.ProjectSettingsWizardPage_Import_selectSettings;
- default: return null;
+ switch (type) {
+ case TITLE:
+ return Messages.ProjectSettingsWizardPage_Import_title;
+ case MESSAGE:
+ return Messages.ProjectSettingsWizardPage_Import_message;
+ case CHECKBOX:
+ return Messages.ProjectSettingsWizardPage_Import_checkBox;
+ case FILE:
+ return Messages.ProjectSettingsWizardPage_Import_file;
+ case SETTINGS:
+ return Messages.ProjectSettingsWizardPage_Import_selectSettings;
+ default:
+ return null;
}
}
-
/*
* Start with an empty list of processors.
@@ -71,10 +75,9 @@ public class ProjectSettingsImportStrategy implements IProjectSettingsWizardPage
public void pageCreated(IProjectSettingsWizardPage page) {
page.setDisplayedSettingsProcessors(Collections.<ISettingsProcessor>emptyList());
}
-
-
+
/*
- * Collects the importers that can be applied to the file and displays
+ * Collects the importers that can be applied to the file and displays
* them to the user.
*/
@Override
@@ -88,17 +91,16 @@ public class ProjectSettingsImportStrategy implements IProjectSettingsWizardPage
} catch (SettingsImportExportException e) {
page.setMessage(Messages.ProjectSettingsWizardPage_Import_parseError, IMessageProvider.ERROR);
}
-
+
List<ISettingsProcessor> importersToDisplay = new ArrayList<ISettingsProcessor>();
- for(ImporterSectionPair pair : pairs) {
+ for (ImporterSectionPair pair : pairs) {
importersToDisplay.add(pair.importer);
}
-
+
// if there was an error then importersToDisplay will be empty and this will clear the list
page.setDisplayedSettingsProcessors(importersToDisplay);
}
-
-
+
/*
* Parse the file again and this time actually do the import.
*/
@@ -107,97 +109,97 @@ public class ProjectSettingsImportStrategy implements IProjectSettingsWizardPage
// get the selected project and configuration
ICConfigurationDescription config = page.getSelectedConfiguration();
IProject project = config.getProjectDescription().getProject();
-
+
// get a writable copy of the project description so that we can make changes to it
ICProjectDescription writableDescription = CoreModel.getDefault().getProjectDescription(project, true);
ICConfigurationDescription writableConfig = writableDescription.getConfigurationById(config.getId());
ICFolderDescription writableProjectRoot = writableConfig.getRootFolderDescription();
-
+
List<ISettingsProcessor> selectedImporters = page.getSelectedSettingsProcessors();
-
+
try {
List<ImporterSectionPair> pairs = extractSectionsFromFile(page);
-
- for(ImporterSectionPair pair : pairs) {
- if(selectedImporters.contains(pair.importer))
+
+ for (ImporterSectionPair pair : pairs) {
+ if (selectedImporters.contains(pair.importer))
pair.importer.readSectionXML(writableProjectRoot, pair.section);
}
-
+
} catch (FileNotFoundException e) {
CUIPlugin.log(e);
- page.showErrorDialog(Messages.ProjectSettingsImportStrategy_fileOpenError,
- Messages.ProjectSettingsImportStrategy_couldNotOpen);
+ page.showErrorDialog(Messages.ProjectSettingsImportStrategy_fileOpenError,
+ Messages.ProjectSettingsImportStrategy_couldNotOpen);
return false;
} catch (SettingsImportExportException e) { // error during parsing or importing
CUIPlugin.log(e);
- page.showErrorDialog(Messages.ProjectSettingsImportStrategy_importError,
- Messages.ProjectSettingsImportStrategy_couldNotImport);
+ page.showErrorDialog(Messages.ProjectSettingsImportStrategy_importError,
+ Messages.ProjectSettingsImportStrategy_couldNotImport);
return false;
}
-
+
// only if all the importing was successful do we actually write out to the .cproject file
try {
CoreModel.getDefault().setProjectDescription(project, writableDescription);
} catch (CoreException e) {
CUIPlugin.log(e);
- page.showErrorDialog(Messages.ProjectSettingsImportStrategy_importError,
- Messages.ProjectSettingsImportStrategy_saveError);
+ page.showErrorDialog(Messages.ProjectSettingsImportStrategy_importError,
+ Messages.ProjectSettingsImportStrategy_saveError);
return false;
}
-
+
return true;
}
-
private static class ImporterSectionPair {
Element section;
ISettingsProcessor importer;
+
ImporterSectionPair(ISettingsProcessor importer, Element section) {
this.importer = importer;
this.section = section;
}
}
-
+
/*
* Attempts to parse the file the user selected.
*/
- private List<ImporterSectionPair> extractSectionsFromFile(IProjectSettingsWizardPage page) throws FileNotFoundException, SettingsImportExportException {
+ private List<ImporterSectionPair> extractSectionsFromFile(IProjectSettingsWizardPage page)
+ throws FileNotFoundException, SettingsImportExportException {
// get the file path that the user input
String filePath = page.getDestinationFilePath();
-
+
// get all the importers
- Map<String,ISettingsProcessor> importers = new HashMap<String,ISettingsProcessor>();
- for(ISettingsProcessor processor : page.getSettingsProcessors()) {
+ Map<String, ISettingsProcessor> importers = new HashMap<String, ISettingsProcessor>();
+ for (ISettingsProcessor processor : page.getSettingsProcessors()) {
importers.put(processor.getSectionName(), processor);
}
-
+
FileInputStream in = new FileInputStream(filePath); // throws FileNotFoundException
-
+
// try to parse the file as generic XML with no schema
Document document = parse(in);
-
+
// now try to get a list of <section> elements
Element root = document.getDocumentElement();
List<Element> sections = XMLUtils.extractChildElements(root, ProjectSettingsExportStrategy.SECTION_ELEMENT);
-
+
List<ImporterSectionPair> pairs = new ArrayList<ImporterSectionPair>();
-
+
// associate an importer with each section
- for(Element section : sections) {
+ for (Element section : sections) {
String sectionName = section.getAttribute(ProjectSettingsExportStrategy.SECTION_NAME_ATTRIBUTE);
- if(sectionName != null) {
+ if (sectionName != null) {
ISettingsProcessor importer = importers.get(sectionName);
-
+
// if there is an importer available for the section then delegate to it
- if(importer != null)
+ if (importer != null)
pairs.add(new ImporterSectionPair(importer, section));
}
}
-
+
return pairs;
}
-
-
+
/**
* An error handler that aborts the XML parse at the first sign
* of any kind of problem.
@@ -207,23 +209,24 @@ public class ProjectSettingsImportStrategy implements IProjectSettingsWizardPage
public void error(SAXParseException e) throws SAXException {
throw e;
}
+
@Override
public void fatalError(SAXParseException e) throws SAXException {
throw e;
}
+
@Override
public void warning(SAXParseException e) throws SAXException {
throw e;
}
};
-
-
+
/*
* Uses JAXP to parse the file. Returns null if the file could
* not be parsed as XML.
- *
+ *
* Not validating because I want to make it easy to add new settings processors.
- * Eventually there could be an extension point for adding settings processors
+ * Eventually there could be an extension point for adding settings processors
* so I'm coding everything with the assumption that each settings processor
* will do its own validation programatically.
*/
@@ -232,19 +235,17 @@ public class ProjectSettingsImportStrategy implements IProjectSettingsWizardPage
factory.setValidating(false);
factory.setNamespaceAware(false);
factory.setIgnoringComments(true);
-
+
try {
DocumentBuilder parser = factory.newDocumentBuilder();
parser.setErrorHandler(ABORTING_ERROR_HANDER); // causes SAXException to be thrown on any parse error
InputSource input = new InputSource(in); // TODO should I be using an InputSource?
Document doc = parser.parse(input);
return doc;
-
+
} catch (Exception e) {
throw new SettingsImportExportException(e);
}
}
-
-
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportWizard.java
index 9e866ebea25..78685ce08a3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportWizard.java
@@ -22,7 +22,6 @@ import org.eclipse.ui.IWorkbench;
*/
public class ProjectSettingsImportWizard extends ProjectSettingsWizard implements IImportWizard {
-
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
super.init(workbench, selection);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizard.java
index d5334084d85..04991bd6721 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizard.java
@@ -25,25 +25,24 @@ public abstract class ProjectSettingsWizard extends Wizard {
private ProjectSettingsWizardPage mainPage;
private IStructuredSelection selection;
-
- public abstract ProjectSettingsWizardPage getPage();
+
+ public abstract ProjectSettingsWizardPage getPage();
private boolean finishedPressed;
-
-
+
@Override
public void addPages() {
super.addPages();
mainPage = getPage();
-
+
// happens if the user invoked the wizard by right clicking on a project element
- if(selection != null) {
+ if (selection != null) {
final Object firstElement = selection.getFirstElement();
if (firstElement instanceof IProject) {
- mainPage.setInitialProject((IProject)firstElement);
+ mainPage.setInitialProject((IProject) firstElement);
}
}
-
+
addPage(mainPage);
}
@@ -52,16 +51,14 @@ public abstract class ProjectSettingsWizard extends Wizard {
finishedPressed = true;
return mainPage.finish();
}
-
+
public boolean isFinishedPressed() {
return finishedPressed;
}
-
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.selection = selection;
setNeedsProgressMonitor(true);
}
-
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizardPage.java
index fe96505fb36..fc0863fc0b0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizardPage.java
@@ -67,109 +67,95 @@ import org.eclipse.cdt.internal.ui.wizards.settingswizards.IProjectSettingsWizar
abstract public class ProjectSettingsWizardPage extends WizardPage implements IProjectSettingsWizardPage {
public static final String FILENAME_EXTENSION = "xml"; //$NON-NLS-1$
-
-
+
private final IProjectSettingsWizardPageStrategy strategy;
private final List<ISettingsProcessor> processors;
-
+
private ICProject selectedProject;
private ICConfigurationDescription selectedConfiguration;
-
+
private Text filePathText;
private CheckboxTableViewer settingsViewer;
-
+
private IProject initialProject;
-
+
/**
- *
+ *
* @param strategy
* @param initialProject the initial project to be selected, may be null
*/
private ProjectSettingsWizardPage(IProjectSettingsWizardPageStrategy strategy) {
super(""); //$NON-NLS-1$
this.strategy = strategy;
-
+
// This could be replaced with an extension point
- this.processors = Arrays.<ISettingsProcessor>asList(
- new IncludePathsSettingsProcessor(),
- new MacroSettingsProcessor()
- );
-
+ this.processors = Arrays.<ISettingsProcessor>asList(new IncludePathsSettingsProcessor(),
+ new MacroSettingsProcessor());
+
}
-
-
-
-
+
protected abstract void layoutPage(Composite parent);
-
-
+
public static ProjectSettingsWizardPage createExportWizardPage() {
return new ProjectSettingsWizardPage(new ProjectSettingsExportStrategy()) {
@Override
public void layoutPage(Composite parent) {
- createProjectSelectionGroup(parent);
- createSettingsSelectionGroup(parent);
- //createCheckboxSelectionGroup(parent);
- createFileSelectionGroup(parent);
+ createProjectSelectionGroup(parent);
+ createSettingsSelectionGroup(parent);
+ //createCheckboxSelectionGroup(parent);
+ createFileSelectionGroup(parent);
}
};
}
-
-
+
public static ProjectSettingsWizardPage createImportWizardPage() {
return new ProjectSettingsWizardPage(new ProjectSettingsImportStrategy()) {
@Override
public void layoutPage(Composite parent) {
createFileSelectionGroup(parent);
- createProjectSelectionGroup(parent);
- createSettingsSelectionGroup(parent);
- //createCheckboxSelectionGroup(parent);
+ createProjectSelectionGroup(parent);
+ createSettingsSelectionGroup(parent);
+ //createCheckboxSelectionGroup(parent);
}
};
}
-
-
+
public boolean finish() {
return strategy.finish(this);
}
-
-
+
public void setInitialProject(IProject project) {
this.initialProject = project;
}
-
-
+
@Override
public List<ISettingsProcessor> getSettingsProcessors() {
return Collections.unmodifiableList(processors);
}
-
-
+
@Override
public List<ISettingsProcessor> getSelectedSettingsProcessors() {
List<ISettingsProcessor> selected = new ArrayList<ISettingsProcessor>();
- for(Object element : settingsViewer.getCheckedElements()) {
- selected.add((ISettingsProcessor)element);
+ for (Object element : settingsViewer.getCheckedElements()) {
+ selected.add((ISettingsProcessor) element);
}
return selected;
}
-
+
@Override
public String getDestinationFilePath() {
return filePathText.getText();
}
-
-
+
public ICProject getSelectedProject() {
return selectedProject;
}
-
-
+
@Override
public ICConfigurationDescription getSelectedConfiguration() {
return selectedConfiguration;
}
-
+
@Override
public void setDisplayedSettingsProcessors(List<ISettingsProcessor> processors) {
settingsViewer.setInput(processors);
@@ -177,65 +163,58 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP
settingsViewer.setAllChecked(true);
updateWidgetEnablements();
}
-
-
+
@Override
public void showErrorDialog(String dialogTitle, String message) {
Shell shell = Display.getCurrent().getActiveShell();
Status status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, message, null);
ErrorDialog.openError(shell, dialogTitle, null, status);
}
-
-
+
@Override
public void createControl(Composite parent) {
setTitle(strategy.getMessage(MessageType.TITLE));
setMessage(strategy.getMessage(MessageType.MESSAGE));
-
+
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
- composite.setFont(parent.getFont());
-
- layoutPage(composite);
-
+ composite.setFont(parent.getFont());
+
+ layoutPage(composite);
+
setControl(composite);
-
+
strategy.pageCreated(this);
-
+
updateWidgetEnablements();
}
-
-
+
private void updateWidgetEnablements() {
- boolean enableFinishButton = selectedProject != null
- && selectedConfiguration != null
- && settingsViewer.getCheckedElements().length > 0
- && filePathText.getText().length() > 0;
-
+ boolean enableFinishButton = selectedProject != null && selectedConfiguration != null
+ && settingsViewer.getCheckedElements().length > 0 && filePathText.getText().length() > 0;
+
// since this wizard has only one page we can toggle the finish button using the setPageComplete() method
setPageComplete(enableFinishButton);
}
-
-
-
+
protected void createProjectSelectionGroup(Composite parent) {
Composite projectSelectionGroup = new Composite(parent, SWT.NONE);
projectSelectionGroup.setLayout(new GridLayout(2, true));
projectSelectionGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
projectSelectionGroup.setFont(parent.getFont());
-
+
Label projectLabel = new Label(projectSelectionGroup, SWT.NONE);
projectLabel.setText(Messages.ProjectSettingsWizardPage_selectProject);
projectLabel.setLayoutData(new GridData());
-
+
Label configLabel = new Label(projectSelectionGroup, SWT.NONE);
configLabel.setText(Messages.ProjectSettingsWizardPage_selectConfiguration);
configLabel.setLayoutData(new GridData());
final Table projectTable = new Table(projectSelectionGroup, SWT.SINGLE | SWT.BORDER);
projectTable.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
TableViewer projectViewer = new TableViewer(projectTable);
projectViewer.setContentProvider(new ListContentProvider());
projectViewer.setLabelProvider(new CElementLabelProvider());
@@ -247,175 +226,176 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP
}
});
projectViewer.setInput(openProjects);
-
+
final Table configTable = new Table(projectSelectionGroup, SWT.SINGLE | SWT.BORDER);
configTable.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
final TableViewer configViewer = new TableViewer(configTable);
configViewer.setContentProvider(new ListContentProvider());
- configViewer.setLabelProvider(new LabelProvider() {
- @Override public Image getImage(Object element) {
+ configViewer.setLabelProvider(new LabelProvider() {
+ @Override
+ public Image getImage(Object element) {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CONFIG);
}
- @Override public String getText(Object element) {
- ICConfigurationDescription config = (ICConfigurationDescription)element;
+
+ @Override
+ public String getText(Object element) {
+ ICConfigurationDescription config = (ICConfigurationDescription) element;
String label = config.getName();
- if(config.isActive())
+ if (config.isActive())
label += " (" + Messages.ProjectSettingsWizardPage_active + ")"; //$NON-NLS-1$ //$NON-NLS-2$
return label;
}
});
-
-
+
// TODO what if nothing is selected?
projectTable.addSelectionListener(new SelectionAdapter() {
- @Override public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
TableItem[] items = projectTable.getSelection();
- selectedProject = (ICProject)items[0].getData(); // its a single select so this is ok
+ selectedProject = (ICProject) items[0].getData(); // its a single select so this is ok
configViewer.setInput(getConfigurations(selectedProject));
configViewer.refresh();
configTable.select(0);
configTable.notifyListeners(SWT.Selection, new Event());
}
});
-
-
+
configTable.addSelectionListener(new SelectionAdapter() {
- @Override public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
TableItem[] items = configTable.getSelection();
- selectedConfiguration = (ICConfigurationDescription)items[0].getData();
+ selectedConfiguration = (ICConfigurationDescription) items[0].getData();
updateWidgetEnablements();
}
});
-
- if(openProjects.isEmpty()) {
+
+ if (openProjects.isEmpty()) {
setErrorMessage(Messages.ProjectSettingsWizardPage_noOpenProjects);
}
-
-
- if((initialProject == null || !initialProject.isOpen()) && !openProjects.isEmpty()) {
+
+ if ((initialProject == null || !initialProject.isOpen()) && !openProjects.isEmpty()) {
initialProject = openProjects.get(0).getProject();
}
-
- if(initialProject != null) {
+
+ if (initialProject != null) {
String initialProjectName = initialProject.getName();
- for(int i = 0; i < openProjects.size(); i++) {
+ for (int i = 0; i < openProjects.size(); i++) {
ICProject tableProject = openProjects.get(i);
- if(tableProject.getElementName().equals(initialProjectName)) {
+ if (tableProject.getElementName().equals(initialProjectName)) {
projectTable.select(i);
configViewer.setInput(getConfigurations(tableProject));
configViewer.refresh();
configTable.select(0);
selectedProject = tableProject;
- selectedConfiguration = (ICConfigurationDescription)configTable.getSelection()[0].getData();
+ selectedConfiguration = (ICConfigurationDescription) configTable.getSelection()[0].getData();
break;
}
}
}
}
-
-
+
private static List<ICConfigurationDescription> getConfigurations(ICProject project) {
// get a read-only project description, no need to waste memory
ICProjectDescription description = CCorePlugin.getDefault().getProjectDescription(project.getProject(), false);
return Arrays.asList(description.getConfigurations());
}
-
-
+
private static List<ICProject> getAllOpenCProjects() {
- List<ICProject> projects = new ArrayList<ICProject>();
+ List<ICProject> projects = new ArrayList<ICProject>();
try {
- for(ICProject project : CoreModel.getDefault().getCModel().getCProjects()) {
- if(project.getProject().isOpen()) {
- projects.add(project);
+ for (ICProject project : CoreModel.getDefault().getCModel().getCProjects()) {
+ if (project.getProject().isOpen()) {
+ projects.add(project);
}
- }
- } catch(CModelException e) {
+ }
+ } catch (CModelException e) {
CUIPlugin.log(e);
}
return projects;
}
-
-
+
protected void createSettingsSelectionGroup(Composite parent) {
Composite settingsSelectionGroup = new Composite(parent, SWT.NONE);
settingsSelectionGroup.setLayout(new GridLayout());
settingsSelectionGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
settingsSelectionGroup.setFont(parent.getFont());
-
+
Label label = new Label(settingsSelectionGroup, SWT.NONE);
label.setText(strategy.getMessage(MessageType.SETTINGS));
-
+
Table table = new Table(settingsSelectionGroup, SWT.CHECK | SWT.BORDER);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-
+
settingsViewer = new CheckboxTableViewer(table);
settingsViewer.setContentProvider(new ListContentProvider());
-
+
settingsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateWidgetEnablements();
}
});
-
+
LabelProvider settingsProcessorLabelProvider = new LabelProvider() {
- @Override public Image getImage(Object element) {
- return ((ISettingsProcessor)element).getIcon();
+ @Override
+ public Image getImage(Object element) {
+ return ((ISettingsProcessor) element).getIcon();
}
- @Override public String getText(Object element) {
- return ((ISettingsProcessor)element).getDisplayName();
+
+ @Override
+ public String getText(Object element) {
+ return ((ISettingsProcessor) element).getDisplayName();
}
};
-
- settingsViewer.setLabelProvider(settingsProcessorLabelProvider);
+
+ settingsViewer.setLabelProvider(settingsProcessorLabelProvider);
settingsViewer.setInput(processors);
settingsViewer.setAllChecked(true);
-
-
+
Composite buttonComposite = new Composite(settingsSelectionGroup, SWT.NONE);
GridLayout layout = new GridLayout(2, true);
- layout.marginHeight= layout.marginWidth= 0;
- buttonComposite.setLayout(layout);
- buttonComposite.setLayoutData(new GridData());
-
+ layout.marginHeight = layout.marginWidth = 0;
+ buttonComposite.setLayout(layout);
+ buttonComposite.setLayoutData(new GridData());
+
Button selectButton = new Button(buttonComposite, SWT.PUSH);
selectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
selectButton.setText(Messages.ProjectSettingsWizardPage_selectAll);
-
+
selectButton.addSelectionListener(new SelectionAdapter() {
- @Override public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
settingsViewer.setAllChecked(true);
updateWidgetEnablements();
}
});
-
+
Button deselectButton = new Button(buttonComposite, SWT.PUSH);
deselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
deselectButton.setText(Messages.ProjectSettingsWizardPage_deselectAll);
-
+
deselectButton.addSelectionListener(new SelectionAdapter() {
- @Override public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
settingsViewer.setAllChecked(false);
updateWidgetEnablements();
}
});
}
-
-
+
protected void createFileSelectionGroup(Composite parent) {
Composite fileSelectionGroup = new Composite(parent, SWT.NONE);
fileSelectionGroup.setLayout(new GridLayout(2, false));
fileSelectionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fileSelectionGroup.setFont(parent.getFont());
-
+
Label label = new Label(fileSelectionGroup, SWT.NONE);
label.setText(strategy.getMessage(MessageType.FILE));
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
label.setLayoutData(gridData);
-
+
filePathText = new Text(fileSelectionGroup, SWT.SINGLE | SWT.BORDER);
filePathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filePathText.addModifyListener(new ModifyListener() {
@@ -423,44 +403,40 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP
public void modifyText(ModifyEvent e) {
updateWidgetEnablements();
strategy.fileSelected(ProjectSettingsWizardPage.this);
- }
+ }
});
-
+
Button browseButton = new Button(fileSelectionGroup, SWT.PUSH);
browseButton.setText(Messages.ProjectSettingsWizardPage_browse);
browseButton.setLayoutData(new GridData());
browseButton.addSelectionListener(new SelectionAdapter() {
- @Override public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
int type = (strategy instanceof ProjectSettingsImportStrategy) ? SWT.OPEN : SWT.SAVE;
FileDialog fileDialog = new FileDialog(getShell(), type);
- fileDialog.setFilterExtensions(new String[] {"*." + FILENAME_EXTENSION}); //$NON-NLS-1$
+ fileDialog.setFilterExtensions(new String[] { "*." + FILENAME_EXTENSION }); //$NON-NLS-1$
String filePath = fileDialog.open();
- if(filePath != null)
+ if (filePath != null)
filePathText.setText(filePath);
}
});
}
-
-
-
-// protected void createCheckboxSelectionGroup(Composite parent) {
-// Composite checkboxSelectGroup = new Composite(parent, SWT.NONE);
-// checkboxSelectGroup.setLayout(new GridLayout());
-// checkboxSelectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-// checkboxSelectGroup.setFont(parent.getFont());
-//
-// final Button checkBox = new Button(checkboxSelectGroup, SWT.CHECK);
-// checkBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-// checkBox.setText(strategy.getMessage(CHECKBOX));
-//
-// checkBox.addSelectionListener(new SelectionAdapter() {
-// @Override public void widgetSelected(SelectionEvent e) {
-// strategy.handleCheckboxClick(ProjectSettingsWizardPage.this, checkBox.getSelection());
-// }
-// });
-// }
-
+ // protected void createCheckboxSelectionGroup(Composite parent) {
+ // Composite checkboxSelectGroup = new Composite(parent, SWT.NONE);
+ // checkboxSelectGroup.setLayout(new GridLayout());
+ // checkboxSelectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ // checkboxSelectGroup.setFont(parent.getFont());
+ //
+ // final Button checkBox = new Button(checkboxSelectGroup, SWT.CHECK);
+ // checkBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ // checkBox.setText(strategy.getMessage(CHECKBOX));
+ //
+ // checkBox.addSelectionListener(new SelectionAdapter() {
+ // @Override public void widgetSelected(SelectionEvent e) {
+ // strategy.handleCheckboxClick(ProjectSettingsWizardPage.this, checkBox.getSelection());
+ // }
+ // });
+ // }
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImportExportException.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImportExportException.java
index 9e3be9767e9..882bfccd0e8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImportExportException.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImportExportException.java
@@ -16,7 +16,7 @@ package org.eclipse.cdt.internal.ui.wizards.settingswizards;
/**
* An exception that represents a problem with importing or exporting
* settings.
- *
+ *
* @since 5.1
*/
public class SettingsImportExportException extends Exception {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java
index 9e35fa0c51f..acb79958bb6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java
@@ -29,7 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
/**
* Base class implementing standard import and export functionality
* for a section of the file.
- *
+ *
* @author Mike Kucera
* @since 5.1
*/
@@ -37,85 +37,77 @@ public abstract class SettingsProcessor implements ISettingsProcessor {
protected static final String NONE = ""; //$NON-NLS-1$
protected static final String CDATA = "CDATA"; //$NON-NLS-1$
-
+
protected static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
protected static final String LANGUAGE_ELEMENT = "language"; //$NON-NLS-1$
-
-
+
/**
* Returns a constant from the ICSettingEntry interface.
*/
protected abstract int getSettingsType();
-
-
+
protected abstract void writeSettings(ContentHandler content, ICLanguageSettingEntry setting)
- throws SettingsImportExportException;
-
-
- protected abstract void readSettings(ICLanguageSetting setting, Element language)
- throws SettingsImportExportException;
-
-
+ throws SettingsImportExportException;
+
+ protected abstract void readSettings(ICLanguageSetting setting, Element language)
+ throws SettingsImportExportException;
+
/**
* Outputs a newline (\n) to the given ContentHandler.
*/
protected static void newline(ContentHandler handler) throws SAXException {
handler.ignorableWhitespace("\n".toCharArray(), 0, 1); //$NON-NLS-1$
}
-
-
@Override
- public void writeSectionXML(ICFolderDescription projectRoot, ContentHandler content) throws SettingsImportExportException {
+ public void writeSectionXML(ICFolderDescription projectRoot, ContentHandler content)
+ throws SettingsImportExportException {
ICLanguageSetting[] languages = projectRoot.getLanguageSettings();
AttributesImpl attributes = new AttributesImpl();
-
+
try {
- for(ICLanguageSetting language : languages) {
+ for (ICLanguageSetting language : languages) {
//TODO for some reason language.getLanguageId() is returning null
String languageName = language.getName();
attributes.clear();
attributes.addAttribute(NONE, NONE, NAME_ATTRIBUTE, CDATA, languageName);
content.startElement(NONE, NONE, LANGUAGE_ELEMENT, attributes);
newline(content);
-
+
ICLanguageSettingEntry[] settings = language.getSettingEntries(getSettingsType());
-
- for(ICLanguageSettingEntry setting : settings) {
- if(!setting.isBuiltIn()) {
+
+ for (ICLanguageSettingEntry setting : settings) {
+ if (!setting.isBuiltIn()) {
writeSettings(content, setting);
}
}
-
+
newline(content);
content.endElement(NONE, NONE, LANGUAGE_ELEMENT);
newline(content);
}
-
- } catch(SAXException e) {
+
+ } catch (SAXException e) {
throw new SettingsImportExportException(e);
}
}
-
-
-
+
@Override
public void readSectionXML(ICFolderDescription projectRoot, Element section) throws SettingsImportExportException {
ICLanguageSetting[] languageSettings = projectRoot.getLanguageSettings();
-
- Map<String,ICLanguageSetting> languageMap = new HashMap<String,ICLanguageSetting>();
- for(ICLanguageSetting language : languageSettings) {
+
+ Map<String, ICLanguageSetting> languageMap = new HashMap<String, ICLanguageSetting>();
+ for (ICLanguageSetting language : languageSettings) {
languageMap.put(language.getName(), language);
}
-
+
List<Element> elements = XMLUtils.extractChildElements(section, LANGUAGE_ELEMENT); // throws SettingsImportExportException
- for(Element languageElement : elements) {
+ for (Element languageElement : elements) {
String languageName = languageElement.getAttribute(NAME_ATTRIBUTE);
ICLanguageSetting setting = languageMap.get(languageName);
- if(setting != null)
+ if (setting != null)
readSettings(setting, languageElement);
}
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.java
index cfb3ef77651..e99f73b4aa8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.java
@@ -23,48 +23,47 @@ import org.w3c.dom.Text;
public class XMLUtils {
- private XMLUtils() {}
-
-
- public static List<Element> extractChildElements(Element node, String childElementName) throws SettingsImportExportException {
+ private XMLUtils() {
+ }
+
+ public static List<Element> extractChildElements(Element node, String childElementName)
+ throws SettingsImportExportException {
List<Element> extracted = new ArrayList<Element>();
-
+
NodeList children = node.getChildNodes();
- for(int i = 0; i < children.getLength(); i++) {
+ for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
- switch(child.getNodeType()) {
+ switch (child.getNodeType()) {
case Node.ELEMENT_NODE:
- Element element = (Element)child;
- if(element.getTagName().equals(childElementName)) {
+ Element element = (Element) child;
+ if (element.getTagName().equals(childElementName)) {
extracted.add(element);
- }
- else
+ } else
throw new SettingsImportExportException("Unknown tag: " + element.getTagName()); //$NON-NLS-1$
break;
case Node.TEXT_NODE:
- Text text = (Text)child;
- if(isWhitespace(text.getData()))
+ Text text = (Text) child;
+ if (isWhitespace(text.getData()))
break;
throw new SettingsImportExportException("Unknown text: '" + text.getData() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
default:
throw new SettingsImportExportException("Unknown node: " + child.getNodeName()); //$NON-NLS-1$
}
}
-
+
return extracted;
}
-
-
+
public static boolean isWhitespace(String s) {
- if(s == null)
+ if (s == null)
return false;
-
- for(char c : s.toCharArray()) {
- if(!Character.isWhitespace(c)) {
+
+ for (char c : s.toCharArray()) {
+ if (!Character.isWhitespace(c)) {
return false;
}
}
-
+
return true;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java
index 36d4ef5c9ab..e1751999032 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java
@@ -30,9 +30,9 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* Common API of dynamic contribution of items to manipulate configurations of a working set.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
abstract class AbstractWorkingSetConfigsContribution extends CompoundContributionItem {
@@ -58,7 +58,7 @@ abstract class AbstractWorkingSetConfigsContribution extends CompoundContributio
/**
* Initializes me with my working set.
- *
+ *
* @param workingSet
* my working set
*/
@@ -91,19 +91,19 @@ abstract class AbstractWorkingSetConfigsContribution extends CompoundContributio
/**
* Creates a contribution item for a specific configuration of my working set.
- *
+ *
* @param config
* a configuration of my working set
* @param index
* the index of the contribution in the composite
- *
+ *
* @return the contribution
*/
protected abstract IContributionItem createContribution(IWorkingSetConfiguration config, int index);
/**
* Obtains my working set. It may be lazily determined from the current workbench selection.
- *
+ *
* @return my working set
*/
protected IWorkingSetProxy getWorkingSet() {
@@ -115,8 +115,8 @@ abstract class AbstractWorkingSetConfigsContribution extends CompoundContributio
if (!ssel.isEmpty()) {
Object first = ssel.getFirstElement();
if (first instanceof IWorkingSet) {
- workingSet = WorkingSetConfigurationManager.getDefault().getWorkingSet(
- ((IWorkingSet) first).getName());
+ workingSet = WorkingSetConfigurationManager.getDefault()
+ .getWorkingSet(((IWorkingSet) first).getName());
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContribution.java
index 7cc7df56a05..1975216c12a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContribution.java
@@ -29,9 +29,9 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* A dynamic contribution of sub-menus for working set configuration actions, with further sub-menus showing
* the configurations to choose from.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
abstract class AbstractWorkingSetsContribution extends CompoundContributionItem {
@@ -47,7 +47,7 @@ abstract class AbstractWorkingSetsContribution extends CompoundContributionItem
/**
* Initializes me with my identifier.
- *
+ *
* @param id
* my identifier
*/
@@ -62,8 +62,7 @@ abstract class AbstractWorkingSetsContribution extends CompoundContributionItem
int i = 0;
for (IWorkingSet recent : getWorkingsetManager().getRecentWorkingSets()) {
- IWorkingSetProxy proxy = WorkingSetConfigurationManager.getDefault().getWorkingSet(
- recent.getName());
+ IWorkingSetProxy proxy = WorkingSetConfigurationManager.getDefault().getWorkingSet(recent.getName());
if (proxy != null) {
IContributionItem item = createMenu(proxy, i++);
@@ -102,7 +101,7 @@ abstract class AbstractWorkingSetsContribution extends CompoundContributionItem
/**
* Creates a contribution item for a working set.
- *
+ *
* @param workingSet
* a working set
* @return the contribution
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfigsContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfigsContribution.java
index dd1b73ad52a..93f8d8f2e95 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfigsContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfigsContribution.java
@@ -21,9 +21,9 @@ import org.eclipse.osgi.util.NLS;
/**
* A dynamic contribution of items to activate configurations of a working set.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public class ActivateWorkingSetConfigsContribution extends AbstractWorkingSetConfigsContribution {
@@ -38,7 +38,7 @@ public class ActivateWorkingSetConfigsContribution extends AbstractWorkingSetCon
/**
* Initializes me with my working set.
- *
+ *
* @param workingSet
* my working set
*/
@@ -59,8 +59,7 @@ public class ActivateWorkingSetConfigsContribution extends AbstractWorkingSetCon
private IWorkingSetConfiguration workingSetConfig;
ActivateConfigAction(IWorkingSetConfiguration workingSetConfig, int ordinal) {
- super(NLS.bind(WorkingSetMessages.WorkingSetMenus_enumPattern, ordinal, workingSetConfig
- .getName()));
+ super(NLS.bind(WorkingSetMessages.WorkingSetMenus_enumPattern, ordinal, workingSetConfig.getName()));
this.workingSetConfig = workingSetConfig;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContribution.java
index a48f98fcfcf..488eeca000c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContribution.java
@@ -19,9 +19,9 @@ import org.eclipse.jface.action.IContributionItem;
/**
* A dynamic contribution of sub-menus to activate working sets, with further sub-menus showing the
* configurations to choose from.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public class ActivateWorkingSetsContribution extends AbstractWorkingSetsContribution {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildJob.java
index 14df359a1b2..f44a45340c6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildJob.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildJob.java
@@ -40,23 +40,23 @@ public final class BuildJob extends Job {
/**
* Initializes me with a bunch projects to build in their active configurations.
- *
+ *
* @param projects
* the projects to build
*/
public BuildJob(Collection<IProject> projects) {
- super(Messages.WorkingSetConfigAction_21);
+ super(Messages.WorkingSetConfigAction_21);
this.projects = new java.util.ArrayList<IProject>(projects);
}
/**
* Initializes me with a working set configuration to build.
- *
+ *
* @param workingSetConfig
* the working set configuration to build
*/
public BuildJob(IWorkingSetConfiguration workingSetConfig) {
- super(Messages.WorkingSetConfigAction_21);
+ super(Messages.WorkingSetConfigAction_21);
this.workingSetConfig = workingSetConfig;
}
@@ -73,12 +73,11 @@ public final class BuildJob extends Job {
try {
for (IProject p : projects) {
try {
- setName(Messages.WorkingSetConfigAction_21 + p.getName());
+ setName(Messages.WorkingSetConfigAction_21 + p.getName());
p.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
} catch (CoreException e) {
return new MultiStatus(CUIPlugin.PLUGIN_ID, 0, new IStatus[] { e.getStatus() },
- Messages.WorkingSetConfigAction_22,
- null);
+ Messages.WorkingSetConfigAction_22, null);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsContribution.java
index 679b3d89aa5..f8e89806cee 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsContribution.java
@@ -21,9 +21,9 @@ import org.eclipse.osgi.util.NLS;
/**
* A dynamic contribution of items to build configurations of a working set.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public class BuildWorkingSetConfigsContribution extends AbstractWorkingSetConfigsContribution {
@@ -38,7 +38,7 @@ public class BuildWorkingSetConfigsContribution extends AbstractWorkingSetConfig
/**
* Initializes me with my working set.
- *
+ *
* @param workingSet
* my working set
*/
@@ -59,8 +59,7 @@ public class BuildWorkingSetConfigsContribution extends AbstractWorkingSetConfig
private IWorkingSetConfiguration workingSetConfig;
BuildConfigAction(IWorkingSetConfiguration workingSetConfig, int ordinal) {
- super(NLS.bind(WorkingSetMessages.WorkingSetMenus_enumPattern, ordinal, workingSetConfig
- .getName()));
+ super(NLS.bind(WorkingSetMessages.WorkingSetMenus_enumPattern, ordinal, workingSetConfig.getName()));
this.workingSetConfig = workingSetConfig;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribution.java
index 5876d8a25f9..e2f45a9f291 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribution.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribution.java
@@ -19,9 +19,9 @@ import org.eclipse.jface.action.IContributionItem;
/**
* A dynamic contribution of sub-menus to build working sets, with further sub-menus showing the
* configurations to choose from.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public class BuildWorkingSetsContribution extends AbstractWorkingSetsContribution {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.java
index 76c0bc008d1..e36e8f75327 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.java
@@ -63,17 +63,17 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
/**
- * The C element working set page allows the user to create
+ * The C element working set page allows the user to create
* and edit a C element working set.
* <p>
* Working set elements are presented as a C element tree.
* </p>
- *
+ *
*/
public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPage {
- final private static String PAGE_TITLE= WorkingSetMessages.CElementWorkingSetPage_title;
- final private static String PAGE_ID= "CElementWorkingSetPage"; //$NON-NLS-1$
+ final private static String PAGE_TITLE = WorkingSetMessages.CElementWorkingSetPage_title;
+ final private static String PAGE_ID = "CElementWorkingSetPage"; //$NON-NLS-1$
private final static int SIZING_SELECTION_WIDGET_WIDTH = 50;
private final static int SIZING_SELECTION_WIDGET_HEIGHT = 200;
@@ -81,7 +81,7 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
private Text fWorkingSetName;
private CheckboxTreeViewer fTree;
private IWorkingSet fWorkingSet;
- private boolean fFirstCheck; // set to true if selection is set in setSelection
+ private boolean fFirstCheck; // set to true if selection is set in setSelection
private ITreeContentProvider fTreeContentProvider;
/**
@@ -89,8 +89,8 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
*/
public CElementWorkingSetPage() {
super(PAGE_ID, PAGE_TITLE, CPluginImages.DESC_WIZABAN_C_APP);
- setDescription(WorkingSetMessages.CElementWorkingSetPage_description);
- fFirstCheck= true;
+ setDescription(WorkingSetMessages.CElementWorkingSetPage_description);
+ fFirstCheck = true;
}
/*
@@ -100,30 +100,29 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
public void createControl(Composite parent) {
initializeDialogUnits(parent);
- Composite composite= new Composite(parent, SWT.NULL);
+ Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
setControl(composite);
Label label = new Label(composite, SWT.WRAP);
- label.setText(WorkingSetMessages.CElementWorkingSetPage_name);
- GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+ label.setText(WorkingSetMessages.CElementWorkingSetPage_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(
- new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- validateInput();
- }
+ fWorkingSetName.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validateInput();
}
- );
+ });
fWorkingSetName.setFocus();
-
+
label = new Label(composite, SWT.WRAP);
- label.setText(WorkingSetMessages.CElementWorkingSetPage_content);
+ label.setText(WorkingSetMessages.CElementWorkingSetPage_content);
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
label.setLayoutData(gd);
@@ -133,15 +132,13 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
gd.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
fTree.getControl().setLayoutData(gd);
- fTreeContentProvider= new CElementWorkingSetPageContentProvider();
+ fTreeContentProvider = new CElementWorkingSetPageContentProvider();
fTree.setContentProvider(fTreeContentProvider);
- AppearanceAwareLabelProvider cElementLabelProvider=
- new AppearanceAwareLabelProvider(
+ AppearanceAwareLabelProvider cElementLabelProvider = new AppearanceAwareLabelProvider(
AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
- AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS
- );
-
+ AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS);
+
fTree.setLabelProvider(new DecoratingCLabelProvider(cElementLabelProvider));
fTree.setSorter(new CElementSorter());
fTree.setUseHashlookup(true);
@@ -159,6 +156,7 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
@Override
public void treeCollapsed(TreeExpansionEvent event) {
}
+
@Override
public void treeExpanded(TreeExpansionEvent event) {
final Object element = event.getElement();
@@ -179,8 +177,8 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
validateInput();
Dialog.applyDialogFont(composite);
- // TODO Set help for the page
-// CUIHelp.setHelp(fTree, ICHelpContextIds.C_WORKING_SET_PAGE);
+ // TODO Set help for the page
+ // CUIHelp.setHelp(fTree, ICHelpContextIds.C_WORKING_SET_PAGE);
}
/*
@@ -188,25 +186,26 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
*/
@Override
public void finish() {
- String workingSetName= fWorkingSetName.getText();
- ArrayList<Object> elements= new ArrayList<Object>(10);
+ String workingSetName = fWorkingSetName.getText();
+ ArrayList<Object> elements = new ArrayList<Object>(10);
findCheckedElements(elements, fTree.getInput());
if (fWorkingSet == null) {
- IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager();
- fWorkingSet= workingSetManager.createWorkingSet(workingSetName, elements.toArray(new IAdaptable[elements.size()]));
+ IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ fWorkingSet = workingSetManager.createWorkingSet(workingSetName,
+ elements.toArray(new IAdaptable[elements.size()]));
} else {
// Add inaccessible resources
- IAdaptable[] oldItems= fWorkingSet.getElements();
- HashSet<IProject> closedWithChildren= new HashSet<IProject>(elements.size());
+ IAdaptable[] oldItems = fWorkingSet.getElements();
+ HashSet<IProject> closedWithChildren = new HashSet<IProject>(elements.size());
for (IAdaptable oldItem : oldItems) {
- IResource oldResource= null;
+ IResource oldResource = null;
if (oldItem instanceof IResource) {
- oldResource= (IResource)oldItem;
+ oldResource = (IResource) oldItem;
} else {
- oldResource= oldItem.getAdapter(IResource.class);
+ oldResource = oldItem.getAdapter(IResource.class);
}
if (oldResource != null && oldResource.isAccessible() == false) {
- IProject project= oldResource.getProject();
+ IProject project = oldResource.getProject();
if (closedWithChildren.contains(project) || elements.contains(project)) {
elements.add(oldItem);
elements.remove(project);
@@ -217,7 +216,7 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
fWorkingSet.setName(workingSetName);
fWorkingSet.setElements(elements.toArray(new IAdaptable[elements.size()]));
}
- }
+ }
/*
* @see org.eclipse.ui.dialogs.IWorkingSetPage#getSelection()
@@ -229,16 +228,16 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
/**
* Called when the checked state of a tree item changes.
- *
+ *
* @param event the checked state change event.
*/
void handleCheckStateChange(final CheckStateChangedEvent event) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
@Override
public void run() {
- IAdaptable element= (IAdaptable) event.getElement();
+ IAdaptable element = (IAdaptable) event.getElement();
boolean state = event.getChecked();
-
+
fTree.setGrayed(element, false);
if (isExpandable(element)) {
setSubtreeChecked(element, state, true);
@@ -248,10 +247,9 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
}
});
}
-
+
private boolean isExpandable(Object element) {
- return (element instanceof ICProject || element instanceof ICContainer
- || element instanceof CElementGrouping
+ return (element instanceof ICProject || element instanceof ICContainer || element instanceof CElementGrouping
|| element instanceof ICModel || element instanceof IContainer);
}
@@ -259,37 +257,37 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
if (child == null)
return;
if (child instanceof IAdaptable) {
- IResource resource= ((IAdaptable)child).getAdapter(IResource.class);
+ IResource resource = ((IAdaptable) child).getAdapter(IResource.class);
if (resource != null && !resource.isAccessible())
return;
}
- Object parent= fTreeContentProvider.getParent(child);
+ Object parent = fTreeContentProvider.getParent(child);
if (parent == null)
return;
-
+
updateObjectState(parent, baseChildState);
}
- private void updateObjectState(Object element, boolean baseChildState) {
+ private void updateObjectState(Object element, boolean baseChildState) {
- boolean allSameState= true;
- Object[] children= fTreeContentProvider.getChildren(element);
+ boolean allSameState = true;
+ Object[] children = fTreeContentProvider.getChildren(element);
- for (int i= children.length -1; i >= 0; i--) {
+ for (int i = children.length - 1; i >= 0; i--) {
if (fTree.getChecked(children[i]) != baseChildState || fTree.getGrayed(children[i])) {
- allSameState= false;
+ allSameState = false;
break;
}
}
-
+
fTree.setGrayed(element, !allSameState);
fTree.setChecked(element, !allSameState || baseChildState);
-
+
updateParentState(element, baseChildState);
}
/**
- * Sets the checked state of tree items based on the initial
+ * Sets the checked state of tree items based on the initial
* working set, if any.
*/
private void initializeCheckedState() {
@@ -299,49 +297,49 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
Object[] elements;
if (fWorkingSet == null) {
// Use current part's selection for initialization
- IWorkbenchPage page= CUIPlugin.getActivePage();
+ IWorkbenchPage page = CUIPlugin.getActivePage();
if (page == null)
return;
-
- IWorkbenchPart part= CUIPlugin.getActivePage().getActivePart();
+
+ IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
if (part == null)
return;
-
+
try {
- elements= SelectionConverter.getStructuredSelection(part).toArray();
- for (int i= 0; i < elements.length; i++) {
+ elements = SelectionConverter.getStructuredSelection(part).toArray();
+ for (int i = 0; i < elements.length; i++) {
if (elements[i] instanceof IResource) {
- ICElement ce= ((IResource)elements[i]).getAdapter(ICElement.class);
- if (ce != null && ce.exists() && ce.getCProject().isOnSourceRoot((IResource)elements[i]))
- elements[i]= ce;
+ ICElement ce = ((IResource) elements[i]).getAdapter(ICElement.class);
+ if (ce != null && ce.exists()
+ && ce.getCProject().isOnSourceRoot((IResource) elements[i]))
+ elements[i] = ce;
}
}
} catch (CModelException e) {
return;
}
- }
- else
- elements= fWorkingSet.getElements();
+ } else
+ elements = fWorkingSet.getElements();
for (int i = 0; i < elements.length; i++) {
Object element = elements[i];
if (element instanceof IResource) {
- IProject project= ((IResource)element).getProject();
+ IProject project = ((IResource) element).getProject();
if (!project.isAccessible()) {
- elements[i]= project;
+ elements[i] = project;
} else {
// for backwards compatibility: adapt to ICElement if possible
- if(CoreModel.hasCNature(project)) {
- ICElement cElement= CoreModel.getDefault().create((IResource)element);
+ if (CoreModel.hasCNature(project)) {
+ ICElement cElement = CoreModel.getDefault().create((IResource) element);
if (cElement != null) {
- elements[i]= cElement;
+ elements[i] = cElement;
}
}
}
} else if (element instanceof ICElement) {
- ICProject cProject= ((ICElement)element).getCProject();
- if (cProject != null && !cProject.getProject().isAccessible())
- elements[i]= cProject.getProject();
+ ICProject cProject = ((ICElement) element).getCProject();
+ if (cProject != null && !cProject.getProject().isAccessible())
+ elements[i] = cProject.getProject();
}
}
fTree.setCheckedElements(elements);
@@ -349,17 +347,17 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
for (Object element : elements) {
if (isExpandable(element))
setSubtreeChecked(element, true, true);
-
+
if (element instanceof IAdaptable) {
- IResource resource= ((IAdaptable)element).getAdapter(IResource.class);
+ IResource resource = ((IAdaptable) element).getAdapter(IResource.class);
if (resource != null && !resource.isAccessible())
continue;
}
- Object parent= fTreeContentProvider.getParent(element);
+ Object parent = fTreeContentProvider.getParent(element);
if (parent != null)
parents.add(parent);
}
-
+
for (Object object : parents)
updateObjectState(object, true);
}
@@ -381,31 +379,31 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
initializeCheckedState();
validateInput();
}
- }
+ }
+
/**
* Sets the checked state of the container's members.
- *
+ *
* @param parent the parent whose children should be checked/unchecked
- * @param state true=check all members in the container. false=uncheck all
+ * @param state true=check all members in the container. false=uncheck all
* members in the container.
- * @param checkExpandedState true=recurse into sub-containers and set the
+ * @param checkExpandedState true=recurse into sub-containers and set the
* checked state. false=only set checked state of members of this container
*/
private void setSubtreeChecked(Object parent, boolean state, boolean checkExpandedState) {
if (!(parent instanceof IAdaptable))
return;
- IContainer container= ((IAdaptable)parent).getAdapter(IContainer.class);
+ IContainer container = ((IAdaptable) parent).getAdapter(IContainer.class);
if ((!fTree.getExpandedState(parent) && checkExpandedState) || (container != null && !container.isAccessible()))
return;
-
- Object[] children= fTreeContentProvider.getChildren(parent);
- for (int i= children.length - 1; i >= 0; i--) {
- Object element= children[i];
+
+ Object[] children = fTreeContentProvider.getChildren(parent);
+ for (int i = children.length - 1; i >= 0; i--) {
+ Object element = children[i];
if (state) {
fTree.setChecked(element, true);
fTree.setGrayed(element, false);
- }
- else
+ } else
fTree.setGrayChecked(element, false);
if (isExpandable(element))
setSubtreeChecked(element, state, true);
@@ -413,7 +411,7 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
}
/**
- * Validates the working set name and the checked state of the
+ * Validates the working set name and the checked state of the
* resource tree.
*/
void validateInput() {
@@ -421,30 +419,30 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
String newText = fWorkingSetName.getText();
if (newText.equals(newText.trim()) == false) {
- errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_nameMustNotBeEmpty;
+ errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_nameMustNotBeEmpty;
}
if (newText.isEmpty()) {
if (fFirstCheck) {
setPageComplete(false);
- fFirstCheck= false;
+ fFirstCheck = false;
return;
}
- errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_nameMustNotBeEmpty;
+ errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_nameMustNotBeEmpty;
}
- fFirstCheck= false;
+ fFirstCheck = false;
if (errorMessage == null && (fWorkingSet == null || newText.equals(fWorkingSet.getName()) == false)) {
IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSets();
for (IWorkingSet workingSet : workingSets) {
if (newText.equals(workingSet.getName())) {
- errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_workingSetExists;
+ errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_workingSetExists;
}
}
}
-
+
if (errorMessage == null && fTree.getCheckedElements().length == 0) {
- String infoMessage = WorkingSetMessages.CElementWorkingSetPage_warning_resourceMustBeChecked;
+ String infoMessage = WorkingSetMessages.CElementWorkingSetPage_warning_resourceMustBeChecked;
setMessage(infoMessage, INFORMATION);
}
setErrorMessage(errorMessage);
@@ -453,12 +451,12 @@ public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPag
/**
* Collects all checked elements of the given parent.
- *
+ *
* @param checkedElements the output, list of checked elements
* @param parent the parent to collect checked elements in
*/
private void findCheckedElements(List<Object> checkedElements, Object parent) {
- Object[] children= fTreeContentProvider.getChildren(parent);
+ Object[] children = fTreeContentProvider.getChildren(parent);
for (Object element : children) {
if (fTree.getGrayed(element))
findCheckedElements(checkedElements, element);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageContentProvider.java
index aa1f9f16242..91d1473bf01 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageContentProvider.java
@@ -33,7 +33,7 @@ class CElementWorkingSetPageContentProvider extends BaseCElementContentProvider
@Override
public Object[] getChildren(Object element) {
if (element instanceof IWorkspaceRoot) {
- IWorkspaceRoot root = (IWorkspaceRoot)element;
+ IWorkspaceRoot root = (IWorkspaceRoot) element;
IProject[] projects = root.getProjects();
List<ICProject> list = new ArrayList<ICProject>(projects.length);
for (int i = 0; i < projects.length; i++) {
@@ -45,4 +45,4 @@ class CElementWorkingSetPageContentProvider extends BaseCElementContentProvider
}
return super.getChildren(element);
}
-}
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdater.java
index 25b4b728067..961b7c8c9ca 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdater.java
@@ -41,15 +41,16 @@ import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener;
-
public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementChangedListener {
private static class SingletonRule implements ISchedulingRule {
public static final ISchedulingRule INSTANCE = new SingletonRule();
+
@Override
public boolean contains(ISchedulingRule rule) {
return rule == this;
}
+
@Override
public boolean isConflicting(ISchedulingRule rule) {
return rule == this;
@@ -58,10 +59,12 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
private static class WorkingSetCheck extends Job {
private final IWorkingSet fWorkingSet;
+
WorkingSetCheck(final IWorkingSet workingSet) {
super("Check WorkingSet"); //$NON-NLS-1$
- fWorkingSet= workingSet;
+ fWorkingSet = workingSet;
}
+
/*
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@@ -74,48 +77,53 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
}
}
- public static final String ID= "org.eclipse.cdt.ui.CElementWorkingSetPage"; //$NON-NLS-1$
-
+ public static final String ID = "org.eclipse.cdt.ui.CElementWorkingSetPage"; //$NON-NLS-1$
+
private List<IWorkingSet> fWorkingSets;
-
+
private static class WorkingSetDelta {
private IWorkingSet fWorkingSet;
private List<Object> fElements;
private boolean fChanged;
+
public WorkingSetDelta(IWorkingSet workingSet) {
- fWorkingSet= workingSet;
+ fWorkingSet = workingSet;
synchronized (fWorkingSet) {
- fElements= new ArrayList<Object>(Arrays.asList(fWorkingSet.getElements()));
+ fElements = new ArrayList<Object>(Arrays.asList(fWorkingSet.getElements()));
}
}
+
public int indexOf(Object element) {
return fElements.indexOf(element);
}
+
public void set(int index, Object element) {
if (element == null) {
remove(index);
} else {
fElements.set(index, element);
- fChanged= true;
+ fChanged = true;
}
}
+
public void remove(int index) {
if (fElements.remove(index) != null) {
- fChanged= true;
+ fChanged = true;
}
}
+
public void process() {
if (fChanged) {
fWorkingSet.setElements(fElements.toArray(new IAdaptable[fElements.size()]));
}
}
}
-
+
public CElementWorkingSetUpdater() {
- fWorkingSets= new ArrayList<IWorkingSet>();
+ fWorkingSets = new ArrayList<IWorkingSet>();
CoreModel.getDefault().addElementChangedListener(this);
}
-
+
/**
* {@inheritDoc}
*/
@@ -123,7 +131,7 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
public void add(final IWorkingSet workingSet) {
// delay the check for existence - this may be called very early in the bootstrap
// otherwise it is causing all kinds of weird exceptions
- Job check= new WorkingSetCheck(workingSet);
+ Job check = new WorkingSetCheck(workingSet);
check.setUser(false);
check.setPriority(Job.SHORT);
// make jobs run sequential
@@ -135,7 +143,8 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
synchronized (fWorkingSets) {
fWorkingSets.add(workingSet);
}
- }});
+ }
+ });
}
/**
@@ -144,18 +153,18 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
@Override
public boolean remove(IWorkingSet workingSet) {
boolean result;
- synchronized(fWorkingSets) {
- result= fWorkingSets.remove(workingSet);
+ synchronized (fWorkingSets) {
+ result = fWorkingSets.remove(workingSet);
}
return result;
}
-
+
/**
* {@inheritDoc}
*/
@Override
public boolean contains(IWorkingSet workingSet) {
- synchronized(fWorkingSets) {
+ synchronized (fWorkingSets) {
return fWorkingSets.contains(workingSet);
}
}
@@ -165,7 +174,7 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
*/
@Override
public void dispose() {
- synchronized(fWorkingSets) {
+ synchronized (fWorkingSets) {
fWorkingSets.clear();
}
CoreModel.getDefault().removeElementChangedListener(this);
@@ -177,15 +186,15 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
@Override
public void elementChanged(ElementChangedEvent event) {
IWorkingSet[] workingSets;
- synchronized(fWorkingSets) {
- workingSets= fWorkingSets.toArray(new IWorkingSet[fWorkingSets.size()]);
+ synchronized (fWorkingSets) {
+ workingSets = fWorkingSets.toArray(new IWorkingSet[fWorkingSets.size()]);
}
- for (int w= 0; w < workingSets.length; w++) {
- WorkingSetDelta workingSetDelta= new WorkingSetDelta(workingSets[w]);
+ for (int w = 0; w < workingSets.length; w++) {
+ WorkingSetDelta workingSetDelta = new WorkingSetDelta(workingSets[w]);
processCElementDelta(workingSetDelta, event.getDelta());
- IResourceDelta[] resourceDeltas= event.getDelta().getResourceDeltas();
+ IResourceDelta[] resourceDeltas = event.getDelta().getResourceDeltas();
if (resourceDeltas != null) {
- for (int r= 0; r < resourceDeltas.length; r++) {
+ for (int r = 0; r < resourceDeltas.length; r++) {
processResourceDelta(workingSetDelta, resourceDeltas[r]);
}
}
@@ -194,24 +203,24 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
}
private void processCElementDelta(WorkingSetDelta result, ICElementDelta delta) {
- ICElement cElement= delta.getElement();
- int index= result.indexOf(cElement);
- int type= cElement.getElementType();
- int kind= delta.getKind();
- int flags= delta.getFlags();
+ ICElement cElement = delta.getElement();
+ int index = result.indexOf(cElement);
+ int type = cElement.getElementType();
+ int kind = delta.getKind();
+ int flags = delta.getFlags();
if (type == ICElement.C_PROJECT && kind == ICElementDelta.CHANGED) {
if (index != -1 && (flags & ICElementDelta.F_CLOSED) != 0) {
- result.set(index, ((ICProject)cElement).getProject());
+ result.set(index, ((ICProject) cElement).getProject());
} else if ((flags & ICElementDelta.F_OPENED) != 0) {
- index= result.indexOf(((ICProject)cElement).getProject());
+ index = result.indexOf(((ICProject) cElement).getProject());
if (index != -1)
result.set(index, cElement);
}
} else if (type == ICElement.C_PROJECT && kind == ICElementDelta.REMOVED) {
if (index != -1)
- result.set(index, ((ICProject)cElement).getProject());
+ result.set(index, ((ICProject) cElement).getProject());
} else if (type == ICElement.C_PROJECT && kind == ICElementDelta.ADDED) {
- index= result.indexOf(((ICProject)cElement).getProject());
+ index = result.indexOf(((ICProject) cElement).getProject());
if (index != -1)
result.set(index, cElement);
} else if (index != -1) {
@@ -223,24 +232,24 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
}
}
}
- IResourceDelta[] resourceDeltas= delta.getResourceDeltas();
+ IResourceDelta[] resourceDeltas = delta.getResourceDeltas();
if (resourceDeltas != null) {
- for (int i= 0; i < resourceDeltas.length; i++) {
+ for (int i = 0; i < resourceDeltas.length; i++) {
processResourceDelta(result, resourceDeltas[i]);
}
}
- ICElementDelta[] children= delta.getAffectedChildren();
- for (int i= 0; i < children.length; i++) {
+ ICElementDelta[] children = delta.getAffectedChildren();
+ for (int i = 0; i < children.length; i++) {
processCElementDelta(result, children[i]);
}
}
-
+
private void processResourceDelta(WorkingSetDelta result, IResourceDelta delta) {
- IResource resource= delta.getResource();
- int type= resource.getType();
- int index= result.indexOf(resource);
- int kind= delta.getKind();
- int flags= delta.getFlags();
+ IResource resource = delta.getResource();
+ int type = resource.getType();
+ int index = result.indexOf(resource);
+ int kind = delta.getKind();
+ int flags = delta.getFlags();
if (kind == IResourceDelta.CHANGED && type == IResource.PROJECT && index != -1) {
if ((flags & IResourceDelta.OPEN) != 0) {
result.set(index, resource);
@@ -248,64 +257,62 @@ public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementCh
}
if (index != -1 && kind == IResourceDelta.REMOVED) {
if ((flags & IResourceDelta.MOVED_TO) != 0) {
- result.set(index,
- ResourcesPlugin.getWorkspace().getRoot().findMember(delta.getMovedToPath()));
+ result.set(index, ResourcesPlugin.getWorkspace().getRoot().findMember(delta.getMovedToPath()));
} else {
result.remove(index);
}
}
-
+
// Don't dive into closed or opened projects
if (projectGotClosedOrOpened(resource, kind, flags))
return;
-
- IResourceDelta[] children= delta.getAffectedChildren();
- for (int i= 0; i < children.length; i++) {
+
+ IResourceDelta[] children = delta.getAffectedChildren();
+ for (int i = 0; i < children.length; i++) {
processResourceDelta(result, children[i]);
}
}
private boolean projectGotClosedOrOpened(IResource resource, int kind, int flags) {
- return resource.getType() == IResource.PROJECT
- && kind == IResourceDelta.CHANGED
- && (flags & IResourceDelta.OPEN) != 0;
+ return resource.getType() == IResource.PROJECT && kind == IResourceDelta.CHANGED
+ && (flags & IResourceDelta.OPEN) != 0;
}
-
+
private static void checkElementExistence(IWorkingSet workingSet) {
- List<IAdaptable> elements= new ArrayList<IAdaptable>(Arrays.asList(workingSet.getElements()));
- boolean changed= false;
- for (Iterator<IAdaptable> iter= elements.iterator(); iter.hasNext();) {
- IAdaptable element= iter.next();
- boolean remove= false;
+ List<IAdaptable> elements = new ArrayList<IAdaptable>(Arrays.asList(workingSet.getElements()));
+ boolean changed = false;
+ for (Iterator<IAdaptable> iter = elements.iterator(); iter.hasNext();) {
+ IAdaptable element = iter.next();
+ boolean remove = false;
if (element instanceof ICElement) {
- ICElement cElement= (ICElement)element;
+ ICElement cElement = (ICElement) element;
// If we have directly a project then remove it when it
// doesn't exist anymore. However if we have a sub element
// under a project only remove the element if the parent
// project is open. Otherwise we would remove all elements
// in closed projects.
if (cElement instanceof ICProject) {
- remove= !cElement.exists();
+ remove = !cElement.exists();
} else {
- IProject project= cElement.getCProject().getProject();
- remove= project.isOpen() && !cElement.exists();
+ IProject project = cElement.getCProject().getProject();
+ remove = project.isOpen() && !cElement.exists();
}
} else if (element instanceof IResource) {
- IResource resource= (IResource)element;
+ IResource resource = (IResource) element;
// See comments above
if (resource instanceof IProject) {
- remove= !resource.exists();
+ remove = !resource.exists();
} else {
- IProject project= resource.getProject();
- remove= (project != null ? project.isOpen() : true) && !resource.exists();
+ IProject project = resource.getProject();
+ remove = (project != null ? project.isOpen() : true) && !resource.exists();
}
} else if (element == null) {
// should not happen anyway, but who knows?
- remove= true;
+ remove = true;
}
if (remove) {
iter.remove();
- changed= true;
+ changed = true;
}
}
if (changed) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration.java
index 37cd5a753aa..ff3f699e2f6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration.java
@@ -45,40 +45,40 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
* working-set configuration that includes none of the projects that currently are members of the working set,
* is active.
* </p>
- *
+ *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public interface IWorkingSetConfiguration extends IWorkingSetConfigurationElement {
/**
* Obtains the working set element that contains me.
- *
+ *
* @return my working set
*/
IWorkingSetProxy getWorkingSet();
/**
* Queries my name.
- *
+ *
* @return my name
*/
String getName();
/**
* Obtains the project configuration element for the specified project.
- *
+ *
* @param projectName
* a project name
- *
+ *
* @return that project's configuration element
- *
+ *
* @throws IllegalArgumentException
* if the specified project is not a member of my working set
- *
+ *
* @see #getProjectConfigurations()
*/
IWorkingSetProjectConfiguration getProjectConfiguration(String projectName);
@@ -87,7 +87,7 @@ public interface IWorkingSetConfiguration extends IWorkingSetConfigurationElemen
* Obtains the configuration elements for all of the projects in my working set. These include any
* projects that were not in my working set when I was last updated, and does not include any projects
* that were in my working set when I was last updated but that no longer are.
- *
+ *
* @return my project configuration elements
*/
Collection<IWorkingSetProjectConfiguration> getProjectConfigurations();
@@ -96,9 +96,9 @@ public interface IWorkingSetConfiguration extends IWorkingSetConfigurationElemen
* Queries whether I am currently active in the workspace. I am active if and only if for every the
* projects in my working set, its active configuration is the one that I specify for it. As a special
* case, the configurations of an empty working set can never be active.
- *
+ *
* @return whether I am currently active in the workspace
- *
+ *
* @see #activate()
*/
boolean isActive();
@@ -106,14 +106,14 @@ public interface IWorkingSetConfiguration extends IWorkingSetConfigurationElemen
/**
* Updates the workspace to set, for each project in my working set, the active configuration that I
* specify for it. This method has no effect if I am already active.
- *
+ *
* @see #isActive()
*/
void activate();
/**
* Builds my project configurations in the workspace.
- *
+ *
* @param monitor
* for reporting progress of the working-set build
* @return the aggregate status of the individual
@@ -124,13 +124,13 @@ public interface IWorkingSetConfiguration extends IWorkingSetConfigurationElemen
/**
* Creates a <i>snapshot</i> (also known as a "working copy") of myself, providing a mutable view suitable
* for editing.
- *
+ *
* @param workingSet
* my parent working set snapshot
* @param workspace
* a workspace snapshot that captures the baseline state of the workspace and the working set
* configurations that are to be edited
- *
+ *
* @return a working-copy snapshot of myself
*/
ISnapshot createSnapshot(IWorkingSetProxy.ISnapshot workingSet, WorkspaceSnapshot workspace);
@@ -142,12 +142,12 @@ public interface IWorkingSetConfiguration extends IWorkingSetConfigurationElemen
/**
* The snapshot ("working copy") view of a working set configuration. It defines additional API for the
* manipulation of working set configurations.
- *
+ *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
interface ISnapshot extends IWorkingSetConfiguration, IWorkingSetConfigurationElement.ISnapshot {
@@ -165,17 +165,17 @@ public interface IWorkingSetConfiguration extends IWorkingSetConfigurationElemen
* A working set only ever has at most one read-only configuration, though it may have multiple active
* configurations if some of its configurations are equivalent.
* </p>
- *
+ *
* @return whether I am the read-only active configuration of my working set
*/
boolean isReadOnly();
/**
* Sets my name, which must be unique amongst the configurations in my working set.
- *
+ *
* @param name
* my new, unique name
- *
+ *
* @throws IllegalArgumentException
* if the new name is <code>null</code> or empty, or if it is already used by another
* configuration of the same working set
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfigurationElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfigurationElement.java
index 7a275f59989..64193d95d08 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfigurationElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfigurationElement.java
@@ -20,16 +20,16 @@ import org.eclipse.ui.IPersistable;
/**
* The protocol for elements of the working-set configuration model, which can be persisted via
* {@linkplain IMemento mementos}.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
public interface IWorkingSetConfigurationElement extends IPersistable {
/**
* Loads me from the specified memento.
- *
+ *
* @param memento
* a memento in which I am persisted
*/
@@ -41,18 +41,18 @@ public interface IWorkingSetConfigurationElement extends IPersistable {
/**
* The protocol for mutable working-copies ("snapshots") of working set configuration model elements.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
* @see WorkspaceSnapshot
*/
interface ISnapshot {
/**
* Obtains the workspace snapshot that describes the baseline state of the working-set configuration
* editing session of which I am a part.
- *
+ *
* @return my base workspace snapshot
*/
WorkspaceSnapshot getWorkspaceSnapshot();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfiguration.java
index 9a29bf3a233..57fa6fc7826 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfiguration.java
@@ -34,29 +34,29 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
* Note that project configurations are owned by working set configurations. Thus, different configurations of
* the same (or different) working set may specify different settings for the same project.
* </p>
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public interface IWorkingSetProjectConfiguration extends IWorkingSetConfigurationElement {
/**
* Obtains the working set configuration element that owns me.
- *
+ *
* @return my working set configuration
*/
IWorkingSetConfiguration getWorkingSetConfiguration();
/**
* Queries the name of the project that I configure.
- *
+ *
* @return my project name
*/
String getProjectName();
/**
* Resolves my project name to the actual project resource in the workspace.
- *
+ *
* @return my referenced project, or <code>null</code> if the project is not
* {@linkplain IResource#isAccessible() accessible} in the workspace
*/
@@ -64,7 +64,7 @@ public interface IWorkingSetProjectConfiguration extends IWorkingSetConfiguratio
/**
* Queries the ID of the build configuration that is currently selected for my project.
- *
+ *
* @return my selected build configuration ID
*/
String getSelectedConfigurationID();
@@ -79,9 +79,9 @@ public interface IWorkingSetProjectConfiguration extends IWorkingSetConfiguratio
* of a working-copy {@linkplain IWorkingSetProjectConfiguration.ISnapshot snapshot} of me, the result
* will always be the same object.
* </p>
- *
+ *
* @return the C model representation of my selected build configuration
- *
+ *
* @see #resolveConfigurations()
*/
ICConfigurationDescription resolveSelectedConfiguration();
@@ -96,18 +96,18 @@ public interface IWorkingSetProjectConfiguration extends IWorkingSetConfiguratio
* case of a working-copy {@linkplain IWorkingSetProjectConfiguration.ISnapshot snapshot} of me, the
* results will always be the same objects.
* </p>
- *
+ *
* @return the C model representation of my selected available build configurations
- *
+ *
* @see #resolveSelectedConfiguration()
*/
Collection<ICConfigurationDescription> resolveConfigurations();
/**
* Queries whether my project currently has my selected configuration active in the workspace.
- *
+ *
* @return whether I am my project's active configuration
- *
+ *
* @see #getSelectedConfigurationID()
* @see #activate()
*/
@@ -115,7 +115,7 @@ public interface IWorkingSetProjectConfiguration extends IWorkingSetConfiguratio
/**
* Activates my selected configuration in the workspace, for my project.
- *
+ *
* @see #getSelectedConfigurationID()
* @see ISnapshot#setSelectedConfigurationID(String)
* @see #isActive()
@@ -127,7 +127,7 @@ public interface IWorkingSetProjectConfiguration extends IWorkingSetConfiguratio
* actually requires activating it, and it was not already active, then it would be a good idea to return
* a warning status indicating that the active configuration had to be changed in order to effect the
* build.
- *
+ *
* @param monitor
* a progress monitor to report build progress
* @return a status indicating any error or warning conditions in the invocation of the build
@@ -137,13 +137,13 @@ public interface IWorkingSetProjectConfiguration extends IWorkingSetConfiguratio
/**
* Creates a <i>snapshot</i> (also known as a "working copy") of myself, providing a mutable view suitable
* for editing.
- *
+ *
* @param workingSetConfig
* my parent working set configuration snapshot
* @param workspace
* a workspace snapshot that captures the baseline state of the workspace and the working set
* configurations that are to be edited
- *
+ *
* @return a working-copy snapshot of myself
*/
ISnapshot createSnapshot(IWorkingSetConfiguration.ISnapshot workingSetConfig, WorkspaceSnapshot workspace);
@@ -154,9 +154,9 @@ public interface IWorkingSetProjectConfiguration extends IWorkingSetConfiguratio
/**
* The snapshot ("working copy") view of a working set project configuration.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
interface ISnapshot extends IWorkingSetProjectConfiguration, IWorkingSetConfigurationElement.ISnapshot {
@@ -165,7 +165,7 @@ public interface IWorkingSetProjectConfiguration extends IWorkingSetConfiguratio
/**
* Sets the ID of the build configuration that is currently selected for my project.
- *
+ *
* @param id
* my selected build configuration ID
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationController.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationController.java
index b0e0baea507..4c57ae40068 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationController.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationController.java
@@ -26,16 +26,16 @@ import org.eclipse.jface.viewers.Viewer;
* Protocol for the view controller for the project configurations pane of the working set configurations
* dialog. It takes care of coordinating the user gestures in that pane with the working-set configuration
* model and vice-versa.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
public interface IWorkingSetProjectConfigurationController {
/**
* Queries the project configuration in the Working Set Configurations pane that I control.
- *
+ *
* @return the new working set configuration selection. May be <code>null</code> if there is no selection
*/
IWorkingSetProjectConfiguration.ISnapshot getProjectConfiguration();
@@ -45,7 +45,7 @@ public interface IWorkingSetProjectConfigurationController {
* {@linkplain #getProjectConfiguration() project configuration} has changed its check-state. The
* controller context can be used to pass back reactions such as to veto the check-state change or to
* signal that some level of UI refresh is required.
- *
+ *
* @param element
* an element that has been checked or unchecked
* @param checked
@@ -58,7 +58,7 @@ public interface IWorkingSetProjectConfigurationController {
/**
* Computes the initial check-box settings for my tree according to the current state of my
* {@linkplain #getProjectConfiguration() project configuration}.
- *
+ *
* @param context
* context in which I can set initial check-states of my elements
*/
@@ -68,7 +68,7 @@ public interface IWorkingSetProjectConfigurationController {
* Obtains a content provider for the structure rooted at my {@linkplain #getProjectConfiguration()
* project configuration}. Note that this method will only be called once, and that the caller takes
* responsibility for {@linkplain IContentProvider#dispose() disposing} the content provider.
- *
+ *
* @return my content provider
*/
ITreeContentProvider getContentProvider();
@@ -83,10 +83,10 @@ public interface IWorkingSetProjectConfigurationController {
* The viewer argument is useful to obtain information about default font and colors, for label providers
* that implement the optional {@link IFontProvider} and/or {@link IColorProvider} interfaces.
* </p>
- *
+ *
* @param viewer
* the viewer for which I will provide labels
- *
+ *
* @return my label provider
*/
ILabelProvider getLabelProvider(Viewer viewer);
@@ -98,21 +98,21 @@ public interface IWorkingSetProjectConfigurationController {
/**
* An interface provided by the Manage Working Set Configurations dialog infrastructure to
* {@link IWorkingSetProjectConfigurationController}s for communication of state changes back to the UI.
- *
+ *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
- *
+ *
* @author Christian W. Damus (damus)
- *
+ *
* @since 6.0
*/
interface IControllerContext {
/**
* Queries whether the current working set configuration context is a read-only one. In such cases, I
* should probably disallow check-state changes and other editing.
- *
+ *
* @return whether the current working set configuration is read-only
- *
+ *
* @see IWorkingSetConfiguration.ISnapshot#isReadOnly()
*/
boolean isReadOnly();
@@ -124,12 +124,12 @@ public interface IWorkingSetProjectConfigurationController {
* check state} of a controller and for
* {@linkplain IWorkingSetProjectConfigurationController#checkStateChanged(Object, boolean, IControllerContext)
* vetoing check state changes}.
- *
+ *
* @param element
* the element to update checked
* @param checked
* whether the element should be checked
- *
+ *
* @see IWorkingSetProjectConfigurationController#checkStateChanged(Object, boolean,
* IControllerContext)
* @see IWorkingSetProjectConfigurationController#updateCheckState(IControllerContext)
@@ -144,12 +144,12 @@ public interface IWorkingSetProjectConfigurationController {
* check state} of a controller and for
* {@linkplain IWorkingSetProjectConfigurationController#checkStateChanged(Object, boolean, IControllerContext)
* responding to check state changes}.
- *
+ *
* @param element
* the element to update checked
* @param checked
* whether the element should be checked
- *
+ *
* @see IWorkingSetProjectConfigurationController#checkStateChanged(Object, boolean,
* IControllerContext)
* @see IWorkingSetProjectConfigurationController#updateCheckState(IControllerContext)
@@ -161,7 +161,7 @@ public interface IWorkingSetProjectConfigurationController {
* Requests an update of the visual appearance of the specified element. The element may be any
* element under my control, or even the {@link IWorkingSetConfiguration} or {@link IWorkingSetProxy}
* that owns my project configuration.
- *
+ *
* @param element
* an element to update
*/
@@ -170,7 +170,7 @@ public interface IWorkingSetProjectConfigurationController {
/**
* Notifies that the specified project configuration's activation state has changed. That is, that it
* is now activated when previously it was not, or vice-versa.
- *
+ *
* @param project
* configuration the project configuration that changed
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationFactory.java
index bfbdddd9dd9..0041505bae4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationFactory.java
@@ -42,42 +42,41 @@ import org.eclipse.cdt.internal.ui.workingsets.WorkspaceSnapshot.ProjectState;
/**
* Protocol for a factory of {@link IWorkingSetProjectConfiguration}s. Factories are {@linkplain Registry
* registered} against project natures.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public interface IWorkingSetProjectConfigurationFactory {
/**
* Queries my factory ID. The ID is persisted in the working set configuration data so that the same
* factory can be used to reconstruct project configurations when loading the working set configurations.
- *
+ *
* @return my unique identifier
*/
String getID();
/**
* Creates a new project configuration element.
- *
+ *
* @param parent
* the working set configuration that owns the new project configuration
* @param project
* the workspace project for which to create the configuration
- *
+ *
* @return the new project configuration
*/
- IWorkingSetProjectConfiguration createProjectConfiguration(IWorkingSetConfiguration parent,
- IProject project);
+ IWorkingSetProjectConfiguration createProjectConfiguration(IWorkingSetConfiguration parent, IProject project);
/**
* Creates a UI controller to support editing the specified project configuration snapshot, which should
* have been obtained from a configuration that I previously
* {@linkplain #createProjectConfiguration(org.eclipse.cdt.internal.ui.workingsets.IWorkingSetConfiguration, IProject)
* created}, myself.
- *
+ *
* @param config
* a project configuration snapshot that I created
- *
+ *
* @return a suitable controller for it. Must not be <code>null</code>
*/
IWorkingSetProjectConfigurationController createProjectConfigurationController(
@@ -86,12 +85,12 @@ public interface IWorkingSetProjectConfigurationFactory {
/**
* Creates a snapshot of the configuration state of a project in the workspace. This may capture
* additional build meta-data beyond just the "active configuration."
- *
+ *
* @param project
* a project to capture in a {@link WorkspaceSnapshot}
* @param desc
* the project description, from which to capture the initial configuration data
- *
+ *
* @return the project state capture. Must not be <code>null</code>
*/
WorkspaceSnapshot.ProjectState createProjectState(IProject project, ICProjectDescription desc);
@@ -103,9 +102,9 @@ public interface IWorkingSetProjectConfigurationFactory {
/**
* A registry of {@linkplain IWorkingSetProjectConfigurationFactory project configuration factories}
* contributed on the <tt>org.eclipse.cdt.ui.workingSetConfigurations</tt> extension point.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
class Registry {
@@ -158,8 +157,8 @@ public interface IWorkingSetProjectConfigurationFactory {
return result;
}
- private IWorkingSetProjectConfigurationFactory get(
- Map<?, IWorkingSetProjectConfigurationFactory> map, Object key) {
+ private IWorkingSetProjectConfigurationFactory get(Map<?, IWorkingSetProjectConfigurationFactory> map,
+ Object key) {
return map.get(key);
}
@@ -213,8 +212,8 @@ public interface IWorkingSetProjectConfigurationFactory {
// first pass to populate the map with immediate requireds
IWorkspace ws = ResourcesPlugin.getWorkspace();
for (IProjectNatureDescriptor next : ws.getNatureDescriptors()) {
- result.put(next.getNatureId(), new java.util.HashSet<String>(Arrays.asList(next
- .getRequiredNatureIds())));
+ result.put(next.getNatureId(),
+ new java.util.HashSet<String>(Arrays.asList(next.getRequiredNatureIds())));
}
// now, iterate to add transitive requireds
@@ -261,9 +260,8 @@ public interface IWorkingSetProjectConfigurationFactory {
if (natureID != null) {
factoriesByNature.put(natureID, desc);
} else {
- CUIPlugin.log(NLS.bind(
- WorkingSetMessages.WSProjConfigFactory_noNatureID, ext
- .getContributor().getName()), null);
+ CUIPlugin.log(NLS.bind(WorkingSetMessages.WSProjConfigFactory_noNatureID,
+ ext.getContributor().getName()), null);
}
}
}
@@ -292,8 +290,7 @@ public interface IWorkingSetProjectConfigurationFactory {
if (id == null) {
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, NLS.bind(
- WorkingSetMessages.WSProjConfigFactory_noFactoryID, extension.getContributor()
- .getName())));
+ WorkingSetMessages.WSProjConfigFactory_noFactoryID, extension.getContributor().getName())));
}
}
@@ -303,8 +300,8 @@ public interface IWorkingSetProjectConfigurationFactory {
}
@Override
- public IWorkingSetProjectConfiguration createProjectConfiguration(
- IWorkingSetConfiguration parent, IProject project) {
+ public IWorkingSetProjectConfiguration createProjectConfiguration(IWorkingSetConfiguration parent,
+ IProject project) {
return resolve().createProjectConfiguration(parent, project);
}
@@ -324,11 +321,10 @@ public interface IWorkingSetProjectConfigurationFactory {
IWorkingSetProjectConfigurationFactory result = null;
try {
- result = (IWorkingSetProjectConfigurationFactory) extension
- .createExecutableExtension(A_CLASS);
+ result = (IWorkingSetProjectConfigurationFactory) extension.createExecutableExtension(A_CLASS);
} catch (ClassCastException e) {
- CUIPlugin.log(NLS.bind(WorkingSetMessages.WSProjConfigFactory_badFactory, extension
- .getContributor().getName()), e);
+ CUIPlugin.log(NLS.bind(WorkingSetMessages.WSProjConfigFactory_badFactory,
+ extension.getContributor().getName()), e);
} catch (CoreException e) {
CUIPlugin.log(new MultiStatus(CUIPlugin.PLUGIN_ID, 0, new IStatus[] { e.getStatus() },
WorkingSetMessages.WSProjConfigFactory_factoryFailed, null));
@@ -358,9 +354,9 @@ public interface IWorkingSetProjectConfigurationFactory {
/**
* The default project configuration factory. Clients may extend this class to implement custom
* factories for their project natures.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public static class Default implements IWorkingSetProjectConfigurationFactory, IExecutableExtension {
@@ -372,16 +368,15 @@ public interface IWorkingSetProjectConfigurationFactory {
}
@Override
- public IWorkingSetProjectConfiguration createProjectConfiguration(
- IWorkingSetConfiguration parent, IProject project) {
+ public IWorkingSetProjectConfiguration createProjectConfiguration(IWorkingSetConfiguration parent,
+ IProject project) {
WorkingSetProjectConfiguration result = createProjectConfiguration(parent);
result.setProjectName(project.getName());
return result;
}
- protected WorkingSetProjectConfiguration createProjectConfiguration(
- IWorkingSetConfiguration parent) {
+ protected WorkingSetProjectConfiguration createProjectConfiguration(IWorkingSetConfiguration parent) {
return new WorkingSetProjectConfiguration(parent);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.java
index 5093a972211..ffbdd4a9ffa 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.java
@@ -24,27 +24,27 @@ import org.eclipse.ui.IWorkingSet;
* The protocol for elements representing working sets, providing proxies for the workbench's actual
* {@link IWorkingSet}s. A working set may have zero or more {@linkplain IWorkingSetConfiguration
* configurations} that aggregate configuration settings for the C/C++ projects in the working set.
- *
+ *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
/**
* Queries my name. This is the {@link IWorkingSet#getName() name} of my referenced working set, not its
* {@link IWorkingSet#getLabel() label}. As my referenced working set's name changes, so does my name.
- *
+ *
* @return my working set's name
*/
String getName();
/**
* Resolves me to the actual working set as maintained by the workbench.
- *
+ *
* @return my referenced working set, or <code>null</code> if it no longer exists
*/
IWorkingSet resolve();
@@ -52,7 +52,7 @@ public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
/**
* Resolves the actual existing projects in my working set, that are currently
* {@linkplain IResource#isAccessible() accessible} in the workspace.
- *
+ *
* @return my projects
*/
Collection<IProject> resolveProjects();
@@ -61,17 +61,17 @@ public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
* Queries whether I am a valid working set proxy, to be displayed to and manipulated by the user. This
* should at least check that the proxy {@linkplain #resolve() resolves} to an existing working set and
* that it includes at least one {@linkplain #resolveProjects() project}.
- *
+ *
* @return whether I am a valid working set proxy
*/
boolean isValid();
/**
* Obtains the named configuration of my working set.
- *
+ *
* @param name
* a configuration name
- *
+ *
* @return the matching configuration, or <code>null</code> if there is none such
*/
IWorkingSetConfiguration getConfiguration(String name);
@@ -82,7 +82,7 @@ public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
* {@linkplain IWorkingSetConfiguration.ISnapshot#isReadOnly() read-only} configuration indicating the
* active configurations of my projects, if none of my named configurations is
* {@linkplain IWorkingSetConfiguration#isActive() active}.
- *
+ *
* @return my configurations
*/
Collection<IWorkingSetConfiguration> getConfigurations();
@@ -90,11 +90,11 @@ public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
/**
* Creates a <i>snapshot</i> (also known as a "working copy") of myself, providing a mutable view suitable
* for editing.
- *
+ *
* @param workspace
* a workspace snapshot that captures the baseline state of the workspace and the working set
* configurations that are to be edited
- *
+ *
* @return a working-copy snapshot of myself
*/
ISnapshot createSnapshot(WorkspaceSnapshot workspace);
@@ -106,23 +106,23 @@ public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
/**
* The snapshot ("working copy") view of a working set proxy. It has additional API for modifying
* configurations, which can then be {@linkplain WorkspaceSnapshot#save() saved} for posterity.
- *
+ *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
interface ISnapshot extends IWorkingSetProxy, IWorkingSetConfigurationElement.ISnapshot {
/**
* Creates a new configuration with the specified name.
- *
+ *
* @param name
* a new configuration name
- *
+ *
* @return the new configuration
- *
+ *
* @throws IllegalArgumentException
* if the new name is <code>null</code> or empty, or if it is already used by another
* configuration of the same working set
@@ -131,10 +131,10 @@ public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
/**
* Removes the specified configuration from me.
- *
+ *
* @param config
* a configuration to remove
- *
+ *
* @throws IllegalArgumentException
* if the configuration to be removed is
* {@linkplain IWorkingSetConfiguration.ISnapshot#isReadOnly() read-only}
@@ -156,7 +156,7 @@ public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
* It is assumed that the UI will refresh the tree structure rooted in me when I signal a major
* change.
* </p>
- *
+ *
* @return whether this update results in a "major change" to my child configuration structure
*/
boolean updateActiveConfigurations();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController.java
index 7b336f16aa8..b6803dbf4ca 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController.java
@@ -35,11 +35,11 @@ import org.eclipse.swt.graphics.Image;
/**
* View controller for the project configurations pane of the working set configurations dialog. It takes care
* of coordinating the user gestures in that pane with the working-set configuration model and vice-versa.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
class ProjectConfigsController implements ICheckStateListener, DisposeListener {
private CheckboxTreeViewer tree;
@@ -61,7 +61,7 @@ class ProjectConfigsController implements ICheckStateListener, DisposeListener {
/**
* Assigns the tree viewer that I control.
- *
+ *
* @param tree
* my tree viewer
*/
@@ -87,7 +87,7 @@ class ProjectConfigsController implements ICheckStateListener, DisposeListener {
/**
* Injects the current selection of a working set from the Working Set Configurations pane. This changes
* the project configurations that I show in my own tree.
- *
+ *
* @param config
* the new working set configuration selection. May be <code>null</code> if there is no
* selection
@@ -115,7 +115,7 @@ class ProjectConfigsController implements ICheckStateListener, DisposeListener {
/**
* Queries the current working set configuration that I show in my tree.
- *
+ *
* @return the working set configuration, or <code>null</code> if none
*/
IWorkingSetConfiguration.ISnapshot getWorkingSetConfiguration() {
@@ -125,8 +125,7 @@ class ProjectConfigsController implements ICheckStateListener, DisposeListener {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
- IWorkingSetProjectConfigurationController controller = controllerContext
- .controllerForElement(element);
+ IWorkingSetProjectConfigurationController controller = controllerContext.controllerForElement(element);
if (controller != null) {
controller.checkStateChanged(element, event.getChecked(), controllerContext);
@@ -145,14 +144,13 @@ class ProjectConfigsController implements ICheckStateListener, DisposeListener {
/**
* Computes the initial check-box settings for my tree according to the current state of the specified
* working set configuration.
- *
+ *
* @param config
* a working set configuration that I am now showing
*/
private void updateCheckState(IWorkingSetConfiguration.ISnapshot config) {
for (IWorkingSetProjectConfiguration project : config.getProjectConfigurations()) {
- IWorkingSetProjectConfigurationController controller = controllerContext
- .controllerForElement(project);
+ IWorkingSetProjectConfigurationController controller = controllerContext.controllerForElement(project);
if (controller != null) {
controller.updateCheckState(controllerContext);
@@ -168,7 +166,7 @@ class ProjectConfigsController implements ICheckStateListener, DisposeListener {
/**
* Connects me to the controller of the working set configurations pane.
- *
+ *
* @param controller
* the working-set configs controller
*/
@@ -199,8 +197,7 @@ class ProjectConfigsController implements ICheckStateListener, DisposeListener {
contentProviders = new java.util.HashMap<IWorkingSetProjectConfigurationController, ITreeContentProvider>();
labelProviders = new java.util.HashMap<IWorkingSetProjectConfigurationController, ILabelProvider>();
- for (IWorkingSetProjectConfiguration next : getWorkingSetConfiguration()
- .getProjectConfigurations()) {
+ for (IWorkingSetProjectConfiguration next : getWorkingSetConfiguration().getProjectConfigurations()) {
IWorkingSetProjectConfiguration.ISnapshot project = (IWorkingSetProjectConfiguration.ISnapshot) next;
@@ -382,9 +379,9 @@ class ProjectConfigsController implements ICheckStateListener, DisposeListener {
/**
* A useful empty implementation of the extended label-provider protocol.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
private static class NullLabelProvider extends LabelProvider implements IFontProvider, IColorProvider {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationController.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationController.java
index 16bd8f6ba75..1ae59001336 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationController.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationController.java
@@ -37,11 +37,11 @@ import org.eclipse.cdt.internal.ui.workingsets.IWorkingSetProjectConfiguration.I
/**
* Default implementation of the working set project configuration controller protocol.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
public class ProjectConfigurationController implements IWorkingSetProjectConfigurationController {
@@ -49,7 +49,7 @@ public class ProjectConfigurationController implements IWorkingSetProjectConfigu
/**
* Initializes me with my project configuration.
- *
+ *
* @param config
* my project configuration
*/
@@ -163,8 +163,7 @@ public class ProjectConfigurationController implements IWorkingSetProjectConfigu
}
- private static class LabelProvider extends org.eclipse.jface.viewers.LabelProvider implements
- IFontProvider {
+ private static class LabelProvider extends org.eclipse.jface.viewers.LabelProvider implements IFontProvider {
private IWorkingSetProjectConfiguration.ISnapshot projectConfig;
private WorkbenchLabelProvider wbLabels = new WorkbenchLabelProvider();
@@ -183,9 +182,9 @@ public class ProjectConfigurationController implements IWorkingSetProjectConfigu
if (element instanceof ICConfigurationDescription) {
ICConfigurationDescription config = (ICConfigurationDescription) element;
- return isActiveInWorkspace(config) ? NLS.bind(
- WorkingSetMessages.ProjConfigController_activeConfig, config.getName()) : config
- .getName();
+ return isActiveInWorkspace(config)
+ ? NLS.bind(WorkingSetMessages.ProjConfigController_activeConfig, config.getName())
+ : config.getName();
} else if (element instanceof IWorkingSetProjectConfiguration) {
return wbLabels.getText(((IWorkingSetProjectConfiguration) element).resolveProject());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsController.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsController.java
index 4473be718de..c46c204cdd6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsController.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsController.java
@@ -44,11 +44,11 @@ import org.eclipse.cdt.ui.CUIPlugin;
* The view controller for the working set configurations pane in the dialog. It takes care of coordinating
* the user gestures in the pane with the working set configuration model, and vice-versa. It also implements
* the handling of the action buttons.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
class WorkingSetConfigsController implements SelectionListener, ISelectionChangedListener {
@@ -92,7 +92,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
/**
* Assigns the tree viewer that I control.
- *
+ *
* @param tree
* my tree viewer
*/
@@ -118,8 +118,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
ITreeContentProvider content = (ITreeContentProvider) tree.getContentProvider();
if ((initialWorkingSet != null)
- && Arrays.asList(content.getElements(tree.getInput())).contains(
- initialWorkingSet)) {
+ && Arrays.asList(content.getElements(tree.getInput())).contains(initialWorkingSet)) {
initialSelection = initialWorkingSet;
} else {
// we have a most-recently-used working set. Just
@@ -164,7 +163,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
/**
* Assigns me my "Add..." button.
- *
+ *
* @param addButton
* my add button
*/
@@ -174,7 +173,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
/**
* Assigns me my "Remove" button.
- *
+ *
* @param removeButton
* my remove button
*/
@@ -184,7 +183,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
/**
* Assigns me my "Rename..." button.
- *
+ *
* @param renameButton
* my rename button
*/
@@ -194,7 +193,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
/**
* Assigns me my "Activate" button.
- *
+ *
* @param activateButton
* my activate button
*/
@@ -204,7 +203,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
/**
* Assigns me my "Build" button.
- *
+ *
* @param buildButton
* my build button
*/
@@ -215,7 +214,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
/**
* Connects me to the controller for the project configurations pane, into which I inject the currently
* selected working set configuration.
- *
+ *
* @param controller
* my project configurations controller
*/
@@ -289,8 +288,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
*/
private void addConfig() {
InputDialog dlg = new InputDialog(tree.getTree().getShell(),
- WorkingSetMessages.WSConfigsController_addDlg_title,
- WorkingSetMessages.WSConfigsController_addDlg_msg,
+ WorkingSetMessages.WSConfigsController_addDlg_title, WorkingSetMessages.WSConfigsController_addDlg_msg,
WorkingSetMessages.WSConfigsController_addDlg_defaultName, new IInputValidator() {
@Override
@@ -306,8 +304,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
});
if (dlg.open() == IDialogConstants.OK_ID) {
- IWorkingSetConfiguration.ISnapshot newConfig = currentWorkingSet.createConfiguration(dlg
- .getValue());
+ IWorkingSetConfiguration.ISnapshot newConfig = currentWorkingSet.createConfiguration(dlg.getValue());
tree.refresh(currentWorkingSet);
tree.setSelection(new StructuredSelection(newConfig), true);
currentConfig = newConfig;
@@ -335,8 +332,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
private void renameConfig() {
InputDialog dlg = new InputDialog(tree.getTree().getShell(),
WorkingSetMessages.WSConfigsController_renameDlg_title,
- WorkingSetMessages.WSConfigsController_renameDlg_msg, currentConfig.getName(),
- new IInputValidator() {
+ WorkingSetMessages.WSConfigsController_renameDlg_msg, currentConfig.getName(), new IInputValidator() {
@Override
public String isValid(String newText) {
@@ -459,7 +455,7 @@ class WorkingSetConfigsController implements SelectionListener, ISelectionChange
* Notification that the selection of configuration(s) in some project in the current working set
* configuration has changed. I accordingly update the visuals of the working-set configuration to
* indicate whether it is active or not.
- *
+ *
* @param project
* the project configuration whose active configuration selections have changed
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.java
index 408671fb4be..5ded862e2f8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.java
@@ -34,13 +34,13 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* Default implementation of the {@link IWorkingSetConfiguration} interface.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
public class WorkingSetConfiguration implements IWorkingSetConfiguration {
private final IWorkingSetProxy workingSet;
@@ -50,7 +50,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Initializes me with my parent working set.
- *
+ *
* @param workingSet
* my parent working set
*/
@@ -60,7 +60,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Obtains my parent working set.
- *
+ *
* @return my parent
*/
@Override
@@ -70,7 +70,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Obtains my name.
- *
+ *
* @return my name
*/
@Override
@@ -80,10 +80,10 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Sets my name.
- *
+ *
* @param name
* my new name
- *
+ *
* @throws IllegalArgumentException
* if the specified name is <code>null</code> or empty, or if it is already used by another
* configuration in my warking set
@@ -104,7 +104,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Provides simple access to the name for setting it.
- *
+ *
* @param name
* my new name
*/
@@ -180,8 +180,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
@Override
public IStatus build(IProgressMonitor monitor) {
- MultiStatus result = new MultiStatus(CUIPlugin.PLUGIN_ID, 0,
- WorkingSetMessages.WSConfig_build_problems, null);
+ MultiStatus result = new MultiStatus(CUIPlugin.PLUGIN_ID, 0, WorkingSetMessages.WSConfig_build_problems, null);
List<IWorkingSetProjectConfiguration> toBuild = new java.util.ArrayList<IWorkingSetProjectConfiguration>(
getProjectConfigurations().size());
@@ -193,8 +192,8 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
}
}
- SubMonitor progress = SubMonitor.convert(monitor, NLS.bind(WorkingSetMessages.WSConfig_build_task,
- getWorkingSet().getName()), toBuild.size());
+ SubMonitor progress = SubMonitor.convert(monitor,
+ NLS.bind(WorkingSetMessages.WSConfig_build_task, getWorkingSet().getName()), toBuild.size());
try {
for (IWorkingSetProjectConfiguration next : toBuild) {
@@ -247,7 +246,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Creates a new project configuration for the specified project. May be overridden by subclasses to
* create a different implementation.
- *
+ *
* @param project
* a workspace project
* @return a new project configuration element for it
@@ -272,11 +271,11 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Utility method to query whether the specified configuration is a read-only snapshot.
- *
+ *
* @param config
* a working set configuration
* @return whether it is a read-only snapshot
- *
+ *
* @see IWorkingSetConfiguration.ISnapshot#isReadOnly()
*/
static boolean isReadOnly(IWorkingSetConfiguration config) {
@@ -290,22 +289,21 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Default implementation of the mutable working set configuration snapshot.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
- *
+ *
* @since 6.0
*/
- public static class Snapshot extends WorkingSetConfiguration implements
- IWorkingSetConfiguration.ISnapshot {
+ public static class Snapshot extends WorkingSetConfiguration implements IWorkingSetConfiguration.ISnapshot {
private final boolean readOnly;
private final WorkspaceSnapshot workspace;
/**
* Initializes me with the current workspace snapshot.
- *
+ *
* @param workingSet
* my parent working set
* @param workspace
@@ -318,7 +316,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Initializes me as a special read-only configuration that shows what is the current active
* configuration of the projects in a working set when none of its named configurations is active.
- *
+ *
* @param workingSet
* my parent working set
* @param workspace
@@ -335,7 +333,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Initializes me with the current workspace snapshot.
- *
+ *
* @param workingSet
* my parent working set
* @param config
@@ -343,8 +341,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
* @param workspace
* the current workspace snapshot
*/
- protected Snapshot(IWorkingSetProxy workingSet, IWorkingSetConfiguration config,
- WorkspaceSnapshot workspace) {
+ protected Snapshot(IWorkingSetProxy workingSet, IWorkingSetConfiguration config, WorkspaceSnapshot workspace) {
this(workingSet, workspace);
setName(config.getName());
@@ -367,7 +364,7 @@ public class WorkingSetConfiguration implements IWorkingSetConfiguration {
/**
* Queries whether I am a read-only view of the current active configurations of my working set's
* projects.
- *
+ *
* @return whether I am read-only
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java
index da4d21b0768..76bc34646a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java
@@ -53,9 +53,9 @@ import org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog;
/**
* A block of UI controls for management of working set configurations. These collect the selection of project
* configurations for the member projects of the working sets into named presets.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public class WorkingSetConfigurationBlock {
@@ -75,7 +75,7 @@ public class WorkingSetConfigurationBlock {
/**
* Initializes me. I take the most recently used working set as my initial selection.
- *
+ *
* @param workspace
* the workspace snapshot to edit
*/
@@ -85,22 +85,21 @@ public class WorkingSetConfigurationBlock {
/**
* Initializes me with my initial selection.
- *
+ *
* @param workspace
* the workspace snapshot to edit
* @param initialSelection
* my initial selection
*/
- public WorkingSetConfigurationBlock(WorkspaceSnapshot workspace,
- IWorkingSetProxy.ISnapshot initialSelection) {
-
+ public WorkingSetConfigurationBlock(WorkspaceSnapshot workspace, IWorkingSetProxy.ISnapshot initialSelection) {
+
this.workspace = workspace;
this.initialSelection = initialSelection;
}
/**
* Queries the working set filter, if any, that restricts the display of working sets.
- *
+ *
* @return my working-set filter
*/
public IFilter getWorkingSetFilter() {
@@ -109,7 +108,7 @@ public class WorkingSetConfigurationBlock {
/**
* Assigns a filter to restrict the working sets that are shown.
- *
+ *
* @param filter
* a working-set filter
*/
@@ -119,10 +118,10 @@ public class WorkingSetConfigurationBlock {
/**
* Creates the contents of the working set configuration management control block.
- *
+ *
* @param parent
* the parent composite in which to create my controls
- *
+ *
* @return my controls
*/
public Control createContents(Composite parent) {
@@ -141,13 +140,13 @@ public class WorkingSetConfigurationBlock {
/**
* Creates the "working set configurations" pane in the upper part of the sash form.
- *
+ *
* @param parent
* the parent composite
* @param layoutFactory
* a layout-factory to use to lay out the composite in a grid, possibly pre-configured. Its use
* is optional
- *
+ *
* @return the working set configurations pane
*/
protected Composite createWorkingSetConfigsArea(Composite parent, GridLayoutFactory layoutFactory) {
@@ -224,13 +223,13 @@ public class WorkingSetConfigurationBlock {
/**
* Creates the "project configurations" pane in the lower part of the sash form.
- *
+ *
* @param parent
* the parent composite
* @param layoutFactory
* a layout-factory to use to lay out the composite in a grid, possibly pre-configured. Its use
* is optional
- *
+ *
* @return the project configurations pane
*/
protected Composite createProjectConfigsArea(Composite parent, GridLayoutFactory layoutFactory) {
@@ -275,7 +274,7 @@ public class WorkingSetConfigurationBlock {
* Builds the projects that were reconfigured by the dialog, if any. The user is prompted (if prompting is
* not disabled via the preference) before building. The user has the options to build, not build, or
* cancel. The result indicates cancellation.
- *
+ *
* @return <code>true</code> if the user opted to save changes and exit the dialog (with or without
* build); <code>false</code> if the user cancelled and the dialog should remain open and unsaved
*/
@@ -291,9 +290,9 @@ public class WorkingSetConfigurationBlock {
int button = OptionalMessageDialog.open(BUILD_PROMPT_DIALOG_ID, contents.getShell(),
WorkingSetMessages.WSConfigDialog_buildPrompt_title, null,
- WorkingSetMessages.WSConfigDialog_buildPrompt_message, MessageDialog.QUESTION,
- new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL,
- IDialogConstants.YES_LABEL }, defaultButton);
+ WorkingSetMessages.WSConfigDialog_buildPrompt_message, MessageDialog.QUESTION, new String[] {
+ IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL, IDialogConstants.YES_LABEL },
+ defaultButton);
if (button == OptionalMessageDialog.NOT_SHOWN) {
// handle the case where the dialog was suppressed. Get the current default
@@ -326,7 +325,7 @@ public class WorkingSetConfigurationBlock {
/**
* Simple content provider for the working set configurations tree.
- *
+ *
* @author Christian W. Damus (cdamus)
*/
private class WSConfigsContentProvider implements ITreeContentProvider {
@@ -362,8 +361,8 @@ public class WorkingSetConfigurationBlock {
@Override
public Object getParent(Object element) {
- return (element instanceof IWorkingSetConfiguration) ? ((IWorkingSetConfiguration) element)
- .getWorkingSet() : null;
+ return (element instanceof IWorkingSetConfiguration) ? ((IWorkingSetConfiguration) element).getWorkingSet()
+ : null;
}
@Override
@@ -393,7 +392,7 @@ public class WorkingSetConfigurationBlock {
* Label provider for working sets and their configurations. The active configuration is highlighted in
* bold and affixed with an "(active)" decoration. The special read-only configuration is further
* differentiated with an italic font.
- *
+ *
* @author Christian W. Damus (cdamus)
*/
private class WSConfigsLabelProvider extends LabelProvider implements IFontProvider {
@@ -413,8 +412,8 @@ public class WorkingSetConfigurationBlock {
if (config.isActive()) {
return WorkingSetConfiguration.isReadOnly(config)
- ? WorkingSetMessages.WSConfigDialog_implicit_config : NLS.bind(
- WorkingSetMessages.WSConfigDialog_active_config, config.getName());
+ ? WorkingSetMessages.WSConfigDialog_implicit_config
+ : NLS.bind(WorkingSetMessages.WSConfigDialog_active_config, config.getName());
}
return config.getName();
} else if (element instanceof IWorkingSetProxy) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java
index 78ad2302cde..58a271a44b2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java
@@ -26,9 +26,9 @@ import org.eclipse.swt.widgets.Shell;
/**
* A dialog for management of working set configurations. These collect the selection of project
* configurations for the member projects of the working sets into named presets.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public class WorkingSetConfigurationDialog extends TrayDialog {
@@ -37,7 +37,7 @@ public class WorkingSetConfigurationDialog extends TrayDialog {
/**
* Initializes me with my shell.
- *
+ *
* @param shell
*/
public WorkingSetConfigurationDialog(Shell shell) {
@@ -46,7 +46,7 @@ public class WorkingSetConfigurationDialog extends TrayDialog {
/**
* Initializes me with my shell provider.
- *
+ *
* @param parentShell
*/
public WorkingSetConfigurationDialog(IShellProvider parentShell) {
@@ -71,8 +71,7 @@ public class WorkingSetConfigurationDialog extends TrayDialog {
protected Control createDialogArea(Composite parent) {
Composite result = (Composite) super.createDialogArea(parent);
- block = new WorkingSetConfigurationBlock(WorkingSetConfigurationManager.getDefault()
- .createWorkspaceSnapshot());
+ block = new WorkingSetConfigurationBlock(WorkingSetConfigurationManager.getDefault().createWorkspaceSnapshot());
Control contents = block.createContents(result);
contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationManager.java
index fdd1c71c846..acefa17e254 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationManager.java
@@ -43,11 +43,11 @@ import org.eclipse.cdt.ui.newui.CDTPrefUtil;
* The purveyor of working set configurations. It provides a current view of the {@linkplain IWorkingSetProxy
* working set configurations} defined in the workspace, as well as a working-copy
* {@linkplain WorkspaceSnapshot snapshot} of the same for making modifications.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
public class WorkingSetConfigurationManager {
@@ -91,7 +91,7 @@ public class WorkingSetConfigurationManager {
/**
* Obtains the default working set configuration manager.
- *
+ *
* @return the working set configuration manager
*/
public static WorkingSetConfigurationManager getDefault() {
@@ -115,7 +115,7 @@ public class WorkingSetConfigurationManager {
* Obtains the current immutable view of the specified working set's configurations. These configurations
* may be {@linkplain IWorkingSetConfiguration#activate() activated} to apply their settings to the
* workspace, but they cannot be modified.
- *
+ *
* @param name
* the name of the working set to retrieve
* @return the named working set, or <code>null</code> if there is none available by that name
@@ -128,7 +128,7 @@ public class WorkingSetConfigurationManager {
* Obtains the current immutable view of all available working set configurations. These configurations
* may be {@linkplain IWorkingSetConfiguration#activate() activated} to apply their settings to the
* workspace, but they cannot be modified.
- *
+ *
* @return the working set configurations
*/
public Collection<IWorkingSetProxy> getWorkingSets() {
@@ -138,7 +138,7 @@ public class WorkingSetConfigurationManager {
/**
* Creates a new mutable snapshot of the current working set configurations. This snapshot accepts
* modifications and can be {@linkplain WorkspaceSnapshot#save() saved} to persist the changes.
- *
+ *
* @return a working-copy of the working set configurations
*/
public WorkspaceSnapshot createWorkspaceSnapshot() {
@@ -181,7 +181,7 @@ public class WorkingSetConfigurationManager {
/**
* Saves the working set configurations to storage.
- *
+ *
* @param snapshot
* the snapshot to save
*/
@@ -197,7 +197,7 @@ public class WorkingSetConfigurationManager {
/**
* Records the specified memento as our new store and asynchronously saves it in a job.
- *
+ *
* @param memento
* the new store
*/
@@ -243,7 +243,7 @@ public class WorkingSetConfigurationManager {
/**
* Gets the file in which we persist the working set configurations.
- *
+ *
* @return the file store
*/
private File getStorage() {
@@ -254,7 +254,7 @@ public class WorkingSetConfigurationManager {
/**
* Loads the working set configurations from storage. For compatibility, if the XML file is not available,
* we load from the old preference setting format.
- *
+ *
* @return the working set configuration store
*/
private IMemento loadMemento() {
@@ -332,13 +332,13 @@ public class WorkingSetConfigurationManager {
* A working set manager listener that tracks name changes and removals of working sets to keep our
* configurations in synch as much as possible. It updates the memento store directly in response to
* changes in the working sets.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
- private class WorkingSetChangeTracker extends java.util.IdentityHashMap<IWorkingSet, String> implements
- IPropertyChangeListener {
+ private class WorkingSetChangeTracker extends java.util.IdentityHashMap<IWorkingSet, String>
+ implements IPropertyChangeListener {
WorkingSetChangeTracker() {
for (IWorkingSet next : WS_MGR.getWorkingSets()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationsPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationsPage.java
index 8f32ba761b4..f5ac318d6d7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationsPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationsPage.java
@@ -26,9 +26,9 @@ import org.eclipse.ui.dialogs.PropertyPage;
/**
* Property page for the configurations of a working set.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public class WorkingSetConfigurationsPage extends PropertyPage {
@@ -40,7 +40,7 @@ public class WorkingSetConfigurationsPage extends PropertyPage {
*/
public WorkingSetConfigurationsPage() {
super();
-
+
noDefaultAndApplyButton();
}
@@ -49,8 +49,7 @@ public class WorkingSetConfigurationsPage extends PropertyPage {
Composite result = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().margins(5, 5).applyTo(result);
- final WorkspaceSnapshot workspace = WorkingSetConfigurationManager.getDefault()
- .createWorkspaceSnapshot();
+ final WorkspaceSnapshot workspace = WorkingSetConfigurationManager.getDefault().createWorkspaceSnapshot();
final IWorkingSetProxy.ISnapshot workingSet = getWorkingSet(workspace);
if (workingSet == null) {
@@ -86,7 +85,7 @@ public class WorkingSetConfigurationsPage extends PropertyPage {
return result;
}
-
+
@Override
public boolean performOk() {
if (!block.build()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.java
index 926dd3c2452..e461f237966 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.java
@@ -31,15 +31,15 @@ public final class WorkingSetMessages extends NLS {
public static String CElementWorkingSetPage_warning_nameMustNotBeEmpty;
public static String CElementWorkingSetPage_warning_workingSetExists;
public static String CElementWorkingSetPage_warning_resourceMustBeChecked;
-
+
public static String ProjConfigController_activeConfig;
public static String WorkingSetMenus_enumPattern;
public static String WorkspaceSnapshot_buildNoProj;
-
+
public static String WSConfig_build_problems;
public static String WSConfig_build_task;
-
+
public static String WSConfigDialog_activate_label;
public static String WSConfigDialog_active_config;
public static String WSConfigDialog_add_label;
@@ -59,7 +59,7 @@ public final class WorkingSetMessages extends NLS {
public static String WSConfigManager_loadFailed;
public static String WSConfigManager_save_job;
public static String WSConfigManager_saveFailed;
-
+
public static String WSConfigsController_addDlg_defaultName;
public static String WSConfigsController_addDlg_emptyName;
public static String WSConfigsController_addDlg_msg;
@@ -70,13 +70,13 @@ public final class WorkingSetMessages extends NLS {
public static String WSConfigsController_buildFailedLog;
public static String WSConfigsController_renameDlg_msg;
public static String WSConfigsController_renameDlg_title;
-
+
public static String WSetConfigsPage_noProjects;
-
+
public static String WSProjConfig_activatedWarning;
public static String WSProjConfig_buildProblem;
public static String WSProjConfig_noConfig;
-
+
public static String WSProjConfigFactory_badFactory;
public static String WSProjConfigFactory_factoryFailed;
public static String WSProjConfigFactory_noFactoryID;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfiguration.java
index 46d444c729b..1c17db4b123 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfiguration.java
@@ -41,11 +41,11 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* Default implementation of the {@link IWorkingSetProjectConfiguration} interface. Clients may extend this
* class to implement additional project configuration settings.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfiguration {
private final IWorkingSetConfiguration workingSetConfig;
@@ -54,7 +54,7 @@ public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfigu
/**
* Initializes me with my parent working set configuration.
- *
+ *
* @param parent
* my parent working set configuration
*/
@@ -75,7 +75,7 @@ public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfigu
/**
* Sets my project name. Note that this <b>does not</b> change the name of the project that I represent.
* Rather, it changes <i>which</i> project I represent.
- *
+ *
* @param projectName
* my new project name
*/
@@ -132,8 +132,7 @@ public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfigu
}
}
- return (result == null) ? Collections.<ICConfigurationDescription> emptyList() : Arrays
- .asList(result);
+ return (result == null) ? Collections.<ICConfigurationDescription>emptyList() : Arrays.asList(result);
}
@Override
@@ -169,13 +168,13 @@ public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfigu
ICConfigurationDescription config = resolveSelectedConfiguration();
if (config == null) {
- result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, NLS.bind(
- WorkingSetMessages.WSProjConfig_noConfig, getProjectName()));
+ result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ NLS.bind(WorkingSetMessages.WSProjConfig_noConfig, getProjectName()));
} else {
if (!isActive()) {
activate();
- result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, NLS.bind(
- WorkingSetMessages.WSProjConfig_activatedWarning, config.getName(), getProjectName()));
+ result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ NLS.bind(WorkingSetMessages.WSProjConfig_activatedWarning, config.getName(), getProjectName()));
}
monitor = SubMonitor.convert(monitor);
@@ -211,8 +210,7 @@ public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfigu
}
@Override
- public ISnapshot createSnapshot(IWorkingSetConfiguration.ISnapshot workingSetConfig,
- WorkspaceSnapshot workspace) {
+ public ISnapshot createSnapshot(IWorkingSetConfiguration.ISnapshot workingSetConfig, WorkspaceSnapshot workspace) {
return new Snapshot(workingSetConfig, this, workspace);
}
@@ -223,13 +221,13 @@ public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfigu
/**
* Default implementation of the mutable project configuration snapshot.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
- public static class Snapshot extends WorkingSetProjectConfiguration implements
- IWorkingSetProjectConfiguration.ISnapshot {
+ public static class Snapshot extends WorkingSetProjectConfiguration
+ implements IWorkingSetProjectConfiguration.ISnapshot {
private final IProject project;
private final WorkspaceSnapshot workspace;
@@ -238,7 +236,7 @@ public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfigu
* Initializes me with the project that I represent and the workspace snapshot. I discover the
* currently defined configurations for my project and initially select the one that is currently
* active, or the first available if none is active (which would be odd).
- *
+ *
* @param parent
* my parent working set configuration
* @param projectConfig
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester.java
index 8889c6d6a58..6d0ac5e7376 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester.java
@@ -26,14 +26,14 @@ import org.eclipse.cdt.core.model.CoreModel;
* as managing build configurations.
*
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*
*/
public class WorkingSetPropertyTester extends PropertyTester {
private static final String P_HAS_C_PROJECTS = "hasCProjects"; //$NON-NLS-1$
-
+
/**
* Initializes me.
*/
@@ -46,38 +46,38 @@ public class WorkingSetPropertyTester extends PropertyTester {
if (P_HAS_C_PROJECTS.equals(property)) {
return hasCProjects(getWorkingSet(receiver));
}
-
+
return false;
}
private IWorkingSet getWorkingSet(Object object) {
IWorkingSet result = null;
-
+
if (object instanceof IWorkingSet) {
result = (IWorkingSet) object;
} else if (object instanceof IAdaptable) {
result = ((IAdaptable) object).getAdapter(IWorkingSet.class);
}
-
+
return result;
}
-
+
private boolean hasCProjects(IWorkingSet workingSet) {
boolean result = false;
-
+
if (workingSet != null) {
IAdaptable[] members = workingSet.getElements();
-
+
for (IAdaptable next : members) {
IProject project = next.getAdapter(IProject.class);
-
+
if ((project != null) && CoreModel.hasCNature(project)) {
result = true;
break;
}
}
}
-
+
return result;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.java
index 96e77f0af0c..b111a6ee00c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.java
@@ -33,11 +33,11 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
/**
* Default implementation of the {@link IWorkingSetProxy} interface.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public class WorkingSetProxy implements IWorkingSetProxy {
@@ -59,7 +59,7 @@ public class WorkingSetProxy implements IWorkingSetProxy {
/**
* Sets my name. This <b>does not</b> change the name of the working set that I represent. Rather, it
* changes <i>which</i> working set I represent.
- *
+ *
* @param name
* my new name
*/
@@ -128,7 +128,7 @@ public class WorkingSetProxy implements IWorkingSetProxy {
* Queries whether the specified configuration is transient, meaning that it should not be persisted in
* the working set configuration store. The default implementation just returns <code>false</code>;
* subclasses may redefine as required.
- *
+ *
* @param config
* a working set configuration
* @return whether it should be omitted from persistence
@@ -151,7 +151,7 @@ public class WorkingSetProxy implements IWorkingSetProxy {
/**
* Creates a new child working set configuration element. Subclasses may override to create custom
* implementations.
- *
+ *
* @return the new working set configuration
*/
protected IWorkingSetConfiguration createWorkingSetConfiguration() {
@@ -160,7 +160,7 @@ public class WorkingSetProxy implements IWorkingSetProxy {
/**
* Provides simple access to the child configurations, to remove the specified configuration.
- *
+ *
* @param config
* a configuration to remove
*/
@@ -170,7 +170,7 @@ public class WorkingSetProxy implements IWorkingSetProxy {
/**
* Provides simple access to the child configurations, to add the specified configuration.
- *
+ *
* @param config
* a configuration to add
*/
@@ -193,11 +193,11 @@ public class WorkingSetProxy implements IWorkingSetProxy {
/**
* The default implementation of a mutable working set snapshot.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public static class Snapshot extends WorkingSetProxy implements IWorkingSetProxy.ISnapshot {
@@ -206,7 +206,7 @@ public class WorkingSetProxy implements IWorkingSetProxy {
/**
* Initializes me with the current workspace snapshot.
- *
+ *
* @param workingSet
* the original working set element to copy
* @param workspace
@@ -253,7 +253,7 @@ public class WorkingSetProxy implements IWorkingSetProxy {
* Heuristically attempts to select reasonable default project configurations for a new working-set
* configuration. This implementation does a best-effort match of project configuration names against
* the working set configuration name.
- *
+ *
* @param newConfig
* the new working set configuration
*/
@@ -323,8 +323,7 @@ public class WorkingSetProxy implements IWorkingSetProxy {
}
readOnlyConfig = null;
} else {
- WorkingSetConfiguration.Snapshot ro = new WorkingSetConfiguration.Snapshot(this, workspace,
- true);
+ WorkingSetConfiguration.Snapshot ro = new WorkingSetConfiguration.Snapshot(this, workspace, true);
ro.basicSetName(""); // don't want to validate this name //$NON-NLS-1$
readOnlyConfig = ro;
basicAddConfiguration(readOnlyConfig);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.java
index 432f4b4b571..d89b99b016b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.java
@@ -51,11 +51,11 @@ import org.eclipse.cdt.ui.CUIPlugin;
* {@link WorkingSetConfigurationManager}. Then make edits to the various snapshots of the configuration
* elements and {@linkplain #save() save} the snapshot
* </p>
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
- *
+ *
*/
public class WorkspaceSnapshot {
private Map<String, IWorkingSetProxy.ISnapshot> workingSets = new java.util.HashMap<String, IWorkingSetProxy.ISnapshot>();
@@ -79,12 +79,12 @@ public class WorkspaceSnapshot {
/**
* Creates a project state using the registered factory, if possible.
- *
+ *
* @param project
* a workspace project
* @param desc
* its CDT project description
- *
+ *
* @return its state capture (will never be <code>null</code>)
*/
private static ProjectState createProjectState(IProject project, ICProjectDescription desc) {
@@ -106,7 +106,7 @@ public class WorkspaceSnapshot {
/**
* Initializes me with the specified working sets to copy for editing.
- *
+ *
* @param workingSets
* the working sets to copy
* @return myself
@@ -130,12 +130,12 @@ public class WorkspaceSnapshot {
/**
* Obtains a mutable snapshot of the named working set.
- *
+ *
* @param name
* the working set to retrieve
- *
+ *
* @return the working set snapshot, or <code>null</code> if there is no working set by this name
- *
+ *
* @see #getWorkingSets()
*/
public IWorkingSetProxy.ISnapshot getWorkingSet(String name) {
@@ -144,9 +144,9 @@ public class WorkspaceSnapshot {
/**
* Obtains snapshots of all of the working sets currently defined by the workbench.
- *
+ *
* @return the working set snapshots
- *
+ *
* @see #getWorkingSet(String)
*/
public Collection<IWorkingSetProxy.ISnapshot> getWorkingSets() {
@@ -156,7 +156,7 @@ public class WorkspaceSnapshot {
/**
* Obtains the project state recording the initial configuration of the specified <tt>project</tt> at the
* time that this snapshot was taken.
- *
+ *
* @param project
* a project
* @return its snapshot/delta state
@@ -168,7 +168,7 @@ public class WorkspaceSnapshot {
/**
* Queries the ID of the configuration of the specified project that was active when the workspace
* snapshot was taken.
- *
+ *
* @param project
* a project
* @return its active configuration ID at the time of the snapshot
@@ -186,10 +186,10 @@ public class WorkspaceSnapshot {
/**
* Queries the ID of the currently active configuration of the specified project.
- *
+ *
* @param project
* a project
- *
+ *
* @return the current active configuration ID
*/
String getActiveConfigurationID(IProject project) {
@@ -206,12 +206,12 @@ public class WorkspaceSnapshot {
/**
* Queries whether the configuration selected by the given project in a working set configuration is
* currently active in the workspace.
- *
+ *
* @param project
* a project configuration element in a working set configuration
- *
+ *
* @return whether the project's selected configuration is active
- *
+ *
* @see #activate(IProject, String)
*/
boolean isActive(IWorkingSetProjectConfiguration project) {
@@ -228,12 +228,12 @@ public class WorkspaceSnapshot {
/**
* Activates, in the workspace, the specified configuration of a project. This method has no effect if the
* given configuration is already active.
- *
+ *
* @param project
* the project for which to set the active configuration
* @param configID
* the ID of the configuration to activate
- *
+ *
* @see #isActive(IWorkingSetProjectConfiguration)
*/
void activate(IProject project, String configID) {
@@ -251,16 +251,16 @@ public class WorkspaceSnapshot {
return state.build(configID, monitor);
}
- return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, NLS.bind(
- WorkingSetMessages.WorkspaceSnapshot_buildNoProj, project.getName()));
+ return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+ NLS.bind(WorkingSetMessages.WorkspaceSnapshot_buildNoProj, project.getName()));
}
/**
* Obtains the configurations of the specified project, as known at the time that this snapshot was taken.
- *
+ *
* @param project
* a project
- *
+ *
* @return its configurations, which may be an empty collection if the project is not a C/C++ project
*/
public Collection<ICConfigurationDescription> getConfigurations(IProject project) {
@@ -278,12 +278,12 @@ public class WorkspaceSnapshot {
/**
* Obtains the specified configuration of a project, as known at the time that this snapshot was taken.
- *
+ *
* @param project
* a project
* @param id
* the ID of a configuration
- *
+ *
* @return the configuration, or <code>null</code> if there is none such by this ID
*/
public ICConfigurationDescription getConfiguration(IProject project, String id) {
@@ -294,7 +294,7 @@ public class WorkspaceSnapshot {
/**
* Queries the projects that need to be built because their active configurations have been changed since
* this snapshot was taken.
- *
+ *
* @return the projects needing to be re-built
*/
public Collection<IProject> getProjectsToBuild() {
@@ -325,9 +325,9 @@ public class WorkspaceSnapshot {
* snapshot} was taken, and its delta from that original state. This tracks at least the C/C++ project
* description (if any) and the original active configuration. Subclasses may track additional
* configuration details.
- *
+ *
* @author Christian W. Damus (cdamus)
- *
+ *
* @since 6.0
*/
public static class ProjectState {
@@ -339,7 +339,7 @@ public class WorkspaceSnapshot {
/**
* Initializes me with a project and its description.
- *
+ *
* @param project
* the project whose state I track
* @param desc
@@ -361,7 +361,7 @@ public class WorkspaceSnapshot {
/**
* Obtains the project that I track.
- *
+ *
* @return my project
*/
public final IProject getProject() {
@@ -370,7 +370,7 @@ public class WorkspaceSnapshot {
/**
* Obtains the project description that was current when the snapshot was taken.
- *
+ *
* @return my project description
*/
protected final ICProjectDescription getProjectDescription() {
@@ -380,7 +380,7 @@ public class WorkspaceSnapshot {
/**
* Queries whether my project needs to be re-built because its active configuration has been changed
* since the snapshot was taken, and it hasn't been built already.
- *
+ *
* @return whether I need to be re-built
*/
public boolean needsBuild() {
@@ -389,7 +389,7 @@ public class WorkspaceSnapshot {
/**
* Queries whether the specified configuration is currently active in the workspace for my project.
- *
+ *
* @param configID
* the ID of a project build configuration
* @return whether it is my project's active configuration
@@ -400,7 +400,7 @@ public class WorkspaceSnapshot {
/**
* Queries the ID of the currently active configuration.
- *
+ *
* @return the current active configuration ID
*/
protected String getActiveConfigurationID() {
@@ -410,7 +410,7 @@ public class WorkspaceSnapshot {
/**
* Queries the ID of the configuration of my project that was active when the workspace snapshot was
* taken.
- *
+ *
* @return its active configuration ID at the time of the snapshot
*/
protected String getBaselineConfigurationID() {
@@ -420,7 +420,7 @@ public class WorkspaceSnapshot {
/**
* Sets my project's active configuration to the specified configuration. This method has no effect if
* this configuration is already active.
- *
+ *
* @param configID
* the ID of the configuration to activate
*/
@@ -440,12 +440,12 @@ public class WorkspaceSnapshot {
/**
* Builds the specified configuration of my project. I update myself to record a new build baseline if
* the build succeeds.
- *
+ *
* @param configID
* the configuration to build
* @param monitor
* a monitor to report build progress
- *
+ *
* @return the status of the build
*/
protected IStatus build(String configID, IProgressMonitor monitor) {
@@ -454,14 +454,14 @@ public class WorkspaceSnapshot {
ICConfigurationDescription config = getConfiguration(configID);
if (config == null) {
- result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, NLS.bind(
- WorkingSetMessages.WSProjConfig_noConfig, getProject().getName()));
+ result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ NLS.bind(WorkingSetMessages.WSProjConfig_noConfig, getProject().getName()));
} else {
if (!isActive(configID)) {
activate(configID);
- result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, NLS.bind(
- WorkingSetMessages.WSProjConfig_activatedWarning, config.getName(), getProject()
- .getName()));
+ result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+ NLS.bind(WorkingSetMessages.WSProjConfig_activatedWarning, config.getName(),
+ getProject().getName()));
}
monitor = SubMonitor.convert(monitor);
@@ -475,9 +475,8 @@ public class WorkspaceSnapshot {
if (result.isOK()) {
result = e.getStatus();
} else {
- result = new MultiStatus(CUIPlugin.PLUGIN_ID, 0, new IStatus[] { result,
- e.getStatus() }, NLS.bind(WorkingSetMessages.WSProjConfig_buildProblem,
- getProject().getName()), null);
+ result = new MultiStatus(CUIPlugin.PLUGIN_ID, 0, new IStatus[] { result, e.getStatus() },
+ NLS.bind(WorkingSetMessages.WSProjConfig_buildProblem, getProject().getName()), null);
}
}
}
@@ -488,7 +487,7 @@ public class WorkspaceSnapshot {
/**
* Records that we built the specified configuration ID. I will not {@linkplain #needsBuild() need a
* build} if the last build configuration is my active configuration.
- *
+ *
* @param configID
* the configuration that was built (not <code>null</code>)
*/
@@ -498,7 +497,7 @@ public class WorkspaceSnapshot {
/**
* Obtains the configurations of my project that were defined at the time that the snapshot was taken.
- *
+ *
* @return my project's configurations, which may be empty if it is not a C/C++ project
*/
protected Collection<ICConfigurationDescription> getConfigurations() {
@@ -516,7 +515,7 @@ public class WorkspaceSnapshot {
/**
* Obtains the specified configuration of my project as it was defined at the time that the snapshot
* was taken.
- *
+ *
* @param id
* a configuration ID
* @return the matching configuration, or <code>null</code> if it did not exist
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java
index 2d5aad91f2f..b6f535dcaff 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java
@@ -108,8 +108,8 @@ public class CDTSharedImages {
public static final String IMG_OBJS_INCLUDES_FOLDER_SYSTEM = "icons/obj16/fldr_sys_obj.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OBJS_FRAMEWORKS_FOLDER = "icons/obj16/frameworks.png"; //$NON-NLS-1$
- public static final String IMG_OBJS_MACROS_FILE= "icons/obj16/macros_file.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_LIBRARY_FOLDER= "icons/obj16/fldr_lib_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_MACROS_FILE = "icons/obj16/macros_file.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_LIBRARY_FOLDER = "icons/obj16/fldr_lib_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ORDER = "icons/obj16/cp_order_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_EXCLUSION_FILTER_ATTRIB = "icons/obj16/exclusion_filter_attrib.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SOURCE_ATTACH_ATTRIB = "icons/obj16/source_attach_attrib.gif"; //$NON-NLS-1$
@@ -256,7 +256,7 @@ public class CDTSharedImages {
* Retrieves an overlaid image from the internal repository of images.
* If there is no image one will be created.
*
- * The decoration overlay for the base image will use the array of
+ * The decoration overlay for the base image will use the array of
* provided overlays. The indices of the array correspond to the values
* of the 5 overlay constants defined on {@link IDecoration}, i.e.
* {@link IDecoration#TOP_LEFT},
@@ -312,4 +312,3 @@ public class CDTSharedImages {
return getImageOverlaid(baseKey, CDTSharedImages.IMG_OVR_ERROR, IDecoration.BOTTOM_LEFT);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUIImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUIImages.java
index 94b05ca693c..c7648a21542 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUIImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUIImages.java
@@ -13,32 +13,30 @@
*******************************************************************************/
package org.eclipse.cdt.ui;
-
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
-
/**
* Images for {@link org.eclipse.cdt.utils.ui.controls.FileListControl}.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
- *
+ *
* @deprecated as of CDT 8.0. Use {@link CDTSharedImages}.
*/
@Deprecated
public class CDTUIImages {
- private static final String ICONS= "icons/"; //$NON-NLS-1$
+ private static final String ICONS = "icons/"; //$NON-NLS-1$
/** Converter from CPluginImages key to CDTSharedImages key */
private static Map<String, String> fPathMap = new HashMap<String, String>();
- private static final String NAME_PREFIX= CUIPlugin.PLUGIN_ID + '.';
- private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
- public static final String T_LIST= "elcl16/"; //$NON-NLS-1$
-
+ private static final String NAME_PREFIX = CUIPlugin.PLUGIN_ID + '.';
+ private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
+ public static final String T_LIST = "elcl16/"; //$NON-NLS-1$
+
// Image for file list control
public static final String IMG_FILELIST_ADD = NAME_PREFIX + "list-add.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_FILELIST_ADD = createManaged(T_LIST, IMG_FILELIST_ADD);
@@ -50,7 +48,7 @@ public class CDTUIImages {
public static final ImageDescriptor DESC_FILELIST_MOVEUP = createManaged(T_LIST, IMG_FILELIST_MOVEUP);
public static final String IMG_FILELIST_MOVEDOWN = NAME_PREFIX + "list-movedown.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_FILELIST_MOVEDOWN = createManaged(T_LIST, IMG_FILELIST_MOVEDOWN);
-
+
/**
* Creates an image descriptor which is managed by internal registry in CDTSharedImages.
* {@code name} is assumed to start with "org.eclipse.cdt.ui."
@@ -65,14 +63,14 @@ public class CDTUIImages {
}
return ImageDescriptor.getMissingImageDescriptor();
}
-
+
/**
* Get an image from internal image registry. The image is managed by the registry and
* must not be disposed by the caller.
- *
+ *
* @param key - one of {@code CDTUIImages.IMG_} constants.
* @return the image corresponding the given key.
- *
+ *
* @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImage(String)}.
*/
@Deprecated
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java
index 40ae8359181..659e700ddd7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java
@@ -53,7 +53,7 @@ public final class CDTUITools {
private CDTUITools() {
// prevent instantiation
}
-
+
/**
* Returns the color manager which is used to manage
* colors needed for syntax highlighting.
@@ -86,11 +86,12 @@ public final class CDTUITools {
* @exception PartInitException if the editor could not be initialized or no workbench page is active
* @exception CModelException if this element does not exist or if an exception occurs while accessing its underlying resource
*/
- public static IEditorPart openInEditor(ICElement element, boolean activate, boolean reveal) throws CModelException, PartInitException {
+ public static IEditorPart openInEditor(ICElement element, boolean activate, boolean reveal)
+ throws CModelException, PartInitException {
if (!(element instanceof ISourceReference)) {
return null;
}
- IEditorPart part= EditorUtility.openInEditor(element, activate);
+ IEditorPart part = EditorUtility.openInEditor(element, activate);
if (reveal && part != null) {
EditorUtility.revealInEditor(part, element);
}
@@ -98,7 +99,7 @@ public final class CDTUITools {
}
/**
- * Reveals the given C model element in the given editor..
+ * Reveals the given C model element in the given editor..
*
* @param part the editor displaying a translation unit
* @param element the element to be revealed
@@ -137,7 +138,7 @@ public final class CDTUITools {
if (editorInput instanceof ITranslationUnitEditorInput) {
return ((ITranslationUnitEditorInput) editorInput).getTranslationUnit();
}
- IWorkingCopy tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+ IWorkingCopy tu = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
if (tu != null)
return tu;
@@ -178,7 +179,7 @@ public final class CDTUITools {
/**
* Sets up the given document for the default C/C++ partitioning.
- *
+ *
* @param document the document to be set up
* @param location the path of the resource backing the document. May be null.
* @param locationKind the type of path specified above. May be null.
@@ -196,13 +197,13 @@ public final class CDTUITools {
/**
* Sets up the given document for the default Assembly partitioning.
- *
+ *
* @param document the document to be set up
*/
public static void setupAsmDocument(IDocument document) {
- IDocumentPartitioner partitioner= createAsmDocumentPartitioner();
+ IDocumentPartitioner partitioner = createAsmDocumentPartitioner();
if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
+ IDocumentExtension3 extension3 = (IDocumentExtension3) document;
extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
} else {
document.setDocumentPartitioner(partitioner);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
index 87132adc9d3..f0caccb5540 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
@@ -71,30 +71,31 @@ C model (<code>ICModel</code>)<br>
* </pre>
*/
-public class CElementContentProvider extends BaseCElementContentProvider implements IElementChangedListener, IInformationProvider, IInformationProviderExtension{
+public class CElementContentProvider extends BaseCElementContentProvider
+ implements IElementChangedListener, IInformationProvider, IInformationProviderExtension {
/** Editor. */
- protected ITextEditor fEditor;
- protected StructuredViewer fViewer;
+ protected ITextEditor fEditor;
+ protected StructuredViewer fViewer;
protected Object fInput;
-
+
/** Remember what refreshes we already have pending so we don't post them again. */
protected HashSet<IRefreshable> pendingRefreshes = new HashSet<IRefreshable>();
- /**
- * Creates a new content provider for C elements.
- */
- public CElementContentProvider() {
- // Empty.
- }
-
/**
* Creates a new content provider for C elements.
- * @param editor Editor.
+ */
+ public CElementContentProvider() {
+ // Empty.
+ }
+
+ /**
+ * Creates a new content provider for C elements.
+ * @param editor Editor.
*/
public CElementContentProvider(ITextEditor editor) {
- fEditor = editor;
+ fEditor = editor;
}
-
+
/**
* Creates a new content provider for C elements.
*/
@@ -102,46 +103,45 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
super(provideMembers, provideWorkingCopy);
}
- @Override
+ @Override
public void dispose() {
- super.dispose();
- CoreModel.getDefault().removeElementChangedListener(this);
- }
+ super.dispose();
+ CoreModel.getDefault().removeElementChangedListener(this);
+ }
- @Override
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- super.inputChanged(viewer, oldInput, newInput);
+ super.inputChanged(viewer, oldInput, newInput);
- fViewer = (StructuredViewer) viewer;
+ fViewer = (StructuredViewer) viewer;
- if (oldInput == null && newInput != null) {
- CoreModel.getDefault().addElementChangedListener(this);
- } else if (oldInput != null && newInput == null) {
- CoreModel.getDefault().removeElementChangedListener(this);
- }
- fInput= newInput;
- }
+ if (oldInput == null && newInput != null) {
+ CoreModel.getDefault().addElementChangedListener(this);
+ } else if (oldInput != null && newInput == null) {
+ CoreModel.getDefault().removeElementChangedListener(this);
+ }
+ fInput = newInput;
+ }
- @Override
+ @Override
public void elementChanged(final ElementChangedEvent event) {
try {
processDelta(event.getDelta());
- } catch(CModelException e) {
+ } catch (CModelException e) {
CUIPlugin.log(e);
e.printStackTrace();
}
}
protected boolean isPathEntryChange(ICElementDelta delta) {
- int flags= delta.getFlags();
- return (delta.getKind() == ICElementDelta.CHANGED &&
- ((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0 ||
- (flags & ICElementDelta.F_ADDED_PATHENTRY_LIBRARY) != 0 ||
- (flags & ICElementDelta.F_ADDED_PATHENTRY_SOURCE) != 0 ||
- (flags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0 ||
- (flags & ICElementDelta.F_PATHENTRY_REORDER) != 0 ||
- (flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0 ||
- (flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0));
+ int flags = delta.getFlags();
+ return (delta.getKind() == ICElementDelta.CHANGED && ((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0
+ || (flags & ICElementDelta.F_ADDED_PATHENTRY_LIBRARY) != 0
+ || (flags & ICElementDelta.F_ADDED_PATHENTRY_SOURCE) != 0
+ || (flags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0
+ || (flags & ICElementDelta.F_PATHENTRY_REORDER) != 0
+ || (flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0
+ || (flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0));
}
/**
@@ -150,9 +150,9 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
* current thread but the viewer updates are posted to the UI thread.
*/
protected void processDelta(ICElementDelta delta) throws CModelException {
- int kind= delta.getKind();
- int flags= delta.getFlags();
- ICElement element= delta.getElement();
+ int kind = delta.getKind();
+ int flags = delta.getFlags();
+ ICElement element = delta.getElement();
//System.out.println("Processing " + element);
@@ -183,7 +183,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
}
if (kind == ICElementDelta.ADDED) {
- Object parent= internalGetParent(element);
+ Object parent = internalGetParent(element);
postAdd(parent, element);
updateContainer(element);
}
@@ -206,7 +206,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
return;
} else if (element instanceof ICContainer) {
// if element itself has changed, not its children
- if ((flags&~(ICElementDelta.F_CHILDREN|ICElementDelta.F_FINE_GRAINED))!=0) {
+ if ((flags & ~(ICElementDelta.F_CHILDREN | ICElementDelta.F_FINE_GRAINED)) != 0) {
postRefresh(element);
}
} else if (element instanceof ArchiveContainer || element instanceof BinaryContainer) {
@@ -217,8 +217,8 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
if (processResourceDeltas(delta.getResourceDeltas(), element))
return;
-
- ICElementDelta[] affectedChildren= delta.getAffectedChildren();
+
+ ICElementDelta[] affectedChildren = delta.getAffectedChildren();
for (ICElementDelta element2 : affectedChildren) {
processDelta(element2);
}
@@ -232,7 +232,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
private boolean processResourceDeltas(IResourceDelta[] deltas, Object parent) {
if (deltas == null)
return false;
-
+
if (deltas.length > 1 && !(parent instanceof ICModel)) {
// more than one child changed, refresh from here downwards
// but not if the parent is ICModel
@@ -251,17 +251,17 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
/**
* Processes a resource delta.
- *
+ *
* @return true if the parent got refreshed
*/
private boolean processResourceDelta(IResourceDelta delta, Object parent) {
- int status= delta.getKind();
- IResource resource= delta.getResource();
+ int status = delta.getKind();
+ IResource resource = delta.getResource();
// filter out changes affecting the output folder
if (resource == null) {
return false;
}
-
+
// this could be optimized by handling all the added children in the parent
if ((status & IResourceDelta.REMOVED) != 0) {
postRemove(resource);
@@ -270,7 +270,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
postAdd(parent, resource);
}
- int flags= delta.getFlags();
+ int flags = delta.getFlags();
// open/close state change of a project
if ((flags & IResourceDelta.OPEN) != 0) {
postProjectStateChanged(parent);
@@ -285,7 +285,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
IParent container = null;
ICProject cproject = null;
if (cfile instanceof IBinary) {
- IBinary bin = (IBinary)cfile;
+ IBinary bin = (IBinary) cfile;
if (bin.showInBinaryContainer()) {
cproject = bin.getCProject();
container = cproject.getBinaryContainer();
@@ -300,13 +300,13 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
}
return false;
}
-
+
// Tree refresh system
// We keep track of what we're going to refresh and avoid posting multiple refresh
// messages for the same elements. This avoids major performance issues where
// we update tree views hundreds or thousands of times.
protected interface IRefreshable {
- public void refresh();
+ public void refresh();
}
protected final class RefreshContainer implements IRefreshable {
@@ -332,21 +332,21 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
} else {
fViewer.refresh(project);
}
- }
+ }
@Override
public boolean equals(Object o) {
- if (o instanceof RefreshContainer) {
- RefreshContainer c = (RefreshContainer)o;
- return c.container.equals(container) && c.project.equals(project);
- }
- return false;
- }
+ if (o instanceof RefreshContainer) {
+ RefreshContainer c = (RefreshContainer) o;
+ return c.container.equals(container) && c.project.equals(project);
+ }
+ return false;
+ }
@Override
public int hashCode() {
- return container.hashCode() * 10903143 + 31181;
- }
+ return container.hashCode() * 10903143 + 31181;
+ }
}
protected final class RefreshElement implements IRefreshable {
@@ -358,11 +358,11 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
@Override
public void refresh() {
- if (element instanceof IWorkingCopy){
- if (fViewer.testFindItem(element) != null){
+ if (element instanceof IWorkingCopy) {
+ if (fViewer.testFindItem(element) != null) {
fViewer.refresh(element);
} else {
- fViewer.refresh(((IWorkingCopy)element).getOriginalElement());
+ fViewer.refresh(((IWorkingCopy) element).getOriginalElement());
}
} else if (element instanceof IBinary) {
fViewer.refresh(element, true);
@@ -373,17 +373,17 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
@Override
public boolean equals(Object o) {
- if (o instanceof RefreshElement) {
- RefreshElement c = (RefreshElement)o;
- return c.element.equals(element);
- }
- return false;
- }
+ if (o instanceof RefreshElement) {
+ RefreshElement c = (RefreshElement) o;
+ return c.element.equals(element);
+ }
+ return false;
+ }
@Override
public int hashCode() {
- return element.hashCode() * 7 + 490487;
- }
+ return element.hashCode() * 7 + 490487;
+ }
}
protected final class RefreshProjectState implements IRefreshable {
@@ -403,17 +403,17 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
@Override
public boolean equals(Object o) {
- if (o instanceof RefreshElement) {
- RefreshElement c = (RefreshElement)o;
- return c.element.equals(element);
- }
- return false;
- }
+ if (o instanceof RefreshElement) {
+ RefreshElement c = (RefreshElement) o;
+ return c.element.equals(element);
+ }
+ return false;
+ }
@Override
public int hashCode() {
- return element.hashCode() * 11 + 490487;
- }
+ return element.hashCode() * 11 + 490487;
+ }
}
protected void postContainerRefresh(final IParent container, final ICProject cproject) {
@@ -441,7 +441,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
}
protected final void postRefreshable(final IRefreshable r) {
- Control ctrl= fViewer.getControl();
+ Control ctrl = fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
if (pendingRefreshes.contains(r))
return;
@@ -450,7 +450,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
@Override
public void run() {
pendingRefreshes.remove(r);
- Control ctrl= fViewer.getControl();
+ Control ctrl = fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
r.refresh();
}
@@ -459,11 +459,10 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
}
}
- @Override
+ @Override
public IRegion getSubject(ITextViewer textViewer, int offset) {
if (textViewer != null && fEditor != null) {
- IRegion region = CWordFinder.findWord(textViewer.getDocument(),
- offset);
+ IRegion region = CWordFinder.findWord(textViewer.getDocument(), offset);
if (region != null) {
return region;
}
@@ -472,17 +471,17 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
return null;
}
- @Override
+ @Override
public String getInformation(ITextViewer textViewer, IRegion subject) {
- // deprecated API - not used anymore
- Object info = getInformation2(textViewer, subject);
- if (info != null) {
- return info.toString();
- }
- return null;
- }
-
- @Override
+ // deprecated API - not used anymore
+ Object info = getInformation2(textViewer, subject);
+ if (info != null) {
+ return info.toString();
+ }
+ return null;
+ }
+
+ @Override
public Object getInformation2(ITextViewer textViewer, IRegion subject) {
if (fEditor == null)
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java
index b298fb7c85a..0550ed3d9f0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java
@@ -24,19 +24,19 @@ import org.eclipse.ui.model.WorkbenchAdapter;
public abstract class CElementGrouping extends WorkbenchAdapter implements IAdaptable {
public final static int INCLUDES_GROUPING = 0x00001;
-
+
/**
* @since 5.2
*/
public final static int MACROS_GROUPING = 0x00011;
-
+
public final static int NAMESPACE_GROUPING = 0x00010;
public final static int CLASS_GROUPING = 0x00100;
public final static int LIBRARY_REF_CONTAINER = 0x01000;
public final static int INCLUDE_REF_CONTAINER = 0x10000;
-
+
int type;
-
+
public CElementGrouping(int type) {
this.type = type;
}
@@ -51,10 +51,10 @@ public abstract class CElementGrouping extends WorkbenchAdapter implements IAdap
@Override
public String getLabel(Object object) {
switch (type) {
- case INCLUDES_GROUPING:
- return Messages.CElementGrouping_includeGroupingLabel;
- case MACROS_GROUPING:
- return Messages.CElementGrouping_macroGroupingLabel;
+ case INCLUDES_GROUPING:
+ return Messages.CElementGrouping_includeGroupingLabel;
+ case MACROS_GROUPING:
+ return Messages.CElementGrouping_macroGroupingLabel;
}
return super.getLabel(object);
}
@@ -65,14 +65,14 @@ public abstract class CElementGrouping extends WorkbenchAdapter implements IAdap
@Override
public ImageDescriptor getImageDescriptor(Object object) {
switch (type) {
- case INCLUDES_GROUPING:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCCONT);
- case NAMESPACE_GROUPING:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE);
- case CLASS_GROUPING:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
- case MACROS_GROUPING:
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
+ case INCLUDES_GROUPING:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCCONT);
+ case NAMESPACE_GROUPING:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE);
+ case CLASS_GROUPING:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
+ case MACROS_GROUPING:
+ return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
}
return super.getImageDescriptor(object);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java
index 6418b40ae96..e5a8b403bb7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java
@@ -25,96 +25,95 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.viewsupport.CustomBuildSettingsDecorator;
-
/**
* A CImageDescriptor consists of a base image and several adornments. The adornments
* are computed according to the flags either passed during creation or set via the method
- * <code>setAdornments</code>.
+ * <code>setAdornments</code>.
* </p>
* It is guaranteed that objects that conform to this interface are also instances of type
* <code>ImageDescriptor</code>
* </p>
- * <b>Note:</b> This class/interface is part of an interim API that is still under development
+ * <b>Note:</b> This class/interface is part of an interim API that is still under development
* and expected to change before reaching stability.
* </p>
- *
- * @since 2.0
+ *
+ * @since 2.0
*/
public class CElementImageDescriptor extends CompositeImageDescriptor {
-
+
/** Flag to render the abstract adornment */
- public final static int TEMPLATE= 0x001;
-
+ public final static int TEMPLATE = 0x001;
+
/** Flag to render the const adornment */
- public final static int CONSTANT= 0x002;
-
+ public final static int CONSTANT = 0x002;
+
/** Flag to render the volatile adornment */
- public final static int VOLATILE= 0x004;
-
+ public final static int VOLATILE = 0x004;
+
/** Flag to render the static adornment */
- public final static int STATIC= 0x008;
-
- /**
+ public final static int STATIC = 0x008;
+
+ /**
* @deprecated flag never had an effect
*/
@Deprecated
- public final static int RUNNABLE= 0x010;
-
+ public final static int RUNNABLE = 0x010;
+
/** Flag to render the warning adornment */
- public final static int WARNING= 0x020;
-
+ public final static int WARNING = 0x020;
+
/** Flag to render the error adornment */
- public final static int ERROR= 0x040;
-
- /**
- * @deprecated flag never had an effect
+ public final static int ERROR = 0x040;
+
+ /**
+ * @deprecated flag never had an effect
*/
@Deprecated
- public final static int OVERRIDES= 0x080;
-
- /**
- * @deprecated flag never had an effect
+ public final static int OVERRIDES = 0x080;
+
+ /**
+ * @deprecated flag never had an effect
*/
@Deprecated
- public final static int IMPLEMENTS= 0x100;
+ public final static int IMPLEMENTS = 0x100;
- /** Flag to render the 'relates to' adornment (for trees, an arrow down) */
- public final static int RELATES_TO= 0x200;
+ /** Flag to render the 'relates to' adornment (for trees, an arrow down) */
+ public final static int RELATES_TO = 0x200;
- /** Flag to render the 'relates to' adornment (for trees, two arrows down) */
- public final static int RELATES_TO_MULTIPLE= 0x400;
+ /** Flag to render the 'relates to' adornment (for trees, two arrows down) */
+ public final static int RELATES_TO_MULTIPLE = 0x400;
- /** Flag to render the 'referenced by' adornment (for trees, an arrow up) */
- public final static int REFERENCED_BY= 0x800;
+ /** Flag to render the 'referenced by' adornment (for trees, an arrow up) */
+ public final static int REFERENCED_BY = 0x800;
- /** Flag to render the 'recursive relation' adornment (for trees, an arrow pointing back) */
- public final static int RECURSIVE_RELATION= 0x1000;
-
- /** Flag to render the 'system include' adornment */
- public final static int SYSTEM_INCLUDE= 0x2000;
+ /** Flag to render the 'recursive relation' adornment (for trees, an arrow pointing back) */
+ public final static int RECURSIVE_RELATION = 0x1000;
- /** Flag to render the 'defines' adornment in the type hierarchy*/
- public final static int DEFINES= 0x4000;
+ /** Flag to render the 'system include' adornment */
+ public final static int SYSTEM_INCLUDE = 0x2000;
- /** Flag to render the 'inactive' adornment for include directives */
- public final static int INACTIVE= 0x8000;
+ /** Flag to render the 'defines' adornment in the type hierarchy*/
+ public final static int DEFINES = 0x4000;
- /** Flag to render the 'read access' adornment for references to variables or fields */
- public static final int READ_ACCESS = 0x10000;
+ /** Flag to render the 'inactive' adornment for include directives */
+ public final static int INACTIVE = 0x8000;
- /** Flag to render the 'read access' adornment for references to variables or fields */
- public static final int WRITE_ACCESS = 0x20000;
+ /** Flag to render the 'read access' adornment for references to variables or fields */
+ public static final int READ_ACCESS = 0x10000;
- /** Flag to render the 'external file' adornment for translation units */
+ /** Flag to render the 'read access' adornment for references to variables or fields */
+ public static final int WRITE_ACCESS = 0x20000;
+
+ /** Flag to render the 'external file' adornment for translation units */
public static final int EXTERNAL_FILE = 0x40000;
- /** Flag to render the 'custom settings' adornment. Do not use, this flag has been discontinued.
- * @since 5.2
- * @deprecated The constant has been discontinued since CDT 8.1. The adornment moved to separate class
- * {@link CustomBuildSettingsDecorator}.
- */
- @Deprecated
- public final static int SETTINGS= 0x80000;
+ /** Flag to render the 'custom settings' adornment. Do not use, this flag has been discontinued.
+ * @since 5.2
+ * @deprecated The constant has been discontinued since CDT 8.1. The adornment moved to separate class
+ * {@link CustomBuildSettingsDecorator}.
+ */
+ @Deprecated
+ public final static int SETTINGS = 0x80000;
private ImageDescriptor fBaseImage;
private int fFlags;
@@ -122,7 +121,7 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
/**
* Create a new CElementImageDescriptor.
- *
+ *
* @param baseImage an image descriptor used as the base image
* @param flags flags indicating which adornments are to be rendered. See <code>setAdornments</code>
* for valid values.
@@ -130,29 +129,29 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
* @see #setAdornments(int)
*/
public CElementImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
- fBaseImage= baseImage;
+ fBaseImage = baseImage;
Assert.isNotNull(fBaseImage);
- fFlags= flags;
+ fFlags = flags;
Assert.isTrue(fFlags >= 0);
- fSize= size;
+ fSize = size;
Assert.isNotNull(fSize);
}
-
+
/**
* Sets the descriptors adornments. Valid values are: <code>ABSTRACT</code>, <code>FINAL</code>,
- * </code>STATIC<code>, </code>WARNING<code>,
+ * </code>STATIC<code>, </code>WARNING<code>,
* </code>ERROR<code>, or any combination of those.
- *
+ *
* @param adornments the image descritpors adornments
*/
public void setAdornments(int adornments) {
Assert.isTrue(adornments >= 0);
- fFlags= adornments;
+ fFlags = adornments;
}
/**
* Returns the current adornments.
- *
+ *
* @return the current adornments
*/
public int getAdronments() {
@@ -161,24 +160,24 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
/**
* Sets the size of the image created by calling <code>createImage()</code>.
- *
+ *
* @param size the size of the image returned from calling <code>createImage()</code>
*/
public void setImageSize(Point size) {
Assert.isNotNull(size);
Assert.isTrue(size.x >= 0 && size.y >= 0);
- fSize= size;
+ fSize = size;
}
-
+
/**
* Returns the size of the image created by calling <code>createImage()</code>.
- *
+ *
* @return the size of the image created by calling <code>createImage</code>
*/
public Point getImageSize() {
return new Point(fSize.x, fSize.y);
}
-
+
/* (non-Javadoc)
* Method declared in CompositeImageDescriptor
*/
@@ -186,7 +185,7 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
protected Point getSize() {
return fSize;
}
-
+
/* (non-Javadoc)
* Method declared on Object.
*/
@@ -194,11 +193,11 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
public boolean equals(Object object) {
if (!CElementImageDescriptor.class.equals(object.getClass()))
return false;
-
- CElementImageDescriptor other= (CElementImageDescriptor)object;
+
+ CElementImageDescriptor other = (CElementImageDescriptor) object;
return (fBaseImage.equals(other.fBaseImage) && fFlags == other.fFlags && fSize.equals(other.fSize));
}
-
+
/* (non-Javadoc)
* Method declared on Object.
*/
@@ -206,44 +205,44 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
public int hashCode() {
return fBaseImage.hashCode() | fFlags | fSize.hashCode();
}
-
+
/* (non-Javadoc)
* Method declared in CompositeImageDescriptor
*/
@Override
protected void drawCompositeImage(int width, int height) {
ImageData bg;
- if ((bg= fBaseImage.getImageData()) == null)
- bg= DEFAULT_IMAGE_DATA;
-
+ if ((bg = fBaseImage.getImageData()) == null)
+ bg = DEFAULT_IMAGE_DATA;
+
drawImage(bg, 0, 0);
drawTopRight();
drawBottomRight();
drawBottomLeft();
drawTopLeft();
- }
-
- private void drawTopRight() {
- int x= getSize().x;
- ImageData data= null;
+ }
+
+ private void drawTopRight() {
+ int x = getSize().x;
+ ImageData data = null;
if ((fFlags & VOLATILE) != 0) {
- data= CPluginImages.DESC_OVR_VOLATILE.getImageData();
- x-= data.width;
+ data = CPluginImages.DESC_OVR_VOLATILE.getImageData();
+ x -= data.width;
drawImage(data, x, 0);
}
if ((fFlags & CONSTANT) != 0) {
- data= CPluginImages.DESC_OVR_CONSTANT.getImageData();
- x-= data.width;
+ data = CPluginImages.DESC_OVR_CONSTANT.getImageData();
+ x -= data.width;
drawImage(data, x, 0);
}
if ((fFlags & STATIC) != 0) {
- data= CPluginImages.DESC_OVR_STATIC.getImageData();
- x-= data.width;
+ data = CPluginImages.DESC_OVR_STATIC.getImageData();
+ x -= data.width;
drawImage(data, x, 0);
- }
+ }
if ((fFlags & TEMPLATE) != 0) {
- data= CPluginImages.DESC_OVR_TEMPLATE.getImageData();
- x-= data.width;
+ data = CPluginImages.DESC_OVR_TEMPLATE.getImageData();
+ x -= data.width;
drawImage(data, x, 0);
}
if ((fFlags & SYSTEM_INCLUDE) != 0) {
@@ -251,91 +250,85 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
x -= data.width;
drawImage(data, x, 0);
}
- }
-
+ }
+
private void drawBottomRight() {
- Point size= getSize();
- int x= size.x;
- ImageData data= null;
- if ((fFlags & RECURSIVE_RELATION) != 0) {
- data= CPluginImages.DESC_OVR_REC_RELATESTO.getImageData();
- x-= data.width;
- drawImage(data, x, size.y-data.height);
- }
- else if ((fFlags & RELATES_TO) != 0) {
- data= CPluginImages.DESC_OVR_RELATESTO.getImageData();
- x-= data.width;
- drawImage(data, x, size.y-data.height);
- }
- else if ((fFlags & RELATES_TO_MULTIPLE) != 0) {
- data= CPluginImages.DESC_OVR_RELATESTOMULTIPLE.getImageData();
- x-= data.width;
- drawImage(data, x, size.y-data.height);
- }
- else if ((fFlags & REFERENCED_BY) != 0) {
- data= CPluginImages.DESC_OVR_REFERENCEDBY.getImageData();
- x-= data.width;
- drawImage(data, x, size.y-data.height);
- }
-// if ((fFlags & OVERRIDES) != 0) {
-// data= CPluginImages.DESC_OVR_OVERRIDES.getImageData();
-// x-= data.width;
-// drawImage(data, x, size.y - data.height);
-// }
-// if ((fFlags & IMPLEMENTS) != 0) {
-// data= CPluginImages.DESC_OVR_IMPLEMENTS.getImageData();
-// x-= data.width;
-// drawImage(data, x, size.y - data.height);
-// }
- }
-
+ Point size = getSize();
+ int x = size.x;
+ ImageData data = null;
+ if ((fFlags & RECURSIVE_RELATION) != 0) {
+ data = CPluginImages.DESC_OVR_REC_RELATESTO.getImageData();
+ x -= data.width;
+ drawImage(data, x, size.y - data.height);
+ } else if ((fFlags & RELATES_TO) != 0) {
+ data = CPluginImages.DESC_OVR_RELATESTO.getImageData();
+ x -= data.width;
+ drawImage(data, x, size.y - data.height);
+ } else if ((fFlags & RELATES_TO_MULTIPLE) != 0) {
+ data = CPluginImages.DESC_OVR_RELATESTOMULTIPLE.getImageData();
+ x -= data.width;
+ drawImage(data, x, size.y - data.height);
+ } else if ((fFlags & REFERENCED_BY) != 0) {
+ data = CPluginImages.DESC_OVR_REFERENCEDBY.getImageData();
+ x -= data.width;
+ drawImage(data, x, size.y - data.height);
+ }
+ // if ((fFlags & OVERRIDES) != 0) {
+ // data= CPluginImages.DESC_OVR_OVERRIDES.getImageData();
+ // x-= data.width;
+ // drawImage(data, x, size.y - data.height);
+ // }
+ // if ((fFlags & IMPLEMENTS) != 0) {
+ // data= CPluginImages.DESC_OVR_IMPLEMENTS.getImageData();
+ // x-= data.width;
+ // drawImage(data, x, size.y - data.height);
+ // }
+ }
+
private void drawTopLeft() {
- ImageData data= null;
+ ImageData data = null;
if ((fFlags & DEFINES) != 0) {
- data= CPluginImages.DESC_OVR_DEFINES.getImageData();
+ data = CPluginImages.DESC_OVR_DEFINES.getImageData();
drawImage(data, 0, 0);
}
if ((fFlags & INACTIVE) != 0) {
- data= CPluginImages.DESC_OVR_INACTIVE.getImageData();
+ data = CPluginImages.DESC_OVR_INACTIVE.getImageData();
drawImage(data, 0, 0);
- }
-
- final boolean isReadAccess= (fFlags & READ_ACCESS) != 0;
- final boolean isWriteAccess= (fFlags & WRITE_ACCESS) != 0;
+ }
+
+ final boolean isReadAccess = (fFlags & READ_ACCESS) != 0;
+ final boolean isWriteAccess = (fFlags & WRITE_ACCESS) != 0;
if (isReadAccess) {
if (isWriteAccess) {
- data= CPluginImages.DESC_OVR_READ_WRITE_ACCESS.getImageData();
- }
- else {
- data= CPluginImages.DESC_OVR_READ_ACCESS.getImageData();
+ data = CPluginImages.DESC_OVR_READ_WRITE_ACCESS.getImageData();
+ } else {
+ data = CPluginImages.DESC_OVR_READ_ACCESS.getImageData();
}
drawImage(data, 0, 0);
- }
- else if (isWriteAccess) {
- data= CPluginImages.DESC_OVR_WRITE_ACCESS.getImageData();
+ } else if (isWriteAccess) {
+ data = CPluginImages.DESC_OVR_WRITE_ACCESS.getImageData();
drawImage(data, 0, 0);
}
-
+
if ((fFlags & EXTERNAL_FILE) != 0) {
- data= CPluginImages.DESC_OVR_EXTERNAL_FILE.getImageData();
+ data = CPluginImages.DESC_OVR_EXTERNAL_FILE.getImageData();
drawImage(data, 0, 0);
}
}
private void drawBottomLeft() {
- Point size= getSize();
- int x= 0;
- ImageData data= null;
+ Point size = getSize();
+ int x = 0;
+ ImageData data = null;
if ((fFlags & ERROR) != 0) {
- data= CPluginImages.DESC_OVR_ERROR.getImageData();
+ data = CPluginImages.DESC_OVR_ERROR.getImageData();
drawImage(data, x, size.y - data.height);
- x+= data.width;
+ x += data.width;
}
if ((fFlags & WARNING) != 0) {
- data= CPluginImages.DESC_OVR_WARNING.getImageData();
+ data = CPluginImages.DESC_OVR_WARNING.getImageData();
drawImage(data, x, size.y - data.height);
- x+= data.width;
+ x += data.width;
}
- }
+ }
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java
index d275dd7a8aa..904bf11a96c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java
@@ -61,30 +61,28 @@ public class CElementLabelProvider extends LabelProvider {
* Flag (bit mask) indicating that Complation Units, Class Files, Types, Declarations and Members
* should be rendered qualified.
* Examples: java.lang.String, java.util.Vector.size()
- *
+ *
* @since 2.0
*/
- public final static int SHOW_QUALIFIED= 0x400;
+ public final static int SHOW_QUALIFIED = 0x400;
/**
* Flag (bit mask) indicating that Compilation Units, Class Files, Types, Declarations and Members
* should be rendered qualified. The qualification is appended
* Examples: String - java.lang, size() - java.util.Vector
- *
+ *
* @since 2.0
*/
- public final static int SHOW_POST_QUALIFIED= 0x800;
-
-
+ public final static int SHOW_POST_QUALIFIED = 0x800;
+
/**
- * Constant (value <code>0</code>) indicating that the label should show
+ * Constant (value <code>0</code>) indicating that the label should show
* the basic images only.
*/
- public final static int SHOW_BASICS= 0x000;
-
-
- public final static int SHOW_DEFAULT= Integer.valueOf(SHOW_PARAMETERS | SHOW_OVERLAY_ICONS).intValue();
-
+ public final static int SHOW_BASICS = 0x000;
+
+ public final static int SHOW_DEFAULT = Integer.valueOf(SHOW_PARAMETERS | SHOW_OVERLAY_ICONS).intValue();
+
private volatile WorkbenchLabelProvider fWorkbenchLabelProvider;
protected CElementImageProvider fImageLabelProvider;
private CUILabelProvider fCElementLabelProvider;
@@ -101,21 +99,23 @@ public class CElementLabelProvider extends LabelProvider {
// WorkbenchLabelProvider may only be initialized on the UI thread
// http://bugs.eclipse.org/247274
if (Display.getCurrent() != null) {
- fWorkbenchLabelProvider= new WorkbenchLabelProvider();
+ fWorkbenchLabelProvider = new WorkbenchLabelProvider();
} else {
// Delay initialization
CUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (fCElementLabelProvider != null) {
- fWorkbenchLabelProvider= new WorkbenchLabelProvider();
+ fWorkbenchLabelProvider = new WorkbenchLabelProvider();
}
- }});
+ }
+ });
}
- fImageLabelProvider= new CElementImageProvider();
+ fImageLabelProvider = new CElementImageProvider();
fFlags = flags;
- fCElementLabelProvider= new CUILabelProvider(getTextFlags() | CElementLabels.TEMPLATE_PARAMETERS, getImageFlags());
+ fCElementLabelProvider = new CUILabelProvider(getTextFlags() | CElementLabels.TEMPLATE_PARAMETERS,
+ getImageFlags());
}
@Override
@@ -133,18 +133,18 @@ public class CElementLabelProvider extends LabelProvider {
public Image getImage(Object element) {
return fImageLabelProvider.getImageLabel(element, getImageFlags());
}
-
+
@Override
public void dispose() {
if (fCElementLabelProvider != null) {
fCElementLabelProvider.dispose();
- fCElementLabelProvider= null;
+ fCElementLabelProvider = null;
}
if (fWorkbenchLabelProvider != null) {
fWorkbenchLabelProvider.dispose();
- fWorkbenchLabelProvider= null;
+ fWorkbenchLabelProvider = null;
}
- if(fImageLabelProvider != null) {
+ if (fImageLabelProvider != null) {
fImageLabelProvider.dispose();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementSorter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementSorter.java
index 55e91543c42..6a968f4313d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementSorter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementSorter.java
@@ -52,12 +52,12 @@ import org.eclipse.cdt.core.model.ISourceRoot;
* 6 Source roots
* 5 C Elements
* 6 non C Elements
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
-public class CElementSorter extends ViewerSorter {
+public class CElementSorter extends ViewerSorter {
- protected static final int CMODEL = 0;
+ protected static final int CMODEL = 0;
protected static final int PROJECTS = 10;
protected static final int BINARYCONTAINER = 12;
protected static final int ARCHIVECONTAINER = 13;
@@ -72,7 +72,7 @@ public class CElementSorter extends ViewerSorter {
protected static final int TRANSLATIONUNITS = 22;
protected static final int BINARIES = 23;
protected static final int ARCHIVES = 24;
-
+
protected static final int INCLUDES = 28;
protected static final int MACROS = 29;
protected static final int USINGS = 30;
@@ -101,11 +101,10 @@ public class CElementSorter extends ViewerSorter {
protected static final int CELEMENTS_RESERVED = 101;
protected static final int CELEMENTS_SYSTEM = 102;
- protected static final int RESOURCEFOLDERS= 200;
- protected static final int RESOURCES= 201;
- protected static final int STORAGE= 202;
- protected static final int OTHERS= 500;
-
+ protected static final int RESOURCEFOLDERS = 200;
+ protected static final int RESOURCES = 201;
+ protected static final int STORAGE = 202;
+ protected static final int OTHERS = 500;
/*
* Constants added for names starting with '_' or '__'
@@ -128,20 +127,20 @@ public class CElementSorter extends ViewerSorter {
* otherwise header and source files will be sorted by name.
*/
private boolean fSeparateHeaderAndSource;
-
+
private boolean fKeepSortOrderOfExcludedFiles;
/**
* Default constructor for use as executable extension.
*/
public CElementSorter() {
- final IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- fSeparateHeaderAndSource= store.getBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE);
- fKeepSortOrderOfExcludedFiles= store.getBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES);
+ final IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ fSeparateHeaderAndSource = store.getBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE);
+ fKeepSortOrderOfExcludedFiles = store.getBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES);
}
-
+
@Override
- public int category (Object element) {
+ public int category(Object element) {
if (element instanceof ICElement) {
ICElement cElement = (ICElement) element;
switch (cElement.getElementType()) {
@@ -176,7 +175,7 @@ public class CElementSorter extends ViewerSorter {
case ICElement.C_USING:
return USINGS;
case ICElement.C_TYPEDEF:
- case ICElement.C_CLASS:
+ case ICElement.C_CLASS:
case ICElement.C_CLASS_DECLARATION:
case ICElement.C_TEMPLATE_CLASS:
case ICElement.C_TEMPLATE_CLASS_DECLARATION:
@@ -219,16 +218,16 @@ public class CElementSorter extends ViewerSorter {
case IResource.FOLDER:
return RESOURCEFOLDERS;
default: // translation unit that was excluded from the build
- if(fKeepSortOrderOfExcludedFiles &&
- CoreModel.isValidTranslationUnitName(resource.getProject(), resource.getName())) {
+ if (fKeepSortOrderOfExcludedFiles
+ && CoreModel.isValidTranslationUnitName(resource.getProject(), resource.getName())) {
return getTranslationUnitCategory(resource.getProject(), resource.getName());
- }
+ }
return RESOURCES;
}
} else if (element instanceof IStorage) {
return STORAGE;
} else if (element instanceof CElementGrouping) {
- int type = ((CElementGrouping)element).getType();
+ int type = ((CElementGrouping) element).getType();
switch (type) {
case CElementGrouping.INCLUDES_GROUPING:
return INCLUDES;
@@ -257,7 +256,7 @@ public class CElementSorter extends ViewerSorter {
}
return NORMAL;
}
-
+
private int getTranslationUnitCategory(IProject project, String name) {
if (fSeparateHeaderAndSource) {
if (CoreModel.isValidHeaderUnitName(project, name)) {
@@ -268,7 +267,7 @@ public class CElementSorter extends ViewerSorter {
}
}
return TRANSLATIONUNITS;
- }
+ }
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
@@ -282,14 +281,14 @@ public class CElementSorter extends ViewerSorter {
final Comparator<? super String> comparator = getComparator();
if (cat1 == PROJECTS) {
- IWorkbenchAdapter a1= ((IAdaptable)e1).getAdapter(IWorkbenchAdapter.class);
- IWorkbenchAdapter a2= ((IAdaptable)e2).getAdapter(IWorkbenchAdapter.class);
+ IWorkbenchAdapter a1 = ((IAdaptable) e1).getAdapter(IWorkbenchAdapter.class);
+ IWorkbenchAdapter a2 = ((IAdaptable) e2).getAdapter(IWorkbenchAdapter.class);
return comparator.compare(a1.getLabel(e1), a2.getLabel(e2));
}
if (cat1 == SOURCEROOTS) {
- ISourceRoot root1= getSourceRoot(e1);
- ISourceRoot root2= getSourceRoot(e2);
+ ISourceRoot root1 = getSourceRoot(e1);
+ ISourceRoot root2 = getSourceRoot(e2);
if (root1 == null) {
if (root2 == null) {
return 0;
@@ -297,10 +296,10 @@ public class CElementSorter extends ViewerSorter {
return 1;
} else if (root2 == null) {
return -1;
- }
+ }
if (!root1.getPath().equals(root2.getPath())) {
- int p1= getPathEntryIndex(root1);
- int p2= getPathEntryIndex(root2);
+ int p1 = getPathEntryIndex(root1);
+ int p2 = getPathEntryIndex(root2);
if (p1 != p2) {
return p1 - p2;
}
@@ -311,50 +310,50 @@ public class CElementSorter extends ViewerSorter {
if (cat1 == RESOURCES || cat1 == RESOURCEFOLDERS || cat1 == STORAGE || cat1 == OTHERS) {
return compareWithLabelProvider(viewer, e1, e2);
}
-
+
String ns1 = ""; //$NON-NLS-1$
String ns2 = ns1;
-
+
String name1;
String name2;
if (e1 instanceof ICElement) {
- name1 = ((ICElement)e1).getElementName();
+ name1 = ((ICElement) e1).getElementName();
int idx = name1.lastIndexOf("::"); //$NON-NLS-1$
if (idx >= 0) {
ns1 = name1.substring(0, idx);
name1 = name1.substring(idx + 2);
}
- if (name1.length() > 0 && name1.charAt(0) == '~') {
- name1 = name1.substring(1);
- }
+ if (name1.length() > 0 && name1.charAt(0) == '~') {
+ name1 = name1.substring(1);
+ }
} else if (e1 instanceof IResource) {
- name1 = ((IResource)e1).getName();
+ name1 = ((IResource) e1).getName();
} else {
name1 = e1.toString();
}
if (e2 instanceof ICElement) {
- name2 = ((ICElement)e2).getElementName();
+ name2 = ((ICElement) e2).getElementName();
int idx = name2.lastIndexOf("::"); //$NON-NLS-1$
if (idx >= 0) {
ns2 = name2.substring(0, idx);
name2 = name2.substring(idx + 2);
}
- if (name2.length() > 0 && name2.charAt(0) == '~') {
- name2 = name2.substring(1);
- }
- } else if(e2 instanceof IResource) {
- name2 = ((IResource)e2).getName();
+ if (name2.length() > 0 && name2.charAt(0) == '~') {
+ name2 = name2.substring(1);
+ }
+ } else if (e2 instanceof IResource) {
+ name2 = ((IResource) e2).getName();
} else {
name2 = e2.toString();
}
-
+
// compare namespace
int result = comparator.compare(ns1, ns2);
if (result != 0) {
return result;
}
-
+
// compare method/member kind
if (e1 instanceof IMethodDeclaration && e2 instanceof IMethodDeclaration) {
result = getMethodKind((IMethodDeclaration) e1) - getMethodKind((IMethodDeclaration) e2);
@@ -402,18 +401,18 @@ public class CElementSorter extends ViewerSorter {
}
private ISourceRoot getSourceRoot(Object element) {
- ICElement celement = (ICElement)element;
- while (! (celement instanceof ISourceRoot) && celement != null) {
+ ICElement celement = (ICElement) element;
+ while (!(celement instanceof ISourceRoot) && celement != null) {
celement = celement.getParent();
}
- return (ISourceRoot)celement;
+ return (ISourceRoot) celement;
}
private int compareWithLabelProvider(Viewer viewer, Object e1, Object e2) {
if (viewer instanceof ContentViewer) {
IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
if (prov instanceof ILabelProvider) {
- ILabelProvider lprov= (ILabelProvider) prov;
+ ILabelProvider lprov = (ILabelProvider) prov;
String name1 = lprov.getText(e1);
String name2 = lprov.getText(e2);
if (name1 != null && name2 != null) {
@@ -427,9 +426,9 @@ public class CElementSorter extends ViewerSorter {
private int getPathEntryIndex(ISourceRoot root) {
try {
- IPath rootPath= root.getPath();
- ISourceRoot[] roots= root.getCProject().getSourceRoots();
- for (int i= 0; i < roots.length; i++) {
+ IPath rootPath = root.getPath();
+ ISourceRoot[] roots = root.getCProject().getSourceRoots();
+ for (int i = 0; i < roots.length; i++) {
if (roots[i].getPath().equals(rootPath)) {
return i;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
index 620e583e397..210d75319e3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
@@ -127,10 +127,10 @@ public class CUIPlugin extends AbstractUIPlugin {
public static final String CVIEW_ID = PLUGIN_ID + ".CView"; //$NON-NLS-1$
public static final String C_PROBLEMMARKER = PLUGIN_CORE_ID + ".problem"; //$NON-NLS-1$
- public static final String ID_COMMENT_OWNER= PLUGIN_ID+".DocCommentOwner"; //$NON-NLS-1$
+ public static final String ID_COMMENT_OWNER = PLUGIN_ID + ".DocCommentOwner"; //$NON-NLS-1$
- public static final String ID_INCLUDE_BROWSER= PLUGIN_ID + ".includeBrowser"; //$NON-NLS-1$
- public static final String ID_CALL_HIERARCHY= PLUGIN_ID + ".callHierarchy"; //$NON-NLS-1$
+ public static final String ID_INCLUDE_BROWSER = PLUGIN_ID + ".includeBrowser"; //$NON-NLS-1$
+ public static final String ID_CALL_HIERARCHY = PLUGIN_ID + ".callHierarchy"; //$NON-NLS-1$
public static final String ID_TYPE_HIERARCHY = PLUGIN_ID + ".typeHierarchy"; //$NON-NLS-1$
public static final String C_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCWizard"; //$NON-NLS-1$
@@ -147,7 +147,7 @@ public class CUIPlugin extends AbstractUIPlugin {
private static CUIPlugin fgCPlugin;
private static ResourceBundle fgResourceBundle;
- private static final String CONTENTASSIST = CUIPlugin.PLUGIN_ID + "/debug/contentassist" ; //$NON-NLS-1$
+ private static final String CONTENTASSIST = CUIPlugin.PLUGIN_ID + "/debug/contentassist"; //$NON-NLS-1$
/**
* The id of the C perspective
@@ -222,7 +222,7 @@ public class CUIPlugin extends AbstractUIPlugin {
* The key to store customized templates.
* @since 3.0
*/
- private static final String CUSTOM_TEMPLATES_KEY= "org.eclipse.cdt.ui.text.templates.custom"; //$NON-NLS-1$
+ private static final String CUSTOM_TEMPLATES_KEY = "org.eclipse.cdt.ui.text.templates.custom"; //$NON-NLS-1$
/**
* The id of the C Element Creation action set
@@ -230,7 +230,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*
* @since 2.0
*/
- public static final String ID_CELEMENT_CREATION_ACTION_SET= "org.eclipse.cdt.ui.CElementCreationActionSet"; //$NON-NLS-1$
+ public static final String ID_CELEMENT_CREATION_ACTION_SET = "org.eclipse.cdt.ui.CElementCreationActionSet"; //$NON-NLS-1$
/**
* The id of the scope used by all the CDT views
@@ -243,7 +243,7 @@ public class CUIPlugin extends AbstractUIPlugin {
* The key to store customized code templates.
* @since 5.0
*/
- private static final String CODE_TEMPLATES_KEY= "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$
+ private static final String CODE_TEMPLATES_KEY = "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$
// -------- static methods --------
@@ -307,11 +307,11 @@ public class CUIPlugin extends AbstractUIPlugin {
}
public static Shell getActiveWorkbenchShell() {
- IWorkbenchWindow window= getActiveWorkbenchWindow();
- if (window != null) {
- return window.getShell();
- }
- return null;
+ IWorkbenchWindow window = getActiveWorkbenchWindow();
+ if (window != null) {
+ return window.getShell();
+ }
+ return null;
}
public static CUIPlugin getDefault() {
@@ -377,7 +377,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public static void errorDialog(Shell shell, String title, String message, IStatus s, boolean logError) {
if (logError)
- log(s);
+ log(s);
// if the 'message' resource string and the IStatus' message are the same,
// don't show both in the dialog
@@ -558,7 +558,7 @@ public class CUIPlugin extends AbstractUIPlugin {
Assert.isNotNull(contextId);
BuildConsoleManager manager = fBuildConsoleManagers.get(contextId);
- if (manager == null ) {
+ if (manager == null) {
manager = new BuildConsoleManager();
fBuildConsoleManagers.put(contextId, manager);
manager.startup(name, contextId, iconUrl);
@@ -586,11 +586,12 @@ public class CUIPlugin extends AbstractUIPlugin {
// Initialize AST provider
getASTProvider();
- fThemeListener= new IPropertyChangeListener() {
+ fThemeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty()))
- CUIPreferenceInitializer.setThemeBasedPreferences(PreferenceConstants.getPreferenceStore(), true);
+ CUIPreferenceInitializer.setThemeBasedPreferences(PreferenceConstants.getPreferenceStore(),
+ true);
}
};
PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(fThemeListener);
@@ -618,15 +619,15 @@ public class CUIPlugin extends AbstractUIPlugin {
prefsJob.schedule();
// Start make.ui plug-in, such that it can check for project conversions.
- Job job= new Job(Messages.CUIPlugin_jobStartMakeUI) {
+ Job job = new Job(Messages.CUIPlugin_jobStartMakeUI) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- Bundle bundle= Platform.getBundle("org.eclipse.cdt.make.ui"); //$NON-NLS-1$
+ Bundle bundle = Platform.getBundle("org.eclipse.cdt.make.ui"); //$NON-NLS-1$
try {
if (bundle != null) {
switch (bundle.getState()) {
case Bundle.RESOLVED:
- case Bundle.STARTING: // Because make.ui uses lazy activation, we need to start it.
+ case Bundle.STARTING: // Because make.ui uses lazy activation, we need to start it.
bundle.start(Bundle.START_TRANSIENT);
break;
}
@@ -646,20 +647,20 @@ public class CUIPlugin extends AbstractUIPlugin {
CDTContextActivator.getInstance().uninstall();
if (fASTProvider != null) {
fASTProvider.dispose();
- fASTProvider= null;
+ fASTProvider = null;
}
if (fTextTools != null) {
fTextTools.dispose();
- fTextTools= null;
+ fTextTools = null;
}
if (fImageDescriptorRegistry != null) {
fImageDescriptorRegistry.dispose();
- fImageDescriptorRegistry= null;
+ fImageDescriptorRegistry = null;
}
- if (fBuildConsoleManagers != null ) {
+ if (fBuildConsoleManagers != null) {
Object[] bcm = fBuildConsoleManagers.values().toArray();
for (Object element : bcm) {
- BuildConsoleManager m = (BuildConsoleManager)element;
+ BuildConsoleManager m = (BuildConsoleManager) element;
if (m != null)
m.shutdown();
}
@@ -672,19 +673,19 @@ public class CUIPlugin extends AbstractUIPlugin {
if (fWorkingCopyManager != null) {
fWorkingCopyManager.shutdown();
- fWorkingCopyManager= null;
+ fWorkingCopyManager = null;
}
if (fDocumentProvider != null) {
fDocumentProvider.shutdown();
- fDocumentProvider= null;
+ fDocumentProvider = null;
}
ContentAssistPreference.shutdown();
if (fThemeListener != null) {
PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(fThemeListener);
- fThemeListener= null;
+ fThemeListener = null;
}
// Do this last.
@@ -751,7 +752,7 @@ public class CUIPlugin extends AbstractUIPlugin {
if (isDebugging()) {
String option = Platform.getDebugOption(CONTENTASSIST);
if (option != null)
- Util.VERBOSE_CONTENTASSIST = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
+ Util.VERBOSE_CONTENTASSIST = option.equalsIgnoreCase("true"); //$NON-NLS-1$
}
}
@@ -764,11 +765,8 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public IPreferenceStore getCombinedPreferenceStore() {
if (fCombinedPreferenceStore == null) {
- fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] {
- getPreferenceStore(),
- getCorePreferenceStore(),
- EditorsUI.getPreferenceStore()
- });
+ fCombinedPreferenceStore = new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(),
+ getCorePreferenceStore(), EditorsUI.getPreferenceStore() });
}
return fCombinedPreferenceStore;
}
@@ -780,7 +778,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public IPreferenceStore getCorePreferenceStore() {
if (fCorePreferenceStore == null) {
- fCorePreferenceStore= new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_CORE_ID);
+ fCorePreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_CORE_ID);
}
return fCorePreferenceStore;
}
@@ -793,10 +791,10 @@ public class CUIPlugin extends AbstractUIPlugin {
* @since 5.3
*/
public IDialogSettings getDialogSettingsSection(String name) {
- IDialogSettings dialogSettings= getDialogSettings();
- IDialogSettings section= dialogSettings.getSection(name);
+ IDialogSettings dialogSettings = getDialogSettings();
+ IDialogSettings section = dialogSettings.getSection(name);
if (section == null) {
- section= dialogSettings.addNewSection(name);
+ section = dialogSettings.addNewSection(name);
}
return section;
}
@@ -808,15 +806,15 @@ public class CUIPlugin extends AbstractUIPlugin {
* @return an array of all dirty editor parts.
*/
public static IEditorPart[] getDirtyEditors() {
- Set<IEditorInput> inputs= new HashSet<IEditorInput>();
- List<IEditorPart> result= new ArrayList<IEditorPart>(0);
- IWorkbench workbench= getDefault().getWorkbench();
+ Set<IEditorInput> inputs = new HashSet<IEditorInput>();
+ List<IEditorPart> result = new ArrayList<IEditorPart>(0);
+ IWorkbench workbench = getDefault().getWorkbench();
for (IWorkbenchWindow window : workbench.getWorkbenchWindows()) {
for (IWorkbenchPage page : window.getPages()) {
for (IEditorReference editorRef : page.getEditorReferences()) {
- IEditorPart ep= editorRef.getEditor(false);
- if (ep instanceof ITextEditor && ep.isDirty()) {
- IEditorInput input= ep.getEditorInput();
+ IEditorPart ep = editorRef.getEditor(false);
+ if (ep instanceof ITextEditor && ep.isDirty()) {
+ IEditorInput input = ep.getEditorInput();
if (!inputs.contains(input)) {
inputs.add(input);
result.add(ep);
@@ -827,20 +825,20 @@ public class CUIPlugin extends AbstractUIPlugin {
}
return result.toArray(new IEditorPart[result.size()]);
}
-
+
/**
* Returns an array of all instantiated editors.
*/
public static IEditorPart[] getInstanciatedEditors() {
- List<IEditorPart> result= new ArrayList<IEditorPart>(0);
- IWorkbench workbench= getDefault().getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
+ List<IEditorPart> result = new ArrayList<IEditorPart>(0);
+ IWorkbench workbench = getDefault().getWorkbench();
+ IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
for (IWorkbenchWindow window : windows) {
- IWorkbenchPage[] pages= window.getPages();
+ IWorkbenchPage[] pages = window.getPages();
for (IWorkbenchPage page : pages) {
- IEditorReference[] references= page.getEditorReferences();
+ IEditorReference[] references = page.getEditorReferences();
for (IEditorReference reference : references) {
- IEditorPart editor= reference.getEditor(false);
+ IEditorPart editor = reference.getEditor(false);
if (editor != null)
result.add(editor);
}
@@ -855,9 +853,9 @@ public class CUIPlugin extends AbstractUIPlugin {
* display is returned. Otherwise the method returns the default display.
*/
public static Display getStandardDisplay() {
- Display display= Display.getCurrent();
+ Display display = Display.getCurrent();
if (display == null) {
- display= Display.getDefault();
+ display = Display.getDefault();
}
return display;
}
@@ -892,52 +890,53 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public CEditorTextHoverDescriptor[] getCEditorTextHoverDescriptors() {
if (fCEditorTextHoverDescriptors == null) {
- fCEditorTextHoverDescriptors= CEditorTextHoverDescriptor.getContributedHovers();
- ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
+ fCEditorTextHoverDescriptors = CEditorTextHoverDescriptor.getContributedHovers();
+ ConfigurationElementSorter sorter = new ConfigurationElementSorter() {
/**
* {@inheritDoc}
*/
@Override
public IConfigurationElement getConfigurationElement(Object object) {
- return ((CEditorTextHoverDescriptor)object).getConfigurationElement();
+ return ((CEditorTextHoverDescriptor) object).getConfigurationElement();
}
};
sorter.sort(fCEditorTextHoverDescriptors);
// The Problem hover has to be the first and the Annotation hover has to be the last one in the CDT UI's hover list
- int length= fCEditorTextHoverDescriptors.length;
- int first= -1;
- int last= length - 1;
- int problemHoverIndex= -1;
- int annotationHoverIndex= -1;
- for (int i= 0; i < length; i++) {
+ int length = fCEditorTextHoverDescriptors.length;
+ int first = -1;
+ int last = length - 1;
+ int problemHoverIndex = -1;
+ int annotationHoverIndex = -1;
+ for (int i = 0; i < length; i++) {
if (!fCEditorTextHoverDescriptors[i].getId().startsWith(PLUGIN_ID)) {
if (problemHoverIndex == -1 || annotationHoverIndex == -1) {
continue;
}
- last= i - 1;
+ last = i - 1;
break;
}
if (first == -1)
- first= i;
+ first = i;
if (fCEditorTextHoverDescriptors[i].getId().equals("org.eclipse.cdt.ui.AnnotationHover")) { //$NON-NLS-1$
- annotationHoverIndex= i;
+ annotationHoverIndex = i;
continue;
}
if (fCEditorTextHoverDescriptors[i].getId().equals("org.eclipse.cdt.ui.ProblemHover")) { //$NON-NLS-1$
- problemHoverIndex= i;
+ problemHoverIndex = i;
continue;
}
}
- CEditorTextHoverDescriptor hoverDescriptor= null;
+ CEditorTextHoverDescriptor hoverDescriptor = null;
if (first > -1 && problemHoverIndex > -1 && problemHoverIndex > first) {
// move problem hover to beginning
- hoverDescriptor= fCEditorTextHoverDescriptors[problemHoverIndex];
- System.arraycopy(fCEditorTextHoverDescriptors, first, fCEditorTextHoverDescriptors, first+1, problemHoverIndex - first);
- fCEditorTextHoverDescriptors[first]= hoverDescriptor;
+ hoverDescriptor = fCEditorTextHoverDescriptors[problemHoverIndex];
+ System.arraycopy(fCEditorTextHoverDescriptors, first, fCEditorTextHoverDescriptors, first + 1,
+ problemHoverIndex - first);
+ fCEditorTextHoverDescriptors[first] = hoverDescriptor;
// update annotation hover index if needed
if (annotationHoverIndex >= first && annotationHoverIndex < problemHoverIndex)
@@ -946,19 +945,20 @@ public class CUIPlugin extends AbstractUIPlugin {
if (annotationHoverIndex > -1 && annotationHoverIndex < last) {
// move annotation hover to end
- hoverDescriptor= fCEditorTextHoverDescriptors[annotationHoverIndex];
- System.arraycopy(fCEditorTextHoverDescriptors, annotationHoverIndex+1, fCEditorTextHoverDescriptors, annotationHoverIndex, last - annotationHoverIndex);
- fCEditorTextHoverDescriptors[last]= hoverDescriptor;
+ hoverDescriptor = fCEditorTextHoverDescriptors[annotationHoverIndex];
+ System.arraycopy(fCEditorTextHoverDescriptors, annotationHoverIndex + 1, fCEditorTextHoverDescriptors,
+ annotationHoverIndex, last - annotationHoverIndex);
+ fCEditorTextHoverDescriptors[last] = hoverDescriptor;
}
// Move Best Match hover to front
- for (int i= 0; i < length; i++) {
+ for (int i = 0; i < length; i++) {
if (PreferenceConstants.ID_BESTMATCH_HOVER.equals(fCEditorTextHoverDescriptors[i].getId())) {
if (i > 0) {
// move to top
- CEditorTextHoverDescriptor bestMatchHover= fCEditorTextHoverDescriptors[i];
+ CEditorTextHoverDescriptor bestMatchHover = fCEditorTextHoverDescriptors[i];
System.arraycopy(fCEditorTextHoverDescriptors, 0, fCEditorTextHoverDescriptors, 1, i);
- fCEditorTextHoverDescriptors[0]= bestMatchHover;
+ fCEditorTextHoverDescriptors[0] = bestMatchHover;
}
break;
}
@@ -977,7 +977,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*
*/
public void resetCEditorTextHoverDescriptors() {
- fCEditorTextHoverDescriptors= null;
+ fCEditorTextHoverDescriptors = null;
}
/**
@@ -991,7 +991,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public synchronized CFoldingStructureProviderRegistry getFoldingStructureProviderRegistry() {
if (fFoldingStructureProviderRegistry == null)
- fFoldingStructureProviderRegistry= new CFoldingStructureProviderRegistry();
+ fFoldingStructureProviderRegistry = new CFoldingStructureProviderRegistry();
return fFoldingStructureProviderRegistry;
}
@@ -1003,7 +1003,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public ContextTypeRegistry getTemplateContextRegistry() {
if (fContextTypeRegistry == null) {
- fContextTypeRegistry= new ContributionContextTypeRegistry(EDITOR_ID);
+ fContextTypeRegistry = new ContributionContextTypeRegistry(EDITOR_ID);
fContextTypeRegistry.addContextType(CContextType.ID);
fContextTypeRegistry.addContextType(CommentContextType.ID);
fContextTypeRegistry.addContextType(DocCommentContextType.ID);
@@ -1019,7 +1019,8 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public TemplateStore getTemplateStore() {
if (fTemplateStore == null) {
- fTemplateStore = new ContributionTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), CUSTOM_TEMPLATES_KEY);
+ fTemplateStore = new ContributionTemplateStore(getTemplateContextRegistry(), getPreferenceStore(),
+ CUSTOM_TEMPLATES_KEY);
try {
fTemplateStore.load();
} catch (IOException e) {
@@ -1039,7 +1040,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public ContextTypeRegistry getCodeTemplateContextRegistry() {
if (fCodeTemplateContextTypeRegistry == null) {
- fCodeTemplateContextTypeRegistry= new ContributionContextTypeRegistry("org.eclipse.cdt.ui.codeTemplates"); //$NON-NLS-1$
+ fCodeTemplateContextTypeRegistry = new ContributionContextTypeRegistry("org.eclipse.cdt.ui.codeTemplates"); //$NON-NLS-1$
CodeTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry);
FileTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry);
@@ -1056,8 +1057,9 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public TemplateStore getCodeTemplateStore() {
if (fCodeTemplateStore == null) {
- IPreferenceStore store= getPreferenceStore();
- fCodeTemplateStore= new ContributionTemplateStore(getCodeTemplateContextRegistry(), store, CODE_TEMPLATES_KEY);
+ IPreferenceStore store = getPreferenceStore();
+ fCodeTemplateStore = new ContributionTemplateStore(getCodeTemplateContextRegistry(), store,
+ CODE_TEMPLATES_KEY);
try {
fCodeTemplateStore.load();
@@ -1081,7 +1083,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public synchronized ASTProvider getASTProvider() {
if (fASTProvider == null)
- fASTProvider= new ASTProvider();
+ fASTProvider = new ASTProvider();
return fASTProvider;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java
index a23395e0545..192e78d597b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java
@@ -46,7 +46,7 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
final IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- PreferenceConstants.initializeDefaultValues(store);
+ PreferenceConstants.initializeDefaultValues(store);
CPluginPreferencePage.initDefaults(store);
BuildConsolePreferencePage.initDefaults(store, true);
CView.initDefaults(store);
@@ -61,9 +61,9 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer {
// All of those settings are now in the workbench "All TextEditor" preference Page.
// Later we should remove this calls, after CDT-3.0
EditorsUI.useAnnotationsPreferencePage(store);
- EditorsUI.useQuickDiffPreferencePage(store);
+ EditorsUI.useQuickDiffPreferencePage(store);
useTextEditorPreferencePage(store);
-
+
store.setDefault(CDTPrefUtil.KEY_OTHERS, true);
}
@@ -101,97 +101,54 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer {
}
static void setThemeBasedPreferences(IPreferenceStore store, boolean fireEvent) {
- ColorRegistry registry= null;
+ ColorRegistry registry = null;
if (PlatformUI.isWorkbenchRunning())
- registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
+ registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
- setDefault(
- store,
- PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_TASK_TAG_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_TASK_TAG_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_C_KEYWORD_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_C_KEYWORD_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_C_KEYWORD_COLOR, new RGB(127, 0, 85)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_C_BUILTIN_TYPE_COLOR, new RGB(127, 0, 85)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_C_STRING_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_C_STRING_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_C_STRING_COLOR, new RGB(42, 0, 255)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_C_DEFAULT_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_C_DEFAULT_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_C_DEFAULT_COLOR, new RGB(0, 0, 0)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_C_OPERATOR_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_C_OPERATOR_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_C_OPERATOR_COLOR, new RGB(0, 0, 0)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_C_BRACES_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_C_BRACES_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_C_BRACES_COLOR, new RGB(0, 0, 0)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_C_NUMBER_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_C_NUMBER_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_C_NUMBER_COLOR, new RGB(0, 0, 0)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_PP_DIRECTIVE_COLOR, new RGB(127, 0, 85)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_PP_HEADER_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_PP_HEADER_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_PP_HEADER_COLOR, new RGB(42, 0, 255)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_PP_DEFAULT_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_PP_DEFAULT_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_PP_DEFAULT_COLOR, new RGB(0, 0, 0)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_ASM_LABEL_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_ASM_LABEL_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_ASM_LABEL_COLOR, new RGB(127, 0, 85)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR,
+ setDefault(store, PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR,
findRGB(registry, ICThemeConstants.EDITOR_ASM_DIRECTIVE_COLOR, new RGB(127, 0, 85)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND,
+ setDefault(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND,
findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(255, 255, 255)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND,
+ setDefault(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND,
findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND,
- findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(255, 255, 255)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND,
+ setDefault(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND,
+ findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(255, 255, 255)),
+ fireEvent);
+ setDefault(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND,
findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR,
+ setDefault(store, PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR,
findRGB(registry, ICThemeConstants.DOXYGEN_MULTI_LINE_COLOR, new RGB(63, 95, 191)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR,
+ setDefault(store, PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR,
findRGB(registry, ICThemeConstants.DOXYGEN_SINGLE_LINE_COLOR, new RGB(63, 95, 191)), fireEvent);
- setDefault(
- store,
- PreferenceConstants.DOXYGEN_TAG_COLOR,
+ setDefault(store, PreferenceConstants.DOXYGEN_TAG_COLOR,
findRGB(registry, ICThemeConstants.DOXYGEN_TAG_COLOR, new RGB(127, 159, 191)), fireEvent);
}
@@ -211,9 +168,9 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer {
return;
}
- RGB oldValue= null;
+ RGB oldValue = null;
if (store.isDefault(key))
- oldValue= PreferenceConverter.getDefaultColor(store, key);
+ oldValue = PreferenceConverter.getDefaultColor(store, key);
PreferenceConverter.setDefault(store, key, newValue);
@@ -234,7 +191,7 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer {
if (registry == null)
return defaultRGB;
- RGB rgb= registry.getRGB(key);
+ RGB rgb = registry.getRGB(key);
if (rgb != null)
return rgb;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CodeGeneration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CodeGeneration.java
index 3584ad6b72c..16354932db7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CodeGeneration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CodeGeneration.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Rational Software - initial implementation
* Anton Leherbauer (Wind River Systems)
@@ -24,7 +24,7 @@ import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
/**
* Class that offers access to the templates contained in the 'Code Templates' preference page.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
* @since 2.1
@@ -43,10 +43,9 @@ public class CodeGeneration {
* @throws CoreException
* @since 5.3
*/
- public static String getHeaderFileContent(Template template, ITranslationUnit tu,
- String lineDelimiter) throws CoreException {
- return getHeaderFileContent(template, tu, null, null, null, null, null, null, null,
- lineDelimiter);
+ public static String getHeaderFileContent(Template template, ITranslationUnit tu, String lineDelimiter)
+ throws CoreException {
+ return getHeaderFileContent(template, tu, null, null, null, null, null, null, null, lineDelimiter);
}
/**
@@ -60,10 +59,9 @@ public class CodeGeneration {
* @return Returns the new content or <code>null</code> if the template is undefined or empty.
* @throws CoreException
*/
- public static String getHeaderFileContent(ITranslationUnit tu, String typeComment,
- String typeContent, String lineDelimiter) throws CoreException {
- return getHeaderFileContent(tu, null, null, null, null, typeComment, typeContent, null,
- lineDelimiter);
+ public static String getHeaderFileContent(ITranslationUnit tu, String typeComment, String typeContent,
+ String lineDelimiter) throws CoreException {
+ return getHeaderFileContent(tu, null, null, null, null, typeComment, typeContent, null, lineDelimiter);
}
/**
@@ -78,10 +76,10 @@ public class CodeGeneration {
* @return Returns the new content or <code>null</code> if the template is undefined or empty.
* @throws CoreException
*/
- public static String getHeaderFileContent(Template template, ITranslationUnit tu,
- String typeComment, String typeContent, String lineDelimiter) throws CoreException {
- return getHeaderFileContent(template, tu, null, null, null, null, typeComment, typeContent,
- null, lineDelimiter);
+ public static String getHeaderFileContent(Template template, ITranslationUnit tu, String typeComment,
+ String typeContent, String lineDelimiter) throws CoreException {
+ return getHeaderFileContent(template, tu, null, null, null, null, typeComment, typeContent, null,
+ lineDelimiter);
}
/**
@@ -104,12 +102,11 @@ public class CodeGeneration {
* @throws CoreException
* @since 5.3
*/
- public static String getHeaderFileContent(ITranslationUnit tu, String includes,
- String namespaceBegin, String namespaceEnd, String namespaceName, String typeComment,
- String typeContent, String typeName, String lineDelimiter) throws CoreException {
- return StubUtility.getHeaderFileContent(tu, typeContent,
- getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
- namespaceName, typeComment, typeName, lineDelimiter);
+ public static String getHeaderFileContent(ITranslationUnit tu, String includes, String namespaceBegin,
+ String namespaceEnd, String namespaceName, String typeComment, String typeContent, String typeName,
+ String lineDelimiter) throws CoreException {
+ return StubUtility.getHeaderFileContent(tu, typeContent, getFileComment(tu, lineDelimiter), includes,
+ namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName, lineDelimiter);
}
/**
@@ -133,13 +130,11 @@ public class CodeGeneration {
* @throws CoreException
* @since 5.3
*/
- public static String getHeaderFileContent(Template template, ITranslationUnit tu,
- String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
- String typeComment, String typeContent, String typeName, String lineDelimiter)
- throws CoreException {
- return StubUtility.getHeaderFileContent(template, tu, typeContent,
- getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
- namespaceName, typeComment, typeName, lineDelimiter);
+ public static String getHeaderFileContent(Template template, ITranslationUnit tu, String includes,
+ String namespaceBegin, String namespaceEnd, String namespaceName, String typeComment, String typeContent,
+ String typeName, String lineDelimiter) throws CoreException {
+ return StubUtility.getHeaderFileContent(template, tu, typeContent, getFileComment(tu, lineDelimiter), includes,
+ namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName, lineDelimiter);
}
/**
@@ -153,10 +148,9 @@ public class CodeGeneration {
* @return Returns the new content or <code>null</code> if the template is undefined or empty.
* @throws CoreException
*/
- public static String getBodyFileContent(ITranslationUnit tu, String typeComment,
- String typeContent, String lineDelimiter) throws CoreException {
- return getBodyFileContent(tu, typeContent, null, null, null, null, typeComment, null,
- lineDelimiter);
+ public static String getBodyFileContent(ITranslationUnit tu, String typeComment, String typeContent,
+ String lineDelimiter) throws CoreException {
+ return getBodyFileContent(tu, typeContent, null, null, null, null, typeComment, null, lineDelimiter);
}
/**
@@ -171,10 +165,9 @@ public class CodeGeneration {
* @return Returns the new content or <code>null</code> if the template is undefined or empty.
* @throws CoreException
*/
- public static String getBodyFileContent(Template template, ITranslationUnit tu,
- String typeComment, String typeContent, String lineDelimiter) throws CoreException {
- return getBodyFileContent(template, tu, typeContent, null, null, null, null, typeComment,
- null, lineDelimiter);
+ public static String getBodyFileContent(Template template, ITranslationUnit tu, String typeComment,
+ String typeContent, String lineDelimiter) throws CoreException {
+ return getBodyFileContent(template, tu, typeContent, null, null, null, null, typeComment, null, lineDelimiter);
}
/**
@@ -197,13 +190,11 @@ public class CodeGeneration {
* @throws CoreException
* @since 5.3
*/
- public static String getBodyFileContent(ITranslationUnit tu,
- String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
- String typeComment, String typeContent, String typeName, String lineDelimiter)
- throws CoreException {
- return StubUtility.getBodyFileContent(tu, typeContent, getFileComment(tu, lineDelimiter),
- includes, namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName,
- lineDelimiter);
+ public static String getBodyFileContent(ITranslationUnit tu, String includes, String namespaceBegin,
+ String namespaceEnd, String namespaceName, String typeComment, String typeContent, String typeName,
+ String lineDelimiter) throws CoreException {
+ return StubUtility.getBodyFileContent(tu, typeContent, getFileComment(tu, lineDelimiter), includes,
+ namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName, lineDelimiter);
}
/**
@@ -227,13 +218,11 @@ public class CodeGeneration {
* @throws CoreException
* @since 5.3
*/
- public static String getBodyFileContent(Template template, ITranslationUnit tu,
- String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
- String typeComment, String typeContent, String typeName, String lineDelimiter)
- throws CoreException {
- return StubUtility.getBodyFileContent(template, tu, typeContent,
- getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
- namespaceName, typeComment, typeName, lineDelimiter);
+ public static String getBodyFileContent(Template template, ITranslationUnit tu, String includes,
+ String namespaceBegin, String namespaceEnd, String namespaceName, String typeComment, String typeContent,
+ String typeName, String lineDelimiter) throws CoreException {
+ return StubUtility.getBodyFileContent(template, tu, typeContent, getFileComment(tu, lineDelimiter), includes,
+ namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName, lineDelimiter);
}
/**
@@ -254,104 +243,99 @@ public class CodeGeneration {
* @throws CoreException
* @since 5.3
*/
- public static String getTestFileContent(ITranslationUnit tu,
- String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
- String testCases, String typeName, String lineDelimiter) throws CoreException {
- return StubUtility.getTestFileContent(tu, testCases, getFileComment(tu, lineDelimiter),
- includes, namespaceBegin, namespaceEnd, namespaceName, typeName, lineDelimiter);
+ public static String getTestFileContent(ITranslationUnit tu, String includes, String namespaceBegin,
+ String namespaceEnd, String namespaceName, String testCases, String typeName, String lineDelimiter)
+ throws CoreException {
+ return StubUtility.getTestFileContent(tu, testCases, getFileComment(tu, lineDelimiter), includes,
+ namespaceBegin, namespaceEnd, namespaceName, typeName, lineDelimiter);
}
/**
* Returns the content of the body for a method using the method body template.
* <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit does not need to exist.
* @param typeName Name of the type to which the method belongs.
* @param methodName Name of the method.
- * @param bodyStatement The code to be entered at the place of the variable ${body_statement}.
+ * @param bodyStatement The code to be entered at the place of the variable ${body_statement}.
* @param lineDelimiter The line delimiter to be used.
* @return Returns the constructed body content or <code>null</code> if
* the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
- */
- public static String getMethodBodyContent(ITranslationUnit tu, String typeName,
- String methodName, String bodyStatement, String lineDelimiter) throws CoreException {
- return StubUtility.getMethodBodyContent(tu.getCProject(), typeName, methodName,
- bodyStatement, lineDelimiter);
+ */
+ public static String getMethodBodyContent(ITranslationUnit tu, String typeName, String methodName,
+ String bodyStatement, String lineDelimiter) throws CoreException {
+ return StubUtility.getMethodBodyContent(tu.getCProject(), typeName, methodName, bodyStatement, lineDelimiter);
}
/**
* Returns the content of the body for a constructor using the constructor body template.
* <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit
* does not need to exist.
* @param typeName Name of the type to which the constructor belongs.
- * @param bodyStatement The code to be entered at the place of the variable ${body_statement}.
+ * @param bodyStatement The code to be entered at the place of the variable ${body_statement}.
* @param lineDelimiter The line delimiter to be used.
* @return Returns the constructed body content or <code>null</code> if the comment code
* template is empty. The returned string is unformatted and and has no indent
* (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
- */
- public static String getConstructorBodyContent(ITranslationUnit tu, String typeName,
- String bodyStatement, String lineDelimiter) throws CoreException {
- return StubUtility.getConstructorBodyContent(tu.getCProject(), typeName, bodyStatement,
- lineDelimiter);
+ */
+ public static String getConstructorBodyContent(ITranslationUnit tu, String typeName, String bodyStatement,
+ String lineDelimiter) throws CoreException {
+ return StubUtility.getConstructorBodyContent(tu.getCProject(), typeName, bodyStatement, lineDelimiter);
}
/**
* Returns the content of the body for a destructor using the destructor body template.
* <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit
* does not need to exist.
* @param typeName Name of the type to which the constructor belongs.
- * @param bodyStatement The code to be entered at the place of the variable ${body_statement}.
+ * @param bodyStatement The code to be entered at the place of the variable ${body_statement}.
* @param lineDelimiter The line delimiter to be used.
* @return Returns the constructed body content or <code>null</code> if the comment code
* template is empty. The returned string is unformatted and and has no indent
* (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
- */
- public static String getDestructorBodyContent(ITranslationUnit tu, String typeName,
- String bodyStatement, String lineDelimiter) throws CoreException {
- return StubUtility.getDestructorBodyContent(tu.getCProject(), typeName, bodyStatement,
- lineDelimiter);
+ */
+ public static String getDestructorBodyContent(ITranslationUnit tu, String typeName, String bodyStatement,
+ String lineDelimiter) throws CoreException {
+ return StubUtility.getDestructorBodyContent(tu.getCProject(), typeName, bodyStatement, lineDelimiter);
}
/**
* Returns the content of the class definition body using the class body template.
* <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit
* does not need to exist.
* @param className The name of the class.
* @param classMemberDeclarations The code to be entered at the place of the variable
- * ${declarations}.
+ * ${declarations}.
* @param lineDelimiter The line delimiter to be used.
* @return Returns the constructed class body content or <code>null</code> if
* the class body code template is empty. The returned string is unformatted and
* has no indent (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
* @since 5.3
- */
- public static String getClassBodyContent(ITranslationUnit tu, String className,
- String classMemberDeclarations, String lineDelimiter)
- throws CoreException {
- return StubUtility.getClassBodyContent(tu.getCProject(), className, classMemberDeclarations,
- lineDelimiter);
+ */
+ public static String getClassBodyContent(ITranslationUnit tu, String className, String classMemberDeclarations,
+ String lineDelimiter) throws CoreException {
+ return StubUtility.getClassBodyContent(tu.getCProject(), className, classMemberDeclarations, lineDelimiter);
}
/**
* Returns the content of the beginning of a namespace declaration using the corresponding
* template. <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit
* does not need to exist.
* @param namespaceName The name of the namespace.
@@ -361,9 +345,9 @@ public class CodeGeneration {
* indent (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
* @since 5.3
- */
- public static String getNamespaceBeginContent(ITranslationUnit tu, String namespaceName,
- String lineDelimiter) throws CoreException {
+ */
+ public static String getNamespaceBeginContent(ITranslationUnit tu, String namespaceName, String lineDelimiter)
+ throws CoreException {
return StubUtility.getNamespaceBeginContent(tu.getCProject(), namespaceName, lineDelimiter);
}
@@ -371,7 +355,7 @@ public class CodeGeneration {
* Returns the content of the end of a namespace declaration using the corresponding
* template. <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit
* does not need to exist.
* @param namespaceName The name of the namespace.
@@ -381,9 +365,9 @@ public class CodeGeneration {
* indent (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
* @since 5.3
- */
- public static String getNamespaceEndContent(ITranslationUnit tu, String namespaceName,
- String lineDelimiter) throws CoreException {
+ */
+ public static String getNamespaceEndContent(ITranslationUnit tu, String namespaceName, String lineDelimiter)
+ throws CoreException {
return StubUtility.getNamespaceEndContent(tu.getCProject(), namespaceName, lineDelimiter);
}
@@ -397,26 +381,25 @@ public class CodeGeneration {
* or empty. The returned content is unformatted and is not indented.
* @throws CoreException Thrown when the evaluation of the code template fails.
* @since 5.0
- */
- public static String getFileComment(ITranslationUnit tu, String lineDelimiter)
- throws CoreException {
+ */
+ public static String getFileComment(ITranslationUnit tu, String lineDelimiter) throws CoreException {
return StubUtility.getFileComment(tu, lineDelimiter);
}
-
+
/**
* Returns the content for a new type comment using the 'typecomment' code template.
* The returned content is unformatted and is not indented.
* @param tu The translation unit where the type is contained. The translation unit
* does not need to exist.
* @param typeQualifiedName The name of the type to which the comment is added. For inner types
- * the name must be qualified and include the outer types names (dot separated).
+ * the name must be qualified and include the outer types names (dot separated).
* @param lineDelimiter The line delimiter to be used.
* @return Returns the new content or <code>null</code> if the code template is undefined
* or empty. The returned content is unformatted and is not indented.
* @throws CoreException
- */
- public static String getClassComment(ITranslationUnit tu, String typeQualifiedName,
- String lineDelimiter) throws CoreException {
+ */
+ public static String getClassComment(ITranslationUnit tu, String typeQualifiedName, String lineDelimiter)
+ throws CoreException {
return StubUtility.getClassComment(tu, typeQualifiedName, lineDelimiter);
}
@@ -424,7 +407,7 @@ public class CodeGeneration {
* Returns the comment for a method using the method comment code template.
* <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit
* does not need to exist.
* @param declaringTypeName Name of the type to which the method belongs.
@@ -437,18 +420,17 @@ public class CodeGeneration {
* is empty. The returned content is unformatted and not indented (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
*/
- public static String getMethodComment(ITranslationUnit tu, String declaringTypeName,
- String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig,
- String lineDelimiter) throws CoreException {
- return StubUtility.getMethodComment(tu, declaringTypeName, methodName, paramNames,
- excTypeSig, retTypeSig, lineDelimiter);
+ public static String getMethodComment(ITranslationUnit tu, String declaringTypeName, String methodName,
+ String[] paramNames, String[] excTypeSig, String retTypeSig, String lineDelimiter) throws CoreException {
+ return StubUtility.getMethodComment(tu, declaringTypeName, methodName, paramNames, excTypeSig, retTypeSig,
+ lineDelimiter);
}
/**
* Returns the comment for a constructor using the constructor comment code template.
* <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit
* does not need to exist.
* @param declaringTypeName Name of the type to which the method belongs.
@@ -459,17 +441,16 @@ public class CodeGeneration {
* is empty. The returned content is unformatted and not indented (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
*/
- public static String getConstructorComment(ITranslationUnit tu, String declaringTypeName,
- String[] paramNames, String[] excTypeSig, String lineDelimiter) throws CoreException {
- return StubUtility.getConstructorComment(tu, declaringTypeName, paramNames, excTypeSig,
- lineDelimiter);
+ public static String getConstructorComment(ITranslationUnit tu, String declaringTypeName, String[] paramNames,
+ String[] excTypeSig, String lineDelimiter) throws CoreException {
+ return StubUtility.getConstructorComment(tu, declaringTypeName, paramNames, excTypeSig, lineDelimiter);
}
/**
* Returns the comment for a destructor using the destructor comment code template.
* <code>null</code> is returned if the template is empty.
* <p>The returned string is unformatted and not indented.
- *
+ *
* @param tu The translation unit to which the method belongs. The translation unit
* does not need to exist.
* @param declaringTypeName Name of the type to which the method belongs.
@@ -479,8 +460,8 @@ public class CodeGeneration {
* is empty. The returned content is unformatted and not indented (formatting required).
* @throws CoreException Thrown when the evaluation of the code template fails.
*/
- public static String getDestructorComment(ITranslationUnit tu, String declaringTypeName,
- String[] excTypeSig, String lineDelimiter) throws CoreException {
+ public static String getDestructorComment(ITranslationUnit tu, String declaringTypeName, String[] excTypeSig,
+ String lineDelimiter) throws CoreException {
return StubUtility.getDestructorComment(tu, declaringTypeName, excTypeSig, lineDelimiter);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java
index 5c91c52ba01..a949bf4c67e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java
@@ -14,60 +14,60 @@
package org.eclipse.cdt.ui;
/**
- * This class is a helper class which takes care of implementing some of the
+ * This class is a helper class which takes care of implementing some of the
* function prototype parsing and stripping.
*/
public class FunctionPrototypeSummary implements IFunctionSummary.IFunctionPrototypeSummary {
String fname;
String freturn;
String farguments;
-
+
/**
* Create a function prototype summary based on a prototype string.
- * @param proto The string describing the prototype which is properly
+ * @param proto The string describing the prototype which is properly
* formed with following format -- returntype function(arguments)
* The following formats will be converted as follows:
* function(arguments) --> function(arguments) //constructors!
* returntype function --> returntype function()
- * function --> void function()
+ * function --> void function()
*/
public FunctionPrototypeSummary(String proto) {
int leftbracket = proto.indexOf('(');
int rightbracket = proto.lastIndexOf(')');
-
+
//If there are brackets missing, then assume void parameters
- if(leftbracket == -1 || rightbracket == -1) {
- if(leftbracket != -1) {
+ if (leftbracket == -1 || rightbracket == -1) {
+ if (leftbracket != -1) {
proto = proto.substring(leftbracket) + ")"; //$NON-NLS-1$
- } else if(rightbracket != -1) {
- proto = proto.substring(rightbracket - 1) + "()"; //$NON-NLS-1$
+ } else if (rightbracket != -1) {
+ proto = proto.substring(rightbracket - 1) + "()"; //$NON-NLS-1$
} else {
proto = proto + "()"; //$NON-NLS-1$
}
-
+
leftbracket = proto.indexOf('(');
rightbracket = proto.lastIndexOf(')');
- }
-
+ }
+
farguments = proto.substring(leftbracket + 1, rightbracket);
-
+
// fix for bug #44359
- if(farguments.equals("void")) //$NON-NLS-1$
+ if (farguments.equals("void")) //$NON-NLS-1$
farguments = ""; //$NON-NLS-1$
-
+
int nameend = leftbracket - 1;
- while(proto.charAt(nameend) == ' ') {
+ while (proto.charAt(nameend) == ' ') {
nameend--;
}
int namestart = nameend;
- while(namestart > 0 && proto.charAt(namestart) != ' ') {
+ while (namestart > 0 && proto.charAt(namestart) != ' ') {
namestart--;
}
fname = proto.substring(namestart, nameend + 1).trim();
-
- if(namestart == 0) {
+
+ if (namestart == 0) {
//Constructors are like this, don't stick a type on them.
freturn = ""; //$NON-NLS-1$
} else {
@@ -84,30 +84,30 @@ public class FunctionPrototypeSummary implements IFunctionSummary.IFunctionProto
public String getReturnType() {
return freturn;
}
-
+
@Override
public String getArguments() {
return farguments;
}
-
+
@Override
public String getPrototypeString(boolean namefirst) {
return getPrototypeString(namefirst, true);
}
-
+
public String getPrototypeString(boolean namefirst, boolean appendReturnType) {
StringBuilder buffer = new StringBuilder();
- if((!namefirst) && (appendReturnType)) {
+ if ((!namefirst) && (appendReturnType)) {
buffer.append(getReturnType());
buffer.append(" "); //$NON-NLS-1$
}
buffer.append(getName());
buffer.append("("); //$NON-NLS-1$
- if(getArguments() != null) {
+ if (getArguments() != null) {
buffer.append(getArguments());
}
buffer.append(")"); //$NON-NLS-1$
- if((namefirst) && (appendReturnType) && getReturnType().length() > 0 ) {
+ if ((namefirst) && (appendReturnType) && getReturnType().length() > 0) {
buffer.append(" "); //$NON-NLS-1$
buffer.append(getReturnType());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java
index 035773768fd..0de04d7ad45 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java
@@ -17,15 +17,16 @@ import org.eclipse.core.resources.IProject;
/**
* A build console event.
- *
+ *
* @see IBuildConsoleListener
- *
+ *
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IBuildConsoleEvent {
final static int CONSOLE_START = 1;
final static int CONSOLE_CLOSE = 2;
-
+
IProject getProject();
+
int getType();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleListener.java
index d84b6a94ccd..eb0750445e0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleListener.java
@@ -18,7 +18,7 @@ package org.eclipse.cdt.ui;
* <p>
* Clients may implement this interface.
* </p>
- *
+ *
* @see IBuildConsoleEvent
*/
public interface IBuildConsoleListener {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleManager.java
index 7a74ed3a96b..f6e69879672 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleManager.java
@@ -28,18 +28,23 @@ public interface IBuildConsoleManager {
* and one Global
*/
IConsole getConsole(IProject project);
+
/**
* @return the console associated with the specified project
* @since 5.3
*/
IConsole getProjectConsole(IProject project);
+
/**
* @param project
* @return IDocument backing the console for the given project
*/
IDocument getConsoleDocument(IProject project);
+
IProject getLastBuiltProject();
+
void addConsoleListener(IBuildConsoleListener listener);
+
void removeConsoleListener(IBuildConsoleListener listener);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICDTConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICDTConstants.java
index 5631d87124c..8192ec9e67b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICDTConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICDTConstants.java
@@ -13,12 +13,10 @@
*******************************************************************************/
package org.eclipse.cdt.ui;
-
/**
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICDTConstants
-{
+public interface ICDTConstants {
// CDT Extension Points
public static final String EP_TEXT_HOVERS = "textHovers"; //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java
index 53e416c90ff..02e4df4b732 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java
@@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.cdt.ui;
-
import org.eclipse.jface.viewers.IOpenListener;
+
/**
* The Call Hierarchy Extension Content Provider Interface
* @since 6.4
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java
index ef931ee08f9..3e8d0ede0b1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui;
-
import org.eclipse.cdt.core.model.ICElement;
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java
index 5c40d338510..580c0d4278b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui;
@@ -32,11 +32,10 @@ public interface ICHelpBook {
* @return String representing the HelpBook tytle
*/
String getTitle();
-
+
/**
* gets the type of Help provided with this book that might be ine of ICHelpBook.HELP_TYPE_XXX
* @return one of ICHelpBook.HELP_TYPE_XXX representing the type of Provided help
*/
int getCHelpType();
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java
index b3f242306da..92029f1f84f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui;
@@ -21,7 +21,7 @@ import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
* <p>
* Clients may implement this interface.
* </p>
- *
+ *
* @since 2.1
*/
public interface ICHelpProvider {
@@ -36,19 +36,19 @@ public interface ICHelpProvider {
* @return The <code>ICHelpBook[]</code> array of available help books
*/
ICHelpBook[] getCHelpBooks();
-
+
/**
* get the matching function of a given name
- *
+ *
* @param helpBooks the array of help books to be searched for help
* @param name the function name for which help is needed
* @return the IFunctionSummary interface
*/
IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name);
-
+
/**
* Get array of matching functions starting with this prefix
- *
+ *
* @param helpBooks the array of help books to be searched for help
* @param prefix the function name prefix
* @return the IFunctionSummary[] array
@@ -56,7 +56,7 @@ public interface ICHelpProvider {
IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String prefix);
/**
- *
+ *
* @param helpBooks the array of help books to be searched for help
* @param name the C/C++ element name for which help is needed
* @return the ICHelpResourceDescriptor[] array representing found help resources
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java
index 1fae0cdbda5..8c483b36bdd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui;
@@ -16,7 +16,7 @@ package org.eclipse.cdt.ui;
import org.eclipse.help.IHelpResource;
/**
- * This interface represents Help Resources found in the certain Help Book
+ * This interface represents Help Resources found in the certain Help Book
* provided by certain CHelpProvider
* <p>
* Clients may implement this interface.
@@ -28,10 +28,10 @@ public interface ICHelpResourceDescriptor {
/**
* represents the Help Book, where help resources represented by getHelpResources()
* method were found
- * @return ICHelpBook interface representing the help book where help was found
+ * @return ICHelpBook interface representing the help book where help was found
*/
ICHelpBook getCHelpBook();
-
+
/**
* gets the array of help resources found in the HelpBook represented
* by getCHelpBook() method
@@ -39,4 +39,3 @@ public interface ICHelpResourceDescriptor {
*/
IHelpResource[] getHelpResources();
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java
index 8e193ac93de..d285df5769d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java
@@ -25,14 +25,14 @@ import org.eclipse.ui.IEditorInput;
public interface IEditorInputDelegate extends IEditorInput {
/**
* Returns the editor input delegate for this editor input.
- *
+ *
* @return editor input delegate
*/
IEditorInput getDelegate();
/**
* Returns the storage associated with this editor input.
- *
+ *
* @return storage associated with this editor input
* @throws CoreException on failure. Reasons include:
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java
index c2c789347e0..c7326b03320 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui;
-
/**
* A function summary provided by an {@link ICHelpProvider}.
* <p>
@@ -22,7 +21,7 @@ package org.eclipse.cdt.ui;
* @see ICHelpProvider
*/
public interface IFunctionSummary {
-
+
/**
* <p>
* Clients may implement this interface.
@@ -37,19 +36,19 @@ public interface IFunctionSummary {
* information.
*/
public String getName();
-
+
/**
* Get the return type of the function.
* ie "int main(int argc, char **argv)" --> "int"
- * @return A string containing the return type of the
+ * @return A string containing the return type of the
* function.
- */
+ */
public String getReturnType();
-
+
/**
* Get the arguments of the function.
- * ie "int main(int argc, char **argv)" --> "int argc, char **argv"
- * @return A string containing the arguments of the
+ * ie "int main(int argc, char **argv)" --> "int argc, char **argv"
+ * @return A string containing the arguments of the
* function, or null if the function has no arguments.
*/
public String getArguments();
@@ -62,11 +61,11 @@ public interface IFunctionSummary {
*/
public String getPrototypeString(boolean namefirst);
}
-
+
/**
* Gets the name of the function. This is the simple
* name without any additional return or argument information.
- * The function "int main(int argc, char **argv)" would
+ * The function "int main(int argc, char **argv)" would
* return "main"
* @return The name of the function without any additional
* information
@@ -74,7 +73,7 @@ public interface IFunctionSummary {
public String getName();
/**
- * Get the full namespace qualifier for this function
+ * Get the full namespace qualifier for this function
* (generally C++ only)
* @return The string of the fully qualified namespace for
* this function, or null if the namespace is not known.
@@ -85,18 +84,18 @@ public interface IFunctionSummary {
* Gets the description of the function. This string can be
* either text or HTML coded and is displayed as part of the
* hover help and as the context proposal information.
- * @return A description for this function, or null if no
+ * @return A description for this function, or null if no
* description is available.
*/
public String getDescription();
-
+
/**
- * Gets the prototype description for this function.
- * @return The IFunctionPrototypeSummary describing the
- * prototype for this function
+ * Gets the prototype description for this function.
+ * @return The IFunctionPrototypeSummary describing the
+ * prototype for this function
*/
public IFunctionPrototypeSummary getPrototype();
-
+
/**
* Get headers required by this function
* @return A list of IRequiredInclude definitions, or null if no
@@ -104,4 +103,3 @@ public interface IFunctionSummary {
*/
public IRequiredInclude[] getIncludes();
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ILanguageUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ILanguageUI.java
index dc4ac6ee145..161c4e1f24e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ILanguageUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ILanguageUI.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Doug Schaefer (QNX Software Systems) - Initial API and implementation
**********************************************************************/
@@ -28,9 +28,9 @@ public interface ILanguageUI extends IAdaptable {
/**
* Get the code scanner that drives coloring in the editor.
- *
+ *
* @return code scanner for this language
*/
RuleBasedScanner getCodeScanner();
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IPropertyChangeParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IPropertyChangeParticipant.java
index bd2b1a2f38e..5505a73db08 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IPropertyChangeParticipant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IPropertyChangeParticipant.java
@@ -22,7 +22,7 @@ import org.eclipse.jface.util.PropertyChangeEvent;
* <p>
* Clients may implement this interface.
* </p>
- *
+ *
* @since 5.0
*/
public interface IPropertyChangeParticipant {
@@ -32,7 +32,7 @@ public interface IPropertyChangeParticipant {
* behaviour in a way it determines potential clients could act upon.
*/
public boolean affectsBehavior(PropertyChangeEvent event);
-
+
/**
* Performs any necessary to adapt the participant to the specified event.
* @param event
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java
index c57a1f09110..63335f254ac 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java
@@ -31,4 +31,3 @@ public interface IRequiredInclude {
*/
boolean isStandard();
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java
index 1ec432a2f2b..1f509bf4092 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -27,16 +27,16 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
* objects. The original translation unit is only given indirectly by means
* of an {@code IEditorInput}. The life cycle is as follows:
* <ul>
- * <li> {@code connect} creates and remembers a working copy of the
+ * <li> {@code connect} creates and remembers a working copy of the
* translation unit which is encoded in the given editor input</li>
- * <li> {@code getWorkingCopy} returns the working copy remembered on
+ * <li> {@code getWorkingCopy} returns the working copy remembered on
* {@code connect}</li>
- * <li> {@code disconnect} destroys the working copy remembered on
+ * <li> {@code disconnect} destroys the working copy remembered on
* {@code connect}</li>
* </ul>
* </p>
* @noimplement This interface is not intended to be implemented by clients.
- *
+ *
* @see CDTUITools#getWorkingCopyManager
*/
public interface IWorkingCopyManager {
@@ -46,22 +46,22 @@ public interface IWorkingCopyManager {
* in the given editor input (does nothing if there is no encoded translation unit).
*
* @param input the editor input
- * @exception CoreException if the working copy cannot be created for the
+ * @exception CoreException if the working copy cannot be created for the
* translation unit
*/
void connect(IEditorInput input) throws CoreException;
-
+
/**
* Disconnects the given editor input from this manager. After calling
* this method, a working copy for the translation unit encoded
* in the given editor input will no longer be available. Does nothing if there
* is no encoded translation unit, or if there is no remembered working copy for
* the translation unit.
- *
+ *
* @param input the editor input
*/
void disconnect(IEditorInput input);
-
+
/**
* Returns the working copy remembered for the translation unit encoded in
* the given editor input.
@@ -72,7 +72,7 @@ public interface IWorkingCopyManager {
* copy for this translation unit
*/
IWorkingCopy getWorkingCopy(IEditorInput input);
-
+
/**
* Shuts down this working copy manager. All working copies still remembered
* by this manager is destroyed.
@@ -80,16 +80,16 @@ public interface IWorkingCopyManager {
void shutdown();
/**
- * Returns a shared working copy for the given translation unit. If necessary, a new
+ * Returns a shared working copy for the given translation unit. If necessary, a new
* working copy will be created.
*
* @param tu a translation unit
* @param requestor call back interface for reporting problems, may be {@code null}.
- * @param monitor a monitor to report progress
+ * @param monitor a monitor to report progress
* @since 5.2
*/
- IWorkingCopy getSharedWorkingCopy(ITranslationUnit tu, IProblemRequestor requestor,
- IProgressMonitor monitor) throws CModelException;
+ IWorkingCopy getSharedWorkingCopy(ITranslationUnit tu, IProblemRequestor requestor, IProgressMonitor monitor)
+ throws CModelException;
/**
* Returns all shared working copies, currently available.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java
index fe0931483aa..e06e52b0f32 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -29,17 +29,17 @@ public interface IWorkingCopyManagerExtension {
* <p>
* This working copy manager does not assume the ownership of this working copy, i.e.,
* the given working copy is not automatically be freed when this manager is shut down.
- *
+ *
* @param input the editor input
* @param workingCopy the working copy
*/
void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy);
-
+
/**
* Removes the working copy set for the given editor input. If there is no
* working copy set for this input or this input is not connected to this
* working copy manager, this call has no effect.
- *
+ *
* @param input the editor input
*/
void removeWorkingCopy(IEditorInput input);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java
index 91907db41f3..c00f2d1c7ac 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java
@@ -48,7 +48,7 @@ public class IncludesGrouping extends CElementGrouping {
return true;
}
if (obj instanceof IncludesGrouping) {
- return tu.equals(((IncludesGrouping) obj).tu) ;
+ return tu.equals(((IncludesGrouping) obj).tu);
}
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/NamespacesGrouping.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/NamespacesGrouping.java
index bff59247a53..df8f5716ab6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/NamespacesGrouping.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/NamespacesGrouping.java
@@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.ui.MembersGrouping;
/**
* NamespacesGrouping
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
public class NamespacesGrouping extends CElementGrouping {
@@ -41,14 +41,14 @@ public class NamespacesGrouping extends CElementGrouping {
protected ITranslationUnit fUnit;
protected String fName;
private final boolean fMemberGrouping;
-
+
public NamespacesGrouping(ITranslationUnit unit, INamespace namespace) {
this(unit, namespace, false);
}
/**
* Create new namespace grouping and optional member grouping.
- *
+ *
* @param unit the parent translation unit
* @param namespace the namespace
* @param memberGrouping whether member grouping is enabled
@@ -84,7 +84,6 @@ public class NamespacesGrouping extends CElementGrouping {
return list.toArray();
}
-
/**
* @since 5.1
*/
@@ -115,7 +114,7 @@ public class NamespacesGrouping extends CElementGrouping {
Map<String, MembersGrouping> map = new HashMap<String, MembersGrouping>();
for (int i = 0; i < children.length; ++i) {
if (children[i] instanceof IMember) {
- final ICElement member = (ICElement)children[i];
+ final ICElement member = (ICElement) children[i];
String name = member.getElementName();
int idx = name.lastIndexOf("::"); //$NON-NLS-1$
if (idx < 0) {
@@ -160,7 +159,7 @@ public class NamespacesGrouping extends CElementGrouping {
return true;
}
if (obj instanceof NamespacesGrouping) {
- NamespacesGrouping other = (NamespacesGrouping)obj;
+ NamespacesGrouping other = (NamespacesGrouping) obj;
return fUnit.equals(other.fUnit) && fName.equals(other.fName);
}
return false;
@@ -173,7 +172,7 @@ public class NamespacesGrouping extends CElementGrouping {
public int hashCode() {
return fUnit.hashCode() * 17 + fName.hashCode();
}
-
+
/*
* @see org.eclipse.cdt.ui.CElementGrouping#toString()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
index 7c3384c180a..3c2a6fc919b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
@@ -67,28 +67,28 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$
+ public static final String EDITOR_BOLD_SUFFIX = "_bold"; //$NON-NLS-1$
/**
* Preference key suffix for italic text style preference keys.
*
* @since 4.0
*/
- public static final String EDITOR_ITALIC_SUFFIX= "_italic"; //$NON-NLS-1$
+ public static final String EDITOR_ITALIC_SUFFIX = "_italic"; //$NON-NLS-1$
/**
* Preference key suffix for strikethrough text style preference keys.
*
* @since 4.0
*/
- public static final String EDITOR_STRIKETHROUGH_SUFFIX= "_strikethrough"; //$NON-NLS-1$
+ public static final String EDITOR_STRIKETHROUGH_SUFFIX = "_strikethrough"; //$NON-NLS-1$
/**
* Preference key suffix for underline text style preference keys.
*
* @since 4.0
*/
- public static final String EDITOR_UNDERLINE_SUFFIX= "_underline"; //$NON-NLS-1$
+ public static final String EDITOR_UNDERLINE_SUFFIX = "_underline"; //$NON-NLS-1$
/**
* A named preference that holds the color used to render multi-line comments.
@@ -100,7 +100,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_MULTI_LINE_COMMENT_COLOR= ICColorConstants.C_MULTI_LINE_COMMENT;
+ public final static String EDITOR_MULTI_LINE_COMMENT_COLOR = ICColorConstants.C_MULTI_LINE_COMMENT;
/**
* A named preference that controls whether multi-line comments are rendered in bold.
@@ -110,7 +110,8 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_MULTI_LINE_COMMENT_BOLD= ICColorConstants.C_MULTI_LINE_COMMENT + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_MULTI_LINE_COMMENT_BOLD = ICColorConstants.C_MULTI_LINE_COMMENT
+ + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether multi-line comments are rendered in italic.
@@ -120,7 +121,8 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_MULTI_LINE_COMMENT_ITALIC= ICColorConstants.C_MULTI_LINE_COMMENT + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_MULTI_LINE_COMMENT_ITALIC = ICColorConstants.C_MULTI_LINE_COMMENT
+ + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render single line comments.
@@ -132,7 +134,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR= ICColorConstants.C_SINGLE_LINE_COMMENT;
+ public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR = ICColorConstants.C_SINGLE_LINE_COMMENT;
/**
* A named preference that controls whether single line comments are rendered in bold.
@@ -142,7 +144,8 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD= ICColorConstants.C_SINGLE_LINE_COMMENT + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD = ICColorConstants.C_SINGLE_LINE_COMMENT
+ + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether single line comments are rendered in italic.
@@ -152,7 +155,8 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_SINGLE_LINE_COMMENT_ITALIC= ICColorConstants.C_SINGLE_LINE_COMMENT + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_SINGLE_LINE_COMMENT_ITALIC = ICColorConstants.C_SINGLE_LINE_COMMENT
+ + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render C/C++ keywords.
@@ -164,7 +168,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_C_KEYWORD_COLOR= ICColorConstants.C_KEYWORD;
+ public final static String EDITOR_C_KEYWORD_COLOR = ICColorConstants.C_KEYWORD;
/**
* A named preference that controls whether keywords are rendered in bold.
@@ -173,7 +177,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_KEYWORD_BOLD= ICColorConstants.C_KEYWORD + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_C_KEYWORD_BOLD = ICColorConstants.C_KEYWORD + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether keywords are rendered in italic.
@@ -182,7 +186,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_KEYWORD_ITALIC= ICColorConstants.C_KEYWORD + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_C_KEYWORD_ITALIC = ICColorConstants.C_KEYWORD + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render preprocessor directives.
@@ -194,7 +198,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_PP_DIRECTIVE_COLOR= ICColorConstants.PP_DIRECTIVE;
+ public final static String EDITOR_PP_DIRECTIVE_COLOR = ICColorConstants.PP_DIRECTIVE;
/**
* A named preference that controls whether preprocessor directives are rendered in bold.
@@ -203,7 +207,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_PP_DIRECTIVE_BOLD= ICColorConstants.PP_DIRECTIVE + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_PP_DIRECTIVE_BOLD = ICColorConstants.PP_DIRECTIVE + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether preprocessor directives are rendered in italic.
@@ -212,7 +216,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_PP_DIRECTIVE_ITALIC= ICColorConstants.PP_DIRECTIVE + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_PP_DIRECTIVE_ITALIC = ICColorConstants.PP_DIRECTIVE + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render headers.
@@ -224,7 +228,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_PP_HEADER_COLOR= ICColorConstants.PP_HEADER;
+ public final static String EDITOR_PP_HEADER_COLOR = ICColorConstants.PP_HEADER;
/**
* A named preference that controls whether headers are rendered in bold.
@@ -233,7 +237,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_PP_HEADER_BOLD= ICColorConstants.PP_HEADER + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_PP_HEADER_BOLD = ICColorConstants.PP_HEADER + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether number are rendered in italic.
@@ -242,7 +246,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_PP_HEADER_ITALIC= ICColorConstants.PP_HEADER + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_PP_HEADER_ITALIC = ICColorConstants.PP_HEADER + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render preprocessor text.
@@ -254,7 +258,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_PP_DEFAULT_COLOR= ICColorConstants.PP_DEFAULT;
+ public final static String EDITOR_PP_DEFAULT_COLOR = ICColorConstants.PP_DEFAULT;
/**
* A named preference that controls whether preprocessor text is rendered in bold.
@@ -263,7 +267,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_PP_DEFAULT_BOLD= ICColorConstants.PP_DEFAULT + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_PP_DEFAULT_BOLD = ICColorConstants.PP_DEFAULT + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether preprocessor text is rendered in italic.
@@ -272,7 +276,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_PP_DEFAULT_ITALIC= ICColorConstants.PP_DEFAULT + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_PP_DEFAULT_ITALIC = ICColorConstants.PP_DEFAULT + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render builtin types.
@@ -284,7 +288,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_C_BUILTIN_TYPE_COLOR= ICColorConstants.C_TYPE;
+ public final static String EDITOR_C_BUILTIN_TYPE_COLOR = ICColorConstants.C_TYPE;
/**
* A named preference that controls whether builtin types are rendered in bold.
@@ -293,7 +297,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_BUILTIN_TYPE_BOLD= ICColorConstants.C_TYPE + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_C_BUILTIN_TYPE_BOLD = ICColorConstants.C_TYPE + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether builtin types are rendered in italic.
@@ -302,7 +306,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_BUILTIN_TYPE_ITALIC= ICColorConstants.C_TYPE + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_C_BUILTIN_TYPE_ITALIC = ICColorConstants.C_TYPE + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render string constants.
@@ -314,7 +318,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_C_STRING_COLOR= ICColorConstants.C_STRING;
+ public final static String EDITOR_C_STRING_COLOR = ICColorConstants.C_STRING;
/**
* A named preference that controls whether string constants are rendered in bold.
@@ -323,7 +327,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_STRING_BOLD= ICColorConstants.C_STRING + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_C_STRING_BOLD = ICColorConstants.C_STRING + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether string constants are rendered in italic.
@@ -332,7 +336,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_STRING_ITALIC= ICColorConstants.C_STRING + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_C_STRING_ITALIC = ICColorConstants.C_STRING + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render operators.
@@ -344,7 +348,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_C_OPERATOR_COLOR= ICColorConstants.C_OPERATOR;
+ public final static String EDITOR_C_OPERATOR_COLOR = ICColorConstants.C_OPERATOR;
/**
* A named preference that controls whether operators are rendered in bold.
@@ -353,7 +357,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_OPERATOR_BOLD= ICColorConstants.C_OPERATOR + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_C_OPERATOR_BOLD = ICColorConstants.C_OPERATOR + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether operators are rendered in italic.
@@ -362,7 +366,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_OPERATOR_ITALIC= ICColorConstants.C_OPERATOR + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_C_OPERATOR_ITALIC = ICColorConstants.C_OPERATOR + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render numbers.
@@ -374,7 +378,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_C_NUMBER_COLOR= ICColorConstants.C_NUMBER;
+ public final static String EDITOR_C_NUMBER_COLOR = ICColorConstants.C_NUMBER;
/**
* A named preference that controls whether number are rendered in bold.
@@ -383,7 +387,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_NUMBER_BOLD= ICColorConstants.C_NUMBER + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_C_NUMBER_BOLD = ICColorConstants.C_NUMBER + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether number are rendered in italic.
@@ -392,7 +396,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_NUMBER_ITALIC= ICColorConstants.C_NUMBER + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_C_NUMBER_ITALIC = ICColorConstants.C_NUMBER + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render braces.
@@ -404,7 +408,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_C_BRACES_COLOR= ICColorConstants.C_BRACES;
+ public final static String EDITOR_C_BRACES_COLOR = ICColorConstants.C_BRACES;
/**
* A named preference that controls whether braces are rendered in bold.
@@ -413,7 +417,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_BRACES_BOLD= ICColorConstants.C_BRACES + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_C_BRACES_BOLD = ICColorConstants.C_BRACES + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether braces are rendered in italic.
@@ -422,7 +426,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_BRACES_ITALIC= ICColorConstants.C_BRACES + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_C_BRACES_ITALIC = ICColorConstants.C_BRACES + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render C/C++ default text.
@@ -434,7 +438,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public final static String EDITOR_C_DEFAULT_COLOR= ICColorConstants.C_DEFAULT;
+ public final static String EDITOR_C_DEFAULT_COLOR = ICColorConstants.C_DEFAULT;
/**
* A named preference that controls whether C/C++ default text is rendered in bold.
@@ -443,7 +447,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_DEFAULT_BOLD= ICColorConstants.C_DEFAULT + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_C_DEFAULT_BOLD = ICColorConstants.C_DEFAULT + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether C/C++ default text is rendered in italic.
@@ -452,7 +456,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_C_DEFAULT_ITALIC= ICColorConstants.C_DEFAULT + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_C_DEFAULT_ITALIC = ICColorConstants.C_DEFAULT + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render assembly labels.
@@ -464,7 +468,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.0
*/
- public final static String EDITOR_ASM_LABEL_COLOR= ICColorConstants.ASM_LABEL;
+ public final static String EDITOR_ASM_LABEL_COLOR = ICColorConstants.ASM_LABEL;
/**
* A named preference that controls whether assembly labels are rendered in bold.
@@ -473,7 +477,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String EDITOR_ASM_LABEL_BOLD= ICColorConstants.ASM_LABEL + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_ASM_LABEL_BOLD = ICColorConstants.ASM_LABEL + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether assembly labels are rendered in italic.
@@ -482,7 +486,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String EDITOR_ASM_LABEL_ITALIC= ICColorConstants.ASM_LABEL + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_ASM_LABEL_ITALIC = ICColorConstants.ASM_LABEL + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render assembly directives.
@@ -494,7 +498,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.0
*/
- public final static String EDITOR_ASM_DIRECTIVE_COLOR= ICColorConstants.ASM_DIRECTIVE;
+ public final static String EDITOR_ASM_DIRECTIVE_COLOR = ICColorConstants.ASM_DIRECTIVE;
/**
* A named preference that controls whether assembly directives are rendered in bold.
@@ -503,7 +507,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String EDITOR_ASM_DIRECTIVE_BOLD= ICColorConstants.ASM_DIRECTIVE + EDITOR_BOLD_SUFFIX;
+ public final static String EDITOR_ASM_DIRECTIVE_BOLD = ICColorConstants.ASM_DIRECTIVE + EDITOR_BOLD_SUFFIX;
/**
* A named preference that controls whether assembly directives are rendered in italic.
@@ -512,7 +516,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String EDITOR_ASM_DIRECTIVE_ITALIC= ICColorConstants.ASM_DIRECTIVE + EDITOR_ITALIC_SUFFIX;
+ public final static String EDITOR_ASM_DIRECTIVE_ITALIC = ICColorConstants.ASM_DIRECTIVE + EDITOR_ITALIC_SUFFIX;
/**
* A named preference that holds the color used to render doxygen tags.
@@ -524,7 +528,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.4
*/
- public static final String DOXYGEN_TAG_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"; //$NON-NLS-1$
+ public static final String DOXYGEN_TAG_COLOR = "org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"; //$NON-NLS-1$
/**
* A named preference that holds the color used to render doxygen single line comments.
@@ -536,7 +540,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.4
*/
- public static final String DOXYGEN_SINGLE_LINE_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"; //$NON-NLS-1$
+ public static final String DOXYGEN_SINGLE_LINE_COLOR = "org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"; //$NON-NLS-1$
/**
* A named preference that holds the color used to render doxygen multi-line comments.
@@ -548,7 +552,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.4
*/
- public static final String DOXYGEN_MULTI_LINE_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"; //$NON-NLS-1$
+ public static final String DOXYGEN_MULTI_LINE_COLOR = "org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"; //$NON-NLS-1$
/**
* The symbolic font name for the C/C++ editor text font
@@ -556,7 +560,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public final static String EDITOR_TEXT_FONT= "org.eclipse.cdt.ui.editors.textfont"; //$NON-NLS-1$
+ public final static String EDITOR_TEXT_FONT = "org.eclipse.cdt.ui.editors.textfont"; //$NON-NLS-1$
/**
* A named preference that controls whether the cview's selection is linked to the active
@@ -564,7 +568,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public static final String PREF_LINK_TO_EDITOR= "org.eclipse.cdt.ui.editor.linkToEditor"; //$NON-NLS-1$
+ public static final String PREF_LINK_TO_EDITOR = "org.eclipse.cdt.ui.editor.linkToEditor"; //$NON-NLS-1$
/**
* A named preference that specifies whether children of a translation unit are shown in
@@ -572,7 +576,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public static final String PREF_SHOW_CU_CHILDREN= "org.eclipse.cdt.ui.editor.CUChildren"; //$NON-NLS-1$
+ public static final String PREF_SHOW_CU_CHILDREN = "org.eclipse.cdt.ui.editor.CUChildren"; //$NON-NLS-1$
/**
* A named preference that speficies whether to use the parser's structural mode to build
@@ -580,7 +584,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public static final String PREF_USE_STRUCTURAL_PARSE_MODE= "org.eclipse.cdt.ui.editor.UseStructuralMode"; //$NON-NLS-1$
+ public static final String PREF_USE_STRUCTURAL_PARSE_MODE = "org.eclipse.cdt.ui.editor.UseStructuralMode"; //$NON-NLS-1$
/**
* A named preference that controls if segmented view (show selected element only) is turned
@@ -588,55 +592,55 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public static final String EDITOR_SHOW_SEGMENTS= "org.eclipse.cdt.ui.editor.showSegments"; //$NON-NLS-1$
-
- /**
- * A named preference that holds the color used to render task tags.
- * <p>
- * Value is of type {@code String}. A RGB color value encoded as a string
- * using class {@code PreferenceConverter}
- * </p>
- *
- * @see org.eclipse.jface.resource.StringConverter
- * @see org.eclipse.jface.preference.PreferenceConverter
- */
- public final static String EDITOR_TASK_TAG_COLOR= ICColorConstants.TASK_TAG;
-
- /**
- * A named preference that controls whether task tags are rendered in bold.
- * <p>
- * Value is of type {@code Boolean}.
- * </p>
- */
- public final static String EDITOR_TASK_TAG_BOLD= ICColorConstants.TASK_TAG + EDITOR_BOLD_SUFFIX;
-
- /**
- * A named preference that controls whether task tags are rendered in italic.
- * <p>
- * Value is of type {@code Boolean}.
- * </p>
- */
- public final static String EDITOR_TASK_TAG_ITALIC= ICColorConstants.TASK_TAG + EDITOR_ITALIC_SUFFIX;
-
- /**
+ public static final String EDITOR_SHOW_SEGMENTS = "org.eclipse.cdt.ui.editor.showSegments"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render task tags.
+ * <p>
+ * Value is of type {@code String}. A RGB color value encoded as a string
+ * using class {@code PreferenceConverter}
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_TASK_TAG_COLOR = ICColorConstants.TASK_TAG;
+
+ /**
+ * A named preference that controls whether task tags are rendered in bold.
+ * <p>
+ * Value is of type {@code Boolean}.
+ * </p>
+ */
+ public final static String EDITOR_TASK_TAG_BOLD = ICColorConstants.TASK_TAG + EDITOR_BOLD_SUFFIX;
+
+ /**
+ * A named preference that controls whether task tags are rendered in italic.
+ * <p>
+ * Value is of type {@code Boolean}.
+ * </p>
+ */
+ public final static String EDITOR_TASK_TAG_ITALIC = ICColorConstants.TASK_TAG + EDITOR_ITALIC_SUFFIX;
+
+ /**
* A named preference that controls if correction indicators are shown in the UI.
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_CORRECTION_INDICATION= "CEditor.ShowTemporaryProblem"; //$NON-NLS-1$
+ public final static String EDITOR_CORRECTION_INDICATION = "CEditor.ShowTemporaryProblem"; //$NON-NLS-1$
/**
* A named preference that controls if temporary problems are evaluated and shown in the UI.
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_EVALUATE_TEMPORARY_PROBLEMS= "handleTemporaryProblems"; //$NON-NLS-1$
+ public final static String EDITOR_EVALUATE_TEMPORARY_PROBLEMS = "handleTemporaryProblems"; //$NON-NLS-1$
/**
* A named preference that defines the key for the hover modifiers.
*
*/
- public static final String EDITOR_TEXT_HOVER_MODIFIERS= "hoverModifiers"; //$NON-NLS-1$
+ public static final String EDITOR_TEXT_HOVER_MODIFIERS = "hoverModifiers"; //$NON-NLS-1$
/**
* A named preference that defines the key for the hover modifier state masks.
@@ -645,7 +649,7 @@ public class PreferenceConstants {
*
* @see #EDITOR_TEXT_HOVER_MODIFIERS
*/
- public static final String EDITOR_TEXT_HOVER_MODIFIER_MASKS= "hoverModifierMasks"; //$NON-NLS-1$
+ public static final String EDITOR_TEXT_HOVER_MODIFIER_MASKS = "hoverModifierMasks"; //$NON-NLS-1$
/**
* A named preference that controls whether the 'close strings' feature
@@ -653,7 +657,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_CLOSE_STRINGS= "closeStrings"; //$NON-NLS-1$
+ public final static String EDITOR_CLOSE_STRINGS = "closeStrings"; //$NON-NLS-1$
/**
* A named preference that controls whether the 'wrap strings' feature is
@@ -661,7 +665,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_WRAP_STRINGS= "wrapStrings"; //$NON-NLS-1$
+ public final static String EDITOR_WRAP_STRINGS = "wrapStrings"; //$NON-NLS-1$
/**
* A named preference that controls whether the 'escape strings' feature is
@@ -669,7 +673,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_ESCAPE_STRINGS= "escapeStrings"; //$NON-NLS-1$
+ public final static String EDITOR_ESCAPE_STRINGS = "escapeStrings"; //$NON-NLS-1$
/**
* A named preference that controls whether the 'close brackets' feature is
@@ -677,7 +681,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_CLOSE_BRACKETS= "closeBrackets"; //$NON-NLS-1$
+ public final static String EDITOR_CLOSE_BRACKETS = "closeBrackets"; //$NON-NLS-1$
/**
* A named preference that controls whether the 'close angular brackets' feature is
@@ -685,7 +689,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_CLOSE_ANGULAR_BRACKETS= "closeAngularBrackets"; //$NON-NLS-1$
+ public final static String EDITOR_CLOSE_ANGULAR_BRACKETS = "closeAngularBrackets"; //$NON-NLS-1$
/**
* A named preference that controls whether the 'close braces' feature is
@@ -693,7 +697,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_CLOSE_BRACES= "closeBraces"; //$NON-NLS-1$
+ public final static String EDITOR_CLOSE_BRACES = "closeBraces"; //$NON-NLS-1$
/**
* A named preference that controls whether the 'smart paste' feature is
@@ -701,14 +705,14 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_SMART_PASTE= "smartPaste"; //$NON-NLS-1$
+ public final static String EDITOR_SMART_PASTE = "smartPaste"; //$NON-NLS-1$
/**
* A named preference that controls the smart tab behavior.
* <p>
* Value is of type {@code Boolean}.
*/
- public static final String EDITOR_SMART_TAB= "smart_tab"; //$NON-NLS-1$
+ public static final String EDITOR_SMART_TAB = "smart_tab"; //$NON-NLS-1$
/**
* A named preference that controls whether the 'auto indent' feature is
@@ -716,7 +720,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public final static String EDITOR_AUTO_INDENT= "autoIndent"; //$NON-NLS-1$
+ public final static String EDITOR_AUTO_INDENT = "autoIndent"; //$NON-NLS-1$
/**
* The id of the best match hover contributed for extension point
@@ -724,21 +728,21 @@ public class PreferenceConstants {
*
* @since 2.1
*/
- public static final String ID_BESTMATCH_HOVER= "org.eclipse.cdt.ui.BestMatchHover"; //$NON-NLS-1$
+ public static final String ID_BESTMATCH_HOVER = "org.eclipse.cdt.ui.BestMatchHover"; //$NON-NLS-1$
/**
* A named preference that controls whether the Outline view should group include directives.
* <p>
* Value is of type {@code Boolean}.
*/
- public static final String OUTLINE_GROUP_INCLUDES= "org.eclipse.cdt.ui.outline.groupincludes"; //$NON-NLS-1$
+ public static final String OUTLINE_GROUP_INCLUDES = "org.eclipse.cdt.ui.outline.groupincludes"; //$NON-NLS-1$
/**
* A named preference that controls whether the Outline view should group namespaces.
* <p>
* Value is of type {@code Boolean}.
*/
- public static final String OUTLINE_GROUP_NAMESPACES= "org.eclipse.cdt.ui.outline.groupnamespaces"; //$NON-NLS-1$
+ public static final String OUTLINE_GROUP_NAMESPACES = "org.eclipse.cdt.ui.outline.groupnamespaces"; //$NON-NLS-1$
/**
* A named preference that controls whether the Outline view should group member definitions.
@@ -746,7 +750,7 @@ public class PreferenceConstants {
* Value is of type {@code Boolean}.
* @since 5.1
*/
- public static final String OUTLINE_GROUP_MEMBERS= "org.eclipse.cdt.ui.outline.groupmembers"; //$NON-NLS-1$
+ public static final String OUTLINE_GROUP_MEMBERS = "org.eclipse.cdt.ui.outline.groupmembers"; //$NON-NLS-1$
/**
* A named preference that controls whether the Outline view should group macro definitions.
@@ -754,7 +758,7 @@ public class PreferenceConstants {
* Value is of type {@code Boolean}.
* @since 5.2
*/
- public static final String OUTLINE_GROUP_MACROS= "org.eclipse.cdt.ui.outline.groupmacros"; //$NON-NLS-1$
+ public static final String OUTLINE_GROUP_MACROS = "org.eclipse.cdt.ui.outline.groupmacros"; //$NON-NLS-1$
/**
* A named preference that controls whether the Outline view
@@ -770,7 +774,7 @@ public class PreferenceConstants {
* <p>
* Value is of type {@code Boolean}.
*/
- public static final String CVIEW_GROUP_INCLUDES= "org.eclipse.cdt.ui.cview.groupincludes"; //$NON-NLS-1$
+ public static final String CVIEW_GROUP_INCLUDES = "org.eclipse.cdt.ui.cview.groupincludes"; //$NON-NLS-1$
/**
* A named preference that controls whether macro definitions should be grouped in
@@ -779,7 +783,7 @@ public class PreferenceConstants {
* Value is of type {@code Boolean}.
* @since 5.2
*/
- public static final String CVIEW_GROUP_MACROS= "org.eclipse.cdt.ui.cview.groupmacros"; //$NON-NLS-1$
+ public static final String CVIEW_GROUP_MACROS = "org.eclipse.cdt.ui.cview.groupmacros"; //$NON-NLS-1$
/**
* A named preference that controls whether header and source files should be separated in
@@ -789,7 +793,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public static final String CVIEW_SEPARATE_HEADER_AND_SOURCE= "org.eclipse.cdt.ui.cview.separateheaderandsource"; //$NON-NLS-1$
+ public static final String CVIEW_SEPARATE_HEADER_AND_SOURCE = "org.eclipse.cdt.ui.cview.separateheaderandsource"; //$NON-NLS-1$
/**
* A named preference that controls whether the sorting order of source files should be changed
@@ -799,7 +803,7 @@ public class PreferenceConstants {
*
* @since 5.3
*/
- public static final String SORT_ORDER_OF_EXCLUDED_FILES= "org.eclipse.cdt.ui.cview.sortorderofexcludedfiles"; //$NON-NLS-1$
+ public static final String SORT_ORDER_OF_EXCLUDED_FILES = "org.eclipse.cdt.ui.cview.sortorderofexcludedfiles"; //$NON-NLS-1$
/**
* A named preference that controls which completion proposal categories
@@ -809,7 +813,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String CODEASSIST_EXCLUDED_CATEGORIES= "content_assist_disabled_computers"; //$NON-NLS-1$
+ public static final String CODEASSIST_EXCLUDED_CATEGORIES = "content_assist_disabled_computers"; //$NON-NLS-1$
/**
* A named preference that controls the order of the specific code assist commands.
@@ -818,7 +822,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String CODEASSIST_CATEGORY_ORDER= "content_assist_category_order"; //$NON-NLS-1$
+ public static final String CODEASSIST_CATEGORY_ORDER = "content_assist_category_order"; //$NON-NLS-1$
/**
* A named preference that controls whether folding is enabled in the C editor.
@@ -826,7 +830,7 @@ public class PreferenceConstants {
* Value is of type {@code Boolean}.
*
*/
- public static final String EDITOR_FOLDING_ENABLED= "editor_folding_enabled"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_ENABLED = "editor_folding_enabled"; //$NON-NLS-1$
/**
* A named preference that stores the configured folding provider.
@@ -834,7 +838,7 @@ public class PreferenceConstants {
* Value is of type {@code String}.
*
*/
- public static final String EDITOR_FOLDING_PROVIDER= "editor_folding_provider"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_PROVIDER = "editor_folding_provider"; //$NON-NLS-1$
/**
* A named preference that stores the value for Structure folding for the default folding provider.
@@ -843,7 +847,7 @@ public class PreferenceConstants {
*
* @since 3.0
*/
- public static final String EDITOR_FOLDING_STRUCTURES= "editor_folding_default_structures"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_STRUCTURES = "editor_folding_default_structures"; //$NON-NLS-1$
/**
* A named preference that stores the value for statements folding (if/else, do/while, for, switch statements)
@@ -859,7 +863,7 @@ public class PreferenceConstants {
*
* @since 3.0
*/
- public static final String EDITOR_FOLDING_FUNCTIONS= "editor_folding_default_functions"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_FUNCTIONS = "editor_folding_default_functions"; //$NON-NLS-1$
/**
* A named preference that stores the value for method folding for the default folding provider.
@@ -868,7 +872,7 @@ public class PreferenceConstants {
*
* @since 3.0
*/
- public static final String EDITOR_FOLDING_METHODS= "editor_folding_default_methods"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_METHODS = "editor_folding_default_methods"; //$NON-NLS-1$
/**
* A named preference that stores the value for macros folding for the default folding provider.
@@ -877,7 +881,7 @@ public class PreferenceConstants {
*
* @since 3.0
*/
- public static final String EDITOR_FOLDING_MACROS= "editor_folding_default_macros"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_MACROS = "editor_folding_default_macros"; //$NON-NLS-1$
/**
* A named preference that stores the value for comment folding for the default folding provider.
@@ -886,7 +890,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_FOLDING_COMMENTS= "editor_folding_default_comments"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_COMMENTS = "editor_folding_default_comments"; //$NON-NLS-1$
/**
* A named preference that stores the value for document comment folding for the default folding provider.
@@ -896,7 +900,7 @@ public class PreferenceConstants {
*
* @since 6.2
*/
- public static final String EDITOR_FOLDING_DOC_COMMENTS= "editor_folding_default_doc_comments"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_DOC_COMMENTS = "editor_folding_default_doc_comments"; //$NON-NLS-1$
/**
* A named preference that stores the value for non-document comment folding for the default folding provider.
@@ -906,7 +910,7 @@ public class PreferenceConstants {
*
* @since 6.2
*/
- public static final String EDITOR_FOLDING_NON_DOC_COMMENTS= "editor_folding_default_non_doc_comments"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_NON_DOC_COMMENTS = "editor_folding_default_non_doc_comments"; //$NON-NLS-1$
/**
* A named preference that stores the value for header comment folding for the default folding provider.
@@ -915,7 +919,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_FOLDING_HEADERS= "editor_folding_default_headers"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_HEADERS = "editor_folding_default_headers"; //$NON-NLS-1$
/**
* A named preference that stores the value for inactive code folding for the default folding provider.
@@ -924,7 +928,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_FOLDING_INACTIVE_CODE= "editor_folding_default_inactive"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_INACTIVE_CODE = "editor_folding_default_inactive"; //$NON-NLS-1$
/**
* A named preference that controls whether folding of preprocessor branches is enabled.
@@ -933,7 +937,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED= "editor_folding_preprocessor_enabled"; //$NON-NLS-1$
+ public static final String EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED = "editor_folding_preprocessor_enabled"; //$NON-NLS-1$
/**
* A named preference that controls if templates are formatted when applied.
@@ -942,7 +946,7 @@ public class PreferenceConstants {
*
* @since 2.1
*/
- public static final String TEMPLATES_USE_CODEFORMATTER= "org.eclipse.cdt.ui.text.templates.format"; //$NON-NLS-1$
+ public static final String TEMPLATES_USE_CODEFORMATTER = "org.eclipse.cdt.ui.text.templates.format"; //$NON-NLS-1$
/**
* A named preference that controls which profile is used by the code formatter.
@@ -961,7 +965,7 @@ public class PreferenceConstants {
* @since 5.9
*/
public final static String FORMATTING_SCOPE_FOR_EMPTY_SELECTION = "formattingScopeForEmptySelection"; //$NON-NLS-1$
-
+
/**
* The value of {@link #FORMATTING_SCOPE_FOR_EMPTY_SELECTION} specifying that the formatting
* applies to the whole document.
@@ -1035,14 +1039,14 @@ public class PreferenceConstants {
* @deprecated As of 4.0, replaced by {@link AbstractDecoratedTextEditorPreferenceConstants#EDITOR_SHOW_TEXT_HOVER_AFFORDANCE}
*/
@Deprecated
- public static final String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE;
+ public static final String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE;
/**
* A named preference prefix for semantic highlighting preferences.
*
* @since 4.0
*/
- public static final String EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX="semanticHighlighting."; //$NON-NLS-1$
+ public static final String EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX = "semanticHighlighting."; //$NON-NLS-1$
/**
* A named preference suffix that controls a semantic highlighting's color.
@@ -1054,7 +1058,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 4.0
*/
- public static final String EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX=".color"; //$NON-NLS-1$
+ public static final String EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX = ".color"; //$NON-NLS-1$
/**
* A named preference suffix that controls if semantic highlighting has the text attribute bold.
@@ -1063,7 +1067,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX=".bold"; //$NON-NLS-1$
+ public static final String EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX = ".bold"; //$NON-NLS-1$
/**
* A named preference suffix that controls if semantic highlighting has the text attribute italic.
@@ -1072,7 +1076,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX=".italic"; //$NON-NLS-1$
+ public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX = ".italic"; //$NON-NLS-1$
/**
* A named preference suffix that controls if semantic highlighting has the text attribute strikethrough.
@@ -1081,7 +1085,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX=".strikethrough"; //$NON-NLS-1$
+ public static final String EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX = ".strikethrough"; //$NON-NLS-1$
/**
* A named preference suffix that controls if semantic highlighting has the text attribute underline.
@@ -1090,7 +1094,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX=".underline"; //$NON-NLS-1$
+ public static final String EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX = ".underline"; //$NON-NLS-1$
/**
* A named preference suffix that controls if semantic highlighting is enabled.
@@ -1099,7 +1103,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX=".enabled"; //$NON-NLS-1$
+ public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX = ".enabled"; //$NON-NLS-1$
/**
* A named preference key that controls if semantic highlighting is enabled.
@@ -1108,7 +1112,7 @@ public class PreferenceConstants {
*
* @since 4.0
*/
- public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED= "semanticHighlighting.enabled"; //$NON-NLS-1$
+ public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED = "semanticHighlighting.enabled"; //$NON-NLS-1$
/**
* A named preference that controls if quick assist light bulbs are shown.
@@ -1118,7 +1122,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public static final String EDITOR_QUICKASSIST_LIGHTBULB="org.eclipse.cdt.quickassist.lightbulb"; //$NON-NLS-1$
+ public static final String EDITOR_QUICKASSIST_LIGHTBULB = "org.eclipse.cdt.quickassist.lightbulb"; //$NON-NLS-1$
/**
* A named preference that holds the background color used in the code assist selection dialog.
@@ -1131,7 +1135,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String CODEASSIST_PROPOSALS_BACKGROUND= "content_assist_proposals_background"; //$NON-NLS-1$
+ public final static String CODEASSIST_PROPOSALS_BACKGROUND = "content_assist_proposals_background"; //$NON-NLS-1$
/**
* A named preference that holds the foreground color used in the code assist selection dialog.
* <p>
@@ -1143,19 +1147,19 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String CODEASSIST_PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$
+ public final static String CODEASSIST_PROPOSALS_FOREGROUND = "content_assist_proposals_foreground"; //$NON-NLS-1$
/**
- * A named preference that holds the duration (in milli seconds) a content proposal may compute
- * until it is assumed that the proposal computer has a problem and should be disabled.
- * <p>
- * Value is of type {@code long}.
- *
- * @since 5.4
- */
- public final static String CODEASSIST_PROPOSALS_TIMEOUT= "content_assist_proposals_timeout"; //$NON-NLS-1$
+ * A named preference that holds the duration (in milli seconds) a content proposal may compute
+ * until it is assumed that the proposal computer has a problem and should be disabled.
+ * <p>
+ * Value is of type {@code long}.
+ *
+ * @since 5.4
+ */
+ public final static String CODEASSIST_PROPOSALS_TIMEOUT = "content_assist_proposals_timeout"; //$NON-NLS-1$
- /**
+ /**
* A named preference that holds the background color used for parameter hints.
* <p>
* Value is of type {@code String}. A RGB color value encoded as a string
@@ -1166,7 +1170,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String CODEASSIST_PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$
+ public final static String CODEASSIST_PARAMETERS_BACKGROUND = "content_assist_parameters_background"; //$NON-NLS-1$
/**
* A named preference that holds the foreground color used in the code assist selection dialog.
@@ -1179,7 +1183,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String CODEASSIST_PARAMETERS_FOREGROUND= "content_assist_parameters_foreground"; //$NON-NLS-1$
+ public final static String CODEASSIST_PARAMETERS_FOREGROUND = "content_assist_parameters_foreground"; //$NON-NLS-1$
/**
* A named preference that controls whether all dirty editors are automatically saved before a refactoring is
@@ -1188,7 +1192,7 @@ public class PreferenceConstants {
* Value is of type {@code Boolean}.
* @since 5.3
*/
- public static final String REFACTOR_SAVE_ALL_EDITORS= "Refactoring.savealleditors"; //$NON-NLS-1$
+ public static final String REFACTOR_SAVE_ALL_EDITORS = "Refactoring.savealleditors"; //$NON-NLS-1$
/**
* A named preference that controls whether certain refactorings use a lightweight UI when
@@ -1197,7 +1201,7 @@ public class PreferenceConstants {
* Value is of type {@code Boolean}.
* @since 5.3
*/
- public static final String REFACTOR_LIGHTWEIGHT= "Refactor.lightweight"; //$NON-NLS-1$
+ public static final String REFACTOR_LIGHTWEIGHT = "Refactor.lightweight"; //$NON-NLS-1$
/**
* A named preference that controls whether words containing digits should
@@ -1207,7 +1211,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_IGNORE_DIGITS= "spelling_ignore_digits"; //$NON-NLS-1$
+ public final static String SPELLING_IGNORE_DIGITS = "spelling_ignore_digits"; //$NON-NLS-1$
/**
* A named preference that controls whether mixed case words should be
@@ -1217,7 +1221,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_IGNORE_MIXED= "spelling_ignore_mixed"; //$NON-NLS-1$
+ public final static String SPELLING_IGNORE_MIXED = "spelling_ignore_mixed"; //$NON-NLS-1$
/**
* A named preference that controls whether sentence capitalization should
@@ -1227,7 +1231,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_IGNORE_SENTENCE= "spelling_ignore_sentence"; //$NON-NLS-1$
+ public final static String SPELLING_IGNORE_SENTENCE = "spelling_ignore_sentence"; //$NON-NLS-1$
/**
* A named preference that controls whether upper case words should be
@@ -1237,7 +1241,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_IGNORE_UPPER= "spelling_ignore_upper"; //$NON-NLS-1$
+ public final static String SPELLING_IGNORE_UPPER = "spelling_ignore_upper"; //$NON-NLS-1$
/**
* A named preference that controls whether URLs should be ignored during
@@ -1247,7 +1251,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_IGNORE_URLS= "spelling_ignore_urls"; //$NON-NLS-1$
+ public final static String SPELLING_IGNORE_URLS = "spelling_ignore_urls"; //$NON-NLS-1$
/**
* A named preference that controls whether single letters
@@ -1257,7 +1261,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_IGNORE_SINGLE_LETTERS= "spelling_ignore_single_letters"; //$NON-NLS-1$
+ public final static String SPELLING_IGNORE_SINGLE_LETTERS = "spelling_ignore_single_letters"; //$NON-NLS-1$
/**
* A named preference that controls whether string literals
@@ -1267,7 +1271,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_IGNORE_STRING_LITERALS= "spelling_ignore_string_literals"; //$NON-NLS-1$
+ public final static String SPELLING_IGNORE_STRING_LITERALS = "spelling_ignore_string_literals"; //$NON-NLS-1$
/**
* A named preference that controls whether non-letters at word boundaries
@@ -1277,7 +1281,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_IGNORE_NON_LETTERS= "spelling_ignore_non_letters"; //$NON-NLS-1$
+ public final static String SPELLING_IGNORE_NON_LETTERS = "spelling_ignore_non_letters"; //$NON-NLS-1$
/**
* A named preference that controls the locale used for spell checking.
@@ -1286,7 +1290,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_LOCALE= "spelling_locale"; //$NON-NLS-1$
+ public final static String SPELLING_LOCALE = "spelling_locale"; //$NON-NLS-1$
/**
* A named preference that controls the number of proposals offered during
@@ -1296,7 +1300,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_PROPOSAL_THRESHOLD= "spelling_proposal_threshold"; //$NON-NLS-1$
+ public final static String SPELLING_PROPOSAL_THRESHOLD = "spelling_proposal_threshold"; //$NON-NLS-1$
/**
* A named preference that controls the maximum number of problems reported
@@ -1306,7 +1310,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_PROBLEMS_THRESHOLD= "spelling_problems_threshold"; //$NON-NLS-1$
+ public final static String SPELLING_PROBLEMS_THRESHOLD = "spelling_problems_threshold"; //$NON-NLS-1$
/**
* A named preference that specifies the workspace user dictionary.
@@ -1315,7 +1319,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_USER_DICTIONARY= "spelling_user_dictionary"; //$NON-NLS-1$
+ public final static String SPELLING_USER_DICTIONARY = "spelling_user_dictionary"; //$NON-NLS-1$
/**
* A named preference that specifies encoding of the workspace user dictionary.
@@ -1324,7 +1328,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_USER_DICTIONARY_ENCODING= "spelling_user_dictionary_encoding"; //$NON-NLS-1$
+ public final static String SPELLING_USER_DICTIONARY_ENCODING = "spelling_user_dictionary_encoding"; //$NON-NLS-1$
/**
* A named preference that specifies whether spelling dictionaries are available to content assist.
@@ -1336,7 +1340,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public final static String SPELLING_ENABLE_CONTENTASSIST= "spelling_enable_contentassist"; //$NON-NLS-1$
+ public final static String SPELLING_ENABLE_CONTENTASSIST = "spelling_enable_contentassist"; //$NON-NLS-1$
/**
* A named preference that controls if documentation comment stubs will be added
@@ -1345,7 +1349,7 @@ public class PreferenceConstants {
* Value is of type {@code Boolean}.
* @since 5.0
*/
- public static final String CODEGEN_ADD_COMMENTS= "org.eclipse.cdt.ui.add_comments"; //$NON-NLS-1$
+ public static final String CODEGEN_ADD_COMMENTS = "org.eclipse.cdt.ui.add_comments"; //$NON-NLS-1$
/**
* A named preference that holds the source hover background color.
@@ -1357,7 +1361,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.0
*/
- public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR= "sourceHoverBackgroundColor"; //$NON-NLS-1$
+ public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR = "sourceHoverBackgroundColor"; //$NON-NLS-1$
/**
* A named preference that tells whether to use the system
@@ -1370,7 +1374,7 @@ public class PreferenceConstants {
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.0
*/
- public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT= "sourceHoverBackgroundColor.SystemDefault"; //$NON-NLS-1$
+ public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT = "sourceHoverBackgroundColor.SystemDefault"; //$NON-NLS-1$
/**
* A named preference that controls whether occurrences are marked in the editor.
@@ -1379,7 +1383,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public static final String EDITOR_MARK_OCCURRENCES= "markOccurrences"; //$NON-NLS-1$
+ public static final String EDITOR_MARK_OCCURRENCES = "markOccurrences"; //$NON-NLS-1$
/**
* A named preference that controls whether occurrences are sticky in the editor.
@@ -1389,7 +1393,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
- public static final String EDITOR_STICKY_OCCURRENCES= "stickyOccurrences"; //$NON-NLS-1$
+ public static final String EDITOR_STICKY_OCCURRENCES = "stickyOccurrences"; //$NON-NLS-1$
/**
* A named preference that controls whether occurrences of overloaded operators are marked in the editor.
@@ -1399,7 +1403,7 @@ public class PreferenceConstants {
*
* @since 5.3
*/
- public static final String EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES= "markOverloadedOperatorsOccurrences"; //$NON-NLS-1$
+ public static final String EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES = "markOverloadedOperatorsOccurrences"; //$NON-NLS-1$
/**
* A named preference that controls whether all scalability mode options should be turned on.
@@ -2049,7 +2053,7 @@ public class PreferenceConstants {
*/
public static final String INCLUDE_STYLE_RELATED = "includeStyle.related"; //$NON-NLS-1$
/**
- * Include style for the header with the same name as the including file.
+ * Include style for the header with the same name as the including file.
* The value of the preference is an XML representation of
* {@link org.eclipse.cdt.internal.ui.refactoring.includes.IncludeGroupStyle}.
*
@@ -2153,8 +2157,8 @@ public class PreferenceConstants {
*
* @since 6.1
*/
- public static final String EDITOR_ANNOTATION_ROLL_OVER= "editor_annotation_roll_over"; //$NON-NLS-1$
-
+ public static final String EDITOR_ANNOTATION_ROLL_OVER = "editor_annotation_roll_over"; //$NON-NLS-1$
+
/**
* Returns the CDT-UI preference store.
*
@@ -2164,12 +2168,12 @@ public class PreferenceConstants {
return CUIPlugin.getDefault().getPreferenceStore();
}
- /**
- * Initializes the given preference store with the default values.
- *
- * @param store the preference store to be initialized
- */
- public static void initializeDefaultValues(IPreferenceStore store) {
+ /**
+ * Initializes the given preference store with the default values.
+ *
+ * @param store the preference store to be initialized
+ */
+ public static void initializeDefaultValues(IPreferenceStore store) {
store.setDefault(EDITOR_CORRECTION_INDICATION, false);
store.setDefault(EDITOR_SHOW_SEGMENTS, false);
store.setDefault(PREF_SHOW_CU_CHILDREN, true);
@@ -2178,10 +2182,12 @@ public class PreferenceConstants {
// This option has to be turned on for the spelling checker too work.
store.setDefault(EDITOR_EVALUATE_TEMPORARY_PROBLEMS, true);
- int sourceHoverModifier= SWT.MOD2;
- String sourceHoverModifierName= Action.findModifierString(sourceHoverModifier); // Shift
- store.setDefault(EDITOR_TEXT_HOVER_MODIFIERS, "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + sourceHoverModifierName); //$NON-NLS-1$
- store.setDefault(EDITOR_TEXT_HOVER_MODIFIER_MASKS, "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + sourceHoverModifier); //$NON-NLS-1$
+ int sourceHoverModifier = SWT.MOD2;
+ String sourceHoverModifierName = Action.findModifierString(sourceHoverModifier); // Shift
+ store.setDefault(EDITOR_TEXT_HOVER_MODIFIERS,
+ "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + sourceHoverModifierName); //$NON-NLS-1$
+ store.setDefault(EDITOR_TEXT_HOVER_MODIFIER_MASKS,
+ "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + sourceHoverModifier); //$NON-NLS-1$
store.setDefault(EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT, true);
@@ -2195,7 +2201,7 @@ public class PreferenceConstants {
store.setDefault(EDITOR_SINGLE_LINE_COMMENT_ITALIC, false);
store.setDefault(EDITOR_TASK_TAG_BOLD, true);
- store.setDefault(EDITOR_TASK_TAG_ITALIC, false);
+ store.setDefault(EDITOR_TASK_TAG_ITALIC, false);
store.setDefault(EDITOR_C_KEYWORD_BOLD, true);
store.setDefault(EDITOR_C_KEYWORD_ITALIC, false);
@@ -2209,23 +2215,23 @@ public class PreferenceConstants {
store.setDefault(EDITOR_C_DEFAULT_BOLD, false);
store.setDefault(EDITOR_C_DEFAULT_ITALIC, false);
- store.setDefault(EDITOR_C_OPERATOR_BOLD, false);
- store.setDefault(EDITOR_C_OPERATOR_ITALIC, false);
+ store.setDefault(EDITOR_C_OPERATOR_BOLD, false);
+ store.setDefault(EDITOR_C_OPERATOR_ITALIC, false);
- store.setDefault(EDITOR_C_BRACES_BOLD, false);
- store.setDefault(EDITOR_C_BRACES_ITALIC, false);
+ store.setDefault(EDITOR_C_BRACES_BOLD, false);
+ store.setDefault(EDITOR_C_BRACES_ITALIC, false);
- store.setDefault(EDITOR_C_NUMBER_BOLD, false);
- store.setDefault(EDITOR_C_NUMBER_ITALIC, false);
+ store.setDefault(EDITOR_C_NUMBER_BOLD, false);
+ store.setDefault(EDITOR_C_NUMBER_ITALIC, false);
store.setDefault(EDITOR_PP_DIRECTIVE_BOLD, true);
store.setDefault(EDITOR_PP_DIRECTIVE_ITALIC, false);
- store.setDefault(EDITOR_PP_HEADER_BOLD, false);
- store.setDefault(EDITOR_PP_HEADER_ITALIC, false);
+ store.setDefault(EDITOR_PP_HEADER_BOLD, false);
+ store.setDefault(EDITOR_PP_HEADER_ITALIC, false);
- store.setDefault(EDITOR_PP_DEFAULT_BOLD, false);
- store.setDefault(EDITOR_PP_DEFAULT_ITALIC, false);
+ store.setDefault(EDITOR_PP_DEFAULT_BOLD, false);
+ store.setDefault(EDITOR_PP_DEFAULT_ITALIC, false);
store.setDefault(EDITOR_ASM_LABEL_BOLD, true);
store.setDefault(EDITOR_ASM_LABEL_ITALIC, false);
@@ -2274,7 +2280,8 @@ public class PreferenceConstants {
// Content assist
store.setDefault(CODEASSIST_EXCLUDED_CATEGORIES, "org.eclipse.cdt.ui.textProposalCategory\0"); //$NON-NLS-1$
- store.setDefault(CODEASSIST_CATEGORY_ORDER, "org.eclipse.cdt.ui.parserProposalCategory:65539\0org.eclipse.cdt.ui.textProposalCategory:65541\0org.eclipse.cdt.ui.templateProposalCategory:2\0org.eclipse.cdt.ui.helpProposalCategory:5\0"); //$NON-NLS-1$
+ store.setDefault(CODEASSIST_CATEGORY_ORDER,
+ "org.eclipse.cdt.ui.parserProposalCategory:65539\0org.eclipse.cdt.ui.textProposalCategory:65541\0org.eclipse.cdt.ui.templateProposalCategory:2\0org.eclipse.cdt.ui.helpProposalCategory:5\0"); //$NON-NLS-1$
store.setDefault(CODEASSIST_PROPOSALS_TIMEOUT, 5000);
@@ -2284,11 +2291,11 @@ public class PreferenceConstants {
// Spell checking
store.setDefault(SPELLING_LOCALE, "en_US"); //$NON-NLS-1$
- String isInitializedKey= "spelling_locale_initialized"; //$NON-NLS-1$
+ String isInitializedKey = "spelling_locale_initialized"; //$NON-NLS-1$
if (!store.getBoolean(isInitializedKey)) {
store.setValue(isInitializedKey, true);
- Locale locale= SpellCheckEngine.getDefaultLocale();
- locale= SpellCheckEngine.findClosestLocale(locale);
+ Locale locale = SpellCheckEngine.getDefaultLocale();
+ locale = SpellCheckEngine.findClosestLocale(locale);
if (locale != null)
store.setValue(SPELLING_LOCALE, locale.toString());
}
@@ -2303,8 +2310,7 @@ public class PreferenceConstants {
store.setDefault(SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$
// Note: For backwards compatibility we must use the property and not the workspace default
- store.setDefault(SPELLING_USER_DICTIONARY_ENCODING,
- System.getProperty("file.encoding")); //$NON-NLS-1$
+ store.setDefault(SPELLING_USER_DICTIONARY_ENCODING, System.getProperty("file.encoding")); //$NON-NLS-1$
store.setDefault(SPELLING_PROPOSAL_THRESHOLD, 20);
store.setDefault(SPELLING_PROBLEMS_THRESHOLD, 100);
@@ -2333,8 +2339,7 @@ public class PreferenceConstants {
store.setDefault(SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION, false);
// Code Templates
- store.setDefault(CODE_TEMPLATES_INCLUDE_GUARD_SCHEME,
- CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_PATH);
+ store.setDefault(CODE_TEMPLATES_INCLUDE_GUARD_SCHEME, CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_PATH);
// Name Style
store.setDefault(NAME_STYLE_CONSTANT_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_UPPER_CASE);
@@ -2382,16 +2387,16 @@ public class PreferenceConstants {
// Colors that are set by the current theme
CUIPreferenceInitializer.setThemeBasedPreferences(store, false);
- }
-
- /**
- * Returns the node in the preference in the given context.
- *
- * @param key The preference key.
- * @param project The current context or {@code null} if no context is available and
- * the workspace setting should be taken. Note that passing {@code null} should be avoided.
- * @return Returns the node matching the given context.
- */
+ }
+
+ /**
+ * Returns the node in the preference in the given context.
+ *
+ * @param key The preference key.
+ * @param project The current context or {@code null} if no context is available and
+ * the workspace setting should be taken. Note that passing {@code null} should be avoided.
+ * @return Returns the node matching the given context.
+ */
private static IEclipsePreferences getPreferenceNode(String key, IProject project) {
IEclipsePreferences node = null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/SharedImagesFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/SharedImagesFactory.java
index bb432a29c26..ea39946ba4e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/SharedImagesFactory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/SharedImagesFactory.java
@@ -31,7 +31,6 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.osgi.framework.Bundle;
-
/**
* A helper class to provide common methods to set up managed image repository for a plugin.
* <p>
@@ -43,7 +42,7 @@ import org.osgi.framework.Bundle;
* <p>
* See {@link CDTSharedImages} for an example of using this factory.
* </p>
- *
+ *
* @since 5.7
*
*/
@@ -56,12 +55,12 @@ public class SharedImagesFactory {
/**
* Constructor.
- *
+ *
* @param plugin - the plugin where the images are defined.
*/
public SharedImagesFactory(Plugin plugin) {
this.bundle = plugin.getBundle();
-
+
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
@@ -87,7 +86,7 @@ public class SharedImagesFactory {
IPath projectRelativePath = new Path(key);
URL url = FileLocator.find(bundle, projectRelativePath, null);
- if (url==null) {
+ if (url == null) {
Exception e = new Exception(NLS.bind(Messages.CDTSharedImages_MissingImage, key, CUIPlugin.PLUGIN_ID));
CUIPlugin.log(e.getMessage(), e);
}
@@ -118,10 +117,10 @@ public class SharedImagesFactory {
*/
public Image getImage(String key) {
URL url = getUrl(key);
- String registryKey = url!=null ? url.toString() : null;
+ String registryKey = url != null ? url.toString() : null;
Image image = imageRegistry.get(registryKey);
- if (image==null) {
- ImageDescriptor descriptor= ImageDescriptor.createFromURL(url);
+ if (image == null) {
+ ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
imageRegistry.put(registryKey, descriptor);
image = imageRegistry.get(registryKey);
}
@@ -138,9 +137,9 @@ public class SharedImagesFactory {
*/
public ImageDescriptor getImageDescriptor(String key) {
URL url = getUrl(key);
- String registryKey = url!=null ? url.toString() : null;
+ String registryKey = url != null ? url.toString() : null;
ImageDescriptor descriptor = imageRegistry.getDescriptor(registryKey);
- if (descriptor==null) {
+ if (descriptor == null) {
descriptor = ImageDescriptor.createFromURL(url);
imageRegistry.put(registryKey, descriptor);
}
@@ -151,7 +150,7 @@ public class SharedImagesFactory {
* Retrieves an overlaid image from the internal repository of images.
* If there is no image one will be created.
*
- * The decoration overlay for the base image will use the array of
+ * The decoration overlay for the base image will use the array of
* provided overlays. The indices of the array correspond to the values
* of the 5 overlay constants defined on {@link IDecoration}, i.e.
* {@link IDecoration#TOP_LEFT},
@@ -166,32 +165,32 @@ public class SharedImagesFactory {
* an element to the array if no overlay should be added in given quadrant.
*/
public Image getImageOverlaid(String baseKey, String[] overlayKeys) {
- Assert.isTrue(overlayKeys.length==5);
+ Assert.isTrue(overlayKeys.length == 5);
- String suffix=""; //$NON-NLS-1$
- for (int i=0;i<5;i++) {
- String overlayKey=""; //$NON-NLS-1$
- if (i<overlayKeys.length && overlayKeys[i]!=null) {
- overlayKey=overlayKeys[i];
+ String suffix = ""; //$NON-NLS-1$
+ for (int i = 0; i < 5; i++) {
+ String overlayKey = ""; //$NON-NLS-1$
+ if (i < overlayKeys.length && overlayKeys[i] != null) {
+ overlayKey = overlayKeys[i];
}
- suffix=suffix+OVERLAY_SEPARATOR+overlayKey;
+ suffix = suffix + OVERLAY_SEPARATOR + overlayKey;
}
- if (suffix.length()==5) {
+ if (suffix.length() == 5) {
// No overlays added
Image result = getImage(baseKey);
return result;
}
- String compositeKey=baseKey+suffix;
+ String compositeKey = baseKey + suffix;
Image result = imageRegistry.get(compositeKey);
- if (result!=null)
+ if (result != null)
return result;
Image baseImage = getImage(baseKey);
ImageDescriptor[] overlayDescriptors = new ImageDescriptor[5];
- for (int i=0;i<5;i++) {
+ for (int i = 0; i < 5; i++) {
String overlayKey = overlayKeys[i];
- if (overlayKey!=null) {
+ if (overlayKey != null) {
overlayDescriptors[i] = getImageDescriptor(overlayKey);
}
}
@@ -217,8 +216,7 @@ public class SharedImagesFactory {
*/
public Image getImageOverlaid(String baseKey, String overlayKey, int quadrant) {
String[] overlayKeys = new String[5];
- overlayKeys[quadrant]=overlayKey;
+ overlayKeys[quadrant] = overlayKey;
return getImageOverlaid(baseKey, overlayKeys);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java
index 6dff9cc7406..cc78d7078ff 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java
@@ -100,7 +100,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase
*/
@Override
public void selectionChanged(IAction action, ISelection selection) {
- if (actionMenuCache == null){
+ if (actionMenuCache == null) {
actionMenuCache = action;
}
onSelectionChanged(action, selection);
@@ -115,7 +115,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase
menu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
- fillMenu((Menu)e.widget);
+ fillMenu((Menu) e.widget);
}
});
}
@@ -129,16 +129,17 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase
* Update the tool tip based on the currently selected project and active configuration.
* @param action - The build configuration menu to change the tool tip on
*/
- public void updateBuildConfigMenuToolTip(IAction action){
+ public void updateBuildConfigMenuToolTip(IAction action) {
String toolTipText = ""; //$NON-NLS-1$
if (fProjects.size() <= 5) {
StringBuilder sb = new StringBuilder();
for (IProject prj : fProjects) {
- if (prj != null){
+ if (prj != null) {
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false);
if (prjd != null) {
sb.append(NLS.bind(ActionMessages.BuildActiveConfigMenuAction_buildConfigTooltip,
- prjd.getActiveConfiguration().getName(), prj.getName())).append(System.getProperty("line.separator")); //$NON-NLS-1$
+ prjd.getActiveConfiguration().getName(), prj.getName()))
+ .append(System.getProperty("line.separator")); //$NON-NLS-1$
}
}
}
@@ -151,7 +152,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase
@Override
public void handleEvent(CProjectDescriptionEvent event) {
- if (actionMenuCache != null){
+ if (actionMenuCache != null) {
updateBuildConfigMenuToolTip(actionMenuCache);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java
index 5cea9425aa7..0caf2b38e32 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java
@@ -23,20 +23,21 @@ import org.eclipse.ui.actions.BuildAction;
* Action which builds the active configurations of the selected projects.
*/
public class BuildConfigAction extends ChangeConfigAction {
-
+
private BuildAction buildAction;
/**
* Constructs the action.
- * @param projects List of selected managed-built projects
+ * @param projects List of selected managed-built projects
* @param configName Build configuration name
* @param accel Number to be used as accelerator
*/
- public BuildConfigAction(HashSet<IProject> projects, String configName, String displayName, int accel, BuildAction buildAction) {
+ public BuildConfigAction(HashSet<IProject> projects, String configName, String displayName, int accel,
+ BuildAction buildAction) {
super(projects, configName, displayName, accel);
this.buildAction = buildAction;
}
-
+
/**
* @see org.eclipse.jface.action.IAction#run()
*/
@@ -44,6 +45,6 @@ public class BuildConfigAction extends ChangeConfigAction {
public void run() {
super.run();
buildAction.selectionChanged(new StructuredSelection(fProjects.toArray()));
- buildAction.run();
+ buildAction.run();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java
index 3451924bbf9..e9aa791452d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java
@@ -16,56 +16,56 @@ package org.eclipse.cdt.ui.actions;
/**
* Action ids for standard actions, for groups in the menu bar, and
* for actions in context menus of CDT views.
- *
+ *
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @since 2.0
*/
public class CdtActionConstants {
// Navigate menu
-
+
/**
* Navigate menu: name of standard Goto Type global action
* (value <code>"org.eclipse.cdt.ui.actions.GoToType"</code>).
*/
- public static final String GOTO_TYPE= "org.eclipse.cdt.ui.actions.GoToType"; //$NON-NLS-1$
-
+ public static final String GOTO_TYPE = "org.eclipse.cdt.ui.actions.GoToType"; //$NON-NLS-1$
+
/**
* Navigate menu: name of standard Open Super Implementation global action
* (value <code>"org.eclipse.cdt.ui.actions.OpenSuperImplementation"</code>).
*/
- public static final String OPEN_SUPER_IMPLEMENTATION= "org.eclipse.cdt.ui.actions.OpenSuperImplementation"; //$NON-NLS-1$
-
- /**
- * Navigate menu: name of standard Open Declaration global action
- * (value <code>"org.eclipse.cdt.ui.actions.OpenDeclaration"</code>).
- * @since 5.0
- */
- public static final String OPEN_DECLARATION= "org.eclipse.cdt.ui.actions.OpenDeclaration"; //$NON-NLS-1$
+ public static final String OPEN_SUPER_IMPLEMENTATION = "org.eclipse.cdt.ui.actions.OpenSuperImplementation"; //$NON-NLS-1$
+
+ /**
+ * Navigate menu: name of standard Open Declaration global action
+ * (value <code>"org.eclipse.cdt.ui.actions.OpenDeclaration"</code>).
+ * @since 5.0
+ */
+ public static final String OPEN_DECLARATION = "org.eclipse.cdt.ui.actions.OpenDeclaration"; //$NON-NLS-1$
/**
* Navigate menu: name of standard Open Type Hierarchy global action
* (value <code>"org.eclipse.cdt.ui.actions.OpenTypeHierarchy"</code>).
*/
- public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.cdt.ui.actions.OpenTypeHierarchy"; //$NON-NLS-1$
+ public static final String OPEN_TYPE_HIERARCHY = "org.eclipse.cdt.ui.actions.OpenTypeHierarchy"; //$NON-NLS-1$
- /**
- * Navigate menu: name of standard Open Call Hierarchy global action
- * (value <code>"org.eclipse.cdt.ui.actions.OpenCallHierarchy"</code>).
- * @since 3.0
- */
- public static final String OPEN_CALL_HIERARCHY= "org.eclipse.cdt.ui.actions.OpenCallHierarchy"; //$NON-NLS-1$
+ /**
+ * Navigate menu: name of standard Open Call Hierarchy global action
+ * (value <code>"org.eclipse.cdt.ui.actions.OpenCallHierarchy"</code>).
+ * @since 3.0
+ */
+ public static final String OPEN_CALL_HIERARCHY = "org.eclipse.cdt.ui.actions.OpenCallHierarchy"; //$NON-NLS-1$
- /**
- * Navigate menu: name of standard Open Include Browser global action
- * (value <code>"org.eclipse.cdt.ui.actions.OpenIncludeBrowser"</code>).
- * @since 4.0
- */
- public static final String OPEN_INCLUDE_BROWSER= "org.eclipse.cdt.ui.actions.OpenIncludeBrowser"; //$NON-NLS-1$
+ /**
+ * Navigate menu: name of standard Open Include Browser global action
+ * (value <code>"org.eclipse.cdt.ui.actions.OpenIncludeBrowser"</code>).
+ * @since 4.0
+ */
+ public static final String OPEN_INCLUDE_BROWSER = "org.eclipse.cdt.ui.actions.OpenIncludeBrowser"; //$NON-NLS-1$
// Edit menu
@@ -73,50 +73,50 @@ public class CdtActionConstants {
* Edit menu: name of standard Code Assist global action
* (value <code>"org.eclipse.cdt.ui.actions.ContentAssist"</code>).
*/
- public static final String CONTENT_ASSIST= "org.eclipse.cdt.ui.actions.ContentAssist"; //$NON-NLS-1$
+ public static final String CONTENT_ASSIST = "org.eclipse.cdt.ui.actions.ContentAssist"; //$NON-NLS-1$
+
+ // Source menu
- // Source menu
-
/**
* Source menu: name of standard Comment global action
* (value <code>"org.eclipse.cdt.ui.actions.Comment"</code>).
*/
- public static final String COMMENT= "org.eclipse.cdt.ui.actions.Comment"; //$NON-NLS-1$
-
+ public static final String COMMENT = "org.eclipse.cdt.ui.actions.Comment"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Uncomment global action
* (value <code>"org.eclipse.cdt.ui.actions.Uncomment"</code>).
*/
- public static final String UNCOMMENT= "org.eclipse.cdt.ui.actions.Uncomment"; //$NON-NLS-1$
-
+ public static final String UNCOMMENT = "org.eclipse.cdt.ui.actions.Uncomment"; //$NON-NLS-1$
+
/**
* Source menu: name of standard ToggleComment global action
* (value <code>"org.eclipse.cdt.ui.actions.ToggleComment"</code>).
* @since 3.0
*/
- public static final String TOGGLE_COMMENT= "org.eclipse.cdt.ui.actions.ToggleComment"; //$NON-NLS-1$
-
+ public static final String TOGGLE_COMMENT = "org.eclipse.cdt.ui.actions.ToggleComment"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Block Comment global action
* (value <code>"org.eclipse.cdt.ui.actions.AddBlockComment"</code>).
- *
+ *
* @since 3.0
*/
- public static final String ADD_BLOCK_COMMENT= "org.eclipse.cdt.ui.actions.AddBlockComment"; //$NON-NLS-1$
-
+ public static final String ADD_BLOCK_COMMENT = "org.eclipse.cdt.ui.actions.AddBlockComment"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Block Uncomment global action
* (value <code>"org.eclipse.cdt.ui.actions.RemoveBlockComment"</code>).
- *
+ *
* @since 3.0
*/
- public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.cdt.ui.actions.RemoveBlockComment"; //$NON-NLS-1$
-
+ public static final String REMOVE_BLOCK_COMMENT = "org.eclipse.cdt.ui.actions.RemoveBlockComment"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Indent global action
* (value <code>"org.eclipse.cdt.ui.actions.Indent"</code>).
*/
- public static final String INDENT= "org.eclipse.cdt.ui.actions.Indent"; //$NON-NLS-1$
+ public static final String INDENT = "org.eclipse.cdt.ui.actions.Indent"; //$NON-NLS-1$
/**
* Source menu: name of standard Align Const global action
@@ -130,370 +130,368 @@ public class CdtActionConstants {
* Source menu: name of standard Shift Right action
* (value <code>"org.eclipse.cdt.ui.actions.ShiftRight"</code>).
*/
- public static final String SHIFT_RIGHT= "org.eclipse.cdt.ui.actions.ShiftRight"; //$NON-NLS-1$
-
+ public static final String SHIFT_RIGHT = "org.eclipse.cdt.ui.actions.ShiftRight"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Shift Left global action
* (value <code>"org.eclipse.cdt.ui.actions.ShiftLeft"</code>).
*/
- public static final String SHIFT_LEFT= "org.eclipse.cdt.ui.actions.ShiftLeft"; //$NON-NLS-1$
-
+ public static final String SHIFT_LEFT = "org.eclipse.cdt.ui.actions.ShiftLeft"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Format global action
* (value <code>"org.eclipse.cdt.ui.actions.Format"</code>).
*/
- public static final String FORMAT= "org.eclipse.cdt.ui.actions.Format"; //$NON-NLS-1$
+ public static final String FORMAT = "org.eclipse.cdt.ui.actions.Format"; //$NON-NLS-1$
/**
* Source menu: name of standard Add Include global action
* (value <code>"org.eclipse.cdt.ui.actions.AddInclude"</code>).
*/
- public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.actions.AddInclude"; //$NON-NLS-1$
+ public static final String ADD_INCLUDE = "org.eclipse.cdt.ui.actions.AddInclude"; //$NON-NLS-1$
/**
* Source menu: name of standard Organize Includes global action
* (value <code>"org.eclipse.cdt.ui.actions.OrganizeIncludes"</code>).
* @since 5.6
*/
- public static final String ORGANIZE_INCLUDES= "org.eclipse.cdt.ui.actions.OrganizeIncludes"; //$NON-NLS-1$
+ public static final String ORGANIZE_INCLUDES = "org.eclipse.cdt.ui.actions.OrganizeIncludes"; //$NON-NLS-1$
/**
* Source menu: name of standard Sort Lines global action
* (value <code>"org.eclipse.cdt.ui.actions.SortLines"</code>).
* @since 5.2
*/
- public static final String SORT_LINES= "org.eclipse.cdt.ui.actions.SortLines"; //$NON-NLS-1$
+ public static final String SORT_LINES = "org.eclipse.cdt.ui.actions.SortLines"; //$NON-NLS-1$
/**
* Source menu: name of standard Sort Members global action (value
* <code>"org.eclipse.cdt.ui.actions.SortMembers"</code>).
*/
- public static final String SORT_MEMBERS= "org.eclipse.cdt.ui.actions.SortMembers"; //$NON-NLS-1$
+ public static final String SORT_MEMBERS = "org.eclipse.cdt.ui.actions.SortMembers"; //$NON-NLS-1$
/**
* Source menu: name of standard Surround with try/catch block global action
* (value <code>"org.eclipse.cdt.ui.actions.SurroundWithTryCatch"</code>).
*/
- public static final String SURROUND_WITH_TRY_CATCH= "org.eclipse.cdt.ui.actions.SurroundWithTryCatch"; //$NON-NLS-1$
-
+ public static final String SURROUND_WITH_TRY_CATCH = "org.eclipse.cdt.ui.actions.SurroundWithTryCatch"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Override Methods global action
* (value <code>"org.eclipse.cdt.ui.actions.OverrideMethods"</code>).
*/
- public static final String OVERRIDE_METHODS= "org.eclipse.cdt.ui.actions.OverrideMethods"; //$NON-NLS-1$
-
+ public static final String OVERRIDE_METHODS = "org.eclipse.cdt.ui.actions.OverrideMethods"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Generate Getter and Setter global action
* (value <code>"org.eclipse.cdt.ui.actions.GenerateGetterSetter"</code>).
*/
- public static final String GENERATE_GETTER_SETTER= "org.eclipse.cdt.ui.actions.GenerateGetterSetter"; //$NON-NLS-1$
+ public static final String GENERATE_GETTER_SETTER = "org.eclipse.cdt.ui.actions.GenerateGetterSetter"; //$NON-NLS-1$
/**
* Source menu: name of standard delegate methods global action (value
* <code>"org.eclipse.cdt.ui.actions.GenerateDelegateMethods"</code>).
*/
- public static final String GENERATE_DELEGATE_METHODS= "org.eclipse.cdt.ui.actions.GenerateDelegateMethods"; //$NON-NLS-1$
+ public static final String GENERATE_DELEGATE_METHODS = "org.eclipse.cdt.ui.actions.GenerateDelegateMethods"; //$NON-NLS-1$
/**
* Source menu: name of standard Add Constructor From Superclass global action
* (value <code>"org.eclipse.cdt.ui.actions.AddConstructorFromSuperclass"</code>).
*/
- public static final String ADD_CONSTRUCTOR_FROM_SUPERCLASS= "org.eclipse.cdt.ui.actions.AddConstructorFromSuperclass"; //$NON-NLS-1$
-
+ public static final String ADD_CONSTRUCTOR_FROM_SUPERCLASS = "org.eclipse.cdt.ui.actions.AddConstructorFromSuperclass"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Generate Constructor using Fields global action
* (value <code>"org.eclipse.cdt.ui.actions.GenerateConstructorUsingFields"</code>).
*/
- public static final String GENERATE_CONSTRUCTOR_USING_FIELDS= "org.eclipse.cdt.ui.actions.GenerateConstructorUsingFields"; //$NON-NLS-1$
-
+ public static final String GENERATE_CONSTRUCTOR_USING_FIELDS = "org.eclipse.cdt.ui.actions.GenerateConstructorUsingFields"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Add Cppdoc Comment global action
* (value <code>"org.eclipse.cdt.ui.actions.AddCppDocComment"</code>).
*/
- public static final String ADD_CPP_DOC_COMMENT= "org.eclipse.cdt.ui.actions.AddCppDocComment"; //$NON-NLS-1$
+ public static final String ADD_CPP_DOC_COMMENT = "org.eclipse.cdt.ui.actions.AddCppDocComment"; //$NON-NLS-1$
/**
* Source menu: name of standard Find Strings to Externalize global action
* (value <code>"org.eclipse.cdt.ui.actions.FindStringsToExternalize"</code>).
*/
- public static final String FIND_STRINGS_TO_EXTERNALIZE= "org.eclipse.cdt.ui.actions.FindStringsToExternalize"; //$NON-NLS-1$
-
+ public static final String FIND_STRINGS_TO_EXTERNALIZE = "org.eclipse.cdt.ui.actions.FindStringsToExternalize"; //$NON-NLS-1$
+
/**
* Source menu: name of standard Externalize Strings global action
* (value <code>"org.eclipse.cdt.ui.actions.ExternalizeStrings"</code>).
*/
- public static final String EXTERNALIZE_STRINGS= "org.eclipse.cdt.ui.actions.ExternalizeStrings"; //$NON-NLS-1$
-
+ public static final String EXTERNALIZE_STRINGS = "org.eclipse.cdt.ui.actions.ExternalizeStrings"; //$NON-NLS-1$
+
// Refactor menu
-
+
/**
* Refactor menu: name of standard Self Encapsulate Field global action
* (value <code>"org.eclipse.cdt.ui.actions.SelfEncapsulateField"</code>).
*/
- public static final String SELF_ENCAPSULATE_FIELD= "org.eclipse.cdt.ui.actions.SelfEncapsulateField"; //$NON-NLS-1$
-
+ public static final String SELF_ENCAPSULATE_FIELD = "org.eclipse.cdt.ui.actions.SelfEncapsulateField"; //$NON-NLS-1$
+
/**
* Refactor menu: name of standard Modify Parameters global action
* (value <code>"org.eclipse.cdt.ui.actions.ModifyParameters"</code>).
*/
- public static final String MODIFY_PARAMETERS= "org.eclipse.cdt.ui.actions.ModifyParameters"; //$NON-NLS-1$
-
+ public static final String MODIFY_PARAMETERS = "org.eclipse.cdt.ui.actions.ModifyParameters"; //$NON-NLS-1$
+
/**
* Refactor menu: name of standard Pull Up global action
* (value <code>"org.eclipse.cdt.ui.actions.PullUp"</code>).
*/
- public static final String PULL_UP= "org.eclipse.cdt.ui.actions.PullUp"; //$NON-NLS-1$
+ public static final String PULL_UP = "org.eclipse.cdt.ui.actions.PullUp"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Push Down global action
* (value <code>"org.eclipse.cdt.ui.actions.PushDown"</code>).
*/
- public static final String PUSH_DOWN= "org.eclipse.cdt.ui.actions.PushDown"; //$NON-NLS-1$
-
+ public static final String PUSH_DOWN = "org.eclipse.cdt.ui.actions.PushDown"; //$NON-NLS-1$
+
/**
* Refactor menu: name of standard Move Element global action
* (value <code>"org.eclipse.cdt.ui.actions.Move"</code>).
*/
- public static final String MOVE= "org.eclipse.cdt.ui.actions.Move"; //$NON-NLS-1$
-
+ public static final String MOVE = "org.eclipse.cdt.ui.actions.Move"; //$NON-NLS-1$
+
/**
* Refactor menu: name of standard Rename Element global action
* (value <code>"org.eclipse.cdt.ui.actions.Rename"</code>).
*/
- public static final String RENAME= "org.eclipse.cdt.ui.actions.Rename"; //$NON-NLS-1$
-
+ public static final String RENAME = "org.eclipse.cdt.ui.actions.Rename"; //$NON-NLS-1$
+
/**
* Refactor menu: name of standard Extract Temp global action
* (value <code>"org.eclipse.cdt.ui.actions.ExtractTemp"</code>).
*/
- public static final String EXTRACT_TEMP= "org.eclipse.cdt.ui.actions.ExtractTemp"; //$NON-NLS-1$
+ public static final String EXTRACT_TEMP = "org.eclipse.cdt.ui.actions.ExtractTemp"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Extract Constant global action
* (value <code>"org.eclipse.cdt.ui.actions.ExtractConstant"</code>).
*/
- public static final String EXTRACT_CONSTANT= "org.eclipse.cdt.ui.actions.ExtractConstant"; //$NON-NLS-1$
+ public static final String EXTRACT_CONSTANT = "org.eclipse.cdt.ui.actions.ExtractConstant"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Extract Local Variable global action
* (value <code>"org.eclipse.cdt.ui.actions.ExtractLocalVariable"</code>).
- * @since 5.1
+ * @since 5.1
*/
- public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.cdt.ui.actions.ExtractLocalVariable"; //$NON-NLS-1$
-
+ public static final String EXTRACT_LOCAL_VARIABLE = "org.eclipse.cdt.ui.actions.ExtractLocalVariable"; //$NON-NLS-1$
+
/**
* Refactor menu: name of standard Hide Method global action
* (value <code>"org.eclipse.cdt.ui.actions.HideMethod"</code>).
*/
- public static final String HIDE_METHOD= "org.eclipse.cdt.ui.actions.HideMethod"; //$NON-NLS-1$
+ public static final String HIDE_METHOD = "org.eclipse.cdt.ui.actions.HideMethod"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Extract Constant global action
* (value <code>"org.eclipse.cdt.ui.actions.ImplementMethod"</code>).
*/
- public static final String IMPLEMENT_METHOD= "org.eclipse.cdt.ui.actions.ImplementMethod"; //$NON-NLS-1$
+ public static final String IMPLEMENT_METHOD = "org.eclipse.cdt.ui.actions.ImplementMethod"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Generate Getters and Setters global action
* (value <code>"org.eclipse.cdt.ui.actions.GettersAndSetters"</code>).
*/
- public static final String GETTERS_AND_SETTERS= "org.eclipse.cdt.ui.actions.GettersAndSetters"; //$NON-NLS-1$
-
+ public static final String GETTERS_AND_SETTERS = "org.eclipse.cdt.ui.actions.GettersAndSetters"; //$NON-NLS-1$
+
/**
* Refactor menu: name of standard Introduce Parameter global action
* (value <code>"org.eclipse.cdt.ui.actions.IntroduceParameter"</code>).
*/
- public static final String INTRODUCE_PARAMETER= "org.eclipse.cdt.ui.actions.IntroduceParameter"; //$NON-NLS-1$
+ public static final String INTRODUCE_PARAMETER = "org.eclipse.cdt.ui.actions.IntroduceParameter"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Introduce Factory global action
* (value <code>"org.eclipse.cdt.ui.actions.IntroduceFactory"</code>).
*/
- public static final String INTRODUCE_FACTORY= "org.eclipse.cdt.ui.actions.IntroduceFactory"; //$NON-NLS-1$
+ public static final String INTRODUCE_FACTORY = "org.eclipse.cdt.ui.actions.IntroduceFactory"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Extract Method global action
* (value <code>"org.eclipse.cdt.ui.actions.ExtractMethod"</code>).
*/
- public static final String EXTRACT_METHOD= "org.eclipse.cdt.ui.actions.ExtractMethod"; //$NON-NLS-1$
+ public static final String EXTRACT_METHOD = "org.eclipse.cdt.ui.actions.ExtractMethod"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Toggle Function global action (value
* <code>"org.eclipse.cdt.ui.actions.ExtractMethod"</code>).
- *
+ *
* @since 5.3
*/
public static final String TOGGLE_FUNCTION = "org.eclipse.cdt.ui.actions.ToggleFunction"; //$NON-NLS-1$
/**
- * Refactor menu: name of standard Inline global action
+ * Refactor menu: name of standard Inline global action
* (value <code>"org.eclipse.cdt.ui.actions.Inline"</code>).
*/
- public static final String INLINE= "org.eclipse.cdt.ui.actions.Inline"; //$NON-NLS-1$
+ public static final String INLINE = "org.eclipse.cdt.ui.actions.Inline"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Extract Interface global action
* (value <code>"org.eclipse.cdt.ui.actions.ExtractInterface"</code>).
*/
- public static final String EXTRACT_INTERFACE= "org.eclipse.cdt.ui.actions.ExtractInterface"; //$NON-NLS-1$
+ public static final String EXTRACT_INTERFACE = "org.eclipse.cdt.ui.actions.ExtractInterface"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Generalize Type global action
* (value <code>"org.eclipse.cdt.ui.actions.ChangeType"</code>).
*/
- public static final String CHANGE_TYPE= "org.eclipse.cdt.ui.actions.ChangeType"; //$NON-NLS-1$
+ public static final String CHANGE_TYPE = "org.eclipse.cdt.ui.actions.ChangeType"; //$NON-NLS-1$
/**
* Refactor menu: name of standard global action to convert a nested type to a top level type
* (value <code>"org.eclipse.cdt.ui.actions.MoveInnerToTop"</code>).
*/
- public static final String CONVERT_NESTED_TO_TOP= "org.eclipse.cdt.ui.actions.ConvertNestedToTop"; //$NON-NLS-1$
-
+ public static final String CONVERT_NESTED_TO_TOP = "org.eclipse.cdt.ui.actions.ConvertNestedToTop"; //$NON-NLS-1$
+
/**
* Refactor menu: name of standard Use Supertype global action
* (value <code>"org.eclipse.cdt.ui.actions.UseSupertype"</code>).
*/
- public static final String USE_SUPERTYPE= "org.eclipse.cdt.ui.actions.UseSupertype"; //$NON-NLS-1$
+ public static final String USE_SUPERTYPE = "org.eclipse.cdt.ui.actions.UseSupertype"; //$NON-NLS-1$
/**
* Refactor menu: name of standard global action to convert a local
* variable to a field (value <code>"org.eclipse.cdt.ui.actions.ConvertLocalToField"</code>).
*/
- public static final String CONVERT_LOCAL_TO_FIELD= "org.eclipse.cdt.ui.actions.ConvertLocalToField"; //$NON-NLS-1$
+ public static final String CONVERT_LOCAL_TO_FIELD = "org.eclipse.cdt.ui.actions.ConvertLocalToField"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Covert Anonymous to Nested global action
* (value <code>"org.eclipse.cdt.ui.actions.ConvertAnonymousToNested"</code>).
*/
- public static final String CONVERT_ANONYMOUS_TO_NESTED= "org.eclipse.cdt.ui.actions.ConvertAnonymousToNested"; //$NON-NLS-1$
-
+ public static final String CONVERT_ANONYMOUS_TO_NESTED = "org.eclipse.cdt.ui.actions.ConvertAnonymousToNested"; //$NON-NLS-1$
+
// Search Menu
-
+
/**
* Search menu: name of standard Find References in Workspace global action
* (value <code>"org.eclipse.cdt.ui.actions.ReferencesInWorkspace"</code>).
*/
- public static final String FIND_REFERENCES_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.ReferencesInWorkspace"; //$NON-NLS-1$
+ public static final String FIND_REFERENCES_IN_WORKSPACE = "org.eclipse.cdt.ui.actions.ReferencesInWorkspace"; //$NON-NLS-1$
/**
* Search menu: name of standard Find References in Project global action
* (value <code>"org.eclipse.cdt.ui.actions.ReferencesInProject"</code>).
*/
- public static final String FIND_REFERENCES_IN_PROJECT= "org.eclipse.cdt.ui.actions.ReferencesInProject"; //$NON-NLS-1$
+ public static final String FIND_REFERENCES_IN_PROJECT = "org.eclipse.cdt.ui.actions.ReferencesInProject"; //$NON-NLS-1$
/**
* Search menu: name of standard Find References in Hierarchy global action
* (value <code>"org.eclipse.cdt.ui.actions.ReferencesInHierarchy"</code>).
*/
- public static final String FIND_REFERENCES_IN_HIERARCHY= "org.eclipse.cdt.ui.actions.ReferencesInHierarchy"; //$NON-NLS-1$
-
+ public static final String FIND_REFERENCES_IN_HIERARCHY = "org.eclipse.cdt.ui.actions.ReferencesInHierarchy"; //$NON-NLS-1$
+
/**
* Search menu: name of standard Find References in Working Set global action
* (value <code>"org.eclipse.cdt.ui.actions.ReferencesInWorkingSet"</code>).
*/
- public static final String FIND_REFERENCES_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.ReferencesInWorkingSet"; //$NON-NLS-1$
-
-
+ public static final String FIND_REFERENCES_IN_WORKING_SET = "org.eclipse.cdt.ui.actions.ReferencesInWorkingSet"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Declarations in Workspace global action
* (value <code>"org.eclipse.cdt.ui.actions.DeclarationsInWorkspace"</code>).
*/
- public static final String FIND_DECLARATIONS_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.DeclarationsInWorkspace"; //$NON-NLS-1$
+ public static final String FIND_DECLARATIONS_IN_WORKSPACE = "org.eclipse.cdt.ui.actions.DeclarationsInWorkspace"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Declarations in Project global action
* (value <code>"org.eclipse.cdt.ui.actions.DeclarationsInProject"</code>).
*/
- public static final String FIND_DECLARATIONS_IN_PROJECT= "org.eclipse.cdt.ui.actions.DeclarationsInProject"; //$NON-NLS-1$
+ public static final String FIND_DECLARATIONS_IN_PROJECT = "org.eclipse.cdt.ui.actions.DeclarationsInProject"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Declarations in Hierarchy global action
* (value <code>"org.eclipse.cdt.ui.actions.DeclarationsInHierarchy"</code>).
*/
- public static final String FIND_DECLARATIONS_IN_HIERARCHY= "org.eclipse.cdt.ui.actions.DeclarationsInHierarchy"; //$NON-NLS-1$
-
+ public static final String FIND_DECLARATIONS_IN_HIERARCHY = "org.eclipse.cdt.ui.actions.DeclarationsInHierarchy"; //$NON-NLS-1$
+
/**
* Search menu: name of standard Find Declarations in Working Set global action
* (value <code>"org.eclipse.cdt.ui.actions.DeclarationsInWorkingSet"</code>).
*/
- public static final String FIND_DECLARATIONS_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.DeclarationsInWorkingSet"; //$NON-NLS-1$
+ public static final String FIND_DECLARATIONS_IN_WORKING_SET = "org.eclipse.cdt.ui.actions.DeclarationsInWorkingSet"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Implementors in Workspace global action
* (value <code>"org.eclipse.cdt.ui.actions.ImplementorsInWorkspace"</code>).
*/
- public static final String FIND_IMPLEMENTORS_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.ImplementorsInWorkspace"; //$NON-NLS-1$
+ public static final String FIND_IMPLEMENTORS_IN_WORKSPACE = "org.eclipse.cdt.ui.actions.ImplementorsInWorkspace"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Implementors in Project global action
* (value <code>"org.eclipse.cdt.ui.actions.ImplementorsInProject"</code>).
*/
- public static final String FIND_IMPLEMENTORS_IN_PROJECT= "org.eclipse.cdt.ui.actions.ImplementorsInProject"; //$NON-NLS-1$
+ public static final String FIND_IMPLEMENTORS_IN_PROJECT = "org.eclipse.cdt.ui.actions.ImplementorsInProject"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Implementors in Working Set global action
* (value <code>"org.eclipse.cdt.ui.actions.ImplementorsInWorkingSet"</code>).
*/
- public static final String FIND_IMPLEMENTORS_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.ImplementorsInWorkingSet"; //$NON-NLS-1$
+ public static final String FIND_IMPLEMENTORS_IN_WORKING_SET = "org.eclipse.cdt.ui.actions.ImplementorsInWorkingSet"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Read Access in Workspace global action
* (value <code>"org.eclipse.cdt.ui.actions.ReadAccessInWorkspace"</code>).
*/
- public static final String FIND_READ_ACCESS_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.ReadAccessInWorkspace"; //$NON-NLS-1$
+ public static final String FIND_READ_ACCESS_IN_WORKSPACE = "org.eclipse.cdt.ui.actions.ReadAccessInWorkspace"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Read Access in Project global action
* (value <code>"org.eclipse.cdt.ui.actions.ReadAccessInProject"</code>).
*/
- public static final String FIND_READ_ACCESS_IN_PROJECT= "org.eclipse.cdt.ui.actions.ReadAccessInProject"; //$NON-NLS-1$
+ public static final String FIND_READ_ACCESS_IN_PROJECT = "org.eclipse.cdt.ui.actions.ReadAccessInProject"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Read Access in Hierarchy global action
* (value <code>"org.eclipse.cdt.ui.actions.ReadAccessInHierarchy"</code>).
*/
- public static final String FIND_READ_ACCESS_IN_HIERARCHY= "org.eclipse.cdt.ui.actions.ReadAccessInHierarchy"; //$NON-NLS-1$
-
+ public static final String FIND_READ_ACCESS_IN_HIERARCHY = "org.eclipse.cdt.ui.actions.ReadAccessInHierarchy"; //$NON-NLS-1$
+
/**
* Search menu: name of standard Find Read Access in Working Set global action
* (value <code>"org.eclipse.cdt.ui.actions.ReadAccessInWorkingSet"</code>).
*/
- public static final String FIND_READ_ACCESS_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.ReadAccessInWorkingSet"; //$NON-NLS-1$
+ public static final String FIND_READ_ACCESS_IN_WORKING_SET = "org.eclipse.cdt.ui.actions.ReadAccessInWorkingSet"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Write Access in Workspace global action
* (value <code>"org.eclipse.cdt.ui.actions.WriteAccessInWorkspace"</code>).
*/
- public static final String FIND_WRITE_ACCESS_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.WriteAccessInWorkspace"; //$NON-NLS-1$
+ public static final String FIND_WRITE_ACCESS_IN_WORKSPACE = "org.eclipse.cdt.ui.actions.WriteAccessInWorkspace"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Write Access in Project global action
* (value <code>"org.eclipse.cdt.ui.actions.WriteAccessInProject"</code>).
*/
- public static final String FIND_WRITE_ACCESS_IN_PROJECT= "org.eclipse.cdt.ui.actions.WriteAccessInProject"; //$NON-NLS-1$
+ public static final String FIND_WRITE_ACCESS_IN_PROJECT = "org.eclipse.cdt.ui.actions.WriteAccessInProject"; //$NON-NLS-1$
/**
* Search menu: name of standard Find Read Access in Hierarchy global action
* (value <code>"org.eclipse.cdt.ui.actions.WriteAccessInHierarchy"</code>).
*/
- public static final String FIND_WRITE_ACCESS_IN_HIERARCHY= "org.eclipse.cdt.ui.actions.WriteAccessInHierarchy"; //$NON-NLS-1$
-
+ public static final String FIND_WRITE_ACCESS_IN_HIERARCHY = "org.eclipse.cdt.ui.actions.WriteAccessInHierarchy"; //$NON-NLS-1$
+
/**
* Search menu: name of standard Find Read Access in Working Set global action
* (value <code>"org.eclipse.cdt.ui.actions.WriteAccessInWorkingSet"</code>).
*/
- public static final String FIND_WRITE_ACCESS_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.WriteAccessInWorkingSet"; //$NON-NLS-1$
-
+ public static final String FIND_WRITE_ACCESS_IN_WORKING_SET = "org.eclipse.cdt.ui.actions.WriteAccessInWorkingSet"; //$NON-NLS-1$
+
/**
* Search menu: name of standard Occurrences in File global action (value
* <code>"org.eclipse.cdt.ui.actions.OccurrencesInFile"</code>).
*/
- public static final String FIND_OCCURRENCES_IN_FILE= "org.eclipse.cdt.ui.actions.OccurrencesInFile"; //$NON-NLS-1$
-
+ public static final String FIND_OCCURRENCES_IN_FILE = "org.eclipse.cdt.ui.actions.OccurrencesInFile"; //$NON-NLS-1$
+
/**
* Search menu: name of standard Find exception occurrences global action (value
* <code>"org.eclipse.cdt.ui.actions.ExceptionOccurrences"</code>).
*/
- public static final String FIND_EXCEPTION_OCCURRENCES= "org.eclipse.cdt.ui.actions.ExceptionOccurrences"; //$NON-NLS-1$
+ public static final String FIND_EXCEPTION_OCCURRENCES = "org.eclipse.cdt.ui.actions.ExceptionOccurrences"; //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java
index 4b0d04d06fa..d60dac857f3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java
@@ -48,27 +48,28 @@ import org.eclipse.cdt.internal.ui.cview.IncludeRefContainer;
import org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy;
/**
- * Base class for build configuration actions.
+ * Base class for build configuration actions.
*/
public class ChangeBuildConfigActionBase {
-
+
/**
* List of selected managed-built projects
*/
protected HashSet<IProject> fProjects = new HashSet<IProject>();
-
+
/**
* Fills the menu with build configurations which are common for all selected projects
* @param menu The menu to fill
*/
- protected void fillMenu(Menu menu) {
- // This should not happen
- if (menu == null) return;
+ protected void fillMenu(Menu menu) {
+ // This should not happen
+ if (menu == null)
+ return;
MenuItem[] items = menu.getItems();
for (MenuItem item2 : items)
item2.dispose();
-
+
SortedSet<String> configNames = new TreeSet<String>();
String sCurrentConfig = null;
boolean bCurrentConfig = true;
@@ -79,9 +80,9 @@ public class ChangeBuildConfigActionBase {
// Store names and detect active configuration
for (ICConfigurationDescription cfgDesc : cfgDescs) {
String s = cfgDesc.getName();
- if (!configNames.contains(s))
+ if (!configNames.contains(s))
configNames.add(s);
- if (cfgDesc.isActive())
+ if (cfgDesc.isActive())
sActiveConfig = s;
}
@@ -90,12 +91,12 @@ public class ChangeBuildConfigActionBase {
if (sCurrentConfig == null)
sCurrentConfig = sActiveConfig;
else {
- if (!sCurrentConfig.equals(sActiveConfig))
+ if (!sCurrentConfig.equals(sActiveConfig))
bCurrentConfig = false;
}
}
}
-
+
int accel = 0;
for (String sName : configNames) {
String sDesc = null;
@@ -115,8 +116,9 @@ public class ChangeBuildConfigActionBase {
if (firstProj) {
sDesc = sNewDesc;
firstProj = false;
- } else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) {
- commonDesc = false;
+ } else if (sNewDesc == null && sDesc != null
+ || sNewDesc != null && !sNewDesc.equals(sDesc)) {
+ commonDesc = false;
}
}
break;
@@ -131,15 +133,15 @@ public class ChangeBuildConfigActionBase {
StringBuffer builder = new StringBuffer(sName);
if (commonDesc) {
if (sDesc != null) {
- builder.append(" ("); //$NON-NLS-1$
+ builder.append(" ("); //$NON-NLS-1$
builder.append(sDesc);
- builder.append(")"); //$NON-NLS-1$
+ builder.append(")"); //$NON-NLS-1$
}
} else {
- builder.append(" (...)"); //$NON-NLS-1$
+ builder.append(" (...)"); //$NON-NLS-1$
}
-
- IAction action = makeAction(sName ,builder, accel);
+
+ IAction action = makeAction(sName, builder, accel);
if (bCurrentConfig && sCurrentConfig != null && sCurrentConfig.equals(sName)) {
action.setChecked(true);
}
@@ -160,25 +162,25 @@ public class ChangeBuildConfigActionBase {
*/
private static class ImaginarySelection implements ISelection {
private IProject fProject;
-
+
ImaginarySelection(IProject project) {
fProject = project;
}
-
+
@Override
public boolean isEmpty() {
return fProject == null;
}
-
+
IProject getProject() {
return fProject;
}
}
/**
- * selectionChanged() event handler. Fills the list of managed-built projects
+ * selectionChanged() event handler. Fills the list of managed-built projects
* based on the selection. If some non-managed-built projects are selected,
- * disables the action.
+ * disables the action.
* @param action The action
* @param selection The selection
*/
@@ -186,9 +188,8 @@ public class ChangeBuildConfigActionBase {
fProjects.clear();
boolean badObject = false;
-
- if (selection != null )
- {
+
+ if (selection != null) {
if (selection instanceof IStructuredSelection) {
if (selection.isEmpty()) {
// could be a form editor or something. try to get the project from the active part
@@ -198,36 +199,36 @@ public class ChangeBuildConfigActionBase {
if (part != null) {
Object o = part.getAdapter(IResource.class);
if (o != null && o instanceof IResource) {
- fProjects.add(((IResource)o).getProject());
+ fProjects.add(((IResource) o).getProject());
}
}
}
}
- Iterator<?> iter = ((IStructuredSelection)selection).iterator();
+ Iterator<?> iter = ((IStructuredSelection) selection).iterator();
while (iter.hasNext()) {
Object selItem = iter.next();
IProject project = null;
if (selItem instanceof ICElement) {
- ICProject cproject = ((ICElement)selItem).getCProject();
- if (cproject != null) project = cproject.getProject();
- }
- else if (selItem instanceof IResource) {
- project = ((IResource)selItem).getProject();
+ ICProject cproject = ((ICElement) selItem).getCProject();
+ if (cproject != null)
+ project = cproject.getProject();
+ } else if (selItem instanceof IResource) {
+ project = ((IResource) selItem).getProject();
} else if (selItem instanceof IncludeRefContainer) {
- ICProject fCProject = ((IncludeRefContainer)selItem).getCProject();
+ ICProject fCProject = ((IncludeRefContainer) selItem).getCProject();
if (fCProject != null)
project = fCProject.getProject();
} else if (selItem instanceof IncludeReferenceProxy) {
- IncludeRefContainer irc = ((IncludeReferenceProxy)selItem).getIncludeRefContainer();
+ IncludeRefContainer irc = ((IncludeReferenceProxy) selItem).getIncludeRefContainer();
if (irc != null) {
ICProject fCProject = irc.getCProject();
if (fCProject != null)
project = fCProject.getProject();
}
} else if (selItem instanceof IAdaptable) {
- Object adapter = ((IAdaptable)selItem).getAdapter(IProject.class);
+ Object adapter = ((IAdaptable) selItem).getAdapter(IProject.class);
if (adapter != null && adapter instanceof IProject) {
- project = (IProject)adapter;
+ project = (IProject) adapter;
}
}
// Check whether the project is CDT project
@@ -236,7 +237,8 @@ public class ChangeBuildConfigActionBase {
project = null;
else {
ICConfigurationDescription[] tmp = getCfgs(project);
- if (tmp.length == 0) project = null;
+ if (tmp.length == 0)
+ project = null;
}
}
if (project != null) {
@@ -246,9 +248,7 @@ public class ChangeBuildConfigActionBase {
break;
}
}
- }
- else
- if (selection instanceof ITextSelection) {
+ } else if (selection instanceof ITextSelection) {
// If a text selection check the selected part to see if we can find
// an editor part that we can adapt to a resource and then
// back to a project.
@@ -260,31 +260,28 @@ public class ChangeBuildConfigActionBase {
if (part instanceof IEditorPart) {
IEditorPart epart = (IEditorPart) part;
IResource resource = epart.getEditorInput().getAdapter(IResource.class);
- if (resource != null)
- {
+ if (resource != null) {
IProject project = resource.getProject();
badObject = !(project != null && CoreModel.getDefault().isNewStyleProject(project));
if (!badObject) {
fProjects.add(project);
- }
+ }
}
}
}
}
- }
- else if (selection instanceof ImaginarySelection) {
- fProjects.add(((ImaginarySelection)selection).getProject());
+ } else if (selection instanceof ImaginarySelection) {
+ fProjects.add(((ImaginarySelection) selection).getProject());
}
}
-
-
+
boolean enable = false;
if (!badObject && !fProjects.isEmpty()) {
Iterator<IProject> iter = fProjects.iterator();
ICConfigurationDescription[] firstConfigs = getCfgs(iter.next());
- if (firstConfigs!=null) {
+ if (firstConfigs != null) {
for (ICConfigurationDescription firstConfig : firstConfigs) {
boolean common = true;
Iterator<IProject> iter2 = fProjects.iterator();
@@ -292,7 +289,7 @@ public class ChangeBuildConfigActionBase {
ICConfigurationDescription[] currentConfigs = getCfgs(iter2.next());
int j = 0;
for (; j < currentConfigs.length; j++) {
- if (firstConfig.getName().equals(currentConfigs[j].getName()))
+ if (firstConfig.getName().equals(currentConfigs[j].getName()))
break;
}
if (j == currentConfigs.length) {
@@ -308,7 +305,7 @@ public class ChangeBuildConfigActionBase {
}
}
action.setEnabled(enable);
-
+
// Bug 375760
// If focus is on a view that doesn't provide a resource/project context. Use the selection in a
// project/resource view. We support three views. If more than one is open, nevermind. If there's only
@@ -318,11 +315,11 @@ public class ChangeBuildConfigActionBase {
// call ourselves recursively
//
if (badObject || fProjects.isEmpty()) {
- // Check for lone CDT project in workspace
+ // Check for lone CDT project in workspace
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
if (projects != null && projects.length == 1) {
IProject project = projects[0];
- if (CoreModel.getDefault().isNewStyleProject(project) && (getCfgs(project).length > 0)) {
+ if (CoreModel.getDefault().isNewStyleProject(project) && (getCfgs(project).length > 0)) {
onSelectionChanged(action, new ImaginarySelection(project));
return;
}
@@ -334,18 +331,18 @@ public class ChangeBuildConfigActionBase {
if (page != null) {
IViewReference theViewRef = null;
IViewReference viewRef = null;
-
+
theViewRef = page.findViewReference("org.eclipse.cdt.ui.CView"); //$NON-NLS-1$
viewCount += (theViewRef != null) ? 1 : 0;
-
+
viewRef = page.findViewReference("org.eclipse.ui.navigator.ProjectExplorer"); //$NON-NLS-1$
- viewCount += (viewRef != null) ? 1 : 0;
- theViewRef = (theViewRef == null) ? viewRef : theViewRef;
+ viewCount += (viewRef != null) ? 1 : 0;
+ theViewRef = (theViewRef == null) ? viewRef : theViewRef;
viewRef = page.findViewReference("org.eclipse.ui.views.ResourceNavigator"); //$NON-NLS-1$
viewCount += (viewRef != null) ? 1 : 0;
- theViewRef = (theViewRef == null) ? viewRef : theViewRef;
-
+ theViewRef = (theViewRef == null) ? viewRef : theViewRef;
+
if (theViewRef != null && viewCount == 1) {
IViewPart view = theViewRef.getView(false);
if (view != null) {
@@ -362,16 +359,16 @@ public class ChangeBuildConfigActionBase {
}
}
}
-
+
private ICConfigurationDescription[] getCfgs(IProject prj) {
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false);
- if (prjd != null) {
+ if (prjd != null) {
ICConfigurationDescription[] cfgs = prjd.getConfigurations();
if (cfgs != null) {
return cfgs;
}
}
-
+
return new ICConfigurationDescription[0];
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java
index 07ff3b8e70c..08e663cd0af 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java
@@ -26,8 +26,8 @@ import org.eclipse.ui.IWorkbenchPart;
/**
* This context menu action is used to change active build configuration for the project
*/
-public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase implements
- IMenuCreator, IObjectActionDelegate {
+public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase
+ implements IMenuCreator, IObjectActionDelegate {
/**
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
@@ -80,7 +80,7 @@ public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase
menu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
- fillMenu((Menu)e.widget);
+ fillMenu((Menu) e.widget);
}
});
return menu;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java
index 7c1645d6d7d..45a4431d50c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java
@@ -33,8 +33,8 @@ import org.eclipse.cdt.internal.ui.actions.ActionMessages;
/**
* Action which changes active build configuration of the current project
*/
-public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase implements
- IWorkbenchWindowPulldownDelegate2 {
+public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase
+ implements IWorkbenchWindowPulldownDelegate2 {
/**
* @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate2#getMenu(org.eclipse.swt.widgets.Menu)
@@ -83,8 +83,7 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp
cm.manage(obs, true);
} else {
MessageDialog.openInformation(CUIPlugin.getActiveWorkbenchShell(),
- ActionMessages.ChangeBuildConfigMenuAction_title,
- ActionMessages.ChangeBuildConfigMenuAction_text);
+ ActionMessages.ChangeBuildConfigMenuAction_title, ActionMessages.ChangeBuildConfigMenuAction_text);
}
}
@@ -104,7 +103,7 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp
menu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
- fillMenu((Menu)e.widget);
+ fillMenu((Menu) e.widget);
}
});
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeConfigAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeConfigAction.java
index 913fdc80894..72798524076 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeConfigAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeConfigAction.java
@@ -25,17 +25,17 @@ import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.cdt.ui.newui.CDTPropertyManager;
/**
- * Action which changes active build configuration of the current project to
+ * Action which changes active build configuration of the current project to
* the given one.
*/
public class ChangeConfigAction extends Action {
private String fConfigName = null;
protected HashSet<IProject> fProjects = null;
-
+
/**
* Constructs the action.
- * @param projects List of selected managed-built projects
+ * @param projects List of selected managed-built projects
* @param configName Build configuration name
* @param accel Number to be used as accelerator
*/
@@ -44,7 +44,7 @@ public class ChangeConfigAction extends Action {
fProjects = projects;
fConfigName = configName;
}
-
+
/**
* @see org.eclipse.jface.action.IAction#run()
*/
@@ -55,7 +55,7 @@ public class ChangeConfigAction extends Action {
IProject prj = iter.next();
ICProjectDescription prjd = CDTPropertyManager.getProjectDescription(prj);
boolean changed = false;
- ICConfigurationDescription[] configs = prjd.getConfigurations();
+ ICConfigurationDescription[] configs = prjd.getConfigurations();
if (configs != null && configs.length > 0) {
for (ICConfigurationDescription config : configs) {
if (config.getName().equals(fConfigName)) {
@@ -67,8 +67,8 @@ public class ChangeConfigAction extends Action {
}
}
}
-
- if(!changed)
+
+ if (!changed)
CDTPropertyManager.performCancel(null);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java
index ff94eafce6f..773816704f3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java
@@ -107,16 +107,17 @@ public class CustomFiltersActionGroup extends ActionGroup {
* @param state the initial state of the filter
* @param itemNumber the menu item index
*/
- public FilterActionMenuContributionItem(CustomFiltersActionGroup actionGroup, String filterId, String filterName, boolean state, int itemNumber) {
+ public FilterActionMenuContributionItem(CustomFiltersActionGroup actionGroup, String filterId,
+ String filterName, boolean state, int itemNumber) {
super(filterId);
Assert.isNotNull(actionGroup);
Assert.isNotNull(filterId);
Assert.isNotNull(filterName);
- fActionGroup= actionGroup;
- fFilterId= filterId;
- fFilterName= filterName;
- fState= state;
- fItemNumber= itemNumber;
+ fActionGroup = actionGroup;
+ fFilterId = filterId;
+ fFilterName = filterName;
+ fState = state;
+ fItemNumber = itemNumber;
}
/*
@@ -124,18 +125,18 @@ public class CustomFiltersActionGroup extends ActionGroup {
*/
@Override
public void fill(Menu menu, int index) {
- MenuItem mi= new MenuItem(menu, SWT.CHECK, index);
- mi.setText("&" + fItemNumber + " " + fFilterName); //$NON-NLS-1$ //$NON-NLS-2$
+ MenuItem mi = new MenuItem(menu, SWT.CHECK, index);
+ mi.setText("&" + fItemNumber + " " + fFilterName); //$NON-NLS-1$ //$NON-NLS-2$
/*
* XXX: Don't set the image - would look bad because other menu items don't provide image
* XXX: Get working set specific image name from XML - would need to cache icons
*/
-// mi.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_JAVA_WORKING_SET));
+ // mi.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_JAVA_WORKING_SET));
mi.setSelection(fState);
mi.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- fState= !fState;
+ fState = !fState;
fActionGroup.setFilter(fFilterId, fState);
}
});
@@ -151,20 +152,20 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private static final String TAG_CUSTOM_FILTERS = "customFilters"; //$NON-NLS-1$
- private static final String TAG_USER_DEFINED_PATTERNS_ENABLED= "userDefinedPatternsEnabled"; //$NON-NLS-1$
- private static final String TAG_USER_DEFINED_PATTERNS= "userDefinedPatterns"; //$NON-NLS-1$
- private static final String TAG_XML_DEFINED_FILTERS= "xmlDefinedFilters"; //$NON-NLS-1$
+ private static final String TAG_USER_DEFINED_PATTERNS_ENABLED = "userDefinedPatternsEnabled"; //$NON-NLS-1$
+ private static final String TAG_USER_DEFINED_PATTERNS = "userDefinedPatterns"; //$NON-NLS-1$
+ private static final String TAG_XML_DEFINED_FILTERS = "xmlDefinedFilters"; //$NON-NLS-1$
private static final String TAG_LRU_FILTERS = "lastRecentlyUsedFilters"; //$NON-NLS-1$
- private static final String TAG_CHILD= "child"; //$NON-NLS-1$
- private static final String TAG_PATTERN= "pattern"; //$NON-NLS-1$
- private static final String TAG_FILTER_ID= "filterId"; //$NON-NLS-1$
- private static final String TAG_IS_ENABLED= "isEnabled"; //$NON-NLS-1$
+ private static final String TAG_CHILD = "child"; //$NON-NLS-1$
+ private static final String TAG_PATTERN = "pattern"; //$NON-NLS-1$
+ private static final String TAG_FILTER_ID = "filterId"; //$NON-NLS-1$
+ private static final String TAG_IS_ENABLED = "isEnabled"; //$NON-NLS-1$
- private static final String SEPARATOR= ","; //$NON-NLS-1$
+ private static final String SEPARATOR = ","; //$NON-NLS-1$
- private static final int MAX_FILTER_MENU_ENTRIES= 3;
- private static final String RECENT_FILTERS_GROUP_NAME= "recentFiltersGroup"; //$NON-NLS-1$
+ private static final int MAX_FILTER_MENU_ENTRIES = 3;
+ private static final String RECENT_FILTERS_GROUP_NAME = "recentFiltersGroup"; //$NON-NLS-1$
private StructuredViewer fViewer;
@@ -222,10 +223,10 @@ public class CustomFiltersActionGroup extends ActionGroup {
public CustomFiltersActionGroup(String ownerId, StructuredViewer viewer) {
Assert.isNotNull(ownerId);
Assert.isNotNull(viewer);
- fTargetId= ownerId;
- fViewer= viewer;
+ fTargetId = ownerId;
+ fViewer = viewer;
- fLRUFilterIdsStack= new Stack<String>();
+ fLRUFilterIdsStack = new Stack<String>();
initializeWithPluginContributions();
initializeWithViewDefaults();
@@ -243,40 +244,40 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
public String[] removeFiltersFor(Object parent, Object element, IContentProvider contentProvider) {
- String[] enabledFilters= getEnabledFilterIds();
- Set<String> newFilters= new HashSet<String>();
- for (String filterName : enabledFilters) {
- ViewerFilter filter= fInstalledBuiltInFilters.get(filterName);
- if (filter == null)
- newFilters.add(filterName);
- else if (isSelected(parent, element, contentProvider, filter))
- newFilters.add(filterName);
- }
- if (newFilters.size() == enabledFilters.length)
- return new String[0];
- return newFilters.toArray(new String[newFilters.size()]);
+ String[] enabledFilters = getEnabledFilterIds();
+ Set<String> newFilters = new HashSet<String>();
+ for (String filterName : enabledFilters) {
+ ViewerFilter filter = fInstalledBuiltInFilters.get(filterName);
+ if (filter == null)
+ newFilters.add(filterName);
+ else if (isSelected(parent, element, contentProvider, filter))
+ newFilters.add(filterName);
+ }
+ if (newFilters.size() == enabledFilters.length)
+ return new String[0];
+ return newFilters.toArray(new String[newFilters.size()]);
}
public void setFilters(String[] newFilters) {
- setEnabledFilterIds(newFilters);
- updateViewerFilters(true);
+ setEnabledFilterIds(newFilters);
+ updateViewerFilters(true);
}
private boolean isSelected(Object parent, Object element, IContentProvider contentProvider, ViewerFilter filter) {
- if (contentProvider instanceof ITreeContentProvider) {
- // the element and all its parents have to be selected
- ITreeContentProvider provider = (ITreeContentProvider) contentProvider;
- while (element != null && !(element instanceof ICModel)) {
- if (!filter.select(fViewer, parent, element))
- return false;
- element= provider.getParent( element);
- }
- return true;
- }
- return filter.select(fViewer, parent, element);
- }
-
- /**
+ if (contentProvider instanceof ITreeContentProvider) {
+ // the element and all its parents have to be selected
+ ITreeContentProvider provider = (ITreeContentProvider) contentProvider;
+ while (element != null && !(element instanceof ICModel)) {
+ if (!filter.select(fViewer, parent, element))
+ return false;
+ element = provider.getParent(element);
+ }
+ return true;
+ }
+ return filter.select(fViewer, parent, element);
+ }
+
+ /**
* Sets the enable state of the given filter.
*
* @param filterId the id of the filter
@@ -294,23 +295,22 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private String[] getEnabledFilterIds() {
- Set<String> enabledFilterIds= new HashSet<String>(fEnabledFilterIds.size());
- Iterator<Map.Entry<String,Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
+ Set<String> enabledFilterIds = new HashSet<String>(fEnabledFilterIds.size());
+ Iterator<Map.Entry<String, Boolean>> iter = fEnabledFilterIds.entrySet().iterator();
while (iter.hasNext()) {
- Map.Entry<String,Boolean> entry= iter.next();
- String id= entry.getKey();
- boolean isEnabled= (entry.getValue()).booleanValue();
+ Map.Entry<String, Boolean> entry = iter.next();
+ String id = entry.getKey();
+ boolean isEnabled = (entry.getValue()).booleanValue();
if (isEnabled)
enabledFilterIds.add(id);
}
return enabledFilterIds.toArray(new String[enabledFilterIds.size()]);
}
-
private void setEnabledFilterIds(String[] enabledIds) {
- Iterator<String> iter= fEnabledFilterIds.keySet().iterator();
+ Iterator<String> iter = fEnabledFilterIds.keySet().iterator();
while (iter.hasNext()) {
- String id= iter.next();
+ String id = iter.next();
fEnabledFilterIds.put(id, Boolean.FALSE);
}
for (String enabledId : enabledIds)
@@ -318,7 +318,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private void setUserDefinedPatterns(String[] patterns) {
- fUserDefinedPatterns= patterns;
+ fUserDefinedPatterns = patterns;
cleanUpPatternDuplicates();
}
@@ -329,20 +329,20 @@ public class CustomFiltersActionGroup extends ActionGroup {
* @since 3.0
*/
private void setRecentlyChangedFilters(Stack<FilterDescriptor> changeHistory) {
- Stack<String> oldestFirstStack= new Stack<String>();
+ Stack<String> oldestFirstStack = new Stack<String>();
- int length= Math.min(changeHistory.size(), MAX_FILTER_MENU_ENTRIES);
- for (int i= 0; i < length; i++)
+ int length = Math.min(changeHistory.size(), MAX_FILTER_MENU_ENTRIES);
+ for (int i = 0; i < length; i++)
oldestFirstStack.push((changeHistory.pop()).getId());
- length= Math.min(fLRUFilterIdsStack.size(), MAX_FILTER_MENU_ENTRIES - oldestFirstStack.size());
- int NEWEST= 0;
- for (int i= 0; i < length; i++) {
- String filter= fLRUFilterIdsStack.remove(NEWEST);
+ length = Math.min(fLRUFilterIdsStack.size(), MAX_FILTER_MENU_ENTRIES - oldestFirstStack.size());
+ int NEWEST = 0;
+ for (int i = 0; i < length; i++) {
+ String filter = fLRUFilterIdsStack.remove(NEWEST);
if (!oldestFirstStack.contains(filter))
oldestFirstStack.push(filter);
}
- fLRUFilterIdsStack= oldestFirstStack;
+ fLRUFilterIdsStack = oldestFirstStack;
}
private boolean areUserDefinedPatternsEnabled() {
@@ -350,7 +350,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private void setUserDefinedPatternsEnabled(boolean state) {
- fUserDefinedPatternsEnabled= state;
+ fUserDefinedPatternsEnabled = state;
}
private void fillToolBar(IToolBarManager tooBar) {
@@ -366,8 +366,8 @@ public class CustomFiltersActionGroup extends ActionGroup {
viewMenu.add(new GroupMarker(RECENT_FILTERS_GROUP_NAME));
viewMenu.add(new ShowFilterDialogAction());
- fMenuManager= viewMenu;
- fMenuListener= new IMenuListener() {
+ fMenuManager = viewMenu;
+ fMenuListener = new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
removePreviousLRUFilterActions(manager);
@@ -387,21 +387,22 @@ public class CustomFiltersActionGroup extends ActionGroup {
void addLRUFilterActions(IMenuManager mm) {
if (fLRUFilterIdsStack.isEmpty()) {
- fFilterIdsUsedInLastViewMenu= null;
+ fFilterIdsUsedInLastViewMenu = null;
return;
}
- SortedSet<Object> sortedFilters= new TreeSet<Object>(fLRUFilterIdsStack);
- String[] recentlyChangedFilterIds= sortedFilters.toArray(new String[sortedFilters.size()]);
+ SortedSet<Object> sortedFilters = new TreeSet<Object>(fLRUFilterIdsStack);
+ String[] recentlyChangedFilterIds = sortedFilters.toArray(new String[sortedFilters.size()]);
- fFilterIdsUsedInLastViewMenu= new String[recentlyChangedFilterIds.length];
- for (int i= 0; i < recentlyChangedFilterIds.length; i++) {
- String id= recentlyChangedFilterIds[i];
- fFilterIdsUsedInLastViewMenu[i]= id;
- boolean state= fEnabledFilterIds.containsKey(id) && fEnabledFilterIds.get(id).booleanValue();
- FilterDescriptor filterDesc= fFilterDescriptorMap.get(id);
+ fFilterIdsUsedInLastViewMenu = new String[recentlyChangedFilterIds.length];
+ for (int i = 0; i < recentlyChangedFilterIds.length; i++) {
+ String id = recentlyChangedFilterIds[i];
+ fFilterIdsUsedInLastViewMenu[i] = id;
+ boolean state = fEnabledFilterIds.containsKey(id) && fEnabledFilterIds.get(id).booleanValue();
+ FilterDescriptor filterDesc = fFilterDescriptorMap.get(id);
if (filterDesc != null) {
- IContributionItem item= new FilterActionMenuContributionItem(this, id, filterDesc.getName(), state, i+1);
+ IContributionItem item = new FilterActionMenuContributionItem(this, id, filterDesc.getName(), state,
+ i + 1);
mm.insertBefore(RECENT_FILTERS_GROUP_NAME, item);
}
}
@@ -418,15 +419,15 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private void initializeWithPluginContributions() {
- fUserDefinedPatterns= new String[0];
- fUserDefinedPatternsEnabled= false;
+ fUserDefinedPatterns = new String[0];
+ fUserDefinedPatternsEnabled = false;
- FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId);
- fFilterDescriptorMap= new HashMap<String, FilterDescriptor>(filterDescs.length);
- fEnabledFilterIds= new HashMap<String, Boolean>(filterDescs.length);
+ FilterDescriptor[] filterDescs = FilterDescriptor.getFilterDescriptors(fTargetId);
+ fFilterDescriptorMap = new HashMap<String, FilterDescriptor>(filterDescs.length);
+ fEnabledFilterIds = new HashMap<String, Boolean>(filterDescs.length);
for (FilterDescriptor filterDesc : filterDescs) {
- String id= filterDesc.getId();
- Boolean isEnabled= filterDesc.isEnabled();
+ String id = filterDesc.getId();
+ Boolean isEnabled = filterDesc.isEnabled();
//if (fEnabledFilterIds.containsKey(id))
// CUIPlugin.log(new Status("WARNING: Duplicate id for extension-point \"org.eclipse.jdt.ui.CElementFilters\"")); //$NON-NLS-1$
fEnabledFilterIds.put(id, isEnabled);
@@ -437,15 +438,15 @@ public class CustomFiltersActionGroup extends ActionGroup {
// ---------- viewer filter handling ----------
private void installFilters() {
- fInstalledBuiltInFilters= new HashMap<String, ViewerFilter>(fEnabledFilterIds.size());
- fPatternFilter= new NamePatternFilter();
+ fInstalledBuiltInFilters = new HashMap<String, ViewerFilter>(fEnabledFilterIds.size());
+ fPatternFilter = new NamePatternFilter();
fPatternFilter.setPatterns(getUserAndBuiltInPatterns());
fViewer.addFilter(fPatternFilter);
updateBuiltInFilters();
}
private void updateViewerFilters(boolean refresh) {
- String[] patterns= getUserAndBuiltInPatterns();
+ String[] patterns = getUserAndBuiltInPatterns();
fPatternFilter.setPatterns(patterns);
fViewer.getControl().setRedraw(false);
updateBuiltInFilters();
@@ -455,14 +456,14 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private void updateBuiltInFilters() {
- Set<String> installedFilters= fInstalledBuiltInFilters.keySet();
- Set<String> filtersToAdd= new HashSet<String>(fEnabledFilterIds.size());
- Set<String> filtersToRemove= new HashSet<String>(fEnabledFilterIds.size());
- Iterator<Map.Entry<String,Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
+ Set<String> installedFilters = fInstalledBuiltInFilters.keySet();
+ Set<String> filtersToAdd = new HashSet<String>(fEnabledFilterIds.size());
+ Set<String> filtersToRemove = new HashSet<String>(fEnabledFilterIds.size());
+ Iterator<Map.Entry<String, Boolean>> iter = fEnabledFilterIds.entrySet().iterator();
while (iter.hasNext()) {
- Map.Entry<String, Boolean> entry= iter.next();
- String id= entry.getKey();
- boolean isEnabled= (entry.getValue()).booleanValue();
+ Map.Entry<String, Boolean> entry = iter.next();
+ String id = entry.getKey();
+ boolean isEnabled = (entry.getValue()).booleanValue();
if (isEnabled && !installedFilters.contains(id))
filtersToAdd.add(id);
else if (!isEnabled && installedFilters.contains(id))
@@ -470,14 +471,14 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
// Install the filters
- FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId);
+ FilterDescriptor[] filterDescs = FilterDescriptor.getFilterDescriptors(fTargetId);
for (FilterDescriptor filterDesc : filterDescs) {
- String id= filterDesc.getId();
+ String id = filterDesc.getId();
// just to double check - id should denote a custom filter anyway
- boolean isCustomFilter= filterDesc.isCustomFilter();
+ boolean isCustomFilter = filterDesc.isCustomFilter();
if (isCustomFilter) {
if (filtersToAdd.contains(id)) {
- ViewerFilter filter= filterDesc.createViewerFilter();
+ ViewerFilter filter = filterDesc.createViewerFilter();
if (filter != null) {
fViewer.addFilter(filter);
fInstalledBuiltInFilters.put(id, filter);
@@ -492,15 +493,15 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private String[] getUserAndBuiltInPatterns() {
- List<String> patterns= new ArrayList<String>(fUserDefinedPatterns.length);
+ List<String> patterns = new ArrayList<String>(fUserDefinedPatterns.length);
if (areUserDefinedPatternsEnabled())
patterns.addAll(Arrays.asList(fUserDefinedPatterns));
- FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId);
+ FilterDescriptor[] filterDescs = FilterDescriptor.getFilterDescriptors(fTargetId);
for (FilterDescriptor filterDesc : filterDescs) {
- String id= filterDesc.getId();
- boolean isPatternFilter= filterDesc.isPatternFilter();
- Object isEnabled= fEnabledFilterIds.get(id);
- if (isEnabled != null && isPatternFilter && ((Boolean)isEnabled).booleanValue())
+ String id = filterDesc.getId();
+ boolean isPatternFilter = filterDesc.isPatternFilter();
+ Object isEnabled = fEnabledFilterIds.get(id);
+ if (isEnabled != null && isPatternFilter && ((Boolean) isEnabled).booleanValue())
patterns.add(filterDesc.getPattern());
}
return patterns.toArray(new String[patterns.size()]);
@@ -510,31 +511,32 @@ public class CustomFiltersActionGroup extends ActionGroup {
private void initializeWithViewDefaults() {
// get default values for view
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
// XXX: can be removed once bug 22533 is fixed.
if (!store.contains(getPreferenceKey("TAG_DUMMY_TO_TEST_EXISTENCE")))//$NON-NLS-1$
return;
// XXX: Uncomment once bug 22533 is fixed.
-// if (!store.contains(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED)))
-// return;
+ // if (!store.contains(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED)))
+ // return;
- fUserDefinedPatternsEnabled= store.getBoolean(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED));
- setUserDefinedPatterns(CustomFiltersDialog.convertFromString(store.getString(getPreferenceKey(TAG_USER_DEFINED_PATTERNS)), SEPARATOR));
+ fUserDefinedPatternsEnabled = store.getBoolean(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED));
+ setUserDefinedPatterns(CustomFiltersDialog
+ .convertFromString(store.getString(getPreferenceKey(TAG_USER_DEFINED_PATTERNS)), SEPARATOR));
- Iterator<String> iter= fEnabledFilterIds.keySet().iterator();
+ Iterator<String> iter = fEnabledFilterIds.keySet().iterator();
while (iter.hasNext()) {
- String id= iter.next();
- Boolean isEnabled= store.getBoolean(id);
+ String id = iter.next();
+ Boolean isEnabled = store.getBoolean(id);
fEnabledFilterIds.put(id, isEnabled);
}
fLRUFilterIdsStack.clear();
- String lruFilterIds= store.getString(TAG_LRU_FILTERS);
- StringTokenizer tokenizer= new StringTokenizer(lruFilterIds, SEPARATOR);
+ String lruFilterIds = store.getString(TAG_LRU_FILTERS);
+ StringTokenizer tokenizer = new StringTokenizer(lruFilterIds, SEPARATOR);
while (tokenizer.hasMoreTokens()) {
- String id= tokenizer.nextToken();
+ String id = tokenizer.nextToken();
if (fFilterDescriptorMap.containsKey(id) && !fLRUFilterIdsStack.contains(id))
fLRUFilterIdsStack.push(id);
}
@@ -542,24 +544,25 @@ public class CustomFiltersActionGroup extends ActionGroup {
private void storeViewDefaults() {
// get default values for view
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
// XXX: can be removed once bug 22533 is fixed.
store.setValue(getPreferenceKey("TAG_DUMMY_TO_TEST_EXISTENCE"), "storedViewPreferences");//$NON-NLS-1$//$NON-NLS-2$
store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED), fUserDefinedPatternsEnabled);
- store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS), CustomFiltersDialog.convertToString(fUserDefinedPatterns ,SEPARATOR));
+ store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS),
+ CustomFiltersDialog.convertToString(fUserDefinedPatterns, SEPARATOR));
- Iterator<Entry<String, Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
+ Iterator<Entry<String, Boolean>> iter = fEnabledFilterIds.entrySet().iterator();
while (iter.hasNext()) {
- Map.Entry<String,Boolean> entry= iter.next();
- String id= entry.getKey();
- boolean isEnabled= (entry.getValue()).booleanValue();
+ Map.Entry<String, Boolean> entry = iter.next();
+ String id = entry.getKey();
+ boolean isEnabled = (entry.getValue()).booleanValue();
store.setValue(id, isEnabled);
}
- StringBuilder buf= new StringBuilder(fLRUFilterIdsStack.size() * 20);
- Iterator<String> iterIds= fLRUFilterIdsStack.iterator();
+ StringBuilder buf = new StringBuilder(fLRUFilterIdsStack.size() * 20);
+ Iterator<String> iterIds = fLRUFilterIdsStack.iterator();
while (iterIds.hasNext()) {
buf.append(iterIds.next());
buf.append(SEPARATOR);
@@ -579,7 +582,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
* @param memento the memento into which the state is saved
*/
public void saveState(IMemento memento) {
- IMemento customFilters= memento.createChild(TAG_CUSTOM_FILTERS);
+ IMemento customFilters = memento.createChild(TAG_CUSTOM_FILTERS);
customFilters.putString(TAG_USER_DEFINED_PATTERNS_ENABLED, String.valueOf(fUserDefinedPatternsEnabled));
saveUserDefinedPatterns(customFilters);
saveXmlDefinedFilters(customFilters);
@@ -587,19 +590,20 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private void saveXmlDefinedFilters(IMemento memento) {
- if(fEnabledFilterIds != null && !fEnabledFilterIds.isEmpty()) {
- IMemento xmlDefinedFilters= memento.createChild(TAG_XML_DEFINED_FILTERS);
- Iterator<Map.Entry<String,Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
+ if (fEnabledFilterIds != null && !fEnabledFilterIds.isEmpty()) {
+ IMemento xmlDefinedFilters = memento.createChild(TAG_XML_DEFINED_FILTERS);
+ Iterator<Map.Entry<String, Boolean>> iter = fEnabledFilterIds.entrySet().iterator();
while (iter.hasNext()) {
- Map.Entry<String,Boolean> entry= iter.next();
- String id= entry.getKey();
- Boolean isEnabled= entry.getValue();
- IMemento child= xmlDefinedFilters.createChild(TAG_CHILD);
+ Map.Entry<String, Boolean> entry = iter.next();
+ String id = entry.getKey();
+ Boolean isEnabled = entry.getValue();
+ IMemento child = xmlDefinedFilters.createChild(TAG_CHILD);
child.putString(TAG_FILTER_ID, id);
child.putString(TAG_IS_ENABLED, isEnabled.toString());
}
}
}
+
/**
* Stores the last recently used filter Ids into
* the given memento
@@ -608,22 +612,22 @@ public class CustomFiltersActionGroup extends ActionGroup {
* @since 3.0
*/
private void saveLRUFilters(IMemento memento) {
- if(fLRUFilterIdsStack != null && !fLRUFilterIdsStack.isEmpty()) {
- IMemento lruFilters= memento.createChild(TAG_LRU_FILTERS);
- Iterator<String> iter= fLRUFilterIdsStack.iterator();
+ if (fLRUFilterIdsStack != null && !fLRUFilterIdsStack.isEmpty()) {
+ IMemento lruFilters = memento.createChild(TAG_LRU_FILTERS);
+ Iterator<String> iter = fLRUFilterIdsStack.iterator();
while (iter.hasNext()) {
- String id= iter.next();
- IMemento child= lruFilters.createChild(TAG_CHILD);
+ String id = iter.next();
+ IMemento child = lruFilters.createChild(TAG_CHILD);
child.putString(TAG_FILTER_ID, id);
}
}
}
private void saveUserDefinedPatterns(IMemento memento) {
- if(fUserDefinedPatterns != null && fUserDefinedPatterns.length > 0) {
- IMemento userDefinedPatterns= memento.createChild(TAG_USER_DEFINED_PATTERNS);
+ if (fUserDefinedPatterns != null && fUserDefinedPatterns.length > 0) {
+ IMemento userDefinedPatterns = memento.createChild(TAG_USER_DEFINED_PATTERNS);
for (String userDefinedPattern : fUserDefinedPatterns) {
- IMemento child= userDefinedPatterns.createChild(TAG_CHILD);
+ IMemento child = userDefinedPatterns.createChild(TAG_CHILD);
child.putString(TAG_PATTERN, userDefinedPattern);
}
}
@@ -640,14 +644,14 @@ public class CustomFiltersActionGroup extends ActionGroup {
public void restoreState(IMemento memento) {
if (memento == null)
return;
- IMemento customFilters= memento.getChild(TAG_CUSTOM_FILTERS);
+ IMemento customFilters = memento.getChild(TAG_CUSTOM_FILTERS);
if (customFilters == null)
return;
- String userDefinedPatternsEnabled= customFilters.getString(TAG_USER_DEFINED_PATTERNS_ENABLED);
+ String userDefinedPatternsEnabled = customFilters.getString(TAG_USER_DEFINED_PATTERNS_ENABLED);
if (userDefinedPatternsEnabled == null)
return;
- fUserDefinedPatternsEnabled= Boolean.valueOf(userDefinedPatternsEnabled).booleanValue();
+ fUserDefinedPatternsEnabled = Boolean.valueOf(userDefinedPatternsEnabled).booleanValue();
restoreUserDefinedPatterns(customFilters);
restoreXmlDefinedFilters(customFilters);
restoreLRUFilters(customFilters);
@@ -656,12 +660,12 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private void restoreUserDefinedPatterns(IMemento memento) {
- IMemento userDefinedPatterns= memento.getChild(TAG_USER_DEFINED_PATTERNS);
- if(userDefinedPatterns != null) {
- IMemento children[]= userDefinedPatterns.getChildren(TAG_CHILD);
- String[] patterns= new String[children.length];
+ IMemento userDefinedPatterns = memento.getChild(TAG_USER_DEFINED_PATTERNS);
+ if (userDefinedPatterns != null) {
+ IMemento children[] = userDefinedPatterns.getChildren(TAG_CHILD);
+ String[] patterns = new String[children.length];
for (int i = 0; i < children.length; i++)
- patterns[i]= children[i].getString(TAG_PATTERN);
+ patterns[i] = children[i].getString(TAG_PATTERN);
setUserDefinedPatterns(patterns);
} else
@@ -669,24 +673,24 @@ public class CustomFiltersActionGroup extends ActionGroup {
}
private void restoreXmlDefinedFilters(IMemento memento) {
- IMemento xmlDefinedFilters= memento.getChild(TAG_XML_DEFINED_FILTERS);
- if(xmlDefinedFilters != null) {
- IMemento[] children= xmlDefinedFilters.getChildren(TAG_CHILD);
+ IMemento xmlDefinedFilters = memento.getChild(TAG_XML_DEFINED_FILTERS);
+ if (xmlDefinedFilters != null) {
+ IMemento[] children = xmlDefinedFilters.getChildren(TAG_CHILD);
for (IMemento element : children) {
- String id= element.getString(TAG_FILTER_ID);
- Boolean isEnabled= Boolean.valueOf(element.getString(TAG_IS_ENABLED));
+ String id = element.getString(TAG_FILTER_ID);
+ Boolean isEnabled = Boolean.valueOf(element.getString(TAG_IS_ENABLED));
fEnabledFilterIds.put(id, isEnabled);
}
}
}
private void restoreLRUFilters(IMemento memento) {
- IMemento lruFilters= memento.getChild(TAG_LRU_FILTERS);
+ IMemento lruFilters = memento.getChild(TAG_LRU_FILTERS);
fLRUFilterIdsStack.clear();
- if(lruFilters != null) {
- IMemento[] children= lruFilters.getChildren(TAG_CHILD);
+ if (lruFilters != null) {
+ IMemento[] children = lruFilters.getChildren(TAG_CHILD);
for (IMemento element : children) {
- String id= element.getString(TAG_FILTER_ID);
+ String id = element.getString(TAG_FILTER_ID);
if (fFilterDescriptorMap.containsKey(id) && !fLRUFilterIdsStack.contains(id))
fLRUFilterIdsStack.push(id);
}
@@ -696,33 +700,29 @@ public class CustomFiltersActionGroup extends ActionGroup {
private void cleanUpPatternDuplicates() {
if (!areUserDefinedPatternsEnabled())
return;
- List<String> userDefinedPatterns= new ArrayList<String>(Arrays.asList(fUserDefinedPatterns));
- FilterDescriptor[] filters= FilterDescriptor.getFilterDescriptors(fTargetId);
+ List<String> userDefinedPatterns = new ArrayList<String>(Arrays.asList(fUserDefinedPatterns));
+ FilterDescriptor[] filters = FilterDescriptor.getFilterDescriptors(fTargetId);
for (FilterDescriptor filter : filters) {
if (filter.isPatternFilter()) {
- String pattern= filter.getPattern();
+ String pattern = filter.getPattern();
if (userDefinedPatterns.contains(pattern)) {
fEnabledFilterIds.put(filter.getId(), Boolean.TRUE);
- boolean hasMore= true;
+ boolean hasMore = true;
while (hasMore)
- hasMore= userDefinedPatterns.remove(pattern);
+ hasMore = userDefinedPatterns.remove(pattern);
}
}
}
- fUserDefinedPatterns= userDefinedPatterns.toArray(new String[userDefinedPatterns.size()]);
+ fUserDefinedPatterns = userDefinedPatterns.toArray(new String[userDefinedPatterns.size()]);
setUserDefinedPatternsEnabled(fUserDefinedPatternsEnabled && fUserDefinedPatterns.length > 0);
}
// ---------- dialog related code ----------
void openDialog() {
- CustomFiltersDialog dialog= new CustomFiltersDialog(
- fViewer.getControl().getShell(),
- fTargetId,
- areUserDefinedPatternsEnabled(),
- fUserDefinedPatterns,
- getEnabledFilterIds());
+ CustomFiltersDialog dialog = new CustomFiltersDialog(fViewer.getControl().getShell(), fTargetId,
+ areUserDefinedPatternsEnabled(), fUserDefinedPatterns, getEnabledFilterIds());
if (dialog.open() == Window.OK) {
setEnabledFilterIds(dialog.getEnabledFilterIds());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java
index b7bd12c966a..257f6181443 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java
@@ -55,11 +55,10 @@ import org.eclipse.cdt.internal.ui.actions.DeleteResConfigsHandler;
* @deprecated as of CDT 8.0 now using {@link DeleteResConfigsHandler}
*/
@Deprecated
-public class DeleteResConfigsAction
-implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
+public class DeleteResConfigsAction implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
protected ArrayList<IResource> objects = null;
- private ArrayList<ResCfgData> outData = null;
+ private ArrayList<ResCfgData> outData = null;
@Override
public void selectionChanged(IAction action, ISelection selection) {
@@ -69,19 +68,20 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
if (!selection.isEmpty()) {
// case for context menu
if (selection instanceof IStructuredSelection) {
- Object[] obs = ((IStructuredSelection)selection).toArray();
+ Object[] obs = ((IStructuredSelection) selection).toArray();
if (obs.length > 0) {
- for (int i=0; i<obs.length; i++) {
+ for (int i = 0; i < obs.length; i++) {
IResource res = null;
// only folders and files may be affected by this action
if (obs[i] instanceof ICContainer || obs[i] instanceof ITranslationUnit)
- res = ((ICElement)obs[i]).getResource();
+ res = ((ICElement) obs[i]).getResource();
// project's configuration cannot be deleted
else if (obs[i] instanceof IResource && !(obs[i] instanceof IProject))
- res = (IResource)obs[i];
+ res = (IResource) obs[i];
if (res != null) {
IProject p = res.getProject();
- if (!p.isOpen()) continue;
+ if (!p.isOpen())
+ continue;
if (!CoreModel.getDefault().isNewStyleProject(p))
continue;
@@ -89,13 +89,16 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
IPath path = res.getProjectRelativePath();
// getting description in read-only mode
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
- if (prjd == null) continue;
+ if (prjd == null)
+ continue;
ICConfigurationDescription[] cfgds = prjd.getConfigurations();
- if (cfgds == null || cfgds.length == 0) continue;
+ if (cfgds == null || cfgds.length == 0)
+ continue;
for (ICConfigurationDescription cfgd : cfgds) {
ICResourceDescription rd = cfgd.getResourceDescription(path, true);
if (rd != null) {
- if (objects == null) objects = new ArrayList<IResource>();
+ if (objects == null)
+ objects = new ArrayList<IResource>();
objects.add(res);
break; // stop configurations scanning
}
@@ -113,23 +116,21 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
openDialog();
}
-
private void openDialog() {
- if (objects == null || objects.size() == 0) return;
+ if (objects == null || objects.size() == 0)
+ return;
// create list of configurations to delete
- ListSelectionDialog dialog = new ListSelectionDialog(
- CUIPlugin.getActiveWorkbenchShell(),
- objects,
- createSelectionDialogContentProvider(),
- new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0);
+ ListSelectionDialog dialog = new ListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), objects,
+ createSelectionDialogContentProvider(), new LabelProvider() {
+ }, ActionMessages.DeleteResConfigsAction_0);
dialog.setTitle(ActionMessages.DeleteResConfigsAction_1);
if (dialog.open() == Window.OK) {
Object[] selected = dialog.getResult();
if (selected != null && selected.length > 0) {
for (Object element : selected) {
- ((ResCfgData)element).delete();
- AbstractPage.updateViews(((ResCfgData)element).res);
+ ((ResCfgData) element).delete();
+ AbstractPage.updateViews(((ResCfgData) element).res);
}
}
}
@@ -142,9 +143,12 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
ICConfigurationDescription cfgd;
ICResourceDescription rdesc;
- public ResCfgData(IResource res2, ICProjectDescription prjd2,
- ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) {
- res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2;
+ public ResCfgData(IResource res2, ICProjectDescription prjd2, ICConfigurationDescription cfgd2,
+ ICResourceDescription rdesc2) {
+ res = res2;
+ prjd = prjd2;
+ cfgd = cfgd2;
+ rdesc = rdesc2;
}
// performs deletion
@@ -152,24 +156,26 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
try {
cfgd.removeResourceDescription(rdesc);
CoreModel.getDefault().setProjectDescription(res.getProject(), prjd);
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
}
+
@Override
public String toString() {
- return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$
+ return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$
}
}
-
private IStructuredContentProvider createSelectionDialogContentProvider() {
return new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- if (outData != null) return outData.toArray();
+ if (outData != null)
+ return outData.toArray();
outData = new ArrayList<ResCfgData>();
- List<?> ls = (List<?>)inputElement;
+ List<?> ls = (List<?>) inputElement;
Iterator<?> it = ls.iterator();
IProject proj = null;
ICProjectDescription prjd = null;
@@ -177,7 +183,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
// creating list of all res descs for all objects
while (it.hasNext()) {
- IResource res = (IResource)it.next();
+ IResource res = (IResource) it.next();
IPath path = res.getProjectRelativePath();
if (res.getProject() != proj) {
proj = res.getProject();
@@ -194,24 +200,39 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
}
return outData.toArray();
}
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
};
}
@Override
- public void dispose() { objects = null; }
+ public void dispose() {
+ objects = null;
+ }
// doing nothing
@Override
- public void init(IWorkbenchWindow window) { }
+ public void init(IWorkbenchWindow window) {
+ }
+
@Override
- public Menu getMenu(Menu parent) { return null; }
+ public Menu getMenu(Menu parent) {
+ return null;
+ }
+
@Override
- public Menu getMenu(Control parent) { return null; }
+ public Menu getMenu(Control parent) {
+ return null;
+ }
+
@Override
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java
index 31f78ad0df7..7c2d9ce3740 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java
@@ -57,8 +57,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
* @deprecated as of CDT 8.0 now using {@link ExcludeFromBuildHandler}
*/
@Deprecated
-public class ExcludeFromBuildAction
-implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
+public class ExcludeFromBuildAction implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
protected ArrayList<IResource> objects = null;
protected ArrayList<String> cfgNames = null;
@@ -72,12 +71,12 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
if (!selection.isEmpty()) {
// case for context menu
if (selection instanceof IStructuredSelection) {
- Object[] obs = ((IStructuredSelection)selection).toArray();
+ Object[] obs = ((IStructuredSelection) selection).toArray();
if (obs.length > 0) {
- for (int i=0; i<obs.length && cfgsOK; i++) {
+ for (int i = 0; i < obs.length && cfgsOK; i++) {
// if project selected, don't do anything
if ((obs[i] instanceof IProject) || (obs[i] instanceof ICProject)) {
- cfgsOK=false;
+ cfgsOK = false;
break;
}
IResource res = null;
@@ -90,13 +89,15 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
}
if (res != null) {
ICConfigurationDescription[] cfgds = getCfgsRead(res);
- if (cfgds == null || cfgds.length == 0) continue;
+ if (cfgds == null || cfgds.length == 0)
+ continue;
- if (objects == null) objects = new ArrayList<IResource>();
+ if (objects == null)
+ objects = new ArrayList<IResource>();
objects.add(res);
if (cfgNames == null) {
cfgNames = new ArrayList<String>(cfgds.length);
- for (int j=0; j<cfgds.length; j++) {
+ for (int j = 0; j < cfgds.length; j++) {
if (!canExclude(res, cfgds[j])) {
cfgNames = null;
cfgsOK = false;
@@ -108,9 +109,8 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
if (cfgNames.size() != cfgds.length) {
cfgsOK = false;
} else {
- for (int j=0; j<cfgds.length; j++) {
- if (! canExclude(res, cfgds[j]) ||
- ! cfgNames.contains(cfgds[j].getName())) {
+ for (int j = 0; j < cfgds.length; j++) {
+ if (!canExclude(res, cfgds[j]) || !cfgNames.contains(cfgds[j].getName())) {
cfgsOK = false;
break;
}
@@ -122,7 +122,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
}
}
}
- action.setEnabled(cfgsOK && objects != null );
+ action.setEnabled(cfgsOK && objects != null);
}
private boolean canExclude(IResource res, ICConfigurationDescription cfg) {
@@ -134,7 +134,8 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
private void setExclude(IResource res, ICConfigurationDescription cfg, boolean exclude) {
try {
- ICSourceEntry[] newEntries = CDataUtil.setExcluded(res.getFullPath(), (res instanceof IFolder), exclude, cfg.getSourceEntries());
+ ICSourceEntry[] newEntries = CDataUtil.setExcluded(res.getFullPath(), (res instanceof IFolder), exclude,
+ cfg.getSourceEntries());
cfg.setSourceEntries(newEntries);
} catch (CoreException e) {
CUIPlugin.log(e);
@@ -148,23 +149,24 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
private ICConfigurationDescription[] getCfgsRead(IResource res) {
IProject p = res.getProject();
- if (!p.isOpen()) return null;
- if (!CoreModel.getDefault().isNewStyleProject(p)) return null;
+ if (!p.isOpen())
+ return null;
+ if (!CoreModel.getDefault().isNewStyleProject(p))
+ return null;
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
- if (prjd == null) return null;
+ if (prjd == null)
+ return null;
return prjd.getConfigurations();
}
private void openDialog() {
- if (objects == null || objects.size() == 0) return;
+ if (objects == null || objects.size() == 0)
+ return;
// create list of configurations to delete
- ListSelectionDialog dialog = new ListSelectionDialog(
- CUIPlugin.getActiveWorkbenchShell(),
- cfgNames,
- createSelectionDialogContentProvider(),
- new LabelProvider() {},
- ActionMessages.ExcludeFromBuildAction_0);
+ ListSelectionDialog dialog = new ListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), cfgNames,
+ createSelectionDialogContentProvider(), new LabelProvider() {
+ }, ActionMessages.ExcludeFromBuildAction_0);
dialog.setTitle(ActionMessages.ExcludeFromBuildAction_1);
boolean[] status = new boolean[cfgNames.size()];
@@ -173,14 +175,16 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
IResource res = it.next();
ICConfigurationDescription[] cfgds = getCfgsRead(res);
IPath p = res.getFullPath();
- for (int i=0; i<cfgds.length; i++) {
+ for (int i = 0; i < cfgds.length; i++) {
boolean b = CDataUtil.isExcluded(p, cfgds[i].getSourceEntries());
- if (b) status[i] = true;
+ if (b)
+ status[i] = true;
}
}
ArrayList<String> lst = new ArrayList<String>();
- for (int i=0; i<status.length; i++)
- if (status[i]) lst.add(cfgNames.get(i));
+ for (int i = 0; i < status.length; i++)
+ if (status[i])
+ lst.add(cfgNames.get(i));
if (lst.size() > 0)
dialog.setInitialElementSelections(lst);
@@ -190,14 +194,16 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
while (it2.hasNext()) {
IResource res = it2.next();
IProject p = res.getProject();
- if (!p.isOpen()) continue;
+ if (!p.isOpen())
+ continue;
// get writable description
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, true);
- if (prjd == null) continue;
+ if (prjd == null)
+ continue;
ICConfigurationDescription[] cfgds = prjd.getConfigurations();
- for (int i=0; i<cfgds.length; i++) {
+ for (int i = 0; i < cfgds.length; i++) {
boolean exclude = false;
- for (int j=0; j<selected.length; j++) {
+ for (int j = 0; j < selected.length; j++) {
if (cfgds[i].getName().equals(selected[j])) {
exclude = true;
break;
@@ -218,24 +224,41 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
private IStructuredContentProvider createSelectionDialogContentProvider() {
return new IStructuredContentProvider() {
@Override
- public Object[] getElements(Object inputElement) { return cfgNames.toArray(); }
+ public Object[] getElements(Object inputElement) {
+ return cfgNames.toArray();
+ }
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
};
}
@Override
- public void dispose() { objects = null; }
+ public void dispose() {
+ objects = null;
+ }
// doing nothing
@Override
- public void init(IWorkbenchWindow window) { }
+ public void init(IWorkbenchWindow window) {
+ }
+
@Override
- public Menu getMenu(Menu parent) { return null; }
+ public Menu getMenu(Menu parent) {
+ return null;
+ }
+
@Override
- public Menu getMenu(Control parent) { return null; }
+ public Menu getMenu(Control parent) {
+ return null;
+ }
+
@Override
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java
index 33400f83f2c..a898c0578f4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java
@@ -102,14 +102,17 @@ public class FormatAllAction extends SelectionDispatchAction {
*/
public static class ObjectDelegate implements IObjectActionDelegate {
private FormatAllAction fAction;
+
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fAction= new FormatAllAction(targetPart.getSite());
+ fAction = new FormatAllAction(targetPart.getSite());
}
+
@Override
public void run(IAction action) {
fAction.run();
}
+
@Override
public void selectionChanged(IAction action, ISelection selection) {
if (fAction == null)
@@ -135,7 +138,6 @@ public class FormatAllAction extends SelectionDispatchAction {
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.FORMAT_ALL);
}
-
@Override
public void selectionChanged(ITextSelection selection) {
// do nothing
@@ -147,23 +149,23 @@ public class FormatAllAction extends SelectionDispatchAction {
}
private ITranslationUnit[] getTranslationUnits(IStructuredSelection selection) {
- HashSet<ICElement> result= new HashSet<ICElement>();
- Object[] selected= selection.toArray();
- for (int i= 0; i < selected.length; i++) {
+ HashSet<ICElement> result = new HashSet<ICElement>();
+ Object[] selected = selection.toArray();
+ for (int i = 0; i < selected.length; i++) {
try {
if (selected[i] instanceof ICElement) {
- ICElement elem= (ICElement) selected[i];
+ ICElement elem = (ICElement) selected[i];
if (elem.exists()) {
switch (elem.getElementType()) {
- case ICElement.C_UNIT:
- result.add(elem);
- break;
- case ICElement.C_CCONTAINER:
- collectTranslationUnits((ICContainer) elem, result);
- break;
- case ICElement.C_PROJECT:
- collectTranslationUnits((ICProject) elem, result);
- break;
+ case ICElement.C_UNIT:
+ result.add(elem);
+ break;
+ case ICElement.C_CCONTAINER:
+ collectTranslationUnits((ICContainer) elem, result);
+ break;
+ case ICElement.C_PROJECT:
+ collectTranslationUnits((ICProject) elem, result);
+ break;
}
}
} else if (selected[i] instanceof IProject) {
@@ -187,9 +189,9 @@ public class FormatAllAction extends SelectionDispatchAction {
}
private void collectTranslationUnits(ICContainer container, Collection<ICElement> result) throws CModelException {
- ICElement[] children= container.getChildren();
- for (int i= 0; i < children.length; i++) {
- ICElement elem= children[i];
+ ICElement[] children = container.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ ICElement elem = children[i];
if (elem.exists()) {
switch (elem.getElementType()) {
case ICElement.C_UNIT:
@@ -204,16 +206,16 @@ public class FormatAllAction extends SelectionDispatchAction {
}
private boolean isEnabled(IStructuredSelection selection) {
- Object[] selected= selection.toArray();
- for (int i= 0; i < selected.length; i++) {
+ Object[] selected = selection.toArray();
+ for (int i = 0; i < selected.length; i++) {
if (selected[i] instanceof ICElement) {
- ICElement elem= (ICElement) selected[i];
+ ICElement elem = (ICElement) selected[i];
if (elem.exists()) {
switch (elem.getElementType()) {
- case ICElement.C_UNIT:
- case ICElement.C_CCONTAINER:
- case ICElement.C_PROJECT:
- return true;
+ case ICElement.C_UNIT:
+ case ICElement.C_CCONTAINER:
+ case ICElement.C_PROJECT:
+ return true;
}
}
} else if (selected[i] instanceof IProject) {
@@ -231,25 +233,22 @@ public class FormatAllAction extends SelectionDispatchAction {
@Override
public void run(IStructuredSelection selection) {
- ITranslationUnit[] tus= getTranslationUnits(selection);
+ ITranslationUnit[] tus = getTranslationUnits(selection);
if (tus.length == 0)
return;
if (tus.length > 1) {
- int returnCode= OptionalMessageDialog.open("FormatAll", //$NON-NLS-1$
- getShell(),
- ActionMessages.FormatAllAction_noundo_title,
- null,
- ActionMessages.FormatAllAction_noundo_message,
- MessageDialog.WARNING,
- new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL},
- 0);
- if (returnCode != OptionalMessageDialog.NOT_SHOWN &&
- returnCode != Window.OK ) return;
+ int returnCode = OptionalMessageDialog.open("FormatAll", //$NON-NLS-1$
+ getShell(), ActionMessages.FormatAllAction_noundo_title, null,
+ ActionMessages.FormatAllAction_noundo_message, MessageDialog.WARNING,
+ new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
+ if (returnCode != OptionalMessageDialog.NOT_SHOWN && returnCode != Window.OK)
+ return;
}
- IStatus status= Resources.makeCommittable(getResources(tus), getShell());
+ IStatus status = Resources.makeCommittable(getResources(tus), getShell());
if (!status.isOK()) {
- ErrorDialog.openError(getShell(), ActionMessages.FormatAllAction_failedvalidateedit_title, ActionMessages.FormatAllAction_failedvalidateedit_message, status);
+ ErrorDialog.openError(getShell(), ActionMessages.FormatAllAction_failedvalidateedit_title,
+ ActionMessages.FormatAllAction_failedvalidateedit_message, status);
return;
}
@@ -257,9 +256,9 @@ public class FormatAllAction extends SelectionDispatchAction {
}
private IResource[] getResources(ITranslationUnit[] tus) {
- IResource[] res= new IResource[tus.length];
- for (int i= 0; i < res.length; i++) {
- res[i]= tus[i].getResource();
+ IResource[] res = new IResource[tus.length];
+ for (int i = 0; i < res.length; i++) {
+ res[i] = tus[i].getResource();
}
return res;
}
@@ -270,29 +269,32 @@ public class FormatAllAction extends SelectionDispatchAction {
*/
public void runOnMultiple(final ITranslationUnit[] tus) {
try {
- String message= ActionMessages.FormatAllAction_status_description;
- final MultiStatus status= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.OK, message, null);
+ String message = ActionMessages.FormatAllAction_status_description;
+ final MultiStatus status = new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.OK, message, null);
if (tus.length == 1) {
EditorUtility.openInEditor(tus[0]);
}
- PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(new IWorkspaceRunnable() {
- @Override
- public void run(IProgressMonitor monitor) {
- doRunOnMultiple(tus, status, monitor);
- }
- })); // workspace lock
+ PlatformUI.getWorkbench().getProgressService().run(true, true,
+ new WorkbenchRunnableAdapter(new IWorkspaceRunnable() {
+ @Override
+ public void run(IProgressMonitor monitor) {
+ doRunOnMultiple(tus, status, monitor);
+ }
+ })); // workspace lock
if (!status.isOK()) {
- String title= ActionMessages.FormatAllAction_multi_status_title;
+ String title = ActionMessages.FormatAllAction_multi_status_title;
ErrorDialog.openError(getShell(), title, null, status);
}
} catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message);
+ ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title,
+ ActionMessages.FormatAllAction_error_message);
} catch (InterruptedException e) {
// Canceled by user
} catch (CoreException e) {
- ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message);
+ ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title,
+ ActionMessages.FormatAllAction_error_message);
}
}
@@ -306,7 +308,8 @@ public class FormatAllAction extends SelectionDispatchAction {
context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, options);
context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
- final MultiPassContentFormatter formatter= new MultiPassContentFormatter(ICPartitions.C_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE);
+ final MultiPassContentFormatter formatter = new MultiPassContentFormatter(ICPartitions.C_PARTITIONING,
+ IDocument.DEFAULT_CONTENT_TYPE);
formatter.setMasterStrategy(new CFormattingStrategy());
try {
@@ -316,17 +319,17 @@ public class FormatAllAction extends SelectionDispatchAction {
stopSequentialRewriteMode(document);
}
} finally {
- context.dispose();
+ context.dispose();
}
- }
+ }
@SuppressWarnings("deprecation")
private void startSequentialRewriteMode(IDocument document) {
if (document instanceof IDocumentExtension4) {
- IDocumentExtension4 extension= (IDocumentExtension4) document;
- fRewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
+ IDocumentExtension4 extension = (IDocumentExtension4) document;
+ fRewriteSession = extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
} else if (document instanceof IDocumentExtension) {
- IDocumentExtension extension= (IDocumentExtension) document;
+ IDocumentExtension extension = (IDocumentExtension) document;
extension.startSequentialRewrite(false);
}
}
@@ -334,39 +337,40 @@ public class FormatAllAction extends SelectionDispatchAction {
@SuppressWarnings("deprecation")
private void stopSequentialRewriteMode(IDocument document) {
if (document instanceof IDocumentExtension4) {
- IDocumentExtension4 extension= (IDocumentExtension4) document;
+ IDocumentExtension4 extension = (IDocumentExtension4) document;
extension.stopRewriteSession(fRewriteSession);
} else if (document instanceof IDocumentExtension) {
- IDocumentExtension extension= (IDocumentExtension)document;
+ IDocumentExtension extension = (IDocumentExtension) document;
extension.stopSequentialRewrite();
}
}
- private void doRunOnMultiple(ITranslationUnit[] tus, MultiStatus status, IProgressMonitor monitor) throws OperationCanceledException {
+ private void doRunOnMultiple(ITranslationUnit[] tus, MultiStatus status, IProgressMonitor monitor)
+ throws OperationCanceledException {
if (monitor == null) {
- monitor= new NullProgressMonitor();
+ monitor = new NullProgressMonitor();
}
monitor.setTaskName(ActionMessages.FormatAllAction_operation_description);
monitor.beginTask("", tus.length * 4); //$NON-NLS-1$
try {
- Map<String, Object> lastOptions= null;
- ICProject lastProject= null;
-
- for (int i= 0; i < tus.length; i++) {
- ITranslationUnit tu= tus[i];
- IPath path= tu.getPath();
- if (lastProject == null || lastOptions == null|| !lastProject.equals(tu.getCProject())) {
- lastProject= tu.getCProject();
- lastOptions= getFomatterSettings(lastProject);
+ Map<String, Object> lastOptions = null;
+ ICProject lastProject = null;
+
+ for (int i = 0; i < tus.length; i++) {
+ ITranslationUnit tu = tus[i];
+ IPath path = tu.getPath();
+ if (lastProject == null || lastOptions == null || !lastProject.equals(tu.getCProject())) {
+ lastProject = tu.getCProject();
+ lastOptions = getFomatterSettings(lastProject);
}
- ILanguage language= null;
+ ILanguage language = null;
try {
- language= tu.getLanguage();
+ language = tu.getLanguage();
} catch (CoreException exc) {
// use fallback CPP
- language= GPPLanguage.getDefault();
+ language = GPPLanguage.getDefault();
}
// use working copy if available
@@ -382,13 +386,13 @@ public class FormatAllAction extends SelectionDispatchAction {
throw new OperationCanceledException();
}
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
try {
try {
manager.connect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
monitor.subTask(path.makeRelative().toString());
- ITextFileBuffer fileBuffer= manager.getTextFileBuffer(path, LocationKind.IFILE);
+ ITextFileBuffer fileBuffer = manager.getTextFileBuffer(path, LocationKind.IFILE);
boolean wasDirty = fileBuffer.isDirty();
formatTranslationUnit(fileBuffer, lastOptions);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java
index 707cf19c49a..27ca9e17d27 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java
@@ -74,71 +74,71 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
/**
* Pop-up menu: id of the source sub menu (value <code>org.eclipse.cdt.ui.source.menu</code>).
*/
- public static final String MENU_ID= "org.eclipse.cdt.ui.source.menu"; //$NON-NLS-1$
+ public static final String MENU_ID = "org.eclipse.cdt.ui.source.menu"; //$NON-NLS-1$
/**
* Pop-up menu: id of the organize group of the source sub menu (value
* <code>organizeGroup</code>).
*/
- public static final String GROUP_ORGANIZE= "organizeGroup"; //$NON-NLS-1$
+ public static final String GROUP_ORGANIZE = "organizeGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the generate group of the source sub menu (value
* <code>generateGroup</code>).
*/
- public static final String GROUP_GENERATE= "generateGroup"; //$NON-NLS-1$
+ public static final String GROUP_GENERATE = "generateGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the code group of the source sub menu (value
* <code>codeGroup</code>).
*/
- public static final String GROUP_CODE= "codeGroup"; //$NON-NLS-1$
+ public static final String GROUP_CODE = "codeGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the externalize group of the source sub menu (value
* <code>externalizeGroup</code>).
*/
- private static final String GROUP_EXTERNALIZE= "externalizeGroup"; //$NON-NLS-1$
+ private static final String GROUP_EXTERNALIZE = "externalizeGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the comment group of the source sub menu (value
* <code>commentGroup</code>).
*/
- private static final String GROUP_COMMENT= "commentGroup"; //$NON-NLS-1$
+ private static final String GROUP_COMMENT = "commentGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the edit group of the source sub menu (value
* <code>editGroup</code>).
*/
- private static final String GROUP_EDIT= "editGroup"; //$NON-NLS-1$
+ private static final String GROUP_EDIT = "editGroup"; //$NON-NLS-1$
private CEditor fEditor;
private IWorkbenchSite fSite;
- private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE;
+ private String fGroupName = IContextMenuConstants.GROUP_REORGANIZE;
private List<ISelectionChangedListener> fRegisteredSelectionListeners;
- private List<RefactoringAction> fRefactorActions= new ArrayList<RefactoringAction>();
+ private List<RefactoringAction> fRefactorActions = new ArrayList<RefactoringAction>();
private AddIncludeAction fAddInclude;
-// private OverrideMethodsAction fOverrideMethods;
-// private GenerateHashCodeEqualsAction fHashCodeEquals;
+ // private OverrideMethodsAction fOverrideMethods;
+ // private GenerateHashCodeEqualsAction fHashCodeEquals;
private GettersAndSettersAction fAddGetterSetter;
private ImplementMethodAction fImplementMethod;
-// private AddDelegateMethodsAction fAddDelegateMethods;
-// private AddUnimplementedConstructorsAction fAddUnimplementedConstructors;
-// private GenerateNewConstructorUsingFieldsAction fGenerateConstructorUsingFields;
-// private AddJavaDocStubAction fAddCppDocStub;
+ // private AddDelegateMethodsAction fAddDelegateMethods;
+ // private AddUnimplementedConstructorsAction fAddUnimplementedConstructors;
+ // private GenerateNewConstructorUsingFieldsAction fGenerateConstructorUsingFields;
+ // private AddJavaDocStubAction fAddCppDocStub;
private AddBookmarkAction fAddBookmark;
private AddTaskAction fAddTaskAction;
-// private ExternalizeStringsAction fExternalizeStrings;
-// private CleanUpAction fCleanUp;
-//
+ // private ExternalizeStringsAction fExternalizeStrings;
+ // private CleanUpAction fCleanUp;
+ //
private OrganizeIncludesAction fOrganizeIncludes;
-// private SortMembersAction fSortMembers;
+ // private SortMembersAction fSortMembers;
private SortLinesAction fSortLines;
private FormatAllAction fFormatAll;
-// private CopyQualifiedNameAction fCopyQualifiedNameAction;
-//
- private static final String QUICK_MENU_ID= "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$
+ // private CopyQualifiedNameAction fCopyQualifiedNameAction;
+ //
+ private static final String QUICK_MENU_ID = "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$
private IHandlerActivation fQuickAccessHandlerActivation;
private IHandlerService fHandlerService;
@@ -153,72 +153,72 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
* @noreference This constructor is not intended to be referenced by clients.
*/
public GenerateActionGroup(CEditor editor, String groupName) {
- fSite= editor.getSite();
- fSelectionProvider= fSite.getSelectionProvider();
- fEditor= editor;
- fGroupName= groupName;
+ fSite = editor.getSite();
+ fSelectionProvider = fSite.getSelectionProvider();
+ fEditor = editor;
+ fGroupName = groupName;
- fAddInclude= new AddIncludeAction(editor);
+ fAddInclude = new AddIncludeAction(editor);
fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
editor.setAction("AddInclude", fAddInclude); //$NON-NLS-1$
- fOrganizeIncludes= new OrganizeIncludesAction(editor);
+ fOrganizeIncludes = new OrganizeIncludesAction(editor);
fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
editor.setAction("OrganizeIncludes", fOrganizeIncludes); //$NON-NLS-1$
-// fSortMembers= new SortMembersAction(editor);
-// fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
-// editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$
+ // fSortMembers= new SortMembersAction(editor);
+ // fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
+ // editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$
- fSortLines= new SortLinesAction(editor);
+ fSortLines = new SortLinesAction(editor);
fSortLines.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_LINES);
editor.setAction("SortLines", fSortLines); //$NON-NLS-1$
-// IAction pastAction= editor.getAction(ITextEditorActionConstants.PASTE);//IWorkbenchActionDefinitionIds.PASTE);
-// fCopyQualifiedNameAction= new CopyQualifiedNameAction(editor, null, pastAction);
-// fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID);
-// editor.setAction("CopyQualifiedName", fCopyQualifiedNameAction); //$NON-NLS-1$
-//
-// fOverrideMethods= new OverrideMethodsAction(editor);
-// fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
-// editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
-//
- fAddGetterSetter= new GettersAndSettersAction(editor);
+ // IAction pastAction= editor.getAction(ITextEditorActionConstants.PASTE);//IWorkbenchActionDefinitionIds.PASTE);
+ // fCopyQualifiedNameAction= new CopyQualifiedNameAction(editor, null, pastAction);
+ // fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID);
+ // editor.setAction("CopyQualifiedName", fCopyQualifiedNameAction); //$NON-NLS-1$
+ //
+ // fOverrideMethods= new OverrideMethodsAction(editor);
+ // fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
+ // editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
+ //
+ fAddGetterSetter = new GettersAndSettersAction(editor);
fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.GETTERS_AND_SETTERS);
editor.setAction("org.eclipse.cdt.ui.refactor.getters.and.setters", fAddGetterSetter); //$NON-NLS-1$
fImplementMethod = new ImplementMethodAction(editor);
fImplementMethod.setActionDefinitionId(ICEditorActionDefinitionIds.IMPLEMENT_METHOD);
editor.setAction("org.eclipse.cdt.ui.refactor.implement.method", fImplementMethod); //$NON-NLS-1$
-//
-// fAddDelegateMethods= new AddDelegateMethodsAction(editor);
-// fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
-// editor.setAction("AddDelegateMethods", fAddDelegateMethods); //$NON-NLS-1$
-//
-// fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor);
-// fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONSTRUCTORS);
-// editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$
-//
-// fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(editor);
-// fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
-// editor.setAction("GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$
-//
-// fHashCodeEquals= new GenerateHashCodeEqualsAction(editor);
-// fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
-// editor.setAction("GenerateHashCodeEquals", fHashCodeEquals); //$NON-NLS-1$
-//
-// fAddCppDocStub= new AddJavaDocStubAction(editor);
-// fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
-// editor.setAction("AddJavadocComment", fAddCppDocStub); //$NON-NLS-1$
-//
-// fCleanUp= new CleanUpAction(editor);
-// fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
-// editor.setAction("CleanUp", fCleanUp); //$NON-NLS-1$
-//
-// fExternalizeStrings= new ExternalizeStringsAction(editor);
-// fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
-// editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$
-//
+ //
+ // fAddDelegateMethods= new AddDelegateMethodsAction(editor);
+ // fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
+ // editor.setAction("AddDelegateMethods", fAddDelegateMethods); //$NON-NLS-1$
+ //
+ // fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor);
+ // fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONSTRUCTORS);
+ // editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$
+ //
+ // fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(editor);
+ // fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
+ // editor.setAction("GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$
+ //
+ // fHashCodeEquals= new GenerateHashCodeEqualsAction(editor);
+ // fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
+ // editor.setAction("GenerateHashCodeEquals", fHashCodeEquals); //$NON-NLS-1$
+ //
+ // fAddCppDocStub= new AddJavaDocStubAction(editor);
+ // fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
+ // editor.setAction("AddJavadocComment", fAddCppDocStub); //$NON-NLS-1$
+ //
+ // fCleanUp= new CleanUpAction(editor);
+ // fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
+ // editor.setAction("CleanUp", fCleanUp); //$NON-NLS-1$
+ //
+ // fExternalizeStrings= new ExternalizeStringsAction(editor);
+ // fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
+ // editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$
+ //
installQuickAccessAction();
}
@@ -260,13 +260,13 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
* @since 5.4
*/
public GenerateActionGroup(IWorkbenchSite site, ISelectionProvider selectionProvider) {
- fSite= site;
- fSelectionProvider= selectionProvider == null ? fSite.getSelectionProvider() : selectionProvider;
- ISelection selection= fSelectionProvider.getSelection();
+ fSite = site;
+ fSelectionProvider = selectionProvider == null ? fSite.getSelectionProvider() : selectionProvider;
+ ISelection selection = fSelectionProvider.getSelection();
-// fOverrideMethods= new OverrideMethodsAction(site);
-// fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
-//
+ // fOverrideMethods= new OverrideMethodsAction(site);
+ // fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
+ //
fAddGetterSetter = new GettersAndSettersAction();
fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.GETTERS_AND_SETTERS);
fAddGetterSetter.setSite(fSite);
@@ -277,57 +277,56 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
fImplementMethod.setSite(fSite);
fRefactorActions.add(fImplementMethod);
-// fAddDelegateMethods= new AddDelegateMethodsAction(site);
-// fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
-//
-// fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site);
-// fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONSTRUCTORS);
-//
-// fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(site);
-// fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
-//
-// fHashCodeEquals= new GenerateHashCodeEqualsAction(site);
-// fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
-//
-// fAddCppDocStub= new AddJavaDocStubAction(site);
-// fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
-
- fAddBookmark= new AddBookmarkAction(site, true);
+ // fAddDelegateMethods= new AddDelegateMethodsAction(site);
+ // fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
+ //
+ // fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site);
+ // fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONSTRUCTORS);
+ //
+ // fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(site);
+ // fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
+ //
+ // fHashCodeEquals= new GenerateHashCodeEqualsAction(site);
+ // fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
+ //
+ // fAddCppDocStub= new AddJavaDocStubAction(site);
+ // fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
+
+ fAddBookmark = new AddBookmarkAction(site, true);
fAddBookmark.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_BOOKMARK);
- fAddTaskAction= new AddTaskAction(site);
+ fAddTaskAction = new AddTaskAction(site);
fAddTaskAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_TASK);
-// fExternalizeStrings= new ExternalizeStringsAction(site);
-// fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
-//
-// fOrganizeIncludes= new OrganizeIncludesAction(site);
-// fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
-//
-// fSortMembers= new SortMembersAction(site);
-// fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
-//
- fFormatAll= new FormatAllAction(site);
+ // fExternalizeStrings= new ExternalizeStringsAction(site);
+ // fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
+ //
+ // fOrganizeIncludes= new OrganizeIncludesAction(site);
+ // fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
+ //
+ // fSortMembers= new SortMembersAction(site);
+ // fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
+ //
+ fFormatAll = new FormatAllAction(site);
fFormatAll.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
-//
-// fCleanUp= new CleanUpAction(site);
-// fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
-
-
-// fOverrideMethods.update(selection);
-// fAddDelegateMethods.update(selection);
-// fAddUnimplementedConstructors.update(selection);
-// fGenerateConstructorUsingFields.update(selection);
-// fHashCodeEquals.update(selection);
-// fAddCppDocStub.update(selection);
-// fExternalizeStrings.update(selection);
-// fFindNLSProblems.update(selection);
-// fCleanUp.update(selection);
-// fOrganizeIncludes.update(selection);
-// fSortMembers.update(selection);
+ //
+ // fCleanUp= new CleanUpAction(site);
+ // fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
+
+ // fOverrideMethods.update(selection);
+ // fAddDelegateMethods.update(selection);
+ // fAddUnimplementedConstructors.update(selection);
+ // fGenerateConstructorUsingFields.update(selection);
+ // fHashCodeEquals.update(selection);
+ // fAddCppDocStub.update(selection);
+ // fExternalizeStrings.update(selection);
+ // fFindNLSProblems.update(selection);
+ // fCleanUp.update(selection);
+ // fOrganizeIncludes.update(selection);
+ // fSortMembers.update(selection);
fFormatAll.update(selection);
if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection)selection;
+ IStructuredSelection ss = (IStructuredSelection) selection;
fAddBookmark.selectionChanged(ss);
fAddTaskAction.selectionChanged(ss);
} else {
@@ -335,41 +334,41 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
fAddTaskAction.setEnabled(false);
}
-// registerSelectionListener(fSelectionProvider, fOverrideMethods);
-// registerSelectionListener(fSelectionProvider, fAddDelegateMethods);
-// registerSelectionListener(fSelectionProvider, fAddUnimplementedConstructors);
-// registerSelectionListener(fSelectionProvider, fGenerateConstructorUsingFields);
-// registerSelectionListener(fSelectionProvider, fHashCodeEquals);
-// registerSelectionListener(fSelectionProvider, fAddCppDocStub);
+ // registerSelectionListener(fSelectionProvider, fOverrideMethods);
+ // registerSelectionListener(fSelectionProvider, fAddDelegateMethods);
+ // registerSelectionListener(fSelectionProvider, fAddUnimplementedConstructors);
+ // registerSelectionListener(fSelectionProvider, fGenerateConstructorUsingFields);
+ // registerSelectionListener(fSelectionProvider, fHashCodeEquals);
+ // registerSelectionListener(fSelectionProvider, fAddCppDocStub);
registerSelectionListener(fSelectionProvider, fAddBookmark);
-// registerSelectionListener(fSelectionProvider, fExternalizeStrings);
-// registerSelectionListener(fSelectionProvider, fFindNLSProblems);
-// registerSelectionListener(fSelectionProvider, fOrganizeIncludes);
+ // registerSelectionListener(fSelectionProvider, fExternalizeStrings);
+ // registerSelectionListener(fSelectionProvider, fFindNLSProblems);
+ // registerSelectionListener(fSelectionProvider, fOrganizeIncludes);
registerSelectionListener(fSelectionProvider, fFormatAll);
-// registerSelectionListener(fSelectionProvider, fSortMembers);
+ // registerSelectionListener(fSelectionProvider, fSortMembers);
registerSelectionListener(fSelectionProvider, fAddTaskAction);
-// registerSelectionListener(fSelectionProvider, fCleanUp);
+ // registerSelectionListener(fSelectionProvider, fCleanUp);
selectionChanged(new SelectionChangedEvent(fSelectionProvider, selection));
registerSelectionListener(fSelectionProvider, this);
}
private void installQuickAccessAction() {
- fHandlerService= fSite.getService(IHandlerService.class);
+ fHandlerService = fSite.getService(IHandlerService.class);
if (fHandlerService != null) {
- IHandler handler= new CDTQuickMenuCreator(fEditor) {
+ IHandler handler = new CDTQuickMenuCreator(fEditor) {
@Override
protected void fillMenu(IMenuManager menu) {
fillQuickMenu(menu);
}
}.createHandler();
- fQuickAccessHandlerActivation= fHandlerService.activateHandler(QUICK_MENU_ID, handler);
+ fQuickAccessHandlerActivation = fHandlerService.activateHandler(QUICK_MENU_ID, handler);
}
}
private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) {
if (fRegisteredSelectionListeners == null)
- fRegisteredSelectionListeners= new ArrayList<ISelectionChangedListener>(10);
+ fRegisteredSelectionListeners = new ArrayList<ISelectionChangedListener>(10);
provider.addSelectionChangedListener(listener);
fRegisteredSelectionListeners.add(listener);
}
@@ -401,13 +400,13 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
@Override
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu);
- MenuManager subMenu= new MenuManager(ActionMessages.SourceMenu_label, MENU_ID);
+ MenuManager subMenu = new MenuManager(ActionMessages.SourceMenu_label, MENU_ID);
subMenu.setActionDefinitionId(QUICK_MENU_ID);
- int added= 0;
+ int added = 0;
if (isEditorOwner()) {
- added= fillEditorSubMenu(subMenu);
+ added = fillEditorSubMenu(subMenu);
} else {
- added= fillViewSubMenu(subMenu);
+ added = fillViewSubMenu(subMenu);
}
if (added > 0)
menu.appendToGroup(fGroupName, subMenu);
@@ -422,60 +421,60 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
}
private int fillEditorSubMenu(IMenuManager source) {
- int added= 0;
+ int added = 0;
source.add(new Separator(GROUP_COMMENT));
- added+= addEditorAction(source, "ToggleComment"); //$NON-NLS-1$
- added+= addEditorAction(source, "AddBlockComment"); //$NON-NLS-1$
- added+= addEditorAction(source, "RemoveBlockComment"); //$NON-NLS-1$
-// added+= addAction(source, fAddCppDocStub);
+ added += addEditorAction(source, "ToggleComment"); //$NON-NLS-1$
+ added += addEditorAction(source, "AddBlockComment"); //$NON-NLS-1$
+ added += addEditorAction(source, "RemoveBlockComment"); //$NON-NLS-1$
+ // added+= addAction(source, fAddCppDocStub);
source.add(new Separator(GROUP_EDIT));
- added+= addEditorAction(source, ITextEditorActionConstants.SHIFT_RIGHT);
- added+= addEditorAction(source, ITextEditorActionConstants.SHIFT_LEFT);
- added+= addEditorAction(source, "Indent"); //$NON-NLS-1$
- added+= addEditorAction(source, "Format"); //$NON-NLS-1$
+ added += addEditorAction(source, ITextEditorActionConstants.SHIFT_RIGHT);
+ added += addEditorAction(source, ITextEditorActionConstants.SHIFT_LEFT);
+ added += addEditorAction(source, "Indent"); //$NON-NLS-1$
+ added += addEditorAction(source, "Format"); //$NON-NLS-1$
source.add(new Separator(GROUP_ORGANIZE));
- added+= addAction(source, fAddInclude);
- added+= addAction(source, fOrganizeIncludes);
-// added+= addAction(source, fSortMembers);
- added+= addAction(source, fSortLines);
-// added+= addAction(source, fCleanUp);
+ added += addAction(source, fAddInclude);
+ added += addAction(source, fOrganizeIncludes);
+ // added+= addAction(source, fSortMembers);
+ added += addAction(source, fSortLines);
+ // added+= addAction(source, fCleanUp);
source.add(new Separator(GROUP_GENERATE));
-// added+= addAction(source, fOverrideMethods);
- added+= addAction(source, fAddGetterSetter);
- added+= addAction(source, fImplementMethod);
-// added+= addAction(source, fAddDelegateMethods);
-// added+= addAction(source, fHashCodeEquals);
-// added+= addAction(source, fGenerateConstructorUsingFields);
-// added+= addAction(source, fAddUnimplementedConstructors);
+ // added+= addAction(source, fOverrideMethods);
+ added += addAction(source, fAddGetterSetter);
+ added += addAction(source, fImplementMethod);
+ // added+= addAction(source, fAddDelegateMethods);
+ // added+= addAction(source, fHashCodeEquals);
+ // added+= addAction(source, fGenerateConstructorUsingFields);
+ // added+= addAction(source, fAddUnimplementedConstructors);
source.add(new Separator(GROUP_CODE));
source.add(new Separator(GROUP_EXTERNALIZE));
-// added+= addAction(source, fExternalizeStrings);
+ // added+= addAction(source, fExternalizeStrings);
return added;
}
private int fillViewSubMenu(IMenuManager source) {
- int added= 0;
+ int added = 0;
source.add(new Separator(GROUP_COMMENT));
-// added+= addAction(source, fAddCppDocStub);
+ // added+= addAction(source, fAddCppDocStub);
source.add(new Separator(GROUP_EDIT));
- added+= addAction(source, fFormatAll);
+ added += addAction(source, fFormatAll);
source.add(new Separator(GROUP_ORGANIZE));
- added+= addAction(source, fAddInclude);
- added+= addAction(source, fOrganizeIncludes);
-// added+= addAction(source, fSortMembers);
-// added+= addAction(source, fCleanUp);
+ added += addAction(source, fAddInclude);
+ added += addAction(source, fOrganizeIncludes);
+ // added+= addAction(source, fSortMembers);
+ // added+= addAction(source, fCleanUp);
source.add(new Separator(GROUP_GENERATE));
-// added+= addAction(source, fOverrideMethods);
- added+= addAction(source, fAddGetterSetter);
- added+= addAction(source, fImplementMethod);
-// added+= addAction(source, fAddDelegateMethods);
-// added+= addAction(source, fHashCodeEquals);
-// added+= addAction(source, fGenerateConstructorUsingFields);
-// added+= addAction(source, fAddUnimplementedConstructors);
+ // added+= addAction(source, fOverrideMethods);
+ added += addAction(source, fAddGetterSetter);
+ added += addAction(source, fImplementMethod);
+ // added+= addAction(source, fAddDelegateMethods);
+ // added+= addAction(source, fHashCodeEquals);
+ // added+= addAction(source, fGenerateConstructorUsingFields);
+ // added+= addAction(source, fAddUnimplementedConstructors);
source.add(new Separator(GROUP_CODE));
source.add(new Separator(GROUP_EXTERNALIZE));
-// added+= addAction(source, fExternalizeStrings);
-// added+= addAction(source, fFindNLSProblems);
+ // added+= addAction(source, fExternalizeStrings);
+ // added+= addAction(source, fFindNLSProblems);
return added;
}
@@ -485,46 +484,46 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
@Override
public void dispose() {
if (fRegisteredSelectionListeners != null) {
- ISelectionProvider provider= fSelectionProvider;
- for (Iterator<ISelectionChangedListener> iter= fRegisteredSelectionListeners.iterator(); iter.hasNext();) {
- ISelectionChangedListener listener= iter.next();
+ ISelectionProvider provider = fSelectionProvider;
+ for (Iterator<ISelectionChangedListener> iter = fRegisteredSelectionListeners.iterator(); iter.hasNext();) {
+ ISelectionChangedListener listener = iter.next();
provider.removeSelectionChangedListener(listener);
}
}
if (fQuickAccessHandlerActivation != null && fHandlerService != null) {
fHandlerService.deactivateHandler(fQuickAccessHandlerActivation);
}
- fEditor= null;
+ fEditor = null;
super.dispose();
}
private void setGlobalActionHandlers(IActionBars actionBar) {
actionBar.setGlobalActionHandler(CdtActionConstants.ADD_INCLUDE, fAddInclude);
-// actionBar.setGlobalActionHandler(CdtActionConstants.OVERRIDE_METHODS, fOverrideMethods);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.OVERRIDE_METHODS, fOverrideMethods);
actionBar.setGlobalActionHandler(CdtActionConstants.GETTERS_AND_SETTERS, fAddGetterSetter);
actionBar.setGlobalActionHandler(CdtActionConstants.IMPLEMENT_METHOD, fImplementMethod);
-// actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_DELEGATE_METHODS, fAddDelegateMethods);
-// actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors);
-// actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_CONSTRUCTOR_USING_FIELDS, fGenerateConstructorUsingFields);
-// actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_HASHCODE_EQUALS, fHashCodeEquals);
-// actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CPP_DOC_COMMENT, fAddCppDocStub);
-// actionBar.setGlobalActionHandler(CdtActionConstants.EXTERNALIZE_STRINGS, fExternalizeStrings);
-// actionBar.setGlobalActionHandler(CdtActionConstants.CLEAN_UP, fCleanUp);
-// TODO: actionBar.setGlobalActionHandler(CdtActionConstants.ORGANIZE_INCLUDES, fOrganizeIncludes);
-// actionBar.setGlobalActionHandler(CdtActionConstants.SORT_MEMBERS, fSortMembers);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_DELEGATE_METHODS, fAddDelegateMethods);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_CONSTRUCTOR_USING_FIELDS, fGenerateConstructorUsingFields);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_HASHCODE_EQUALS, fHashCodeEquals);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CPP_DOC_COMMENT, fAddCppDocStub);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.EXTERNALIZE_STRINGS, fExternalizeStrings);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.CLEAN_UP, fCleanUp);
+ // TODO: actionBar.setGlobalActionHandler(CdtActionConstants.ORGANIZE_INCLUDES, fOrganizeIncludes);
+ // actionBar.setGlobalActionHandler(CdtActionConstants.SORT_MEMBERS, fSortMembers);
if (!isEditorOwner()) {
// editor provides its own implementation of these actions.
actionBar.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), fAddBookmark);
actionBar.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), fAddTaskAction);
actionBar.setGlobalActionHandler(CdtActionConstants.FORMAT, fFormatAll);
} else {
-// actionBar.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction);
+ // actionBar.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction);
}
}
private int addAction(IMenuManager menu, IAction action) {
if (action instanceof IUpdate)
- ((IUpdate)action).update();
+ ((IUpdate) action).update();
if (action != null && action.isEnabled()) {
menu.add(action);
return 1;
@@ -535,11 +534,11 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
private int addEditorAction(IMenuManager menu, String actionID) {
if (fEditor == null)
return 0;
- IAction action= fEditor.getAction(actionID);
+ IAction action = fEditor.getAction(actionID);
if (action == null)
return 0;
if (action instanceof IUpdate)
- ((IUpdate)action).update();
+ ((IUpdate) action).update();
if (action.isEnabled()) {
menu.add(action);
return 1;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java
index 06a1bcbee56..78e25e9ed77 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java
@@ -30,8 +30,7 @@ import org.eclipse.cdt.ui.newui.ManageConfigSelector;
/**
* Action which lets to manage (add/remove etc.) build configurations of the project.
*/
-public class ManageConfigsAction
-implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
+public class ManageConfigsAction implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
IProject[] obs = null;
@Override
@@ -39,7 +38,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
if (!selection.isEmpty()) {
// case for context menu
if (selection instanceof StructuredSelection) {
- obs = ManageConfigSelector.getProjects(((StructuredSelection)selection).toArray());
+ obs = ManageConfigSelector.getProjects(((StructuredSelection) selection).toArray());
action.setEnabled(ManageConfigSelector.getManager(obs) != null);
return;
}
@@ -55,15 +54,26 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
}
@Override
- public void dispose() { obs = null; }
+ public void dispose() {
+ obs = null;
+ }
// doing nothing
@Override
- public void init(IWorkbenchWindow window) { }
+ public void init(IWorkbenchWindow window) {
+ }
+
@Override
- public Menu getMenu(Menu parent) { return null; }
+ public Menu getMenu(Menu parent) {
+ return null;
+ }
+
@Override
- public Menu getMenu(Control parent) { return null; }
+ public Menu getMenu(Control parent) {
+ return null;
+ }
+
@Override
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java
index 2e27f456cc2..a0b6f74a174 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java
@@ -52,28 +52,28 @@ import org.eclipse.cdt.internal.ui.viewsupport.MemberFilter;
import org.eclipse.cdt.internal.ui.viewsupport.MemberFilterAction;
public class MemberFilterActionGroup extends ActionGroup {
- public static final int FILTER_NONPUBLIC= MemberFilter.FILTER_NONPUBLIC;
- public static final int FILTER_STATIC= MemberFilter.FILTER_STATIC;
- public static final int FILTER_FIELDS= MemberFilter.FILTER_FIELDS;
+ public static final int FILTER_NONPUBLIC = MemberFilter.FILTER_NONPUBLIC;
+ public static final int FILTER_STATIC = MemberFilter.FILTER_STATIC;
+ public static final int FILTER_FIELDS = MemberFilter.FILTER_FIELDS;
/**
* @since 5.1
*/
- public static final int FILTER_INACTIVE= MemberFilter.FILTER_INACTIVE;
+ public static final int FILTER_INACTIVE = MemberFilter.FILTER_INACTIVE;
/** @deprecated Unsupported filter constant */
@Deprecated
- public static final int FILTER_LOCALTYPES= MemberFilter.FILTER_LOCALTYPES;
+ public static final int FILTER_LOCALTYPES = MemberFilter.FILTER_LOCALTYPES;
/**
* @deprecated we may choose to add more filters in future versions.
*/
@Deprecated
- public static final int ALL_FILTERS= FILTER_NONPUBLIC | FILTER_FIELDS | FILTER_STATIC;
+ public static final int ALL_FILTERS = FILTER_NONPUBLIC | FILTER_FIELDS | FILTER_STATIC;
- private static final String TAG_HIDEFIELDS= "hidefields"; //$NON-NLS-1$
- private static final String TAG_HIDESTATIC= "hidestatic"; //$NON-NLS-1$
- private static final String TAG_HIDENONPUBLIC= "hidenonpublic"; //$NON-NLS-1$
- private static final String TAG_HIDEINACTIVE= "hideinactive"; //$NON-NLS-1$
+ private static final String TAG_HIDEFIELDS = "hidefields"; //$NON-NLS-1$
+ private static final String TAG_HIDESTATIC = "hidestatic"; //$NON-NLS-1$
+ private static final String TAG_HIDENONPUBLIC = "hidenonpublic"; //$NON-NLS-1$
+ private static final String TAG_HIDEINACTIVE = "hideinactive"; //$NON-NLS-1$
private MemberFilterAction[] fFilterActions;
private MemberFilter fFilter;
@@ -82,7 +82,6 @@ public class MemberFilterActionGroup extends ActionGroup {
private String fViewerId;
private boolean fInViewMenu;
-
/**
* Creates a new <code>MemberFilterActionGroup</code>.
*
@@ -106,18 +105,18 @@ public class MemberFilterActionGroup extends ActionGroup {
* @since 2.1
*/
public MemberFilterActionGroup(StructuredViewer viewer, String viewerId, boolean inViewMenu) {
- fViewer= viewer;
- fViewerId= viewerId;
- fInViewMenu= inViewMenu;
+ fViewer = viewer;
+ fViewerId = viewerId;
+ fInViewMenu = inViewMenu;
// get initial values
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- boolean doHideFields= store.getBoolean(getPreferenceKey(FILTER_FIELDS));
- boolean doHideStatic= store.getBoolean(getPreferenceKey(FILTER_STATIC));
- boolean doHidePublic= store.getBoolean(getPreferenceKey(FILTER_NONPUBLIC));
- boolean doHideInactive= store.getBoolean(getPreferenceKey(FILTER_INACTIVE));
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ boolean doHideFields = store.getBoolean(getPreferenceKey(FILTER_FIELDS));
+ boolean doHideStatic = store.getBoolean(getPreferenceKey(FILTER_STATIC));
+ boolean doHidePublic = store.getBoolean(getPreferenceKey(FILTER_NONPUBLIC));
+ boolean doHideInactive = store.getBoolean(getPreferenceKey(FILTER_INACTIVE));
- fFilter= new MemberFilter();
+ fFilter = new MemberFilter();
if (doHideFields)
fFilter.addFilter(FILTER_FIELDS);
if (doHideStatic)
@@ -128,38 +127,39 @@ public class MemberFilterActionGroup extends ActionGroup {
fFilter.addFilter(FILTER_INACTIVE);
// fields
- String title= ActionMessages.MemberFilterActionGroup_hide_fields_label;
- String helpContext= ICHelpContextIds.FILTER_FIELDS_ACTION;
- MemberFilterAction hideFields= new MemberFilterAction(this, title, FILTER_FIELDS, helpContext, doHideFields);
+ String title = ActionMessages.MemberFilterActionGroup_hide_fields_label;
+ String helpContext = ICHelpContextIds.FILTER_FIELDS_ACTION;
+ MemberFilterAction hideFields = new MemberFilterAction(this, title, FILTER_FIELDS, helpContext, doHideFields);
hideFields.setDescription(ActionMessages.MemberFilterActionGroup_hide_fields_description);
hideFields.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_fields_tooltip);
CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
// static
- title= ActionMessages.MemberFilterActionGroup_hide_static_label;
- helpContext= ICHelpContextIds.FILTER_STATIC_ACTION;
- MemberFilterAction hideStatic= new MemberFilterAction(this, title, FILTER_STATIC, helpContext, doHideStatic);
+ title = ActionMessages.MemberFilterActionGroup_hide_static_label;
+ helpContext = ICHelpContextIds.FILTER_STATIC_ACTION;
+ MemberFilterAction hideStatic = new MemberFilterAction(this, title, FILTER_STATIC, helpContext, doHideStatic);
hideStatic.setDescription(ActionMessages.MemberFilterActionGroup_hide_static_description);
hideStatic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_static_tooltip);
CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC);
// non-public
- title= ActionMessages.MemberFilterActionGroup_hide_nonpublic_label;
- helpContext= ICHelpContextIds.FILTER_PUBLIC_ACTION;
- MemberFilterAction hideNonPublic= new MemberFilterAction(this, title, FILTER_NONPUBLIC, helpContext, doHidePublic);
+ title = ActionMessages.MemberFilterActionGroup_hide_nonpublic_label;
+ helpContext = ICHelpContextIds.FILTER_PUBLIC_ACTION;
+ MemberFilterAction hideNonPublic = new MemberFilterAction(this, title, FILTER_NONPUBLIC, helpContext,
+ doHidePublic);
hideNonPublic.setDescription(ActionMessages.MemberFilterActionGroup_hide_nonpublic_description);
hideNonPublic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_nonpublic_tooltip);
CPluginImages.setImageDescriptors(hideNonPublic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC);
// inactive
- title= ActionMessages.MemberFilterActionGroup_hide_inactive_label;
- MemberFilterAction hideInactive= new MemberFilterAction(this, title, FILTER_INACTIVE, null, doHideInactive);
+ title = ActionMessages.MemberFilterActionGroup_hide_inactive_label;
+ MemberFilterAction hideInactive = new MemberFilterAction(this, title, FILTER_INACTIVE, null, doHideInactive);
hideInactive.setDescription(ActionMessages.MemberFilterActionGroup_hide_inactive_description);
hideInactive.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_inactive_tooltip);
CPluginImages.setImageDescriptors(hideInactive, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE);
// order corresponds to order in toolbar
- fFilterActions= new MemberFilterAction[] { hideFields, hideStatic, hideNonPublic, hideInactive };
+ fFilterActions = new MemberFilterAction[] { hideFields, hideStatic, hideNonPublic, hideInactive };
fViewer.addFilter(fFilter);
}
@@ -178,26 +178,27 @@ public class MemberFilterActionGroup extends ActionGroup {
*/
public MemberFilterActionGroup(StructuredViewer viewer, String viewerId, boolean inViewMenu, int availableFilters) {
- fViewer= viewer;
- fViewerId= viewerId;
- fInViewMenu= inViewMenu;
+ fViewer = viewer;
+ fViewerId = viewerId;
+ fInViewMenu = inViewMenu;
- IPreferenceStore store= PreferenceConstants.getPreferenceStore();
- fFilter= new MemberFilter();
+ IPreferenceStore store = PreferenceConstants.getPreferenceStore();
+ fFilter = new MemberFilter();
String title, helpContext;
- ArrayList<MemberFilterAction> actions= new ArrayList<MemberFilterAction>(4);
+ ArrayList<MemberFilterAction> actions = new ArrayList<MemberFilterAction>(4);
// fields
- int filterProperty= FILTER_FIELDS;
+ int filterProperty = FILTER_FIELDS;
if (isSet(filterProperty, availableFilters)) {
- boolean filterEnabled= store.getBoolean(getPreferenceKey(filterProperty));
+ boolean filterEnabled = store.getBoolean(getPreferenceKey(filterProperty));
if (filterEnabled) {
fFilter.addFilter(filterProperty);
}
- title= ActionMessages.MemberFilterActionGroup_hide_fields_label;
- helpContext= ICHelpContextIds.FILTER_FIELDS_ACTION;
- MemberFilterAction hideFields= new MemberFilterAction(this, title, filterProperty, helpContext, filterEnabled);
+ title = ActionMessages.MemberFilterActionGroup_hide_fields_label;
+ helpContext = ICHelpContextIds.FILTER_FIELDS_ACTION;
+ MemberFilterAction hideFields = new MemberFilterAction(this, title, filterProperty, helpContext,
+ filterEnabled);
hideFields.setDescription(ActionMessages.MemberFilterActionGroup_hide_fields_description);
hideFields.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_fields_tooltip);
CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, "fields_co.gif"); //$NON-NLS-1$
@@ -205,15 +206,16 @@ public class MemberFilterActionGroup extends ActionGroup {
}
// static
- filterProperty= FILTER_STATIC;
+ filterProperty = FILTER_STATIC;
if (isSet(filterProperty, availableFilters)) {
- boolean filterEnabled= store.getBoolean(getPreferenceKey(filterProperty));
+ boolean filterEnabled = store.getBoolean(getPreferenceKey(filterProperty));
if (filterEnabled) {
fFilter.addFilter(filterProperty);
}
- title= ActionMessages.MemberFilterActionGroup_hide_static_label;
- helpContext= ICHelpContextIds.FILTER_STATIC_ACTION;
- MemberFilterAction hideStatic= new MemberFilterAction(this, title, FILTER_STATIC, helpContext, filterEnabled);
+ title = ActionMessages.MemberFilterActionGroup_hide_static_label;
+ helpContext = ICHelpContextIds.FILTER_STATIC_ACTION;
+ MemberFilterAction hideStatic = new MemberFilterAction(this, title, FILTER_STATIC, helpContext,
+ filterEnabled);
hideStatic.setDescription(ActionMessages.MemberFilterActionGroup_hide_static_description);
hideStatic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_static_tooltip);
CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, "static_co.gif"); //$NON-NLS-1$
@@ -221,15 +223,16 @@ public class MemberFilterActionGroup extends ActionGroup {
}
// non-public
- filterProperty= FILTER_NONPUBLIC;
+ filterProperty = FILTER_NONPUBLIC;
if (isSet(filterProperty, availableFilters)) {
- boolean filterEnabled= store.getBoolean(getPreferenceKey(filterProperty));
+ boolean filterEnabled = store.getBoolean(getPreferenceKey(filterProperty));
if (filterEnabled) {
fFilter.addFilter(filterProperty);
}
- title= ActionMessages.MemberFilterActionGroup_hide_nonpublic_label;
- helpContext= ICHelpContextIds.FILTER_PUBLIC_ACTION;
- MemberFilterAction hideNonPublic= new MemberFilterAction(this, title, filterProperty, helpContext, filterEnabled);
+ title = ActionMessages.MemberFilterActionGroup_hide_nonpublic_label;
+ helpContext = ICHelpContextIds.FILTER_PUBLIC_ACTION;
+ MemberFilterAction hideNonPublic = new MemberFilterAction(this, title, filterProperty, helpContext,
+ filterEnabled);
hideNonPublic.setDescription(ActionMessages.MemberFilterActionGroup_hide_nonpublic_description);
hideNonPublic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_nonpublic_tooltip);
CPluginImages.setImageDescriptors(hideNonPublic, CPluginImages.T_LCL, "public_co.gif"); //$NON-NLS-1$
@@ -237,14 +240,14 @@ public class MemberFilterActionGroup extends ActionGroup {
}
// non-public
- filterProperty= FILTER_INACTIVE;
+ filterProperty = FILTER_INACTIVE;
if (isSet(filterProperty, availableFilters)) {
- boolean filterEnabled= store.getBoolean(getPreferenceKey(filterProperty));
+ boolean filterEnabled = store.getBoolean(getPreferenceKey(filterProperty));
if (filterEnabled) {
fFilter.addFilter(filterProperty);
}
- title= ActionMessages.MemberFilterActionGroup_hide_inactive_label;
- MemberFilterAction hideInactive= new MemberFilterAction(this, title, filterProperty, null, filterEnabled);
+ title = ActionMessages.MemberFilterActionGroup_hide_inactive_label;
+ MemberFilterAction hideInactive = new MemberFilterAction(this, title, filterProperty, null, filterEnabled);
hideInactive.setDescription(ActionMessages.MemberFilterActionGroup_hide_inactive_description);
hideInactive.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_inactive_tooltip);
CPluginImages.setImageDescriptors(hideInactive, CPluginImages.T_LCL, "filterInactive.gif"); //$NON-NLS-1$
@@ -252,7 +255,7 @@ public class MemberFilterActionGroup extends ActionGroup {
}
// order corresponds to order in toolbar
- fFilterActions= actions.toArray(new MemberFilterAction[actions.size()]);
+ fFilterActions = actions.toArray(new MemberFilterAction[actions.size()]);
fViewer.addFilter(fFilter);
}
@@ -276,7 +279,7 @@ public class MemberFilterActionGroup extends ActionGroup {
* .
*/
public void setMemberFilter(int filterProperty, boolean set) {
- setMemberFilters(new int[] {filterProperty}, new boolean[] {set}, true);
+ setMemberFilters(new int[] { filterProperty }, new boolean[] { set }, true);
}
private void setMemberFilters(int[] propertyKeys, boolean[] propertyValues, boolean refresh) {
@@ -284,18 +287,18 @@ public class MemberFilterActionGroup extends ActionGroup {
return;
Assert.isTrue(propertyKeys.length == propertyValues.length);
- for (int i= 0; i < propertyKeys.length; i++) {
- int filterProperty= propertyKeys[i];
- boolean set= propertyValues[i];
+ for (int i = 0; i < propertyKeys.length; i++) {
+ int filterProperty = propertyKeys[i];
+ boolean set = propertyValues[i];
if (set) {
fFilter.addFilter(filterProperty);
} else {
fFilter.removeFilter(filterProperty);
}
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- for (int j= 0; j < fFilterActions.length; j++) {
- int currProperty= fFilterActions[j].getFilterProperty();
+ for (int j = 0; j < fFilterActions.length; j++) {
+ int currProperty = fFilterActions[j].getFilterProperty();
if (currProperty == filterProperty) {
fFilterActions[j].setChecked(set);
}
@@ -345,14 +348,12 @@ public class MemberFilterActionGroup extends ActionGroup {
* @param memento the memento from which the state is restored
*/
public void restoreState(IMemento memento) {
- setMemberFilters(
- new int[] {FILTER_FIELDS, FILTER_STATIC, FILTER_NONPUBLIC, FILTER_INACTIVE},
- new boolean[] {
- Boolean.valueOf(memento.getString(TAG_HIDEFIELDS)).booleanValue(),
- Boolean.valueOf(memento.getString(TAG_HIDESTATIC)).booleanValue(),
- Boolean.valueOf(memento.getString(TAG_HIDENONPUBLIC)).booleanValue(),
- Boolean.valueOf(memento.getString(TAG_HIDEINACTIVE)).booleanValue()
- }, false);
+ setMemberFilters(new int[] { FILTER_FIELDS, FILTER_STATIC, FILTER_NONPUBLIC, FILTER_INACTIVE },
+ new boolean[] { Boolean.valueOf(memento.getString(TAG_HIDEFIELDS)).booleanValue(),
+ Boolean.valueOf(memento.getString(TAG_HIDESTATIC)).booleanValue(),
+ Boolean.valueOf(memento.getString(TAG_HIDENONPUBLIC)).booleanValue(),
+ Boolean.valueOf(memento.getString(TAG_HIDEINACTIVE)).booleanValue() },
+ false);
}
/* (non-Javadoc)
@@ -386,7 +387,7 @@ public class MemberFilterActionGroup extends ActionGroup {
public void contributeToViewMenu(IMenuManager menu) {
if (!fInViewMenu)
return;
- final String filters= "filters"; //$NON-NLS-1$
+ final String filters = "filters"; //$NON-NLS-1$
if (menu.find(filters) != null) {
menu.prependToGroup(filters, fFilterActions[0]); // fields
menu.prependToGroup(filters, fFilterActions[1]); // static
@@ -405,12 +406,11 @@ public class MemberFilterActionGroup extends ActionGroup {
*/
@Override
public void dispose() {
- fFilterActions= null;
- fFilter= null;
- fViewer= null;
+ fFilterActions = null;
+ fFilter = null;
+ fViewer = null;
super.dispose();
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenAction.java
index 626501b8f2c..2889b73d419 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenAction.java
@@ -52,43 +52,43 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
* The action is applicable to selections containing elements of
* type <code>ICompilationUnit</code>, <code>IMember</code>
* or <code>IFile</code>.
- *
+ *
* <p>
* This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
+ * </p>
+ *
* @since 2.0
*/
public class OpenAction extends SelectionDispatchAction {
private CEditor fEditor;
-
+
/**
* Creates a new <code>OpenAction</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
*/
public OpenAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.OpenAction_label);
setToolTipText(ActionMessages.OpenAction_tooltip);
- setDescription(ActionMessages.OpenAction_description);
+ setDescription(ActionMessages.OpenAction_description);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.OPEN_ACTION);
}
-
+
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
- *
+ *
* @noreference This constructor is not intended to be referenced by clients.
*/
public OpenAction(CEditor editor) {
this(editor.getEditorSite());
- fEditor= editor;
+ fEditor = editor;
setText(ActionMessages.OpenAction_declaration_label);
setEnabled(SelectionConverter.canOperateOn(fEditor));
}
-
+
/* (non-Javadoc)
* Method declared on SelectionDispatchAction.
*/
@@ -103,12 +103,12 @@ public class OpenAction extends SelectionDispatchAction {
public void selectionChanged(IStructuredSelection selection) {
setEnabled(checkEnabled(selection));
}
-
+
private boolean checkEnabled(IStructuredSelection selection) {
if (selection.isEmpty())
return false;
- for (Iterator<?> iter= selection.iterator(); iter.hasNext();) {
- Object element= iter.next();
+ for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
+ Object element = iter.next();
if (element instanceof ISourceReference)
continue;
if (element instanceof IFile)
@@ -119,7 +119,7 @@ public class OpenAction extends SelectionDispatchAction {
}
return true;
}
-
+
/* (non-Javadoc)
* Method declared on SelectionDispatchAction.
*/
@@ -128,25 +128,25 @@ public class OpenAction extends SelectionDispatchAction {
if (!ActionUtil.isProcessable(fEditor))
return;
try {
- ICElement element= SelectionConverter.codeResolve(fEditor, getShell(), getDialogTitle(),
- ActionMessages.OpenAction_select_element);
+ ICElement element = SelectionConverter.codeResolve(fEditor, getShell(), getDialogTitle(),
+ ActionMessages.OpenAction_select_element);
if (element == null) {
- IEditorStatusLine statusLine= fEditor.getAdapter(IEditorStatusLine.class);
+ IEditorStatusLine statusLine = fEditor.getAdapter(IEditorStatusLine.class);
if (statusLine != null)
statusLine.setMessage(true, ActionMessages.OpenAction_error_messageBadSelection, null);
getShell().getDisplay().beep();
return;
}
- ICElement input= SelectionConverter.getInput(fEditor);
- int type= element.getElementType();
+ ICElement input = SelectionConverter.getInput(fEditor);
+ int type = element.getElementType();
if (type == ICElement.C_PROJECT || type == ICElement.C_CCONTAINER)
- element= input;
- run(new Object[] {element} );
+ element = input;
+ run(new Object[] { element });
} catch (CModelException e) {
showError(e);
}
}
-
+
/* (non-Javadoc)
* Method declared on SelectionDispatchAction.
*/
@@ -156,7 +156,7 @@ public class OpenAction extends SelectionDispatchAction {
return;
run(selection.toArray());
}
-
+
/**
* Note: this method is for internal use only. Clients should not call this method.
*/
@@ -165,45 +165,44 @@ public class OpenAction extends SelectionDispatchAction {
return;
for (Object element : elements) {
try {
- element= getElementToOpen(element);
- boolean activateOnOpen= fEditor != null ? true : OpenStrategy.activateOnOpen();
+ element = getElementToOpen(element);
+ boolean activateOnOpen = fEditor != null ? true : OpenStrategy.activateOnOpen();
OpenActionUtil.open(element, activateOnOpen);
} catch (CModelException e) {
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
- ICStatusConstants.INTERNAL_ERROR, ActionMessages.OpenAction_error_message, e));
- ErrorDialog.openError(getShell(), getDialogTitle(),
- ActionMessages.OpenAction_error_messageProblems, e.getStatus());
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR,
+ ActionMessages.OpenAction_error_message, e));
+ ErrorDialog.openError(getShell(), getDialogTitle(), ActionMessages.OpenAction_error_messageProblems,
+ e.getStatus());
} catch (PartInitException x) {
- String name= null;
-
+ String name = null;
+
if (element instanceof ICElement) {
- name= ((ICElement) element).getElementName();
+ name = ((ICElement) element).getElementName();
} else if (element instanceof IStorage) {
- name= ((IStorage) element).getName();
+ name = ((IStorage) element).getName();
} else if (element instanceof IResource) {
- name= ((IResource) element).getName();
+ name = ((IResource) element).getName();
}
-
+
if (name != null) {
- MessageDialog.openError(getShell(),
- ActionMessages.OpenAction_error_messageProblems,
- NLS.bind(ActionMessages.OpenAction_error_messageArgs, name, x.getMessage()));
+ MessageDialog.openError(getShell(), ActionMessages.OpenAction_error_messageProblems,
+ NLS.bind(ActionMessages.OpenAction_error_messageArgs, name, x.getMessage()));
}
- }
+ }
}
}
-
+
/**
* Note: this method is for internal use only. Clients should not call this method.
*/
public Object getElementToOpen(Object object) throws CModelException {
return object;
- }
-
+ }
+
private String getDialogTitle() {
return ActionMessages.OpenAction_error_title;
}
-
+
private void showError(CoreException e) {
ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.OpenAction_error_message);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java
index f3984925c9c..8af4dde1d4d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java
@@ -43,28 +43,28 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
import org.eclipse.cdt.internal.ui.typehierarchy.OpenTypeHierarchyAction;
/**
- * Action group that adds actions to open a new CDT view part or an external
+ * Action group that adds actions to open a new CDT view part or an external
* viewer to a context menu and the global menu bar.
- *
+ *
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
- *
+ *
* @since 2.0
*/
public class OpenViewActionGroup extends ActionGroup {
- private boolean fEditorIsOwner;
+ private boolean fEditorIsOwner;
private boolean fSuppressTypeHierarchy;
private boolean fSuppressCallHierarchy;
private boolean fSuppressProperties;
private boolean fEnableIncludeBrowser;
-
+
private IWorkbenchSite fSite;
- private String fGroupName= IContextMenuConstants.GROUP_OPEN;
-
-// private OpenSuperImplementationAction fOpenSuperImplementation;
-// private OpenExternalJavadocAction fOpenExternalJavadoc;
+ private String fGroupName = IContextMenuConstants.GROUP_OPEN;
+
+ // private OpenSuperImplementationAction fOpenSuperImplementation;
+ // private OpenExternalJavadocAction fOpenExternalJavadoc;
private OpenTypeHierarchyAction fOpenTypeHierarchy;
private PropertyDialogAction fOpenPropertiesDialog;
private OpenCallHierarchyAction fOpenCallHierarchy;
@@ -75,7 +75,7 @@ public class OpenViewActionGroup extends ActionGroup {
* Creates a new <code>OpenActionGroup</code>. The group requires
* that the selection provided by the page's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
+ *
* @param page the page that owns this action group
*/
public OpenViewActionGroup(Page page) {
@@ -86,9 +86,9 @@ public class OpenViewActionGroup extends ActionGroup {
* Creates a new <code>OpenActionGroup</code>. The group requires
* that the selection provided by the page's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
+ *
* @param page the page that owns this action group
- *
+ *
* @noreference This constructor is not intended to be referenced by clients.
*/
public OpenViewActionGroup(Page page, CEditor editor) {
@@ -99,93 +99,93 @@ public class OpenViewActionGroup extends ActionGroup {
* Creates a new <code>OpenActionGroup</code>. The group requires
* that the selection provided by the part's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
+ *
* @param part the view part that owns this action group
*/
public OpenViewActionGroup(IWorkbenchPart part) {
createSiteActions(part.getSite(), null);
}
-
+
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*/
public OpenViewActionGroup(ITextEditor part) {
- fEditorIsOwner= true;
+ fEditorIsOwner = true;
-// fOpenSuperImplementation= new OpenSuperImplementationAction(part);
-// fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
-// part.setAction("OpenSuperImplementation", fOpenSuperImplementation); //$NON-NLS-1$
+ // fOpenSuperImplementation= new OpenSuperImplementationAction(part);
+ // fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
+ // part.setAction("OpenSuperImplementation", fOpenSuperImplementation); //$NON-NLS-1$
-// fOpenExternalJavadoc= new OpenExternalJavadocAction(part);
-// fOpenExternalJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EXTERNAL_JAVADOC);
-// part.setAction("OpenExternalJavadoc", fOpenExternalJavadoc); //$NON-NLS-1$
+ // fOpenExternalJavadoc= new OpenExternalJavadocAction(part);
+ // fOpenExternalJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EXTERNAL_JAVADOC);
+ // part.setAction("OpenExternalJavadoc", fOpenExternalJavadoc); //$NON-NLS-1$
- fOpenTypeHierarchy= new OpenTypeHierarchyAction(part);
+ fOpenTypeHierarchy = new OpenTypeHierarchyAction(part);
fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
part.setAction("OpenTypeHierarchy", fOpenTypeHierarchy); //$NON-NLS-1$
-
- fOpenCallHierarchy= new OpenCallHierarchyAction(part);
- fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
- part.setAction("OpenCallHierarchy", fOpenCallHierarchy); //$NON-NLS-1$
-
- fOpenIncludeBrowser= new OpenIncludeBrowserAction(part);
- fOpenIncludeBrowser.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_INCLUDE_BROWSER);
- part.setAction("OpenIncludeBrowser", fOpenIncludeBrowser); //$NON-NLS-1$
-
- if (part instanceof ICModelBasedEditor) {
- fOpenDeclaration= new OpenDeclarationsAction((ICModelBasedEditor) part);
- fOpenDeclaration.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
- part.setAction("OpenDeclarations", fOpenDeclaration); //$NON-NLS-1$
- }
+
+ fOpenCallHierarchy = new OpenCallHierarchyAction(part);
+ fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
+ part.setAction("OpenCallHierarchy", fOpenCallHierarchy); //$NON-NLS-1$
+
+ fOpenIncludeBrowser = new OpenIncludeBrowserAction(part);
+ fOpenIncludeBrowser.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_INCLUDE_BROWSER);
+ part.setAction("OpenIncludeBrowser", fOpenIncludeBrowser); //$NON-NLS-1$
+
+ if (part instanceof ICModelBasedEditor) {
+ fOpenDeclaration = new OpenDeclarationsAction((ICModelBasedEditor) part);
+ fOpenDeclaration.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
+ part.setAction("OpenDeclarations", fOpenDeclaration); //$NON-NLS-1$
+ }
initialize(part.getEditorSite());
}
private void createSiteActions(IWorkbenchSite site, CEditor editor) {
-// fOpenSuperImplementation= new OpenSuperImplementationAction(site);
-// fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
-//
-// fOpenExternalJavadoc= new OpenExternalJavadocAction(site);
-// fOpenExternalJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EXTERNAL_JAVADOC);
+ // fOpenSuperImplementation= new OpenSuperImplementationAction(site);
+ // fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
+ //
+ // fOpenExternalJavadoc= new OpenExternalJavadocAction(site);
+ // fOpenExternalJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EXTERNAL_JAVADOC);
- fOpenTypeHierarchy= new OpenTypeHierarchyAction(site);
+ fOpenTypeHierarchy = new OpenTypeHierarchyAction(site);
fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
-
- fOpenCallHierarchy= new OpenCallHierarchyAction(site);
- fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
- fOpenIncludeBrowser= new OpenIncludeBrowserAction(site);
+ fOpenCallHierarchy = new OpenCallHierarchyAction(site);
+ fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
+
+ fOpenIncludeBrowser = new OpenIncludeBrowserAction(site);
fOpenIncludeBrowser.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_INCLUDE_BROWSER);
- if (editor != null) {
- fOpenDeclaration= new OpenDeclarationsAction(editor);
- fOpenDeclaration.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
- }
+ if (editor != null) {
+ fOpenDeclaration = new OpenDeclarationsAction(editor);
+ fOpenDeclaration.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
+ }
+
+ fOpenPropertiesDialog = new PropertyDialogAction(site, site.getSelectionProvider());
+ fOpenPropertiesDialog.setActionDefinitionId("org.eclipse.ui.file.properties"); //$NON-NLS-1$
- fOpenPropertiesDialog= new PropertyDialogAction(site, site.getSelectionProvider());
- fOpenPropertiesDialog.setActionDefinitionId("org.eclipse.ui.file.properties"); //$NON-NLS-1$
-
- initialize(site);
+ initialize(site);
}
-
+
private void initialize(IWorkbenchSite site) {
- fSite= site;
- ISelectionProvider provider= fSite.getSelectionProvider();
- ISelection selection= provider.getSelection();
-// fOpenSuperImplementation.update(selection);
-// fOpenExternalJavadoc.update(selection);
+ fSite = site;
+ ISelectionProvider provider = fSite.getSelectionProvider();
+ ISelection selection = provider.getSelection();
+ // fOpenSuperImplementation.update(selection);
+ // fOpenExternalJavadoc.update(selection);
fOpenTypeHierarchy.update(selection);
fOpenCallHierarchy.update(selection);
fOpenIncludeBrowser.update(selection);
if (!fEditorIsOwner) {
if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection)selection;
+ IStructuredSelection ss = (IStructuredSelection) selection;
fOpenPropertiesDialog.selectionChanged(ss);
} else {
fOpenPropertiesDialog.selectionChanged(selection);
}
-// provider.addSelectionChangedListener(fOpenSuperImplementation);
-// provider.addSelectionChangedListener(fOpenExternalJavadoc);
+ // provider.addSelectionChangedListener(fOpenSuperImplementation);
+ // provider.addSelectionChangedListener(fOpenExternalJavadoc);
provider.addSelectionChangedListener(fOpenTypeHierarchy);
provider.addSelectionChangedListener(fOpenCallHierarchy);
provider.addSelectionChangedListener(fOpenIncludeBrowser);
@@ -201,18 +201,18 @@ public class OpenViewActionGroup extends ActionGroup {
super.fillActionBars(actionBar);
setGlobalActionHandlers(actionBar);
}
-
+
/* (non-Javadoc)
* Method declared in ActionGroup
*/
@Override
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu);
- IStructuredSelection selection= getStructuredSelection();
+ IStructuredSelection selection = getStructuredSelection();
if (!fEditorIsOwner) {
if (fOpenDeclaration != null && fOpenDeclaration.isEnabled()) {
if (selection != null) {
- Object elem= selection.getFirstElement();
+ Object elem = selection.getFirstElement();
if (elem instanceof ICElement && elem instanceof IInclude == false) {
menu.appendToGroup(fGroupName, fOpenDeclaration);
}
@@ -228,9 +228,10 @@ public class OpenViewActionGroup extends ActionGroup {
menu.appendToGroup(fGroupName, fOpenIncludeBrowser);
}
}
-// appendToGroup(menu, fOpenSuperImplementation);
+ // appendToGroup(menu, fOpenSuperImplementation);
if (!fSuppressProperties) {
- if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null &&fOpenPropertiesDialog.isApplicableForSelection(selection)) {
+ if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null
+ && fOpenPropertiesDialog.isApplicableForSelection(selection)) {
menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
}
}
@@ -241,9 +242,9 @@ public class OpenViewActionGroup extends ActionGroup {
*/
@Override
public void dispose() {
- ISelectionProvider provider= fSite.getSelectionProvider();
-// provider.removeSelectionChangedListener(fOpenSuperImplementation);
-// provider.removeSelectionChangedListener(fOpenExternalJavadoc);
+ ISelectionProvider provider = fSite.getSelectionProvider();
+ // provider.removeSelectionChangedListener(fOpenSuperImplementation);
+ // provider.removeSelectionChangedListener(fOpenExternalJavadoc);
provider.removeSelectionChangedListener(fOpenTypeHierarchy);
provider.removeSelectionChangedListener(fOpenCallHierarchy);
provider.removeSelectionChangedListener(fOpenIncludeBrowser);
@@ -252,26 +253,26 @@ public class OpenViewActionGroup extends ActionGroup {
}
super.dispose();
}
-
+
private void setGlobalActionHandlers(IActionBars actionBars) {
-// actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_SUPER_IMPLEMENTATION, fOpenSuperImplementation);
-// actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_EXTERNAL_JAVA_DOC, fOpenExternalJavadoc);
+ // actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_SUPER_IMPLEMENTATION, fOpenSuperImplementation);
+ // actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_EXTERNAL_JAVA_DOC, fOpenExternalJavadoc);
actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_TYPE_HIERARCHY, fOpenTypeHierarchy);
- actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_CALL_HIERARCHY, fOpenCallHierarchy);
- actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_INCLUDE_BROWSER, fOpenIncludeBrowser);
- if (fOpenDeclaration != null) {
- actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenDeclaration);
- }
- if (fOpenPropertiesDialog != null) {
- actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), fOpenPropertiesDialog);
- }
+ actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_CALL_HIERARCHY, fOpenCallHierarchy);
+ actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_INCLUDE_BROWSER, fOpenIncludeBrowser);
+ if (fOpenDeclaration != null) {
+ actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenDeclaration);
+ }
+ if (fOpenPropertiesDialog != null) {
+ actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), fOpenPropertiesDialog);
+ }
}
-
+
private IStructuredSelection getStructuredSelection() {
if (fSite != null) {
- ISelection selection= fSite.getSelectionProvider().getSelection();
+ ISelection selection = fSite.getSelectionProvider().getSelection();
if (selection instanceof IStructuredSelection) {
- return (IStructuredSelection)selection;
+ return (IStructuredSelection) selection;
}
}
return null;
@@ -283,23 +284,22 @@ public class OpenViewActionGroup extends ActionGroup {
}
return getElement(selection) != null;
}
-
+
private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
- List<?> list= ((IStructuredSelection)sel).toList();
+ List<?> list = ((IStructuredSelection) sel).toList();
if (list.size() == 1) {
- Object element= list.get(0);
+ Object element = list.get(0);
if (element instanceof ICElement) {
- return (ICElement)element;
+ return (ICElement) element;
}
}
}
return null;
}
-
public void setAppendToGroup(String groupName) {
- fGroupName= groupName;
+ fGroupName = groupName;
}
public void setSuppressTypeHierarchy(boolean suppressTypeHierarchy) {
@@ -313,8 +313,8 @@ public class OpenViewActionGroup extends ActionGroup {
public void setSuppressProperties(boolean suppressProperties) {
fSuppressProperties = suppressProperties;
}
-
+
public void setEnableIncludeBrowser(boolean enableIncludeBrowser) {
- fEnableIncludeBrowser= enableIncludeBrowser;
+ fEnableIncludeBrowser = enableIncludeBrowser;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java
index fbb2627a8f8..84586f51a35 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.actions;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.ITextSelection;
@@ -62,7 +61,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
*/
protected SelectionDispatchAction(IWorkbenchSite site) {
Assert.isNotNull(site);
- fSite= site;
+ fSite = site;
}
/**
@@ -90,7 +89,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
*
* @return the site's shell
*/
- public Shell getShell() {
+ public Shell getShell() {
return fSite.getShell();
}
@@ -121,7 +120,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
* @param selection the new selection
*/
public void selectionChanged(IStructuredSelection selection) {
- selectionChanged((ISelection)selection);
+ selectionChanged((ISelection) selection);
}
/**
@@ -129,7 +128,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
* calls <code>run(ISelection selection)</code>.
*/
public void run(IStructuredSelection selection) {
- run((ISelection)selection);
+ run((ISelection) selection);
}
/**
@@ -139,7 +138,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
* @param selection the new selection
*/
public void selectionChanged(ITextSelection selection) {
- selectionChanged((ISelection)selection);
+ selectionChanged((ISelection) selection);
}
/**
@@ -147,7 +146,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
* calls <code>run(ISelection selection)</code>.
*/
public void run(ITextSelection selection) {
- run((ISelection)selection);
+ run((ISelection) selection);
}
/**
@@ -185,9 +184,9 @@ 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 ITextSelection) {
- selectionChanged((ITextSelection)selection);
+ selectionChanged((ITextSelection) selection);
} else {
selectionChanged(selection);
}
@@ -195,9 +194,9 @@ 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 ITextSelection) {
- run((ITextSelection)selection);
+ run((ITextSelection) selection);
} else {
run(selection);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
index 8941afb180f..609bf259fbd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
@@ -36,10 +36,10 @@ import org.eclipse.ui.texteditor.ITextEditor;
/**
* This class will open the C/C++ Projects view and highlight the
* selected resource matching the current resouce being edited in
- * the C/C++ Editor. It uses the IShowInSource/IShowInTarget to
+ * the C/C++ Editor. It uses the IShowInSource/IShowInTarget to
* accomplish this task so as to provide some additional portability
* and future proofing.
- *
+ *
* @deprecated Use generic IShowInTarget support instead.
*/
@Deprecated
@@ -52,17 +52,17 @@ public class ShowInCViewAction extends SelectionProviderAction {
this(site.getPage(), site.getSelectionProvider());
}
- public ShowInCViewAction(ITextEditor editor) {
+ public ShowInCViewAction(ITextEditor editor) {
this(editor.getEditorSite().getWorkbenchWindow().getActivePage(), editor.getSelectionProvider());
fEditor = editor;
}
public ShowInCViewAction(IWorkbenchPage page, ISelectionProvider viewer) {
- super(viewer, CEditorMessages.ShowInCView_label);
- setToolTipText(CEditorMessages.ShowInCView_tooltip);
- setDescription(CEditorMessages.ShowInCView_description);
+ super(viewer, CEditorMessages.ShowInCView_label);
+ setToolTipText(CEditorMessages.ShowInCView_tooltip);
+ setDescription(CEditorMessages.ShowInCView_description);
this.page = page;
- setDescription(CEditorMessages.ShowInCView_tooltip);
+ setDescription(CEditorMessages.ShowInCView_tooltip);
//WorkbenchHelp.setHelp(this, ICHelpContextIds.SHOW_IN_CVIEW_ACTION);
}
@@ -72,7 +72,7 @@ public class ShowInCViewAction extends SelectionProviderAction {
if (selection instanceof ITextSelection) {
run(fEditor);
} else if (selection instanceof IStructuredSelection) {
- run((IStructuredSelection)selection);
+ run((IStructuredSelection) selection);
}
}
@@ -91,7 +91,7 @@ public class ShowInCViewAction extends SelectionProviderAction {
if (part instanceof ISetSelectionTarget) {
((ISetSelectionTarget) part).selectReveal(selection);
}
- } catch(PartInitException ex) {
+ } catch (PartInitException ex) {
}
}
@@ -117,4 +117,3 @@ public class ShowInCViewAction extends SelectionProviderAction {
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java
index fa3adfb42ff..444bc5c4dc4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java
@@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog;
/**
*/
public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener {
-
+
private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
private boolean enabled = true;
private IWorkbenchWindow window;
@@ -63,7 +63,7 @@ public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, I
wsm.addPropertyChangeListener(this);
checkWS();
}
-
+
private void checkWS() {
enabled = false;
IWorkingSet[] w = wsm.getWorkingSets();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java
index 0ecfafd036f..8d468d7bad9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java
@@ -61,7 +61,7 @@ import org.eclipse.cdt.internal.ui.build.NewToolChainWizard;
/**
* Preference page to manage Toolchains for Core Build.
- *
+ *
* @since 6.3
*/
public class ToolChainPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
@@ -163,7 +163,7 @@ public class ToolChainPreferencePage extends PreferencePage implements IWorkbenc
if (i < 1) {
return;
}
-
+
IToolChain tc = toolChains.get(i - 1);
toolChains.set(i - 1, toolChains.get(i));
toolChains.set(i, tc);
@@ -265,7 +265,8 @@ public class ToolChainPreferencePage extends PreferencePage implements IWorkbenc
WizardDialog dialog = new WizardDialog(getShell(), wizard);
dialog.open();
} else {
- MessageDialog.openInformation(getShell(), CUIMessages.ToolChainPreferencePage_Edit, CUIMessages.ToolChainPreferencePage_NoEditor);
+ MessageDialog.openInformation(getShell(), CUIMessages.ToolChainPreferencePage_Edit,
+ CUIMessages.ToolChainPreferencePage_NoEditor);
}
}
});
@@ -354,7 +355,7 @@ public class ToolChainPreferencePage extends PreferencePage implements IWorkbenc
tableLayout.setColumnData(tableArchColumn, new ColumnWeightData(2));
tableComp.setLayout(tableLayout);
-
+
return new TableViewer(table);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java
index 154dffaa475..d99f894f91b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java
@@ -16,7 +16,7 @@ import org.eclipse.cdt.core.build.IToolChain;
/**
* Parent class for toolChain wizards that create or edit toolchains.
- *
+ *
* @since 6.3
*/
public abstract class ToolChainWizard extends Wizard {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.java
index e00fedc1907..9fc01e9cdf6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.java
@@ -72,7 +72,8 @@ public abstract class AbstractBinaryParserPage extends AbstractCOptionPage {
private void initializeParserPageMap() {
fParserPageMap = new HashMap<String, BinaryParserPageConfiguration>(5);
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ "BinaryParserPage"); //$NON-NLS-1$
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
for (int i = 0; i < infos.length; i++) {
if (infos[i].getName().equals("parserPage")) { //$NON-NLS-1$
@@ -96,6 +97,7 @@ public abstract class AbstractBinaryParserPage extends AbstractCOptionPage {
super.setVisible(visible);
handleBinaryParserChanged();
}
+
/**
* Notification that the user changed the selection of the Binary Parser.
*/
@@ -155,7 +157,7 @@ public abstract class AbstractBinaryParserPage extends AbstractCOptionPage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
@@ -163,7 +165,7 @@ public abstract class AbstractBinaryParserPage extends AbstractCOptionPage {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java
index 889ba3b97dd..fc4de807514 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java
@@ -30,7 +30,6 @@ public abstract class AbstractCOptionPage extends DialogPage implements ICOption
private boolean bIsValid = true;
private ICOptionContainer fContainer;
-
protected Button createPushButton(Composite parent, String label, Image image) {
Button button = new Button(parent, SWT.PUSH);
button.setFont(parent.getFont());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java
index 91fde7cc76f..4ef909f8af0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java
@@ -83,7 +83,7 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
@Deprecated
public AbstractErrorParserBlock(Preferences prefs) {
this();
-// usingDeprecatedConstructor = true;
+ // usingDeprecatedConstructor = true;
fPrefs = prefs;
}
@@ -267,14 +267,11 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.ERROR_PARSERS_PAGE);
- String[] buttonLabels = new String[]{
- CUIMessages.AbstractErrorParserBlock_label_up,
+ String[] buttonLabels = new String[] { CUIMessages.AbstractErrorParserBlock_label_up,
CUIMessages.AbstractErrorParserBlock_label_down,
/* 2 */
- null,
- CUIMessages.AbstractErrorParserBlock_label_selectAll,
- CUIMessages.AbstractErrorParserBlock_label_unselectAll
- };
+ null, CUIMessages.AbstractErrorParserBlock_label_selectAll,
+ CUIMessages.AbstractErrorParserBlock_label_unselectAll };
fErrorParserList = new CheckedListDialogField<String>(null, buttonLabels, getLabelProvider());
fErrorParserList.setDialogFieldListener(getFieldListenerAdapter());
@@ -284,7 +281,7 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
fErrorParserList.setCheckAllButtonIndex(3);
fErrorParserList.setUncheckAllButtonIndex(4);
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fErrorParserList}, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fErrorParserList }, true);
LayoutUtil.setHorizontalGrabbing(fErrorParserList.getListControl(null), true);
initializeValues();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java
index 23afd5a3ffe..25c8df75293 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java
@@ -111,7 +111,8 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage {
private void initializeParserId() {
if (parserID == null) {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ "BinaryParserPage"); //$NON-NLS-1$
IConfigurationElement[] infos = point.getConfigurationElements();
for (int i = 0; i < infos.length; i++) {
String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$
@@ -122,7 +123,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage {
return;
}
}
- parserID = ""; //$NON-NLS-1$
+ parserID = ""; //$NON-NLS-1$
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java
index 41a7a02bb65..aef3bab8767 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java
@@ -62,14 +62,14 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
private Button fIndexAllHeaderVersions;
private Text fIndexAllVersionsSpecificHeaders;
- private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() {
- @Override
+ private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() {
+ @Override
public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+ if (event.getProperty().equals(FieldEditor.IS_VALID)) {
updateValidState();
}
- }
- };
+ }
+ };
/** @since 5.3 */
protected PixelConverter pixelConverter;
@@ -87,31 +87,32 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
@Override
public void createControl(Composite parent) {
- pixelConverter = new PixelConverter(parent);
+ pixelConverter = new PixelConverter(parent);
GridLayout gl;
Composite page = new Composite(parent, SWT.NULL);
page.setFont(parent.getFont());
- page.setLayout(gl= new GridLayout(1, true));
+ page.setLayout(gl = new GridLayout(1, true));
gl.marginHeight = 0;
gl.marginWidth = 0;
page.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Composite group= new Composite(page, SWT.NONE);
- group.setLayout(gl= new GridLayout(3, false));
+ Composite group = new Composite(page, SWT.NONE);
+ group.setLayout(gl = new GridLayout(3, false));
gl.marginHeight = 0;
- gl.marginWidth= 0;
+ gl.marginWidth = 0;
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fAllSources= createAllFilesButton(group);
- IProject prj= getCurrentProject();
+ fAllSources = createAllFilesButton(group);
+ IProject prj = getCurrentProject();
if (prj == null || !CProject.hasCCNature(prj)) {
- fAllHeadersDefault= createAllHeadersButton(group);
+ fAllHeadersDefault = createAllHeadersButton(group);
} else {
- fAllHeadersDefault= createAllCppHeadersButton(group);
- fAllHeadersAlt= createAllCHeadersButton(group);
+ fAllHeadersDefault = createAllCppHeadersButton(group);
+ fAllHeadersAlt = createAllCHeadersButton(group);
}
- fIndexAllHeaderVersions = ControlFactory.createCheckBox(group, DialogsMessages.AbstractIndexerPage_indexAllHeaderVersions);
+ fIndexAllHeaderVersions = ControlFactory.createCheckBox(group,
+ DialogsMessages.AbstractIndexerPage_indexAllHeaderVersions);
fIndexAllHeaderVersions.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -119,7 +120,8 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
}
});
- Label label = ControlFactory.createLabel(group, DialogsMessages.AbstractIndexerPage_indexAllVersionsSpecificHeaders);
+ Label label = ControlFactory.createLabel(group,
+ DialogsMessages.AbstractIndexerPage_indexAllVersionsSpecificHeaders);
int indent = pixelConverter.convertHorizontalDLUsToPixels(12);
GridData layoutData = new GridData();
layoutData.horizontalSpan = 3;
@@ -131,29 +133,29 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
layoutData.horizontalIndent = indent;
fIndexAllVersionsSpecificHeaders.setLayoutData(layoutData);
- fIndexOnOpen= createIndexOnOpenButton(group);
+ fIndexOnOpen = createIndexOnOpenButton(group);
- fIncludeHeuristics= createIncludeHeuristicsButton(group);
+ fIncludeHeuristics = createIncludeHeuristicsButton(group);
- group= new Composite(page, SWT.NONE);
- fFileSizeLimit= createFileSizeLimit(group, IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB,
+ group = new Composite(page, SWT.NONE);
+ fFileSizeLimit = createFileSizeLimit(group, IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB,
DialogsMessages.AbstractIndexerPage_fileSizeLimit);
- fIncludedFileSizeLimit= createFileSizeLimit(group, IndexerPreferences.KEY_SKIP_INCLUDED_FILES_LARGER_THAN_MB,
+ fIncludedFileSizeLimit = createFileSizeLimit(group, IndexerPreferences.KEY_SKIP_INCLUDED_FILES_LARGER_THAN_MB,
DialogsMessages.AbstractIndexerPage_includedFileSizeLimit);
- group.setLayout(gl= new GridLayout(3, false));
+ group.setLayout(gl = new GridLayout(3, false));
gl.marginHeight = 0;
- gl.marginWidth= 0;
+ gl.marginWidth = 0;
group.setLayoutData(new GridData());
- group= new Composite(page, SWT.NONE);
- group.setLayout(gl= new GridLayout(1, false));
+ group = new Composite(page, SWT.NONE);
+ group.setLayout(gl = new GridLayout(1, false));
gl.marginHeight = 0;
- gl.marginWidth= 0;
+ gl.marginWidth = 0;
group.setLayoutData(new GridData());
- fSkipReferences= createSkipReferencesButton(group);
- fSkipImplicitReferences= createSkipImplicitReferencesButton(group);
- fSkipMacroAndTypeReferences= createSkipMacroAndTypeReferencesButton(group);
-
+ fSkipReferences = createSkipReferencesButton(group);
+ fSkipImplicitReferences = createSkipImplicitReferencesButton(group);
+ fSkipMacroAndTypeReferences = createSkipMacroAndTypeReferencesButton(group);
+
final SelectionAdapter selectionListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -166,79 +168,84 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
}
/**
- * Use the properties to initialize the controls of the page. Fill in defaults
+ * Use the properties to initialize the controls of the page. Fill in defaults
* for properties that are missing.
* @since 4.0
*/
public void setProperties(Properties properties) {
if (fAllSources != null) {
- boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
+ boolean indexAllFiles = TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
fAllSources.setSelection(indexAllFiles);
}
if (fAllHeadersDefault != null) {
- boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG));
+ boolean indexAllFiles = TRUE
+ .equals(properties.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG));
fAllHeadersDefault.setSelection(indexAllFiles);
}
if (fAllHeadersAlt != null) {
- boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG));
+ boolean indexAllFiles = TRUE
+ .equals(properties.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG));
fAllHeadersAlt.setSelection(indexAllFiles);
}
if (fIndexOnOpen != null) {
- boolean indexOnOpen= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ON_OPEN));
+ boolean indexOnOpen = TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ON_OPEN));
fIndexOnOpen.setSelection(indexOnOpen);
}
if (fIncludeHeuristics != null) {
- Object prop= properties.get(IndexerPreferences.KEY_INCLUDE_HEURISTICS);
- boolean use= prop == null || TRUE.equals(prop);
+ Object prop = properties.get(IndexerPreferences.KEY_INCLUDE_HEURISTICS);
+ boolean use = prop == null || TRUE.equals(prop);
fIncludeHeuristics.setSelection(use);
}
if (fFileSizeLimit != null) {
- Object prop= properties.get(IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB);
- int size= 0;
+ Object prop = properties.get(IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB);
+ int size = 0;
if (prop != null) {
try {
- size= Integer.parseInt(prop.toString());
+ size = Integer.parseInt(prop.toString());
} catch (NumberFormatException e) {
}
}
if (size <= 0) {
- size= IndexerPreferences.DEFAULT_FILE_SIZE_LIMIT_MB;
+ size = IndexerPreferences.DEFAULT_FILE_SIZE_LIMIT_MB;
}
fFileSizeLimit.setStringValue(String.valueOf(size));
}
if (fIncludedFileSizeLimit != null) {
- Object prop= properties.get(IndexerPreferences.KEY_SKIP_INCLUDED_FILES_LARGER_THAN_MB);
- int size= 0;
+ Object prop = properties.get(IndexerPreferences.KEY_SKIP_INCLUDED_FILES_LARGER_THAN_MB);
+ int size = 0;
if (prop != null) {
try {
- size= Integer.parseInt(prop.toString());
+ size = Integer.parseInt(prop.toString());
} catch (NumberFormatException e) {
}
}
if (size <= 0) {
- size= IndexerPreferences.DEFAULT_INCLUDED_FILE_SIZE_LIMIT_MB;
+ size = IndexerPreferences.DEFAULT_INCLUDED_FILE_SIZE_LIMIT_MB;
}
fIncludedFileSizeLimit.setStringValue(String.valueOf(size));
}
if (fSkipReferences != null) {
- boolean skipReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_ALL_REFERENCES));
+ boolean skipReferences = TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_ALL_REFERENCES));
fSkipReferences.setSelection(skipReferences);
}
if (fSkipImplicitReferences != null) {
- boolean skipImplicitReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES));
+ boolean skipImplicitReferences = TRUE
+ .equals(properties.get(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES));
fSkipImplicitReferences.setSelection(skipImplicitReferences);
- }
+ }
if (fSkipMacroAndTypeReferences != null) {
- boolean skipTypeReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES));
- boolean skipMacroReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES));
+ boolean skipTypeReferences = TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES));
+ boolean skipMacroReferences = TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES));
fSkipMacroAndTypeReferences.setSelection(skipTypeReferences && skipMacroReferences);
}
if (fIndexAllHeaderVersions != null) {
- boolean indexAllHeaderVersions = TRUE.equals(properties.get((IndexerPreferences.KEY_INDEX_ALL_HEADER_VERSIONS)));
+ boolean indexAllHeaderVersions = TRUE
+ .equals(properties.get((IndexerPreferences.KEY_INDEX_ALL_HEADER_VERSIONS)));
fIndexAllHeaderVersions.setSelection(indexAllHeaderVersions);
}
if (fIndexAllVersionsSpecificHeaders != null) {
- String indexAllVersionsSpecificHeaders = properties.getProperty((IndexerPreferences.KEY_INDEX_ALL_VERSIONS_SPECIFIC_HEADERS), ""); //$NON-NLS-1$
+ String indexAllVersionsSpecificHeaders = properties
+ .getProperty((IndexerPreferences.KEY_INDEX_ALL_VERSIONS_SPECIFIC_HEADERS), ""); //$NON-NLS-1$
fIndexAllVersionsSpecificHeaders.setText(indexAllVersionsSpecificHeaders);
}
updateEnablement();
@@ -248,16 +255,18 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
* Return the properties according to the selections on the page.
* @since 4.0
*/
- public Properties getProperties(){
- Properties props= new Properties();
+ public Properties getProperties() {
+ Properties props = new Properties();
if (fAllSources != null) {
props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllSources.getSelection()));
}
if (fAllHeadersDefault != null) {
- props.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, String.valueOf(fAllHeadersDefault.getSelection()));
+ props.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ String.valueOf(fAllHeadersDefault.getSelection()));
}
if (fAllHeadersAlt != null) {
- props.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG, String.valueOf(fAllHeadersAlt.getSelection()));
+ props.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG,
+ String.valueOf(fAllHeadersAlt.getSelection()));
}
if (fIndexOnOpen != null) {
props.put(IndexerPreferences.KEY_INDEX_ON_OPEN, String.valueOf(fIndexOnOpen.getSelection()));
@@ -269,13 +278,15 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
props.put(IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB, String.valueOf(fFileSizeLimit.getIntValue()));
}
if (fIncludedFileSizeLimit != null) {
- props.put(IndexerPreferences.KEY_SKIP_INCLUDED_FILES_LARGER_THAN_MB, String.valueOf(fIncludedFileSizeLimit.getIntValue()));
+ props.put(IndexerPreferences.KEY_SKIP_INCLUDED_FILES_LARGER_THAN_MB,
+ String.valueOf(fIncludedFileSizeLimit.getIntValue()));
}
if (fSkipReferences != null) {
props.put(IndexerPreferences.KEY_SKIP_ALL_REFERENCES, String.valueOf(fSkipReferences.getSelection()));
}
if (fSkipImplicitReferences != null) {
- props.put(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES, String.valueOf(fSkipImplicitReferences.getSelection()));
+ props.put(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES,
+ String.valueOf(fSkipImplicitReferences.getSelection()));
}
if (fSkipMacroAndTypeReferences != null) {
final String value = String.valueOf(fSkipMacroAndTypeReferences.getSelection());
@@ -283,7 +294,8 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
props.put(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES, value);
}
if (fIndexAllHeaderVersions != null) {
- props.put((IndexerPreferences.KEY_INDEX_ALL_HEADER_VERSIONS), String.valueOf(fIndexAllHeaderVersions.getSelection()));
+ props.put((IndexerPreferences.KEY_INDEX_ALL_HEADER_VERSIONS),
+ String.valueOf(fIndexAllHeaderVersions.getSelection()));
}
if (fIndexAllVersionsSpecificHeaders != null) {
String[] headers = fIndexAllVersionsSpecificHeaders.getText().split(","); //$NON-NLS-1$
@@ -335,66 +347,66 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
fIndexAllVersionsSpecificHeaders.setEnabled(!fIndexAllHeaderVersions.getSelection());
}
}
-
- private void updateValidState() {
- if (!fFileSizeLimit.isValid()) {
- setErrorMessage(fFileSizeLimit.getErrorMessage());
- setValid(false);
- } else if (!fIncludedFileSizeLimit.isValid()) {
- setErrorMessage(fIncludedFileSizeLimit.getErrorMessage());
- setValid(false);
+
+ private void updateValidState() {
+ if (!fFileSizeLimit.isValid()) {
+ setErrorMessage(fFileSizeLimit.getErrorMessage());
+ setValid(false);
+ } else if (!fIncludedFileSizeLimit.isValid()) {
+ setErrorMessage(fIncludedFileSizeLimit.getErrorMessage());
+ setValid(false);
} else {
- setValid(true);
- }
- final ICOptionContainer container = getContainer();
- if (container != null) {
- container.updateContainer();
- }
- }
-
+ setValid(true);
+ }
+ final ICOptionContainer container = getContainer();
+ if (container != null) {
+ container.updateContainer();
+ }
+ }
+
private Button createAllFilesButton(Composite page) {
- Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllFiles);
- ((GridData) result.getLayoutData()).horizontalSpan= 3;
+ Button result = ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllFiles);
+ ((GridData) result.getLayoutData()).horizontalSpan = 3;
return result;
}
private Button createAllHeadersButton(Composite page) {
- Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeaders);
- ((GridData) result.getLayoutData()).horizontalSpan= 3;
+ Button result = ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeaders);
+ ((GridData) result.getLayoutData()).horizontalSpan = 3;
return result;
}
private Button createAllCHeadersButton(Composite page) {
- Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeadersC);
- ((GridData) result.getLayoutData()).horizontalSpan= 3;
+ Button result = ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeadersC);
+ ((GridData) result.getLayoutData()).horizontalSpan = 3;
return result;
}
private Button createAllCppHeadersButton(Composite page) {
- Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeadersCpp);
- ((GridData) result.getLayoutData()).horizontalSpan= 3;
+ Button result = ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeadersCpp);
+ ((GridData) result.getLayoutData()).horizontalSpan = 3;
return result;
}
private Button createIndexOnOpenButton(Composite page) {
- Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexOpenedFiles);
- ((GridData) result.getLayoutData()).horizontalSpan= 3;
+ Button result = ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexOpenedFiles);
+ ((GridData) result.getLayoutData()).horizontalSpan = 3;
return result;
}
private Button createIncludeHeuristicsButton(Composite page) {
- Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_heuristicIncludes);
- ((GridData) result.getLayoutData()).horizontalSpan= 3;
+ Button result = ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_heuristicIncludes);
+ ((GridData) result.getLayoutData()).horizontalSpan = 3;
return result;
}
-
+
private IntegerFieldEditor createFileSizeLimit(Composite group, String key, String label) {
- IntegerFieldEditor result= new IntegerFieldEditor(key, label, group, 5);
+ IntegerFieldEditor result = new IntegerFieldEditor(key, label, group, 5);
result.setValidRange(1, 100000);
- ControlFactory.createLabel(group, DialogsMessages.Megabyte);
+ ControlFactory.createLabel(group, DialogsMessages.Megabyte);
Text control = result.getTextControl(group);
LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10));
- LayoutUtil.setHorizontalGrabbing(control, false);
+ LayoutUtil.setHorizontalGrabbing(control, false);
result.setPropertyChangeListener(validityChangeListener);
return result;
@@ -411,11 +423,11 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
private Button createSkipMacroAndTypeReferencesButton(Composite page) {
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipTypeAndMacroReferences);
}
-
+
/**
* @deprecated parsing files up-front is no longer necessary.
*/
@Deprecated
- protected void setSupportForFilesParsedUpFront(boolean enable){
+ protected void setSupportForFilesParsedUpFront(boolean enable) {
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java
index eb84f3495e9..7027adc2822 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java
@@ -115,9 +115,8 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
public BinaryParserBlock() {
super(CUIPlugin.getResourceString(LABEL));
setDescription(CUIPlugin.getResourceString(DESC));
- String[] buttonLabels = new String[]{
- CUIMessages.BinaryParserBlock_button_up,
- CUIMessages.BinaryParserBlock_button_down};
+ String[] buttonLabels = new String[] { CUIMessages.BinaryParserBlock_button_up,
+ CUIMessages.BinaryParserBlock_button_down };
IListAdapter<BinaryParserConfiguration> listAdapter = new IListAdapter<BinaryParserConfiguration>() {
@@ -135,7 +134,8 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
}
};
- binaryList = new CheckedListDialogField<BinaryParserConfiguration>(listAdapter, buttonLabels, new BinaryParserLabelProvider()) {
+ binaryList = new CheckedListDialogField<BinaryParserConfiguration>(listAdapter, buttonLabels,
+ new BinaryParserLabelProvider()) {
@Override
protected int getListStyle() {
@@ -160,7 +160,8 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
}
private void initializeParserList() {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
+ CCorePlugin.BINARY_PARSER_SIMPLE_ID);
if (point != null) {
IExtension[] exts = point.getExtensions();
configMap = new HashMap<String, BinaryParserConfiguration>(exts.length);
@@ -173,7 +174,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
}
private boolean isExtensionVisible(IExtension ext) {
- IConfigurationElement[] elements = ext.getConfigurationElements();
+ IConfigurationElement[] elements = ext.getConfigurationElements();
for (IConfigurationElement element : elements) {
IConfigurationElement[] children = element.getChildren(ATTR_FILTER);
for (IConfigurationElement element2 : children) {
@@ -201,7 +202,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.BINARY_PARSER_PAGE);
Composite listComposite = ControlFactory.createComposite(composite, 1);
- LayoutUtil.doDefaultLayout(listComposite, new DialogField[]{binaryList}, true);
+ LayoutUtil.doDefaultLayout(listComposite, new DialogField[] { binaryList }, true);
LayoutUtil.setHorizontalGrabbing(binaryList.getListControl(null), true);
int buttonBarWidth = converter.convertWidthInCharsToPixels(15);
@@ -245,8 +246,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
if (initialSelected == null || !selected.equals(initialSelected)) {
descriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
for (int i = 0; i < selected.size(); i++) {
- descriptor.create(CCorePlugin.BINARY_PARSER_UNIQ_ID,
- selected.get(i).getID());
+ descriptor.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, selected.get(i).getID());
}
}
monitor.worked(1);
@@ -262,7 +262,8 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
}
}
};
- CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(getContainer().getProject(), op, monitor);
+ CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(getContainer().getProject(), op,
+ monitor);
} else {
if (initialSelected == null || !selected.equals(initialSelected)) {
Preferences store = getContainer().getPreferences();
@@ -291,7 +292,8 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
if (getContainer().getProject() != null) {
try {
- ICConfigExtensionReference[] ref = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(getContainer().getProject());
+ ICConfigExtensionReference[] ref = CCorePlugin.getDefault()
+ .getDefaultBinaryParserExtensions(getContainer().getProject());
initialSelected = new ArrayList<BinaryParserConfiguration>(ref.length);
for (ICConfigExtensionReference element : ref) {
if (configMap.get(element.getID()) != null) {
@@ -301,7 +303,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
}
} catch (CoreException e) {
}
- for (Entry<String, BinaryParserConfiguration> entry: configMap.entrySet()) {
+ for (Entry<String, BinaryParserConfiguration> entry : configMap.entrySet()) {
if (!elements.contains(entry.getValue())) {
elements.add(entry.getValue());
}
@@ -327,7 +329,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
}
}
}
- for (Entry<String, BinaryParserConfiguration> entry: configMap.entrySet()) {
+ for (Entry<String, BinaryParserConfiguration> entry : configMap.entrySet()) {
if (!elements.contains(entry.getValue())) {
elements.add(entry.getValue());
}
@@ -340,6 +342,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
initialSelected = null;
}
}
+
private String arrayToString(Object[] array) {
StringBuilder buf = new StringBuilder();
for (Object element : array) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java
index 828bb5dcee3..7515af32fff 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java
@@ -51,8 +51,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
* @since 2.1
* @noextend This class is not intended to be subclassed by clients.
*/
-public class CHelpConfigurationPropertyPage extends PropertyPage implements
- IWorkbenchPreferencePage {
+public class CHelpConfigurationPropertyPage extends PropertyPage implements IWorkbenchPreferencePage {
private CHelpSettingsDisplay fCHelpSettingsDisplay;
private class CHelpBookListLabelProvider extends LabelProvider {
@@ -60,14 +59,14 @@ public class CHelpConfigurationPropertyPage extends PropertyPage implements
private ImageDescriptorRegistry fRegistry;
public CHelpBookListLabelProvider() {
- fRegistry= CUIPlugin.getImageDescriptorRegistry();
- fHelpProviderIcon= CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY);
+ fRegistry = CUIPlugin.getImageDescriptorRegistry();
+ fHelpProviderIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY);
}
@Override
public String getText(Object element) {
if (element instanceof CHelpBookDescriptor) {
- return ((CHelpBookDescriptor)element).getCHelpBook().getTitle();
+ return ((CHelpBookDescriptor) element).getCHelpBook().getTitle();
}
return super.getText(element);
}
@@ -88,45 +87,50 @@ public class CHelpConfigurationPropertyPage extends PropertyPage implements
public CHelpSettingsDisplay() {
- String[] buttonLabels= new String[] {
- /* 0 */ CUIMessages.CHelpConfigurationPropertyPage_buttonLabels_CheckAll,
- /* 1 */ CUIMessages.CHelpConfigurationPropertyPage_buttonLabels_UncheckAll
- };
+ String[] buttonLabels = new String[] {
+ /* 0 */ CUIMessages.CHelpConfigurationPropertyPage_buttonLabels_CheckAll,
+ /* 1 */ CUIMessages.CHelpConfigurationPropertyPage_buttonLabels_UncheckAll };
- fCHelpBookList= new CheckedListDialogField<CHelpBookDescriptor>(null, buttonLabels, new CHelpBookListLabelProvider());
+ fCHelpBookList = new CheckedListDialogField<CHelpBookDescriptor>(null, buttonLabels,
+ new CHelpBookListLabelProvider());
fCHelpBookList.setLabelText(CUIMessages.CHelpConfigurationPropertyPage_HelpBooks);
fCHelpBookList.setCheckAllButtonIndex(0);
fCHelpBookList.setUncheckAllButtonIndex(1);
}
- public Control createControl(Composite parent){
- PixelConverter converter= new PixelConverter(parent);
+ public Control createControl(Composite parent) {
+ PixelConverter converter = new PixelConverter(parent);
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
LayoutUtil.doDefaultLayout(composite, new DialogField[] { fCHelpBookList }, true);
LayoutUtil.setHorizontalGrabbing(fCHelpBookList.getListControl(null), true);
- int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
+ int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
fCHelpBookList.setButtonsMinWidth(buttonBarWidth);
return composite;
}
public void init(final IResource resource) {
- if(!(resource instanceof IProject))
+ if (!(resource instanceof IProject))
return;
- fProject = (IProject)resource;
- fCHelpBookDescriptors = CHelpProviderManager.getDefault().getCHelpBookDescriptors(new ICHelpInvocationContext(){
- @Override
- public IProject getProject(){return (IProject)resource;}
- @Override
- public ITranslationUnit getTranslationUnit(){return null;}
- }
- );
-
- List<CHelpBookDescriptor> allTopicsList= Arrays.asList(fCHelpBookDescriptors);
- List<CHelpBookDescriptor> enabledTopicsList= getEnabledEntries(allTopicsList);
+ fProject = (IProject) resource;
+ fCHelpBookDescriptors = CHelpProviderManager.getDefault()
+ .getCHelpBookDescriptors(new ICHelpInvocationContext() {
+ @Override
+ public IProject getProject() {
+ return (IProject) resource;
+ }
+
+ @Override
+ public ITranslationUnit getTranslationUnit() {
+ return null;
+ }
+ });
+
+ List<CHelpBookDescriptor> allTopicsList = Arrays.asList(fCHelpBookDescriptors);
+ List<CHelpBookDescriptor> enabledTopicsList = getEnabledEntries(allTopicsList);
fCHelpBookList.setElements(allTopicsList);
fCHelpBookList.setCheckedElements(enabledTopicsList);
@@ -134,32 +138,37 @@ public class CHelpConfigurationPropertyPage extends PropertyPage implements
private List<CHelpBookDescriptor> getEnabledEntries(List<CHelpBookDescriptor> list) {
int size = list.size();
- List<CHelpBookDescriptor> desList= new ArrayList<CHelpBookDescriptor>();
+ List<CHelpBookDescriptor> desList = new ArrayList<CHelpBookDescriptor>();
- for (int i= 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
CHelpBookDescriptor el = list.get(i);
- if(el.isEnabled())
+ if (el.isEnabled())
desList.add(el);
}
return desList;
}
- public void performOk(){
+ public void performOk() {
List<CHelpBookDescriptor> list = fCHelpBookList.getElements();
final IProject project = fProject;
- for(int i = 0; i < list.size(); i++){
+ for (int i = 0; i < list.size(); i++) {
Object obj = list.get(i);
- if(obj != null && obj instanceof CHelpBookDescriptor){
- ((CHelpBookDescriptor)obj).enable(fCHelpBookList.isChecked(obj));
+ if (obj != null && obj instanceof CHelpBookDescriptor) {
+ ((CHelpBookDescriptor) obj).enable(fCHelpBookList.isChecked(obj));
}
}
- CHelpProviderManager.getDefault().serialize(new ICHelpInvocationContext(){
+ CHelpProviderManager.getDefault().serialize(new ICHelpInvocationContext() {
@Override
- public IProject getProject(){return project;}
+ public IProject getProject() {
+ return project;
+ }
+
@Override
- public ITranslationUnit getTranslationUnit(){return null;}
- });
+ public ITranslationUnit getTranslationUnit() {
+ return null;
+ }
+ });
}
}
@@ -168,15 +177,15 @@ public class CHelpConfigurationPropertyPage extends PropertyPage implements
*/
@Override
protected Control createContents(Composite parent) {
- fCHelpSettingsDisplay= new CHelpSettingsDisplay();
+ fCHelpSettingsDisplay = new CHelpSettingsDisplay();
fCHelpSettingsDisplay.init(getResource());
return fCHelpSettingsDisplay.createControl(parent);
}
private IResource getResource() {
- IAdaptable element= getElement();
+ IAdaptable element = getElement();
if (element instanceof IResource) {
- return (IResource)element;
+ return (IResource) element;
}
return element.getAdapter(IResource.class);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java
index 09e0cd70006..dfec1710ade 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java
@@ -46,86 +46,88 @@ public class CacheSizeBlock extends AbstractCOptionPage {
private IntegerFieldEditor fDBLimitPct;
private IntegerFieldEditor fDBAbsoluteLimit;
- private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() {
- @Override
+ private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() {
+ @Override
public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+ if (event.getProperty().equals(FieldEditor.IS_VALID)) {
updateValidState();
}
- }
- };
+ }
+ };
- public CacheSizeBlock(ICOptionContainer container){
- setContainer(container);
- }
+ public CacheSizeBlock(ICOptionContainer container) {
+ setContainer(container);
+ }
- @Override
+ @Override
public void createControl(Composite parent) {
- PixelConverter pixelConverter = new PixelConverter(parent);
- GridData gd;
- GridLayout gl;
- Composite composite = ControlFactory.createComposite(parent, 1);
- gl= (GridLayout)composite.getLayout();
- gl.marginWidth= 0;
+ PixelConverter pixelConverter = new PixelConverter(parent);
+ GridData gd;
+ GridLayout gl;
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ gl = (GridLayout) composite.getLayout();
+ gl.marginWidth = 0;
- gd= (GridData) composite.getLayoutData();
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalAlignment= GridData.FILL;
+ gd = (GridData) composite.getLayoutData();
+ gd.grabExcessHorizontalSpace = false;
+ gd.horizontalAlignment = GridData.FILL;
setControl(composite);
- Group group= ControlFactory.createGroup(composite, DialogsMessages.CacheSizeBlock_cacheLimitGroup, 1);
- gd= (GridData) group.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
- gd.horizontalAlignment= GridData.FILL;
+ Group group = ControlFactory.createGroup(composite, DialogsMessages.CacheSizeBlock_cacheLimitGroup, 1);
+ gd = (GridData) group.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
- Composite cacheComp= ControlFactory.createComposite(group, 3);
+ Composite cacheComp = ControlFactory.createComposite(group, 3);
- Label dbCacheLabel= ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_indexDatabaseCache);
- fDBLimitPct= new IntegerFieldEditor(CCorePreferenceConstants.INDEX_DB_CACHE_SIZE_PCT, DialogsMessages.CacheSizeBlock_limitRelativeToMaxHeapSize, cacheComp, 3);
+ Label dbCacheLabel = ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_indexDatabaseCache);
+ fDBLimitPct = new IntegerFieldEditor(CCorePreferenceConstants.INDEX_DB_CACHE_SIZE_PCT,
+ DialogsMessages.CacheSizeBlock_limitRelativeToMaxHeapSize, cacheComp, 3);
fDBLimitPct.setValidRange(1, 75);
Text control = fDBLimitPct.getTextControl(cacheComp);
LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10));
LayoutUtil.setHorizontalGrabbing(control, false);
ControlFactory.createLabel(cacheComp, "%"); //$NON-NLS-1$
- fDBAbsoluteLimit= new IntegerFieldEditor(CCorePreferenceConstants.MAX_INDEX_DB_CACHE_SIZE_MB, DialogsMessages.CacheSizeBlock_absoluteLimit, cacheComp, 4);
+ fDBAbsoluteLimit = new IntegerFieldEditor(CCorePreferenceConstants.MAX_INDEX_DB_CACHE_SIZE_MB,
+ DialogsMessages.CacheSizeBlock_absoluteLimit, cacheComp, 4);
fDBAbsoluteLimit.setValidRange(1, 10000);
control = fDBAbsoluteLimit.getTextControl(cacheComp);
LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10));
LayoutUtil.setHorizontalGrabbing(control, false);
ControlFactory.createLabel(cacheComp, DialogsMessages.Megabyte);
- gl= (GridLayout) cacheComp.getLayout();
- gl.numColumns= 3;
- gl.makeColumnsEqualWidth= false;
- gl.marginLeft= 0;
- gl.verticalSpacing= 2;
+ gl = (GridLayout) cacheComp.getLayout();
+ gl.numColumns = 3;
+ gl.makeColumnsEqualWidth = false;
+ gl.marginLeft = 0;
+ gl.verticalSpacing = 2;
- gd= (GridData) dbCacheLabel.getLayoutData();
- gd.horizontalSpan= 3;
+ gd = (GridData) dbCacheLabel.getLayoutData();
+ gd.horizontalSpan = 3;
- int hindent= pixelConverter.convertWidthInCharsToPixels(2);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.horizontalIndent= hindent;
+ int hindent = pixelConverter.convertWidthInCharsToPixels(2);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.horizontalIndent = hindent;
fDBLimitPct.getLabelControl(cacheComp).setLayoutData(gd);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.horizontalIndent= hindent;
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.horizontalIndent = hindent;
fDBAbsoluteLimit.getLabelControl(cacheComp).setLayoutData(gd);
initializeValues();
- }
+ }
- private void initializeValues() {
- IPreferenceStore prefStore= CUIPlugin.getDefault().getCorePreferenceStore();
+ private void initializeValues() {
+ IPreferenceStore prefStore = CUIPlugin.getDefault().getCorePreferenceStore();
- fDBLimitPct.setPreferenceStore(prefStore);
- fDBLimitPct.setPropertyChangeListener(validityChangeListener);
- fDBAbsoluteLimit.setPreferenceStore(prefStore);
- fDBAbsoluteLimit.setPropertyChangeListener(validityChangeListener);
+ fDBLimitPct.setPreferenceStore(prefStore);
+ fDBLimitPct.setPropertyChangeListener(validityChangeListener);
+ fDBAbsoluteLimit.setPreferenceStore(prefStore);
+ fDBAbsoluteLimit.setPropertyChangeListener(validityChangeListener);
fDBLimitPct.load();
fDBAbsoluteLimit.load();
@@ -135,24 +137,24 @@ public class CacheSizeBlock extends AbstractCOptionPage {
public void performApply(IProgressMonitor monitor) throws CoreException {
fDBLimitPct.store();
fDBAbsoluteLimit.store();
- }
+ }
- @Override
+ @Override
public void performDefaults() {
- fDBLimitPct.loadDefault();
+ fDBLimitPct.loadDefault();
fDBAbsoluteLimit.loadDefault();
- }
-
- private void updateValidState() {
- if (!fDBLimitPct.isValid()) {
- setErrorMessage(fDBLimitPct.getErrorMessage());
- setValid(false);
- } else if (!fDBAbsoluteLimit.isValid()) {
- setErrorMessage(fDBAbsoluteLimit.getErrorMessage());
- setValid(false);
- } else {
- setValid(true);
- }
- getContainer().updateContainer();
- }
+ }
+
+ private void updateValidState() {
+ if (!fDBLimitPct.isValid()) {
+ setErrorMessage(fDBLimitPct.getErrorMessage());
+ setValid(false);
+ } else if (!fDBAbsoluteLimit.isValid()) {
+ setErrorMessage(fDBAbsoluteLimit.getErrorMessage());
+ setValid(false);
+ } else {
+ setValid(true);
+ }
+ getContainer().updateContainer();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java
index 2b8d1c936f1..61b95fe65f1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java
@@ -91,7 +91,8 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
}
}
if (cext != null && cext.length > 0) {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ "BinaryParserPage"); //$NON-NLS-1$
IConfigurationElement[] infos = point.getConfigurationElements();
for (int i = 0; i < infos.length; i++) {
String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$
@@ -300,7 +301,6 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
}
});
-
label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_nmCommand);
gd = new GridData();
gd.horizontalSpan = 2;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
index 04ca44f41d2..e77f0e076bc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
@@ -15,7 +15,6 @@
package org.eclipse.cdt.ui.dialogs;
-
/**
* @noextend This class is not intended to be subclassed by clients.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
index c893aa18050..090ab133387 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
@@ -48,7 +48,7 @@ class DialogsMessages extends NLS {
public static String CacheSizeBlock_headerFileCache;
public static String CacheSizeBlock_indexDatabaseCache;
public static String CacheSizeBlock_limitRelativeToMaxHeapSize;
-
+
public static String DocCommentOwnerBlock_DocToolLabel;
public static String DocCommentOwnerBlock_EnableProjectSpecificSettings;
public static String DocCommentOwnerBlock_SelectDocToolDescription;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java
index 5319e20cdec..b2cdcb24cd2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java
@@ -35,85 +35,86 @@ import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
/**
* Project property page for setting documentation comment owner.
* <em>This class is not intended for use outside of CDT</em>
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class DocCommentOwnerBlock extends AbstractCOptionPage {
- private static String EDITOR_PREF_PAGE_ID= "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$
-
+ private static String EDITOR_PREF_PAGE_ID = "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$
+
protected DocCommentOwnerComposite fDocComboComposite;
protected DocCommentOwnerManager fManager;
-
+
protected Button fCheckbox;
protected Link fLink;
-
+
public DocCommentOwnerBlock() {
- fManager= DocCommentOwnerManager.getInstance();
+ fManager = DocCommentOwnerManager.getInstance();
}
-
+
void handleCheckBox() {
fDocComboComposite.setEnabled(fCheckbox.getSelection());
fLink.setVisible(!fCheckbox.getSelection());
}
-
+
@Override
public void createControl(final Composite parent) {
- Composite pane= new Composite(parent, SWT.NONE);
+ Composite pane = new Composite(parent, SWT.NONE);
pane.setLayout(new GridLayout(2, true));
- pane.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).span(2, 1).create());
-
+ pane.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
+
setControl(pane);
-
- fCheckbox= ControlFactory.createCheckBox(pane, DialogsMessages.DocCommentOwnerBlock_EnableProjectSpecificSettings);
- fCheckbox.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).create());
- fCheckbox.addSelectionListener(new SelectionAdapter(){
+
+ fCheckbox = ControlFactory.createCheckBox(pane,
+ DialogsMessages.DocCommentOwnerBlock_EnableProjectSpecificSettings);
+ fCheckbox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
+ fCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleCheckBox();
}
});
-
- fLink= new Link(pane, SWT.NONE);
+
+ fLink = new Link(pane, SWT.NONE);
fLink.setText(DialogsMessages.PreferenceScopeBlock_preferenceLink);
- fLink.setLayoutData(GridDataFactory.fillDefaults().align(GridData.CENTER, GridData.BEGINNING).grab(true,false).create());
+ fLink.setLayoutData(
+ GridDataFactory.fillDefaults().align(GridData.CENTER, GridData.BEGINNING).grab(true, false).create());
fLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), EDITOR_PREF_PAGE_ID, null, null).open();
}
});
-
- String dsc= DialogsMessages.DocCommentOwnerBlock_SelectDocToolDescription;
- String msg= DialogsMessages.DocCommentOwnerBlock_DocToolLabel;
-
- IDocCommentOwner prjOwner= DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
- fDocComboComposite= new DocCommentOwnerComposite(pane, prjOwner, dsc, msg);
- fDocComboComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).span(2, 1).create());
-
+
+ String dsc = DialogsMessages.DocCommentOwnerBlock_SelectDocToolDescription;
+ String msg = DialogsMessages.DocCommentOwnerBlock_DocToolLabel;
+
+ IDocCommentOwner prjOwner = DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
+ fDocComboComposite = new DocCommentOwnerComposite(pane, prjOwner, dsc, msg);
+ fDocComboComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
+
fCheckbox.setSelection(fManager.projectDefinesOwnership(getProject()));
handleCheckBox();
}
-
+
@Override
public void performApply(IProgressMonitor monitor) throws CoreException {
- if(!fCheckbox.getSelection())
+ if (!fCheckbox.getSelection())
fManager.setCommentOwner(getProject(), null, true);
else {
- IDocCommentOwner newOwner= fDocComboComposite.getSelectedDocCommentOwner();
- IProject p= getProject();
+ IDocCommentOwner newOwner = fDocComboComposite.getSelectedDocCommentOwner();
+ IProject p = getProject();
fManager.setCommentOwner(p, newOwner, true);
}
}
public IProject getProject() {
ICOptionContainer container = getContainer();
- if (container != null){
+ if (container != null) {
if (container instanceof ICOptionContainerExtension) {
try {
return ((ICOptionContainerExtension) container).getProjectHandle();
- }
- catch (Exception e) {
+ } catch (Exception e) {
return null;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.java
index 6ff6b857fb5..f889018aa92 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.java
@@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner;
/**
* Manages the population and selection of the doc-comment {@link Combo} box
* <em>This class is not intended for use outside of CDT</em>
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
@@ -40,49 +40,49 @@ public class DocCommentOwnerCombo extends Composite {
public DocCommentOwnerCombo(Composite parent, int style, IDocCommentOwner initialOwner) {
super(parent, style);
setLayout(new GridLayout());
- fInitialOwner= initialOwner;
- fOwners= getNontestOwners();
+ fInitialOwner = initialOwner;
+ fOwners = getNontestOwners();
createControl(this);
}
public IDocCommentOwner getSelectedDocCommentOwner() {
- int index= fCombo.getSelectionIndex();
- return index == 0 ? NullDocCommentOwner.INSTANCE : fOwners[index-1];
+ int index = fCombo.getSelectionIndex();
+ return index == 0 ? NullDocCommentOwner.INSTANCE : fOwners[index - 1];
}
-
+
/**
* @return the list of registered doc-comment owners, filtering out those from the
* test plug-in.
*/
private static IDocCommentOwner[] getNontestOwners() {
- List<IDocCommentOwner> result= new ArrayList<IDocCommentOwner>();
- for(IDocCommentOwner owner : DocCommentOwnerManager.getInstance().getRegisteredOwners()) {
- if(owner.getID().indexOf(".test.")==-1) //$NON-NLS-1$
+ List<IDocCommentOwner> result = new ArrayList<IDocCommentOwner>();
+ for (IDocCommentOwner owner : DocCommentOwnerManager.getInstance().getRegisteredOwners()) {
+ if (owner.getID().indexOf(".test.") == -1) //$NON-NLS-1$
result.add(owner);
}
return result.toArray(new IDocCommentOwner[result.size()]);
}
-
+
public void createControl(Composite parent) {
- String[] items= new String[fOwners.length+1];
- items[0]= DialogsMessages.DocCommentOwnerCombo_None;
- for(int i=0; i<fOwners.length; i++) {
- items[i+1]= fOwners[i].getName();
+ String[] items = new String[fOwners.length + 1];
+ items[0] = DialogsMessages.DocCommentOwnerCombo_None;
+ for (int i = 0; i < fOwners.length; i++) {
+ items[i + 1] = fOwners[i].getName();
}
fCombo = ControlFactory.createSelectCombo(parent, items, DialogsMessages.DocCommentOwnerCombo_None);
selectInCombo(fInitialOwner);
}
public void selectInCombo(IDocCommentOwner owner) {
- for(int i=0; i<fOwners.length; i++) {
- if(fOwners[i].getID().equals(owner.getID())) {
- fCombo.select(i+1);
+ for (int i = 0; i < fOwners.length; i++) {
+ if (fOwners[i].getID().equals(owner.getID())) {
+ fCombo.select(i + 1);
return;
}
}
fCombo.select(0);
}
-
+
@Override
public void setEnabled(boolean enabled) {
fCombo.setEnabled(enabled);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java
index f3a78b738e9..9ed6f9f57ef 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java
@@ -26,7 +26,7 @@ import org.eclipse.cdt.utils.ui.controls.ControlFactory;
/**
* <em>This class is not intended for use outside of CDT</em>
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
@@ -34,34 +34,36 @@ public class DocCommentOwnerComposite extends Composite {
protected DocCommentOwnerCombo fDocCombo;
protected Label desc, comboLabel;
protected Group group;
-
+
public DocCommentOwnerComposite(Composite parent, IDocCommentOwner initialOwner, String description, String label) {
super(parent, SWT.NONE);
- GridLayout gl= new GridLayout();
- gl.marginHeight= gl.marginWidth= 0;
+ GridLayout gl = new GridLayout();
+ gl.marginHeight = gl.marginWidth = 0;
setLayout(gl);
-
- group = ControlFactory.createGroup(this, DialogsMessages.DocCommentOwnerComposite_DocumentationToolGroupTitle, 2);
+
+ group = ControlFactory.createGroup(this, DialogsMessages.DocCommentOwnerComposite_DocumentationToolGroupTitle,
+ 2);
group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
-
- desc= new Label(group, SWT.WRAP);
+
+ desc = new Label(group, SWT.WRAP);
GridData gd = GridDataFactory.fillDefaults().grab(false, false).span(2, 1).create();
- gd.widthHint= 150;
+ gd.widthHint = 150;
desc.setText(description);
desc.setLayoutData(gd);
-
- comboLabel= new Label(group, SWT.NONE);
+
+ comboLabel = new Label(group, SWT.NONE);
comboLabel.setText(label);
-
- fDocCombo= new DocCommentOwnerCombo(group, SWT.NONE, initialOwner) {};
+
+ fDocCombo = new DocCommentOwnerCombo(group, SWT.NONE, initialOwner) {
+ };
gd = GridDataFactory.fillDefaults().grab(true, false).create();
fDocCombo.setLayoutData(gd);
}
-
+
public IDocCommentOwner getSelectedDocCommentOwner() {
return fDocCombo.getSelectedDocCommentOwner();
}
-
+
@Override
public void setEnabled(boolean enabled) {
desc.setEnabled(enabled);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/FastIndexerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/FastIndexerBlock.java
index 48e25c3d002..027612ba0e8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/FastIndexerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/FastIndexerBlock.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.ui.dialogs;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java
index c1b04882746..a83b23b07e2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
@@ -16,8 +16,8 @@ package org.eclipse.cdt.ui.dialogs;
/**
* Reusing AbstractGNUBinaryParserPage.
* New class is required for the algorithm in method performApply.
- * Must implement getRealBinaryParserPage method.
- *
+ * Must implement getRealBinaryParserPage method.
+ *
* @author vhirsl
* @noextend This class is not intended to be subclassed by clients.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java
index 3a7daedd185..f6b4eabe75b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
@@ -16,8 +16,8 @@ package org.eclipse.cdt.ui.dialogs;
/**
* Reusing AbstractGNUBinaryParserPage.
* New class is required for the algorithm in method performApply.
- * Must implement getRealBinaryParserPage method.
- *
+ * Must implement getRealBinaryParserPage method.
+ *
* @author vhirsl
* @noextend This class is not intended to be subclassed by clients.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.java
index b0b1b1223a3..7302d0e98ed 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.java
@@ -16,8 +16,8 @@ package org.eclipse.cdt.ui.dialogs;
/**
* Reusing AbstractGNUBinaryParserPage.
* New class is required for the algorithm in method performApply.
- * Must implement getRealBinaryParserPage method.
- *
+ * Must implement getRealBinaryParserPage method.
+ *
* @author vhirsl
* @noextend This class is not intended to be subclassed by clients.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.java
index 4de4ebfc53c..61f31fb24da 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.ui.dialogs;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionPage.java
index 771ca1f1001..16169f0542a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionPage.java
@@ -20,9 +20,9 @@ import org.eclipse.jface.dialogs.IDialogPage;
public interface ICOptionPage extends IDialogPage {
public void setContainer(ICOptionContainer container);
-
+
public boolean isValid();
-
+
public void performApply(IProgressMonitor monitor) throws CoreException;
public void performDefaults();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IInputStatusValidator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IInputStatusValidator.java
index dd6af7769c4..c2690dfbad1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IInputStatusValidator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IInputStatusValidator.java
@@ -17,17 +17,17 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
- * The IInputStatusValidator is the interface for IStatus validators.
+ * The IInputStatusValidator is the interface for IStatus validators.
* @since 5.2
*/
public interface IInputStatusValidator {
/**
* Validates the given string. Returns the status with an error/warning/info message to display if the new
* text fails validation.
- *
+ *
* @param newText
* the text to check for validity
- *
+ *
* @return {@link IStatus} object. For the purpose of validation severity and message are considered.
* <li/>{@link Status#OK_STATUS} or any {@link IStatus#OK} to indicate no error.
* <li/>{@link IStatus#ERROR} indicates an error.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
index cf801e2ef2b..d7738badffb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
@@ -66,40 +66,40 @@ import org.eclipse.cdt.internal.ui.preferences.IndexerPreferencePage;
*/
public class IndexerBlock extends AbstractCOptionPage {
private static final String NODE_INDEXERUI = "indexerUI"; //$NON-NLS-1$
- private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$
+ private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$
private static final String ATTRIB_NAME = "name"; //$NON-NLS-1$
private static final String ATTRIB_INDEXERID = "indexerID"; //$NON-NLS-1$
private static final String ATTRIB_ID = "id"; //$NON-NLS-1$
private static final String PREF_PAGE_ID = "org.eclipse.cdt.ui.preferences.IndexerPreferencePage"; //$NON-NLS-1$
- private static final String INDEXER_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.label" ); //$NON-NLS-1$
+ private static final String INDEXER_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.label"); //$NON-NLS-1$
private static final String INDEXER_DESCRIPTION = CUIPlugin.getResourceString("BaseIndexerBlock.desc"); //$NON-NLS-1$
- private PreferenceScopeBlock fPrefScopeBlock;
- private Button fEnableIndexer;
- private Combo fIndexersComboBox;
- private HashMap<String, IndexerConfig> fIndexerConfigMap;
- private String fTheOneIndexerID;
- private Composite fIndexerPageComposite;
- private AbstractIndexerPage fCurrentPage;
- private Properties fCurrentProperties;
- private Composite fPreferenceContent;
- private Composite fParent;
- private Button fUseActiveBuildButton;
- private Button fUseFixedBuildConfig;
- private Combo fBuildConfigComboBox;
- private ControlEnableState fEnableState;
+ private PreferenceScopeBlock fPrefScopeBlock;
+ private Button fEnableIndexer;
+ private Combo fIndexersComboBox;
+ private HashMap<String, IndexerConfig> fIndexerConfigMap;
+ private String fTheOneIndexerID;
+ private Composite fIndexerPageComposite;
+ private AbstractIndexerPage fCurrentPage;
+ private Properties fCurrentProperties;
+ private Composite fPreferenceContent;
+ private Composite fParent;
+ private Button fUseActiveBuildButton;
+ private Button fUseFixedBuildConfig;
+ private Combo fBuildConfigComboBox;
+ private ControlEnableState fEnableState;
private Group fBuildConfigGroup;
private int fLastScope;
private Button fReindexOnConfigChange;
private Button fReindexOnIndexerChange;
- public IndexerBlock(){
+ public IndexerBlock() {
super(INDEXER_LABEL);
setDescription(INDEXER_DESCRIPTION);
initializeIndexerConfigMap();
- }
+ }
@Override
public boolean isValid() {
@@ -110,76 +110,76 @@ public class IndexerBlock extends AbstractCOptionPage {
public String getErrorMessage() {
String msg = super.getErrorMessage();
if (msg == null && fCurrentPage != null) {
- msg= fCurrentPage.getErrorMessage();
+ msg = fCurrentPage.getErrorMessage();
}
return msg;
}
/**
- * Create a profile page only on request
- */
- private static class IndexerConfig implements IPluginContribution {
+ * Create a profile page only on request
+ */
+ private static class IndexerConfig implements IPluginContribution {
private static final String NULL = "null"; //$NON-NLS-1$
private AbstractIndexerPage fPage;
- private IConfigurationElement fElement;
-
- public IndexerConfig(NullIndexerBlock fixed) {
- fPage= fixed;
- }
-
- public IndexerConfig(IConfigurationElement element) {
- fElement= element;
- }
-
- public AbstractIndexerPage getPage() throws CoreException {
- if (fPage == null) {
- try {
- fPage= (AbstractIndexerPage) fElement.createExecutableExtension(ATTRIB_CLASS);
- } catch (Exception e) {
- CUIPlugin.log(e);
- }
- if (fPage == null) {
- fPage= new NullIndexerBlock();
- }
- }
- return fPage;
- }
-
- public String getName() {
- if (fElement == null)
- return NULL;
- return fElement.getAttribute(ATTRIB_NAME);
- }
+ private IConfigurationElement fElement;
+
+ public IndexerConfig(NullIndexerBlock fixed) {
+ fPage = fixed;
+ }
+
+ public IndexerConfig(IConfigurationElement element) {
+ fElement = element;
+ }
+
+ public AbstractIndexerPage getPage() throws CoreException {
+ if (fPage == null) {
+ try {
+ fPage = (AbstractIndexerPage) fElement.createExecutableExtension(ATTRIB_CLASS);
+ } catch (Exception e) {
+ CUIPlugin.log(e);
+ }
+ if (fPage == null) {
+ fPage = new NullIndexerBlock();
+ }
+ }
+ return fPage;
+ }
+
+ public String getName() {
+ if (fElement == null)
+ return NULL;
+ return fElement.getAttribute(ATTRIB_NAME);
+ }
@Override
public String getLocalId() {
- if (fElement == null)
- return NULL;
+ if (fElement == null)
+ return NULL;
return fElement.getAttribute(ATTRIB_ID);
}
@Override
public String getPluginId() {
- if (fElement == null)
- return NULL;
+ if (fElement == null)
+ return NULL;
return fElement.getContributor().getName();
}
- }
+ }
- @Override
+ @Override
public void createControl(Composite parent) {
- fParent= parent;
+ fParent = parent;
- Composite composite = ControlFactory.createComposite(parent, 1);
- GridLayout layout= ((GridLayout)composite.getLayout());
- layout.marginWidth= 0;
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ GridLayout layout = ((GridLayout) composite.getLayout());
+ layout.marginWidth = 0;
- GridData gd= (GridData) composite.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
+ GridData gd = (GridData) composite.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
setControl(composite);
if (getProject() != null || getContainer() instanceof ICOptionContainerExtension) {
- fPrefScopeBlock= new PreferenceScopeBlock(PREF_PAGE_ID) {
+ fPrefScopeBlock = new PreferenceScopeBlock(PREF_PAGE_ID) {
@Override
protected void onPreferenceScopeChange() {
IndexerBlock.this.onPreferenceScopeChange();
@@ -188,12 +188,12 @@ public class IndexerBlock extends AbstractCOptionPage {
fPrefScopeBlock.createControl(composite);
}
- fPreferenceContent= ControlFactory.createComposite(composite, 1);
- layout= (GridLayout)fPreferenceContent.getLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- gd= (GridData) fPreferenceContent.getLayoutData();
- gd.horizontalIndent= 0;
+ fPreferenceContent = ControlFactory.createComposite(composite, 1);
+ layout = (GridLayout) fPreferenceContent.getLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ gd = (GridData) fPreferenceContent.getLayoutData();
+ gd.horizontalIndent = 0;
// add option to enable indexer
final SelectionAdapter indexerChangeListener = new SelectionAdapter() {
@@ -202,62 +202,68 @@ public class IndexerBlock extends AbstractCOptionPage {
onIndexerChange();
}
};
- fEnableIndexer= ControlFactory.createCheckBox(fPreferenceContent, CUIPlugin.getResourceString("IndexerBlock.enable")); //$NON-NLS-1$
+ fEnableIndexer = ControlFactory.createCheckBox(fPreferenceContent,
+ CUIPlugin.getResourceString("IndexerBlock.enable")); //$NON-NLS-1$
fEnableIndexer.addSelectionListener(indexerChangeListener);
// Add a group for indexer options.
- Group group= ControlFactory.createGroup(fPreferenceContent, DialogsMessages.IndexerBlock_indexerOptions, 1);
- gd= (GridData) group.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
+ Group group = ControlFactory.createGroup(fPreferenceContent, DialogsMessages.IndexerBlock_indexerOptions, 1);
+ gd = (GridData) group.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
if (fIndexerConfigMap.size() > 2) {
fIndexersComboBox = ControlFactory.createSelectCombo(group, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
fIndexersComboBox.addSelectionListener(indexerChangeListener);
-
- if(getProject() != null) {
- fReindexOnIndexerChange = ControlFactory.createCheckBox(group, CUIPlugin.getResourceString("IndexerBlock.redindexOnIndexerChange")); //$NON-NLS-1$
+
+ if (getProject() != null) {
+ fReindexOnIndexerChange = ControlFactory.createCheckBox(group,
+ CUIPlugin.getResourceString("IndexerBlock.redindexOnIndexerChange")); //$NON-NLS-1$
}
}
// add composite for pages
- fIndexerPageComposite= ControlFactory.createComposite(group, 1);
- fIndexerPageComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
- fIndexerPageComposite.setLayout(new TabFolderLayout());
-
- if (needBuildConfigOptions()) {
- fBuildConfigGroup= group= ControlFactory.createGroup(composite, DialogsMessages.IndexerBlock_buildConfigGroup, 1);
- gd= (GridData) group.getLayoutData();
- gd.grabExcessHorizontalSpace= true;
- fUseActiveBuildButton= ControlFactory.createRadioButton(group, DialogsMessages.IndexerBlock_activeBuildConfig, null, null);
- fUseFixedBuildConfig= ControlFactory.createRadioButton(group, DialogsMessages.IndexerBlock_fixedBuildConfig, null, null);
- fBuildConfigComboBox= ControlFactory.createSelectCombo(group, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
- final SelectionAdapter listener = new SelectionAdapter() {
- @Override
+ fIndexerPageComposite = ControlFactory.createComposite(group, 1);
+ fIndexerPageComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
+ fIndexerPageComposite.setLayout(new TabFolderLayout());
+
+ if (needBuildConfigOptions()) {
+ fBuildConfigGroup = group = ControlFactory.createGroup(composite,
+ DialogsMessages.IndexerBlock_buildConfigGroup, 1);
+ gd = (GridData) group.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
+ fUseActiveBuildButton = ControlFactory.createRadioButton(group,
+ DialogsMessages.IndexerBlock_activeBuildConfig, null, null);
+ fUseFixedBuildConfig = ControlFactory.createRadioButton(group,
+ DialogsMessages.IndexerBlock_fixedBuildConfig, null, null);
+ fBuildConfigComboBox = ControlFactory.createSelectCombo(group, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ final SelectionAdapter listener = new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- setUseActiveBuildConfig(fUseActiveBuildButton.getSelection());
- }
- };
+ setUseActiveBuildConfig(fUseActiveBuildButton.getSelection());
+ }
+ };
fUseActiveBuildButton.addSelectionListener(listener);
fUseFixedBuildConfig.addSelectionListener(listener);
- fReindexOnConfigChange = ControlFactory.createCheckBox(group, CUIPlugin.getResourceString("IndexerBlock.reindexOnBuildConfigChange")); //$NON-NLS-1$
- }
+ fReindexOnConfigChange = ControlFactory.createCheckBox(group,
+ CUIPlugin.getResourceString("IndexerBlock.reindexOnBuildConfigChange")); //$NON-NLS-1$
+ }
- initializeScope();
+ initializeScope();
initializeIndexerCombo();
initializeBuildConfigs();
onPreferenceScopeChange();
- fParent.layout(true);
- }
+ fParent.layout(true);
+ }
protected boolean needBuildConfigOptions() {
if (fPrefScopeBlock == null || !(getContainer() instanceof PropertyPage)) {
return false;
}
- IProject prj= getProject();
+ IProject prj = getProject();
if (prj != null) {
if (IndexerPreferencePage.showBuildConfiguration()) {
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+ ICProjectDescriptionManager prjDescMgr = CCorePlugin.getDefault().getProjectDescriptionManager();
if (prjDescMgr.isNewStyleProject(prj))
return true;
}
@@ -268,9 +274,11 @@ public class IndexerBlock extends AbstractCOptionPage {
private void updateBuildConfigForScope(int scope) {
if (fBuildConfigComboBox != null) {
if (scope == IndexerPreferences.SCOPE_INSTANCE) {
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
- ICProjectDescriptionWorkspacePreferences prefs= prjDescMgr.getProjectDescriptionWorkspacePreferences(false);
- boolean useActive= prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE;
+ ICProjectDescriptionManager prjDescMgr = CCorePlugin.getDefault().getProjectDescriptionManager();
+ ICProjectDescriptionWorkspacePreferences prefs = prjDescMgr
+ .getProjectDescriptionWorkspacePreferences(false);
+ boolean useActive = prefs
+ .getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE;
fUseActiveBuildButton.setSelection(useActive);
fUseFixedBuildConfig.setSelection(!useActive);
}
@@ -291,7 +299,8 @@ public class IndexerBlock extends AbstractCOptionPage {
fBuildConfigComboBox.setEnabled(fixed);
fUseActiveBuildButton.setEnabled(notDerived);
fUseFixedBuildConfig.setEnabled(notDerived);
- fReindexOnConfigChange.setEnabled(fUseActiveBuildButton.getEnabled() && fUseActiveBuildButton.getSelection());
+ fReindexOnConfigChange
+ .setEnabled(fUseActiveBuildButton.getEnabled() && fUseActiveBuildButton.getSelection());
fBuildConfigGroup.setEnabled(notDerived || fixed);
}
}
@@ -299,9 +308,9 @@ public class IndexerBlock extends AbstractCOptionPage {
protected void setUseActiveBuildConfig(boolean useActive) {
if (fBuildConfigComboBox != null) {
if (useActive) {
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
- ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), false);
- selectBuildConfigInCombo(prefs.getActiveConfiguration().getName());
+ ICProjectDescriptionManager prjDescMgr = CCorePlugin.getDefault().getProjectDescriptionManager();
+ ICProjectDescription prefs = prjDescMgr.getProjectDescription(getProject(), false);
+ selectBuildConfigInCombo(prefs.getActiveConfiguration().getName());
fBuildConfigComboBox.setEnabled(false);
fReindexOnConfigChange.setEnabled(fUseActiveBuildButton.getEnabled());
} else {
@@ -319,49 +328,49 @@ public class IndexerBlock extends AbstractCOptionPage {
fEnableState.restore();
}
if (enable) {
- fEnableState= null;
+ fEnableState = null;
} else {
- fEnableState= ControlEnableState.disable(fPreferenceContent);
+ fEnableState = ControlEnableState.disable(fPreferenceContent);
}
}
private void initializeScope() {
- IProject proj= getProject();
- if (fPrefScopeBlock == null) {
- return;
- }
-
- int scope= proj == null ? IndexerPreferences.SCOPE_INSTANCE : IndexerPreferences.getScope(proj);
- switch(scope) {
- case IndexerPreferences.SCOPE_PROJECT_PRIVATE:
- fPrefScopeBlock.setProjectLocalScope();
- break;
- case IndexerPreferences.SCOPE_PROJECT_SHARED:
- fPrefScopeBlock.setProjectScope();
- break;
- default:
- fPrefScopeBlock.setInstanceScope();
- break;
- }
+ IProject proj = getProject();
+ if (fPrefScopeBlock == null) {
+ return;
+ }
+
+ int scope = proj == null ? IndexerPreferences.SCOPE_INSTANCE : IndexerPreferences.getScope(proj);
+ switch (scope) {
+ case IndexerPreferences.SCOPE_PROJECT_PRIVATE:
+ fPrefScopeBlock.setProjectLocalScope();
+ break;
+ case IndexerPreferences.SCOPE_PROJECT_SHARED:
+ fPrefScopeBlock.setProjectScope();
+ break;
+ default:
+ fPrefScopeBlock.setInstanceScope();
+ break;
+ }
}
private void initializeIndexerCombo() {
if (fIndexersComboBox != null) {
- String[] names= new String[fIndexerConfigMap.size()-1];
- int j= 0;
+ String[] names = new String[fIndexerConfigMap.size() - 1];
+ int j = 0;
for (String id : fIndexerConfigMap.keySet()) {
if (!IPDOMManager.ID_NO_INDEXER.equals(id)) {
- names[j++]= fIndexerConfigMap.get(id).getName();
+ names[j++] = fIndexerConfigMap.get(id).getName();
}
}
final Comparator<Object> collator = Collator.getInstance();
Arrays.sort(names, collator);
fIndexersComboBox.setItems(names);
} else {
- fTheOneIndexerID= IPDOMManager.ID_NO_INDEXER;
+ fTheOneIndexerID = IPDOMManager.ID_NO_INDEXER;
for (String id : fIndexerConfigMap.keySet()) {
if (!IPDOMManager.ID_NO_INDEXER.equals(id)) {
- fTheOneIndexerID= id;
+ fTheOneIndexerID = id;
break;
}
}
@@ -374,61 +383,62 @@ public class IndexerBlock extends AbstractCOptionPage {
private void initializeBuildConfigs() {
if (fBuildConfigComboBox != null) {
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
- final IProject project = getProject();
- ICProjectDescription prefs= prjDescMgr.getProjectDescription(project, false);
- setUseActiveBuildConfig(prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
- ICConfigurationDescription[] configs= prefs.getConfigurations();
- String[] names= new String[configs.length];
- for (int i = 0; i < configs.length; i++) {
+ ICProjectDescriptionManager prjDescMgr = CCorePlugin.getDefault().getProjectDescriptionManager();
+ final IProject project = getProject();
+ ICProjectDescription prefs = prjDescMgr.getProjectDescription(project, false);
+ setUseActiveBuildConfig(prefs
+ .getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
+ ICConfigurationDescription[] configs = prefs.getConfigurations();
+ String[] names = new String[configs.length];
+ for (int i = 0; i < configs.length; i++) {
ICConfigurationDescription config = configs[i];
- names[i]= config.getName();
+ names[i] = config.getName();
}
final Comparator<Object> collator = Collator.getInstance();
Arrays.sort(names, collator);
fBuildConfigComboBox.setItems(names);
- selectBuildConfigInCombo(prefs.getDefaultSettingConfiguration().getName());
+ selectBuildConfigInCombo(prefs.getDefaultSettingConfiguration().getName());
- fReindexOnConfigChange.setSelection(IndexerPreferences.getReindexOnConfigChange(project));
+ fReindexOnConfigChange.setSelection(IndexerPreferences.getReindexOnConfigChange(project));
}
}
private void selectBuildConfigInCombo(String useName) {
- String[] names= fBuildConfigComboBox.getItems();
+ String[] names = fBuildConfigComboBox.getItems();
int selectedIndex = 0;
- for (int i = 0; i < names.length; i++){
+ for (int i = 0; i < names.length; i++) {
if (names[i].equals(useName))
selectedIndex = i;
}
fBuildConfigComboBox.select(selectedIndex);
}
- protected void onPreferenceScopeChange() {
- int scope= computeScope();
- if (fCurrentProperties == null || scope == IndexerPreferences.SCOPE_INSTANCE
- || (fLastScope == IndexerPreferences.SCOPE_INSTANCE
- && scope == IndexerPreferences.SCOPE_PROJECT_SHARED)) {
- Properties props= IndexerPreferences.getProperties(getProject(), scope);
-
- String indexerId= props.getProperty(IndexerPreferences.KEY_INDEXER_ID);
- if (getIndexerName(indexerId) == null) {
- if (fCurrentProperties != null) {
- props= fCurrentProperties;
- } else {
- props= IndexerPreferences.getProperties(getProject(), IndexerPreferences.SCOPE_INSTANCE);
- }
- }
- fCurrentProperties= props;
+ protected void onPreferenceScopeChange() {
+ int scope = computeScope();
+ if (fCurrentProperties == null || scope == IndexerPreferences.SCOPE_INSTANCE
+ || (fLastScope == IndexerPreferences.SCOPE_INSTANCE
+ && scope == IndexerPreferences.SCOPE_PROJECT_SHARED)) {
+ Properties props = IndexerPreferences.getProperties(getProject(), scope);
+
+ String indexerId = props.getProperty(IndexerPreferences.KEY_INDEXER_ID);
+ if (getIndexerName(indexerId) == null) {
+ if (fCurrentProperties != null) {
+ props = fCurrentProperties;
+ } else {
+ props = IndexerPreferences.getProperties(getProject(), IndexerPreferences.SCOPE_INSTANCE);
+ }
+ }
+ fCurrentProperties = props;
} else {
fCurrentProperties.putAll(fCurrentPage.getProperties());
}
updateForNewProperties(scope);
- updateBuildConfigForScope(scope);
- fLastScope= scope;
+ updateBuildConfigForScope(scope);
+ fLastScope = scope;
}
private void updateForNewProperties(int scope) {
- String indexerId= fCurrentProperties.getProperty(IndexerPreferences.KEY_INDEXER_ID);
+ String indexerId = fCurrentProperties.getProperty(IndexerPreferences.KEY_INDEXER_ID);
if (IPDOMManager.ID_NO_INDEXER.equals(indexerId)) {
fEnableIndexer.setSelection(false);
} else {
@@ -437,29 +447,29 @@ public class IndexerBlock extends AbstractCOptionPage {
String indexerName = getIndexerName(indexerId);
String[] indexerList = fIndexersComboBox.getItems();
int selectedIndex = 0;
- for (int i = 0; i < indexerList.length; i++){
+ for (int i = 0; i < indexerList.length; i++) {
if (indexerList[i].equals(indexerName))
selectedIndex = i;
}
fIndexersComboBox.select(selectedIndex);
}
}
- setPage();
- if (fPrefScopeBlock != null) {
- enablePreferenceContent(scope != IndexerPreferences.SCOPE_INSTANCE);
- }
+ setPage();
+ if (fPrefScopeBlock != null) {
+ enablePreferenceContent(scope != IndexerPreferences.SCOPE_INSTANCE);
+ }
}
protected void onIndexerChange() {
- if (fCurrentPage != null) {
- Properties props= fCurrentPage.getProperties();
- if (props != null) {
- fCurrentProperties.putAll(props);
- }
- }
- setPage();
- updateBuildConfigEnablement(computeScope());
- }
+ if (fCurrentPage != null) {
+ Properties props = fCurrentPage.getProperties();
+ if (props != null) {
+ fCurrentProperties.putAll(props);
+ }
+ }
+ setPage();
+ updateBuildConfigEnablement(computeScope());
+ }
private int computeScope() {
if (fPrefScopeBlock != null) {
@@ -473,148 +483,149 @@ public class IndexerBlock extends AbstractCOptionPage {
return IndexerPreferences.SCOPE_INSTANCE;
}
- private void setPage() {
- String indexerID= getSelectedIndexerID();
- AbstractIndexerPage page = getIndexerPage(indexerID);
- if (page != null) {
- if (page.getControl() == null) {
- page.setContainer(getContainer());
- page.createControl(fIndexerPageComposite);
- fIndexerPageComposite.layout(true);
- fParent.layout(true);
- }
- }
-
- if (fCurrentPage != null){
- fCurrentPage.setVisible(false);
- }
-
- if (page != null) {
- page.setProperties(fCurrentProperties);
- page.setVisible(true);
- }
-
- fCurrentPage= page;
+ private void setPage() {
+ String indexerID = getSelectedIndexerID();
+ AbstractIndexerPage page = getIndexerPage(indexerID);
+ if (page != null) {
+ if (page.getControl() == null) {
+ page.setContainer(getContainer());
+ page.createControl(fIndexerPageComposite);
+ fIndexerPageComposite.layout(true);
+ fParent.layout(true);
+ }
+ }
+
+ if (fCurrentPage != null) {
+ fCurrentPage.setVisible(false);
+ }
+
+ if (page != null) {
+ page.setProperties(fCurrentProperties);
+ page.setVisible(true);
+ }
+
+ fCurrentPage = page;
}
/**
- * Adds all the contributed Indexer Pages to a map
- */
- private void initializeIndexerConfigMap() {
- fIndexerConfigMap = new HashMap<String, IndexerConfig>(5);
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.getPluginId(), "IndexerPage"); //$NON-NLS-1$
- IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
- for (final IConfigurationElement info : infos) {
- if (info.getName().equals(NODE_INDEXERUI)) {
- final String id = info.getAttribute(ATTRIB_INDEXERID);
- if (id != null) {
- IndexerConfig config= new IndexerConfig(info);
- if (config.getName() != null && !WorkbenchActivityHelper.filterItem(config)) {
- fIndexerConfigMap.put(id, config);
- }
- }
- }
- }
- fIndexerConfigMap.put(IPDOMManager.ID_NO_INDEXER, new IndexerConfig(new NullIndexerBlock()));
- }
-
- private String getIndexerName(String indexerID) {
- IndexerConfig configElement= fIndexerConfigMap.get(indexerID);
- if (configElement != null) {
- return configElement.getName();
- }
- return null;
- }
-
- private AbstractIndexerPage getIndexerPage(String indexerID) {
- IndexerConfig configElement= fIndexerConfigMap.get(indexerID);
- if (configElement != null) {
- try {
- return configElement.getPage();
- } catch (CoreException e) {
- CUIPlugin.log(e);
- }
- }
- return null;
- }
-
- @Override
+ * Adds all the contributed Indexer Pages to a map
+ */
+ private void initializeIndexerConfigMap() {
+ fIndexerConfigMap = new HashMap<String, IndexerConfig>(5);
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.getPluginId(),
+ "IndexerPage"); //$NON-NLS-1$
+ IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
+ for (final IConfigurationElement info : infos) {
+ if (info.getName().equals(NODE_INDEXERUI)) {
+ final String id = info.getAttribute(ATTRIB_INDEXERID);
+ if (id != null) {
+ IndexerConfig config = new IndexerConfig(info);
+ if (config.getName() != null && !WorkbenchActivityHelper.filterItem(config)) {
+ fIndexerConfigMap.put(id, config);
+ }
+ }
+ }
+ }
+ fIndexerConfigMap.put(IPDOMManager.ID_NO_INDEXER, new IndexerConfig(new NullIndexerBlock()));
+ }
+
+ private String getIndexerName(String indexerID) {
+ IndexerConfig configElement = fIndexerConfigMap.get(indexerID);
+ if (configElement != null) {
+ return configElement.getName();
+ }
+ return null;
+ }
+
+ private AbstractIndexerPage getIndexerPage(String indexerID) {
+ IndexerConfig configElement = fIndexerConfigMap.get(indexerID);
+ if (configElement != null) {
+ try {
+ return configElement.getPage();
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ return null;
+ }
+
+ @Override
public void performApply(IProgressMonitor monitor) throws CoreException {
- int scope= computeScope();
- IProject project= getProject();
- String indexerID = getSelectedIndexerID();
- if (indexerID == null) {
- return;
- }
-
- if (scope != IndexerPreferences.SCOPE_INSTANCE || project == null) {
- Properties props= new Properties();
- props.setProperty(IndexerPreferences.KEY_INDEXER_ID, indexerID);
- if (fCurrentPage != null) {
- Properties p1= fCurrentPage.getProperties();
- if (p1 != null) {
- props.putAll(p1);
- }
- }
-
- IndexerPreferences.setProperties(project, scope, props);
- }
-
- if (project != null) {
- IndexerPreferences.setScope(project, scope);
- }
+ int scope = computeScope();
+ IProject project = getProject();
+ String indexerID = getSelectedIndexerID();
+ if (indexerID == null) {
+ return;
+ }
+
+ if (scope != IndexerPreferences.SCOPE_INSTANCE || project == null) {
+ Properties props = new Properties();
+ props.setProperty(IndexerPreferences.KEY_INDEXER_ID, indexerID);
+ if (fCurrentPage != null) {
+ Properties p1 = fCurrentPage.getProperties();
+ if (p1 != null) {
+ props.putAll(p1);
+ }
+ }
+
+ IndexerPreferences.setProperties(project, scope, props);
+ }
+
+ if (project != null) {
+ IndexerPreferences.setScope(project, scope);
+ }
if (fReindexOnIndexerChange != null) {
IndexerPreferences.setReindexOnIndexerChange(project, fReindexOnIndexerChange.getSelection());
}
- if (fBuildConfigComboBox != null) {
- boolean useActive= fUseActiveBuildButton.getSelection();
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
- ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), true);
- if (scope == IndexerPreferences.SCOPE_INSTANCE) {
- prefs.useDefaultConfigurationRelations();
- } else {
- prefs.setConfigurationRelations(useActive ?
- ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE :
- ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT);
- }
- if (!useActive) {
- final ICConfigurationDescription config= prefs.getConfigurationByName(fBuildConfigComboBox.getText());
- if (config != null) {
- prefs.setDefaultSettingConfiguration(config);
- }
- }
+ if (fBuildConfigComboBox != null) {
+ boolean useActive = fUseActiveBuildButton.getSelection();
+ ICProjectDescriptionManager prjDescMgr = CCorePlugin.getDefault().getProjectDescriptionManager();
+ ICProjectDescription prefs = prjDescMgr.getProjectDescription(getProject(), true);
+ if (scope == IndexerPreferences.SCOPE_INSTANCE) {
+ prefs.useDefaultConfigurationRelations();
+ } else {
+ prefs.setConfigurationRelations(
+ useActive ? ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE
+ : ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT);
+ }
+ if (!useActive) {
+ final ICConfigurationDescription config = prefs.getConfigurationByName(fBuildConfigComboBox.getText());
+ if (config != null) {
+ prefs.setDefaultSettingConfiguration(config);
+ }
+ }
IndexerPreferences.setReindexOnConfigChange(project, fReindexOnConfigChange.getSelection());
- prjDescMgr.setProjectDescription(getProject(), prefs);
- }
- CCoreInternals.savePreferences(project, scope == IndexerPreferences.SCOPE_PROJECT_SHARED);
- }
+ prjDescMgr.setProjectDescription(getProject(), prefs);
+ }
+ CCoreInternals.savePreferences(project, scope == IndexerPreferences.SCOPE_PROJECT_SHARED);
+ }
- @Override
+ @Override
public void performDefaults() {
- fCurrentProperties= null;
- if (fPrefScopeBlock != null) {
- fPrefScopeBlock.setInstanceScope();
- onPreferenceScopeChange();
- } else {
- fCurrentProperties= IndexerPreferences.getDefaultIndexerProperties();
- updateForNewProperties(IndexerPreferences.SCOPE_INSTANCE);
- }
- }
-
- /**
- * @deprecated always returns false
- * @noreference This method is not intended to be referenced by clients.
- */
+ fCurrentProperties = null;
+ if (fPrefScopeBlock != null) {
+ fPrefScopeBlock.setInstanceScope();
+ onPreferenceScopeChange();
+ } else {
+ fCurrentProperties = IndexerPreferences.getDefaultIndexerProperties();
+ updateForNewProperties(IndexerPreferences.SCOPE_INSTANCE);
+ }
+ }
+
+ /**
+ * @deprecated always returns false
+ * @noreference This method is not intended to be referenced by clients.
+ */
@Deprecated
public boolean isIndexEnabled() {
return false;
}
- private String getSelectedIndexerID(){
+ private String getSelectedIndexerID() {
if (fEnableIndexer.getSelection()) {
if (fIndexersComboBox == null)
return fTheOneIndexerID;
@@ -632,7 +643,7 @@ public class IndexerBlock extends AbstractCOptionPage {
public IProject getProject() {
ICOptionContainer container = getContainer();
- if (container != null){
+ if (container != null) {
if (container instanceof ICOptionContainerExtension) {
try {
return ((ICOptionContainerExtension) container).getProjectHandle();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java
index 59aeeba94ed..a3dae443aef 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java
@@ -37,7 +37,7 @@ public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionC
private IndexerBlock optionPage;
- public IndexerOptionPropertyPage(){
+ public IndexerOptionPropertyPage() {
super();
optionPage = new IndexerBlock();
optionPage.setContainer(this);
@@ -70,13 +70,13 @@ public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionC
}
@Override
- public IProject getProject(){
- IProject project= null;
+ public IProject getProject() {
+ IProject project = null;
IAdaptable elem = getElement();
if (elem instanceof IProject) {
- project= (IProject) elem;
+ project = (IProject) elem;
} else if (elem != null) {
- project= elem.getAdapter(IProject.class);
+ project = elem.getAdapter(IProject.class);
}
return project;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java
index 1fc3947e38e..f51b6bfa8d9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java
@@ -62,33 +62,33 @@ public class InputStatusDialog extends StatusDialog {
*/
private Text text;
- /**
- * Creates an input dialog with OK and Cancel buttons. Note that the dialog
- * will have no visual representation (no widgets) until it is told to open.
- * <p>
- * Note that the <code>open</code> method blocks for input dialogs.
- * </p>
- *
- * @param parentShell
- * the parent shell, or <code>null</code> to create a top-level
- * shell
- * @param dialogTitle
- * the dialog title, or <code>null</code> if none
- * @param dialogMessage
- * the dialog message, or <code>null</code> if none
- * @param initialValue
- * the initial input value, or <code>null</code> if none
- * (equivalent to the empty string)
- * @param validator
- * an input validator, or <code>null</code> if none
- * For a validator, following return statuses are recognized:
- * <li/>{@link Status#OK_STATUS} or any {@link IStatus#OK} to indicate no error.
- * <li/>{@link IStatus#ERROR} indicates an error.
- * <li/>{@link IStatus#WARNING} indicates a warning.
- * <li/>{@link IStatus#INFO} indicates an informational message
- */
- public InputStatusDialog(Shell parentShell, String dialogTitle, String dialogMessage,
- String initialValue, IInputStatusValidator validator) {
+ /**
+ * Creates an input dialog with OK and Cancel buttons. Note that the dialog
+ * will have no visual representation (no widgets) until it is told to open.
+ * <p>
+ * Note that the <code>open</code> method blocks for input dialogs.
+ * </p>
+ *
+ * @param parentShell
+ * the parent shell, or <code>null</code> to create a top-level
+ * shell
+ * @param dialogTitle
+ * the dialog title, or <code>null</code> if none
+ * @param dialogMessage
+ * the dialog message, or <code>null</code> if none
+ * @param initialValue
+ * the initial input value, or <code>null</code> if none
+ * (equivalent to the empty string)
+ * @param validator
+ * an input validator, or <code>null</code> if none
+ * For a validator, following return statuses are recognized:
+ * <li/>{@link Status#OK_STATUS} or any {@link IStatus#OK} to indicate no error.
+ * <li/>{@link IStatus#ERROR} indicates an error.
+ * <li/>{@link IStatus#WARNING} indicates a warning.
+ * <li/>{@link IStatus#INFO} indicates an informational message
+ */
+ public InputStatusDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
+ IInputStatusValidator validator) {
super(parentShell);
this.title = dialogTitle;
if (dialogMessage == null) {
@@ -136,8 +136,8 @@ public class InputStatusDialog extends StatusDialog {
Label label = new Label(composite, SWT.WRAP);
label.setText(message);
- GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
- | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+ GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_CENTER);
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
label.setLayoutData(data);
label.setFont(parent.getFont());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java
index 729f00b92de..2b45c0337c4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java
@@ -82,7 +82,8 @@ public class MachOBinaryParserPage extends AbstractCOptionPage {
}
}
if (cext != null && cext.length > 0) {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ "BinaryParserPage"); //$NON-NLS-1$
IConfigurationElement[] infos = point.getConfigurationElements();
for (int i = 0; i < infos.length; i++) {
String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java
index 17dd0b8978f..067cd4a8ded 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java
@@ -19,7 +19,6 @@ import java.util.Properties;
import org.eclipse.jface.dialogs.ControlEnableState;
import org.eclipse.swt.widgets.Composite;
-
/**
* @author Bogdan Gheorghe
* @noextend This class is not intended to be subclassed by clients.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java
index a926da1ec59..d12d7e83e73 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.ui.dialogs;
@@ -34,26 +34,27 @@ abstract public class PreferenceScopeBlock {
private Button fStoreWithProject;
private String fPrefPageID;
private Link fLink;
-
+
public PreferenceScopeBlock(String linkedPrefPageID) {
- fPrefPageID= linkedPrefPageID;
+ fPrefPageID = linkedPrefPageID;
}
-
+
public void createControl(final Composite parent) {
- Composite group= ControlFactory.createComposite(parent,2);
- GridLayout layout = (GridLayout)group.getLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ Composite group = ControlFactory.createComposite(parent, 2);
+ GridLayout layout = (GridLayout) group.getLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
GridData gd = (GridData) group.getLayoutData();
- gd.horizontalIndent= 0;
+ gd.horizontalIndent = 0;
- fUseProjectSettings= ControlFactory.createCheckBox(group, DialogsMessages.PreferenceScopeBlock_enableProjectSettings);
-
- Composite two= ControlFactory.createComposite(group, 1);
+ fUseProjectSettings = ControlFactory.createCheckBox(group,
+ DialogsMessages.PreferenceScopeBlock_enableProjectSettings);
+
+ Composite two = ControlFactory.createComposite(group, 1);
two.setLayout(new TabFolderLayout());
- fStoreWithProject= ControlFactory.createCheckBox(two, DialogsMessages.PreferenceScopeBlock_storeWithProject);
-
- SelectionListener sl= new SelectionAdapter() {
+ fStoreWithProject = ControlFactory.createCheckBox(two, DialogsMessages.PreferenceScopeBlock_storeWithProject);
+
+ SelectionListener sl = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateEnablement();
@@ -62,11 +63,11 @@ abstract public class PreferenceScopeBlock {
};
fUseProjectSettings.addSelectionListener(sl);
fStoreWithProject.addSelectionListener(sl);
-
- fLink= new Link(two, SWT.NONE);
+
+ fLink = new Link(two, SWT.NONE);
fLink.setText(DialogsMessages.PreferenceScopeBlock_preferenceLink);
fLink.setLayoutData(new GridData());
- sl= new SelectionAdapter() {
+ sl = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), fPrefPageID, null, null).open();
@@ -74,8 +75,8 @@ abstract public class PreferenceScopeBlock {
}
};
fLink.addSelectionListener(sl);
-
- Label horizontalLine= new Label(group, SWT.SEPARATOR | SWT.HORIZONTAL);
+
+ Label horizontalLine = new Label(group, SWT.SEPARATOR | SWT.HORIZONTAL);
horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
horizontalLine.setFont(group.getFont());
}
@@ -86,8 +87,7 @@ abstract public class PreferenceScopeBlock {
if (fUseProjectSettings.getSelection()) {
fLink.setVisible(false);
fStoreWithProject.setVisible(true);
- }
- else {
+ } else {
fStoreWithProject.setVisible(false);
fLink.setVisible(true);
}
@@ -119,7 +119,7 @@ abstract public class PreferenceScopeBlock {
public boolean isProjectScope() {
return fUseProjectSettings.getSelection() && fStoreWithProject.getSelection();
}
-
+
public boolean isInstanceScope() {
return !fUseProjectSettings.getSelection();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java
index 00a3828ce97..5bddd3a32c4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java
@@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.ui.CUIMessages;
/**
* @deprecated as of CDT 4.0. This Block was used for New Project Wizard
* for 3.X style projects.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
@Deprecated
@@ -59,7 +59,7 @@ public class ReferenceBlock extends AbstractCOptionPage {
private CheckboxTableViewer referenceProjectsViewer;
private static final int PROJECT_LIST_MULTIPLIER = 10;
-
+
public ReferenceBlock() {
super(CUIPlugin.getResourceString(LABEL));
setDescription(CUIPlugin.getResourceString(DESC));
@@ -83,7 +83,7 @@ public class ReferenceBlock extends AbstractCOptionPage {
if (!(element instanceof IWorkspace))
return new Object[0];
ArrayList<IProject> aList = new ArrayList<IProject>(15);
- final IProject[] projects = ((IWorkspace)element).getRoot().getProjects();
+ final IProject[] projects = ((IWorkspace) element).getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
if (CoreModel.hasCNature(projects[i])) {
// Do not show the actual project being look at
@@ -98,7 +98,7 @@ public class ReferenceBlock extends AbstractCOptionPage {
};
}
- protected void initializeValues () {
+ protected void initializeValues() {
if (getContainer().getProject() != null) {
try {
IProject[] referenced = getContainer().getProject().getReferencedProjects();
@@ -117,7 +117,7 @@ public class ReferenceBlock extends AbstractCOptionPage {
Object[] elements = referenceProjectsViewer.getCheckedElements();
IProject[] projects = new IProject[elements.length];
System.arraycopy(elements, 0, projects, 0, elements.length);
- return projects;
+ return projects;
}
@Override
@@ -132,15 +132,10 @@ public class ReferenceBlock extends AbstractCOptionPage {
lbldata.horizontalSpan = 1;
label.setLayoutData(lbldata);
-
- referenceProjectsViewer =
- CheckboxTableViewer.newCheckList(composite, SWT.TOP | SWT.BORDER);
+ referenceProjectsViewer = CheckboxTableViewer.newCheckList(composite, SWT.TOP | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.grabExcessHorizontalSpace = true;
- data.heightHint =
- getDefaultFontHeight(
- referenceProjectsViewer.getTable(),
- PROJECT_LIST_MULTIPLIER);
+ data.heightHint = getDefaultFontHeight(referenceProjectsViewer.getTable(), PROJECT_LIST_MULTIPLIER);
//Only set a height hint if it will not result in a cut off dialog
referenceProjectsViewer.getTable().setLayoutData(data);
@@ -178,7 +173,7 @@ public class ReferenceBlock extends AbstractCOptionPage {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
- monitor.beginTask(CUIMessages.ReferenceBlock_task_ReferenceProjects, 1);
+ monitor.beginTask(CUIMessages.ReferenceBlock_task_ReferenceProjects, 1);
try {
IProjectDescription description = project.getDescription();
description.setReferencedProjects(refProjects);
@@ -186,7 +181,7 @@ public class ReferenceBlock extends AbstractCOptionPage {
} catch (CoreException e) {
}
}
-
+
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java
index 28b5388e71f..aed8499dfca 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java
@@ -87,12 +87,8 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
private static final int BUTTON_MOVEUP = 2;
private static final int BUTTON_MOVEDOWN = 3;
- private static final String[] BUTTONS = new String[] {
- AbstractCPropertyTab.ADD_STR,
- AbstractCPropertyTab.DEL_STR,
- AbstractCPropertyTab.MOVEUP_STR,
- AbstractCPropertyTab.MOVEDOWN_STR,
- };
+ private static final String[] BUTTONS = new String[] { AbstractCPropertyTab.ADD_STR, AbstractCPropertyTab.DEL_STR,
+ AbstractCPropertyTab.MOVEUP_STR, AbstractCPropertyTab.MOVEDOWN_STR, };
private static final String OOPS = "OOPS"; //$NON-NLS-1$
@@ -242,7 +238,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
}
private void createLinkToPreferences(final Composite parent) {
- // must not be editable as error parser gets desynchronized with ErrorParsTab
+ // must not be editable as error parser gets desynchronized with ErrorParsTab
Assert.isTrue(!fEditable);
Link link = new Link(parent, SWT.NONE);
@@ -252,7 +248,8 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
@Override
public void handleEvent(Event event) {
// Use event.text to tell which link was used
- PreferencesUtil.createPreferenceDialogOn(parent.getShell(), WORKSPACE_PREFERENCE_PAGE, null, null).open();
+ PreferencesUtil.createPreferenceDialogOn(parent.getShell(), WORKSPACE_PREFERENCE_PAGE, null, null)
+ .open();
IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(fErrorParser.getId());
if (errorParser instanceof RegexErrorParser)
@@ -288,9 +285,9 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
}
private void initializeTable() {
- RegexErrorPattern[] errorParserPatterns = fErrorParser!=null
- ? errorParserPatterns = fErrorParser.getPatterns()
- : new RegexErrorPattern[0];
+ RegexErrorPattern[] errorParserPatterns = fErrorParser != null
+ ? errorParserPatterns = fErrorParser.getPatterns()
+ : new RegexErrorPattern[0];
int len = errorParserPatterns.length;
int newLen = len;
@@ -311,7 +308,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
tableLayouter.addColumnData(new ColumnWeightData(15, true)); // description
tableLayouter.addColumnData(new ColumnWeightData(10, true)); // eat line
- int style= SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
+ int style = SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
if (fEditable) {
style = style | SWT.FULL_SELECTION;
}
@@ -336,23 +333,25 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
fTableViewer = new TableViewer(fTable);
fTableViewer.setUseHashlookup(true);
fTableViewer.setContentProvider(ArrayContentProvider.getInstance());
-
+
//Bug 307542 - [Accessibility] Error Parser Options table should be accessible by keyboard
- TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(fTableViewer,new FocusCellOwnerDrawHighlighter(fTableViewer));
+ TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(fTableViewer,
+ new FocusCellOwnerDrawHighlighter(fTableViewer));
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(fTableViewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
- || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && (event.keyCode == SWT.CR || event.character == ' '))
+ || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
+ && (event.keyCode == SWT.CR || event.character == ' '))
|| event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
-
- TableViewerEditor.create(fTableViewer, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL
- | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
- | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
-
+
+ TableViewerEditor.create(fTableViewer, focusCellManager, actSupport,
+ ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
+ | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
+
createSeverityColumn();
createPatternColumn();
createFileColumn();
@@ -384,7 +383,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
case IMarkerGenerator.SEVERITY_ERROR_RESOURCE:
return images.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
case RegexErrorPattern.SEVERITY_SKIP:
- return images.getImage(ISharedImages.IMG_ELCL_REMOVE_DISABLED);
+ return images.getImage(ISharedImages.IMG_ELCL_REMOVE_DISABLED);
}
}
return null;
@@ -404,8 +403,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
severityToString(IMarkerGenerator.SEVERITY_ERROR_RESOURCE),
severityToString(IMarkerGenerator.SEVERITY_WARNING),
severityToString(IMarkerGenerator.SEVERITY_INFO),
- severityToString(RegexErrorPattern.SEVERITY_SKIP),
- };
+ severityToString(RegexErrorPattern.SEVERITY_SKIP), };
private int severityToIndex(int severity) {
String strSeverity = severityToString(severity);
@@ -481,13 +479,13 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
protected void setToPattern(RegexErrorPattern regexErrorPattern, String value) {
if (!fEditable)
return;
- try{
+ try {
regexErrorPattern.setPattern(value);
} catch (Exception e) {
// to avoid recursive edits. the dialog is needed to ensure valid pattern on losing focus.
// this looks ugly and likely incorrect
fEditable = false;
- RegularExpressionStatusDialog dialog= new RegularExpressionStatusDialog(getShell(), value);
+ RegularExpressionStatusDialog dialog = new RegularExpressionStatusDialog(getShell(), value);
if (dialog.open() == Window.OK) {
regexErrorPattern.setPattern(dialog.getValue());
}
@@ -596,7 +594,8 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
columnViewer.getColumn().setText(DialogsMessages.RegexErrorParserOptionPage_EatColumn);
columnViewer.getColumn().setResizable(true);
- String message = MessageFormat.format(DialogsMessages.RegexErrorParserOptionPage_TooltipConsume, new Object[] { EAT_NO });
+ String message = MessageFormat.format(DialogsMessages.RegexErrorParserOptionPage_TooltipConsume,
+ new Object[] { EAT_NO });
columnViewer.getColumn().setToolTipText(message);
columnViewer.setLabelProvider(new ColumnLabelProvider() {
@@ -665,7 +664,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
fButtons[i].addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- for (int i=0; i<fButtons.length; i++) {
+ for (int i = 0; i < fButtons.length; i++) {
if (fButtons[i].equals(event.widget)) {
buttonPressed(i);
return;
@@ -678,11 +677,11 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
}
private void updateButtons() {
- if (fButtons!=null) {
+ if (fButtons != null) {
int pos = fTable.getSelectionIndex();
int count = fTable.getItemCount();
- int last = count-1;
- boolean selected = pos>=0 && pos<=last;
+ int last = count - 1;
+ boolean selected = pos >= 0 && pos <= last;
fButtons[BUTTON_ADD].setEnabled(true);
fButtons[BUTTON_DELETE].setEnabled(selected);
@@ -691,7 +690,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
}
}
- private void buttonPressed (int button) {
+ private void buttonPressed(int button) {
switch (button) {
case BUTTON_ADD:
addErrorPattern();
@@ -715,8 +714,8 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
private void addErrorPattern() {
int pos = fTable.getSelectionIndex();
- int last = fTable.getItemCount()-1;
- if (pos<0 || pos>last)
+ int last = fTable.getItemCount() - 1;
+ if (pos < 0 || pos > last)
pos = last;
int newPos = pos + 1;
@@ -726,9 +725,9 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
private void deleteErrorPattern() {
int pos = fTable.getSelectionIndex();
- int last = fTable.getItemCount()-1;
+ int last = fTable.getItemCount() - 1;
- if (pos>=0 && pos<=last) {
+ if (pos >= 0 && pos <= last) {
fTableViewer.remove(fTableViewer.getElementAt(pos));
fTable.setSelection(pos);
}
@@ -737,26 +736,26 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
private void moveItem(boolean up) {
int pos = fTable.getSelectionIndex();
int count = fTable.getItemCount();
- int last = count-1;
- boolean selected = pos>=0 && pos<=last;
+ int last = count - 1;
+ boolean selected = pos >= 0 && pos <= last;
- if (!selected || (up && pos==0) || (!up && pos==last))
+ if (!selected || (up && pos == 0) || (!up && pos == last))
return;
Object item = fTableViewer.getElementAt(pos);
fTableViewer.remove(item);
- int newPos = up ? pos-1 : pos+1;
+ int newPos = up ? pos - 1 : pos + 1;
fTableViewer.insert(item, newPos);
fTable.setSelection(newPos);
}
private void applyPatterns() {
- if (fErrorParser!=null && fEditable) {
+ if (fErrorParser != null && fEditable) {
fErrorParser.clearPatterns();
for (TableItem tableItem : fTable.getItems()) {
Object item = tableItem.getData();
if (item instanceof RegexErrorPattern) {
- fErrorParser.addPattern((RegexErrorPattern)item);
+ fErrorParser.addPattern((RegexErrorPattern) item);
}
}
}
@@ -785,14 +784,14 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
/**
* @since 5.3
*/
- public void addListener(Listener listener){
+ public void addListener(Listener listener) {
fListeners.add(listener);
}
/**
* @since 5.3
*/
- public void removeListener(Listener listener){
+ public void removeListener(Listener listener) {
fListeners.remove(listener);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java
index 73f910e6f0d..d2f66a102b8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java
@@ -58,9 +58,8 @@ public class RegularExpressionStatusDialog extends InputStatusDialog {
* (equivalent to the empty string)
*/
public RegularExpressionStatusDialog(Shell shell, String initialValue) {
- super(shell, DialogsMessages.RegularExpression_Validate,
- DialogsMessages.RegularExpression_Enter,
- initialValue, fValidator);
+ super(shell, DialogsMessages.RegularExpression_Validate, DialogsMessages.RegularExpression_Enter, initialValue,
+ fValidator);
}
/**
@@ -83,14 +82,8 @@ public class RegularExpressionStatusDialog extends InputStatusDialog {
protected Control createDialogArea(Composite parent) {
Control control = super.createDialogArea(parent);
- new ContentAssistCommandAdapter(
- getText(),
- new TextContentAdapter(),
- new FindReplaceDocumentAdapterContentProposalProvider(true),
- null,
- null,
- true);
-
+ new ContentAssistCommandAdapter(getText(), new TextContentAdapter(),
+ new FindReplaceDocumentAdapterContentProposalProvider(true), null, null, true);
setHelpAvailable(false);
return control;
@@ -102,7 +95,7 @@ public class RegularExpressionStatusDialog extends InputStatusDialog {
@Override
public void create() {
super.create();
- if (getValue().length()>0)
+ if (getValue().length() > 0)
validateInput();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java
index 42496eeae42..565023b9dbf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.dialogs;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -129,7 +128,7 @@ public abstract class TabFolderOptionBlock {
@Override
public void widgetSelected(SelectionEvent e) {
if (!initializingTabs) {
- setCurrentPage((ICOptionPage) ((TabItem)e.item).getData());
+ setCurrentPage((ICOptionPage) ((TabItem) e.item).getData());
fParent.updateContainer();
}
}
@@ -165,9 +164,8 @@ public abstract class TabFolderOptionBlock {
try {
tab.performApply(new SubProgressMonitor(monitor, 1));
} catch (CoreException e) {
- CUIPlugin.errorDialog(
- composite.getShell(),
- CUIMessages.TabFolderOptionBlock_error, CUIMessages.TabFolderOptionBlock_error_settingOptions, e, true);
+ CUIPlugin.errorDialog(composite.getShell(), CUIMessages.TabFolderOptionBlock_error,
+ CUIMessages.TabFolderOptionBlock_error_settingOptions, e, true);
return false;
}
}
@@ -195,13 +193,12 @@ public abstract class TabFolderOptionBlock {
ICOptionPage tab = iter.next();
ok = tab.isValid();
if (!ok) {
- String errorMessage = tab.getErrorMessage();
- if (!tab.getControl().isVisible()) {
- setErrorMessage(NLS.bind(
- CUIMessages.TabFolderOptionBlock_error_message, tab.getTitle()));
- } else {
- setErrorMessage(errorMessage);
- }
+ String errorMessage = tab.getErrorMessage();
+ if (!tab.getControl().isVisible()) {
+ setErrorMessage(NLS.bind(CUIMessages.TabFolderOptionBlock_error_message, tab.getTitle()));
+ } else {
+ setErrorMessage(errorMessage);
+ }
break;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallHierarchyProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallHierarchyProvider.java
index d5638c0001c..7112029ccf5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallHierarchyProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallHierarchyProvider.java
@@ -42,8 +42,7 @@ public interface ICallHierarchyProvider {
* @param result the accumulator to add the results to
* @throws CoreException may be thrown in case of an error
*/
- void findCalledBy(ICElement callee, int linkageID, IIndex index, ICalledByResult result)
- throws CoreException;
+ void findCalledBy(ICElement callee, int linkageID, IIndex index, ICalledByResult result) throws CoreException;
/**
* Adds the called functions and the corresponding call points for a function defined in a file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/IExternalSearchProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/IExternalSearchProvider.java
index b7876337277..05ef577c955 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/IExternalSearchProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/IExternalSearchProvider.java
@@ -55,8 +55,8 @@ public interface IExternalSearchProvider {
*
* @see {@link IIndex#findNames(IBinding, int)}
*/
- void findNames(IBinding binding, int flags, ICProject[] projects, IIndex index,
- List<IIndexName> foundNames) throws CoreException;
+ void findNames(IBinding binding, int flags, ICProject[] projects, IIndex index, List<IIndexName> foundNames)
+ throws CoreException;
/**
* Finds the function or the class enclosing the given name.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
index ef6e6a6e328..3363f5a7eed 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
@@ -121,15 +121,15 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
public static final int TRI_NO = 0;
protected static final String ENUM = "enum"; //$NON-NLS-1$
- protected static final String SSET = "set"; //$NON-NLS-1$
+ protected static final String SSET = "set"; //$NON-NLS-1$
private PageBook pageBook; // to select between background and usercomp.
- private CLabel background;
+ private CLabel background;
private Composite userdata;
protected Composite usercomp; // space where user can create widgets
protected Composite buttoncomp; // space for buttons on the right
- private Button[] buttons; // buttons in buttoncomp
+ private Button[] buttons; // buttons in buttoncomp
public ICPropertyProvider page;
protected Image icon = null;
private String helpId = EMPTY_STR;
@@ -157,18 +157,18 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
background.setText(EMPTY_STR);
GridData gd;
- userdata= new Composite(pageBook, SWT.NONE);
+ userdata = new Composite(pageBook, SWT.NONE);
userdata.setLayout(new GridLayout(2, false));
usercomp = new Composite(userdata, SWT.NONE);
- usercomp.setLayoutData(gd= new GridData(GridData.FILL_BOTH));
- gd.widthHint= 150;
+ usercomp.setLayoutData(gd = new GridData(GridData.FILL_BOTH));
+ gd.widthHint = 150;
buttoncomp = new Composite(userdata, SWT.NONE);
- buttoncomp.setLayoutData(gd= new GridData(GridData.END));
+ buttoncomp.setLayoutData(gd = new GridData(GridData.END));
// width hint must be set to one, otherwise subclasses that do not have buttons
// don't look pretty, bug 242408
- gd.widthHint= 1;
+ gd.widthHint = 1;
pageBook.showPage(userdata);
@@ -181,10 +181,11 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
* @param names : array of button names
* null instead of name means "skip place"
*/
- protected void initButtons(String[] names) {
+ protected void initButtons(String[] names) {
initButtons(buttoncomp, names, 80);
}
- protected void initButtons(String[] names, int width) {
+
+ protected void initButtons(String[] names, int width) {
initButtons(buttoncomp, names, width);
}
@@ -196,12 +197,14 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
protected void initButtons(Composite c, String[] names) {
initButtons(c, names, 80);
}
+
protected void initButtons(Composite c, String[] names, int width) {
- if (names == null || names.length == 0) return;
+ if (names == null || names.length == 0)
+ return;
c.setLayoutData(new GridData(GridData.FILL_VERTICAL));
c.setLayout(new GridLayout(1, false));
buttons = new Button[names.length];
- for (int i=0; i<names.length; i++) {
+ for (int i = 0; i < names.length; i++) {
buttons[i] = new Button(c, SWT.PUSH);
GridData gdb = new GridData(GridData.VERTICAL_ALIGN_CENTER);
gdb.grabExcessHorizontalSpace = false;
@@ -231,7 +234,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
* @param cfg - selected configuration
*/
private void configChanged(ICResourceDescription cfg) {
- if (visible) updateData(cfg);
+ if (visible)
+ updateData(cfg);
}
/**
@@ -248,7 +252,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
*/
public void setVisible(boolean _visible) {
visible = _visible;
- if (visible) updateData(page.getResDesc());
+ if (visible)
+ updateData(page.getResDesc());
}
/**
@@ -261,17 +266,24 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
* @param dst
*/
protected abstract void performApply(ICResourceDescription src, ICResourceDescription dst);
+
protected abstract void performDefaults();
+
protected abstract void updateData(ICResourceDescription cfg);
+
protected abstract void updateButtons();
- protected void performCancel() {}
- protected void performOK() {}
+
+ protected void performCancel() {
+ }
+
+ protected void performOK() {
+ }
/**
* @param e - event to be handled
*/
private void buttonPressed(SelectionEvent e) {
- for (int i=0; i<buttons.length; i++) {
+ for (int i = 0; i < buttons.length; i++) {
if (buttons[i].equals(e.widget)) {
buttonPressed(i);
return;
@@ -286,7 +298,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
* Does nothing by default.
* May (but not must) be overridden.
*/
- protected void buttonPressed(int i) {}
+ protected void buttonPressed(int i) {
+ }
/**
* Checks state of existing button.
@@ -295,7 +308,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
* @return - true if button exists and enabled
*/
protected boolean buttonIsEnabled(int i) {
- if (buttons == null || buttons.length <= i )
+ if (buttons == null || buttons.length <= i)
return false;
return buttons[i].isEnabled();
}
@@ -308,7 +321,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
* @param state - required state
*/
protected void buttonSetEnabled(int i, boolean state) {
- if (buttons == null || buttons.length <= i ) return;
+ if (buttons == null || buttons.length <= i)
+ return;
buttons[i].setEnabled(state);
}
@@ -320,7 +334,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
* @param text - text to display
*/
protected void buttonSetText(int i, String text) {
- if (buttons == null || buttons.length <= i ) return;
+ if (buttons == null || buttons.length <= i)
+ return;
buttons[i].setText(text);
Composite c = buttons[i].getParent();
if (c != null) {
@@ -345,7 +360,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
Button b = new Button(c, SWT.PUSH);
b.setText(name);
setupControl(b, span, mode);
- GridData g = (GridData)b.getLayoutData();
+ GridData g = (GridData) b.getLayoutData();
g.minimumWidth = BUTTON_WIDTH;
g.horizontalAlignment = SWT.RIGHT;
b.setLayoutData(g);
@@ -414,15 +429,17 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
*/
public static String getFileSystemDirDialog(Shell shell, String text) {
- DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN|SWT.APPLICATION_MODAL);
- if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
+ DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN | SWT.APPLICATION_MODAL);
+ if (text != null && text.trim().length() != 0)
+ dialog.setFilterPath(text);
dialog.setMessage(FILESYSTEM_DIR_DIALOG_MSG);
return dialog.open();
}
public static String getFileSystemFileDialog(Shell shell, String text) {
FileDialog dialog = new FileDialog(shell);
- if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
+ if (text != null && text.trim().length() != 0)
+ dialog.setFilterPath(text);
dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE);
return dialog.open();
}
@@ -432,7 +449,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
*/
public static String getFileSystemFileDialog(Shell shell, String text, String[] filter) {
FileDialog dialog = new FileDialog(shell);
- if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
+ if (text != null && text.trim().length() != 0)
+ dialog.setFilterPath(text);
dialog.setFilterExtensions(filter);
dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE);
return dialog.open();
@@ -446,8 +464,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
if (dialog.open() == Window.OK) {
Object[] selected = dialog.getResult();
if (selected.length > 0) {
- String s = ((ICdtVariable)selected[0]).getName();
- return "${"+s.trim()+"}"; //$NON-NLS-1$//$NON-NLS-2$
+ String s = ((ICdtVariable) selected[0]).getName();
+ return "${" + s.trim() + "}"; //$NON-NLS-1$//$NON-NLS-2$
}
}
return null;
@@ -456,15 +474,18 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
public static String getWorkspaceDirDialog(Shell shell, String text) {
return getWorkspaceDialog(shell, text, true, null);
}
+
public static String getWorkspaceFileDialog(Shell shell, String text) {
return getWorkspaceDialog(shell, text, false, null);
}
+
/**
* @since 5.4
*/
public static String getProjectDirDialog(Shell shell, String text, IProject prj) {
return getWorkspaceDialog(shell, text, true, prj);
}
+
/**
* @since 5.4
*/
@@ -480,8 +501,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
currentPathText = currentPathText.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$
path = new Path(currentPathText);
- ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
- new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(),
+ new WorkbenchContentProvider());
if (prj == null)
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
@@ -489,11 +510,11 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
dialog.setInput(prj);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
- if (dir) {
+ if (dir) {
IResource container = null;
- if(path.isAbsolute()){
+ if (path.isAbsolute()) {
IContainer cs[] = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(path);
- if(cs != null && cs.length > 0)
+ if (cs != null && cs.length > 0)
container = cs[0];
}
dialog.setInitialSelection(container);
@@ -511,8 +532,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG);
} else {
IResource resource = null;
- if(path.isAbsolute()){
- resource= ResourceLookup.selectFileForLocation(path, prj);
+ if (path.isAbsolute()) {
+ resource = ResourceLookup.selectFileForLocation(path, prj);
}
dialog.setInitialSelection(resource);
dialog.setValidator(new ISelectionStatusValidator() {
@@ -547,16 +568,19 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
* Common event handler: called by parent for each tab
*/
@Override
- public void handleTabEvent (int kind, Object data) {
- switch(kind) {
+ public void handleTabEvent(int kind, Object data) {
+ switch (kind) {
case ICPropertyTab.OK:
- if (canBeVisible()) performOK();
+ if (canBeVisible())
+ performOK();
break;
case ICPropertyTab.APPLY:
- if (canBeVisible()) performApply(getResDesc(), (ICResourceDescription)data);
+ if (canBeVisible())
+ performApply(getResDesc(), (ICResourceDescription) data);
break;
case ICPropertyTab.CANCEL:
- if (canBeVisible()) performCancel();
+ if (canBeVisible())
+ performCancel();
break;
case ICPropertyTab.DEFAULTS:
if (canBeVisible() /*&& getResDesc() != null*/) {
@@ -568,10 +592,9 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
if (canSupportMultiCfg() || !page.isMultiCfg()) {
if (canBeVisible()) {
setButtonVisible(true);
- configChanged((ICResourceDescription)data);
+ configChanged((ICResourceDescription) data);
}
- }
- else
+ } else
setAllVisible(false, null);
break;
case ICPropertyTab.DISPOSE:
@@ -582,15 +605,13 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
if (canBeVisible()) {
setVisible(data != null);
setButtonVisible(data != null);
- }
- else
+ } else
setVisible(false);
- }
- else
+ } else
setAllVisible(false, null);
break;
case ICPropertyTab.SET_ICON:
- icon = (Image)data;
+ icon = (Image) data;
break;
default:
break;
@@ -607,9 +628,9 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
/**
* Method to be implemented by inherited classes to indicate whether or not the tab supports displaying
* and editing settings for multiple configuration selection.
- *
+ *
* Default implementation returns true.
- *
+ *
* @return true if the tab supports multiple configurations, false otherwise
* @since 5.7
*/
@@ -619,7 +640,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
/**
* Returns true if this tab is the one currently selected in the UI.
- *
+ *
* @return true if this tab is the one selected in the UI, false otherwise.
* @since 5.7
*/
@@ -628,6 +649,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
return ((ICPropertyProvider2) page).getSelectedTab() == this;
return false;
}
+
/**
* Added to avoid usage PixelConverter class.
* @param control
@@ -636,7 +658,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
public static FontMetrics getFontMetrics(Control control) {
GC gc = new GC(control);
gc.setFont(control.getFont());
- FontMetrics fFontMetrics= gc.getFontMetrics();
+ FontMetrics fFontMetrics = gc.getFontMetrics();
gc.dispose();
return fFontMetrics;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java
index 733d2cd9a5b..fd9ccbb7205 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java
@@ -64,9 +64,9 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
protected static final LanguageManager lm = LanguageManager.getInstance();
protected static final IContentTypeManager ctm = Platform.getContentTypeManager();
-// protected boolean showBI = false;
-// boolean savedShowBI = false;
-// List incs;
+ // protected boolean showBI = false;
+ // boolean savedShowBI = false;
+ // List incs;
public static final Image IMG_FS = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM);
public static final Image IMG_WS = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE);
@@ -82,13 +82,13 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
static {
ILanguage[] ls = lm.getRegisteredLanguages();
names_ls = new String[ls.length];
- for (int i=0; i<ls.length; i++) {
+ for (int i = 0; i < ls.length; i++) {
names_l.put(ls[i].getName(), ls[i].getId());
names_ls[i] = ls[i].getName();
}
String[] ids = lm.getRegisteredContentTypeIds();
names_ts = new String[ids.length];
- for (int i=0; i<ids.length; i++) {
+ for (int i = 0; i < ids.length; i++) {
IContentType ct = ctm.getContentType(ids[i]);
names_t.put(ct.getName(), ct.getId());
names_ts[i] = ct.getName();
@@ -100,81 +100,90 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
public void createControls(Composite parent) {
super.createControls(parent);
usercomp.setLayout(new GridLayout(2, false));
- table = new Table(usercomp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.minimumWidth = 255;
- table.setLayoutData(gd);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
+ table = new Table(usercomp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.minimumWidth = 255;
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
- tv = new TableViewer(table);
+ tv = new TableViewer(table);
tv.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- return (Object[])inputElement;
+ return (Object[]) inputElement;
}
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
});
- tv.setLabelProvider(new RichLabelProvider());
+ tv.setLabelProvider(new RichLabelProvider());
- table.addSelectionListener(new SelectionAdapter() {
- @Override
+ table.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- updateButtons();
- }
- @Override
+ updateButtons();
+ }
+
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {
- if (buttonIsEnabled(1) && table.getSelectionIndex() != -1)
- buttonPressed(1);
- }
- });
- TableColumn c = new TableColumn(table, SWT.NONE);
- c.setWidth(hasValues() ? 100 : 200);
- c.setText(Messages.EnvDialog_0);
- c = new TableColumn(table, SWT.NONE);
- c.setWidth(hasValues() ? 100 : 0);
- c.setText(Messages.EnvDialog_1);
- c = new TableColumn(table, SWT.NONE);
- c.setWidth(100);
- c.setText(Messages.LanguagesTab_1);
- c = new TableColumn(table, SWT.NONE);
- c.setWidth(100);
- c.setText(Messages.LanguagesTab_0);
-
- initButtons(new String[] {ADD_STR, EDIT_STR, DEL_STR});
- updateData(getResDesc());
+ if (buttonIsEnabled(1) && table.getSelectionIndex() != -1)
+ buttonPressed(1);
+ }
+ });
+ TableColumn c = new TableColumn(table, SWT.NONE);
+ c.setWidth(hasValues() ? 100 : 200);
+ c.setText(Messages.EnvDialog_0);
+ c = new TableColumn(table, SWT.NONE);
+ c.setWidth(hasValues() ? 100 : 0);
+ c.setText(Messages.EnvDialog_1);
+ c = new TableColumn(table, SWT.NONE);
+ c.setWidth(100);
+ c.setText(Messages.LanguagesTab_1);
+ c = new TableColumn(table, SWT.NONE);
+ c.setWidth(100);
+ c.setText(Messages.LanguagesTab_0);
+
+ initButtons(new String[] { ADD_STR, EDIT_STR, DEL_STR });
+ updateData(getResDesc());
}
-
- /**
- * Updates state of add/edit/delete buttons
- * Called when table selection changes.
- */
- @Override
+ /**
+ * Updates state of add/edit/delete buttons
+ * Called when table selection changes.
+ */
+ @Override
protected void updateButtons() {
- int i = table.getSelectionIndex();
+ int i = table.getSelectionIndex();
boolean x = i != -1;
boolean y = x;
if (x) {
- ICSettingEntry ent = ((ExtData)(table.getItem(i).getData())).entry;
- if (ent.isReadOnly()) x = false;
- if (ent.isBuiltIn() || ent.isReadOnly()) y = false;
+ ICSettingEntry ent = ((ExtData) (table.getItem(i).getData())).entry;
+ if (ent.isReadOnly())
+ x = false;
+ if (ent.isBuiltIn() || ent.isReadOnly())
+ y = false;
}
- buttonSetEnabled(1, x);
- buttonSetEnabled(2, y);
- }
+ buttonSetEnabled(1, x);
+ buttonSetEnabled(2, y);
+ }
/*
* Methods to be implemented in descendants
*/
public abstract int getKind();
+
public abstract ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp);
+
public abstract ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp);
+
public abstract boolean hasValues();
/**
@@ -183,7 +192,8 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
*/
protected void update() {
int x = table.getSelectionIndex();
- if (x == -1) x = 0;
+ if (x == -1)
+ x = 0;
namesList = new ArrayList<String>();
ArrayList<ExtData> lst = new ArrayList<ExtData>();
@@ -195,7 +205,8 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
}
for (ICExternalSetting v : vals) {
ICSettingEntry[] ents = v.getEntries(getKind());
- if (ents == null || ents.length == 0) continue;
+ if (ents == null || ents.length == 0)
+ continue;
for (ICSettingEntry se : ents) {
lst.add(new ExtData(v, se));
namesList.add(se.getName());
@@ -203,8 +214,10 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
}
Collections.sort(lst, CDTListComparator.getInstance());
tv.setInput(lst.toArray(new Object[lst.size()]));
- if (table.getItemCount() > x) table.select(x);
- else if (table.getItemCount() > 0) table.select(0);
+ if (table.getItemCount() > x)
+ table.select(x);
+ else if (table.getItemCount() > 0)
+ table.select(0);
updateButtons();
}
@@ -214,7 +227,8 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
*/
@Override
public void updateData(ICResourceDescription rcfg) {
- if (rcfg == null) return;
+ if (rcfg == null)
+ return;
if (page.isMultiCfg()) {
setAllVisible(false, null);
} else {
@@ -224,6 +238,7 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
update();
}
}
+
/**
* Unified "Add/Edit/Delete" buttons handler
*/
@@ -236,8 +251,7 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
switch (i) {
case 0: // add
- dlg = new ExpDialog(usercomp.getShell(), true,
- Messages.AbstractExportTab_2, EMPTY_STR, EMPTY_STR, cfg,
+ dlg = new ExpDialog(usercomp.getShell(), true, Messages.AbstractExportTab_2, EMPTY_STR, EMPTY_STR, cfg,
null, null, getKind(), names_ls, names_ts, namesList, false);
if (dlg.open()) {
ent[0] = doAdd(dlg.text1.trim(), dlg.text2.trim(), dlg.check2);
@@ -245,19 +259,21 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
if (dlg.check1) { // apply to all ?
ICConfigurationDescription[] cfgs = page.getCfgsEditable();
for (ICConfigurationDescription cfg2 : cfgs)
- cfg2.createExternalSetting(name2id(dlg.sel_langs, names_l),
- name2id(dlg.sel_types, names_t), null, ent);
+ cfg2.createExternalSetting(name2id(dlg.sel_langs, names_l), name2id(dlg.sel_types, names_t),
+ null, ent);
} else {
- cfg.createExternalSetting(name2id(dlg.sel_langs, names_l),
- name2id(dlg.sel_types, names_t), null, ent);
+ cfg.createExternalSetting(name2id(dlg.sel_langs, names_l), name2id(dlg.sel_types, names_t),
+ null, ent);
}
update();
}
break;
case 1: // edit
- if (n == -1) return;
- old = (ExtData)(table.getItem(n).getData());
- if (old.entry.isReadOnly()) return;
+ if (n == -1)
+ return;
+ old = (ExtData) (table.getItem(n).getData());
+ if (old.entry.isReadOnly())
+ return;
String s1, s2;
if (getKind() == ICSettingEntry.MACRO) {
s1 = old.getName();
@@ -265,40 +281,44 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab {
} else
s1 = s2 = old.getName();
boolean isWsp = (old.entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
- dlg = new ExpDialog(usercomp.getShell(), false,
- Messages.AbstractExportTab_3, s1, s2, cfg,
+ dlg = new ExpDialog(usercomp.getShell(), false, Messages.AbstractExportTab_3, s1, s2, cfg,
id2name(old.setting.getCompatibleLanguageIds(), names_l),
- id2name(old.setting.getCompatibleContentTypeIds(), names_t),
- getKind(), names_ls, names_ts, null, isWsp);
+ id2name(old.setting.getCompatibleContentTypeIds(), names_t), getKind(), names_ls, names_ts, null,
+ isWsp);
if (dlg.open()) {
ent[0] = doEdit(dlg.text1.trim(), dlg.text2.trim(), dlg.check2);
ICSettingEntry[] ls = old.setting.getEntries();
ICSettingEntry[] ls2 = new ICLanguageSettingEntry[ls.length];
- for (int x=0; x<ls.length; x++)
- if (ls[x].equals(old.entry)) ls2[x] = ent[0];
- else ls2[x] = ls[x];
+ for (int x = 0; x < ls.length; x++)
+ if (ls[x].equals(old.entry))
+ ls2[x] = ent[0];
+ else
+ ls2[x] = ls[x];
cfg.removeExternalSetting(old.setting);
cfg.createExternalSetting(name2id(dlg.sel_langs, names_l), name2id(dlg.sel_types, names_t), null, ls2);
update();
}
break;
case 2: // delete
- if (n == -1) return;
+ if (n == -1)
+ return;
TableItem[] its = table.getSelection();
boolean checked[] = new boolean[its.length];
- for (int t=0; t<its.length; t++) {
- if (checked[t] || its[t] == null) continue;
- old = (ExtData)(its[t].getData());
- if (old.entry.isReadOnly() || old.entry.isBuiltIn()) continue;
+ for (int t = 0; t < its.length; t++) {
+ if (checked[t] || its[t] == null)
+ continue;
+ old = (ExtData) (its[t].getData());
+ if (old.entry.isReadOnly() || old.entry.isBuiltIn())
+ continue;
ICSettingEntry[] ls = old.setting.getEntries(getKind());
ArrayList<ICSettingEntry> lst = new ArrayList<ICSettingEntry>();
-outer:
- for (ICSettingEntry se : ls) {
- for (int y=t; y<its.length; y++) {
- if (its[y] == null) break;
+ outer: for (ICSettingEntry se : ls) {
+ for (int y = t; y < its.length; y++) {
+ if (its[y] == null)
+ break;
Object ob = its[y].getData();
if (ob != null && (ob instanceof ExtData)) {
- ExtData ex = (ExtData)ob;
+ ExtData ex = (ExtData) ob;
if (se.equals(ex.entry)) {
checked[y] = true;
continue outer;
@@ -314,8 +334,7 @@ outer:
// Remove and re-add the particular setting entry
cfg.removeExternalSetting(old.setting);
cfg.createExternalSetting(old.setting.getCompatibleLanguageIds(),
- old.setting.getCompatibleContentTypeIds(),
- old.setting.getCompatibleExtensions(),
+ old.setting.getCompatibleContentTypeIds(), old.setting.getCompatibleExtensions(),
lst.toArray(new ICSettingEntry[lst.size()]));
}
update();
@@ -328,13 +347,14 @@ outer:
public static String[] name2id(String[] ein, Map<String, String> names) {
if (ein != null)
- for (int k=0; k<ein.length; k++) ein[k] = names.get(ein[k]);
+ for (int k = 0; k < ein.length; k++)
+ ein[k] = names.get(ein[k]);
return ein;
}
public static String[] id2name(String[] ein, Map<String, String> names) {
if (ein != null)
- for (int i=0; i<ein.length; i++) {
+ for (int i = 0; i < ein.length; i++) {
Iterator<String> it = names.keySet().iterator();
while (it.hasNext()) {
String s = it.next();
@@ -354,9 +374,8 @@ outer:
c2.removeExternalSettings();
ICExternalSetting[] v = c1.getExternalSettings();
for (ICExternalSetting element : v)
- c2.createExternalSetting(element.getCompatibleLanguageIds(),
- element.getCompatibleContentTypeIds(),
- element.getCompatibleExtensions(), element.getEntries());
+ c2.createExternalSetting(element.getCompatibleLanguageIds(), element.getCompatibleContentTypeIds(),
+ element.getCompatibleExtensions(), element.getEntries());
}
@Override
@@ -367,34 +386,43 @@ outer:
// setSourceEntries -> ... -> Configuration#setSourceEntries(...) -> Configuration#exportArtifactInfo()
try {
cfg.setSourceEntries(cfg.getSourceEntries());
- } catch (CoreException e) {CUIPlugin.log(e);}
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
updateData(this.getResDesc());
}
// Extended label provider
- private class RichLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
- public RichLabelProvider(){}
+ private class RichLabelProvider extends LabelProvider
+ implements IFontProvider, ITableLabelProvider /*, IColorProvider*/ {
+ public RichLabelProvider() {
+ }
+
@Override
public Image getImage(Object element) {
return getColumnImage(element, 0);
}
+
@Override
public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex > 0) return null;
- ExtData data = (ExtData)element;
+ if (columnIndex > 0)
+ return null;
+ ExtData data = (ExtData) element;
if (data.entry.getKind() == ICSettingEntry.MACRO)
return IMG_MK;
if ((data.entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0)
return IMG_WS;
return IMG_FS;
}
+
@Override
public String getText(Object element) {
return getColumnText(element, 0);
}
+
@Override
public String getColumnText(Object element, int columnIndex) {
- ExtData data = (ExtData)element;
+ ExtData data = (ExtData) element;
switch (columnIndex) {
case 0:
return data.getName();
@@ -411,9 +439,10 @@ outer:
@Override
public Font getFont(Object element) {
- ExtData data = (ExtData)element;
- if (data.entry.isBuiltIn()) return null; // built in
- if (data.entry.isReadOnly()) // read only
+ ExtData data = (ExtData) element;
+ if (data.entry.isBuiltIn())
+ return null; // built in
+ if (data.entry.isReadOnly()) // read only
return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
}
@@ -421,7 +450,7 @@ outer:
@Override
public boolean canBeVisible() {
- if (! page.isForProject() )
+ if (!page.isForProject())
return false;
return true;
}
@@ -437,20 +466,25 @@ outer:
setting = _s;
entry = _e;
}
+
protected String getName() {
return entry.getName();
}
+
protected String getValue() {
if (entry.getKind() == ICSettingEntry.MACRO)
return entry.getValue();
return EMPTY_STR;
}
+
protected String getLangStr() {
return getLabel(setting.getCompatibleLanguageIds(), names_l);
}
+
protected String getTypeStr() {
return getLabel(setting.getCompatibleContentTypeIds(), names_t);
}
+
@Override
public String toString() {
return getName();
@@ -458,8 +492,10 @@ outer:
}
static protected String getLabel(String[] lst, Map<String, String> names) {
- if (lst == null || lst.length == 0) return ALL;
- if (lst.length > 1) return LIST;
+ if (lst == null || lst.length == 0)
+ return ALL;
+ if (lst.length > 1)
+ return LIST;
Iterator<String> it = names.keySet().iterator();
while (it.hasNext()) {
String s = it.next();
@@ -468,15 +504,16 @@ outer:
}
return lst[0];
}
+
static protected String getList(String[] lst) {
String s = EMPTY_STR;
for (String element : lst)
s = s + element + '\n';
return s;
}
+
static public Image getWspImage(boolean isWsp) {
return isWsp ? AbstractExportTab.IMG_WS : AbstractExportTab.IMG_FS;
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java
index e3b144c67ae..c901fc4227f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java
@@ -101,7 +101,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
/** A set of resolved exported entries */
protected ArrayList<ICSettingEntry> exported;
protected SashForm sashForm;
- protected ICLanguageSetting [] ls; // all languages known
+ protected ICLanguageSetting[] ls; // all languages known
private boolean fHadSomeModification;
private StringListModeControl stringListModeControl;
@@ -114,21 +114,9 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
private static final int BUTTON_MOVE_UP = 5;
private static final int BUTTON_MOVE_DOWN = 6;
- protected final static String[] BUTTONS = {
- ADD_STR,
- EDIT_STR,
- DEL_STR,
- Messages.AbstractLangsListTab_Export,
- null,
- MOVEUP_STR,
- MOVEDOWN_STR
- };
- protected final static String[] BUTTSYM = {
- ADD_STR,
- EDIT_STR,
- DEL_STR,
- Messages.AbstractLangsListTab_Export
- };
+ protected final static String[] BUTTONS = { ADD_STR, EDIT_STR, DEL_STR, Messages.AbstractLangsListTab_Export, null,
+ MOVEUP_STR, MOVEDOWN_STR };
+ protected final static String[] BUTTSYM = { ADD_STR, EDIT_STR, DEL_STR, Messages.AbstractLangsListTab_Export };
private static final Comparator<Object> comp = CDTListComparator.getInstance();
private static String selectedLanguage;
@@ -141,7 +129,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
usercomp.setLayout(new GridLayout(2, false));
GridData gd = (GridData) usercomp.getLayoutData();
// Discourage settings entry table from trying to show all its items at once, see bug 264330
- gd.heightHint =1;
+ gd.heightHint = 1;
// Create the sash form
sashForm = new SashForm(usercomp, SWT.NONE);
@@ -185,12 +173,16 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
tv.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- return (Object[])inputElement;
+ return (Object[]) inputElement;
}
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
});
tv.setLabelProvider(new LanguageSettingsEntriesLabelProvider());
@@ -214,10 +206,12 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
public void controlMoved(ControlEvent e) {
setColumnToFit();
}
+
@Override
public void controlResized(ControlEvent e) {
setColumnToFit();
- }});
+ }
+ });
fStatusLine = new StatusMessageLine(usercomp, SWT.LEFT, 2);
@@ -248,10 +242,10 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
*/
private ICLanguageSettingEntry getSelectedEntry() {
int index = table.getSelectionIndex();
- if (index<0 || table.getSelectionIndices().length!=1)
+ if (index < 0 || table.getSelectionIndices().length != 1)
return null;
- return (ICLanguageSettingEntry)(table.getItem(index).getData());
+ return (ICLanguageSettingEntry) (table.getItem(index).getData());
}
/**
@@ -274,11 +268,14 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
IStatus status = LanguageSettingsImages.getStatus(getSelectedEntry(), cfgDescription);
if (cfgDescription != null && (status == null || status.isOK())) {
IProject project = cfgDescription.getProjectDescription().getProject();
- boolean isEnabled = !LanguageSettingsProvidersPage.isLanguageSettingsProvidersEnabled(project) || ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
+ boolean isEnabled = !LanguageSettingsProvidersPage.isLanguageSettingsProvidersEnabled(project)
+ || ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
if (!isEnabled) {
- status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.AbstractLangsListTab_MbsProviderNotEnabled);
+ status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID,
+ Messages.AbstractLangsListTab_MbsProviderNotEnabled);
} else if (LanguageSettingsProvidersPage.isLanguageSettingsProvidersEnabled(project)) {
- status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.AbstractLangsListTab_LspPageMayDefineAdditionalEntries);
+ status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID,
+ Messages.AbstractLangsListTab_LspPageMayDefineAdditionalEntries);
}
}
@@ -299,9 +296,11 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
boolean canDelete = canExport;
ICLanguageSettingEntry ent = null;
if (canExport) {
- ent = (ICLanguageSettingEntry)(table.getItem(index).getData());
- if (ent.isReadOnly()) canEdit = false;
- if (ent.isReadOnly()) canDelete = false;
+ ent = (ICLanguageSettingEntry) (table.getItem(index).getData());
+ if (ent.isReadOnly())
+ canEdit = false;
+ if (ent.isReadOnly())
+ canDelete = false;
if (exported.contains(resolve(ent)))
buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_Unexport);
else
@@ -316,8 +315,9 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
canMoveDown = canEdit && (index < table.getItemCount() - 1) && !ent.isBuiltIn();
}
if (canMoveDown && showBIButton.getSelection()) {
- ent = (ICLanguageSettingEntry)(table.getItem(index+1).getData());
- if (ent.isBuiltIn()) canMoveDown = false; // cannot exchange with built in
+ ent = (ICLanguageSettingEntry) (table.getItem(index + 1).getData());
+ if (ent.isBuiltIn())
+ canMoveDown = false; // cannot exchange with built in
}
buttonSetEnabled(BUTTON_ADD, canAdd);
buttonSetEnabled(BUTTON_EDIT, canEdit);
@@ -368,9 +368,13 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
* Methods to be implemented in descendants
*/
public abstract int getKind();
+
public abstract ICLanguageSettingEntry doAdd();
+
public abstract ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent);
- public void additionalTableSet() {} // may be not overwritten
+
+ public void additionalTableSet() {
+ } // may be not overwritten
/**
* Called when language changed or item added/edited/removed.
@@ -378,18 +382,24 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
*
* Note, this method is rewritten in Symbols tab.
*/
- public void update() { update(0); }
+ public void update() {
+ update(0);
+ }
public void update(int shift) {
if (lang != null) {
int x = table.getSelectionIndex();
- if (x == -1) x = 0;
- else x += shift; // used only for UP/DOWN
+ if (x == -1)
+ x = 0;
+ else
+ x += shift; // used only for UP/DOWN
shownEntries = getIncs();
tv.setInput(shownEntries.toArray(new Object[shownEntries.size()]));
- if (table.getItemCount() > x) table.setSelection(x);
- else if (table.getItemCount() > 0) table.setSelection(0);
+ if (table.getItemCount() > x)
+ table.setSelection(x);
+ else if (table.getItemCount() > 0)
+ table.setSelection(0);
}
updateStringListModeControl();
@@ -414,14 +424,14 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
return l;
}
-
/**
* Called when configuration changed
* Refreshes languages list and calls table refresh.
*/
@Override
public void updateData(ICResourceDescription rcDes) {
- if (rcDes == null || !canBeVisible()) return;
+ if (rcDes == null || !canBeVisible())
+ return;
updateExport();
langTree.removeAll();
TreeItem selectedItem = null;
@@ -434,8 +444,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
String langId = getLanguageName(langSetting);
t.setText(0, langId);
t.setData(langSetting);
- if (selectedItem == null
- || (selectedLanguage != null && selectedLanguage.equals(langId))) {
+ if (selectedItem == null || (selectedLanguage != null && selectedLanguage.equals(langId))) {
selectedItem = t;
lang = langSetting;
}
@@ -471,7 +480,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (!(extSettings == null || extSettings.length == 0)) {
for (ICExternalSetting extSetting : extSettings) {
ICSettingEntry[] entries = extSetting.getEntries(getKind());
- if (entries == null || entries.length == 0) continue;
+ if (entries == null || entries.length == 0)
+ continue;
for (ICSettingEntry entry : entries)
exported.add(entry);
}
@@ -480,8 +490,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
private void performAdd(ICLanguageSettingEntry entry) {
if (entry != null) {
- fHadSomeModification= true;
- if ((toAllCfgs || toAllLang) && ! (getResDesc() instanceof ICMultiResourceDescription)) {
+ fHadSomeModification = true;
+ if ((toAllCfgs || toAllLang) && !(getResDesc() instanceof ICMultiResourceDescription)) {
addToAll(entry);
} else {
if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) {
@@ -519,12 +529,11 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
* @param del - entry to delete
*/
private void performMulti(ICLanguageSettingEntry ent, ICLanguageSettingEntry del) {
- MultiLanguageSetting ms = (MultiLanguageSetting)lang;
- ICLanguageSetting[] langSettings = (ICLanguageSetting[])ms.getItems();
+ MultiLanguageSetting ms = (MultiLanguageSetting) lang;
+ ICLanguageSetting[] langSettings = (ICLanguageSetting[]) ms.getItems();
ICLanguageSettingEntry[][] es = ms.getSettingEntriesM(getKind());
- for (int i=0; i<langSettings.length; i++) {
- List<ICLanguageSettingEntry> entries =
- new ArrayList<ICLanguageSettingEntry>(Arrays.asList(es[i]));
+ for (int i = 0; i < langSettings.length; i++) {
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(Arrays.asList(es[i]));
if (del != null) {
for (ICLanguageSettingEntry entry : entries) {
if (entry.getName().equals(del.getName())) {
@@ -540,13 +549,15 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
}
private void performEdit(int n) {
- if (n == -1) return;
- ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(n).getData());
- if (old.isReadOnly()) return;
+ if (n == -1)
+ return;
+ ICLanguageSettingEntry old = (ICLanguageSettingEntry) (table.getItem(n).getData());
+ if (old.isReadOnly())
+ return;
ICLanguageSettingEntry ent = doEdit(old);
toAllLang = false;
if (ent != null) {
- fHadSomeModification= true;
+ fHadSomeModification = true;
if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) {
performMulti(ent, old);
} else {
@@ -561,19 +572,20 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
}
private void performDelete(int n) {
- if (n == -1) return;
- fHadSomeModification= true;
+ if (n == -1)
+ return;
+ fHadSomeModification = true;
int[] ids = table.getSelectionIndices();
if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) {
- for (int x=ids.length-1; x>=0; x--) {
- ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(ids[x]).getData());
- performMulti(null, old);
+ for (int x = ids.length - 1; x >= 0; x--) {
+ ICLanguageSettingEntry old = (ICLanguageSettingEntry) (table.getItem(ids[x]).getData());
+ performMulti(null, old);
}
} else {
ICLanguageSettingEntry[] del = new ICLanguageSettingEntry[ids.length];
- for (int x=ids.length-1; x>=0; x--) {
- ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(ids[x]).getData());
-// if (old.isReadOnly()) continue;
+ for (int x = ids.length - 1; x >= 0; x--) {
+ ICLanguageSettingEntry old = (ICLanguageSettingEntry) (table.getItem(ids[x]).getData());
+ // if (old.isReadOnly()) continue;
del[x] = old;
}
changeIt(null, del);
@@ -581,6 +593,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
update();
}
+
/**
* Unified buttons handler
*/
@@ -603,13 +616,15 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
performDelete(n);
break;
case BUTTON_EXPORT_UNEXPORT:
- if (n == -1) return;
- for (int x=ids.length-1; x>=0; x--) {
- old = resolve((ICLanguageSettingEntry)(table.getItem(ids[x]).getData()));
+ if (n == -1)
+ return;
+ for (int x = ids.length - 1; x >= 0; x--) {
+ old = resolve((ICLanguageSettingEntry) (table.getItem(ids[x]).getData()));
if (exported.contains(old)) {
deleteExportSetting(old);
} else {
- page.getResDesc().getConfiguration().createExternalSetting(null, null, null, new ICLanguageSettingEntry[] {old});
+ page.getResDesc().getConfiguration().createExternalSetting(null, null, null,
+ new ICLanguageSettingEntry[] { old });
}
}
updateExport();
@@ -617,10 +632,12 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
break;
case BUTTON_MOVE_UP:
case BUTTON_MOVE_DOWN:
- old = (ICLanguageSettingEntry)(table.getItem(n).getData());
+ old = (ICLanguageSettingEntry) (table.getItem(n).getData());
int x = shownEntries.indexOf(old);
- if (x < 0) break;
- if (buttonIndex == BUTTON_MOVE_DOWN) x++; // "down" simply means "up underlying item"
+ if (x < 0)
+ break;
+ if (buttonIndex == BUTTON_MOVE_DOWN)
+ x++; // "down" simply means "up underlying item"
old = shownEntries.get(x);
ICLanguageSettingEntry old2 = shownEntries.get(x - 1);
shownEntries.remove(x);
@@ -641,31 +658,32 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
* @return resolved ICLanguageSettingEntry
*/
private ICLanguageSettingEntry resolve(ICLanguageSettingEntry entry) {
- ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] {entry}, getResDesc().getConfiguration());
+ ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] { entry },
+ getResDesc().getConfiguration());
if (entries.length > 0)
return entries[0];
return entry;
}
private void deleteExportSetting(ICSettingEntry ent) {
-// if (ent.isReadOnly() || ent.isBuiltIn()) continue;
+ // if (ent.isReadOnly() || ent.isBuiltIn()) continue;
ICConfigurationDescription cfg = getResDesc().getConfiguration();
ICExternalSetting[] extSettings = cfg.getExternalSettings();
if (!(extSettings == null || extSettings.length == 0)) {
for (ICExternalSetting extSetting : extSettings) {
ICSettingEntry[] entries = extSetting.getEntries(getKind());
- if (entries == null || entries.length == 0) continue;
- for (int j=0; j<entries.length; j++) {
+ if (entries == null || entries.length == 0)
+ continue;
+ for (int j = 0; j < entries.length; j++) {
if (entries[j].equalsByName(ent)) {
ICSettingEntry[] arr = new ICSettingEntry[entries.length - 1];
int index = 0;
- for (int k=0; k<entries.length; k++)
- if (k != j) arr[index++] = entries[k];
+ for (int k = 0; k < entries.length; k++)
+ if (k != j)
+ arr[index++] = entries[k];
cfg.removeExternalSetting(extSetting);
cfg.createExternalSetting(extSetting.getCompatibleLanguageIds(),
- extSetting.getCompatibleContentTypeIds(),
- extSetting.getCompatibleExtensions(),
- arr);
+ extSetting.getCompatibleContentTypeIds(), extSetting.getCompatibleExtensions(), arr);
return;
}
}
@@ -673,7 +691,6 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
}
}
-
/**
* Adds entry to all configurations
* @param ent - entry to add
@@ -699,15 +716,16 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
@Override
protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
- fHadSomeModification= false;
+ fHadSomeModification = false;
if (page.isMultiCfg()) {
- ICLanguageSetting [] sr = ls;
+ ICLanguageSetting[] sr = ls;
if (dst instanceof ICMultiItemsHolder) {
- for (Object item : ((ICMultiItemsHolder)dst).getItems()) {
+ for (Object item : ((ICMultiItemsHolder) dst).getItems()) {
if (item instanceof ICResourceDescription) {
- ICLanguageSetting [] ds = getLangSetting((ICResourceDescription)item);
- if (ds == null || sr.length != ds.length) return;
- for (int i=0; i<sr.length; i++) {
+ ICLanguageSetting[] ds = getLangSetting((ICResourceDescription) item);
+ if (ds == null || sr.length != ds.length)
+ return;
+ for (int i = 0; i < sr.length; i++) {
ICLanguageSettingEntry[] ents = null;
ents = sr[i].getSettingEntries(getKind());
ds[i].setSettingEntries(getKind(), ents);
@@ -716,10 +734,11 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
}
}
} else {
- ICLanguageSetting [] sr = getLangSetting(src);
- ICLanguageSetting [] ds = getLangSetting(dst);
- if (sr == null || ds == null || sr.length != ds.length) return;
- for (int i=0; i<sr.length; i++) {
+ ICLanguageSetting[] sr = getLangSetting(src);
+ ICLanguageSetting[] ds = getLangSetting(dst);
+ if (sr == null || ds == null || sr.length != ds.length)
+ return;
+ for (int i = 0; i < sr.length; i++) {
ICLanguageSettingEntry[] ents = null;
ents = sr[i].getSettingEntries(getKind());
ds[i].setSettingEntries(getKind(), ents);
@@ -729,19 +748,20 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
@Override
protected void performDefaults() {
- fHadSomeModification= true;
+ fHadSomeModification = true;
TreeItem[] tis = langTree.getItems();
for (TreeItem ti : tis) {
Object ob = ti.getData();
if (ob != null && ob instanceof ICLanguageSetting) {
- ((ICLanguageSetting)ob).setSettingEntries(getKind(), (List<ICLanguageSettingEntry>)null);
+ ((ICLanguageSetting) ob).setSettingEntries(getKind(), (List<ICLanguageSettingEntry>) null);
}
}
updateData(this.getResDesc());
}
// Extended label provider
- private class LanguageSettingsEntriesLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
+ private class LanguageSettingsEntriesLabelProvider extends LabelProvider
+ implements IFontProvider, ITableLabelProvider /*, IColorProvider*/ {
@Override
public Image getImage(Object element) {
return getColumnImage(element, 0);
@@ -749,7 +769,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
@Override
public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex==0 && (element instanceof ICLanguageSettingEntry)) {
+ if (columnIndex == 0 && (element instanceof ICLanguageSettingEntry)) {
ICConfigurationDescription cfg = getResDesc().getConfiguration();
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, cfg);
}
@@ -774,7 +794,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
case 1:
if (entry.getKind() == ICSettingEntry.MACRO) {
return entry.getValue();
- }
+ }
return null;
}
} else if (columnIndex == 0) {
@@ -791,10 +811,10 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (entry.isBuiltIn())
return null;
if (entry.isReadOnly())
- return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
- // normal
- return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
- }
+ return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
+ // normal
+ return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+ }
return null;
}
}
@@ -804,13 +824,13 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
case ICSettingBase.SETTING_PROJECT:
case ICSettingBase.SETTING_CONFIGURATION:
case ICSettingBase.SETTING_FOLDER:
- ICFolderDescription foDes = (ICFolderDescription)rcDes;
+ ICFolderDescription foDes = (ICFolderDescription) rcDes;
if (foDes instanceof ICMultiFolderDescription) {
- return getLS((ICMultiFolderDescription)foDes);
+ return getLS((ICMultiFolderDescription) foDes);
}
return foDes.getLanguageSettings();
case ICSettingBase.SETTING_FILE:
- ICFileDescription fiDes = (ICFileDescription)rcDes;
+ ICFileDescription fiDes = (ICFileDescription) rcDes;
ICLanguageSetting langSetting = fiDes.getLanguageSetting();
return (langSetting != null) ? new ICLanguageSetting[] { langSetting } : null;
}
@@ -823,7 +843,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
ICLanguageSetting[][] lsArray2D = foDes.getLanguageSettingsM(comp);
ICLanguageSetting[] fs = conv2LS(CDTPrefUtil.getListForDisplay(lsArray2D, comp));
lsets = new ICLanguageSetting[fs.length];
- for (int i=0; i<fs.length; i++) {
+ for (int i = 0; i < fs.length; i++) {
ArrayList<ICLanguageSetting> list = new ArrayList<ICLanguageSetting>(lsArray2D.length);
for (ICLanguageSetting[] lsArray : lsArray2D) {
int x = Arrays.binarySearch(lsArray, fs[i], comp);
@@ -838,12 +858,13 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
return lsets;
}
-
@Override
public boolean canBeVisible() {
- if (getResDesc() == null) return true;
- ICLanguageSetting [] langSettings = getLangSetting(getResDesc());
- if (langSettings == null) return false;
+ if (getResDesc() == null)
+ return true;
+ ICLanguageSetting[] langSettings = getLangSetting(getResDesc());
+ if (langSettings == null)
+ return false;
for (ICLanguageSetting element : langSettings) {
if ((element.getSupportedEntryKinds() & getKind()) != 0)
return true;
@@ -853,13 +874,14 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
private void setSettingEntries(int kind, List<ICLanguageSettingEntry> incs, boolean toAll) {
if (page.isMultiCfg()) {
- ((ICMultiResourceDescription)getResDesc()).setSettingEntries(lang, kind, incs, toAll);
+ ((ICMultiResourceDescription) getResDesc()).setSettingEntries(lang, kind, incs, toAll);
} else
lang.setSettingEntries(kind, incs);
}
+
private List<ICLanguageSettingEntry> getSettingEntriesList(int kind) {
if (page.isMultiCfg() && lang instanceof MultiLanguageSetting) {
- ICLanguageSettingEntry[][] lses = ((MultiLanguageSetting)lang).getSettingEntriesM(kind);
+ ICLanguageSettingEntry[][] lses = ((MultiLanguageSetting) lang).getSettingEntriesM(kind);
Object[] res = CDTPrefUtil.getListForDisplay(lses, comp);
ICLanguageSettingEntry[] out = new ICLanguageSettingEntry[res.length];
System.arraycopy(res, 0, out, 0, res.length);
@@ -894,7 +916,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
@Override
protected final boolean isIndexerAffected() {
- switch(getKind()) {
+ switch (getKind()) {
case ICSettingEntry.INCLUDE_PATH:
case ICSettingEntry.MACRO:
case ICSettingEntry.INCLUDE_FILE:
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java
index b9e28495b00..01035ccd216 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java
@@ -126,9 +126,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
* more than 1 tabs refer to this pas as a parent, only 1st
* one would be taken into account, others will be ignored.
*/
-public abstract class AbstractPage extends PropertyPage
-implements
- IPreferencePageContainer, // dynamic pages
+public abstract class AbstractPage extends PropertyPage implements IPreferencePageContainer, // dynamic pages
ICPropertyProvider2 // utility methods for tabs
{
private static ICResourceDescription resd = null;
@@ -147,7 +145,7 @@ implements
private static final String HELPID_NAME = "helpId"; //$NON-NLS-1$
private static final Object NOT_NULL = new Object();
- public static final String EMPTY_STR = ""; //$NON-NLS-1$
+ public static final String EMPTY_STR = ""; //$NON-NLS-1$
private static final int SAVE_MODE_OK = 1;
private static final int SAVE_MODE_APPLY = 2;
@@ -156,8 +154,7 @@ implements
private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$
private Map<URL, Image> loadedIcons = new HashMap<URL, Image>();
- private static Map<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>> recentTabs =
- new HashMap<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>>();
+ private static Map<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>> recentTabs = new HashMap<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>>();
private final Image IMG_WARN = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_WARNING);
/*
@@ -177,8 +174,8 @@ implements
protected boolean displayedConfig = false;
protected IResource internalElement = null;
protected boolean isProject = false;
- protected boolean isFolder = false;
- protected boolean isFile = false;
+ protected boolean isFolder = false;
+ protected boolean isFile = false;
// tabs
protected TabFolder folder;
@@ -195,19 +192,21 @@ implements
ICPropertyTab tab;
InternalTab(Composite _comp, String _text, Image _image, ICPropertyTab _tab, String _tip) {
- comp = _comp;
- text = _text;
+ comp = _comp;
+ text = _text;
image = _image;
- tab = _tab;
- tip = _tip;
+ tab = _tab;
+ tip = _tip;
}
public TabItem createOn(TabFolder f) {
if (tab.canBeVisible()) {
TabItem ti = new TabItem(f, SWT.NONE);
ti.setText(text);
- if (tip != null) ti.setToolTipText(tip);
- if (image != null) ti.setImage(image);
+ if (tip != null)
+ ti.setToolTipText(tip);
+ if (image != null)
+ ti.setImage(image);
ti.setControl(comp);
ti.setData(tab);
return ti;
@@ -236,7 +235,7 @@ implements
compositeLayout.numColumns = 1;
compositeLayout.marginHeight = 0;
compositeLayout.marginWidth = 0;
- composite.setLayout( compositeLayout );
+ composite.setLayout(compositeLayout);
String s = null;
if (!checkElement()) {
@@ -247,10 +246,10 @@ implements
s = Messages.AbstractPage_2;
}
- if (s == null) {
- contentForCDT(composite);
- return composite;
- }
+ if (s == null) {
+ contentForCDT(composite);
+ return composite;
+ }
// no contents
Label label = new Label(composite, SWT.LEFT);
@@ -269,7 +268,7 @@ implements
Group configGroup = ControlFactory.createGroup(composite, EMPTY_STR, 1);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.grabExcessHorizontalSpace = true;
- gd.widthHint= 150;
+ gd.widthHint = 150;
configGroup.setLayoutData(gd);
configGroup.setLayout(new GridLayout(3, false));
@@ -338,7 +337,7 @@ implements
ICResourceDescription rcDescription = getResDesc();
rcDescription.setExcluded(excludeFromBuildCheck.getSelection());
if (currentTab instanceof AbstractCPropertyTab) {
- ((AbstractCPropertyTab)currentTab).updateData(rcDescription);
+ ((AbstractCPropertyTab) currentTab).updateData(rcDescription);
}
}
});
@@ -357,13 +356,13 @@ implements
public void createWidgets(Composite c) {
GridData gd;
parentComposite = new Composite(c, SWT.NONE);
- parentComposite.setLayoutData(gd= new GridData(GridData.FILL_BOTH));
- gd.widthHint= 600;
+ parentComposite.setLayoutData(gd = new GridData(GridData.FILL_BOTH));
+ gd.widthHint = 600;
itabs.clear();
if (!isSingle()) {
parentComposite.setLayout(new FillLayout());
folder = new TabFolder(parentComposite, SWT.NONE);
-// folder.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
+ // folder.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
}
loadExtensionsSynchronized(parentComposite);
@@ -373,7 +372,7 @@ implements
folder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
- if (folder.getSelection().length > 0 ) {
+ if (folder.getSelection().length > 0) {
updateSelectedTab();
}
}
@@ -398,14 +397,16 @@ implements
}
private void updateSelectedTab() {
- ICPropertyTab newTab = (ICPropertyTab)folder.getSelection()[0].getData();
+ ICPropertyTab newTab = (ICPropertyTab) folder.getSelection()[0].getData();
if (newTab != null && currentTab != newTab) {
recentTabs.put(getClass(), newTab.getClass());
- if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);
+ if (currentTab != null)
+ currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);
currentTab = newTab;
currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL);
}
}
+
/**
*
*/
@@ -413,15 +414,11 @@ implements
public IProject getProject() {
Object element = getElement();
if (element != null) {
- if (element instanceof IFile ||
- element instanceof IProject ||
- element instanceof IFolder)
- {
- IResource f = (IResource) element;
- return f.getProject();
- }
- else if (element instanceof ICProject)
- return ((ICProject)element).getProject();
+ if (element instanceof IFile || element instanceof IProject || element instanceof IFolder) {
+ IResource f = (IResource) element;
+ return f.getProject();
+ } else if (element instanceof ICProject)
+ return ((ICProject) element).getProject();
}
return null;
}
@@ -431,22 +428,26 @@ implements
*/
private void handleConfigSelection() {
// If there is nothing in config selection widget just bail
- if (configSelector.getItemCount() == 0) return;
+ if (configSelector.getItemCount() == 0)
+ return;
int selectionIndex = configSelector.getSelectionIndex();
- if (selectionIndex == -1) return;
- if (cfgDescs == null || cfgDescs.length == 0) return;
+ if (selectionIndex == -1)
+ return;
+ if (cfgDescs == null || cfgDescs.length == 0)
+ return;
// Check if the user has selected the "all / multiple" configuration
if (selectionIndex >= cfgDescs.length) {
- if (selectionIndex == cfgDescs.length) { // all
+ if (selectionIndex == cfgDescs.length) { // all
multiCfgs = cfgDescs;
} else { // multiple
// Check previous state of variables figuring out if need to pop up selection dialog
// areCfgsStillThere() covers deletions by a user in Manage Configurations dialog
- boolean enterMultiCfgsDialog = (multiCfgs == null)
- || (multiCfgs == cfgDescs) || !areCfgsStillThere(multiCfgs);
+ boolean enterMultiCfgsDialog = (multiCfgs == null) || (multiCfgs == cfgDescs)
+ || !areCfgsStillThere(multiCfgs);
if (enterMultiCfgsDialog) {
- ICConfigurationDescription[] mcfgs = ConfigMultiSelectionDialog.select(cfgDescs, parentComposite.getShell());
+ ICConfigurationDescription[] mcfgs = ConfigMultiSelectionDialog.select(cfgDescs,
+ parentComposite.getShell());
if (mcfgs == null || mcfgs.length == 0) {
// return back to previous selection
int cfgIndex = -1;
@@ -516,7 +517,8 @@ implements
* @return true if all present, false otherwise
*/
private static boolean areCfgsStillThere(ICConfigurationDescription[] cfgs) {
- if (cfgs==null || cfgDescs==null) return false;
+ if (cfgs == null || cfgDescs == null)
+ return false;
for (ICConfigurationDescription multiCfg : cfgs) {
boolean foundOne = false;
@@ -533,62 +535,68 @@ implements
return true;
}
- @Override
+ @Override
public boolean performCancel() {
- if (! noContentOnPage && displayedConfig) forEach(ICPropertyTab.CANCEL);
+ if (!noContentOnPage && displayedConfig)
+ forEach(ICPropertyTab.CANCEL);
CDTPropertyManager.performCancel(this);
- return true;
- }
+ return true;
+ }
+
@Override
public void performDefaults() {
- if (! noContentOnPage && displayedConfig) forEach(ICPropertyTab.DEFAULTS);
+ if (!noContentOnPage && displayedConfig)
+ forEach(ICPropertyTab.DEFAULTS);
}
- @Override
- public void performApply() { performSave(SAVE_MODE_APPLY); }
-
- /**
- * There are 2 ways to perform OK for CDT property pages.
- * 1st (default):
- * All pages use the same editable copy of ICProjectDescription.
- * When OK occurs, this object is simply set.
- *
- * 2nd:
- * When OK occurs, each page must copy its data to new instance
- * of ICProjectDescription, like it occurs during Apply event.
- * It allows to avoid collisions with other property pages,
- * which do not share ICProjectDescription instance.
- * But some changes may be saved wrong if they are affected
- * by data from another property pages (Discovery options etc).
-
- * To enable 2nd mode, just create the following file:
- * <workspace>/.metadata/.plugins/org.eclipse.cdt.ui/apply_mode
- */
-
- @Override
+
+ @Override
+ public void performApply() {
+ performSave(SAVE_MODE_APPLY);
+ }
+
+ /**
+ * There are 2 ways to perform OK for CDT property pages.
+ * 1st (default):
+ * All pages use the same editable copy of ICProjectDescription.
+ * When OK occurs, this object is simply set.
+ *
+ * 2nd:
+ * When OK occurs, each page must copy its data to new instance
+ * of ICProjectDescription, like it occurs during Apply event.
+ * It allows to avoid collisions with other property pages,
+ * which do not share ICProjectDescription instance.
+ * But some changes may be saved wrong if they are affected
+ * by data from another property pages (Discovery options etc).
+
+ * To enable 2nd mode, just create the following file:
+ * <workspace>/.metadata/.plugins/org.eclipse.cdt.ui/apply_mode
+ */
+
+ @Override
public boolean performOk() {
- File f = CUIPlugin.getDefault().getStateLocation().append("apply_mode").toFile(); //$NON-NLS-1$
- if (f.exists())
- return performSave(SAVE_MODE_APPLYOK);
+ File f = CUIPlugin.getDefault().getStateLocation().append("apply_mode").toFile(); //$NON-NLS-1$
+ if (f.exists())
+ return performSave(SAVE_MODE_APPLYOK);
return performSave(SAVE_MODE_OK);
- }
-
- /**
- * Searches in the prj for the config description with the same ID as for given cfg.
- * If there's no such cfgd, it will be created.
- *
- * @param prj - project description where we'll search (or create) config description
- * @param cfg - config description belonging to another project description,
- * it is a sample for search and base for possile creation
- * of resulting configuration description.
- *
- * @return the configuration description (found or created) or null in case of error
- */
- private ICConfigurationDescription findCfg(ICProjectDescription prj, ICConfigurationDescription cfg) {
- String id = cfg.getId();
- // find config with the same ID as original one
+ }
+
+ /**
+ * Searches in the prj for the config description with the same ID as for given cfg.
+ * If there's no such cfgd, it will be created.
+ *
+ * @param prj - project description where we'll search (or create) config description
+ * @param cfg - config description belonging to another project description,
+ * it is a sample for search and base for possile creation
+ * of resulting configuration description.
+ *
+ * @return the configuration description (found or created) or null in case of error
+ */
+ private ICConfigurationDescription findCfg(ICProjectDescription prj, ICConfigurationDescription cfg) {
+ String id = cfg.getId();
+ // find config with the same ID as original one
ICConfigurationDescription c = prj.getConfigurationById(id);
// if there's no cfg found, try to create it
if (c == null) {
@@ -605,26 +613,29 @@ implements
mb.setMessage(Messages.AbstractPage_3);
mb.open();
}
- return c;
- }
+ return c;
+ }
- /**
- * The same code used to perform OK and Apply
- */
- private boolean performSave(int mode) {
- final int finalMode = mode;
- if (noContentOnPage || !displayedConfig) return true;
- if ((mode == SAVE_MODE_OK || mode == SAVE_MODE_APPLYOK) && CDTPropertyManager.isSaveDone()) return true; // do not duplicate
+ /**
+ * The same code used to perform OK and Apply
+ */
+ private boolean performSave(int mode) {
+ final int finalMode = mode;
+ if (noContentOnPage || !displayedConfig)
+ return true;
+ if ((mode == SAVE_MODE_OK || mode == SAVE_MODE_APPLYOK) && CDTPropertyManager.isSaveDone())
+ return true; // do not duplicate
final boolean needs = (mode != SAVE_MODE_OK);
- final ICProjectDescription local_prjd = needs ? CoreModel.getDefault().getProjectDescription(getProject()) : null;
+ final ICProjectDescription local_prjd = needs ? CoreModel.getDefault().getProjectDescription(getProject())
+ : null;
ICResourceDescription lc = null;
if (needs) {
if (isMultiCfg()) {
- ICResourceDescription[] rds = (ICResourceDescription[])((ICMultiItemsHolder)resd).getItems();
- for (int i=0; i<rds.length; i++) {
+ ICResourceDescription[] rds = (ICResourceDescription[]) ((ICMultiItemsHolder) resd).getItems();
+ for (int i = 0; i < rds.length; i++) {
ICConfigurationDescription c = local_prjd.getConfigurationById(rds[i].getConfiguration().getId());
rds[i] = getResDesc(c);
}
@@ -641,11 +652,12 @@ implements
IRunnableWithProgress runnable = new IRunnableWithProgress() {
private void sendOK() {
- for (int j=0; j<CDTPropertyManager.getPagesCount(); j++) {
+ for (int j = 0; j < CDTPropertyManager.getPagesCount(); j++) {
Object p = CDTPropertyManager.getPage(j);
if (p != null && p instanceof AbstractPage) {
- AbstractPage ap = (AbstractPage)p;
- if (ap.displayedConfig) ap.forEach(ICPropertyTab.OK, null);
+ AbstractPage ap = (AbstractPage) p;
+ if (ap.displayedConfig)
+ ap.forEach(ICPropertyTab.OK, null);
}
}
}
@@ -656,21 +668,22 @@ implements
switch (finalMode) {
case SAVE_MODE_APPLYOK:
sendOK();
- ICConfigurationDescription[] olds = CDTPropertyManager.getProjectDescription(AbstractPage.this, getProject()).getConfigurations();
+ ICConfigurationDescription[] olds = CDTPropertyManager
+ .getProjectDescription(AbstractPage.this, getProject()).getConfigurations();
for (ICConfigurationDescription old : olds) {
- resd = getResDesc(old);
- ICResourceDescription r = getResDesc(local_prjd.getConfigurationById(old.getId()));
- for (int j=0; j<CDTPropertyManager.getPagesCount(); j++) {
- Object p = CDTPropertyManager.getPage(j);
- if (p != null && p instanceof AbstractPage) {
- AbstractPage ap = (AbstractPage)p;
- if (ap.displayedConfig) {
- ap.forEach(ICPropertyTab.UPDATE, resd);
- ap.forEach(ICPropertyTab.APPLY, r);
- }
+ resd = getResDesc(old);
+ ICResourceDescription r = getResDesc(local_prjd.getConfigurationById(old.getId()));
+ for (int j = 0; j < CDTPropertyManager.getPagesCount(); j++) {
+ Object p = CDTPropertyManager.getPage(j);
+ if (p != null && p instanceof AbstractPage) {
+ AbstractPage ap = (AbstractPage) p;
+ if (ap.displayedConfig) {
+ ap.forEach(ICPropertyTab.UPDATE, resd);
+ ap.forEach(ICPropertyTab.APPLY, r);
}
}
}
+ }
break;
case SAVE_MODE_APPLY:
forEach(ICPropertyTab.APPLY, local_cfgd);
@@ -692,35 +705,34 @@ implements
};
IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
try {
- PlatformUI.getWorkbench().getProgressService().runInUI(new ProgressMonitorDialog(getShell()), op, ResourcesPlugin.getWorkspace().getRoot());
+ PlatformUI.getWorkbench().getProgressService().runInUI(new ProgressMonitorDialog(getShell()), op,
+ ResourcesPlugin.getWorkspace().getRoot());
} catch (InvocationTargetException e) {
Throwable e1 = e.getTargetException();
- CUIPlugin.errorDialog(getShell(),
- Messages.AbstractPage_8,
- Messages.AbstractPage_9, e1, true);
+ CUIPlugin.errorDialog(getShell(), Messages.AbstractPage_8, Messages.AbstractPage_9, e1, true);
return false;
} catch (InterruptedException e) {
// IProgressService.runInUI(...) misuses this exception to signal that the operation was canceled.
return false;
}
- final boolean rebuildIndex= isIndexerAffected();
+ final boolean rebuildIndex = isIndexerAffected();
if (rebuildIndex)
rebuildIndex();
return true;
}
private boolean isIndexerAffected() {
- ICProjectDescription desc= CoreModel.getDefault().getProjectDescription(getProject(), false);
+ ICProjectDescription desc = CoreModel.getDefault().getProjectDescription(getProject(), false);
if (desc == null || desc.isCdtProjectCreating())
return false;
Iterator<InternalTab> it = itabs.iterator();
- while(it.hasNext()) {
+ while (it.hasNext()) {
InternalTab tab = it.next();
if (tab != null) {
ICPropertyTab tabtab = tab.tab;
- if (tabtab instanceof AbstractCPropertyTab && ((AbstractCPropertyTab)tabtab).isIndexerAffected()) {
+ if (tabtab instanceof AbstractCPropertyTab && ((AbstractCPropertyTab) tabtab).isIndexerAffected()) {
return true;
}
}
@@ -729,14 +741,13 @@ implements
}
private void rebuildIndex() {
- final Shell shell= getShell();
- final String title= getTitle();
- final String msg= Messages.AbstractPage_rebuildIndex_question;
- int result= OptionalMessageDialog.open(PREF_ASK_REINDEX,
- shell, title, null /* default image */, msg, MessageDialog.QUESTION,
- new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0);
+ final Shell shell = getShell();
+ final String title = getTitle();
+ final String msg = Messages.AbstractPage_rebuildIndex_question;
+ int result = OptionalMessageDialog.open(PREF_ASK_REINDEX, shell, title, null /* default image */, msg,
+ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
if (result == OptionalMessageDialog.NOT_SHOWN) {
- result= OptionalMessageDialog.getDialogDetail(PREF_ASK_REINDEX);
+ result = OptionalMessageDialog.getDialogDetail(PREF_ASK_REINDEX);
} else if (result != SWT.DEFAULT) {
OptionalMessageDialog.setDialogDetail(PREF_ASK_REINDEX, result);
}
@@ -755,18 +766,20 @@ implements
// Do not re-read if list already created by another page
if (cfgDescs == null) {
ICProjectDescription pDesc = CDTPropertyManager.getProjectDescription(this, prj);
- cfgDescs = (pDesc == null)? null : pDesc.getConfigurations();
- if (cfgDescs == null || cfgDescs.length == 0) return;
+ cfgDescs = (pDesc == null) ? null : pDesc.getConfigurations();
+ if (cfgDescs == null || cfgDescs.length == 0)
+ return;
Arrays.sort(cfgDescs, CDTListComparator.getInstance());
} else {
- if (cfgDescs.length == 0) return;
+ if (cfgDescs.length == 0)
+ return;
// just register in CDTPropertyManager;
CDTPropertyManager.getProjectDescription(this, prj);
}
// Do nothing if widget not created yet.
- if (configSelector == null) {
+ if (configSelector == null) {
lastSelectedCfg = cfgDescs[getActiveCfgIndex()];
cfgChanged(lastSelectedCfg);
return;
@@ -800,7 +813,7 @@ implements
}
}
- if (cfgIndex<0) {
+ if (cfgIndex < 0) {
cfgIndex = getActiveCfgIndex();
}
@@ -809,13 +822,20 @@ implements
}
@Override
- public void updateButtons() {}
+ public void updateButtons() {
+ }
+
@Override
- public void updateMessage() { }
+ public void updateMessage() {
+ }
+
@Override
- public void updateTitle() { }
+ public void updateTitle() {
+ }
+
@Override
- public void updateContainer() { }
+ public void updateContainer() {
+ }
@Override
public boolean isValid() {
@@ -834,11 +854,12 @@ implements
populateConfigurations();
}
- if (itabs.size() < 1) return;
+ if (itabs.size() < 1)
+ return;
- if (currentTab == null && folder.getItemCount() > 0) {
+ if (currentTab == null && folder.getItemCount() > 0) {
Object ob = folder.getItem(0).getData();
- currentTab = (ICPropertyTab)ob;
+ currentTab = (ICPropertyTab) ob;
}
if (currentTab != null)
currentTab.handleTabEvent(ICPropertyTab.VISIBLE, visible ? NOT_NULL : null);
@@ -848,43 +869,50 @@ implements
if (!getShell().isVisible()) {
return; // do not resize shell before its open, it will screw up shell positioning
}
- if (visible && !isNewOpening) return; // do not duplicate
+ if (visible && !isNewOpening)
+ return; // do not duplicate
if (visible)
isNewOpening = false;
int saveMode = CDTPrefUtil.getInt(CDTPrefUtil.KEY_POSSAVE);
- if (saveMode == CDTPrefUtil.POSITION_SAVE_NONE) return;
+ if (saveMode == CDTPrefUtil.POSITION_SAVE_NONE)
+ return;
if (internalElement == null && !checkElement())
return; // not initialized. Do not process
IProject prj = getProject();
if (prj == null)
- return; // preferences. Do not process.
- QualifiedName WIDTH = new QualifiedName(prj.getName(),".property.page.width"); //$NON-NLS-1$
- QualifiedName HEIGHT = new QualifiedName(prj.getName(),".property.page.height"); //$NON-NLS-1$
- QualifiedName XKEY = new QualifiedName(prj.getName(),".property.page.x"); //$NON-NLS-1$
- QualifiedName YKEY = new QualifiedName(prj.getName(),".property.page.y"); //$NON-NLS-1$
+ return; // preferences. Do not process.
+ QualifiedName WIDTH = new QualifiedName(prj.getName(), ".property.page.width"); //$NON-NLS-1$
+ QualifiedName HEIGHT = new QualifiedName(prj.getName(), ".property.page.height"); //$NON-NLS-1$
+ QualifiedName XKEY = new QualifiedName(prj.getName(), ".property.page.x"); //$NON-NLS-1$
+ QualifiedName YKEY = new QualifiedName(prj.getName(), ".property.page.y"); //$NON-NLS-1$
Rectangle r = getShell().getBounds();
try {
if (visible) {
String w = prj.getPersistentProperty(WIDTH);
String h = prj.getPersistentProperty(HEIGHT);
- if (w != null) r.width = Integer.parseInt(w);
- if (h != null) r.height = Integer.parseInt(h);
+ if (w != null)
+ r.width = Integer.parseInt(w);
+ if (h != null)
+ r.height = Integer.parseInt(h);
if (saveMode == CDTPrefUtil.POSITION_SAVE_BOTH) {
String x = prj.getPersistentProperty(XKEY);
String y = prj.getPersistentProperty(YKEY);
- if (x != null) r.x = Integer.parseInt(x);
- if (y != null) r.y = Integer.parseInt(y);
+ if (x != null)
+ r.x = Integer.parseInt(x);
+ if (y != null)
+ r.y = Integer.parseInt(y);
}
getShell().setBounds(r);
} else {
- prj.setPersistentProperty(WIDTH, String.valueOf(r.width));
+ prj.setPersistentProperty(WIDTH, String.valueOf(r.width));
prj.setPersistentProperty(HEIGHT, String.valueOf(r.height));
prj.setPersistentProperty(XKEY, String.valueOf(r.x));
prj.setPersistentProperty(YKEY, String.valueOf(r.y));
}
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
}
@Override
@@ -897,14 +925,16 @@ implements
*/
@Override
@Deprecated
- public org.eclipse.core.runtime.Preferences getPreferences() {
+ public org.eclipse.core.runtime.Preferences getPreferences() {
return CUIPlugin.getDefault().getPluginPreferences();
}
@Override
- public void enableConfigSelection (boolean enable) {
- if (configSelector != null) configSelector.setEnabled(enable);
- if (manageButton != null) manageButton.setEnabled(enable);
+ public void enableConfigSelection(boolean enable) {
+ if (configSelector != null)
+ configSelector.setEnabled(enable);
+ if (manageButton != null)
+ manageButton.setEnabled(enable);
}
/**
@@ -933,7 +963,8 @@ implements
*/
public static boolean isCDTPrj(IProject p) {
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
- if (prjd == null) return false;
+ if (prjd == null)
+ return false;
ICConfigurationDescription[] cfgs = prjd.getConfigurations();
return (cfgs != null && cfgs.length > 0);
}
@@ -949,7 +980,7 @@ implements
if (cfgDescs == null) {
populateConfigurations();
}
- if (lastSelectedCfg!=null) {
+ if (lastSelectedCfg != null) {
resd = getResDesc(lastSelectedCfg);
}
}
@@ -963,22 +994,21 @@ implements
if (isForProject())
return cf.getRootFolderDescription();
ICResourceDescription out = null;
- IResource res = (IResource)ad;
+ IResource res = (IResource) ad;
IPath p = res.getProjectRelativePath();
if (isForFolder() || isForFile()) {
if (cf instanceof ICMultiItemsHolder) {
out = cf.getResourceDescription(p, isForFolder()); // sic !
} else {
out = cf.getResourceDescription(p, false);
- if (! p.equals(out.getPath()) ) {
+ if (!p.equals(out.getPath())) {
try {
if (isForFolder())
- out = cf.createFolderDescription(p, (ICFolderDescription)out);
+ out = cf.createFolderDescription(p, (ICFolderDescription) out);
else
out = cf.createFileDescription(p, out);
} catch (CoreException e) {
- System.out.println(Messages.AbstractPage_10 +
- p.toOSString() + "\n" + e.getLocalizedMessage()); //$NON-NLS-1$
+ System.out.println(Messages.AbstractPage_10 + p.toOSString() + "\n" + e.getLocalizedMessage()); //$NON-NLS-1$
}
}
}
@@ -1008,13 +1038,13 @@ implements
excludeFromBuildCheck.setSelection(resd.isExcluded());
}
int x = CDTPropertyManager.getPagesCount();
- for (int i=0; i<x; i++) {
+ for (int i = 0; i < x; i++) {
Object p = CDTPropertyManager.getPage(i);
if (p == null || !(p instanceof AbstractPage))
continue;
- AbstractPage ap = (AbstractPage)p;
+ AbstractPage ap = (AbstractPage) p;
if (ap.displayedConfig)
- ap.forEach(ICPropertyTab.UPDATE,getResDesc());
+ ap.forEach(ICPropertyTab.UPDATE, getResDesc());
}
}
@@ -1053,17 +1083,23 @@ implements
* Subclasses may override this.
* @return true, if the configurations control should be shown (default); false otherwise
*/
- protected boolean showsConfig() { return true; }
+ protected boolean showsConfig() {
+ return true;
+ }
/**
* Apply specified method to all tabs
*/
- protected void forEach(int m) { forEach(m, null); }
+ protected void forEach(int m) {
+ forEach(m, null);
+ }
+
protected void forEach(int m, Object pars) {
Iterator<InternalTab> it = itabs.iterator();
- while(it.hasNext()) {
+ while (it.hasNext()) {
InternalTab tab = it.next();
- if (tab != null) tab.tab.handleTabEvent(m, pars);
+ if (tab != null)
+ tab.tab.handleTabEvent(m, pars);
}
}
@@ -1083,11 +1119,12 @@ implements
private synchronized void loadExtensionsSynchronized(Composite parent) {
// Get the extensions
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
- .getExtensionPoint(EXTENSION_POINT_ID);
- if (extensionPoint == null) return;
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint == null)
+ return;
IExtension[] extensions = extensionPoint.getExtensions();
- if (extensions == null) return;
+ if (extensions == null)
+ return;
List<IConfigurationElement> elements = new ArrayList<IConfigurationElement>();
for (IExtension ext : extensions)
@@ -1096,7 +1133,8 @@ implements
for (IConfigurationElement element : elements) {
if (element.getName().equals(ELEMENT_NAME)) {
- if (loadTab(element, parent)) return;
+ if (loadTab(element, parent))
+ return;
} else {
System.out.println(Messages.AbstractPage_13 + element.getName());
}
@@ -1114,27 +1152,29 @@ implements
private boolean loadTab(IConfigurationElement element, Composite parent) {
// MBSCustomPageData currentPageData;
// Check whether it's our tab
- if (!this.getClass().getName().equals(element.getAttribute(PARENT_NAME))) return false;
+ if (!this.getClass().getName().equals(element.getAttribute(PARENT_NAME)))
+ return false;
ICPropertyTab page = null;
try {
page = (ICPropertyTab) element.createExecutableExtension(CLASS_NAME);
} catch (CoreException e) {
- System.out.println(Messages.AbstractPage_14 +
- e.getLocalizedMessage());
+ System.out.println(Messages.AbstractPage_14 + e.getLocalizedMessage());
return false;
}
- if (page == null) return false;
+ if (page == null)
+ return false;
String helpId = element.getAttribute(HELPID_NAME);
if (helpId != null && helpId.length() > 0
- // TODO: in next version: refer to ICPropertyTab instead of AbstractCPropertyTab
- && page instanceof AbstractCPropertyTab) {
- ((AbstractCPropertyTab)page).setHelpContextId(helpId);
+ // TODO: in next version: refer to ICPropertyTab instead of AbstractCPropertyTab
+ && page instanceof AbstractCPropertyTab) {
+ ((AbstractCPropertyTab) page).setHelpContextId(helpId);
}
Image _img = getIcon(element);
- if (_img != null) page.handleTabEvent(ICPropertyTab.SET_ICON, _img);
+ if (_img != null)
+ page.handleTabEvent(ICPropertyTab.SET_ICON, _img);
if (isSingle()) {
// note that name, image and tooltip
@@ -1145,7 +1185,7 @@ implements
currentTab = page;
return true; // don't load other tabs
}
- String _name = element.getAttribute(TEXT_NAME);
+ String _name = element.getAttribute(TEXT_NAME);
String _tip = element.getAttribute(TIP_NAME);
Composite _comp = new Composite(folder, SWT.NONE);
@@ -1161,7 +1201,9 @@ implements
URL url = null;
String iconName = config.getAttribute(IMAGE_NAME);
if (iconName != null) {
- idesc = AbstractUIPlugin.imageDescriptorFromPlugin(Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getSymbolicName(), iconName);
+ idesc = AbstractUIPlugin.imageDescriptorFromPlugin(
+ Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getSymbolicName(),
+ iconName);
}
if (idesc == null)
return null;
@@ -1172,22 +1214,22 @@ implements
@Override
public void informAll(int code, Object data) {
- for (int i=0; i<CDTPropertyManager.getPagesCount(); i++) {
+ for (int i = 0; i < CDTPropertyManager.getPagesCount(); i++) {
Object p = CDTPropertyManager.getPage(i);
if (p == null || !(p instanceof AbstractPage))
continue;
- AbstractPage ap = (AbstractPage)p;
+ AbstractPage ap = (AbstractPage) p;
ap.forEach(code, data);
}
}
@Override
public void informPages(int code, Object data) {
- for (int i=0; i<CDTPropertyManager.getPagesCount(); i++) {
+ for (int i = 0; i < CDTPropertyManager.getPagesCount(); i++) {
Object p = CDTPropertyManager.getPage(i);
if (p == null || !(p instanceof AbstractPage))
continue;
- AbstractPage ap = (AbstractPage)p;
+ AbstractPage ap = (AbstractPage) p;
ap.handleMessage(code, data);
}
}
@@ -1195,60 +1237,63 @@ implements
@Override
public void handleMessage(int code, Object data) {
switch (code) {
- // First re-check visibility of all tabs.
- // While tab deletion can be made on the fly,
- // tabs adding will be made by re-creation
- // of all elements, to preserve their order
- case ICPropertyTab.MANAGEDBUILDSTATE:
- if (folder == null) {
- if (itabs == null || itabs.size() == 0)
- return;
- ICPropertyTab t = itabs.get(0).tab;
- if (! t.canBeVisible())
- t.handleTabEvent(ICPropertyTab.VISIBLE, null);
+ // First re-check visibility of all tabs.
+ // While tab deletion can be made on the fly,
+ // tabs adding will be made by re-creation
+ // of all elements, to preserve their order
+ case ICPropertyTab.MANAGEDBUILDSTATE:
+ if (folder == null) {
+ if (itabs == null || itabs.size() == 0)
return;
- }
- boolean willAdd = false;
- TabItem[] ts = folder.getItems();
- int x = folder.getSelectionIndex();
- String currHeader = (x == -1) ? null : ts[x].getText();
- for (int i=0; i<itabs.size(); i++) {
- InternalTab itab = itabs.get(i);
- TabItem ti = null;
- for (TabItem element2 : ts) {
- if (element2.isDisposed()) continue;
- if (element2.getData() == itab.tab) {
- ti = element2;
- break;
- }
+ ICPropertyTab t = itabs.get(0).tab;
+ if (!t.canBeVisible())
+ t.handleTabEvent(ICPropertyTab.VISIBLE, null);
+ return;
+ }
+ boolean willAdd = false;
+ TabItem[] ts = folder.getItems();
+ int x = folder.getSelectionIndex();
+ String currHeader = (x == -1) ? null : ts[x].getText();
+ for (int i = 0; i < itabs.size(); i++) {
+ InternalTab itab = itabs.get(i);
+ TabItem ti = null;
+ for (TabItem element2 : ts) {
+ if (element2.isDisposed())
+ continue;
+ if (element2.getData() == itab.tab) {
+ ti = element2;
+ break;
}
- if (itab.tab.canBeVisible()) {
- if (ti == null) {
- willAdd = true;
- break;
- }
- } else {
- if (ti != null) ti.dispose();
+ }
+ if (itab.tab.canBeVisible()) {
+ if (ti == null) {
+ willAdd = true;
+ break;
}
+ } else {
+ if (ti != null)
+ ti.dispose();
}
- // in case of new tab added,
- // we have to dispose and re-create all tabs
- if (willAdd) {
- for (int j=0; j<ts.length; j++)
- if (ts[j] != null && !ts[j].isDisposed())
- ts[j].dispose();
- TabItem ti = null;
- for (int i=0; i<itabs.size(); i++) {
- InternalTab itab = itabs.get(i);
- if (itab.tab.canBeVisible()) {
- TabItem currTI = itab.createOn(folder);
- if (currHeader != null && currHeader.equals(itab.text))
- ti = currTI;
- }
+ }
+ // in case of new tab added,
+ // we have to dispose and re-create all tabs
+ if (willAdd) {
+ for (int j = 0; j < ts.length; j++)
+ if (ts[j] != null && !ts[j].isDisposed())
+ ts[j].dispose();
+ TabItem ti = null;
+ for (int i = 0; i < itabs.size(); i++) {
+ InternalTab itab = itabs.get(i);
+ if (itab.tab.canBeVisible()) {
+ TabItem currTI = itab.createOn(folder);
+ if (currHeader != null && currHeader.equals(itab.text))
+ ti = currTI;
}
- if (ti != null) folder.setSelection(ti);
}
- break;
+ if (ti != null)
+ folder.setSelection(ti);
+ }
+ break;
}
}
@@ -1258,15 +1303,16 @@ implements
protected boolean checkElement() {
IAdaptable el = super.getElement();
if (el instanceof ICElement)
- internalElement = ((ICElement)el).getResource();
+ internalElement = ((ICElement) el).getResource();
else if (el instanceof IResource)
- internalElement = (IResource)el;
+ internalElement = (IResource) el;
else
- internalElement = el.getAdapter(IResource.class);
- if (internalElement == null) return false;
+ internalElement = el.getAdapter(IResource.class);
+ if (internalElement == null)
+ return false;
isProject = internalElement instanceof IProject;
- isFolder = internalElement instanceof IFolder;
- isFile = internalElement instanceof IFile;
+ isFolder = internalElement instanceof IFolder;
+ isFile = internalElement instanceof IFile;
return true;
}
@@ -1279,15 +1325,29 @@ implements
}
@Override
- public boolean isForProject() { return isProject; }
+ public boolean isForProject() {
+ return isProject;
+ }
+
@Override
- public boolean isForFolder() { return isFolder; }
+ public boolean isForFolder() {
+ return isFolder;
+ }
+
@Override
- public boolean isForFile() { return isFile; }
+ public boolean isForFile() {
+ return isFile;
+ }
+
@Override
- public boolean isForPrefs() { return false; }
+ public boolean isForPrefs() {
+ return false;
+ }
+
@Override
- public boolean isMultiCfg() { return resd instanceof ICMultiItemsHolder; }
+ public boolean isMultiCfg() {
+ return resd instanceof ICMultiItemsHolder;
+ }
/**
* Checks whether CDT property pages can be open for given object.
@@ -1312,12 +1372,14 @@ implements
* update views (in particular, display resource configurations)
*/
public static void updateViews(IResource res) {
- if (res == null) return;
+ if (res == null)
+ return;
IWorkbenchPartReference refs[] = CUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (IWorkbenchPartReference ref : refs) {
IWorkbenchPart part = ref.getPart(false);
if (part != null && part instanceof IPropertyChangeListener)
- ((IPropertyChangeListener)part).propertyChange(new PropertyChangeEvent(res, PreferenceConstants.PREF_SHOW_CU_CHILDREN, null, null));
+ ((IPropertyChangeListener) part).propertyChange(
+ new PropertyChangeEvent(res, PreferenceConstants.PREF_SHOW_CU_CHILDREN, null, null));
}
}
@@ -1354,11 +1416,11 @@ implements
@Override
public void performHelp() {
- // TODO: in next version: refer to ICPropertyTab instead of AbstractCPropertyTab
+ // TODO: in next version: refer to ICPropertyTab instead of AbstractCPropertyTab
if (currentTab != null && currentTab instanceof AbstractCPropertyTab) {
- String s = ((AbstractCPropertyTab)currentTab).getHelpContextId();
+ String s = ((AbstractCPropertyTab) currentTab).getHelpContextId();
if (s != null && s.length() > 0) {
- IContext context= HelpSystem.getContext(s);
+ IContext context = HelpSystem.getContext(s);
if (context != null)
PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
else
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java
index 671389a94b4..2fada1ad1d1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java
@@ -29,8 +29,7 @@ import org.eclipse.cdt.utils.ui.controls.ControlFactory;
/**
* Abstract page to be used as base for preference pages
*/
-public abstract class AbstractPrefPage extends AbstractPage
- implements IWorkbenchPreferencePage {
+public abstract class AbstractPrefPage extends AbstractPage implements IWorkbenchPreferencePage {
public Label titleLabel;
@@ -43,7 +42,7 @@ public abstract class AbstractPrefPage extends AbstractPage
compositeLayout.numColumns = 1;
compositeLayout.marginHeight = 0;
compositeLayout.marginWidth = 0;
- composite.setLayout( compositeLayout );
+ composite.setLayout(compositeLayout);
String s = getHeader();
if (s != null) {
@@ -54,23 +53,38 @@ public abstract class AbstractPrefPage extends AbstractPage
titleLabel = ControlFactory.createLabel(configGroup, s);
}
createWidgets(composite);
- return composite;
+ return composite;
}
@Override
- protected boolean checkElement() { return true; }
+ protected boolean checkElement() {
+ return true;
+ }
+
@Override
- public boolean isForPrefs() { return true; }
+ public boolean isForPrefs() {
+ return true;
+ }
+
@Override
- public void init(IWorkbench workbench) {}
+ public void init(IWorkbench workbench) {
+ }
+
@Override
- public ICResourceDescription getResDesc() { return null; }
+ public ICResourceDescription getResDesc() {
+ return null;
+ }
+
@Override
- public void performApply() { performOk(); }
+ public void performApply() {
+ performOk();
+ }
+
@Override
public boolean performOk() {
forEach(ICPropertyTab.OK, null);
return true;
}
+
abstract protected String getHeader();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java
index 703875f01bb..95342d8028a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java
@@ -28,13 +28,13 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public abstract class AbstractPropertyDialog extends Dialog {
- private final static String WSP_BEG = "${workspace_loc:"; //$NON-NLS-1$
+ private final static String WSP_BEG = "${workspace_loc:"; //$NON-NLS-1$
private final static String WSP_END = "}"; //$NON-NLS-1$
protected final static String EMPTY_STR = ""; //$NON-NLS-1$
-
+
protected Shell shell;
public boolean result = false;
-
+
public Object data = null;
public boolean check1 = false;
public boolean check2 = false;
@@ -42,50 +42,54 @@ public abstract class AbstractPropertyDialog extends Dialog {
public String text1;
public String text2;
private Shell parent;
-
+
public AbstractPropertyDialog(Shell _parent, String title) {
super(_parent, 0);
this.getStyle();
-
+
parent = _parent;
this.setText(title);
}
abstract public void buttonPressed(SelectionEvent e);
+
abstract protected Control createDialogArea(Composite c);
-
+
protected Button setupButton(Composite c, String text) {
Button b = new Button(c, SWT.PUSH);
b.setText(text);
b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
b.addSelectionListener(new SelectionAdapter() {
- @Override
+ @Override
public void widgetSelected(SelectionEvent event) {
- buttonPressed(event);
- }});
+ buttonPressed(event);
+ }
+ });
return b;
}
-
- public boolean open () {
- shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
- shell.setImage(Window.getDefaultImage());
- shell.setText(getText());
- createDialogArea(shell);
-
- // center window
- Rectangle r1 = parent.getBounds();
- Rectangle r2 = shell.getBounds();
- int x = r1.x + (r1.width - r2.width) / 2;
- int y = r1.y + (r1.height - r2.height) / 2;
- shell.setBounds(x, y, r2.width, r2.height);
-
- shell.open();
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- return result;
+
+ public boolean open() {
+ shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
+ shell.setImage(Window.getDefaultImage());
+ shell.setText(getText());
+ createDialogArea(shell);
+
+ // center window
+ Rectangle r1 = parent.getBounds();
+ Rectangle r2 = shell.getBounds();
+ int x = r1.x + (r1.width - r2.width) / 2;
+ int y = r1.y + (r1.height - r2.height) / 2;
+ shell.setBounds(x, y, r2.width, r2.height);
+
+ shell.open();
+ Display display = parent.getDisplay();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ return result;
}
+
protected static String strip_wsp(String s) {
s = s.trim();
if (s.startsWith(WSP_BEG) && s.endsWith(WSP_END)) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java
index 916723e5da2..cf4dc0ab09a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java
@@ -19,7 +19,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
/**
- * Bug #183341 : Single property page which does not
+ * Bug #183341 : Single property page which does not
* require separate cPropertyTab to display data.
*
*/
@@ -30,63 +30,63 @@ public abstract class AbstractSinglePage extends AbstractPage {
*/
@Override
public abstract void createWidgets(Composite c);
-
+
/**
* Implement this method to perform apply:
- * copy all data affected by this page
+ * copy all data affected by this page
* from src resource description to dst
* @param src
* @param dst
*/
protected abstract void performApply(ICResourceDescription src, ICResourceDescription dst);
- /**
- * Rewrite this method to handle configuration change
- * Do not forget to call super.cfgChanged(_cfgd);
- */
+ /**
+ * Rewrite this method to handle configuration change
+ * Do not forget to call super.cfgChanged(_cfgd);
+ */
@Override
protected void cfgChanged(ICConfigurationDescription _cfgd) {
super.cfgChanged(_cfgd);
- // if (displayedConfig) {
- // update widgets according to getResDesc() values
- // }
+ // if (displayedConfig) {
+ // update widgets according to getResDesc() values
+ // }
}
/**
* Usually, this method needs not to be rewritten
*/
- @Override
+ @Override
public boolean performCancel() {
- // if (! noContentOnPage && displayedConfig) {
- // do nothing in most cases
- // }
- return true;
- }
-
- /**
- * Rewrite this method to restore default
- * values in current ResourceDescription
- */
+ // if (! noContentOnPage && displayedConfig) {
+ // do nothing in most cases
+ // }
+ return true;
+ }
+
+ /**
+ * Rewrite this method to restore default
+ * values in current ResourceDescription
+ */
@Override
public void performDefaults() {
- // if (! noContentOnPage && displayedConfig) {
- // do something with getResDesc() fields
- // }
+ // if (! noContentOnPage && displayedConfig) {
+ // do something with getResDesc() fields
+ // }
}
-
+
/**
* Usually, this method needs not to be rewritten
*/
- @Override
+ @Override
public boolean performOk() {
- if (! noContentOnPage && displayedConfig) {
+ if (!noContentOnPage && displayedConfig) {
// do nothing in most cases
}
- return super.performOk();
- }
+ return super.performOk();
+ }
/**
- *
+ *
*/
@Override
public void setVisible(boolean visible) {
@@ -100,16 +100,18 @@ public abstract class AbstractSinglePage extends AbstractPage {
* No need to rewrite
*/
@Override
- protected boolean isSingle() { return true; }
-
+ protected boolean isSingle() {
+ return true;
+ }
+
/**
* Call to "foreach" does not really matter, since we have not tabs
- * But we intercept this call to perform other operations (apply).
+ * But we intercept this call to perform other operations (apply).
*/
@Override
protected void forEach(int m, Object data) {
if (m == ICPropertyTab.APPLY)
- performApply(getResDesc(), (ICResourceDescription)data);
+ performApply(getResDesc(), (ICResourceDescription) data);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java
index d64d1ad97a9..5ca1d66fe95 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java
@@ -87,11 +87,24 @@ public class BinaryParsTab extends AbstractCPropertyTab {
protected class BinaryParserConfiguration {
IExtension fExtension;
- public BinaryParserConfiguration(IExtension extension) { fExtension = extension; }
- public String getID() { return fExtension.getUniqueIdentifier();}
- public String getName() { return fExtension.getLabel(); }
+
+ public BinaryParserConfiguration(IExtension extension) {
+ fExtension = extension;
+ }
+
+ public String getID() {
+ return fExtension.getUniqueIdentifier();
+ }
+
+ public String getName() {
+ return fExtension.getLabel();
+ }
+
@Override
- public String toString() { return fExtension.getUniqueIdentifier(); }
+ public String toString() {
+ return fExtension.getUniqueIdentifier();
+ }
+
@Override
public boolean equals(Object obj) {
if (obj instanceof BinaryParserConfiguration) {
@@ -104,9 +117,11 @@ public class BinaryParsTab extends AbstractCPropertyTab {
protected class BinaryParserPageConfiguration {
ICOptionPage dynamicPage;
IConfigurationElement fElement;
+
public BinaryParserPageConfiguration(IConfigurationElement element) {
fElement = element;
}
+
public ICOptionPage getPage() throws CoreException {
if (dynamicPage == null) {
dynamicPage = (ICOptionPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
@@ -145,24 +160,29 @@ public class BinaryParsTab extends AbstractCPropertyTab {
public void widgetSelected(SelectionEvent e) {
handleBinaryParserChanged();
updateButtons();
- }});
+ }
+ });
tv = new CheckboxTableViewer(table);
tv.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- return (Object[])inputElement;
+ return (Object[]) inputElement;
}
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
});
tv.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
String txt = (element != null) ? element.toString() : EMPTY_STR;
if (element instanceof BinaryParserConfiguration)
- txt = ((BinaryParserConfiguration)element).getName();
+ txt = ((BinaryParserConfiguration) element).getName();
return txt;
}
});
@@ -171,12 +191,13 @@ public class BinaryParsTab extends AbstractCPropertyTab {
@Override
public void checkStateChanged(CheckStateChangedEvent e) {
saveChecked();
- }});
+ }
+ });
// get "standard" buttons on my own place
Composite c = new Composite(c1, SWT.NONE);
c.setLayoutData(new GridData(GridData.END));
- initButtons(c, new String[] {MOVEUP_STR, MOVEDOWN_STR});
+ initButtons(c, new String[] { MOVEUP_STR, MOVEDOWN_STR });
parserGroup = new Composite(sashForm, SWT.NULL);
GridData gd = new GridData();
@@ -191,23 +212,23 @@ public class BinaryParsTab extends AbstractCPropertyTab {
gd.horizontalSpan = 2;
parserGroup.setLayoutData(gd);
- sashForm.setWeights(new int[] {100, 100});
+ sashForm.setWeights(new int[] { 100, 100 });
initializeParserList();
initializeParserPageMap();
handleBinaryParserChanged();
}
- @Override
+ @Override
public void setVisible(boolean _visible) {
- super.setVisible(_visible);
- page.enableConfigSelection(!_visible);
- }
+ super.setVisible(_visible);
+ page.enableConfigSelection(!_visible);
+ }
@Override
public void updateData(ICResourceDescription cfgd) {
String[] ids = null;
if (page.isForPrefs()) { // prefs
- if (cfgd != null && cfgd.getConfiguration() != null) {
+ if (cfgd != null && cfgd.getConfiguration() != null) {
tps = cfgd.getConfiguration().getTargetPlatformSetting();
if (tps != null)
ids = tps.getBinaryParserIds();
@@ -222,13 +243,13 @@ public class BinaryParsTab extends AbstractCPropertyTab {
HashMap<String, BinaryParserConfiguration> clone = new HashMap<String, BinaryParserConfiguration>(configMap);
// add checked elements
int i;
- for (i=0; i<ids.length; i++) {
+ for (i = 0; i < ids.length; i++) {
data[i] = clone.get(ids[i]);
clone.remove(ids[i]);
}
// add remaining parsers (unchecked)
Iterator<String> it = clone.keySet().iterator();
-// i = 0;
+ // i = 0;
while (it.hasNext()) {
String s = it.next();
data[i++] = clone.get(s);
@@ -236,7 +257,7 @@ public class BinaryParsTab extends AbstractCPropertyTab {
tv.setInput(data);
tv.setAllChecked(false);
// set check marks
- for (i=0; i<ids.length; i++) {
+ for (i = 0; i < ids.length; i++) {
if (configMap.containsKey(ids[i])) {
tv.setChecked(configMap.get(ids[i]), true);
}
@@ -245,7 +266,8 @@ public class BinaryParsTab extends AbstractCPropertyTab {
}
private void initializeParserList() {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
+ CCorePlugin.BINARY_PARSER_SIMPLE_ID);
if (point != null) {
IExtension[] exts = point.getExtensions();
configMap = new HashMap<String, BinaryParserConfiguration>(exts.length);
@@ -260,7 +282,8 @@ public class BinaryParsTab extends AbstractCPropertyTab {
private void initializeParserPageMap() {
fParserPageMap = new HashMap<String, BinaryParserPageConfiguration>(5);
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+ "BinaryParserPage"); //$NON-NLS-1$
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
for (IConfigurationElement info : infos) {
if (info.getName().equals("parserPage")) { //$NON-NLS-1$
@@ -271,7 +294,7 @@ public class BinaryParsTab extends AbstractCPropertyTab {
}
private boolean isExtensionVisible(IExtension ext) {
- IConfigurationElement[] elements = ext.getConfigurationElements();
+ IConfigurationElement[] elements = ext.getConfigurationElements();
for (IConfigurationElement element : elements) {
IConfigurationElement[] children = element.getChildren(ATTR_FILTER);
for (IConfigurationElement element2 : children) {
@@ -295,6 +318,7 @@ public class BinaryParsTab extends AbstractCPropertyTab {
buttonSetEnabled(0, pos > 0);
buttonSetEnabled(1, pos != -1 && pos < (cnt - 1));
}
+
protected void handleBinaryParserChanged() {
String[] enabled = getBinaryParserIDs();
ICOptionPage dynamicPage;
@@ -312,7 +336,9 @@ public class BinaryParsTab extends AbstractCPropertyTab {
// Retrieve the dynamic UI for the current parser
String parserID = getCurrentBinaryParserID();
dynamicPage = getBinaryParserPage(parserID);
- if (dynamicPage != null) { dynamicPage.setVisible(true); }
+ if (dynamicPage != null) {
+ dynamicPage.setVisible(true);
+ }
}
protected String[] getBinaryParserIDs() {
@@ -324,22 +350,24 @@ public class BinaryParsTab extends AbstractCPropertyTab {
if (configElement != null) {
try {
return configElement.getPage();
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
}
return null;
}
protected String getCurrentBinaryParserID() {
int x = table.getSelectionIndex();
- if (x < 0) return null;
- return ((BinaryParserConfiguration)table.getItem(x).getData()).getID();
+ if (x < 0)
+ return null;
+ return ((BinaryParserConfiguration) table.getItem(x).getData()).getID();
}
@Override
protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
if (page.isMultiCfg()) {
- src = ((ICResourceDescription[])((ICMultiResourceDescription)src).getItems())[0];
- dst = ((ICResourceDescription[])((ICMultiResourceDescription)dst).getItems())[0];
+ src = ((ICResourceDescription[]) ((ICMultiResourceDescription) src).getItems())[0];
+ dst = ((ICResourceDescription[]) ((ICMultiResourceDescription) dst).getItems())[0];
}
ICTargetPlatformSetting tps1 = src.getConfiguration().getTargetPlatformSetting();
ICTargetPlatformSetting tps2 = dst.getConfiguration().getTargetPlatformSetting();
@@ -352,9 +380,8 @@ public class BinaryParsTab extends AbstractCPropertyTab {
protected void performDefaults() {
if (page.isForProject())
CoreModelUtil.setBinaryParserIds(page.getCfgsEditable(), null);
- else
- if (tps != null)
- tps.setBinaryParserIds(null);
+ else if (tps != null)
+ tps.setBinaryParserIds(null);
informPages(false);
updateData(getResDesc());
}
@@ -372,7 +399,8 @@ public class BinaryParsTab extends AbstractCPropertyTab {
else
dynamicPage.performDefaults();
}
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
}
}
@@ -393,9 +421,7 @@ public class BinaryParsTab extends AbstractCPropertyTab {
// Move item up / down
private void moveItem(boolean up) {
int n = table.getSelectionIndex();
- if (n < 0 ||
- (up && n == 0) ||
- (!up && n+1 == table.getItemCount()))
+ if (n < 0 || (up && n == 0) || (!up && n + 1 == table.getItemCount()))
return;
Object d = tv.getElementAt(n);
boolean checked = tv.getChecked(d);
@@ -413,16 +439,18 @@ public class BinaryParsTab extends AbstractCPropertyTab {
String[] ids = null;
if (objs != null) {
ids = new String[objs.length];
- for (int i=0; i<objs.length; i++) {
- ids[i] = ((BinaryParserConfiguration)objs[i]).getID();
+ for (int i = 0; i < objs.length; i++) {
+ ids[i] = ((BinaryParserConfiguration) objs[i]).getID();
}
}
if (page.isForPrefs()) {
- if (tps != null) tps.setBinaryParserIds(ids);
+ if (tps != null)
+ tps.setBinaryParserIds(ids);
} else {
CoreModelUtil.setBinaryParserIds(page.getCfgsEditable(), ids);
}
}
+
// This page can be displayed for project only
@Override
public boolean canBeVisible() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BuildVarListDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BuildVarListDialog.java
index 9bf8064c669..792660012ac 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BuildVarListDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BuildVarListDialog.java
@@ -33,32 +33,33 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
/**
* Displays CDT variables dialog with ability to filter.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
public class BuildVarListDialog extends ElementListSelectionDialog {
- private static final String TYPE = Messages.BuildVarListDialog_0;
- private IStringVariable[] sysVars = VariablesPlugin.getDefault().getStringVariableManager().getVariables();
+ private static final String TYPE = Messages.BuildVarListDialog_0;
+ private IStringVariable[] sysVars = VariablesPlugin.getDefault().getStringVariableManager().getVariables();
private Text text;
private Label type;
- private static final String LIST_DESCRIPTION = Messages.BuildVarListDialog_11;
-
+ private static final String LIST_DESCRIPTION = Messages.BuildVarListDialog_11;
+
public BuildVarListDialog(Shell parent, Object[] input) {
- super(parent, new LabelProvider () {
+ super(parent, new LabelProvider() {
@Override
public String getText(Object element) {
- if (element instanceof ICdtVariable)
- return ((ICdtVariable)element).getName();
- return super.getText(element);
- }});
+ if (element instanceof ICdtVariable)
+ return ((ICdtVariable) element).getName();
+ return super.getText(element);
+ }
+ });
setShellStyle(getShellStyle() | SWT.RESIZE);
setMessage(Messages.StringVariableSelectionDialog_message);
setMultipleSelection(false);
setElements(input);
}
-
+
@Override
protected Control createDialogArea(Composite container) {
Composite c = (Composite) super.createDialogArea(container);
@@ -66,83 +67,81 @@ public class BuildVarListDialog extends ElementListSelectionDialog {
type = new Label(c, SWT.NONE);
type.setFont(container.getFont());
type.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
Label desc = new Label(c, SWT.NONE);
desc.setFont(c.getFont());
desc.setText(Messages.StringVariableSelectionDialog_columnDescription);
desc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
text = new Text(c, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
text.setFont(container.getFont());
text.setEditable(false);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 50;
text.setLayoutData(gd);
-
+
//bug 189413 - adding label to build variable list for accessiblity
if (fFilteredList != null) {
- fFilteredList.getAccessible().addAccessibleListener(
- new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result = LIST_DESCRIPTION;
- }
- }
- );
+ fFilteredList.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ e.result = LIST_DESCRIPTION;
+ }
+ });
}
-
+
return c;
}
-
+
@Override
protected void handleSelectionChanged() {
super.handleSelectionChanged();
Object[] objects = getSelectedElements();
String descr = null;
if (objects.length == 1) {
- ICdtVariable v = (ICdtVariable)objects[0];
+ ICdtVariable v = (ICdtVariable) objects[0];
// update type name
type.setText(TYPE + " " + typeIntToString(v.getValueType())); //$NON-NLS-1$
// search in system variables list
for (int i = 0; i < sysVars.length; i++) {
if (v.getName() == sysVars[i].getName()) {
- descr = sysVars[i].getDescription();
- break;
+ descr = sysVars[i].getDescription();
+ break;
}
}
}
- if (descr == null)
- descr = Messages.BuildVarListDialog_10;
+ if (descr == null)
+ descr = Messages.BuildVarListDialog_10;
text.setText(descr);
}
- public static String typeIntToString(int type){
+ public static String typeIntToString(int type) {
String stringType;
- switch(type){
+ switch (type) {
case ICdtVariable.VALUE_TEXT_LIST:
- stringType = Messages.BuildVarListDialog_1;
+ stringType = Messages.BuildVarListDialog_1;
break;
case ICdtVariable.VALUE_PATH_FILE:
- stringType = Messages.BuildVarListDialog_2;
+ stringType = Messages.BuildVarListDialog_2;
break;
case ICdtVariable.VALUE_PATH_FILE_LIST:
- stringType = Messages.BuildVarListDialog_3;
+ stringType = Messages.BuildVarListDialog_3;
break;
case ICdtVariable.VALUE_PATH_DIR:
- stringType = Messages.BuildVarListDialog_4;
+ stringType = Messages.BuildVarListDialog_4;
break;
case ICdtVariable.VALUE_PATH_DIR_LIST:
- stringType = Messages.BuildVarListDialog_5;
+ stringType = Messages.BuildVarListDialog_5;
break;
case ICdtVariable.VALUE_PATH_ANY:
- stringType = Messages.BuildVarListDialog_6;
+ stringType = Messages.BuildVarListDialog_6;
break;
case ICdtVariable.VALUE_PATH_ANY_LIST:
- stringType = Messages.BuildVarListDialog_7;
+ stringType = Messages.BuildVarListDialog_7;
break;
case ICdtVariable.VALUE_TEXT:
default:
- stringType = Messages.BuildVarListDialog_8;
+ stringType = Messages.BuildVarListDialog_8;
break;
}
return stringType;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTHelpContextIds.java
index 66bbbac7c87..a33ba8e2399 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTHelpContextIds.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTHelpContextIds.java
@@ -20,7 +20,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface CDTHelpContextIds {
- public static final String PREFIX= CUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+ public static final String PREFIX = CUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
// Wizard pages
public static final String MAN_PROJ_PLATFORM_HELP = PREFIX + "new_proj_wiz_m_target"; //$NON-NLS-1$
@@ -29,7 +29,7 @@ public interface CDTHelpContextIds {
public static final String MAN_PROJ_WIZ_ERRORPARSERS_TAB = PREFIX + "new_proj_wiz_m_errorp"; //$NON-NLS-1$
public static final String MAN_PROJ_WIZ_INDEXER_TAB = PREFIX + "new_proj_wiz_m_cindexer"; //$NON-NLS-1$
public static final String MAN_PROJ_WIZ_BINARYPARSER_TAB = PREFIX + "new_proj_wiz_s_binary"; //$NON-NLS-1$
-
+
public static final String MAN_PROJ_BUILD_PROP = PREFIX + "man_prop_build"; //$NON-NLS-1$
public static final String MAN_PROJ_ERROR_PARSER = PREFIX + "man_prop_error"; //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java
index 8bea9087253..4ed4d197b84 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java
@@ -35,28 +35,28 @@ import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationManager;
*/
public class CDTPrefUtil {
// boolean keys (KEY_NO-s are to be inverted !)
- public static final String KEY_NOSUPP = "wizard.show.unsupported.disable"; //$NON-NLS-1$
- public static final String KEY_OTHERS = "wizard.group.others.enable"; //$NON-NLS-1$
- public static final String KEY_NOMNG = "properties.manage.config.disable"; //$NON-NLS-1$
- public static final String KEY_DTREE = "properties.data.hierarchy.enable"; //$NON-NLS-1$
- public static final String KEY_NOTOOLM = "properties.toolchain.modification.disable"; //$NON-NLS-1$
- public static final String KEY_EXPORT = "properties.export.page.enable"; //$NON-NLS-1$
+ public static final String KEY_NOSUPP = "wizard.show.unsupported.disable"; //$NON-NLS-1$
+ public static final String KEY_OTHERS = "wizard.group.others.enable"; //$NON-NLS-1$
+ public static final String KEY_NOMNG = "properties.manage.config.disable"; //$NON-NLS-1$
+ public static final String KEY_DTREE = "properties.data.hierarchy.enable"; //$NON-NLS-1$
+ public static final String KEY_NOTOOLM = "properties.toolchain.modification.disable"; //$NON-NLS-1$
+ public static final String KEY_EXPORT = "properties.export.page.enable"; //$NON-NLS-1$
/** @since 5.2 Show the "Include Files" settings entry tab */
public static final String KEY_SHOW_INC_FILES = "properties.includefiles.page.enable"; //$NON-NLS-1$
/** @since 5.4 Show the "Scanner Discovery" tab*/
- public static final String KEY_SHOW_SD = "properties.sd.page.enable"; //$NON-NLS-1$
+ public static final String KEY_SHOW_SD = "properties.sd.page.enable"; //$NON-NLS-1$
/** @since 5.2 */
- public static final String KEY_TIPBOX = "properties.option.tipbox.enable"; //$NON-NLS-1$
+ public static final String KEY_TIPBOX = "properties.option.tipbox.enable"; //$NON-NLS-1$
// string keys
- public static final String KEY_PREFTC = "wizard.preferred.toolchains"; //$NON-NLS-1$
- public static final String KEY_CONFSET = "workingsets.selected.configs"; //$NON-NLS-1$
+ public static final String KEY_PREFTC = "wizard.preferred.toolchains"; //$NON-NLS-1$
+ public static final String KEY_CONFSET = "workingsets.selected.configs"; //$NON-NLS-1$
// integer keys
- public static final String KEY_POSSAVE = "properties.save.position"; //$NON-NLS-1$
+ public static final String KEY_POSSAVE = "properties.save.position"; //$NON-NLS-1$
public static final int POSITION_SAVE_SIZE = 0;
public static final int POSITION_SAVE_NONE = 2;
public static final int POSITION_SAVE_BOTH = 3;
- public static final String KEY_DISC_NAMES = "properties.discovery.naming"; //$NON-NLS-1$
+ public static final String KEY_DISC_NAMES = "properties.discovery.naming"; //$NON-NLS-1$
public static final int DISC_NAMING_UNIQUE_OR_BOTH = 0;
public static final int DISC_NAMING_UNIQUE_OR_IDS = 1;
public static final int DISC_NAMING_ALWAYS_BOTH = 2;
@@ -73,7 +73,7 @@ public class CDTPrefUtil {
/** Property key used for string list write mode for multi-configuration edits (modify/replace) */
public static final String KEY_WMODE = "properties.multi.write.mode"; //$NON-NLS-1$
/** Modify implies changing only given elements and not changing any others */
- public static final int WMODE_MODIFY = 4;
+ public static final int WMODE_MODIFY = 4;
/** Replace implies replacing the whole list with the given one, overwriting old entries */
public static final int WMODE_REPLACE = 8;
@@ -86,40 +86,68 @@ public class CDTPrefUtil {
public static final Object[] EMPTY_ARRAY = new Object[0];
// low-level methods
- public static boolean getBool(String key) { return pref.getBoolean(key); }
- public static void setBool(String key, boolean val) { pref.setValue(key, val); }
- public static int getInt(String key) { return pref.getInt(key); }
- public static void setInt(String key, int val) { pref.setValue(key, val); }
- public static String getStr(String key) { return pref.getString(key); }
- public static void setStr(String key, String val) { pref.setValue(key, val); }
+ public static boolean getBool(String key) {
+ return pref.getBoolean(key);
+ }
+
+ public static void setBool(String key, boolean val) {
+ pref.setValue(key, val);
+ }
+
+ public static int getInt(String key) {
+ return pref.getInt(key);
+ }
+
+ public static void setInt(String key, int val) {
+ pref.setValue(key, val);
+ }
+
+ public static String getStr(String key) {
+ return pref.getString(key);
+ }
+
+ public static void setStr(String key, String val) {
+ pref.setValue(key, val);
+ }
// up-level methods
public static void readPreferredTCs() {
preferredTCs = new LinkedList<String>(Arrays.asList(getStr(KEY_PREFTC).split(DELIMITER)));
}
+
public static List<String> getPreferredTCs() {
- if (preferredTCs == null) readPreferredTCs();
+ if (preferredTCs == null)
+ readPreferredTCs();
return preferredTCs;
}
+
public static void delPreferredTC(String s) {
- if (preferredTCs == null) readPreferredTCs();
+ if (preferredTCs == null)
+ readPreferredTCs();
preferredTCs.remove(s);
}
+
public static void addPreferredTC(String s) {
- if (preferredTCs == null) readPreferredTCs();
- if (!preferredTCs.contains(s)) preferredTCs.add(s);
+ if (preferredTCs == null)
+ readPreferredTCs();
+ if (!preferredTCs.contains(s))
+ preferredTCs.add(s);
}
+
public static void cleanPreferredTCs() {
setStr(KEY_PREFTC, IPreferenceStore.STRING_DEFAULT_DEFAULT);
readPreferredTCs();
}
+
public static void savePreferredTCs() {
- if (preferredTCs == null) return;
+ if (preferredTCs == null)
+ return;
Iterator<String> it = preferredTCs.iterator();
StringBuilder b = new StringBuilder();
while (it.hasNext()) {
String s = it.next();
- if (s == null) continue;
+ if (s == null)
+ continue;
b.append(s);
b.append(DELIMITER);
}
@@ -136,7 +164,7 @@ public class CDTPrefUtil {
*/
public static int getMultiCfgStringListDisplayMode() {
int mode = getInt(KEY_DMODE);
- if (mode!=DMODE_CONJUNCTION && mode!=DMODE_DISJUNCTION) {
+ if (mode != DMODE_CONJUNCTION && mode != DMODE_DISJUNCTION) {
mode = DMODE_CONJUNCTION;
}
return mode;
@@ -164,7 +192,7 @@ public class CDTPrefUtil {
*/
public static int getMultiCfgStringListWriteMode() {
int mode = getInt(KEY_WMODE);
- if (mode!=WMODE_MODIFY && mode!=WMODE_REPLACE) {
+ if (mode != WMODE_MODIFY && mode != WMODE_REPLACE) {
mode = WMODE_MODIFY;
}
return mode;
@@ -188,7 +216,7 @@ public class CDTPrefUtil {
@Deprecated
public static String getDMode() {
String s = null;
- switch(getMultiCfgStringListDisplayMode()) {
+ switch (getMultiCfgStringListDisplayMode()) {
case DMODE_CONJUNCTION:
s = Messages.EnvironmentTab_17;
break;
@@ -205,7 +233,7 @@ public class CDTPrefUtil {
@Deprecated
public static String getWMode() {
String s = null;
- switch(getMultiCfgStringListWriteMode()) {
+ switch (getMultiCfgStringListWriteMode()) {
case WMODE_MODIFY:
s = Messages.EnvironmentTab_24;
break;
@@ -221,7 +249,7 @@ public class CDTPrefUtil {
*/
public static void spinDMode() {
int mode = getMultiCfgStringListDisplayMode();
- if (mode==DMODE_CONJUNCTION) {
+ if (mode == DMODE_CONJUNCTION) {
mode = DMODE_DISJUNCTION;
} else {
mode = DMODE_CONJUNCTION;
@@ -234,7 +262,7 @@ public class CDTPrefUtil {
*/
public static void spinWMode() {
int mode = getMultiCfgStringListWriteMode();
- if (mode==WMODE_MODIFY) {
+ if (mode == WMODE_MODIFY) {
mode = WMODE_REPLACE;
} else {
mode = WMODE_MODIFY;
@@ -256,6 +284,7 @@ public class CDTPrefUtil {
public static final Object[] getListForDisplay(Object[][] input, Comparator<Object> cmp) {
return getListForDisplay(input, getMultiCfgStringListDisplayMode(), cmp);
}
+
/**
* Utility method forms string list
* according to current list display mode
@@ -277,11 +306,11 @@ public class CDTPrefUtil {
if (getMultiCfgStringListDisplayMode() == DMODE_CONJUNCTION) {
ArrayList<Object> lst = new ArrayList<Object>();
- for (int i=0; i<s1.length; i++) {
+ for (int i = 0; i < s1.length; i++) {
if (s1[i] == null)
continue;
boolean found = true;
- for (int k = 1; k<input.length; k++) {
+ for (int k = 1; k < input.length; k++) {
Object[] s2 = input[k];
if (s2 == null || s2.length == 0) {
return EMPTY_ARRAY;
@@ -329,7 +358,8 @@ public class CDTPrefUtil {
public static void saveConfigSets(List<String> out) {
StringBuilder b = new StringBuilder();
for (String s : out) {
- if (s == null) continue;
+ if (s == null)
+ continue;
b.append(s);
b.append(CONFSETDEL);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java
index 309c7fdc70f..caeec157180 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java
@@ -57,17 +57,18 @@ public class CDTPropertyManager {
private static ArrayList<Object> pages = new ArrayList<Object>();
private static ICProjectDescription prjd = null;
- private static boolean saveDone = false;
+ private static boolean saveDone = false;
private static IProject project = null;
private static DListener dListener = new DListener();
-
public static ICProjectDescription getProjectDescription(PropertyPage p, IProject prj) {
return get(p, prj);
}
+
public static ICProjectDescription getProjectDescription(Widget w, IProject prj) {
return get(w, prj);
}
+
public static ICProjectDescription getProjectDescription(IProject prj) {
return get(null, prj);
}
@@ -83,10 +84,10 @@ public class CDTPropertyManager {
if (p != null && !pages.contains(p)) {
pages.add(p);
if (p instanceof PropertyPage) {
- if (((PropertyPage)p).getControl() != null)
- ((PropertyPage)p).getControl().addDisposeListener(dListener);
+ if (((PropertyPage) p).getControl() != null)
+ ((PropertyPage) p).getControl().addDisposeListener(dListener);
} else if (p instanceof Widget) {
- ((Widget)p).addDisposeListener(dListener);
+ ((Widget) p).addDisposeListener(dListener);
}
}
// Check that we are working with the same project
@@ -106,7 +107,8 @@ public class CDTPropertyManager {
* @param p - widget which calls this functionality
*/
public static void performOk(Object p) {
- if (saveDone) return;
+ if (saveDone)
+ return;
performOkForced(p);
@@ -156,19 +158,27 @@ public class CDTPropertyManager {
}
// pages utilities
- public static boolean isSaveDone() { return saveDone; }
- public static int getPagesCount() { return pages.size(); }
- public static Object getPage(int index) { return pages.get(index); }
+ public static boolean isSaveDone() {
+ return saveDone;
+ }
+
+ public static int getPagesCount() {
+ return pages.size();
+ }
+
+ public static Object getPage(int index) {
+ return pages.get(index);
+ }
// Removes disposed items from list
static class DListener implements DisposeListener {
- public static void dispose (Object w) {
+ public static void dispose(Object w) {
if (pages.contains(w)) { // Widget ?
pages.remove(w);
- } else { // Property Page ?
+ } else { // Property Page ?
for (Object ob : pages) {
if (ob != null && ob instanceof PropertyPage) {
- if (((PropertyPage)ob).getControl().equals(w)) {
+ if (((PropertyPage) ob).getControl().equals(w)) {
pages.remove(ob);
break;
}
@@ -183,6 +193,7 @@ public class CDTPropertyManager {
saveDone = false;
}
}
+
@Override
public void widgetDisposed(DisposeEvent e) {
dispose(e.widget);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java
index efa0a4b8dd3..03ff791ff84 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java
@@ -26,27 +26,57 @@ public class CDTStatusInfo implements IStatus {
private String text;
private int code;
- public CDTStatusInfo() {this(OK, null); }
+ public CDTStatusInfo() {
+ this(OK, null);
+ }
+
public CDTStatusInfo(int _code, String _text) {
- text= _text;
- code= _code;
+ text = _text;
+ code = _code;
}
+
@Override
- public IStatus[] getChildren() { return new IStatus[0];}
+ public IStatus[] getChildren() {
+ return new IStatus[0];
+ }
+
@Override
- public int getCode() { return code; }
+ public int getCode() {
+ return code;
+ }
+
@Override
- public Throwable getException() { return null; }
+ public Throwable getException() {
+ return null;
+ }
+
@Override
- public String getMessage() { return text; }
+ public String getMessage() {
+ return text;
+ }
+
@Override
- public String getPlugin() { return CUIPlugin.PLUGIN_ID; }
+ public String getPlugin() {
+ return CUIPlugin.PLUGIN_ID;
+ }
+
@Override
- public int getSeverity() { return code; }
+ public int getSeverity() {
+ return code;
+ }
+
@Override
- public boolean isMultiStatus() { return false; }
+ public boolean isMultiStatus() {
+ return false;
+ }
+
@Override
- public boolean isOK() { return (code == OK); }
+ public boolean isOK() {
+ return (code == OK);
+ }
+
@Override
- public boolean matches(int mask) { return (code & mask) != 0; }
+ public boolean matches(int mask) {
+ return (code & mask) != 0;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTUIListComparator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTUIListComparator.java
index a1e9d35eeb9..2e4eb088e57 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTUIListComparator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTUIListComparator.java
@@ -32,19 +32,20 @@ public class CDTUIListComparator extends CDTListComparator {
comparator = new CDTUIListComparator();
return comparator;
}
+
@Override
public int compare(Object a, Object b) {
- if (a == null || b == null)
+ if (a == null || b == null)
return 0;
if (a instanceof ExtData) {
- ExtData c1 = (ExtData)a;
- ExtData c2 = (ExtData)b;
+ ExtData c1 = (ExtData) a;
+ ExtData c2 = (ExtData) b;
return c1.getName().compareToIgnoreCase(c2.getName());
- }
+ }
if (a instanceof IConfigurationElement) {
- IConfigurationElement e1 = (IConfigurationElement)a;
- IConfigurationElement e2 = (IConfigurationElement)b;
- return AbstractPage.getWeight(e1).compareTo(AbstractPage.getWeight(e2));
+ IConfigurationElement e1 = (IConfigurationElement) a;
+ IConfigurationElement e2 = (IConfigurationElement) b;
+ return AbstractPage.getWeight(e1).compareTo(AbstractPage.getWeight(e2));
}
if (a instanceof EntryDescriptor) {
EntryDescriptor c1 = (EntryDescriptor) a;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java
index 965a27ecdd4..eca5bebc706 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java
@@ -33,26 +33,30 @@ public class CLocationOutputTab extends CLocationTab {
@Override
public void createControls(Composite parent) {
super.createControls(parent);
- label.setText(Messages.CLocationOutputTab_0);
+ label.setText(Messages.CLocationOutputTab_0);
}
@Override
public ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd) {
return cfgd.getConfiguration().getBuildSetting().getOutputDirectories();
}
+
@Override
public void setEntries(ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data) {
ICOutputEntry[] out = null;
if (data != null) {
out = new ICOutputEntry[data.length];
- for (int i=0; i<out.length; i++) out[i] = (ICOutputEntry)data[i];
+ for (int i = 0; i < out.length; i++)
+ out[i] = (ICOutputEntry) data[i];
}
cfgd.getConfiguration().getBuildSetting().setOutputDirectories(out);
}
+
@Override
public ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean isWorkspacePath) {
return new COutputEntry(p, ex, isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0);
}
+
@Override
public ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean isWorkspacePath) {
return new COutputEntry(f, ex, isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java
index f083ab34ba9..c9058cff712 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java
@@ -30,34 +30,39 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
* @noextend This class is not intended to be subclassed by clients.
*/
public class CLocationSourceTab extends CLocationTab {
-
+
@Override
public void createControls(Composite parent) {
super.createControls(parent);
- label.setText(Messages.CLocationSourceTab_0);
+ label.setText(Messages.CLocationSourceTab_0);
}
-
+
@Override
public ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean isWorkspacePath) {
return new CSourceEntry(p, ex, isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0);
}
+
@Override
public ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean isWorkspacePath) {
return new CSourceEntry(f, ex, isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0);
}
+
@Override
public ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd) {
return cfgd.getConfiguration().getSourceEntries();
}
+
@Override
public void setEntries(ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data) {
ICSourceEntry[] out = null;
if (data != null) {
out = new ICSourceEntry[data.length];
- for (int i=0; i<out.length; i++) out[i] = (ICSourceEntry)data[i];
+ for (int i = 0; i < out.length; i++)
+ out[i] = (ICSourceEntry) data[i];
}
try {
cfgd.getConfiguration().setSourceEntries(out);
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java
index 41e466f5d1f..b4907dca011 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java
@@ -79,7 +79,10 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
class _Filter {
_Entry entry;
- _Filter(_Entry _entry) { entry = _entry; }
+
+ _Filter(_Entry _entry) {
+ entry = _entry;
+ }
public IPath[] getExtPaths() {
IPath[] p = null;
@@ -92,7 +95,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
if (p == null || p.length == 0)
return new String[0];
String[] s = new String[p.length];
- for (int i=0; i<p.length; i++)
+ for (int i = 0; i < p.length; i++)
s[i] = p[i].toOSString();
return s;
}
@@ -113,21 +116,19 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
class _Entry {
ICExclusionPatternPathEntry ent;
_Filter[] f = new _Filter[1];
+
_Entry(ICExclusionPatternPathEntry _ent) {
ent = _ent;
f[0] = new _Filter(this);
}
+
@Override
public String toString() {
- return getPath() == null ?
- EMPTY_STR :
- getPath().toString();
+ return getPath() == null ? EMPTY_STR : getPath().toString();
}
public IPath getPath() {
- return ent.isValueWorkspacePath() ?
- ent.getFullPath() :
- ent.getLocation();
+ return ent.isValueWorkspacePath() ? ent.getFullPath() : ent.getLocation();
}
}
@@ -143,35 +144,44 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
@Override
public void widgetSelected(SelectionEvent e) {
updateButtons();
- }});
+ }
+ });
- initButtons(new String[] {Messages.CLocationTab_4, Messages.CLocationTab_5, Messages.CLocationTab_6, Messages.CLocationTab_7}, 150);
+ initButtons(new String[] { Messages.CLocationTab_4, Messages.CLocationTab_5, Messages.CLocationTab_6,
+ Messages.CLocationTab_7 }, 150);
tree.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof _Entry)
- return ((_Entry)parentElement).f;
+ return ((_Entry) parentElement).f;
return null;
}
+
@Override
public Object getParent(Object element) {
if (element instanceof _Filter)
- return ((_Filter)element).entry;
+ return ((_Filter) element).entry;
return null;
}
+
@Override
public boolean hasChildren(Object element) {
return (element instanceof _Entry);
}
+
@Override
public Object[] getElements(Object inputElement) {
return src.toArray(new _Entry[src.size()]);
}
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }});
+ }
+ });
tree.setLabelProvider(new LabelProvider() {
@Override
@@ -194,8 +204,8 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
@Override
protected void updateButtons() {
TreeItem[] sel = tree.getTree().getSelection();
- buttonSetEnabled(2, sel.length == 1);
- buttonSetEnabled(3, sel.length > 0 && sel[0].getData() instanceof _Entry);
+ buttonSetEnabled(2, sel.length == 1);
+ buttonSetEnabled(3, sel.length > 0 && sel[0].getData() instanceof _Entry);
}
@Override
@@ -214,7 +224,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
break;
// create / link
case 1:
- NewFolderDialog d = new NewFolderDialog(shell, page.getProject()) {
+ NewFolderDialog d = new NewFolderDialog(shell, page.getProject()) {
@Override
public void create() {
super.create();
@@ -222,22 +232,25 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
}
};
if (d.open() == Window.OK) {
- IFolder f = (IFolder)d.getFirstResult();
+ IFolder f = (IFolder) d.getFirstResult();
src.add(new _Entry(newEntry(f, new IPath[0], !f.isLinked())));
saveData();
}
break;
// edit filter
case 2:
- if (sel.length == 0) return;
+ if (sel.length == 0)
+ return;
Object data = sel[0].getData();
_Entry entry = null;
if (data instanceof _Entry)
- entry = (_Entry)data;
+ entry = (_Entry) data;
else if (data instanceof _Filter)
- entry = ((_Filter)data).entry;
- else return;
- ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(), entry.getPath(), page.getProject());
+ entry = ((_Filter) data).entry;
+ else
+ return;
+ ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(),
+ entry.getPath(), page.getProject());
if (dialog.open() == Window.OK) {
IPath[] ps = dialog.getExclusionPattern();
IPath path = entry.getPath();
@@ -247,10 +260,12 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
}
break;
case 3:
- if (sel.length == 0) return;
+ if (sel.length == 0)
+ return;
for (TreeItem element : sel) {
- if (element.getData() instanceof _Entry) src.remove(element.getData());
- }
+ if (element.getData() instanceof _Entry)
+ src.remove(element.getData());
+ }
saveData();
break;
default:
@@ -261,14 +276,16 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
private void saveData() {
ICExclusionPatternPathEntry[] p = new ICExclusionPatternPathEntry[src.size()];
Iterator<_Entry> it = src.iterator();
- int i=0;
- while(it.hasNext()) { p[i++] = (it.next()).ent; }
+ int i = 0;
+ while (it.hasNext()) {
+ p[i++] = (it.next()).ent;
+ }
setEntries(cfgd, p);
tree.setInput(cfgd);
updateData(cfgd);
if (page instanceof AbstractPage) {
ICConfigurationDescription cfgDescription = cfgd.getConfiguration();
- ((AbstractPage)page).cfgChanged(cfgDescription);
+ ((AbstractPage) page).cfgChanged(cfgDescription);
}
}
@@ -282,9 +299,9 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
cfgd = _cfgd;
IAdaptable ad = page.getElement();
if (ad instanceof ICProject) {
- cprj = (ICProject)ad;
+ cprj = (ICProject) ad;
}
- IResource rc = (IResource)ad;
+ IResource rc = (IResource) ad;
setAllVisible(true, null);
@@ -298,8 +315,8 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
src.add(entry);
}
tree.setInput(src);
- if (selectedSourcePath!=null) {
- ISelection selection = new StructuredSelection(new Object[] {selectedSourcePath});
+ if (selectedSourcePath != null) {
+ ISelection selection = new StructuredSelection(new Object[] { selectedSourcePath });
tree.setSelection(selection);
}
@@ -312,8 +329,11 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
}
protected abstract ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd);
- protected abstract void setEntries (ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data);
+
+ protected abstract void setEntries(ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data);
+
protected abstract ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean workspacePath);
+
protected abstract ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean workspacePath);
@Override
@@ -323,10 +343,9 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
@Override
protected void performDefaults() {
- setEntries(cfgd, null);
- updateData(cfgd);
- }
-
+ setEntries(cfgd, null);
+ updateData(cfgd);
+ }
// This page can be displayed either for project or for folder
@Override
@@ -351,8 +370,8 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
Object[] resources = dialog.getResult();
if (resources != null) {
String[] ss = new String[resources.length];
- for (int i=0; i<resources.length; i++)
- ss[i] = ((Holder)resources[i]).getPath().toString();
+ for (int i = 0; i < resources.length; i++)
+ ss[i] = ((Holder) resources[i]).getPath().toString();
return ss;
}
}
@@ -363,7 +382,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
* This class should hold elements for source location tree
*/
class Holder implements IAdaptable {
- private IFolder f = null;
+ private IFolder f = null;
private boolean isRoot = false;
private IPath p = null;
@@ -383,12 +402,15 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
public <T> T getAdapter(Class<T> adapter) {
return f.getAdapter(adapter);
}
+
public boolean isRoot() {
return isRoot;
}
+
public IFolder getFolder() {
return f;
}
+
public IPath getPath() {
return p;
}
@@ -439,66 +461,66 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
}
}
- class LocDialog extends ElementTreeSelectionDialog {
- Set <IPath> existing;
+ class LocDialog extends ElementTreeSelectionDialog {
+ Set<IPath> existing;
- public LocDialog(Shell parent, Set <IPath> ex) {
+ public LocDialog(Shell parent, Set<IPath> ex) {
super(parent,
- new WorkbenchLabelProvider() {
- @Override
- protected String decorateText(String input, Object element) {
- if (element instanceof Holder &&
- ((Holder)element).isRoot())
- return Messages.CLocationTab_8;
- return super.decorateText(input, element);
- }
- },
-
- new WorkbenchContentProvider() {
- @Override
- public Object[] getChildren(Object element) {
- if (element instanceof IProject) {
- Object[] ob1 = super.getChildren(element);
- Object[] ob2 = new Object[ob1.length + 1];
- int cnt = 0;
- ob2[cnt++] = new Holder((IProject)element);
- for (Object ob: ob1) {
- if (ob instanceof IFolder)
- ob2[cnt++] = new Holder((IFolder)ob);
+ new WorkbenchLabelProvider() {
+ @Override
+ protected String decorateText(String input, Object element) {
+ if (element instanceof Holder && ((Holder) element).isRoot())
+ return Messages.CLocationTab_8;
+ return super.decorateText(input, element);
}
- ob1 = new Object[cnt];
- System.arraycopy(ob2, 0, ob1, 0, cnt);
- return ob1;
- } else if (element instanceof Holder) {
- Holder h = (Holder)element;
- if (h.isRoot())
- return new Object[0];
- Object[] ob1 = super.getChildren(h.getFolder());
- Object[] ob2 = new Object[ob1.length];
- int cnt = 0;
- for (Object ob: ob1) {
- if (ob instanceof IFolder)
- ob2[cnt++] = new Holder((IFolder)ob);
+ },
+
+ new WorkbenchContentProvider() {
+ @Override
+ public Object[] getChildren(Object element) {
+ if (element instanceof IProject) {
+ Object[] ob1 = super.getChildren(element);
+ Object[] ob2 = new Object[ob1.length + 1];
+ int cnt = 0;
+ ob2[cnt++] = new Holder((IProject) element);
+ for (Object ob : ob1) {
+ if (ob instanceof IFolder)
+ ob2[cnt++] = new Holder((IFolder) ob);
+ }
+ ob1 = new Object[cnt];
+ System.arraycopy(ob2, 0, ob1, 0, cnt);
+ return ob1;
+ } else if (element instanceof Holder) {
+ Holder h = (Holder) element;
+ if (h.isRoot())
+ return new Object[0];
+ Object[] ob1 = super.getChildren(h.getFolder());
+ Object[] ob2 = new Object[ob1.length];
+ int cnt = 0;
+ for (Object ob : ob1) {
+ if (ob instanceof IFolder)
+ ob2[cnt++] = new Holder((IFolder) ob);
+ }
+ ob1 = new Object[cnt];
+ System.arraycopy(ob2, 0, ob1, 0, cnt);
+ return ob1;
+ } else
+ return super.getChildren(element);
}
- ob1 = new Object[cnt];
- System.arraycopy(ob2, 0, ob1, 0, cnt);
- return ob1;
- } else
- return super.getChildren(element);
- }
- });
+ });
- addFilter(new ViewerFilter () {
+ addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (! (element instanceof Holder))
+ if (!(element instanceof Holder))
return false;
if (existing == null || existing.size() == 0)
return true;
- Holder h = (Holder)element;
- return (! existing.contains(h.getPath()));
- }});
+ Holder h = (Holder) element;
+ return (!existing.contains(h.getPath()));
+ }
+ });
existing = ex;
}
@@ -509,12 +531,13 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
// Expand the tree and select current resource
if (page.getElement() instanceof IFolder) {
- IFolder folder = (IFolder)page.getElement();
+ IFolder folder = (IFolder) page.getElement();
List<Holder> list = new ArrayList<Holder>();
list.add(new Holder(folder));
- for (IContainer parentFolder = folder.getParent();parentFolder instanceof IFolder;parentFolder=parentFolder.getParent()) {
- list.add(0,new Holder((IFolder) parentFolder));
+ for (IContainer parentFolder = folder
+ .getParent(); parentFolder instanceof IFolder; parentFolder = parentFolder.getParent()) {
+ list.add(0, new Holder((IFolder) parentFolder));
}
treeViewer.expandToLevel(new TreePath(list.toArray()), 0);
setInitialSelection(new Holder(folder));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java
index 818ded859f0..e14eec99f2e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java
@@ -61,7 +61,9 @@ public class ConfigMultiSelectionDialog extends Dialog {
return null;
}
- public ConfigMultiSelectionDialog(Shell parentShell) { super(parentShell); }
+ public ConfigMultiSelectionDialog(Shell parentShell) {
+ super(parentShell);
+ }
@Override
protected void configureShell(Shell shell) {
@@ -91,7 +93,8 @@ public class ConfigMultiSelectionDialog extends Dialog {
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Create the current config table
- table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
+ table = new Table(composite,
+ SWT.CHECK | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
table.setLayoutData(new GridData(GridData.FILL));
table.setHeaderVisible(true);
table.setLinesVisible(true);
@@ -111,17 +114,24 @@ public class ConfigMultiSelectionDialog extends Dialog {
tv = new CheckboxTableViewer(table);
tv.setContentProvider(new IStructuredContentProvider() {
@Override
- public Object[] getElements(Object inputElement) { return cfgds; }
+ public Object[] getElements(Object inputElement) {
+ return cfgds;
+ }
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
});
tv.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent e) {
boolean enabled = (tv.getCheckedElements().length > 1);
- if (b_ok != null) b_ok.setEnabled(enabled);
+ if (b_ok != null)
+ b_ok.setEnabled(enabled);
message.setVisible(!enabled);
if (enabled) {
Object[] ob = tv.getCheckedElements();
@@ -129,26 +139,41 @@ public class ConfigMultiSelectionDialog extends Dialog {
System.arraycopy(ob, 0, result, 0, ob.length);
} else
result = null;
- }});
+ }
+ });
tv.setLabelProvider(new ITableLabelProvider() {
@Override
- public Image getColumnImage(Object element, int columnIndex) { return null; }
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
@Override
- public void addListener(ILabelProviderListener listener) {}
+ public void addListener(ILabelProviderListener listener) {
+ }
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public boolean isLabelProperty(Object element, String property) { return false;}
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
@Override
- public void removeListener(ILabelProviderListener listener) {}
+ public void removeListener(ILabelProviderListener listener) {
+ }
@Override
public String getColumnText(Object element, int index) {
- ICConfigurationDescription cfg = (ICConfigurationDescription)element;
- if (index == 0) return cfg.getName();
- if (index == 1) return cfg.getDescription();
+ ICConfigurationDescription cfg = (ICConfigurationDescription) element;
+ if (index == 0)
+ return cfg.getName();
+ if (index == 1)
+ return cfg.getDescription();
return AbstractPage.EMPTY_STR;
- }});
+ }
+ });
tv.setInput(cfgds);
table.setFocus();
return composite;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
index 733315206a6..069fb915607 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
@@ -50,11 +50,7 @@ public class EnvDialog extends Dialog {
public boolean toAll = false;
private String title;
- public EnvDialog(Shell parent,
- IEnvironmentVariable _var,
- String _title,
- boolean _newAction,
- boolean _multiCfg,
+ public EnvDialog(Shell parent, IEnvironmentVariable _var, String _title, boolean _newAction, boolean _multiCfg,
ICConfigurationDescription _cfgd) {
super(parent);
var = _var;
@@ -95,9 +91,12 @@ public class EnvDialog extends Dialog {
gd.horizontalSpan = 2;
gd.widthHint = 400;
text1.setLayoutData(gd);
- text1.addModifyListener(new ModifyListener () {
+ text1.addModifyListener(new ModifyListener() {
@Override
- public void modifyText(ModifyEvent e) { setButtons(); }});
+ public void modifyText(ModifyEvent e) {
+ setButtons();
+ }
+ });
Label l2 = new Label(c, SWT.NONE);
l2.setText(Messages.EnvDialog_1);
@@ -107,9 +106,12 @@ public class EnvDialog extends Dialog {
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 250;
text2.setLayoutData(gd);
- text2.addModifyListener(new ModifyListener () {
+ text2.addModifyListener(new ModifyListener() {
@Override
- public void modifyText(ModifyEvent e) { setButtons(); }});
+ public void modifyText(ModifyEvent e) {
+ setButtons();
+ }
+ });
final Button b = new Button(c, SWT.PUSH);
b.setText(Messages.EnvDialog_2);
@@ -121,7 +123,8 @@ public class EnvDialog extends Dialog {
text2.insert(x);
setButtons();
}
- }});
+ }
+ });
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
b.setLayoutData(gd);
@@ -136,7 +139,8 @@ public class EnvDialog extends Dialog {
@Override
public void widgetSelected(SelectionEvent e) {
toAll = b_add2all.getSelection();
- }});
+ }
+ });
if (multiCfg)
b_add2all.setVisible(false);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java
index 7cb6127adf2..cd9aad035a8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java
@@ -86,41 +86,48 @@ public class EnvironmentTab extends AbstractCPropertyTab {
private class TabData implements Comparable<TabData> {
IEnvironmentVariable var;
+
TabData(IEnvironmentVariable _var) {
var = _var;
}
+
@Override
public int compareTo(TabData a) {
String s = var.getName();
if (a != null && s != null && a.var != null)
- return (s.compareTo(a.var.getName()));
+ return (s.compareTo(a.var.getName()));
return 0;
}
}
- private class EnvironmentLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
- public EnvironmentLabelProvider(boolean user){
+ private class EnvironmentLabelProvider extends LabelProvider
+ implements ITableLabelProvider, IFontProvider, ITableFontProvider, IColorProvider {
+ public EnvironmentLabelProvider(boolean user) {
}
+
@Override
public Image getImage(Object element) {
return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
}
+
@Override
public String getText(Object element) {
return getColumnText(element, 0);
}
+
@Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
+
@Override
public String getColumnText(Object element, int columnIndex) {
- TabData td = (TabData)element;
- switch(columnIndex){
+ TabData td = (TabData) element;
+ switch (columnIndex) {
case 0:
return td.var.getName();
case 1:
- if(td.var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
+ if (td.var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
return Messages.EnvironmentTab_20;
return td.var.getValue();
case 2:
@@ -136,8 +143,8 @@ public class EnvironmentTab extends AbstractCPropertyTab {
@Override
public Font getFont(Object element, int columnIndex) {
- TabData td = (TabData)element;
- switch(columnIndex){
+ TabData td = (TabData) element;
+ switch (columnIndex) {
case 0:
if (isUsers(td.var))
return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
@@ -148,18 +155,18 @@ public class EnvironmentTab extends AbstractCPropertyTab {
return null;
}
- @Override
- public Color getForeground(Object element){
+ @Override
+ public Color getForeground(Object element) {
return null;
- }
+ }
- @Override
- public Color getBackground(Object element){
- TabData td = (TabData)element;
+ @Override
+ public Color getBackground(Object element) {
+ TabData td = (TabData) element;
if (isUsers(td.var))
return BACKGROUND_FOR_USER_VAR;
return null;
- }
+ }
}
@Override
@@ -273,13 +280,8 @@ public class EnvironmentTab extends AbstractCPropertyTab {
}
});
- initButtons(new String[] {
- Messages.EnvironmentTab_5,
- Messages.EnvironmentTab_6,
- Messages.EnvironmentTab_7,
- Messages.EnvironmentTab_8,
- Messages.EnvironmentTab_9
- });
+ initButtons(new String[] { Messages.EnvironmentTab_5, Messages.EnvironmentTab_6, Messages.EnvironmentTab_7,
+ Messages.EnvironmentTab_8, Messages.EnvironmentTab_9 });
}
@Override
@@ -306,16 +308,17 @@ public class EnvironmentTab extends AbstractCPropertyTab {
@Override
protected void updateButtons() {
- if (table == null || table.isDisposed()) return;
+ if (table == null || table.isDisposed())
+ return;
boolean canEdit = table.getSelectionCount() == 1;
- boolean canDel = false;
+ boolean canDel = false;
boolean canUndef = table.getSelectionCount() >= 1;
if (canUndef) {
for (int i : table.getSelectionIndices()) {
- IEnvironmentVariable var = ((TabData)tv.getElementAt(i)).var;
+ IEnvironmentVariable var = ((TabData) tv.getElementAt(i)).var;
if (isUsers(var)) {
- // if (cfgd == null || !wse.getVariable(var.))
+ // if (cfgd == null || !wse.getVariable(var.))
canDel = true;
break;
}
@@ -342,13 +345,13 @@ public class EnvironmentTab extends AbstractCPropertyTab {
if (cfgd != null) {
b1.setSelection(ce.appendEnvironment(cfgd));
b2.setSelection(!ce.appendEnvironment(cfgd));
- _vars = ce.getVariables(cfgd);
+ _vars = ce.getVariables(cfgd);
} else {
if (vars == null)
vars = fUserSupplier.getWorkspaceEnvironmentCopy();
b1.setSelection(vars.appendContributedEnvironment());
b2.setSelection(!vars.appendContributedEnvironment());
- _vars = vars.getVariables() ;
+ _vars = vars.getVariables();
}
data.clear();
@@ -360,7 +363,7 @@ public class EnvironmentTab extends AbstractCPropertyTab {
Collections.sort(data);
tv.setInput(data);
- if (stringListModeControl!=null) {
+ if (stringListModeControl != null) {
stringListModeControl.updateStringListModeControl();
}
updateButtons();
@@ -378,8 +381,8 @@ public class EnvironmentTab extends AbstractCPropertyTab {
v = ce.getVariables(src);
for (IEnvironmentVariable element : v) {
if (ce.isUserVariable(src, element))
- ce.addVariable(element.getName(), element.getValue(),
- element.getOperation(), element.getDelimiter(), dst);
+ ce.addVariable(element.getName(), element.getValue(), element.getOperation(), element.getDelimiter(),
+ dst);
}
}
@@ -388,45 +391,44 @@ public class EnvironmentTab extends AbstractCPropertyTab {
*/
private class MyListSelectionDialog extends ListSelectionDialog {
public boolean toAll = false;
- public MyListSelectionDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider) {
- super(parentShell, input, contentProvider, new LabelProvider() {}, Messages.EnvironmentTab_12);
- }
- @Override
+
+ public MyListSelectionDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider) {
+ super(parentShell, input, contentProvider, new LabelProvider() {
+ }, Messages.EnvironmentTab_12);
+ }
+
+ @Override
protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- Button b = new Button(composite, SWT.CHECK);
- b.setText(Messages.EnvironmentTab_13);
- b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- if (cfgd == null)
- b.setVisible(false);
- else
- b.addSelectionListener(new SelectionAdapter() {
- @Override
+ Composite composite = (Composite) super.createDialogArea(parent);
+ Button b = new Button(composite, SWT.CHECK);
+ b.setText(Messages.EnvironmentTab_13);
+ b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ if (cfgd == null)
+ b.setVisible(false);
+ else
+ b.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
- toAll = ((Button)e.widget).getSelection();
- }});
- return composite;
- }
+ toAll = ((Button) e.widget).getSelection();
+ }
+ });
+ return composite;
+ }
}
private void handleEnvEditButtonSelected(int n) {
if (n == -1)
return;
- IEnvironmentVariable var = ((TabData)tv.getElementAt(n)).var;
- EnvDialog dlg = new EnvDialog(usercomp.getShell(),
- var,
- Messages.EnvironmentTab_11,
- false,
- page.isMultiCfg(),
+ IEnvironmentVariable var = ((TabData) tv.getElementAt(n)).var;
+ EnvDialog dlg = new EnvDialog(usercomp.getShell(), var, Messages.EnvironmentTab_11, false, page.isMultiCfg(),
cfgd);
if (dlg.open() == Window.OK) {
if (cfgd != null)
- ce.addVariable( var.getName(), dlg.t2.trim(),
- IEnvironmentVariable.ENVVAR_REPLACE,
- var.getDelimiter(), cfgd);
+ ce.addVariable(var.getName(), dlg.t2.trim(), IEnvironmentVariable.ENVVAR_REPLACE, var.getDelimiter(),
+ cfgd);
else
- vars.createVariable(dlg.t1.trim(), dlg.t2.trim(),
- IEnvironmentVariable.ENVVAR_REPLACE, var.getDelimiter());
+ vars.createVariable(dlg.t1.trim(), dlg.t2.trim(), IEnvironmentVariable.ENVVAR_REPLACE,
+ var.getDelimiter());
updateData();
table.setSelection(n);
updateButtons();
@@ -437,19 +439,11 @@ public class EnvironmentTab extends AbstractCPropertyTab {
if (n == -1)
return;
for (int i : table.getSelectionIndices()) {
- IEnvironmentVariable var = ((TabData)tv.getElementAt(i)).var;
+ IEnvironmentVariable var = ((TabData) tv.getElementAt(i)).var;
if (cfgd == null)
- vars.createVariable(
- var.getName(),
- null,
- IEnvironmentVariable.ENVVAR_REMOVE,
- var.getDelimiter());
+ vars.createVariable(var.getName(), null, IEnvironmentVariable.ENVVAR_REMOVE, var.getDelimiter());
else
- ce.addVariable(
- var.getName(),
- null,
- IEnvironmentVariable.ENVVAR_REMOVE,
- var.getDelimiter(), cfgd);
+ ce.addVariable(var.getName(), null, IEnvironmentVariable.ENVVAR_REMOVE, var.getDelimiter(), cfgd);
}
updateData();
table.setSelection(n);
@@ -460,7 +454,7 @@ public class EnvironmentTab extends AbstractCPropertyTab {
if (n == -1)
return;
for (int i : table.getSelectionIndices()) {
- IEnvironmentVariable var = ((TabData)tv.getElementAt(i)).var;
+ IEnvironmentVariable var = ((TabData) tv.getElementAt(i)).var;
if (cfgd == null)
vars.deleteVariable(var.getName());
else
@@ -476,11 +470,7 @@ public class EnvironmentTab extends AbstractCPropertyTab {
private void handleEnvAddButtonSelected() {
IEnvironmentVariable var = null;
- EnvDialog dlg = new EnvDialog(usercomp.getShell(),
- var,
- Messages.EnvironmentTab_10,
- true,
- page.isMultiCfg(),
+ EnvDialog dlg = new EnvDialog(usercomp.getShell(), var, Messages.EnvironmentTab_10, true, page.isMultiCfg(),
cfgd);
if (dlg.open() == Window.OK) {
String name = dlg.t1.trim();
@@ -489,15 +479,12 @@ public class EnvironmentTab extends AbstractCPropertyTab {
if (dlg.toAll)
cfgs = page.getCfgsEditable();
else
- cfgs = new ICConfigurationDescription[] {cfgd};
+ cfgs = new ICConfigurationDescription[] { cfgd };
if (cfgd == null)
- vars.createVariable(name, dlg.t2.trim(),
- IEnvironmentVariable.ENVVAR_APPEND, SEPARATOR);
+ vars.createVariable(name, dlg.t2.trim(), IEnvironmentVariable.ENVVAR_APPEND, SEPARATOR);
else
for (ICConfigurationDescription cfg : cfgs) {
- ce.addVariable(name, dlg.t2.trim(),
- IEnvironmentVariable.ENVVAR_APPEND,
- SEPARATOR, cfg);
+ ce.addVariable(name, dlg.t2.trim(), IEnvironmentVariable.ENVVAR_APPEND, SEPARATOR, cfg);
}
updateData();
setPos(name);
@@ -508,7 +495,7 @@ public class EnvironmentTab extends AbstractCPropertyTab {
private void setPos(String name) {
if (name == null || name.length() == 0)
return;
- for (int i=0; i<table.getItemCount(); i++) {
+ for (int i = 0; i < table.getItemCount(); i++) {
if (name.equals(table.getItem(i).getText())) {
table.setSelection(i);
updateButtons();
@@ -519,8 +506,9 @@ public class EnvironmentTab extends AbstractCPropertyTab {
private void handleEnvSelectButtonSelected() {
// get Environment Variables from the OS
- Map<?,?> v = EnvironmentReader.getEnvVars();
- MyListSelectionDialog dialog = new MyListSelectionDialog(usercomp.getShell(), v, createSelectionDialogContentProvider());
+ Map<?, ?> v = EnvironmentReader.getEnvVars();
+ MyListSelectionDialog dialog = new MyListSelectionDialog(usercomp.getShell(), v,
+ createSelectionDialogContentProvider());
dialog.setTitle(Messages.EnvironmentTab_14);
if (dialog.open() == Window.OK) {
@@ -529,11 +517,11 @@ public class EnvironmentTab extends AbstractCPropertyTab {
if (dialog.toAll)
cfgs = page.getCfgsEditable();
else
- cfgs = new ICConfigurationDescription[] {cfgd};
+ cfgs = new ICConfigurationDescription[] { cfgd };
String name = null;
for (Object element : selected) {
- name = (String)element;
+ name = (String) element;
String value = EMPTY_STR;
int x = name.indexOf(LBR);
if (x >= 0) {
@@ -545,11 +533,8 @@ public class EnvironmentTab extends AbstractCPropertyTab {
vars.createVariable(name, value);
else
for (ICConfigurationDescription cfg : cfgs) {
- ce.addVariable(
- name, value,
- IEnvironmentVariable.ENVVAR_APPEND,
- SEPARATOR, cfg);
- }
+ ce.addVariable(name, value, IEnvironmentVariable.ENVVAR_APPEND, SEPARATOR, cfg);
+ }
}
updateData();
setPos(name);
@@ -564,7 +549,7 @@ public class EnvironmentTab extends AbstractCPropertyTab {
String[] els = null;
if (inputElement instanceof Map<?, ?>) {
@SuppressWarnings("unchecked")
- Map<String, String> m = (Map<String, String>)inputElement;
+ Map<String, String> m = (Map<String, String>) inputElement;
els = new String[m.size()];
int index = 0;
for (Iterator<String> iterator = m.keySet().iterator(); iterator.hasNext(); index++) {
@@ -575,12 +560,17 @@ public class EnvironmentTab extends AbstractCPropertyTab {
Arrays.sort(els, CDTListComparator.getInstance());
return els;
}
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
};
}
+
// This page can be displayed for project only
@Override
public boolean canBeVisible() {
@@ -613,9 +603,8 @@ public class EnvironmentTab extends AbstractCPropertyTab {
}
private boolean isUsers(IEnvironmentVariable var) {
- return cfgd == null ||
- (ce.isUserVariable(cfgd, var) &&
- ((EnvVarDescriptor)var).getContextInfo().getContext() != null);
+ return cfgd == null
+ || (ce.isUserVariable(cfgd, var) && ((EnvVarDescriptor) var).getContextInfo().getContext() != null);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java
index 1557ce9a095..832e75d9fda 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java
@@ -75,7 +75,6 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.newui.Messages;
-
/**
* This class represents Error Parser Tab in Project Properties or workspace Preferences
*
@@ -90,14 +89,8 @@ public class ErrorParsTab extends AbstractCPropertyTab {
private static final int BUTTON_MOVEUP = 4;
private static final int BUTTON_MOVEDOWN = 5;
- private static final String[] BUTTONS = new String[] {
- ADD_STR,
- EDIT_STR,
- DEL_STR,
- null,
- MOVEUP_STR,
- MOVEDOWN_STR,
- };
+ private static final String[] BUTTONS = new String[] { ADD_STR, EDIT_STR, DEL_STR, null, MOVEUP_STR,
+ MOVEDOWN_STR, };
private static final String RESET_STR = Messages.ErrorParsTab_Reset;
private static final String OOPS = "OOPS"; //$NON-NLS-1$
@@ -145,27 +138,32 @@ public class ErrorParsTab extends AbstractCPropertyTab {
public void widgetSelected(SelectionEvent e) {
displaySelectedOptionPage();
updateButtons();
- }});
+ }
+ });
fTableViewer = new CheckboxTableViewer(fTable);
fTableViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- return (Object[])inputElement;
+ return (Object[]) inputElement;
}
+
@Override
- public void dispose() {}
+ public void dispose() {
+ }
+
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
});
fTableViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof String) {
- String id = (String)element;
+ String id = (String) element;
IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
- if (errorParser!=null) {
+ if (errorParser != null) {
String name = errorParser.getName();
- if (name!=null && name.length()>0) {
+ if (name != null && name.length() > 0) {
return name;
}
}
@@ -207,7 +205,8 @@ public class ErrorParsTab extends AbstractCPropertyTab {
@Override
public void checkStateChanged(CheckStateChangedEvent e) {
saveChecked();
- }});
+ }
+ });
// Buttons
Composite compositeButtons = new Composite(compositeSashForm, SWT.NONE);
@@ -227,17 +226,17 @@ public class ErrorParsTab extends AbstractCPropertyTab {
gd.horizontalSpan = 2;
fCompositeForOptionsPage.setLayoutData(gd);
- sashForm.setWeights(new int[] {50, 50});
+ sashForm.setWeights(new int[] { 50, 50 });
// init data
ICResourceDescription resDecs = getResDesc();
- fCfgDesc = resDecs!=null ? resDecs.getConfiguration() : null;
+ fCfgDesc = resDecs != null ? resDecs.getConfiguration() : null;
initMapParsers();
updateData(getResDesc());
}
private void initMapParsers() {
- if (fExtensionErrorParsers==null) {
+ if (fExtensionErrorParsers == null) {
fExtensionErrorParsers = new LinkedHashMap<String, IErrorParserNamed>();
String[] idsExt = ErrorParserManager.getErrorParserExtensionIds();
for (String idExt : idsExt) {
@@ -254,10 +253,10 @@ public class ErrorParsTab extends AbstractCPropertyTab {
}
String ids[];
- if (fCfgDesc!=null) {
+ if (fCfgDesc != null) {
ICConfigurationDescription srcCfgDesc = fCfgDesc.getConfiguration();
if (srcCfgDesc instanceof ICMultiConfigDescription) {
- String[][] ss = ((ICMultiConfigDescription)srcCfgDesc).getErrorParserIDs();
+ String[][] ss = ((ICMultiConfigDescription) srcCfgDesc).getErrorParserIDs();
ids = CDTPrefUtil.getStrListForDisplay(ss);
} else {
ids = srcCfgDesc.getBuildSetting().getErrorParserIDs();
@@ -276,13 +275,14 @@ public class ErrorParsTab extends AbstractCPropertyTab {
private void initializeOptionsPage(final String id) {
IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
- if (errorParser!=null) {
+ if (errorParser != null) {
String name = errorParser.getName();
- if (name!=null && name.length()>0) {
+ if (name != null && name.length() > 0) {
// RegexErrorParser has an Options page
if (errorParser instanceof RegexErrorParser) {
// allow to edit only for Build Settings Preference Page (where cfgd==null)
- RegexErrorParserOptionPage optionsPage = new RegexErrorParserOptionPage((RegexErrorParser) errorParser, isErrorParsersEditable());
+ RegexErrorParserOptionPage optionsPage = new RegexErrorParserOptionPage(
+ (RegexErrorParser) errorParser, isErrorParsersEditable());
optionsPage.addListener(new Listener() {
@Override
public void handleEvent(Event event) {
@@ -305,10 +305,10 @@ public class ErrorParsTab extends AbstractCPropertyTab {
fCurrentOptionsPage.setVisible(false);
int pos = fTable.getSelectionIndex();
- if (pos<0)
+ if (pos < 0)
return;
- String parserId = (String)fTable.getItem(pos).getData();
+ String parserId = (String) fTable.getItem(pos).getData();
ICOptionPage optionsPage = fOptionsPageMap.get(parserId);
if (optionsPage != null) {
optionsPage.setVisible(true);
@@ -320,7 +320,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
* @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#buttonPressed(int)
*/
@Override
- public void buttonPressed (int n) {
+ public void buttonPressed(int n) {
switch (n) {
case BUTTON_ADD:
addErrorParser();
@@ -346,13 +346,13 @@ public class ErrorParsTab extends AbstractCPropertyTab {
// Move item up / down
private void moveItem(boolean up) {
int n = fTable.getSelectionIndex();
- if (n < 0 || (up && n == 0) || (!up && n+1 == fTable.getItemCount()))
+ if (n < 0 || (up && n == 0) || (!up && n + 1 == fTable.getItemCount()))
return;
- String id = (String)fTableViewer.getElementAt(n);
+ String id = (String) fTableViewer.getElementAt(n);
boolean checked = fTableViewer.getChecked(id);
fTableViewer.remove(id);
- n = up ? n-1 : n+1;
+ n = up ? n - 1 : n + 1;
fTableViewer.insert(id, n);
fTableViewer.setChecked(id, checked);
fTable.setSelection(n);
@@ -361,7 +361,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
}
private String makeId(String name) {
- return CUIPlugin.PLUGIN_ID+'.'+name;
+ return CUIPlugin.PLUGIN_ID + '.' + name;
}
private void addErrorParser() {
@@ -371,8 +371,8 @@ public class ErrorParsTab extends AbstractCPropertyTab {
StatusInfo status = new StatusInfo();
if (newText.trim().length() == 0) {
status.setError(Messages.ErrorParsTab_error_NonEmptyName);
- } else if (newText.indexOf(ErrorParserManager.ERROR_PARSER_DELIMITER)>=0) {
- String message = MessageFormat.format( Messages.ErrorParsTab_error_IllegalCharacter,
+ } else if (newText.indexOf(ErrorParserManager.ERROR_PARSER_DELIMITER) >= 0) {
+ String message = MessageFormat.format(Messages.ErrorParsTab_error_IllegalCharacter,
new Object[] { ErrorParserManager.ERROR_PARSER_DELIMITER });
status.setError(message);
} else if (fAvailableErrorParsers.containsKey(makeId(newText))) {
@@ -382,10 +382,8 @@ public class ErrorParsTab extends AbstractCPropertyTab {
}
};
- InputStatusDialog addDialog = new InputStatusDialog(usercomp.getShell(),
- Messages.ErrorParsTab_title_Add,
- Messages.ErrorParsTab_label_EnterName,
- Messages.ErrorParsTab_label_DefaultRegexErrorParserName,
+ InputStatusDialog addDialog = new InputStatusDialog(usercomp.getShell(), Messages.ErrorParsTab_title_Add,
+ Messages.ErrorParsTab_label_EnterName, Messages.ErrorParsTab_label_DefaultRegexErrorParserName,
inputValidator);
addDialog.setHelpAvailable(false);
@@ -397,7 +395,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
fTableViewer.add(newId);
fTableViewer.setChecked(newId, true);
- fTable.setSelection(fTable.getItemCount()-1);
+ fTable.setSelection(fTable.getItemCount() - 1);
initializeOptionsPage(newId);
displaySelectedOptionPage();
@@ -407,9 +405,9 @@ public class ErrorParsTab extends AbstractCPropertyTab {
private void editErrorParser() {
int n = fTable.getSelectionIndex();
- Assert.isTrue(n>=0);
+ Assert.isTrue(n >= 0);
- String id = (String)fTableViewer.getElementAt(n);
+ String id = (String) fTableViewer.getElementAt(n);
IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
IInputStatusValidator inputValidator = new IInputStatusValidator() {
@@ -418,8 +416,8 @@ public class ErrorParsTab extends AbstractCPropertyTab {
StatusInfo status = new StatusInfo();
if (newText.trim().length() == 0) {
status.setError(Messages.ErrorParsTab_error_NonEmptyName);
- } else if (newText.indexOf(ErrorParserManager.ERROR_PARSER_DELIMITER)>=0) {
- String message = MessageFormat.format( Messages.ErrorParsTab_error_IllegalCharacter,
+ } else if (newText.indexOf(ErrorParserManager.ERROR_PARSER_DELIMITER) >= 0) {
+ String message = MessageFormat.format(Messages.ErrorParsTab_error_IllegalCharacter,
new Object[] { ErrorParserManager.ERROR_PARSER_DELIMITER });
status.setError(message);
}
@@ -427,11 +425,8 @@ public class ErrorParsTab extends AbstractCPropertyTab {
}
};
- InputStatusDialog addDialog = new InputStatusDialog(usercomp.getShell(),
- Messages.ErrorParsTab_title_Edit,
- Messages.ErrorParsTab_label_EnterName,
- errorParser.getName(),
- inputValidator);
+ InputStatusDialog addDialog = new InputStatusDialog(usercomp.getShell(), Messages.ErrorParsTab_title_Edit,
+ Messages.ErrorParsTab_label_EnterName, errorParser.getName(), inputValidator);
addDialog.setHelpAvailable(false);
if (addDialog.open() == Window.OK) {
@@ -445,7 +440,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
if (n < 0)
return;
- String id = (String)fTableViewer.getElementAt(n);
+ String id = (String) fTableViewer.getElementAt(n);
if (fExtensionErrorParsers.containsKey(id)) {
// Reset
fAvailableErrorParsers.put(id, ErrorParserManager.getErrorParserExtensionCopy(id));
@@ -457,9 +452,9 @@ public class ErrorParsTab extends AbstractCPropertyTab {
fTableViewer.remove(id);
int last = fTable.getItemCount() - 1;
- if (n>last)
+ if (n > last)
n = last;
- if (n>=0)
+ if (n >= 0)
fTable.setSelection(n);
saveChecked();
@@ -472,8 +467,8 @@ public class ErrorParsTab extends AbstractCPropertyTab {
@Override
public void updateData(ICResourceDescription resDecs) {
ICConfigurationDescription oldCfgDesc = fCfgDesc;
- fCfgDesc = resDecs!=null ? resDecs.getConfiguration() : null;
- if (oldCfgDesc!=fCfgDesc) {
+ fCfgDesc = resDecs != null ? resDecs.getConfiguration() : null;
+ if (oldCfgDesc != fCfgDesc) {
initMapParsers();
}
displaySelectedOptionPage();
@@ -495,7 +490,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
private boolean isModified(String id) {
IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
IErrorParserNamed errorParserExt = fExtensionErrorParsers.get(id);
- return ! errorParser.equals(errorParserExt);
+ return !errorParser.equals(errorParserExt);
}
/* (non-Javadoc)
@@ -507,7 +502,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
int count = fTable.getItemCount();
int last = count - 1;
boolean selected = pos >= 0 && pos <= last;
- String id = (String)fTableViewer.getElementAt(pos);
+ String id = (String) fTableViewer.getElementAt(pos);
boolean isExtensionId = isExtensionId(id);
boolean canDelete = !isExtensionId && isErrorParsersEditable();
@@ -518,11 +513,10 @@ public class ErrorParsTab extends AbstractCPropertyTab {
buttonSetEnabled(BUTTON_ADD, isErrorParsersEditable());
buttonSetEnabled(BUTTON_EDIT, isErrorParsersEditable() && selected);
buttonSetEnabled(BUTTON_DELETE, (canDelete || canReset) && selected);
- buttonSetEnabled(BUTTON_MOVEUP, selected && pos!=0);
- buttonSetEnabled(BUTTON_MOVEDOWN, selected && pos!=last);
+ buttonSetEnabled(BUTTON_MOVEUP, selected && pos != 0);
+ buttonSetEnabled(BUTTON_MOVEDOWN, selected && pos != last);
}
-
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#performApply(org.eclipse.cdt.core.settings.model.ICResourceDescription, org.eclipse.cdt.core.settings.model.ICResourceDescription)
*/
@@ -535,13 +529,13 @@ public class ErrorParsTab extends AbstractCPropertyTab {
ICConfigurationDescription dd = dst.getConfiguration();
String[] s = null;
if (sd instanceof ICMultiConfigDescription) {
- String[][] ss = ((ICMultiConfigDescription)sd).getErrorParserIDs();
+ String[][] ss = ((ICMultiConfigDescription) sd).getErrorParserIDs();
s = CDTPrefUtil.getStrListForDisplay(ss);
} else {
s = sd.getBuildSetting().getErrorParserIDs();
}
if (dd instanceof ICMultiConfigDescription)
- ((ICMultiConfigDescription)dd).setErrorParserIDs(s);
+ ((ICMultiConfigDescription) dd).setErrorParserIDs(s);
else
dd.getBuildSetting().setErrorParserIDs(s);
initMapParsers();
@@ -556,7 +550,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
informPages(true);
if (page.isForPrefs()) {
- if (fCfgDesc==null) {
+ if (fCfgDesc == null) {
// Build Settings page
try {
List<IErrorParserNamed> errorParsersList = new ArrayList<IErrorParserNamed>(fTable.getItemCount());
@@ -574,7 +568,8 @@ public class ErrorParsTab extends AbstractCPropertyTab {
System.arraycopy(checkedElements, 0, checkedErrorParserIds, 0, checkedElements.length);
ErrorParserManager.setDefaultErrorParserIds(checkedErrorParserIds);
- ErrorParserManager.setUserDefinedErrorParsers(errorParsersList.toArray(new IErrorParserNamed[errorParsersList.size()]));
+ ErrorParserManager.setUserDefinedErrorParsers(
+ errorParsersList.toArray(new IErrorParserNamed[errorParsersList.size()]));
} catch (BackingStoreException e) {
CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e);
} catch (CoreException e) {
@@ -586,13 +581,13 @@ public class ErrorParsTab extends AbstractCPropertyTab {
}
private void saveChecked() {
- if (fCfgDesc!=null) {
+ if (fCfgDesc != null) {
Object[] objs = fTableViewer.getCheckedElements();
String[] ids = new String[objs.length];
System.arraycopy(objs, 0, ids, 0, objs.length);
if (fCfgDesc instanceof ICMultiConfigDescription)
- ((ICMultiConfigDescription)fCfgDesc).setErrorParserIDs(ids);
+ ((ICMultiConfigDescription) fCfgDesc).setErrorParserIDs(ids);
else
fCfgDesc.getBuildSetting().setErrorParserIDs(ids);
}
@@ -613,7 +608,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
* not for Preference New CDT Project Wizard/Makefile Project.
*/
private boolean isErrorParsersEditable() {
- return fCfgDesc==null;
+ return fCfgDesc == null;
}
/* (non-Javadoc)
@@ -623,8 +618,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
protected void performDefaults() {
if (isErrorParsersEditable()) {
// Must be Build Settings Preference Page
- if (MessageDialog.openQuestion(usercomp.getShell(),
- Messages.ErrorParsTab_title_ConfirmReset,
+ if (MessageDialog.openQuestion(usercomp.getShell(), Messages.ErrorParsTab_title_ConfirmReset,
Messages.ErrorParsTab_message_ConfirmReset)) {
try {
@@ -649,7 +643,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
private void informPages(boolean apply) {
Collection<ICOptionPage> pages = fOptionsPageMap.values();
for (ICOptionPage dynamicPage : pages) {
- if (dynamicPage!=null && dynamicPage.isValid() && dynamicPage.getControl() != null) {
+ if (dynamicPage != null && dynamicPage.isValid() && dynamicPage.getControl() != null) {
try {
if (apply)
dynamicPage.performApply(new NullProgressMonitor());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java
index f1fe66c4d4c..e3d22465657 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java
@@ -68,10 +68,10 @@ public class ExPatternDialog extends StatusDialog {
private IPath path;
private IContainer fCurrSourceFolder;
- private static final int IDX_ADD= 0;
- private static final int IDX_ADD_MULTIPLE= 1;
- private static final int IDX_EDIT= 2;
- private static final int IDX_REMOVE= 4;
+ private static final int IDX_ADD = 0;
+ private static final int IDX_ADD_MULTIPLE = 1;
+ private static final int IDX_EDIT = 2;
+ private static final int IDX_REMOVE = 4;
public ExPatternDialog(Shell parent, IPath[] _data, IPath _path, IProject proj) {
super(parent);
@@ -80,32 +80,29 @@ public class ExPatternDialog extends StatusDialog {
path = _path;
setTitle(CPathEntryMessages.ExclusionPatternDialog_title);
- String label= NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label,
+ String label = NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label,
path.makeRelative().toString());
- String[] buttonLabels= new String[] {
- CPathEntryMessages.ExclusionPatternDialog_pattern_add,
- CPathEntryMessages.ExclusionPatternDialog_pattern_add_multiple,
- CPathEntryMessages.ExclusionPatternDialog_pattern_edit,
- null,
- CPathEntryMessages.ExclusionPatternDialog_pattern_remove
- };
+ String[] buttonLabels = new String[] { CPathEntryMessages.ExclusionPatternDialog_pattern_add,
+ CPathEntryMessages.ExclusionPatternDialog_pattern_add_multiple,
+ CPathEntryMessages.ExclusionPatternDialog_pattern_edit, null,
+ CPathEntryMessages.ExclusionPatternDialog_pattern_remove };
- ExclusionPatternAdapter adapter= new ExclusionPatternAdapter();
+ ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
- fExclusionPatternList= new ListDialogField<String>(adapter, buttonLabels, new ExPatternLabelProvider());
+ fExclusionPatternList = new ListDialogField<String>(adapter, buttonLabels, new ExPatternLabelProvider());
fExclusionPatternList.setDialogFieldListener(adapter);
fExclusionPatternList.setLabelText(label);
fExclusionPatternList.setRemoveButtonIndex(IDX_REMOVE);
fExclusionPatternList.enableButton(IDX_EDIT, false);
- IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot();
- IResource res= root.findMember(path);
+ IWorkspaceRoot root = fCurrProject.getWorkspace().getRoot();
+ IResource res = root.findMember(path);
if (res instanceof IContainer) {
- fCurrSourceFolder= (IContainer) res;
+ fCurrSourceFolder = (IContainer) res;
}
- ArrayList<String> elements= new ArrayList<String>(pattern.length);
+ ArrayList<String> elements = new ArrayList<String>(pattern.length);
for (IPath p : pattern)
elements.add(p.toString());
fExclusionPatternList.setElements(elements);
@@ -117,13 +114,13 @@ public class ExPatternDialog extends StatusDialog {
@Override
protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
+ Composite composite = (Composite) super.createDialogArea(parent);
- Composite inner= new Composite(composite, SWT.NONE);
+ Composite inner = new Composite(composite, SWT.NONE);
inner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- GridLayout layout= new GridLayout(2, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
inner.setLayout(layout);
fExclusionPatternList.doFillIntoGrid(inner, 3);
@@ -148,7 +145,7 @@ public class ExPatternDialog extends StatusDialog {
}
protected void doSelectionChanged(ListDialogField<String> field) {
- List<String> selected= field.getSelectedElements();
+ List<String> selected = field.getSelectedElements();
fExclusionPatternList.enableButton(IDX_EDIT, canEdit(selected));
}
@@ -158,21 +155,21 @@ public class ExPatternDialog extends StatusDialog {
private void editEntry() {
- List<String> selElements= fExclusionPatternList.getSelectedElements();
+ List<String> selElements = fExclusionPatternList.getSelectedElements();
if (selElements.size() != 1) {
return;
}
- List<String> existing= fExclusionPatternList.getElements();
- String entry= selElements.get(0);
- ExPatternEntryDialog dialog= new ExPatternEntryDialog(getShell(), entry, existing, fCurrProject, path);
+ List<String> existing = fExclusionPatternList.getElements();
+ String entry = selElements.get(0);
+ ExPatternEntryDialog dialog = new ExPatternEntryDialog(getShell(), entry, existing, fCurrProject, path);
if (dialog.open() == Window.OK) {
fExclusionPatternList.replaceElement(entry, dialog.getExclusionPattern());
}
}
private void addEntry() {
- List<String> existing= fExclusionPatternList.getElements();
- ExPatternEntryDialog dialog= new ExPatternEntryDialog(getShell(), null, existing, fCurrProject, path);
+ List<String> existing = fExclusionPatternList.getElements();
+ ExPatternEntryDialog dialog = new ExPatternEntryDialog(getShell(), null, existing, fCurrProject, path);
if (dialog.open() == Window.OK) {
fExclusionPatternList.addElement(dialog.getExclusionPattern());
}
@@ -185,10 +182,10 @@ public class ExPatternDialog extends StatusDialog {
}
public IPath[] getExclusionPattern() {
- IPath[] res= new IPath[fExclusionPatternList.getSize()];
- for (int i= 0; i < res.length; i++) {
- String entry= fExclusionPatternList.getElement(i);
- res[i]= new Path(entry);
+ IPath[] res = new IPath[fExclusionPatternList.getSize()];
+ for (int i = 0; i < res.length; i++) {
+ String entry = fExclusionPatternList.getElement(i);
+ res[i] = new Path(entry);
}
return res;
}
@@ -199,25 +196,25 @@ public class ExPatternDialog extends StatusDialog {
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
-// WorkbenchHelp.setHelp(newShell, ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
+ // WorkbenchHelp.setHelp(newShell, ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
}
- @Override
+ @Override
protected boolean isResizable() {
- return true;
- }
+ return true;
+ }
private void addMultipleEntries() {
- Class<?>[] acceptedClasses= new Class<?>[] { IFolder.class, IFile.class };
- ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
- ViewerFilter filter= new TypedViewerFilter(acceptedClasses);
+ Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class };
+ ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, true);
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
- ILabelProvider lp= new WorkbenchLabelProvider();
- ITreeContentProvider cp= new WorkbenchContentProvider();
+ ILabelProvider lp = new WorkbenchLabelProvider();
+ ITreeContentProvider cp = new WorkbenchContentProvider();
- IResource initialElement= null;
+ IResource initialElement = null;
- ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setTitle(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_title);
dialog.setValidator(validator);
dialog.setMessage(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_description);
@@ -227,17 +224,17 @@ public class ExPatternDialog extends StatusDialog {
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
- Object[] objects= dialog.getResult();
- int existingSegments= fCurrSourceFolder.getFullPath().segmentCount();
+ Object[] objects = dialog.getResult();
+ int existingSegments = fCurrSourceFolder.getFullPath().segmentCount();
for (Object object : objects) {
- IResource curr= (IResource) object;
- IPath path= curr.getFullPath().removeFirstSegments(existingSegments).makeRelative();
+ IResource curr = (IResource) object;
+ IPath path = curr.getFullPath().removeFirstSegments(existingSegments).makeRelative();
String res;
if (curr instanceof IContainer) {
- res= path.addTrailingSeparator().toString();
+ res = path.addTrailingSeparator().toString();
} else {
- res= path.toString();
+ res = path.toString();
}
fExclusionPatternList.addElement(res);
}
@@ -248,7 +245,7 @@ public class ExPatternDialog extends StatusDialog {
@Override
public Image getImage(Object element) {
- ImageDescriptorRegistry registry= CUIPlugin.getImageDescriptorRegistry();
+ ImageDescriptorRegistry registry = CUIPlugin.getImageDescriptorRegistry();
return registry.get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java
index 751170308b0..bc37a6b52d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java
@@ -63,7 +63,8 @@ public class ExPatternEntryDialog extends StatusDialog {
private String fExclusionPattern;
private List<String> fExistingPatterns;
- public ExPatternEntryDialog(Shell parent, String patternToEdit, List<String> existingPatterns, IProject proj, IPath path) {
+ public ExPatternEntryDialog(Shell parent, String patternToEdit, List<String> existingPatterns, IProject proj,
+ IPath path) {
super(parent);
fExistingPatterns = existingPatterns;
if (patternToEdit == null) {
@@ -199,7 +200,7 @@ public class ExPatternEntryDialog extends StatusDialog {
// ---------- util method ------------
private IPath chooseExclusionPattern() {
- Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class};
+ Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class };
ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
@@ -233,7 +234,8 @@ public class ExPatternEntryDialog extends StatusDialog {
if (dialog.open() == Window.OK) {
IResource res = (IResource) dialog.getFirstResult();
- IPath path = res.getFullPath().removeFirstSegments(fCurrSourceFolder.getFullPath().segmentCount()).makeRelative();
+ IPath path = res.getFullPath().removeFirstSegments(fCurrSourceFolder.getFullPath().segmentCount())
+ .makeRelative();
if (res instanceof IContainer) {
return path.addTrailingSeparator();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java
index 27188cbbbaf..b2e1ab8be08 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java
@@ -68,12 +68,9 @@ public class ExpDialog extends AbstractPropertyDialog {
private String[] names_l, names_t;
private java.util.List<String> existing;
- public ExpDialog(Shell parent, boolean _newAction,
- String title, String _data1, String _data2,
- ICConfigurationDescription _cfgd,
- String[] _langs, String[] _types,
- int _kind, String[] _names_l, String[] _names_t,
- java.util.List<String> _existing, boolean _isWsp) {
+ public ExpDialog(Shell parent, boolean _newAction, String title, String _data1, String _data2,
+ ICConfigurationDescription _cfgd, String[] _langs, String[] _types, int _kind, String[] _names_l,
+ String[] _names_t, java.util.List<String> _existing, boolean _isWsp) {
super(parent, title);
super.text1 = (_data1 == null) ? EMPTY_STR : _data1;
super.text2 = (_data2 == null) ? EMPTY_STR : _data2;
@@ -92,7 +89,7 @@ public class ExpDialog extends AbstractPropertyDialog {
protected Control createDialogArea(Composite c) {
GridData gd;
if (c.getLayoutData() instanceof GridData) {
- gd = (GridData)c.getLayoutData();
+ gd = (GridData) c.getLayoutData();
gd.horizontalIndent = 10;
c.setLayoutData(gd);
}
@@ -111,7 +108,8 @@ public class ExpDialog extends AbstractPropertyDialog {
@Override
public void modifyText(ModifyEvent e) {
setButtons(false);
- }});
+ }
+ });
Label l2 = new Label(c, SWT.NONE);
l2.setText(Messages.ExpDialog_7);
@@ -126,7 +124,8 @@ public class ExpDialog extends AbstractPropertyDialog {
@Override
public void modifyText(ModifyEvent e) {
setButtons(false);
- }});
+ }
+ });
if (kind != ICSettingEntry.MACRO) {
l1.setVisible(false);
@@ -135,7 +134,8 @@ public class ExpDialog extends AbstractPropertyDialog {
} else {
txt1.setText(super.text1);
txt2.setText(super.text1);
- if (!newAction) txt1.setEnabled(false); // macro name
+ if (!newAction)
+ txt1.setEnabled(false); // macro name
}
b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME);
@@ -160,7 +160,8 @@ public class ExpDialog extends AbstractPropertyDialog {
@Override
public void widgetSelected(SelectionEvent e) {
c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
- }});
+ }
+ });
c_wsp.setImage(AbstractExportTab.getWspImage(isWsp));
@@ -192,7 +193,8 @@ public class ExpDialog extends AbstractPropertyDialog {
@Override
public void widgetSelected(SelectionEvent e) {
langs.setEnabled(!c_langs.getSelection());
- }});
+ }
+ });
c_types = new Button(dest, SWT.CHECK);
c_types.setText(TO_ALL);
@@ -201,7 +203,8 @@ public class ExpDialog extends AbstractPropertyDialog {
@Override
public void widgetSelected(SelectionEvent e) {
types.setEnabled(!c_types.getSelection());
- }});
+ }
+ });
langs = new List(dest, SWT.BORDER | SWT.MULTI);
langs.setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -217,7 +220,7 @@ public class ExpDialog extends AbstractPropertyDialog {
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
message.setLayoutData(gd);
- message.setForeground(c.getDisplay().getSystemColor(SWT.COLOR_RED));
+ message.setForeground(c.getDisplay().getSystemColor(SWT.COLOR_RED));
// DUMMY PLACEHOLDER
new Label(c, 0).setLayoutData(new GridData(GridData.BEGINNING));
@@ -231,12 +234,13 @@ public class ExpDialog extends AbstractPropertyDialog {
}
private void setButtons(boolean anew) {
- if (b_ok == null) return; // while init only
+ if (b_ok == null)
+ return; // while init only
message.setText(EMPTY_STR);
String name;
boolean enabled = true;
if (kind == ICSettingEntry.MACRO)
- name = txt1.getText().trim();
+ name = txt1.getText().trim();
else
name = txt2.getText().trim();
if (name.length() == 0) {
@@ -272,10 +276,10 @@ public class ExpDialog extends AbstractPropertyDialog {
shell.dispose();
} else if (e.widget.equals(b_vars)) {
s = AbstractCPropertyTab.getVariableDialog(shell, cfgd);
- if (s != null) txt2.insert(s);
- } else if (e.widget.equals(b_work)) {
- if (kind == ICSettingEntry.INCLUDE_PATH ||
- kind == ICSettingEntry.LIBRARY_PATH)
+ if (s != null)
+ txt2.insert(s);
+ } else if (e.widget.equals(b_work)) {
+ if (kind == ICSettingEntry.INCLUDE_PATH || kind == ICSettingEntry.LIBRARY_PATH)
s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, txt2.getText());
else
s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, txt2.getText());
@@ -286,13 +290,14 @@ public class ExpDialog extends AbstractPropertyDialog {
c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
}
} else if (e.widget.equals(b_file)) {
- if (kind == ICSettingEntry.INCLUDE_PATH ||
- kind == ICSettingEntry.LIBRARY_PATH) {
+ if (kind == ICSettingEntry.INCLUDE_PATH || kind == ICSettingEntry.LIBRARY_PATH) {
s = AbstractCPropertyTab.getFileSystemDirDialog(shell, txt2.getText());
- } else if (kind==ICSettingEntry.INCLUDE_FILE) {
- s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText(), IncludeDialog.FILTER_INCLUDE_FILE);
- } else if (kind==ICSettingEntry.LIBRARY_FILE) {
- s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText(), IncludeDialog.FILTER_LIBRARY_FILE);
+ } else if (kind == ICSettingEntry.INCLUDE_FILE) {
+ s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText(),
+ IncludeDialog.FILTER_INCLUDE_FILE);
+ } else if (kind == ICSettingEntry.LIBRARY_FILE) {
+ s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText(),
+ IncludeDialog.FILTER_LIBRARY_FILE);
} else {
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText());
}
@@ -311,14 +316,16 @@ public class ExpDialog extends AbstractPropertyDialog {
} else {
lst.setEnabled(true);
check.setSelection(false);
- if (sel.length == 0) return;
+ if (sel.length == 0)
+ return;
int cnt = 0;
String[] items = lst.getItems();
int[] indices = new int[items.length];
- for (int i=0; i<indices.length; i++) indices[i] = -1;
+ for (int i = 0; i < indices.length; i++)
+ indices[i] = -1;
- for (int i=0; i<items.length; i++) {
+ for (int i = 0; i < items.length; i++) {
for (String element : sel) {
if (items[i].equals(element)) {
indices[cnt++] = i;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java
index 9d0e0d0485a..c6d673a64c5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java
@@ -34,7 +34,12 @@ public class ExpIncludeTab extends AbstractExportTab {
}
@Override
- public int getKind() { return ICSettingEntry.INCLUDE_PATH; }
+ public int getKind() {
+ return ICSettingEntry.INCLUDE_PATH;
+ }
+
@Override
- public boolean hasValues() { return false; }
+ public boolean hasValues() {
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java
index a909fd31528..3706400f574 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java
@@ -50,5 +50,3 @@ public class ExpLibraryTab extends AbstractExportTab implements IPathEntryStoreL
return false;
}
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java
index ddb985e62e9..74430f74c6e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java
@@ -34,7 +34,12 @@ public class ExpSymbolTab extends AbstractExportTab {
}
@Override
- public int getKind() { return ICSettingEntry.MACRO; }
+ public int getKind() {
+ return ICSettingEntry.MACRO;
+ }
+
@Override
- public boolean hasValues() { return true; }
+ public boolean hasValues() {
+ return true;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java
index b729f5e9a5f..bea0d2849a9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java
@@ -27,52 +27,65 @@ import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
* Property tabs associated to this page receive
* link to this interface and, so, can access
* required data, such as project, config etc.
- *
- * In addition, some methods allow to send
+ *
+ * In addition, some methods allow to send
* control messages to other pages / tabs.
- *
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPropertyProvider extends ICOptionContainer {
-
+
// new list of config descriptions for given project
ICConfigurationDescription[] getCfgsReadOnly(IProject p);
- // list of loaded config descriptions for current project
+
+ // list of loaded config descriptions for current project
ICConfigurationDescription[] getCfgsEditable();
+
// Resource description for given object in current cfg
ICResourceDescription getResDesc();
+
// Resource description for given object, in given cfg
ICResourceDescription getResDesc(ICConfigurationDescription cfgd);
- // get Affected object (project, folder, file)
+
+ // get Affected object (project, folder, file)
IAdaptable getElement();
+
// ask page to enable or disable config selection
- void enableConfigSelection (boolean enable);
-
+ void enableConfigSelection(boolean enable);
+
//
// set of methods intended to handle messages
//
// 1. send message to all tabs in all pages
void informAll(int code, Object data);
- // 2. send message to all pages.
+
+ // 2. send message to all pages.
void informPages(int code, Object data);
+
// 3. send message only to current page
void handleMessage(int code, Object data);
-
+
//
// set of methods for object kind check
//
boolean isForProject();
+
boolean isForFolder();
+
boolean isForFile();
+
boolean isForPrefs();
-
+
// Checks whether a project is new CDT model-style
boolean isCDTProject(IProject p);
+
boolean isMultiCfg();
+
// Gives access to buttons
Button getAButton();
+
Button getDButton();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider2.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider2.java
index c7a5e9e6faa..cc6f55b0460 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider2.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider2.java
@@ -13,16 +13,15 @@
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
-
/**
* Interface provides an additional method to the CDT model property page.
- *
+ *
* @see ICPropertyProvider
* @since 5.7
*/
public interface ICPropertyProvider2 extends ICPropertyProvider {
-
+
/**
* Return the selected tab, or null if the select tab isn't initialized
* @return the select tab in the page
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java
index d09fa64dd78..24b203f28e8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java
@@ -24,38 +24,38 @@ import org.eclipse.swt.widgets.Composite;
public interface ICPropertyTab {
// kinds of message to be sent (and appropriate data class)
- public static final int OK = 0; // perform OK (null)
+ public static final int OK = 0; // perform OK (null)
public static final int APPLY = 1; // apply changes (IResourceDescription)
public static final int CANCEL = 2; // cancel changes (null)
public static final int DEFAULTS = 3; // set defaults (null)
- public static final int UPDATE = 4; // re-read cfg (IConfiguration)
+ public static final int UPDATE = 4; // re-read cfg (IConfiguration)
public static final int VISIBLE = 5; // set visible (not-null means true)
- public static final int DISPOSE = 6; // dispose (null)
- public static final int SET_ICON = 7; // inform tab about its icon (Image)
-
+ public static final int DISPOSE = 6; // dispose (null)
+ public static final int SET_ICON = 7; // inform tab about its icon (Image)
+
public static final int MAXCOMMON = 100; // values below are common
- // values above are private
- // Informs other tabs about changes in managed build settings.
- // It may result in hiding/showing some tabs or changing their
- // contents. Data field is not used (null).
- public static final int MANAGEDBUILDSTATE = MAXCOMMON + 1;
+ // values above are private
+ // Informs other tabs about changes in managed build settings.
+ // It may result in hiding/showing some tabs or changing their
+ // contents. Data field is not used (null).
+ public static final int MANAGEDBUILDSTATE = MAXCOMMON + 1;
/**
* Creation of all visible elements
* @param parent - composite where widgets should be created
- * @param provider - underlying page
+ * @param provider - underlying page
*/
public void createControls(Composite parent, ICPropertyProvider provider);
-
+
/**
- * Handle events sent by another tabs or pages
+ * Handle events sent by another tabs or pages
* Most of them are processed in <link>AbstractCPropertyTab</link>
* but this functionality can be overridden partially or fully.
* @param kind - message ID (see <link>AbstractCPropertyTab</link>)
* @param data - additional info, depanding of message kind.
*/
- public void handleTabEvent (int kind, Object data);
-
+ public void handleTabEvent(int kind, Object data);
+
/**
* Returns true (by default) if page's contents is correct
* Returns false if page cannot be shown because it does
@@ -63,7 +63,7 @@ public interface ICPropertyTab {
* settings are not possible when managed build is off).
*/
public boolean canBeVisible();
-
+
//*********************************
// TODO: in next version, add :
//*********************************
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java
index f8104d3e69b..da237df8bf4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java
@@ -16,27 +16,27 @@ package org.eclipse.cdt.ui.newui;
import org.eclipse.core.resources.IProject;
/*
- * Implementors are intended to
+ * Implementors are intended to
* override "Manage Configurations" dialog
- *
+ *
* @see ConfigManager extension point.
*/
public interface IConfigManager {
/**
* Checks whether objects are applicable to the manager
- *
- * @param obs - selected projects
- * @return true if Configuration Management
+ *
+ * @param obs - selected projects
+ * @return true if Configuration Management
* is possible for these objects
*/
public boolean canManage(IProject[] obs);
-
+
/**
* Displays "Manage Configurations" dialog
- *
+ *
* @param obs - selected projects
* @param doOk - whether data saving is required
- * @return true if user pressed OK in dialog
+ * @return true if user pressed OK in dialog
*/
public boolean manage(IProject[] obs, boolean doOk);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java
index c82dbd9218c..35763726c4b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java
@@ -22,19 +22,22 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
* "New configuration" dialog instead of standard one
* and, if user pressed OK, create new configuration
* on a basis of its internal data
- *
+ *
* used by extension point:
- * "org.eclipse.cdt.ui.newCfgDialog"
+ * "org.eclipse.cdt.ui.newCfgDialog"
*/
public interface INewCfgDialog {
// Project to work with (set before open() !)
void setProject(ICProjectDescription prj);
+
// Title of dialog box (set before open() !)
void setTitle(String title);
+
// Shell to create dialog (set before open() !)
void setShell(Shell shell);
+
// Opens dialog and (after user presses OK)
- // creates new configuration.
- // Returns Windows.OK on success.
+ // creates new configuration.
+ // Returns Windows.OK on success.
int open();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java
index 411e293ba9b..6470a167b14 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java
@@ -10,7 +10,7 @@
*
* Contributors:
* IBM Corporation - Initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.ui.newui;
import org.eclipse.core.runtime.IAdaptable;
@@ -36,13 +36,13 @@ import org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsWizard
/**
* Utility class that adds buttons for "Import Settings..." and "Export Settings..."
* to the bottom of the Includes and Symbols tabs.
- *
+ *
* @since 5.2
*/
public class ImportExportWizardButtons {
-
- private ImportExportWizardButtons() {}
-
+
+ private ImportExportWizardButtons() {
+ }
public static void addWizardLaunchButtons(final Composite parent, final IAdaptable selection) {
Composite comp = new Composite(parent, SWT.NONE);
@@ -52,44 +52,45 @@ public class ImportExportWizardButtons {
GridData data = new GridData();
data.horizontalSpan = 2;
comp.setLayoutData(data);
-
+
Button importButton = new Button(comp, SWT.NONE);
- importButton.setText(Messages.IncludeTab_import);
+ importButton.setText(Messages.IncludeTab_import);
importButton.setImage(CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_IMPORT_SETTINGS));
importButton.addSelectionListener(new SelectionAdapter() {
- @Override public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
boolean finishedPressed = launchWizard(parent.getShell(), selection, false);
// There is no way to get the contents of the property page to update
// other than to close the whole dialog and then reopen it.
- if(finishedPressed)
+ if (finishedPressed)
parent.getShell().close();
}
});
-
+
Button exportButton = new Button(comp, SWT.NONE);
- exportButton.setText(Messages.IncludeTab_export);
+ exportButton.setText(Messages.IncludeTab_export);
exportButton.setImage(CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXPORT_SETTINGS));
exportButton.addSelectionListener(new SelectionAdapter() {
- @Override public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
launchWizard(parent.getShell(), selection, true);
}
});
-
+
}
-
-
+
private static boolean launchWizard(Shell shell, IAdaptable selection, boolean export) {
ProjectSettingsWizard wizard;
- if(export)
+ if (export)
wizard = new ProjectSettingsExportWizard();
else
wizard = new ProjectSettingsImportWizard();
-
+
wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(selection));
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.create();
dialog.open();
-
+
return wizard.isFinishedPressed();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java
index 6707b1c9e1d..60c7c1b85a5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java
@@ -45,8 +45,8 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
* @noextend This class is not intended to be subclassed by clients.
*/
public class IncludeDialog extends AbstractPropertyDialog {
- static final String[] FILTER_INCLUDE_FILE = new String[] {"*.h;*.hpp", "*"}; //$NON-NLS-1$ //$NON-NLS-2$
- static final String[] FILTER_LIBRARY_FILE = new String[] {"*.a;*.so;*.dll;*.lib", "*"}; //$NON-NLS-1$ //$NON-NLS-2$
+ static final String[] FILTER_INCLUDE_FILE = new String[] { "*.h;*.hpp", "*" }; //$NON-NLS-1$ //$NON-NLS-2$
+ static final String[] FILTER_LIBRARY_FILE = new String[] { "*.a;*.so;*.dll;*.lib", "*" }; //$NON-NLS-1$ //$NON-NLS-2$
public String sdata;
private Button b_add2confs;
private Button b_add2langs;
@@ -63,9 +63,9 @@ public class IncludeDialog extends AbstractPropertyDialog {
private int kind = 0;
static final int NEW_FILE = 0;
- static final int NEW_DIR = 1;
+ static final int NEW_DIR = 1;
static final int OLD_FILE = 2;
- static final int OLD_DIR = 3;
+ static final int OLD_DIR = 3;
static final int DIR_MASK = 1;
static final int OLD_MASK = 2;
@@ -73,8 +73,8 @@ public class IncludeDialog extends AbstractPropertyDialog {
/**
* @since 5.3
*/
- public IncludeDialog(Shell parent, int mode, String title, String data,
- ICConfigurationDescription cfgd, int flags, int kind) {
+ public IncludeDialog(Shell parent, int mode, String title, String data, ICConfigurationDescription cfgd, int flags,
+ int kind) {
super(parent, title);
this.mode = mode;
@@ -84,8 +84,8 @@ public class IncludeDialog extends AbstractPropertyDialog {
this.kind = kind;
}
- public IncludeDialog(Shell parent, int mode, String title, String data,
- ICConfigurationDescription cfgd, int flags) {
+ public IncludeDialog(Shell parent, int mode, String title, String data, ICConfigurationDescription cfgd,
+ int flags) {
this(parent, mode, title, data, cfgd, flags, 0);
}
@@ -109,15 +109,18 @@ public class IncludeDialog extends AbstractPropertyDialog {
gd.horizontalSpan = 2;
gd.widthHint = 300;
text.setLayoutData(gd);
- if ((mode & OLD_MASK) == OLD_MASK) { text.setText(sdata); }
+ if ((mode & OLD_MASK) == OLD_MASK) {
+ text.setText(sdata);
+ }
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
setButtons();
- }});
+ }
+ });
-// Checkboxes
- Composite c1 = new Composite (c, SWT.NONE);
+ // Checkboxes
+ Composite c1 = new Composite(c, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = SWT.TOP;
c1.setLayoutData(gd);
@@ -126,8 +129,7 @@ public class IncludeDialog extends AbstractPropertyDialog {
b_add2confs = new Button(c1, SWT.CHECK);
b_add2confs.setText(Messages.IncludeDialog_2);
gd = new GridData(GridData.FILL_HORIZONTAL);
- if (((mode & OLD_MASK) == OLD_MASK) ||
- (cfgd instanceof ICMultiConfigDescription)) {
+ if (((mode & OLD_MASK) == OLD_MASK) || (cfgd instanceof ICMultiConfigDescription)) {
gd.heightHint = 1;
b_add2confs.setVisible(false);
}
@@ -151,11 +153,12 @@ public class IncludeDialog extends AbstractPropertyDialog {
@Override
public void widgetSelected(SelectionEvent e) {
c_wsp.setImage(getWspImage(c_wsp.getSelection()));
- }});
+ }
+ });
c_wsp.setImage(getWspImage(isWsp));
-// Buttons
- Composite c2 = new Composite (c, SWT.NONE);
+ // Buttons
+ Composite c2 = new Composite(c, SWT.NONE);
gd = new GridData(GridData.END);
c2.setLayoutData(gd);
c2.setLayout(new GridLayout(2, true));
@@ -179,7 +182,7 @@ public class IncludeDialog extends AbstractPropertyDialog {
int x = b_ko.getBounds().width * 3 + 10;
int y = c.getBounds().width - 10;
if (x > y) {
- ((GridData)(text.getLayoutData())).widthHint = x;
+ ((GridData) (text.getLayoutData())).widthHint = x;
c.pack();
}
@@ -204,7 +207,7 @@ public class IncludeDialog extends AbstractPropertyDialog {
} else if (e.widget.equals(b_ko)) {
shell.dispose();
} else if (e.widget.equals(b_work)) {
- if ((mode & DIR_MASK)== DIR_MASK)
+ if ((mode & DIR_MASK) == DIR_MASK)
s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, text.getText());
else
s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, text.getText());
@@ -215,12 +218,12 @@ public class IncludeDialog extends AbstractPropertyDialog {
c_wsp.setImage(getWspImage(c_wsp.getSelection()));
}
} else if (e.widget.equals(b_file)) {
- if ((mode & DIR_MASK)== DIR_MASK) {
+ if ((mode & DIR_MASK) == DIR_MASK) {
s = AbstractCPropertyTab.getFileSystemDirDialog(shell, text.getText());
} else {
- if (kind==ICSettingEntry.INCLUDE_FILE)
+ if (kind == ICSettingEntry.INCLUDE_FILE)
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText(), FILTER_INCLUDE_FILE);
- else if (kind==ICSettingEntry.LIBRARY_FILE)
+ else if (kind == ICSettingEntry.LIBRARY_FILE)
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText(), FILTER_LIBRARY_FILE);
else
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText());
@@ -232,7 +235,8 @@ public class IncludeDialog extends AbstractPropertyDialog {
}
} else if (e.widget.equals(b_vars)) {
s = AbstractCPropertyTab.getVariableDialog(shell, cfgd);
- if (s != null) text.insert(s);
+ if (s != null)
+ text.insert(s);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java
index 39e699c7708..074ba88f213 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java
@@ -56,14 +56,8 @@ public class IncludeFileTab extends AbstractLangsListTab {
@Override
public ICLanguageSettingEntry doAdd() {
- IncludeDialog dlg = new IncludeDialog(
- usercomp.getShell(),
- IncludeDialog.NEW_FILE,
- Messages.IncludeFileTab_1,
- EMPTY_STR,
- getResDesc().getConfiguration(),
- 0,
- ICSettingEntry.INCLUDE_FILE);
+ IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.NEW_FILE, Messages.IncludeFileTab_1,
+ EMPTY_STR, getResDesc().getConfiguration(), 0, ICSettingEntry.INCLUDE_FILE);
if (dlg.open() && dlg.text1.trim().length() > 0) {
toAllCfgs = dlg.check1;
toAllLang = dlg.check3;
@@ -78,13 +72,8 @@ public class IncludeFileTab extends AbstractLangsListTab {
@Override
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
- IncludeDialog dlg = new IncludeDialog(
- usercomp.getShell(),
- IncludeDialog.OLD_FILE,
- Messages.IncludeFileTab_2,
- ent.getValue(),
- getResDesc().getConfiguration(),
- ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
+ IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.OLD_FILE, Messages.IncludeFileTab_2,
+ ent.getValue(), getResDesc().getConfiguration(), ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
ICSettingEntry.INCLUDE_FILE);
if (dlg.open()) {
int flags = 0;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java
index b2661dceb9e..f825befec5a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java
@@ -31,29 +31,25 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
*/
public class IncludeTab extends AbstractLangsListTab {
- @Override
-public void additionalTableSet() {
- columnToFit = new TableColumn(table, SWT.NONE);
- columnToFit.setText(Messages.IncludeTab_0);
- columnToFit.setToolTipText(Messages.IncludeTab_0);
- showBIButton.setSelection(true);
- table.getAccessible().addAccessibleListener(
- new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result = Messages.IncludeTab_0;
- }
- }
- );
- }
+ @Override
+ public void additionalTableSet() {
+ columnToFit = new TableColumn(table, SWT.NONE);
+ columnToFit.setText(Messages.IncludeTab_0);
+ columnToFit.setToolTipText(Messages.IncludeTab_0);
+ showBIButton.setSelection(true);
+ table.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ e.result = Messages.IncludeTab_0;
+ }
+ });
+ }
@Override
public ICLanguageSettingEntry doAdd() {
- IncludeDialog dlg = new IncludeDialog(
- usercomp.getShell(), IncludeDialog.NEW_DIR,
- Messages.IncludeTab_1,
+ IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.NEW_DIR, Messages.IncludeTab_1,
EMPTY_STR, getResDesc().getConfiguration(), 0);
- if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ if (dlg.open() && dlg.text1.trim().length() > 0) {
toAllCfgs = dlg.check1;
toAllLang = dlg.check3;
int flags = 0;
@@ -67,22 +63,22 @@ public void additionalTableSet() {
@Override
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
- IncludeDialog dlg = new IncludeDialog(
- usercomp.getShell(), IncludeDialog.OLD_DIR,
- Messages.IncludeTab_2,
+ IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.OLD_DIR, Messages.IncludeTab_2,
ent.getValue(), getResDesc().getConfiguration(),
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
if (dlg.open()) {
int flags = 0;
- if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ if (dlg.check2)
+ flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return CDataUtil.createCIncludePathEntry(dlg.text1, flags);
}
return null;
}
@Override
- public int getKind() { return ICSettingEntry.INCLUDE_PATH; }
-
+ public int getKind() {
+ return ICSettingEntry.INCLUDE_PATH;
+ }
@Override
public void createControls(final Composite parent) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java
index 8efcefe844a..d14f7f1e7df 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java
@@ -51,15 +51,14 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt
@Override
public ICLanguageSettingEntry doAdd() {
- IncludeDialog dlg = new IncludeDialog(
- usercomp.getShell(), IncludeDialog.NEW_DIR,
- Messages.LibraryPathTab_1,
+ IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.NEW_DIR, Messages.LibraryPathTab_1,
EMPTY_STR, getResDesc().getConfiguration(), 0);
- if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ if (dlg.open() && dlg.text1.trim().length() > 0) {
toAllCfgs = dlg.check1;
toAllLang = dlg.check3;
int flags = 0;
- if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ if (dlg.check2)
+ flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return CDataUtil.createCLibraryPathEntry(dlg.text1, flags);
}
return null;
@@ -67,14 +66,13 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt
@Override
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
- IncludeDialog dlg = new IncludeDialog(
- usercomp.getShell(), IncludeDialog.OLD_DIR,
- Messages.LibraryPathTab_2,
+ IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.OLD_DIR, Messages.LibraryPathTab_2,
ent.getValue(), getResDesc().getConfiguration(),
(ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
- if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ if (dlg.open() && dlg.text1.trim().length() > 0) {
int flags = 0;
- if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ if (dlg.check2)
+ flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return CDataUtil.createCLibraryPathEntry(dlg.text1, flags);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java
index 2073058fea6..7d8257e7418 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java
@@ -39,7 +39,7 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
@Override
public void createControls(Composite parent) {
super.createControls(parent);
- sashForm.setWeights(PRIVATE_SASH_WEIGHTS);
+ sashForm.setWeights(PRIVATE_SASH_WEIGHTS);
langTree.setVisible(false);
}
@@ -50,18 +50,14 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
@Override
public ICLanguageSettingEntry doAdd() {
- IncludeDialog dlg = new IncludeDialog(
- usercomp.getShell(), IncludeDialog.NEW_FILE,
- Messages.LibraryTab_1,
- EMPTY_STR,
- getResDesc().getConfiguration(),
- 0,
- ICSettingEntry.LIBRARY_FILE);
- if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.NEW_FILE, Messages.LibraryTab_1,
+ EMPTY_STR, getResDesc().getConfiguration(), 0, ICSettingEntry.LIBRARY_FILE);
+ if (dlg.open() && dlg.text1.trim().length() > 0) {
toAllCfgs = dlg.check1;
toAllLang = dlg.check3;
int flags = 0;
- if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ if (dlg.check2)
+ flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return CDataUtil.createCLibraryFileEntry(dlg.text1, flags);
}
return null;
@@ -69,16 +65,13 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL
@Override
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
- IncludeDialog dlg = new IncludeDialog(
- usercomp.getShell(), IncludeDialog.OLD_FILE,
- Messages.LibraryTab_2,
- ent.getValue(),
- getResDesc().getConfiguration(),
- ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
+ IncludeDialog dlg = new IncludeDialog(usercomp.getShell(), IncludeDialog.OLD_FILE, Messages.LibraryTab_2,
+ ent.getValue(), getResDesc().getConfiguration(), ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
ICSettingEntry.LIBRARY_FILE);
- if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ if (dlg.open() && dlg.text1.trim().length() > 0) {
int flags = 0;
- if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ if (dlg.check2)
+ flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
return CDataUtil.createCLibraryFileEntry(dlg.text1, flags);
}
return null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java
index e725c3687e5..4806554d78d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java
@@ -60,7 +60,7 @@ public class ManageConfigDialog extends Dialog {
private String title;
private String mbs_id;
protected Table table;
-
+
protected Button actBtn;
protected Button newBtn;
protected Button renBtn;
@@ -79,9 +79,10 @@ public class ManageConfigDialog extends Dialog {
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
- if (title != null) shell.setText(title);
+ if (title != null)
+ shell.setText(title);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@@ -91,7 +92,7 @@ public class ManageConfigDialog extends Dialog {
composite.setFont(parent.getFont());
composite.setLayout(new GridLayout(4, true));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
// Create the current config table
table = new Table(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.FILL_BOTH);
@@ -99,36 +100,39 @@ public class ManageConfigDialog extends Dialog {
table.setLayoutData(gd);
table.setHeaderVisible(true);
table.setLinesVisible(true);
-
+
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateButtons();
- }});
-
+ }
+ });
+
TableColumn col = new TableColumn(table, SWT.NONE);
- col.setText(Messages.ManageConfigDialog_1);
+ col.setText(Messages.ManageConfigDialog_1);
col.setWidth(100);
col = new TableColumn(table, SWT.NONE);
- col.setText(Messages.ManageConfigDialog_2);
+ col.setText(Messages.ManageConfigDialog_2);
col.setWidth(120);
col = new TableColumn(table, SWT.NONE);
- col.setText(Messages.ManageConfigDialog_3);
+ col.setText(Messages.ManageConfigDialog_3);
col.setWidth(80);
actBtn = new Button(composite, SWT.PUSH);
- actBtn.setText(Messages.ManageConfigDialog_4);
+ actBtn.setText(Messages.ManageConfigDialog_4);
actBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
actBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] tis = table.getSelection();
- if (tis == null || tis.length != 1) return;
- ICConfigurationDescription cfgd = (ICConfigurationDescription)tis[0].getData();
-// cfgd.setActive();
+ if (tis == null || tis.length != 1)
+ return;
+ ICConfigurationDescription cfgd = (ICConfigurationDescription) tis[0].getData();
+ // cfgd.setActive();
des.setActiveConfiguration(cfgd);
updateData();
- }} );
+ }
+ });
newBtn = new Button(composite, SWT.PUSH);
newBtn.setText(Messages.BuildPropertyCommon_label_new);
@@ -137,7 +141,8 @@ public class ManageConfigDialog extends Dialog {
@Override
public void widgetSelected(SelectionEvent e) {
handleNewPressed();
- }} );
+ }
+ });
delBtn = new Button(composite, SWT.PUSH);
delBtn.setText(Messages.BuildPropertyCommon_label_remove);
@@ -146,7 +151,8 @@ public class ManageConfigDialog extends Dialog {
@Override
public void widgetSelected(SelectionEvent e) {
handleRemovePressed();
- }} );
+ }
+ });
renBtn = new Button(composite, SWT.PUSH);
renBtn.setText(Messages.ManageConfig_label_rename);
@@ -155,14 +161,16 @@ public class ManageConfigDialog extends Dialog {
@Override
public void widgetSelected(SelectionEvent e) {
handleRenamePressed();
- }} );
+ }
+ });
des = CDTPropertyManager.getProjectDescription(composite, prj);
-// comp = composite;
-
+ // comp = composite;
+
updateData();
- return composite;
+ return composite;
}
+
/*
* Event handler for the add button
*/
@@ -172,25 +180,27 @@ public class ManageConfigDialog extends Dialog {
dialog = new NewConfigurationDialog(getShell());
dialog.setTitle(Messages.ManageConfig_label_new_config_dialog);
}
- dialog.setProject(des);
- if (dialog.open() == OK) updateData();
+ dialog.setProject(des);
+ if (dialog.open() == OK)
+ updateData();
}
-
+
/**
* Tries to load MBS-specific creation dialog a
- * @return false if there's no such feature
+ * @return false if there's no such feature
*/
protected INewCfgDialog handleSpecificMBS(String id) {
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
- .getExtensionPoint(EXTENSION_POINT_ID);
- if (extensionPoint == null) return null;
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint == null)
+ return null;
IExtension[] extensions = extensionPoint.getExtensions();
- if (extensions == null) return null;
- for (int i = 0; i < extensions.length; ++i) {
+ if (extensions == null)
+ return null;
+ for (int i = 0; i < extensions.length; ++i) {
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
for (int k = 0; k < elements.length; k++) {
if (elements[k].getName().equals(ELEMENT_NAME)) {
- if (! id.equals(elements[k].getAttribute(ID_NAME)))
+ if (!id.equals(elements[k].getAttribute(ID_NAME)))
continue;
INewCfgDialog dialog = null;
try {
@@ -200,14 +210,14 @@ public class ManageConfigDialog extends Dialog {
return dialog;
} catch (CoreException e) {
System.out.println("Cannot create dialog: " + e.getLocalizedMessage()); //$NON-NLS-1$
- return null;
+ return null;
}
- }
+ }
}
}
return null;
}
-
+
/*
* (non-javadoc) Event handler for the rename button
*/
@@ -215,8 +225,7 @@ public class ManageConfigDialog extends Dialog {
int sel = table.getSelectionIndex();
if (sel != -1) {
ICConfigurationDescription cfgd = (ICConfigurationDescription) table.getItem(sel).getData();
- RenameConfigurationDialog dialog = new RenameConfigurationDialog(
- getShell(), cfgd, des.getConfigurations(),
+ RenameConfigurationDialog dialog = new RenameConfigurationDialog(getShell(), cfgd, des.getConfigurations(),
Messages.ManageConfig_label_rename_config_dialog);
if (dialog.open() == OK) {
cfgd.setName(dialog.getNewName());
@@ -231,24 +240,25 @@ public class ManageConfigDialog extends Dialog {
*/
protected void handleRemovePressed() {
TableItem[] tis = table.getSelection();
- if (tis == null || tis.length < 1) return;
+ if (tis == null || tis.length < 1)
+ return;
String[] names = new String[tis.length];
- for (int i=0; i<tis.length; i++)
+ for (int i = 0; i < tis.length; i++)
names[i] = tis[i].getText(0);
// Get the confirmation from user before deleting the configuration
Shell shell = CUIPlugin.getActiveWorkbenchShell();
- boolean shouldDelete = MessageDialog.openQuestion(shell,
- Messages.ManageConfig_deletedialog_title,
- NLS.bind(Messages.ManageConfig_deletedialog_message, names));
+ boolean shouldDelete = MessageDialog.openQuestion(shell, Messages.ManageConfig_deletedialog_title,
+ NLS.bind(Messages.ManageConfig_deletedialog_message, names));
if (shouldDelete) {
boolean wasActive = false;
- for (int j=0; j<tis.length; j++) {
- ICConfigurationDescription cfgd = (ICConfigurationDescription)tis[j].getData();
- if (cfgd.isActive()) wasActive = true;
+ for (int j = 0; j < tis.length; j++) {
+ ICConfigurationDescription cfgd = (ICConfigurationDescription) tis[j].getData();
+ if (cfgd.isActive())
+ wasActive = true;
des.removeConfiguration(cfgd);
-
+
}
- ICConfigurationDescription[] cfgds = des.getConfigurations();
+ ICConfigurationDescription[] cfgds = des.getConfigurations();
if (wasActive && cfgds.length > 0) {
cfgds[0].setActive();
des.setActiveConfiguration(cfgds[0]);
@@ -262,7 +272,7 @@ public class ManageConfigDialog extends Dialog {
delBtn.setEnabled(sel > 0 & sel < table.getItemCount());
renBtn.setEnabled(sel == 1);
if (sel == 1) {
- ICConfigurationDescription c = (ICConfigurationDescription)table.getSelection()[0].getData();
+ ICConfigurationDescription c = (ICConfigurationDescription) table.getSelection()[0].getData();
actBtn.setEnabled(c != null && !c.isActive());
} else
actBtn.setEnabled(false);
@@ -276,7 +286,7 @@ public class ManageConfigDialog extends Dialog {
ICConfigurationDescription[] cfgds = des.getConfigurations();
mbs_id = cfgds[0].getBuildSystemId();
Arrays.sort(cfgds, CDTListComparator.getInstance());
- for (int i=0; i<cfgds.length; i++ ) {
+ for (int i = 0; i < cfgds.length; i++) {
TableItem t = new TableItem(table, 0);
t.setText(0, cfgds[i].getName());
String description = cfgds[i].getDescription();
@@ -284,7 +294,7 @@ public class ManageConfigDialog extends Dialog {
description = ""; //$NON-NLS-1$
}
t.setText(1, description);
- t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$
+ t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$
t.setData(cfgds[i]);
}
if (table.getItemCount() > 0) {
@@ -293,8 +303,8 @@ public class ManageConfigDialog extends Dialog {
table.setFocus();
updateButtons();
}
-
- ICProjectDescription getProjectDescription(){
+
+ ICProjectDescription getProjectDescription() {
return des;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java
index f698d10976e..7ce021b8c3e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java
@@ -60,17 +60,18 @@ public class ManageConfigRunner implements IConfigManager {
return false;
ManageConfigDialog d = new ManageConfigDialog(Display.getDefault().getActiveShell(),
- obs[0].getName()+ ": " + MANAGE_TITLE, obs[0]); //$NON-NLS-1$
+ obs[0].getName() + ": " + MANAGE_TITLE, obs[0]); //$NON-NLS-1$
boolean result = false;
if (d.open() == Window.OK) {
if (doOk) {
des = d.getProjectDescription();
prj = obs[0];
- if(des != null)
+ if (des != null)
try {
PlatformUI.getWorkbench().getProgressService().run(false, false, getRunnable());
- } catch (InvocationTargetException e) {}
- catch (InterruptedException e) {}
+ } catch (InvocationTargetException e) {
+ } catch (InterruptedException e) {
+ }
}
AbstractPage.updateViews(obs[0]);
result = true;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java
index 7e34bff9ee4..5cdfb803f82 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java
@@ -34,7 +34,7 @@ import org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy;
/**
* This class provides static methods to work with multiple
* implementors of "ConfigManager" extension point.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
@@ -47,7 +47,7 @@ public class ManageConfigSelector {
/**
* Searches for IConfigManager which
* can process given projects.
- *
+ *
* @param obs - list of projects to handle
* @return first matching ConfigManager
*/
@@ -55,27 +55,27 @@ public class ManageConfigSelector {
readMgrs();
if (mgrs == null)
return null;
- for (int i=0; i<mgrs.length; i++) {
+ for (int i = 0; i < mgrs.length; i++) {
if (mgrs[i].canManage(obs))
return mgrs[i];
}
return null;
}
-
+
/**
* Searches for IConfigManager which
* can process given objects.
- *
+ *
* @param obs - "raw" array of objects
* @return first matching ConfigManager
*/
public static IConfigManager getManagerFor(Object[] obs) {
return getManager(getProjects(obs));
- }
-
+ }
+
/**
* Filters "raw" objects array
- *
+ *
* @param obs - objects to filter
* @return array with only new-style projects included
*/
@@ -84,28 +84,27 @@ public class ManageConfigSelector {
if (obs != null) {
for (Object ob : obs) {
IProject prj = null;
- // Extract project from selection
+ // Extract project from selection
if (ob instanceof ICElement) { // for C/C++ view
- prj = ((ICElement)ob).getCProject().getProject();
+ prj = ((ICElement) ob).getCProject().getProject();
} else if (ob instanceof IResource) { // for other views
- prj = ((IResource)ob).getProject();
- /* get project from Include folder elements */
+ prj = ((IResource) ob).getProject();
+ /* get project from Include folder elements */
} else if (ob instanceof IncludeRefContainer) {
- ICProject fCProject = ((IncludeRefContainer)ob).getCProject();
+ ICProject fCProject = ((IncludeRefContainer) ob).getCProject();
if (fCProject != null)
prj = fCProject.getProject();
} else if (ob instanceof IncludeReferenceProxy) {
- IncludeRefContainer irc = ((IncludeReferenceProxy)ob).getIncludeRefContainer();
+ IncludeRefContainer irc = ((IncludeReferenceProxy) ob).getIncludeRefContainer();
if (irc != null) {
ICProject fCProject = irc.getCProject();
if (fCProject != null)
prj = fCProject.getProject();
}
- }
+ }
- if (prj == null || lst.contains(prj) ||
- !CoreModel.getDefault().isNewStyleProject(prj))
- continue;
+ if (prj == null || lst.contains(prj) || !CoreModel.getDefault().isNewStyleProject(prj))
+ continue;
lst.add(prj);
}
}
@@ -117,15 +116,15 @@ public class ManageConfigSelector {
return;
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
- if (extensionPoint == null)
+ if (extensionPoint == null)
return;
IExtension[] extensions = extensionPoint.getExtensions();
- if (extensions == null)
+ if (extensions == null)
return;
ArrayList<IConfigManager> list = new ArrayList<IConfigManager>();
- for (int i = 0; i < extensions.length; ++i) {
+ for (int i = 0; i < extensions.length; ++i) {
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
for (int k = 0; k < elements.length; k++) {
if (elements[k].getName().equals(ELEMENT_NAME)) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java
index d80f8e27518..a4f3d6a01cf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java
@@ -30,7 +30,8 @@ import org.eclipse.cdt.internal.core.envvar.ContributedEnvironment;
* @noextend This class is not intended to be subclassed by clients.
*/
public class MultiCfgContributedEnvironment implements IContributedEnvironment {
- private static final IContributedEnvironment ice = CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment();
+ private static final IContributedEnvironment ice = CCorePlugin.getDefault().getBuildEnvironmentManager()
+ .getContributedEnvironment();
private boolean isMulti = false;
private ICConfigurationDescription[] mono = new ICConfigurationDescription[1];
private static final EnvCmp comparator = new EnvCmp();
@@ -41,17 +42,16 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
public int compare(Object a0, Object a1) {
if (a0 == null || a1 == null)
return 0;
- if (a0 instanceof IEnvironmentVariable &&
- a1 instanceof IEnvironmentVariable) {
- IEnvironmentVariable x0 = (IEnvironmentVariable)a0;
- IEnvironmentVariable x1 = (IEnvironmentVariable)a1;
+ if (a0 instanceof IEnvironmentVariable && a1 instanceof IEnvironmentVariable) {
+ IEnvironmentVariable x0 = (IEnvironmentVariable) a0;
+ IEnvironmentVariable x1 = (IEnvironmentVariable) a1;
String s0 = x0.getName();
if (s0 == null)
s0 = AbstractPage.EMPTY_STR;
String s1 = x1.getName();
if (s1 == null)
s1 = AbstractPage.EMPTY_STR;
- return(s0.compareTo(s1));
+ return (s0.compareTo(s1));
}
return 0;
}
@@ -62,8 +62,8 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
}
@Override
- public IEnvironmentVariable addVariable(String name, String value,
- int op, String delimiter, ICConfigurationDescription des) {
+ public IEnvironmentVariable addVariable(String name, String value, int op, String delimiter,
+ ICConfigurationDescription des) {
IEnvironmentVariable v = null;
for (ICConfigurationDescription c : getCfs(des))
v = ice.addVariable(name, value, op, delimiter, c);
@@ -72,10 +72,10 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
}
private void doReplace(ICConfigurationDescription des) {
- if (isMulti && ! isModifyMode()) {
+ if (isMulti && !isModifyMode()) {
IEnvironmentVariable[] vars = getVariables(des);
- for (int i=0; i<vars.length; i++)
- if (! ice.isUserVariable(des, vars[i]))
+ for (int i = 0; i < vars.length; i++)
+ if (!ice.isUserVariable(des, vars[i]))
vars[i] = null;
for (ICConfigurationDescription c : getCfs(des)) {
ice.restoreDefaults(c);
@@ -89,14 +89,13 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
@Override
public boolean appendEnvironment(ICConfigurationDescription des) {
for (ICConfigurationDescription c : getCfs(des))
- if (! ice.appendEnvironment(c))
+ if (!ice.appendEnvironment(c))
return false;
return true;
}
@Override
- public IEnvironmentVariable getVariable(String name,
- ICConfigurationDescription des) {
+ public IEnvironmentVariable getVariable(String name, ICConfigurationDescription des) {
if (!isMulti)
return ice.getVariable(name, des);
// should we show ANY vars, even if they exist not in all cfgs ?
@@ -106,27 +105,26 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
// if ((any && v != null) || (! any && v == null))
if (any ^ (v == null))
return v;
- for (int i=1; i<cfs.length; i++) {
+ for (int i = 1; i < cfs.length; i++) {
IEnvironmentVariable w = ice.getVariable(name, cfs[i]);
if (any && (w != null))
return w;
// if (! any && ! v==w)
- if (! (any || (v==null && w==null) || (v != null && v.equals(w))))
+ if (!(any || (v == null && w == null) || (v != null && v.equals(w))))
return null;
}
return v;
}
@Override
- public IEnvironmentVariable[] getVariables(
- ICConfigurationDescription des) {
+ public IEnvironmentVariable[] getVariables(ICConfigurationDescription des) {
if (!isMulti)
return ice.getVariables(des);
ICConfigurationDescription[] cfs = getCfs(des);
IEnvironmentVariable[][] evs = new IEnvironmentVariable[cfs.length][];
int i = 0;
for (ICConfigurationDescription c : cfs)
- evs[i++] = ice.getVariables(c);
+ evs[i++] = ice.getVariables(c);
Object[] obs = CDTPrefUtil.getListForDisplay(evs, comparator);
IEnvironmentVariable[] ev = new IEnvironmentVariable[obs.length];
@@ -136,17 +134,15 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
}
@Override
- public boolean isUserVariable(ICConfigurationDescription des,
- IEnvironmentVariable var) {
+ public boolean isUserVariable(ICConfigurationDescription des, IEnvironmentVariable var) {
for (ICConfigurationDescription c : getCfs(des))
- if (! ice.isUserVariable(c, var))
+ if (!ice.isUserVariable(c, var))
return false;
return true; // only if for each cfg
}
@Override
- public IEnvironmentVariable removeVariable(String name,
- ICConfigurationDescription des) {
+ public IEnvironmentVariable removeVariable(String name, ICConfigurationDescription des) {
IEnvironmentVariable res = null;
for (ICConfigurationDescription c : getCfs(des))
res = ice.removeVariable(name, c);
@@ -161,14 +157,14 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
}
@Override
- public void setAppendEnvironment(boolean append,ICConfigurationDescription des) {
+ public void setAppendEnvironment(boolean append, ICConfigurationDescription des) {
for (ICConfigurationDescription c : getCfs(des))
ice.setAppendEnvironment(append, c);
}
private ICConfigurationDescription[] getCfs(ICConfigurationDescription des) {
if (isMulti && des instanceof ICMultiConfigDescription) {
- return (ICConfigurationDescription[])((ICMultiConfigDescription)des).getItems();
+ return (ICConfigurationDescription[]) ((ICMultiConfigDescription) des).getItems();
}
mono[0] = des;
return mono;
@@ -186,8 +182,7 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
}
@Override
- public IEnvironmentVariable addVariable(IEnvironmentVariable var,
- ICConfigurationDescription des) {
+ public IEnvironmentVariable addVariable(IEnvironmentVariable var, ICConfigurationDescription des) {
IEnvironmentVariable v = null;
for (ICConfigurationDescription c : getCfs(des))
v = ice.addVariable(var, c);
@@ -196,8 +191,7 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
}
@Override
- public void addVariables(IEnvironmentVariable[] vars,
- ICConfigurationDescription des) {
+ public void addVariables(IEnvironmentVariable[] vars, ICConfigurationDescription des) {
for (ICConfigurationDescription c : getCfs(des))
ice.addVariables(vars, c);
doReplace(des);
@@ -205,7 +199,7 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
public String getOrigin(IEnvironmentVariable var) {
if (ice instanceof ContributedEnvironment)
- return ((ContributedEnvironment)ice).getOrigin(var);
+ return ((ContributedEnvironment) ice).getOrigin(var);
return AbstractPage.EMPTY_STR;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java
index ea36aa04e12..f42311f7a7d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.swt.SWT;
@@ -100,11 +99,13 @@ public class MultiLineTextFieldEditor extends FieldEditor {
* <code>VALIDATE_ON_KEY_STROKE</code> by default.
*/
private int validateStrategy = VALIDATE_ON_KEY_STROKE;
+
/**
* Creates a new string field editor
*/
protected MultiLineTextFieldEditor() {
}
+
/**
* Creates a string field editor.
* Use the method <code>setTextLimit</code> to limit the text.
@@ -119,12 +120,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
* @param parent the parent of the field editor's control
* @since 2.0
*/
- public MultiLineTextFieldEditor(
- String name,
- String labelText,
- int width,
- int strategy,
- Composite parent) {
+ public MultiLineTextFieldEditor(String name, String labelText, int width, int strategy, Composite parent) {
init(name, labelText);
setValidateStrategy(strategy);
isValid = false;
@@ -146,6 +142,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
this(name, labelText, width, VALIDATE_ON_KEY_STROKE, parent);
this.compTitle = labelText;
}
+
/**
* Creates a string field editor of unlimited width.
* Use the method <code>setTextLimit</code> to limit the text.
@@ -179,6 +176,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
// we assume it is setting the width.
gd.grabExcessHorizontalSpace = gd.horizontalSpan == 1;
}
+
/**
* Checks whether the text input field contains a valid value or not.
*
@@ -197,8 +195,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
if (txt == null) {
result = false;
- }
- else {
+ } else {
result = (txt.trim().length() > 0) || emptyStringAllowed;
}
@@ -212,6 +209,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
return result;
}
+
/**
* Hook for subclasses to do specific state checks.
* <p>
@@ -226,6 +224,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
protected boolean doCheckState() {
return true;
}
+
/**
* Fills this field editor's basic controls into the given parent.
* <p>
@@ -279,8 +278,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
@Override
protected void doLoadDefault() {
if (textField != null) {
- String value =
- getPreferenceStore().getDefaultString(getPreferenceName());
+ String value = getPreferenceStore().getDefaultString(getPreferenceName());
textField.setText(value);
}
valueChanged();
@@ -303,6 +301,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
public String getErrorMessage() {
return errorMessage;
}
+
/**
* Returns the number of basic controls this field editor consists of.
*
@@ -312,6 +311,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
public int getNumberOfControls() {
return 2;
}
+
/**
* Returns the field editor's value.
*
@@ -343,51 +343,50 @@ public class MultiLineTextFieldEditor extends FieldEditor {
*/
public Text getTextControl(Composite parent) {
if (textField == null) {
- textField =
- new Text(
- parent,
- SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
+ textField = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
textField.setFont(parent.getFont());
switch (validateStrategy) {
- case VALIDATE_ON_KEY_STROKE :
- textField.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- valueChanged();
- }
- });
-
- textField.addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- refreshValidState();
- }
- @Override
- public void focusLost(FocusEvent e) {
- clearErrorMessage();
- }
- });
- break;
- case VALIDATE_ON_FOCUS_LOST :
- textField.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- clearErrorMessage();
- }
- });
- textField.addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- refreshValidState();
- }
- @Override
- public void focusLost(FocusEvent e) {
- valueChanged();
- clearErrorMessage();
- }
- });
- break;
- default :
+ case VALIDATE_ON_KEY_STROKE:
+ textField.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ valueChanged();
+ }
+ });
+
+ textField.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ refreshValidState();
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ clearErrorMessage();
+ }
+ });
+ break;
+ case VALIDATE_ON_FOCUS_LOST:
+ textField.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ clearErrorMessage();
+ }
+ });
+ textField.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ refreshValidState();
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ valueChanged();
+ clearErrorMessage();
+ }
+ });
+ break;
+ default:
}
textField.addDisposeListener(new DisposeListener() {
@Override
@@ -525,8 +524,7 @@ public class MultiLineTextFieldEditor extends FieldEditor {
* perform validation only after the text has been typed in
*/
public void setValidateStrategy(int value) {
- Assert.isTrue(
- value == VALIDATE_ON_FOCUS_LOST || value == VALIDATE_ON_KEY_STROKE);
+ Assert.isTrue(value == VALIDATE_ON_FOCUS_LOST || value == VALIDATE_ON_KEY_STROKE);
validateStrategy = value;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java
index 27bd08f91e2..d361b50d4ff 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java
@@ -59,12 +59,11 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
private String newDescription;
private String title;
-
/**
*/
protected NewConfigurationDialog(Shell parentShell) {
super(parentShell);
- setShellStyle(getShellStyle()|SWT.RESIZE);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
newName = ""; //$NON-NLS-1$
newDescription = ""; //$NON-NLS-1$
}
@@ -99,10 +98,10 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
for (int i = 0; i < cfgds.length; i++) {
description = cfgds[i].getDescription();
- if( (description == null) || (description.isEmpty()) ){
+ if ((description == null) || (description.isEmpty())) {
nameAndDescription = cfgds[i].getName();
} else {
- nameAndDescription = cfgds[i].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
+ nameAndDescription = cfgds[i].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
if (nameAndDescription.equals(baseConfigNameAndDescription)) {
parentConfig = cfgds[i];
@@ -192,24 +191,24 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
}
});
-// Add a label and a text widget for Configuration's description
- final Label descriptionLabel = new Label(group1, SWT.LEFT);
- descriptionLabel.setFont(parent.getFont());
- descriptionLabel.setText(Messages.NewConfiguration_label_description);
+ // Add a label and a text widget for Configuration's description
+ final Label descriptionLabel = new Label(group1, SWT.LEFT);
+ descriptionLabel.setFont(parent.getFont());
+ descriptionLabel.setText(Messages.NewConfiguration_label_description);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 1;
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
gd.grabExcessHorizontalSpace = false;
- descriptionLabel.setLayoutData(gd);
- configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
- configDescription.setFont(group1.getFont());
+ descriptionLabel.setLayoutData(gd);
+ configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
+ configDescription.setFont(group1.getFont());
configDescription.setText(getNewDescription());
configDescription.setFocus();
- gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
- gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- configDescription.setLayoutData(gd);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ configDescription.setLayoutData(gd);
final Group group = new Group(composite, SWT.NONE);
group.setFont(composite.getFont());
@@ -244,19 +243,18 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
return composite;
}
-
/*
* Returns the array of configuration names defined for this managed project.
* This list will be used to populate the list of configurations to
* clone.
*/
- private String [] getDefinedConfigNamesAndDescriptions() {
- String [] namesAndDescriptions = new String[cfgds.length];
+ private String[] getDefinedConfigNamesAndDescriptions() {
+ String[] namesAndDescriptions = new String[cfgds.length];
for (int i = 0; i < cfgds.length; ++i) {
- if ( (cfgds[i].getDescription() == null) || cfgds[i].getDescription().isEmpty())
+ if ((cfgds[i].getDescription() == null) || cfgds[i].getDescription().isEmpty())
namesAndDescriptions[i] = cfgds[i].getName();
else
- namesAndDescriptions[i] = cfgds[i].getName() + "( " + cfgds[i].getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$
+ namesAndDescriptions[i] = cfgds[i].getName() + "( " + cfgds[i].getDescription() + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
return namesAndDescriptions;
}
@@ -321,6 +319,7 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
}
return true;
}
+
/* (non-Javadoc)
* Update the status message and button state based on the input selected
* by the user
@@ -330,15 +329,15 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
String s = null;
String currentName = configName.getText();
// Trim trailing whitespace
- while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) {
- currentName = currentName.substring(0, currentName.length()-1);
+ while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length() - 1))) {
+ currentName = currentName.substring(0, currentName.length() - 1);
}
// Make sure that the name is at least one character in length
if (currentName.length() == 0) {
// No error message, but cannot select OK
- s = ""; //$NON-NLS-1$
+ s = ""; //$NON-NLS-1$
} else if (cfgds.length == 0) {
- s = ""; //$NON-NLS-1$
+ s = ""; //$NON-NLS-1$
// Make sure the name is not a duplicate
} else if (isDuplicateName(currentName)) {
s = NLS.bind(Messages.NewConfiguration_error_duplicateName, currentName);
@@ -348,21 +347,25 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
// TODO Create a decent I18N string to describe this problem
s = NLS.bind(Messages.NewConfiguration_error_invalidName, currentName);
}
- if (statusLabel == null) return;
+ if (statusLabel == null)
+ return;
Button b = getButton(IDialogConstants.OK_ID);
if (s != null) {
statusLabel.setText(s);
statusLabel.setVisible(true);
- if (b != null) b.setEnabled(false);
+ if (b != null)
+ b.setEnabled(false);
} else {
statusLabel.setVisible(false);
- if (b != null) b.setEnabled(true);
+ if (b != null)
+ b.setEnabled(true);
}
return;
}
- public String getNewDescription() {
- return newDescription;
- }
+
+ public String getNewDescription() {
+ return newDescription;
+ }
/**
* Create a new configuration, using the values currently set in
@@ -374,11 +377,12 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
ICConfigurationDescription newcfg = des.createConfiguration(id, newName, parentConfig);
newcfg.setDescription(newDescription);
} catch (CoreException e) {
- System.out.println("Cannot create config\n"+ e.getLocalizedMessage()); //$NON-NLS-1$
+ System.out.println("Cannot create config\n" + e.getLocalizedMessage()); //$NON-NLS-1$
}
}
// useless in our case
@Override
- public void setShell(Shell shell) {}
+ public void setShell(Shell shell) {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PageLayout.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PageLayout.java
index 81f5d18fbb0..965f9903b5c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PageLayout.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PageLayout.java
@@ -20,13 +20,12 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
-
/**
* Layout for the page container.
* @noextend This class is not intended to be subclassed by clients.
*/
public class PageLayout extends Layout {
-
+
/**
* The minimum page size; 200 by 200 by default.
*
@@ -42,8 +41,9 @@ public class PageLayout extends Layout {
children[i].setSize(rect.width, rect.height);
}
}
+
@Override
- public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
+ public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
return new Point(wHint, hHint);
}
@@ -65,4 +65,3 @@ public class PageLayout extends Layout {
return new Point(x, y);
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java
index 27466269cfa..3641dc7737f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java
@@ -36,9 +36,9 @@ public class Page_head_general extends PropertyPage implements ICOptionContainer
@Override
protected Control createContents(Composite parent) {
- isProjectLevel= getProject() != null;
- if(isProjectLevel) {
- fDocBlock= new DocCommentOwnerBlock();
+ isProjectLevel = getProject() != null;
+ if (isProjectLevel) {
+ fDocBlock = new DocCommentOwnerBlock();
fDocBlock.setContainer(this);
fDocBlock.createControl(parent);
}
@@ -48,7 +48,7 @@ public class Page_head_general extends PropertyPage implements ICOptionContainer
@Override
protected void performDefaults() {
- if(isProjectLevel) {
+ if (isProjectLevel) {
fDocBlock.performDefaults();
}
super.performDefaults();
@@ -56,10 +56,10 @@ public class Page_head_general extends PropertyPage implements ICOptionContainer
@Override
public boolean performOk() {
- if(isProjectLevel) {
+ if (isProjectLevel) {
try {
fDocBlock.performApply(new NullProgressMonitor());
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
CUIPlugin.log(ce);
}
}
@@ -67,13 +67,13 @@ public class Page_head_general extends PropertyPage implements ICOptionContainer
}
@Override
- public IProject getProject(){
- IProject project= null;
+ public IProject getProject() {
+ IProject project = null;
IAdaptable elem = getElement();
if (elem instanceof IProject) {
- project= (IProject) elem;
+ project = (IProject) elem;
} else if (elem != null) {
- project= elem.getAdapter(IProject.class);
+ project = elem.getAdapter(IProject.class);
}
return project;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java
index cf5aba292eb..b570433e2fc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java
@@ -18,22 +18,22 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.model.CoreModel;
-/* This class is a base for preference pages
- * which store data in preferences
- * It means:
+/* This class is a base for preference pages
+ * which store data in preferences
+ * It means:
* - changes are saved by tabs, not by page
* - if changes are made, all projects are
* to be updated
*/
public class PrefPage_Abstract extends AbstractPrefPage {
-
+
static public boolean isChanged;
-
+
public PrefPage_Abstract() {
super();
isChanged = false;
}
-
+
protected void doSave(IProgressMonitor monitor) throws CoreException {
if (isChanged) {
CoreModel.getDefault().updateProjectDescriptions(null, monitor);
@@ -41,7 +41,12 @@ public class PrefPage_Abstract extends AbstractPrefPage {
}
@Override
- protected String getHeader() { return null; }
+ protected String getHeader() {
+ return null;
+ }
+
@Override
- protected boolean isSingle() { return true; }
+ protected boolean isSingle() {
+ return true;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java
index 60b1b553165..f87167abc80 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java
@@ -40,6 +40,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.cdt.internal.ui.newui.Messages;
+
/**
* @noextend This class is not intended to be subclassed by clients.
*/
@@ -103,8 +104,7 @@ public class ProjectContentsArea {
if (useDefaults) {
userPath = locationPathField.getText();
- locationPathField.setText(TextProcessor
- .process(getDefaultPathDisplayString()));
+ locationPathField.setText(TextProcessor.process(getDefaultPathDisplayString()));
} else {
locationPathField.setText(TextProcessor.process(userPath));
}
@@ -153,14 +153,12 @@ public class ProjectContentsArea {
});
if (defaultEnabled) {
- locationPathField.setText(TextProcessor
- .process(getDefaultPathDisplayString()));
+ locationPathField.setText(TextProcessor.process(getDefaultPathDisplayString()));
} else {
if (existingProject == null) {
locationPathField.setText(AbstractPage.EMPTY_STR);
} else {
- locationPathField.setText(TextProcessor.process(existingProject
- .getLocation().toString()));
+ locationPathField.setText(TextProcessor.process(existingProject.getLocation().toString()));
}
}
@@ -224,7 +222,8 @@ public class ProjectContentsArea {
if (!dirName.equals(AbstractPage.EMPTY_STR)) {
File f = new Path(dirName).toFile();
- if (!f.exists()) dirName = AbstractPage.EMPTY_STR;
+ if (!f.exists())
+ dirName = AbstractPage.EMPTY_STR;
}
DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell());
@@ -268,7 +267,8 @@ public class ProjectContentsArea {
*/
private String checkValidLocation() {
- if (isDefault()) return null;
+ if (isDefault())
+ return null;
String locationFieldContents = locationPathField.getText();
@@ -294,7 +294,8 @@ public class ProjectContentsArea {
boolean result = false;
try {
result = f.createNewFile();
- } catch (IOException e) {}
+ } catch (IOException e) {
+ }
if (result)
f.delete();
@@ -355,9 +356,7 @@ public class ProjectContentsArea {
* @return String
*/
public String getProjectLocation() {
- return isDefault() ?
- Platform.getLocation().toString():
- locationPathField.getText();
+ return isDefault() ? Platform.getLocation().toString() : locationPathField.getText();
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java
index f5b126b4e82..e820237d076 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java
@@ -67,24 +67,18 @@ public class RefsTab extends AbstractCPropertyTab {
@Override
public void createControls(Composite parent) {
super.createControls(parent);
- initButtons(new String[] {
- Messages.RefsTab_ExpandAll,
- Messages.RefsTab_CollapseAll,
- null,
- MOVEUP_STR,
- MOVEDOWN_STR}, 120);
+ initButtons(new String[] { Messages.RefsTab_ExpandAll, Messages.RefsTab_CollapseAll, null, MOVEUP_STR,
+ MOVEDOWN_STR }, 120);
usercomp.setLayout(new GridLayout(1, false));
tree = new Tree(usercomp, SWT.SINGLE | SWT.CHECK | SWT.BORDER);
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
- tree.getAccessible().addAccessibleListener(
- new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result = Messages.RefsTab_ProjectsList;
- }
- }
- );
+ tree.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ e.result = Messages.RefsTab_ProjectsList;
+ }
+ });
// Populate the tree
initData();
@@ -93,7 +87,7 @@ public class RefsTab extends AbstractCPropertyTab {
@Override
public void widgetSelected(SelectionEvent e) {
if ((e.detail & SWT.CHECK) == SWT.CHECK && e.item != null && (e.item instanceof TreeItem)) {
- TreeItem sel = (TreeItem)e.item;
+ TreeItem sel = (TreeItem) e.item;
Object data = sel.getData();
// If data is not a configuration ID, then the user isn't allowed to select this...
@@ -121,18 +115,18 @@ public class RefsTab extends AbstractCPropertyTab {
}
} else {
// Configuration selected (it has a parent)
- if (parent.getChecked()) {
- // Deselect other configs already selected
- for (TreeItem obj : parent.getItems())
- obj.setChecked(false);
- sel.setChecked(checked);
- }
- parent.setChecked(checked);
+ if (parent.getChecked()) {
+ // Deselect other configs already selected
+ for (TreeItem obj : parent.getItems())
+ obj.setChecked(false);
+ sel.setChecked(checked);
+ }
+ parent.setChecked(checked);
}
// Save the checked configurations
saveChecked();
- }
+ }
updateButtons();
}
});
@@ -142,50 +136,51 @@ public class RefsTab extends AbstractCPropertyTab {
public void treeCollapsed(TreeEvent e) {
updateExpandButtons(e, false, true);
}
+
@Override
public void treeExpanded(TreeEvent e) {
updateExpandButtons(e, true, false);
- }});
+ }
+ });
}
- @Override
+ @Override
public void buttonPressed(int n) {
- switch (n)
- {
- case COLLAPSE_ALL_BUTTON:
- case EXPAND_ALL_BUTTON:
- for (TreeItem item : tree.getItems())
- item.setExpanded(n==EXPAND_ALL_BUTTON);
- updateButtons();
- break;
- case MOVEUP_BUTTON:
- case MOVEDOWN_BUTTON:
- // TODO cache this...
- Map<String, String> oldMapping = getResDesc().getConfiguration().getReferenceInfo();
- TreeItem ti = tree.getSelection()[0];
- String projectName = ti.getText();
- List<String> projNames = new ArrayList<String>(oldMapping.keySet());
- int index = projNames.indexOf(projectName);
- if (n == MOVEUP_BUTTON) {
- if (index > 0) {
- projNames.set(index, projNames.get(index - 1));
- projNames.set(index - 1, projectName);
- }
- } else {
- if (index < projNames.size() - 1) {
- projNames.set(index, projNames.get(index + 1));
- projNames.set(index + 1, projectName);
- }
- }
- Map<String, String> newMapping = new LinkedHashMap<String, String>(oldMapping.size());
- for (String name : projNames)
- newMapping.put(name, oldMapping.get(name));
- getResDesc().getConfiguration().setReferenceInfo(newMapping);
- initData();
- break;
- }
- }
+ switch (n) {
+ case COLLAPSE_ALL_BUTTON:
+ case EXPAND_ALL_BUTTON:
+ for (TreeItem item : tree.getItems())
+ item.setExpanded(n == EXPAND_ALL_BUTTON);
+ updateButtons();
+ break;
+ case MOVEUP_BUTTON:
+ case MOVEDOWN_BUTTON:
+ // TODO cache this...
+ Map<String, String> oldMapping = getResDesc().getConfiguration().getReferenceInfo();
+ TreeItem ti = tree.getSelection()[0];
+ String projectName = ti.getText();
+ List<String> projNames = new ArrayList<String>(oldMapping.keySet());
+ int index = projNames.indexOf(projectName);
+ if (n == MOVEUP_BUTTON) {
+ if (index > 0) {
+ projNames.set(index, projNames.get(index - 1));
+ projNames.set(index - 1, projectName);
+ }
+ } else {
+ if (index < projNames.size() - 1) {
+ projNames.set(index, projNames.get(index + 1));
+ projNames.set(index + 1, projectName);
+ }
+ }
+ Map<String, String> newMapping = new LinkedHashMap<String, String>(oldMapping.size());
+ for (String name : projNames)
+ newMapping.put(name, oldMapping.get(name));
+ getResDesc().getConfiguration().setReferenceInfo(newMapping);
+ initData();
+ break;
+ }
+ }
@Override
protected void updateData(ICResourceDescription cfgd) {
@@ -211,14 +206,14 @@ public class RefsTab extends AbstractCPropertyTab {
for (TreeItem project : tree.getItems()) {
if (project.getChecked()) {
if (project.getData() instanceof String) {
- assert(project.getData() != null);
+ assert (project.getData() != null);
// Project is missing from the workspace, maintain references
- refs.put(project.getText(), (String)project.getData());
+ refs.put(project.getText(), (String) project.getData());
} else {
for (TreeItem config : project.getItems()) {
if (config.getChecked()) {
- assert(config.getData() != null);
- refs.put(project.getText(), (String)config.getData());
+ assert (config.getData() != null);
+ refs.put(project.getText(), (String) config.getData());
break; // only one configuration can be selected a time in a project
}
}
@@ -241,13 +236,13 @@ public class RefsTab extends AbstractCPropertyTab {
* {IProject.getName()} , {String cfgId}
*
*/
- private void initData() {
- // Persist the current select / expand state to restore...
- String currentSelection = tree.getSelectionCount() == 1 ? tree.getSelection()[0].getText() : null;
- Set<String> currentExpanded = new HashSet<String>();
- for (TreeItem ti : tree.getItems())
- if (ti.getExpanded())
- currentExpanded.add(ti.getText());
+ private void initData() {
+ // Persist the current select / expand state to restore...
+ String currentSelection = tree.getSelectionCount() == 1 ? tree.getSelection()[0].getText() : null;
+ Set<String> currentExpanded = new HashSet<String>();
+ for (TreeItem ti : tree.getItems())
+ if (ti.getExpanded())
+ currentExpanded.add(ti.getText());
tree.removeAll();
IProject p = page.getProject();
@@ -255,7 +250,7 @@ public class RefsTab extends AbstractCPropertyTab {
return;
// Get all the CDT references
- Map<String,String> refs = getResDesc().getConfiguration().getReferenceInfo();
+ Map<String, String> refs = getResDesc().getConfiguration().getReferenceInfo();
// Preserve project order. All linked to projects occur before others
Set<String> projects = new LinkedHashSet<String>(refs.keySet());
@@ -271,7 +266,7 @@ public class RefsTab extends AbstractCPropertyTab {
prj = p.getWorkspace().getRoot().getProject(pname);
cfgs = page.getCfgsReadOnly(prj);
} catch (Exception e) {
- CUIPlugin.log(Messages.RefsTab_ConfigurationsAccessError+pname, e);
+ CUIPlugin.log(Messages.RefsTab_ConfigurationsAccessError + pname, e);
continue;
}
if (cfgs == null || cfgs.length == 0) {
@@ -373,14 +368,14 @@ public class RefsTab extends AbstractCPropertyTab {
private void updateExpandButtons(TreeEvent e, boolean stateE, boolean stateC) {
boolean cntE = stateE;
boolean cntC = stateC;
- for (TreeItem item : tree.getItems()) {
- if (e != null && e.widget.equals(item))
- continue;
- if (item.getExpanded())
- cntE = true;
- else
- cntC = true;
- }
+ for (TreeItem item : tree.getItems()) {
+ if (e != null && e.widget.equals(item))
+ continue;
+ if (item.getExpanded())
+ cntE = true;
+ else
+ cntC = true;
+ }
buttonSetEnabled(EXPAND_ALL_BUTTON, cntC); // Expand All
buttonSetEnabled(COLLAPSE_ALL_BUTTON, cntE); // Collapse all
}
@@ -404,4 +399,3 @@ public class RefsTab extends AbstractCPropertyTab {
}
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java
index 834bc12fe87..ee3dfe5eebe 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java
@@ -53,21 +53,21 @@ public class RenameConfigurationDialog extends Dialog {
private String originalName;
final private String title;
+
/**
*/
- protected RenameConfigurationDialog(Shell parentShell,
- ICConfigurationDescription _renameConfig,
- ICConfigurationDescription[] _cfgds,
- String _title) {
+ protected RenameConfigurationDialog(Shell parentShell, ICConfigurationDescription _renameConfig,
+ ICConfigurationDescription[] _cfgds, String _title) {
super(parentShell);
title = _title;
renameConfig = _renameConfig;
cfgds = _cfgds;
- setShellStyle(getShellStyle()|SWT.RESIZE);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
newName = renameConfig.getName();
newDescription = renameConfig.getDescription();
- if(newDescription == null) newDescription = ""; //$NON-NLS-1$
+ if (newDescription == null)
+ newDescription = ""; //$NON-NLS-1$
originalName = renameConfig.getName();
}
@@ -91,7 +91,8 @@ public class RenameConfigurationDialog extends Dialog {
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
- if (title != null) shell.setText(title);
+ if (title != null)
+ shell.setText(title);
}
/* (non-Javadoc)
@@ -159,26 +160,26 @@ public class RenameConfigurationDialog extends Dialog {
}
});
-// Add a label and a text widget for Configuration's description
- final Label descriptionLabel = new Label(group1, SWT.LEFT);
- descriptionLabel.setFont(parent.getFont());
- descriptionLabel.setText(Messages.RenameConfiguration_label_description);
+ // Add a label and a text widget for Configuration's description
+ final Label descriptionLabel = new Label(group1, SWT.LEFT);
+ descriptionLabel.setFont(parent.getFont());
+ descriptionLabel.setText(Messages.RenameConfiguration_label_description);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 1;
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
gd.grabExcessHorizontalSpace = false;
- descriptionLabel.setLayoutData(gd);
- configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
- configDescription.setFont(group1.getFont());
+ descriptionLabel.setLayoutData(gd);
+ configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
+ configDescription.setFont(group1.getFont());
configDescription.setText(getNewDescription());
configDescription.setFocus();
- gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
- gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- configDescription.setLayoutData(gd);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ configDescription.setLayoutData(gd);
- statusLabel = new Label(parent, SWT.CENTER);
+ statusLabel = new Label(parent, SWT.CENTER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
statusLabel.setLayoutData(gd);
@@ -188,19 +189,23 @@ public class RenameConfigurationDialog extends Dialog {
}
protected boolean isDuplicateName(String newName) {
- if(newName.equals(originalName)) return false;
+ if (newName.equals(originalName))
+ return false;
// Return true if there is already a config of that name defined
for (int i = 0; i < cfgds.length; i++) {
- if (cfgds[i].getName().equals(newName)) return true;
+ if (cfgds[i].getName().equals(newName))
+ return true;
}
return false;
}
protected boolean isSimilarName(String newName) {
- if(newName.equalsIgnoreCase(originalName)) return false;
+ if (newName.equalsIgnoreCase(originalName))
+ return false;
// Return true if there is already a config of that name defined on the target
for (int i = 0; i < cfgds.length; i++) {
- if (cfgds[i].getName().equalsIgnoreCase(newName)) return true;
+ if (cfgds[i].getName().equalsIgnoreCase(newName))
+ return true;
}
return false;
}
@@ -237,6 +242,7 @@ public class RenameConfigurationDialog extends Dialog {
}
return true;
}
+
/* (non-Javadoc)
* Update the status message and button state based on the input selected
* by the user
@@ -247,8 +253,8 @@ public class RenameConfigurationDialog extends Dialog {
String currentName = configName.getText().trim();
// Make sure that the name is at least one character in length
if (currentName.length() == 0) {
- s = ""; //$NON-NLS-1$
- // Make sure the name is not a duplicate
+ s = ""; //$NON-NLS-1$
+ // Make sure the name is not a duplicate
} else if (isDuplicateName(currentName)) {
s = NLS.bind(Messages.RenameConfiguration_error_duplicateName, currentName);
} else if (isSimilarName(currentName)) {
@@ -260,14 +266,21 @@ public class RenameConfigurationDialog extends Dialog {
if (s != null) {
statusLabel.setText(s);
statusLabel.setVisible(true);
- if (b != null) b.setEnabled(false);
+ if (b != null)
+ b.setEnabled(false);
} else {
statusLabel.setVisible(false);
- if (b != null) b.setEnabled(true);
+ if (b != null)
+ b.setEnabled(true);
}
return;
}
- public String getNewName() { return newName; }
- public String getNewDescription() { return newDescription; }
+ public String getNewName() {
+ return newName;
+ }
+
+ public String getNewDescription() {
+ return newDescription;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java
index 94cd780fc35..beaa818d518 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java
@@ -57,8 +57,10 @@ public class StringListModeControl {
@Override
public void handleEvent(Event event) {
// Use event.text to tell which link was used
- int result = PreferencesUtil.createPreferenceDialogOn(parent.getShell(), STRING_LIST_MODE_PREFERENCE_PAGE, null, null).open();
- if (result!=Window.CANCEL) {
+ int result = PreferencesUtil
+ .createPreferenceDialogOn(parent.getShell(), STRING_LIST_MODE_PREFERENCE_PAGE, null, null)
+ .open();
+ if (result != Window.CANCEL) {
updateStringListModeControl();
for (Listener listener : listeners) {
listener.handleEvent(event);
@@ -88,7 +90,7 @@ public class StringListModeControl {
* @param eventType the type of event to listen for, currently not used.
* @param listener the listener which should no longer be notified.
*/
- protected void removeListener (int eventType, Listener listener) {
+ protected void removeListener(int eventType, Listener listener) {
listeners.remove(listener);
}
@@ -129,8 +131,8 @@ public class StringListModeControl {
break;
}
- linkStringListMode.setText(Messages.AbstractLangsListTab_StringListMode +
- " <a href=\"workspace-settings\">"+modeDisplay+"</a> + <a href=\"workspace-settings\">"+modeWrite+"</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ linkStringListMode.setText(Messages.AbstractLangsListTab_StringListMode + " <a href=\"workspace-settings\">" //$NON-NLS-1$
+ + modeDisplay + "</a> + <a href=\"workspace-settings\">" + modeWrite + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
}
linkStringListMode.getParent().layout();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java
index 87485fb33c8..763ea025113 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java
@@ -85,12 +85,13 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
*
* @noextend This class is not intended to be subclassed by clients.
*/
-public class StructureTreeTab extends AbstractCPropertyTab {
+public class StructureTreeTab extends AbstractCPropertyTab {
protected class LevelDialog extends Dialog {
protected LevelDialog() {
super(CUIPlugin.getActiveWorkbenchShell());
}
+
@Override
protected Control createDialogArea(Composite parent) {
Composite c = new Composite(parent, 0);
@@ -103,15 +104,16 @@ public class StructureTreeTab extends AbstractCPropertyTab {
sp.setMaximum(NESTING_MAX);
sp.setMinimum(0);
sp.setSelection(currentLevel);
- sp.addSelectionListener(new SelectionAdapter () {
+ sp.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- currentLevel = ((Spinner)e.widget).getSelection();
+ currentLevel = ((Spinner) e.widget).getSelection();
}
});
return c;
}
}
+
private static final String BL = "["; //$NON-NLS-1$
private static final String BR = "]"; //$NON-NLS-1$
private static final Image IMG = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_ERROR);
@@ -129,14 +131,16 @@ public class StructureTreeTab extends AbstractCPropertyTab {
* - tree item nesting is no too deep.
*/
private boolean check(TreeItem ti, Object obj) {
- if (obj == null || ti == null) return false;
+ if (obj == null || ti == null)
+ return false;
// data not used now
// ti.setData(obj);
int cnt = NESTING_MAX;
TreeItem tiSaved = ti;
while (--cnt > 0) {
ti = ti.getParentItem();
- if (ti == null) return true;
+ if (ti == null)
+ return true;
}
tiSaved.setText(2, Messages.StructureTreeTab_1);
tiSaved.setImage(IMG);
@@ -154,6 +158,7 @@ public class StructureTreeTab extends AbstractCPropertyTab {
t.setText(2, EMPTY_STR);
return t;
}
+
private TreeItem create(TreeItem ti0, String text, long val) {
TreeItem t = create(ti0, text, String.valueOf(val));
t.setText(2, Messages.StructureTreeTab_2);
@@ -161,9 +166,9 @@ public class StructureTreeTab extends AbstractCPropertyTab {
}
private TreeItem create(TreeItem ti0, String text, String val) {
- TreeItem ti = ti0 == null ? new TreeItem(tree, 0) : new TreeItem(ti0, 0);
+ TreeItem ti = ti0 == null ? new TreeItem(tree, 0) : new TreeItem(ti0, 0);
ti.setText(0, text == null ? NULL : text);
- ti.setText(1, val == null ? NULL : val );
+ ti.setText(1, val == null ? NULL : val);
ti.setText(2, Messages.StructureTreeTab_3);
return ti;
}
@@ -190,7 +195,8 @@ public class StructureTreeTab extends AbstractCPropertyTab {
@Override
public void widgetSelected(SelectionEvent e) {
updateData(cfg);
- }});
+ }
+ });
Button b1 = new Button(usercomp, SWT.PUSH);
GridData gd = new GridData(GridData.END);
@@ -203,7 +209,8 @@ public class StructureTreeTab extends AbstractCPropertyTab {
tree.setRedraw(false);
expandAll(tree.getItem(0), true, -1);
tree.setRedraw(true);
- }});
+ }
+ });
Button b2 = new Button(usercomp, SWT.PUSH);
gd = new GridData(GridData.END);
@@ -219,7 +226,8 @@ public class StructureTreeTab extends AbstractCPropertyTab {
expandAll(tree.getItem(0), true, 0);
tree.setRedraw(true);
}
- }});
+ }
+ });
Button b3 = new Button(usercomp, SWT.PUSH);
gd = new GridData(GridData.END);
@@ -232,7 +240,8 @@ public class StructureTreeTab extends AbstractCPropertyTab {
tree.setRedraw(false);
expandAll(tree.getItem(0), false, -1);
tree.setRedraw(true);
- }});
+ }
+ });
tree = new Tree(usercomp, SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
@@ -256,14 +265,17 @@ public class StructureTreeTab extends AbstractCPropertyTab {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
+
@Override
public void widgetSelected(SelectionEvent e) {
- }});
+ }
+ });
}
private TreeItem createObj(TreeItem ti0, String text, String name, Object obj) {
- TreeItem t = create(ti0, text, BL+name+BR);
- if (obj != null) t.setText(2, obj.getClass().getName());
+ TreeItem t = create(ti0, text, BL + name + BR);
+ if (obj != null)
+ t.setText(2, obj.getClass().getName());
return t;
}
@@ -274,46 +286,65 @@ public class StructureTreeTab extends AbstractCPropertyTab {
TreeItem ti = create(ti0, text, obs == null ? 0 : obs.length);
if (obs == null || !check(ti, obs))
return;
- for (int i=0; i<obs.length; i++) {
- String s = BL+i+BR;
- if (obs[i] instanceof String) create(ti, s, (String)obs[i]);
- else if (obs[i] instanceof CLanguageData) update(ti, s, (CLanguageData)obs[i]);
- else if (obs[i] instanceof CResourceData) update(ti, s, (CResourceData)obs[i]);
- else if (obs[i] instanceof ICExclusionPatternPathEntry) update(ti, s, (ICExclusionPatternPathEntry)obs[i]);
- else if (obs[i] instanceof ICExternalSetting) update(ti, s, (ICExternalSetting)obs[i]);
- else if (obs[i] instanceof ICLanguageSettingEntry) update(ti, s, (ICLanguageSettingEntry)obs[i]);
- else if (obs[i] instanceof ICResourceDescription) update(ti, s, (ICResourceDescription)obs[i]);
- else if (obs[i] instanceof ICSettingObject) update(ti, s, (ICSettingObject)obs[i]);
- else if (obs[i] instanceof IPath) update(ti, s, (IPath)obs[i]);
- else if (obs[i] instanceof IResource) update(ti, s, (IResource)obs[i]);
- else if (obs[i] instanceof IProjectNatureDescriptor) update(ti, s, (IProjectNatureDescriptor)obs[i]);
- else update(ti, s, obs[i]);
+ for (int i = 0; i < obs.length; i++) {
+ String s = BL + i + BR;
+ if (obs[i] instanceof String)
+ create(ti, s, (String) obs[i]);
+ else if (obs[i] instanceof CLanguageData)
+ update(ti, s, (CLanguageData) obs[i]);
+ else if (obs[i] instanceof CResourceData)
+ update(ti, s, (CResourceData) obs[i]);
+ else if (obs[i] instanceof ICExclusionPatternPathEntry)
+ update(ti, s, (ICExclusionPatternPathEntry) obs[i]);
+ else if (obs[i] instanceof ICExternalSetting)
+ update(ti, s, (ICExternalSetting) obs[i]);
+ else if (obs[i] instanceof ICLanguageSettingEntry)
+ update(ti, s, (ICLanguageSettingEntry) obs[i]);
+ else if (obs[i] instanceof ICResourceDescription)
+ update(ti, s, (ICResourceDescription) obs[i]);
+ else if (obs[i] instanceof ICSettingObject)
+ update(ti, s, (ICSettingObject) obs[i]);
+ else if (obs[i] instanceof IPath)
+ update(ti, s, (IPath) obs[i]);
+ else if (obs[i] instanceof IResource)
+ update(ti, s, (IResource) obs[i]);
+ else if (obs[i] instanceof IProjectNatureDescriptor)
+ update(ti, s, (IProjectNatureDescriptor) obs[i]);
+ else
+ update(ti, s, obs[i]);
}
}
private void expandAll(TreeItem ti, boolean b, int level) {
- if (level == -1) ti.setExpanded(b);
- else ti.setExpanded(level++ < currentLevel);
+ if (level == -1)
+ ti.setExpanded(b);
+ else
+ ti.setExpanded(level++ < currentLevel);
TreeItem[] tis = ti.getItems();
- if (tis == null) return;
+ if (tis == null)
+ return;
for (TreeItem ti2 : tis)
expandAll(ti2, b, level);
}
+
// used for languages kinds display
- private int[] flagsToArray(int flags){
+ private int[] flagsToArray(int flags) {
int arr[] = new int[32];
int num = 0;
- for(int i = 1; i != 0; i = i << 1){
- if((flags & i) != 0)
+ for (int i = 1; i != 0; i = i << 1) {
+ if ((flags & i) != 0)
arr[num++] = i;
}
- if(num == arr.length) return arr;
- else if(num == 0) return new int[0];
+ if (num == arr.length)
+ return arr;
+ else if (num == 0)
+ return new int[0];
int result[] = new int[num];
System.arraycopy(arr, 0, result, 0, num);
return result;
}
+
private int getDepth(TreeItem ti) {
int x = 0;
while (ti != null) {
@@ -324,30 +355,34 @@ public class StructureTreeTab extends AbstractCPropertyTab {
}
@Override
- protected void performApply(ICResourceDescription src,ICResourceDescription dst) {}
+ protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ }
@Override
- protected void performDefaults() {}
+ protected void performDefaults() {
+ }
private void update(ICProjectDescription prj) {
TreeItem ti = new TreeItem(tree, 0);
- if (!check(ti, prj)) return;
- ti.setText(0, "ICProjectDescription"); //$NON-NLS-1$
+ if (!check(ti, prj))
+ return;
+ ti.setText(0, "ICProjectDescription"); //$NON-NLS-1$
update(ti, "getActiveConfiguration()", prj.getActiveConfiguration()); //$NON-NLS-1$
expand(ti, "getConfigurations()", prj.getConfigurations()); //$NON-NLS-1$
- create(ti,"getId()",prj.getId()); //$NON-NLS-1$
- create(ti,"getName()",prj.getName()); //$NON-NLS-1$
+ create(ti, "getId()", prj.getId()); //$NON-NLS-1$
+ create(ti, "getName()", prj.getName()); //$NON-NLS-1$
update(ti, "getParent()", prj.getParent()); //$NON-NLS-1$
update(ti, "getProject()", prj.getProject()); //$NON-NLS-1$
- create(ti,"getType()",prj.getType()); //$NON-NLS-1$
- create(ti,"isModified()",prj.isModified()); //$NON-NLS-1$
- create(ti,"isReadOnly()",prj.isReadOnly()); //$NON-NLS-1$
- create(ti,"isValid()",prj.isValid()); //$NON-NLS-1$
+ create(ti, "getType()", prj.getType()); //$NON-NLS-1$
+ create(ti, "isModified()", prj.isModified()); //$NON-NLS-1$
+ create(ti, "isReadOnly()", prj.isReadOnly()); //$NON-NLS-1$
+ create(ti, "isValid()", prj.isValid()); //$NON-NLS-1$
}
private TreeItem update(TreeItem ti0, String text, CBuildData bd) {
- TreeItem ti = createObj(ti0, text, bd == null ? NULL : bd.getName(), bd);
- if (bd == null || !check(ti, bd)) return ti;
+ TreeItem ti = createObj(ti0, text, bd == null ? NULL : bd.getName(), bd);
+ if (bd == null || !check(ti, bd))
+ return ti;
// ALMOST THE SAME AS ICBuildSetting
update(ti, "getBuilderCWD()", bd.getBuilderCWD()); //$NON-NLS-1$
createObj(ti, "getBuildEnvironmentContributor()", EMPTY_STR, bd.getBuildEnvironmentContributor()); //$NON-NLS-1$
@@ -356,13 +391,14 @@ public class StructureTreeTab extends AbstractCPropertyTab {
create(ti, "getName()", bd.getName()); //$NON-NLS-1$
expand(ti, "getOutputDirectories()", bd.getOutputDirectories()); //$NON-NLS-1$
create(ti, "getType()", bd.getType()); //$NON-NLS-1$
- create(ti, "isValid()",bd.isValid()); //$NON-NLS-1$
+ create(ti, "isValid()", bd.isValid()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, CConfigurationData cd) {
TreeItem ti = createObj(ti0, text, cd == null ? NULL : cd.getName(), cd);
- if (cd == null || !check(ti, cd)) return ti;
+ if (cd == null || !check(ti, cd))
+ return ti;
update(ti, "getBuildData()", cd.getBuildData()); //$NON-NLS-1$
createObj(ti, "getBuildVariablesContributor()", EMPTY_STR, cd.getBuildVariablesContributor()); //$NON-NLS-1$
create(ti, "getDescription()", cd.getDescription()); //$NON-NLS-1$
@@ -370,60 +406,65 @@ public class StructureTreeTab extends AbstractCPropertyTab {
create(ti, "getName()", cd.getName()); //$NON-NLS-1$
expand(ti, "getResourceDatas()", cd.getResourceDatas()); //$NON-NLS-1$
update(ti, "getRootFolderData()", cd.getRootFolderData()); //$NON-NLS-1$
-// expand(ti, "getSourcePaths()", cd.getSourcePaths()); //$NON-NLS-1$
+ // expand(ti, "getSourcePaths()", cd.getSourcePaths()); //$NON-NLS-1$
update(ti, "getTargetPlatformData()", cd.getTargetPlatformData()); //$NON-NLS-1$
- create(ti,"getType()",cd.getType()); //$NON-NLS-1$
- create(ti,"isValid()",cd.isValid()); //$NON-NLS-1$
+ create(ti, "getType()", cd.getType()); //$NON-NLS-1$
+ create(ti, "isValid()", cd.isValid()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, CLanguageData ls) {
TreeItem ti = createObj(ti0, text, ls == null ? NULL : ls.getName(), ls);
- if (ls == null || !check(ti, ls)) return ti;
+ if (ls == null || !check(ti, ls))
+ return ti;
create(ti, "getId()", ls.getId()); //$NON-NLS-1$
create(ti, "getLanguageId()", ls.getLanguageId()); //$NON-NLS-1$
create(ti, "getName()", ls.getName()); //$NON-NLS-1$
expand(ti, "getSourceContentTypeIds()", ls.getSourceContentTypeIds()); //$NON-NLS-1$
expand(ti, "getSourceExtensions()", ls.getSourceExtensions()); //$NON-NLS-1$
- create(ti,"getType()",ls.getType()); //$NON-NLS-1$
+ create(ti, "getType()", ls.getType()); //$NON-NLS-1$
int k = ls.getSupportedEntryKinds();
TreeItem ti1 = create(ti, "getSupportedEntryKinds()", k); //$NON-NLS-1$
int[] kind = flagsToArray(k);
for (int element : kind) {
TreeItem ti2 = create(ti1, "Kind", element); //$NON-NLS-1$
- expand(ti2, "getEntries",ls.getEntries(element)); //$NON-NLS-1$
+ expand(ti2, "getEntries", ls.getEntries(element)); //$NON-NLS-1$
}
- create(ti,"isValid()",ls.isValid()); //$NON-NLS-1$
+ create(ti, "isValid()", ls.isValid()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, CResourceData bd) {
TreeItem ti = createObj(ti0, text, bd == null ? NULL : bd.getName(), bd);
- if (bd == null || !check(ti, bd)) return ti;
+ if (bd == null || !check(ti, bd))
+ return ti;
create(ti, "getId()", bd.getId()); //$NON-NLS-1$
if (bd instanceof CFolderData)
- expand(ti, "getLanguageDatas()", ((CFolderData)bd).getLanguageDatas()); //$NON-NLS-1$
+ expand(ti, "getLanguageDatas()", ((CFolderData) bd).getLanguageDatas()); //$NON-NLS-1$
create(ti, "getName()", bd.getName()); //$NON-NLS-1$
- update(ti,"getPath()",bd.getPath()); //$NON-NLS-1$
- create(ti,"getType()",bd.getType()); //$NON-NLS-1$
-// create(ti,"isExcluded()",bd.isExcluded()); //$NON-NLS-1$
- create(ti,"isValid()",bd.isValid()); //$NON-NLS-1$
+ update(ti, "getPath()", bd.getPath()); //$NON-NLS-1$
+ create(ti, "getType()", bd.getType()); //$NON-NLS-1$
+ // create(ti,"isExcluded()",bd.isExcluded()); //$NON-NLS-1$
+ create(ti, "isValid()", bd.isValid()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, CTargetPlatformData bd) {
TreeItem ti = createObj(ti0, text, bd == null ? NULL : bd.getName(), bd);
- if (bd == null || !check(ti, bd)) return ti;
+ if (bd == null || !check(ti, bd))
+ return ti;
expand(ti, "getBinaryParserIds()", bd.getBinaryParserIds()); //$NON-NLS-1$
create(ti, "getId()", bd.getId()); //$NON-NLS-1$
create(ti, "getName()", bd.getName()); //$NON-NLS-1$
- create(ti, "getType()",bd.getType()); //$NON-NLS-1$
- create(ti, "isValid()",bd.isValid()); //$NON-NLS-1$
+ create(ti, "getType()", bd.getType()); //$NON-NLS-1$
+ create(ti, "isValid()", bd.isValid()); //$NON-NLS-1$
return ti;
}
+
private TreeItem update(TreeItem ti0, String text, ICBuildSetting obj) {
TreeItem ti = createObj(ti0, text, obj == null ? NULL : obj.getName(), obj);
- if (obj == null || !check(ti, obj)) return ti;
+ if (obj == null || !check(ti, obj))
+ return ti;
// ALMOST THE SAME AS CBuildData
update(ti, "getBuilderCWD()", obj.getBuilderCWD()); //$NON-NLS-1$
createObj(ti, "getBuildEnvironmentContributor()", EMPTY_STR, obj.getBuildEnvironmentContributor()); //$NON-NLS-1$
@@ -436,13 +477,16 @@ public class StructureTreeTab extends AbstractCPropertyTab {
update(ti, "getParent()", obj.getParent()); //$NON-NLS-1$
create(ti, "getType()", obj.getType()); //$NON-NLS-1$
create(ti, "isReadOnly()", obj.isReadOnly()); //$NON-NLS-1$
- create(ti, "isValid()",obj.isValid()); //$NON-NLS-1$
+ create(ti, "isValid()", obj.isValid()); //$NON-NLS-1$
return ti;
}
+
private TreeItem update(TreeItem ti0, String text, ICConfigurationDescription cfg) {
TreeItem ti = createObj(ti0, text, cfg == null ? NULL : cfg.getName(), cfg);
- if (cfg == null || !check(ti, cfg)) return ti;
- if (getDepth(ti) > NESTING_CFG) return ti;
+ if (cfg == null || !check(ti, cfg))
+ return ti;
+ if (getDepth(ti) > NESTING_CFG)
+ return ti;
update(ti, "getBuildSetting()", cfg.getBuildSetting()); //$NON-NLS-1$
create(ti, "getBuildSystemId()", cfg.getBuildSystemId()); //$NON-NLS-1$
@@ -460,26 +504,27 @@ public class StructureTreeTab extends AbstractCPropertyTab {
update(ti, "getRootFolderDescription()", cfg.getRootFolderDescription()); //$NON-NLS-1$
expand(ti, "getSourceEntries()", cfg.getSourceEntries()); //$NON-NLS-1$
update(ti, "getTargetPlatformSetting()", cfg.getTargetPlatformSetting()); //$NON-NLS-1$
- create(ti,"getType()",cfg.getType()); //$NON-NLS-1$
- create(ti,"isActive()",cfg.isActive()); //$NON-NLS-1$
- create(ti,"isModified()",cfg.isModified()); //$NON-NLS-1$
- create(ti,"isPreferenceConfiguration()",cfg.isPreferenceConfiguration()); //$NON-NLS-1$
- create(ti,"isReadOnly()",cfg.isReadOnly()); //$NON-NLS-1$
- create(ti,"isValid()",cfg.isValid()); //$NON-NLS-1$
+ create(ti, "getType()", cfg.getType()); //$NON-NLS-1$
+ create(ti, "isActive()", cfg.isActive()); //$NON-NLS-1$
+ create(ti, "isModified()", cfg.isModified()); //$NON-NLS-1$
+ create(ti, "isPreferenceConfiguration()", cfg.isPreferenceConfiguration()); //$NON-NLS-1$
+ create(ti, "isReadOnly()", cfg.isReadOnly()); //$NON-NLS-1$
+ create(ti, "isValid()", cfg.isValid()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, ICExclusionPatternPathEntry s) {
TreeItem ti = createObj(ti0, text, s.getName(), s);
- if (!check(ti, s)) return ti;
+ if (!check(ti, s))
+ return ti;
char[][] chrs = s.fullExclusionPatternChars();
TreeItem ti1 = create(ti, "fullExclusionPatternChars()", chrs.length); //$NON-NLS-1$
- for (int j=0; j<chrs.length; j++)
- create(ti1, BL+j+BR, new String(chrs[j]));
+ for (int j = 0; j < chrs.length; j++)
+ create(ti1, BL + j + BR, new String(chrs[j]));
expand(ti, "getExclusionPatterns()", s.getExclusionPatterns()); //$NON-NLS-1$
- create(ti,"getFlags()", s.getFlags()); //$NON-NLS-1$
+ create(ti, "getFlags()", s.getFlags()); //$NON-NLS-1$
update(ti, "getFullPath()", s.getFullPath()); //$NON-NLS-1$
- create(ti,"getKind()", s.getKind()); //$NON-NLS-1$
+ create(ti, "getKind()", s.getKind()); //$NON-NLS-1$
update(ti, "getLocation()", s.getLocation()); //$NON-NLS-1$
create(ti, "getName()", s.getName()); //$NON-NLS-1$
create(ti, "getValue()", s.getValue()); //$NON-NLS-1$
@@ -492,24 +537,27 @@ public class StructureTreeTab extends AbstractCPropertyTab {
private TreeItem update(TreeItem ti0, String text, ICExternalSetting es) {
TreeItem ti = createObj(ti0, text, EMPTY_STR, es);
- if (!check(ti, es)) return ti;
+ if (!check(ti, es))
+ return ti;
expand(ti, "getCompatibleContentTypeIds()", es.getCompatibleContentTypeIds()); //$NON-NLS-1$
expand(ti, "getCompatibleExtensions()", es.getCompatibleExtensions()); //$NON-NLS-1$
expand(ti, "getCompatibleLanguageIds()", es.getCompatibleLanguageIds()); //$NON-NLS-1$
expand(ti, "getEntries()", es.getEntries()); //$NON-NLS-1$
return ti;
}
+
private TreeItem update(TreeItem ti0, String text, ICResourceDescription rcfg) {
TreeItem ti = createObj(ti0, text, rcfg == null ? NULL : rcfg.getName(), rcfg);
- if (rcfg == null || !check(ti, rcfg)) return ti;
+ if (rcfg == null || !check(ti, rcfg))
+ return ti;
update(ti, "getConfiguration()", rcfg.getConfiguration()); //$NON-NLS-1$
create(ti, "getId()", rcfg.getId()); //$NON-NLS-1$
create(ti, "getName()", rcfg.getName()); //$NON-NLS-1$
if (rcfg instanceof ICFileDescription)
- update(ti, "getLanguageSettings()", ((ICFileDescription)rcfg).getLanguageSetting()); //$NON-NLS-1$
+ update(ti, "getLanguageSettings()", ((ICFileDescription) rcfg).getLanguageSetting()); //$NON-NLS-1$
else if (rcfg instanceof ICFolderDescription) {
- expand(ti, "getLanguageSettings()", ((ICFolderDescription)rcfg).getLanguageSettings()); //$NON-NLS-1$
- ICResourceDescription[] rds = ((ICFolderDescription)rcfg).getNestedResourceDescriptions();
+ expand(ti, "getLanguageSettings()", ((ICFolderDescription) rcfg).getLanguageSettings()); //$NON-NLS-1$
+ ICResourceDescription[] rds = ((ICFolderDescription) rcfg).getNestedResourceDescriptions();
if (getDepth(ti) > NESTING_CFG)
create(ti, "getNestedResourceDescriptions()", rds.length); //$NON-NLS-1$
else
@@ -519,16 +567,18 @@ public class StructureTreeTab extends AbstractCPropertyTab {
update(ti, "getParentFolderDescription()", rcfg.getParentFolderDescription()); //$NON-NLS-1$
update(ti, "getPath()", rcfg.getPath()); //$NON-NLS-1$
create(ti, "getType()", rcfg.getType()); //$NON-NLS-1$
- create(ti,"isExcluded()", rcfg.isExcluded()); //$NON-NLS-1$
- create(ti,"isReadOnly()", rcfg.isReadOnly()); //$NON-NLS-1$
+ create(ti, "isExcluded()", rcfg.isExcluded()); //$NON-NLS-1$
+ create(ti, "isReadOnly()", rcfg.isReadOnly()); //$NON-NLS-1$
if (rcfg instanceof ICFolderDescription)
- create(ti,"isRoot()",((ICFolderDescription)rcfg).isRoot()); //$NON-NLS-1$
- create(ti,"isValid()",rcfg.isValid()); //$NON-NLS-1$
+ create(ti, "isRoot()", ((ICFolderDescription) rcfg).isRoot()); //$NON-NLS-1$
+ create(ti, "isValid()", rcfg.isValid()); //$NON-NLS-1$
return ti;
}
+
private TreeItem update(TreeItem ti0, String text, ICLanguageSetting ls) {
TreeItem ti = createObj(ti0, text, ls == null ? NULL : ls.getName(), ls);
- if (ls == null || !check(ti, ls)) return ti;
+ if (ls == null || !check(ti, ls))
+ return ti;
update(ti, "getConfiguration()", ls.getConfiguration()); //$NON-NLS-1$
create(ti, "getId()", ls.getId()); //$NON-NLS-1$
create(ti, "getLanguageId()", ls.getLanguageId()); //$NON-NLS-1$
@@ -536,23 +586,24 @@ public class StructureTreeTab extends AbstractCPropertyTab {
update(ti, "getParent()", ls.getParent()); //$NON-NLS-1$
expand(ti, "getSourceContentTypeIds()", ls.getSourceContentTypeIds()); //$NON-NLS-1$
expand(ti, "getSourceExtensions()", ls.getSourceExtensions()); //$NON-NLS-1$
- create(ti,"getType()",ls.getType()); //$NON-NLS-1$
+ create(ti, "getType()", ls.getType()); //$NON-NLS-1$
int k = ls.getSupportedEntryKinds();
TreeItem ti1 = create(ti, "getSupportedEntryKinds()", k); //$NON-NLS-1$
int[] kind = flagsToArray(k);
for (int element : kind) {
TreeItem ti2 = create(ti1, "Kind", element); //$NON-NLS-1$
- expand(ti2, "getResolvedSettingEntries",ls.getResolvedSettingEntries(element)); //$NON-NLS-1$
+ expand(ti2, "getResolvedSettingEntries", ls.getResolvedSettingEntries(element)); //$NON-NLS-1$
expand(ti2, "getSettingEntries", ls.getSettingEntries(element)); //$NON-NLS-1$
}
- create(ti,"isReadOnly()",ls.isReadOnly()); //$NON-NLS-1$
- create(ti,"isValid()",ls.isValid()); //$NON-NLS-1$
+ create(ti, "isReadOnly()", ls.isReadOnly()); //$NON-NLS-1$
+ create(ti, "isValid()", ls.isValid()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, ICLanguageSettingEntry ent) {
TreeItem ti = createObj(ti0, text, ent == null ? NULL : ent.getName(), ent);
- if (ent == null || !check(ti, ent)) return ti;
+ if (ent == null || !check(ti, ent))
+ return ti;
create(ti, "getFlags()", ent.getFlags()); //$NON-NLS-1$
create(ti, "getKind()", ent.getKind()); //$NON-NLS-1$
create(ti, "getName()", ent.getName()); //$NON-NLS-1$
@@ -565,43 +616,48 @@ public class StructureTreeTab extends AbstractCPropertyTab {
private TreeItem update(TreeItem ti0, String text, ICSettingContainer c) {
TreeItem ti = createObj(ti0, text, EMPTY_STR, c);
- if (!check(ti, c)) return ti;
- if (getDepth(ti) > NESTING_CFG) return ti;
+ if (!check(ti, c))
+ return ti;
+ if (getDepth(ti) > NESTING_CFG)
+ return ti;
expand(ti, "getChildSettings()", c.getChildSettings()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, ICSettingObject obj) {
TreeItem ti = createObj(ti0, text, obj == null ? NULL : obj.getName(), obj);
- if (obj == null || !check(ti, obj)) return ti;
+ if (obj == null || !check(ti, obj))
+ return ti;
if (obj instanceof ICTargetPlatformSetting)
- expand(ti, "getBinaryParserIds()", ((ICTargetPlatformSetting)obj).getBinaryParserIds()); //$NON-NLS-1$
+ expand(ti, "getBinaryParserIds()", ((ICTargetPlatformSetting) obj).getBinaryParserIds()); //$NON-NLS-1$
update(ti, "getConfiguration()", obj.getConfiguration()); //$NON-NLS-1$
create(ti, "getId()", obj.getId()); //$NON-NLS-1$
create(ti, "getName()", obj.getName()); //$NON-NLS-1$
createObj(ti, "getParent()", EMPTY_STR, obj.getParent()); //$NON-NLS-1$
create(ti, "getType()", obj.getType()); //$NON-NLS-1$
- create(ti,"isReadOnly()", obj.isReadOnly()); //$NON-NLS-1$
- create(ti,"isValid()",obj.isValid()); //$NON-NLS-1$
+ create(ti, "isReadOnly()", obj.isReadOnly()); //$NON-NLS-1$
+ create(ti, "isValid()", obj.isValid()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, ICTargetPlatformSetting obj) {
TreeItem ti = createObj(ti0, text, obj == null ? NULL : obj.getName(), obj);
- if (obj == null || !check(ti, obj)) return ti;
+ if (obj == null || !check(ti, obj))
+ return ti;
update(ti, "getConfiguration()", obj.getConfiguration()); //$NON-NLS-1$
create(ti, "getId()", obj.getId()); //$NON-NLS-1$
create(ti, "getName()", obj.getName()); //$NON-NLS-1$
update(ti, "getParent()", obj.getParent()); //$NON-NLS-1$
create(ti, "getType()", obj.getType()); //$NON-NLS-1$
- create(ti,"isReadOnly()", obj.isReadOnly()); //$NON-NLS-1$
- create(ti,"isValid()",obj.isValid()); //$NON-NLS-1$
+ create(ti, "isReadOnly()", obj.isReadOnly()); //$NON-NLS-1$
+ create(ti, "isValid()", obj.isValid()); //$NON-NLS-1$
return ti;
}
private TreeItem update(TreeItem ti0, String text, IPath p) {
TreeItem ti = createObj(ti0, text, p == null ? NULL : p.toString(), p);
- if (p == null || !check(ti, p)) return ti;
+ if (p == null || !check(ti, p))
+ return ti;
create(ti, "getDevice()", p.getDevice()); //$NON-NLS-1$
create(ti, "getFileExtension()", p.getFileExtension()); //$NON-NLS-1$
create(ti, "hasTrailingSeparator()", p.hasTrailingSeparator()); //$NON-NLS-1$
@@ -610,20 +666,23 @@ public class StructureTreeTab extends AbstractCPropertyTab {
create(ti, "isRoot()", p.isRoot()); //$NON-NLS-1$
create(ti, "isUNC()", p.isUNC()); //$NON-NLS-1$
TreeItem ti1 = create(ti, "segmentCount()", p.segmentCount()); //$NON-NLS-1$
- for (int i=0; i<p.segmentCount(); i++)
- create(ti1, "segment("+i+")", p.segment(i)); //$NON-NLS-1$ //$NON-NLS-2$
+ for (int i = 0; i < p.segmentCount(); i++)
+ create(ti1, "segment(" + i + ")", p.segment(i)); //$NON-NLS-1$ //$NON-NLS-2$
create(ti, "toOSString()", p.toOSString()); //$NON-NLS-1$
create(ti, "toPortableString()", p.toPortableString()); //$NON-NLS-1$
return ti;
}
+
private TreeItem update(TreeItem ti0, String text, IProject prj) {
TreeItem ti = createObj(ti0, text, prj == null ? NULL : prj.getName(), prj);
- if (prj == null || !check(ti, prj)) return ti;
+ if (prj == null || !check(ti, prj))
+ return ti;
create(ti, "exists()", prj.exists()); //$NON-NLS-1$
try {
create(ti, "getDefaultCharset()", prj.getDefaultCharset()); //$NON-NLS-1$
prj.getDescription();
- } catch (CoreException e) {}
+ } catch (CoreException e) {
+ }
update(ti, "getFullPath()", prj.getFullPath()); //$NON-NLS-1$
create(ti, "getName()", prj.getName()); //$NON-NLS-1$
update(ti, "getParent()", prj.getParent()); //$NON-NLS-1$
@@ -631,8 +690,10 @@ public class StructureTreeTab extends AbstractCPropertyTab {
IProject[] ps = prj.getReferencedProjects();
TreeItem ti1 = create(ti, "getReferencedProjects()", ps == null ? 0 : ps.length); //$NON-NLS-1$
if (ps != null)
- for (int i=0; i<ps.length; i++) update(ti1, BL+i+BR, ps[i]);
- } catch (CoreException e) {}
+ for (int i = 0; i < ps.length; i++)
+ update(ti1, BL + i + BR, ps[i]);
+ } catch (CoreException e) {
+ }
prj.getResourceAttributes();
create(ti, "getType()", prj.getType()); //$NON-NLS-1$
update(ti, "getWorkspace()", prj.getWorkspace()); //$NON-NLS-1$
@@ -641,7 +702,8 @@ public class StructureTreeTab extends AbstractCPropertyTab {
private TreeItem update(TreeItem ti0, String text, IProjectNatureDescriptor nd) {
TreeItem ti = createObj(ti0, text, nd == null ? NULL : nd.getLabel(), nd);
- if (nd == null || !check(ti, nd)) return ti;
+ if (nd == null || !check(ti, nd))
+ return ti;
create(ti, "getLabel()", nd.getLabel()); //$NON-NLS-1$
create(ti, "getNatureId()", nd.getNatureId()); //$NON-NLS-1$
expand(ti, "getNatureSetIds()", nd.getNatureSetIds()); //$NON-NLS-1$
@@ -652,25 +714,28 @@ public class StructureTreeTab extends AbstractCPropertyTab {
private TreeItem update(TreeItem ti0, String text, IResource c) {
TreeItem ti = createObj(ti0, text, c == null ? NULL : c.getName(), c);
- if (c == null || !check(ti, c)) return ti;
- if (getDepth(ti) > NESTING_CFG) return ti;
+ if (c == null || !check(ti, c))
+ return ti;
+ if (getDepth(ti) > NESTING_CFG)
+ return ti;
if (c instanceof IContainer)
try {
- create(ti, "getDefaultCharset()", ((IContainer)c).getDefaultCharset()); //$NON-NLS-1$
- } catch (CoreException e) {}
+ create(ti, "getDefaultCharset()", ((IContainer) c).getDefaultCharset()); //$NON-NLS-1$
+ } catch (CoreException e) {
+ }
create(ti, "getFileExtension()", c.getFileExtension()); //$NON-NLS-1$
update(ti, "getFullPath()", c.getFullPath()); //$NON-NLS-1$
-// TODO:
-// c.getLocalTimeStamp());
+ // TODO:
+ // c.getLocalTimeStamp());
update(ti, "getLocation()", c.getLocation()); //$NON-NLS-1$
update(ti, "getLocationURI()", c.getLocationURI()); //$NON-NLS-1$
-// c.getModificationStamp());
+ // c.getModificationStamp());
create(ti, "getName()", c.getName()); //$NON-NLS-1$
update(ti, "getParent()", c.getParent()); //$NON-NLS-1$
update(ti, "getProject()", c.getProject()); //$NON-NLS-1$
if (c instanceof IWorkspaceRoot)
- expand(ti, "getProjects()", ((IWorkspaceRoot)c).getProjects()); //$NON-NLS-1$
+ expand(ti, "getProjects()", ((IWorkspaceRoot) c).getProjects()); //$NON-NLS-1$
update(ti, "getProjectRelativePath()", c.getProjectRelativePath()); //$NON-NLS-1$
update(ti, "getRawLocation()", c.getRawLocation()); //$NON-NLS-1$
update(ti, "getRawLocationURI()", c.getRawLocationURI()); //$NON-NLS-1$
@@ -680,23 +745,25 @@ public class StructureTreeTab extends AbstractCPropertyTab {
create(ti, "isAccessible()", c.isAccessible()); //$NON-NLS-1$
create(ti, "isDerived()", c.isDerived()); //$NON-NLS-1$
create(ti, "isLinked()", c.isLinked()); //$NON-NLS-1$
- // create(ti, "isLocal(ZERO)", c.isLocal(0)); //$NON-NLS-1$
- // create(ti, "isLocal(INIFINITE)", c.isLocal(2)); //$NON-NLS-1$
+ // create(ti, "isLocal(ZERO)", c.isLocal(0)); //$NON-NLS-1$
+ // create(ti, "isLocal(INIFINITE)", c.isLocal(2)); //$NON-NLS-1$
create(ti, "isPhantom()", c.isPhantom()); //$NON-NLS-1$
- // create(ti, "isReadOnly()", c.isReadOnly()); //$NON-NLS-1$
+ // create(ti, "isReadOnly()", c.isReadOnly()); //$NON-NLS-1$
create(ti, "isSynchronized(ZERO)", c.isSynchronized(0)); //$NON-NLS-1$
create(ti, "isSynchronized(INFINITE)", c.isSynchronized(2)); //$NON-NLS-1$
create(ti, "isTeamPrivateMember()", c.isTeamPrivateMember()); //$NON-NLS-1$
if (c instanceof IContainer)
try {
- expand(ti, "members()", ((IContainer)c).members()); //$NON-NLS-1$
- } catch (CoreException e) {}
+ expand(ti, "members()", ((IContainer) c).members()); //$NON-NLS-1$
+ } catch (CoreException e) {
+ }
return ti;
}
private TreeItem update(TreeItem ti0, String text, IWorkspace w) {
TreeItem ti = createObj(ti0, text, EMPTY_STR, w);
- if (!check(ti, w)) return ti;
+ if (!check(ti, w))
+ return ti;
update(ti, "getDescription()", w.getDescription()); //$NON-NLS-1$
expand(ti, "getNatureDescriptors()", w.getNatureDescriptors()); //$NON-NLS-1$
createObj(ti, "getPathVariableManager()", EMPTY_STR, w.getPathVariableManager()); //$NON-NLS-1$
@@ -709,7 +776,8 @@ public class StructureTreeTab extends AbstractCPropertyTab {
private TreeItem update(TreeItem ti0, String text, IWorkspaceDescription w) {
TreeItem ti = createObj(ti0, text, EMPTY_STR, w);
- if (!check(ti, w)) return ti;
+ if (!check(ti, w))
+ return ti;
expand(ti, "getBuildOrder()", w.getBuildOrder()); //$NON-NLS-1$
create(ti, "getFileStateLongevity()", w.getFileStateLongevity()); //$NON-NLS-1$
create(ti, "getMaxBuildIterations()", w.getMaxBuildIterations()); //$NON-NLS-1$
@@ -724,15 +792,16 @@ public class StructureTreeTab extends AbstractCPropertyTab {
* Default method to display unknown classes
*/
private TreeItem update(TreeItem ti0, String text, Object ob) {
- TreeItem ti = createObj(ti0, BL+text+BR, "???", ob); //$NON-NLS-1$
+ TreeItem ti = createObj(ti0, BL + text + BR, "???", ob); //$NON-NLS-1$
check(ti, ob);
return ti;
}
- private TreeItem update(TreeItem ti0, String text, Map<String,String> m) {
+ private TreeItem update(TreeItem ti0, String text, Map<String, String> m) {
String s = (m == null) ? NULL : String.valueOf(m.size());
TreeItem ti = createObj(ti0, text, s, m);
- if (m == null || !check(ti, m)) return ti;
+ if (m == null || !check(ti, m))
+ return ti;
Iterator<String> it = m.keySet().iterator();
while (it.hasNext()) {
s = it.next();
@@ -743,7 +812,8 @@ public class StructureTreeTab extends AbstractCPropertyTab {
private TreeItem update(TreeItem ti0, String text, ResourceAttributes ra) {
TreeItem ti = createObj(ti0, text, EMPTY_STR, ra);
- if (!check(ti, ra)) return ti;
+ if (!check(ti, ra))
+ return ti;
create(ti, "isArchive()", ra.isArchive()); //$NON-NLS-1$
create(ti, "isExecutable()", ra.isExecutable()); //$NON-NLS-1$
create(ti, "isHidden()", ra.isHidden()); //$NON-NLS-1$
@@ -753,7 +823,8 @@ public class StructureTreeTab extends AbstractCPropertyTab {
private TreeItem update(TreeItem ti0, String text, URI uri) {
TreeItem ti = createObj(ti0, text, uri == null ? NULL : uri.toString(), uri);
- if (uri == null || !check(ti, uri)) return ti;
+ if (uri == null || !check(ti, uri))
+ return ti;
create(ti, "getAuthority()", uri.getAuthority()); //$NON-NLS-1$
create(ti, "getFragment()", uri.getFragment()); //$NON-NLS-1$
create(ti, "getHost()", uri.getHost()); //$NON-NLS-1$
@@ -804,5 +875,6 @@ public class StructureTreeTab extends AbstractCPropertyTab {
}
@Override
- protected void updateButtons() {} // Do nothing. No buttons to update.
+ protected void updateButtons() {
+ } // Do nothing. No buttons to update.
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java
index 1e9f8ef160c..f88e9826e78 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java
@@ -36,8 +36,8 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
* @noextend This class is not intended to be subclassed by clients.
*/
public class SymbolDialog extends AbstractPropertyDialog {
- private String data1;
- private String data2;
+ private String data1;
+ private String data2;
private Button b_add2conf;
private Button b_add2lang;
private Text txt1;
@@ -48,9 +48,8 @@ public class SymbolDialog extends AbstractPropertyDialog {
private boolean newAction;
private ICResourceDescription cfgd;
- public SymbolDialog(Shell parent, boolean _newAction,
- String title, String _data1, String _data2,
- ICResourceDescription _cfgd) {
+ public SymbolDialog(Shell parent, boolean _newAction, String title, String _data1, String _data2,
+ ICResourceDescription _cfgd) {
super(parent, title);
data1 = _data1;
data2 = _data2;
@@ -76,7 +75,8 @@ public class SymbolDialog extends AbstractPropertyDialog {
@Override
public void modifyText(ModifyEvent e) {
setButtons();
- }});
+ }
+ });
Label l2 = new Label(c, SWT.NONE);
l2.setText(Messages.SymbolDialog_1);
@@ -91,7 +91,8 @@ public class SymbolDialog extends AbstractPropertyDialog {
@Override
public void modifyText(ModifyEvent e) {
setButtons();
- }});
+ }
+ });
b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME);
@@ -149,7 +150,8 @@ public class SymbolDialog extends AbstractPropertyDialog {
shell.dispose();
} else if (e.widget.equals(b_vars)) {
String s = AbstractCPropertyTab.getVariableDialog(shell, cfgd.getConfiguration());
- if (s != null) txt2.insert(s);
+ if (s != null)
+ txt2.insert(s);
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java
index b1b92519413..ee6940923f8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java
@@ -58,10 +58,9 @@ public class SymbolTab extends AbstractLangsListTab {
@Override
public ICLanguageSettingEntry doAdd() {
- SymbolDialog dlg = new SymbolDialog(
- usercomp.getShell(), true,
- Messages.SymbolTab_2, EMPTY_STR, EMPTY_STR, getResDesc());
- if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ SymbolDialog dlg = new SymbolDialog(usercomp.getShell(), true, Messages.SymbolTab_2, EMPTY_STR, EMPTY_STR,
+ getResDesc());
+ if (dlg.open() && dlg.text1.trim().length() > 0) {
toAllCfgs = dlg.check1;
toAllLang = dlg.check3;
return CDataUtil.createCMacroEntry(dlg.text1, dlg.text2, 0);
@@ -71,9 +70,7 @@ public class SymbolTab extends AbstractLangsListTab {
@Override
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
- SymbolDialog dlg = new SymbolDialog(
- usercomp.getShell(), false,
- Messages.SymbolTab_3, ent.getName(),
+ SymbolDialog dlg = new SymbolDialog(usercomp.getShell(), false, Messages.SymbolTab_3, ent.getName(),
ent.getValue(), getResDesc());
if (dlg.open())
return CDataUtil.createCMacroEntry(dlg.text1, dlg.text2, 0);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java
index c3f5095707d..aa092fe34cd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java
@@ -18,21 +18,25 @@ import org.eclipse.jface.viewers.ViewerFilter;
/**
* see org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
public class TypedCDTViewerFilter extends ViewerFilter {
private Class<?>[] types;
- public TypedCDTViewerFilter(Class<?>[] _types) { types= _types; }
+ public TypedCDTViewerFilter(Class<?>[] _types) {
+ types = _types;
+ }
+
/**
* @see ViewerFilter#select
*/
@Override
public boolean select(Viewer viewer, Object parent, Object element) {
for (Class<?> type : types) {
- if (type.isInstance(element)) return true;
+ if (type.isInstance(element))
+ return true;
}
return false;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java
index 17a7462c5d0..acf675a8309 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
@@ -42,6 +42,7 @@ public class UIMessages {
private static String toNlsFormatKey(String key) {
return key.replace('.', '_');
}
+
public static String getFormattedString(String key, String arg) {
key = toNlsFormatKey(key);
return MessageFormat.format(getString(key), new Object[] { arg });
@@ -49,7 +50,7 @@ public class UIMessages {
public static String getFormattedString(String key, String[] args) {
key = toNlsFormatKey(key);
- return MessageFormat.format(getString(key), (Object[])args);
+ return MessageFormat.format(getString(key), (Object[]) args);
}
public static String getString(String key) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java
index 0d35c956b63..f6564df7ef7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java
@@ -36,73 +36,73 @@ import org.eclipse.cdt.internal.ui.refactoring.changes.UndoCTextFileChange;
/**
* A TextFileChange that uses a working copy in order to generate CModel events.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
public class CTextFileChange extends TextFileChange {
- // "c2" is the extension which the CContentViewerCreator is registered
- // with the extension point "org.eclipse.compare.contentMergeViewers"
- private static final String TEXT_TYPE = "c2"; //$NON-NLS-1$
+ // "c2" is the extension which the CContentViewerCreator is registered
+ // with the extension point "org.eclipse.compare.contentMergeViewers"
+ private static final String TEXT_TYPE = "c2"; //$NON-NLS-1$
private ITranslationUnit fTranslationUnit;
- private IWorkingCopy fWorkingCopy;
- private int fAcquireCount;
-
- public CTextFileChange(String name, IFile file) {
- super(name, file);
- ICElement element = CoreModel.getDefault().create(file);
- if (element instanceof ITranslationUnit) {
- fTranslationUnit = (ITranslationUnit) element;
- setTextType(TEXT_TYPE);
- }
- }
-
- /**
+ private IWorkingCopy fWorkingCopy;
+ private int fAcquireCount;
+
+ public CTextFileChange(String name, IFile file) {
+ super(name, file);
+ ICElement element = CoreModel.getDefault().create(file);
+ if (element instanceof ITranslationUnit) {
+ fTranslationUnit = (ITranslationUnit) element;
+ setTextType(TEXT_TYPE);
+ }
+ }
+
+ /**
* @since 5.1
*/
- public CTextFileChange(String name, ITranslationUnit tu) {
- super(name, tu.getFile());
- fTranslationUnit = tu;
- if (tu instanceof IWorkingCopy)
- fWorkingCopy = (IWorkingCopy) tu;
- setTextType(TEXT_TYPE);
- }
+ public CTextFileChange(String name, ITranslationUnit tu) {
+ super(name, tu.getFile());
+ fTranslationUnit = tu;
+ if (tu instanceof IWorkingCopy)
+ fWorkingCopy = (IWorkingCopy) tu;
+ setTextType(TEXT_TYPE);
+ }
- @Override
+ @Override
protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException {
- IDocument doc= super.acquireDocument(pm);
- if (++fAcquireCount == 1) {
- if (fWorkingCopy == null && fTranslationUnit instanceof TranslationUnit) {
- fWorkingCopy= ((TranslationUnit) fTranslationUnit).getWorkingCopy(null, DocumentAdapter.FACTORY);
- if (!fTranslationUnit.isOpen()) {
- fTranslationUnit.open(null);
- }
- }
- }
- return doc;
- }
-
- @Override
+ IDocument doc = super.acquireDocument(pm);
+ if (++fAcquireCount == 1) {
+ if (fWorkingCopy == null && fTranslationUnit instanceof TranslationUnit) {
+ fWorkingCopy = ((TranslationUnit) fTranslationUnit).getWorkingCopy(null, DocumentAdapter.FACTORY);
+ if (!fTranslationUnit.isOpen()) {
+ fTranslationUnit.open(null);
+ }
+ }
+ }
+ return doc;
+ }
+
+ @Override
protected void commit(final IDocument document, final IProgressMonitor pm) throws CoreException {
- if (fWorkingCopy == null) {
- super.commit(document, pm);
- } else if (needsSaving()) {
- fWorkingCopy.commit(false, pm);
- }
- }
-
- @Override
+ if (fWorkingCopy == null) {
+ super.commit(document, pm);
+ } else if (needsSaving()) {
+ fWorkingCopy.commit(false, pm);
+ }
+ }
+
+ @Override
protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException {
- super.releaseDocument(document, pm);
- if (--fAcquireCount == 0) {
- if (fWorkingCopy != null && fWorkingCopy != fTranslationUnit) {
- fWorkingCopy.destroy();
- fWorkingCopy= null;
- }
- }
- }
+ super.releaseDocument(document, pm);
+ if (--fAcquireCount == 0) {
+ if (fWorkingCopy != null && fWorkingCopy != fTranslationUnit) {
+ fWorkingCopy.destroy();
+ fWorkingCopy = null;
+ }
+ }
+ }
- @Override
+ @Override
protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) {
- return new UndoCTextFileChange(getName(), getFile(), edit, stampToRestore, getSaveMode());
- }
+ return new UndoCTextFileChange(getName(), getFile(), edit, stampToRestore, getSaveMode());
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java
index 2937398976a..ab1f79f5ee8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java
@@ -10,7 +10,7 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
- * Markus Schorn, Wind River Systems Inc. - ported for rename refactoring impl.
+ * Markus Schorn, Wind River Systems Inc. - ported for rename refactoring impl.
*******************************************************************************/
package org.eclipse.cdt.ui.refactoring.actions;
@@ -42,167 +42,165 @@ import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
/**
* Action group that adds refactoring actions (for example Rename..., Move..., etc)
* to a context menu and the global menu bar.
- *
+ *
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
- *
+ *
* @since 2.0
* @noextend This class is not intended to be subclassed by clients.
*/
public class CRefactoringActionGroup extends ActionGroup implements ISelectionChangedListener {
- /**
- * Pop-up menu: id of the refactor sub menu (value <code>org.eclipse.cdt.ui.refactoring.menu</code>).
- *
- * @since 2.1
- */
- public static final String MENU_ID = "org.eclipse.cdt.ui.refactoring.menu"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: id of the reorg group of the refactor sub menu (value
- * <code>reorgGroup</code>).
- *
- * @since 2.1
- */
- public static final String GROUP_REORG = "reorgGroup"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: id of the type group of the refactor sub menu (value
- * <code>typeGroup</code>).
- *
- * @since 2.1
- */
- public static final String GROUP_TYPE = "typeGroup"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: id of the coding group of the refactor sub menu (value
- * <code>codingGroup</code>).
- *
- * @since 2.1
- */
- public static final String GROUP_CODING = "codingGroup"; //$NON-NLS-1$
-
+ /**
+ * Pop-up menu: id of the refactor sub menu (value <code>org.eclipse.cdt.ui.refactoring.menu</code>).
+ *
+ * @since 2.1
+ */
+ public static final String MENU_ID = "org.eclipse.cdt.ui.refactoring.menu"; //$NON-NLS-1$
+
+ /**
+ * Pop-up menu: id of the reorg group of the refactor sub menu (value
+ * <code>reorgGroup</code>).
+ *
+ * @since 2.1
+ */
+ public static final String GROUP_REORG = "reorgGroup"; //$NON-NLS-1$
+
+ /**
+ * Pop-up menu: id of the type group of the refactor sub menu (value
+ * <code>typeGroup</code>).
+ *
+ * @since 2.1
+ */
+ public static final String GROUP_TYPE = "typeGroup"; //$NON-NLS-1$
+
+ /**
+ * Pop-up menu: id of the coding group of the refactor sub menu (value
+ * <code>codingGroup</code>).
+ *
+ * @since 2.1
+ */
+ public static final String GROUP_CODING = "codingGroup"; //$NON-NLS-1$
+
/**
* Pop-up menu: id of the coding group 2 of the refactor sub menu (value
* <code>codingGroup2</code>).
- *
+ *
* @since 5.0
*/
- public static final String GROUP_CODING2= "codingGroup2"; //$NON-NLS-1$
+ public static final String GROUP_CODING2 = "codingGroup2"; //$NON-NLS-1$
/**
* Pop-up menu: id of the reorg group 2 of the refactor sub menu (value
* <code>reorgGroup2</code>).
- *
+ *
* @since 5.0
*/
- public static final String GROUP_REORG2= "reorgGroup2"; //$NON-NLS-1$
-
+ public static final String GROUP_REORG2 = "reorgGroup2"; //$NON-NLS-1$
+
/**
* Pop-up menu: id of the type group 2 of the refactor sub menu (value
* <code>typeGroup2</code>).
- *
+ *
* @since 5.0
*/
- public static final String GROUP_TYPE2= "typeGroup2"; //$NON-NLS-1$
-
+ public static final String GROUP_TYPE2 = "typeGroup2"; //$NON-NLS-1$
+
/**
* Pop-up menu: id of the type group 2 of the refactor sub menu (value
* <code>typeGroup3</code>).
- *
+ *
* @since 5.0
*/
- public static final String GROUP_TYPE3= "typeGroup3"; //$NON-NLS-1$
+ public static final String GROUP_TYPE3 = "typeGroup3"; //$NON-NLS-1$
- private String fGroupName= IWorkbenchActionConstants.GROUP_REORGANIZE;
- private CRenameAction fRenameAction;
- private RefactoringAction fExtractConstantAction;
- private RefactoringAction fExtractLocalVariableAction;
- private RefactoringAction fExtractFunctionAction;
+ private String fGroupName = IWorkbenchActionConstants.GROUP_REORGANIZE;
+ private CRenameAction fRenameAction;
+ private RefactoringAction fExtractConstantAction;
+ private RefactoringAction fExtractLocalVariableAction;
+ private RefactoringAction fExtractFunctionAction;
private RefactoringAction fToggleFunctionAction;
- private RefactoringAction fHideMethodAction;
+ private RefactoringAction fHideMethodAction;
private IWorkbenchSite fSite;
- private List<RefactoringAction> fAllActions= new ArrayList<RefactoringAction>();
-
- public CRefactoringActionGroup(IWorkbenchPart part) {
- this(part, null);
- }
-
- public CRefactoringActionGroup(Page page) {
- createActions(false);
- setWorkbenchSite(page.getSite());
- }
-
- public CRefactoringActionGroup(IWorkbenchPart part, String groupName) {
- if (groupName != null && groupName.length() > 0) {
- fGroupName= groupName;
- }
- createActions(part instanceof ITextEditor);
-
- if (part instanceof ITextEditor) {
- setEditor((ITextEditor) part);
- }
- else {
- setWorkbenchSite(part.getSite());
- }
- }
+ private List<RefactoringAction> fAllActions = new ArrayList<RefactoringAction>();
+
+ public CRefactoringActionGroup(IWorkbenchPart part) {
+ this(part, null);
+ }
+
+ public CRefactoringActionGroup(Page page) {
+ createActions(false);
+ setWorkbenchSite(page.getSite());
+ }
+
+ public CRefactoringActionGroup(IWorkbenchPart part, String groupName) {
+ if (groupName != null && groupName.length() > 0) {
+ fGroupName = groupName;
+ }
+ createActions(part instanceof ITextEditor);
+
+ if (part instanceof ITextEditor) {
+ setEditor((ITextEditor) part);
+ } else {
+ setWorkbenchSite(part.getSite());
+ }
+ }
private void createActions(boolean forEditor) {
fRenameAction = new CRenameAction();
- fRenameAction.setActionDefinitionId(ICEditorActionDefinitionIds.RENAME_ELEMENT);
- fAllActions.add(fRenameAction);
-
- if (forEditor) {
- fExtractConstantAction= new ExtractConstantAction();
- fExtractConstantAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_CONSTANT);
- fAllActions.add(fExtractConstantAction);
-
- fExtractLocalVariableAction= new ExtractLocalVariableAction();
- fExtractLocalVariableAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_LOCAL_VARIABLE);
- fAllActions.add(fExtractLocalVariableAction);
-
- fExtractFunctionAction = new ExtractFunctionAction();
+ fRenameAction.setActionDefinitionId(ICEditorActionDefinitionIds.RENAME_ELEMENT);
+ fAllActions.add(fRenameAction);
+
+ if (forEditor) {
+ fExtractConstantAction = new ExtractConstantAction();
+ fExtractConstantAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_CONSTANT);
+ fAllActions.add(fExtractConstantAction);
+
+ fExtractLocalVariableAction = new ExtractLocalVariableAction();
+ fExtractLocalVariableAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_LOCAL_VARIABLE);
+ fAllActions.add(fExtractLocalVariableAction);
+
+ fExtractFunctionAction = new ExtractFunctionAction();
fExtractFunctionAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_FUNCTION);
fAllActions.add(fExtractFunctionAction);
fToggleFunctionAction = new ToggleFunctionAction();
fToggleFunctionAction.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_FUNCTION);
fAllActions.add(fToggleFunctionAction);
- }
+ }
- fHideMethodAction = new HideMethodAction();
- fHideMethodAction.setActionDefinitionId(ICEditorActionDefinitionIds.HIDE_METHOD);
- fAllActions.add(fHideMethodAction);
+ fHideMethodAction = new HideMethodAction();
+ fHideMethodAction.setActionDefinitionId(ICEditorActionDefinitionIds.HIDE_METHOD);
+ fAllActions.add(fHideMethodAction);
}
- public void setWorkbenchSite(IWorkbenchSite site) {
+ public void setWorkbenchSite(IWorkbenchSite site) {
unregisterSite();
- fSite= site;
-
- for (RefactoringAction action : fAllActions) {
+ fSite = site;
+
+ for (RefactoringAction action : fAllActions) {
action.setSite(site);
- }
- final ISelectionProvider sp = fSite.getSelectionProvider();
- sp.addSelectionChangedListener(this);
- updateActions(sp.getSelection());
- }
+ }
+ final ISelectionProvider sp = fSite.getSelectionProvider();
+ sp.addSelectionChangedListener(this);
+ updateActions(sp.getSelection());
+ }
private void unregisterSite() {
if (fSite != null) {
- fSite.getSelectionProvider().removeSelectionChangedListener(this);
- fSite= null;
- }
+ fSite.getSelectionProvider().removeSelectionChangedListener(this);
+ fSite = null;
+ }
}
-
+
public void setEditor(ITextEditor textEditor) {
unregisterSite();
-
- for (RefactoringAction action : fAllActions) {
- action.setEditor(textEditor);
- }
- }
+ for (RefactoringAction action : fAllActions) {
+ action.setEditor(textEditor);
+ }
+ }
@Override
public void fillActionBars(IActionBars actionBar) {
@@ -212,7 +210,7 @@ public class CRefactoringActionGroup extends ActionGroup implements ISelectionCh
setActionHandler(actionBar, CdtActionConstants.EXTRACT_LOCAL_VARIABLE, fExtractLocalVariableAction);
setActionHandler(actionBar, CdtActionConstants.EXTRACT_METHOD, fExtractFunctionAction);
setActionHandler(actionBar, CdtActionConstants.TOGGLE_FUNCTION, fToggleFunctionAction);
- setActionHandler(actionBar, CdtActionConstants.HIDE_METHOD, fHideMethodAction);
+ setActionHandler(actionBar, CdtActionConstants.HIDE_METHOD, fHideMethodAction);
}
private void setActionHandler(IActionBars actionBar, String id, RefactoringAction action) {
@@ -220,23 +218,23 @@ public class CRefactoringActionGroup extends ActionGroup implements ISelectionCh
actionBar.setGlobalActionHandler(id, action);
}
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- @Override
+ /* (non-Javadoc)
+ * Method declared in ActionGroup
+ */
+ @Override
public void fillContextMenu(IMenuManager menu) {
- updateActionBars();
-
- boolean needMenu= false;
- for (RefactoringAction action : fAllActions) {
+ updateActionBars();
+
+ boolean needMenu = false;
+ for (RefactoringAction action : fAllActions) {
if (action.isEnabled()) {
- needMenu= true;
+ needMenu = true;
break;
}
- }
+ }
if (needMenu) {
- IMenuManager refactorSubmenu = new MenuManager(Messages.CRefactoringActionGroup_menu, MENU_ID);
+ IMenuManager refactorSubmenu = new MenuManager(Messages.CRefactoringActionGroup_menu, MENU_ID);
refactorSubmenu.add(new Separator(GROUP_REORG));
addAction(refactorSubmenu, fRenameAction);
refactorSubmenu.add(new Separator(GROUP_CODING));
@@ -250,10 +248,10 @@ public class CRefactoringActionGroup extends ActionGroup implements ISelectionCh
refactorSubmenu.add(new Separator(GROUP_TYPE2));
refactorSubmenu.add(new Separator(GROUP_CODING2));
refactorSubmenu.add(new Separator(GROUP_TYPE3));
-
+
menu.appendToGroup(fGroupName, refactorSubmenu);
}
- }
+ }
private void addAction(IMenuManager refactorSubmenu, RefactoringAction action) {
if (action != null && action.isEnabled()) {
@@ -263,9 +261,9 @@ public class CRefactoringActionGroup extends ActionGroup implements ISelectionCh
private ICElement getCElement(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) selection;
+ IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
- Object o= ss.getFirstElement();
+ Object o = ss.getFirstElement();
if (o instanceof ICElement && o instanceof ISourceReference) {
return (ICElement) o;
}
@@ -275,11 +273,11 @@ public class CRefactoringActionGroup extends ActionGroup implements ISelectionCh
}
private void updateActions(ISelection selection) {
- ICElement celem= getCElement(selection);
+ ICElement celem = getCElement(selection);
for (RefactoringAction action : fAllActions) {
action.updateSelection(celem);
}
- }
+ }
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionGroup#dispose()
@@ -287,7 +285,7 @@ public class CRefactoringActionGroup extends ActionGroup implements ISelectionCh
@Override
public void dispose() {
unregisterSite();
- fSite= null;
+ fSite = null;
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java
index 796a3047548..14587b88937 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 Wind River Systems, Inc.
+ * Copyright (c) 2005, 2012 Wind River Systems, Inc.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- * Sergey Prigogin (Google)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.ui.refactoring.actions;
@@ -32,15 +32,15 @@ import org.eclipse.cdt.internal.ui.refactoring.rename.RenameLinkedMode;
/**
* Launches a rename refactoring.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
- */
+ */
public class CRenameAction extends RefactoringAction {
-
- public CRenameAction() {
- super(Messages.CRenameAction_label);
- }
-
+
+ public CRenameAction() {
+ super(Messages.CRenameAction_label);
+ }
+
@Override
public void run(IShellProvider shellProvider, ICElement elem) {
if (!ActionUtil.isEditable(fEditor, shellProvider.getShell(), elem))
@@ -52,8 +52,8 @@ public class CRenameAction extends RefactoringAction {
public void run(IShellProvider shellProvider, IWorkingCopy workingCopy, ITextSelection selection) {
if (!ActionUtil.isEditable(fEditor))
return;
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- boolean lightweight= store.getBoolean(PreferenceConstants.REFACTOR_LIGHTWEIGHT);
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ boolean lightweight = store.getBoolean(PreferenceConstants.REFACTOR_LIGHTWEIGHT);
if (lightweight) {
new RenameLinkedMode(fEditor).start();
} else {
@@ -61,13 +61,13 @@ public class CRenameAction extends RefactoringAction {
}
}
- @Override
+ @Override
public void updateSelection(ICElement elem) {
- super.updateSelection(elem);
- if (elem == null || elem instanceof IInclude || elem instanceof ITranslationUnit) {
- setEnabled(false);
- } else {
- setEnabled(true);
- }
- }
+ super.updateSelection(elem);
+ if (elem == null || elem instanceof IInclude || elem instanceof ITranslationUnit) {
+ setEnabled(false);
+ } else {
+ setEnabled(true);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java
index 4ef212faab9..726adeaaef7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 Wind River Systems, Inc.
+ * Copyright (c) 2005, 2012 Wind River Systems, Inc.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -24,15 +24,15 @@ import org.eclipse.cdt.internal.ui.refactoring.extractconstant.ExtractConstantRe
/**
* Launches an Extract Constant refactoring.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
- */
+ */
public class ExtractConstantAction extends RefactoringAction {
-
- public ExtractConstantAction() {
- super(Messages.ExtractConstantAction_label);
- }
-
+
+ public ExtractConstantAction() {
+ super(Messages.ExtractConstantAction_label);
+ }
+
@Override
public void run(IShellProvider shellProvider, ICElement elem) {
}
@@ -44,9 +44,9 @@ public class ExtractConstantAction extends RefactoringAction {
}
}
- @Override
+ @Override
public void updateSelection(ICElement elem) {
- super.updateSelection(elem);
- setEnabled(false);
- }
+ super.updateSelection(elem);
+ setEnabled(false);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java
index 524f3efa182..5ae37a7ffc3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software (IFS)- initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software (IFS)- initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
package org.eclipse.cdt.ui.refactoring.actions;
@@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRe
/**
* Launches an Extract Function refactoring.
- *
+ *
* @since 5.0
* @noextend This class is not intended to be subclassed by clients.
* @author Emanuel Graf IFS
@@ -47,7 +47,7 @@ public class ExtractFunctionAction extends RefactoringAction {
}
}
- @Override
+ @Override
public void updateSelection(ICElement elem) {
super.updateSelection(elem);
setEnabled(false);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java
index 6d2a78856b5..9f81ffbb10b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 Wind River Systems, Inc.
+ * Copyright (c) 2005, 2012 Wind River Systems, Inc.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -26,13 +26,13 @@ import org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocal
* Launches an Extract Local Variable refactoring.
* @since 5.1
* @noextend This class is not intended to be subclassed by clients.
- */
+ */
public class ExtractLocalVariableAction extends RefactoringAction {
-
- public ExtractLocalVariableAction() {
- super(Messages.ExtractLocalVariableAction_label);
- }
-
+
+ public ExtractLocalVariableAction() {
+ super(Messages.ExtractLocalVariableAction_label);
+ }
+
@Override
public void run(IShellProvider shellProvider, ICElement elem) {
}
@@ -44,9 +44,9 @@ public class ExtractLocalVariableAction extends RefactoringAction {
}
}
- @Override
+ @Override
public void updateSelection(ICElement elem) {
- super.updateSelection(elem);
- setEnabled(false);
- }
+ super.updateSelection(elem);
+ setEnabled(false);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java
index 2297a558247..005d92a1325 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
+ * SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -29,14 +29,14 @@ import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GenerateGetters
/**
* Launches a getter and setter source code generation.
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
- */
+ */
public class GettersAndSettersAction extends RefactoringAction {
- public GettersAndSettersAction() {
- super(Messages.GettersAndSetters_label);
- }
+ public GettersAndSettersAction() {
+ super(Messages.GettersAndSetters_label);
+ }
/**
* @since 5.1
@@ -58,12 +58,12 @@ public class GettersAndSettersAction extends RefactoringAction {
}
}
- @Override
+ @Override
public void updateSelection(ICElement elem) {
- super.updateSelection(elem);
- if (!(elem instanceof IField) || !(elem instanceof ISourceReference) ||
- !(((ISourceReference) elem).getTranslationUnit().getResource() instanceof IFile)) {
- setEnabled(false);
- }
- }
+ super.updateSelection(elem);
+ if (!(elem instanceof IField) || !(elem instanceof ISourceReference)
+ || !(((ISourceReference) elem).getTranslationUnit().getResource() instanceof IFile)) {
+ setEnabled(false);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java
index 63dbe87940a..93818f35fae 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -28,15 +28,15 @@ import org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoringR
/**
* Launches a Hide Method refactoring
* @author Guido Zgraggen IFS
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
public class HideMethodAction extends RefactoringAction {
-
- public HideMethodAction() {
- super(Messages.HideMethodAction_label);
- }
-
+
+ public HideMethodAction() {
+ super(Messages.HideMethodAction_label);
+ }
+
@Override
public void run(IShellProvider shellProvider, ICElement elem) {
if (elem instanceof ISourceReference) {
@@ -51,12 +51,12 @@ public class HideMethodAction extends RefactoringAction {
}
}
- @Override
+ @Override
public void updateSelection(ICElement elem) {
- super.updateSelection(elem);
- if (!(elem instanceof IMethodDeclaration) || !(elem instanceof ISourceReference) ||
- ((ISourceReference) elem).getTranslationUnit().getResource() == null) {
- setEnabled(false);
- }
- }
+ super.updateSelection(elem);
+ if (!(elem instanceof IMethodDeclaration) || !(elem instanceof ISourceReference)
+ || ((ISourceReference) elem).getTranslationUnit().getResource() == null) {
+ setEnabled(false);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java
index 09d13ad7197..ecb099825ab 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
@@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.ui.refactoring.implementmethod.ImplementMethodRe
/**
* Launches the implement method source generator (refactoring).
- *
+ *
* @author Lukas Felber
* @noextend This class is not intended to be subclassed by clients.
*/
@@ -64,11 +64,11 @@ public class ImplementMethodAction extends RefactoringAction {
@Override
public void updateSelection(ICElement elem) {
- super.updateSelection(elem);
- if (elem instanceof IMethod || elem instanceof IMethodDeclaration == false
- || elem instanceof ISourceReference == false
- || ((ISourceReference) elem).getTranslationUnit().getResource() instanceof IFile == false) {
- setEnabled(false);
- }
- }
+ super.updateSelection(elem);
+ if (elem instanceof IMethod || elem instanceof IMethodDeclaration == false
+ || elem instanceof ISourceReference == false
+ || ((ISourceReference) elem).getTranslationUnit().getResource() instanceof IFile == false) {
+ setEnabled(false);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java
index 65e1c576122..a08dd04d548 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java
@@ -34,8 +34,8 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.EclipseObjects;
* @noextend This class is not intended to be subclassed by clients.
*/
public abstract class RefactoringAction extends Action {
- protected CEditor fEditor;
- private IWorkbenchSite fSite;
+ protected CEditor fEditor;
+ private IWorkbenchSite fSite;
private ICElement fElement;
private boolean saveRequired;
@@ -55,48 +55,50 @@ public abstract class RefactoringAction extends Action {
this.saveRequired = saveRequired;
}
- public void setEditor(IEditorPart editor) {
- fEditor= null;
- fSite= null;
- if (editor instanceof CEditor) {
- fEditor= (CEditor) editor;
- }
- setEnabled(fEditor != null);
- }
+ public void setEditor(IEditorPart editor) {
+ fEditor = null;
+ fSite = null;
+ if (editor instanceof CEditor) {
+ fEditor = (CEditor) editor;
+ }
+ setEnabled(fEditor != null);
+ }
public void setSite(IWorkbenchSite site) {
- fEditor= null;
- fSite= site;
+ fEditor = null;
+ fSite = site;
}
- @Override
+ @Override
public final void run() {
- if (saveRequired) {
- EclipseObjects.getActivePage().saveAllEditors(true);
- if (EclipseObjects.getActivePage().getDirtyEditors().length != 0) {
- return;
- }
- }
- if (fEditor != null) {
- ISelectionProvider provider= fEditor.getSelectionProvider();
- if (provider != null) {
- ISelection s= provider.getSelection();
- if (s instanceof ITextSelection) {
- IWorkingCopy wc= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
- if (wc != null)
- run(fEditor.getSite(), wc, (ITextSelection) s);
- }
- }
- } else if (fSite != null && fElement != null) {
- run(fSite, fElement);
- }
- }
+ if (saveRequired) {
+ EclipseObjects.getActivePage().saveAllEditors(true);
+ if (EclipseObjects.getActivePage().getDirtyEditors().length != 0) {
+ return;
+ }
+ }
+ if (fEditor != null) {
+ ISelectionProvider provider = fEditor.getSelectionProvider();
+ if (provider != null) {
+ ISelection s = provider.getSelection();
+ if (s instanceof ITextSelection) {
+ IWorkingCopy wc = CUIPlugin.getDefault().getWorkingCopyManager()
+ .getWorkingCopy(fEditor.getEditorInput());
+ if (wc != null)
+ run(fEditor.getSite(), wc, (ITextSelection) s);
+ }
+ }
+ } else if (fSite != null && fElement != null) {
+ run(fSite, fElement);
+ }
+ }
public void updateSelection(ICElement elem) {
- fElement= elem;
+ fElement = elem;
setEnabled(elem != null);
}
- public abstract void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s);
- public abstract void run(IShellProvider shellProvider, ICElement elem);
+ public abstract void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s);
+
+ public abstract void run(IShellProvider shellProvider, ICElement elem);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.java
index 5cb6fc4ed2f..35847faa278 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software (IFS)- initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.ui.refactoring.togglefunction.ToggleRefactoringR
/**
* @since 5.3
* @author Emanuel Graf IFS
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
*/
public class ToggleFunctionAction extends RefactoringAction {
@@ -55,7 +55,7 @@ public class ToggleFunctionAction extends RefactoringAction {
new ToggleRefactoringRunner(wc, selection, shellProvider, wc.getCProject()).run();
}
- @Override
+ @Override
public void updateSelection(ICElement elem) {
super.updateSelection(elem);
setEnabled(false);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/Messages.java
index 22747482e89..f886324d494 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/Messages.java
@@ -26,7 +26,7 @@ public class Messages extends NLS {
public static String RefreshPolicyExceptionDialog_SelectResourceDialogMessage;
public static String RefreshPolicyExceptionDialog_SelectResourceDialogTitle;
public static String RefreshPolicyExceptionDialog_deleteButtonLabel;
-
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager.java
index d4a76945d36..630c50c6224 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -29,10 +29,10 @@ import org.eclipse.cdt.ui.CUIPlugin;
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
- *
+ *
* @author crecoskie
* @since 5.3
- *
+ *
*/
public class RefreshExclusionContributionManager {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributor.java
index 7bfe80f4cd2..00dc8143237 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributor.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -21,10 +21,10 @@ import org.eclipse.cdt.core.resources.RefreshExclusion;
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
- *
+ *
* @author crecoskie
* @since 5.3
- *
+ *
*/
public abstract class RefreshExclusionContributor {
@@ -36,7 +36,7 @@ public abstract class RefreshExclusionContributor {
/**
* Creates the UI that allows user to modify the given RefreshExclusion
- *
+ *
* @param parent
* - the parent composite to contain the UI
* @param exclusion
@@ -50,7 +50,7 @@ public abstract class RefreshExclusionContributor {
/**
* Returns the human-readable name of this exclusion type.
- *
+ *
* @return String.
*/
public String getName() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java
index c536a233200..d06d341cc5c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -33,26 +33,26 @@ import org.eclipse.cdt.ui.IPropertyChangeParticipant;
* <p>
* Clients may instantiate and extend this class.
* </p>
- *
+ *
* @since 5.1
*/
public abstract class AbstractCScanner extends BufferedRuleBasedScanner implements ICTokenScanner {
private List<IPropertyChangeParticipant> fParticipants;
final protected ITokenStore fTokenStore;
-
+
/**
* Create a new scanner for the given token store with default buffer size.
- *
+ *
* @param tokenStore
*/
public AbstractCScanner(ITokenStore tokenStore) {
- fTokenStore= tokenStore;
- fParticipants= new ArrayList<IPropertyChangeParticipant>();
+ fTokenStore = tokenStore;
+ fParticipants = new ArrayList<IPropertyChangeParticipant>();
}
-
+
/**
* Create a new scanner for the given token store and buffer size.
- *
+ *
* @param tokenStore
* @param size
*/
@@ -60,23 +60,23 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen
this(tokenStore);
setBufferSize(size);
}
-
+
protected void addPropertyChangeParticipant(IPropertyChangeParticipant participant) {
fParticipants.add(participant);
}
-
+
/**
* Convenience method for setting the scanner rules with a list rather
* than an array.
* @param rules
*/
public final void setRules(List<IRule> rules) {
- if(rules==null) {
- setRules((IRule[])null);
+ if (rules == null) {
+ setRules((IRule[]) null);
} else {
- IRule[] result= new IRule[rules.size()];
+ IRule[] result = new IRule[rules.size()];
rules.toArray(result);
- setRules(result);
+ setRules(result);
}
}
@@ -88,11 +88,11 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen
fTokenStore.ensureTokensInitialised();
return super.nextToken();
}
-
+
public IToken getToken(String key) {
return fTokenStore.getToken(key);
}
-
+
public IPreferenceStore getPreferenceStore() {
return fTokenStore.getPreferenceStore();
}
@@ -102,7 +102,7 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen
*/
@Override
public void adaptToPreferenceChange(PropertyChangeEvent event) {
- if(fTokenStore.affectsBehavior(event)) {
+ if (fTokenStore.affectsBehavior(event)) {
fTokenStore.adaptToPreferenceChange(event);
}
for (IPropertyChangeParticipant propertyChangeParticipant : fParticipants) {
@@ -115,8 +115,8 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen
*/
@Override
public boolean affectsBehavior(PropertyChangeEvent event) {
- boolean result= fTokenStore.affectsBehavior(event);
- for(Iterator<IPropertyChangeParticipant> i= fParticipants.iterator(); !result && i.hasNext(); ) {
+ boolean result = fTokenStore.affectsBehavior(event);
+ for (Iterator<IPropertyChangeParticipant> i = fParticipants.iterator(); !result && i.hasNext();) {
result |= (i.next()).affectsBehavior(event);
}
return result;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java
index eb34b9f767c..932829a8b32 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.text;
-
import java.util.Map;
import org.eclipse.core.resources.IFile;
@@ -65,7 +64,7 @@ import org.eclipse.cdt.internal.ui.text.TokenStore;
* </p>
*
* @noextend This class is not intended to be subclassed by clients.
- *
+ *
* @since 5.1
*/
public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration {
@@ -99,7 +98,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
* The document partitioning.
*/
private String fDocumentPartitioning;
-
+
/**
* Creates a new assembly source viewer configuration for viewers in the given editor
* using the given preference store, the color manager and the specified document partitioning.
@@ -109,11 +108,12 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
* @param editor the editor in which the configured viewer(s) will reside, or <code>null</code> if none
* @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
*/
- public AsmSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
+ public AsmSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore,
+ ITextEditor editor, String partitioning) {
super(preferenceStore);
- fColorManager= colorManager;
- fTextEditor= editor;
- fDocumentPartitioning= partitioning;
+ fColorManager = colorManager;
+ fTextEditor = editor;
+ fDocumentPartitioning = partitioning;
initializeScanners();
}
@@ -121,9 +121,9 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
* Initializes the scanners.
*/
private void initializeScanners() {
- fMultilineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT);
- fSinglelineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT);
- fStringScanner= new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
+ fMultilineCommentScanner = new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT);
+ fSinglelineCommentScanner = new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT);
+ fStringScanner = new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
}
/**
@@ -134,7 +134,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
public RuleBasedScanner getMultilineCommentScanner() {
return fMultilineCommentScanner;
}
-
+
/**
* Returns the ASM singleline comment scanner for this configuration.
*
@@ -143,7 +143,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
public RuleBasedScanner getSinglelineCommentScanner() {
return fSinglelineCommentScanner;
}
-
+
/**
* Returns the ASM string scanner for this configuration.
*
@@ -163,14 +163,14 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
if (fPreprocessorScanner != null) {
return fPreprocessorScanner;
}
- AbstractCScanner scanner= null;
+ AbstractCScanner scanner = null;
if (language instanceof IAsmLanguage) {
- scanner= new AsmPreprocessorScanner(getTokenStoreFactory(), (IAsmLanguage)language);
+ scanner = new AsmPreprocessorScanner(getTokenStoreFactory(), (IAsmLanguage) language);
}
if (scanner == null) {
- scanner= new AsmPreprocessorScanner(getTokenStoreFactory(), AssemblyLanguage.getDefault());
+ scanner = new AsmPreprocessorScanner(getTokenStoreFactory(), AssemblyLanguage.getDefault());
}
- fPreprocessorScanner= scanner;
+ fPreprocessorScanner = scanner;
return fPreprocessorScanner;
}
@@ -182,9 +182,9 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
if (fCodeScanner != null) {
return fCodeScanner;
}
- RuleBasedScanner scanner= null;
+ RuleBasedScanner scanner = null;
if (language instanceof IAsmLanguage) {
- IAsmLanguage asmLang= (IAsmLanguage)language;
+ IAsmLanguage asmLang = (IAsmLanguage) language;
scanner = new AsmCodeScanner(getTokenStoreFactory(), asmLang);
} else if (language != null) {
ILanguageUI languageUI = language.getAdapter(ILanguageUI.class);
@@ -195,7 +195,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
scanner = new AsmCodeScanner(getTokenStoreFactory(), AssemblyLanguage.getDefault());
}
if (scanner instanceof AbstractCScanner) {
- fCodeScanner= (AbstractCScanner)scanner;
+ fCodeScanner = (AbstractCScanner) scanner;
}
return scanner;
}
@@ -216,49 +216,45 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- PresentationReconciler reconciler= new PresentationReconciler();
+ PresentationReconciler reconciler = new PresentationReconciler();
- ILanguage language= getLanguage();
- DefaultDamagerRepairer dr= new DefaultDamagerRepairer(getCodeScanner(language));
+ ILanguage language = getLanguage();
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getCodeScanner(language));
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
- dr= new DefaultDamagerRepairer(getMultilineCommentScanner());
+ dr = new DefaultDamagerRepairer(getMultilineCommentScanner());
reconciler.setDamager(dr, ICPartitions.C_MULTI_LINE_COMMENT);
reconciler.setRepairer(dr, ICPartitions.C_MULTI_LINE_COMMENT);
-
- dr= new DefaultDamagerRepairer(getSinglelineCommentScanner());
+
+ dr = new DefaultDamagerRepairer(getSinglelineCommentScanner());
reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
- dr= new DefaultDamagerRepairer(getStringScanner());
+ dr = new DefaultDamagerRepairer(getStringScanner());
reconciler.setDamager(dr, ICPartitions.C_STRING);
reconciler.setRepairer(dr, ICPartitions.C_STRING);
- dr= new DefaultDamagerRepairer(getStringScanner());
+ dr = new DefaultDamagerRepairer(getStringScanner());
reconciler.setDamager(dr, ICPartitions.C_CHARACTER);
reconciler.setRepairer(dr, ICPartitions.C_CHARACTER);
- dr= new DefaultDamagerRepairer(getPreprocessorScanner(language));
+ dr = new DefaultDamagerRepairer(getPreprocessorScanner(language));
reconciler.setDamager(new PartitionDamager(), ICPartitions.C_PREPROCESSOR);
reconciler.setRepairer(dr, ICPartitions.C_PREPROCESSOR);
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
return reconciler;
}
-
+
/*
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredContentTypes(org.eclipse.jface.text.source.ISourceViewer)
*/
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[] {
- IDocument.DEFAULT_CONTENT_TYPE,
- ICPartitions.C_MULTI_LINE_COMMENT,
- ICPartitions.C_SINGLE_LINE_COMMENT,
- ICPartitions.C_STRING,
- ICPartitions.C_CHARACTER,
- ICPartitions.C_PREPROCESSOR};
+ return new String[] { IDocument.DEFAULT_CONTENT_TYPE, ICPartitions.C_MULTI_LINE_COMMENT,
+ ICPartitions.C_SINGLE_LINE_COMMENT, ICPartitions.C_STRING, ICPartitions.C_CHARACTER,
+ ICPartitions.C_PREPROCESSOR };
}
/*
@@ -267,7 +263,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
if (fTextEditor != null) {
- MonoReconciler reconciler= new MonoReconciler(new AsmReconcilingStrategy(fTextEditor), false);
+ MonoReconciler reconciler = new MonoReconciler(new AsmReconcilingStrategy(fTextEditor), false);
reconciler.setIsIncrementalReconciler(false);
reconciler.setProgressMonitor(new NullProgressMonitor());
reconciler.setDelay(500);
@@ -284,11 +280,10 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
* @return <code>true</code> if event causes a behavioral change
*/
public boolean affectsTextPresentation(PropertyChangeEvent event) {
- if (fMultilineCommentScanner.affectsBehavior(event)
- || fSinglelineCommentScanner.affectsBehavior(event)
+ if (fMultilineCommentScanner.affectsBehavior(event) || fSinglelineCommentScanner.affectsBehavior(event)
|| fStringScanner.affectsBehavior(event)) {
- return true;
- }
+ return true;
+ }
if (fCodeScanner != null && fCodeScanner.affectsBehavior(event)) {
return true;
}
@@ -338,7 +333,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
ICElement element = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fTextEditor.getEditorInput());
if (element instanceof ITranslationUnit) {
try {
- return ((ITranslationUnit)element).getLanguage();
+ return ((ITranslationUnit) element).getLanguage();
} catch (CoreException e) {
CUIPlugin.log(e);
}
@@ -350,7 +345,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
if (file != null) {
contentType = CCorePlugin.getContentType(file.getProject(), file.getName());
} else if (input instanceof IPathEditorInput) {
- IPath path = ((IPathEditorInput)input).getPath();
+ IPath path = ((IPathEditorInput) input).getPath();
contentType = CCorePlugin.getContentType(path.lastSegment());
} else {
ILocationProvider locationProvider = input.getAdapter(ILocationProvider.class);
@@ -371,8 +366,8 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
* Reset cached language dependent scanners.
*/
public void resetScanners() {
- fCodeScanner= null;
- fPreprocessorScanner= null;
+ fCodeScanner = null;
+ fPreprocessorScanner = null;
}
private ITokenStoreFactory getTokenStoreFactory() {
@@ -383,10 +378,10 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
}
};
}
-
+
@Override
protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
- Map<String, IAdaptable> targets= super.getHyperlinkDetectorTargets(sourceViewer);
+ Map<String, IAdaptable> targets = super.getHyperlinkDetectorTargets(sourceViewer);
targets.put("org.eclipse.cdt.ui.cCode", fTextEditor); //$NON-NLS-1$
return targets;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java
index 936226667e1..b6aa2060f42 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -122,7 +122,7 @@ import org.eclipse.cdt.internal.ui.typehierarchy.THInformationProvider;
* <p>
* This class may be instantiated and subclassed by clients.
* </p>
- *
+ *
* @since 5.1
*/
public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
@@ -163,7 +163,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* The color manager.
*/
protected IColorManager fColorManager;
-
+
/**
* Creates a new C source viewer configuration for viewers in the given editor
* using the given preference store, the color manager and the specified document partitioning.
@@ -173,11 +173,12 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* @param editor the editor in which the configured viewer(s) will reside, or <code>null</code> if none
* @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
*/
- public CSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
+ public CSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor,
+ String partitioning) {
super(preferenceStore);
- fColorManager= colorManager;
- fTextEditor= editor;
- fDocumentPartitioning= partitioning;
+ fColorManager = colorManager;
+ fTextEditor = editor;
+ fDocumentPartitioning = partitioning;
initializeScanners();
}
@@ -199,19 +200,20 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
if (fPreprocessorScanner != null) {
return fPreprocessorScanner;
}
- AbstractCScanner scanner= null;
- ICLanguageKeywords keywords = language == null ? null : (ICLanguageKeywords) language.getAdapter(ICLanguageKeywords.class);
+ AbstractCScanner scanner = null;
+ ICLanguageKeywords keywords = language == null ? null
+ : (ICLanguageKeywords) language.getAdapter(ICLanguageKeywords.class);
if (keywords != null) {
scanner = new CPreprocessorScanner(getTokenStoreFactory(), keywords);
}
if (scanner == null) {
keywords = GPPLanguage.getDefault().getAdapter(ICLanguageKeywords.class);
- scanner= new CPreprocessorScanner(getTokenStoreFactory(), keywords);
+ scanner = new CPreprocessorScanner(getTokenStoreFactory(), keywords);
}
- fPreprocessorScanner= scanner;
+ fPreprocessorScanner = scanner;
return fPreprocessorScanner;
}
-
+
/**
* Returns the color manager for this configuration.
*
@@ -230,99 +232,99 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
return fTextEditor;
}
- /**
- * Creates outline presenter.
- * @return Presenter with outline view.
- */
- public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer) {
- final IInformationControlCreator outlineControlCreator = getOutlineControlCreator();
- final InformationPresenter presenter = new InformationPresenter(outlineControlCreator);
- presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+ /**
+ * Creates outline presenter.
+ * @return Presenter with outline view.
+ */
+ public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer) {
+ final IInformationControlCreator outlineControlCreator = getOutlineControlCreator();
+ final InformationPresenter presenter = new InformationPresenter(outlineControlCreator);
+ presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
final IInformationProvider provider = new CElementContentProvider(getEditor());
- String[] contentTypes= getConfiguredContentTypes(sourceViewer);
- for (int i= 0; i < contentTypes.length; i++)
+ String[] contentTypes = getConfiguredContentTypes(sourceViewer);
+ for (int i = 0; i < contentTypes.length; i++)
presenter.setInformationProvider(provider, contentTypes[i]);
- presenter.setSizeConstraints(50, 20, true, false);
- return presenter;
- }
-
- /**
- * Creates type hierarchy presenter.
- * @return Presenter with type hierarchy view.
- */
- public IInformationPresenter getHierarchyPresenter(ISourceViewer sourceViewer) {
- final IInformationControlCreator hierarchyControlCreator = getHierarchyControlCreator();
- final InformationPresenter presenter = new InformationPresenter(hierarchyControlCreator);
- presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+ presenter.setSizeConstraints(50, 20, true, false);
+ return presenter;
+ }
+
+ /**
+ * Creates type hierarchy presenter.
+ * @return Presenter with type hierarchy view.
+ */
+ public IInformationPresenter getHierarchyPresenter(ISourceViewer sourceViewer) {
+ final IInformationControlCreator hierarchyControlCreator = getHierarchyControlCreator();
+ final InformationPresenter presenter = new InformationPresenter(hierarchyControlCreator);
+ presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
final IInformationProvider provider = new THInformationProvider(getEditor());
- String[] contentTypes= getConfiguredContentTypes(sourceViewer);
- for (int i= 0; i < contentTypes.length; i++)
+ String[] contentTypes = getConfiguredContentTypes(sourceViewer);
+ for (int i = 0; i < contentTypes.length; i++)
presenter.setInformationProvider(provider, contentTypes[i]);
- presenter.setSizeConstraints(50, 20, true, false);
- return presenter;
- }
-
+ presenter.setSizeConstraints(50, 20, true, false);
+ return presenter;
+ }
+
/**
* Initializes language independent scanners.
*/
protected void initializeScanners() {
- fStringScanner= new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
- fMultilineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT);
- fSinglelineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT);
+ fStringScanner = new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
+ fMultilineCommentScanner = new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT);
+ fSinglelineCommentScanner = new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT);
}
- /**
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
+ /**
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
*/
- @Override
+ @Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- CPresentationReconciler reconciler= new CPresentationReconciler();
+ CPresentationReconciler reconciler = new CPresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
- ILanguage language= getLanguage();
+ ILanguage language = getLanguage();
RuleBasedScanner scanner = getCodeScanner(language);
- DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner);
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
- dr= new DefaultDamagerRepairer(getSinglelineCommentScanner());
+
+ dr = new DefaultDamagerRepairer(getSinglelineCommentScanner());
reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
- dr= new DefaultDamagerRepairer(getMultilineCommentScanner());
+ dr = new DefaultDamagerRepairer(getMultilineCommentScanner());
reconciler.setDamager(dr, ICPartitions.C_MULTI_LINE_COMMENT);
reconciler.setRepairer(dr, ICPartitions.C_MULTI_LINE_COMMENT);
-
- ICTokenScanner docCommentSingleScanner= getSinglelineDocCommentScanner(getProject());
- if (docCommentSingleScanner!=null) {
- dr= new DefaultDamagerRepairer(docCommentSingleScanner);
+
+ ICTokenScanner docCommentSingleScanner = getSinglelineDocCommentScanner(getProject());
+ if (docCommentSingleScanner != null) {
+ dr = new DefaultDamagerRepairer(docCommentSingleScanner);
reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_DOC_COMMENT);
reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_DOC_COMMENT);
}
-
- ICTokenScanner docCommentMultiScanner= getMultilineDocCommentScanner(getProject());
- if (docCommentMultiScanner!=null) {
- dr= new DefaultDamagerRepairer(docCommentMultiScanner);
+
+ ICTokenScanner docCommentMultiScanner = getMultilineDocCommentScanner(getProject());
+ if (docCommentMultiScanner != null) {
+ dr = new DefaultDamagerRepairer(docCommentMultiScanner);
reconciler.setDamager(dr, ICPartitions.C_MULTI_LINE_DOC_COMMENT);
reconciler.setRepairer(dr, ICPartitions.C_MULTI_LINE_DOC_COMMENT);
}
-
- dr= new DefaultDamagerRepairer(getStringScanner());
+
+ dr = new DefaultDamagerRepairer(getStringScanner());
reconciler.setDamager(dr, ICPartitions.C_STRING);
reconciler.setRepairer(dr, ICPartitions.C_STRING);
-
- dr= new DefaultDamagerRepairer(getStringScanner());
+
+ dr = new DefaultDamagerRepairer(getStringScanner());
reconciler.setDamager(dr, ICPartitions.C_CHARACTER);
reconciler.setRepairer(dr, ICPartitions.C_CHARACTER);
-
- dr= new DefaultDamagerRepairer(getPreprocessorScanner(language));
+
+ dr = new DefaultDamagerRepairer(getPreprocessorScanner(language));
reconciler.setDamager(new PartitionDamager(), ICPartitions.C_PREPROCESSOR);
reconciler.setRepairer(dr, ICPartitions.C_PREPROCESSOR);
-
+
return reconciler;
}
@@ -352,13 +354,14 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
protected ICTokenScanner getMultilineDocCommentScanner(IResource resource) {
if (fMultilineDocCommentScanner == null) {
if (resource == null) {
- resource= ResourcesPlugin.getWorkspace().getRoot();
+ resource = ResourcesPlugin.getWorkspace().getRoot();
}
- IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getMultilineConfiguration();
- fMultilineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
+ IDocCommentViewerConfiguration owner = DocCommentOwnerManager.getInstance().getCommentOwner(resource)
+ .getMultilineConfiguration();
+ fMultilineDocCommentScanner = owner.createCommentScanner(getTokenStoreFactory());
if (fMultilineDocCommentScanner == null) {
// fallback: normal comment highlighting
- fMultilineDocCommentScanner= fMultilineCommentScanner;
+ fMultilineDocCommentScanner = fMultilineCommentScanner;
}
}
return fMultilineDocCommentScanner;
@@ -372,18 +375,19 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
protected ICTokenScanner getSinglelineDocCommentScanner(IResource resource) {
if (fSinglelineDocCommentScanner == null) {
if (resource == null) {
- resource= ResourcesPlugin.getWorkspace().getRoot();
+ resource = ResourcesPlugin.getWorkspace().getRoot();
}
- IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getSinglelineConfiguration();
- fSinglelineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
+ IDocCommentViewerConfiguration owner = DocCommentOwnerManager.getInstance().getCommentOwner(resource)
+ .getSinglelineConfiguration();
+ fSinglelineDocCommentScanner = owner.createCommentScanner(getTokenStoreFactory());
if (fSinglelineDocCommentScanner == null) {
// fallback: normal comment highlighting
- fSinglelineDocCommentScanner= fSinglelineCommentScanner;
+ fSinglelineDocCommentScanner = fSinglelineCommentScanner;
}
}
return fSinglelineDocCommentScanner;
}
-
+
/**
* Returns the code scanner for the given language.
*/
@@ -391,8 +395,8 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
if (fCodeScanner != null) {
return fCodeScanner;
}
- RuleBasedScanner scanner= null;
-
+ RuleBasedScanner scanner = null;
+
if (language != null) {
ICLanguageKeywords keywords = language.getAdapter(ICLanguageKeywords.class);
if (keywords != null) {
@@ -403,12 +407,12 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
scanner = languageUI.getCodeScanner();
}
}
-
+
if (scanner == null) {
scanner = new CCodeScanner(getTokenStoreFactory(), GPPLanguage.getDefault());
}
if (scanner instanceof AbstractCScanner) {
- fCodeScanner= (AbstractCScanner)scanner;
+ fCodeScanner = (AbstractCScanner) scanner;
}
return scanner;
}
@@ -423,8 +427,9 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$
-
- IContentAssistProcessor processor = new CContentAssistProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE);
+
+ IContentAssistProcessor processor = new CContentAssistProcessor(getEditor(), assistant,
+ IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
processor = new CContentAssistProcessor(getEditor(), assistant, ICPartitions.C_MULTI_LINE_COMMENT);
@@ -446,7 +451,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
assistant.setContentAssistProcessor(processor, ICPartitions.C_PREPROCESSOR);
ContentAssistPreference.configure(assistant, fPreferenceStore);
-
+
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
@@ -462,13 +467,13 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* @since 4.0
*/
protected IDialogSettings getSettings(String sectionName) {
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null)
- settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
+ settings = CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
return settings;
}
-
+
@Override
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
if (getEditor() != null)
@@ -480,9 +485,9 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
public IReconciler getReconciler(ISourceViewer sourceViewer) {
if (fTextEditor != null) {
// Delay changed and non-incremental reconciler used due to PR 130089.
- CCompositeReconcilingStrategy strategy=
- new CCompositeReconcilingStrategy(sourceViewer, fTextEditor, getConfiguredDocumentPartitioning(sourceViewer));
- MonoReconciler reconciler= new CReconciler(fTextEditor, strategy);
+ CCompositeReconcilingStrategy strategy = new CCompositeReconcilingStrategy(sourceViewer, fTextEditor,
+ getConfiguredDocumentPartitioning(sourceViewer));
+ MonoReconciler reconciler = new CReconciler(fTextEditor, strategy);
reconciler.setIsIncrementalReconciler(false);
reconciler.setProgressMonitor(new ProgressMonitorAndCanceler());
reconciler.setDelay(500);
@@ -493,47 +498,49 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
@Override
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
- String partitioning= getConfiguredDocumentPartitioning(sourceViewer);
-
- IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
- IAutoEditStrategy single= owner.getSinglelineConfiguration().createAutoEditStrategy();
- IAutoEditStrategy multi= owner.getMultilineConfiguration().createAutoEditStrategy();
-
- IAutoEditStrategy[] NONE= new IAutoEditStrategy[0];
-
+ String partitioning = getConfiguredDocumentPartitioning(sourceViewer);
+
+ IDocCommentOwner owner = DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
+ IAutoEditStrategy single = owner.getSinglelineConfiguration().createAutoEditStrategy();
+ IAutoEditStrategy multi = owner.getMultilineConfiguration().createAutoEditStrategy();
+
+ IAutoEditStrategy[] NONE = new IAutoEditStrategy[0];
+
if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType))
return new IAutoEditStrategy[] { new DefaultMultilineCommentAutoEditStrategy() };
if (ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(contentType))
- return single!=null ? new IAutoEditStrategy[] {single} : NONE;
+ return single != null ? new IAutoEditStrategy[] { single } : NONE;
else if (ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(contentType))
- return multi!=null? new IAutoEditStrategy[] {multi} : NONE;
+ return multi != null ? new IAutoEditStrategy[] { multi } : NONE;
else if (ICPartitions.C_STRING.equals(contentType))
- return new IAutoEditStrategy[] { /*new SmartSemicolonAutoEditStrategy(partitioning),*/ new CStringAutoIndentStrategy(partitioning, getCProject()) };
+ return new IAutoEditStrategy[] {
+ /*new SmartSemicolonAutoEditStrategy(partitioning),*/ new CStringAutoIndentStrategy(partitioning,
+ getCProject()) };
else
return new IAutoEditStrategy[] { new CAutoIndentStrategy(partitioning, getCProject()) };
}
-
+
/**
* @see SourceViewerConfiguration#getDoubleClickStrategy(ISourceViewer, String)
*/
@Override
public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
- if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType) ||
- ICPartitions.C_SINGLE_LINE_COMMENT.equals(contentType)) {
+ if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType)
+ || ICPartitions.C_SINGLE_LINE_COMMENT.equals(contentType)) {
return new DefaultTextDoubleClickStrategy();
} else if (ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(contentType)) {
- IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
- ITextDoubleClickStrategy single= owner.getSinglelineConfiguration().createDoubleClickStrategy();
+ IDocCommentOwner owner = DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
+ ITextDoubleClickStrategy single = owner.getSinglelineConfiguration().createDoubleClickStrategy();
return single != null ? single : new DefaultTextDoubleClickStrategy();
} else if (ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(contentType)) {
- IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
- ITextDoubleClickStrategy multi= owner.getMultilineConfiguration().createDoubleClickStrategy();
- return multi!=null ? multi : new DefaultTextDoubleClickStrategy();
- } else if (ICPartitions.C_STRING.equals(contentType) ||
- ICPartitions.C_CHARACTER.equals(contentType)) {
+ IDocCommentOwner owner = DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
+ ITextDoubleClickStrategy multi = owner.getMultilineConfiguration().createDoubleClickStrategy();
+ return multi != null ? multi : new DefaultTextDoubleClickStrategy();
+ } else if (ICPartitions.C_STRING.equals(contentType) || ICPartitions.C_CHARACTER.equals(contentType)) {
return new CStringDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer));
} else if (ICPartitions.C_PREPROCESSOR.equals(contentType)) {
- return new CStringDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), new CDoubleClickSelector());
+ return new CStringDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer),
+ new CDoubleClickSelector());
}
return new CDoubleClickSelector();
}
@@ -545,22 +552,23 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
@Override
public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
- ICProject project= getCProject();
- final int tabWidth= CodeFormatterUtil.getTabWidth(project);
- final int indentWidth= CodeFormatterUtil.getIndentWidth(project);
- boolean allowTabs= tabWidth <= indentWidth;
-
+ ICProject project = getCProject();
+ final int tabWidth = CodeFormatterUtil.getTabWidth(project);
+ final int indentWidth = CodeFormatterUtil.getIndentWidth(project);
+ boolean allowTabs = tabWidth <= indentWidth;
+
String indentMode;
if (project == null) {
- indentMode= CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+ indentMode = CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
} else {
- indentMode= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
+ indentMode = project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
}
- boolean useSpaces= CCorePlugin.SPACE.equals(indentMode) || DefaultCodeFormatterConstants.MIXED.equals(indentMode);
-
+ boolean useSpaces = CCorePlugin.SPACE.equals(indentMode)
+ || DefaultCodeFormatterConstants.MIXED.equals(indentMode);
+
// assert allowTabs || useSpaces;
-
+
if (!allowTabs) {
return new String[] { getStringWithSpaces(indentWidth), "" }; //$NON-NLS-1$
} else if (!useSpaces) {
@@ -573,36 +581,36 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
/**
* Computes and returns the indent prefixes for space indentation
* and the given <code>tabWidth</code>.
- *
+ *
* @param tabWidth the display tab width
* @return the indent prefixes
* @see #getIndentPrefixes(ISourceViewer, String)
*/
protected String[] getIndentPrefixesForSpaces(int tabWidth) {
- String[] indentPrefixes= new String[tabWidth + 2];
- indentPrefixes[0]= getStringWithSpaces(tabWidth);
-
- for (int i= 0; i < tabWidth; i++) {
- String spaces= getStringWithSpaces(i);
+ String[] indentPrefixes = new String[tabWidth + 2];
+ indentPrefixes[0] = getStringWithSpaces(tabWidth);
+
+ for (int i = 0; i < tabWidth; i++) {
+ String spaces = getStringWithSpaces(i);
if (i < tabWidth)
- indentPrefixes[i+1]= spaces + '\t';
+ indentPrefixes[i + 1] = spaces + '\t';
else
- indentPrefixes[i+1]= spaces;
+ indentPrefixes[i + 1] = spaces;
}
-
- indentPrefixes[tabWidth + 1]= ""; //$NON-NLS-1$
+
+ indentPrefixes[tabWidth + 1] = ""; //$NON-NLS-1$
return indentPrefixes;
}
/**
* Creates and returns a String with <code>count</code> spaces.
- *
+ *
* @param count the space count
* @return the string with the spaces
*/
protected static String getStringWithSpaces(int count) {
- char[] spaceChars= new char[count];
+ char[] spaceChars = new char[count];
Arrays.fill(spaceChars, ' ');
return new String(spaceChars);
}
@@ -613,16 +621,16 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* @return the ICProject or <code>null</code>
*/
protected ICProject getCProject() {
- ITextEditor editor= getEditor();
+ ITextEditor editor = getEditor();
if (editor == null)
return null;
- ICElement element= null;
- IEditorInput input= editor.getEditorInput();
- IDocumentProvider provider= editor.getDocumentProvider();
+ ICElement element = null;
+ IEditorInput input = editor.getEditorInput();
+ IDocumentProvider provider = editor.getDocumentProvider();
if (provider instanceof CDocumentProvider) {
- CDocumentProvider cudp= (CDocumentProvider) provider;
- element= cudp.getWorkingCopy(input);
+ CDocumentProvider cudp = (CDocumentProvider) provider;
+ element = cudp.getWorkingCopy(input);
}
if (element == null)
@@ -645,21 +653,21 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
/**
* Returns whether spaces should be used exclusively for indentation.
- *
+ *
* @param sourceViewer
* @return <code>true</code> if spaces should be used for indentation
*/
public boolean useSpacesOnly(ISourceViewer sourceViewer) {
- ICProject project= getCProject();
+ ICProject project = getCProject();
String option;
if (project == null) {
- option= CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+ option = CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
} else {
- option= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
+ option = project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
}
return CCorePlugin.SPACE.equals(option);
}
-
+
@Override
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
return new HTMLAnnotationHover() {
@@ -672,36 +680,36 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
@Override
public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
- CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
- int stateMasks[]= new int[hoverDescs.length];
- int stateMasksLength= 0;
+ CEditorTextHoverDescriptor[] hoverDescs = CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
+ int stateMasks[] = new int[hoverDescs.length];
+ int stateMasksLength = 0;
for (CEditorTextHoverDescriptor hoverDesc : hoverDescs) {
if (hoverDesc.isEnabled()) {
- int j= 0;
- int stateMask= hoverDesc.getStateMask();
+ int j = 0;
+ int stateMask = hoverDesc.getStateMask();
while (j < stateMasksLength) {
if (stateMasks[j] == stateMask)
break;
j++;
}
if (j == stateMasksLength)
- stateMasks[stateMasksLength++]= stateMask;
+ stateMasks[stateMasksLength++] = stateMask;
}
}
if (stateMasksLength == hoverDescs.length)
return stateMasks;
-
- int[] shortenedStateMasks= new int[stateMasksLength];
+
+ int[] shortenedStateMasks = new int[stateMasksLength];
System.arraycopy(stateMasks, 0, shortenedStateMasks, 0, stateMasksLength);
return shortenedStateMasks;
}
-
+
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
- CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
- int i= 0;
+ CEditorTextHoverDescriptor[] hoverDescs = CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
+ int i = 0;
while (i < hoverDescs.length) {
- if (hoverDescs[i].isEnabled() && hoverDescs[i].getStateMask() == stateMask)
+ if (hoverDescs[i].isEnabled() && hoverDescs[i].getStateMask() == stateMask)
return new CEditorTextHoverProxy(hoverDescs[i], getEditor());
i++;
}
@@ -716,34 +724,26 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[] {
- IDocument.DEFAULT_CONTENT_TYPE,
- ICPartitions.C_MULTI_LINE_COMMENT,
- ICPartitions.C_SINGLE_LINE_COMMENT,
- ICPartitions.C_STRING,
- ICPartitions.C_CHARACTER,
- ICPartitions.C_PREPROCESSOR,
- ICPartitions.C_SINGLE_LINE_DOC_COMMENT,
- ICPartitions.C_MULTI_LINE_DOC_COMMENT
- };
+ return new String[] { IDocument.DEFAULT_CONTENT_TYPE, ICPartitions.C_MULTI_LINE_COMMENT,
+ ICPartitions.C_SINGLE_LINE_COMMENT, ICPartitions.C_STRING, ICPartitions.C_CHARACTER,
+ ICPartitions.C_PREPROCESSOR, ICPartitions.C_SINGLE_LINE_DOC_COMMENT,
+ ICPartitions.C_MULTI_LINE_DOC_COMMENT };
}
-
+
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
- final MultiPassContentFormatter formatter =
- new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer),
- IDocument.DEFAULT_CONTENT_TYPE);
-
+ final MultiPassContentFormatter formatter = new MultiPassContentFormatter(
+ getConfiguredDocumentPartitioning(sourceViewer), IDocument.DEFAULT_CONTENT_TYPE);
+
formatter.setMasterStrategy(new CFormattingStrategy());
return formatter;
}
-
+
public boolean affectsBehavior(PropertyChangeEvent event) {
if ((fMultilineDocCommentScanner != null && fMultilineDocCommentScanner.affectsBehavior(event))
- || (fSinglelineDocCommentScanner != null && fSinglelineDocCommentScanner.affectsBehavior(event))
- || fMultilineCommentScanner.affectsBehavior(event)
- || fSinglelineCommentScanner.affectsBehavior(event)
- || fStringScanner.affectsBehavior(event)) {
+ || (fSinglelineDocCommentScanner != null && fSinglelineDocCommentScanner.affectsBehavior(event))
+ || fMultilineCommentScanner.affectsBehavior(event) || fSinglelineCommentScanner.affectsBehavior(event)
+ || fStringScanner.affectsBehavior(event)) {
return true;
}
if (fCodeScanner != null && fCodeScanner.affectsBehavior(event)) {
@@ -785,19 +785,19 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
@Override
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
- InformationPresenter presenter= new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
+ InformationPresenter presenter = new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
-
+
// Register information provider
- IInformationProvider provider= new CInformationProvider(getEditor());
- String[] contentTypes= getConfiguredContentTypes(sourceViewer);
+ IInformationProvider provider = new CInformationProvider(getEditor());
+ String[] contentTypes = getConfiguredContentTypes(sourceViewer);
for (String contentType : contentTypes)
presenter.setInformationProvider(provider, contentType);
-
+
presenter.setSizeConstraints(60, 10, true, true);
return presenter;
}
-
+
/**
* Determines whether the preference change encoded by the given event
* changes the behavior of one of its contained components.
@@ -823,9 +823,9 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
public void handlePropertyChangeEvent(PropertyChangeEvent event) {
if (fCodeScanner != null && fCodeScanner.affectsBehavior(event))
fCodeScanner.adaptToPreferenceChange(event);
- if (fMultilineDocCommentScanner!=null && fMultilineDocCommentScanner.affectsBehavior(event))
+ if (fMultilineDocCommentScanner != null && fMultilineDocCommentScanner.affectsBehavior(event))
fMultilineDocCommentScanner.adaptToPreferenceChange(event);
- if (fSinglelineDocCommentScanner!=null && fSinglelineDocCommentScanner.affectsBehavior(event))
+ if (fSinglelineDocCommentScanner != null && fSinglelineDocCommentScanner.affectsBehavior(event))
fSinglelineDocCommentScanner.adaptToPreferenceChange(event);
if (fMultilineCommentScanner.affectsBehavior(event))
fMultilineCommentScanner.adaptToPreferenceChange(event);
@@ -845,41 +845,41 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
}
/**
- * Creates control for outline presentation in editor.
- * @return Control.
- */
- protected IInformationControlCreator getOutlineControlCreator() {
- final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
- /**
- * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
- */
- @Override
+ * Creates control for outline presentation in editor.
+ * @return Control.
+ */
+ protected IInformationControlCreator getOutlineControlCreator() {
+ final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
+ /**
+ * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
public IInformationControl createInformationControl(Shell parent) {
- int shellStyle= SWT.RESIZE;
- int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
- return new COutlineInformationControl(parent, shellStyle, treeStyle);
- }
- };
- return conrolCreator;
- }
-
- /**
- * Creates control for outline presentation in editor.
- */
- protected IInformationControlCreator getHierarchyControlCreator() {
- final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
- /**
- * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
- */
- @Override
+ int shellStyle = SWT.RESIZE;
+ int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
+ return new COutlineInformationControl(parent, shellStyle, treeStyle);
+ }
+ };
+ return conrolCreator;
+ }
+
+ /**
+ * Creates control for outline presentation in editor.
+ */
+ protected IInformationControlCreator getHierarchyControlCreator() {
+ final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
+ /**
+ * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
public IInformationControl createInformationControl(Shell parent) {
- int shellStyle= SWT.RESIZE;
- int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
- return new THInformationControl(parent, shellStyle, treeStyle);
- }
- };
- return conrolCreator;
- }
+ int shellStyle = SWT.RESIZE;
+ int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
+ return new THInformationControl(parent, shellStyle, treeStyle);
+ }
+ };
+ return conrolCreator;
+ }
protected ILanguage getLanguage() {
if (fTextEditor == null) {
@@ -888,7 +888,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
ICElement element = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fTextEditor.getEditorInput());
if (element instanceof ITranslationUnit) {
try {
- return ((ITranslationUnit)element).getLanguage();
+ return ((ITranslationUnit) element).getLanguage();
} catch (CoreException e) {
CUIPlugin.log(e);
}
@@ -900,7 +900,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
if (file != null) {
contentType = CCorePlugin.getContentType(file.getProject(), file.getName());
} else if (input instanceof IPathEditorInput) {
- IPath path = ((IPathEditorInput)input).getPath();
+ IPath path = ((IPathEditorInput) input).getPath();
contentType = CCorePlugin.getContentType(path.lastSegment());
} else {
ILocationProvider locationProvider = input.getAdapter(ILocationProvider.class);
@@ -918,70 +918,71 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
// fallback
return GPPLanguage.getDefault();
}
-
+
/**
* Resets cached language dependent scanners.
*/
public void resetScanners() {
- fCodeScanner= null;
- fMultilineDocCommentScanner= null;
- fSinglelineDocCommentScanner= null;
- fPreprocessorScanner= null;
+ fCodeScanner = null;
+ fMultilineDocCommentScanner = null;
+ fSinglelineDocCommentScanner = null;
+ fPreprocessorScanner = null;
}
-
+
/**
* Creates macro exploration presenter.
* @param sourceViewer
* @return Presenter with macro exploration view.
- *
+ *
* @since 5.0
*/
public IInformationPresenter getMacroExplorationPresenter(ISourceViewer sourceViewer) {
- final IInformationControlCreator controlCreator= getMacroExplorationControlCreator();
- final InformationPresenter presenter = new InformationPresenter(controlCreator);
- presenter.setRestoreInformationControlBounds(getDialogSettings(CMacroExpansionExplorationControl.KEY_CONTROL_BOUNDS), true, true);
- presenter.setSizeConstraints(320, 120, true, false);
- presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+ final IInformationControlCreator controlCreator = getMacroExplorationControlCreator();
+ final InformationPresenter presenter = new InformationPresenter(controlCreator);
+ presenter.setRestoreInformationControlBounds(
+ getDialogSettings(CMacroExpansionExplorationControl.KEY_CONTROL_BOUNDS), true, true);
+ presenter.setSizeConstraints(320, 120, true, false);
+ presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
final IInformationProvider provider = new CMacroExpansionInformationProvider(getEditor());
- String[] contentTypes= getConfiguredContentTypes(sourceViewer);
- for (int i= 0; i < contentTypes.length; i++)
+ String[] contentTypes = getConfiguredContentTypes(sourceViewer);
+ for (int i = 0; i < contentTypes.length; i++)
presenter.setInformationProvider(provider, contentTypes[i]);
- presenter.setSizeConstraints(50, 20, true, false);
- return presenter;
+ presenter.setSizeConstraints(50, 20, true, false);
+ return presenter;
}
protected IDialogSettings getDialogSettings(String sectionName) {
if (sectionName == null) {
return null;
}
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null) {
- settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
+ settings = CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
}
return settings;
}
-
+
/**
- * Creates control for macro exploration in editor.
- */
- protected IInformationControlCreator getMacroExplorationControlCreator() {
- final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
- @Override
+ * Creates control for macro exploration in editor.
+ */
+ protected IInformationControlCreator getMacroExplorationControlCreator() {
+ final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
+ @Override
public IInformationControl createInformationControl(Shell parent) {
- return new CMacroExpansionExplorationControl(parent);
- }
- };
- return conrolCreator;
- }
-
- /**
+ return new CMacroExpansionExplorationControl(parent);
+ }
+ };
+ return conrolCreator;
+ }
+
+ /**
* @return the IProject associated with this CSourceViewerConfiguration, or null if
* no IProject could be determined
*/
protected IProject getProject() {
- ICProject cproject= getCProject();
- return cproject!=null ? cproject.getProject() :null;
+ ICProject cproject = getCProject();
+ return cproject != null ? cproject.getProject() : null;
}
protected ITokenStoreFactory getTokenStoreFactory() {
@@ -995,7 +996,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
@Override
protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
- Map<String, IAdaptable> targets= super.getHyperlinkDetectorTargets(sourceViewer);
+ Map<String, IAdaptable> targets = super.getHyperlinkDetectorTargets(sourceViewer);
targets.put("org.eclipse.cdt.ui.cCode", fTextEditor); //$NON-NLS-1$
return targets;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java
index bc74ea96ec1..4db20979407 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java
@@ -14,8 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.text;
-
-
/**
* Color keys used for syntax highlighting C/C++ and Assembly code
* A <code>IColorManager</code> is responsible for mapping
@@ -25,7 +23,7 @@ package org.eclipse.cdt.ui.text;
* implemented.
* </p>
* @see org.eclipse.cdt.ui.text.IColorManager
- *
+ *
* @since 5.1
*
* @noimplement This interface is not intended to be implemented by clients.
@@ -33,41 +31,39 @@ package org.eclipse.cdt.ui.text;
*/
public interface ICColorConstants {
/** The color key for multi-line comments in C code. */
- String C_MULTI_LINE_COMMENT= "c_multi_line_comment"; //$NON-NLS-1$
+ String C_MULTI_LINE_COMMENT = "c_multi_line_comment"; //$NON-NLS-1$
/** The color key for single-line comments in C code. */
- String C_SINGLE_LINE_COMMENT= "c_single_line_comment"; //$NON-NLS-1$
+ String C_SINGLE_LINE_COMMENT = "c_single_line_comment"; //$NON-NLS-1$
/** The color key for keywords in C code. */
- String C_KEYWORD= "c_keyword"; //$NON-NLS-1$
+ String C_KEYWORD = "c_keyword"; //$NON-NLS-1$
/** The color key for builtin types in C code. */
- String C_TYPE= "c_type"; //$NON-NLS-1$
+ String C_TYPE = "c_type"; //$NON-NLS-1$
/** The color key for string and character literals in C code. */
- String C_STRING= "c_string"; //$NON-NLS-1$
- /** The color key for operators. */
- String C_OPERATOR= "c_operators"; //$NON-NLS-1$
- /** The color key for braces. */
- String C_BRACES= "c_braces"; //$NON-NLS-1$
- /** The color key for numbers. */
- String C_NUMBER= "c_numbers"; //$NON-NLS-1$
- /** The color key for everthing in C code for which no other color is specified. */
- String C_DEFAULT= "c_default"; //$NON-NLS-1$
+ String C_STRING = "c_string"; //$NON-NLS-1$
+ /** The color key for operators. */
+ String C_OPERATOR = "c_operators"; //$NON-NLS-1$
+ /** The color key for braces. */
+ String C_BRACES = "c_braces"; //$NON-NLS-1$
+ /** The color key for numbers. */
+ String C_NUMBER = "c_numbers"; //$NON-NLS-1$
+ /** The color key for everthing in C code for which no other color is specified. */
+ String C_DEFAULT = "c_default"; //$NON-NLS-1$
/** The color key for preprocessor directives. */
- String PP_DIRECTIVE= "pp_directive"; //$NON-NLS-1$
+ String PP_DIRECTIVE = "pp_directive"; //$NON-NLS-1$
/** The color key for preprocessor text not colored otherwise. */
- String PP_DEFAULT= "pp_default"; //$NON-NLS-1$
- /** The color key for preprocessor include files. */
- String PP_HEADER= "pp_header"; //$NON-NLS-1$
+ String PP_DEFAULT = "pp_default"; //$NON-NLS-1$
+ /** The color key for preprocessor include files. */
+ String PP_HEADER = "pp_header"; //$NON-NLS-1$
/** The color key for keywords in assembly code. */
- String ASM_DIRECTIVE= "asm_directive"; //$NON-NLS-1$
- /** The color key for assembly labels. */
- String ASM_LABEL= "asm_label"; //$NON-NLS-1$
+ String ASM_DIRECTIVE = "asm_directive"; //$NON-NLS-1$
+ /** The color key for assembly labels. */
+ String ASM_LABEL = "asm_label"; //$NON-NLS-1$
- /**
- * The color key for task tags in C comments
- * (value <code>"c_comment_task_tag"</code>).
- */
- String TASK_TAG= "c_comment_task_tag"; //$NON-NLS-1$
+ /**
+ * The color key for task tags in C comments
+ * (value <code>"c_comment_task_tag"</code>).
+ */
+ String TASK_TAG = "c_comment_task_tag"; //$NON-NLS-1$
}
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionProposal.java
index acac6438ca2..5f5997dfc31 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionProposal.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
@@ -24,19 +24,18 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal;
* </p>
*/
public interface ICCompletionProposal extends ICompletionProposal {
-
+
/**
* Returns the relevance of the proposal.
*/
int getRelevance();
- /**
- * Returns an id string that uniquely identifies this proposal. For most things this is the
- * same as the display name. For functions, this strips off the parameter names and the
- * return type.
- *
- * @return the string that uniquely identifies this proposal
- */
- String getIdString();
+ /**
+ * Returns an id string that uniquely identifies this proposal. For most things this is the
+ * same as the display name. For functions, this strips off the parameter names and the
+ * return type.
+ *
+ * @return the string that uniquely identifies this proposal
+ */
+ String getIdString();
}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java
index 9e0ea29704c..affb115f1f7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
@@ -19,15 +19,15 @@ import org.eclipse.core.resources.IProject;
/**
* Invocation context for the CHelpProviderManager.
- *
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
- *
+ *
* @see IHoverHelpInvocationContext
* @see IContentAssistHelpInvocationContext
*/
public interface ICHelpInvocationContext {
-
+
/**
* @return the project
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java
index d715a981e74..60e2b6925b6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Andrew Ferguson (Symbian)
@@ -16,7 +16,7 @@ package org.eclipse.cdt.ui.text;
/**
* Definition of C partitioning and its partitions.
- *
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @since 4.0
@@ -26,69 +26,58 @@ public interface ICPartitions {
/**
* The identifier of the C partitioning.
*/
- String C_PARTITIONING= "___c_partitioning"; //$NON-NLS-1$
+ String C_PARTITIONING = "___c_partitioning"; //$NON-NLS-1$
/**
* The identifier of the single-line comment partition content type.
*/
- String C_SINGLE_LINE_COMMENT= "__c_singleline_comment"; //$NON-NLS-1$
+ String C_SINGLE_LINE_COMMENT = "__c_singleline_comment"; //$NON-NLS-1$
/**
* The identifier multi-line comment partition content type.
*/
- String C_MULTI_LINE_COMMENT= "__c_multiline_comment"; //$NON-NLS-1$
+ String C_MULTI_LINE_COMMENT = "__c_multiline_comment"; //$NON-NLS-1$
/**
* The identifier of the C string partition content type.
*/
- String C_STRING= "__c_string"; //$NON-NLS-1$
+ String C_STRING = "__c_string"; //$NON-NLS-1$
/**
* The identifier of the C character partition content type.
*/
- String C_CHARACTER= "__c_character"; //$NON-NLS-1$
+ String C_CHARACTER = "__c_character"; //$NON-NLS-1$
/**
* The identifier of the C preprocessor partition content type.
*/
- String C_PREPROCESSOR= "__c_preprocessor"; //$NON-NLS-1$
-
+ String C_PREPROCESSOR = "__c_preprocessor"; //$NON-NLS-1$
+
/**
* The identifier of the single-line documentation tool comment partition content type.
- * @since 5.0
+ * @since 5.0
*/
- String C_SINGLE_LINE_DOC_COMMENT= "__c_singleline_doc_comment"; //$NON-NLS-1$
+ String C_SINGLE_LINE_DOC_COMMENT = "__c_singleline_doc_comment"; //$NON-NLS-1$
/**
* The identifier multi-line comment documentation tool partition content type.
- * @since 5.0
+ * @since 5.0
*/
- String C_MULTI_LINE_DOC_COMMENT= "__c_multiline_doc_comment"; //$NON-NLS-1$
-
+ String C_MULTI_LINE_DOC_COMMENT = "__c_multiline_doc_comment"; //$NON-NLS-1$
+
/**
* All defined CDT editor partitions.
* @since 5.0
*/
- String[] ALL_CPARTITIONS= {
- ICPartitions.C_MULTI_LINE_COMMENT,
- ICPartitions.C_SINGLE_LINE_COMMENT,
- ICPartitions.C_STRING,
- ICPartitions.C_CHARACTER,
- ICPartitions.C_PREPROCESSOR,
- ICPartitions.C_SINGLE_LINE_DOC_COMMENT,
- ICPartitions.C_MULTI_LINE_DOC_COMMENT
- };
-
+ String[] ALL_CPARTITIONS = { ICPartitions.C_MULTI_LINE_COMMENT, ICPartitions.C_SINGLE_LINE_COMMENT,
+ ICPartitions.C_STRING, ICPartitions.C_CHARACTER, ICPartitions.C_PREPROCESSOR,
+ ICPartitions.C_SINGLE_LINE_DOC_COMMENT, ICPartitions.C_MULTI_LINE_DOC_COMMENT };
+
/**
* Array of all assembly partitions.
* @since 5.1
*/
- String[] ALL_ASM_PARTITIONS= new String[] {
- ICPartitions.C_MULTI_LINE_COMMENT,
- ICPartitions.C_SINGLE_LINE_COMMENT,
- ICPartitions.C_STRING,
- ICPartitions.C_CHARACTER,
- ICPartitions.C_PREPROCESSOR
- };
+ String[] ALL_ASM_PARTITIONS = new String[] { ICPartitions.C_MULTI_LINE_COMMENT, ICPartitions.C_SINGLE_LINE_COMMENT,
+ ICPartitions.C_STRING, ICPartitions.C_CHARACTER, ICPartitions.C_PREPROCESSOR };
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java
index f37d82dd47a..3db92432d17 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
@@ -17,8 +17,6 @@ package org.eclipse.cdt.ui.text;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
-
-
/**
* Manages SWT color objects for the given color keys and
* given <code>RGB</code> objects. Until the <code>dispose</code>
@@ -30,21 +28,21 @@ import org.eclipse.swt.graphics.RGB;
* </p>
*
* @see org.eclipse.cdt.ui.text.ICColorConstants
- *
+ *
* @since 5.1
*/
public interface IColorManager {
-
+
/**
- * Returns a color object for the given key. The color objects
- * are remembered internally; the same color object is returned
+ * Returns a color object for the given key. The color objects
+ * are remembered internally; the same color object is returned
* for equal keys.
*
* @param key the color key
* @return the color object for the given key
*/
Color getColor(String key);
-
+
/**
* Returns the color object for the value represented by the given
* <code>RGB</code> object.
@@ -52,8 +50,8 @@ public interface IColorManager {
* @param rgb the rgb color specification
* @return the color object for the given rgb value
*/
- Color getColor(RGB rgb);
-
+ Color getColor(RGB rgb);
+
/**
* Disposes all color objects remembered by this color manager.
*/
@@ -68,8 +66,7 @@ public interface IColorManager {
* color specification remembered under the given key
*/
void bindColor(String key, RGB rgb);
-
-
+
/**
* Forgets the color specification remembered under the given key.
* @param key the color key
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java
index 2511d0863b8..884e5bfd8da 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Red Hat Inc. - Initial API and implementation
**********************************************************************/
@@ -18,21 +18,21 @@ import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
/**
* Invocation context for content assist.
- *
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @since 5.1
*/
public interface IContentAssistHelpInvocationContext extends ICHelpInvocationContext {
-
+
/**
* @return the offset of the content assist.
*/
int getInvocationOffset();
-
+
/**
* @return the AST completion node or null.
*/
IASTCompletionNode getCompletionNode();
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java
index 6ceff4edece..0b265030ce9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java
@@ -7,8 +7,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Red Hat Inc. - Initial API and implementation
**********************************************************************/
@@ -18,16 +18,16 @@ import org.eclipse.jface.text.IRegion;
/**
* Invocation context for the CHelpProviderManager.
- *
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @since 5.1
*/
public interface IHoverHelpInvocationContext extends ICHelpInvocationContext {
-
+
/**
* @return the hover region or null
*/
IRegion getHoverRegion();
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IInvocationContext.java
index e3d546a831c..0c0e3304342 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IInvocationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IInvocationContext.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -33,7 +33,7 @@ public interface IInvocationContext {
* @return Returns the length of the current selection
*/
int getSelectionLength();
-
+
/**
* @return ITranslationUnit or null
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IProblemLocation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IProblemLocation.java
index c2078f79e98..11a7ac8a860 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IProblemLocation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IProblemLocation.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -15,7 +15,7 @@ package org.eclipse.cdt.ui.text;
/**
* Problem information for quick fix and quick assist processors.
- *
+ *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
@@ -40,7 +40,7 @@ public interface IProblemLocation {
* @return The marker type of the problem.
*/
String getMarkerType();
-
+
/**
* Returns the id of problem. Note that problem ids are defined per problem marker type.
*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickAssistProcessor.java
index 221d6530397..862af9a09c6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickAssistProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickAssistProcessor.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickFixProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickFixProcessor.java
index a3c7e1349a6..8bec59c8ae5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickFixProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickFixProcessor.java
@@ -21,7 +21,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
/**
* Interface to be implemented by contributors to the extension point
* <code>org.eclipse.cdt.ui.quickFixProcessors</code>.
- *
+ *
* @since 5.0
*/
public interface IQuickFixProcessor {
@@ -45,6 +45,6 @@ public interface IQuickFixProcessor {
* can be offered
* @throws CoreException CoreException can be thrown if the operation fails
*/
- ICCompletionProposal[] getCorrections(IInvocationContext context,
- IProblemLocation[] locations) throws CoreException;
+ ICCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations)
+ throws CoreException;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticHighlighter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticHighlighter.java
index 9ee036d391f..7c68c200261 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticHighlighter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ISemanticHighlighter.java
@@ -11,7 +11,6 @@
package org.eclipse.cdt.ui.text;
-
/**
* Interface that must be implemented by contributors to the org.eclipse.cdt.ui.semanticHighlighting extension
* point.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStore.java
index e2a5e375dd8..817208bfbf8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStore.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStore.java
@@ -24,9 +24,9 @@ import org.eclipse.cdt.ui.PreferenceConstants;
* <ul>
* <li> Reacting to changes to preferences in a specified {@link IPreferenceStore}
* <li> Managing whether further styles (bold, italic, strikethrough, underline) should be applied
- * <li> Coping with
+ * <li> Coping with
* </ul>
- *
+ *
* ITokenStore assumes style preferences are stored under the following names
* <p>
* Preference color key + {@link PreferenceConstants#EDITOR_BOLD_SUFFIX} are used
@@ -54,10 +54,10 @@ import org.eclipse.cdt.ui.PreferenceConstants;
public interface ITokenStore extends IPropertyChangeParticipant {
/**
* Ensures any IToken objects that will be <em>or have been</em> returned are
- * initialized for display.
+ * initialized for display.
*/
void ensureTokensInitialised();
-
+
/**
* @param property
* @return a token for the specified property. The Token may not be suitable for use if the
@@ -65,7 +65,7 @@ public interface ITokenStore extends IPropertyChangeParticipant {
* point of token use in case this token store was originally initialized before a display was available.
*/
IToken getToken(String property);
-
+
/**
* @return The preference store used to read token styling preferences from.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/SharedASTJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/SharedASTJob.java
index cf4894c78ad..81c83f98bc2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/SharedASTJob.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/SharedASTJob.java
@@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.ui.editor.ASTProvider;
/**
* A Job specialized to give access to the shared AST of the currently active editor.
* Clients must implement {@link #runOnAST(ILanguage, IASTTranslationUnit)}.
- *
+ *
* @since 5.1
*/
public abstract class SharedASTJob extends Job {
@@ -44,7 +44,7 @@ public abstract class SharedASTJob extends Job {
/**
* Create a shared AST job for the given translation unit.
- *
+ *
* @param name the display name of this job
* @param tUnit the translation unit to get the AST for
*/
@@ -55,9 +55,9 @@ public abstract class SharedASTJob extends Job {
/**
* Run an operation on the shared AST of the requested translation unit.
- * This method will only be called if the requested translation unit is open
- * in the currently active editor.
- *
+ * This method will only be called if the requested translation unit is open
+ * in the currently active editor.
+ *
* @param lang the associated <code>ILanguage</code> of the translation unit
* @param ast the AST object of the translation unit or <code>null</code>
* @return A <code>Status</code> object reflecting the result of the operation
@@ -75,17 +75,18 @@ public abstract class SharedASTJob extends Job {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
return SharedASTJob.this.runOnAST(lang, ast);
- }});
+ }
+ });
}
- @Override
+ @Override
public boolean shouldSchedule() {
- return super.shouldSchedule() && PlatformUI.isWorkbenchRunning() && CUIPlugin.getDefault() != null;
- }
+ return super.shouldSchedule() && PlatformUI.isWorkbenchRunning() && CUIPlugin.getDefault() != null;
+ }
- @Override
+ @Override
public boolean shouldRun() {
- return super.shouldRun() && PlatformUI.isWorkbenchRunning() && CUIPlugin.getDefault() != null;
- }
+ return super.shouldRun() && PlatformUI.isWorkbenchRunning() && CUIPlugin.getDefault() != null;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java
index 739737467db..6cb34f54204 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -30,19 +30,20 @@ import org.eclipse.cdt.ui.IPropertyChangeParticipant;
/**
* Which words should be recognized as task tags is specified under {@link CCorePreferenceConstants#TODO_TASK_TAGS} as a
* comma delimited list.
- *
+ *
* @see CCorePreferenceConstants#TODO_TASK_TAGS
* @since 5.0
* @deprecated This class doesn't properly implement parsing of task tags
* (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=246846). It will be removed.
*/
@Deprecated
-public final class TaskTagRule extends WordRule implements IPropertyChangeParticipant {
+public final class TaskTagRule extends WordRule implements IPropertyChangeParticipant {
private static class TaskTagDetector implements IWordDetector {
@Override
public boolean isWordStart(char c) {
return Character.isLetter(c);
}
+
@Override
public boolean isWordPart(char c) {
return Character.isLetter(c);
@@ -50,7 +51,7 @@ public final class TaskTagRule extends WordRule implements IPropertyChangePartic
}
/**
- * Convenience method for extracting a list of words that should be recognized as
+ * Convenience method for extracting a list of words that should be recognized as
* task labels from an {@link IPreferenceStore} and a backup {@link Preferences}
* @param preferenceStore
* @param corePreferences
@@ -58,11 +59,11 @@ public final class TaskTagRule extends WordRule implements IPropertyChangePartic
* expected by TaskTagRule
*/
public static String getTaskWords(IPreferenceStore preferenceStore, Preferences corePreferences) {
- String result= null;
+ String result = null;
if (preferenceStore.contains(CCorePreferenceConstants.TODO_TASK_TAGS)) {
- result= preferenceStore.getString(CCorePreferenceConstants.TODO_TASK_TAGS);
+ result = preferenceStore.getString(CCorePreferenceConstants.TODO_TASK_TAGS);
} else if (corePreferences != null) {
- result= corePreferences.getString(CCorePreferenceConstants.TODO_TASK_TAGS);
+ result = corePreferences.getString(CCorePreferenceConstants.TODO_TASK_TAGS);
}
return result;
}
@@ -76,8 +77,8 @@ public final class TaskTagRule extends WordRule implements IPropertyChangePartic
*/
public TaskTagRule(IToken token, String taskWords) {
super(new TaskTagDetector(), Token.UNDEFINED);
- fToken= token;
- if( taskWords!= null) {
+ fToken = token;
+ if (taskWords != null) {
addTaskTags(taskWords);
}
}
@@ -95,8 +96,8 @@ public final class TaskTagRule extends WordRule implements IPropertyChangePartic
* @param value a comma delimited list of words to recognize as task tags
*/
public void addTaskTags(String value) {
- String[] tasks= value.split(","); //$NON-NLS-1$
- for (int i= 0; i < tasks.length; i++) {
+ String[] tasks = value.split(","); //$NON-NLS-1$
+ for (int i = 0; i < tasks.length; i++) {
if (tasks[i].length() > 0) {
addWord(tasks[i], fToken);
}
@@ -117,7 +118,7 @@ public final class TaskTagRule extends WordRule implements IPropertyChangePartic
@Override
public void adaptToPreferenceChange(PropertyChangeEvent event) {
if (event.getProperty().equals(CCorePreferenceConstants.TODO_TASK_TAGS)) {
- Object value= event.getNewValue();
+ Object value = event.getNewValue();
if (value instanceof String) {
clearTaskTags();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java
index 78971125048..61d97227855 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java
@@ -30,7 +30,7 @@ public interface ICEditorTextHover extends ITextHover {
/**
* Sets the editor on which the hover is shown.
- *
+ *
* @param editor the editor on which the hover popup should be shown
*/
void setEditor(IEditorPart editor);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationContext.java
index fdbea4b76e0..60dee61fd8b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationContext.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -61,7 +61,7 @@ public class ContentAssistInvocationContext {
/**
* Equivalent to
* {@linkplain #ContentAssistInvocationContext(ITextViewer, int) ContentAssistInvocationContext(viewer, viewer.getSelectedRange().x)}.
- *
+ *
* @param viewer the text viewer that content assist is invoked in
*/
public ContentAssistInvocationContext(ITextViewer viewer) {
@@ -70,66 +70,66 @@ public class ContentAssistInvocationContext {
/**
* Creates a new context for the given viewer and offset.
- *
+ *
* @param viewer the text viewer that content assist is invoked in
* @param offset the offset into the viewer's document where content assist is invoked at
*/
public ContentAssistInvocationContext(ITextViewer viewer, int offset) {
Assert.isNotNull(viewer);
- fViewer= viewer;
- fDocument= null;
- fOffset= offset;
+ fViewer = viewer;
+ fDocument = null;
+ fOffset = offset;
numberOfUndisposedContexts.incrementAndGet();
}
-
+
/**
* Creates a new context with no viewer or invocation offset set.
*/
protected ContentAssistInvocationContext() {
- fDocument= null;
- fViewer= null;
- fOffset= -1;
+ fDocument = null;
+ fViewer = null;
+ fOffset = -1;
numberOfUndisposedContexts.incrementAndGet();
}
-
+
/**
* Creates a new context for the given document and offset.
- *
+ *
* @param document the document that content assist is invoked in
* @param offset the offset into the document where content assist is invoked at
*/
public ContentAssistInvocationContext(IDocument document, int offset) {
Assert.isNotNull(document);
Assert.isTrue(offset >= 0);
- fViewer= null;
- fDocument= document;
- fOffset= offset;
+ fViewer = null;
+ fDocument = document;
+ fOffset = offset;
numberOfUndisposedContexts.incrementAndGet();
}
-
+
/**
* Returns the invocation offset.
- *
+ *
* @return the invocation offset
*/
public final int getInvocationOffset() {
assertNotDisposed();
return fOffset;
}
-
+
/**
* Returns the viewer, <code>null</code> if not available.
- *
+ *
* @return the viewer, possibly <code>null</code>
*/
public final ITextViewer getViewer() {
assertNotDisposed();
return fViewer;
}
-
+
/**
* Returns the document that content assist is invoked on, or <code>null</code> if not known.
- *
+ *
* @return the document or <code>null</code>
*/
public IDocument getDocument() {
@@ -141,11 +141,11 @@ public class ContentAssistInvocationContext {
}
return fDocument;
}
-
+
/**
* Computes the identifier (as specified by {@link Character#isJavaIdentifierPart(char)}) that
* immediately precedes the invocation offset.
- *
+ *
* @return the prefix preceding the content assist invocation offset, <code>null</code> if
* there is no document
* @throws BadLocationException if accessing the document fails
@@ -153,22 +153,22 @@ public class ContentAssistInvocationContext {
public CharSequence computeIdentifierPrefix() throws BadLocationException {
assertNotDisposed();
if (fPrefix == null) {
- IDocument document= getDocument();
+ IDocument document = getDocument();
if (document == null)
return null;
- int end= getInvocationOffset();
- int start= end;
+ int end = getInvocationOffset();
+ int start = end;
while (--start >= 0) {
if (!Character.isJavaIdentifierPart(document.getChar(start)))
break;
}
start++;
- fPrefix= document.get(start, end - start);
+ fPrefix = document.get(start, end - start);
}
-
+
return fPrefix;
}
-
+
/**
* Must be called upon completion of the content assist. Used to free any resources
* used by the context.
@@ -194,14 +194,14 @@ public class ContentAssistInvocationContext {
* necessarily cached values).
* <p>
* Example:
- *
+ *
* <pre>
* class MyContext extends ContentAssistInvocationContext {
* private final Object fState;
* private Object fCachedInfo;
- *
+ *
* ...
- *
+ *
* public boolean equals(Object obj) {
* if (!super.equals(obj))
* return false;
@@ -210,12 +210,12 @@ public class ContentAssistInvocationContext {
* }
* }
* </pre>
- *
+ *
* </p>
* <p>
* Subclasses should also extend {@link Object#hashCode()}.
* </p>
- *
+ *
* @param obj {@inheritDoc}
* @return {@inheritDoc}
*/
@@ -225,10 +225,12 @@ public class ContentAssistInvocationContext {
return false;
if (!getClass().equals(obj.getClass()))
return false;
- ContentAssistInvocationContext other= (ContentAssistInvocationContext) obj;
- return (fViewer == null && other.fViewer == null || fViewer != null && fViewer.equals(other.fViewer)) && fOffset == other.fOffset && (fDocument == null && other.fDocument == null || fDocument != null && fDocument.equals(other.fDocument));
+ ContentAssistInvocationContext other = (ContentAssistInvocationContext) obj;
+ return (fViewer == null && other.fViewer == null || fViewer != null && fViewer.equals(other.fViewer))
+ && fOffset == other.fOffset && (fDocument == null && other.fDocument == null
+ || fDocument != null && fDocument.equals(other.fDocument));
}
-
+
@Override
public int hashCode() {
return 23459213 << 5 | (fViewer == null ? 0 : fViewer.hashCode() << 3) | fOffset;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java
index 36dcfd3dbf6..15e647b7954 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java
@@ -24,7 +24,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
/**
* Describes the context of a content assist invocation in a C/C++ editor.
- *
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
@@ -32,7 +32,7 @@ public interface ICEditorContentAssistInvocationContext {
/**
* Returns the translation unit that content assist is invoked in, <code>null</code> if there
* is none.
- *
+ *
* @return the translation unit that content assist is invoked in, possibly <code>null</code>
*/
ITranslationUnit getTranslationUnit();
@@ -40,7 +40,7 @@ public interface ICEditorContentAssistInvocationContext {
/**
* Returns the project of the translation unit that content assist is invoked in,
* <code>null</code> if none.
- *
+ *
* @return the current C project, possibly <code>null</code>
*/
ICProject getProject();
@@ -66,45 +66,45 @@ public interface ICEditorContentAssistInvocationContext {
/**
* Get the editor content assist is invoked in.
- *
+ *
* @return the editor, may be <code>null</code>
*/
IEditorPart getEditor();
/**
* Returns the viewer, <code>null</code> if not available.
- *
+ *
* @return the viewer, possibly <code>null</code>
*/
ITextViewer getViewer();
-
+
/**
* Returns the invocation offset.
- *
+ *
* @return the invocation offset
*/
int getInvocationOffset();
-
+
/**
* Returns <code>true</code> if the current content assist invocation
* is for revealing context information, or <code>false</code> otherwise.
- *
+ *
* @return <code>true</code> if the current content assist invocation
* is for revealing context information.
*/
boolean isContextInformationStyle();
-
+
/**
* Returns the document that content assist is invoked on, or <code>null</code> if not known.
- *
+ *
* @return the document or <code>null</code>
*/
IDocument getDocument();
-
+
/**
* Computes the identifier (as specified by {@link Character#isJavaIdentifierPart(char)}) that
* immediately precedes the invocation offset.
- *
+ *
* @return the prefix preceding the content assist invocation offset, <code>null</code> if
* there is no document
* @throws BadLocationException if accessing the document fails
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java
index 112890af15f..d62c0cdbac7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java
@@ -23,7 +23,7 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
/**
* This interface must be implemented by clients extending the extension point
* <tt>org.eclipse.cdt.core.completionContributors</tt>.
- *
+ *
* @deprecated Clients should extend the new extension point
* <tt>completionProprosalComputer</tt> and implement interface
* {@link ICompletionProposalComputer}
@@ -34,7 +34,7 @@ public interface ICompletionContributor {
/**
* This method allows the contributor to add to the list of proposals
- *
+ *
* @param viewer the text viewer where completion is occuring
* @param offset the offset into the text where the completion is occuring
* @param completionNode the completion node produced by the parser for the offset
@@ -42,11 +42,7 @@ public interface ICompletionContributor {
* proposals to this list.
*/
@SuppressWarnings("rawtypes") // no need to change, it's deprecated
- void contributeCompletionProposals(ITextViewer viewer,
- int offset,
- IWorkingCopy workingCopy,
- ASTCompletionNode completionNode,
- String prefix,
- List proposals);
-
+ void contributeCompletionProposals(ITextViewer viewer, int offset, IWorkingCopy workingCopy,
+ ASTCompletionNode completionNode, String prefix, List proposals);
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java
index d4fcc85574c..722844eaf77 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java
@@ -26,7 +26,7 @@ import org.eclipse.jface.text.contentassist.IContextInformation;
* Contributions to the <tt>org.eclipse.cdt.ui.completionProposalComputer</tt> extension point
* must implement this interface.
* </p>
- *
+ *
* @since 4.0
*/
public interface ICompletionProposalComputer {
@@ -41,28 +41,30 @@ public interface ICompletionProposalComputer {
/**
* Returns a list of completion proposals valid at the given invocation context.
- *
+ *
* @param context the context of the content assist invocation
* @param monitor a progress monitor to report progress. The monitor is private to this
* invocation, i.e. there is no need for the receiver to spawn a sub monitor.
* @return a list of completion proposals (element type: {@link ICompletionProposal})
*/
- List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor);
+ List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor);
/**
* Returns context information objects valid at the given invocation context.
- *
+ *
* @param context the context of the content assist invocation
* @param monitor a progress monitor to report progress. The monitor is private to this
* invocation, i.e. there is no need for the receiver to spawn a sub monitor.
* @return a list of context information objects (element type: {@link IContextInformation})
*/
- List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor);
+ List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor);
/**
* Returns the reason why this computer was unable to produce any completion proposals or
* context information.
- *
+ *
* @return an error message or <code>null</code> if no error occurred
*/
String getErrorMessage();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/IProposalFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/IProposalFilter.java
index 763e85fddca..da602ddb43d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/IProposalFilter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/IProposalFilter.java
@@ -15,7 +15,6 @@ package org.eclipse.cdt.ui.text.contentassist;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
-
/**
* Filters completion proposals displayed by the C/C++ editor content assistant.
* <p>
@@ -33,6 +32,6 @@ public interface IProposalFilter {
* @param proposals The List of proposals
* @return The filtered list of proposals as array
*/
- ICCompletionProposal[] filterProposals(ICCompletionProposal[] proposals) ;
+ ICCompletionProposal[] filterProposals(ICCompletionProposal[] proposals);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEditStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEditStrategy.java
index 21d32a5184e..1f57fe499b3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEditStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEditStrategy.java
@@ -51,9 +51,9 @@ import org.eclipse.cdt.ui.text.ICPartitions;
/**
* This class provides default behaviors for multi-line comment auto-editing.
- *
+ *
* This class is intended to be sub-classed.
- *
+ *
* @since 5.0
*/
public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrategy {
@@ -61,10 +61,10 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
protected static final String MULTILINE_MID = " * "; //$NON-NLS-1$
protected static final String MULTILINE_END = "*/"; //$NON-NLS-1$
private static String fgDefaultLineDelim = "\n"; //$NON-NLS-1$
-
+
public DefaultMultilineCommentAutoEditStrategy() {
}
-
+
/**
* @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
*/
@@ -72,12 +72,12 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
public void customizeDocumentCommand(IDocument doc, DocumentCommand cmd) {
fgDefaultLineDelim = TextUtilities.getDefaultLineDelimiter(doc);
if (doc instanceof IDocumentExtension4) {
- boolean forNewLine= cmd.length == 0 && cmd.text != null && endsWithDelimiter(doc, cmd.text);
- boolean forCommentEnd= "/".equals(cmd.text); //$NON-NLS-1$
-
+ boolean forNewLine = cmd.length == 0 && cmd.text != null && endsWithDelimiter(doc, cmd.text);
+ boolean forCommentEnd = "/".equals(cmd.text); //$NON-NLS-1$
+
if (forNewLine || forCommentEnd) {
- IDocumentExtension4 ext4= (IDocumentExtension4) doc;
- DocumentRewriteSession drs= ext4.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED_SMALL);
+ IDocumentExtension4 ext4 = (IDocumentExtension4) doc;
+ DocumentRewriteSession drs = ext4.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED_SMALL);
try {
if (forNewLine) {
customizeDocumentAfterNewLine(doc, cmd);
@@ -90,7 +90,7 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
}
}
}
-
+
/**
* This implements a rule that when in a multi-line comment context typing a forward slash with
* one white space after the "*" will move eliminate the whitespace.
@@ -106,12 +106,12 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
// modify document command
command.length++;
command.offset--;
- }
+ }
} catch (BadLocationException excp) {
// stop work
}
}
-
+
/**
* Copies the indentation of the previous line and adds a star.
* If the comment just started on this line adds also a blank.
@@ -120,39 +120,39 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
* @param c the command to deal with
*/
public void customizeDocumentAfterNewLine(IDocument doc, final DocumentCommand c) {
- int offset= c.offset;
+ int offset = c.offset;
if (offset == -1 || doc.getLength() == 0)
return;
-
+
String lineDelim = TextUtilities.getDefaultLineDelimiter(doc);
- final StringBuilder buf= new StringBuilder(c.text);
+ final StringBuilder buf = new StringBuilder(c.text);
try {
// find start of line
- IRegion line= doc.getLineInformationOfOffset(c.offset);
- int lineStart= line.getOffset();
- int firstNonWS= findEndOfWhiteSpaceAt(doc, lineStart, c.offset);
+ IRegion line = doc.getLineInformationOfOffset(c.offset);
+ int lineStart = line.getOffset();
+ int firstNonWS = findEndOfWhiteSpaceAt(doc, lineStart, c.offset);
- IRegion prefix= findPrefixRange(doc, line);
- String indentation= doc.get(prefix.getOffset(), prefix.getLength());
- int lengthToAdd= Math.min(offset - prefix.getOffset(), prefix.getLength());
+ IRegion prefix = findPrefixRange(doc, line);
+ String indentation = doc.get(prefix.getOffset(), prefix.getLength());
+ int lengthToAdd = Math.min(offset - prefix.getOffset(), prefix.getLength());
buf.append(indentation.substring(0, lengthToAdd));
-
- boolean commentAtStart= firstNonWS < c.offset && doc.getChar(firstNonWS) == '/';
+
+ boolean commentAtStart = firstNonWS < c.offset && doc.getChar(firstNonWS) == '/';
if (commentAtStart) {
// comment started on this line
buf.append(MULTILINE_MID);
}
- c.shiftsCaret= false;
- c.caretOffset= c.offset + buf.length();
+ c.shiftsCaret = false;
+ c.caretOffset = c.offset + buf.length();
if (commentAtStart && shouldCloseMultiline(doc, c.offset)) {
try {
- doc.replace(c.offset, 0, indentation+" "+MULTILINE_END); // close the comment in order to parse //$NON-NLS-1$
+ doc.replace(c.offset, 0, indentation + " " + MULTILINE_END); // close the comment in order to parse //$NON-NLS-1$
buf.append(lineDelim);
// as we are auto-closing, the comment becomes eligible for auto-doc'ing
- IASTDeclaration dec= null;
+ IASTDeclaration dec = null;
IIndex index = null;
ITranslationUnit unit = getTranslationUnitForActiveEditor();
if (unit != null) {
@@ -165,21 +165,22 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
}
try {
IASTTranslationUnit ast = getAST(unit, index);
-
+
if (ast != null) {
- dec= findFollowingDeclaration(ast, offset);
+ dec = findFollowingDeclaration(ast, offset);
if (dec == null) {
- IASTNodeSelector ans= ast.getNodeSelector(ast.getFilePath());
- IASTNode node= ans.findEnclosingNode(offset, 0);
+ IASTNodeSelector ans = ast.getNodeSelector(ast.getFilePath());
+ IASTNode node = ans.findEnclosingNode(offset, 0);
if (node instanceof IASTDeclaration) {
- dec= (IASTDeclaration) node;
+ dec = (IASTDeclaration) node;
}
}
}
-
+
if (dec != null) {
- ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING /* this! */, offset, false);
- StringBuilder content= customizeAfterNewLineForDeclaration(doc, dec, partition);
+ ITypedRegion partition = TextUtilities.getPartition(doc,
+ ICPartitions.C_PARTITIONING /* this! */, offset, false);
+ StringBuilder content = customizeAfterNewLineForDeclaration(doc, dec, partition);
buf.append(indent(content, indentation + MULTILINE_MID, lineDelim));
}
} finally {
@@ -187,28 +188,29 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
index.releaseReadLock();
}
}
- } catch(BadLocationException ble) {
+ } catch (BadLocationException ble) {
CUIPlugin.log(ble);
- } catch(CoreException e) {
+ } catch (CoreException e) {
CUIPlugin.log(e);
}
}
- c.text= buf.toString();
+ c.text = buf.toString();
} catch (BadLocationException excp) {
// stop work
- }
+ }
}
- protected StringBuilder customizeAfterNewLineForDeclaration(IDocument doc, IASTDeclaration dec, ITypedRegion region) {
+ protected StringBuilder customizeAfterNewLineForDeclaration(IDocument doc, IASTDeclaration dec,
+ ITypedRegion region) {
return new StringBuilder();
}
-
+
/*
* Utilities
*/
-
+
/**
* Locates the {@link IASTDeclaration} most immediately following the specified offset
* @param unit the translation unit, or null (in which case the result will also be null)
@@ -217,51 +219,52 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
* is no {@link IASTDeclaration}
*/
public static IASTDeclaration findFollowingDeclaration(IASTTranslationUnit unit, final int offset) {
- final IASTDeclaration[] dec= new IASTDeclaration[1];
- final ASTVisitor av= new ASTVisitor() {
+ final IASTDeclaration[] dec = new IASTDeclaration[1];
+ final ASTVisitor av = new ASTVisitor() {
{
- shouldVisitTranslationUnit= true;
- shouldVisitDeclarations= true;
+ shouldVisitTranslationUnit = true;
+ shouldVisitDeclarations = true;
}
-
+
/**
- * Holds the
+ * Holds the
*/
IASTDeclaration stopWhenLeaving;
-
+
@Override
public int visit(IASTDeclaration declaration) {
- IASTNodeLocation loc= declaration.getFileLocation();
+ IASTNodeLocation loc = declaration.getFileLocation();
if (loc != null) {
- int candidateOffset= loc.getNodeOffset();
- int candidateEndOffset= candidateOffset+loc.getNodeLength();
+ int candidateOffset = loc.getNodeOffset();
+ int candidateEndOffset = candidateOffset + loc.getNodeLength();
if (offset <= candidateOffset) {
- dec[0]= declaration;
+ dec[0] = declaration;
return PROCESS_ABORT;
}
- boolean candidateEnclosesOffset= (offset >= candidateOffset) && (offset < candidateEndOffset);
+ boolean candidateEnclosesOffset = (offset >= candidateOffset) && (offset < candidateEndOffset);
if (candidateEnclosesOffset) {
- stopWhenLeaving= declaration;
+ stopWhenLeaving = declaration;
}
}
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTDeclaration declaration) {
- if (declaration == stopWhenLeaving)
+ if (declaration == stopWhenLeaving)
return PROCESS_ABORT;
return PROCESS_CONTINUE;
}
};
-
+
if (unit != null) {
unit.accept(av);
}
return dec[0];
}
-
+
/**
* @return the AST unit for the active editor, not based on an index, or <code>null</code> if there
* is no active editor, or the AST could not be obtained.
@@ -269,16 +272,16 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
public IASTTranslationUnit getAST() {
return getAST(getTranslationUnitForActiveEditor(), null);
}
-
+
/**
- * @return the AST for the given translation unit, based on the given index, or <code>null</code> if
+ * @return the AST for the given translation unit, based on the given index, or <code>null</code> if
* the translation unit is <code>null</code>, or the AST could not be obtained.
* @since 5.10
*/
public IASTTranslationUnit getAST(ITranslationUnit unit, IIndex index) {
try {
if (unit != null) {
- IASTTranslationUnit ast= unit.getAST(index, ITranslationUnit.AST_SKIP_ALL_HEADERS);
+ IASTTranslationUnit ast = unit.getAST(index, ITranslationUnit.AST_SKIP_ALL_HEADERS);
return ast;
}
} catch (CModelException e) {
@@ -303,20 +306,20 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
*/
public boolean shouldCloseMultiline(IDocument document, int offset) {
try {
- IRegion line= document.getLineInformationOfOffset(offset);
- ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
- int partitionEnd= partition.getOffset() + partition.getLength();
+ IRegion line = document.getLineInformationOfOffset(offset);
+ ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
+ int partitionEnd = partition.getOffset() + partition.getLength();
if (line.getOffset() >= partitionEnd)
return false;
- String comment= document.get(partition.getOffset(), partition.getLength());
- if (comment.indexOf(MULTILINE_START, offset - partition.getOffset()) != -1)
+ String comment = document.get(partition.getOffset(), partition.getLength());
+ if (comment.indexOf(MULTILINE_START, offset - partition.getOffset()) != -1)
return true; // enclosed another comment -> probably a new comment
if (document.getLength() == partitionEnd) {
return !comment.endsWith(MULTILINE_END);
}
-
+
return false;
} catch (BadLocationException e) {
@@ -331,26 +334,26 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
*/
@Deprecated
protected static ITranslationUnit getTranslationUnit() {
- IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null)
return null;
- IWorkbenchPage page= window.getActivePage();
+ IWorkbenchPage page = window.getActivePage();
if (page == null)
return null;
- IEditorPart editor= page.getActiveEditor();
+ IEditorPart editor = page.getActiveEditor();
if (editor == null)
return null;
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
- ITranslationUnit unit= manager.getWorkingCopy(editor.getEditorInput());
+ IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+ ITranslationUnit unit = manager.getWorkingCopy(editor.getEditorInput());
if (unit == null)
return null;
return unit;
}
-
+
/**
* Same as above, but nonstatic so derived classes can override it.
* @since 5.10
@@ -358,41 +361,41 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
protected ITranslationUnit getTranslationUnitForActiveEditor() {
return getTranslationUnit();
}
-
+
/**
* Returns a new buffer with the specified indent string inserted at the beginning
* of each line in the specified input buffer
* @param buffer
* @param indent
- * @param lineDelim
+ * @param lineDelim
* @since 5.3
*/
protected static final StringBuilder indent(StringBuilder buffer, String indent, String lineDelim) {
- StringBuilder result= new StringBuilder();
- BufferedReader br= new BufferedReader(new StringReader(buffer.toString()));
+ StringBuilder result = new StringBuilder();
+ BufferedReader br = new BufferedReader(new StringReader(buffer.toString()));
try {
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
result.append(indent).append(line).append(lineDelim);
}
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
throw new AssertionError(); // we can't get IO errors from a string backed reader
}
return result;
}
-
+
/**
* Returns a new buffer with the specified indent string inserted at the beginning
* of each line in the specified input buffer
* @param buffer
* @param indent
- *
+ *
* @deprecated Use {{@link #indent(StringBuilder, String, String)} instead.
*/
@Deprecated
protected static final StringBuilder indent(StringBuilder buffer, String indent) {
return indent(buffer, indent, fgDefaultLineDelim);
}
-
+
/**
* Returns the offset of the first non-whitespace character in the specified document, searching
* right/downward from the specified start offset up to the specified end offset. If there is
@@ -404,7 +407,7 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
*/
protected static int findEndOfWhiteSpaceAt(IDocument document, int offset, int end) throws BadLocationException {
while (offset < end) {
- char c= document.getChar(offset);
+ char c = document.getChar(offset);
if (c != ' ' && c != '\t') {
return offset;
}
@@ -412,7 +415,7 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
}
return end;
}
-
+
/**
* Returns the range of the comment prefix on the given line in
* <code>document</code>. The prefix greedily matches the following regex
@@ -427,9 +430,9 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
* @throws BadLocationException if accessing the document fails
*/
protected static IRegion findPrefixRange(IDocument document, IRegion line) throws BadLocationException {
- int lineOffset= line.getOffset();
- int lineEnd= lineOffset + line.getLength();
- int indentEnd= findEndOfWhiteSpaceAt(document, lineOffset, lineEnd);
+ int lineOffset = line.getOffset();
+ int lineEnd = lineOffset + line.getLength();
+ int indentEnd = findEndOfWhiteSpaceAt(document, lineOffset, lineEnd);
if (indentEnd < lineEnd && document.getChar(indentEnd) == '*') {
indentEnd++;
while (indentEnd < lineEnd && !isWhitespace(document.getChar(indentEnd)))
@@ -439,7 +442,7 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
}
return new Region(lineOffset, indentEnd - lineOffset);
}
-
+
private static boolean isWhitespace(char ch) {
return ch == ' ' || ch == '\t';
}
@@ -449,8 +452,8 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
* legal line delimiters.
*/
protected static boolean endsWithDelimiter(IDocument d, String txt) {
- String[] delimiters= d.getLegalLineDelimiters();
- for (int i= 0; i < delimiters.length; i++) {
+ String[] delimiters = d.getLegalLineDelimiters();
+ for (int i = 0; i < delimiters.length; i++) {
if (txt.endsWith(delimiters[i]))
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.java
index eadefeee731..48bb2516881 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.java
@@ -20,4 +20,5 @@ package org.eclipse.cdt.ui.text.doctools;
* will be available in the future.
* @since 5.0
*/
-public interface IDocCommentDictionary {}
+public interface IDocCommentDictionary {
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.java
index 083c83bfaf6..8bf081d6c9e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.java
@@ -16,7 +16,7 @@ package org.eclipse.cdt.ui.text.doctools;
/**
* A comment owner provides {@link IDocCommentViewerConfiguration} to
* the CDT c/c++ editor.<p>
- *
+ *
* In future it may also provide a point for providing
* <ul>
* <li>access an implementation of a documentation comment validation mechanism
@@ -24,17 +24,17 @@ package org.eclipse.cdt.ui.text.doctools;
* <li>information for code generation e.g. default single and multi-line comment
* delimiting prefix/post-fixes
* </ul>
- *
+ *
* @since 5.0
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IDocCommentOwner {
/**
* @return the non-null unique identifier for this comment owner. If contributed via the
- * extension point, the ID corresponds to that in plugin.xml.
+ * extension point, the ID corresponds to that in plugin.xml.
*/
String getID();
-
+
/**
* @return a non-null human-readable name for this comment owner. If contributed via plugin.xml
* this name can be localized using the plug-in externalization mechanism.
@@ -45,7 +45,7 @@ public interface IDocCommentOwner {
* @return a non-null {@link IDocCommentViewerConfiguration} suitable for a multi-line comment context
*/
IDocCommentViewerConfiguration getMultilineConfiguration();
-
+
/**
* @return a non-null {@link IDocCommentViewerConfiguration} suitable for a single-line comment context
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.java
index 9ad99166c56..1b8436e3365 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.java
@@ -28,8 +28,9 @@ public interface IDocCommentOwnershipListener {
* @param oldOwner the previous document comment owner
* @param newOwner the new document comment owner
*/
- public void ownershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner, IDocCommentOwner newOwner);
-
+ public void ownershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner,
+ IDocCommentOwner newOwner);
+
/**
* Called when workspace-scope document comment owner changes.
* @param oldOwner the previous document comment owner
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.java
index 6d46710470c..642e2ff22ac 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.java
@@ -14,7 +14,7 @@
package org.eclipse.cdt.ui.text.doctools;
/**
- * This interface is a simplified means of obtaining spelling support.
+ * This interface is a simplified means of obtaining spelling support.
* @since 5.0
*/
public interface IDocCommentSimpleDictionary extends IDocCommentDictionary {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java
index 4e69e25f562..e15458b43a8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java
@@ -24,9 +24,9 @@ import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
/**
* An IDocCommentViewerConfiguration aggregates a collection of editor tools that can be contributed to
- * the CDT editor. The tools will be active for CEditor partitions of type {@link ICPartitions#C_MULTI_LINE_DOC_COMMENT} or
+ * the CDT editor. The tools will be active for CEditor partitions of type {@link ICPartitions#C_MULTI_LINE_DOC_COMMENT} or
* {@link ICPartitions#C_SINGLE_LINE_DOC_COMMENT} when the {@link IDocCommentOwner} this instance originated from is active.
- *
+ *
* @see org.eclipse.jface.text.source.SourceViewerConfiguration (in analogy to)
* @since 5.0
*/
@@ -38,30 +38,30 @@ public interface IDocCommentViewerConfiguration {
* @return whether the region specified is a documentation comment handled by this viewer configuration
*/
boolean isDocumentationComment(IDocument doc, int offset, int length);
-
+
/**
* @return a ICTokenScanner for tokenising/coloring the appropriate comment region. May return null.
*/
ICTokenScanner createCommentScanner(ITokenStoreFactory tokenStoreFactory);
-
+
/**
* @return an auto edit strategy suitable for the appropriate comment region. May return null
* in the case where no auto-edit-strategy is required.
*/
IAutoEditStrategy createAutoEditStrategy();
-
+
/**
* @return a double click strategy suitable for the associated comment-region. May return null in
* the case where no double-click-strategy is required.
*/
ITextDoubleClickStrategy createDoubleClickStrategy();
-
+
/**
* @return a completion proposal computer suitable for the associated comment-region. May return null in
* the case where no proposal-computer is required.
*/
ICompletionProposalComputer createProposalComputer();
-
+
/**
* @return a {@link IDocCommentDictionary} suitable for spell-checking. May return null
* in the case where no additional dictionary is required.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java
index 9ec37e79ace..07c478cadd3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java
@@ -12,6 +12,7 @@
* Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.ui.text.doctools.doxygen;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -34,54 +35,55 @@ import org.eclipse.cdt.ui.text.doctools.generic.GenericDocTag;
* @noextend This class is not intended to be subclassed by clients.
*/
public class DoxygenHelper extends AbstractPreferenceInitializer {
- private static final IPath TAGS_CSV= new Path("doxygenTags.csv"); //$NON-NLS-1$
+ private static final IPath TAGS_CSV = new Path("doxygenTags.csv"); //$NON-NLS-1$
private static GenericDocTag[] fTags;
/**
* @deprecated Use {@link PreferenceConstants#DOXYGEN_TAG_COLOR} instead.
*/
@Deprecated
- public static final String DOXYGEN_TAG_RECOGNIZED= PreferenceConstants.DOXYGEN_TAG_COLOR;
+ public static final String DOXYGEN_TAG_RECOGNIZED = PreferenceConstants.DOXYGEN_TAG_COLOR;
/**
* @deprecated Use {@link PreferenceConstants#DOXYGEN_SINGLE_LINE_COLOR} instead.
*/
@Deprecated
- public static final String DOXYGEN_SINGLE_TOKEN= PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR;
+ public static final String DOXYGEN_SINGLE_TOKEN = PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR;
/**
* @deprecated Use {@link PreferenceConstants#DOXYGEN_MULTI_LINE_COLOR} instead.
*/
@Deprecated
- public static final String DOXYGEN_MULTI_TOKEN= PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR;
+ public static final String DOXYGEN_MULTI_TOKEN = PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR;
/**
* @return The tags which are understood by default by the doxygen tool.
*/
public static GenericDocTag[] getDoxygenTags() {
- if(fTags==null) {
+ if (fTags == null) {
InputStream is = null;
try {
- List<GenericDocTag> temp= new ArrayList<GenericDocTag>();
- is= FileLocator.openStream(CUIPlugin.getDefault().getBundle(), TAGS_CSV, false);
- BufferedReader br= new BufferedReader(new InputStreamReader(is));
- StringBuilder content= new StringBuilder(2000);
- for(String line= br.readLine(); line!=null; line= br.readLine()) {
+ List<GenericDocTag> temp = new ArrayList<GenericDocTag>();
+ is = FileLocator.openStream(CUIPlugin.getDefault().getBundle(), TAGS_CSV, false);
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ StringBuilder content = new StringBuilder(2000);
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
content.append(line).append('\n');
}
content.append("dummy-for-split"); //$NON-NLS-1$
- String[] values= content.toString().split("(\\s)*,(\\s)*"); //$NON-NLS-1$
+ String[] values = content.toString().split("(\\s)*,(\\s)*"); //$NON-NLS-1$
- for(int i=0; i+1<values.length; i+=2) {
- temp.add(new GenericDocTag(values[i], values[i+1]));
+ for (int i = 0; i + 1 < values.length; i += 2) {
+ temp.add(new GenericDocTag(values[i], values[i + 1]));
}
- fTags= temp.toArray(new GenericDocTag[temp.size()]);
- } catch(IOException ioe) {
- fTags= new GenericDocTag[0];
+ fTags = temp.toArray(new GenericDocTag[temp.size()]);
+ } catch (IOException ioe) {
+ fTags = new GenericDocTag[0];
CUIPlugin.log(ioe);
} finally {
if (is != null) {
try {
is.close();
- } catch (IOException exc) {}
+ } catch (IOException exc) {
+ }
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java
index e106fa26780..888817d0238 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java
@@ -46,7 +46,7 @@ import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy;
/**
* {@link IAutoEditStrategy} for adding Doxygen tags for comments.
- *
+ *
* @since 5.0
* @noextend This class is not intended to be subclassed by clients.
*/
@@ -55,39 +55,39 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
private static final String PARAM = "@param "; //$NON-NLS-1$
private static final String RETURN = "@return"; //$NON-NLS-1$
- protected boolean documentPureVirtuals= true;
- protected boolean documentDeclarations= true;
-
+ protected boolean documentPureVirtuals = true;
+ protected boolean documentDeclarations = true;
+
private String fLineDelimiter;
-
+
public DoxygenMultilineAutoEditStrategy() {
}
-
+
/**
* @param decl the function declarator to document
* @param ds the function specifier to document
* @return content describing the specified function
*/
protected StringBuilder documentFunction(IASTFunctionDeclarator decl, IASTDeclSpecifier ds) {
- StringBuilder result= new StringBuilder();
-
+ StringBuilder result = new StringBuilder();
+
result.append(documentFunctionParameters(getParameterDecls(decl)));
-
- boolean hasReturn= true;
- if(ds instanceof IASTSimpleDeclSpecifier) {
- IASTSimpleDeclSpecifier sds= (IASTSimpleDeclSpecifier) ds;
- if(sds.getType() == IASTSimpleDeclSpecifier.t_void ||
- sds.getType() == IASTSimpleDeclSpecifier.t_unspecified) {
- hasReturn= false;
+
+ boolean hasReturn = true;
+ if (ds instanceof IASTSimpleDeclSpecifier) {
+ IASTSimpleDeclSpecifier sds = (IASTSimpleDeclSpecifier) ds;
+ if (sds.getType() == IASTSimpleDeclSpecifier.t_void
+ || sds.getType() == IASTSimpleDeclSpecifier.t_unspecified) {
+ hasReturn = false;
}
}
- if(hasReturn) {
+ if (hasReturn) {
result.append(documentFunctionReturn());
}
return result;
}
-
+
/**
* Returns the comment content to add to the documentation comment.
* @param decls The parameter declarations to describe
@@ -95,19 +95,19 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
* the specified {@link IASTParameterDeclaration} objects.
*/
protected StringBuilder documentFunctionParameters(IASTParameterDeclaration[] decls) {
- StringBuilder result= new StringBuilder();
- for(int i=0; i<decls.length; i++) {
- if(!isVoidParameter(decls[i])) {
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < decls.length; i++) {
+ if (!isVoidParameter(decls[i])) {
result.append(PARAM).append(getParameterName(decls[i])).append(getLineDelimiter());
}
}
return result;
}
-
+
/**
* Get the default line delimiter for the currently customized document
* which should be used for new lines.
- *
+ *
* @return the default line delimiter
*/
private String getLineDelimiter() {
@@ -119,23 +119,24 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
* @return the name of the parameter
*/
String getParameterName(IASTParameterDeclaration decl) {
- IASTDeclarator dtor= decl.getDeclarator();
- for(int i=0; i<8 && dtor.getName().getRawSignature().length()==0 && dtor.getNestedDeclarator() != null; i++) {
- dtor= dtor.getNestedDeclarator();
+ IASTDeclarator dtor = decl.getDeclarator();
+ for (int i = 0; i < 8 && dtor.getName().getRawSignature().length() == 0
+ && dtor.getNestedDeclarator() != null; i++) {
+ dtor = dtor.getNestedDeclarator();
}
return dtor.getName().getRawSignature();
}
-
+
/**
* @param decl
* @return true if the specified parameter declaration is of void type
*/
boolean isVoidParameter(IASTParameterDeclaration decl) {
- if(decl.getDeclSpecifier() instanceof IASTSimpleDeclSpecifier) {
- if(((IASTSimpleDeclSpecifier)decl.getDeclSpecifier()).getType() == IASTSimpleDeclSpecifier.t_void) {
- IASTDeclarator dtor= decl.getDeclarator();
- if(dtor.getPointerOperators().length == 0) {
- if(!(dtor instanceof IASTFunctionDeclarator) && !(dtor instanceof IASTArrayDeclarator)) {
+ if (decl.getDeclSpecifier() instanceof IASTSimpleDeclSpecifier) {
+ if (((IASTSimpleDeclSpecifier) decl.getDeclSpecifier()).getType() == IASTSimpleDeclSpecifier.t_void) {
+ IASTDeclarator dtor = decl.getDeclarator();
+ if (dtor.getPointerOperators().length == 0) {
+ if (!(dtor instanceof IASTFunctionDeclarator) && !(dtor instanceof IASTArrayDeclarator)) {
return true;
}
}
@@ -158,13 +159,13 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
protected IASTParameterDeclaration[] getParameterDecls(IASTFunctionDeclarator decl) {
IASTParameterDeclaration[] result;
if (decl instanceof IASTStandardFunctionDeclarator) {
- IASTStandardFunctionDeclarator standardFunctionDecl= (IASTStandardFunctionDeclarator)decl;
- result= standardFunctionDecl.getParameters();
+ IASTStandardFunctionDeclarator standardFunctionDecl = (IASTStandardFunctionDeclarator) decl;
+ result = standardFunctionDecl.getParameters();
} else /*if (def instanceof ICASTKnRFunctionDeclarator) {
- ICASTKnRFunctionDeclarator knrDeclarator= (ICASTKnRFunctionDeclarator)decl;
- result= knrDeclarator.getParameterDeclarations();
- } else */{
- result= new IASTParameterDeclaration[0];
+ ICASTKnRFunctionDeclarator knrDeclarator= (ICASTKnRFunctionDeclarator)decl;
+ result= knrDeclarator.getParameterDeclarations();
+ } else */ {
+ result = new IASTParameterDeclaration[0];
}
return result;
}
@@ -173,20 +174,21 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
* @see org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy#customizeAfterNewLineForDeclaration(org.eclipse.jface.text.IDocument, org.eclipse.cdt.core.dom.ast.IASTDeclaration, org.eclipse.jface.text.ITypedRegion)
*/
@Override
- protected StringBuilder customizeAfterNewLineForDeclaration(IDocument doc, IASTDeclaration dec, ITypedRegion partition) {
+ protected StringBuilder customizeAfterNewLineForDeclaration(IDocument doc, IASTDeclaration dec,
+ ITypedRegion partition) {
fLineDelimiter = TextUtilities.getDefaultLineDelimiter(doc);
IASTDeclaration declToDocument = dec;
-
- if(declToDocument instanceof ICPPASTLinkageSpecification) {
- ICPPASTLinkageSpecification linkageSpecification = (ICPPASTLinkageSpecification)declToDocument;
+
+ if (declToDocument instanceof ICPPASTLinkageSpecification) {
+ ICPPASTLinkageSpecification linkageSpecification = (ICPPASTLinkageSpecification) declToDocument;
IASTDeclaration[] declarations = linkageSpecification.getDeclarations();
-
- if(declarations.length == 1) {
-
+
+ if (declarations.length == 1) {
+
boolean isCurlyExtern = false;
IToken token = null;
-
+
try {
token = declarations[0].getTrailingSyntax();
} catch (UnsupportedOperationException e) {
@@ -194,42 +196,42 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
} catch (ExpansionOverlapsBoundaryException e) {
return new StringBuilder();
}
-
- if(token != null && token.getType() == IToken.tRBRACE) {
+
+ if (token != null && token.getType() == IToken.tRBRACE) {
isCurlyExtern = true;
}
-
- if(!isCurlyExtern) {
- declToDocument = declarations[0];
+
+ if (!isCurlyExtern) {
+ declToDocument = declarations[0];
}
}
}
-
- while(declToDocument instanceof ICPPASTTemplateDeclaration) /* if? */
- declToDocument= ((ICPPASTTemplateDeclaration)declToDocument).getDeclaration();
- if(declToDocument instanceof IASTFunctionDefinition) {
- IASTFunctionDefinition fd= (IASTFunctionDefinition) declToDocument;
+ while (declToDocument instanceof ICPPASTTemplateDeclaration) /* if? */
+ declToDocument = ((ICPPASTTemplateDeclaration) declToDocument).getDeclaration();
+
+ if (declToDocument instanceof IASTFunctionDefinition) {
+ IASTFunctionDefinition fd = (IASTFunctionDefinition) declToDocument;
return documentFunction(fd.getDeclarator(), fd.getDeclSpecifier());
}
- if(declToDocument instanceof IASTSimpleDeclaration) {
- IASTSimpleDeclaration sdec= (IASTSimpleDeclaration) declToDocument;
- StringBuilder result= new StringBuilder();
-
- if(sdec.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier) {
+ if (declToDocument instanceof IASTSimpleDeclaration) {
+ IASTSimpleDeclaration sdec = (IASTSimpleDeclaration) declToDocument;
+ StringBuilder result = new StringBuilder();
+
+ if (sdec.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier) {
return result;
} else {
- IASTDeclarator[] dcs= sdec.getDeclarators();
- if(dcs.length == 1 && dcs[0] instanceof IASTFunctionDeclarator) {
- IASTFunctionDeclarator fdecl = (IASTFunctionDeclarator)dcs[0];
- boolean shouldDocument= documentDeclarations;
- if(documentPureVirtuals && dcs[0] instanceof ICPPASTFunctionDeclarator) {
- ICPPASTFunctionDeclarator cppfdecl= (ICPPASTFunctionDeclarator) dcs[0];
+ IASTDeclarator[] dcs = sdec.getDeclarators();
+ if (dcs.length == 1 && dcs[0] instanceof IASTFunctionDeclarator) {
+ IASTFunctionDeclarator fdecl = (IASTFunctionDeclarator) dcs[0];
+ boolean shouldDocument = documentDeclarations;
+ if (documentPureVirtuals && dcs[0] instanceof ICPPASTFunctionDeclarator) {
+ ICPPASTFunctionDeclarator cppfdecl = (ICPPASTFunctionDeclarator) dcs[0];
shouldDocument = shouldDocument || cppfdecl.isPureVirtual();
}
-
- if(shouldDocument) {
+
+ if (shouldDocument) {
return documentFunction(fdecl, sdec.getDeclSpecifier());
}
}
@@ -238,7 +240,7 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
try {
alterDoc(doc, declToDocument);
- } catch(BadLocationException ble) {
+ } catch (BadLocationException ble) {
/*ignore*/
}
@@ -249,42 +251,46 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
* Add post-declaration comments to enumerators, after initializing a doc-comment on an enumeration
*/
private void alterDoc(IDocument doc, IASTDeclaration dec) throws BadLocationException {
- if(dec instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration)dec).getDeclSpecifier() instanceof IASTEnumerationSpecifier) {
- IASTEnumerationSpecifier spc= (IASTEnumerationSpecifier) ((IASTSimpleDeclaration)dec).getDeclSpecifier();
- IASTEnumerator[] enms= spc.getEnumerators();
+ if (dec instanceof IASTSimpleDeclaration
+ && ((IASTSimpleDeclaration) dec).getDeclSpecifier() instanceof IASTEnumerationSpecifier) {
+ IASTEnumerationSpecifier spc = (IASTEnumerationSpecifier) ((IASTSimpleDeclaration) dec).getDeclSpecifier();
+ IASTEnumerator[] enms = spc.getEnumerators();
class Entry {
final int offset, length;
StringBuilder comment;
+
Entry(int offset, int length, String comment) {
- this.offset= offset;
- this.length= length;
- this.comment= new StringBuilder(comment);
+ this.offset = offset;
+ this.length = length;
+ this.comment = new StringBuilder(comment);
}
+
@Override
public int hashCode() {
return offset;
}
+
@Override
public boolean equals(Object obj) {
- if(obj instanceof Entry) {
- Entry other= (Entry) obj;
+ if (obj instanceof Entry) {
+ Entry other = (Entry) obj;
return offset == other.offset;
}
return false;
}
}
- boolean noCollisions= true;
- LinkedHashSet<Entry> entries= new LinkedHashSet<Entry>();
- for(IASTEnumerator enumerator : enms) {
- IASTNodeLocation loc= enumerator.getName().getFileLocation();
- if(loc != null) {
- int nodeOffset= loc.getNodeOffset()+loc.getNodeLength();
- String cmt= SINGLELINE_COMMENT_PRECEDING+enumerator.getName();
- IRegion line= doc.getLineInformationOfOffset(nodeOffset);
- if(!doc.get(line.getOffset(), line.getLength()).contains("//")) { //$NON-NLS-1$
- noCollisions &= entries.add(new Entry(line.getOffset(),line.getLength(), cmt));
+ boolean noCollisions = true;
+ LinkedHashSet<Entry> entries = new LinkedHashSet<Entry>();
+ for (IASTEnumerator enumerator : enms) {
+ IASTNodeLocation loc = enumerator.getName().getFileLocation();
+ if (loc != null) {
+ int nodeOffset = loc.getNodeOffset() + loc.getNodeLength();
+ String cmt = SINGLELINE_COMMENT_PRECEDING + enumerator.getName();
+ IRegion line = doc.getLineInformationOfOffset(nodeOffset);
+ if (!doc.get(line.getOffset(), line.getLength()).contains("//")) { //$NON-NLS-1$
+ noCollisions &= entries.add(new Entry(line.getOffset(), line.getLength(), cmt));
}
}
}
@@ -292,22 +298,22 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
/*
* Only auto-insert comments if each enumerator is declared on a unique line
*/
- if(noCollisions) {
- int max= Integer.MIN_VALUE;
- for(Entry e : entries) {
- if(e.length > max)
- max= e.length;
+ if (noCollisions) {
+ int max = Integer.MIN_VALUE;
+ for (Entry e : entries) {
+ if (e.length > max)
+ max = e.length;
}
- int addedLength=0;
- for(Entry e : entries) {
+ int addedLength = 0;
+ for (Entry e : entries) {
// pad with whitespace
- int toAdd= max-e.length;
- for(int j=0; j<toAdd; j++) {
+ int toAdd = max - e.length;
+ for (int j = 0; j < toAdd; j++) {
e.comment.insert(0, " "); //$NON-NLS-1$
}
- doc.replace(e.offset+e.length+addedLength, 0, e.comment.toString());
- addedLength+= e.comment.length();
+ doc.replace(e.offset + e.length + addedLength, 0, e.comment.toString());
+ addedLength += e.comment.length();
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java
index 46faa4a4be7..9047ac6689b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java
@@ -33,7 +33,8 @@ public class DoxygenMultilineConfiguration extends AbstractGenericTagDocCommentV
* Default constructor
*/
public DoxygenMultilineConfiguration() {
- super(DoxygenHelper.getDoxygenTags(), new char[] {'@','\\'}, PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR, PreferenceConstants.DOXYGEN_TAG_COLOR);
+ super(DoxygenHelper.getDoxygenTags(), new char[] { '@', '\\' }, PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR,
+ PreferenceConstants.DOXYGEN_TAG_COLOR);
}
/**
@@ -44,7 +45,8 @@ public class DoxygenMultilineConfiguration extends AbstractGenericTagDocCommentV
* @param tagToken the scanner token to use to mark used by this configuration
* @see AbstractGenericTagDocCommentViewerConfiguration
*/
- protected DoxygenMultilineConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken, String tagToken) {
+ protected DoxygenMultilineConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken,
+ String tagToken) {
super(tags, tagMarkers, defaultToken, tagToken);
}
@@ -62,11 +64,11 @@ public class DoxygenMultilineConfiguration extends AbstractGenericTagDocCommentV
@Override
public boolean isDocumentationComment(IDocument doc, int offset, int length) {
try {
- if(offset+2 < doc.getLength()) {
- char c= doc.getChar(offset+2);
+ if (offset + 2 < doc.getLength()) {
+ char c = doc.getChar(offset + 2);
return c == '*' || c == '!';
}
- } catch(BadLocationException ble) {
+ } catch (BadLocationException ble) {
CUIPlugin.log(ble);
}
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java
index e7059e7d938..4f354e34ef6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.text.doctools.doxygen;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.DocumentRewriteSession;
@@ -40,160 +39,150 @@ import org.eclipse.cdt.ui.text.ICPartitions;
* @noextend This class is not intended to be subclassed by clients.
*/
public class DoxygenSingleAutoEditStrategy extends DoxygenMultilineAutoEditStrategy {
- private static final String SLASH_COMMENT = "///"; //$NON-NLS-1$
- private static final String EXCL_COMMENT = "//!"; //$NON-NLS-1$
- private static String fgDefaultLineDelim = "\n"; //$NON-NLS-1$
-
+ private static final String SLASH_COMMENT = "///"; //$NON-NLS-1$
+ private static final String EXCL_COMMENT = "//!"; //$NON-NLS-1$
+ private static String fgDefaultLineDelim = "\n"; //$NON-NLS-1$
- public DoxygenSingleAutoEditStrategy() {
- }
+ public DoxygenSingleAutoEditStrategy() {
+ }
- /**
- * @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
- */
- @Override
+ /**
+ * @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
+ */
+ @Override
public void customizeDocumentCommand(IDocument doc, DocumentCommand cmd) {
- fgDefaultLineDelim = TextUtilities.getDefaultLineDelimiter(doc);
- if(doc instanceof IDocumentExtension4) {
- boolean forNewLine= cmd.length == 0 && cmd.text != null && endsWithDelimiter(doc, cmd.text);
-
- if(forNewLine ) {
- IDocumentExtension4 ext4= (IDocumentExtension4) doc;
- DocumentRewriteSession drs= ext4.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED_SMALL);
- try {
- customizeDocumentAfterNewLine(doc, cmd);
- } finally {
- ext4.stopRewriteSession(drs);
- }
- }
- }
- }
-
- @Override
+ fgDefaultLineDelim = TextUtilities.getDefaultLineDelimiter(doc);
+ if (doc instanceof IDocumentExtension4) {
+ boolean forNewLine = cmd.length == 0 && cmd.text != null && endsWithDelimiter(doc, cmd.text);
+
+ if (forNewLine) {
+ IDocumentExtension4 ext4 = (IDocumentExtension4) doc;
+ DocumentRewriteSession drs = ext4.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED_SMALL);
+ try {
+ customizeDocumentAfterNewLine(doc, cmd);
+ } finally {
+ ext4.stopRewriteSession(drs);
+ }
+ }
+ }
+ }
+
+ @Override
public void customizeDocumentAfterNewLine(IDocument doc, final DocumentCommand c) {
- int offset= c.offset;
- if (offset == -1 || doc.getLength() == 0)
- return;
-
- final StringBuilder buf= new StringBuilder(c.text);
- try {
- IRegion line= doc.getLineInformationOfOffset(c.offset);
- String lineDelimiter = doc.getLineDelimiter(doc.getLineOfOffset(c.offset));
- int lineDelimiterLength = lineDelimiter.length();
-
-
- IRegion prefix= findPrefixRange(doc, line);
- String indentationWithPrefix = doc.get(prefix.getOffset(), prefix.getLength());
- String commentPrefix = getCommentPrefix(indentationWithPrefix);
- String commentContent = doc.get(prefix.getOffset() + prefix.getLength(),
- line.getLength() - prefix.getLength());
- //String commentContentBeforeCursor = doc.get(prefix.getOffset() + prefix.getLength(),
- // c.offset - line.getOffset() - prefix.getLength());
- String commentContentBehindCursor = doc.get(c.offset,
- line.getLength() - (c.offset - line.getOffset()));
-
- buf.append(indentationWithPrefix);
-
-
- boolean commentAtStart = prefix.getOffset() + prefix.getLength() <= c.offset;
- boolean commentFollows = false;
- boolean commentAhead = false;
- boolean firstLineContainsText = commentContent.trim().length() > 0;
-
- if (commentAtStart) {
- if (line.getOffset() + line.getLength() + lineDelimiterLength < doc.getLength())
- {
- IRegion nextLine = doc.getLineInformationOfOffset(line.getOffset() + line.getLength() + lineDelimiterLength);
- commentFollows = doc.get(nextLine.getOffset(), nextLine.getLength()).trim().startsWith(commentPrefix);
-
- if (line.getOffset() >= 1)
- {
- IRegion previousLine = doc.getLineInformationOfOffset(line.getOffset() - 1);
- commentAhead = doc.get(previousLine.getOffset(), previousLine.getLength()).trim().startsWith(commentPrefix);
- }
- }
- // comment started on this line
- buf.append(" "); //$NON-NLS-1$
- }
-
- c.shiftsCaret= false;
- c.caretOffset= c.offset + buf.length();
-
- if(commentAtStart && !commentFollows && !commentAhead) {
- try {
- StringBuilder content = getDeclarationLines(doc, offset);
-
- boolean contentAlreadyThere = (firstLineContainsText && content != null && content.toString().contains(commentContentBehindCursor.trim()));
- if (content == null || content.toString().trim().length() == 0 || contentAlreadyThere)
- {
- buf.setLength(0);
- buf.append(fgDefaultLineDelim);
- buf.append(indentationWithPrefix).append(' ');
- c.shiftsCaret= false;
- c.caretOffset= c.offset + buf.length();
- } else {
- if (!firstLineContainsText)
- {
- c.shiftsCaret= false;
- c.caretOffset= c.offset + 1;
- buf.setLength(0);
- buf.append(' ').append(
- indent(content, indentationWithPrefix + " ", //$NON-NLS-1$
- fgDefaultLineDelim).substring((indentationWithPrefix + " ").length())); //$NON-NLS-1$
- }
- else
- {
- buf.append(fgDefaultLineDelim);
- buf.append(indent(content, indentationWithPrefix + " ", fgDefaultLineDelim)); //$NON-NLS-1$
- }
-
- buf.setLength(buf.length() - fgDefaultLineDelim.length());
- }
- } catch(BadLocationException ble) {
- ble.printStackTrace();
- }
- }
-
- c.text= buf.toString();
-
- } catch (BadLocationException excp) {
- }
- }
-
- private StringBuilder getDeclarationLines(IDocument doc, int offset)
- throws BadLocationException {
- IASTDeclaration dec= null;
- IASTTranslationUnit ast= getAST();
-
- if(ast != null) {
- dec= findFollowingDeclaration(ast, offset);
- if(dec == null) {
- IASTNodeSelector ans= ast.getNodeSelector(ast.getFilePath());
- IASTNode node= ans.findEnclosingNode(offset, 0);
- if(node instanceof IASTDeclaration) {
- dec= (IASTDeclaration) node;
- }
- }
+ int offset = c.offset;
+ if (offset == -1 || doc.getLength() == 0)
+ return;
+
+ final StringBuilder buf = new StringBuilder(c.text);
+ try {
+ IRegion line = doc.getLineInformationOfOffset(c.offset);
+ String lineDelimiter = doc.getLineDelimiter(doc.getLineOfOffset(c.offset));
+ int lineDelimiterLength = lineDelimiter.length();
+
+ IRegion prefix = findPrefixRange(doc, line);
+ String indentationWithPrefix = doc.get(prefix.getOffset(), prefix.getLength());
+ String commentPrefix = getCommentPrefix(indentationWithPrefix);
+ String commentContent = doc.get(prefix.getOffset() + prefix.getLength(),
+ line.getLength() - prefix.getLength());
+ //String commentContentBeforeCursor = doc.get(prefix.getOffset() + prefix.getLength(),
+ // c.offset - line.getOffset() - prefix.getLength());
+ String commentContentBehindCursor = doc.get(c.offset, line.getLength() - (c.offset - line.getOffset()));
+
+ buf.append(indentationWithPrefix);
+
+ boolean commentAtStart = prefix.getOffset() + prefix.getLength() <= c.offset;
+ boolean commentFollows = false;
+ boolean commentAhead = false;
+ boolean firstLineContainsText = commentContent.trim().length() > 0;
+
+ if (commentAtStart) {
+ if (line.getOffset() + line.getLength() + lineDelimiterLength < doc.getLength()) {
+ IRegion nextLine = doc
+ .getLineInformationOfOffset(line.getOffset() + line.getLength() + lineDelimiterLength);
+ commentFollows = doc.get(nextLine.getOffset(), nextLine.getLength()).trim()
+ .startsWith(commentPrefix);
+
+ if (line.getOffset() >= 1) {
+ IRegion previousLine = doc.getLineInformationOfOffset(line.getOffset() - 1);
+ commentAhead = doc.get(previousLine.getOffset(), previousLine.getLength()).trim()
+ .startsWith(commentPrefix);
+ }
+ }
+ // comment started on this line
+ buf.append(" "); //$NON-NLS-1$
+ }
+
+ c.shiftsCaret = false;
+ c.caretOffset = c.offset + buf.length();
+
+ if (commentAtStart && !commentFollows && !commentAhead) {
+ try {
+ StringBuilder content = getDeclarationLines(doc, offset);
+
+ boolean contentAlreadyThere = (firstLineContainsText && content != null
+ && content.toString().contains(commentContentBehindCursor.trim()));
+ if (content == null || content.toString().trim().length() == 0 || contentAlreadyThere) {
+ buf.setLength(0);
+ buf.append(fgDefaultLineDelim);
+ buf.append(indentationWithPrefix).append(' ');
+ c.shiftsCaret = false;
+ c.caretOffset = c.offset + buf.length();
+ } else {
+ if (!firstLineContainsText) {
+ c.shiftsCaret = false;
+ c.caretOffset = c.offset + 1;
+ buf.setLength(0);
+ buf.append(' ').append(indent(content, indentationWithPrefix + " ", //$NON-NLS-1$
+ fgDefaultLineDelim).substring((indentationWithPrefix + " ").length())); //$NON-NLS-1$
+ } else {
+ buf.append(fgDefaultLineDelim);
+ buf.append(indent(content, indentationWithPrefix + " ", fgDefaultLineDelim)); //$NON-NLS-1$
+ }
+
+ buf.setLength(buf.length() - fgDefaultLineDelim.length());
+ }
+ } catch (BadLocationException ble) {
+ ble.printStackTrace();
+ }
+ }
+
+ c.text = buf.toString();
+
+ } catch (BadLocationException excp) {
+ }
+ }
+
+ private StringBuilder getDeclarationLines(IDocument doc, int offset) throws BadLocationException {
+ IASTDeclaration dec = null;
+ IASTTranslationUnit ast = getAST();
+
+ if (ast != null) {
+ dec = findFollowingDeclaration(ast, offset);
+ if (dec == null) {
+ IASTNodeSelector ans = ast.getNodeSelector(ast.getFilePath());
+ IASTNode node = ans.findEnclosingNode(offset, 0);
+ if (node instanceof IASTDeclaration) {
+ dec = (IASTDeclaration) node;
+ }
+ }
}
- if(dec!=null) {
- ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING /* this! */, offset, false);
- return customizeAfterNewLineForDeclaration(doc, dec, partition);
+ if (dec != null) {
+ ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING /* this! */, offset,
+ false);
+ return customizeAfterNewLineForDeclaration(doc, dec, partition);
}
return null;
}
- private String getCommentPrefix(String indent) throws BadLocationException {
- if (indent.endsWith(SLASH_COMMENT))
- {
- return SLASH_COMMENT;
- }
- else
- {
- return EXCL_COMMENT;
- }
- }
-
+ private String getCommentPrefix(String indent) throws BadLocationException {
+ if (indent.endsWith(SLASH_COMMENT)) {
+ return SLASH_COMMENT;
+ } else {
+ return EXCL_COMMENT;
+ }
+ }
+
/**
* Returns the range of the comment prefix on the given line in
* <code>document</code>. The prefix greedily matches the following regex
@@ -207,11 +196,11 @@ public class DoxygenSingleAutoEditStrategy extends DoxygenMultilineAutoEditStrat
* @throws BadLocationException if accessing the document fails
*/
protected static IRegion findPrefixRange(IDocument document, IRegion line) throws BadLocationException {
- int lineOffset= line.getOffset();
- int lineEnd= lineOffset + line.getLength();
- int indentEnd= findEndOfWhiteSpaceAt(document, lineOffset, lineEnd);
- if (indentEnd < lineEnd-2 && document.getChar(indentEnd) == '/' && document.getChar(indentEnd+1) == '/' && (
- document.getChar(indentEnd+2) == '/' || document.getChar(indentEnd+2) == '!')) {
+ int lineOffset = line.getOffset();
+ int lineEnd = lineOffset + line.getLength();
+ int indentEnd = findEndOfWhiteSpaceAt(document, lineOffset, lineEnd);
+ if (indentEnd < lineEnd - 2 && document.getChar(indentEnd) == '/' && document.getChar(indentEnd + 1) == '/'
+ && (document.getChar(indentEnd + 2) == '/' || document.getChar(indentEnd + 2) == '!')) {
indentEnd += 3;
}
return new Region(lineOffset, indentEnd - lineOffset);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java
index af485345179..58242f7c84c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java
@@ -33,7 +33,8 @@ public class DoxygenSingleConfiguration extends AbstractGenericTagDocCommentView
* Default constructor
*/
public DoxygenSingleConfiguration() {
- super(DoxygenHelper.getDoxygenTags(), new char[] {'@','\\'}, PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR, PreferenceConstants.DOXYGEN_TAG_COLOR);
+ super(DoxygenHelper.getDoxygenTags(), new char[] { '@', '\\' }, PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR,
+ PreferenceConstants.DOXYGEN_TAG_COLOR);
}
/**
@@ -43,7 +44,8 @@ public class DoxygenSingleConfiguration extends AbstractGenericTagDocCommentView
* @param defaultToken the default scanner token id
* @param tagToken the scanner token to use to mark used by this configuration
*/
- protected DoxygenSingleConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken, String tagToken) {
+ protected DoxygenSingleConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken,
+ String tagToken) {
super(tags, tagMarkers, defaultToken, tagToken);
}
@@ -61,11 +63,11 @@ public class DoxygenSingleConfiguration extends AbstractGenericTagDocCommentView
@Override
public boolean isDocumentationComment(IDocument doc, int offset, int length) {
try {
- if(offset+2 < doc.getLength()) {
- char c= doc.getChar(offset+2);
+ if (offset + 2 < doc.getLength()) {
+ char c = doc.getChar(offset + 2);
return c == '/' || c == '!';
}
- } catch(BadLocationException ble) {
+ } catch (BadLocationException ble) {
CUIPlugin.log(ble);
}
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCommentViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCommentViewerConfiguration.java
index 025eb4a7a1d..a285363d614 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCommentViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCommentViewerConfiguration.java
@@ -29,28 +29,29 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
public abstract class AbstractGenericTagDocCommentViewerConfiguration implements IDocCommentViewerConfiguration {
protected GenericDocTag[] fTags;
protected char[] fTagMarkers;
-
+
protected ITextDoubleClickStrategy fDCStrategy;
protected ICompletionProposalComputer fCPComputer;
protected String fDefaultToken;
protected String fTagToken;
protected IDocCommentSimpleDictionary fDictionary;
-
+
/**
- *
+ *
* @param tags a non-null array of tags this configuration should recognize
* @param tagMarkers a non-null array of characters used to prefix the tags (e.g. @ or \)
* @param defaultToken the default scanner token id
* @param tagToken the scanner token to use to mark used by this configuration
*/
- public AbstractGenericTagDocCommentViewerConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken, String tagToken) {
- fTags= tags;
- fTagMarkers= tagMarkers;
- fDCStrategy= new GenericTagDoubleClickStrategy(tagMarkers);
- fCPComputer= new GenericTagCompletionProposalComputer(fTags, tagMarkers);
- fDefaultToken= defaultToken;
- fTagToken= tagToken;
- fDictionary= new GenericTagSimpleDictionary(fTags, fTagMarkers);
+ public AbstractGenericTagDocCommentViewerConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken,
+ String tagToken) {
+ fTags = tags;
+ fTagMarkers = tagMarkers;
+ fDCStrategy = new GenericTagDoubleClickStrategy(tagMarkers);
+ fCPComputer = new GenericTagCompletionProposalComputer(fTags, tagMarkers);
+ fDefaultToken = defaultToken;
+ fTagToken = tagToken;
+ fDictionary = new GenericTagSimpleDictionary(fTags, fTagMarkers);
}
/*
@@ -76,7 +77,7 @@ public abstract class AbstractGenericTagDocCommentViewerConfiguration implements
public ICompletionProposalComputer createProposalComputer() {
return fCPComputer;
}
-
+
/*
* @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#getSpellingDictionary()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.java
index 0073c30bfdd..4da2e20d7f8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.java
@@ -19,24 +19,24 @@ package org.eclipse.cdt.ui.text.doctools.generic;
*/
public class GenericDocTag {
protected final String name, description;
-
+
/**
* Create a tag
* @param name
* @param description
*/
public GenericDocTag(String name, String description) {
- this.name= name;
- this.description= description;
+ this.name = name;
+ this.description = description;
}
-
+
/**
* @return the tag name (without any prefix e.g. no at or backslash)
*/
public String getTagName() {
return name;
}
-
+
/**
* @return a human readable description of the tag. May be null.
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanner.java
index e2482819926..f8c2da17158 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanner.java
@@ -55,16 +55,17 @@ public class GenericTagCommentScanner extends BufferedRuleBasedScanner implement
* @param docToken the token id associated with the enclosing comment
* @param tagToken the token id associated with highlighting any recognized tags
*/
- public GenericTagCommentScanner(GenericDocTag[] tags, char[] tagMarkers, ITokenStoreFactory tokenStoreFactory, String docToken, String tagToken) {
+ public GenericTagCommentScanner(GenericDocTag[] tags, char[] tagMarkers, ITokenStoreFactory tokenStoreFactory,
+ String docToken, String tagToken) {
Assert.isNotNull(tags);
Assert.isNotNull(tagMarkers);
-
- fTags= tags;
- fTagMarkers= tagMarkers;
- fTagToken= tagToken;
- fTokenStore= tokenStoreFactory.createTokenStore(mkArray(docToken, tagToken));
- fDefaultTokenProperty= docToken;
+ fTags = tags;
+ fTagMarkers = tagMarkers;
+ fTagToken = tagToken;
+
+ fTokenStore = tokenStoreFactory.createTokenStore(mkArray(docToken, tagToken));
+ fDefaultTokenProperty = docToken;
setRules(createRules());
}
@@ -82,16 +83,17 @@ public class GenericTagCommentScanner extends BufferedRuleBasedScanner implement
* @return the rules to use in this scanner
*/
protected IRule[] createRules() {
- List<IRule> result= new ArrayList<IRule>();
+ List<IRule> result = new ArrayList<IRule>();
class TagDetector implements IWordDetector {
@Override
public boolean isWordStart(char c) {
- for (int i= 0; i < fTagMarkers.length; i++)
+ for (int i = 0; i < fTagMarkers.length; i++)
if (fTagMarkers[i] == c)
return true;
return false;
}
+
@Override
public boolean isWordPart(char c) {
return c == '.' || Character.isJavaIdentifierPart(c);
@@ -99,17 +101,17 @@ public class GenericTagCommentScanner extends BufferedRuleBasedScanner implement
}
setDefaultReturnToken(fTokenStore.getToken(fDefaultTokenProperty));
- WordRule wr= new WordRule(new TagDetector(), fDefaultReturnToken);
- for (int i= 0; i < fTags.length; i++) {
- String wd= fTags[i].getTagName();
- for (int j= 0; j < fTagMarkers.length; j++) {
+ WordRule wr = new WordRule(new TagDetector(), fDefaultReturnToken);
+ for (int i = 0; i < fTags.length; i++) {
+ String wd = fTags[i].getTagName();
+ for (int j = 0; j < fTagMarkers.length; j++) {
wr.addWord(fTagMarkers[j] + wd, fTokenStore.getToken(fTagToken));
}
}
result.add(wr);
// Add rule for Task Tags.
- fTaskTagRule= new TaskTagRule(fTokenStore.getToken(PreferenceConstants.EDITOR_TASK_TAG_COLOR),
+ fTaskTagRule = new TaskTagRule(fTokenStore.getToken(PreferenceConstants.EDITOR_TASK_TAG_COLOR),
fDefaultReturnToken, fTokenStore.getPreferenceStore(), fCorePreferenceStore);
result.add(fTaskTagRule);
@@ -134,7 +136,7 @@ public class GenericTagCommentScanner extends BufferedRuleBasedScanner implement
}
fTaskTagRule.adaptToPreferenceChange(event);
}
-
+
private static String[] mkArray(String defaultTokenProperty, String tagToken) {
return new String[] { defaultTokenProperty, tagToken, PreferenceConstants.EDITOR_TASK_TAG_COLOR };
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionProposalComputer.java
index 45812e8a4c5..fb645f0ffb2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionProposalComputer.java
@@ -39,49 +39,52 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposal;
public class GenericTagCompletionProposalComputer implements ICompletionProposalComputer {
protected GenericDocTag[] tags;
protected char[] tagMarkers;
-
+
/**
* Constructs a proposal computer for the specified tags
* @param tags
*/
public GenericTagCompletionProposalComputer(GenericDocTag[] tags, char[] tagMarkers) {
- this.tags= tags;
- this.tagMarkers= tagMarkers;
+ this.tags = tags;
+ this.tagMarkers = tagMarkers;
}
-
+
/**
* @param c the character to test
- * @return whether the specified character is a tag prefix marker
+ * @return whether the specified character is a tag prefix marker
*/
protected boolean isTagMarker(char c) {
- for(char candidate : tagMarkers)
- if(c == candidate)
+ for (char candidate : tagMarkers)
+ if (c == candidate)
return true;
return false;
}
-
+
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
- IDocument doc= context.getDocument();
- int ivcOffset= context.getInvocationOffset();
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
+ IDocument doc = context.getDocument();
+ int ivcOffset = context.getInvocationOffset();
try {
- ITypedRegion tr= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, ivcOffset, false);
- int firstNonWS= ivcOffset;
- while(firstNonWS-1> tr.getOffset() && !Character.isWhitespace(doc.get(firstNonWS-1, 1).charAt(0)))
+ ITypedRegion tr = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, ivcOffset, false);
+ int firstNonWS = ivcOffset;
+ while (firstNonWS - 1 > tr.getOffset() && !Character.isWhitespace(doc.get(firstNonWS - 1, 1).charAt(0)))
firstNonWS--;
- String prefix= doc.get(firstNonWS, ivcOffset-firstNonWS);
- if(prefix.length()>0 && isTagMarker(prefix.charAt(0))) {
- List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>();
- char tagMarker= prefix.charAt(0);
+ String prefix = doc.get(firstNonWS, ivcOffset - firstNonWS);
+ if (prefix.length() > 0 && isTagMarker(prefix.charAt(0))) {
+ List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
+ char tagMarker = prefix.charAt(0);
for (GenericDocTag tag2 : tags) {
- String tag= tag2.getTagName();
- if(tag.toLowerCase().startsWith(prefix.substring(1).toLowerCase())) {
- CCompletionProposal proposal= new CCompletionProposal(tagMarker+tag, ivcOffset-prefix.length(), prefix.length(), null, tagMarker+tag, 1, context.getViewer());
- String description= tag2.getTagDescription();
- if(description!=null && description.length()>0) {
+ String tag = tag2.getTagName();
+ if (tag.toLowerCase().startsWith(prefix.substring(1).toLowerCase())) {
+ CCompletionProposal proposal = new CCompletionProposal(tagMarker + tag,
+ ivcOffset - prefix.length(), prefix.length(), null, tagMarker + tag, 1,
+ context.getViewer());
+ String description = tag2.getTagDescription();
+ if (description != null && description.length() > 0) {
proposal.setAdditionalProposalInfo(description);
}
proposals.add(proposal);
@@ -89,7 +92,7 @@ public class GenericTagCompletionProposalComputer implements ICompletionProposal
}
return proposals;
}
- } catch(BadLocationException ble) {
+ } catch (BadLocationException ble) {
// offset is zero, ignore
}
return Collections.emptyList();
@@ -99,7 +102,8 @@ public class GenericTagCompletionProposalComputer implements ICompletionProposal
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context,
+ IProgressMonitor monitor) {
return Collections.emptyList();
}
@@ -115,11 +119,13 @@ public class GenericTagCompletionProposalComputer implements ICompletionProposal
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#sessionEnded()
*/
@Override
- public void sessionEnded() {}
-
+ public void sessionEnded() {
+ }
+
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#sessionStarted()
*/
@Override
- public void sessionStarted() {}
+ public void sessionStarted() {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickStrategy.java
index 7cef8d253fb..d080282834b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickStrategy.java
@@ -33,17 +33,17 @@ import org.eclipse.jface.text.Region;
*/
public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
protected char[] fTagMarkers;
-
+
/**
* A double-click strategy that additionally understands tag markers form part of a
* selectable word.
* @param tagMarkers the set of characters to additionally consider part of a word
*/
public GenericTagDoubleClickStrategy(char[] tagMarkers) {
- fTagMarkers= new char[tagMarkers.length];
+ fTagMarkers = new char[tagMarkers.length];
System.arraycopy(tagMarkers, 0, fTagMarkers, 0, tagMarkers.length);
}
-
+
/**
* Implements a character iterator that works directly on
* instances of <code>IDocument</code>. Used to collaborate with
@@ -57,11 +57,11 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
/** Document to iterate over. */
private IDocument fDocument;
/** Start offset of iteration. */
- private int fOffset= -1;
+ private int fOffset = -1;
/** End offset of iteration. */
- private int fEndOffset= -1;
+ private int fEndOffset = -1;
/** Current offset of iteration. */
- private int fIndex= -1;
+ private int fIndex = -1;
/** Creates a new document iterator. */
public DocumentCharacterIterator() {
@@ -74,9 +74,9 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
* @param iteratorRange the range in the document to be iterated
*/
public void setDocument(IDocument document, IRegion iteratorRange) {
- fDocument= document;
- fOffset= iteratorRange.getOffset();
- fEndOffset= fOffset + iteratorRange.getLength();
+ fDocument = document;
+ fOffset = iteratorRange.getOffset();
+ fEndOffset = fOffset + iteratorRange.getLength();
}
/*
@@ -84,7 +84,7 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
*/
@Override
public char first() {
- fIndex= fOffset;
+ fIndex = fOffset;
return current();
}
@@ -93,7 +93,7 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
*/
@Override
public char last() {
- fIndex= fOffset < fEndOffset ? fEndOffset -1 : fEndOffset;
+ fIndex = fOffset < fEndOffset ? fEndOffset - 1 : fEndOffset;
return current();
}
@@ -117,9 +117,9 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
@Override
public char next() {
++fIndex;
- int end= getEndIndex();
+ int end = getEndIndex();
if (fIndex >= end) {
- fIndex= end;
+ fIndex = end;
return DONE;
}
return current();
@@ -134,7 +134,7 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
return DONE;
if (fIndex > fOffset)
- -- fIndex;
+ --fIndex;
return current();
}
@@ -144,7 +144,7 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
*/
@Override
public char setIndex(int index) {
- fIndex= index;
+ fIndex = index;
return current();
}
@@ -177,21 +177,20 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
*/
@Override
public Object clone() {
- DocumentCharacterIterator i= new DocumentCharacterIterator();
- i.fDocument= fDocument;
- i.fIndex= fIndex;
- i.fOffset= fOffset;
- i.fEndOffset= fEndOffset;
+ DocumentCharacterIterator i = new DocumentCharacterIterator();
+ i.fDocument = fDocument;
+ i.fIndex = fIndex;
+ i.fOffset = fOffset;
+ i.fEndOffset = fEndOffset;
return i;
}
}
-
/**
* The document character iterator used by this strategy.
* @since 2.0
*/
- private DocumentCharacterIterator fDocIter= new DocumentCharacterIterator();
+ private DocumentCharacterIterator fDocIter = new DocumentCharacterIterator();
/*
* @see org.eclipse.jface.text.ITextDoubleClickStrategy#doubleClicked(org.eclipse.jface.text.ITextViewer)
@@ -199,12 +198,12 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
@Override
public void doubleClicked(ITextViewer text) {
- int position= text.getSelectedRange().x;
+ int position = text.getSelectedRange().x;
if (position < 0)
return;
- IRegion word= getWordRegion(text.getDocument(), position);
+ IRegion word = getWordRegion(text.getDocument(), position);
if (word != null)
text.setSelectedRange(word.getOffset(), word.getLength());
@@ -220,35 +219,38 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
private IRegion getWordRegion(IDocument document, int position) {
try {
- IRegion line= document.getLineInformationOfOffset(position);
+ IRegion line = document.getLineInformationOfOffset(position);
if (position == line.getOffset() + line.getLength())
return null;
fDocIter.setDocument(document, line);
- BreakIterator breakIter= BreakIterator.getWordInstance();
+ BreakIterator breakIter = BreakIterator.getWordInstance();
breakIter.setText(fDocIter);
- int start= breakIter.preceding(position);
+ int start = breakIter.preceding(position);
if (start == BreakIterator.DONE)
- start= line.getOffset();
+ start = line.getOffset();
- int end= breakIter.following(position);
+ int end = breakIter.following(position);
if (end == BreakIterator.DONE)
- end= line.getOffset() + line.getLength();
+ end = line.getOffset() + line.getLength();
if (breakIter.isBoundary(position)) {
- if (end - position > position- start)
- start= position;
+ if (end - position > position - start)
+ start = position;
else
- end= position;
+ end = position;
}
- if (start > 0 && isTagMarker(document.getChar(start - 1)) && Character.isJavaIdentifierPart(document.getChar(start))
- && (start == 1 || Character.isWhitespace(document.getChar(start - 2)) || document.getChar(start - 2) == '{')) {
+ if (start > 0 && isTagMarker(document.getChar(start - 1))
+ && Character.isJavaIdentifierPart(document.getChar(start))
+ && (start == 1 || Character.isWhitespace(document.getChar(start - 2))
+ || document.getChar(start - 2) == '{')) {
// double click after @ident
start--;
- } else if (end == position && end == start + 1 && end < line.getOffset() + line.getLength() && document.getChar(end) == '@') {
+ } else if (end == position && end == start + 1 && end < line.getOffset() + line.getLength()
+ && document.getChar(end) == '@') {
// double click before " @ident"
return getWordRegion(document, position + 1);
}
@@ -262,10 +264,9 @@ public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
}
}
-
protected boolean isTagMarker(char c) {
- for(int i=0; i<fTagMarkers.length; i++) {
- if(c == fTagMarkers[i])
+ for (int i = 0; i < fTagMarkers.length; i++) {
+ if (c == fTagMarkers[i])
return true;
}
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDictionary.java
index 42fc2523640..91b07b76482 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDictionary.java
@@ -29,10 +29,10 @@ public class GenericTagSimpleDictionary implements IDocCommentSimpleDictionary {
* @param tagMarkers the characters that may delimit the start of a tag
*/
public GenericTagSimpleDictionary(GenericDocTag[] tags, char[] tagMarkers) {
- fTags= new String[tags.length];
+ fTags = new String[tags.length];
- for(int j=0; j<tags.length; j++) {
- fTags[j]= tags[j].getTagName();
+ for (int j = 0; j < tags.length; j++) {
+ fTags[j] = tags[j].getTagName();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.java
index 3bafe2b91ef..8ad42866d72 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.java
@@ -19,26 +19,26 @@ import org.eclipse.swt.widgets.Control;
/**
* Contributors to the <code>org.eclipse.cdt.ui.foldingStructureProvider</code> extension point
- * can specify an implementation of this interface to be displayed on the C/C++ &gt; Editor &gt;
+ * can specify an implementation of this interface to be displayed on the C/C++ &gt; Editor &gt;
* Folding preference page.
* <p>
* Clients may implement this interface.
* </p>
- *
+ *
*/
public interface ICFoldingPreferenceBlock {
/**
* Creates the control that will be displayed on the C/C++ &gt; Editor &gt; Folding
* preference page.
- *
+ *
* @param parent the parent composite to which to add the preferences control
- * @return the control that was added to <code>parent</code>
+ * @return the control that was added to <code>parent</code>
*/
Control createControl(Composite parent);
/**
- * Called after creating the control. Implementations should load the
+ * Called after creating the control. Implementations should load the
* preferences values and update the controls accordingly.
*/
void initialize();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.java
index dc3bfd53bb3..57b8d4995c3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.java
@@ -26,7 +26,7 @@ import org.eclipse.ui.texteditor.ITextEditor;
* <p>
* Clients may implement this interface.
* </p>
- *
+ *
*/
public interface ICFoldingStructureProvider {
@@ -35,7 +35,7 @@ public interface ICFoldingStructureProvider {
* Implementations should listen to the projection events generated by
* <code>viewer</code> and enable / disable generation of projection
* structure accordingly.
- *
+ *
* @param editor the editor that this provider works on
* @param viewer the projection viewer that displays the annotations created
* by this structure provider
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java
index 23a641e54ef..f61afb1ce44 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java
@@ -31,33 +31,34 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
public class CCProjectWizard extends CDTCommonProjectWizard {
public CCProjectWizard() {
- super(Messages.NewModelProjectWizard_2, Messages.NewModelProjectWizard_3);
+ super(Messages.NewModelProjectWizard_2, Messages.NewModelProjectWizard_3);
}
-
+
@Override
public String[] getNatures() {
return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID };
}
-
+
@Override
protected IProject continueCreation(IProject prj) {
if (continueCreationMonitor == null) {
continueCreationMonitor = new NullProgressMonitor();
}
-
+
try {
- continueCreationMonitor.beginTask(Messages.CCProjectWizard_0, 2);
+ continueCreationMonitor.beginTask(Messages.CCProjectWizard_0, 2);
CProjectNature.addCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
CCProjectNature.addCCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
- } catch (CoreException e) {}
- finally {continueCreationMonitor.done();}
+ } catch (CoreException e) {
+ } finally {
+ continueCreationMonitor.done();
+ }
return prj;
}
-
+
@Override
public String[] getContentTypeIDs() {
return new String[] { CCorePlugin.CONTENT_TYPE_CXXSOURCE, CCorePlugin.CONTENT_TYPE_CXXHEADER };
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java
index ec1f364fc9a..0c20007b168 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.wizards;
-
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.ArrayList;
@@ -58,12 +57,11 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard
-implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
-{
- private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
- private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$
- private static final String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
- private static final String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
+ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard {
+ private static final String PREFIX = "CProjectWizard"; //$NON-NLS-1$
+ private static final String OP_ERROR = "CProjectWizard.op_error"; //$NON-NLS-1$
+ private static final String title = CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
+ private static final String message = CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
private static final String[] EMPTY_ARR = new String[0];
protected IConfigurationElement fConfigElement;
@@ -79,7 +77,7 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
private CWizardHandler savedHandler = null;
public CDTCommonProjectWizard() {
- this(Messages.NewModelProjectWizard_0,Messages.NewModelProjectWizard_1);
+ this(Messages.NewModelProjectWizard_0, Messages.NewModelProjectWizard_1);
}
public CDTCommonProjectWizard(String title, String desc) {
@@ -94,7 +92,7 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
@Override
public void addPages() {
- fMainPage= new CDTMainWizardPage(CUIPlugin.getResourceString(PREFIX));
+ fMainPage = new CDTMainWizardPage(CUIPlugin.getResourceString(PREFIX));
fMainPage.setTitle(wz_title);
fMainPage.setDescription(wz_desc);
addPage(fMainPage);
@@ -129,27 +127,28 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
public IProject getProject(boolean defaults, boolean onFinish) {
if (newProject != null && isChanged())
clearProject();
- if (newProject == null) {
- existingPath = false;
- try {
- IFileStore fs;
+ if (newProject == null) {
+ existingPath = false;
+ try {
+ IFileStore fs;
URI p = fMainPage.getProjectLocation();
- if (p == null) {
- fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
- fs = fs.getChild(fMainPage.getProjectName());
- } else
- fs = EFS.getStore(p);
- IFileInfo f = fs.fetchInfo();
- if (f.exists() && f.isDirectory()) {
- if (fs.getChild(".project").fetchInfo().exists()) { //$NON-NLS-1$
- if (!MessageDialog.openConfirm(getShell(), Messages.CDTCommonProjectWizard_0, Messages.CDTCommonProjectWizard_1))
- return null;
- }
- existingPath = true;
- }
- } catch (CoreException e) {
- CUIPlugin.log(e.getStatus());
- }
+ if (p == null) {
+ fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
+ fs = fs.getChild(fMainPage.getProjectName());
+ } else
+ fs = EFS.getStore(p);
+ IFileInfo f = fs.fetchInfo();
+ if (f.exists() && f.isDirectory()) {
+ if (fs.getChild(".project").fetchInfo().exists()) { //$NON-NLS-1$
+ if (!MessageDialog.openConfirm(getShell(), Messages.CDTCommonProjectWizard_0,
+ Messages.CDTCommonProjectWizard_1))
+ return null;
+ }
+ existingPath = true;
+ }
+ } catch (CoreException e) {
+ CUIPlugin.log(e.getStatus());
+ }
savedHandler = fMainPage.h_selected;
savedHandler.saveState();
lastProjectName = fMainPage.getProjectName();
@@ -165,24 +164,26 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
* or if user returned back from config page.
*/
private void clearProject() {
- if (lastProjectName == null) return;
+ if (lastProjectName == null)
+ return;
try {
ResourcesPlugin.getWorkspace().getRoot().getProject(lastProjectName).delete(!existingPath, true, null);
- } catch (CoreException ignore) {}
+ } catch (CoreException ignore) {
+ }
newProject = null;
lastProjectName = null;
lastProjectLocation = null;
}
private boolean invokeRunnable(IRunnableWithProgress runnable) {
- IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
try {
getContainer().run(true, true, op);
} catch (InvocationTargetException e) {
CUIPlugin.errorDialog(getShell(), title, message, e.getTargetException(), true);
clearProject();
return false;
- } catch (InterruptedException e) {
+ } catch (InterruptedException e) {
clearProject();
return false;
}
@@ -212,11 +213,11 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
ICProjectDescription des = mngr.getProjectDescription(newProject, false);
- if(des == null ) {
+ if (des == null) {
return false;
}
- if(des.isCdtProjectCreating()){
+ if (des.isCdtProjectCreating()) {
des = mngr.getProjectDescription(newProject, true);
des.setCdtProjectCreated();
mngr.setProjectDescription(newProject, des, false, null);
@@ -225,15 +226,16 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
return false;
}
- @Override
+ @Override
public boolean performCancel() {
- clearProject();
- return true;
- }
+ clearProject();
+ return true;
+ }
@Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- fConfigElement= config;
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ throws CoreException {
+ fConfigElement = config;
}
private IRunnableWithProgress getRunnable(boolean _defaults, final boolean onFinish) {
@@ -245,24 +247,28 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
- IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
@Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
final IProgressMonitor fMonitor;
if (monitor == null) {
- fMonitor= new NullProgressMonitor();
+ fMonitor = new NullProgressMonitor();
} else {
fMonitor = monitor;
}
fMonitor.beginTask(CUIPlugin.getResourceString("CProjectWizard.op_description"), 100); //$NON-NLS-1$
fMonitor.worked(10);
try {
- newProject = createIProject(lastProjectName, lastProjectLocation, new SubProgressMonitor(fMonitor, 40));
+ newProject = createIProject(lastProjectName, lastProjectLocation,
+ new SubProgressMonitor(fMonitor, 40));
if (newProject != null)
- fMainPage.h_selected.createProject(newProject, defaults, onFinish, new SubProgressMonitor(fMonitor, 40));
+ fMainPage.h_selected.createProject(newProject, defaults, onFinish,
+ new SubProgressMonitor(fMonitor, 40));
fMonitor.worked(10);
- } catch (CoreException e) { CUIPlugin.log(e); }
- finally {
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ } finally {
fMonitor.done();
}
}
@@ -278,10 +284,10 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
});
if (except[0] != null) {
if (except[0] instanceof InvocationTargetException) {
- throw (InvocationTargetException)except[0];
+ throw (InvocationTargetException) except[0];
}
if (except[0] instanceof InterruptedException) {
- throw (InterruptedException)except[0];
+ throw (InterruptedException) except[0];
}
throw new InvocationTargetException(except[0]);
}
@@ -290,7 +296,7 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
}
@Override
- public IProject createIProject(final String name, final URI location) throws CoreException{
+ public IProject createIProject(final String name, final URI location) throws CoreException {
return createIProject(name, location, new NullProgressMonitor());
}
@@ -305,24 +311,27 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
*
*/
@Override
- public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException{
+ public IProject createIProject(final String name, final URI location, IProgressMonitor monitor)
+ throws CoreException {
monitor.beginTask(Messages.CDTCommonProjectWizard_creatingProject, 100);
- if (newProject != null) return newProject;
+ if (newProject != null)
+ return newProject;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
final IProject newProjectHandle = root.getProject(name);
if (!newProjectHandle.exists()) {
-// IWorkspaceDescription workspaceDesc = workspace.getDescription();
-// workspaceDesc.setAutoBuilding(false);
-// workspace.setDescription(workspaceDesc);
+ // IWorkspaceDescription workspaceDesc = workspace.getDescription();
+ // workspaceDesc.setAutoBuilding(false);
+ // workspace.setDescription(workspaceDesc);
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
- if(location != null)
+ if (location != null)
description.setLocationURI(location);
- newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new SubProgressMonitor(monitor,25));
+ newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle,
+ new SubProgressMonitor(monitor, 25));
} else {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
@@ -330,16 +339,16 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
};
- workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor,25));
+ workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor, 25));
newProject = newProjectHandle;
}
// Open the project if we have to
if (!newProject.isOpen()) {
- newProject.open(new SubProgressMonitor(monitor,25));
+ newProject.open(new SubProgressMonitor(monitor, 25));
}
- continueCreationMonitor = new SubProgressMonitor(monitor,25);
+ continueCreationMonitor = new SubProgressMonitor(monitor, 25);
IProject proj = continueCreation(newProject);
monitor.done();
@@ -348,6 +357,7 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
}
protected abstract IProject continueCreation(IProject prj);
+
@Override
public abstract String[] getNatures();
@@ -356,19 +366,21 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
fMainPage.dispose();
}
- @Override
+ @Override
public boolean canFinish() {
- if (fMainPage.h_selected != null) {
- if(!fMainPage.h_selected.canFinish())
- return false;
- String s = fMainPage.h_selected.getErrorMessage();
- if (s != null) return false;
- }
- return super.canFinish();
- }
- /**
- * Returns last project name used for creation
- */
+ if (fMainPage.h_selected != null) {
+ if (!fMainPage.h_selected.canFinish())
+ return false;
+ String s = fMainPage.h_selected.getErrorMessage();
+ if (s != null)
+ return false;
+ }
+ return super.canFinish();
+ }
+
+ /**
+ * Returns last project name used for creation
+ */
@Override
public String getLastProjectName() {
return lastProjectName;
@@ -386,16 +398,16 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
// Methods below should provide data for language check
@Override
- public String[] getLanguageIDs (){
+ public String[] getLanguageIDs() {
String[] contentTypeIds = getContentTypeIDs();
- if(contentTypeIds.length > 0) {
+ if (contentTypeIds.length > 0) {
IContentTypeManager manager = Platform.getContentTypeManager();
List<String> languageIDs = new ArrayList<String>();
- for(int i = 0; i < contentTypeIds.length; ++i) {
+ for (int i = 0; i < contentTypeIds.length; ++i) {
IContentType contentType = manager.getContentType(contentTypeIds[i]);
- if(null != contentType) {
+ if (null != contentType) {
ILanguage language = LanguageManager.getInstance().getLanguage(contentType);
- if(!languageIDs.contains(language.getId())) {
+ if (!languageIDs.contains(language.getId())) {
languageIDs.add(language.getId());
}
}
@@ -404,19 +416,21 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
}
return EMPTY_ARR;
}
+
@Override
- public String[] getContentTypeIDs (){
+ public String[] getContentTypeIDs() {
return EMPTY_ARR;
}
+
@Override
- public String[] getExtensions (){
+ public String[] getExtensions() {
String[] contentTypeIds = getContentTypeIDs();
- if(contentTypeIds.length > 0) {
+ if (contentTypeIds.length > 0) {
IContentTypeManager manager = Platform.getContentTypeManager();
List<String> extensions = new ArrayList<String>();
- for(int i = 0; i < contentTypeIds.length; ++i) {
+ for (int i = 0; i < contentTypeIds.length; ++i) {
IContentType contentType = manager.getContentType(contentTypeIds[i]);
- if(null != contentType) {
+ if (null != contentType) {
String[] thisTypeExtensions = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
extensions.addAll(Arrays.asList(thisTypeExtensions));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java
index 29e0c9a8687..e41763dcd1b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java
@@ -88,9 +88,8 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
public void createControl(Composite parent) {
super.createControl(parent);
- createDynamicGroup((Composite)getControl());
- switchTo(updateData(tree, right, showSup, CDTMainWizardPage.this, getWizard()),
- getDescriptor(tree));
+ createDynamicGroup((Composite) getControl());
+ switchTo(updateData(tree, right, showSup, CDTMainWizardPage.this, getWizard()), getDescriptor(tree));
setPageComplete(validatePage());
setErrorMessage(null);
@@ -117,10 +116,12 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] tis = tree.getSelection();
- if (tis == null || tis.length == 0) return;
- switchTo((CWizardHandler)tis[0].getData(), (EntryDescriptor)tis[0].getData(DESC));
+ if (tis == null || tis.length == 0)
+ return;
+ switchTo((CWizardHandler) tis[0].getData(), (EntryDescriptor) tis[0].getData(DESC));
setPageComplete(validatePage());
- }});
+ }
+ });
tree.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
@@ -129,7 +130,8 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
return;
}
e.result = Messages.CMainWizardPage_0;
- }});
+ }
+ });
right = new Composite(c, SWT.NONE);
right.setLayoutData(new GridData(GridData.FILL_BOTH));
right.setLayout(new PageLayout());
@@ -144,9 +146,9 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
public void widgetSelected(SelectionEvent e) {
if (h_selected != null)
h_selected.setSupportedOnly(showSup.getSelection());
- switchTo(updateData(tree, right, showSup, CDTMainWizardPage.this, getWizard()),
- getDescriptor(tree));
- }});
+ switchTo(updateData(tree, right, showSup, CDTMainWizardPage.this, getWizard()), getDescriptor(tree));
+ }
+ });
// restore settings from preferences
showSup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP));
@@ -184,7 +186,7 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
IProject handle = getProjectHandle();
if (handle.exists()) {
if (getWizard() instanceof IWizardWithMemory) {
- IWizardWithMemory w = (IWizardWithMemory)getWizard();
+ IWizardWithMemory w = (IWizardWithMemory) getWizard();
if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName()))
bad = false;
}
@@ -209,8 +211,7 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
if (f.getAttribute(EFS.ATTRIBUTE_READ_ONLY)) {
setErrorMessage(Messages.CMainWizardPage_DirReadOnlyError);
return false;
- }
- else
+ } else
setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING);
} else {
setErrorMessage(Messages.CMainWizardPage_6);
@@ -223,8 +224,8 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
}
if (!useDefaults()) {
- IStatus locationStatus =
- ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle, getLocationURI());
+ IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle,
+ getLocationURI());
if (!locationStatus.isOK()) {
setErrorMessage(locationStatus.getMessage());
return false;
@@ -261,8 +262,8 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
* @param wizard
* @return : selected Wizard Handler.
*/
- public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup,
- IWizardItemsListListener ls, IWizard wizard) {
+ public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup, IWizardItemsListListener ls,
+ IWizard wizard) {
// Remember selected item
TreeItem[] selection = tree.getSelection();
TreeItem selectedItem = selection.length > 0 ? selection[0] : null;
@@ -270,14 +271,15 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
String savedParentLabel = getParentText(selectedItem);
tree.removeAll();
- IExtensionPoint extensionPoint =
- Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
- if (extensionPoint == null) return null;
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint == null)
+ return null;
IExtension[] extensions = extensionPoint.getExtensions();
- if (extensions == null) return null;
+ if (extensions == null)
+ return null;
List<EntryDescriptor> items = new ArrayList<EntryDescriptor>();
- for (int i = 0; i < extensions.length; ++i) {
+ for (int i = 0; i < extensions.length; ++i) {
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
for (IConfigurationElement element : elements) {
if (element.getName().equals(ELEMENT_NAME)) {
@@ -361,7 +363,7 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
target = target.getItem(0);
}
tree.setSelection(target);
- return (CWizardHandler)target.getData();
+ return (CWizardHandler) target.getData();
}
return null;
}
@@ -375,7 +377,7 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
private static TreeItem findItem(Tree tree, String label, String parentLabel) {
for (TreeItem item : tree.getItems()) {
TreeItem foundItem = findTreeItem(item, label, parentLabel);
- if (foundItem!=null)
+ if (foundItem != null)
return foundItem;
}
return null;
@@ -387,7 +389,7 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
for (TreeItem child : item.getItems()) {
TreeItem foundItem = findTreeItem(child, label, parentLabel);
- if (foundItem!=null)
+ if (foundItem != null)
return foundItem;
}
return null;
@@ -416,7 +418,8 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
Iterator<EntryDescriptor> it2 = items.iterator();
while (it2.hasNext()) {
EntryDescriptor wd1 = it2.next();
- if (wd1.getParentId() == null) continue;
+ if (wd1.getParentId() == null)
+ continue;
for (int i = 0; i < placedEntryDescriptorsList.size(); i++) {
EntryDescriptor wd2 = placedEntryDescriptorsList.get(i);
if (wd2.getId().equals(wd1.getParentId())) {
@@ -435,7 +438,7 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
wd1.setParent(wd2);
if (h != null) {
if (wd1.getHandler() == null && !wd1.isCategory())
- wd1.setHandler((CWizardHandler)h.clone());
+ wd1.setHandler((CWizardHandler) h.clone());
if (!h.isApplicable(wd1))
break;
}
@@ -453,7 +456,8 @@ public class CDTMainWizardPage extends WizardNewProjectCreationPage implements I
}
}
// repeat iterations until all items are placed.
- if (!found) break;
+ if (!found)
+ break;
}
// orphan elements (with not-existing parentId) are ignored
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTProjectWizard.java
index 1ee04a066fd..ad3382abdbd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTProjectWizard.java
@@ -20,9 +20,9 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
public class CDTProjectWizard extends CDTCommonProjectWizard {
public CDTProjectWizard() {
- super(Messages.NewModelProjectWizard_0, Messages.NewModelProjectWizard_1);
+ super(Messages.NewModelProjectWizard_0, Messages.NewModelProjectWizard_1);
}
-
+
@Override
public String[] getNatures() {
return new String[0];
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CNewWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CNewWizard.java
index 933605ed95c..18cde4da489 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CNewWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CNewWizard.java
@@ -16,39 +16,38 @@ package org.eclipse.cdt.ui.wizards;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.swt.widgets.Composite;
-
/**
* Interface to be used by extension point:
* org.eclipse.cdt.managedbuilder.ui.CDTWizard
- *
+ *
* Implementors should provide 1 or more
* items in "Project types" list (left pane on
- * the 1st page in any CDT new project wizard)
+ * the 1st page in any CDT new project wizard)
*/
public abstract class CNewWizard {
/**
* Creates tree items to be displayed in left pane.
- *
- * Method should add 1 or more tree items,
+ *
+ * Method should add 1 or more tree items,
* each of them should have data object attached,
- * data should be lt;ICProjectTypeHandler&gt;
- *
+ * data should be lt;ICProjectTypeHandler&gt;
+ *
* @param supportedOnly - whether display supported types only
- * @param wizard - New Project wizard to be passed to ICWizardHandler
+ * @param wizard - New Project wizard to be passed to ICWizardHandler
*/
public abstract EntryDescriptor[] createItems(boolean supportedOnly, IWizard wizard);
-
+
/**
* Implementor will be informed about widget where additional
* data should be displayed. Normally, it is right pane in the
* 1st Wizard page.
- *
+ *
* @param parent - composite where widgets are to be created
* @param page - reference to object which will be informed
* about changes (usually 1st page in Wizard)
* May be null if notification is not required
- * or implementor does not really support it.
+ * or implementor does not really support it.
*/
- public void setDependentControl(Composite parent, IWizardItemsListListener page){
+ public void setDependentControl(Composite parent, IWizardItemsListListener page) {
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java
index 53d85148036..056eabf56d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java
@@ -37,18 +37,20 @@ public class CProjectWizard extends CDTCommonProjectWizard {
public String[] getNatures() {
return new String[] { CProjectNature.C_NATURE_ID };
}
-
+
@Override
protected IProject continueCreation(IProject prj) {
if (continueCreationMonitor == null) {
continueCreationMonitor = new NullProgressMonitor();
}
-
+
try {
continueCreationMonitor.beginTask(Messages.CProjectWizard_0, 1);
CProjectNature.addCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
- } catch (CoreException e) {}
- finally {continueCreationMonitor.done();}
+ } catch (CoreException e) {
+ } finally {
+ continueCreationMonitor.done();
+ }
return prj;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CWizardHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CWizardHandler.java
index 62f19e57cbe..179326b9684 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CWizardHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CWizardHandler.java
@@ -33,31 +33,31 @@ import org.eclipse.cdt.ui.newui.CDTPrefUtil;
* This class is basic implementation for ICWizardHandler interface.
* It is independent of managed build system, and, so, almost useless
* It creates "empty" project with no specific.
- *
+ *
* Its descendants should overwrite some methods,
* including createProject() and handleSelection()
- *
+ *
* This object is created per each Project type
- * on the left pane of New Project Wizard page
- *
+ * on the left pane of New Project Wizard page
+ *
* It is responsible for:
* - corresponding line in left pane of 1st wizard page
* - whole view of right pane
* - processing preferred items, if any.
* - providing data for ConfigPage
- * - processing data received from config page
+ * - processing data received from config page
*
*/
public class CWizardHandler implements Cloneable {
protected static final Image IMG0 = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EMPTY);
protected static final Image IMG1 = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_PREFERRED);
-
+
protected String head;
protected String name;
protected Composite parent;
protected Table table;
protected boolean supportedOnly = true;
-
+
public CWizardHandler(Composite _parent, String _head, String _name) {
parent = _parent;
head = _head;
@@ -66,8 +66,8 @@ public class CWizardHandler implements Cloneable {
/**
* Called when user selects corresponding item in wizard tree
- *
- * @parame pane - parent for handler-specific data
+ *
+ * @parame pane - parent for handler-specific data
*/
public void handleSelection() {
List<String> preferred = CDTPrefUtil.getPreferredTCs();
@@ -84,105 +84,118 @@ public class CWizardHandler implements Cloneable {
}
/**
- * Called when user leaves corresponding item in wizard tree
+ * Called when user leaves corresponding item in wizard tree
*/
public void handleUnSelection() {
if (table != null) {
table.setVisible(false);
}
}
-
+
/**
* @return text for label above handler-specific pane
*/
- public String getHeader() { return head; }
+ public String getHeader() {
+ return head;
+ }
/**
* @return text for label in left tree
*/
- public String getName() { return name; }
+ public String getName() {
+ return name;
+ }
/**
* @return null if data is consistent
- * else returns error message
+ * else returns error message
*/
- public String getErrorMessage() { return null; }
+ public String getErrorMessage() {
+ return null;
+ }
/**
* Defines whether only supported project types and toolchains are displayed
- * @param supp
+ * @param supp
*/
- public void setSupportedOnly(boolean supp) { supportedOnly = supp;}
+ public void setSupportedOnly(boolean supp) {
+ supportedOnly = supp;
+ }
/**
* @return true if only supported project types and toolchains are displayed
*/
- public boolean supportedOnly() { return supportedOnly; }
+ public boolean supportedOnly() {
+ return supportedOnly;
+ }
/**
* @return true if handler is able to process preferred toolchains
*/
- public boolean supportsPreferred() { return false; }
+ public boolean supportsPreferred() {
+ return false;
+ }
/**
* @return 1st handler-specific page
*/
- public IWizardPage getSpecificPage() { return null; }
+ public IWizardPage getSpecificPage() {
+ return null;
+ }
/**
* Asks handler to update its data according to preferred list.
* Usually, marks preferred toolchains somehow (icon, font etc)
* @param prefs - list of strings (preferred Toolchain IDs)
*/
- public void updatePreferred(List<String> prefs) {}
+ public void updatePreferred(List<String> prefs) {
+ }
/**
* Creates project
- *
+ *
* @param proj - simple project to be used as base
* @param defaults - true if called from 1st Wizard page
* @throws CoreException
*/
- public void createProject(IProject proj, boolean defaults)
- throws CoreException {}
+ public void createProject(IProject proj, boolean defaults) throws CoreException {
+ }
/**
* Creates project
- *
+ *
* @param proj - simple project to be used as base
* @param defaults - true if called from 1st Wizard page
* @param onFinish - true when the project creation is performed on finish. false -otherwise
* false means that the project created is actually a temporary one that can be removed in case cancel is pressed
- *
+ *
* @throws CoreException
*/
- public void createProject(IProject proj, boolean defaults, boolean onFinish)
- throws CoreException {
+ public void createProject(IProject proj, boolean defaults, boolean onFinish) throws CoreException {
createProject(proj, defaults);
}
-
/**
* Creates project
- *
+ *
* @param proj - simple project to be used as base
* @param defaults - true if called from 1st Wizard page
* @param monitor - progress monitor to track the creation process
* @throws CoreException
* @since 5.1
*/
- public void createProject(IProject proj, boolean defaults, IProgressMonitor monitor)
- throws CoreException {}
+ public void createProject(IProject proj, boolean defaults, IProgressMonitor monitor) throws CoreException {
+ }
/**
* Creates project
- *
+ *
* @param proj - simple project to be used as base
* @param defaults - true if called from 1st Wizard page
* @param onFinish - true when the project creation is performed on finish. false -otherwise
* false means that the project created is actually a temporary one that can be removed in case cancel is pressed
* @param monitor - progress monitor to track the creation process
- *
+ *
* @throws CoreException
* @since 5.1
*/
@@ -190,33 +203,37 @@ public class CWizardHandler implements Cloneable {
throws CoreException {
createProject(proj, defaults, monitor);
}
-
+
/**
* Converts an already created project
- *
+ *
* @param proj - the project to convert
- *
+ *
* @throws CoreException
* @since 5.1
*/
- public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException {}
-
+ public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException {
+ }
+
/**
- *
- * @return true if settings were changed
+ *
+ * @return true if settings were changed
* since last call to saveState()
*/
- public boolean isChanged() { return true; }
+ public boolean isChanged() {
+ return true;
+ }
/**
- * Stores current internal settings
+ * Stores current internal settings
*/
- public void saveState() {}
+ public void saveState() {
+ }
/**
- * Called when Finish button pressed,
+ * Called when Finish button pressed,
* even if project was created before.
- *
+ *
* @param prj - affected project
* @param created - true if the project was created before
*/
@@ -227,34 +244,41 @@ public class CWizardHandler implements Cloneable {
/**
* Checks whether this item can be added to Wizard tree
- *
- * @param data - Wizard Item data to be added
+ *
+ * @param data - Wizard Item data to be added
* as child to current Wizard item
* @return - true if item can be added.
*/
- public boolean isApplicable(EntryDescriptor data) { return true; }
+ public boolean isApplicable(EntryDescriptor data) {
+ return true;
+ }
/**
* Initializes the handler to be used for the specified entry
- *
- * @param data - Wizard Item data to be handled
+ *
+ * @param data - Wizard Item data to be handled
* @throws CoreException
*/
- public void initialize(EntryDescriptor data) throws CoreException {}
+ public void initialize(EntryDescriptor data) throws CoreException {
+ }
- public boolean canFinish() {return true;}
+ public boolean canFinish() {
+ return true;
+ }
@Override
public Object clone() {
try {
- CWizardHandler clone = (CWizardHandler)super.clone();
+ CWizardHandler clone = (CWizardHandler) super.clone();
clone.parent = parent;
clone.head = head;
clone.name = name;
return clone;
- } catch (CloneNotSupportedException e) { return null; }
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
}
-
+
/**
* @deprecated since CDT 6.1.
*/
@@ -262,44 +286,46 @@ public class CWizardHandler implements Cloneable {
public static String removeSpaces(String s) {
char[] cs = s.toCharArray();
StringBuilder sb = new StringBuilder();
- for (int i=0; i<cs.length; i++) {
- if (Character.isWhitespace(cs[i]))
+ for (int i = 0; i < cs.length; i++) {
+ if (Character.isWhitespace(cs[i]))
continue;
sb.append(cs[i]);
}
- return sb.toString();
+ return sb.toString();
}
-
+
/**
* Called after project creation in order to apply
* template-specific settings.
- *
+ *
* Can be called 2 or more times:
- * - each time when user presses <Advanced Settings> button
+ * - each time when user presses <Advanced Settings> button
* - when user presses <Finish> button.
* If <Adv. settings> were not invoked, called once.
- *
+ *
* Since the project is cleared before each method call,
* no need to check whether it has been called before.
- *
+ *
* @param prj - affected project.
*/
-protected void doTemplatesPostProcess(IProject prj) {}
+ protected void doTemplatesPostProcess(IProject prj) {
+ }
-/**
- * Called after project creation in order to apply
- * settings from custom pages.
- *
- * Can be called 2 or more times:
- * - each time when user presses <Advanced Settings> button
- * - when user presses <Finish> button.
- * If <Adv. settings> were not invoked, called once.
- *
- * Since the project is cleared before each doCustom() call,
- * no need to check whether it has been called before.
- * @param prj - affected project.
- */
-
-protected void doCustom(IProject prj) {}
+ /**
+ * Called after project creation in order to apply
+ * settings from custom pages.
+ *
+ * Can be called 2 or more times:
+ * - each time when user presses <Advanced Settings> button
+ * - when user presses <Finish> button.
+ * If <Adv. settings> were not invoked, called once.
+ *
+ * Since the project is cleared before each doCustom() call,
+ * no need to check whether it has been called before.
+ * @param prj - affected project.
+ */
+
+ protected void doCustom(IProject prj) {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/EntryDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/EntryDescriptor.java
index 43fac84cf6a..ef8d72a52ee 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/EntryDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/EntryDescriptor.java
@@ -40,16 +40,20 @@ public final class EntryDescriptor {
handler = _h;
image = _image;
}
+
// these parameters are set in constructor only
public String getId() {
return id;
}
+
public String getName() {
return name;
}
+
public boolean isCategory() {
return isCategory;
}
+
public Image getImage() {
return image;
}
@@ -58,40 +62,46 @@ public final class EntryDescriptor {
public void setParentId(String pId) {
parentId = pId;
}
+
public String getParentId() {
return parentId;
}
-
- public void setPath(String p) {
- path = p;
+
+ public void setPath(String p) {
+ path = p;
}
- public String getPath() {
- return path;
+
+ public String getPath() {
+ return path;
}
- public String[] getPathArray() {
- return CDataUtil.stringToArray(path, "/"); //$NON-NLS-1$
+ public String[] getPathArray() {
+ return CDataUtil.stringToArray(path, "/"); //$NON-NLS-1$
}
- public void setParent(EntryDescriptor p) {
- parent = p;
+ public void setParent(EntryDescriptor p) {
+ parent = p;
}
- public EntryDescriptor getParent() {
- return parent;
+
+ public EntryDescriptor getParent() {
+ return parent;
}
public void setHandler(CWizardHandler h) {
handler = h;
}
+
public CWizardHandler getHandler() {
return handler;
}
+
/**
* @since 5.1
*/
public void setDefaultForCategory(boolean isDefaultForCategory) {
this.isDefaultForCategory = isDefaultForCategory;
}
+
/**
* @since 5.1
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ICPathContainerPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ICPathContainerPage.java
index c42f5c65447..3ad9a3b81e1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ICPathContainerPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ICPathContainerPage.java
@@ -19,20 +19,20 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
/**
- * A path container page allows the user to create a new or edit an
+ * A path container page allows the user to create a new or edit an
* existing patch container entry.
* <p>
- * Clients should implement this interface and include the name of their
- * class in an extension contributed to the cdt.ui's path container page
+ * Clients should implement this interface and include the name of their
+ * class in an extension contributed to the cdt.ui's path container page
* extension point (named <code>org.eclipse.cdt.ui.pathContainerPage
* </code>).
* </p>
* <p>
- * Clients implementing this interface may subclass from
+ * Clients implementing this interface may subclass from
* <code>org.eclipse.jface.wizard.WizardPage</code>.
* </p>
- *
- * @deprecated - use IPathEntryContainerPage
+ *
+ * @deprecated - use IPathEntryContainerPage
* @noreference This interface is not intended to be referenced by clients.
*/
@Deprecated
@@ -43,7 +43,7 @@ public interface ICPathContainerPage extends IWizardPage {
* to give additional information about the context the path container entry is configured in. This information
* only reflects the underlying dialogs current selection state. The user still can make changes after the
* the classpath container pages has been closed or decide to cancel the operation.
- * @param project The project the new or modified entry is added to. The project does not have to exist.
+ * @param project The project the new or modified entry is added to. The project does not have to exist.
* Project can be <code>null</code>.
* @param currentEntries The class path entries currently selected to be set as the projects classpath. This can also
* include the entry to be edited.
@@ -51,25 +51,25 @@ public interface ICPathContainerPage extends IWizardPage {
public void initialize(ICProject project, IPathEntry[] currentEntries);
/**
- * Called when the classpath container wizard is closed by selecting
- * the finish button. Implementers typically override this method to
- * store the page result (new/changed path entry returned in
+ * Called when the classpath container wizard is closed by selecting
+ * the finish button. Implementers typically override this method to
+ * store the page result (new/changed path entry returned in
* getSelection) into its model.
- *
+ *
* @return if the operation was succesful. Only when returned
* <code>true</code>, the wizard will close.
*/
public boolean finish();
-
- /**
- * @return the classpath entries created on the page.
+
+ /**
+ * @return the classpath entries created on the page.
*/
public IPathEntry[] getContainerEntries();
-
+
/**
- * Sets the path container entry to be edited or <code>null</code>
+ * Sets the path container entry to be edited or <code>null</code>
* if a new entry should be created.
- *
+ *
* @param containerEntry the classpath entry to edit or <code>null</code>.
* If unequals <code>null</code> then the classpath entry must be of
* kind <code>IClasspathEntry.CPE_CONTAINER</code>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.java
index 5430c09df65..b46ae8181d2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.java
@@ -25,7 +25,7 @@ public interface IPathEntryContainerPage extends IWizardPage {
* to give additional information about the context the path container entry is configured in. This information
* only reflects the underlying dialogs current selection state. The user still can make changes after the
* the path container pages has been closed or decide to cancel the operation.
- * @param project - The project the new or modified entry is added to. The project does not have to exist.
+ * @param project - The project the new or modified entry is added to. The project does not have to exist.
* Project can be <code>null</code>.
* @param currentEntries - The path entries currently selected to be set as the projects path. This can also
* include the entry to be edited.
@@ -33,26 +33,26 @@ public interface IPathEntryContainerPage extends IWizardPage {
public void initialize(ICProject project, IPathEntry[] currentEntries);
/**
- * Called when the path container wizard is closed by selecting
- * the finish button. Implementers typically override this method to
- * store the page result (new/changed path entry returned in
+ * Called when the path container wizard is closed by selecting
+ * the finish button. Implementers typically override this method to
+ * store the page result (new/changed path entry returned in
* getSelection) into its model.
- *
+ *
* @return if the operation was successful. Only when returned
* <code>true</code>, the wizard will close.
*/
public boolean finish();
/**
- * Method {@link #getNewContainers()} is called to get the the newly added containers.
- * @return the path entries created on this page.
+ * Method {@link #getNewContainers()} is called to get the the newly added containers.
+ * @return the path entries created on this page.
*/
public IContainerEntry[] getNewContainers();
/**
- * Sets the path container entry to be edited or <code>null</code>
+ * Sets the path container entry to be edited or <code>null</code>
* if a new entry should be created.
- *
+ *
* @param containerEntry the path entry to edit or <code>null</code>.
* If not equals <code>null</code> then the path entry must be of
* kind <code>IPathEntry.CDT_CONTAINER</code>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardItemsListListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardItemsListListener.java
index 9a93096680d..bfff11cca15 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardItemsListListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardItemsListListener.java
@@ -17,20 +17,20 @@ import java.util.List;
/**
* Interface should be implemented by some visible object
- * (usually - 1st page in CDT New Project wizard)
- * to be informed about changes in tool chains selection
+ * (usually - 1st page in CDT New Project wizard)
+ * to be informed about changes in tool chains selection
* performed by ICNewWizard implementors.
*/
public interface IWizardItemsListListener {
/**
* Called by ICNewWizard instance when user has changed tool chains selection.
- *
+ *
* @param count - number of selected toolchains.
*/
void toolChainListChanged(int count);
/**
- * @return true if this page is visible
+ * @return true if this page is visible
*/
boolean isCurrent();
@@ -38,9 +38,9 @@ public interface IWizardItemsListListener {
* Ability to filter items which would be shown in the left pane of Main Wizard Page.
* Standard implementation: returns unchanged list. When filtering, please note that
* the items have hierarchical relations with others, so removing some item(s) can
- * break a tree.
+ * break a tree.
*
- * @param items - list of EntryDescriptor objects
+ * @param items - list of EntryDescriptor objects
* @return - list with filtered items
*/
List<EntryDescriptor> filterItems(List<EntryDescriptor> items);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardWithMemory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardWithMemory.java
index 4ecbc0f68b5..ea5ecb548be 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardWithMemory.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardWithMemory.java
@@ -20,8 +20,8 @@ import org.eclipse.jface.wizard.IWizard;
public interface IWizardWithMemory extends IWizard {
// returns name of last-created project
// or null if no projects were created
- public String getLastProjectName();
+ public String getLastProjectName();
- public URI getLastProjectLocation();
+ public URI getLastProjectLocation();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCCProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCCProjectWizard.java
index dee642208d6..78bf6470b62 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCCProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCCProjectWizard.java
@@ -13,13 +13,11 @@
*******************************************************************************/
package org.eclipse.cdt.ui.wizards;
-
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-
/**
* @deprecated as of CDT 4.0. Being kept here for API compatibility only.
*/
@@ -36,13 +34,12 @@ public abstract class NewCCProjectWizard extends NewCProjectWizard {
setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
}
-
@Override
protected void doRun(IProgressMonitor monitor) throws CoreException {
super.doRun(monitor);
// Add C++ Nature to the newly created project.
- if (newProject != null){
- CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, monitor);
- }
+ if (newProject != null) {
+ CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, monitor);
+ }
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java
index da48298bc31..a3f34f67d64 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.wizards;
-
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IFile;
@@ -51,26 +50,24 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.CPluginImages;
-
/**
* C Project wizard that creates a new project resource in
* a location of the user's choice.
*/
public abstract class NewCProjectWizard extends BasicNewResourceWizard implements IExecutableExtension {
- private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$
- private static final String OP_DESC= "CProjectWizard.op_description"; //$NON-NLS-1$
+ private static final String OP_ERROR = "CProjectWizard.op_error"; //$NON-NLS-1$
+ private static final String OP_DESC = "CProjectWizard.op_description"; //$NON-NLS-1$
- private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
- private static final String WZ_TITLE= "CProjectWizard.title"; //$NON-NLS-1$
- private static final String WZ_DESC= "CProjectWizard.description"; //$NON-NLS-1$
+ private static final String PREFIX = "CProjectWizard"; //$NON-NLS-1$
+ private static final String WZ_TITLE = "CProjectWizard.title"; //$NON-NLS-1$
+ private static final String WZ_DESC = "CProjectWizard.description"; //$NON-NLS-1$
private static final String WINDOW_TITLE = "CProjectWizard.windowTitle"; //$NON-NLS-1$
-
private String wz_title;
private String wz_desc;
-// private String op_error;
+ // private String op_error;
protected IConfigurationElement fConfigElement;
protected NewCProjectWizardPage fMainPage;
@@ -78,7 +75,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
public NewCProjectWizard() {
this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC),
- CUIPlugin.getResourceString(OP_ERROR));
+ CUIPlugin.getResourceString(OP_ERROR));
}
public NewCProjectWizard(String title, String description) {
@@ -91,7 +88,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
setNeedsProgressMonitor(true);
wz_title = title;
wz_desc = description;
-// op_error = error;
+ // op_error = error;
}
/* (non-Javadoc)
@@ -99,7 +96,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
*/
@Override
public void addPages() {
- fMainPage= new NewCProjectWizardPage(CUIPlugin.getResourceString(PREFIX));
+ fMainPage = new NewCProjectWizardPage(CUIPlugin.getResourceString(PREFIX));
fMainPage.setTitle(wz_title);
fMainPage.setDescription(wz_desc);
addPage(fMainPage);
@@ -169,7 +166,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
IResource resource = getSelectedResource();
selectAndReveal(resource);
if (resource != null && resource.getType() == IResource.FILE) {
- IFile file = (IFile)resource;
+ IFile file = (IFile) resource;
// Open editor on new file.
IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
if (dw != null) {
@@ -178,8 +175,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
if (page != null)
IDE.openEditor(page, file, true);
} catch (PartInitException e) {
- MessageDialog.openError(dw.getShell(),
- CUIPlugin.getResourceString(OP_ERROR), e.getMessage());
+ MessageDialog.openError(dw.getShell(), CUIPlugin.getResourceString(OP_ERROR), e.getMessage());
}
}
}
@@ -194,7 +190,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
*/
@Override
public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
- fConfigElement= cfig;
+ fConfigElement = cfig;
}
/*
@@ -223,27 +219,27 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
- IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- final IProgressMonitor fMonitor;
- if (monitor == null) {
- fMonitor= new NullProgressMonitor();
- } else {
- fMonitor = monitor;
- }
- fMonitor.beginTask(CUIPlugin.getResourceString(OP_DESC), 3);
- doRunPrologue(new SubProgressMonitor(fMonitor, 1));
- try {
- doRun(new SubProgressMonitor(fMonitor, 1));
- }
- catch (CoreException e) {
- except[0] = e;
- }
- doRunEpilogue(new SubProgressMonitor(fMonitor, 1));
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ final IProgressMonitor fMonitor;
+ if (monitor == null) {
+ fMonitor = new NullProgressMonitor();
+ } else {
+ fMonitor = monitor;
+ }
+ fMonitor.beginTask(CUIPlugin.getResourceString(OP_DESC), 3);
+ doRunPrologue(new SubProgressMonitor(fMonitor, 1));
+ try {
+ doRun(new SubProgressMonitor(fMonitor, 1));
+ } catch (CoreException e) {
+ except[0] = e;
+ }
+ doRunEpilogue(new SubProgressMonitor(fMonitor, 1));
fMonitor.done();
- }
- });
+ }
+ });
try {
getContainer().run(false, true, op);
} catch (InvocationTargetException e) {
@@ -255,14 +251,14 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
});
if (except[0] != null) {
if (except[0] instanceof InvocationTargetException) {
- throw (InvocationTargetException)except[0];
+ throw (InvocationTargetException) except[0];
}
if (except[0] instanceof InterruptedException) {
- throw (InterruptedException)except[0];
+ throw (InterruptedException) except[0];
}
throw new InvocationTargetException(except[0]);
}
- }
+ }
});
}
@@ -270,15 +266,15 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
* Utility method: call a runnable in a WorkbenchModifyDelegatingOperation
*/
protected boolean invokeRunnable(IRunnableWithProgress runnable) {
- IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
try {
getContainer().run(true, true, op);
} catch (InvocationTargetException e) {
- Shell shell= getShell();
- String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
- String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
+ Shell shell = getShell();
+ String title = CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
+ String message = CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
- Throwable th= e.getTargetException();
+ Throwable th = e.getTargetException();
CUIPlugin.errorDialog(shell, title, message, th, false);
try {
getProjectHandle().delete(false, false, null);
@@ -286,7 +282,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
} catch (UnsupportedOperationException ignore) {
}
return false;
- } catch (InterruptedException e) {
+ } catch (InterruptedException e) {
return false;
}
return true;
@@ -334,22 +330,23 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
description.setLocation(newPath);
- if(getBuildSystemId() != null)
- newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, getBuildSystemId(), monitor);
+ if (getBuildSystemId() != null)
+ newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, getBuildSystemId(),
+ monitor);
else
- newProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, monitor, getProjectID());
+ newProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, monitor,
+ getProjectID());
return newProject;
}
-
/**
* Method getID.
* @return String
*/
public abstract String getProjectID();
- public String getBuildSystemId(){
+ public String getBuildSystemId() {
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java
index fbcd09b702b..1bc13bb223d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java
@@ -78,7 +78,7 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements
*/
@Override
public IProject getProject() {
- return ((NewCProjectWizard)getWizard()).getNewProject();
+ return ((NewCProjectWizard) getWizard()).getNewProject();
}
/* (non-Javadoc)
@@ -86,6 +86,6 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements
*/
@Override
public IProject getProjectHandle() {
- return ((NewCProjectWizard)getWizard()).getProjectHandle();
+ return ((NewCProjectWizard) getWizard()).getProjectHandle();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.java
index 9fbc0fea3a3..22904f8d2ee 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.java
@@ -37,31 +37,30 @@ public class NewCProjectWizardPage extends WizardNewProjectCreationPage {
* Unique string ID for this page. Used by Managed Build's custom page manager to refer to this page.
*/
public static final String PAGE_ID = "org.eclipse.cdt.ui.wizard.basicPage"; //$NON-NLS-1$
-
+
/* TODO: Implement proper data publishing from this wizard page.
- *
+ *
* The following items would in theory be used to publish the project name and location with
* the managed build system's custom wizard page manager. However, this would create a dependency
* on MBS by the core, which is not very attractive. It seems like it might be worthwhile in the future
* to move the data publishing capabilities of the page manager out into another, more generic class
* in the core.
- *
+ *
* For now, interested parties can obtain the IWizard page of this page from the page manager, cast it
* to a NewCProjectWizardPage, and obtain the data via its public methods. Messy, but it avoids
- * the unwanted dependency.
- *
- *
+ * the unwanted dependency.
+ *
+ *
public static final String PROJECT_NAME = "projectName"; //$NON-NLS-1$
public static final String PROJECT_LOCATION = "projectLocation"; //$NON-NLS-1$
*/
-
-
+
public NewCProjectWizardPage(String pageName) {
super(pageName);
}
/**
- * Returns whether this page's controls currently all contain valid
+ * Returns whether this page's controls currently all contain valid
* values.
*
* @return <code>true</code> if all controls are valid, and
@@ -84,8 +83,7 @@ public class NewCProjectWizardPage extends WizardNewProjectCreationPage {
setErrorMessage(validLocation.getMessage());
return false;
}
-
-
+
return true;
}
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
index 8612cdfe61e..0392a518e69 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
@@ -109,50 +109,49 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
public class NewClassCreationWizardPage extends NewElementWizardPage {
- protected static final String PAGE_NAME = "NewClassWizardPage"; //$NON-NLS-1$
- protected static final int MAX_FIELD_CHARS = 50;
+ protected static final String PAGE_NAME = "NewClassWizardPage"; //$NON-NLS-1$
+ protected static final int MAX_FIELD_CHARS = 50;
- // Dialog setting keys.
- private static final String KEY_NAMESPACE_SELECTED = "namespaceSelected"; //$NON-NLS-1$
- private static final String KEY_NAMESPACE = "namespace"; //$NON-NLS-1$
- private static final String KEY_TEST_FILE_SELECTED = "testFileSelected"; //$NON-NLS-1$
- private static final String KEY_STUB_SELECTED = "stubSelected"; //$NON-NLS-1$
- private static final String KEY_STUB_VIRTUAL = "stubVirtual"; //$NON-NLS-1$
- private static final String KEY_STUB_INLINE = "stubInline"; //$NON-NLS-1$
+ // Dialog setting keys.
+ private static final String KEY_NAMESPACE_SELECTED = "namespaceSelected"; //$NON-NLS-1$
+ private static final String KEY_NAMESPACE = "namespace"; //$NON-NLS-1$
+ private static final String KEY_TEST_FILE_SELECTED = "testFileSelected"; //$NON-NLS-1$
+ private static final String KEY_STUB_SELECTED = "stubSelected"; //$NON-NLS-1$
+ private static final String KEY_STUB_VIRTUAL = "stubVirtual"; //$NON-NLS-1$
+ private static final String KEY_STUB_INLINE = "stubInline"; //$NON-NLS-1$
// Field IDs
- protected static final int SOURCE_FOLDER_ID = 1;
- protected static final int NAMESPACE_ID = 2;
- protected static final int CLASS_NAME_ID = 4;
- protected static final int BASE_CLASSES_ID = 8;
- protected static final int METHOD_STUBS_ID = 16;
- protected static final int HEADER_FILE_ID = 32;
- protected static final int SOURCE_FILE_ID = 64;
- /** @since 5.3 */
- protected static final int TEST_FILE_ID = 128;
- protected static final int ALL_FIELDS = SOURCE_FOLDER_ID | NAMESPACE_ID
- | CLASS_NAME_ID | BASE_CLASSES_ID | METHOD_STUBS_ID
- | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
+ protected static final int SOURCE_FOLDER_ID = 1;
+ protected static final int NAMESPACE_ID = 2;
+ protected static final int CLASS_NAME_ID = 4;
+ protected static final int BASE_CLASSES_ID = 8;
+ protected static final int METHOD_STUBS_ID = 16;
+ protected static final int HEADER_FILE_ID = 32;
+ protected static final int SOURCE_FILE_ID = 64;
+ /** @since 5.3 */
+ protected static final int TEST_FILE_ID = 128;
+ protected static final int ALL_FIELDS = SOURCE_FOLDER_ID | NAMESPACE_ID | CLASS_NAME_ID | BASE_CLASSES_ID
+ | METHOD_STUBS_ID | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
protected int fLastFocusedField = 0;
- protected StringButtonDialogField fSourceFolderDialogField;
- protected SelectionButtonDialogField fNamespaceSelection;
- protected StringButtonDialogField fNamespaceDialogField;
- protected StringDialogField fClassNameDialogField;
- protected BaseClassesListDialogField fBaseClassesDialogField;
- protected MethodStubsListDialogField fMethodStubsDialogField;
- protected StringButtonDialogField fHeaderFileDialogField;
+ protected StringButtonDialogField fSourceFolderDialogField;
+ protected SelectionButtonDialogField fNamespaceSelection;
+ protected StringButtonDialogField fNamespaceDialogField;
+ protected StringDialogField fClassNameDialogField;
+ protected BaseClassesListDialogField fBaseClassesDialogField;
+ protected MethodStubsListDialogField fMethodStubsDialogField;
+ protected StringButtonDialogField fHeaderFileDialogField;
protected StringButtonDialogField fSourceFileDialogField;
- /** @since 5.3 */
- protected StringButtonDialogField fTestFileDialogField;
- /** @since 5.3 */
- protected SelectionButtonDialogField fTestFileSelection;
- /** @since 5.3 */
- protected boolean fHeaderFileDerivedFromClassName;
- /** @since 5.3 */
- protected boolean fSourceFileDerivedFromClassName;
- /** @since 5.3 */
- protected boolean fTestFileDerivedFromClassName;
+ /** @since 5.3 */
+ protected StringButtonDialogField fTestFileDialogField;
+ /** @since 5.3 */
+ protected SelectionButtonDialogField fTestFileSelection;
+ /** @since 5.3 */
+ protected boolean fHeaderFileDerivedFromClassName;
+ /** @since 5.3 */
+ protected boolean fSourceFileDerivedFromClassName;
+ /** @since 5.3 */
+ protected boolean fTestFileDerivedFromClassName;
protected IStatus fSourceFolderStatus;
protected IStatus fNamespaceStatus;
@@ -165,19 +164,18 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
protected IStatus fTestFileStatus;
protected final IStatus STATUS_OK = new StatusInfo();
- protected IFile fCreatedHeaderFile;
- protected IFile fCreatedSourceFile;
- /** @since 5.3 */
- protected IFile fCreatedTestFile;
- protected ICElement fCreatedClass;
-
- /**
- * This flag isFirstTime is used to keep a note
- * that the class creation wizard has just been
- * created.
- */
- private boolean isFirstTime = false;
+ protected IFile fCreatedHeaderFile;
+ protected IFile fCreatedSourceFile;
+ /** @since 5.3 */
+ protected IFile fCreatedTestFile;
+ protected ICElement fCreatedClass;
+ /**
+ * This flag isFirstTime is used to keep a note
+ * that the class creation wizard has just been
+ * created.
+ */
+ private boolean isFirstTime = false;
/**
* Constructor for NewClassCreationWizardPage
@@ -208,10 +206,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
fClassNameDialogField.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_className_label);
BaseClassesFieldAdapter baseClassesAdapter = new BaseClassesFieldAdapter();
- fBaseClassesDialogField = new BaseClassesListDialogField(NewClassWizardMessages.NewClassCreationWizardPage_baseClasses_label, baseClassesAdapter);
+ fBaseClassesDialogField = new BaseClassesListDialogField(
+ NewClassWizardMessages.NewClassCreationWizardPage_baseClasses_label, baseClassesAdapter);
MethodStubsFieldAdapter methodStubsAdapter = new MethodStubsFieldAdapter();
- fMethodStubsDialogField = new MethodStubsListDialogField(NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label, methodStubsAdapter);
+ fMethodStubsDialogField = new MethodStubsListDialogField(
+ NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label, methodStubsAdapter);
FileGroupFieldAdapter fileGroupAdapter = new FileGroupFieldAdapter();
fHeaderFileDialogField = new StringButtonDialogField(fileGroupAdapter);
@@ -229,9 +229,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
fTestFileDialogField.setDialogFieldListener(fileGroupAdapter);
fTestFileDialogField.setButtonLabel(NewClassWizardMessages.NewClassCreationWizardPage_testFile_button);
- fHeaderFileDerivedFromClassName = true;
- fSourceFileDerivedFromClassName = true;
- fTestFileDerivedFromClassName = true;
+ fHeaderFileDerivedFromClassName = true;
+ fSourceFileDerivedFromClassName = true;
+ fTestFileDerivedFromClassName = true;
fSourceFolderStatus = STATUS_OK;
fNamespaceStatus = STATUS_OK;
@@ -248,41 +248,41 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
// -------- UI Creation ---------
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
public void createControl(Composite parent) {
- initializeDialogUnits(parent);
+ initializeDialogUnits(parent);
- Composite composite = new Composite(parent, SWT.NONE);
- int nColumns = 4;
+ Composite composite = new Composite(parent, SWT.NONE);
+ int nColumns = 4;
- GridLayout layout = new GridLayout();
- layout.numColumns = nColumns;
- composite.setLayout(layout);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = nColumns;
+ composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setFont(parent.getFont());
- createSourceFolderControls(composite, nColumns);
- createNamespaceControls(composite, nColumns);
+ createSourceFolderControls(composite, nColumns);
+ createNamespaceControls(composite, nColumns);
- createSeparator(composite, nColumns);
+ createSeparator(composite, nColumns);
- createClassNameControls(composite, nColumns);
- createBaseClassesControls(composite, nColumns);
- createMethodStubsControls(composite, nColumns);
+ createClassNameControls(composite, nColumns);
+ createBaseClassesControls(composite, nColumns);
+ createMethodStubsControls(composite, nColumns);
- createSeparator(composite, nColumns);
+ createSeparator(composite, nColumns);
- createFileControls(composite, nColumns);
+ createFileControls(composite, nColumns);
composite.layout();
setErrorMessage(null);
setMessage(null);
setControl(composite);
- }
+ }
/**
* Creates a separator line. Expects a <code>GridLayout</code> with at least 1 column.
@@ -291,7 +291,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param nColumns number of columns to span
*/
protected void createSeparator(Composite composite, int nColumns) {
- (new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns, convertHeightInCharsToPixels(1));
+ (new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns,
+ convertHeightInCharsToPixels(1));
}
/**
@@ -319,23 +320,23 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param nColumns number of columns to span
*/
protected void createNamespaceControls(Composite composite, int nColumns) {
- Composite tabGroup= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- tabGroup.setLayout(layout);
+ Composite tabGroup = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ tabGroup.setLayout(layout);
fNamespaceSelection.doFillIntoGrid(tabGroup, 1);
- Text textControl= fNamespaceDialogField.getTextControl(composite);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= getMaxFieldWidth();
- gd.horizontalSpan= 2;
+ Text textControl = fNamespaceDialogField.getTextControl(composite);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = getMaxFieldWidth();
+ gd.horizontalSpan = 2;
textControl.setLayoutData(gd);
textControl.addFocusListener(new StatusFocusListener(NAMESPACE_ID));
- Button button= fNamespaceDialogField.getChangeControl(composite);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ Button button = fNamespaceDialogField.getChangeControl(composite);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.widthHint = SWTUtil.getButtonWidthHint(button);
button.setLayoutData(gd);
}
@@ -363,9 +364,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param nColumns number of columns to span
*/
protected void createBaseClassesControls(Composite composite, int nColumns) {
- fBaseClassesDialogField.doFillIntoGrid(composite, nColumns);
- Control listControl = fBaseClassesDialogField.getListControl(null);
- LayoutUtil.setVerticalGrabbing(listControl, false);
+ fBaseClassesDialogField.doFillIntoGrid(composite, nColumns);
+ Control listControl = fBaseClassesDialogField.getListControl(null);
+ LayoutUtil.setVerticalGrabbing(listControl, false);
listControl.addFocusListener(new StatusFocusListener(BASE_CLASSES_ID));
}
@@ -378,10 +379,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
*/
protected void createMethodStubsControls(Composite composite, int nColumns) {
fMethodStubsDialogField.doFillIntoGrid(composite, nColumns);
- Control listControl = fMethodStubsDialogField.getListControl(null);
- LayoutUtil.setHeightHint(listControl,
- convertHeightInCharsToPixels(6) + convertHeightInCharsToPixels(1) / 2);
- LayoutUtil.setVerticalGrabbing(listControl, false);
+ Control listControl = fMethodStubsDialogField.getListControl(null);
+ LayoutUtil.setHeightHint(listControl, convertHeightInCharsToPixels(6) + convertHeightInCharsToPixels(1) / 2);
+ LayoutUtil.setVerticalGrabbing(listControl, false);
listControl.addFocusListener(new StatusFocusListener(METHOD_STUBS_ID));
}
@@ -393,7 +393,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param nColumns number of columns to span
*/
protected void createFileControls(Composite composite, int nColumns) {
- fHeaderFileDialogField.doFillIntoGrid(composite, nColumns);
+ fHeaderFileDialogField.doFillIntoGrid(composite, nColumns);
Text textControl = fHeaderFileDialogField.getTextControl(null);
LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
textControl.addFocusListener(new StatusFocusListener(HEADER_FILE_ID));
@@ -407,7 +407,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
- tabGroup.setLayout(layout);
+ tabGroup.setLayout(layout);
fTestFileSelection.doFillIntoGrid(tabGroup, 1);
@@ -424,33 +424,33 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
button.setLayoutData(gd);
}
- /**
- * The wizard owning this page is responsible for calling this method with the
- * current selection. The selection is used to initialize the fields of the wizard
- * page.
- *
- * @param selection used to initialize the fields
- */
- public void init(IStructuredSelection selection) {
- if (fDialogSettings == null) {
+ /**
+ * The wizard owning this page is responsible for calling this method with the
+ * current selection. The selection is used to initialize the fields of the wizard
+ * page.
+ *
+ * @param selection used to initialize the fields
+ */
+ public void init(IStructuredSelection selection) {
+ if (fDialogSettings == null) {
fDialogSettings = getDialogSettings().getSection(PAGE_NAME);
if (fDialogSettings == null) {
fDialogSettings = getDialogSettings().addNewSection(PAGE_NAME);
}
- }
+ }
ICElement celem = getInitialCElement(selection);
- String namespace = null;
- if (celem != null) {
- ICElement ns = NewClassWizardUtil.getNamespace(celem);
- if (ns != null) {
- namespace = TypeUtil.getFullyQualifiedName(ns).toString();
- if (namespace != null && namespace.length() == 0) {
- namespace = null;
- }
- }
- }
+ String namespace = null;
+ if (celem != null) {
+ ICElement ns = NewClassWizardUtil.getNamespace(celem);
+ if (ns != null) {
+ namespace = TypeUtil.getFullyQualifiedName(ns).toString();
+ if (namespace != null && namespace.length() == 0) {
+ namespace = null;
+ }
+ }
+ }
if (namespace == null) {
namespace = fDialogSettings.get(KEY_NAMESPACE);
}
@@ -458,81 +458,81 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
setNamespaceText(namespace, false);
setNamespaceSelection(namespace != null || fDialogSettings.getBoolean(KEY_NAMESPACE_SELECTED), true);
- IPath folderPath = null;
- if (celem != null) {
- ICContainer folder = NewClassWizardUtil.getSourceFolder(celem);
- if (folder == null) {
- ICProject cproject = celem.getCProject();
- if (cproject != null) {
- folder = NewClassWizardUtil.getFirstSourceRoot(cproject);
- }
- }
- if (folder != null) {
- folderPath = folder.getResource().getFullPath();
- }
- }
- setSourceFolderFullPath(folderPath, false);
-
- String className = null;
- ITextSelection textSel = getEditorTextSelection();
- if (textSel != null) {
- String text = textSel.getText();
- if (text != null && text.length() > 0 && CConventions.validateClassName(text).isOK()) {
- className = text;
- }
- }
+ IPath folderPath = null;
+ if (celem != null) {
+ ICContainer folder = NewClassWizardUtil.getSourceFolder(celem);
+ if (folder == null) {
+ ICProject cproject = celem.getCProject();
+ if (cproject != null) {
+ folder = NewClassWizardUtil.getFirstSourceRoot(cproject);
+ }
+ }
+ if (folder != null) {
+ folderPath = folder.getResource().getFullPath();
+ }
+ }
+ setSourceFolderFullPath(folderPath, false);
+
+ String className = null;
+ ITextSelection textSel = getEditorTextSelection();
+ if (textSel != null) {
+ String text = textSel.getText();
+ if (text != null && text.length() > 0 && CConventions.validateClassName(text).isOK()) {
+ className = text;
+ }
+ }
// Forcing update will also populate default file names.
- setClassName(className, true);
-
- IMethodStub[] stubs = getDefaultMethodStubs();
- for (int i = 0; i < stubs.length; ++i) {
- IMethodStub stub = stubs[i];
- if (stub.canModifyVirtual()) {
- stub.setVirtual(getBooleanSettingWithDefault(KEY_STUB_VIRTUAL + i, stub.isVirtual()));
- }
- if (stub.canModifyInline()) {
- stub.setInline(getBooleanSettingWithDefault(KEY_STUB_INLINE + i, stub.isInline()));
- }
- addMethodStub(stub, getBooleanSettingWithDefault(KEY_STUB_SELECTED + i, true));
- }
-
- setTestFileSelection(fDialogSettings.getBoolean(KEY_TEST_FILE_SELECTED), true);
- handleFieldChanged(ALL_FIELDS);
- }
-
- private boolean getBooleanSettingWithDefault(String key, boolean defaultValue) {
- String value = fDialogSettings.get(key);
- if (value == null) {
- return defaultValue;
- }
- return Boolean.valueOf(value);
- }
-
- /**
- * Attempts to extract a C Element from the initial selection.
- *
- * @param selection the initial selection
- * @return a C Element, or <code>null</code> if not available
- */
- protected ICElement getInitialCElement(IStructuredSelection selection) {
- ICElement celem = NewClassWizardUtil.getCElementFromSelection(selection);
- if (celem == null) {
- celem = NewClassWizardUtil.getCElementFromEditor();
- }
- if (celem == null || celem.getElementType() == ICElement.C_MODEL) {
- try {
- ICProject[] projects = CoreModel.create(NewClassWizardUtil.getWorkspaceRoot()).getCProjects();
- if (projects.length == 1) {
- celem = projects[0];
- }
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- }
- return celem;
- }
-
- /**
+ setClassName(className, true);
+
+ IMethodStub[] stubs = getDefaultMethodStubs();
+ for (int i = 0; i < stubs.length; ++i) {
+ IMethodStub stub = stubs[i];
+ if (stub.canModifyVirtual()) {
+ stub.setVirtual(getBooleanSettingWithDefault(KEY_STUB_VIRTUAL + i, stub.isVirtual()));
+ }
+ if (stub.canModifyInline()) {
+ stub.setInline(getBooleanSettingWithDefault(KEY_STUB_INLINE + i, stub.isInline()));
+ }
+ addMethodStub(stub, getBooleanSettingWithDefault(KEY_STUB_SELECTED + i, true));
+ }
+
+ setTestFileSelection(fDialogSettings.getBoolean(KEY_TEST_FILE_SELECTED), true);
+ handleFieldChanged(ALL_FIELDS);
+ }
+
+ private boolean getBooleanSettingWithDefault(String key, boolean defaultValue) {
+ String value = fDialogSettings.get(key);
+ if (value == null) {
+ return defaultValue;
+ }
+ return Boolean.valueOf(value);
+ }
+
+ /**
+ * Attempts to extract a C Element from the initial selection.
+ *
+ * @param selection the initial selection
+ * @return a C Element, or <code>null</code> if not available
+ */
+ protected ICElement getInitialCElement(IStructuredSelection selection) {
+ ICElement celem = NewClassWizardUtil.getCElementFromSelection(selection);
+ if (celem == null) {
+ celem = NewClassWizardUtil.getCElementFromEditor();
+ }
+ if (celem == null || celem.getElementType() == ICElement.C_MODEL) {
+ try {
+ ICProject[] projects = CoreModel.create(NewClassWizardUtil.getWorkspaceRoot()).getCProjects();
+ if (projects.length == 1) {
+ celem = projects[0];
+ }
+ } catch (CModelException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ return celem;
+ }
+
+ /**
* Returns the recommended maximum width for text fields (in pixels). This
* method requires that createContent has been called before this method is
* call. Subclasses may override to change the maximum width for text
@@ -544,101 +544,98 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return convertWidthInCharsToPixels(MAX_FIELD_CHARS);
}
- /**
- * Returns the text selection of the current editor. <code>null</code> is returned
- * when the current editor does not have focus or does not return a text selection.
- *
- * @return the selection of the current editor, or <code>null</code>.
- */
- protected ITextSelection getEditorTextSelection() {
- IWorkbenchPage page = CUIPlugin.getActivePage();
- if (page != null) {
- IWorkbenchPart part = page.getActivePart();
- if (part instanceof IEditorPart) {
- ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
- if (selectionProvider != null) {
- ISelection selection = selectionProvider.getSelection();
- if (selection instanceof ITextSelection) {
- return (ITextSelection) selection;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the method stubs to display in the wizard.
- *
- * @return array of method stubs
- *
- * @noreference This method is not intended to be referenced by clients.
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- */
- protected IMethodStub[] getDefaultMethodStubs() {
- return new IMethodStub[] {
- new ConstructorMethodStub(),
- new DestructorMethodStub()
- };
- }
-
- /**
- * Returns the text entered into the source folder input field.
- *
- * @return the source folder
- */
- public String getSourceFolderText() {
- return fSourceFolderDialogField.getText().trim();
- }
-
- /**
- * Sets the text of the source folder input field.
- *
- * @param folder the folder name
- * @param update <code>true</code> if the dialog should be updated
- */
- public void setSourceFolderText(String folder, boolean update) {
- fSourceFolderDialogField.setTextWithoutUpdate(folder != null ? folder : ""); //$NON-NLS-1$
- if (update) {
- fSourceFolderDialogField.dialogFieldChanged();
- }
- }
-
- /**
- * Returns the current source folder as a path.
- *
- * @return the source folder path
- */
- protected IPath getSourceFolderFullPath() {
- String text = getSourceFolderText();
- if (text.length() > 0)
- return new Path(text).makeAbsolute();
- return null;
- }
-
- /**
- * Sets the source folder from the given path.
- *
- * @param folderPath the source folder path
- * @param update <code>true</code> if the dialog should be updated
- */
- protected void setSourceFolderFullPath(IPath folderPath, boolean update) {
- String str = (folderPath != null) ? folderPath.makeRelative().toString() : ""; //.makeRelative().toString(); //$NON-NLS-1$
- setSourceFolderText(str, update);
- }
-
- /**
- * Returns the current project, based on the current source folder.
- *
- * @return the current project
- */
- protected ICProject getCurrentProject() {
- IPath folderPath = getSourceFolderFullPath();
- if (folderPath != null) {
- return toCProject(PathUtil.getEnclosingProject(folderPath));
- }
- return null;
- }
+ /**
+ * Returns the text selection of the current editor. <code>null</code> is returned
+ * when the current editor does not have focus or does not return a text selection.
+ *
+ * @return the selection of the current editor, or <code>null</code>.
+ */
+ protected ITextSelection getEditorTextSelection() {
+ IWorkbenchPage page = CUIPlugin.getActivePage();
+ if (page != null) {
+ IWorkbenchPart part = page.getActivePart();
+ if (part instanceof IEditorPart) {
+ ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
+ if (selectionProvider != null) {
+ ISelection selection = selectionProvider.getSelection();
+ if (selection instanceof ITextSelection) {
+ return (ITextSelection) selection;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the method stubs to display in the wizard.
+ *
+ * @return array of method stubs
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+ protected IMethodStub[] getDefaultMethodStubs() {
+ return new IMethodStub[] { new ConstructorMethodStub(), new DestructorMethodStub() };
+ }
+
+ /**
+ * Returns the text entered into the source folder input field.
+ *
+ * @return the source folder
+ */
+ public String getSourceFolderText() {
+ return fSourceFolderDialogField.getText().trim();
+ }
+
+ /**
+ * Sets the text of the source folder input field.
+ *
+ * @param folder the folder name
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ public void setSourceFolderText(String folder, boolean update) {
+ fSourceFolderDialogField.setTextWithoutUpdate(folder != null ? folder : ""); //$NON-NLS-1$
+ if (update) {
+ fSourceFolderDialogField.dialogFieldChanged();
+ }
+ }
+
+ /**
+ * Returns the current source folder as a path.
+ *
+ * @return the source folder path
+ */
+ protected IPath getSourceFolderFullPath() {
+ String text = getSourceFolderText();
+ if (text.length() > 0)
+ return new Path(text).makeAbsolute();
+ return null;
+ }
+
+ /**
+ * Sets the source folder from the given path.
+ *
+ * @param folderPath the source folder path
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ protected void setSourceFolderFullPath(IPath folderPath, boolean update) {
+ String str = (folderPath != null) ? folderPath.makeRelative().toString() : ""; //.makeRelative().toString(); //$NON-NLS-1$
+ setSourceFolderText(str, update);
+ }
+
+ /**
+ * Returns the current project, based on the current source folder.
+ *
+ * @return the current project
+ */
+ protected ICProject getCurrentProject() {
+ IPath folderPath = getSourceFolderFullPath();
+ if (folderPath != null) {
+ return toCProject(PathUtil.getEnclosingProject(folderPath));
+ }
+ return null;
+ }
private ICProject toCProject(IProject enclosingProject) {
if (enclosingProject != null)
@@ -646,894 +643,893 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return null;
}
- /**
- * Returns the text entered into the namespace input field.
- *
- * @return the namespace
- */
- public String getNamespaceText() {
- return fNamespaceDialogField.getText().trim();
- }
-
- /**
- * Sets the text of the namespace input field.
- *
- * @param namespace the namespace name
- * @param update <code>true</code> if the dialog should be updated
- */
- public void setNamespaceText(String namespace, boolean update) {
- fNamespaceDialogField.setTextWithoutUpdate(namespace != null ? namespace : ""); //$NON-NLS-1$
- if (update) {
- fNamespaceDialogField.dialogFieldChanged();
- }
- }
-
- /**
- * Returns the selection state of the namespace checkbox.
- *
- * @return the selection state of the namespace checkbox
- */
- public boolean isNamespaceSelected() {
- return fNamespaceSelection.isSelected();
- }
-
- /**
- * Sets the namespace checkbox's selection state.
- *
- * @param isSelected the checkbox's selection state
- * @param canBeModified if <code>true</code> the checkbox is
- * modifiable; otherwise it is read-only.
- */
- public void setNamespaceSelection(boolean isSelected, boolean canBeModified) {
- fNamespaceSelection.setSelection(isSelected);
- fNamespaceSelection.setEnabled(canBeModified);
- updateNamespaceEnableState();
- }
-
- /**
- * Updates the enable state of the namespace button.
- */
- private void updateNamespaceEnableState() {
- fNamespaceDialogField.setEnabled(isNamespaceSelected());
- }
-
- /**
- * Returns the class name entered into the class input field.
- *
- * @return the class name
- */
- public String getClassName() {
- return fClassNameDialogField.getText().trim();
- }
-
- /**
- * Sets the text of the class name input field.
- *
- * @param name the new class name
- * @param update <code>true</code> if the dialog should be updated
- */
- public void setClassName(String name, boolean update) {
- fClassNameDialogField.setTextWithoutUpdate(name != null ? name : ""); //$NON-NLS-1$
- if (update) {
- fClassNameDialogField.dialogFieldChanged();
- }
- }
-
- /**
- * Returns the currently selected (checked) method stubs.
- *
- * @return array of <code>IMethodStub</code> or empty array if none selected.
- *
- * @noreference This method is not intended to be referenced by clients.
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- */
- protected IMethodStub[] getSelectedMethodStubs() {
- return fMethodStubsDialogField.getCheckedMethodStubs();
- }
-
- /**
- * Adds a method stub to the method stubs field.
- *
- * @param methodStub the method stub to add
- * @param selected <code>true</code> if the stub is initially selected (checked)
- *
- * @noreference This method is not intended to be referenced by clients.
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- */
- protected void addMethodStub(IMethodStub methodStub, boolean selected) {
- fMethodStubsDialogField.addMethodStub(methodStub, selected);
- }
-
- /**
- * Returns the contents of the base classes field.
- *
- * @return array of <code>IBaseClassInfo</code>
- *
- * @noreference This method is not intended to be referenced by clients.
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- */
- protected IBaseClassInfo[] getBaseClasses() {
- List<IBaseClassInfo> classesList = fBaseClassesDialogField.getElements();
- return classesList.toArray(new IBaseClassInfo[classesList.size()]);
- }
-
- /**
- * Adds a base class to the base classes field.
- * @param newBaseClass the new base class
- * @param access the access visibility (public/private/protected)
- * @param isVirtual <code>true</code> if the inheritance is virtual
- */
- protected void addBaseClass(ITypeInfo newBaseClass, ASTAccessVisibility access, boolean isVirtual) {
- // Check if already exists.
- List<IBaseClassInfo> baseClasses = fBaseClassesDialogField.getElements();
- if (baseClasses != null) {
- for (IBaseClassInfo baseClassInfo : baseClasses) {
- BaseClassInfo info = (BaseClassInfo) baseClassInfo;
- if (info.getType().equals(newBaseClass)) {
- // already added
- return;
- }
- }
- }
-
- if (verifyBaseClasses()) {
- NewClassWizardUtil.resolveClassLocation(newBaseClass, getContainer());
- }
-
- fBaseClassesDialogField.addBaseClass(new BaseClassInfo(newBaseClass, access, isVirtual));
- }
-
- /**
- * Sets the use test file creation checkbox's selection state.
- *
- * @param isSelected the checkbox's selection state
- * @param canBeModified if <code>true</code> the checkbox is modifiable; otherwise it is read-only.
- * @since 5.3
- */
- public void setTestFileSelection(boolean isSelected, boolean canBeModified) {
- fTestFileSelection.setSelection(isSelected);
- fTestFileSelection.setEnabled(canBeModified);
- updateTestFileEnableState();
- }
-
- /**
- * Updates the enable state of test file name text box.
- */
- private void updateTestFileEnableState() {
- fTestFileDialogField.setEnabled(fTestFileSelection.isSelected());
- }
-
- /**
- * Returns the text entered into the header file input field.
- *
- * @return the header file
- */
- public String getHeaderFileText() {
- return fHeaderFileDialogField.getText().trim();
- }
-
- /**
- * Sets the text of the header file input field.
- *
- * @param header the header file name
- * @param update <code>true</code> if the dialog should be updated
- */
- public void setHeaderFileText(String header, boolean update) {
- setFileText(fHeaderFileDialogField, header, update);
- }
-
- /**
- * Returns the current header file as a path.
- *
- * @return the header file path
- */
- protected IPath getHeaderFileFullPath() {
- return getFilePath(getHeaderFileText());
- }
-
- /**
- * Sets the header file from the given path.
- *
- * @param path the header file path
- * @param update <code>true</code> if the dialog should be updated
- */
- protected void setHeaderFileFullPath(IPath path, boolean update) {
- setFileFullPath(fHeaderFileDialogField, path, update);
- }
-
- /**
- * Returns the text entered into the source file input field.
- *
- * @return the source file
- */
- public String getSourceFileText() {
- return fSourceFileDialogField.getText().trim();
- }
-
- /**
- * Sets the text of the source file input field.
- *
- * @param source the source file name
- * @param update <code>true</code> if the dialog should be updated
- */
- public void setSourceFileText(String source, boolean update) {
- setFileText(fSourceFileDialogField, source, update);
- }
-
- /**
- * Returns the current source file as a path.
- *
- * @return the source file path
- */
- protected IPath getSourceFileFullPath() {
- return getFilePath(getSourceFileText());
- }
-
- /**
- * Sets the source file from the given path.
- *
- * @param path the source file path
- * @param update <code>true</code> if the dialog should be updated
- */
- protected void setSourceFileFullPath(IPath path, boolean update) {
- setFileFullPath(fSourceFileDialogField, path, update);
- }
-
- /**
- * Returns the text entered into the source file input field.
- *
- * @return the source file
- * @since 5.3
- */
- public String getTestFileText() {
- return fTestFileDialogField.isEnabled() ? fTestFileDialogField.getText().trim() : null;
- }
-
- /**
- * Sets the text of the test file input field.
- *
- * @param testFile the test file name
- * @param update <code>true</code> if the dialog should be updated
- * @since 5.3
- */
- public void setTestFileText(String testFile, boolean update) {
- setFileText(fTestFileDialogField, testFile, update);
- }
-
- /**
- * Returns the current test file as a path. Returns {@code null} if creation of test file
- * is disabled.
- *
- * @return the test file path, or {@code null} if creation of test file is disabled.
- * @since 5.3
- */
- protected IPath getTestFileFullPath() {
- return getFilePath(getTestFileText());
- }
-
- /**
- * Returns a path corresponding to a file name.
- * @param filename the name of a header, a source, or a test file. Can be {@code null}.
- * @return the corresponding path, or {@code null} if the filename is {@code null}.
- */
+ /**
+ * Returns the text entered into the namespace input field.
+ *
+ * @return the namespace
+ */
+ public String getNamespaceText() {
+ return fNamespaceDialogField.getText().trim();
+ }
+
+ /**
+ * Sets the text of the namespace input field.
+ *
+ * @param namespace the namespace name
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ public void setNamespaceText(String namespace, boolean update) {
+ fNamespaceDialogField.setTextWithoutUpdate(namespace != null ? namespace : ""); //$NON-NLS-1$
+ if (update) {
+ fNamespaceDialogField.dialogFieldChanged();
+ }
+ }
+
+ /**
+ * Returns the selection state of the namespace checkbox.
+ *
+ * @return the selection state of the namespace checkbox
+ */
+ public boolean isNamespaceSelected() {
+ return fNamespaceSelection.isSelected();
+ }
+
+ /**
+ * Sets the namespace checkbox's selection state.
+ *
+ * @param isSelected the checkbox's selection state
+ * @param canBeModified if <code>true</code> the checkbox is
+ * modifiable; otherwise it is read-only.
+ */
+ public void setNamespaceSelection(boolean isSelected, boolean canBeModified) {
+ fNamespaceSelection.setSelection(isSelected);
+ fNamespaceSelection.setEnabled(canBeModified);
+ updateNamespaceEnableState();
+ }
+
+ /**
+ * Updates the enable state of the namespace button.
+ */
+ private void updateNamespaceEnableState() {
+ fNamespaceDialogField.setEnabled(isNamespaceSelected());
+ }
+
+ /**
+ * Returns the class name entered into the class input field.
+ *
+ * @return the class name
+ */
+ public String getClassName() {
+ return fClassNameDialogField.getText().trim();
+ }
+
+ /**
+ * Sets the text of the class name input field.
+ *
+ * @param name the new class name
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ public void setClassName(String name, boolean update) {
+ fClassNameDialogField.setTextWithoutUpdate(name != null ? name : ""); //$NON-NLS-1$
+ if (update) {
+ fClassNameDialogField.dialogFieldChanged();
+ }
+ }
+
+ /**
+ * Returns the currently selected (checked) method stubs.
+ *
+ * @return array of <code>IMethodStub</code> or empty array if none selected.
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+ protected IMethodStub[] getSelectedMethodStubs() {
+ return fMethodStubsDialogField.getCheckedMethodStubs();
+ }
+
+ /**
+ * Adds a method stub to the method stubs field.
+ *
+ * @param methodStub the method stub to add
+ * @param selected <code>true</code> if the stub is initially selected (checked)
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+ protected void addMethodStub(IMethodStub methodStub, boolean selected) {
+ fMethodStubsDialogField.addMethodStub(methodStub, selected);
+ }
+
+ /**
+ * Returns the contents of the base classes field.
+ *
+ * @return array of <code>IBaseClassInfo</code>
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+ protected IBaseClassInfo[] getBaseClasses() {
+ List<IBaseClassInfo> classesList = fBaseClassesDialogField.getElements();
+ return classesList.toArray(new IBaseClassInfo[classesList.size()]);
+ }
+
+ /**
+ * Adds a base class to the base classes field.
+ * @param newBaseClass the new base class
+ * @param access the access visibility (public/private/protected)
+ * @param isVirtual <code>true</code> if the inheritance is virtual
+ */
+ protected void addBaseClass(ITypeInfo newBaseClass, ASTAccessVisibility access, boolean isVirtual) {
+ // Check if already exists.
+ List<IBaseClassInfo> baseClasses = fBaseClassesDialogField.getElements();
+ if (baseClasses != null) {
+ for (IBaseClassInfo baseClassInfo : baseClasses) {
+ BaseClassInfo info = (BaseClassInfo) baseClassInfo;
+ if (info.getType().equals(newBaseClass)) {
+ // already added
+ return;
+ }
+ }
+ }
+
+ if (verifyBaseClasses()) {
+ NewClassWizardUtil.resolveClassLocation(newBaseClass, getContainer());
+ }
+
+ fBaseClassesDialogField.addBaseClass(new BaseClassInfo(newBaseClass, access, isVirtual));
+ }
+
+ /**
+ * Sets the use test file creation checkbox's selection state.
+ *
+ * @param isSelected the checkbox's selection state
+ * @param canBeModified if <code>true</code> the checkbox is modifiable; otherwise it is read-only.
+ * @since 5.3
+ */
+ public void setTestFileSelection(boolean isSelected, boolean canBeModified) {
+ fTestFileSelection.setSelection(isSelected);
+ fTestFileSelection.setEnabled(canBeModified);
+ updateTestFileEnableState();
+ }
+
+ /**
+ * Updates the enable state of test file name text box.
+ */
+ private void updateTestFileEnableState() {
+ fTestFileDialogField.setEnabled(fTestFileSelection.isSelected());
+ }
+
+ /**
+ * Returns the text entered into the header file input field.
+ *
+ * @return the header file
+ */
+ public String getHeaderFileText() {
+ return fHeaderFileDialogField.getText().trim();
+ }
+
+ /**
+ * Sets the text of the header file input field.
+ *
+ * @param header the header file name
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ public void setHeaderFileText(String header, boolean update) {
+ setFileText(fHeaderFileDialogField, header, update);
+ }
+
+ /**
+ * Returns the current header file as a path.
+ *
+ * @return the header file path
+ */
+ protected IPath getHeaderFileFullPath() {
+ return getFilePath(getHeaderFileText());
+ }
+
+ /**
+ * Sets the header file from the given path.
+ *
+ * @param path the header file path
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ protected void setHeaderFileFullPath(IPath path, boolean update) {
+ setFileFullPath(fHeaderFileDialogField, path, update);
+ }
+
+ /**
+ * Returns the text entered into the source file input field.
+ *
+ * @return the source file
+ */
+ public String getSourceFileText() {
+ return fSourceFileDialogField.getText().trim();
+ }
+
+ /**
+ * Sets the text of the source file input field.
+ *
+ * @param source the source file name
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ public void setSourceFileText(String source, boolean update) {
+ setFileText(fSourceFileDialogField, source, update);
+ }
+
+ /**
+ * Returns the current source file as a path.
+ *
+ * @return the source file path
+ */
+ protected IPath getSourceFileFullPath() {
+ return getFilePath(getSourceFileText());
+ }
+
+ /**
+ * Sets the source file from the given path.
+ *
+ * @param path the source file path
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ protected void setSourceFileFullPath(IPath path, boolean update) {
+ setFileFullPath(fSourceFileDialogField, path, update);
+ }
+
+ /**
+ * Returns the text entered into the source file input field.
+ *
+ * @return the source file
+ * @since 5.3
+ */
+ public String getTestFileText() {
+ return fTestFileDialogField.isEnabled() ? fTestFileDialogField.getText().trim() : null;
+ }
+
+ /**
+ * Sets the text of the test file input field.
+ *
+ * @param testFile the test file name
+ * @param update <code>true</code> if the dialog should be updated
+ * @since 5.3
+ */
+ public void setTestFileText(String testFile, boolean update) {
+ setFileText(fTestFileDialogField, testFile, update);
+ }
+
+ /**
+ * Returns the current test file as a path. Returns {@code null} if creation of test file
+ * is disabled.
+ *
+ * @return the test file path, or {@code null} if creation of test file is disabled.
+ * @since 5.3
+ */
+ protected IPath getTestFileFullPath() {
+ return getFilePath(getTestFileText());
+ }
+
+ /**
+ * Returns a path corresponding to a file name.
+ * @param filename the name of a header, a source, or a test file. Can be {@code null}.
+ * @return the corresponding path, or {@code null} if the filename is {@code null}.
+ */
private IPath getFilePath(String filename) {
if (filename == null || filename.length() == 0) {
- return null;
- }
- IPath path = new Path(filename);
+ return null;
+ }
+ IPath path = new Path(filename);
if (!path.isAbsolute()) {
IPath folderPath = getSourceFolderFullPath();
if (folderPath != null)
path = folderPath.append(path);
}
- return path;
- }
-
- /**
- * Sets a file name field to a given value.
- *
- * @param field the field to set
- * @param filename the new value of the field
- * @param update <code>true</code> if the dialog should be updated
- */
- private void setFileText(StringButtonDialogField field, String filename, boolean update) {
- field.setTextWithoutUpdate(filename != null ? filename : ""); //$NON-NLS-1$
- if (update) {
- field.dialogFieldChanged();
- }
- }
-
- /**
- * Sets a file name field from the given path.
- *
- * @param path the file path
- * @param update <code>true</code> if the dialog should be updated
- */
- private void setFileFullPath(StringButtonDialogField field, IPath path, boolean update) {
- String str = null;
- if (path != null) {
- IPath sourceFolder = getSourceFolderFullPath();
- if (sourceFolder != null) {
- IPath relativePath = PathUtil.makeRelativePath(path, sourceFolder);
- if (relativePath != null)
- path = relativePath;
- }
- str = path.makeRelative().toString();
- }
- setFileText(field, str, update);
- }
-
- /**
- * Sets the test file from the given path.
- *
- * @param path the test file path
- * @param update <code>true</code> if the dialog should be updated
- * @since 5.3
- */
- protected void setTestFileFullPath(IPath path, boolean update) {
- setFileFullPath(fTestFileDialogField, path, update);
- }
-
- /*
- * @see WizardPage#becomesVisible
- */
- @Override
+ return path;
+ }
+
+ /**
+ * Sets a file name field to a given value.
+ *
+ * @param field the field to set
+ * @param filename the new value of the field
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ private void setFileText(StringButtonDialogField field, String filename, boolean update) {
+ field.setTextWithoutUpdate(filename != null ? filename : ""); //$NON-NLS-1$
+ if (update) {
+ field.dialogFieldChanged();
+ }
+ }
+
+ /**
+ * Sets a file name field from the given path.
+ *
+ * @param path the file path
+ * @param update <code>true</code> if the dialog should be updated
+ */
+ private void setFileFullPath(StringButtonDialogField field, IPath path, boolean update) {
+ String str = null;
+ if (path != null) {
+ IPath sourceFolder = getSourceFolderFullPath();
+ if (sourceFolder != null) {
+ IPath relativePath = PathUtil.makeRelativePath(path, sourceFolder);
+ if (relativePath != null)
+ path = relativePath;
+ }
+ str = path.makeRelative().toString();
+ }
+ setFileText(field, str, update);
+ }
+
+ /**
+ * Sets the test file from the given path.
+ *
+ * @param path the test file path
+ * @param update <code>true</code> if the dialog should be updated
+ * @since 5.3
+ */
+ protected void setTestFileFullPath(IPath path, boolean update) {
+ setFileFullPath(fTestFileDialogField, path, update);
+ }
+
+ /*
+ * @see WizardPage#becomesVisible
+ */
+ @Override
public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- setFocus();
- }
- }
-
- /**
- * Sets the focus on the class name input field.
- */
- protected void setFocus() {
- fClassNameDialogField.setFocus();
- }
-
- // ----------- UI Validation ----------
-
- /**
- * Causes doStatusUpdate() to be called whenever the focus changes.
- * Remembers the last focused field.
- */
- private final class StatusFocusListener implements FocusListener {
- private int fieldID;
-
- public StatusFocusListener(int fieldID) {
- this.fieldID = fieldID;
- }
-
- @Override
+ super.setVisible(visible);
+ if (visible) {
+ setFocus();
+ }
+ }
+
+ /**
+ * Sets the focus on the class name input field.
+ */
+ protected void setFocus() {
+ fClassNameDialogField.setFocus();
+ }
+
+ // ----------- UI Validation ----------
+
+ /**
+ * Causes doStatusUpdate() to be called whenever the focus changes.
+ * Remembers the last focused field.
+ */
+ private final class StatusFocusListener implements FocusListener {
+ private int fieldID;
+
+ public StatusFocusListener(int fieldID) {
+ this.fieldID = fieldID;
+ }
+
+ @Override
public void focusGained(FocusEvent e) {
- if (fLastFocusedField != this.fieldID) {
- fLastFocusedField = this.fieldID;
- if (isFirstTime) {
- isFirstTime = false;
- return;
- }
- doStatusUpdate();
- }
- }
-
- @Override
+ if (fLastFocusedField != this.fieldID) {
+ fLastFocusedField = this.fieldID;
+ if (isFirstTime) {
+ isFirstTime = false;
+ return;
+ }
+ doStatusUpdate();
+ }
+ }
+
+ @Override
public void focusLost(FocusEvent e) {
- if (fLastFocusedField != 0) {
- fLastFocusedField = 0;
- doStatusUpdate();
- }
- }
- }
-
- /**
- * Handles changes to the source folder field
- */
- private final class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
+ if (fLastFocusedField != 0) {
+ fLastFocusedField = 0;
+ doStatusUpdate();
+ }
+ }
+ }
+
+ /**
+ * Handles changes to the source folder field
+ */
+ private final class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
@Override
public void changeControlPressed(DialogField field) {
- IPath oldFolderPath = getSourceFolderFullPath();
+ IPath oldFolderPath = getSourceFolderFullPath();
IPath newFolderPath = chooseSourceFolder(oldFolderPath);
if (newFolderPath != null) {
setSourceFolderFullPath(newFolderPath, false);
- handleFieldChanged(SOURCE_FOLDER_ID|ALL_FIELDS);
+ handleFieldChanged(SOURCE_FOLDER_ID | ALL_FIELDS);
}
}
@Override
public void dialogFieldChanged(DialogField field) {
- handleFieldChanged(SOURCE_FOLDER_ID|ALL_FIELDS);
- }
- }
-
- private IPath chooseSourceFolder(IPath initialPath) {
- ICElement initElement = NewClassWizardUtil.getSourceFolder(initialPath);
- if (initElement instanceof ISourceRoot) {
- ICProject cProject = initElement.getCProject();
- ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject());
- if (projRoot != null && projRoot.equals(initElement))
- initElement = cProject;
- }
-
- SourceFolderSelectionDialog dialog = new SourceFolderSelectionDialog(getShell());
- dialog.setInput(CoreModel.create(NewClassWizardUtil.getWorkspaceRoot()));
- dialog.setInitialSelection(initElement);
-
- if (dialog.open() == Window.OK) {
- Object result = dialog.getFirstResult();
- if (result instanceof ICElement) {
- ICElement element = (ICElement)result;
- if (element instanceof ICProject) {
- ICProject cproject = (ICProject)element;
- ISourceRoot folder = cproject.findSourceRoot(cproject.getProject());
- if (folder != null)
- return folder.getResource().getFullPath();
- }
- return element.getResource().getFullPath();
- }
- }
- return null;
- }
-
- /**
- * handles changes to the namespace field
- */
- private final class NamespaceFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
+ handleFieldChanged(SOURCE_FOLDER_ID | ALL_FIELDS);
+ }
+ }
+
+ private IPath chooseSourceFolder(IPath initialPath) {
+ ICElement initElement = NewClassWizardUtil.getSourceFolder(initialPath);
+ if (initElement instanceof ISourceRoot) {
+ ICProject cProject = initElement.getCProject();
+ ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject());
+ if (projRoot != null && projRoot.equals(initElement))
+ initElement = cProject;
+ }
+
+ SourceFolderSelectionDialog dialog = new SourceFolderSelectionDialog(getShell());
+ dialog.setInput(CoreModel.create(NewClassWizardUtil.getWorkspaceRoot()));
+ dialog.setInitialSelection(initElement);
+
+ if (dialog.open() == Window.OK) {
+ Object result = dialog.getFirstResult();
+ if (result instanceof ICElement) {
+ ICElement element = (ICElement) result;
+ if (element instanceof ICProject) {
+ ICProject cproject = (ICProject) element;
+ ISourceRoot folder = cproject.findSourceRoot(cproject.getProject());
+ if (folder != null)
+ return folder.getResource().getFullPath();
+ }
+ return element.getResource().getFullPath();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * handles changes to the namespace field
+ */
+ private final class NamespaceFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
@Override
public void changeControlPressed(DialogField field) {
- ITypeInfo ns = chooseNamespace();
- if (ns != null) {
- int changedFields = NAMESPACE_ID|CLASS_NAME_ID;
- IPath oldFolderPath = getSourceFolderFullPath();
- if (oldFolderPath == null) {
+ ITypeInfo ns = chooseNamespace();
+ if (ns != null) {
+ int changedFields = NAMESPACE_ID | CLASS_NAME_ID;
+ IPath oldFolderPath = getSourceFolderFullPath();
+ if (oldFolderPath == null) {
IPath headerPath = getHeaderFileFullPath();
IPath sourcePath = getSourceFileFullPath();
IPath testPath = getTestFileFullPath();
- IPath newFolderPath = updateSourceFolderFromPath(ns.getEnclosingProject().getProject().getFullPath());
- if (newFolderPath != null) {
- changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
- setSourceFolderFullPath(newFolderPath, false);
- // Adjust the relative paths
- setHeaderFileFullPath(headerPath, false);
- setSourceFileFullPath(sourcePath, false);
- setTestFileFullPath(testPath, false);
- }
- }
- setNamespaceText(ns.getQualifiedTypeName().toString(), false);
+ IPath newFolderPath = updateSourceFolderFromPath(
+ ns.getEnclosingProject().getProject().getFullPath());
+ if (newFolderPath != null) {
+ changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
+ setSourceFolderFullPath(newFolderPath, false);
+ // Adjust the relative paths
+ setHeaderFileFullPath(headerPath, false);
+ setSourceFileFullPath(sourcePath, false);
+ setTestFileFullPath(testPath, false);
+ }
+ }
+ setNamespaceText(ns.getQualifiedTypeName().toString(), false);
handleFieldChanged(changedFields);
- }
+ }
}
@Override
public void dialogFieldChanged(DialogField field) {
- updateNamespaceEnableState();
- handleFieldChanged(NAMESPACE_ID|CLASS_NAME_ID);
- }
- }
-
- private IPath updateSourceFolderFromPath(IPath filePath) {
- ICElement folder = NewClassWizardUtil.getSourceFolder(filePath);
- if (folder instanceof ISourceRoot) {
- ICProject cProject = folder.getCProject();
- ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject());
- if (projRoot != null && projRoot.equals(folder))
- folder = cProject;
- }
- if (folder != null) {
- return folder.getPath();
- }
- IProject proj = PathUtil.getEnclosingProject(filePath);
- if (proj != null)
- return proj.getFullPath();
- return null;
- }
-
- private ITypeInfo chooseNamespace() {
- ITypeSearchScope scope;
- ICProject project = getCurrentProject();
- if (project != null) {
- scope = new TypeSearchScope(project);
- } else {
- scope = new TypeSearchScope(true);
- }
-
- ITypeInfo[] elements = AllTypesCache.getNamespaces(scope, false);
- if (elements == null || elements.length == 0) {
- String title = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noNamespaces_title;
- String message = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noNamespaces_message;
- MessageDialog.openInformation(getShell(), title, message);
- return null;
- }
-
- NamespaceSelectionDialog dialog = new NamespaceSelectionDialog(getShell());
- dialog.setElements(elements);
- int result = dialog.open();
- if (result == IDialogConstants.OK_ID) {
- return (ITypeInfo) dialog.getFirstResult();
- }
-
- return null;
- }
-
- /**
- * Handles changes to the class name field
- */
+ updateNamespaceEnableState();
+ handleFieldChanged(NAMESPACE_ID | CLASS_NAME_ID);
+ }
+ }
+
+ private IPath updateSourceFolderFromPath(IPath filePath) {
+ ICElement folder = NewClassWizardUtil.getSourceFolder(filePath);
+ if (folder instanceof ISourceRoot) {
+ ICProject cProject = folder.getCProject();
+ ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject());
+ if (projRoot != null && projRoot.equals(folder))
+ folder = cProject;
+ }
+ if (folder != null) {
+ return folder.getPath();
+ }
+ IProject proj = PathUtil.getEnclosingProject(filePath);
+ if (proj != null)
+ return proj.getFullPath();
+ return null;
+ }
+
+ private ITypeInfo chooseNamespace() {
+ ITypeSearchScope scope;
+ ICProject project = getCurrentProject();
+ if (project != null) {
+ scope = new TypeSearchScope(project);
+ } else {
+ scope = new TypeSearchScope(true);
+ }
+
+ ITypeInfo[] elements = AllTypesCache.getNamespaces(scope, false);
+ if (elements == null || elements.length == 0) {
+ String title = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noNamespaces_title;
+ String message = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noNamespaces_message;
+ MessageDialog.openInformation(getShell(), title, message);
+ return null;
+ }
+
+ NamespaceSelectionDialog dialog = new NamespaceSelectionDialog(getShell());
+ dialog.setElements(elements);
+ int result = dialog.open();
+ if (result == IDialogConstants.OK_ID) {
+ return (ITypeInfo) dialog.getFirstResult();
+ }
+
+ return null;
+ }
+
+ /**
+ * Handles changes to the class name field
+ */
private final class ClassNameFieldAdapter implements IDialogFieldListener {
@Override
public void dialogFieldChanged(DialogField field) {
- int changedFields = CLASS_NAME_ID;
+ int changedFields = CLASS_NAME_ID;
updateFilesFromClassName(fClassNameDialogField.getText().trim());
changedFields |= HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
handleFieldChanged(changedFields);
}
}
- /**
- * Handles changes to the base classes field
- */
+ /**
+ * Handles changes to the base classes field
+ */
private final class BaseClassesFieldAdapter implements IListAdapter<IBaseClassInfo> {
- @Override
+ @Override
public void customButtonPressed(ListDialogField<IBaseClassInfo> field, int index) {
- if (index == 0) {
- chooseBaseClasses();
- }
- handleFieldChanged(BASE_CLASSES_ID);
- }
+ if (index == 0) {
+ chooseBaseClasses();
+ }
+ handleFieldChanged(BASE_CLASSES_ID);
+ }
- @Override
+ @Override
public void selectionChanged(ListDialogField<IBaseClassInfo> field) {
- }
+ }
- @Override
+ @Override
public void doubleClicked(ListDialogField<IBaseClassInfo> field) {
- }
- }
-
- private void chooseBaseClasses() {
- List<IBaseClassInfo> oldContents = fBaseClassesDialogField.getElements();
- NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell());
- dialog.addListener(new ITypeSelectionListener() {
- @Override
+ }
+ }
+
+ private void chooseBaseClasses() {
+ List<IBaseClassInfo> oldContents = fBaseClassesDialogField.getElements();
+ NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell());
+ dialog.addListener(new ITypeSelectionListener() {
+ @Override
public void typeAdded(ITypeInfo newBaseClass) {
- addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false);
- }
- });
- int result = dialog.open();
- if (result != IDialogConstants.OK_ID) {
- // Restore the old contents
- fBaseClassesDialogField.setElements(oldContents);
- }
- }
-
- /**
- * Handles changes to the method stubs field
- */
+ addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false);
+ }
+ });
+ int result = dialog.open();
+ if (result != IDialogConstants.OK_ID) {
+ // Restore the old contents
+ fBaseClassesDialogField.setElements(oldContents);
+ }
+ }
+
+ /**
+ * Handles changes to the method stubs field
+ */
private final class MethodStubsFieldAdapter implements IListAdapter<IMethodStub> {
- @Override
+ @Override
public void customButtonPressed(ListDialogField<IMethodStub> field, int index) {
- }
+ }
- @Override
+ @Override
public void selectionChanged(ListDialogField<IMethodStub> field) {
- }
+ }
- @Override
+ @Override
public void doubleClicked(ListDialogField<IMethodStub> field) {
- }
- }
+ }
+ }
- /**
- * handles changes to the file name fields
- */
- private final class FileGroupFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
+ /**
+ * handles changes to the file name fields
+ */
+ private final class FileGroupFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
@Override
public void changeControlPressed(DialogField field) {
- IPath filePath = null;
+ IPath filePath = null;
IPath headerPath = getHeaderFileFullPath();
IPath sourcePath = getSourceFileFullPath();
IPath testPath = getTestFileFullPath();
- if (field == fHeaderFileDialogField) {
- filePath = chooseFile(NewClassWizardMessages.NewClassCreationWizardPage_ChooseHeaderFileDialog_title,
- getHeaderFileFullPath());
- if (filePath != null) {
- headerPath = filePath;
- }
- } else if (field == fSourceFileDialogField) {
+ if (field == fHeaderFileDialogField) {
+ filePath = chooseFile(NewClassWizardMessages.NewClassCreationWizardPage_ChooseHeaderFileDialog_title,
+ getHeaderFileFullPath());
+ if (filePath != null) {
+ headerPath = filePath;
+ }
+ } else if (field == fSourceFileDialogField) {
filePath = chooseFile(NewClassWizardMessages.NewClassCreationWizardPage_ChooseSourceFileDialog_title,
- getSourceFileFullPath());
- if (filePath != null) {
- sourcePath = filePath;
- }
- } else if (field == fTestFileDialogField) {
+ getSourceFileFullPath());
+ if (filePath != null) {
+ sourcePath = filePath;
+ }
+ } else if (field == fTestFileDialogField) {
filePath = chooseFile(NewClassWizardMessages.NewClassCreationWizardPage_ChooseTestFileDialog_title,
- getTestFileFullPath());
- if (filePath != null) {
- testPath = filePath;
- }
- }
- if (filePath != null) {
- IPath folderPath = null;
- int changedFields = 0;
- int headerSegments = 0;
- int sourceSegments = 0;
- int testSegments = 0;
- if (headerPath != null)
- headerSegments = filePath.matchingFirstSegments(headerPath);
- if (sourcePath != null)
- sourceSegments = filePath.matchingFirstSegments(sourcePath);
- if (testPath != null)
- testSegments = filePath.matchingFirstSegments(testPath);
- int segments = Math.min(Math.min(headerSegments, sourceSegments), testSegments);
- if (segments > 0) {
- IPath newFolderPath = filePath.uptoSegment(segments);
- folderPath = updateSourceFolderFromPath(newFolderPath);
- }
- if (folderPath != null) {
- changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
- // Adjust the relative paths
- setSourceFolderFullPath(folderPath, false);
- setHeaderFileFullPath(headerPath, false);
- setSourceFileFullPath(sourcePath, false);
- setTestFileFullPath(testPath, false);
- }
- if (field == fHeaderFileDialogField) {
- setHeaderFileFullPath(filePath, false);
- changedFields |= HEADER_FILE_ID;
- } else if (field == fSourceFileDialogField) {
- setSourceFileFullPath(filePath, false);
- changedFields |= SOURCE_FILE_ID;
- } else if (field == fTestFileDialogField) {
- setTestFileFullPath(filePath, false);
- changedFields |= TEST_FILE_ID;
- }
+ getTestFileFullPath());
+ if (filePath != null) {
+ testPath = filePath;
+ }
+ }
+ if (filePath != null) {
+ IPath folderPath = null;
+ int changedFields = 0;
+ int headerSegments = 0;
+ int sourceSegments = 0;
+ int testSegments = 0;
+ if (headerPath != null)
+ headerSegments = filePath.matchingFirstSegments(headerPath);
+ if (sourcePath != null)
+ sourceSegments = filePath.matchingFirstSegments(sourcePath);
+ if (testPath != null)
+ testSegments = filePath.matchingFirstSegments(testPath);
+ int segments = Math.min(Math.min(headerSegments, sourceSegments), testSegments);
+ if (segments > 0) {
+ IPath newFolderPath = filePath.uptoSegment(segments);
+ folderPath = updateSourceFolderFromPath(newFolderPath);
+ }
+ if (folderPath != null) {
+ changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
+ // Adjust the relative paths
+ setSourceFolderFullPath(folderPath, false);
+ setHeaderFileFullPath(headerPath, false);
+ setSourceFileFullPath(sourcePath, false);
+ setTestFileFullPath(testPath, false);
+ }
+ if (field == fHeaderFileDialogField) {
+ setHeaderFileFullPath(filePath, false);
+ changedFields |= HEADER_FILE_ID;
+ } else if (field == fSourceFileDialogField) {
+ setSourceFileFullPath(filePath, false);
+ changedFields |= SOURCE_FILE_ID;
+ } else if (field == fTestFileDialogField) {
+ setTestFileFullPath(filePath, false);
+ changedFields |= TEST_FILE_ID;
+ }
handleFieldChanged(changedFields);
- }
+ }
}
@Override
public void dialogFieldChanged(DialogField field) {
- int changedFields = 0;
- if (field == fTestFileSelection) {
- boolean enabled = fTestFileSelection.isSelected();
- fTestFileDialogField.setEnabled(enabled);
- if (enabled) {
- fTestFileDerivedFromClassName = true;
- updateFilesFromClassName(fClassNameDialogField.getText().trim());
- } else {
- fTestFileDialogField.setTextWithoutUpdate(""); //$NON-NLS-1$
- }
- changedFields = TEST_FILE_ID;
- updateTestFileEnableState();
- handleFieldChanged(SOURCE_FOLDER_ID);
- }
- if (field == fHeaderFileDialogField) {
- changedFields |= HEADER_FILE_ID;
- fHeaderFileDerivedFromClassName = false;
- } else if (field == fSourceFileDialogField) {
- changedFields |= SOURCE_FILE_ID;
- fSourceFileDerivedFromClassName = false;
- } else if (field == fTestFileDialogField) {
- changedFields |= TEST_FILE_ID;
- fTestFileDerivedFromClassName = false;
- }
+ int changedFields = 0;
+ if (field == fTestFileSelection) {
+ boolean enabled = fTestFileSelection.isSelected();
+ fTestFileDialogField.setEnabled(enabled);
+ if (enabled) {
+ fTestFileDerivedFromClassName = true;
+ updateFilesFromClassName(fClassNameDialogField.getText().trim());
+ } else {
+ fTestFileDialogField.setTextWithoutUpdate(""); //$NON-NLS-1$
+ }
+ changedFields = TEST_FILE_ID;
+ updateTestFileEnableState();
+ handleFieldChanged(SOURCE_FOLDER_ID);
+ }
+ if (field == fHeaderFileDialogField) {
+ changedFields |= HEADER_FILE_ID;
+ fHeaderFileDerivedFromClassName = false;
+ } else if (field == fSourceFileDialogField) {
+ changedFields |= SOURCE_FILE_ID;
+ fSourceFileDerivedFromClassName = false;
+ } else if (field == fTestFileDialogField) {
+ changedFields |= TEST_FILE_ID;
+ fTestFileDerivedFromClassName = false;
+ }
handleFieldChanged(changedFields);
}
}
- private IPath chooseFile(String title, IPath initialPath) {
- SourceFileSelectionDialog dialog = new SourceFileSelectionDialog(getShell());
- dialog.setTitle(title);
- ICElement input = CoreModel.create(NewClassWizardUtil.getWorkspaceRoot());
- ICProject project = getCurrentProject();
- if (project != null)
- input = project;
- dialog.setInput(input);
-
- IPath filePath = initialPath;
- if (filePath != null) {
- String folderName = filePath.removeLastSegments(1).toString();
- String fileName = filePath.lastSegment();
- dialog.setInitialSelection(folderName, fileName);
- } else {
- filePath = getSourceFolderFullPath();
- if (filePath != null) {
- dialog.setInitialSelection(filePath.toString(), null);
- }
- }
-
- if (dialog.open() == Window.OK) {
- return dialog.getFilePath();
- }
- return null;
- }
-
- /**
- * update header and source file fields from the class name
- */
- private void updateFilesFromClassName(String className) {
- String headerName = ""; //$NON-NLS-1$
- String sourceName = ""; //$NON-NLS-1$
- String testName = ""; //$NON-NLS-1$
- IPath folder = getSourceFolderFullPath();
- if (className != null && className.length() > 0) {
- String[] names = generateFileNames(className, folder);
- if (names != null && names.length == 3) {
- headerName = names[0];
- sourceName = names[1];
- testName = names[2];
- }
- }
- if (fHeaderFileDerivedFromClassName)
- fHeaderFileDialogField.setTextWithoutUpdate(headerName);
- if (fSourceFileDerivedFromClassName)
- fSourceFileDialogField.setTextWithoutUpdate(sourceName);
- if (fTestFileDerivedFromClassName && fTestFileDialogField.isEnabled())
- fTestFileDialogField.setTextWithoutUpdate(testName);
- }
-
- private static final int MAX_UNIQUE_CLASSNAME = 99;
+ private IPath chooseFile(String title, IPath initialPath) {
+ SourceFileSelectionDialog dialog = new SourceFileSelectionDialog(getShell());
+ dialog.setTitle(title);
+ ICElement input = CoreModel.create(NewClassWizardUtil.getWorkspaceRoot());
+ ICProject project = getCurrentProject();
+ if (project != null)
+ input = project;
+ dialog.setInput(input);
+
+ IPath filePath = initialPath;
+ if (filePath != null) {
+ String folderName = filePath.removeLastSegments(1).toString();
+ String fileName = filePath.lastSegment();
+ dialog.setInitialSelection(folderName, fileName);
+ } else {
+ filePath = getSourceFolderFullPath();
+ if (filePath != null) {
+ dialog.setInitialSelection(filePath.toString(), null);
+ }
+ }
+
+ if (dialog.open() == Window.OK) {
+ return dialog.getFilePath();
+ }
+ return null;
+ }
+
+ /**
+ * update header and source file fields from the class name
+ */
+ private void updateFilesFromClassName(String className) {
+ String headerName = ""; //$NON-NLS-1$
+ String sourceName = ""; //$NON-NLS-1$
+ String testName = ""; //$NON-NLS-1$
+ IPath folder = getSourceFolderFullPath();
+ if (className != null && className.length() > 0) {
+ String[] names = generateFileNames(className, folder);
+ if (names != null && names.length == 3) {
+ headerName = names[0];
+ sourceName = names[1];
+ testName = names[2];
+ }
+ }
+ if (fHeaderFileDerivedFromClassName)
+ fHeaderFileDialogField.setTextWithoutUpdate(headerName);
+ if (fSourceFileDerivedFromClassName)
+ fSourceFileDialogField.setTextWithoutUpdate(sourceName);
+ if (fTestFileDerivedFromClassName && fTestFileDialogField.isEnabled())
+ fTestFileDialogField.setTextWithoutUpdate(testName);
+ }
+
+ private static final int MAX_UNIQUE_CLASSNAME = 99;
private IDialogSettings fDialogSettings;
- /**
- * Returns the names of the header file and source file which will be
- * used when this class is created, e.g. "MyClass" -> ["MyClass.h","MyClass.cpp"]
- * Note: the file names should be unique to avoid overwriting existing files.
- *
- * @param className the class name
- * @param folder the folder where the files are to be created, or <code>null</code>
- * @return an array of 2 Strings, containing the header file name and
- * source file name, respectively.
- */
- protected String[] generateFileNames(String className, IPath folder) {
- String headerName = null;
- String sourceName = null;
- String testName = null;
-
- if (folder == null) {
- headerName = NewSourceFileGenerator.generateHeaderFileNameFromClass(className);
- sourceName = NewSourceFileGenerator.generateSourceFileNameFromClass(className);
- testName = NewSourceFileGenerator.generateTestFileNameFromClass(className);
- } else {
- // Make sure the file names are unique.
- String currName = className;
- int count = 0;
- String separator = ""; //$NON-NLS-1$
- if (Character.isDigit(className.charAt(className.length() - 1)))
- separator = "_"; //$NON-NLS-1$
- while (count < MAX_UNIQUE_CLASSNAME) {
- String header = NewSourceFileGenerator.generateHeaderFileNameFromClass(currName);
- IPath path = folder.append(header);
- if (!path.toFile().exists()) {
- String source = NewSourceFileGenerator.generateSourceFileNameFromClass(currName);
- path = folder.append(source);
- if (!path.toFile().exists()) {
- String test = NewSourceFileGenerator.generateTestFileNameFromClass(currName);
- path = folder.append(test);
- if (!path.toFile().exists()) {
- headerName = header;
- sourceName = source;
- testName = test;
- // We're done.
- break;
- }
- }
- }
- ++count;
- currName = className + separator + count;
- }
- }
-
- return new String[] { headerName, sourceName, testName };
- }
-
- /**
- * Hook method that gets called when a field on this page has changed.
- *
- * @param fields Bitwise-OR'd ids of the fields that changed.
- */
- protected void handleFieldChanged(int fields) {
- if (fields == 0)
- return; // no change
-
- if (fieldChanged(fields, SOURCE_FOLDER_ID)) {
- fSourceFolderStatus = sourceFolderChanged();
- }
- if (fieldChanged(fields, NAMESPACE_ID)) {
- fNamespaceStatus = namespaceChanged();
- }
- if (fieldChanged(fields, CLASS_NAME_ID)) {
- fClassNameStatus = classNameChanged();
- }
- if (fieldChanged(fields, BASE_CLASSES_ID)) {
- fBaseClassesStatus = baseClassesChanged();
- }
- if (fieldChanged(fields, METHOD_STUBS_ID)) {
- fMethodStubsStatus = methodStubsChanged();
- }
- if (fieldChanged(fields, HEADER_FILE_ID)) {
- fHeaderFileStatus = headerFileChanged();
- }
- if (fieldChanged(fields, SOURCE_FILE_ID)) {
- fSourceFileStatus = sourceFileChanged();
- }
- if (fieldChanged(fields, TEST_FILE_ID)) {
- fTestFileStatus = testFileChanged();
- }
- doStatusUpdate();
- }
-
- private boolean fieldChanged(int fields, int fieldID) {
- return ((fields & fieldID) != 0);
- }
-
- /**
- * Updates the status line and the ok button according to the status of the fields
- * on the page. The most severe error is taken, with the last-focused field being
- * evaluated first.
- */
- protected void doStatusUpdate() {
- // do the last focused field first
- IStatus lastStatus = getLastFocusedStatus();
-
- final boolean isClassNameWarning = fClassNameStatus.getSeverity() == IStatus.WARNING;
- // status of all used components
- IStatus[] status = new IStatus[] {
- lastStatus,
- (fSourceFolderStatus != lastStatus) ? fSourceFolderStatus : STATUS_OK,
- (fNamespaceStatus != lastStatus) ? fNamespaceStatus : STATUS_OK,
-
- // Give priority to file-level warnings over class name warnings
- (fHeaderFileStatus != lastStatus && isClassNameWarning) ? fHeaderFileStatus : STATUS_OK,
- (fSourceFileStatus != lastStatus && isClassNameWarning) ? fSourceFileStatus : STATUS_OK,
- (fTestFileStatus != lastStatus && isClassNameWarning) ? fTestFileStatus : STATUS_OK,
-
- (fClassNameStatus != lastStatus) ? fClassNameStatus : STATUS_OK,
- (fBaseClassesStatus != lastStatus) ? fBaseClassesStatus : STATUS_OK,
- (fMethodStubsStatus != lastStatus) ? fMethodStubsStatus : STATUS_OK,
- (fHeaderFileStatus != lastStatus) ? fHeaderFileStatus : STATUS_OK,
- (fSourceFileStatus != lastStatus) ? fSourceFileStatus : STATUS_OK,
- (fTestFileStatus != lastStatus) ? fTestFileStatus : STATUS_OK,
- };
-
- // the mode severe status will be displayed and the ok button enabled/disabled.
- updateStatus(status);
- }
-
- /**
- * Returns the status of the last field which had focus.
- *
- * @return status of the last field which had focus
- */
- protected IStatus getLastFocusedStatus() {
- switch (fLastFocusedField) {
- case SOURCE_FOLDER_ID:
- return fSourceFolderStatus;
- case NAMESPACE_ID:
- return fNamespaceStatus;
- case CLASS_NAME_ID:
- return fClassNameStatus;
- case BASE_CLASSES_ID:
- return fBaseClassesStatus;
- case METHOD_STUBS_ID:
- return fMethodStubsStatus;
- case HEADER_FILE_ID:
- return fHeaderFileStatus;
- case SOURCE_FILE_ID:
- return fSourceFileStatus;
- case TEST_FILE_ID:
- return fTestFileStatus;
- default:
- return STATUS_OK;
- }
- }
-
- /**
- * Hook method that gets called when the source folder has changed. The method validates the
- * source folder and returns the status of the validation.
- *
- * @return the status of the validation
- */
+ /**
+ * Returns the names of the header file and source file which will be
+ * used when this class is created, e.g. "MyClass" -> ["MyClass.h","MyClass.cpp"]
+ * Note: the file names should be unique to avoid overwriting existing files.
+ *
+ * @param className the class name
+ * @param folder the folder where the files are to be created, or <code>null</code>
+ * @return an array of 2 Strings, containing the header file name and
+ * source file name, respectively.
+ */
+ protected String[] generateFileNames(String className, IPath folder) {
+ String headerName = null;
+ String sourceName = null;
+ String testName = null;
+
+ if (folder == null) {
+ headerName = NewSourceFileGenerator.generateHeaderFileNameFromClass(className);
+ sourceName = NewSourceFileGenerator.generateSourceFileNameFromClass(className);
+ testName = NewSourceFileGenerator.generateTestFileNameFromClass(className);
+ } else {
+ // Make sure the file names are unique.
+ String currName = className;
+ int count = 0;
+ String separator = ""; //$NON-NLS-1$
+ if (Character.isDigit(className.charAt(className.length() - 1)))
+ separator = "_"; //$NON-NLS-1$
+ while (count < MAX_UNIQUE_CLASSNAME) {
+ String header = NewSourceFileGenerator.generateHeaderFileNameFromClass(currName);
+ IPath path = folder.append(header);
+ if (!path.toFile().exists()) {
+ String source = NewSourceFileGenerator.generateSourceFileNameFromClass(currName);
+ path = folder.append(source);
+ if (!path.toFile().exists()) {
+ String test = NewSourceFileGenerator.generateTestFileNameFromClass(currName);
+ path = folder.append(test);
+ if (!path.toFile().exists()) {
+ headerName = header;
+ sourceName = source;
+ testName = test;
+ // We're done.
+ break;
+ }
+ }
+ }
+ ++count;
+ currName = className + separator + count;
+ }
+ }
+
+ return new String[] { headerName, sourceName, testName };
+ }
+
+ /**
+ * Hook method that gets called when a field on this page has changed.
+ *
+ * @param fields Bitwise-OR'd ids of the fields that changed.
+ */
+ protected void handleFieldChanged(int fields) {
+ if (fields == 0)
+ return; // no change
+
+ if (fieldChanged(fields, SOURCE_FOLDER_ID)) {
+ fSourceFolderStatus = sourceFolderChanged();
+ }
+ if (fieldChanged(fields, NAMESPACE_ID)) {
+ fNamespaceStatus = namespaceChanged();
+ }
+ if (fieldChanged(fields, CLASS_NAME_ID)) {
+ fClassNameStatus = classNameChanged();
+ }
+ if (fieldChanged(fields, BASE_CLASSES_ID)) {
+ fBaseClassesStatus = baseClassesChanged();
+ }
+ if (fieldChanged(fields, METHOD_STUBS_ID)) {
+ fMethodStubsStatus = methodStubsChanged();
+ }
+ if (fieldChanged(fields, HEADER_FILE_ID)) {
+ fHeaderFileStatus = headerFileChanged();
+ }
+ if (fieldChanged(fields, SOURCE_FILE_ID)) {
+ fSourceFileStatus = sourceFileChanged();
+ }
+ if (fieldChanged(fields, TEST_FILE_ID)) {
+ fTestFileStatus = testFileChanged();
+ }
+ doStatusUpdate();
+ }
+
+ private boolean fieldChanged(int fields, int fieldID) {
+ return ((fields & fieldID) != 0);
+ }
+
+ /**
+ * Updates the status line and the ok button according to the status of the fields
+ * on the page. The most severe error is taken, with the last-focused field being
+ * evaluated first.
+ */
+ protected void doStatusUpdate() {
+ // do the last focused field first
+ IStatus lastStatus = getLastFocusedStatus();
+
+ final boolean isClassNameWarning = fClassNameStatus.getSeverity() == IStatus.WARNING;
+ // status of all used components
+ IStatus[] status = new IStatus[] { lastStatus,
+ (fSourceFolderStatus != lastStatus) ? fSourceFolderStatus : STATUS_OK,
+ (fNamespaceStatus != lastStatus) ? fNamespaceStatus : STATUS_OK,
+
+ // Give priority to file-level warnings over class name warnings
+ (fHeaderFileStatus != lastStatus && isClassNameWarning) ? fHeaderFileStatus : STATUS_OK,
+ (fSourceFileStatus != lastStatus && isClassNameWarning) ? fSourceFileStatus : STATUS_OK,
+ (fTestFileStatus != lastStatus && isClassNameWarning) ? fTestFileStatus : STATUS_OK,
+
+ (fClassNameStatus != lastStatus) ? fClassNameStatus : STATUS_OK,
+ (fBaseClassesStatus != lastStatus) ? fBaseClassesStatus : STATUS_OK,
+ (fMethodStubsStatus != lastStatus) ? fMethodStubsStatus : STATUS_OK,
+ (fHeaderFileStatus != lastStatus) ? fHeaderFileStatus : STATUS_OK,
+ (fSourceFileStatus != lastStatus) ? fSourceFileStatus : STATUS_OK,
+ (fTestFileStatus != lastStatus) ? fTestFileStatus : STATUS_OK, };
+
+ // the mode severe status will be displayed and the ok button enabled/disabled.
+ updateStatus(status);
+ }
+
+ /**
+ * Returns the status of the last field which had focus.
+ *
+ * @return status of the last field which had focus
+ */
+ protected IStatus getLastFocusedStatus() {
+ switch (fLastFocusedField) {
+ case SOURCE_FOLDER_ID:
+ return fSourceFolderStatus;
+ case NAMESPACE_ID:
+ return fNamespaceStatus;
+ case CLASS_NAME_ID:
+ return fClassNameStatus;
+ case BASE_CLASSES_ID:
+ return fBaseClassesStatus;
+ case METHOD_STUBS_ID:
+ return fMethodStubsStatus;
+ case HEADER_FILE_ID:
+ return fHeaderFileStatus;
+ case SOURCE_FILE_ID:
+ return fSourceFileStatus;
+ case TEST_FILE_ID:
+ return fTestFileStatus;
+ default:
+ return STATUS_OK;
+ }
+ }
+
+ /**
+ * Hook method that gets called when the source folder has changed. The method validates the
+ * source folder and returns the status of the validation.
+ *
+ * @return the status of the validation
+ */
protected IStatus sourceFolderChanged() {
StatusInfo status = new StatusInfo();
@@ -1549,26 +1545,30 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
IProject proj = res.getProject();
if (!proj.isOpen()) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFolder, folderPath));
+ status.setError(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFolder, folderPath));
return status;
}
- if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+ if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
if (resType == IResource.PROJECT) {
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotACProject);
return status;
}
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject);
}
- if (!NewClassWizardUtil.isOnSourceRoot(res)) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotASourceFolder, folderPath));
+ if (!NewClassWizardUtil.isOnSourceRoot(res)) {
+ status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotASourceFolder,
+ folderPath));
return status;
}
} else {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFolder, folderPath));
+ status.setError(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFolder, folderPath));
return status;
}
} else {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
+ status.setError(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
return status;
}
@@ -1576,19 +1576,19 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
/**
- * Hook method that gets called when the namespace has changed. The method validates the
- * namespace and returns the status of the validation.
- *
- * @return the status of the validation
- */
+ * Hook method that gets called when the namespace has changed. The method validates the
+ * namespace and returns the status of the validation.
+ *
+ * @return the status of the validation
+ */
protected IStatus namespaceChanged() {
StatusInfo status = new StatusInfo();
if (!isNamespaceSelected()) {
- return status;
+ return status;
}
// must not be empty
- String namespace = getNamespaceText();
+ String namespace = getNamespaceText();
if (namespace == null || namespace.length() == 0) {
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterNamespace);
return status;
@@ -1596,13 +1596,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
IStatus val = CConventions.validateNamespaceName(namespace);
if (val.getSeverity() == IStatus.ERROR) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidNamespace, val.getMessage()));
+ status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidNamespace,
+ val.getMessage()));
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
- status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceDiscouraged, val.getMessage()));
+ status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceDiscouraged,
+ val.getMessage()));
}
- IQualifiedTypeName typeName = new QualifiedTypeName(namespace);
+ IQualifiedTypeName typeName = new QualifiedTypeName(namespace);
ICProject project = getCurrentProject();
if (project != null) {
@@ -1618,14 +1620,16 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_NamespaceExistsDifferentCase);
return status;
case NewClassWizardUtil.SEARCH_MATCH_FOUND_ANOTHER_TYPE:
- status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase);
+ status.setWarning(
+ NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase);
return status;
case NewClassWizardUtil.SEARCH_MATCH_NOTFOUND:
// Find the highest ancestor namespace that does not exist.
IQualifiedTypeName ns = typeName;
while (ns.isQualified()) {
IQualifiedTypeName ns1 = ns.getEnclosingTypeName();
- if (NewClassWizardUtil.searchForCppType(ns1, project, ICPPNamespace.class) == NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) {
+ if (NewClassWizardUtil.searchForCppType(ns1, project,
+ ICPPNamespace.class) == NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) {
break;
}
ns = ns1;
@@ -1634,14 +1638,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
ns.getFullyQualifiedName()));
break;
}
- }
+ }
- val = CConventions.validateNamespaceName(typeName.lastSegment());
+ val = CConventions.validateNamespaceName(typeName.lastSegment());
if (val.getSeverity() == IStatus.ERROR) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidNamespace, val.getMessage()));
+ status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidNamespace,
+ val.getMessage()));
return status;
}
- return status;
+ return status;
}
/**
@@ -1651,38 +1656,40 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @return the status of the validation
*/
protected IStatus classNameChanged() {
- StatusInfo status = new StatusInfo();
+ StatusInfo status = new StatusInfo();
- String className = getClassName();
+ String className = getClassName();
// Must not be empty.
if (className == null || className.length() == 0) {
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterClassName);
return status;
}
- IQualifiedTypeName typeName = new QualifiedTypeName(className);
- if (typeName.isQualified()) {
- status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_QualifiedClassName);
- return status;
- }
+ IQualifiedTypeName typeName = new QualifiedTypeName(className);
+ if (typeName.isQualified()) {
+ status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_QualifiedClassName);
+ return status;
+ }
IStatus val = CConventions.validateClassName(className);
if (val.getSeverity() == IStatus.ERROR) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidClassName, val.getMessage()));
+ status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidClassName,
+ val.getMessage()));
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
- status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_ClassNameDiscouraged, val.getMessage()));
+ status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_ClassNameDiscouraged,
+ val.getMessage()));
// continue checking
}
- ICProject project = getCurrentProject();
- if (project != null) {
- IQualifiedTypeName fullyQualifiedName = typeName;
+ ICProject project = getCurrentProject();
+ if (project != null) {
+ IQualifiedTypeName fullyQualifiedName = typeName;
if (isNamespaceSelected()) {
- String namespace = getNamespaceText();
- if (namespace != null && namespace.length() > 0) {
- fullyQualifiedName = new QualifiedTypeName(namespace).append(typeName);
- }
+ String namespace = getNamespaceText();
+ if (namespace != null && namespace.length() > 0) {
+ fullyQualifiedName = new QualifiedTypeName(namespace).append(typeName);
+ }
}
int searchResult = NewClassWizardUtil.searchForCppType(fullyQualifiedName, project, ICPPClassType.class);
switch (searchResult) {
@@ -1696,103 +1703,105 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_ClassNameExistsDifferentCase);
return status;
case NewClassWizardUtil.SEARCH_MATCH_FOUND_ANOTHER_TYPE:
- status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingClassExistsDifferentCase);
+ status.setWarning(
+ NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingClassExistsDifferentCase);
return status;
case NewClassWizardUtil.SEARCH_MATCH_NOTFOUND:
break;
}
- }
+ }
return status;
}
- /**
+ /**
* Hook method that gets called when the list of base classes has changed. The method
* validates the base classes and returns the status of the validation.
*
* @return the status of the validation
*/
protected IStatus baseClassesChanged() {
- if (verifyBaseClasses()) {
+ if (verifyBaseClasses()) {
IPath folder = getSourceFolderFullPath();
- ICProject project = getCurrentProject();
+ ICProject project = getCurrentProject();
if (project != null) {
- IBaseClassInfo[] baseClasses = getBaseClasses();
- // make sure all classes belong to the project
- if (baseClasses != null && baseClasses.length > 0) {
- IStatus status = baseClassesChanged(project, folder, baseClasses);
- if (status.isMultiStatus()) {
- // we only want to show the most severe error
- return StatusUtil.getMostSevere(status.getChildren());
- }
- return status;
- }
- }
- }
+ IBaseClassInfo[] baseClasses = getBaseClasses();
+ // make sure all classes belong to the project
+ if (baseClasses != null && baseClasses.length > 0) {
+ IStatus status = baseClassesChanged(project, folder, baseClasses);
+ if (status.isMultiStatus()) {
+ // we only want to show the most severe error
+ return StatusUtil.getMostSevere(status.getChildren());
+ }
+ return status;
+ }
+ }
+ }
return Status.OK_STATUS;
}
- /**
- * This method validates the base classes by searching through the project's
- * include paths and checking if each base class is reachable.
- *
- * @param project the current project
- * @param sourceFolder the current source folder
- * @param baseClasses an array of base classes
- *
- * @return the status of the validation
- *
- * @noreference This method is not intended to be referenced by clients.
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- */
- protected IStatus baseClassesChanged(ICProject project, IPath sourceFolder, IBaseClassInfo[] baseClasses) {
- MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project.getProject());
- if (provider != null) {
- // TODO Get the scanner info for the actual source folder.
- IScannerInfo info = provider.getScannerInformation(project.getProject());
- if (info != null) {
- String[] includePaths = info.getIncludePaths();
- for (int i = 0; i < baseClasses.length; ++i) {
- IBaseClassInfo baseClass = baseClasses[i];
- ITypeInfo baseType = baseClass.getType();
- StatusInfo baseClassStatus = new StatusInfo();
- if (!NewClassWizardUtil.isTypeReachable(baseType, project, includePaths)) {
- baseClassStatus.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_BaseClassNotExistsInProject,
- baseType.getQualifiedTypeName().toString()));
- }
- status.add(baseClassStatus);
- }
- }
- }
- return status;
- }
-
- /**
- * Checks if the base classes need to be verified (ie they must exist in the project)
- *
- * @return <code>true</code> if the base classes should be verified
- */
- public boolean verifyBaseClasses() {
- return NewClassWizardPrefs.verifyBaseClasses();
- }
-
- /**
- * Hook method that gets called when the list of method stubs has changed. The method
- * validates the method stubs and returns the status of the validation.
- *
- * @return the status of the validation
- */
+ /**
+ * This method validates the base classes by searching through the project's
+ * include paths and checking if each base class is reachable.
+ *
+ * @param project the current project
+ * @param sourceFolder the current source folder
+ * @param baseClasses an array of base classes
+ *
+ * @return the status of the validation
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+ protected IStatus baseClassesChanged(ICProject project, IPath sourceFolder, IBaseClassInfo[] baseClasses) {
+ MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+ IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project.getProject());
+ if (provider != null) {
+ // TODO Get the scanner info for the actual source folder.
+ IScannerInfo info = provider.getScannerInformation(project.getProject());
+ if (info != null) {
+ String[] includePaths = info.getIncludePaths();
+ for (int i = 0; i < baseClasses.length; ++i) {
+ IBaseClassInfo baseClass = baseClasses[i];
+ ITypeInfo baseType = baseClass.getType();
+ StatusInfo baseClassStatus = new StatusInfo();
+ if (!NewClassWizardUtil.isTypeReachable(baseType, project, includePaths)) {
+ baseClassStatus.setError(NLS.bind(
+ NewClassWizardMessages.NewClassCreationWizardPage_error_BaseClassNotExistsInProject,
+ baseType.getQualifiedTypeName().toString()));
+ }
+ status.add(baseClassStatus);
+ }
+ }
+ }
+ return status;
+ }
+
+ /**
+ * Checks if the base classes need to be verified (ie they must exist in the project)
+ *
+ * @return <code>true</code> if the base classes should be verified
+ */
+ public boolean verifyBaseClasses() {
+ return NewClassWizardPrefs.verifyBaseClasses();
+ }
+
+ /**
+ * Hook method that gets called when the list of method stubs has changed. The method
+ * validates the method stubs and returns the status of the validation.
+ *
+ * @return the status of the validation
+ */
protected IStatus methodStubsChanged() {
- // do nothing
- return Status.OK_STATUS;
+ // do nothing
+ return Status.OK_STATUS;
}
- /**
- * Hook method that gets called when the header file has changed. The method
- * validates the header file and returns the status of the validation.
- *
- * @return the status of the validation
- */
+ /**
+ * Hook method that gets called when the header file has changed. The method
+ * validates the header file and returns the status of the validation.
+ *
+ * @return the status of the validation
+ */
protected IStatus headerFileChanged() {
StatusInfo status = new StatusInfo();
@@ -1817,8 +1826,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
boolean fileExists = false;
// Check if the file already exists
IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path);
- if (file.getType() == IResource.FILE) {
- if (!file.exists()) {
+ if (file.getType() == IResource.FILE) {
+ if (!file.exists()) {
URI location = file.getLocationURI();
try {
IFileStore store = EFS.getStore(location);
@@ -1827,9 +1836,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_LocationUnknown);
return status;
}
- } else {
- fileExists = true;
- }
+ } else {
+ fileExists = true;
+ }
IProject proj = file.getProject();
if (!proj.isOpen()) {
@@ -1837,42 +1846,47 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return status;
}
- if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+ if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject);
} else if (fileExists) {
- status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_HeaderFileExists);
+ status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_HeaderFileExists);
}
- } else {
- status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
- return status;
- }
+ } else {
+ status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
+ return status;
+ }
// Check if folder exists
IPath folderPath = path.removeLastSegments(1).makeRelative();
IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath);
- if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
+ if (folder == null || !folder.exists()
+ || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+ status.setError(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
return status;
}
if (!fileExists) {
IStatus val = CConventions.validateHeaderFileName(getCurrentProject().getProject(), path.lastSegment());
if (val.getSeverity() == IStatus.ERROR) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidHeaderFileName, val.getMessage()));
+ status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidHeaderFileName,
+ val.getMessage()));
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
- status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_HeaderFileNameDiscouraged, val.getMessage()));
+ status.setWarning(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_HeaderFileNameDiscouraged,
+ val.getMessage()));
}
}
return status;
}
- /**
- * Hook method that gets called when the source file has changed. The method
- * validates the source file and returns the status of the validation.
- *
- * @return the status of the validation
- */
+ /**
+ * Hook method that gets called when the source file has changed. The method
+ * validates the source file and returns the status of the validation.
+ *
+ * @return the status of the validation
+ */
protected IStatus sourceFileChanged() {
StatusInfo status = new StatusInfo();
@@ -1897,8 +1911,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
boolean fileExists = false;
// Check if file already exists
IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path);
- if (file.getType() == IResource.FILE) {
- if (!file.exists()) {
+ if (file.getType() == IResource.FILE) {
+ if (!file.exists()) {
URI location = file.getLocationURI();
try {
IFileStore store = EFS.getStore(location);
@@ -1907,9 +1921,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_LocationUnknown);
return status;
}
- } else {
- fileExists = true;
- }
+ } else {
+ fileExists = true;
+ }
IProject proj = file.getProject();
if (!proj.isOpen()) {
@@ -1917,43 +1931,48 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return status;
}
- if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+ if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject);
} else if (fileExists) {
- status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_SourceFileExists);
+ status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_SourceFileExists);
}
- } else {
- status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
- return status;
- }
+ } else {
+ status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
+ return status;
+ }
// Check if folder exists
IPath folderPath = path.removeLastSegments(1).makeRelative();
IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath);
- if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
+ if (folder == null || !folder.exists()
+ || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+ status.setError(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
return status;
}
if (!fileExists) {
IStatus val = CConventions.validateSourceFileName(getCurrentProject().getProject(), path.lastSegment());
if (val.getSeverity() == IStatus.ERROR) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidSourceFileName, val.getMessage()));
+ status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidSourceFileName,
+ val.getMessage()));
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
- status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_SourceFileNameDiscouraged, val.getMessage()));
+ status.setWarning(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_SourceFileNameDiscouraged,
+ val.getMessage()));
}
}
return status;
}
- /**
- * Hook method that gets called when the test file has changed. The method
- * validates the test file and returns the status of the validation.
- *
- * @return the status of the validation
- * @since 5.3
- */
+ /**
+ * Hook method that gets called when the test file has changed. The method
+ * validates the test file and returns the status of the validation.
+ *
+ * @return the status of the validation
+ * @since 5.3
+ */
protected IStatus testFileChanged() {
StatusInfo status = new StatusInfo();
@@ -1981,8 +2000,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
boolean fileExists = false;
// Check if file already exists
IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path);
- if (file.getType() == IResource.FILE) {
- if (!file.exists()) {
+ if (file.getType() == IResource.FILE) {
+ if (!file.exists()) {
URI location = file.getLocationURI();
try {
IFileStore store = EFS.getStore(location);
@@ -1991,9 +2010,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_LocationUnknown);
return status;
}
- } else {
- fileExists = true;
- }
+ } else {
+ fileExists = true;
+ }
IProject proj = file.getProject();
if (!proj.isOpen()) {
@@ -2001,37 +2020,42 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return status;
}
- if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+ if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject);
} else if (fileExists) {
- status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_TestFileExists);
+ status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_TestFileExists);
}
- } else {
- status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
- return status;
- }
+ } else {
+ status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
+ return status;
+ }
// Check if folder exists
IPath folderPath = path.removeLastSegments(1).makeRelative();
IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath);
- if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
+ if (folder == null || !folder.exists()
+ || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+ status.setError(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
return status;
}
if (!fileExists) {
IStatus val = CConventions.validateSourceFileName(getCurrentProject().getProject(), path.lastSegment());
if (val.getSeverity() == IStatus.ERROR) {
- status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidTestFileName, val.getMessage()));
+ status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidTestFileName,
+ val.getMessage()));
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
- status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_TestFileNameDiscouraged, val.getMessage()));
+ status.setWarning(
+ NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_TestFileNameDiscouraged,
+ val.getMessage()));
}
}
return status;
}
- // -------- Code Generation ---------
+ // -------- Code Generation ---------
/**
* Creates the new class using the entered field values.
@@ -2045,87 +2069,79 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
fDialogSettings.put(KEY_TEST_FILE_SELECTED, fTestFileSelection.isSelected());
String namespace = fNamespaceSelection.isSelected() ? getNamespaceText() : null;
fDialogSettings.put(KEY_NAMESPACE, namespace);
- IMethodStub[] stubs = fMethodStubsDialogField.getMethodStubs();
- for (int i = 0; i < stubs.length; ++i) {
- IMethodStub stub = stubs[i];
- if (stub.canModifyVirtual()) {
- fDialogSettings.put(KEY_STUB_VIRTUAL + i, stub.isVirtual());
- }
- if (stub.canModifyInline()) {
- fDialogSettings.put(KEY_STUB_INLINE + i, stub.isInline());
- }
- fDialogSettings.put(KEY_STUB_SELECTED + i, fMethodStubsDialogField.isChecked(stub));
- }
-
- fCreatedClass = null;
- fCreatedHeaderFile = null;
- fCreatedSourceFile = null;
- fCreatedTestFile = null;
-
- IPath headerPath = getHeaderFileFullPath();
- IPath sourcePath = getSourceFileFullPath();
- IPath testPath = getTestFileFullPath();
- createClass(headerPath, sourcePath, testPath, getClassName(), namespace, getBaseClasses(),
- getSelectedMethodStubs(), monitor);
- }
-
- /**
- * Returns whether the generated header and source files should be
- * opened in editors after the finish button is pressed.
- *
- * @return <code>true</code> if the header and source file should be
- * displayed
- */
- public boolean openClassInEditor() {
- return NewClassWizardPrefs.openClassInEditor();
- }
-
- /**
- * Creates a new class.
- *
- * @param headerPath the header file path
- * @param sourcePath the source file path
- * @param testPath the test file path, can be {@code null}.
- * @param className the class name
- * @param namespace the namespace
- * @param baseClasses array of base classes
- * @param methodStubs array of method stubs
- * @param monitor a progress monitor
- * @throws CoreException if the creation failed
- * @since 5.3
- *
- * @noreference This method is not intended to be referenced by clients.
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- */
- protected void createClass(IPath headerPath, IPath sourcePath, IPath testPath, String className,
- String namespace, IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor)
- throws CoreException {
- NewClassCodeGenerator generator = new NewClassCodeGenerator(
- headerPath,
- sourcePath,
- testPath,
- className,
- namespace,
- baseClasses,
- methodStubs);
- generator.setForceSourceFileCreation(true);
- generator.createClass(monitor);
-
- fCreatedClass = generator.getCreatedClass();
- fCreatedHeaderFile = generator.getCreatedHeaderFile();
- fCreatedSourceFile = generator.getCreatedSourceFile();
- fCreatedTestFile = generator.getCreatedTestFile();
- }
-
- /**
- * @noreference This method is not intended to be referenced by clients.
- * @nooverride This method is not intended to be re-implemented or extended by clients.
- */
- protected void createClass(IPath headerPath, IPath sourcePath, String className, String namespace,
- IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor)
- throws CoreException {
- createClass(headerPath, sourcePath, null, className, namespace, baseClasses, methodStubs, monitor);
- }
+ IMethodStub[] stubs = fMethodStubsDialogField.getMethodStubs();
+ for (int i = 0; i < stubs.length; ++i) {
+ IMethodStub stub = stubs[i];
+ if (stub.canModifyVirtual()) {
+ fDialogSettings.put(KEY_STUB_VIRTUAL + i, stub.isVirtual());
+ }
+ if (stub.canModifyInline()) {
+ fDialogSettings.put(KEY_STUB_INLINE + i, stub.isInline());
+ }
+ fDialogSettings.put(KEY_STUB_SELECTED + i, fMethodStubsDialogField.isChecked(stub));
+ }
+
+ fCreatedClass = null;
+ fCreatedHeaderFile = null;
+ fCreatedSourceFile = null;
+ fCreatedTestFile = null;
+
+ IPath headerPath = getHeaderFileFullPath();
+ IPath sourcePath = getSourceFileFullPath();
+ IPath testPath = getTestFileFullPath();
+ createClass(headerPath, sourcePath, testPath, getClassName(), namespace, getBaseClasses(),
+ getSelectedMethodStubs(), monitor);
+ }
+
+ /**
+ * Returns whether the generated header and source files should be
+ * opened in editors after the finish button is pressed.
+ *
+ * @return <code>true</code> if the header and source file should be
+ * displayed
+ */
+ public boolean openClassInEditor() {
+ return NewClassWizardPrefs.openClassInEditor();
+ }
+
+ /**
+ * Creates a new class.
+ *
+ * @param headerPath the header file path
+ * @param sourcePath the source file path
+ * @param testPath the test file path, can be {@code null}.
+ * @param className the class name
+ * @param namespace the namespace
+ * @param baseClasses array of base classes
+ * @param methodStubs array of method stubs
+ * @param monitor a progress monitor
+ * @throws CoreException if the creation failed
+ * @since 5.3
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+ protected void createClass(IPath headerPath, IPath sourcePath, IPath testPath, String className, String namespace,
+ IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor) throws CoreException {
+ NewClassCodeGenerator generator = new NewClassCodeGenerator(headerPath, sourcePath, testPath, className,
+ namespace, baseClasses, methodStubs);
+ generator.setForceSourceFileCreation(true);
+ generator.createClass(monitor);
+
+ fCreatedClass = generator.getCreatedClass();
+ fCreatedHeaderFile = generator.getCreatedHeaderFile();
+ fCreatedSourceFile = generator.getCreatedSourceFile();
+ fCreatedTestFile = generator.getCreatedTestFile();
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+ protected void createClass(IPath headerPath, IPath sourcePath, String className, String namespace,
+ IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor) throws CoreException {
+ createClass(headerPath, sourcePath, null, className, namespace, baseClasses, methodStubs, monitor);
+ }
/**
* Returns the created class. The method only returns a valid class
@@ -2135,40 +2151,40 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @see #createClass(IProgressMonitor)
*/
public ICElement getCreatedClass() {
- return fCreatedClass;
- }
-
- /**
- * Returns the created header file. The method only returns a valid file
- * after {@link #createClass} has been called.
- *
- * @return the created header file
- * @see #createClass(IProgressMonitor)
- */
- public IFile getCreatedHeaderFile() {
- return fCreatedHeaderFile;
- }
-
- /**
- * Returns the created source file. The method only returns a valid file
- * after {@link #createClass} has been called.
- *
- * @return the created source file
- * @see #createClass(IProgressMonitor)
- */
- public IFile getCreatedSourceFile() {
- return fCreatedSourceFile;
- }
-
- /**
- * Returns the created test file. The method only returns a valid file
- * after {@link #createClass} has been called.
- *
- * @return the created test file
- * @see #createClass(IProgressMonitor)
- * @since 5.3
- */
- public IFile getCreatedTestFile() {
- return fCreatedTestFile;
- }
+ return fCreatedClass;
+ }
+
+ /**
+ * Returns the created header file. The method only returns a valid file
+ * after {@link #createClass} has been called.
+ *
+ * @return the created header file
+ * @see #createClass(IProgressMonitor)
+ */
+ public IFile getCreatedHeaderFile() {
+ return fCreatedHeaderFile;
+ }
+
+ /**
+ * Returns the created source file. The method only returns a valid file
+ * after {@link #createClass} has been called.
+ *
+ * @return the created source file
+ * @see #createClass(IProgressMonitor)
+ */
+ public IFile getCreatedSourceFile() {
+ return fCreatedSourceFile;
+ }
+
+ /**
+ * Returns the created test file. The method only returns a valid file
+ * after {@link #createClass} has been called.
+ *
+ * @return the created test file
+ * @see #createClass(IProgressMonitor)
+ * @since 5.3
+ */
+ public IFile getCreatedTestFile() {
+ return fCreatedTestFile;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java
index b826f6c50d4..0903680b05a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java
@@ -20,22 +20,22 @@ import org.eclipse.cdt.internal.ui.wizards.filewizard.NewHeaderFileCreationWizar
import org.eclipse.cdt.ui.CUIPlugin;
public class NewHeaderFileCreationWizard extends AbstractFileCreationWizard {
-
- public NewHeaderFileCreationWizard() {
- super();
- setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_HEADERFILE);
- setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
- setWindowTitle(NewFileWizardMessages.NewHeaderFileCreationWizard_title);
- }
-
- /*
- * @see Wizard#createPages
- */
- @Override
+
+ public NewHeaderFileCreationWizard() {
+ super();
+ setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_HEADERFILE);
+ setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+ setWindowTitle(NewFileWizardMessages.NewHeaderFileCreationWizard_title);
+ }
+
+ /*
+ * @see Wizard#createPages
+ */
+ @Override
public void addPages() {
- super.addPages();
- fPage = new NewHeaderFileCreationWizardPage();
- addPage(fPage);
- fPage.init(getSelection());
- }
+ super.addPages();
+ fPage = new NewHeaderFileCreationWizardPage();
+ addPage(fPage);
+ fPage.init(getSelection());
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java
index c1afc493cdd..fd586920540 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java
@@ -20,22 +20,22 @@ import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileCreationWizar
import org.eclipse.cdt.ui.CUIPlugin;
public class NewSourceFileCreationWizard extends AbstractFileCreationWizard {
-
- public NewSourceFileCreationWizard() {
- super();
- setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_SOURCEFILE);
- setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
- setWindowTitle(NewFileWizardMessages.NewSourceFileCreationWizard_title);
- }
-
- /*
- * @see Wizard#createPages
- */
- @Override
+
+ public NewSourceFileCreationWizard() {
+ super();
+ setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_SOURCEFILE);
+ setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+ setWindowTitle(NewFileWizardMessages.NewSourceFileCreationWizard_title);
+ }
+
+ /*
+ * @see Wizard#createPages
+ */
+ @Override
public void addPages() {
- super.addPages();
- fPage = new NewSourceFileCreationWizardPage();
- addPage(fPage);
- fPage.init(getSelection());
- }
+ super.addPages();
+ fPage = new NewSourceFileCreationWizardPage();
+ addPage(fPage);
+ fPage.init(getSelection());
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java
index fd6c0041237..d1925f8acbe 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java
@@ -36,19 +36,19 @@ public class NewSourceFolderCreationWizard extends NewElementWizard {
@Override
public void addPages() {
super.addPages();
- fPage= new NewSourceFolderWizardPage();
+ fPage = new NewSourceFolderWizardPage();
addPage(fPage);
fPage.init(getSelection());
- }
+ }
@Override
protected void finishPage(IProgressMonitor monitor) throws CoreException {
fPage.createSourceRoot(monitor); // Use the full progress monitor.
}
-
+
@Override
public boolean performFinish() {
- boolean res= super.performFinish();
+ boolean res = super.performFinish();
if (res) {
selectAndReveal(fPage.getCorrespondingResource());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java
index 67553d896a8..48e0e0a074c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.wizards.conversion;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -27,144 +26,146 @@ import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
* change the nature of their projects. This class cannot be implemented. It
* is meant to be subclassed, with the subclasses providing the new labels,
* and pages.
- *
+ *
* @author Judy N. Green
* @since Aug 8, 2002
*/
-public abstract class ConversionWizard
- extends NewCProjectWizard {
-
- // Titles and descriptions may be overwritten by subclasses through the accessor methods.
- private static final String WZ_TITLE = "ConversionWizard.title"; //$NON-NLS-1$
- private static final String WZ_DESC = "ConversionWizard.description"; //$NON-NLS-1$
- private static final String PREFIX = "ConversionWizard"; //$NON-NLS-1$
-
- // Window Title should be overwritten by subclasses
- private static final String WINDOW_TITLE = "ConversionWizard.windowTitle"; //$NON-NLS-1$
-
- // the wizards main page containing the list of projects that the user may select for conversion.
- protected ConvertProjectWizardPage mainPage;
-
- /**
- * Conversion Wizard constructor
- */
- public ConversionWizard() {
- this(getWindowTitleResource(), getWzDescriptionResource());
- }
-
- /**
- * Conversion Wizard constructor
- *
- * @param title
- * @param desc
- */
- public ConversionWizard(String title, String desc) {
- super(title, desc);
- }
-
- /* (non-Javadoc)
- * Method declared on IWorkbenchWizard.
- */
- @Override
+public abstract class ConversionWizard extends NewCProjectWizard {
+
+ // Titles and descriptions may be overwritten by subclasses through the accessor methods.
+ private static final String WZ_TITLE = "ConversionWizard.title"; //$NON-NLS-1$
+ private static final String WZ_DESC = "ConversionWizard.description"; //$NON-NLS-1$
+ private static final String PREFIX = "ConversionWizard"; //$NON-NLS-1$
+
+ // Window Title should be overwritten by subclasses
+ private static final String WINDOW_TITLE = "ConversionWizard.windowTitle"; //$NON-NLS-1$
+
+ // the wizards main page containing the list of projects that the user may select for conversion.
+ protected ConvertProjectWizardPage mainPage;
+
+ /**
+ * Conversion Wizard constructor
+ */
+ public ConversionWizard() {
+ this(getWindowTitleResource(), getWzDescriptionResource());
+ }
+
+ /**
+ * Conversion Wizard constructor
+ *
+ * @param title
+ * @param desc
+ */
+ public ConversionWizard(String title, String desc) {
+ super(title, desc);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchWizard.
+ */
+ @Override
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
- super.init(workbench, currentSelection);
- setWindowTitle(getWindowTitleResource());
- }
-
- /**
- * Method getWindowTitleResource, allows Wizard Title label value to be
- * changed by subclasses
- *
- * @return String
- */
- protected static String getWindowTitleResource() {
-
- return CUIPlugin.getResourceString(WINDOW_TITLE);
- }
-
- /**
- * Method getWzDescriptionResource, allows Wizard description label value
- * to be changed by subclasses
- *
- * @return String
- */
- protected static String getWzDescriptionResource() {
-
- return CUIPlugin.getResourceString(WZ_DESC);
- }
-
- /**
- * Method getWzTitleResource, allows Wizard description label value
- * to be changed by subclasses
- *
- * @return String
- */
- protected static String getWzTitleResource() {
-
- return CUIPlugin.getResourceString(WZ_TITLE);
- }
-
- /**
- * Method getPrefix, allows prefix value to be changed by subclasses
- *
- * @return String
- */
- protected static String getPrefix() {
-
- return PREFIX;
- }
-
- /**
- * Method doRun calls the doRunPrologue and mainPage's doRun method and the
- * doRunEpliogue. Subclasses may overwrite to add further actions
- */
- @Override
+ super.init(workbench, currentSelection);
+ setWindowTitle(getWindowTitleResource());
+ }
+
+ /**
+ * Method getWindowTitleResource, allows Wizard Title label value to be
+ * changed by subclasses
+ *
+ * @return String
+ */
+ protected static String getWindowTitleResource() {
+
+ return CUIPlugin.getResourceString(WINDOW_TITLE);
+ }
+
+ /**
+ * Method getWzDescriptionResource, allows Wizard description label value
+ * to be changed by subclasses
+ *
+ * @return String
+ */
+ protected static String getWzDescriptionResource() {
+
+ return CUIPlugin.getResourceString(WZ_DESC);
+ }
+
+ /**
+ * Method getWzTitleResource, allows Wizard description label value
+ * to be changed by subclasses
+ *
+ * @return String
+ */
+ protected static String getWzTitleResource() {
+
+ return CUIPlugin.getResourceString(WZ_TITLE);
+ }
+
+ /**
+ * Method getPrefix, allows prefix value to be changed by subclasses
+ *
+ * @return String
+ */
+ protected static String getPrefix() {
+
+ return PREFIX;
+ }
+
+ /**
+ * Method doRun calls the doRunPrologue and mainPage's doRun method and the
+ * doRunEpliogue. Subclasses may overwrite to add further actions
+ */
+ @Override
protected void doRun(IProgressMonitor monitor) throws CoreException {
- try{
- mainPage.doRun(monitor, getProjectID(), getBuildSystemId());
- } catch (CoreException ce){
- CUIPlugin.log(ce);
- throw ce;
- } finally{
- doRunEpilogue(monitor);
- monitor.isCanceled();
- }
- }
- /**
- * Return the type of project that it is being converted to
- * The default if a make project
- */
- @Override
+ try {
+ mainPage.doRun(monitor, getProjectID(), getBuildSystemId());
+ } catch (CoreException ce) {
+ CUIPlugin.log(ce);
+ throw ce;
+ } finally {
+ doRunEpilogue(monitor);
+ monitor.isCanceled();
+ }
+ }
+
+ /**
+ * Return the type of project that it is being converted to
+ * The default if a make project
+ */
+ @Override
public abstract String getProjectID();
- /**
- * Method addPages allows subclasses to add as many pages as they need. Overwrite
- * to create at least one conversion specific page. <p>
- *
- * i.e. <br>
- *<pre>
- * mainPage = new ConvertToStdMakeProjectWizardPage(getPrefix());
- * addPage(mainPage);
- *</pre>
- *
- * @see NewCProjectWizard#addPages
- */
- @Override
+ /**
+ * Method addPages allows subclasses to add as many pages as they need. Overwrite
+ * to create at least one conversion specific page. <p>
+ *
+ * i.e. <br>
+ *<pre>
+ * mainPage = new ConvertToStdMakeProjectWizardPage(getPrefix());
+ * addPage(mainPage);
+ *</pre>
+ *
+ * @see NewCProjectWizard#addPages
+ */
+ @Override
public abstract void addPages();
- /**
- * Required by superclass but with no implementation here
- *
- * @param monitor
- */
- @Override
- protected void doRunPrologue(IProgressMonitor monitor) {}
-
- /**
- * Required by superclass but with no implementation here
- *
- * @param monitor
- */
- @Override
- protected void doRunEpilogue(IProgressMonitor monitor) {}
+ /**
+ * Required by superclass but with no implementation here
+ *
+ * @param monitor
+ */
+ @Override
+ protected void doRunPrologue(IProgressMonitor monitor) {
+ }
+
+ /**
+ * Required by superclass but with no implementation here
+ *
+ * @param monitor
+ */
+ @Override
+ protected void doRunEpilogue(IProgressMonitor monitor) {
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java
index dea5dfb1a90..41d215f60cf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.ui.wizards.conversion;
-
import java.util.Vector;
import org.eclipse.core.resources.IProject;
@@ -63,7 +62,6 @@ import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.util.SWTUtil;
-
/**
* <p>
* ConvertProjectWizardPage Standard main page for a wizard that converts a
@@ -81,86 +79,84 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
* @author Judy N. Green
* @since Aug 6, 2002 <p>
*/
-public abstract class ConvertProjectWizardPage
- extends WizardPage {
+public abstract class ConvertProjectWizardPage extends WizardPage {
- public static final String KEY_TITLE = "ConvertionWizard.title"; //$NON-NLS-1$
- public static final String KEY_CONVERTING = "ConvertionWizard.converting"; //$NON-NLS-1$
- private static final String PROJECT_LIST = "ConversionWizard.projectlist"; //$NON-NLS-1$
+ public static final String KEY_TITLE = "ConvertionWizard.title"; //$NON-NLS-1$
+ public static final String KEY_CONVERTING = "ConvertionWizard.converting"; //$NON-NLS-1$
+ private static final String PROJECT_LIST = "ConversionWizard.projectlist"; //$NON-NLS-1$
protected boolean convertToC = false;
- protected boolean convertToCC = true;
- protected Button cRadioButton;
- protected Button ccRadioButton;
-
- // The Main widget containing the table and its list of candidate open projects
- protected CheckboxTableViewer tableViewer;
-
- protected Button selectAllButton;
- protected Button deselectAllButton;
-
- // We only need to calculate this once per instantiation of this wizard
- protected Object[] listItems = null;
-
- /**
- * Constructor for ConvertProjectWizardPage.
- *
- * @param pageName
- */
- public ConvertProjectWizardPage(String pageName) {
- super(pageName);
- setTitle(getWzTitleResource());
- setDescription(getWzDescriptionResource());
- }
-
- // get methods to allow values to be changed by subclasses
- protected abstract String getWzTitleResource();
-
- protected abstract String getWzDescriptionResource();
-
- /**
- * Returns the elements that the user has checked
- *
- * @return Object[]
- */
- protected Object[] getCheckedElements() {
-
- return tableViewer.getCheckedElements();
- }
-
- /**
- * Creates the main wizard page.
- *
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
- */
- @Override
+ protected boolean convertToCC = true;
+ protected Button cRadioButton;
+ protected Button ccRadioButton;
+
+ // The Main widget containing the table and its list of candidate open projects
+ protected CheckboxTableViewer tableViewer;
+
+ protected Button selectAllButton;
+ protected Button deselectAllButton;
+
+ // We only need to calculate this once per instantiation of this wizard
+ protected Object[] listItems = null;
+
+ /**
+ * Constructor for ConvertProjectWizardPage.
+ *
+ * @param pageName
+ */
+ public ConvertProjectWizardPage(String pageName) {
+ super(pageName);
+ setTitle(getWzTitleResource());
+ setDescription(getWzDescriptionResource());
+ }
+
+ // get methods to allow values to be changed by subclasses
+ protected abstract String getWzTitleResource();
+
+ protected abstract String getWzDescriptionResource();
+
+ /**
+ * Returns the elements that the user has checked
+ *
+ * @return Object[]
+ */
+ protected Object[] getCheckedElements() {
+
+ return tableViewer.getCheckedElements();
+ }
+
+ /**
+ * Creates the main wizard page.
+ *
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
+ */
+ @Override
public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NONE);
-
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- container.setLayout(layout);
- setControl(createAvailableProjectsGroup(container));
- addToMainPage(container);
- // will default to false until a selection is made
- setPageComplete(validatePage());
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.CONVERT_TO_CCPP_WIZARD_PAGE);
- }
-
- /**
- * Method addToMainPage allows subclasses to add
- * elements to the main page.
- *
- */
- protected void addToMainPage(Composite container){
+ Composite container = new Composite(parent, SWT.NONE);
+
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ container.setLayout(layout);
+ setControl(createAvailableProjectsGroup(container));
+ addToMainPage(container);
+ // will default to false until a selection is made
+ setPageComplete(validatePage());
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.CONVERT_TO_CCPP_WIZARD_PAGE);
+ }
+
+ /**
+ * Method addToMainPage allows subclasses to add
+ * elements to the main page.
+ *
+ */
+ protected void addToMainPage(Composite container) {
// Add convert to C or C/C++ buttons
Composite area = ControlFactory.createGroup(container, CUIMessages.ConvertProjectWizardPage_convertTo, 2);
-
- SelectionListener cListener = new SelectionAdapter() {
+ SelectionListener cListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
convertToC = cRadioButton.getSelection();
@@ -168,15 +164,11 @@ public abstract class ConvertProjectWizardPage
validatePage();
}
};
- cRadioButton = ControlFactory.createRadioButton(area,
- CUIMessages.ConvertProjectWizardPage_CProject,
- "C ", //$NON-NLS-1$
- cListener);
+ cRadioButton = ControlFactory.createRadioButton(area, CUIMessages.ConvertProjectWizardPage_CProject, "C ", //$NON-NLS-1$
+ cListener);
cRadioButton.setSelection(convertToC);
- ccRadioButton = ControlFactory.createRadioButton(area,
- CUIMessages.ConvertProjectWizardPage_CppProject,
- "C++", //$NON-NLS-1$
- cListener);
+ ccRadioButton = ControlFactory.createRadioButton(area, CUIMessages.ConvertProjectWizardPage_CppProject, "C++", //$NON-NLS-1$
+ cListener);
ccRadioButton.setSelection(convertToCC);
area.addDisposeListener(new DisposeListener() {
@@ -186,407 +178,371 @@ public abstract class ConvertProjectWizardPage
ccRadioButton = null;
}
});
- }
-
- /**
- * Creates a list of projects that can be selected by the user.
- *
- * @param parent the parent composite
- * @return Composite
- */
- private final Composite createAvailableProjectsGroup(Composite parent) {
-
- // Add a label
- Label label = new Label(parent, SWT.LEFT);
- label.setText(CUIPlugin.getResourceString(PROJECT_LIST));
-
- Composite container = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- layout.numColumns = 2;
- container.setLayout(layout);
- GridData data = new GridData(GridData.FILL_BOTH);
- container.setLayoutData(data);
-
- // create the table
- Table table = new Table(container,
- SWT.CHECK | SWT.BORDER | SWT.MULTI |
- SWT.SINGLE | SWT.H_SCROLL |
- SWT.V_SCROLL);
- data = new GridData(GridData.FILL_BOTH);
- table.setLayoutData(data);
- table.setHeaderVisible(true);
- table.setLinesVisible(false);
- table.getAccessible().addAccessibleListener(
- new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result = CUIPlugin.getResourceString(PROJECT_LIST);
- }
- }
- );
-
- TableLayout tableLayout = new TableLayout();
- table.setHeaderVisible(false);
- table.setLayout(tableLayout);
-
- // add a table viewer
- tableViewer = new CheckboxTableViewer(table);
- tableViewer.setLabelProvider(new ProjectLabelProvider());
- tableViewer.setContentProvider(new ProjectContentProvider());
-
- // set initial input
- tableViewer.setInput(getElements());
-
- // define and assign sorter
- tableViewer.setSorter(new ViewerSorter() {
- @Override
+ }
+
+ /**
+ * Creates a list of projects that can be selected by the user.
+ *
+ * @param parent the parent composite
+ * @return Composite
+ */
+ private final Composite createAvailableProjectsGroup(Composite parent) {
+
+ // Add a label
+ Label label = new Label(parent, SWT.LEFT);
+ label.setText(CUIPlugin.getResourceString(PROJECT_LIST));
+
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 5;
+ layout.marginWidth = 5;
+ layout.numColumns = 2;
+ container.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ container.setLayoutData(data);
+
+ // create the table
+ Table table = new Table(container,
+ SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ data = new GridData(GridData.FILL_BOTH);
+ table.setLayoutData(data);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(false);
+ table.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ e.result = CUIPlugin.getResourceString(PROJECT_LIST);
+ }
+ });
+
+ TableLayout tableLayout = new TableLayout();
+ table.setHeaderVisible(false);
+ table.setLayout(tableLayout);
+
+ // add a table viewer
+ tableViewer = new CheckboxTableViewer(table);
+ tableViewer.setLabelProvider(new ProjectLabelProvider());
+ tableViewer.setContentProvider(new ProjectContentProvider());
+
+ // set initial input
+ tableViewer.setInput(getElements());
+
+ // define and assign sorter
+ tableViewer.setSorter(new ViewerSorter() {
+ @Override
public int compare(Viewer viewer, Object object1, Object object2) {
- if ((object1 instanceof IProject) && (object2 instanceof IProject)) {
- IProject left = (IProject)object1;
- IProject right = (IProject)object2;
- int result = left.getName().compareToIgnoreCase(right.getName());
+ if ((object1 instanceof IProject) && (object2 instanceof IProject)) {
+ IProject left = (IProject) object1;
+ IProject right = (IProject) object2;
+ int result = left.getName().compareToIgnoreCase(right.getName());
- if (result != 0) {
- return result;
- }
- return left.getName().compareToIgnoreCase(right.getName());
- }
- return super.compare(viewer, object1, object2);
- }
+ if (result != 0) {
+ return result;
+ }
+ return left.getName().compareToIgnoreCase(right.getName());
+ }
+ return super.compare(viewer, object1, object2);
+ }
- @Override
+ @Override
public boolean isSorterProperty(Object element, String property) {
- return true;
- }
- });
- tableViewer.setAllChecked(false);
- tableViewer.refresh();
-
- tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
+ return true;
+ }
+ });
+ tableViewer.setAllChecked(false);
+ tableViewer.refresh();
+
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
public void selectionChanged(SelectionChangedEvent e) {
- // will default to false until a selection is made
- setPageComplete(validatePage());
- updateSelectionButtons();
- }
- });
- // Add button panel
-
- Composite buttons= new Composite(container, SWT.NULL);
- buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.verticalSpacing = 8;
- buttons.setLayout(layout);
-
-
- selectAllButton= new Button(buttons, SWT.PUSH);
- selectAllButton.setText(CUIMessages.ConvertProjectWizardPage_SelectAll);
- selectAllButton.setLayoutData(getButtonGridData(selectAllButton));
- selectAllButton.addListener(SWT.Selection, new Listener() {
- @Override
+ // will default to false until a selection is made
+ setPageComplete(validatePage());
+ updateSelectionButtons();
+ }
+ });
+ // Add button panel
+
+ Composite buttons = new Composite(container, SWT.NULL);
+ buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 8;
+ buttons.setLayout(layout);
+
+ selectAllButton = new Button(buttons, SWT.PUSH);
+ selectAllButton.setText(CUIMessages.ConvertProjectWizardPage_SelectAll);
+ selectAllButton.setLayoutData(getButtonGridData(selectAllButton));
+ selectAllButton.addListener(SWT.Selection, new Listener() {
+ @Override
public void handleEvent(Event e) {
- ConvertProjectWizardPage.this.tableViewer.setAllChecked(true);
- // update the pageComplete status
- setPageComplete(true);
- updateSelectionButtons();
- }
- });
-
- deselectAllButton= new Button(buttons, SWT.PUSH);
- deselectAllButton.setText(CUIMessages.ConvertProjectWizardPage_DeselectAll);
- deselectAllButton.setLayoutData(getButtonGridData(deselectAllButton));
- deselectAllButton.addListener(SWT.Selection, new Listener() {
- @Override
+ ConvertProjectWizardPage.this.tableViewer.setAllChecked(true);
+ // update the pageComplete status
+ setPageComplete(true);
+ updateSelectionButtons();
+ }
+ });
+
+ deselectAllButton = new Button(buttons, SWT.PUSH);
+ deselectAllButton.setText(CUIMessages.ConvertProjectWizardPage_DeselectAll);
+ deselectAllButton.setLayoutData(getButtonGridData(deselectAllButton));
+ deselectAllButton.addListener(SWT.Selection, new Listener() {
+ @Override
public void handleEvent(Event e) {
- ConvertProjectWizardPage.this.tableViewer.setAllChecked(false);
- // update the pageComplete status
- setPageComplete(false);
- updateSelectionButtons();
- }
- });
-
- // enable or disable selection buttons
- Object[] elements = getElements();
- boolean enableSelectionButtons = (elements != null) && (elements.length > 0);
-
- selectAllButton.setEnabled(enableSelectionButtons);
- // we've called setAllChecked(false) earlier
- deselectAllButton.setEnabled(false);
-
- return parent;
- }
-
- /*
- * Method updateSelectionButtons, enables/disables buttons
- * dependent on what is selected
- */
-
- protected void updateSelectionButtons() {
-
- // update select and deselect buttons as required
- Object[] checkedObjects = getCheckedElements();
- int totalItems = tableViewer.getTable().getItemCount();
- boolean allSelected = checkedObjects.length == totalItems;
- boolean noneSelected = checkedObjects.length == 0;
- selectAllButton.setEnabled(!allSelected);
- deselectAllButton.setEnabled(!noneSelected);
- }
- /*
- * Method getButtonGridData creates
- * and returns a GridData for the given button
- *
- * @GridData
- */
- private static GridData getButtonGridData(Button button) {
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint= SWTUtil.getButtonWidthHint(button);
-
- return data;
- }
-
- /**
- * Returns whether this page's controls currently all contain valid values.
- *
- * @return <code>true</code> if the user has selected at least one
- * candidate project.
- */
- protected boolean validatePage() {
-
- Object[] selection = getCheckedElements();
-
- return ((selection != null) && (selection.length > 0));
- }
-
- /**
- * Provides the contents for the list using the enclosing class's method
- * getElements();
- */
- public class ProjectContentProvider
- implements IStructuredContentProvider {
- @Override
+ ConvertProjectWizardPage.this.tableViewer.setAllChecked(false);
+ // update the pageComplete status
+ setPageComplete(false);
+ updateSelectionButtons();
+ }
+ });
+
+ // enable or disable selection buttons
+ Object[] elements = getElements();
+ boolean enableSelectionButtons = (elements != null) && (elements.length > 0);
+
+ selectAllButton.setEnabled(enableSelectionButtons);
+ // we've called setAllChecked(false) earlier
+ deselectAllButton.setEnabled(false);
+
+ return parent;
+ }
+
+ /*
+ * Method updateSelectionButtons, enables/disables buttons
+ * dependent on what is selected
+ */
+
+ protected void updateSelectionButtons() {
+
+ // update select and deselect buttons as required
+ Object[] checkedObjects = getCheckedElements();
+ int totalItems = tableViewer.getTable().getItemCount();
+ boolean allSelected = checkedObjects.length == totalItems;
+ boolean noneSelected = checkedObjects.length == 0;
+ selectAllButton.setEnabled(!allSelected);
+ deselectAllButton.setEnabled(!noneSelected);
+ }
+
+ /*
+ * Method getButtonGridData creates
+ * and returns a GridData for the given button
+ *
+ * @GridData
+ */
+ private static GridData getButtonGridData(Button button) {
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = SWTUtil.getButtonWidthHint(button);
+
+ return data;
+ }
+
+ /**
+ * Returns whether this page's controls currently all contain valid values.
+ *
+ * @return <code>true</code> if the user has selected at least one
+ * candidate project.
+ */
+ protected boolean validatePage() {
+
+ Object[] selection = getCheckedElements();
+
+ return ((selection != null) && (selection.length > 0));
+ }
+
+ /**
+ * Provides the contents for the list using the enclosing class's method
+ * getElements();
+ */
+ public class ProjectContentProvider implements IStructuredContentProvider {
+ @Override
public Object[] getElements(Object parent) {
- return listItems;
- }
-
- @Override
- public void dispose() {}
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {}
- }
-
- /**
- * Provides labels for the listed items. In this case it returns each
- * project's name
- */
- public class ProjectLabelProvider
- extends LabelProvider
- implements ITableLabelProvider {
- @Override
+ return listItems;
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ /**
+ * Provides labels for the listed items. In this case it returns each
+ * project's name
+ */
+ public class ProjectLabelProvider extends LabelProvider implements ITableLabelProvider {
+ @Override
public String getColumnText(Object obj, int index) {
- if (index == 0) {
+ if (index == 0) {
- return ((IProject)obj).getName();
- }
+ return ((IProject) obj).getName();
+ }
- return ""; //$NON-NLS-1$
- }
+ return ""; //$NON-NLS-1$
+ }
- @Override
+ @Override
public Image getColumnImage(Object obj, int index) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(
- IDE.SharedImages.IMG_OBJ_PROJECT);
- }
- }
-
- /**
- * Returns a list of open projects that are determined to be candidates
- * through the method isCandidate().<br>
- *
- * Note: Only Projects that are open will be considered for conversion.
- *
- * @return Object[] which may be null
- */
- protected Object[] getElements() {
-
- IWorkspace workspace = CUIPlugin.getWorkspace();
- IProject[] projects = workspace.getRoot().getProjects();
- Vector<IProject> candidates = new Vector<IProject>(projects.length);
- IProject next = null;
-
- // ensure we only present open, valid candidates to the user
- for (IProject project : projects) {
- next = project;
-
- if ((next != null)
- && next.isOpen()
- && isCandidate(next)) {
- candidates.addElement(next);
- }
-
- next = null;
- }
-
- // convert to an array for return
- Object[] candidateArray = null;
-
- if (candidates.size() > 0) {
- candidateArray = new Object[candidates.size()];
- candidates.copyInto(candidateArray);
- }
- // update the global variable that will
- // be returned by the ProjectContentProvider
- listItems = candidateArray;
-
- return candidateArray;
- }
-
- /**
- * doRun can be overwritten in subclasses to change behaviour, but this is
- * generally not required. It is called from the corresponding Conversion
- * Wizard
- *
- * @param monitor
- * @param projectID
- * @exception CoreException
- */
- public void doRun(IProgressMonitor monitor, String projectID) throws CoreException {
-
- Object[] selection = getCheckedElements();
- int totalSelected = selection.length;
-
- if (totalSelected > 0) {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(CUIPlugin.getResourceString(KEY_TITLE), 1);
- convertProjects(selection, monitor, projectID);
- }
- }
-
- public void doRun(IProgressMonitor monitor, String projectID, String bsId) throws CoreException {
- if(bsId == null)
- doRun(monitor, projectID);
- else {
- Object[] selection = getCheckedElements();
- if (selection != null) {
- int totalSelected = selection.length;
-
- if (totalSelected > 0) {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(CUIPlugin.getResourceString(KEY_TITLE), 1);
- convertProjects(selection, bsId, monitor);
- }
- }
- }
- }
-
- /**
- * convertProjects calls the convertProject() method on each project
- * passed to it.
- *
- * @param selected
- * @param monitor
- * @param projectID
- * @throws CoreException
- */
- private void convertProjects(Object[] selected, IProgressMonitor monitor, String projectID)
- throws CoreException {
- monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING),
- selected.length);
+ return PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT);
+ }
+ }
+
+ /**
+ * Returns a list of open projects that are determined to be candidates
+ * through the method isCandidate().<br>
+ *
+ * Note: Only Projects that are open will be considered for conversion.
+ *
+ * @return Object[] which may be null
+ */
+ protected Object[] getElements() {
+
+ IWorkspace workspace = CUIPlugin.getWorkspace();
+ IProject[] projects = workspace.getRoot().getProjects();
+ Vector<IProject> candidates = new Vector<IProject>(projects.length);
+ IProject next = null;
+
+ // ensure we only present open, valid candidates to the user
+ for (IProject project : projects) {
+ next = project;
+
+ if ((next != null) && next.isOpen() && isCandidate(next)) {
+ candidates.addElement(next);
+ }
+
+ next = null;
+ }
+
+ // convert to an array for return
+ Object[] candidateArray = null;
+
+ if (candidates.size() > 0) {
+ candidateArray = new Object[candidates.size()];
+ candidates.copyInto(candidateArray);
+ }
+ // update the global variable that will
+ // be returned by the ProjectContentProvider
+ listItems = candidateArray;
+
+ return candidateArray;
+ }
+
+ /**
+ * doRun can be overwritten in subclasses to change behaviour, but this is
+ * generally not required. It is called from the corresponding Conversion
+ * Wizard
+ *
+ * @param monitor
+ * @param projectID
+ * @exception CoreException
+ */
+ public void doRun(IProgressMonitor monitor, String projectID) throws CoreException {
+
+ Object[] selection = getCheckedElements();
+ int totalSelected = selection.length;
+
+ if (totalSelected > 0) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(CUIPlugin.getResourceString(KEY_TITLE), 1);
+ convertProjects(selection, monitor, projectID);
+ }
+ }
+
+ public void doRun(IProgressMonitor monitor, String projectID, String bsId) throws CoreException {
+ if (bsId == null)
+ doRun(monitor, projectID);
+ else {
+ Object[] selection = getCheckedElements();
+ if (selection != null) {
+ int totalSelected = selection.length;
+
+ if (totalSelected > 0) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(CUIPlugin.getResourceString(KEY_TITLE), 1);
+ convertProjects(selection, bsId, monitor);
+ }
+ }
+ }
+ }
+
+ /**
+ * convertProjects calls the convertProject() method on each project
+ * passed to it.
+ *
+ * @param selected
+ * @param monitor
+ * @param projectID
+ * @throws CoreException
+ */
+ private void convertProjects(Object[] selected, IProgressMonitor monitor, String projectID) throws CoreException {
+ monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING), selected.length);
try {
- for (Object element : selected) {
- IProject project = (IProject)element;
- convertProject(project, new SubProgressMonitor(monitor, 1), projectID);
- }
+ for (Object element : selected) {
+ IProject project = (IProject) element;
+ convertProject(project, new SubProgressMonitor(monitor, 1), projectID);
+ }
} finally {
- monitor.done();
+ monitor.done();
}
- }
+ }
- private void convertProjects(Object[] selected, String bsId, IProgressMonitor monitor)
- throws CoreException {
- monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING),
- selected.length);
+ private void convertProjects(Object[] selected, String bsId, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING), selected.length);
try {
for (Object element : selected) {
- IProject project = (IProject)element;
- convertProject(project, bsId, new SubProgressMonitor(monitor, 1));
+ IProject project = (IProject) element;
+ convertProject(project, bsId, new SubProgressMonitor(monitor, 1));
}
} finally {
monitor.done();
}
}
- /**
- * Method finish we always finish successfully :)
- *
- * @return boolean
- */
- public boolean finish() {
-
- return true;
- }
-
- /**
- * Must be overwritten in subclasses to change behaviour Determines which
- * projects will be displayed in the list
- *
- * @param project
- * @return boolean
- */
- public abstract boolean isCandidate(IProject project);
-
- /**
- * convertProject must be overwritten in subclasses to change behaviour
- *
- * @param project
- * @param monitor
- * @param projectID
- * @throws CoreException
- */
- public void convertProject(IProject project,
- IProgressMonitor monitor,
- String projectID)
- throws CoreException{
- // Add the correct nature
- if (convertToC) {
- if (!project.hasNature(CProjectNature.C_NATURE_ID)){
- addCNature(project, monitor, true);
- } else {
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)){
- // remove the C++ nature
- CCProjectNature.removeCCNature(project, monitor);
- }
- }
- } else {
- if (convertToCC && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- addCCNature(project, monitor, true);
- }
- }
- }
-
- public void convertProject(IProject project,
- String bsId,
- IProgressMonitor monitor)
- throws CoreException{
+
+ /**
+ * Method finish we always finish successfully :)
+ *
+ * @return boolean
+ */
+ public boolean finish() {
+
+ return true;
+ }
+
+ /**
+ * Must be overwritten in subclasses to change behaviour Determines which
+ * projects will be displayed in the list
+ *
+ * @param project
+ * @return boolean
+ */
+ public abstract boolean isCandidate(IProject project);
+
+ /**
+ * convertProject must be overwritten in subclasses to change behaviour
+ *
+ * @param project
+ * @param monitor
+ * @param projectID
+ * @throws CoreException
+ */
+ public void convertProject(IProject project, IProgressMonitor monitor, String projectID) throws CoreException {
// Add the correct nature
if (convertToC) {
- if (!project.hasNature(CProjectNature.C_NATURE_ID)){
+ if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
addCNature(project, monitor, true);
} else {
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)){
- // remove the C++ nature
- CCProjectNature.removeCCNature(project, monitor);
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ // remove the C++ nature
+ CCProjectNature.removeCCNature(project, monitor);
}
}
} else {
@@ -596,28 +552,47 @@ public abstract class ConvertProjectWizardPage
}
}
- protected void addCNature(IProject project, IProgressMonitor monitor, boolean addMakeBuilder) throws CoreException{
- if ( getWizard() instanceof ConversionWizard) {
- ConversionWizard cw = (ConversionWizard)getWizard();
- if(cw.getBuildSystemId() != null)
+ public void convertProject(IProject project, String bsId, IProgressMonitor monitor) throws CoreException {
+ // Add the correct nature
+ if (convertToC) {
+ if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
+ addCNature(project, monitor, true);
+ } else {
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ // remove the C++ nature
+ CCProjectNature.removeCCNature(project, monitor);
+ }
+ }
+ } else {
+ if (convertToCC && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ addCCNature(project, monitor, true);
+ }
+ }
+ }
+
+ protected void addCNature(IProject project, IProgressMonitor monitor, boolean addMakeBuilder) throws CoreException {
+ if (getWizard() instanceof ConversionWizard) {
+ ConversionWizard cw = (ConversionWizard) getWizard();
+ if (cw.getBuildSystemId() != null)
CCorePlugin.getDefault().convertProjectToNewC(project, cw.getBuildSystemId(), monitor);
else
CCorePlugin.getDefault().convertProjectToC(project, monitor, cw.getProjectID());
}
- }
-
- protected void addCCNature(IProject project, IProgressMonitor monitor, boolean addMakeBuilder) throws CoreException{
- if ( getWizard() instanceof ConversionWizard) {
- if (project.hasNature(CProjectNature.C_NATURE_ID)) {
- CCorePlugin.getDefault().convertProjectFromCtoCC(project, monitor);
- } else {
- ConversionWizard cw = (ConversionWizard)getWizard();
- if(cw.getBuildSystemId() != null)
- CCorePlugin.getDefault().convertProjectToNewCC(project, cw.getBuildSystemId(), monitor);
- else
- CCorePlugin.getDefault().convertProjectToCC(project, monitor, cw.getProjectID());
- }
+ }
+
+ protected void addCCNature(IProject project, IProgressMonitor monitor, boolean addMakeBuilder)
+ throws CoreException {
+ if (getWizard() instanceof ConversionWizard) {
+ if (project.hasNature(CProjectNature.C_NATURE_ID)) {
+ CCorePlugin.getDefault().convertProjectFromCtoCC(project, monitor);
+ } else {
+ ConversionWizard cw = (ConversionWizard) getWizard();
+ if (cw.getBuildSystemId() != null)
+ CCorePlugin.getDefault().convertProjectToNewCC(project, cw.getBuildSystemId(), monitor);
+ else
+ CCorePlugin.getDefault().convertProjectToCC(project, monitor, cw.getProjectID());
+ }
}
- }
+ }
}

Back to the top