boolean (DataContext dataContext, boolean checkAbstract, boolean checkIsTest, LinkedHashSet<? super String> classes, PsiElementProcessor.CollectElements<PsiElement> processor) { PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext); if (elements != null) { return collectTestMembers(elements, checkAbstract, checkIsTest, processor, classes); } else { final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); PsiElement element = null; if (editor != null) { final PsiFile editorFile = CommonDataKeys.PSI_FILE.getData(dataContext); final List<Caret> allCarets = editor.getCaretModel().getAllCarets(); if (editorFile != null) { if (allCarets.size() > 1) { final Set<PsiMethod> methods = new LinkedHashSet<>(); for (Caret caret : allCarets) { ContainerUtil .addIfNotNull(methods, PsiTreeUtil.getParentOfType(editorFile.findElementAt(caret.getOffset()), PsiMethod.class)); } if (!methods.isEmpty()) { return collectTestMembers(methods.toArray(PsiElement.EMPTY_ARRAY), checkAbstract, checkIsTest, processor, classes); } } else { element = editorFile.findElementAt(editor.getCaretModel().getOffset()); @NotNull TextRange range = editor.getCaretModel().getCurrentCaret().getSelectionRange(); if (!range.isEmpty()) { PsiClass psiClass = PsiTreeUtil.getParentOfType(editorFile.findElementAt(range.getStartOffset()), PsiClass.class); if (psiClass != null) { PsiMethod[] methodsInSelection = Arrays.stream(psiClass.getMethods()) .filter(method -> { TextRange methodTextRange = method.getTextRange(); return methodTextRange != null && range.contains(methodTextRange); }) .toArray(PsiMethod[]::new); if (methodsInSelection.length > 0) { return collectTestMembers(methodsInSelection, checkAbstract, checkIsTest, processor, classes); } } } } } } if (element == null) { element = CommonDataKeys.PSI_ELEMENT.getData(dataContext); } final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext); if (files != null) { Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project != null) { final PsiManager psiManager = PsiManager.getInstance(project); for (VirtualFile file : files) { final PsiFile psiFile = psiManager.findFile(file); if (psiFile instanceof PsiClassOwner) { PsiClass[] psiClasses = ((PsiClassOwner)psiFile).getClasses(); if (element != null) { for (PsiClass aClass : psiClasses) { if (PsiTreeUtil.isAncestor(aClass, element, false)) { psiClasses = new PsiClass[]{aClass}; break; } } } collectTestMembers(psiClasses, checkAbstract, checkIsTest, processor); for (PsiElement psiMember : processor.getCollection()) { String qName = ((PsiClass)psiMember).getQualifiedName(); if (qName != null) { classes.add(qName); } } } } return true; } } } return false; }