Don't rank local classes (KT-27712)
Allow enable ranking even for single source file in tests #KT-27712
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.sun.jdi.Location
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.idea.KotlinFileTypeFactory
|
||||
@@ -42,6 +43,9 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
|
||||
object DebuggerUtils {
|
||||
@TestOnly
|
||||
var forceRanking = false
|
||||
|
||||
fun findSourceFileForClassIncludeLibrarySources(
|
||||
project: Project,
|
||||
scope: GlobalSearchScope,
|
||||
@@ -74,7 +78,7 @@ object DebuggerUtils {
|
||||
|
||||
if (filesWithExactName.isEmpty()) return null
|
||||
|
||||
if (filesWithExactName.size == 1) {
|
||||
if (filesWithExactName.size == 1 && !forceRanking) {
|
||||
return filesWithExactName.single()
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypes2
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypes3
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.utils.keysToMap
|
||||
@@ -107,6 +108,8 @@ abstract class FileRankingCalculator(private val checkClassFqName: Boolean = tru
|
||||
}
|
||||
|
||||
private fun rankingForClassName(fqName: String, descriptor: ClassDescriptor, bindingContext: BindingContext): Ranking {
|
||||
if (DescriptorUtils.isLocal(descriptor)) return Ranking.ZERO
|
||||
|
||||
val expectedFqName = makeTypeMapper(bindingContext).mapType(descriptor).className
|
||||
return when {
|
||||
checkClassFqName -> if (expectedFqName == fqName) MAJOR else LOW
|
||||
|
||||
+2
@@ -1,5 +1,7 @@
|
||||
package stopInObjectLiteralInInlineCallWithClosureInAnonymous
|
||||
|
||||
// FORCE_RANKING
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a = 12
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils.findStringWithPrefixes
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||
import java.io.File
|
||||
import java.lang.AssertionError
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
||||
@@ -113,6 +112,8 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
||||
debuggerSettings.SKIP_CLASSLOADERS = fileText.getValueForSetting("SKIP_CLASSLOADERS", oldSettings!!.SKIP_CLASSLOADERS)
|
||||
debuggerSettings.TRACING_FILTERS_ENABLED = fileText.getValueForSetting("TRACING_FILTERS_ENABLED", oldSettings!!.TRACING_FILTERS_ENABLED)
|
||||
debuggerSettings.SKIP_GETTERS = fileText.getValueForSetting("SKIP_GETTERS", oldSettings!!.SKIP_GETTERS)
|
||||
|
||||
DebuggerUtils.forceRanking = InTextDirectivesUtils.isDirectiveDefined(fileText, "FORCE_RANKING")
|
||||
}
|
||||
|
||||
private fun String.getValueForSetting(name: String, defaultValue: Boolean): Boolean {
|
||||
@@ -137,6 +138,8 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
||||
debuggerSettings.SKIP_CLASSLOADERS = oldSettings!!.SKIP_CLASSLOADERS
|
||||
debuggerSettings.TRACING_FILTERS_ENABLED = oldSettings!!.TRACING_FILTERS_ENABLED
|
||||
debuggerSettings.SKIP_GETTERS = oldSettings!!.SKIP_GETTERS
|
||||
|
||||
DebuggerUtils.forceRanking = false
|
||||
}
|
||||
|
||||
protected val dp: DebugProcessImpl
|
||||
|
||||
Reference in New Issue
Block a user