J2K adds "operator" modifier to methods that look like operator on conversion
This commit is contained in:
@@ -40,6 +40,10 @@ class AddOperatorModifierIntention : JetSelfTargetingRangeIntention<JetNamedFunc
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetNamedFunction, editor: Editor) {
|
||||
applyTo(element)
|
||||
}
|
||||
|
||||
fun applyTo(element: JetNamedFunction) {
|
||||
element.addModifier(JetTokens.OPERATOR_KEYWORD)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ object J2KPostProcessingRegistrar {
|
||||
registerIntentionBasedProcessing(IfNullToElvisIntention()) { applyTo(it) }
|
||||
registerIntentionBasedProcessing(SimplifyNegatedBinaryExpressionIntention()) { applyTo(it) }
|
||||
registerIntentionBasedProcessing(ReplaceGetIntention()) { applyTo(it) }
|
||||
registerIntentionBasedProcessing(AddOperatorModifierIntention()) { applyTo(it) }
|
||||
|
||||
registerDiagnosticBasedProcessing<JetBinaryExpressionWithTypeRHS>(Errors.USELESS_CAST) { element, diagnostic ->
|
||||
val expression = RemoveRightPartOfBinaryExpressionFix(element, "").invoke()
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.KotlinOutOfBlockCompletionModificationTracker
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
|
||||
import org.jetbrains.kotlin.idea.conversion.copy.range
|
||||
@@ -32,7 +33,7 @@ import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.elementsInRange
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import java.util.LinkedHashMap
|
||||
import java.util.*
|
||||
|
||||
public class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor {
|
||||
override fun insertImport(file: JetFile, fqName: FqName) {
|
||||
@@ -65,6 +66,9 @@ public class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor {
|
||||
|
||||
if (modificationStamp == file.modificationStamp) break
|
||||
|
||||
//TODO: it's a hack!
|
||||
KotlinOutOfBlockCompletionModificationTracker.getInstance(file.project).incModificationCount()
|
||||
|
||||
elementToActions = collectAvailableActions(file, rangeMarker)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import java.util.HashMap
|
||||
import kotlinApi.KotlinClass
|
||||
|
||||
internal class X {
|
||||
fun get(index: Int): Int {
|
||||
operator fun get(index: Int): Int {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ internal class C {
|
||||
}
|
||||
|
||||
fun foo(x: X): Int {
|
||||
return x.get(0)
|
||||
return x[0]
|
||||
}
|
||||
|
||||
fun foo(kotlinClass: KotlinClass): Int {
|
||||
|
||||
Reference in New Issue
Block a user