Cleanup: better function name
This commit is contained in:
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the license/LICENSE.txt file.
|
||||||
* 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
|
package org.jetbrains.kotlin.idea.parameterInfo
|
||||||
@@ -38,12 +27,12 @@ fun provideArgumentNameHints(element: KtCallElement): List<InlayInfo> {
|
|||||||
val call = element.getCall(ctx) ?: return emptyList()
|
val call = element.getCall(ctx) ?: return emptyList()
|
||||||
val resolvedCall = call.getResolvedCall(ctx)
|
val resolvedCall = call.getResolvedCall(ctx)
|
||||||
if (resolvedCall != null) {
|
if (resolvedCall != null) {
|
||||||
return getParameterInfoForCallCandidate(resolvedCall)
|
return getArgumentNameHintsForCallCandidate(resolvedCall)
|
||||||
}
|
}
|
||||||
val candidates = call.resolveCandidates(ctx, element.getResolutionFacade())
|
val candidates = call.resolveCandidates(ctx, element.getResolutionFacade())
|
||||||
if (candidates.isEmpty()) return emptyList()
|
if (candidates.isEmpty()) return emptyList()
|
||||||
candidates.singleOrNull()?.let { return getParameterInfoForCallCandidate(it) }
|
candidates.singleOrNull()?.let { return getArgumentNameHintsForCallCandidate(it) }
|
||||||
return candidates.map { getParameterInfoForCallCandidate(it) }.reduce { infos1, infos2 ->
|
return candidates.map { getArgumentNameHintsForCallCandidate(it) }.reduce { infos1, infos2 ->
|
||||||
for (index in infos1.indices) {
|
for (index in infos1.indices) {
|
||||||
if (index >= infos2.size || infos1[index] != infos2[index]) {
|
if (index >= infos2.size || infos1[index] != infos2[index]) {
|
||||||
return@reduce infos1.subList(0, index)
|
return@reduce infos1.subList(0, index)
|
||||||
@@ -53,7 +42,7 @@ fun provideArgumentNameHints(element: KtCallElement): List<InlayInfo> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getParameterInfoForCallCandidate(resolvedCall: ResolvedCall<out CallableDescriptor>): List<InlayInfo> {
|
private fun getArgumentNameHintsForCallCandidate(resolvedCall: ResolvedCall<out CallableDescriptor>): List<InlayInfo> {
|
||||||
val resultingDescriptor = resolvedCall.resultingDescriptor
|
val resultingDescriptor = resolvedCall.resultingDescriptor
|
||||||
if (resultingDescriptor.hasSynthesizedParameterNames() && resultingDescriptor !is FunctionInvokeDescriptor) {
|
if (resultingDescriptor.hasSynthesizedParameterNames() && resultingDescriptor !is FunctionInvokeDescriptor) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
|
|||||||
Reference in New Issue
Block a user