Boolean (@NotNull String mainClassName, @NotNull Module module) { final PsiClass psiClass = JavaExecutionUtil.findMainClass(module, mainClassName); if (psiClass == null) { return null; } final PsiFile psiFile = psiClass.getContainingFile(); if (psiFile == null) return null; final VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile == null) return null; Module classModule = psiClass.isValid() ? ModuleUtilCore.findModuleForPsiElement(psiClass) : null; if (classModule == null) classModule = module; final ModuleRootManager rootManager = ModuleRootManager.getInstance(classModule); final ModuleFileIndex fileIndex = rootManager.getFileIndex(); if (fileIndex.isInSourceContent(virtualFile)) { return !fileIndex.isInTestSourceContent(virtualFile); } // the mainClass is located in libraries for (OrderEntry entry : fileIndex.getOrderEntriesForFile(virtualFile)) { if (entry instanceof ExportableOrderEntry && ((ExportableOrderEntry)entry).getScope() == DependencyScope.TEST) { return false; } } if (rootManager.getSourceRoots(false).length == 0) { return false; // there are no 'non-test' sources in the module } return true; }