Skip to content

Commit 0cc7460

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of runtime/bundles/org.eclipse.e4.core.contexts
1 parent c5aef98 commit 0cc7460

File tree

10 files changed

+163
-85
lines changed

10 files changed

+163
-85
lines changed

runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ConcurrentNeutralValueMap.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ public int hashCode() {
9292
/** return does NOT use equals() of the neutralValue **/
9393
@Override
9494
public boolean equals(Object obj) {
95-
if (!(obj instanceof ConcurrentNeutralValueMap))
95+
if (!(obj instanceof ConcurrentNeutralValueMap)) {
9696
return false;
97+
}
9798
return delegate.equals(((ConcurrentNeutralValueMap<?, ?>) obj).delegate);
9899
}
99100

runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextChangeEvent.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,15 @@ public int hashCode() {
149149

150150
@Override
151151
public boolean equals(Object obj) {
152-
if (this == obj)
152+
if (this == obj) {
153153
return true;
154-
if (obj == null)
154+
}
155+
if (obj == null) {
155156
return false;
156-
if (getClass() != obj.getClass())
157+
}
158+
if (getClass() != obj.getClass()) {
157159
return false;
160+
}
158161
ContextChangeEvent other = (ContextChangeEvent) obj;
159162

160163
// if ((eventType == DISPOSE) || (eventType == UNINJECTED)) {

runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ public ContextInjectionListener(IEclipseContext context, Object[] result, String
5252

5353
@Override
5454
public Reference<Object> getReference() {
55-
if (requestor instanceof Requestor)
55+
if (requestor instanceof Requestor) {
5656
return ((Requestor<?>) requestor).getReference();
57+
}
5758
return super.getReference();
5859
}
5960

@@ -62,16 +63,19 @@ public boolean update(IEclipseContext eventsContext, int eventType, Object[] ext
6263
if (eventType == ContextChangeEvent.INITIAL) {
6364
// needs to be done inside runnable to establish dependencies
6465
for (int i = 0; i < keys.length; i++) {
65-
if (keys[i] == null)
66+
if (keys[i] == null) {
6667
continue;
68+
}
6769
IEclipseContext targetContext = (active[i]) ? context.getActiveLeaf() : context;
6870
if (ECLIPSE_CONTEXT_NAME.equals(keys[i])) {
6971
result[i] = targetContext;
7072
IEclipseContext parent = targetContext.getParent(); // creates pseudo-link
71-
if (parent == null)
73+
if (parent == null) {
7274
targetContext.get(ECLIPSE_CONTEXT_NAME); // pseudo-link in case there is no parent
73-
} else if (targetContext.containsKey(keys[i]))
75+
}
76+
} else if (targetContext.containsKey(keys[i])) {
7477
result[i] = targetContext.get(keys[i]);
78+
}
7579
}
7680
return true;
7781
}
@@ -89,8 +93,9 @@ public boolean update(IEclipseContext eventsContext, int eventType, Object[] ext
8993
return requestor.uninject(extraArguments[0], originatingSupplier);
9094
} break;
9195
default:
92-
if (!requestor.isValid())
96+
if (!requestor.isValid()) {
9397
return false; // remove this listener
98+
}
9499
requestor.resolveArguments(false);
95100
requestor.execute();
96101
break;
@@ -113,12 +118,15 @@ public int hashCode() {
113118

114119
@Override
115120
public boolean equals(Object obj) {
116-
if (this == obj)
121+
if (this == obj) {
117122
return true;
118-
if (obj == null)
123+
}
124+
if (obj == null) {
119125
return false;
120-
if (getClass() != obj.getClass())
126+
}
127+
if (getClass() != obj.getClass()) {
121128
return false;
129+
}
122130
ContextInjectionListener other = (ContextInjectionListener) obj;
123131
return Objects.equals(this.context, other.context) && Objects.equals(this.requestor, other.requestor);
124132
}
@@ -147,16 +155,18 @@ public void get(IObjectDescriptor[] descriptors, Object[] actualArgs, final IReq
147155

148156
for (int i = 0; i < descriptors.length; i++) {
149157
String key = getKey(descriptors[i]);
150-
if ((actualArgs[i] == IInjector.NOT_A_VALUE))
158+
if ((actualArgs[i] == IInjector.NOT_A_VALUE)) {
151159
keys[i] = key;
152-
else if (ECLIPSE_CONTEXT_NAME.equals(key)) // allow provider to override IEclipseContext
160+
} else if (ECLIPSE_CONTEXT_NAME.equals(key)) { // allow provider to override IEclipseContext
153161
keys[i] = ECLIPSE_CONTEXT_NAME;
154-
else
162+
} else {
155163
keys[i] = null;
156-
if (descriptors[i] == null)
164+
}
165+
if (descriptors[i] == null) {
157166
active[i] = false;
158-
else
167+
} else {
159168
active[i] = (descriptors[i].hasQualifier(Active.class));
169+
}
160170
}
161171

162172
if (requestor != null && track) { // only track if requested
@@ -178,13 +188,15 @@ else if (ECLIPSE_CONTEXT_NAME.equals(key)) // allow provider to override IEclips
178188

179189
private void fillArgs(Object[] actualArgs, String[] keys, boolean[] active) {
180190
for (int i = 0; i < keys.length; i++) {
181-
if (keys[i] == null)
191+
if (keys[i] == null) {
182192
continue;
193+
}
183194
IEclipseContext targetContext = (active[i]) ? context.getActiveLeaf() : context;
184-
if (ECLIPSE_CONTEXT_NAME.equals(keys[i]))
195+
if (ECLIPSE_CONTEXT_NAME.equals(keys[i])) {
185196
actualArgs[i] = targetContext;
186-
else if (targetContext.containsKey(keys[i]))
197+
} else if (targetContext.containsKey(keys[i])) {
187198
actualArgs[i] = targetContext.get(keys[i]);
199+
}
188200
}
189201
}
190202

@@ -198,10 +210,12 @@ private String getKey(IObjectDescriptor descriptor) {
198210
}
199211

200212
private String typeToString(Type type) {
201-
if (type == null)
213+
if (type == null) {
202214
return null;
203-
if (type instanceof Class<?>)
215+
}
216+
if (type instanceof Class<?>) {
204217
return ((Class<?>) type).getName();
218+
}
205219
if (type instanceof ParameterizedType) {
206220
Type rawType = ((ParameterizedType) type).getRawType();
207221
return typeToString(rawType);
@@ -219,17 +233,20 @@ synchronized public void pauseRecording() {
219233
synchronized public void resumeRecording() {
220234
Stack<Computation> current = EclipseContext.getCalculatedComputations();
221235
Computation plug = current.pop();
222-
if (plug != null)
236+
if (plug != null) {
223237
throw new IllegalArgumentException("Internal error in nested computation processing"); //$NON-NLS-1$
238+
}
224239
}
225240

226241
static public ContextObjectSupplier getObjectSupplier(IEclipseContext context, IInjector injector) {
227-
if (context == null)
242+
if (context == null) {
228243
return null;
244+
}
229245
// don't track this dependency if we are called in RaT
230246
ContextObjectSupplier supplier = (ContextObjectSupplier) ((EclipseContext) context).internalGet((EclipseContext) context, ContextObjectSupplier.class.getName(), true);
231-
if (supplier != null)
247+
if (supplier != null) {
232248
return supplier;
249+
}
233250
ContextObjectSupplier objectSupplier = new ContextObjectSupplier(context, injector);
234251
context.set(ContextObjectSupplier.class, objectSupplier);
235252
return objectSupplier;

0 commit comments

Comments
 (0)