highlight infix function calls
#KT-6540 Fixed
This commit is contained in:
+20
-3
@@ -17,7 +17,9 @@
|
|||||||
package org.jetbrains.kotlin.idea.highlighter
|
package org.jetbrains.kotlin.idea.highlighter
|
||||||
|
|
||||||
import com.intellij.lang.annotation.AnnotationHolder
|
import com.intellij.lang.annotation.AnnotationHolder
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.builtins.isFunctionTypeOrSubtype
|
import org.jetbrains.kotlin.builtins.isFunctionTypeOrSubtype
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
@@ -26,6 +28,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
||||||
|
|
||||||
@@ -47,10 +50,27 @@ internal class FunctionsHighlightingVisitor(holder: AnnotationHolder, bindingCon
|
|||||||
super.visitSuperTypeCallEntry(call)
|
super.visitSuperTypeCallEntry(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitBinaryExpression(expression: KtBinaryExpression) {
|
||||||
|
if (expression.operationReference.getIdentifier() != null) {
|
||||||
|
val resolvedCall = expression.getResolvedCall(bindingContext)
|
||||||
|
if (resolvedCall != null) {
|
||||||
|
highlightCall(expression.operationReference, resolvedCall)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.visitBinaryExpression(expression)
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitCallExpression(expression: KtCallExpression) {
|
override fun visitCallExpression(expression: KtCallExpression) {
|
||||||
val callee = expression.calleeExpression
|
val callee = expression.calleeExpression
|
||||||
val resolvedCall = expression.getResolvedCall(bindingContext)
|
val resolvedCall = expression.getResolvedCall(bindingContext)
|
||||||
if (callee is KtReferenceExpression && resolvedCall != null) {
|
if (callee is KtReferenceExpression && resolvedCall != null) {
|
||||||
|
highlightCall(callee, resolvedCall)
|
||||||
|
}
|
||||||
|
|
||||||
|
super.visitCallExpression(expression)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun highlightCall(callee: PsiElement, resolvedCall: ResolvedCall<out CallableDescriptor>) {
|
||||||
val calleeDescriptor = resolvedCall.resultingDescriptor
|
val calleeDescriptor = resolvedCall.resultingDescriptor
|
||||||
|
|
||||||
if (calleeDescriptor.isDynamic()) {
|
if (calleeDescriptor.isDynamic()) {
|
||||||
@@ -84,7 +104,4 @@ internal class FunctionsHighlightingVisitor(holder: AnnotationHolder, bindingCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.visitCallExpression(expression)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -8,10 +8,15 @@ fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">global</info>() {
|
|||||||
fun <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">ext</info>() {
|
fun <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">ext</info>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">infix</info> fun <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">fif</info>(<info textAttributesKey="KOTLIN_PARAMETER">y</info>: <info textAttributesKey="KOTLIN_CLASS">Int</info>) {
|
||||||
|
this * <info textAttributesKey="KOTLIN_PARAMETER">y</info>
|
||||||
|
}
|
||||||
|
|
||||||
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">open</info> class <info textAttributesKey="KOTLIN_CLASS">Container</info> {
|
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">open</info> class <info textAttributesKey="KOTLIN_CLASS">Container</info> {
|
||||||
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">open</info> fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">member</info>() {
|
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">open</info> fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">member</info>() {
|
||||||
<info textAttributesKey="KOTLIN_PACKAGE_FUNCTION_CALL">global</info>()
|
<info textAttributesKey="KOTLIN_PACKAGE_FUNCTION_CALL">global</info>()
|
||||||
5.<info textAttributesKey="KOTLIN_EXTENSION_FUNCTION_CALL">ext</info>()
|
5.<info textAttributesKey="KOTLIN_EXTENSION_FUNCTION_CALL">ext</info>()
|
||||||
<info textAttributesKey="KOTLIN_FUNCTION_CALL">member</info>()
|
<info textAttributesKey="KOTLIN_FUNCTION_CALL">member</info>()
|
||||||
|
5 <info textAttributesKey="KOTLIN_EXTENSION_FUNCTION_CALL">fif</info> 6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user