Reports calls to Collections.sort(list, comparator) which could be replaced with list.sort(comparator). Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>tags/V1_9_7M1
@@ -291,7 +291,7 @@ public class LstBuildConfigManager implements BuildConfigManager { | |||
private void sortModel(BuildConfigNode node, Comparator<BuildConfigNode> comparator) { | |||
if (node == null || node.getChildren() == null) | |||
return; | |||
Collections.sort(node.getChildren(), comparator); | |||
node.getChildren().sort(comparator); | |||
for (BuildConfigNode nextNode : node.getChildren()) { | |||
if (nextNode != null) | |||
sortModel(nextNode, comparator); |
@@ -196,7 +196,7 @@ public class TreeStructureViewBuilder { | |||
private void sortView(IStructureViewNode node, Comparator<IStructureViewNode> comparator) { | |||
if (node == null || node.getChildren() == null) return; | |||
Collections.sort(node.getChildren(), comparator); | |||
node.getChildren().sort(comparator); | |||
for (Object o : node.getChildren()) { | |||
IStructureViewNode nextNode = (IStructureViewNode) o; | |||
if (nextNode != null) sortView(nextNode, comparator); |
@@ -509,7 +509,7 @@ public class ClassGen extends Modifiers implements Cloneable { | |||
relevantFields.add(field); | |||
} | |||
} | |||
Collections.sort(relevantFields, new FieldComparator()); | |||
relevantFields.sort(new FieldComparator()); | |||
int relevantFlags = Constants.ACC_PUBLIC | Constants.ACC_PRIVATE | Constants.ACC_PROTECTED | Constants.ACC_STATIC | |||
| Constants.ACC_FINAL | Constants.ACC_VOLATILE | Constants.ACC_TRANSIENT; | |||
for (Field f : relevantFields) { | |||
@@ -534,8 +534,8 @@ public class ClassGen extends Modifiers implements Cloneable { | |||
relevantMethods.add(m); | |||
} | |||
} | |||
Collections.sort(relevantCtors, new ConstructorComparator()); | |||
Collections.sort(relevantMethods, new MethodComparator()); | |||
relevantCtors.sort(new ConstructorComparator()); | |||
relevantMethods.sort(new MethodComparator()); | |||
// 5. If a class initializer exists, write out the following: | |||
// 1. The name of the method, <clinit>. |
@@ -421,7 +421,7 @@ class Samples { | |||
List<Sample> getSortedSamples(Comparator<Sample> comparer) { | |||
ArrayList<Sample> result = new ArrayList<>(); | |||
result.addAll(samples); | |||
Collections.sort(result, comparer); | |||
result.sort(comparer); | |||
return result; | |||
} | |||
} |
@@ -416,7 +416,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { | |||
List<LocalVariable> l = new ArrayList<>(); | |||
LocalVariable lv[] = lvt.getLocalVariableTable(); | |||
Collections.addAll(l, lv); | |||
Collections.sort(l, new MyComparator()); | |||
l.sort(new MyComparator()); | |||
return l; | |||
} | |||
@@ -452,7 +452,7 @@ public class Diffs { | |||
if (LangUtil.isEmpty(skip)) { | |||
sink.addAll(Arrays.asList(source)); | |||
Collections.sort(sink, MESSAGE_LINEKIND); | |||
sink.sort(MESSAGE_LINEKIND); | |||
return sink; | |||
} | |||
for (IMessage message : source) { | |||
@@ -467,7 +467,7 @@ public class Diffs { | |||
sink.add(message); | |||
} | |||
} | |||
Collections.sort(sink, MESSAGE_LINEKIND); | |||
sink.sort(MESSAGE_LINEKIND); | |||
return sink; | |||
} | |||
@@ -941,11 +941,11 @@ public class LangUtil { | |||
ArrayList expected = new ArrayList(); | |||
expected.addAll(expectedListIn); | |||
Collections.sort(expected, comparator); | |||
expected.sort(comparator); | |||
ArrayList actual = new ArrayList(); | |||
actual.addAll(actualListIn); | |||
Collections.sort(actual, comparator); | |||
actual.sort(comparator); | |||
Iterator actualIter = actual.iterator(); | |||
Object act = null; | |||
@@ -2170,8 +2170,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa | |||
assertFalse(typeA.isMissing()); | |||
List<ResolvedMember> viaIteratorList = getThemAll(typeA.getMethods(wantGenerics, true)); | |||
List<ResolvedMember> directlyList = typeA.getMethodsWithoutIterator(true, true, wantGenerics); | |||
Collections.sort(viaIteratorList, new ResolvedMemberComparator()); | |||
Collections.sort(directlyList, new ResolvedMemberComparator()); | |||
viaIteratorList.sort(new ResolvedMemberComparator()); | |||
directlyList.sort(new ResolvedMemberComparator()); | |||
compare(viaIteratorList, directlyList, name); | |||
// System.out.println(toString(viaIteratorList, directlyList, genericsAware)); | |||
} |
@@ -1785,7 +1785,7 @@ public class AtAjAttributes { | |||
} | |||
// sort by index | |||
Collections.sort(arguments, new Comparator<MethodArgument>() { | |||
arguments.sort(new Comparator<MethodArgument>() { | |||
public int compare(MethodArgument mo, MethodArgument mo1) { | |||
if (mo.indexOnStack == mo1.indexOnStack) { | |||
return 0; |
@@ -2593,7 +2593,7 @@ class BcelClassWeaver implements IClassWeaver { | |||
} | |||
private void weaveInAddedMethods() { | |||
Collections.sort(addedLazyMethodGens, new Comparator<LazyMethodGen>() { | |||
addedLazyMethodGens.sort(new Comparator<LazyMethodGen>() { | |||
public int compare(LazyMethodGen aa, LazyMethodGen bb) { | |||
int i = aa.getName().compareTo(bb.getName()); | |||
if (i != 0) { |
@@ -548,7 +548,7 @@ public class BcelWeaver { | |||
// this code may need | |||
// a bit of alteration... | |||
Collections.sort(shadowMungerList, new Comparator<ShadowMunger>() { | |||
shadowMungerList.sort(new Comparator<ShadowMunger>() { | |||
public int compare(ShadowMunger sm1, ShadowMunger sm2) { | |||
if (sm1.getSourceLocation() == null) { | |||
return (sm2.getSourceLocation() == null ? 0 : 1); |
@@ -1260,7 +1260,7 @@ public final class LazyClassGen { | |||
lists.add(list); | |||
List<Map.Entry<BcelShadow, Field>> entries = new ArrayList<>(tjpFields.entrySet()); | |||
Collections.sort(entries, new Comparator<Map.Entry<BcelShadow, Field>>() { | |||
entries.sort(new Comparator<Map.Entry<BcelShadow, Field>>() { | |||
@Override | |||
public int compare(Map.Entry<BcelShadow, Field> a, Map.Entry<BcelShadow, Field> b) { | |||
return (a.getValue()).getName().compareTo((b.getValue()).getName()); |