use of com.intellij.codeInspection.reference.RefJavaVisitor in project intellij-community by JetBrains.
the class ClassWithTooManyDependenciesInspection method runInspection.
@Override
public void runInspection(@NotNull AnalysisScope scope, @NotNull final InspectionManager inspectionManager, @NotNull GlobalInspectionContext globalInspectionContext, @NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
final RefManager refManager = globalInspectionContext.getRefManager();
refManager.iterate(new RefJavaVisitor() {
@Override
public void visitClass(@NotNull RefClass refClass) {
super.visitClass(refClass);
if (refClass.getOwner() instanceof RefClass) {
return;
}
final Set<RefClass> dependencies = DependencyUtils.calculateDependenciesForClass(refClass);
final int numDependencies = dependencies.size();
if (numDependencies <= limit) {
return;
}
final String errorString = InspectionGadgetsBundle.message("class.with.too.many.dependencies.problem.descriptor", refClass.getName(), numDependencies, limit);
final CommonProblemDescriptor[] descriptors = { inspectionManager.createProblemDescriptor(errorString) };
problemDescriptionsProcessor.addProblemElement(refClass, descriptors);
}
});
}
Aggregations