Skip to content

Commit

Permalink
Fix raw type warnings in org.eclipse.ui.ide
Browse files Browse the repository at this point in the history
Fixes those raw type warnings in org.eclipse.ui.ide that do not affect
public API.
  • Loading branch information
HeikoKlare committed Jan 22, 2024
1 parent 55034d1 commit 35b9674
Show file tree
Hide file tree
Showing 31 changed files with 185 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,11 @@ protected boolean updateSelection(IStructuredSelection selection) {

// to enable this command there must be one project selected and nothing
// else
List selectedResources = getSelectedResources();
List<? extends IResource> selectedResources = getSelectedResources();
if (selectedResources.size() != 1) {
return false;
}
IResource source = (IResource) selectedResources.get(0);
IResource source = selectedResources.get(0);
if (source instanceof IProject && ((IProject) source).isOpen()) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class MoveResourceAction extends CopyResourceAction {
* Keep a list of destinations so that any required update can be done after the
* move.
*/
protected List destinations;
protected List<IPath> destinations;

/**
* Creates a new action.
Expand Down Expand Up @@ -97,7 +98,7 @@ protected List getDestinations() {
}

@Override
protected IResource[] getResources(List resourceList) {
protected IResource[] getResources(List<? extends IResource> resourceList) {
ReadOnlyStateChecker checker = new ReadOnlyStateChecker(getShell(),
IDEWorkbenchMessages.MoveResourceAction_title,
IDEWorkbenchMessages.MoveResourceAction_checkMoveMessage);
Expand All @@ -107,7 +108,7 @@ protected IResource[] getResources(List resourceList) {
@Override
protected void runOperation(IResource[] resources, IContainer destination) {
//Initialize the destinations
destinations = new ArrayList();
destinations = new ArrayList<>();
IResource[] copiedResources = operation.copyResources(resources,
destination);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private boolean promptToOpenWithReferences() {
@Override
public void resourceChanged(IResourceChangeEvent event) {
// Warning: code duplicated in CloseResourceAction
List sel = getSelectedResources();
List<? extends IResource> sel = getSelectedResources();
// don't bother looking at delta if selection not applicable
if (selectionIsOfType(IResource.PROJECT)) {
IResourceDelta delta = event.getDelta();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public ReadOnlyStateChecker(Shell parent, String title, String message) {
* Return true if all items are selected and false if any are skipped.
*/
private boolean checkAcceptedResource(IResource resourceToCheck,
List selectedChildren) throws CoreException {
List<IResource> selectedChildren) throws CoreException {

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

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

boolean noneSkipped = true;
List selectedChildren = new ArrayList();
List<IResource> selectedChildren = new ArrayList<>();

for (IResource resourceToCheck : itemsToCheck) {
ResourceAttributes checkAttributes = resourceToCheck.getResourceAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public Object[] getResult() {
if (result == null)
return null;

List resultToReturn = new ArrayList();
List<Object> resultToReturn = new ArrayList<>();

for (Object element : result) {
if (element instanceof IResource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ public class ResourceListSelectionDialog extends SelectionDialog {

private boolean allowUserToToggleDerived;

static class ResourceDescriptor implements Comparable {
static class ResourceDescriptor implements Comparable<ResourceDescriptor> {
String label;

ArrayList resources = new ArrayList();
ArrayList<IResource> resources = new ArrayList<>();

boolean resourcesSorted = true;

@Override
public int compareTo(Object o) {
return collator.compare(label, ((ResourceDescriptor) o).label);
public int compareTo(ResourceDescriptor o) {
return collator.compare(label, o.label);
}
}

Expand Down Expand Up @@ -632,7 +632,7 @@ private void gatherResources(boolean force) {
* @return an image for a resource descriptor.
*/
private Image getImage(ResourceDescriptor desc) {
IResource r = (IResource) desc.resources.get(0);
IResource r = desc.resources.get(0);
return labelProvider.getImage(r);
}

Expand Down Expand Up @@ -773,10 +773,10 @@ private void initDescriptors(final IResource resources[]) {
return;
}
ResourceDescriptor current = descriptors[index];
IResource currentResource = (IResource) current.resources.get(0);
IResource currentResource = current.resources.get(0);
for (int i2 = 1; i2 < descriptorsSize; i2++) {
ResourceDescriptor next = descriptors[i2];
IResource nextResource = (IResource) next.resources.get(0);
IResource nextResource = next.resources.get(0);
if (nextResource.getType() == currentResource.getType() && next.label.equals(current.label)) {
current.resources.add(nextResource);
// If we are merging resources with the same name, into a single descriptor,
Expand All @@ -791,7 +791,7 @@ private void initDescriptors(final IResource resources[]) {
descriptors[index + 1] = descriptors[i2];
index++;
current = descriptors[index];
currentResource = (IResource) current.resources.get(0);
currentResource = current.resources.get(0);
}
}
descriptorsSize = index + 1;
Expand Down Expand Up @@ -819,7 +819,7 @@ private boolean match(String label) {
protected void okPressed() {
TableItem items[] = folderNames.getSelection();
if (items.length == 1) {
ArrayList result = new ArrayList();
ArrayList<Object> result = new ArrayList<>();
result.add(items[0].getData());
setResult(result);
}
Expand Down Expand Up @@ -864,8 +864,8 @@ private void updateFolders(final ResourceDescriptor desc) {
if (!desc.resourcesSorted) {
// sort the folder names
desc.resources.sort((o1, o2) -> {
String s1 = getParentLabel((IResource) o1);
String s2 = getParentLabel((IResource) o2);
String s1 = getParentLabel(o1);
String s2 = getParentLabel(o2);
return collator.compare(s1, s2);
});
desc.resourcesSorted = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
public abstract class WizardExportResourcesPage extends WizardDataTransferPage {
private IStructuredSelection initialResourceSelection;

private List selectedTypes = new ArrayList();
private List<Object> selectedTypes = new ArrayList<>();

// widgets
private ResourceTreeAndListGroup resourceGroup;
Expand Down Expand Up @@ -272,7 +272,7 @@ protected final void createResourcesGroup(Composite parent) {

// create the input element, which has the root resource
// as its only child
List input = new ArrayList();
List<IProject> input = new ArrayList<>();
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
if (project.isOpen()) {
Expand Down Expand Up @@ -322,11 +322,11 @@ protected boolean ensureResourcesLocal(List resources) {
* <code>IResource</code>)
*/
protected List extractNonLocalResources(List originalList) {
ArrayList result = new ArrayList(originalList.size());
Iterator resourcesEnum = originalList.iterator();
ArrayList<IResource> result = new ArrayList<>(originalList.size());
Iterator<IResource> resourcesEnum = originalList.iterator();

while (resourcesEnum.hasNext()) {
IResource currentResource = (IResource) resourcesEnum.next();
IResource currentResource = resourcesEnum.next();
if (!currentResource.isLocal(IResource.DEPTH_ZERO)) {
result.add(currentResource);
}
Expand Down Expand Up @@ -424,8 +424,8 @@ protected void updateContentProviders(boolean showLinked) {
* type: <code>IResource</code>)
*/
protected List getSelectedResources() {
Iterator resourcesToExportIterator = this.getSelectedResourcesIterator();
List resourcesToExport = new ArrayList();
Iterator<?> resourcesToExportIterator = this.getSelectedResourcesIterator();
List<Object> resourcesToExport = new ArrayList<>();
while (resourcesToExportIterator.hasNext()) {
resourcesToExport.add(resourcesToExportIterator.next());
}
Expand Down Expand Up @@ -477,7 +477,7 @@ protected void handleTypesEditButtonPressed() {
Object[] newSelectedTypes = queryResourceTypesToExport();

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

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

Iterator it = selectedTypes.iterator();
Iterator<Object> it = selectedTypes.iterator();
while (it.hasNext()) {
if (extension.equalsIgnoreCase((String) it.next())) {
return true;
Expand Down Expand Up @@ -584,18 +584,18 @@ protected void setupBasedOnInitialSelections() {
private void setupSelectionsBasedOnSelectedTypes() {

Runnable runnable = () -> {
Map selectionMap = new Hashtable();
Map<IContainer, List<IResource>> selectionMap = new Hashtable<>();
// Only get the white selected ones
Iterator resourceIterator = resourceGroup.getAllWhiteCheckedItems().iterator();
Iterator<?> resourceIterator = resourceGroup.getAllWhiteCheckedItems().iterator();
while (resourceIterator.hasNext()) {
// handle the files here - white checked containers require recursion
IResource resource = (IResource) resourceIterator.next();
if (resource.getType() == IResource.FILE) {
if (hasExportableExtension(resource.getName())) {
List resourceList = new ArrayList();
List<IResource> resourceList = new ArrayList<>();
IContainer parent = resource.getParent();
if (selectionMap.containsKey(parent)) {
resourceList = (List) selectionMap.get(parent);
resourceList = selectionMap.get(parent);
}
resourceList.add(resource);
selectionMap.put(parent, resourceList);
Expand All @@ -616,9 +616,9 @@ private void setupSelectionsBasedOnSelectedTypes() {
* selectionMap. If a resource is a file see if it matches one of the selected
* extensions. If not then check the children.
*/
private void setupSelectionsBasedOnSelectedTypes(Map selectionMap, IContainer parent) {
private void setupSelectionsBasedOnSelectedTypes(Map<IContainer, List<IResource>> selectionMap, IContainer parent) {

List selections = new ArrayList();
List<IResource> selections = new ArrayList<>();
IResource[] resources;
boolean hasFiles = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

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

protected java.util.List selectedTypes = new ArrayList();
protected List<Object> selectedTypes = new ArrayList<>();

// widgets
private Text containerNameField;
Expand Down Expand Up @@ -313,7 +314,7 @@ protected IPath getResourcePath() {
* @return a list of resources currently selected for export (element type:
* <code>IResource</code>)
*/
protected java.util.List getSelectedResources() {
protected List getSelectedResources() {
return this.selectionGroup.getAllCheckedListItems();
}

Expand Down Expand Up @@ -365,7 +366,7 @@ protected IContainer getSpecifiedContainer() {
* Returns a collection of the currently-specified resource types for use by the
* type selection dialog.
*/
protected java.util.List getTypesToImport() {
protected List getTypesToImport() {

return selectedTypes;
}
Expand Down Expand Up @@ -417,7 +418,7 @@ protected void handleTypesEditButtonPressed() {

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

setupSelectionsBasedOnSelectedTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected void processDelta(IResourceDelta delta) {
}


final Collection runnables = new ArrayList();
final Collection<Runnable> runnables = new ArrayList<>();
processDelta(delta, runnables);

if (runnables.isEmpty()) {
Expand All @@ -144,18 +144,18 @@ protected void processDelta(IResourceDelta delta) {
/**
* Run all of the runnables that are the widget updates
*/
private void runUpdates(Collection runnables) {
Iterator runnableIterator = runnables.iterator();
private void runUpdates(Collection<Runnable> runnables) {
Iterator<Runnable> runnableIterator = runnables.iterator();
while(runnableIterator.hasNext()){
((Runnable)runnableIterator.next()).run();
runnableIterator.next().run();
}

}

/**
* Process a resource delta. Add any runnables
*/
private void processDelta(IResourceDelta delta, Collection runnables) {
private void processDelta(IResourceDelta delta, Collection<Runnable> runnables) {
//he widget may have been destroyed
// by the time this is run. Check for this and do nothing if so.
Control ctrl = viewer.getControl();
Expand Down
Loading

0 comments on commit 35b9674

Please sign in to comment.