mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
[project model] ModuleUtilCore: drop sort from findModuleForPsiElement
GitOrigin-RevId: 421623fab558b2f9becb66bfdac5522bcd6530ab
This commit is contained in:
committed by
intellij-monorepo-bot
parent
48025c65b4
commit
06351d299b
@@ -105,22 +105,31 @@ public class ModuleUtilCore {
|
||||
return element.getUserData(KEY_MODULE);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileIndex.isInLibrary(vFile)) {
|
||||
List<OrderEntry> orderEntries = fileIndex.getOrderEntriesForFile(vFile);
|
||||
if (orderEntries.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (orderEntries.size() == 1) {
|
||||
return orderEntries.get(0).getOwnerModule();
|
||||
}
|
||||
Set<Module> modules = new HashSet<>();
|
||||
for (OrderEntry orderEntry : orderEntries) {
|
||||
modules.add(orderEntry.getOwnerModule());
|
||||
|
||||
Comparator<Module> comparator = ModuleManager.getInstance(project).moduleDependencyComparator();
|
||||
Iterator<OrderEntry> iterator = orderEntries.iterator();
|
||||
Module candidate = iterator.next().getOwnerModule();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Module next = iterator.next().getOwnerModule();
|
||||
if (comparator.compare(next, candidate) < 0) {
|
||||
candidate = next;
|
||||
}
|
||||
}
|
||||
Module[] candidates = modules.toArray(Module.EMPTY_ARRAY);
|
||||
Arrays.sort(candidates, ModuleManager.getInstance(project).moduleDependencyComparator());
|
||||
return candidates[0];
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
return fileIndex.getModuleForFile(vFile);
|
||||
}
|
||||
if (containingFile != null) {
|
||||
|
||||
Reference in New Issue
Block a user