Light Classes: Consider FakeFileForLightClass instances equivalent if they correspond to the light classes with common KtFile
#KT-12117 Fixed
This commit is contained in:
@@ -85,6 +85,7 @@
|
||||
###### Issues fixed
|
||||
|
||||
- [`KT-12091`](https://youtrack.jetbrains.com/issue/KT-12091) Fixed unstable behavior of Spring line markers
|
||||
- [`KT-12117`](https://youtrack.jetbrains.com/issue/KT-12117) Group Kotlin classes from the same file in the Choose Bean dialog
|
||||
- [`KT-12120`](https://youtrack.jetbrains.com/issue/KT-12120) Show autowiring candidates line markers for @Autowired-annotated constructors and constructor parameters
|
||||
- [`KT-12122`](https://youtrack.jetbrains.com/issue/KT-12122) Fixed line marker popup on functions with @Qualifier-annotated parameters
|
||||
- [`KT-12143`](https://youtrack.jetbrains.com/issue/KT-12143) Fixed "Spring Facet Code Configuration (Kotlin)" inspection description
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.asJava
|
||||
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
import com.intellij.psi.ClassFileViewProvider
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl
|
||||
import com.intellij.psi.stubs.PsiClassHolderFileStub
|
||||
@@ -45,4 +46,25 @@ open class FakeFileForLightClass(
|
||||
|
||||
// this should be equal to current compiler target language level
|
||||
override fun getLanguageLevel() = LanguageLevel.JDK_1_6
|
||||
|
||||
override fun hashCode(): Int {
|
||||
val thisClass = lightClass()
|
||||
if (thisClass is KtLightClassForExplicitDeclaration) return ktFile.hashCode()
|
||||
return thisClass.hashCode()
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is FakeFileForLightClass) return false
|
||||
val thisClass = lightClass()
|
||||
val anotherClass = other.lightClass()
|
||||
|
||||
if (thisClass is KtLightClassForExplicitDeclaration) {
|
||||
return anotherClass is KtLightClassForExplicitDeclaration && ktFile == other.ktFile
|
||||
}
|
||||
|
||||
return thisClass == anotherClass
|
||||
}
|
||||
|
||||
override fun isEquivalentTo(another: PsiElement?) = this == another
|
||||
}
|
||||
+1
-1
@@ -110,7 +110,7 @@ private fun createAutowiredDependency(
|
||||
|
||||
fun generateAutowiredDependenciesFor(klass: KtLightClass): List<BatchTemplateRunner> {
|
||||
val model = SpringModelUtils.getInstance().getPsiClassSpringModel(klass)
|
||||
val candidates = GenerateSpringBeanDependenciesUtil.getAutowiredBeanCandidates(model) { it.containingFile != klass.containingFile }
|
||||
val candidates = GenerateSpringBeanDependenciesUtil.getAutowiredBeanCandidates(model) { true }
|
||||
val dependencies = if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
candidates.map { it.springBean }.filter(klass.project.beanFilter).sortedBy { it.name }
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user