KT-8794 Parameter Information should work in index expression
#KT-8794 Fixed
This commit is contained in:
@@ -280,6 +280,15 @@ public class CallResolver {
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveFunctionCall(@NotNull BasicCallResolutionContext context) {
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
|
||||
|
||||
Call.CallType callType = context.call.getCallType();
|
||||
if (callType == Call.CallType.ARRAY_GET_METHOD || callType == Call.CallType.ARRAY_SET_METHOD) {
|
||||
Name name = Name.identifier(callType == Call.CallType.ARRAY_GET_METHOD ? "get" : "set");
|
||||
JetArrayAccessExpression arrayAccessExpression = (JetArrayAccessExpression) context.call.getCallElement();
|
||||
return computeTasksAndResolveCall(
|
||||
context, name, arrayAccessExpression,
|
||||
CallableDescriptorCollectors.FUNCTIONS_AND_VARIABLES, CallTransformer.FUNCTION_CALL_TRANSFORMER);
|
||||
}
|
||||
|
||||
JetExpression calleeExpression = context.call.getCalleeExpression();
|
||||
if (calleeExpression instanceof JetSimpleNameExpression) {
|
||||
JetSimpleNameExpression expression = (JetSimpleNameExpression) calleeExpression;
|
||||
|
||||
@@ -79,7 +79,7 @@ import org.jetbrains.kotlin.idea.kdoc.AbstractKDocTypingTest
|
||||
import org.jetbrains.kotlin.idea.navigation.AbstractGotoSuperTest
|
||||
import org.jetbrains.kotlin.idea.navigation.AbstractKotlinGotoImplementationTest
|
||||
import org.jetbrains.kotlin.idea.navigation.AbstractKotlinGotoTest
|
||||
import org.jetbrains.kotlin.idea.parameterInfo.AbstractFunctionParameterInfoTest
|
||||
import org.jetbrains.kotlin.idea.parameterInfo.AbstractParameterInfoTest
|
||||
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiFileTest
|
||||
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest
|
||||
import org.jetbrains.kotlin.idea.refactoring.inline.AbstractInlineTest
|
||||
@@ -392,8 +392,8 @@ fun main(args: Array<String>) {
|
||||
model("navigation/gotoSuper", extension = "test")
|
||||
}
|
||||
|
||||
testClass<AbstractFunctionParameterInfoTest>() {
|
||||
model("parameterInfo/functionParameterInfo")
|
||||
testClass<AbstractParameterInfoTest>() {
|
||||
model("parameterInfo", recursive = true)
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinGotoTest>() {
|
||||
|
||||
@@ -341,6 +341,7 @@
|
||||
<qualifiedNameProvider implementation="org.jetbrains.kotlin.idea.actions.KotlinQualifiedNameProvider"/>
|
||||
|
||||
<codeInsight.parameterInfo language="kotlin" implementationClass="org.jetbrains.kotlin.idea.parameterInfo.KotlinFunctionParameterInfoHandler"/>
|
||||
<codeInsight.parameterInfo language="kotlin" implementationClass="org.jetbrains.kotlin.idea.parameterInfo.KotlinArrayAccessParameterInfoHandler"/>
|
||||
|
||||
<codeInsight.gotoSuper language="kotlin" implementationClass="org.jetbrains.kotlin.idea.codeInsight.GotoSuperActionHandler"/>
|
||||
<typeDeclarationProvider implementation="org.jetbrains.kotlin.idea.codeInsight.JetTypeDeclarationProvider"/>
|
||||
|
||||
+217
-186
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.lang.parameterInfo.*
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.ui.Gray
|
||||
import com.intellij.ui.JBColor
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
@@ -35,7 +36,10 @@ import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
|
||||
@@ -61,36 +65,69 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||
import org.jetbrains.kotlin.types.typeUtil.containsError
|
||||
import java.awt.Color
|
||||
import java.util.*
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupport<JetValueArgumentList, FunctionDescriptor, JetValueArgument> {
|
||||
|
||||
class KotlinFunctionParameterInfoHandler : KotlinParameterInfoWithCallHandlerBase<JetValueArgumentList, JetValueArgument>(JetValueArgumentList::class, JetValueArgument::class) {
|
||||
override fun getActualParameters(arguments: JetValueArgumentList) = arguments.arguments.toTypedArray()
|
||||
|
||||
override fun getActualParameterDelimiterType() = JetTokens.COMMA
|
||||
|
||||
override fun getActualParametersRBraceType() = JetTokens.RPAR
|
||||
|
||||
override fun getArgumentListAllowedParentClasses() = setOf(JetCallElement::class.java)
|
||||
}
|
||||
|
||||
class KotlinArrayAccessParameterInfoHandler : KotlinParameterInfoWithCallHandlerBase<JetContainerNode, JetExpression>(JetContainerNode::class, JetExpression::class) {
|
||||
override fun getArgumentListAllowedParentClasses() = setOf(JetArrayAccessExpression::class.java)
|
||||
|
||||
override fun getActualParameters(containerNode: JetContainerNode): Array<out JetExpression> = containerNode.allChildren.filterIsInstance<JetExpression>().toList().toTypedArray()
|
||||
|
||||
override fun getActualParametersRBraceType() = JetTokens.RBRACKET
|
||||
}
|
||||
|
||||
abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : JetElement, TArgument : JetElement>(
|
||||
private val argumentListClass: KClass<TArgumentList>,
|
||||
private val argumentClass: KClass<TArgument>
|
||||
) : ParameterInfoHandlerWithTabActionSupport<TArgumentList, FunctionDescriptor, TArgument> {
|
||||
|
||||
companion object {
|
||||
val GREEN_BACKGROUND: Color = JBColor(Color(231, 254, 234), Gray._100)
|
||||
}
|
||||
|
||||
private fun findCall(argumentList: TArgumentList, bindingContext: BindingContext): Call? {
|
||||
return (argumentList.parent as JetElement).getCall(bindingContext)
|
||||
}
|
||||
|
||||
override fun getActualParameterDelimiterType() = JetTokens.COMMA
|
||||
|
||||
override fun getArgListStopSearchClasses() = setOf(JetNamedFunction::class.java, JetVariableDeclaration::class.java)
|
||||
|
||||
override fun getArgumentListClass() = JetValueArgumentList::class.java
|
||||
override fun getArgumentListClass() = argumentListClass.java
|
||||
|
||||
override fun couldShowInLookup() = true
|
||||
override fun showParameterInfo(element: TArgumentList, context: CreateParameterInfoContext) {
|
||||
context.showHint(element, element.textRange.startOffset, this)
|
||||
}
|
||||
|
||||
override fun getParametersForLookup(item: LookupElement, context: ParameterInfoContext) = emptyArray<Any>() //todo: ?
|
||||
override fun findElementForUpdatingParameterInfo(context: UpdateParameterInfoContext): TArgumentList? {
|
||||
val element = context.file.findElementAt(context.offset) ?: return null
|
||||
val argumentList = PsiTreeUtil.getParentOfType(element, argumentListClass.java) ?: return null
|
||||
val argument = element.parents.takeWhile { it != argumentList }.lastOrNull()
|
||||
if (argument != null && !argumentClass.java.isInstance(argument)) {
|
||||
val arguments = getActualParameters(argumentList)
|
||||
val index = arguments.indexOf(element)
|
||||
context.setCurrentParameter(index)
|
||||
context.setHighlightedParameter(element)
|
||||
}
|
||||
return argumentList
|
||||
}
|
||||
|
||||
override fun getParametersForDocumentation(item: FunctionDescriptor, context: ParameterInfoContext) = emptyArray<Any>() //todo: ?
|
||||
|
||||
override fun findElementForParameterInfo(context: CreateParameterInfoContext): JetValueArgumentList? {
|
||||
override fun findElementForParameterInfo(context: CreateParameterInfoContext): TArgumentList? {
|
||||
//todo: calls to this constructors, when we will have auxiliary constructors
|
||||
val file = context.file as? JetFile ?: return null
|
||||
|
||||
val argumentList = file.findElementAt(context.offset)?.getStrictParentOfType<JetValueArgumentList>() ?: return null
|
||||
val token = file.findElementAt(context.offset) ?: return null
|
||||
val argumentList = PsiTreeUtil.getParentOfType(token, argumentListClass.java) ?: return null
|
||||
|
||||
val callElement = argumentList.parent as? JetCallElement ?: return null
|
||||
val bindingContext = callElement.analyze(BodyResolveMode.PARTIAL)
|
||||
val call = callElement.getCall(bindingContext) ?: return null
|
||||
val bindingContext = argumentList.analyze(BodyResolveMode.PARTIAL)
|
||||
val call = findCall(argumentList, bindingContext) ?: return null
|
||||
|
||||
val candidates = detectCandidates(call, bindingContext, file.getResolutionFacade())
|
||||
|
||||
@@ -98,23 +135,7 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
||||
return argumentList
|
||||
}
|
||||
|
||||
override fun showParameterInfo(element: JetValueArgumentList, context: CreateParameterInfoContext) {
|
||||
context.showHint(element, element.textRange.startOffset, this)
|
||||
}
|
||||
|
||||
override fun findElementForUpdatingParameterInfo(context: UpdateParameterInfoContext): JetValueArgumentList? {
|
||||
val element = context.file.findElementAt(context.offset) ?: return null
|
||||
val argumentList = element.getStrictParentOfType<JetValueArgumentList>() ?: return null
|
||||
val argument = element.parents.takeWhile { it != argumentList }.lastOrNull() as? JetValueArgument
|
||||
if (argument != null) {
|
||||
val index = argumentList.arguments.indexOf(element)
|
||||
context.setCurrentParameter(index)
|
||||
context.setHighlightedParameter(element)
|
||||
}
|
||||
return argumentList
|
||||
}
|
||||
|
||||
override fun updateParameterInfo(argumentList: JetValueArgumentList, context: UpdateParameterInfoContext) {
|
||||
override fun updateParameterInfo(argumentList: TArgumentList, context: UpdateParameterInfoContext) {
|
||||
if (context.parameterOwner !== argumentList) {
|
||||
context.removeHint()
|
||||
}
|
||||
@@ -126,10 +147,6 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
||||
context.setCurrentParameter(parameterIndex)
|
||||
}
|
||||
|
||||
override fun getParameterCloseChars() = ParameterInfoUtils.DEFAULT_PARAMETER_CLOSE_CHARS
|
||||
|
||||
override fun tracksParameterIndex() = true
|
||||
|
||||
override fun updateUI(itemToShow: FunctionDescriptor, context: ParameterInfoUIContext) {
|
||||
if (!updateUIOrFail(itemToShow, context)) {
|
||||
context.isUIComponentEnabled = false
|
||||
@@ -138,22 +155,21 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
||||
}
|
||||
|
||||
private fun updateUIOrFail(itemToShow: FunctionDescriptor, context: ParameterInfoUIContext): Boolean {
|
||||
//todo: when we will have ability to pass Array as vararg, implement such feature here too?
|
||||
if (context.parameterOwner == null || !context.parameterOwner.isValid) return false
|
||||
if (!argumentListClass.java.isInstance(context.parameterOwner)) return false
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val argumentList = context.parameterOwner as TArgumentList
|
||||
|
||||
val argumentList = context.parameterOwner as? JetValueArgumentList ?: return false
|
||||
val currentArgumentIndex = context.currentParameterIndex
|
||||
if (currentArgumentIndex < 0) return false // by some strange reason we are invoked with currentParameterIndex == -1 during initialization
|
||||
|
||||
val bindingContext = argumentList.analyze(BodyResolveMode.PARTIAL)
|
||||
val callElement = argumentList.parent as? JetCallElement ?: return false
|
||||
val call = callElement.getCall(bindingContext) ?: return false
|
||||
val call = findCall(argumentList, bindingContext) ?: return false
|
||||
|
||||
val project = callElement.project
|
||||
|
||||
val currentParameterIndex = context.currentParameterIndex
|
||||
if (currentParameterIndex < 0) return false // by some strange reason we are invoked with currentParameterIndex == -1 during initialization
|
||||
val project = argumentList.project
|
||||
|
||||
val (substitutedDescriptor, argumentToParameter, highlightParameterIndex, isGrey) = matchCallWithSignature(
|
||||
call, itemToShow, currentParameterIndex, bindingContext, argumentList.getResolutionFacade()
|
||||
call, itemToShow, currentArgumentIndex, bindingContext, argumentList.getResolutionFacade()
|
||||
) ?: return false
|
||||
|
||||
var boldStartOffset = -1
|
||||
@@ -162,6 +178,11 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
||||
val usedParameterIndices = HashSet<Int>()
|
||||
var namedMode = false
|
||||
|
||||
if (call.callType == Call.CallType.ARRAY_SET_METHOD) {
|
||||
// for set-operator the last parameter is used for the value assigned
|
||||
usedParameterIndices.add(substitutedDescriptor.valueParameters.lastIndex)
|
||||
}
|
||||
|
||||
fun appendParameter(parameter: ValueParameterDescriptor) {
|
||||
if (length() > 0) {
|
||||
append(", ")
|
||||
@@ -179,7 +200,8 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
||||
}
|
||||
}
|
||||
|
||||
for (argument in argumentList.arguments) {
|
||||
for (argument in call.valueArguments) {
|
||||
if (argument is FunctionLiteralArgument) continue
|
||||
val parameter = argumentToParameter(argument) ?: continue
|
||||
if (!usedParameterIndices.add(parameter.index)) continue
|
||||
|
||||
@@ -203,7 +225,7 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
||||
|
||||
|
||||
val color = if (isResolvedToDescriptor(call, itemToShow, bindingContext))
|
||||
GREEN_BACKGROUND
|
||||
KotlinParameterInfoWithCallHandlerBase.GREEN_BACKGROUND
|
||||
else
|
||||
context.defaultParameterColor
|
||||
|
||||
@@ -214,169 +236,178 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
val GREEN_BACKGROUND: Color = JBColor(Color(231, 254, 234), Gray._100)
|
||||
override fun getParameterCloseChars() = ParameterInfoUtils.DEFAULT_PARAMETER_CLOSE_CHARS
|
||||
|
||||
private fun renderParameter(parameter: ValueParameterDescriptor, named: Boolean, project: Project): String {
|
||||
return StringBuilder {
|
||||
if (named) append("[")
|
||||
override fun tracksParameterIndex() = true
|
||||
|
||||
if (parameter.varargElementType != null) {
|
||||
append("vararg ")
|
||||
}
|
||||
append(parameter.name)
|
||||
append(": ")
|
||||
append(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(parameterTypeToRender(parameter)))
|
||||
//TODO
|
||||
override fun couldShowInLookup() = false
|
||||
override fun getParametersForLookup(item: LookupElement, context: ParameterInfoContext) = emptyArray<Any>()
|
||||
override fun getParametersForDocumentation(item: FunctionDescriptor, context: ParameterInfoContext) = emptyArray<Any>()
|
||||
|
||||
if (parameter.hasDefaultValue()) {
|
||||
append(" = ")
|
||||
append(parameter.renderDefaultValue(project))
|
||||
}
|
||||
protected fun renderParameter(parameter: ValueParameterDescriptor, named: Boolean, project: Project): String {
|
||||
return StringBuilder {
|
||||
if (named) append("[")
|
||||
|
||||
if (named) append("]")
|
||||
}.toString()
|
||||
}
|
||||
|
||||
private fun ValueParameterDescriptor.renderDefaultValue(project: Project): String {
|
||||
val expression = OptionalParametersHelper.defaultParameterValueExpression(this, project)
|
||||
if (expression != null) {
|
||||
val text = expression.text
|
||||
if (text.length() <= 32) {
|
||||
return text
|
||||
}
|
||||
|
||||
if (expression is JetConstantExpression || expression is JetStringTemplateExpression) {
|
||||
if (text.startsWith("\"")) {
|
||||
return "\"...\""
|
||||
}
|
||||
else if (text.startsWith("\'")) {
|
||||
return "\'...\'"
|
||||
}
|
||||
}
|
||||
if (parameter.varargElementType != null) {
|
||||
append("vararg ")
|
||||
}
|
||||
return "..."
|
||||
}
|
||||
append(parameter.name)
|
||||
append(": ")
|
||||
append(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(parameterTypeToRender(parameter)))
|
||||
|
||||
private fun parameterTypeToRender(descriptor: ValueParameterDescriptor): JetType {
|
||||
var type = descriptor.varargElementType ?: descriptor.type
|
||||
if (type.containsError()) {
|
||||
val original = descriptor.original
|
||||
type = original.varargElementType ?: original.type
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
private fun isResolvedToDescriptor(
|
||||
call: Call,
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
bindingContext: BindingContext
|
||||
): Boolean {
|
||||
val target = call.getResolvedCall(bindingContext)?.resultingDescriptor as? FunctionDescriptor
|
||||
return target != null && descriptorsEqual(target, functionDescriptor)
|
||||
}
|
||||
|
||||
private data class SignatureInfo(
|
||||
val substitutedDescriptor: FunctionDescriptor,
|
||||
val argumentToParameter: (ValueArgument) -> ValueParameterDescriptor?,
|
||||
val highlightParameterIndex: Int?,
|
||||
val isGrey: Boolean
|
||||
)
|
||||
|
||||
private fun matchCallWithSignature(
|
||||
call: Call,
|
||||
overload: FunctionDescriptor,
|
||||
currentArgumentIndex: Int,
|
||||
bindingContext: BindingContext,
|
||||
resolutionFacade: ResolutionFacade
|
||||
): SignatureInfo? {
|
||||
if (currentArgumentIndex == 0 && call.valueArguments.isEmpty() && overload.valueParameters.isEmpty()) {
|
||||
return SignatureInfo(overload, { null }, null, isGrey = false)
|
||||
if (parameter.hasDefaultValue()) {
|
||||
append(" = ")
|
||||
append(parameter.renderDefaultValue(project))
|
||||
}
|
||||
|
||||
assert(call.valueArguments.size() >= currentArgumentIndex)
|
||||
if (named) append("]")
|
||||
}.toString()
|
||||
}
|
||||
|
||||
val argumentsBeforeCurrent = call.valueArguments.subList(0, currentArgumentIndex)
|
||||
|
||||
val callToUse: Call
|
||||
val currentArgument: ValueArgument
|
||||
if (call.valueArguments.size() > currentArgumentIndex) {
|
||||
currentArgument = call.valueArguments[currentArgumentIndex]
|
||||
callToUse = call
|
||||
private fun ValueParameterDescriptor.renderDefaultValue(project: Project): String {
|
||||
val expression = OptionalParametersHelper.defaultParameterValueExpression(this, project)
|
||||
if (expression != null) {
|
||||
val text = expression.text
|
||||
if (text.length() <= 32) {
|
||||
return text
|
||||
}
|
||||
else {
|
||||
// add dummy current argument if we don't have one
|
||||
currentArgument = object : ValueArgument {
|
||||
override fun getArgumentExpression(): JetExpression? = null
|
||||
override fun getArgumentName(): ValueArgumentName? = null
|
||||
override fun isNamed(): Boolean = false
|
||||
override fun asElement(): JetElement = call.callElement // is a hack but what to do?
|
||||
override fun getSpreadElement(): LeafPsiElement? = null
|
||||
override fun isExternal() = false
|
||||
}
|
||||
callToUse = object : DelegatingCall(call) {
|
||||
val arguments = call.valueArguments + currentArgument
|
||||
|
||||
override fun getValueArguments() = arguments
|
||||
override fun getFunctionLiteralArguments() = emptyList<FunctionLiteralArgument>()
|
||||
override fun getValueArgumentList() = null
|
||||
if (expression is JetConstantExpression || expression is JetStringTemplateExpression) {
|
||||
if (text.startsWith("\"")) {
|
||||
return "\"...\""
|
||||
}
|
||||
else if (text.startsWith("\'")) {
|
||||
return "\'...\'"
|
||||
}
|
||||
}
|
||||
}
|
||||
return "..."
|
||||
}
|
||||
|
||||
val candidates = detectCandidates(callToUse, bindingContext, resolutionFacade)
|
||||
val resolvedCall = candidates.singleOrNull { descriptorsEqual(it.resultingDescriptor, overload) } ?: return null
|
||||
val resultingDescriptor = resolvedCall.resultingDescriptor
|
||||
private fun parameterTypeToRender(descriptor: ValueParameterDescriptor): JetType {
|
||||
var type = descriptor.varargElementType ?: descriptor.type
|
||||
if (type.containsError()) {
|
||||
val original = descriptor.original
|
||||
type = original.varargElementType ?: original.type
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
val argumentToParameter = { argument: ValueArgument -> (resolvedCall.getArgumentMapping(argument) as? ArgumentMatch)?.valueParameter }
|
||||
protected fun isResolvedToDescriptor(
|
||||
call: Call,
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
bindingContext: BindingContext
|
||||
): Boolean {
|
||||
val target = call.getResolvedCall(bindingContext)?.resultingDescriptor as? FunctionDescriptor
|
||||
return target != null && descriptorsEqual(target, functionDescriptor)
|
||||
}
|
||||
|
||||
val currentParameter = (resolvedCall.getArgumentMapping(currentArgument) as? ArgumentMatch)?.valueParameter
|
||||
val highlightParameterIndex = currentParameter?.index
|
||||
protected data class SignatureInfo(
|
||||
val substitutedDescriptor: FunctionDescriptor,
|
||||
val argumentToParameter: (ValueArgument) -> ValueParameterDescriptor?,
|
||||
val highlightParameterIndex: Int?,
|
||||
val isGrey: Boolean
|
||||
)
|
||||
|
||||
if (!(argumentsBeforeCurrent + currentArgument).all { argument -> resolvedCall.getArgumentMapping(argument) is ArgumentMatch }) { // some of arguments before the current one are not mapped to any of the parameters
|
||||
return SignatureInfo(resultingDescriptor, argumentToParameter, highlightParameterIndex, isGrey = true)
|
||||
private fun matchCallWithSignature(
|
||||
call: Call,
|
||||
overload: FunctionDescriptor,
|
||||
currentArgumentIndex: Int,
|
||||
bindingContext: BindingContext,
|
||||
resolutionFacade: ResolutionFacade
|
||||
): SignatureInfo? {
|
||||
if (currentArgumentIndex == 0 && call.valueArguments.isEmpty() && overload.valueParameters.isEmpty()) {
|
||||
return SignatureInfo(overload, { null }, null, isGrey = false)
|
||||
}
|
||||
|
||||
assert(call.valueArguments.size() >= currentArgumentIndex)
|
||||
|
||||
val argumentsBeforeCurrent = call.valueArguments.subList(0, currentArgumentIndex)
|
||||
|
||||
val callToUse: Call
|
||||
val currentArgument: ValueArgument
|
||||
if (call.valueArguments.size() > currentArgumentIndex) {
|
||||
currentArgument = call.valueArguments[currentArgumentIndex]
|
||||
callToUse = call
|
||||
}
|
||||
else {
|
||||
// add dummy current argument if we don't have one
|
||||
currentArgument = object : ValueArgument {
|
||||
override fun getArgumentExpression(): JetExpression? = null
|
||||
override fun getArgumentName(): ValueArgumentName? = null
|
||||
override fun isNamed(): Boolean = false
|
||||
override fun asElement(): JetElement = call.callElement // is a hack but what to do?
|
||||
override fun getSpreadElement(): LeafPsiElement? = null
|
||||
override fun isExternal() = false
|
||||
}
|
||||
callToUse = object : DelegatingCall(call) {
|
||||
val arguments = call.valueArguments + currentArgument
|
||||
|
||||
// grey out if not all arguments before the current are matched
|
||||
val isGrey = argumentsBeforeCurrent
|
||||
.any { argument -> resolvedCall.getArgumentMapping(argument).isError() && !argument.hasError(bindingContext) /* ignore arguments that has error type */ }
|
||||
return SignatureInfo(resultingDescriptor, argumentToParameter, highlightParameterIndex, isGrey)
|
||||
override fun getValueArguments() = arguments
|
||||
override fun getFunctionLiteralArguments() = emptyList<FunctionLiteralArgument>()
|
||||
override fun getValueArgumentList() = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun ValueArgument.hasError(bindingContext: BindingContext)
|
||||
= getArgumentExpression()?.let { bindingContext.getType(it) }?.isError ?: true
|
||||
val candidates = detectCandidates(callToUse, bindingContext, resolutionFacade)
|
||||
val resolvedCall = candidates.singleOrNull { descriptorsEqual(it.resultingDescriptor, overload) } ?: return null
|
||||
val resultingDescriptor = resolvedCall.resultingDescriptor
|
||||
|
||||
private fun detectCandidates(call: Call, bindingContext: BindingContext, resolutionFacade: ResolutionFacade): List<ResolvedCall<FunctionDescriptor>> {
|
||||
val callElement = call.callElement
|
||||
val resolutionScope = callElement.getResolutionScope(bindingContext, resolutionFacade)
|
||||
val inDescriptor = resolutionScope.ownerDescriptor
|
||||
|
||||
val dataFlowInfo = bindingContext.getDataFlowInfo(call.calleeExpression)
|
||||
val bindingTrace = DelegatingBindingTrace(bindingContext, "Temporary trace")
|
||||
val expectedType = (callElement as? JetExpression)?.let {
|
||||
bindingContext[BindingContext.EXPECTED_EXPRESSION_TYPE, it.getQualifiedExpressionForSelectorOrThis()]
|
||||
} ?: TypeUtils.NO_EXPECTED_TYPE
|
||||
val callResolutionContext = BasicCallResolutionContext.create(
|
||||
bindingTrace, resolutionScope, call, expectedType, dataFlowInfo,
|
||||
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
CallChecker.DoNothing, false/*TODO?*/
|
||||
).replaceCollectAllCandidates(true)
|
||||
val callResolver = resolutionFacade.frontendService<CallResolver>()
|
||||
|
||||
val results: OverloadResolutionResults<FunctionDescriptor> = callResolver.resolveFunctionCall(callResolutionContext)
|
||||
|
||||
return results.allCandidates!!
|
||||
.filter { it.status != ResolutionStatus.RECEIVER_TYPE_ERROR && it.status != ResolutionStatus.RECEIVER_PRESENCE_ERROR }
|
||||
.filter {
|
||||
val thisReceiver = ExpressionTypingUtils.normalizeReceiverValueForVisibility(it.dispatchReceiver, bindingContext)
|
||||
Visibilities.isVisible(thisReceiver, it.resultingDescriptor, inDescriptor)
|
||||
}
|
||||
fun argumentToParameter(argument: ValueArgument): ValueParameterDescriptor? {
|
||||
val parameter = (resolvedCall.getArgumentMapping(argument) as? ArgumentMatch)?.valueParameter ?: return null
|
||||
if (call.callType == Call.CallType.ARRAY_SET_METHOD && parameter.index == resultingDescriptor.valueParameters.lastIndex) return null
|
||||
return parameter
|
||||
}
|
||||
|
||||
// we should not compare descriptors directly because partial resolve is involved
|
||||
private fun descriptorsEqual(descriptor1: FunctionDescriptor, descriptor2: FunctionDescriptor): Boolean {
|
||||
if (descriptor1.original == descriptor2.original) return true
|
||||
val declaration1 = DescriptorToSourceUtils.descriptorToDeclaration(descriptor1) ?: return false
|
||||
val declaration2 = DescriptorToSourceUtils.descriptorToDeclaration(descriptor2)
|
||||
return declaration1 == declaration2
|
||||
val highlightParameterIndex = argumentToParameter(currentArgument)?.index
|
||||
|
||||
if (!(argumentsBeforeCurrent + currentArgument).all { argumentToParameter(it) != null }) { // some of arguments before the current one are not mapped to any of the parameters
|
||||
return SignatureInfo(resultingDescriptor, ::argumentToParameter, highlightParameterIndex, isGrey = true)
|
||||
}
|
||||
|
||||
// grey out if not all arguments before the current are matched
|
||||
val isGrey = argumentsBeforeCurrent
|
||||
.any { argument -> resolvedCall.getArgumentMapping(argument).isError() && !argument.hasError(bindingContext) /* ignore arguments that has error type */ }
|
||||
return SignatureInfo(resultingDescriptor, ::argumentToParameter, highlightParameterIndex, isGrey)
|
||||
}
|
||||
|
||||
private fun ValueArgument.hasError(bindingContext: BindingContext)
|
||||
= getArgumentExpression()?.let { bindingContext.getType(it) }?.isError ?: true
|
||||
|
||||
private fun detectCandidates(call: Call, bindingContext: BindingContext, resolutionFacade: ResolutionFacade): List<ResolvedCall<FunctionDescriptor>> {
|
||||
val callElement = call.callElement
|
||||
val resolutionScope = callElement.getResolutionScope(bindingContext, resolutionFacade)
|
||||
val inDescriptor = resolutionScope.ownerDescriptor
|
||||
|
||||
val dataFlowInfo = bindingContext.getDataFlowInfo(call.calleeExpression)
|
||||
val bindingTrace = DelegatingBindingTrace(bindingContext, "Temporary trace")
|
||||
val expectedType = (callElement as? JetExpression)?.let {
|
||||
bindingContext[BindingContext.EXPECTED_EXPRESSION_TYPE, it.getQualifiedExpressionForSelectorOrThis()]
|
||||
} ?: TypeUtils.NO_EXPECTED_TYPE
|
||||
val callResolutionContext = BasicCallResolutionContext.create(
|
||||
bindingTrace, resolutionScope, call, expectedType, dataFlowInfo,
|
||||
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
CallChecker.DoNothing, false/*TODO?*/
|
||||
).replaceCollectAllCandidates(true)
|
||||
val callResolver = resolutionFacade.frontendService<CallResolver>()
|
||||
|
||||
val results: OverloadResolutionResults<FunctionDescriptor> = callResolver.resolveFunctionCall(callResolutionContext)
|
||||
|
||||
return results.allCandidates!!
|
||||
.filter { it.status != ResolutionStatus.RECEIVER_TYPE_ERROR && it.status != ResolutionStatus.RECEIVER_PRESENCE_ERROR }
|
||||
.filter {
|
||||
val thisReceiver = ExpressionTypingUtils.normalizeReceiverValueForVisibility(it.dispatchReceiver, bindingContext)
|
||||
Visibilities.isVisible(thisReceiver, it.resultingDescriptor, inDescriptor)
|
||||
}
|
||||
.distinctBy { it.resultingDescriptor.original }
|
||||
}
|
||||
|
||||
// we should not compare descriptors directly because partial resolve is involved
|
||||
private fun descriptorsEqual(descriptor1: FunctionDescriptor, descriptor2: FunctionDescriptor): Boolean {
|
||||
if (descriptor1.original == descriptor2.original) return true
|
||||
val declaration1 = DescriptorToSourceUtils.descriptorToDeclaration(descriptor1) ?: return false
|
||||
val declaration2 = DescriptorToSourceUtils.descriptorToDeclaration(descriptor2)
|
||||
return declaration1 == declaration2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
operator fun get(x: String) = 1
|
||||
operator fun get(x: Int, y: Boolean) = 2
|
||||
|
||||
fun d(x: Int) {
|
||||
this[<caret>1, false]
|
||||
}
|
||||
}
|
||||
/*
|
||||
Text: (<highlight>x: Int</highlight>, y: Boolean), Disabled: false, Strikeout: false, Green: true
|
||||
Text: (<highlight>x: String</highlight>), Disabled: false, Strikeout: false, Green: false
|
||||
*/
|
||||
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
operator fun get(x: String) = 1
|
||||
operator fun get(x: String, y: Boolean) = 2
|
||||
operator fun get(x: Int, y: Boolean) = 2
|
||||
|
||||
fun d(x: Int) {
|
||||
this[1, <caret>false]
|
||||
}
|
||||
}
|
||||
/*
|
||||
Text: (x: Int, <highlight>y: Boolean</highlight>), Disabled: false, Strikeout: false, Green: true
|
||||
Text: (x: String), Disabled: true, Strikeout: false, Green: false
|
||||
Text: (x: String, <highlight>y: Boolean</highlight>), Disabled: true, Strikeout: false, Green: false
|
||||
*/
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
operator fun get(x: Int) {}
|
||||
operator fun set(x: String, y: Int, value: Int) {}
|
||||
|
||||
fun d(x: Int) {
|
||||
this[<caret>] = 1
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Text: (<highlight>x: String</highlight>, y: Int), Disabled: false, Strikeout: false, Green: true
|
||||
*/
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
operator fun get(x: Int) {}
|
||||
operator fun set(x: String, value: Int) {}
|
||||
|
||||
fun d(x: Int) {
|
||||
this["", 1<caret>] = 1
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Text: (x: String), Disabled: true, Strikeout: false, Green: true
|
||||
*/
|
||||
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
operator fun get(pInt: Int, pString: String){}
|
||||
}
|
||||
|
||||
fun foo(c: C) {
|
||||
c[<caret>]
|
||||
}
|
||||
|
||||
//Text: (<highlight>pInt: Int</highlight>, pString: String), Disabled: false, Strikeout: false, Green: true
|
||||
@@ -0,0 +1,8 @@
|
||||
open class A(x: Int) {
|
||||
fun m(x: Int, y: Boolean) = 2
|
||||
|
||||
fun d(x: Int) {
|
||||
m(1, false, <caret>)
|
||||
}
|
||||
}
|
||||
//Text: (x: Int, y: Boolean), Disabled: true, Strikeout: false, Green: true
|
||||
+16
-7
@@ -16,10 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.parameterInfo
|
||||
|
||||
import com.intellij.codeInsight.hint.ShowParameterInfoContext
|
||||
import com.intellij.codeInsight.hint.ShowParameterInfoHandler
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.idea.JetLanguage
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.idea.test.ProjectDescriptorWithStdlibSources
|
||||
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||
@@ -29,12 +33,12 @@ import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.junit.Assert
|
||||
|
||||
abstract class AbstractFunctionParameterInfoTest : LightCodeInsightFixtureTestCase() {
|
||||
abstract class AbstractParameterInfoTest : LightCodeInsightFixtureTestCase() {
|
||||
override fun getProjectDescriptor() = ProjectDescriptorWithStdlibSources.INSTANCE
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
myFixture.testDataPath = PluginTestCaseBase.getTestDataPathBase() + "/parameterInfo/functionParameterInfo"
|
||||
myFixture.testDataPath = PluginTestCaseBase.getTestDataPathBase() + "/parameterInfo"
|
||||
}
|
||||
|
||||
protected fun doTest(fileName: String) {
|
||||
@@ -49,9 +53,14 @@ abstract class AbstractFunctionParameterInfoTest : LightCodeInsightFixtureTestCa
|
||||
else -> error("Unexpected last file child")
|
||||
}
|
||||
|
||||
val parameterInfoHandler = KotlinFunctionParameterInfoHandler()
|
||||
val context = ShowParameterInfoContext(editor, project, file, editor.caretModel.offset, -1)
|
||||
|
||||
val handlers = ShowParameterInfoHandler.getHandlers(project, JetLanguage.INSTANCE)!!
|
||||
val handler = handlers.firstOrNull { it.findElementForParameterInfo(context) != null }
|
||||
?: error("Could not find parameter info handler")
|
||||
|
||||
val mockCreateParameterInfoContext = MockCreateParameterInfoContext(file, myFixture)
|
||||
val parameterOwner = parameterInfoHandler.findElementForParameterInfo(mockCreateParameterInfoContext)
|
||||
val parameterOwner = handler.findElementForParameterInfo(mockCreateParameterInfoContext) as PsiElement
|
||||
|
||||
val textToType = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// TYPE:")
|
||||
if (textToType != null) {
|
||||
@@ -66,16 +75,16 @@ abstract class AbstractFunctionParameterInfoTest : LightCodeInsightFixtureTestCa
|
||||
|
||||
//to update current parameter index
|
||||
val updateContext = MockUpdateParameterInfoContext(file, myFixture)
|
||||
val elementForUpdating = parameterInfoHandler.findElementForUpdatingParameterInfo(updateContext)
|
||||
val elementForUpdating = handler.findElementForUpdatingParameterInfo(updateContext)
|
||||
if (elementForUpdating != null) {
|
||||
parameterInfoHandler.updateParameterInfo(elementForUpdating, updateContext)
|
||||
handler.updateParameterInfo(elementForUpdating, updateContext)
|
||||
}
|
||||
|
||||
val parameterInfoUIContext = MockParameterInfoUIContext(parameterOwner, updateContext.currentParameter)
|
||||
|
||||
for (item in mockCreateParameterInfoContext.itemsToShow) {
|
||||
//noinspection unchecked
|
||||
parameterInfoHandler.updateUI(item as FunctionDescriptor, parameterInfoUIContext)
|
||||
handler.updateUI(item as FunctionDescriptor, parameterInfoUIContext)
|
||||
}
|
||||
Assert.assertEquals(expectedResultText, parameterInfoUIContext.resultText)
|
||||
}
|
||||
-217
@@ -1,217 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.parameterInfo;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/parameterInfo/functionParameterInfo")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class FunctionParameterInfoTestGenerated extends AbstractFunctionParameterInfoTest {
|
||||
public void testAllFilesPresentInFunctionParameterInfo() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/functionParameterInfo"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("DefaultValuesFromLib.kt")
|
||||
public void testDefaultValuesFromLib() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/DefaultValuesFromLib.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/Deprecated.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionOnClassObject.kt")
|
||||
public void testExtensionOnClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/ExtensionOnClassObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionalValue1.kt")
|
||||
public void testFunctionalValue1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/FunctionalValue1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionalValue2.kt")
|
||||
public void testFunctionalValue2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/FunctionalValue2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedFunctions.kt")
|
||||
public void testInheritedFunctions() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/InheritedFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedWithCurrentFunctions.kt")
|
||||
public void testInheritedWithCurrentFunctions() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/InheritedWithCurrentFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Invoke.kt")
|
||||
public void testInvoke() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/Invoke.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("LocalFunctionBug.kt")
|
||||
public void testLocalFunctionBug() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/LocalFunctionBug.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NamedAndDefaultParameter.kt")
|
||||
public void testNamedAndDefaultParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NamedAndDefaultParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NamedParameter.kt")
|
||||
public void testNamedParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NamedParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NamedParameter2.kt")
|
||||
public void testNamedParameter2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NamedParameter2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NoAnnotations.kt")
|
||||
public void testNoAnnotations() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NoAnnotations.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NotAccessible.kt")
|
||||
public void testNotAccessible() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NotAccessible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NotGreen.kt")
|
||||
public void testNotGreen() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NotGreen.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NullableTypeCall.kt")
|
||||
public void testNullableTypeCall() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NullableTypeCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Println.kt")
|
||||
public void testPrintln() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/Println.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/Simple.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SimpleConstructor.kt")
|
||||
public void testSimpleConstructor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SimpleConstructor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteExpectedType.kt")
|
||||
public void testSubstituteExpectedType() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteExpectedType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteExplicitTypeArgs.kt")
|
||||
public void testSubstituteExplicitTypeArgs() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteExplicitTypeArgs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArguments1.kt")
|
||||
public void testSubstituteFromArguments1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArguments2.kt")
|
||||
public void testSubstituteFromArguments2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArguments3.kt")
|
||||
public void testSubstituteFromArguments3() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments3.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArguments4.kt")
|
||||
public void testSubstituteFromArguments4() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments4.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArgumentsOnTyping.kt")
|
||||
public void testSubstituteFromArgumentsOnTyping() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArgumentsOnTyping.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SuperConstructorCall.kt")
|
||||
public void testSuperConstructorCall() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SuperConstructorCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TwoFunctions.kt")
|
||||
public void testTwoFunctions() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/TwoFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TwoFunctionsGrey.kt")
|
||||
public void testTwoFunctionsGrey() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/TwoFunctionsGrey.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("UpdateOnTyping.kt")
|
||||
public void testUpdateOnTyping() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/UpdateOnTyping.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class MockParameterInfoUIContext implements ParameterInfoUIContext {
|
||||
String resultText = "Text: (" + highlightedText + "), " +
|
||||
"Disabled: " + isDisabled + ", " +
|
||||
"Strikeout: " + strikeout + ", " +
|
||||
"Green: " + background.equals(KotlinFunctionParameterInfoHandler.GREEN_BACKGROUND);
|
||||
"Green: " + background.equals(KotlinParameterInfoWithCallHandlerBase.GREEN_BACKGROUND);
|
||||
result.add(resultText);
|
||||
|
||||
// return value not used, just return something
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.parameterInfo;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/parameterInfo")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInParameterInfo() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/parameterInfo/arrayAccess")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ArrayAccess extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInArrayAccess() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/arrayAccess"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Overloads.kt")
|
||||
public void testOverloads() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/arrayAccess/Overloads.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Overloads2.kt")
|
||||
public void testOverloads2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/arrayAccess/Overloads2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Set.kt")
|
||||
public void testSet() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/arrayAccess/Set.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SetTooManyArgs.kt")
|
||||
public void testSetTooManyArgs() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/arrayAccess/SetTooManyArgs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/arrayAccess/Simple.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/parameterInfo/functionCall")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class FunctionCall extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInFunctionCall() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/functionCall"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("DefaultValuesFromLib.kt")
|
||||
public void testDefaultValuesFromLib() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/DefaultValuesFromLib.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/Deprecated.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionOnClassObject.kt")
|
||||
public void testExtensionOnClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/ExtensionOnClassObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionalValue1.kt")
|
||||
public void testFunctionalValue1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/FunctionalValue1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionalValue2.kt")
|
||||
public void testFunctionalValue2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/FunctionalValue2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedFunctions.kt")
|
||||
public void testInheritedFunctions() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/InheritedFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedWithCurrentFunctions.kt")
|
||||
public void testInheritedWithCurrentFunctions() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/InheritedWithCurrentFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Invoke.kt")
|
||||
public void testInvoke() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/Invoke.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("LocalFunctionBug.kt")
|
||||
public void testLocalFunctionBug() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/LocalFunctionBug.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NamedAndDefaultParameter.kt")
|
||||
public void testNamedAndDefaultParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NamedAndDefaultParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NamedParameter.kt")
|
||||
public void testNamedParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NamedParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NamedParameter2.kt")
|
||||
public void testNamedParameter2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NamedParameter2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NoAnnotations.kt")
|
||||
public void testNoAnnotations() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NoAnnotations.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NotAccessible.kt")
|
||||
public void testNotAccessible() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NotAccessible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NotGreen.kt")
|
||||
public void testNotGreen() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NotGreen.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NullableTypeCall.kt")
|
||||
public void testNullableTypeCall() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/NullableTypeCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Println.kt")
|
||||
public void testPrintln() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/Println.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/Simple.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SimpleConstructor.kt")
|
||||
public void testSimpleConstructor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SimpleConstructor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteExpectedType.kt")
|
||||
public void testSubstituteExpectedType() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SubstituteExpectedType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteExplicitTypeArgs.kt")
|
||||
public void testSubstituteExplicitTypeArgs() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SubstituteExplicitTypeArgs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArguments1.kt")
|
||||
public void testSubstituteFromArguments1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SubstituteFromArguments1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArguments2.kt")
|
||||
public void testSubstituteFromArguments2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SubstituteFromArguments2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArguments3.kt")
|
||||
public void testSubstituteFromArguments3() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SubstituteFromArguments3.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArguments4.kt")
|
||||
public void testSubstituteFromArguments4() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SubstituteFromArguments4.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SubstituteFromArgumentsOnTyping.kt")
|
||||
public void testSubstituteFromArgumentsOnTyping() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SubstituteFromArgumentsOnTyping.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SuperConstructorCall.kt")
|
||||
public void testSuperConstructorCall() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/SuperConstructorCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TooManyArgs.kt")
|
||||
public void testTooManyArgs() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/TooManyArgs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TwoFunctions.kt")
|
||||
public void testTwoFunctions() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/TwoFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TwoFunctionsGrey.kt")
|
||||
public void testTwoFunctionsGrey() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/TwoFunctionsGrey.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("UpdateOnTyping.kt")
|
||||
public void testUpdateOnTyping() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionCall/UpdateOnTyping.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user