Merge branch 'master' of git.labs.intellij.net:jet

This commit is contained in:
Dmitry Jemerov
2011-03-24 15:53:05 +01:00
4 changed files with 36 additions and 6 deletions
@@ -114,6 +114,6 @@ public class BindingTraceContext extends BindingTrace implements BindingContext
@Override
public PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor) {
return descriptorToDeclarations.get(descriptor);
return descriptorToDeclarations.get(descriptor.getOriginal());
}
}
@@ -37,6 +37,10 @@ public class JavaTypeTransformer {
return JetStandardClasses.getNullableAnyType();
}
if ("java.lang.String".equals(psiClass.getQualifiedName())) {
return standardLibrary.getNullableStringType();
}
ClassDescriptor descriptor = resolver.resolveClass(psiClass);
// TODO : arguments & raw types
List<TypeProjection> arguments = Collections.<TypeProjection>emptyList(); // TODO
@@ -335,6 +335,9 @@ public class JetTypeInferrer {
if (property != null) {
trace.recordReferenceResolution(expression, property);
result = property.getOutType();
if (result == null) {
semanticServices.getErrorHandler().genericError(expression.getNode(), "This property is not readable in this context");
}
return;
} else {
NamespaceDescriptor namespace = scope.getNamespace(referencedName);
@@ -1036,9 +1039,11 @@ public class JetTypeInferrer {
List<JetType> argumentTypes = getTypes(scope, indexExpressions);
if (argumentTypes == null) return;
FunctionDescriptor functionDescriptor = lookupFunction(scope, expression, "get", receiverType, argumentTypes, true);
if (functionDescriptor != null) {
result = functionDescriptor.getUnsubstitutedReturnType();
if (receiverType != null) {
FunctionDescriptor functionDescriptor = lookupFunction(scope, expression, "get", receiverType, argumentTypes, true);
if (functionDescriptor != null) {
result = functionDescriptor.getUnsubstitutedReturnType();
}
}
}
@@ -9,6 +9,8 @@ import java.util.List;
* @author abreslav
*/
public class DescriptorUtil {
private DescriptorUtil() {}
public static String renderPresentableText(DeclarationDescriptor declarationDescriptor) {
if (declarationDescriptor == null) return "<null>";
StringBuilder stringBuilder = new StringBuilder();
@@ -16,8 +18,27 @@ public class DescriptorUtil {
new DeclarationDescriptorVisitor<Void, StringBuilder>() {
@Override
public Void visitPropertyDescriptor(PropertyDescriptor descriptor, StringBuilder builder) {
JetType type = descriptor.getOutType();
builder.append(renderName(descriptor)).append(" : ").append(type);
JetType outType = descriptor.getOutType();
JetType inType = descriptor.getInType();
String typeString = "<no type>";
if (inType != null && outType != null) {
builder.append("var ");
if (inType.equals(outType)) {
typeString = outType.toString();
}
else {
typeString = "<in " + inType + " out " + outType + ">";
}
}
else if (outType != null) {
builder.append("val ");
typeString = outType.toString();
}
else if (inType != null) {
builder.append("<write-only> ");
typeString = inType.toString();
}
builder.append(renderName(descriptor)).append(" : ").append(typeString);
return super.visitPropertyDescriptor(descriptor, builder);
}