Skip to content

Commit 193c8ae

Browse files
Perform clean code of bundles/org.eclipse.e4.ui.workbench
1 parent 8dc4f46 commit 193c8ae

32 files changed

+207
-187
lines changed

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/LocaleChangeServiceImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ protected void updateLocalization(List<? extends MUIElement> children) {
110110
updateLocalization(((MElementContainer) element).getChildren());
111111
}
112112

113-
if (element instanceof MWindow) {
114-
MWindow window = (MWindow) element;
113+
if (element instanceof MWindow window) {
115114
MMenu mainMenu = window.getMainMenu();
116115
if (mainMenu != null) {
117116
mainMenu.updateLocalization();
@@ -132,8 +131,7 @@ protected void updateLocalization(List<? extends MUIElement> children) {
132131
updateLocalization(((MPerspective) element).getWindows());
133132
}
134133

135-
if (element instanceof MPart) {
136-
MPart mPart = (MPart) element;
134+
if (element instanceof MPart mPart) {
137135
MToolBar toolbar = mPart.getToolbar();
138136
if (toolbar != null && toolbar.getChildren() != null) {
139137
toolbar.updateLocalization();

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ActiveChildLookupFunction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
public class ActiveChildLookupFunction extends ContextFunction {
2121

22-
private String localVar;
23-
private String var;
22+
private final String localVar;
23+
private final String var;
2424

2525
public ActiveChildLookupFunction(String var, String localVar) {
2626
this.var = var;

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ActivePartLookupFunction.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ public Object compute(IEclipseContext context, String contextKey) {
4242
return null;
4343
}
4444
MPart part = current.getActiveLeaf().get(MPart.class);
45-
if (part == null)
45+
if (part == null) {
4646
return null;
47+
}
4748
MUIElement parent = part.getCurSharedRef() != null ? part.getCurSharedRef().getParent() : part.getParent();
48-
if (parent == null)
49+
if (parent == null) {
4950
return part;
51+
}
5052
List<String> parentTags = parent.getTags();
5153
if (parentTags.contains(IPresentationEngine.MINIMIZED) && !parentTags.contains(IPresentationEngine.ACTIVE)
5254
&& !part.getTags().contains(IPresentationEngine.ACTIVE)) {

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ApplicationPartServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public class ApplicationPartServiceImpl implements EPartService {
3838
private static final Supplier<RuntimeException> NO_VALID_PARTSERVICE = () -> new IllegalStateException(
3939
"No valid PartService can be acquired from the current context"); //$NON-NLS-1$
4040

41-
private MApplication application;
41+
private final MApplication application;
4242

43-
private EModelService modelService;
43+
private final EModelService modelService;
4444

4545
@Inject
4646
ApplicationPartServiceImpl(MApplication application, EModelService modelService) {

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/BundleFinder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ final class BundleFinder implements BundleTrackerCustomizer<List<Bundle>> {
4949
*/
5050
public Bundle findBundle(String symbolicName) {
5151
List<Bundle> bundlesWithSameSymName = trackedBundles.get(symbolicName);
52-
if (bundlesWithSameSymName == null)
52+
if (bundlesWithSameSymName == null) {
5353
return null;
54+
}
5455

5556
List<Bundle> snapshot = new ArrayList<>(bundlesWithSameSymName);
5657

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ConfigurationElementAdapter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ public Object getProperty(Object element, String id) {
5454
String constructedName = Util.ZERO_LENGTH_STRING;
5555
if (nameVal != null) {
5656
constructedName = nameVal;
57-
if (idVal != null)
57+
if (idVal != null) {
5858
constructedName += " [" + idVal + "]"; //$NON-NLS-1$ //$NON-NLS-2$
59+
}
5960
} else if (idVal != null) {
6061
constructedName = idVal;
61-
} else
62+
} else {
6263
constructedName = ice.getName();
64+
}
6365

6466
return constructedName;
6567
} else if (CLASS_IMPL.equals(id)) {

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,9 @@ static boolean isFiltered(MMenu menuModel, MMenuContribution menuContribution,
196196
}
197197

198198
public static void collectInfo(ExpressionInfo info, MExpression exp) {
199-
if (!(exp instanceof MCoreExpression)) {
199+
if (!(exp instanceof MCoreExpression expr)) {
200200
return;
201201
}
202-
MCoreExpression expr = (MCoreExpression) exp;
203202
Expression ref = null;
204203
if (expr.getCoreExpression() instanceof Expression) {
205204
ref = (Expression) expr.getCoreExpression();
@@ -232,8 +231,7 @@ public static boolean isVisible(MTrimContribution contribution, ExpressionContex
232231
}
233232

234233
public static boolean isVisible(MExpression exp, final ExpressionContext eContext) {
235-
if (exp instanceof MCoreExpression) {
236-
MCoreExpression coreExpression = (MCoreExpression) exp;
234+
if (exp instanceof MCoreExpression coreExpression) {
237235
return isCoreExpressionVisible(coreExpression, eContext);
238236
} else if (exp instanceof MImperativeExpression) {
239237
return isImperativeExpressionVisible((MImperativeExpression) exp, eContext);
@@ -472,10 +470,10 @@ public static MCommand getCommandById(MApplication app, String cmdId) {
472470
static class Key {
473471
private int tag = -1;
474472
private int hc = -1;
475-
private String parentId;
476-
private String position;
477-
private MCoreExpression vexp;
478-
private Object factory;
473+
private final String parentId;
474+
private final String position;
475+
private final MCoreExpression vexp;
476+
private final Object factory;
479477

480478
public Key(String parentId, String position, List<String> tags, MCoreExpression vexp,
481479
Object factory) {
@@ -500,10 +498,9 @@ int getSchemeTag() {
500498

501499
@Override
502500
public boolean equals(Object obj) {
503-
if (!(obj instanceof Key)) {
501+
if (!(obj instanceof Key other)) {
504502
return false;
505503
}
506-
Key other = (Key) obj;
507504
Object exp1 = vexp == null ? null : vexp.getCoreExpression();
508505
Object exp2 = other.vexp == null ? null : other.vexp.getCoreExpression();
509506
return Objects.equals(parentId, other.parentId) && Objects.equals(position, other.position)
@@ -533,7 +530,7 @@ public String toString() {
533530

534531
static class MenuKey extends Key {
535532
static final String FACTORY = "ContributionFactory"; //$NON-NLS-1$
536-
private MMenuContribution contribution;
533+
private final MMenuContribution contribution;
537534

538535
public MenuKey(MMenuContribution mc) {
539536
super(mc.getParentId(), mc.getPositionInParent(), mc.getTags(), (MCoreExpression) mc
@@ -549,7 +546,7 @@ public MMenuContribution getContribution() {
549546

550547
static class ToolBarKey extends Key {
551548
static final String FACTORY = "ToolBarContributionFactory"; //$NON-NLS-1$
552-
private MToolBarContribution contribution;
549+
private final MToolBarContribution contribution;
553550

554551
public ToolBarKey(MToolBarContribution mc) {
555552
super(mc.getParentId(), mc.getPositionInParent(), mc.getTags(), (MCoreExpression) mc
@@ -564,7 +561,7 @@ public MToolBarContribution getContribution() {
564561
}
565562

566563
static class TrimKey extends Key {
567-
private MTrimContribution contribution;
564+
private final MTrimContribution contribution;
568565

569566
public TrimKey(MTrimContribution mc) {
570567
super(mc.getParentId(), mc.getPositionInParent(), mc.getTags(), (MCoreExpression) mc

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4XMIResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public class E4XMIResource extends XMIResourceImpl {
3030

3131
public static final String OPTION_FILTER_PERSIST_STATE = "E4_FILTER_PERSISTED_STATE"; //$NON-NLS-1$
3232

33-
private Map<EObject, String> objectMap = new WeakHashMap<>();
34-
private Set<String> knownIds = new HashSet<>();
33+
private final Map<EObject, String> objectMap = new WeakHashMap<>();
34+
private final Set<String> knownIds = new HashSet<>();
3535

3636
public E4XMIResource() {
3737
}

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4XMISave.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ public E4XMISave(XMLHelper helper) {
3737
*/
3838
@Override
3939
protected void saveElement(InternalEObject o, EStructuralFeature f) {
40-
if (o instanceof MApplicationElement) {
41-
MApplicationElement appElement = (MApplicationElement) o;
40+
if (o instanceof MApplicationElement appElement) {
4241
String persists = appElement.getPersistedState().get(IWorkbench.PERSIST_STATE);
4342
if (persists != null && !Boolean.parseBoolean(persists)) {
4443
return;
4544
}
4645
}
47-
if (o instanceof MUIElement) {
48-
MUIElement uiElement = (MUIElement) o;
46+
if (o instanceof MUIElement uiElement) {
4947
if (OpaqueElementUtil.isOpaqueElement(uiElement) || RenderedElementUtil.isRenderedElement(uiElement)) {
5048
return;
5149
}

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ExtensionTrackeContextFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ExtensionTrackeContextFunction extends ContextFunction implements E
3737
@Reference
3838
private ILog log;
3939

40-
private Map<IEclipseContext, IExtensionTracker> createdObjects = new ConcurrentHashMap<>();
40+
private final Map<IEclipseContext, IExtensionTracker> createdObjects = new ConcurrentHashMap<>();
4141

4242
@Override
4343
public Object compute(IEclipseContext context, String contextKey) {

0 commit comments

Comments
 (0)