String (@NotNull PsiModifierListOwner owner, String annotationFqName) { Set<String> annotationNames = Collections.singleton(annotationFqName); boolean nestedClass = owner instanceof PsiClass && ((PsiClass)owner).getContainingClass() != null; PsiAnnotation element = nestedClass ? AnnotationUtil.findAnnotation(owner, annotationNames) : AnnotationUtil.findAnnotationInHierarchy(owner, annotationNames); final UAnnotation annotation = UastContextKt.toUElement(element, UAnnotation.class); if (annotation != null) { UExpression value = annotation.findAttributeValue(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME); if (value != null) { final Project project = owner.getProject(); final Object constantValue = value.evaluate(); if (constantValue instanceof String path) { if (path.contains(TestFrameworkConstants.CONTENT_ROOT_VARIABLE)) { final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final VirtualFile file = owner.getContainingFile().getVirtualFile(); if (file == null) { return null; } final VirtualFile contentRoot = fileIndex.getContentRootForFile(file); if (contentRoot == null) return null; path = path.replace(TestFrameworkConstants.CONTENT_ROOT_VARIABLE, contentRoot.getPath()); } if (path.contains(TestFrameworkConstants.PROJECT_ROOT_VARIABLE)) { String baseDir = project.getBasePath(); if (baseDir == null) { return null; } path = path.replace(TestFrameworkConstants.PROJECT_ROOT_VARIABLE, baseDir); } return path; } } } return null; }