Skip to content

Commit 28395d8

Browse files
Perform clean code of resources/bundles/org.eclipse.core.resources
1 parent 47871af commit 28395d8

File tree

162 files changed

+3971
-2097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+3971
-2097
lines changed

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTreeNode.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ public abstract class AbstractDataTreeNode {
5050
*/
5151
AbstractDataTreeNode(String name, AbstractDataTreeNode[] children) {
5252
this.name = name;
53-
if (children == null || children.length == 0)
53+
if (children == null || children.length == 0) {
5454
this.children = AbstractDataTreeNode.NO_CHILDREN;
55-
else
55+
} else {
5656
this.children = children;
57+
}
5758
}
5859

5960
/**
@@ -84,8 +85,9 @@ AbstractDataTreeNode asReverseComparisonNode(IComparator comparator) {
8485
static AbstractDataTreeNode[] assembleWith(AbstractDataTreeNode[] oldNodes, AbstractDataTreeNode[] newNodes, boolean keepDeleted) {
8586

8687
// Optimize the common case where the new list is empty.
87-
if (newNodes.length == 0)
88+
if (newNodes.length == 0) {
8889
return oldNodes;
90+
}
8991

9092
// Can't just return newNodes if oldNodes has length 0
9193
// because newNodes may contain deleted nodes.
@@ -198,8 +200,9 @@ AbstractDataTreeNode assembleWith(AbstractDataTreeNode node) {
198200
}
199201
if (this.isDelta()) {
200202
AbstractDataTreeNode[] assembledChildren = assembleWith(children, node.children, true);
201-
if (this.hasData())
203+
if (this.hasData()) {
202204
return new DataDeltaNode(name, this.getData(), assembledChildren);
205+
}
203206
return new NoDataDeltaNode(name, assembledChildren);
204207
}
205208
AbstractDataTreeNode[] assembledChildren = assembleWith(children, node.children, false);
@@ -271,10 +274,11 @@ AbstractDataTreeNode childAtIgnoreCase(String localName) {
271274
for (AbstractDataTreeNode element : children) {
272275
if (element.getName().equalsIgnoreCase(localName)) {
273276
//if we find a deleted child, keep looking for a real child
274-
if (element.isDeleted())
277+
if (element.isDeleted()) {
275278
result = element;
276-
else
279+
} else {
277280
return element;
281+
}
278282
}
279283
}
280284
return result;
@@ -502,8 +506,9 @@ boolean isEmptyDelta() {
502506
String[] namesOfChildren() {
503507
String names[] = new String[children.length];
504508
/* copy child names (Reverse loop optimized) */
505-
for (int i = children.length; --i >= 0;)
509+
for (int i = children.length; --i >= 0;) {
506510
names[i] = children[i].getName();
511+
}
507512
return names;
508513
}
509514

@@ -538,8 +543,9 @@ void setName(String s) {
538543
*/
539544
protected static AbstractDataTreeNode[] simplifyWithParent(AbstractDataTreeNode[] nodes, IPath key, DeltaDataTree parent, IComparator comparer) {
540545
int nodeCount = nodes.length;
541-
if (nodeCount == 0)
546+
if (nodeCount == 0) {
542547
return NO_CHILDREN;
548+
}
543549
AbstractDataTreeNode[] simplifiedNodes = new AbstractDataTreeNode[nodeCount];
544550
int simplifiedCount = 0;
545551
for (int i = 0; i < nodeCount; ++i) {
@@ -577,9 +583,11 @@ public void storeStrings(StringPool set) {
577583
name = set.add(name);
578584
//copy children pointer in case of concurrent modification
579585
AbstractDataTreeNode[] nodes = children;
580-
if (nodes != null)
581-
for (int i = nodes.length; --i >= 0;)
586+
if (nodes != null) {
587+
for (int i = nodes.length; --i >= 0;) {
582588
nodes[i].storeStrings(set);
589+
}
590+
}
583591
}
584592

585593
/**

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataDeltaNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ boolean isDelta() {
100100
AbstractDataTreeNode simplifyWithParent(IPath key, DeltaDataTree parent, IComparator comparer) {
101101
AbstractDataTreeNode[] simplifiedChildren = simplifyWithParent(children, key, parent, comparer);
102102
/* don't compare root nodes */
103-
if (!key.isRoot() && comparer.compare(parent.getData(key), data) == 0)
103+
if (!key.isRoot() && comparer.compare(parent.getData(key), data) == 0) {
104104
return new NoDataDeltaNode(name, simplifiedChildren);
105+
}
105106
return new DataDeltaNode(name, data, simplifiedChildren);
106107
}
107108

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeNode.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ public DataTreeNode(String name, Object data, AbstractDataTreeNode[] children) {
5555
*/
5656
@Override
5757
AbstractDataTreeNode asBackwardDelta(DeltaDataTree myTree, DeltaDataTree parentTree, IPath key) {
58-
if (parentTree.includes(key))
58+
if (parentTree.includes(key)) {
5959
return parentTree.copyCompleteSubtree(key);
60+
}
6061
return new DeletedNode(name);
6162
}
6263

@@ -116,8 +117,9 @@ AbstractDataTreeNode compareWith(DataTreeNode other, IComparator comparator) {
116117

117118
@Override
118119
AbstractDataTreeNode compareWithParent(IPath key, DeltaDataTree parent, IComparator comparator) {
119-
if (!parent.includes(key))
120+
if (!parent.includes(key)) {
120121
return convertToAddedComparisonNode(this, NodeComparison.K_ADDED);
122+
}
121123
DataTreeNode inParent = (DataTreeNode) parent.copyCompleteSubtree(key);
122124
return inParent.compareWith(this, comparator);
123125
}
@@ -218,47 +220,52 @@ protected static AbstractDataTreeNode[] forwardDeltaWith(AbstractDataTreeNode[]
218220
AbstractDataTreeNode deltaNode = forwardDeltaWithOrNullIfEqual(oldNodes[oldIndex++], newNodes[newIndex++], comparer);
219221
if (deltaNode != null) {
220222
if (numChildDeltas >= childDeltaMax) {
221-
if (childDeltas == null)
223+
if (childDeltas == null) {
222224
childDeltas = new AbstractDataTreeNode[childDeltaMax = 5];
223-
else
225+
} else {
224226
System.arraycopy(childDeltas, 0, childDeltas = new AbstractDataTreeNode[childDeltaMax = childDeltaMax * 2 + 1], 0, numChildDeltas);
227+
}
225228
}
226229
childDeltas[numChildDeltas++] = deltaNode;
227230
}
228231
} else if (compare < 0) {
229232
if (numChildDeltas >= childDeltaMax) {
230-
if (childDeltas == null)
233+
if (childDeltas == null) {
231234
childDeltas = new AbstractDataTreeNode[childDeltaMax = 5];
232-
else
235+
} else {
233236
System.arraycopy(childDeltas, 0, childDeltas = new AbstractDataTreeNode[childDeltaMax = childDeltaMax * 2 + 1], 0, numChildDeltas);
237+
}
234238
}
235239
childDeltas[numChildDeltas++] = new DeletedNode(oldName);
236240
oldIndex++;
237241
} else {
238242
if (numChildDeltas >= childDeltaMax) {
239-
if (childDeltas == null)
243+
if (childDeltas == null) {
240244
childDeltas = new AbstractDataTreeNode[childDeltaMax = 5];
241-
else
245+
} else {
242246
System.arraycopy(childDeltas, 0, childDeltas = new AbstractDataTreeNode[childDeltaMax = childDeltaMax * 2 + 1], 0, numChildDeltas);
247+
}
243248
}
244249
childDeltas[numChildDeltas++] = newNodes[newIndex++];
245250
}
246251
}
247252
while (oldIndex < oldNodes.length) {
248253
if (numChildDeltas >= childDeltaMax) {
249-
if (childDeltas == null)
254+
if (childDeltas == null) {
250255
childDeltas = new AbstractDataTreeNode[childDeltaMax = 5];
251-
else
256+
} else {
252257
System.arraycopy(childDeltas, 0, childDeltas = new AbstractDataTreeNode[childDeltaMax = childDeltaMax * 2 + 1], 0, numChildDeltas);
258+
}
253259
}
254260
childDeltas[numChildDeltas++] = new DeletedNode(oldNodes[oldIndex++].name);
255261
}
256262
while (newIndex < newNodes.length) {
257263
if (numChildDeltas >= childDeltaMax) {
258-
if (childDeltas == null)
264+
if (childDeltas == null) {
259265
childDeltas = new AbstractDataTreeNode[childDeltaMax = 5];
260-
else
266+
} else {
261267
System.arraycopy(childDeltas, 0, childDeltas = new AbstractDataTreeNode[childDeltaMax = childDeltaMax * 2 + 1], 0, numChildDeltas);
268+
}
262269
}
263270
childDeltas[numChildDeltas++] = newNodes[newIndex++];
264271
}
@@ -346,8 +353,9 @@ public void storeStrings(StringPool set) {
346353
super.storeStrings(set);
347354
//copy data for thread safety
348355
Object o = data;
349-
if (o instanceof IStringPoolParticipant)
356+
if (o instanceof IStringPoolParticipant) {
350357
((IStringPoolParticipant) o).shareStrings(set);
358+
}
351359
}
352360

353361
@Override

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DeletedNode.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ public class DeletedNode extends AbstractDataTreeNode {
3636
*/
3737
@Override
3838
AbstractDataTreeNode asBackwardDelta(DeltaDataTree myTree, DeltaDataTree parentTree, IPath key) {
39-
if (parentTree.includes(key))
39+
if (parentTree.includes(key)) {
4040
return parentTree.copyCompleteSubtree(key);
41+
}
4142
return this;
4243
}
4344

@@ -66,8 +67,9 @@ AbstractDataTreeNode compareWithParent(IPath key, DeltaDataTree parent, ICompara
6667
* be a corresponding node in the parent. Deleted nodes can live
6768
* in isolation.
6869
*/
69-
if (parent.includes(key))
70+
if (parent.includes(key)) {
7071
return convertToRemovedComparisonNode(parent.copyCompleteSubtree(key), NodeComparison.K_REMOVED);
72+
}
7173
// Node doesn't exist in either tree. Return an empty comparison.
7274
// Empty comparisons are omitted from the delta.
7375
return new DataTreeNode(key.lastSegment(), new NodeComparison(null, null, 0, 0));
@@ -95,8 +97,9 @@ boolean isDeleted() {
9597
*/
9698
@Override
9799
AbstractDataTreeNode simplifyWithParent(IPath key, DeltaDataTree parent, IComparator comparer) {
98-
if (parent.includes(key))
100+
if (parent.includes(key)) {
99101
return this;
102+
}
100103
return new NoDataDeltaNode(name);
101104
}
102105

0 commit comments

Comments
 (0)