Removed tooltip for variable as function(-like) call.
This commit is contained in:
@@ -66,11 +66,13 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
|||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall =
|
ResolvedCall<? extends CallableDescriptor> resolvedCall =
|
||||||
bindingContext.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
|
bindingContext.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
|
||||||
if (resolvedCall != null) {
|
if (resolvedCall != null) {
|
||||||
|
DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
|
||||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||||
highlightVariableAsFunctionCall(callee, (VariableAsFunctionResolvedCall) resolvedCall);
|
JetPsiChecker.highlightName(holder, callee, containedInFunctionClassOrSubclass(calleeDescriptor)
|
||||||
|
? JetHighlightingColors.VARIABLE_AS_FUNCTION_CALL
|
||||||
|
: JetHighlightingColors.VARIABLE_AS_FUNCTION_LIKE_CALL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
|
|
||||||
if (calleeDescriptor instanceof ConstructorDescriptor) {
|
if (calleeDescriptor instanceof ConstructorDescriptor) {
|
||||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.CONSTRUCTOR_CALL);
|
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.CONSTRUCTOR_CALL);
|
||||||
}
|
}
|
||||||
@@ -91,25 +93,6 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
|||||||
super.visitCallExpression(expression);
|
super.visitCallExpression(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void highlightVariableAsFunctionCall(JetExpression callee, VariableAsFunctionResolvedCall resolvedCall) {
|
|
||||||
VariableDescriptor variableDescriptor = resolvedCall.getVariableCall().getResultingDescriptor();
|
|
||||||
|
|
||||||
String kind = variableDescriptor instanceof ValueParameterDescriptor
|
|
||||||
? "parameter"
|
|
||||||
: variableDescriptor instanceof PropertyDescriptor
|
|
||||||
? "property"
|
|
||||||
: "variable";
|
|
||||||
|
|
||||||
if (containedInFunctionClassOrSubclass(resolvedCall.getFunctionCall().getResultingDescriptor())) {
|
|
||||||
holder.createInfoAnnotation(callee, "Calling " + kind + " as function").setTextAttributes(
|
|
||||||
JetHighlightingColors.VARIABLE_AS_FUNCTION_CALL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.createInfoAnnotation(callee, "Calling " + kind + " as function-like").setTextAttributes(
|
|
||||||
JetHighlightingColors.VARIABLE_AS_FUNCTION_LIKE_CALL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean containedInFunctionClassOrSubclass(DeclarationDescriptor calleeDescriptor) {
|
private static boolean containedInFunctionClassOrSubclass(DeclarationDescriptor calleeDescriptor) {
|
||||||
DeclarationDescriptor parent = calleeDescriptor.getContainingDeclaration();
|
DeclarationDescriptor parent = calleeDescriptor.getContainingDeclaration();
|
||||||
if (!(parent instanceof ClassDescriptor)) {
|
if (!(parent instanceof ClassDescriptor)) {
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
class FunctionLike {
|
|
||||||
fun invoke() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val <info>property</info> = {}
|
|
||||||
|
|
||||||
fun foo(param: (Int) -> Int, functionLike: FunctionLike) {
|
|
||||||
<info descr="Calling parameter as function">param</info>(1)
|
|
||||||
<info descr="Calling parameter as function-like">functionLike</info>()
|
|
||||||
|
|
||||||
val v1 = param
|
|
||||||
var v2 = param
|
|
||||||
|
|
||||||
<info descr="Calling variable as function">v1</info>(1)
|
|
||||||
<info descr="Calling variable as function">v2</info>(1)
|
|
||||||
|
|
||||||
<info descr="Calling property as function">property</info>();
|
|
||||||
|
|
||||||
{}() //should not be highlighted as "calling variable as function"
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
trait <info textAttributesKey="KOTLIN_TRAIT">FunctionLike</info> {
|
||||||
|
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">invoke</info>() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var <info textAttributesKey="KOTLIN_NAMESPACE_PROPERTY"><info textAttributesKey="KOTLIN_PROPERTY_WITH_BACKING_FIELD"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">global</info></info></info> : () -> <info textAttributesKey="KOTLIN_CLASS">Unit</info> = {}
|
var <info textAttributesKey="KOTLIN_NAMESPACE_PROPERTY"><info textAttributesKey="KOTLIN_PROPERTY_WITH_BACKING_FIELD"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">global</info></info></info> : () -> <info textAttributesKey="KOTLIN_CLASS">Unit</info> = {}
|
||||||
|
|
||||||
val <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY"><info textAttributesKey="KOTLIN_NAMESPACE_PROPERTY">ext</info></info> : () -> <info textAttributesKey="KOTLIN_CLASS">Unit</info>
|
val <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY"><info textAttributesKey="KOTLIN_NAMESPACE_PROPERTY">ext</info></info> : () -> <info textAttributesKey="KOTLIN_CLASS">Unit</info>
|
||||||
@@ -5,8 +10,11 @@ val <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="K
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">foo</info>(<info textAttributesKey="KOTLIN_PARAMETER">a</info> : () -> <info textAttributesKey="KOTLIN_CLASS">Unit</info>) {
|
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">foo</info>(<info textAttributesKey="KOTLIN_PARAMETER">a</info> : () -> <info textAttributesKey="KOTLIN_CLASS">Unit</info>, <info textAttributesKey="KOTLIN_PARAMETER">functionLike</info>: <info textAttributesKey="KOTLIN_TRAIT">FunctionLike</info>) {
|
||||||
<info textAttributesKey="KOTLIN_PARAMETER"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION">a</info></info>()
|
<info textAttributesKey="KOTLIN_PARAMETER"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION">a</info></info>()
|
||||||
|
<info textAttributesKey="KOTLIN_PARAMETER"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION_LIKE">functionLike</info></info>()
|
||||||
<info textAttributesKey="KOTLIN_NAMESPACE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION">global</info></info></info>()
|
<info textAttributesKey="KOTLIN_NAMESPACE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION">global</info></info></info>()
|
||||||
1.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY"><info textAttributesKey="KOTLIN_NAMESPACE_PROPERTY"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION">ext</info></info></info>()
|
1.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY"><info textAttributesKey="KOTLIN_NAMESPACE_PROPERTY"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION">ext</info></info></info>();
|
||||||
|
|
||||||
|
{}() //should not be highlighted as "calling variable as function"!
|
||||||
}
|
}
|
||||||
@@ -422,11 +422,6 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
|
|||||||
doTestWithInfos("idea/testData/checker/infos/PropertiesWithBackingFields.kt");
|
doTestWithInfos("idea/testData/checker/infos/PropertiesWithBackingFields.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("VariableAsFunction.kt")
|
|
||||||
public void testVariableAsFunction() throws Exception {
|
|
||||||
doTestWithInfos("idea/testData/checker/infos/VariableAsFunction.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("WrapIntoRef.kt")
|
@TestMetadata("WrapIntoRef.kt")
|
||||||
public void testWrapIntoRef() throws Exception {
|
public void testWrapIntoRef() throws Exception {
|
||||||
doTestWithInfos("idea/testData/checker/infos/WrapIntoRef.kt");
|
doTestWithInfos("idea/testData/checker/infos/WrapIntoRef.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user