Skip to content

Commit 0c9792f

Browse files
eclipse-pde-botakurtakov
authored andcommitted
Perform clean code of ui/org.eclipse.pde.ui
1 parent 3252c16 commit 0c9792f

File tree

10 files changed

+10
-21
lines changed

10 files changed

+10
-21
lines changed

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/contentassist/XMLCompletionProposal.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,8 @@ private void modifyModel(IDocument document) {
308308
findExtensionVirtualPointValue(base);
309309
break;
310310
}
311-
} else if (fRange instanceof IDocumentElementNode && base instanceof IDocumentElementNode) {
311+
} else if (fRange instanceof IDocumentElementNode node && base instanceof IDocumentElementNode newSearch) {
312312
ArrayDeque<IDocumentElementNode> s = new ArrayDeque<>();
313-
IDocumentElementNode node = (IDocumentElementNode) fRange;
314-
IDocumentElementNode newSearch = (IDocumentElementNode) base;
315313
// traverse up old model, pushing all nodes onto the stack along the way
316314
while (node != null && !(node instanceof IPluginBase)) {
317315
s.push(node);

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,8 @@ protected void doPaste(Object targetObject, Object[] sourceObjects) {
632632

633633
protected void doAddDependencies() {
634634
IBaseModel model = getPage().getModel();
635-
if (model instanceof IBundlePluginModelBase) {
635+
if (model instanceof IBundlePluginModelBase bmodel) {
636636
IProject proj = getPage().getPDEEditor().getCommonProject();
637-
IBundlePluginModelBase bmodel = ((IBundlePluginModelBase) model);
638637
AddNewDependenciesAction action = new AddNewDependenciesAction(proj, bmodel);
639638
action.run();
640639
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionPointsSection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,8 @@ protected void handleDoubleClick(IStructuredSelection selection) {
266266
private void handleDelete() {
267267
Object[] selection = pointTable.getStructuredSelection().toArray();
268268
for (Object selectedObject : selection) {
269-
if (selectedObject != null && selectedObject instanceof IPluginExtensionPoint) {
269+
if (selectedObject != null && selectedObject instanceof IPluginExtensionPoint ep) {
270270
IStructuredSelection newSelection = null;
271-
IPluginExtensionPoint ep = (IPluginExtensionPoint) selectedObject;
272271
IPluginBase plugin = ep.getPluginBase();
273272
IPluginExtensionPoint[] points = plugin.getExtensionPoints();
274273
int index = getNewSelectionIndex(getArrayIndex(points, ep), points.length);

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionsPage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public Object getPageKey(Object object) {
8080
if (object instanceof IPluginExtension) {
8181
return IPluginExtension.class;
8282
}
83-
if (object instanceof IPluginElement) {
83+
if (object instanceof IPluginElement pelement) {
8484
ISchemaElement element = ExtensionsSection.getSchemaElement((IPluginElement) object);
8585
// Extension point schema exists
8686
if (element != null) {
@@ -96,7 +96,6 @@ public Object getPageKey(Object object) {
9696
}
9797
// No Extension point schema
9898
// no element - construct one
99-
IPluginElement pelement = (IPluginElement) object;
10099
// Use the body text page if the element has no child
101100
// elements or attributes
102101
if ((pelement.getAttributeCount() == 0) && (pelement.getChildCount() == 0)) {

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/PluginUndoManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ private void executeAdd(IModelChangeProvider model, Object[] elements) {
158158
((ImportPackageHeader) header).addPackage((PackageObject) element);
159159
}
160160
}
161-
if (element instanceof RequireBundleObject) {
161+
if (element instanceof RequireBundleObject requireBundle) {
162162
IBaseModel aggModel = getEditor().getAggregateModel();
163163
if (aggModel instanceof BundlePluginModel pluginModel) {
164-
RequireBundleObject requireBundle = (RequireBundleObject) element;
165164
pluginBase = pluginModel.getPluginBase();
166165
String elementValue = requireBundle.getValue();
167166
IPluginImport importNode = null;

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/AbstractSchemaDetails.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,8 @@ public void selectionChanged(IFormPart part, ISelection selection) {
252252
return;
253253
}
254254
Object obj = ((IStructuredSelection) selection).getFirstElement();
255-
if (obj instanceof ISchemaObject) {
255+
if (obj instanceof ISchemaObject sObj) {
256256
setBlockListeners(true);
257-
ISchemaObject sObj = (ISchemaObject) obj;
258257
fSchemaObject = sObj;
259258
if (fShowDTD && fDtdSection != null) {
260259
fDtdSection.updateDTDLabel(obj);

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/ElementSection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ public void handleModelChanged(IModelChangedEvent e) {
604604
// the new selection is handled by the handleDelete method for cuts and deletes,
605605
// for moves it is handled by the subsequent insert
606606
}
607-
} else if (obj instanceof ISchemaComplexType) {
607+
} else if (obj instanceof ISchemaComplexType type) {
608608
// first compositor added/removed
609609
ISchemaCompositor comp = ((ISchemaComplexType) obj).getCompositor();
610610
fTreeViewer.refresh(comp);
@@ -613,7 +613,6 @@ public void handleModelChanged(IModelChangedEvent e) {
613613
}
614614

615615
if (e.getChangeType() == IModelChangedEvent.INSERT || e.getChangeType() == IModelChangedEvent.CHANGE) {
616-
ISchemaComplexType type = (ISchemaComplexType) obj;
617616
final ISchemaCompositor compositor = type.getCompositor();
618617
if (compositor != null) {
619618
fTreeViewer.getTree().getDisplay().asyncExec(() -> fTreeViewer.setSelection(new StructuredSelection(compositor), true));

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ManifestTextHover.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
4949
String hover = getHoverInfo2(textViewer, hoverRegion);
5050
if (hover == null) {
5151
IAnnotationModel annotationModel = fSourcePage.getViewer().getAnnotationModel();
52-
if (annotationModel instanceof PDEMarkerAnnotationModel) {
52+
if (annotationModel instanceof PDEMarkerAnnotationModel pdeAnnotationModel) {
5353
int offset = hoverRegion.getOffset();
54-
PDEMarkerAnnotationModel pdeAnnotationModel = (PDEMarkerAnnotationModel) annotationModel;
5554
Iterator<Annotation> annotationIterator = pdeAnnotationModel.getAnnotationIterator(offset, 0, true,
5655
true);
5756
while (annotationIterator.hasNext()) {

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/search/ExtensionsPatternFilter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,8 @@ public boolean isElementVisible(Viewer viewer, Object element) {
221221

222222
@Override
223223
public Object[] filter(Viewer viewer, Object parent, Object[] elements) {
224-
if (parent != null && parent instanceof BundlePlugin) {
224+
if (parent != null && parent instanceof BundlePlugin pluginPlugin) {
225225
if (fFoundAnyElementsCache.isEmpty() && fSearchPattern != null && fSearchPattern.length() > 0) {
226-
BundlePlugin pluginPlugin = (BundlePlugin) parent;
227226
doFilter(viewer, pluginPlugin, pluginPlugin.getExtensions(), false);
228227
}
229228
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/search/PluginSearchActionGroup.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ private void addOpenSchemaAction(Object object, IMenuManager menu) {
6262
action.setInput((IPluginExtension) object);
6363
action.setEnabled(true);
6464
menu.add(action);
65-
} else if (object instanceof IPluginExtensionPoint) {
65+
} else if (object instanceof IPluginExtensionPoint point) {
6666
// From PluginSearchResultPage
6767
// From ExtensionPointsSection
6868
OpenSchemaAction action = new OpenSchemaAction();
69-
IPluginExtensionPoint point = (IPluginExtensionPoint) object;
7069
String pointID = point.getFullId();
7170
// Ensure the extension point ID is fully qualified
7271
if (pointID.indexOf('.') == -1) {

0 commit comments

Comments
 (0)