Reapplied Dmitry's changes to util methods
This commit is contained in:
+3
-3
@@ -32,8 +32,8 @@ import org.jetbrains.k2js.translate.utils.BindingUtils;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getClassDescriptorForType;
|
||||
import static org.jetbrains.k2js.translate.utils.JsAstUtils.*;
|
||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.getClassDescriptorForType;
|
||||
import static org.jetbrains.k2js.translate.utils.PsiUtils.getLoopRange;
|
||||
import static org.jetbrains.k2js.translate.utils.TemporariesUtils.temporariesInitialization;
|
||||
|
||||
@@ -72,8 +72,8 @@ public final class ArrayForTranslator extends ForTranslator {
|
||||
loopRange = context.declareTemporary(Translation.translateAsExpression(getLoopRange(expression), context));
|
||||
|
||||
JsExpression length = ArrayFIF.ARRAY_LENGTH_INTRINSIC.apply(loopRange.reference(),
|
||||
Collections.<JsExpression>emptyList(),
|
||||
context());
|
||||
Collections.<JsExpression>emptyList(),
|
||||
context());
|
||||
end = context().declareTemporary(length);
|
||||
index = context().declareTemporary(program().getNumberLiteral(0));
|
||||
}
|
||||
|
||||
@@ -26,18 +26,15 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.k2js.config.LibrarySourcesConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getSuperclassDescriptors;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject;
|
||||
import static org.jetbrains.k2js.translate.utils.BindingUtils.isNotAny;
|
||||
|
||||
/**
|
||||
* @author Pavel Talanov
|
||||
@@ -73,34 +70,11 @@ public final class JsDescriptorUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<ClassDescriptor> getSuperclassDescriptors(@NotNull ClassDescriptor classDescriptor) {
|
||||
Collection<? extends JetType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
List<ClassDescriptor> superClassDescriptors = new ArrayList<ClassDescriptor>();
|
||||
for (JetType type : superclassTypes) {
|
||||
ClassDescriptor result = getClassDescriptorForType(type);
|
||||
if (isNotAny(result)) {
|
||||
superClassDescriptors.add(result);
|
||||
}
|
||||
}
|
||||
return superClassDescriptors;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getSuperclass(@NotNull ClassDescriptor classDescriptor) {
|
||||
return findAncestorClass(getSuperclassDescriptors(classDescriptor));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ClassDescriptor getClassDescriptorForType(@NotNull JetType type) {
|
||||
DeclarationDescriptor superClassDescriptor =
|
||||
type.getConstructor().getDeclarationDescriptor();
|
||||
assert superClassDescriptor instanceof ClassDescriptor
|
||||
: "Superclass descriptor of a type should be of type ClassDescriptor";
|
||||
return (ClassDescriptor) superClassDescriptor;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static DeclarationDescriptor getContainingDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||
DeclarationDescriptor containing = descriptor.getContainingDeclaration();
|
||||
|
||||
Reference in New Issue
Block a user