Skip to content

Commit 35b9674

Browse files
committed
Fix raw type warnings in org.eclipse.ui.ide
Fixes those raw type warnings in org.eclipse.ui.ide that do not affect public API.
1 parent 55034d1 commit 35b9674

31 files changed

+185
-182
lines changed

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,11 @@ protected boolean updateSelection(IStructuredSelection selection) {
333333

334334
// to enable this command there must be one project selected and nothing
335335
// else
336-
List selectedResources = getSelectedResources();
336+
List<? extends IResource> selectedResources = getSelectedResources();
337337
if (selectedResources.size() != 1) {
338338
return false;
339339
}
340-
IResource source = (IResource) selectedResources.get(0);
340+
IResource source = selectedResources.get(0);
341341
if (source instanceof IProject && ((IProject) source).isOpen()) {
342342
return true;
343343
}

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.eclipse.core.resources.IContainer;
2020
import org.eclipse.core.resources.IResource;
21+
import org.eclipse.core.runtime.IPath;
2122
import org.eclipse.jface.window.IShellProvider;
2223
import org.eclipse.swt.widgets.Shell;
2324
import org.eclipse.ui.PlatformUI;
@@ -46,7 +47,7 @@ public class MoveResourceAction extends CopyResourceAction {
4647
* Keep a list of destinations so that any required update can be done after the
4748
* move.
4849
*/
49-
protected List destinations;
50+
protected List<IPath> destinations;
5051

5152
/**
5253
* Creates a new action.
@@ -97,7 +98,7 @@ protected List getDestinations() {
9798
}
9899

99100
@Override
100-
protected IResource[] getResources(List resourceList) {
101+
protected IResource[] getResources(List<? extends IResource> resourceList) {
101102
ReadOnlyStateChecker checker = new ReadOnlyStateChecker(getShell(),
102103
IDEWorkbenchMessages.MoveResourceAction_title,
103104
IDEWorkbenchMessages.MoveResourceAction_checkMoveMessage);
@@ -107,7 +108,7 @@ protected IResource[] getResources(List resourceList) {
107108
@Override
108109
protected void runOperation(IResource[] resources, IContainer destination) {
109110
//Initialize the destinations
110-
destinations = new ArrayList();
111+
destinations = new ArrayList<>();
111112
IResource[] copiedResources = operation.copyResources(resources,
112113
destination);
113114

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private boolean promptToOpenWithReferences() {
186186
@Override
187187
public void resourceChanged(IResourceChangeEvent event) {
188188
// Warning: code duplicated in CloseResourceAction
189-
List sel = getSelectedResources();
189+
List<? extends IResource> sel = getSelectedResources();
190190
// don't bother looking at delta if selection not applicable
191191
if (selectionIsOfType(IResource.PROJECT)) {
192192
IResourceDelta delta = event.getDelta();

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public ReadOnlyStateChecker(Shell parent, String title, String message) {
6969
* Return true if all items are selected and false if any are skipped.
7070
*/
7171
private boolean checkAcceptedResource(IResource resourceToCheck,
72-
List selectedChildren) throws CoreException {
72+
List<IResource> selectedChildren) throws CoreException {
7373

7474
if (resourceToCheck.getType() == IResource.FILE) {
7575
selectedChildren.add(resourceToCheck);
@@ -142,15 +142,15 @@ public IResource[] checkReadOnlyResources(IResource[] itemsToCheck) {
142142
* @param allSelected the List of currently selected resources to add to.
143143
*/
144144
private int checkReadOnlyResources(IResource[] itemsToCheck,
145-
List allSelected) throws CoreException {
145+
List<IResource> allSelected) throws CoreException {
146146

147147
//Shortcut. If the user has already selected yes to all then just return it
148148
if (yesToAllSelected) {
149149
return IDialogConstants.YES_TO_ALL_ID;
150150
}
151151

152152
boolean noneSkipped = true;
153-
List selectedChildren = new ArrayList();
153+
List<IResource> selectedChildren = new ArrayList<>();
154154

155155
for (IResource resourceToCheck : itemsToCheck) {
156156
ResourceAttributes checkAttributes = resourceToCheck.getResourceAttributes();

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public Object[] getResult() {
374374
if (result == null)
375375
return null;
376376

377-
List resultToReturn = new ArrayList();
377+
List<Object> resultToReturn = new ArrayList<>();
378378

379379
for (Object element : result) {
380380
if (element instanceof IResource) {

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceListSelectionDialog.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ public class ResourceListSelectionDialog extends SelectionDialog {
9393

9494
private boolean allowUserToToggleDerived;
9595

96-
static class ResourceDescriptor implements Comparable {
96+
static class ResourceDescriptor implements Comparable<ResourceDescriptor> {
9797
String label;
9898

99-
ArrayList resources = new ArrayList();
99+
ArrayList<IResource> resources = new ArrayList<>();
100100

101101
boolean resourcesSorted = true;
102102

103103
@Override
104-
public int compareTo(Object o) {
105-
return collator.compare(label, ((ResourceDescriptor) o).label);
104+
public int compareTo(ResourceDescriptor o) {
105+
return collator.compare(label, o.label);
106106
}
107107
}
108108

@@ -632,7 +632,7 @@ private void gatherResources(boolean force) {
632632
* @return an image for a resource descriptor.
633633
*/
634634
private Image getImage(ResourceDescriptor desc) {
635-
IResource r = (IResource) desc.resources.get(0);
635+
IResource r = desc.resources.get(0);
636636
return labelProvider.getImage(r);
637637
}
638638

@@ -773,10 +773,10 @@ private void initDescriptors(final IResource resources[]) {
773773
return;
774774
}
775775
ResourceDescriptor current = descriptors[index];
776-
IResource currentResource = (IResource) current.resources.get(0);
776+
IResource currentResource = current.resources.get(0);
777777
for (int i2 = 1; i2 < descriptorsSize; i2++) {
778778
ResourceDescriptor next = descriptors[i2];
779-
IResource nextResource = (IResource) next.resources.get(0);
779+
IResource nextResource = next.resources.get(0);
780780
if (nextResource.getType() == currentResource.getType() && next.label.equals(current.label)) {
781781
current.resources.add(nextResource);
782782
// If we are merging resources with the same name, into a single descriptor,
@@ -791,7 +791,7 @@ private void initDescriptors(final IResource resources[]) {
791791
descriptors[index + 1] = descriptors[i2];
792792
index++;
793793
current = descriptors[index];
794-
currentResource = (IResource) current.resources.get(0);
794+
currentResource = current.resources.get(0);
795795
}
796796
}
797797
descriptorsSize = index + 1;
@@ -819,7 +819,7 @@ private boolean match(String label) {
819819
protected void okPressed() {
820820
TableItem items[] = folderNames.getSelection();
821821
if (items.length == 1) {
822-
ArrayList result = new ArrayList();
822+
ArrayList<Object> result = new ArrayList<>();
823823
result.add(items[0].getData());
824824
setResult(result);
825825
}
@@ -864,8 +864,8 @@ private void updateFolders(final ResourceDescriptor desc) {
864864
if (!desc.resourcesSorted) {
865865
// sort the folder names
866866
desc.resources.sort((o1, o2) -> {
867-
String s1 = getParentLabel((IResource) o1);
868-
String s2 = getParentLabel((IResource) o2);
867+
String s1 = getParentLabel(o1);
868+
String s2 = getParentLabel(o2);
869869
return collator.compare(s1, s2);
870870
});
871871
desc.resourcesSorted = true;

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
public abstract class WizardExportResourcesPage extends WizardDataTransferPage {
8080
private IStructuredSelection initialResourceSelection;
8181

82-
private List selectedTypes = new ArrayList();
82+
private List<Object> selectedTypes = new ArrayList<>();
8383

8484
// widgets
8585
private ResourceTreeAndListGroup resourceGroup;
@@ -272,7 +272,7 @@ protected final void createResourcesGroup(Composite parent) {
272272

273273
// create the input element, which has the root resource
274274
// as its only child
275-
List input = new ArrayList();
275+
List<IProject> input = new ArrayList<>();
276276
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
277277
for (IProject project : projects) {
278278
if (project.isOpen()) {
@@ -322,11 +322,11 @@ protected boolean ensureResourcesLocal(List resources) {
322322
* <code>IResource</code>)
323323
*/
324324
protected List extractNonLocalResources(List originalList) {
325-
ArrayList result = new ArrayList(originalList.size());
326-
Iterator resourcesEnum = originalList.iterator();
325+
ArrayList<IResource> result = new ArrayList<>(originalList.size());
326+
Iterator<IResource> resourcesEnum = originalList.iterator();
327327

328328
while (resourcesEnum.hasNext()) {
329-
IResource currentResource = (IResource) resourcesEnum.next();
329+
IResource currentResource = resourcesEnum.next();
330330
if (!currentResource.isLocal(IResource.DEPTH_ZERO)) {
331331
result.add(currentResource);
332332
}
@@ -424,8 +424,8 @@ protected void updateContentProviders(boolean showLinked) {
424424
* type: <code>IResource</code>)
425425
*/
426426
protected List getSelectedResources() {
427-
Iterator resourcesToExportIterator = this.getSelectedResourcesIterator();
428-
List resourcesToExport = new ArrayList();
427+
Iterator<?> resourcesToExportIterator = this.getSelectedResourcesIterator();
428+
List<Object> resourcesToExport = new ArrayList<>();
429429
while (resourcesToExportIterator.hasNext()) {
430430
resourcesToExport.add(resourcesToExportIterator.next());
431431
}
@@ -477,7 +477,7 @@ protected void handleTypesEditButtonPressed() {
477477
Object[] newSelectedTypes = queryResourceTypesToExport();
478478

479479
if (newSelectedTypes != null) { // ie.- did not press Cancel
480-
this.selectedTypes = new ArrayList(newSelectedTypes.length);
480+
this.selectedTypes = new ArrayList<>(newSelectedTypes.length);
481481
this.selectedTypes.addAll(Arrays.asList(newSelectedTypes));
482482
setupSelectionsBasedOnSelectedTypes();
483483
}
@@ -504,7 +504,7 @@ protected boolean hasExportableExtension(String resourceName) {
504504

505505
String extension = resourceName.substring(separatorIndex + 1);
506506

507-
Iterator it = selectedTypes.iterator();
507+
Iterator<Object> it = selectedTypes.iterator();
508508
while (it.hasNext()) {
509509
if (extension.equalsIgnoreCase((String) it.next())) {
510510
return true;
@@ -584,18 +584,18 @@ protected void setupBasedOnInitialSelections() {
584584
private void setupSelectionsBasedOnSelectedTypes() {
585585

586586
Runnable runnable = () -> {
587-
Map selectionMap = new Hashtable();
587+
Map<IContainer, List<IResource>> selectionMap = new Hashtable<>();
588588
// Only get the white selected ones
589-
Iterator resourceIterator = resourceGroup.getAllWhiteCheckedItems().iterator();
589+
Iterator<?> resourceIterator = resourceGroup.getAllWhiteCheckedItems().iterator();
590590
while (resourceIterator.hasNext()) {
591591
// handle the files here - white checked containers require recursion
592592
IResource resource = (IResource) resourceIterator.next();
593593
if (resource.getType() == IResource.FILE) {
594594
if (hasExportableExtension(resource.getName())) {
595-
List resourceList = new ArrayList();
595+
List<IResource> resourceList = new ArrayList<>();
596596
IContainer parent = resource.getParent();
597597
if (selectionMap.containsKey(parent)) {
598-
resourceList = (List) selectionMap.get(parent);
598+
resourceList = selectionMap.get(parent);
599599
}
600600
resourceList.add(resource);
601601
selectionMap.put(parent, resourceList);
@@ -616,9 +616,9 @@ private void setupSelectionsBasedOnSelectedTypes() {
616616
* selectionMap. If a resource is a file see if it matches one of the selected
617617
* extensions. If not then check the children.
618618
*/
619-
private void setupSelectionsBasedOnSelectedTypes(Map selectionMap, IContainer parent) {
619+
private void setupSelectionsBasedOnSelectedTypes(Map<IContainer, List<IResource>> selectionMap, IContainer parent) {
620620

621-
List selections = new ArrayList();
621+
List<IResource> selections = new ArrayList<>();
622622
IResource[] resources;
623623
boolean hasFiles = false;
624624

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardResourceImportPage.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.util.ArrayList;
2020
import java.util.Arrays;
21+
import java.util.List;
2122
import java.util.Map;
2223

2324
import org.eclipse.core.resources.IContainer;
@@ -83,7 +84,7 @@ public abstract class WizardResourceImportPage extends WizardDataTransferPage {
8384
// initial value stores
8485
private String initialContainerFieldValue;
8586

86-
protected java.util.List selectedTypes = new ArrayList();
87+
protected List<Object> selectedTypes = new ArrayList<>();
8788

8889
// widgets
8990
private Text containerNameField;
@@ -313,7 +314,7 @@ protected IPath getResourcePath() {
313314
* @return a list of resources currently selected for export (element type:
314315
* <code>IResource</code>)
315316
*/
316-
protected java.util.List getSelectedResources() {
317+
protected List getSelectedResources() {
317318
return this.selectionGroup.getAllCheckedListItems();
318319
}
319320

@@ -365,7 +366,7 @@ protected IContainer getSpecifiedContainer() {
365366
* Returns a collection of the currently-specified resource types for use by the
366367
* type selection dialog.
367368
*/
368-
protected java.util.List getTypesToImport() {
369+
protected List getTypesToImport() {
369370

370371
return selectedTypes;
371372
}
@@ -417,7 +418,7 @@ protected void handleTypesEditButtonPressed() {
417418

418419
Object[] newSelectedTypes = dialog.getResult();
419420
if (newSelectedTypes != null) { // ie.- did not press Cancel
420-
this.selectedTypes = new ArrayList(newSelectedTypes.length);
421+
this.selectedTypes = new ArrayList<>(newSelectedTypes.length);
421422
this.selectedTypes.addAll(Arrays.asList(newSelectedTypes));
422423

423424
setupSelectionsBasedOnSelectedTypes();

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected void processDelta(IResourceDelta delta) {
117117
}
118118

119119

120-
final Collection runnables = new ArrayList();
120+
final Collection<Runnable> runnables = new ArrayList<>();
121121
processDelta(delta, runnables);
122122

123123
if (runnables.isEmpty()) {
@@ -144,18 +144,18 @@ protected void processDelta(IResourceDelta delta) {
144144
/**
145145
* Run all of the runnables that are the widget updates
146146
*/
147-
private void runUpdates(Collection runnables) {
148-
Iterator runnableIterator = runnables.iterator();
147+
private void runUpdates(Collection<Runnable> runnables) {
148+
Iterator<Runnable> runnableIterator = runnables.iterator();
149149
while(runnableIterator.hasNext()){
150-
((Runnable)runnableIterator.next()).run();
150+
runnableIterator.next().run();
151151
}
152152

153153
}
154154

155155
/**
156156
* Process a resource delta. Add any runnables
157157
*/
158-
private void processDelta(IResourceDelta delta, Collection runnables) {
158+
private void processDelta(IResourceDelta delta, Collection<Runnable> runnables) {
159159
//he widget may have been destroyed
160160
// by the time this is run. Check for this and do nothing if so.
161161
Control ctrl = viewer.getControl();

0 commit comments

Comments
 (0)