Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-11-30 19:23:22 +0000
committerMarkus Keller2015-12-01 12:59:16 +0000
commit96da92a20589d62dad534245c5d9c4d45618ee95 (patch)
treedb7f27dc0839db136db463ad28a7e763a6a07a91 /org.eclipse.ui.editors
parent0bbe21e0e553957dd09eda0b29e8c77a98f38048 (diff)
downloadeclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.gz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.xz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.zip
Diffstat (limited to 'org.eclipse.ui.editors')
-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
45 files changed, 619 insertions, 612 deletions
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
index 7499d06370a..f99f3d1c685 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
@@ -326,7 +326,7 @@ public class EncodingActionGroup extends ActionGroup {
/** List of encoding actions of this group. */
- private List fRetargetActions= new ArrayList();
+ private List<RetargetTextEditorAction> fRetargetActions= new ArrayList<>();
/**
* Creates a new encoding action group for an action bar contributor.
@@ -357,11 +357,11 @@ public class EncodingActionGroup extends ActionGroup {
}
});
- Iterator e= fRetargetActions.iterator();
- subMenu.add((IAction) e.next());
+ Iterator<RetargetTextEditorAction> e= fRetargetActions.iterator();
+ subMenu.add(e.next());
subMenu.add(new Separator());
while (e.hasNext())
- subMenu.add((IAction) e.next());
+ subMenu.add(e.next());
editMenu.add(subMenu);
}
@@ -374,9 +374,9 @@ public class EncodingActionGroup extends ActionGroup {
*/
public void retarget(ITextEditor editor) {
fTextEditor= editor;
- Iterator e= fRetargetActions.iterator();
+ Iterator<RetargetTextEditorAction> e= fRetargetActions.iterator();
while (e.hasNext()) {
- RetargetTextEditorAction a= (RetargetTextEditorAction) e.next();
+ RetargetTextEditorAction a= e.next();
a.setAction(editor == null ? null : editor.getAction(a.getId()));
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java
index 598ecb548f7..0efd803137f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.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
@@ -55,7 +55,7 @@ import org.eclipse.ui.PlatformUI;
*/
public class FileBufferOperationAction extends Action implements IWorkbenchWindowActionDelegate {
- private Set fResources;
+ private Set<Object> fResources;
private IPath fLocation;
private IWorkbenchWindow fWindow;
protected IFileBufferOperation fFileBufferOperation;
@@ -80,13 +80,13 @@ public class FileBufferOperationAction extends Action implements IWorkbenchWindo
@Override
public void selectionChanged(IAction action, ISelection selection) {
- fResources= new HashSet();
+ fResources= new HashSet<>();
fLocation= null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection= (IStructuredSelection) selection;
- Iterator e= structuredSelection.iterator();
+ Iterator<?> e= structuredSelection.iterator();
while (e.hasNext()) {
Object element= e.next();
if (element instanceof IResource)
@@ -139,7 +139,7 @@ public class FileBufferOperationAction extends Action implements IWorkbenchWindo
@Override
public void run(IAction action) {
if (fResources != null && !fResources.isEmpty()) {
- IFile[] files= collectFiles((IResource[]) fResources.toArray(new IResource[fResources.size()]));
+ IFile[] files= collectFiles(fResources.toArray(new IResource[fResources.size()]));
if (files != null && files.length > 0)
doRun(files, null, fFileBufferOperation);
} else if (isAcceptableLocation(fLocation))
@@ -154,13 +154,13 @@ public class FileBufferOperationAction extends Action implements IWorkbenchWindo
* @return the files to process, can be <code>null</code>
*/
protected IFile[] collectFiles(IResource[] resources) {
- Set files= new HashSet();
+ Set<IResource> files= new HashSet<>();
for (int i= 0; i < resources.length; i++) {
IResource resource= resources[i];
if ((IResource.FILE & resource.getType()) > 0)
files.add(resource);
}
- return (IFile[]) files.toArray(new IFile[files.size()]);
+ return files.toArray(new IFile[files.size()]);
}
protected final void doRun(final IFile[] files, final IPath location, final IFileBufferOperation fileBufferOperation) {
@@ -206,14 +206,14 @@ public class FileBufferOperationAction extends Action implements IWorkbenchWindo
protected final IPath[] generateLocations(IFile[] files, IProgressMonitor progressMonitor) {
progressMonitor.beginTask(TextEditorMessages.FileBufferOperationAction_collectionFiles_label, files.length);
try {
- Set locations= new HashSet();
+ Set<IPath> locations= new HashSet<>();
for (int i= 0; i < files.length; i++) {
IPath fullPath= files[i].getFullPath();
if (isAcceptableLocation(fullPath))
locations.add(fullPath);
progressMonitor.worked(1);
}
- return (IPath[]) locations.toArray(new IPath[locations.size()]);
+ return locations.toArray(new IPath[locations.size()]);
} finally {
progressMonitor.done();
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java
index 24ec9c2fe76..63ee227c408 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.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
@@ -100,9 +100,9 @@ public class FileBufferOperationHandler extends AbstractHandler {
ISelection selection= getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection= (IStructuredSelection) selection;
- ArrayList resources= new ArrayList(structuredSelection.size());
+ ArrayList<Object> resources= new ArrayList<>(structuredSelection.size());
- Iterator e= structuredSelection.iterator();
+ Iterator<?> e= structuredSelection.iterator();
while (e.hasNext()) {
Object element= e.next();
if (element instanceof IResource)
@@ -116,7 +116,7 @@ public class FileBufferOperationHandler extends AbstractHandler {
}
if (!resources.isEmpty())
- fResources= (IResource[]) resources.toArray(new IResource[resources.size()]);
+ fResources= resources.toArray(new IResource[resources.size()]);
} else if (selection instanceof ITextSelection) {
IWorkbenchWindow window= getWorkbenchWindow();
@@ -170,13 +170,13 @@ public class FileBufferOperationHandler extends AbstractHandler {
* @return an array of files
*/
protected IFile[] collectFiles(IResource[] resources) {
- Set files= new HashSet();
+ Set<IResource> files= new HashSet<>();
for (int i= 0; i < resources.length; i++) {
IResource resource= resources[i];
if ((IResource.FILE & resource.getType()) > 0)
files.add(resource);
}
- return (IFile[]) files.toArray(new IFile[files.size()]);
+ return files.toArray(new IFile[files.size()]);
}
/**
@@ -246,14 +246,14 @@ public class FileBufferOperationHandler extends AbstractHandler {
protected final IPath[] generateLocations(IFile[] files, IProgressMonitor progressMonitor) {
progressMonitor.beginTask(TextEditorMessages.FileBufferOperationHandler_collectionFiles_label, files.length);
try {
- Set locations= new HashSet();
+ Set<IPath> locations= new HashSet<>();
for (int i= 0; i < files.length; i++) {
IPath fullPath= files[i].getFullPath();
if (isAcceptableLocation(fullPath))
locations.add(fullPath);
progressMonitor.worked(1);
}
- return (IPath[]) locations.toArray(new IPath[locations.size()]);
+ return locations.toArray(new IPath[locations.size()]);
} finally {
progressMonitor.done();
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java
index 7493d9094b8..470773e6b23 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.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
@@ -152,10 +152,11 @@ public class TextEditor extends AbstractDecoratedTextEditor {
fEncodingSupport.reset();
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (IEncodingSupport.class.equals(adapter))
- return fEncodingSupport;
+ return (T) fEncodingSupport;
return super.getAdapter(adapter);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java
index b5676271dde..0cc3c8f0a22 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.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
@@ -226,11 +226,11 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
public boolean fCachedReadOnlyState;
}
- static private class SingleElementIterator implements Iterator {
+ static private class SingleElementIterator<E> implements Iterator<E> {
- private Object fElement;
+ private E fElement;
- public SingleElementIterator(Object element) {
+ public SingleElementIterator(E element) {
fElement= element;
}
@@ -240,9 +240,9 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
}
@Override
- public Object next() {
+ public E next() {
if (fElement != null) {
- Object result= fElement;
+ E result= fElement;
fElement= null;
return result;
}
@@ -262,11 +262,11 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void bufferContentAboutToBeReplaced(IFileBuffer file) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
+ List<IElementStateListener> list= new ArrayList<>(fElementStateListeners);
+ Iterator<IElementStateListener> e= list.iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
+ IElementStateListener l= e.next();
+ Iterator<Object> i= getElements(file);
while (i.hasNext())
l.elementContentAboutToBeReplaced(i.next());
}
@@ -274,11 +274,11 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void bufferContentReplaced(IFileBuffer file) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
+ List<IElementStateListener> list= new ArrayList<>(fElementStateListeners);
+ Iterator<IElementStateListener> e= list.iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
+ IElementStateListener l= e.next();
+ Iterator<Object> i= getElements(file);
while (i.hasNext())
l.elementContentReplaced(i.next());
}
@@ -286,18 +286,18 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void stateChanging(IFileBuffer file) {
- Iterator i= getElements(file);
+ Iterator<Object> i= getElements(file);
while (i.hasNext())
fireElementStateChanging(i.next());
}
@Override
public void dirtyStateChanged(IFileBuffer file, boolean isDirty) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
+ List<IElementStateListener> list= new ArrayList<>(fElementStateListeners);
+ Iterator<IElementStateListener> e= list.iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
+ IElementStateListener l= e.next();
+ Iterator<Object> i= getElements(file);
while (i.hasNext())
l.elementDirtyStateChanged(i.next(), isDirty);
}
@@ -305,13 +305,13 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void stateValidationChanged(IFileBuffer file, boolean isStateValidated) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
+ List<IElementStateListener> list= new ArrayList<>(fElementStateListeners);
+ Iterator<IElementStateListener> e= list.iterator();
while (e.hasNext()) {
Object l= e.next();
if (l instanceof IElementStateListenerExtension) {
IElementStateListenerExtension x= (IElementStateListenerExtension) l;
- Iterator i= getElements(file);
+ Iterator<Object> i= getElements(file);
while (i.hasNext())
x.elementStateValidationChanged(i.next(), isStateValidated);
}
@@ -323,11 +323,11 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
IWorkspace workspace=ResourcesPlugin.getWorkspace();
IFile newFile= workspace.getRoot().getFile(newLocation);
IEditorInput input= new FileEditorInput(newFile);
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
+ List<IElementStateListener> list= new ArrayList<>(fElementStateListeners);
+ Iterator<IElementStateListener> e= list.iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
+ IElementStateListener l= e.next();
+ Iterator<Object> i= getElements(file);
while (i.hasNext())
l.elementMoved(i.next(), input);
}
@@ -335,11 +335,11 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void underlyingFileDeleted(IFileBuffer file) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
+ List<IElementStateListener> list= new ArrayList<>(fElementStateListeners);
+ Iterator<IElementStateListener> e= list.iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
+ IElementStateListener l= e.next();
+ Iterator<Object> i= getElements(file);
while (i.hasNext())
l.elementDeleted(i.next());
}
@@ -347,7 +347,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void stateChangeFailed(IFileBuffer file) {
- Iterator i= getElements(file);
+ Iterator<Object> i= getElements(file);
while (i.hasNext())
fireElementStateChangeFailed(i.next());
}
@@ -366,11 +366,11 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
/** The parent document provider. */
private IDocumentProvider fParentProvider;
/** Element information of all connected elements. */
- private final Map fFileInfoMap= new HashMap();
- /** Map from file buffers to their connected elements. */
- private final Map fFileBufferMap= new HashMap();
+ private final Map<Object, FileInfo> fFileInfoMap= new HashMap<>();
+ /** Map from file buffers to their connected elements. Value is an Object or a {@code List<Object>}. */
+ private final Map<ITextFileBuffer, Object> fFileBufferMap= new HashMap<>();
/** The list of element state listeners. */
- private List fElementStateListeners= new ArrayList();
+ private List<IElementStateListener> fElementStateListeners= new ArrayList<>();
/** The file buffer listener. */
private final IFileBufferListener fFileBufferListener= new FileBufferListener();
/** The progress monitor. */
@@ -472,7 +472,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void connect(Object element) throws CoreException {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info == null) {
info= createFileInfo(element);
@@ -499,7 +499,8 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
Object value= fFileBufferMap.get(info.fTextFileBuffer);
if (value instanceof List) {
- List list= (List) value;
+ @SuppressWarnings("unchecked")
+ List<Object> list= (List<Object>) value;
list.add(element);
return;
}
@@ -507,7 +508,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
if (value == null) {
value= element;
} else {
- List list= new ArrayList(2);
+ List<Object> list= new ArrayList<>(2);
list.add(value);
list.add(element);
@@ -637,7 +638,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void disconnect(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info == null) {
getParentProvider().disconnect(element);
@@ -667,7 +668,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
return;
if (value instanceof List) {
- List list= (List) value;
+ List<?> list= (List<?>) value;
list.remove(element);
if (list.size() == 1)
fFileBufferMap.put(info.fTextFileBuffer, list.get(0));
@@ -705,16 +706,16 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
* @param file the file buffer
* @return an iterator for all elements connected with the given file buffer
*/
- protected Iterator getElements(IFileBuffer file) {
+ protected Iterator<Object> getElements(IFileBuffer file) {
Object value= fFileBufferMap.get(file);
if (value instanceof List)
- return new ArrayList((List) value).iterator();
- return new SingleElementIterator(value);
+ return new ArrayList<Object>((List<?>) value).iterator();
+ return new SingleElementIterator<>(value);
}
@Override
public IDocument getDocument(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fTextFileBuffer.getDocument();
return getParentProvider().getDocument(element);
@@ -722,7 +723,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void resetDocument(Object element) throws CoreException {
- final FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ final FileInfo info= fFileInfoMap.get(element);
if (info != null) {
DocumentProviderOperation operation= new DocumentProviderOperation() {
@Override
@@ -763,7 +764,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
}
protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document, final boolean overwrite) throws CoreException {
- final FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ final FileInfo info= fFileInfoMap.get(element);
if (info != null) {
if (info.fTextFileBuffer.getDocument() != document) {
@@ -898,7 +899,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public long getModificationStamp(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fTextFileBuffer.getModificationStamp();
return getParentProvider().getModificationStamp(element);
@@ -906,7 +907,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public long getSynchronizationStamp(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return 0;
return getParentProvider().getSynchronizationStamp(element);
@@ -914,7 +915,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public boolean isDeleted(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null) {
IFileStore fileStore= getFileStore(info);
return fileStore == null ? true : !fileStore.fetchInfo().exists();
@@ -924,7 +925,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public boolean mustSaveDocument(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return (info.fCount == 1) && info.fTextFileBuffer.isDirty();
return getParentProvider().mustSaveDocument(element);
@@ -932,7 +933,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public boolean canSaveDocument(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fTextFileBuffer.isDirty();
return getParentProvider().canSaveDocument(element);
@@ -940,7 +941,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public IAnnotationModel getAnnotationModel(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fModel;
return getParentProvider().getAnnotationModel(element);
@@ -948,14 +949,14 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void aboutToChange(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info == null)
getParentProvider().aboutToChange(element);
}
@Override
public void changed(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info == null)
getParentProvider().changed(element);
}
@@ -986,7 +987,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public boolean isReadOnly(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fCachedReadOnlyState;
return ((IDocumentProviderExtension) getParentProvider()).isReadOnly(element);
@@ -994,7 +995,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public boolean isModifiable(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fTextFileBuffer.isStateValidated() ? !isReadOnly(element) : true;
return ((IDocumentProviderExtension) getParentProvider()).isModifiable(element);
@@ -1002,7 +1003,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void validateState(Object element, final Object computationContext) throws CoreException {
- final FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ final FileInfo info= fFileInfoMap.get(element);
if (info != null) {
DocumentProviderOperation operation= new DocumentProviderOperation() {
@Override
@@ -1025,7 +1026,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public boolean isStateValidated(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fTextFileBuffer.isStateValidated();
return ((IDocumentProviderExtension) getParentProvider()).isStateValidated(element);
@@ -1033,7 +1034,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void updateStateCache(Object element) throws CoreException {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null) {
boolean isReadOnly= isSystemFileReadOnly(info);
// See http://bugs.eclipse.org/bugs/show_bug.cgi?id=14469 for the dirty bit check
@@ -1048,14 +1049,14 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void setCanSaveDocument(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info == null)
((IDocumentProviderExtension) getParentProvider()).setCanSaveDocument(element);
}
@Override
public IStatus getStatus(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info == null)
return ((IDocumentProviderExtension) getParentProvider()).getStatus(element);
@@ -1086,7 +1087,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void synchronize(Object element) throws CoreException {
- final FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ final FileInfo info= fFileInfoMap.get(element);
if (info != null) {
DocumentProviderOperation operation= new DocumentProviderOperation() {
@Override
@@ -1121,7 +1122,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public boolean isSynchronized(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fTextFileBuffer.isSynchronized();
return ((IDocumentProviderExtension3) getParentProvider()).isSynchronized(element);
@@ -1146,7 +1147,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public String getEncoding(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fTextFileBuffer.getEncoding();
return ((IStorageDocumentProvider) getParentProvider()).getEncoding(element);
@@ -1154,7 +1155,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public void setEncoding(Object element, String encoding) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
info.fTextFileBuffer.setEncoding(encoding);
else
@@ -1163,7 +1164,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
@Override
public IContentType getContentType(Object element) throws CoreException {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
+ FileInfo info= fFileInfoMap.get(element);
if (info != null)
return info.fTextFileBuffer.getContentType();
IDocumentProvider parent= getParentProvider();
@@ -1232,25 +1233,25 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
* @return the file info object, or <code>null</code> if none
*/
protected FileInfo getFileInfo(Object element) {
- return (FileInfo) fFileInfoMap.get(element);
+ return fFileInfoMap.get(element);
}
/**
* Returns an iterator over the elements connected via this document provider.
*
- * @return an iterator over the list of elements (element type: {@link java.lang.Object})
+ * @return an iterator over the list of elements
*/
- protected Iterator getConnectedElementsIterator() {
- return new HashSet(fFileInfoMap.keySet()).iterator();
+ protected Iterator<Object> getConnectedElementsIterator() {
+ return new HashSet<>(fFileInfoMap.keySet()).iterator();
}
/**
* Returns an iterator over this document provider's file info objects.
*
- * @return the iterator over list of file info objects (element type: {@link TextFileDocumentProvider.FileInfo})
+ * @return the iterator over list of file info objects
*/
- protected Iterator getFileInfosIterator() {
- return new ArrayList(fFileInfoMap.values()).iterator();
+ protected Iterator<FileInfo> getFileInfosIterator() {
+ return new ArrayList<>(fFileInfoMap.values()).iterator();
}
/**
@@ -1261,8 +1262,8 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
* @see IElementStateListenerExtension#elementStateChanging(Object)
*/
protected void fireElementStateChanging(Object element) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
+ List<IElementStateListener> list= new ArrayList<>(fElementStateListeners);
+ Iterator<IElementStateListener> e= list.iterator();
while (e.hasNext()) {
Object l= e.next();
if (l instanceof IElementStateListenerExtension) {
@@ -1280,8 +1281,8 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPro
* @see IElementStateListenerExtension#elementStateChangeFailed(Object)
*/
protected void fireElementStateChangeFailed(Object element) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
+ List<IElementStateListener> list= new ArrayList<>(fElementStateListeners);
+ Iterator<IElementStateListener> e= list.iterator();
while (e.hasNext()) {
Object l= e.next();
if (l instanceof IElementStateListenerExtension) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java
index db85c0dc6fe..9fba7bfda78 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.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
@@ -230,15 +230,15 @@ public class TextSourceViewerConfiguration extends SourceViewerConfiguration {
protected final IHyperlinkDetector[] getRegisteredHyperlinkDetectors(ISourceViewer sourceViewer) {
HyperlinkDetectorRegistry registry= EditorsUI.getHyperlinkDetectorRegistry();
- Map targets= getHyperlinkDetectorTargets(sourceViewer);
+ Map<String, IAdaptable> targets= getHyperlinkDetectorTargets(sourceViewer);
Assert.isNotNull(targets);
IHyperlinkDetector[] result= null;
- Iterator iter= targets.entrySet().iterator();
+ Iterator<Entry<String, IAdaptable>> iter= targets.entrySet().iterator();
while (iter.hasNext()) {
- Entry target= (Entry)iter.next();
- String targetId= (String)target.getKey();
- IAdaptable context= (IAdaptable)target.getValue();
+ Entry<String, IAdaptable> target= iter.next();
+ String targetId= target.getKey();
+ IAdaptable context= target.getValue();
result= merge(result, registry.createHyperlinkDetectors(targetId, context));
}
return result;
@@ -256,8 +256,8 @@ public class TextSourceViewerConfiguration extends SourceViewerConfiguration {
* and the target context (<code>IAdaptable</code>) as value
* @since 3.3
*/
- protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
- Map targets= new HashMap();
+ protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
+ Map<String, IAdaptable> targets= new HashMap<>();
targets.put(EditorsUI.DEFAULT_TEXT_EDITOR_ID, null);
return targets;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
index 963686cf5fc..92cb4761cb3 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
@@ -182,7 +182,7 @@ public class ContributionContextTypeRegistry extends ContextTypeRegistry {
* @return the instantiated resolvers
*/
private static TemplateVariableResolver[] createResolvers(IConfigurationElement[] extensions, String contextTypeId) {
- List resolvers= new ArrayList();
+ List<TemplateVariableResolver> resolvers= new ArrayList<>();
for (int i= 0; i < extensions.length; i++) {
if (extensions[i].getName().equals(RESOLVER)) {
String declaredId= extensions[i].getAttribute(CONTEXT_TYPE_ID);
@@ -198,7 +198,7 @@ public class ContributionContextTypeRegistry extends ContextTypeRegistry {
}
}
- return (TemplateVariableResolver[]) resolvers.toArray(new TemplateVariableResolver[resolvers.size()]);
+ return resolvers.toArray(new TemplateVariableResolver[resolvers.size()]);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
index 83f1c579cc9..d7479dd8667 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
@@ -105,15 +105,15 @@ public class ContributionTemplateStore extends TemplateStore {
@Override
protected void loadContributedTemplates() throws IOException {
IConfigurationElement[] extensions= getTemplateExtensions();
- Collection contributed= readContributedTemplates(extensions);
- for (Iterator it= contributed.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ Collection<TemplatePersistenceData> contributed= readContributedTemplates(extensions);
+ for (Iterator<TemplatePersistenceData> it= contributed.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
internalAdd(data);
}
}
- private Collection readContributedTemplates(IConfigurationElement[] extensions) throws IOException {
- Collection templates= new ArrayList();
+ private Collection<TemplatePersistenceData> readContributedTemplates(IConfigurationElement[] extensions) throws IOException {
+ Collection<TemplatePersistenceData> templates= new ArrayList<>();
for (int i= 0; i < extensions.length; i++) {
if (extensions[i].getName().equals(TEMPLATE))
createTemplate(templates, extensions[i]);
@@ -125,7 +125,7 @@ public class ContributionTemplateStore extends TemplateStore {
return templates;
}
- private void readIncludedTemplates(Collection templates, IConfigurationElement element) throws IOException {
+ private void readIncludedTemplates(Collection<TemplatePersistenceData> templates, IConfigurationElement element) throws IOException {
String file= element.getAttribute(FILE);
if (file != null) {
Bundle plugin = Platform.getBundle(element.getContributor().getName());
@@ -218,7 +218,7 @@ public class ContributionTemplateStore extends TemplateStore {
return Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATES_EXTENSION_POINT);
}
- private void createTemplate(Collection map, IConfigurationElement element) {
+ private void createTemplate(Collection<TemplatePersistenceData> map, IConfigurationElement element) {
String contextTypeId= element.getAttribute(CONTEXT_TYPE_ID);
// log failures since extension point id and name are mandatory
if (contextExists(contextTypeId)) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
index 63c1bccbd55..55d8024250b 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.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
@@ -40,6 +40,7 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.editors.text.AccessibilityPreferencePage.EnumeratedDomain.EnumValue;
+import org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
@@ -208,8 +209,8 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
}
}
- private final java.util.List fItems= new ArrayList();
- private final Set fValueSet= new HashSet();
+ private final java.util.List<EnumValue> fItems= new ArrayList<>();
+ private final Set<EnumValue> fValueSet= new HashSet<>();
public void addValue(EnumValue val) {
if (fValueSet.contains(val))
@@ -220,8 +221,8 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
public int getIndex(EnumValue enumValue) {
int i= 0;
- for (Iterator it= fItems.iterator(); it.hasNext();) {
- EnumValue ev= (EnumValue) it.next();
+ for (Iterator<EnumValue> it= fItems.iterator(); it.hasNext();) {
+ EnumValue ev= it.next();
if (ev.equals(enumValue))
return i;
i++;
@@ -231,13 +232,13 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
public EnumValue getValueByIndex (int index) {
if (index >= 0 && fItems.size() > index)
- return (EnumValue) fItems.get(index);
+ return fItems.get(index);
return null;
}
public EnumValue getValueByInteger(int intValue) {
- for (Iterator it= fItems.iterator(); it.hasNext();) {
- EnumValue e= (EnumValue) it.next();
+ for (Iterator<EnumValue> it= fItems.iterator(); it.hasNext();) {
+ EnumValue e= it.next();
if (e.getIntValue() == intValue)
return e;
}
@@ -344,12 +345,12 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
*/
private boolean fFieldsInitialized= false;
- private java.util.List fInitializers= new ArrayList();
+ private java.util.List<Initializer> fInitializers= new ArrayList<>();
private InitializerFactory fInitializerFactory= new InitializerFactory();
private Control fContents;
- private ArrayList fMasterSlaveListeners= new ArrayList();
+ private ArrayList<SelectionListener> fMasterSlaveListeners= new ArrayList<>();
public AccessibilityPreferencePage() {
@@ -367,7 +368,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
private OverlayPreferenceStore createOverlayStore() {
- ArrayList overlayKeys= new ArrayList();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET));
@@ -439,8 +440,8 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
private void initializeFields() {
- for (Iterator it= fInitializers.iterator(); it.hasNext();) {
- Initializer initializer= (Initializer) it.next();
+ for (Iterator<Initializer> it= fInitializers.iterator(); it.hasNext();) {
+ Initializer initializer= it.next();
initializer.initialize();
}
@@ -463,8 +464,8 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
initializeFields();
- for (Iterator iterator= fMasterSlaveListeners.iterator(); iterator.hasNext();) {
- SelectionListener listener= (SelectionListener)iterator.next();
+ for (Iterator<SelectionListener> iterator= fMasterSlaveListeners.iterator(); iterator.hasNext();) {
+ SelectionListener listener= iterator.next();
listener.widgetSelected(null);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
index a0d8f4018d5..cf0695a4c5e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.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
@@ -55,6 +55,7 @@ import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
@@ -154,7 +155,7 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
private final ListItem[] fListModel;
private ComboViewer fDecorationViewer;
- private final Set fImageKeys= new HashSet();
+ private final Set<String> fImageKeys= new HashSet<>();
public AnnotationsConfigurationBlock(OverlayPreferenceStore store) {
Assert.isNotNull(store);
@@ -166,11 +167,11 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
- ArrayList overlayKeys= new ArrayList();
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
if (info.getHighlightPreferenceKey() != null)
@@ -527,11 +528,11 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
}
private ListItem[] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
- ArrayList listModelItems= new ArrayList();
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ ArrayList<ListItem> listModelItems= new ArrayList<>();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
if (info.isIncludeOnPreferencePage()) {
String label= info.getPreferenceLabel();
if (containsMoreThanOne(preferences.getAnnotationPreferences().iterator(), label))
@@ -544,16 +545,11 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
}
}
- Comparator comparator= new Comparator() {
+ Comparator<ListItem> comparator= new Comparator<ListItem>() {
@Override
- public int compare(Object o1, Object o2) {
- if (!(o2 instanceof ListItem))
- return -1;
- if (!(o1 instanceof ListItem))
- return 1;
-
- String label1= ((ListItem)o1).label;
- String label2= ((ListItem)o2).label;
+ public int compare(ListItem o1, ListItem o2) {
+ String label1= o1.label;
+ String label2= o2.label;
return Collator.getInstance().compare(label1, label2);
@@ -649,13 +645,13 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
return copy;
}
- private boolean containsMoreThanOne(Iterator annotationPrefernceIterator, String label) {
+ private boolean containsMoreThanOne(Iterator<AnnotationPreference> annotationPrefernceIterator, String label) {
if (label == null)
return false;
int count= 0;
while (annotationPrefernceIterator.hasNext()) {
- if (label.equals(((AnnotationPreference)annotationPrefernceIterator.next()).getPreferenceLabel()))
+ if (label.equals(annotationPrefernceIterator.next().getPreferenceLabel()))
count++;
if (count == 2)
@@ -668,8 +664,8 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
public void dispose() {
ImageRegistry registry= EditorsPlugin.getDefault().getImageRegistry();
- for (Iterator it= fImageKeys.iterator(); it.hasNext();) {
- String string= (String) it.next();
+ for (Iterator<String> it= fImageKeys.iterator(); it.hasNext();) {
+ String string= it.next();
registry.remove(string);
}
@@ -688,7 +684,7 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
if (changed) {
String[] selection= null;
- ArrayList list= new ArrayList();
+ ArrayList<String[]> list= new ArrayList<>();
// highlighting
if (item.highlightKey != null) {
@@ -712,8 +708,8 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
// set selection
if (selection == null) {
String val= item.textStyleKey == null ? SQUIGGLES[1] : fStore.getString(item.textStyleKey);
- for (Iterator iter= list.iterator(); iter.hasNext();) {
- String[] elem= (String[]) iter.next();
+ for (Iterator<String[]> iter= list.iterator(); iter.hasNext();) {
+ String[] elem= iter.next();
if (elem[1].equals(val)) {
selection= elem;
break;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java
index f635e2aeaca..20b98b019ac 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java
@@ -154,7 +154,7 @@ public class ConvertLineDelimitersAction extends FileBufferOperationAction {
*/
private IFile[] filterUnacceptableFiles(IFile[] files) {
boolean askForBinary= true;
- Set filtered= new HashSet();
+ Set<IFile> filtered= new HashSet<>();
for (int i= 0; i < files.length; i++) {
IFile file= files[i];
if (isAcceptableLocation(file.getFullPath())) {
@@ -174,7 +174,7 @@ public class ConvertLineDelimitersAction extends FileBufferOperationAction {
}
}
}
- return (IFile[]) filtered.toArray(new IFile[filtered.size()]);
+ return filtered.toArray(new IFile[filtered.size()]);
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java
index e7f5a3d18bb..ad274083f89 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.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,22 +40,23 @@ public class FileEditorInputAdapterFactory implements IAdapterFactory {
}
/** The list of provided adapters. */
- private static final Class[] ADAPTER_LIST= new Class[] { ILocationProvider.class };
+ private static final Class<?>[] ADAPTER_LIST= new Class[] { ILocationProvider.class };
/** The provided location provider */
private ILocationProvider fLocationProvider= new LocationProvider();
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (ILocationProvider.class.equals(adapterType)) {
if (adaptableObject instanceof IFile)
- return fLocationProvider;
+ return (T) fLocationProvider;
}
return null;
}
@Override
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
return ADAPTER_LIST;
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
index 2724db09139..d128c92316a 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 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
@@ -57,6 +57,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey;
+
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.HyperlinkDetectorDescriptor;
import org.eclipse.ui.texteditor.HyperlinkDetectorTargetDescriptor;
@@ -176,7 +178,7 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
}
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
- ArrayList overlayKeys= new ArrayList();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
for (int i= 0; i < fHyperlinkDetectorDescriptors.length; i++) {
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, fHyperlinkDetectorDescriptors[i].getId()));
@@ -447,7 +449,7 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
}
private Object[] getCheckedItems() {
- List result= new ArrayList();
+ List<ListItem> result= new ArrayList<>();
for (int i= 0; i < fListModel.length; i++)
if (!fStore.getBoolean(fListModel[i].id))
result.add(fListModel[i]);
@@ -513,7 +515,7 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
}
private ListItem[] createListModel() {
- ArrayList listModelItems= new ArrayList();
+ ArrayList<ListItem> listModelItems= new ArrayList<>();
for (int i= 0; i < fHyperlinkDetectorDescriptors.length; i++) {
HyperlinkDetectorDescriptor desc= fHyperlinkDetectorDescriptors[i];
HyperlinkDetectorTargetDescriptor target= desc.getTarget();
@@ -524,17 +526,11 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
listModelItems.add(new ListItem(desc.getId(), desc.getName(), target.getName(), modifierKeys));
}
- Comparator comparator= new Comparator() {
+ Comparator<ListItem> comparator= new Comparator<ListItem>() {
@Override
- public int compare(Object o1, Object o2) {
- if (!(o2 instanceof ListItem))
- return -1;
- if (!(o1 instanceof ListItem))
- return 1;
-
- String label1= ((ListItem)o1).name;
- String label2= ((ListItem)o2).name;
-
+ public int compare(ListItem o1, ListItem o2) {
+ String label1= o1.name;
+ String label2= o2.name;
return Collator.getInstance().compare(label1, label2);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java
index 10023802fee..e17b056b4b6 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.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
@@ -54,22 +54,23 @@ public class IURIEditorInputAdapterFactory implements IAdapterFactory {
/** The list of provided adapters. */
- private static final Class[] ADAPTER_LIST= new Class[] { ILocationProvider.class };
+ private static final Class<?>[] ADAPTER_LIST= new Class[] { ILocationProvider.class };
/** The provided location provider */
private ILocationProvider fLocationProvider= new LocationProvider();
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (ILocationProvider.class.equals(adapterType)) {
if (adaptableObject instanceof IURIEditorInput)
- return fLocationProvider;
+ return (T) fLocationProvider;
}
return null;
}
@Override
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
return ADAPTER_LIST;
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java
index 38a5dae7801..fbaba7547e9 100755
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.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
@@ -53,6 +53,8 @@ import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey;
+
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
@@ -79,9 +81,9 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
final String highlightKey;
final String textStyleKey;
final String textKey;
- final List validStyles;
+ final List<String[]> validStyles;
- ListItem(String label, String colorKey, String textKey, String highlightKey, String textStyleKey, List validStyles) {
+ ListItem(String label, String colorKey, String textKey, String highlightKey, String textStyleKey, List<String[]> validStyles) {
this.label= label;
this.colorKey= colorKey;
this.highlightKey= highlightKey;
@@ -141,7 +143,7 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
protected static final int INDENT= 20;
private OverlayPreferenceStore fStore;
- private ArrayList fMasterSlaveListeners= new ArrayList();
+ private ArrayList<SelectionListener> fMasterSlaveListeners= new ArrayList<>();
private OverlayPreferenceStore getPreferenceStore() {
return fStore;
@@ -155,11 +157,11 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
}
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
- ArrayList overlayKeys= new ArrayList();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
if (isLinkedModeAnnotation(info)) {
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
@@ -183,14 +185,14 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
}
private ListItem[] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
- ArrayList listModelItems= new ArrayList();
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ ArrayList<ListItem> listModelItems= new ArrayList<>();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
if (isLinkedModeAnnotation(info)) {
String label= info.getPreferenceLabel();
- List styles= getStyles(info.getAnnotationType());
+ List<String[]> styles= getStyles(info.getAnnotationType());
listModelItems.add(new ListItem(label, info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getHighlightPreferenceKey(), info.getTextStylePreferenceKey(), styles));
}
}
@@ -201,7 +203,7 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
}
- private List getStyles(Object type) {
+ private List<String[]> getStyles(Object type) {
if (type.equals(MASTER))
return Arrays.asList(new String[][] {BOX, DASHED_BOX, HIGHLIGHT, UNDERLINE, SQUIGGLES});
if (type.equals(SLAVE))
@@ -210,7 +212,7 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
return Arrays.asList(new String[][] {BOX, DASHED_BOX, HIGHLIGHT, UNDERLINE, SQUIGGLES});
if (type.equals(EXIT))
return Arrays.asList(new String[][] {IBEAM});
- return new ArrayList();
+ return new ArrayList<>();
}
/**
@@ -466,7 +468,7 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
if (changed) {
String[] selection= null;
- ArrayList list= new ArrayList();
+ ArrayList<String[]> list= new ArrayList<>();
list.addAll(item.validStyles);
@@ -476,8 +478,8 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
// set selection
if (selection == null) {
String val= getPreferenceStore().getString(item.textStyleKey);
- for (Iterator iter= list.iterator(); iter.hasNext();) {
- String[] elem= (String[]) iter.next();
+ for (Iterator<String[]> iter= list.iterator(); iter.hasNext();) {
+ String[] elem= iter.next();
if (elem[1].equals(val)) {
selection= elem;
break;
@@ -487,7 +489,7 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
fDecorationViewer.setInput(list.toArray(new Object[list.size()]));
if (selection == null)
- selection= (String[]) list.get(0);
+ selection= list.get(0);
fDecorationViewer.setSelection(new StructuredSelection((Object) selection), true);
}
}
@@ -556,9 +558,9 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
private void initializeFields() {
// Update slaves
- Iterator iter= fMasterSlaveListeners.iterator();
+ Iterator<SelectionListener> iter= fMasterSlaveListeners.iterator();
while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
+ SelectionListener listener= iter.next();
listener.widgetSelected(null);
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
index 64e5392e00c..951b60f5738 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.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 @@ public abstract class NextPreviousPulldownActionDelegate extends Action implemen
private IPreferenceStore fStore;
/** Action for handling menu item selection. */
- private static class NavigationEnablementAction extends Action implements Comparable {
+ private static class NavigationEnablementAction extends Action implements Comparable<NavigationEnablementAction> {
/** The preference store. */
private IPreferenceStore fStore;
@@ -82,13 +82,8 @@ public abstract class NextPreviousPulldownActionDelegate extends Action implemen
}
@Override
- public int compareTo(Object o) {
- if (!(o instanceof NavigationEnablementAction))
- return -1;
-
- String otherName= ((NavigationEnablementAction)o).fName;
-
- return Collator.getInstance().compare(fName, otherName);
+ public int compareTo(NavigationEnablementAction o) {
+ return Collator.getInstance().compare(fName, o.fName);
}
}
@@ -160,11 +155,11 @@ public abstract class NextPreviousPulldownActionDelegate extends Action implemen
*/
private IAction[] getActionsFromDescriptors() {
MarkerAnnotationPreferences fMarkerAnnotationPreferences= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
- SortedSet containers= new TreeSet();
+ SortedSet<NavigationEnablementAction> containers= new TreeSet<>();
- Iterator iter= fMarkerAnnotationPreferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> iter= fMarkerAnnotationPreferences.getAnnotationPreferences().iterator();
while (iter.hasNext()) {
- AnnotationPreference preference= (AnnotationPreference)iter.next();
+ AnnotationPreference preference= iter.next();
String key= preference.getShowInNextPrevDropdownToolbarActionKey();
if (key != null && fStore.getBoolean(key)) {
String preferenceKey= getPreferenceKey(preference);
@@ -182,7 +177,7 @@ public abstract class NextPreviousPulldownActionDelegate extends Action implemen
}
}
- return (IAction[]) containers.toArray(new Action[containers.size()]);
+ return containers.toArray(new Action[containers.size()]);
}
@Override
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NonExistingFileEditorInput.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NonExistingFileEditorInput.java
index 33b3670648b..049d04ff266 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NonExistingFileEditorInput.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NonExistingFileEditorInput.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
@@ -69,10 +69,11 @@ public class NonExistingFileEditorInput implements IEditorInput, ILocationProvid
return fName;
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (ILocationProvider.class.equals(adapter))
- return this;
+ return (T) this;
return Platform.getAdapterManager().getAdapter(this, adapter);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
index fc48a4af8ac..4531693e940 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.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
@@ -14,6 +14,7 @@ package org.eclipse.ui.internal.editors.text;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.swt.SWT;
@@ -37,6 +38,8 @@ import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey;
+
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
@@ -54,7 +57,7 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
private OverlayPreferenceStore fStore;
- private Map fCheckBoxes= new HashMap();
+ private Map<Button, String> fCheckBoxes= new HashMap<>();
private SelectionListener fCheckBoxListener= new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
@@ -62,7 +65,7 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void widgetSelected(SelectionEvent e) {
Button button= (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
+ fStore.setValue(fCheckBoxes.get(button), button.getSelection());
}
};
@@ -114,14 +117,14 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
}
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
- ArrayList overlayKeys= new ArrayList();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER));
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") //$NON-NLS-1$
|| (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$
@@ -140,9 +143,9 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
private String[][] createQuickDiffModel(MarkerAnnotationPreferences preferences) {
String[][] items= new String[3][];
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange")) //$NON-NLS-1$
items[0]= new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.QuickDiffConfigurationBlock_changeColor };
else if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$
@@ -154,10 +157,10 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
}
private String[][] createQuickDiffReferenceListModel() {
- java.util.List descriptors= new QuickDiff().getReferenceProviderDescriptors();
- ArrayList listModelItems= new ArrayList();
- for (Iterator it= descriptors.iterator(); it.hasNext();) {
- ReferenceProviderDescriptor descriptor= (ReferenceProviderDescriptor) it.next();
+ List<ReferenceProviderDescriptor> descriptors= new QuickDiff().getReferenceProviderDescriptors();
+ ArrayList<String[]> listModelItems= new ArrayList<>();
+ for (Iterator<ReferenceProviderDescriptor> it= descriptors.iterator(); it.hasNext();) {
+ ReferenceProviderDescriptor descriptor= it.next();
String label= LegacyActionTools.removeMnemonics(descriptor.getLabel());
listModelItems.add(new String[] { descriptor.getId(), label });
}
@@ -408,10 +411,10 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
}
private void initializeFields() {
- Iterator e= fCheckBoxes.keySet().iterator();
+ Iterator<Button> e= fCheckBoxes.keySet().iterator();
while (e.hasNext()) {
- Button b= (Button) e.next();
- String key= (String) fCheckBoxes.get(b);
+ Button b= e.next();
+ String key= fCheckBoxes.get(b);
b.setSelection(fStore.getBoolean(key));
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RefreshEditorAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RefreshEditorAction.java
index d574dc90f01..cbd84775ae5 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RefreshEditorAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RefreshEditorAction.java
@@ -37,7 +37,7 @@ public class RefreshEditorAction extends RefreshAction implements IUpdate {
@Override
public void update() {
- final IResource resource= fTextEditor == null ? null : (IResource)fTextEditor.getEditorInput().getAdapter(IResource.class);
+ final IResource resource= fTextEditor == null ? null : fTextEditor.getEditorInput().getAdapter(IResource.class);
if (resource != null)
selectionChanged(new StructuredSelection(resource));
else
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java
index 3ab60367b19..56e6f967bcf 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java
@@ -104,13 +104,13 @@ public class RemoveTrailingWhitespaceHandler extends FileBufferOperationHandler
* @since 3.2
*/
private IFile[] filterUnacceptableFiles(IFile[] files) {
- Set filtered= new HashSet();
+ Set<IFile> filtered= new HashSet<>();
for (int i= 0; i < files.length; i++) {
IFile file= files[i];
if (isAcceptableLocation(file.getFullPath()))
filtered.add(file);
}
- return (IFile[]) filtered.toArray(new IFile[filtered.size()]);
+ return filtered.toArray(new IFile[filtered.size()]);
}
@Override
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
index ac6e768c5f1..8f3b8cf846a 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.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
@@ -31,6 +31,8 @@ import org.eclipse.swt.widgets.Tree;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.resources.IContainer;
+
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
@@ -70,7 +72,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
*/
interface IElementFilter {
- void filterElements(Collection elements) throws InterruptedException;
+ void filterElements(Collection<Object> elements) throws InterruptedException;
void filterElements(Object[] elements) throws InterruptedException;
}
@@ -80,11 +82,11 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
private Object currentTreeSelection;
- private Collection expandedTreeNodes= new HashSet();
+ private Collection<Object> expandedTreeNodes= new HashSet<>();
- private Map checkedStateStore= new HashMap(9);
+ private Map<Object, List<Object>> checkedStateStore= new HashMap<>(9);
- private Collection whiteCheckedTreeItems= new HashSet();
+ private Collection<Object> whiteCheckedTreeItems= new HashSet<>();
private ListenerList listeners= new ListenerList(ListenerList.IDENTITY);
@@ -265,7 +267,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
private boolean determineShouldBeAtLeastGrayChecked(Object treeElement) {
// if any list items associated with treeElement are checked then it
// retains its gray-checked status regardless of its children
- List checked= (List) checkedStateStore.get(treeElement);
+ List<Object> checked= checkedStateStore.get(treeElement);
if (checked != null && (!checked.isEmpty()))
return true;
@@ -310,7 +312,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
Object child= children[i];
setWhiteChecked(child, true);
treeViewer.setChecked(child, true);
- checkedStateStore.put(child, new ArrayList());
+ checkedStateStore.put(child, new ArrayList<>());
}
}
@@ -341,7 +343,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
filter.filterElements(listContentProvider.getElements(treeElement));
else { //Add what we have stored
if (checkedStateStore.containsKey(treeElement))
- filter.filterElements((Collection) checkedStateStore.get(treeElement));
+ filter.filterElements(checkedStateStore.get(treeElement));
}
Object[] treeChildren= treeContentProvider.getChildren(treeElement);
@@ -365,12 +367,12 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
* @param treeElement java.lang.Object
* @param result java.util.Collection
*/
- private void findAllWhiteCheckedItems(Object treeElement, Collection result) {
+ private void findAllWhiteCheckedItems(Object treeElement, Collection<Object> result) {
if (whiteCheckedTreeItems.contains(treeElement))
result.add(treeElement);
else {
- Collection listChildren= (Collection) checkedStateStore.get(treeElement);
+ Collection<Object> listChildren= checkedStateStore.get(treeElement);
//if it is not in the store then it and its children are not interesting
if (listChildren == null)
return;
@@ -404,14 +406,14 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
* @return all of the leaf elements which are checked. This API does not
* return null in order to keep backwards compatibility.
*/
- public List getAllCheckedListItems() {
+ public List<Object> getAllCheckedListItems() {
- final ArrayList returnValue= new ArrayList();
+ final ArrayList<Object> returnValue= new ArrayList<>();
IElementFilter passThroughFilter= new IElementFilter() {
@Override
- public void filterElements(Collection elements) throws InterruptedException {
+ public void filterElements(Collection<Object> elements) throws InterruptedException {
returnValue.addAll(elements);
}
@@ -426,7 +428,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
try {
getAllCheckedListItems(passThroughFilter);
} catch (InterruptedException exception) {
- return new ArrayList();
+ return new ArrayList<>();
}
return returnValue;
@@ -439,9 +441,9 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
*
* @return the list of all of the items that are white checked
*/
- public List getAllWhiteCheckedItems() {
+ public List<Object> getAllWhiteCheckedItems() {
- List result= new ArrayList();
+ List<Object> result= new ArrayList<>();
//Iterate through the children of the root as the root is not in the
// store
@@ -469,7 +471,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
if (checkedStateStore.containsKey(treeElement))
return; // no need to proceed upwards from here
- checkedStateStore.put(treeElement, new ArrayList());
+ checkedStateStore.put(treeElement, new ArrayList<>());
Object parent= treeContentProvider.getParent(treeElement);
if (parent != null)
grayCheckHierarchy(parent);
@@ -508,7 +510,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
*/
private void initialize() {
treeViewer.setInput(root);
- this.expandedTreeNodes= new ArrayList();
+ this.expandedTreeNodes= new ArrayList<>();
this.expandedTreeNodes.add(root);
Object[] topElements= treeContentProvider.getElements(root);
if (topElements.length == 1)
@@ -526,7 +528,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
* update caused by selection
*/
private void listItemChecked(Object listElement, boolean state, boolean updatingFromSelection) {
- List checkedListItems= (List) checkedStateStore.get(currentTreeSelection);
+ List<Object> checkedListItems= checkedStateStore.get(currentTreeSelection);
//If it has not been expanded do so as the selection of list items will
// affect gray state
if (!expandedTreeNodes.contains(currentTreeSelection))
@@ -537,7 +539,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
// since the associated tree item has gone from 0 -> 1 checked
// list items, tree checking may need to be updated
grayCheckHierarchy(currentTreeSelection);
- checkedListItems= (List) checkedStateStore.get(currentTreeSelection);
+ checkedListItems= checkedStateStore.get(currentTreeSelection);
}
checkedListItems.add(listElement);
} else {
@@ -597,10 +599,10 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
});
} else {
- List listItemsToCheck= (List) checkedStateStore.get(treeElement);
+ List<Object> listItemsToCheck= checkedStateStore.get(treeElement);
if (listItemsToCheck != null) {
- Iterator listItemsEnum= listItemsToCheck.iterator();
+ Iterator<Object> listItemsEnum= listItemsToCheck.iterator();
while (listItemsEnum.hasNext())
listViewer.setChecked(listItemsEnum.next(), true);
}
@@ -615,13 +617,13 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
* @param item the tree item
* @param selectedNodes the set of selected nodes
*/
- private void primeHierarchyForSelection(Object item, Set selectedNodes) {
+ private void primeHierarchyForSelection(Object item, Set<Object> selectedNodes) {
//Only prime it if we haven't visited yet
if (selectedNodes.contains(item))
return;
- checkedStateStore.put(item, new ArrayList());
+ checkedStateStore.put(item, new ArrayList<>());
//mark as expanded as we are going to populate it after this
expandedTreeNodes.add(item);
@@ -708,7 +710,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
private void setListForWhiteSelection(Object treeElement) {
Object[] listItems= listContentProvider.getElements(treeElement);
- List listItemsChecked= new ArrayList();
+ List<Object> listItemsChecked= new ArrayList<>();
for (int i= 0; i < listItems.length; ++i) {
listItemsChecked.add(listItems[i]);
}
@@ -855,18 +857,18 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
* empty list). If a tree element does not have any selected
* items, do not include the element in the Map.
*/
- public void updateSelections(Map items) {
+ public void updateSelections(Map<IContainer, List<Object>> items) {
// We are replacing all selected items with the given selected items,
// so reinitialize everything.
this.listViewer.setAllChecked(false);
this.treeViewer.setCheckedElements(new Object[0]);
- this.whiteCheckedTreeItems= new HashSet();
- Set selectedNodes= new HashSet();
- checkedStateStore= new HashMap();
+ this.whiteCheckedTreeItems= new HashSet<>();
+ Set<Object> selectedNodes= new HashSet<>();
+ checkedStateStore= new HashMap<>();
//Update the store before the hierarchy to prevent updating parents
// before all of the children are done
- Iterator keyIterator= items.keySet().iterator();
+ Iterator<IContainer> keyIterator= items.keySet().iterator();
while (keyIterator.hasNext()) {
Object key= keyIterator.next();
primeHierarchyForSelection(key, selectedNodes);
@@ -882,7 +884,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
if (currentTreeSelection != null) {
Object displayItems= items.get(currentTreeSelection);
if (displayItems != null)
- listViewer.setCheckedElements(((List) displayItems).toArray());
+ listViewer.setCheckedElements(((List<?>) displayItems).toArray());
}
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java
index 87cd0b0b723..a5596442f3d 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.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
@@ -62,7 +62,7 @@ class SelectResourcesDialog extends Dialog {
}
private SelectResourcesBlock fResourceGroup;
- private List fAcceptedFileTypes = new ArrayList();
+ private List<Object> fAcceptedFileTypes = new ArrayList<>();
private IResource[] fInput;
private String fTitle;
private String fInstruction;
@@ -92,8 +92,8 @@ class SelectResourcesDialog extends Dialog {
}
public IResource[] getSelectedResources() {
- List items= fResourceGroup.getAllCheckedListItems();
- return (IResource[]) items.toArray(new IResource[items.size()]);
+ List<Object> items= fResourceGroup.getAllCheckedListItems();
+ return items.toArray(new IResource[items.size()]);
}
@Override
@@ -139,7 +139,7 @@ class SelectResourcesDialog extends Dialog {
@Override
public Object[] getChildren(Object o) {
if (o instanceof IWorkspaceRoot) {
- HashSet projects= new HashSet();
+ HashSet<IResource> projects= new HashSet<>();
for (int i= 0; i < fInput.length; i++) {
IResource project= fInput[i].getProject();
if ((project.getType() & resourceType) > 0)
@@ -158,7 +158,7 @@ class SelectResourcesDialog extends Dialog {
}
//filter out the desired resource types
- ArrayList results = new ArrayList();
+ ArrayList<IResource> results = new ArrayList<>();
for (int i = 0; i < members.length; i++) {
//And the test bits with the resource types to see if they are what we want
if ((members[i].getType() & resourceType) > 0 && (resourceType != IResource.FILE || fAcceptableLocationsFilter == null || fAcceptableLocationsFilter.accept(members[i]))) {
@@ -170,7 +170,7 @@ class SelectResourcesDialog extends Dialog {
//input element case
if (o instanceof ArrayList)
- return ((ArrayList) o).toArray();
+ return ((ArrayList<?>) o).toArray();
return new Object[0];
}
@@ -252,8 +252,8 @@ class SelectResourcesDialog extends Dialog {
}
};
- List list= fResourceGroup.getAllWhiteCheckedItems();
- final IResource[] resources= (IResource[]) list.toArray(new IResource[list.size()]);
+ List<Object> list= fResourceGroup.getAllWhiteCheckedItems();
+ final IResource[] resources= list.toArray(new IResource[list.size()]);
Runnable runnable = new Runnable() {
@Override
@@ -276,7 +276,7 @@ class SelectResourcesDialog extends Dialog {
String extension= resourceName.substring(separatorIndex + 1);
- Iterator e= fAcceptedFileTypes.iterator();
+ Iterator<Object> e= fAcceptedFileTypes.iterator();
while (e.hasNext()) {
if (extension.equalsIgnoreCase((String) e.next()))
return true;
@@ -291,17 +291,17 @@ class SelectResourcesDialog extends Dialog {
}
protected void setSelection(IResource[] input, IFilter filter) {
- Map selectionMap= new Hashtable();
+ Map<IContainer, List<Object>> selectionMap= new Hashtable<>();
for (int i= 0; i < input.length; i++) {
IResource resource= input[i];
if ((resource.getType() & IResource.FILE) > 0) {
if (filter.accept(resource)) {
- List files= null;
+ List<Object> files= null;
IContainer parent= resource.getParent();
if (selectionMap.containsKey(parent))
- files= (List) selectionMap.get(parent);
+ files= selectionMap.get(parent);
else
- files= new ArrayList();
+ files= new ArrayList<>();
files.add(resource);
selectionMap.put(parent, files);
@@ -313,11 +313,11 @@ class SelectResourcesDialog extends Dialog {
updateSelectionCount();
}
- private void setSelection(Map selectionMap, IContainer parent, IFilter filter) {
+ private void setSelection(Map<IContainer, List<Object>> selectionMap, IContainer parent, IFilter filter) {
try {
IResource[] resources= parent.members();
- List selections= new ArrayList();
+ List<Object> selections= new ArrayList<>();
for (int i= 0; i < resources.length; i++) {
IResource resource= resources[i];
@@ -348,7 +348,7 @@ class SelectResourcesDialog extends Dialog {
}
private void updateSelectionCount() {
- List listItems= fResourceGroup.getAllCheckedListItems();
+ List<Object> listItems= fResourceGroup.getAllCheckedListItems();
int checkedFiles= listItems == null ? 0 : listItems.size();
StringBuffer buffer= new StringBuffer();
switch (checkedFiles) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java
index 047968bd09a..fabb852146e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.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.ISharedTextColors;
class SharedTextColors implements ISharedTextColors {
/** The display table. */
- private Map fDisplayTable;
+ private Map<Display, Map<RGB, Color>> fDisplayTable;
/** Creates an returns a shared color manager. */
public SharedTextColors() {
@@ -40,13 +40,13 @@ class SharedTextColors implements ISharedTextColors {
return null;
if (fDisplayTable == null)
- fDisplayTable= new HashMap(2);
+ fDisplayTable= new HashMap<>(2);
final Display display= Display.getCurrent();
- Map colorTable= (Map) fDisplayTable.get(display);
+ Map<RGB, Color> colorTable= fDisplayTable.get(display);
if (colorTable == null) {
- colorTable= new HashMap(10);
+ colorTable= new HashMap<>(10);
fDisplayTable.put(display, colorTable);
display.disposeExec(new Runnable() {
@Override
@@ -56,7 +56,7 @@ class SharedTextColors implements ISharedTextColors {
});
}
- Color color= (Color) colorTable.get(rgb);
+ Color color= colorTable.get(rgb);
if (color == null) {
color= new Color(display, rgb);
colorTable.put(rgb, color);
@@ -70,9 +70,9 @@ class SharedTextColors implements ISharedTextColors {
if (fDisplayTable == null)
return;
- Iterator iter= fDisplayTable.values().iterator();
+ Iterator<Map<RGB, Color>> iter= fDisplayTable.values().iterator();
while (iter.hasNext())
- dispose((Map)iter.next());
+ dispose(iter.next());
fDisplayTable= null;
}
@@ -84,7 +84,7 @@ class SharedTextColors implements ISharedTextColors {
*/
private void dispose(Display display) {
if (fDisplayTable != null)
- dispose((Map)fDisplayTable.remove(display));
+ dispose(fDisplayTable.remove(display));
}
/**
@@ -93,13 +93,13 @@ class SharedTextColors implements ISharedTextColors {
* @param colorTable the color table that maps <code>RGB</code> to <code>Color</code>
* @since 3.3
*/
- private void dispose(Map colorTable) {
+ private void dispose(Map<RGB, Color> colorTable) {
if (colorTable == null)
return;
- Iterator iter= colorTable.values().iterator();
+ Iterator<Color> iter= colorTable.values().iterator();
while (iter.hasNext())
- ((Color) iter.next()).dispose();
+ iter.next().dispose();
colorTable.clear();
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
index 1d711e1d252..50d53dcb65e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
@@ -50,6 +50,8 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey;
+
import org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor;
import org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock;
import org.eclipse.ui.texteditor.spelling.SpellingEngineDescriptor;
@@ -175,9 +177,9 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
private StackLayout fStackLayout;
/* the model */
- private final Map fProviderDescriptors;
- private final Map fProviderPreferences;
- private final Map fProviderControls;
+ private final Map<String, SpellingEngineDescriptor> fProviderDescriptors;
+ private final Map<String, ISpellingPreferenceBlock> fProviderPreferences;
+ private final Map<String, Control> fProviderControls;
private ForwardingStatusMonitor fStatusMonitor;
@@ -190,13 +192,13 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
fStore.addKeys(createOverlayStoreKeys());
fStatusMonitor= new ForwardingStatusMonitor(statusMonitor);
fProviderDescriptors= createListModel();
- fProviderPreferences= new HashMap();
- fProviderControls= new HashMap();
+ fProviderPreferences= new HashMap<>();
+ fProviderControls= new HashMap<>();
}
- private Map createListModel() {
+ private Map<String, SpellingEngineDescriptor> createListModel() {
SpellingEngineDescriptor[] descs= EditorsUI.getSpellingService().getSpellingEngineDescriptors();
- Map map= new HashMap();
+ Map<String, SpellingEngineDescriptor> map= new HashMap<>();
for (int i= 0; i < descs.length; i++) {
map.put(descs[i].getId(), descs[i]);
}
@@ -205,7 +207,7 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
- ArrayList overlayKeys= new ArrayList();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SpellingService.PREFERENCE_SPELLING_ENABLED));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, SpellingService.PREFERENCE_SPELLING_ENGINE));
@@ -398,7 +400,7 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
setEnabled(fComboGroup, enabled);
SpellingEngineDescriptor desc= EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore);
String id= desc != null ? desc.getId() : ""; //$NON-NLS-1$
- final ISpellingPreferenceBlock preferenceBlock= (ISpellingPreferenceBlock) fProviderPreferences.get(id);
+ final ISpellingPreferenceBlock preferenceBlock= fProviderPreferences.get(id);
if (preferenceBlock != null) {
ISafeRunnable runnable= new ISafeRunnable() {
@Override
@@ -433,7 +435,7 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
fCurrentBlock= new ErrorPreferences(message);
} else {
id= desc.getId();
- fCurrentBlock= (ISpellingPreferenceBlock) fProviderPreferences.get(id);
+ fCurrentBlock= fProviderPreferences.get(id);
if (fCurrentBlock == null) {
try {
fCurrentBlock= desc.createPreferences();
@@ -445,7 +447,7 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
}
}
- Control control= (Control) fProviderControls.get(id);
+ Control control= fProviderControls.get(id);
if (control == null) {
final Control[] result= new Control[1];
ISafeRunnable runnable= new ISafeRunnable() {
@@ -495,7 +497,7 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
public boolean canPerformOk() {
SpellingEngineDescriptor desc= EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore);
String id= desc != null ? desc.getId() : ""; //$NON-NLS-1$
- final ISpellingPreferenceBlock block= (ISpellingPreferenceBlock) fProviderPreferences.get(id);
+ final ISpellingPreferenceBlock block= fProviderPreferences.get(id);
if (block == null)
return true;
@@ -515,8 +517,8 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void performOk() {
- for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
- final ISpellingPreferenceBlock block= (ISpellingPreferenceBlock) it.next();
+ for (Iterator<ISpellingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
+ final ISpellingPreferenceBlock block= it.next();
ISafeRunnable runnable= new ISafeRunnable() {
@Override
public void run() throws Exception {
@@ -533,8 +535,8 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void performDefaults() {
restoreFromPreferences();
- for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
- final ISpellingPreferenceBlock block= (ISpellingPreferenceBlock) it.next();
+ for (Iterator<ISpellingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
+ final ISpellingPreferenceBlock block= it.next();
ISafeRunnable runnable= new ISafeRunnable() {
@Override
public void run() throws Exception {
@@ -550,8 +552,8 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void dispose() {
- for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
- final ISpellingPreferenceBlock block= (ISpellingPreferenceBlock) it.next();
+ for (Iterator<ISpellingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
+ final ISpellingPreferenceBlock block= it.next();
ISafeRunnable runnable= new ISafeRunnable() {
@Override
public void run() throws Exception {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
index 571c0d7018e..ad2fae6dc0e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
@@ -58,6 +58,7 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey;
import org.eclipse.ui.internal.editors.text.TextEditorDefaultsPreferencePage.EnumeratedDomain.EnumValue;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
@@ -256,8 +257,8 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
}
}
- private final java.util.List fItems= new ArrayList();
- private final Set fValueSet= new HashSet();
+ private final java.util.List<EnumValue> fItems= new ArrayList<>();
+ private final Set<EnumValue> fValueSet= new HashSet<>();
public void addValue(EnumValue val) {
if (fValueSet.contains(val))
@@ -268,8 +269,8 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
public int getIndex(EnumValue enumValue) {
int i= 0;
- for (Iterator it= fItems.iterator(); it.hasNext();) {
- EnumValue ev= (EnumValue) it.next();
+ for (Iterator<EnumValue> it= fItems.iterator(); it.hasNext();) {
+ EnumValue ev= it.next();
if (ev.equals(enumValue))
return i;
i++;
@@ -279,13 +280,13 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
public EnumValue getValueByIndex (int index) {
if (index >= 0 && fItems.size() > index)
- return (EnumValue) fItems.get(index);
+ return fItems.get(index);
return null;
}
public EnumValue getValueByInteger(int intValue) {
- for (Iterator it= fItems.iterator(); it.hasNext();) {
- EnumValue e= (EnumValue) it.next();
+ for (Iterator<EnumValue> it= fItems.iterator(); it.hasNext();) {
+ EnumValue e= it.next();
if (e.getIntValue() == intValue)
return e;
}
@@ -392,7 +393,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
private static class WhitespaceCharacterPainterOptionsDialog extends Dialog {
- private java.util.List fDialogInitializers= new ArrayList();
+ private java.util.List<Initializer> fDialogInitializers= new ArrayList<>();
private OverlayPreferenceStore fDialogOverlayStore;
@@ -410,7 +411,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
}
private OverlayPreferenceStore createDialogOverlayStore() {
- ArrayList overlayKeys= new ArrayList();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_SPACES));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_SPACES));
@@ -447,8 +448,8 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
}
private void initializeShowWhitespaceCharactersPreferences() {
- for (Iterator it= fDialogInitializers.iterator(); it.hasNext();) {
- Initializer initializer= (Initializer)it.next();
+ for (Iterator<Initializer> it= fDialogInitializers.iterator(); it.hasNext();) {
+ Initializer initializer= it.next();
initializer.initialize();
}
}
@@ -670,13 +671,13 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
*/
private boolean fFieldsInitialized= false;
- private ArrayList fMasterSlaveListeners= new ArrayList();
+ private ArrayList<SelectionListener> fMasterSlaveListeners= new ArrayList<>();
- private java.util.List fInitializers= new ArrayList();
+ private java.util.List<Initializer> fInitializers= new ArrayList<>();
private InitializerFactory fInitializerFactory;
- private Map fDomains= new HashMap();
+ private Map<Domain, Text> fDomains= new HashMap<>();
public TextEditorDefaultsPreferencePage() {
@@ -688,7 +689,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
private OverlayPreferenceStore createOverlayStore() {
- ArrayList overlayKeys= new ArrayList();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_FIND_SCOPE));
@@ -1043,8 +1044,8 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
}
private void initializeFields() {
- for (Iterator it= fInitializers.iterator(); it.hasNext();) {
- Initializer initializer= (Initializer) it.next();
+ for (Iterator<Initializer> it= fInitializers.iterator(); it.hasNext();) {
+ Initializer initializer= it.next();
initializer.initialize();
}
@@ -1052,9 +1053,9 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
updateStatus(new StatusInfo());
// Update slaves
- Iterator iter= fMasterSlaveListeners.iterator();
+ Iterator<SelectionListener> iter= fMasterSlaveListeners.iterator();
while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
+ SelectionListener listener= iter.next();
listener.widgetSelected(null);
}
@@ -1205,8 +1206,8 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
combo.setLayoutData(gd);
combo.setToolTipText(preference.getDescription());
- for (Iterator it= domain.fItems.iterator(); it.hasNext();) {
- EnumValue value= (EnumValue) it.next();
+ for (Iterator<EnumValue> it= domain.fItems.iterator(); it.hasNext();) {
+ EnumValue value= it.next();
combo.add(value.getLabel());
}
@@ -1351,9 +1352,9 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
if (updateStatusOnError(checkedDomain))
return;
- Iterator iter= fDomains.keySet().iterator();
+ Iterator<Domain> iter= fDomains.keySet().iterator();
while (iter.hasNext()) {
- Domain domain= (Domain)iter.next();
+ Domain domain= iter.next();
if (domain.equals(checkedDomain))
continue;
if (updateStatusOnError(domain))
@@ -1363,7 +1364,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
}
private boolean updateStatusOnError(Domain domain) {
- Text textWidget= (Text)fDomains.get(domain);
+ Text textWidget= fDomains.get(domain);
if (textWidget.isEnabled()) {
IStatus status= domain.validate(textWidget.getText());
if (status.matches(IStatus.ERROR)) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java
index 06c344b6e38..5b8af149ef4 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 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
@@ -114,8 +114,8 @@ public class AnnotationColumn extends AbstractContributedRulerColumn implements
if (store != null && fDelegate instanceof AnnotationRulerColumn) {
final AnnotationRulerColumn column= (AnnotationRulerColumn) fDelegate;
// initial set up
- for (Iterator iter2= fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext();) {
- AnnotationPreference preference= (AnnotationPreference)iter2.next();
+ for (Iterator<AnnotationPreference> iter2= fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext();) {
+ AnnotationPreference preference= iter2.next();
String key= preference.getVerticalRulerPreferenceKey();
boolean showAnnotation= true;
if (key != null && store.contains(key))
@@ -156,9 +156,9 @@ public class AnnotationColumn extends AbstractContributedRulerColumn implements
if (preferenceKey == null)
return null;
- Iterator e= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= fAnnotationPreferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
if (info != null && preferenceKey.equals(info.getVerticalRulerPreferenceKey()))
return info;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
index 7bd4280324d..f195f6daee9 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
@@ -30,14 +30,14 @@ import org.eclipse.ui.editors.text.EditorsUI;
*/
public final class AnnotationTypeHierarchy {
- private Map fTypeMap;
- private Map fTypesCache= new HashMap();
+ private Map<String, String> fTypeMap;
+ private Map<String, AnnotationType> fTypesCache= new HashMap<>();
public AnnotationTypeHierarchy() {
}
public AnnotationType getAnnotationType(String typeName) {
- AnnotationType type= (AnnotationType) fTypesCache.get(typeName);
+ AnnotationType type= fTypesCache.get(typeName);
if (type == null) {
String[] superTypes= computeSuperTypes(typeName);
type= new AnnotationType(typeName, superTypes);
@@ -52,11 +52,11 @@ public final class AnnotationTypeHierarchy {
}
private String[] computeSuperTypes(String typeName) {
- ArrayList types= new ArrayList();
+ ArrayList<String> types= new ArrayList<>();
append(types, getDirectSuperType(typeName));
int index= 0;
while (index < types.size()) {
- String type= (String) types.get(index++);
+ String type= types.get(index++);
append(types, getDirectSuperType(type));
}
@@ -66,10 +66,10 @@ public final class AnnotationTypeHierarchy {
}
private String getDirectSuperType(String typeName) {
- return (String) getTypeMap().get(typeName);
+ return getTypeMap().get(typeName);
}
- private void append(List list, String string) {
+ private void append(List<String> list, String string) {
if (string == null || string.trim().length() == 0)
return;
@@ -77,14 +77,14 @@ public final class AnnotationTypeHierarchy {
list.add(string);
}
- private Map getTypeMap() {
+ private Map<String, String> getTypeMap() {
if (fTypeMap == null)
fTypeMap= readTypes();
return fTypeMap;
}
- private Map readTypes() {
- HashMap allTypes= new HashMap();
+ private Map<String, String> readTypes() {
+ HashMap<String, String> allTypes= new HashMap<>();
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "annotationTypes"); //$NON-NLS-1$
if (extensionPoint != null) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
index 85efcfb3056..7840f06c2a3 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
@@ -28,7 +28,7 @@ public class DelegatingAnnotationPreference extends AnnotationPreference {
private AnnotationType fType;
private AnnotationPreferenceLookup fLookup;
- private Set fCache= new HashSet();
+ private Set<Object> fCache= new HashSet<>();
public DelegatingAnnotationPreference(AnnotationType type, AnnotationPreferenceLookup lookup) {
fType= type;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java
index f639325d16b..f903c1213fc 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 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
@@ -33,8 +33,8 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.revisions.IRevisionRulerColumn;
import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension;
-import org.eclipse.jface.text.revisions.RevisionInformation;
import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode;
+import org.eclipse.jface.text.revisions.RevisionInformation;
import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IAnnotationHover;
@@ -225,10 +225,10 @@ public class LineNumberColumn extends AbstractContributedRulerColumn implements
updateRevisionAuthorVisibility(store, fDelegate);
updateRevisionIdVisibility(store, fDelegate);
- Map annotationPrefs= getAnnotationPreferenceMap();
- final AnnotationPreference changedPref= (AnnotationPreference) annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffChange"); //$NON-NLS-1$
- final AnnotationPreference addedPref= (AnnotationPreference) annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffAddition"); //$NON-NLS-1$
- final AnnotationPreference deletedPref= (AnnotationPreference) annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffDeletion"); //$NON-NLS-1$
+ Map<Object, AnnotationPreference> annotationPrefs= getAnnotationPreferenceMap();
+ final AnnotationPreference changedPref= annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffChange"); //$NON-NLS-1$
+ final AnnotationPreference addedPref= annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffAddition"); //$NON-NLS-1$
+ final AnnotationPreference deletedPref= annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffDeletion"); //$NON-NLS-1$
updateChangedColor(changedPref, store, fDelegate);
updateAddedColor(addedPref, store, fDelegate);
updateDeletedColor(deletedPref, store, fDelegate);
@@ -327,11 +327,11 @@ public class LineNumberColumn extends AbstractContributedRulerColumn implements
}
}
- private Map getAnnotationPreferenceMap() {
- Map annotationPrefs= new HashMap();
- Iterator iter= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ private Map<Object, AnnotationPreference> getAnnotationPreferenceMap() {
+ Map<Object, AnnotationPreference> annotationPrefs= new HashMap<>();
+ Iterator<AnnotationPreference> iter= fAnnotationPreferences.getAnnotationPreferences().iterator();
while (iter.hasNext()) {
- AnnotationPreference pref= (AnnotationPreference) iter.next();
+ AnnotationPreference pref= iter.next();
Object type= pref.getAnnotationType();
annotationPrefs.put(type, pref);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java
index 35f49ff8153..0dddf4d09b9 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 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
@@ -23,8 +23,8 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
public final class PropertyEventDispatcher {
- private final Map fHandlerMap= new HashMap();
- private final Map fReverseMap= new HashMap();
+ private final Map<Object, Object> fHandlerMap= new HashMap<>();
+ private final Map<Object, Object> fReverseMap= new HashMap<>();
private final IPreferenceStore fStore;
private final IPropertyChangeListener fListener= new IPropertyChangeListener() {
@Override
@@ -47,8 +47,8 @@ public final class PropertyEventDispatcher {
if (value instanceof IPropertyChangeListener)
((IPropertyChangeListener) value).propertyChange(event);
else if (value instanceof Set)
- for (Iterator it= ((Set) value).iterator(); it.hasNext(); )
- ((IPropertyChangeListener) it.next()).propertyChange(event);
+ for (@SuppressWarnings("unchecked") Iterator<IPropertyChangeListener> it= ((Set<IPropertyChangeListener>) value).iterator(); it.hasNext(); )
+ it.next().propertyChange(event);
}
public void addPropertyChangeListener(String property, IPropertyChangeListener listener) {
Assert.isLegal(property != null);
@@ -60,23 +60,27 @@ public final class PropertyEventDispatcher {
multiMapPut(fHandlerMap, property, listener);
multiMapPut(fReverseMap, listener, property);
}
- private void multiMapPut(Map map, Object key, Object value) {
+ private void multiMapPut(Map<Object, Object> map, Object key, Object value) {
Object mapping= map.get(key);
if (mapping == null) {
map.put(key, value);
} else if (mapping instanceof Set) {
- ((Set) mapping).add(value);
+ @SuppressWarnings("unchecked")
+ Set<Object> set= (Set<Object>) mapping;
+ set.add(value);
} else {
- Set set= new LinkedHashSet();
+ Set<Object> set= new LinkedHashSet<>();
set.add(mapping);
set.add(value);
map.put(key, set);
}
}
- private void multiMapRemove(Map map, Object key, Object value) {
+ private void multiMapRemove(Map<Object, Object> map, Object key, Object value) {
Object mapping= map.get(key);
if (mapping instanceof Set) {
- ((Set) mapping).remove(value);
+ @SuppressWarnings("unchecked")
+ Set<Object> set= (Set<Object>) mapping;
+ set.remove(value);
} else if (mapping != null) {
map.remove(key);
}
@@ -90,7 +94,7 @@ public final class PropertyEventDispatcher {
multiMapRemove(fHandlerMap, value, listener);
} else if (value instanceof Set) {
fReverseMap.remove(listener);
- for (Iterator it= ((Set) value).iterator(); it.hasNext();)
+ for (@SuppressWarnings("unchecked") Iterator<Object> it= ((Set<Object>) value).iterator(); it.hasNext();)
multiMapRemove(fHandlerMap, it.next(), listener);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
index 0e3c4137720..d08346b7163 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.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
@@ -402,9 +402,9 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
protected IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors) {
IOverviewRuler ruler= new OverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, sharedColors);
- Iterator e= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= fAnnotationPreferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference preference= (AnnotationPreference) e.next();
+ AnnotationPreference preference= e.next();
if (preference.contributesToHeader())
ruler.addHeaderAnnotationType(preference.getAnnotationType());
}
@@ -428,9 +428,9 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
*/
protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
- Iterator e= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= fAnnotationPreferences.getAnnotationPreferences().iterator();
while (e.hasNext())
- support.setAnnotationPreference((AnnotationPreference) e.next());
+ support.setAnnotationPreference(e.next());
support.setCursorLinePainterPreferenceKeys(CURRENT_LINE, CURRENT_LINE_COLOR);
support.setMarginPainterPreferenceKeys(PRINT_MARGIN, PRINT_MARGIN_COLOR, PRINT_MARGIN_COLUMN);
@@ -446,7 +446,7 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
if (fSourceViewerDecorationSupport != null)
fSourceViewerDecorationSupport.install(getPreferenceStore());
- IColumnSupport columnSupport= (IColumnSupport)getAdapter(IColumnSupport.class);
+ IColumnSupport columnSupport= getAdapter(IColumnSupport.class);
if (isLineNumberRulerVisible()) {
RulerColumnDescriptor lineNumberColumnDescriptor= RulerColumnRegistry.getDefault().getColumnDescriptor(LineNumberColumn.ID);
@@ -564,7 +564,7 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
if (show == isChangeInformationShowing())
return;
- IColumnSupport columnSupport= (IColumnSupport)getAdapter(IColumnSupport.class);
+ IColumnSupport columnSupport= getAdapter(IColumnSupport.class);
// only handle visibility of the combined column, but not the number/change only state
if (show && fLineColumn == null) {
@@ -820,7 +820,7 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
if (LINE_NUMBER_RULER.equals(property)) {
// only handle visibility of the combined column, but not the number/change only state
- IColumnSupport columnSupport= (IColumnSupport)getAdapter(IColumnSupport.class);
+ IColumnSupport columnSupport= getAdapter(IColumnSupport.class);
if (isLineNumberRulerVisible() && fLineColumn == null) {
RulerColumnDescriptor lineNumberColumnDescriptor= RulerColumnRegistry.getDefault().getColumnDescriptor(LineNumberColumn.ID);
if (lineNumberColumnDescriptor != null)
@@ -1385,16 +1385,17 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
setAction(ITextEditorActionConstants.PRINT, action);
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (IGotoMarker.class.equals(adapter))
- return fGotoMarkerAdapter;
+ return (T) fGotoMarkerAdapter;
if (IAnnotationAccess.class.equals(adapter))
- return getAnnotationAccess();
+ return (T) getAnnotationAccess();
if (adapter == IShowInSource.class) {
- return new IShowInSource() {
+ return (T) new IShowInSource() {
@Override
public ShowInContext getShowInContext() {
ISelection selection= null;
@@ -1408,11 +1409,11 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
if (IRevisionRulerColumn.class.equals(adapter)) {
if (fLineNumberRulerColumn instanceof IRevisionRulerColumn)
- return fLineNumberRulerColumn;
+ return (T) fLineNumberRulerColumn;
}
if (MarkerAnnotationPreferences.class.equals(adapter))
- return EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
+ return (T) EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
return super.getAdapter(adapter);
@@ -1466,7 +1467,7 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
RulerColumnDescriptor lineNumberColumnDescriptor= RulerColumnRegistry.getDefault().getColumnDescriptor(LineNumberColumn.ID);
if (lineNumberColumnDescriptor != null) {
- IColumnSupport columnSupport= (IColumnSupport)getAdapter(IColumnSupport.class);
+ IColumnSupport columnSupport= getAdapter(IColumnSupport.class);
columnSupport.setColumnVisible(lineNumberColumnDescriptor, isLineNumberRulerVisible() || isPrefQuickDiffAlwaysOn());
}
}
@@ -1702,7 +1703,7 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
* @since 3.6
*/
private Charset getCharset() {
- IEncodingSupport encodingSupport= (IEncodingSupport)getAdapter(IEncodingSupport.class);
+ IEncodingSupport encodingSupport= getAdapter(IEncodingSupport.class);
if (encodingSupport == null)
return null;
try {
@@ -1785,9 +1786,9 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
Point selection= getSourceViewer().getSelectedRange();
IAnnotationModel model= getSourceViewer().getAnnotationModel();
Annotation annotation= null;
- Iterator iter= model.getAnnotationIterator();
+ Iterator<Annotation> iter= model.getAnnotationIterator();
while (iter.hasNext()) {
- annotation= (Annotation)iter.next();
+ annotation= iter.next();
Position p= model.getPosition(annotation);
if (p.getOffset() == selection.x && p.getLength() == selection.y)
break;
@@ -1905,12 +1906,12 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
*/
private void addRulerContributionActions(IMenuManager menu) {
// store directly in generic editor preferences
- final IColumnSupport support= (IColumnSupport) getAdapter(IColumnSupport.class);
+ final IColumnSupport support= getAdapter(IColumnSupport.class);
IPreferenceStore store= EditorsUI.getPreferenceStore();
final RulerColumnPreferenceAdapter adapter= new RulerColumnPreferenceAdapter(store, AbstractTextEditor.PREFERENCE_RULER_CONTRIBUTIONS);
- List descriptors= RulerColumnRegistry.getDefault().getColumnDescriptors();
- for (Iterator t= descriptors.iterator(); t.hasNext();) {
- final RulerColumnDescriptor descriptor= (RulerColumnDescriptor) t.next();
+ List<RulerColumnDescriptor> descriptors= RulerColumnRegistry.getDefault().getColumnDescriptors();
+ for (Iterator<RulerColumnDescriptor> t= descriptors.iterator(); t.hasNext();) {
+ final RulerColumnDescriptor descriptor= t.next();
if (!descriptor.isIncludedInMenu() || !support.isColumnSupported(descriptor))
continue;
final boolean isVisible= support.isColumnVisible(descriptor);
@@ -2013,7 +2014,7 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
if (editor instanceof IGotoMarker)
gotoMarkerTarget= (IGotoMarker)editor;
else
- gotoMarkerTarget= editor != null ? (IGotoMarker)editor.getAdapter(IGotoMarker.class) : null;
+ gotoMarkerTarget= editor != null ? editor.getAdapter(IGotoMarker.class) : null;
if (gotoMarkerTarget != null) {
final IEditorInput input= editor.getEditorInput();
if (input instanceof IFileEditorInput) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
index 7ba1f7788f6..120c86346f0 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.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
@@ -70,11 +70,11 @@ import org.eclipse.ui.editors.text.EditorsUI;
public abstract class AbstractMarkerAnnotationModel extends AnnotationModel implements IPersistableAnnotationModel {
/** List of annotations whose text range became invalid because of document changes */
- private List fDeletedAnnotations= new ArrayList(2);
+ private List<Annotation> fDeletedAnnotations= new ArrayList<>(2);
/** List of registered and instantiated marker updaters */
- private List fInstantiatedMarkerUpdaters= null;
+ private List<IMarkerUpdater> fInstantiatedMarkerUpdaters= null;
/** List of registered but not yet instantiated marker updaters */
- private List fMarkerUpdaterSpecifications= null;
+ private List<IConfigurationElement> fMarkerUpdaterSpecifications= null;
private static final String ID= "id"; //$NON-NLS-1$
@@ -262,9 +262,9 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
private void installMarkerUpdaters() {
// initialize lists - indicates that the initialization happened
- fInstantiatedMarkerUpdaters= new ArrayList(2);
- HashMap markerUpdaterOrderMap = new HashMap(2);
- LinkedList markerUpdaterSpecificationsLinkedList= new LinkedList();
+ fInstantiatedMarkerUpdaters= new ArrayList<>(2);
+ HashMap<String, Integer> markerUpdaterOrderMap = new HashMap<>(2);
+ LinkedList<IConfigurationElement> markerUpdaterSpecificationsLinkedList= new LinkedList<>();
// populate list
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "markerUpdaters"); //$NON-NLS-1$
@@ -275,7 +275,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
markerUpdaterOrderMap.put(elements[i].getAttribute(ID), new Integer(i));
}
//start sorting based on required-updater definition
- HashMap markerUpdaterRequiredByOrderMap= new HashMap(2);
+ HashMap<String, ArrayList<String>> markerUpdaterRequiredByOrderMap= new HashMap<>(2);
for (int i= 0; i < elements.length; i++) {
// Required marker should execute before other updater markers
IConfigurationElement[] requiredUpdaters= elements[i].getChildren("required-updater"); //$NON-NLS-1$
@@ -292,16 +292,16 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
// Updating requiredByUpdaters to identify and log error for cyclic Dependency like A required B, B required C, C required D and D required A
// or A requires B and B requires A
- ArrayList requiredByUpdaters;
+ ArrayList<String> requiredByUpdaters;
if (markerUpdaterRequiredByOrderMap.get(requiredID) == null) {
- requiredByUpdaters= new ArrayList(2);
+ requiredByUpdaters= new ArrayList<>(2);
}
else {
- requiredByUpdaters= (ArrayList)markerUpdaterRequiredByOrderMap.get(requiredID);
+ requiredByUpdaters= markerUpdaterRequiredByOrderMap.get(requiredID);
}
// Build up extended required id list to identify Case 2
if (markerUpdaterRequiredByOrderMap.get(elements[i].getAttribute(ID)) != null) {
- ArrayList requiredByList= (ArrayList)markerUpdaterRequiredByOrderMap.get(elements[i].getAttribute(ID));
+ ArrayList<String> requiredByList= markerUpdaterRequiredByOrderMap.get(elements[i].getAttribute(ID));
requiredByUpdaters.addAll(requiredByList);
}
if (requiredByUpdaters.contains(requiredID)) { //log error if marker ID is in the required list of required ID
@@ -312,11 +312,11 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
requiredByUpdaters.add(elements[i].getAttribute(ID));
markerUpdaterRequiredByOrderMap.put(requiredID, requiredByUpdaters);
- Integer requiredLocation= (Integer)markerUpdaterOrderMap.get(requiredID);
- if (requiredLocation.intValue() > ((Integer)markerUpdaterOrderMap.get(elements[i].getAttribute(ID))).intValue()) { // If required marker is not ordered before
- int newLocation= (((Integer)markerUpdaterOrderMap.get(elements[i].getAttribute(ID))).intValue() == 0) ? 0 : (((Integer)markerUpdaterOrderMap.get(elements[i]
- .getAttribute(ID))).intValue() - 1);
- Object requiredMarker= markerUpdaterSpecificationsLinkedList.remove(requiredLocation.intValue());
+ Integer requiredLocation= markerUpdaterOrderMap.get(requiredID);
+ if (requiredLocation.intValue() > markerUpdaterOrderMap.get(elements[i].getAttribute(ID)).intValue()) { // If required marker is not ordered before
+ int newLocation= (markerUpdaterOrderMap.get(elements[i].getAttribute(ID)).intValue() == 0) ? 0 : (markerUpdaterOrderMap.get(elements[i]
+ .getAttribute(ID)).intValue() - 1);
+ IConfigurationElement requiredMarker= markerUpdaterSpecificationsLinkedList.remove(requiredLocation.intValue());
markerUpdaterSpecificationsLinkedList.add(newLocation, requiredMarker); // Put the required location before the marker
markerUpdaterOrderMap.put(requiredID, new Integer(newLocation));
markerUpdaterOrderMap.put(elements[i].getAttribute(ID), new Integer(newLocation + 1));
@@ -324,7 +324,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
}
}
}
- fMarkerUpdaterSpecifications= new ArrayList(markerUpdaterSpecificationsLinkedList);
+ fMarkerUpdaterSpecifications= new ArrayList<>(markerUpdaterSpecificationsLinkedList);
//end sorting
}
@@ -364,7 +364,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
public Position getMarkerPosition(IMarker marker) {
MarkerAnnotation a= getMarkerAnnotation(marker);
if (a != null) {
- return (Position) getAnnotationMap().get(a);
+ return getAnnotationMap().get(a);
}
return null;
}
@@ -390,12 +390,12 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
}
@Override
- protected void removeAnnotations(List annotations, boolean fireModelChanged, boolean modelInitiated) {
+ protected void removeAnnotations(List<? extends Annotation> annotations, boolean fireModelChanged, boolean modelInitiated) {
if (annotations != null && annotations.size() > 0) {
- List markerAnnotations= new ArrayList();
- for (Iterator e= annotations.iterator(); e.hasNext();) {
- Annotation a= (Annotation) e.next();
+ List<Annotation> markerAnnotations= new ArrayList<>();
+ for (Iterator<? extends Annotation> e= annotations.iterator(); e.hasNext();) {
+ Annotation a= e.next();
if (a instanceof MarkerAnnotation)
markerAnnotations.add(a);
@@ -455,8 +455,8 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
*/
private void catchupWithMarkers() throws CoreException {
- for (Iterator e=getAnnotationIterator(false); e.hasNext();) {
- Annotation a= (Annotation) e.next();
+ for (Iterator<Annotation> e=getAnnotationIterator(false); e.hasNext();) {
+ Annotation a= e.next();
if (a instanceof MarkerAnnotation)
removeAnnotation(a, false);
}
@@ -475,7 +475,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
* @return the annotation, or <code>null</code> if none
*/
public final MarkerAnnotation getMarkerAnnotation(IMarker marker) {
- Iterator e= getAnnotationIterator(false);
+ Iterator<Annotation> e= getAnnotationIterator(false);
while (e.hasNext()) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
@@ -513,9 +513,9 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
* @since 2.0
*/
private void checkMarkerUpdaters(IMarker marker) {
- List toBeDeleted= new ArrayList();
+ List<IConfigurationElement> toBeDeleted= new ArrayList<>();
for (int i= 0; i < fMarkerUpdaterSpecifications.size(); i++) {
- IConfigurationElement spec= (IConfigurationElement) fMarkerUpdaterSpecifications.get(i);
+ IConfigurationElement spec= fMarkerUpdaterSpecifications.get(i);
String markerType= spec.getAttribute("markerType"); //$NON-NLS-1$
if (markerType == null || MarkerUtilities.isMarkerType(marker, markerType)) {
toBeDeleted.add(spec);
@@ -561,7 +561,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
boolean isOK= true;
for (int i= 0; i < fInstantiatedMarkerUpdaters.size(); i++) {
- IMarkerUpdater updater= (IMarkerUpdater) fInstantiatedMarkerUpdaters.get(i);
+ IMarkerUpdater updater= fInstantiatedMarkerUpdaters.get(i);
String markerType= updater.getMarkerType();
if (markerType == null || MarkerUtilities.isMarkerType(marker, markerType)) {
@@ -624,12 +624,12 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
try {
// update all markers with the positions known by the annotation model
- for (Iterator e= getAnnotationIterator(false); e.hasNext();) {
+ for (Iterator<Annotation> e= getAnnotationIterator(false); e.hasNext();) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a= (MarkerAnnotation) o;
IMarker marker= a.getMarker();
- Position position= (Position) annotationMap.get(a);
+ Position position= annotationMap.get(a);
if ( !updateMarker(marker, document, position)) {
if ( !fDeletedAnnotations.contains(a))
fDeletedAnnotations.add(a);
@@ -655,7 +655,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
public void resetMarkers() {
// re-initializes the positions from the markers
- for (Iterator e= getAnnotationIterator(false); e.hasNext();) {
+ for (Iterator<Annotation> e= getAnnotationIterator(false); e.hasNext();) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a= (MarkerAnnotation) o;
@@ -672,7 +672,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
}
// add the markers of deleted positions back to the annotation model
- for (Iterator e= fDeletedAnnotations.iterator(); e.hasNext();) {
+ for (Iterator<Annotation> e= fDeletedAnnotations.iterator(); e.hasNext();) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a= (MarkerAnnotation) o;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
index 82ee3f86c6f..9fbd8b7ab0f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.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
@@ -123,7 +123,7 @@ public class AddMarkerAction extends TextEditorAction {
IResource resource= getResource();
if (resource == null)
return;
- Map attributes= getInitialAttributes();
+ Map<String, Object> attributes= getInitialAttributes();
if (fAskForLabel) {
if (!askForLabel(attributes))
return;
@@ -134,10 +134,11 @@ public class AddMarkerAction extends TextEditorAction {
final Shell shell= getTextEditor().getSite().getShell();
IAdaptable context= new IAdaptable() {
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == Shell.class)
- return shell;
+ return (T) shell;
return null;
}
};
@@ -168,7 +169,7 @@ public class AddMarkerAction extends TextEditorAction {
* @param attributes the attributes map
* @return <code>true</code> if a label has been entered
*/
- protected boolean askForLabel(Map attributes) {
+ protected boolean askForLabel(Map<String, Object> attributes) {
Object o= attributes.get("message"); //$NON-NLS-1$
String proposal= (o instanceof String) ? (String) o : ""; //$NON-NLS-1$
@@ -204,9 +205,9 @@ public class AddMarkerAction extends TextEditorAction {
*
* @return the attributes the new marker will be initialized with
*/
- protected Map getInitialAttributes() {
+ protected Map<String, Object> getInitialAttributes() {
- Map attributes= new HashMap(11);
+ Map<String, Object> attributes= new HashMap<>(11);
ITextSelection selection= (ITextSelection) getTextEditor().getSelectionProvider().getSelection();
if (!selection.isEmpty()) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.java
index 78acf6a9056..770092691e1 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.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
@@ -49,7 +49,7 @@ public class AddTaskAction extends AddMarkerAction {
IResource resource= getResource();
if (resource == null)
return;
- Map attributes= getInitialAttributes();
+ Map<String, Object> attributes= getInitialAttributes();
TaskPropertiesDialog dialog= new TaskPropertiesDialog(getTextEditor().getSite().getShell());
dialog.setResource(resource);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java
index 17f8a9daea9..bf9cf4d7eaf 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.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.ui.internal.texteditor.DelegatingAnnotationPreference;
public class AnnotationPreferenceLookup {
/** The map between annotation types and annotation preference fragments. */
- private Map fFragments;
+ private Map<Object, AnnotationPreference> fFragments;
/**
* Creates a new annotation preference lookup object.
@@ -79,8 +79,8 @@ public class AnnotationPreferenceLookup {
* @return the defined annotation preference fragment
*/
public AnnotationPreference getAnnotationPreferenceFragment(String annotationType) {
- Map fragments= getPreferenceFragments();
- return (AnnotationPreference) fragments.get(annotationType);
+ Map<Object, AnnotationPreference> fragments= getPreferenceFragments();
+ return fragments.get(annotationType);
}
/**
@@ -98,15 +98,15 @@ public class AnnotationPreferenceLookup {
*
* @return the map between annotation type names and annotation preference fragments
*/
- private synchronized Map getPreferenceFragments() {
+ private synchronized Map<Object, AnnotationPreference> getPreferenceFragments() {
if (fFragments == null) {
- fFragments= new HashMap();
+ fFragments= new HashMap<>();
MarkerAnnotationPreferences p= new MarkerAnnotationPreferences();
- Iterator e= p.getAnnotationPreferenceFragments().iterator();
+ Iterator<AnnotationPreference> e= p.getAnnotationPreferenceFragments().iterator();
while (e.hasNext()) {
- AnnotationPreference fragment= (AnnotationPreference) e.next();
+ AnnotationPreference fragment= e.next();
Object annotationType = fragment.getAnnotationType();
- AnnotationPreference preference= (AnnotationPreference) fFragments.get(annotationType);
+ AnnotationPreference preference= fFragments.get(annotationType);
if (preference == null)
fFragments.put(annotationType, fragment);
else
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
index 40dbb02bf7c..adb808e64f5 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.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
@@ -49,8 +49,11 @@ public final class AnnotationTypeLookup {
}
}
- /** The lookup table for marker to annotation type mappings. */
- private Map fMapping;
+ /**
+ * The lookup table for marker to annotation type mappings. The value type is a {@link String}
+ * or a {@code Map<Integer, String>}.
+ */
+ private Map<String, Object> fMapping;
/**
* Creates a new annotation lookup object.
@@ -113,8 +116,9 @@ public final class AnnotationTypeLookup {
return (String) value;
if (value instanceof Map) {
- Map severityMap= (Map) value;
- return (String) severityMap.get(new Integer(severity));
+ @SuppressWarnings("unchecked")
+ Map<Integer, String> severityMap= (Map<Integer, String>) value;
+ return severityMap.get(Integer.valueOf(severity));
}
return null;
@@ -125,18 +129,19 @@ public final class AnnotationTypeLookup {
* annotation types.
*/
private void initializeMapping() {
- fMapping= new HashMap();
- List mappings= getAnnotationTypeMappings();
+ fMapping= new HashMap<>();
+ List<AnnotationTypeMapping> mappings= getAnnotationTypeMappings();
for (int i= 0, l= mappings.size(); i < l; i++) {
- AnnotationTypeMapping atm= (AnnotationTypeMapping) mappings.get(i);
+ AnnotationTypeMapping atm= mappings.get(i);
if (atm.isMarkerSeverityDefined()) {
Object severityMap= fMapping.get(atm.fMarkerType);
if (!(severityMap instanceof Map)) {
- severityMap= new HashMap();
+ severityMap= new HashMap<>();
fMapping.put(atm.fMarkerType, severityMap);
}
- Map map= (Map) severityMap;
- map.put(new Integer(atm.fMarkerSeverity), atm.fAnnotationType);
+ @SuppressWarnings("unchecked")
+ Map<Integer, String> map= (Map<Integer, String>) severityMap;
+ map.put(Integer.valueOf(atm.fMarkerSeverity), atm.fAnnotationType);
} else {
fMapping.put(atm.fMarkerType, atm.fAnnotationType);
}
@@ -149,8 +154,8 @@ public final class AnnotationTypeLookup {
*
* @return a list of annotation type mappings
*/
- private List getAnnotationTypeMappings() {
- List annotationTypeMappings= new ArrayList();
+ private List<AnnotationTypeMapping> getAnnotationTypeMappings() {
+ List<AnnotationTypeMapping> annotationTypeMappings= new ArrayList<>();
// read compatibility mode
readExtensionPoint(annotationTypeMappings, "markerAnnotationSpecification", "annotationType"); //$NON-NLS-1$ //$NON-NLS-2$
// read new extension point
@@ -168,7 +173,7 @@ public final class AnnotationTypeLookup {
* @param typeAttributeName the name of attribute specifying the annotation
* type
*/
- private void readExtensionPoint(List annotationTypeMappings, String extensionPointName, String typeAttributeName) {
+ private void readExtensionPoint(List<AnnotationTypeMapping> annotationTypeMappings, String extensionPointName, String typeAttributeName) {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, extensionPointName);
if (extensionPoint != null) {
IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
index 5b616c2c24e..6705e52f01d 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
@@ -41,7 +41,7 @@ public class ChainedPreferenceStore implements IPreferenceStore {
private ListenerList fClientListeners= new ListenerList(ListenerList.IDENTITY);
/** Listeners on the child preference stores. */
- private List fChildListeners= new ArrayList();
+ private List<PropertyChangeListener> fChildListeners= new ArrayList<>();
/**
* Listener on the chained preference stores. Forwards only the events
@@ -470,9 +470,9 @@ public class ChainedPreferenceStore implements IPreferenceStore {
* Register the child listeners on the child preference stores.
*/
private void registerChildListeners() {
- Iterator iter= fChildListeners.iterator();
+ Iterator<PropertyChangeListener> iter= fChildListeners.iterator();
while (iter.hasNext()) {
- PropertyChangeListener listener= (PropertyChangeListener) iter.next();
+ PropertyChangeListener listener= iter.next();
listener.register();
}
}
@@ -481,9 +481,9 @@ public class ChainedPreferenceStore implements IPreferenceStore {
* Unregister the child listeners from the child preference stores.
*/
private void unregisterChildListeners() {
- Iterator iter= fChildListeners.iterator();
+ Iterator<PropertyChangeListener> iter= fChildListeners.iterator();
while (iter.hasNext()) {
- PropertyChangeListener listener= (PropertyChangeListener) iter.next();
+ PropertyChangeListener listener= iter.next();
listener.unregister();
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java
index d180e03c4f9..a8466602c4d 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.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
@@ -100,10 +100,10 @@ public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnota
*
* @since 3.0
*/
- private final static Map MAPPING;
+ private final static Map<String, String> MAPPING;
static {
- MAPPING= new HashMap();
+ MAPPING= new HashMap<>();
MAPPING.put(ERROR_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_ERROR_TSK);
MAPPING.put(WARNING_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_WARN_TSK);
MAPPING.put(INFO_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_INFO_TSK);
@@ -235,8 +235,8 @@ public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnota
// backward compatibility, ignore exceptions, just return default layer
try {
- Method method= annotation.getClass().getMethod("getLayer", null); //$NON-NLS-1$
- Integer result= (Integer) method.invoke(annotation, null);
+ Method method= annotation.getClass().getMethod("getLayer"); //$NON-NLS-1$
+ Integer result= (Integer) method.invoke(annotation);
return result.intValue();
} catch (SecurityException x) {
@@ -340,7 +340,7 @@ public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnota
*/
public static String getSharedImageName(String symbolicImageName) {
Assert.isLegal(symbolicImageName != null);
- String sharedImageName= (String)MAPPING.get(symbolicImageName);
+ String sharedImageName= MAPPING.get(symbolicImageName);
Assert.isLegal(sharedImageName != null);
return sharedImageName;
}
@@ -360,7 +360,7 @@ public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnota
if (annotation instanceof AnnotationBag) {
AnnotationBag bag= (AnnotationBag)annotation;
if (!bag.isEmpty())
- annotation= (Annotation)bag.iterator().next();
+ annotation= bag.iterator().next();
}
ImageRegistry registry= EditorsPlugin.getDefault().getImageRegistry();
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
index f15e9a6b612..b0dc84bbc75 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.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
@@ -69,11 +69,11 @@ public class DocumentProviderRegistry {
/** The mapping between name extensions and configuration elements. */
- private Map fExtensionMapping= new HashMap();
+ private Map<String, Set<IConfigurationElement>> fExtensionMapping= new HashMap<>();
/** The mapping between editor input type names and configuration elements. */
- private Map fInputTypeMapping= new HashMap();
+ private Map<String, Set<IConfigurationElement>> fInputTypeMapping= new HashMap<>();
/** The mapping between configuration elements and instantiated document providers. */
- private Map fInstances= new HashMap();
+ private Map<IConfigurationElement, IDocumentProvider> fInstances= new HashMap<>();
/**
@@ -93,16 +93,16 @@ public class DocumentProviderRegistry {
* @param element the configuration element
* @param attributeName the attribute name
*/
- private void read(Map map, IConfigurationElement element, String attributeName) {
+ private void read(Map<String, Set<IConfigurationElement>> map, IConfigurationElement element, String attributeName) {
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);
@@ -144,7 +144,7 @@ public class DocumentProviderRegistry {
* @return the document provider for the given entry
*/
private IDocumentProvider getDocumentProvider(IConfigurationElement entry) {
- IDocumentProvider provider= (IDocumentProvider) fInstances.get(entry);
+ IDocumentProvider provider= fInstances.get(entry);
if (provider == null) {
try {
provider= (IDocumentProvider) entry.createExecutableExtension("class"); //$NON-NLS-1$
@@ -161,10 +161,10 @@ public class DocumentProviderRegistry {
* @param set the set
* @return the first configuration element in the set or <code>null</code> if none
*/
- 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;
}
@@ -177,7 +177,7 @@ public class DocumentProviderRegistry {
*/
public IDocumentProvider getDocumentProvider(String extension) {
- Set set= (Set) fExtensionMapping.get(extension);
+ Set<IConfigurationElement> set= fExtensionMapping.get(extension);
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
return getDocumentProvider(entry);
@@ -192,11 +192,11 @@ public class DocumentProviderRegistry {
* @param type the type
* @return a list containing the super class hierarchy
*/
- private List computeClassList(Class type) {
+ private List<Class<?>> computeClassList(Class<?> type) {
- List result= new ArrayList();
+ List<Class<?>> result= new ArrayList<>();
- Class c= type;
+ Class<?> c= type;
while (c != null) {
result.add(c);
c= c.getSuperclass();
@@ -213,14 +213,14 @@ public class DocumentProviderRegistry {
* @param classes a list of {@link java.lang.Class} objects
* @return a list with elements of type <code>Class</code>
*/
- private List computeInterfaceList(List classes) {
+ private List<Class<?>> computeInterfaceList(List<Class<?>> classes) {
- List result= new ArrayList(4);
- Hashtable visited= new Hashtable(4);
+ List<Class<?>> result= new ArrayList<>(4);
+ Hashtable<Class<?>, Class<?>> visited= new Hashtable<>(4);
- Iterator e= classes.iterator();
+ Iterator<Class<?>> e= classes.iterator();
while (e.hasNext()) {
- Class c= (Class) e.next();
+ Class<?> c= e.next();
computeInterfaceList(c.getInterfaces(), result, visited);
}
@@ -235,12 +235,12 @@ public class DocumentProviderRegistry {
* @param result the result list
* @param visited map of visited interfaces
*/
- private void computeInterfaceList(Class[] interfaces, List result, Hashtable visited) {
+ private void computeInterfaceList(Class<?>[] interfaces, List<Class<?>> result, Hashtable<Class<?>, Class<?>> visited) {
- List toBeVisited= new ArrayList(interfaces.length);
+ List<Class<?>> toBeVisited= new ArrayList<>(interfaces.length);
for (int i= 0; i < interfaces.length; i++) {
- Class iface= interfaces[i];
+ Class<?> iface= interfaces[i];
if (visited.get(iface) == null) {
visited.put(iface, iface);
result.add(iface);
@@ -248,9 +248,9 @@ public class DocumentProviderRegistry {
}
}
- Iterator e= toBeVisited.iterator();
+ Iterator<Class<?>> e= toBeVisited.iterator();
while(e.hasNext()) {
- Class iface= (Class) e.next();
+ Class<?> iface= e.next();
computeInterfaceList(iface.getInterfaces(), result, visited);
}
}
@@ -262,11 +262,11 @@ public class DocumentProviderRegistry {
* @param classes a list of {@link java.lang.Class} objects
* @return an input type mapping or <code>null</code>
*/
- private Object getFirstInputTypeMapping(List classes) {
- Iterator e= classes.iterator();
+ private Set<IConfigurationElement> getFirstInputTypeMapping(List<Class<?>> classes) {
+ Iterator<Class<?>> e= classes.iterator();
while (e.hasNext()) {
- Class c= (Class) e.next();
- Object mapping= fInputTypeMapping.get(c.getName());
+ Class<?> c= e.next();
+ Set<IConfigurationElement> mapping= fInputTypeMapping.get(c.getName());
if (mapping != null)
return mapping;
}
@@ -281,16 +281,16 @@ public class DocumentProviderRegistry {
* @param type a {@link java.lang.Class} object
* @return an input type mapping or <code>null</code>
*/
- private Object findInputTypeMapping(Class type) {
+ private Set<IConfigurationElement> findInputTypeMapping(Class<?> type) {
if (type == null)
return null;
- Object mapping= fInputTypeMapping.get(type.getName());
+ Set<IConfigurationElement> mapping= fInputTypeMapping.get(type.getName());
if (mapping != null)
return mapping;
- List classList= computeClassList(type);
+ List<Class<?>> classList= computeClassList(type);
mapping= getFirstInputTypeMapping(classList);
if (mapping != null)
return mapping;
@@ -313,7 +313,7 @@ public class DocumentProviderRegistry {
provider= getDocumentProvider(file.getFileExtension());
if (provider == null) {
- Set set= (Set) findInputTypeMapping(editorInput.getClass());
+ Set<IConfigurationElement> set= findInputTypeMapping(editorInput.getClass());
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
provider= getDocumentProvider(entry);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
index d4ec1e35f0f..5fcf71bddf6 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
@@ -57,7 +57,7 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation implements IQuickFi
public final static int PROBLEM_LAYER= 5;
/** Internal image registry. */
- private static Map fgImageRegistry;
+ private static Map<ImageDescriptor, Image> fgImageRegistry;
/**
* Returns an image for the given display as specified by the given image
@@ -72,8 +72,8 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation implements IQuickFi
*/
@Deprecated
protected static Image getImage(Display display, ImageDescriptor descriptor) {
- Map map= getImageRegistry(display);
- Image image= (Image) map.get(descriptor);
+ Map<ImageDescriptor, Image> map= getImageRegistry(display);
+ Image image= map.get(descriptor);
if (image == null) {
image= descriptor.createImage();
map.put(descriptor, image);
@@ -92,18 +92,18 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation implements IQuickFi
* {@link org.eclipse.jface.text.source.IAnnotationPresentation}
*/
@Deprecated
- protected static Map getImageRegistry(Display display) {
+ protected static Map<ImageDescriptor, Image> getImageRegistry(Display display) {
if (fgImageRegistry == null) {
- fgImageRegistry= new HashMap();
+ fgImageRegistry= new HashMap<>();
display.disposeExec(new Runnable() {
@Override
public void run() {
if (fgImageRegistry != null) {
- Map map= fgImageRegistry;
+ Map<ImageDescriptor, Image> map= fgImageRegistry;
fgImageRegistry= null;
- Iterator e= map.values().iterator();
+ Iterator<Image> e= map.values().iterator();
while (e.hasNext()) {
- Image image= (Image) e.next();
+ Image image= e.next();
if (!image.isDisposed())
image.dispose();
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
index 17b7e5a3dab..0048f909ef2 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.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
@@ -57,9 +57,9 @@ public class MarkerAnnotationPreferences {
boolean ignoreQuickDiffPrefPage= store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE);
MarkerAnnotationPreferences preferences= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
if (ignoreAnnotationsPrefPage && info.isIncludeOnPreferencePage() && isComplete(info))
continue;
@@ -111,9 +111,9 @@ public class MarkerAnnotationPreferences {
store.putValue(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE, Boolean.toString(true));
MarkerAnnotationPreferences preferences= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
// Only reset annotations shown on Annotations preference page
if (!info.isIncludeOnPreferencePage() || !isComplete(info))
@@ -160,9 +160,9 @@ public class MarkerAnnotationPreferences {
store.putValue(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE, Boolean.toString(true));
MarkerAnnotationPreferences preferences= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
- Iterator e= preferences.getAnnotationPreferences().iterator();
+ Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
// Only reset annotations shown on Quick Diff preference page
@@ -192,7 +192,7 @@ public class MarkerAnnotationPreferences {
private static final class AccessChecker extends SecurityManager {
@Override
- public Class[] getClassContext() {
+ public Class<?>[] getClassContext() {
return super.getClassContext();
}
}
@@ -203,7 +203,7 @@ public class MarkerAnnotationPreferences {
* @since 3.0
*/
private static void checkAccess() throws IllegalStateException {
- Class[] elements = new AccessChecker().getClassContext();
+ Class<?>[] elements = new AccessChecker().getClassContext();
if (!(elements[3].equals(EditorsUI.class)
|| elements[4].equals(EditorsUI.class)))
throw new IllegalStateException();
@@ -211,9 +211,9 @@ public class MarkerAnnotationPreferences {
/** The list of extension fragments. */
- private List/*<AnnotationPreference>*/ fFragments;
+ private List<AnnotationPreference> fFragments;
/** The list of extensions. */
- private List/*<AnnotationPreference>*/ fPreferences;
+ private List<AnnotationPreference> fPreferences;
/**
* Creates a new marker annotation preferences to access
@@ -239,9 +239,8 @@ public class MarkerAnnotationPreferences {
* Returns all extensions provided for the <code>markerAnnotationSpecification</code> extension point.
*
* @return all extensions provided for the <code>markerAnnotationSpecification</code> extension point
- * (element type: {@link AnnotationPreference})
*/
- public List getAnnotationPreferences() {
+ public List<AnnotationPreference> getAnnotationPreferences() {
if (fPreferences == null)
initialize();
return fPreferences;
@@ -254,9 +253,9 @@ public class MarkerAnnotationPreferences {
* change the presentation part.
*
* @return all extensions provided for the <code>markerAnnotationSpecification</code>
- * extension point including fragments (element type: {@link AnnotationPreference})
+ * extension point including fragments
*/
- public List getAnnotationPreferenceFragments() {
+ public List<AnnotationPreference> getAnnotationPreferenceFragments() {
if (fFragments == null)
initialize();
return fFragments;
@@ -281,8 +280,8 @@ public class MarkerAnnotationPreferences {
private void initializeSharedMakerAnnotationPreferences() {
// initialize lists - indicates that the initialization happened
- fFragments= new ArrayList(2);
- fPreferences= new ArrayList(2);
+ fFragments= new ArrayList<>(2);
+ fPreferences= new ArrayList<>(2);
// populate list
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "markerAnnotationSpecification"); //$NON-NLS-1$
@@ -305,13 +304,13 @@ public class MarkerAnnotationPreferences {
* @return the cloned list of cloned annotation preferences
* @since 3.1
*/
- private List cloneAnnotationPreferences(List annotationPreferences) {
+ private List<AnnotationPreference> cloneAnnotationPreferences(List<AnnotationPreference> annotationPreferences) {
if (annotationPreferences == null)
return null;
- List clone= new ArrayList(annotationPreferences.size());
- Iterator iter= annotationPreferences.iterator();
+ List<AnnotationPreference> clone= new ArrayList<>(annotationPreferences.size());
+ Iterator<AnnotationPreference> iter= annotationPreferences.iterator();
while (iter.hasNext())
- clone.add(clone(((AnnotationPreference)iter.next())));
+ clone.add(clone(iter.next()));
return clone;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
index 2c0de048e7e..033b413a032 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.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
@@ -77,7 +77,7 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
/** The of the marker to be created/removed. */
private String fMarkerType;
/** The cached list of markers covering a particular vertical ruler position. */
- private List fMarkers;
+ private List<IMarker> fMarkers;
/** The flag indicating whether user interaction is required. */
private boolean fAskForLabel;
/** The action's resource bundle. */
@@ -212,10 +212,10 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
* @return boolean <code>true</code> if they are all editable
* @since 3.2
*/
- private boolean markersUserEditable(List markers) {
- Iterator iter= markers.iterator();
+ private boolean markersUserEditable(List<IMarker> markers) {
+ Iterator<IMarker> iter= markers.iterator();
while (iter.hasNext()) {
- if (!isUserEditable((IMarker)iter.next()))
+ if (!isUserEditable(iter.next()))
return false;
}
return true;
@@ -333,9 +333,9 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
*
* @return all a list of markers which include the ruler's line of activity
*/
- protected List getMarkers() {
+ protected List<IMarker> getMarkers() {
- List markers= new ArrayList();
+ List<IMarker> markers= new ArrayList<>();
IResource resource= getResource();
IDocument document= getDocument();
@@ -367,7 +367,7 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
IResource resource= getResource();
if (resource == null)
return;
- Map attributes= getInitialAttributes();
+ Map<String, Object> attributes= getInitialAttributes();
if (fAskForLabel) {
if (!askForLabel(attributes))
return;
@@ -380,8 +380,8 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
*
* @param markers the markers to be deleted
*/
- protected void removeMarkers(final List markers) {
- IMarker[] markersArray= (IMarker[])markers.toArray(new IMarker[markers.size()]);
+ protected void removeMarkers(final List<? extends IMarker> markers) {
+ IMarker[] markersArray= markers.toArray(new IMarker[markers.size()]);
execute(new DeleteMarkersOperation(markersArray, getOperationName()));
}
@@ -394,7 +394,7 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
* @param attributes the map of attributes
* @return <code>true</code> if the map of attributes has successfully been initialized
*/
- protected boolean askForLabel(Map attributes) {
+ protected boolean askForLabel(Map<String, Object> attributes) {
Object o= attributes.get("message"); //$NON-NLS-1$
String proposal= (o instanceof String) ? (String) o : ""; //$NON-NLS-1$
@@ -427,12 +427,11 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
* Returns the attributes with which a newly created marker will be
* initialized.
*
- * @return the initial marker attributes (key type: <code>String</code>, value type:
- * <code>Object</code>)
+ * @return the initial marker attributes
*/
- protected Map getInitialAttributes() {
+ protected Map<String, Object> getInitialAttributes() {
- Map attributes= new HashMap(11);
+ Map<String, Object> attributes= new HashMap<>(11);
IDocumentProvider provider= fTextEditor.getDocumentProvider();
IDocument document= provider.getDocument(fTextEditor.getEditorInput());
@@ -503,10 +502,11 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
private void execute(IUndoableOperation operation) {
final Shell shell= getTextEditor().getSite().getShell();
IAdaptable context= new IAdaptable() {
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == Shell.class)
- return shell;
+ return (T) shell;
return null;
}
};
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
index c02d4371b3b..2ea3f56a8b3 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.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 final class MarkerUtilities {
*/
private static class MarkerTypeHierarchy {
- private Map fTypeMap;
- private Map fSuperTypesCache= new HashMap();
+ private Map<String, String[]> fTypeMap;
+ private Map<String, String[]> fSuperTypesCache= new HashMap<>();
public String[] getSuperTypes(String typeName) {
- String[] cachedTypes= (String[]) fSuperTypesCache.get(typeName);
+ String[] cachedTypes= fSuperTypesCache.get(typeName);
if (cachedTypes == null) {
cachedTypes= computeSuperTypes(typeName);
fSuperTypesCache.put(typeName, cachedTypes);
@@ -66,11 +66,11 @@ public final class MarkerUtilities {
}
private String[] computeSuperTypes(String typeName) {
- ArrayList types= new ArrayList();
+ ArrayList<String> types= new ArrayList<>();
appendAll(types, getDirectSuperTypes(typeName));
int index= 0;
while (index < types.size()) {
- String type= (String) types.get(index++);
+ String type= types.get(index++);
appendAll(types, getDirectSuperTypes(type));
}
@@ -80,33 +80,33 @@ public final class MarkerUtilities {
}
private String[] getDirectSuperTypes(String typeName) {
- return (String[]) getTypeMap().get(typeName);
+ return getTypeMap().get(typeName);
}
- private void appendAll(List list, Object[] objects) {
+ private <T> void appendAll(List<T> list, T[] objects) {
if (objects == null)
return;
for (int i= 0; i < objects.length; i++) {
- Object o= objects[i];
+ T o= objects[i];
if (!list.contains(o))
list.add(o);
}
}
- private Map getTypeMap() {
+ private Map<String, String[]> getTypeMap() {
if (fTypeMap == null)
fTypeMap= readTypes();
return fTypeMap;
}
- private Map readTypes() {
- HashMap allTypes= new HashMap();
+ private Map<String, String[]> readTypes() {
+ HashMap<String, String[]> allTypes= new HashMap<>();
IExtensionPoint point= Platform.getExtensionRegistry().getExtensionPoint(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_MARKERS);
if (point != null) {
IExtension[] extensions = point.getExtensions();
for (int i= 0; i < extensions.length; i++) {
IExtension extension= extensions[i];
- ArrayList types= new ArrayList();
+ ArrayList<String> types= new ArrayList<>();
IConfigurationElement[] configElements= extension.getConfigurationElements();
for (int j= 0; j < configElements.length; ++j) {
IConfigurationElement element= configElements[j];
@@ -287,12 +287,11 @@ public final class MarkerUtilities {
* Sets the ending character offset in the given map using the standard
* marker attribute name as the key.
*
- * @param map the map (key type: <code>String</code>, value type:
- * <code>Object</code>)
+ * @param map the map
* @param charEnd the ending character offset
* @see IMarker#CHAR_END
*/
- public static void setCharEnd(Map map, int charEnd) {
+ public static void setCharEnd(Map<String, Object> map, int charEnd) {
map.put(IMarker.CHAR_END, new Integer(charEnd));
}
@@ -312,12 +311,11 @@ public final class MarkerUtilities {
* Sets the starting character offset in the given map using the standard
* marker attribute name as the key.
*
- * @param map the map (key type: <code>String</code>, value type:
- * <code>Object</code>)
+ * @param map the map
* @param charStart the starting character offset
* @see IMarker#CHAR_START
*/
- public static void setCharStart(Map map, int charStart) {
+ public static void setCharStart(Map<String, Object> map, int charStart) {
map.put(IMarker.CHAR_START, new Integer(charStart));
}
@@ -353,12 +351,11 @@ public final class MarkerUtilities {
* Sets the line number in the given map using the standard marker attribute
* name as the key.
*
- * @param map the map (key type: <code>String</code>, value type:
- * <code>Object</code>)
+ * @param map the map
* @param lineNum the line number
* @see IMarker#LINE_NUMBER
*/
- public static void setLineNumber(Map map, int lineNum) {
+ public static void setLineNumber(Map<String, Object> map, int lineNum) {
map.put(IMarker.LINE_NUMBER, new Integer(lineNum));
}
@@ -366,12 +363,11 @@ public final class MarkerUtilities {
* Sets the message in the given map using the standard marker attribute name
* as the key.
*
- * @param map the map (key type: <code>String</code>, value type:
- * <code>Object</code>)
+ * @param map the map
* @param message the message
* @see IMarker#MESSAGE
*/
- public static void setMessage(Map map, String message) {
+ public static void setMessage(Map<String, Object> map, String message) {
map.put(IMarker.MESSAGE, message);
}
@@ -381,13 +377,12 @@ public final class MarkerUtilities {
* This method modifies the workspace (progress is not reported to the user).</p>
*
* @param resource the resource
- * @param attributes the attribute map (key type: <code>String</code>,
- * value type: <code>Object</code>)
+ * @param attributes the attribute map
* @param markerType the type of marker
* @throws CoreException if this method fails
* @see IResource#createMarker(java.lang.String)
*/
- public static void createMarker(final IResource resource, final Map attributes, final String markerType) throws CoreException {
+ public static void createMarker(final IResource resource, final Map<String, Object> attributes, final String markerType) throws CoreException {
IWorkspaceRunnable r= new IWorkspaceRunnable() {
@Override
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
index 819ee7a70a7..ea352062831 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.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,6 +27,7 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
@@ -116,8 +117,8 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel
* @param markerDeltas the array of marker deltas
*/
private void batchedUpdate(IMarkerDelta[] markerDeltas) {
- HashSet removedMarkers= new HashSet(markerDeltas.length);
- HashSet modifiedMarkers= new HashSet(markerDeltas.length);
+ HashSet<IMarker> removedMarkers= new HashSet<>(markerDeltas.length);
+ HashSet<IMarker> modifiedMarkers= new HashSet<>(markerDeltas.length);
for (int i= 0; i < markerDeltas.length; i++) {
IMarkerDelta delta= markerDeltas[i];
@@ -137,7 +138,7 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel
if (modifiedMarkers.isEmpty() && removedMarkers.isEmpty())
return;
- Iterator e= getAnnotationIterator(false);
+ Iterator<Annotation> e= getAnnotationIterator(false);
while (e.hasNext()) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
@@ -161,9 +162,9 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel
}
}
- Iterator iter= modifiedMarkers.iterator();
+ Iterator<IMarker> iter= modifiedMarkers.iterator();
while (iter.hasNext())
- addMarkerAnnotation((IMarker)iter.next());
+ addMarkerAnnotation(iter.next());
}
@Override
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java
index d2db5b778da..c526d80b5d4 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.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
@@ -190,7 +190,7 @@ public class SelectMarkerRulerAction extends ResourceAction implements IUpdate {
* @param markers the list of markers to choose from
* @return the chosen marker or <code>null</code> if none of the given markers has a marker annotation in the model
*/
- protected final IMarker chooseMarker(List markers) {
+ protected final IMarker chooseMarker(List<? extends IMarker> markers) {
AbstractMarkerAnnotationModel model= getAnnotationModel();
IAnnotationAccessExtension access= getAnnotationAccessExtension();
@@ -198,9 +198,9 @@ public class SelectMarkerRulerAction extends ResourceAction implements IUpdate {
IMarker marker= null;
int maxLayer= 0;
- Iterator iter= markers.iterator();
+ Iterator<? extends IMarker> iter= markers.iterator();
while (iter.hasNext()) {
- IMarker m= (IMarker) iter.next();
+ IMarker m= iter.next();
Annotation a= model.getMarkerAnnotation(m);
if (a != null) {
if (access == null) {
@@ -363,37 +363,36 @@ public class SelectMarkerRulerAction extends ResourceAction implements IUpdate {
* Returns all markers which include the ruler's line of activity.
*
* @return an unmodifiable list with all markers which include the ruler's line of activity
- * (element type: {@link IMarker})
*/
- protected final List getMarkers() {
+ protected final List<IMarker> getMarkers() {
final IResource resource= getResource();
if (resource == null || !resource.exists())
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
final IDocument document= getDocument();
if (document == null)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
final AbstractMarkerAnnotationModel model= getAnnotationModel();
if (model == null)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
final IMarker[] allMarkers;
try {
allMarkers= resource.findMarkers(null, true, IResource.DEPTH_ZERO);
} catch (CoreException x) {
handleCoreException(x, TextEditorMessages.SelectMarkerRulerAction_getMarker);
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
if (allMarkers.length == 0)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
final int activeLine= fRuler.getLineOfLastMouseButtonActivity();
if (activeLine == -1)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
- Iterator it;
+ Iterator<Annotation> it;
try {
IRegion line= document.getLineInformation(activeLine);
it= model.getAnnotationIterator(line.getOffset(), line.getLength() + 1, true, true);
@@ -404,14 +403,14 @@ public class SelectMarkerRulerAction extends ResourceAction implements IUpdate {
it= model.getAnnotationIterator();
}
- List markers= null;
+ List<IMarker> markers= null;
while (it.hasNext()) {
- Annotation annotation= (Annotation) it.next();
+ Annotation annotation= it.next();
if (annotation instanceof MarkerAnnotation) {
Position position= model.getPosition(annotation);
if (includesLine(position, document, activeLine)) {
if (markers == null)
- markers= new ArrayList(10);
+ markers= new ArrayList<>(10);
markers.add(((MarkerAnnotation) annotation).getMarker());
}
@@ -419,16 +418,15 @@ public class SelectMarkerRulerAction extends ResourceAction implements IUpdate {
}
if (markers == null)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
return Collections.unmodifiableList(markers);
}
/**
- * Returns all markers which include the ruler's line of activity.
+ * Returns <code>true</code> iff there are any markers which include the ruler's line of activity.
*
- * @return an unmodifiable list with all markers which include the ruler's line of activity
- * (element type: {@link IMarker})
+ * @return <code>true</code> iff there are any markers which include the ruler's line of activity.
* @since 3.3
*/
protected final boolean hasMarkers() {
@@ -459,7 +457,7 @@ public class SelectMarkerRulerAction extends ResourceAction implements IUpdate {
if (activeLine == -1)
return false;
- Iterator it;
+ Iterator<Annotation> it;
try {
IRegion line= document.getLineInformation(activeLine);
it= model.getAnnotationIterator(line.getOffset(), line.getLength() + 1, true, true);
@@ -469,7 +467,7 @@ public class SelectMarkerRulerAction extends ResourceAction implements IUpdate {
}
while (it.hasNext()) {
- Annotation annotation= (Annotation) it.next();
+ Annotation annotation= it.next();
if (annotation instanceof MarkerAnnotation) {
Position position= model.getPosition(annotation);
if (includesLine(position, document, activeLine)) {

Back to the top