KT-16999: Fix duplicates in parameter info
Use ShadowedDeclarationFilter in Parameter Info #KT-16999 fixed
This commit is contained in:
+13
-2
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
|||||||
import org.jetbrains.kotlin.idea.core.OptionalParametersHelper
|
import org.jetbrains.kotlin.idea.core.OptionalParametersHelper
|
||||||
import org.jetbrains.kotlin.idea.core.resolveCandidates
|
import org.jetbrains.kotlin.idea.core.resolveCandidates
|
||||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||||
|
import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.load.java.sam.SamAdapterDescriptor
|
import org.jetbrains.kotlin.load.java.sam.SamAdapterDescriptor
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
@@ -47,6 +48,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
|||||||
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
|
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.isError
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.containsError
|
import org.jetbrains.kotlin.types.typeUtil.containsError
|
||||||
@@ -117,9 +119,18 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
|||||||
val bindingContext = argumentList.analyze(BodyResolveMode.PARTIAL)
|
val bindingContext = argumentList.analyze(BodyResolveMode.PARTIAL)
|
||||||
val call = findCall(argumentList, bindingContext) ?: return null
|
val call = findCall(argumentList, bindingContext) ?: return null
|
||||||
|
|
||||||
val candidates = call.resolveCandidates(bindingContext, file.getResolutionFacade())
|
val resolutionFacade = file.getResolutionFacade()
|
||||||
|
val candidates =
|
||||||
|
call.resolveCandidates(bindingContext, resolutionFacade)
|
||||||
|
.map { it.resultingDescriptor }
|
||||||
|
.distinctBy { it.original }
|
||||||
|
|
||||||
context.itemsToShow = candidates.map { it.resultingDescriptor.original }.distinct().toTypedArray()
|
val shadowedDeclarationsFilter = ShadowedDeclarationsFilter(bindingContext,
|
||||||
|
resolutionFacade,
|
||||||
|
call.callElement,
|
||||||
|
call.explicitReceiver as? ReceiverValue)
|
||||||
|
|
||||||
|
context.itemsToShow = shadowedDeclarationsFilter.filter(candidates).toTypedArray()
|
||||||
return argumentList
|
return argumentList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
class A
|
||||||
|
|
||||||
|
fun some() {
|
||||||
|
A().toString(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Text: (<no parameters>), Disabled: false, Strikeout: false, Green: true
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
fun A.some(s: String) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class A {
|
||||||
|
private fun some(s: String) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage() {
|
||||||
|
// private some shadows extension
|
||||||
|
some("lol"<caret>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Text: (<highlight>s: String</highlight>), Disabled: false, Strikeout: false, Green: true
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
// WITH_RUNTIME
|
|
||||||
// See KT-14484
|
// See KT-14484
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
@@ -10,6 +9,5 @@ class C {
|
|||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Text: (other: Any?), Disabled: true, Strikeout: false, Green: true
|
Text: (other: Any?), Disabled: true, Strikeout: false, Green: true
|
||||||
Text: (other: String?, <highlight>ignoreCase: Boolean = ...</highlight>), Disabled: false, Strikeout: false, Green: false
|
|
||||||
Text: (other: String?, <highlight>ignoreCase: Boolean = false</highlight>), Disabled: false, Strikeout: false, Green: false
|
Text: (other: String?, <highlight>ignoreCase: Boolean = false</highlight>), Disabled: false, Strikeout: false, Green: false
|
||||||
*/
|
*/
|
||||||
@@ -185,6 +185,18 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoShadowedDeclarations.kt")
|
||||||
|
public void testNoShadowedDeclarations() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NoShadowedDeclarations.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoShadowedDeclarations2.kt")
|
||||||
|
public void testNoShadowedDeclarations2() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NoShadowedDeclarations2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NoSynthesizedParameterNames.kt")
|
@TestMetadata("NoSynthesizedParameterNames.kt")
|
||||||
public void testNoSynthesizedParameterNames() throws Exception {
|
public void testNoSynthesizedParameterNames() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NoSynthesizedParameterNames.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NoSynthesizedParameterNames.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user