Best way to visit all classes

I was wondering about what is the most effective way to visit all the classes in a module.

Any ideas ?

1 comment
Comment actions Permalink

For future reference, here's what i did:

basePackage.accept(new LocalClassVisitor(_module) {
public void visitClass(PsiClass aClass) {
// whatever

public abstract class LocalClassVisitor extends PsiRecursiveElementVisitor {
private Module _module;

protected LocalClassVisitor(Module module) {
_module = module;

public void visitPackage(PsiPackage aPackage) {
PsiPackage[] subPackages = aPackage.getSubPackages(GlobalSearchScope.moduleRuntimeScope(_module, false));

for (PsiPackage subPackage : subPackages)

PsiClass[] classes = aPackage.getClasses(GlobalSearchScope.moduleRuntimeScope(_module, false));

for (PsiClass clazz : classes)

public abstract void visitClass(PsiClass aClass);


Please sign in to leave a comment.