Rename kt-reference module to kt-references.
This commit is contained in:
@@ -9,7 +9,7 @@ dependencies {
|
||||
implementation(project(":compiler:frontend.java"))
|
||||
implementation(project(":analysis:analysis-api-impl-base"))
|
||||
implementation(project(":analysis:analysis-internal-utils"))
|
||||
implementation(project(":analysis:kt-reference"))
|
||||
implementation(project(":analysis:kt-references"))
|
||||
|
||||
implementation(project(":compiler:backend"))
|
||||
implementation(project(":compiler:backend.jvm"))
|
||||
|
||||
@@ -21,7 +21,7 @@ dependencies {
|
||||
api(intellijCore())
|
||||
implementation(project(":analysis:analysis-api-providers"))
|
||||
implementation(project(":analysis:analysis-internal-utils"))
|
||||
implementation(project(":analysis:kt-reference"))
|
||||
implementation(project(":analysis:kt-references"))
|
||||
|
||||
testApi(projectTests(":analysis:low-level-api-fir"))
|
||||
testApi(projectTests(":compiler:tests-common"))
|
||||
|
||||
-8
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirSafe
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildImport
|
||||
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.classId
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||
@@ -31,14 +30,7 @@ import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.analysis.api.fir.getCandidateSymbols
|
||||
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
||||
import org.jetbrains.kotlin.analysis.api.fir.buildSymbol
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirSyntheticPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
@@ -7,7 +7,7 @@ dependencies {
|
||||
api(project(":compiler:psi"))
|
||||
api(project(":analysis:analysis-api"))
|
||||
api(project(":analysis:analysis-api-impl-barebone"))
|
||||
api(project(":analysis:kt-reference"))
|
||||
api(project(":analysis:kt-references"))
|
||||
api(intellijCore())
|
||||
implementation(project(":analysis:analysis-internal-utils"))
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ dependencies {
|
||||
compileOnly(project(":analysis:low-level-api-fir"))
|
||||
implementation(project(":analysis:analysis-internal-utils"))
|
||||
implementation(project(":analysis:analysis-api-providers"))
|
||||
implementation(project(":analysis:kt-reference"))
|
||||
implementation(project(":analysis:kt-references"))
|
||||
|
||||
api(intellijCore())
|
||||
api(commonDependency("com.google.guava:guava"))
|
||||
|
||||
+50
@@ -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<PsiReference>
|
||||
}
|
||||
|
||||
interface KotlinReferenceProviderContributor {
|
||||
fun registerReferenceProviders(registrar: KotlinPsiReferenceRegistrar)
|
||||
|
||||
companion object {
|
||||
fun getInstance(): KotlinReferenceProviderContributor =
|
||||
ServiceManager.getService(KotlinReferenceProviderContributor::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class KotlinPsiReferenceRegistrar {
|
||||
val providers: MultiMap<Class<out PsiElement>, KotlinPsiReferenceProvider> = MultiMap.create()
|
||||
|
||||
inline fun <reified E : KtElement> registerProvider(crossinline factory: (E) -> PsiReference?) {
|
||||
registerMultiProvider<E> { element ->
|
||||
factory(element)?.let { reference -> arrayOf(reference) } ?: PsiReference.EMPTY_ARRAY
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified E : KtElement> registerMultiProvider(crossinline factory: (E) -> Array<PsiReference>) {
|
||||
val provider: KotlinPsiReferenceProvider = object : KotlinPsiReferenceProvider {
|
||||
override fun getReferencesByElement(element: PsiElement): Array<PsiReference> {
|
||||
return factory(element as E)
|
||||
}
|
||||
}
|
||||
|
||||
registerMultiProvider(E::class.java, provider)
|
||||
}
|
||||
|
||||
fun registerMultiProvider(klass: Class<out PsiElement>, provider: KotlinPsiReferenceProvider) {
|
||||
providers.putValue(klass, provider)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user