From 8780b2c2abfc7561911a13f68d97e137e661fc2f Mon Sep 17 00:00:00 2001 From: "Natalia.Ukhorskaya" Date: Tue, 27 Dec 2011 14:18:52 +0400 Subject: [PATCH] Kotlin compiler update to v0.1.100 Statistics view changed Logs without localhost requests --- .../k2js/translate/utils/DescriptorUtils.java | 60 ++----------------- 1 file changed, 5 insertions(+), 55 deletions(-) diff --git a/translator/src/org/jetbrains/k2js/translate/utils/DescriptorUtils.java b/translator/src/org/jetbrains/k2js/translate/utils/DescriptorUtils.java index af2ea09b5d6..1dc0e7b9bc0 100644 --- a/translator/src/org/jetbrains/k2js/translate/utils/DescriptorUtils.java +++ b/translator/src/org/jetbrains/k2js/translate/utils/DescriptorUtils.java @@ -4,7 +4,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.resolve.scopes.JetScope; -import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.expressions.OperatorConventions; import java.util.ArrayList; @@ -36,7 +35,7 @@ public final class DescriptorUtils { return (functionDescriptor.getName().equals(OperatorConventions.COMPARE_TO)); } - public static boolean isConstructorDescriptor(@NotNull CallableDescriptor descriptor) { + public static boolean isConstructorDescriptor(@NotNull FunctionDescriptor descriptor) { return (descriptor instanceof ConstructorDescriptor); } @@ -72,8 +71,7 @@ public final class DescriptorUtils { @NotNull String name) { Set functionDescriptors = scope.getFunctions(name); assert functionDescriptors.size() == 1 : - "In scope " + scope + " supposed to be exactly one " + name + " function.\n" + - "Found: " + functionDescriptors.size(); + "In scope " + scope + " supposed to be exactly one " + name + " function."; //noinspection LoopStatementThatDoesntLoop for (FunctionDescriptor descriptor : functionDescriptors) { return descriptor; @@ -82,17 +80,13 @@ public final class DescriptorUtils { + " supposed to be exactly one " + name + " function."); } - //TODO: some stange stuff happening to this method @NotNull public static PropertyDescriptor getPropertyByName(@NotNull JetScope scope, @NotNull String name) { VariableDescriptor variable = scope.getLocalVariable(name); if (variable == null) { - variable = scope.getPropertyByFieldReference("$" + name); + variable = org.jetbrains.jet.lang.resolve.DescriptorUtils.filterNonExtensionProperty(scope.getProperties(name)); } - Set variables = scope.getProperties(name); - assert variables.size() == 1 : "Actual size: " + variables.size(); - variable = variables.iterator().next(); PropertyDescriptor descriptor = (PropertyDescriptor) variable; assert descriptor != null : "Must have a descriptor."; return descriptor; @@ -128,60 +122,16 @@ public final class DescriptorUtils { return containing; } - public static boolean isExtensionFunction(@NotNull CallableDescriptor functionDescriptor) { + public static boolean isExtensionFunction(@NotNull FunctionDescriptor functionDescriptor) { return (functionDescriptor.getReceiverParameter().exists()); } - //TODO: make "anonymous" a constant @NotNull - public static String getNameForNamespace(@NotNull NamespaceDescriptor descriptor) { + public static String nameForNamespace(@NotNull NamespaceDescriptor descriptor) { String name = descriptor.getName(); if (name.equals("")) { return "Anonymous"; } return name; } - - //TODO: why callable descriptor - @Nullable - public static DeclarationDescriptor getExpectedThisDescriptor(@NotNull CallableDescriptor callableDescriptor) { - ReceiverDescriptor expectedThisObject = callableDescriptor.getExpectedThisObject(); - if (!expectedThisObject.exists()) { - return null; - } - return getDeclarationDescriptorForReceiver(expectedThisObject); - } - - @NotNull - public static DeclarationDescriptor getDeclarationDescriptorForReceiver - (@NotNull ReceiverDescriptor receiverParameter) { - DeclarationDescriptor declarationDescriptor = - receiverParameter.getType().getConstructor().getDeclarationDescriptor(); - //TODO: WHY assert? - assert declarationDescriptor != null; - return declarationDescriptor.getOriginal(); - } - - @Nullable - public static DeclarationDescriptor getExpectedReceiverDescriptor(@NotNull CallableDescriptor callableDescriptor) { - ReceiverDescriptor receiverParameter = callableDescriptor.getReceiverParameter(); - if (!receiverParameter.exists()) { - return null; - } - return getDeclarationDescriptorForReceiver(receiverParameter); - } - - //TODO: maybe we have similar routine - @Nullable - public static ClassDescriptor getContainingClass(@NotNull DeclarationDescriptor descriptor) { - DeclarationDescriptor containing = descriptor.getContainingDeclaration(); - while (containing != null) { - if (containing instanceof ClassDescriptor) { - return (ClassDescriptor) containing; - } - containing = containing.getContainingDeclaration(); - } - return null; - } - }