How to filter PsiClass from test folder

Hi I'm building plugin, and I try to get All class that inherits specific interface/class, Everything is fine excpet that I want to exclude from search files from test folders,I can't find solution for this, Can anyone help me !?
My actual code look like this:

  • final Project project = e.getData(PlatformDataKeys.PROJECT);
    SearchScope searchScope = GlobalSearchScope.projectScope(project);
    PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass("eu.common.MyInterface", GlobalSearchScope.projectScope(project));
    Query<PsiClass> query =, searchScope, true);
    final StringBuilder stringBuilder = new StringBuilder();
    query.forEach(new Processor<PsiClass>()
        public boolean process(PsiClass psiClass)
            //here are classes from src na test folders
            return true;
    Comment actions Permalink

    I found solution with help

    boolean isInTest = ProjectFileIndex.SERVICE.getInstance(project).isInTestSourceContent(psiClass.getContainingFile().getVirtualFile());

    Please sign in to leave a comment.