File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,18 @@ class GenerateTestsAction : AnAction() {
4545
4646 if (psiElementHandler.isCreateTestActionAvailable(element)) {
4747 val srcClass = psiElementHandler.containingClass(element) ? : return null
48+ val srcSourceRoot = srcClass.getSourceRoot() ? : return null
4849 val srcMethods = TestIntegrationUtils .extractClassMethods(srcClass, false )
4950 val focusedMethod = focusedMethodOrNull(element, srcMethods, psiElementHandler)
51+
52+ val module = ModuleUtil .findModuleForFile(srcSourceRoot, project) ? : return null
53+ val matchingRoot = ModuleRootManager .getInstance(module).contentEntries
54+ .flatMap { entry -> entry.sourceFolders.toList() }
55+ .singleOrNull { folder -> folder.file == srcSourceRoot }
56+ if (matchingRoot == null || matchingRoot.rootType.isForTests) {
57+ return null
58+ }
59+
5060 return Pair (setOf (srcClass), focusedMethod)
5161 }
5262 } else {
You can’t perform that action at this time.
0 commit comments