RENDER_COLLECTION_OF_TYPES changed

This commit is contained in:
Svetlana Isakova
2012-12-25 18:51:34 +04:00
parent 76a62d8b7d
commit 93fd2bf10f
4 changed files with 39 additions and 10 deletions
@@ -19,7 +19,9 @@ package org.jetbrains.jet.lang.diagnostics.rendering;
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
@@ -314,15 +316,12 @@ public class Renderers {
@NotNull
@Override
public String render(@NotNull Collection<JetType> types) {
StringBuilder builder = new StringBuilder();
for (Iterator<JetType> iterator = types.iterator(); iterator.hasNext(); ) {
JetType jetType = iterator.next();
builder.append(jetType);
if (iterator.hasNext()) {
builder.append(", ");
return StringUtil.join(types, new Function<JetType, String>() {
@Override
public String fun(JetType type) {
return RENDER_TYPE.render(type);
}
}
return builder.toString();
}, ", ");
}
};
@@ -0,0 +1,11 @@
package aa
import java.util.ArrayList
fun foo(f: (List<Int>, ArrayList<String>) -> MutableMap<Int, String>) = f
fun test() {
foo {
""
}
}
@@ -0,0 +1,2 @@
<!-- renderCollectionOfTypes1 -->
Expected 2 parameters of types jet.List<jet.Int>, java.util.ArrayList<jet.String>
@@ -26,6 +26,7 @@ import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.lang.diagnostics.AbstractDiagnosticFactory;
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.diagnostics.rendering.DefaultErrorMessages;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -67,8 +68,20 @@ public class HtmlTabledDescriptorRendererTest extends JetLiteFixture {
int index = 1;
for (Diagnostic diagnostic : diagnostics) {
String readableDiagnosticHtml = "<!-- " + name + index + " -->\n" + IdeErrorMessages.RENDERER.render(diagnostic).replaceAll(">", ">\n");
assertSameLinesWithFile(getTestDataPath() + "/" + name + index + ".html", readableDiagnosticHtml);
String readableDiagnosticText;
String extension;
if (IdeErrorMessages.MAP.get(diagnostic.getFactory()) != null) {
readableDiagnosticText = IdeErrorMessages.RENDERER.render(diagnostic).replaceAll(">", ">\n");
extension = "html";
}
else {
readableDiagnosticText = DefaultErrorMessages.RENDERER.render(diagnostic);
extension = "txt";
}
String errorMessageFileName = name + index;
String path = getTestDataPath() + "/" + errorMessageFileName + "." + extension;
String actualText = "<!-- " + errorMessageFileName + " -->\n" + readableDiagnosticText;
assertSameLinesWithFile(path, actualText);
index++;
}
@@ -81,4 +94,8 @@ public class HtmlTabledDescriptorRendererTest extends JetLiteFixture {
public void testFunctionPlaceholder() throws Exception {
doTest("functionPlaceholder", 3, Errors.TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH);
}
public void testRenderCollectionOfTypes() throws Exception {
doTest("renderCollectionOfTypes", 1, Errors.EXPECTED_PARAMETERS_NUMBER_MISMATCH);
}
}