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 #1311

Merged
merged 3 commits into from
Jun 20, 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
2 changes: 1 addition & 1 deletion ds/org.eclipse.pde.ds.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.pde.ds.ui;singleton:=true
Bundle-Version: 1.3.400.qualifier
Bundle-Version: 1.3.500.qualifier
Bundle-Activator: org.eclipse.pde.internal.ds.ui.Activator
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.30.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.20.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ private void assignRange(int offset) {
fRange = ((IDocumentAttributeNode) fRange)
.getEnclosingElement();
} else if (fRange instanceof IDocumentElementNode) {
if (((IDocumentElementNode) fRange).getOffset() == offset)
if (fRange.getOffset() == offset)
fRange = ((IDocumentElementNode) fRange).getParentNode();
} else if (fRange instanceof IDocumentTextNode) {
if (((IDocumentTextNode) fRange).getOffset() == offset)
if (fRange.getOffset() == offset)
fRange = ((IDocumentTextNode) fRange).getEnclosingElement();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void setItems(String[] items) {

public void setEnabled(boolean enabled) {
if (combo instanceof Combo)
((Combo) combo).setEnabled(enabled);
combo.setEnabled(enabled);
else
((CCombo) combo).setEnabled(enabled);
}
Expand Down
2 changes: 1 addition & 1 deletion ua/org.eclipse.pde.ua.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.pde.ua.ui;singleton:=true
Bundle-Version: 1.3.400.qualifier
Bundle-Version: 1.3.500.qualifier
Bundle-Activator: org.eclipse.pde.internal.ua.ui.PDEUserAssistanceUIPlugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.205.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.30.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ private void handleModelEventWorldChanged(IModelChangedEvent event) {
.getCurrentPage();
// Replace the current dirty model with the model reloaded from
// file
fModel = ((ICompCS) object).getModel();
fModel = object.getModel();
// Reset the treeviewer using the new model as input
// TODO: MP: CompCS: This is redundant and should be deleted
fTreeViewer.setInput(fModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.pde.internal.ua.ui.editor.cheatsheet.simple.NewCommandKeyEvent;
import org.eclipse.pde.internal.ua.ui.editor.cheatsheet.simple.SimpleCSCommandManager;
import org.eclipse.pde.internal.ui.parts.ComboPart;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Combo;
Expand All @@ -43,9 +42,9 @@ public void addDisposeListener(DisposeListener listener) {
if (combo == null) {
return;
} else if (combo instanceof Combo) {
((Combo) combo).addDisposeListener(listener);
combo.addDisposeListener(listener);
} else {
((CCombo) combo).addDisposeListener(listener);
combo.addDisposeListener(listener);
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.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: %name
Bundle-SymbolicName: org.eclipse.pde.core; singleton:=true
Bundle-Version: 3.18.100.qualifier
Bundle-Version: 3.18.200.qualifier
Bundle-Activator: org.eclipse.pde.internal.core.PDECore
Bundle-Vendor: %provider-name
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected void validateElementWithContent(Element element, boolean hasContent) {
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child instanceof Text) {
textFound = ((Text) child).getNodeValue().trim().length() > 0;
textFound = child.getNodeValue().trim().length() > 0;
} else if (child instanceof Element) {
reportIllegalElement((Element) child, CompilerFlags.ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public String getDescription() {
}
String elementName = null;
if (getParent() instanceof ISchemaElement) {
elementName = ((ISchemaElement) getParent()).getName();
elementName = getParent().getName();
if (elementName == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void checkEditConfigurationLink(Control[] element) {

private void isEditLaunchConfigurationLinkAvilable(Control[] element, Control control) {
Control editConfigLink = element[0];
((Link) control).notifyListeners(SWT.Selection, new Event());
control.notifyListeners(SWT.Selection, new Event());
assertNotNull(editConfigLink.isVisible());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void configureTextViewer(TextViewer textViewer) {

Font font = JFaceResources.getFont(ManifestContentMergeViewer.class.getName());
if (font != null) {
((SourceViewer) textViewer).getTextWidget().setFont(font);
textViewer.getTextWidget().setFont(font);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void configureTextViewer(final TextViewer textViewer) {
((SourceViewer) textViewer).configure(configuration);
Font font = JFaceResources.getFont(PluginContentMergeViewer.class.getName());
if (font != null)
((SourceViewer) textViewer).getTextWidget().setFont(font);
textViewer.getTextWidget().setFont(font);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public boolean visit(IResourceDelta delta) throws CoreException {
fDoRefresh = true;
return false;
}
} else if (resource instanceof IProject && ((IProject) resource).equals(project)) {
} else if (resource instanceof IProject && resource.equals(project)) {
return delta.getKind() != IResourceDelta.REMOVED;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ private void applyExtensionFullPoint(IDocument document, String delim, StringBui

private void applyElement(String indent, String delim, StringBuilder documentInsertBuffer) {
documentInsertBuffer.append('<');
documentInsertBuffer.append(((ISchemaElement) fSchemaObject).getName());
documentInsertBuffer.append(fSchemaObject.getName());
documentInsertBuffer.append('>');
documentInsertBuffer.append(delim);
documentInsertBuffer.append(indent);
documentInsertBuffer.append('<');
documentInsertBuffer.append('/');
documentInsertBuffer.append(((ISchemaElement) fSchemaObject).getName());
documentInsertBuffer.append(fSchemaObject.getName());
documentInsertBuffer.append('>');
}

Expand Down Expand Up @@ -368,7 +368,7 @@ private void findExtensionVirtualPointValue(IPluginBase base) {
return;
}
// Get the offset of the extension element
int targetOffset = ((IDocumentElementNode) range).getOffset();
int targetOffset = range.getOffset();
// Search this plug-ins extensions for the proper one
IPluginExtension[] extensions = base.getExtensions();
for (IPluginExtension extension : extensions) {
Expand All @@ -388,7 +388,7 @@ private void findExtensionVirtualPointValue(IPluginBase base) {
private void setSelectionOffsets(IDocument document, ISchemaElement schemaElement, IPluginParent pluginParent) {
if (pluginParent instanceof IPluginExtension) {
String point = ((IPluginExtension) pluginParent).getPoint();
IPluginObject[] children = ((IPluginExtension) pluginParent).getChildren();
IPluginObject[] children = pluginParent.getChildren();
if (children != null && children.length > 0 && children[0] instanceof IPluginParent) {
pluginParent = (IPluginParent) children[0];
schemaElement = XMLUtil.getSchemaElement((IDocumentElementNode) pluginParent, point);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ private void assignRange(int offset) {
if (((IDocumentAttributeNode) fRange).getNameOffset() == offset)
fRange = ((IDocumentAttributeNode) fRange).getEnclosingElement();
} else if (fRange instanceof IDocumentElementNode) {
if (((IDocumentElementNode) fRange).getOffset() == offset)
if (fRange.getOffset() == offset)
fRange = ((IDocumentElementNode) fRange).getParentNode();
} else if (fRange instanceof IDocumentTextNode) {
if (((IDocumentTextNode) fRange).getOffset() == offset)
if (fRange.getOffset() == offset)
fRange = ((IDocumentTextNode) fRange).getEnclosingElement();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,15 @@ private IProductModel getModel() {
public void commit(boolean onSave) {
fNameEntry.commit();
for (int i = 0; i < fIcons.size(); i++)
((FormEntry) fIcons.get(i)).commit();
fIcons.get(i).commit();
super.commit(onSave);
}

@Override
public void cancelEdit() {
fNameEntry.cancelEdit();
for (int i = 0; i < fIcons.size(); i++)
((FormEntry) fIcons.get(i)).commit();
fIcons.get(i).commit();
super.cancelEdit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ public void addPages() {
if (fIsInterface) {
((NewInterfaceWizardPage) fMainPage).init(StructuredSelection.EMPTY);
if (className != null)
((NewInterfaceWizardPage) fMainPage).setTypeName(className, true);
fMainPage.setTypeName(className, true);
if (packageRoot != null)
((NewInterfaceWizardPage) fMainPage).setPackageFragmentRoot(packageRoot, true);
fMainPage.setPackageFragmentRoot(packageRoot, true);
if (packageName != null)
((NewInterfaceWizardPage) fMainPage).setPackageFragment(packageName, true);
fMainPage.setPackageFragment(packageName, true);
} else {
((NewClassWizardPage) fMainPage).init(StructuredSelection.EMPTY);
if (className != null)
((NewClassWizardPage) fMainPage).setTypeName(className, true);
fMainPage.setTypeName(className, true);
if (packageRoot != null)
((NewClassWizardPage) fMainPage).setPackageFragmentRoot(packageRoot, true);
fMainPage.setPackageFragmentRoot(packageRoot, true);
if (packageName != null)
((NewClassWizardPage) fMainPage).setPackageFragment(packageName, true);
fMainPage.setPackageFragment(packageName, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}

@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {

Check warning on line 49 in ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/PluginXMLTextHover.java

View check run for this annotation

Jenkins - eclipse-pde / Compiler and API Tools

Deprecation

NORMAL: The method PluginXMLTextHover.getHoverInfo(ITextViewer, IRegion) overrides a deprecated method from ITextHover
int offset = hoverRegion.getOffset();
IDocumentRange range = fSourcePage.getRangeElement(offset, true);
if (range instanceof IDocumentTextNode)
Expand Down Expand Up @@ -120,7 +120,7 @@

private ISchemaObject getSchemaObject(ISchema schema, IPluginObject object) {
if (object instanceof IPluginElement)
return schema.findElement(((IPluginElement) object).getName());
return schema.findElement(object.getName());
if (object instanceof IPluginExtension)
return schema.findElement("extension"); //$NON-NLS-1$
if (object instanceof IDocumentAttributeNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public static boolean withinRange(IDocumentRange range, int offset) {
if (range instanceof IDocumentAttributeNode)
return withinRange(((IDocumentAttributeNode) range).getValueOffset(), ((IDocumentAttributeNode) range).getValueLength(), offset);
if (range instanceof IDocumentElementNode)
return withinRange(((IDocumentElementNode) range).getOffset(), ((IDocumentElementNode) range).getLength(), offset);
return withinRange(range.getOffset(), range.getLength(), offset);
if (range instanceof IDocumentTextNode)
return withinRange(((IDocumentTextNode) range).getOffset(), ((IDocumentTextNode) range).getLength(), offset);
return withinRange(range.getOffset(), range.getLength(), offset);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void setItems(String[] items) {

public void setEnabled(boolean enabled) {
if (combo instanceof Combo)
((Combo) combo).setEnabled(enabled);
combo.setEnabled(enabled);
else
((CCombo) combo).setEnabled(enabled);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static Change createRenameChange(IFile file, Object[] affectedElements, S
if (textChange != null) {
TextEdit edit = textChange.getEdit();
if (edit instanceof MultiTextEdit) {
((MultiTextEdit) edit).addChild(multiEdit);
edit.addChild(multiEdit);
multiEdit = ((MultiTextEdit) edit);
} else
multiEdit.addChild(edit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
fComposite.setLayout(layout);
fComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

fFilteredTree = new FilteredTree(fComposite, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE, new PatternFilter(), true) {

Check warning on line 293 in ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/target/StateViewPage.java

View check run for this annotation

Jenkins - eclipse-pde / Compiler and API Tools

Deprecation

NORMAL: The constructor FilteredTree(Composite, int, PatternFilter, boolean) is deprecated

Check warning on line 293 in ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/target/StateViewPage.java

View check run for this annotation

Jenkins - eclipse-pde / Compiler and API Tools

Deprecation

NORMAL: The constructor FilteredTree(Composite, int, PatternFilter, boolean) is deprecated
@Override
protected void createControl(Composite parent, int treeStyle) {
super.createControl(parent, treeStyle);
Expand Down Expand Up @@ -367,7 +367,7 @@
if (obj instanceof BundleSpecification)
obj = ((BundleSpecification) obj).getSupplier();
else if (obj instanceof ImportPackageSpecification)
obj = ((ExportPackageDescription) ((ImportPackageSpecification) obj).getSupplier()).getSupplier();
obj = ((ImportPackageSpecification) obj).getSupplier().getSupplier();
if (obj instanceof BundleDescription)
return (BundleDescription) obj;
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private void deleteConflictingProjects(MultiStatus status, IProgressMonitor moni
IResource resource = content.getAdapter(IResource.class);
if (resource instanceof IProject) {
// TODO For now just list everything in the map
String id = ((IProject) resource).getName();
String id = resource.getName();
List<IWorkingSet> workingSets = fProjectWorkingSets.get(id);
if (workingSets == null) {
workingSets = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ protected void addProjectPackages(IBundle bundle, Set<String> ignorePkgs) {
for (IResource child : children) {
if (child instanceof IContainer)
stack.push(child);
else if ("class".equals(((IFile) child).getFileExtension())) { //$NON-NLS-1$
else if ("class".equals(child.getFileExtension())) { //$NON-NLS-1$
String path = folder.getProjectRelativePath().toString();
ignorePkgs.add(path.replace('/', '.'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ else if (!wasUIPluginEnabled) {
* @return if the field data is using the OSGi framework
*/
private boolean isPureOSGi() {
return ((PluginFieldData) fData).getOSGiFramework() != null;
return fData.getOSGiFramework() != null;
}

@Override
Expand Down
Loading