[Java. Refactorings] Show rename popup only when method is located outside the test class

IDEA-351758

GitOrigin-RevId: f4004e304639fa4f58d6bc4a67e5c137172482fc
This commit is contained in:
Georgii Ustinov
2024-04-18 23:06:54 +03:00
committed by intellij-monorepo-bot
parent ba39cce039
commit a526e56691
3 changed files with 72 additions and 2 deletions

View File

@@ -11,7 +11,8 @@ import com.intellij.usageView.UsageInfo
class JavaAutomaticTestMethodRenamerFactory : AutomaticTestMethodRenamerFactory() {
override fun isApplicable(element: PsiElement): Boolean {
if (element !is PsiMethod) return false
return !TestFrameworks.getInstance().isTestMethod(element)
val clazz = element.containingClass ?: return false
return !TestFrameworks.getInstance().isTestClass(clazz)
}
override fun isEnabled(): Boolean = JavaRefactoringSettings.getInstance().isRenameTestMethods