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