From 92224ebfba129730bd0dd3f5987f114c188fb126 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 27 Dec 2019 16:37:25 +0300 Subject: [PATCH] [groovy] pull up #buildCastFix implementation from ConstructorCallHighlighter to CallReferenceHighlighter GitOrigin-RevId: 0d717dea6eddd26ee370697109550a32dafa69cc --- .../type/highlighting/CallReferenceHighlighter.kt | 9 ++++++++- .../type/highlighting/ConstructorCallHighlighter.kt | 11 ----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/highlighting/CallReferenceHighlighter.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/highlighting/CallReferenceHighlighter.kt index 9a77fda06b78..df506a37e3fd 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/highlighting/CallReferenceHighlighter.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/highlighting/CallReferenceHighlighter.kt @@ -138,5 +138,12 @@ abstract class CallReferenceHighlighter(protected val reference: GroovyCallRefer } } - protected open fun buildCastFix(argument: ExpressionArgument, expectedType: PsiType): LocalQuickFix? = null + protected open fun buildCastFix(argument: ExpressionArgument, expectedType: PsiType): LocalQuickFix? { + val arguments = reference.arguments ?: return null + val position = arguments.indexOf(argument) + if (position < 0) { + return null + } + return ParameterCastFix(argument.expression, position, expectedType) + } } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/highlighting/ConstructorCallHighlighter.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/highlighting/ConstructorCallHighlighter.kt index d1c42dddca93..350cff281f3b 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/highlighting/ConstructorCallHighlighter.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/highlighting/ConstructorCallHighlighter.kt @@ -1,14 +1,12 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.codeInspection.type.highlighting -import com.intellij.codeInspection.LocalQuickFix import com.intellij.psi.PsiType import org.jetbrains.plugins.groovy.GroovyBundle import org.jetbrains.plugins.groovy.highlighting.HighlightSink import org.jetbrains.plugins.groovy.lang.psi.api.GroovyMethodResult import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.DefaultConstructor import org.jetbrains.plugins.groovy.lang.resolve.api.Arguments -import org.jetbrains.plugins.groovy.lang.resolve.api.ExpressionArgument import org.jetbrains.plugins.groovy.lang.resolve.api.GroovyCallReference abstract class ConstructorCallHighlighter(reference: GroovyCallReference, sink: HighlightSink) : CallReferenceHighlighter(reference, sink) { @@ -25,14 +23,5 @@ abstract class ConstructorCallHighlighter(reference: GroovyCallReference, sink: } } - override fun buildCastFix(argument: ExpressionArgument, expectedType: PsiType): LocalQuickFix? { - val arguments = reference.arguments ?: return null - val position = arguments.indexOf(argument) - if (position < 0) { - return null - } - return ParameterCastFix(argument.expression, position, expectedType) - } - fun highlight(): Boolean = highlightMethodApplicability() }