diff --git a/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java b/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java index cb13140..3bc5383 100644 --- a/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java +++ b/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.jetbrains.java.decompiler.main.TextBuffer; import org.jetbrains.java.decompiler.struct.StructContext; import java.util.*; -import java.util.Map.Entry; +import java.util.stream.Collectors; public class ImportCollector { private static final String JAVA_LANG_PACKAGE = "java.lang"; @@ -124,26 +124,17 @@ public class ImportCollector { } private List packImports() { - List> lst = new ArrayList<>(mapSimpleNames.entrySet()); - - Collections.sort(lst, (par0, par1) -> { - int res = par0.getValue().compareTo(par1.getValue()); - if (res == 0) { - res = par0.getKey().compareTo(par1.getKey()); - } - return res; - }); - - List res = new ArrayList<>(); - for (Entry ent : lst) { - // exclude a current class or one of the nested ones, java.lang and empty packages - if (!setNotImportedNames.contains(ent.getKey()) && - !JAVA_LANG_PACKAGE.equals(ent.getValue()) && - !ent.getValue().isEmpty()) { - res.add(ent.getValue() + "." + ent.getKey()); - } - } - - return res; + return mapSimpleNames.entrySet().stream() + .filter(ent -> + // exclude the current class or one of the nested ones + // empty, java.lang and the current packages + !setNotImportedNames.contains(ent.getKey()) && + !ent.getValue().isEmpty() && + !JAVA_LANG_PACKAGE.equals(ent.getValue()) && + !ent.getValue().equals(currentPackagePoint) + ) + .sorted(Map.Entry.comparingByValue().thenComparing(Map.Entry.comparingByKey())) + .map(ent -> ent.getValue() + "." + ent.getKey()) + .collect(Collectors.toList()); } } \ No newline at end of file diff --git a/testData/results/InvalidMethodSignature.dec b/testData/results/InvalidMethodSignature.dec index 7b4f8c5..e2a15b3 100644 --- a/testData/results/InvalidMethodSignature.dec +++ b/testData/results/InvalidMethodSignature.dec @@ -4,7 +4,6 @@ import a.a.a.a.a.k; import a.a.a.a.c.c; import a.a.a.a.c.j; import a.a.a.a.e.bg; -import a.a.a.a.e.f.b; import java.io.File; class i implements bg { @@ -27,30 +26,30 @@ class i implements bg { class 'a/a/a/a/e/f/i' { method ' (La/a/a/a/e/f/b;La/a/a/a/c/j;)V' { - 2 14 - 7 15 - e 16 + 2 13 + 7 14 + e 15 } method 'a (La/a/a/a/c/c;La/a/a/a/a/k;Z)V' { - 1 19 - 4 19 - a 19 - f 19 - 12 20 - 15 20 - 1a 20 - 20 21 + 1 18 + 4 18 + a 18 + f 18 + 12 19 + 15 19 + 1a 19 + 20 20 } method 'a (La/a/a/a/c/b;)V' { - 0 24 + 0 23 } } Lines mapping: -0 <-> 25 -1 <-> 15 -2 <-> 20 -3 <-> 21 -4 <-> 22 +0 <-> 24 +1 <-> 14 +2 <-> 19 +3 <-> 20 +4 <-> 21