Fix blinking parameter info popup for nested places (KT-29574)
#KT-29574 Fixed
This commit is contained in:
+12
-2
@@ -103,6 +103,15 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
||||
@JvmField
|
||||
val GREEN_BACKGROUND: Color = JBColor(Color(231, 254, 234), Gray._100)
|
||||
|
||||
val STOP_SEARCH_CLASSES: Set<Class<out KtElement>> = setOf(
|
||||
KtNamedFunction::class.java,
|
||||
KtVariableDeclaration::class.java,
|
||||
KtValueArgumentList::class.java,
|
||||
KtLambdaArgument::class.java,
|
||||
KtContainerNode::class.java,
|
||||
KtTypeArgumentList::class.java
|
||||
)
|
||||
|
||||
private val RENDERER = DescriptorRenderer.SHORT_NAMES_IN_TYPES.withOptions {
|
||||
enhancedTypes = true
|
||||
renderUnabbreviatedType = false
|
||||
@@ -115,7 +124,7 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
||||
|
||||
override fun getActualParameterDelimiterType(): KtSingleValueToken = KtTokens.COMMA
|
||||
|
||||
override fun getArgListStopSearchClasses() = setOf(KtNamedFunction::class.java, KtVariableDeclaration::class.java)
|
||||
override fun getArgListStopSearchClasses(): Set<Class<out KtElement>> = STOP_SEARCH_CLASSES
|
||||
|
||||
override fun getArgumentListClass() = argumentListClass.java
|
||||
|
||||
@@ -141,7 +150,8 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
||||
val file = context.file as? KtFile ?: return null
|
||||
|
||||
val token = file.findElementAt(context.offset) ?: return null
|
||||
val argumentList = PsiTreeUtil.getParentOfType(token, argumentListClass.java, true, KtValueArgumentList::class.java) ?: return null
|
||||
val argumentList = PsiTreeUtil.getParentOfType(token, argumentListClass.java, true, *STOP_SEARCH_CLASSES.toTypedArray())
|
||||
?: return null
|
||||
|
||||
val bindingContext = argumentList.analyze(BodyResolveMode.PARTIAL)
|
||||
val call = findCall(argumentList, bindingContext) ?: return null
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Possible parameter info, for index, lambda and arguments.
|
||||
// Test is flaky without the fix. In IDEA there's a blinking without the fix with different popups.
|
||||
|
||||
fun foo(a: A) {
|
||||
a.subscribe(object : L {
|
||||
override fun on() {
|
||||
withLambda {
|
||||
<caret>arrayOf(1)[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun withLambda(a: (Int) -> Unit) {}
|
||||
|
||||
interface L {
|
||||
fun on()
|
||||
}
|
||||
|
||||
class A {
|
||||
fun subscribe(listener: L) {}
|
||||
}
|
||||
|
||||
/*
|
||||
Text: (<highlight>a: (Int) -> Unit</highlight>), Disabled: false, Strikeout: false, Green: true
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Possible parameter info, for index, lambda and arguments.
|
||||
// Test is flaky without the fix. In IDEA there's a blinking without the fix with different popups.
|
||||
|
||||
fun foo(a: A) {
|
||||
a.subscribe(object : L {
|
||||
override fun on() {
|
||||
withLambda {
|
||||
bar<<caret>>()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun withLambda(a: (Int) -> Unit) {}
|
||||
fun <T> bar() {}
|
||||
|
||||
interface L {
|
||||
fun on()
|
||||
}
|
||||
|
||||
class A {
|
||||
fun subscribe(listener: L) {}
|
||||
}
|
||||
|
||||
/*
|
||||
Text: (<highlight>T</highlight>), Disabled: false, Strikeout: false, Green: false
|
||||
*/
|
||||
+10
@@ -107,6 +107,11 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/functionCall"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("Conflicting.kt")
|
||||
public void testConflicting() throws Exception {
|
||||
runTest("idea/testData/parameterInfo/functionCall/Conflicting.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("DefaultValuesFromLib.kt")
|
||||
public void testDefaultValuesFromLib() throws Exception {
|
||||
runTest("idea/testData/parameterInfo/functionCall/DefaultValuesFromLib.kt");
|
||||
@@ -370,6 +375,11 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
||||
runTest("idea/testData/parameterInfo/typeArguments/BaseClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ConflictingWithArgument.kt")
|
||||
public void testConflictingWithArgument() throws Exception {
|
||||
runTest("idea/testData/parameterInfo/typeArguments/ConflictingWithArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Constraints.kt")
|
||||
public void testConstraints() throws Exception {
|
||||
runTest("idea/testData/parameterInfo/typeArguments/Constraints.kt");
|
||||
|
||||
Reference in New Issue
Block a user