KT-24788: Fix exceptions in offline inspections
When there is severe memory load SLRUCache inside getResolutionFacade may cause double computation of ResolutionFacade, thus will cause moduleDescriptor to be recreated, and it will be different from one that is stored in declarationDescriptor Newer resolutionFacade will actually not built for old moduleDescriptor and will cause exception #KT-24788 fixed
This commit is contained in:
@@ -26,18 +26,23 @@ import org.jetbrains.kotlin.kdoc.psi.impl.KDocName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
class KDocReference(element: KDocName): KtMultiReference<KDocName>(element) {
|
||||
class KDocReference(element: KDocName) : KtMultiReference<KDocName>(element) {
|
||||
override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {
|
||||
val declaration = element.getContainingDoc().getOwner() ?: return arrayListOf()
|
||||
val declarationDescriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration] ?: return arrayListOf()
|
||||
val resolutionFacade = element.getResolutionFacade()
|
||||
val correctContext = resolutionFacade.analyze(declaration, BodyResolveMode.PARTIAL)
|
||||
val declarationDescriptor = correctContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration] ?: return arrayListOf()
|
||||
|
||||
val kdocLink = element.getStrictParentOfType<KDocLink>()!!
|
||||
return resolveKDocLink(context,
|
||||
element.getResolutionFacade(),
|
||||
declarationDescriptor,
|
||||
kdocLink.getTagIfSubject(),
|
||||
element.getQualifiedName())
|
||||
return resolveKDocLink(
|
||||
correctContext,
|
||||
resolutionFacade,
|
||||
declarationDescriptor,
|
||||
kdocLink.getTagIfSubject(),
|
||||
element.getQualifiedName()
|
||||
)
|
||||
}
|
||||
|
||||
override fun getRangeInElement(): TextRange = element.getNameTextRange()
|
||||
|
||||
Reference in New Issue
Block a user