Kotlin compiler update to v0.1.100
Statistics view changed Logs without localhost requests
This commit is contained in:
committed by
unknown
parent
5ab485b072
commit
8780b2c2ab
@@ -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<FunctionDescriptor> 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<VariableDescriptor> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user