use navigation element to resolve KDoc links, so that we have correct context when resolving links in the documentation of library elements
#KT-10654 Fixed
This commit is contained in:
@@ -53,13 +53,10 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getDocumentationElementForLink(psiManager: PsiManager, link: String, context: PsiElement?): PsiElement? {
|
override fun getDocumentationElementForLink(psiManager: PsiManager, link: String, context: PsiElement?): PsiElement? {
|
||||||
if (context !is KtElement) {
|
val navElement = context?.navigationElement as? KtElement ?: return null
|
||||||
return null
|
val bindingContext = navElement.analyze(BodyResolveMode.PARTIAL)
|
||||||
}
|
val contextDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, navElement] ?: return null
|
||||||
|
val descriptors = resolveKDocLink(bindingContext, navElement.getResolutionFacade(),
|
||||||
val bindingContext = context.analyze(BodyResolveMode.PARTIAL)
|
|
||||||
val contextDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, context] ?: return null
|
|
||||||
val descriptors = resolveKDocLink(bindingContext, context.getResolutionFacade(),
|
|
||||||
contextDescriptor, null, StringUtil.split(link, ","))
|
contextDescriptor, null, StringUtil.split(link, ","))
|
||||||
val target = descriptors.firstOrNull() ?: return null
|
val target = descriptors.firstOrNull() ?: return null
|
||||||
return DescriptorToSourceUtilsIde.getAnyDeclaration(psiManager.project, target)
|
return DescriptorToSourceUtilsIde.getAnyDeclaration(psiManager.project, target)
|
||||||
|
|||||||
Reference in New Issue
Block a user