Name class
In the most places in frontend identifier is stored in Name class, was in String. Name has two advantages over String: * validation: you cannot accidentally create identifier with dot, for example * readability: if you see String, you don't now whether it is identifier, fq name, jvm class name or something else Name's disadvantage is (small) performance overhead. We have no value types in JVM.
This commit is contained in:
@@ -135,13 +135,6 @@ public final class TipsManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (descriptor instanceof NamespaceDescriptor) {
|
||||
NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) descriptor;
|
||||
if (namespaceDescriptor.getName().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.objectweb.asm.*;
|
||||
|
||||
@@ -101,8 +102,8 @@ public abstract class AnnotationCodegen {
|
||||
continue;
|
||||
}
|
||||
|
||||
String keyName = entry.getKey().getName();
|
||||
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName);
|
||||
Name keyName = entry.getKey().getName();
|
||||
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ public abstract class AnnotationCodegen {
|
||||
if(call != null) {
|
||||
if(call.getResultingDescriptor() instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor descriptor = (PropertyDescriptor)call.getResultingDescriptor();
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(), descriptor.getName());
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(), descriptor.getName().getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -154,7 +155,7 @@ public abstract class AnnotationCodegen {
|
||||
String value = null;
|
||||
if (annotations != null) {
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) {
|
||||
value = (String) annotation.getValueArguments().get(0).getValue();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
|
||||
@@ -74,7 +75,7 @@ public class ClosureAnnotator {
|
||||
funDescriptor,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
// TODO: internal name used as identifier
|
||||
name.getInternalName()); // TODO:
|
||||
Name.identifier(name.getInternalName())); // TODO:
|
||||
classDescriptor.initialize(
|
||||
false,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
@@ -126,8 +127,7 @@ public class ClosureAnnotator {
|
||||
}
|
||||
|
||||
public boolean hasThis0(ClassDescriptor classDescriptor) {
|
||||
if(DescriptorUtils.isClassObject(classDescriptor))
|
||||
return false;
|
||||
if (DescriptorUtils.isClassObject(classDescriptor)) { return false; }
|
||||
|
||||
ClassDescriptor other = enclosing.get(classDescriptor);
|
||||
return other != null;
|
||||
@@ -208,11 +208,10 @@ public class ClosureAnnotator {
|
||||
recordEnclosing(classDescriptor);
|
||||
classStack.push(classDescriptor);
|
||||
String base = nameStack.peek();
|
||||
if(classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
nameStack.push(base.isEmpty() ? classDescriptor.getName() : base + '/' + classDescriptor.getName());
|
||||
if (classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
nameStack.push(base.isEmpty() ? classDescriptor.getName().getName() : base + '/' + classDescriptor.getName());
|
||||
}
|
||||
else
|
||||
nameStack.push(base + '$' + classDescriptor.getName());
|
||||
else { nameStack.push(base + '$' + classDescriptor.getName()); }
|
||||
super.visitObjectDeclaration(declaration);
|
||||
nameStack.pop();
|
||||
classStack.pop();
|
||||
@@ -227,11 +226,10 @@ public class ClosureAnnotator {
|
||||
recordEnclosing(classDescriptor);
|
||||
classStack.push(classDescriptor);
|
||||
String base = nameStack.peek();
|
||||
if(classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
nameStack.push(base.isEmpty() ? classDescriptor.getName() : base + '/' + classDescriptor.getName());
|
||||
if (classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
nameStack.push(base.isEmpty() ? classDescriptor.getName().getName() : base + '/' + classDescriptor.getName());
|
||||
}
|
||||
else
|
||||
nameStack.push(base + '$' + classDescriptor.getName());
|
||||
else { nameStack.push(base + '$' + classDescriptor.getName()); }
|
||||
super.visitClass(klass);
|
||||
nameStack.pop();
|
||||
classStack.pop();
|
||||
@@ -298,10 +296,8 @@ public class ClosureAnnotator {
|
||||
}
|
||||
else if (containingDeclaration instanceof NamespaceDescriptor) {
|
||||
String peek = nameStack.peek();
|
||||
if(peek.isEmpty())
|
||||
peek = "namespace";
|
||||
else
|
||||
peek = peek + "/namespace";
|
||||
if (peek.isEmpty()) { peek = "namespace"; }
|
||||
else { peek = peek + "/namespace"; }
|
||||
nameStack.push(peek + '$' + function.getName());
|
||||
super.visitNamedFunction(function);
|
||||
nameStack.pop();
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
@@ -99,7 +100,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
||||
}
|
||||
|
||||
public JvmMethodSignature invokeSignature(FunctionDescriptor fd) {
|
||||
return state.getInjector().getJetTypeMapper().mapSignature("invoke", fd);
|
||||
return state.getInjector().getJetTypeMapper().mapSignature(Name.identifier("invoke"), fd);
|
||||
}
|
||||
|
||||
public GeneratedAnonymousClassDescriptor gen(JetExpression fun) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.InstructionAdapter;
|
||||
@@ -97,8 +98,7 @@ public abstract class CodegenContext {
|
||||
}
|
||||
|
||||
protected StackValue getOuterExpression(@Nullable StackValue prefix) {
|
||||
if(outerExpression == null)
|
||||
throw new UnsupportedOperationException();
|
||||
if (outerExpression == null) { throw new UnsupportedOperationException(); }
|
||||
|
||||
outerWasUsed = outerExpression.type;
|
||||
return prefix != null ? StackValue.composed(prefix, outerExpression) : outerExpression;
|
||||
@@ -173,8 +173,7 @@ public abstract class CodegenContext {
|
||||
final ObjectOrClosureCodegen top = closure;
|
||||
if (top != null) {
|
||||
final StackValue answer = top.lookupInContext(d, result);
|
||||
if (answer != null)
|
||||
return result == null ? answer : StackValue.composed(result, answer);
|
||||
if (answer != null) { return result == null ? answer : StackValue.composed(result, answer); }
|
||||
|
||||
StackValue outer = getOuterExpression(null);
|
||||
result = result == null ? outer : StackValue.composed(result, outer);
|
||||
@@ -185,15 +184,13 @@ public abstract class CodegenContext {
|
||||
|
||||
public Type enclosingClassType(JetTypeMapper typeMapper) {
|
||||
CodegenContext cur = getParentContext();
|
||||
while(cur != null && !(cur.getContextDescriptor() instanceof ClassDescriptor))
|
||||
cur = cur.getParentContext();
|
||||
while (cur != null && !(cur.getContextDescriptor() instanceof ClassDescriptor)) { cur = cur.getParentContext(); }
|
||||
|
||||
return cur == null ? null : typeMapper.mapType(((ClassDescriptor) cur.getContextDescriptor()).getDefaultType(), MapTypeMode.IMPL);
|
||||
}
|
||||
|
||||
public int getTypeInfoConstantIndex(JetType type) {
|
||||
if(parentContext != STATIC)
|
||||
return parentContext.getTypeInfoConstantIndex(type);
|
||||
if (parentContext != STATIC) { return parentContext.getTypeInfoConstantIndex(type); }
|
||||
|
||||
if(typeInfoConstants == null) {
|
||||
typeInfoConstants = new LinkedHashMap<JetType, Integer>();
|
||||
@@ -215,13 +212,12 @@ public abstract class CodegenContext {
|
||||
}
|
||||
descriptor = descriptor.getOriginal();
|
||||
DeclarationDescriptor accessor = accessors.get(descriptor);
|
||||
if(accessor != null)
|
||||
return accessor;
|
||||
if (accessor != null) { return accessor; }
|
||||
|
||||
if(descriptor instanceof SimpleFunctionDescriptor) {
|
||||
SimpleFunctionDescriptorImpl myAccessor = new SimpleFunctionDescriptorImpl(contextType,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
descriptor.getName() + "$bridge$" + accessors.size(),
|
||||
Name.identifier(descriptor.getName() + "$bridge$" + accessors.size()), // TODO: evil
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
FunctionDescriptor fd = (SimpleFunctionDescriptor) descriptor;
|
||||
myAccessor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
||||
@@ -242,7 +238,7 @@ public abstract class CodegenContext {
|
||||
pd.getVisibility(),
|
||||
pd.isVar(),
|
||||
pd.isObjectDeclaration(),
|
||||
pd.getName() + "$bridge$" + accessors.size(),
|
||||
Name.identifier(pd.getName() + "$bridge$" + accessors.size()), // TODO: evil
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
);
|
||||
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class CodegenUtil {
|
||||
SimpleFunctionDescriptorImpl invokeDescriptor = new SimpleFunctionDescriptorImpl(
|
||||
fd.getExpectedThisObject().exists() ? JetStandardClasses.getReceiverFunction(arity) : JetStandardClasses.getFunction(arity),
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
"invoke",
|
||||
Name.identifier("invoke"),
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
|
||||
invokeDescriptor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
||||
|
||||
@@ -1010,7 +1010,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if(classDescriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
ClassDescriptor containing = (ClassDescriptor) classDescriptor.getContainingDeclaration().getContainingDeclaration();
|
||||
Type type = typeMapper.mapType(containing.getDefaultType(), MapTypeMode.VALUE);
|
||||
StackValue.field(type, type.getInternalName(), classDescriptor.getName(), true).put(TYPE_OBJECT, v);
|
||||
StackValue.field(type, type.getInternalName(), classDescriptor.getName().getName(), true).put(TYPE_OBJECT, v);
|
||||
|
||||
// todo: for now we don't generate classes for enum entries, so we need this hack
|
||||
type = typeMapper.mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE);
|
||||
@@ -1148,7 +1148,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
isInterface = CodegenUtil.isInterface(containingDeclaration);
|
||||
}
|
||||
|
||||
v.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : isInterface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL, owner, functionDescriptor.getName(), typeMapper.mapSignature(functionDescriptor.getName(),functionDescriptor).getAsmMethod().getDescriptor());
|
||||
v.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : isInterface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL, owner, functionDescriptor.getName().getName(), typeMapper.mapSignature(functionDescriptor.getName(),functionDescriptor).getAsmMethod().getDescriptor());
|
||||
StackValue.onStack(asmType(functionDescriptor.getReturnType())).coerce(type, v);
|
||||
}
|
||||
|
||||
@@ -1238,7 +1238,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
ownerParam = callableMethod.getDefaultImplParam();
|
||||
}
|
||||
|
||||
return StackValue.property(propertyDescriptor.getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode);
|
||||
return StackValue.property(propertyDescriptor.getName().getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1951,7 +1951,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if (!(descriptor instanceof ClassDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
String className = descriptor.getName();
|
||||
String className = descriptor.getName().getName();
|
||||
return className.equals("Int") || className.equals("Long") || className.equals("Short") ||
|
||||
className.equals("Byte") || className.equals("Char") || className.equals("Float") ||
|
||||
className.equals("Double");
|
||||
@@ -1961,7 +1961,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if (!(descriptor instanceof ClassDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
String className = descriptor.getName();
|
||||
String className = descriptor.getName().getName();
|
||||
return className.equals(name);
|
||||
}
|
||||
|
||||
@@ -2113,7 +2113,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
else {
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
if (isNumberPrimitive(cls) || !(op.getName().equals("inc") || op.getName().equals("dec")) ) {
|
||||
if (isNumberPrimitive(cls) || !(op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) ) {
|
||||
return invokeOperation(expression, (FunctionDescriptor) op, (CallableMethod) callable);
|
||||
}
|
||||
else {
|
||||
@@ -2165,14 +2165,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if (op instanceof FunctionDescriptor) {
|
||||
final Type asmType = expressionType(expression);
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
if (op.getName().equals("inc") || op.getName().equals("dec")) {
|
||||
if (op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) {
|
||||
if (isNumberPrimitive(cls)) {
|
||||
receiver.put(receiver.type, v);
|
||||
JetExpression operand = expression.getBaseExpression();
|
||||
if (operand instanceof JetReferenceExpression) {
|
||||
final int index = indexOfLocal((JetReferenceExpression) operand);
|
||||
if (index >= 0 && isIntPrimitive(asmType)) {
|
||||
int increment = op.getName().equals("inc") ? 1 : -1;
|
||||
int increment = op.getName().getName().equals("inc") ? 1 : -1;
|
||||
return StackValue.postIncrement(index, increment);
|
||||
}
|
||||
}
|
||||
@@ -2230,7 +2230,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
|
||||
private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) {
|
||||
int increment = op.getName().equals("inc") ? 1 : -1;
|
||||
int increment = op.getName().getName().equals("inc") ? 1 : -1;
|
||||
if (operand instanceof JetReferenceExpression) {
|
||||
final int index = indexOfLocal((JetReferenceExpression) operand);
|
||||
if (index >= 0 && isIntPrimitive(asmType)) {
|
||||
|
||||
@@ -159,7 +159,7 @@ public class FunctionCodegen {
|
||||
for(int i = 0; i != paramDescrs.size(); ++i) {
|
||||
JetValueParameterAnnotationWriter av = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, i + start);
|
||||
ValueParameterDescriptor parameterDescriptor = paramDescrs.get(i);
|
||||
av.writeName(parameterDescriptor.getName());
|
||||
av.writeName(parameterDescriptor.getName().getName());
|
||||
av.writeHasDefaultValue(parameterDescriptor.declaresDefaultValue());
|
||||
av.writeNullable(parameterDescriptor.getType().isNullable());
|
||||
if (jvmSignature.getKotlinParameterTypes() != null && jvmSignature.getKotlinParameterTypes().get(i) != null) {
|
||||
@@ -261,7 +261,7 @@ public class FunctionCodegen {
|
||||
for (ValueParameterDescriptor parameter : paramDescrs) {
|
||||
Type type = state.getInjector().getJetTypeMapper().mapType(parameter.getType(), MapTypeMode.VALUE);
|
||||
// TODO: specify signature
|
||||
mv.visitLocalVariable(parameter.getName(), type.getDescriptor(), null, methodBegin, methodEnd, k);
|
||||
mv.visitLocalVariable(parameter.getName().getName(), type.getDescriptor(), null, methodBegin, methodEnd, k);
|
||||
k += type.getSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
// TODO: cache internal names
|
||||
String outerClassInernalName = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
String innerClassInternalName = typeMapper.mapType(innerClass.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
v.visitInnerClass(innerClassInternalName, outerClassInernalName, innerClass.getName(), innerClassAccess);
|
||||
v.visitInnerClass(innerClassInternalName, outerClassInernalName, innerClass.getName().getName(), innerClassAccess);
|
||||
}
|
||||
|
||||
if (descriptor.getClassObjectDescriptor() != null) {
|
||||
@@ -298,7 +298,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Method originalMethod = typeMapper.mapSignature(original.getName(), original).getAsmMethod();
|
||||
Type[] argTypes = method.getArgumentTypes();
|
||||
|
||||
MethodVisitor mv = v.newMethod(null, ACC_PUBLIC| ACC_BRIDGE| ACC_FINAL, bridge.getName(), method.getDescriptor(), null, null);
|
||||
MethodVisitor mv = v.newMethod(null, ACC_PUBLIC| ACC_BRIDGE| ACC_FINAL, bridge.getName().getName(), method.getDescriptor(), null, null);
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
|
||||
StubCodegen.generateStubCode(mv);
|
||||
}
|
||||
@@ -340,7 +340,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||
if(original.getVisibility() == Visibilities.PRIVATE)
|
||||
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName(), originalMethod.getReturnType().getDescriptor());
|
||||
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName().getName(), originalMethod.getReturnType().getDescriptor());
|
||||
else
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
|
||||
@@ -373,7 +373,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
reg += argType.getSize();
|
||||
}
|
||||
if(original.getVisibility() == Visibilities.PRIVATE && original.getModality() == Modality.FINAL)
|
||||
iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName(), originalMethod.getArgumentTypes()[0].getDescriptor());
|
||||
iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName().getName(), originalMethod.getArgumentTypes()[0].getDescriptor());
|
||||
else
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
|
||||
@@ -484,7 +484,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if(closure != null) {
|
||||
if(closure.captureThis != null) {
|
||||
if(!hasThis0)
|
||||
consArgTypes.add(insert, new JvmMethodParameterSignature(Type.getObjectType(context.getThisDescriptor().getName()), "", JvmMethodParameterKind.THIS0));
|
||||
consArgTypes.add(insert, new JvmMethodParameterSignature(Type.getObjectType(context.getThisDescriptor().getName().getName()), "", JvmMethodParameterKind.THIS0));
|
||||
insert++;
|
||||
}
|
||||
else {
|
||||
@@ -553,7 +553,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
for (ValueParameterDescriptor valueParameter : constructorDescriptor.getValueParameters()) {
|
||||
JetValueParameterAnnotationWriter jetValueParameterAnnotation = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, i);
|
||||
jetValueParameterAnnotation.writeName(valueParameter.getName());
|
||||
jetValueParameterAnnotation.writeName(valueParameter.getName().getName());
|
||||
jetValueParameterAnnotation.writeHasDefaultValue(valueParameter.declaresDefaultValue());
|
||||
jetValueParameterAnnotation.writeType(constructorMethod.getKotlinParameterType(i));
|
||||
jetValueParameterAnnotation.visitEnd();
|
||||
@@ -689,7 +689,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type type = typeMapper.mapType(descriptor.getType(), MapTypeMode.VALUE);
|
||||
iv.load(0, classType);
|
||||
iv.load(frameMap.getIndex(descriptor), type);
|
||||
iv.putfield(classname, descriptor.getName(), type.getDescriptor());
|
||||
iv.putfield(classname, descriptor.getName().getName(), type.getDescriptor());
|
||||
}
|
||||
curParam++;
|
||||
}
|
||||
@@ -954,7 +954,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
codegen.gen(initializer, type);
|
||||
// @todo write directly to the field. Fix test excloset.jet::test6
|
||||
String owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
StackValue.property(propertyDescriptor.getName(), owner, owner,
|
||||
StackValue.property(propertyDescriptor.getName().getName(), owner, owner,
|
||||
typeMapper.mapType(propertyDescriptor.getType(), MapTypeMode.VALUE), false, false, false, null, null, 0).store(iv);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ 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.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
@@ -222,10 +223,6 @@ public class JetTypeMapper {
|
||||
r.append("$");
|
||||
}
|
||||
}
|
||||
if (ns.getName().length() == 0) {
|
||||
throw new IllegalStateException(
|
||||
"name must not be empty at this point when generating for " + namespace);
|
||||
}
|
||||
r.append(ns.getName());
|
||||
}
|
||||
|
||||
@@ -316,14 +313,17 @@ public class JetTypeMapper {
|
||||
}
|
||||
|
||||
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
||||
String name = descriptor.getName();
|
||||
Name name = descriptor.getName();
|
||||
if(JetPsiUtil.NO_NAME_PROVIDED.equals(name)) {
|
||||
return closureAnnotator
|
||||
.classNameForAnonymousClass((JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor))
|
||||
.getInternalName();
|
||||
}
|
||||
if(name.contains("/"))
|
||||
return name;
|
||||
|
||||
// This is the worst code in the project
|
||||
if(name.getName().contains("/"))
|
||||
return name.getName();
|
||||
|
||||
if (container != null) {
|
||||
String baseName = getFQName(container);
|
||||
if (!baseName.isEmpty()) {
|
||||
@@ -331,7 +331,7 @@ public class JetTypeMapper {
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
return name.getName();
|
||||
}
|
||||
|
||||
private static ClassDescriptor getContainingClass(DeclarationDescriptor descriptor) {
|
||||
@@ -667,7 +667,7 @@ public class JetTypeMapper {
|
||||
mapReturnType(f.getReturnType(), signatureVisitor);
|
||||
signatureVisitor.writeReturnTypeEnd();
|
||||
}
|
||||
return signatureVisitor.makeJvmMethodSignature(f.getName());
|
||||
return signatureVisitor.makeJvmMethodSignature(f.getName().getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -684,7 +684,7 @@ public class JetTypeMapper {
|
||||
}
|
||||
|
||||
private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) {
|
||||
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName(), typeParameterDescriptor.getVariance(), typeParameterDescriptor.isReified());
|
||||
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().getName(), typeParameterDescriptor.getVariance(), typeParameterDescriptor.isReified());
|
||||
|
||||
classBound:
|
||||
{
|
||||
@@ -725,7 +725,7 @@ public class JetTypeMapper {
|
||||
|
||||
}
|
||||
|
||||
public JvmMethodSignature mapSignature(String name, FunctionDescriptor f) {
|
||||
public JvmMethodSignature mapSignature(Name name, FunctionDescriptor f) {
|
||||
final ReceiverDescriptor receiver = f.getReceiverParameter();
|
||||
|
||||
BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD, false);
|
||||
@@ -752,7 +752,7 @@ public class JetTypeMapper {
|
||||
mapReturnType(f.getReturnType(), signatureWriter);
|
||||
signatureWriter.writeReturnTypeEnd();
|
||||
|
||||
return signatureWriter.makeJvmMethodSignature(name);
|
||||
return signatureWriter.makeJvmMethodSignature(name.getName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -206,7 +207,7 @@ public class PropertyCodegen {
|
||||
}
|
||||
else {
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.GETSTATIC : Opcodes.GETFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName(),
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName().getName(),
|
||||
type.getDescriptor());
|
||||
}
|
||||
iv.areturn(type);
|
||||
@@ -296,7 +297,7 @@ public class PropertyCodegen {
|
||||
else {
|
||||
iv.load(paramCode, type);
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName(),
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName().getName(),
|
||||
type.getDescriptor());
|
||||
}
|
||||
|
||||
@@ -307,12 +308,12 @@ public class PropertyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getterName(String propertyName) {
|
||||
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName);
|
||||
public static String getterName(Name propertyName) {
|
||||
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
|
||||
}
|
||||
|
||||
public static String setterName(String propertyName) {
|
||||
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName);
|
||||
public static String setterName(Name propertyName) {
|
||||
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
|
||||
}
|
||||
|
||||
public void genDelegate(PropertyDescriptor declaration, PropertyDescriptor overriddenDescriptor, StackValue field) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.psi.search.ProjectScope;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
@@ -54,8 +55,8 @@ public class IntrinsicMethods {
|
||||
private static final IntrinsicMethod INC = new Increment(1);
|
||||
private static final IntrinsicMethod DEC = new Increment(-1);
|
||||
|
||||
private static final List<String> PRIMITIVE_TYPES = ImmutableList.of("Boolean", "Byte", "Char", "Short", "Int", "Float", "Long", "Double");
|
||||
private static final List<String> PRIMITIVE_NUMBER_TYPES = ImmutableList.of("Byte", "Char", "Short", "Int", "Float", "Long", "Double");
|
||||
private static final List<Name> PRIMITIVE_TYPES = ImmutableList.of(Name.identifier("Boolean"), Name.identifier("Byte"), Name.identifier("Char"), Name.identifier("Short"), Name.identifier("Int"), Name.identifier("Float"), Name.identifier("Long"), Name.identifier("Double"));
|
||||
private static final List<Name> PRIMITIVE_NUMBER_TYPES = ImmutableList.of(Name.identifier("Byte"), Name.identifier("Char"), Name.identifier("Short"), Name.identifier("Int"), Name.identifier("Float"), Name.identifier("Long"), Name.identifier("Double"));
|
||||
public static final IntrinsicMethod ARRAY_SIZE = new ArraySize();
|
||||
public static final IntrinsicMethod ARRAY_INDICES = new ArrayIndices();
|
||||
public static final Equals EQUALS = new Equals();
|
||||
@@ -91,69 +92,69 @@ public class IntrinsicMethods {
|
||||
namedMethods.put(KOTLIN_JAVA_CLASS_PROPERTY, new JavaClassProperty());
|
||||
namedMethods.put(KOTLIN_ARRAYS_ARRAY, new JavaClassArray());
|
||||
|
||||
List<String> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
|
||||
for (String method : primitiveCastMethods) {
|
||||
declareIntrinsicFunction("Number", method, 0, NUMBER_CAST, true);
|
||||
for (String type : PRIMITIVE_NUMBER_TYPES) {
|
||||
ImmutableList<Name> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
|
||||
for (Name method : primitiveCastMethods) {
|
||||
declareIntrinsicFunction(Name.identifier("Number"), method, 0, NUMBER_CAST, true);
|
||||
for (Name type : PRIMITIVE_NUMBER_TYPES) {
|
||||
declareIntrinsicFunction(type, method, 0, NUMBER_CAST, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (String type : PRIMITIVE_NUMBER_TYPES) {
|
||||
declareIntrinsicFunction(type, "plus", 0, UNARY_PLUS, false);
|
||||
declareIntrinsicFunction(type, "minus", 0, UNARY_MINUS, false);
|
||||
declareIntrinsicFunction(type, "inv", 0, INV, false);
|
||||
declareIntrinsicFunction(type, "rangeTo", 1, UP_TO, false);
|
||||
declareIntrinsicFunction(type, "upto", 1, UP_TO, false);
|
||||
declareIntrinsicFunction(type, "downto", 1, DOWN_TO, false);
|
||||
declareIntrinsicFunction(type, "inc", 0, INC, false);
|
||||
declareIntrinsicFunction(type, "dec", 0, DEC, false);
|
||||
for (Name type : PRIMITIVE_NUMBER_TYPES) {
|
||||
declareIntrinsicFunction(type, Name.identifier("plus"), 0, UNARY_PLUS, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("minus"), 0, UNARY_MINUS, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("inv"), 0, INV, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("rangeTo"), 1, UP_TO, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("upto"), 1, UP_TO, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("downto"), 1, DOWN_TO, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("inc"), 0, INC, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("dec"), 0, DEC, false);
|
||||
}
|
||||
|
||||
declareBinaryOp("plus", Opcodes.IADD);
|
||||
declareBinaryOp("minus", Opcodes.ISUB);
|
||||
declareBinaryOp("times", Opcodes.IMUL);
|
||||
declareBinaryOp("div", Opcodes.IDIV);
|
||||
declareBinaryOp("mod", Opcodes.IREM);
|
||||
declareBinaryOp("shl", Opcodes.ISHL);
|
||||
declareBinaryOp("shr", Opcodes.ISHR);
|
||||
declareBinaryOp("ushr", Opcodes.IUSHR);
|
||||
declareBinaryOp("and", Opcodes.IAND);
|
||||
declareBinaryOp("or", Opcodes.IOR);
|
||||
declareBinaryOp("xor", Opcodes.IXOR);
|
||||
declareBinaryOp(Name.identifier("plus"), Opcodes.IADD);
|
||||
declareBinaryOp(Name.identifier("minus"), Opcodes.ISUB);
|
||||
declareBinaryOp(Name.identifier("times"), Opcodes.IMUL);
|
||||
declareBinaryOp(Name.identifier("div"), Opcodes.IDIV);
|
||||
declareBinaryOp(Name.identifier("mod"), Opcodes.IREM);
|
||||
declareBinaryOp(Name.identifier("shl"), Opcodes.ISHL);
|
||||
declareBinaryOp(Name.identifier("shr"), Opcodes.ISHR);
|
||||
declareBinaryOp(Name.identifier("ushr"), Opcodes.IUSHR);
|
||||
declareBinaryOp(Name.identifier("and"), Opcodes.IAND);
|
||||
declareBinaryOp(Name.identifier("or"), Opcodes.IOR);
|
||||
declareBinaryOp(Name.identifier("xor"), Opcodes.IXOR);
|
||||
|
||||
declareIntrinsicFunction("Boolean", "not", 0, new Not(), true);
|
||||
declareIntrinsicFunction(Name.identifier("Boolean"), Name.identifier("not"), 0, new Not(), true);
|
||||
|
||||
declareIntrinsicFunction("String", "plus", 1, new Concat(), true);
|
||||
declareIntrinsicFunction("CharSequence", "get", 1, new StringGetChar(), true);
|
||||
declareIntrinsicFunction("String", "get", 1, new StringGetChar(), true);
|
||||
declareIntrinsicFunction(Name.identifier("String"), Name.identifier("plus"), 1, new Concat(), true);
|
||||
declareIntrinsicFunction(Name.identifier("CharSequence"), Name.identifier("get"), 1, new StringGetChar(), true);
|
||||
declareIntrinsicFunction(Name.identifier("String"), Name.identifier("get"), 1, new StringGetChar(), true);
|
||||
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("toString"), 0, new ToString());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("equals"), 1, EQUALS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("identityEquals"), 1, IDENTITY_EQUALS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("plus"), 1, STRING_PLUS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("arrayOfNulls"), 1, new NewArray());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("sure"), 0, new Sure());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("synchronized"), 2, new StupidSync());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("iterator"), 0, new IteratorIterator());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("toString")), 0, new ToString());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("equals")), 1, EQUALS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("identityEquals")), 1, IDENTITY_EQUALS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("plus")), 1, STRING_PLUS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("arrayOfNulls")), 1, new NewArray());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("sure")), 0, new Sure());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("synchronized")), 2, new StupidSync());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("iterator")), 0, new IteratorIterator());
|
||||
|
||||
declareIntrinsicFunction("ByteIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("ShortIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("IntIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("LongIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("CharIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("BooleanIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("FloatIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("DoubleIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("ByteIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("ShortIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("IntIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("LongIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("CharIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("BooleanIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("FloatIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("DoubleIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
|
||||
for (String type : PRIMITIVE_TYPES) {
|
||||
declareIntrinsicFunction(type, "compareTo", 1, new CompareTo(), false);
|
||||
for (Name type : PRIMITIVE_TYPES) {
|
||||
declareIntrinsicFunction(type, Name.identifier("compareTo"), 1, new CompareTo(), false);
|
||||
}
|
||||
// declareIntrinsicFunction("Any", "equals", 1, new Equals());
|
||||
//
|
||||
declareIntrinsicStringMethods();
|
||||
declareIntrinsicProperty("CharSequence", "length", new StringLength());
|
||||
declareIntrinsicProperty("String", "length", new StringLength());
|
||||
declareIntrinsicProperty(Name.identifier("CharSequence"), Name.identifier("length"), new StringLength());
|
||||
declareIntrinsicProperty(Name.identifier("String"), Name.identifier("length"), new StringLength());
|
||||
|
||||
declareArrayMethods();
|
||||
}
|
||||
@@ -164,24 +165,24 @@ public class IntrinsicMethods {
|
||||
declareArrayMethodsForPrimitive(jvmPrimitiveType);
|
||||
}
|
||||
|
||||
declareIntrinsicProperty("Array", "size", ARRAY_SIZE);
|
||||
declareIntrinsicProperty("Array", "indices", ARRAY_INDICES);
|
||||
declareIntrinsicFunction("Array", "set", 2, ARRAY_SET, true);
|
||||
declareIntrinsicFunction("Array", "get", 1, ARRAY_GET, true);
|
||||
declareIntrinsicProperty(Name.identifier("Array"), Name.identifier("size"), ARRAY_SIZE);
|
||||
declareIntrinsicProperty(Name.identifier("Array"), Name.identifier("indices"), ARRAY_INDICES);
|
||||
declareIntrinsicFunction(Name.identifier("Array"), Name.identifier("set"), 2, ARRAY_SET, true);
|
||||
declareIntrinsicFunction(Name.identifier("Array"), Name.identifier("get"), 1, ARRAY_GET, true);
|
||||
declareIterator(myStdLib.getArray());
|
||||
}
|
||||
|
||||
private void declareArrayMethodsForPrimitive(JvmPrimitiveType jvmPrimitiveType) {
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
declareIntrinsicProperty(primitiveType.getArrayTypeName(), "size", ARRAY_SIZE);
|
||||
declareIntrinsicProperty(primitiveType.getArrayTypeName(), "indices", ARRAY_INDICES);
|
||||
declareIntrinsicFunction(primitiveType.getArrayTypeName(), "set", 2, ARRAY_SET, true);
|
||||
declareIntrinsicFunction(primitiveType.getArrayTypeName(), "get", 1, ARRAY_GET, true);
|
||||
declareIntrinsicProperty(primitiveType.getArrayTypeName(), Name.identifier("size"), ARRAY_SIZE);
|
||||
declareIntrinsicProperty(primitiveType.getArrayTypeName(), Name.identifier("indices"), ARRAY_INDICES);
|
||||
declareIntrinsicFunction(primitiveType.getArrayTypeName(), Name.identifier("set"), 2, ARRAY_SET, true);
|
||||
declareIntrinsicFunction(primitiveType.getArrayTypeName(), Name.identifier("get"), 1, ARRAY_GET, true);
|
||||
declareIterator(myStdLib.getPrimitiveArrayClassDescriptor(primitiveType));
|
||||
}
|
||||
|
||||
private void declareIterator(ClassDescriptor classDescriptor) {
|
||||
declareOverload(classDescriptor.getDefaultType().getMemberScope().getFunctions("iterator"), 0, ARRAY_ITERATOR);
|
||||
declareOverload(classDescriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("iterator")), 0, ARRAY_ITERATOR);
|
||||
}
|
||||
|
||||
private void declareIntrinsicStringMethods() {
|
||||
@@ -200,7 +201,7 @@ public class IntrinsicMethods {
|
||||
if (stringMember instanceof SimpleFunctionDescriptor) {
|
||||
final SimpleFunctionDescriptor stringMethod = (SimpleFunctionDescriptor) stringMember;
|
||||
final PsiMethod[] methods = stringPsiClass != null?
|
||||
stringPsiClass.findMethodsByName(stringMember.getName(), false) : new PsiMethod[]{};
|
||||
stringPsiClass.findMethodsByName(stringMember.getName().getName(), false) : new PsiMethod[]{};
|
||||
for (PsiMethod method : methods) {
|
||||
if (method.getParameterList().getParametersCount() == stringMethod.getValueParameters().size()) {
|
||||
myMethods.put(stringMethod, new PsiMethodCall(stringMethod));
|
||||
@@ -210,14 +211,14 @@ public class IntrinsicMethods {
|
||||
}
|
||||
}
|
||||
|
||||
private void declareBinaryOp(String methodName, int opcode) {
|
||||
private void declareBinaryOp(Name methodName, int opcode) {
|
||||
BinaryOp op = new BinaryOp(opcode);
|
||||
for (String type : PRIMITIVE_TYPES) {
|
||||
for (Name type : PRIMITIVE_TYPES) {
|
||||
declareIntrinsicFunction(type, methodName, 1, op, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void declareIntrinsicProperty(String className, String methodName, IntrinsicMethod implementation) {
|
||||
private void declareIntrinsicProperty(Name className, Name methodName, IntrinsicMethod implementation) {
|
||||
final JetScope numberScope = getClassMemberScope(className);
|
||||
Set<VariableDescriptor> properties = numberScope.getProperties(methodName);
|
||||
assert properties.size() == 1;
|
||||
@@ -225,7 +226,7 @@ public class IntrinsicMethods {
|
||||
myMethods.put(property.getOriginal(), implementation);
|
||||
}
|
||||
|
||||
private void declareIntrinsicFunction(String className, String functionName, int arity, IntrinsicMethod implementation, boolean original) {
|
||||
private void declareIntrinsicFunction(Name className, Name functionName, int arity, IntrinsicMethod implementation, boolean original) {
|
||||
JetScope memberScope = getClassMemberScope(className);
|
||||
final Set<FunctionDescriptor> group = memberScope.getFunctions(functionName);
|
||||
for (FunctionDescriptor descriptor : group) {
|
||||
@@ -243,7 +244,7 @@ public class IntrinsicMethods {
|
||||
}
|
||||
}
|
||||
|
||||
private JetScope getClassMemberScope(String className) {
|
||||
private JetScope getClassMemberScope(Name className) {
|
||||
final ClassDescriptor descriptor = (ClassDescriptor) myStdLib.getLibraryScope().getClassifier(className);
|
||||
final List<TypeParameterDescriptor> typeParameterDescriptors = descriptor.getTypeConstructor().getParameters();
|
||||
List<TypeProjection> typeParameters = new ArrayList<TypeProjection>();
|
||||
@@ -257,11 +258,10 @@ public class IntrinsicMethods {
|
||||
List<AnnotationDescriptor> annotations = descriptor.getAnnotations();
|
||||
if (annotations != null) {
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) {
|
||||
String value = (String) annotation.getValueArguments().get(0).getValue();
|
||||
IntrinsicMethod intrinsicMethod = namedMethods.get(value);
|
||||
if(intrinsicMethod != null)
|
||||
return intrinsicMethod;
|
||||
if (intrinsicMethod != null) { return intrinsicMethod; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,11 +274,10 @@ public class IntrinsicMethods {
|
||||
List<AnnotationDescriptor> annotations = descriptor.getAnnotations();
|
||||
if (annotations != null) {
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) {
|
||||
String value = (String) annotation.getValueArguments().get(0).getValue();
|
||||
intrinsicMethod = namedMethods.get(value);
|
||||
if(intrinsicMethod != null)
|
||||
break;
|
||||
if (intrinsicMethod != null) { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetSignatureUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureReader;
|
||||
@@ -264,9 +265,9 @@ public class BothSignatureWriter {
|
||||
pop();
|
||||
}
|
||||
|
||||
public void writeTypeVariable(final String name, boolean nullable, Type asmType) {
|
||||
signatureVisitor().visitTypeVariable(name);
|
||||
jetSignatureWriter.visitTypeVariable(name, nullable);
|
||||
public void writeTypeVariable(final Name name, boolean nullable, Type asmType) {
|
||||
signatureVisitor().visitTypeVariable(name.getName());
|
||||
jetSignatureWriter.visitTypeVariable(name.getName(), nullable);
|
||||
generic = true;
|
||||
writeAsmType0(asmType);
|
||||
}
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
import org.jetbrains.jet.utils.Progress;
|
||||
@@ -127,7 +128,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
for (JetFile file : configuration.getEnvironment().getSourceFiles()) {
|
||||
if (JetMainDetector.hasMain(file.getDeclarations())) {
|
||||
FqName fqName = JetPsiUtil.getFQName(file);
|
||||
mainClass = fqName.child(JvmAbi.PACKAGE_CLASS);
|
||||
mainClass = fqName.child(Name.identifier(JvmAbi.PACKAGE_CLASS));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class InjectorForJavaSemanticServices {
|
||||
this.bindingTrace = new org.jetbrains.jet.lang.resolve.BindingTraceContext();
|
||||
this.javaBridgeConfiguration = new JavaBridgeConfiguration();
|
||||
this.psiClassFinderForJvm = new PsiClassFinderForJvm();
|
||||
this.moduleDescriptor = new org.jetbrains.jet.lang.descriptors.ModuleDescriptor("<dummy>");
|
||||
this.moduleDescriptor = new org.jetbrains.jet.lang.descriptors.ModuleDescriptor(org.jetbrains.jet.lang.resolve.name.Name.special("<dummy>"));
|
||||
this.compilerDependencies = compilerDependencies;
|
||||
this.compilerSpecialMode = compilerDependencies.getCompilerSpecialMode();
|
||||
this.project = project;
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.ObservableBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -83,7 +84,7 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
|
||||
@NotNull CompilerDependencies compilerDependencies) {
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
|
||||
final ModuleDescriptor owner = new ModuleDescriptor("<module>");
|
||||
final ModuleDescriptor owner = new ModuleDescriptor(Name.special("<module>"));
|
||||
|
||||
TopDownAnalysisParameters topDownAnalysisParameters = new TopDownAnalysisParameters(
|
||||
filesToAnalyzeCompletely, false, false);
|
||||
|
||||
+7
-6
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -40,7 +41,7 @@ import java.util.Set;
|
||||
* @author abreslav
|
||||
*/
|
||||
public class JavaClassMembersScope extends JavaClassOrPackageScope {
|
||||
private final Map<String, ClassifierDescriptor> classifiers = Maps.newHashMap();
|
||||
private final Map<Name, ClassifierDescriptor> classifiers = Maps.newHashMap();
|
||||
|
||||
public JavaClassMembersScope(
|
||||
@NotNull JavaSemanticServices semanticServices,
|
||||
@@ -62,7 +63,7 @@ public class JavaClassMembersScope extends JavaClassOrPackageScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
ClassifierDescriptor classifierDescriptor = classifiers.get(name);
|
||||
if (classifierDescriptor == null) {
|
||||
classifierDescriptor = doGetClassifierDescriptor(name);
|
||||
@@ -72,7 +73,7 @@ public class JavaClassMembersScope extends JavaClassOrPackageScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -82,10 +83,10 @@ public class JavaClassMembersScope extends JavaClassOrPackageScope {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
private ClassifierDescriptor doGetClassifierDescriptor(String name) {
|
||||
private ClassifierDescriptor doGetClassifierDescriptor(Name name) {
|
||||
// TODO : suboptimal, walk the list only once
|
||||
for (PsiClass innerClass : resolverScopeData.psiClass.getAllInnerClasses()) {
|
||||
if (name.equals(innerClass.getName())) {
|
||||
if (name.getName().equals(innerClass.getName())) {
|
||||
if (innerClass.hasModifierProperty(PsiModifier.STATIC) != resolverScopeData.staticMembers) return null;
|
||||
ClassDescriptor classDescriptor = semanticServices.getDescriptorResolver()
|
||||
.resolveClass(new FqName(innerClass.getQualifiedName()), DescriptorSearchRule.IGNORE_IF_FOUND_IN_KOTLIN);
|
||||
@@ -98,7 +99,7 @@ public class JavaClassMembersScope extends JavaClassOrPackageScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScopeImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -60,13 +61,13 @@ public abstract class JavaClassOrPackageScope extends JetScopeImpl {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
return semanticServices.getDescriptorResolver().resolveFieldGroupByName(name, resolverScopeData);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
return semanticServices.getDescriptorResolver().resolveFunctionGroup(name, resolverScopeData);
|
||||
}
|
||||
|
||||
|
||||
+27
-26
@@ -34,6 +34,7 @@ import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
@@ -50,11 +51,11 @@ import java.util.*;
|
||||
*/
|
||||
public class JavaDescriptorResolver {
|
||||
|
||||
public static final String JAVA_ROOT = "<java_root>";
|
||||
public static final Name JAVA_ROOT = Name.special("<java_root>");
|
||||
|
||||
public static final ModuleDescriptor FAKE_ROOT_MODULE = new ModuleDescriptor(JAVA_ROOT);
|
||||
|
||||
/*package*/ static final DeclarationDescriptor JAVA_METHOD_TYPE_PARAMETER_PARENT = new DeclarationDescriptorImpl(null, Collections.<AnnotationDescriptor>emptyList(), "<java_generic_method>") {
|
||||
/*package*/ static final DeclarationDescriptor JAVA_METHOD_TYPE_PARAMETER_PARENT = new DeclarationDescriptorImpl(null, Collections.<AnnotationDescriptor>emptyList(), Name.special("<java_generic_method>")) {
|
||||
|
||||
@Override
|
||||
public DeclarationDescriptor substitute(TypeSubstitutor substitutor) {
|
||||
@@ -67,7 +68,7 @@ public class JavaDescriptorResolver {
|
||||
}
|
||||
};
|
||||
|
||||
/*package*/ static final DeclarationDescriptor JAVA_CLASS_OBJECT = new DeclarationDescriptorImpl(null, Collections.<AnnotationDescriptor>emptyList(), "<java_class_object_emulation>") {
|
||||
/*package*/ static final DeclarationDescriptor JAVA_CLASS_OBJECT = new DeclarationDescriptorImpl(null, Collections.<AnnotationDescriptor>emptyList(), Name.special("<java_class_object_emulation>")) {
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor substitute(TypeSubstitutor substitutor) {
|
||||
@@ -158,7 +159,7 @@ public class JavaDescriptorResolver {
|
||||
(new PsiClassWrapper(psiClass).getJetClass().isDefined() || psiClass.getName().equals(JvmAbi.PACKAGE_CLASS));
|
||||
classOrNamespaceDescriptor = descriptor;
|
||||
|
||||
if (fqName.lastSegmentIs(JvmAbi.PACKAGE_CLASS) && psiClass != null && kotlin) {
|
||||
if (fqName.lastSegmentIs(Name.identifier(JvmAbi.PACKAGE_CLASS)) && psiClass != null && kotlin) {
|
||||
throw new IllegalStateException("Kotlin namespace cannot have last segment " + JvmAbi.PACKAGE_CLASS + ": " + fqName);
|
||||
}
|
||||
}
|
||||
@@ -189,7 +190,7 @@ public class JavaDescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, NamedMembers> namedMembersMap;
|
||||
private Map<Name, NamedMembers> namedMembersMap;
|
||||
|
||||
@NotNull
|
||||
public abstract List<TypeParameterDescriptor> getTypeParameters();
|
||||
@@ -359,7 +360,7 @@ public class JavaDescriptorResolver {
|
||||
|
||||
checkPsiClassIsNotJet(psiClass);
|
||||
|
||||
String name = psiClass.getName();
|
||||
Name name = Name.identifier(psiClass.getName());
|
||||
ClassKind kind = psiClass.isInterface() ? (psiClass.isAnnotationType() ? ClassKind.ANNOTATION_CLASS : ClassKind.TRAIT) : ClassKind.CLASS;
|
||||
ClassOrNamespaceDescriptor containingDeclaration = resolveParentDescriptor(psiClass);
|
||||
|
||||
@@ -454,7 +455,7 @@ public class JavaDescriptorResolver {
|
||||
constructorDescriptor,
|
||||
i,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
method.getName(),
|
||||
Name.identifier(method.getName()),
|
||||
false,
|
||||
semanticServices.getTypeTransformer().transformToType(returnType, resolverForTypeParameters),
|
||||
annotationMethod.getDefaultValue() != null,
|
||||
@@ -686,7 +687,7 @@ public class JavaDescriptorResolver {
|
||||
Collections.<AnnotationDescriptor>emptyList(), // TODO: wrong
|
||||
reified,
|
||||
JetSignatureUtils.translateVariance(variance),
|
||||
name,
|
||||
Name.identifier(name),
|
||||
formalTypeParameterIndex++);
|
||||
|
||||
previousTypeParameters.add(typeParameter);
|
||||
@@ -761,7 +762,7 @@ public class JavaDescriptorResolver {
|
||||
Collections.<AnnotationDescriptor>emptyList(), // TODO
|
||||
false,
|
||||
Variance.INVARIANT,
|
||||
psiTypeParameter.getName(),
|
||||
Name.identifier(psiTypeParameter.getName()),
|
||||
psiTypeParameter.getIndex()
|
||||
);
|
||||
return new TypeParameterDescriptorInitialization(typeParameterDescriptor, psiTypeParameter);
|
||||
@@ -1012,7 +1013,7 @@ public class JavaDescriptorResolver {
|
||||
|
||||
@Nullable
|
||||
private PsiClass getPsiClassForJavaPackageScope(@NotNull FqName packageFQN) {
|
||||
return psiClassFinder.findPsiClass(packageFQN.child(JvmAbi.PACKAGE_CLASS), PsiClassFinder.RuntimeClassesHandleMode.IGNORE);
|
||||
return psiClassFinder.findPsiClass(packageFQN.child(Name.identifier(JvmAbi.PACKAGE_CLASS)), PsiClassFinder.RuntimeClassesHandleMode.IGNORE);
|
||||
}
|
||||
|
||||
private static class ValueParameterDescriptors {
|
||||
@@ -1068,10 +1069,10 @@ public class JavaDescriptorResolver {
|
||||
PsiType psiType = parameter.getPsiParameter().getType();
|
||||
|
||||
// TODO: must be very slow, make it lazy?
|
||||
String name = parameter.getPsiParameter().getName() != null ? parameter.getPsiParameter().getName() : "p" + i;
|
||||
Name name = Name.identifier(parameter.getPsiParameter().getName() != null ? parameter.getPsiParameter().getName() : "p" + i);
|
||||
|
||||
if (parameter.getJetValueParameter().name().length() > 0) {
|
||||
name = parameter.getJetValueParameter().name();
|
||||
name = Name.identifier(parameter.getJetValueParameter().name());
|
||||
}
|
||||
|
||||
String typeFromAnnotation = parameter.getJetValueParameter().type();
|
||||
@@ -1123,7 +1124,7 @@ public class JavaDescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
public Set<VariableDescriptor> resolveFieldGroupByName(@NotNull String fieldName, @NotNull ResolverScopeData scopeData) {
|
||||
public Set<VariableDescriptor> resolveFieldGroupByName(@NotNull Name fieldName, @NotNull ResolverScopeData scopeData) {
|
||||
|
||||
if (scopeData.psiClass == null) {
|
||||
return Collections.emptySet();
|
||||
@@ -1148,10 +1149,10 @@ public class JavaDescriptorResolver {
|
||||
getResolverScopeData(scopeData);
|
||||
|
||||
Set<VariableDescriptor> descriptors = Sets.newHashSet();
|
||||
Map<String, NamedMembers> membersForProperties = scopeData.namedMembersMap;
|
||||
for (Map.Entry<String, NamedMembers> entry : membersForProperties.entrySet()) {
|
||||
Map<Name, NamedMembers> membersForProperties = scopeData.namedMembersMap;
|
||||
for (Map.Entry<Name, NamedMembers> entry : membersForProperties.entrySet()) {
|
||||
NamedMembers namedMembers = entry.getValue();
|
||||
String propertyName = entry.getKey();
|
||||
Name propertyName = entry.getKey();
|
||||
|
||||
resolveNamedGroupProperties(scopeData.classOrNamespaceDescriptor, scopeData, namedMembers, propertyName, "class or namespace " + scopeData.psiClass.getQualifiedName());
|
||||
descriptors.addAll(namedMembers.propertyDescriptors);
|
||||
@@ -1196,7 +1197,7 @@ public class JavaDescriptorResolver {
|
||||
private void resolveNamedGroupProperties(
|
||||
@NotNull ClassOrNamespaceDescriptor owner,
|
||||
@NotNull ResolverScopeData scopeData,
|
||||
@NotNull NamedMembers namedMembers, @NotNull String propertyName,
|
||||
@NotNull NamedMembers namedMembers, @NotNull Name propertyName,
|
||||
@NotNull String context) {
|
||||
getResolverScopeData(scopeData);
|
||||
|
||||
@@ -1397,7 +1398,7 @@ public class JavaDescriptorResolver {
|
||||
getterDescriptor.initialize(propertyType);
|
||||
}
|
||||
if (setterDescriptor != null) {
|
||||
setterDescriptor.initialize(new ValueParameterDescriptorImpl(setterDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "p0"/*TODO*/, false, propertyDescriptor.getType(), false, null));
|
||||
setterDescriptor.initialize(new ValueParameterDescriptorImpl(setterDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), Name.identifier("p0") /*TODO*/, false, propertyDescriptor.getType(), false, null));
|
||||
}
|
||||
|
||||
trace.record(BindingContext.VARIABLE, anyMember.getMember().psiMember, propertyDescriptor);
|
||||
@@ -1432,7 +1433,7 @@ public class JavaDescriptorResolver {
|
||||
}
|
||||
|
||||
private void resolveNamedGroupFunctions(@NotNull ClassOrNamespaceDescriptor owner, PsiClass psiClass,
|
||||
TypeSubstitutor typeSubstitutorForGenericSuperclasses, NamedMembers namedMembers, String methodName, ResolverScopeData scopeData) {
|
||||
TypeSubstitutor typeSubstitutorForGenericSuperclasses, NamedMembers namedMembers, Name methodName, ResolverScopeData scopeData) {
|
||||
if (namedMembers.functionDescriptors != null) {
|
||||
return;
|
||||
}
|
||||
@@ -1471,7 +1472,7 @@ public class JavaDescriptorResolver {
|
||||
namedMembers.functionDescriptors = functions;
|
||||
}
|
||||
|
||||
private Set<SimpleFunctionDescriptor> getFunctionsFromSupertypes(ResolverScopeData scopeData, String methodName) {
|
||||
private Set<SimpleFunctionDescriptor> getFunctionsFromSupertypes(ResolverScopeData scopeData, Name methodName) {
|
||||
Set<SimpleFunctionDescriptor> r = new HashSet<SimpleFunctionDescriptor>();
|
||||
for (JetType supertype : getSupertypes(scopeData)) {
|
||||
for (FunctionDescriptor function : supertype.getMemberScope().getFunctions(methodName)) {
|
||||
@@ -1481,7 +1482,7 @@ public class JavaDescriptorResolver {
|
||||
return r;
|
||||
}
|
||||
|
||||
private Set<PropertyDescriptor> getPropertiesFromSupertypes(ResolverScopeData scopeData, String propertyName) {
|
||||
private Set<PropertyDescriptor> getPropertiesFromSupertypes(ResolverScopeData scopeData, Name propertyName) {
|
||||
Set<PropertyDescriptor> r = new HashSet<PropertyDescriptor>();
|
||||
for (JetType supertype : getSupertypes(scopeData)) {
|
||||
for (VariableDescriptor property : supertype.getMemberScope().getProperties(propertyName)) {
|
||||
@@ -1498,11 +1499,11 @@ public class JavaDescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<FunctionDescriptor> resolveFunctionGroup(@NotNull String methodName, @NotNull ResolverScopeData scopeData) {
|
||||
public Set<FunctionDescriptor> resolveFunctionGroup(@NotNull Name methodName, @NotNull ResolverScopeData scopeData) {
|
||||
|
||||
getResolverScopeData(scopeData);
|
||||
|
||||
Map<String, NamedMembers> namedMembersMap = scopeData.namedMembersMap;
|
||||
Map<Name, NamedMembers> namedMembersMap = scopeData.namedMembersMap;
|
||||
|
||||
NamedMembers namedMembers = namedMembersMap.get(methodName);
|
||||
if (namedMembers != null && namedMembers.methods != null) {
|
||||
@@ -1582,7 +1583,7 @@ public class JavaDescriptorResolver {
|
||||
SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl(
|
||||
scopeData.classOrNamespaceDescriptor,
|
||||
resolveAnnotations(method.getPsiMethod()),
|
||||
method.getName(),
|
||||
Name.identifier(method.getName()),
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
);
|
||||
|
||||
@@ -1696,8 +1697,8 @@ public class JavaDescriptorResolver {
|
||||
|
||||
List<FunctionDescriptor> functions = new ArrayList<FunctionDescriptor>();
|
||||
|
||||
for (Map.Entry<String, NamedMembers> entry : scopeData.namedMembersMap.entrySet()) {
|
||||
String methodName = entry.getKey();
|
||||
for (Map.Entry<Name, NamedMembers> entry : scopeData.namedMembersMap.entrySet()) {
|
||||
Name methodName = entry.getKey();
|
||||
NamedMembers namedMembers = entry.getValue();
|
||||
resolveNamedGroupFunctions(scopeData.classOrNamespaceDescriptor, scopeData.psiClass, substitutorForGenericSupertypes, namedMembers, methodName, scopeData);
|
||||
functions.addAll(namedMembers.functionDescriptors);
|
||||
|
||||
+10
-12
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.java.prop.PropertyNameUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.prop.PropertyParseResult;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -39,7 +40,7 @@ class JavaDescriptorResolverHelper {
|
||||
private final boolean staticMembers;
|
||||
private final boolean kotlin;
|
||||
|
||||
private Map<String, NamedMembers> namedMembersMap = new HashMap<String, NamedMembers>();
|
||||
private Map<Name, NamedMembers> namedMembersMap = new HashMap<Name, NamedMembers>();
|
||||
|
||||
private Builder(PsiClassWrapper psiClass, boolean staticMembers, boolean kotlin) {
|
||||
this.psiClass = psiClass;
|
||||
@@ -52,10 +53,7 @@ class JavaDescriptorResolverHelper {
|
||||
processMethods();
|
||||
}
|
||||
|
||||
private NamedMembers getNamedMembers(String name) {
|
||||
if (name.length() == 0) {
|
||||
throw new IllegalStateException("Oi! Empty member name in " + psiClass.getPsiClass() + ". How it is possible?");
|
||||
}
|
||||
private NamedMembers getNamedMembers(Name name) {
|
||||
NamedMembers r = namedMembersMap.get(name);
|
||||
if (r == null) {
|
||||
r = new NamedMembers();
|
||||
@@ -87,7 +85,7 @@ class JavaDescriptorResolverHelper {
|
||||
PsiFieldWrapper field = new PsiFieldWrapper(field0);
|
||||
|
||||
// group must be created even for excluded field
|
||||
NamedMembers namedMembers = getNamedMembers(field.getName());
|
||||
NamedMembers namedMembers = getNamedMembers(Name.identifier(field.getName()));
|
||||
|
||||
if (!includeMember(field)) {
|
||||
continue;
|
||||
@@ -102,11 +100,11 @@ class JavaDescriptorResolverHelper {
|
||||
private void processMethods() {
|
||||
|
||||
for (PsiMethod method : psiClass.getPsiClass().getAllMethods()) {
|
||||
getNamedMembers(method.getName());
|
||||
getNamedMembers(Name.identifier(method.getName()));
|
||||
|
||||
PropertyParseResult propertyParseResult = PropertyNameUtils.parseMethodToProperty(method.getName());
|
||||
if (propertyParseResult != null) {
|
||||
getNamedMembers(propertyParseResult.getPropertyName());
|
||||
getNamedMembers(Name.identifier(propertyParseResult.getPropertyName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +122,7 @@ class JavaDescriptorResolverHelper {
|
||||
if (propertyParseResult != null && propertyParseResult.isGetter()) {
|
||||
|
||||
String propertyName = propertyParseResult.getPropertyName();
|
||||
NamedMembers members = getNamedMembers(propertyName);
|
||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||
|
||||
// TODO: some java properties too
|
||||
if (method.getJetMethod().kind() == JvmStdlibNames.JET_METHOD_KIND_PROPERTY) {
|
||||
@@ -167,7 +165,7 @@ class JavaDescriptorResolverHelper {
|
||||
else if (propertyParseResult != null && !propertyParseResult.isGetter()) {
|
||||
|
||||
String propertyName = propertyParseResult.getPropertyName();
|
||||
NamedMembers members = getNamedMembers(propertyName);
|
||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||
|
||||
if (method.getJetMethod().kind() == JvmStdlibNames.JET_METHOD_KIND_PROPERTY) {
|
||||
if (method.getParameters().size() == 0) {
|
||||
@@ -207,7 +205,7 @@ class JavaDescriptorResolverHelper {
|
||||
}
|
||||
|
||||
if (method.getJetMethod().kind() != JvmStdlibNames.JET_METHOD_KIND_PROPERTY) {
|
||||
NamedMembers namedMembers = getNamedMembers(method.getName());
|
||||
NamedMembers namedMembers = getNamedMembers(Name.identifier(method.getName()));
|
||||
namedMembers.addMethod(method);
|
||||
}
|
||||
}
|
||||
@@ -216,7 +214,7 @@ class JavaDescriptorResolverHelper {
|
||||
|
||||
|
||||
@NotNull
|
||||
static Map<String, NamedMembers> getNamedMembers(@NotNull JavaDescriptorResolver.ResolverScopeData resolverScopeData) {
|
||||
static Map<Name, NamedMembers> getNamedMembers(@NotNull JavaDescriptorResolver.ResolverScopeData resolverScopeData) {
|
||||
if (resolverScopeData.psiClass != null) {
|
||||
Builder builder = new Builder(new PsiClassWrapper(resolverScopeData.psiClass), resolverScopeData.staticMembers, resolverScopeData.kotlin);
|
||||
builder.run();
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import org.jetbrains.jet.lang.descriptors.AbstractNamespaceDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptorParent;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,7 +34,7 @@ public class JavaNamespaceDescriptor extends AbstractNamespaceDescriptorImpl {
|
||||
private final FqName qualifiedName;
|
||||
|
||||
public JavaNamespaceDescriptor(NamespaceDescriptorParent containingDeclaration, List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name, @NotNull FqName qualifiedName) {
|
||||
@NotNull Name name, @NotNull FqName qualifiedName) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
this.qualifiedName = qualifiedName;
|
||||
}
|
||||
|
||||
+4
-3
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -44,7 +45,7 @@ public class JavaPackageScope extends JavaClassOrPackageScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
ClassDescriptor classDescriptor = semanticServices.getDescriptorResolver().resolveClass(packageFQN.child(name), DescriptorSearchRule.IGNORE_IF_FOUND_IN_KOTLIN);
|
||||
if (classDescriptor == null || DescriptorUtils.isObject(classDescriptor)) {
|
||||
// TODO: this is a big hack against several things that I barely understand myself and cannot explain
|
||||
@@ -56,13 +57,13 @@ public class JavaPackageScope extends JavaClassOrPackageScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
return semanticServices.getDescriptorResolver().resolveNamespace(packageFQN.child(name), DescriptorSearchRule.INCLUDE_KOTLIN);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -87,8 +88,8 @@ public class JavaSemanticServices {
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor getKotlinBuiltinClassDescriptor(@NotNull FqName qualifiedName) {
|
||||
if (qualifiedName.getFqName().startsWith("jet.")) {
|
||||
return (ClassDescriptor) JetStandardLibrary.getInstance().getLibraryScope().getClassifier(qualifiedName.getFqName().substring("jet.".length()));
|
||||
if (qualifiedName.firstSegmentIs(Name.identifier("jet")) && qualifiedName.pathSegments().size() == 2) {
|
||||
return (ClassDescriptor) JetStandardLibrary.getInstance().getLibraryScope().getClassifier(qualifiedName.pathSegments().get(1));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiClass;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -29,7 +30,7 @@ import java.util.Set;
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
class NamedMembers {
|
||||
String name;
|
||||
Name name;
|
||||
List<PsiMethodWrapper> methods = new ArrayList<PsiMethodWrapper>(0);
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class TypeVariableResolverFromTypeDescriptors implements TypeVariableReso
|
||||
@NotNull DeclarationDescriptor owner,
|
||||
@NotNull String context) {
|
||||
for (TypeParameterDescriptor typeParameter : typeParameters) {
|
||||
if (typeParameter.getName().equals(name)) {
|
||||
if (typeParameter.getName().getName().equals(name)) {
|
||||
return typeParameter;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.NamespaceType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
@@ -32,13 +33,12 @@ public abstract class AbstractNamespaceDescriptorImpl extends DeclarationDescrip
|
||||
public AbstractNamespaceDescriptorImpl(
|
||||
@NotNull NamespaceDescriptorParent containingDeclaration,
|
||||
List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name) {
|
||||
@NotNull Name name) {
|
||||
|
||||
super(containingDeclaration, annotations, name);
|
||||
|
||||
boolean rootAccordingToContainer = containingDeclaration instanceof ModuleDescriptor;
|
||||
boolean rootAccordingToName = name.startsWith("<");
|
||||
if (rootAccordingToContainer != rootAccordingToName) {
|
||||
if (rootAccordingToContainer != name.isSpecial()) {
|
||||
throw new IllegalStateException("something is wrong, name: " + name + ", container: " + containingDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
@@ -42,7 +43,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl
|
||||
public ClassDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name) {
|
||||
@NotNull Name name) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl
|
||||
@NotNull Set<ConstructorDescriptor> constructors,
|
||||
@Nullable ConstructorDescriptor primaryConstructor,
|
||||
@Nullable JetType superclassType) {
|
||||
this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName(), typeParameters, supertypes);
|
||||
this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName().getName(), typeParameters, supertypes);
|
||||
this.memberDeclarations = memberDeclarations;
|
||||
this.constructors = constructors;
|
||||
this.primaryConstructor = primaryConstructor;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface ConstructorDescriptor extends FunctionDescriptor {
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
String getName();
|
||||
Name getName();
|
||||
|
||||
boolean isPrimary();
|
||||
}
|
||||
|
||||
+5
-2
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -32,13 +33,15 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
|
||||
private final boolean isPrimary;
|
||||
|
||||
private static final Name NAME = Name.special("<init>");
|
||||
|
||||
public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull List<AnnotationDescriptor> annotations, boolean isPrimary) {
|
||||
super(containingDeclaration, annotations, "<init>", Kind.DECLARATION);
|
||||
super(containingDeclaration, annotations, NAME, Kind.DECLARATION);
|
||||
this.isPrimary = isPrimary;
|
||||
}
|
||||
|
||||
public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull ConstructorDescriptor original, @NotNull List<AnnotationDescriptor> annotations, boolean isPrimary) {
|
||||
super(containingDeclaration, original, annotations, "<init>", Kind.DECLARATION);
|
||||
super(containingDeclaration, original, annotations, NAME, Kind.DECLARATION);
|
||||
this.isPrimary = isPrimary;
|
||||
}
|
||||
|
||||
|
||||
+5
-7
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotatedImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.util.List;
|
||||
@@ -29,23 +30,20 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements Named, DeclarationDescriptor {
|
||||
|
||||
private final String name;
|
||||
@NotNull
|
||||
private final Name name;
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
|
||||
public DeclarationDescriptorImpl(@Nullable DeclarationDescriptor containingDeclaration, @NotNull List<AnnotationDescriptor> annotations, @NotNull String name) {
|
||||
public DeclarationDescriptorImpl(@Nullable DeclarationDescriptor containingDeclaration, @NotNull List<AnnotationDescriptor> annotations, @NotNull Name name) {
|
||||
super(annotations);
|
||||
|
||||
if (name.length() == 0) {
|
||||
throw new IllegalArgumentException("descriptor name cannot be empty string");
|
||||
}
|
||||
|
||||
this.name = name;
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public Name getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver;
|
||||
@@ -55,7 +56,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorImpl i
|
||||
protected FunctionDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
Kind kind) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
this.original = this;
|
||||
@@ -66,7 +67,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorImpl i
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull FunctionDescriptor original,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
Kind kind) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
this.original = original;
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
@@ -141,7 +142,7 @@ public class FunctionDescriptorUtil {
|
||||
|
||||
ClassifierDescriptor classDescriptorForFunction = functionType.getConstructor().getDeclarationDescriptor();
|
||||
assert classDescriptorForFunction instanceof ClassDescriptor;
|
||||
Set<FunctionDescriptor> invokeFunctions = ((ClassDescriptor) classDescriptorForFunction).getMemberScope(functionType.getArguments()).getFunctions("invoke");
|
||||
Set<FunctionDescriptor> invokeFunctions = ((ClassDescriptor) classDescriptorForFunction).getMemberScope(functionType.getArguments()).getFunctions(Name.identifier("invoke"));
|
||||
assert invokeFunctions.size() == 1;
|
||||
return invokeFunctions.iterator().next();
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
@@ -137,7 +138,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public Name getName() {
|
||||
return original.getName();
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
@@ -32,7 +33,7 @@ public class LocalVariableDescriptor extends VariableDescriptorImpl {
|
||||
public LocalVariableDescriptor(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
@Nullable JetType type,
|
||||
boolean mutable) {
|
||||
super(containingDeclaration, annotations, name, type);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -28,8 +29,11 @@ import java.util.Collections;
|
||||
public class ModuleDescriptor extends DeclarationDescriptorImpl implements ClassOrNamespaceDescriptor, NamespaceDescriptorParent {
|
||||
private NamespaceDescriptor rootNs;
|
||||
|
||||
public ModuleDescriptor(String name) {
|
||||
public ModuleDescriptor(Name name) {
|
||||
super(null, Collections.<AnnotationDescriptor>emptyList(), name);
|
||||
if (!name.isSpecial()) {
|
||||
throw new IllegalArgumentException("module name must be special: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRootNs(@NotNull NamespaceDescriptor rootNs) {
|
||||
|
||||
+3
-2
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.resolve.AbstractScopeAdapter;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
@@ -47,7 +48,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
||||
private WritableScope scopeForInitializers = null; //contains members + primary constructor value parameters + map for backing fields
|
||||
|
||||
public MutableClassDescriptor(@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetScope outerScope, ClassKind kind, String name) {
|
||||
@NotNull JetScope outerScope, ClassKind kind, Name name) {
|
||||
super(containingDeclaration, kind);
|
||||
|
||||
RedeclarationHandler redeclarationHandler = RedeclarationHandler.DO_NOTHING;
|
||||
@@ -118,7 +119,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void setName(@NotNull String name) {
|
||||
public void setName(@NotNull Name name) {
|
||||
super.setName(name);
|
||||
scopeForMemberResolution.addLabeledDeclaration(this);
|
||||
}
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ public class MutableClassDescriptorLite extends MutableDeclarationDescriptor
|
||||
this,
|
||||
Collections.<AnnotationDescriptor>emptyList(), // TODO : pass annotations from the class?
|
||||
!modality.isOverridable(),
|
||||
getName(),
|
||||
getName().getName(),
|
||||
typeParameters,
|
||||
supertypes);
|
||||
for (FunctionDescriptor functionDescriptor : constructors) {
|
||||
|
||||
+4
-3
@@ -17,12 +17,13 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class MutableDeclarationDescriptor implements DeclarationDescriptor {
|
||||
private String name;
|
||||
private Name name;
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
|
||||
public MutableDeclarationDescriptor(@NotNull DeclarationDescriptor containingDeclaration) {
|
||||
@@ -31,11 +32,11 @@ public abstract class MutableDeclarationDescriptor implements DeclarationDescrip
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public Name getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@NotNull String name) {
|
||||
public void setName(@NotNull Name name) {
|
||||
assert this.name == null : this.name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface Named {
|
||||
@NotNull
|
||||
String getName();
|
||||
Name getName();
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,7 +34,7 @@ public class NamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl imp
|
||||
|
||||
public NamespaceDescriptorImpl(@NotNull NamespaceDescriptorParent containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name) {
|
||||
@NotNull Name name) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
@@ -43,7 +44,7 @@ public abstract class PropertyAccessorDescriptor extends DeclarationDescriptorIm
|
||||
@NotNull Visibility visibility,
|
||||
@NotNull PropertyDescriptor correspondingProperty,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
Kind kind) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver;
|
||||
@@ -54,7 +55,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
private PropertySetterDescriptor setter;
|
||||
|
||||
private PropertyDescriptor() {
|
||||
super(ErrorUtils.getErrorClass(), Collections.<AnnotationDescriptor>emptyList(), "dummy");
|
||||
super(ErrorUtils.getErrorClass(), Collections.<AnnotationDescriptor>emptyList(), Name.special("<dummy>"));
|
||||
this.modality = null;
|
||||
this.visibility = null;
|
||||
this.isVar = false;
|
||||
@@ -71,7 +72,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
@NotNull Visibility visibility,
|
||||
boolean isVar,
|
||||
boolean isObject,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
Kind kind) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
this.isVar = isVar;
|
||||
@@ -89,7 +90,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
@NotNull Visibility visibility,
|
||||
boolean isVar,
|
||||
boolean isObject,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
Kind kind) {
|
||||
this(null, containingDeclaration, annotations, modality, visibility, isVar, isObject, name, kind);
|
||||
}
|
||||
@@ -103,7 +104,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
boolean isObject,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull ReceiverDescriptor expectedThisObject,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
@NotNull JetType outType,
|
||||
Kind kind
|
||||
) {
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -33,7 +34,7 @@ public class PropertyGetterDescriptor extends PropertyAccessorDescriptor {
|
||||
public PropertyGetterDescriptor(@NotNull PropertyDescriptor correspondingProperty, @NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull Modality modality, @NotNull Visibility visibility, boolean hasBody, boolean isDefault, Kind kind)
|
||||
{
|
||||
super(modality, visibility, correspondingProperty, annotations, "get-" + correspondingProperty.getName(), hasBody, isDefault, kind);
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<get-" + correspondingProperty.getName() + ">"), hasBody, isDefault, kind);
|
||||
}
|
||||
|
||||
public void initialize(JetType returnType) {
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
@@ -40,7 +41,7 @@ public class PropertySetterDescriptor extends PropertyAccessorDescriptor {
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
Kind kind) {
|
||||
super(modality, visibility, correspondingProperty, annotations, "set-" + correspondingProperty.getName(), hasBody, isDefault, kind);
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<set-" + correspondingProperty.getName() + ">"), hasBody, isDefault, kind);
|
||||
}
|
||||
|
||||
public void initialize(@NotNull ValueParameterDescriptor parameter) {
|
||||
@@ -50,7 +51,7 @@ public class PropertySetterDescriptor extends PropertyAccessorDescriptor {
|
||||
|
||||
public void initializeDefault() {
|
||||
assert parameter == null;
|
||||
parameter = new ValueParameterDescriptorImpl(this, 0, Collections.<AnnotationDescriptor>emptyList(), "<>", false, getCorrespondingProperty().getReturnType(), false, null);
|
||||
parameter = new ValueParameterDescriptorImpl(this, 0, Collections.<AnnotationDescriptor>emptyList(), Name.special("<set-?>"), false, getCorrespondingProperty().getReturnType(), false, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
@@ -28,10 +29,12 @@ import java.util.Collections;
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class ScriptDescriptor extends DeclarationDescriptorImpl {
|
||||
private static final Name NAME = Name.special("<script>");
|
||||
|
||||
private JetType returnType;
|
||||
|
||||
public ScriptDescriptor(@Nullable DeclarationDescriptor containingDeclaration) {
|
||||
super(containingDeclaration, Collections.<AnnotationDescriptor>emptyList(), "<script>");
|
||||
super(containingDeclaration, Collections.<AnnotationDescriptor>emptyList(), NAME);
|
||||
}
|
||||
|
||||
public void initialize(@NotNull JetType returnType) {
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
@@ -36,7 +37,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
public SimpleFunctionDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
Kind kind) {
|
||||
super(containingDeclaration, annotations, name, kind);
|
||||
}
|
||||
@@ -45,7 +46,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull SimpleFunctionDescriptor original,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
Kind kind) {
|
||||
super(containingDeclaration, original, annotations, name, kind);
|
||||
}
|
||||
|
||||
+5
-4
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -41,7 +42,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
boolean reified,
|
||||
@NotNull Variance variance,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
int index) {
|
||||
TypeParameterDescriptor typeParameterDescriptor = createForFurtherModification(containingDeclaration, annotations, reified, variance, name, index);
|
||||
typeParameterDescriptor.addUpperBound(JetStandardClasses.getDefaultBound());
|
||||
@@ -54,7 +55,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
boolean reified,
|
||||
@NotNull Variance variance,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
int index) {
|
||||
return new TypeParameterDescriptor(containingDeclaration, annotations, reified, variance, name, index);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
boolean reified,
|
||||
@NotNull Variance variance,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
int index) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
this.index = index;
|
||||
@@ -90,7 +91,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
this,
|
||||
annotations,
|
||||
false,
|
||||
name,
|
||||
name.getName(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
upperBounds);
|
||||
}
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
int index,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
boolean isVar,
|
||||
@NotNull JetType outType,
|
||||
boolean declaresDefaultValue,
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
@@ -35,7 +36,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
|
||||
public VariableDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
@Nullable JetType outType) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
|
||||
@@ -45,7 +46,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
|
||||
protected VariableDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name
|
||||
@NotNull Name name
|
||||
)
|
||||
{
|
||||
super(containingDeclaration, annotations, name);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Renderers {
|
||||
@Override
|
||||
public String render(@NotNull Object element) {
|
||||
if (element instanceof Named) {
|
||||
return ((Named) element).getName();
|
||||
return ((Named) element).getName().getName();
|
||||
}
|
||||
return element.toString();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.intellij.psi.PsiNameIdentifierOwner;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
/**
|
||||
@@ -44,6 +46,12 @@ public abstract class JetNamedDeclaration extends JetDeclaration implements PsiN
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Name getNameAsName() {
|
||||
String name = getName();
|
||||
return name != null ? Name.identifier(name) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getNameIdentifier() {
|
||||
return findChildByType(JetTokens.IDENTIFIER);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class JetNamedFunction extends JetFunction implements StubBasedPsiElement
|
||||
}
|
||||
JetFile jetFile = (JetFile) parent;
|
||||
final FqName fileFQN = JetPsiUtil.getFQName(jetFile);
|
||||
return fileFQN.child(getName());
|
||||
return fileFQN.child(getNameAsName());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -78,6 +79,12 @@ public class JetNamespaceHeader extends JetReferenceExpression {
|
||||
return nameIdentifier == null ? "" : nameIdentifier.getText();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Name getNameAsName() {
|
||||
PsiElement nameIdentifier = getNameIdentifier();
|
||||
return nameIdentifier == null ? null : Name.identifier(nameIdentifier.getText());
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return getName().length() == 0;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
@@ -38,7 +39,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class JetPsiUtil {
|
||||
|
||||
public static final String NO_NAME_PROVIDED = "<no name provided>";
|
||||
public static final Name NO_NAME_PROVIDED = Name.special("<no name provided>");
|
||||
|
||||
private JetPsiUtil() {
|
||||
}
|
||||
@@ -67,8 +68,8 @@ public class JetPsiUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String safeName(String name) {
|
||||
return name == null ? NO_NAME_PROVIDED : name;
|
||||
public static Name safeName(@Nullable String name) {
|
||||
return name == null ? NO_NAME_PROVIDED : Name.identifier(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -162,7 +163,7 @@ public class JetPsiUtil {
|
||||
return getFQName(objectDeclaration);
|
||||
}
|
||||
|
||||
String functionName = namedDeclaration.getName();
|
||||
Name functionName = namedDeclaration.getNameAsName();
|
||||
if (functionName == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -201,7 +202,7 @@ public class JetPsiUtil {
|
||||
|
||||
@NotNull
|
||||
private static FqName makeFQName(@NotNull FqName prefix, @NotNull JetClassOrObject jetClass) {
|
||||
return prefix.child(jetClass.getName());
|
||||
return prefix.child(Name.identifier(jetClass.getName()));
|
||||
}
|
||||
|
||||
public static boolean isIrrefutable(JetWhenEntry entry) {
|
||||
@@ -297,7 +298,7 @@ public class JetPsiUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getAliasName(@NotNull JetImportDirective importDirective) {
|
||||
public static Name getAliasName(@NotNull JetImportDirective importDirective) {
|
||||
String aliasName = importDirective.getAliasName();
|
||||
JetExpression importedReference = importDirective.getImportedReference();
|
||||
if (importedReference == null) {
|
||||
@@ -307,7 +308,7 @@ public class JetPsiUtil {
|
||||
if (aliasName == null) {
|
||||
aliasName = referenceExpression != null ? referenceExpression.getReferencedName() : null;
|
||||
}
|
||||
return aliasName;
|
||||
return aliasName != null ? Name.identifier(aliasName) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -327,7 +328,7 @@ public class JetPsiUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
return JetStandardClasses.UNIT_ALIAS.equals(typeReference.getText());
|
||||
return JetStandardClasses.UNIT_ALIAS.getName().equals(typeReference.getText());
|
||||
}
|
||||
|
||||
public static boolean isSafeCall(@NotNull Call call) {
|
||||
|
||||
@@ -25,7 +25,9 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.parsing.JetExpressionParsing;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import static org.jetbrains.jet.lexer.JetTokens.*;
|
||||
@@ -87,6 +89,14 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
|
||||
return text != null ? JetPsiUtil.unquoteIdentifierOrFieldReference(text) : null;
|
||||
}
|
||||
|
||||
public Name getReferencedNameAsName() {
|
||||
String name = getReferencedName();
|
||||
if (name != null && name.length() == 0) {
|
||||
// TODO: fix parser or do something // stepan.koltsov@
|
||||
}
|
||||
return name != null ? Name.identifierNoValidate(name) : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiElement getReferencedNameElement() {
|
||||
PsiElement element = findChildByType(REFERENCE_TOKENS);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
@@ -48,22 +49,22 @@ public abstract class AbstractScopeAdapter implements JetScope {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
return getWorkerScope().getFunctions(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
return getWorkerScope().getNamespace(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
return getWorkerScope().getClassifier(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return getWorkerScope().getObjectDescriptor(name);
|
||||
}
|
||||
|
||||
@@ -75,12 +76,12 @@ public abstract class AbstractScopeAdapter implements JetScope {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
return getWorkerScope().getProperties(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableDescriptor getLocalVariable(@NotNull String name) {
|
||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||
return getWorkerScope().getLocalVariable(name);
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ public abstract class AbstractScopeAdapter implements JetScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
|
||||
return getWorkerScope().getPropertyByFieldReference(fieldName);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +96,11 @@ public class AnnotationResolver {
|
||||
ConstructorDescriptor constructor = (ConstructorDescriptor)descriptor;
|
||||
ClassDescriptor classDescriptor = constructor.getContainingDeclaration();
|
||||
if (classDescriptor.getKind() != ClassKind.ANNOTATION_CLASS) {
|
||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor.getName()));
|
||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor.getName().getName()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, descriptor.getName()));
|
||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, descriptor.getName().getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
@@ -251,8 +252,8 @@ public class DeclarationResolver {
|
||||
|
||||
private void checkRedeclarationsInNamespaces() {
|
||||
for (NamespaceDescriptorImpl descriptor : context.getNamespaceDescriptors().values()) {
|
||||
Multimap<String, DeclarationDescriptor> simpleNameDescriptors = descriptor.getMemberScope().getDeclaredDescriptorsAccessibleBySimpleName();
|
||||
for (String name : simpleNameDescriptors.keySet()) {
|
||||
Multimap<Name, DeclarationDescriptor> simpleNameDescriptors = descriptor.getMemberScope().getDeclaredDescriptorsAccessibleBySimpleName();
|
||||
for (Name name : simpleNameDescriptors.keySet()) {
|
||||
// Keep only properties with no receiver
|
||||
Collection<DeclarationDescriptor> descriptors = Collections2.filter(simpleNameDescriptors.get(name), new Predicate<DeclarationDescriptor>() {
|
||||
@Override
|
||||
@@ -268,7 +269,7 @@ public class DeclarationResolver {
|
||||
for (DeclarationDescriptor declarationDescriptor : descriptors) {
|
||||
for (PsiElement declaration : getDeclarationsByDescriptor(declarationDescriptor)) {
|
||||
assert declaration != null;
|
||||
trace.report(REDECLARATION.on(declaration, declarationDescriptor.getName()));
|
||||
trace.report(REDECLARATION.on(declaration, declarationDescriptor.getName().getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ public class DeclarationsChecker {
|
||||
boolean inAbstractClass = classDescriptor.getModality() == Modality.ABSTRACT;
|
||||
if (hasAbstractModifier && !inAbstractClass && !inTrait && !inEnum) {
|
||||
JetClass classElement = (JetClass) BindingContextUtils.classDescriptorToDeclaration(trace.getBindingContext(), classDescriptor);
|
||||
trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.getName(), classDescriptor));
|
||||
trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.getName().getName(), classDescriptor));
|
||||
}
|
||||
if (hasAbstractModifier && inTrait) {
|
||||
trace.report(ABSTRACT_MODIFIER_IN_TRAIT.on(function));
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
@@ -272,7 +273,9 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MutableValueParameterDescriptor resolveValueParameterDescriptor(JetScope scope, DeclarationDescriptor declarationDescriptor, JetParameter valueParameter, int index, JetType type, BindingTrace trace) {
|
||||
public MutableValueParameterDescriptor resolveValueParameterDescriptor(
|
||||
JetScope scope, DeclarationDescriptor declarationDescriptor,
|
||||
JetParameter valueParameter, int index, JetType type, BindingTrace trace) {
|
||||
JetType varargElementType = null;
|
||||
JetType variableType = type;
|
||||
if (valueParameter.hasModifier(JetTokens.VARARG_KEYWORD)) {
|
||||
@@ -347,7 +350,7 @@ public class DescriptorResolver {
|
||||
List<UpperBoundCheckerTask> deferredUpperBoundCheckerTasks = Lists.newArrayList();
|
||||
|
||||
List<JetTypeParameter> typeParameters = declaration.getTypeParameters();
|
||||
Map<String, TypeParameterDescriptor> parameterByName = Maps.newHashMap();
|
||||
Map<Name, TypeParameterDescriptor> parameterByName = Maps.newHashMap();
|
||||
for (int i = 0; i < typeParameters.size(); i++) {
|
||||
JetTypeParameter jetTypeParameter = typeParameters.get(i);
|
||||
TypeParameterDescriptor typeParameterDescriptor = parameters.get(i);
|
||||
@@ -366,7 +369,7 @@ public class DescriptorResolver {
|
||||
if (subjectTypeParameterName == null) {
|
||||
continue;
|
||||
}
|
||||
String referencedName = subjectTypeParameterName.getReferencedName();
|
||||
Name referencedName = subjectTypeParameterName.getReferencedNameAsName();
|
||||
if (referencedName == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -875,7 +878,7 @@ public class DescriptorResolver {
|
||||
@NotNull JetScope scope,
|
||||
@NotNull JetParameter parameter, BindingTrace trace) {
|
||||
JetType type = resolveParameterType(scope, parameter, trace);
|
||||
String name = parameter.getName();
|
||||
Name name = parameter.getNameAsName();
|
||||
boolean isMutable = parameter.isMutable();
|
||||
JetModifierList modifierList = parameter.getModifierList();
|
||||
|
||||
@@ -893,7 +896,7 @@ public class DescriptorResolver {
|
||||
resolveVisibilityFromModifiers(parameter.getModifierList()),
|
||||
isMutable,
|
||||
false,
|
||||
name == null ? "<no name>" : name,
|
||||
name == null ? Name.special("<no name>") : name,
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.psi.JetFunction;
|
||||
import org.jetbrains.jet.lang.psi.JetSecondaryConstructor;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
@@ -191,10 +192,10 @@ public class DescriptorUtils {
|
||||
if (containingDeclaration == null) {
|
||||
if (descriptor instanceof NamespaceDescriptor) {
|
||||
// TODO: namespace must always have parent
|
||||
if (descriptor.getName().equals("jet")) {
|
||||
return FqNameUnsafe.topLevel("jet");
|
||||
if (descriptor.getName().equals(Name.identifier("jet"))) {
|
||||
return FqNameUnsafe.topLevel(Name.identifier("jet"));
|
||||
}
|
||||
if (descriptor.getName().equals("<java_root>")) {
|
||||
if (descriptor.getName().equals(Name.special("<java_root>"))) {
|
||||
return FqName.ROOT.toUnsafe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
import java.util.List;
|
||||
@@ -31,7 +32,7 @@ import java.util.List;
|
||||
|
||||
void addAllUnderImport(@NotNull DeclarationDescriptor descriptor);
|
||||
|
||||
void addAliasImport(@NotNull DeclarationDescriptor descriptor, @NotNull String aliasName);
|
||||
void addAliasImport(@NotNull DeclarationDescriptor descriptor, @NotNull Name aliasName);
|
||||
|
||||
Importer DO_NOTHING = new Importer() {
|
||||
@Override
|
||||
@@ -39,7 +40,7 @@ import java.util.List;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAliasImport(@NotNull DeclarationDescriptor descriptor, @NotNull String aliasName) {
|
||||
public void addAliasImport(@NotNull DeclarationDescriptor descriptor, @NotNull Name aliasName) {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,7 +57,7 @@ import java.util.List;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAliasImport(@NotNull DeclarationDescriptor descriptor, @NotNull String aliasName) {
|
||||
public void addAliasImport(@NotNull DeclarationDescriptor descriptor, @NotNull Name aliasName) {
|
||||
importDeclarationAlias(descriptor, aliasName);
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ import java.util.List;
|
||||
}
|
||||
}
|
||||
|
||||
protected void importDeclarationAlias(@NotNull DeclarationDescriptor descriptor, @NotNull String aliasName) {
|
||||
protected void importDeclarationAlias(@NotNull DeclarationDescriptor descriptor, @NotNull Name aliasName) {
|
||||
if (descriptor instanceof ClassifierDescriptor) {
|
||||
namespaceScope.importClassifierAlias(aliasName, (ClassifierDescriptor) descriptor);
|
||||
}
|
||||
@@ -92,7 +93,7 @@ import java.util.List;
|
||||
}
|
||||
|
||||
class DelayedImporter extends StandardImporter {
|
||||
private final List<Pair<DeclarationDescriptor, String>> imports = Lists.newArrayList();
|
||||
private final List<Pair<DeclarationDescriptor, Name>> imports = Lists.newArrayList();
|
||||
|
||||
public DelayedImporter(@NotNull WritableScope namespaceScope) {
|
||||
super(namespaceScope);
|
||||
@@ -100,18 +101,18 @@ import java.util.List;
|
||||
|
||||
@Override
|
||||
public void addAllUnderImport(@NotNull DeclarationDescriptor descriptor) {
|
||||
imports.add(Pair.<DeclarationDescriptor, String>create(descriptor, null));
|
||||
imports.add(Pair.<DeclarationDescriptor, Name>create(descriptor, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAliasImport(@NotNull DeclarationDescriptor descriptor, @NotNull String aliasName) {
|
||||
public void addAliasImport(@NotNull DeclarationDescriptor descriptor, @NotNull Name aliasName) {
|
||||
imports.add(Pair.create(descriptor, aliasName));
|
||||
}
|
||||
|
||||
public void processImports() {
|
||||
for (Pair<DeclarationDescriptor, String> anImport : imports) {
|
||||
for (Pair<DeclarationDescriptor, Name> anImport : imports) {
|
||||
DeclarationDescriptor descriptor = anImport.getFirst();
|
||||
String aliasName = anImport.getSecond();
|
||||
Name aliasName = anImport.getSecond();
|
||||
boolean allUnderImport = aliasName == null;
|
||||
if (allUnderImport) {
|
||||
importAllUnderDeclaration(descriptor);
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
@@ -125,7 +126,7 @@ public class ImportsResolver {
|
||||
if (importedReference == null || !resolvedDirectives.containsKey(importDirective)) {
|
||||
return;
|
||||
}
|
||||
String aliasName = JetPsiUtil.getAliasName(importDirective);
|
||||
Name aliasName = JetPsiUtil.getAliasName(importDirective);
|
||||
if (aliasName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.resolve;
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.NamespaceType;
|
||||
|
||||
@@ -26,6 +27,6 @@ import org.jetbrains.jet.lang.types.NamespaceType;
|
||||
public class JetModuleUtil {
|
||||
public static NamespaceType getRootNamespaceType(JetElement expression) {
|
||||
// TODO: this is a stub: at least the modules' root namespaces must be indexed here
|
||||
return new NamespaceType("<namespace_root>", JetScope.EMPTY);
|
||||
return new NamespaceType(Name.special("<namespace_root>"), JetScope.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
@@ -80,7 +81,7 @@ public class NamespaceFactoryImpl implements NamespaceFactory {
|
||||
}
|
||||
|
||||
for (JetSimpleNameExpression nameExpression : namespaceHeader.getParentNamespaceNames()) {
|
||||
String namespaceName = JetPsiUtil.safeName(nameExpression.getReferencedName());
|
||||
Name namespaceName = JetPsiUtil.safeName(nameExpression.getReferencedName());
|
||||
|
||||
NamespaceDescriptorImpl namespaceDescriptor = createNamespaceDescriptorIfNeeded(
|
||||
null, currentOwner, namespaceName, nameExpression, handler);
|
||||
@@ -93,14 +94,14 @@ public class NamespaceFactoryImpl implements NamespaceFactory {
|
||||
}
|
||||
|
||||
NamespaceDescriptorImpl namespaceDescriptor;
|
||||
String name;
|
||||
Name name;
|
||||
if (namespaceHeader.isRoot()) {
|
||||
// previous call to createRootNamespaceDescriptorIfNeeded couldn't store occurrence for current file.
|
||||
namespaceDescriptor = moduleDescriptor.getRootNs();
|
||||
storeBindingForFileAndExpression(file, null, namespaceDescriptor);
|
||||
}
|
||||
else {
|
||||
name = namespaceHeader.getName();
|
||||
name = namespaceHeader.getNameAsName();
|
||||
namespaceDescriptor = createNamespaceDescriptorIfNeeded(
|
||||
file, currentOwner, name, namespaceHeader.getLastPartExpression(), handler);
|
||||
|
||||
@@ -156,7 +157,7 @@ public class NamespaceFactoryImpl implements NamespaceFactory {
|
||||
@NotNull
|
||||
private NamespaceDescriptorImpl createNamespaceDescriptorIfNeeded(@Nullable JetFile file,
|
||||
@NotNull NamespaceDescriptorImpl owner,
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
@Nullable JetReferenceExpression expression,
|
||||
@NotNull RedeclarationHandler handler) {
|
||||
FqName ownerFqName = DescriptorUtils.getFQName(owner).toSafe();
|
||||
@@ -174,7 +175,7 @@ public class NamespaceFactoryImpl implements NamespaceFactory {
|
||||
}
|
||||
|
||||
private NamespaceDescriptorImpl createNewNamespaceDescriptor(NamespaceDescriptorParent owner,
|
||||
String name,
|
||||
Name name,
|
||||
PsiElement expression,
|
||||
RedeclarationHandler handler,
|
||||
FqName fqName) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.psi.JetClass;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collection;
|
||||
@@ -70,12 +71,12 @@ public class OverloadResolver {
|
||||
checkOverloadsInANamespace(inNamespaces);
|
||||
}
|
||||
|
||||
private static class Key extends Pair<String, String> {
|
||||
Key(String namespace, String name) {
|
||||
private static class Key extends Pair<String, Name> {
|
||||
Key(String namespace, Name name) {
|
||||
super(namespace, name);
|
||||
}
|
||||
|
||||
Key(NamespaceDescriptor namespaceDescriptor, String name) {
|
||||
Key(NamespaceDescriptor namespaceDescriptor, Name name) {
|
||||
this(DescriptorUtils.getFQName(namespaceDescriptor).getFqName(), name);
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ public class OverloadResolver {
|
||||
return first;
|
||||
}
|
||||
|
||||
public String getFunctionName() {
|
||||
public Name getFunctionName() {
|
||||
return second;
|
||||
}
|
||||
}
|
||||
@@ -150,7 +151,7 @@ public class OverloadResolver {
|
||||
}
|
||||
if (jetClass instanceof JetObjectDeclaration) {
|
||||
// must be class object
|
||||
name = classDescriptor.getContainingDeclaration().getName();
|
||||
name = classDescriptor.getContainingDeclaration().getName().getName();
|
||||
return "class object " + name;
|
||||
}
|
||||
// safe
|
||||
@@ -161,7 +162,7 @@ public class OverloadResolver {
|
||||
MutableClassDescriptor classDescriptor, JetClassOrObject klass,
|
||||
Collection<ConstructorDescriptor> nestedClassConstructors
|
||||
) {
|
||||
MultiMap<String, CallableMemberDescriptor> functionsByName = MultiMap.create();
|
||||
MultiMap<Name, CallableMemberDescriptor> functionsByName = MultiMap.create();
|
||||
|
||||
for (CallableMemberDescriptor function : classDescriptor.getDeclaredCallableMembers()) {
|
||||
functionsByName.putValue(function.getName(), function);
|
||||
@@ -171,7 +172,7 @@ public class OverloadResolver {
|
||||
functionsByName.putValue(nestedClassConstructor.getContainingDeclaration().getName(), nestedClassConstructor);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Collection<CallableMemberDescriptor>> e : functionsByName.entrySet()) {
|
||||
for (Map.Entry<Name, Collection<CallableMemberDescriptor>> e : functionsByName.entrySet()) {
|
||||
checkOverloadsWithSameName(e.getKey(), e.getValue(), nameForErrorMessage(classDescriptor, klass));
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ public class OverloadResolver {
|
||||
|
||||
}
|
||||
|
||||
private void checkOverloadsWithSameName(String name, Collection<CallableMemberDescriptor> functions, @NotNull String functionContainer) {
|
||||
private void checkOverloadsWithSameName(@NotNull Name name, Collection<CallableMemberDescriptor> functions, @NotNull String functionContainer) {
|
||||
if (functions.size() == 1) {
|
||||
// microoptimization
|
||||
return;
|
||||
@@ -200,7 +201,7 @@ public class OverloadResolver {
|
||||
}
|
||||
|
||||
if (member instanceof PropertyDescriptor) {
|
||||
trace.report(Errors.REDECLARATION.on(BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), member), member.getName()));
|
||||
trace.report(Errors.REDECLARATION.on(BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), member), member.getName().getName()));
|
||||
}
|
||||
else {
|
||||
trace.report(Errors.CONFLICTING_OVERLOADS.on(jetDeclaration, member, functionContainer));
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
@@ -113,16 +114,16 @@ public class OverrideResolver {
|
||||
|
||||
List<CallableMemberDescriptor> functionsFromSupertypes = getDescriptorsFromSupertypes(classDescriptor);
|
||||
|
||||
MultiMap<String, CallableMemberDescriptor> functionsFromSupertypesByName = groupDescriptorsByName(functionsFromSupertypes);
|
||||
MultiMap<Name, CallableMemberDescriptor> functionsFromSupertypesByName = groupDescriptorsByName(functionsFromSupertypes);
|
||||
|
||||
MultiMap<String, CallableMemberDescriptor> functionsFromCurrentByName = groupDescriptorsByName(classDescriptor.getDeclaredCallableMembers());
|
||||
MultiMap<Name, CallableMemberDescriptor> functionsFromCurrentByName = groupDescriptorsByName(classDescriptor.getDeclaredCallableMembers());
|
||||
|
||||
Set<String> functionNames = new LinkedHashSet<String>();
|
||||
Set<Name> functionNames = new LinkedHashSet<Name>();
|
||||
functionNames.addAll(functionsFromSupertypesByName.keySet());
|
||||
functionNames.addAll(functionsFromCurrentByName.keySet());
|
||||
|
||||
Set<CallableMemberDescriptor> fakeOverrides = Sets.newHashSet();
|
||||
for (String functionName : functionNames) {
|
||||
for (Name functionName : functionNames) {
|
||||
generateOverridesInFunctionGroup(functionName, fakeOverrides,
|
||||
functionsFromSupertypesByName.get(functionName),
|
||||
functionsFromCurrentByName.get(functionName),
|
||||
@@ -145,7 +146,7 @@ public class OverrideResolver {
|
||||
@Override
|
||||
public void conflict(@NotNull CallableMemberDescriptor fromSuper, @NotNull CallableMemberDescriptor fromCurrent) {
|
||||
JetDeclaration jetProperty = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), fromCurrent);
|
||||
trace.report(Errors.CONFLICTING_OVERLOADS.on(jetProperty, fromCurrent, fromCurrent.getContainingDeclaration().getName()));
|
||||
trace.report(Errors.CONFLICTING_OVERLOADS.on(jetProperty, fromCurrent, fromCurrent.getContainingDeclaration().getName().getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -168,7 +169,7 @@ public class OverrideResolver {
|
||||
}
|
||||
|
||||
public static void generateOverridesInFunctionGroup(
|
||||
@NotNull String name,
|
||||
@NotNull Name name,
|
||||
@Nullable Set<CallableMemberDescriptor> fakeOverrides,
|
||||
@NotNull Collection<? extends CallableMemberDescriptor> functionsFromSupertypes,
|
||||
@NotNull Collection<? extends CallableMemberDescriptor> functionsFromCurrent,
|
||||
@@ -221,8 +222,8 @@ public class OverrideResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends DeclarationDescriptor> MultiMap<String, T> groupDescriptorsByName(Collection<T> properties) {
|
||||
MultiMap<String, T> r = new LinkedMultiMap<String, T>();
|
||||
private static <T extends DeclarationDescriptor> MultiMap<Name, T> groupDescriptorsByName(Collection<T> properties) {
|
||||
MultiMap<Name, T> r = new LinkedMultiMap<Name, T>();
|
||||
for (T property : properties) {
|
||||
r.putValue(property.getName(), property);
|
||||
}
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -80,7 +81,7 @@ public class QualifiedExpressionResolver {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
String aliasName = JetPsiUtil.getAliasName(importDirective);
|
||||
Name aliasName = JetPsiUtil.getAliasName(importDirective);
|
||||
if (aliasName == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -220,7 +221,7 @@ public class QualifiedExpressionResolver {
|
||||
private LookupResult lookupSimpleNameReference(@NotNull JetSimpleNameExpression referenceExpression,
|
||||
@NotNull JetScope outerScope, boolean onlyClasses, boolean namespaceLevel) {
|
||||
|
||||
String referencedName = referenceExpression.getReferencedName();
|
||||
Name referencedName = referenceExpression.getReferencedNameAsName();
|
||||
if (referencedName == null) {
|
||||
//to store a scope where we tried to resolve this reference
|
||||
return new SuccessfulLookupResult(Collections.<DeclarationDescriptor>emptyList(), outerScope, namespaceLevel);
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
@@ -210,7 +211,7 @@ public class TopDownAnalyzer {
|
||||
@NotNull final DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetObjectDeclaration object
|
||||
) {
|
||||
ModuleDescriptor moduleDescriptor = new ModuleDescriptor("<dummy for object>");
|
||||
ModuleDescriptor moduleDescriptor = new ModuleDescriptor(Name.special("<dummy for object>"));
|
||||
|
||||
TopDownAnalysisParameters topDownAnalysisParameters =
|
||||
new TopDownAnalysisParameters(Predicates.equalTo(object.getContainingFile()), false, true);
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class TraceBasedRedeclarationHandler implements RedeclarationHandler {
|
||||
private void report(DeclarationDescriptor descriptor) {
|
||||
PsiElement firstElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), descriptor);
|
||||
if (firstElement != null) {
|
||||
trace.report(REDECLARATION.on(firstElement, descriptor.getName()));
|
||||
trace.report(REDECLARATION.on(firstElement, descriptor.getName().getName()));
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("No declaration found found for " + descriptor);
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
@@ -295,7 +296,7 @@ public class TypeHierarchyResolver {
|
||||
private void createClassObjectForEnumClass(JetClass klass, MutableClassDescriptor mutableClassDescriptor) {
|
||||
if (klass.hasModifier(JetTokens.ENUM_KEYWORD)) {
|
||||
MutableClassDescriptor classObjectDescriptor = new MutableClassDescriptor(
|
||||
mutableClassDescriptor, outerScope, ClassKind.OBJECT, "class-object-for-" + klass.getName());
|
||||
mutableClassDescriptor, outerScope, ClassKind.OBJECT, Name.special("<class-object-for-" + klass.getName() + ">"));
|
||||
classObjectDescriptor.setModality(Modality.FINAL);
|
||||
classObjectDescriptor.setVisibility(DescriptorResolver.resolveVisibilityFromModifiers(klass.getModifierList()));
|
||||
classObjectDescriptor.setTypeParameterDescriptors(new ArrayList<TypeParameterDescriptor>(0));
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemSolution;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemWithPriorities;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.DebugConstraintResolutionListener;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
@@ -97,13 +98,13 @@ public class CallResolver {
|
||||
JetExpression calleeExpression = context.call.getCalleeExpression();
|
||||
assert calleeExpression instanceof JetSimpleNameExpression;
|
||||
JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) calleeExpression;
|
||||
String referencedName = nameExpression.getReferencedName();
|
||||
Name referencedName = nameExpression.getReferencedNameAsName();
|
||||
if (referencedName == null) {
|
||||
return OverloadResolutionResultsImpl.nameNotFound();
|
||||
}
|
||||
List<CallableDescriptorCollector<? extends VariableDescriptor>> callableDescriptorCollectors = Lists.newArrayList();
|
||||
if (nameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
|
||||
referencedName = referencedName.substring(1);
|
||||
referencedName = Name.identifier(referencedName.getName().substring(1));
|
||||
callableDescriptorCollectors.add(CallableDescriptorCollectors.PROPERTIES);
|
||||
}
|
||||
else {
|
||||
@@ -117,7 +118,7 @@ public class CallResolver {
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithGivenName(
|
||||
@NotNull BasicResolutionContext context,
|
||||
@NotNull final JetReferenceExpression functionReference,
|
||||
@NotNull String name) {
|
||||
@NotNull Name name) {
|
||||
List<ResolutionTask<CallableDescriptor, FunctionDescriptor>> tasks = TaskPrioritizer.computePrioritizedTasks(context, name, functionReference, CallableDescriptorCollectors.FUNCTIONS_AND_VARIABLES);
|
||||
return doResolveCall(context, tasks, CallTransformer.FUNCTION_CALL_TRANSFORMER, functionReference);
|
||||
}
|
||||
@@ -137,7 +138,7 @@ public class CallResolver {
|
||||
JetSimpleNameExpression expression = (JetSimpleNameExpression) calleeExpression;
|
||||
functionReference = expression;
|
||||
|
||||
String name = expression.getReferencedName();
|
||||
Name name = expression.getReferencedNameAsName();
|
||||
if (name == null) return checkArgumentTypesAndFail(context);
|
||||
|
||||
prioritizedTasks = TaskPrioritizer.computePrioritizedTasks(context, name, functionReference, CallableDescriptorCollectors.FUNCTIONS_AND_VARIABLES);
|
||||
@@ -222,7 +223,7 @@ public class CallResolver {
|
||||
return checkArgumentTypesAndFail(context);
|
||||
}
|
||||
|
||||
FunctionDescriptorImpl functionDescriptor = new ExpressionAsFunctionDescriptor(context.scope.getContainingDeclaration(), "[for expression " + calleeExpression.getText() + "]");
|
||||
FunctionDescriptorImpl functionDescriptor = new ExpressionAsFunctionDescriptor(context.scope.getContainingDeclaration(), Name.special("<for expression " + calleeExpression.getText() + ">"));
|
||||
FunctionDescriptorUtil.initializeFromFunctionType(functionDescriptor, calleeType, NO_RECEIVER, Modality.FINAL, Visibilities.LOCAL);
|
||||
ResolutionCandidate<CallableDescriptor> resolutionCandidate = ResolutionCandidate.<CallableDescriptor>create(functionDescriptor, JetPsiUtil.isSafeCall(context.call));
|
||||
resolutionCandidate.setReceiverArgument(context.call.getExplicitReceiver());
|
||||
@@ -888,7 +889,7 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull JetScope scope, @NotNull ReceiverDescriptor receiver, @NotNull String name, @NotNull List<JetType> parameterTypes) {
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull JetScope scope, @NotNull ReceiverDescriptor receiver, @NotNull Name name, @NotNull List<JetType> parameterTypes) {
|
||||
List<ResolutionCandidate<FunctionDescriptor>> candidates = findCandidatesByExactSignature(scope, receiver, name, parameterTypes);
|
||||
|
||||
BindingTraceContext trace = new BindingTraceContext();
|
||||
@@ -902,7 +903,7 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
private List<ResolutionCandidate<FunctionDescriptor>> findCandidatesByExactSignature(JetScope scope, ReceiverDescriptor receiver,
|
||||
String name, List<JetType> parameterTypes) {
|
||||
Name name, List<JetType> parameterTypes) {
|
||||
List<ResolutionCandidate<FunctionDescriptor>> result = Lists.newArrayList();
|
||||
if (receiver.exists()) {
|
||||
Collection<ResolutionCandidate<FunctionDescriptor>> extensionFunctionDescriptors = ResolutionCandidate.convertCollection(scope.getFunctions(name), false);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -185,7 +186,7 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
|
||||
BasicResolutionContext basicResolutionContext = BasicResolutionContext.create(variableCallTrace, context.scope, functionCall, context.expectedType, context.dataFlowInfo);
|
||||
|
||||
// 'invoke' call resolve
|
||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenName(basicResolutionContext, task.reference, "invoke");
|
||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenName(basicResolutionContext, task.reference, Name.identifier("invoke"));
|
||||
Collection<ResolvedCallWithTrace<FunctionDescriptor>> calls = ((OverloadResolutionResultsImpl<FunctionDescriptor>)results).getResultingCalls();
|
||||
|
||||
return Collections2.transform(calls, new Function<ResolvedCallWithTrace<FunctionDescriptor>, ResolvedCallWithTrace<FunctionDescriptor>>() {
|
||||
|
||||
+4
-3
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.calls;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
@@ -28,11 +29,11 @@ import java.util.Collection;
|
||||
*/
|
||||
public interface CallableDescriptorCollector<D extends CallableDescriptor> {
|
||||
@NotNull
|
||||
Collection<D> getNonExtensionsByName(JetScope scope, String name);
|
||||
Collection<D> getNonExtensionsByName(JetScope scope, Name name);
|
||||
|
||||
@NotNull
|
||||
Collection<D> getMembersByName(@NotNull JetType receiver, String name);
|
||||
Collection<D> getMembersByName(@NotNull JetType receiver, Name name);
|
||||
|
||||
@NotNull
|
||||
Collection<D> getNonMembersByName(JetScope scope, String name);
|
||||
Collection<D> getNonMembersByName(JetScope scope, Name name);
|
||||
}
|
||||
|
||||
+11
-10
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -39,7 +40,7 @@ public class CallableDescriptorCollectors {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getNonExtensionsByName(JetScope scope, String name) {
|
||||
public Collection<FunctionDescriptor> getNonExtensionsByName(JetScope scope, Name name) {
|
||||
Set<FunctionDescriptor> functions = Sets.newLinkedHashSet(scope.getFunctions(name));
|
||||
for (Iterator<FunctionDescriptor> iterator = functions.iterator(); iterator.hasNext(); ) {
|
||||
FunctionDescriptor functionDescriptor = iterator.next();
|
||||
@@ -53,7 +54,7 @@ public class CallableDescriptorCollectors {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getMembersByName(@NotNull JetType receiverType, String name) {
|
||||
public Collection<FunctionDescriptor> getMembersByName(@NotNull JetType receiverType, Name name) {
|
||||
JetScope receiverScope = receiverType.getMemberScope();
|
||||
Set<FunctionDescriptor> members = Sets.newHashSet(receiverScope.getFunctions(name));
|
||||
addConstructors(receiverScope, name, members);
|
||||
@@ -62,11 +63,11 @@ public class CallableDescriptorCollectors {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getNonMembersByName(JetScope scope, String name) {
|
||||
public Collection<FunctionDescriptor> getNonMembersByName(JetScope scope, Name name) {
|
||||
return scope.getFunctions(name);
|
||||
}
|
||||
|
||||
private void addConstructors(JetScope scope, String name, Collection<FunctionDescriptor> functions) {
|
||||
private void addConstructors(JetScope scope, Name name, Collection<FunctionDescriptor> functions) {
|
||||
ClassifierDescriptor classifier = scope.getClassifier(name);
|
||||
if (classifier instanceof ClassDescriptor && !ErrorUtils.isError(classifier.getTypeConstructor())) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) classifier;
|
||||
@@ -79,7 +80,7 @@ public class CallableDescriptorCollectors {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getNonExtensionsByName(JetScope scope, String name) {
|
||||
public Collection<VariableDescriptor> getNonExtensionsByName(JetScope scope, Name name) {
|
||||
VariableDescriptor descriptor = scope.getLocalVariable(name);
|
||||
if (descriptor == null) {
|
||||
descriptor = DescriptorUtils.filterNonExtensionProperty(scope.getProperties(name));
|
||||
@@ -90,13 +91,13 @@ public class CallableDescriptorCollectors {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getMembersByName(@NotNull JetType receiverType, String name) {
|
||||
public Collection<VariableDescriptor> getMembersByName(@NotNull JetType receiverType, Name name) {
|
||||
return receiverType.getMemberScope().getProperties(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getNonMembersByName(JetScope scope, String name) {
|
||||
public Collection<VariableDescriptor> getNonMembersByName(JetScope scope, Name name) {
|
||||
Collection<VariableDescriptor> result = Sets.newLinkedHashSet();
|
||||
|
||||
VariableDescriptor localVariable = scope.getLocalVariable(name);
|
||||
@@ -121,19 +122,19 @@ public class CallableDescriptorCollectors {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getNonExtensionsByName(JetScope scope, String name) {
|
||||
public Collection<VariableDescriptor> getNonExtensionsByName(JetScope scope, Name name) {
|
||||
return filterProperties(VARIABLES.getNonExtensionsByName(scope, name));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getMembersByName(@NotNull JetType receiver, String name) {
|
||||
public Collection<VariableDescriptor> getMembersByName(@NotNull JetType receiver, Name name) {
|
||||
return filterProperties(VARIABLES.getMembersByName(receiver, name));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getNonMembersByName(JetScope scope, String name) {
|
||||
public Collection<VariableDescriptor> getNonMembersByName(JetScope scope, Name name) {
|
||||
return filterProperties(VARIABLES.getNonMembersByName(scope, name));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -28,7 +29,7 @@ import java.util.Collections;
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class ExpressionAsFunctionDescriptor extends FunctionDescriptorImpl {
|
||||
public ExpressionAsFunctionDescriptor(DeclarationDescriptor containingDeclaration, String name) {
|
||||
public ExpressionAsFunctionDescriptor(DeclarationDescriptor containingDeclaration, Name name) {
|
||||
super(containingDeclaration, Collections.<AnnotationDescriptor>emptyList(), name, Kind.DECLARATION);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.SolutionStatus;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
@@ -205,13 +206,13 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends R
|
||||
JetBinaryExpression binaryExpression = (JetBinaryExpression)callElement;
|
||||
JetSimpleNameExpression operationReference = binaryExpression.getOperationReference();
|
||||
|
||||
String operationString = operationReference.getReferencedNameElementType() == JetTokens.IDENTIFIER ?
|
||||
operationReference.getText() :
|
||||
Name operationString = operationReference.getReferencedNameElementType() == JetTokens.IDENTIFIER ?
|
||||
Name.identifier(operationReference.getText()) :
|
||||
OperatorConventions.getNameForOperationSymbol((JetToken)operationReference.getReferencedNameElementType());
|
||||
|
||||
JetExpression right = binaryExpression.getRight();
|
||||
if (right != null) {
|
||||
trace.report(UNSAFE_INFIX_CALL.on(reference, binaryExpression.getLeft().getText(), operationString, right.getText()));
|
||||
trace.report(UNSAFE_INFIX_CALL.on(reference, binaryExpression.getLeft().getText(), operationString.getName(), right.getText()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetSuperExpression;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastServiceImpl;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
@@ -74,7 +75,7 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <D extends CallableDescriptor, F extends D> List<ResolutionTask<D, F>> computePrioritizedTasks(@NotNull BasicResolutionContext context, @NotNull String name,
|
||||
public static <D extends CallableDescriptor, F extends D> List<ResolutionTask<D, F>> computePrioritizedTasks(@NotNull BasicResolutionContext context, @NotNull Name name,
|
||||
@NotNull JetReferenceExpression functionReference, @NotNull List<CallableDescriptorCollector<? extends D>> callableDescriptorCollectors) {
|
||||
ReceiverDescriptor explicitReceiver = context.call.getExplicitReceiver();
|
||||
final JetScope scope;
|
||||
@@ -104,7 +105,7 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
}
|
||||
|
||||
private static <D extends CallableDescriptor, F extends D> void doComputeTasks(@NotNull JetScope scope, @NotNull ReceiverDescriptor receiver,
|
||||
@NotNull String name, @NotNull ResolutionTaskHolder<D, F> result,
|
||||
@NotNull Name name, @NotNull ResolutionTaskHolder<D, F> result,
|
||||
@NotNull BasicResolutionContext context, @NotNull CallableDescriptorCollector<? extends D> callableDescriptorCollector) {
|
||||
AutoCastServiceImpl autoCastService = new AutoCastServiceImpl(context.dataFlowInfo, context.trace.getBindingContext());
|
||||
List<ReceiverDescriptor> implicitReceivers = Lists.newArrayList();
|
||||
|
||||
+3
-2
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
@@ -82,7 +83,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
|
||||
List<ValueParameterDescriptor> valueParameters = candidate.getValueParameters();
|
||||
|
||||
Map<String, ValueParameterDescriptor> parameterByName = Maps.newHashMap();
|
||||
Map<Name, ValueParameterDescriptor> parameterByName = Maps.newHashMap();
|
||||
for (ValueParameterDescriptor valueParameter : valueParameters) {
|
||||
parameterByName.put(valueParameter.getName(), valueParameter);
|
||||
}
|
||||
@@ -97,7 +98,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
if (valueArgument.isNamed()) {
|
||||
someNamed = true;
|
||||
JetSimpleNameExpression nameReference = valueArgument.getArgumentName().getReferenceExpression();
|
||||
ValueParameterDescriptor valueParameterDescriptor = parameterByName.get(nameReference.getReferencedName());
|
||||
ValueParameterDescriptor valueParameterDescriptor = parameterByName.get(nameReference.getReferencedNameAsName());
|
||||
if (valueParameterDescriptor == null) {
|
||||
temporaryTrace.report(NAMED_PARAMETER_NOT_FOUND.on(nameReference));
|
||||
unmappedArguments.add(valueArgument);
|
||||
|
||||
@@ -101,12 +101,12 @@ public class FqName {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FqName child(@NotNull String name) {
|
||||
public FqName child(@NotNull Name name) {
|
||||
return new FqName(fqName.child(name), this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String shortName() {
|
||||
public Name shortName() {
|
||||
return fqName.shortName();
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class FqName {
|
||||
path.add(ROOT);
|
||||
fqName.walk(new FqNameUnsafe.WalkCallback() {
|
||||
@Override
|
||||
public void segment(@NotNull String shortName, @NotNull FqNameUnsafe fqName) {
|
||||
public void segment(@NotNull Name shortName, @NotNull FqNameUnsafe fqName) {
|
||||
// TODO: do not validate
|
||||
path.add(new FqName(fqName));
|
||||
}
|
||||
@@ -125,22 +125,22 @@ public class FqName {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> pathSegments() {
|
||||
public List<Name> pathSegments() {
|
||||
return fqName.pathSegments();
|
||||
}
|
||||
|
||||
public boolean firstSegmentIs(@NotNull String segment) {
|
||||
public boolean firstSegmentIs(@NotNull Name segment) {
|
||||
return fqName.firstSegmentIs(segment);
|
||||
}
|
||||
|
||||
public boolean lastSegmentIs(@NotNull String segment) {
|
||||
public boolean lastSegmentIs(@NotNull Name segment) {
|
||||
return fqName.lastSegmentIs(segment);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@NotNull
|
||||
public static FqName topLevel(@NotNull String shortName) {
|
||||
public static FqName topLevel(@NotNull Name shortName) {
|
||||
return new FqName(FqNameUnsafe.topLevel(shortName));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.List;
|
||||
*/
|
||||
public class FqNameUnsafe {
|
||||
|
||||
public static final String ROOT_NAME = "<root>";
|
||||
public static final Name ROOT_NAME = Name.special("<root>");
|
||||
|
||||
@NotNull
|
||||
private final String fqName;
|
||||
@@ -37,7 +37,7 @@ public class FqNameUnsafe {
|
||||
// cache
|
||||
private transient FqName safe;
|
||||
private transient FqNameUnsafe parent;
|
||||
private transient String shortName;
|
||||
private transient Name shortName;
|
||||
|
||||
FqNameUnsafe(@NotNull String fqName, @NotNull FqName safe) {
|
||||
this.fqName = fqName;
|
||||
@@ -52,7 +52,7 @@ public class FqNameUnsafe {
|
||||
validateFqName();
|
||||
}
|
||||
|
||||
private FqNameUnsafe(@NotNull String fqName, FqNameUnsafe parent, String shortName) {
|
||||
private FqNameUnsafe(@NotNull String fqName, FqNameUnsafe parent, Name shortName) {
|
||||
this.fqName = fqName;
|
||||
this.parent = parent;
|
||||
this.shortName = shortName;
|
||||
@@ -75,11 +75,11 @@ public class FqNameUnsafe {
|
||||
private void compute() {
|
||||
int lastDot = fqName.lastIndexOf('.');
|
||||
if (lastDot >= 0) {
|
||||
shortName = fqName.substring(lastDot + 1);
|
||||
shortName = Name.guess(fqName.substring(lastDot + 1));
|
||||
parent = new FqNameUnsafe(fqName.substring(0, lastDot));
|
||||
}
|
||||
else {
|
||||
shortName = fqName;
|
||||
shortName = Name.guess(fqName);
|
||||
parent = FqName.ROOT.toUnsafe();
|
||||
}
|
||||
}
|
||||
@@ -120,19 +120,19 @@ public class FqNameUnsafe {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FqNameUnsafe child(@NotNull String name) {
|
||||
public FqNameUnsafe child(@NotNull Name name) {
|
||||
String childFqName;
|
||||
if (isRoot()) {
|
||||
childFqName = name;
|
||||
childFqName = name.getName();
|
||||
}
|
||||
else {
|
||||
childFqName = fqName + "." + name;
|
||||
childFqName = fqName + "." + name.getName();
|
||||
}
|
||||
return new FqNameUnsafe(childFqName, this, name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String shortName() {
|
||||
public Name shortName() {
|
||||
if (shortName != null) {
|
||||
return shortName;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public class FqNameUnsafe {
|
||||
}
|
||||
|
||||
interface WalkCallback {
|
||||
void segment(@NotNull String shortName, @NotNull FqNameUnsafe fqName);
|
||||
void segment(@NotNull Name shortName, @NotNull FqNameUnsafe fqName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -156,7 +156,7 @@ public class FqNameUnsafe {
|
||||
path.add(FqName.ROOT.toUnsafe());
|
||||
walk(new WalkCallback() {
|
||||
@Override
|
||||
public void segment(@NotNull String shortName, @NotNull FqNameUnsafe fqName) {
|
||||
public void segment(@NotNull Name shortName, @NotNull FqNameUnsafe fqName) {
|
||||
path.add(fqName);
|
||||
}
|
||||
});
|
||||
@@ -164,11 +164,11 @@ public class FqNameUnsafe {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> pathSegments() {
|
||||
final List<String> path = Lists.newArrayList();
|
||||
public List<Name> pathSegments() {
|
||||
final List<Name> path = Lists.newArrayList();
|
||||
walk(new WalkCallback() {
|
||||
@Override
|
||||
public void segment(@NotNull String shortName, @NotNull FqNameUnsafe fqName) {
|
||||
public void segment(@NotNull Name shortName, @NotNull FqNameUnsafe fqName) {
|
||||
path.add(shortName);
|
||||
}
|
||||
});
|
||||
@@ -188,14 +188,14 @@ public class FqNameUnsafe {
|
||||
this.parent = FqName.ROOT.toUnsafe();
|
||||
}
|
||||
if (this.shortName == null) {
|
||||
this.shortName = fqName;
|
||||
this.shortName = Name.guess(fqName);
|
||||
}
|
||||
callback.segment(fqName, this);
|
||||
callback.segment(shortName, this);
|
||||
return;
|
||||
}
|
||||
|
||||
String firstSegment = fqName.substring(0, pos);
|
||||
FqNameUnsafe last = new FqNameUnsafe(firstSegment, FqName.ROOT.toUnsafe(), firstSegment);
|
||||
Name firstSegment = Name.guess(fqName.substring(0, pos));
|
||||
FqNameUnsafe last = new FqNameUnsafe(firstSegment.getName(), FqName.ROOT.toUnsafe(), firstSegment);
|
||||
callback.segment(firstSegment, last);
|
||||
|
||||
while (true) {
|
||||
@@ -204,7 +204,7 @@ public class FqNameUnsafe {
|
||||
if (this.parent == null) {
|
||||
this.parent = last;
|
||||
}
|
||||
String shortName = fqName.substring(pos + 1);
|
||||
Name shortName = Name.guess(fqName.substring(pos + 1));
|
||||
if (this.shortName == null) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class FqNameUnsafe {
|
||||
return;
|
||||
}
|
||||
|
||||
String shortName = fqName.substring(pos + 1, next);
|
||||
Name shortName = Name.guess(fqName.substring(pos + 1, next));
|
||||
last = new FqNameUnsafe(fqName.substring(0, next), last, shortName);
|
||||
callback.segment(shortName, last);
|
||||
|
||||
@@ -220,15 +220,15 @@ public class FqNameUnsafe {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean firstSegmentIs(@NotNull String segment) {
|
||||
public boolean firstSegmentIs(@NotNull Name segment) {
|
||||
if (isRoot()) {
|
||||
return false;
|
||||
}
|
||||
List<String> pathSegments = pathSegments();
|
||||
List<Name> pathSegments = pathSegments();
|
||||
return pathSegments.get(0).equals(segment);
|
||||
}
|
||||
|
||||
public boolean lastSegmentIs(@NotNull String segment) {
|
||||
public boolean lastSegmentIs(@NotNull Name segment) {
|
||||
if (isRoot()) {
|
||||
return false;
|
||||
}
|
||||
@@ -238,17 +238,14 @@ public class FqNameUnsafe {
|
||||
|
||||
|
||||
@NotNull
|
||||
public static FqNameUnsafe topLevel(@NotNull String shortName) {
|
||||
if (shortName.indexOf('.') >= 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return new FqNameUnsafe(shortName, FqName.ROOT.toUnsafe(), shortName);
|
||||
public static FqNameUnsafe topLevel(@NotNull Name shortName) {
|
||||
return new FqNameUnsafe(shortName.getName(), FqName.ROOT.toUnsafe(), shortName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return isRoot() ? ROOT_NAME : fqName;
|
||||
return isRoot() ? ROOT_NAME.getName() : fqName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.name;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class Name implements Comparable<Name> {
|
||||
@NotNull
|
||||
private final String name;
|
||||
private final boolean special;
|
||||
|
||||
private Name(String name, boolean special) {
|
||||
this.name = name;
|
||||
this.special = special;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getIdentifier() {
|
||||
if (special) {
|
||||
throw new IllegalStateException("not identifier: " + this);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isSpecial() {
|
||||
return special;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Name that) {
|
||||
return this.name.compareTo(that.name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Name identifier(@NotNull String name) {
|
||||
NameUtils.requireIdentifier(name);
|
||||
return new Name(name, false);
|
||||
}
|
||||
|
||||
/** Must be validated by caller */
|
||||
@NotNull
|
||||
public static Name identifierNoValidate(@NotNull String name) {
|
||||
return new Name(name, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Name special(@NotNull String name) {
|
||||
if (!name.startsWith("<")) {
|
||||
throw new IllegalArgumentException("special name must start with '<': " + name);
|
||||
}
|
||||
return new Name(name, true);
|
||||
}
|
||||
|
||||
// TODO: wrong
|
||||
@NotNull
|
||||
public static Name guess(@NotNull String name) {
|
||||
if (name.startsWith("<")) {
|
||||
return special(name);
|
||||
}
|
||||
else {
|
||||
return identifier(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Name name1 = (Name) o;
|
||||
|
||||
if (special != name1.special) return false;
|
||||
if (!name.equals(name1.name)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name.hashCode();
|
||||
result = 31 * result + (special ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class NameUtils {
|
||||
|
||||
public static boolean isValidIdentified(@NotNull String name) {
|
||||
return name.length() > 0 && !name.startsWith("<");
|
||||
return name.length() > 0 && !name.startsWith("<") && !name.contains(".");
|
||||
}
|
||||
|
||||
public static void requireIdentifier(@NotNull String name) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -41,7 +42,7 @@ public class ChainedScope implements JetScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
for (JetScope scope : scopeChain) {
|
||||
ClassifierDescriptor classifier = scope.getClassifier(name);
|
||||
if (classifier != null) return classifier;
|
||||
@@ -50,7 +51,7 @@ public class ChainedScope implements JetScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
for (JetScope scope : scopeChain) {
|
||||
ClassDescriptor objectDescriptor = scope.getObjectDescriptor(name);
|
||||
if (objectDescriptor != null) return objectDescriptor;
|
||||
@@ -69,7 +70,7 @@ public class ChainedScope implements JetScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
for (JetScope jetScope : scopeChain) {
|
||||
NamespaceDescriptor namespace = jetScope.getNamespace(name);
|
||||
if (namespace != null) {
|
||||
@@ -81,7 +82,7 @@ public class ChainedScope implements JetScope {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
Set<VariableDescriptor> properties = Sets.newLinkedHashSet();
|
||||
for (JetScope jetScope : scopeChain) {
|
||||
properties.addAll(jetScope.getProperties(name));
|
||||
@@ -90,7 +91,7 @@ public class ChainedScope implements JetScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableDescriptor getLocalVariable(@NotNull String name) {
|
||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||
for (JetScope jetScope : scopeChain) {
|
||||
VariableDescriptor variable = jetScope.getLocalVariable(name);
|
||||
if (variable != null) {
|
||||
@@ -102,7 +103,7 @@ public class ChainedScope implements JetScope {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
if (scopeChain.length == 0) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
@@ -144,7 +145,7 @@ public class ChainedScope implements JetScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
|
||||
for (JetScope jetScope : scopeChain) {
|
||||
PropertyDescriptor propertyByFieldReference = jetScope.getPropertyByFieldReference(fieldName);
|
||||
if (propertyByFieldReference != null) {
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.descriptors.ClassKind;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -45,7 +46,7 @@ public class InnerClassesScopeWrapper extends JetScopeImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
ClassifierDescriptor classifier = actualScope.getClassifier(name);
|
||||
if (isClass(classifier)) return classifier;
|
||||
return null;
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -44,38 +45,38 @@ public interface JetScope {
|
||||
};
|
||||
|
||||
@Nullable
|
||||
ClassifierDescriptor getClassifier(@NotNull String name);
|
||||
ClassifierDescriptor getClassifier(@NotNull Name name);
|
||||
|
||||
@Nullable
|
||||
ClassDescriptor getObjectDescriptor(@NotNull String name);
|
||||
ClassDescriptor getObjectDescriptor(@NotNull Name name);
|
||||
|
||||
@NotNull
|
||||
Set<ClassDescriptor> getObjectDescriptors();
|
||||
|
||||
@Nullable
|
||||
NamespaceDescriptor getNamespace(@NotNull String name);
|
||||
NamespaceDescriptor getNamespace(@NotNull Name name);
|
||||
|
||||
@NotNull
|
||||
Set<VariableDescriptor> getProperties(@NotNull String name);
|
||||
Set<VariableDescriptor> getProperties(@NotNull Name name);
|
||||
|
||||
@Nullable
|
||||
VariableDescriptor getLocalVariable(@NotNull String name);
|
||||
VariableDescriptor getLocalVariable(@NotNull Name name);
|
||||
|
||||
@NotNull
|
||||
Set<FunctionDescriptor> getFunctions(@NotNull String name);
|
||||
Set<FunctionDescriptor> getFunctions(@NotNull Name name);
|
||||
|
||||
@NotNull
|
||||
DeclarationDescriptor getContainingDeclaration();
|
||||
|
||||
@NotNull
|
||||
Collection<DeclarationDescriptor> getDeclarationsByLabel(LabelName labelName);
|
||||
Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull LabelName labelName);
|
||||
|
||||
/**
|
||||
* @param fieldName includes the "$"
|
||||
* @return the property declaring this field, if any
|
||||
*/
|
||||
@Nullable
|
||||
PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName);
|
||||
PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName);
|
||||
|
||||
/**
|
||||
* All visible descriptors from current scope.
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve.scopes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -31,12 +32,12 @@ import java.util.Set;
|
||||
*/
|
||||
public abstract class JetScopeImpl implements JetScope {
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -48,17 +49,17 @@ public abstract class JetScopeImpl implements JetScope {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableDescriptor getLocalVariable(@NotNull String name) {
|
||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ public abstract class JetScopeImpl implements JetScope {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ public abstract class JetScopeImpl implements JetScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
@@ -82,22 +83,22 @@ public class SubstitutingScope implements JetScope {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
return substitute(workerScope.getProperties(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableDescriptor getLocalVariable(@NotNull String name) {
|
||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||
return substitute(workerScope.getLocalVariable(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
return substitute(workerScope.getClassifier(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return substitute(workerScope.getObjectDescriptor(name));
|
||||
}
|
||||
|
||||
@@ -109,12 +110,12 @@ public class SubstitutingScope implements JetScope {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
return substitute(workerScope.getFunctions(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
return workerScope.getNamespace(name); // TODO
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ public class SubstitutingScope implements JetScope {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.collect.Multimap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
/**
|
||||
@@ -48,33 +49,32 @@ public interface WritableScope extends JetScope {
|
||||
|
||||
void addObjectDescriptor(@NotNull ClassDescriptor objectDescriptor);
|
||||
|
||||
void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor);
|
||||
void addClassifierAlias(@NotNull Name name, @NotNull ClassifierDescriptor classifierDescriptor);
|
||||
|
||||
void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor);
|
||||
void addNamespaceAlias(@NotNull Name name, @NotNull NamespaceDescriptor namespaceDescriptor);
|
||||
|
||||
void addFunctionAlias(@NotNull String name, @NotNull FunctionDescriptor functionDescriptor);
|
||||
void addFunctionAlias(@NotNull Name name, @NotNull FunctionDescriptor functionDescriptor);
|
||||
|
||||
void addVariableAlias(@NotNull String name, @NotNull VariableDescriptor variableDescriptor);
|
||||
void addVariableAlias(@NotNull Name name, @NotNull VariableDescriptor variableDescriptor);
|
||||
|
||||
void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor);
|
||||
|
||||
@Nullable
|
||||
NamespaceDescriptor getDeclaredNamespace(@NotNull String name);
|
||||
NamespaceDescriptor getDeclaredNamespace(@NotNull Name name);
|
||||
|
||||
@NotNull
|
||||
Multimap<String, DeclarationDescriptor> getDeclaredDescriptorsAccessibleBySimpleName();
|
||||
@NotNull Multimap<Name, DeclarationDescriptor> getDeclaredDescriptorsAccessibleBySimpleName();
|
||||
|
||||
void importScope(@NotNull JetScope imported);
|
||||
|
||||
void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver);
|
||||
|
||||
void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor);
|
||||
void importClassifierAlias(@NotNull Name importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor);
|
||||
|
||||
void importNamespaceAlias(@NotNull String aliasName, @NotNull NamespaceDescriptor namespaceDescriptor);
|
||||
void importNamespaceAlias(@NotNull Name aliasName, @NotNull NamespaceDescriptor namespaceDescriptor);
|
||||
|
||||
void importFunctionAlias(@NotNull String aliasName, @NotNull FunctionDescriptor functionDescriptor);
|
||||
void importFunctionAlias(@NotNull Name aliasName, @NotNull FunctionDescriptor functionDescriptor);
|
||||
|
||||
void importVariableAlias(@NotNull String aliasName, @NotNull VariableDescriptor variableDescriptor);
|
||||
void importVariableAlias(@NotNull Name aliasName, @NotNull VariableDescriptor variableDescriptor);
|
||||
|
||||
void clearImports();
|
||||
}
|
||||
|
||||
+42
-41
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.util.CommonSuppliers;
|
||||
@@ -34,7 +35,7 @@ import java.util.*;
|
||||
public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
|
||||
private final Collection<DeclarationDescriptor> allDescriptors = Sets.newLinkedHashSet();
|
||||
private final Multimap<String, DeclarationDescriptor> declaredDescriptorsAccessibleBySimpleName = HashMultimap.create();
|
||||
private final Multimap<Name, DeclarationDescriptor> declaredDescriptorsAccessibleBySimpleName = HashMultimap.create();
|
||||
private boolean allDescriptorsDone = false;
|
||||
|
||||
@NotNull
|
||||
@@ -42,25 +43,25 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
|
||||
// FieldNames include "$"
|
||||
@Nullable
|
||||
private Map<String, PropertyDescriptor> propertyDescriptorsByFieldNames;
|
||||
private Map<Name, PropertyDescriptor> propertyDescriptorsByFieldNames;
|
||||
|
||||
@Nullable
|
||||
private SetMultimap<String, FunctionDescriptor> functionGroups;
|
||||
private SetMultimap<Name, FunctionDescriptor> functionGroups;
|
||||
|
||||
@Nullable
|
||||
private Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors;
|
||||
private Map<Name, DeclarationDescriptor> variableClassOrNamespaceDescriptors;
|
||||
|
||||
@Nullable
|
||||
private SetMultimap<String, VariableDescriptor> propertyGroups;
|
||||
private SetMultimap<Name, VariableDescriptor> propertyGroups;
|
||||
|
||||
@Nullable
|
||||
private Map<String, NamespaceDescriptor> namespaceAliases;
|
||||
private Map<Name, NamespaceDescriptor> namespaceAliases;
|
||||
|
||||
@Nullable
|
||||
private Map<LabelName, List<DeclarationDescriptor>> labelsToDescriptors;
|
||||
|
||||
@Nullable
|
||||
private Map<String, ClassDescriptor> objectDescriptors;
|
||||
private Map<Name, ClassDescriptor> objectDescriptors;
|
||||
|
||||
@Nullable
|
||||
private ReceiverDescriptor implicitReceiver;
|
||||
@@ -83,7 +84,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
public void importClassifierAlias(@NotNull Name importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
allDescriptors.add(classifierDescriptor);
|
||||
@@ -91,7 +92,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importNamespaceAlias(@NotNull String aliasName, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
public void importNamespaceAlias(@NotNull Name aliasName, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
allDescriptors.add(namespaceDescriptor);
|
||||
@@ -99,7 +100,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importFunctionAlias(@NotNull String aliasName, @NotNull FunctionDescriptor functionDescriptor) {
|
||||
public void importFunctionAlias(@NotNull Name aliasName, @NotNull FunctionDescriptor functionDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
addFunctionDescriptor(functionDescriptor);
|
||||
@@ -108,7 +109,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importVariableAlias(@NotNull String aliasName, @NotNull VariableDescriptor variableDescriptor) {
|
||||
public void importVariableAlias(@NotNull Name aliasName, @NotNull VariableDescriptor variableDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
addPropertyDescriptor(variableDescriptor);
|
||||
@@ -146,7 +147,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<String, ClassDescriptor> getObjectDescriptorsMap() {
|
||||
private Map<Name, ClassDescriptor> getObjectDescriptorsMap() {
|
||||
if (objectDescriptors == null) {
|
||||
objectDescriptors = Maps.newHashMap();
|
||||
}
|
||||
@@ -175,7 +176,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
checkMayWrite();
|
||||
|
||||
Map<LabelName, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors();
|
||||
LabelName name = new LabelName(descriptor.getName());
|
||||
LabelName name = new LabelName(descriptor.getName().getName());
|
||||
List<DeclarationDescriptor> declarationDescriptors = labelsToDescriptors.get(name);
|
||||
if (declarationDescriptors == null) {
|
||||
declarationDescriptors = new ArrayList<DeclarationDescriptor>();
|
||||
@@ -185,7 +186,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<String, DeclarationDescriptor> getVariableClassOrNamespaceDescriptors() {
|
||||
private Map<Name, DeclarationDescriptor> getVariableClassOrNamespaceDescriptors() {
|
||||
if (variableClassOrNamespaceDescriptors == null) {
|
||||
variableClassOrNamespaceDescriptors = Maps.newHashMap();
|
||||
}
|
||||
@@ -193,7 +194,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<String, NamespaceDescriptor> getNamespaceAliases() {
|
||||
private Map<Name, NamespaceDescriptor> getNamespaceAliases() {
|
||||
if (namespaceAliases == null) {
|
||||
namespaceAliases = Maps.newHashMap();
|
||||
}
|
||||
@@ -213,7 +214,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
private void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor, boolean isProperty) {
|
||||
checkMayWrite();
|
||||
|
||||
String name = variableDescriptor.getName();
|
||||
Name name = variableDescriptor.getName();
|
||||
if (isProperty) {
|
||||
checkForPropertyRedeclaration(name, variableDescriptor);
|
||||
getPropertyGroups().put(name, variableDescriptor);
|
||||
@@ -229,7 +230,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
Set<VariableDescriptor> result = Sets.newLinkedHashSet(getPropertyGroups().get(name));
|
||||
@@ -242,10 +243,10 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableDescriptor getLocalVariable(@NotNull String name) {
|
||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||
Map<Name, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||
DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name);
|
||||
if (descriptor instanceof VariableDescriptor && !getPropertyGroups().get(name).contains(descriptor)) {
|
||||
return (VariableDescriptor) descriptor;
|
||||
@@ -259,7 +260,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SetMultimap<String, VariableDescriptor> getPropertyGroups() {
|
||||
private SetMultimap<Name, VariableDescriptor> getPropertyGroups() {
|
||||
if (propertyGroups == null) {
|
||||
propertyGroups = CommonSuppliers.newLinkedHashSetHashSetMultimap();
|
||||
}
|
||||
@@ -267,7 +268,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SetMultimap<String, FunctionDescriptor> getFunctionGroups() {
|
||||
private SetMultimap<Name, FunctionDescriptor> getFunctionGroups() {
|
||||
if (functionGroups == null) {
|
||||
functionGroups = CommonSuppliers.newLinkedHashSetHashSetMultimap();
|
||||
}
|
||||
@@ -284,7 +285,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
Set<FunctionDescriptor> result = Sets.newLinkedHashSet(getFunctionGroups().get(name));
|
||||
@@ -300,7 +301,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
String name = typeParameterDescriptor.getName();
|
||||
Name name = typeParameterDescriptor.getName();
|
||||
addClassifierAlias(name, typeParameterDescriptor);
|
||||
}
|
||||
|
||||
@@ -327,7 +328,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
public void addClassifierAlias(@NotNull Name name, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
checkForRedeclaration(name, classifierDescriptor);
|
||||
@@ -337,7 +338,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
public void addNamespaceAlias(@NotNull Name name, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
checkForRedeclaration(name, namespaceDescriptor);
|
||||
@@ -347,7 +348,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionAlias(@NotNull String name, @NotNull FunctionDescriptor functionDescriptor) {
|
||||
public void addFunctionAlias(@NotNull Name name, @NotNull FunctionDescriptor functionDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
checkForRedeclaration(name, functionDescriptor);
|
||||
@@ -356,7 +357,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariableAlias(@NotNull String name, @NotNull VariableDescriptor variableDescriptor) {
|
||||
public void addVariableAlias(@NotNull Name name, @NotNull VariableDescriptor variableDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
checkForRedeclaration(name, variableDescriptor);
|
||||
@@ -365,7 +366,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
addToDeclared(variableDescriptor);
|
||||
}
|
||||
|
||||
private void checkForPropertyRedeclaration(String name, VariableDescriptor variableDescriptor) {
|
||||
private void checkForPropertyRedeclaration(@NotNull Name name, VariableDescriptor variableDescriptor) {
|
||||
Set<VariableDescriptor> properties = getPropertyGroups().get(name);
|
||||
ReceiverDescriptor receiverParameter = variableDescriptor.getReceiverParameter();
|
||||
for (VariableDescriptor oldProperty : properties) {
|
||||
@@ -377,7 +378,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForRedeclaration(String name, DeclarationDescriptor classifierDescriptor) {
|
||||
private void checkForRedeclaration(@NotNull Name name, DeclarationDescriptor classifierDescriptor) {
|
||||
DeclarationDescriptor originalDescriptor = getVariableClassOrNamespaceDescriptors().get(name);
|
||||
if (originalDescriptor != null) {
|
||||
redeclarationHandler.handleRedeclaration(originalDescriptor, classifierDescriptor);
|
||||
@@ -385,10 +386,10 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||
Map<Name, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||
DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name);
|
||||
if (descriptor instanceof ClassifierDescriptor) return (ClassifierDescriptor) descriptor;
|
||||
|
||||
@@ -399,7 +400,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return getObjectDescriptorsMap().get(name);
|
||||
}
|
||||
|
||||
@@ -413,7 +414,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||
Map<Name, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||
DeclarationDescriptor oldValue = variableClassOrNamespaceDescriptors.put(namespaceDescriptor.getName(), namespaceDescriptor);
|
||||
if (oldValue != null) {
|
||||
redeclarationHandler.handleRedeclaration(oldValue, namespaceDescriptor);
|
||||
@@ -423,17 +424,17 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getDeclaredNamespace(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
Map<String, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||
Map<Name, DeclarationDescriptor> variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors();
|
||||
DeclarationDescriptor namespaceDescriptor = variableClassOrNamespaceDescriptors.get(name);
|
||||
if (namespaceDescriptor instanceof NamespaceDescriptor) return (NamespaceDescriptor) namespaceDescriptor;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
NamespaceDescriptor declaredNamespace = getDeclaredNamespace(name);
|
||||
@@ -480,18 +481,18 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
|
||||
// @SuppressWarnings({"NullableProblems"})
|
||||
@NotNull
|
||||
private Map<String, PropertyDescriptor> getPropertyDescriptorsByFieldNames() {
|
||||
private Map<Name, PropertyDescriptor> getPropertyDescriptorsByFieldNames() {
|
||||
if (propertyDescriptorsByFieldNames == null) {
|
||||
propertyDescriptorsByFieldNames = new HashMap<String, PropertyDescriptor>();
|
||||
propertyDescriptorsByFieldNames = new HashMap<Name, PropertyDescriptor>();
|
||||
}
|
||||
return propertyDescriptorsByFieldNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
|
||||
checkMayRead();
|
||||
|
||||
if (!fieldName.startsWith("$")) {
|
||||
if (!fieldName.getName().startsWith("$")) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@@ -531,7 +532,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Multimap<String, DeclarationDescriptor> getDeclaredDescriptorsAccessibleBySimpleName() {
|
||||
public Multimap<Name, DeclarationDescriptor> getDeclaredDescriptorsAccessibleBySimpleName() {
|
||||
return declaredDescriptorsAccessibleBySimpleName;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-10
@@ -20,6 +20,7 @@ import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -124,7 +125,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
Set<VariableDescriptor> properties = Sets.newLinkedHashSet();
|
||||
@@ -135,7 +136,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableDescriptor getLocalVariable(@NotNull String name) {
|
||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
// Meaningful lookup goes here
|
||||
@@ -150,7 +151,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
if (getImports().isEmpty()) {
|
||||
@@ -164,7 +165,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
for (JetScope imported : getImports()) {
|
||||
@@ -177,7 +178,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
for (JetScope imported : getImports()) {
|
||||
@@ -190,7 +191,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
for (JetScope imported : getImports()) {
|
||||
@@ -213,7 +214,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
public void importClassifierAlias(@NotNull Name importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
getCurrentIndividualImportScope().addClassifierAlias(importedClassifierName, classifierDescriptor);
|
||||
@@ -221,21 +222,21 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
|
||||
|
||||
@Override
|
||||
public void importNamespaceAlias(@NotNull String aliasName, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
public void importNamespaceAlias(@NotNull Name aliasName, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
getCurrentIndividualImportScope().addNamespaceAlias(aliasName, namespaceDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importFunctionAlias(@NotNull String aliasName, @NotNull FunctionDescriptor functionDescriptor) {
|
||||
public void importFunctionAlias(@NotNull Name aliasName, @NotNull FunctionDescriptor functionDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
getCurrentIndividualImportScope().addFunctionAlias(aliasName, functionDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importVariableAlias(@NotNull String aliasName, @NotNull VariableDescriptor variableDescriptor) {
|
||||
public void importVariableAlias(@NotNull Name aliasName, @NotNull VariableDescriptor variableDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
getCurrentIndividualImportScope().addVariableAlias(aliasName, variableDescriptor);
|
||||
|
||||
+14
-13
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -42,7 +43,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
|
||||
checkMayRead();
|
||||
|
||||
return writableWorker.getPropertyByFieldReference(fieldName);
|
||||
@@ -74,7 +75,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
Set<FunctionDescriptor> result = Sets.newLinkedHashSet();
|
||||
@@ -90,7 +91,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
Set<VariableDescriptor> properties = Sets.newLinkedHashSet();
|
||||
@@ -102,7 +103,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public VariableDescriptor getLocalVariable(@NotNull String name) {
|
||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
VariableDescriptor variable = writableWorker.getLocalVariable(name);
|
||||
@@ -116,7 +117,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
NamespaceDescriptor namespace = writableWorker.getNamespace(name);
|
||||
@@ -130,7 +131,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
ClassifierDescriptor classifier = writableWorker.getClassifier(name);
|
||||
@@ -143,7 +144,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
ClassDescriptor objectDescriptor = writableWorker.getObjectDescriptor(name);
|
||||
@@ -217,28 +218,28 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
public void addClassifierAlias(@NotNull Name name, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
writableWorker.addClassifierAlias(name, classifierDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
public void addNamespaceAlias(@NotNull Name name, @NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
writableWorker.addNamespaceAlias(name, namespaceDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariableAlias(@NotNull String name, @NotNull VariableDescriptor variableDescriptor) {
|
||||
public void addVariableAlias(@NotNull Name name, @NotNull VariableDescriptor variableDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
writableWorker.addVariableAlias(name, variableDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionAlias(@NotNull String name, @NotNull FunctionDescriptor functionDescriptor) {
|
||||
public void addFunctionAlias(@NotNull Name name, @NotNull FunctionDescriptor functionDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
writableWorker.addFunctionAlias(name, functionDescriptor);
|
||||
@@ -253,7 +254,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getDeclaredNamespace(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
return writableWorker.getDeclaredNamespace(name);
|
||||
@@ -261,7 +262,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Multimap<String, DeclarationDescriptor> getDeclaredDescriptorsAccessibleBySimpleName() {
|
||||
public Multimap<Name, DeclarationDescriptor> getDeclaredDescriptorsAccessibleBySimpleName() {
|
||||
return writableWorker.getDeclaredDescriptorsAccessibleBySimpleName();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.error.ErrorSimpleFunctionDescriptorImpl;
|
||||
@@ -33,7 +34,7 @@ import java.util.*;
|
||||
*/
|
||||
public class ErrorUtils {
|
||||
|
||||
private static final ModuleDescriptor ERROR_MODULE = new ModuleDescriptor("<ERROR MODULE>");
|
||||
private static final ModuleDescriptor ERROR_MODULE = new ModuleDescriptor(Name.special("<ERROR MODULE>"));
|
||||
|
||||
|
||||
public static class ErrorScope implements JetScope {
|
||||
@@ -45,12 +46,12 @@ public class ErrorUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
return ERROR_CLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull String name) {
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return ERROR_CLASS;
|
||||
}
|
||||
|
||||
@@ -62,17 +63,17 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull String name) {
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
return ERROR_PROPERTY_GROUP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableDescriptor getLocalVariable(@NotNull String name) {
|
||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||
return ERROR_PROPERTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull String name) {
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
return null; // TODO : review
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ public class ErrorUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
|
||||
return null; // TODO : review
|
||||
}
|
||||
|
||||
@@ -117,7 +118,7 @@ public class ErrorUtils {
|
||||
|
||||
}
|
||||
|
||||
private static final ClassDescriptorImpl ERROR_CLASS = new ClassDescriptorImpl(ERROR_MODULE, Collections.<AnnotationDescriptor>emptyList(), "<ERROR CLASS>") {
|
||||
private static final ClassDescriptorImpl ERROR_CLASS = new ClassDescriptorImpl(ERROR_MODULE, Collections.<AnnotationDescriptor>emptyList(), Name.special("<ERROR CLASS>")) {
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<ConstructorDescriptor> getConstructors() {
|
||||
@@ -159,7 +160,7 @@ public class ErrorUtils {
|
||||
false,
|
||||
null,
|
||||
ReceiverDescriptor.NO_RECEIVER,
|
||||
"<ERROR PROPERTY>",
|
||||
Name.special("<ERROR PROPERTY>"),
|
||||
ERROR_PROPERTY_TYPE,
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
private static final Set<VariableDescriptor> ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY);
|
||||
@@ -198,7 +199,7 @@ public class ErrorUtils {
|
||||
functionDescriptor,
|
||||
i,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
"<ERROR VALUE_PARAMETER>",
|
||||
Name.special("<ERROR VALUE_PARAMETER>"),
|
||||
true,
|
||||
ERROR_PARAMETER_TYPE,
|
||||
false,
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.types;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
|
||||
import java.util.List;
|
||||
@@ -29,11 +30,11 @@ import java.util.List;
|
||||
* @author abreslav
|
||||
*/
|
||||
public class NamespaceType implements JetType {
|
||||
private final String name;
|
||||
private final Name name;
|
||||
@NotNull
|
||||
private final JetScope memberScope;
|
||||
|
||||
public NamespaceType(@NotNull String name, @NotNull JetScope memberScope) {
|
||||
public NamespaceType(@NotNull Name name, @NotNull JetScope memberScope) {
|
||||
this.name = name;
|
||||
this.memberScope = memberScope;
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -33,7 +34,7 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI
|
||||
private final ErrorUtils.ErrorScope ownerScope;
|
||||
|
||||
public ErrorSimpleFunctionDescriptorImpl(ErrorUtils.ErrorScope ownerScope) {
|
||||
super(ErrorUtils.getErrorClass(), Collections.<AnnotationDescriptor>emptyList(), "<ERROR FUNCTION>", Kind.DECLARATION);
|
||||
super(ErrorUtils.getErrorClass(), Collections.<AnnotationDescriptor>emptyList(), Name.special("<ERROR FUNCTION>"), Kind.DECLARATION);
|
||||
this.ownerScope = ownerScope;
|
||||
}
|
||||
|
||||
|
||||
+17
-16
@@ -37,6 +37,7 @@ import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.constants.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
@@ -76,7 +77,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
return type; // TODO : Extensions to this
|
||||
}
|
||||
|
||||
private JetType lookupNamespaceOrClassObject(JetSimpleNameExpression expression, String referencedName, ExpressionTypingContext context) {
|
||||
private JetType lookupNamespaceOrClassObject(JetSimpleNameExpression expression, Name referencedName, ExpressionTypingContext context) {
|
||||
ClassifierDescriptor classifier = context.scope.getClassifier(referencedName);
|
||||
if (classifier != null) {
|
||||
JetType classObjectType = classifier.getClassObjectType();
|
||||
@@ -111,7 +112,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
return result[0];
|
||||
}
|
||||
|
||||
protected boolean furtherNameLookup(@NotNull JetSimpleNameExpression expression, @NotNull String referencedName, @NotNull JetType[] result, ExpressionTypingContext context) {
|
||||
protected boolean furtherNameLookup(@NotNull JetSimpleNameExpression expression, @NotNull Name referencedName, @NotNull JetType[] result, ExpressionTypingContext context) {
|
||||
if (context.namespacesAllowed) {
|
||||
result[0] = lookupNamespaceType(expression, referencedName, context);
|
||||
return result[0] != null;
|
||||
@@ -125,7 +126,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected NamespaceType lookupNamespaceType(@NotNull JetSimpleNameExpression expression, @NotNull String referencedName, ExpressionTypingContext context) {
|
||||
protected NamespaceType lookupNamespaceType(@NotNull JetSimpleNameExpression expression, @NotNull Name referencedName, ExpressionTypingContext context) {
|
||||
NamespaceDescriptor namespace = context.scope.getNamespace(referencedName);
|
||||
if (namespace == null) {
|
||||
return null;
|
||||
@@ -569,7 +570,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (wholeExpressionValue == null && receiverValue != null && !(receiverValue instanceof ErrorValue) && receiverValue.getValue() instanceof Number
|
||||
&& JetStandardLibrary.getInstance().getNumber() == declarationDescriptor) {
|
||||
Number value = (Number) receiverValue.getValue();
|
||||
String referencedName = selectorExpression.getReferencedName();
|
||||
Name referencedName = selectorExpression.getReferencedNameAsName();
|
||||
if (OperatorConventions.NUMBER_CONVERSIONS.contains(referencedName)) {
|
||||
if (DOUBLE.equals(referencedName)) {
|
||||
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new DoubleValue(value.doubleValue()));
|
||||
@@ -630,7 +631,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
ExpressionTypingContext newContext = receiver.exists()
|
||||
? context.replaceScope(receiver.getType().getMemberScope())
|
||||
: context;
|
||||
JetType jetType = lookupNamespaceOrClassObject(nameExpression, nameExpression.getReferencedName(), newContext);
|
||||
JetType jetType = lookupNamespaceOrClassObject(nameExpression, nameExpression.getReferencedNameAsName(), newContext);
|
||||
if (jetType == null) {
|
||||
context.trace.report(UNRESOLVED_REFERENCE.on(nameExpression));
|
||||
}
|
||||
@@ -713,7 +714,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
// Conventions for unary operations
|
||||
String name = OperatorConventions.UNARY_OPERATION_NAMES.get(operationType);
|
||||
Name name = OperatorConventions.UNARY_OPERATION_NAMES.get(operationType);
|
||||
if (name == null) {
|
||||
context.trace.report(UNSUPPORTED.on(operationSign, "visitUnaryExpression"));
|
||||
return null;
|
||||
@@ -745,13 +746,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType result;
|
||||
if (operationType == JetTokens.PLUSPLUS || operationType == JetTokens.MINUSMINUS) {
|
||||
if (JetTypeChecker.INSTANCE.isSubtypeOf(returnType, JetStandardClasses.getUnitType())) {
|
||||
result = ErrorUtils.createErrorType(JetStandardClasses.UNIT_ALIAS);
|
||||
result = ErrorUtils.createErrorType(JetStandardClasses.UNIT_ALIAS.getName());
|
||||
context.trace.report(INC_DEC_SHOULD_NOT_RETURN_UNIT.on(operationSign));
|
||||
}
|
||||
else {
|
||||
JetType receiverType = receiver.getType();
|
||||
if (!JetTypeChecker.INSTANCE.isSubtypeOf(returnType, receiverType)) {
|
||||
context.trace.report(RESULT_TYPE_MISMATCH.on(operationSign, name, receiverType, returnType));
|
||||
context.trace.report(RESULT_TYPE_MISMATCH.on(operationSign, name.getName(), receiverType, returnType));
|
||||
}
|
||||
else {
|
||||
context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression);
|
||||
@@ -816,7 +817,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType result = null;
|
||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||
if (operationType == JetTokens.IDENTIFIER) {
|
||||
String referencedName = operationSign.getReferencedName();
|
||||
Name referencedName = operationSign.getReferencedNameAsName();
|
||||
if (referencedName != null) {
|
||||
result = getTypeForBinaryCall(context.scope, referencedName, context, expression);
|
||||
}
|
||||
@@ -831,7 +832,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
result = visitAssignmentOperation(expression, contextWithExpectedType);
|
||||
}
|
||||
else if (OperatorConventions.COMPARISON_OPERATIONS.contains(operationType)) {
|
||||
JetType compareToReturnType = getTypeForBinaryCall(context.scope, "compareTo", context, expression);
|
||||
JetType compareToReturnType = getTypeForBinaryCall(context.scope, Name.identifier("compareTo"), context, expression);
|
||||
if (compareToReturnType != null) {
|
||||
TypeConstructor constructor = compareToReturnType.getConstructor();
|
||||
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||
@@ -847,11 +848,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
else {
|
||||
JetType booleanType = JetStandardLibrary.getInstance().getBooleanType();
|
||||
if (OperatorConventions.EQUALS_OPERATIONS.contains(operationType)) {
|
||||
String name = "equals";
|
||||
Name name = Name.identifier("equals");
|
||||
if (right != null) {
|
||||
ExpressionReceiver receiver = ExpressionTypingUtils.safeGetExpressionReceiver(facade, left, context.replaceScope(context.scope));
|
||||
OverloadResolutionResults<FunctionDescriptor> resolutionResults = context.resolveExactSignature(
|
||||
receiver, "equals",
|
||||
receiver, name,
|
||||
Collections.singletonList(JetStandardClasses.getNullableAnyType()));
|
||||
if (resolutionResults.isSuccess()) {
|
||||
FunctionDescriptor equals = resolutionResults.getResultingCall().getResultingDescriptor();
|
||||
@@ -926,7 +927,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
public boolean checkInExpression(JetElement callElement, @NotNull JetSimpleNameExpression operationSign, @Nullable JetExpression left, @NotNull JetExpression right, ExpressionTypingContext context) {
|
||||
String name = "contains";
|
||||
Name name = Name.identifier("contains");
|
||||
ExpressionReceiver receiver = safeGetExpressionReceiver(facade, right, context.replaceExpectedType(NO_EXPECTED_TYPE));
|
||||
OverloadResolutionResults<FunctionDescriptor> resolutionResult = context.resolveCallWithGivenNameToDescriptor(
|
||||
CallMaker.makeCallWithExpressions(callElement, receiver, null, operationSign, Collections.singletonList(left)),
|
||||
@@ -985,13 +986,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetType getTypeForBinaryCall(JetScope scope, String name, ExpressionTypingContext context, JetBinaryExpression binaryExpression) {
|
||||
public JetType getTypeForBinaryCall(JetScope scope, Name name, ExpressionTypingContext context, JetBinaryExpression binaryExpression) {
|
||||
ExpressionReceiver receiver = safeGetExpressionReceiver(facade, binaryExpression.getLeft(), context.replaceScope(scope));
|
||||
return OverloadResolutionResultsUtil.getResultType(getResolutionResultsForBinaryCall(scope, name, context, binaryExpression, receiver));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
/*package*/ OverloadResolutionResults<FunctionDescriptor> getResolutionResultsForBinaryCall(JetScope scope, String name, ExpressionTypingContext context, JetBinaryExpression binaryExpression, ExpressionReceiver receiver) {
|
||||
/*package*/ OverloadResolutionResults<FunctionDescriptor> getResolutionResultsForBinaryCall(JetScope scope, Name name, ExpressionTypingContext context, JetBinaryExpression binaryExpression, ExpressionReceiver receiver) {
|
||||
// ExpressionReceiver receiver = safeGetExpressionReceiver(facade, binaryExpression.getLeft(), context.replaceScope(scope));
|
||||
return context.replaceScope(scope).resolveCallWithGivenNameToDescriptor(
|
||||
CallMaker.makeCall(receiver, binaryExpression),
|
||||
@@ -1100,7 +1101,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
? CallMaker.makeArrayGetCall(receiver, arrayAccessExpression)
|
||||
: CallMaker.makeArraySetCall(receiver, arrayAccessExpression, rightHandSide),
|
||||
arrayAccessExpression,
|
||||
isGet ? "get" : "set");
|
||||
Name.identifier(isGet ? "get" : "set"));
|
||||
if (!functionResults.isSuccess()) {
|
||||
traceForResolveResult.report(isGet ? NO_GET_METHOD.on(arrayAccessExpression) : NO_SET_METHOD.on(arrayAccessExpression));
|
||||
return null;
|
||||
|
||||
+3
-2
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.ObservableBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalyzer;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -130,7 +131,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||
JetTypeReference receiverTypeRef = functionLiteral.getReceiverTypeRef();
|
||||
SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl(
|
||||
context.scope.getContainingDeclaration(), Collections.<AnnotationDescriptor>emptyList(), "<anonymous>", CallableMemberDescriptor.Kind.DECLARATION);
|
||||
context.scope.getContainingDeclaration(), Collections.<AnnotationDescriptor>emptyList(), Name.special("<anonymous>"), CallableMemberDescriptor.Kind.DECLARATION);
|
||||
|
||||
List<ValueParameterDescriptor> valueParameterDescriptors = createValueParameterDescriptors(context, functionLiteral, functionDescriptor, functionTypeExpected);
|
||||
|
||||
@@ -172,7 +173,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (functionTypeExpected && !hasDeclaredValueParameters && expectedValueParameters.size() == 1) {
|
||||
ValueParameterDescriptor valueParameterDescriptor = expectedValueParameters.get(0);
|
||||
ValueParameterDescriptor it = new ValueParameterDescriptorImpl(
|
||||
functionDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "it", false, valueParameterDescriptor.getType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
|
||||
functionDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), Name.identifier("it"), false, valueParameterDescriptor.getType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
|
||||
);
|
||||
valueParameterDescriptors.add(it);
|
||||
context.trace.record(AUTO_CREATED_IT, it);
|
||||
|
||||
+7
-6
@@ -34,6 +34,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.calls.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
@@ -273,7 +274,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
VariableDescriptor olderVariable = context.scope.getLocalVariable(variableDescriptor.getName());
|
||||
if (olderVariable != null && DescriptorUtils.isLocal(context.scope.getContainingDeclaration(), olderVariable)) {
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor);
|
||||
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName()));
|
||||
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +294,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetExpression loopRangeExpression = loopRange.getExpression();
|
||||
|
||||
// Make a fake call loopRange.iterator(), and try to resolve it
|
||||
String iterator = "iterator";
|
||||
Name iterator = Name.identifier("iterator");
|
||||
OverloadResolutionResults<FunctionDescriptor> iteratorResolutionResults = resolveFakeCall(loopRange, context, iterator);
|
||||
|
||||
// We allow the loop range to be null (nothing happens), so we make the receiver type non-null
|
||||
@@ -326,7 +327,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
context.trace.record(LOOP_RANGE_HAS_NEXT, loopRange.getExpression(), hasNextFunctionSupported ? hasNextFunction : hasNextProperty);
|
||||
}
|
||||
|
||||
OverloadResolutionResults<FunctionDescriptor> nextResolutionResults = context.resolveExactSignature(new TransientReceiver(iteratorType), "next", Collections.<JetType>emptyList());
|
||||
OverloadResolutionResults<FunctionDescriptor> nextResolutionResults = context.resolveExactSignature(new TransientReceiver(iteratorType), Name.identifier("next"), Collections.<JetType>emptyList());
|
||||
if (nextResolutionResults.isAmbiguity()) {
|
||||
context.trace.report(NEXT_AMBIGUITY.on(loopRangeExpression));
|
||||
}
|
||||
@@ -356,7 +357,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
public static OverloadResolutionResults<FunctionDescriptor> resolveFakeCall(ExpressionReceiver receiver,
|
||||
ExpressionTypingContext context, String name) {
|
||||
ExpressionTypingContext context, Name name) {
|
||||
JetReferenceExpression fake = JetPsiFactory.createSimpleName(context.expressionTypingServices.getProject(), "fake");
|
||||
BindingTrace fakeTrace = new BindingTraceContext();
|
||||
Call call = CallMaker.makeCall(fake, receiver, null, fake, Collections.<ValueArgument>emptyList());
|
||||
@@ -365,7 +366,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
@Nullable
|
||||
private static FunctionDescriptor checkHasNextFunctionSupport(@NotNull JetExpression loopRange, @NotNull JetType iteratorType, ExpressionTypingContext context) {
|
||||
OverloadResolutionResults<FunctionDescriptor> hasNextResolutionResults = context.resolveExactSignature(new TransientReceiver(iteratorType), "hasNext", Collections.<JetType>emptyList());
|
||||
OverloadResolutionResults<FunctionDescriptor> hasNextResolutionResults = context.resolveExactSignature(new TransientReceiver(iteratorType), Name.identifier("hasNext"), Collections.<JetType>emptyList());
|
||||
if (hasNextResolutionResults.isAmbiguity()) {
|
||||
context.trace.report(HAS_NEXT_FUNCTION_AMBIGUITY.on(loopRange));
|
||||
}
|
||||
@@ -384,7 +385,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
@Nullable
|
||||
private static VariableDescriptor checkHasNextPropertySupport(@NotNull JetExpression loopRange, @NotNull JetType iteratorType, ExpressionTypingContext context) {
|
||||
VariableDescriptor hasNextProperty = DescriptorUtils.filterNonExtensionProperty(iteratorType.getMemberScope().getProperties("hasNext"));
|
||||
VariableDescriptor hasNextProperty = DescriptorUtils.filterNonExtensionProperty(iteratorType.getMemberScope().getProperties(Name.identifier("hasNext")));
|
||||
if (hasNextProperty == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+4
-3
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.calls.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.calls.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -149,12 +150,12 @@ public class ExpressionTypingContext {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithGivenName(@NotNull Call call, @NotNull JetReferenceExpression functionReference, @NotNull String name) {
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithGivenName(@NotNull Call call, @NotNull JetReferenceExpression functionReference, @NotNull Name name) {
|
||||
return expressionTypingServices.getCallResolver().resolveCallWithGivenName(makeResolutionContext(call), functionReference, name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithGivenNameToDescriptor(@NotNull Call call, @NotNull JetReferenceExpression functionReference, @NotNull String name) {
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithGivenNameToDescriptor(@NotNull Call call, @NotNull JetReferenceExpression functionReference, @NotNull Name name) {
|
||||
return resolveCallWithGivenName(call, functionReference, name);
|
||||
// return results == null ? null : results.getResultingDescriptor();
|
||||
}
|
||||
@@ -172,7 +173,7 @@ public class ExpressionTypingContext {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull ReceiverDescriptor receiver, @NotNull String name, @NotNull List<JetType> parameterTypes) {
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull ReceiverDescriptor receiver, @NotNull Name name, @NotNull List<JetType> parameterTypes) {
|
||||
return expressionTypingServices.getCallResolver().resolveExactSignature(scope, receiver, name, parameterTypes);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user