'it' parameter highlighting fixed for chain usage.
#KT-31037 Fixed
This commit is contained in:
committed by
Vladimir Ilmov
parent
fb9fb2e048
commit
46423443e9
+10
-2
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+4
-9
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user