Prohibit operator mod as declaration and calls that resolved via it

#KT-24197 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-06-28 03:04:13 +03:00
parent c887b88ed9
commit 2e88f5c47d
16 changed files with 149 additions and 8 deletions
@@ -148,6 +148,8 @@ class QuickFixRegistrar : QuickFixContributor {
TYPE_CANT_BE_USED_FOR_CONST_VAL.registerFactory(removeModifierFactory)
DEPRECATED_BINARY_MOD.registerFactory(removeModifierFactory)
DEPRECATED_BINARY_MOD.registerFactory(RenameModToRemFix.Factory)
FORBIDDEN_BINARY_MOD.registerFactory(removeModifierFactory)
FORBIDDEN_BINARY_MOD.registerFactory(RenameModToRemFix.Factory)
UNRESOLVED_REFERENCE.registerFactory(ImportFix)
@@ -41,7 +41,7 @@ class RenameModToRemFix(element: KtNamedFunction, val newName: Name) : KotlinQui
companion object Factory : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
if (diagnostic.factory != Errors.DEPRECATED_BINARY_MOD) return null
if (diagnostic.factory != Errors.DEPRECATED_BINARY_MOD && diagnostic.factory != Errors.FORBIDDEN_BINARY_MOD) return null
val operatorMod = diagnostic.psiElement.getNonStrictParentOfType<KtNamedFunction>() ?: return null
val newName = REM_TO_MOD_OPERATION_NAMES.inverse()[operatorMod.nameAsName] ?: return null