J2K: coversion of specially mapped built-in methods + replacing "get" with "[]" where possible

This commit is contained in:
Valentin Kipyatkov
2015-10-16 22:45:19 +03:00
parent 50f559a1c8
commit dc909ac166
29 changed files with 327 additions and 57 deletions
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.inspections.RedundantSamConstructorInspection
import org.jetbrains.kotlin.idea.intentions.*
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisIntention
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention
import org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetIntention
import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix
import org.jetbrains.kotlin.idea.quickfix.RemoveRightPartOfBinaryExpressionFix
import org.jetbrains.kotlin.idea.references.mainReference
@@ -58,6 +59,7 @@ object J2KPostProcessingRegistrar {
registerIntentionBasedProcessing(IfThenToElvisIntention()) { applyTo(it) }
registerIntentionBasedProcessing(IfNullToElvisIntention()) { applyTo(it) }
registerIntentionBasedProcessing(SimplifyNegatedBinaryExpressionIntention()) { applyTo(it) }
registerIntentionBasedProcessing(ReplaceGetIntention()) { applyTo(it) }
registerDiagnosticBasedProcessing<JetBinaryExpressionWithTypeRHS>(Errors.USELESS_CAST) { element, diagnostic ->
val expression = RemoveRightPartOfBinaryExpressionFix(element, "").invoke()
@@ -1,6 +1,6 @@
fun foo(o: Any) {
if (o is String) {
val l = o.length()
val l = o.length
}
somethingElse()
}
@@ -1,5 +1,5 @@
fun foo(o: Any) {
if (o !is String) return
val l = o.length()
val l = o.length
somethingElse(o as String/* we should not remove this cast because it's not in pasted range*/)
}