Fix parameter info presentation with regard to DeprecatedSinceKotlin
This commit is contained in:
@@ -1117,6 +1117,8 @@ public abstract class KotlinBuiltIns {
|
|||||||
return classFqNameEquals(descriptor, FQ_NAMES.cloneable);
|
return classFqNameEquals(descriptor, FQ_NAMES.cloneable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function only checks presence of Deprecated annotation at declaration-site, it doesn't take into account @DeprecatedSinceKotlin
|
||||||
|
// To check that a referenced descriptor is actually deprecated at call-site, use DeprecationResolver
|
||||||
public static boolean isDeprecated(@NotNull DeclarationDescriptor declarationDescriptor) {
|
public static boolean isDeprecated(@NotNull DeclarationDescriptor declarationDescriptor) {
|
||||||
if (declarationDescriptor.getOriginal().getAnnotations().hasAnnotation(FQ_NAMES.deprecated)) return true;
|
if (declarationDescriptor.getOriginal().getAnnotations().hasAnnotation(FQ_NAMES.deprecated)) return true;
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -33,6 +33,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.resolve.frontendService
|
||||||
import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter
|
import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter
|
||||||
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
@@ -51,6 +52,7 @@ import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue
|
|||||||
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
|
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
|
||||||
|
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
|
||||||
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.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
@@ -278,9 +280,7 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
|||||||
|
|
||||||
val color = if (itemToShow.isResolvedToDescriptor) GREEN_BACKGROUND else context.defaultParameterColor
|
val color = if (itemToShow.isResolvedToDescriptor) GREEN_BACKGROUND else context.defaultParameterColor
|
||||||
|
|
||||||
val isDeprecated = KotlinBuiltIns.isDeprecated(substitutedDescriptor)
|
context.setupUIComponentPresentation(text, boldStartOffset, boldEndOffset, isGrey, itemToShow.isDeprecatedAtCallSite, false, color)
|
||||||
|
|
||||||
context.setupUIComponentPresentation(text, boldStartOffset, boldEndOffset, isGrey, isDeprecated, false, color)
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -373,7 +373,8 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
|||||||
var dummyArgument: ValueArgument? = null,
|
var dummyArgument: ValueArgument? = null,
|
||||||
var dummyResolvedCall: ResolvedCall<FunctionDescriptor>? = null,
|
var dummyResolvedCall: ResolvedCall<FunctionDescriptor>? = null,
|
||||||
var isResolvedToDescriptor: Boolean = false,
|
var isResolvedToDescriptor: Boolean = false,
|
||||||
var isGreyArgumentIndex: Int = -1
|
var isGreyArgumentIndex: Int = -1,
|
||||||
|
var isDeprecatedAtCallSite: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun resolveCallInfo(
|
private fun resolveCallInfo(
|
||||||
@@ -417,6 +418,8 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
|||||||
!argument.hasError(bindingContext) /* ignore arguments that have error type */
|
!argument.hasError(bindingContext) /* ignore arguments that have error type */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isDeprecated = resolutionFacade.frontendService<DeprecationResolver>().getDeprecations(resultingDescriptor).isNotEmpty()
|
||||||
|
|
||||||
with(info) {
|
with(info) {
|
||||||
this.call = call
|
this.call = call
|
||||||
this.resolvedCall = resolvedCall
|
this.resolvedCall = resolvedCall
|
||||||
@@ -425,6 +428,7 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
|||||||
this.dummyResolvedCall = dummyResolvedCall
|
this.dummyResolvedCall = dummyResolvedCall
|
||||||
this.isResolvedToDescriptor = resolvedToDescriptor
|
this.isResolvedToDescriptor = resolvedToDescriptor
|
||||||
this.isGreyArgumentIndex = isGreyArgumentIndex
|
this.isGreyArgumentIndex = isGreyArgumentIndex
|
||||||
|
this.isDeprecatedAtCallSite = isDeprecated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@Suppress("DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE")
|
||||||
|
@Deprecated("")
|
||||||
|
@DeprecatedSinceKotlin(warningSince = "1.0")
|
||||||
|
fun f(x: Int) {}
|
||||||
|
|
||||||
|
fun d(x: Int) {
|
||||||
|
f(<caret>1)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Text: (<highlight>x: Int</highlight>), Disabled: false, Strikeout: true, Green: true
|
||||||
|
*/
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
@Suppress("DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE")
|
||||||
|
@Deprecated("")
|
||||||
|
@DeprecatedSinceKotlin(warningSince = "1.9")
|
||||||
|
fun f(x: Int) {}
|
||||||
|
|
||||||
|
fun d(x: Int) {
|
||||||
|
f(<caret>1)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Text: (<highlight>x: Int</highlight>), Disabled: false, Strikeout: false, Green: true
|
||||||
|
*/
|
||||||
+10
@@ -121,6 +121,16 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
|||||||
runTest("idea/testData/parameterInfo/functionCall/Deprecated.kt");
|
runTest("idea/testData/parameterInfo/functionCall/Deprecated.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("deprecatedSinceKotlinApplicable.kt")
|
||||||
|
public void testDeprecatedSinceKotlinApplicable() throws Exception {
|
||||||
|
runTest("idea/testData/parameterInfo/functionCall/deprecatedSinceKotlinApplicable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("deprecatedSinceKotlinNotApplicable.kt")
|
||||||
|
public void testDeprecatedSinceKotlinNotApplicable() throws Exception {
|
||||||
|
runTest("idea/testData/parameterInfo/functionCall/deprecatedSinceKotlinNotApplicable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ExtensionOnCapturedScopeChange.kt")
|
@TestMetadata("ExtensionOnCapturedScopeChange.kt")
|
||||||
public void testExtensionOnCapturedScopeChange() throws Exception {
|
public void testExtensionOnCapturedScopeChange() throws Exception {
|
||||||
runTest("idea/testData/parameterInfo/functionCall/ExtensionOnCapturedScopeChange.kt");
|
runTest("idea/testData/parameterInfo/functionCall/ExtensionOnCapturedScopeChange.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user