From 682550148ced6013f81ae9f532c50a3709182157 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Sun, 31 Aug 2025 16:23:17 +0200 Subject: [PATCH] PY-83776: Add logging to trace the problem. Enable the following log: ``` #com.intellij.python.community.services.shared:debug ``` GitOrigin-RevId: 7ea444ebca62d3f8186d983cd10381199165a0a2 --- python/services/shared/BUILD.bazel | 4 +++ ...ellij.python.community.services.shared.iml | 2 ++ .../community/services/shared/comparators.kt | 32 +++++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/python/services/shared/BUILD.bazel b/python/services/shared/BUILD.bazel index 4e79395ad3f0..bc01dc1b2d5e 100644 --- a/python/services/shared/BUILD.bazel +++ b/python/services/shared/BUILD.bazel @@ -18,6 +18,8 @@ jvm_library( "@lib//:jetbrains-annotations", "//platform/eel-provider", "//python/python-exec-service/execService.python", + "//platform/diagnostic", + "//platform/util", ], runtime_deps = [":shared_resources"] ) @@ -40,6 +42,8 @@ jvm_library( "@lib//:hamcrest", "//python/python-exec-service/execService.python", "//python/python-exec-service/execService.python:execService.python_test_lib", + "//platform/diagnostic", + "//platform/util", ], runtime_deps = [":shared_resources"] ) diff --git a/python/services/shared/intellij.python.community.services.shared.iml b/python/services/shared/intellij.python.community.services.shared.iml index c96f4eb50215..73be23996c57 100644 --- a/python/services/shared/intellij.python.community.services.shared.iml +++ b/python/services/shared/intellij.python.community.services.shared.iml @@ -18,5 +18,7 @@ + + \ No newline at end of file diff --git a/python/services/shared/src/com/intellij/python/community/services/shared/comparators.kt b/python/services/shared/src/com/intellij/python/community/services/shared/comparators.kt index 8c15c630ac7c..5bb68e8f78cb 100644 --- a/python/services/shared/src/com/intellij/python/community/services/shared/comparators.kt +++ b/python/services/shared/src/com/intellij/python/community/services/shared/comparators.kt @@ -1,21 +1,39 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.python.community.services.shared +import com.intellij.openapi.diagnostic.fileLogger +import com.jetbrains.python.psi.LanguageLevel import java.util.* +private val logger = fileLogger() + object LanguageLevelComparator : Comparator { - override fun compare(o1: LanguageLevelHolder, o2: LanguageLevelHolder): Int = + override fun compare(o1: LanguageLevelHolder, o2: LanguageLevelHolder): Int { // Backward: first python is the highest - o1.languageLevel.compareTo(o2.languageLevel) * -1 + if (logger.isDebugEnabled) { + logger.debug("langLevel ${o1.languageLevel} vs ${o2.languageLevel}") + } + return LanguageLevel.VERSION_COMPARATOR.compare(o1.languageLevel, o2.languageLevel) * -1 + } } object UiComparator : Comparator { - override fun compare(o1: UiHolder, o2: UiHolder): Int = - Objects.compare(o1.ui, o2.ui, Comparator.nullsFirst(UICustomization::compareTo)) + override fun compare(o1: UiHolder, o2: UiHolder): Int { + if (logger.isDebugEnabled) { + logger.debug("ui ${o1.ui?.title} vs ${o2.ui?.title}") + } + return Objects.compare(o1.ui, o2.ui, Comparator.nullsFirst(UICustomization::compareTo)) + } } class LanguageLevelWithUiComparator : Comparator where T : LanguageLevelHolder, T : UiHolder { - override fun compare(o1: T, o2: T): Int = - LanguageLevelComparator.compare(o1, o2) * 10 + UiComparator.compare(o1, o2) -} \ No newline at end of file + override fun compare(o1: T, o2: T): Int { + if (logger.isDebugEnabled) { + logger.debug("full ${o1.string()} vs ${o2.string()}") + } + return LanguageLevelComparator.compare(o1, o2) * 10 + UiComparator.compare(o1, o2) + } +} + +private fun T.string(): String where T : LanguageLevelHolder, T : UiHolder = "($languageLevel,${ui?.title})"