mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
kotlin: automatic rename: do not suggest constant names for companion object properties
GitOrigin-RevId: 4ecf3493a55127f7b7a224f6c1fd93010e737419
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a9d6f77e1c
commit
c2ebab1d86
+5
-2
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.core.unquote
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSettings
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException
|
||||
@@ -51,8 +52,7 @@ class AutomaticVariableRenamer(
|
||||
KtParameter::class.java
|
||||
) as KtCallableDeclaration? ?: continue
|
||||
|
||||
if (parameterOrVariable.name == null) continue
|
||||
val variableName = parameterOrVariable.name!!
|
||||
val variableName = parameterOrVariable.name ?: continue
|
||||
|
||||
if (variableName.equals(newClassNameUnquoted, ignoreCase = true)) continue
|
||||
if (!StringUtil.containsIgnoreCase(variableName, oldClassName)) continue
|
||||
@@ -120,6 +120,9 @@ class AutomaticVariableRenamer(
|
||||
if (ktElement is KtProperty && ktElement.isTopLevel && !ktElement.hasModifier(KtTokens.CONST_KEYWORD)) {
|
||||
return null
|
||||
}
|
||||
if (ktElement.containingClassOrObject is KtObjectDeclaration) {
|
||||
return null
|
||||
}
|
||||
val psiVariable = ktElement.toLightElements().firstIsInstanceOrNull<PsiVariable>()
|
||||
return if (psiVariable != null) codeStyleManager.getVariableKind(psiVariable) else null
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
package test
|
||||
|
||||
class Bar {
|
||||
|
||||
companion object {
|
||||
val barKlass: Class<Bar> = Bar::class.java
|
||||
}
|
||||
}
|
||||
|
||||
val SOME_Bar: Bar = Bar()
|
||||
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
package test
|
||||
|
||||
class Foo {
|
||||
|
||||
companion object {
|
||||
val fooKlass: Class<Foo> = Foo::class.java
|
||||
}
|
||||
}
|
||||
|
||||
val SOME_FOO: Foo = Foo()
|
||||
|
||||
Reference in New Issue
Block a user