{"record":{"id":"28b7f3c87f2e1f4d","repo":"JetBrains/intellij-community","slug":"no-java-sources-found-in-the-selected-scope","errorCode":null,"errorMessage":"No Java sources found in the selected scope","messagePattern":"No Java sources found in the selected scope","errorType":"exception","errorClass":"CantRunException","httpStatus":null,"severity":"error","filePath":"java/java-impl/src/com/intellij/javadoc/JavadocGeneratorRunProfile.java","lineNumber":250,"sourceCode":"          parameters.add(\"-link\");\n          parameters.add(url);\n        }\n      }\n\n      if (myConfiguration.OUTPUT_DIRECTORY != null) {\n        parameters.add(\"-d\");\n        parameters.add(myConfiguration.OUTPUT_DIRECTORY.replace('/', File.separatorChar));\n      }\n\n      Set<Module> modules = new LinkedHashSet<>();\n      Set<VirtualFile> sources = new HashSet<>();\n      Runnable r = () -> myGenerationOptions.accept(new MyContentIterator(myProject, modules, sources));\n      String title = JavaBundle.message(\"javadoc.generate.sources.progress\");\n      if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(r, title, true, myProject)) {\n        return;\n      }\n      if (sources.isEmpty()) {\n        throw new CantRunException(JavaBundle.message(\"javadoc.generate.no.classes.in.selected.packages.error\"));\n      }\n\n      Set<Module> modulesWithoutDescriptor = new HashSet<>(modules);\n      Map<Module, VirtualFile> moduleDescriptors = new HashMap<>();\n      boolean hasJavaModules = false;\n      for (VirtualFile source : sources) {\n        if (!PsiJavaModule.MODULE_INFO_FILE.equals(source.getName())) {\n          continue;\n        }\n        hasJavaModules = true;\n        Module module = ModuleUtilCore.findModuleForFile(source, myProject);\n        if (module != null) {\n          moduleDescriptors.put(module, source);\n          modulesWithoutDescriptor.remove(module);\n        }\n      }\n      if (hasJavaModules && !modulesWithoutDescriptor.isEmpty()) {\n        // So far we can't generate javadoc for each module independently as we have to merge the results into common files,","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl/src/com/intellij/javadoc/JavadocGeneratorRunProfile.java#L232-L268","documentation":"The generator iterates the selected scope (custom scope, package, or 'whole project') collecting Java source files; if the collected 'sources' set is empty after the scan, CantRunException('No Java sources found in the selected scope') stops the run. The iteration itself is wrapped in a modal progress; an empty result means the chosen scope simply contains no compilable Java files reachable as source roots.","triggerScenarios":"Invoking Tools | Generate JavaDoc with a scope selection (e.g. a custom scope or package) that matches no Java files, or when the project's Java directories are not marked as Sources Roots so the content iterator never yields them.","commonSituations":"Running generation from a view where the selected package contains only resources or Kotlin; newly opened projects whose source roots are unmarked; custom scopes with overly restrictive patterns; generated-code-only modules excluded from the scope.","solutions":["Re-check the scope combobox in the Generate JavaDoc dialog — pick a package/scope that actually contains .java files.","Mark Java directories as Sources Root (right-click | Mark Directory as | Sources Root) so they are traversable.","For mixed-language projects, confirm the module really has Java sources; Kotlin-only scopes will always fail here."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before generation, confirm the scope yields Java sources\nSet<VirtualFile> javaSources = collectJavaSources(project, scope);\nif (javaSources.isEmpty()) { notify(\"Selected scope contains no Java sources\"); return; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark Java directories as Sources Root","Double-check the scope/package selection in the Generate JavaDoc dialog","Remember Kotlin-only scopes produce no Java sources"],"tags":["javadoc","scope","source-roots","ide","validation"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}