Remove dependency of "descriptors" on StringUtil

This commit is contained in:
Alexander Udalov
2014-08-14 14:23:28 +04:00
parent df554e7c53
commit aff7619206
4 changed files with 36 additions and 18 deletions
@@ -17,8 +17,8 @@
package org.jetbrains.jet.lang.resolve.name;
import com.google.common.collect.Lists;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.utils.UtilsPackage;
import java.util.List;
@@ -26,8 +26,7 @@ public final class FqName extends FqNameBase {
@NotNull
public static FqName fromSegments(@NotNull List<String> names) {
String fqName = StringUtil.join(names, ".");
return new FqName(fqName);
return new FqName(UtilsPackage.join(names, "."));
}
public static final FqName ROOT = new FqName("");
@@ -17,9 +17,9 @@
package org.jetbrains.jet.lang.resolve.name;
import com.google.common.collect.Lists;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.utils.UtilsPackage;
import java.util.List;
@@ -256,8 +256,7 @@ public final class FqNameUnsafe extends FqNameBase {
@NotNull
public static FqNameUnsafe fromSegments(@NotNull List<Name> names) {
String fqName = StringUtil.join(names, ".");
return new FqNameUnsafe(fqName);
return new FqNameUnsafe(UtilsPackage.join(names, "."));
}
@@ -18,7 +18,6 @@ package org.jetbrains.jet.renderer;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.openapi.util.text.StringUtil;
import kotlin.Function1;
import kotlin.KotlinPackage;
import org.jetbrains.annotations.NotNull;
@@ -39,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.error.MissingDependencyErrorClass;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.utils.UtilsPackage;
import java.util.*;
@@ -408,7 +408,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
StringBuilder sb = new StringBuilder();
sb.append(renderType(annotation.getType()));
if (verbose) {
sb.append("(").append(StringUtil.join(renderAndSortAnnotationArguments(annotation), ", ")).append(")");
sb.append("(").append(UtilsPackage.join(renderAndSortAnnotationArguments(annotation), ", ")).append(")");
}
return sb.toString();
}
@@ -436,15 +436,15 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
@Override
public String visitArrayValue(ArrayValue value, Void data) {
List<CompileTimeConstant<?>> elements = value.getValue();
if (elements.isEmpty()) return "{}";
List<String> renderedElements = KotlinPackage.map(elements, new Function1<CompileTimeConstant<?>, String>() {
@Override
public String invoke(CompileTimeConstant<?> constant) {
return renderConstant(constant);
}
});
return "{" + StringUtil.join(renderedElements, ", ") + "}";
List<String> renderedElements =
KotlinPackage.map(value.getValue(),
new Function1<CompileTimeConstant<?>, String>() {
@Override
public String invoke(CompileTimeConstant<?> constant) {
return renderConstant(constant);
}
});
return "{" + UtilsPackage.join(renderedElements, ", ") + "}";
}
@Override
@@ -681,7 +681,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
}
if (!upperBoundStrings.isEmpty()) {
builder.append(" ").append(renderKeyword("where")).append(" ");
builder.append(StringUtil.join(upperBoundStrings, ", "));
builder.append(UtilsPackage.join(upperBoundStrings, ", "));
}
}
@@ -0,0 +1,20 @@
/*
* 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.utils
// Needed for Java interop: otherwise you need to specify all the optional parameters to join, i.e. prefix, postfix, limit, truncated
fun Iterable<Any>.join(separator: String) = joinToString(separator)