Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-11-30 19:23:22 +0000
committerMarkus Keller2015-12-01 12:59:16 +0000
commit96da92a20589d62dad534245c5d9c4d45618ee95 (patch)
treedb7f27dc0839db136db463ad28a7e763a6a07a91
parent0bbe21e0e553957dd09eda0b29e8c77a98f38048 (diff)
downloadeclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.gz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.xz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.zip
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java12
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java12
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java4
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForFilesInLinkedFolders.java2
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java2
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonAccessibleWorkspaceFiles.java4
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java4
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java4
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java2
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBufferFunctions.java12
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForExternalFiles.java6
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingExternalFiles.java6
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingWorkspaceFiles.java6
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForWorkspaceFiles.java2
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java6
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java14
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java15
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java97
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java6
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java8
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java68
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java24
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java12
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java10
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java51
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java12
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java12
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java4
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/AnnotationBag.java8
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java5
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java8
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java5
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java42
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java13
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java64
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java84
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java45
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java12
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java36
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java143
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java25
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java18
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java30
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java5
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java18
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java40
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java40
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java29
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java39
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java98
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java34
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java64
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java45
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java60
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java46
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java6
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java18
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java6
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java6
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java15
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java50
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java18
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java16
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java18
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java4
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java42
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java4
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java32
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java22
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java41
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java14
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java2
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java34
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java8
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java64
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java22
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java8
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java42
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java26
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java16
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java6
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java18
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java8
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java6
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java18
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java8
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java35
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java8
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java16
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java34
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java78
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java45
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java28
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java15
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java20
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java38
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java13
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java6
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java6
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java14
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java41
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java17
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/EditorOpener.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java16
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java21
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java22
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java16
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java81
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java28
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java31
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java15
-rw-r--r--org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java4
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java16
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java28
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java56
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java24
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java35
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java24
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java27
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java16
-rw-r--r--org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java2
-rw-r--r--org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java22
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java154
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/AbstractLineTracker.java10
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/DocumentPartitioningChangedEvent.java8
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/ListLineTracker.java30
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/SequentialRewriteTextStore.java36
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java40
-rwxr-xr-xorg.eclipse.text/src/org/eclipse/jface/text/TreeLineTracker.java14
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeManager.java26
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeModel.java94
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java73
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationMap.java30
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java164
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java10
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationMap.java15
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModel.java6
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java4
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension2.java6
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java4
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContextType.java30
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateTranslator.java24
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariableType.java10
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/CopySourceEdit.java14
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/CopyTargetEdit.java4
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java32
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/MoveTargetEdit.java6
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/MultiTextEdit.java10
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/TextEdit.java51
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/TextEditCopier.java18
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/TextEditGroup.java14
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/TextEditProcessor.java16
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/UndoEdit.java4
-rw-r--r--org.eclipse.text/src/org/eclipse/text/undo/DocumentUndoManager.java20
-rw-r--r--org.eclipse.text/src/org/eclipse/text/undo/DocumentUndoManagerRegistry.java10
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ChainedPreferenceStoreTest.java10
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java12
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java18
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java16
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java155
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java16
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java14
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java31
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java44
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java11
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java24
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java11
-rwxr-xr-xorg.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java40
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java21
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NonExistingFileEditorInput.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java33
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RefreshEditorAction.java2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java64
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java34
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java24
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java38
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java49
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java10
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java20
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java20
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java26
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java47
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java66
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java15
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java18
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java33
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java10
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java14
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java66
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java16
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java41
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java34
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java51
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java13
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java42
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlinePage.java4
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java9
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaPartitionScanner.java2
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java2
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java2
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/util/JavaColorProvider.java8
-rw-r--r--org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/ColorManager.java10
-rw-r--r--org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/AntVariableResolver.java8
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/HippieCompletionTest.java52
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/ChangeRegionTest.java26
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/RangeUtil.java30
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/rulers/DAGTest.java16
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java62
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java8
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java14
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java135
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java6
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRangeDifference.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DocumentEquivalenceClass.java12
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java75
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java14
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnTarget.java14
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/StringSetSerializer.java18
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java10
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java68
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java156
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java9
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java37
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java34
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java28
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java22
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java6
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorTargetDescriptor.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java8
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/KeyBindingSupportForAssistant.java10
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java24
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java16
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java6
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnPreferenceAdapter.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java58
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java22
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingProblem.java18
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingReconcileStrategy.java16
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java20
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java6
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java72
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java17
301 files changed, 3407 insertions, 3391 deletions
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java
index 82830736b..ee6cb0fd4 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java
@@ -14,8 +14,6 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.eclipse.core.runtime.Path;
import org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension;
@@ -30,6 +28,8 @@ import org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants.TestDSP6
import org.eclipse.jface.text.IDocument;
+import junit.framework.TestCase;
+
/**
* @since 3.4
@@ -106,13 +106,13 @@ public abstract class AbstractFileBufferDocCreationTests extends TestCase {
/* Utilities */
- private void assertParticipantsInvoked(String path, Class[] expectedDSPsArray) {
+ private void assertParticipantsInvoked(String path, Class<?>[] expectedDSPsArray) {
LocationKind[] lks= getSupportLocationKinds();
for(int i=0; i<lks.length; i++) {
IDocument document= fManager.createEmptyDocument(new Path(path), lks[i]);
String content= document.get();
- Set expectedDSPs= new HashSet(Arrays.asList(toString(expectedDSPsArray)));
- Set actualDSPs= new HashSet(Arrays.asList(content.split("\n")));
+ Set<String> expectedDSPs= new HashSet<>(Arrays.asList(toString(expectedDSPsArray)));
+ Set<String> actualDSPs= new HashSet<>(Arrays.asList(content.split("\n")));
assertEquals(expectedDSPs, actualDSPs);
}
}
@@ -123,7 +123,7 @@ public abstract class AbstractFileBufferDocCreationTests extends TestCase {
assertEquals(expectedContent, fManager.createEmptyDocument(new Path(path), locKind).get());
}
- private static String[] toString(Class[] clss) {
+ private static String[] toString(Class<?>[] clss) {
String[] result= new String[clss.length];
for(int i=0; i<result.length; i++) {
String s= null;
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java
index 71533493d..3881085b5 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java
@@ -14,8 +14,6 @@ package org.eclipse.core.filebuffers.tests;
import java.io.PrintStream;
import java.io.PrintWriter;
-import junit.framework.TestCase;
-
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
@@ -35,6 +33,8 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension4;
import org.eclipse.jface.text.source.IAnnotationModel;
+import junit.framework.TestCase;
+
/**
* FileBufferFunctions
*/
@@ -57,7 +57,7 @@ public abstract class FileBufferFunctions extends TestCase {
protected abstract boolean isStateValidationSupported();
- protected abstract Class getAnnotationModelClass() throws Exception;
+ protected abstract Class<IAnnotationModel> getAnnotationModelClass() throws Exception;
@Override
@@ -1109,7 +1109,7 @@ public abstract class FileBufferFunctions extends TestCase {
ITextFileBuffer buffer= fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
assertNotNull(buffer);
- Class clazz= getAnnotationModelClass();
+ Class<IAnnotationModel> clazz= getAnnotationModelClass();
if (clazz != null) {
IAnnotationModel model= buffer.getAnnotationModel();
assertTrue(clazz.isInstance(model));
@@ -1176,7 +1176,7 @@ public abstract class FileBufferFunctions extends TestCase {
ITextFileBuffer buffer= fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
assertNotNull(buffer);
- Class clazz= getAnnotationModelClass();
+ Class<IAnnotationModel> clazz= getAnnotationModelClass();
if (clazz != null) {
IAnnotationModel model= buffer.getAnnotationModel();
assertTrue(clazz.isInstance(model));
@@ -1216,7 +1216,7 @@ public abstract class FileBufferFunctions extends TestCase {
try {
ITextFileBuffer fileBuffer= fManager.getFileStoreTextFileBuffer(fileStore);
IAnnotationModel model= fileBuffer.getAnnotationModel();
- Class clazz= getAnnotationModelClass();
+ Class<IAnnotationModel> clazz= getAnnotationModelClass();
if (clazz != null)
assertTrue(clazz.isInstance(model));
else
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java
index 6f165eb60..b5840cbc3 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java
@@ -22,6 +22,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
/**
* FileBuffersForExternalFiles
*/
@@ -70,7 +72,7 @@ public class FileBuffersForExternalFiles extends FileBufferFunctions {
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
return null;
}
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForFilesInLinkedFolders.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForFilesInLinkedFolders.java
index 55dc5ec09..add40638e 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForFilesInLinkedFolders.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForFilesInLinkedFolders.java
@@ -125,7 +125,7 @@ public class FileBuffersForFilesInLinkedFolders extends FileBufferFunctions {
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
Bundle bundle= Platform.getBundle("org.eclipse.ui.editors");
return bundle != null ? IAnnotationModel.class : null;
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java
index 26a352288..6977a6b47 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java
@@ -97,7 +97,7 @@ public class FileBuffersForLinkedFiles extends FileBufferFunctions {
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
Bundle bundle= Platform.getBundle("org.eclipse.ui.editors");
return bundle != null ? IAnnotationModel.class : null;
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonAccessibleWorkspaceFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonAccessibleWorkspaceFiles.java
index f2526d518..d4c1a9f1c 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonAccessibleWorkspaceFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonAccessibleWorkspaceFiles.java
@@ -21,6 +21,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
/**
* FileBuffersForWorkspaceFiles
*/
@@ -77,7 +79,7 @@ public class FileBuffersForNonAccessibleWorkspaceFiles extends FileBufferFunctio
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
return null;
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java
index ccf40bd5e..e070b56e2 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java
@@ -20,6 +20,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
/**
* FileBuffersForNonExistingExternalFiles
*/
@@ -69,7 +71,7 @@ public class FileBuffersForNonExistingExternalFiles extends FileBufferFunctions
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
return null;
}
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java
index 7629120dd..3484b862d 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java
@@ -23,6 +23,8 @@ import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
/**
* FileBuffersForNonExistingWorkspaceFiles
*/
@@ -101,7 +103,7 @@ public class FileBuffersForNonExistingWorkspaceFiles extends FileBufferFunctions
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
return null;
}
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java
index 7f703dd39..d4627276b 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java
@@ -105,7 +105,7 @@ public class FileBuffersForWorkspaceFiles extends FileBufferFunctions {
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
Bundle bundle= Platform.getBundle("org.eclipse.ui.editors");
return bundle != null ? IAnnotationModel.class : null;
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBufferFunctions.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBufferFunctions.java
index 5a4b6a2db..b6d985fea 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBufferFunctions.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBufferFunctions.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,6 @@ package org.eclipse.core.filebuffers.tests;
import java.io.PrintStream;
import java.io.PrintWriter;
-import junit.framework.TestCase;
-
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
@@ -33,6 +31,8 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension4;
import org.eclipse.jface.text.source.IAnnotationModel;
+import junit.framework.TestCase;
+
/**
* FileBufferFunctions
*/
@@ -55,7 +55,7 @@ public abstract class FileStoreFileBufferFunctions extends TestCase {
protected abstract boolean isStateValidationSupported();
- protected abstract Class getAnnotationModelClass() throws Exception;
+ protected abstract Class<IAnnotationModel> getAnnotationModelClass() throws Exception;
@Override
@@ -1095,7 +1095,7 @@ public abstract class FileStoreFileBufferFunctions extends TestCase {
ITextFileBuffer buffer= fManager.getFileStoreTextFileBuffer(fFileStore);
assertNotNull(buffer);
- Class clazz= getAnnotationModelClass();
+ Class<IAnnotationModel> clazz= getAnnotationModelClass();
if (clazz != null) {
IAnnotationModel model= buffer.getAnnotationModel();
assertTrue(clazz.isInstance(model));
@@ -1162,7 +1162,7 @@ public abstract class FileStoreFileBufferFunctions extends TestCase {
ITextFileBuffer buffer= fManager.getFileStoreTextFileBuffer(fFileStore);
assertNotNull(buffer);
- Class clazz= getAnnotationModelClass();
+ Class<IAnnotationModel> clazz= getAnnotationModelClass();
if (clazz != null) {
IAnnotationModel model= buffer.getAnnotationModel();
assertTrue(clazz.isInstance(model));
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForExternalFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForExternalFiles.java
index de05cffeb..de02b9129 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForExternalFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForExternalFiles.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
/**
* FileBuffersForExternalFiles
*/
@@ -70,7 +72,7 @@ public class FileStoreFileBuffersForExternalFiles extends FileStoreFileBufferFun
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
return null;
}
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingExternalFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingExternalFiles.java
index 1484e941c..ad1f6c91d 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingExternalFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingExternalFiles.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,6 +20,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
/**
* FileBuffersForNonExistingExternalFiles
*/
@@ -69,7 +71,7 @@ public class FileStoreFileBuffersForNonExistingExternalFiles extends FileStoreFi
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
return null;
}
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingWorkspaceFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingWorkspaceFiles.java
index 9c50e9a9a..2da4f6f1b 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingWorkspaceFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForNonExistingWorkspaceFiles.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,6 +23,8 @@ import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
/**
* FileBuffersForNonExistingWorkspaceFiles
*/
@@ -101,7 +103,7 @@ public class FileStoreFileBuffersForNonExistingWorkspaceFiles extends FileStoreF
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
return null;
}
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForWorkspaceFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForWorkspaceFiles.java
index 22a7d3a20..dcf49abe9 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForWorkspaceFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileStoreFileBuffersForWorkspaceFiles.java
@@ -105,7 +105,7 @@ public class FileStoreFileBuffersForWorkspaceFiles extends FileBufferFunctions {
}
@Override
- protected Class getAnnotationModelClass() throws Exception {
+ protected Class<IAnnotationModel> getAnnotationModelClass() throws Exception {
Bundle bundle= Platform.getBundle("org.eclipse.ui.editors");
return bundle != null ? IAnnotationModel.class : null;
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java
index 7d88be8dd..022c8c94d 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileTool.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -53,11 +53,11 @@ public class FileTool {
*/
public static void unzip(ZipFile zipFile, File dstDir) throws IOException {
- Enumeration entries = zipFile.entries();
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
try {
while(entries.hasMoreElements()){
- ZipEntry entry = (ZipEntry)entries.nextElement();
+ ZipEntry entry = entries.nextElement();
if(entry.isDirectory()){
continue;
}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
index 2092ae679..b141a8849 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
@@ -200,21 +200,21 @@ public class GenericFileBufferOperationRunner {
}
private IFileBuffer[] findUnsynchronizedFileBuffers(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IFileBuffer> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
if (!fileBuffers[i].isSynchronizationContextRequested())
list.add(fileBuffers[i]);
}
- return (IFileBuffer[]) list.toArray(new IFileBuffer[list.size()]);
+ return list.toArray(new IFileBuffer[list.size()]);
}
private IFileBuffer[] findSynchronizedFileBuffers(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IFileBuffer> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
if (fileBuffers[i].isSynchronizationContextRequested())
list.add(fileBuffers[i]);
}
- return (IFileBuffer[]) list.toArray(new IFileBuffer[list.size()]);
+ return list.toArray(new IFileBuffer[list.size()]);
}
private IFileBuffer[] createFileBuffers(IPath[] locations, IProgressMonitor progressMonitor) throws CoreException {
@@ -255,13 +255,13 @@ public class GenericFileBufferOperationRunner {
}
private IFileBuffer[] findFileBuffersToSave(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IFileBuffer> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
IFileBuffer buffer= fileBuffers[i];
if (!buffer.isDirty())
list.add(buffer);
}
- return (IFileBuffer[]) list.toArray(new IFileBuffer[list.size()]);
+ return list.toArray(new IFileBuffer[list.size()]);
}
private boolean isCommitable(IFileBuffer[] fileBuffers) {
@@ -273,7 +273,7 @@ public class GenericFileBufferOperationRunner {
}
protected ISchedulingRule computeCommitRule(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<ISchedulingRule> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
ISchedulingRule rule= fileBuffers[i].computeCommitRule();
if (rule != null)
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java
index c4321198b..37e96d2ad 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,6 +33,7 @@ import org.eclipse.jface.text.DocumentRewriteSession;
import org.eclipse.jface.text.DocumentRewriteSessionType;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.TextUtilities;
/**
@@ -96,7 +97,7 @@ public abstract class TextFileBufferOperation implements IFileBufferOperation {
MultiTextEditWithProgress edit= computeTextEdit(textFileBuffer, subMonitor);
subMonitor.done();
if (edit != null) {
- Object stateData= startRewriteSession(textFileBuffer);
+ Map<String, IDocumentPartitioner> stateData= startRewriteSession(textFileBuffer);
try {
subMonitor= Progress.getSubMonitor(progressMonitor, 90);
applyTextEdit(textFileBuffer, edit, subMonitor);
@@ -111,8 +112,8 @@ public abstract class TextFileBufferOperation implements IFileBufferOperation {
}
}
- private Object startRewriteSession(ITextFileBuffer fileBuffer) {
- Object stateData= null;
+ private Map<String, IDocumentPartitioner> startRewriteSession(ITextFileBuffer fileBuffer) {
+ Map<String, IDocumentPartitioner> stateData= null;
IDocument document= fileBuffer.getDocument();
if (document instanceof IDocumentExtension4) {
@@ -124,14 +125,14 @@ public abstract class TextFileBufferOperation implements IFileBufferOperation {
return stateData;
}
- private void stopRewriteSession(ITextFileBuffer fileBuffer, Object stateData) {
+ private void stopRewriteSession(ITextFileBuffer fileBuffer, Map<String, IDocumentPartitioner> stateData) {
IDocument document= fileBuffer.getDocument();
if (document instanceof IDocumentExtension4) {
IDocumentExtension4 extension= (IDocumentExtension4) document;
extension.stopRewriteSession(fDocumentRewriteSession);
fDocumentRewriteSession= null;
- } else if (stateData instanceof Map)
- TextUtilities.addDocumentPartitioners(document, (Map) stateData);
+ } else if (stateData != null)
+ TextUtilities.addDocumentPartitioners(document, stateData);
}
private void applyTextEdit(ITextFileBuffer fileBuffer, MultiTextEditWithProgress textEdit, IProgressMonitor progressMonitor) throws CoreException, OperationCanceledException {
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
index 63731ff3a..4e5e483f6 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -85,17 +85,17 @@ public class ExtensionsRegistry {
protected static final String WILDCARD= "*"; //$NON-NLS-1$
/** The mapping between file attributes and configuration elements describing document factories. */
- private Map fFactoryDescriptors= new HashMap();
+ private Map<Object, Set<IConfigurationElement>> fFactoryDescriptors= new HashMap<>();
/** The mapping between configuration elements for document factories and instantiated document factories. */
- private Map fFactories= new HashMap();
+ private Map<IConfigurationElement, Object> fFactories= new HashMap<>();
/** The mapping between file attributes and configuration elements describing document setup participants. */
- private Map fSetupParticipantDescriptors= new HashMap();
+ private Map<Object, Set<IConfigurationElement>> fSetupParticipantDescriptors= new HashMap<>();
/** The mapping between configuration elements for setup participants and instantiated setup participants. */
- private Map fSetupParticipants= new HashMap();
+ private Map<IConfigurationElement, Object> fSetupParticipants= new HashMap<>();
/** The mapping between file attributes and configuration elements describing annotation model factories. */
- private Map fAnnotationModelFactoryDescriptors= new HashMap();
+ private Map<Object, Set<IConfigurationElement>> fAnnotationModelFactoryDescriptors= new HashMap<>();
/** The mapping between configuration elements for annotation model factories */
- private Map fAnnotationModelFactories= new HashMap();
+ private Map<IConfigurationElement, Object> fAnnotationModelFactories= new HashMap<>();
/** The content type manager. */
protected IContentTypeManager fContentTypeManager= Platform.getContentTypeManager();
@@ -125,16 +125,16 @@ public class ExtensionsRegistry {
* @param element the configuration element
* @param map the map which remembers the configuration element
*/
- private void read(String attributeName, IConfigurationElement element, Map map) {
+ private void read(String attributeName, IConfigurationElement element, Map<Object, Set<IConfigurationElement>> map) {
String value= element.getAttribute(attributeName);
if (value != null) {
StringTokenizer tokenizer= new StringTokenizer(value, ","); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
String token= tokenizer.nextToken().trim();
- Set s= (Set) map.get(token);
+ Set<IConfigurationElement> s= map.get(token);
if (s == null) {
- s= new HashSet();
+ s= new HashSet<>();
map.put(token, s);
}
s.add(element);
@@ -150,7 +150,7 @@ public class ExtensionsRegistry {
* @param element the configuration element
* @param map the map which remembers the configuration element
*/
- private void readContentType(String attributeName, IConfigurationElement element, Map map) {
+ private void readContentType(String attributeName, IConfigurationElement element, Map<Object, Set<IConfigurationElement>> map) {
String value= element.getAttribute(attributeName);
if (value != null) {
IContentType contentType= fContentTypeManager.getContentType(value);
@@ -159,9 +159,9 @@ public class ExtensionsRegistry {
return;
}
ContentTypeAdapter adapter= new ContentTypeAdapter(contentType);
- Set s= (Set) map.get(adapter);
+ Set<IConfigurationElement> s= map.get(adapter);
if (s == null) {
- s= new HashSet();
+ s= new HashSet<>();
map.put(adapter, s);
}
s.add(element);
@@ -187,7 +187,7 @@ public class ExtensionsRegistry {
* @param isContentTypeId the child element is a content type id
* @param descriptors the map to be filled
*/
- private void initialize(String extensionPointName, String childElementName, boolean isContentTypeId, Map descriptors) {
+ private void initialize(String extensionPointName, String childElementName, boolean isContentTypeId, Map<Object, Set<IConfigurationElement>> descriptors) {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(FileBuffersPlugin.PLUGIN_ID, extensionPointName);
if (extensionPoint == null) {
@@ -214,13 +214,14 @@ public class ExtensionsRegistry {
* @param extensionType the requested result type
* @return the executable extension for the given configuration element.
*/
- private Object getExtension(IConfigurationElement entry, Map extensions, Class extensionType) {
- Object extension= extensions.get(entry);
+ @SuppressWarnings("unchecked")
+ private <T> T getExtension(IConfigurationElement entry, Map<IConfigurationElement, Object> extensions, Class<T> extensionType) {
+ T extension= (T) extensions.get(entry);
if (extension != null)
return extension;
try {
- extension= entry.createExecutableExtension("class"); //$NON-NLS-1$
+ extension= (T) entry.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException x) {
log(x.getStatus());
}
@@ -239,10 +240,10 @@ public class ExtensionsRegistry {
* @param set the set from which to choose
* @return the selected configuration element
*/
- private IConfigurationElement selectConfigurationElement(Set set) {
+ private IConfigurationElement selectConfigurationElement(Set<IConfigurationElement> set) {
if (set != null && !set.isEmpty()) {
- Iterator e= set.iterator();
- return (IConfigurationElement) e.next();
+ Iterator<IConfigurationElement> e= set.iterator();
+ return e.next();
}
return null;
}
@@ -256,10 +257,10 @@ public class ExtensionsRegistry {
*/
@Deprecated
protected org.eclipse.core.filebuffers.IDocumentFactory getDocumentFactory(String nameOrExtension) {
- Set set= (Set) fFactoryDescriptors.get(nameOrExtension);
+ Set<IConfigurationElement> set= fFactoryDescriptors.get(nameOrExtension);
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
- return (org.eclipse.core.filebuffers.IDocumentFactory)getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
+ return getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
}
return null;
}
@@ -273,15 +274,15 @@ public class ExtensionsRegistry {
*/
@Deprecated
protected org.eclipse.core.filebuffers.IDocumentFactory doGetDocumentFactory(IContentType[] contentTypes) {
- Set set= null;
+ Set<IConfigurationElement> set= null;
int i= 0;
while (i < contentTypes.length && set == null) {
- set= (Set) fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
+ set= fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
}
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
- return (org.eclipse.core.filebuffers.IDocumentFactory)getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
+ return getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
}
return null;
}
@@ -312,16 +313,16 @@ public class ExtensionsRegistry {
* @param nameOrExtension the name or extension to be used for lookup
* @return the sharable set of document setup participants
*/
- protected List getDocumentSetupParticipants(String nameOrExtension) {
- Set set= (Set) fSetupParticipantDescriptors.get(nameOrExtension);
+ protected List<IDocumentSetupParticipant> getDocumentSetupParticipants(String nameOrExtension) {
+ Set<IConfigurationElement> set= fSetupParticipantDescriptors.get(nameOrExtension);
if (set == null)
return null;
- List participants= new ArrayList();
- Iterator e= set.iterator();
+ List<IDocumentSetupParticipant> participants= new ArrayList<>();
+ Iterator<IConfigurationElement> e= set.iterator();
while (e.hasNext()) {
- IConfigurationElement entry= (IConfigurationElement) e.next();
- Object participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
+ IConfigurationElement entry= e.next();
+ IDocumentSetupParticipant participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
if (participant != null)
participants.add(participant);
}
@@ -335,20 +336,20 @@ public class ExtensionsRegistry {
* @param contentTypes the contentTypes to be used for lookup
* @return the sharable set of document setup participants
*/
- private List doGetDocumentSetupParticipants(IContentType[] contentTypes) {
- Set resultSet= new HashSet();
+ private List<IDocumentSetupParticipant> doGetDocumentSetupParticipants(IContentType[] contentTypes) {
+ Set<IConfigurationElement> resultSet= new HashSet<>();
int i= 0;
while (i < contentTypes.length) {
- Set set= (Set) fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
+ Set<IConfigurationElement> set= fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
if (set != null)
resultSet.addAll(set);
}
- List participants= new ArrayList();
- Iterator e= resultSet.iterator();
+ List<IDocumentSetupParticipant> participants= new ArrayList<>();
+ Iterator<IConfigurationElement> e= resultSet.iterator();
while (e.hasNext()) {
- IConfigurationElement entry= (IConfigurationElement) e.next();
- Object participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
+ IConfigurationElement entry= e.next();
+ IDocumentSetupParticipant participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
if (participant != null)
participants.add(participant);
}
@@ -364,8 +365,8 @@ public class ExtensionsRegistry {
* @param contentTypes the contentTypes to be used for lookup
* @return the sharable set of document setup participants
*/
- protected List getDocumentSetupParticipants(IContentType[] contentTypes) {
- List participants= doGetDocumentSetupParticipants(contentTypes);
+ protected List<IDocumentSetupParticipant> getDocumentSetupParticipants(IContentType[] contentTypes) {
+ List<IDocumentSetupParticipant> participants= doGetDocumentSetupParticipants(contentTypes);
while (participants == null) {
contentTypes= computeBaseContentTypes(contentTypes);
if (contentTypes == null)
@@ -382,15 +383,15 @@ public class ExtensionsRegistry {
* @return the sharable annotation model factory or <code>null</code>
*/
private IAnnotationModelFactory doGetAnnotationModelFactory(IContentType[] contentTypes) {
- Set set= null;
+ Set<IConfigurationElement> set= null;
int i= 0;
while (i < contentTypes.length && set == null) {
- set= (Set) fAnnotationModelFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
+ set= fAnnotationModelFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
}
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
- return (IAnnotationModelFactory) getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
+ return getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
}
return null;
}
@@ -421,10 +422,10 @@ public class ExtensionsRegistry {
* @return the sharable document factory or <code>null</code>
*/
protected IAnnotationModelFactory getAnnotationModelFactory(String extension) {
- Set set= (Set) fAnnotationModelFactoryDescriptors.get(extension);
+ Set<IConfigurationElement> set= fAnnotationModelFactoryDescriptors.get(extension);
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
- return (IAnnotationModelFactory) getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
+ return getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
}
return null;
}
@@ -451,7 +452,7 @@ public class ExtensionsRegistry {
* @return the set of direct base content types
*/
private IContentType[] computeBaseContentTypes(IContentType[] contentTypes) {
- List baseTypes= new ArrayList();
+ List<IContentType> baseTypes= new ArrayList<>();
for (int i= 0; i < contentTypes.length; i++) {
IContentType baseType= contentTypes[i].getBaseType();
if (baseType != null)
@@ -497,9 +498,9 @@ public class ExtensionsRegistry {
* @since 3.3
*/
public IDocumentSetupParticipant[] getDocumentSetupParticipants(IPath location, LocationKind locationKind) {
- Set participants= new HashSet();
+ Set<IDocumentSetupParticipant> participants= new HashSet<>();
- List p= getDocumentSetupParticipants(findContentTypes(location, locationKind));
+ List<IDocumentSetupParticipant> p= getDocumentSetupParticipants(findContentTypes(location, locationKind));
if (p != null)
participants.addAll(p);
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java
index 0c171b055..af4e33cca 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -116,9 +116,9 @@ public class ResourceExtensionRegistry extends ExtensionsRegistry {
* @return the sharable set of document setup participants
*/
IDocumentSetupParticipant[] getDocumentSetupParticipants(IFile file) {
- Set participants= new HashSet();
+ Set<IDocumentSetupParticipant> participants= new HashSet<>();
- List p= getDocumentSetupParticipants(findContentTypes(file));
+ List<IDocumentSetupParticipant> p= getDocumentSetupParticipants(findContentTypes(file));
if (p != null)
participants.addAll(p);
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
index d3932fdbe..0f183eb5c 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
@@ -236,7 +236,7 @@ public class ResourceTextFileBufferManager extends TextFileBufferManager {
}
private IStatus validateEdit(IFileBuffer[] fileBuffers, Object computationContext) {
- ArrayList list= new ArrayList();
+ ArrayList<IFile> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
IFile file= getWorkspaceFile(fileBuffers[i]);
if (file != null)
@@ -248,12 +248,12 @@ public class ResourceTextFileBufferManager extends TextFileBufferManager {
}
private IFileBuffer[] findFileBuffersToValidate(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IFileBuffer> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
if (!fileBuffers[i].isStateValidated())
list.add(fileBuffers[i]);
}
- return (IFileBuffer[]) list.toArray(new IFileBuffer[list.size()]);
+ return list.toArray(new IFileBuffer[list.size()]);
}
private void validationStateAboutToBeChanged(IFileBuffer[] fileBuffers) {
@@ -288,7 +288,7 @@ public class ResourceTextFileBufferManager extends TextFileBufferManager {
}
private ISchedulingRule computeValidateStateRule(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IResource> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
IResource resource= getWorkspaceFile(fileBuffers[i]);
if (resource != null)
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
index 1a0da3fce..25aba768c 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
@@ -68,9 +68,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
protected static final IContentType TEXT_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);
- private Map fFilesBuffers= new HashMap();
- private Map fFileStoreFileBuffers= new HashMap();
- private List fFileBufferListeners= new ArrayList();
+ private Map<IPath, AbstractFileBuffer> fFilesBuffers= new HashMap<>();
+ private Map<IFileStore, FileStoreFileBuffer> fFileStoreFileBuffers= new HashMap<>();
+ private List<IFileBufferListener> fFileBufferListeners= new ArrayList<>();
protected ExtensionsRegistry fRegistry;
private ISynchronizationContext fSynchronizationContext;
@@ -339,13 +339,13 @@ public class TextFileBufferManager implements ITextFileBufferManager {
private AbstractFileBuffer internalGetFileBuffer(IPath location) {
synchronized (fFilesBuffers) {
- return (AbstractFileBuffer)fFilesBuffers.get(location);
+ return fFilesBuffers.get(location);
}
}
private FileStoreFileBuffer internalGetFileBuffer(IFileStore fileStore) {
synchronized (fFileStoreFileBuffers) {
- return (FileStoreFileBuffer)fFileStoreFileBuffers.get(fileStore);
+ return fFileStoreFileBuffers.get(fileStore);
}
}
@@ -374,9 +374,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
@Override
public ITextFileBuffer getTextFileBuffer(IDocument document) {
Assert.isLegal(document != null);
- Iterator iter;
+ Iterator<AbstractFileBuffer> iter;
synchronized (fFilesBuffers) {
- iter= new ArrayList(fFilesBuffers.values()).iterator();
+ iter= new ArrayList<>(fFilesBuffers.values()).iterator();
}
while (iter.hasNext()) {
@@ -391,7 +391,7 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
}
synchronized (fFileStoreFileBuffers) {
- iter= new ArrayList(fFileStoreFileBuffers.values()).iterator();
+ iter= new ArrayList<AbstractFileBuffer>(fFileStoreFileBuffers.values()).iterator();
}
while (iter.hasNext()) {
Object buffer= iter.next();
@@ -409,16 +409,16 @@ public class TextFileBufferManager implements ITextFileBufferManager {
@Override
public IFileBuffer[] getFileBuffers() {
synchronized (fFilesBuffers) {
- Collection values= fFilesBuffers.values();
- return (IFileBuffer[])values.toArray(new IFileBuffer[values.size()]);
+ Collection<AbstractFileBuffer> values= fFilesBuffers.values();
+ return values.toArray(new IFileBuffer[values.size()]);
}
}
@Override
public IFileBuffer[] getFileStoreFileBuffers() {
synchronized (fFileStoreFileBuffers) {
- Collection values= fFileStoreFileBuffers.values();
- return (IFileBuffer[])values.toArray(new IFileBuffer[values.size()]);
+ Collection<FileStoreFileBuffer> values= fFileStoreFileBuffers.values();
+ return values.toArray(new IFileBuffer[values.size()]);
}
}
@@ -663,16 +663,16 @@ public class TextFileBufferManager implements ITextFileBufferManager {
// return createTextFileBuffer(location);
// }
- private Iterator getFileBufferListenerIterator() {
+ private Iterator<IFileBufferListener> getFileBufferListenerIterator() {
synchronized (fFileBufferListeners) {
- return new ArrayList(fFileBufferListeners).iterator();
+ return new ArrayList<>(fFileBufferListeners).iterator();
}
}
protected void fireDirtyStateChanged(final IFileBuffer buffer, final boolean isDirty) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -683,9 +683,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireBufferContentAboutToBeReplaced(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -696,9 +696,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireBufferContentReplaced(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -709,9 +709,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireUnderlyingFileMoved(final IFileBuffer buffer, final IPath target) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -722,9 +722,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireUnderlyingFileDeleted(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -735,9 +735,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireStateValidationChanged(final IFileBuffer buffer, final boolean isStateValidated) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -748,9 +748,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireStateChanging(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -761,9 +761,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireStateChangeFailed(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -774,9 +774,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireBufferCreated(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -787,9 +787,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireBufferDisposed(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java
index 6108c2240..0a6a828a6 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 IBM Corporation and others.
+ * Copyright (c) 2006, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,6 @@ package org.eclipse.jface.text.tests;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@@ -31,6 +29,8 @@ import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
import org.eclipse.jface.text.source.ICharacterPairMatcherExtension;
+import junit.framework.TestCase;
+
/**
* Generic test of simple character pair matchers
*
@@ -74,7 +74,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Very simple checks.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testSimpleMatchSameMatcher() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -106,7 +106,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Very simple checks.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testSimpleMatchDifferentMatchers() throws BadLocationException {
performMatch("()[]{}", "#( )%");
@@ -124,7 +124,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Close matches.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testCloseMatches() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -151,7 +151,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Checks of simple situations where no matches should be found.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testIncompleteMatch() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -164,7 +164,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Test that it doesn't match across different partitions.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testPartitioned() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -201,7 +201,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Test that it works properly next to partition boundaries.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testTightPartitioned() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -255,7 +255,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Test a few boundary conditions.
*
- * * @throws BadLocationException
+ * * @throws BadLocationException test failure
*/
public void testBoundaries() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -519,11 +519,11 @@ public abstract class AbstractPairMatcherTest extends TestCase {
private static IDocumentPartitioner createPartitioner() {
final RuleBasedPartitionScanner scan= new RuleBasedPartitionScanner();
- final List/*<IPredicateRule>*/ rules= new ArrayList/*<IPredicateRule>*/();
+ final List<SingleLineRule> rules= new ArrayList<>();
rules.add(new SingleLineRule("|a", "a|", new Token("a")));
rules.add(new SingleLineRule("|b", "b|", new Token("b")));
rules.add(new SingleLineRule("|c", "c|", new Token("c")));
- scan.setPredicateRules((IPredicateRule[]) rules.toArray(new IPredicateRule[rules.size()]));
+ scan.setPredicateRules(rules.toArray(new IPredicateRule[rules.size()]));
scan.setDefaultReturnToken(new Token(DEFAULT_PARTITION));
return new FastPartitioner(scan, new String[] { DEFAULT_PARTITION, "a", "b", "c" });
}
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java
index bac928e01..cd53ca47e 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 IBM Corporation and others.
+ * Copyright (c) 2006, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.jface.text.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
/**
* Tests for the default pair matcher.
@@ -42,7 +42,7 @@ public class DefaultPairMatcherTest extends AbstractPairMatcherTest {
/**
* Close matches.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testCloseMatches1() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -55,7 +55,7 @@ public class DefaultPairMatcherTest extends AbstractPairMatcherTest {
/**
* Checks of simple situations where no matches should be found.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testIncompleteMatch1() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java
index 56f3d985c..30f6a16cc 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2012, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.jface.text.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
/**
* Tests for the default pair matcher.
@@ -42,7 +42,7 @@ public class DefaultPairMatcherTest2 extends AbstractPairMatcherTest {
/**
* Very simple checks.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testSimpleMatchSameMatcher1() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
index 2c9fc3da7..60f8e0dbc 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
@@ -16,14 +16,9 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
@@ -31,6 +26,10 @@ import org.eclipse.jface.internal.text.html.HTML2TextReader;
import org.eclipse.jface.text.TextPresentation;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class HTML2TextReaderTest extends TestCase {
@@ -47,10 +46,10 @@ public class HTML2TextReaderTest extends TestCase {
}
/**
- * @param input
- * @param expectedOutput
- * @param styleRangeCount
- * @throws IOException
+ * @param input input
+ * @param expectedOutput expected output
+ * @param styleRangeCount count
+ * @throws IOException test failure
* @deprecated pass actual style ranges
*/
@Deprecated
@@ -63,26 +62,19 @@ public class HTML2TextReaderTest extends TestCase {
System.out.println("<" + result + "/>");
assertEquals(expectedOutput, result);
- Iterator styleRangeIterator= textPresentation.getAllStyleRangeIterator();
- List ranges= new ArrayList();
+ Iterator<StyleRange> styleRangeIterator= textPresentation.getAllStyleRangeIterator();
+ List<StyleRange> ranges= new ArrayList<>();
while (styleRangeIterator.hasNext()) {
ranges.add(styleRangeIterator.next());
}
assertEquals("Incorrect number of style ranges", styleRangeCount, ranges.size());
- Collections.sort(ranges, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- StyleRange range1= (StyleRange)o1;
- StyleRange range2= (StyleRange)o2;
- return range1.start - range2.start;
- }
- });
+ Collections.sort(ranges, (r1, r2) -> r1.start - r2.start);
for (int i= 0; i < ranges.size() - 1; i++) {
- StyleRange range1= (StyleRange)ranges.get(i);
- StyleRange range2= (StyleRange)ranges.get(i + 1);
+ StyleRange range1= ranges.get(i);
+ StyleRange range2= ranges.get(i + 1);
if (range1.start + range1.length > range2.start) {
assertTrue("StyleRanges overlap", false);
@@ -100,26 +92,19 @@ public class HTML2TextReaderTest extends TestCase {
System.out.println("<" + result + "/>");
assertEquals(expectedOutput, result);
- Iterator styleRangeIterator= textPresentation.getAllStyleRangeIterator();
- List ranges= new ArrayList();
+ Iterator<StyleRange> styleRangeIterator= textPresentation.getAllStyleRangeIterator();
+ List<StyleRange> ranges= new ArrayList<>();
while (styleRangeIterator.hasNext()) {
ranges.add(styleRangeIterator.next());
}
- Collections.sort(ranges, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- StyleRange range1= (StyleRange)o1;
- StyleRange range2= (StyleRange)o2;
- return range1.start - range2.start;
- }
- });
+ Collections.sort(ranges, (r1, r2) -> r1.start - r2.start);
assertEquals(Arrays.asList(styleRanges), ranges);
for (int i= 0; i < ranges.size() - 1; i++) {
- StyleRange range1= (StyleRange)ranges.get(i);
- StyleRange range2= (StyleRange)ranges.get(i + 1);
+ StyleRange range1= ranges.get(i);
+ StyleRange range2= ranges.get(i + 1);
if (range1.start + range1.length > range2.start) {
assertTrue("StyleRanges overlap", false);
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java
index 7a1bc8022..7e4bfb6b3 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java
@@ -51,8 +51,8 @@ public class TestTextViewer implements ISourceViewer, IDocumentListener {
protected IDocument fDocument;
- protected List fInputListeners= new ArrayList();
- protected List fTextListeners= new ArrayList();
+ protected List<ITextInputListener> fInputListeners= new ArrayList<>();
+ protected List<ITextListener> fTextListeners= new ArrayList<>();
protected TextPresentation fTextPresentation;
protected Point fSelection= new Point(-1, -1);
protected String fDeletion;
@@ -112,9 +112,9 @@ public class TestTextViewer implements ISourceViewer, IDocumentListener {
}
protected void fireTextInputChanged(IDocument oldDoc, IDocument newDoc, boolean about) {
- Iterator e= new ArrayList(fInputListeners).iterator();
+ Iterator<ITextInputListener> e= new ArrayList<>(fInputListeners).iterator();
while (e.hasNext()) {
- ITextInputListener l= (ITextInputListener) e.next();
+ ITextInputListener l= e.next();
if (about)
l.inputDocumentAboutToBeChanged(oldDoc, newDoc);
else
@@ -377,9 +377,9 @@ public class TestTextViewer implements ISourceViewer, IDocumentListener {
}
protected void fireTextChanged(TextEvent event) {
- Iterator e= new ArrayList(fTextListeners).iterator();
+ Iterator<ITextListener> e= new ArrayList<>(fTextListeners).iterator();
while (e.hasNext()) {
- ITextListener l= (ITextListener) e.next();
+ ITextListener l= e.next();
l.textChanged(event);
}
}
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
index 665b53abc..3572129f1 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,10 +12,6 @@ package org.eclipse.jface.text.tests;
import java.util.Iterator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
@@ -24,6 +20,10 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextPresentation;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class TextPresentationTest extends TestCase {
private static final int NORMAL= SWT.NORMAL;
@@ -98,7 +98,7 @@ public class TextPresentationTest extends TestCase {
}
private void checkRegions(StyleRange[] expectedAllRanges, StyleRange[] expectedNonDefaultRanges) {
- Iterator e= fTextPresentation.getAllStyleRangeIterator();
+ Iterator<StyleRange> e= fTextPresentation.getAllStyleRangeIterator();
for (int i= 0; i < expectedAllRanges.length; i++) {
assertTrue(e.hasNext());
assertEquals(expectedAllRanges[i], e.next());
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java
index ee4fddf83..1a7471580 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java
@@ -127,7 +127,7 @@ public class AbstractReconcilerTest extends TestCase {
private Accessor fAccessor;
private Barrier fBarrier;
- private List fCallLog;
+ private List<String> fCallLog;
private ITextViewer fViewer;
protected AbstractReconciler fReconciler;
private Document fDocument;
@@ -138,7 +138,7 @@ public class AbstractReconcilerTest extends TestCase {
@Override
protected void setUp() {
fBarrier= new Barrier();
- fCallLog= Collections.synchronizedList(new ArrayList());
+ fCallLog= Collections.synchronizedList(new ArrayList<String>());
fReconciler= new AbstractReconciler() {
@Override
protected void initialProcess() {
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/AnnotationBag.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/AnnotationBag.java
index 94681b1d8..94c91ae63 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/AnnotationBag.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/AnnotationBag.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,7 +27,7 @@ import org.eclipse.jface.text.source.Annotation;
*/
public class AnnotationBag extends Annotation {
- private Set fAnnotations;
+ private Set<Annotation> fAnnotations;
/**
* Creates a new annotation bag.
@@ -45,7 +45,7 @@ public class AnnotationBag extends Annotation {
*/
public void add(Annotation annotation) {
if (fAnnotations == null)
- fAnnotations= new HashSet(2);
+ fAnnotations= new HashSet<>(2);
fAnnotations.add(annotation);
}
@@ -78,7 +78,7 @@ public class AnnotationBag extends Annotation {
* @return an iterator for all annotations in the bag or <code>null</code>
* @since 3.1
*/
- public Iterator iterator() {
+ public Iterator<Annotation> iterator() {
if (!isEmpty())
return fAnnotations.iterator();
return null;
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java
index 2374073e7..1ea796c8a 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,6 +23,7 @@ import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.information.IInformationProviderExtension2;
+import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationHoverExtension;
import org.eclipse.jface.text.source.IAnnotationModel;
@@ -102,7 +103,7 @@ class ProjectionAnnotationHover implements IAnnotationHover, IAnnotationHoverExt
if (model != null) {
try {
IDocument document= viewer.getDocument();
- Iterator e= model.getAnnotationIterator();
+ Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
if (!annotation.isCollapsed())
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
index a40bedb60..d95eb17b5 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -113,7 +113,7 @@ public class ProjectionAnnotationModel extends AnnotationModel {
boolean collapsing= false;
- Iterator iterator= getAnnotationIterator();
+ Iterator<Annotation> iterator= getAnnotationIterator();
while (iterator.hasNext()) {
ProjectionAnnotation annotation= (ProjectionAnnotation) iterator.next();
if (!annotation.isCollapsed()) {
@@ -146,7 +146,7 @@ public class ProjectionAnnotationModel extends AnnotationModel {
boolean expanding= false;
- Iterator iterator= getAnnotationIterator();
+ Iterator<Annotation> iterator= getAnnotationIterator();
while (iterator.hasNext()) {
ProjectionAnnotation annotation= (ProjectionAnnotation) iterator.next();
if (annotation.isCollapsed()) {
@@ -172,7 +172,7 @@ public class ProjectionAnnotationModel extends AnnotationModel {
* @param additions the set of annotations to add together with their associated position
* @param modifications the list of modified annotations
*/
- public void modifyAnnotations(Annotation[] deletions, Map additions, Annotation[] modifications) {
+ public void modifyAnnotations(Annotation[] deletions, Map<? extends Annotation, ? extends Position> additions, Annotation[] modifications) {
try {
replaceAnnotations(deletions, additions, false);
if (modifications != null) {
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java
index d7c156a22..b184718f8 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.AnnotationRulerColumn;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IAnnotationAccess;
@@ -113,7 +114,7 @@ class ProjectionRulerColumn extends AnnotationRulerColumn {
int previousDistance= Integer.MAX_VALUE;
- Iterator e= model.getAnnotationIterator();
+ Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
Object next= e.next();
if (next instanceof ProjectionAnnotation) {
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
index 147513901..abd2fd7f6 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -79,7 +79,7 @@ class ProjectionSummary {
private ProjectionViewer fProjectionViewer;
private IAnnotationAccess fAnnotationAccess;
- private List fConfiguredAnnotationTypes;
+ private List<String> fConfiguredAnnotationTypes;
private Object fLock= new Object();
private IProgressMonitor fProgressMonitor;
@@ -106,7 +106,7 @@ class ProjectionSummary {
public void addAnnotationType(String annotationType) {
synchronized(fLock) {
if (fConfiguredAnnotationTypes == null) {
- fConfiguredAnnotationTypes= new ArrayList();
+ fConfiguredAnnotationTypes= new ArrayList<>();
fConfiguredAnnotationTypes.add(annotationType);
} else if (!fConfiguredAnnotationTypes.contains(annotationType))
fConfiguredAnnotationTypes.add(annotationType);
@@ -161,16 +161,16 @@ class ProjectionSummary {
private void removeSummaries(IProgressMonitor monitor, IAnnotationModel visualAnnotationModel) {
IAnnotationModelExtension extension= null;
- List bags= null;
+ List<Annotation> bags= null;
if (visualAnnotationModel instanceof IAnnotationModelExtension) {
extension= (IAnnotationModelExtension)visualAnnotationModel;
- bags= new ArrayList();
+ bags= new ArrayList<>();
}
- Iterator e= visualAnnotationModel.getAnnotationIterator();
+ Iterator<Annotation> e= visualAnnotationModel.getAnnotationIterator();
while (e.hasNext()) {
- Annotation annotation= (Annotation) e.next();
+ Annotation annotation= e.next();
if (annotation instanceof AnnotationBag) {
if (bags == null)
visualAnnotationModel.removeAnnotation(annotation);
@@ -195,9 +195,9 @@ class ProjectionSummary {
if (model == null)
return;
- Map additions= new HashMap();
+ Map<Annotation, Position> additions= new HashMap<>();
- Iterator e= model.getAnnotationIterator();
+ Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
ProjectionAnnotation projection= (ProjectionAnnotation) e.next();
if (projection.isCollapsed()) {
@@ -222,10 +222,10 @@ class ProjectionSummary {
if (!isCanceled(monitor))
extension.replaceAnnotations(null, additions);
} else {
- Iterator e1= additions.keySet().iterator();
+ Iterator<Annotation> e1= additions.keySet().iterator();
while (e1.hasNext()) {
AnnotationBag bag= (AnnotationBag) e1.next();
- Position position= (Position) additions.get(bag);
+ Position position= additions.get(bag);
if (isCanceled(monitor))
return;
visualAnnotationModel.addAnnotation(bag, position);
@@ -234,17 +234,17 @@ class ProjectionSummary {
}
}
- private void createSummary(Map additions, IRegion[] summaryRegions, Position summaryAnchor) {
+ private void createSummary(Map<Annotation, Position> additions, IRegion[] summaryRegions, Position summaryAnchor) {
int size= 0;
- Map map= null;
+ Map<String, AnnotationBag> map= null;
synchronized (fLock) {
if (fConfiguredAnnotationTypes != null) {
size= fConfiguredAnnotationTypes.size();
- map= new HashMap();
+ map= new HashMap<>();
for (int i= 0; i < size; i++) {
- String type= (String) fConfiguredAnnotationTypes.get(i);
+ String type= fConfiguredAnnotationTypes.get(i);
map.put(type, new AnnotationBag(type));
}
}
@@ -256,9 +256,9 @@ class ProjectionSummary {
IAnnotationModel model= fProjectionViewer.getAnnotationModel();
if (model == null)
return;
- Iterator e= model.getAnnotationIterator();
+ Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
- Annotation annotation= (Annotation) e.next();
+ Annotation annotation= e.next();
AnnotationBag bag= findBagForType(map, annotation.getType());
if (bag != null) {
Position position= model.getPosition(annotation);
@@ -268,19 +268,19 @@ class ProjectionSummary {
}
for (int i= 0; i < size; i++) {
- AnnotationBag bag= (AnnotationBag) map.get(fConfiguredAnnotationTypes.get(i));
+ AnnotationBag bag= map.get(fConfiguredAnnotationTypes.get(i));
if (!bag.isEmpty())
additions.put(bag, new Position(summaryAnchor.getOffset(), summaryAnchor.getLength()));
}
}
- private AnnotationBag findBagForType(Map bagMap, String annotationType) {
- AnnotationBag bag= (AnnotationBag) bagMap.get(annotationType);
+ private AnnotationBag findBagForType(Map<String, AnnotationBag> bagMap, String annotationType) {
+ AnnotationBag bag= bagMap.get(annotationType);
if (bag == null && fAnnotationAccess instanceof IAnnotationAccessExtension) {
IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
Object[] superTypes= extension.getSupertypes(annotationType);
for (int i= 0; i < superTypes.length && bag == null; i++) {
- bag= (AnnotationBag) bagMap.get(superTypes[i]);
+ bag= bagMap.get(superTypes[i]);
}
}
return bag;
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java
index e6722f766..09b1be4f9 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -144,7 +144,7 @@ public class ProjectionSupport {
private ProjectionViewer fViewer;
private IAnnotationAccess fAnnotationAccess;
private ISharedTextColors fSharedTextColors;
- private List fSummarizableTypes;
+ private List<String> fSummarizableTypes;
private IInformationControlCreator fInformationControlCreator;
private IInformationControlCreator fInformationPresenterControlCreator;
private ProjectionListener fProjectionListener;
@@ -183,7 +183,7 @@ public class ProjectionSupport {
*/
public void addSummarizableAnnotationType(String annotationType) {
if (fSummarizableTypes == null) {
- fSummarizableTypes= new ArrayList();
+ fSummarizableTypes= new ArrayList<>();
fSummarizableTypes.add(annotationType);
} else if (!fSummarizableTypes.contains(annotationType))
fSummarizableTypes.add(annotationType);
@@ -326,7 +326,7 @@ public class ProjectionSupport {
if (fSummarizableTypes != null) {
int size= fSummarizableTypes.size();
for (int i= 0; i < size; i++)
- summary.addAnnotationType((String) fSummarizableTypes.get(i));
+ summary.addAnnotationType(fSummarizableTypes.get(i));
}
return summary;
}
@@ -347,11 +347,12 @@ public class ProjectionSupport {
* @return the adapter or <code>null</code>
*
*/
- public Object getAdapter(ISourceViewer viewer, Class required) {
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(ISourceViewer viewer, Class<T> required) {
if (ProjectionAnnotationModel.class.equals(required)) {
if (viewer instanceof ProjectionViewer) {
ProjectionViewer projectionViewer= (ProjectionViewer) viewer;
- return projectionViewer.getProjectionAnnotationModel();
+ return (T) projectionViewer.getProjectionAnnotationModel();
}
}
return null;
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
index 123b8bb8d..6c8cd0886 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -224,7 +224,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
final static int REDRAW_COSTS= 15;
final static int INVALIDATION_COSTS= 10;
- List fList= new ArrayList(15);
+ List<ProjectionCommand> fList= new ArrayList<>(15);
int fExpectedExecutionCosts= -1;
@@ -232,7 +232,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
fList.add(command);
}
- Iterator iterator() {
+ Iterator<ProjectionCommand> iterator() {
return fList.iterator();
}
@@ -258,9 +258,9 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
fExpectedExecutionCosts= fList.size();
if (fExpectedExecutionCosts <= max_costs) {
ProjectionCommand command;
- Iterator e= fList.iterator();
+ Iterator<ProjectionCommand> e= fList.iterator();
while (e.hasNext()) {
- command= (ProjectionCommand) e.next();
+ command= e.next();
fExpectedExecutionCosts += command.computeExpectedCosts();
if (fExpectedExecutionCosts > max_costs)
break;
@@ -280,11 +280,11 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
/** Indication whether projection changes in the visible document should be considered. */
private boolean fHandleProjectionChanges= true;
/** The list of projection listeners. */
- private List fProjectionListeners;
+ private List<IProjectionListener> fProjectionListeners;
/** Internal lock for protecting the list of pending requests */
private Object fLock= new Object();
/** The list of pending requests */
- private List fPendingRequests= new ArrayList();
+ private List<AnnotationModelEvent> fPendingRequests= new ArrayList<>();
/** The replace-visible-document execution trigger */
private IDocument fReplaceVisibleDocumentExecutionTrigger;
/** <code>true</code> if projection was on the last time we switched to segmented mode. */
@@ -436,7 +436,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
Assert.isNotNull(listener);
if (fProjectionListeners == null)
- fProjectionListeners= new ArrayList();
+ fProjectionListeners= new ArrayList<>();
if (!fProjectionListeners.contains(listener))
fProjectionListeners.add(listener);
@@ -466,9 +466,9 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
*/
protected void fireProjectionEnabled() {
if (fProjectionListeners != null) {
- Iterator e= new ArrayList(fProjectionListeners).iterator();
+ Iterator<IProjectionListener> e= new ArrayList<>(fProjectionListeners).iterator();
while (e.hasNext()) {
- IProjectionListener l= (IProjectionListener) e.next();
+ IProjectionListener l= e.next();
l.projectionEnabled();
}
}
@@ -480,9 +480,9 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
*/
protected void fireProjectionDisabled() {
if (fProjectionListeners != null) {
- Iterator e= new ArrayList(fProjectionListeners).iterator();
+ Iterator<IProjectionListener> e= new ArrayList<>(fProjectionListeners).iterator();
while (e.hasNext()) {
- IProjectionListener l= (IProjectionListener) e.next();
+ IProjectionListener l= e.next();
l.projectionDisabled();
}
}
@@ -535,7 +535,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
Position found= null;
Annotation bestMatch= null;
Point selection= getSelectedRange();
- for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
+ for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
if (annotation.isCollapsed()) {
Position position= fProjectionAnnotationModel.getPosition(annotation);
@@ -564,7 +564,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
Position found= null;
Annotation bestMatch= null;
Point selection= getSelectedRange();
- for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
+ for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
if (!annotation.isCollapsed()) {
Position position= fProjectionAnnotationModel.getPosition(annotation);
@@ -883,7 +883,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
synchronized (fLock) {
if (fPendingRequests.size() == 0)
return;
- ame= (AnnotationModelEvent) fPendingRequests.remove(0);
+ ame= fPendingRequests.remove(0);
}
catchupWithProjectionAnnotationModel(ame);
}
@@ -959,7 +959,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
int topIndex= isRedrawing ? getTopIndex() : -1;
processDeletions(event, removedAnnotations, true);
- List coverage= new ArrayList();
+ List<Position> coverage= new ArrayList<>();
processChanges(addedAnnotations, true, coverage);
processChanges(changedAnnotation, true, coverage);
@@ -991,9 +991,9 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
private void executeProjectionCommands(ProjectionCommandQueue commandQueue, boolean fireRedraw) throws BadLocationException {
ProjectionCommand command;
- Iterator e= commandQueue.iterator();
+ Iterator<ProjectionCommand> e= commandQueue.iterator();
while (e.hasNext()) {
- command= (ProjectionCommand) e.next();
+ command= e.next();
switch (command.fType) {
case ProjectionCommand.ADD:
addMasterDocumentRange(command.fProjection, command.fOffset, command.fLength);
@@ -1012,8 +1012,8 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
}
private ProjectionAnnotation[] computeCollapsedNestedAnnotations(int offset, int length) {
- List annotations= new ArrayList(5);
- Iterator e= fProjectionAnnotationModel.getAnnotationIterator(offset, length, false, false);
+ List<ProjectionAnnotation> annotations= new ArrayList<>(5);
+ Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(offset, length, false, false);
while (e.hasNext()) {
ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
if (annotation.isCollapsed()) {
@@ -1140,7 +1140,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
return null;
}
- private void processChanges(Annotation[] annotations, boolean fireRedraw, List coverage) throws BadLocationException {
+ private void processChanges(Annotation[] annotations, boolean fireRedraw, List<Position> coverage) throws BadLocationException {
for (int i= 0; i < annotations.length; i++) {
ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i];
Position position= fProjectionAnnotationModel.getPosition(annotation);
@@ -1162,10 +1162,10 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
}
}
- private boolean covers(List coverage, Position position) {
- Iterator e= coverage.iterator();
+ private boolean covers(List<Position> coverage, Position position) {
+ Iterator<Position> e= coverage.iterator();
while (e.hasNext()) {
- Position p= (Position) e.next();
+ Position p= e.next();
if (p.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= p.getOffset() + p.getLength())
return true;
}
@@ -1195,7 +1195,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
}
if (projection != null) {
- Iterator e= fProjectionAnnotationModel.getAnnotationIterator();
+ Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator();
while (e.hasNext()) {
ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
if (annotation.isCollapsed()) {
@@ -1260,9 +1260,9 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
public void setRangeIndication(int offset, int length, boolean moveCursor) {
IRegion rangeIndication= getRangeIndication();
if (moveCursor && fProjectionAnnotationModel != null && (rangeIndication == null || offset != rangeIndication.getOffset() || length != rangeIndication.getLength())) {
- List expand= new ArrayList(2);
+ List<ProjectionAnnotation> expand= new ArrayList<>(2);
// expand the immediate affected collapsed regions
- Iterator iterator= fProjectionAnnotationModel.getAnnotationIterator();
+ Iterator<Annotation> iterator= fProjectionAnnotationModel.getAnnotationIterator();
while (iterator.hasNext()) {
ProjectionAnnotation annotation= (ProjectionAnnotation)iterator.next();
if (annotation.isCollapsed() && willAutoExpand(fProjectionAnnotationModel.getPosition(annotation), offset, length))
@@ -1270,9 +1270,9 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
}
if (!expand.isEmpty()) {
- Iterator e= expand.iterator();
+ Iterator<ProjectionAnnotation> e= expand.iterator();
while (e.hasNext())
- fProjectionAnnotationModel.expand((Annotation)e.next());
+ fProjectionAnnotationModel.expand(e.next());
}
}
super.setRangeIndication(offset, length, moveCursor);
@@ -1646,14 +1646,14 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
* @since 3.1
*/
private Position[] computeOverlappingAnnotationPositions(IRegion modelSelection) {
- List positions= new ArrayList();
- for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
+ List<Position> positions= new ArrayList<>();
+ for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
ProjectionAnnotation annotation= (ProjectionAnnotation) e.next();
Position position= fProjectionAnnotationModel.getPosition(annotation);
if (position != null && position.overlapsWith(modelSelection.getOffset(), modelSelection.getLength()) && modelRange2WidgetRange(position) != null)
positions.add(position);
}
- return (Position[]) positions.toArray(new Position[positions.size()]);
+ return positions.toArray(new Position[positions.size()]);
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
index 57b16ebe0..221d971e2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
@@ -58,11 +58,11 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
/**
* VerifyKeyListeners for the control.
*/
- private List fVerifyKeyListeners;
+ private List<VerifyKeyListener> fVerifyKeyListeners;
/**
* KeyListeners for the control.
*/
- private Set fKeyListeners;
+ private Set<KeyListener> fKeyListeners;
/**
* The Listener installed on the control which passes events to
* {@link #fVerifyKeyListeners fVerifyKeyListeners} and {@link #fKeyListeners}.
@@ -88,8 +88,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
* Creates a new {@link AbstractControlContentAssistSubjectAdapter}.
*/
public AbstractControlContentAssistSubjectAdapter() {
- fVerifyKeyListeners= new ArrayList(1);
- fKeyListeners= new HashSet(1);
+ fVerifyKeyListeners= new ArrayList<>(1);
+ fKeyListeners= new HashSet<>(1);
}
@Override
@@ -192,8 +192,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
dump("before traverse", e, verifyEvent); //$NON-NLS-1$
verifyEvent.doit= true;
- for (Iterator iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
- ((VerifyKeyListener) iter.next()).verifyKey(verifyEvent);
+ for (Iterator<VerifyKeyListener> iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
+ iter.next().verifyKey(verifyEvent);
if (! verifyEvent.doit) {
e.detail= SWT.TRAVERSE_NONE;
e.doit= true;
@@ -208,8 +208,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
break;
case SWT.KeyDown:
- for (Iterator iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
- ((VerifyKeyListener) iter.next()).verifyKey(verifyEvent);
+ for (Iterator<VerifyKeyListener> iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
+ iter.next().verifyKey(verifyEvent);
if (! verifyEvent.doit) {
e.doit= verifyEvent.doit;
if (DEBUG)
@@ -221,8 +221,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
if (DEBUG)
dump("keyDown OK", e, verifyEvent); //$NON-NLS-1$
- for (Iterator iter= fKeyListeners.iterator(); iter.hasNext();) {
- ((KeyListener) iter.next()).keyPressed(keyEvent);
+ for (Iterator<KeyListener> iter= fKeyListeners.iterator(); iter.hasNext();) {
+ iter.next().keyPressed(keyEvent);
}
break;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
index c4b719507..93d98c27c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
@@ -85,7 +85,7 @@ public class ComboContentAssistSubjectAdapter extends AbstractControlContentAssi
* The combo widget.
*/
private Combo fCombo;
- private HashMap fModifyListeners;
+ private HashMap<SelectionListener, Listener> fModifyListeners;
/**
* Creates a content assist subject control adapter for the given combo.
@@ -95,7 +95,7 @@ public class ComboContentAssistSubjectAdapter extends AbstractControlContentAssi
public ComboContentAssistSubjectAdapter(Combo combo) {
Assert.isNotNull(combo);
fCombo= combo;
- fModifyListeners= new HashMap();
+ fModifyListeners= new HashMap<>();
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
index 8dd2244aa..b47cccde2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
@@ -74,7 +74,7 @@ public class TextContentAssistSubjectAdapter extends AbstractControlContentAssis
/** The text. */
private Text fText;
/** The modify listeners. */
- private HashMap fModifyListeners= new HashMap();
+ private HashMap<SelectionListener, Listener> fModifyListeners= new HashMap<>();
/**
* Creates a content assist subject control adapter for the given text widget.
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
index 67f9b3d74..bfc048735 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -437,9 +437,9 @@ public class BrowserInformationControl extends AbstractInformationControl implem
fTextLayout.setText(text);
fTextLayout.setWidth(sizeConstraints == null ? SWT.DEFAULT : sizeConstraints.x - trim.width);
- Iterator iter= presentation.getAllStyleRangeIterator();
+ Iterator<StyleRange> iter= presentation.getAllStyleRangeIterator();
while (iter.hasNext()) {
- StyleRange sr= (StyleRange)iter.next();
+ StyleRange sr= iter.next();
if (sr.fontStyle == SWT.BOLD)
fTextLayout.setStyle(fBoldStyle, sr.start, sr.start + sr.length - 1);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
index 290a684de..9aef7af89 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
@@ -33,12 +33,12 @@ import org.eclipse.jface.text.TextPresentation;
public class HTML2TextReader extends SubstitutionTextReader {
private static final String EMPTY_STRING= ""; //$NON-NLS-1$
- private static final Map fgEntityLookup;
- private static final Set fgTags;
+ private static final Map<String, String> fgEntityLookup;
+ private static final Set<String> fgTags;
static {
- fgTags= new HashSet();
+ fgTags= new HashSet<>();
fgTags.add("b"); //$NON-NLS-1$
fgTags.add("br"); //$NON-NLS-1$
fgTags.add("br/"); //$NON-NLS-1$
@@ -58,7 +58,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
fgTags.add("pre"); //$NON-NLS-1$
fgTags.add("head"); //$NON-NLS-1$
- fgEntityLookup= new HashMap(7);
+ fgEntityLookup= new HashMap<>(7);
fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
@@ -351,7 +351,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
} catch (NumberFormatException e) {
}
} else {
- String str= (String) fgEntityLookup.get(symbol);
+ String str= fgEntityLookup.get(symbol);
if (str != null) {
return str;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java
index 341452782..b88aa2762 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -57,10 +57,10 @@ public class HTMLTextPresenter implements DefaultInformationControl.IInformation
int yoursEnd= offset + insertLength -1;
yoursEnd= Math.max(yoursStart, yoursEnd);
- Iterator e= presentation.getAllStyleRangeIterator();
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext()) {
- StyleRange range= (StyleRange) e.next();
+ StyleRange range= e.next();
int myStart= range.start;
int myEnd= range.start + range.length -1;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
index 188df4e69..4d6a932b4 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
@@ -85,7 +85,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
/** The key listener to control navigation */
private KeyListener fKeyListener;
/** List of document events used for filtering proposals */
- private List fDocumentEvents= new ArrayList();
+ private List<DocumentEvent> fDocumentEvents= new ArrayList<>();
/** Listener filling the document event queue */
private IDocumentListener fDocumentListener;
/** Reentrance count for <code>filterProposals</code> */
@@ -936,7 +936,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
IDocument document= fViewer.getDocument();
int length= proposals.length;
- List filtered= new ArrayList(length);
+ List<Object> filtered= new ArrayList<>(length);
for (int i= 0; i < length; i++) {
if (proposals[i] instanceof ICompletionProposalExtension2) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
index f8993b471..26ea2ecc0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
@@ -667,7 +667,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
private boolean fIsAutoInserting= false;
private int fProposalPopupOrientation= PROPOSAL_OVERLAY;
private int fContextInfoPopupOrientation= CONTEXT_INFO_ABOVE;
- private Map fProcessors;
+ private Map<String, IContentAssistProcessor> fProcessors;
private String fPartitioning;
private Color fContextInfoPopupBackground;
@@ -690,7 +690,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
private int fCompletionPosition;
private String[] fProposalStrings;
private ICompletionProposal[] fProposals;
- private final List fProposalListeners= new ArrayList();
+ private final List<IProposalListener> fProposalListeners= new ArrayList<>();
/**
* Tells whether colored label support is enabled.
@@ -764,7 +764,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
Assert.isNotNull(contentType);
if (fProcessors == null)
- fProcessors= new HashMap();
+ fProcessors= new HashMap<>();
if (processor == null)
fProcessors.remove(contentType);
@@ -780,7 +780,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
if (fProcessors == null)
return null;
- return (IContentAssistProcessor) fProcessors.get(contentType);
+ return fProcessors.get(contentType);
}
/**
@@ -1522,9 +1522,9 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
* @param proposal the proposal
*/
public void fireProposalChosen(ICompletionProposal proposal) {
- List list= new ArrayList(fProposalListeners);
- for (Iterator it= list.iterator(); it.hasNext();) {
- IProposalListener listener= (IProposalListener) it.next();
+ List<IProposalListener> list= new ArrayList<>(fProposalListeners);
+ for (Iterator<IProposalListener> it= list.iterator(); it.hasNext();) {
+ IProposalListener listener= it.next();
listener.proposalChosen(proposal);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
index 766c134b3..ce022e648 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -84,7 +84,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
private StyledText fContextInfoText;
private TextPresentation fTextPresentation;
- private Stack fContextFrameStack= new Stack();
+ private Stack<ContextFrame> fContextFrameStack= new Stack<>();
/**
@@ -291,7 +291,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
}
if (size > 0) {
- ContextFrame current= (ContextFrame) fContextFrameStack.peek();
+ ContextFrame current= fContextFrameStack.peek();
internalShowContextFrame(current, false);
} else {
@@ -619,7 +619,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
*/
fContextInfoPopup.getDisplay().asyncExec(new Runnable() {
- private ContextFrame fFrame= (ContextFrame) fContextFrameStack.peek();
+ private ContextFrame fFrame= fContextFrameStack.peek();
@Override
public void run() {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java
index ac3aeef76..84f4a8d6d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,7 +30,7 @@ import org.eclipse.jface.text.source.LineRange;
public final class ChangeRegion {
private final Revision fRevision;
private final ILineRange fLines;
- private final List fAdjusted= new LinkedList();
+ private final List<Range> fAdjusted= new LinkedList<>();
/**
* Creates a new change region for the given revision and line range.
@@ -66,12 +66,12 @@ public final class ChangeRegion {
}
/**
- * Returns the list of {@link ILineRange}s of this change region for which the revision
+ * Returns the list of {@link Range}s of this change region for which the revision
* information is still valid.
*
* @return the list of adjusted line ranges
*/
- public List getAdjustedRanges() {
+ public List<Range> getAdjustedRanges() {
return fAdjusted;
}
@@ -84,8 +84,8 @@ public final class ChangeRegion {
if (fAdjusted.isEmpty())
return new LineRange(fLines.getStartLine(), 0);
- Range first= (Range) fAdjusted.get(0);
- Range last= (Range) fAdjusted.get(fAdjusted.size() - 1);
+ Range first= fAdjusted.get(0);
+ Range last= fAdjusted.get(fAdjusted.size() - 1);
return Range.createAbsolute(first.start(), last.end());
}
@@ -104,8 +104,8 @@ public final class ChangeRegion {
* @param hunk the diff hunk to adjust to
*/
public void adjustTo(Hunk hunk) {
- for (ListIterator it= fAdjusted.listIterator(); it.hasNext();) {
- Range range= (Range) it.next();
+ for (ListIterator<Range> it= fAdjusted.listIterator(); it.hasNext();) {
+ Range range= it.next();
// do we need a split?
int unchanged= getUnchanged(hunk, range.start());
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java
index 3e527e579..2e2d49026 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java
@@ -32,7 +32,7 @@ public final class HunkComputer {
* @return the corresponding {@link Hunk} information
*/
public static Hunk[] computeHunks(ILineDiffer differ, int lines) {
- List hunks= new ArrayList(lines);
+ List<Hunk> hunks= new ArrayList<>(lines);
int added= 0;
int changed= 0;
@@ -70,7 +70,7 @@ public final class HunkComputer {
}
}
- return (Hunk[]) hunks.toArray(new Hunk[hunks.size()]);
+ return hunks.toArray(new Hunk[hunks.size()]);
}
private HunkComputer() {
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
index 2fbbb36de..91d5e026d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
@@ -138,15 +138,15 @@ public final class RevisionPainter {
/**
* A list of {@link Long}, storing the age of each revision in a sorted list.
*/
- private List fRevisions;
+ private List<Long> fRevisions;
/**
* The stored shaded colors.
*/
- private final Map fColors= new HashMap();
+ private final Map<Revision, RGB> fColors= new HashMap<>();
/**
* The stored focus colors.
*/
- private final Map fFocusColors= new HashMap();
+ private final Map<Revision, RGB> fFocusColors= new HashMap<>();
/**
* Sets the revision information, which is needed to compute the relative age of a revision.
@@ -160,9 +160,9 @@ public final class RevisionPainter {
if (info == null)
return;
- List revisions= new ArrayList();
- for (Iterator it= info.getRevisions().iterator(); it.hasNext();) {
- Revision revision= (Revision) it.next();
+ List<Long> revisions= new ArrayList<>();
+ for (Iterator<Revision> it= info.getRevisions().iterator(); it.hasNext();) {
+ Revision revision= it.next();
revisions.add(new Long(computeAge(revision)));
}
Collections.sort(revisions);
@@ -248,8 +248,8 @@ public final class RevisionPainter {
* @return the color for a revision
*/
public RGB getColor(Revision revision, boolean focus) {
- Map map= focus ? fFocusColors : fColors;
- RGB color= (RGB) map.get(revision);
+ Map<Revision, RGB> map= focus ? fFocusColors : fColors;
+ RGB color= map.get(revision);
if (color != null)
return color;
@@ -533,9 +533,9 @@ public final class RevisionPainter {
/* Cache. */
/** The cached list of ranges adapted to quick diff. */
- private List fRevisionRanges= null;
+ private List<RevisionRange> fRevisionRanges= null;
/** The annotations created for the overview ruler temporary display. */
- private List fAnnotations= new ArrayList();
+ private List<Annotation> fAnnotations= new ArrayList<>();
/* State */
@@ -693,9 +693,9 @@ public final class RevisionPainter {
}
// draw change regions
- List/* <RevisionRange> */ranges= getRanges(visibleLines);
- for (Iterator it= ranges.iterator(); it.hasNext();) {
- RevisionRange region= (RevisionRange) it.next();
+ List<RevisionRange> ranges= getRanges(visibleLines);
+ for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
+ RevisionRange region= it.next();
paintRange(region, gc);
}
}
@@ -902,19 +902,19 @@ public final class RevisionPainter {
* @return the corresponding <code>RevisionRange</code> or <code>null</code>
*/
private RevisionRange getRange(int line) {
- List ranges= getRangeCache();
+ List<RevisionRange> ranges= getRangeCache();
if (ranges.isEmpty() || line == -1)
return null;
- for (Iterator it= ranges.iterator(); it.hasNext();) {
- RevisionRange range= (RevisionRange) it.next();
+ for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
+ RevisionRange range= it.next();
if (contains(range, line))
return range;
}
// line may be right after the last region
- RevisionRange lastRegion= (RevisionRange) ranges.get(ranges.size() - 1);
+ RevisionRange lastRegion= ranges.get(ranges.size() - 1);
if (line == end(lastRegion))
return lastRegion;
return null;
@@ -926,14 +926,14 @@ public final class RevisionPainter {
* @param lines the model based lines of interest
* @return elementType: RevisionRange
*/
- private List getRanges(ILineRange lines) {
- List ranges= getRangeCache();
+ private List<RevisionRange> getRanges(ILineRange lines) {
+ List<RevisionRange> ranges= getRangeCache();
// return the interesting subset
int end= end(lines);
int first= -1, last= -1;
for (int i= 0; i < ranges.size(); i++) {
- RevisionRange range= (RevisionRange) ranges.get(i);
+ RevisionRange range= ranges.get(i);
int rangeEnd= end(range);
if (first == -1 && rangeEnd > lines.getStartLine())
first= i;
@@ -943,7 +943,7 @@ public final class RevisionPainter {
}
}
if (first == -1)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
if (last == -1)
last= ranges.size() - 1; // bottom index may be one too much
@@ -956,10 +956,10 @@ public final class RevisionPainter {
*
* @return the list of all change regions, with diff information applied
*/
- private synchronized List getRangeCache() {
+ private synchronized List<RevisionRange> getRangeCache() {
if (fRevisionRanges == null) {
if (fRevisionInfo == null) {
- fRevisionRanges= Collections.EMPTY_LIST;
+ fRevisionRanges= Collections.emptyList();
} else {
Hunk[] hunks= HunkComputer.computeHunks(fLineDiffer, fViewer.getDocument().getNumberOfLines());
fRevisionInfo.applyDiff(hunks);
@@ -1075,11 +1075,11 @@ public final class RevisionPainter {
Revision revision= fFocusRevision != null ? fFocusRevision : fSelectedRevision;
- Map added= null;
+ Map<Annotation, Position> added= null;
if (revision != null) {
- added= new HashMap();
- for (Iterator it= revision.getRegions().iterator(); it.hasNext();) {
- RevisionRange range= (RevisionRange) it.next();
+ added= new HashMap<>();
+ for (Iterator<RevisionRange> it= revision.getRegions().iterator(); it.hasNext();) {
+ RevisionRange range= it.next();
try {
IRegion charRegion= toCharRegion(range);
Position position= new Position(charRegion.getOffset(), charRegion.getLength());
@@ -1093,16 +1093,16 @@ public final class RevisionPainter {
if (fAnnotationModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext= (IAnnotationModelExtension) fAnnotationModel;
- ext.replaceAnnotations((Annotation[]) fAnnotations.toArray(new Annotation[fAnnotations.size()]), added);
+ ext.replaceAnnotations(fAnnotations.toArray(new Annotation[fAnnotations.size()]), added);
} else {
- for (Iterator it= fAnnotations.iterator(); it.hasNext();) {
- Annotation annotation= (Annotation) it.next();
+ for (Iterator<Annotation> it= fAnnotations.iterator(); it.hasNext();) {
+ Annotation annotation= it.next();
fAnnotationModel.removeAnnotation(annotation);
}
if (added != null) {
- for (Iterator it= added.entrySet().iterator(); it.hasNext();) {
- Entry entry= (Entry) it.next();
- fAnnotationModel.addAnnotation((Annotation) entry.getKey(), (Position) entry.getValue());
+ for (Iterator<Entry<Annotation, Position>> it= added.entrySet().iterator(); it.hasNext();) {
+ Entry<Annotation, Position> entry= it.next();
+ fAnnotationModel.addAnnotation(entry.getKey(), entry.getValue());
}
}
}
@@ -1156,8 +1156,8 @@ public final class RevisionPainter {
if (fRevisionInfo == null)
return;
- for (Iterator it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
- Revision revision= (Revision) it.next();
+ for (Iterator<Revision> it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
+ Revision revision= it.next();
if (id.equals(revision.getId())) {
handleRevisionSelected(revision);
return;
@@ -1287,10 +1287,10 @@ public final class RevisionPainter {
ILineRange nextWidgetRange= null;
ILineRange last= null;
- List ranges= fFocusRevision.getRegions();
+ List<RevisionRange> ranges= fFocusRevision.getRegions();
if (up) {
- for (Iterator it= ranges.iterator(); it.hasNext();) {
- RevisionRange range= (RevisionRange) it.next();
+ for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
+ RevisionRange range= it.next();
ILineRange widgetRange= modelLinesToWidgetLines(range);
if (contains(range, documentHoverLine)) {
nextWidgetRange= last;
@@ -1300,8 +1300,8 @@ public final class RevisionPainter {
last= widgetRange;
}
} else {
- for (ListIterator it= ranges.listIterator(ranges.size()); it.hasPrevious();) {
- RevisionRange range= (RevisionRange) it.previous();
+ for (ListIterator<RevisionRange> it= ranges.listIterator(ranges.size()); it.hasPrevious();) {
+ RevisionRange range= it.previous();
ILineRange widgetRange= modelLinesToWidgetLines(range);
if (contains(range, documentHoverLine)) {
nextWidgetRange= last;
@@ -1459,8 +1459,8 @@ public final class RevisionPainter {
if (hasInformation() && (fShowRevision || fShowAuthor)) {
int revisionWidth= 0;
int authorWidth= 0;
- for (Iterator it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
- Revision revision= (Revision) it.next();
+ for (Iterator<Revision> it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
+ Revision revision= it.next();
revisionWidth= Math.max(revisionWidth, revision.getId().length());
authorWidth= Math.max(authorWidth, revision.getAuthor().length());
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java
index 94fc58360..a28f14bfe 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java
@@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Shell;
*/
public abstract class AbstractReusableInformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension, DisposeListener {
- private Map fInformationControls= new HashMap();
+ private Map<Shell, IInformationControl> fInformationControls= new HashMap<>();
/**
* Creates the control.
@@ -38,7 +38,7 @@ public abstract class AbstractReusableInformationControlCreator implements IInfo
@Override
public IInformationControl createInformationControl(Shell parent) {
- IInformationControl control= (IInformationControl)fInformationControls.get(parent);
+ IInformationControl control= fInformationControls.get(parent);
if (control == null) {
control= doCreateInformationControl(parent);
control.addDisposeListener(this);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
index 9c4704e75..28cb78a47 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
@@ -40,7 +40,7 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
/** The original line delimiters */
private String[] fOriginalLineDelimiters;
/** The registered text change listeners */
- private List fTextChangeListeners= new ArrayList(1);
+ private List<TextChangeListener> fTextChangeListeners= new ArrayList<>(1);
/**
* The remembered document event
* @since 2.0
@@ -317,9 +317,9 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
TextChangedEvent event= new TextChangedEvent(this);
if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
+ Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
- ((TextChangeListener) e.next()).textChanged(event);
+ e.next().textChanged(event);
}
}
@@ -334,9 +334,9 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
TextChangedEvent event = new TextChangedEvent(this);
if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
+ Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
- ((TextChangeListener) e.next()).textSet(event);
+ e.next().textSet(event);
}
}
@@ -362,9 +362,9 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
event.newLineCount= (fEvent.fText == null ? 0 : document.computeNumberOfLines(fEvent.fText));
if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
+ Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
- ((TextChangeListener) e.next()).textChanging(event);
+ e.next().textChanging(event);
}
} catch (BadLocationException e) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java
index d75515222..ab30e23d7 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -51,9 +51,9 @@ public class DefaultTextHover implements ITextHover {
if (model == null)
return null;
- Iterator e= model.getAnnotationIterator();
+ Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
if (isIncluded(a)) {
Position p= model.getPosition(a);
if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
index ae95f9bb4..fb9b366a6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -424,7 +424,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
class CompoundTextCommand extends TextCommand {
/** The list of individual commands */
- private List fCommands= new ArrayList();
+ private List<TextCommand> fCommands= new ArrayList<>();
/**
* Creates a new compound text command.
@@ -455,11 +455,11 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
TextCommand c;
for (int i= size -1; i > 0; --i) {
- c= (TextCommand) fCommands.get(i);
+ c= fCommands.get(i);
c.undoTextChange();
}
- c= (TextCommand) fCommands.get(0);
+ c= fCommands.get(0);
c.undo(monitor, uiInfo);
}
@@ -476,11 +476,11 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
TextCommand c;
for (int i= 0; i < size -1; ++i) {
- c= (TextCommand) fCommands.get(i);
+ c= fCommands.get(i);
c.redoTextChange();
}
- c= (TextCommand) fCommands.get(size -1);
+ c= fCommands.get(size -1);
c.redo(monitor, uiInfo);
}
return Status.OK_STATUS;
@@ -556,7 +556,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
if (fStart > -1)
return super.getUndoModificationStamp();
else if (fCommands.size() > 0)
- return ((TextCommand)fCommands.get(0)).getUndoModificationStamp();
+ return fCommands.get(0).getUndoModificationStamp();
return fUndoModificationStamp;
}
@@ -572,7 +572,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
if (fStart > -1)
return super.getRedoModificationStamp();
else if (fCommands.size() > 0)
- return ((TextCommand)fCommands.get(fCommands.size()-1)).getRedoModificationStamp();
+ return fCommands.get(fCommands.size()-1).getRedoModificationStamp();
return fRedoModificationStamp;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
index 554032cfe..cc3731f60 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -37,7 +37,7 @@ public class DocumentCommand {
* A command which is added to document commands.
* @since 2.1
*/
- private static class Command implements Comparable {
+ private static class Command implements Comparable<Command> {
/** The offset of the range to be replaced */
private final int fOffset;
/** The length of the range to be replaced. */
@@ -85,15 +85,12 @@ public class DocumentCommand {
document.addDocumentListener(fOwner);
}
- /*
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
@Override
- public int compareTo(final Object object) {
+ public int compareTo(Command object) {
if (isEqual(object))
return 0;
- final Command command= (Command) object;
+ Command command= object;
// diff middle points if not intersecting
if (fOffset + fLength <= command.fOffset || command.fOffset + command.fLength <= fOffset) {
@@ -117,17 +114,19 @@ public class DocumentCommand {
/**
* An iterator, which iterates in reverse over a list.
+ *
+ * @param <E> the type of elements returned by this iterator
*/
- private static class ReverseListIterator implements Iterator {
+ private static class ReverseListIterator<E> implements Iterator<E> {
/** The list iterator. */
- private final ListIterator fListIterator;
+ private final ListIterator<E> fListIterator;
/**
* Creates a reverse list iterator.
* @param listIterator the iterator that this reverse iterator is based upon
*/
- public ReverseListIterator(ListIterator listIterator) {
+ public ReverseListIterator(ListIterator<E> listIterator) {
if (listIterator == null)
throw new IllegalArgumentException();
fListIterator= listIterator;
@@ -139,7 +138,7 @@ public class DocumentCommand {
}
@Override
- public Object next() {
+ public E next() {
return fListIterator.previous();
}
@@ -152,10 +151,10 @@ public class DocumentCommand {
/**
* A command iterator.
*/
- private static class CommandIterator implements Iterator {
+ private static class CommandIterator implements Iterator<Command> {
/** The command iterator. */
- private final Iterator fIterator;
+ private final Iterator<Command> fIterator;
/** The original command. */
private Command fCommand;
@@ -170,10 +169,10 @@ public class DocumentCommand {
* @param command the original command
* @param forward the direction
*/
- public CommandIterator(final List commands, final Command command, final boolean forward) {
+ public CommandIterator(final List<Command> commands, final Command command, final boolean forward) {
if (commands == null || command == null)
throw new IllegalArgumentException();
- fIterator= forward ? commands.iterator() : new ReverseListIterator(commands.listIterator(commands.size()));
+ fIterator= forward ? commands.iterator() : new ReverseListIterator<>(commands.listIterator(commands.size()));
fCommand= command;
fForward= forward;
}
@@ -184,7 +183,7 @@ public class DocumentCommand {
}
@Override
- public Object next() {
+ public Command next() {
if (!hasNext())
throw new NoSuchElementException();
@@ -198,7 +197,7 @@ public class DocumentCommand {
return tempCommand;
}
- final Command command= (Command) fIterator.next();
+ final Command command= fIterator.next();
final int compareValue= command.compareTo(fCommand);
if ((compareValue < 0) ^ !fForward) {
@@ -242,7 +241,7 @@ public class DocumentCommand {
* Additional document commands.
* @since 2.1
*/
- private final List fCommands= new ArrayList();
+ private final List<Command> fCommands= new ArrayList<>();
/**
* Indicates whether the caret should be shifted by this command.
* @since 3.0
@@ -319,11 +318,11 @@ public class DocumentCommand {
final int insertionIndex= -(index + 1);
// overlaps to the right?
- if (insertionIndex != fCommands.size() && intersects((Command) fCommands.get(insertionIndex), command))
+ if (insertionIndex != fCommands.size() && intersects(fCommands.get(insertionIndex), command))
throw new BadLocationException();
// overlaps to the left?
- if (insertionIndex != 0 && intersects((Command) fCommands.get(insertionIndex - 1), command))
+ if (insertionIndex != 0 && intersects(fCommands.get(insertionIndex - 1), command))
throw new BadLocationException();
fCommands.add(insertionIndex, command);
@@ -336,7 +335,7 @@ public class DocumentCommand {
*
* @return returns the command iterator
*/
- public Iterator getCommandIterator() {
+ public Iterator<Command> getCommandIterator() {
Command command= new Command(offset, length, text, owner);
return new CommandIterator(fCommands, command, true);
}
@@ -403,8 +402,8 @@ public class DocumentCommand {
}
final Command originalCommand= new Command(offset, length, text, owner);
- for (final Iterator iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); )
- ((Command) iterator.next()).execute(document);
+ for (final Iterator<Command> iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); )
+ iterator.next().execute(document);
} catch (BadLocationException e) {
// ignore
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java
index 37089e74f..4d9a270f3 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java
@@ -51,11 +51,11 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
/**
* The high-priority proposals.
*/
- private final ArrayList fPriorityProposals;
+ private final ArrayList<ContentProposal> fPriorityProposals;
/**
* The low-priority proposals.
*/
- private final ArrayList fProposals;
+ private final ArrayList<ContentProposal> fProposals;
/**
* <code>true</code> iff <code>fExpression</code> ends with an open escape.
*/
@@ -69,8 +69,8 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
public ProposalComputer(String contents, int position) {
fExpression= contents;
fDocumentOffset= position;
- fPriorityProposals= new ArrayList();
- fProposals= new ArrayList();
+ fPriorityProposals= new ArrayList<>();
+ fProposals= new ArrayList<>();
boolean isEscape= false;
esc: for (int i= position - 1; i >= 0; i--) {
@@ -196,7 +196,7 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
}
fPriorityProposals.addAll(fProposals);
- return (IContentProposal[]) fPriorityProposals.toArray(new IContentProposal[fProposals.size()]);
+ return fPriorityProposals.toArray(new IContentProposal[fProposals.size()]);
}
/**
@@ -224,7 +224,7 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
addBsProposal("\\C", RegExMessages.getString("displayString_replace_bs_C"), RegExMessages.getString("additionalInfo_replace_bs_C")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
fPriorityProposals.addAll(fProposals);
- return (IContentProposal[]) fPriorityProposals.toArray(new IContentProposal[fPriorityProposals.size()]);
+ return fPriorityProposals.toArray(new IContentProposal[fPriorityProposals.size()]);
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
index 0220b5f29..551bc5b84 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
@@ -172,7 +172,7 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
/** The painters managed by this paint manager. */
- private List fPainters= new ArrayList(2);
+ private List<IPainter> fPainters= new ArrayList<>(2);
/** The position manager used by this paint manager */
private PositionManager fManager;
/** The associated text viewer */
@@ -264,8 +264,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
fManager= null;
}
- for (Iterator e = fPainters.iterator(); e.hasNext();)
- ((IPainter) e.next()).dispose();
+ for (Iterator<IPainter> e = fPainters.iterator(); e.hasNext();)
+ e.next().dispose();
fPainters.clear();
fTextViewer.removeTextInputListener(this);
@@ -298,8 +298,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
* @see IPainter
*/
private void paint(int reason) {
- for (Iterator e = fPainters.iterator(); e.hasNext();)
- ((IPainter) e.next()).paint(reason);
+ for (Iterator<IPainter> e = fPainters.iterator(); e.hasNext();)
+ e.next().paint(reason);
}
@Override
@@ -350,8 +350,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
@Override
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
if (oldInput != null) {
- for (Iterator e= fPainters.iterator(); e.hasNext();)
- ((IPainter)e.next()).deactivate(false);
+ for (Iterator<IPainter> e= fPainters.iterator(); e.hasNext();)
+ e.next().deactivate(false);
fManager.uninstall(oldInput);
removeListeners();
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
index 6730ae24f..d38b07901 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -48,9 +48,9 @@ public class TextPresentation {
StyleRange[] ranges= new StyleRange[presentation.getDenumerableRanges()];
int i= 0;
- Iterator e= presentation.getAllStyleRangeIterator();
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext())
- ranges[i++]= (StyleRange) e.next();
+ ranges[i++]= e.next();
text.setStyleRanges(ranges);
}
@@ -61,7 +61,7 @@ public class TextPresentation {
/**
* Enumerates all the <code>StyleRange</code>s included in the presentation.
*/
- class FilterIterator implements Iterator {
+ class FilterIterator implements Iterator<StyleRange> {
/** The index of the next style range to be enumerated */
protected int fIndex;
@@ -91,9 +91,9 @@ public class TextPresentation {
}
@Override
- public Object next() {
+ public StyleRange next() {
try {
- StyleRange r= (StyleRange) fRanges.get(fIndex++);
+ StyleRange r= fRanges.get(fIndex++);
return createWindowRelativeRange(fWindow, r);
} catch (ArrayIndexOutOfBoundsException x) {
throw new NoSuchElementException();
@@ -136,7 +136,7 @@ public class TextPresentation {
/** The style information for the range covered by the whole presentation */
private StyleRange fDefaultRange;
/** The member ranges of the presentation */
- private ArrayList fRanges;
+ private ArrayList<StyleRange> fRanges;
/** A clipping region against which the presentation can be clipped when asked for results */
private IRegion fResultWindow;
/**
@@ -150,7 +150,7 @@ public class TextPresentation {
* Creates a new empty text presentation.
*/
public TextPresentation() {
- fRanges= new ArrayList(50);
+ fRanges= new ArrayList<>(50);
}
/**
@@ -161,7 +161,7 @@ public class TextPresentation {
*/
public TextPresentation(int sizeHint) {
Assert.isTrue(sizeHint > 0);
- fRanges= new ArrayList(sizeHint);
+ fRanges= new ArrayList<>(sizeHint);
}
/**
@@ -294,7 +294,7 @@ public class TextPresentation {
int last= getFirstIndexAfterWindow(rangeRegion);
for (int i= first; i < last && length > 0; i++) {
- StyleRange current= (StyleRange)fRanges.get(i);
+ StyleRange current= fRanges.get(i);
int currentStart= current.start;
int currentEnd= currentStart + current.length;
@@ -405,8 +405,8 @@ public class TextPresentation {
*/
private void applyStyleRanges(StyleRange[] ranges, boolean merge) {
int j= 0;
- ArrayList oldRanges= fRanges;
- ArrayList newRanges= new ArrayList(2*ranges.length + oldRanges.size());
+ ArrayList<StyleRange> oldRanges= fRanges;
+ ArrayList<StyleRange> newRanges= new ArrayList<>(2*ranges.length + oldRanges.size());
for (int i= 0, n= ranges.length; i < n; i++) {
StyleRange range= ranges[i];
fRanges= oldRanges; // for getFirstIndexAfterWindow(...)
@@ -511,7 +511,7 @@ public class TextPresentation {
int i= -1, j= fRanges.size();
while (j - i > 1) {
int k= (i + j) >> 1;
- StyleRange r= (StyleRange) fRanges.get(k);
+ StyleRange r= fRanges.get(k);
if (r.start + r.length > start)
j= k;
else
@@ -535,7 +535,7 @@ public class TextPresentation {
int i= -1, j= fRanges.size();
while (j - i > 1) {
int k= (i + j) >> 1;
- StyleRange r= (StyleRange) fRanges.get(k);
+ StyleRange r= fRanges.get(k);
if (r.start < end)
i= k;
else
@@ -605,7 +605,7 @@ public class TextPresentation {
*
* @return a style range iterator
*/
- public Iterator getNonDefaultStyleRangeIterator() {
+ public Iterator<StyleRange> getNonDefaultStyleRangeIterator() {
return new FilterIterator(fDefaultRange != null);
}
@@ -616,7 +616,7 @@ public class TextPresentation {
*
* @return a style range iterator
*/
- public Iterator getAllStyleRangeIterator() {
+ public Iterator<StyleRange> getAllStyleRangeIterator() {
return new FilterIterator(false);
}
@@ -650,7 +650,7 @@ public class TextPresentation {
public StyleRange getFirstStyleRange() {
try {
- StyleRange range= (StyleRange) fRanges.get(getFirstIndexInWindow(fResultWindow));
+ StyleRange range= fRanges.get(getFirstIndexInWindow(fResultWindow));
return createWindowRelativeRange(fResultWindow, range);
} catch (NoSuchElementException x) {
@@ -668,7 +668,7 @@ public class TextPresentation {
public StyleRange getLastStyleRange() {
try {
- StyleRange range= (StyleRange) fRanges.get(getFirstIndexAfterWindow(fResultWindow) - 1);
+ StyleRange range= fRanges.get(getFirstIndexAfterWindow(fResultWindow) - 1);
return createWindowRelativeRange(fResultWindow, range);
} catch (NoSuchElementException x) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
index fe62f16a3..adf4e3909 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
@@ -466,9 +466,9 @@ public class TextViewer extends Viewer implements
}
/** List of registered verify key listeners. */
- private List fListeners= new ArrayList();
+ private List<VerifyKeyListener> fListeners= new ArrayList<>();
/** List of pending batches. */
- private List fBatched= new ArrayList();
+ private List<Batch> fBatched= new ArrayList<>();
/** The reentrance count. */
private int fReentranceCount= 0;
@@ -479,9 +479,9 @@ public class TextViewer extends Viewer implements
try {
fReentranceCount++;
- Iterator iterator= fListeners.iterator();
+ Iterator<VerifyKeyListener> iterator= fListeners.iterator();
while (iterator.hasNext() && event.doit) {
- VerifyKeyListener listener= (VerifyKeyListener) iterator.next();
+ VerifyKeyListener listener= iterator.next();
listener.verifyKey(event); // we might trigger reentrant calls on GTK
}
} finally {
@@ -496,9 +496,9 @@ public class TextViewer extends Viewer implements
*/
private void processBatchedRequests() {
if (!fBatched.isEmpty()) {
- Iterator e= fBatched.iterator();
+ Iterator<Batch> e= fBatched.iterator();
while (e.hasNext()) {
- Batch batch= (Batch) e.next();
+ Batch batch= e.next();
insertListener(batch.listener, batch.index);
}
fBatched.clear();
@@ -777,7 +777,7 @@ public class TextViewer extends Viewer implements
/** The highlight color of the range of this target. */
private Color fScopeHighlightColor;
/** The document partitioner remembered in case of a "Replace All". */
- private Map fRememberedPartitioners;
+ private Map<String, IDocumentPartitioner> fRememberedPartitioners;
/**
* The active rewrite session.
* @since 3.1
@@ -1522,7 +1522,7 @@ public class TextViewer extends Viewer implements
* The registered post selection changed listeners.
* @since 3.0
*/
- private List fPostSelectionChangedListeners;
+ private List<ISelectionChangedListener> fPostSelectionChangedListeners;
/**
* Queued post selection changed events count.
* @since 3.0
@@ -1537,7 +1537,7 @@ public class TextViewer extends Viewer implements
* The set of registered editor helpers.
* @since 3.1
*/
- private Set fEditorHelpers= new HashSet();
+ private Set<IEditingSupport> fEditorHelpers= new HashSet<>();
/**
* The internal rewrite session listener.
* @since 3.1
@@ -1547,25 +1547,25 @@ public class TextViewer extends Viewer implements
/** Should the auto indent strategies ignore the next edit operation */
protected boolean fIgnoreAutoIndent= false;
/** The strings a line is prefixed with on SHIFT_RIGHT and removed from each line on SHIFT_LEFT */
- protected Map fIndentChars;
+ protected Map<String, String[]> fIndentChars;
/** The string a line is prefixed with on PREFIX and removed from each line on STRIP_PREFIX */
- protected Map fDefaultPrefixChars;
+ protected Map<String, String[]> fDefaultPrefixChars;
/** The text viewer's text double click strategies */
- protected Map fDoubleClickStrategies;
+ protected Map<String, ITextDoubleClickStrategy> fDoubleClickStrategies;
/** The text viewer's undo manager */
protected IUndoManager fUndoManager;
/** The text viewer's auto indent strategies */
- protected Map fAutoIndentStrategies;
+ protected Map<String, List<IAutoEditStrategy>> fAutoIndentStrategies;
/** The text viewer's text hovers */
- protected Map fTextHovers;
+ protected Map<TextHoverKey, ITextHover> fTextHovers;
/** All registered view port listeners> */
- protected List fViewportListeners;
+ protected List<IViewportListener> fViewportListeners;
/** The last visible vertical position of the top line */
protected int fLastTopPixel;
/** All registered text listeners */
- protected List fTextListeners;
+ protected List<ITextListener> fTextListeners;
/** All registered text input listeners */
- protected List fTextInputListeners;
+ protected List<ITextInputListener> fTextInputListeners;
/** The text viewer's event consumer */
protected IEventConsumer fEventConsumer;
/** Indicates whether the viewer's text presentation should be replaced are modified. */
@@ -1594,7 +1594,7 @@ public class TextViewer extends Viewer implements
* All registered text presentation listeners.
* since 3.0
*/
- protected List fTextPresentationListeners;
+ protected List<ITextPresentationListener> fTextPresentationListeners;
/**
* The find/replace document adapter.
* @since 3.0
@@ -1953,9 +1953,9 @@ public class TextViewer extends Viewer implements
*/
protected final void setAutoEditStrategies(IAutoEditStrategy[] strategies, String contentType) {
if (fAutoIndentStrategies == null)
- fAutoIndentStrategies= new HashMap();
+ fAutoIndentStrategies= new HashMap<>();
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
+ List<IAutoEditStrategy> autoEditStrategies= fAutoIndentStrategies.get(contentType);
if (strategies == null) {
if (autoEditStrategies == null)
@@ -1965,7 +1965,7 @@ public class TextViewer extends Viewer implements
} else {
if (autoEditStrategies == null) {
- autoEditStrategies= new ArrayList();
+ autoEditStrategies= new ArrayList<>();
fAutoIndentStrategies.put(contentType, autoEditStrategies);
}
@@ -1981,11 +1981,11 @@ public class TextViewer extends Viewer implements
throw new IllegalArgumentException();
if (fAutoIndentStrategies == null)
- fAutoIndentStrategies= new HashMap();
+ fAutoIndentStrategies= new HashMap<>();
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
+ List<IAutoEditStrategy> autoEditStrategies= fAutoIndentStrategies.get(contentType);
if (autoEditStrategies == null) {
- autoEditStrategies= new ArrayList();
+ autoEditStrategies= new ArrayList<>();
fAutoIndentStrategies.put(contentType, autoEditStrategies);
}
@@ -1997,11 +1997,11 @@ public class TextViewer extends Viewer implements
if (fAutoIndentStrategies == null)
return;
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
+ List<IAutoEditStrategy> autoEditStrategies= fAutoIndentStrategies.get(contentType);
if (autoEditStrategies == null)
return;
- for (final Iterator iterator= autoEditStrategies.iterator(); iterator.hasNext(); ) {
+ for (final Iterator<IAutoEditStrategy> iterator= autoEditStrategies.iterator(); iterator.hasNext(); ) {
if (iterator.next().equals(strategy)) {
iterator.remove();
break;
@@ -2028,7 +2028,7 @@ public class TextViewer extends Viewer implements
if (ok) {
if (fIndentChars == null)
- fIndentChars= new HashMap();
+ fIndentChars= new HashMap<>();
fIndentChars.put(contentType, indentPrefixes);
@@ -2063,7 +2063,7 @@ public class TextViewer extends Viewer implements
if (defaultPrefixes != null && defaultPrefixes.length > 0) {
if (fDefaultPrefixChars == null)
- fDefaultPrefixChars= new HashMap();
+ fDefaultPrefixChars= new HashMap<>();
fDefaultPrefixChars.put(contentType, defaultPrefixes);
} else if (fDefaultPrefixChars != null)
fDefaultPrefixChars.remove(contentType);
@@ -2089,7 +2089,7 @@ public class TextViewer extends Viewer implements
TextHoverKey key= new TextHoverKey(contentType, stateMask);
if (hover != null) {
if (fTextHovers == null) {
- fTextHovers= new HashMap();
+ fTextHovers= new HashMap<>();
}
fTextHovers.put(key, hover);
} else if (fTextHovers != null)
@@ -2103,9 +2103,9 @@ public class TextViewer extends Viewer implements
if (fTextHovers == null)
return;
- Iterator iter= new HashSet(fTextHovers.keySet()).iterator();
+ Iterator<TextHoverKey> iter= new HashSet<>(fTextHovers.keySet()).iterator();
while (iter.hasNext()) {
- TextHoverKey key= (TextHoverKey)iter.next();
+ TextHoverKey key= iter.next();
if (key.fContentType.equals(contentType))
fTextHovers.remove(key);
}
@@ -2486,7 +2486,7 @@ public class TextViewer extends Viewer implements
Assert.isNotNull(listener);
if (fPostSelectionChangedListeners == null)
- fPostSelectionChangedListeners= new ArrayList();
+ fPostSelectionChangedListeners= new ArrayList<>();
if (!fPostSelectionChangedListeners.contains(listener))
fPostSelectionChangedListeners.add(listener);
@@ -2613,11 +2613,11 @@ public class TextViewer extends Viewer implements
* @since 3.0
*/
private void firePostSelectionChanged(SelectionChangedEvent event) {
- List listeners= fPostSelectionChangedListeners;
+ List<ISelectionChangedListener> listeners= fPostSelectionChangedListeners;
if (listeners != null) {
- listeners= new ArrayList(listeners);
+ listeners= new ArrayList<>(listeners);
for (int i= 0; i < listeners.size(); i++) {
- ISelectionChangedListener l= (ISelectionChangedListener) listeners.get(i);
+ ISelectionChangedListener l= listeners.get(i);
l.selectionChanged(event);
}
}
@@ -2654,7 +2654,7 @@ public class TextViewer extends Viewer implements
Assert.isNotNull(listener);
if (fTextListeners == null)
- fTextListeners= new ArrayList();
+ fTextListeners= new ArrayList<>();
if (!fTextListeners.contains(listener))
fTextListeners.add(listener);
@@ -2679,16 +2679,16 @@ public class TextViewer extends Viewer implements
* @param cmd the widget command translated into a text event sent to all text listeners
*/
protected void updateTextListeners(WidgetCommand cmd) {
- List textListeners= fTextListeners;
+ List<ITextListener> textListeners= fTextListeners;
if (textListeners != null) {
- textListeners= new ArrayList(textListeners);
+ textListeners= new ArrayList<>(textListeners);
DocumentEvent event= cmd.event;
if (event instanceof SlaveDocumentEvent)
event= ((SlaveDocumentEvent) event).getMasterEvent();
TextEvent e= new TextEvent(cmd.start, cmd.length, cmd.text, cmd.preservedText, event, redraws());
for (int i= 0; i < textListeners.size(); i++) {
- ITextListener l= (ITextListener) textListeners.get(i);
+ ITextListener l= textListeners.get(i);
l.textChanged(e);
}
}
@@ -2702,7 +2702,7 @@ public class TextViewer extends Viewer implements
Assert.isNotNull(listener);
if (fTextInputListeners == null)
- fTextInputListeners= new ArrayList();
+ fTextInputListeners= new ArrayList<>();
if (!fTextInputListeners.contains(listener))
fTextInputListeners.add(listener);
@@ -2728,10 +2728,10 @@ public class TextViewer extends Viewer implements
* @param newInput the new input document
*/
protected void fireInputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- List listener= fTextInputListeners;
+ List<ITextInputListener> listener= fTextInputListeners;
if (listener != null) {
for (int i= 0; i < listener.size(); i++) {
- ITextInputListener l= (ITextInputListener) listener.get(i);
+ ITextInputListener l= listener.get(i);
l.inputDocumentAboutToBeChanged(oldInput, newInput);
}
}
@@ -2745,10 +2745,10 @@ public class TextViewer extends Viewer implements
* @param newInput the new input document
*/
protected void fireInputDocumentChanged(IDocument oldInput, IDocument newInput) {
- List listener= fTextInputListeners;
+ List<ITextInputListener> listener= fTextInputListeners;
if (listener != null) {
for (int i= 0; i < listener.size(); i++) {
- ITextInputListener l= (ITextInputListener) listener.get(i);
+ ITextInputListener l= listener.get(i);
l.inputDocumentChanged(oldInput, newInput);
}
}
@@ -2937,7 +2937,7 @@ public class TextViewer extends Viewer implements
public void addViewportListener(IViewportListener listener) {
if (fViewportListeners == null) {
- fViewportListeners= new ArrayList();
+ fViewportListeners= new ArrayList<>();
initializeViewportUpdate();
}
@@ -2966,7 +2966,7 @@ public class TextViewer extends Viewer implements
if (topPixel >= 0 && topPixel != fLastTopPixel) {
if (fViewportListeners != null) {
for (int i= 0; i < fViewportListeners.size(); i++) {
- IViewportListener l= (IViewportListener) fViewportListeners.get(i);
+ IViewportListener l= fViewportListeners.get(i);
l.viewportChanged(topPixel);
}
}
@@ -3532,7 +3532,7 @@ public class TextViewer extends Viewer implements
if (strategy != null) {
if (fDoubleClickStrategies == null)
- fDoubleClickStrategies= new HashMap();
+ fDoubleClickStrategies= new HashMap<>();
fDoubleClickStrategies.put(contentType, strategy);
} else if (fDoubleClickStrategies != null)
fDoubleClickStrategies.remove(contentType);
@@ -3542,11 +3542,11 @@ public class TextViewer extends Viewer implements
* Selects from the given map the one which is registered under the content type of the
* partition in which the given offset is located.
*
- * @param plugins the map from which to choose
* @param offset the offset for which to find the plug-in
+ * @param plugins the map from which to choose
* @return the plug-in registered under the offset's content type or <code>null</code> if none
*/
- protected Object selectContentTypePlugin(int offset, Map plugins) {
+ protected Object selectContentTypePlugin(int offset, Map<String, ?> plugins) {
final IDocument document= getDocument();
if (document == null)
return null;
@@ -3567,7 +3567,7 @@ public class TextViewer extends Viewer implements
* @param plugins the table to be searched
* @return the plug-in in the map for the given content type
*/
- private Object selectContentTypePlugin(String type, Map plugins) {
+ private Object selectContentTypePlugin(String type, Map<String, ?> plugins) {
if (plugins == null)
return null;
@@ -3592,7 +3592,8 @@ public class TextViewer extends Viewer implements
if (fTabsToSpacesConverter != null)
fTabsToSpacesConverter.customizeDocumentCommand(document, command);
- List strategies= (List) selectContentTypePlugin(command.offset, fAutoIndentStrategies);
+ @SuppressWarnings("unchecked")
+ List<IAutoEditStrategy> strategies= (List<IAutoEditStrategy>) selectContentTypePlugin(command.offset, fAutoIndentStrategies);
if (strategies == null)
return;
@@ -3602,14 +3603,14 @@ public class TextViewer extends Viewer implements
break;
case 1:
- ((IAutoEditStrategy) strategies.iterator().next()).customizeDocumentCommand(document, command);
+ strategies.iterator().next().customizeDocumentCommand(document, command);
break;
// make iterator robust against adding/removing strategies from within strategies
default:
- strategies= new ArrayList(strategies);
- for (final Iterator iterator= strategies.iterator(); iterator.hasNext(); )
- ((IAutoEditStrategy) iterator.next()).customizeDocumentCommand(document, command);
+ strategies= new ArrayList<>(strategies);
+ for (final Iterator<IAutoEditStrategy> iterator= strategies.iterator(); iterator.hasNext(); )
+ iterator.next().customizeDocumentCommand(document, command);
break;
}
@@ -4219,7 +4220,7 @@ public class TextViewer extends Viewer implements
fUndoManager.beginCompoundChange();
IDocument d= getDocument();
- Map partitioners= null;
+ Map<String, IDocumentPartitioner> partitioners= null;
DocumentRewriteSession rewriteSession= null;
try {
ITextSelection selection= (ITextSelection) getSelection();
@@ -4251,7 +4252,7 @@ public class TextViewer extends Viewer implements
partitioners= TextUtilities.removeDocumentPartitioners(d);
// Perform the shift operation.
- Map map= (useDefaultPrefixes ? fDefaultPrefixChars : fIndentChars);
+ Map<String, String[]> map= (useDefaultPrefixes ? fDefaultPrefixChars : fIndentChars);
for (int i= 0, j= 0; i < regions.length; i++, j += 2) {
String[] prefixes= (String[]) selectContentTypePlugin(regions[i].getType(), map);
if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0) {
@@ -4652,27 +4653,27 @@ public class TextViewer extends Viewer implements
if (range != null)
fTextWidget.setStyleRange(range);
- ArrayList ranges= new ArrayList(presentation.getDenumerableRanges());
- Iterator e= presentation.getNonDefaultStyleRangeIterator();
+ ArrayList<StyleRange> ranges= new ArrayList<>(presentation.getDenumerableRanges());
+ Iterator<StyleRange> e= presentation.getNonDefaultStyleRangeIterator();
while (e.hasNext()) {
- range= (StyleRange) e.next();
+ range= e.next();
range= modelStyleRange2WidgetStyleRange(range);
if (range != null)
ranges.add(range);
}
if (!ranges.isEmpty())
- fTextWidget.replaceStyleRanges(0, 0, (StyleRange[])ranges.toArray(new StyleRange[ranges.size()]));
+ fTextWidget.replaceStyleRanges(0, 0, ranges.toArray(new StyleRange[ranges.size()]));
} else {
IRegion region= modelRange2WidgetRange(presentation.getCoverage());
if (region == null)
return;
- List list= new ArrayList(presentation.getDenumerableRanges());
- Iterator e= presentation.getAllStyleRangeIterator();
+ List<StyleRange> list= new ArrayList<>(presentation.getDenumerableRanges());
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext()) {
- range= (StyleRange) e.next();
+ range= e.next();
range= modelStyleRange2WidgetStyleRange(range);
if (range != null)
list.add(range);
@@ -4694,10 +4695,10 @@ public class TextViewer extends Viewer implements
*/
private void applyTextPresentation(TextPresentation presentation) {
- List list= new ArrayList(presentation.getDenumerableRanges());
- Iterator e= presentation.getAllStyleRangeIterator();
+ List<StyleRange> list= new ArrayList<>(presentation.getDenumerableRanges());
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext()) {
- StyleRange range= (StyleRange) e.next();
+ StyleRange range= e.next();
range= modelStyleRange2WidgetStyleRange(range);
if (range != null)
list.add(range);
@@ -4742,9 +4743,9 @@ public class TextViewer extends Viewer implements
* and let them apply their presentation.
*/
if (fTextPresentationListeners != null) {
- ArrayList listeners= new ArrayList(fTextPresentationListeners);
+ ArrayList<ITextPresentationListener> listeners= new ArrayList<>(fTextPresentationListeners);
for (int i= 0, size= listeners.size(); i < size; i++) {
- ITextPresentationListener listener= (ITextPresentationListener)listeners.get(i);
+ ITextPresentationListener listener= listeners.get(i);
listener.applyTextPresentation(presentation);
}
}
@@ -5459,7 +5460,7 @@ public class TextViewer extends Viewer implements
Assert.isNotNull(listener);
if (fTextPresentationListeners == null)
- fTextPresentationListeners= new ArrayList();
+ fTextPresentationListeners= new ArrayList<>();
if (!fTextPresentationListeners.contains(listener))
fTextPresentationListeners.add(listener);
@@ -5502,7 +5503,7 @@ public class TextViewer extends Viewer implements
*/
@Override
public IEditingSupport[] getRegisteredSupports() {
- return (IEditingSupport[]) fEditorHelpers.toArray(new IEditingSupport[fEditorHelpers.size()]);
+ return fEditorHelpers.toArray(new IEditingSupport[fEditorHelpers.size()]);
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
index cb28c3961..697c52fba 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,6 @@ package org.eclipse.jface.text.contentassist;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Comparator;
import java.util.List;
import org.eclipse.osgi.util.TextProcessor;
@@ -291,7 +290,7 @@ class CompletionProposalPopup implements IContentAssistListener {
/** The key listener to control navigation. */
private ProposalSelectionListener fKeyListener;
/** List of document events used for filtering proposals. */
- private final List fDocumentEvents= new ArrayList();
+ private final List<DocumentEvent> fDocumentEvents= new ArrayList<>();
/** Listener filling the document event queue. */
private IDocumentListener fDocumentListener;
/** The filter list of proposals. */
@@ -1509,7 +1508,7 @@ class CompletionProposalPopup implements IContentAssistListener {
IDocument document= fContentAssistSubjectControlAdapter.getDocument();
int length= proposals.length;
- List filtered= new ArrayList(length);
+ List<Object> filtered= new ArrayList<>(length);
for (int i= 0; i < length; i++) {
if (proposals[i] instanceof ICompletionProposalExtension2) {
@@ -1540,7 +1539,7 @@ class CompletionProposalPopup implements IContentAssistListener {
}
}
- return (ICompletionProposal[]) filtered.toArray(new ICompletionProposal[filtered.size()]);
+ return filtered.toArray(new ICompletionProposal[filtered.size()]);
}
/**
@@ -1658,7 +1657,7 @@ class CompletionProposalPopup implements IContentAssistListener {
// contains the common postfix in the case that there are any proposals matching our LHS
StringBuffer rightCasePostfix= null;
- List rightCase= new ArrayList();
+ List<ICompletionProposal> rightCase= new ArrayList<>();
boolean isWrongCaseMatch= false;
@@ -1668,7 +1667,7 @@ class CompletionProposalPopup implements IContentAssistListener {
int wrongCasePrefixStart= 0;
// contains the common postfix of all case-insensitive matches
StringBuffer wrongCasePostfix= null;
- List wrongCase= new ArrayList();
+ List<ICompletionProposal> wrongCase= new ArrayList<>();
for (int i= 0; i < fFilteredProposals.length; i++) {
ICompletionProposal proposal= fFilteredProposals[i];
@@ -1721,7 +1720,7 @@ class CompletionProposalPopup implements IContentAssistListener {
// 2: replace single proposals
if (rightCase.size() == 1) {
- ICompletionProposal proposal= (ICompletionProposal) rightCase.get(0);
+ ICompletionProposal proposal= rightCase.get(0);
if (canAutoInsert(proposal) && rightCasePostfix.length() > 0) {
insertProposal(proposal, (char) 0, 0, fInvocationOffset);
hide();
@@ -1729,7 +1728,7 @@ class CompletionProposalPopup implements IContentAssistListener {
}
return false;
} else if (isWrongCaseMatch && wrongCase.size() == 1) {
- ICompletionProposal proposal= (ICompletionProposal) wrongCase.get(0);
+ ICompletionProposal proposal= wrongCase.get(0);
if (canAutoInsert(proposal)) {
insertProposal(proposal, (char) 0, 0, fInvocationOffset);
hide();
@@ -1904,12 +1903,6 @@ class CompletionProposalPopup implements IContentAssistListener {
* @since 3.8
*/
private void sortProposals(final ICompletionProposal[] proposals) {
- Arrays.sort(proposals, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- return fSorter.compare((ICompletionProposal)o1,
- (ICompletionProposal)o2);
- }
- });
+ Arrays.sort(proposals, fSorter::compare);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index 94f6c0443..7fc5166fc 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -906,7 +906,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
private boolean fIsAutoInserting= false;
private int fProposalPopupOrientation= PROPOSAL_OVERLAY;
private int fContextInfoPopupOrientation= CONTEXT_INFO_ABOVE;
- private Map fProcessors;
+ private Map<String, IContentAssistProcessor> fProcessors;
/**
* The partitioning.
@@ -1023,7 +1023,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
*
* @since 3.4
*/
- private Map fHandlers;
+ private Map<String, IHandler> fHandlers;
/**
* Tells whether colored labels support is enabled.
@@ -1080,7 +1080,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
Assert.isNotNull(contentType);
if (fProcessors == null)
- fProcessors= new HashMap();
+ fProcessors= new HashMap<>();
if (processor == null)
fProcessors.remove(contentType);
@@ -1096,7 +1096,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
if (fProcessors == null)
return null;
- return (IContentAssistProcessor) fProcessors.get(contentType);
+ return fProcessors.get(contentType);
}
/**
@@ -1110,10 +1110,10 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
return ""; //$NON-NLS-1$
StringBuffer buf= new StringBuffer(5);
- Iterator iter= fProcessors.entrySet().iterator();
+ Iterator<Entry<String, IContentAssistProcessor>> iter= fProcessors.entrySet().iterator();
while (iter.hasNext()) {
- Entry entry= (Entry) iter.next();
- IContentAssistProcessor processor= (IContentAssistProcessor) entry.getValue();
+ Entry<String, IContentAssistProcessor> entry= iter.next();
+ IContentAssistProcessor processor= entry.getValue();
char[] triggers= processor.getCompletionProposalAutoActivationCharacters();
if (triggers != null)
buf.append(triggers);
@@ -2535,7 +2535,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
if (fHandlers == null)
throw new IllegalStateException();
- IHandler handler= (IHandler)fHandlers.get(commandId);
+ IHandler handler= fHandlers.get(commandId);
if (handler != null)
return handler;
@@ -2552,7 +2552,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
*/
protected final void registerHandler(String commandId, IHandler handler) {
if (fHandlers == null)
- fHandlers= new HashMap(2);
+ fHandlers= new HashMap<>(2);
fHandlers.put(commandId, handler);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
index 0bc4eb036..600741249 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -117,7 +117,7 @@ class ContextInformationPopup implements IContentAssistListener {
private StyledText fContextInfoText;
private TextPresentation fTextPresentation;
- private Stack fContextFrameStack= new Stack();
+ private Stack<ContextFrame> fContextFrameStack= new Stack<>();
/**
* The content assist subject control.
*
@@ -218,8 +218,8 @@ class ContextInformationPopup implements IContentAssistListener {
}
// also check all other contexts
- for (Iterator it= fContextFrameStack.iterator(); it.hasNext(); ) {
- ContextFrame stackFrame= (ContextFrame) it.next();
+ for (Iterator<ContextFrame> it= fContextFrameStack.iterator(); it.hasNext(); ) {
+ ContextFrame stackFrame= it.next();
if (stackFrame.equals(frame)) {
validateContextInformation();
return;
@@ -321,7 +321,7 @@ class ContextInformationPopup implements IContentAssistListener {
if (fContextFrameStack.isEmpty())
return false;
// stack not empty
- ContextFrame top= (ContextFrame) fContextFrameStack.peek();
+ ContextFrame top= fContextFrameStack.peek();
return frame.equals(top);
}
@@ -460,12 +460,12 @@ class ContextInformationPopup implements IContentAssistListener {
int size= fContextFrameStack.size();
if (size > 0) {
- fLastContext= (ContextFrame) fContextFrameStack.pop();
+ fLastContext= fContextFrameStack.pop();
-- size;
}
if (size > 0) {
- ContextFrame current= (ContextFrame) fContextFrameStack.peek();
+ ContextFrame current= fContextFrameStack.peek();
internalShowContextFrame(current, false);
} else {
@@ -872,7 +872,7 @@ class ContextInformationPopup implements IContentAssistListener {
fContextInfoPopup.getDisplay().asyncExec(new Runnable() {
- private ContextFrame fFrame= (ContextFrame) fContextFrameStack.peek();
+ private ContextFrame fFrame= fContextFrameStack.peek();
@Override
public void run() {
@@ -882,7 +882,7 @@ class ContextInformationPopup implements IContentAssistListener {
// iterate all contexts on the stack
while (Helper.okToUse(fContextInfoPopup) && !fContextFrameStack.isEmpty()) {
- ContextFrame top= (ContextFrame) fContextFrameStack.peek();
+ ContextFrame top= fContextFrameStack.peek();
if (top.fValidator == null || !top.fValidator.isContextInformationValid(offset)) {
hideContextInfoPopup(); // loop variant: reduces the number of contexts on the stack
} else if (top.fPresenter != null && top.fPresenter.updatePresentation(offset, fTextPresentation)) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
index e02b999a4..fd0d9b8dd 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -69,7 +69,7 @@ public class ContentFormatter implements IContentFormatter {
* Defines a reference to either the offset or the end offset of
* a particular position.
*/
- static class PositionReference implements Comparable {
+ static class PositionReference implements Comparable<PositionReference> {
/** The referenced position */
protected Position fPosition;
@@ -167,14 +167,8 @@ public class ContentFormatter implements IContentFormatter {
}
@Override
- public int compareTo(Object obj) {
-
- if (obj instanceof PositionReference) {
- PositionReference r= (PositionReference) obj;
- return getCharacterPosition() - r.getCharacterPosition();
- }
-
- throw new ClassCastException();
+ public int compareTo(PositionReference r) {
+ return getCharacterPosition() - r.getCharacterPosition();
}
}
@@ -251,14 +245,14 @@ public class ContentFormatter implements IContentFormatter {
private final static String PARTITIONING= "__formatter_partitioning"; //$NON-NLS-1$
/** The map of <code>IFormattingStrategy</code> objects */
- private Map fStrategies;
+ private Map<String, IFormattingStrategy> fStrategies;
/** The indicator of whether the formatter operates in partition aware mode or not */
private boolean fIsPartitionAware= true;
/** The partition information managing document position categories */
private String[] fPartitionManagingCategories;
/** The list of references to offset and end offset of all overlapping positions */
- private List fOverlappingPositionReferences;
+ private List<PositionReference> fOverlappingPositionReferences;
/** Position updater used for partitioning positions */
private IPositionUpdater fPartitioningUpdater;
/**
@@ -306,7 +300,7 @@ public class ContentFormatter implements IContentFormatter {
Assert.isNotNull(contentType);
if (fStrategies == null)
- fStrategies= new HashMap();
+ fStrategies= new HashMap<>();
if (strategy == null)
fStrategies.remove(contentType);
@@ -355,7 +349,7 @@ public class ContentFormatter implements IContentFormatter {
if (fStrategies == null)
return null;
- return (IFormattingStrategy) fStrategies.get(contentType);
+ return fStrategies.get(contentType);
}
@Override
@@ -657,7 +651,7 @@ public class ContentFormatter implements IContentFormatter {
*/
private int[] getAffectedPositions(int offset, int length) {
- fOverlappingPositionReferences= new ArrayList();
+ fOverlappingPositionReferences= new ArrayList<>();
determinePositionsToUpdate(offset, length);
@@ -665,7 +659,7 @@ public class ContentFormatter implements IContentFormatter {
int[] positions= new int[fOverlappingPositionReferences.size()];
for (int i= 0; i < positions.length; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
+ PositionReference r= fOverlappingPositionReferences.get(i);
positions[i]= r.getCharacterPosition() - offset;
}
@@ -681,7 +675,7 @@ public class ContentFormatter implements IContentFormatter {
private void removeAffectedPositions(IDocument document) {
int size= fOverlappingPositionReferences.size();
for (int i= 0; i < size; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
+ PositionReference r= fOverlappingPositionReferences.get(i);
try {
document.removePosition(r.getCategory(), r.getPosition());
} catch (BadPositionCategoryException x) {
@@ -708,7 +702,7 @@ public class ContentFormatter implements IContentFormatter {
for (int i= 0; i < positions.length; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
+ PositionReference r= fOverlappingPositionReferences.get(i);
if (r.refersToOffset())
r.setOffset(offset + positions[i]);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
index ddeccc8d1..65342636d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,14 +25,14 @@ import java.util.Map;
public abstract class ContextBasedFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
/** The current preferences for formatting */
- private Map fCurrentPreferences= null;
+ private Map<String, String> fCurrentPreferences= null;
/** The list of preferences for initiated the formatting steps */
- private final LinkedList fPreferences= new LinkedList();
+ private final LinkedList<Map<String, String>> fPreferences= new LinkedList<>();
@Override
public void format() {
- fCurrentPreferences= (Map)fPreferences.removeFirst();
+ fCurrentPreferences= fPreferences.removeFirst();
}
@Override
@@ -42,7 +42,9 @@ public abstract class ContextBasedFormattingStrategy implements IFormattingStrat
@Override
public void formatterStarts(final IFormattingContext context) {
- fPreferences.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES));
+ @SuppressWarnings("unchecked")
+ Map<String, String> prefs= (Map<String, String>) context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES);
+ fPreferences.addLast(prefs);
}
@Override
@@ -62,7 +64,7 @@ public abstract class ContextBasedFormattingStrategy implements IFormattingStrat
*
* @return The preferences for the current formatting step
*/
- public final Map getPreferences() {
+ public final Map<String, String> getPreferences() {
return fCurrentPreferences;
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
index 9b76ced36..adce03929 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,7 +24,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
public class FormattingContext implements IFormattingContext {
/** Map to store the properties */
- private final Map fMap= new HashMap();
+ private final Map<Object, Object> fMap= new HashMap<>();
@Override
public void dispose() {
@@ -73,7 +73,7 @@ public class FormattingContext implements IFormattingContext {
}
@Override
- public void mapToStore(Map map, IPreferenceStore store) {
+ public void mapToStore(Map<Object, Object> map, IPreferenceStore store) {
final String[] preferences= getPreferenceKeys();
@@ -114,7 +114,7 @@ public class FormattingContext implements IFormattingContext {
}
@Override
- public void storeToMap(IPreferenceStore store, Map map, boolean useDefault) {
+ public void storeToMap(IPreferenceStore store, Map<Object, Object> map, boolean useDefault) {
final String[] preferences= getPreferenceKeys();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
index 662b1d0f2..27fa75a30 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,8 +42,8 @@ public class FormattingContextProperties {
public static final String CONTEXT_PARTITION= "formatting.context.partition"; //$NON-NLS-1$
/**
- * Property key of the preferences property. The property must implement
- * <code>java.util#Map</code>. The formatting preferences mapping preference
+ * Property key of the preferences property. The property value must implement
+ * {@code java.util.Map<String, String>}. The formatting preferences mapping preference
* keys to values.
* <p>
* Value: <code>"formatting.context.preferences"</code>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
index fa92119d1..616c1e2f9 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,7 +41,7 @@ public interface IFormattingContext {
/**
* Retrieves the property <code>key</code> from the formatting context
*
- * @param key the key of the property to store in the context
+ * @param key the key of the property to store in the context. Must be a {@link String}.
* @return the property <code>key</code> if available, <code>null</code> otherwise
*/
Object getProperty(Object key);
@@ -110,12 +110,12 @@ public interface IFormattingContext {
* @param map Map to retrieve the preferences from
* @param store Preference store to store the preferences in
*/
- void mapToStore(Map map, IPreferenceStore store);
+ void mapToStore(Map<Object, Object> map, IPreferenceStore store);
/**
* Stores the property <code>key</code> in the formatting context.
*
- * @param key Key of the property to store in the context
+ * @param key Key of the property to store in the context. Must be a {@link String}.
* @param property Property to store in the context. If already present, the new property
* overwrites the present one.
*/
@@ -133,5 +133,5 @@ public interface IFormattingContext {
* @param useDefault <code>true</code> if the default preferences should be used,
* <code>false</code> otherwise
*/
- void storeToMap(IPreferenceStore store, Map map, boolean useDefault);
+ void storeToMap(IPreferenceStore store, Map<Object, Object> map, boolean useDefault);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
index be8d54989..7abacbb4a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultPositionUpdater;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.TextUtilities;
@@ -103,7 +104,7 @@ public class MultiPassContentFormatter implements IContentFormatter, IContentFor
/** The partitioning of this content formatter */
private final String fPartitioning;
/** The slave formatting strategies */
- private final Map fSlaves= new HashMap();
+ private final Map<String, IFormattingStrategy> fSlaves= new HashMap<>();
/** The default content type */
private final String fType;
@@ -240,7 +241,7 @@ public class MultiPassContentFormatter implements IContentFormatter, IContentFor
*/
protected void formatSlaves(final IFormattingContext context, final IDocument document, final int offset, final int length) {
- Map partitioners= new HashMap(0);
+ Map<String, IDocumentPartitioner> partitioners= new HashMap<>(0);
try {
final ITypedRegion[] partitions= TextUtilities.computePartitioning(document, fPartitioning, offset, length, false);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java
index cd73b4f44..56684a0ba 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -60,7 +60,7 @@ public abstract class AbstractHyperlinkDetector implements IHyperlinkDetector, I
* or <code>null</code> if this object does not
* have an adapter for the given class
*/
- protected final Object getAdapter(Class adapterClass) {
+ protected final <T> T getAdapter(Class<T> adapterClass) {
Assert.isLegal(adapterClass != null);
if (fContext != null)
return fContext.getAdapter(adapterClass);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java
index 419e4bb0b..e38a970cf 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -267,7 +267,7 @@ public class HyperlinkManager implements ITextListener, Listener, KeyListener, M
* @since 3.7
*/
private IHyperlink[] findHyperlinks(IRegion region) {
- List allHyperlinks= new ArrayList(fHyperlinkDetectors.length * 2);
+ List<IHyperlink> allHyperlinks= new ArrayList<>(fHyperlinkDetectors.length * 2);
synchronized (fHyperlinkDetectors) {
for (int i= 0, length= fHyperlinkDetectors.length; i < length; i++) {
IHyperlinkDetector detector= fHyperlinkDetectors[i];
@@ -304,18 +304,18 @@ public class HyperlinkManager implements ITextListener, Listener, KeyListener, M
if (fDetectionStrategy != ALL) {
int maxLength= computeLongestHyperlinkLength(allHyperlinks);
- Iterator iter= new ArrayList(allHyperlinks).iterator();
+ Iterator<IHyperlink> iter= new ArrayList<>(allHyperlinks).iterator();
while (iter.hasNext()) {
- IHyperlink hyperlink= (IHyperlink)iter.next();
+ IHyperlink hyperlink= iter.next();
if (hyperlink.getHyperlinkRegion().getLength() < maxLength)
allHyperlinks.remove(hyperlink);
}
}
if (fDetectionStrategy == LONGEST_REGION_FIRST)
- return new IHyperlink[] {(IHyperlink)allHyperlinks.get(0)};
+ return new IHyperlink[] {allHyperlinks.get(0)};
- return (IHyperlink[])allHyperlinks.toArray(new IHyperlink[allHyperlinks.size()]);
+ return allHyperlinks.toArray(new IHyperlink[allHyperlinks.size()]);
}
@@ -325,12 +325,12 @@ public class HyperlinkManager implements ITextListener, Listener, KeyListener, M
* @param hyperlinks the list of hyperlinks
* @return the length of the longest detected
*/
- protected int computeLongestHyperlinkLength(List hyperlinks) {
+ protected int computeLongestHyperlinkLength(List<? extends IHyperlink> hyperlinks) {
Assert.isLegal(hyperlinks != null && !hyperlinks.isEmpty());
- Iterator iter= hyperlinks.iterator();
+ Iterator<? extends IHyperlink> iter= hyperlinks.iterator();
int length= Integer.MIN_VALUE;
while (iter.hasNext()) {
- IRegion region= ((IHyperlink)iter.next()).getHyperlinkRegion();
+ IRegion region= iter.next().getHyperlinkRegion();
if (region.getLength() < length)
continue;
length= region.getLength();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
index c9c73534e..45e927dc2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
@@ -200,7 +200,7 @@ public class InformationPresenter extends AbstractInformationControlManager impl
/** The text viewer this information presenter works on */
private ITextViewer fTextViewer;
/** The map of <code>IInformationProvider</code> objects */
- private Map fProviders;
+ private Map<String, IInformationProvider> fProviders;
/** The offset to override selection. */
private int fOffset= -1;
/**
@@ -256,7 +256,7 @@ public class InformationPresenter extends AbstractInformationControlManager impl
Assert.isNotNull(contentType);
if (fProviders == null)
- fProviders= new HashMap();
+ fProviders= new HashMap<>();
if (provider == null)
fProviders.remove(contentType);
@@ -269,7 +269,7 @@ public class InformationPresenter extends AbstractInformationControlManager impl
if (fProviders == null)
return null;
- return (IInformationProvider) fProviders.get(contentType);
+ return fProviders.get(contentType);
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
index 4f2a5492d..40cf26cd6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
@@ -1043,12 +1043,12 @@ public class LinkedModeUI {
if (document instanceof IDocumentExtension3) {
IDocumentExtension3 ext= (IDocumentExtension3) document;
String[] partitionings= ext.getPartitionings();
- Set contentTypes= new HashSet(20);
+ Set<String> contentTypes= new HashSet<>(20);
for (int i= 0; i < partitionings.length; i++) {
contentTypes.addAll(Arrays.asList(ext.getLegalContentTypes(partitionings[i])));
}
contentTypes.add(IDocument.DEFAULT_CONTENT_TYPE);
- return (String[]) contentTypes.toArray(new String[contentTypes.size()]);
+ return contentTypes.toArray(new String[contentTypes.size()]);
}
return document.getLegalContentTypes();
}
@@ -1149,7 +1149,7 @@ public class LinkedModeUI {
if ((flags & ILinkedModeListener.UPDATE_CARET) != 0 && fExitPosition != null && fFramePosition != fExitPosition && !fExitPosition.isDeleted())
switchPosition(fExitPosition, true, false);
- final List docs= new ArrayList();
+ final List<IDocument> docs= new ArrayList<>();
for (int i= 0; i < fTargets.length; i++) {
IDocument doc= fTargets[i].getViewer().getDocument();
if (doc != null)
@@ -1164,8 +1164,8 @@ public class LinkedModeUI {
if (fExitPosition != null)
fExitPosition.getDocument().removePosition(fExitPosition);
- for (Iterator iter = docs.iterator(); iter.hasNext(); ) {
- IDocument doc= (IDocument) iter.next();
+ for (Iterator<IDocument> iter = docs.iterator(); iter.hasNext(); ) {
+ IDocument doc= iter.next();
doc.removePositionUpdater(fPositionUpdater);
boolean uninstallCat= false;
String[] cats= doc.getPositionCategories();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
index b379b88ca..297afa7d8 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
@@ -46,8 +46,8 @@ final class LinkedPositionAnnotations extends AnnotationModel {
private Annotation fFocusAnnotation= null;
private Annotation fExitAnnotation= null;
- private final Map fGroupAnnotations= new HashMap();
- private final Map fTargetAnnotations= new HashMap();
+ private final Map<Position, Annotation> fGroupAnnotations= new HashMap<>();
+ private final Map<Position, Annotation> fTargetAnnotations= new HashMap<>();
private Position[] fTargets= new Position[0];
private LinkedPosition fExitPosition= null;
@@ -96,7 +96,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
* @param positions the new slave positions, or <code>null</code> if no slave positions are to be set
* @throws BadLocationException in case any of the given positions is invalid
*/
- private void setGroupPositions(List positions) throws BadLocationException {
+ private void setGroupPositions(List<Position> positions) throws BadLocationException {
if (!fMarkSlaves)
return;
@@ -104,11 +104,11 @@ final class LinkedPositionAnnotations extends AnnotationModel {
// Algorithm: toRemove contains all mappings at first, but all that are in
// positions get removed -> toRemove contains the difference set of previous - new
// toAdd are the new positions, which don't exist in previous = new - previous
- List toRemove= new ArrayList(fGroupAnnotations.values());
- Map toAdd= new HashMap();
+ List<Annotation> toRemove= new ArrayList<>(fGroupAnnotations.values());
+ Map<Annotation, Position> toAdd= new HashMap<>();
if (positions != null) {
- for (Iterator iter= positions.iterator(); iter.hasNext();) {
- Position p= (Position) iter.next();
+ for (Iterator<Position> iter= positions.iterator(); iter.hasNext();) {
+ Position p= iter.next();
if (fGroupAnnotations.containsKey(p)) {
toRemove.remove(fGroupAnnotations.get(p));
} else {
@@ -120,7 +120,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
}
fGroupAnnotations.values().removeAll(toRemove);
- replaceAnnotations((Annotation[]) toRemove.toArray(new Annotation[0]), toAdd, false);
+ replaceAnnotations(toRemove.toArray(new Annotation[0]), toAdd, false);
}
/**
@@ -130,7 +130,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
* @param positions the new target positions, or <code>null</code> if no target positions are to be set
* @throws BadLocationException in case any of the given positions is invalid
*/
- private void setTargetPositions(List positions) throws BadLocationException {
+ private void setTargetPositions(List<Position> positions) throws BadLocationException {
if (!fMarkTargets)
return;
@@ -138,11 +138,11 @@ final class LinkedPositionAnnotations extends AnnotationModel {
// Algorithm: toRemove contains all mappings at first, but all that are in
// positions get removed -> toRemove contains the difference set of previous - new
// toAdd are the new positions, which don't exist in previous = new - previous
- List toRemove= new ArrayList(fTargetAnnotations.values());
- Map toAdd= new HashMap();
+ List<Annotation> toRemove= new ArrayList<>(fTargetAnnotations.values());
+ Map<Annotation, Position> toAdd= new HashMap<>();
if (positions != null) {
- for (Iterator iter= positions.iterator(); iter.hasNext();) {
- Position p= (Position) iter.next();
+ for (Iterator<Position> iter= positions.iterator(); iter.hasNext();) {
+ Position p= iter.next();
if (fTargetAnnotations.containsKey(p)) {
toRemove.remove(fTargetAnnotations.get(p));
} else {
@@ -154,7 +154,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
}
fTargetAnnotations.values().removeAll(toRemove);
- replaceAnnotations((Annotation[]) toRemove.toArray(new Annotation[0]), toAdd, false);
+ replaceAnnotations(toRemove.toArray(new Annotation[0]), toAdd, false);
}
/**
@@ -175,14 +175,14 @@ final class LinkedPositionAnnotations extends AnnotationModel {
if (position != null)
linkedGroup= env.getGroupForPosition(position);
- List targets= new ArrayList();
+ List<Position> targets= new ArrayList<>();
targets.addAll(Arrays.asList(fTargets));
- List group;
+ List<Position> group;
if (linkedGroup != null)
- group= new ArrayList(Arrays.asList(linkedGroup.getPositions()));
+ group= new ArrayList<>(Arrays.asList(linkedGroup.getPositions()));
else
- group= new ArrayList();
+ group= new ArrayList<>();
if (position == null || !fDocument.equals(position.getDocument()))
// position is not valid if not in this document
@@ -225,8 +225,8 @@ final class LinkedPositionAnnotations extends AnnotationModel {
*
* @param list the list of positions to prune
*/
- private void prune(List list) {
- for (Iterator iter= list.iterator(); iter.hasNext();) {
+ private void prune(List<Position> list) {
+ for (Iterator<Position> iter= list.iterator(); iter.hasNext();) {
LinkedPosition pos= (LinkedPosition) iter.next();
if (!pos.getDocument().equals(fDocument))
iter.remove();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
index e45acee33..bfcdaea89 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,18 +36,10 @@ class TabStopIterator {
* Comparator for <code>LinkedPosition</code>s. If the sequence number of two positions is equal, the
* offset is used.
*/
- private static class SequenceComparator implements Comparator {
-
- /**
- * {@inheritDoc}
- *
- * <p><code>o1</code> and <code>o2</code> are required to be instances
- * of <code>LinkedPosition</code>.</p>
- */
+ private static class SequenceComparator implements Comparator<LinkedPosition> {
+
@Override
- public int compare(Object o1, Object o2) {
- LinkedPosition p1= (LinkedPosition)o1;
- LinkedPosition p2= (LinkedPosition)o2;
+ public int compare(LinkedPosition p1, LinkedPosition p2) {
int i= p1.getSequenceNumber() - p2.getSequenceNumber();
if (i != 0)
return i;
@@ -57,10 +49,10 @@ class TabStopIterator {
}
/** The comparator to sort the list of positions. */
- private static final Comparator fComparator= new SequenceComparator();
+ private static final Comparator<LinkedPosition> fComparator= new SequenceComparator();
/** The iteration sequence. */
- private final ArrayList fList;
+ private final ArrayList<LinkedPosition> fList;
/** The size of <code>fList</code>. */
private int fSize;
/** Index of the current element, to the first one initially. */
@@ -68,9 +60,9 @@ class TabStopIterator {
/** Cycling property. */
private boolean fIsCycling= false;
- TabStopIterator(List positionSequence) {
+ TabStopIterator(List<LinkedPosition> positionSequence) {
Assert.isNotNull(positionSequence);
- fList= new ArrayList(positionSequence);
+ fList= new ArrayList<>(positionSequence);
Collections.sort(fList, fComparator);
fSize= fList.size();
fIndex= -1;
@@ -113,8 +105,8 @@ class TabStopIterator {
// find the position that follows closest to the current position
LinkedPosition found= null;
- for (Iterator it= fList.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
+ for (Iterator<LinkedPosition> it= fList.iterator(); it.hasNext(); ) {
+ LinkedPosition p= it.next();
if (p.offset > current.offset)
if (found == null || found.offset > p.offset)
found= p;
@@ -163,8 +155,8 @@ class TabStopIterator {
// find the position that follows closest to the current position
LinkedPosition found= null;
- for (Iterator it= fList.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
+ for (Iterator<LinkedPosition> it= fList.iterator(); it.hasNext(); ) {
+ LinkedPosition p= it.next();
if (p.offset < current.offset)
if (found == null || found.offset < p.offset)
found= p;
@@ -180,20 +172,20 @@ class TabStopIterator {
LinkedPosition next(LinkedPosition current) {
if (!hasNext(current))
throw new NoSuchElementException();
- return (LinkedPosition) fList.get(fIndex= getNextIndex(current));
+ return fList.get(fIndex= getNextIndex(current));
}
LinkedPosition previous(LinkedPosition current) {
if (!hasPrevious(current))
throw new NoSuchElementException();
- return (LinkedPosition) fList.get(fIndex= getPreviousIndex(current));
+ return fList.get(fIndex= getPreviousIndex(current));
}
void setCycling(boolean mode) {
fIsCycling= mode;
}
- void addPosition(Position position) {
+ void addPosition(LinkedPosition position) {
fList.add(fSize++, position);
Collections.sort(fList, fComparator);
}
@@ -211,6 +203,6 @@ class TabStopIterator {
}
LinkedPosition[] getPositions() {
- return (LinkedPosition[]) fList.toArray(new LinkedPosition[fSize]);
+ return fList.toArray(new LinkedPosition[fSize]);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
index d53044645..5fe6030a5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
@@ -240,9 +240,9 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
}
/** The map of presentation damagers. */
- private Map fDamagers;
+ private Map<String, IPresentationDamager> fDamagers;
/** The map of presentation repairers. */
- private Map fRepairers;
+ private Map<String, IPresentationRepairer> fRepairers;
/** The target viewer. */
private ITextViewer fViewer;
/** The internal listener. */
@@ -308,7 +308,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
Assert.isNotNull(contentType);
if (fDamagers == null)
- fDamagers= new HashMap();
+ fDamagers= new HashMap<>();
if (damager == null)
fDamagers.remove(contentType);
@@ -329,7 +329,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
Assert.isNotNull(contentType);
if (fRepairers == null)
- fRepairers= new HashMap();
+ fRepairers= new HashMap<>();
if (repairer == null)
fRepairers.remove(contentType);
@@ -363,7 +363,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
if (fDamagers == null)
return null;
- return (IPresentationDamager) fDamagers.get(contentType);
+ return fDamagers.get(contentType);
}
@Override
@@ -372,7 +372,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
if (fRepairers == null)
return null;
- return (IPresentationRepairer) fRepairers.get(contentType);
+ return fRepairers.get(contentType);
}
/**
@@ -382,9 +382,9 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
*/
protected void setDocumentToDamagers(IDocument document) {
if (fDamagers != null) {
- Iterator e= fDamagers.values().iterator();
+ Iterator<IPresentationDamager> e= fDamagers.values().iterator();
while (e.hasNext()) {
- IPresentationDamager damager= (IPresentationDamager) e.next();
+ IPresentationDamager damager= e.next();
damager.setDocument(document);
}
}
@@ -397,9 +397,9 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
*/
protected void setDocumentToRepairers(IDocument document) {
if (fRepairers != null) {
- Iterator e= fRepairers.values().iterator();
+ Iterator<IPresentationRepairer> e= fRepairers.values().iterator();
while (e.hasNext()) {
- IPresentationRepairer repairer= (IPresentationRepairer) e.next();
+ IPresentationRepairer repairer= e.next();
repairer.setDocument(document);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
index 111607fd6..8e1fec145 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
@@ -132,9 +132,9 @@ public abstract class AbstractReconcileStep implements IReconcileStep {
return results1;
// XXX: not yet performance optimized
- Collection collection= new ArrayList(Arrays.asList(results1));
+ Collection<IReconcileResult> collection= new ArrayList<>(Arrays.asList(results1));
collection.addAll(Arrays.asList(results2));
- return (IReconcileResult[])collection.toArray(new IReconcileResult[collection.size()]);
+ return collection.toArray(new IReconcileResult[collection.size()]);
}
/*
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
index bd0ff4098..abce51645 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
@@ -25,7 +25,7 @@ import java.util.List;
class DirtyRegionQueue {
/** The list of dirty regions. */
- private List fDirtyRegions= new ArrayList();
+ private List<DirtyRegion> fDirtyRegions= new ArrayList<>();
/**
* Creates a new empty dirty region.
@@ -70,7 +70,7 @@ class DirtyRegionQueue {
*/
private DirtyRegion getLastDirtyRegion() {
int size= fDirtyRegions.size();
- return (size == 0 ? null : (DirtyRegion) fDirtyRegions.get(size - 1));
+ return (size == 0 ? null : fDirtyRegions.get(size - 1));
}
/**
@@ -97,7 +97,7 @@ class DirtyRegionQueue {
public DirtyRegion removeNextDirtyRegion() {
if (fDirtyRegions.size() == 0)
return null;
- DirtyRegion dr= (DirtyRegion) fDirtyRegions.get(0);
+ DirtyRegion dr= fDirtyRegions.get(0);
fDirtyRegions.remove(0);
return dr;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
index 4ff26dd22..39ba8881c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
@@ -44,7 +44,7 @@ import org.eclipse.jface.text.TypedRegion;
public class Reconciler extends AbstractReconciler implements IReconcilerExtension {
/** The map of reconciling strategies. */
- private Map fStrategies;
+ private Map<String, IReconcilingStrategy> fStrategies;
/**
* The partitioning this reconciler uses.
@@ -92,7 +92,7 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
Assert.isNotNull(contentType);
if (fStrategies == null)
- fStrategies= new HashMap();
+ fStrategies= new HashMap<>();
if (strategy == null)
fStrategies.remove(contentType);
@@ -113,7 +113,7 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
if (fStrategies == null)
return null;
- return (IReconcilingStrategy) fStrategies.get(contentType);
+ return fStrategies.get(contentType);
}
/**
@@ -151,9 +151,9 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
@Override
protected void reconcilerDocumentChanged(IDocument document) {
if (fStrategies != null) {
- Iterator e= fStrategies.values().iterator();
+ Iterator<IReconcilingStrategy> e= fStrategies.values().iterator();
while (e.hasNext()) {
- IReconcilingStrategy strategy= (IReconcilingStrategy) e.next();
+ IReconcilingStrategy strategy= e.next();
strategy.setDocument(document);
}
}
@@ -164,9 +164,9 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
super.setProgressMonitor(monitor);
if (fStrategies != null) {
- Iterator e= fStrategies.values().iterator();
+ Iterator<IReconcilingStrategy> e= fStrategies.values().iterator();
while (e.hasNext()) {
- IReconcilingStrategy strategy= (IReconcilingStrategy) e.next();
+ IReconcilingStrategy strategy= e.next();
if (strategy instanceof IReconcilingStrategyExtension) {
IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) strategy;
extension.setProgressMonitor(monitor);
@@ -178,7 +178,7 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
@Override
protected void initialProcess() {
ITypedRegion[] regions= computePartitioning(0, getDocument().getLength());
- List contentTypes= new ArrayList(regions.length);
+ List<String> contentTypes= new ArrayList<>(regions.length);
for (int i= 0; i < regions.length; i++) {
String contentType= regions[i].getType();
if( contentTypes.contains(contentType))
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java
index 9765150f9..9a69d5264 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,6 +20,7 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.jface.internal.text.revisions.ChangeRegion;
import org.eclipse.jface.internal.text.revisions.Hunk;
+import org.eclipse.jface.internal.text.revisions.Range;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.source.ILineRange;
@@ -33,15 +34,15 @@ import org.eclipse.jface.text.source.ILineRange;
* @since 3.2
*/
public abstract class Revision {
- /** The original list of change regions, element type: {@link ChangeRegion}. */
- private final List fChangeRegions= new ArrayList();
+ /** The original list of change regions. */
+ private final List<ChangeRegion> fChangeRegions= new ArrayList<>();
/**
- * The cached list of adjusted ranges, element type: {@link RevisionRange}. <code>null</code>
+ * The cached list of adjusted ranges. <code>null</code>
* if the list must be re-computed. Unmodifiable.
*
* @since 3.3
*/
- private List fRanges= null;
+ private List<RevisionRange> fRanges= null;
/**
* Creates a new revision.
@@ -65,15 +66,15 @@ public abstract class Revision {
* information is only valid at the moment it is returned, and may change as the annotated
* document is modified.
*
- * @return an unmodifiable view of the contained ranges (element type: {@link RevisionRange})
+ * @return an unmodifiable view of the contained ranges
*/
- public final List getRegions() {
+ public final List<RevisionRange> getRegions() {
if (fRanges == null) {
- List ranges= new ArrayList(fChangeRegions.size());
- for (Iterator it= fChangeRegions.iterator(); it.hasNext();) {
- ChangeRegion region= (ChangeRegion) it.next();
- for (Iterator inner= region.getAdjustedRanges().iterator(); inner.hasNext();) {
- ILineRange range= (ILineRange) inner.next();
+ List<RevisionRange> ranges= new ArrayList<>(fChangeRegions.size());
+ for (Iterator<ChangeRegion> it= fChangeRegions.iterator(); it.hasNext();) {
+ ChangeRegion region= it.next();
+ for (Iterator<Range> inner= region.getAdjustedRanges().iterator(); inner.hasNext();) {
+ ILineRange range= inner.next();
ranges.add(new RevisionRange(this, range));
}
}
@@ -91,8 +92,8 @@ public abstract class Revision {
*/
final void applyDiff(Hunk[] hunks) {
fRanges= null; // mark for recomputation
- for (Iterator regions= fChangeRegions.iterator(); regions.hasNext();) {
- ChangeRegion region= (ChangeRegion) regions.next();
+ for (Iterator<ChangeRegion> regions= fChangeRegions.iterator(); regions.hasNext();) {
+ ChangeRegion region= regions.next();
region.clearDiff();
for (int i= 0; i < hunks.length; i++) {
Hunk hunk= hunks[i];
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java
index 42f04a2be..aaf5656c6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,7 +12,6 @@ package org.eclipse.jface.text.revisions;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@@ -34,17 +33,17 @@ import org.eclipse.jface.text.information.IInformationProviderExtension2;
* @see Revision
*/
public final class RevisionInformation implements ITextHoverExtension, IInformationProviderExtension2 {
- /** The revisions, element type: {@link Revision}. */
- private final List fRevisions= new ArrayList();
+ /** The revisions. */
+ private final List<Revision> fRevisions= new ArrayList<>();
/** A unmodifiable view of <code>fRevisions</code>. */
- private final List fRORevisions= Collections.unmodifiableList(fRevisions);
+ private final List<Revision> fRORevisions= Collections.unmodifiableList(fRevisions);
/**
* The flattened list of {@link RevisionRange}s, unmodifiable. <code>null</code> if the list
* must be re-computed.
*
* @since 3.3
*/
- private List fRanges= null;
+ private List<RevisionRange> fRanges= null;
/**
* The hover control creator. Can be <code>null</code>.
@@ -79,9 +78,9 @@ public final class RevisionInformation implements ITextHoverExtension, IInformat
/**
* Returns the contained revisions.
*
- * @return an unmodifiable view of the contained revisions (element type: {@link Revision})
+ * @return an unmodifiable view of the contained revisions
*/
- public List getRevisions() {
+ public List<Revision> getRevisions() {
return fRORevisions;
}
@@ -91,28 +90,20 @@ public final class RevisionInformation implements ITextHoverExtension, IInformat
* {@link IRevisionListener} for a way to be informed when the revision information changes. The
* returned list is sorted by document offset.
*
- * @return an unmodifiable view of the line ranges (element type: {@link RevisionRange})
+ * @return an unmodifiable view of the line ranges
* @see IRevisionListener
* @since 3.3
*/
- public List getRanges() {
+ public List<RevisionRange> getRanges() {
if (fRanges == null) {
- List ranges= new ArrayList(fRevisions.size() * 2); // wild size guess
- for (Iterator it= fRevisions.iterator(); it.hasNext();) {
- Revision revision= (Revision) it.next();
+ List<RevisionRange> ranges= new ArrayList<>(fRevisions.size() * 2); // wild size guess
+ for (Iterator<Revision> it= fRevisions.iterator(); it.hasNext();) {
+ Revision revision= it.next();
ranges.addAll(revision.getRegions());
}
// sort by start line
- Collections.sort(ranges, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- RevisionRange r1= (RevisionRange) o1;
- RevisionRange r2= (RevisionRange) o2;
-
- return r1.getStartLine() - r2.getStartLine();
- }
- });
+ Collections.sort(ranges, (r1, r2) -> r1.getStartLine() - r2.getStartLine());
fRanges= Collections.unmodifiableList(ranges);
}
@@ -130,8 +121,8 @@ public final class RevisionInformation implements ITextHoverExtension, IInformat
*/
public void applyDiff(Hunk[] hunks) {
fRanges= null; // mark for recomputation
- for (Iterator revisions= getRevisions().iterator(); revisions.hasNext();)
- ((Revision) revisions.next()).applyDiff(hunks);
+ for (Iterator<Revision> revisions= getRevisions().iterator(); revisions.hasNext();)
+ revisions.next().applyDiff(hunks);
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
index 210e6bacd..7c8cdb1e2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
@@ -537,7 +537,7 @@ public class DefaultPartitioner implements IDocumentPartitioner, IDocumentPartit
@Override
public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) {
checkInitialization();
- List list= new ArrayList();
+ List<TypedRegion> list= new ArrayList<>();
try {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
index cb2937ec8..63e5251ec 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
@@ -613,7 +613,7 @@ public class FastPartitioner implements IDocumentPartitioner, IDocumentPartition
@Override
public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) {
checkInitialization();
- List list= new ArrayList();
+ List<TypedRegion> list= new ArrayList<>();
try {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
index bb9ffa870..4f8cf9412 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,10 +33,10 @@ public class PatternRule implements IPredicateRule {
*
* @since 3.1
*/
- private static class DecreasingCharArrayLengthComparator implements Comparator {
+ private static class DecreasingCharArrayLengthComparator implements Comparator<char[]> {
@Override
- public int compare(Object o1, Object o2) {
- return ((char[]) o2).length - ((char[]) o1).length;
+ public int compare(char[] o1, char[] o2) {
+ return o2.length - o1.length;
}
}
@@ -67,7 +67,7 @@ public class PatternRule implements IPredicateRule {
* Line delimiter comparator which orders according to decreasing delimiter length.
* @since 3.1
*/
- private Comparator fLineDelimiterComparator= new DecreasingCharArrayLengthComparator();
+ private Comparator<char[]> fLineDelimiterComparator= new DecreasingCharArrayLengthComparator();
/**
* Cached line delimiters.
* @since 3.1
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
index e6150e68f..2d0303f36 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
@@ -528,7 +528,7 @@ public class RuleBasedPartitioner implements IDocumentPartitioner, IDocumentPart
@Override
public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) {
- List list= new ArrayList();
+ List<TypedRegion> list= new ArrayList<>();
try {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
index 12ec542a5..d091e18d6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
@@ -37,7 +37,7 @@ public class WordRule implements IRule {
/** The column constraint. */
protected int fColumn= UNDEFINED;
/** The table of predefined words and token for this rule. */
- protected Map fWords= new HashMap();
+ protected Map<String, IToken> fWords= new HashMap<>();
/** Buffer used for pattern detection. */
private StringBuffer fBuffer= new StringBuffer();
/**
@@ -143,7 +143,7 @@ public class WordRule implements IRule {
if (fIgnoreCase)
buffer= buffer.toLowerCase();
- IToken token= (IToken)fWords.get(buffer);
+ IToken token= fWords.get(buffer);
if (token != null)
return token;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
index 760b2b6ed..3b96efa60 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -540,7 +540,7 @@ public class AnnotationBarHoverManager extends AbstractHoverInformationControlMa
if (fVerticalRulerInfo instanceof CompositeRuler) {
CompositeRuler comp= (CompositeRuler) fVerticalRulerInfo;
- for (Iterator it= comp.getDecoratorIterator(); it.hasNext();) {
+ for (Iterator<IVerticalRulerColumn> it= comp.getDecoratorIterator(); it.hasNext();) {
Object o= it.next();
if (o instanceof IVerticalRulerInfoExtension && o instanceof IVerticalRulerInfo) {
if (((IVerticalRulerInfo) o).getControl() == event.getSource()) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
index b1361603e..ef1addf19 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,8 +18,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.swt.SWT;
@@ -355,12 +355,12 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* The map with decorations
* @since 3.0
*/
- private Map fDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
+ private Map<Annotation, Decoration> fDecorationsMap= new HashMap<>(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
/**
* The map with of highlighted decorations.
* @since 3.0
*/
- private Map fHighlightedDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
+ private Map<Annotation, Decoration> fHighlightedDecorationsMap= new HashMap<>(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
/**
* Mutex for highlighted decorations map.
* @since 3.0
@@ -376,13 +376,13 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
*
* @see #setAnnotationTypeColor(Object, Color)
*/
- private Map fAnnotationType2Color= new HashMap();
+ private Map<Object, Color> fAnnotationType2Color= new HashMap<>();
/**
* Cache that maps the annotation type to its color.
* @since 3.4
*/
- private Map fCachedAnnotationType2Color= new HashMap();
+ private Map<Object, Color> fCachedAnnotationType2Color= new HashMap<>();
/**
* The range in which the current highlight annotations can be found.
* @since 3.0
@@ -421,19 +421,19 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* @see #addAnnotationType(Object, Object)
* @since 3.0
*/
- private Map fAnnotationType2PaintingStrategyId= new HashMap();
+ private Map<Object, Object> fAnnotationType2PaintingStrategyId= new HashMap<>();
/**
* Maps annotation types to painting strategy identifiers.
* @since 3.4
*/
- private Map fCachedAnnotationType2PaintingStrategy= new HashMap();
+ private Map<String, Object> fCachedAnnotationType2PaintingStrategy= new HashMap<>();
/**
* Maps painting strategy identifiers to painting strategies.
*
* @since 3.0
*/
- private Map fPaintingStrategyId2PaintingStrategy= new HashMap();
+ private Map<Object, Object> fPaintingStrategyId2PaintingStrategy= new HashMap<>();
/**
* Reuse this region for performance reasons.
@@ -552,31 +552,31 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
int drawRangeStart= Integer.MAX_VALUE;
int drawRangeEnd= -1;
- Map decorationsMap;
- Map highlightedDecorationsMap;
+ Map<Annotation, Decoration> decorationsMap;
+ Map<Annotation, Decoration> highlightedDecorationsMap;
// Clone decoration maps
synchronized (fDecorationMapLock) {
- decorationsMap= new HashMap(fDecorationsMap);
+ decorationsMap= new HashMap<>(fDecorationsMap);
}
synchronized (fHighlightedDecorationsMapLock) {
- highlightedDecorationsMap= new HashMap(fHighlightedDecorationsMap);
+ highlightedDecorationsMap= new HashMap<>(fHighlightedDecorationsMap);
}
boolean isWorldChange= false;
- Iterator e;
+ Iterator<Annotation> e;
if (event == null || event.isWorldChange()) {
isWorldChange= true;
if (DEBUG && event == null)
System.out.println("AP: INTERNAL CHANGE"); //$NON-NLS-1$
- Iterator iter= decorationsMap.entrySet().iterator();
+ Iterator<Entry<Annotation, Decoration>> iter= decorationsMap.entrySet().iterator();
while (iter.hasNext()) {
- Map.Entry entry= (Map.Entry)iter.next();
- Annotation annotation= (Annotation)entry.getKey();
- Decoration decoration= (Decoration)entry.getValue();
+ Entry<Annotation, Decoration> entry= iter.next();
+ Annotation annotation= entry.getKey();
+ Decoration decoration= entry.getValue();
drawDecoration(decoration, null, annotation, clippingRegion, document);
}
@@ -593,7 +593,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
Annotation[] removedAnnotations= event.getRemovedAnnotations();
for (int i= 0, length= removedAnnotations.length; i < length; i++) {
Annotation annotation= removedAnnotations[i];
- Decoration decoration= (Decoration)highlightedDecorationsMap.remove(annotation);
+ Decoration decoration= highlightedDecorationsMap.remove(annotation);
if (decoration != null) {
Position position= decoration.fPosition;
if (position != null) {
@@ -601,7 +601,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, position.offset + position.length);
}
}
- decoration= (Decoration)decorationsMap.remove(annotation);
+ decoration= decorationsMap.remove(annotation);
if (decoration != null) {
drawDecoration(decoration, null, annotation, clippingRegion, document);
Position position= decoration.fPosition;
@@ -620,14 +620,14 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
boolean isHighlighting= false;
- Decoration decoration= (Decoration)highlightedDecorationsMap.get(annotation);
+ Decoration decoration= highlightedDecorationsMap.get(annotation);
if (decoration != null) {
isHighlighting= true;
// The call below updates the decoration - no need to create new decoration
decoration= getDecoration(annotation, decoration);
if (decoration == null) {
- Decoration removedDecoration= (Decoration)highlightedDecorationsMap.remove(annotation);
+ Decoration removedDecoration= highlightedDecorationsMap.remove(annotation);
if (removedDecoration != null) {
highlightAnnotationRangeStart= Math.min(highlightAnnotationRangeStart, removedDecoration.fPosition.offset);
highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, removedDecoration.fPosition.offset + removedDecoration.fPosition.length);
@@ -660,7 +660,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
drawRangeEnd= Math.max(drawRangeEnd, position.offset + position.length);
}
} else {
- Decoration removedDecoration= (Decoration)highlightedDecorationsMap.remove(annotation);
+ Decoration removedDecoration= highlightedDecorationsMap.remove(annotation);
if (removedDecoration != null) {
highlightAnnotationRangeStart= Math.min(highlightAnnotationRangeStart, removedDecoration.fPosition.offset);
highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, removedDecoration.fPosition.offset + removedDecoration.fPosition.length);
@@ -668,7 +668,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
}
if (usesDrawingStrategy) {
- Decoration oldDecoration= (Decoration)decorationsMap.get(annotation);
+ Decoration oldDecoration= decorationsMap.get(annotation);
if (oldDecoration != null) {
drawDecoration(oldDecoration, null, annotation, clippingRegion, document);
if (decoration != null)
@@ -684,7 +684,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
// Add new annotations
while (e.hasNext()) {
- Annotation annotation= (Annotation)e.next();
+ Annotation annotation= e.next();
Decoration pp= getDecoration(annotation, null);
if (pp != null) {
if (pp.fPaintingStrategy instanceof IDrawingStrategy) {
@@ -910,11 +910,11 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* @since 3.0
*/
private Color getColor(final Object annotationType) {
- Color color= (Color)fCachedAnnotationType2Color.get(annotationType);
+ Color color= fCachedAnnotationType2Color.get(annotationType);
if (color != null)
return color;
- color= (Color)fAnnotationType2Color.get(annotationType);
+ color= fAnnotationType2Color.get(annotationType);
if (color != null) {
fCachedAnnotationType2Color.put(annotationType, color);
return color;
@@ -925,7 +925,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
Object[] superTypes= extension.getSupertypes(annotationType);
if (superTypes != null) {
for (int i= 0; i < superTypes.length; i++) {
- color= (Color)fAnnotationType2Color.get(superTypes[i]);
+ color= fAnnotationType2Color.get(superTypes[i]);
if (color != null) {
fCachedAnnotationType2Color.put(annotationType, color);
return color;
@@ -976,13 +976,13 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
@Override
public void applyTextPresentation(TextPresentation tp) {
- Set decorations;
+ Set<Entry<Annotation, Decoration>> decorations;
synchronized (fHighlightedDecorationsMapLock) {
if (fHighlightedDecorationsMap == null || fHighlightedDecorationsMap.isEmpty())
return;
- decorations= new HashSet(fHighlightedDecorationsMap.entrySet());
+ decorations= new HashSet<>(fHighlightedDecorationsMap.entrySet());
}
IRegion region= tp.getExtent();
@@ -992,14 +992,14 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
for (int layer= 0, maxLayer= 1; layer < maxLayer; layer++) {
- for (Iterator iter= decorations.iterator(); iter.hasNext();) {
- Map.Entry entry= (Map.Entry)iter.next();
+ for (Iterator<Entry<Annotation, Decoration>> iter= decorations.iterator(); iter.hasNext();) {
+ Entry<Annotation, Decoration> entry= iter.next();
- Annotation a= (Annotation)entry.getKey();
+ Annotation a= entry.getKey();
if (a.isMarkedDeleted())
continue;
- Decoration pp = (Decoration)entry.getValue();
+ Decoration pp = entry.getValue();
maxLayer= Math.max(maxLayer, pp.fLayer + 1); // dynamically update layer maximum
if (pp.fLayer != layer) // wrong layer: skip annotation
@@ -1362,9 +1362,9 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
final GC gc= event != null ? event.gc : null;
// Clone decorations
- Collection decorations;
+ Collection<Entry<Annotation, Decoration>> decorations;
synchronized (fDecorationMapLock) {
- decorations= new ArrayList(fDecorationsMap.size());
+ decorations= new ArrayList<>(fDecorationsMap.size());
decorations.addAll(fDecorationsMap.entrySet());
}
@@ -1372,27 +1372,27 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* Create a new list of annotations to be drawn, since removing from decorations is more
* expensive. One bucket per drawing layer. Use linked lists as addition is cheap here.
*/
- ArrayList toBeDrawn= new ArrayList(10);
- for (Iterator e = decorations.iterator(); e.hasNext();) {
- Map.Entry entry= (Map.Entry)e.next();
+ ArrayList<LinkedList<Entry<Annotation, Decoration>>> toBeDrawn= new ArrayList<>(10);
+ for (Iterator<Entry<Annotation, Decoration>> e = decorations.iterator(); e.hasNext();) {
+ Entry<Annotation, Decoration> entry= e.next();
- Annotation a= (Annotation)entry.getKey();
- Decoration pp = (Decoration)entry.getValue();
+ Annotation a= entry.getKey();
+ Decoration pp = entry.getValue();
// prune any annotation that is not drawable or does not need drawing
if (!(a.isMarkedDeleted() || skip(a) || !regionsTouchOrOverlap(pp.fPosition.getOffset(), pp.fPosition.getLength(), vOffset, vLength))) {
// ensure sized appropriately
for (int i= toBeDrawn.size(); i <= pp.fLayer; i++)
- toBeDrawn.add(new LinkedList());
- ((List) toBeDrawn.get(pp.fLayer)).add(entry);
+ toBeDrawn.add(new LinkedList<>());
+ toBeDrawn.get(pp.fLayer).add(entry);
}
}
IDocument document= fSourceViewer.getDocument();
- for (Iterator it= toBeDrawn.iterator(); it.hasNext();) {
- List layer= (List) it.next();
- for (Iterator e = layer.iterator(); e.hasNext();) {
- Map.Entry entry= (Map.Entry)e.next();
- Annotation a= (Annotation)entry.getKey();
- Decoration pp = (Decoration)entry.getValue();
+ for (Iterator<LinkedList<Entry<Annotation, Decoration>>> it= toBeDrawn.iterator(); it.hasNext();) {
+ LinkedList<Entry<Annotation, Decoration>> layer= it.next();
+ for (Iterator<Entry<Annotation, Decoration>> e = layer.iterator(); e.hasNext();) {
+ Entry<Annotation, Decoration> entry= e.next();
+ Annotation a= entry.getKey();
+ Decoration pp = entry.getValue();
drawDecoration(pp, gc, a, clippingRegion, document);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
index 3673751fa..0e3472bed 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
@@ -115,11 +115,11 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
* Comparator for <code>Tuple</code>s.
* @since 3.0
*/
- private static class TupleComparator implements Comparator {
+ private static class TupleComparator implements Comparator<Tuple> {
@Override
- public int compare(Object o1, Object o2) {
- Position p1= ((Tuple) o1).position;
- Position p2= ((Tuple) o2).position;
+ public int compare(Tuple o1, Tuple o2) {
+ Position p1= o1.position;
+ Position p2= o2.position;
return p1.getOffset() - p2.getOffset();
}
}
@@ -148,14 +148,14 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
* The list of annotation types to be shown in this ruler.
* @since 3.0
*/
- private Set fConfiguredAnnotationTypes= new HashSet();
+ private Set<Object> fConfiguredAnnotationTypes= new HashSet<>();
/**
* The list of allowed annotation types to be shown in this ruler.
* An allowed annotation type maps to <code>true</code>, a disallowed
* to <code>false</code>.
* @since 3.0
*/
- private Map fAllowedAnnotationTypes= new HashMap();
+ private Map<Object, Boolean> fAllowedAnnotationTypes= new HashMap<>();
/**
* The annotation access extension.
* @since 3.0
@@ -170,12 +170,12 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
* The cached annotations.
* @since 3.0
*/
- private List fCachedAnnotations= new ArrayList();
+ private List<Tuple> fCachedAnnotations= new ArrayList<>();
/**
* The comparator for sorting annotations according to the offset of their position.
* @since 3.0
*/
- private Comparator fTupleComparator= new TupleComparator();
+ private Comparator<Tuple> fTupleComparator= new TupleComparator();
/**
* The hit detection cursor. Do not dispose.
* @since 3.0
@@ -474,14 +474,14 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
int lineStart= line.getOffset();
int lineLength= line.getLength();
- Iterator e;
+ Iterator<Annotation> e;
if (fModel instanceof IAnnotationModelExtension2)
e= ((IAnnotationModelExtension2)fModel).getAnnotationIterator(lineStart, lineLength + 1, true, true);
else
e= model.getAnnotationIterator();
while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
if (a.isMarkedDeleted())
continue;
@@ -646,14 +646,14 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
int maxLayer= 1; // loop at least once through layers.
for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter;
+ Iterator<Annotation> iter;
if (fModel instanceof IAnnotationModelExtension2)
iter= ((IAnnotationModelExtension2)fModel).getAnnotationIterator(topLeft, viewPort + 1, true, true);
else
iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
if (fAnnotationAccessExtension != null)
@@ -736,14 +736,14 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
int minLayer= Integer.MAX_VALUE, maxLayer= Integer.MIN_VALUE;
fCachedAnnotations.clear();
- Iterator iter;
+ Iterator<Annotation> iter;
if (fModel instanceof IAnnotationModelExtension2)
iter= ((IAnnotationModelExtension2)fModel).getAnnotationIterator(vOffset, vLength + 1, true, true);
else
iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
if (skip(annotation))
continue;
@@ -769,7 +769,7 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
for (int layer= minLayer; layer <= maxLayer; layer++) {
for (int i= 0, n= fCachedAnnotations.size(); i < n; i++) {
- Tuple tuple= (Tuple) fCachedAnnotations.get(i);
+ Tuple tuple= fCachedAnnotations.get(i);
Annotation annotation= tuple.annotation;
Position position= tuple.position;
@@ -924,7 +924,7 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
*/
private boolean skip(Annotation annotation) {
Object annotationType= annotation.getType();
- Boolean allowed= (Boolean) fAllowedAnnotationTypes.get(annotationType);
+ Boolean allowed= fAllowedAnnotationTypes.get(annotationType);
if (allowed != null)
return !allowed.booleanValue();
@@ -944,7 +944,7 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
*/
private boolean skip(Object annotationType) {
if (fAnnotationAccessExtension != null) {
- Iterator e= fConfiguredAnnotationTypes.iterator();
+ Iterator<Object> e= fConfiguredAnnotationTypes.iterator();
while (e.hasNext()) {
if (fAnnotationAccessExtension.isSubtype(annotationType, e.next()))
return false;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
index fca69ff52..4b62c5870 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -102,9 +102,9 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
int rulerHeight= clArea.height;
int x= 0;
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
int columnWidth= column.getWidth();
column.getControl().setBounds(x, 0, columnWidth, rulerHeight);
x += (columnWidth + fGap);
@@ -122,12 +122,12 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* Keeps the information for which event type a listener object has been added.
*/
static class ListenerInfo {
- Class fClass;
+ Class<? extends EventListener> fClass;
EventListener fListener;
}
/** The list of listeners added to this canvas. */
- private List fCachedListeners= new ArrayList();
+ private List<ListenerInfo> fCachedListeners= new ArrayList<>();
/**
* Internal listener for opening the context menu.
* @since 3.0
@@ -173,7 +173,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param control the control to add the listener to
* @param listener the listener to be added
*/
- private void addListener(Class clazz, Control control, EventListener listener) {
+ private void addListener(Class<? extends EventListener> clazz, Control control, EventListener listener) {
if (ControlListener.class.equals(clazz)) {
control. addControlListener((ControlListener) listener);
return;
@@ -228,7 +228,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param control the control to remove the listener from
* @param listener the listener to be removed
*/
- private void removeListener(Class clazz, Control control, EventListener listener) {
+ private void removeListener(Class<? extends EventListener> clazz, Control control, EventListener listener) {
if (ControlListener.class.equals(clazz)) {
control. removeControlListener((ControlListener) listener);
return;
@@ -278,7 +278,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param clazz the listener type
* @param listener the listener object
*/
- private void addListener(Class clazz, EventListener listener) {
+ private void addListener(Class<? extends EventListener> clazz, EventListener listener) {
Control[] children= getChildren();
for (int i= 0; i < children.length; i++) {
if (children[i] != null && !children[i].isDisposed())
@@ -298,7 +298,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param clazz the listener type
* @param listener the listener object
*/
- private void removeListener(Class clazz, EventListener listener) {
+ private void removeListener(Class<? extends EventListener> clazz, EventListener listener) {
// Keep as first statement to ensure checkWidget() is called.
Control[] children= getChildren();
@@ -307,7 +307,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
int length= fCachedListeners.size();
for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
+ ListenerInfo info= fCachedListeners.get(i);
if (listener == info.fListener && clazz.equals(info.fClass)) {
fCachedListeners.remove(i);
break;
@@ -329,7 +329,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
if (child != null && !child.isDisposed()) {
int length= fCachedListeners.size();
for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
+ ListenerInfo info= fCachedListeners.get(i);
addListener(info.fClass, child, info.fListener);
}
child.addListener(SWT.MenuDetect, fMenuDetectListener);
@@ -345,7 +345,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
if (child != null && !child.isDisposed()) {
int length= fCachedListeners.size();
for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
+ ListenerInfo info= fCachedListeners.get(i);
removeListener(info.fClass, child, info.fListener);
}
child.removeListener(SWT.MenuDetect, fMenuDetectListener);
@@ -498,7 +498,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
/** The ruler's annotation model */
private IAnnotationModel fModel;
/** The list of columns */
- private List fDecorators= new ArrayList(2);
+ private List<IVerticalRulerColumn> fDecorators= new ArrayList<>(2);
/** The cached location of the last mouse button activity */
private Point fLocation= new Point(-1, -1);
/** The cached line of the list mouse button activity */
@@ -509,7 +509,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* The set of annotation listeners.
* @since 3.0
*/
- private Set fAnnotationListeners= new HashSet();
+ private Set<IVerticalRulerListener> fAnnotationListeners= new HashSet<>();
/**
@@ -556,7 +556,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param index the index
*/
public void removeDecorator(int index) {
- IVerticalRulerColumn rulerColumn= (IVerticalRulerColumn) fDecorators.get(index);
+ IVerticalRulerColumn rulerColumn= fDecorators.get(index);
removeDecorator(rulerColumn);
}
@@ -608,9 +608,9 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
fComposite= new CompositeRulerCanvas(parent, SWT.NONE);
fComposite.setLayout(new RulerLayout());
- Iterator iter= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> iter= fDecorators.iterator();
while (iter.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) iter.next();
+ IVerticalRulerColumn column= iter.next();
column.createControl(this, fComposite);
fComposite.childAdded(column.getControl());
}
@@ -623,9 +623,9 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
fModel= model;
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
column.setModel(model);
}
}
@@ -656,18 +656,18 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @since 3.2
*/
public void immediateUpdate() {
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
column.redraw();
}
}
@Override
public void setFont(Font font) {
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
column.setFont(font);
}
}
@@ -675,9 +675,9 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
@Override
public int getWidth() {
int width= 0;
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
width += (column.getWidth() + fGap);
}
return Math.max(0, width - fGap);
@@ -757,7 +757,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @return an iterator over the contained columns.
* @since 3.0
*/
- public Iterator getDecoratorIterator() {
+ public Iterator<IVerticalRulerColumn> getDecoratorIterator() {
Assert.isNotNull(fDecorators, "fDecorators must be initialized"); //$NON-NLS-1$
return fDecorators.iterator();
}
@@ -787,8 +787,8 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationSelected(VerticalRulerEvent event) {
// forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= (IVerticalRulerListener) it.next();
+ for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
+ IVerticalRulerListener listener= it.next();
listener.annotationSelected(event);
}
}
@@ -803,8 +803,8 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationDefaultSelected(VerticalRulerEvent event) {
// forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= (IVerticalRulerListener) it.next();
+ for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
+ IVerticalRulerListener listener= it.next();
listener.annotationDefaultSelected(event);
}
}
@@ -820,8 +820,8 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) {
// forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= (IVerticalRulerListener) it.next();
+ for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
+ IVerticalRulerListener listener= it.next();
listener.annotationContextMenuAboutToShow(event, menu);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
index ade74e15b..9a83dd091 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -58,31 +58,31 @@ public class DefaultAnnotationHover implements IAnnotationHover {
@Override
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- List javaAnnotations= getAnnotationsForLine(sourceViewer, lineNumber);
+ List<Annotation> javaAnnotations= getAnnotationsForLine(sourceViewer, lineNumber);
if (javaAnnotations != null) {
if (javaAnnotations.size() == 1) {
// optimization
- Annotation annotation= (Annotation) javaAnnotations.get(0);
+ Annotation annotation= javaAnnotations.get(0);
String message= annotation.getText();
if (message != null && message.trim().length() > 0)
return formatSingleMessage(message);
} else {
- List messages= new ArrayList();
+ List<String> messages= new ArrayList<>();
- Iterator e= javaAnnotations.iterator();
+ Iterator<Annotation> e= javaAnnotations.iterator();
while (e.hasNext()) {
- Annotation annotation= (Annotation) e.next();
+ Annotation annotation= e.next();
String message= annotation.getText();
if (message != null && message.trim().length() > 0)
messages.add(message.trim());
}
if (messages.size() == 1)
- return formatSingleMessage((String)messages.get(0));
+ return formatSingleMessage(messages.get(0));
if (messages.size() > 1)
return formatMultipleMessages(messages);
@@ -127,17 +127,17 @@ public class DefaultAnnotationHover implements IAnnotationHover {
* format like HTML.
* </p>
*
- * @param messages the messages to format (element type: {@link String})
+ * @param messages the messages to format
* @return the formatted message
*/
- protected String formatMultipleMessages(List messages) {
+ protected String formatMultipleMessages(List<String> messages) {
StringBuffer buffer= new StringBuffer();
buffer.append(JFaceTextMessages.getString("DefaultAnnotationHover.multipleMarkers")); //$NON-NLS-1$
- Iterator e= messages.iterator();
+ Iterator<String> e= messages.iterator();
while (e.hasNext()) {
buffer.append('\n');
- String listItemText= (String) e.next();
+ String listItemText= e.next();
buffer.append(JFaceTextMessages.getFormattedString("DefaultAnnotationHover.listItem", new String[] { listItemText })); //$NON-NLS-1$
}
return buffer.toString();
@@ -161,20 +161,21 @@ public class DefaultAnnotationHover implements IAnnotationHover {
return viewer.getAnnotationModel();
}
- private boolean isDuplicateAnnotation(Map messagesAtPosition, Position position, String message) {
+ private boolean isDuplicateAnnotation(Map<Position, Object> messagesAtPosition, Position position, String message) {
if (messagesAtPosition.containsKey(position)) {
Object value= messagesAtPosition.get(position);
if (message.equals(value))
return true;
if (value instanceof List) {
- List messages= (List)value;
+ @SuppressWarnings("unchecked")
+ List<Object> messages= (List<Object>) value;
if (messages.contains(message))
return true;
messages.add(message);
} else {
- ArrayList messages= new ArrayList();
+ ArrayList<Object> messages= new ArrayList<>();
messages.add(value);
messages.add(message);
messagesAtPosition.put(position, messages);
@@ -184,7 +185,7 @@ public class DefaultAnnotationHover implements IAnnotationHover {
return false;
}
- private boolean includeAnnotation(Annotation annotation, Position position, HashMap messagesAtPosition) {
+ private boolean includeAnnotation(Annotation annotation, Position position, HashMap<Position, Object> messagesAtPosition) {
if (!isIncluded(annotation))
return false;
@@ -192,18 +193,18 @@ public class DefaultAnnotationHover implements IAnnotationHover {
return (text != null && !isDuplicateAnnotation(messagesAtPosition, position, text));
}
- private List getAnnotationsForLine(ISourceViewer viewer, int line) {
+ private List<Annotation> getAnnotationsForLine(ISourceViewer viewer, int line) {
IAnnotationModel model= getAnnotationModel(viewer);
if (model == null)
return null;
IDocument document= viewer.getDocument();
- List javaAnnotations= new ArrayList();
- HashMap messagesAtPosition= new HashMap();
- Iterator iterator= model.getAnnotationIterator();
+ List<Annotation> javaAnnotations= new ArrayList<>();
+ HashMap<Position, Object> messagesAtPosition= new HashMap<>();
+ Iterator<Annotation> iterator= model.getAnnotationIterator();
while (iterator.hasNext()) {
- Annotation annotation= (Annotation) iterator.next();
+ Annotation annotation= iterator.next();
Position position= model.getPosition(annotation);
if (position == null)
@@ -214,9 +215,9 @@ public class DefaultAnnotationHover implements IAnnotationHover {
if (annotation instanceof AnnotationBag) {
AnnotationBag bag= (AnnotationBag) annotation;
- Iterator e= bag.iterator();
+ Iterator<Annotation> e= bag.iterator();
while (e.hasNext()) {
- annotation= (Annotation) e.next();
+ annotation= e.next();
position= model.getPosition(annotation);
if (position != null && includeAnnotation(annotation, position, messagesAtPosition))
javaAnnotations.add(annotation);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
index 4b9df8724..73522d819 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -88,7 +88,7 @@ public class LineChangeHover implements IAnnotationHover, IAnnotationHoverExtens
if (differ == null)
return null;
- final List lines= new LinkedList();
+ final List<ILineDiffInfo> lines= new LinkedList<>();
for (int l= first; l <= last; l++) {
ILineDiffInfo info= differ.getLineInfo(l);
if (info != null)
@@ -110,15 +110,15 @@ public class LineChangeHover implements IAnnotationHover, IAnnotationHoverExtens
* more than that due to deleted lines.
* @return a <code>String</code> suitable for hover display
*/
- protected String decorateText(List diffInfos, int maxLines) {
+ protected String decorateText(List<? extends ILineDiffInfo> diffInfos, int maxLines) {
/* maxLines controls the size of the hover (not more than what fits into the display are of
* the viewer).
* added controls how many lines are added - added lines are
*/
String text= ""; //$NON-NLS-1$
int added= 0;
- for (Iterator it= diffInfos.iterator(); it.hasNext();) {
- ILineDiffInfo info= (ILineDiffInfo)it.next();
+ for (Iterator<? extends ILineDiffInfo> it= diffInfos.iterator(); it.hasNext();) {
+ ILineDiffInfo info= it.next();
String[] original= info.getOriginalText();
int type= info.getChangeType();
int i= 0;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
index 153fc7776..7f060da4b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
@@ -137,13 +137,13 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* Enumerates the annotations of a specified type and characteristics
* of the associated annotation model.
*/
- class FilterIterator implements Iterator {
+ class FilterIterator implements Iterator<Annotation> {
final static int TEMPORARY= 1 << 1;
final static int PERSISTENT= 1 << 2;
final static int IGNORE_BAGS= 1 << 3;
- private Iterator fIterator;
+ private Iterator<Annotation> fIterator;
private Object fType;
private Annotation fNext;
private int fStyle;
@@ -170,7 +170,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* @param style the style
* @param iterator the iterator
*/
- public FilterIterator(Object annotationType, int style, Iterator iterator) {
+ public FilterIterator(Object annotationType, int style, Iterator<Annotation> iterator) {
fType= annotationType;
fStyle= style;
fIterator= iterator;
@@ -184,7 +184,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
boolean ignr= (fStyle & IGNORE_BAGS) != 0;
while (fIterator.hasNext()) {
- Annotation next= (Annotation) fIterator.next();
+ Annotation next= fIterator.next();
if (next.isMarkedDeleted())
continue;
@@ -216,7 +216,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
return fNext != null;
}
@Override
- public Object next() {
+ public Annotation next() {
try {
return fNext;
} finally {
@@ -403,14 +403,14 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* The list of annotation types to be shown in this ruler.
* @since 3.0
*/
- private Set fConfiguredAnnotationTypes= new HashSet();
+ private Set<Object> fConfiguredAnnotationTypes= new HashSet<>();
/**
* The list of annotation types to be shown in the header of this ruler.
* @since 3.0
*/
- private Set fConfiguredHeaderAnnotationTypes= new HashSet();
+ private Set<Object> fConfiguredHeaderAnnotationTypes= new HashSet<>();
/** The mapping between annotation types and colors */
- private Map fAnnotationTypes2Colors= new HashMap();
+ private Map<Object, Color> fAnnotationTypes2Colors= new HashMap<>();
/** The color manager */
private ISharedTextColors fSharedTextColors;
/**
@@ -418,32 +418,32 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
*
* @since 3.0
*/
- private List fAnnotationsSortedByLayer= new ArrayList();
+ private List<Object> fAnnotationsSortedByLayer= new ArrayList<>();
/**
* All available layers sorted by layer.
* This list may contain duplicates.
* @since 3.0
*/
- private List fLayersSortedByLayer= new ArrayList();
+ private List<Integer> fLayersSortedByLayer= new ArrayList<>();
/**
* Map of allowed annotation types.
* An allowed annotation type maps to <code>true</code>, a disallowed
* to <code>false</code>.
* @since 3.0
*/
- private Map fAllowedAnnotationTypes= new HashMap();
+ private Map<Object, Boolean> fAllowedAnnotationTypes= new HashMap<>();
/**
* Map of allowed header annotation types.
* An allowed annotation type maps to <code>true</code>, a disallowed
* to <code>false</code>.
* @since 3.0
*/
- private Map fAllowedHeaderAnnotationTypes= new HashMap();
+ private Map<Object, Boolean> fAllowedHeaderAnnotationTypes= new HashMap<>();
/**
* The cached annotations.
* @since 3.0
*/
- private List fCachedAnnotations= new ArrayList();
+ private List<Annotation> fCachedAnnotations= new ArrayList<>();
/**
* Redraw runnable lock
@@ -695,9 +695,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
private void cacheAnnotations() {
fCachedAnnotations.clear();
if (fModel != null) {
- Iterator iter= fModel.getAnnotationIterator();
+ Iterator<Annotation> iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
if (annotation.isMarkedDeleted())
continue;
@@ -731,7 +731,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
WidgetInfos infos= null;
- for (Iterator iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
+ for (Iterator<Object> iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
Object annotationType= iterator.next();
if (skip(annotationType))
@@ -743,9 +743,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
Color fill= null;
Color stroke= null;
- Iterator e= new FilterIterator(annotationType, style[t], fCachedAnnotations.iterator());
+ Iterator<Annotation> e= new FilterIterator(annotationType, style[t], fCachedAnnotations.iterator());
while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
Position p= fModel.getPosition(a);
if (p == null)
@@ -1036,9 +1036,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
Object annotationType= fAnnotationsSortedByLayer.get(i);
- Iterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY);
+ Iterator<Annotation> e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY);
while (e.hasNext() && found == null) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
if (a.isMarkedDeleted())
continue;
@@ -1179,7 +1179,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
if (layer >= 0) {
int i= 0;
int size= fLayersSortedByLayer.size();
- while (i < size && layer >= ((Integer)fLayersSortedByLayer.get(i)).intValue())
+ while (i < size && layer >= fLayersSortedByLayer.get(i).intValue())
i++;
Integer layerObj= new Integer(layer);
fLayersSortedByLayer.add(i, layerObj);
@@ -1228,10 +1228,10 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* otherwise
* @since 3.0
*/
- private boolean contains(Object annotationType, Map allowed, Set configured) {
+ private boolean contains(Object annotationType, Map<Object, Boolean> allowed, Set<Object> configured) {
boolean covered;
synchronized (fRunnableLock){
- Boolean cached= (Boolean) allowed.get(annotationType);
+ Boolean cached= allowed.get(annotationType);
if (cached != null)
return cached.booleanValue();
@@ -1252,10 +1252,10 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* otherwise
* @since 3.0
*/
- private boolean isCovered(Object annotationType, Set configured) {
+ private boolean isCovered(Object annotationType, Set<Object> configured) {
if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- Iterator e= configured.iterator();
+ Iterator<Object> e= configured.iterator();
while (e.hasNext()) {
if (extension.isSubtype(annotationType,e.next()))
return true;
@@ -1337,7 +1337,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* @since 3.0
*/
private Color findColor(Object annotationType) {
- Color color= (Color) fAnnotationTypes2Colors.get(annotationType);
+ Color color= fAnnotationTypes2Colors.get(annotationType);
if (color != null)
return color;
@@ -1346,7 +1346,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
Object[] superTypes= extension.getSupertypes(annotationType);
if (superTypes != null) {
for (int i= 0; i < superTypes.length; i++) {
- color= (Color) fAnnotationTypes2Colors.get(superTypes[i]);
+ color= fAnnotationTypes2Colors.get(superTypes[i]);
if (color != null)
return color;
}
@@ -1451,7 +1451,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
if (skipInHeader(annotationType) || skip(annotationType))
continue;
- Iterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
+ Iterator<Annotation> e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
while (e.hasNext()) {
if (e.next() != null) {
colorType= annotationType;
@@ -1501,9 +1501,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
int count= 0;
String annotationTypeLabel= null;
- Iterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
+ Iterator<Annotation> e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
while (e.hasNext()) {
- Annotation annotation= (Annotation)e.next();
+ Annotation annotation= e.next();
if (annotation != null) {
if (annotationTypeLabel == null)
annotationTypeLabel= ((IAnnotationAccessExtension)fAnnotationAccess).getTypeLabel(annotation);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
index 29ed1c65b..f8448a7c3 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
@@ -295,7 +295,7 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
* Stack of saved selections in the underlying document
* @since 3.0
*/
- protected final Stack fSelections= new Stack();
+ protected final Stack<Position> fSelections= new Stack<>();
/**
* Position updater for saved selections
* @since 3.0
@@ -877,7 +877,7 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
if (!fSelections.isEmpty()) {
final IDocument document= getDocument();
- final Position position= (Position) fSelections.pop();
+ final Position position= fSelections.pop();
try {
document.removePosition(fSelectionCategory, position);
@@ -1148,7 +1148,7 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
return true;
if (fVerticalRuler instanceof CompositeRuler) {
- Iterator iter= ((CompositeRuler)fVerticalRuler).getDecoratorIterator();
+ Iterator<IVerticalRulerColumn> iter= ((CompositeRuler)fVerticalRuler).getDecoratorIterator();
return iter.hasNext() && iter.next() instanceof AnnotationRulerColumn && !iter.hasNext();
}
return false;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
index 005c8c21a..b710fafa6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -307,10 +307,10 @@ public final class VerticalRuler implements IVerticalRuler, IVerticalRulerExtens
int maxLayer= 1; // loop at least once though layers.
for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
+ Iterator<Annotation> iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
IAnnotationPresentation annotationPresentation= null;
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
if (annotationAccessExtension != null)
@@ -394,10 +394,10 @@ public final class VerticalRuler implements IVerticalRuler, IVerticalRulerExtens
int maxLayer= 1; // loop at least once through layers.
for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
+ Iterator<Annotation> iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
IAnnotationPresentation annotationPresentation= null;
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
if (annotationAccessExtension != null)
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java
index 8a2162025..cb8b9f68e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,7 +27,7 @@ import java.util.Map;
public class ContextTypeRegistry {
/** all known context types */
- private final Map fContextTypes= new LinkedHashMap();
+ private final Map<String, TemplateContextType> fContextTypes= new LinkedHashMap<>();
/**
* Adds a context type to the registry. If there already is a context type
@@ -46,15 +46,15 @@ public class ContextTypeRegistry {
* @return the context type if <code>name</code> is valid, <code>null</code> otherwise
*/
public TemplateContextType getContextType(String id) {
- return (TemplateContextType) fContextTypes.get(id);
+ return fContextTypes.get(id);
}
/**
* Returns an iterator over all registered context types.
*
- * @return an iterator over all registered context types (element type: {@link TemplateContextType})
+ * @return an iterator over all registered context types
*/
- public Iterator contextTypes() {
+ public Iterator<TemplateContextType> contextTypes() {
return fContextTypes.values().iterator();
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
index f3d6e7ae1..4fd70687c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -38,14 +38,16 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator;
*/
public abstract class TemplateCompletionProcessor implements IContentAssistProcessor {
- private static final class ProposalComparator implements Comparator {
+ private static final class ProposalComparator implements Comparator<ICompletionProposal> {
@Override
- public int compare(Object o1, Object o2) {
- return ((TemplateProposal) o2).getRelevance() - ((TemplateProposal) o1).getRelevance();
+ public int compare(ICompletionProposal o1, ICompletionProposal o2) {
+ int r1= o1 instanceof TemplateProposal ? ((TemplateProposal) o1).getRelevance() : 0;
+ int r2= o2 instanceof TemplateProposal ? ((TemplateProposal) o2).getRelevance() : 0;
+ return r2 - r1;
}
}
- private static final Comparator fgProposalComparator= new ProposalComparator();
+ private static final Comparator<ICompletionProposal> fgProposalComparator= new ProposalComparator();
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
@@ -66,7 +68,7 @@ public abstract class TemplateCompletionProcessor implements IContentAssistProce
Template[] templates= getTemplates(context.getContextType().getId());
- List matches= new ArrayList();
+ List<ICompletionProposal> matches= new ArrayList<>();
for (int i= 0; i < templates.length; i++) {
Template template= templates[i];
try {
@@ -80,7 +82,7 @@ public abstract class TemplateCompletionProcessor implements IContentAssistProce
Collections.sort(matches, fgProposalComparator);
- return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]);
+ return matches.toArray(new ICompletionProposal[matches.size()]);
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
index 4a0aa208a..cda02f46a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -145,8 +145,8 @@ public class TemplateReaderWriter {
*/
private TemplatePersistenceData[] read(InputSource source, ResourceBundle bundle, String singleId) throws IOException {
try {
- Collection templates= new ArrayList();
- Set ids= new HashSet();
+ Collection<TemplatePersistenceData> templates= new ArrayList<>();
+ Set<String> ids= new HashSet<>();
DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
DocumentBuilder parser= factory.newDocumentBuilder();
@@ -206,7 +206,7 @@ public class TemplateReaderWriter {
break;
}
- return (TemplatePersistenceData[]) templates.toArray(new TemplatePersistenceData[templates.size()]);
+ return templates.toArray(new TemplatePersistenceData[templates.size()]);
} catch (ParserConfigurationException e) {
Assert.isTrue(false);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
index edbdbcab9..631955a5b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
@@ -38,7 +38,7 @@ import org.eclipse.jface.text.templates.TemplateException;
*/
public class TemplateStore {
/** The stored templates. */
- private final List fTemplates= new ArrayList();
+ private final List<TemplatePersistenceData> fTemplates= new ArrayList<>();
/** The preference store. */
private IPreferenceStore fPreferenceStore;
/**
@@ -185,8 +185,8 @@ public class TemplateStore {
if (!data.isCustom()) {
// check if the added template is not a duplicate id
String id= data.getId();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData d2= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData d2= it.next();
if (d2.getId() != null && d2.getId().equals(id))
return;
}
@@ -200,16 +200,16 @@ public class TemplateStore {
* @throws IOException if the templates cannot be written
*/
public void save() throws IOException {
- ArrayList custom= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ ArrayList<TemplatePersistenceData> custom= new ArrayList<>();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates
custom.add(data);
}
StringWriter output= new StringWriter();
TemplateReaderWriter writer= new TemplateReaderWriter();
- writer.save((TemplatePersistenceData[]) custom.toArray(new TemplatePersistenceData[custom.size()]), output);
+ writer.save(custom.toArray(new TemplatePersistenceData[custom.size()]), output);
fIgnorePreferenceStoreChanges= true;
try {
@@ -234,8 +234,8 @@ public class TemplateStore {
if (data.isUserAdded()) {
fTemplates.add(data);
} else {
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData d2= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData d2= it.next();
if (d2.getId() != null && d2.getId().equals(data.getId())) {
d2.setTemplate(data.getTemplate());
d2.setDeleted(data.isDeleted());
@@ -268,8 +268,8 @@ public class TemplateStore {
* Restores all contributed templates that have been deleted.
*/
public void restoreDeleted() {
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (data.isDeleted())
data.setDeleted(false);
}
@@ -336,14 +336,14 @@ public class TemplateStore {
* @return all enabled templates for the given context type
*/
public Template[] getTemplates(String contextTypeId) {
- List templates= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ List<Template> templates= new ArrayList<>();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (data.isEnabled() && !data.isDeleted() && (contextTypeId == null || contextTypeId.equals(data.getTemplate().getContextTypeId())))
templates.add(data.getTemplate());
}
- return (Template[]) templates.toArray(new Template[templates.size()]);
+ return templates.toArray(new Template[templates.size()]);
}
/**
@@ -366,8 +366,8 @@ public class TemplateStore {
public Template findTemplate(String name, String contextTypeId) {
Assert.isNotNull(name);
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
Template template= data.getTemplate();
if (data.isEnabled() && !data.isDeleted()
&& (contextTypeId == null || contextTypeId.equals(template.getContextTypeId()))
@@ -400,14 +400,14 @@ public class TemplateStore {
* @return all template data, whether enabled or not
*/
public TemplatePersistenceData[] getTemplateData(boolean includeDeleted) {
- List datas= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ List<TemplatePersistenceData> datas= new ArrayList<>();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (includeDeleted || !data.isDeleted())
datas.add(data);
}
- return (TemplatePersistenceData[]) datas.toArray(new TemplatePersistenceData[datas.size()]);
+ return datas.toArray(new TemplatePersistenceData[datas.size()]);
}
/**
@@ -420,8 +420,8 @@ public class TemplateStore {
*/
public TemplatePersistenceData getTemplateData(String id) {
Assert.isNotNull(id);
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (id.equals(data.getId()))
return data;
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java
index b227e8daf..160ac8fe9 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -50,11 +50,11 @@ public class FileTool {
* @throws IOException in case of problem
*/
public static void unzip(ZipFile zipFile, File dstDir) throws IOException {
- Enumeration entries = zipFile.entries();
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
try {
while(entries.hasMoreElements()){
- ZipEntry entry = (ZipEntry)entries.nextElement();
+ ZipEntry entry = entries.nextElement();
if(entry.isDirectory()){
continue;
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
index e7e8856a3..1c98bdb66 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
@@ -97,9 +97,9 @@ public class AnnotationManagerTest extends TestCase {
ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
annotationModel.getAnnotationIterator();
- HashSet positions= new HashSet();
- for (Iterator iter= annotationModel.getAnnotationIterator(); iter.hasNext();) {
- Annotation annotation= (Annotation) iter.next();
+ HashSet<Position> positions= new HashSet<>();
+ for (Iterator<Annotation> iter= annotationModel.getAnnotationIterator(); iter.hasNext();) {
+ Annotation annotation= iter.next();
if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
positions.add(annotationModel.getPosition(annotation));
}
@@ -138,8 +138,8 @@ public class AnnotationManagerTest extends TestCase {
ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
- for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
- Annotation annotation= (Annotation) annotations.next();
+ for (Iterator<Annotation> annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
+ Annotation annotation= annotations.next();
if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
annotationCount++;
}
@@ -164,8 +164,8 @@ public class AnnotationManagerTest extends TestCase {
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
- for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
- Annotation annotation= (Annotation) annotations.next();
+ for (Iterator<Annotation> annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
+ Annotation annotation= annotations.next();
if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
Position p= annotationModel.getPosition(annotation);
String text= document.get(p.getOffset(), p.getLength());
@@ -192,8 +192,8 @@ public class AnnotationManagerTest extends TestCase {
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
- for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
- Annotation annotation= (Annotation) annotations.next();
+ for (Iterator<Annotation> annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
+ Annotation annotation= annotations.next();
if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
Position p= annotationModel.getPosition(annotation);
String text= document.get(p.getOffset(), p.getLength());
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
index 097516ace..86e76d62b 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
@@ -55,14 +55,14 @@ public class FileSearchTests extends TestCase {
private static class TestResultCollector extends TextSearchRequestor {
- protected List fResult;
+ protected List<TestResult> fResult;
public TestResultCollector() {
reset();
}
public TestResult[] getResults() {
- return (TestResult[]) fResult.toArray(new TestResult[fResult.size()]);
+ return fResult.toArray(new TestResult[fResult.size()]);
}
public int getNumberOfResults() {
@@ -70,7 +70,7 @@ public class FileSearchTests extends TestCase {
}
public void reset() {
- fResult= new ArrayList();
+ fResult= new ArrayList<>();
}
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
index efc1708de..78896fe4e 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
@@ -94,9 +94,9 @@ public class LineAnnotationManagerTest extends TestCase {
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
annotationModel.getAnnotationIterator();
- ArrayList positions= new ArrayList();
- for (Iterator iter= annotationModel.getAnnotationIterator(); iter.hasNext();) {
- Annotation annotation= (Annotation) iter.next();
+ ArrayList<Position> positions= new ArrayList<>();
+ for (Iterator<Annotation> iter= annotationModel.getAnnotationIterator(); iter.hasNext();) {
+ Annotation annotation= iter.next();
if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) {
positions.add(annotationModel.getPosition(annotation));
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
index 7595720a6..c45cd30b6 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,16 +13,15 @@ package org.eclipse.search.tests.filesearch;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.eclipse.search.internal.ui.text.FileSearchQuery;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.FileTextSearchScope;
import org.eclipse.search.ui.text.Match;
-import org.eclipse.search.internal.ui.text.FileSearchQuery;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
public class SortingTest extends TestCase {
FileSearchQuery fQuery1;
@@ -58,7 +57,7 @@ public class SortingTest extends TestCase {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
int originalMatchCount= result.getMatchCount();
- List allMatches= new ArrayList(originalMatchCount);
+ List<Match> allMatches= new ArrayList<>(originalMatchCount);
// first, collect all matches
Object[] elements= result.getElements();
@@ -73,7 +72,7 @@ public class SortingTest extends TestCase {
assertTrue("removed all matches", result.getMatchCount() == 0);
for (int i= allMatches.size()-1; i >= 0; i--) {
- result.addMatch((Match) allMatches.get(i));
+ result.addMatch(allMatches.get(i));
}
assertEquals("Test that all matches have been added again", result.getMatchCount(), originalMatchCount);
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
index fbd75957f..f4ba3d60c 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,8 +33,8 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
private static final Match[] EMPTY_ARRAY= new Match[0];
- private final Map fElementsToMatches;
- private final List fListeners;
+ private final Map<Object, List<Match>> fElementsToMatches;
+ private final List<ISearchResultListener> fListeners;
private final MatchEvent fMatchEvent;
private MatchFilter[] fMatchFilters;
@@ -43,8 +43,8 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
* Constructs a new <code>AbstractTextSearchResult</code>
*/
protected AbstractTextSearchResult() {
- fElementsToMatches= new HashMap();
- fListeners= new ArrayList();
+ fElementsToMatches= new HashMap<>();
+ fListeners= new ArrayList<>();
fMatchEvent= new MatchEvent(this);
fMatchFilters= null; // filtering disabled by default
@@ -60,9 +60,9 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
*/
public Match[] getMatches(Object element) {
synchronized (fElementsToMatches) {
- List matches= (List) fElementsToMatches.get(element);
+ List<Match> matches= fElementsToMatches.get(element);
if (matches != null)
- return (Match[]) matches.toArray(new Match[matches.size()]);
+ return matches.toArray(new Match[matches.size()]);
return EMPTY_ARRAY;
}
}
@@ -94,7 +94,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
* @param matches the matches to add
*/
public void addMatches(Match[] matches) {
- Collection reallyAdded= new ArrayList();
+ Collection<Match> reallyAdded= new ArrayList<>();
synchronized (fElementsToMatches) {
for (int i = 0; i < matches.length; i++) {
if (doAddMatch(matches[i]))
@@ -111,9 +111,9 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
return fMatchEvent;
}
- private MatchEvent getSearchResultEvent(Collection matches, int eventKind) {
+ private MatchEvent getSearchResultEvent(Collection<Match> matches, int eventKind) {
fMatchEvent.setKind(eventKind);
- Match[] matchArray= (Match[]) matches.toArray(new Match[matches.size()]);
+ Match[] matchArray= matches.toArray(new Match[matches.size()]);
fMatchEvent.setMatches(matchArray);
return fMatchEvent;
}
@@ -121,9 +121,9 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
private boolean doAddMatch(Match match) {
updateFilterState(match);
- List matches= (List) fElementsToMatches.get(match.getElement());
+ List<Match> matches= fElementsToMatches.get(match.getElement());
if (matches == null) {
- matches= new ArrayList();
+ matches= new ArrayList<>();
fElementsToMatches.put(match.getElement(), matches);
matches.add(match);
return true;
@@ -135,17 +135,17 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
return false;
}
- private static void insertSorted(List matches, Match match) {
+ private static void insertSorted(List<Match> matches, Match match) {
int insertIndex= getInsertIndex(matches, match);
matches.add(insertIndex, match);
}
- private static int getInsertIndex(List matches, Match match) {
+ private static int getInsertIndex(List<Match> matches, Match match) {
int count= matches.size();
int min = 0, max = count - 1;
while (min <= max) {
int mid = (min + max) / 2;
- Match data = (Match) matches.get(mid);
+ Match data = matches.get(mid);
int compare = compare(match, data);
if (compare > 0)
max = mid - 1;
@@ -206,7 +206,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
* @param matches the matches to remove
*/
public void removeMatches(Match[] matches) {
- Collection existing= new ArrayList();
+ Collection<Match> existing= new ArrayList<>();
synchronized (fElementsToMatches) {
for (int i = 0; i < matches.length; i++) {
if (doRemoveMatch(matches[i]))
@@ -220,7 +220,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
private boolean doRemoveMatch(Match match) {
boolean existed= false;
- List matches= (List) fElementsToMatches.get(match.getElement());
+ List<Match> matches= fElementsToMatches.get(match.getElement());
if (matches != null) {
existed= matches.remove(match);
if (matches.isEmpty())
@@ -252,19 +252,19 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
* @see ISearchResultListener
*/
protected void fireChange(SearchResultEvent e) {
- HashSet copiedListeners= new HashSet();
+ HashSet<ISearchResultListener> copiedListeners= new HashSet<>();
synchronized (fListeners) {
copiedListeners.addAll(fListeners);
}
- Iterator listeners= copiedListeners.iterator();
+ Iterator<ISearchResultListener> listeners= copiedListeners.iterator();
while (listeners.hasNext()) {
- ((ISearchResultListener) listeners.next()).searchResultChanged(e);
+ listeners.next().searchResultChanged(e);
}
}
private void updateFilterStateForAllMatches() {
boolean disableFiltering= getActiveMatchFilters() == null;
- ArrayList changed= new ArrayList();
+ ArrayList<Match> changed= new ArrayList<>();
Object[] elements= getElements();
for (int i= 0; i < elements.length; i++) {
Match[] matches= getMatches(elements[i]);
@@ -274,7 +274,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
}
}
}
- Match[] allChanges= (Match[]) changed.toArray(new Match[changed.size()]);
+ Match[] allChanges= changed.toArray(new Match[changed.size()]);
fireChange(new FilterUpdateEvent(this, allChanges, getActiveMatchFilters()));
}
@@ -307,8 +307,8 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
public int getMatchCount() {
int count= 0;
synchronized (fElementsToMatches) {
- for (Iterator elements= fElementsToMatches.values().iterator(); elements.hasNext();) {
- List element= (List) elements.next();
+ for (Iterator<List<Match>> elements= fElementsToMatches.values().iterator(); elements.hasNext();) {
+ List<Match> element= elements.next();
if (element != null)
count+= element.size();
}
@@ -325,7 +325,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
* @return the number of matches reported against the element
*/
public int getMatchCount(Object element) {
- List matches= (List) fElementsToMatches.get(element);
+ List<Match> matches= fElementsToMatches.get(element);
if (matches != null)
return matches.size();
return 0;
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
index f7578dddc..dfda87720 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
@@ -174,7 +174,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
}
private class SelectionProviderAdapter implements ISelectionProvider, ISelectionChangedListener {
- private ArrayList fListeners= new ArrayList(5);
+ private ArrayList<ISelectionChangedListener> fListeners= new ArrayList<>(5);
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
@@ -200,8 +200,8 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
public void selectionChanged(SelectionChangedEvent event) {
// forward to my listeners
SelectionChangedEvent wrappedEvent= new SelectionChangedEvent(this, event.getSelection());
- for (Iterator listeners= fListeners.iterator(); listeners.hasNext();) {
- ISelectionChangedListener listener= (ISelectionChangedListener) listeners.next();
+ for (Iterator<ISelectionChangedListener> listeners= fListeners.iterator(); listeners.hasNext();) {
+ ISelectionChangedListener listener= listeners.next();
listener.selectionChanged(wrappedEvent);
}
}
@@ -223,7 +223,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
private PageBook fPagebook;
private boolean fIsBusyShown;
private ISearchResultViewPart fViewPart;
- private Set fBatchedUpdates;
+ private Set<Object> fBatchedUpdates;
private boolean fBatchedClearAll;
private ISearchResultListener fListener;
@@ -296,7 +296,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
fSelectAllAction= new SelectAllAction();
createLayoutActions();
- fBatchedUpdates = new HashSet();
+ fBatchedUpdates = new HashSet<>();
fBatchedClearAll= false;
fListener = new ISearchResultListener() {
@@ -1240,7 +1240,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
* @param changedElements the set that collects the elements to change. Clients should only add elements to the set.
* @since 3.4
*/
- protected void evaluateChangedElements(Match[] matches, Set changedElements) {
+ protected void evaluateChangedElements(Match[] matches, Set<Object> changedElements) {
for (int i = 0; i < matches.length; i++) {
changedElements.add(matches[i].getElement());
}
@@ -1357,7 +1357,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
StructuredViewer viewer = getViewer();
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
- HashSet set = new HashSet();
+ HashSet<Match> set = new HashSet<>();
if (viewer instanceof TreeViewer) {
ITreeContentProvider cp = (ITreeContentProvider) viewer.getContentProvider();
collectAllMatchesBelow(result, set, cp, selection.toArray());
@@ -1371,7 +1371,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
result.removeMatches(matches);
}
- private void collectAllMatches(HashSet set, Object[] elements) {
+ private void collectAllMatches(HashSet<Match> set, Object[] elements) {
for (int j = 0; j < elements.length; j++) {
Match[] matches = getDisplayedMatches(elements[j]);
for (int i = 0; i < matches.length; i++) {
@@ -1380,7 +1380,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
}
}
- private void collectAllMatchesBelow(AbstractTextSearchResult result, Set set, ITreeContentProvider cp, Object[] elements) {
+ private void collectAllMatchesBelow(AbstractTextSearchResult result, Set<Match> set, ITreeContentProvider cp, Object[] elements) {
for (int j = 0; j < elements.length; j++) {
Match[] matches = getDisplayedMatches(elements[j]);
for (int i = 0; i < matches.length; i++) {
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
index 9ace3c800..da2462f3d 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
@@ -240,7 +240,7 @@ public final class FileTextSearchScope extends TextSearchScope {
if (fileNamePatterns == null || fileNamePatterns.length == 0) {
return null;
}
- ArrayList patterns= new ArrayList();
+ ArrayList<String> patterns= new ArrayList<>();
for (int i= 0; i < fileNamePatterns.length; i++) {
String pattern= fFileNamePatterns[i];
if (negativeMatcher == pattern.startsWith(FileTypeEditor.FILE_PATTERN_NEGATOR)) {
@@ -253,7 +253,7 @@ public final class FileTextSearchScope extends TextSearchScope {
}
}
if (!patterns.isEmpty()) {
- String[] patternArray= (String[]) patterns.toArray(new String[patterns.size()]);
+ String[] patternArray= patterns.toArray(new String[patterns.size()]);
Pattern pattern= PatternConstructor.createPattern(patternArray, IS_CASE_SENSITIVE_FILESYSTEM);
return pattern.matcher(""); //$NON-NLS-1$
}
@@ -261,16 +261,16 @@ public final class FileTextSearchScope extends TextSearchScope {
}
private static IResource[] removeRedundantEntries(IResource[] elements, boolean includeDerived) {
- ArrayList res= new ArrayList();
+ ArrayList<IResource> res= new ArrayList<>();
for (int i= 0; i < elements.length; i++) {
IResource curr= elements[i];
addToList(res, curr, includeDerived);
}
- return (IResource[])res.toArray(new IResource[res.size()]);
+ return res.toArray(new IResource[res.size()]);
}
private static IResource[] convertToResources(IWorkingSet[] workingSets, boolean includeDerived) {
- ArrayList res= new ArrayList();
+ ArrayList<IResource> res= new ArrayList<>();
for (int i= 0; i < workingSets.length; i++) {
IWorkingSet workingSet= workingSets[i];
if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
@@ -284,16 +284,16 @@ public final class FileTextSearchScope extends TextSearchScope {
}
}
}
- return (IResource[]) res.toArray(new IResource[res.size()]);
+ return res.toArray(new IResource[res.size()]);
}
- private static void addToList(ArrayList res, IResource curr, boolean includeDerived) {
+ private static void addToList(ArrayList<IResource> res, IResource curr, boolean includeDerived) {
if (!includeDerived && curr.isDerived(IResource.CHECK_ANCESTORS)) {
return;
}
IPath currPath= curr.getFullPath();
for (int k= res.size() - 1; k >= 0 ; k--) {
- IResource other= (IResource) res.get(k);
+ IResource other= res.get(k);
IPath otherPath= other.getFullPath();
if (otherPath.isPrefixOf(currPath)) {
return;
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
index 04e885b3d..99ac2018b 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -46,7 +46,7 @@ public class InternalSearchUI {
private static InternalSearchUI fgInstance;
// contains all running jobs
- private HashMap fSearchJobs;
+ private HashMap<ISearchQuery, SearchJobRecord> fSearchJobs;
private QueryManager fSearchResultsManager;
private PositionTracker fPositionTracker;
@@ -123,7 +123,7 @@ public class InternalSearchUI {
*/
public InternalSearchUI() {
fgInstance= this;
- fSearchJobs= new HashMap();
+ fSearchJobs= new HashMap<>();
fSearchResultsManager= new QueryManager();
fPositionTracker= new PositionTracker();
@@ -186,7 +186,7 @@ public class InternalSearchUI {
}
public boolean isQueryRunning(ISearchQuery query) {
- SearchJobRecord sjr= (SearchJobRecord) fSearchJobs.get(query);
+ SearchJobRecord sjr= fSearchJobs.get(query);
return sjr != null && sjr.isRunning;
}
@@ -253,9 +253,9 @@ public class InternalSearchUI {
}
private void doShutdown() {
- Iterator jobRecs= fSearchJobs.values().iterator();
+ Iterator<SearchJobRecord> jobRecs= fSearchJobs.values().iterator();
while (jobRecs.hasNext()) {
- SearchJobRecord element= (SearchJobRecord) jobRecs.next();
+ SearchJobRecord element= jobRecs.next();
if (element.job != null)
element.job.cancel();
}
@@ -266,7 +266,7 @@ public class InternalSearchUI {
}
public void cancelSearch(ISearchQuery job) {
- SearchJobRecord rec= (SearchJobRecord) fSearchJobs.get(job);
+ SearchJobRecord rec= fSearchJobs.get(job);
if (rec != null && rec.job != null)
rec.job.cancel();
}
@@ -332,8 +332,8 @@ public class InternalSearchUI {
}
public void removeAllQueries() {
- for (Iterator queries= fSearchJobs.keySet().iterator(); queries.hasNext();) {
- ISearchQuery query= (ISearchQuery) queries.next();
+ for (Iterator<ISearchQuery> queries= fSearchJobs.keySet().iterator(); queries.hasNext();) {
+ ISearchQuery query= queries.next();
cancelSearch(query);
}
fSearchJobs.clear();
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java
index 63c781677..27978fe4b 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java
@@ -41,7 +41,7 @@ public class MatchFilterAction extends Action implements IUpdate {
if (input == null) {
return;
}
- ArrayList newFilters= new ArrayList();
+ ArrayList<MatchFilter> newFilters= new ArrayList<>();
MatchFilter[] activeMatchFilters= input.getActiveMatchFilters();
if (activeMatchFilters == null) {
return;
@@ -56,7 +56,7 @@ public class MatchFilterAction extends Action implements IUpdate {
if (newState) {
newFilters.add(fFilter);
}
- input.setActiveMatchFilters((MatchFilter[]) newFilters.toArray(new MatchFilter[newFilters.size()]));
+ input.setActiveMatchFilters(newFilters.toArray(new MatchFilter[newFilters.size()]));
}
public MatchFilter getFilter() {
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
index 673e1f94e..1bed6493e 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
@@ -21,14 +21,14 @@ import org.eclipse.search.ui.IQueryListener;
import org.eclipse.search.ui.ISearchQuery;
class QueryManager {
- private List fQueries;
- private List fListeners;
+ private List<ISearchQuery> fQueries;
+ private List<IQueryListener> fListeners;
public QueryManager() {
super();
// an ArrayList should be plenty fast enough (few searches).
- fListeners= new ArrayList();
- fQueries= new LinkedList();
+ fListeners= new ArrayList<>();
+ fQueries= new LinkedList<>();
}
public boolean hasQueries() {
@@ -50,7 +50,7 @@ class QueryManager {
*/
public ISearchQuery[] getQueries() {
synchronized (this) {
- return (ISearchQuery[]) fQueries.toArray(new ISearchQuery[fQueries.size()]);
+ return fQueries.toArray(new ISearchQuery[fQueries.size()]);
}
}
@@ -83,60 +83,60 @@ class QueryManager {
}
public void fireAdded(ISearchQuery query) {
- Set copiedListeners= new HashSet();
+ Set<IQueryListener> copiedListeners= new HashSet<>();
synchronized (fListeners) {
copiedListeners.addAll(fListeners);
}
- Iterator listeners= copiedListeners.iterator();
+ Iterator<IQueryListener> listeners= copiedListeners.iterator();
while (listeners.hasNext()) {
- IQueryListener l= (IQueryListener) listeners.next();
+ IQueryListener l= listeners.next();
l.queryAdded(query);
}
}
public void fireRemoved(ISearchQuery query) {
- Set copiedListeners= new HashSet();
+ Set<IQueryListener> copiedListeners= new HashSet<>();
synchronized (fListeners) {
copiedListeners.addAll(fListeners);
}
- Iterator listeners= copiedListeners.iterator();
+ Iterator<IQueryListener> listeners= copiedListeners.iterator();
while (listeners.hasNext()) {
- IQueryListener l= (IQueryListener) listeners.next();
+ IQueryListener l= listeners.next();
l.queryRemoved(query);
}
}
public void fireStarting(ISearchQuery query) {
- Set copiedListeners= new HashSet();
+ Set<IQueryListener> copiedListeners= new HashSet<>();
synchronized (fListeners) {
copiedListeners.addAll(fListeners);
}
- Iterator listeners= copiedListeners.iterator();
+ Iterator<IQueryListener> listeners= copiedListeners.iterator();
while (listeners.hasNext()) {
- IQueryListener l= (IQueryListener) listeners.next();
+ IQueryListener l= listeners.next();
l.queryStarting(query);
}
}
public void fireFinished(ISearchQuery query) {
- Set copiedListeners= new HashSet();
+ Set<IQueryListener> copiedListeners= new HashSet<>();
synchronized (fListeners) {
copiedListeners.addAll(fListeners);
}
- Iterator listeners= copiedListeners.iterator();
+ Iterator<IQueryListener> listeners= copiedListeners.iterator();
while (listeners.hasNext()) {
- IQueryListener l= (IQueryListener) listeners.next();
+ IQueryListener l= listeners.next();
l.queryFinished(query);
}
}
public void removeAll() {
synchronized (this) {
- List old= fQueries;
- fQueries= new LinkedList();
- Iterator iter= old.iterator();
+ List<ISearchQuery> old= fQueries;
+ fQueries= new LinkedList<>();
+ Iterator<ISearchQuery> iter= old.iterator();
while (iter.hasNext()) {
- ISearchQuery element= (ISearchQuery) iter.next();
+ ISearchQuery element= iter.next();
fireRemoved(element);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java
index 7b695e092..45924a447 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -38,7 +38,7 @@ class SearchHistoryDropDownAction extends Action implements IMenuCreator {
String label= escapeAmp(search.getLabel());
if (InternalSearchUI.getInstance().isQueryRunning(search.getQuery()))
- label= MessageFormat.format(SearchMessages.SearchDropDownAction_running_message, new String[] { label });
+ label= MessageFormat.format(SearchMessages.SearchDropDownAction_running_message, new Object[] { label });
// fix for bug 38049
if (label.indexOf('@') >= 0)
label+= '@';
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java
index aa6a69aad..9d7e59cd4 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -67,8 +67,8 @@ public class SearchHistorySelectionDialog extends SelectionDialog {
private static final int REMOVE_ID= IDialogConstants.CLIENT_ID+1;
private static final int WIDTH_IN_CHARACTERS= 55;
- private List fInput;
- private final List fRemovedEntries;
+ private List<ISearchResult> fInput;
+ private final List<ISearchResult> fRemovedEntries;
private TableViewer fViewer;
private Button fRemoveButton;
@@ -82,10 +82,10 @@ public class SearchHistorySelectionDialog extends SelectionDialog {
private int fHistorySize;
private Text fHistorySizeTextField;
- private final List fCurrentList;
- private final List fCurrentRemoves;
+ private final List<ISearchResult> fCurrentList;
+ private final List<ISearchResult> fCurrentRemoves;
- public HistoryConfigurationDialog(Shell parent, List currentList, List removedEntries) {
+ public HistoryConfigurationDialog(Shell parent, List<ISearchResult> currentList, List<ISearchResult> removedEntries) {
super(parent);
fCurrentList= currentList;
fCurrentRemoves= removedEntries;
@@ -186,7 +186,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog {
private static final class SearchesLabelProvider extends LabelProvider {
- private ArrayList fImages= new ArrayList();
+ private ArrayList<Image> fImages= new ArrayList<>();
@Override
public String getText(Object element) {
@@ -208,20 +208,20 @@ public class SearchHistorySelectionDialog extends SelectionDialog {
@Override
public void dispose() {
- Iterator iter= fImages.iterator();
+ Iterator<Image> iter= fImages.iterator();
while (iter.hasNext())
- ((Image)iter.next()).dispose();
+ iter.next().dispose();
fImages= null;
}
}
- public SearchHistorySelectionDialog(Shell parent, List input) {
+ public SearchHistorySelectionDialog(Shell parent, List<ISearchResult> input) {
super(parent);
setTitle(SearchMessages.SearchesDialog_title);
setMessage(SearchMessages.SearchesDialog_message);
fInput= input;
- fRemovedEntries= new ArrayList();
+ fRemovedEntries= new ArrayList<>();
setHelpAvailable(false);
}
@@ -273,7 +273,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog {
public void create() {
super.create();
- List initialSelection= getInitialElementSelections();
+ List<?> initialSelection= getInitialElementSelections();
if (initialSelection != null)
fViewer.setSelection(new StructuredSelection(initialSelection));
@@ -388,9 +388,9 @@ public class SearchHistorySelectionDialog extends SelectionDialog {
protected void buttonPressed(int buttonId) {
if (buttonId == REMOVE_ID) {
IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection();
- Iterator searchResults= selection.iterator();
+ Iterator<?> searchResults= selection.iterator();
while (searchResults.hasNext()) {
- Object curr= searchResults.next();
+ ISearchResult curr= (ISearchResult) searchResults.next();
fRemovedEntries.add(curr);
fInput.remove(curr);
fViewer.remove(curr);
@@ -418,8 +418,8 @@ public class SearchHistorySelectionDialog extends SelectionDialog {
setResult(((IStructuredSelection) fViewer.getSelection()).toList());
// remove queries
- for (Iterator iter= fRemovedEntries.iterator(); iter.hasNext();) {
- ISearchResult result= (ISearchResult) iter.next();
+ for (Iterator<ISearchResult> iter= fRemovedEntries.iterator(); iter.hasNext();) {
+ ISearchResult result= iter.next();
ISearchQuery query= result.getQuery();
if (query != null) { // must not be null: invalid implementation of a search query
InternalSearchUI.getInstance().removeQuery(query);
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
index 821322c02..0eb8fc7c2 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -35,13 +35,13 @@ public class SearchPageRegistry {
public static final String ATTRIB_HELP_CONTEXT= "helpContextId"; //$NON-NLS-1$
- private final Map fResultClassNameToExtension;
- private final Map fExtensionToInstance;
+ private final Map<String, IConfigurationElement> fResultClassNameToExtension;
+ private final Map<IConfigurationElement, ISearchResultPage> fExtensionToInstance;
private final IConfigurationElement[] fExtensions;
public SearchPageRegistry() {
- fExtensionToInstance= new HashMap();
- fResultClassNameToExtension= new HashMap();
+ fExtensionToInstance= new HashMap<>();
+ fResultClassNameToExtension= new HashMap<>();
fExtensions= Platform.getExtensionRegistry().getConfigurationElementsFor(ID_EXTENSION_POINT);
for (int i= 0; i < fExtensions.length; i++) {
fResultClassNameToExtension.put(fExtensions[i].getAttribute(ATTRIB_SEARCH_RESULT_CLASS), fExtensions[i]);
@@ -49,7 +49,7 @@ public class SearchPageRegistry {
}
public ISearchResultPage findPageForSearchResult(ISearchResult result, boolean create) {
- Class resultClass= result.getClass();
+ Class<? extends ISearchResult> resultClass= result.getClass();
IConfigurationElement configElement= findConfigurationElement(resultClass);
if (configElement != null) {
return getSearchResultPage(configElement, create);
@@ -82,7 +82,7 @@ public class SearchPageRegistry {
}
private ISearchResultPage getSearchResultPage(final IConfigurationElement configElement, boolean create) {
- ISearchResultPage instance= (ISearchResultPage) fExtensionToInstance.get(configElement);
+ ISearchResultPage instance= fExtensionToInstance.get(configElement);
if (instance == null && create) {
final Object[] result= new Object[1];
@@ -117,13 +117,13 @@ public class SearchPageRegistry {
return null;
}
- private IConfigurationElement findConfigurationElement(Class resultClass) {
+ private IConfigurationElement findConfigurationElement(Class<?> resultClass) {
String className= resultClass.getName();
- IConfigurationElement configElement= (IConfigurationElement) fResultClassNameToExtension.get(className);
+ IConfigurationElement configElement= fResultClassNameToExtension.get(className);
if (configElement != null) {
return configElement;
}
- Class superclass= resultClass.getSuperclass();
+ Class<?> superclass= resultClass.getSuperclass();
if (superclass != null) {
IConfigurationElement foundExtension= findConfigurationElement(superclass);
if (foundExtension != null) {
@@ -132,7 +132,7 @@ public class SearchPageRegistry {
}
}
- Class[] interfaces= resultClass.getInterfaces();
+ Class<?>[] interfaces= resultClass.getInterfaces();
for (int i= 0; i < interfaces.length; i++) {
IConfigurationElement foundExtension= findConfigurationElement(interfaces[i]);
if (foundExtension != null) {
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
index 51ac16106..2d4bd7fbc 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@ package org.eclipse.search2.internal.ui;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
+import java.util.Map.Entry;
import com.ibm.icu.text.MessageFormat;
@@ -91,9 +91,9 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
private static final String MEMENTO_KEY_IS_PINNED= "isPinned"; //$NON-NLS-1$
private static final String MEMENTO_KEY_LAST_ACTIVATION= "org.eclipse.search.lastActivation"; //$NON-NLS-1$
private static final String MEMENTO_KEY_RESTORE= "org.eclipse.search.restore"; //$NON-NLS-1$
- private HashMap fPartsToPages;
- private HashMap fPagesToParts;
- private HashMap fSearchViewStates;
+ private HashMap<DummyPart, IPageBookViewPage> fPartsToPages;
+ private HashMap<ISearchResultPage, DummyPart> fPagesToParts;
+ private HashMap<ISearchResult, Object> fSearchViewStates;
private SearchPageRegistry fSearchViewPageService;
private SearchHistoryDropDownAction fSearchesDropDownAction;
private ISearchResult fCurrentSearch;
@@ -216,7 +216,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
@Override
public void setFocus() {/*dummy*/}
@Override
- public Object getAdapter(Class adapter) { return null; }
+ public <T> T getAdapter(Class<T> adapter) { return null; }
}
static class EmptySearchView extends Page implements ISearchResultPage {
@@ -312,10 +312,10 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
public SearchView() {
super();
- fPartsToPages= new HashMap();
- fPagesToParts= new HashMap();
+ fPartsToPages= new HashMap<>();
+ fPagesToParts= new HashMap<>();
fSearchViewPageService= new SearchPageRegistry();
- fSearchViewStates= new HashMap();
+ fSearchViewStates= new HashMap<>();
fIsPinned= false;
}
@@ -337,7 +337,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
@Override
protected IPage createDefaultPage(PageBook book) {
- IPageBookViewPage page= new EmptySearchView();
+ ISearchResultPage page= new EmptySearchView();
page.createControl(book);
initPage(page);
DummyPart part= new DummyPart(getSite());
@@ -349,7 +349,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
@Override
protected PageRec doCreatePage(IWorkbenchPart part) {
- IPageBookViewPage page = (IPageBookViewPage) fPartsToPages.get(part);
+ IPageBookViewPage page = fPartsToPages.get(part);
initPage(page);
page.createControl(getPageBook());
PageRec rec = new PageRec(part, page);
@@ -409,7 +409,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
if (page != null) {
if (page != currentPage) {
- DummyPart part= (DummyPart) fPagesToParts.get(page);
+ DummyPart part= fPagesToParts.get(page);
if (part == null) {
part= new DummyPart(getSite());
fPagesToParts.put(page, part);
@@ -657,7 +657,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
if (result != null) {
menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, fSearchAgainAction);
// first check if we have a selection for the show in mechanism, bugzilla 127718
- IShowInSource showInSource= (IShowInSource) getAdapter(IShowInSource.class);
+ IShowInSource showInSource= getAdapter(IShowInSource.class);
if (showInSource != null) {
ShowInContext context= showInSource.getShowInContext();
if (context != null) {
@@ -690,10 +690,10 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
@Override
public void saveState(IMemento memento) {
- for (Iterator iter= fPagesToParts.entrySet().iterator(); iter.hasNext();) {
- Map.Entry entry= (Map.Entry) iter.next();
- ISearchResultPage page= (ISearchResultPage) entry.getKey();
- DummyPart part= (DummyPart) entry.getValue();
+ for (Iterator<Entry<ISearchResultPage, DummyPart>> iter= fPagesToParts.entrySet().iterator(); iter.hasNext();) {
+ Entry<ISearchResultPage, DummyPart> entry= iter.next();
+ ISearchResultPage page= entry.getKey();
+ DummyPart part= entry.getValue();
IMemento child= memento.createChild(MEMENTO_TYPE, page.getID());
page.saveState(child);
@@ -778,13 +778,14 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
getProgressService().warnOfContentChange();
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
Object superAdapter= super.getAdapter(adapter);
if (superAdapter != null)
- return superAdapter;
+ return (T) superAdapter;
if (adapter == IShowInSource.class) {
- return new IShowInSource() {
+ return (T) new IShowInSource() {
@Override
public ShowInContext getShowInContext() {
return new ShowInContext(null, getSelectionProvider().getSelection());
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java
index e4d1e7f3b..0d0f7d3ea 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java
@@ -38,7 +38,7 @@ public class SearchViewManager {
private IQueryListener fNewQueryListener;
private int fViewCount= 0;
- private LinkedList fLRUSearchViews;
+ private LinkedList<SearchView> fLRUSearchViews;
public SearchViewManager(QueryManager queryManager) {
@@ -60,7 +60,7 @@ public class SearchViewManager {
queryManager.addQueryListener(fNewQueryListener);
- fLRUSearchViews= new LinkedList();
+ fLRUSearchViews= new LinkedList<>();
}
@@ -71,7 +71,7 @@ public class SearchViewManager {
protected boolean showNewSearchQuery(ISearchQuery query) {
if (!fLRUSearchViews.isEmpty()) {
- SearchView view= (SearchView) fLRUSearchViews.getFirst();
+ SearchView view= fLRUSearchViews.getFirst();
view.showSearchResult(query.getSearchResult());
return true;
}
@@ -120,8 +120,8 @@ public class SearchViewManager {
}
public boolean isShown(ISearchQuery query) {
- for (Iterator iter= fLRUSearchViews.iterator(); iter.hasNext();) {
- SearchView view= (SearchView) iter.next();
+ for (Iterator<SearchView> iter= fLRUSearchViews.iterator(); iter.hasNext();) {
+ SearchView view= iter.next();
ISearchResult currentSearchResult= view.getCurrentSearchResult();
if (currentSearchResult != null && query == currentSearchResult.getQuery()) {
return true;
@@ -142,8 +142,8 @@ public class SearchViewManager {
private ISearchResultViewPart findLRUSearchResultView(IWorkbenchPage page, boolean avoidPinnedViews) {
boolean viewFoundInPage= false;
- for (Iterator iter= fLRUSearchViews.iterator(); iter.hasNext();) {
- SearchView view= (SearchView) iter.next();
+ for (Iterator<SearchView> iter= fLRUSearchViews.iterator(); iter.hasNext();) {
+ SearchView view= iter.next();
if (page.equals(view.getSite().getPage())) {
if (!avoidPinnedViews || !view.isPinned()) {
return view;
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java
index ca3d107fd..bfee6fcfb 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java
@@ -43,7 +43,7 @@ class ShowSearchHistoryDialogAction extends Action {
public void run() {
ISearchQuery[] queries= NewSearchUI.getQueries();
- ArrayList input= new ArrayList();
+ ArrayList<ISearchResult> input= new ArrayList<>();
for (int j= 0; j < queries.length; j++) {
ISearchResult search= queries[j].getSearchResult();
input.add(search);
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java
index 278661bc7..954c1abc7 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,17 +41,17 @@ import org.eclipse.search2.internal.ui.SearchMessages;
public class AnnotationHighlighter extends Highlighter {
private IAnnotationModel fModel;
private IDocument fDocument;
- private Map fMatchesToAnnotations;
+ private Map<Match, Annotation> fMatchesToAnnotations;
public AnnotationHighlighter(IAnnotationModel model, IDocument document) {
fModel= model;
fDocument= document;
- fMatchesToAnnotations= new HashMap();
+ fMatchesToAnnotations= new HashMap<>();
}
@Override
public void addHighlights(Match[] matches) {
- HashMap map= new HashMap(matches.length);
+ HashMap<Annotation, Position> map= new HashMap<>(matches.length);
for (int i= 0; i < matches.length; i++) {
int offset= matches[i].getOffset();
int length= matches[i].getLength();
@@ -95,9 +95,9 @@ public class AnnotationHighlighter extends Highlighter {
@Override
public void removeHighlights(Match[] matches) {
- HashSet annotations= new HashSet(matches.length);
+ HashSet<Annotation> annotations= new HashSet<>(matches.length);
for (int i= 0; i < matches.length; i++) {
- Annotation annotation= (Annotation) fMatchesToAnnotations.remove(matches[i]);
+ Annotation annotation= fMatchesToAnnotations.remove(matches[i]);
if (annotation != null) {
annotations.add(annotation);
}
@@ -107,19 +107,19 @@ public class AnnotationHighlighter extends Highlighter {
@Override
public void removeAll() {
- Collection matchSet= fMatchesToAnnotations.values();
+ Collection<Annotation> matchSet= fMatchesToAnnotations.values();
removeAnnotations(matchSet);
fMatchesToAnnotations.clear();
}
- private void addAnnotations(Map annotationToPositionMap) {
+ private void addAnnotations(Map<Annotation, Position> annotationToPositionMap) {
if (fModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ame= (IAnnotationModelExtension) fModel;
ame.replaceAnnotations(new Annotation[0], annotationToPositionMap);
} else {
- for (Iterator elements= annotationToPositionMap.keySet().iterator(); elements.hasNext();) {
- Annotation element= (Annotation) elements.next();
- Position p= (Position) annotationToPositionMap.get(element);
+ for (Iterator<Annotation> elements= annotationToPositionMap.keySet().iterator(); elements.hasNext();) {
+ Annotation element= elements.next();
+ Position p= annotationToPositionMap.get(element);
fModel.addAnnotation(element, p);
}
}
@@ -132,14 +132,14 @@ public class AnnotationHighlighter extends Highlighter {
* @param annotations A set containing the annotations to be removed.
* @see Annotation
*/
- private void removeAnnotations(Collection annotations) {
+ private void removeAnnotations(Collection<Annotation> annotations) {
if (fModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ame= (IAnnotationModelExtension) fModel;
Annotation[] annotationArray= new Annotation[annotations.size()];
- ame.replaceAnnotations((Annotation[]) annotations.toArray(annotationArray), Collections.EMPTY_MAP);
+ ame.replaceAnnotations(annotations.toArray(annotationArray), Collections.emptyMap());
} else {
- for (Iterator iter= annotations.iterator(); iter.hasNext();) {
- Annotation element= (Annotation) iter.next();
+ for (Iterator<Annotation> iter= annotations.iterator(); iter.hasNext();) {
+ Annotation element= iter.next();
fModel.removeAnnotation(element);
}
}
@@ -152,8 +152,8 @@ public class AnnotationHighlighter extends Highlighter {
ITextFileBuffer textBuffer= (ITextFileBuffer) buffer;
if (fDocument != null && fDocument.equals(textBuffer.getDocument())) {
- Set allMatches= fMatchesToAnnotations.keySet();
- Match[] matchesCopy= (Match[]) allMatches.toArray(new Match[allMatches.size()]);
+ Set<Match> allMatches= fMatchesToAnnotations.keySet();
+ Match[] matchesCopy= allMatches.toArray(new Match[allMatches.size()]);
removeAll();
addHighlights(matchesCopy);
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java
index 15f69f08e..1dc966b46 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java
@@ -21,7 +21,7 @@ import org.eclipse.search.ui.text.AbstractTextSearchResult;
public class AnnotationManagers {
static {
- fgManagerMap = new HashMap();
+ fgManagerMap = new HashMap<>();
IWindowListener listener = new IWindowListener() {
@Override
public void windowActivated(IWorkbenchWindow window) {
@@ -46,11 +46,11 @@ public class AnnotationManagers {
PlatformUI.getWorkbench().addWindowListener(listener);
}
- private static HashMap fgManagerMap;
+ private static HashMap<IWorkbenchWindow, WindowAnnotationManager> fgManagerMap;
private static void disposeAnnotationManager(IWorkbenchWindow window) {
- WindowAnnotationManager mgr = (WindowAnnotationManager) fgManagerMap.remove(window);
+ WindowAnnotationManager mgr = fgManagerMap.remove(window);
if (mgr != null)
mgr.dispose();
}
@@ -64,7 +64,7 @@ public class AnnotationManagers {
}
private static WindowAnnotationManager getWindowAnnotationManager(IWorkbenchWindow window) {
- WindowAnnotationManager mgr= (WindowAnnotationManager) fgManagerMap.get(window);
+ WindowAnnotationManager mgr= fgManagerMap.get(window);
if (mgr == null) {
mgr= new WindowAnnotationManager(window);
fgManagerMap.put(window, mgr);
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java
index 7312e2308..a2c665c87 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,16 +40,16 @@ import org.eclipse.search2.internal.ui.SearchMessages;
public class EditorAccessHighlighter extends Highlighter {
private ISearchEditorAccess fEditorAcess;
- private Map fMatchesToAnnotations;
+ private Map<Match, Annotation> fMatchesToAnnotations;
public EditorAccessHighlighter(ISearchEditorAccess editorAccess) {
fEditorAcess= editorAccess;
- fMatchesToAnnotations= new HashMap();
+ fMatchesToAnnotations= new HashMap<>();
}
@Override
public void addHighlights(Match[] matches) {
- Map mapsByAnnotationModel= new HashMap();
+ Map<IAnnotationModel, HashMap<Annotation, Position>> mapsByAnnotationModel= new HashMap<>();
for (int i= 0; i < matches.length; i++) {
int offset= matches[i].getOffset();
int length= matches[i].getLength();
@@ -57,7 +57,7 @@ public class EditorAccessHighlighter extends Highlighter {
try {
Position position= createPosition(matches[i]);
if (position != null) {
- Map map= getMap(mapsByAnnotationModel, matches[i]);
+ Map<Annotation, Position> map= getMap(mapsByAnnotationModel, matches[i]);
if (map != null) {
Annotation annotation= matches[i].isFiltered()
? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null)
@@ -71,9 +71,9 @@ public class EditorAccessHighlighter extends Highlighter {
}
}
}
- for (Iterator maps= mapsByAnnotationModel.keySet().iterator(); maps.hasNext();) {
- IAnnotationModel model= (IAnnotationModel) maps.next();
- Map positionMap= (Map) mapsByAnnotationModel.get(model);
+ for (Iterator<IAnnotationModel> maps= mapsByAnnotationModel.keySet().iterator(); maps.hasNext();) {
+ IAnnotationModel model= maps.next();
+ Map<Annotation, Position> positionMap= mapsByAnnotationModel.get(model);
addAnnotations(model, positionMap);
}
@@ -98,25 +98,25 @@ public class EditorAccessHighlighter extends Highlighter {
return position;
}
- private Map getMap(Map mapsByAnnotationModel, Match match) {
+ private Map<Annotation, Position> getMap(Map<IAnnotationModel, HashMap<Annotation, Position>> mapsByAnnotationModel, Match match) {
IAnnotationModel model= fEditorAcess.getAnnotationModel(match);
if (model == null)
return null;
- HashMap map= (HashMap) mapsByAnnotationModel.get(model);
+ HashMap<Annotation, Position> map= mapsByAnnotationModel.get(model);
if (map == null) {
- map= new HashMap();
+ map= new HashMap<>();
mapsByAnnotationModel.put(model, map);
}
return map;
}
- private Set getSet(Map setsByAnnotationModel, Match match) {
+ private Set<Annotation> getSet(Map<IAnnotationModel, HashSet<Annotation>> setsByAnnotationModel, Match match) {
IAnnotationModel model= fEditorAcess.getAnnotationModel(match);
if (model == null)
return null;
- HashSet set= (HashSet) setsByAnnotationModel.get(model);
+ HashSet<Annotation> set= setsByAnnotationModel.get(model);
if (set == null) {
- set= new HashSet();
+ set= new HashSet<>();
setsByAnnotationModel.put(model, set);
}
return set;
@@ -124,32 +124,32 @@ public class EditorAccessHighlighter extends Highlighter {
@Override
public void removeHighlights(Match[] matches) {
- Map setsByAnnotationModel= new HashMap();
+ Map<IAnnotationModel, HashSet<Annotation>> setsByAnnotationModel= new HashMap<>();
for (int i= 0; i < matches.length; i++) {
- Annotation annotation= (Annotation) fMatchesToAnnotations.remove(matches[i]);
+ Annotation annotation= fMatchesToAnnotations.remove(matches[i]);
if (annotation != null) {
- Set annotations= getSet(setsByAnnotationModel, matches[i]);
+ Set<Annotation> annotations= getSet(setsByAnnotationModel, matches[i]);
if (annotations != null)
annotations.add(annotation);
}
}
- for (Iterator maps= setsByAnnotationModel.keySet().iterator(); maps.hasNext();) {
- IAnnotationModel model= (IAnnotationModel) maps.next();
- Set set= (Set) setsByAnnotationModel.get(model);
+ for (Iterator<IAnnotationModel> maps= setsByAnnotationModel.keySet().iterator(); maps.hasNext();) {
+ IAnnotationModel model= maps.next();
+ Set<Annotation> set= setsByAnnotationModel.get(model);
removeAnnotations(model, set);
}
}
- private void addAnnotations(IAnnotationModel model, Map annotationToPositionMap) {
+ private void addAnnotations(IAnnotationModel model, Map<Annotation, Position> annotationToPositionMap) {
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ame= (IAnnotationModelExtension) model;
ame.replaceAnnotations(new Annotation[0], annotationToPositionMap);
} else {
- for (Iterator elements= annotationToPositionMap.keySet().iterator(); elements.hasNext();) {
- Annotation element= (Annotation) elements.next();
- Position p= (Position) annotationToPositionMap.get(element);
+ for (Iterator<Annotation> elements= annotationToPositionMap.keySet().iterator(); elements.hasNext();) {
+ Annotation element= elements.next();
+ Position p= annotationToPositionMap.get(element);
model.addAnnotation(element, p);
}
}
@@ -162,14 +162,14 @@ public class EditorAccessHighlighter extends Highlighter {
* @param annotations A set containing the annotations to be removed.
* @see Annotation
*/
- private void removeAnnotations(IAnnotationModel model, Set annotations) {
+ private void removeAnnotations(IAnnotationModel model, Set<Annotation> annotations) {
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ame= (IAnnotationModelExtension) model;
Annotation[] annotationArray= new Annotation[annotations.size()];
- ame.replaceAnnotations((Annotation[]) annotations.toArray(annotationArray), Collections.EMPTY_MAP);
+ ame.replaceAnnotations(annotations.toArray(annotationArray), Collections.emptyMap());
} else {
- for (Iterator iter= annotations.iterator(); iter.hasNext();) {
- Annotation element= (Annotation) iter.next();
+ for (Iterator<Annotation> iter= annotations.iterator(); iter.hasNext();) {
+ Annotation element= iter.next();
model.removeAnnotation(element);
}
}
@@ -177,9 +177,9 @@ public class EditorAccessHighlighter extends Highlighter {
@Override
public void removeAll() {
- Set matchSet= fMatchesToAnnotations.keySet();
+ Set<Match> matchSet= fMatchesToAnnotations.keySet();
Match[] matches= new Match[matchSet.size()];
- removeHighlights((Match[]) matchSet.toArray(matches));
+ removeHighlights(matchSet.toArray(matches));
}
@Override
@@ -188,8 +188,8 @@ public class EditorAccessHighlighter extends Highlighter {
return;
IDocument document= null;
ITextFileBuffer textBuffer= (ITextFileBuffer) buffer;
- for (Iterator matches = fMatchesToAnnotations.keySet().iterator(); matches.hasNext();) {
- Match match = (Match) matches.next();
+ for (Iterator<Match> matches = fMatchesToAnnotations.keySet().iterator(); matches.hasNext();) {
+ Match match = matches.next();
document= fEditorAcess.getDocument(match);
if (document != null)
break;
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
index 00fa9f393..30334152f 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
@@ -42,7 +42,7 @@ import org.eclipse.search.ui.text.RemoveAllEvent;
public class EditorAnnotationManager implements ISearchResultListener {
- private ArrayList fResults;
+ private ArrayList<AbstractTextSearchResult> fResults;
private IEditorPart fEditor;
private Highlighter fHighlighter; // initialized lazy
@@ -57,7 +57,7 @@ public class EditorAnnotationManager implements ISearchResultListener {
Assert.isNotNull(editorPart);
fEditor= editorPart;
fHighlighter= null; // lazy initialization
- fResults= new ArrayList(3);
+ fResults= new ArrayList<>(3);
}
@@ -72,7 +72,7 @@ public class EditorAnnotationManager implements ISearchResultListener {
fHighlighter.dispose();
for (int i= 0; i < fResults.size(); i++) {
- ((AbstractTextSearchResult) fResults.get(i)).removeListener(this);
+ fResults.get(i).removeListener(this);
}
fResults.clear();
}
@@ -86,20 +86,20 @@ public class EditorAnnotationManager implements ISearchResultListener {
}
for (int i= 0; i < fResults.size(); i++) {
- AbstractTextSearchResult curr= (AbstractTextSearchResult) fResults.get(i);
+ AbstractTextSearchResult curr= fResults.get(i);
addAnnotations(curr);
}
}
- public synchronized void setSearchResults(List results) {
+ public synchronized void setSearchResults(List<AbstractTextSearchResult> results) {
removeAllAnnotations();
for (int i= 0; i < fResults.size(); i++) {
- ((AbstractTextSearchResult) fResults.get(i)).removeListener(this);
+ fResults.get(i).removeListener(this);
}
fResults.clear();
for (int i= 0; i < results.size(); i++) {
- addSearchResult((AbstractTextSearchResult) results.get(i));
+ addSearchResult(results.get(i));
}
}
@@ -154,18 +154,18 @@ public class EditorAnnotationManager implements ISearchResultListener {
return adapter.isShownInEditor(matches[0], fEditor) ? matches : null;
}
- ArrayList matchesInEditor= null; // lazy initialization
+ ArrayList<Match> matchesInEditor= null; // lazy initialization
for (int i= 0; i < matches.length; i++) {
Match curr= matches[i];
if (adapter.isShownInEditor(curr, fEditor)) {
if (matchesInEditor == null) {
- matchesInEditor= new ArrayList();
+ matchesInEditor= new ArrayList<>();
}
matchesInEditor.add(curr);
}
}
if (matchesInEditor != null) {
- return (Match[]) matchesInEditor.toArray(new Match[matchesInEditor.size()]);
+ return matchesInEditor.toArray(new Match[matchesInEditor.size()]);
}
return null;
}
@@ -230,7 +230,7 @@ public class EditorAnnotationManager implements ISearchResultListener {
removeAllAnnotations();
for (int i= 0; i < fResults.size(); i++) {
- AbstractTextSearchResult curr= (AbstractTextSearchResult) fResults.get(i);
+ AbstractTextSearchResult curr= fResults.get(i);
if (curr != result) {
addAnnotations(curr);
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java
index e4b1e81d2..fab4562db 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java
@@ -34,11 +34,11 @@ import org.eclipse.search2.internal.ui.InternalSearchUI;
public class MarkerHighlighter extends Highlighter {
private IFile fFile;
- private Map fMatchesToAnnotations;
+ private Map<Match, IMarker> fMatchesToAnnotations;
public MarkerHighlighter(IFile file) {
fFile= file;
- fMatchesToAnnotations= new HashMap();
+ fMatchesToAnnotations= new HashMap<>();
}
@Override
@@ -74,7 +74,7 @@ public class MarkerHighlighter extends Highlighter {
IMarker marker= match.isFiltered()
? fFile.createMarker(SearchPlugin.FILTERED_SEARCH_MARKER)
: fFile.createMarker(NewSearchUI.SEARCH_MARKER);
- HashMap attributes= new HashMap(4);
+ HashMap<String, Integer> attributes= new HashMap<>(4);
if (match.getBaseUnit() == Match.UNIT_CHARACTER) {
attributes.put(IMarker.CHAR_START, new Integer(position.getOffset()));
attributes.put(IMarker.CHAR_END, new Integer(position.getOffset()+position.getLength()));
@@ -88,7 +88,7 @@ public class MarkerHighlighter extends Highlighter {
@Override
public void removeHighlights(Match[] matches) {
for (int i= 0; i < matches.length; i++) {
- IMarker marker= (IMarker) fMatchesToAnnotations.remove(matches[i]);
+ IMarker marker= fMatchesToAnnotations.remove(matches[i]);
if (marker != null) {
try {
marker.delete();
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
index 3a28913fc..b5ed04173 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -48,9 +48,9 @@ import org.eclipse.search.ui.text.RemoveAllEvent;
public class PositionTracker implements IQueryListener, ISearchResultListener, IFileBufferListener {
- private Map fMatchesToPositions= new HashMap();
- private Map fMatchesToSearchResults= new HashMap();
- private Map fFileBuffersToMatches= new HashMap();
+ private Map<Match, Position> fMatchesToPositions= new HashMap<>();
+ private Map<Match, AbstractTextSearchResult> fMatchesToSearchResults= new HashMap<>();
+ private Map<ITextFileBuffer, Set<Match>> fFileBuffersToMatches= new HashMap<>();
private interface IFileBufferMatchOperation {
void run(ITextFileBuffer buffer, Match match);
@@ -108,10 +108,10 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
}
private void untrackAll(AbstractTextSearchResult result) {
- Set matchSet= new HashSet(fMatchesToPositions.keySet());
- for (Iterator matches= matchSet.iterator(); matches.hasNext();) {
- Match match= (Match) matches.next();
- AbstractTextSearchResult matchContainer= (AbstractTextSearchResult) fMatchesToSearchResults.get(match);
+ Set<Match> matchSet= new HashSet<>(fMatchesToPositions.keySet());
+ for (Iterator<Match> matches= matchSet.iterator(); matches.hasNext();) {
+ Match match= matches.next();
+ AbstractTextSearchResult matchContainer= fMatchesToSearchResults.get(match);
if (result.equals(matchContainer)) {
ITextFileBuffer fb= getTrackedFileBuffer(result, match.getElement());
if (fb != null) {
@@ -122,7 +122,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
}
private void untrackPosition(ITextFileBuffer fb, Match match) {
- Position position= (Position) fMatchesToPositions.get(match);
+ Position position= fMatchesToPositions.get(match);
if (position != null) {
removeFileBufferMapping(fb, match);
fMatchesToSearchResults.remove(match);
@@ -168,16 +168,16 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
}
private void addFileBufferMapping(ITextFileBuffer fb, Match match) {
- Set matches= (Set) fFileBuffersToMatches.get(fb);
+ Set<Match> matches= fFileBuffersToMatches.get(fb);
if (matches == null) {
- matches= new HashSet();
+ matches= new HashSet<>();
fFileBuffersToMatches.put(fb, matches);
}
matches.add(match);
}
private void removeFileBufferMapping(ITextFileBuffer fb, Match match) {
- Set matches= (Set) fFileBuffersToMatches.get(fb);
+ Set<Match> matches= fFileBuffersToMatches.get(fb);
if (matches != null) {
matches.remove(match);
if (matches.size() == 0)
@@ -198,10 +198,10 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
}
public Position getCurrentPosition(Match match) {
- Position pos= (Position)fMatchesToPositions.get(match);
+ Position pos= fMatchesToPositions.get(match);
if (pos == null)
return pos;
- AbstractTextSearchResult result= (AbstractTextSearchResult) fMatchesToSearchResults.get(match);
+ AbstractTextSearchResult result= fMatchesToSearchResults.get(match);
if (match.getBaseUnit() == Match.UNIT_LINE && result != null) {
ITextFileBuffer fb= getTrackedFileBuffer(result, match.getElement());
if (fb != null) {
@@ -268,11 +268,11 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
private void doForExistingMatchesIn(IFileBuffer buffer, IFileBufferMatchOperation operation) {
if (!(buffer instanceof ITextFileBuffer))
return;
- Set matches= (Set) fFileBuffersToMatches.get(buffer);
+ Set<Match> matches= fFileBuffersToMatches.get(buffer);
if (matches != null) {
- Set matchSet= new HashSet(matches);
- for (Iterator matchIterator= matchSet.iterator(); matchIterator.hasNext();) {
- Match element= (Match) matchIterator.next();
+ Set<Match> matchSet= new HashSet<>(matches);
+ for (Iterator<Match> matchIterator= matchSet.iterator(); matchIterator.hasNext();) {
+ Match element= matchIterator.next();
operation.run((ITextFileBuffer) buffer, element);
}
}
@@ -303,7 +303,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
@Override
public void run(ITextFileBuffer textBuffer, Match match) {
trackCount[0]++;
- AbstractTextSearchResult result= (AbstractTextSearchResult) fMatchesToSearchResults.get(match);
+ AbstractTextSearchResult result= fMatchesToSearchResults.get(match);
untrackPosition(textBuffer, match);
trackPosition(result, textBuffer, match);
}
@@ -324,10 +324,10 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
@Override
public void run(ITextFileBuffer textBuffer, Match match) {
trackCount[0]++;
- Position pos= (Position) fMatchesToPositions.get(match);
+ Position pos= fMatchesToPositions.get(match);
if (pos != null) {
if (pos.isDeleted()) {
- AbstractTextSearchResult result= (AbstractTextSearchResult) fMatchesToSearchResults.get(match);
+ AbstractTextSearchResult result= fMatchesToSearchResults.get(match);
// might be that the containing element has been removed.
if (result != null) {
result.removeMatch(match);
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java
index a35c52d64..65ff7f2cd 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java
@@ -26,15 +26,15 @@ import org.eclipse.search.ui.text.AbstractTextSearchResult;
public class WindowAnnotationManager {
private IWorkbenchWindow fWindow;
- private Map fAnnotationManagers;
+ private Map<IEditorPart, EditorAnnotationManager> fAnnotationManagers;
private IPartListener2 fPartListener;
- private ArrayList fSearchResults;
+ private ArrayList<AbstractTextSearchResult> fSearchResults;
public WindowAnnotationManager(IWorkbenchWindow window) {
fWindow = window;
- fAnnotationManagers = new HashMap();
+ fAnnotationManagers = new HashMap<>();
- fSearchResults= new ArrayList();
+ fSearchResults= new ArrayList<>();
initEditors();
fPartListener= new IPartListener2() {
@@ -83,7 +83,7 @@ public class WindowAnnotationManager {
private void startHighlighting(IEditorPart editor) {
if (editor == null)
return;
- EditorAnnotationManager mgr= (EditorAnnotationManager) fAnnotationManagers.get(editor);
+ EditorAnnotationManager mgr= fAnnotationManagers.get(editor);
if (mgr == null) {
mgr= new EditorAnnotationManager(editor);
fAnnotationManagers.put(editor, mgr);
@@ -94,7 +94,7 @@ public class WindowAnnotationManager {
private void updateHighlighting(IEditorPart editor) {
if (editor == null)
return;
- EditorAnnotationManager mgr= (EditorAnnotationManager) fAnnotationManagers.get(editor);
+ EditorAnnotationManager mgr= fAnnotationManagers.get(editor);
if (mgr != null) {
mgr.doEditorInputChanged();
}
@@ -117,7 +117,7 @@ public class WindowAnnotationManager {
private void stopHighlighting(IEditorPart editor) {
if (editor == null)
return;
- EditorAnnotationManager mgr= (EditorAnnotationManager) fAnnotationManagers.remove(editor);
+ EditorAnnotationManager mgr= fAnnotationManagers.remove(editor);
if (mgr != null)
mgr.dispose();
}
@@ -131,8 +131,8 @@ public class WindowAnnotationManager {
void dispose() {
fWindow.getPartService().removePartListener(fPartListener);
- for (Iterator mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
- EditorAnnotationManager mgr = (EditorAnnotationManager) mgrs.next();
+ for (Iterator<EditorAnnotationManager> mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
+ EditorAnnotationManager mgr = mgrs.next();
mgr.dispose();
}
fAnnotationManagers= null;
@@ -142,8 +142,8 @@ public class WindowAnnotationManager {
boolean alreadyShown= fSearchResults.contains(result);
fSearchResults.add(result);
if (!alreadyShown) {
- for (Iterator mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
- EditorAnnotationManager mgr = (EditorAnnotationManager) mgrs.next();
+ for (Iterator<EditorAnnotationManager> mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
+ EditorAnnotationManager mgr = mgrs.next();
mgr.addSearchResult(result);
}
}
@@ -153,8 +153,8 @@ public class WindowAnnotationManager {
fSearchResults.remove(result);
boolean stillShown= fSearchResults.contains(result);
if (!stillShown) {
- for (Iterator mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
- EditorAnnotationManager mgr = (EditorAnnotationManager) mgrs.next();
+ for (Iterator<EditorAnnotationManager> mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
+ EditorAnnotationManager mgr = mgrs.next();
mgr.removeSearchResult(result);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
index fe12c0aee..10f146c5a 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
@@ -91,7 +91,7 @@ public class TextSearchQueryProviderRegistry {
}
public String[][] getAvailableProviders() {
- ArrayList res= new ArrayList();
+ ArrayList<String[]> res= new ArrayList<>();
res.add(new String[] { SearchMessages.TextSearchQueryProviderRegistry_defaultProviderLabel, "" }); //$NON-NLS-1$
IConfigurationElement[] extensions= Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
@@ -101,6 +101,6 @@ public class TextSearchQueryProviderRegistry {
res.add(new String[] { engine.getAttribute(ATTRIB_LABEL), engine.getAttribute(ATTRIB_ID) });
}
}
- return (String[][]) res.toArray(new String[res.size()][]);
+ return res.toArray(new String[res.size()][]);
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java
index dd01d712e..f55b7e00e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java
@@ -44,7 +44,7 @@ public class FileNamePatternSearchScope extends TextSearchScope {
private final String fDescription;
private final IResource[] fRootElements;
- private final Set fFileNamePatterns;
+ private final Set<String> fFileNamePatterns;
private Matcher fFileNameMatcher;
private boolean fVisitDerived;
@@ -53,7 +53,7 @@ public class FileNamePatternSearchScope extends TextSearchScope {
Assert.isNotNull(description);
fDescription= description;
fRootElements= resources;
- fFileNamePatterns= new HashSet(3);
+ fFileNamePatterns= new HashSet<>(3);
fFileNameMatcher= null;
fVisitDerived= visitDerived;
}
@@ -119,7 +119,7 @@ public class FileNamePatternSearchScope extends TextSearchScope {
if (fFileNamePatterns.isEmpty()) {
pattern= Pattern.compile(".*"); //$NON-NLS-1$
} else {
- String[] patternStrings= (String[]) fFileNamePatterns.toArray(new String[fFileNamePatterns.size()]);
+ String[] patternStrings= fFileNamePatterns.toArray(new String[fFileNamePatterns.size()]);
pattern= PatternConstructor.createPattern(patternStrings, IS_CASE_SENSITIVE_FILESYSTEM);
}
fFileNameMatcher= pattern.matcher(""); //$NON-NLS-1$
@@ -141,7 +141,7 @@ public class FileNamePatternSearchScope extends TextSearchScope {
* @return the description of the scope
*/
public String getFileNamePatternDescription() {
- String[] ext= (String[]) fFileNamePatterns.toArray(new String[fFileNamePatterns.size()]);
+ String[] ext= fFileNamePatterns.toArray(new String[fFileNamePatterns.size()]);
Arrays.sort(ext);
StringBuffer buf= new StringBuffer();
for (int i= 0; i < ext.length; i++) {
@@ -155,21 +155,21 @@ public class FileNamePatternSearchScope extends TextSearchScope {
private static IResource[] removeRedundantEntries(IResource[] elements, boolean includeDerived) {
- ArrayList res= new ArrayList();
+ ArrayList<IResource> res= new ArrayList<>();
for (int i= 0; i < elements.length; i++) {
IResource curr= elements[i];
addToList(res, curr, includeDerived);
}
- return (IResource[])res.toArray(new IResource[res.size()]);
+ return res.toArray(new IResource[res.size()]);
}
- private static void addToList(ArrayList res, IResource curr, boolean includeDerived) {
+ private static void addToList(ArrayList<IResource> res, IResource curr, boolean includeDerived) {
if (!includeDerived && curr.isDerived(IResource.CHECK_ANCESTORS)) {
return;
}
IPath currPath= curr.getFullPath();
for (int k= res.size() - 1; k >= 0 ; k--) {
- IResource other= (IResource) res.get(k);
+ IResource other= res.get(k);
IPath otherPath= other.getFullPath();
if (otherPath.isPrefixOf(currPath)) {
return;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java
index 4f9eea1a7..b4b2ec1c7 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java
@@ -26,7 +26,7 @@ public class FilesOfScopeCalculator implements IResourceProxyVisitor {
private final TextSearchScope fScope;
private final MultiStatus fStatus;
- private ArrayList fFiles;
+ private ArrayList<IResource> fFiles;
public FilesOfScopeCalculator(TextSearchScope scope, MultiStatus status) {
fScope= scope;
@@ -44,7 +44,7 @@ public class FilesOfScopeCalculator implements IResourceProxyVisitor {
}
public IFile[] process() {
- fFiles= new ArrayList();
+ fFiles= new ArrayList<>();
try {
IResource[] roots= fScope.getRoots();
for (int i= 0; i < roots.length; i++) {
@@ -58,7 +58,7 @@ public class FilesOfScopeCalculator implements IResourceProxyVisitor {
fStatus.add(ex.getStatus());
}
}
- return (IFile[]) fFiles.toArray(new IFile[fFiles.size()]);
+ return fFiles.toArray(new IFile[fFiles.size()]);
} finally {
fFiles= null;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
index 82476a460..20ab53caa 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
@@ -100,7 +100,7 @@ public class TextSearchEngineRegistry {
}
public String[][] getAvailableEngines() {
- ArrayList res= new ArrayList();
+ ArrayList<String[]> res= new ArrayList<>();
res.add(new String[] { SearchMessages.TextSearchEngineRegistry_defaulttextsearch_label, "" }); //$NON-NLS-1$
IConfigurationElement[] extensions= Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
@@ -110,6 +110,6 @@ public class TextSearchEngineRegistry {
res.add(new String[] { engine.getAttribute(ATTRIB_LABEL), engine.getAttribute(ATTRIB_ID) });
}
}
- return (String[][]) res.toArray(new String[res.size()][]);
+ return res.toArray(new String[res.size()][]);
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
index b50496b89..8942085da 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
@@ -142,7 +142,7 @@ public class TextSearchVisitor {
private final IFile[] fFiles;
private final int fBegin;
private final int fEnd;
- private final Map fDocumentsInEditors;
+ private final Map<IFile, IDocument> fDocumentsInEditors;
private ReusableMatchAccess fReusableMatchAccess;
private IProgressMonitor fMonitor;
@@ -154,7 +154,7 @@ public class TextSearchVisitor {
* @param end one past the last element in the array to process
* @param documentsInEditors a map from IFile to IDocument for all open, dirty editors
*/
- public TextSearchJob(IFile[] files, int begin, int end, Map documentsInEditors) {
+ public TextSearchJob(IFile[] files, int begin, int end, Map<IFile, IDocument> documentsInEditors) {
super(files[begin].getName());
setSystem(true);
fFiles = files;
@@ -185,7 +185,7 @@ public class TextSearchVisitor {
return fMonitor;
}
- public Map getDocumentsInEditors() {
+ public Map<IFile, IDocument> getDocumentsInEditors() {
return fDocumentsInEditors;
}
@@ -281,7 +281,7 @@ public class TextSearchVisitor {
monitorUpdateJob.schedule();
try {
fCollector.beginReporting();
- Map documentsInEditors= PlatformUI.isWorkbenchRunning() ? evalNonFileBufferDocuments() : Collections.EMPTY_MAP;
+ Map<IFile, IDocument> documentsInEditors= PlatformUI.isWorkbenchRunning() ? evalNonFileBufferDocuments() : Collections.emptyMap();
int filesPerJob = (files.length + jobCount - 1) / jobCount;
for (int first= 0; first < files.length; first += filesPerJob) {
int end= Math.min(files.length, first + filesPerJob);
@@ -324,8 +324,8 @@ public class TextSearchVisitor {
*
* @return a map from IFile to IDocument for all open, dirty editors
*/
- private Map evalNonFileBufferDocuments() {
- Map result= new HashMap();
+ private Map<IFile, IDocument> evalNonFileBufferDocuments() {
+ Map<IFile, IDocument> result= new HashMap<>();
IWorkbench workbench= SearchPlugin.getDefault().getWorkbench();
IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
for (int i= 0; i < windows.length; i++) {
@@ -343,7 +343,7 @@ public class TextSearchVisitor {
return result;
}
- private void evaluateTextEditor(Map result, IEditorPart ep) {
+ private void evaluateTextEditor(Map<IFile, IDocument> result, IEditorPart ep) {
IEditorInput input= ep.getEditorInput();
if (input instanceof IFileEditorInput) {
IFile file= ((IFileEditorInput) input).getFile();
@@ -497,8 +497,8 @@ public class TextSearchVisitor {
return message;
}
- private IDocument getOpenDocument(IFile file, Map documentsInEditors) {
- IDocument document= (IDocument)documentsInEditors.get(file);
+ private IDocument getOpenDocument(IFile file, Map<IFile, IDocument> documentsInEditors) {
+ IDocument document= documentsInEditors.get(file);
if (document == null) {
ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager();
ITextFileBuffer textFileBuffer= bufferManager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
index 696ad7510..31b56c327 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -109,7 +109,7 @@ public class CopyToClipboardAction extends Action {
IBaseLabelProvider labelProvider= fViewer.getLabelProvider();
String lineDelim= System.getProperty("line.separator"); //$NON-NLS-1$
StringBuffer buf= new StringBuffer();
- Iterator iter= getSelection();
+ Iterator<?> iter= getSelection();
while (iter.hasNext()) {
if (buf.length() > 0) {
buf.append(lineDelim);
@@ -141,11 +141,11 @@ public class CopyToClipboardAction extends Action {
}
}
- private Iterator getSelection() {
+ private Iterator<?> getSelection() {
ISelection s= fViewer.getSelection();
if (s instanceof IStructuredSelection)
return ((IStructuredSelection)s).iterator();
- return Collections.EMPTY_LIST.iterator();
+ return Collections.emptyList().iterator();
}
private void copyToClipboard(Clipboard clipboard, String str, Shell shell) {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java
index 8740ee841..068992c47 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java
@@ -75,10 +75,10 @@ public class OpenSearchDialogPageAction implements IWorkbenchWindowPulldownDeleg
}
private void fillMenu(final Menu localMenu) {
- List pageDescriptors= SearchPlugin.getDefault().getSearchPageDescriptors();
+ List<SearchPageDescriptor> pageDescriptors= SearchPlugin.getDefault().getSearchPageDescriptors();
int accelerator= 1;
- for (Iterator iter= pageDescriptors.iterator(); iter.hasNext();) {
- SearchPageDescriptor desc= (SearchPageDescriptor) iter.next();
+ for (Iterator<SearchPageDescriptor> iter= pageDescriptors.iterator(); iter.hasNext();) {
+ SearchPageDescriptor desc= iter.next();
if (!WorkbenchActivityHelper.filterItem(desc) && desc.isEnabled()) {
SearchPageAction action= new SearchPageAction(fWorkbenchWindow, desc);
addToMenu(localMenu, action, accelerator++);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java
index e30dfd45a..0d1622be6 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -78,18 +78,18 @@ class RemovePotentialMatchesAction extends Action {
if (size <= 0)
return null;
- ArrayList markers= new ArrayList(size * 3);
- Iterator iter= selection.iterator();
+ ArrayList<IMarker> markers= new ArrayList<>(size * 3);
+ Iterator<?> iter= selection.iterator();
while (iter.hasNext()) {
SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- Iterator entryIter= entry.getMarkers().iterator();
+ Iterator<IMarker> entryIter= entry.getMarkers().iterator();
while (entryIter.hasNext()) {
- IMarker marker= (IMarker)entryIter.next();
+ IMarker marker= entryIter.next();
if (marker.getAttribute(SearchUI.POTENTIAL_MATCH, false))
markers.add(marker);
}
}
- return (IMarker[])markers.toArray(new IMarker[markers.size()]);
+ return markers.toArray(new IMarker[markers.size()]);
}
private boolean usePluralLabel() {
@@ -104,12 +104,12 @@ class RemovePotentialMatchesAction extends Action {
return false;
int markerCount= 0;
- Iterator iter= selection.iterator();
+ Iterator<?> iter= selection.iterator();
while (iter.hasNext()) {
SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- Iterator entryIter= entry.getMarkers().iterator();
+ Iterator<IMarker> entryIter= entry.getMarkers().iterator();
while (entryIter.hasNext()) {
- IMarker marker= (IMarker)entryIter.next();
+ IMarker marker= entryIter.next();
if (marker.getAttribute(SearchUI.POTENTIAL_MATCH, false)) {
markerCount++;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java
index c60a0aaa4..996f7bc99 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -73,15 +73,15 @@ class RemoveResultAction extends Action {
int size= selection.size();
if (size <= 0)
return null;
- ArrayList markers= new ArrayList(size * 3);
+ ArrayList<IMarker> markers= new ArrayList<>(size * 3);
int markerCount= 0;
- Iterator iter= selection.iterator();
+ Iterator<?> iter= selection.iterator();
while (iter.hasNext()) {
SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
markerCount += entry.getMatchCount();
markers.addAll(entry.getMarkers());
}
- return (IMarker[])markers.toArray(new IMarker[markerCount]);
+ return markers.toArray(new IMarker[markerCount]);
}
private boolean usePluralLabel() {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
index 0546843ff..8e74e8a6e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -37,15 +37,15 @@ class ResourceToItemsMapper {
private static final int NUMBER_LIST_REUSE= 10;
- // map from resource to item
- private HashMap fResourceToItem;
- private Stack fReuseLists;
+ // map from IResource to Item | List<Item>
+ private HashMap<IResource, Object> fResourceToItem;
+ private Stack<List<Item>> fReuseLists;
private ContentViewer fContentViewer;
public ResourceToItemsMapper(ContentViewer viewer) {
- fResourceToItem= new HashMap();
- fReuseLists= new Stack();
+ fResourceToItem= new HashMap<>();
+ fReuseLists= new Stack<>();
fContentViewer= viewer;
}
@@ -61,9 +61,10 @@ class ResourceToItemsMapper {
} else if (obj instanceof Item) {
updateItem((Item) obj);
} else { // List of Items
- List list= (List) obj;
+ @SuppressWarnings("unchecked")
+ List<Item> list= (List<Item>) obj;
for (int k= 0; k < list.size(); k++) {
- updateItem((Item) list.get(k));
+ updateItem(list.get(k));
}
}
}
@@ -101,13 +102,14 @@ class ResourceToItemsMapper {
fResourceToItem.put(resource, item);
} else if (existingMapping instanceof Item) {
if (existingMapping != item) {
- List list= getNewList();
- list.add(existingMapping);
+ List<Item> list= getNewList();
+ list.add((Item) existingMapping);
list.add(item);
fResourceToItem.put(resource, list);
}
} else { // List
- List list= (List) existingMapping;
+ @SuppressWarnings("unchecked")
+ List<Item> list= (List<Item>) existingMapping;
if (!list.contains(item)) {
list.add(item);
}
@@ -129,7 +131,8 @@ class ResourceToItemsMapper {
} else if (existingMapping instanceof Item) {
fResourceToItem.remove(resource);
} else { // List
- List list= (List) existingMapping;
+ @SuppressWarnings("unchecked")
+ List<Item> list= (List<Item>) existingMapping;
list.remove(item);
if (list.isEmpty()) {
fResourceToItem.remove(list);
@@ -139,14 +142,14 @@ class ResourceToItemsMapper {
}
}
- private List getNewList() {
+ private List<Item> getNewList() {
if (!fReuseLists.isEmpty()) {
- return (List) fReuseLists.pop();
+ return fReuseLists.pop();
}
- return new ArrayList(2);
+ return new ArrayList<>(2);
}
- private void releaseList(List list) {
+ private void releaseList(List<Item> list) {
if (fReuseLists.size() < NUMBER_LIST_REUSE) {
fReuseLists.push(list);
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
index 279e97106..5596d58cb 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
@@ -125,7 +125,7 @@ public class ScopePart {
IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager();
if (lruWorkingSetNames != null) {
- Set existingWorkingSets= new HashSet(lruWorkingSetNames.length);
+ Set<IWorkingSet> existingWorkingSets= new HashSet<>(lruWorkingSetNames.length);
for (int i= 0; i < lruWorkingSetNames.length; i++) {
IWorkingSet workingSet= getWorkingSet(workingSetManager, lruWorkingSetNames[i]);
if (workingSet != null) {
@@ -133,7 +133,7 @@ public class ScopePart {
}
}
if (!existingWorkingSets.isEmpty()) {
- return (IWorkingSet[]) existingWorkingSets.toArray(new IWorkingSet[existingWorkingSets.size()]);
+ return existingWorkingSets.toArray(new IWorkingSet[existingWorkingSets.size()]);
}
} else {
// Backward compatibility
@@ -230,7 +230,7 @@ public class ScopePart {
Assert.isNotNull(workingSets);
setSelectedScope(ISearchPageContainer.WORKING_SET_SCOPE);
fWorkingSets= null;
- Set existingWorkingSets= new HashSet(workingSets.length);
+ Set<IWorkingSet> existingWorkingSets= new HashSet<>(workingSets.length);
for (int i= 0; i < workingSets.length; i++) {
String name= workingSets[i].getName();
IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
@@ -238,7 +238,7 @@ public class ScopePart {
existingWorkingSets.add(workingSet);
}
if (!existingWorkingSets.isEmpty())
- fWorkingSets= (IWorkingSet[]) existingWorkingSets.toArray(new IWorkingSet[existingWorkingSets.size()]);
+ fWorkingSets= existingWorkingSets.toArray(new IWorkingSet[existingWorkingSets.size()]);
saveState();
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
index e9c4d970b..2796e5505 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,7 +42,7 @@ public class Search extends Object {
private ImageDescriptor fImageDescriptor;
private ILabelProvider fLabelProvider;
private ISelection fSelection;
- private ArrayList fResults;
+ private ArrayList<SearchResultViewEntry> fResults;
private IAction fGotoMarkerAction;
private IContextMenuContributor fContextMenuContributor;
private IActionGroupFactory fActionGroupFactory;
@@ -125,15 +125,15 @@ public class Search extends Object {
int getItemCount() {
int count= 0;
- Iterator iter= getResults().iterator();
+ Iterator<SearchResultViewEntry> iter= getResults().iterator();
while (iter.hasNext())
count += ((ISearchResultViewEntry)iter.next()).getMatchCount();
return count;
}
- List getResults() {
+ List<SearchResultViewEntry> getResults() {
if (fResults == null)
- return new ArrayList();
+ return new ArrayList<>();
return fResults;
}
@@ -161,9 +161,9 @@ public class Search extends Object {
}
void backupMarkers() {
- Iterator iter= getResults().iterator();
+ Iterator<SearchResultViewEntry> iter= getResults().iterator();
while (iter.hasNext()) {
- ((SearchResultViewEntry)iter.next()).backupMarkers();
+ iter.next().backupMarkers();
}
}
@@ -195,7 +195,7 @@ public class Search extends Object {
fResults= null;
}
- void setResults(ArrayList results) {
+ void setResults(ArrayList<SearchResultViewEntry> results) {
Assert.isNotNull(results);
fResults= results;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
index dabc2c4ac..bde9ccc08 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -143,7 +143,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
private String fInitialPageId;
private int fCurrentIndex;
- private List fDescriptors;
+ private List<SearchPageDescriptor> fDescriptors;
private Point fMinSize;
private ScopePart[] fScopeParts;
private boolean fLastEnableState;
@@ -197,8 +197,8 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
return new String[] { name };
}
} else if (selection instanceof IStructuredSelection) {
- HashSet res= new HashSet();
- for (Iterator iter= ((IStructuredSelection) selection).iterator(); iter.hasNext();) {
+ HashSet<String> res= new HashSet<>();
+ for (Iterator<?> iter= ((IStructuredSelection) selection).iterator(); iter.hasNext();) {
Object curr= iter.next();
if (curr instanceof IWorkingSet) {
IWorkingSet workingSet= (IWorkingSet) curr;
@@ -227,7 +227,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
}
}
if (!res.isEmpty()) {
- return (String[]) res.toArray(new String[res.size()]);
+ return res.toArray(new String[res.size()]);
}
}
return new String[0];
@@ -307,10 +307,10 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
}
private void handleCustomizePressed() {
- List input= SearchPlugin.getDefault().getSearchPageDescriptors();
+ List<SearchPageDescriptor> input= SearchPlugin.getDefault().getSearchPageDescriptors();
input= filterByActivities(input);
- final ArrayList createdImages= new ArrayList(input.size());
+ final ArrayList<Image> createdImages= new ArrayList<>(input.size());
ILabelProvider labelProvider= new LabelProvider() {
@Override
public String getText(Object element) {
@@ -393,10 +393,10 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
destroyImages(createdImages);
}
- private List filterByActivities(List input) {
- ArrayList filteredList= new ArrayList(input.size());
- for (Iterator descriptors= input.iterator(); descriptors.hasNext();) {
- SearchPageDescriptor descriptor= (SearchPageDescriptor) descriptors.next();
+ private List<SearchPageDescriptor> filterByActivities(List<SearchPageDescriptor> input) {
+ ArrayList<SearchPageDescriptor> filteredList= new ArrayList<>(input.size());
+ for (Iterator<SearchPageDescriptor> descriptors= input.iterator(); descriptors.hasNext();) {
+ SearchPageDescriptor descriptor= descriptors.next();
if (!WorkbenchActivityHelper.filterItem(descriptor))
filteredList.add(descriptor);
@@ -404,10 +404,10 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
return filteredList;
}
- private void destroyImages(List images) {
- Iterator iter= images.iterator();
+ private void destroyImages(List<Image> images) {
+ Iterator<Image> iter= images.iterator();
while (iter.hasNext()) {
- Image image= (Image)iter.next();
+ Image image= iter.next();
if (image != null && !image.isDisposed())
image.dispose();
}
@@ -544,7 +544,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
}
private SearchPageDescriptor getDescriptorAt(int index) {
- return (SearchPageDescriptor) fDescriptors.get(index);
+ return fDescriptors.get(index);
}
private Point getMinSize() {
@@ -616,7 +616,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
int level= ISearchPageScoreComputer.LOWEST;
int size= fDescriptors.size();
for (int i= 0; i < size; i++) {
- SearchPageDescriptor descriptor= (SearchPageDescriptor) fDescriptors.get(i);
+ SearchPageDescriptor descriptor= fDescriptors.get(i);
if (fInitialPageId != null && fInitialPageId.equals(descriptor.getId()))
return i;
@@ -834,7 +834,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
@Override
public boolean close() {
for (int i= 0; i < fDescriptors.size(); i++) {
- SearchPageDescriptor desc= (SearchPageDescriptor) fDescriptors.get(i);
+ SearchPageDescriptor desc= fDescriptors.get(i);
desc.dispose();
}
return super.close();
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java
index 1fe05775b..ac1fe2f1b 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java
@@ -59,11 +59,11 @@ class SearchDropDownAction extends Action implements IMenuCreator {
fMenu= new Menu(parent);
boolean checkedOne= false;
- Iterator iter= SearchManager.getDefault().getPreviousSearches().iterator();
+ Iterator<Search> iter= SearchManager.getDefault().getPreviousSearches().iterator();
Search selected= SearchManager.getDefault().getCurrentSearch();
int i= 0;
while (iter.hasNext() && i++ < RESULTS_IN_DROP_DOWN) {
- Search search= (Search)iter.next();
+ Search search= iter.next();
ShowSearchAction action= new ShowSearchAction(search);
action.setChecked(search.equals(selected));
if (search.equals(selected))
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
index 253bf416e..0eb749fcc 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -58,8 +58,8 @@ public class SearchManager implements IResourceChangeListener {
SearchPlugin.getWorkspace().addResourceChangeListener(this);
}
- private HashSet fListeners= new HashSet();
- private LinkedList fPreviousSearches= new LinkedList();
+ private HashSet<SearchResultViewer> fListeners= new HashSet<>();
+ private LinkedList<Search> fPreviousSearches= new LinkedList<>();
private boolean fIsRemoveAll= false;
public static synchronized SearchManager getDefault() {
@@ -76,17 +76,17 @@ public class SearchManager implements IResourceChangeListener {
* Returns the list with previous searches (ISearch).
* @return previous searches
*/
- LinkedList getPreviousSearches() {
+ LinkedList<Search> getPreviousSearches() {
return fPreviousSearches;
}
/**
* Returns the list with current (last) results
* @return the current results
*/
- ArrayList getCurrentResults() {
+ ArrayList<SearchResultViewEntry> getCurrentResults() {
if (fCurrentSearch == null)
- return new ArrayList(0);
- return (ArrayList)fCurrentSearch.getResults();
+ return new ArrayList<>(0);
+ return (ArrayList<SearchResultViewEntry>)fCurrentSearch.getResults();
}
public Search getCurrentSearch() {
@@ -118,13 +118,13 @@ public class SearchManager implements IResourceChangeListener {
}
// clear searches
- fPreviousSearches= new LinkedList();
+ fPreviousSearches= new LinkedList<>();
fCurrentSearch= null;
// update viewers
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext()) {
- SearchResultViewer viewer= (SearchResultViewer)iter.next();
+ SearchResultViewer viewer= iter.next();
handleAllSearchesRemoved(viewer);
}
}
@@ -177,15 +177,15 @@ public class SearchManager implements IResourceChangeListener {
monitor.worked(10);
// add search markers
- Iterator iter= getCurrentResults().iterator();
- ArrayList emptyEntries= new ArrayList(10);
+ Iterator<SearchResultViewEntry> iter= getCurrentResults().iterator();
+ ArrayList<SearchResultViewEntry> emptyEntries= new ArrayList<>(10);
boolean filesChanged= false;
boolean filesDeleted= false;
IGroupByKeyComputer groupByKeyComputer= getCurrentSearch().getGroupByKeyComputer();
while (iter.hasNext()) {
monitor.worked(1);
- SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- Iterator attrPerMarkerIter= entry.getAttributesPerMarker().iterator();
+ SearchResultViewEntry entry= iter.next();
+ Iterator<Map<String, Object>> attrPerMarkerIter= entry.getAttributesPerMarker().iterator();
entry.clearMarkerList();
if (entry.getResource() == null || !entry.getResource().exists()) {
emptyEntries.add(entry);
@@ -201,7 +201,7 @@ public class SearchManager implements IResourceChangeListener {
continue;
}
try {
- newMarker.setAttributes((Map)attrPerMarkerIter.next());
+ newMarker.setAttributes(attrPerMarkerIter.next());
if (groupByKeyComputer !=null && groupByKeyComputer.computeGroupByKey(newMarker) == null) {
filesDeleted= true;
newMarker.delete();
@@ -246,11 +246,11 @@ public class SearchManager implements IResourceChangeListener {
}
// update viewers
- iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter2= fListeners.iterator();
if (display != null && !display.isDisposed()) {
final Viewer visibleViewer= ((SearchResultView)SearchUI.getSearchResultView()).getViewer();
- while (iter.hasNext()) {
- final SearchResultViewer viewer= (SearchResultViewer)iter.next();
+ while (iter2.hasNext()) {
+ final SearchResultViewer viewer= iter2.next();
display.syncExec(new Runnable() {
@Override
public void run() {
@@ -296,12 +296,12 @@ public class SearchManager implements IResourceChangeListener {
SearchPlugin.getWorkspace().removeResourceChangeListener(this);
// Clear the viewers
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
Display display= getDisplay();
if (display != null && !display.isDisposed()) {
final Viewer visibleViewer= ((SearchResultView)SearchUI.getSearchResultView()).getViewer();
while (iter.hasNext()) {
- final SearchResultViewer viewer= (SearchResultViewer)iter.next();
+ final SearchResultViewer viewer= iter.next();
display.syncExec(new Runnable() {
@Override
public void run() {
@@ -330,7 +330,7 @@ public class SearchManager implements IResourceChangeListener {
}
}
- void searchFinished(ArrayList results) {
+ void searchFinished(ArrayList<SearchResultViewEntry> results) {
Assert.isNotNull(results);
getCurrentSearch().setResults(results);
@@ -369,9 +369,9 @@ public class SearchManager implements IResourceChangeListener {
return;
}
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext())
- ((SearchResultViewer)iter.next()).getControl().setRedraw(false);
+ iter.next().getControl().setRedraw(false);
for (int i=0; i < markerDeltas.length; i++) {
handleSearchMarkerChanged(markerDeltas[i]);
@@ -379,7 +379,7 @@ public class SearchManager implements IResourceChangeListener {
iter= fListeners.iterator();
while (iter.hasNext())
- ((SearchResultViewer)iter.next()).getControl().setRedraw(true);
+ iter.next().getControl().setRedraw(true);
}
@@ -395,15 +395,15 @@ public class SearchManager implements IResourceChangeListener {
private void handleRemoveAll() {
if (fCurrentSearch != null)
fCurrentSearch.removeResults();
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext())
- ((SearchResultViewer)iter.next()).handleRemoveAll();
+ iter.next().handleRemoveAll();
}
private void handleNewSearchResult() {
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext()) {
- SearchResultViewer viewer= (SearchResultViewer)iter.next();
+ SearchResultViewer viewer= iter.next();
viewer.setInput(getCurrentResults());
}
}
@@ -423,14 +423,14 @@ public class SearchManager implements IResourceChangeListener {
entry.remove(marker);
if (entry.getMatchCount() == 0) {
getCurrentResults().remove(entry);
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext())
- ((SearchResultViewer)iter.next()).handleRemoveMatch(entry);
+ iter.next().handleRemoveMatch(entry);
}
else {
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext())
- ((SearchResultViewer)iter.next()).handleUpdateMatch(entry, true);
+ iter.next().handleUpdateMatch(entry, true);
}
}
}
@@ -438,16 +438,16 @@ public class SearchManager implements IResourceChangeListener {
private void handleUpdateMatch(IMarker marker) {
SearchResultViewEntry entry= findEntry(marker);
if (entry != null) {
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext())
- ((SearchResultViewer)iter.next()).handleUpdateMatch(entry, false);
+ iter.next().handleUpdateMatch(entry, false);
}
}
private SearchResultViewEntry findEntry(IMarker marker) {
- Iterator entries= getCurrentResults().iterator();
+ Iterator<SearchResultViewEntry> entries= getCurrentResults().iterator();
while (entries.hasNext()) {
- SearchResultViewEntry entry= (SearchResultViewEntry)entries.next();
+ SearchResultViewEntry entry= entries.next();
if (entry.contains(marker))
return entry;
}
@@ -479,9 +479,9 @@ public class SearchManager implements IResourceChangeListener {
if (getCurrentSearch() != null) {
handleSearchMarkersChanged(markerDeltas);
// update title and actions
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext()) {
- SearchResultViewer viewer= (SearchResultViewer)iter.next();
+ SearchResultViewer viewer= iter.next();
viewer.enableActions();
viewer.updateTitle();
}
@@ -495,7 +495,7 @@ public class SearchManager implements IResourceChangeListener {
* @return the display
*/
private Display getDisplay() {
- Iterator iter= fListeners.iterator();
+ Iterator<SearchResultViewer> iter= fListeners.iterator();
while (iter.hasNext()) {
Control control= ((Viewer)iter.next()).getControl();
if (control != null && !control.isDisposed()) {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
index 36c2dfa23..3c59e8b5d 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -47,7 +47,7 @@ import org.eclipse.search.ui.ISearchPageScoreComputer;
/**
* Proxy that represents a search page.
*/
-class SearchPageDescriptor implements IPluginContribution, Comparable {
+class SearchPageDescriptor implements IPluginContribution, Comparable<SearchPageDescriptor> {
public final static String PAGE_TAG= "page"; //$NON-NLS-1$
private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
@@ -69,7 +69,7 @@ class SearchPageDescriptor implements IPluginContribution, Comparable {
private final static String STORE_ENABLED_PAGE_IDS= SECTION_ID + ".enabledPageIds"; //$NON-NLS-1$
private final static String STORE_PROCESSED_PAGE_IDS= SECTION_ID + ".processedPageIds"; //$NON-NLS-1$
- private static List fgEnabledPageIds;
+ private static List<String> fgEnabledPageIds;
private static class ExtensionScorePair {
public String extension;
@@ -81,7 +81,7 @@ class SearchPageDescriptor implements IPluginContribution, Comparable {
}
private IConfigurationElement fElement;
- private List fExtensionScorePairs;
+ private List<ExtensionScorePair> fExtensionScorePairs;
private int fWildcardScore= ISearchPageScoreComputer.UNKNOWN;
private ISearchPage fCreatedPage;
@@ -232,7 +232,7 @@ class SearchPageDescriptor implements IPluginContribution, Comparable {
}
static void setEnabled(Object[] enabledDescriptors) {
- fgEnabledPageIds= new ArrayList(5);
+ fgEnabledPageIds= new ArrayList<>(5);
for (int i= 0; i < enabledDescriptors.length; i++) {
if (enabledDescriptors[i] instanceof SearchPageDescriptor)
fgEnabledPageIds.add(((SearchPageDescriptor)enabledDescriptors[i]).getId());
@@ -240,28 +240,28 @@ class SearchPageDescriptor implements IPluginContribution, Comparable {
storeEnabledPageIds();
}
- private static List getEnabledPageIds() {
+ private static List<String> getEnabledPageIds() {
if (fgEnabledPageIds == null) {
- List descriptors= SearchPlugin.getDefault().getSearchPageDescriptors();
+ List<SearchPageDescriptor> descriptors= SearchPlugin.getDefault().getSearchPageDescriptors();
String[] enabledPageIds= getDialogSettings().getArray(STORE_ENABLED_PAGE_IDS);
if (enabledPageIds == null)
- fgEnabledPageIds= new ArrayList(descriptors.size());
+ fgEnabledPageIds= new ArrayList<>(descriptors.size());
else
- fgEnabledPageIds= new ArrayList(Arrays.asList(enabledPageIds));
+ fgEnabledPageIds= new ArrayList<>(Arrays.asList(enabledPageIds));
- List processedPageIds;
+ List<String> processedPageIds;
String[] processedPageIdsArr= getDialogSettings().getArray(STORE_PROCESSED_PAGE_IDS);
if (processedPageIdsArr == null)
- processedPageIds= new ArrayList(descriptors.size());
+ processedPageIds= new ArrayList<>(descriptors.size());
else
- processedPageIds= new ArrayList(Arrays.asList(processedPageIdsArr));
+ processedPageIds= new ArrayList<>(Arrays.asList(processedPageIdsArr));
// Enable pages based on contribution
- Iterator iter= descriptors.iterator();
+ Iterator<SearchPageDescriptor> iter= descriptors.iterator();
while (iter.hasNext()) {
- SearchPageDescriptor desc= (SearchPageDescriptor)iter.next();
+ SearchPageDescriptor desc= iter.next();
if (processedPageIds.contains(desc.getId()))
continue;
@@ -270,14 +270,14 @@ class SearchPageDescriptor implements IPluginContribution, Comparable {
fgEnabledPageIds.add(desc.getId());
}
- getDialogSettings().put(STORE_PROCESSED_PAGE_IDS, (String[])processedPageIds.toArray(new String[processedPageIds.size()]));
+ getDialogSettings().put(STORE_PROCESSED_PAGE_IDS, processedPageIds.toArray(new String[processedPageIds.size()]));
storeEnabledPageIds();
}
return fgEnabledPageIds;
}
private static void storeEnabledPageIds() {
- getDialogSettings().put(STORE_ENABLED_PAGE_IDS, (String[])fgEnabledPageIds.toArray(new String[fgEnabledPageIds.size()]));
+ getDialogSettings().put(STORE_ENABLED_PAGE_IDS, fgEnabledPageIds.toArray(new String[fgEnabledPageIds.size()]));
}
private static IDialogSettings getDialogSettings() {
@@ -289,15 +289,12 @@ class SearchPageDescriptor implements IPluginContribution, Comparable {
return section;
}
- /*
- * Implements a method from IComparable
- */
@Override
- public int compareTo(Object o) {
+ public int compareTo(SearchPageDescriptor o) {
int myPos= getTabPosition();
- int objsPos= ((SearchPageDescriptor)o).getTabPosition();
+ int objsPos= o.getTabPosition();
if (myPos == Integer.MAX_VALUE && objsPos == Integer.MAX_VALUE || myPos == objsPos)
- return getLabel().compareTo(((SearchPageDescriptor)o).getLabel());
+ return getLabel().compareTo(o.getLabel());
return myPos - objsPos;
}
@@ -338,7 +335,7 @@ class SearchPageDescriptor implements IPluginContribution, Comparable {
int size= fExtensionScorePairs.size();
for (int i= 0; i < size; i++) {
- ExtensionScorePair p= (ExtensionScorePair)fExtensionScorePairs.get(i);
+ ExtensionScorePair p= fExtensionScorePairs.get(i);
if (extension.equals(p.extension))
return p.score;
}
@@ -347,7 +344,7 @@ class SearchPageDescriptor implements IPluginContribution, Comparable {
}
private void readExtensionScorePairs() {
- fExtensionScorePairs= new ArrayList(3);
+ fExtensionScorePairs= new ArrayList<>(3);
String content= fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
if (content == null)
return;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
index 538a67ecc..3702c32cb 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
@@ -85,8 +85,8 @@ public class SearchPlugin extends AbstractUIPlugin {
private static SearchPlugin fgSearchPlugin;
- private List fPageDescriptors;
- private List fSorterDescriptors;
+ private List<SearchPageDescriptor> fPageDescriptors;
+ private List<SorterDescriptor> fSorterDescriptors;
private TextSearchEngineRegistry fTextSearchEngineRegistry;
private TextSearchQueryProviderRegistry fTextSearchQueryProviderRegistry;
@@ -226,7 +226,7 @@ public class SearchPlugin extends AbstractUIPlugin {
/**
* @return Returns all search pages contributed to the workbench.
*/
- public List getSearchPageDescriptors() {
+ public List<SearchPageDescriptor> getSearchPageDescriptors() {
if (fPageDescriptors == null) {
IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(NewSearchUI.PLUGIN_ID, SEARCH_PAGE_EXTENSION_POINT);
fPageDescriptors= createSearchPageDescriptors(elements);
@@ -238,11 +238,11 @@ public class SearchPlugin extends AbstractUIPlugin {
* @param pageId the page id or <code>null</code>
* @return all descriptors of the enabled search pages, plus the descriptor for the given page id
*/
- public List getEnabledSearchPageDescriptors(String pageId) {
- Iterator iter= getSearchPageDescriptors().iterator();
- List enabledDescriptors= new ArrayList(5);
+ public List<SearchPageDescriptor> getEnabledSearchPageDescriptors(String pageId) {
+ Iterator<SearchPageDescriptor> iter= getSearchPageDescriptors().iterator();
+ List<SearchPageDescriptor> enabledDescriptors= new ArrayList<>(5);
while (iter.hasNext()) {
- SearchPageDescriptor desc= (SearchPageDescriptor)iter.next();
+ SearchPageDescriptor desc= iter.next();
if (desc.isEnabled() || desc.getId().equals(pageId))
enabledDescriptors.add(desc);
}
@@ -261,9 +261,9 @@ public class SearchPlugin extends AbstractUIPlugin {
Search currentSearch= SearchManager.getDefault().getCurrentSearch();
if (currentSearch != null) {
String pageId= currentSearch.getPageId();
- Iterator iter= getSearchPageDescriptors().iterator();
+ Iterator<SearchPageDescriptor> iter= getSearchPageDescriptors().iterator();
while (iter.hasNext()) {
- SearchPageDescriptor desc= (SearchPageDescriptor)iter.next();
+ SearchPageDescriptor desc= iter.next();
if (desc.getId().equals(pageId)) {
String helpId= desc.getSearchViewHelpContextId();
if (helpId == null)
@@ -280,8 +280,8 @@ public class SearchPlugin extends AbstractUIPlugin {
* @param elements the configuration elements
* @return the created SearchPageDescriptor
*/
- private List createSearchPageDescriptors(IConfigurationElement[] elements) {
- List result= new ArrayList(5);
+ private List<SearchPageDescriptor> createSearchPageDescriptors(IConfigurationElement[] elements) {
+ List<SearchPageDescriptor> result= new ArrayList<>(5);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
if (SearchPageDescriptor.PAGE_TAG.equals(element.getName())) {
@@ -296,7 +296,7 @@ public class SearchPlugin extends AbstractUIPlugin {
/**
* @return Returns all sorters contributed to the workbench.
*/
- public List getSorterDescriptors() {
+ public List<SorterDescriptor> getSorterDescriptors() {
if (fSorterDescriptors == null) {
IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(NewSearchUI.PLUGIN_ID, SORTER_EXTENSION_POINT);
fSorterDescriptors= createSorterDescriptors(elements);
@@ -324,8 +324,8 @@ public class SearchPlugin extends AbstractUIPlugin {
* @param elements the configuration elements
* @return the created SorterDescriptor
*/
- private List createSorterDescriptors(IConfigurationElement[] elements) {
- List result= new ArrayList(5);
+ private List<SorterDescriptor> createSorterDescriptors(IConfigurationElement[] elements) {
+ List<SorterDescriptor> result= new ArrayList<>(5);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
if (SorterDescriptor.SORTER_TAG.equals(element.getName()))
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
index 01c47faad..716c1321b 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -59,15 +59,12 @@ public class SearchPreferencePage extends FieldEditorPreferencePage implements I
private BooleanFieldEditor fIgnorePotentialMatchesCheckbox;
- private static class PerspectiveDescriptorComparator implements Comparator {
+ private static class PerspectiveDescriptorComparator implements Comparator<IPerspectiveDescriptor> {
@Override
- public int compare(Object o1, Object o2) {
- if (o1 instanceof IPerspectiveDescriptor && o2 instanceof IPerspectiveDescriptor) {
- String id1= ((IPerspectiveDescriptor)o1).getLabel();
- String id2= ((IPerspectiveDescriptor)o2).getLabel();
- return Collator.getInstance().compare(id1, id2);
- }
- return 0;
+ public int compare(IPerspectiveDescriptor o1, IPerspectiveDescriptor o2) {
+ String id1= o1.getLabel();
+ String id2= o2.getLabel();
+ return Collator.getInstance().compare(id1, id2);
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
index 953f26e69..f05bdcf72 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -57,10 +57,10 @@ import org.eclipse.search.ui.ISearchResultView;
public class SearchResultView extends ViewPart implements ISearchResultView {
- private static Map fgLabelProviders= new HashMap(5);
+ private static Map<String, ILabelProvider> fgLabelProviders= new HashMap<>(5);
private SearchResultViewer fViewer;
- private Map fResponse;
+ private Map<Object, SearchResultViewEntry> fResponse;
private IMemento fMemento;
private IPropertyChangeListener fPropertyChangeListener;
private CellEditorActionHandler fCellEditorActionHandler;
@@ -183,7 +183,7 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
ILabelProvider getLabelProvider(String pageId) {
if (pageId != null)
- return (ILabelProvider)fgLabelProviders.get(pageId);
+ return fgLabelProviders.get(pageId);
return null;
}
@@ -245,10 +245,10 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
Assert.isNotNull(pluralLabelPattern);
Assert.isNotNull(gotoAction);
- fResponse= new HashMap(500);
+ fResponse= new HashMap<>(500);
setGotoMarkerAction(gotoAction);
- ILabelProvider oldLabelProvider= (ILabelProvider)fgLabelProviders.get(pageId);
+ ILabelProvider oldLabelProvider= fgLabelProviders.get(pageId);
if (oldLabelProvider != null)
oldLabelProvider.dispose();
fgLabelProviders.put(pageId, labelProvider);
@@ -301,10 +301,10 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
Assert.isNotNull(pluralLabelPattern);
Assert.isNotNull(gotoAction);
- fResponse= new HashMap(500);
+ fResponse= new HashMap<>(500);
setGotoMarkerAction(gotoAction);
- ILabelProvider oldLabelProvider= (ILabelProvider)fgLabelProviders.get(pageId);
+ ILabelProvider oldLabelProvider= fgLabelProviders.get(pageId);
if (oldLabelProvider != null)
oldLabelProvider.dispose();
fgLabelProviders.put(pageId, labelProvider);
@@ -327,7 +327,7 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
*/
@Override
public void addMatch(String description, Object groupByKey, IResource resource, IMarker marker) {
- SearchResultViewEntry entry= (SearchResultViewEntry)fResponse.get(groupByKey);
+ SearchResultViewEntry entry= fResponse.get(groupByKey);
if (entry == null) {
entry= new SearchResultViewEntry(groupByKey, resource);
fResponse.put(groupByKey, entry);
@@ -341,7 +341,7 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
*/
@Override
public void searchFinished() {
- SearchManager.getDefault().searchFinished(new ArrayList(fResponse.values()));
+ SearchManager.getDefault().searchFinished(new ArrayList<>(fResponse.values()));
fResponse= null;
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
index 5e73850e8..485f60bd8 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,8 +34,8 @@ public class SearchResultViewEntry extends PlatformObject implements ISearchResu
private Object fGroupByKey= null;
private IResource fResource= null;
private IMarker fMarker= null;
- private ArrayList fMarkers= null;
- private ArrayList fAttributes;
+ private ArrayList<IMarker> fMarkers= null;
+ private ArrayList<Map<String, Object>> fAttributes;
private int fSelectedMarkerIndex;
private long fModificationStamp= IResource.NULL_STAMP;
private String fMarkerType;
@@ -77,9 +77,9 @@ public class SearchResultViewEntry extends PlatformObject implements ISearchResu
return false;
}
- List getAttributesPerMarker() {
+ List<Map<String, Object>> getAttributesPerMarker() {
if (fAttributes == null)
- return new ArrayList(0);
+ return new ArrayList<>(0);
return fAttributes;
}
@@ -109,7 +109,7 @@ public class SearchResultViewEntry extends PlatformObject implements ISearchResu
return;
}
if (fMarkers == null) {
- fMarkers= new ArrayList(10);
+ fMarkers= new ArrayList<>(10);
addByStartpos(fMarkers, fMarker);
}
addByStartpos(fMarkers, marker);
@@ -125,15 +125,15 @@ public class SearchResultViewEntry extends PlatformObject implements ISearchResu
if (fMarkers == null && fMarker == null)
return null;
if (fMarkers != null && fSelectedMarkerIndex >= 0)
- return (IMarker)fMarkers.get(fSelectedMarkerIndex);
+ return fMarkers.get(fSelectedMarkerIndex);
return fMarker;
}
- public List getMarkers() {
+ public List<IMarker> getMarkers() {
if (fMarkers == null && fMarker == null)
- return new ArrayList(0);
+ return new ArrayList<>(0);
else if (fMarkers == null && fMarker != null) {
- List markers= new ArrayList(1);
+ List<IMarker> markers= new ArrayList<>(1);
markers.add(fMarker);
return markers;
}
@@ -165,7 +165,7 @@ public class SearchResultViewEntry extends PlatformObject implements ISearchResu
else {
fMarkers.remove(marker);
if (fMarkers.size() == 1) {
- fMarker= (IMarker)fMarkers.get(0);
+ fMarker= fMarkers.get(0);
fMarkers= null;
}
}
@@ -174,12 +174,12 @@ public class SearchResultViewEntry extends PlatformObject implements ISearchResu
void backupMarkers() {
if (fResource != null)
fModificationStamp= fResource.getModificationStamp();
- List markers= getMarkers();
- fAttributes= new ArrayList(markers.size());
- Iterator iter= markers.iterator();
+ List<IMarker> markers= getMarkers();
+ fAttributes= new ArrayList<>(markers.size());
+ Iterator<IMarker> iter= markers.iterator();
while (iter.hasNext()) {
- IMarker marker= (IMarker)iter.next();
- Map attributes= null;
+ IMarker marker= iter.next();
+ Map<String, Object> attributes= null;
try {
attributes= marker.getAttributes();
} catch (CoreException ex) {
@@ -190,11 +190,11 @@ public class SearchResultViewEntry extends PlatformObject implements ISearchResu
}
}
- private void addByStartpos(ArrayList markers, IMarker marker) {
+ private void addByStartpos(ArrayList<IMarker> markers, IMarker marker) {
int startPos= marker.getAttribute(IMarker.CHAR_START, -1);
int i= 0;
int markerCount= markers.size();
- while (i < markerCount && startPos >= ((IMarker)markers.get(i)).getAttribute(IMarker.CHAR_START, -1))
+ while (i < markerCount && startPos >= markers.get(i).getAttribute(IMarker.CHAR_START, -1))
i++;
markers.add(i, marker);
if (i == 0)
@@ -202,7 +202,7 @@ public class SearchResultViewEntry extends PlatformObject implements ISearchResu
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return super.getAdapter(adapter);
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
index 7151156a8..b122d1628 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,23 +27,24 @@ import org.eclipse.search.ui.ISearchResultViewEntry;
@Deprecated
public class SearchResultViewEntryAdapterFactory implements IAdapterFactory {
- private static Class[] PROPERTIES= new Class[] {
+ private static Class<?>[] PROPERTIES= new Class[] {
IResource.class, IMarker.class,
};
@Override
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
return PROPERTIES;
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Object element, Class key) {
+ public <T> T getAdapter(Object element, Class<T> key) {
ISearchResultViewEntry entry= (ISearchResultViewEntry) element;
if (IMarker.class.equals(key)) {
- return entry.getSelectedMarker();
+ return (T) entry.getSelectedMarker();
}
if (IResource.class.equals(key)) {
IResource resource= entry.getResource();
@@ -54,7 +55,7 @@ public class SearchResultViewEntryAdapterFactory implements IAdapterFactory {
*/
int type= resource.getType();
if (type != IResource.PROJECT && type != IResource.ROOT)
- return resource;
+ return (T) resource;
}
return null;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
index aa53a3c97..4af2237ee 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -347,7 +347,7 @@ public class SearchResultViewer extends TableViewer {
if (getSelectedEntriesCount() == 0)
return false;
- Iterator iter= Collections.EMPTY_LIST.iterator();
+ Iterator<?> iter= Collections.emptyList().iterator();
ISelection selection= getSelection();
if (selection instanceof IStructuredSelection)
iter= ((IStructuredSelection)selection).iterator();
@@ -677,7 +677,7 @@ public class SearchResultViewer extends TableViewer {
protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
Object[] changed= event.getElements();
if (changed != null && !fResourceToItemsMapper.isEmpty()) {
- ArrayList others= new ArrayList(changed.length);
+ ArrayList<Object> others= new ArrayList<>(changed.length);
for (int i= 0; i < changed.length; i++) {
Object curr= changed[i];
if (curr instanceof IResource)
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
index 1b4be53d7..1e497535b 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
@@ -44,7 +44,7 @@ public class SelectAllAction extends Action {
fViewer= viewer;
}
- private void collectExpandedAndVisible(TreeItem[] items, List result) {
+ private void collectExpandedAndVisible(TreeItem[] items, List<TreeItem> result) {
for (int i= 0; i < items.length; i++) {
TreeItem item= items[i];
result.add(item);
@@ -63,10 +63,10 @@ public class SelectAllAction extends Action {
return;
}
if (fViewer instanceof TreeViewer) {
- ArrayList allVisible= new ArrayList();
+ ArrayList<TreeItem> allVisible= new ArrayList<>();
Tree tree= ((TreeViewer) fViewer).getTree();
collectExpandedAndVisible(tree.getItems(), allVisible);
- tree.setSelection((TreeItem[]) allVisible.toArray(new TreeItem[allVisible.size()]));
+ tree.setSelection(allVisible.toArray(new TreeItem[allVisible.size()]));
} else if (fViewer instanceof TableViewer) {
((TableViewer) fViewer).getTable().selectAll();
// force viewer selection change
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java
index 10ee4dd15..4c504e5e7 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java
@@ -36,7 +36,7 @@ class ShowSearchesAction extends Action {
private static final class SearchesLabelProvider extends LabelProvider {
- private ArrayList fImages= new ArrayList();
+ private ArrayList<Image> fImages= new ArrayList<>();
@Override
public String getText(Object element) {
@@ -61,9 +61,9 @@ class ShowSearchesAction extends Action {
@Override
public void dispose() {
- Iterator iter= fImages.iterator();
+ Iterator<Image> iter= fImages.iterator();
while (iter.hasNext())
- ((Image)iter.next()).dispose();
+ iter.next().dispose();
fImages= null;
}
@@ -85,7 +85,7 @@ class ShowSearchesAction extends Action {
}
public void run(boolean showAll) {
- Iterator iter= SearchManager.getDefault().getPreviousSearches().iterator();
+ Iterator<Search> iter= SearchManager.getDefault().getPreviousSearches().iterator();
int cutOffSize;
if (showAll)
cutOffSize= 0;
@@ -94,10 +94,10 @@ class ShowSearchesAction extends Action {
int size= SearchManager.getDefault().getPreviousSearches().size() - cutOffSize;
Search selectedSearch= SearchManager.getDefault().getCurrentSearch();
Action selectedAction = null;
- ArrayList input= new ArrayList(size);
+ ArrayList<Action> input= new ArrayList<>(size);
int i= 0;
while (iter.hasNext()) {
- Search search= (Search)iter.next();
+ Search search= iter.next();
if (i++ < cutOffSize)
continue;
Action action= new ShowSearchAction(search);
@@ -132,7 +132,7 @@ class ShowSearchesAction extends Action {
dlg.setInitialSelections(selected);
}
if (dlg.open() == Window.OK) {
- List result= Arrays.asList(dlg.getResult());
+ List<Object> result= Arrays.asList(dlg.getResult());
if (result != null && result.size() == 1) {
((ShowSearchAction)result.get(0)).run();
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
index 8e9738146..0130c9cc7 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.eclipse.search.internal.ui;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Map.Entry;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Control;
@@ -40,12 +41,12 @@ class SortDropDownAction extends Action implements IMenuCreator {
private static final String TAG_PAGE_ID= "pageId"; //$NON-NLS-1$
private static final String TAG_SORTER_ID= "sorterId"; //$NON-NLS-1$
- private static Map fgLastCheckedForType= new HashMap(5);
+ private static Map<String, SorterDescriptor> fgLastCheckedForType= new HashMap<>(5);
private SearchResultViewer fViewer;
private String fPageId;
private Menu fMenu;
- private Map fLastCheckedForType;
+ private Map<String, SorterDescriptor> fLastCheckedForType;
public SortDropDownAction(SearchResultViewer viewer) {
super(SearchMessages.SortDropDownAction_label);
@@ -53,7 +54,7 @@ class SortDropDownAction extends Action implements IMenuCreator {
fViewer= viewer;
setToolTipText(SearchMessages.SortDropDownAction_tooltip);
setMenuCreator(this);
- fLastCheckedForType= new HashMap(5);
+ fLastCheckedForType= new HashMap<>(5);
}
@Override
@@ -70,9 +71,9 @@ class SortDropDownAction extends Action implements IMenuCreator {
void setPageId(String pageId) {
fPageId= pageId;
- SorterDescriptor sorterDesc= (SorterDescriptor)fLastCheckedForType.get(pageId);
+ SorterDescriptor sorterDesc= fLastCheckedForType.get(pageId);
if (sorterDesc == null)
- sorterDesc= (SorterDescriptor)fgLastCheckedForType.get(pageId);
+ sorterDesc= fgLastCheckedForType.get(pageId);
if (sorterDesc == null)
sorterDesc= findSorter(fPageId);
if (sorterDesc != null) {
@@ -90,7 +91,7 @@ class SortDropDownAction extends Action implements IMenuCreator {
fMenu= new Menu(parent);
- Iterator iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
+ Iterator<SorterDescriptor> iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
while (iter.hasNext()) {
Object value= fLastCheckedForType.get(fPageId);
final String checkedId;
@@ -99,7 +100,7 @@ class SortDropDownAction extends Action implements IMenuCreator {
else
checkedId= ""; //$NON-NLS-1$
- final SorterDescriptor sorterDesc= (SorterDescriptor) iter.next();
+ final SorterDescriptor sorterDesc= iter.next();
if (!sorterDesc.getPageId().equals(fPageId) && !sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
continue;
final ViewerSorter sorter= sorterDesc.createObject();
@@ -139,9 +140,9 @@ class SortDropDownAction extends Action implements IMenuCreator {
}
private SorterDescriptor findSorter(String pageId) {
- Iterator iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
+ Iterator<SorterDescriptor> iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
while (iter.hasNext()) {
- SorterDescriptor sorterDesc= (SorterDescriptor)iter.next();
+ SorterDescriptor sorterDesc= iter.next();
if (sorterDesc.getPageId().equals(pageId) || sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
return sorterDesc;
}
@@ -149,9 +150,9 @@ class SortDropDownAction extends Action implements IMenuCreator {
}
private SorterDescriptor getSorter(String sorterId) {
- Iterator iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
+ Iterator<SorterDescriptor> iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
while (iter.hasNext()) {
- SorterDescriptor sorterDesc= (SorterDescriptor)iter.next();
+ SorterDescriptor sorterDesc= iter.next();
if (sorterDesc.getId().equals(sorterId))
return sorterDesc;
}
@@ -184,7 +185,7 @@ class SortDropDownAction extends Action implements IMenuCreator {
restoreState(memento, fgLastCheckedForType, TAG_DEFAULT_SORTERS);
}
- private void restoreState(IMemento memento, Map map, String mapName) {
+ private void restoreState(IMemento memento, Map<String, SorterDescriptor> map, String mapName) {
memento= memento.getChild(mapName);
if (memento == null)
return;
@@ -203,22 +204,22 @@ class SortDropDownAction extends Action implements IMenuCreator {
saveState(memento, fLastCheckedForType, TAG_SORTERS);
}
- private void saveState(IMemento memento, Map map, String mapName) {
- Iterator iter= map.entrySet().iterator();
+ private void saveState(IMemento memento, Map<String, SorterDescriptor> map, String mapName) {
+ Iterator<Entry<String, SorterDescriptor>> iter= map.entrySet().iterator();
memento= memento.createChild(mapName);
while (iter.hasNext()) {
IMemento mementoElement= memento.createChild(TAG_ELEMENT);
- Map.Entry entry= (Map.Entry)iter.next();
- mementoElement.putString(TAG_PAGE_ID, (String)entry.getKey());
- mementoElement.putString(TAG_SORTER_ID, ((SorterDescriptor)entry.getValue()).getId());
+ Entry<String, SorterDescriptor> entry= iter.next();
+ mementoElement.putString(TAG_PAGE_ID, entry.getKey());
+ mementoElement.putString(TAG_SORTER_ID, entry.getValue().getId());
}
}
int getSorterCount() {
int count= 0;
- Iterator iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
+ Iterator<SorterDescriptor> iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
while (iter.hasNext()) {
- SorterDescriptor sorterDesc= (SorterDescriptor)iter.next();
+ SorterDescriptor sorterDesc= iter.next();
if (sorterDesc.getPageId().equals(fPageId) || sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
count++;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java
index 9fbc46976..075c3511a 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/WorkingSetComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,21 +16,14 @@ import com.ibm.icu.text.Collator;
import org.eclipse.ui.IWorkingSet;
-public class WorkingSetComparator implements Comparator {
+public class WorkingSetComparator implements Comparator<IWorkingSet> {
private Collator fCollator= Collator.getInstance();
@Override
- public int compare(Object o1, Object o2) {
- String name1= null;
- String name2= null;
-
- if (o1 instanceof IWorkingSet)
- name1= ((IWorkingSet)o1).getLabel();
-
- if (o2 instanceof IWorkingSet)
- name2= ((IWorkingSet)o2).getLabel();
-
+ public int compare(IWorkingSet o1, IWorkingSet o2) {
+ String name1= o1.getLabel();
+ String name2= o2.getLabel();
return fCollator.compare(name1, name2);
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/EditorOpener.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/EditorOpener.java
index 8b0744b82..f907e685d 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/EditorOpener.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/EditorOpener.java
@@ -127,7 +127,7 @@ public class EditorOpener {
IMarker marker= null;
try {
marker= file.createMarker(NewSearchUI.SEARCH_MARKER);
- HashMap attributes= new HashMap(4);
+ HashMap<String, Integer> attributes= new HashMap<>(4);
attributes.put(IMarker.CHAR_START, new Integer(offset));
attributes.put(IMarker.CHAR_END, new Integer(offset + length));
marker.setAttributes(attributes);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
index 6d90937d2..797e7f7a2 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,11 +21,11 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -48,7 +48,7 @@ public class FileLabelProvider extends LabelProvider implements IStyledLabelProv
private final WorkbenchLabelProvider fLabelProvider;
private final AbstractTextSearchViewPage fPage;
- private final Comparator fMatchComparator;
+ private final Comparator<FileMatch> fMatchComparator;
private final Image fLineMatchImage;
@@ -59,10 +59,10 @@ public class FileLabelProvider extends LabelProvider implements IStyledLabelProv
fOrder= orderFlag;
fPage= page;
fLineMatchImage= SearchPluginImages.get(SearchPluginImages.IMG_OBJ_TEXT_SEARCH_LINE);
- fMatchComparator= new Comparator() {
+ fMatchComparator= new Comparator<FileMatch>() {
@Override
- public int compare(Object o1, Object o2) {
- return ((FileMatch) o1).getOriginalOffset() - ((FileMatch) o2).getOriginalOffset();
+ public int compare(FileMatch o1, FileMatch o2) {
+ return o1.getOriginalOffset() - o2.getOriginalOffset();
}
};
}
@@ -116,7 +116,7 @@ public class FileLabelProvider extends LabelProvider implements IStyledLabelProv
StyledString str= new StyledString(lineNumberString, StyledString.QUALIFIER_STYLER);
- Match[] matches= lineElement.getMatches(fPage.getInput());
+ FileMatch[] matches= lineElement.getMatches(fPage.getInput());
Arrays.sort(matches, fMatchComparator);
String content= lineElement.getContents();
@@ -127,7 +127,7 @@ public class FileLabelProvider extends LabelProvider implements IStyledLabelProv
int charsToCut= getCharsToCut(length, matches); // number of characters to leave away if the line is too long
for (int i= 0; i < matches.length; i++) {
- FileMatch match= (FileMatch) matches[i];
+ FileMatch match= matches[i];
int start= Math.max(match.getOriginalOffset() - lineElement.getOffset(), 0);
// append gap between last match and the new one
if (pos < start) {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
index a40dcf2e7..55d54928f 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -104,7 +104,9 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
name1 = "";//$NON-NLS-1$
if (name2 == null)
name2 = "";//$NON-NLS-1$
- return getComparator().compare(name1, name2);
+ @SuppressWarnings("unchecked")
+ int result= getComparator().compare(name1, name2);
+ return result;
}
}
@@ -308,10 +310,11 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
memento.putInteger(KEY_LIMIT, getElementLimit().intValue());
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (IShowInTargetList.class.equals(adapter)) {
- return SHOW_IN_TARGET_LIST;
+ return (T) SHOW_IN_TARGET_LIST;
}
if (adapter == IShowInSource.class) {
@@ -322,8 +325,8 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
ISelection selection= selectionProvider.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection= ((StructuredSelection)selection);
- final Set newSelection= new HashSet(structuredSelection.size());
- Iterator iter= structuredSelection.iterator();
+ final Set<Object> newSelection= new HashSet<>(structuredSelection.size());
+ Iterator<?> iter= structuredSelection.iterator();
while (iter.hasNext()) {
Object element= iter.next();
if (element instanceof LineElement)
@@ -331,10 +334,10 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
newSelection.add(element);
}
- return new IShowInSource() {
+ return (T) new IShowInSource() {
@Override
public ShowInContext getShowInContext() {
- return new ShowInContext(null, new StructuredSelection(new ArrayList(newSelection)));
+ return new ShowInContext(null, new StructuredSelection(new ArrayList<>(newSelection)));
}
};
}
@@ -395,7 +398,7 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
}
@Override
- protected void evaluateChangedElements(Match[] matches, Set changedElements) {
+ protected void evaluateChangedElements(Match[] matches, Set<Object> changedElements) {
if (showLineMatches()) {
for (int i = 0; i < matches.length; i++) {
changedElements.add(((FileMatch) matches[i]).getLineElement());
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
index 043283005..1b47a2885 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
@@ -52,7 +52,7 @@ public class FileSearchQuery implements ISearchQuery {
private final boolean fSearchInBinaries;
private final boolean fIsLightweightAutoRefresh;
- private Map fCachedMatches; // map of IFile -> ArrayList of FileMatches
+ private Map<IFile, ArrayList<FileMatch>> fCachedMatches;
private Object fLock= new Object();
private TextSearchResultCollector(AbstractTextSearchResult result, boolean isFileSearchOnly, boolean searchInBinaries) {
@@ -89,7 +89,7 @@ public class FileSearchQuery implements ISearchQuery {
@Override
public boolean acceptPatternMatch(TextSearchMatchAccess matchRequestor) throws CoreException {
- ArrayList matches;
+ ArrayList<FileMatch> matches;
synchronized(fLock) {
// fCachedMatches is set to null when the caller invokes endReporting(),
// indicating that no further results are desired/expected, so discard
@@ -97,7 +97,7 @@ public class FileSearchQuery implements ISearchQuery {
if (fCachedMatches == null) {
return false;
}
- matches= (ArrayList) fCachedMatches.get(matchRequestor.getFile());
+ matches= fCachedMatches.get(matchRequestor.getFile());
}
int matchOffset= matchRequestor.getMatchOffset();
@@ -120,9 +120,9 @@ public class FileSearchQuery implements ISearchQuery {
if (fCachedMatches == null) {
return false;
}
- matches= (ArrayList) fCachedMatches.get(matchRequestor.getFile());
+ matches= fCachedMatches.get(matchRequestor.getFile());
if (matches == null) {
- matches= new ArrayList();
+ matches= new ArrayList<>();
fCachedMatches.put(matchRequestor.getFile(), matches);
}
matches.add(fileMatch);
@@ -131,13 +131,13 @@ public class FileSearchQuery implements ISearchQuery {
return true;
}
- private LineElement getLineElement(int offset, TextSearchMatchAccess matchRequestor, ArrayList matches) {
+ private LineElement getLineElement(int offset, TextSearchMatchAccess matchRequestor, ArrayList<FileMatch> matches) {
int lineNumber= 1;
int lineStart= 0;
if (matches != null) {
// match on same line as last?
- FileMatch last= (FileMatch) matches.get(matches.size() - 1);
+ FileMatch last= matches.get(matches.size() - 1);
LineElement lineElement= last.getLineElement();
if (lineElement.contains(offset)) {
return lineElement;
@@ -188,7 +188,7 @@ public class FileSearchQuery implements ISearchQuery {
@Override
public void beginReporting() {
- fCachedMatches= new HashMap();
+ fCachedMatches= new HashMap<>();
}
@Override
@@ -202,10 +202,10 @@ public class FileSearchQuery implements ISearchQuery {
private void flushMatches() {
synchronized (fLock) {
if (fCachedMatches != null && !fCachedMatches.isEmpty()) {
- Iterator it = fCachedMatches.values().iterator();
+ Iterator<ArrayList<FileMatch>> it = fCachedMatches.values().iterator();
while(it.hasNext()) {
- ArrayList matches= (ArrayList) it.next();
- fResult.addMatches((Match[]) matches.toArray(new Match[matches.size()]));
+ ArrayList<FileMatch> matches= it.next();
+ fResult.addMatches(matches.toArray(new Match[matches.size()]));
}
fCachedMatches.clear();
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
index d891cd5e2..8ee249cb2 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,7 +36,7 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc
private AbstractTextSearchResult fResult;
private FileSearchPage fPage;
private AbstractTreeViewer fTreeViewer;
- private Map fChildrenMap;
+ private Map<Object, Set<Object>> fChildrenMap;
FileTreeContentProvider(FileSearchPage page, AbstractTreeViewer viewer) {
fPage= page;
@@ -73,7 +73,7 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc
private synchronized void initialize(AbstractTextSearchResult result) {
fResult= result;
- fChildrenMap= new HashMap();
+ fChildrenMap= new HashMap<>();
boolean showLineMatches= !((FileSearchQuery) fResult.getQuery()).isFileNameSearch();
if (result != null) {
@@ -120,16 +120,16 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc
*/
private boolean insertChild(Object parent, Object child) {
- Set children= (Set) fChildrenMap.get(parent);
+ Set<Object> children= fChildrenMap.get(parent);
if (children == null) {
- children= new HashSet();
+ children= new HashSet<>();
fChildrenMap.put(parent, children);
}
return children.add(child);
}
private boolean hasChild(Object parent, Object child) {
- Set children= (Set) fChildrenMap.get(parent);
+ Set<Object> children= fChildrenMap.get(parent);
return children != null && children.contains(child);
}
@@ -170,7 +170,7 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc
private void removeFromSiblings(Object element, Object parent) {
- Set siblings= (Set) fChildrenMap.get(parent);
+ Set<Object> siblings= fChildrenMap.get(parent);
if (siblings != null) {
siblings.remove(element);
}
@@ -178,7 +178,7 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc
@Override
public Object[] getChildren(Object parentElement) {
- Set children= (Set) fChildrenMap.get(parentElement);
+ Set<Object> children= fChildrenMap.get(parentElement);
if (children == null)
return EMPTY_ARR;
return children.toArray();
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java
index 7d0e0c101..cb9c0d2ff 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java
@@ -62,7 +62,7 @@ public class LineElement {
}
public FileMatch[] getMatches(AbstractTextSearchResult result) {
- ArrayList res= new ArrayList();
+ ArrayList<FileMatch> res= new ArrayList<>();
Match[] matches= result.getMatches(fParent);
for (int i= 0; i < matches.length; i++) {
FileMatch curr= (FileMatch) matches[i];
@@ -70,7 +70,7 @@ public class LineElement {
res.add(curr);
}
}
- return (FileMatch[]) res.toArray(new FileMatch[res.size()]);
+ return res.toArray(new FileMatch[res.size()]);
}
public int getNumberOfMatches(AbstractTextSearchResult result) {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java
index 838c4a682..ee0710c58 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java
@@ -196,7 +196,7 @@ public class ReplaceConfigurationPage extends UserInputWizardPage {
private void storeSettings() {
String[] items= fTextField.getItems();
- ArrayList history= new ArrayList();
+ ArrayList<String> history= new ArrayList<>();
history.add(fTextField.getText());
int historySize= Math.min(items.length, 6);
for (int i= 0; i < historySize; i++) {
@@ -206,7 +206,7 @@ public class ReplaceConfigurationPage extends UserInputWizardPage {
}
}
IDialogSettings settings= SearchPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_GROUP);
- settings.put(SETTINGS_REPLACE_WITH, (String[]) history.toArray(new String[history.size()]));
+ settings.put(SETTINGS_REPLACE_WITH, history.toArray(new String[history.size()]));
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
index 67bde0296..c8d7bcee1 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,6 +19,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -87,16 +88,16 @@ public class ReplaceRefactoring extends Refactoring {
private MatchGroup[] fMatchGroups;
private Match[] fMatches;
- private Map/*<URI,ArrayList<Match>*/ fIgnoredMatches;
+ private Map<URI, ArrayList<FileMatch>> fIgnoredMatches;
private final FileSearchResult fResult;
private final boolean fIsRemove;
- public SearchResultUpdateChange(FileSearchResult result, MatchGroup[] matchGroups, Map ignoredMatches) {
+ public SearchResultUpdateChange(FileSearchResult result, MatchGroup[] matchGroups, Map<URI, ArrayList<FileMatch>> ignoredMatches) {
this(result, null, ignoredMatches, true);
fMatchGroups= matchGroups;
}
- private SearchResultUpdateChange(FileSearchResult result, Match[] matches, Map ignoredMatches, boolean isRemove) {
+ private SearchResultUpdateChange(FileSearchResult result, Match[] matches, Map<URI, ArrayList<FileMatch>> ignoredMatches, boolean isRemove) {
fResult= result;
fMatches= matches;
fIgnoredMatches= ignoredMatches;
@@ -124,7 +125,7 @@ public class ReplaceRefactoring extends Refactoring {
private Match[] getMatches() {
if (fMatches == null) {
- ArrayList matches= new ArrayList();
+ ArrayList<FileMatch> matches= new ArrayList<>();
for (int i= 0; i < fMatchGroups.length; i++) {
MatchGroup curr= fMatchGroups[i];
if (curr.group.isEnabled()) {
@@ -138,13 +139,13 @@ public class ReplaceRefactoring extends Refactoring {
IFile file= match.getFile();
URI uri= file.getLocationURI();
if (uri != null) {
- ArrayList ignoredMatches= (ArrayList)fIgnoredMatches.get(uri);
+ ArrayList<FileMatch> ignoredMatches= fIgnoredMatches.get(uri);
if (ignoredMatches != null)
matches.addAll(ignoredMatches);
}
}
}
- fMatches= (Match[]) matches.toArray(new Match[matches.size()]);
+ fMatches= matches.toArray(new Match[matches.size()]);
fMatchGroups= null;
}
return fMatches;
@@ -168,13 +169,13 @@ public class ReplaceRefactoring extends Refactoring {
private final FileSearchResult fResult;
private final Object[] fSelection;
- private final HashMap/*<IFile,Set<Match>*/ fMatches;
+ private final HashMap<IFile, Set<FileMatch>> fMatches;
/** Map that keeps already collected locations. */
- private final Map/*<URI,IFile>*/fAlreadyCollected;
+ private final Map<URI, IFile> fAlreadyCollected;
/** Map that keeps ignored matches (can be null). */
- private Map/*<URI,ArrayList<Match>*/ fIgnoredMatches;
+ private Map<URI, ArrayList<FileMatch>> fIgnoredMatches;
private String fReplaceString;
@@ -186,8 +187,8 @@ public class ReplaceRefactoring extends Refactoring {
fResult= result;
fSelection= selection;
- fMatches= new HashMap();
- fAlreadyCollected= new HashMap(selection != null ? selection.length : result.getElements().length);
+ fMatches= new HashMap<>();
+ fAlreadyCollected= new HashMap<>(selection != null ? selection.length : result.getElements().length);
fReplaceString= null;
}
@@ -244,7 +245,7 @@ public class ReplaceRefactoring extends Refactoring {
} else if (object instanceof IFile) {
Match[] matches= fResult.getMatches(object);
if (matches.length > 0) {
- Collection bucket= null;
+ Collection<FileMatch> bucket= null;
for (int i= 0; i < matches.length; i++) {
FileMatch fileMatch= (FileMatch) matches[i];
if (isMatchToBeIncluded(fileMatch)) {
@@ -264,8 +265,8 @@ public class ReplaceRefactoring extends Refactoring {
public int getNumberOfMatches() {
int count= 0;
- for (Iterator iterator= fMatches.values().iterator(); iterator.hasNext();) {
- Collection bucket= (Collection) iterator.next();
+ for (Iterator<Set<FileMatch>> iterator= fMatches.values().iterator(); iterator.hasNext();) {
+ Set<FileMatch> bucket= iterator.next();
count += bucket.size();
}
return count;
@@ -289,17 +290,17 @@ public class ReplaceRefactoring extends Refactoring {
if (uri == null)
return true;
- for (Iterator iter= fAlreadyCollected.keySet().iterator(); iter.hasNext();) {
- if (URIUtil.equals((URI)iter.next(), uri)) {
+ for (Iterator<URI> iter= fAlreadyCollected.keySet().iterator(); iter.hasNext();) {
+ if (URIUtil.equals(iter.next(), uri)) {
if (file.equals(fAlreadyCollected.get(uri)))
return true; // another FileMatch for an IFile which already had matches
if (fIgnoredMatches == null)
- fIgnoredMatches= new HashMap();
+ fIgnoredMatches= new HashMap<>();
- ArrayList matches= (ArrayList)fIgnoredMatches.get(uri);
+ ArrayList<FileMatch> matches= fIgnoredMatches.get(uri);
if (matches == null) {
- matches= new ArrayList();
+ matches= new ArrayList<>();
fIgnoredMatches.put(uri, matches);
}
matches.add(match);
@@ -312,13 +313,13 @@ public class ReplaceRefactoring extends Refactoring {
return true;
}
- private Collection getBucket(IFile file) {
- Collection col= (Collection) fMatches.get(file);
- if (col == null) {
- col= new HashSet();
- fMatches.put(file, col);
+ private Set<FileMatch> getBucket(IFile file) {
+ Set<FileMatch> set= fMatches.get(file);
+ if (set == null) {
+ set= new HashSet<>();
+ fMatches.put(file, set);
}
- return col;
+ return set;
}
@Override
@@ -335,14 +336,14 @@ public class ReplaceRefactoring extends Refactoring {
RefactoringStatus resultingStatus= new RefactoringStatus();
- Collection allFilesSet= fMatches.keySet();
- IFile[] allFiles= (IFile[]) allFilesSet.toArray(new IFile[allFilesSet.size()]);
- Arrays.sort(allFiles, new Comparator() {
+ Collection<IFile> allFilesSet= fMatches.keySet();
+ IFile[] allFiles= allFilesSet.toArray(new IFile[allFilesSet.size()]);
+ Arrays.sort(allFiles, new Comparator<IFile>() {
private Collator fCollator= Collator.getInstance();
@Override
- public int compare(Object o1, Object o2) {
- String p1= ((IFile) o1).getFullPath().toString();
- String p2= ((IFile) o2).getFullPath().toString();
+ public int compare(IFile o1, IFile o2) {
+ String p1= o1.getFullPath().toString();
+ String p2= o2.getFullPath().toString();
return fCollator.compare(p1, p2);
}
});
@@ -354,12 +355,12 @@ public class ReplaceRefactoring extends Refactoring {
CompositeChange compositeChange= new CompositeChange(SearchMessages.ReplaceRefactoring_composite_change_name);
compositeChange.markAsSynthetic();
- ArrayList matchGroups= new ArrayList();
+ ArrayList<MatchGroup> matchGroups= new ArrayList<>();
boolean hasChanges= false;
try {
for (int i= 0; i < allFiles.length; i++) {
IFile file= allFiles[i];
- Collection bucket= (Collection) fMatches.get(file);
+ Set<FileMatch> bucket= fMatches.get(file);
if (!bucket.isEmpty()) {
try {
TextChange change= createFileChange(file, pattern, bucket, resultingStatus, matchGroups);
@@ -381,20 +382,20 @@ public class ReplaceRefactoring extends Refactoring {
return RefactoringStatus.createFatalErrorStatus(SearchMessages.ReplaceRefactoring_error_no_changes);
}
- compositeChange.add(new SearchResultUpdateChange(fResult, (MatchGroup[])matchGroups.toArray(new MatchGroup[matchGroups.size()]), fIgnoredMatches));
+ compositeChange.add(new SearchResultUpdateChange(fResult, matchGroups.toArray(new MatchGroup[matchGroups.size()]), fIgnoredMatches));
fChange= compositeChange;
return resultingStatus;
}
private void checkFilesToBeChanged(IFile[] filesToBeChanged, RefactoringStatus resultingStatus) throws CoreException {
- ArrayList readOnly= new ArrayList();
+ ArrayList<IFile> readOnly= new ArrayList<>();
for (int i= 0; i < filesToBeChanged.length; i++) {
IFile file= filesToBeChanged[i];
if (file.isReadOnly())
readOnly.add(file);
}
- IFile[] readOnlyFiles= (IFile[]) readOnly.toArray(new IFile[readOnly.size()]);
+ IFile[] readOnlyFiles= readOnly.toArray(new IFile[readOnly.size()]);
IStatus status= ResourcesPlugin.getWorkspace().validateEdit(readOnlyFiles, getValidationContext());
if (status.getSeverity() == IStatus.CANCEL) {
@@ -407,7 +408,7 @@ public class ReplaceRefactoring extends Refactoring {
resultingStatus.merge(ResourceChangeChecker.checkFilesToBeChanged(filesToBeChanged, null));
}
- private TextChange createFileChange(IFile file, Pattern pattern, Collection/*FileMatch*/ matches, RefactoringStatus resultingStatus, Collection matchGroups) throws PatternSyntaxException, CoreException {
+ private TextChange createFileChange(IFile file, Pattern pattern, Set<FileMatch> matches, RefactoringStatus resultingStatus, Collection<MatchGroup> matchGroups) throws PatternSyntaxException, CoreException {
PositionTracker tracker= InternalSearchUI.getInstance().getPositionTracker();
TextFileChange change= new TextFileChange(Messages.format(SearchMessages.ReplaceRefactoring_group_label_change_for_file, file.getName()), file);
@@ -424,8 +425,8 @@ public class ReplaceRefactoring extends Refactoring {
IDocument document= textFileBuffer.getDocument();
String lineDelimiter= TextUtilities.getDefaultLineDelimiter(document);
- for (Iterator iterator= matches.iterator(); iterator.hasNext();) {
- FileMatch match= (FileMatch) iterator.next();
+ for (Iterator<FileMatch> iterator= matches.iterator(); iterator.hasNext();) {
+ FileMatch match= iterator.next();
int offset= match.getOffset();
int length= match.getLength();
Position currentPosition= tracker.getCurrentPosition(match);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
index 039f1128b..5d81904ee 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
@@ -112,7 +112,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
*/
private static final String STORE_EXTENSIONS= "EXTENSIONS"; //$NON-NLS-1$
- private List fPreviousSearchPatterns= new ArrayList(HISTORY_SIZE);
+ private List<SearchPatternData> fPreviousSearchPatterns= new ArrayList<>(HISTORY_SIZE);
private boolean fFirstTime= true;
private boolean fIsCaseSensitive;
@@ -336,10 +336,10 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
}
private FileTextSearchScope getSelectedResourcesScope() {
- HashSet resources= new HashSet();
+ HashSet<IResource> resources= new HashSet<>();
ISelection sel= getContainer().getSelection();
if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
- Iterator iter= ((IStructuredSelection) sel).iterator();
+ Iterator<?> iter= ((IStructuredSelection) sel).iterator();
while (iter.hasNext()) {
Object curr= iter.next();
if (curr instanceof IWorkingSet) {
@@ -368,7 +368,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
} else if (getContainer().getActiveEditorInput() != null) {
resources.add(getContainer().getActiveEditorInput().getAdapter(IFile.class));
}
- IResource[] arr= (IResource[]) resources.toArray(new IResource[resources.size()]);
+ IResource[] arr= resources.toArray(new IResource[resources.size()]);
return FileTextSearchScope.newSearchScope(arr, getExtensions(), fSearchDerived);
}
@@ -389,8 +389,8 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private SearchPatternData findInPrevious(String pattern) {
- for (Iterator iter= fPreviousSearchPatterns.iterator(); iter.hasNext();) {
- SearchPatternData element= (SearchPatternData) iter.next();
+ for (Iterator<SearchPatternData> iter= fPreviousSearchPatterns.iterator(); iter.hasNext();) {
+ SearchPatternData element= iter.next();
if (pattern.equals(element.textPattern)) {
return element;
}
@@ -421,22 +421,22 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
}
private String[] getPreviousExtensionsOldStyle() {
- List extensions= new ArrayList(fPreviousSearchPatterns.size());
+ List<String> extensions= new ArrayList<>(fPreviousSearchPatterns.size());
int size= fPreviousSearchPatterns.size();
for (int i= 0; i < size; i++) {
- SearchPatternData data= (SearchPatternData)fPreviousSearchPatterns.get(i);
+ SearchPatternData data= fPreviousSearchPatterns.get(i);
String text= FileTypeEditor.typesToString(data.fileNamePatterns);
if (!extensions.contains(text))
extensions.add(text);
}
- return (String[])extensions.toArray(new String[extensions.size()]);
+ return extensions.toArray(new String[extensions.size()]);
}
private String[] getPreviousSearchPatterns() {
int size= fPreviousSearchPatterns.size();
String [] patterns= new String[size];
for (int i= 0; i < size; i++)
- patterns[i]= ((SearchPatternData) fPreviousSearchPatterns.get(i)).textPattern;
+ patterns[i]= fPreviousSearchPatterns.get(i).textPattern;
return patterns;
}
@@ -632,7 +632,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
if (selectionIndex < 0 || selectionIndex >= fPreviousSearchPatterns.size())
return;
- SearchPatternData patternData= (SearchPatternData) fPreviousSearchPatterns.get(selectionIndex);
+ SearchPatternData patternData= fPreviousSearchPatterns.get(selectionIndex);
if (!fPattern.getText().equals(patternData.textPattern))
return;
fIsCaseSensitiveCheckbox.setSelection(patternData.isCaseSensitive);
@@ -852,7 +852,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
// ignore
}
- Set previousExtensions= new LinkedHashSet(HISTORY_SIZE);
+ Set<String> previousExtensions= new LinkedHashSet<>(HISTORY_SIZE);
IDialogSettings extensionsSettings= s.getSection(STORE_EXTENSIONS);
if (extensionsSettings != null) {
for (int i= 0; i < HISTORY_SIZE; i++) {
@@ -883,13 +883,13 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
s.put(STORE_HISTORY_SIZE, historySize);
for (int i= 0; i < historySize; i++) {
IDialogSettings histSettings= s.addNewSection(STORE_HISTORY + i);
- SearchPatternData data= ((SearchPatternData) fPreviousSearchPatterns.get(i));
+ SearchPatternData data= fPreviousSearchPatterns.get(i);
data.store(histSettings);
}
IDialogSettings extensionsSettings= s.addNewSection(STORE_EXTENSIONS);
extensionsSettings.put(Integer.toString(0), fExtensions.getText());
- Set extensions= new HashSet(HISTORY_SIZE);
+ Set<String> extensions= new HashSet<>(HISTORY_SIZE);
extensions.add(fExtensions.getText());
int length= Math.min(fExtensions.getItemCount(), HISTORY_SIZE - 1);
int j= 1;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
index c479282aa..70819f646 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
@@ -47,7 +47,7 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
private Control fContents;
private Button fCancelButton;
- private List fActionButtons;
+ private List<Button> fActionButtons;
// The number of long running operation executed from the dialog.
private long fActiveRunningOperations;
@@ -60,7 +60,7 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
public ExtendedDialogWindow(Shell shell) {
super(shell);
- fActionButtons= new ArrayList();
+ fActionButtons= new ArrayList<>();
}
@Override
@@ -174,8 +174,8 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
* @param state The new state
*/
public void setPerformActionEnabled(boolean state) {
- for (Iterator buttons = fActionButtons.iterator(); buttons.hasNext(); ) {
- Button element = (Button) buttons.next();
+ for (Iterator<Button> buttons = fActionButtons.iterator(); buttons.hasNext(); ) {
+ Button element = buttons.next();
element.setEnabled(state);
}
}
@@ -211,7 +211,7 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
* @return The saved UI state.
*/
protected synchronized Object aboutToStart(boolean enableCancelButton) {
- HashMap savedState= null;
+ HashMap<Object, Object> savedState= null;
Shell shell= getShell();
if (shell != null) {
Display d= shell.getDisplay();
@@ -257,7 +257,8 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
fProgressMonitorPart.removeFromCancelComponent(fCancelButton);
}
- HashMap state= (HashMap)savedState;
+ @SuppressWarnings("unchecked")
+ HashMap<Object, Object> state= (HashMap<Object, Object>)savedState;
restoreUIState(state);
setDisplayCursor(shell.getDisplay(), null);
@@ -276,10 +277,10 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
//---- UI state save and restoring ---------------------------------------------
- private void restoreUIState(HashMap state) {
+ private void restoreUIState(HashMap<Object, Object> state) {
restoreEnableState(fCancelButton, state);
- for (Iterator actionButtons = fActionButtons.iterator(); actionButtons.hasNext(); ) {
- Button button = (Button) actionButtons.next();
+ for (Iterator<Button> actionButtons = fActionButtons.iterator(); actionButtons.hasNext(); ) {
+ Button button = actionButtons.next();
restoreEnableState(button, state);
}
ControlEnableState pageState= (ControlEnableState)state.get("tabForm"); //$NON-NLS-1$
@@ -289,7 +290,7 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
/*
* Restores the enable state of the given control.
*/
- protected void restoreEnableState(Control w, HashMap h) {
+ protected void restoreEnableState(Control w, HashMap<Object, Object> h) {
if (!w.isDisposed()) {
Boolean b= (Boolean)h.get(w);
if (b != null)
@@ -297,11 +298,11 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
}
}
- private HashMap saveUIState(boolean keepCancelEnabled) {
- HashMap savedState= new HashMap(10);
+ private HashMap<Object, Object> saveUIState(boolean keepCancelEnabled) {
+ HashMap<Object, Object> savedState= new HashMap<>(10);
saveEnableStateAndSet(fCancelButton, savedState, keepCancelEnabled);
- for (Iterator actionButtons = fActionButtons.iterator(); actionButtons.hasNext(); ) {
- Button button = (Button) actionButtons.next();
+ for (Iterator<Button> actionButtons = fActionButtons.iterator(); actionButtons.hasNext(); ) {
+ Button button = actionButtons.next();
saveEnableStateAndSet(button, savedState, false);
}
savedState.put("tabForm", ControlEnableState.disable(fContents)); //$NON-NLS-1$
@@ -309,7 +310,7 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
return savedState;
}
- private void saveEnableStateAndSet(Control w, HashMap h, boolean enabled) {
+ private void saveEnableStateAndSet(Control w, HashMap<Object, Object> h, boolean enabled) {
if (!w.isDisposed()) {
h.put(w, Boolean.valueOf(w.isEnabled()));
w.setEnabled(enabled);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java
index 9c7418971..91bae8fe1 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -45,7 +45,7 @@ public class FileLabelProvider extends LabelProvider {
private ILabelDecorator fDecorator;
private int fOrder;
- private String[] fArgs= new String[2];
+ private Object[] fArgs= new String[2];
public FileLabelProvider(int orderFlag) {
fDecorator= PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
index e5fb3e9ca..f8cd8e892 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -38,11 +38,8 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener
private final static String TYPE_DELIMITER= SearchMessages.FileTypeEditor_typeDelimiter;
public final static String FILE_PATTERN_NEGATOR= "!"; //$NON-NLS-1$
- private static final Comparator FILE_TYPES_COMPARATOR= new Comparator() {
+ private static final Comparator<String> FILE_TYPES_COMPARATOR= new Comparator<String>() {
@Override
- public int compare(Object o1, Object o2) {
- return compare((String) o1, (String) o2);
- }
public int compare(String fp1, String fp2) {
boolean isNegative1= fp1.startsWith(FILE_PATTERN_NEGATOR);
boolean isNegative2= fp2.startsWith(FILE_PATTERN_NEGATOR);
@@ -78,14 +75,14 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener
}
public String[] getFileTypes() {
- Set result= new HashSet();
+ Set<String> result= new HashSet<>();
StringTokenizer tokenizer= new StringTokenizer(fTextField.getText(), TYPE_DELIMITER);
while (tokenizer.hasMoreTokens()) {
String currentExtension= tokenizer.nextToken().trim();
result.add(currentExtension);
}
- return (String[]) result.toArray(new String[result.size()]);
+ return result.toArray(new String[result.size()]);
}
public void setFileTypes(String[] types) {
@@ -96,7 +93,7 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener
TypeFilteringDialog dialog= new TypeFilteringDialog(fTextField.getShell(), Arrays.asList(getFileTypes()));
if (dialog.open() == Window.OK) {
Object[] result= dialog.getResult();
- HashSet patterns= new HashSet();
+ HashSet<String> patterns= new HashSet<>();
boolean starIncluded= false;
for (int i= 0; i < result.length; i++) {
String curr= result[i].toString();
@@ -109,7 +106,7 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener
if (patterns.isEmpty() && starIncluded) { // remove star when other file extensions active
patterns.add("*"); //$NON-NLS-1$
}
- String[] filePatterns= (String[]) patterns.toArray(new String[patterns.size()]);
+ String[] filePatterns= patterns.toArray(new String[patterns.size()]);
Arrays.sort(filePatterns);
setFileTypes(filePatterns);
}
diff --git a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java b/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
index 314073d90..e0a0e3158 100644
--- a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
+++ b/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
@@ -1576,7 +1576,7 @@ public class ProjectionDocumentTest extends TestCase {
public void test22() {
// test document events sent out by the slave document when adding segments
- final List receivedEvents= new ArrayList();
+ final List<DocumentEvent> receivedEvents= new ArrayList<>();
IDocumentListener listener= new IDocumentListener() {
@Override
@@ -1606,7 +1606,7 @@ public class ProjectionDocumentTest extends TestCase {
public void test23() {
// test document events sent out by the slave document when removing segments
- final List receivedEvents= new ArrayList();
+ final List<DocumentEvent> receivedEvents= new ArrayList<>();
IDocumentListener listener= new IDocumentListener() {
@Override
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
index 82e70551f..0290286ad 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,7 +28,7 @@ import org.eclipse.core.runtime.Assert;
public class Accessor {
/** The class to access. */
- private Class fClass;
+ private Class<?> fClass;
/** The instance to access. */
private Object fInstance;
@@ -40,7 +40,7 @@ public class Accessor {
* @param instance the instance
* @param clazz the class
*/
- public Accessor(Object instance, Class clazz) {
+ public Accessor(Object instance, Class<?> clazz) {
org.eclipse.core.runtime.Assert.isNotNull(instance);
Assert.isNotNull(clazz);
fInstance= instance;
@@ -94,7 +94,7 @@ public class Accessor {
* @param constructorTypes the types of the constructor arguments
* @param constructorArgs the constructor arguments
*/
- public Accessor(String className, ClassLoader classLoader, Class[] constructorTypes, Object[] constructorArgs) {
+ public Accessor(String className, ClassLoader classLoader, Class<?>[] constructorTypes, Object[] constructorArgs) {
try {
fClass= Class.forName(className, true, classLoader);
} catch (ClassNotFoundException e) {
@@ -102,7 +102,7 @@ public class Accessor {
} catch (ExceptionInInitializerError e) {
fail();
}
- Constructor constructor= null;
+ Constructor<?> constructor= null;
try {
constructor= fClass.getDeclaredConstructor(constructorTypes);
} catch (SecurityException e2) {
@@ -168,7 +168,7 @@ public class Accessor {
* @param arguments the method arguments
* @return the method return value
*/
- public Object invoke(String methodName, Class[] types, Object[] arguments) {
+ public Object invoke(String methodName, Class<?>[] types, Object[] arguments) {
Method method= null;
try {
method= fClass.getDeclaredMethod(methodName, types);
@@ -312,12 +312,12 @@ public class Accessor {
return field;
}
- private static Class[] getTypes(Object[] objects) {
+ private static Class<?>[] getTypes(Object[] objects) {
if (objects == null)
return null;
int length= objects.length;
- Class[] classes= new Class[length];
+ Class<?>[] classes= new Class[length];
for (int i= 0; i < length; i++) {
Assert.isNotNull(objects[i]);
classes[i]= objects[i].getClass();
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java
index 764712c15..c39b3f91a 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,10 +16,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
@@ -28,6 +24,10 @@ import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModelListener;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
* Tests the {@link org.eclipse.jface.text.source.IAnnotationModelExtension2}.
@@ -38,7 +38,7 @@ public class AnnotationModelExtension2Test extends TestCase {
public class OldAnnotationModel implements IAnnotationModel {
- private final HashMap fAnnotations= new HashMap();
+ private final HashMap<Annotation, Position> fAnnotations= new HashMap<>();
@Override
public void addAnnotation(Annotation annotation, Position position) {
@@ -58,13 +58,13 @@ public class AnnotationModelExtension2Test extends TestCase {
}
@Override
- public Iterator getAnnotationIterator() {
+ public Iterator<Annotation> getAnnotationIterator() {
return fAnnotations.keySet().iterator();
}
@Override
public Position getPosition(Annotation annotation) {
- return (Position) fAnnotations.get(annotation);
+ return fAnnotations.get(annotation);
}
@Override
@@ -135,7 +135,7 @@ public class AnnotationModelExtension2Test extends TestCase {
}
private void assertEquals(Annotation[] expected, Annotation[] actual, IAnnotationModel insideModel, IAnnotationModel beforeModel, IAnnotationModel afterModel) {
- HashSet expectedSet= new HashSet(Arrays.asList(expected));
+ HashSet<Annotation> expectedSet= new HashSet<>(Arrays.asList(expected));
for (int i= 0; i < actual.length; i++) {
if (!expectedSet.contains(actual[i])) {
String message= "Unexpected annotation " + getName(actual[i]) + " in result with models [" + getAnnotationModelNames(insideModel, beforeModel, afterModel) + "]";
@@ -146,8 +146,8 @@ public class AnnotationModelExtension2Test extends TestCase {
if (!expectedSet.isEmpty()) {
String message= "Missing annotations in result with models [" + getAnnotationModelNames(insideModel, beforeModel, afterModel) + "]";
- for (Iterator iterator= expectedSet.iterator(); iterator.hasNext();) {
- Annotation missing= (Annotation) iterator.next();
+ for (Iterator<Annotation> iterator= expectedSet.iterator(); iterator.hasNext();) {
+ Annotation missing= iterator.next();
message= message + "\n" + getName(missing);
}
assertTrue(message, false);
@@ -210,14 +210,14 @@ public class AnnotationModelExtension2Test extends TestCase {
}
private Annotation[] getAnnotations(boolean lookAhead, boolean lookBehind) {
- Iterator iterator= fAnnotationModel.getAnnotationIterator(10, 11, lookAhead, lookBehind);
+ Iterator<Annotation> iterator= fAnnotationModel.getAnnotationIterator(10, 11, lookAhead, lookBehind);
- ArrayList result= new ArrayList();
+ ArrayList<Annotation> result= new ArrayList<>();
while (iterator.hasNext()) {
result.add(iterator.next());
}
- return (Annotation[]) result.toArray(new Annotation[result.size()]);
+ return result.toArray(new Annotation[result.size()]);
}
private void assertPermutations(boolean lookAhead, boolean lookBehind, Annotation[] expected) {
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
index 6926f671e..4e5bca4b9 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,16 +14,16 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModel;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
* @since 3.4
@@ -1253,8 +1253,8 @@ public class AnnotationModelStressTest extends TestCase {
return null;
}
- private void assertRemove(ArrayList added) {
- AnnotationData first= (AnnotationData) added.remove(0);
+ private void assertRemove(ArrayList<AnnotationData> added) {
+ AnnotationData first= added.remove(0);
IAnnotationModel model= getModel(first.annotationNumber);
assertTrue(model.getPosition(first.annotation) == first.position);
@@ -1262,7 +1262,7 @@ public class AnnotationModelStressTest extends TestCase {
assertTrue(model.getPosition(first.annotation) == null);
}
- private void assertAdd(AnnotationData data, ArrayList added) {
+ private void assertAdd(AnnotationData data, ArrayList<AnnotationData> added) {
Annotation annotation= new Annotation(false);
Position position= new Position(data.offset, data.length);
IAnnotationModel model= getModel(data.annotationNumber);
@@ -1276,18 +1276,18 @@ public class AnnotationModelStressTest extends TestCase {
added.add(data);
}
- private void assertExist(ArrayList added) {
+ private void assertExist(ArrayList<AnnotationData> added) {
for (int i= 0, size= added.size(); i < size; i++) {
- AnnotationData data= (AnnotationData) added.get(i);
+ AnnotationData data= added.get(i);
IAnnotationModel model= getModel(data.annotationNumber);
assertTrue(model.getPosition(data.annotation) == data.position);
}
- ArrayList annotations= getAllAnnotations();
+ ArrayList<Annotation> annotations= getAllAnnotations();
assertEquals(added.size(), annotations.size());
for (int i= 0, size= annotations.size(); i < size; i++) {
- Annotation annotation= (Annotation) annotations.get(i);
+ Annotation annotation= annotations.get(i);
AnnotationData data= getAnnotationData(added, annotation);
assertNotNull(data);
@@ -1296,18 +1296,18 @@ public class AnnotationModelStressTest extends TestCase {
}
}
- private void assertExistNew(ArrayList added) {
+ private void assertExistNew(ArrayList<AnnotationData> added) {
for (int i= 0, size= added.size(); i < size; i++) {
- AnnotationData data= (AnnotationData) added.get(i);
+ AnnotationData data= added.get(i);
IAnnotationModel model= getModel(data.annotationNumber);
assertTrue(model.getPosition(data.annotation) == data.position);
}
- ArrayList annotations= getAllAnnotationsNew();
+ ArrayList<Annotation> annotations= getAllAnnotationsNew();
assertEquals(added.size(), annotations.size());
for (int i= 0, size= annotations.size(); i < size; i++) {
- Annotation annotation= (Annotation) annotations.get(i);
+ Annotation annotation= annotations.get(i);
AnnotationData data= getAnnotationData(added, annotation);
assertNotNull(data);
@@ -1316,19 +1316,19 @@ public class AnnotationModelStressTest extends TestCase {
}
}
- private AnnotationData getAnnotationData(ArrayList datas, Annotation annotation) {
+ private AnnotationData getAnnotationData(ArrayList<AnnotationData> datas, Annotation annotation) {
for (int i= 0, size= datas.size(); i < size; i++) {
- AnnotationData data= (AnnotationData) datas.get(i);
+ AnnotationData data= datas.get(i);
if (data.annotation == annotation)
return data;
}
return null;
}
- private ArrayList getAllAnnotations() {
- ArrayList result= new ArrayList();
+ private ArrayList<Annotation> getAllAnnotations() {
+ ArrayList<Annotation> result= new ArrayList<>();
- Iterator iterator= fAnnotationModel.getAnnotationIterator();
+ Iterator<Annotation> iterator= fAnnotationModel.getAnnotationIterator();
while (iterator.hasNext()) {
result.add(iterator.next());
}
@@ -1336,10 +1336,10 @@ public class AnnotationModelStressTest extends TestCase {
return result;
}
- private ArrayList getAllAnnotationsNew() {
- ArrayList result= new ArrayList();
+ private ArrayList<Annotation> getAllAnnotationsNew() {
+ ArrayList<Annotation> result= new ArrayList<>();
- Iterator iterator= fAnnotationModel.getAnnotationIterator(0, fDocument.getLength(), true, true);
+ Iterator<Annotation> iterator= fAnnotationModel.getAnnotationIterator(0, fDocument.getLength(), true, true);
while (iterator.hasNext()) {
result.add(iterator.next());
}
@@ -1348,7 +1348,7 @@ public class AnnotationModelStressTest extends TestCase {
}
public void testStressTestPlainOld() throws Exception {
- ArrayList added= new ArrayList();
+ ArrayList<AnnotationData> added= new ArrayList<>();
int i= 0;
while (i < 20) {
AnnotationData data= RANDOM_ANNOTATIONS[i];
@@ -1378,7 +1378,7 @@ public class AnnotationModelStressTest extends TestCase {
}
public void testStressTestPlainNew() throws Exception {
- ArrayList added= new ArrayList();
+ ArrayList<AnnotationData> added= new ArrayList<>();
int i= 0;
while (i < 20) {
AnnotationData data= RANDOM_ANNOTATIONS[i];
@@ -1408,7 +1408,7 @@ public class AnnotationModelStressTest extends TestCase {
}
public void testStressTestMoveOld() throws Exception {
- ArrayList added= new ArrayList();
+ ArrayList<AnnotationData> added= new ArrayList<>();
int i= 0;
while (i < 20) {
AnnotationData data= RANDOM_ANNOTATIONS[i];
@@ -1442,7 +1442,7 @@ public class AnnotationModelStressTest extends TestCase {
}
public void testStressTestMoveNew() throws Exception {
- ArrayList added= new ArrayList();
+ ArrayList<AnnotationData> added= new ArrayList<>();
int i= 0;
while (i < 20) {
AnnotationData data= RANDOM_ANNOTATIONS[i];
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
index 47ed07ee7..40126d353 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,10 +14,6 @@ package org.eclipse.text.tests;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.DocumentEvent;
@@ -27,6 +23,10 @@ import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.projection.ChildDocument;
import org.eclipse.jface.text.projection.ChildDocumentManager;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class DocumentExtensionTest extends TestCase {
@@ -116,15 +116,15 @@ public class DocumentExtensionTest extends TestCase {
static class TestDocumentListener implements IDocumentListener {
private IDocument fDocument1;
- private List fTrace1;
+ private List<TestDocumentEvent> fTrace1;
private TestDocumentEvent fExpected1;
- private List fTrace2;
+ private List<TestDocumentEvent> fTrace2;
private TestDocumentEvent fExpected2;
private boolean fPopped= false;
- public TestDocumentListener(IDocument d1, List t1, List t2) {
+ public TestDocumentListener(IDocument d1, List<TestDocumentEvent> t1, List<TestDocumentEvent> t2) {
fDocument1= d1;
fTrace1= t1;
fTrace2= t2;
@@ -134,8 +134,8 @@ public class DocumentExtensionTest extends TestCase {
public void documentAboutToBeChanged(DocumentEvent received) {
if (!fPopped) {
fPopped= true;
- fExpected1= (TestDocumentEvent) fTrace1.remove(0);
- fExpected2= (TestDocumentEvent) fTrace2.remove(0);
+ fExpected1= fTrace1.remove(0);
+ fExpected2= fTrace2.remove(0);
}
TestDocumentEvent e= (received.getDocument() == fDocument1 ? fExpected1 : fExpected2);
@@ -252,9 +252,9 @@ public class DocumentExtensionTest extends TestCase {
assertTrue("axxxxxbxxxxxcxxxxx".equals(document.get()));
}
- private List createTrace(IDocument document, int repetitions) {
+ private List<TestDocumentEvent> createTrace(IDocument document, int repetitions) {
int i;
- List trace= new ArrayList();
+ List<TestDocumentEvent> trace= new ArrayList<>();
trace.add(new TestDocumentEvent(document, 0, 0, "c"));
for (i= 0; i < repetitions; i++)
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java
index c5c7b687b..16176538c 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,10 +15,6 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.text.edits.CopySourceEdit;
import org.eclipse.text.edits.CopyTargetEdit;
import org.eclipse.text.edits.DeleteEdit;
@@ -38,9 +34,13 @@ import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class TextEditTests extends TestCase {
- private static final Class THIS= TextEditTests.class;
+ private static final Class<TextEditTests> THIS= TextEditTests.class;
private IDocument fDocument;
private MultiTextEdit fRoot;
@@ -274,9 +274,9 @@ public class TextEditTests extends TestCase {
TextEdit e2= new ReplaceEdit(2, 3, "3456");
root.addChild(e1);
root.addChild(e2);
- List org= flatten(root);
+ List<TextEdit> org= flatten(root);
TextEditCopier copier= new TextEditCopier(root);
- List copy= flatten(copier.perform());
+ List<TextEdit> copy= flatten(copier.perform());
compare(org, copy);
}
@@ -290,19 +290,19 @@ public class TextEditTests extends TestCase {
root.addChild(s1);
root.addChild(t1);
root.addChild(t2);
- List org= flatten(root);
+ List<TextEdit> org= flatten(root);
TextEditCopier copier= new TextEditCopier(root);
- List copy= flatten(copier.perform());
+ List<TextEdit> copy= flatten(copier.perform());
compare(org, copy);
}
- private List flatten(TextEdit edit) {
- List result= new ArrayList();
+ private List<TextEdit> flatten(TextEdit edit) {
+ List<TextEdit> result= new ArrayList<>();
flatten(result, edit);
return result;
}
- private static void flatten(List result, TextEdit edit) {
+ private static void flatten(List<TextEdit> result, TextEdit edit) {
result.add(edit);
TextEdit[] children= edit.getChildren();
for (int i= 0; i < children.length; i++) {
@@ -310,10 +310,10 @@ public class TextEditTests extends TestCase {
}
}
- private static void compare(List org, List copy) {
+ private static void compare(List<TextEdit> org, List<TextEdit> copy) {
assertTrue("Same length", org.size() == copy.size());
- for (Iterator iter= copy.iterator(); iter.hasNext();) {
- TextEdit edit= (TextEdit)iter.next();
+ for (Iterator<TextEdit> iter= copy.iterator(); iter.hasNext();) {
+ TextEdit edit= iter.next();
assertTrue("Original is part of copy list", !org.contains(edit));
if (edit instanceof MoveSourceEdit) {
MoveSourceEdit source= (MoveSourceEdit)edit;
@@ -1206,7 +1206,8 @@ public class TextEditTests extends TestCase {
public void testComparator() throws Exception {
DeleteEdit d1= new DeleteEdit(1,3);
Accessor accessor= new Accessor(d1, TextEdit.class);
- Comparator comparator= (Comparator)accessor.get("INSERTION_COMPARATOR");
+ @SuppressWarnings("unchecked")
+ Comparator<TextEdit> comparator= (Comparator<TextEdit>)accessor.get("INSERTION_COMPARATOR");
TextEdit edit1= new InsertEdit(1, "test");
TextEdit edit2= new InsertEdit(1, "test");
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java
index 9bddfec24..e8390adf4 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java
@@ -56,7 +56,7 @@ public class TextUtilitiesTest extends TestCase {
private final DocumentListener fDocumentListener= new DocumentListener();
/** The buffered events. */
- private final List fEvents= new ArrayList();
+ private final List<DocumentEvent> fEvents= new ArrayList<>();
public LazilyMirroredDocument(IDocument document) {
document.addDocumentListener(fDocumentListener);
@@ -107,7 +107,7 @@ public class TextUtilitiesTest extends TestCase {
private final DocumentListener fDocumentListener= new DocumentListener();
/** The buffered events. */
- private final List fEvents= new ArrayList();
+ private final List<DocumentEvent> fEvents= new ArrayList<>();
public LazilyMirroredDocument2(IDocument document) {
document.addDocumentListener(fDocumentListener);
@@ -187,7 +187,7 @@ public class TextUtilitiesTest extends TestCase {
try {
- List events= new ArrayList();
+ List<DocumentEvent> events= new ArrayList<>();
int currentLength= 0;
events.add(new DocumentEvent(reference, 0, 0, "foo bar goo haa"));
@@ -198,8 +198,8 @@ public class TextUtilitiesTest extends TestCase {
events.add(new DocumentEvent(reference, 9, 2, "asd"));
events.add(new DocumentEvent(reference, 0, 2, "asd"));
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
+ for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
+ DocumentEvent event= iterator.next();
currentLength += event.getText().length() - event.getLength();
}
@@ -210,8 +210,8 @@ public class TextUtilitiesTest extends TestCase {
events.add(event);
}
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
+ for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
+ DocumentEvent event= iterator.next();
// System.err.println(event.getOffset() + ", " + event.getLength() + ", [" + event.getText() + "]") ;
@@ -239,7 +239,7 @@ public class TextUtilitiesTest extends TestCase {
try {
- List events= new ArrayList();
+ List<DocumentEvent> events= new ArrayList<>();
int currentLength= 0;
events.add(new DocumentEvent(reference, 0, 0, "foo bar goo haa"));
@@ -250,8 +250,8 @@ public class TextUtilitiesTest extends TestCase {
events.add(new DocumentEvent(reference, 9, 2, "asd"));
events.add(new DocumentEvent(reference, 0, 2, "asd"));
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
+ for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
+ DocumentEvent event= iterator.next();
currentLength += event.getText().length() - event.getLength();
}
@@ -262,8 +262,8 @@ public class TextUtilitiesTest extends TestCase {
events.add(event);
}
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
+ for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
+ DocumentEvent event= iterator.next();
reference.replace(event.getOffset(), event.getLength(), event.getText());
if (Math.random() < 0.3) {
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java
index eb145a344..6914890ac 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,8 +17,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@@ -27,12 +25,14 @@ import org.eclipse.jface.text.link.LinkedModeModel;
import org.eclipse.jface.text.link.LinkedPosition;
import org.eclipse.jface.text.link.LinkedPositionGroup;
+import junit.framework.TestCase;
+
public class LinkedModeModelTest extends TestCase {
- private List fPositions= new LinkedList();
+ private List<LinkedPosition> fPositions= new LinkedList<>();
- private List fDocumentMap= new ArrayList();
+ private List<IDocument[]> fDocumentMap= new ArrayList<>();
public void testUpdate() throws BadLocationException {
IDocument doc1= new Document(GARTEN1);
@@ -541,7 +541,7 @@ public class LinkedModeModelTest extends TestCase {
}
private void assertUnchanged(LinkedPositionGroup actual1, LinkedPositionGroup actual2) throws BadLocationException {
- LinkedPosition[] exp= (LinkedPosition[]) fPositions.toArray(new LinkedPosition[0]);
+ LinkedPosition[] exp= fPositions.toArray(new LinkedPosition[0]);
LinkedPosition[] act1= actual1.getPositions();
LinkedPosition[] act2= actual2.getPositions();
LinkedPosition[] act= new LinkedPosition[act1.length + act2.length];
@@ -620,8 +620,8 @@ public class LinkedModeModelTest extends TestCase {
}
private IDocument getOriginal(IDocument doc) {
- for (Iterator it = fDocumentMap.iterator(); it.hasNext(); ) {
- IDocument[] docs = (IDocument[]) it.next();
+ for (Iterator<IDocument[]> it = fDocumentMap.iterator(); it.hasNext(); ) {
+ IDocument[] docs = it.next();
if (docs[0] == doc)
return docs[1];
}
@@ -814,13 +814,10 @@ public class LinkedModeModelTest extends TestCase {
public void resume(LinkedModeModel environment, int flags) {}
}
- public class PositionComparator implements Comparator {
+ public class PositionComparator implements Comparator<LinkedPosition> {
@Override
- public int compare(Object o1, Object o2) {
- LinkedPosition p1= (LinkedPosition) o1;
- LinkedPosition p2= (LinkedPosition) o2;
-
+ public int compare(LinkedPosition p1, LinkedPosition p2) {
IDocument d1= p1.getDocument();
IDocument d2= p2.getDocument();
@@ -832,8 +829,8 @@ public class LinkedModeModelTest extends TestCase {
private int getIndex(IDocument doc) {
int i= 0;
- for (Iterator it= fDocumentMap.iterator(); it.hasNext(); i++) {
- IDocument[] docs= (IDocument[]) it.next();
+ for (Iterator<IDocument[]> it= fDocumentMap.iterator(); it.hasNext(); i++) {
+ IDocument[] docs= it.next();
if (docs[0] == doc || docs[1] == doc)
return i;
}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java
index 7ded61147..494e3f1c2 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,15 +15,15 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.templates.TemplateBuffer;
import org.eclipse.jface.text.templates.TemplateException;
import org.eclipse.jface.text.templates.TemplateTranslator;
import org.eclipse.jface.text.templates.TemplateVariable;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
* @since 3.3
*/
@@ -287,7 +287,7 @@ public class TemplateTranslatorTest extends TestCase {
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("type", vars[0].getType());
- List params= new ArrayList(2);
+ List<String> params= new ArrayList<>(2);
params.add("param1");
params.add("param2");
params.add("param3");
@@ -309,7 +309,7 @@ public class TemplateTranslatorTest extends TestCase {
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("qual.type", vars[0].getType());
- List params= new ArrayList(2);
+ List<String> params= new ArrayList<>(2);
params.add("qual.param1");
params.add("qual.param2");
assertEquals(params, vars[0].getVariableType().getParams());
@@ -330,7 +330,7 @@ public class TemplateTranslatorTest extends TestCase {
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("qual.type", vars[0].getType());
- List params= new ArrayList(3);
+ List<String> params= new ArrayList<>(3);
params.add("a parameter 1");
params.add("qual.param2");
params.add("a parameter '3");
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
index 7b3b6d045..c73299bfc 100644
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
+++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
@@ -460,7 +460,7 @@ public class ProjectionDocument extends AbstractDocument {
if (fragments == null || fragments.length == 0)
return new IRegion[] { new Region(offsetInMaster, lengthInMaster) };
- List gaps= new ArrayList();
+ List<Region> gaps= new ArrayList<>();
IRegion region= fragments[0];
if (offsetInMaster < region.getOffset())
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java
index 9d1541075..820d7dfe1 100644
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java
+++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocumentManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -47,7 +47,7 @@ import org.eclipse.jface.text.ISlaveDocumentManagerExtension;
public class ProjectionDocumentManager implements IDocumentListener, ISlaveDocumentManager, ISlaveDocumentManagerExtension {
/** Registry for master documents and their projection documents. */
- private Map fProjectionRegistry= new HashMap();
+ private Map<IDocument, List<ProjectionDocument>> fProjectionRegistry= new HashMap<>();
/**
* Registers the given projection document for the given master document.
@@ -56,9 +56,9 @@ public class ProjectionDocumentManager implements IDocumentListener, ISlaveDocum
* @param projection the projection document
*/
private void add(IDocument master, ProjectionDocument projection) {
- List list= (List) fProjectionRegistry.get(master);
+ List<ProjectionDocument> list= fProjectionRegistry.get(master);
if (list == null) {
- list= new ArrayList(1);
+ list= new ArrayList<>(1);
fProjectionRegistry.put(master, list);
}
list.add(projection);
@@ -71,7 +71,7 @@ public class ProjectionDocumentManager implements IDocumentListener, ISlaveDocum
* @param projection the projection document
*/
private void remove(IDocument master, ProjectionDocument projection) {
- List list= (List) fProjectionRegistry.get(master);
+ List<ProjectionDocument> list= fProjectionRegistry.get(master);
if (list != null) {
list.remove(projection);
if (list.size() == 0)
@@ -86,7 +86,7 @@ public class ProjectionDocumentManager implements IDocumentListener, ISlaveDocum
* @return <code>true</code> if the given document is a master document known to this manager
*/
private boolean hasProjection(IDocument master) {
- return (fProjectionRegistry.get(master) instanceof List);
+ return (fProjectionRegistry.get(master) != null);
}