Better rendering for PLATFORM_CLASS_MAPPED_TO_KOTLIN.

This commit is contained in:
Evgeny Gerashchenko
2012-09-17 20:53:21 +04:00
parent 8e463ac0ac
commit 9cbe853cad
2 changed files with 9 additions and 7 deletions
@@ -96,7 +96,7 @@ public class DefaultErrorMessages {
MAP.put(CANNOT_BE_IMPORTED, "Cannot import ''{0}'', functions and properties can be imported only from packages", NAME);
MAP.put(USELESS_HIDDEN_IMPORT, "Useless import, it is hidden further");
MAP.put(USELESS_SIMPLE_IMPORT, "Useless import, does nothing");
MAP.put(PLATFORM_CLASS_MAPPED_TO_KOTLIN, "This class shouldn''t be used in Kotlin. Use {0} instead.", CLASS_DESCRIPTOR_LIST);
MAP.put(PLATFORM_CLASS_MAPPED_TO_KOTLIN, "This class shouldn''t be used in Kotlin. Use {0} instead.", CLASSES_OR_SEPARATED);
MAP.put(CANNOT_INFER_PARAMETER_TYPE,
"Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) => ...} notation");
@@ -288,20 +288,22 @@ public class Renderers {
return result;
}
public static final Renderer<Collection<ClassDescriptor>> CLASS_DESCRIPTOR_LIST = new Renderer<Collection<ClassDescriptor>>() {
public static final Renderer<Collection<ClassDescriptor>> CLASSES_OR_SEPARATED = new Renderer<Collection<ClassDescriptor>>() {
@NotNull
@Override
public String render(@NotNull Collection<ClassDescriptor> descriptors) {
StringBuilder sb = new StringBuilder();
sb.append("(");
for (Iterator<ClassDescriptor> iterator = descriptors.iterator(); iterator.hasNext(); ) {
ClassDescriptor descriptor = iterator.next();
int index = 0;
for (ClassDescriptor descriptor : descriptors) {
sb.append(DescriptorUtils.getFQName(descriptor).getFqName());
if (iterator.hasNext()) {
index++;
if (index <= descriptors.size() - 2) {
sb.append(", ");
}
else if (index == descriptors.size() - 1) {
sb.append(" or ");
}
}
sb.append(")");
return sb.toString();
}
};