void (@NotNull List<PsiClass> classes, @NotNull PsiFile file) { Project project = file.getProject(); DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project); for (int i = classes.size() - 1; i >= 0; i--) { PsiClass psiClass = classes.get(i); PsiFile targetFile = psiClass.getContainingFile(); if (targetFile == null) continue; DependencyRule[] violated = validationManager.getViolatorDependencyRules(file, targetFile); // remove class with violated dependency except the only remaining if (violated.length != 0 && (i!=0 || classes.size()>1)) { classes.remove(i); } } }