diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-15 16:13:00 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-15 16:13:00 +0200 |
commit | efa2e5ce8c9cc2d20ab7479d1caa4a2ae1de6e8a (patch) | |
tree | 7be97c63260610ad409b9dbd889fbe9bfaf5b434 | |
parent | 7824e7d3045b9db278a96a21e69110976767b32e (diff) | |
download | aspectj-efa2e5ce8c9cc2d20ab7479d1caa4a2ae1de6e8a.tar.gz aspectj-efa2e5ce8c9cc2d20ab7479d1caa4a2ae1de6e8a.zip |
Collections.sort() can be replaced with List.sort()
Reports calls to Collections.sort(list, comparator) which could be replaced with list.sort(comparator).
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
12 files changed, 17 insertions, 17 deletions
diff --git a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java index cde164cc1..20db17581 100644 --- a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java @@ -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); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java index 23f999ac8..a8a07ee34 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java @@ -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); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java index 943b77f6e..371013997 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java @@ -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>. diff --git a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java index ca041b33d..ce7f2ce27 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java @@ -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; } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java index 81e2616ea..dbb5557cc 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java @@ -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; } diff --git a/testing/src/test/java/org/aspectj/testing/util/Diffs.java b/testing/src/test/java/org/aspectj/testing/util/Diffs.java index c9a58e99f..e95ab3184 100644 --- a/testing/src/test/java/org/aspectj/testing/util/Diffs.java +++ b/testing/src/test/java/org/aspectj/testing/util/Diffs.java @@ -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; } diff --git a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java index ddf3a832a..23385db3a 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java @@ -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; diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 30793c396..49663211f 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -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)); } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java index b91496ea7..96222fba2 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -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; diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java index bbad8ed6a..06735b523 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -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) { diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java index a6809f26f..b80080ec1 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java @@ -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); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java index 46f0958e6..f2e61c565 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java @@ -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()); |