ExcludePolicyDescriptor (@NotNull DirectoryIndexExcludePolicy policy, @NotNull Set<? extends Sdk> sdks, @NotNull Set<? extends VirtualFile> sdkRoots) { String[] excludedRootUrls = policy.getExcludeUrlsForProject(); if (excludedRootUrls.length == 0) excludedRootUrls = ArrayUtil.EMPTY_STRING_ARRAY; Function<Sdk, List<VirtualFile>> strategy = policy.getExcludeSdkRootsStrategy(); Set<VirtualFile> excludedFromSdkRoots; if (strategy == null) { excludedFromSdkRoots = Collections.emptySet(); } else { Collection<VirtualFile> excludedFromSdk = new ArrayList<>(); for (Sdk sdk : sdks) { List<VirtualFile> excluded = strategy.fun(sdk); for (VirtualFile file : excluded) { if (!sdkRoots.contains(file)) { excludedFromSdk.add(file); } } } excludedFromSdkRoots = Set.copyOf(excludedFromSdk); } return new ExcludePolicyDescriptor(policy.getClass(), excludedRootUrls, excludedFromSdkRoots); }