From efa00782a4accbcce05a7a13491e68d3b4128ef3 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 18 Apr 2014 15:59:09 +0400 Subject: [PATCH] Reformat html test data for DiagnosticMessageTest --- .../conflictingOverloadsClass1.html | 9 +- .../conflictingOverloadsClass2.html | 9 +- .../conflictingSubstitutions1.html | 136 +++++------------- .../conflictingSubstitutions2.html | 132 +++++------------ .../functionPlaceholder1.html | 53 ++----- .../functionPlaceholder2.html | 53 ++----- .../functionPlaceholder3.html | 53 ++----- .../diagnosticMessage/numberValueTypes1.html | 21 +-- .../diagnosticMessage/numberValueTypes2.html | 21 +-- .../diagnosticMessage/numberValueTypes3.html | 53 ++----- .../diagnosticMessage/numberValueTypes4.html | 132 +++++------------ .../typeInferenceExpectedTypeMismatch1.html | 21 +-- .../typeInferenceExpectedTypeMismatch2.html | 21 +-- .../typeInferenceExpectedTypeMismatch3.html | 21 +-- .../typeMismatchWithNothing1.html | 15 +- .../AbstractDiagnosticMessageTest.java | 4 +- .../jet/plugin/highlighter/FormatHtmlUtil.kt | 40 ++++++ 17 files changed, 238 insertions(+), 556 deletions(-) create mode 100644 idea/tests/org/jetbrains/jet/plugin/highlighter/FormatHtmlUtil.kt diff --git a/idea/testData/diagnosticMessage/conflictingOverloadsClass1.html b/idea/testData/diagnosticMessage/conflictingOverloadsClass1.html index 007b2b855dd..4f9b8fd762d 100644 --- a/idea/testData/diagnosticMessage/conflictingOverloadsClass1.html +++ b/idea/testData/diagnosticMessage/conflictingOverloadsClass1.html @@ -1,10 +1,3 @@ -' -internal - -final - -fun - lol(x: kotlin.Int): kotlin.Int'
-is already defined in conflictingOverloads +'internal final fun lol(x: kotlin.Int): kotlin.Int'
is already defined in conflictingOverloads \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/conflictingOverloadsClass2.html b/idea/testData/diagnosticMessage/conflictingOverloadsClass2.html index f2533361b3b..3b5e6499f45 100644 --- a/idea/testData/diagnosticMessage/conflictingOverloadsClass2.html +++ b/idea/testData/diagnosticMessage/conflictingOverloadsClass2.html @@ -1,10 +1,3 @@ -' -internal - -final - -fun - lol(y: kotlin.Int): kotlin.Int'
-is already defined in conflictingOverloads +'internal final fun lol(y: kotlin.Int): kotlin.Int'
is already defined in conflictingOverloads \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/conflictingSubstitutions1.html b/idea/testData/diagnosticMessage/conflictingSubstitutions1.html index 8bad7c72b65..ca36f85d8a8 100644 --- a/idea/testData/diagnosticMessage/conflictingSubstitutions1.html +++ b/idea/testData/diagnosticMessage/conflictingSubstitutions1.html @@ -1,118 +1,48 @@ -Type inference failed: Cannot infer type parameter -T - in +Type inference failed: Cannot infer type parameter T in +
- - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + +
- - -fun - <T, E : java.lang.Cloneable> - writeToMyList -( -l: MyList<in T>, -t: T -) -: kotlin.Unit -where - E : java.io.Closeablefun <`T, E : java.lang.Cloneable> writeToMyList(l: MyList<`in T>,t: T): kotlin.Unit where E : java.io.Closeable
-None of the following substitutionsNone of the following substitutions
- - - - -( - - - -MyList<in kotlin.Any> - - -, - - -kotlin.Any - - -) -(MyList<`in kotlin.Any>,kotlin.Any)
- - - - -( - - -MyList<in kotlin.Int> - -, - - - -kotlin.Int - - - -) -(MyList<`in kotlin.Int>,kotlin.Int)
-can be applied tocan be applied to
- - - - -( - - -MyList<kotlin.Int> - -, - - -kotlin.Any - - -) -(MyList<`kotlin.Int>,kotlin.Any)
- + \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/conflictingSubstitutions2.html b/idea/testData/diagnosticMessage/conflictingSubstitutions2.html index 3e05ada7063..c1e2155fcac 100644 --- a/idea/testData/diagnosticMessage/conflictingSubstitutions2.html +++ b/idea/testData/diagnosticMessage/conflictingSubstitutions2.html @@ -1,116 +1,48 @@ -Type inference failed: Cannot infer type parameter -T - in +Type inference failed: Cannot infer type parameter T in +
- - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + +
- - -constructor - Cons<T, E : java.lang.Cloneable> - -( -l: MyList<in T>, -t: T -) -constructor Cons<`T, E : java.lang.Cloneable>(l: MyList<`in T>,t: T)
-None of the following substitutionsNone of the following substitutions
- - - - -( - - - -MyList<in kotlin.Any> - - -, - - -kotlin.Any - - -) -(MyList<`in kotlin.Any>,kotlin.Any)
- - - - -( - - -MyList<in kotlin.Int> - -, - - - -kotlin.Int - - - -) -(MyList<`in kotlin.Int>,kotlin.Int)
-can be applied tocan be applied to
- - - - -( - - -MyList<kotlin.Int> - -, - - -kotlin.Any - - -) -(MyList<`kotlin.Int>,kotlin.Any)
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/functionPlaceholder1.html b/idea/testData/diagnosticMessage/functionPlaceholder1.html index bb469c38083..4505cc77745 100644 --- a/idea/testData/diagnosticMessage/functionPlaceholder1.html +++ b/idea/testData/diagnosticMessage/functionPlaceholder1.html @@ -1,48 +1,25 @@ -Type inference failed: +Type inference failed: +
- - - - - - + + + + + + - + - - - - - - + + + + + +
- - -fun - <T, R> - foo -( -a: A<T, R> -) -: A<T, R>fun <`T, R> foo(a: A<`T, R>): A<`T, R>
-cannot be applied tocannot be applied to
- - - - -( - - - -() → ??? - - - -) -(() → ???)
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/functionPlaceholder2.html b/idea/testData/diagnosticMessage/functionPlaceholder2.html index d18f4dbc9a5..f93271a6173 100644 --- a/idea/testData/diagnosticMessage/functionPlaceholder2.html +++ b/idea/testData/diagnosticMessage/functionPlaceholder2.html @@ -1,48 +1,25 @@ -Type inference failed: +Type inference failed: +
- - - - - - + + + + + + - + - - - - - - + + + + + +
- - -fun - <T, R> - foo -( -a: A<T, R> -) -: A<T, R>fun <`T, R> foo(a: A<`T, R>): A<`T, R>
-cannot be applied tocannot be applied to
- - - - -( - - - -(???) → ??? - - - -) -((???) → ???)
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/functionPlaceholder3.html b/idea/testData/diagnosticMessage/functionPlaceholder3.html index 08efebf7a73..b3d58210157 100644 --- a/idea/testData/diagnosticMessage/functionPlaceholder3.html +++ b/idea/testData/diagnosticMessage/functionPlaceholder3.html @@ -1,48 +1,25 @@ -Type inference failed: +Type inference failed: +
- - - - - - + + + + + + - + - - - - - - + + + + + +
- - -fun - <T, R> - foo -( -a: A<T, R> -) -: A<T, R>fun <`T, R> foo(a: A<`T, R>): A<`T, R>
-cannot be applied tocannot be applied to
- - - - -( - - - -(kotlin.Int) → kotlin.Int - - - -) -((kotlin.Int) → kotlin.Int)
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/numberValueTypes1.html b/idea/testData/diagnosticMessage/numberValueTypes1.html index 5486a27afe8..4478c57bcf4 100644 --- a/idea/testData/diagnosticMessage/numberValueTypes1.html +++ b/idea/testData/diagnosticMessage/numberValueTypes1.html @@ -1,23 +1,14 @@ -Type inference failed. Expected type mismatch: +Type inference failed. Expected type mismatch: +
- - + + - - + +
-required: - -kotlin.Int -required: kotlin.Int
-found: - - -kotlin.Long - -found: kotlin.Long
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/numberValueTypes2.html b/idea/testData/diagnosticMessage/numberValueTypes2.html index 317d8277ea3..8c73c0e5a47 100644 --- a/idea/testData/diagnosticMessage/numberValueTypes2.html +++ b/idea/testData/diagnosticMessage/numberValueTypes2.html @@ -1,23 +1,14 @@ -Type inference failed. Expected type mismatch: +Type inference failed. Expected type mismatch: +
- - + + - - + +
-required: - -kotlin.Byte -required: kotlin.Byte
-found: - - -kotlin.Int - -found: kotlin.Int
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/numberValueTypes3.html b/idea/testData/diagnosticMessage/numberValueTypes3.html index 8a03aab200c..e547ad375cc 100644 --- a/idea/testData/diagnosticMessage/numberValueTypes3.html +++ b/idea/testData/diagnosticMessage/numberValueTypes3.html @@ -1,48 +1,25 @@ -Type inference failed: +Type inference failed: +
- - - - - - + + + + + + - + - - - - - - + + + + + +
- - -fun - <T> - foo -( -l: kotlin.List<T> -) -: kotlin.Unitfun <`T> foo(l: kotlin.List<`T>): kotlin.Unit
-cannot be applied tocannot be applied to
- - - - -( - - - -kotlin.Int - - - -) -(kotlin.Int)
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/numberValueTypes4.html b/idea/testData/diagnosticMessage/numberValueTypes4.html index 454712a72f6..873901302a3 100644 --- a/idea/testData/diagnosticMessage/numberValueTypes4.html +++ b/idea/testData/diagnosticMessage/numberValueTypes4.html @@ -1,116 +1,48 @@ -Type inference failed: Cannot infer type parameter -T - in +Type inference failed: Cannot infer type parameter T in +
- - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + +
- - -fun - <T> - bar -( -t: T, -l: kotlin.MutableList<T> -) -: kotlin.Unitfun <`T> bar(t: T,l: kotlin.MutableList<`T>): kotlin.Unit
-None of the following substitutionsNone of the following substitutions
- - - - -( - - - -kotlin.String - - -, - - -kotlin.MutableList<kotlin.String> - - -) -(kotlin.String,kotlin.MutableList<`kotlin.String>)
- - - - -( - - -kotlin.Int - -, - - - -kotlin.MutableList<kotlin.Int> - - - -) -(kotlin.Int,kotlin.MutableList<`kotlin.Int>)
-can be applied tocan be applied to
- - - - -( - - -kotlin.Int - -, - - -kotlin.MutableList<kotlin.String> - - -) -(kotlin.Int,kotlin.MutableList<`kotlin.String>)
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch1.html b/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch1.html index ea304ca2ba3..58ee0551803 100644 --- a/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch1.html +++ b/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch1.html @@ -1,23 +1,14 @@ -Type inference failed. Expected type mismatch: +Type inference failed. Expected type mismatch: +
- - + + - - + +
-required: - -kotlin.String -required: kotlin.String
-found: - - -kotlin.Int - -found: kotlin.Int
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch2.html b/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch2.html index f0db7f965df..3f48824a878 100644 --- a/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch2.html +++ b/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch2.html @@ -1,23 +1,14 @@ -Type inference failed. Expected type mismatch: +Type inference failed. Expected type mismatch: +
- - + + - - + +
-required: - -kotlin.List<kotlin.Int> -required: kotlin.List<`kotlin.Int>
-found: - - -kotlin.Set<kotlin.Int> - -found: kotlin.Set<`kotlin.Int>
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch3.html b/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch3.html index 163beaa95b1..48218e74da1 100644 --- a/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch3.html +++ b/idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch3.html @@ -1,23 +1,14 @@ -Type inference failed. Expected type mismatch: +Type inference failed. Expected type mismatch: +
- - + + - - + +
-required: - -kotlin.Set<kotlin.String> -required: kotlin.Set<`kotlin.String>
-found: - - -kotlin.Set<kotlin.Int> - -found: kotlin.Set<`kotlin.Int>
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/typeMismatchWithNothing1.html b/idea/testData/diagnosticMessage/typeMismatchWithNothing1.html index 86b5d53f41f..430b7e274e7 100644 --- a/idea/testData/diagnosticMessage/typeMismatchWithNothing1.html +++ b/idea/testData/diagnosticMessage/typeMismatchWithNothing1.html @@ -1,17 +1,14 @@ -Type mismatch. +Type mismatch. +
- - + + - - + +
-Required: -b.A<???>Required:b.A<`???>
-Found: -kotlin.Nothing?Found:kotlin.Nothing?
\ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/highlighter/AbstractDiagnosticMessageTest.java b/idea/tests/org/jetbrains/jet/plugin/highlighter/AbstractDiagnosticMessageTest.java index 3d0658b4543..43b7b8bc84a 100644 --- a/idea/tests/org/jetbrains/jet/plugin/highlighter/AbstractDiagnosticMessageTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/highlighter/AbstractDiagnosticMessageTest.java @@ -42,6 +42,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import static org.jetbrains.jet.plugin.highlighter.formatHtml.FormatHtmlPackage.formatHtml; + public abstract class AbstractDiagnosticMessageTest extends JetLiteFixture { private static final String DIAGNOSTICS_NUMBER_DIRECTIVE = "DIAGNOSTICS_NUMBER"; private static final String DIAGNOSTICS_DIRECTIVE = "DIAGNOSTICS"; @@ -98,7 +100,7 @@ public abstract class AbstractDiagnosticMessageTest extends JetLiteFixture { String readableDiagnosticText; String extension; if (messageType != MessageType.TEXT && IdeErrorMessages.MAP.get(diagnostic.getFactory()) != null) { - readableDiagnosticText = IdeErrorMessages.RENDERER.render(diagnostic).replaceAll(">", ">\n"); + readableDiagnosticText = formatHtml(IdeErrorMessages.RENDERER.render(diagnostic)); extension = MessageType.HTML.extension; } else { diff --git a/idea/tests/org/jetbrains/jet/plugin/highlighter/FormatHtmlUtil.kt b/idea/tests/org/jetbrains/jet/plugin/highlighter/FormatHtmlUtil.kt new file mode 100644 index 00000000000..d8660d5b0ba --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/highlighter/FormatHtmlUtil.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2014 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.jet.plugin.highlighter.formatHtml + +private fun formatHtml(html: String): String { + var message = html + fun wrapTagWithNewLines(tagName: String, isSubTag: Boolean) { + val openTagPart = "<$tagName" + val indent = if (isSubTag) " " else "" + message = message.replace(openTagPart, "\n$indent$openTagPart") + + val tagPart = if (isSubTag) "/$tagName>" else "$tagName>" + message = message.replace(tagPart, "$tagPart\n") + } + + for (tag in listOf("html", "ul", "table", "tr")) { + wrapTagWithNewLines(tag, isSubTag = false) + } + for (tag in listOf("li", "td")) { + wrapTagWithNewLines(tag, isSubTag = true) + } + message = message.replace("
", "
\n").replace(" ", " ") + message = message.replace("<", "<`").replace(">", ">") + message = message.split("(\r|\n|\r\n)+").map { s -> s.trimTrailing() }.filter { s -> !s.isEmpty() }.makeString("\n") + return message +} \ No newline at end of file