Don't highlight declaration with WRAPPED_INTO_REF

Leave highlighting only for usage. This may allow to make highlighting more local and lazy.
Java follows the same rules for "Implicit anonymous class parameter".
This commit is contained in:
Nikolay Krasko
2016-08-31 20:32:35 +03:00
parent f797d53343
commit 795fef20d7
8 changed files with 34 additions and 30 deletions
@@ -25,8 +25,6 @@ class KotlinChangeLocalityDetector : ChangeLocalityDetector {
override fun getChangeHighlightingDirtyScopeFor(element: PsiElement): PsiElement? {
val parent = element.parent
if (element is KtBlockExpression && parent is KtNamedFunction && parent.name != null) {
// Do nothing for local functions because of at least WRAPPED_INTO_REF highlighting
if (parent.parents.all { it is KtClassBody || it is KtClassOrObject || it is KtFile || it is KtScript }) {
return parent
}
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.highlighter
import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiNameIdentifierOwner
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
@@ -145,7 +146,11 @@ internal class VariablesHighlightingVisitor(holder: AnnotationHolder, bindingCon
"Wrapped into a reference object to be modified when captured in a closure"
else
"Value captured in a closure"
holder.createInfoAnnotation(elementToHighlight, msg).textAttributes = WRAPPED_INTO_REF
val parent = elementToHighlight.parent
if (!(parent is PsiNameIdentifierOwner && parent.nameIdentifier == elementToHighlight)) {
holder.createInfoAnnotation(elementToHighlight, msg).textAttributes = WRAPPED_INTO_REF
}
}
if (descriptor is LocalVariableDescriptor && descriptor !is SyntheticFieldDescriptor) {