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() {
45
45
46
46
if (psiElementHandler.isCreateTestActionAvailable(element)) {
47
47
val srcClass = psiElementHandler.containingClass(element) ? : return null
48
+ val srcSourceRoot = srcClass.getSourceRoot() ? : return null
48
49
val srcMethods = TestIntegrationUtils .extractClassMethods(srcClass, false )
49
50
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
+
50
60
return Pair (setOf (srcClass), focusedMethod)
51
61
}
52
62
} else {
You can’t perform that action at this time.
0 commit comments