Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unnecessary casts #1438

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) {
}
}
if (resource != null) {
IPath location = ((IFile) resource).getLocation();
IPath location = resource.getLocation();
if (location != null) {
List<ILaunchConfiguration> list = collectConfigurations(location);
return list.toArray(new ILaunchConfiguration[list.size()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ protected void controlChanged(Widget widget) {

private void updateControlsForProblemReporting(boolean reportProblems) {
for (int i = fComboBoxes.size() - 1; i >= 0; i--) {
((Control) fComboBoxes.get(i)).setEnabled(reportProblems);
((Control) fProblemLabels.get(i)).setEnabled(reportProblems);
fComboBoxes.get(i).setEnabled(reportProblems);
fProblemLabels.get(i).setEnabled(reportProblems);
}
fSeverityLabel.setEnabled(reportProblems);
fBuildFilesToIgnoreProblems.setEnabled(reportProblems);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ public void update() {
AntElementNode selection = getSelectedElement();
boolean enabled = false;
if (selection instanceof AntTargetNode) {
if (!((AntTargetNode) selection).isErrorNode()) {
if (!selection.isErrorNode()) {
setToolTipText(AntViewActionMessages.RunTargetAction_4);
enabled = true;
}
} else if (selection instanceof AntProjectNode) {
if (!((AntProjectNode) selection).isErrorNode()) {
if (!selection.isErrorNode()) {
enabled = true;
setToolTipText(AntViewActionMessages.RunTargetAction_3);
}
} else if (selection instanceof AntTaskNode) {
if (!((AntTaskNode) selection).isErrorNode()) {
if (!selection.isErrorNode()) {
enabled = true;
setToolTipText(AntViewActionMessages.RunTargetAction_0);
}
Expand Down
2 changes: 1 addition & 1 deletion ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ant.ui; singleton:=true
Bundle-Version: 3.9.400.qualifier
Bundle-Version: 3.9.500.qualifier
Bundle-Activator: org.eclipse.ant.internal.ui.AntUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion debug/org.eclipse.debug.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.tests;singleton:=true
Bundle-Version: 3.14.200.qualifier
Bundle-Version: 3.14.300.qualifier
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void testLabelUpdatesCompletedOutOfSequence1() throws Exception {

// Complete the second set of children updates
for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
((ILabelUpdate)model.fCapturedUpdates.get(i)).done();
model.fCapturedUpdates.get(i).done();
}

// Then complete the first set.
Expand Down Expand Up @@ -229,7 +229,7 @@ public void testLabelUpdatesCompletedOutOfSequence2() throws Exception {

// Complete the second set of children updates
for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
((ILabelUpdate)model.fCapturedUpdates.get(i)).done();
model.fCapturedUpdates.get(i).done();
}

// Then complete the first set.
Expand Down Expand Up @@ -281,7 +281,7 @@ public void _x_testChildrenUpdatesCompletedOutOfSequence() throws Exception {

// Complete the second set of children updates
for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
((IChildrenUpdate)model.fCapturedUpdates.get(i)).done();
model.fCapturedUpdates.get(i).done();
}

// Then complete the first set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;

Expand All @@ -38,7 +37,7 @@ public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector
FolderSourceContainerDialog dialog = new FolderSourceContainerDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());

if (dialog.open() == Window.OK) {
Object[] selection= ((ElementTreeSelectionDialog)dialog).getResult();
Object[] selection= dialog.getResult();
ArrayList<ISourceContainer> containers = new ArrayList<>();
for (Object f : selection) {
if (f instanceof IFolder) {
Expand All @@ -63,7 +62,7 @@ public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirecto
dialog.setInitialSelection(container.getContainer());
if (dialog.open() == Window.OK) {
container.dispose();
Object[] selection= ((ElementTreeSelectionDialog)dialog).getResult();
Object[] selection= dialog.getResult();
ArrayList<ISourceContainer> list = new ArrayList<>();
for (Object f : selection) {
if (f instanceof IFolder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private void deleteResource(IResource resource) throws CoreException {
}
folder.delete(true, null);
} else if (type == IResource.FILE) {
((IFile) resource).delete(true, null);
resource.delete(true, null);
} else {
throw new ResourceException(IResourceStatus.RESOURCE_WRONG_TYPE, null, "Wrong resource type", null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -111,11 +110,11 @@ public void testCopyResource() throws Throwable {
() -> folder.copy(destinationFolder.getFullPath(), false, null));
assertThat(exception.getStatus().getChildren()).hasSize(2);
assertTrue(destinationFolder.exists());
assertTrue(((IContainer) destinationFolder).getFile(IPath.fromOSString(file.getName())).exists());
assertFalse(((IContainer) destinationFolder).getFolder(IPath.fromOSString(subfolder.getName())).exists());
assertFalse(((IContainer) destinationFolder).getFile(IPath.fromOSString(anotherFile.getName())).exists());
assertTrue(destinationFolder.getFile(IPath.fromOSString(file.getName())).exists());
assertFalse(destinationFolder.getFolder(IPath.fromOSString(subfolder.getName())).exists());
assertFalse(destinationFolder.getFile(IPath.fromOSString(anotherFile.getName())).exists());
/* assert properties were properly copied */
IResource target = ((IContainer) destinationFolder).getFile(IPath.fromOSString(file.getName()));
IResource target = destinationFolder.getFile(IPath.fromOSString(file.getName()));
for (int i = 0; i < NUMBER_OF_PROPERTIES; i++) {
String persistentValue = target.getPersistentProperty(propNames[i]);
Object sessionValue = target.getSessionProperty(propNames[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.eclipse.core.internal.resources.Resource;
import org.eclipse.core.internal.resources.ResourceInfo;
import org.eclipse.core.internal.resources.Workspace;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -464,7 +463,7 @@ public void testMoveResource() throws Exception {
assertTrue(folder.exists());
// FIXME: should #move be a best effort operation?
// its ok for the root to be moved but ensure the destination child wasn't moved
IResource destChild = ((IContainer) folderDestination).getFile(IPath.fromOSString(anotherFile.getName()));
IResource destChild = folderDestination.getFile(IPath.fromOSString(anotherFile.getName()));
assertFalse(folderDestination.exists());
assertFalse(destChild.exists());
// cleanup and delete the destination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public void testProjectCopyVariations() throws CoreException {
sourceChild = resources[1];
sourceChild.setPersistentProperty(qname, value);
monitor.prepare();
((IProject) source).copy(description, false, monitor);
source.copy(description, false, monitor);
monitor.assertUsedUp();
assertExistsInWorkspace(project);
assertExistsInWorkspace(resources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse Core Tests Runtime
Bundle-SymbolicName: org.eclipse.core.tests.runtime; singleton:=true
Bundle-Version: 3.21.400.qualifier
Bundle-Version: 3.21.500.qualifier
Bundle-Activator: org.eclipse.core.tests.runtime.RuntimeTestsPlugin
Bundle-Vendor: Eclipse.org
Export-Package: org.eclipse.core.tests.internal.preferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ private void wait(ArrayList<RandomTestRunnable> allRunnables, LockManager lockMa
// join all threads:
for (int i = 0; i < allRunnables.size(); i++) {
try {
((Thread) allRunnables.get(i)).join(100000);
allRunnables.get(i).join(100000);
} catch (InterruptedException e1) {
//ignore
}
assertTrue("1." + i, !((Thread) allRunnables.get(i)).isAlive());
assertTrue("1." + i, !allRunnables.get(i).isAlive());
}
//the underlying array has to be empty
assertTrue("Locks not removed from graph.", lockManager.isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5155,7 +5155,7 @@ private void scrollVertical(int avpos, int lvpos, int rvpos, MergeSourceViewer a

Control center= getCenterControl();
if (center instanceof Canvas)
((Canvas) center).redraw();
center.redraw();

if (fRightCanvas != null)
fRightCanvas.redraw();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ public void configure(SourceViewerConfiguration configuration) {
*/
public void setBounds (int x, int y, int width, int height) {
if(getSourceViewer().getControl() instanceof Composite){
((Composite)getSourceViewer().getControl()).setBounds(x, y, width, height);
getSourceViewer().getControl().setBounds(x, y, width, height);
} else {
getSourceViewer().getTextWidget().setBounds(x, y, width, height);
}
Expand Down
2 changes: 1 addition & 1 deletion team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.team.core; singleton:=true
Bundle-Version: 3.10.400.qualifier
Bundle-Version: 3.10.500.qualifier
Bundle-Activator: org.eclipse.team.internal.core.TeamPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public IStatus merge(IDiff diff, boolean ignoreLocalChanges, IProgressMonitor mo
&& twd.getDirection() == IThreeWayDiff.OUTGOING
&& ((IFolder)resource).members().length == 0) {
// Delete the local folder addition
((IFolder)resource).delete(false, monitor);
resource.delete(false, monitor);
} else if (resource.getType() == IResource.FOLDER
&& !resource.exists()
&& twd.getKind() == IDiff.ADD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected AbstractSynchronizeModelProvider(AbstractSynchronizeModelProvider pare
}

private Tree getTree() {
return ((Tree)((AbstractTreeViewer)getViewer()).getControl());
return ((Tree)getViewer().getControl());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void fireChanges() {
public ImageDescriptor getImageDescriptor(Object object) {
IResource resource = getResource();
if(resource != null) {
IWorkbenchAdapter adapter = ((IAdaptable) resource).getAdapter(IWorkbenchAdapter.class);
IWorkbenchAdapter adapter = resource.getAdapter(IWorkbenchAdapter.class);
return adapter.getImageDescriptor(resource);
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion ua/org.eclipse.help.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %help_system_plugin_name
Bundle-SymbolicName: org.eclipse.help.ui; singleton:=true
Bundle-Version: 4.7.0.qualifier
Bundle-Version: 4.7.100.qualifier
Bundle-Activator: org.eclipse.help.ui.internal.HelpUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public void addModifyListener(ModifyListener listener) {

public void addKeyListener(KeyListener listener) {
if (combo instanceof Combo)
((Combo) combo).addKeyListener(listener);
combo.addKeyListener(listener);
else
((CCombo) combo).addKeyListener(listener);
combo.addKeyListener(listener);
}

public void createControl(Composite parent, FormToolkit toolkit, int style) {
Expand Down
2 changes: 1 addition & 1 deletion ua/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %PLUGIN_NAME
Bundle-SymbolicName: org.eclipse.ui.cheatsheets; singleton:=true
Bundle-Version: 3.8.400.qualifier
Bundle-Version: 3.8.500.qualifier
Bundle-Activator: org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin
Bundle-Vendor: %PROVIDER_NAME
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion ua/org.eclipse.ui.cheatsheets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.ui</groupId>
<artifactId>org.eclipse.ui.cheatsheets</artifactId>
<version>3.8.400-SNAPSHOT</version>
<version>3.8.500-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ private void hookDialogListener() {
if (!inDialog && isInDialogItem() && (Platform.getBundle("org.eclipse.help.ui") != null)) { //$NON-NLS-1$
listener = event -> {
if (isTrayDialog(event.widget)) {
dialogOpened((TrayDialog) ((Shell) event.widget).getData());
dialogOpened((TrayDialog) event.widget.getData());
}
};
Display.getCurrent().addFilter(SWT.Show, listener);
Expand Down Expand Up @@ -986,7 +986,7 @@ public boolean isInDialogMode() {
* @return whether or not the widget is a TrayDialog
*/
private boolean isTrayDialog(Widget widget) {
return (widget instanceof Shell && ((Shell)widget).getData() instanceof TrayDialog);
return (widget instanceof Shell && widget.getData() instanceof TrayDialog);
}

/**
Expand Down
Loading