From cc9127c001b0ba5c114e2fac470bb8587c1043d5 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Sun, 12 Oct 2025 15:47:54 +0200 Subject: [PATCH] [java, completion] IJPL-207762 RefStartInsertHandler is serializable GitOrigin-RevId: 105abeb88ad3719cc985a7a2b92d2b94c75acdc1 --- .../resource/intellij.java.frontback.impl.xml | 1 + .../method/JavaMethodCallInsertHandlerHelper.kt | 2 +- .../completion/method/RefStartInsertHandler.kt | 17 +++++++++++++++++ .../completion/JavaMethodCallInsertHandler.kt | 6 ------ 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 java/java-frontback-impl/src/com/intellij/codeInsight/completion/method/RefStartInsertHandler.kt diff --git a/java/java-frontback-impl/resource/intellij.java.frontback.impl.xml b/java/java-frontback-impl/resource/intellij.java.frontback.impl.xml index a518f2939700..d48d2ef96d59 100644 --- a/java/java-frontback-impl/resource/intellij.java.frontback.impl.xml +++ b/java/java-frontback-impl/resource/intellij.java.frontback.impl.xml @@ -80,6 +80,7 @@ description="Format chained calls as in versions prior to 2021.2"/> + diff --git a/java/java-frontback-impl/src/com/intellij/codeInsight/completion/method/JavaMethodCallInsertHandlerHelper.kt b/java/java-frontback-impl/src/com/intellij/codeInsight/completion/method/JavaMethodCallInsertHandlerHelper.kt index 56abef800311..a93064946f21 100644 --- a/java/java-frontback-impl/src/com/intellij/codeInsight/completion/method/JavaMethodCallInsertHandlerHelper.kt +++ b/java/java-frontback-impl/src/com/intellij/codeInsight/completion/method/JavaMethodCallInsertHandlerHelper.kt @@ -33,7 +33,7 @@ object JavaMethodCallInsertHandlerHelper { return element.getUserData(callKey) } - fun installRefStartKey(context: InsertionContext, item: LookupElement) { + internal fun installRefStartKey(context: InsertionContext, item: LookupElement) { val refStart = OffsetKey.create("refStart", true) context.offsetMap.addOffset(refStart, context.startOffset) item.putUserData(refStartKey, refStart) diff --git a/java/java-frontback-impl/src/com/intellij/codeInsight/completion/method/RefStartInsertHandler.kt b/java/java-frontback-impl/src/com/intellij/codeInsight/completion/method/RefStartInsertHandler.kt new file mode 100644 index 000000000000..efe7d6a631e9 --- /dev/null +++ b/java/java-frontback-impl/src/com/intellij/codeInsight/completion/method/RefStartInsertHandler.kt @@ -0,0 +1,17 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.codeInsight.completion.method + +import com.intellij.codeInsight.completion.FrontendFriendlyInsertHandler +import com.intellij.codeInsight.completion.InsertHandler +import com.intellij.codeInsight.completion.InsertionContext +import com.intellij.codeInsight.lookup.LookupElement +import kotlinx.serialization.Serializable +import org.jetbrains.annotations.ApiStatus + +@ApiStatus.Internal +@Serializable +class RefStartInsertHandler : InsertHandler, FrontendFriendlyInsertHandler { + override fun handleInsert(context: InsertionContext, item: LookupElement) { + JavaMethodCallInsertHandlerHelper.installRefStartKey(context, item) + } +} \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallInsertHandler.kt b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallInsertHandler.kt index c0dabbc755e3..4bf99e3a4704 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallInsertHandler.kt +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallInsertHandler.kt @@ -172,12 +172,6 @@ public class JavaMethodCallInsertHandler( } } -private class RefStartInsertHandler : InsertHandler { - override fun handleInsert(context: InsertionContext, item: LookupElement) { - JavaMethodCallInsertHandlerHelper.installRefStartKey(context, item) - } -} - private fun createDiamondInsertHandler(item: JavaMethodCallElement): InsertHandler? { val method = item.getObject().takeIf { it.isConstructor } ?: return null val containingClass = method.containingClass ?: return null