diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KDocReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KDocReference.kt similarity index 93% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KDocReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KDocReference.kt index 3947b00f2ef..1d4f4ef5463 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KDocReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KDocReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -22,4 +22,4 @@ abstract class KDocReference(element: KDocName) : KtMultiReference(ele override fun getCanonicalText(): String = element.getNameText() override val resolvesByNames: Collection get() = listOf(Name.identifier(element.getNameText())) -} +} \ No newline at end of file diff --git a/compiler/psi/src/org/jetbrains/kotlin/idea/references/KotlinPsiReferenceProvider.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KotlinPsiReferenceProvider.kt new file mode 100644 index 00000000000..a23a9012ac1 --- /dev/null +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KotlinPsiReferenceProvider.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.references + +import com.intellij.openapi.components.ServiceManager +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiReference +import com.intellij.util.containers.MultiMap +import org.jetbrains.kotlin.psi.KtElement + +interface KotlinPsiReferenceProvider { + fun getReferencesByElement(element: PsiElement): Array +} + +interface KotlinReferenceProviderContributor { + fun registerReferenceProviders(registrar: KotlinPsiReferenceRegistrar) + + companion object { + fun getInstance(): KotlinReferenceProviderContributor = + ServiceManager.getService(KotlinReferenceProviderContributor::class.java) + } +} + + +class KotlinPsiReferenceRegistrar { + val providers: MultiMap, KotlinPsiReferenceProvider> = MultiMap.create() + + inline fun registerProvider(crossinline factory: (E) -> PsiReference?) { + registerMultiProvider { element -> + factory(element)?.let { reference -> arrayOf(reference) } ?: PsiReference.EMPTY_ARRAY + } + } + + inline fun registerMultiProvider(crossinline factory: (E) -> Array) { + val provider: KotlinPsiReferenceProvider = object : KotlinPsiReferenceProvider { + override fun getReferencesByElement(element: PsiElement): Array { + return factory(element as E) + } + } + + registerMultiProvider(E::class.java, provider) + } + + fun registerMultiProvider(klass: Class, provider: KotlinPsiReferenceProvider) { + providers.putValue(klass, provider) + } +} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtArrayAccessReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtArrayAccessReference.kt similarity index 95% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtArrayAccessReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtArrayAccessReference.kt index 7df923157c3..226ecfe77e4 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtArrayAccessReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtArrayAccessReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.idea.references import com.google.common.collect.Lists import com.intellij.psi.MultiRangeReference import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.lexer.KtToken import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.Name @@ -48,7 +47,7 @@ abstract class KtArrayAccessReference( appendExpressions(arrayAccessExpression.indexExpressions, ",") appendFixedText(")") } - val fullCallExpression = arrayAccessExpression.replaced(replacement) + val fullCallExpression = arrayAccessExpression.replace(replacement) as KtExpression val callExpression = fullCallExpression.getPossiblyQualifiedCallExpression() if (callExpression != null && canMoveLambdaOutsideParentheses(callExpression)) { moveFunctionLiteralOutsideParentheses(callExpression) @@ -66,4 +65,4 @@ abstract class KtArrayAccessReference( companion object { private val NAMES = Lists.newArrayList(OperatorNameConventions.GET, OperatorNameConventions.SET) } -} +} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtCollectionLiteralReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtCollectionLiteralReference.kt similarity index 90% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtCollectionLiteralReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtCollectionLiteralReference.kt index ec5564081fa..4f2cca59920 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtCollectionLiteralReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtCollectionLiteralReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -9,7 +9,7 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.MultiRangeReference import com.intellij.psi.PsiElement import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.KtCollectionLiteralExpression +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.ArrayFqNames abstract class KtCollectionLiteralReference(expression: KtCollectionLiteralExpression) : @@ -28,4 +28,4 @@ abstract class KtCollectionLiteralReference(expression: KtCollectionLiteralExpre get() = COLLECTION_LITERAL_CALL_NAMES private fun PsiElement.normalizeRange(): TextRange = this.textRange.shiftRight(-expression.textOffset) -} +} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtConstructorDelegationReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtConstructorDelegationReference.kt similarity index 86% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtConstructorDelegationReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtConstructorDelegationReference.kt index 0ae63287e55..e23c41ad538 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtConstructorDelegationReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtConstructorDelegationReference.kt @@ -1,13 +1,14 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ + package org.jetbrains.kotlin.idea.references import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.KtConstructorDelegationReferenceExpression +import org.jetbrains.kotlin.psi.* abstract class KtConstructorDelegationReference( expression: KtConstructorDelegationReferenceExpression diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt similarity index 95% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt index 70498d514f9..9139ad53c66 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -31,4 +31,4 @@ abstract class KtDestructuringDeclarationReference( val componentIndex = destructuringParent.entries.indexOf(element) + 1 return listOf(Name.identifier("component$componentIndex")) } -} +} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt similarity index 89% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt index 1c6e82cc294..c2f57855d09 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -7,7 +7,7 @@ package org.jetbrains.kotlin.idea.references import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.KtForExpression +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.util.OperatorNameConventions abstract class KtForLoopInReference(element: KtForExpression) : KtMultiReference(element) { @@ -28,4 +28,4 @@ abstract class KtForLoopInReference(element: KtForExpression) : KtMultiReference OperatorNameConventions.HAS_NEXT ) } -} +} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtInvokeFunctionReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtInvokeFunctionReference.kt similarity index 98% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtInvokeFunctionReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtInvokeFunctionReference.kt index 12141910b19..2a954262e17 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtInvokeFunctionReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtInvokeFunctionReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt similarity index 94% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt index 15a776e69b2..e6ef2bf5ad9 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtReference.kt similarity index 96% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtReference.kt index 453152179f8..f21f08ce9db 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt similarity index 81% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt index 66d7d31a863..f7b313ecb0a 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -8,31 +8,16 @@ package org.jetbrains.kotlin.idea.references import com.intellij.openapi.extensions.Extensions import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement -import com.intellij.psi.PsiReference import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.plugin.references.SimpleNameReferenceExtension import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.types.expressions.OperatorConventions abstract class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleReference(expression) { - override fun isReferenceTo(element: PsiElement): Boolean { - if (!doCanBeReferenceTo(element)) return false - - - @Suppress("DEPRECATION") // compatibility with 191 - for (extension in Extensions.getArea(element.project).getExtensionPoint(SimpleNameReferenceExtension.EP_NAME).extensions) { - if (extension.isReferenceTo(this, element)) return true - } - - return isReferenceToWithoutExtensionChecking(element) - } - protected abstract fun doCanBeReferenceTo(candidateTarget: PsiElement): Boolean - protected abstract fun isReferenceToWithoutExtensionChecking(candidateTarget: PsiElement): Boolean override fun getRangeInElement(): TextRange { val element = element.getReferencedNameElement() diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt similarity index 72% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index aef23d4b77b..c6d24bf1b22 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -15,16 +15,9 @@ abstract class SyntheticPropertyAccessorReference( expression: KtNameReferenceExpression, val getter: Boolean ) : KtSimpleReference(expression) { - - override fun isReferenceTo(element: PsiElement): Boolean { - if (element !is PsiMethod || !isAccessorName(element.name)) return false - if (!getter && expression.readWriteAccess(true) == ReferenceAccess.READ) return false - return additionalIsReferenceToChecker(element) - } - protected abstract fun additionalIsReferenceToChecker(element: PsiElement): Boolean - private fun isAccessorName(name: String): Boolean { + protected fun isAccessorName(name: String): Boolean { if (getter) { return name.startsWith("get") || name.startsWith("is") } diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/referenceUtils.kt b/compiler/psi/src/org/jetbrains/kotlin/idea/references/referenceUtils.kt similarity index 94% rename from idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/referenceUtils.kt rename to compiler/psi/src/org/jetbrains/kotlin/idea/references/referenceUtils.kt index 6ac6a1788ec..8aacfc0ced1 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/referenceUtils.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/idea/references/referenceUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt index 8129ba0d0e0..997ee70235c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt @@ -42,12 +42,10 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions class KtSimpleNameReferenceDescriptorsImpl( expression: KtSimpleNameExpression ) : KtSimpleNameReference(expression), KtDescriptorsBasedReference { + override fun doCanBeReferenceTo(candidateTarget: PsiElement): Boolean = canBeReferenceTo(candidateTarget) - override fun isReferenceToWithoutExtensionChecking(candidateTarget: PsiElement): Boolean = - matchesTarget(candidateTarget) - override fun getTargetDescriptors(context: BindingContext): Collection { return SmartList().apply { // Replace Java property with its accessor(s) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index 0a0198cb1e3..98c9f46ff67 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.idea.references import com.intellij.psi.PsiElement +import com.intellij.psi.PsiMethod import com.intellij.util.SmartList import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor @@ -29,8 +30,12 @@ class SyntheticPropertyAccessorReferenceDescriptorImpl( expression: KtNameReferenceExpression, getter: Boolean ) : SyntheticPropertyAccessorReference(expression, getter), KtDescriptorsBasedReference { - override fun isReferenceTo(element: PsiElement): Boolean = - super.isReferenceTo(element) + + override fun isReferenceTo(element: PsiElement): Boolean { + if (element !is PsiMethod || !isAccessorName(element.name)) return false + if (!getter && expression.readWriteAccess(true) == ReferenceAccess.READ) return false + return additionalIsReferenceToChecker(element) + } override fun additionalIsReferenceToChecker(element: PsiElement): Boolean = matchesTarget(element) diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceResolveMixIn.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceResolveMixIn.kt index 384c7846fe5..0c96bb2d014 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceResolveMixIn.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceResolveMixIn.kt @@ -7,9 +7,7 @@ package org.jetbrains.kotlin.idea.frontend.api.components import org.jetbrains.kotlin.idea.frontend.api.KtSymbolBasedReference import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol -import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer import org.jetbrains.kotlin.idea.references.KtReference -import org.jetbrains.kotlin.idea.references.KtSimpleReference interface KtReferenceResolveMixIn : KtAnalysisSessionMixIn { fun KtReference.resolveToSymbols(): Collection { diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirSimpleNameReference.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirSimpleNameReference.kt index 3617bb7b2b8..2a9edbf8367 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirSimpleNameReference.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirSimpleNameReference.kt @@ -47,8 +47,9 @@ internal class KtFirSimpleNameReference( return true // TODO } - override fun isReferenceToWithoutExtensionChecking(candidateTarget: PsiElement): Boolean { - return resolve() == candidateTarget //todo + + override fun isReferenceTo(element: PsiElement): Boolean { + return resolve() == element //todo } override fun handleElementRename(newElementName: String): PsiElement? { diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtIdeReferenceProviderService.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtIdeReferenceProviderService.kt index f6246fe9ad6..a29b5a6e370 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtIdeReferenceProviderService.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/references/KtIdeReferenceProviderService.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.idea.references -import com.intellij.openapi.components.service import com.intellij.openapi.project.IndexNotReadyException import com.intellij.psi.ContributedReferenceHost import com.intellij.psi.PsiElement @@ -16,49 +15,10 @@ import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.PsiModificationTracker import com.intellij.util.containers.ConcurrentFactoryMap -import com.intellij.util.containers.ContainerUtil import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.psi.KotlinReferenceProvidersService -import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.utils.SmartList -interface KotlinPsiReferenceProvider { - fun getReferencesByElement(element: PsiElement): Array -} - -interface KotlinReferenceProviderContributor { - fun registerReferenceProviders(registrar: KotlinPsiReferenceRegistrar) - - companion object { - fun getInstance(): KotlinReferenceProviderContributor = service() - } -} - - -class KotlinPsiReferenceRegistrar { - val providers: MultiMap, KotlinPsiReferenceProvider> = MultiMap.create() - - inline fun registerProvider(crossinline factory: (E) -> PsiReference?) { - registerMultiProvider { element -> - factory(element)?.let { reference -> arrayOf(reference) } ?: PsiReference.EMPTY_ARRAY - } - } - - inline fun registerMultiProvider(crossinline factory: (E) -> Array) { - val provider: KotlinPsiReferenceProvider = object : KotlinPsiReferenceProvider { - override fun getReferencesByElement(element: PsiElement): Array { - return factory(element as E) - } - } - - registerMultiProvider(E::class.java, provider) - } - - fun registerMultiProvider(klass: Class, provider: KotlinPsiReferenceProvider) { - providers.putValue(klass, provider) - } -} - class KtIdeReferenceProviderService : KotlinReferenceProvidersService() { private val originalProvidersBinding: MultiMap, KotlinPsiReferenceProvider> private val providersBindingCache: Map, List>