List<String> (final PsiElement element) { List<String> urls = null; if (element instanceof PsiClass) { urls = findUrlForClass((PsiClass)element); } else if (element instanceof PsiField field) { PsiClass aClass = field.getContainingClass(); if (aClass != null) { urls = findUrlForClass(aClass); if (urls != null) { urls.replaceAll(url -> url + "#" + field.getName()); } } } else if (element instanceof PsiMethod method) { PsiClass aClass = method.getContainingClass(); if (aClass != null) { List<String> classUrls = findUrlForClass(aClass); if (classUrls != null) { urls = new SmartList<>(); final Set<String> signatures = getHtmlMethodSignatures(method, PsiUtil.getLanguageLevel(method)); for (String signature : signatures) { for (String classUrl : classUrls) { urls.add(classUrl + "#" + signature); } } } } } else if (element instanceof PsiPackage) { urls = findUrlForPackage((PsiPackage)element); } else if (element instanceof PsiDirectory) { PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(((PsiDirectory)element)); if (aPackage != null) { urls = findUrlForPackage(aPackage); } } if (urls == null || urls.isEmpty()) { return null; } else { urls.replaceAll(FileUtil::toSystemIndependentName); return urls; } }