Ensure stable order is used when rendering list of resolved calls by sorting them with MemberComparator.
This commit is contained in:
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.psi.JetNamedDeclaration
|
|||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
import org.jetbrains.kotlin.renderer.Renderer
|
import org.jetbrains.kotlin.renderer.Renderer
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
|
import org.jetbrains.kotlin.resolve.MemberComparator
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.*
|
import org.jetbrains.kotlin.resolve.calls.inference.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound
|
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND
|
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND
|
||||||
@@ -95,12 +96,11 @@ public object Renderers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public val AMBIGUOUS_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
|
public val AMBIGUOUS_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
|
||||||
argument: Collection<ResolvedCall<*>> ->
|
calls: Collection<ResolvedCall<*>> ->
|
||||||
val stringBuilder = StringBuilder("\n")
|
calls
|
||||||
for (call in argument) {
|
.map { it.getResultingDescriptor() }
|
||||||
stringBuilder.append(DescriptorRenderer.FQ_NAMES_IN_TYPES.render(call.getResultingDescriptor())).append("\n")
|
.sortBy(MemberComparator.INSTANCE)
|
||||||
}
|
.joinToString(separator = "\n", prefix = "\n") { DescriptorRenderer.FQ_NAMES_IN_TYPES.render(it) }
|
||||||
stringBuilder.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
platformStatic
|
platformStatic
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.Renderers
|
|||||||
import org.jetbrains.kotlin.idea.highlighter.renderersUtil.renderResolvedCall
|
import org.jetbrains.kotlin.idea.highlighter.renderersUtil.renderResolvedCall
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
import org.jetbrains.kotlin.renderer.Renderer
|
import org.jetbrains.kotlin.renderer.Renderer
|
||||||
|
import org.jetbrains.kotlin.resolve.MemberComparator
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData
|
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData
|
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData
|
||||||
@@ -29,13 +30,10 @@ import org.jetbrains.kotlin.types.JetType
|
|||||||
public object IdeRenderers {
|
public object IdeRenderers {
|
||||||
public val HTML_AMBIGUOUS_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
|
public val HTML_AMBIGUOUS_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
|
||||||
calls: Collection<ResolvedCall<*>> ->
|
calls: Collection<ResolvedCall<*>> ->
|
||||||
StringBuilder {
|
calls
|
||||||
for (call in calls) {
|
.map { it.getResultingDescriptor() }
|
||||||
append("<li>")
|
.sortBy(MemberComparator.INSTANCE)
|
||||||
append(DescriptorRenderer.HTML.render(call.getResultingDescriptor()))
|
.joinToString("") { "<li>" + DescriptorRenderer.HTML.render(it) + "</li>" }
|
||||||
append("</li>")
|
|
||||||
}
|
|
||||||
}.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public val HTML_RENDER_TYPE: Renderer<JetType> = Renderer {
|
public val HTML_RENDER_TYPE: Renderer<JetType> = Renderer {
|
||||||
@@ -44,13 +42,11 @@ public object IdeRenderers {
|
|||||||
|
|
||||||
public val HTML_NONE_APPLICABLE_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
|
public val HTML_NONE_APPLICABLE_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
|
||||||
calls: Collection<ResolvedCall<*>> ->
|
calls: Collection<ResolvedCall<*>> ->
|
||||||
StringBuilder {
|
// TODO: compareBy(comparator, selector) in stdlib
|
||||||
for (resolvedCall in calls) {
|
val comparator = comparator<ResolvedCall<*>> { c1, c2 -> MemberComparator.INSTANCE.compare(c1.getResultingDescriptor(), c2.getResultingDescriptor()) }
|
||||||
append("<li>")
|
calls
|
||||||
append(renderResolvedCall(resolvedCall))
|
.sortBy(comparator)
|
||||||
append("</li>")
|
.joinToString("") { "<li>" + renderResolvedCall(it) + "</li>" }
|
||||||
}
|
|
||||||
}.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public val HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER: Renderer<InferenceErrorData> = Renderer {
|
public val HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER: Renderer<InferenceErrorData> = Renderer {
|
||||||
@@ -76,19 +72,14 @@ public object IdeRenderers {
|
|||||||
|
|
||||||
public val HTML_CONFLICTING_JVM_DECLARATIONS_DATA: Renderer<ConflictingJvmDeclarationsData> = Renderer<ConflictingJvmDeclarationsData> {
|
public val HTML_CONFLICTING_JVM_DECLARATIONS_DATA: Renderer<ConflictingJvmDeclarationsData> = Renderer<ConflictingJvmDeclarationsData> {
|
||||||
data: ConflictingJvmDeclarationsData ->
|
data: ConflictingJvmDeclarationsData ->
|
||||||
val sb = StringBuilder {
|
|
||||||
append("<ul>")
|
val conflicts = data.signatureOrigins
|
||||||
for (origin in data.signatureOrigins) {
|
.map { it.descriptor }
|
||||||
val descriptor = origin.descriptor
|
.filterNotNull()
|
||||||
if (descriptor != null) {
|
.sortBy(MemberComparator.INSTANCE)
|
||||||
append("<li>")
|
.joinToString("") { "<li>" + DescriptorRenderer.HTML_COMPACT_WITH_MODIFIERS.render(it) + "</li>\n" }
|
||||||
append(DescriptorRenderer.HTML_COMPACT_WITH_MODIFIERS.render(descriptor))
|
|
||||||
append("</li>\n")
|
"The following declarations have the same JVM signature (<code>${data.signature.name}${data.signature.desc}</code>):<br/>\n<ul>\n$conflicts</ul>"
|
||||||
}
|
|
||||||
}
|
|
||||||
append("</ul>")
|
|
||||||
}
|
|
||||||
("The following declarations have the same JVM signature (<code>" + data.signature.name + data.signature.desc + "</code>):<br/>\n" + sb).trim()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public val HTML_THROWABLE: Renderer<Throwable> = Renderer {
|
public val HTML_THROWABLE: Renderer<Throwable> = Renderer {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
<html>
|
<html>
|
||||||
None of the following functions can be called with the arguments supplied.
|
None of the following functions can be called with the arguments supplied.
|
||||||
<ul>
|
<ul>
|
||||||
<li>foo(Int, String, <font color=red><b>Boolean</b></font>) <i>defined in</i> root package</li>
|
|
||||||
<li>foo(<font color=red><b>Boolean</b></font>, String) <i>defined in</i> root package</li>
|
<li>foo(<font color=red><b>Boolean</b></font>, String) <i>defined in</i> root package</li>
|
||||||
<li>foo(Int<font color=red><b>)</b></font> <i>defined in</i> root package</li>
|
<li>foo(Int<font color=red><b>)</b></font> <i>defined in</i> root package</li>
|
||||||
|
<li>foo(Int, String, <font color=red><b>Boolean</b></font>) <i>defined in</i> root package</li>
|
||||||
</ul>
|
</ul>
|
||||||
</html>
|
</html>
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
<html>
|
<html>
|
||||||
None of the following functions can be called with the arguments supplied.
|
None of the following functions can be called with the arguments supplied.
|
||||||
<ul>
|
<ul>
|
||||||
<li>foo(Int, Any, List<`Int><font color=red><b>)</b></font><br/>
|
|
||||||
<i>where</i> T = Int<i> for </i><br/>
|
|
||||||
<b>fun</b> <`T> foo(t: T, a: Any, l: List<`T>): Int <i>defined in</i> p</li>
|
|
||||||
<li>foo(Int, <font color=red><b>R</b></font>, MutableList<`Int>, MutableList<`<font color=red><b>R</b></font>>)<br/>
|
|
||||||
<i>where</i> <font color=red><b>R</b></font><i> cannot be inferred</i>; T = Int<i> for </i><br/>
|
|
||||||
<b>fun</b> <`T, R> foo(t: T, r: R, lt: MutableList<`T>, lr: MutableList<`R>): Int <i>defined in</i> p</li>
|
|
||||||
<li>foo(<font color=red><b>T</b></font>, Any, MutableList<`<font color=red><b>T</b></font>>, MutableList<`<font color=red><b>T</b></font>>)<br/>
|
<li>foo(<font color=red><b>T</b></font>, Any, MutableList<`<font color=red><b>T</b></font>>, MutableList<`<font color=red><b>T</b></font>>)<br/>
|
||||||
<i>where</i> <font color=red><b>T</b></font><i> cannot be inferred</i><i> for </i><br/>
|
<i>where</i> <font color=red><b>T</b></font><i> cannot be inferred</i><i> for </i><br/>
|
||||||
<b>fun</b> <`T> foo(t: T, a: Any, lt: MutableList<`T>, lr: MutableList<`T>): Int <i>defined in</i> p</li>
|
<b>fun</b> <`T> foo(t: T, a: Any, lt: MutableList<`T>, lr: MutableList<`T>): Int <i>defined in</i> p</li>
|
||||||
|
<li>foo(Int, <font color=red><b>R</b></font>, MutableList<`Int>, MutableList<`<font color=red><b>R</b></font>>)<br/>
|
||||||
|
<i>where</i> <font color=red><b>R</b></font><i> cannot be inferred</i>; T = Int<i> for </i><br/>
|
||||||
|
<b>fun</b> <`T, R> foo(t: T, r: R, lt: MutableList<`T>, lr: MutableList<`R>): Int <i>defined in</i> p</li>
|
||||||
|
<li>foo(Int, Any, List<`Int><font color=red><b>)</b></font><br/>
|
||||||
|
<i>where</i> T = Int<i> for </i><br/>
|
||||||
|
<b>fun</b> <`T> foo(t: T, a: Any, l: List<`T>): Int <i>defined in</i> p</li>
|
||||||
</ul>
|
</ul>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// "Import" "true"
|
// "Import" "true"
|
||||||
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>internal</b> <b>fun</b> kotlin.String.minus(str: kotlin.String): kotlin.String <i>defined in</i> h</li><li><b>internal</b> <b>fun</b> kotlin.String.minus(i: java.lang.Integer): kotlin.String <i>defined in</i> h</li></ul></html>
|
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>internal</b> <b>fun</b> kotlin.String.minus(i: java.lang.Integer): kotlin.String <i>defined in</i> h</li><li><b>internal</b> <b>fun</b> kotlin.String.minus(str: kotlin.String): kotlin.String <i>defined in</i> h</li></ul></html>
|
||||||
|
|
||||||
package h
|
package h
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// "Import" "true"
|
// "Import" "true"
|
||||||
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>internal</b> <b>fun</b> kotlin.String.minus(str: kotlin.String): kotlin.String <i>defined in</i> h</li><li><b>internal</b> <b>fun</b> kotlin.String.minus(i: java.lang.Integer): kotlin.String <i>defined in</i> h</li></ul></html>
|
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>internal</b> <b>fun</b> kotlin.String.minus(i: java.lang.Integer): kotlin.String <i>defined in</i> h</li><li><b>internal</b> <b>fun</b> kotlin.String.minus(str: kotlin.String): kotlin.String <i>defined in</i> h</li></ul></html>
|
||||||
|
|
||||||
package h
|
package h
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// "Insert 'this()' call" "true"
|
// "Insert 'this()' call" "true"
|
||||||
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li><init>(<font color=red><b>String</b></font>) <i>defined in</i> A</li><li><init>(<font color=red><b>Int</b></font>) <i>defined in</i> A</li></ul></html>
|
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li><init>(<font color=red><b>Int</b></font>) <i>defined in</i> A</li><li><init>(<font color=red><b>String</b></font>) <i>defined in</i> A</li></ul></html>
|
||||||
|
|
||||||
class A(val x: Int) {
|
class A(val x: Int) {
|
||||||
constructor(x: String)<caret>
|
constructor(x: String)<caret>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// "Insert 'this()' call" "true"
|
// "Insert 'this()' call" "true"
|
||||||
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li><init>(<font color=red><b>String</b></font>) <i>defined in</i> A</li><li><init>(<font color=red><b>Int</b></font>) <i>defined in</i> A</li></ul></html>
|
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li><init>(<font color=red><b>Int</b></font>) <i>defined in</i> A</li><li><init>(<font color=red><b>String</b></font>) <i>defined in</i> A</li></ul></html>
|
||||||
|
|
||||||
class A(val x: Int) {
|
class A(val x: Int) {
|
||||||
constructor(x: String) : this(<caret>)
|
constructor(x: String) : this(<caret>)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// ERROR: None of the following functions can be called with the arguments supplied: public open fun valueOf(p0: kotlin.String!, p1: kotlin.Int): kotlin.Short! defined in java.lang.Short public open fun valueOf(p0: kotlin.String!): kotlin.Short! defined in java.lang.Short public open fun valueOf(p0: kotlin.Short): kotlin.Short! defined in java.lang.Short
|
// ERROR: None of the following functions can be called with the arguments supplied: public open fun valueOf(p0: kotlin.Short): kotlin.Short! defined in java.lang.Short public open fun valueOf(p0: kotlin.String!): kotlin.Short! defined in java.lang.Short public open fun valueOf(p0: kotlin.String!, p1: kotlin.Int): kotlin.Short! defined in java.lang.Short
|
||||||
package demo
|
package demo
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// ERROR: None of the following functions can be called with the arguments supplied: public constructor FileInputStream(p0: kotlin.String!) defined in java.io.FileInputStream public constructor FileInputStream(p0: java.io.File!) defined in java.io.FileInputStream public constructor FileInputStream(p0: [ERROR : Unresolved java classifier: FileDescriptor]!) defined in java.io.FileInputStream
|
// ERROR: None of the following functions can be called with the arguments supplied: public constructor FileInputStream(p0: [ERROR : Unresolved java classifier: FileDescriptor]!) defined in java.io.FileInputStream public constructor FileInputStream(p0: java.io.File!) defined in java.io.FileInputStream public constructor FileInputStream(p0: kotlin.String!) defined in java.io.FileInputStream
|
||||||
// ERROR: None of the following functions can be called with the arguments supplied: public constructor InputStreamReader(p0: java.io.InputStream!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: kotlin.String!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: java.nio.charset.Charset!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: [ERROR : Unresolved java classifier: CharsetDecoder]!) defined in java.io.InputStreamReader
|
// ERROR: None of the following functions can be called with the arguments supplied: public constructor InputStreamReader(p0: java.io.InputStream!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: [ERROR : Unresolved java classifier: CharsetDecoder]!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: java.nio.charset.Charset!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: kotlin.String!) defined in java.io.InputStreamReader
|
||||||
// ERROR: Assignments are not expressions, and only expressions are allowed in this context
|
// ERROR: Assignments are not expressions, and only expressions are allowed in this context
|
||||||
// ERROR: Unresolved reference: close
|
// ERROR: Unresolved reference: close
|
||||||
import java.io.*
|
import java.io.*
|
||||||
|
|||||||
Reference in New Issue
Block a user