int (final @NotNull VirtualFile file1, final @NotNull VirtualFile file2) { final int[] result = {0}; ContainerUtil.process(myScopes, scope -> { // ignore irrelevant scopes - they don't know anything about the files if (!scope.contains(file1) || !scope.contains(file2)) return true; int cmp = scope.compare(file1, file2); if (result[0] == 0) { result[0] = cmp; return true; } if (cmp == 0) { return true; } if (result[0] > 0 == cmp > 0) { return true; } // scopes disagree about the order - abort the voting result[0] = 0; return false; }); return result[0]; }