mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
run test on unnamed element in editor: choose element at caret in addition to data context retrieval (IDEA-159387)
This commit is contained in:
+12
-4
@@ -165,11 +165,12 @@ public abstract class AbstractPatternBasedConfigurationProducer<T extends Module
|
||||
}
|
||||
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 (allCarets.size() > 1) {
|
||||
final PsiFile editorFile = CommonDataKeys.PSI_FILE.getData(dataContext);
|
||||
if (editorFile != null) {
|
||||
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));
|
||||
@@ -178,9 +179,16 @@ public abstract class AbstractPatternBasedConfigurationProducer<T extends Module
|
||||
return collectTestMembers(methods.toArray(PsiElement.EMPTY_ARRAY), checkAbstract, checkIsTest, processor, classes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
element = editorFile.findElementAt(editor.getCaretModel().getOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user