boolean (PsiElement[] elements, boolean fromUpdate) { Set<String> names = new HashSet<>(); for (PsiElement element : elements) { if (!(element instanceof PsiDirectory || element instanceof PsiFile)) return false; if (!element.isValid()) return false; if (element instanceof PsiCompiledFile) return false; String name = ((PsiFileSystemItem) element).getName(); if (names.contains(name)) { return false; } names.add(name); } if (fromUpdate) return elements.length > 0; PsiElement[] filteredElements = PsiTreeUtil.filterAncestors(elements); return filteredElements.length == elements.length; }