Don't highlight entire complex callee expression as call

If an expression returns something that has invoke() defined on it,
this entire expression can act as a callee. If we highlight it, this
will suppress more useful highlighting such as string literals.

 #KT-16159 Fixed
This commit is contained in:
Dmitry Jemerov
2017-05-09 11:04:59 +02:00
parent 5d9307024a
commit d1893cfa5f
4 changed files with 16 additions and 2 deletions
@@ -63,7 +63,7 @@ internal class FunctionsHighlightingVisitor(holder: AnnotationHolder, bindingCon
override fun visitCallExpression(expression: KtCallExpression) {
val callee = expression.calleeExpression
val resolvedCall = expression.getResolvedCall(bindingContext)
if (callee is KtReferenceExpression && resolvedCall != null) {
if (callee is KtReferenceExpression && callee !is KtCallExpression && resolvedCall != null) {
highlightCall(callee, resolvedCall)
}
+8
View File
@@ -0,0 +1,8 @@
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">test</info>() {
<info textAttributesKey="KOTLIN_CONSTRUCTOR">Test</info>("text", "text")() // BUG
}
class <info textAttributesKey="KOTLIN_CLASS">Test</info>(val <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">x</info>: <info textAttributesKey="KOTLIN_CLASS">String</info>, val <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">y</info>: <info textAttributesKey="KOTLIN_CLASS">String</info>) {
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">operator</info> fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">invoke</info>() {
}
}
@@ -66,6 +66,12 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
doTest(fileName);
}
@TestMetadata("InvokeCall.kt")
public void testInvokeCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/highlighter/InvokeCall.kt");
doTest(fileName);
}
@TestMetadata("JavaTypes.kt")
public void testJavaTypes() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/highlighter/JavaTypes.kt");
@@ -151,7 +151,7 @@ public class TagsTestDataUtil {
highlightInfo.getDescription());
}
else {
return String.format("textAttributesKey=\"%s\"", getName());
return String.format("textAttributesKey=\"%s\"", highlightInfo.forcedTextAttributesKey);
}
}
else {