List<PsiClass> (@NotNull PsiElement element, PsiClass @NotNull [] classes) { DependencyValidationManager dependencyValidationManager = DependencyValidationManager.getInstance(element.getProject()); PsiFile fromFile = element.getContainingFile(); List<PsiClass> result = new ArrayList<>(); for (PsiClass psiClass : classes) { PsiFile containingFile = psiClass.getContainingFile(); if (containingFile != null && dependencyValidationManager.getViolatorDependencyRule(fromFile, containingFile) == null) { result.add(psiClass); } } return result; }