Skip to content

Commit

Permalink
remove unnecessary casts (eclipse-platform#1988)
Browse files Browse the repository at this point in the history
* remove unnecessary casts
  • Loading branch information
stephan-herrmann authored Jun 20, 2024
1 parent 1acae4f commit 160dfa8
Show file tree
Hide file tree
Showing 34 changed files with 53 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.e4.ui.workbench.addons.swt;singleton:=true
Bundle-Version: 1.5.400.qualifier
Bundle-Version: 1.5.500.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public static MWindow getWindowFor(MUIElement element) {
// null since it's not in the 'children' hierarchy
while (parent != null && !(parent instanceof MWindow)) {
if (parent.getTags().contains(MIN_MAXIMIZEABLE_CHILDREN_AREA_TAG) && parent instanceof MArea) {
parent = ((MArea) parent).getCurSharedRef();
parent = parent.getCurSharedRef();
} else {
parent = parent.getParent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected void layout(Composite composite, boolean flushCache) {

Rectangle bounds = composite.getBounds();
if (composite instanceof Shell)
bounds = ((Shell) composite).getClientArea();
bounds = composite.getClientArea();
else {
bounds.x = 0;
bounds.y = 0;
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.e4.ui.workbench/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.e4.ui.workbench;singleton:=true
Bundle-Version: 1.15.400.qualifier
Bundle-Version: 1.15.500.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.e4.core.services.translation.TranslationService;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MLocalizable;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
Expand Down Expand Up @@ -142,7 +141,7 @@ protected void updateLocalization(List<? extends MUIElement> children) {
}
}

((MLocalizable) element).updateLocalization();
element.updateLocalization();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ private boolean createColumnObjects() {

private Image getColumnImage(Item item) {
if (item instanceof TableColumn) {
return ((TableColumn) item).getImage();
return item.getImage();
} else if (item instanceof TreeColumn) {
return ((TreeColumn) item).getImage();
return item.getImage();
}
return null;
}
Expand Down Expand Up @@ -301,12 +301,12 @@ private void createLabel(final Composite composite, String string) {
private String getColumnName(Item item) {
String result = ""; //$NON-NLS-1$
if (item instanceof TableColumn) {
result = ((TableColumn) item).getText();
result = item.getText();
if (result.trim().isEmpty()) {
result = ((TableColumn) item).getToolTipText();
}
} else if (item instanceof TreeColumn) {
result = ((TreeColumn) item).getText();
result = item.getText();
if (result.trim().isEmpty()) {
result = ((TreeColumn) item).getToolTipText();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.ltk.core.refactoring
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ltk.core.refactoring; singleton:=true
Bundle-Version: 3.14.400.qualifier
Bundle-Version: 3.14.500.qualifier
Bundle-Activator: org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ private static void disableParticipant(final RefactoringParticipant participant,

private void addToTextChangeMap(Change change) {
if (change instanceof TextChange) {
Object element= ((TextChange) change).getModifiedElement();
Object element= change.getModifiedElement();
if (element != null) {
fTextChangeMap.put(element, (TextChange) change);
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.search/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.search; singleton:=true
Bundle-Version: 3.16.200.qualifier
Bundle-Version: 3.16.300.qualifier
Bundle-Activator: org.eclipse.search.internal.ui.SearchPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;

import org.eclipse.jface.dialogs.IDialogSettings;
Expand Down Expand Up @@ -336,7 +335,7 @@ public int computeScore(Object element) {

IResource resource= ((IAdaptable)element).getAdapter(IResource.class);
if (resource != null && resource.getType() == IResource.FILE) {
String extension= ((IFile)resource).getFileExtension();
String extension= resource.getFileExtension();
if (extension != null)
score= Math.max(score, getScoreForFileExtension(extension));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ private boolean ensureQuickDiffProvider(String diffProviderId) {
modelExtension.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, newDiffer);

if (fDelegate instanceof IChangeRulerColumn)
((IChangeRulerColumn) fDelegate).setModel(annotationModel); // picks up the new model attachment
fDelegate.setModel(annotationModel); // picks up the new model attachment

return true;
}
Expand All @@ -543,7 +543,7 @@ private boolean ensureQuickDiffProvider(String diffProviderId) {
private void installChangeRulerModel(IVerticalRulerColumn column) {
if (column instanceof IChangeRulerColumn) {
IAnnotationModel model= getAnnotationModelWithDiffer();
((IChangeRulerColumn) column).setModel(model);
column.setModel(model);
if (model != null) {
ISourceViewer viewer= fViewer;
if (viewer != null && viewer.getAnnotationModel() == null && column.getControl() != null)
Expand All @@ -559,7 +559,7 @@ private void installChangeRulerModel(IVerticalRulerColumn column) {
*/
private void uninstallChangeRulerModel(IVerticalRulerColumn column) {
if (column instanceof IChangeRulerColumn)
((IChangeRulerColumn) column).setModel(null);
column.setModel(null);
IAnnotationModel model= getDiffer();
if (model instanceof ILineDifferExtension)
((ILineDifferExtension) model).suspend();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ protected IResource getResource() {
ITextEditor editor= getTextEditor();
if (editor != null) {
IEditorInput input= editor.getEditorInput();
return ((IAdaptable) input).getAdapter(IResource.class);
return input.getAdapter(IResource.class);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private boolean promptForConfirmation() {
IResource firstSelected = selection.get(0);
String projectName = null;
if (firstSelected instanceof IProject) {
projectName = ((IProject) firstSelected).getName();
projectName = firstSelected.getName();
}
message = NLS.bind(IDEWorkbenchMessages.CloseUnrelatedProjectsAction_confirmMsg1, projectName);
} else // if more then one project is selected then print there number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ protected boolean updateSelection(IStructuredSelection selection) {
if (selectedResources.isEmpty()) {
return false;
}
IContainer firstParent = ((IResource) selectedResources.get(0))
IContainer firstParent = selectedResources.get(0)
.getParent();
if (firstParent == null) {
return false;
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: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.navigator.resources; singleton:=true
Bundle-Version: 3.9.300.qualifier
Bundle-Version: 3.9.400.qualifier
Bundle-Activator: org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private IContainer getContainer(IResource[] clipboardContent) {
}

if (selection.get(0) instanceof IFile) {
return ((IFile) selection.get(0)).getParent();
return selection.get(0).getParent();
}
return (IContainer) selection.get(0);
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.navigator/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.navigator; singleton:=true
Bundle-Version: 3.12.400.qualifier
Bundle-Version: 3.12.500.qualifier
Bundle-Activator: org.eclipse.ui.internal.navigator.NavigatorPlugin
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ private boolean callNormalHasChildren(Object anElementOrPath, Object anElement,
ITreePathContentProvider tpcp = cp;
return tpcp.hasChildren((TreePath) anElementOrPath);
}
return ((ITreeContentProvider) cp).hasChildren(anElement);
return cp.hasChildren(anElement);
}

private boolean pipelineHasChildren(Object anElementOrPath, Object anElement,
Expand Down Expand Up @@ -632,8 +632,8 @@ public void run() throws Exception {

if (!isOverridingDescriptorInSet(foundExtension.getDescriptor(), descriptors)) {
if (foundExtension.internalGetContentProvider().isTreePath()) {
TreePath[] parentTreePaths = ((ITreePathContentProvider) foundExtension
.internalGetContentProvider()).getParents(anElement);
TreePath[] parentTreePaths = foundExtension
.internalGetContentProvider().getParents(anElement);

for (TreePath parentTreePath : parentTreePaths) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension;
import org.eclipse.ui.navigator.INavigatorContentDescriptor;
import org.eclipse.ui.navigator.INavigatorPipelineService;
import org.eclipse.ui.navigator.IPipelinedTreeContentProvider;
import org.eclipse.ui.navigator.PipelinedShapeModification;
import org.eclipse.ui.navigator.PipelinedViewerUpdate;

Expand Down Expand Up @@ -79,8 +78,8 @@ private void pipelineInterceptAdd(final PipelinedShapeModification anAddModifica
SafeRunner.run(new NavigatorSafeRunnable() {
@Override
public void run() throws Exception {
((IPipelinedTreeContentProvider) extension
.internalGetContentProvider())
extension
.internalGetContentProvider()
.interceptAdd(anAddModification);
}

Expand Down Expand Up @@ -139,8 +138,8 @@ private void pipelineInterceptRemove(final PipelinedShapeModification aRemoveMod
SafeRunner.run(new NavigatorSafeRunnable() {
@Override
public void run() throws Exception {
((IPipelinedTreeContentProvider) overridingExtension
.internalGetContentProvider()).interceptRemove(aRemoveModification);
overridingExtension
.internalGetContentProvider().interceptRemove(aRemoveModification);
}

@Override
Expand Down Expand Up @@ -189,8 +188,8 @@ private boolean pipelineInterceptRefresh(final NavigatorContentExtension overrid
SafeRunner.run(new NavigatorSafeRunnable() {
@Override
public void run() throws Exception {
intercepted[0] |= ((IPipelinedTreeContentProvider) nceLocal
.internalGetContentProvider())
intercepted[0] |= nceLocal
.internalGetContentProvider()
.interceptRefresh(aRefreshSynchronization);

if (nceLocal.getDescriptor().hasOverridingExtensions())
Expand Down Expand Up @@ -242,8 +241,8 @@ private boolean pipelineInterceptUpdate(final NavigatorContentExtension override
SafeRunner.run(new NavigatorSafeRunnable() {
@Override
public void run() throws Exception {
intercepted[0] |= ((IPipelinedTreeContentProvider) nceLocal
.internalGetContentProvider())
intercepted[0] |= nceLocal
.internalGetContentProvider()
.interceptUpdate(anUpdateSynchronization);

if (nceLocal.getDescriptor().hasOverridingExtensions())
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.views/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.ui.views; singleton:=true
Bundle-Version: 3.12.300.qualifier
Bundle-Version: 3.12.400.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.ui.internal.views.contentoutline;x-internal:=true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ private void refreshChildEntries() {

// Dispose of entries which are no longer needed
for (PropertySheetEntry element : entriesToDispose) {
((IPropertySheetEntry) element).dispose();
element.dispose();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ private void storeButtonWithMnemonicInMap(Button button) {
private void setGridData(Control component, int horizontalAlignment, boolean grabExcessHorizontalSpace,
int verticalAlignment, boolean grabExcessVerticalSpace) {
GridData gd;
if (component instanceof Button && (((Button) component).getStyle() & SWT.PUSH) != 0) {
if (component instanceof Button && (component.getStyle() & SWT.PUSH) != 0) {
SWTUtil.setButtonDimensionHint((Button) component);
gd = (GridData) component.getLayoutData();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ public void dragOver(DropTargetEvent event) {
public void drop(DropTargetEvent event) {
if (event.item == null)
return;
Object object= ((TreeItem) event.item).getData();
Object object= event.item.getData();
final String contextId;
if (object instanceof TemplateContextType)
contextId= ((TemplateContextType) object).getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ private void revokeActionSetFromCoolbar(ICoolBarManager coolbarMgr, String actio
if (item instanceof IToolBarManager) {
revokeActionSetFromToolbar((IToolBarManager) item, actionsetId);
} else if (item instanceof IToolBarContributionItem) {
id = ((IToolBarContributionItem) item).getId();
id = item.getId();
if (actionsetId.equals(id)) {
itemsToRemove.add(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,13 +1030,13 @@ public MPart findPart(IWorkbenchPart part) {

for (ViewReference reference : viewReferences) {
if (part == reference.getPart(false)) {
return ((WorkbenchPartReference) reference).getModel();
return reference.getModel();
}
}

for (EditorReference reference : editorReferences) {
if (part == reference.getPart(false)) {
return ((WorkbenchPartReference) reference).getModel();
return reference.getModel();
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public Object getElementType() {
protected List<E> doGetList(S source) {
ISelection selection;
if (partId != null) {
selection = ((ISelectionService) source).getSelection(partId);
selection = source.getSelection(partId);
} else {
selection = ((ISelectionService) source).getSelection();
selection = source.getSelection();
}
if (selection instanceof IStructuredSelection) {
List<E> list = ((IStructuredSelection) selection).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public INativePropertyListener<S> adaptListener(ISimplePropertyListener<S, Value
protected T doGetValue(S source) {
ISelection selection;
if (partId != null) {
selection = ((ISelectionService) source).getSelection(partId);
selection = source.getSelection(partId);
} else {
selection = ((ISelectionService) source).getSelection();
selection = source.getSelection();
}
if (selection instanceof IStructuredSelection) {
T elem = (T) ((IStructuredSelection) selection).getFirstElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ protected void addButtonsToHelpControl(Control control) {
exportButton.setToolTipText(WorkbenchMessages.Preference_export);
exportButton.addListener(SWT.Selection, e -> openExportWizard(parent));
} else if (control instanceof Link) {
Composite linkParent = ((Link) control).getParent();
Composite linkParent = control.getParent();
Link importLink = new Link(linkParent, SWT.WRAP | SWT.NO_FOCUS);
((GridLayout) parent.getLayout()).numColumns++;
importLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final Object execute(final ExecutionEvent event) throws ExecutionExceptio
final int numParams = methodToExecute.getParameterTypes().length;

if ((focusControl instanceof Composite)
&& ((((Composite) focusControl).getStyle() & SWT.EMBEDDED) != 0)) {
&& ((focusControl.getStyle() & SWT.EMBEDDED) != 0)) {

// we only support selectAll for swing components
if (numParams != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Object execute(final ExecutionEvent event) throws ExecutionException {
try {
final Control focusControl = Display.getCurrent().getFocusControl();
if ((focusControl instanceof Composite)
&& ((((Composite) focusControl).getStyle() & SWT.EMBEDDED) != 0)) {
&& ((focusControl.getStyle() & SWT.EMBEDDED) != 0)) {
/*
* Okay. Have a seat. Relax a while. This is going to be a bumpy ride. If it is
* an embedded widget, then it *might* be a Swing widget. At the point where
Expand Down Expand Up @@ -210,7 +210,7 @@ protected Method getMethodToExecute() {
}

if ((method == null) && (focusControl instanceof Composite)
&& ((((Composite) focusControl).getStyle() & SWT.EMBEDDED) != 0)) {
&& ((focusControl.getStyle() & SWT.EMBEDDED) != 0)) {
/*
* We couldn't find the appropriate method on the current focus control. It is
* possible that the current focus control is an embedded SWT composite, which
Expand Down
Loading

0 comments on commit 160dfa8

Please sign in to comment.