Replace KotlinPackage legacy facade with corresponding package parts.

This commit is contained in:
Ilya Gorbunov
2015-10-01 22:31:17 +03:00
parent 80e4ba8712
commit 90e5ee8a7e
64 changed files with 214 additions and 206 deletions
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.DataOutputStream;
import kotlin.KotlinPackage;
import kotlin.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -120,7 +120,7 @@ public class ClassFileFactory implements OutputFileCollection {
if (builder.getPackagePartsCount() != 0) {
state.getProgress().reportOutput(sourceFiles, new File(outputFilePath));
generators.put(outputFilePath, new OutAndSourceFileList(KotlinPackage.toList(sourceFiles)) {
generators.put(outputFilePath, new OutAndSourceFileList(CollectionsKt.toList(sourceFiles)) {
@Override
public byte[] asBytes(ClassBuilderFactory factory) {
try {
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen;
import com.google.common.collect.Lists;
import com.intellij.util.ArrayUtil;
import kotlin.KotlinPackage;
import kotlin.CollectionsKt;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
@@ -283,7 +283,7 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
Type[] myParameterTypes = bridge.getArgumentTypes();
List<ParameterDescriptor> calleeParameters = KotlinPackage.plus(
List<ParameterDescriptor> calleeParameters = CollectionsKt.plus(
UtilsPackage.<ParameterDescriptor>singletonOrEmptyList(funDescriptor.getExtensionReceiverParameter()),
funDescriptor.getValueParameters()
);
@@ -24,7 +24,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.Stack;
import kotlin.KotlinPackage;
import kotlin.CollectionsKt;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
@@ -1489,7 +1489,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
Collection<ConstructorDescriptor> constructors = classDescriptor.getConstructors();
assert constructors.size() == 1 : "Unexpected number of constructors for class: " + classDescriptor + " " + constructors;
ConstructorDescriptor constructorDescriptor = KotlinPackage.single(constructors);
ConstructorDescriptor constructorDescriptor = CollectionsKt.single(constructors);
JvmMethodSignature constructor = typeMapper.mapSignature(SamCodegenUtil.resolveSamAdapter(constructorDescriptor));
v.invokespecial(type.getInternalName(), "<init>", constructor.getAsmMethod().getDescriptor(), false);
@@ -2750,7 +2750,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
assert state.getReflectionTypes().getKClass().getTypeConstructor().equals(type.getConstructor())
: "::class expression should be type checked to a KClass: " + type;
return generateClassLiteralReference(typeMapper, KotlinPackage.single(type.getArguments()).getType());
return generateClassLiteralReference(typeMapper, CollectionsKt.single(type.getArguments()).getType());
}
@Override
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.codegen;
import kotlin.KotlinPackage;
import kotlin.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.state.GenerationState;
@@ -149,7 +149,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
int receivers = (referencedFunction.getDispatchReceiverParameter() != null ? 1 : 0) +
(referencedFunction.getExtensionReceiverParameter() != null ? 1 : 0);
List<ValueParameterDescriptor> parameters = KotlinPackage.drop(callableDescriptor.getValueParameters(), receivers);
List<ValueParameterDescriptor> parameters = CollectionsKt.drop(callableDescriptor.getValueParameters(), receivers);
for (int i = 0; i < parameters.size(); i++) {
ValueParameterDescriptor parameter = parameters.get(i);
ValueArgument fakeArgument = fakeArguments.get(i);
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.psi.PsiElement;
import com.intellij.util.ArrayUtil;
import kotlin.KotlinPackage;
import kotlin.CollectionsKt;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
@@ -76,7 +76,6 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
import java.util.*;
import static kotlin.KotlinPackage.firstOrNull;
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedSubclass;
@@ -809,7 +808,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(getBuiltIns(descriptor).getArrayType(INVARIANT, descriptor.getDefaultType()));
FunctionDescriptor valuesFunction =
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUES, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
CollectionsKt.single(descriptor.getStaticScope().getFunctions(ENUM_VALUES, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
@Override
public Boolean invoke(FunctionDescriptor descriptor) {
return CodegenUtil.isEnumValuesMethod(descriptor);
@@ -829,7 +828,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateEnumValueOfMethod() {
FunctionDescriptor valueOfFunction =
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
CollectionsKt.single(descriptor.getStaticScope().getFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
@Override
public Boolean invoke(FunctionDescriptor descriptor) {
return CodegenUtil.isEnumValueOfMethod(descriptor);
@@ -1005,7 +1004,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return;
}
JetObjectDeclaration companionObject = firstOrNull(((JetClass) myClass).getCompanionObjects());
JetObjectDeclaration companionObject = CollectionsKt.firstOrNull(((JetClass) myClass).getCompanionObjects());
assert companionObject != null : "Companion object not found: " + myClass.getText();
StackValue.Field field = StackValue.singleton(companionObjectDescriptor, typeMapper);
@@ -1067,7 +1066,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateCompanionObjectInitializer(@NotNull ClassDescriptor companionObject) {
ExpressionCodegen codegen = createOrGetClInitCodegen();
FunctionDescriptor constructor = (FunctionDescriptor) context.accessibleDescriptor(
KotlinPackage.single(companionObject.getConstructors()), /* superCallExpression = */ null
CollectionsKt.single(companionObject.getConstructors()), /* superCallExpression = */ null
);
generateMethodCallTo(constructor, null, codegen.v);
codegen.v.dup();
@@ -1674,7 +1673,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateEnumEntries() {
if (descriptor.getKind() != ClassKind.ENUM_CLASS) return;
List<JetEnumEntry> enumEntries = KotlinPackage.filterIsInstance(element.getDeclarations(), JetEnumEntry.class);
List<JetEnumEntry> enumEntries = CollectionsKt.filterIsInstance(element.getDeclarations(), JetEnumEntry.class);
for (JetEnumEntry enumEntry : enumEntries) {
ClassDescriptor descriptor = getNotNull(bindingContext, BindingContext.CLASS, enumEntry);
@@ -17,7 +17,8 @@
package org.jetbrains.kotlin.codegen;
import com.intellij.psi.PsiElement;
import kotlin.KotlinPackage;
import kotlin.CollectionsKt;
import kotlin.StringsKt;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -123,7 +124,7 @@ public class JvmCodegenUtil {
}
public static boolean hasAbstractMembers(@NotNull ClassDescriptor classDescriptor) {
return KotlinPackage.any(classDescriptor.getDefaultType().getMemberScope().getAllDescriptors(),
return CollectionsKt.any(classDescriptor.getDefaultType().getMemberScope().getAllDescriptors(),
new Function1<DeclarationDescriptor, Boolean>() {
@Override
public Boolean invoke(DeclarationDescriptor descriptor) {
@@ -220,7 +221,7 @@ public class JvmCodegenUtil {
@NotNull
public static String getModuleName(ModuleDescriptor module) {
return KotlinPackage.removeSurrounding(module.getName().asString(), "<", ">");
return StringsKt.removeSurrounding(module.getName().asString(), "<", ">");
}
@NotNull
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import kotlin.StringsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -44,9 +45,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage;
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
import org.jetbrains.kotlin.resolve.jvm.JvmClassName;
import org.jetbrains.kotlin.serialization.ProtoBuf;
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor;
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf;
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
@@ -59,7 +57,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ListIterator;
import static kotlin.KotlinPackage.substringAfterLast;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isInterface;
@@ -157,7 +154,7 @@ public class InlineCodegenUtil {
@Nullable
public static VirtualFile findVirtualFile(@NotNull Project project, @NotNull String internalClassName) {
FqName packageFqName = JvmClassName.byInternalName(internalClassName).getPackageFqName();
String classNameWithDollars = substringAfterLast(internalClassName, "/", internalClassName);
String classNameWithDollars = StringsKt.substringAfterLast(internalClassName, "/", internalClassName);
JvmVirtualFileFinder fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project);
//TODO: we cannot construct proper classId at this point, we need to read InnerClasses info from class file
// we construct valid.package.name/RelativeClassNameAsSingleName that should work in compiler, but fails for inner classes in IDE