cleanup after code review
This commit is contained in:
+1
-1
@@ -75,7 +75,7 @@ internal class BeforeResolveHighlightingVisitor(private val holder: AnnotationHo
|
|||||||
override fun visitExpressionWithLabel(expression: KtExpressionWithLabel) {
|
override fun visitExpressionWithLabel(expression: KtExpressionWithLabel) {
|
||||||
val targetLabel = expression.getTargetLabel()
|
val targetLabel = expression.getTargetLabel()
|
||||||
if (targetLabel != null) {
|
if (targetLabel != null) {
|
||||||
NameHighlighter.highlightName(holder, targetLabel, KotlinHighlightingColors.LABEL)
|
holder.highlightName(targetLabel, KotlinHighlightingColors.LABEL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -89,7 +89,7 @@ internal class FunctionsHighlightingVisitor(holder: AnnotationHolder, bindingCon
|
|||||||
holder.highlightName(callee, CONSTRUCTOR_CALL)
|
holder.highlightName(callee, CONSTRUCTOR_CALL)
|
||||||
}
|
}
|
||||||
else if (calleeDescriptor is FunctionDescriptor) {
|
else if (calleeDescriptor is FunctionDescriptor) {
|
||||||
val color = when {
|
val attributesKey = when {
|
||||||
calleeDescriptor.extensionReceiverParameter != null ->
|
calleeDescriptor.extensionReceiverParameter != null ->
|
||||||
EXTENSION_FUNCTION_CALL
|
EXTENSION_FUNCTION_CALL
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ internal class FunctionsHighlightingVisitor(holder: AnnotationHolder, bindingCon
|
|||||||
FUNCTION_CALL
|
FUNCTION_CALL
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.highlightName(callee, color)
|
holder.highlightName(callee, attributesKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,22 +25,16 @@ import org.jetbrains.annotations.TestOnly
|
|||||||
object NameHighlighter {
|
object NameHighlighter {
|
||||||
var namesHighlightingEnabled = true
|
var namesHighlightingEnabled = true
|
||||||
@TestOnly set
|
@TestOnly set
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun highlightName(holder: AnnotationHolder, psiElement: PsiElement, attributesKey: TextAttributesKey) {
|
|
||||||
if (namesHighlightingEnabled) {
|
|
||||||
holder.createInfoAnnotation(psiElement, null).textAttributes = attributesKey
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun highlightName(holder: AnnotationHolder, textRange: TextRange, attributesKey: TextAttributesKey) {
|
|
||||||
if (namesHighlightingEnabled) {
|
|
||||||
holder.createInfoAnnotation(textRange, null).textAttributes = attributesKey
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AnnotationHolder.highlightName(element: PsiElement, attributesKey: TextAttributesKey) {
|
fun AnnotationHolder.highlightName(element: PsiElement, attributesKey: TextAttributesKey) {
|
||||||
NameHighlighter.highlightName(this, element, attributesKey)
|
if (NameHighlighter.namesHighlightingEnabled) {
|
||||||
|
createInfoAnnotation(element, null).textAttributes = attributesKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AnnotationHolder.highlightName(textRange: TextRange, attributesKey: TextAttributesKey) {
|
||||||
|
if (NameHighlighter.namesHighlightingEnabled) {
|
||||||
|
createInfoAnnotation(textRange, null).textAttributes = attributesKey
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -72,7 +72,7 @@ internal class PropertiesHighlightingVisitor(holder: AnnotationHolder, bindingCo
|
|||||||
elementToHighlight: PsiElement,
|
elementToHighlight: PsiElement,
|
||||||
descriptor: PropertyDescriptor) {
|
descriptor: PropertyDescriptor) {
|
||||||
|
|
||||||
val color = when {
|
val attributesKey = when {
|
||||||
descriptor.isDynamic() ->
|
descriptor.isDynamic() ->
|
||||||
DYNAMIC_PROPERTY_CALL
|
DYNAMIC_PROPERTY_CALL
|
||||||
|
|
||||||
@@ -85,6 +85,6 @@ internal class PropertiesHighlightingVisitor(holder: AnnotationHolder, bindingCo
|
|||||||
else ->
|
else ->
|
||||||
INSTANCE_PROPERTY
|
INSTANCE_PROPERTY
|
||||||
}
|
}
|
||||||
holder.highlightName(elementToHighlight, color)
|
holder.highlightName(elementToHighlight, attributesKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ internal class TypeKindHighlightingVisitor(holder: AnnotationHolder, bindingCont
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NameHighlighter.highlightName(holder, range, ANNOTATION)
|
holder.highlightName(range, ANNOTATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitTypeParameter(parameter: KtTypeParameter) {
|
override fun visitTypeParameter(parameter: KtTypeParameter) {
|
||||||
|
|||||||
Reference in New Issue
Block a user