mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
optimize imports: leave on demand imports untouched when no corresponding dirs can be found in the resolve scope (IDEA-82944) [peter]
(cherry picked from commit 61c42a9b1cb1fa712db584b8df5bc707cf4fb7ea)
This commit is contained in:
@@ -104,10 +104,17 @@ public class OptimizeImportsRefactoringHelper implements RefactoringHelper<Set<P
|
||||
if (importStatement != null && importStatement.isValid()) {
|
||||
final PsiJavaCodeReferenceElement ref = importStatement.getImportReference();
|
||||
//Do not remove non-resolving refs
|
||||
if (ref == null || ref.resolve() == null) {
|
||||
if (ref == null) {
|
||||
continue;
|
||||
}
|
||||
final PsiElement resolve = ref.resolve();
|
||||
if (resolve == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (resolve instanceof PsiPackage && ((PsiPackage)resolve).getDirectories(ref.getResolveScope()).length == 0) {
|
||||
continue;
|
||||
}
|
||||
importStatement.delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user