PlaceInfo (final Project project, String message) { int startIndex; int endIndex; if (message.startsWith(RUNNING_SUBSTRING)) { startIndex = RUNNING_SUBSTRING.length(); endIndex = message.length(); } else if (message.startsWith(TEST_SUBSTRING)) { startIndex = TEST_SUBSTRING.length(); if (message.endsWith(FAILED_SUBSTRING)) { endIndex = message.length() - FAILED_SUBSTRING.length(); } else if (message.endsWith(FAILED_SUBSTRING_2)) { endIndex = message.length() - FAILED_SUBSTRING_2.length(); } else { return null; } } else { return null; } if (endIndex < startIndex) return null; final String possibleTestClassName = message.substring(startIndex, endIndex); final PsiFile[] psiFile = new PsiFile[1]; final PsiManager psiManager = PsiManager.getInstance(project); ApplicationManager.getApplication().runReadAction(() -> { PsiClass psiClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(possibleTestClassName, GlobalSearchScope.allScope(project)); if (psiClass == null) return; PsiElement parent = psiClass.getParent(); if (parent instanceof PsiFile) { psiFile[0] = (PsiFile)parent; } }); if (psiFile[0] == null) return null; return new PlaceInfo(psiFile[0].getVirtualFile(), 1, 1, startIndex, endIndex - 1); }