Skip to content

Commit 98d8f82

Browse files
eclipse-pde-botmerks
authored andcommitted
Perform clean code of e4tools/bundles/org.eclipse.e4.tools
1 parent bdddc89 commit 98d8f82

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

e4tools/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ private IPackageFragmentRoot choosePackageRoot() {
377377
@Override
378378
public boolean isSelectedValid(Object element) {
379379
try {
380-
if (element instanceof IJavaProject) {
381-
final IJavaProject jproject = (IJavaProject) element;
380+
if (element instanceof final IJavaProject jproject) {
382381
final IPath path = jproject.getProject().getFullPath();
383382
return jproject.findPackageFragmentRoot(path) != null;
384383
} else if (element instanceof IPackageFragmentRoot) {
@@ -422,8 +421,7 @@ public boolean select(Viewer viewer, Object parent, Object element) {
422421

423422
if (dialog.open() == Window.OK) {
424423
final Object element = dialog.getFirstResult();
425-
if (element instanceof IJavaProject) {
426-
final IJavaProject jproject = (IJavaProject) element;
424+
if (element instanceof final IJavaProject jproject) {
427425
return jproject.getPackageFragmentRoot(jproject.getProject());
428426
} else if (element instanceof IPackageFragmentRoot) {
429427
return (IPackageFragmentRoot) element;

e4tools/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassWizard.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ protected IJavaElement getInitialJavaElement(IStructuredSelection selection) {
9595
IJavaElement jelem = null;
9696
if (selection != null && !selection.isEmpty()) {
9797
final Object selectedElement = selection.getFirstElement();
98-
if (selectedElement instanceof IAdaptable) {
99-
final IAdaptable adaptable = (IAdaptable) selectedElement;
100-
98+
if (selectedElement instanceof final IAdaptable adaptable) {
10199
jelem = adaptable.getAdapter(IJavaElement.class);
102100
if (jelem == null || !jelem.exists()) {
103101
jelem = null;

e4tools/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ private IPluginExtension copyExtension(IExtensionsModelFactory factory, final IP
380380
clonedExt.setPoint(ext.getPoint());
381381
final IPluginObject[] _children = ext.getChildren();
382382
for (final IPluginObject elt : _children) {
383-
if (elt instanceof IPluginElement) {
384-
final IPluginElement ipe = (IPluginElement) elt;
383+
if (elt instanceof final IPluginElement ipe) {
385384
final IPluginElement clonedElt = copyExtensionElement(factory, ipe, ext);
386385
clonedExt.add(clonedElt);
387386
}
@@ -420,8 +419,7 @@ private IPluginElement copyExtensionElement(IExtensionsModelFactory factory, fin
420419
clonedElt.setAttribute(a.getName(), a.getValue());
421420
}
422421
for (final IPluginObject e : elt.getChildren()) {
423-
if (e instanceof IPluginElement) {
424-
final IPluginElement ipe = (IPluginElement) e;
422+
if (e instanceof final IPluginElement ipe) {
425423
final IPluginElement copyExtensionElement = copyExtensionElement(factory, ipe, clonedElt);
426424
clonedElt.add(copyExtensionElement);
427425
}

e4tools/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ protected void createAdditionalControls(Composite parent) {
116116

117117
private void initialize() {
118118
if (selection != null && selection.isEmpty() == false
119-
&& selection instanceof IStructuredSelection) {
120-
final IStructuredSelection ssel = (IStructuredSelection) selection;
119+
&& selection instanceof final IStructuredSelection ssel) {
121120
if (ssel.size() > 1) {
122121
return;
123122
}
@@ -131,8 +130,7 @@ private void initialize() {
131130
container = ((IResource) obj).getParent();
132131
}
133132
containerText.setText(container.getFullPath().toString());
134-
} else if (obj instanceof IJavaProject) {
135-
final IJavaProject container = (IJavaProject) obj;
133+
} else if (obj instanceof final IJavaProject container) {
136134
try {
137135
containerText.setText(container.getCorrespondingResource().getFullPath().toString());
138136
} catch (final JavaModelException e) {

0 commit comments

Comments
 (0)