List<TasksToRun> (@NotNull VirtualFile source, @NotNull Project project) { String sourcePath = source.getPath(); ProjectFileIndex projectFileIndex = ProjectFileIndex.getInstance(project); Module module = ReadAction.compute(() -> projectFileIndex.getModuleForFile(source)); if (module == null) return Collections.emptyList(); List<TasksToRun> testTasks = new ArrayList<>(); for (GradleTestTasksProvider provider : GradleTestTasksProvider.EP_NAME.getExtensions()) { List<String> tasks = provider.getTasks(module, source); if (!ContainerUtil.isEmpty(tasks)) { String testName = StringUtil.join(tasks, " "); testTasks.add(new TasksToRun.Impl(testName, tasks)); } } GradleModuleData gradleModuleData = CachedModuleDataFinder.getGradleModuleData(module); if (gradleModuleData == null) return testTasks; for (TestData testData : gradleModuleData.findAll(ProjectKeys.TEST)) { Set<String> sourceFolders = testData.getSourceFolders(); for (String sourceFolder : sourceFolders) { if (FileUtil.isAncestor(sourceFolder, sourcePath, false)) { String testTaskSimpleName = testData.getTestName(); List<String> tasks = new SmartList<>(gradleModuleData.getTaskPathOfSimpleTaskName(testTaskSimpleName)); testTasks.add(new TasksToRun.Impl(testTaskSimpleName, tasks)); } } } return testTasks; }