IDEA-166101 Imports Added for Classes in Same Package
This commit is contained in:
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 org.jetbrains.java.decompiler.struct.StructContext;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ImportCollector {
|
public class ImportCollector {
|
||||||
private static final String JAVA_LANG_PACKAGE = "java.lang";
|
private static final String JAVA_LANG_PACKAGE = "java.lang";
|
||||||
@@ -124,26 +124,17 @@ public class ImportCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<String> packImports() {
|
private List<String> packImports() {
|
||||||
List<Entry<String, String>> lst = new ArrayList<>(mapSimpleNames.entrySet());
|
return mapSimpleNames.entrySet().stream()
|
||||||
|
.filter(ent ->
|
||||||
Collections.sort(lst, (par0, par1) -> {
|
// exclude the current class or one of the nested ones
|
||||||
int res = par0.getValue().compareTo(par1.getValue());
|
// empty, java.lang and the current packages
|
||||||
if (res == 0) {
|
!setNotImportedNames.contains(ent.getKey()) &&
|
||||||
res = par0.getKey().compareTo(par1.getKey());
|
!ent.getValue().isEmpty() &&
|
||||||
}
|
!JAVA_LANG_PACKAGE.equals(ent.getValue()) &&
|
||||||
return res;
|
!ent.getValue().equals(currentPackagePoint)
|
||||||
});
|
)
|
||||||
|
.sorted(Map.Entry.<String, String>comparingByValue().thenComparing(Map.Entry.comparingByKey()))
|
||||||
List<String> res = new ArrayList<>();
|
.map(ent -> ent.getValue() + "." + ent.getKey())
|
||||||
for (Entry<String, String> ent : lst) {
|
.collect(Collectors.toList());
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,6 @@ import a.a.a.a.a.k;
|
|||||||
import a.a.a.a.c.c;
|
import a.a.a.a.c.c;
|
||||||
import a.a.a.a.c.j;
|
import a.a.a.a.c.j;
|
||||||
import a.a.a.a.e.bg;
|
import a.a.a.a.e.bg;
|
||||||
import a.a.a.a.e.f.b;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
class i implements bg {
|
class i implements bg {
|
||||||
@@ -27,30 +26,30 @@ class i implements bg {
|
|||||||
|
|
||||||
class 'a/a/a/a/e/f/i' {
|
class 'a/a/a/a/e/f/i' {
|
||||||
method '<init> (La/a/a/a/e/f/b;La/a/a/a/c/j;)V' {
|
method '<init> (La/a/a/a/e/f/b;La/a/a/a/c/j;)V' {
|
||||||
2 14
|
2 13
|
||||||
7 15
|
7 14
|
||||||
e 16
|
e 15
|
||||||
}
|
}
|
||||||
|
|
||||||
method 'a (La/a/a/a/c/c;La/a/a/a/a/k;Z)V' {
|
method 'a (La/a/a/a/c/c;La/a/a/a/a/k;Z)V' {
|
||||||
1 19
|
1 18
|
||||||
4 19
|
4 18
|
||||||
a 19
|
a 18
|
||||||
f 19
|
f 18
|
||||||
12 20
|
12 19
|
||||||
15 20
|
15 19
|
||||||
1a 20
|
1a 19
|
||||||
20 21
|
20 20
|
||||||
}
|
}
|
||||||
|
|
||||||
method 'a (La/a/a/a/c/b;)V' {
|
method 'a (La/a/a/a/c/b;)V' {
|
||||||
0 24
|
0 23
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Lines mapping:
|
Lines mapping:
|
||||||
0 <-> 25
|
0 <-> 24
|
||||||
1 <-> 15
|
1 <-> 14
|
||||||
2 <-> 20
|
2 <-> 19
|
||||||
3 <-> 21
|
3 <-> 20
|
||||||
4 <-> 22
|
4 <-> 21
|
||||||
|
|||||||
Reference in New Issue
Block a user