Add missed calcHashCode for ModuleSourceScope subclasses
This commit is contained in:
@@ -250,6 +250,7 @@ private abstract class ModuleSourceScope(val module: Module) : GlobalSearchScope
|
|||||||
override fun isSearchInLibraries() = false
|
override fun isSearchInLibraries() = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("EqualsOrHashCode") // DelegatingGlobalSearchScope requires to provide calcHashCode()
|
||||||
private class ModuleProductionSourceScope(module: Module) : ModuleSourceScope(module) {
|
private class ModuleProductionSourceScope(module: Module) : ModuleSourceScope(module) {
|
||||||
val moduleFileIndex = ModuleRootManager.getInstance(module).fileIndex
|
val moduleFileIndex = ModuleRootManager.getInstance(module).fileIndex
|
||||||
|
|
||||||
@@ -258,8 +259,7 @@ private class ModuleProductionSourceScope(module: Module) : ModuleSourceScope(mo
|
|||||||
return (other is ModuleProductionSourceScope && module == other.module)
|
return (other is ModuleProductionSourceScope && module == other.module)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-6206
|
override fun calcHashCode(): Int = 31 * module.hashCode()
|
||||||
override fun hashCode(): Int = 31 * module.hashCode()
|
|
||||||
|
|
||||||
override fun contains(file: VirtualFile) =
|
override fun contains(file: VirtualFile) =
|
||||||
moduleFileIndex.isInSourceContentWithoutInjected(file) && !moduleFileIndex.isInTestSourceContentKotlinAware(file)
|
moduleFileIndex.isInSourceContentWithoutInjected(file) && !moduleFileIndex.isInTestSourceContentKotlinAware(file)
|
||||||
@@ -267,6 +267,7 @@ private class ModuleProductionSourceScope(module: Module) : ModuleSourceScope(mo
|
|||||||
override fun toString() = "ModuleProductionSourceScope($module)"
|
override fun toString() = "ModuleProductionSourceScope($module)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("EqualsOrHashCode") // DelegatingGlobalSearchScope requires to provide calcHashCode()
|
||||||
private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module) {
|
private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module) {
|
||||||
val moduleFileIndex = ModuleRootManager.getInstance(module).fileIndex
|
val moduleFileIndex = ModuleRootManager.getInstance(module).fileIndex
|
||||||
|
|
||||||
@@ -275,8 +276,7 @@ private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module)
|
|||||||
return (other is ModuleTestSourceScope && module == other.module)
|
return (other is ModuleTestSourceScope && module == other.module)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-6206
|
override fun calcHashCode(): Int = 37 * module.hashCode()
|
||||||
override fun hashCode(): Int = 37 * module.hashCode()
|
|
||||||
|
|
||||||
override fun contains(file: VirtualFile) = moduleFileIndex.isInTestSourceContentKotlinAware(file)
|
override fun contains(file: VirtualFile) = moduleFileIndex.isInTestSourceContentKotlinAware(file)
|
||||||
|
|
||||||
@@ -325,6 +325,7 @@ open class LibraryInfo(val project: Project, val library: Library) : IdeaModuleI
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int = 43 * library.hashCode()
|
override fun hashCode(): Int = 43 * library.hashCode()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data class LibrarySourceInfo(val project: Project, val library: Library, override val binariesModuleInfo: BinaryModuleInfo) :
|
data class LibrarySourceInfo(val project: Project, val library: Library, override val binariesModuleInfo: BinaryModuleInfo) :
|
||||||
@@ -388,6 +389,7 @@ object NotUnderContentRootModuleInfo : IdeaModuleInfo {
|
|||||||
get() = platform.single().findAnalyzerServices()
|
get() = platform.single().findAnalyzerServices()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("EqualsOrHashCode") // DelegatingGlobalSearchScope requires to provide calcHashCode()
|
||||||
private class LibraryWithoutSourceScope(project: Project, private val library: Library) :
|
private class LibraryWithoutSourceScope(project: Project, private val library: Library) :
|
||||||
LibraryScopeBase(project, library.getFiles(OrderRootType.CLASSES), arrayOf<VirtualFile>()) {
|
LibraryScopeBase(project, library.getFiles(OrderRootType.CLASSES), arrayOf<VirtualFile>()) {
|
||||||
|
|
||||||
@@ -395,11 +397,12 @@ private class LibraryWithoutSourceScope(project: Project, private val library: L
|
|||||||
|
|
||||||
override fun equals(other: Any?) = other is LibraryWithoutSourceScope && library == other.library
|
override fun equals(other: Any?) = other is LibraryWithoutSourceScope && library == other.library
|
||||||
|
|
||||||
override fun hashCode() = library.hashCode()
|
override fun calcHashCode(): Int = library.hashCode()
|
||||||
|
|
||||||
override fun toString() = "LibraryWithoutSourceScope($library)"
|
override fun toString() = "LibraryWithoutSourceScope($library)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("EqualsOrHashCode") // DelegatingGlobalSearchScope requires to provide calcHashCode()
|
||||||
private class LibrarySourceScope(project: Project, private val library: Library) :
|
private class LibrarySourceScope(project: Project, private val library: Library) :
|
||||||
LibraryScopeBase(project, arrayOf<VirtualFile>(), library.getFiles(OrderRootType.SOURCES)) {
|
LibraryScopeBase(project, arrayOf<VirtualFile>(), library.getFiles(OrderRootType.SOURCES)) {
|
||||||
|
|
||||||
@@ -407,18 +410,19 @@ private class LibrarySourceScope(project: Project, private val library: Library)
|
|||||||
|
|
||||||
override fun equals(other: Any?) = other is LibrarySourceScope && library == other.library
|
override fun equals(other: Any?) = other is LibrarySourceScope && library == other.library
|
||||||
|
|
||||||
override fun hashCode() = library.hashCode()
|
override fun calcHashCode(): Int = library.hashCode()
|
||||||
|
|
||||||
override fun toString() = "LibrarySourceScope($library)"
|
override fun toString() = "LibrarySourceScope($library)"
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: (module refactoring) android sdk has modified scope
|
//TODO: (module refactoring) android sdk has modified scope
|
||||||
|
@Suppress("EqualsOrHashCode") // DelegatingGlobalSearchScope requires to provide calcHashCode()
|
||||||
private class SdkScope(project: Project, val sdk: Sdk) :
|
private class SdkScope(project: Project, val sdk: Sdk) :
|
||||||
LibraryScopeBase(project, sdk.rootProvider.getFiles(OrderRootType.CLASSES), arrayOf<VirtualFile>()) {
|
LibraryScopeBase(project, sdk.rootProvider.getFiles(OrderRootType.CLASSES), arrayOf<VirtualFile>()) {
|
||||||
|
|
||||||
override fun equals(other: Any?) = other is SdkScope && sdk == other.sdk
|
override fun equals(other: Any?) = other is SdkScope && sdk == other.sdk
|
||||||
|
|
||||||
override fun hashCode() = sdk.hashCode()
|
override fun calcHashCode(): Int = sdk.hashCode()
|
||||||
|
|
||||||
override fun toString() = "SdkScope($sdk)"
|
override fun toString() = "SdkScope($sdk)"
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -23,6 +23,7 @@ import com.intellij.psi.search.DelegatingGlobalSearchScope
|
|||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||||
|
|
||||||
|
@Suppress("EqualsOrHashCode") // DelegatingGlobalSearchScope requires to provide calcHashCode()
|
||||||
class KotlinSourceFilterScope private constructor(
|
class KotlinSourceFilterScope private constructor(
|
||||||
delegate: GlobalSearchScope,
|
delegate: GlobalSearchScope,
|
||||||
private val includeProjectSourceFiles: Boolean,
|
private val includeProjectSourceFiles: Boolean,
|
||||||
@@ -73,8 +74,8 @@ class KotlinSourceFilterScope private constructor(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun calcHashCode(): Int {
|
||||||
var result = super.hashCode()
|
var result = super.calcHashCode()
|
||||||
result = 31 * result + includeProjectSourceFiles.hashCode()
|
result = 31 * result + includeProjectSourceFiles.hashCode()
|
||||||
result = 31 * result + includeLibrarySourceFiles.hashCode()
|
result = 31 * result + includeLibrarySourceFiles.hashCode()
|
||||||
result = 31 * result + includeClassFiles.hashCode()
|
result = 31 * result + includeClassFiles.hashCode()
|
||||||
|
|||||||
Reference in New Issue
Block a user