Provide toString() for classes that extend GlobalSearchScope (to diagnose package fragment errors)
This commit is contained in:
+4
-2
@@ -18,12 +18,12 @@ package org.jetbrains.kotlin.resolve.lazy.declarations
|
|||||||
|
|
||||||
import com.intellij.openapi.components.ServiceManager
|
import com.intellij.openapi.components.ServiceManager
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.psi.search.DelegatingGlobalSearchScope
|
import com.intellij.psi.search.DelegatingGlobalSearchScope
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import java.util.*
|
||||||
import java.util.HashSet
|
|
||||||
|
|
||||||
abstract class DeclarationProviderFactoryService {
|
abstract class DeclarationProviderFactoryService {
|
||||||
|
|
||||||
@@ -60,5 +60,7 @@ abstract class DeclarationProviderFactoryService {
|
|||||||
private val originals = syntheticFiles.mapNotNullTo(HashSet<VirtualFile>()) { it.originalFile.virtualFile }
|
private val originals = syntheticFiles.mapNotNullTo(HashSet<VirtualFile>()) { it.originalFile.virtualFile }
|
||||||
|
|
||||||
override fun contains(file: VirtualFile) = super.contains(file) && file !in originals
|
override fun contains(file: VirtualFile) = super.contains(file) && file !in originals
|
||||||
|
|
||||||
|
override fun toString() = "SyntheticFilesFilteringScope($myBaseScope)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,6 +187,8 @@ private class ModuleProductionSourceScope(module: Module) : ModuleSourceScope(mo
|
|||||||
override fun hashCode(): Int = 31 * module.hashCode()
|
override fun hashCode(): Int = 31 * module.hashCode()
|
||||||
|
|
||||||
override fun contains(file: VirtualFile) = moduleFileIndex.isInSourceContent(file) && !moduleFileIndex.isInTestSourceContent(file)
|
override fun contains(file: VirtualFile) = moduleFileIndex.isInSourceContent(file) && !moduleFileIndex.isInTestSourceContent(file)
|
||||||
|
|
||||||
|
override fun toString() = "ModuleProductionSourceScope($module)"
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module) {
|
private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module) {
|
||||||
@@ -200,6 +202,8 @@ private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module)
|
|||||||
override fun hashCode(): Int = 37 * module.hashCode()
|
override fun hashCode(): Int = 37 * module.hashCode()
|
||||||
|
|
||||||
override fun contains(file: VirtualFile) = moduleFileIndex.isInTestSourceContent(file)
|
override fun contains(file: VirtualFile) = moduleFileIndex.isInTestSourceContent(file)
|
||||||
|
|
||||||
|
override fun toString() = "ModuleTestSourceScope($module)"
|
||||||
}
|
}
|
||||||
|
|
||||||
open class LibraryInfo(val project: Project, val library: Library) : IdeaModuleInfo {
|
open class LibraryInfo(val project: Project, val library: Library) : IdeaModuleInfo {
|
||||||
@@ -287,6 +291,8 @@ 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 hashCode() = library.hashCode()
|
||||||
|
|
||||||
|
override fun toString() = "LibraryWithoutSourceScope($library)"
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: (module refactoring) android sdk has modified scope
|
//TODO: (module refactoring) android sdk has modified scope
|
||||||
@@ -296,6 +302,8 @@ private class SdkScope(project: Project, private val sdk: Sdk) :
|
|||||||
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 hashCode() = sdk.hashCode()
|
||||||
|
|
||||||
|
override fun toString() = "SdkScope($sdk)"
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun IdeaModuleInfo.isLibraryClasses() = this is SdkInfo || this is LibraryInfo
|
internal fun IdeaModuleInfo.isLibraryClasses() = this is SdkInfo || this is LibraryInfo
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ class KotlinSourceFilterScope private constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "KotlinSourceFilterScope(delegate=$myBaseScope src=$includeProjectSourceFiles libSrc=$includeLibrarySourceFiles " +
|
||||||
|
"cls=$includeClassFiles script=$includeScriptDependencies)"
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sourcesAndLibraries(delegate: GlobalSearchScope, project: Project) = create(delegate, true, true, true, true, project)
|
fun sourcesAndLibraries(delegate: GlobalSearchScope, project: Project) = create(delegate, true, true, true, true, project)
|
||||||
|
|||||||
Reference in New Issue
Block a user