[IDEA] Add HTML render for ambiguous callable references diagnostic

^KT-36125 Fixed
This commit is contained in:
Pavel Kirpichenkov
2020-03-18 19:28:43 +03:00
parent a416fde814
commit b7ea590e23
7 changed files with 86 additions and 5 deletions
@@ -147,6 +147,9 @@ public class IdeErrorMessages {
MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY,
KotlinIdeaAnalysisBundle.htmlMessage("html.overload.resolution.ambiguity.all.these.functions.match.ul.0.ul.html"),
HTML_AMBIGUOUS_CALLS);
MAP.put(CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY,
KotlinIdeaAnalysisBundle.htmlMessage("html.overload.resolution.ambiguity.all.these.functions.match.ul.0.ul.html"),
HTML_AMBIGUOUS_REFERENCES);
MAP.put(NONE_APPLICABLE, KotlinIdeaAnalysisBundle.htmlMessage("html.none.of.the.following.functions.can.be.called.with.the.arguments.supplied.ul.0.ul.html"),
HTML_NONE_APPLICABLE_CALLS);
MAP.put(CANNOT_COMPLETE_RESOLVE,
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.idea.highlighter
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.diagnostics.rendering.*
import org.jetbrains.kotlin.idea.KotlinIdeaAnalysisBundle
@@ -20,11 +21,18 @@ object IdeRenderers {
@JvmField
val HTML_AMBIGUOUS_CALLS = Renderer { calls: Collection<ResolvedCall<*>> ->
val descriptors = calls
.map { it.resultingDescriptor }
.sortedWith(MemberComparator.INSTANCE)
val context = RenderingContext.Impl(descriptors)
descriptors.joinToString("") { "<li>${HTML.render(it, context)}</li>" }
renderAmbiguousDescriptors(calls.map { it.resultingDescriptor })
}
@JvmField
val HTML_AMBIGUOUS_REFERENCES = Renderer { descriptors: Collection<CallableDescriptor> ->
renderAmbiguousDescriptors(descriptors)
}
private fun renderAmbiguousDescriptors(descriptors: Collection<CallableDescriptor>): String {
val sortedDescriptors = descriptors.sortedWith(MemberComparator.INSTANCE)
val context = RenderingContext.Impl(sortedDescriptors)
return sortedDescriptors.joinToString("") { "<li>${HTML.render(it, context)}</li>" }
}
@JvmField