diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/HighlightingVisitor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/HighlightingVisitor.kt
index 02dbb44c3b8..68177688eef 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/HighlightingVisitor.kt
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/HighlightingVisitor.kt
@@ -27,6 +27,14 @@ abstract class HighlightingVisitor protected constructor(
private val holder: AnnotationHolder
) : KtVisitorVoid() {
+ protected fun createInfoAnnotation(element: PsiElement, textAttributes: TextAttributesKey, message: String? = null) {
+ createInfoAnnotation(element.textRange, textAttributes, message)
+ }
+
+ protected fun createInfoAnnotation(range: TextRange, textAttributes: TextAttributesKey, message: String? = null) {
+ createInfoAnnotation(range, message).textAttributes = textAttributes
+ }
+
protected fun createInfoAnnotation(element: PsiElement, message: String? = null): Annotation =
createInfoAnnotation(element.textRange, message)
@@ -35,13 +43,13 @@ abstract class HighlightingVisitor protected constructor(
protected fun highlightName(element: PsiElement, attributesKey: TextAttributesKey, message: String? = null) {
if (NameHighlighter.namesHighlightingEnabled && !element.textRange.isEmpty) {
- createInfoAnnotation(element, message).textAttributes = attributesKey
+ createInfoAnnotation(element, attributesKey, message)
}
}
protected fun highlightName(textRange: TextRange, attributesKey: TextAttributesKey, message: String? = null) {
if (NameHighlighter.namesHighlightingEnabled) {
- createInfoAnnotation(textRange, message).textAttributes = attributesKey
+ createInfoAnnotation(textRange, attributesKey, message)
}
}
}
diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightingColors.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightingColors.java
index 697e802145d..ba9652cdd64 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightingColors.java
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightingColors.java
@@ -79,7 +79,7 @@ public class KotlinHighlightingColors {
public static final TextAttributesKey PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION = createTextAttributesKey("KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION", PACKAGE_PROPERTY);
// functions
- public static final TextAttributesKey FUNCTION_LITERAL_DEFAULT_PARAMETER = createTextAttributesKey("KOTLIN_CLOSURE_DEFAULT_PARAMETER");
+ public static final TextAttributesKey FUNCTION_LITERAL_DEFAULT_PARAMETER = createTextAttributesKey("KOTLIN_CLOSURE_DEFAULT_PARAMETER", PARAMETER);
public static final TextAttributesKey FUNCTION_DECLARATION = createTextAttributesKey("KOTLIN_FUNCTION_DECLARATION", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION);
public static final TextAttributesKey FUNCTION_CALL = createTextAttributesKey("KOTLIN_FUNCTION_CALL", DefaultLanguageHighlighterColors.FUNCTION_CALL);
public static final TextAttributesKey PACKAGE_FUNCTION_CALL = createTextAttributesKey("KOTLIN_PACKAGE_FUNCTION_CALL", DefaultLanguageHighlighterColors.STATIC_METHOD);
diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.kt
index 1a8e9e8c8a2..ab228cef8c9 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.kt
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.kt
@@ -42,14 +42,9 @@ internal class VariablesHighlightingVisitor(holder: AnnotationHolder, bindingCon
override fun visitSimpleNameExpression(expression: KtSimpleNameExpression) {
val target = bindingContext.get(REFERENCE_TARGET, expression) ?: return
- if (target is ValueParameterDescriptor) {
- if (bindingContext.get(AUTO_CREATED_IT, target) == true) {
- createInfoAnnotation(expression, "Automatically declared based on the expected type")
- .textAttributes = FUNCTION_LITERAL_DEFAULT_PARAMETER
- }
- }
-
- if (expression.parent !is KtValueArgumentName) { // highlighted separately
+ if (target is ValueParameterDescriptor && bindingContext.get(AUTO_CREATED_IT, target) == true) {
+ createInfoAnnotation(expression, FUNCTION_LITERAL_DEFAULT_PARAMETER, "Automatically declared based on the expected type")
+ } else if (expression.parent !is KtValueArgumentName) { // highlighted separately
highlightVariable(expression, target)
}
@@ -156,7 +151,7 @@ internal class VariablesHighlightingVisitor(holder: AnnotationHolder, bindingCon
val parent = elementToHighlight.parent
if (!(parent is PsiNameIdentifierOwner && parent.nameIdentifier == elementToHighlight)) {
- createInfoAnnotation(elementToHighlight, msg).textAttributes = WRAPPED_INTO_REF
+ createInfoAnnotation(elementToHighlight, WRAPPED_INTO_REF, msg)
return
}
}
diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceHighlightingTestGenerated.java b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceHighlightingTestGenerated.java
index 98e45a99221..52a497b4c44 100644
--- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceHighlightingTestGenerated.java
+++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/PerformanceHighlightingTestGenerated.java
@@ -33,6 +33,11 @@ public class PerformanceHighlightingTestGenerated extends AbstractPerformanceHig
runTest("idea/testData/highlighter/Annotations.kt");
}
+ @TestMetadata("AutoCreatedItParameter.kt")
+ public void testAutoCreatedItParameter() throws Exception {
+ runTest("idea/testData/highlighter/AutoCreatedItParameter.kt");
+ }
+
@TestMetadata("Destructuring.kt")
public void testDestructuring() throws Exception {
runTest("idea/testData/highlighter/Destructuring.kt");
diff --git a/idea/testData/highlighter/AutoCreatedItParameter.kt b/idea/testData/highlighter/AutoCreatedItParameter.kt
new file mode 100644
index 00000000000..f50f05c068b
--- /dev/null
+++ b/idea/testData/highlighter/AutoCreatedItParameter.kt
@@ -0,0 +1,10 @@
+fun test() {
+ val vect = MyIterable<Int>()
+ vect.filter { it != 2 }.forEach { it.toString() }
+}
+
+class MyIterable<T> {
+ fun filter(function: (T) -> Boolean) = this
+ fun forEach(action: (T) -> Unit) {
+ }
+}
diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingTestGenerated.java
index c8de1c7d178..13fda2a8c79 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingTestGenerated.java
@@ -33,6 +33,11 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
runTest("idea/testData/highlighter/Annotations.kt");
}
+ @TestMetadata("AutoCreatedItParameter.kt")
+ public void testAutoCreatedItParameter() throws Exception {
+ runTest("idea/testData/highlighter/AutoCreatedItParameter.kt");
+ }
+
@TestMetadata("Destructuring.kt")
public void testDestructuring() throws Exception {
runTest("idea/testData/highlighter/Destructuring.kt");